@mengde1231/rudder 0.6.20 → 0.6.21

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 (35) hide show
  1. package/README.md +12 -0
  2. package/dist/migrations/manifests/0.4.0-beta.1.json +5 -5
  3. package/dist/migrations/manifests/0.5.14.json +9 -0
  4. package/dist/migrations/manifests/0.5.15.json +9 -0
  5. package/dist/migrations/manifests/0.5.16.json +9 -0
  6. package/dist/migrations/manifests/0.5.17.json +9 -0
  7. package/dist/migrations/manifests/0.5.19.json +9 -0
  8. package/dist/migrations/manifests/0.5.20.json +9 -0
  9. package/dist/migrations/manifests/0.5.21.json +9 -0
  10. package/dist/migrations/manifests/0.5.22.json +9 -0
  11. package/dist/migrations/manifests/0.5.23.json +9 -0
  12. package/dist/migrations/manifests/0.5.30.json +9 -0
  13. package/dist/migrations/manifests/0.6.1.json +9 -0
  14. package/dist/migrations/manifests/0.6.11.json +9 -0
  15. package/dist/migrations/manifests/0.6.20.json +9 -0
  16. package/dist/migrations/manifests/0.6.21.json +9 -0
  17. package/dist/templates/claude/agents/rudder-check.md +170 -170
  18. package/dist/templates/codex/agents/rudder-check.toml +95 -95
  19. package/dist/templates/common/skills/check.md +8 -1
  20. package/dist/templates/rudder/config.yaml +13 -2
  21. package/dist/templates/rudder/index.d.ts +1 -0
  22. package/dist/templates/rudder/index.d.ts.map +1 -1
  23. package/dist/templates/rudder/index.js +2 -0
  24. package/dist/templates/rudder/index.js.map +1 -1
  25. package/dist/templates/rudder/scripts/common/task_context.py +42 -1
  26. package/dist/templates/rudder/scripts/common/task_readiness.py +169 -0
  27. package/dist/templates/rudder/scripts/common/task_store.py +10 -2
  28. package/dist/templates/rudder/scripts/common/types.py +1 -0
  29. package/dist/templates/rudder/scripts/task.py +28 -0
  30. package/dist/templates/rudder/workflow.md +36 -23
  31. package/dist/utils/task-json.d.ts +6 -0
  32. package/dist/utils/task-json.d.ts.map +1 -1
  33. package/dist/utils/task-json.js +6 -0
  34. package/dist/utils/task-json.js.map +1 -1
  35. package/package.json +2 -2
