@mindfoldhq/trellis 0.4.0-beta.1 → 0.4.0-beta.10

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.
Files changed (200) hide show
  1. package/README.md +19 -5
  2. package/dist/cli/index.js +3 -0
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/commands/init.d.ts +3 -0
  5. package/dist/commands/init.d.ts.map +1 -1
  6. package/dist/commands/init.js +48 -23
  7. package/dist/commands/init.js.map +1 -1
  8. package/dist/commands/update.d.ts.map +1 -1
  9. package/dist/commands/update.js +52 -41
  10. package/dist/commands/update.js.map +1 -1
  11. package/dist/configurators/codebuddy.d.ts +11 -0
  12. package/dist/configurators/codebuddy.d.ts.map +1 -0
  13. package/dist/configurators/codebuddy.js +58 -0
  14. package/dist/configurators/codebuddy.js.map +1 -0
  15. package/dist/configurators/codex.d.ts +7 -4
  16. package/dist/configurators/codex.d.ts.map +1 -1
  17. package/dist/configurators/codex.js +40 -10
  18. package/dist/configurators/codex.js.map +1 -1
  19. package/dist/configurators/copilot.d.ts +9 -0
  20. package/dist/configurators/copilot.d.ts.map +1 -0
  21. package/dist/configurators/copilot.js +34 -0
  22. package/dist/configurators/copilot.js.map +1 -0
  23. package/dist/configurators/index.d.ts +11 -1
  24. package/dist/configurators/index.d.ts.map +1 -1
  25. package/dist/configurators/index.js +72 -4
  26. package/dist/configurators/index.js.map +1 -1
  27. package/dist/configurators/opencode.d.ts +1 -1
  28. package/dist/configurators/opencode.js +1 -1
  29. package/dist/configurators/windsurf.d.ts +8 -0
  30. package/dist/configurators/windsurf.d.ts.map +1 -0
  31. package/dist/configurators/windsurf.js +18 -0
  32. package/dist/configurators/windsurf.js.map +1 -0
  33. package/dist/configurators/workflow.d.ts +1 -1
  34. package/dist/configurators/workflow.d.ts.map +1 -1
  35. package/dist/configurators/workflow.js +4 -2
  36. package/dist/configurators/workflow.js.map +1 -1
  37. package/dist/migrations/manifests/0.3.10.json +9 -0
  38. package/dist/migrations/manifests/0.4.0-beta.10.json +9 -0
  39. package/dist/migrations/manifests/0.4.0-beta.2.json +9 -0
  40. package/dist/migrations/manifests/0.4.0-beta.3.json +9 -0
  41. package/dist/migrations/manifests/0.4.0-beta.4.json +9 -0
  42. package/dist/migrations/manifests/0.4.0-beta.5.json +9 -0
  43. package/dist/migrations/manifests/0.4.0-beta.6.json +9 -0
  44. package/dist/migrations/manifests/0.4.0-beta.7.json +9 -0
  45. package/dist/migrations/manifests/0.4.0-beta.8.json +34 -0
  46. package/dist/migrations/manifests/0.4.0-beta.9.json +9 -0
  47. package/dist/templates/claude/commands/trellis/record-session.md +3 -2
  48. package/dist/templates/claude/hooks/inject-subagent-context.py +8 -1
  49. package/dist/templates/claude/hooks/ralph-loop.py +18 -10
  50. package/dist/templates/claude/hooks/session-start.py +33 -9
  51. package/dist/templates/claude/hooks/statusline.py +211 -0
  52. package/dist/templates/claude/settings.json +4 -0
  53. package/dist/templates/codebuddy/commands/trellis/before-dev.md +29 -0
  54. package/dist/templates/codebuddy/commands/trellis/brainstorm.md +487 -0
  55. package/dist/templates/codebuddy/commands/trellis/break-loop.md +107 -0
  56. package/dist/templates/codebuddy/commands/trellis/check-cross-layer.md +153 -0
  57. package/dist/templates/codebuddy/commands/trellis/check.md +25 -0
  58. package/dist/templates/codebuddy/commands/trellis/create-command.md +154 -0
  59. package/dist/templates/codebuddy/commands/trellis/finish-work.md +143 -0
  60. package/dist/templates/codebuddy/commands/trellis/integrate-skill.md +219 -0
  61. package/dist/templates/codebuddy/commands/trellis/onboard.md +358 -0
  62. package/dist/templates/codebuddy/commands/trellis/record-session.md +61 -0
  63. package/dist/templates/codebuddy/commands/trellis/start.md +373 -0
  64. package/dist/templates/codebuddy/commands/trellis/update-spec.md +354 -0
  65. package/dist/templates/codebuddy/index.d.ts +25 -0
  66. package/dist/templates/codebuddy/index.d.ts.map +1 -0
  67. package/dist/templates/codebuddy/index.js +45 -0
  68. package/dist/templates/codebuddy/index.js.map +1 -0
  69. package/dist/templates/codex/agents/check.toml +23 -0
  70. package/dist/templates/codex/agents/implement.toml +19 -0
  71. package/dist/templates/codex/agents/research.toml +26 -0
  72. package/dist/templates/codex/codex-skills/parallel/SKILL.md +194 -0
  73. package/dist/templates/codex/config.toml +5 -0
  74. package/dist/templates/codex/hooks/session-start.py +228 -0
  75. package/dist/templates/codex/hooks.json +16 -0
  76. package/dist/templates/codex/index.d.ts +27 -5
  77. package/dist/templates/codex/index.d.ts.map +1 -1
  78. package/dist/templates/codex/index.js +60 -8
  79. package/dist/templates/codex/index.js.map +1 -1
  80. package/dist/templates/codex/skills/before-dev/SKILL.md +1 -1
  81. package/dist/templates/codex/skills/brainstorm/SKILL.md +1 -1
  82. package/dist/templates/codex/skills/break-loop/SKILL.md +1 -1
  83. package/dist/templates/codex/skills/check/SKILL.md +1 -1
  84. package/dist/templates/codex/skills/check-cross-layer/SKILL.md +1 -1
  85. package/dist/templates/codex/skills/create-command/SKILL.md +1 -1
  86. package/dist/templates/codex/skills/finish-work/SKILL.md +1 -1
  87. package/dist/templates/codex/skills/improve-ut/SKILL.md +69 -0
  88. package/dist/templates/codex/skills/integrate-skill/SKILL.md +1 -1
  89. package/dist/templates/codex/skills/onboard/SKILL.md +1 -1
  90. package/dist/templates/codex/skills/record-session/SKILL.md +4 -3
  91. package/dist/templates/codex/skills/start/SKILL.md +1 -1
  92. package/dist/templates/codex/skills/update-spec/SKILL.md +1 -1
  93. package/dist/templates/copilot/hooks/session-start.py +218 -0
  94. package/dist/templates/copilot/hooks.json +11 -0
  95. package/dist/templates/copilot/index.d.ts +23 -0
  96. package/dist/templates/copilot/index.d.ts.map +1 -0
  97. package/dist/templates/copilot/index.js +54 -0
  98. package/dist/templates/copilot/index.js.map +1 -0
  99. package/dist/templates/copilot/prompts/before-dev.prompt.md +33 -0
  100. package/dist/templates/copilot/prompts/brainstorm.prompt.md +491 -0
  101. package/dist/templates/copilot/prompts/break-loop.prompt.md +129 -0
  102. package/dist/templates/copilot/prompts/check-cross-layer.prompt.md +157 -0
  103. package/dist/templates/copilot/prompts/check.prompt.md +29 -0
  104. package/dist/templates/copilot/prompts/create-command.prompt.md +116 -0
  105. package/dist/templates/copilot/prompts/finish-work.prompt.md +157 -0
  106. package/dist/templates/copilot/prompts/integrate-skill.prompt.md +223 -0
  107. package/dist/templates/copilot/prompts/onboard.prompt.md +362 -0
  108. package/dist/templates/copilot/prompts/parallel.prompt.md +196 -0
  109. package/dist/templates/copilot/prompts/record-session.prompt.md +66 -0
  110. package/dist/templates/copilot/prompts/start.prompt.md +397 -0
  111. package/dist/templates/copilot/prompts/update-spec.prompt.md +358 -0
  112. package/dist/templates/cursor/commands/trellis-record-session.md +3 -2
  113. package/dist/templates/extract.d.ts +36 -0
  114. package/dist/templates/extract.d.ts.map +1 -1
  115. package/dist/templates/extract.js +64 -0
  116. package/dist/templates/extract.js.map +1 -1
  117. package/dist/templates/gemini/commands/trellis/record-session.toml +3 -2
  118. package/dist/templates/iflow/commands/trellis/record-session.md +3 -2
  119. package/dist/templates/iflow/hooks/inject-subagent-context.py +8 -1
  120. package/dist/templates/iflow/hooks/ralph-loop.py +8 -1
  121. package/dist/templates/iflow/hooks/session-start.py +33 -9
  122. package/dist/templates/kilo/workflows/record-session.md +3 -2
  123. package/dist/templates/kiro/skills/before-dev/SKILL.md +1 -1
  124. package/dist/templates/kiro/skills/brainstorm/SKILL.md +1 -1
  125. package/dist/templates/kiro/skills/break-loop/SKILL.md +1 -1
  126. package/dist/templates/kiro/skills/check/SKILL.md +1 -1
  127. package/dist/templates/kiro/skills/check-cross-layer/SKILL.md +1 -1
  128. package/dist/templates/kiro/skills/create-command/SKILL.md +1 -1
  129. package/dist/templates/kiro/skills/finish-work/SKILL.md +1 -1
  130. package/dist/templates/kiro/skills/integrate-skill/SKILL.md +1 -1
  131. package/dist/templates/kiro/skills/onboard/SKILL.md +1 -1
  132. package/dist/templates/kiro/skills/record-session/SKILL.md +4 -3
  133. package/dist/templates/kiro/skills/start/SKILL.md +1 -1
  134. package/dist/templates/kiro/skills/update-spec/SKILL.md +1 -1
  135. package/dist/templates/markdown/agents.md +4 -0
  136. package/dist/templates/markdown/spec/backend/directory-structure.md +1 -1
  137. package/dist/templates/markdown/workspace-index.md +2 -0
  138. package/dist/templates/opencode/agents/dispatch.md +20 -19
  139. package/dist/templates/opencode/commands/trellis/record-session.md +3 -2
  140. package/dist/templates/opencode/lib/trellis-context.js +42 -2
  141. package/dist/templates/opencode/{plugin → plugins}/session-start.js +7 -27
  142. package/dist/templates/qoder/skills/before-dev/SKILL.md +1 -1
  143. package/dist/templates/qoder/skills/brainstorm/SKILL.md +1 -1
  144. package/dist/templates/qoder/skills/break-loop/SKILL.md +1 -1
  145. package/dist/templates/qoder/skills/check/SKILL.md +1 -1
  146. package/dist/templates/qoder/skills/check-cross-layer/SKILL.md +1 -1
  147. package/dist/templates/qoder/skills/create-command/SKILL.md +1 -1
  148. package/dist/templates/qoder/skills/finish-work/SKILL.md +1 -1
  149. package/dist/templates/qoder/skills/integrate-skill/SKILL.md +1 -1
  150. package/dist/templates/qoder/skills/onboard/SKILL.md +1 -1
  151. package/dist/templates/qoder/skills/record-session/SKILL.md +4 -3
  152. package/dist/templates/qoder/skills/start/SKILL.md +1 -1
  153. package/dist/templates/qoder/skills/update-spec/SKILL.md +1 -1
  154. package/dist/templates/trellis/scripts/add_session.py +69 -16
  155. package/dist/templates/trellis/scripts/common/__init__.py +2 -0
  156. package/dist/templates/trellis/scripts/common/cli_adapter.py +133 -21
  157. package/dist/templates/trellis/scripts/common/config.py +40 -0
  158. package/dist/templates/trellis/scripts/common/developer.py +2 -2
  159. package/dist/templates/trellis/scripts/common/packages_context.py +9 -4
  160. package/dist/templates/trellis/scripts/common/paths.py +57 -6
  161. package/dist/templates/trellis/scripts/common/session_context.py +98 -2
  162. package/dist/templates/trellis/scripts/common/task_context.py +27 -1
  163. package/dist/templates/trellis/scripts/common/task_store.py +6 -4
  164. package/dist/templates/trellis/scripts/common/task_utils.py +14 -8
  165. package/dist/templates/trellis/scripts/create_bootstrap.py +1 -1
  166. package/dist/templates/trellis/scripts/multi_agent/plan.py +7 -6
  167. package/dist/templates/trellis/scripts/multi_agent/start.py +16 -11
  168. package/dist/templates/trellis/scripts/task.py +1 -1
  169. package/dist/templates/trellis/scripts-shell-archive/create-bootstrap.sh +1 -1
  170. package/dist/templates/trellis/workflow.md +17 -4
  171. package/dist/templates/windsurf/index.d.ts +21 -0
  172. package/dist/templates/windsurf/index.d.ts.map +1 -0
  173. package/dist/templates/windsurf/index.js +44 -0
  174. package/dist/templates/windsurf/index.js.map +1 -0
  175. package/dist/templates/windsurf/workflows/trellis-before-dev.md +31 -0
  176. package/dist/templates/windsurf/workflows/trellis-brainstorm.md +491 -0
  177. package/dist/templates/windsurf/workflows/trellis-break-loop.md +111 -0
  178. package/dist/templates/windsurf/workflows/trellis-check-cross-layer.md +157 -0
  179. package/dist/templates/windsurf/workflows/trellis-check.md +27 -0
  180. package/dist/templates/windsurf/workflows/trellis-create-command.md +154 -0
  181. package/dist/templates/windsurf/workflows/trellis-finish-work.md +147 -0
  182. package/dist/templates/windsurf/workflows/trellis-integrate-skill.md +220 -0
  183. package/dist/templates/windsurf/workflows/trellis-onboard.md +362 -0
  184. package/dist/templates/windsurf/workflows/trellis-record-session.md +66 -0
  185. package/dist/templates/windsurf/workflows/trellis-start.md +373 -0
  186. package/dist/templates/windsurf/workflows/trellis-update-spec.md +358 -0
  187. package/dist/types/ai-tools.d.ts +15 -3
  188. package/dist/types/ai-tools.d.ts.map +1 -1
  189. package/dist/types/ai-tools.js +42 -2
  190. package/dist/types/ai-tools.js.map +1 -1
  191. package/dist/utils/project-detector.d.ts +5 -0
  192. package/dist/utils/project-detector.d.ts.map +1 -1
  193. package/dist/utils/project-detector.js +7 -0
  194. package/dist/utils/project-detector.js.map +1 -1
  195. package/dist/utils/template-fetcher.d.ts +24 -3
  196. package/dist/utils/template-fetcher.d.ts.map +1 -1
  197. package/dist/utils/template-fetcher.js +129 -16
  198. package/dist/utils/template-fetcher.js.map +1 -1
  199. package/package.json +1 -1
  200. /package/dist/templates/opencode/{plugin → plugins}/inject-subagent-context.js +0 -0
