@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
@@ -0,0 +1,211 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ Trellis StatusLine — project-level status display for Claude Code.
5
+
6
+ Reads Claude Code session JSON from stdin + Trellis task data from filesystem.
7
+ Outputs 1-2 lines:
8
+ With active task: [P1] Task title (status) + info line
9
+ Without task: info line only
10
+ Info line: model · ctx% · branch · duration · developer · tasks · rate limits
11
+ """
12
+ from __future__ import annotations
13
+
14
+ import json
15
+ import re
16
+ import subprocess
17
+ import sys
18
+ from pathlib import Path
19
+
20
+
21
+ def _read_text(path: Path) -> str:
22
+ try:
23
+ return path.read_text(encoding="utf-8").strip()
24
+ except (FileNotFoundError, PermissionError, OSError):
25
+ return ""
26
+
27
+
28
+ def _read_json(path: Path) -> dict:
29
+ text = _read_text(path)
30
+ if not text:
31
+ return {}
32
+ try:
33
+ return json.loads(text)
34
+ except (json.JSONDecodeError, ValueError):
35
+ return {}
36
+
37
+
38
+ def _normalize_task_ref(task_ref: str) -> str:
39
+ normalized = task_ref.strip()
40
+ if not normalized:
41
+ return ""
42
+
43
+ path_obj = Path(normalized)
44
+ if path_obj.is_absolute():
45
+ return str(path_obj)
46
+
47
+ normalized = normalized.replace("\\", "/")
48
+ while normalized.startswith("./"):
49
+ normalized = normalized[2:]
50
+
51
+ if normalized.startswith("tasks/"):
52
+ return f".trellis/{normalized}"
53
+
54
+ return normalized
55
+
56
+
57
+ def _resolve_task_dir(trellis_dir: Path, task_ref: str) -> Path:
58
+ normalized = _normalize_task_ref(task_ref)
59
+ path_obj = Path(normalized)
60
+ if path_obj.is_absolute():
61
+ return path_obj
62
+ if normalized.startswith(".trellis/"):
63
+ return trellis_dir.parent / path_obj
64
+ return trellis_dir / "tasks" / path_obj
65
+
66
+
67
+ def _find_trellis_dir() -> Path | None:
68
+ """Walk up from cwd to find .trellis/ directory."""
69
+ current = Path.cwd()
70
+ for parent in [current, *current.parents]:
71
+ candidate = parent / ".trellis"
72
+ if candidate.is_dir():
73
+ return candidate
74
+ return None
75
+
76
+
77
+ def _get_current_task(trellis_dir: Path) -> dict | None:
78
+ """Load current task info. Returns dict with title/status/priority or None."""
79
+ task_ref = _normalize_task_ref(_read_text(trellis_dir / ".current-task"))
80
+ if not task_ref:
81
+ return None
82
+
83
+ # Resolve task directory
84
+ task_path = _resolve_task_dir(trellis_dir, task_ref)
85
+ task_data = _read_json(task_path / "task.json")
86
+ if not task_data:
87
+ return None
88
+
89
+ return {
90
+ "title": task_data.get("title") or task_data.get("name") or "unknown",
91
+ "status": task_data.get("status", "unknown"),
92
+ "priority": task_data.get("priority", "P2"),
93
+ }
94
+
95
+
96
+ def _count_active_tasks(trellis_dir: Path) -> int:
97
+ """Count non-archived task directories with valid task.json."""
98
+ tasks_dir = trellis_dir / "tasks"
99
+ if not tasks_dir.is_dir():
100
+ return 0
101
+ count = 0
102
+ for d in tasks_dir.iterdir():
103
+ if d.is_dir() and d.name != "archive" and (d / "task.json").is_file():
104
+ count += 1
105
+ return count
106
+
107
+
108
+ def _get_developer(trellis_dir: Path) -> str:
109
+ content = _read_text(trellis_dir / ".developer")
110
+ if not content:
111
+ return "unknown"
112
+ for line in content.splitlines():
113
+ if line.startswith("name="):
114
+ return line[5:].strip()
115
+ return content.splitlines()[0].strip() or "unknown"
116
+
117
+
118
+ def _get_git_branch() -> str:
119
+ try:
120
+ result = subprocess.run(
121
+ ["git", "branch", "--show-current"],
122
+ capture_output=True, text=True, timeout=3,
123
+ )
124
+ return result.stdout.strip() if result.returncode == 0 else ""
125
+ except (FileNotFoundError, subprocess.TimeoutExpired):
126
+ return ""
127
+
128
+
129
+ def _format_ctx_size(size: int) -> str:
130
+ if size >= 1_000_000:
131
+ return f"{size // 1_000_000}M"
132
+ if size >= 1_000:
133
+ return f"{size // 1_000}K"
134
+ return str(size)
135
+
136
+
137
+ def _format_duration(ms: int) -> str:
138
+ secs = ms // 1000
139
+ hours, remainder = divmod(secs, 3600)
140
+ mins = remainder // 60
141
+ if hours > 0:
142
+ return f"{hours}h{mins}m"
143
+ return f"{mins}m"
144
+
145
+
146
+ def main() -> None:
147
+ # Read Claude Code session JSON from stdin
148
+ try:
149
+ cc_data = json.loads(sys.stdin.read())
150
+ except (json.JSONDecodeError, ValueError):
151
+ cc_data = {}
152
+
153
+ trellis_dir = _find_trellis_dir()
154
+ SEP = " \033[90m·\033[0m "
155
+
156
+ # --- Trellis data ---
157
+ task = _get_current_task(trellis_dir) if trellis_dir else None
158
+ dev = _get_developer(trellis_dir) if trellis_dir else ""
159
+ task_count = _count_active_tasks(trellis_dir) if trellis_dir else 0
160
+
161
+ # --- CC session data ---
162
+ model = cc_data.get("model", {}).get("display_name", "?")
163
+ ctx_pct = int(cc_data.get("context_window", {}).get("used_percentage") or 0)
164
+ ctx_size = _format_ctx_size(cc_data.get("context_window", {}).get("context_window_size") or 0)
165
+ duration = _format_duration(cc_data.get("cost", {}).get("total_duration_ms") or 0)
166
+ branch = _get_git_branch()
167
+
168
+ # Avoid "Opus 4.6 (1M context) (1M)"
169
+ if re.search(r"\d+[KMG]\b", model, re.IGNORECASE):
170
+ model_label = model
171
+ else:
172
+ model_label = f"{model} ({ctx_size})"
173
+
174
+ # Context % with color
175
+ if ctx_pct >= 90:
176
+ ctx_color = "\033[31m"
177
+ elif ctx_pct >= 70:
178
+ ctx_color = "\033[33m"
179
+ else:
180
+ ctx_color = "\033[32m"
181
+
182
+ # Build info line: model · ctx · branch · duration · dev · tasks [· rate limits]
183
+ parts = [
184
+ model_label,
185
+ f"ctx {ctx_color}{ctx_pct}%\033[0m",
186
+ ]
187
+ if branch:
188
+ parts.append(f"\033[35m{branch}\033[0m")
189
+ parts.append(duration)
190
+ if dev:
191
+ parts.append(f"\033[32m{dev}\033[0m")
192
+ if task_count:
193
+ parts.append(f"{task_count} task(s)")
194
+
195
+ five_hr = cc_data.get("rate_limits", {}).get("five_hour", {}).get("used_percentage")
196
+ if five_hr is not None:
197
+ parts.append(f"5h {int(five_hr)}%")
198
+ seven_day = cc_data.get("rate_limits", {}).get("seven_day", {}).get("used_percentage")
199
+ if seven_day is not None:
200
+ parts.append(f"7d {int(seven_day)}%")
201
+
202
+ info_line = SEP.join(parts)
203
+
204
+ # Output: task line (only if active) + info line
205
+ if task:
206
+ print(f"\033[36m[{task['priority']}]\033[0m {task['title']} \033[33m({task['status']})\033[0m")
207
+ print(info_line)
208
+
209
+
210
+ if __name__ == "__main__":
211
+ main()
@@ -1,4 +1,8 @@
1
1
  {
2
+ "statusLine": {
3
+ "type": "command",
4
+ "command": "{{PYTHON_CMD}} .claude/hooks/statusline.py"
5
+ },
2
6
  "hooks": {
3
7
  "SessionStart": [
4
8
  {
@@ -0,0 +1,29 @@
1
+ Read the relevant development guidelines before starting your task.
2
+
3
+ Execute these steps:
4
+
5
+ 1. **Discover packages and their spec layers**:
6
+ ```bash
7
+ python3 ./.trellis/scripts/get_context.py --mode packages
8
+ ```
9
+
10
+ 2. **Identify which specs apply** to your task based on:
11
+ - Which package you're modifying (e.g., `cli/`, `docs-site/`)
12
+ - What type of work (backend, frontend, unit-test, docs, etc.)
13
+
14
+ 3. **Read the spec index** for each relevant module:
15
+ ```bash
16
+ cat .trellis/spec/<package>/<layer>/index.md
17
+ ```
18
+ Follow the **"Pre-Development Checklist"** section in the index.
19
+
20
+ 4. **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.
21
+
22
+ 5. **Always read shared guides**:
23
+ ```bash
24
+ cat .trellis/spec/guides/index.md
25
+ ```
26
+
27
+ 6. Understand the coding standards and patterns you need to follow, then proceed with your development plan.
28
+
29
+ This step is **mandatory** before writing any code.