@aipper/aiws-spec 0.0.40 → 0.0.41

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.
@@ -249,7 +249,139 @@ ws_goal:
249
249
  <每次迭代更新,记录做了什么、什么阻塞、进度百分比>
250
250
  ```
251
251
 
252
- ### 3.2 Evidence Type Registry
252
+ ### 3.2 Intake State
253
+
254
+ #### 3.2.1 用途
255
+
256
+ 在 PHASE 0(INTAKE)期间记录机器可读状态,填补"ws-goal 开始 intake"到"创建 goal state.json"之间的持久化空白。避免 session 在 intake 阶段被中断后,恢复时无法检测到进行中的 work。
257
+
258
+ #### 3.2.2 文件路径
259
+
260
+ `.aiws/intake/<intake-id>.state.json`
261
+
262
+ `<intake-id>` 与对应的 `.aiws/plan/<timestamp>-<slug>.intake.md` 文件 slug 一致。
263
+
264
+ #### 3.2.3 Schema
265
+
266
+ ```json
267
+ {
268
+ "$schema": "ws-goal-intake-schema.json",
269
+ "version": "1",
270
+ "intake_id": "<intake-id>",
271
+ "status": "in_progress",
272
+ "max_idle_minutes": 30,
273
+ "created_at": "<ISO 8601>",
274
+ "updated_at": "<ISO 8601>",
275
+ "questions": {
276
+ "total": 7,
277
+ "frozen": 1,
278
+ "open": 6,
279
+ "items": [
280
+ { "id": "Q1", "title": "目标用户是谁?", "status": "frozen", "frozen_at": "<ISO 8601>", "answer_summary": "开发者,macOS 用户" },
281
+ { "id": "Q2", "title": "目标用户的网络环境是什么?", "status": "in_progress", "frozen_at": null, "answer_summary": null }
282
+ ]
283
+ },
284
+ "current_question": "Q2: 目标用户的网络环境是什么?",
285
+ "background_tasks": [
286
+ {
287
+ "task_id": "bg_abc123",
288
+ "type": "librarian",
289
+ "description": "Explore ClashX.Meta repo architecture",
290
+ "started_at": "<ISO 8601>",
291
+ "status": "running"
292
+ }
293
+ ],
294
+ "last_error": null,
295
+ "session_metadata": {
296
+ "last_agent": "user",
297
+ "message_count": 42,
298
+ "last_activity_at": "<ISO 8601>"
299
+ }
300
+ }
301
+ ```
302
+
303
+ #### 3.2.4 字段说明
304
+
305
+ | 字段 | 类型 | 说明 |
306
+ |---|---|---|
307
+ | `intake_id` | string | 对应 `.aiws/plan/<timestamp>-<slug>.intake.md` 的 slug 部分 |
308
+ | `status` | enum | `pending` \| `in_progress` \| `paused` \| `complete` \| `archived` \| `timed_out` |
309
+ | `max_idle_minutes` | number | 后台任务空闲超时阈值(分钟,默认 30)。ws-goal step 0 发现 background task 的 started_at 超过此阈值时自动标记为 timed_out |
310
+ | `questions.total` | number | intake 问题总数 |
311
+ | `questions.frozen` | number | 已冻结(已回答并确认)的问题数(status=frozen) |
312
+ | `questions.open` | number | 待回答的问题数 |
313
+ | `questions.items[]` | object[] | 逐问题详情列表,用于问题级恢复展示。可选,有值时 total/frozen/open 必须与 items 派生值一致 |
314
+ | `questions.items[].id` | string | 问题标识,如 Q1、Q2 |
315
+ | `questions.items[].title` | string | 问题标题,用于恢复时展示 |
316
+ | `questions.items[].status` | enum | `pending` \| `in_progress` \| `frozen` \| `skipped` |
317
+ | `questions.items[].frozen_at` | string \| null | 冻结时间(若 status=frozen) |
318
+ | `questions.items[].answer_summary` | string \| null | 回答摘要,供跨 session 上下文保留 |
319
+ | `current_question` | string \| null | 当前正在处理的问题,恢复时定位位置 |
320
+ | `background_tasks[]` | object[] | 已启动的 subagent 任务追踪 |
321
+ | `last_error` | string \| null | 最近的错误信息 |
322
+ | `session_metadata` | object | 调试辅助,无程序化依赖 |
323
+
324
+ #### 3.2.5 状态机
325
+
326
+ ```
327
+ pending → in_progress → complete → archived
328
+ → paused(用户主动暂停)
329
+ → timed_out(超时检测:后台任务超过 max_idle_minutes 无响应)
330
+ ```
331
+
332
+ - **pending**:state.json 已创建但 intake 尚未正式开始。用于 crash 恢复时区分"刚创建还没开始"和"已经卡住了"
333
+ - **in_progress**:intake 正在执行中,可能有 frozen 问题进度
334
+ - **paused**:用户主动暂停 intake
335
+ - **timed_out**:系统在下一 session 的 step 0 检测时自动标记。背景任务超过 `max_idle_minutes` 无更新。Auto-resume 行为与 in_progress 相同,但附加超时警告通知
336
+ - **complete**:intake 全部问题已冻结
337
+ - **archived**:最终状态,已移动到 `archive/` 子目录
338
+
339
+ #### 3.2.6 生命周期
340
+
341
+ ```
342
+ 1. ws-goal PHASE 0 开始 intake → 创建 .aiws/intake/<id>.state.json (status=in_progress)
343
+ 2. 每 frozen 一个 intake 问题 → 更新 questions.frozen + current_question
344
+ 3. 每次启动 background subagent → 追加 background_tasks[] (status=running)
345
+ 4. Background task 完成/失败 → 更新对应 task status
346
+ 5. Intake 全部完成 → status=complete
347
+ 6. 进入 PHASE 1 创建 goal state.json 后 → 归档到 .aiws/intake/archive/<id>.state.json
348
+ 7. 归档后不再是扫描目标
349
+ ```
350
+
351
+ #### 3.2.7 恢复检测(Auto-Resume)
352
+
353
+ 下一 session ws-goal step 0 扫描 `.aiws/intake/*.state.json`:
354
+
355
+ | status | 行为 |
356
+ |---|---|
357
+ | `in_progress` 或 `paused` | auto-resume:从 current_question 直接恢复,不询问用户 |
358
+ | `timed_out` | auto-resume + 附加超时警告通知,仍从 current_question 恢复 |
359
+ | `complete`,且对应 goal 不存在 | 输出警告:intake 完成但 goal 未创建。建议运行 ws-goal 基于此 intake 继续 |
360
+ | `complete`,且对应 goal 存在 | 跳过(正常状态,已被 PHASE 1 消费) |
361
+ | `archived` | 跳过(已归档) |
362
+
363
+ Auto-resume 时输出以下通知(含问题级进度展示,但不需要用户选择):
364
+
365
+ ```
366
+ ↻ 恢复中断的 intake: <intake-id>
367
+ 问题进度(<frozen>/<total>):
368
+ ✅ Q1: <title> — 已冻结
369
+ ▶ Q2: <title> — 处理中(从该问题继续)
370
+ ⬜ Q3: <title> — 待处理
371
+ ⬜ Q4: <title> — 待处理
372
+ ```
373
+
374
+ #### 3.2.8 旧格式迁移
375
+
376
+ 检测到 `.aiws/plan/*.intake.md` 但无 `.aiws/intake/` state → 自动生成 intake state.json:
377
+
378
+ 1. 通过解析 intake.md 的 markdown 结构推断问题列表
379
+ 2. 启发式判断已 frozen 问题:找到第一个未回答的问题标记,之前的都算 frozen
380
+ 3. 生成 state.json,status=in_progress
381
+
382
+ ---
383
+
384
+ ### 3.3 Evidence Type Registry
253
385
 
254
386
  完成审计使用的证据类型:
255
387
 
@@ -261,7 +393,7 @@ ws_goal:
261
393
  | **benchmark** | `{ metric: string, before: number, after: number, threshold: string }` | 性能基准。threshold 格式 `"<N"` `">N"` `"±N%"` |
262
394
  | **artifact** | `{ url: string, metadata?: object }` | 外部交付物(部署 URL、PR 链接、发布包等)。metadata 可包含版本号、commit sha 等 |
263
395
 
264
- ### 3.3 Budget Protocol
396
+ ### 3.4 Budget Protocol
265
397
 
266
398
  三个约束维度,全部为软停止(soft-stop,不 abort):
267
399
 
@@ -273,7 +405,7 @@ ws_goal:
273
405
 
274
406
  token_budget 依赖平台的 token 计数器。aiws 不提供独立的 token 监控,只定义协议:平台应能声明当前 token 用量和剩余预算。当平台无法提供 token 计数时,此维度应标记为 `unsupported`。
275
407
 
276
- ### 3.4 Integration with Existing aiws Artifacts
408
+ ### 3.5 Integration with Existing aiws Artifacts
277
409
 
278
410
  | aiws 工件 | ws-goal 映射 |
279
411
  |---|---|
@@ -385,6 +517,9 @@ Group 是 goal 内部的一个自包含执行单元:
385
517
  | **verification** | string[] | 该组的验收标准。组完成时需逐条验证 |
386
518
  | **depends_on** | string[] | 依赖的其他 group id。默认 `[]`(无依赖) |
387
519
  | **status** | enum | `pending \| in_progress \| complete \| paused \| failed` |
520
+ | **design_context** | string | 该组的设计草稿/意图说明,委托 subagent 前必须填写 |
521
+ | **internal_tasks** | string[] | 组内部可安全委托的自包含子任务列表,每项应 ≤ 3 文件改动粒度 |
522
+ | **granularity_ok** | boolean | 主 session 在 DEV phase 前设置,true = 该组 scope ≤ 5 文件且不跨模块 |
388
523
 
389
524
  #### 6.2.2 Group Dependencies
390
525
 
@@ -455,6 +590,12 @@ phase 间的主 session 验证是门禁:
455
590
 
456
591
  ### group-1: Foundation Pages
457
592
  - scope: index.tsx, category.tsx, search.tsx
593
+ - design_context: "Foundation pages use shared Layout component, SSR with getServerSideProps"
594
+ - internal_tasks:
595
+ - "Replace hardcoded grid with <ProductGrid> component"
596
+ - "Add category filter sidebar to category.tsx"
597
+ - "Wire search API endpoint to search.tsx"
598
+ - granularity_ok: false
458
599
  - verification:
459
600
  - "Home page renders product grid"
460
601
  - "Category page renders with filters"
@@ -464,6 +605,12 @@ phase 间的主 session 验证是门禁:
464
605
 
465
606
  ### group-2: Purchase Conversion
466
607
  - scope: cart.tsx, checkout.tsx, payment-form.tsx
608
+ - design_context: "Purchase flow is client-only, uses React context for cart state"
609
+ - internal_tasks:
610
+ - "Refactor cart context to persist to localStorage"
611
+ - "Add shipping address form with validation"
612
+ - "Implement card number validation with Luhn check"
613
+ - granularity_ok: false
467
614
  - verification:
468
615
  - "Add to cart updates badge count"
469
616
  - "Checkout collects shipping address"
@@ -498,7 +645,12 @@ ws-goal 执行 Phase-Level Sequential Dispatch 时遵循以下协议:
498
645
  - plan file exists with verification commands
499
646
  - plan-verify passed
500
647
  - Fail max 2x → group paused, blocker recorded, STOP
501
- c. Group PHASE 2 - DEV:
648
+ c. Granularity Gate (before DEV):
649
+ i. Read current group's granularity_ok field
650
+ ii. If granularity_ok !== true: output block report (scope, file count, cross-module span), pause goal
651
+ iii. Verify design_context and internal_tasks non-empty
652
+ iv. If either empty: output warning (non-blocking), suggest filling
653
+ d. Group PHASE 2 - DEV:
502
654
  i. Construct phase delegation prompt:
503
655
  - Plan content, proposal links
504
656
  - Phase scope: ONLY implement per plan + local verify
@@ -510,7 +662,7 @@ ws-goal 执行 Phase-Level Sequential Dispatch 时遵循以下协议:
510
662
  - Diagnostics clean (lsp_diagnostics on changed files)
511
663
  - Changes match plan scope
512
664
  - Fail → group paused, blocker recorded, STOP
513
- d. Group PHASE 3 - REVIEW:
665
+ e. Group PHASE 3 - REVIEW:
514
666
  i. Construct phase delegation prompt:
515
667
  - Proposal + plan + changed files
516
668
  - Phase scope: ONLY audit, produce review evidence
@@ -522,7 +674,7 @@ ws-goal 执行 Phase-Level Sequential Dispatch 时遵循以下协议:
522
674
  - Review evidence files exist
523
675
  - No HIGH blocker unresolved
524
676
  - Fail → group paused, blocker recorded, STOP
525
- e. Group PHASE 4 - FINISH:
677
+ f. Group PHASE 4 - FINISH:
526
678
  i. Construct phase delegation prompt:
527
679
  - Phase scope: ONLY commit + finish
528
680
  - Phase constraints: NOT modify code
@@ -532,8 +684,8 @@ ws-goal 执行 Phase-Level Sequential Dispatch 时遵循以下协议:
532
684
  iii. Main session verify:
533
685
  - Change branch merged to target_base_branch
534
686
  - Pushed to remote
535
- f. Update group status → complete
536
- g. Update goal Progress Notes with group result
687
+ g. Update group status → complete
688
+ h. Update goal Progress Notes with group result
537
689
  4. All groups complete:
538
690
  - Run overall completion audit (all verification + goal-level checks)
539
691
  - Update goal state → complete
@@ -571,16 +723,8 @@ Phase-Level Pipeline Dispatch 的审计分散在各 phase 的门禁验证中,
571
723
 
572
724
  1. ws-goal 记录当前组停止位置到 Progress Notes
573
725
  2. 标记 goal state=paused
574
- 3. 输出恢复命令建议,例如:
575
- ```
576
- Goal <id> paused at group <group-id>.
577
- To resume: fix the reported issue, then restart ws-goal.
578
- ws-goal will detect the paused goal and ask whether to:
579
- a) Retry group <group-id> (re-delegate)
580
- b) Skip group <group-id> (mark complete manually, proceed to next)
581
- c) Pause and handoff
582
- ```
583
- 4. 下一 session 启动 ws-goal 时(step 0),检测到 paused goal → 输出恢复选项 → 用户选择后继续
726
+ 3. **默认重试**:下一 session 自动从失败 phase 重新委托(不询问 skip)
727
+ 4. 重试耗尽(3 次)后自动暂停并 handoff,输出恢复上下文供手动处理
584
728
 
585
729
  ### 6.7 Backward Compatibility
586
730
 
@@ -589,3 +733,141 @@ Phase-Level Pipeline Dispatch 的审计分散在各 phase 的门禁验证中,
589
733
  | 不含 groups 定义的 goal | 受影响:step 5 从单次 delegation 变为 4-phase 顺序执行。迁移后需按 phase-level 适配 |
590
734
  | 含 groups 定义的 goal(新格式) | 进入 Phase-Level Sequential Dispatch 模式,每 group 按 4-phase 执行 |
591
735
  | 已有 goal 工件(.md 文件) | 兼容。goal 文件格式不变,仅 delegation 执行方式变更 |
736
+
737
+ ## 7. Persistence & Resume
738
+
739
+ ### 7.1 Motivation & Gap Analysis
740
+
741
+ Codex /goal 使用 machine state table(pursuing/paused/achieved/budget_limited)作为持久化状态源,独立于人类可读的格式展示。它的状态由 runtime 自动管理,session 重启时恢复 thread-level 状态,无需用户额外操作。
742
+
743
+ ws-goal 当前仅依赖 `.md` YAML frontmatter 中的 `ws_goal.state` 字段管理状态。这导致两个问题:
744
+ 1. **Session 重启后 frontmatter 可能不被正确读取**:AI agent 的上下文窗口在重启后丢失,依赖人类可读文件恢复状态不可靠。
745
+ 2. **Phase 进度丢失**:没有 per-phase checkpoint,重启后无法判断哪些 phase 已完成。
746
+
747
+ 解决方案:引入 `.state.json` 作为机器可读的精确状态源,与 `.md` 文件共存。`.md` 保持人类可读,`.state.json` 作为程序化读取/写入的主状态源。
748
+
749
+ ### 7.2 State File Format
750
+
751
+ 文件路径:`.aiws/goals/<goal-id>.state.json`
752
+
753
+ Schema:
754
+ ```json
755
+ {
756
+ "$schema": "ws-goal-state-schema.json",
757
+ "version": "1",
758
+ "goal_id": "<goal-id>",
759
+ "status": "active",
760
+ "iteration": 1,
761
+ "current_phase": "intake",
762
+ "current_group": null,
763
+ "checkpoints": {
764
+ "intake": { "status": "pending", "attempts": 0, "completed_at": null, "error": null },
765
+ "goal_def": { "status": "pending", "attempts": 0, "completed_at": null, "error": null },
766
+ "dep_check": { "status": "pending", "attempts": 0, "completed_at": null, "error": null },
767
+ "ws_analysis": { "status": "pending", "attempts": 0, "completed_at": null, "error": null },
768
+ "plan": { "status": "pending", "attempts": 0, "completed_at": null, "error": null },
769
+ "dev": { "status": "pending", "attempts": 0, "completed_at": null, "error": null },
770
+ "review": { "status": "pending", "attempts": 0, "completed_at": null, "error": null },
771
+ "finish": { "status": "pending", "attempts": 0, "completed_at": null, "error": null }
772
+ },
773
+ "groups": {}
774
+ }
775
+ ```
776
+
777
+ 字段说明:
778
+ - `status`:`active` | `paused` | `complete` | `budget_limited` | `archived`
779
+ - `iteration`:同组 goal 的重试次数(paused → resume 计数)
780
+ - `current_phase`:当前正在执行的 phase 名称
781
+ - `current_group`:当前正在执行的 group(无 groups 时为 null)
782
+ - `checkpoints`:per-phase 状态记录,每个 checkpoint 含:
783
+ - `status`:`pending` | `in_progress` | `complete` | `failed`
784
+ - `attempts`:该 phase 重试次数
785
+ - `completed_at`:ISO 8601 时间戳(complete 时写入)
786
+ - `error`:失败时的错误信息(failed 时写入)
787
+ - `groups`:group-level 的 checkpoints 映射(可选,§6 支持)
788
+
789
+ ### 7.3 Phase-Level Checkpoints
790
+
791
+ 每个 phase 边界记录 checkpoint。记录时机:
792
+
793
+ | 时机 | Checkpoint | 动作 |
794
+ |---|---|---|
795
+ | PHASE 0 完成 | intake | status=complete + timestamp |
796
+ | PHASE 1 完成 | goal_def | status=complete + timestamp |
797
+ | PHASE 2 step 4 依赖链预检通过 | dep_check | status=complete + timestamp |
798
+ | PHASE 2 step 4.5 workspace 分析通过 | ws_analysis | status=complete + timestamp |
799
+ | PHASE 2 step 5 PHASE 1 (PLAN) 通过/失败 | plan | status=complete/failed + timestamp + error |
800
+ | PHASE 2 step 5 PHASE 2 (DEV) 通过/失败 | dev | status=complete/failed + timestamp + error |
801
+ | PHASE 2 step 5 PHASE 3 (REVIEW) 通过/失败 | review | status=complete/failed + timestamp + error |
802
+ | PHASE 2 step 5 PHASE 4 (FINISH) 通过/失败 | finish | status=complete/failed + timestamp + error |
803
+
804
+ 进入 phase 时更新 `current_phase` 和对应 checkpoint status=in_progress。
805
+ 完成 phase 时更新 checkpoint status=complete + `completed_at` 时间戳。
806
+ 失败时更新 checkpoint status=failed + `error`。
807
+ 暂停 goal 时更新 `status=paused`。
808
+
809
+ **FINISH checkpoint complete 后自动归档**:
810
+ ```
811
+ mkdir -p .aiws/goals/archive
812
+ mv .aiws/goals/<goal-id>.md .aiws/goals/archive/<goal-id>.md
813
+ mv .aiws/goals/<goal-id>.state.json .aiws/goals/archive/<goal-id>.state.json
814
+ ```
815
+ 归档后 goal 不再出现在 step 0 扫描列表中。
816
+
817
+ ### 7.4 Resume Protocol (Auto-Resume)
818
+
819
+ Session 重启后 ws-goal step 0 检测流程:
820
+
821
+ 1. 扫描 `.aiws/goals/*.state.json`
822
+ 2. 读取每个 state.json 的 `status` 字段
823
+ 3. 若发现 `status=active` 或 `status=paused`:
824
+ - **单个中断 goal**:直接从最后一个非 complete checkpoint 恢复,**不询问用户**
825
+ - 输出恢复通知:"↻ 检测到中断 goal <id>(<phase>),正在恢复..."
826
+ - 设置 `current_phase` 到对应 phase
827
+ - 注入 §7.5 continuation context 并恢复执行
828
+ - **多个中断 goal**:列出所有可恢复 goal 让用户选一个,选定后按单人流程 auto-resume
829
+
830
+ 恢复后 phase 重试逻辑:
831
+ - 从 checkpoint 中最后一个非 complete 的 phase 开始
832
+ - 已 complete 的 phase 不重新执行
833
+ - 每个 phase 最多重试 3 次(由 `attempts` 字段追踪)
834
+ - 重试为默认行为(**不提供 skip 选项**),重试耗尽后自动暂停并 handoff
835
+ - 若 checkpoint 没有记录(旧格式 .md 且无 .state.json),降级为从 PHASE 0 全量重跑
836
+
837
+ > 设计原则:用户执行 ws-goal 即代表意图明确——继续未完成的工作。重复询问"是否要继续"增加摩擦、不增加价值。仅在无法自动决策时(如多个冲突 goal)才需要用户介入。
838
+
839
+ ### 7.5 Continuation Context Template
840
+
841
+ 当 session 重启后检测到 paused goal 并 auto-resume 时,ws-goal 技能注入以下上下文:
842
+
843
+ ```
844
+ ## Resumed Goal: <goal-id>
845
+
846
+ - Objective: <outcome from .md>
847
+ - Resume Point: Phase <X> (<phase-name>)
848
+ - Previous Error: <error from checkpoint>
849
+ - Attempts remaining: <3 - attempt_count>
850
+
851
+ Instructions: Continue from the failed phase. Do NOT redo completed phases.
852
+ ```
853
+
854
+ 此模板作为 prompt 上下文由 ws-goal 技能注入,不写入独立文件。
855
+
856
+ ### 7.6 Migration from Existing Goals
857
+
858
+ 检测到旧格式 goal(只有 .md,无 state.json)时的处理:
859
+
860
+ 1. 读取 `.aiws/goals/<goal-id>.md` 的 `ws_goal.state` 和 `iteration` 字段
861
+ 2. 如果 status 为 active 或 paused:
862
+ - 自动生成 `.state.json`
863
+ - 所有 checkpoints 设为 pending
864
+ - `current_phase` 设为 null(需全量重跑)
865
+ 3. 如果 status 为 complete 或 archived:
866
+ - 不生成 state.json(不需要恢复)
867
+
868
+ ### 7.7 Limitations
869
+
870
+ - state.json 是当前工作区本地文件,不支持跨设备同步
871
+ - 如果用户手动删除或修改 state.json,ws-goal 降级为全量重跑(可重新生成)
872
+ - 并行执行多个 goal 时,state.json 独立管理,互不依赖
873
+ - state.json 不包含 secrets 或凭证信息
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aipper/aiws-spec",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "description": "AIWS spec and templates (single source of truth).",
5
5
  "type": "module",
6
6
  "files": [
@@ -0,0 +1,174 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "ws-goal-intake-schema.json",
4
+ "title": "WS-Goal Intake State",
5
+ "description": "Machine-readable state for PHASE 0 (INTAKE) of ws-goal workflow. Persisted between AI agent sessions to enable recovery from interrupted intake processes.",
6
+ "type": "object",
7
+ "required": [
8
+ "version",
9
+ "intake_id",
10
+ "status",
11
+ "created_at",
12
+ "updated_at",
13
+ "questions"
14
+ ],
15
+ "properties": {
16
+ "$schema": {
17
+ "type": "string",
18
+ "description": "Reference to this schema file"
19
+ },
20
+ "version": {
21
+ "type": "string",
22
+ "enum": ["1"],
23
+ "description": "Schema version for forward compatibility"
24
+ },
25
+ "intake_id": {
26
+ "type": "string",
27
+ "pattern": "^[a-z0-9]([a-z0-9-]*[a-z0-9])?$",
28
+ "description": "Slug matching the corresponding .intake.md file in .aiws/plan/"
29
+ },
30
+ "status": {
31
+ "type": "string",
32
+ "enum": ["pending", "in_progress", "paused", "complete", "archived", "timed_out"],
33
+ "description": "Intake state machine status. timed_out = auto-detected when background tasks exceed max_idle_minutes"
34
+ },
35
+ "created_at": {
36
+ "type": "string",
37
+ "format": "date-time",
38
+ "description": "ISO 8601 timestamp when this intake state was first created"
39
+ },
40
+ "updated_at": {
41
+ "type": "string",
42
+ "format": "date-time",
43
+ "description": "ISO 8601 timestamp of last state update"
44
+ },
45
+ "questions": {
46
+ "type": "object",
47
+ "required": ["total", "frozen", "open"],
48
+ "properties": {
49
+ "total": {
50
+ "type": "integer",
51
+ "minimum": 0,
52
+ "description": "Total number of intake questions"
53
+ },
54
+ "frozen": {
55
+ "type": "integer",
56
+ "minimum": 0,
57
+ "description": "Number of questions with confirmed answers (status=frozen)"
58
+ },
59
+ "open": {
60
+ "type": "integer",
61
+ "minimum": 0,
62
+ "description": "Number of remaining unanswered questions"
63
+ },
64
+ "items": {
65
+ "type": "array",
66
+ "description": "Per-question detail list for question-level recovery. Counters (total/frozen/open) MUST equal derived values from items when present.",
67
+ "items": {
68
+ "type": "object",
69
+ "required": ["id", "title", "status"],
70
+ "properties": {
71
+ "id": {
72
+ "type": "string",
73
+ "description": "Question identifier, e.g. Q1, Q2"
74
+ },
75
+ "title": {
76
+ "type": "string",
77
+ "description": "Short question title for display in recovery options"
78
+ },
79
+ "status": {
80
+ "type": "string",
81
+ "enum": ["pending", "in_progress", "frozen", "skipped"],
82
+ "description": "Per-question status"
83
+ },
84
+ "frozen_at": {
85
+ "type": ["string", "null"],
86
+ "format": "date-time",
87
+ "description": "When this question was frozen (if status=frozen)"
88
+ },
89
+ "answer_summary": {
90
+ "type": ["string", "null"],
91
+ "description": "Optional brief summary of the answer for context preservation"
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+ },
98
+ "current_question": {
99
+ "type": ["string", "null"],
100
+ "description": "The question currently being processed, used for resume positioning"
101
+ },
102
+ "background_tasks": {
103
+ "type": "array",
104
+ "items": {
105
+ "type": "object",
106
+ "required": ["task_id", "type", "description", "started_at", "status"],
107
+ "properties": {
108
+ "task_id": {
109
+ "type": "string",
110
+ "description": "Background task ID (bg_...)"
111
+ },
112
+ "type": {
113
+ "type": "string",
114
+ "enum": ["explore", "librarian", "oracle", "general"],
115
+ "description": "Subagent type used"
116
+ },
117
+ "description": {
118
+ "type": "string",
119
+ "description": "Brief description of what this task was searching for"
120
+ },
121
+ "started_at": {
122
+ "type": "string",
123
+ "format": "date-time",
124
+ "description": "When the task was launched"
125
+ },
126
+ "status": {
127
+ "type": "string",
128
+ "enum": ["running", "completed", "failed", "orphaned", "timed_out"],
129
+ "description": "Current task status. timed_out = exceeded max_idle_minutes threshold"
130
+ },
131
+ "completed_at": {
132
+ "type": ["string", "null"],
133
+ "format": "date-time",
134
+ "description": "When the task completed (if applicable)"
135
+ },
136
+ "summary": {
137
+ "type": ["string", "null"],
138
+ "description": "Optional brief summary of task results"
139
+ }
140
+ }
141
+ },
142
+ "description": "Tracked background subagent tasks launched during intake"
143
+ },
144
+ "max_idle_minutes": {
145
+ "type": "integer",
146
+ "minimum": 1,
147
+ "default": 30,
148
+ "description": "Idle timeout threshold in minutes. Background tasks with started_at older than this are auto-marked timed_out on next detection scan."
149
+ },
150
+ "last_error": {
151
+ "type": ["string", "null"],
152
+ "description": "Most recent error message, if any"
153
+ },
154
+ "session_metadata": {
155
+ "type": "object",
156
+ "properties": {
157
+ "last_agent": {
158
+ "type": "string",
159
+ "description": "The agent type that last updated this state"
160
+ },
161
+ "message_count": {
162
+ "type": "integer",
163
+ "description": "Approximate message count in the session that created this state"
164
+ },
165
+ "last_activity_at": {
166
+ "type": ["string", "null"],
167
+ "format": "date-time",
168
+ "description": "Last user activity timestamp"
169
+ }
170
+ },
171
+ "description": "Debugging metadata, no programmatic dependencies"
172
+ }
173
+ }
174
+ }
@@ -67,4 +67,21 @@ git commit -m "<message>"
67
67
  - `下一步(Next):` 若存在 submodule 改动,先提示用户进入 submodule 提交
68
68
  <!-- AIWS_MANAGED_END:opencode:ws-commit -->
69
69
 
70
+ ---
71
+ description: 提交:门禁/审计后提交(submodule 感知)
72
+ ---
73
+ # ws-commit
74
+
75
+ Thin CLI wrapper. Delegates to `aiws commit`.
76
+
77
+ ```bash
78
+ if [[ -x "./node_modules/.bin/aiws" ]]; then
79
+ ./node_modules/.bin/aiws commit
80
+ elif command -v aiws >/dev/null 2>&1; then
81
+ aiws commit
82
+ else
83
+ npx @aipper/aiws commit
84
+ fi
85
+ ```
86
+
70
87
  可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
@@ -55,4 +55,21 @@ description: 交付:submodules+superproject 分步提交并安全合并回 bas
55
55
  - `Evidence:` `.agentdocs/tmp/aiws-validate/*.json`(若使用 --stamp)
56
56
  <!-- AIWS_MANAGED_END:opencode:ws-deliver -->
57
57
 
58
+ ---
59
+ description: 交付:submodules+superproject 分步提交并安全合并回 base
60
+ ---
61
+ # ws-deliver
62
+
63
+ Thin CLI wrapper. Delegates to `aiws deliver`.
64
+
65
+ ```bash
66
+ if [[ -x "./node_modules/.bin/aiws" ]]; then
67
+ ./node_modules/.bin/aiws deliver
68
+ elif command -v aiws >/dev/null 2>&1; then
69
+ aiws deliver
70
+ else
71
+ npx @aipper/aiws deliver
72
+ fi
73
+ ```
74
+
58
75
  可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
@@ -76,4 +76,21 @@ fi
76
76
  - 不执行破坏性命令。
77
77
  <!-- AIWS_MANAGED_END:opencode:ws-finish -->
78
78
 
79
+ ---
80
+ description: 收尾:fast-forward 合并并把 submodule 并回目标分支后顺序 push
81
+ ---
82
+ # ws-finish
83
+
84
+ Thin CLI wrapper. Delegates to `aiws finish`.
85
+
86
+ ```bash
87
+ if [[ -x "./node_modules/.bin/aiws" ]]; then
88
+ ./node_modules/.bin/aiws finish
89
+ elif command -v aiws >/dev/null 2>&1; then
90
+ aiws finish
91
+ else
92
+ npx @aipper/aiws finish
93
+ fi
94
+ ```
95
+
79
96
  可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
@@ -25,15 +25,19 @@ ws-goal 只做三件事,不做更多:
25
25
 
26
26
  ## 执行流程
27
27
 
28
- 0) 检查 `.aiws/goals/` 目录:
28
+ 0) 检查 `.aiws/goals/` 目录(先扫描 `.state.json`,再扫描 `.md`):
29
29
  a) 若用户仅查询状态(无明确目标),列出所有 goal 文件及其 status 字段,然后结束。
30
- b) 若存在 status=active 或 status=paused 的 goal 文件,优先读取并恢复执行,不再新建 goal。
30
+ b) 扫描 `.aiws/goals/*.state.json`:
31
+ - 若发现 status=active 或 status=paused 的 state.json,输出恢复选项(从失败的 phase 继续 / 跳过 / handoff)
32
+ - 用户选择后设置 current_phase 到对应 phase 并继续执行
33
+ c) 若未找到 state.json 但有 status=active 或 status=paused 的 .md 文件(旧格式迁移),按 §7.6 自动生成 state.json 后全量重跑
31
34
 
32
35
  1) 读取真值文件(`AI_PROJECT.md`、`REQUIREMENTS.md`、`AI_WORKSPACE.md`),确认项目规则与边界。
33
36
 
34
37
  2) 接受用户输入的 goal objective,明确目标范围与验收标准。
35
38
 
36
39
  3) 按 ws-goal-contract.md 的目标模板生成目标文件,写入 `.aiws/goals/<goal-id>.md`。
40
+ 并同时创建 `.aiws/goals/<goal-id>.state.json`(§7.2 格式),初始状态 `status=active`、`current_phase=intake`、所有 checkpoints pending。
37
41
  a) 生成时填入 `Target Base Branch` 字段:
38
42
  - `target_base_branch`:从当前分支追踪或用户声明确定。默认 `main`
39
43
  - `base_branch_mismatch_action`:默认 `block`
@@ -106,15 +110,16 @@ ws-goal 只做三件事,不做更多:
106
110
  [LOW] .aiws/journal/ 日志文件 — 无影响
107
111
  ════════════════════════
108
112
  ```
109
- g) 展示报告后要求用户选择:
110
- - **继续** → 进入 step 5
111
- - **暂停** → goal status=paused,报告写入 Audit Trail,结束
112
- - **先清理** → goal status=paused,输出清理建议步骤,结束
113
- 用户未确认前,不得进入 step 5。
113
+ g) 展示报告后要求用户选择:
114
+ - **继续** → 更新 state.json checkpoint `ws_analysis=complete`,进入 step 5
115
+ - **暂停** → state.json status=paused,报告写入 Audit Trail,结束
116
+ - **先清理** → state.json status=paused,输出清理建议步骤,结束
117
+ 用户未确认前,不得进入 step 5。
114
118
 
115
119
  5) **Phase-Level Pipeline Delegation**:依赖链预检 + workspace 分析通过后,将 goal 拆分为 PLAN→DEV→REVIEW→FINISH 四个 phase 顺序执行,每个 phase 委托给独立轻量子 agent,主 session 验证每个 phase 产出后决定继续/重试/暂停。
116
- 前置条件:step 4 必须通过(ALL HEALTHY 或 UNHEALTHY 已显式放行)。若 step 4 阻断,不允许 delegation。
117
- 前置条件 2:不存在 status=active 的 change 分支。若有,让用户选择「使用已有 change 继续」或「暂停」。
120
+ 前置条件:step 4 必须通过(ALL HEALTHY 或 UNHEALTHY 已显式放行)。若 step 4 阻断,不允许 delegation。
121
+ 前置条件 2:不存在 status=active 的 change 分支。若有,让用户选择「使用已有 change 继续」或「暂停」。
122
+ 前置条件 3:每个 pipeline phase 开始前更新 state.json `current_phase` + checkpoint `status=in_progress`;完成/失败后对应更新 checkpoint。
118
123
 
119
124
  5a) **Check for Groups**:读取 goal 文件,检查是否定义了 `Groups` 区域。
120
125
  - 若 goal **不含** groups → 走单组 phase-level pipeline(step 5b-5g)
@@ -23,4 +23,21 @@ sed -n '1,160p' changes/archive/*-"${change_id}"/handoff.md
23
23
  - 若是历史/异常场景尚未归档,再手工运行 `/p-aiws-change-archive`。
24
24
  <!-- AIWS_MANAGED_END:opencode:ws-handoff -->
25
25
 
26
+ ---
27
+ description: 交接:查看归档 change 的 handoff.md(标准由 aiws change finish --push 自动归档生成)
28
+ ---
29
+ # ws-handoff
30
+
31
+ Thin CLI wrapper. Delegates to `aiws handoff`.
32
+
33
+ ```bash
34
+ if [[ -x "./node_modules/.bin/aiws" ]]; then
35
+ ./node_modules/.bin/aiws handoff
36
+ elif command -v aiws >/dev/null 2>&1; then
37
+ aiws handoff
38
+ else
39
+ npx @aipper/aiws handoff
40
+ fi
41
+ ```
42
+
26
43
  可在下方追加本项目对 OpenCode 的额外说明(托管块外内容会被保留)。
@@ -9,7 +9,7 @@ description: 目标协议:设定可审计的 goal 目标;依赖链预检;
9
9
  目标:
10
10
  - 将用户需求转化为可审计的 goal 目标,按 ws-goal-contract.md 的目标模板写入目标文件。
11
11
  - 依赖链预检:阻断"死 change 阻塞下游"这类 chain 问题。
12
- - 管道委托:预检通过后将 goal 拆分为 phase-level 子任务(PLAN→DEV→REVIEW→FINISH),每个 phase 委托给独立轻量子 agent,主 session 编排调度与验证。
12
+ - 管道委托:预检通过后将 goal 拆分为 phase-level 子任务(INTAKE→PLAN→DEV→REVIEW→FINISH),每个 phase 委托给独立轻量子 agent,主 session 编排调度与验证。
13
13
  - 完成审计:claim done 时验证 outcome 真伪。
14
14
 
15
15
  ws-goal 不做的事:
@@ -21,12 +21,69 @@ ws-goal 不做的事:
21
21
  1) 先运行 `/ws-preflight`(对齐 `AI_PROJECT.md` / `REQUIREMENTS.md` / `AI_WORKSPACE.md`)。
22
22
 
23
23
  执行流程:
24
- 0) 检查 `.aiws/goals/` 目录:
24
+
25
+ ### PHASE 0 — INTAKE(对抗式目标审问)
26
+
27
+ 在写 goal 文件前,先对目标本身做对抗式审问:
28
+
29
+ 0) 检查 `.aiws/goals/` 目录(先扫描 `.state.json`,再扫描 `.md`):
25
30
  a) 若用户仅查询状态(无明确目标),列出所有 goal 文件及其 status 字段,然后结束。
26
- b) 若存在 status=active 或 status=paused 的 goal 文件,优先读取并恢复执行,不再新建 goal。
31
+ b) 扫描 `.aiws/goals/*.state.json`:
32
+ - 读取每个 state.json 的 `status` 字段
33
+ - 若发现 `status=active` 或 `status=paused` 的 state.json:
34
+ i. 读取对应 `.aiws/goals/<goal-id>.md` 文件获取完整目标描述
35
+ ii. 输出 goal 摘要:goal_id, status, current_phase, checkpoint 状态, error(若有)
36
+ iii. 输出恢复选项:
37
+ - (a)从失败的 phase 继续
38
+ - (b)跳过该 phase(标记 complete,继续下一个)
39
+ - (c)暂停并 handoff
40
+ iv. 用户选择后:
41
+ - 若选择 a)→ 设置 `current_phase` 到最近一个非 complete 的 checkpoint,注入 §7.5 continuation context 并恢复执行
42
+ - 若选择 b)→ 标记当前 failed phase 为 complete,设置 `current_phase` 到下一个 phase
43
+ - 若选择 c)→ 输出 handoff 建议,结束
44
+ v. 若用户选择全量重跑 → 重置 state.json 所有 checkpoints 为 pending,status=active,从头开始
45
+ c) 若未找到 state.json 但有 status=active 或 status=paused 的 .md 文件(旧格式迁移):
46
+ - 按 §7.6 迁移策略处理(自动生成 state.json 后全量重跑)
27
47
  1) 读取真值文件(`AI_PROJECT.md`、`REQUIREMENTS.md`、`AI_WORKSPACE.md`),确认项目规则与边界。
28
- 2) 接受用户输入的 goal objective,明确目标范围与验收标准。
29
- 3) ws-goal-contract.md 的目标模板生成目标文件,写入 `.aiws/goals/<goal-id>.md`。
30
- 4) 输出 completion audit checklist,列出每个 goal 的完成标准与验证方式。
31
- 5) **Workspace State Analysis**:分析 dirty/submodule/change artifacts/git 状态,输出影响等级报告,用户确认后才能继续。参考 `/ws-goal` command 的 step 4.5 完整流程。
32
- 6) **Phase-Level Pipeline Delegation**:预检 + 分析通过后,将 goal 拆分为 PLAN→DEV→REVIEW→FINISH 四个 phase 顺序执行,每个 phase 委托给独立轻量子 agent,主 session 验证每个 phase 产出后决定继续/重试/暂停。参考 `/ws-goal` command 的 step 5 完整流程。
48
+ 2) **运行改进后的 `/ws-intake`**(对抗式审问模式)对 goal objective 做逐条审问:
49
+ - 推荐答案模式:对事实类/选择类问题先给出推荐(参考 `recommendAnswers` 配置)
50
+ - 决策树分支遍历:每条回答展开对应子分支,直到所有叶节点被消费
51
+ - 对抗式审问层:自动探查代码库寻找矛盾信号,挑战隐含假设,探测边缘案例
52
+ 3) **产出 intake 草案**:写入 `plan/<timestamp>-<slug>.intake.md`,包含完整的决策树遍历记录
53
+ 4) **阻塞检查**:若 intake 草案中存在 `UNRESOLVED_BRANCH`,输出阻塞报告并暂停。用户必须显式确认忽略或补充信息后才能进入 PHASE 1。
54
+ 5) 将 intake 审问结果(已冻结的目标范围、约束、边界)传递到后续 goal objective 定义。
55
+ 5a) **记录 checkpoint**:更新 `.aiws/goals/<goal-id>.state.json` → checkpoint `intake=complete` + `completed_at`
56
+
57
+ ### PHASE 1 — GOAL 定义
58
+
59
+ 6) 接受用户输入的 goal objective,明确目标范围与验收标准(基于 PHASE 0 的 intake 产出)。
60
+ 7) 按 ws-goal-contract.md 的目标模板生成目标文件,写入 `.aiws/goals/<goal-id>.md`。
61
+ 7a) 同时创建 `.aiws/goals/<goal-id>.state.json`(§7.2 格式),初始状态:
62
+ - `status`: "active"
63
+ - `current_phase`: "intake"
64
+ - 所有 checkpoints: `{"status": "pending", "attempts": 0, "completed_at": null, "error": null}`
65
+ 8) 输出 completion audit checklist,列出每个 goal 的完成标准与验证方式。
66
+ 8a) **记录 checkpoint**:更新 `.aiws/goals/<goal-id>.state.json` → checkpoint `goal_def=complete` + `completed_at`
67
+
68
+ ### PHASE 2 — 预检与管道委托
69
+
70
+ **Checkpoint 记录规则**(贯穿整个 Phase 2):
71
+ - 每个 phase 边界必须更新 `.aiws/goals/<goal-id>.state.json`:
72
+ - 进入 phase → `current_phase=<phase>`,对应 checkpoint `status=in_progress`
73
+ - 完成 phase → checkpoint `status=complete` + `completed_at=ISO8601`
74
+ - 失败 → checkpoint `status=failed` + `error=<message>`
75
+ - 暂停 goal → `status=paused`(全局)
76
+
77
+ 8b) **依赖链预检**:按 ws-goal-contract.md §2.4 执行上游依赖链健康检查。
78
+ - 通过后:更新 checkpoint `dep_check=complete`
79
+ - 阻断时:更新 state.json `status=paused`,记录 error,结束
80
+
81
+ 9) **Workspace State Analysis**:分析 dirty/submodule/change artifacts/git 状态,输出影响等级报告,用户确认后才能继续。参考 `/ws-goal` command 的 step 4.5 完整流程。
82
+ - 通过后:更新 checkpoint `ws_analysis=complete`
83
+ 10) **Phase-Level Pipeline Delegation**:预检 + 分析通过后,将 goal 拆分为 PLAN→DEV→REVIEW→FINISH 四个 phase 顺序执行,每个 phase 委托给独立轻量子 agent,主 session 验证每个 phase 产出后决定继续/重试/暂停。参考 `/ws-goal` command 的 step 5 完整流程。
84
+ - 每个 pipeline phase 开始前:更新 state.json `current_phase`,对应 checkpoint `status=in_progress`
85
+ - Granularity Gate(c-i):在 DEV 委托前运行;检查 granularity_ok=true、design_context 和 internal_tasks 非空
86
+ - 粒度不达标(granularity_ok != true)→ 阻断并输出报告,暂停 goal
87
+ - 粒度达标后进入 DEV delegation(c-ii)
88
+ - 每个 pipeline phase 通过后:更新 checkpoint `status=complete` + `completed_at`
89
+ - 每个 pipeline phase 失败后:更新 checkpoint `status=failed` + `error`,递增 `attempts`
@@ -3,6 +3,15 @@ name: ws-intake
3
3
  description: 使用时机:新需求需要逐条澄清、冻结问题时。触发词:需求澄清、intake、冻结问题、前期沟通。注意:需求已冻结直接进 ws-plan。
4
4
  ---
5
5
 
6
+ ## 配置
7
+
8
+ 本 skill 支持以下配置项,用户可在 `.opencode/opencode.json` 的 `skills.ws-intake` 中覆盖:
9
+
10
+ | 配置项 | 类型 | 默认值 | 说明 |
11
+ |---|---|---|---|
12
+ | `recommendAnswers` | boolean | true | 提问时先给出推荐答案,用户确认即可。逐问题类型标注是否可推荐 |
13
+ | `adversarial` | boolean | true | 启用对抗式审问:挑战假设 + 自动探查代码库寻找矛盾 |
14
+
6
15
  用中文输出(命令/路径/代码标识符保持原样不翻译)。
7
16
 
8
17
  目标:
@@ -91,18 +100,37 @@ Must-have / Should-have / Nice-to-have 三层分类,明确 scope 底线。
91
100
  2) 若存在最新 `plan/*.intake.md`,先续写它;否则新建一份 intake 草案。
92
101
  3) 把当前任务拆成 `Open Questions`,状态只允许 `open / in_discussion / frozen / deferred`。
93
102
 
94
- 4) **探码后问**:在对每个 Open Question 提问前,先 spawn `explore` agent 探查代码库。如果代码库中已有足以回答该问题的信息,在 intake 草案的相应章节记录该信息,并跳过该问题的提问。只有当代码库无法回答时,才把该问题交给用户。记录每个问题属于以下哪一类:
95
- - `codebase: answered` — 代码库已可回答,跳过提问
96
- - `codebase: partial` — 代码库有部分信息,补充提问未覆盖的部分
97
- - `user: required` — 必须问用户
103
+ 4) **对抗式探码后问**:在对每个 Open Question 提问前,先 spawn `explore` agent 探查代码库,执行以下三层操作:
104
+ a) **事实探查**:代码库中是否有足以回答该问题的信息?如果有,记录到 intake 草案并跳过提问。
105
+ - `codebase: answered` — 跳过提问
106
+ - `codebase: partial` — 补充提问未覆盖部分
107
+ - `user: required` — 必须问用户
108
+ b) **矛盾检索**:主动搜索代码库中与用户可能假设相矛盾的代码模式。例如用户说"这个功能很简单",但代码库显示相关模块有 20 个调用点——这是一个矛盾信号,必须在提问时点出。
109
+ c) **边缘案例探测**:搜索边界条件模式——空值、并发写入、依赖不可用、超大输入等,在提问时自动补充边缘问题。
98
110
 
99
111
  5) 每次只推进 1 个当前问题,并显式输出:
100
112
  - `Current question:`
101
113
  - `Why it matters:`
102
114
  - `Current options / current understanding:`
103
- - `Exit condition:`
115
+ - `Recommended answer:` — 如果该问题类型可推荐(事实确认类、二选一/多选一、最佳实践类),先给出推荐答案。开放型/创意型问题标注 `recommendation: N/A`
116
+ - `Exit condition:`
104
117
  - 每个问题独立线程:在未标记 frozen/deferred 前,不进入下一题。问答往返不限轮数,但一次只处理一个维度的决策。
105
- 6) 若用户一次提出多个问题,必须显式排队:列出所有问题编号,按顺序逐个处理;不得同时推进多个问题的讨论。输出格式:`Queued questions: #1, #2, ... | Current: #1`
118
+ - **推荐答案模式**:对事实确认类、二选一/多选一、最佳实践类问题,agent 先在 `Recommended answer` 中给出推荐,用户只需确认或修正。推荐答案必须来自代码库探查、规范文件或公认最佳实践,不做编造。若 `recommendAnswers: false`(配置关闭),则不显示推荐答案直接提问。
119
+ 6) **决策树分支遍历**(替代扁平队列):
120
+ - 问题组织为树而非列表:每个答案可能产生子问题(分支),每个分支必须走到叶节点(无子问题)才算完成。
121
+ - 交互式遍历:用户回答后,根据答案展开对应子分支;下一个问题由当前回答决定,而非预定顺序。
122
+ - 追踪状态:使用缩进树格式维护当前遍历位置:
123
+ ```
124
+ Tree:
125
+ ├─ Q1 (frozen)
126
+ │ ├─ Q1.1 (frozen)
127
+ │ └─ Q1.2 ← current
128
+ ├─ Q2 (pending, blocked by Q1.2)
129
+ └─ Q3 (pending)
130
+ ```
131
+ - 分支耗尽判据:所有叶节点均标记 `frozen` 或 `deferred` 时,intake 完成。
132
+ - `UNRESOLVED_BRANCH`:如果某分支因外部依赖或信息不足无法继续,标记为 `UNRESOLVED_BRANCH` 并写入 intake 草案的 `Decision Tree` 小节。goal 文件会读取此标记作为阻塞项。
133
+ - 用户一次性提出多个问题仍需要排队,但队列中的问题按决策树优先级重排(先主干、再分支)。
106
134
  7) 每轮都要把 intake 草案写盘,至少包含:
107
135
  - `Deep Interview` — 9 维分析:Why/非目标/影响面/假设/替代方案/约束/优先级/成功度量/风险
108
136
  - `Context`