@@ -66,23 +66,47 @@ def run_script(script_path: Path) -> str:
66
66
  return "No context available"
67
67
 
68
68
 
69
+ def _normalize_task_ref(task_ref: str) -> str:
70
+ normalized = task_ref.strip()
71
+ if not normalized:
72
+ return ""
73
+
74
+ path_obj = Path(normalized)
75
+ if path_obj.is_absolute():
76
+ return str(path_obj)
77
+
78
+ normalized = normalized.replace("\\", "/")
79
+ while normalized.startswith("./"):
80
+ normalized = normalized[2:]
81
+
82
+ if normalized.startswith("tasks/"):
83
+ return f".trellis/{normalized}"
84
+
85
+ return normalized
86
+
87
+
88
+ def _resolve_task_dir(trellis_dir: Path, task_ref: str) -> Path:
89
+ normalized = _normalize_task_ref(task_ref)
90
+ path_obj = Path(normalized)
91
+ if path_obj.is_absolute():
92
+ return path_obj
93
+ if normalized.startswith(".trellis/"):
94
+ return trellis_dir.parent / path_obj
95
+ return trellis_dir / "tasks" / path_obj
96
+
97
+
69
98
  def _get_task_status(trellis_dir: Path) -> str:
70
99
  """Check current task status and return structured status string."""