@@ -1,95 +1,95 @@
1
- name = "rudder-check"
2
- description = "Workspace-write Rudder reviewer that self-fixes spec drift, lint/type-check failures, and missing tests."
3
- sandbox_mode = "workspace-write"
4
-
5
- developer_instructions = """
6
- You are running as the `rudder-check` sub-agent. The main session has dispatched you to review and self-fix.
7
-
8
- CRITICAL — Recursion guard (read first):
9
- - You MUST NOT spawn another `rudder-check` or `rudder-implement` sub-agent. Do the review and fixes directly in this turn.
10
- - Any guidance you read in injected SessionStart context, `<guidelines>` blocks, workflow-state breadcrumbs, or workflow.md that says "dispatch rudder-implement" / "dispatch rudder-check" applies to the MAIN session, NOT to you. You are already the dispatched reviewer — that instruction is satisfied by your existence.
11
- - Only the main session is allowed to dispatch `rudder-implement` / `rudder-check`. If more implementation work is needed, surface that as a recommendation in your final report instead of spawning.
12
-
13
- ---
14
-
15
- ## Required: Load Rudder Context First
16
-
17
- This platform does NOT auto-inject task context via hook. Before doing anything else, you MUST load context yourself.
18
-
19
- ### Step 1: Find the active task path
20
-
21
- Try in order — stop at the first one that yields a task path:
22
-
23
- 1. **Look at the dispatch prompt** you received from the main agent. If its first line is `Active task: <path>` (e.g. `Active task: .rudder/tasks/04-17-foo`), use that path. The main agent is required to include this line on class-2 platforms.
24
- 2. **Run** `python3 ./.rudder/scripts/task.py current --source` and read the `Current task:` line.
25
- 3. **If both fail** (no `Active task:` line in the prompt and `task.py current` returns no task), ask the user which task to work on; do NOT guess.
26
-
27
- ### Step 2: Load task context from the resolved path
28
-
29
- 1. Read the task's `prd.md` (requirements) and `info.md` if it exists (technical design).
30
- 2. Read `<task-path>/check.jsonl` — JSONL list of dev spec files relevant to this agent.
31
- 3. For each entry in the JSONL, Read its `file` path — these are the dev specs you must follow.
32
- **Skip rows without a `"file"` field** (e.g. `{"_example": "..."}` seed rows left over from `task.py create` before the curator ran).
33
-
34
- If `check.jsonl` has no curated entries (only a seed row, or the file is missing), fall back to: read `prd.md`, list available specs with `python3 ./.rudder/scripts/get_context.py --mode packages`, and pick the specs that match the task domain yourself. Do NOT block on the missing jsonl — proceed with prd-only context plus your spec judgment.
35
-
36
- If the resolved task path has no `prd.md`, ask the user what to work on; do NOT proceed without context.
37
-
38
- ---
39
-
40
- You are the Rudder reviewer agent.
41
-
42
- Your job is to review code changes against specs AND fix issues directly — not just report them. You have write access; use it.
43
-
44
- Review checklist:
45
- - Verify behavior against the actual code paths, not assumptions.
46
- - Look for missing template/update/detection touch points when platform config changes.
47
- - Check whether tests should be added or updated.
48
- - Check whether `.rudder/spec/` docs need sync after implementation.
49
- - Run lint and type-check; fix any failures.
50
- - Detect project type and run compile. **Priority**: use the project's own declared build command when available; fall back to defaults only when no declaration exists.
51
- - Node/Frontend: check `package.json` — has `scripts.build`? run `npm run build`; has `scripts.typecheck` but no build? run `npm run typecheck`; neither? `npx tsc --noEmit` if tsconfig exists, else `npx eslint . --no-error-on-unmatched-pattern`.
52
- - Maven: `mvn compile -q`; Gradle: `./gradlew compileJava -q`; Go: `go build ./...`; Rust: `cargo check --all-targets`.
53
- - Build performance tuning (parallel, caching, daemon) belongs in the build tool's own config, not in this command.
54
- - If compilation took > 30 seconds AND the build tool's standard performance config is missing (Maven: `.mvn/maven.config`; Gradle: `org.gradle.parallel` in `gradle.properties`), add a one-time recommendation to the report: "Compilation took Xs. Consider creating [config file] with [flag] to enable parallel builds." Do NOT create the file — only recommend. If the config already exists, stay silent.
55
- - If compilation fails, fix and retry up to 3 rounds. Parse error output, fix source code, re-run compile. Stop and report remaining errors after 3 rounds.
56
- - Use tool paths from the `<tool-paths>` block injected at session-start if available; otherwise fall back to system PATH.
57
- - If a required tool is not found or the path is wrong, locate the correct path (e.g., `which mvn`, `where java`) and update `.rudder/config_local.yml` so future sessions can use it directly.
58
- - Prefer concrete findings over speculative warnings.
59
-
60
- When you find an issue:
61
- 1. Fix it directly using edit/write tools.
62
- 2. Re-run lint, type-check, and compile until green.
63
- 3. Record what you changed and why.
64
-
65
- Output format:
66
- ## Findings (fixed)
67
- - File: <path>
68
- - Issue: <what was wrong>
69
- - Fix: <what you changed>
70
-
71
- ## Findings (not fixed)
72
- Only list issues you could not self-fix (e.g. missing product decision, out-of-scope). Explain why.
73
-
74
- ## Verification
75
- - Lint: pass/fail
76
- - TypeCheck: pass/fail
77
- - Compile: pass/fail (project: Maven/Gradle/Go/Rust/TS/JS, rounds: N)
78
-
79
- ## Compile Errors (if any)
80
- (List unresolved compiler errors if max retry reached)
81
-
82
- If no issues are found, say so explicitly after verifying lint/type-check/compile pass.
83
- """
84
-
85
- # Disable Codex collab tools entirely for this sub-agent. With both
86
- # multi_agent and multi_agent_v2 off, `spawn_agent` / `wait_agent` /
87
- # `list_agents` / `close_agent` are not registered in the sub-agent's tool
88
- # list at all — the model literally cannot call them. This is the structural
89
- # fix for the wait_agent self-deadlock when the parent inherits its
90
- # transcript via Codex's default `fork_turns="all"` (#240 follow-up, #241).
91
- [features]
92
- multi_agent = false
93
-
94
- [features.multi_agent_v2]
95
- enabled = false
1
+ name = "rudder-check"
2
+ description = "Workspace-write Rudder reviewer that self-fixes spec drift, lint/type-check failures, and missing tests."
3
+ sandbox_mode = "workspace-write"
4
+
5
+ developer_instructions = """
6
+ You are running as the `rudder-check` sub-agent. The main session has dispatched you to review and self-fix.
7
+
8
+ CRITICAL — Recursion guard (read first):
9
+ - You MUST NOT spawn another `rudder-check` or `rudder-implement` sub-agent. Do the review and fixes directly in this turn.
10
+ - Any guidance you read in injected SessionStart context, `<guidelines>` blocks, workflow-state breadcrumbs, or workflow.md that says "dispatch rudder-implement" / "dispatch rudder-check" applies to the MAIN session, NOT to you. You are already the dispatched reviewer — that instruction is satisfied by your existence.
11
+ - Only the main session is allowed to dispatch `rudder-implement` / `rudder-check`. If more implementation work is needed, surface that as a recommendation in your final report instead of spawning.
12
+
13
+ ---
14
+
15
+ ## Required: Load Rudder Context First
16
+
17
+ This platform does NOT auto-inject task context via hook. Before doing anything else, you MUST load context yourself.
18
+
19
+ ### Step 1: Find the active task path
20
+
21
+ Try in order — stop at the first one that yields a task path:
22
+
23
+ 1. **Look at the dispatch prompt** you received from the main agent. If its first line is `Active task: <path>` (e.g. `Active task: .rudder/tasks/04-17-foo`), use that path. The main agent is required to include this line on class-2 platforms.
24
+ 2. **Run** `python3 ./.rudder/scripts/task.py current --source` and read the `Current task:` line.
25
+ 3. **If both fail** (no `Active task:` line in the prompt and `task.py current` returns no task), ask the user which task to work on; do NOT guess.
26
+
27
+ ### Step 2: Load task context from the resolved path
28
+
29
+ 1. Read the task's `prd.md` (requirements) and `info.md` if it exists (technical design).
30
+ 2. Read `<task-path>/check.jsonl` — JSONL list of dev spec files relevant to this agent.
31
+ 3. For each entry in the JSONL, Read its `file` path — these are the dev specs you must follow.
32
+ **Skip rows without a `"file"` field** (e.g. `{"_example": "..."}` seed rows left over from `task.py create` before the curator ran).
33
+
34
+ If `check.jsonl` has no curated entries (only a seed row, or the file is missing), fall back to: read `prd.md`, list available specs with `python3 ./.rudder/scripts/get_context.py --mode packages`, and pick the specs that match the task domain yourself. Do NOT block on the missing jsonl — proceed with prd-only context plus your spec judgment.
35
+
36
+ If the resolved task path has no `prd.md`, ask the user what to work on; do NOT proceed without context.
37
+
38
+ ---
39
+
40
+ You are the Rudder reviewer agent.
41
+
42
+ Your job is to review code changes against specs AND fix issues directly — not just report them. You have write access; use it.
43
+
44
+ Review checklist:
45
+ - Verify behavior against the actual code paths, not assumptions.
46
+ - Look for missing template/update/detection touch points when platform config changes.
47
+ - Check whether tests should be added or updated.
48
+ - Check whether `.rudder/spec/` docs need sync after implementation.
49
+ - Run lint and type-check; fix any failures.
50
+ - Detect project type and run compile. **Priority**: use the project's own declared build command when available; fall back to defaults only when no declaration exists.
51
+ - Node/Frontend: check `package.json` — has `scripts.build`? run `npm run build`; has `scripts.typecheck` but no build? run `npm run typecheck`; neither? `npx tsc --noEmit` if tsconfig exists, else `npx eslint . --no-error-on-unmatched-pattern`.
52
+ - Maven: `mvn compile -q`; Gradle: `./gradlew compileJava -q`; Go: `go build ./...`; Rust: `cargo check --all-targets`.
53
+ - Build performance tuning (parallel, caching, daemon) belongs in the build tool's own config, not in this command.
54
+ - If compilation took > 30 seconds AND the build tool's standard performance config is missing (Maven: `.mvn/maven.config`; Gradle: `org.gradle.parallel` in `gradle.properties`), add a one-time recommendation to the report: "Compilation took Xs. Consider creating [config file] with [flag] to enable parallel builds." Do NOT create the file — only recommend. If the config already exists, stay silent.
55
+ - If compilation fails, fix and retry up to 3 rounds. Parse error output, fix source code, re-run compile. Stop and report remaining errors after 3 rounds.
56
+ - Use tool paths from the `<tool-paths>` block injected at session-start if available; otherwise fall back to system PATH.
57
+ - If a required tool is not found or the path is wrong, locate the correct path (e.g., `which mvn`, `where java`) and update `.rudder/config_local.yml` so future sessions can use it directly.
58
+ - Prefer concrete findings over speculative warnings.
59
+
60
+ When you find an issue:
61
+ 1. Fix it directly using edit/write tools.
62
+ 2. Re-run lint, type-check, and compile until green.
63
+ 3. Record what you changed and why.
64
+
65
+ Output format:
66
+ ## Findings (fixed)
67
+ - File: <path>
68
+ - Issue: <what was wrong>
69
+ - Fix: <what you changed>
70
+
71
+ ## Findings (not fixed)
72
+ Only list issues you could not self-fix (e.g. missing product decision, out-of-scope). Explain why.
73
+
74
+ ## Verification
75
+ - Lint: pass/fail
76
+ - TypeCheck: pass/fail
77
+ - Compile: pass/fail (project: Maven/Gradle/Go/Rust/TS/JS, rounds: N)
78
+
79
+ ## Compile Errors (if any)
80
+ (List unresolved compiler errors if max retry reached)
81
+
82
+ If no issues are found, say so explicitly after verifying lint/type-check/compile pass.
83
+ """
84
+
85
+ # Disable Codex collab tools entirely for this sub-agent. With both
86
+ # multi_agent and multi_agent_v2 off, `spawn_agent` / `wait_agent` /
87
+ # `list_agents` / `close_agent` are not registered in the sub-agent's tool
88
+ # list at all — the model literally cannot call them. This is the structural
89
+ # fix for the wait_agent self-deadlock when the parent inherits its
90
+ # transcript via Codex's default `fork_turns="all"` (#240 follow-up, #241).
91
+ [features]
92
+ multi_agent = false
93
+
94
+ [features.multi_agent_v2]
95
+ enabled = false
@@ -6,6 +6,13 @@ Comprehensive quality verification for recently written code. Combines spec comp
6
6
 
