@mindfoldhq/trellis 0.5.0-beta.9 → 0.5.0-rc.0

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 (192) hide show
  1. package/README.md +60 -95
  2. package/dist/cli/index.js +7 -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 +117 -117
  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 +289 -33
  10. package/dist/commands/update.js.map +1 -1
  11. package/dist/configurators/antigravity.d.ts.map +1 -1
  12. package/dist/configurators/antigravity.js +2 -8
  13. package/dist/configurators/antigravity.js.map +1 -1
  14. package/dist/configurators/claude.d.ts.map +1 -1
  15. package/dist/configurators/claude.js +4 -10
  16. package/dist/configurators/claude.js.map +1 -1
  17. package/dist/configurators/codebuddy.d.ts.map +1 -1
  18. package/dist/configurators/codebuddy.js +3 -3
  19. package/dist/configurators/codebuddy.js.map +1 -1
  20. package/dist/configurators/codex.d.ts.map +1 -1
  21. package/dist/configurators/codex.js +5 -13
  22. package/dist/configurators/codex.js.map +1 -1
  23. package/dist/configurators/copilot.d.ts.map +1 -1
  24. package/dist/configurators/copilot.js +5 -19
  25. package/dist/configurators/copilot.js.map +1 -1
  26. package/dist/configurators/cursor.d.ts.map +1 -1
  27. package/dist/configurators/cursor.js +3 -3
  28. package/dist/configurators/cursor.js.map +1 -1
  29. package/dist/configurators/droid.d.ts.map +1 -1
  30. package/dist/configurators/droid.js +3 -3
  31. package/dist/configurators/droid.js.map +1 -1
  32. package/dist/configurators/gemini.d.ts.map +1 -1
  33. package/dist/configurators/gemini.js +3 -5
  34. package/dist/configurators/gemini.js.map +1 -1
  35. package/dist/configurators/index.d.ts.map +1 -1
  36. package/dist/configurators/index.js +37 -49
  37. package/dist/configurators/index.js.map +1 -1
  38. package/dist/configurators/kilo.d.ts.map +1 -1
  39. package/dist/configurators/kilo.js +2 -8
  40. package/dist/configurators/kilo.js.map +1 -1
  41. package/dist/configurators/kiro.d.ts.map +1 -1
  42. package/dist/configurators/kiro.js +3 -3
  43. package/dist/configurators/kiro.js.map +1 -1
  44. package/dist/configurators/opencode.d.ts.map +1 -1
  45. package/dist/configurators/opencode.js +7 -4
  46. package/dist/configurators/opencode.js.map +1 -1
  47. package/dist/configurators/pi.d.ts +3 -0
  48. package/dist/configurators/pi.d.ts.map +1 -0
  49. package/dist/configurators/pi.js +44 -0
  50. package/dist/configurators/pi.js.map +1 -0
  51. package/dist/configurators/qoder.d.ts.map +1 -1
  52. package/dist/configurators/qoder.js +3 -5
  53. package/dist/configurators/qoder.js.map +1 -1
  54. package/dist/configurators/shared.d.ts +28 -6
  55. package/dist/configurators/shared.d.ts.map +1 -1
  56. package/dist/configurators/shared.js +47 -15
  57. package/dist/configurators/shared.js.map +1 -1
  58. package/dist/configurators/windsurf.d.ts.map +1 -1
  59. package/dist/configurators/windsurf.js +2 -8
  60. package/dist/configurators/windsurf.js.map +1 -1
  61. package/dist/constants/paths.d.ts +2 -0
  62. package/dist/constants/paths.d.ts.map +1 -1
  63. package/dist/constants/paths.js +2 -0
  64. package/dist/constants/paths.js.map +1 -1
  65. package/dist/migrations/manifests/0.5.0-beta.0.json +2 -0
  66. package/dist/migrations/manifests/0.5.0-beta.10.json +9 -0
  67. package/dist/migrations/manifests/0.5.0-beta.11.json +9 -0
  68. package/dist/migrations/manifests/0.5.0-beta.12.json +9 -0
  69. package/dist/migrations/manifests/0.5.0-beta.13.json +9 -0
  70. package/dist/migrations/manifests/0.5.0-beta.14.json +9 -0
  71. package/dist/migrations/manifests/0.5.0-beta.15.json +116 -0
  72. package/dist/migrations/manifests/0.5.0-beta.16.json +9 -0
  73. package/dist/migrations/manifests/0.5.0-beta.17.json +9 -0
  74. package/dist/migrations/manifests/0.5.0-beta.18.json +9 -0
  75. package/dist/migrations/manifests/0.5.0-beta.19.json +9 -0
  76. package/dist/migrations/manifests/0.5.0-beta.5.json +2 -0
  77. package/dist/migrations/manifests/0.5.0-rc.0.json +9 -0
  78. package/dist/templates/claude/agents/trellis-research.md +1 -1
  79. package/dist/templates/claude/settings.json +0 -4
  80. package/dist/templates/codebuddy/agents/trellis-research.md +1 -1
  81. package/dist/templates/codex/agents/trellis-research.toml +3 -2
  82. package/dist/templates/codex/hooks/session-start.py +126 -26
  83. package/dist/templates/codex/skills/finish-work/SKILL.md +41 -109
  84. package/dist/templates/codex/skills/start/SKILL.md +12 -9
  85. package/dist/templates/common/bundled-skills/trellis-meta/SKILL.md +73 -0
  86. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/add-project-local-conventions.md +83 -0
  87. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-agents.md +54 -0
  88. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-context-loading.md +81 -0
  89. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-hooks.md +57 -0
  90. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-skills-or-commands.md +78 -0
  91. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-spec-structure.md +83 -0
  92. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-task-lifecycle.md +90 -0
  93. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-workflow.md +64 -0
  94. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/overview.md +55 -0
  95. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/context-injection.md +68 -0
  96. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/generated-files.md +80 -0
  97. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/overview.md +51 -0
  98. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/spec-system.md +102 -0
  99. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/task-system.md +101 -0
  100. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/workflow.md +75 -0
  101. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/workspace-memory.md +71 -0
  102. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/agents.md +79 -0
  103. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/hooks-and-settings.md +69 -0
  104. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/overview.md +59 -0
  105. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md +74 -0
  106. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/skills-and-commands.md +83 -0
  107. package/dist/templates/common/commands/continue.md +9 -5
  108. package/dist/templates/common/commands/finish-work.md +34 -10
  109. package/dist/templates/common/index.d.ts +22 -2
  110. package/dist/templates/common/index.d.ts.map +1 -1
  111. package/dist/templates/common/index.js +53 -4
  112. package/dist/templates/common/index.js.map +1 -1
  113. package/dist/templates/common/skills/brainstorm.md +3 -0
  114. package/dist/templates/copilot/hooks/session-start.py +127 -30
  115. package/dist/templates/copilot/prompts/finish-work.prompt.md +44 -112
  116. package/dist/templates/copilot/prompts/start.prompt.md +12 -9
  117. package/dist/templates/cursor/agents/trellis-check.md +1 -1
  118. package/dist/templates/cursor/agents/trellis-implement.md +1 -1
  119. package/dist/templates/cursor/agents/trellis-research.md +2 -2
  120. package/dist/templates/cursor/hooks.json +7 -1
  121. package/dist/templates/droid/droids/trellis-research.md +1 -1
  122. package/dist/templates/extract.d.ts +6 -0
  123. package/dist/templates/extract.d.ts.map +1 -1
  124. package/dist/templates/extract.js +14 -0
  125. package/dist/templates/extract.js.map +1 -1
  126. package/dist/templates/gemini/agents/trellis-research.md +1 -1
  127. package/dist/templates/kiro/agents/trellis-research.json +1 -1
  128. package/dist/templates/markdown/agents.md +19 -12
  129. package/dist/templates/markdown/gitignore.txt +3 -0
  130. package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +24 -0
  131. package/dist/templates/opencode/agents/trellis-check.md +1 -1
  132. package/dist/templates/opencode/agents/trellis-implement.md +7 -4
  133. package/dist/templates/opencode/agents/trellis-research.md +2 -2
  134. package/dist/templates/opencode/lib/trellis-context.js +100 -13
  135. package/dist/templates/opencode/plugins/inject-subagent-context.js +70 -5
  136. package/dist/templates/opencode/plugins/inject-workflow-state.js +38 -58
  137. package/dist/templates/opencode/plugins/session-start.js +76 -31
  138. package/dist/templates/pi/agents/trellis-check.md +28 -0
  139. package/dist/templates/pi/agents/trellis-implement.md +33 -0
  140. package/dist/templates/pi/agents/trellis-research.md +25 -0
  141. package/dist/templates/pi/extensions/trellis/index.ts.txt +997 -0
  142. package/dist/templates/pi/index.d.ts +5 -0
  143. package/dist/templates/pi/index.d.ts.map +1 -0
  144. package/dist/templates/pi/index.js +12 -0
  145. package/dist/templates/pi/index.js.map +1 -0
  146. package/dist/templates/pi/settings.json +12 -0
  147. package/dist/templates/qoder/agents/trellis-research.md +1 -1
  148. package/dist/templates/shared-hooks/index.d.ts +31 -0
  149. package/dist/templates/shared-hooks/index.d.ts.map +1 -1
  150. package/dist/templates/shared-hooks/index.js +59 -0
  151. package/dist/templates/shared-hooks/index.js.map +1 -1
  152. package/dist/templates/shared-hooks/inject-shell-session-context.py +180 -0
  153. package/dist/templates/shared-hooks/inject-subagent-context.py +156 -27
  154. package/dist/templates/shared-hooks/inject-workflow-state.py +85 -105
  155. package/dist/templates/shared-hooks/session-start.py +222 -36
  156. package/dist/templates/trellis/gitignore.txt +3 -0
  157. package/dist/templates/trellis/index.d.ts +1 -0
  158. package/dist/templates/trellis/index.d.ts.map +1 -1
  159. package/dist/templates/trellis/index.js +2 -0
  160. package/dist/templates/trellis/index.js.map +1 -1
  161. package/dist/templates/trellis/scripts/common/__init__.py +8 -0
  162. package/dist/templates/trellis/scripts/common/active_task.py +593 -0
  163. package/dist/templates/trellis/scripts/common/cli_adapter.py +72 -14
  164. package/dist/templates/trellis/scripts/common/paths.py +61 -58
  165. package/dist/templates/trellis/scripts/common/session_context.py +12 -0
  166. package/dist/templates/trellis/scripts/common/task_context.py +27 -194
  167. package/dist/templates/trellis/scripts/common/task_store.py +102 -26
  168. package/dist/templates/trellis/scripts/common/tasks.py +4 -1
  169. package/dist/templates/trellis/scripts/common/workflow_phase.py +15 -3
  170. package/dist/templates/trellis/scripts/task.py +99 -34
  171. package/dist/templates/trellis/workflow.md +332 -69
  172. package/dist/types/ai-tools.d.ts +12 -3
  173. package/dist/types/ai-tools.d.ts.map +1 -1
  174. package/dist/types/ai-tools.js +29 -0
  175. package/dist/types/ai-tools.js.map +1 -1
  176. package/dist/utils/file-writer.d.ts.map +1 -1
  177. package/dist/utils/file-writer.js +7 -2
  178. package/dist/utils/file-writer.js.map +1 -1
  179. package/dist/utils/posix.d.ts +13 -0
  180. package/dist/utils/posix.d.ts.map +1 -0
  181. package/dist/utils/posix.js +15 -0
  182. package/dist/utils/posix.js.map +1 -0
  183. package/dist/utils/template-fetcher.d.ts +22 -6
  184. package/dist/utils/template-fetcher.d.ts.map +1 -1
  185. package/dist/utils/template-fetcher.js +405 -27
  186. package/dist/utils/template-fetcher.js.map +1 -1
  187. package/dist/utils/template-hash.d.ts +22 -3
  188. package/dist/utils/template-hash.d.ts.map +1 -1
  189. package/dist/utils/template-hash.js +99 -19
  190. package/dist/utils/template-hash.js.map +1 -1
  191. package/package.json +7 -7
  192. package/dist/templates/shared-hooks/statusline.py +0 -218