71
100
  current_task_file = trellis_dir / ".current-task"
72
101
  if not current_task_file.is_file():
73
102
  return "Status: NO ACTIVE TASK\nNext: Describe what you want to work on"
74
103
 
75
- task_ref = current_task_file.read_text(encoding="utf-8").strip()
104
+ task_ref = _normalize_task_ref(current_task_file.read_text(encoding="utf-8").strip())
76
105
  if not task_ref:
77
106
  return "Status: NO ACTIVE TASK\nNext: Describe what you want to work on"
78
107
 
79
108
  # Resolve task directory
80
- if Path(task_ref).is_absolute():
81
- task_dir = Path(task_ref)
82
- elif task_ref.startswith(".trellis/"):
83
- task_dir = trellis_dir.parent / task_ref
84
- else:
85
- task_dir = trellis_dir / "tasks" / task_ref
109
+ task_dir = _resolve_task_dir(trellis_dir, task_ref)
86
110
  if not task_dir.is_dir():
87
111
  return f"Status: STALE POINTER\nTask: {task_ref}\nNext: Task directory not found. Run: python3 ./.trellis/scripts/task.py finish"
88
112
 
@@ -131,8 +155,8 @@ def _load_trellis_config(trellis_dir: Path) -> tuple:
131
155
  sys.path.insert(0, str(scripts_dir))