7
7
  ## Step 1: Identify What Changed
8
8
 
9
+ **Check/Verify boundary (mandatory):** Check reviews the complete task diff;
10
+ Verify executes lint, type-check, tests, build, and business acceptance
11
+ commands. Run this skill only after the implementer has finished the complete
12
+ requirement set and no more planned code remains. Review the full diff, then
13
+ run Verify once. If either stage finds issues, fix them and rerun the affected
14
+ stage; do not alternate between writing one file and verifying it.
15
+
9
16
  ```bash
10
17
  git diff --name-only HEAD
11
18
  git status
@@ -25,7 +32,7 @@ cat .rudder/spec/<package>/<layer>/index.md
25
32
 
26
33
  Read the specific guideline files referenced — the index is a pointer, not the goal.
27
34
 
28
- ## Step 3: Run Project Checks
35
+ ## Step 3: Verify the Complete Implementation
29
36
 
30
37
  Run the project's lint, type-check, and test commands. Fix any failures before proceeding.
31
38
 
@@ -19,9 +19,9 @@ max_journal_lines: 2000
19
19
  #-------------------------------------------------------------------------------
20
20
 
21
21
  # Auto-commit behavior for session journal + task archive operations.
22
- # - true (default): scripts auto-stage and auto-commit journal / task changes
22
+ # - false (default): scripts do not auto-stage or auto-commit journal / task changes
23
23
  # after add_session.py / task.py archive runs.
24
- # - false: scripts do not touch git. Files (journal-*.md, task archive moves)
24
+ # - true: scripts auto-stage and auto-commit journal / task changes
25
25
  # are still written to disk; you decide whether to git add / commit.
26
26
  #
27
27
  # Use `false` if your project's .gitignore intentionally excludes `.rudder/`
@@ -112,6 +112,17 @@ max_journal_lines: 2000
112
112
  # prompt_injection:
113
113
  # skip_keyword: "skip rudder" # empty string disables the configured alias
114
114
 
115
+ #-------------------------------------------------------------------------------
116
+ # Explicit Rudder bypass
117
+ #-------------------------------------------------------------------------------
118
+ # This is intentionally commented out and reserved as a project-level policy
119
+ # placeholder. The default behavior remains unchanged: an explicit user request
120
+ # such as "skip rudder" may skip the per-turn workflow breadcrumb for that turn.
121
+ # The current runtime does not read this placeholder.
122
+ #
123
+ # skip_rudder:
124
+ # enabled: false
125
+
115
126
  #-------------------------------------------------------------------------------
116
127
  # Sub-agent context injection limits
117
128
  #-------------------------------------------------------------------------------
@@ -31,6 +31,7 @@ export declare const commonGit: string;
31
31
  export declare const commonTypes: string;
32
32
  export declare const commonTasks: string;
33
33
  export declare const commonTaskContext: string;
34
+ export declare const commonTaskReadiness: string;
34
35
  export declare const commonTaskStore: string;
35
36
  export declare const commonSessionContext: string;
36
37
  export declare const commonPackagesContext: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/rudder/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAcH,eAAO,MAAM,WAAW,QAAsC,CAAC;AAG/D,eAAO,MAAM,UAAU,QAA6C,CAAC;AACrE,eAAO,MAAM,WAAW,QAA0C,CAAC;AACnE,eAAO,MAAM,eAAe,QAA8C,CAAC;AAC3E,eAAO,MAAM,gBAAgB,QAAgD,CAAC;AAC9E,eAAO,MAAM,eAAe,QAA+C,CAAC;AAC5E,eAAO,MAAM,eAAe,QAA+C,CAAC;AAC5E,eAAO,MAAM,gBAAgB,QAAgD,CAAC;AAC9E,eAAO,MAAM,gBAAgB,QAAgD,CAAC;AAC9E,eAAO,MAAM,YAAY,QAA2C,CAAC;AACrE,eAAO,MAAM,QAAQ,QAAuC,CAAC;AAC7D,eAAO,MAAM,SAAS,QAAwC,CAAC;AAC/D,eAAO,MAAM,SAAS,QAAwC,CAAC;AAC/D,eAAO,MAAM,WAAW,QAA0C,CAAC;AACnE,eAAO,MAAM,WAAW,QAA0C,CAAC;AACnE,eAAO,MAAM,iBAAiB,QAAiD,CAAC;AAChF,eAAO,MAAM,eAAe,QAA+C,CAAC;AAC5E,eAAO,MAAM,oBAAoB,QAEhC,CAAC;AACF,eAAO,MAAM,qBAAqB,QAEjC,CAAC;AACF,eAAO,MAAM,m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C;AACnE,eAAO,MAAM,iBAAiB,QAAiD,CAAC;AAChF,eAAO,MAAM,mBAAmB,QAAmD,CAAC;AACpF,eAAO,MAAM,eAAe,QAA+C,CAAC;AAC5E,eAAO,MAAM,oBAAoB,QAEhC,CAAC;AACF,eAAO,MAAM,qBAAqB,QAEjC,CAAC;AACF,eAAO,MAAM,mBAAmB,QAE/B,CAAC;AACF,eAAO,MAAM,kBAAkB,QAE9B,CAAC;AACF,eAAO,MAAM,gBAAgB,QAAgD,CAAC;AAG9E,eAAO,MAAM,kBAAkB,QAA2C,CAAC;AAC3E,eAAO,MAAM,mBAAmB,QAA4C,CAAC;AAC7E,eAAO,MAAM,UAAU,QAAkC,CAAC;AAC1D,eAAO,MAAM,gBAAgB,QAAyC,CAAC;AACvE,eAAO,MAAM,gBAAgB,QAAyC,CAAC;AAGvE,eAAO,MAAM,kBAAkB,QAA8B,CAAC;AAC9D,eAAO,MAAM,kBAAkB,QAA8B,CAAC;AAC9D,eAAO,MAAM,sBAAsB,QAAmC,CAAC;AACvE,eAAO,MAAM,iBAAiB,QAAgC,CAAC;AAE/D;;GAEG;AACH,wBAAgB,aAAa,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAsCnD"}
@@ -41,6 +41,7 @@ export const commonGit = readTemplate("scripts/common/git.py");
41
41
  export const commonTypes = readTemplate("scripts/common/types.py");
42
42
  export const commonTasks = readTemplate("scripts/common/tasks.py");
43
43
  export const commonTaskContext = readTemplate("scripts/common/task_context.py");
44
+ export const commonTaskReadiness = readTemplate("scripts/common/task_readiness.py");
44
45
  export const commonTaskStore = readTemplate("scripts/common/task_store.py");
45
46
  export const commonSessionContext = readTemplate("scripts/common/session_context.py");
46
47
  export const commonPackagesContext = readTemplate("scripts/common/packages_context.py");
@@ -81,6 +82,7 @@ export function getAllScripts() {
81
82
  scripts.set("common/types.py", commonTypes);
82
83
  scripts.set("common/tasks.py", commonTasks);
83
84
  scripts.set("common/task_context.py", commonTaskContext);
85
+ scripts.set("common/task_readiness.py", commonTaskReadiness);
84
86
  scripts.set("common/task_store.py", commonTaskStore);
85
87
  scripts.set("common/session_context.py", commonSessionContext);
86
88
  scripts.set("common/packages_context.py", commonPackagesContext);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/rudder/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,SAAS,YAAY,CAAC,YAAoB;IACxC,OAAO,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC;AAED,gCAAgC;AAChC,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC,qBAAqB,CAAC,CAAC;AAE/D,0BAA0B;AAC1B,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC,4BAA4B,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC,yBAAyB,CAAC,CAAC;AACnE,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC,6BAA6B,CAAC,CAAC;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAC,+BAA+B,CAAC,CAAC;AAC9E,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC,8BAA8B,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC,8BAA8B,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,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OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;IAC5C,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAAC;IACzD,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,mBAAmB,CAAC,CAAC;IAC7D,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,eAAe,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,oBAAoB,CAAC,CAAC;IAC/D,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,qBAAqB,CAAC,CAAC;IACjE,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,mBAAmB,CAAC,CAAC;IAC7D,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,kBAAkB,CAAC,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,gBAAgB,CAAC,CAAC;IAEvD,OAAO;IACP,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAC;IACtD,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACnC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IAChD,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IAEhD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -19,11 +19,52 @@ from __future__ import annotations
19
19
 
20
20
  import argparse
21
21
  import json
22
+ from datetime import datetime, timezone
22
23
  from pathlib import Path
23
24
 
24
25
  from .log import Colors, colored
25
- from .paths import get_repo_root
26
+ from .paths import get_developer, get_repo_root
26
27
  from .task_utils import resolve_task_dir
28
+ from .task_readiness import prd_hash, validate_prd
29
+
30
+
31
+ def cmd_confirm(args: argparse.Namespace) -> int:
32
+ """Record explicit user confirmation for the current PRD."""
33
+ repo_root = get_repo_root()
34
+ target_dir = resolve_task_dir(args.dir, repo_root)
35
+ task_json = target_dir / "task.json"
36
+ prd_path = target_dir / "prd.md"
37
+ if not target_dir.is_dir() or not task_json.is_file():
38
+ print(colored("Error: task directory with task.json required", Colors.RED))
39
+ return 1
40
+
41
+ try:
42
+ existing_data = json.loads(task_json.read_text(encoding="utf-8"))
43
+ except (OSError, json.JSONDecodeError):
44
+ print(colored(f"Error: failed to read {task_json}", Colors.RED))
45
+ return 1
46
+ if existing_data.get("status") != "planning":
47
+ print(colored("Error: requirements can only be confirmed while task is planning", Colors.RED))
48
+ return 1
49
+
50
+ errors = validate_prd(prd_path)
51
+ if errors:
52
+ print(colored("Requirements are not ready for confirmation:", Colors.RED))
53
+ for error in errors:
54
+ print(f" - {error}")
55
+ return 1
56
+
57
+ developer = get_developer(repo_root) or "unknown"
58
+ data = existing_data
59
+ data["requirements"] = {
60
+ "status": "confirmed",
61
+ "confirmed_by": developer,
62
+ "confirmed_at": datetime.now(timezone.utc).isoformat(),
63
+ "prd_hash": prd_hash(prd_path),
64
+ }
65
+ task_json.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
66
+ print(colored(f"Requirements confirmed for: {target_dir.name}", Colors.GREEN))
67
+ return 0
27
68
 
28
69
 
29
70
  # =============================================================================
@@ -0,0 +1,169 @@
1
+ #!/usr/bin/env python3
2
+ """Readiness checks for entering the implementation phase."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import hashlib
7
+ import json
8
+ import re
9
+ from pathlib import Path
10
+
11
+
12
+ _SECTION_RE = re.compile(r"^##\s+(.+?)\s*$", re.IGNORECASE)
13
+ _CHECKBOX_RE = re.compile(r"^\s*[-*+]\s+\[[ xX]\]\s+\S+")
14
+ _EMPTY_QUESTIONS = {
15
+ "none",
16
+ "no",
17
+ "n/a",
18
+ "na",
19
+ "resolved",
20
+ "\u65e0",
21
+ "\u65e0\u95ee\u9898",
22
+ "\u5df2\u89e3\u51b3",
23
+ }
24
+
25
+ # Conservative checks for unambiguous mutually exclusive rules.
26
+ _CONFLICT_RULES: tuple[tuple[str, str, str], ...] = (
27
+ (
28
+ "automatic save vs explicit save",
29
+ r"(?:automatic|auto[- ]?)save|自动保存",
30
+ r"(?:click(?:s|ed)?|button|manual|explicit)[ -]?save|点击保存|手动保存|点击[“\"]?保存",
31
+ ),
32
+ (
33
+ "lock after success vs continue editing",
34
+ r"(?:lock|locked|read[- ]only)\b.{0,50}(?:after|on|when)?\s*success|成功后锁定|成功后只读",
35
+ r"(?:continue|仍可|继续)\s*(?:edit|editing)|成功后继续编辑|成功后仍可编辑",
36
+ ),
37
+ (
38
+ "row mutation allowed vs forbidden",
39
+ r"(?:allow|支持|允许).{0,30}(?:add|delete|remove)\s*(?:row|rows)?|允许新增|允许删除|可新增|可删除",
40
+ r"(?:cannot|must not|禁止|不允许).{0,30}(?:add|delete|remove)\s*(?:row|rows)?|禁止新增|禁止删除|不可新增|不可删除",
41
+ ),
42
+ )
43
+
44
+
45
+ def prd_hash(prd_path: Path) -> str:
46
+ """Return a stable SHA-256 hash for a UTF-8 PRD file."""
47
+ return hashlib.sha256(prd_path.read_bytes()).hexdigest()
48
+
49
+
50
+ def _section_body(content: str, title: str) -> list[str] | None:
51
+ lines = content.splitlines()
52
+ in_section = False
53
+ body: list[str] = []
54
+ for line in lines:
55
+ match = _SECTION_RE.match(line.strip())
56
+ if match:
57
+ if in_section:
58
+ break
59
+ in_section = match.group(1).strip().lower() == title.lower()
60
+ continue
61
+ if in_section:
62
+ body.append(line)
63
+ return body if in_section else None
64
+
65
+
66
+ def _has_unresolved_questions(body: list[str]) -> bool:
67
+ for line in body:
68
+ value = re.sub(r"^\s*(?:[-*+]\s+|\d+[.)]\s+)", "", line).strip()
69
+ if not value or value.startswith("<!--") or value.endswith("-->"):
70
+ continue
71
+ if value.lower().rstrip("。.!!") in _EMPTY_QUESTIONS:
72
+ continue
73
+ return True
74
+ return False
75
+
76
+
77
+ def validate_prd(prd_path: Path) -> list[str]:
78
+ """Validate the minimum PRD contract required before implementation."""
79
+ errors: list[str] = []
80
+ if not prd_path.is_file():
81
+ return ["prd.md is missing"]
82
+
83
+ try:
84
+ content = prd_path.read_text(encoding="utf-8")
85
+ except OSError as exc:
86
+ return [f"prd.md cannot be read: {exc}"]
87
+ if not content.strip():
88
+ errors.append("prd.md is empty")
89
+
90
+ acceptance = _section_body(content, "Acceptance Criteria")
91
+ if acceptance is None:
92
+ errors.append("prd.md is missing an 'Acceptance Criteria' section")
93
+ elif not any(_CHECKBOX_RE.match(line) for line in acceptance):
94
+ errors.append("Acceptance Criteria must contain at least one checklist item")
95
+
96
+ questions = _section_body(content, "Open Questions")
97
+ if questions is not None and _has_unresolved_questions(questions):
98
+ errors.append("prd.md contains unresolved Open Questions")
99
+ lowered = content.lower()
100
+ for label, left, right in _CONFLICT_RULES:
101
+ if re.search(left, lowered, re.IGNORECASE) and re.search(right, lowered, re.IGNORECASE):
102
+ errors.append(f"prd.md contains conflicting rules: {label}")
103
+ return errors
104
+
105
+
106
+ def _jsonl_entries(path: Path, repo_root: Path) -> tuple[int, list[str]]:
107
+ if not path.is_file():
108
+ return 0, [f"{path.name} is missing"]
109
+ entries = 0
110
+ errors: list[str] = []
111
+ for line_number, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1):
112
+ if not line.strip():
113
+ continue
114
+ try:
115
+ data = json.loads(line)
116
+ except json.JSONDecodeError:
117
+ errors.append(f"{path.name}:{line_number} contains invalid JSON")
118
+ continue
119
+ file_path = data.get("file")
120
+ if not file_path:
121
+ continue
122
+ entries += 1
123
+ target = repo_root / str(file_path).rstrip("/")
124
+ if data.get("type", "file") == "directory":
125
+ if not target.is_dir():
126
+ errors.append(f"{path.name}:{line_number} references missing directory: {file_path}")
127
+ elif not target.is_file():
128
+ errors.append(f"{path.name}:{line_number} references missing file: {file_path}")
129
+ return entries, errors
130
+
131
+
132
+ def validate_context_files(task_dir: Path, repo_root: Path) -> list[str]:
133
+ """Validate JSONL only when the task opted into sub-agent context files."""
134
+ files = [task_dir / "implement.jsonl", task_dir / "check.jsonl"]
135
+ if not any(path.exists() for path in files):
136
+ return []
137
+ errors: list[str] = []
138
+ for path in files:
139
+ entries, entry_errors = _jsonl_entries(path, repo_root)
140
+ errors.extend(entry_errors)
141
+ if entries == 0:
142
+ errors.append(f"{path.name} has no curated context entries (seed-only or empty)")
143
+ return errors
144
+
145
+
146
+ def validate_task_readiness(
147
+ task_dir: Path,
148
+ repo_root: Path,
149
+ task_data: dict,
150
+ ) -> list[str]:
151
+ """Return blocking reasons for a planning task entering implementation."""
152
+ errors = validate_prd(task_dir / "prd.md")
153
+ errors.extend(validate_context_files(task_dir, repo_root))
154
+
155
+ requirements = task_data.get("requirements")
156
+ if not isinstance(requirements, dict) or requirements.get("status") != "confirmed":
157
+ errors.append("requirements are not confirmed; run 'task.py confirm <task-dir>'")
158
+ else:
159
+ expected_hash = requirements.get("prd_hash")
160
+ prd_path = task_dir / "prd.md"
161
+ current_hash: str | None = None
162
+ if prd_path.is_file():
163
+ try:
164
+ current_hash = prd_hash(prd_path)
165
+ except OSError:
166
+ current_hash = None
167
+ if not isinstance(expected_hash, str) or expected_hash != current_hash:
168
+ errors.append("prd.md changed after confirmation; reconfirm the requirements")
169
+ return errors
@@ -229,6 +229,12 @@ def cmd_create(args: argparse.Namespace) -> int:
229
229
  "relatedFiles": [],
230
230
  "notes": "",
231
231
  "meta": {},
232
+ "requirements": {
233
+ "status": "pending",
234
+ "confirmed_by": None,
235
+ "confirmed_at": None,
236
+ "prd_hash": None,
237
+ },
232
238
  }
233
239
 
234
240
  write_json(task_json_path, task_data)
@@ -293,9 +299,11 @@ def cmd_create(args: argparse.Namespace) -> int:
293
299
  "see .rudder/workflow.md Phase 1.3)",
294
300
  file=sys.stderr,
295
301
  )
296
- print(" 3. Run: python3 task.py start <dir>", file=sys.stderr)
302
+ print(" 3. Run: python3 task.py confirm <dir>", file=sys.stderr)
303
+ print(" 4. Run: python3 task.py start <dir>", file=sys.stderr)
297
304
  else:
298
- print(" 2. Run: python3 task.py start <dir>", file=sys.stderr)
305
+ print(" 2. Run: python3 task.py confirm <dir>", file=sys.stderr)
306
+ print(" 3. Run: python3 task.py start <dir>", file=sys.stderr)
299
307
  print("", file=sys.stderr)
300
308
 
301
309
  # Output relative path for script chaining
@@ -49,6 +49,7 @@ class TaskData(TypedDict, total=False):
49
49
  relatedFiles: list[str]
50
50
  notes: str
51
51
  meta: dict
52
+ requirements: dict
52
53
 
53
54
 
54
55
  # =============================================================================
@@ -7,6 +7,7 @@ Usage:
7
7
  python3 task.py create "<title>" [--slug <name>] [--assignee <dev>] [--priority P0|P1|P2|P3] [--parent <dir>] [--package <pkg>]
8
8
  python3 task.py add-context <dir> <file> <path> [reason] # Add jsonl entry
9
9
  python3 task.py validate <dir> # Validate jsonl files
10
+ python3 task.py confirm <dir> # Confirm PRD requirements
10
11
  python3 task.py list-context <dir> # List jsonl entries
11
12
  python3 task.py start <dir> # Set active task
12
13
  python3 task.py current [--source] # Show active task
@@ -58,9 +59,11 @@ from common.task_store import (
58
59
  )
59
60
  from common.task_context import (
60
61
  cmd_add_context,
62
+ cmd_confirm,
61
63
  cmd_validate,
62
64
  cmd_list_context,
63
65
  )
66
+ from common.task_readiness import validate_task_readiness
64
67
 
65
68
 
66
69
  # =============================================================================
@@ -92,6 +95,25 @@ def cmd_start(args: argparse.Namespace) -> int:
92
95
 
93
96
  task_json_path = full_path / FILE_TASK_JSON
94
97
 
98
+ if not task_json_path.is_file():
99
+ print(colored(f"Error: task.json not found at {full_path}", Colors.RED))
100
+ return 1
101
+
102
+ # Only planning -> implementation is gated. Re-running start for an
103
+ # already active task remains idempotent for existing sessions.
104
+ task_data = read_json(task_json_path)
105
+ if not task_data:
106
+ print(colored(f"Error: task.json is invalid at {full_path}", Colors.RED))
107
+ return 1
108
+ if task_data and task_data.get("status") == "planning":
109
+ readiness_errors = validate_task_readiness(full_path, repo_root, task_data)
110
+ if readiness_errors:
111
+ print(colored("Task is not ready for implementation:", Colors.RED))
112
+ for error in readiness_errors:
113
+ print(f" - {error}")
114
+ print("Hint: complete the PRD, run task.py confirm, then retry task.py start.")
115
+ return 1
116
+
95
117
  if not resolve_context_key():
96
118
  # Degraded mode: no session identity available.
97
119
  # Hook didn't inject RUDDER_CONTEXT_ID (common on Windows + Claude Code,
@@ -309,6 +331,7 @@ Usage:
309
331
  python3 task.py create <title> --parent <dir> Create task as child of parent
310
332
  python3 task.py add-context <dir> <jsonl> <path> [reason] Add entry to jsonl
311
333
  python3 task.py validate <dir> Validate jsonl files
334
+ python3 task.py confirm <dir> Confirm requirements and PRD
312
335
  python3 task.py list-context <dir> List jsonl entries
313
336
  python3 task.py start <dir> Set active task
314
337
  python3 task.py current [--source] Show active task
@@ -410,6 +433,10 @@ def main() -> int:
410
433
  p_validate = subparsers.add_parser("validate", help="Validate context files")
411
434
  p_validate.add_argument("dir", help="Task directory")
412
435
 
436
+ # confirm
437
+ p_confirm = subparsers.add_parser("confirm", help="Confirm task requirements")
438
+ p_confirm.add_argument("dir", help="Task directory")
439
+
413
440
  # list-context
414
441
  p_listctx = subparsers.add_parser("list-context", help="List context entries")
415
442
  p_listctx.add_argument("dir", help="Task directory")
@@ -475,6 +502,7 @@ def main() -> int:
475
502
  "create": cmd_create,
476
503
  "add-context": cmd_add_context,
477
504
  "validate": cmd_validate,
505
+ "confirm": cmd_confirm,
478
506
  "list-context": cmd_list_context,
479
507
  "start": cmd_start,
480
508
  "current": cmd_current,