@linimin/pi-letscook 0.1.75 → 0.1.76

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/CHANGELOG.md CHANGED
@@ -1,17 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.76
4
+
5
+ ### Fixed
6
+
7
+ - taught the completion protocol and core role prompts to auto-preserve routine unrelated tracked worktree dirt with a reversible stash-plus-note flow instead of asking the user to choose between stash/cleanup/background continuation for every dirty-worktree checkpoint
8
+ - refined sticky `/cook` continuation detection so clear workflow-follow-up turns stay inside the active workflow while unrelated ordinary chat stays outside it, and aligned smoke/release regressions with that split
9
+
3
10
  ## 0.1.75
4
11
 
5
12
  ### Fixed
6
13
 
7
14
  - stopped treating a fresh but under-specified explicit `cook_handoff` as an automatic startup blocker; `/cook` now uses the user's explicit entry as implementation intent and lets same-entry primary-agent startup synthesis tighten the first slice before it gives up
8
15
  - aligned startup, sticky-workflow, and canonical-evidence regressions with the new implementation-first `/cook` behavior so long-running workflows no longer bounce users back into handoff-authoring loops
16
+ - taught the completion protocol and core role prompts to auto-preserve routine unrelated tracked worktree dirt with a reversible stash-plus-note flow instead of asking the user to choose between stash/cleanup/background continuation for every dirty-worktree checkpoint
9
17
 
10
18
  ## 0.1.74
11
19
 
12
20
  ### Fixed
13
21
 
14
- - made active `/cook` workflows sticky across subsequent turns so routine continuation, exact await-user-input replies, and mandatory completion-role dispatch no longer depend on prompt-shaped driver turns or repeated manual `/cook` re-entry
22
+ - made active `/cook` workflows sticky across routine continuation turns, exact await-user-input replies, and mandatory completion-role dispatch so long-running workflows keep moving without repeated manual `/cook` re-entry while unrelated ordinary chat stays outside workflow mode
15
23
  - updated smoke, canonical-evidence, release-check, and completion-role gating regressions to enforce the new sticky active-workflow self-healing behavior
16
24
  - stopped letting fresh but under-specified explicit `cook_handoff` capsules block `/cook` startup by default; `/cook` now treats the user's entry as implementation intent and tries same-entry primary-agent startup synthesis to tighten the first slice before failing closed
17
25
 