132
156
 
133
157
  try:
134
- from common.config import get_default_package, get_packages, get_spec_scope, is_monorepo
135
- from common.paths import get_current_task
158
+ from common.config import get_default_package, get_packages, get_spec_scope, is_monorepo # type: ignore[import-not-found]
159
+ from common.paths import get_current_task # type: ignore[import-not-found]
136
160
 
137
161
  repo_root = trellis_dir.parent
138
162
  is_mono = is_monorepo(repo_root)
@@ -1,6 +1,6 @@
1
1
  [!] **Prerequisite**: This command should only be used AFTER the human has tested and committed the code.
2
2
 
3
- **AI must NOT execute git commit** - only read history (`git log`, `git status`, `git diff`).
3
+ **Do NOT run `git commit` directly** the scripts below handle their own commits for `.trellis/` metadata. You only need to read git history (`git log`, `git status`, `git diff`) and run the Python scripts.
4
4
 
5
5
  ---
6
6
 
@@ -46,6 +46,7 @@ EOF
46
46
  **Auto-completes**:
47
47
  - [OK] Appends session to journal-N.md
48
48
  - [OK] Auto-detects line count, creates new file if >2000 lines
49
+ - [OK] Auto-detects Branch context (`--branch` override; otherwise Branch = task.json -> current git branch; missing values are omitted gracefully)
49
50
  - [OK] Updates index.md (Total Sessions +1, Last Active, line stats, history)
50
51
  - [OK] Auto-commits .trellis/workspace and .trellis/tasks changes
51
52
 
@@ -56,6 +57,6 @@ EOF
56
57
  | Command | Purpose |
57
58
  |---------|---------|
58
59
  | `python3 ./.trellis/scripts/get_context.py --mode record` | Get context for record-session |
59
- | `python3 ./.trellis/scripts/add_session.py --title "..." --commit "..."` | **One-click add session (recommended)** |
60
+ | `python3 ./.trellis/scripts/add_session.py --title "..." --commit "..."` | **One-click add session (recommended, branch auto-complete)** |
60
61
  | `python3 ./.trellis/scripts/task.py archive <name>` | Archive completed task (auto-commits) |
61
62
  | `python3 ./.trellis/scripts/task.py list` | List active tasks |
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: before-dev
3
- description: "Read the relevant development guidelines before starting your task."
3
+ description: "Discovers and injects project-specific coding guidelines from .trellis/spec/ before implementation begins. Reads spec indexes, pre-development checklists, and shared thinking guides for the target package. Use when starting a new coding task, before writing any code, switching to a different package, or needing to refresh project conventions and standards."
4
4
  ---
5
5
 
6
6
  Read the relevant development guidelines before starting your task.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: brainstorm
3
- description: "Brainstorm - Requirements Discovery (AI Coding Enhanced)"
3
+ description: "Collaborative requirements discovery session optimized for AI coding workflows. Creates task directories, seeds PRDs, runs codebase research, proposes concrete implementation approaches with trade-offs, and converges on MVP scope through structured Q&A. Use when requirements are unclear, multiple implementation paths exist, trade-offs need evaluation, or a complex feature needs scoping before development."
4
4
  ---
5
5
 
6
6
  # Brainstorm - Requirements Discovery (AI Coding Enhanced)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: break-loop
3
- description: "Break the Loop - Deep Bug Analysis"
3
+ description: "Deep post-fix bug analysis across five dimensions: root cause categorization, fix failure analysis, prevention mechanisms, systematic expansion, and knowledge capture. Updates .trellis/spec/ guides with lessons learned to prevent recurring bugs. Use when a debugging session completes, after fixing a tricky bug, when the same class of bug keeps recurring, or when you want to capture debugging insights into project documentation."
4
4
  ---
5
5
 
6
6
  # Break the Loop - Deep Bug Analysis
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: check
3
- description: "Check if the code you just wrote follows the development guidelines."
3
+ description: "Validates recently written code against project-specific development guidelines from .trellis/spec/. Identifies changed files via git diff, discovers applicable spec modules, runs lint and typecheck, and reports guideline violations. Use when code is written and needs quality verification, to catch context drift during long sessions, or before committing changes."
4
4
  ---
5
5
 
6
6
  Check if the code you just wrote follows the development guidelines.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: check-cross-layer
3
- description: "Cross-Layer Check"
3
+ description: "Post-implementation verification across multiple code dimensions: cross-layer data flow, code reuse analysis, import path validation, and same-layer consistency checks. Identifies missed update sites, type mismatches, and duplicated constants. Use when changes span 3+ architectural layers, after modifying shared constants or configs, after batch file modifications, or when creating new utility functions."
4
4
  ---
5
5
 
6
6
  # Cross-Layer Check
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: create-command
3
- description: "Create New Skill"
3
+ description: "Scaffolds a new skill file with proper naming conventions and structure. Analyzes requirements to determine skill type and generates appropriate content. Use when adding a new developer workflow skill, creating a custom skill, or extending the Trellis skill set."
4
4
  ---
5
5
 
6
6
  # Create New Skill
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: finish-work
3
- description: "Finish Work - Pre-Commit Checklist"
3
+ description: "Pre-commit quality checklist covering lint, typecheck, tests, code-spec sync, API changes, database migrations, cross-layer verification, and manual testing. Blocks commit if infra or cross-layer specs lack executable depth. Use when code is written and tested but not yet committed, before submitting changes, or as a final review before git commit."
4
4
  ---
