@bonesofspring/ai-rules 0.2.78 → 0.2.80
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 +47 -0
- package/README.md +4 -2
- package/bin/lib/engine-scripts.js +6 -0
- package/bin/lib/seed-ai-local-team.js +2 -0
- package/docs/TEAM-DB.md +118 -15
- package/docs/openapi/team-db.v1.json +2879 -1858
- package/package.json +5 -1
- package/presets/_shared/ai-local/scripts/check-task-repositories.mjs +264 -0
- package/presets/_shared/ai-local/scripts/rr-migrate-repositories.mjs +481 -0
- package/presets/_shared/ai-local/scripts/team-db-api.mjs +211 -12
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +289 -3
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +857 -1
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +68 -0
- package/presets/_shared/ai-local/scripts/team-db-tracker.mjs +29 -10
- package/presets/_shared/ai-local/scripts/team-db.mjs +46 -1
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +69 -1
- package/presets/claude/android-kotlin/agents/task-router.md +2 -0
- package/presets/claude/android-kotlin/commands/README.md +1 -0
- package/presets/claude/android-kotlin/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/android-kotlin/commands/task.md +4 -0
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +69 -1
- package/presets/claude/go/agents/task-router.md +2 -0
- package/presets/claude/go/commands/README.md +1 -0
- package/presets/claude/go/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/go/commands/task.md +4 -0
- package/presets/claude/go/hooks/chain-team-phases.sh +69 -1
- package/presets/claude/ios-swift/agents/task-router.md +2 -0
- package/presets/claude/ios-swift/commands/README.md +1 -0
- package/presets/claude/ios-swift/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/ios-swift/commands/task.md +4 -0
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +69 -1
- package/presets/claude/java/agents/task-router.md +2 -0
- package/presets/claude/java/commands/README.md +1 -0
- package/presets/claude/java/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/java/commands/task.md +4 -0
- package/presets/claude/java/hooks/chain-team-phases.sh +69 -1
- package/presets/claude/mcp-ts/agents/task-router.md +2 -0
- package/presets/claude/mcp-ts/commands/README.md +1 -0
- package/presets/claude/mcp-ts/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/mcp-ts/commands/task.md +4 -0
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +69 -1
- package/presets/claude/mol/agents/task-router.md +2 -0
- package/presets/claude/mol/commands/README.md +1 -0
- package/presets/claude/mol/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/mol/commands/task.md +4 -0
- package/presets/claude/mol/hooks/chain-team-phases.sh +69 -1
- package/presets/claude/next/agents/task-router.md +2 -0
- package/presets/claude/next/commands/README.md +1 -0
- package/presets/claude/next/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/next/commands/task.md +4 -0
- package/presets/claude/next/commands/ui-start.md +12 -4
- package/presets/claude/next/commands/ui-stop.md +5 -2
- package/presets/claude/next/hooks/chain-team-phases.sh +69 -1
- package/presets/claude/nuxt/agents/task-router.md +2 -0
- package/presets/claude/nuxt/commands/README.md +1 -0
- package/presets/claude/nuxt/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/nuxt/commands/task.md +4 -0
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +69 -1
- package/presets/claude/php-hexagonal/agents/task-router.md +2 -0
- package/presets/claude/php-hexagonal/commands/README.md +1 -0
- package/presets/claude/php-hexagonal/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/php-hexagonal/commands/task.md +4 -0
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +69 -1
- package/presets/claude/php-laravel/agents/task-router.md +2 -0
- package/presets/claude/php-laravel/commands/README.md +1 -0
- package/presets/claude/php-laravel/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/php-laravel/commands/task.md +4 -0
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +69 -1
- package/presets/claude/svelte/agents/task-router.md +2 -0
- package/presets/claude/svelte/commands/README.md +1 -0
- package/presets/claude/svelte/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/svelte/commands/task.md +4 -0
- package/presets/claude/svelte/hooks/chain-team-phases.sh +69 -1
- package/presets/cursor/android-kotlin/agents/task-router.md +2 -0
- package/presets/cursor/android-kotlin/commands/README.md +1 -0
- package/presets/cursor/android-kotlin/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/android-kotlin/commands/task.md +4 -0
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +69 -1
- package/presets/cursor/go/agents/task-router.md +2 -0
- package/presets/cursor/go/commands/README.md +1 -0
- package/presets/cursor/go/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/go/commands/task.md +4 -0
- package/presets/cursor/go/hooks/chain-team-phases.sh +69 -1
- package/presets/cursor/ios-swift/agents/task-router.md +2 -0
- package/presets/cursor/ios-swift/commands/README.md +1 -0
- package/presets/cursor/ios-swift/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/ios-swift/commands/task.md +4 -0
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +69 -1
- package/presets/cursor/java/agents/task-router.md +2 -0
- package/presets/cursor/java/commands/README.md +1 -0
- package/presets/cursor/java/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/java/commands/task.md +4 -0
- package/presets/cursor/java/hooks/chain-team-phases.sh +69 -1
- package/presets/cursor/mcp-ts/agents/task-router.md +2 -0
- package/presets/cursor/mcp-ts/commands/README.md +1 -0
- package/presets/cursor/mcp-ts/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/mcp-ts/commands/task.md +4 -0
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +69 -1
- package/presets/cursor/mol/agents/task-router.md +2 -0
- package/presets/cursor/mol/commands/README.md +1 -0
- package/presets/cursor/mol/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/mol/commands/task.md +4 -0
- package/presets/cursor/mol/hooks/chain-team-phases.sh +69 -1
- package/presets/cursor/next/agents/task-router.md +2 -0
- package/presets/cursor/next/commands/README.md +1 -0
- package/presets/cursor/next/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/next/commands/task.md +4 -0
- package/presets/cursor/next/commands/ui-start.md +12 -4
- package/presets/cursor/next/commands/ui-stop.md +5 -2
- package/presets/cursor/next/hooks/chain-team-phases.sh +69 -1
- package/presets/cursor/nuxt/agents/task-router.md +2 -0
- package/presets/cursor/nuxt/commands/README.md +1 -0
- package/presets/cursor/nuxt/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/nuxt/commands/task.md +4 -0
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +69 -1
- package/presets/cursor/php-hexagonal/agents/task-router.md +2 -0
- package/presets/cursor/php-hexagonal/commands/README.md +1 -0
- package/presets/cursor/php-hexagonal/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/php-hexagonal/commands/task.md +4 -0
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +69 -1
- package/presets/cursor/php-laravel/agents/task-router.md +2 -0
- package/presets/cursor/php-laravel/commands/README.md +1 -0
- package/presets/cursor/php-laravel/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/php-laravel/commands/task.md +4 -0
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +69 -1
- package/presets/cursor/svelte/agents/task-router.md +2 -0
- package/presets/cursor/svelte/commands/README.md +1 -0
- package/presets/cursor/svelte/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/svelte/commands/task.md +4 -0
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +69 -1
- package/presets/mavis/android-kotlin/adapter-map.json +9 -1
- package/presets/mavis/android-kotlin/agents/task-router.md +2 -0
- package/presets/mavis/android-kotlin/commands/README.md +1 -0
- package/presets/mavis/android-kotlin/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/android-kotlin/commands/task.md +4 -0
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +69 -1
- package/presets/mavis/go/adapter-map.json +9 -1
- package/presets/mavis/go/agents/task-router.md +2 -0
- package/presets/mavis/go/commands/README.md +1 -0
- package/presets/mavis/go/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/go/commands/task.md +4 -0
- package/presets/mavis/go/hooks/chain-team-phases.sh +69 -1
- package/presets/mavis/ios-swift/adapter-map.json +9 -1
- package/presets/mavis/ios-swift/agents/task-router.md +2 -0
- package/presets/mavis/ios-swift/commands/README.md +1 -0
- package/presets/mavis/ios-swift/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/ios-swift/commands/task.md +4 -0
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +69 -1
- package/presets/mavis/java/adapter-map.json +9 -1
- package/presets/mavis/java/agents/task-router.md +2 -0
- package/presets/mavis/java/commands/README.md +1 -0
- package/presets/mavis/java/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/java/commands/task.md +4 -0
- package/presets/mavis/java/hooks/chain-team-phases.sh +69 -1
- package/presets/mavis/mcp-ts/adapter-map.json +9 -1
- package/presets/mavis/mcp-ts/agents/task-router.md +2 -0
- package/presets/mavis/mcp-ts/commands/README.md +1 -0
- package/presets/mavis/mcp-ts/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/mcp-ts/commands/task.md +4 -0
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +69 -1
- package/presets/mavis/mol/adapter-map.json +9 -1
- package/presets/mavis/mol/agents/task-router.md +2 -0
- package/presets/mavis/mol/commands/README.md +1 -0
- package/presets/mavis/mol/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/mol/commands/task.md +4 -0
- package/presets/mavis/mol/hooks/chain-team-phases.sh +69 -1
- package/presets/mavis/next/adapter-map.json +9 -1
- package/presets/mavis/next/agents/task-router.md +2 -0
- package/presets/mavis/next/commands/README.md +1 -0
- package/presets/mavis/next/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/next/commands/task.md +4 -0
- package/presets/mavis/next/commands/ui-start.md +12 -4
- package/presets/mavis/next/commands/ui-stop.md +5 -2
- package/presets/mavis/next/hooks/chain-team-phases.sh +69 -1
- package/presets/mavis/nuxt/adapter-map.json +9 -1
- package/presets/mavis/nuxt/agents/task-router.md +2 -0
- package/presets/mavis/nuxt/commands/README.md +1 -0
- package/presets/mavis/nuxt/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/nuxt/commands/task.md +4 -0
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +69 -1
- package/presets/mavis/php-hexagonal/adapter-map.json +9 -1
- package/presets/mavis/php-hexagonal/agents/task-router.md +2 -0
- package/presets/mavis/php-hexagonal/commands/README.md +1 -0
- package/presets/mavis/php-hexagonal/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/php-hexagonal/commands/task.md +4 -0
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +69 -1
- package/presets/mavis/php-laravel/adapter-map.json +9 -1
- package/presets/mavis/php-laravel/agents/task-router.md +2 -0
- package/presets/mavis/php-laravel/commands/README.md +1 -0
- package/presets/mavis/php-laravel/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/php-laravel/commands/task.md +4 -0
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +69 -1
- package/presets/mavis/svelte/adapter-map.json +9 -1
- package/presets/mavis/svelte/agents/task-router.md +2 -0
- package/presets/mavis/svelte/commands/README.md +1 -0
- package/presets/mavis/svelte/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/svelte/commands/task.md +4 -0
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +69 -1
- package/presets/opencode/android-kotlin/adapter-map.json +9 -1
- package/presets/opencode/android-kotlin/agents/task-router.md +2 -0
- package/presets/opencode/android-kotlin/commands/README.md +1 -0
- package/presets/opencode/android-kotlin/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/android-kotlin/commands/task.md +4 -0
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +69 -1
- package/presets/opencode/go/adapter-map.json +9 -1
- package/presets/opencode/go/agents/task-router.md +2 -0
- package/presets/opencode/go/commands/README.md +1 -0
- package/presets/opencode/go/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/go/commands/task.md +4 -0
- package/presets/opencode/go/hooks/chain-team-phases.sh +69 -1
- package/presets/opencode/ios-swift/adapter-map.json +9 -1
- package/presets/opencode/ios-swift/agents/task-router.md +2 -0
- package/presets/opencode/ios-swift/commands/README.md +1 -0
- package/presets/opencode/ios-swift/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/ios-swift/commands/task.md +4 -0
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +69 -1
- package/presets/opencode/java/adapter-map.json +9 -1
- package/presets/opencode/java/agents/task-router.md +2 -0
- package/presets/opencode/java/commands/README.md +1 -0
- package/presets/opencode/java/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/java/commands/task.md +4 -0
- package/presets/opencode/java/hooks/chain-team-phases.sh +69 -1
- package/presets/opencode/mcp-ts/adapter-map.json +9 -1
- package/presets/opencode/mcp-ts/agents/task-router.md +2 -0
- package/presets/opencode/mcp-ts/commands/README.md +1 -0
- package/presets/opencode/mcp-ts/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/mcp-ts/commands/task.md +4 -0
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +69 -1
- package/presets/opencode/mol/adapter-map.json +9 -1
- package/presets/opencode/mol/agents/task-router.md +2 -0
- package/presets/opencode/mol/commands/README.md +1 -0
- package/presets/opencode/mol/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/mol/commands/task.md +4 -0
- package/presets/opencode/mol/hooks/chain-team-phases.sh +69 -1
- package/presets/opencode/next/adapter-map.json +9 -1
- package/presets/opencode/next/agents/task-router.md +2 -0
- package/presets/opencode/next/commands/README.md +1 -0
- package/presets/opencode/next/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/next/commands/task.md +4 -0
- package/presets/opencode/next/commands/ui-start.md +12 -4
- package/presets/opencode/next/commands/ui-stop.md +5 -2
- package/presets/opencode/next/hooks/chain-team-phases.sh +69 -1
- package/presets/opencode/nuxt/adapter-map.json +9 -1
- package/presets/opencode/nuxt/agents/task-router.md +2 -0
- package/presets/opencode/nuxt/commands/README.md +1 -0
- package/presets/opencode/nuxt/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/nuxt/commands/task.md +4 -0
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +69 -1
- package/presets/opencode/php-hexagonal/adapter-map.json +9 -1
- package/presets/opencode/php-hexagonal/agents/task-router.md +2 -0
- package/presets/opencode/php-hexagonal/commands/README.md +1 -0
- package/presets/opencode/php-hexagonal/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/php-hexagonal/commands/task.md +4 -0
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +69 -1
- package/presets/opencode/php-laravel/adapter-map.json +9 -1
- package/presets/opencode/php-laravel/agents/task-router.md +2 -0
- package/presets/opencode/php-laravel/commands/README.md +1 -0
- package/presets/opencode/php-laravel/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/php-laravel/commands/task.md +4 -0
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +69 -1
- package/presets/opencode/plugins/task-status/README.md +15 -7
- package/presets/opencode/plugins/task-status/deepseek.ts +193 -0
- package/presets/opencode/plugins/task-status/details-data.ts +39 -2
- package/presets/opencode/plugins/task-status/prompt-text.ts +18 -8
- package/presets/opencode/plugins/task-status/task-view.ts +253 -63
- package/presets/opencode/plugins/task-status/tui.tsx +48 -11
- package/presets/opencode/svelte/adapter-map.json +9 -1
- package/presets/opencode/svelte/agents/task-router.md +2 -0
- package/presets/opencode/svelte/commands/README.md +1 -0
- package/presets/opencode/svelte/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/svelte/commands/task.md +4 -0
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +69 -1
- package/presets/zcode/android-kotlin/adapter-map.json +9 -1
- package/presets/zcode/android-kotlin/agents/task-router.md +2 -0
- package/presets/zcode/android-kotlin/commands/README.md +1 -0
- package/presets/zcode/android-kotlin/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/android-kotlin/commands/task.md +4 -0
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +69 -1
- package/presets/zcode/go/adapter-map.json +9 -1
- package/presets/zcode/go/agents/task-router.md +2 -0
- package/presets/zcode/go/commands/README.md +1 -0
- package/presets/zcode/go/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/go/commands/task.md +4 -0
- package/presets/zcode/go/hooks/chain-team-phases.sh +69 -1
- package/presets/zcode/ios-swift/adapter-map.json +9 -1
- package/presets/zcode/ios-swift/agents/task-router.md +2 -0
- package/presets/zcode/ios-swift/commands/README.md +1 -0
- package/presets/zcode/ios-swift/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/ios-swift/commands/task.md +4 -0
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +69 -1
- package/presets/zcode/java/adapter-map.json +9 -1
- package/presets/zcode/java/agents/task-router.md +2 -0
- package/presets/zcode/java/commands/README.md +1 -0
- package/presets/zcode/java/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/java/commands/task.md +4 -0
- package/presets/zcode/java/hooks/chain-team-phases.sh +69 -1
- package/presets/zcode/mcp-ts/adapter-map.json +9 -1
- package/presets/zcode/mcp-ts/agents/task-router.md +2 -0
- package/presets/zcode/mcp-ts/commands/README.md +1 -0
- package/presets/zcode/mcp-ts/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/mcp-ts/commands/task.md +4 -0
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +69 -1
- package/presets/zcode/mol/adapter-map.json +9 -1
- package/presets/zcode/mol/agents/task-router.md +2 -0
- package/presets/zcode/mol/commands/README.md +1 -0
- package/presets/zcode/mol/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/mol/commands/task.md +4 -0
- package/presets/zcode/mol/hooks/chain-team-phases.sh +69 -1
- package/presets/zcode/next/adapter-map.json +9 -1
- package/presets/zcode/next/agents/task-router.md +2 -0
- package/presets/zcode/next/commands/README.md +1 -0
- package/presets/zcode/next/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/next/commands/task.md +4 -0
- package/presets/zcode/next/commands/ui-start.md +12 -4
- package/presets/zcode/next/commands/ui-stop.md +5 -2
- package/presets/zcode/next/hooks/chain-team-phases.sh +69 -1
- package/presets/zcode/nuxt/adapter-map.json +9 -1
- package/presets/zcode/nuxt/agents/task-router.md +2 -0
- package/presets/zcode/nuxt/commands/README.md +1 -0
- package/presets/zcode/nuxt/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/nuxt/commands/task.md +4 -0
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +69 -1
- package/presets/zcode/php-hexagonal/adapter-map.json +9 -1
- package/presets/zcode/php-hexagonal/agents/task-router.md +2 -0
- package/presets/zcode/php-hexagonal/commands/README.md +1 -0
- package/presets/zcode/php-hexagonal/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/php-hexagonal/commands/task.md +4 -0
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +69 -1
- package/presets/zcode/php-laravel/adapter-map.json +9 -1
- package/presets/zcode/php-laravel/agents/task-router.md +2 -0
- package/presets/zcode/php-laravel/commands/README.md +1 -0
- package/presets/zcode/php-laravel/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/php-laravel/commands/task.md +4 -0
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +69 -1
- package/presets/zcode/svelte/adapter-map.json +9 -1
- package/presets/zcode/svelte/agents/task-router.md +2 -0
- package/presets/zcode/svelte/commands/README.md +1 -0
- package/presets/zcode/svelte/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/svelte/commands/task.md +4 -0
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +69 -1
|
@@ -12,20 +12,23 @@ Modelled on the built-in MCP sidebar plugin (`packages/tui/src/feature-plugins/s
|
|
|
12
12
|
- the `eta` row reads `~52m · p90 3h 32m`: estimated time to finish the remaining plan steps. It hides while the run waits on a human gate, is paused, blocked, waiting for a receipt, or is done. A stale run keeps it — the estimate is historical, not live — and with fewer than 3 ledgers the row reads `—` instead of disappearing
|
|
13
13
|
- clicking any row opens a details dialog with 3-cell side padding: `goal.md`, pipeline steps with the current one marked, artifacts from `artifact-manifest.json`, the last manifest entries, the prompt, the last update age and the ETA with its ledger count. The body scrolls with ↑/↓, PgUp/PgDn, Home/End or the mouse wheel; `esc` closes it.
|
|
14
14
|
- a live task shows `■ stop` in the header; click → confirm → writes the task-scoped `.ai.local/team/tasks/<slug>/STOP` (the repo-wide `.ai.local/STOP` only when the task directory is gone). The in-flight attempt finishes, no next step starts. A task with a stop sentinel shows `▶ resume` instead: confirm clears it. Saying `/task-continue <slug>` (or `продолжай` / `continue`) in a matched session is the keyboard path. <!-- i18n-keep: E4 -->
|
|
15
|
+
- a `DeepSeek` row under the fields reads `[peak]` in red or `[off-peak]` in green: the current DeepSeek billing window, read from the same file catalog as the team-tasks UI — the peak `windows` linked to the `DeepSeek` provider under the nearest `.ai.local/catalog` above the project directory (whole-hour windows, end hour inclusive, overnight wrap). Without a catalog — a project that never ran the catalog sync — the row falls back to the published schedule shipped with the plugin: 09:00–12:00 and 14:00–18:00 Asia/Shanghai, Monday–Friday. Chinese public holidays are off-peak all day but are not tracked, so a holiday weekday still reads `peak` inside a window
|
|
15
16
|
- a stale task reads `◌ stale · 8d 17h ago` with a muted tone instead of pretending to run
|
|
16
17
|
- the open flag lives in `context.storage.store("panel", { initial: { open: true } })`, so it survives restarts; the live view stays in `context.storage.memory`
|
|
17
18
|
- values use `wrapMode="none" truncate` and `minWidth={0}`, so a narrow sidebar truncates instead of wrapping
|
|
18
19
|
|
|
19
20
|
## Data
|
|
20
21
|
|
|
21
|
-
Reads the nearest `.ai.local/team/` above the session directory:
|
|
22
|
+
Reads the nearest `.ai.local/team/` above the session directory, and the DeepSeek peak windows from the nearest `.ai.local/catalog/` — the same `providers`/`links`/`windows` records `apps/team-tasks-ui` reads:
|
|
22
23
|
|
|
23
|
-
- `tasks/<slug>/prompt.md
|
|
24
|
+
- `tasks/<slug>/prompt.md` — the original prompt, the session-matching anchor
|
|
25
|
+
- `tasks/<slug>/prompt-log.md` — the follow-up log, shown in the details dialog only
|
|
24
26
|
- `tasks/<slug>/status.json` — state, attempts, gate, timestamps
|
|
25
27
|
- `tasks/<slug>/pipeline.json` — step count and the agent for each remaining step
|
|
26
28
|
- `tasks/<slug>/metrics.json` — task start, role per attempt, attempt durations
|
|
27
29
|
- `tasks/<slug>/artifact-manifest.json` — producer receipts that feed the details dialog
|
|
28
30
|
- every `tasks/*/metrics.json` — historical attempt durations that feed the ETA medians
|
|
31
|
+
- `output-guard/results*.jsonl` — tool-byte totals for the economy block, read incrementally
|
|
29
32
|
|
|
30
33
|
## ETA
|
|
31
34
|
|
|
@@ -47,12 +50,17 @@ The number excludes human gates and ignores parallelism between steps, so the ac
|
|
|
47
50
|
|
|
48
51
|
The sidebar renders the session the host passes into the `sidebar.content` slot (`input.sessionID`), not the router's current route: with session tabs the route and the visible sidebar can differ. The router is only a fallback when the slot input is empty. Every tick the plugin reads that session's user messages (`client.message.list`, `type=user`, oldest first, up to five pages) and matches them against the prompt index:
|
|
49
52
|
|
|
50
|
-
-
|
|
51
|
-
- the match
|
|
52
|
-
- a
|
|
53
|
+
- the index holds `prompt.md` only. `prompt-log.md` stores every follow-up, confirmations included, so it is a details-dialog source and never a matching source
|
|
54
|
+
- the match anchors on the session's **opening prompt**; a later `делай` / `продолжай` / `подтверждаю` cannot re-map the tab to another task <!-- i18n-keep: E4 — Russian confirmation words quoted in prose -->
|
|
55
|
+
- tiers: an exact prompt match wins; otherwise a substring match of at least 40 characters over the remaining messages. A confirmation word is ignored at every tier
|
|
56
|
+
- a `/task-continue <slug>` message maps the tab directly to that slug, case-insensitively; an unknown slug falls back to the prompt match instead of hiding the task
|
|
57
|
+
- the first successful mapping is pinned for the session, so a new message cannot flip the tab; an explicit `/task-continue <other-slug>` re-binds it
|
|
58
|
+
- the match is memoized per prompt-index generation and a fingerprint of every message, so the one-second tick does not re-scan every prompt
|
|
59
|
+
- a `/task ...` prefix on the prompt is stripped on both sides, so a `prompt.md` written with or without the command matches
|
|
53
60
|
- a subagent session maps through `data.session.root(sessionID)`, so its sidebar shows the parent task
|
|
54
61
|
- no match → `prompt <session title>` and `state no task`; an `Untitled session` title falls back to the first user message
|
|
55
62
|
- a task with `prompt.md` but no `status.json` renders as a note (`note · 33m`)
|
|
63
|
+
- the slot input is trusted only while `data.session.get(slot.sessionID)` still resolves, so a closed tab cannot leak its task into the next one
|
|
56
64
|
|
|
57
65
|
Session messages refresh every 5s and the prompt index every 30s, so a `/task` tab picks up its task as soon as the agent writes `prompt.md`. The old global `active-task.json` pointer is no longer used for selection; it only helps locate the team root.
|
|
58
66
|
|
|
@@ -96,8 +104,8 @@ The sidebar is session-scoped and follows `session.sidebar.toggle` (`ctrl+x b`).
|
|
|
96
104
|
## Limits
|
|
97
105
|
|
|
98
106
|
- The stop button writes the task-scoped `tasks/<slug>/STOP`; the repo-wide `.ai.local/STOP` is the fallback when that directory is gone and remains the operator's own pause, so it blocks new steps for every task.
|
|
99
|
-
- The resume intent clears a sentinel only
|
|
100
|
-
- Mapping relies on prompt text: a task without `prompt.md`
|
|
107
|
+
- The resume intent clears a task-scoped sentinel only for the session's pinned task; a repository-wide `.ai.local/STOP` is lifted only by an explicit `/task-continue <slug>`, never by a text match in an unrelated session. <!-- i18n-keep: E4 -->
|
|
108
|
+
- Mapping relies on prompt text: a task without `prompt.md` cannot be matched, so its tab falls back to the prompt view. A session whose first message is not the prompt (for example a resumed tab opened with a bare `продолжай`) needs `/task-continue <slug>`. <!-- i18n-keep: E4 -->
|
|
101
109
|
- With a remote server, messages come from the server but the prompt files are read from the client filesystem; a failed message fetch keeps the last view and marks it `offline` for a minute.
|
|
102
110
|
- `status.json` timestamps are the only clock: a task paused for days shows total wall time plus a `stale` marker.
|
|
103
111
|
- A timestamp later than the host clock is ignored; a future `task_started` in agent-written metrics would otherwise freeze the elapsed value at `0s`.
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The DeepSeek billing window at a given instant.
|
|
3
|
+
*
|
|
4
|
+
* Peak windows come from the same file-authoritative catalog the team-tasks
|
|
5
|
+
* UI reads: the `windows` records linked to the `DeepSeek` provider under
|
|
6
|
+
* `.ai.local/catalog` (synced by the `opencode-models-sync` job). Window
|
|
7
|
+
* semantics mirror `apps/team-tasks-ui/src/lib/catalog/effectiveWindow.ts`:
|
|
8
|
+
* weekly windows match whole hours with the end hour inclusive and
|
|
9
|
+
* `startHour > endHour` spanning midnight; absolute windows match
|
|
10
|
+
* `[startAt, endAt]`. When no catalog is reachable — a project that never ran
|
|
11
|
+
* the catalog sync — the published schedule shipped below applies unchanged.
|
|
12
|
+
*
|
|
13
|
+
* Chinese public holidays are off-peak all day, but a holiday calendar is not
|
|
14
|
+
* shipped here, so a holiday weekday still reads `peak` inside a window.
|
|
15
|
+
*
|
|
16
|
+
* Source: https://api-docs.deepseek.com/quick_start/pricing
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import fs from "node:fs"
|
|
20
|
+
import path from "node:path"
|
|
21
|
+
|
|
22
|
+
export type DeepseekRate = "peak" | "off-peak"
|
|
23
|
+
|
|
24
|
+
type WeeklyWindow = {
|
|
25
|
+
shape: "weekly"
|
|
26
|
+
weekdays: number[]
|
|
27
|
+
startHour: number
|
|
28
|
+
endHour: number
|
|
29
|
+
timezone: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type AbsoluteWindow = {
|
|
33
|
+
shape: "absolute"
|
|
34
|
+
startAt: string
|
|
35
|
+
endAt: string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type PeakWindow = WeeklyWindow | AbsoluteWindow
|
|
39
|
+
|
|
40
|
+
const PROVIDER_NAME = "DeepSeek"
|
|
41
|
+
const CATALOG_TTL_MS = 10 * 60 * 1000
|
|
42
|
+
|
|
43
|
+
const DEFAULT_WINDOWS: readonly PeakWindow[] = [
|
|
44
|
+
{ shape: "weekly", weekdays: [1, 2, 3, 4, 5], startHour: 9, endHour: 12, timezone: "Asia/Shanghai" },
|
|
45
|
+
{ shape: "weekly", weekdays: [1, 2, 3, 4, 5], startHour: 14, endHour: 18, timezone: "Asia/Shanghai" },
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
type CatalogProvider = { id: number; name?: string }
|
|
49
|
+
type CatalogLink = { windowId?: number; targetType?: string; targetId?: number }
|
|
50
|
+
type CatalogWindow = {
|
|
51
|
+
id?: number
|
|
52
|
+
kind?: string
|
|
53
|
+
shape?: string
|
|
54
|
+
weekdays?: number[]
|
|
55
|
+
startHour?: number
|
|
56
|
+
endHour?: number
|
|
57
|
+
timezone?: string
|
|
58
|
+
startAt?: string
|
|
59
|
+
endAt?: string
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const readRecords = <T>(directory: string): T[] => {
|
|
63
|
+
try {
|
|
64
|
+
return fs
|
|
65
|
+
.readdirSync(directory, { withFileTypes: true })
|
|
66
|
+
.filter((entry) => entry.isFile() && entry.name.endsWith(".json"))
|
|
67
|
+
.flatMap((entry) => {
|
|
68
|
+
try {
|
|
69
|
+
return [JSON.parse(fs.readFileSync(path.join(directory, entry.name), "utf8")) as T]
|
|
70
|
+
} catch {
|
|
71
|
+
return []
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
} catch {
|
|
75
|
+
return []
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The catalog root the UI would resolve for the same project, `CATALOG_ROOT` override included. */
|
|
80
|
+
const resolveCatalogRoot = (directory: string | undefined): string | undefined => {
|
|
81
|
+
const override = process.env.CATALOG_ROOT
|
|
82
|
+
if (override !== undefined && override !== "") return path.resolve(override)
|
|
83
|
+
|
|
84
|
+
let current = directory === undefined ? undefined : path.resolve(directory)
|
|
85
|
+
for (let level = 0; current !== undefined && level < 5; level += 1) {
|
|
86
|
+
const candidate = path.join(current, ".ai.local", "catalog")
|
|
87
|
+
if (fs.existsSync(candidate)) return candidate
|
|
88
|
+
const parent = path.dirname(current)
|
|
89
|
+
if (parent === current) break
|
|
90
|
+
current = parent
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return undefined
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const asPeakWindow = (window: CatalogWindow): PeakWindow | null => {
|
|
97
|
+
if (window.kind !== "peak") return null
|
|
98
|
+
if (window.shape === "weekly" && Array.isArray(window.weekdays)) {
|
|
99
|
+
return {
|
|
100
|
+
shape: "weekly",
|
|
101
|
+
weekdays: window.weekdays,
|
|
102
|
+
startHour: window.startHour ?? 0,
|
|
103
|
+
endHour: window.endHour ?? 0,
|
|
104
|
+
timezone: window.timezone ?? "UTC",
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (window.shape === "absolute" && window.startAt !== undefined && window.endAt !== undefined) {
|
|
108
|
+
return { shape: "absolute", startAt: window.startAt, endAt: window.endAt }
|
|
109
|
+
}
|
|
110
|
+
return null
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const loadPeakWindows = (root: string): readonly PeakWindow[] | null => {
|
|
114
|
+
const provider = readRecords<CatalogProvider>(path.join(root, "providers")).find(
|
|
115
|
+
(candidate) => candidate?.name === PROVIDER_NAME,
|
|
116
|
+
)
|
|
117
|
+
if (provider === undefined) return null
|
|
118
|
+
|
|
119
|
+
const windowIds = new Set(
|
|
120
|
+
readRecords<CatalogLink>(path.join(root, "links"))
|
|
121
|
+
.filter((link) => link?.targetType === "provider" && link.targetId === provider.id)
|
|
122
|
+
.map((link) => link.windowId),
|
|
123
|
+
)
|
|
124
|
+
if (windowIds.size === 0) return null
|
|
125
|
+
|
|
126
|
+
const windows = readRecords<CatalogWindow>(path.join(root, "windows")).flatMap((window) => {
|
|
127
|
+
const id = window?.id
|
|
128
|
+
return id !== undefined && windowIds.has(id) ? [window] : []
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
const peak = windows.map(asPeakWindow).filter((window): window is PeakWindow => window !== null)
|
|
132
|
+
return peak.length > 0 ? peak : null
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let cache: { root: string; atMs: number; windows: readonly PeakWindow[] } | undefined
|
|
136
|
+
|
|
137
|
+
const peakWindows = (directory: string | undefined): readonly PeakWindow[] => {
|
|
138
|
+
const root = resolveCatalogRoot(directory)
|
|
139
|
+
if (root === undefined) return DEFAULT_WINDOWS
|
|
140
|
+
if (cache?.root === root && Date.now() - cache.atMs < CATALOG_TTL_MS) return cache.windows
|
|
141
|
+
|
|
142
|
+
const windows = loadPeakWindows(root) ?? DEFAULT_WINDOWS
|
|
143
|
+
cache = { root, atMs: Date.now(), windows }
|
|
144
|
+
return windows
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** The wall-clock parts of `at` in an IANA zone, on the JS weekday convention. */
|
|
148
|
+
const partsInTimeZone = (at: Date, timeZone: string): { weekday: number; hour: number } => {
|
|
149
|
+
const parts = new Intl.DateTimeFormat("en-CA", {
|
|
150
|
+
timeZone,
|
|
151
|
+
year: "numeric",
|
|
152
|
+
month: "2-digit",
|
|
153
|
+
day: "2-digit",
|
|
154
|
+
hour: "2-digit",
|
|
155
|
+
minute: "2-digit",
|
|
156
|
+
second: "2-digit",
|
|
157
|
+
hourCycle: "h23",
|
|
158
|
+
}).formatToParts(at)
|
|
159
|
+
|
|
160
|
+
const valueOf = (type: Intl.DateTimeFormatPartTypes): string =>
|
|
161
|
+
parts.find((part) => part.type === type)?.value ?? ""
|
|
162
|
+
|
|
163
|
+
const asUtc = Date.UTC(
|
|
164
|
+
Number(valueOf("year")),
|
|
165
|
+
Number(valueOf("month")) - 1,
|
|
166
|
+
Number(valueOf("day")),
|
|
167
|
+
Number(valueOf("hour")),
|
|
168
|
+
Number(valueOf("minute")),
|
|
169
|
+
Number(valueOf("second")),
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
const shifted = new Date(asUtc)
|
|
173
|
+
return { weekday: shifted.getUTCDay(), hour: shifted.getUTCHours() }
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const hourInRange = (hour: number, startHour: number, endHour: number): boolean => {
|
|
177
|
+
if (startHour < endHour) return hour >= startHour && hour <= endHour
|
|
178
|
+
if (startHour > endHour) return hour >= startHour || hour <= endHour
|
|
179
|
+
return hour === startHour
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const isPeakAt = (window: PeakWindow, at: Date): boolean => {
|
|
183
|
+
if (window.shape === "absolute") {
|
|
184
|
+
const instant = at.getTime()
|
|
185
|
+
return instant >= Date.parse(window.startAt) && instant <= Date.parse(window.endAt)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const { weekday, hour } = partsInTimeZone(at, window.timezone)
|
|
189
|
+
return window.weekdays.includes(weekday) && hourInRange(hour, window.startHour, window.endHour)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export const deepseekRate = (now: Date, directory?: string): DeepseekRate =>
|
|
193
|
+
peakWindows(directory).some((window) => isPeakAt(window, now)) ? "peak" : "off-peak"
|
|
@@ -43,6 +43,39 @@ const readJson = <T>(file: string): T | null => {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
type EtaStats = ReturnType<typeof createEtaStats>
|
|
47
|
+
|
|
48
|
+
const DETAILS_MS = 5000
|
|
49
|
+
const STATS_MS = 30_000
|
|
50
|
+
const SIGNATURE_FILES = [
|
|
51
|
+
"status.json",
|
|
52
|
+
"pipeline.json",
|
|
53
|
+
"artifact-manifest.json",
|
|
54
|
+
"metrics.json",
|
|
55
|
+
"goal.md",
|
|
56
|
+
"prompt.md",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
let statsCache: { root: string; at: number; stats: EtaStats } | undefined
|
|
60
|
+
let detailsCache: { key: string; at: number; value: Details } | undefined
|
|
61
|
+
|
|
62
|
+
/** The ETA index scans every `metrics.json`; the dialog must not do that per render. */
|
|
63
|
+
const etaStatsFor = (root: string, now: number): EtaStats => {
|
|
64
|
+
if (statsCache && statsCache.root === root && now - statsCache.at < STATS_MS) return statsCache.stats
|
|
65
|
+
const stats = createEtaStats(root, readJson)
|
|
66
|
+
statsCache = { root, at: now, stats }
|
|
67
|
+
return stats
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const signature = (taskDir: string): string =>
|
|
71
|
+
SIGNATURE_FILES.map((file) => {
|
|
72
|
+
try {
|
|
73
|
+
return fs.statSync(path.join(taskDir, file)).mtimeMs
|
|
74
|
+
} catch {
|
|
75
|
+
return 0
|
|
76
|
+
}
|
|
77
|
+
}).join("|")
|
|
78
|
+
|
|
46
79
|
const section = (raw: string, heading: string, limit: number): string | undefined => {
|
|
47
80
|
const lines = raw.split("\n")
|
|
48
81
|
const start = lines.findIndex((line) => new RegExp(`^#+\\s*${heading}\\s*$`, "i").test(line.trim()))
|
|
@@ -59,6 +92,8 @@ const section = (raw: string, heading: string, limit: number): string | undefine
|
|
|
59
92
|
|
|
60
93
|
export const buildDetails = (root: string, slug: string, now = Date.now()): Details => {
|
|
61
94
|
const taskDir = path.join(root, "tasks", slug)
|
|
95
|
+
const key = `${taskDir}|${signature(taskDir)}`
|
|
96
|
+
if (detailsCache && detailsCache.key === key && now - detailsCache.at < DETAILS_MS) return detailsCache.value
|
|
62
97
|
const status = readJson<Status>(path.join(taskDir, "status.json"))
|
|
63
98
|
const pipeline = readJson<Pipeline>(path.join(taskDir, "pipeline.json"))
|
|
64
99
|
const manifest = readJson<Manifest>(path.join(taskDir, "artifact-manifest.json"))
|
|
@@ -124,7 +159,7 @@ export const buildDetails = (root: string, slug: string, now = Date.now()): Deta
|
|
|
124
159
|
const updatedAt = status?.updatedAt ? Date.parse(status.updatedAt) : Number.NaN
|
|
125
160
|
const updatedLine = Number.isFinite(updatedAt) ? `updated ${formatAge(Math.max(0, now - updatedAt))}` : undefined
|
|
126
161
|
|
|
127
|
-
const stats =
|
|
162
|
+
const stats = etaStatsFor(root, now)
|
|
128
163
|
const estimate = estimateEta(pipeline?.steps ?? [], status ?? {}, metrics?.events ?? [], stats, now)
|
|
129
164
|
const eta =
|
|
130
165
|
(pipeline?.steps?.length ?? 0) === 0
|
|
@@ -133,7 +168,7 @@ export const buildDetails = (root: string, slug: string, now = Date.now()): Deta
|
|
|
133
168
|
? `${formatEta(estimate)} · ${stats.tasks} ledgers`
|
|
134
169
|
: `— · ${stats.tasks}/3 ledgers`
|
|
135
170
|
|
|
136
|
-
|
|
171
|
+
const value: Details = {
|
|
137
172
|
slug,
|
|
138
173
|
stateLine,
|
|
139
174
|
updatedLine,
|
|
@@ -145,4 +180,6 @@ export const buildDetails = (root: string, slug: string, now = Date.now()): Deta
|
|
|
145
180
|
manifest: manifestRows,
|
|
146
181
|
eta,
|
|
147
182
|
}
|
|
183
|
+
detailsCache = { key, at: now, value }
|
|
184
|
+
return value
|
|
148
185
|
}
|
|
@@ -1,27 +1,37 @@
|
|
|
1
|
-
const META_LINE = /^(language|slug|created|source|command|capturedAt):/i
|
|
1
|
+
const META_LINE = /^(?:[-*]\s*)?(language|slug|created|source|command|capturedAt):/i
|
|
2
|
+
const PROMPT_HEADING = /^#+\s*(?:verbatim prompt|original prompt|prompt)\s*$/i
|
|
2
3
|
|
|
3
4
|
export const normalize = (text: string): string => text.toLowerCase().replace(/\s+/g, " ").trim()
|
|
4
5
|
|
|
5
6
|
export const stripFrontmatter = (text: string): string =>
|
|
6
7
|
text.startsWith("---") ? text.replace(/^---[\s\S]*?\n---\s*/, "") : text
|
|
7
8
|
|
|
9
|
+
const isHeading = (line: string): boolean => /^#+\s/.test(line)
|
|
10
|
+
|
|
11
|
+
const isFence = (line: string): boolean => line.startsWith("```")
|
|
12
|
+
|
|
8
13
|
/**
|
|
9
|
-
* The user's words from a `prompt.md
|
|
10
|
-
*
|
|
11
|
-
*
|
|
14
|
+
* The user's words from a `prompt.md`. Handles the `# Verbatim prompt` and the
|
|
15
|
+
* legacy `# Original prompt` headings, a bare body, and both bare and list-style
|
|
16
|
+
* meta lines (`source: user`, `- source: user`). Fences are markup, not text.
|
|
12
17
|
*/
|
|
13
18
|
export const verbatimPrompt = (raw: string): string => {
|
|
14
19
|
const lines = stripFrontmatter(raw).split("\n")
|
|
15
|
-
const start = lines.findIndex((line) =>
|
|
20
|
+
const start = lines.findIndex((line) => PROMPT_HEADING.test(line.trim()))
|
|
16
21
|
const slice = start >= 0 ? lines.slice(start + 1) : lines
|
|
17
22
|
const kept: string[] = []
|
|
23
|
+
let fenced = false
|
|
18
24
|
for (const line of slice) {
|
|
19
|
-
|
|
25
|
+
const trimmed = line.trim()
|
|
26
|
+
if (isFence(trimmed)) {
|
|
27
|
+
fenced = !fenced
|
|
28
|
+
continue
|
|
29
|
+
}
|
|
30
|
+
if (!fenced && isHeading(trimmed)) {
|
|
20
31
|
if (start >= 0) break
|
|
21
32
|
continue
|
|
22
33
|
}
|
|
23
|
-
|
|
24
|
-
if (trimmed === "" || trimmed.startsWith("```") || META_LINE.test(trimmed)) continue
|
|
34
|
+
if (!fenced && (trimmed === "" || META_LINE.test(trimmed))) continue
|
|
25
35
|
kept.push(trimmed)
|
|
26
36
|
}
|
|
27
37
|
return kept.join("\n")
|