@mindfoldhq/trellis 0.3.10-beta.0 → 0.3.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 (173) hide show
  1. package/dist/cli/index.js +0 -2
  2. package/dist/cli/index.js.map +1 -1
  3. package/dist/commands/init.d.ts +0 -1
  4. package/dist/commands/init.d.ts.map +1 -1
  5. package/dist/commands/init.js +31 -203
  6. package/dist/commands/init.js.map +1 -1
  7. package/dist/commands/update.d.ts.map +1 -1
  8. package/dist/commands/update.js +6 -154
  9. package/dist/commands/update.js.map +1 -1
  10. package/dist/configurators/workflow.d.ts +2 -6
  11. package/dist/configurators/workflow.d.ts.map +1 -1
  12. package/dist/configurators/workflow.js +58 -88
  13. package/dist/configurators/workflow.js.map +1 -1
  14. package/dist/migrations/index.d.ts +0 -1
  15. package/dist/migrations/index.d.ts.map +1 -1
  16. package/dist/migrations/index.js +0 -2
  17. package/dist/migrations/index.js.map +1 -1
  18. package/dist/migrations/manifests/0.3.10.json +9 -0
  19. package/dist/templates/claude/agents/dispatch.md +2 -1
  20. package/dist/templates/claude/agents/implement.md +3 -2
  21. package/dist/templates/claude/commands/trellis/before-backend-dev.md +13 -0
  22. package/dist/templates/claude/commands/trellis/before-frontend-dev.md +13 -0
  23. package/dist/templates/claude/commands/trellis/check-backend.md +13 -0
  24. package/dist/templates/claude/commands/trellis/check-frontend.md +13 -0
  25. package/dist/templates/claude/commands/trellis/create-command.md +2 -2
  26. package/dist/templates/claude/commands/trellis/onboard.md +13 -13
  27. package/dist/templates/claude/commands/trellis/parallel.md +2 -1
  28. package/dist/templates/claude/commands/trellis/record-session.md +2 -2
  29. package/dist/templates/claude/commands/trellis/start.md +4 -8
  30. package/dist/templates/claude/hooks/inject-subagent-context.py +13 -21
  31. package/dist/templates/claude/hooks/session-start.py +2 -170
  32. package/dist/templates/codex/skills/before-backend-dev/SKILL.md +18 -0
  33. package/dist/templates/codex/skills/before-frontend-dev/SKILL.md +18 -0
  34. package/dist/templates/codex/skills/check-backend/SKILL.md +18 -0
  35. package/dist/templates/codex/skills/check-frontend/SKILL.md +18 -0
  36. package/dist/templates/codex/skills/create-command/SKILL.md +2 -2
  37. package/dist/templates/codex/skills/onboard/SKILL.md +11 -11
  38. package/dist/templates/codex/skills/record-session/SKILL.md +2 -2
  39. package/dist/templates/codex/skills/start/SKILL.md +3 -8
  40. package/dist/templates/cursor/commands/trellis-before-backend-dev.md +13 -0
  41. package/dist/templates/cursor/commands/trellis-before-frontend-dev.md +13 -0
  42. package/dist/templates/cursor/commands/trellis-check-backend.md +13 -0
  43. package/dist/templates/cursor/commands/trellis-check-frontend.md +13 -0
  44. package/dist/templates/cursor/commands/trellis-create-command.md +2 -2
  45. package/dist/templates/cursor/commands/trellis-onboard.md +13 -13
  46. package/dist/templates/cursor/commands/trellis-record-session.md +2 -2
  47. package/dist/templates/cursor/commands/trellis-start.md +16 -7
  48. package/dist/templates/gemini/commands/trellis/before-backend-dev.toml +17 -0
  49. package/dist/templates/gemini/commands/trellis/before-frontend-dev.toml +17 -0
  50. package/dist/templates/gemini/commands/trellis/check-backend.toml +17 -0
  51. package/dist/templates/gemini/commands/trellis/check-frontend.toml +17 -0
  52. package/dist/templates/gemini/commands/trellis/create-command.toml +2 -2
  53. package/dist/templates/gemini/commands/trellis/onboard.toml +2 -2
  54. package/dist/templates/gemini/commands/trellis/record-session.toml +2 -2
  55. package/dist/templates/gemini/commands/trellis/start.toml +4 -9
  56. package/dist/templates/iflow/agents/dispatch.md +2 -1
  57. package/dist/templates/iflow/agents/implement.md +3 -2
  58. package/dist/templates/iflow/commands/trellis/before-backend-dev.md +13 -0
  59. package/dist/templates/iflow/commands/trellis/before-frontend-dev.md +13 -0
  60. package/dist/templates/iflow/commands/trellis/check-backend.md +13 -0
  61. package/dist/templates/iflow/commands/trellis/check-frontend.md +13 -0
  62. package/dist/templates/iflow/commands/trellis/create-command.md +2 -2
  63. package/dist/templates/iflow/commands/trellis/onboard.md +13 -13
  64. package/dist/templates/iflow/commands/trellis/parallel.md +2 -1
  65. package/dist/templates/iflow/commands/trellis/record-session.md +2 -2
  66. package/dist/templates/iflow/commands/trellis/start.md +4 -8
  67. package/dist/templates/iflow/hooks/inject-subagent-context.py +13 -21
  68. package/dist/templates/iflow/hooks/session-start.py +1 -156
  69. package/dist/templates/kilo/workflows/before-backend-dev.md +13 -0
  70. package/dist/templates/kilo/workflows/before-frontend-dev.md +13 -0
  71. package/dist/templates/kilo/workflows/check-backend.md +13 -0
  72. package/dist/templates/kilo/workflows/check-frontend.md +13 -0
  73. package/dist/templates/kilo/workflows/create-command.md +2 -2
  74. package/dist/templates/kilo/workflows/onboard.md +13 -13
  75. package/dist/templates/kilo/workflows/parallel.md +2 -1
  76. package/dist/templates/kilo/workflows/record-session.md +2 -2
  77. package/dist/templates/kilo/workflows/start.md +3 -8
  78. package/dist/templates/kiro/skills/before-backend-dev/SKILL.md +18 -0
  79. package/dist/templates/kiro/skills/before-frontend-dev/SKILL.md +18 -0
  80. package/dist/templates/kiro/skills/check-backend/SKILL.md +18 -0
  81. package/dist/templates/kiro/skills/check-frontend/SKILL.md +18 -0
  82. package/dist/templates/kiro/skills/create-command/SKILL.md +2 -2
  83. package/dist/templates/kiro/skills/onboard/SKILL.md +11 -11
  84. package/dist/templates/kiro/skills/record-session/SKILL.md +2 -2
  85. package/dist/templates/kiro/skills/start/SKILL.md +3 -8
  86. package/dist/templates/markdown/spec/backend/script-conventions.md +0 -93
  87. package/dist/templates/opencode/agents/dispatch.md +2 -1
  88. package/dist/templates/opencode/agents/implement.md +2 -2
  89. package/dist/templates/opencode/agents/research.md +2 -1
  90. package/dist/templates/opencode/commands/trellis/before-backend-dev.md +13 -0
  91. package/dist/templates/opencode/commands/trellis/before-frontend-dev.md +13 -0
  92. package/dist/templates/opencode/commands/trellis/check-backend.md +13 -0
  93. package/dist/templates/opencode/commands/trellis/check-frontend.md +13 -0
  94. package/dist/templates/opencode/commands/trellis/create-command.md +2 -2
  95. package/dist/templates/opencode/commands/trellis/onboard.md +13 -13
  96. package/dist/templates/opencode/commands/trellis/parallel.md +2 -1
  97. package/dist/templates/opencode/commands/trellis/record-session.md +2 -2
  98. package/dist/templates/opencode/commands/trellis/start.md +3 -8
  99. package/dist/templates/opencode/plugin/inject-subagent-context.js +18 -45
  100. package/dist/templates/opencode/plugin/session-start.js +1 -149
  101. package/dist/templates/qoder/skills/before-backend-dev/SKILL.md +18 -0
  102. package/dist/templates/qoder/skills/before-frontend-dev/SKILL.md +18 -0
  103. package/dist/templates/qoder/skills/check-backend/SKILL.md +18 -0
  104. package/dist/templates/qoder/skills/check-frontend/SKILL.md +18 -0
  105. package/dist/templates/qoder/skills/create-command/SKILL.md +2 -2
  106. package/dist/templates/qoder/skills/onboard/SKILL.md +13 -13
  107. package/dist/templates/qoder/skills/record-session/SKILL.md +2 -2
  108. package/dist/templates/qoder/skills/start/SKILL.md +3 -8
  109. package/dist/templates/trellis/config.yaml +0 -20
  110. package/dist/templates/trellis/index.d.ts +0 -11
  111. package/dist/templates/trellis/index.d.ts.map +1 -1
  112. package/dist/templates/trellis/index.js +0 -22
  113. package/dist/templates/trellis/index.js.map +1 -1
  114. package/dist/templates/trellis/scripts/add_session.py +7 -52
  115. package/dist/templates/trellis/scripts/common/cli_adapter.py +45 -33
  116. package/dist/templates/trellis/scripts/common/config.py +0 -152
  117. package/dist/templates/trellis/scripts/common/git_context.py +586 -23
  118. package/dist/templates/trellis/scripts/common/paths.py +0 -46
  119. package/dist/templates/trellis/scripts/common/phase.py +49 -50
  120. package/dist/templates/trellis/scripts/common/registry.py +72 -41
  121. package/dist/templates/trellis/scripts/common/task_queue.py +98 -27
  122. package/dist/templates/trellis/scripts/common/task_utils.py +6 -96
  123. package/dist/templates/trellis/scripts/create_bootstrap.py +26 -31
  124. package/dist/templates/trellis/scripts/multi_agent/cleanup.py +48 -43
  125. package/dist/templates/trellis/scripts/multi_agent/create_pr.py +45 -336
  126. package/dist/templates/trellis/scripts/multi_agent/plan.py +26 -2
  127. package/dist/templates/trellis/scripts/multi_agent/start.py +57 -126
  128. package/dist/templates/trellis/scripts/multi_agent/status.py +753 -12
  129. package/dist/templates/trellis/scripts/task.py +975 -50
  130. package/dist/templates/trellis/workflow.md +34 -21
  131. package/dist/types/migration.d.ts +1 -3
  132. package/dist/types/migration.d.ts.map +1 -1
  133. package/dist/utils/project-detector.d.ts +0 -23
  134. package/dist/utils/project-detector.d.ts.map +1 -1
  135. package/dist/utils/project-detector.js +0 -364
  136. package/dist/utils/project-detector.js.map +1 -1
  137. package/dist/utils/template-fetcher.d.ts +10 -2
  138. package/dist/utils/template-fetcher.d.ts.map +1 -1
  139. package/dist/utils/template-fetcher.js +43 -12
  140. package/dist/utils/template-fetcher.js.map +1 -1
  141. package/package.json +1 -1
  142. package/dist/migrations/manifests/0.4.0-beta.1.json +0 -228
  143. package/dist/templates/claude/commands/trellis/before-dev.md +0 -29
  144. package/dist/templates/claude/commands/trellis/check.md +0 -25
  145. package/dist/templates/codex/skills/before-dev/SKILL.md +0 -34
  146. package/dist/templates/codex/skills/check/SKILL.md +0 -30
  147. package/dist/templates/cursor/commands/trellis-before-dev.md +0 -29
  148. package/dist/templates/cursor/commands/trellis-check.md +0 -25
  149. package/dist/templates/gemini/commands/trellis/before-dev.toml +0 -33
  150. package/dist/templates/gemini/commands/trellis/check.toml +0 -29
  151. package/dist/templates/iflow/commands/trellis/before-dev.md +0 -29
  152. package/dist/templates/iflow/commands/trellis/check.md +0 -25
  153. package/dist/templates/kilo/workflows/before-dev.md +0 -29
  154. package/dist/templates/kilo/workflows/check.md +0 -25
  155. package/dist/templates/kiro/skills/before-dev/SKILL.md +0 -34
  156. package/dist/templates/kiro/skills/check/SKILL.md +0 -30
  157. package/dist/templates/opencode/commands/trellis/before-dev.md +0 -29
  158. package/dist/templates/opencode/commands/trellis/check.md +0 -25
  159. package/dist/templates/qoder/skills/before-dev/SKILL.md +0 -34
  160. package/dist/templates/qoder/skills/check/SKILL.md +0 -30
  161. package/dist/templates/trellis/scripts/common/git.py +0 -31
  162. package/dist/templates/trellis/scripts/common/io.py +0 -37
  163. package/dist/templates/trellis/scripts/common/log.py +0 -45
  164. package/dist/templates/trellis/scripts/common/packages_context.py +0 -233
  165. package/dist/templates/trellis/scripts/common/session_context.py +0 -466
  166. package/dist/templates/trellis/scripts/common/task_context.py +0 -384
  167. package/dist/templates/trellis/scripts/common/task_store.py +0 -534
  168. package/dist/templates/trellis/scripts/common/tasks.py +0 -109
  169. package/dist/templates/trellis/scripts/common/types.py +0 -112
  170. package/dist/templates/trellis/scripts/hooks/linear_sync.py +0 -243
  171. package/dist/templates/trellis/scripts/multi_agent/_bootstrap.py +0 -17
  172. package/dist/templates/trellis/scripts/multi_agent/status_display.py +0 -542
  173. package/dist/templates/trellis/scripts/multi_agent/status_monitor.py +0 -225