5
5
 
6
6
  # Finish Work - Pre-Commit Checklist
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: integrate-skill
3
- description: "Integrate Skill into Project Guidelines"
3
+ description: "Adapts an external skill into project-specific development guidelines in .trellis/spec/. Creates guideline sections, code example templates with .template suffix, and updates spec indexes. Use when integrating an external skill, adding a new skill's patterns to project conventions, or incorporating third-party skill best practices into .trellis/spec/ documentation."
4
4
  ---
5
5
 
6
6
  # Integrate Skill into Project Guidelines
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: onboard
3
- description: "PART 3: Customize Your Development Guidelines"
3
+ description: "Interactive three-part onboarding for new team members to the Trellis AI-assisted workflow system. Covers core philosophy (AI memory, project-specific knowledge, context drift), system structure and command deep-dives, real-world workflow examples, and guideline customization. Use when a new developer joins the project, someone needs to understand the Trellis workflow, or project guidelines need initial setup."
4
4
  ---
5
5
 
6
6
  You are a senior developer onboarding a new team member to this project's AI-assisted workflow system.
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: record-session
3
- description: "Record work progress after human has tested and committed code"
3
+ description: "Records completed work progress to .trellis/workspace/ journal files after human testing and commit. Captures session summaries, commit hashes, and updates developer index files for future session context. Use when a coding session is complete, after the human has committed code, or to persist session knowledge for future AI sessions."
4
4
  ---
5
5
 
6
6
  [!] **Prerequisite**: This skill should only be used AFTER the human has tested and committed the code.
7
7
 
8
- **AI must NOT execute git commit** - only read history (`git log`, `git status`, `git diff`).
8
+ **Do NOT run `git commit` directly** the scripts below handle their own commits for `.trellis/` metadata. You only need to read git history (`git log`, `git status`, `git diff`) and run the Python scripts.
9
9
 
10
10
  ---
11
11
 
@@ -51,6 +51,7 @@ EOF
51
51
  **Auto-completes**:
52
52
  - [OK] Appends session to journal-N.md
53
53
  - [OK] Auto-detects line count, creates new file if >2000 lines
54
+ - [OK] Auto-detects Branch context (`--branch` override; otherwise Branch = task.json -> current git branch; missing values are omitted gracefully)
54
55
  - [OK] Updates index.md (Total Sessions +1, Last Active, line stats, history)
55
56
  - [OK] Auto-commits .trellis/workspace and .trellis/tasks changes
56
57
 
@@ -61,6 +62,6 @@ EOF
61
62
  | Command | Purpose |
62
63
  |---------|---------|
63
64
  | `python3 ./.trellis/scripts/get_context.py --mode record` | Get context for record-session |
64
- | `python3 ./.trellis/scripts/add_session.py --title "..." --commit "..."` | **One-click add session (recommended)** |
65
+ | `python3 ./.trellis/scripts/add_session.py --title "..." --commit "..."` | **One-click add session (recommended, branch auto-complete)** |
65
66
  | `python3 ./.trellis/scripts/task.py archive <name>` | Archive completed task (auto-commits) |
66
67
  | `python3 ./.trellis/scripts/task.py list` | List active tasks |
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: start
3
- description: "Start Session"
3
+ description: "Initializes an AI development session by reading workflow guides, developer identity, git status, active tasks, and project guidelines from .trellis/. Classifies incoming tasks and routes to brainstorm, direct edit, or task workflow. Use when beginning a new coding session, resuming work, starting a new task, or re-establishing project context."
4
4
  ---
5
5
 
6
6
  # Start Session
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: update-spec
3
- description: "Update Code-Spec - Capture Executable Contracts"
3
+ description: "Captures executable contracts and coding knowledge into .trellis/spec/ documents after implementation, debugging, or design decisions. Enforces code-spec depth for infra and cross-layer changes with mandatory sections for signatures, contracts, validation matrices, and test points. Use when a feature is implemented, a bug is fixed, a design decision is made, a new pattern is discovered, or cross-layer contracts change."
4
4
  ---
5
5
 
6
6
  # Update Code-Spec - Capture Executable Contracts
@@ -13,6 +13,10 @@ Use `@/.trellis/` to learn:
13
13
  - Project structure guidelines (`spec/`)
14
14
  - Developer workspace (`workspace/`)
15
15
 
16
+ If you're using Codex, project-scoped helpers may also live in:
17
+ - `.agents/skills/` for reusable Trellis skills
18
+ - `.codex/agents/` for optional custom subagents
19
+
16
20
  Keep this managed block so 'trellis update' can refresh the instructions.
17
21
 
18
22
  <!-- TRELLIS:END -->
@@ -239,7 +239,7 @@ Templates use `.txt` extension to:
239
239
  ```typescript
240
240
  import { downloadTemplate } from "giget";
241
241
 
242
- await downloadTemplate("gh:mindfold-ai/Trellis/marketplace/specs/electron-fullstack", {
242
+ await downloadTemplate("gh:mindfold-ai/marketplace/specs/electron-fullstack", {
243
243
  dir: destDir,
244
244
  preferOffline: true,
245
245
  });
@@ -73,6 +73,7 @@ This will:
73
73
 
74
74
  Each session should include:
75
75
  - Summary: One-line description
76
+ - Branch: Which branch the work was done on
76
77
  - Main Changes: What was modified
77
78
  - Git Commits: Commit hashes and messages
78
79
  - Next Steps: What to do next
@@ -88,6 +89,7 @@ Use this template when recording sessions:
88
89
 
89
90
  **Date**: YYYY-MM-DD
90
91
  **Task**: {task-name}
92
+ **Branch**: `{branch-name}`
91
93
 
92
94
  ### Summary
93
95
 
@@ -71,6 +71,10 @@ Execute each step in `phase` order.
71
71
 
72
72
  > Hook will auto-inject all specs, requirements, and technical design to subagent context.
73
73
  > Dispatch only needs to issue simple call commands.
74
+ >
75
+ > **OpenCode dispatch rule**: Call subagents synchronously (`run_in_background: false`).
76
+ > Do NOT use `TaskOutput` or background polling as the completion signal for child phases.
77
+ > The background wrapper can finish before the real subagent session is actually done.
74
78
 
75
79
  ### action: "implement"
76
80
 
@@ -79,7 +83,7 @@ Task(
79
83
  subagent_type: "implement",
80
84
  prompt: "Implement the feature described in prd.md in the task directory",
81
85
  model: "opus",
82
- run_in_background: true
86
+ run_in_background: false
83
87
  )
84
88
  ```