@@ -14,21 +14,55 @@ import { TrellisContext, contextCollector, debugLog } from "../lib/trellis-conte
14
14
 
15
15
  const PYTHON_CMD = platform() === "win32" ? "python" : "python3"
16
16
 
17
+ const FIRST_REPLY_NOTICE = `<first-reply-notice>
18
+ On the first visible assistant reply in this session, begin with exactly one short Chinese sentence:
19
+ Trellis SessionStart 已注入:workflow、当前任务状态、开发者身份、git 状态、active tasks、spec 索引已加载。
20
+ 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.
21
+ </first-reply-notice>`
22
+
23
+
24
+ /**
25
+ * Return true iff jsonl has at least one row with a `file` field.
26
+ * A freshly seeded jsonl only contains a `{"_example": ...}` row (no `file`
27
+ * key) — that is NOT "ready". Readiness requires at least one curated entry.
28
+ * Matches the contract used by `shared-hooks/inject-subagent-context.py`.
29
+ */
30
+ function hasCuratedJsonlEntry(jsonlPath) {
31
+ try {
32
+ const content = readFileSync(jsonlPath, "utf-8")
33
+ for (const rawLine of content.split(/\r?\n/)) {
34
+ const line = rawLine.trim()
35
+ if (!line) continue
36
+ try {
37
+ const row = JSON.parse(line)
38
+ if (row && typeof row === "object" && typeof row.file === "string" && row.file) {
39
+ return true
40
+ }
41
+ } catch {
42
+ // Ignore malformed line — move on.
43
+ }
44
+ }
45
+ } catch {
46
+ return false
47
+ }
48
+ return false
49
+ }
17
50
 
