@mindfoldhq/trellis 0.6.0-beta.2 → 0.6.0-beta.21
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/README.md +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +58 -2
- package/dist/cli/index.js.map +1 -1
- 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 +2 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +97 -42
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/mem.d.ts +13 -117
- package/dist/commands/mem.d.ts.map +1 -1
- package/dist/commands/mem.js +168 -1074
- package/dist/commands/mem.js.map +1 -1
- package/dist/commands/uninstall.d.ts.map +1 -1
- package/dist/commands/uninstall.js +28 -2
- package/dist/commands/uninstall.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +31 -111
- package/dist/commands/update.js.map +1 -1
- 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/claude.d.ts.map +1 -1
- package/dist/configurators/claude.js +1 -0
- package/dist/configurators/claude.js.map +1 -1
- package/dist/configurators/codex.d.ts.map +1 -1
- package/dist/configurators/codex.js +5 -3
- package/dist/configurators/codex.js.map +1 -1
- package/dist/configurators/shared.js +4 -4
- package/dist/configurators/shared.js.map +1 -1
- package/dist/configurators/workflow.d.ts +8 -0
- package/dist/configurators/workflow.d.ts.map +1 -1
- package/dist/configurators/workflow.js +3 -2
- package/dist/configurators/workflow.js.map +1 -1
- 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.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.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 +13 -7
- package/dist/templates/claude/agents/trellis-implement.md +8 -7
- package/dist/templates/claude/settings.json +4 -4
- package/dist/templates/codebuddy/agents/trellis-check.md +13 -7
- package/dist/templates/codebuddy/agents/trellis-implement.md +8 -7
- package/dist/templates/codebuddy/settings.json +4 -4
- package/dist/templates/codex/agents/trellis-check.toml +4 -4
- package/dist/templates/codex/agents/trellis-implement.toml +4 -4
- package/dist/templates/codex/config.toml +9 -16
- package/dist/templates/codex/hooks/session-start.py +205 -119
- package/dist/templates/codex/hooks.json +2 -2
- package/dist/templates/codex/skills/before-dev/SKILL.md +12 -6
- package/dist/templates/codex/skills/brainstorm/SKILL.md +69 -457
- package/dist/templates/codex/skills/check/SKILL.md +86 -18
- package/dist/templates/codex/skills/start/SKILL.md +33 -323
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-context-loading.md +7 -4
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-spec-structure.md +1 -1
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-workflow.md +3 -2
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/context-injection.md +5 -5
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/spec-system.md +1 -1
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/task-system.md +35 -6
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/agents.md +5 -4
- 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 +6 -5
- package/dist/templates/common/commands/start.md +9 -6
- package/dist/templates/common/skills/before-dev.md +12 -6
- package/dist/templates/common/skills/brainstorm.md +68 -504
- package/dist/templates/common/skills/check.md +7 -1
- package/dist/templates/copilot/hooks/session-start.py +219 -101
- package/dist/templates/copilot/hooks.json +2 -2
- package/dist/templates/copilot/prompts/before-dev.prompt.md +12 -6
- package/dist/templates/copilot/prompts/brainstorm.prompt.md +69 -457
- package/dist/templates/copilot/prompts/check.prompt.md +86 -18
- package/dist/templates/copilot/prompts/parallel.prompt.md +16 -8
- package/dist/templates/copilot/prompts/start.prompt.md +33 -367
- package/dist/templates/cursor/agents/trellis-check.md +13 -7
- package/dist/templates/cursor/agents/trellis-implement.md +8 -7
- package/dist/templates/cursor/hooks.json +1 -7
- package/dist/templates/droid/droids/trellis-check.md +13 -7
- package/dist/templates/droid/droids/trellis-implement.md +8 -7
- package/dist/templates/droid/settings.json +4 -4
- package/dist/templates/gemini/agents/trellis-check.md +11 -5
- package/dist/templates/gemini/agents/trellis-implement.md +7 -6
- package/dist/templates/gemini/settings.json +2 -2
- package/dist/templates/kiro/agents/trellis-check.json +1 -1
- package/dist/templates/kiro/agents/trellis-implement.json +1 -1
- package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md.txt +127 -9
- package/dist/templates/markdown/spec/guides/cross-layer-thinking-guide.md.txt +171 -6
- package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +333 -43
- package/dist/templates/markdown/spec/guides/index.md.txt +18 -0
- package/dist/templates/opencode/agents/trellis-check.md +13 -7
- package/dist/templates/opencode/agents/trellis-implement.md +9 -8
- package/dist/templates/opencode/lib/session-utils.js +212 -123
- package/dist/templates/opencode/lib/trellis-context.js +73 -11
- package/dist/templates/opencode/plugins/inject-subagent-context.js +131 -29
- package/dist/templates/opencode/plugins/inject-workflow-state.js +9 -5
- package/dist/templates/opencode/plugins/session-start.js +9 -1
- package/dist/templates/pi/agents/trellis-check.md +5 -4
- package/dist/templates/pi/agents/trellis-implement.md +5 -4
- package/dist/templates/pi/extensions/trellis/index.ts.txt +1357 -754
- package/dist/templates/qoder/agents/trellis-check.md +11 -5
- package/dist/templates/qoder/agents/trellis-implement.md +7 -6
- package/dist/templates/qoder/settings.json +4 -4
- package/dist/templates/shared-hooks/index.d.ts.map +1 -1
- package/dist/templates/shared-hooks/index.js +0 -1
- package/dist/templates/shared-hooks/index.js.map +1 -1
- package/dist/templates/shared-hooks/inject-subagent-context.py +36 -14
- package/dist/templates/shared-hooks/inject-workflow-state.py +40 -42
- package/dist/templates/shared-hooks/session-start.py +222 -171
- package/dist/templates/trellis/config.yaml +38 -0
- package/dist/templates/trellis/index.d.ts +1 -0
- package/dist/templates/trellis/index.d.ts.map +1 -1
- package/dist/templates/trellis/index.js +2 -0
- package/dist/templates/trellis/index.js.map +1 -1
- package/dist/templates/trellis/scripts/add_session.py +50 -24
- package/dist/templates/trellis/scripts/common/config.py +57 -1
- package/dist/templates/trellis/scripts/common/safe_commit.py +285 -0
- package/dist/templates/trellis/scripts/common/session_context.py +384 -137
- package/dist/templates/trellis/scripts/common/task_context.py +3 -3
- package/dist/templates/trellis/scripts/common/task_store.py +161 -15
- package/dist/templates/trellis/scripts/common/workflow_phase.py +7 -10
- package/dist/templates/trellis/scripts/task.py +3 -3
- package/dist/templates/trellis/workflow.md +119 -98
- 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 +13 -0
- package/dist/utils/file-writer.d.ts.map +1 -1
- package/dist/utils/file-writer.js +59 -1
- package/dist/utils/file-writer.js.map +1 -1
- 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/task-json.d.ts +9 -42
- package/dist/utils/task-json.d.ts.map +1 -1
- package/dist/utils/task-json.js +8 -45
- package/dist/utils/task-json.js.map +1 -1
- package/dist/utils/template-hash.d.ts +32 -6
- package/dist/utils/template-hash.d.ts.map +1 -1
- package/dist/utils/template-hash.js +53 -31
- package/dist/utils/template-hash.js.map +1 -1
- package/dist/utils/uninstall-scrubbers.d.ts +1 -0
- package/dist/utils/uninstall-scrubbers.d.ts.map +1 -1
- package/dist/utils/uninstall-scrubbers.js +21 -0
- package/dist/utils/uninstall-scrubbers.js.map +1 -1
- 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 +9 -8
|
@@ -18,6 +18,28 @@ import warnings
|
|
|
18
18
|
from io import StringIO
|
|
19
19
|
from pathlib import Path
|
|
20
20
|
|
|
21
|
+
# Force UTF-8 on stdin/stdout/stderr on Windows. Default codepage there is
|
|
22
|
+
# cp936 / cp1252 / etc. — non-ASCII content (Chinese task names, prd snippets)
|
|
23
|
+
# both in stdin (hook payload from host CLI) and stdout (our emitted blocks)
|
|
24
|
+
# raises UnicodeDecodeError / UnicodeEncodeError. Equivalent to `python -X utf8`
|
|
25
|
+
# but applied per-stream so we don't depend on host CLI's command wiring.
|
|
26
|
+
if sys.platform.startswith("win"):
|
|
27
|
+
import io as _io
|
|
28
|
+
for _stream_name in ("stdin", "stdout", "stderr"):
|
|
29
|
+
_stream = getattr(sys, _stream_name, None)
|
|
30
|
+
if _stream is None:
|
|
31
|
+
continue
|
|
32
|
+
if hasattr(_stream, "reconfigure"):
|
|
33
|
+
try:
|
|
34
|
+
_stream.reconfigure(encoding="utf-8", errors="replace") # type: ignore[union-attr]
|
|
35
|
+
except Exception:
|
|
36
|
+
pass
|
|
37
|
+
elif hasattr(_stream, "detach"):
|
|
38
|
+
try:
|
|
39
|
+
setattr(sys, _stream_name, _io.TextIOWrapper(_stream.detach(), encoding="utf-8", errors="replace"))
|
|
40
|
+
except Exception:
|
|
41
|
+
pass
|
|
42
|
+
|
|
21
43
|
|
|
22
44
|
def _normalize_windows_shell_path(path_str: str) -> str:
|
|
23
45
|
"""Normalize Unix-style shell paths to real Windows paths.
|
|
@@ -75,23 +97,6 @@ Trellis SessionStart 已注入:workflow、当前任务状态、开发者身份
|
|
|
75
97
|
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.
|
|
76
98
|
</first-reply-notice>"""
|
|
77
99
|
|
|
78
|
-
SUB_AGENT_NOTICE = """<sub-agent-notice>
|
|
79
|
-
SUB-AGENT NOTICE - READ FIRST IF SPAWNED VIA spawn_agent
|
|
80
|
-
|
|
81
|
-
If your parent session spawned you via spawn_agent with an explicit task
|
|
82
|
-
message above this hook output, that message is your only job.
|
|
83
|
-
- Execute the parent message exactly as written, then return.
|
|
84
|
-
- Ignore all Trellis workflow guidance below this notice.
|
|
85
|
-
- Do NOT call task.py start, task.py add-context, or task.py archive.
|
|
86
|
-
- Do NOT call wait_agent or spawn_agent.
|
|
87
|
-
- Do NOT modify .trellis/tasks/* or any other file unless the parent message
|
|
88
|
-
explicitly asks for that.
|
|
89
|
-
|
|
90
|
-
If you are the main interactive Codex session and the user is typing at the
|
|
91
|
-
terminal with no parent agent, use the workflow guidance below normally.
|
|
92
|
-
</sub-agent-notice>"""
|
|
93
|
-
|
|
94
|
-
|
|
95
100
|
def should_skip_injection() -> bool:
|
|
96
101
|
if os.environ.get("TRELLIS_HOOKS") == "0":
|
|
97
102
|
return True
|
|
@@ -218,12 +223,19 @@ def _resolve_task_dir(trellis_dir: Path, task_ref: str) -> Path:
|
|
|
218
223
|
def _get_task_status(trellis_dir: Path, hook_input: dict) -> str:
|
|
219
224
|
active = _resolve_active_task(trellis_dir, hook_input)
|
|
220
225
|
if not active.task_path:
|
|
221
|
-
return
|
|
226
|
+
return (
|
|
227
|
+
"Status: NO ACTIVE TASK\n"
|
|
228
|
+
"Next: Classify the current turn and ask for task-creation consent "
|
|
229
|
+
"before creating any Trellis task."
|
|
230
|
+
)
|
|
222
231
|
|
|
223
232
|
task_ref = active.task_path
|
|
224
233
|
task_dir = _resolve_task_dir(trellis_dir, task_ref)
|
|
225
234
|
if active.stale or not task_dir.is_dir():
|
|
226
|
-
return
|
|
235
|
+
return (
|
|
236
|
+
f"Status: STALE POINTER\nTask: {task_ref}\n"
|
|
237
|
+
"Next: Task directory not found. Run: python3 ./.trellis/scripts/task.py finish"
|
|
238
|
+
)
|
|
227
239
|
|
|
228
240
|
task_json_path = task_dir / "task.json"
|
|
229
241
|
task_data: dict = {}
|
|
@@ -237,40 +249,170 @@ def _get_task_status(trellis_dir: Path, hook_input: dict) -> str:
|
|
|
237
249
|
task_status = task_data.get("status", "unknown")
|
|
238
250
|
|
|
239
251
|
if task_status == "completed":
|
|
240
|
-
return
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
if jsonl_path.is_file() and _has_curated_jsonl_entry(jsonl_path):
|
|
246
|
-
has_context = True
|
|
247
|
-
break
|
|
252
|
+
return (
|
|
253
|
+
f"Status: COMPLETED\nTask: {task_title}\n"
|
|
254
|
+
f"Next: Archive with `python3 ./.trellis/scripts/task.py archive {task_dir.name}` "
|
|
255
|
+
"or start a new task."
|
|
256
|
+
)
|
|
248
257
|
|
|
249
258
|
has_prd = (task_dir / "prd.md").is_file()
|
|
259
|
+
has_design = (task_dir / "design.md").is_file()
|
|
260
|
+
has_implement = (task_dir / "implement.md").is_file()
|
|
261
|
+
present = [
|
|
262
|
+
name
|
|
263
|
+
for name in ("prd.md", "design.md", "implement.md", "implement.jsonl", "check.jsonl")
|
|
264
|
+
if (task_dir / name).is_file()
|
|
265
|
+
]
|
|
266
|
+
present_line = ", ".join(present) if present else "none"
|
|
250
267
|
|
|
251
268
|
if not has_prd:
|
|
252
|
-
return
|
|
269
|
+
return (
|
|
270
|
+
f"Status: PLANNING\nTask: {task_title}\nPresent: {present_line}\n"
|
|
271
|
+
"Next: Load trellis-brainstorm and write prd.md. Stay in planning."
|
|
272
|
+
)
|
|
253
273
|
|
|
254
|
-
if
|
|
255
|
-
|
|
274
|
+
if task_status == "planning":
|
|
275
|
+
if has_design and has_implement:
|
|
276
|
+
next_action = "Review planning artifacts with the user before `task.py start`."
|
|
277
|
+
else:
|
|
278
|
+
next_action = (
|
|
279
|
+
"Lightweight task can ask for start review with PRD-only; "
|
|
280
|
+
"complex task must add design.md and implement.md before `task.py start`."
|
|
281
|
+
)
|
|
282
|
+
return (
|
|
283
|
+
f"Status: PLANNING\nTask: {task_title}\nPresent: {present_line}\n"
|
|
284
|
+
f"Next: {next_action}"
|
|
285
|
+
)
|
|
256
286
|
|
|
257
287
|
return (
|
|
258
|
-
f"Status:
|
|
259
|
-
|
|
260
|
-
"
|
|
261
|
-
"For agent-capable platforms, the default is to NOT edit code in the main session. "
|
|
262
|
-
"After implementation, dispatch `trellis-check` per Phase 2.2 before reporting completion.\n"
|
|
263
|
-
"Sub-agent self-exemption: if you are reading this as a `trellis-implement` or "
|
|
264
|
-
"`trellis-check` sub-agent (your own role / agent name reflects that), this dispatch "
|
|
265
|
-
"instruction does NOT apply to you — you are already the dispatched sub-agent. "
|
|
266
|
-
"Implement / check directly without spawning another sub-agent of the same kind.\n"
|
|
267
|
-
"User override (per-turn escape hatch): if the user's CURRENT message explicitly tells the "
|
|
268
|
-
"main session to handle it directly (\"你直接改\" / \"别派 sub-agent\" / \"main session 写就行\" / "
|
|
269
|
-
"\"do it inline\" / \"不用 sub-agent\"), honor it for this turn and edit code directly. "
|
|
270
|
-
"Per-turn only; do NOT invent an override the user did not say."
|
|
288
|
+
f"Status: {task_status.upper()}\nTask: {task_title}\nPresent: {present_line}\n"
|
|
289
|
+
"Next: Follow the matching per-turn workflow-state. Context order is jsonl entries, "
|
|
290
|
+
"prd.md, design.md if present, implement.md if present."
|
|
271
291
|
)
|
|
272
292
|
|
|
273
293
|
|
|
294
|
+
def _run_git(repo_root: Path, args: list[str]) -> str:
|
|
295
|
+
try:
|
|
296
|
+
result = subprocess.run(
|
|
297
|
+
["git", *args],
|
|
298
|
+
capture_output=True,
|
|
299
|
+
text=True,
|
|
300
|
+
encoding="utf-8",
|
|
301
|
+
errors="replace",
|
|
302
|
+
timeout=3,
|
|
303
|
+
cwd=str(repo_root),
|
|
304
|
+
)
|
|
305
|
+
except (subprocess.TimeoutExpired, FileNotFoundError, PermissionError):
|
|
306
|
+
return ""
|
|
307
|
+
if result.returncode != 0:
|
|
308
|
+
return ""
|
|
309
|
+
return result.stdout.strip()
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def _format_git_state(repo_root: Path) -> str:
|
|
313
|
+
branch = _run_git(repo_root, ["branch", "--show-current"]) or "(detached)"
|
|
314
|
+
dirty_lines = [
|
|
315
|
+
line for line in _run_git(repo_root, ["status", "--porcelain"]).splitlines()
|
|
316
|
+
if line.strip()
|
|
317
|
+
]
|
|
318
|
+
dirty_text = "clean" if not dirty_lines else f"dirty {len(dirty_lines)} paths"
|
|
319
|
+
return f"Git: branch {branch}; {dirty_text}."
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def _repo_relative(repo_root: Path, path: Path) -> str:
|
|
323
|
+
try:
|
|
324
|
+
return path.relative_to(repo_root).as_posix()
|
|
325
|
+
except ValueError:
|
|
326
|
+
return str(path)
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
def _collect_spec_index_paths(trellis_dir: Path) -> list[str]:
|
|
330
|
+
paths: list[str] = []
|
|
331
|
+
guides_index = trellis_dir / "spec" / "guides" / "index.md"
|
|
332
|
+
if guides_index.is_file():
|
|
333
|
+
paths.append(".trellis/spec/guides/index.md")
|
|
334
|
+
|
|
335
|
+
spec_dir = trellis_dir / "spec"
|
|
336
|
+
if not spec_dir.is_dir():
|
|
337
|
+
return paths
|
|
338
|
+
|
|
339
|
+
for sub in sorted(spec_dir.iterdir()):
|
|
340
|
+
if not sub.is_dir() or sub.name.startswith(".") or sub.name == "guides":
|
|
341
|
+
continue
|
|
342
|
+
index_file = sub / "index.md"
|
|
343
|
+
if index_file.is_file():
|
|
344
|
+
paths.append(f".trellis/spec/{sub.name}/index.md")
|
|
345
|
+
continue
|
|
346
|
+
for nested in sorted(sub.iterdir()):
|
|
347
|
+
if not nested.is_dir():
|
|
348
|
+
continue
|
|
349
|
+
nested_index = nested / "index.md"
|
|
350
|
+
if nested_index.is_file():
|
|
351
|
+
paths.append(f".trellis/spec/{sub.name}/{nested.name}/index.md")
|
|
352
|
+
|
|
353
|
+
return paths
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
def _build_compact_current_state(
|
|
357
|
+
trellis_dir: Path,
|
|
358
|
+
hook_input: dict,
|
|
359
|
+
spec_index_paths: list[str],
|
|
360
|
+
) -> str:
|
|
361
|
+
repo_root = trellis_dir.parent
|
|
362
|
+
lines: list[str] = []
|
|
363
|
+
|
|
364
|
+
try:
|
|
365
|
+
from common.paths import get_active_journal_file, get_developer, get_tasks_dir, count_lines # type: ignore[import-not-found]
|
|
366
|
+
from common.tasks import iter_active_tasks # type: ignore[import-not-found]
|
|
367
|
+
except Exception:
|
|
368
|
+
get_active_journal_file = None # type: ignore[assignment]
|
|
369
|
+
get_developer = None # type: ignore[assignment]
|
|
370
|
+
get_tasks_dir = None # type: ignore[assignment]
|
|
371
|
+
count_lines = None # type: ignore[assignment]
|
|
372
|
+
iter_active_tasks = None # type: ignore[assignment]
|
|
373
|
+
|
|
374
|
+
developer = get_developer(repo_root) if get_developer else None
|
|
375
|
+
lines.append(f"Developer: {developer or '(not initialized)'}")
|
|
376
|
+
lines.append(_format_git_state(repo_root))
|
|
377
|
+
|
|
378
|
+
active = _resolve_active_task(trellis_dir, hook_input)
|
|
379
|
+
if active.task_path:
|
|
380
|
+
task_dir = _resolve_task_dir(trellis_dir, active.task_path)
|
|
381
|
+
status = "unknown"
|
|
382
|
+
task_json = task_dir / "task.json"
|
|
383
|
+
if task_json.is_file():
|
|
384
|
+
try:
|
|
385
|
+
data = json.loads(task_json.read_text(encoding="utf-8"))
|
|
386
|
+
if isinstance(data, dict):
|
|
387
|
+
status = str(data.get("status") or "unknown")
|
|
388
|
+
except (json.JSONDecodeError, OSError):
|
|
389
|
+
pass
|
|
390
|
+
lines.append(f"Current task: {_repo_relative(repo_root, task_dir)}; status={status}.")
|
|
391
|
+
else:
|
|
392
|
+
lines.append("Current task: none.")
|
|
393
|
+
|
|
394
|
+
if get_tasks_dir and iter_active_tasks:
|
|
395
|
+
try:
|
|
396
|
+
task_count = sum(1 for _ in iter_active_tasks(get_tasks_dir(repo_root)))
|
|
397
|
+
lines.append(
|
|
398
|
+
f"Active tasks: {task_count} total. Use `python3 ./.trellis/scripts/task.py list --mine` only if needed."
|
|
399
|
+
)
|
|
400
|
+
except Exception:
|
|
401
|
+
pass
|
|
402
|
+
|
|
403
|
+
if get_active_journal_file and count_lines:
|
|
404
|
+
journal = get_active_journal_file(repo_root)
|
|
405
|
+
if journal:
|
|
406
|
+
lines.append(
|
|
407
|
+
f"Journal: {_repo_relative(repo_root, journal)}, {count_lines(journal)} / 2000 lines."
|
|
408
|
+
)
|
|
409
|
+
|
|
410
|
+
if spec_index_paths:
|
|
411
|
+
lines.append(f"Spec indexes: {len(spec_index_paths)} available.")
|
|
412
|
+
|
|
413
|
+
return "\n".join(lines)
|
|
414
|
+
|
|
415
|
+
|
|
274
416
|
def _extract_range(content: str, start_header: str, end_header: str) -> str:
|
|
275
417
|
"""Extract lines starting at `## start_header` up to (but excluding) `## end_header`."""
|
|
276
418
|
lines = content.splitlines()
|
|
@@ -298,33 +440,25 @@ _BREADCRUMB_TAG_RE = re.compile(
|
|
|
298
440
|
|
|
299
441
|
|
|
300
442
|
def _strip_breadcrumb_tag_blocks(content: str) -> str:
|
|
301
|
-
|
|
443
|
+
stripped = _BREADCRUMB_TAG_RE.sub("", content)
|
|
444
|
+
stripped = re.sub(r"<!--.*?-->", "", stripped, flags=re.DOTALL)
|
|
445
|
+
stripped = re.sub(r"^\[(?!/?workflow-state:)/?[^\]\n]+\]\s*\n?", "", stripped, flags=re.MULTILINE)
|
|
446
|
+
return re.sub(r"\n{3,}", "\n\n", stripped).strip()
|
|
302
447
|
|
|
303
448
|
|
|
304
449
|
def _build_workflow_toc(workflow_path: Path) -> str:
|
|
305
|
-
"""Inject
|
|
306
|
-
|
|
307
|
-
Since v0.5.0-rc.0 the [workflow-state:STATUS] breadcrumb tag blocks
|
|
308
|
-
live inside ## Phase Index. They're consumed by inject-workflow-state.py
|
|
309
|
-
on each UserPromptSubmit, so strip them from the session-start payload
|
|
310
|
-
to avoid duplicating context.
|
|
311
|
-
"""
|
|
450
|
+
"""Inject only the compact Phase Index summary for SessionStart."""
|
|
312
451
|
content = read_file(workflow_path)
|
|
313
452
|
if not content:
|
|
314
453
|
return "No workflow.md found"
|
|
315
454
|
|
|
316
455
|
out_lines = [
|
|
317
|
-
"# Development Workflow
|
|
318
|
-
"Full guide: .trellis/workflow.md
|
|
456
|
+
"# Development Workflow - Session Summary",
|
|
457
|
+
"Full guide: .trellis/workflow.md. Step detail: `python3 ./.trellis/scripts/get_context.py --mode phase --step <X.Y>`.",
|
|
319
458
|
"",
|
|
320
|
-
"## Table of Contents",
|
|
321
459
|
]
|
|
322
|
-
for line in content.splitlines():
|
|
323
|
-
if line.startswith("## "):
|
|
324
|
-
out_lines.append(line)
|
|
325
|
-
out_lines += ["", "---", ""]
|
|
326
460
|
|
|
327
|
-
phases = _extract_range(content, "Phase Index", "
|
|
461
|
+
phases = _extract_range(content, "Phase Index", "Phase 1: Plan")
|
|
328
462
|
if phases:
|
|
329
463
|
out_lines.append(_strip_breadcrumb_tag_blocks(phases).rstrip())
|
|
330
464
|
|
|
@@ -348,16 +482,12 @@ def main() -> None:
|
|
|
348
482
|
configure_project_encoding(project_dir)
|
|
349
483
|
|
|
350
484
|
trellis_dir = project_dir / ".trellis"
|
|
351
|
-
|
|
485
|
+
spec_index_paths = _collect_spec_index_paths(trellis_dir)
|
|
352
486
|
|
|
353
487
|
output = StringIO()
|
|
354
488
|
|
|
355
|
-
output.write(SUB_AGENT_NOTICE)
|
|
356
|
-
output.write("\n\n")
|
|
357
|
-
|
|
358
489
|
output.write("""<session-context>
|
|
359
|
-
|
|
360
|
-
Read and follow all instructions below carefully.
|
|
490
|
+
Trellis compact SessionStart context. Use it to orient the session; load details on demand.
|
|
361
491
|
</session-context>
|
|
362
492
|
|
|
363
493
|
""")
|
|
@@ -365,65 +495,23 @@ Read and follow all instructions below carefully.
|
|
|
365
495
|
output.write("\n\n")
|
|
366
496
|
|
|
367
497
|
output.write("<current-state>\n")
|
|
368
|
-
|
|
369
|
-
output.write(run_script(context_script, context_key))
|
|
498
|
+
output.write(_build_compact_current_state(trellis_dir, hook_input, spec_index_paths))
|
|
370
499
|
output.write("\n</current-state>\n\n")
|
|
371
500
|
|
|
372
|
-
output.write("<workflow>\n")
|
|
501
|
+
output.write("<trellis-workflow>\n")
|
|
373
502
|
output.write(_build_workflow_toc(trellis_dir / "workflow.md"))
|
|
374
|
-
output.write("\n</workflow>\n\n")
|
|
503
|
+
output.write("\n</trellis-workflow>\n\n")
|
|
375
504
|
|
|
376
505
|
output.write("<guidelines>\n")
|
|
377
506
|
output.write(
|
|
378
|
-
"
|
|
379
|
-
"
|
|
380
|
-
"
|
|
381
|
-
"- If you're spawning an implement/check sub-agent, context is injected "
|
|
382
|
-
"automatically via `{task}/implement.jsonl` / `check.jsonl`. You do NOT "
|
|
383
|
-
"need to read these indexes yourself.\n"
|
|
384
|
-
"- For agent-capable platforms, the default is to dispatch "
|
|
385
|
-
"`trellis-implement` and `trellis-check` (so JSONL context is loaded by "
|
|
386
|
-
"the sub-agents) rather than editing code in the main session. "
|
|
387
|
-
"Honor a per-turn user override only if the user's current message "
|
|
388
|
-
"explicitly opts out (see <task-status> below for override phrases).\n"
|
|
389
|
-
"- Sub-agent self-exemption: if you are reading this as a `trellis-implement` "
|
|
390
|
-
"or `trellis-check` sub-agent, the \"dispatch trellis-implement / trellis-check\" "
|
|
391
|
-
"rule above does NOT apply to you — you are already the dispatched sub-agent. "
|
|
392
|
-
"Do NOT spawn another sub-agent of the same kind; implement / check directly.\n\n"
|
|
507
|
+
"Task context order for implementation/check: jsonl entries -> `prd.md` -> "
|
|
508
|
+
"`design.md if present` -> `implement.md if present`. Missing optional artifacts "
|
|
509
|
+
"are skipped for lightweight tasks.\n\n"
|
|
393
510
|
)
|
|
394
511
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
output.write("## guides (inlined — cross-package thinking guides)\n")
|
|
399
|
-
output.write(read_file(guides_index))
|
|
400
|
-
output.write("\n\n")
|
|
401
|
-
|
|
402
|
-
# Other indexes — paths only
|
|
403
|
-
paths: list[str] = []
|
|
404
|
-
spec_dir = trellis_dir / "spec"
|
|
405
|
-
if spec_dir.is_dir():
|
|
406
|
-
for sub in sorted(spec_dir.iterdir()):
|
|
407
|
-
if not sub.is_dir() or sub.name.startswith("."):
|
|
408
|
-
continue
|
|
409
|
-
if sub.name == "guides":
|
|
410
|
-
continue
|
|
411
|
-
index_file = sub / "index.md"
|
|
412
|
-
if index_file.is_file():
|
|
413
|
-
paths.append(f".trellis/spec/{sub.name}/index.md")
|
|
414
|
-
else:
|
|
415
|
-
for nested in sorted(sub.iterdir()):
|
|
416
|
-
if not nested.is_dir():
|
|
417
|
-
continue
|
|
418
|
-
nested_index = nested / "index.md"
|
|
419
|
-
if nested_index.is_file():
|
|
420
|
-
paths.append(
|
|
421
|
-
f".trellis/spec/{sub.name}/{nested.name}/index.md"
|
|
422
|
-
)
|
|
423
|
-
|
|
424
|
-
if paths:
|
|
425
|
-
output.write("## Available spec indexes (read on demand)\n")
|
|
426
|
-
for p in paths:
|
|
512
|
+
if spec_index_paths:
|
|
513
|
+
output.write("## Available indexes (read on demand)\n")
|
|
514
|
+
for p in spec_index_paths:
|
|
427
515
|
output.write(f"- {p}\n")
|
|
428
516
|
output.write("\n")
|
|
429
517
|
|
|
@@ -437,9 +525,7 @@ Read and follow all instructions below carefully.
|
|
|
437
525
|
output.write(f"<task-status>\n{task_status}\n</task-status>\n\n")
|
|
438
526
|
|
|
439
527
|
output.write("""<ready>
|
|
440
|
-
Context loaded.
|
|
441
|
-
When the user sends the first message, follow <task-status> and the workflow guide.
|
|
442
|
-
If a task is READY, execute its Next required action without asking whether to continue.
|
|
528
|
+
Context loaded. Follow <task-status>. Load workflow/spec/task details only when needed.
|
|
443
529
|
</ready>""")
|
|
444
530
|
|
|
445
531
|
context = output.getvalue()
|
|
@@ -7,28 +7,34 @@ Read the relevant development guidelines before starting your task.
|
|
|
7
7
|
|
|
8
8
|
Execute these steps:
|
|
9
9
|
|
|
10
|
-
1. **
|
|
10
|
+
1. **Read current task artifacts**:
|
|
11
|
+
- `prd.md` for requirements and acceptance criteria
|
|
12
|
+
- `design.md` if present for technical design
|
|
13
|
+
- `implement.md` if present for execution order and validation plan
|
|
14
|
+
|
|
15
|
+
2. **Discover packages and their spec layers**:
|
|
11
16
|
```bash
|
|
12
17
|
python3 ./.trellis/scripts/get_context.py --mode packages
|
|
13
18
|
```
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
3. **Identify which specs apply** to your task based on:
|
|
16
21
|
- Which package you're modifying (e.g., `cli/`, `docs-site/`)
|
|
17
22
|
- What type of work (backend, frontend, unit-test, docs, etc.)
|
|
23
|
+
- Any spec/research paths referenced by the task artifacts
|
|
18
24
|
|
|
19
|
-
|
|
25
|
+
4. **Read the spec index** for each relevant module:
|
|
20
26
|
```bash
|
|
21
27
|
cat .trellis/spec/<package>/<layer>/index.md
|
|
22
28
|
```
|
|
23
29
|
Follow the **"Pre-Development Checklist"** section in the index.
|
|
24
30
|
|
|
25
|
-
|
|
31
|
+
5. **Read the specific guideline files** listed in the Pre-Development Checklist that are relevant to your task. The index is NOT the goal — it points you to the actual guideline files (e.g., `error-handling.md`, `conventions.md`, `mock-strategies.md`). Read those files to understand the coding standards and patterns.
|
|
26
32
|
|
|
27
|
-
|
|
33
|
+
6. **Always read shared guides**:
|
|
28
34
|
```bash
|
|
29
35
|
cat .trellis/spec/guides/index.md
|
|
30
36
|
```
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
7. Understand the coding standards and patterns you need to follow, then proceed with your development plan.
|
|
33
39
|
|
|
34
40
|
This step is **mandatory** before writing any code.
|