85
89
 
@@ -98,7 +102,7 @@ Task(
98
102
  subagent_type: "check",
99
103
  prompt: "Check code changes, fix issues yourself",
100
104
  model: "opus",
101
- run_in_background: true
105
+ run_in_background: false
102
106
  )
103
107
  ```
104
108
 
@@ -116,7 +120,7 @@ Task(
116
120
  subagent_type: "debug",
117
121
  prompt: "Fix the issues described in the task context",
118
122
  model: "opus",
119
- run_in_background: true
123
+ run_in_background: false
120
124
  )
121
125
  ```
122
126
 
@@ -132,7 +136,7 @@ Task(
132
136
  subagent_type: "check",
133
137
  prompt: "[finish] Execute final completion check before PR",
134
138
  model: "opus",
135
- run_in_background: true
139
+ run_in_background: false
136
140
  )
137
141
  ```
138
142
 
@@ -168,27 +172,23 @@ This will:
168
172
  ### Basic Pattern
169
173
 
170
174
  ```
171
- task_id = Task(
175
+ result = Task(
172
176
  subagent_type: "implement", // or "check", "debug"
173
177
  prompt: "Simple task description",
174
178
  model: "opus",
175
- run_in_background: true
179
+ run_in_background: false
176
180
  )
177
181
 
178
- // Poll for completion
179
- for i in 1..N:
180
- result = TaskOutput(task_id, block=true, timeout=300000)
181
- if result.status == "completed":
182
- break
182
+ // Wait for the Task call to return before starting the next phase.
183
+ // Do NOT call TaskOutput or use background polling inside OpenCode dispatch.
183
184
  ```
184
185
 
185
- ### Timeout Settings
186
+ ### Execution Rule
186
187
 
187
- | Phase | Max Time | Poll Count |
188
- |-------|----------|------------|
189
- | implement | 30 min | 6 times |
190
- | check | 15 min | 3 times |
191
- | debug | 20 min | 4 times |
188
+ - Run one phase at a time
189
+ - Start the next phase only after the current `Task(...)` call returns
190
+ - If a phase returns a clear timeout or failure, handle that result explicitly
191
+ - Do **not** simulate completion by polling a background task wrapper
192
192
 
193
193
  ---
194
194
 
@@ -196,7 +196,7 @@ for i in 1..N:
196
196
 
197
197
  ### Timeout
198
198
 
199
- If a subagent times out, notify the user and ask for guidance:
199
+ If a synchronous subagent call times out, notify the user and ask for guidance:
200
200
 
201
201
  ```
202
202
  "Subagent {phase} timed out after {time}. Options:
@@ -207,10 +207,11 @@ If a subagent times out, notify the user and ask for guidance:
207
207
 
208
208
  ### Subagent Failure
209
209
 
210
- If a subagent reports failure, read the output and decide:
210
+ If a synchronous subagent call reports failure, read the output and decide:
211
211
 
212
212
  - If recoverable: call debug agent to fix
213
213
  - If not recoverable: notify user and ask for guidance
214
+ - Do not switch back to `TaskOutput` polling for the same phase
214
215
 
215
216
  ---
216
217
 
@@ -1,6 +1,6 @@
1
1
  [!] **Prerequisite**: This command should only be used AFTER the human has tested and committed the code.
2
2
 
3
- **AI must NOT execute git commit** - only read history (`git log`, `git status`, `git diff`).
3
+ **Do NOT run `git commit` directly** the scripts below handle their own commits for `.trellis/` metadata. You only need to read git history (`git log`, `git status`, `git diff`) and run the Python scripts.
4
4
 
5
5
  ---
6
6
 
@@ -46,6 +46,7 @@ EOF
46
46
  **Auto-completes**:
47
47
  - [OK] Appends session to journal-N.md
48
48
  - [OK] Auto-detects line count, creates new file if >2000 lines
49
+ - [OK] Auto-detects Branch context (`--branch` override; otherwise Branch = task.json -> current git branch; missing values are omitted gracefully)
49
50
  - [OK] Updates index.md (Total Sessions +1, Last Active, line stats, history)
50
51
  - [OK] Auto-commits .trellis/workspace and .trellis/tasks changes
51
52
 
@@ -56,6 +57,6 @@ EOF
56
57
  | Command | Purpose |
57
58
  |---------|---------|
58
59
  | `python3 ./.trellis/scripts/get_context.py --mode record` | Get context for record-session |
59
- | `python3 ./.trellis/scripts/add_session.py --title "..." --commit "..."` | **One-click add session (recommended)** |
60
+ | `python3 ./.trellis/scripts/add_session.py --title "..." --commit "..."` | **One-click add session (recommended, branch auto-complete)** |
60
61
  | `python3 ./.trellis/scripts/task.py archive <name>` | Archive completed task (auto-commits) |
61
62
  | `python3 ./.trellis/scripts/task.py list` | List active tasks |
@@ -11,7 +11,7 @@
11
11
  */
12
12
 
13
13
  import { existsSync, readFileSync, appendFileSync, readdirSync } from "fs"
14
- import { join } from "path"
14
+ import { isAbsolute, join } from "path"
15
15
  import { homedir, platform } from "os"
16
16
  import { execSync } from "child_process"
17
17
 
@@ -191,12 +191,52 @@ export class TrellisContext {
191
191
  if (!existsSync(currentTaskPath)) {
192
192
  return null
193
193
  }
194
- return readFileSync(currentTaskPath, "utf-8").trim()
194
+ const taskRef = readFileSync(currentTaskPath, "utf-8").trim()
195
+ const normalized = this.normalizeTaskRef(taskRef)
196
+ return normalized || null
195
197
  } catch {
196
198
  return null
197
199
  }
198
200
  }