18
51
  /**
19
52
  * Check current task status and return structured status string.
20
53
  * JavaScript equivalent of _get_task_status in Claude's session-start.py.
21
54
  */
22
- function getTaskStatus(ctx) {
23
- const taskRef = ctx.getCurrentTask()
55
+ function getTaskStatus(ctx, platformInput = null) {
56
+ const active = ctx.getActiveTask(platformInput)
57
+ const taskRef = active.taskPath
24
58
  if (!taskRef) {
25
- return "Status: NO ACTIVE TASK\nNext: Describe what you want to work on"
59
+ return `Status: NO ACTIVE TASK\nSource: ${active.source}\nNext: Describe what you want to work on`
26
60
  }
27
61
 
28
62
  const taskDir = ctx.resolveTaskDir(taskRef)
29
63
 
30
- if (!taskDir || !existsSync(taskDir)) {
31
- return `Status: STALE POINTER\nTask: ${taskRef}\nNext: Task directory not found. Run: python3 ./.trellis/scripts/task.py finish`
64
+ if (active.stale || !taskDir || !existsSync(taskDir)) {
65
+ return `Status: STALE POINTER\nTask: ${taskRef}\nSource: ${active.source}\nNext: Task directory not found. Run: python3 ./.trellis/scripts/task.py finish`
32
66
  }
33
67
 
34
68
  let taskData = {}
@@ -46,43 +80,46 @@ function getTaskStatus(ctx) {
46
80
 
47
81
  if (taskStatus === "completed") {
48
82
  const dirName = basename(taskDir)
49
- return `Status: COMPLETED\nTask: ${taskTitle}\nNext: Archive with \`python3 ./.trellis/scripts/task.py archive ${dirName}\` or start a new task`
83
+ return `Status: COMPLETED\nTask: ${taskTitle}\nSource: ${active.source}\nNext: Archive with \`python3 ./.trellis/scripts/task.py archive ${dirName}\` or start a new task`
50
84
  }
51
85
 
52
86
  let hasContext = false
53
87
  for (const jsonlName of ["implement.jsonl", "check.jsonl"]) {
54
88
  const jsonlPath = join(taskDir, jsonlName)
55
- if (existsSync(jsonlPath)) {
56
- try {
57
- const st = statSync(jsonlPath)
58
- if (st.size > 0) {
59
- hasContext = true
60
- break
61
- }
62
- } catch {
63
- // Ignore stat errors
64
- }
89
+ if (existsSync(jsonlPath) && hasCuratedJsonlEntry(jsonlPath)) {
90
+ hasContext = true
91
+ break
65
92
  }
66
93
  }
67
94
 
68
95
  const hasPrd = existsSync(join(taskDir, "prd.md"))
69
96
 
70
97
  if (!hasPrd) {
71
- return `Status: NOT READY\nTask: ${taskTitle}\nMissing: prd.md not created\nNext: Write PRD, then research init-context start`
98
+ return `Status: NOT READY\nTask: ${taskTitle}\nSource: ${active.source}\nMissing: prd.md not created\nNext: Write PRD (see workflow.md Phase 1.1) then curate implement.jsonl per Phase 1.3`
72
99
  }
73
100
 
74
101
  if (!hasContext) {
75
- return `Status: NOT READY\nTask: ${taskTitle}\nMissing: Context not configured (no jsonl files)\nNext: Complete Phase 2 (research init-context start) before implementing`
102
+ return `Status: NOT READY\nTask: ${taskTitle}\nSource: ${active.source}\nMissing: implement.jsonl / check.jsonl missing or empty\nNext: Curate entries per workflow.md Phase 1.3 (spec + research files only), then \`task.py start\``
76
103
  }
77
104
 
78
- return `Status: READY\nTask: ${taskTitle}\nNext: Continue with implement or check`
105
+ return (
106
+ `Status: READY\nTask: ${taskTitle}\n` +
107
+ `Source: ${active.source}\n` +
108
+ "Next required action: dispatch `trellis-implement` per Phase 2.1. " +
109
+ "For agent-capable platforms, the default is to NOT edit code in the main session. " +
110
+ "After implementation, dispatch `trellis-check` per Phase 2.2 before reporting completion.\n" +
111
+ "User override (per-turn escape hatch): if the user's CURRENT message explicitly tells the " +
112
+ "main session to handle it directly (\"你直接改\" / \"别派 sub-agent\" / \"main session 写就行\" / " +
113
+ "\"do it inline\" / \"不用 sub-agent\"), honor it for this turn and edit code directly. " +
114
+ "Per-turn only; do NOT invent an override the user did not say."
115
+ )
79
116
  }
80
117
 
81
118
  /**
82
119
  * Load Trellis config for session-start decisions.
83
120
  * Calls get_context.py --mode packages --json for reliable config data.
84
121
  */
85
- function loadTrellisConfig(directory) {
122
+ function loadTrellisConfig(directory, contextKey = null) {
86
123
  const scriptPath = join(directory, ".trellis", "scripts", "get_context.py")
87
124
  if (!existsSync(scriptPath)) {
88
125
  return { isMonorepo: false, packages: {}, specScope: null, activeTaskPackage: null, defaultPackage: null }
@@ -93,6 +130,10 @@ function loadTrellisConfig(directory) {
93
130
  timeout: 5000,
94
131
  encoding: "utf-8",
95
132
  stdio: ["pipe", "pipe", "pipe"],
133
+ env: {
134
+ ...process.env,
135
+ ...(contextKey ? { TRELLIS_CONTEXT_ID: contextKey } : {}),
136
+ },
96
137
  })
97
138
  const data = JSON.parse(output)
98
139
  if (data.mode !== "monorepo") {
@@ -195,11 +236,14 @@ function resolveSpecScope(config) {
195
236
  /**
196
237
  * Build session context for injection
197
238
  */
198
- function buildSessionContext(ctx) {
239
+ export function buildSessionContext(ctx, platformInput = null) {
199
240
  const directory = ctx.directory
200
241
  const trellisDir = join(directory, ".trellis")
242
+ const contextKey = typeof ctx.getContextKey === "function"
243
+ ? ctx.getContextKey(platformInput)
244
+ : null
201
245
 
202
- const config = loadTrellisConfig(directory)
246
+ const config = loadTrellisConfig(directory, contextKey)
203
247
  const allowedPkgs = resolveSpecScope(config)
204
248
 
205
249
  const parts = []
@@ -209,6 +253,7 @@ function buildSessionContext(ctx) {
209
253
  You are starting a new session in a Trellis-managed project.
210
254
  Read and follow all instructions below carefully.
211
255
  </trellis-context>`)
256
+ parts.push(FIRST_REPLY_NOTICE)
212
257
 
213
258
  // Legacy migration warning
214
259
  const legacyWarning = checkLegacySpec(directory, config)
@@ -219,7 +264,7 @@ Read and follow all instructions below carefully.
219
264
  // 2. Current Context (dynamic)
220
265
  const contextScript = join(trellisDir, "scripts", "get_context.py")
221
266
  if (existsSync(contextScript)) {
222
- const output = ctx.runScript(contextScript)
267
+ const output = ctx.runScript(contextScript, undefined, contextKey)
223
268
  if (output) {
224
269
  parts.push("<current-state>")
225
270
  parts.push(output)
@@ -268,8 +313,7 @@ Read and follow all instructions below carefully.
268
313
  }
269
314
 
270
315
  // 4. Guidelines — paths-only for most indexes; guides/ inlined (cross-package,
271
- // broadly useful). Sub-agents get their specific specs via jsonl injection
272
- // main agent reads paths on demand when editing code directly.
316
+ // broadly useful). Sub-agents get their specific specs via jsonl injection.
273
317
  parts.push("<guidelines>")
274
318
  parts.push(
275
319
  "Project spec indexes are listed by path below. Each index contains a " +
@@ -278,8 +322,9 @@ Read and follow all instructions below carefully.
278
322
  "- If you're spawning an implement/check sub-agent, context is injected " +
279
323
  "automatically via `{task}/implement.jsonl` / `check.jsonl`. You do NOT " +
280
324
  "need to read these indexes yourself.\n" +
281
- "- If you're editing code directly in the main session, Read the relevant " +
282
- "index(es) on-demand and follow their Pre-Dev Checklist.\n"
325
+ "- For agent-capable platforms, do NOT edit code directly in the main " +
326
+ "session; dispatch `trellis-implement` and `trellis-check` so JSONL " +
327
+ "context is loaded by the sub-agents.\n"
283
328
  )
284
329
 
285
330
  const specDir = join(directory, ".trellis", "spec")
@@ -353,14 +398,14 @@ Read and follow all instructions below carefully.
353
398
  parts.push("</guidelines>")
354
399
 
355
400
  // 6. Task status
356
- const taskStatus = getTaskStatus(ctx)
401
+ const taskStatus = getTaskStatus(ctx, platformInput)
357
402
  parts.push(`<task-status>\n${taskStatus}\n</task-status>`)
358
403
 
359
404
  // 7. Final directive
360
405
  parts.push(`<ready>
361
406
  Context loaded. Workflow index, project state, and guidelines are already injected above — do NOT re-read them.
362
- Wait for the user's first message, then handle it following the workflow guide.
363
- If there is an active task, ask whether to continue it.
407
+ When the user sends the first message, follow <task-status> and the workflow guide.
408
+ If a task is READY, execute its Next required action without asking whether to continue.
364
409
  </ready>`)
365
410
 
366
411
  return parts.join("\n\n")
@@ -482,7 +527,7 @@ export default async ({ directory, client }) => {
482
527
  }
483
528
 
484
529
  // Build context
485
- const context = buildSessionContext(ctx)
530
+ const context = buildSessionContext(ctx, input)
486
531
  debugLog("session", "Built context, length:", context.length)
487
532
 
488
533
  // Inject context directly into output.parts so it gets persisted by updatePart
@@ -0,0 +1,28 @@
1
+ ---
2
+ name: trellis-check
3
+ description: |
4
+ Code quality check expert. Reviews changes against Trellis specs, fixes issues directly, and verifies quality gates.
5
+ tools: Read, Write, Edit, Bash, Glob, Grep
6
+ ---
7
+ # Check Agent
8
+
9
+ You are the Check Agent in the Trellis workflow.
10
+
11
+ ## Core Responsibilities
12
+
13
+ 1. Inspect the current git diff.
14
+ 2. Read and follow the spec and research files listed in the task's `check.jsonl`.
15
+ 3. Review all changed code against the task PRD and project specs.
16
+ 4. Fix issues directly when they are within scope.
17
+ 5. Run the relevant lint, typecheck, and focused tests available for the touched code.
18
+
19
+ ## Review Priorities
20
+
21
+ - Behavioral regressions and missing requirements.
22
+ - Spec or platform contract violations.
23
+ - Missing or weak tests for logic changes.
24
+ - Cross-platform path, command, and encoding assumptions.
25
+
26
+ ## Output
27
+
28
+ Report findings fixed, files changed, and verification results. If no issues remain, say that clearly.
@@ -0,0 +1,33 @@
1
+ ---
2
+ name: trellis-implement
3
+ description: |
4
+ Code implementation expert. Understands Trellis specs and requirements, then implements features. No git commit allowed.
5
+ tools: Read, Write, Edit, Bash, Glob, Grep
6
+ ---
7
+ # Implement Agent
8
+
9
+ You are the Implement Agent in the Trellis workflow.
10
+
11
+ ## Core Responsibilities
12
+
13
+ 1. Understand the active task requirements.
14
+ 2. Read and follow the spec and research files listed in the task's `implement.jsonl`.
15
+ 3. Implement the requested change using existing project patterns.
16
+ 4. Run the relevant lint, typecheck, and focused tests available for the touched code.
17
+ 5. Report files changed and verification results.
18
+
19
+ ## Forbidden Operations
20
+
21
+ Do not run:
22
+
23
+ - `git commit`
24
+ - `git push`
25
+ - `git merge`
26
+
27
+ ## Working Rules
28
+
29
+ - Read adjacent code and tests before editing.
30
+ - Keep changes scoped to the task.
31
+ - Do not revert unrelated user or concurrent changes.
32
+ - Fix root causes rather than masking symptoms.
33
+ - Prefer existing local helpers and platform patterns over new abstractions.
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: trellis-research
3
+ description: |
4
+ Code and technical research expert. Finds relevant files, patterns, docs, and persists findings to the current task's research/ directory.
5
+ tools: Read, Write, Bash, Glob, Grep
6
+ ---
7
+ # Research Agent
8
+
9
+ You are the Research Agent in the Trellis workflow.
10
+
11
+ ## Core Principle
12
+
13
+ Persist every finding to a file. Chat context is temporary; files under the task directory survive compaction and handoff.
14
+
15
+ ## Core Responsibilities
16
+
17
+ 1. Resolve the active task with `python3 ./.trellis/scripts/task.py current --source`.
18
+ 2. Create `<task-dir>/research/` when it does not exist.
19
+ 3. Search internal code, specs, and relevant external documentation.
20
+ 4. Write each distinct topic to `<task-dir>/research/<topic-slug>.md`.
21
+ 5. Report only file paths and concise summaries to the caller.
22
+
23
+ ## Scope Limits
24
+
25
+ Write only under the current task's `research/` directory. Do not edit code, specs, platform config, or task files outside research artifacts.