@mindfoldhq/trellis 0.5.0-beta.13 → 0.5.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/cli/index.js +1 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +24 -20
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +15 -12
- package/dist/commands/update.js.map +1 -1
- package/dist/configurators/claude.js +1 -1
- package/dist/configurators/claude.js.map +1 -1
- package/dist/configurators/codebuddy.js +1 -1
- package/dist/configurators/codebuddy.js.map +1 -1
- package/dist/configurators/codex.d.ts.map +1 -1
- package/dist/configurators/codex.js +3 -6
- package/dist/configurators/codex.js.map +1 -1
- package/dist/configurators/copilot.d.ts.map +1 -1
- package/dist/configurators/copilot.js +4 -11
- package/dist/configurators/copilot.js.map +1 -1
- package/dist/configurators/cursor.js +1 -1
- package/dist/configurators/cursor.js.map +1 -1
- package/dist/configurators/droid.js +1 -1
- package/dist/configurators/droid.js.map +1 -1
- package/dist/configurators/gemini.d.ts.map +1 -1
- package/dist/configurators/gemini.js +1 -3
- package/dist/configurators/gemini.js.map +1 -1
- package/dist/configurators/index.d.ts.map +1 -1
- package/dist/configurators/index.js +24 -38
- package/dist/configurators/index.js.map +1 -1
- package/dist/configurators/kiro.js +1 -1
- package/dist/configurators/kiro.js.map +1 -1
- package/dist/configurators/pi.d.ts +3 -0
- package/dist/configurators/pi.d.ts.map +1 -0
- package/dist/configurators/pi.js +39 -0
- package/dist/configurators/pi.js.map +1 -0
- package/dist/configurators/qoder.d.ts.map +1 -1
- package/dist/configurators/qoder.js +1 -3
- package/dist/configurators/qoder.js.map +1 -1
- package/dist/configurators/shared.d.ts +2 -4
- package/dist/configurators/shared.d.ts.map +1 -1
- package/dist/configurators/shared.js +6 -9
- package/dist/configurators/shared.js.map +1 -1
- package/dist/migrations/manifests/0.5.0-beta.14.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.15.json +126 -0
- package/dist/templates/claude/agents/trellis-research.md +1 -1
- package/dist/templates/claude/settings.json +0 -4
- package/dist/templates/codebuddy/agents/trellis-research.md +1 -1
- package/dist/templates/codex/agents/trellis-check.toml +0 -16
- package/dist/templates/codex/agents/trellis-implement.toml +0 -16
- package/dist/templates/codex/agents/trellis-research.toml +3 -2
- package/dist/templates/codex/hooks/session-start.py +82 -22
- package/dist/templates/codex/skills/start/SKILL.md +1 -1
- package/dist/templates/copilot/hooks/session-start.py +84 -26
- package/dist/templates/copilot/prompts/start.prompt.md +1 -1
- package/dist/templates/cursor/agents/trellis-check.md +1 -1
- package/dist/templates/cursor/agents/trellis-implement.md +1 -1
- package/dist/templates/cursor/agents/trellis-research.md +2 -2
- package/dist/templates/cursor/hooks.json +7 -1
- package/dist/templates/droid/droids/trellis-research.md +1 -1
- package/dist/templates/extract.d.ts +6 -0
- package/dist/templates/extract.d.ts.map +1 -1
- package/dist/templates/extract.js +14 -0
- package/dist/templates/extract.js.map +1 -1
- package/dist/templates/gemini/agents/trellis-research.md +1 -1
- package/dist/templates/kiro/agents/trellis-research.json +1 -1
- package/dist/templates/markdown/agents.md +11 -12
- package/dist/templates/markdown/gitignore.txt +3 -0
- package/dist/templates/opencode/agents/trellis-check.md +1 -1
- package/dist/templates/opencode/agents/trellis-implement.md +1 -1
- package/dist/templates/opencode/agents/trellis-research.md +2 -2
- package/dist/templates/opencode/lib/trellis-context.js +100 -13
- package/dist/templates/opencode/plugins/inject-subagent-context.js +54 -4
- package/dist/templates/opencode/plugins/inject-workflow-state.js +50 -23
- package/dist/templates/opencode/plugins/session-start.js +46 -21
- package/dist/templates/pi/agents/trellis-check.md +28 -0
- package/dist/templates/pi/agents/trellis-implement.md +33 -0
- package/dist/templates/pi/agents/trellis-research.md +25 -0
- package/dist/templates/pi/extensions/trellis/index.ts.txt +549 -0
- package/dist/templates/pi/index.d.ts +5 -0
- package/dist/templates/pi/index.d.ts.map +1 -0
- package/dist/templates/pi/index.js +12 -0
- package/dist/templates/pi/index.js.map +1 -0
- package/dist/templates/pi/settings.json +12 -0
- package/dist/templates/qoder/agents/trellis-research.md +1 -1
- package/dist/templates/shared-hooks/index.d.ts +31 -0
- package/dist/templates/shared-hooks/index.d.ts.map +1 -1
- package/dist/templates/shared-hooks/index.js +59 -0
- package/dist/templates/shared-hooks/index.js.map +1 -1
- package/dist/templates/shared-hooks/inject-shell-session-context.py +180 -0
- package/dist/templates/shared-hooks/inject-subagent-context.py +128 -26
- package/dist/templates/shared-hooks/inject-workflow-state.py +101 -61
- package/dist/templates/shared-hooks/session-start.py +151 -28
- package/dist/templates/trellis/gitignore.txt +3 -0
- package/dist/templates/trellis/index.d.ts +1 -0
- package/dist/templates/trellis/index.d.ts.map +1 -1
- package/dist/templates/trellis/index.js +2 -0
- package/dist/templates/trellis/index.js.map +1 -1
- package/dist/templates/trellis/scripts/common/__init__.py +8 -0
- package/dist/templates/trellis/scripts/common/active_task.py +593 -0
- package/dist/templates/trellis/scripts/common/cli_adapter.py +43 -8
- package/dist/templates/trellis/scripts/common/paths.py +61 -58
- package/dist/templates/trellis/scripts/common/session_context.py +12 -0
- package/dist/templates/trellis/scripts/common/task_store.py +4 -6
- package/dist/templates/trellis/scripts/task.py +56 -14
- package/dist/templates/trellis/workflow.md +31 -26
- package/dist/types/ai-tools.d.ts +3 -3
- package/dist/types/ai-tools.d.ts.map +1 -1
- package/dist/types/ai-tools.js +16 -0
- package/dist/types/ai-tools.js.map +1 -1
- package/dist/utils/template-fetcher.d.ts +22 -6
- package/dist/utils/template-fetcher.d.ts.map +1 -1
- package/dist/utils/template-fetcher.js +405 -27
- package/dist/utils/template-fetcher.js.map +1 -1
- package/dist/utils/template-hash.d.ts.map +1 -1
- package/dist/utils/template-hash.js +3 -2
- package/dist/utils/template-hash.js.map +1 -1
- package/package.json +1 -1
- package/dist/templates/shared-hooks/statusline.py +0 -218
|
@@ -14,6 +14,12 @@ 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
|
+
|
|
17
23
|
|
|
18
24
|
/**
|
|
19
25
|
* Return true iff jsonl has at least one row with a `file` field.
|
|
@@ -46,16 +52,17 @@ function hasCuratedJsonlEntry(jsonlPath) {
|
|
|
46
52
|
* Check current task status and return structured status string.
|
|
47
53
|
* JavaScript equivalent of _get_task_status in Claude's session-start.py.
|
|
48
54
|
*/
|
|
49
|
-
function getTaskStatus(ctx) {
|
|
50
|
-
const
|
|
55
|
+
function getTaskStatus(ctx, platformInput = null) {
|
|
56
|
+
const active = ctx.getActiveTask(platformInput)
|
|
57
|
+
const taskRef = active.taskPath
|
|
51
58
|
if (!taskRef) {
|
|
52
|
-
return
|
|
59
|
+
return `Status: NO ACTIVE TASK\nSource: ${active.source}\nNext: Describe what you want to work on`
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
const taskDir = ctx.resolveTaskDir(taskRef)
|
|
56
63
|
|
|
57
|
-
if (!taskDir || !existsSync(taskDir)) {
|
|
58
|
-
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`
|
|
59
66
|
}
|
|
60
67
|
|
|
61
68
|
let taskData = {}
|
|
@@ -73,7 +80,7 @@ function getTaskStatus(ctx) {
|
|
|
73
80
|
|
|
74
81
|
if (taskStatus === "completed") {
|
|
75
82
|
const dirName = basename(taskDir)
|
|
76
|
-
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`
|
|
77
84
|
}
|
|
78
85
|
|
|
79
86
|
let hasContext = false
|
|
@@ -88,21 +95,31 @@ function getTaskStatus(ctx) {
|
|
|
88
95
|
const hasPrd = existsSync(join(taskDir, "prd.md"))
|
|
89
96
|
|
|
90
97
|
if (!hasPrd) {
|
|
91
|
-
return `Status: NOT READY\nTask: ${taskTitle}\nMissing: prd.md not created\nNext: Write PRD (see workflow.md Phase 1.1) then curate implement.jsonl per Phase 1.3`
|
|
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`
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
if (!hasContext) {
|
|
95
|
-
return `Status: NOT READY\nTask: ${taskTitle}\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\``
|
|
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\``
|
|
96
103
|
}
|
|
97
104
|
|
|
98
|
-
return
|
|
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
|
+
)
|
|
99
116
|
}
|
|
100
117
|
|
|
101
118
|
/**
|
|
102
119
|
* Load Trellis config for session-start decisions.
|
|
103
120
|
* Calls get_context.py --mode packages --json for reliable config data.
|
|
104
121
|
*/
|
|
105
|
-
function loadTrellisConfig(directory) {
|
|
122
|
+
function loadTrellisConfig(directory, contextKey = null) {
|
|
106
123
|
const scriptPath = join(directory, ".trellis", "scripts", "get_context.py")
|
|
107
124
|
if (!existsSync(scriptPath)) {
|
|
108
125
|
return { isMonorepo: false, packages: {}, specScope: null, activeTaskPackage: null, defaultPackage: null }
|
|
@@ -113,6 +130,10 @@ function loadTrellisConfig(directory) {
|
|
|
113
130
|
timeout: 5000,
|
|
114
131
|
encoding: "utf-8",
|
|
115
132
|
stdio: ["pipe", "pipe", "pipe"],
|
|
133
|
+
env: {
|
|
134
|
+
...process.env,
|
|
135
|
+
...(contextKey ? { TRELLIS_CONTEXT_ID: contextKey } : {}),
|
|
136
|
+
},
|
|
116
137
|
})
|
|
117
138
|
const data = JSON.parse(output)
|
|
118
139
|
if (data.mode !== "monorepo") {
|
|
@@ -215,11 +236,14 @@ function resolveSpecScope(config) {
|
|
|
215
236
|
/**
|
|
216
237
|
* Build session context for injection
|
|
217
238
|
*/
|
|
218
|
-
function buildSessionContext(ctx) {
|
|
239
|
+
export function buildSessionContext(ctx, platformInput = null) {
|
|
219
240
|
const directory = ctx.directory
|
|
220
241
|
const trellisDir = join(directory, ".trellis")
|
|
242
|
+
const contextKey = typeof ctx.getContextKey === "function"
|
|
243
|
+
? ctx.getContextKey(platformInput)
|
|
244
|
+
: null
|
|
221
245
|
|
|
222
|
-
const config = loadTrellisConfig(directory)
|
|
246
|
+
const config = loadTrellisConfig(directory, contextKey)
|
|
223
247
|
const allowedPkgs = resolveSpecScope(config)
|
|
224
248
|
|
|
225
249
|
const parts = []
|
|
@@ -229,6 +253,7 @@ function buildSessionContext(ctx) {
|
|
|
229
253
|
You are starting a new session in a Trellis-managed project.
|
|
230
254
|
Read and follow all instructions below carefully.
|
|
231
255
|
</trellis-context>`)
|
|
256
|
+
parts.push(FIRST_REPLY_NOTICE)
|
|
232
257
|
|
|
233
258
|
// Legacy migration warning
|
|
234
259
|
const legacyWarning = checkLegacySpec(directory, config)
|
|
@@ -239,7 +264,7 @@ Read and follow all instructions below carefully.
|
|
|
239
264
|
// 2. Current Context (dynamic)
|
|
240
265
|
const contextScript = join(trellisDir, "scripts", "get_context.py")
|
|
241
266
|
if (existsSync(contextScript)) {
|
|
242
|
-
const output = ctx.runScript(contextScript)
|
|
267
|
+
const output = ctx.runScript(contextScript, undefined, contextKey)
|
|
243
268
|
if (output) {
|
|
244
269
|
parts.push("<current-state>")
|
|
245
270
|
parts.push(output)
|
|
@@ -288,8 +313,7 @@ Read and follow all instructions below carefully.
|
|
|
288
313
|
}
|
|
289
314
|
|
|
290
315
|
// 4. Guidelines — paths-only for most indexes; guides/ inlined (cross-package,
|
|
291
|
-
// broadly useful). Sub-agents get their specific specs via jsonl injection
|
|
292
|
-
// main agent reads paths on demand when editing code directly.
|
|
316
|
+
// broadly useful). Sub-agents get their specific specs via jsonl injection.
|
|
293
317
|
parts.push("<guidelines>")
|
|
294
318
|
parts.push(
|
|
295
319
|
"Project spec indexes are listed by path below. Each index contains a " +
|
|
@@ -298,8 +322,9 @@ Read and follow all instructions below carefully.
|
|
|
298
322
|
"- If you're spawning an implement/check sub-agent, context is injected " +
|
|
299
323
|
"automatically via `{task}/implement.jsonl` / `check.jsonl`. You do NOT " +
|
|
300
324
|
"need to read these indexes yourself.\n" +
|
|
301
|
-
"-
|
|
302
|
-
"
|
|
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"
|
|
303
328
|
)
|
|
304
329
|
|
|
305
330
|
const specDir = join(directory, ".trellis", "spec")
|
|
@@ -373,14 +398,14 @@ Read and follow all instructions below carefully.
|
|
|
373
398
|
parts.push("</guidelines>")
|
|
374
399
|
|
|
375
400
|
// 6. Task status
|
|
376
|
-
const taskStatus = getTaskStatus(ctx)
|
|
401
|
+
const taskStatus = getTaskStatus(ctx, platformInput)
|
|
377
402
|
parts.push(`<task-status>\n${taskStatus}\n</task-status>`)
|
|
378
403
|
|
|
379
404
|
// 7. Final directive
|
|
380
405
|
parts.push(`<ready>
|
|
381
406
|
Context loaded. Workflow index, project state, and guidelines are already injected above — do NOT re-read them.
|
|
382
|
-
|
|
383
|
-
If
|
|
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.
|
|
384
409
|
</ready>`)
|
|
385
410
|
|
|
386
411
|
return parts.join("\n\n")
|
|
@@ -502,7 +527,7 @@ export default async ({ directory, client }) => {
|
|
|
502
527
|
}
|
|
503
528
|
|
|
504
529
|
// Build context
|
|
505
|
-
const context = buildSessionContext(ctx)
|
|
530
|
+
const context = buildSessionContext(ctx, input)
|
|
506
531
|
debugLog("session", "Built context, length:", context.length)
|
|
507
532
|
|
|
508
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.
|