@ibotor/smart-trellis 0.5.19
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/LICENSE +235 -0
- package/README.md +263 -0
- package/bin/smart-trellis.js +3 -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 +132 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/smart.d.ts +2 -0
- package/dist/cli/smart.d.ts.map +1 -0
- package/dist/cli/smart.js +41 -0
- package/dist/cli/smart.js.map +1 -0
- package/dist/commands/init.d.ts +56 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +1466 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/smart-init.d.ts +22 -0
- package/dist/commands/smart-init.d.ts.map +1 -0
- package/dist/commands/smart-init.js +122 -0
- package/dist/commands/smart-init.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 +72 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +1926 -0
- package/dist/commands/update.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 +85 -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 +10 -0
- package/dist/configurators/cursor.d.ts.map +1 -0
- package/dist/configurators/cursor.js +29 -0
- package/dist/configurators/cursor.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 +65 -0
- package/dist/configurators/index.d.ts.map +1 -0
- package/dist/configurators/index.js +367 -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 +178 -0
- package/dist/configurators/shared.d.ts.map +1 -0
- package/dist/configurators/shared.js +538 -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 +29 -0
- package/dist/configurators/workflow.d.ts.map +1 -0
- package/dist/configurators/workflow.js +163 -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 +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -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.9.json +30 -0
- package/dist/migrations/manifests/0.2.0.json +49 -0
- package/dist/migrations/manifests/0.2.12.json +9 -0
- package/dist/migrations/manifests/0.2.13.json +9 -0
- package/dist/migrations/manifests/0.2.14.json +175 -0
- package/dist/migrations/manifests/0.2.15.json +33 -0
- package/dist/migrations/manifests/0.3.0-beta.0.json +297 -0
- package/dist/migrations/manifests/0.3.0-beta.1.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.10.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.11.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.12.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.13.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.14.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.15.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.16.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.2.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.3.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.4.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.5.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.6.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.7.json +11 -0
- package/dist/migrations/manifests/0.3.0-beta.8.json +9 -0
- package/dist/migrations/manifests/0.3.0-beta.9.json +9 -0
- package/dist/migrations/manifests/0.3.0-rc.0.json +9 -0
- package/dist/migrations/manifests/0.3.0-rc.1.json +9 -0
- package/dist/migrations/manifests/0.3.0-rc.2.json +9 -0
- package/dist/migrations/manifests/0.3.0-rc.3.json +9 -0
- package/dist/migrations/manifests/0.3.0-rc.4.json +9 -0
- package/dist/migrations/manifests/0.3.0-rc.5.json +9 -0
- package/dist/migrations/manifests/0.3.0-rc.6.json +9 -0
- package/dist/migrations/manifests/0.3.0.json +11 -0
- package/dist/migrations/manifests/0.3.1.json +9 -0
- package/dist/migrations/manifests/0.3.10.json +9 -0
- package/dist/migrations/manifests/0.3.2.json +9 -0
- package/dist/migrations/manifests/0.3.3.json +9 -0
- package/dist/migrations/manifests/0.3.4.json +21 -0
- package/dist/migrations/manifests/0.3.5.json +9 -0
- package/dist/migrations/manifests/0.3.6.json +9 -0
- package/dist/migrations/manifests/0.3.7.json +9 -0
- package/dist/migrations/manifests/0.3.8.json +9 -0
- package/dist/migrations/manifests/0.3.9.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.1.json +228 -0
- package/dist/migrations/manifests/0.4.0-beta.10.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.2.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.3.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.4.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.5.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.6.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.7.json +9 -0
- package/dist/migrations/manifests/0.4.0-beta.8.json +34 -0
- package/dist/migrations/manifests/0.4.0-beta.9.json +9 -0
- package/dist/migrations/manifests/0.4.0-rc.0.json +9 -0
- package/dist/migrations/manifests/0.4.0-rc.1.json +9 -0
- package/dist/migrations/manifests/0.4.0.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.0.json +1646 -0
- package/dist/migrations/manifests/0.5.0-beta.1.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.10.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.11.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.12.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.13.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.14.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.15.json +116 -0
- package/dist/migrations/manifests/0.5.0-beta.16.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.17.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.18.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.19.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.2.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.3.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.4.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.5.json +222 -0
- package/dist/migrations/manifests/0.5.0-beta.6.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.7.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.8.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.9.json +48 -0
- package/dist/migrations/manifests/0.5.0-rc.0.json +9 -0
- package/dist/migrations/manifests/0.5.0-rc.1.json +9 -0
- package/dist/migrations/manifests/0.5.0-rc.2.json +9 -0
- package/dist/migrations/manifests/0.5.0-rc.3.json +9 -0
- package/dist/migrations/manifests/0.5.0-rc.4.json +9 -0
- package/dist/migrations/manifests/0.5.0-rc.5.json +9 -0
- package/dist/migrations/manifests/0.5.0-rc.6.json +9 -0
- package/dist/migrations/manifests/0.5.0-rc.7.json +9 -0
- package/dist/migrations/manifests/0.5.0.json +9 -0
- package/dist/migrations/manifests/0.5.1.json +9 -0
- package/dist/migrations/manifests/0.5.10.json +9 -0
- package/dist/migrations/manifests/0.5.11.json +16 -0
- package/dist/migrations/manifests/0.5.12.json +9 -0
- package/dist/migrations/manifests/0.5.13.json +9 -0
- package/dist/migrations/manifests/0.5.14.json +9 -0
- package/dist/migrations/manifests/0.5.15.json +9 -0
- package/dist/migrations/manifests/0.5.16.json +9 -0
- package/dist/migrations/manifests/0.5.17.json +9 -0
- package/dist/migrations/manifests/0.5.18.json +9 -0
- package/dist/migrations/manifests/0.5.19.json +9 -0
- package/dist/migrations/manifests/0.5.2.json +9 -0
- package/dist/migrations/manifests/0.5.3.json +9 -0
- package/dist/migrations/manifests/0.5.4.json +9 -0
- package/dist/migrations/manifests/0.5.5.json +9 -0
- package/dist/migrations/manifests/0.5.6.json +9 -0
- package/dist/migrations/manifests/0.5.7.json +16 -0
- package/dist/migrations/manifests/0.5.8.json +9 -0
- package/dist/migrations/manifests/0.5.9.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.0.json +16 -0
- package/dist/migrations/manifests/0.6.0-beta.1.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.10.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.11.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.12.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.13.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.14.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.15.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.16.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.17.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.18.json +16 -0
- package/dist/migrations/manifests/0.6.0-beta.19.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.2.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.20.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.21.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.3.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.4.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.5.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.6.json +16 -0
- package/dist/migrations/manifests/0.6.0-beta.7.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.8.json +9 -0
- package/dist/migrations/manifests/0.6.0-beta.9.json +9 -0
- package/dist/templates/claude/agents/trellis-check.md +109 -0
- package/dist/templates/claude/agents/trellis-implement.md +109 -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 +73 -0
- package/dist/templates/codebuddy/agents/trellis-check.md +109 -0
- package/dist/templates/codebuddy/agents/trellis-implement.md +109 -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 +59 -0
- package/dist/templates/codex/agents/trellis-check.toml +84 -0
- package/dist/templates/codex/agents/trellis-implement.toml +65 -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 +481 -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 +34 -0
- package/dist/templates/codex/skills/brainstorm/SKILL.md +500 -0
- package/dist/templates/codex/skills/break-loop/SKILL.md +130 -0
- package/dist/templates/codex/skills/check/SKILL.md +30 -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 +354 -0
- package/dist/templates/codex/skills/update-spec/SKILL.md +335 -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 +81 -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 +78 -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 +90 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-workflow.md +64 -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 +101 -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 +79 -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 +59 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md +74 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/skills-and-commands.md +83 -0
- package/dist/templates/common/bundled-skills/trellis-spec-bootstarp/SKILL.md +41 -0
- package/dist/templates/common/bundled-skills/trellis-spec-bootstarp/references/mcp-setup.md +90 -0
- package/dist/templates/common/bundled-skills/trellis-spec-bootstarp/references/repository-analysis.md +59 -0
- package/dist/templates/common/bundled-skills/trellis-spec-bootstarp/references/spec-task-planning.md +61 -0
- package/dist/templates/common/bundled-skills/trellis-spec-bootstarp/references/spec-writing.md +70 -0
- package/dist/templates/common/commands/continue.md +55 -0
- package/dist/templates/common/commands/finish-work.md +66 -0
- package/dist/templates/common/commands/start.md +58 -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 +29 -0
- package/dist/templates/common/skills/brainstorm.md +543 -0
- package/dist/templates/common/skills/break-loop.md +125 -0
- package/dist/templates/common/skills/check.md +87 -0
- package/dist/templates/common/skills/update-spec.md +351 -0
- package/dist/templates/copilot/hooks/session-start.py +454 -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 +33 -0
- package/dist/templates/copilot/prompts/brainstorm.prompt.md +499 -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 +29 -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 +196 -0
- package/dist/templates/copilot/prompts/record-session.prompt.md +66 -0
- package/dist/templates/copilot/prompts/start.prompt.md +397 -0
- package/dist/templates/copilot/prompts/update-spec.prompt.md +358 -0
- package/dist/templates/cursor/agents/trellis-check.md +108 -0
- package/dist/templates/cursor/agents/trellis-implement.md +108 -0
- package/dist/templates/cursor/agents/trellis-research.md +136 -0
- package/dist/templates/cursor/hooks.json +24 -0
- package/dist/templates/cursor/index.d.ts +13 -0
- package/dist/templates/cursor/index.d.ts.map +1 -0
- package/dist/templates/cursor/index.js +13 -0
- package/dist/templates/cursor/index.js.map +1 -0
- package/dist/templates/droid/droids/trellis-check.md +101 -0
- package/dist/templates/droid/droids/trellis-implement.md +101 -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 +59 -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 +101 -0
- package/dist/templates/gemini/agents/trellis-implement.md +101 -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 +21 -0
- package/dist/templates/markdown/gitignore.txt +15 -0
- package/dist/templates/markdown/index.d.ts +27 -0
- package/dist/templates/markdown/index.d.ts.map +1 -0
- package/dist/templates/markdown/index.js +52 -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 +105 -0
- package/dist/templates/markdown/spec/guides/cross-layer-thinking-guide.md.txt +162 -0
- package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +595 -0
- package/dist/templates/markdown/spec/guides/index.md.txt +79 -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 +116 -0
- package/dist/templates/opencode/agents/trellis-implement.md +117 -0
- package/dist/templates/opencode/agents/trellis-research.md +145 -0
- package/dist/templates/opencode/lib/session-utils.js +432 -0
- package/dist/templates/opencode/lib/trellis-context.js +381 -0
- package/dist/templates/opencode/package.json +5 -0
- package/dist/templates/opencode/plugins/inject-subagent-context.js +497 -0
- package/dist/templates/opencode/plugins/inject-workflow-state.js +162 -0
- package/dist/templates/opencode/plugins/session-start.js +101 -0
- package/dist/templates/pi/agents/trellis-check.md +36 -0
- package/dist/templates/pi/agents/trellis-implement.md +41 -0
- package/dist/templates/pi/agents/trellis-research.md +25 -0
- package/dist/templates/pi/extensions/trellis/index.ts.txt +1172 -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 +21 -0
- package/dist/templates/qoder/agents/trellis-check.md +102 -0
- package/dist/templates/qoder/agents/trellis-implement.md +102 -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 +88 -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 +749 -0
- package/dist/templates/shared-hooks/inject-workflow-state.py +387 -0
- package/dist/templates/shared-hooks/session-start.py +797 -0
- package/dist/templates/template-utils.d.ts +26 -0
- package/dist/templates/template-utils.d.ts.map +1 -0
- package/dist/templates/template-utils.js +60 -0
- package/dist/templates/template-utils.js.map +1 -0
- package/dist/templates/trellis/config.yaml +90 -0
- package/dist/templates/trellis/gitignore.txt +32 -0
- package/dist/templates/trellis/index.d.ts +52 -0
- package/dist/templates/trellis/index.d.ts.map +1 -0
- package/dist/templates/trellis/index.js +97 -0
- package/dist/templates/trellis/index.js.map +1 -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/common/__init__.py +92 -0
- package/dist/templates/trellis/scripts/common/active_task.py +626 -0
- package/dist/templates/trellis/scripts/common/cli_adapter.py +811 -0
- package/dist/templates/trellis/scripts/common/config.py +445 -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 +106 -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 +238 -0
- package/dist/templates/trellis/scripts/common/paths.py +447 -0
- package/dist/templates/trellis/scripts/common/safe_commit.py +285 -0
- package/dist/templates/trellis/scripts/common/session_context.py +821 -0
- package/dist/templates/trellis/scripts/common/task_context.py +223 -0
- package/dist/templates/trellis/scripts/common/task_queue.py +188 -0
- package/dist/templates/trellis/scripts/common/task_store.py +697 -0
- package/dist/templates/trellis/scripts/common/task_utils.py +274 -0
- package/dist/templates/trellis/scripts/common/tasks.py +112 -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 +215 -0
- package/dist/templates/trellis/scripts/get_context.py +16 -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/task.py +500 -0
- package/dist/templates/trellis/tasks/.gitkeep +0 -0
- package/dist/templates/trellis/workflow.md +690 -0
- package/dist/types/ai-tools.d.ts +95 -0
- package/dist/types/ai-tools.d.ts.map +1 -0
- package/dist/types/ai-tools.js +280 -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/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/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/task-json.d.ts +46 -0
- package/dist/utils/task-json.d.ts.map +1 -0
- package/dist/utils/task-json.js +49 -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/package.json +89 -0
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
/* global process */
|
|
2
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "fs"
|
|
3
|
+
import { basename, join } from "path"
|
|
4
|
+
import { execFileSync } from "child_process"
|
|
5
|
+
import { platform } from "os"
|
|
6
|
+
import { debugLog } from "./trellis-context.js"
|
|
7
|
+
|
|
8
|
+
const PYTHON_CMD = platform() === "win32" ? "python" : "python3"
|
|
9
|
+
|
|
10
|
+
const FIRST_REPLY_NOTICE = `<first-reply-notice>
|
|
11
|
+
On the first visible assistant reply in this session, begin with exactly one short Chinese sentence:
|
|
12
|
+
Trellis SessionStart 已注入:workflow、当前任务状态、开发者身份、git 状态、active tasks、spec 索引已加载。
|
|
13
|
+
Then continue directly with the user's request. This notice is one-shot: do not repeat it after the first assistant reply in the same session.
|
|
14
|
+
</first-reply-notice>`
|
|
15
|
+
|
|
16
|
+
function hasCuratedJsonlEntry(jsonlPath) {
|
|
17
|
+
try {
|
|
18
|
+
const content = readFileSync(jsonlPath, "utf-8")
|
|
19
|
+
for (const rawLine of content.split(/\r?\n/)) {
|
|
20
|
+
const line = rawLine.trim()
|
|
21
|
+
if (!line) continue
|
|
22
|
+
try {
|
|
23
|
+
const row = JSON.parse(line)
|
|
24
|
+
if (row && typeof row === "object" && typeof row.file === "string" && row.file) {
|
|
25
|
+
return true
|
|
26
|
+
}
|
|
27
|
+
} catch {
|
|
28
|
+
// Ignore malformed line
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
} catch {
|
|
32
|
+
return false
|
|
33
|
+
}
|
|
34
|
+
return false
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getTaskStatus(ctx, platformInput = null) {
|
|
38
|
+
const active = ctx.getActiveTask(platformInput)
|
|
39
|
+
const taskRef = active.taskPath
|
|
40
|
+
if (!taskRef) {
|
|
41
|
+
return `Status: NO ACTIVE TASK\nSource: ${active.source}\nNext: Describe what you want to work on`
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const taskDir = ctx.resolveTaskDir(taskRef)
|
|
45
|
+
|
|
46
|
+
if (active.stale || !taskDir || !existsSync(taskDir)) {
|
|
47
|
+
return `Status: STALE POINTER\nTask: ${taskRef}\nSource: ${active.source}\nNext: Task directory not found. Run: python3 ./.trellis/scripts/task.py finish`
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let taskData = {}
|
|
51
|
+
const taskJsonPath = join(taskDir, "task.json")
|
|
52
|
+
if (existsSync(taskJsonPath)) {
|
|
53
|
+
try {
|
|
54
|
+
taskData = JSON.parse(readFileSync(taskJsonPath, "utf-8"))
|
|
55
|
+
} catch {
|
|
56
|
+
// Ignore parse errors
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const taskTitle = taskData.title || taskRef
|
|
61
|
+
const taskStatus = taskData.status || "unknown"
|
|
62
|
+
|
|
63
|
+
if (taskStatus === "completed") {
|
|
64
|
+
const dirName = basename(taskDir)
|
|
65
|
+
return `Status: COMPLETED\nTask: ${taskTitle}\nSource: ${active.source}\nNext: Archive with \`python3 ./.trellis/scripts/task.py archive ${dirName}\` or start a new task`
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let hasContext = false
|
|
69
|
+
for (const jsonlName of ["implement.jsonl", "check.jsonl"]) {
|
|
70
|
+
const jsonlPath = join(taskDir, jsonlName)
|
|
71
|
+
if (existsSync(jsonlPath) && hasCuratedJsonlEntry(jsonlPath)) {
|
|
72
|
+
hasContext = true
|
|
73
|
+
break
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const hasPrd = existsSync(join(taskDir, "prd.md"))
|
|
78
|
+
|
|
79
|
+
if (!hasPrd) {
|
|
80
|
+
return `Status: NOT READY\nTask: ${taskTitle}\nSource: ${active.source}\nMissing: prd.md not created\nNext: Write PRD (see workflow.md Phase 1.1) then curate implement.jsonl per Phase 1.3`
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!hasContext) {
|
|
84
|
+
return `Status: NOT READY\nTask: ${taskTitle}\nSource: ${active.source}\nMissing: implement.jsonl / check.jsonl missing or empty\nNext: Curate entries per workflow.md Phase 1.3 (spec + research files only), then \`task.py start\``
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
`Status: READY\nTask: ${taskTitle}\n` +
|
|
89
|
+
`Source: ${active.source}\n` +
|
|
90
|
+
"Next required action: dispatch `trellis-implement` per Phase 2.1. " +
|
|
91
|
+
"For agent-capable platforms, the default is to NOT edit code in the main session. " +
|
|
92
|
+
"After implementation, dispatch `trellis-check` per Phase 2.2 before reporting completion.\n" +
|
|
93
|
+
"User override (per-turn escape hatch): if the user's CURRENT message explicitly tells the " +
|
|
94
|
+
"main session to handle it directly (\"你直接改\" / \"别派 sub-agent\" / \"main session 写就行\" / " +
|
|
95
|
+
"\"do it inline\" / \"不用 sub-agent\"), honor it for this turn and edit code directly. " +
|
|
96
|
+
"Per-turn only; do NOT invent an override the user did not say."
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function loadTrellisConfig(directory, contextKey = null) {
|
|
101
|
+
const scriptPath = join(directory, ".trellis", "scripts", "get_context.py")
|
|
102
|
+
if (!existsSync(scriptPath)) {
|
|
103
|
+
return { isMonorepo: false, packages: {}, specScope: null, activeTaskPackage: null, defaultPackage: null }
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const output = execFileSync(PYTHON_CMD, [scriptPath, "--mode", "packages", "--json"], {
|
|
107
|
+
cwd: directory,
|
|
108
|
+
timeout: 5000,
|
|
109
|
+
encoding: "utf-8",
|
|
110
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
111
|
+
env: {
|
|
112
|
+
...process.env,
|
|
113
|
+
...(contextKey ? { TRELLIS_CONTEXT_ID: contextKey } : {}),
|
|
114
|
+
},
|
|
115
|
+
})
|
|
116
|
+
const data = JSON.parse(output)
|
|
117
|
+
if (data.mode !== "monorepo") {
|
|
118
|
+
return { isMonorepo: false, packages: {}, specScope: null, activeTaskPackage: null, defaultPackage: null }
|
|
119
|
+
}
|
|
120
|
+
const pkgDict = {}
|
|
121
|
+
for (const pkg of (data.packages || [])) {
|
|
122
|
+
pkgDict[pkg.name] = pkg
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
isMonorepo: true,
|
|
126
|
+
packages: pkgDict,
|
|
127
|
+
specScope: data.specScope || null,
|
|
128
|
+
activeTaskPackage: data.activeTaskPackage || null,
|
|
129
|
+
defaultPackage: data.defaultPackage || null,
|
|
130
|
+
}
|
|
131
|
+
} catch (e) {
|
|
132
|
+
debugLog("session", "loadTrellisConfig error:", e.message)
|
|
133
|
+
return { isMonorepo: false, packages: {}, specScope: null, activeTaskPackage: null, defaultPackage: null }
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function checkLegacySpec(directory, config) {
|
|
138
|
+
if (!config.isMonorepo || Object.keys(config.packages).length === 0) {
|
|
139
|
+
return null
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const specDir = join(directory, ".trellis", "spec")
|
|
143
|
+
if (!existsSync(specDir)) return null
|
|
144
|
+
|
|
145
|
+
let hasLegacy = false
|
|
146
|
+
for (const name of ["backend", "frontend"]) {
|
|
147
|
+
if (existsSync(join(specDir, name, "index.md"))) {
|
|
148
|
+
hasLegacy = true
|
|
149
|
+
break
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (!hasLegacy) return null
|
|
153
|
+
|
|
154
|
+
const pkgNames = Object.keys(config.packages).sort()
|
|
155
|
+
const missing = pkgNames.filter(name => !existsSync(join(specDir, name)))
|
|
156
|
+
|
|
157
|
+
if (missing.length === 0) return null
|
|
158
|
+
|
|
159
|
+
if (missing.length === pkgNames.length) {
|
|
160
|
+
return (
|
|
161
|
+
`[!] Legacy spec structure detected: found \`spec/backend/\` or \`spec/frontend/\` ` +
|
|
162
|
+
`but no package-scoped \`spec/<package>/\` directories.\n` +
|
|
163
|
+
`Monorepo packages: ${pkgNames.join(", ")}\n` +
|
|
164
|
+
`Please reorganize: \`spec/backend/\` -> \`spec/<package>/backend/\``
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
return (
|
|
168
|
+
`[!] Partial spec migration detected: packages ${missing.join(", ")} ` +
|
|
169
|
+
`still missing \`spec/<pkg>/\` directory.\n` +
|
|
170
|
+
`Please complete migration for all packages.`
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function resolveSpecScope(config) {
|
|
175
|
+
if (!config.isMonorepo || Object.keys(config.packages).length === 0) {
|
|
176
|
+
return null
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const { specScope, activeTaskPackage, defaultPackage, packages } = config
|
|
180
|
+
if (specScope == null) return null
|
|
181
|
+
|
|
182
|
+
if (specScope === "active_task") {
|
|
183
|
+
if (activeTaskPackage && activeTaskPackage in packages) return new Set([activeTaskPackage])
|
|
184
|
+
if (defaultPackage && defaultPackage in packages) return new Set([defaultPackage])
|
|
185
|
+
return null
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (Array.isArray(specScope)) {
|
|
189
|
+
const valid = new Set()
|
|
190
|
+
for (const entry of specScope) {
|
|
191
|
+
if (entry in packages) {
|
|
192
|
+
valid.add(entry)
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (valid.size > 0) return valid
|
|
196
|
+
if (activeTaskPackage && activeTaskPackage in packages) return new Set([activeTaskPackage])
|
|
197
|
+
if (defaultPackage && defaultPackage in packages) return new Set([defaultPackage])
|
|
198
|
+
return null
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return null
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function buildSessionContext(ctx, platformInput = null) {
|
|
205
|
+
const directory = ctx.directory
|
|
206
|
+
const trellisDir = join(directory, ".trellis")
|
|
207
|
+
const contextKey = typeof ctx.getContextKey === "function"
|
|
208
|
+
? ctx.getContextKey(platformInput)
|
|
209
|
+
: null
|
|
210
|
+
|
|
211
|
+
const config = loadTrellisConfig(directory, contextKey)
|
|
212
|
+
const allowedPkgs = resolveSpecScope(config)
|
|
213
|
+
|
|
214
|
+
const parts = []
|
|
215
|
+
|
|
216
|
+
parts.push(`<trellis-context>
|
|
217
|
+
You are starting a new session in a Trellis-managed project.
|
|
218
|
+
Read and follow all instructions below carefully.
|
|
219
|
+
</trellis-context>`)
|
|
220
|
+
parts.push(FIRST_REPLY_NOTICE)
|
|
221
|
+
|
|
222
|
+
const legacyWarning = checkLegacySpec(directory, config)
|
|
223
|
+
if (legacyWarning) {
|
|
224
|
+
parts.push(`<migration-warning>\n${legacyWarning}\n</migration-warning>`)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const contextScript = join(trellisDir, "scripts", "get_context.py")
|
|
228
|
+
if (existsSync(contextScript)) {
|
|
229
|
+
const output = ctx.runScript(contextScript, undefined, contextKey)
|
|
230
|
+
if (output) {
|
|
231
|
+
parts.push("<current-state>")
|
|
232
|
+
parts.push(output)
|
|
233
|
+
parts.push("</current-state>")
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const workflowContent = ctx.readProjectFile(".trellis/workflow.md")
|
|
238
|
+
if (workflowContent) {
|
|
239
|
+
const allLines = workflowContent.split("\n")
|
|
240
|
+
const overviewLines = [
|
|
241
|
+
"# Development Workflow — Section Index",
|
|
242
|
+
"Full guide: .trellis/workflow.md (read on demand)",
|
|
243
|
+
"",
|
|
244
|
+
"## Table of Contents",
|
|
245
|
+
]
|
|
246
|
+
for (const line of allLines) {
|
|
247
|
+
if (line.startsWith("## ")) overviewLines.push(line)
|
|
248
|
+
}
|
|
249
|
+
overviewLines.push("", "---", "")
|
|
250
|
+
|
|
251
|
+
let rangeStart = -1
|
|
252
|
+
let rangeEnd = allLines.length
|
|
253
|
+
for (let i = 0; i < allLines.length; i++) {
|
|
254
|
+
const stripped = allLines[i].trim()
|
|
255
|
+
if (rangeStart === -1 && stripped === "## Phase Index") {
|
|
256
|
+
rangeStart = i
|
|
257
|
+
} else if (rangeStart !== -1 && stripped === "## Workflow State Breadcrumbs") {
|
|
258
|
+
rangeEnd = i
|
|
259
|
+
break
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (rangeStart !== -1) {
|
|
263
|
+
overviewLines.push(...allLines.slice(rangeStart, rangeEnd))
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
parts.push("<workflow>")
|
|
267
|
+
parts.push(overviewLines.join("\n").trimEnd())
|
|
268
|
+
parts.push("</workflow>")
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
parts.push("<guidelines>")
|
|
272
|
+
parts.push(
|
|
273
|
+
"Project spec indexes are listed by path below. Each index contains a " +
|
|
274
|
+
"**Pre-Development Checklist** listing the specific guideline files to " +
|
|
275
|
+
"read before coding.\n\n" +
|
|
276
|
+
"- If you're spawning an implement/check sub-agent, context is injected " +
|
|
277
|
+
"automatically via `{task}/implement.jsonl` / `check.jsonl`. You do NOT " +
|
|
278
|
+
"need to read these indexes yourself.\n" +
|
|
279
|
+
"- For agent-capable platforms, do NOT edit code directly in the main " +
|
|
280
|
+
"session; dispatch `trellis-implement` and `trellis-check` so JSONL " +
|
|
281
|
+
"context is loaded by the sub-agents.\n"
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
const specDir = join(directory, ".trellis", "spec")
|
|
285
|
+
|
|
286
|
+
const guidesIndex = join(specDir, "guides", "index.md")
|
|
287
|
+
if (existsSync(guidesIndex)) {
|
|
288
|
+
const content = ctx.readFile(guidesIndex)
|
|
289
|
+
if (content) {
|
|
290
|
+
parts.push(`## guides (inlined — cross-package thinking guides)\n${content}\n`)
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const paths = []
|
|
295
|
+
if (existsSync(specDir)) {
|
|
296
|
+
try {
|
|
297
|
+
const subs = readdirSync(specDir).filter(name => {
|
|
298
|
+
if (name.startsWith(".")) return false
|
|
299
|
+
try {
|
|
300
|
+
return statSync(join(specDir, name)).isDirectory()
|
|
301
|
+
} catch {
|
|
302
|
+
return false
|
|
303
|
+
}
|
|
304
|
+
}).sort()
|
|
305
|
+
|
|
306
|
+
for (const sub of subs) {
|
|
307
|
+
if (sub === "guides") continue
|
|
308
|
+
|
|
309
|
+
const indexFile = join(specDir, sub, "index.md")
|
|
310
|
+
if (existsSync(indexFile)) {
|
|
311
|
+
paths.push(`.trellis/spec/${sub}/index.md`)
|
|
312
|
+
} else {
|
|
313
|
+
if (allowedPkgs !== null && !allowedPkgs.has(sub)) continue
|
|
314
|
+
try {
|
|
315
|
+
const nested = readdirSync(join(specDir, sub)).filter(name => {
|
|
316
|
+
try {
|
|
317
|
+
return statSync(join(specDir, sub, name)).isDirectory()
|
|
318
|
+
} catch {
|
|
319
|
+
return false
|
|
320
|
+
}
|
|
321
|
+
}).sort()
|
|
322
|
+
for (const layer of nested) {
|
|
323
|
+
const nestedIndex = join(specDir, sub, layer, "index.md")
|
|
324
|
+
if (existsSync(nestedIndex)) {
|
|
325
|
+
paths.push(`.trellis/spec/${sub}/${layer}/index.md`)
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
} catch {
|
|
329
|
+
// Ignore directory read errors
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
} catch {
|
|
334
|
+
// Ignore spec directory read errors
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (paths.length > 0) {
|
|
339
|
+
parts.push("## Available spec indexes (read on demand)")
|
|
340
|
+
for (const p of paths) {
|
|
341
|
+
parts.push(`- ${p}`)
|
|
342
|
+
}
|
|
343
|
+
parts.push("")
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
parts.push(
|
|
347
|
+
"Discover more via: " +
|
|
348
|
+
"`python3 ./.trellis/scripts/get_context.py --mode packages`"
|
|
349
|
+
)
|
|
350
|
+
parts.push("</guidelines>")
|
|
351
|
+
|
|
352
|
+
const taskStatus = getTaskStatus(ctx, platformInput)
|
|
353
|
+
parts.push(`<task-status>\n${taskStatus}\n</task-status>`)
|
|
354
|
+
|
|
355
|
+
parts.push(`<ready>
|
|
356
|
+
Context loaded. Workflow index, project state, and guidelines are already injected above — do NOT re-read them.
|
|
357
|
+
When the user sends the first message, follow <task-status> and the workflow guide.
|
|
358
|
+
If a task is READY, execute its Next required action without asking whether to continue.
|
|
359
|
+
</ready>`)
|
|
360
|
+
|
|
361
|
+
return parts.join("\n\n")
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function getTrellisMetadata(metadata) {
|
|
365
|
+
if (!metadata || typeof metadata !== "object") {
|
|
366
|
+
return {}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const trellis = metadata.trellis
|
|
370
|
+
if (!trellis || typeof trellis !== "object") {
|
|
371
|
+
return {}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return trellis
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function markPartAsSessionStart(part) {
|
|
378
|
+
const metadata = part.metadata && typeof part.metadata === "object"
|
|
379
|
+
? part.metadata
|
|
380
|
+
: {}
|
|
381
|
+
part.metadata = {
|
|
382
|
+
...metadata,
|
|
383
|
+
trellis: {
|
|
384
|
+
...getTrellisMetadata(metadata),
|
|
385
|
+
sessionStart: true,
|
|
386
|
+
},
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function hasSessionStartMarker(part) {
|
|
391
|
+
if (!part || part.type !== "text" || typeof part.text !== "string") {
|
|
392
|
+
return false
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
return getTrellisMetadata(part.metadata).sessionStart === true
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
export function hasInjectedTrellisContext(messages) {
|
|
399
|
+
if (!Array.isArray(messages)) {
|
|
400
|
+
return false
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return messages.some(message => {
|
|
404
|
+
if (!message?.info || message.info.role !== "user" || !Array.isArray(message.parts)) {
|
|
405
|
+
return false
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return message.parts.some(hasSessionStartMarker)
|
|
409
|
+
})
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
export async function hasPersistedInjectedContext(client, directory, sessionID) {
|
|
413
|
+
try {
|
|
414
|
+
const response = await client.session.messages({
|
|
415
|
+
path: { id: sessionID },
|
|
416
|
+
query: { directory },
|
|
417
|
+
throwOnError: true,
|
|
418
|
+
})
|
|
419
|
+
return hasInjectedTrellisContext(response.data || [])
|
|
420
|
+
} catch (error) {
|
|
421
|
+
debugLog(
|
|
422
|
+
"session",
|
|
423
|
+
"Failed to read session history for dedupe:",
|
|
424
|
+
error instanceof Error ? error.message : String(error),
|
|
425
|
+
)
|
|
426
|
+
return false
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export function markContextInjected(part) {
|
|
431
|
+
markPartAsSessionStart(part)
|
|
432
|
+
}
|