package/README.md CHANGED
@@ -190,6 +190,8 @@ Deterministic active-slice contract regression now lives in `bash scripts/active
190
190
 
191
191
  Deterministic verification for this packaged contract also lives in `npm run rubric-contract-test`, which now exercises reviewer, auditor, and stop-judge transcription paths while the bootstrap/refocus/context regressions plus control-plane verifier fail closed when required canonical signaling is missing.
192
192
 
193
+ Active `/cook` workflows now also auto-reconcile routine unrelated tracked worktree dirt instead of bouncing that decision back to the user. When the dirty tracked files are outside the latest slice or current reconciliation surfaces and can be isolated safely, the workflow should preserve them with a reversible mechanism such as a named git stash plus a `.agent/tmp/dirty-worktree-autostash.json` note, continue the mandatory step on a clean worktree, and restore them before handing control back. Only overlapping changes, ownership ambiguity, or stash/restore conflicts should force a user-facing decision.
194
+
193
195
  ## Canonical files
194
196
 
195
197
  This package stores canonical workflow state under:
@@ -64,13 +64,14 @@ These lines are for workflow observability, not hidden reasoning. Keep them brie
64
64
  3. Confirm the canonical slice ID, goal, acceptance criteria, contract IDs, priority, why_now, implementation_surfaces, verification_commands, locked notes, must-fix findings, basis_commit, and before-slice counters in `.agent/active-slice.json` match canonical `.agent/plan.json`. If they do not match, stop and report the mismatch instead of guessing.
65
65
  4. Make truthful `.agent/state.json` and `.agent/active-slice.json` updates before implementation if needed.
66
66
  5. If implementation reveals roadmap-level drift — for example a missing prerequisite slice, invalid slice boundary, dependency reorder, or blocker that changes the current slice contract — do not silently redesign the plan. Report the discrepancy explicitly, make only the minimal truthful local state updates needed for the current slice, and hand control back for canonical re-grounding by `completion-regrounder`.
67
- 6. Make the smallest correct tracked-file change.
68
- 7. Add or strengthen tests or deterministic proof.
69
- 8. Run focused verification first, then broader verification if shared surfaces changed.
70
- 9. If the chosen slice changes top-level validation entrypoints or is explicitly about verifier freshness, refresh `.agent/verify_completion_stop.sh` so it remains a truthful repo-level baseline verifier.
71
- 10. Create a new commit.
72
- 11. Make truthful `.agent/state.json`, `.agent/active-slice.json`, and `.agent/plan.json` updates after the commit, including `current_phase = post_commit_review`, `continuation_policy = continue`, `continuation_reason`, and `next_mandatory_role = completion-reviewer`.
73
- 12. Append exactly one `implemented` record to `.agent/slice-history.jsonl`.
67
+ 6. If unrelated tracked worktree changes are present and would otherwise block the mandatory dirty-worktree reconciliation or the current slice commit, auto-preserve them yourself with a reversible mechanism such as a named git stash plus a `.agent/tmp/dirty-worktree-autostash.json` note, continue the current slice on a clean worktree, and restore them before handing control back. Ask the user only when overlap, ownership ambiguity, or stash/restore conflicts make automatic isolation unsafe.
68
+ 7. Make the smallest correct tracked-file change.
69
+ 8. Add or strengthen tests or deterministic proof.
70
+ 9. Run focused verification first, then broader verification if shared surfaces changed.
71
+ 10. If the chosen slice changes top-level validation entrypoints or is explicitly about verifier freshness, refresh `.agent/verify_completion_stop.sh` so it remains a truthful repo-level baseline verifier.
72
+ 11. Create a new commit.
73
+ 12. Make truthful `.agent/state.json`, `.agent/active-slice.json`, and `.agent/plan.json` updates after the commit, including `current_phase = post_commit_review`, `continuation_policy = continue`, `continuation_reason`, and `next_mandatory_role = completion-reviewer`.
74
+ 13. Append exactly one `implemented` record to `.agent/slice-history.jsonl`.
74
75
 
75
76
  Do not stop after editing or verification if the slice changes remain uncommitted.
76
77
 
@@ -41,14 +41,16 @@ These lines are for workflow observability, not hidden reasoning. Keep them brie
41
41
  5. Reopen any previously `done` slice whose acceptance criteria no longer hold.
42
42
  6. Keep `.agent/state.json` and `.agent/active-slice.json` truthful, including `current_phase`, `continuation_policy`, `continuation_reason`, `next_mandatory_role`, and any exact implementer handoff snapshot fields.
43
43
  7. Reconcile canonical state after review, audit, and final stop verification waves when required.
44
- 8. If the latest committed slice leaves the tracked and unignored worktree dirty, treat that dirty state as a blocker, reopen or continue that latest slice for reconciliation, set `Next role to invoke` to `completion-implementer`, and do not select or hand off any different next slice until it is reconciled.
45
- 9. When reconciling after review, audit, or dirty-worktree follow-up for the latest committed slice, emit an explicit reconciliation record decision:
44
+ 8. If the latest committed slice leaves the tracked and unignored worktree dirty, first classify the dirty tracked files against the latest slice's `implementation_surfaces` and the tracked reconciliation surfaces you need to touch now.
45
+ 9. If the dirty tracked files are unrelated and can be isolated safely, auto-preserve them yourself with a reversible mechanism such as a named git stash plus a `.agent/tmp/dirty-worktree-autostash.json` note, continue the mandatory reconciliation on a clean worktree, and restore them before handing control back. Do not ask the user for this routine unrelated-dirty-worktree case.
46
+ 10. If overlap, ownership ambiguity, or stash/restore conflicts make automatic isolation unsafe, treat that dirty state as a blocker, reopen or continue the latest slice for reconciliation, set `Next role to invoke` to `completion-implementer`, and do not select or hand off any different next slice until it is reconciled.
47
+ 11. When reconciling after review, audit, or dirty-worktree follow-up for the latest committed slice, emit an explicit reconciliation record decision:
46
48
  - `accepted` only when the latest committed slice is truthfully accepted as-is
47
49
  - `reopened` only when the latest committed slice must be reopened for follow-up work
48
50
  - `none` when this re-ground was not a post-commit reconciliation decision
49
- 10. If you emit `accepted` or `reopened`, also emit the exact reconciled slice id in the report.
50
- 11. If a slice is already selected, ensure `.agent/active-slice.json` contains the exact implementer handoff snapshot and return that exact handoff payload for `completion-implementer` instead of implementing it yourself.
51
- 12. If no slice is selected, return the exact next recommended slice and why.
51
+ 12. If you emit `accepted` or `reopened`, also emit the exact reconciled slice id in the report.
52
+ 13. If a slice is already selected, ensure `.agent/active-slice.json` contains the exact implementer handoff snapshot and return that exact handoff payload for `completion-implementer` instead of implementing it yourself.
53
+ 14. If no slice is selected, return the exact next recommended slice and why.
52
54
 
53
55
  Output format:
54
56
 
@@ -257,8 +257,26 @@ function isCompletionDriverPromptTurn(snapshot: CompletionStateSnapshot | undefi
257
257
  return true;
258
258
  }
259
259
 
260
- function isCompletionWorkflowSessionTurn(snapshot: CompletionStateSnapshot | undefined, _ctx: { sessionManager?: any }): boolean {
261
- return hasCompletionRoutingActivation(snapshot) || hasActiveWorkflowEntry(snapshot);
260
+ function workflowContinuationIntentText(text: string | undefined): string {
261
+ return (text ?? "").trim().toLowerCase();
262
+ }
263
+
264
+ function isLikelyWorkflowContinuationTurn(
265
+ snapshot: CompletionStateSnapshot | undefined,
266
+ ctx: { sessionManager?: any },
267
+ ): boolean {
268
+ if (!hasActiveWorkflowEntry(snapshot)) return false;
269
+ const latest = workflowContinuationIntentText(latestUserOrCustomTurnText(ctx));
270
+ if (!latest) return false;
271
+ if (isCookCommandTurn(ctx) || isCompletionDriverPromptTurn(snapshot, ctx)) return true;
272
+ if (asString(snapshot?.state?.continuation_policy) === "await_user_input") return true;
273
+ return /(\b(continue|resume|proceed|go ahead|keep going|next|finish|fix|repair|reconcile|commit|stash|audit|review|reground|implement|phase|slice|batch)\b|\.agent\b|\bworktree\b|\bworkflow\b|\bdirty\b|繼續|继续|開始|开始|先做|先把|修好|修復|修复|清理|處理|处理|提交|下一步|接著|继续做|做完|完成)/iu.test(latest);
274
+ }
275
+
276
+ function isCompletionWorkflowSessionTurn(snapshot: CompletionStateSnapshot | undefined, ctx: { sessionManager?: any }): boolean {
277
+ if (hasCompletionRoutingActivation(snapshot)) return true;
278
+ if (!hasActiveWorkflowEntry(snapshot)) return false;
279
+ return isCookCommandTurn(ctx) || isCompletionDriverPromptTurn(snapshot, ctx) || isLikelyWorkflowContinuationTurn(snapshot, ctx);
262
280
  }
263
281
 
264
282
  function shouldInjectCompletionWorkflowContext(snapshot: CompletionStateSnapshot | undefined, ctx: { sessionManager?: any }): boolean {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linimin/pi-letscook",
3
- "version": "0.1.75",
3
+ "version": "0.1.76",
4
4
  "description": "Pi package for long-running completion workflows with canonical .agent state, role-based subagents, continuity, and verification helpers.",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -42,6 +42,7 @@
42
42
  "context-proposal-test": "bash ./scripts/context-proposal-test.sh",
43
43
  "observability-status-test": "bash ./scripts/observability-status-test.sh",
44
44
  "completion-role-gating-test": "bash ./scripts/completion-role-gating-test.sh",
45
+ "dirty-worktree-policy-test": "bash ./scripts/dirty-worktree-policy-test.sh",
45
46
  "evaluator-calibration-test": "bash ./scripts/evaluator-calibration-test.sh",
46
47
  "rubric-contract-test": "bash ./scripts/rubric-contract-test.sh",
47
48
  "release-check": "bash ./scripts/release-check.sh"
@@ -510,10 +510,7 @@ import sys
510
510
  from pathlib import Path
511
511
 
512
512
  reminder = Path(sys.argv[1])
513
- assert reminder.exists(), 'active selected-slice canonical state should inject the completion reminder on subsequent non-/cook turns'
514
- text = reminder.read_text()
515
- assert 'Completion workflow detected.' in text, 'selected-slice reminder should expose canonical workflow context'
516
- assert 'Verification evidence subject: selected_slice' in text, 'selected-slice reminder should expose the canonical evidence subject'
513
+ assert not reminder.exists(), 'ordinary non-/cook turn should not inject completion reminder solely from selected-slice canonical state'
517
514
  PY
518
515
 
519
516
  python3 - <<'PY'
@@ -21,26 +21,24 @@ const assertNotIncludes = (file, snippet) => {
21
21
  }
22
22
  };
23
23
 
24
+ assertIncludes('extensions/completion/index.ts', 'function isLikelyWorkflowContinuationTurn(');
24
25
  assertIncludes('extensions/completion/index.ts', 'function isCompletionWorkflowSessionTurn(');
25
- assertIncludes('extensions/completion/index.ts', 'return hasCompletionRoutingActivation(snapshot) || hasActiveWorkflowEntry(snapshot);');
26
+ assertIncludes('extensions/completion/index.ts', 'return isCookCommandTurn(ctx) || isCompletionDriverPromptTurn(snapshot, ctx) || isLikelyWorkflowContinuationTurn(snapshot, ctx);');
26
27
  assertIncludes('extensions/completion/index.ts', 'const completionRoleDispatchAllowed = Boolean(role) || isCompletionWorkflowSessionTurn(snapshot, ctx);');
27
28
  assertIncludes('extensions/completion/policy-guards.ts', 'return "completion_role may only be used from an active /cook workflow session.";');
28
- assertIncludes('CHANGELOG.md', 'made active `/cook` workflows sticky across subsequent turns so completion-role dispatch and workflow context continue to self-heal from canonical active state instead of depending on prompt-shaped driver turns');
29
29
  assertIncludes('CHANGELOG.md', 'stopped pushing users to rerun `/cook` for routine active-workflow continuation or exact await-user-input replies when canonical workflow state is already active');
30
30
 
31
- assertNotIncludes('extensions/completion/index.ts', 'function isOrdinaryMainChatTurnDuringActiveWorkflow(');
32
- assertNotIncludes('extensions/completion/index.ts', 'function isCompletionRoleDispatchAllowedTurn(');
33
- assertNotIncludes('extensions/completion/index.ts', 'function isAwaitingUserInputWorkflowReplyTurn(');
31
+ assertNotIncludes('extensions/completion/index.ts', 'return hasCompletionRoutingActivation(snapshot) || hasActiveWorkflowEntry(snapshot);');
34
32
 
35
33
  const indexText = read('extensions/completion/index.ts');
36
- const sessionTurnIndex = indexText.indexOf('function isCompletionWorkflowSessionTurn(');
37
- const stickyReturnIndex = indexText.indexOf('return hasCompletionRoutingActivation(snapshot) || hasActiveWorkflowEntry(snapshot);');
34
+ const continuationIntentIndex = indexText.indexOf('function isLikelyWorkflowContinuationTurn(');
35
+ const stickyReturnIndex = indexText.indexOf('return isCookCommandTurn(ctx) || isCompletionDriverPromptTurn(snapshot, ctx) || isLikelyWorkflowContinuationTurn(snapshot, ctx);');
38
36
  const toolGateIndex = indexText.indexOf('const completionRoleDispatchAllowed = Boolean(role) || isCompletionWorkflowSessionTurn(snapshot, ctx);');
39
- if (sessionTurnIndex === -1 || stickyReturnIndex === -1 || toolGateIndex === -1) {
40
- throw new Error('extensions/completion/index.ts must derive workflow legitimacy from canonical active state and reuse that gate for completion_role dispatch.');
37
+ if (continuationIntentIndex === -1 || stickyReturnIndex === -1 || toolGateIndex === -1) {
38
+ throw new Error('extensions/completion/index.ts must gate workflow continuation through explicit workflow turns or likely continuation turns before dispatching completion_role.');
41
39
  }
42
- if (!(sessionTurnIndex < stickyReturnIndex && stickyReturnIndex < toolGateIndex)) {
43
- throw new Error('extensions/completion/index.ts should define sticky workflow-session detection before reusing it for completion_role dispatch.');
40
+ if (!(continuationIntentIndex < stickyReturnIndex && stickyReturnIndex < toolGateIndex)) {
41
+ throw new Error('extensions/completion/index.ts should define continuation-turn detection before reusing it for completion_role dispatch.');
44
42
  }
45
43
  NODE
46
44
 
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5
+ cd "$ROOT"
6
+
7
+ node <<'NODE'
8
+ const fs = require('node:fs');
9
+
10
+ const read = (file) => fs.readFileSync(file, 'utf8');
11
+ const assertIncludes = (file, snippet) => {
12
+ const text = read(file);
13
+ if (!text.includes(snippet)) {
14
+ throw new Error(`${file} is missing required dirty-worktree policy text: ${snippet}`);
15
+ }
16
+ };
17
+
18
+ assertIncludes('skills/completion-protocol/SKILL.md', 'auto-preserve them with a reversible mechanism such as a named git stash plus a `.agent/tmp/dirty-worktree-autostash.json` note');
19
+ assertIncludes('skills/completion-protocol/SKILL.md', 'Ask the user only when overlap, ownership ambiguity, or stash/restore conflicts make automatic isolation unsafe.');
20
+ assertIncludes('skills/completion-protocol/references/completion.md', 'Dirty-worktree auto-reconcile. If tracked worktree dirt is unrelated to the latest slice or current reconciliation surfaces and can be isolated safely');
21
+ assertIncludes('agents/completion-regrounder.md', 'Do not ask the user for this routine unrelated-dirty-worktree case.');
22
+ assertIncludes('agents/completion-implementer.md', 'auto-preserve them yourself with a reversible mechanism such as a named git stash plus a `.agent/tmp/dirty-worktree-autostash.json` note');
23
+ assertIncludes('README.md', 'Active `/cook` workflows now also auto-reconcile routine unrelated tracked worktree dirt instead of bouncing that decision back to the user.');
24
+ assertIncludes('CHANGELOG.md', 'auto-preserve routine unrelated tracked worktree dirt with a reversible stash-plus-note flow');
25
+ NODE
26
+
27
+ echo "dirty-worktree policy test passed"
@@ -5,7 +5,7 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5
5
  cd "$ROOT"
6
6
  export PI_COMPLETION_RUNNING_RELEASE_CHECK=1
7
7
 
8
- echo "[release-check] running control-plane validation, tracked .agent contract coverage, slice-surface parity, explicit-/cook parity, startup/refocus/context regressions, canonical evidence artifact, active-slice contract, observability, completion-role gating, legacy cleanup, evaluator calibration, and rubric contract coverage"
8
+ echo "[release-check] running control-plane validation, tracked .agent contract coverage, slice-surface parity, explicit-/cook parity, startup/refocus/context regressions, canonical evidence artifact, active-slice contract, observability, completion-role gating, dirty-worktree policy, legacy cleanup, evaluator calibration, and rubric contract coverage"
9
9
  bash .agent/verify_completion_control_plane.sh
10
10
  git ls-files --error-unmatch .agent/README.md .agent/mission.md .agent/profile.json .agent/verify_completion_stop.sh .agent/verify_completion_control_plane.sh >/dev/null
11
11
 
@@ -34,8 +34,8 @@ checks = {
34
34
  'description: "/cook workflow: start or replace workflow only from an explicit primary-agent handoff, or resume the current workflow from canonical state"',
35
35
  '"Do not call completion_role from ordinary chat; it is reserved for active /cook workflow sessions."',
36
36
  '`COMPLETION WORKFLOW DRIVER\\nStart or continue the completion workflow for this repo.',