@@ -21,6 +21,7 @@ Configuration: .trellis/worktree.yaml
21
21
 
22
22
  from __future__ import annotations
23
23
 
24
+ import json
24
25
  import os
25
26
  import shutil
26
27
  import subprocess
@@ -28,12 +29,11 @@ import sys
28
29
  import uuid
29
30
  from pathlib import Path
30
31
 
31
- import _bootstrap # noqa: F401 — adds parent scripts/ dir to sys.path
32
+ # Add parent directory to path for imports
33
+ sys.path.insert(0, str(Path(__file__).parent.parent))
32
34
 
33
- from common.cli_adapter import get_cli_adapter
34
- from common.git import run_git
35
- from common.io import read_json, write_json
36
- from common.log import Colors, log_info, log_success, log_warn, log_error
35
+ from common.cli_adapter import CLIAdapter, get_cli_adapter
36
+ from common.git_context import _run_git_command
37
37
  from common.paths import (
38
38
  DIR_WORKFLOW,
39
39
  FILE_CURRENT_TASK,
@@ -44,12 +44,6 @@ from common.registry import (
44
44
  registry_add_agent,
45
45
  registry_get_file,
46
46
  )
47
- from common.config import (
48
- get_default_package,
49
- get_packages,
50
- get_submodule_packages,
51
- validate_package,
52
- )
53
47
  from common.worktree import (
54
48
  get_worktree_base_dir,
55
49
  get_worktree_config,
@@ -57,121 +51,64 @@ from common.worktree import (
57
51
  get_worktree_post_create_hooks,
58
52
  )
59
53
 
60
- # Colors, log_info, log_success, log_warn, log_error, read_json, write_json
61
- # are now imported from common.log and common.io above.
62
-
63
-
64
54
  # =============================================================================
65
- # Constants
55
+ # Colors
66
56
  # =============================================================================
67
57
 
68
- DEFAULT_PLATFORM = "claude"
58
+
59
+ class Colors:
60
+ RED = "\033[0;31m"
61
+ GREEN = "\033[0;32m"
62
+ YELLOW = "\033[1;33m"
63
+ BLUE = "\033[0;34m"
64
+ NC = "\033[0m"
65
+
66
+
67
+ def log_info(msg: str) -> None:
68
+ print(f"{Colors.BLUE}[INFO]{Colors.NC} {msg}")
69
+
70
+
71
+ def log_success(msg: str) -> None:
72
+ print(f"{Colors.GREEN}[SUCCESS]{Colors.NC} {msg}")
73
+
74
+
75
+ def log_warn(msg: str) -> None:
76
+ print(f"{Colors.YELLOW}[WARN]{Colors.NC} {msg}")
77
+
78
+
79
+ def log_error(msg: str) -> None:
80
+ print(f"{Colors.RED}[ERROR]{Colors.NC} {msg}")
69
81
 
70
82
 
71
83
  # =============================================================================
72
- # Submodule Init
84
+ # Helper Functions
73
85
  # =============================================================================
74
86
 
75
87
 
76
- def _init_submodules_for_task(
77
- task_data: dict, worktree_path: str, project_root: Path
78
- ) -> None:
79
- """Initialize submodules in worktree based on task's target package.
88
+ def _read_json_file(path: Path) -> dict | None:
89
+ """Read and parse a JSON file."""
90
+ try:
91
+ return json.loads(path.read_text(encoding="utf-8"))
92
+ except (FileNotFoundError, json.JSONDecodeError, OSError):
93
+ return None
80
94
 
81
- Resolves the target package from task_data.package -> default_package -> None.
82
- Only initializes submodule-type packages. Idempotent: skips already-initialized
83
- submodules to avoid detaching HEAD on in-progress work.
84
- """
85
- # Skip if not a monorepo (no packages configured)
86
- if get_packages(project_root) is None:
87
- return
88
95
 
89
- # Resolve package: task.package -> default_package -> None
90
- task_package = task_data.get("package")
91
- package = None
96
+ def _write_json_file(path: Path, data: dict) -> bool:
97
+ """Write dict to JSON file."""
98
+ try:
99
+ path.write_text(
100
+ json.dumps(data, indent=2, ensure_ascii=False), encoding="utf-8"
101
+ )
102
+ return True
103
+ except (OSError, IOError):
104
+ return False
92
105
 
93
- if task_package and isinstance(task_package, str):
94
- if validate_package(task_package, project_root):
95
- package = task_package
96
- else:
97
- log_warn(
98
- f"package '{task_package}' not found in config.yaml, "
99
- "skipping submodule init"
100
- )
101
- return
102
- else:
103
- # Fallback to default_package
104
- default_pkg = get_default_package(project_root)
105
- if default_pkg:
106
- if validate_package(default_pkg, project_root):
107
- package = default_pkg
108
- else:
109
- log_warn(
110
- f"package '{default_pkg}' not found in config.yaml, "
111
- "skipping submodule init"
112
- )
113
- return
114
-
115
- if not package:
116
- log_warn("no package specified, skipping submodule init")
117
- return
118
-
119
- # Check if this package is a submodule
120
- submodule_packages = get_submodule_packages(project_root)
121
- if package not in submodule_packages:
122
- log_info(f"Package '{package}' is not a submodule, skipping submodule init")
123
- return
124
-
125
- submodule_path = submodule_packages[package]
126
- log_info(f"Checking submodule status for '{package}' ({submodule_path})...")
127
-
128
- # Run git submodule status in worktree directory
129
- ret, status_out, status_err = run_git(
130
- ["submodule", "status", submodule_path], cwd=Path(worktree_path)
131
- )
132
106
 
133
- if ret != 0:
134
- log_warn(
135
- f"git submodule status failed for '{submodule_path}': {status_err.strip()}, "
136
- "skipping submodule init"
137
- )
138
- return
139
-
140
- # Parse the prefix character from submodule status output
141
- # Format: "<prefix><sha1> <path> (<describe>)"
142
- # Prefix: '-' (uninitialized), ' ' (normal), '+' (commit mismatch), 'U' (conflict)
143
- status_line = status_out.rstrip("\n\r")
144
- if not status_line:
145
- log_warn(f"Empty submodule status for '{submodule_path}', skipping")
146
- return
147
-
148
- prefix = status_line[0]
149
-
150
- if prefix == "-":
151
- # Uninitialized: run git submodule update --init
152
- log_info(f"Initializing submodule '{submodule_path}'...")
153
- ret, _, err = run_git(
154
- ["submodule", "update", "--init", submodule_path],
155
- cwd=Path(worktree_path),
156
- )
157
- if ret != 0:
158
- log_warn(f"Failed to initialize submodule '{submodule_path}': {err.strip()}")
159
- else:
160
- log_success(f"Submodule '{submodule_path}' initialized")
161
- elif prefix == " ":
162
- log_info(f"Submodule '{submodule_path}' already initialized, skipping")
163
- elif prefix == "+":
164
- log_warn(
165
- f"submodule {submodule_path} has local changes, skipping update"
166
- )
167
- elif prefix == "U":
168
- log_warn(
169
- f"submodule {submodule_path} has conflicts, skipping"
170
- )
171
- else:
172
- log_warn(
173
- f"Unknown submodule status prefix '{prefix}' for '{submodule_path}', skipping"
174
- )
107
+ # =============================================================================
108
+ # Constants
109
+ # =============================================================================
110
+
111
+ DEFAULT_PLATFORM = "claude"
175
112
 
176
113
 
177
114
  # =============================================================================
@@ -236,7 +173,7 @@ def main() -> int:
236
173
  print(f"{Colors.BLUE}=== Multi-Agent Pipeline: Start ==={Colors.NC}")
237
174
  log_info(f"Task: {task_dir_abs}")
238
175
 
239
- task_data = read_json(task_json_path)
176
+ task_data = _read_json_file(task_json_path)
240
177
  if not task_data:
241
178
  log_error("Failed to read task.json")
242
179
  return 1
@@ -285,7 +222,7 @@ def main() -> int:
285
222
  log_info("Step 1: Creating worktree...")
286
223
 
287
224
  # Record current branch as base_branch (PR target)
288
- _, base_branch_out, _ = run_git(
225
+ _, base_branch_out, _ = _run_git_command(
289
226
  ["branch", "--show-current"], cwd=project_root
290
227
  )
291
228
  base_branch = base_branch_out.strip()
@@ -302,18 +239,18 @@ def main() -> int:
302
239
  worktree_path_obj.parent.mkdir(parents=True, exist_ok=True)
303
240
 
304
241
  # Create branch if not exists
305
- ret, _, _ = run_git(
242
+ ret, _, _ = _run_git_command(
306
243
  ["show-ref", "--verify", "--quiet", f"refs/heads/{branch}"],
307
244
  cwd=project_root,
308
245
  )
309
246
  if ret == 0:
310
247
  log_info("Branch exists, checking out...")
311
- ret, _, err = run_git(
248
+ ret, _, err = _run_git_command(
312
249
  ["worktree", "add", worktree_path, branch], cwd=project_root
313
250
  )
314
251
  else:
315
252
  log_info(f"Creating new branch: {branch}")
316
- ret, _, err = run_git(
253
+ ret, _, err = _run_git_command(
317
254
  ["worktree", "add", "-b", branch, worktree_path], cwd=project_root
318
255
  )
319
256
 
@@ -326,7 +263,7 @@ def main() -> int:
326
263
  # Update task.json with worktree_path and base_branch
327
264
  task_data["worktree_path"] = worktree_path
328
265
  task_data["base_branch"] = base_branch
329
- write_json(task_json_path, task_data)
266
+ _write_json_file(task_json_path, task_data)
330
267
 
331
268
  # ----- Copy environment files -----
332
269
  log_info("Copying environment files...")
@@ -357,9 +294,6 @@ def main() -> int:
357
294
  shutil.copytree(str(task_dir_abs), str(task_target_dir))
358
295
  log_success("Task directory copied to worktree")
359
296
 
360
- # ----- Initialize submodules (before hooks, so hooks can use submodule content) -----
361
- _init_submodules_for_task(task_data, worktree_path, project_root)
362
-
363
297
  # ----- Run post_create hooks -----
364
298
  log_info("Running post_create hooks...")
365
299
  post_create = get_worktree_post_create_hooks(project_root)
@@ -381,9 +315,6 @@ def main() -> int:
381
315
  else:
382
316
  log_info(f"Step 1: Using existing worktree: {worktree_path}")
383
317
 
384
- # ----- Initialize submodules (idempotent, for reused worktrees) -----
385
- _init_submodules_for_task(task_data, worktree_path, project_root)
386
-
387
318
  # =============================================================================
388
319
  # Step 2: Set .current-task in Worktree
389
320
  # =============================================================================
@@ -403,7 +334,7 @@ def main() -> int:
403
334
 
404
335
  # Update task status
405
336
  task_data["status"] = "in_progress"
406
- write_json(task_json_path, task_data)
337
+ _write_json_file(task_json_path, task_data)
407
338
 
408
339
  log_file = Path(worktree_path) / ".agent-log"
409
340
  session_id_file = Path(worktree_path) / ".session-id"