@linimin/pi-letscook 0.1.42 → 0.1.44

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
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.1.44
6
+
7
+ ### Fixed
8
+
9
+ - inject a done-workflow boundary prompt into ordinary primary-agent turns so finished completion state is treated as historical context only and the agent must not resume/reground/refocus the workflow unless the user explicitly reruns `/cook`
10
+
11
+ ## 0.1.43
12
+
13
+ ### Fixed
14
+
15
+ - stopped injecting completion-workflow reminder and compaction-resume context into ordinary primary-agent turns after canonical `continuation_policy` reaches `done`, so users must rerun `/cook` before the workflow protocol reactivates
16
+
5
17
  ## 0.1.42
6
18
 
7
19
  ### Changed
@@ -562,6 +562,25 @@ function isWorkflowDone(snapshot: CompletionStateSnapshot | undefined): boolean
562
562
  return asString(snapshot?.state?.continuation_policy) === "done";
563
563
  }
564
564
 
565
+ function shouldInjectCompletionWorkflowContext(snapshot: CompletionStateSnapshot | undefined): boolean {
566
+ return Boolean(snapshot);
567
+ }
568
+
569
+ function buildDoneWorkflowBoundaryReminder(snapshot: CompletionStateSnapshot): string {
570
+ const missionAnchor = asString(snapshot.state?.mission_anchor) ?? asString(snapshot.plan?.mission_anchor) ?? "(unknown)";
571
+ const continuationReason = asString(snapshot.state?.continuation_reason) ?? "(unknown)";
572
+ return [
573
+ "A previous completion workflow exists for this repo, but it is closed.",
574
+ `Mission anchor: ${missionAnchor}`,
575
+ `Continuation policy: ${asString(snapshot.state?.continuation_policy) ?? "unknown"}`,
576
+ `Continuation reason: ${continuationReason}`,
577
+ "Treat the previous completion workflow as historical context only.",
578
+ "Do not resume, reground, refocus, reopen, or otherwise restart completion workflow from this context unless the user explicitly runs /cook.",
579
+ "For ordinary user requests, respond normally and ignore prior completion-protocol instructions that were only relevant to the finished workflow.",
580
+ "Only /cook may reactivate workflow routing for the next round.",
581
+ ].join(" ");
582
+ }
583
+
565
584
  function extractTextFromMessageContent(content: unknown): string {
566
585
  if (typeof content === "string") return content.trim();
567
586
  if (!Array.isArray(content)) return "";
@@ -3733,19 +3752,23 @@ export default function completionExtension(pi: ExtensionAPI) {
3733
3752
  const fingerprint = completionContinuationFingerprint(loaded.snapshot);
3734
3753
  if (fingerprint) markQueuedDriverPromptInFlight(rootKey, fingerprint);
3735
3754
  }
3736
- if (!loaded) return;
3737
- const markerText = await readText(loaded.snapshot.files.compactionMarkerPath);
3738
- let marker: JsonRecord | undefined;
3739
- if (markerText) {
3740
- try {
3741
- const parsed = JSON.parse(markerText);
3742
- marker = isRecord(parsed) ? parsed : undefined;
3743
- } catch {
3744
- marker = undefined;
3755
+ if (!loaded || !shouldInjectCompletionWorkflowContext(loaded.snapshot)) return;
3756
+ const additions = isWorkflowDone(loaded.snapshot)
3757
+ ? [buildDoneWorkflowBoundaryReminder(loaded.snapshot)]
3758
+ : [buildSystemReminder(loaded.snapshot, loaded.sliceHistory, loaded.stopHistory)];
3759
+ if (!isWorkflowDone(loaded.snapshot)) {
3760
+ const markerText = await readText(loaded.snapshot.files.compactionMarkerPath);
3761
+ let marker: JsonRecord | undefined;
3762
+ if (markerText) {
3763
+ try {
3764
+ const parsed = JSON.parse(markerText);
3765
+ marker = isRecord(parsed) ? parsed : undefined;
3766
+ } catch {
3767
+ marker = undefined;
3768
+ }
3745
3769
  }
3770
+ if (marker) additions.push(buildPostCompactionDriverInstructions(loaded.snapshot, marker));
3746
3771
  }
3747
- const additions = [buildSystemReminder(loaded.snapshot, loaded.sliceHistory, loaded.stopHistory)];
3748
- if (marker) additions.push(buildPostCompactionDriverInstructions(loaded.snapshot, marker));
3749
3772
  maybeWriteTestSnapshot(completionTestSystemReminderPath(), additions.join("\n\n"));
3750
3773
  const systemPrompt = getSystemPromptSafe(ctx);
3751
3774
  if (!systemPrompt) return;
@@ -3756,7 +3779,7 @@ export default function completionExtension(pi: ExtensionAPI) {
3756
3779
 
3757
3780
  pi.on("session_before_compact", async (event, ctx) => {
3758
3781
  const loaded = await loadCompletionDataForReminder(getCtxCwd(ctx));
3759
- if (!loaded) return;
3782
+ if (!loaded || isWorkflowDone(loaded.snapshot)) return;
3760
3783
  const { preparation } = event;
3761
3784
  const summary = buildResumeCapsule(loaded.snapshot, loaded.sliceHistory, loaded.stopHistory);
3762
3785
  await fsp.mkdir(loaded.snapshot.files.tmpDir, { recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linimin/pi-letscook",
3
- "version": "0.1.42",
3
+ "version": "0.1.44",
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,
@@ -392,4 +392,56 @@ assert 'Verification evidence summary:' in text, text
392
392
  assert 'selected_slice' in text, text
393
393
  PY
394
394
 
395
+ python3 - <<'PY'
396
+ import json
397
+ from pathlib import Path
398
+
399
+ state_path = Path('.agent/state.json')
400
+ plan_path = Path('.agent/plan.json')
401
+ active_path = Path('.agent/active-slice.json')
402
+
403
+ state = json.loads(state_path.read_text())
404
+ state.update({
405
+ 'current_phase': 'done',
406
+ 'continuation_policy': 'done',
407
+ 'continuation_reason': 'Fixture is complete; ordinary primary-agent turns should stay outside completion until /cook runs again.',
408
+ 'project_done': True,
409
+ 'remaining_high_value_gaps': 0,
410
+ 'unsatisfied_contract_ids': [],
411
+ 'next_mandatory_action': None,
412
+ 'next_mandatory_role': None,
413
+ 'remaining_stop_judges': 0,
414
+ 'contract_status': 'done',
415
+ })
416
+ state_path.write_text(json.dumps(state, indent=2) + '\n')
417
+
418
+ plan = json.loads(plan_path.read_text())
419
+ for slice_data in plan.get('candidate_slices', []):
420
+ if slice_data.get('slice_id') == 'evidence-fixture':
421
+ slice_data['status'] = 'done'
422
+ plan_path.write_text(json.dumps(plan, indent=2) + '\n')
423
+
424
+ active = json.loads(active_path.read_text())
425
+ active['status'] = 'done'
426
+ active_path.write_text(json.dumps(active, indent=2) + '\n')
427
+ PY
428
+
429
+ rm -f "$SYSTEM_REMINDER"
430
+ PI_COMPLETION_TEST_SYSTEM_REMINDER_PATH="$SYSTEM_REMINDER" \
431
+ pi -e "$PKG_ROOT" -p "Summarize the latest release briefly." \
432
+ >"$TMPDIR/pi-canonical-evidence-done-reminder.out" 2>"$TMPDIR/pi-canonical-evidence-done-reminder.err"
433
+
434
+ python3 - "$SYSTEM_REMINDER" <<'PY'
435
+ import sys
436
+ from pathlib import Path
437
+
438
+ text = Path(sys.argv[1]).read_text()
439
+ assert 'A previous completion workflow exists for this repo, but it is closed.' in text, text
440
+ assert 'Treat the previous completion workflow as historical context only.' in text, text
441
+ assert 'Do not resume, reground, refocus, reopen, or otherwise restart completion workflow from this context unless the user explicitly runs /cook.' in text, text
442
+ assert 'For ordinary user requests, respond normally and ignore prior completion-protocol instructions that were only relevant to the finished workflow.' in text, text
443
+ assert 'Only /cook may reactivate workflow routing for the next round.' in text, text
444
+ assert 'Completion workflow detected.' not in text, text
445
+ PY
446
+
395
447
  echo "canonical evidence artifact test passed: $TMPDIR"