199
201
 
202
+ normalizeTaskRef(taskRef) {
203
+ if (!taskRef) {
204
+ return ""
205
+ }
206
+
207
+ if (isAbsolute(taskRef)) {
208
+ return taskRef.trim()
209
+ }
210
+
211
+ let normalized = taskRef.trim().replace(/\\/g, "/")
212
+ while (normalized.startsWith("./")) {
213
+ normalized = normalized.slice(2)
214
+ }
215
+
216
+ if (normalized.startsWith("tasks/")) {
217
+ return `.trellis/${normalized}`
218
+ }
219
+
220
+ return normalized
221
+ }
222
+
223
+ resolveTaskDir(taskRef) {
224
+ const normalized = this.normalizeTaskRef(taskRef)
225
+ if (!normalized) {
226
+ return null
227
+ }
228
+
229
+ if (isAbsolute(normalized)) {
230
+ return normalized
231
+ }
232
+
233
+ if (normalized.startsWith(".trellis/")) {
234
+ return join(this.directory, normalized)
235
+ }
236
+
237
+ return join(this.directory, ".trellis", "tasks", normalized)
238
+ }
239
+
200
240
  // ============================================================
201
241
  // Hook Decision Logic
202
242
  // ============================================================
@@ -11,7 +11,7 @@
11
11
  */
12
12
 
13
13
  import { existsSync, readFileSync, readdirSync, statSync } from "fs"
14
- import { join } from "path"
14
+ import { basename, join } from "path"
15
15
  import { execFileSync } from "child_process"
16
16
  import { platform } from "os"
17
17
  import { TrellisContext, contextCollector, debugLog } from "../lib/trellis-context.js"
@@ -23,36 +23,16 @@ const PYTHON_CMD = platform() === "win32" ? "python" : "python3"
23
23
  * Check current task status and return structured status string.
24
24
  * JavaScript equivalent of _get_task_status in Claude's session-start.py.
25
25
  */