37
- 'function isCompletionWorkflowSessionTurn(',
38
- 'return hasCompletionRoutingActivation(snapshot) || hasActiveWorkflowEntry(snapshot);',
37
+ 'function isLikelyWorkflowContinuationTurn(',
38
+ 'return isCookCommandTurn(ctx) || isCompletionDriverPromptTurn(snapshot, ctx) || isLikelyWorkflowContinuationTurn(snapshot, ctx);',
39
39
  ],
40
40
  "extensions/completion/policy-guards.ts": [
41
41
  'return "completion_role may only be used from an active /cook workflow session.";',
@@ -84,6 +84,7 @@ bash ./scripts/canonical-evidence-artifact-test.sh
84
84
  bash ./scripts/active-slice-contract-test.sh
85
85
  npm run observability-status-test
86
86
  npm run completion-role-gating-test
87
+ npm run dirty-worktree-policy-test
87
88
  bash ./scripts/legacy-cleanup-test.sh
88
89
  npm run evaluator-calibration-test
89
90
  npm run rubric-contract-test
@@ -273,15 +273,20 @@ reminder = Path(sys.argv[3])
273
273
  handoff = Path(sys.argv[4])
274
274
  auto_resume = Path(sys.argv[5])
275
275
 
276
- assert reminder.exists(), 'active workflow should inject the completion reminder on subsequent non-/cook turns'
277
- reminder_text = reminder.read_text()
278
- assert 'Completion workflow detected.' in reminder_text, 'active workflow reminder should inject canonical workflow context'
279
- assert 'If continuation_policy == continue, do not stop after a slice or ask whether to continue; dispatch the next mandatory role directly.' in reminder_text, 'active workflow reminder should direct mandatory continuation'
280
- assert not handoff.exists(), 'active workflow should not fall back to the ordinary /cook handoff boundary reminder'
281
- if auto_resume.exists():
282
- auto_resume_text = auto_resume.read_text()
283
- assert 'COMPLETION WORKFLOW DRIVER' in auto_resume_text, 'auto-resume prompt should use the workflow driver format when it is queued'
284
- assert 'Resume the completion workflow from canonical state.' in auto_resume_text, 'auto-resume prompt should resume canonical workflow state when it is queued'
276
+ assert not reminder.exists(), 'ordinary non-/cook turn should not inject completion reminder solely from canonical state'
277
+ assert handoff.exists(), 'ordinary non-/cook turn should inject the /cook handoff boundary reminder'
278
+ handoff_text = handoff.read_text()
279
+ assert 'ordinary main chat unless the user explicitly runs /cook' in handoff_text, 'ordinary handoff reminder should preserve explicit /cook workflow entry'
280
+ assert 'directly implement requested repo changes, including multi-file work' in handoff_text, 'ordinary handoff reminder should allow direct ordinary-chat implementation'
281
+ assert 'Do not proactively tell the user to run /cook' in handoff_text, 'ordinary handoff reminder should keep ordinary chat neutral until explicit /cook entry'
282
+ assert '/cook is optional workflow mode' in handoff_text, 'ordinary handoff reminder should position /cook as optional workflow mode'
283
+ assert 'In ordinary chat, do not load or follow completion-protocol, and do not call completion_role.' in handoff_text, 'ordinary handoff reminder should forbid workflow-role routing before explicit /cook'
284
+ assert 'If the user wants direct implementation now, stay in ordinary chat and help directly instead of blocking on /cook.' in handoff_text, 'ordinary handoff reminder should avoid blocking implementation on /cook'
285
+ assert 'the extension should call a primary-agent handoff synthesis step from the current task context' in handoff_text, 'ordinary handoff reminder should describe same-entry primary-agent handoff synthesis for /cook'
286
+ assert 'Do not expect /cook to infer or guess startup intent from recent discussion alone' in handoff_text, 'ordinary handoff reminder should forbid /cook-side guessing'
287
+ assert 'do not silently rewrite discussion into canonical workflow state' in handoff_text, 'ordinary handoff reminder should preserve non-canonical ordinary-chat behavior'
288
+ assert not auto_resume.exists(), 'ordinary non-/cook turn should not queue auto-resume before /cook activation'
289
+ assert 'Skipped completion workflow auto-resume prompt (test mode)' not in output, 'ordinary non-/cook turn should not attempt auto-resume'
285
290
  PY
286
291
 
287
292
  PI_COMPLETION_SKIP_DRIVER_KICKOFF=1 \
@@ -303,11 +308,10 @@ routing = json.loads(Path(sys.argv[2]).read_text())
303
308
  chooser_path = Path(sys.argv[3])
304
309
  state = json.loads(Path('.agent/state.json').read_text())
305
310
 
306
- if resume_path.exists():
307
- resume = resume_path.read_text()
308
- assert 'Canonical routing profile:' in resume, 'resume prompt should expose canonical routing profile when it is queued'
309
- assert f'- task_type: {expected_task_type}' in resume, 'resume prompt missing canonical task_type when it is queued'
310
- assert f'- evaluation_profile: {expected_eval_profile}' in resume, 'resume prompt missing canonical evaluation_profile when it is queued'
311
+ resume = resume_path.read_text()
312
+ assert 'Canonical routing profile:' in resume, 'resume prompt should expose canonical routing profile'
313
+ assert f'- task_type: {expected_task_type}' in resume, 'resume prompt missing canonical task_type'
314
+ assert f'- evaluation_profile: {expected_eval_profile}' in resume, 'resume prompt missing canonical evaluation_profile'
311
315
  assert routing['mode'] == 'bare', 'active bare /cook should snapshot bare routing mode'
312
316
  assert routing['action'] == 'continue', 'no-discussion active bare /cook should resume from canonical state without a concrete replacement mission'
313
317
  assert routing['reason'] == 'missing_explicit_handoff', 'no-discussion active bare /cook should explain that resume happened because no fresh explicit handoff existed'
@@ -32,6 +32,7 @@ This skill defines shared protocol facts only. Role-specific behavior belongs in
32
32
  - Run exactly one implementation slice at a time.
33
33
  - A slice is not complete unless it lands as a new commit.
34
34
  - Before selecting or advancing to the next slice after a committed slice, the tracked and unignored worktree must be clean. If it is not clean, treat that dirty state as a blocker to next-slice progression and reopen or continue the latest slice for reconciliation.
35
+ - When that dirty tracked worktree contains changes unrelated to the latest slice or current reconciliation surfaces and those changes can be isolated safely, auto-preserve them with a reversible mechanism such as a named git stash plus a `.agent/tmp/dirty-worktree-autostash.json` note, continue the mandatory workflow step, and restore them before handing control back. Ask the user only when overlap, ownership ambiguity, or stash/restore conflicts make automatic isolation unsafe.
35
36
  - Docs, config, and runbooks must stay truthful to shipped behavior.
36
37
  - `.agent/verify_completion_stop.sh` is a generated repo-level baseline verifier. Onboarding should create a working version from current repo truth rather than an unconditional failing placeholder.
37
38
  - The packaged default stop policy is `required_stop_judges: 2` plus `stop_aggregation_policy: "unanimous-current-head-v1"` in `.agent/profile.json`.
@@ -168,6 +168,7 @@ Rules:
168
168
  3. Done requires all satisfied. A slice may only transition to `done` when every acceptance criterion is satisfied and `evidence` contains the proof for each one.
169
169
  4. Re-ground validation. During re-ground, the current slice backlog must be revalidated against repo truth. A slice previously marked `done` whose criteria no longer hold must be reopened.
170
170
  5. Clean handoff before next slice. After a committed slice is reviewed and audited, the tracked and unignored worktree must be clean before the next slice is selected.
171
+ 6. Dirty-worktree auto-reconcile. If tracked worktree dirt is unrelated to the latest slice or current reconciliation surfaces and can be isolated safely, the workflow should auto-preserve it with a reversible mechanism such as a named git stash plus a `.agent/tmp/dirty-worktree-autostash.json` note, continue the mandatory workflow step, and restore it before handing control back. Ask the user only when overlap, ownership ambiguity, or stash/restore conflicts make automatic isolation unsafe.
171
172
 
172
173
  `active-slice.json` carries one current slice cursor.
173
174