-
Notifications
You must be signed in to change notification settings - Fork 3
Orchestrator #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Orchestrator #19
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
1ea8430
v2
devzeebo fb8e492
v3
devzeebo 1ec54d0
ts orchestrator
devzeebo dbb06b2
bifrost plugin
devzeebo 9d70c7e
v2
devzeebo e96a601
update to simplify the interfaces and fix up the tests
devzeebo 5a2de1b
tests are tsc'd
devzeebo 262fe9e
prettier and oxlint
devzeebo 76b2b74
move prds
devzeebo 1d62915
prettier
devzeebo f367f51
prettier
devzeebo cbfdb23
workspaces
devzeebo baeb93b
clean up
devzeebo 388244d
create bifrost-task-source prd
devzeebo 64cd301
update oxlint
devzeebo 0848277
pulling the linting up to the root
devzeebo 4bce8d1
working on linting hook
devzeebo 5b99fc3
hook block
devzeebo 63bd183
lint hook
devzeebo e7054c3
lint fix
devzeebo f968ae4
linting
devzeebo 5c79200
test
devzeebo 5d68460
fix lint and format
devzeebo 29eb332
tsc
devzeebo 102fc0a
build
devzeebo e89861e
new types
devzeebo 7c13e10
splitting out the builds
devzeebo 122ae12
lint/test/build fixes
devzeebo b2fd78b
fix more
devzeebo 06bc9c4
fix build
devzeebo bbda4fe
added wanted for ts skill
devzeebo 8031b41
claude engine
devzeebo aafddd2
bifrost-ai
devzeebo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| name: typescript-quality | ||
| description: | | ||
| Fixes lint and tests, and is only allowed to use read and write commands. Hooks run the tests | ||
| isolation: none | ||
| tools: Edit, Write, Read | ||
| model: glm-4.5-air | ||
| hooks: | ||
| SessionStart: | ||
| - hooks: | ||
| - type: command | ||
| command: $CLAUDE_PROJECT_DIR/.claude/hooks/dispatch typescript quality common | ||
| Stop: | ||
| - hooks: | ||
| - type: command | ||
| command: $CLAUDE_PROJECT_DIR/.claude/hooks/dispatch typescript quality common | ||
| --- | ||
|
|
||
| Fix the listed lint and test errors. When you fix them, quit. Do not look for more errors. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| INPUT=$(cat) | ||
|
|
||
| escape_json() { | ||
| JSON=$(echo -n "$1" | jq -Rca . | tail -c +2 | head -c -2) | ||
|
|
||
| echo "$JSON" | ||
| } | ||
|
|
||
| get_field() { | ||
| local field="$1" | ||
| local json="${2:-$INPUT}" | ||
| echo "$json" | jq -r ".$field // empty" 2>/dev/null || echo "" | ||
| } | ||
|
|
||
| deny() { | ||
| JSON=$(escape_json "$1") | ||
| echo '{"hookSpecificOutput":{"hookEventName":"'$(get_field hook_event_name)'","permissionDecision":"deny","permissionDecisionReason":"'$JSON'"}}' | ||
|
|
||
| exit 2 | ||
| } | ||
|
|
||
| block() { | ||
| JSON=$(escape_json "$1") | ||
| echo -e '{"hookSpecificOutput":{"hookEventName":"'$(get_field hook_event_name)'","decision":"block","reason":"'$JSON'"}}' >&2 | ||
|
|
||
| exit 2 | ||
| } | ||
|
|
||
| additionalContext() { | ||
| JSON=$(escape_json "$1") | ||
| echo -e '{"hookSpecificOutput":{"hookEventName":"'$(get_field hook_event_name)'","additionalContext":"'$JSON'"}}' | ||
|
|
||
| exit 0 | ||
| } | ||
|
|
||
| sentinel() { | ||
| SESSION_ID=$(get_field "session_id") | ||
|
|
||
| mkdir -p /tmp/.claude | ||
|
|
||
| echo "/tmp/.claude/$SESSION_ID.$1.sentinel" | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| export -f get_field | ||
| export -f deny | ||
| export -f block | ||
| export -f sentinel | ||
| export -f additionalContext | ||
| export -f escape_json | ||
| export INPUT | ||
|
|
||
| $CLAUDE_PROJECT_DIR/.claude/skills/$1/hooks/${3:-$(get_field hook_event_name)}.d/$2 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| { | ||
| "hooks": { | ||
| "PreToolUse": [ | ||
| { | ||
| "matcher": "Bash", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "if": "Bash(npx *)", | ||
| "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/dispatch node ban-npx" | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "Stop": [ | ||
| { | ||
| "matcher": "*", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/dispatch typescript lint-oxlint" | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "PostToolUse": [ | ||
| { | ||
| "matcher": "Edit|Write", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/dispatch typescript format" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "matcher": "Edit|Write", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/dispatch typescript lint-capture" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| --- | ||
| name: node | ||
| description: | | ||
| Use when working with Node.js, npm, package.json, or npx. Alternative package managers | ||
| like Yarn and pnpm as well as monorepo tools like nx, yarn, or turborepo should also use this skill | ||
| --- | ||
|
|
||
| # Node.js | ||
|
|
||
| ## Invoking scripts | ||
|
|
||
| Prefer explicit `scripts` entries over `npx`. Write scripts to package.json: | ||
|
|
||
| ```json | ||
| "scripts": { | ||
| "test": "vitest run", | ||
| "dev": "vitest --watch", | ||
| "build": "vite build" | ||
| } | ||
| ``` | ||
|
|
||
| Reason: Enforces consistent flags, prevents drift, works better in monorepos. | ||
|
|
||
| ## Monorepos | ||
|
|
||
| Use native npm workspaces unless user explicitly chose otherwise (turborepo, nx, pnpm). | ||
|
|
||
| **Workspace pattern** ([examples/workspace-setup](examples/workspace-setup.md)): | ||
| - Root `workspaces: ["packages/**"]` in package.json | ||
| - Workspace scripts: `npm run build -ws`, `npm run test -ws` | ||
| - Local deps use workspace names: `@bifrost-ai/core` | ||
|
|
||
| **TypeScript project references** ([examples/tsconfig-references](examples/tsconfig-references.md)): | ||
| - Base config with `composite: true` | ||
| - Package configs extend base, declare `references` | ||
| - Enables cross-package type checking, faster builds | ||
|
|
||
| **Build** ([examples/vite-build](examples/vite-build.md)): | ||
| - Vite for fast builds | ||
| - `vite-plugin-dts` for .d.ts generation | ||
| - `external:` workspace deps in rollupOptions | ||
|
|
||
| **Testing** ([examples/vitest-setup](examples/vitest-setup.md)): | ||
| - Vitest config per workspace or root | ||
| - `*.spec.ts` naming, exclude from builds | ||
| - Root script runs all: `"test": "vitest run"` | ||
|
|
||
| ## See also | ||
|
|
||
| - [TypeScript config](examples/tsconfig-references.md) - Project references pattern | ||
| - [Vite build](examples/vite-build.md) - Library build with deps | ||
| - [Vitest setup](examples/vitest-setup.md) - Test config for monorepos | ||
| - [Workspace setup](examples/workspace-setup.md) - Complete monorepo structure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # TypeScript Project References | ||
|
|
||
| Enables cross-package type checking, faster incremental builds. | ||
|
|
||
| Root tsconfig.base.json: | ||
|
|
||
| ```json | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES2022", | ||
| "module": "nodenext", | ||
| "lib": ["ESNext"], | ||
| "types": ["node"], | ||
| "moduleResolution": "bundler", | ||
| "strict": true, | ||
| "esModuleInterop": true, | ||
| "skipLibCheck": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "declaration": true, | ||
| "declarationMap": true, | ||
| "sourceMap": true, | ||
| "composite": true | ||
| }, | ||
| "exclude": ["node_modules", "dist"] | ||
| } | ||
| ``` | ||
|
|
||
| Package tsconfig.json (packages/core/tsconfig.json): | ||
|
|
||
| ```json | ||
| { | ||
| "extends": "../../tsconfig.base.json", | ||
| "compilerOptions": { | ||
| "outDir": "./dist", | ||
| "rootDir": "./src" | ||
| }, | ||
| "references": [ | ||
| { "path": "../another-monorepo-package" } | ||
| ], | ||
| "include": ["src/**/*"], | ||
| "exclude": ["node_modules", "dist", "**/*.spec.ts", "**/*.test.ts"] | ||
| } | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Vite Build for Libraries | ||
|
|
||
| Fast builds, TypeScript declarations, workspace deps. | ||
|
|
||
| vite.config.ts: | ||
|
|
||
| ```ts | ||
| import { defineConfig } from 'vite' | ||
| import dts from 'vite-plugin-dts' | ||
| import pkg from './package.json' | ||
|
|
||
| export default defineConfig({ | ||
| plugins: [ | ||
| dts({ | ||
| tsconfigPath: './tsconfig.json', | ||
| rollupTypes: true, | ||
| }), | ||
| ], | ||
| build: { | ||
| lib: { | ||
| entry: './src/index.ts', | ||
| formats: ['es'], | ||
| fileName: 'index', | ||
| }, | ||
| rollupOptions: { | ||
| external: [ | ||
| '@my-monorepo/utils', | ||
| ...Object.keys(pkg.dependencies || {}), | ||
| ...Object.keys(pkg.peerDependencies || {}), | ||
| ], | ||
| output: { | ||
| globals: { | ||
| '@my-monorepo/utils': 'Utils', | ||
| }, | ||
| }, | ||
| }, | ||
| target: 'esnext', | ||
| emptyOutDir: true, | ||
| }, | ||
| }) | ||
| ``` | ||
|
|
||
| **Key points:** | ||
| - `external:` workspace deps + all deps | ||
| - `rollupTypes: true` bundles .d.ts files | ||
| - `formats: ['es']` for ESM-only packages |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Vitest Testing Setup | ||
|
|
||
| Root vitest.config.ts: | ||
|
|
||
| ```ts | ||
| import { defineConfig } from 'vitest/config' | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| globals: true, | ||
| environment: 'node', | ||
| }, | ||
| }) | ||
| ``` | ||
|
|
||
| Test file naming: | ||
| - `*.spec.ts` for unit tests | ||
| - Exclude from tsconfig `exclude` array | ||
|
|
||
| Usage: | ||
|
|
||
| ```bash | ||
| npm run test # run all tests once | ||
| npm run dev # watch mode | ||
| npm run test -- -ui # vitest ui (if installed) | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Npm Workspace Monorepo Setup | ||
|
|
||
| Root package.json: | ||
|
|
||
| ```json | ||
| { | ||
| "name": "my-monorepo", | ||
| "private": true, | ||
| "type": "module", | ||
| "workspaces": ["packages/**"], | ||
| "scripts": { | ||
| "build": "npm run build -ws", | ||
| "test": "vitest run", | ||
| "dev": "vitest --watch" | ||
| }, | ||
| "devDependencies": { | ||
| "typescript": "^6.0.3", | ||
| "vite": "^8.0.11", | ||
| "vite-plugin-dts": "^5.0.0", | ||
| "vitest": "^4.1.5" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Package (packages/core/package.json): | ||
|
|
||
| ```json | ||
| { | ||
| "name": "@my-monorepo/core", | ||
| "version": "1.0.0", | ||
| "type": "module", | ||
| "main": "./dist/index.js", | ||
| "types": "./dist/index.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.js" | ||
| } | ||
| }, | ||
| "scripts": { | ||
| "build": "vite build" | ||
| } | ||
| } | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/bin/bash | ||
| # if: Bash(npx *) | ||
| ### | ||
|
|
||
| deny 'npx is forbidden. use a script defined in package.json and `npm run <script-name>` instead.'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # Package.json | ||
|
|
||
| 1. npm monorepos should ban edits that include 'workspace:*' | ||
| 2. monorepo'd projects should ban devDependencies in the workspace packages. put them in the root | ||
| 3. you should not have multiple versions of dependencies across a monorepo. share them | ||
| 4. must run ncu and use latest versions |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shell/JSON injection: all three output functions are vulnerable.
The
deny(),block(), andadditionalContext()functions useescape_json()but then concatenate the result into a shell string literal. This approach is still vulnerable:$(get_field hook_event_name)contains"or other JSON metacharacters, it will produce malformed JSONescape_json()Use
jq -nwith--argflags to construct JSON safely:🛡️ Proposed fix for all three functions
deny() { - JSON=$(escape_json "$1") - echo '{"hookSpecificOutput":{"hookEventName":"'$(get_field hook_event_name)'","permissionDecision":"deny","permissionDecisionReason":"'$JSON'"}}' - + jq -n \ + --arg event "$(get_field hook_event_name)" \ + --arg reason "$1" \ + '{"hookSpecificOutput":{"hookEventName":$event,"permissionDecision":"deny","permissionDecisionReason":$reason}}' exit 2 } block() { - JSON=$(escape_json "$1") - echo -e '{"hookSpecificOutput":{"hookEventName":"'$(get_field hook_event_name)'","decision":"block","reason":"'$JSON'"}}' >&2 - + jq -n \ + --arg event "$(get_field hook_event_name)" \ + --arg reason "$1" \ + '{"hookSpecificOutput":{"hookEventName":$event,"decision":"block","reason":$reason}}' >&2 exit 2 } additionalContext() { - JSON=$(escape_json "$1") - echo -e '{"hookSpecificOutput":{"hookEventName":"'$(get_field hook_event_name)'","additionalContext":"'$JSON'"}}' - + jq -n \ + --arg event "$(get_field hook_event_name)" \ + --arg context "$1" \ + '{"hookSpecificOutput":{"hookEventName":$event,"additionalContext":$context}}' exit 0 }If this fix is applied, the
escape_json()function becomes unused and should be removed (or kept only if other code needs it).🤖 Prompt for AI Agents