26
- function getTaskStatus(directory) {
27
- const trellisDir = join(directory, ".trellis")
28
- const currentTaskFile = join(trellisDir, ".current-task")
29
-
30
- if (!existsSync(currentTaskFile)) {
31
- return "Status: NO ACTIVE TASK\nNext: Describe what you want to work on"
32
- }
33
-
34
- let taskRef
35
- try {
36
- taskRef = readFileSync(currentTaskFile, "utf-8").trim()
37
- } catch {
38
- return "Status: NO ACTIVE TASK\nNext: Describe what you want to work on"
39
- }
40
-
26
+ function getTaskStatus(ctx) {
27
+ const taskRef = ctx.getCurrentTask()
41
28
  if (!taskRef) {
42
29
  return "Status: NO ACTIVE TASK\nNext: Describe what you want to work on"
43
30
  }
44
31
 
45
32
  // Resolve task directory
46
- let taskDir
47
- if (taskRef.startsWith("/")) {
48
- taskDir = taskRef
49
- } else if (taskRef.startsWith(".trellis/")) {
50
- taskDir = join(directory, taskRef)
51
- } else {
52
- taskDir = join(trellisDir, "tasks", taskRef)
53
- }
33
+ const taskDir = ctx.resolveTaskDir(taskRef)
54
34
 
55
- if (!existsSync(taskDir)) {
35
+ if (!taskDir || !existsSync(taskDir)) {
56
36
  return `Status: STALE POINTER\nTask: ${taskRef}\nNext: Task directory not found. Run: python3 ./.trellis/scripts/task.py finish`
57
37
  }
58
38
 
@@ -71,7 +51,7 @@ function getTaskStatus(directory) {
71
51
  const taskStatus = taskData.status || "unknown"
72
52
 
73
53
  if (taskStatus === "completed") {
74
- const dirName = taskDir.split("/").pop()
54
+ const dirName = basename(taskDir)
75
55
  return `Status: COMPLETED\nTask: ${taskTitle}\nNext: Archive with \`python3 ./.trellis/scripts/task.py archive ${dirName}\` or start a new task`
76
56
  }
77
57
 
@@ -354,7 +334,7 @@ Read and follow all instructions below carefully.
354
334
  }
355
335
 
356
336
  // 6. Task status (R2: check task state for session resume)
357
- const taskStatus = getTaskStatus(directory)
337
+ const taskStatus = getTaskStatus(ctx)
358
338
  parts.push(`<task-status>\n${taskStatus}\n</task-status>`)
359
339
 
360
340
  // 7. Final directive (R3: active, not passive)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: before-dev
3
- description: "Read the relevant development guidelines before starting your task."
3
+ description: "Discovers and injects project-specific coding guidelines from .trellis/spec/ before implementation begins. Reads spec indexes, pre-development checklists, and shared thinking guides for the target package. Use when starting a new coding task, before writing any code, switching to a different package, or needing to refresh project conventions and standards."
4
4
  ---
5
5
 
6
6
  Read the relevant development guidelines before starting your task.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: brainstorm
3
- description: "Brainstorm - Requirements Discovery (AI Coding Enhanced)"
3
+ description: "Collaborative requirements discovery session optimized for AI coding workflows. Creates task directories, seeds PRDs, runs codebase research, proposes concrete implementation approaches with trade-offs, and converges on MVP scope through structured Q&A. Use when requirements are unclear, multiple implementation paths exist, trade-offs need evaluation, or a complex feature needs scoping before development."
4
4
  ---
5
5
 
6
6
  # Brainstorm - Requirements Discovery (AI Coding Enhanced)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: break-loop
3
- description: "Break the Loop - Deep Bug Analysis"
3
+ description: "Deep post-fix bug analysis across five dimensions: root cause categorization, fix failure analysis, prevention mechanisms, systematic expansion, and knowledge capture. Updates .trellis/spec/ guides with lessons learned to prevent recurring bugs. Use when a debugging session completes, after fixing a tricky bug, when the same class of bug keeps recurring, or when you want to capture debugging insights into project documentation."
4
4
  ---
5
5
 
6
6
  # Break the Loop - Deep Bug Analysis
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: check
3
- description: "Check if the code you just wrote follows the development guidelines."
3
+ description: "Validates recently written code against project-specific development guidelines from .trellis/spec/. Identifies changed files via git diff, discovers applicable spec modules, runs lint and typecheck, and reports guideline violations. Use when code is written and needs quality verification, to catch context drift during long sessions, or before committing changes."
4
4
  ---
5
5
 
6
6
  Check if the code you just wrote follows the development guidelines.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: check-cross-layer
3
- description: "Cross-Layer Check"
3
+ description: "Post-implementation verification across multiple code dimensions: cross-layer data flow, code reuse analysis, import path validation, and same-layer consistency checks. Identifies missed update sites, type mismatches, and duplicated constants. Use when changes span 3+ architectural layers, after modifying shared constants or configs, after batch file modifications, or when creating new utility functions."
4
4
  ---
5
5
 
6
6
  # Cross-Layer Check
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: create-command
3
- description: "Create New Skill"
3
+ description: "Scaffolds a new skill file with proper naming conventions and structure. Analyzes requirements to determine skill type and generates appropriate content. Use when adding a new developer workflow skill, creating a custom skill, or extending the Trellis skill set."
4
4
  ---
5
5
 
6
6
  # Create New Skill
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: finish-work
3
- description: "Finish Work - Pre-Commit Checklist"
3
+ description: "Pre-commit quality checklist covering lint, typecheck, tests, code-spec sync, API changes, database migrations, cross-layer verification, and manual testing. Blocks commit if infra or cross-layer specs lack executable depth. Use when code is written and tested but not yet committed, before submitting changes, or as a final review before git commit."
4
4
  ---
5
5
 
6
6
  # Finish Work - Pre-Commit Checklist
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: integrate-skill
3
- description: "Integrate Skill into Project Guidelines"
3
+ description: "Adapts an external skill into project-specific development guidelines in .trellis/spec/. Creates guideline sections, code example templates with .template suffix, and updates spec indexes. Use when integrating an external skill, adding a new skill's patterns to project conventions, or incorporating third-party skill best practices into .trellis/spec/ documentation."
4
4
  ---
5
5
 
6
6
  # Integrate Skill into Project Guidelines
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: onboard
3
- description: "PART 3: Customize Your Development Guidelines"
3
+ description: "Interactive three-part onboarding for new team members to the Trellis AI-assisted workflow system. Covers core philosophy (AI memory, project-specific knowledge, context drift), system structure and command deep-dives, real-world workflow examples, and guideline customization. Use when a new developer joins the project, someone needs to understand the Trellis workflow, or project guidelines need initial setup."
4
4
  ---
5
5
 
6
6
  You are a senior developer onboarding a new team member to this project's AI-assisted workflow system.
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: record-session
3
- description: "Record work progress after human has tested and committed code"
3
+ description: "Records completed work progress to .trellis/workspace/ journal files after human testing and commit. Captures session summaries, commit hashes, and updates developer index files for future session context. Use when a coding session is complete, after the human has committed code, or to persist session knowledge for future AI sessions."
4
4
  ---
5
5
 
6
6
  [!] **Prerequisite**: This command should only be used AFTER the human has tested and committed the code.
7
7
 
8
- **AI must NOT execute git commit** - only read history (`git log`, `git status`, `git diff`).
8
+ **Do NOT run `git commit` directly** the scripts below handle their own commits for `.trellis/` metadata. You only need to read git history (`git log`, `git status`, `git diff`) and run the Python scripts.
9
9
 
10
10
  ---
11
11
 
@@ -51,6 +51,7 @@ EOF
51
51
  **Auto-completes**:
52
52
  - [OK] Appends session to journal-N.md
53
53
  - [OK] Auto-detects line count, creates new file if >2000 lines
54
+ - [OK] Auto-detects Branch context (`--branch` override; otherwise Branch = task.json -> current git branch; missing values are omitted gracefully)
54
55
  - [OK] Updates index.md (Total Sessions +1, Last Active, line stats, history)
55
56
  - [OK] Auto-commits .trellis/workspace and .trellis/tasks changes
56
57
 
@@ -61,6 +62,6 @@ EOF
61
62
  | Command | Purpose |
62
63
  |---------|---------|
63
64
  | `python3 ./.trellis/scripts/get_context.py --mode record` | Get context for record-session |
64
- | `python3 ./.trellis/scripts/add_session.py --title "..." --commit "..."` | **One-click add session (recommended)** |
65
+ | `python3 ./.trellis/scripts/add_session.py --title "..." --commit "..."` | **One-click add session (recommended, branch auto-complete)** |
65
66
  | `python3 ./.trellis/scripts/task.py archive <name>` | Archive completed task (auto-commits) |
66
67
  | `python3 ./.trellis/scripts/task.py list` | List active tasks |