@pennixrv/trellis 0.7.2-beta.26 → 0.7.2-beta.27
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/dist/migrations/manifests/0.7.2-beta.27.json +8 -0
- package/dist/templates/codex/hooks/turn-guard.py +2 -1
- package/dist/templates/common/bundled-skills/trellis-decision-space-construction-and-merging/workflow.md +4 -2
- package/dist/templates/common/bundled-skills/trellis-delivery-review-and-closeout/workflow.md +11 -9
- package/dist/templates/common/bundled-skills/trellis-goal-exploration-and-requirements/workflow.md +1 -1
- package/dist/templates/common/bundled-skills/trellis-solution-design-and-convergence/workflow.md +7 -1
- package/dist/templates/common/bundled-skills/trellis-task-implementation/workflow.md +1 -1
- package/dist/templates/common/commands/continue.md +2 -2
- package/dist/templates/common/skills/request-intake.md +2 -0
- package/dist/templates/omp/extensions/trellis/index.ts.txt +16 -9
- package/dist/templates/opencode/plugins/inject-workflow-state.js +15 -7
- package/dist/templates/pi/extensions/trellis/index.ts.txt +9 -4
- package/dist/templates/shared-hooks/inject-shell-session-context.py +4 -1
- package/dist/templates/shared-hooks/inject-workflow-state.py +44 -27
- package/dist/templates/trellis/scripts/common/task_turn.py +69 -26
- package/dist/templates/trellis/scripts/common/task_workflow.py +289 -68
- package/dist/templates/trellis/scripts/common/workflow_selection.py +23 -38
- package/dist/templates/trellis/scripts/task.py +14 -4
- package/dist/templates/trellis/workflow.md +12 -2
- package/package.json +2 -2
|
@@ -35,7 +35,8 @@ def main() -> int:
|
|
|
35
35
|
"Before ending this request, record native exit evidence via a single direct "
|
|
36
36
|
"Python .trellis/scripts/task.py turn record command from the project root. "
|
|
37
37
|
"Use --kind and --evidence-ref; bounded_reply also needs --scope; waits need "
|
|
38
|
-
"--no-independent-work and --question
|
|
38
|
+
"--no-independent-work and --question; external_block uses --no-independent-work and --blocker. "
|
|
39
|
+
"Use turn record --help for current arguments. "
|
|
39
40
|
"A tool answer or passing local test is not completion. Continue independent "
|
|
40
41
|
"authorized work. This guard grants no permission or task-phase acceptance."}}
|
|
41
42
|
elif name == "PostToolUse":
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# 决策空间构造与归并阶段流程
|
|
2
2
|
|
|
3
|
+
先区分已证实无实质差异、有实质差异、事实尚缺。只在第一种情况据实省略;第二种用最短能解释差异的比较,只有依赖会改变下游选择才展开树;第三种先查会改变可行性或选择的事实,不把查不到包装成用户偏好。证据足够后移交剩余用户取舍,不凑候选或重复搜索。已启用覆盖校验的复杂路线,在结果的 `## 决策覆盖` 表按需求编号写 `接受条件 | 处置 | 证据`;证据指向任务内文件。编号齐全不代表取证或处置正确。
|
|
4
|
+
|
|
3
5
|
核对目标探索与需求核对阶段已确认的目标基线及当前 `artifact_revision`。判断候选差异、条件分支是否会影响交付、验收、风险或下游选择。若没有实质差异,可记录基线引用、跳过理由、解决方案设计与收敛阶段的最低输入和需要重新进入本阶段的变化条件,再由 Trellis CLI 核验跳过。
|
|
4
6
|
|
|
5
7
|
若本阶段处于 `waiting_user` 或 `blocked`,先核对真实答复或解除证据并写回,再通过原生 `phase resume` 恢复;重新核验 revision 后才更新、接受或跳过。不要在等待态直接 accept,也不因一项待决或局部证据完成而结束仍可继续的已授权工作。
|
|
6
8
|
|
|
7
9
|
需要构造时,梳理决策项及其权限、候选、重要排除项与理由;按需补齐证据、适用约束、标准、阈值、依赖、影响和优先级。证据足够时给出推荐;证据不足则保留未知或待决项,不伪造结论。仅当选择之间存在条件依赖时使用决策树,并标明分支条件、来源、未知路径及其下游影响。互斥、共享依赖或汇合关系可用依赖图;独立候选用比较表或清单即可。
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
候选尚未覆盖实质选择时,从不同机制、责任边界或运作方式拓宽,而非只列同一做法的参数变体;适用时纳入维持现状或不做。再以已确认约束、当前实现、外部先例及必要的有界探针筛选,区分不可行、代价较高与证据不足,保留排除理由及依赖后果。移交前核对重要默认与遗漏分支;不凑候选数量,不在没有新证据时追加轮次。目标变化回到目标探索与需求核对阶段,用户保留决定交给解决方案设计与收敛阶段,不由辅助 Skill 提前锁定。
|
|
10
12
|
|
|
11
13
|
新颖机制、重大重构、跨组件边界变化或关键取舍缺少可信本地先例时,进行有界的 `prior-art review`,记录适用性与采纳或排除理由。只读 Teamwork 可按需补充证据;主代理核验报告后归并。将 `DecisionSpace` 或有据跳过记录交由 Trellis CLI 接受,待用户决定交由解决方案设计与收敛阶段处理。
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
移交前,用实际使用、故障或交付场景检验会改变结论的假设,检查是否漏掉会改变行为、责任或验收的候选。优先核对可能改变比较结果的事实,记录重要替代机制及排除依据。缺少可行候选、证据或比较标准而无法比较时,留在本阶段补齐;候选已可比较、只剩用户取舍时,将候选、权衡、依赖和未决原因交给解决方案设计与收敛阶段,不替用户决定。达到该条件便停止扩展候选,不穷举理论分支,也不把没有就绪问题当作证据充分;原生接受后继续已授权工作,不把本阶段收敛误作整个用户请求结束。
|
|
14
16
|
|
|
15
17
|
```mermaid
|
|
16
18
|
flowchart TD
|
package/dist/templates/common/bundled-skills/trellis-delivery-review-and-closeout/workflow.md
CHANGED
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
实施、集成或必需验证缺陷回到任务实施与测试验证阶段;方案、合同、风险、依赖、回退或停止条件失效回到解决方案设计与收敛阶段;候选、标准或条件变化回到决策空间构造与归并阶段;目标、范围或接受目标变化回到目标探索与需求核对阶段。必要证据缺失时,暂停并停留在交付审查与现场收尾阶段;必要用户决定缺失时,通过 `pennix-decision-grill` 同步请求决定,答复前保持暂停,收到答复后重新核对当前输入和受影响阶段。当前合同内未完成工作不能改记为遗留后关闭。合同外、已明确延期或撤回后不继续的事项,可在现有收尾产物中记录范围、责任方、触发条件、影响和后续任务引用;没有遗留时不另造清单。
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
合同、用户明确要求或重大且不能代替用户承担的风险需要用户接受时,先直接询问,收到适用于当前交付的接受后再调用 `phase accept`。没有该要求不另加人工门。用户要求修改或拒绝时,使候选失效并按影响回流。`delivery_ready` 或 `no_go` 的阶段接受不等于 `complete`;先做仍可执行的归档前置,只在外部依赖确实阻断所有剩余操作时记录阻断。回执不明先读同一任务和原生布局,不盲目重放。
|
|
12
|
+
|
|
13
|
+
若用户明确撤回,走原生取消路线并记录原因。关联子任务逐项确定继续、独立或取消;继续保留关系,独立记录依据后解除,取消用子任务自己的流程。只核对实际涉及的外部执行资源;可能继续写入、泄露、造成数据风险或状态未知时保留现场,阻止 `complete` 或 `cancel`。
|
|
12
14
|
|
|
13
15
|
```mermaid
|
|
14
16
|
flowchart TD
|
|
@@ -18,20 +20,20 @@ flowchart TD
|
|
|
18
20
|
gaps -->|"方案或合同"| solution_design_and_convergence["回到解决方案设计与收敛阶段"]
|
|
19
21
|
gaps -->|"候选、标准或条件"| decision_space_construction_and_merging["回到决策空间构造与归并阶段"]
|
|
20
22
|
gaps -->|"目标、范围或接受目标"| goal_exploration_and_requirements["回到目标探索与需求核对阶段"]
|
|
21
|
-
gaps -->|"必要证据缺失"| wait["
|
|
22
|
-
gaps -->|"必要用户决定缺失"| decision_grill["
|
|
23
|
+
gaps -->|"必要证据缺失"| wait["补可查证据;只暂停依赖缺项的动作"]
|
|
24
|
+
gaps -->|"必要用户决定缺失"| decision_grill["同步问必要决定;继续不依赖答复的核验"]
|
|
23
25
|
decision_grill --> candidate
|
|
24
26
|
wait --> candidate
|
|
25
27
|
gaps -->|"无"| residual{"是否有可保留的合同外或已延期遗留?"}
|
|
26
28
|
residual -->|"是"| record["记录责任方、触发条件、影响和后续引用"]
|
|
27
|
-
residual -->|"否"|
|
|
28
|
-
record -->
|
|
29
|
-
accept
|
|
30
|
-
user_gate -->|"否"| ready["核验任务生命周期及适用资源后按条件 complete"]
|
|
29
|
+
residual -->|"否"| user_gate{"交付需要用户接受?"}
|
|
30
|
+
record --> user_gate
|
|
31
|
+
user_gate -->|"否"| accept["Trellis CLI 接受 delivery_ready 或 no_go"]
|
|
31
32
|
user_gate -->|"是"| ask_accept["pennix-decision-grill 同步请求用户接受"]
|
|
32
33
|
ask_accept --> answer{"用户答复是否明确?"}
|
|
33
|
-
answer -->|"接受"|
|
|
34
|
-
|
|
34
|
+
answer -->|"接受"| accept
|
|
35
|
+
accept --> ready["继续归档前置;按原生生命周期 complete"]
|
|
36
|
+
answer -->|"未答复或答复不清"| user_wait["不当作接受;继续独立核验"]
|
|
35
37
|
user_wait --> candidate
|
|
36
38
|
answer -->|"要求修订或拒绝"| invalidate["使当前交付候选失效并判断最早受影响阶段"]
|
|
37
39
|
invalidate -->|"实施、集成或验证"| task_implementation
|
package/dist/templates/common/bundled-skills/trellis-goal-exploration-and-requirements/workflow.md
CHANGED
|
@@ -16,7 +16,7 @@ flowchart TD
|
|
|
16
16
|
evidence --> baseline["整理目标、范围、成功条件与约束"]
|
|
17
17
|
baseline --> enough{"关键事实是否足以形成基线?"}
|
|
18
18
|
enough -->|"否,需用户补充"| ask["Trellis CLI 记录 needs_user_input;同步询问"]
|
|
19
|
-
ask --> wait["
|
|
19
|
+
ask --> wait["只暂停依赖答复的动作;继续独立取证"]
|
|
20
20
|
wait --> evidence
|
|
21
21
|
enough -->|"否,依赖阻断"| blocked["记录 blocked 与恢复条件"]
|
|
22
22
|
blocked -->|"依赖恢复后"| evidence
|
package/dist/templates/common/bundled-skills/trellis-solution-design-and-convergence/workflow.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# 解决方案设计与收敛阶段流程
|
|
2
2
|
|
|
3
|
+
按所选方案尚未处置的交付风险确定深度,不沿用决策空间构造与归并阶段的篇幅。局部、可逆且可直接验收的任务只保留最短合同;共享契约、数据、权限、发布、回退或不可逆后果确有影响时,只展开受影响部分,即使只有一个可行机制。问实施者还须猜什么、哪一步删去后约束、验收和恢复仍成立,据此增删。证据确实排除了原风险可缩短;仅重开受影响阶段。
|
|
4
|
+
|
|
5
|
+
已启用覆盖校验的复杂路线,验收覆盖表逐项使用目标探索与需求核对阶段已接受的编号。`analysis_conclusion` 或 `no_go` 仍使用 `## 验收覆盖`,但只写 `接受条件 | 结论 | 证据`,证据指向任务内文件,不造实施工作包。整体请批前运行 `task.py phase preflight <task> --outcome-kind <结果> --result-ref <当前产物>`。该检查只读,不是接受或批准;另从未用于支持方案的实际失败或边界反查验证对象、预期、失败动作及关键子约束。区分当前论据和实施后才会有的回执,不要求提前执行。
|
|
6
|
+
|
|
7
|
+
若宿主要求在普通文本请求整体批准,且已做完独立工作,可在原生回合记录中声明 `waiting_authorization`,以 `--approval-result-ref`、`--approval-artifact-revision` 和适用的 `--approval-outcome` 显式绑定刚核验的候选;这不是普通设计提问的要求。已经接受实施合同但只差实施批准时保留接受事实,不为等待而回流。若内容、路线或上游证据改变,旧批准不能授权新候选。
|
|
8
|
+
|
|
3
9
|
核对有效的目标基线、决策空间构造与归并阶段结果或跳过记录及其 revision。按依赖筛选影响目标、范围、成功条件、用户偏好、风险承受或重要取舍的保留决定;使用 `pennix-decision-grill` 同步提问。答复到达后,核对其权限、当前 revision 和影响范围:影响目标或范围时回到目标探索与需求核对阶段,影响候选、标准或依赖时回到决策空间构造与归并阶段,仅改变当前候选中的方案时继续本阶段评估。待决定事项使解决方案设计与收敛阶段保持待决。
|
|
4
10
|
|
|
5
11
|
真实答复或解除证据先写回;当前阶段为 `waiting_user` 或 `blocked` 时,先原生 `phase resume`,再核对 revision、修订产物及接受。不能在等待态直接 accept/authorize,不能把普通设计答复当成实施批准;已有整体批准仍有效时沿原生接口继续,不重复索取。需要宿主规定的普通文本批准时,直接提出绑定当前合同的明确问题,而非只报告“等待确认”;独立且已授权的步骤继续。
|
|
@@ -49,7 +55,7 @@ flowchart TD
|
|
|
49
55
|
assess -->|"deferred"| defer["记录恢复条件并留在解决方案设计与收敛阶段"]
|
|
50
56
|
assess -->|"implementation_contract"| contract["冻结必要实施合同"]
|
|
51
57
|
contract --> approval{"合同获接受且实施批准有效?"}
|
|
52
|
-
approval -->|"否"| wait["
|
|
58
|
+
approval -->|"否"| wait["直接问剩余必要决定或授权;仅暂停依赖动作,不进入实施"]
|
|
53
59
|
approval -->|"是"| task_implementation["Trellis CLI 核验并进入任务实施与测试验证阶段"]
|
|
54
60
|
reviewResult --> delivery_review_and_closeout["交付审查与现场收尾阶段"]
|
|
55
61
|
```
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
```mermaid
|
|
16
16
|
flowchart TD
|
|
17
17
|
contract["核验 implementation_contract、授权、revision 和依赖"] --> ready{"准入与实施授权有效?"}
|
|
18
|
-
ready -->|"否,待用户决定或依赖"| wait["
|
|
18
|
+
ready -->|"否,待用户决定或依赖"| wait["直接问必要决定或记录具体阻断;只暂停依赖动作"]
|
|
19
19
|
wait -->|"恢复后重新核验"| contract
|
|
20
20
|
ready -->|"是"| work["按合同依赖和优先级选取当前工作包"]
|
|
21
21
|
work --> implement["读取适用规范并实施最小变更"]
|
|
@@ -14,11 +14,11 @@ Follow the active phase breadcrumb to the matching bundled phase Skill and its w
|
|
|
14
14
|
|
|
15
15
|
Without hook context, use `{{PYTHON_CMD}} ./.trellis/scripts/task.py phase show <task>`
|
|
16
16
|
and explicitly read the applicable spec indexes and guidelines. If the route is
|
|
17
|
-
missing, inspect
|
|
17
|
+
missing, inspect the Goal Exploration and Requirements Confirmation Phase baseline and recorded authorization, choose the ordered
|
|
18
18
|
phases with evidence for omissions, then initialize through the native CLI.
|
|
19
19
|
Reuse existing confirmations; resume only the known unfinished action.
|
|
20
20
|
|
|
21
|
-
Task lifecycle status
|
|
21
|
+
Task lifecycle status, business phase and current implementation admission are separate. `in_progress` does not prove the current phase is implementation or that authorization survived a return. `task.py start` can bind the session without starting implementation. Read `phase show` and the lifecycle when the breadcrumb is absent or conflicts with the known task; an accepted closeout with no active phase still needs native `complete` or `cancel`. Resume from verified references without reloading unaffected history. `completed` and `cancelled` are terminal lifecycle states.
|
|
22
22
|
|
|
23
23
|
## Phase operations
|
|
24
24
|
|
|
@@ -10,6 +10,8 @@ To resume without new input, use trellis-continue and the current native task fa
|
|
|
10
10
|
|
|
11
11
|
Reuse verified evidence and existing authorization. Follow the taskless route in workflow.md only when all of these are true: the goal is clear; the scope and owner are bounded; risk is controlled; the user has authorized the actual action; success can be verified in the current session; and the work needs no persistent route, coordination, design, review, release, installation, migration, external delivery, or dedicated rollback plan. A bounded irreversible action additionally needs exact target verification, an acceptable recovery or loss boundary, and a stop condition. User authorization alone is not sufficient. Read-only inspection, bounded diagnosis, low-impact native-owner maintenance or cleanup, small single-surface edits, and rerunning existing checks are examples, not an allowlist. Intake ends when the request reaches its appropriate phase; do not repeat session initialization or conduct a second requirements or planning workflow here.
|
|
12
12
|
|
|
13
|
+
Routine self-review and verification do not by themselves require a task. Where Codex turn evidence is active, record a verified bounded maintenance or edit as `bounded_reply --scope maintenance`, with references to the actual action and its verification, not as inspection or task completion. An unrelated active task keeps its own state.
|
|
14
|
+
|
|
13
15
|
## Start the task
|
|
14
16
|
|
|
15
17
|
Choose auxiliary methods from the host's available Skills according to the actual business problem, including taskless requests. A clear match goes directly to that Skill; combinations or unclear ownership may use an available workflow router. Do not require the user to name a method, preload a collection, or create a task merely to use one. Method output returns to this intake or the current phase; it does not grant action permissions or replace Trellis acceptance and authorization.
|
|
@@ -202,7 +202,7 @@ function displayProjectPath(projectRoot: string, filePath: string, taskDir?: str
|
|
|
202
202
|
function resolveActiveTaskStatus(
|
|
203
203
|
projectRoot: string,
|
|
204
204
|
contextKey: string | null,
|
|
205
|
-
): { status: string; phaseStatus: string | null; taskDir: string | null; taskTitle: string | null } {
|
|
205
|
+
): { status: string; phaseStatus: string | null; lifecycle?: string; taskDir: string | null; taskTitle: string | null } {
|
|
206
206
|
const sessionsDir = join(projectRoot, ".trellis", ".runtime", "sessions");
|
|
207
207
|
if (!existsSync(sessionsDir)) return { status: "no_task", phaseStatus: null, taskDir: null, taskTitle: null };
|
|
208
208
|
|
|
@@ -264,15 +264,22 @@ function resolveActiveTaskStatus(
|
|
|
264
264
|
const phaseWorkflow = taskMeta && typeof taskMeta === "object" && !Array.isArray(taskMeta)
|
|
265
265
|
? (taskMeta as Record<string, unknown>).task_workflow as Record<string, unknown> | undefined
|
|
266
266
|
: undefined;
|
|
267
|
-
const
|
|
268
|
-
const phaseId = phaseWorkflow?.current_phase_id
|
|
267
|
+
const lifecycle = typeof taskData.status === "string" ? taskData.status : "planning";
|
|
268
|
+
const phaseId = phaseWorkflow?.current_phase_id;
|
|
269
269
|
const phaseMap = phaseWorkflow?.phases;
|
|
270
270
|
const phase = typeof phaseId === "string" && phaseMap && typeof phaseMap === "object" && !Array.isArray(phaseMap)
|
|
271
271
|
? (phaseMap as Record<string, Record<string, unknown>>)[phaseId]
|
|
272
272
|
: null;
|
|
273
|
+
const closeout = phaseMap && typeof phaseMap === "object"
|
|
274
|
+
? (phaseMap as Record<string, Record<string, unknown>>).delivery_review_and_closeout
|
|
275
|
+
: null;
|
|
276
|
+
const terminal = ["completed", "cancelled"].includes(lifecycle);
|
|
277
|
+
const pending = phaseId === null && closeout?.status === "accepted"
|
|
278
|
+
&& ["delivery_ready", "no_go", "cancelled"].includes(String(phaseWorkflow?.closeout_disposition));
|
|
273
279
|
return {
|
|
274
|
-
status: typeof phaseId === "string" && phase ? phaseId :
|
|
275
|
-
phaseStatus: typeof phase?.status === "string" ? phase.status : null,
|
|
280
|
+
status: terminal ? lifecycle : pending ? "closeout_pending" : typeof phaseId === "string" && phase ? phaseId : phaseWorkflow ? "task_error" : lifecycle,
|
|
281
|
+
phaseStatus: !terminal && typeof phase?.status === "string" ? phase.status : null,
|
|
282
|
+
lifecycle,
|
|
276
283
|
taskDir,
|
|
277
284
|
taskTitle: typeof taskData.title === "string" ? taskData.title : null,
|
|
278
285
|
};
|
|
@@ -820,14 +827,14 @@ class TurnContextCache {
|
|
|
820
827
|
return { workflowMsg: this.workflowMsg };
|
|
821
828
|
}
|
|
822
829
|
|
|
823
|
-
const { status, phaseStatus } = resolveActiveTaskStatus(projectRoot, contextKey);
|
|
830
|
+
const { status, phaseStatus, lifecycle } = resolveActiveTaskStatus(projectRoot, contextKey);
|
|
824
831
|
|
|
825
832
|
const workflowPath = join(projectRoot, ".trellis", "workflow.md");
|
|
826
833
|
let workflowMd = "";
|
|
827
834
|
try { workflowMd = readFileSync(workflowPath, "utf-8"); } catch { }
|
|
828
835
|
|
|
829
836
|
let workflowBody = "";
|
|
830
|
-
if (workflowMd) {
|
|
837
|
+
if (workflowMd && !/planning-inline|in_progress-inline|<codex-mode>|已配置时可使用宿主原生 agent 路径/.test(workflowMd)) {
|
|
831
838
|
const blocks = parseWorkflowStateBlocks(workflowMd);
|
|
832
839
|
const activeBlock = blocks.find((b) => b.status === status);
|
|
833
840
|
if (activeBlock) {
|
|
@@ -835,13 +842,13 @@ class TurnContextCache {
|
|
|
835
842
|
}
|
|
836
843
|
}
|
|
837
844
|
if (!workflowBody) {
|
|
838
|
-
workflowBody = "
|
|
845
|
+
workflowBody = "Workflow prompt unavailable; verify task.py phase show <task>.";
|
|
839
846
|
}
|
|
840
847
|
|
|
841
848
|
// When skip keyword is present, skip workflow state injection this turn
|
|
842
849
|
this.workflowMsg = this.skipThisTurn
|
|
843
850
|
? ""
|
|
844
|
-
: `<workflow-state>\n${phaseStatus ? `Phase: ${status} (${phaseStatus})\n` : ""}${workflowBody}\n</workflow-state>\n\n<session-overview>\n${SESSION_OVERVIEW_TEXT}\n</session-overview>`;
|
|
851
|
+
: `<workflow-state>\n${lifecycle ? `Lifecycle: ${lifecycle}\n` : ""}${phaseStatus ? `Phase: ${status} (${phaseStatus})\n` : ""}${workflowBody}\n</workflow-state>\n\n<session-overview>\n${SESSION_OVERVIEW_TEXT}\n</session-overview>`;
|
|
845
852
|
|
|
846
853
|
this.key = cacheKey;
|
|
847
854
|
this.timestamp = now;
|
|
@@ -230,6 +230,7 @@ function loadBreadcrumbs(workflowPath) {
|
|
|
230
230
|
} catch {
|
|
231
231
|
return {}
|
|
232
232
|
}
|
|
233
|
+
if (/planning-inline|in_progress-inline|<codex-mode>|已配置时可使用宿主原生 agent 路径/.test(content)) return {}
|
|
233
234
|
const result = {}
|
|
234
235
|
for (const match of content.matchAll(TAG_RE)) {
|
|
235
236
|
const status = match[1]
|
|
@@ -251,19 +252,26 @@ function getActiveTask(ctx, platformInput = null) {
|
|
|
251
252
|
return { id: taskRef.split("/").pop(), status: "stale", source: active.source }
|
|
252
253
|
}
|
|
253
254
|
const taskJsonPath = join(taskDir, "task.json")
|
|
254
|
-
if (!existsSync(taskJsonPath)) return
|
|
255
|
+
if (!existsSync(taskJsonPath)) return { id: taskRef.split("/").pop(), status: "task_error" }
|
|
255
256
|
try {
|
|
256
257
|
const data = JSON.parse(readFileSync(taskJsonPath, "utf-8"))
|
|
257
258
|
const status = typeof data.status === "string" ? data.status : ""
|
|
258
259
|
if (!status) return null
|
|
259
260
|
const phaseWorkflow = data.meta?.task_workflow
|
|
260
261
|
const phases = phaseWorkflow?.phases
|
|
261
|
-
const phaseId = phaseWorkflow?.current_phase_id
|
|
262
|
+
const phaseId = phaseWorkflow?.current_phase_id
|
|
262
263
|
const phase = typeof phaseId === "string" ? phases?.[phaseId] : null
|
|
263
264
|
const id = data.id || taskRef.split("/").pop()
|
|
265
|
+
if (["completed", "cancelled"].includes(status)) return { id, status }
|
|
264
266
|
if (typeof phaseId === "string" && phase && typeof phase.status === "string") {
|
|
265
|
-
return { id, status: phaseId, phaseStatus: phase.status, source: active.source }
|
|
267
|
+
return { id, status: phaseId, lifecycle: status, phaseStatus: phase.status, source: active.source }
|
|
266
268
|
}
|
|
269
|
+
if (phaseWorkflow?.current_phase_id === null &&
|
|
270
|
+
phases?.delivery_review_and_closeout?.status === "accepted" &&
|
|
271
|
+
["delivery_ready", "no_go", "cancelled"].includes(phaseWorkflow.closeout_disposition)) {
|
|
272
|
+
return { id, status: "closeout_pending", lifecycle: status }
|
|
273
|
+
}
|
|
274
|
+
if (data.meta && "task_workflow" in data.meta) return { id, status: "task_error", lifecycle: status }
|
|
267
275
|
return { id, status, source: active.source }
|
|
268
276
|
} catch {
|
|
269
277
|
return null
|
|
@@ -277,17 +285,17 @@ function getActiveTask(ctx, platformInput = null) {
|
|
|
277
285
|
* "Refer to workflow.md for current step." line
|
|
278
286
|
* - no_task pseudo-status (id === null) → header omits task info
|
|
279
287
|
*/
|
|
280
|
-
function buildBreadcrumb(id, status, templates, phaseStatus = null) {
|
|
288
|
+
function buildBreadcrumb(id, status, templates, phaseStatus = null, lifecycle = null) {
|
|
281
289
|
let body = templates[status]
|
|
282
290
|
if (body === undefined) {
|
|
283
|
-
body = "Refer to workflow.md for current step."
|
|
291
|
+
body = "Refer to workflow.md for current step. Verify unavailable workflow context with task.py phase show <task>."
|
|
284
292
|
}
|
|
285
293
|
const header = id === null
|
|
286
294
|
? `Status: ${status}`
|
|
287
295
|
: phaseStatus
|
|
288
296
|
? `Task: ${id}\nPhase: ${status} (${phaseStatus})`
|
|
289
297
|
: `Task: ${id} (${status})`
|
|
290
|
-
return `<workflow-state>\n${header}\n${body}\n</workflow-state>`
|
|
298
|
+
return `<workflow-state>\n${header}${lifecycle ? `\nLifecycle: ${lifecycle}` : ""}\n${body}\n</workflow-state>`
|
|
291
299
|
}
|
|
292
300
|
|
|
293
301
|
// OpenCode 1.2.x expects plugins to be factory functions (see the native plugin factory contract).
|
|
@@ -323,7 +331,7 @@ export default async ({ directory }) => {
|
|
|
323
331
|
const templates = loadBreadcrumbs(resolveWorkflowMd(ctx, directory, platformInput))
|
|
324
332
|
const task = getActiveTask(ctx, platformInput)
|
|
325
333
|
const breadcrumb = task
|
|
326
|
-
? buildBreadcrumb(task.id, task.status, templates, task.phaseStatus)
|
|
334
|
+
? buildBreadcrumb(task.id, task.status, templates, task.phaseStatus, task.lifecycle)
|
|
327
335
|
: buildBreadcrumb(null, "no_task", templates)
|
|
328
336
|
|
|
329
337
|
prependEphemeralText(messages, breadcrumb)
|
|
@@ -471,7 +471,9 @@ const WF_RE =
|
|
|
471
471
|
/\[workflow-state:([A-Za-z0-9_-]+)\]\s*\n([\s\S]*?)\n\s*\[\/workflow-state:\1\]/g;
|
|
472
472
|
function workflowBreadcrumb(root: string, key: string | null): string {
|
|
473
473
|
const wf = readText(resolveWorkflowMd(root, key));
|
|
474
|
-
if (!wf)
|
|
474
|
+
if (!wf || /planning-inline|in_progress-inline|<codex-mode>|已配置时可使用宿主原生 agent 路径/.test(wf)) {
|
|
475
|
+
return "<workflow-state>\nWorkflow source unavailable; verify task.py phase show <task>.\n</workflow-state>";
|
|
476
|
+
}
|
|
475
477
|
const templates: Record<string, string> = {};
|
|
476
478
|
for (const m of wf.matchAll(WF_RE)) {
|
|
477
479
|
const s = m[1] ?? "",
|
|
@@ -491,15 +493,18 @@ function workflowBreadcrumb(root: string, key: string | null): string {
|
|
|
491
493
|
lookup = status;
|
|
492
494
|
}
|
|
493
495
|
const meta = d.meta as JsonObject | undefined;
|
|
494
|
-
if (isObj(meta) && "task_workflow" in meta) {
|
|
496
|
+
if (!["completed", "cancelled"].includes(status) && isObj(meta) && "task_workflow" in meta) {
|
|
495
497
|
const state = meta.task_workflow;
|
|
496
|
-
const
|
|
497
|
-
const phase = isObj(state) && str(state.current_phase_id === null ? routed.at(-1) : state.current_phase_id);
|
|
498
|
+
const phase = isObj(state) && str(state.current_phase_id);
|
|
498
499
|
const phases = isObj(state) && isObj(state.phases) ? state.phases : null;
|
|
499
500
|
const record = phase && phases?.[phase];
|
|
500
501
|
if (phase && isObj(record) && str(record.status)) {
|
|
501
502
|
lookup = phase;
|
|
502
503
|
header += `; phase=${phase}; state=${str(record.status) ?? "unknown"}`;
|
|
504
|
+
} else if (isObj(state) && state.current_phase_id === null && isObj(phases?.delivery_review_and_closeout)
|
|
505
|
+
&& phases.delivery_review_and_closeout.status === "accepted"
|
|
506
|
+
&& ["delivery_ready", "no_go", "cancelled"].includes(str(state.closeout_disposition) ?? "")) {
|
|
507
|
+
lookup = "closeout_pending";
|
|
503
508
|
} else {
|
|
504
509
|
lookup = "task_error";
|
|
505
510
|
}
|
|
@@ -265,7 +265,10 @@ def main() -> int:
|
|
|
265
265
|
|
|
266
266
|
command, response = _pending_shell_command(hook_input)
|
|
267
267
|
platform_name = _host_platform_name()
|
|
268
|
-
if platform_name == "codex" and re.
|
|
268
|
+
if platform_name == "codex" and re.match(
|
|
269
|
+
r"""^\s*(?:["']?[^ \t"']*/)?python(?:3)?["']?\s+(?:-X\s+utf8\s+)?(?:"[^"]*task\.py"|'[^']*task\.py'|[^ \t]+task\.py)\s+turn\b""",
|
|
270
|
+
command,
|
|
271
|
+
):
|
|
269
272
|
if hook_input.get("agent_id") is not None:
|
|
270
273
|
return 0
|
|
271
274
|
root = _resolve_trellis_root(hook_input)
|
|
@@ -163,7 +163,7 @@ def _resolve_active_task(root: Path, input_data: dict):
|
|
|
163
163
|
|
|
164
164
|
def get_active_task(
|
|
165
165
|
root: Path, input_data: dict
|
|
166
|
-
) -> tuple[str, str, str, str | None] | None:
|
|
166
|
+
) -> tuple[str, str, str, str | None, str | None] | None:
|
|
167
167
|
"""Return active task data, a task-record error, or no task pointer.
|
|
168
168
|
|
|
169
169
|
``(task_id, "task_error", source)`` is distinct from ``None``: a session
|
|
@@ -179,39 +179,42 @@ def get_active_task(
|
|
|
179
179
|
if not task_dir.is_absolute():
|
|
180
180
|
task_dir = root / task_dir
|
|
181
181
|
if active.stale:
|
|
182
|
-
return task_dir.name, f"stale_{active.source_type}", active.source, None
|
|
182
|
+
return task_dir.name, f"stale_{active.source_type}", active.source, None, None
|
|
183
183
|
|
|
184
184
|
task_json = task_dir / "task.json"
|
|
185
185
|
if not task_json.is_file():
|
|
186
|
-
return task_dir.name, "task_error", active.source, None
|
|
186
|
+
return task_dir.name, "task_error", active.source, None, None
|
|
187
187
|
try:
|
|
188
188
|
data = json.loads(task_json.read_text(encoding="utf-8"))
|
|
189
189
|
except (json.JSONDecodeError, OSError):
|
|
190
|
-
return task_dir.name, "task_error", active.source, None
|
|
190
|
+
return task_dir.name, "task_error", active.source, None, None
|
|
191
191
|
if not isinstance(data, dict):
|
|
192
|
-
return task_dir.name, "task_error", active.source, None
|
|
192
|
+
return task_dir.name, "task_error", active.source, None, None
|
|
193
193
|
|
|
194
194
|
task_id = data.get("id") or task_dir.name
|
|
195
195
|
status = data.get("status", "")
|
|
196
196
|
if not isinstance(status, str) or not status:
|
|
197
|
-
return task_dir.name, "task_error", active.source, None
|
|
197
|
+
return task_dir.name, "task_error", active.source, None, None
|
|
198
|
+
if status in {"completed", "cancelled"}:
|
|
199
|
+
return task_id, status, active.source, None, None
|
|
198
200
|
meta = data.get("meta")
|
|
199
201
|
if isinstance(meta, dict) and "task_workflow" in meta:
|
|
200
202
|
phase_workflow = meta["task_workflow"]
|
|
201
203
|
if not isinstance(phase_workflow, dict):
|
|
202
|
-
return task_id, "task_error", active.source, None
|
|
204
|
+
return task_id, "task_error", active.source, None, status
|
|
203
205
|
phase_id = phase_workflow.get("current_phase_id")
|
|
204
206
|
phases = phase_workflow.get("phases")
|
|
205
207
|
if phase_id is None:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
+
closeout = phases.get("delivery_review_and_closeout") if isinstance(phases, dict) else None
|
|
209
|
+
if isinstance(closeout, dict) and closeout.get("status") == "accepted" and phase_workflow.get("closeout_disposition") in {"delivery_ready", "no_go", "cancelled"}:
|
|
210
|
+
return task_id, "closeout_pending", active.source, None, status
|
|
208
211
|
phase = phases.get(phase_id) if isinstance(phases, dict) and isinstance(phase_id, str) else None
|
|
209
212
|
if isinstance(phase_id, str) and isinstance(phase, dict):
|
|
210
213
|
phase_status = phase.get("status")
|
|
211
214
|
if isinstance(phase_status, str) and phase_status:
|
|
212
|
-
return task_id, phase_id, active.source, phase_status
|
|
213
|
-
return task_id, "task_error", active.source, None
|
|
214
|
-
return task_id, status, active.source, None
|
|
215
|
+
return task_id, phase_id, active.source, phase_status, status
|
|
216
|
+
return task_id, "task_error", active.source, None, status
|
|
217
|
+
return task_id, status, active.source, None, None
|
|
215
218
|
|
|
216
219
|
|
|
217
220
|
# ---------------------------------------------------------------------------
|
|
@@ -225,25 +228,33 @@ _TAG_RE = re.compile(
|
|
|
225
228
|
re.DOTALL,
|
|
226
229
|
)
|
|
227
230
|
|
|
228
|
-
def _resolve_workflow_md(root: Path, input_data: dict) -> Path:
|
|
229
|
-
"""
|
|
230
|
-
|
|
231
|
-
The per-task resolution rule lives in common.workflow_selection inside
|
|
232
|
-
.trellis/scripts. Older installed projects may not ship that module, and
|
|
233
|
-
hooks must never crash the session — ANY failure (import error, old
|
|
234
|
-
scripts tree, resolver bug) falls back to the global workflow.md.
|
|
235
|
-
"""
|
|
231
|
+
def _resolve_workflow_md(root: Path, input_data: dict) -> Path | None:
|
|
232
|
+
"""Use the native selector; only projects predating it use legacy lookup."""
|
|
236
233
|
try:
|
|
237
234
|
scripts_dir = root / ".trellis" / "scripts"
|
|
238
235
|
if str(scripts_dir) not in sys.path:
|
|
239
236
|
sys.path.insert(0, str(scripts_dir))
|
|
240
237
|
from common.workflow_selection import resolve_workflow_md # type: ignore[import-not-found]
|
|
241
238
|
|
|
239
|
+
except ModuleNotFoundError as error:
|
|
240
|
+
if error.name not in {"common", "common.workflow_selection"}:
|
|
241
|
+
return None
|
|
242
|
+
candidate = root / ".trellis" / "workflow.md"
|
|
243
|
+
try:
|
|
244
|
+
if re.search(r"planning-inline|in_progress-inline|<codex-mode>|已配置时可使用宿主原生 agent 路径",
|
|
245
|
+
candidate.read_text(encoding="utf-8")):
|
|
246
|
+
return None
|
|
247
|
+
except (OSError, UnicodeError):
|
|
248
|
+
return None
|
|
249
|
+
return candidate
|
|
250
|
+
except ImportError:
|
|
251
|
+
return None
|
|
252
|
+
try:
|
|
242
253
|
return resolve_workflow_md(
|
|
243
254
|
root, input_data, platform=_detect_platform(input_data)
|
|
244
255
|
)
|
|
245
|
-
except
|
|
246
|
-
return
|
|
256
|
+
except (OSError, ValueError):
|
|
257
|
+
return None
|
|
247
258
|
|
|
248
259
|
|
|
249
260
|
def load_breadcrumbs(root: Path, input_data: dict) -> dict[str, str]:
|
|
@@ -259,11 +270,11 @@ def load_breadcrumbs(root: Path, input_data: dict) -> dict[str, str]:
|
|
|
259
270
|
reads the global .trellis/workflow.md exactly as before.
|
|
260
271
|
"""
|
|
261
272
|
workflow = _resolve_workflow_md(root, input_data)
|
|
262
|
-
if not workflow.is_file():
|
|
273
|
+
if workflow is None or not workflow.is_file():
|
|
263
274
|
return {}
|
|
264
275
|
try:
|
|
265
276
|
content = workflow.read_text(encoding="utf-8")
|
|
266
|
-
except OSError:
|
|
277
|
+
except (OSError, UnicodeError):
|
|
267
278
|
return {}
|
|
268
279
|
|
|
269
280
|
result: dict[str, str] = {}
|
|
@@ -338,6 +349,7 @@ def build_breadcrumb(
|
|
|
338
349
|
templates: dict[str, str],
|
|
339
350
|
source: str | None = None,
|
|
340
351
|
phase_status: str | None = None,
|
|
352
|
+
lifecycle: str | None = None,
|
|
341
353
|
) -> str:
|
|
342
354
|
"""Build the <workflow-state>...</workflow-state> block.
|
|
343
355
|
|
|
@@ -347,14 +359,18 @@ def build_breadcrumb(
|
|
|
347
359
|
- `no_task` pseudo-status (task_id is None) → header omits task info
|
|
348
360
|
"""
|
|
349
361
|
body = templates.get(status)
|
|
350
|
-
if
|
|
351
|
-
body = "Refer to workflow.md
|
|
362
|
+
if templates == {}:
|
|
363
|
+
body = "Refer to workflow.md only after verifying the native workflow source. With a task, inspect `task.py phase show <task>` first."
|
|
364
|
+
elif body is None:
|
|
365
|
+
body = "Refer to workflow.md for current step. If the current phase has no matching prompt, verify it with `task.py phase show <task>`."
|
|
352
366
|
if task_id is None:
|
|
353
367
|
header = f"Status: {status}"
|
|
354
368
|
elif phase_status:
|
|
355
369
|
header = f"Task: {task_id}\nPhase: {status} ({phase_status})"
|
|
356
370
|
else:
|
|
357
371
|
header = f"Task: {task_id} ({status})"
|
|
372
|
+
if lifecycle is not None:
|
|
373
|
+
header += f"\nLifecycle: {lifecycle}"
|
|
358
374
|
return f"<workflow-state>\n{header}\n{body}\n</workflow-state>"
|
|
359
375
|
|
|
360
376
|
|
|
@@ -435,11 +451,12 @@ def main() -> int:
|
|
|
435
451
|
None, "no_task", templates
|
|
436
452
|
)
|
|
437
453
|
else:
|
|
438
|
-
task_id, status, source, phase_status = task
|
|
454
|
+
task_id, status, source, phase_status, lifecycle = task
|
|
439
455
|
source_for_breadcrumb = None if platform == "codex" else source
|
|
440
456
|
breadcrumb = build_breadcrumb(
|
|
441
457
|
task_id, status, templates, source_for_breadcrumb,
|
|
442
458
|
phase_status=phase_status,
|
|
459
|
+
lifecycle=lifecycle,
|
|
443
460
|
)
|
|
444
461
|
if platform == "codex":
|
|
445
462
|
parts: list[str] = []
|