@blxzer/cursor-trellis 0.1.0
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 +45 -0
- package/LICENSE +235 -0
- package/README.md +9 -0
- package/bin/smart-search.js +79 -0
- package/bin/trellis.js +3 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +258 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/commands/channel/adapters/claude.d.ts +29 -0
- package/dist/commands/channel/adapters/claude.d.ts.map +1 -0
- package/dist/commands/channel/adapters/claude.js +203 -0
- package/dist/commands/channel/adapters/claude.js.map +1 -0
- package/dist/commands/channel/adapters/codex.d.ts +85 -0
- package/dist/commands/channel/adapters/codex.d.ts.map +1 -0
- package/dist/commands/channel/adapters/codex.js +505 -0
- package/dist/commands/channel/adapters/codex.js.map +1 -0
- package/dist/commands/channel/adapters/index.d.ts +84 -0
- package/dist/commands/channel/adapters/index.d.ts.map +1 -0
- package/dist/commands/channel/adapters/index.js +115 -0
- package/dist/commands/channel/adapters/index.js.map +1 -0
- package/dist/commands/channel/adapters/types.d.ts +33 -0
- package/dist/commands/channel/adapters/types.d.ts.map +1 -0
- package/dist/commands/channel/adapters/types.js +2 -0
- package/dist/commands/channel/adapters/types.js.map +1 -0
- package/dist/commands/channel/agent-loader.d.ts +32 -0
- package/dist/commands/channel/agent-loader.d.ts.map +1 -0
- package/dist/commands/channel/agent-loader.js +154 -0
- package/dist/commands/channel/agent-loader.js.map +1 -0
- package/dist/commands/channel/context-loader.d.ts +26 -0
- package/dist/commands/channel/context-loader.d.ts.map +1 -0
- package/dist/commands/channel/context-loader.js +290 -0
- package/dist/commands/channel/context-loader.js.map +1 -0
- package/dist/commands/channel/context.d.ts +16 -0
- package/dist/commands/channel/context.d.ts.map +1 -0
- package/dist/commands/channel/context.js +83 -0
- package/dist/commands/channel/context.js.map +1 -0
- package/dist/commands/channel/create.d.ts +27 -0
- package/dist/commands/channel/create.d.ts.map +1 -0
- package/dist/commands/channel/create.js +39 -0
- package/dist/commands/channel/create.js.map +1 -0
- package/dist/commands/channel/dev-parse-trace.d.ts +14 -0
- package/dist/commands/channel/dev-parse-trace.d.ts.map +1 -0
- package/dist/commands/channel/dev-parse-trace.js +70 -0
- package/dist/commands/channel/dev-parse-trace.js.map +1 -0
- package/dist/commands/channel/guard.d.ts +150 -0
- package/dist/commands/channel/guard.d.ts.map +1 -0
- package/dist/commands/channel/guard.js +474 -0
- package/dist/commands/channel/guard.js.map +1 -0
- package/dist/commands/channel/index.d.ts +3 -0
- package/dist/commands/channel/index.d.ts.map +1 -0
- package/dist/commands/channel/index.js +531 -0
- package/dist/commands/channel/index.js.map +1 -0
- package/dist/commands/channel/interrupt.d.ts +10 -0
- package/dist/commands/channel/interrupt.d.ts.map +1 -0
- package/dist/commands/channel/interrupt.js +22 -0
- package/dist/commands/channel/interrupt.js.map +1 -0
- package/dist/commands/channel/kill.d.ts +7 -0
- package/dist/commands/channel/kill.d.ts.map +1 -0
- package/dist/commands/channel/kill.js +121 -0
- package/dist/commands/channel/kill.js.map +1 -0
- package/dist/commands/channel/list.d.ts +17 -0
- package/dist/commands/channel/list.d.ts.map +1 -0
- package/dist/commands/channel/list.js +233 -0
- package/dist/commands/channel/list.js.map +1 -0
- package/dist/commands/channel/messages.d.ts +15 -0
- package/dist/commands/channel/messages.d.ts.map +1 -0
- package/dist/commands/channel/messages.js +245 -0
- package/dist/commands/channel/messages.js.map +1 -0
- package/dist/commands/channel/rm.d.ts +27 -0
- package/dist/commands/channel/rm.d.ts.map +1 -0
- package/dist/commands/channel/rm.js +216 -0
- package/dist/commands/channel/rm.js.map +1 -0
- package/dist/commands/channel/run.d.ts +30 -0
- package/dist/commands/channel/run.d.ts.map +1 -0
- package/dist/commands/channel/run.js +130 -0
- package/dist/commands/channel/run.js.map +1 -0
- package/dist/commands/channel/send.d.ts +11 -0
- package/dist/commands/channel/send.d.ts.map +1 -0
- package/dist/commands/channel/send.js +24 -0
- package/dist/commands/channel/send.js.map +1 -0
- package/dist/commands/channel/spawn.d.ts +40 -0
- package/dist/commands/channel/spawn.d.ts.map +1 -0
- package/dist/commands/channel/spawn.js +244 -0
- package/dist/commands/channel/spawn.js.map +1 -0
- package/dist/commands/channel/store/events.d.ts +39 -0
- package/dist/commands/channel/store/events.d.ts.map +1 -0
- package/dist/commands/channel/store/events.js +87 -0
- package/dist/commands/channel/store/events.js.map +1 -0
- package/dist/commands/channel/store/filter.d.ts +3 -0
- package/dist/commands/channel/store/filter.d.ts.map +1 -0
- package/dist/commands/channel/store/filter.js +2 -0
- package/dist/commands/channel/store/filter.js.map +1 -0
- package/dist/commands/channel/store/lock.d.ts +23 -0
- package/dist/commands/channel/store/lock.d.ts.map +1 -0
- package/dist/commands/channel/store/lock.js +99 -0
- package/dist/commands/channel/store/lock.js.map +1 -0
- package/dist/commands/channel/store/paths.d.ts +63 -0
- package/dist/commands/channel/store/paths.d.ts.map +1 -0
- package/dist/commands/channel/store/paths.js +246 -0
- package/dist/commands/channel/store/paths.js.map +1 -0
- package/dist/commands/channel/store/schema.d.ts +27 -0
- package/dist/commands/channel/store/schema.d.ts.map +1 -0
- package/dist/commands/channel/store/schema.js +34 -0
- package/dist/commands/channel/store/schema.js.map +1 -0
- package/dist/commands/channel/store/thread-state.d.ts +5 -0
- package/dist/commands/channel/store/thread-state.d.ts.map +1 -0
- package/dist/commands/channel/store/thread-state.js +16 -0
- package/dist/commands/channel/store/thread-state.js.map +1 -0
- package/dist/commands/channel/store/watch.d.ts +19 -0
- package/dist/commands/channel/store/watch.d.ts.map +1 -0
- package/dist/commands/channel/store/watch.js +146 -0
- package/dist/commands/channel/store/watch.js.map +1 -0
- package/dist/commands/channel/supervisor/idle.d.ts +46 -0
- package/dist/commands/channel/supervisor/idle.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/idle.js +72 -0
- package/dist/commands/channel/supervisor/idle.js.map +1 -0
- package/dist/commands/channel/supervisor/inbox.d.ts +30 -0
- package/dist/commands/channel/supervisor/inbox.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/inbox.js +160 -0
- package/dist/commands/channel/supervisor/inbox.js.map +1 -0
- package/dist/commands/channel/supervisor/shutdown.d.ts +68 -0
- package/dist/commands/channel/supervisor/shutdown.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/shutdown.js +146 -0
- package/dist/commands/channel/supervisor/shutdown.js.map +1 -0
- package/dist/commands/channel/supervisor/stdout.d.ts +51 -0
- package/dist/commands/channel/supervisor/stdout.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/stdout.js +121 -0
- package/dist/commands/channel/supervisor/stdout.js.map +1 -0
- package/dist/commands/channel/supervisor/turns.d.ts +31 -0
- package/dist/commands/channel/supervisor/turns.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/turns.js +45 -0
- package/dist/commands/channel/supervisor/turns.js.map +1 -0
- package/dist/commands/channel/supervisor/warning.d.ts +48 -0
- package/dist/commands/channel/supervisor/warning.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/warning.js +77 -0
- package/dist/commands/channel/supervisor/warning.js.map +1 -0
- package/dist/commands/channel/supervisor.d.ts +59 -0
- package/dist/commands/channel/supervisor.d.ts.map +1 -0
- package/dist/commands/channel/supervisor.js +344 -0
- package/dist/commands/channel/supervisor.js.map +1 -0
- package/dist/commands/channel/text-body.d.ts +13 -0
- package/dist/commands/channel/text-body.d.ts.map +1 -0
- package/dist/commands/channel/text-body.js +47 -0
- package/dist/commands/channel/text-body.js.map +1 -0
- package/dist/commands/channel/threads.d.ts +39 -0
- package/dist/commands/channel/threads.d.ts.map +1 -0
- package/dist/commands/channel/threads.js +106 -0
- package/dist/commands/channel/threads.js.map +1 -0
- package/dist/commands/channel/title.d.ts +12 -0
- package/dist/commands/channel/title.d.ts.map +1 -0
- package/dist/commands/channel/title.js +24 -0
- package/dist/commands/channel/title.js.map +1 -0
- package/dist/commands/channel/wait.d.ts +17 -0
- package/dist/commands/channel/wait.d.ts.map +1 -0
- package/dist/commands/channel/wait.js +75 -0
- package/dist/commands/channel/wait.js.map +1 -0
- package/dist/commands/init.d.ts +62 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +1656 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mem.d.ts +30 -0
- package/dist/commands/mem.d.ts.map +1 -0
- package/dist/commands/mem.js +424 -0
- package/dist/commands/mem.js.map +1 -0
- package/dist/commands/rollout.d.ts +34 -0
- package/dist/commands/rollout.d.ts.map +1 -0
- package/dist/commands/rollout.js +102 -0
- package/dist/commands/rollout.js.map +1 -0
- package/dist/commands/uninstall.d.ts +27 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +339 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/update.d.ts +80 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +2185 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/upgrade.d.ts +28 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +84 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/commands/workflow.d.ts +35 -0
- package/dist/commands/workflow.d.ts.map +1 -0
- package/dist/commands/workflow.js +219 -0
- package/dist/commands/workflow.js.map +1 -0
- package/dist/configurators/antigravity.d.ts +7 -0
- package/dist/configurators/antigravity.d.ts.map +1 -0
- package/dist/configurators/antigravity.js +19 -0
- package/dist/configurators/antigravity.js.map +1 -0
- package/dist/configurators/claude.d.ts +9 -0
- package/dist/configurators/claude.d.ts.map +1 -0
- package/dist/configurators/claude.js +72 -0
- package/dist/configurators/claude.js.map +1 -0
- package/dist/configurators/codebuddy.d.ts +10 -0
- package/dist/configurators/codebuddy.d.ts.map +1 -0
- package/dist/configurators/codebuddy.js +30 -0
- package/dist/configurators/codebuddy.js.map +1 -0
- package/dist/configurators/codex.d.ts +8 -0
- package/dist/configurators/codex.d.ts.map +1 -0
- package/dist/configurators/codex.js +87 -0
- package/dist/configurators/codex.js.map +1 -0
- package/dist/configurators/copilot.d.ts +10 -0
- package/dist/configurators/copilot.d.ts.map +1 -0
- package/dist/configurators/copilot.js +51 -0
- package/dist/configurators/copilot.js.map +1 -0
- package/dist/configurators/cursor.d.ts +20 -0
- package/dist/configurators/cursor.d.ts.map +1 -0
- package/dist/configurators/cursor.js +49 -0
- package/dist/configurators/cursor.js.map +1 -0
- package/dist/configurators/cursor2plus-local.d.ts +6 -0
- package/dist/configurators/cursor2plus-local.d.ts.map +1 -0
- package/dist/configurators/cursor2plus-local.js +20 -0
- package/dist/configurators/cursor2plus-local.js.map +1 -0
- package/dist/configurators/droid.d.ts +10 -0
- package/dist/configurators/droid.d.ts.map +1 -0
- package/dist/configurators/droid.js +30 -0
- package/dist/configurators/droid.js.map +1 -0
- package/dist/configurators/gemini.d.ts +16 -0
- package/dist/configurators/gemini.d.ts.map +1 -0
- package/dist/configurators/gemini.js +38 -0
- package/dist/configurators/gemini.js.map +1 -0
- package/dist/configurators/index.d.ts +69 -0
- package/dist/configurators/index.d.ts.map +1 -0
- package/dist/configurators/index.js +395 -0
- package/dist/configurators/index.js.map +1 -0
- package/dist/configurators/kilo.d.ts +7 -0
- package/dist/configurators/kilo.d.ts.map +1 -0
- package/dist/configurators/kilo.js +19 -0
- package/dist/configurators/kilo.js.map +1 -0
- package/dist/configurators/kiro.d.ts +8 -0
- package/dist/configurators/kiro.d.ts.map +1 -0
- package/dist/configurators/kiro.js +24 -0
- package/dist/configurators/kiro.js.map +1 -0
- package/dist/configurators/opencode.d.ts +14 -0
- package/dist/configurators/opencode.d.ts.map +1 -0
- package/dist/configurators/opencode.js +96 -0
- package/dist/configurators/opencode.js.map +1 -0
- package/dist/configurators/pi.d.ts +3 -0
- package/dist/configurators/pi.d.ts.map +1 -0
- package/dist/configurators/pi.js +45 -0
- package/dist/configurators/pi.js.map +1 -0
- package/dist/configurators/qoder.d.ts +11 -0
- package/dist/configurators/qoder.d.ts.map +1 -0
- package/dist/configurators/qoder.js +31 -0
- package/dist/configurators/qoder.js.map +1 -0
- package/dist/configurators/shared.d.ts +183 -0
- package/dist/configurators/shared.d.ts.map +1 -0
- package/dist/configurators/shared.js +557 -0
- package/dist/configurators/shared.js.map +1 -0
- package/dist/configurators/windsurf.d.ts +7 -0
- package/dist/configurators/windsurf.d.ts.map +1 -0
- package/dist/configurators/windsurf.js +19 -0
- package/dist/configurators/windsurf.js.map +1 -0
- package/dist/configurators/workflow.d.ts +46 -0
- package/dist/configurators/workflow.d.ts.map +1 -0
- package/dist/configurators/workflow.js +180 -0
- package/dist/configurators/workflow.js.map +1 -0
- package/dist/constants/paths.d.ts +70 -0
- package/dist/constants/paths.d.ts.map +1 -0
- package/dist/constants/paths.js +79 -0
- package/dist/constants/paths.js.map +1 -0
- package/dist/constants/version.d.ts +9 -0
- package/dist/constants/version.d.ts.map +1 -0
- package/dist/constants/version.js +15 -0
- package/dist/constants/version.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/index.d.ts +62 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +187 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/manifests/0.1.0.json +9 -0
- package/dist/templates/claude/agents/trellis-check.md +124 -0
- package/dist/templates/claude/agents/trellis-implement.md +110 -0
- package/dist/templates/claude/agents/trellis-research.md +137 -0
- package/dist/templates/claude/index.d.ts +22 -0
- package/dist/templates/claude/index.d.ts.map +1 -0
- package/dist/templates/claude/index.js +46 -0
- package/dist/templates/claude/index.js.map +1 -0
- package/dist/templates/claude/settings.json +84 -0
- package/dist/templates/codebuddy/agents/trellis-check.md +115 -0
- package/dist/templates/codebuddy/agents/trellis-implement.md +110 -0
- package/dist/templates/codebuddy/agents/trellis-research.md +137 -0
- package/dist/templates/codebuddy/index.d.ts +15 -0
- package/dist/templates/codebuddy/index.d.ts.map +1 -0
- package/dist/templates/codebuddy/index.js +15 -0
- package/dist/templates/codebuddy/index.js.map +1 -0
- package/dist/templates/codebuddy/settings.json +70 -0
- package/dist/templates/codex/agents/trellis-check.toml +67 -0
- package/dist/templates/codex/agents/trellis-implement.toml +40 -0
- package/dist/templates/codex/agents/trellis-research.toml +73 -0
- package/dist/templates/codex/config.toml +28 -0
- package/dist/templates/codex/hooks/session-start.py +575 -0
- package/dist/templates/codex/hooks.json +15 -0
- package/dist/templates/codex/index.d.ts +39 -0
- package/dist/templates/codex/index.d.ts.map +1 -0
- package/dist/templates/codex/index.js +85 -0
- package/dist/templates/codex/index.js.map +1 -0
- package/dist/templates/codex/skills/before-dev/SKILL.md +40 -0
- package/dist/templates/codex/skills/brainstorm/SKILL.md +112 -0
- package/dist/templates/codex/skills/break-loop/SKILL.md +130 -0
- package/dist/templates/codex/skills/check/SKILL.md +98 -0
- package/dist/templates/codex/skills/check-cross-layer/SKILL.md +158 -0
- package/dist/templates/codex/skills/create-command/SKILL.md +101 -0
- package/dist/templates/codex/skills/finish-work/SKILL.md +90 -0
- package/dist/templates/codex/skills/improve-ut/SKILL.md +69 -0
- package/dist/templates/codex/skills/integrate-skill/SKILL.md +221 -0
- package/dist/templates/codex/skills/onboard/SKILL.md +363 -0
- package/dist/templates/codex/skills/record-session/SKILL.md +67 -0
- package/dist/templates/codex/skills/start/SKILL.md +66 -0
- package/dist/templates/codex/skills/update-spec/SKILL.md +335 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/SKILL.md +388 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/agents/openai.yaml +3 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/examples/batch-search.md +98 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/examples/evidence-gathering.md +89 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/references/cli-contract.md +337 -0
- package/dist/templates/common/bundled-skills/trellis-cursor2plus-setup/SKILL.md +62 -0
- package/dist/templates/common/bundled-skills/trellis-meta/SKILL.md +73 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/add-project-local-conventions.md +83 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-agents.md +54 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-context-loading.md +84 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-hooks.md +57 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-skills-or-commands.md +80 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-spec-structure.md +83 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-task-lifecycle.md +88 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-workflow.md +65 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/overview.md +55 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/context-injection.md +68 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/generated-files.md +80 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/overview.md +51 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/spec-system.md +102 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/task-system.md +133 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/workflow.md +75 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/workspace-memory.md +71 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/agents.md +80 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/hooks-and-settings.md +69 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/overview.md +61 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md +76 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/skills-and-commands.md +128 -0
- package/dist/templates/common/bundled-skills/trellis-micro-grill/SKILL.md +47 -0
- package/dist/templates/common/bundled-skills/trellis-skill-creator/SKILL.md +44 -0
- package/dist/templates/common/bundled-skills/trellis-skill-creator/references/authoring-rules.md +97 -0
- package/dist/templates/common/bundled-skills/trellis-skill-creator/references/review-checklist.md +47 -0
- package/dist/templates/common/bundled-skills/trellis-skill-creator/references/trellis-skill-locations.md +52 -0
- package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/SKILL.md +41 -0
- package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/mcp-setup.md +90 -0
- package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/repository-analysis.md +59 -0
- package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/spec-task-planning.md +61 -0
- package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/spec-writing.md +70 -0
- package/dist/templates/common/commands/continue.md +63 -0
- package/dist/templates/common/commands/finish-work.md +68 -0
- package/dist/templates/common/commands/start.md +69 -0
- package/dist/templates/common/index.d.ts +48 -0
- package/dist/templates/common/index.d.ts.map +1 -0
- package/dist/templates/common/index.js +104 -0
- package/dist/templates/common/index.js.map +1 -0
- package/dist/templates/common/skills/before-dev.md +35 -0
- package/dist/templates/common/skills/brainstorm.md +164 -0
- package/dist/templates/common/skills/break-loop.md +125 -0
- package/dist/templates/common/skills/check.md +106 -0
- package/dist/templates/common/skills/update-spec.md +364 -0
- package/dist/templates/copilot/hooks/session-start.py +557 -0
- package/dist/templates/copilot/hooks.json +19 -0
- package/dist/templates/copilot/index.d.ts +23 -0
- package/dist/templates/copilot/index.d.ts.map +1 -0
- package/dist/templates/copilot/index.js +54 -0
- package/dist/templates/copilot/index.js.map +1 -0
- package/dist/templates/copilot/prompts/before-dev.prompt.md +39 -0
- package/dist/templates/copilot/prompts/brainstorm.prompt.md +111 -0
- package/dist/templates/copilot/prompts/break-loop.prompt.md +129 -0
- package/dist/templates/copilot/prompts/check-cross-layer.prompt.md +157 -0
- package/dist/templates/copilot/prompts/check.prompt.md +97 -0
- package/dist/templates/copilot/prompts/create-command.prompt.md +116 -0
- package/dist/templates/copilot/prompts/finish-work.prompt.md +99 -0
- package/dist/templates/copilot/prompts/integrate-skill.prompt.md +223 -0
- package/dist/templates/copilot/prompts/onboard.prompt.md +362 -0
- package/dist/templates/copilot/prompts/parallel.prompt.md +204 -0
- package/dist/templates/copilot/prompts/record-session.prompt.md +66 -0
- package/dist/templates/copilot/prompts/start.prompt.md +63 -0
- package/dist/templates/copilot/prompts/update-spec.prompt.md +358 -0
- package/dist/templates/cursor/agents/trellis-check.md +139 -0
- package/dist/templates/cursor/agents/trellis-implement.md +119 -0
- package/dist/templates/cursor/agents/trellis-research.md +147 -0
- package/dist/templates/cursor/commands/cursor2plus-setup.md +82 -0
- package/dist/templates/cursor/hooks.json +30 -0
- package/dist/templates/cursor/index.d.ts +19 -0
- package/dist/templates/cursor/index.d.ts.map +1 -0
- package/dist/templates/cursor/index.js +19 -0
- package/dist/templates/cursor/index.js.map +1 -0
- package/dist/templates/cursor/rules/trellis-triage.mdc +38 -0
- package/dist/templates/cursor/worktrees.json +11 -0
- package/dist/templates/droid/droids/trellis-check.md +107 -0
- package/dist/templates/droid/droids/trellis-implement.md +102 -0
- package/dist/templates/droid/droids/trellis-research.md +137 -0
- package/dist/templates/droid/index.d.ts +15 -0
- package/dist/templates/droid/index.d.ts.map +1 -0
- package/dist/templates/droid/index.js +15 -0
- package/dist/templates/droid/index.js.map +1 -0
- package/dist/templates/droid/settings.json +70 -0
- package/dist/templates/extract.d.ts +40 -0
- package/dist/templates/extract.d.ts.map +1 -0
- package/dist/templates/extract.js +106 -0
- package/dist/templates/extract.js.map +1 -0
- package/dist/templates/gemini/agents/trellis-check.md +107 -0
- package/dist/templates/gemini/agents/trellis-implement.md +102 -0
- package/dist/templates/gemini/agents/trellis-research.md +136 -0
- package/dist/templates/gemini/index.d.ts +13 -0
- package/dist/templates/gemini/index.d.ts.map +1 -0
- package/dist/templates/gemini/index.js +13 -0
- package/dist/templates/gemini/index.js.map +1 -0
- package/dist/templates/gemini/settings.json +28 -0
- package/dist/templates/kiro/agents/trellis-check.json +26 -0
- package/dist/templates/kiro/agents/trellis-implement.json +26 -0
- package/dist/templates/kiro/agents/trellis-research.json +30 -0
- package/dist/templates/kiro/index.d.ts +18 -0
- package/dist/templates/kiro/index.d.ts.map +1 -0
- package/dist/templates/kiro/index.js +18 -0
- package/dist/templates/kiro/index.js.map +1 -0
- package/dist/templates/markdown/agents.md +32 -0
- package/dist/templates/markdown/gitignore.txt +15 -0
- package/dist/templates/markdown/index.d.ts +30 -0
- package/dist/templates/markdown/index.d.ts.map +1 -0
- package/dist/templates/markdown/index.js +55 -0
- package/dist/templates/markdown/index.js.map +1 -0
- package/dist/templates/markdown/spec/backend/database-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/backend/directory-structure.md.txt +54 -0
- package/dist/templates/markdown/spec/backend/error-handling.md.txt +51 -0
- package/dist/templates/markdown/spec/backend/index.md.txt +38 -0
- package/dist/templates/markdown/spec/backend/logging-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/backend/quality-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/component-guidelines.md.txt +59 -0
- package/dist/templates/markdown/spec/frontend/directory-structure.md.txt +54 -0
- package/dist/templates/markdown/spec/frontend/hook-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/index.md.txt +39 -0
- package/dist/templates/markdown/spec/frontend/quality-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/state-management.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/type-safety.md.txt +51 -0
- package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md.txt +223 -0
- package/dist/templates/markdown/spec/guides/cross-layer-thinking-guide.md.txt +259 -0
- package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +633 -0
- package/dist/templates/markdown/spec/guides/cursor-context-injection-guide.md.txt +65 -0
- package/dist/templates/markdown/spec/guides/cursor-subagent-policy.md.txt +382 -0
- package/dist/templates/markdown/spec/guides/durable-learning-decision-guide.md.txt +76 -0
- package/dist/templates/markdown/spec/guides/index.md.txt +101 -0
- package/dist/templates/markdown/spec/guides/retrieval-daily-guide.md.txt +92 -0
- package/dist/templates/markdown/workspace-index.md +125 -0
- package/dist/templates/markdown/worktree.yaml.txt +58 -0
- package/dist/templates/opencode/agents/trellis-check.md +122 -0
- package/dist/templates/opencode/agents/trellis-implement.md +118 -0
- package/dist/templates/opencode/agents/trellis-research.md +145 -0
- package/dist/templates/opencode/lib/session-utils.js +667 -0
- package/dist/templates/opencode/lib/trellis-context.js +336 -0
- package/dist/templates/opencode/package.json +5 -0
- package/dist/templates/opencode/plugins/inject-subagent-context.js +495 -0
- package/dist/templates/opencode/plugins/inject-workflow-state.js +159 -0
- package/dist/templates/opencode/plugins/session-start.js +101 -0
- package/dist/templates/pi/agents/trellis-check.md +37 -0
- package/dist/templates/pi/agents/trellis-implement.md +42 -0
- package/dist/templates/pi/agents/trellis-research.md +25 -0
- package/dist/templates/pi/extensions/trellis/index.ts.txt +1600 -0
- package/dist/templates/pi/index.d.ts +5 -0
- package/dist/templates/pi/index.d.ts.map +1 -0
- package/dist/templates/pi/index.js +12 -0
- package/dist/templates/pi/index.js.map +1 -0
- package/dist/templates/pi/settings.json +12 -0
- package/dist/templates/qoder/agents/trellis-check.md +108 -0
- package/dist/templates/qoder/agents/trellis-implement.md +103 -0
- package/dist/templates/qoder/agents/trellis-research.md +137 -0
- package/dist/templates/qoder/index.d.ts +15 -0
- package/dist/templates/qoder/index.d.ts.map +1 -0
- package/dist/templates/qoder/index.js +15 -0
- package/dist/templates/qoder/index.js.map +1 -0
- package/dist/templates/qoder/settings.json +47 -0
- package/dist/templates/shared-hooks/index.d.ts +50 -0
- package/dist/templates/shared-hooks/index.d.ts.map +1 -0
- package/dist/templates/shared-hooks/index.js +92 -0
- package/dist/templates/shared-hooks/index.js.map +1 -0
- package/dist/templates/shared-hooks/inject-shell-session-context.py +183 -0
- package/dist/templates/shared-hooks/inject-subagent-context.py +774 -0
- package/dist/templates/shared-hooks/inject-workflow-state.py +366 -0
- package/dist/templates/shared-hooks/research-end-retrieval-pack.py +220 -0
- package/dist/templates/shared-hooks/session-start.py +873 -0
- package/dist/templates/template-utils.d.ts +28 -0
- package/dist/templates/template-utils.d.ts.map +1 -0
- package/dist/templates/template-utils.js +83 -0
- package/dist/templates/template-utils.js.map +1 -0
- package/dist/templates/trellis/config.yaml +132 -0
- package/dist/templates/trellis/gitignore.txt +39 -0
- package/dist/templates/trellis/index.d.ts +80 -0
- package/dist/templates/trellis/index.d.ts.map +1 -0
- package/dist/templates/trellis/index.js +171 -0
- package/dist/templates/trellis/index.js.map +1 -0
- package/dist/templates/trellis/local/README.md +59 -0
- package/dist/templates/trellis/local/config.local.json.example +6 -0
- package/dist/templates/trellis/local/index.d.ts +7 -0
- package/dist/templates/trellis/local/index.d.ts.map +1 -0
- package/dist/templates/trellis/local/index.js +14 -0
- package/dist/templates/trellis/local/index.js.map +1 -0
- package/dist/templates/trellis/local/patch_wpelc8.py +297 -0
- package/dist/templates/trellis/local/subagent-models.json.example +4 -0
- package/dist/templates/trellis/local/trellis-task-models.json.example +10 -0
- package/dist/templates/trellis/local/trellis-task-models.json5.example +45 -0
- package/dist/templates/trellis/local/trellis_task_models_config.py +200 -0
- package/dist/templates/trellis/scripts/__init__.py +5 -0
- package/dist/templates/trellis/scripts/add_session.py +547 -0
- package/dist/templates/trellis/scripts/build_context_pack.py +12 -0
- package/dist/templates/trellis/scripts/build_retrieval_pack.py +12 -0
- package/dist/templates/trellis/scripts/common/__init__.py +103 -0
- package/dist/templates/trellis/scripts/common/active_task.py +607 -0
- package/dist/templates/trellis/scripts/common/artifact_search.py +587 -0
- package/dist/templates/trellis/scripts/common/cli_adapter.py +811 -0
- package/dist/templates/trellis/scripts/common/cli_environment.py +155 -0
- package/dist/templates/trellis/scripts/common/codebase_retrieval_router.py +902 -0
- package/dist/templates/trellis/scripts/common/config.py +458 -0
- package/dist/templates/trellis/scripts/common/context_pack.py +371 -0
- package/dist/templates/trellis/scripts/common/developer.py +190 -0
- package/dist/templates/trellis/scripts/common/git.py +31 -0
- package/dist/templates/trellis/scripts/common/git_context.py +149 -0
- package/dist/templates/trellis/scripts/common/io.py +37 -0
- package/dist/templates/trellis/scripts/common/log.py +45 -0
- package/dist/templates/trellis/scripts/common/packages_context.py +239 -0
- package/dist/templates/trellis/scripts/common/parent_orchestration.py +691 -0
- package/dist/templates/trellis/scripts/common/paths.py +457 -0
- package/dist/templates/trellis/scripts/common/retrieval_adapter_metadata.py +889 -0
- package/dist/templates/trellis/scripts/common/retrieval_evidence.py +917 -0
- package/dist/templates/trellis/scripts/common/retrieval_pack.py +425 -0
- package/dist/templates/trellis/scripts/common/retrieval_pack_context.py +126 -0
- package/dist/templates/trellis/scripts/common/safe_commit.py +285 -0
- package/dist/templates/trellis/scripts/common/session_context.py +1159 -0
- package/dist/templates/trellis/scripts/common/session_memory.py +360 -0
- package/dist/templates/trellis/scripts/common/smart_search_evidence.py +479 -0
- package/dist/templates/trellis/scripts/common/smart_search_resolve.py +125 -0
- package/dist/templates/trellis/scripts/common/task_context.py +223 -0
- package/dist/templates/trellis/scripts/common/task_dashboard.py +140 -0
- package/dist/templates/trellis/scripts/common/task_gates.py +1735 -0
- package/dist/templates/trellis/scripts/common/task_map.py +586 -0
- package/dist/templates/trellis/scripts/common/task_queue.py +188 -0
- package/dist/templates/trellis/scripts/common/task_store.py +1533 -0
- package/dist/templates/trellis/scripts/common/task_utils.py +274 -0
- package/dist/templates/trellis/scripts/common/tasks.py +231 -0
- package/dist/templates/trellis/scripts/common/test_retrieval_arbitration.py +333 -0
- package/dist/templates/trellis/scripts/common/trellis_config.py +131 -0
- package/dist/templates/trellis/scripts/common/types.py +110 -0
- package/dist/templates/trellis/scripts/common/workflow_phase.py +212 -0
- package/dist/templates/trellis/scripts/get_context.py +17 -0
- package/dist/templates/trellis/scripts/get_developer.py +26 -0
- package/dist/templates/trellis/scripts/hooks/linear_sync.py +243 -0
- package/dist/templates/trellis/scripts/init_developer.py +51 -0
- package/dist/templates/trellis/scripts/route_codebase_retrieval.py +77 -0
- package/dist/templates/trellis/scripts/run_smart_search.py +12 -0
- package/dist/templates/trellis/scripts/search_artifacts.py +13 -0
- package/dist/templates/trellis/scripts/search_memory.py +12 -0
- package/dist/templates/trellis/scripts/task.py +851 -0
- package/dist/templates/trellis/tasks/.gitkeep +0 -0
- package/dist/templates/trellis/tasks/templates/release-execution/design.md +61 -0
- package/dist/templates/trellis/tasks/templates/release-execution/handoff-template.md +29 -0
- package/dist/templates/trellis/tasks/templates/release-execution/implement.md +29 -0
- package/dist/templates/trellis/tasks/templates/release-execution/prd.md +31 -0
- package/dist/templates/trellis/tasks/templates/release-readiness/design.md +50 -0
- package/dist/templates/trellis/tasks/templates/release-readiness/handoff-template.md +39 -0
- package/dist/templates/trellis/tasks/templates/release-readiness/implement.md +29 -0
- package/dist/templates/trellis/tasks/templates/release-readiness/prd.md +31 -0
- package/dist/templates/trellis/workflow.md +960 -0
- package/dist/types/ai-tools.d.ts +106 -0
- package/dist/types/ai-tools.d.ts.map +1 -0
- package/dist/types/ai-tools.js +294 -0
- package/dist/types/ai-tools.js.map +1 -0
- package/dist/types/migration.d.ts +125 -0
- package/dist/types/migration.d.ts.map +1 -0
- package/dist/types/migration.js +8 -0
- package/dist/types/migration.js.map +1 -0
- package/dist/utils/codebase-retrieval-router.d.ts +77 -0
- package/dist/utils/codebase-retrieval-router.d.ts.map +1 -0
- package/dist/utils/codebase-retrieval-router.js +767 -0
- package/dist/utils/codebase-retrieval-router.js.map +1 -0
- package/dist/utils/compare-versions.d.ts +12 -0
- package/dist/utils/compare-versions.d.ts.map +1 -0
- package/dist/utils/compare-versions.js +86 -0
- package/dist/utils/compare-versions.js.map +1 -0
- package/dist/utils/cwd-guard.d.ts +38 -0
- package/dist/utils/cwd-guard.d.ts.map +1 -0
- package/dist/utils/cwd-guard.js +62 -0
- package/dist/utils/cwd-guard.js.map +1 -0
- package/dist/utils/file-writer.d.ts +36 -0
- package/dist/utils/file-writer.d.ts.map +1 -0
- package/dist/utils/file-writer.js +203 -0
- package/dist/utils/file-writer.js.map +1 -0
- package/dist/utils/manifest-prune.d.ts +61 -0
- package/dist/utils/manifest-prune.d.ts.map +1 -0
- package/dist/utils/manifest-prune.js +136 -0
- package/dist/utils/manifest-prune.js.map +1 -0
- package/dist/utils/posix.d.ts +13 -0
- package/dist/utils/posix.d.ts.map +1 -0
- package/dist/utils/posix.js +15 -0
- package/dist/utils/posix.js.map +1 -0
- package/dist/utils/post-update-smoke.d.ts +7 -0
- package/dist/utils/post-update-smoke.d.ts.map +1 -0
- package/dist/utils/post-update-smoke.js +40 -0
- package/dist/utils/post-update-smoke.js.map +1 -0
- package/dist/utils/project-capabilities.d.ts +54 -0
- package/dist/utils/project-capabilities.d.ts.map +1 -0
- package/dist/utils/project-capabilities.js +515 -0
- package/dist/utils/project-capabilities.js.map +1 -0
- package/dist/utils/project-detector.d.ts +46 -0
- package/dist/utils/project-detector.d.ts.map +1 -0
- package/dist/utils/project-detector.js +666 -0
- package/dist/utils/project-detector.js.map +1 -0
- package/dist/utils/proxy.d.ts +25 -0
- package/dist/utils/proxy.d.ts.map +1 -0
- package/dist/utils/proxy.js +60 -0
- package/dist/utils/proxy.js.map +1 -0
- package/dist/utils/readiness.d.ts +20 -0
- package/dist/utils/readiness.d.ts.map +1 -0
- package/dist/utils/readiness.js +430 -0
- package/dist/utils/readiness.js.map +1 -0
- package/dist/utils/retrieval-execution-telemetry.d.ts +162 -0
- package/dist/utils/retrieval-execution-telemetry.d.ts.map +1 -0
- package/dist/utils/retrieval-execution-telemetry.js +288 -0
- package/dist/utils/retrieval-execution-telemetry.js.map +1 -0
- package/dist/utils/retrieval-result-ranking.d.ts +40 -0
- package/dist/utils/retrieval-result-ranking.d.ts.map +1 -0
- package/dist/utils/retrieval-result-ranking.js +162 -0
- package/dist/utils/retrieval-result-ranking.js.map +1 -0
- package/dist/utils/task-json.d.ts +13 -0
- package/dist/utils/task-json.d.ts.map +1 -0
- package/dist/utils/task-json.js +12 -0
- package/dist/utils/task-json.js.map +1 -0
- package/dist/utils/template-fetcher.d.ts +150 -0
- package/dist/utils/template-fetcher.d.ts.map +1 -0
- package/dist/utils/template-fetcher.js +907 -0
- package/dist/utils/template-fetcher.js.map +1 -0
- package/dist/utils/template-hash.d.ts +123 -0
- package/dist/utils/template-hash.d.ts.map +1 -0
- package/dist/utils/template-hash.js +334 -0
- package/dist/utils/template-hash.js.map +1 -0
- package/dist/utils/uninstall-scrubbers.d.ts +66 -0
- package/dist/utils/uninstall-scrubbers.d.ts.map +1 -0
- package/dist/utils/uninstall-scrubbers.js +342 -0
- package/dist/utils/uninstall-scrubbers.js.map +1 -0
- package/dist/utils/update-rollout-report.d.ts +137 -0
- package/dist/utils/update-rollout-report.d.ts.map +1 -0
- package/dist/utils/update-rollout-report.js +108 -0
- package/dist/utils/update-rollout-report.js.map +1 -0
- package/dist/utils/workflow-resolver.d.ts +86 -0
- package/dist/utils/workflow-resolver.d.ts.map +1 -0
- package/dist/utils/workflow-resolver.js +265 -0
- package/dist/utils/workflow-resolver.js.map +1 -0
- package/package.json +137 -0
- package/scripts/postinstall.js +45 -0
- package/vendor/smart-search/LICENSE +21 -0
- package/vendor/smart-search/README.md +412 -0
- package/vendor/smart-search/README.zh-CN.md +430 -0
- package/vendor/smart-search/npm/bin/smart-search.js +63 -0
- package/vendor/smart-search/npm/scripts/postinstall.js +87 -0
- package/vendor/smart-search/npm/scripts/resolve-prerelease-version.js +108 -0
- package/vendor/smart-search/npm/scripts/set-package-version.js +35 -0
- package/vendor/smart-search/npm/scripts/sync-python-version.js +22 -0
- package/vendor/smart-search/npm/scripts/test-wrapper-repair.js +99 -0
- package/vendor/smart-search/npm/scripts/test.js +85 -0
- package/vendor/smart-search/package.json +42 -0
- package/vendor/smart-search/pyproject.toml +37 -0
- package/vendor/smart-search/skills/smart-search-cli/SKILL.md +387 -0
- package/vendor/smart-search/skills/smart-search-cli/agents/openai.yaml +3 -0
- package/vendor/smart-search/skills/smart-search-cli/examples/batch-search.md +98 -0
- package/vendor/smart-search/skills/smart-search-cli/examples/evidence-gathering.md +89 -0
- package/vendor/smart-search/skills/smart-search-cli/references/cli-contract.md +337 -0
- package/vendor/smart-search/src/smart_search/__init__.py +1 -0
- package/vendor/smart-search/src/smart_search/assets/skills/smart-search-cli/SKILL.md +387 -0
- package/vendor/smart-search/src/smart_search/assets/skills/smart-search-cli/agents/openai.yaml +3 -0
- package/vendor/smart-search/src/smart_search/assets/skills/smart-search-cli/examples/batch-search.md +98 -0
- package/vendor/smart-search/src/smart_search/assets/skills/smart-search-cli/examples/evidence-gathering.md +89 -0
- package/vendor/smart-search/src/smart_search/assets/skills/smart-search-cli/references/cli-contract.md +337 -0
- package/vendor/smart-search/src/smart_search/cli.py +2003 -0
- package/vendor/smart-search/src/smart_search/config.py +580 -0
- package/vendor/smart-search/src/smart_search/logger.py +43 -0
- package/vendor/smart-search/src/smart_search/providers/__init__.py +16 -0
- package/vendor/smart-search/src/smart_search/providers/base.py +41 -0
- package/vendor/smart-search/src/smart_search/providers/context7.py +141 -0
- package/vendor/smart-search/src/smart_search/providers/exa.py +206 -0
- package/vendor/smart-search/src/smart_search/providers/jina.py +136 -0
- package/vendor/smart-search/src/smart_search/providers/openai_compatible.py +370 -0
- package/vendor/smart-search/src/smart_search/providers/zhipu.py +143 -0
- package/vendor/smart-search/src/smart_search/service.py +2865 -0
- package/vendor/smart-search/src/smart_search/sources.py +429 -0
- package/vendor/smart-search/src/smart_search/utils.py +220 -0
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
Multi-Platform Sub-Agent Context Injection Hook
|
|
5
|
+
|
|
6
|
+
Injects task-specific context when sub-agents (implement, check, research) are spawned.
|
|
7
|
+
|
|
8
|
+
Core Design Philosophy:
|
|
9
|
+
- Hook is responsible for injecting all context, subagent works autonomously with complete info
|
|
10
|
+
- Each agent has a dedicated jsonl file defining its context
|
|
11
|
+
- No resume needed, no segmentation, behavior controlled by code not prompt
|
|
12
|
+
|
|
13
|
+
Trigger: PreToolUse (before Task tool call)
|
|
14
|
+
|
|
15
|
+
Context Source: Trellis selected task resolver points to task directory
|
|
16
|
+
- implement.jsonl - Implement agent dedicated context
|
|
17
|
+
- check.jsonl - Check agent dedicated context
|
|
18
|
+
- prd.md - Requirements document
|
|
19
|
+
- design.md - Technical design for complex tasks
|
|
20
|
+
- implement.md - Execution plan for complex tasks
|
|
21
|
+
- codex-review-output.txt - Code Review results
|
|
22
|
+
"""
|
|
23
|
+
from __future__ import annotations
|
|
24
|
+
|
|
25
|
+
# IMPORTANT: Suppress all warnings FIRST
|
|
26
|
+
import warnings
|
|
27
|
+
warnings.filterwarnings("ignore")
|
|
28
|
+
|
|
29
|
+
import json
|
|
30
|
+
import os
|
|
31
|
+
import sys
|
|
32
|
+
from pathlib import Path
|
|
33
|
+
from typing import Any
|
|
34
|
+
|
|
35
|
+
# IMPORTANT: Force stdout to use UTF-8 on Windows
|
|
36
|
+
# This fixes UnicodeEncodeError when outputting non-ASCII characters
|
|
37
|
+
if sys.platform.startswith("win"):
|
|
38
|
+
import io as _io
|
|
39
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
40
|
+
sys.stdout.reconfigure(encoding="utf-8", errors="replace") # type: ignore[union-attr]
|
|
41
|
+
elif hasattr(sys.stdout, "detach"):
|
|
42
|
+
sys.stdout = _io.TextIOWrapper(sys.stdout.detach(), encoding="utf-8", errors="replace") # type: ignore[union-attr]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# =============================================================================
|
|
46
|
+
# Path Constants (change here to rename directories)
|
|
47
|
+
# =============================================================================
|
|
48
|
+
|
|
49
|
+
DIR_WORKFLOW = ".trellis"
|
|
50
|
+
DIR_SPEC = "spec"
|
|
51
|
+
FILE_TASK_JSON = "task.json"
|
|
52
|
+
|
|
53
|
+
# =============================================================================
|
|
54
|
+
# Subagent Constants (change here to rename subagent types)
|
|
55
|
+
# =============================================================================
|
|
56
|
+
|
|
57
|
+
AGENT_IMPLEMENT = "trellis-implement"
|
|
58
|
+
AGENT_CHECK = "trellis-check"
|
|
59
|
+
AGENT_RESEARCH = "trellis-research"
|
|
60
|
+
|
|
61
|
+
# Agents that require a task directory
|
|
62
|
+
AGENTS_REQUIRE_TASK = (AGENT_IMPLEMENT, AGENT_CHECK)
|
|
63
|
+
# All supported agents
|
|
64
|
+
AGENTS_ALL = (AGENT_IMPLEMENT, AGENT_CHECK, AGENT_RESEARCH)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def find_repo_root(start_path: str) -> str | None:
|
|
68
|
+
"""
|
|
69
|
+
Find Trellis harness root (.trellis/) or git repo root from start_path upwards.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
Workspace root path, or None if not found
|
|
73
|
+
"""
|
|
74
|
+
current = Path(start_path).resolve()
|
|
75
|
+
while current != current.parent:
|
|
76
|
+
if (current / DIR_WORKFLOW).is_dir():
|
|
77
|
+
return str(current)
|
|
78
|
+
if (current / ".git").exists():
|
|
79
|
+
return str(current)
|
|
80
|
+
current = current.parent
|
|
81
|
+
return None
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _detect_platform(input_data: dict) -> str | None:
|
|
85
|
+
if isinstance(input_data.get("cursor_version"), str):
|
|
86
|
+
return "cursor"
|
|
87
|
+
env_map = {
|
|
88
|
+
"CLAUDE_PROJECT_DIR": "claude",
|
|
89
|
+
"CURSOR_PROJECT_DIR": "cursor",
|
|
90
|
+
"CODEBUDDY_PROJECT_DIR": "codebuddy",
|
|
91
|
+
"FACTORY_PROJECT_DIR": "droid",
|
|
92
|
+
"GEMINI_PROJECT_DIR": "gemini",
|
|
93
|
+
"QODER_PROJECT_DIR": "qoder",
|
|
94
|
+
"KIRO_PROJECT_DIR": "kiro",
|
|
95
|
+
"COPILOT_PROJECT_DIR": "copilot",
|
|
96
|
+
}
|
|
97
|
+
for env_name, platform in env_map.items():
|
|
98
|
+
if os.environ.get(env_name):
|
|
99
|
+
return platform
|
|
100
|
+
script_parts = set(Path(sys.argv[0]).parts)
|
|
101
|
+
if ".claude" in script_parts:
|
|
102
|
+
return "claude"
|
|
103
|
+
if ".cursor" in script_parts:
|
|
104
|
+
return "cursor"
|
|
105
|
+
if ".gemini" in script_parts:
|
|
106
|
+
return "gemini"
|
|
107
|
+
if ".qoder" in script_parts:
|
|
108
|
+
return "qoder"
|
|
109
|
+
if ".codebuddy" in script_parts:
|
|
110
|
+
return "codebuddy"
|
|
111
|
+
if ".factory" in script_parts:
|
|
112
|
+
return "droid"
|
|
113
|
+
if ".kiro" in script_parts:
|
|
114
|
+
return "kiro"
|
|
115
|
+
return None
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def get_selected_task(repo_root: str, input_data: dict) -> str | None:
|
|
119
|
+
"""Resolve selected task directory through the unified selected task resolver."""
|
|
120
|
+
scripts_dir = Path(repo_root) / DIR_WORKFLOW / "scripts"
|
|
121
|
+
if str(scripts_dir) not in sys.path:
|
|
122
|
+
sys.path.insert(0, str(scripts_dir))
|
|
123
|
+
try:
|
|
124
|
+
from common.active_task import resolve_selected_task # type: ignore[import-not-found]
|
|
125
|
+
except Exception:
|
|
126
|
+
return None
|
|
127
|
+
|
|
128
|
+
selected = resolve_selected_task(
|
|
129
|
+
Path(repo_root),
|
|
130
|
+
input_data,
|
|
131
|
+
platform=_detect_platform(input_data),
|
|
132
|
+
)
|
|
133
|
+
return selected.task_path
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def read_file_content(base_path: str, file_path: str) -> str | None:
|
|
137
|
+
"""Read file content, return None if file doesn't exist"""
|
|
138
|
+
full_path = os.path.join(base_path, file_path)
|
|
139
|
+
if os.path.exists(full_path) and os.path.isfile(full_path):
|
|
140
|
+
try:
|
|
141
|
+
with open(full_path, "r", encoding="utf-8") as f:
|
|
142
|
+
return f.read()
|
|
143
|
+
except Exception:
|
|
144
|
+
return None
|
|
145
|
+
return None
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def read_directory_contents(
|
|
149
|
+
base_path: str, dir_path: str, max_files: int = 20
|
|
150
|
+
) -> list[tuple[str, str]]:
|
|
151
|
+
"""
|
|
152
|
+
Read all .md files in a directory
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
base_path: Base path (usually repo_root)
|
|
156
|
+
dir_path: Directory relative path
|
|
157
|
+
max_files: Max files to read (prevent huge directories)
|
|
158
|
+
|
|
159
|
+
Returns:
|
|
160
|
+
[(file_path, content), ...]
|
|
161
|
+
"""
|
|
162
|
+
full_path = os.path.join(base_path, dir_path)
|
|
163
|
+
if not os.path.exists(full_path) or not os.path.isdir(full_path):
|
|
164
|
+
return []
|
|
165
|
+
|
|
166
|
+
results = []
|
|
167
|
+
try:
|
|
168
|
+
# Only read .md files, sorted by filename
|
|
169
|
+
md_files = sorted(
|
|
170
|
+
[
|
|
171
|
+
f
|
|
172
|
+
for f in os.listdir(full_path)
|
|
173
|
+
if f.endswith(".md") and os.path.isfile(os.path.join(full_path, f))
|
|
174
|
+
]
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
for filename in md_files[:max_files]:
|
|
178
|
+
file_full_path = os.path.join(full_path, filename)
|
|
179
|
+
relative_path = os.path.join(dir_path, filename)
|
|
180
|
+
try:
|
|
181
|
+
with open(file_full_path, "r", encoding="utf-8") as f:
|
|
182
|
+
content = f.read()
|
|
183
|
+
results.append((relative_path, content))
|
|
184
|
+
except Exception:
|
|
185
|
+
continue
|
|
186
|
+
except Exception:
|
|
187
|
+
pass
|
|
188
|
+
|
|
189
|
+
return results
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def read_jsonl_entries(base_path: str, jsonl_path: str) -> list[tuple[str, str]]:
|
|
193
|
+
"""
|
|
194
|
+
Read all file/directory contents referenced in jsonl file
|
|
195
|
+
|
|
196
|
+
Schema:
|
|
197
|
+
{"file": "path/to/file.md", "reason": "..."}
|
|
198
|
+
{"file": "path/to/dir/", "type": "directory", "reason": "..."}
|
|
199
|
+
{"_example": "..."} # seed row — skipped (no `file` field)
|
|
200
|
+
|
|
201
|
+
Rows without a ``file`` field (e.g. the self-describing seed line written
|
|
202
|
+
by ``task.py create`` before the agent has curated entries) are skipped
|
|
203
|
+
silently. If the resulting entry list is empty, a stderr warning is
|
|
204
|
+
emitted so the operator can debug missing context.
|
|
205
|
+
|
|
206
|
+
Returns:
|
|
207
|
+
[(path, content), ...]
|
|
208
|
+
"""
|
|
209
|
+
full_path = os.path.join(base_path, jsonl_path)
|
|
210
|
+
if not os.path.exists(full_path):
|
|
211
|
+
print(
|
|
212
|
+
f"[inject-subagent-context] WARN: {jsonl_path} not found — "
|
|
213
|
+
f"sub-agent will receive only task artifacts",
|
|
214
|
+
file=sys.stderr,
|
|
215
|
+
)
|
|
216
|
+
return []
|
|
217
|
+
|
|
218
|
+
results = []
|
|
219
|
+
saw_real_entry = False
|
|
220
|
+
try:
|
|
221
|
+
with open(full_path, "r", encoding="utf-8") as f:
|
|
222
|
+
for line in f:
|
|
223
|
+
line = line.strip()
|
|
224
|
+
if not line:
|
|
225
|
+
continue
|
|
226
|
+
try:
|
|
227
|
+
item = json.loads(line)
|
|
228
|
+
file_path = item.get("file") or item.get("path")
|
|
229
|
+
entry_type = item.get("type", "file")
|
|
230
|
+
|
|
231
|
+
if not file_path:
|
|
232
|
+
# Seed / comment row — skip silently
|
|
233
|
+
continue
|
|
234
|
+
|
|
235
|
+
saw_real_entry = True
|
|
236
|
+
if entry_type == "directory":
|
|
237
|
+
# Read all .md files in directory
|
|
238
|
+
dir_contents = read_directory_contents(base_path, file_path)
|
|
239
|
+
results.extend(dir_contents)
|
|
240
|
+
else:
|
|
241
|
+
# Read single file
|
|
242
|
+
content = read_file_content(base_path, file_path)
|
|
243
|
+
if content:
|
|
244
|
+
results.append((file_path, content))
|
|
245
|
+
except json.JSONDecodeError:
|
|
246
|
+
continue
|
|
247
|
+
except Exception:
|
|
248
|
+
pass
|
|
249
|
+
|
|
250
|
+
if not saw_real_entry:
|
|
251
|
+
print(
|
|
252
|
+
f"[inject-subagent-context] WARN: {jsonl_path} has no curated "
|
|
253
|
+
f"entries (only seed / empty) — sub-agent will receive only "
|
|
254
|
+
f"task artifacts. See workflow.md planning artifact guidance.",
|
|
255
|
+
file=sys.stderr,
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
return results
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def get_agent_context(repo_root: str, task_dir: str, agent_type: str) -> str:
|
|
264
|
+
"""
|
|
265
|
+
Get context from {agent_type}.jsonl for the specified agent.
|
|
266
|
+
Only reads implement.jsonl or check.jsonl (the two JSONL files the task system creates).
|
|
267
|
+
"""
|
|
268
|
+
context_parts = []
|
|
269
|
+
|
|
270
|
+
agent_jsonl = f"{task_dir}/{agent_type}.jsonl"
|
|
271
|
+
for file_path, content in read_jsonl_entries(repo_root, agent_jsonl):
|
|
272
|
+
context_parts.append(f"=== {file_path} ===\n{content}")
|
|
273
|
+
|
|
274
|
+
return "\n\n".join(context_parts)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def get_implement_context(repo_root: str, task_dir: str) -> str:
|
|
278
|
+
"""
|
|
279
|
+
Complete context for Implement Agent
|
|
280
|
+
|
|
281
|
+
Read order:
|
|
282
|
+
1. All files in implement.jsonl (spec/research manifests)
|
|
283
|
+
2. prd.md (requirements)
|
|
284
|
+
3. design.md if present (technical design)
|
|
285
|
+
4. implement.md if present (execution plan)
|
|
286
|
+
"""
|
|
287
|
+
context_parts = []
|
|
288
|
+
|
|
289
|
+
# 1. Read implement.jsonl
|
|
290
|
+
base_context = get_agent_context(repo_root, task_dir, "implement")
|
|
291
|
+
if base_context:
|
|
292
|
+
context_parts.append(base_context)
|
|
293
|
+
|
|
294
|
+
# 2. Requirements document
|
|
295
|
+
prd_content = read_file_content(repo_root, f"{task_dir}/prd.md")
|
|
296
|
+
if prd_content:
|
|
297
|
+
context_parts.append(f"=== {task_dir}/prd.md (Requirements) ===\n{prd_content}")
|
|
298
|
+
|
|
299
|
+
# 3. Technical design for complex tasks
|
|
300
|
+
design_content = read_file_content(repo_root, f"{task_dir}/design.md")
|
|
301
|
+
if design_content:
|
|
302
|
+
context_parts.append(
|
|
303
|
+
f"=== {task_dir}/design.md (Technical Design) ===\n{design_content}"
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
# 4. Execution plan for complex tasks
|
|
307
|
+
implement_plan_content = read_file_content(repo_root, f"{task_dir}/implement.md")
|
|
308
|
+
if implement_plan_content:
|
|
309
|
+
context_parts.append(
|
|
310
|
+
f"=== {task_dir}/implement.md (Execution Plan) ===\n{implement_plan_content}"
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
return "\n\n".join(context_parts)
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
def get_check_context(repo_root: str, task_dir: str) -> str:
|
|
317
|
+
"""
|
|
318
|
+
Context for Check Agent: check.jsonl + task artifacts.
|
|
319
|
+
"""
|
|
320
|
+
context_parts = []
|
|
321
|
+
|
|
322
|
+
for file_path, content in read_jsonl_entries(repo_root, f"{task_dir}/check.jsonl"):
|
|
323
|
+
context_parts.append(f"=== {file_path} ===\n{content}")
|
|
324
|
+
|
|
325
|
+
prd_content = read_file_content(repo_root, f"{task_dir}/prd.md")
|
|
326
|
+
if prd_content:
|
|
327
|
+
context_parts.append(f"=== {task_dir}/prd.md (Requirements) ===\n{prd_content}")
|
|
328
|
+
|
|
329
|
+
design_content = read_file_content(repo_root, f"{task_dir}/design.md")
|
|
330
|
+
if design_content:
|
|
331
|
+
context_parts.append(
|
|
332
|
+
f"=== {task_dir}/design.md (Technical Design) ===\n{design_content}"
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
implement_plan_content = read_file_content(repo_root, f"{task_dir}/implement.md")
|
|
336
|
+
if implement_plan_content:
|
|
337
|
+
context_parts.append(
|
|
338
|
+
f"=== {task_dir}/implement.md (Execution Plan) ===\n{implement_plan_content}"
|
|
339
|
+
)
|
|
340
|
+
|
|
341
|
+
return "\n\n".join(context_parts)
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
def get_finish_context(repo_root: str, task_dir: str) -> str:
|
|
345
|
+
"""
|
|
346
|
+
Context for Finish phase: reuses check.jsonl + prd.md
|
|
347
|
+
(Finish is a final check, same context source.)
|
|
348
|
+
"""
|
|
349
|
+
return get_check_context(repo_root, task_dir)
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
def build_implement_prompt(original_prompt: str, context: str) -> str:
|
|
354
|
+
"""Build complete prompt for Implement"""
|
|
355
|
+
return f"""<!-- trellis-hook-injected -->
|
|
356
|
+
# Implement Agent Task
|
|
357
|
+
|
|
358
|
+
You are the Implement Agent in the Multi-Agent Pipeline.
|
|
359
|
+
|
|
360
|
+
## Your Context
|
|
361
|
+
|
|
362
|
+
All the information you need has been prepared for you:
|
|
363
|
+
|
|
364
|
+
{context}
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
## Your Task
|
|
369
|
+
|
|
370
|
+
{original_prompt}
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Workflow
|
|
375
|
+
|
|
376
|
+
1. **Understand specs** - All dev specs are injected above, understand them
|
|
377
|
+
2. **Understand task artifacts** - Read requirements, technical design if present, and execution plan if present
|
|
378
|
+
3. **Implement feature** - Implement following specs and task artifacts
|
|
379
|
+
4. **Self-check** - Ensure code quality against check specs
|
|
380
|
+
|
|
381
|
+
## Important Constraints
|
|
382
|
+
|
|
383
|
+
- Do NOT execute git commit, only code modifications
|
|
384
|
+
- Follow all dev specs injected above
|
|
385
|
+
- Report list of modified/created files when done"""
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
def build_check_prompt(original_prompt: str, context: str) -> str:
|
|
389
|
+
"""Build complete prompt for Check"""
|
|
390
|
+
return f"""<!-- trellis-hook-injected -->
|
|
391
|
+
# Check Agent Task
|
|
392
|
+
|
|
393
|
+
You are the Check Agent in the Multi-Agent Pipeline (code and cross-layer checker).
|
|
394
|
+
|
|
395
|
+
## Your Context
|
|
396
|
+
|
|
397
|
+
All check specs and dev specs you need:
|
|
398
|
+
|
|
399
|
+
{context}
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Your Task
|
|
404
|
+
|
|
405
|
+
{original_prompt}
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
## Workflow
|
|
410
|
+
|
|
411
|
+
1. **Get changes** - Run `git diff --name-only` and `git diff` to get code changes
|
|
412
|
+
2. **Check against specs** - Check item by item against specs above
|
|
413
|
+
3. **Self-fix** - Fix issues directly, don't just report
|
|
414
|
+
4. **Run verification** - Run project's lint and typecheck commands
|
|
415
|
+
|
|
416
|
+
## Important Constraints
|
|
417
|
+
|
|
418
|
+
- Fix issues yourself, don't just report
|
|
419
|
+
- Must execute complete checklist in check specs
|
|
420
|
+
- Pay special attention to impact radius analysis (L1-L5)"""
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
def build_finish_prompt(original_prompt: str, context: str) -> str:
|
|
424
|
+
"""Build complete prompt for Finish (final check before PR)"""
|
|
425
|
+
return f"""<!-- trellis-hook-injected -->
|
|
426
|
+
# Finish Agent Task
|
|
427
|
+
|
|
428
|
+
You are performing the final check before creating a PR.
|
|
429
|
+
|
|
430
|
+
## Your Context
|
|
431
|
+
|
|
432
|
+
Finish checklist and requirements:
|
|
433
|
+
|
|
434
|
+
{context}
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
## Your Task
|
|
439
|
+
|
|
440
|
+
{original_prompt}
|
|
441
|
+
|
|
442
|
+
---
|
|
443
|
+
|
|
444
|
+
## Workflow
|
|
445
|
+
|
|
446
|
+
1. **Review changes** - Run `git diff --name-only` to see all changed files
|
|
447
|
+
2. **Verify task artifacts** - Check requirements in prd.md and, when present, design.md / implement.md
|
|
448
|
+
3. **Spec sync** - Analyze whether changes introduce new patterns, contracts, or conventions
|
|
449
|
+
- If new pattern/convention found: read target spec file → update it → update index.md if needed
|
|
450
|
+
- If infra/cross-layer change: follow the 7-section mandatory template from update-spec.md
|
|
451
|
+
- If pure code fix with no new patterns: skip this step
|
|
452
|
+
4. **Run final checks** - Execute lint and typecheck
|
|
453
|
+
5. **Confirm ready** - Ensure code is ready for PR
|
|
454
|
+
|
|
455
|
+
## Important Constraints
|
|
456
|
+
|
|
457
|
+
- You MAY update spec files when gaps are detected (use update-spec.md as guide)
|
|
458
|
+
- MUST read the target spec file BEFORE editing (avoid duplicating existing content)
|
|
459
|
+
- Do NOT update specs for trivial changes (typos, formatting, obvious fixes)
|
|
460
|
+
- If critical CODE issues found, report them clearly (fix specs, not code)
|
|
461
|
+
- Verify all acceptance criteria in prd.md are met
|
|
462
|
+
- Verify design.md and implement.md constraints when those files are present"""
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
def get_research_context(repo_root: str, task_dir: str | None) -> str:
|
|
467
|
+
"""
|
|
468
|
+
Context for Research Agent — project structure overview for spec directories.
|
|
469
|
+
|
|
470
|
+
`task_dir` kept for signature parity with get_implement_context / get_check_context
|
|
471
|
+
so the dispatcher can call them uniformly.
|
|
472
|
+
"""
|
|
473
|
+
_ = task_dir
|
|
474
|
+
context_parts = []
|
|
475
|
+
|
|
476
|
+
# 1. Project structure overview (dynamically discover spec directories)
|
|
477
|
+
spec_path = f"{DIR_WORKFLOW}/{DIR_SPEC}"
|
|
478
|
+
spec_root = Path(repo_root) / DIR_WORKFLOW / DIR_SPEC
|
|
479
|
+
|
|
480
|
+
# Build spec tree dynamically
|
|
481
|
+
tree_lines = [f"{spec_path}/"]
|
|
482
|
+
if spec_root.is_dir():
|
|
483
|
+
pkg_dirs = sorted(d for d in spec_root.iterdir() if d.is_dir())
|
|
484
|
+
for i, pkg_dir in enumerate(pkg_dirs):
|
|
485
|
+
is_last = i == len(pkg_dirs) - 1
|
|
486
|
+
prefix = "└── " if is_last else "├── "
|
|
487
|
+
layers = sorted(d.name for d in pkg_dir.iterdir() if d.is_dir())
|
|
488
|
+
layer_info = f" ({', '.join(layers)})" if layers else ""
|
|
489
|
+
tree_lines.append(f"{prefix}{pkg_dir.name}/{layer_info}")
|
|
490
|
+
|
|
491
|
+
spec_tree = "\n".join(tree_lines)
|
|
492
|
+
|
|
493
|
+
project_structure = f"""## Project Spec Directory Structure
|
|
494
|
+
|
|
495
|
+
```
|
|
496
|
+
{spec_tree}
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
To get structured package info, run: `python ./{DIR_WORKFLOW}/scripts/get_context.py --mode packages`
|
|
500
|
+
|
|
501
|
+
## Search Tips
|
|
502
|
+
|
|
503
|
+
- Spec files: `{spec_path}/**/*.md`
|
|
504
|
+
- Code search: Use Glob and Grep tools
|
|
505
|
+
- External facts / docs: load `smart-search-cli` skill and use Bash (`smart-search` CLI), not Cursor WebSearch/WebFetch by default"""
|
|
506
|
+
|
|
507
|
+
context_parts.append(project_structure)
|
|
508
|
+
|
|
509
|
+
return "\n\n".join(context_parts)
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
def build_research_prompt(original_prompt: str, context: str) -> str:
|
|
513
|
+
"""Build complete prompt for Research (aligned with trellis-research.md)."""
|
|
514
|
+
return f"""<!-- trellis-hook-injected -->
|
|
515
|
+
# Research Agent Task
|
|
516
|
+
|
|
517
|
+
You are the Trellis Research Agent.
|
|
518
|
+
|
|
519
|
+
## Core Principle
|
|
520
|
+
|
|
521
|
+
**You do one thing: find, explain, and PERSIST information.**
|
|
522
|
+
|
|
523
|
+
Conversations get compacted; files do not. Every research topic MUST be written under `{{TASK_DIR}}/research/`. Chat-only findings are a failure.
|
|
524
|
+
|
|
525
|
+
## Dispatch contract
|
|
526
|
+
|
|
527
|
+
- External facts: load `smart-search-cli` skill + Bash — default **not** Cursor `WebSearch`/`WebFetch`.
|
|
528
|
+
- Do NOT spawn nested `trellis-implement` / `trellis-check` / `trellis-research` sub-agents.
|
|
529
|
+
|
|
530
|
+
## Project Info
|
|
531
|
+
|
|
532
|
+
{context}
|
|
533
|
+
|
|
534
|
+
---
|
|
535
|
+
|
|
536
|
+
## Your Task
|
|
537
|
+
|
|
538
|
+
{original_prompt}
|
|
539
|
+
|
|
540
|
+
---
|
|
541
|
+
|
|
542
|
+
## Workflow
|
|
543
|
+
|
|
544
|
+
1. **Resolve task** — `python ./.trellis/scripts/task.py selected --source`; ensure `{{TASK_DIR}}/research/` exists (`mkdir -p`).
|
|
545
|
+
2. **Classify** — internal / external / mixed.
|
|
546
|
+
3. **Search** — Glob/Grep/Read for repo; `smart-search-cli` + CLI for external.
|
|
547
|
+
4. **Persist** — Write each topic to `{{TASK_DIR}}/research/<topic-slug>.md`.
|
|
548
|
+
5. **Report** — Reply with file paths + one-line summaries only (not full content).
|
|
549
|
+
|
|
550
|
+
## Write ALLOWED
|
|
551
|
+
|
|
552
|
+
- `{{TASK_DIR}}/research/*.md` only
|
|
553
|
+
|
|
554
|
+
## Write FORBIDDEN
|
|
555
|
+
|
|
556
|
+
- Code, `.trellis/spec/`, platform config, git operations"""
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
def _string_value(value: Any) -> str:
|
|
560
|
+
if isinstance(value, str):
|
|
561
|
+
stripped = value.strip()
|
|
562
|
+
return stripped
|
|
563
|
+
return ""
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
def _extract_subagent_name(value: Any) -> str:
|
|
567
|
+
"""Extract a sub-agent name from common platform encodings.
|
|
568
|
+
|
|
569
|
+
Cursor's native Task args encode custom sub-agents as a protobuf oneof,
|
|
570
|
+
which can appear in hook JSON as either ``{"custom": {"name": "..."}}``
|
|
571
|
+
or ``{"type": {"case": "custom", "value": {"name": "..."}}}``.
|
|
572
|
+
"""
|
|
573
|
+
direct = _string_value(value)
|
|
574
|
+
if direct:
|
|
575
|
+
return direct
|
|
576
|
+
|
|
577
|
+
if not isinstance(value, dict):
|
|
578
|
+
return ""
|
|
579
|
+
|
|
580
|
+
for key in ("name", "subagent_type_name", "subagentTypeName"):
|
|
581
|
+
direct = _string_value(value.get(key))
|
|
582
|
+
if direct:
|
|
583
|
+
return direct
|
|
584
|
+
|
|
585
|
+
custom = value.get("custom")
|
|
586
|
+
if isinstance(custom, dict):
|
|
587
|
+
custom_name = _string_value(custom.get("name"))
|
|
588
|
+
if custom_name:
|
|
589
|
+
return custom_name
|
|
590
|
+
|
|
591
|
+
oneof = value.get("type")
|
|
592
|
+
if isinstance(oneof, dict):
|
|
593
|
+
case_name = _string_value(oneof.get("case"))
|
|
594
|
+
if case_name == "custom":
|
|
595
|
+
nested_value = oneof.get("value")
|
|
596
|
+
if isinstance(nested_value, dict):
|
|
597
|
+
custom_name = _string_value(nested_value.get("name"))
|
|
598
|
+
if custom_name:
|
|
599
|
+
return custom_name
|
|
600
|
+
if case_name:
|
|
601
|
+
return case_name
|
|
602
|
+
|
|
603
|
+
case_name = _string_value(value.get("case"))
|
|
604
|
+
if case_name == "custom":
|
|
605
|
+
nested_value = value.get("value")
|
|
606
|
+
if isinstance(nested_value, dict):
|
|
607
|
+
custom_name = _string_value(nested_value.get("name"))
|
|
608
|
+
if custom_name:
|
|
609
|
+
return custom_name
|
|
610
|
+
if case_name:
|
|
611
|
+
return case_name
|
|
612
|
+
|
|
613
|
+
for agent_name in AGENTS_ALL:
|
|
614
|
+
if agent_name in value:
|
|
615
|
+
return agent_name
|
|
616
|
+
|
|
617
|
+
return ""
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
def _extract_subagent_type(tool_input: dict) -> str:
|
|
621
|
+
for key in (
|
|
622
|
+
"subagent_type",
|
|
623
|
+
"subagentType",
|
|
624
|
+
"subagent_type_name",
|
|
625
|
+
"subagentTypeName",
|
|
626
|
+
"agent_type",
|
|
627
|
+
"agentType",
|
|
628
|
+
"name",
|
|
629
|
+
):
|
|
630
|
+
agent_name = _extract_subagent_name(tool_input.get(key))
|
|
631
|
+
if agent_name:
|
|
632
|
+
return agent_name
|
|
633
|
+
return ""
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
def _parse_hook_input(input_data: dict) -> tuple[str, str, dict]:
|
|
637
|
+
"""Parse hook input across different platform formats.
|
|
638
|
+
|
|
639
|
+
Returns (subagent_type, original_prompt, tool_input).
|
|
640
|
+
Handles:
|
|
641
|
+
- Claude Code / Qoder / CodeBuddy / Droid: tool_name=Task|Agent, tool_input.subagent_type
|
|
642
|
+
- Cursor: tool_name=Task|Subagent, tool_input.subagent_type
|
|
643
|
+
- Copilot CLI: toolName=task (camelCase key, lowercase value)
|
|
644
|
+
- Gemini CLI: tool_name IS the agent name (BeforeTool matcher already filtered)
|
|
645
|
+
- Kiro: agentSpawn hook, agent_name field at top level
|
|
646
|
+
"""
|
|
647
|
+
tool_input = input_data.get("tool_input", {})
|
|
648
|
+
|
|
649
|
+
# Standard format: Task/Agent tool with subagent_type
|
|
650
|
+
tool_name = input_data.get("tool_name", "") or input_data.get("toolName", "")
|
|
651
|
+
if tool_name.lower() in ("task", "agent", "subagent"):
|
|
652
|
+
return (
|
|
653
|
+
_extract_subagent_type(tool_input),
|
|
654
|
+
tool_input.get("prompt", ""),
|
|
655
|
+
tool_input,
|
|
656
|
+
)
|
|
657
|
+
|
|
658
|
+
# Kiro: agentSpawn hook passes agent_name at top level
|
|
659
|
+
agent_name = input_data.get("agent_name", "")
|
|
660
|
+
if agent_name:
|
|
661
|
+
return agent_name, tool_input.get("prompt", input_data.get("prompt", "")), tool_input
|
|
662
|
+
|
|
663
|
+
# Gemini CLI: BeforeTool where tool_name IS the agent name
|
|
664
|
+
# (matcher already ensured it's one of our agents)
|
|
665
|
+
if tool_name in AGENTS_ALL:
|
|
666
|
+
return tool_name, tool_input.get("prompt", ""), tool_input
|
|
667
|
+
|
|
668
|
+
# Copilot CLI: toolName field (camelCase), value might be the agent name
|
|
669
|
+
tool_name_camel = input_data.get("toolName", "")
|
|
670
|
+
if tool_name_camel in AGENTS_ALL:
|
|
671
|
+
return tool_name_camel, input_data.get("toolArgs", ""), tool_input
|
|
672
|
+
|
|
673
|
+
return "", "", tool_input
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
def main():
|
|
677
|
+
if os.environ.get("TRELLIS_HOOKS") == "0" or os.environ.get("TRELLIS_DISABLE_HOOKS") == "1":
|
|
678
|
+
sys.exit(0)
|
|
679
|
+
|
|
680
|
+
try:
|
|
681
|
+
input_data = json.load(sys.stdin)
|
|
682
|
+
except json.JSONDecodeError:
|
|
683
|
+
sys.exit(0)
|
|
684
|
+
|
|
685
|
+
subagent_type, original_prompt, tool_input = _parse_hook_input(input_data)
|
|
686
|
+
cwd = input_data.get("cwd", os.getcwd())
|
|
687
|
+
|
|
688
|
+
# Only handle subagent types we care about
|
|
689
|
+
if subagent_type not in AGENTS_ALL:
|
|
690
|
+
sys.exit(0)
|
|
691
|
+
|
|
692
|
+
# Find repo root
|
|
693
|
+
repo_root = find_repo_root(cwd)
|
|
694
|
+
if not repo_root:
|
|
695
|
+
sys.exit(0)
|
|
696
|
+
|
|
697
|
+
# Get selected task directory (research doesn't require it)
|
|
698
|
+
task_dir = get_selected_task(repo_root, input_data)
|
|
699
|
+
|
|
700
|
+
# Fallback: extract task path from dispatch prompt (Multitask / clean-context scenarios)
|
|
701
|
+
if not task_dir and original_prompt:
|
|
702
|
+
for line in original_prompt.split("\n"):
|
|
703
|
+
line = line.strip()
|
|
704
|
+
if line.startswith("Selected task:"):
|
|
705
|
+
candidate = line.split("Selected task:", 1)[1].strip()
|
|
706
|
+
if candidate and os.path.isdir(os.path.join(repo_root, candidate)):
|
|
707
|
+
task_dir = candidate
|
|
708
|
+
print(
|
|
709
|
+
f"[inject-subagent-context] Resolved task from prompt: {task_dir}",
|
|
710
|
+
file=sys.stderr,
|
|
711
|
+
)
|
|
712
|
+
break
|
|
713
|
+
|
|
714
|
+
# implement/check need task directory
|
|
715
|
+
if subagent_type in AGENTS_REQUIRE_TASK:
|
|
716
|
+
if not task_dir:
|
|
717
|
+
sys.exit(0)
|
|
718
|
+
# Check if task directory exists
|
|
719
|
+
task_dir_full = os.path.join(repo_root, task_dir)
|
|
720
|
+
if not os.path.exists(task_dir_full):
|
|
721
|
+
sys.exit(0)
|
|
722
|
+
|
|
723
|
+
# Check for [finish] marker in prompt (check agent with finish context)
|
|
724
|
+
is_finish_phase = "[finish]" in original_prompt.lower()
|
|
725
|
+
|
|
726
|
+
# Get context and build prompt based on subagent type
|
|
727
|
+
if subagent_type == AGENT_IMPLEMENT:
|
|
728
|
+
assert task_dir is not None # validated above
|
|
729
|
+
context = get_implement_context(repo_root, task_dir)
|
|
730
|
+
new_prompt = build_implement_prompt(original_prompt, context)
|
|
731
|
+
elif subagent_type == AGENT_CHECK:
|
|
732
|
+
assert task_dir is not None # validated above
|
|
733
|
+
if is_finish_phase:
|
|
734
|
+
# Finish phase: use finish context (lighter, focused on final verification)
|
|
735
|
+
context = get_finish_context(repo_root, task_dir)
|
|
736
|
+
new_prompt = build_finish_prompt(original_prompt, context)
|
|
737
|
+
else:
|
|
738
|
+
# Regular check phase: use check context (full specs for self-fix loop)
|
|
739
|
+
context = get_check_context(repo_root, task_dir)
|
|
740
|
+
new_prompt = build_check_prompt(original_prompt, context)
|
|
741
|
+
elif subagent_type == AGENT_RESEARCH:
|
|
742
|
+
# Research can work without task directory
|
|
743
|
+
context = get_research_context(repo_root, task_dir)
|
|
744
|
+
new_prompt = build_research_prompt(original_prompt, context)
|
|
745
|
+
else:
|
|
746
|
+
sys.exit(0)
|
|
747
|
+
|
|
748
|
+
if not context:
|
|
749
|
+
sys.exit(0)
|
|
750
|
+
|
|
751
|
+
# Return updated input — use a multi-format output that covers all platforms.
|
|
752
|
+
# Most platforms ignore unrecognized fields, so we include multiple formats.
|
|
753
|
+
# The platform picks whichever fields it understands.
|
|
754
|
+
updated = {**tool_input, "prompt": new_prompt}
|
|
755
|
+
output = {
|
|
756
|
+
# Claude Code / Qoder / CodeBuddy / Droid format
|
|
757
|
+
"hookSpecificOutput": {
|
|
758
|
+
"hookEventName": "PreToolUse",
|
|
759
|
+
"permissionDecision": "allow",
|
|
760
|
+
"updatedInput": updated,
|
|
761
|
+
},
|
|
762
|
+
# Cursor format
|
|
763
|
+
"permission": "allow",
|
|
764
|
+
"updated_input": updated,
|
|
765
|
+
# Gemini format
|
|
766
|
+
"updatedInput": updated,
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
print(json.dumps(output, ensure_ascii=False))
|
|
770
|
+
sys.exit(0)
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
if __name__ == "__main__":
|
|
774
|
+
main()
|