@bonesofspring/ai-rules 0.2.65 → 0.2.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/README.md +21 -11
- package/bin/cli.js +9 -1
- package/bin/lib/engine-scripts.js +34 -7
- package/bin/lib/engine-upgrade.js +5 -2
- package/bin/lib/seed-ai-local-team.js +32 -3
- package/docs/OPENCODE-COMPATIBILITY.md +1 -0
- package/docs/OPENCODE.md +31 -10
- package/docs/TEAM-DB.md +54 -14
- package/docs/TOKEN-ECONOMY.md +110 -0
- package/docs/openapi/team-db.v1.json +5 -5
- package/package.json +16 -3
- package/presets/_shared/ai-local/scripts/dump-output.mjs +422 -0
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +3 -3
- package/presets/_shared/ai-local/scripts/team-db-tracker.mjs +2 -0
- package/presets/_shared/ai-local/scripts/team-db.mjs +82 -2
- package/presets/_shared/core/agent-team/agent-team-orchestrator.md +3 -1
- package/presets/_shared/core/architecture/feature-delivery-workflow.md +4 -0
- package/presets/_shared/core/quality/context-and-iteration.md +1 -0
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +9 -2
- package/presets/_shared/hooks/list-ai-local.mjs +17 -0
- package/presets/claude/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +9 -2
- package/presets/claude/android-kotlin/hooks/list-ai-local.mjs +17 -0
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/go/agents/task-analyst.md +1 -1
- package/presets/claude/go/hooks/chain-team-phases.sh +9 -2
- package/presets/claude/go/hooks/list-ai-local.mjs +17 -0
- package/presets/claude/go/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/ios-swift/agents/task-analyst.md +1 -1
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +9 -2
- package/presets/claude/ios-swift/hooks/list-ai-local.mjs +17 -0
- package/presets/claude/ios-swift/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/java/agents/task-analyst.md +1 -1
- package/presets/claude/java/hooks/chain-team-phases.sh +9 -2
- package/presets/claude/java/hooks/list-ai-local.mjs +17 -0
- package/presets/claude/java/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +9 -2
- package/presets/claude/mcp-ts/hooks/list-ai-local.mjs +17 -0
- package/presets/claude/mcp-ts/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/mol/agents/task-analyst.md +1 -1
- package/presets/claude/mol/hooks/chain-team-phases.sh +9 -2
- package/presets/claude/mol/hooks/list-ai-local.mjs +17 -0
- package/presets/claude/mol/rules/architecture/feature-delivery-workflow.md +4 -0
- package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/next/agents/ci-investigator.md +5 -2
- package/presets/claude/next/agents/debugger.md +5 -2
- package/presets/claude/next/agents/feature-developer.md +5 -2
- package/presets/claude/next/agents/task-analyst.md +1 -1
- package/presets/claude/next/commands/README.md +1 -1
- package/presets/claude/next/commands/task.md +1 -1
- package/presets/claude/next/hooks/chain-team-phases.sh +9 -2
- package/presets/claude/next/hooks/list-ai-local.mjs +17 -0
- package/presets/claude/next/rules/architecture/feature-delivery-workflow.md +8 -0
- package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/next/team/README.md +7 -3
- package/presets/claude/nuxt/agents/task-analyst.md +1 -1
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +9 -2
- package/presets/claude/nuxt/hooks/list-ai-local.mjs +17 -0
- package/presets/claude/nuxt/rules/architecture/feature-delivery-workflow.md +4 -0
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +9 -2
- package/presets/claude/php-hexagonal/hooks/list-ai-local.mjs +17 -0
- package/presets/claude/php-hexagonal/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/php-laravel/agents/task-analyst.md +1 -1
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +9 -2
- package/presets/claude/php-laravel/hooks/list-ai-local.mjs +17 -0
- package/presets/claude/php-laravel/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/claude/svelte/agents/task-analyst.md +1 -1
- package/presets/claude/svelte/hooks/chain-team-phases.sh +9 -2
- package/presets/claude/svelte/hooks/list-ai-local.mjs +17 -0
- package/presets/claude/svelte/rules/architecture/feature-delivery-workflow.md +4 -0
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +3 -1
- package/presets/cursor/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +9 -2
- package/presets/cursor/android-kotlin/hooks/list-ai-local.mjs +17 -0
- package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/go/agents/task-analyst.md +1 -1
- package/presets/cursor/go/hooks/chain-team-phases.sh +9 -2
- package/presets/cursor/go/hooks/list-ai-local.mjs +17 -0
- package/presets/cursor/go/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/ios-swift/agents/task-analyst.md +1 -1
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +9 -2
- package/presets/cursor/ios-swift/hooks/list-ai-local.mjs +17 -0
- package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/java/agents/task-analyst.md +1 -1
- package/presets/cursor/java/hooks/chain-team-phases.sh +9 -2
- package/presets/cursor/java/hooks/list-ai-local.mjs +17 -0
- package/presets/cursor/java/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +9 -2
- package/presets/cursor/mcp-ts/hooks/list-ai-local.mjs +17 -0
- package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mol/agents/task-analyst.md +1 -1
- package/presets/cursor/mol/hooks/chain-team-phases.sh +9 -2
- package/presets/cursor/mol/hooks/list-ai-local.mjs +17 -0
- package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/next/agents/task-analyst.md +1 -1
- package/presets/cursor/next/commands/README.md +1 -1
- package/presets/cursor/next/commands/task.md +1 -1
- package/presets/cursor/next/hooks/chain-team-phases.sh +9 -2
- package/presets/cursor/next/hooks/list-ai-local.mjs +17 -0
- package/presets/cursor/next/rules/agent-team-orchestrator.mdc +3 -1
- package/presets/cursor/next/rules/feature-delivery-workflow.mdc +4 -0
- package/presets/cursor/next/team/README.md +7 -3
- package/presets/cursor/nuxt/agents/task-analyst.md +1 -1
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +9 -2
- package/presets/cursor/nuxt/hooks/list-ai-local.mjs +17 -0
- package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +9 -2
- package/presets/cursor/php-hexagonal/hooks/list-ai-local.mjs +17 -0
- package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-laravel/agents/task-analyst.md +1 -1
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +9 -2
- package/presets/cursor/php-laravel/hooks/list-ai-local.mjs +17 -0
- package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/svelte/agents/task-analyst.md +1 -1
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +9 -2
- package/presets/cursor/svelte/hooks/list-ai-local.mjs +17 -0
- package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +9 -2
- package/presets/mavis/android-kotlin/hooks/list-ai-local.mjs +17 -0
- package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/agents/task-analyst.md +1 -1
- package/presets/mavis/go/hooks/chain-team-phases.sh +9 -2
- package/presets/mavis/go/hooks/list-ai-local.mjs +17 -0
- package/presets/mavis/go/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/go/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/agents/task-analyst.md +1 -1
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +9 -2
- package/presets/mavis/ios-swift/hooks/list-ai-local.mjs +17 -0
- package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/ios-swift/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/agents/task-analyst.md +1 -1
- package/presets/mavis/java/hooks/chain-team-phases.sh +9 -2
- package/presets/mavis/java/hooks/list-ai-local.mjs +17 -0
- package/presets/mavis/java/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/java/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +9 -2
- package/presets/mavis/mcp-ts/hooks/list-ai-local.mjs +17 -0
- package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/mcp-ts/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/mol/adapter-map.json +1 -1
- package/presets/mavis/mol/agents/task-analyst.md +1 -1
- package/presets/mavis/mol/hooks/chain-team-phases.sh +9 -2
- package/presets/mavis/mol/hooks/list-ai-local.mjs +17 -0
- package/presets/mavis/mol/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/mol/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/next/adapter-map.json +9 -1
- package/presets/mavis/next/agents/ci-investigator.md +5 -2
- package/presets/mavis/next/agents/debugger.md +5 -2
- package/presets/mavis/next/agents/feature-developer.md +5 -2
- package/presets/mavis/next/agents/task-analyst.md +1 -1
- package/presets/mavis/next/commands/README.md +1 -1
- package/presets/mavis/next/commands/task.md +1 -1
- package/presets/mavis/next/hooks/chain-team-phases.sh +9 -2
- package/presets/mavis/next/hooks/list-ai-local.mjs +17 -0
- package/presets/mavis/next/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/next/rules/feature-delivery-workflow.md +8 -0
- package/presets/mavis/next/team/README.md +7 -3
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/agents/task-analyst.md +1 -1
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +9 -2
- package/presets/mavis/nuxt/hooks/list-ai-local.mjs +17 -0
- package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/nuxt/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +9 -2
- package/presets/mavis/php-hexagonal/hooks/list-ai-local.mjs +17 -0
- package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/agents/task-analyst.md +1 -1
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +9 -2
- package/presets/mavis/php-laravel/hooks/list-ai-local.mjs +17 -0
- package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/php-laravel/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/agents/task-analyst.md +1 -1
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +9 -2
- package/presets/mavis/svelte/hooks/list-ai-local.mjs +17 -0
- package/presets/mavis/svelte/rules/agent-team-orchestrator.md +3 -1
- package/presets/mavis/svelte/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +9 -2
- package/presets/opencode/android-kotlin/hooks/list-ai-local.mjs +17 -0
- package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/agents/task-analyst.md +1 -1
- package/presets/opencode/go/hooks/chain-team-phases.sh +9 -2
- package/presets/opencode/go/hooks/list-ai-local.mjs +17 -0
- package/presets/opencode/go/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/go/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +9 -2
- package/presets/opencode/ios-swift/hooks/list-ai-local.mjs +17 -0
- package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/ios-swift/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/agents/task-analyst.md +1 -1
- package/presets/opencode/java/hooks/chain-team-phases.sh +9 -2
- package/presets/opencode/java/hooks/list-ai-local.mjs +17 -0
- package/presets/opencode/java/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/java/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +9 -2
- package/presets/opencode/mcp-ts/hooks/list-ai-local.mjs +17 -0
- package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/mcp-ts/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/mol/adapter-map.json +1 -1
- package/presets/opencode/mol/agents/task-analyst.md +1 -1
- package/presets/opencode/mol/hooks/chain-team-phases.sh +9 -2
- package/presets/opencode/mol/hooks/list-ai-local.mjs +17 -0
- package/presets/opencode/mol/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/mol/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/next/adapter-map.json +9 -1
- package/presets/opencode/next/agents/ci-investigator.md +5 -2
- package/presets/opencode/next/agents/debugger.md +5 -2
- package/presets/opencode/next/agents/feature-developer.md +5 -2
- package/presets/opencode/next/agents/task-analyst.md +1 -1
- package/presets/opencode/next/commands/README.md +1 -1
- package/presets/opencode/next/commands/task.md +1 -1
- package/presets/opencode/next/hooks/chain-team-phases.sh +9 -2
- package/presets/opencode/next/hooks/list-ai-local.mjs +17 -0
- package/presets/opencode/next/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/next/rules/feature-delivery-workflow.md +8 -0
- package/presets/opencode/next/team/README.md +7 -3
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +9 -2
- package/presets/opencode/nuxt/hooks/list-ai-local.mjs +17 -0
- package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/nuxt/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +9 -2
- package/presets/opencode/php-hexagonal/hooks/list-ai-local.mjs +17 -0
- package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +9 -2
- package/presets/opencode/php-laravel/hooks/list-ai-local.mjs +17 -0
- package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/php-laravel/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/plugins/output-guard/README.md +43 -0
- package/presets/opencode/plugins/output-guard/index.ts +300 -0
- package/presets/opencode/plugins/output-guard/package.json +9 -0
- package/presets/opencode/plugins/output-guard/rewrite.ts +149 -0
- package/presets/opencode/plugins/task-status/README.md +23 -11
- package/presets/opencode/plugins/task-status/details-data.ts +64 -46
- package/presets/opencode/plugins/task-status/details.tsx +12 -2
- package/presets/opencode/plugins/task-status/format.ts +16 -0
- package/presets/opencode/plugins/task-status/prompt-text.ts +37 -0
- package/presets/opencode/plugins/task-status/task-view.ts +281 -179
- package/presets/opencode/plugins/task-status/tui.tsx +60 -16
- package/presets/opencode/plugins/task-status/types.ts +74 -0
- package/presets/opencode/svelte/adapter-map.json +1 -1
- package/presets/opencode/svelte/agents/task-analyst.md +1 -1
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +9 -2
- package/presets/opencode/svelte/hooks/list-ai-local.mjs +17 -0
- package/presets/opencode/svelte/rules/agent-team-orchestrator.md +3 -1
- package/presets/opencode/svelte/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/android-kotlin/adapter-map.json +1 -1
- package/presets/zcode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +9 -2
- package/presets/zcode/android-kotlin/hooks/list-ai-local.mjs +17 -0
- package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/go/adapter-map.json +1 -1
- package/presets/zcode/go/agents/task-analyst.md +1 -1
- package/presets/zcode/go/hooks/chain-team-phases.sh +9 -2
- package/presets/zcode/go/hooks/list-ai-local.mjs +17 -0
- package/presets/zcode/go/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/go/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/ios-swift/adapter-map.json +1 -1
- package/presets/zcode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +9 -2
- package/presets/zcode/ios-swift/hooks/list-ai-local.mjs +17 -0
- package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/ios-swift/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/java/adapter-map.json +1 -1
- package/presets/zcode/java/agents/task-analyst.md +1 -1
- package/presets/zcode/java/hooks/chain-team-phases.sh +9 -2
- package/presets/zcode/java/hooks/list-ai-local.mjs +17 -0
- package/presets/zcode/java/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/java/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/mcp-ts/adapter-map.json +1 -1
- package/presets/zcode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +9 -2
- package/presets/zcode/mcp-ts/hooks/list-ai-local.mjs +17 -0
- package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/mcp-ts/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/mol/adapter-map.json +1 -1
- package/presets/zcode/mol/agents/task-analyst.md +1 -1
- package/presets/zcode/mol/hooks/chain-team-phases.sh +9 -2
- package/presets/zcode/mol/hooks/list-ai-local.mjs +17 -0
- package/presets/zcode/mol/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/mol/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/next/adapter-map.json +9 -1
- package/presets/zcode/next/agents/ci-investigator.md +5 -2
- package/presets/zcode/next/agents/debugger.md +5 -2
- package/presets/zcode/next/agents/feature-developer.md +5 -2
- package/presets/zcode/next/agents/task-analyst.md +1 -1
- package/presets/zcode/next/commands/README.md +1 -1
- package/presets/zcode/next/commands/task.md +1 -1
- package/presets/zcode/next/hooks/chain-team-phases.sh +9 -2
- package/presets/zcode/next/hooks/list-ai-local.mjs +17 -0
- package/presets/zcode/next/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/next/rules/feature-delivery-workflow.md +8 -0
- package/presets/zcode/next/team/README.md +7 -3
- package/presets/zcode/nuxt/adapter-map.json +1 -1
- package/presets/zcode/nuxt/agents/task-analyst.md +1 -1
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +9 -2
- package/presets/zcode/nuxt/hooks/list-ai-local.mjs +17 -0
- package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/nuxt/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
- package/presets/zcode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +9 -2
- package/presets/zcode/php-hexagonal/hooks/list-ai-local.mjs +17 -0
- package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/php-laravel/adapter-map.json +1 -1
- package/presets/zcode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +9 -2
- package/presets/zcode/php-laravel/hooks/list-ai-local.mjs +17 -0
- package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/php-laravel/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/svelte/adapter-map.json +1 -1
- package/presets/zcode/svelte/agents/task-analyst.md +1 -1
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +9 -2
- package/presets/zcode/svelte/hooks/list-ai-local.mjs +17 -0
- package/presets/zcode/svelte/rules/agent-team-orchestrator.md +3 -1
- package/presets/zcode/svelte/rules/feature-delivery-workflow.md +4 -0
- package/scripts/report-context-cost.mjs +432 -0
- package/presets/_shared/ai-local/scripts/upstream-research.mjs +0 -2964
- package/presets/claude/next/commands/upstream-research.md +0 -23
- package/presets/claude/next/team/upstream/config.json +0 -31
- package/presets/claude/next/team/upstream/digest-template.md +0 -55
- package/presets/claude/next/team/upstream/jobs.json +0 -34
- package/presets/claude/next/team/upstream/opencode.json +0 -34
- package/presets/claude/next/team/upstream/projects.json +0 -4
- package/presets/claude/next/team/upstream/prompt.md +0 -77
- package/presets/claude/next/team/upstream/signatures.json +0 -9
- package/presets/cursor/next/commands/upstream-research.md +0 -23
- package/presets/cursor/next/team/upstream/config.json +0 -31
- package/presets/cursor/next/team/upstream/digest-template.md +0 -55
- package/presets/cursor/next/team/upstream/jobs.json +0 -34
- package/presets/cursor/next/team/upstream/opencode.json +0 -34
- package/presets/cursor/next/team/upstream/projects.json +0 -4
- package/presets/cursor/next/team/upstream/prompt.md +0 -77
- package/presets/cursor/next/team/upstream/signatures.json +0 -9
- package/presets/mavis/next/commands/upstream-research.md +0 -18
- package/presets/mavis/next/team/upstream/config.json +0 -31
- package/presets/mavis/next/team/upstream/digest-template.md +0 -55
- package/presets/mavis/next/team/upstream/jobs.json +0 -34
- package/presets/mavis/next/team/upstream/opencode.json +0 -34
- package/presets/mavis/next/team/upstream/projects.json +0 -4
- package/presets/mavis/next/team/upstream/prompt.md +0 -77
- package/presets/mavis/next/team/upstream/signatures.json +0 -9
- package/presets/opencode/next/commands/upstream-research.md +0 -26
- package/presets/opencode/next/team/upstream/config.json +0 -31
- package/presets/opencode/next/team/upstream/digest-template.md +0 -55
- package/presets/opencode/next/team/upstream/jobs.json +0 -34
- package/presets/opencode/next/team/upstream/opencode.json +0 -34
- package/presets/opencode/next/team/upstream/projects.json +0 -4
- package/presets/opencode/next/team/upstream/prompt.md +0 -77
- package/presets/opencode/next/team/upstream/signatures.json +0 -9
- package/presets/zcode/next/commands/upstream-research.md +0 -26
- package/presets/zcode/next/team/upstream/config.json +0 -31
- package/presets/zcode/next/team/upstream/digest-template.md +0 -55
- package/presets/zcode/next/team/upstream/jobs.json +0 -34
- package/presets/zcode/next/team/upstream/opencode.json +0 -34
- package/presets/zcode/next/team/upstream/projects.json +0 -4
- package/presets/zcode/next/team/upstream/prompt.md +0 -77
- package/presets/zcode/next/team/upstream/signatures.json +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.67
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **OpenCode output guard.** `init opencode` and `update` copy `presets/opencode/plugins/output-guard/` to `.opencode/plugins/output-guard/`. The server plugin registers `ctx.session.hook("context")` and replaces a `tool-result` over 8 KB with a bounded head + tail, the path under `.ai.local/team/output-guard/`, and one `grep` / `sed` hint. `AI_RULES_OUTPUT_GUARD_BYTES` changes the threshold and the seeded `.ai.local/.gitignore` ignores `team/output-guard/`. It works for a prompt without `/task`; a host without the hook no-ops and `AI_RULES_OUTPUT_GUARD=0` disables it.
|
|
8
|
+
- **Output-guard totals in the context report.** `report-context-cost.mjs` reads `output-guard/stats.jsonl`, dedupes by path, and prints before/after/saved bytes plus the session count; `--json` adds `outputGuard`.
|
|
9
|
+
- **Efficiency report and A/B harness.** `report:efficiency` reads `results.jsonl` (every tool result) and `usage.jsonl` (per-step tokens/cost), prints measured bytes, tokens, cost, turns, and quality, and writes a static dashboard with `--html`. `bench:efficiency` runs the guard off/on through `opencode run --standalone` with a deterministic oracle and writes `efficiency.json`; the verdict requires `--runs 5`. The report never turns a byte saving into a token saving.
|
|
10
|
+
- **Next implementer reads 8 rules at startup.** The other 21 stems move to a `Read when the task reaches the matching zone` section of the generated `## Rules to load` block (Next only), so `feature-developer` no longer reads ~100 KB of rules before its first action.
|
|
11
|
+
- **`focus.md` lists at most 5 incomplete entries** plus a count; the existing 100-line cap still bounds a single entry with many paths.
|
|
12
|
+
- **`list-ai-local.mjs` prints an 8-hex body hash per file**, so a session can skip a re-read whose content did not change.
|
|
13
|
+
- **`tracker list --json` rows carry `labels` and `sourceRefs`.** Both arrays join the summary row, so the repository-only upstream importer can recognize an item it already created without fetching every item back.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **`dump-output.mjs` resolves the team root above the current directory.** A run from `packages/ai-rules` no longer creates a nested `.ai.local/team`; `--root` still wins and a missing root is a usage error.
|
|
18
|
+
- **The Cursor `next` feature-delivery rule carries the Context hygiene paragraph**, matching the OpenCode and Claude carriers.
|
|
19
|
+
- **A consumer seeded by ≤0.2.65 is told its weekly `upstream-research` job is dead.** `update` now prints a warning when the operator-owned `scheduler/jobs.json` references the runner that became repository-only, instead of silently leaving a job that fails every fire; the file itself is never rewritten. `test-pack-repo-only.mjs` covers the upgrade cohort.
|
|
20
|
+
- **The task-status sidebar can no longer lift a repo-wide stop by accident.** A resume word or the sidebar Resume clears only the pause it detected — a task sentinel or the operator `STOP`; a repo `ESTOP` is emergency semantics and is removed by hand alone. A prompt match is exact-first, so a longer substring prompt can no longer outrank the exact one.
|
|
21
|
+
- **Tracker UI refusals and affordances match the engine.** `E_TRACKER_TRANSITION` explains itself and closes instead of offering a dead Reload loop; the tracker form and the linked-task form gate the submit while invalid and cannot double-fire mid-flight; enqueue is hidden on terminal items; the mock upstream mirrors the contract (integer delete id, 202 on continue, the idempotent enqueue 200, query-grammar 422s).
|
|
22
|
+
- **A crash between a tracker create and its map write no longer duplicates an upstream item.** The repository-only importer adopts the row whose `sourceRefs` carry this run's `run:<id>` instead of creating a second one; if the lookup fails, the previous create path runs unchanged.
|
|
23
|
+
- **`doctor` gives an engine module with no recorded base its own `no-base` finding.** Its bytes were never attributed to the package, so the finding no longer says `modified` and reads as a consumer edit.
|
|
24
|
+
|
|
25
|
+
## 0.2.66
|
|
26
|
+
|
|
27
|
+
### Repository-only upstream research payload
|
|
28
|
+
|
|
29
|
+
- **The npm package no longer carries the `upstream-research` workflow.** `package.json` excludes the runner, the `/upstream-research` command, and every `presets/<tool>/next/team/upstream/**` template from the published tarball. `REPO_ONLY_ENGINE_SCRIPTS` names the runner: `init`, `update`, and `doctor` skip it silently when the installed preset has no source, while the repository checkout keeps seeding and mirroring it.
|
|
30
|
+
- **Packaging proof.** `test-pack-repo-only.mjs` packs the tarball, installs it into a scratch consumer, and asserts no job, runner, command, or `team/upstream/` file appears, the 22 published engine modules seed, and `doctor` reports no missing-engine finding.
|
|
31
|
+
|
|
32
|
+
### Upstream research plans into the tracker backlog
|
|
33
|
+
|
|
34
|
+
- **A second read-only call turns proposals into an ordered plan.** After ranking, the runner composes `plan-prompt.md` from the digest proposals and the target-repository sketch, calls the shipped `upstream-planner` agent once (one retry on a validation failure), and validates coverage, keys, `dependsOn` edges, and the acyclicity before any write.
|
|
35
|
+
- **Plan steps become `backlog` tracker items, blockers first.** Each item carries its mechanism, evidence, signature, and run; dependencies reference the generated ids. The idempotency map `upstream/tracker.json` reuses an id on a retry and never re-creates an idea imported by an earlier run.
|
|
36
|
+
- **A failed plan or tracker write is a digest gap.** Research evidence and the cursor stay the record; `report.plan` and the digest `Plan:` header name the state. `tracker.enabled` (default `true`) and `tracker.maxItems` (default 12) are data in `upstream/config.json`.
|
|
37
|
+
- **Seeding.** `init`/`update` refresh `upstream/plan-prompt.md` beside the prompt and agent config; the sealed `upstream-planner` permission map denies every tool like the researcher, and both are asserted before a project runs.
|
|
38
|
+
|
|
39
|
+
### Task-status sidebar: session source, pause scope, and thin-status rows
|
|
40
|
+
|
|
41
|
+
- **The sidebar reads the session from the `sidebar.content` slot input.** The router is only a fallback, so a session tab keeps its own task while a background subagent runs in another tab; a subagent tab still maps through `data.session.root`.
|
|
42
|
+
- **Stop and resume are task-scoped.** `■ stop` writes `tasks/<slug>/STOP` (repo-wide `.ai.local/STOP` only as a fallback), a paused task shows `▶ resume`, and the resume intent clears a sentinel only when the session maps to that task — a bare `дальше` in an unrelated session no longer releases a repo-wide pause. The view recognises the task-scoped sentinel the tracker writes.
|
|
43
|
+
- **A bootstrap or stale `status.json` keeps its rows.** `role`/`agent` fall back to `currentAgent` and then to the planned step, an `in_progress` task without an attempt reads `2/3 · no attempt started`, and the `eta` row survives a `stale` marker. `stale` now uses the agent's p90 as a floor, so a genuinely long step is not called stale after six hours.
|
|
44
|
+
- **State semantics match the hook.** `blocked` hides stop and ETA, `awaiting_artifact_receipt` hides ETA, a human gate hides stop and ETA, and an unknown agent reads `—` instead of a fabricated `implementation` role.
|
|
45
|
+
- **Matching is deterministic and cheap.** An exact prompt match outranks a newer substring match, matching is memoized per index generation and message fingerprint, normalized texts live in the session cache, and `message.list` follows up to five cursor pages so a late `/task-continue` is seen.
|
|
46
|
+
- **Fewer redundant reads.** `findTeamRoot` is cached for 30s, the session cache keeps the last four tabs (no `no task` flash on tab switch), a failed fetch keeps the last view and marks it `offline` for a minute, and the error is logged under the debug flag.
|
|
47
|
+
- **The details dialog reads the manifest.** Artifacts come from `artifact-manifest.json` (producer + outcome + path, last eight) with the known file names as a fallback, and the header adds the last update age, the ETA with its ledger count, and the run id.
|
|
48
|
+
- **Shared modules.** `types.ts`, `prompt-text.ts`, and `format.ts` replace the duplicated status types and two divergent `prompt.md` parsers.
|
|
49
|
+
- **Diagnostics without UI noise.** `OPENCODE_TASK_STATUS_DEBUG=1` appends the slot/route session IDs, message count, matched slug, rendered summary, fetch errors, and cleared pauses to `<tmpdir>/ai-rules-task-status-debug.log`.
|
|
50
|
+
- **Fixtures.** `test-task-status-view.mjs` grows to 14 cases (matched, no match, bootstrap, stale, repo stop, task stop, completed, gate, blocked, receipt, exact-vs-newer, unknown agent, note, details) and runs from `check-preset-structure.sh` and as `test:task-status-view`; it needs Node's built-in type stripping and skips on older runtimes.
|
|
51
|
+
- **Explicit import extensions.** The plugin's relative imports carry `.ts` / `.tsx`, so a local plugin directory resolves them (the loader skips extensionless `.tsx` imports silently).
|
|
52
|
+
- **Orchestrator contract.** The shared rule and `/task` now say a returned session handle has only **started** the specialist: the step stays open until the agent reports back and the hook records the receipt.
|
|
53
|
+
|
|
54
|
+
### Context output externalization
|
|
55
|
+
|
|
56
|
+
- **`dump-output.mjs` keeps a large command output out of the context window.** New shipped engine module: reads stdin or `--input`, writes `.ai.local/team/tasks/<slug>/outputs/<id>.txt` under a hard 2 097 152 B cap applied while streaming (a 0-byte file and a notice for empty input, a `-2`/`-3` suffix instead of an overwrite, a symlinked task or `outputs/` directory refused), then prints at most 40 head lines (≤8 KiB, ≤400 B per line), the byte count, the path, and one `grep -n` hint.
|
|
57
|
+
- **`team-db.mjs search <query>` reads the existing FTS5 projection.** Default 5 hits, `--limit` clamped to 1…20, snippets collapsed to single spaces and cut at 800 B on a UTF-8 boundary, `--json` one array with `snippetBytes`/`snippetTruncated`, and no hit is `team-db: no matches` with exit 0. Read-only: no schema, migration, route or `searchProjection` change. One requestable line in `context-and-iteration.md` names the dump → head → `grep`/`search` flow.
|
|
58
|
+
|
|
3
59
|
## 0.2.65
|
|
4
60
|
|
|
5
61
|
### Agent process manager
|
package/README.md
CHANGED
|
@@ -25,11 +25,13 @@ Run `init` from the **app root** (`--cwd` if needed). Default `--preset` is `nex
|
|
|
25
25
|
| Root agents | `REPO_AGENTS.md` → `AGENTS.md` (same file on all five; ZCode loads it natively) | | | | |
|
|
26
26
|
| `/task` artifacts | **`.ai.local/team/`** (shared; templates refreshed; `tasks/<slug>/` never overwritten) | | | |
|
|
27
27
|
| Template drift | **`.ai.local/.template-base.json`** (shared; one record per tree of files that hold a shipped template byte; `update` prints one drift line, `update --merge-ai-local` fast-forwards a file only when its recorded base still matches and reports the rest) | | | |
|
|
28
|
-
| Self-learning engine | **`.ai.local/scripts/`** (shared; twenty-two scripts — the six self-learning engine modules, `manifest.mjs`, the ten `team-db*.mjs` projection, scheduler and lifecycle modules, the
|
|
28
|
+
| Self-learning engine | **`.ai.local/scripts/`** (shared; twenty-two scripts — the six self-learning engine modules, `manifest.mjs`, the `dump-output.mjs` output externalizer, the ten `team-db*.mjs` projection, scheduler and lifecycle modules, the read-only `check-write-scope.mjs` write audit, the `aggregate-agent-task-metrics.mjs` aggregator, and the `processes.mjs` + `process-lease.mjs` process manager; existing files never overwritten. The repository-only `upstream-research.mjs` is not published) | | | |
|
|
29
29
|
| Specs seed | `docs/specs/` copied only if the directory is **absent** | | | |
|
|
30
30
|
|
|
31
31
|
OpenCode also ships **`.opencode/plugins/task-status/`**, a TUI sidebar for the active `/task` run (slug, state, elapsed time, step, remaining-time estimate, soft-stop). OpenCode auto-loads it; it needs no `opencode.json` entry, is refreshed by `update`, and is a viewer only — the chain hook stays manual.
|
|
32
32
|
|
|
33
|
+
**`.opencode/plugins/output-guard/`** is the server counterpart: a `tool-result` over 8 KB is stored under `.ai.local/team/output-guard/` and replaced with a bounded head + tail, the path, and one `grep` hint. It registers `ctx.session.hook("context")`, so it works for a prompt without `/task`; `AI_RULES_OUTPUT_GUARD=0` disables it and a host without the hook no-ops. It is a token-economy mechanism, not a security boundary. Measure it with `yarn report:efficiency` (text/JSON/HTML) and `yarn bench:efficiency --model <provider/model> --runs 5` (A/B with a deterministic oracle); a byte saving is never reported as a token saving.
|
|
34
|
+
|
|
33
35
|
### Project MCP catalog
|
|
34
36
|
|
|
35
37
|
`init mcp` writes the third-party servers this package ships plus Storybook, DefectDojo, and the packaged GitLab / GitHub / Yandex runtime entries into every installed client; `--tools` narrows the list to the clients you name. Entries render in each client's native shape and merge like `init`: extra servers, the consumer's `env` / `headers`, and other top-level keys stay. Names: `context7`, `playwright` (Claude's id is `playwright-test`), `chrome-devtools`, `next-devtools`, `semgrep`, `sentry`, `figma-desktop` (alias `figma`, the local `http://127.0.0.1:3845/mcp` server), `figma-cloud` (the remote `https://mcp.figma.com/mcp` server), `storybook` (`http://localhost:6200/mcp`), `defectdojo`, `gitlab`, `github`, `yandex-tracker`, and `yandex-wiki`; `--all` selects every one. The last five are packaged runtime entries: they are registered without credentials and need `mcp setup <provider>` once (DefectDojo reads `.env.defectdojo`). Next.js DevTools needs a running `next dev` on Next.js 16+; Semgrep needs the `semgrep` CLI; Sentry uses OAuth.
|
|
@@ -168,16 +170,24 @@ pre-v2 database is rebuilt from the files on the next `sync`.
|
|
|
168
170
|
|
|
169
171
|
### Upstream research
|
|
170
172
|
|
|
171
|
-
The `
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
173
|
+
**Repository-only.** The `upstream-research` job, the `/upstream-research` command, the runner
|
|
174
|
+
(`.ai.local/scripts/upstream-research.mjs`), and the `team/upstream/` templates are not part of
|
|
175
|
+
the published npm package; they are used only in the `@bonesofspring/ai-rules` repository
|
|
176
|
+
itself. A consumer install seeds no job and no runner.
|
|
177
|
+
|
|
178
|
+
In this repository the `next` preset carries a weekly `upstream-research` job and a read-only
|
|
179
|
+
`opencode` agent for it. `init`/`update` seed the job definition into
|
|
180
|
+
`.ai.local/team/scheduler/jobs.json` when the file is absent; an operator-edited definition is
|
|
181
|
+
never overwritten. The runner probes `opencode`, loads `upstream/projects.json` and
|
|
182
|
+
`upstream/config.json`, fetches each due clone with `git fetch --depth 1`, labels the window
|
|
183
|
+
(`range`, `baseline`, `unprovable`, `no-change`), validates the agent's marked JSON, re-checks
|
|
184
|
+
every citation inside the clone, dedupes by mechanism against the committed
|
|
185
|
+
`upstream/signatures.json`, and writes one ranked digest to `docs/upstream/digest-<runId>.md`.
|
|
186
|
+
A second read-only planner call decomposes the ranked proposals into ordered steps, and the
|
|
187
|
+
runner imports them into `team/tracker` as `backlog` items with `dependsOn` edges (blockers
|
|
188
|
+
first) and an idempotency map in `upstream/tracker.json`. The cursor is git-ignored; the caps
|
|
189
|
+
are data. `/upstream-research` queues a run and adds one `schedule --once` tick when no timer
|
|
190
|
+
is online. Details:
|
|
181
191
|
[`docs/TEAM-DB.md`](docs/TEAM-DB.md#upstream-research-job) and
|
|
182
192
|
[`docs/OPENCODE.md`](docs/OPENCODE.md#upstream-research-agent).
|
|
183
193
|
|
package/bin/cli.js
CHANGED
|
@@ -1057,7 +1057,15 @@ function collectDoctorState(cwd, packageRoot) {
|
|
|
1057
1057
|
continue;
|
|
1058
1058
|
}
|
|
1059
1059
|
engineFindings.push({
|
|
1060
|
-
|
|
1060
|
+
// A `no-base` module is not a consumer edit: its bytes were never
|
|
1061
|
+
// attributed, so it carries its own finding code instead of folding
|
|
1062
|
+
// into `modified`.
|
|
1063
|
+
code:
|
|
1064
|
+
entry.state === 'stale'
|
|
1065
|
+
? 'stale-engine'
|
|
1066
|
+
: entry.state === 'no-base'
|
|
1067
|
+
? 'no-base'
|
|
1068
|
+
: 'modified',
|
|
1061
1069
|
path: entry.rel,
|
|
1062
1070
|
detail: entry.detail,
|
|
1063
1071
|
fixable: entry.state === 'stale',
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* The
|
|
4
|
+
* The engine `.ai.local/scripts/` set, declared once.
|
|
5
5
|
*
|
|
6
|
-
* `init` seeds
|
|
7
|
-
*
|
|
8
|
-
* `scripts/lib/engine-mirror.mjs`. An explicit
|
|
9
|
-
* repo-local tooling (the `*.test.mjs` suites
|
|
10
|
-
* the shipped set.
|
|
6
|
+
* `init` seeds these files into a consumer's `.ai.local/scripts/` when their
|
|
7
|
+
* source exists in the installed preset, and the monorepo dogfood copy is
|
|
8
|
+
* mirrored from the same source by `scripts/lib/engine-mirror.mjs`. An explicit
|
|
9
|
+
* list — never a glob — keeps the repo-local tooling (the `*.test.mjs` suites
|
|
10
|
+
* and `requirements-*.mjs`) out of the shipped set.
|
|
11
11
|
*
|
|
12
12
|
* `manifest.mjs` is the deterministic writer for
|
|
13
13
|
* `.ai.local/team/tasks/<slug>/artifact-manifest.json`; producers call it
|
|
@@ -17,7 +17,19 @@ const path = require('path');
|
|
|
17
17
|
* read-only dashboard, the scheduler, and the `ui` lifecycle supervisor.
|
|
18
18
|
* `team-db.mjs` is the CLI; the others are loaded by it on demand, so a runtime
|
|
19
19
|
* without `node:sqlite` never imports them.
|
|
20
|
+
*
|
|
21
|
+
* `REPO_ONLY_ENGINE_SCRIPTS` stay in the preset source and the monorepo dogfood
|
|
22
|
+
* mirror, but the published tarball excludes their sources. A consumer install
|
|
23
|
+
* sees no source for them, so `init`, `update`, and `doctor` skip them without
|
|
24
|
+
* warning; a source that exists (this repository) is seeded and upgraded as
|
|
25
|
+
* usual.
|
|
20
26
|
*/
|
|
27
|
+
const REPO_ONLY_ENGINE_SCRIPTS = [
|
|
28
|
+
// The weekly upstream evolution review is a personal workflow: the job,
|
|
29
|
+
// prompt, agent config, and runner live only in this repository.
|
|
30
|
+
'upstream-research.mjs',
|
|
31
|
+
];
|
|
32
|
+
|
|
21
33
|
const ENGINE_SCRIPTS = [
|
|
22
34
|
'run.mjs',
|
|
23
35
|
'signals.mjs',
|
|
@@ -26,6 +38,10 @@ const ENGINE_SCRIPTS = [
|
|
|
26
38
|
'derive-gate-signals.mjs',
|
|
27
39
|
'efficacy-oracle.mjs',
|
|
28
40
|
'manifest.mjs',
|
|
41
|
+
// Command-output externalizer: stdin (or `--input`) becomes a capped
|
|
42
|
+
// `.ai.local/team/tasks/<slug>/outputs/` file plus a head, so a large dump
|
|
43
|
+
// never enters the context window. Reads no network and spawns nothing.
|
|
44
|
+
'dump-output.mjs',
|
|
29
45
|
'team-db.mjs',
|
|
30
46
|
'team-db-ui.mjs',
|
|
31
47
|
'team-db-tracker.mjs',
|
|
@@ -67,4 +83,15 @@ function engineSourceDir(presetsRoot) {
|
|
|
67
83
|
return path.join(presetsRoot, ...ENGINE_SOURCE_RELATIVE.split('/'));
|
|
68
84
|
}
|
|
69
85
|
|
|
70
|
-
module
|
|
86
|
+
/** True when the module is source-only in this repository and never published. */
|
|
87
|
+
function isRepoOnlyEngineScript(name) {
|
|
88
|
+
return REPO_ONLY_ENGINE_SCRIPTS.includes(name);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
module.exports = {
|
|
92
|
+
ENGINE_SCRIPTS,
|
|
93
|
+
REPO_ONLY_ENGINE_SCRIPTS,
|
|
94
|
+
ENGINE_SOURCE_RELATIVE,
|
|
95
|
+
engineSourceDir,
|
|
96
|
+
isRepoOnlyEngineScript,
|
|
97
|
+
};
|
|
@@ -27,7 +27,7 @@ const {
|
|
|
27
27
|
serialiseRecord,
|
|
28
28
|
} = require('./ai-local-drift');
|
|
29
29
|
const { runStamp } = require('./fs-utils');
|
|
30
|
-
const { ENGINE_SCRIPTS, ENGINE_SOURCE_RELATIVE, engineSourceDir } = require('./engine-scripts');
|
|
30
|
+
const { ENGINE_SCRIPTS, ENGINE_SOURCE_RELATIVE, engineSourceDir, isRepoOnlyEngineScript } = require('./engine-scripts');
|
|
31
31
|
|
|
32
32
|
const ENGINE_ROOT_REL = '.ai.local/scripts';
|
|
33
33
|
const BACKUP_PREFIX = 'engine-';
|
|
@@ -54,7 +54,10 @@ function shippedEngineTemplates(packageRoot) {
|
|
|
54
54
|
const abs = path.join(sourceDir, name);
|
|
55
55
|
const stat = lstatOrNull(abs);
|
|
56
56
|
if (!stat || !stat.isFile()) {
|
|
57
|
-
|
|
57
|
+
// A repo-only module is intentionally absent from the published tarball.
|
|
58
|
+
if (!isRepoOnlyEngineScript(name)) {
|
|
59
|
+
warn(`engine source ${name} is missing from presets/${ENGINE_SOURCE_RELATIVE}; skipped`);
|
|
60
|
+
}
|
|
58
61
|
continue;
|
|
59
62
|
}
|
|
60
63
|
const content = fs.readFileSync(abs);
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
const path = require('path');
|
|
12
12
|
const { assertSafeDest } = require('./safe-path');
|
|
13
|
-
const { ENGINE_SCRIPTS, engineSourceDir } = require('./engine-scripts');
|
|
13
|
+
const { ENGINE_SCRIPTS, engineSourceDir, isRepoOnlyEngineScript } = require('./engine-scripts');
|
|
14
14
|
const { runTemplateDrift } = require('./ai-local-drift');
|
|
15
15
|
|
|
16
16
|
const LEGACY_TOOLS = ['cursor', 'claude', 'mavis', 'opencode', 'zcode'];
|
|
@@ -43,6 +43,8 @@ const AI_LOCAL_GITIGNORE = [
|
|
|
43
43
|
'# Per-step write-scope baselines; derived from git, never a project input.',
|
|
44
44
|
'team/.write-scope/',
|
|
45
45
|
'team/upstream/cursor.json',
|
|
46
|
+
'# Output-guard spill files; runtime state, never commit.',
|
|
47
|
+
'team/output-guard/',
|
|
46
48
|
'# Dashboard lifecycle marker (`.ai.local/.ui/api.json`); local runtime state, never commit.',
|
|
47
49
|
'.ui/',
|
|
48
50
|
'# Dev-server lifecycle markers (`.ai.local/.dev/<name>.json`); local runtime state, never commit.',
|
|
@@ -301,7 +303,10 @@ function seedEngineScripts({ cwd, presetTeamSrc }) {
|
|
|
301
303
|
const source = path.join(sourceDir, name);
|
|
302
304
|
const dest = path.join(destDir, name);
|
|
303
305
|
if (!fs.existsSync(source)) {
|
|
304
|
-
|
|
306
|
+
// A repo-only module is absent from the published tarball by design.
|
|
307
|
+
if (!isRepoOnlyEngineScript(name)) {
|
|
308
|
+
warn(`.ai.local/scripts: engine source ${name} is missing from the preset; skipped`);
|
|
309
|
+
}
|
|
305
310
|
continue;
|
|
306
311
|
}
|
|
307
312
|
if (fs.existsSync(dest)) {
|
|
@@ -348,7 +353,7 @@ function copyTemplates(presetTeamSrc, dest) {
|
|
|
348
353
|
// Preset-owned upstream templates refresh on every init/update: a consumer edit
|
|
349
354
|
// to the permission map or the prompt must not silently defeat the contract.
|
|
350
355
|
const upstreamSrc = path.join(presetTeamSrc, 'upstream');
|
|
351
|
-
for (const name of ['prompt.md', 'digest-template.md', 'opencode.json']) {
|
|
356
|
+
for (const name of ['prompt.md', 'plan-prompt.md', 'digest-template.md', 'opencode.json']) {
|
|
352
357
|
const source = path.join(upstreamSrc, name);
|
|
353
358
|
if (!fs.existsSync(source)) continue;
|
|
354
359
|
copyFile(source, path.join(dest, 'upstream', name));
|
|
@@ -375,6 +380,30 @@ function copyTemplates(presetTeamSrc, dest) {
|
|
|
375
380
|
if (fs.existsSync(jobsSource) && !fs.existsSync(jobsTarget)) {
|
|
376
381
|
copyFile(jobsSource, jobsTarget);
|
|
377
382
|
written.push('.ai.local/team/scheduler/jobs.json');
|
|
383
|
+
} else if (!fs.existsSync(jobsSource) && fs.existsSync(jobsTarget)) {
|
|
384
|
+
// The upgrade cohort: a consumer seeded by a pre-repository-only release
|
|
385
|
+
// keeps the weekly job whose runner no longer ships. The operator file
|
|
386
|
+
// is never rewritten, so the dead job is named, not silently left behind.
|
|
387
|
+
try {
|
|
388
|
+
const jobs = JSON.parse(fs.readFileSync(jobsTarget, 'utf8'));
|
|
389
|
+
const dead = Array.isArray(jobs?.jobs)
|
|
390
|
+
? jobs.jobs.filter(
|
|
391
|
+
(job) =>
|
|
392
|
+
String(job?.id ?? '').includes('upstream-research') ||
|
|
393
|
+
(Array.isArray(job?.payload?.runner) &&
|
|
394
|
+
job.payload.runner.some((element) =>
|
|
395
|
+
String(element).includes('upstream-research'),
|
|
396
|
+
)),
|
|
397
|
+
)
|
|
398
|
+
: [];
|
|
399
|
+
for (const job of dead) {
|
|
400
|
+
warn(
|
|
401
|
+
`scheduler/jobs.json keeps job "${job?.id ?? '?'}", whose runner (upstream-research.mjs) is repository-only in this version: the weekly run will fail until the job is removed or a repository checkout provides the runner`,
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
} catch {
|
|
405
|
+
// An unreadable jobs file is the scheduler's refusal to explain.
|
|
406
|
+
}
|
|
378
407
|
}
|
|
379
408
|
}
|
|
380
409
|
const gitkeepSrc = path.join(presetTeamSrc, 'tasks', '.gitkeep');
|
|
@@ -36,6 +36,7 @@ Allowed status values are `confirmed`, `partial`, `unknown`, `manual`, and `no-e
|
|
|
36
36
|
| Workspace Skill discovery | `confirmed` | opencode.ai/docs/skills | `.opencode/skills/<name>/SKILL.md` | Native `skill` tool |
|
|
37
37
|
| Project MCP | `confirmed` | opencode.ai/docs/mcp-servers | `opencode.json` `mcp` | Merge on init |
|
|
38
38
|
| TUI plugin discovery | `confirmed` | opencode.ai/docs/plugins | `.opencode/plugins/<name>/` loads automatically | Ships `task-status` TUI sidebar |
|
|
39
|
+
| Tool-output guard (server plugin) | `confirmed` | opencode.ai/docs/build/plugins/server + live probe 2026-11-13 | `ctx.session.hook("context")` mutates assembled messages before dispatch | Ships `output-guard`; a host without the hook no-ops |
|
|
39
40
|
| Project hooks (`hooks.json`) | `manual` | plugins exist; this preset ships a TUI viewer, not a hook plugin | No confirmed `subagentStop` analog was opened | Manual `chain-team-phases.sh` |
|
|
40
41
|
| Slash commands | `confirmed` | opencode.ai/docs/commands | `.opencode/commands/<name>.md` | Native `/task` |
|
|
41
42
|
| Plugin / skill / MCP combo | `confirmed` | skills + mcp docs | MCP inflates context | Gate unused servers in operator config |
|
package/docs/OPENCODE.md
CHANGED
|
@@ -78,10 +78,23 @@ printf '%s\n' '{"status":"completed","attemptId":"<from-status.json>"}' \
|
|
|
78
78
|
| TEAM_TASK_SLUG=<slug> bash .opencode/hooks/chain-team-phases.sh
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
Human gates pause with `awaitingHumanGate: true`. Resume with `/task-continue`. There is **no** shipped `hooks.json
|
|
81
|
+
Human gates pause with `awaitingHumanGate: true`. Resume with `/task-continue`. There is **no** shipped `hooks.json`; the shipped OpenCode plugins are the TUI viewer and the output guard.
|
|
82
82
|
|
|
83
83
|
Full team layout: `.ai.local/team/README.md`.
|
|
84
84
|
|
|
85
|
+
## Output guard (server plugin)
|
|
86
|
+
|
|
87
|
+
`.opencode/plugins/output-guard/` ships with every OpenCode preset. It registers
|
|
88
|
+
`ctx.session.hook("context")`, which receives the assembled model messages before
|
|
89
|
+
dispatch. A `tool-result` over 8 KB is written to
|
|
90
|
+
`.ai.local/team/output-guard/<sessionID>/outputs/` and replaced with a bounded
|
|
91
|
+
head + tail, the path, and one `grep` / `sed` hint. It works for every prompt,
|
|
92
|
+
including one without `/task`.
|
|
93
|
+
|
|
94
|
+
- `AI_RULES_OUTPUT_GUARD=0` disables it; `AI_RULES_OUTPUT_GUARD_BYTES` changes the threshold.
|
|
95
|
+
- The change affects only the outgoing model call; persisted history is untouched.
|
|
96
|
+
- Hosts without `ctx.session.hook` no-op. It is a token-economy mechanism, not a security boundary.
|
|
97
|
+
|
|
85
98
|
## Task status sidebar (TUI plugin)
|
|
86
99
|
|
|
87
100
|
`.opencode/plugins/task-status/` ships with every OpenCode preset. `init` and
|
|
@@ -128,24 +141,32 @@ Do not pin OpenCode CLI or TUI versions in the contract.
|
|
|
128
141
|
|
|
129
142
|
## Upstream research agent
|
|
130
143
|
|
|
131
|
-
The `
|
|
144
|
+
**Repository-only.** The `upstream-research` job and its `team/upstream/` payload are not part
|
|
145
|
+
of the published npm package; this section documents the workflow used in the
|
|
146
|
+
`@bonesofspring/ai-rules` repository itself. A consumer install does not include the agent
|
|
147
|
+
config, the command, or the runner.
|
|
148
|
+
|
|
149
|
+
The `next` preset carries a read-only agent for the `upstream-research` job at
|
|
132
150
|
`.ai.local/team/upstream/opencode.json` (source:
|
|
133
|
-
`presets/cursor/next/team/upstream/opencode.json`). It is refreshed on every `init`/`update
|
|
134
|
-
so
|
|
151
|
+
`presets/cursor/next/team/upstream/opencode.json`). It is refreshed on every `init`/`update`
|
|
152
|
+
in this repository, so the installed copy cannot be widened by editing it.
|
|
135
153
|
|
|
136
|
-
- `agent.upstream-researcher`
|
|
137
|
-
- `permission` starts with `"*": "deny"`, so
|
|
138
|
-
- Before phase 1 the runner resolves
|
|
154
|
+
- `agent.upstream-researcher` and `agent.upstream-planner` have `mode: "subagent"`.
|
|
155
|
+
- `permission` starts with `"*": "deny"`, so an agent has no tool at all: MCP servers installed by the same project (`chrome-devtools`, `playwright`, `context7`, `figma`) and custom tools resolve as `<server>_<tool>` and are denied by the same wildcard. The named rows stay as a second line of defence: `edit`/`bash`/`read`/`glob`/`grep`/`list` are `{"*": "deny"}`; `webfetch`, `websearch`, `task`, and `external_directory` are `deny`. The shell deny stops a write around the edit deny; the wildcard and the read/fetch/subagent denies keep untrusted upstream content from reaching a secret or a network destination. Neither agent needs a tool: the prompt arrives as an attached `--file` message and the runner verifies evidence itself.
|
|
156
|
+
- Before phase 1 the runner resolves both installed agents with `opencode debug agents` and refuses to start a project unless the global `*` and every named action still resolve to `deny` on resource `*` under last-match-wins (`E_AGENT_CONFIG_INVALID`, exit 12). The probe also asserts a synthetic non-built-in name, so a config that enumerates only the ten built-ins fails. A discovered config that appends an allow after the preset deny is caught here, not by a file grep.
|
|
139
157
|
- The job invokes `opencode run --agent upstream-researcher --format json --archived --auto`
|
|
140
158
|
with the child `cwd` set to the team `upstream/` directory; that nested config is the only
|
|
141
|
-
selector, because this build has no `--dir`.
|
|
159
|
+
selector, because this build has no `--dir`. After ranking, one
|
|
160
|
+
`--agent upstream-planner` call over the same `cwd` decomposes the proposals into ordered
|
|
161
|
+
backlog steps; it reads only the attached `plan-prompt.md`.
|
|
142
162
|
- `--worktree` is never passed: the research is read-only.
|
|
143
163
|
- `--auto` cannot widen an explicit `deny`; the runner also compares `git status --porcelain`
|
|
144
164
|
in the repository before and after each call (`E_WORKTREE_CHANGED`) and inside the reviewed
|
|
145
165
|
clone (`E_UPSTREAM_DIRTY`).
|
|
146
166
|
|
|
147
|
-
The
|
|
148
|
-
row; the job asserts
|
|
167
|
+
The agents are not first-class preset agents: they have no `agents/**` mirror and no
|
|
168
|
+
adapter-map row; the job asserts their resolved rules with `opencode debug agents` before the
|
|
169
|
+
first project.
|
|
149
170
|
## Local overlay
|
|
150
171
|
|
|
151
172
|
`.ai.local/rules/*.md` at repo root (or monorepo parents) override preset rules. See [`LOCAL-OVERLAY.md`](./LOCAL-OVERLAY.md).
|
package/docs/TEAM-DB.md
CHANGED
|
@@ -8,7 +8,7 @@ The projection is installed by `init` as ten `team-db*.mjs` modules under `.ai.l
|
|
|
8
8
|
|
|
9
9
|
| Module | Role |
|
|
10
10
|
|---|---|
|
|
11
|
-
| `team-db.mjs` | CLI: `init`, `sync`, `delete`, `migrate-tasks`, `check`, `serve`, `jobs`, `schedule`, `tracker`, `task-run`, `ui` |
|
|
11
|
+
| `team-db.mjs` | CLI: `init`, `sync`, `delete`, `migrate-tasks`, `check`, `search`, `serve`, `jobs`, `schedule`, `tracker`, `task-run`, `ui` |
|
|
12
12
|
| `team-db-ui.mjs` | the `ui` supervisor: probe-first `start`, `stop`, `status`, `restart`, the ownership marker, leader-only termination |
|
|
13
13
|
| `team-db-tracker.mjs` | the file-authoritative tracker: items, links, the launch queue, eligibility order, import |
|
|
14
14
|
| `team-db-task-runner.mjs` | the opt-in `team/runner.json` supervisor behind tracker Continue |
|
|
@@ -20,10 +20,13 @@ The projection is installed by `init` as ten `team-db*.mjs` modules under `.ai.l
|
|
|
20
20
|
| `team-db-scheduler.mjs` | job model, cron/interval math, the file store, the projection, and the timer |
|
|
21
21
|
|
|
22
22
|
The same seeded set is `ENGINE_SCRIPTS` in `bin/lib/engine-scripts.js`: the ten `team-db*.mjs`
|
|
23
|
-
modules plus the self-learning engine, `manifest.mjs`, `
|
|
24
|
-
`check-write-scope.mjs`, `aggregate-agent-task-metrics.mjs`, and the `processes.mjs` +
|
|
25
|
-
(twenty-two entries;
|
|
26
|
-
|
|
23
|
+
modules plus the self-learning engine, `manifest.mjs`, `dump-output.mjs`,
|
|
24
|
+
`check-write-scope.mjs`, `aggregate-agent-task-metrics.mjs`, and the `processes.mjs` +
|
|
25
|
+
`process-lease.mjs` process manager (twenty-two published entries;
|
|
26
|
+
`node -e "require('./bin/lib/engine-scripts.js').SHIPPED_ENGINE_SCRIPTS.length"` prints the
|
|
27
|
+
shipped count). One further module, `upstream-research.mjs`, is declared in
|
|
28
|
+
`REPO_ONLY_ENGINE_SCRIPTS`: it exists in this repository's preset source and dogfood mirror but
|
|
29
|
+
is excluded from the published tarball, and a consumer install skips it without a warning.
|
|
27
30
|
|
|
28
31
|
## Behavior contract
|
|
29
32
|
|
|
@@ -63,9 +66,10 @@ team.db-shm
|
|
|
63
66
|
team-db-errors.log
|
|
64
67
|
team/scheduler/runs/
|
|
65
68
|
team/scheduler/state.json
|
|
69
|
+
team/output-guard/
|
|
66
70
|
```
|
|
67
71
|
|
|
68
|
-
`team/scheduler/jobs.json` stays tracked: definitions are code, run output is not. The
|
|
72
|
+
`team/scheduler/jobs.json` stays tracked: definitions are code, run output is not. `team/output-guard/` holds the OpenCode output-guard spill files; runtime state, never commit. The
|
|
69
73
|
consumer root `.gitignore` is never created or edited. Never commit the database even
|
|
70
74
|
for a demo: it contains copies of prompts and task documents.
|
|
71
75
|
|
|
@@ -114,6 +118,7 @@ node .ai.local/scripts/team-db.mjs delete --slug <slug> [--root <team-dir>] [--j
|
|
|
114
118
|
node .ai.local/scripts/team-db.mjs migrate-tasks [--root <team-dir>] [--quiet] [--json]
|
|
115
119
|
[--rebuild | --no-rebuild]
|
|
116
120
|
node .ai.local/scripts/team-db.mjs check [--root <team-dir>]
|
|
121
|
+
node .ai.local/scripts/team-db.mjs search <query> [--limit <n>] [--json] [--root <team-dir>]
|
|
117
122
|
node .ai.local/scripts/team-db.mjs serve [--root <team-dir>] [--host <addr>] [--port <n>]
|
|
118
123
|
[--allow-remote] [--open]
|
|
119
124
|
node .ai.local/scripts/team-db.mjs ui start|restart [--root <team-dir>] [--json] [--quiet]
|
|
@@ -148,6 +153,19 @@ vocabulary: `0` ok, `1` a validation refusal carrying its named code (`E_TRACKER
|
|
|
148
153
|
`E_TRACKER_TRANSITION`, `E_TRACKER_REVISION`, `E_SCHEMA`), `3` usage, `4` the tree lock was
|
|
149
154
|
contended (`E_TRACKER_BUSY`).
|
|
150
155
|
|
|
156
|
+
`search <query>` answers from the FTS5 projection: it calls `searchProjection` (`MATCH` when the
|
|
157
|
+
`search_fts` table exists, the escaped `LIKE` fallback otherwise) and never builds SQL from the
|
|
158
|
+
input. It opens the database read-only, defaults to 5 hits, clamps `--limit` to 1…20 (a larger
|
|
159
|
+
number is clamped, not refused) and prints one line per hit — task slug, document path, kind,
|
|
160
|
+
snippet. A snippet collapses whitespace and is cut at 800 B on a UTF-8 boundary with `…`;
|
|
161
|
+
`--json` prints exactly one array of `{taskSlug, doc_path, kind, snippet, snippetBytes,
|
|
162
|
+
snippetTruncated}`. No match prints `team-db: no matches for "<query>"` (`[]` under `--json`)
|
|
163
|
+
with exit 0, a missing database is `E_DB_MISSING` with exit 2, and the kill switch or an
|
|
164
|
+
unavailable `node:sqlite` answer as they do for `check` (exit 1). The writer behind it is the
|
|
165
|
+
shipped `dump-output.mjs`: it stores a command output under
|
|
166
|
+
`.ai.local/team/tasks/<slug>/outputs/<id>.txt` with a hard cap of 2 097 152 B (2 MiB) per file
|
|
167
|
+
and prints a bounded head, so the next projection indexes the file and this verb finds it.
|
|
168
|
+
|
|
151
169
|
`sync` is idempotent: a second run reports `inserted=0 updated=0 unchanged=<n>`. One changed
|
|
152
170
|
byte changes exactly one document hash and one task content hash. A removed task directory is
|
|
153
171
|
tombstoned with `absent_at` (soft delete) and `--prune` removes tombstones.
|
|
@@ -335,7 +353,13 @@ not supported in v1.
|
|
|
335
353
|
|
|
336
354
|
## Upstream research job
|
|
337
355
|
|
|
338
|
-
|
|
356
|
+
**Repository-only.** This job, the `/upstream-research` command, the
|
|
357
|
+
`.ai.local/scripts/upstream-research.mjs` runner, and every `team/upstream/` template are used
|
|
358
|
+
only in the `@bonesofspring/ai-rules` repository. The published tarball excludes all of them:
|
|
359
|
+
a consumer install seeds no job and no runner. The rest of this section documents the workflow
|
|
360
|
+
for repository maintainers.
|
|
361
|
+
|
|
362
|
+
The `next` preset carries one `pipeline` job, `upstream-research`, and one engine module,
|
|
339
363
|
`.ai.local/scripts/upstream-research.mjs`. The job renders `upstream/prompt.md` and runs the
|
|
340
364
|
module with `--prompt {promptFile} --team-root . --repo-root ../..`; it is a normal
|
|
341
365
|
definition in `scheduler/jobs.json`, so `jobs list|get|put|enable|disable|run`, the dashboard
|
|
@@ -356,19 +380,35 @@ one `schedule --once` tick.
|
|
|
356
380
|
`.ai.local/team/upstream/cursor.json`. A lost cursor is rebuilt from the newest
|
|
357
381
|
`scheduler/runs/upstream-research/<runId>/report.json`, then degrades to a bounded baseline
|
|
358
382
|
when the run tree has been pruned. `upstream/projects.json`, `config.json`, `signatures.json`,
|
|
359
|
-
the prompt, the digest template,
|
|
360
|
-
|
|
383
|
+
the prompt, the plan prompt, the digest template, the agent config, and `tracker.json` are
|
|
384
|
+
committed; `docs/upstream/digest-<runId>.md` is committed and never pruned.
|
|
361
385
|
|
|
362
386
|
**Write allow-list.** A run writes only `scheduler/runs/upstream-research/<runId>/**`, the
|
|
363
|
-
cursor,
|
|
364
|
-
|
|
387
|
+
cursor, `upstream/tracker.json`, the `team/tracker/items/**` it creates, and the committed
|
|
388
|
+
digest. It never writes `status.json` or `metrics.json`, and the scheduler keeps owning
|
|
389
|
+
`run.json`, `stdout.log`, `stderr.log`, and `<runDir>/prompt.md`.
|
|
390
|
+
|
|
391
|
+
**Planning and backlog.** After the digest proposals are ranked, the runner makes one
|
|
392
|
+
read-only `upstream-planner` call over that ranked set. The planner returns ordered steps;
|
|
393
|
+
each step names the proposal signatures it covers and the steps that block it. The runner
|
|
394
|
+
validates the plan (coverage, known keys, acyclic `dependsOn`), writes `plan-prompt.md` and
|
|
395
|
+
`plan.json` under the run tree, and creates one tracker item per step in the captured
|
|
396
|
+
`backlog` state — blockers first, so the store can accept the dependency edge. The
|
|
397
|
+
idempotency map is `upstream/tracker.json` (`plan key → item id`, `signature → per-run ids`):
|
|
398
|
+
a retry reuses an id instead of duplicating a step, and an idea imported by an earlier run is
|
|
399
|
+
not re-created. A missing prompt, a failed planner call, or an invalid plan is a digest gap,
|
|
400
|
+
never a failed research run; no tracker item is written without a validated plan. Set
|
|
401
|
+
`tracker.enabled` to `false` to skip planning, and `tracker.maxItems` (1…30, default 12) to
|
|
402
|
+
cap one plan. `backlog` is not launchable: a human promotes an item to `planned` in the
|
|
403
|
+
tracker UI or with `tracker set`.
|
|
365
404
|
|
|
366
405
|
**Failure surface.** The scheduler's reason codes are a closed set, so a runner code such as
|
|
367
406
|
`E_OPENCODE_MISSING` lives in `report.json`, `stderr.log`, and the digest header; the job row
|
|
368
407
|
reports `E_EXIT_10` / `E_EXIT_11` / `E_EXIT_12` / `E_EXIT_13` / `E_EXIT_15` / `E_EXIT_16`.
|
|
369
|
-
`E_AGENT_CONFIG_INVALID` (12) means the resolved `upstream-researcher`
|
|
370
|
-
every tool (the global `*` or a named action); reinstall
|
|
371
|
-
`init`/`update`.
|
|
408
|
+
`E_AGENT_CONFIG_INVALID` (12) means the resolved `upstream-researcher` or `upstream-planner`
|
|
409
|
+
no longer denies every tool (the global `*` or a named action); reinstall
|
|
410
|
+
`team/upstream/opencode.json` with `init`/`update`. Plan and tracker failures are `Gaps:` and
|
|
411
|
+
`report.plan`, not run exit codes.
|
|
372
412
|
|
|
373
413
|
**Commands.** Validate the registry with
|
|
374
414
|
`node .ai.local/scripts/upstream-research.mjs registry --check --team-root .`; refresh the
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Token economy
|
|
2
|
+
|
|
3
|
+
Scope: the fixed context cost `ai-rules` charges before a session does any work. `report-context-cost.mjs` prints, per host, the always-on files, their bytes, and a labelled `bytes / 4` estimate; then the Cursor fixture lines; then the bytes every task directory holds; then `usage_recorded` totals.
|
|
4
|
+
|
|
5
|
+
It counts **inputs**, not session tokens: prompt bytes and artifact bytes. Nothing tokenizes, nothing starts a session, and no number here is a measured token count or a claimed saving.
|
|
6
|
+
|
|
7
|
+
## Run it
|
|
8
|
+
|
|
9
|
+
From a repository checkout, at the package directory:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
cd packages/ai-rules
|
|
13
|
+
node scripts/report-context-cost.mjs # human tables
|
|
14
|
+
node scripts/report-context-cost.mjs --json # same data, machine-readable
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The script resolves the repository root from its own path, so it runs from any cwd. Node built-ins only; it writes nothing.
|
|
18
|
+
|
|
19
|
+
Exit code is 0 on success and 1 only when a required file exists but cannot be read. A host whose files are absent is still reported: empty `alwaysOnFiles`, a note in `rule`, bytes 0.
|
|
20
|
+
|
|
21
|
+
## Host rules
|
|
22
|
+
|
|
23
|
+
| Host | What is counted |
|
|
24
|
+
|---|---|
|
|
25
|
+
| OpenCode | every path in `.opencode/opencode.json` `instructions`, resolved against the repository root |
|
|
26
|
+
| Cursor | `.cursor/rules/**/*.mdc` with `alwaysApply: true` in frontmatter |
|
|
27
|
+
| Claude | `.claude/CLAUDE.md` plus `.claude/rules/**/*.md` with no `paths:` frontmatter key; `README.md` excluded |
|
|
28
|
+
| Mavis | entries with `loadMode: "root-entry"` in `packages/ai-rules/presets/mavis/next/adapter-map.json`, mapped to `.mavis/MAVIS.md`, `.mavis/rules/*.md`, and the root `AGENTS.md` |
|
|
29
|
+
| ZCode | the root `AGENTS.md`; ZCode loads it natively and has no per-tool map |
|
|
30
|
+
|
|
31
|
+
Each host entry repeats the rule it used, so every byte is attributable. `alwaysOnFiles` is repo-relative and sorted.
|
|
32
|
+
|
|
33
|
+
## JSON shape
|
|
34
|
+
|
|
35
|
+
Example run, 2026-11-13; file lists elided; task bytes move as a task grows.
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"generatedAt": "2026-11-13T14:11:07.317Z",
|
|
40
|
+
"root": "/abs/path/to/repo",
|
|
41
|
+
"hosts": {
|
|
42
|
+
"cursor": { "rule": "alwaysApply: true under .cursor/rules", "alwaysOnFiles": ["…"], "alwaysOnBytes": 12470, "estimatedTokens": 3118 },
|
|
43
|
+
"claude": { "rule": "CLAUDE.md + rules without paths: (README excluded)", "alwaysOnFiles": ["…"], "alwaysOnBytes": 16452, "estimatedTokens": 4113 },
|
|
44
|
+
"mavis": { "rule": "adapter-map root-entry: …", "alwaysOnFiles": ["…"], "alwaysOnBytes": 26298, "estimatedTokens": 6575 },
|
|
45
|
+
"opencode": { "rule": "opencode.json instructions", "alwaysOnFiles": ["…"], "alwaysOnBytes": 17285, "estimatedTokens": 4321 },
|
|
46
|
+
"zcode": { "rule": "root AGENTS.md (native entry; no per-tool map)", "alwaysOnFiles": ["AGENTS.md"], "alwaysOnBytes": 9648, "estimatedTokens": 2412 }
|
|
47
|
+
},
|
|
48
|
+
"fixtures": [
|
|
49
|
+
{ "key": "UI", "file": "app/src/ui/pages/Example/Example.tsx", "cap": 420, "attachedLines": 415, "headroom": 5 }
|
|
50
|
+
],
|
|
51
|
+
"tasks": [{ "slug": "context-cost-report", "files": 8, "bytes": 18257 }],
|
|
52
|
+
"usage": { "events": 0, "input": 0, "output": 0, "cached": 0 },
|
|
53
|
+
"outputGuard": {
|
|
54
|
+
"present": true,
|
|
55
|
+
"file": ".ai.local/team/output-guard/stats.jsonl",
|
|
56
|
+
"events": 10,
|
|
57
|
+
"invalid": 0,
|
|
58
|
+
"beforeBytes": 113996,
|
|
59
|
+
"afterBytes": 34189,
|
|
60
|
+
"savedBytes": 79807,
|
|
61
|
+
"savedRatio": 0.7,
|
|
62
|
+
"sessions": 1,
|
|
63
|
+
"tools": ["read", "shell"]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`fixtures` carries the seven fixtures from `check-next-attached-budget.mjs` and attaches them against `.cursor/rules`; that gate and its caps stay untouched.
|
|
69
|
+
|
|
70
|
+
`tasks` sums every file under `.ai.local/team/tasks/<slug>`, `archive/` included. A missing team directory returns `tasks: []`.
|
|
71
|
+
|
|
72
|
+
`outputGuard` reads `.ai.local/team/output-guard/stats.jsonl`, written by the OpenCode output guard. Rows are deduped by `path` because a plugin reload re-records a historical result. `savedRatio` is the byte saving on the replaced tool results, not a session-token claim; `invalid` counts unreadable rows. A missing file returns `present: false` and zeros.
|
|
73
|
+
|
|
74
|
+
## Effectiveness (separate report)
|
|
75
|
+
|
|
76
|
+
This report measures **fixed inputs**. It does not measure a session. The output guard writes two more ledgers under `.ai.local/team/output-guard/`:
|
|
77
|
+
|
|
78
|
+
- `results.jsonl` — every tool result, replaced or not (the denominator);
|
|
79
|
+
- `usage.jsonl` — one row per assistant step, from the OpenCode `ctx.session.context` tokens and cost.
|
|
80
|
+
|
|
81
|
+
`report-efficiency.mjs` reads both and prints measured tool bytes, input/output/reasoning/cache tokens, cost, turns, and quality. `bench-efficiency.mjs` runs an A/B (guard off/on) through `opencode run --standalone` with a deterministic oracle and writes `efficiency.json`; `report-efficiency --bench <file>` merges it. The byte percentage is always labelled as tool-result bytes, never as a token saving.
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
yarn report:efficiency
|
|
85
|
+
yarn report:efficiency --html /tmp/efficiency.html
|
|
86
|
+
yarn bench:efficiency --model <provider/model> --runs 3
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The A/B needs `--runs 5` for a verdict; `--runs 1` is a smoke. Each run starts a private server, so the arm env (`AI_RULES_OUTPUT_GUARD=0|1`) applies without touching the shared server.
|
|
90
|
+
|
|
91
|
+
`usage` sums `input`, `output`, and `cached` over `metrics.json` events with `type: "usage_recorded"`. Zero events is a valid result and prints as zero. A usage record that was never written stays missing; the report does not infer one.
|
|
92
|
+
|
|
93
|
+
## Baseline
|
|
94
|
+
|
|
95
|
+
Measured 2026-11-13 on the same file sets:
|
|
96
|
+
|
|
97
|
+
| Surface | Bytes |
|
|
98
|
+
|---|---|
|
|
99
|
+
| OpenCode always-on set (5 files) | 17,285 |
|
|
100
|
+
| Root `AGENTS.md` (ZCode entry; Mavis `REPO_AGENTS.md` target) | 9,648 |
|
|
101
|
+
|
|
102
|
+
Re-run the command for the current tree; these numbers move with any rule edit.
|
|
103
|
+
|
|
104
|
+
## Bytes are not tokens
|
|
105
|
+
|
|
106
|
+
`estimatedTokens` is `Math.round(bytes / 4)` for every host. The JSON key, the human output, and this page call it an estimate. No tokenizer runs, no model is called, no session is observed.
|
|
107
|
+
|
|
108
|
+
## Next steps
|
|
109
|
+
|
|
110
|
+
WP2…WP5 — externalize and search, prompt byte cap, PreToolUse size deny, `focus.md` pointer budget — are planned in `.ai.local/team/tasks/context-mode-token-economy/archive/2026-11-13/architecture.md` §4.
|