@linimin/pi-letscook 0.1.43 → 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,12 @@
|
|
|
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
|
+
|
|
5
11
|
## 0.1.43
|
|
6
12
|
|
|
7
13
|
### Fixed
|
|
@@ -563,7 +563,22 @@ function isWorkflowDone(snapshot: CompletionStateSnapshot | undefined): boolean
|
|
|
563
563
|
}
|
|
564
564
|
|
|
565
565
|
function shouldInjectCompletionWorkflowContext(snapshot: CompletionStateSnapshot | undefined): boolean {
|
|
566
|
-
return Boolean(snapshot)
|
|
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(" ");
|
|
567
582
|
}
|
|
568
583
|
|
|
569
584
|
function extractTextFromMessageContent(content: unknown): string {
|
|
@@ -3738,18 +3753,22 @@ export default function completionExtension(pi: ExtensionAPI) {
|
|
|
3738
3753
|
if (fingerprint) markQueuedDriverPromptInFlight(rootKey, fingerprint);
|
|
3739
3754
|
}
|
|
3740
3755
|
if (!loaded || !shouldInjectCompletionWorkflowContext(loaded.snapshot)) return;
|
|
3741
|
-
const
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
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
|
+
}
|
|
3749
3769
|
}
|
|
3770
|
+
if (marker) additions.push(buildPostCompactionDriverInstructions(loaded.snapshot, marker));
|
|
3750
3771
|
}
|
|
3751
|
-
const additions = [buildSystemReminder(loaded.snapshot, loaded.sliceHistory, loaded.stopHistory)];
|
|
3752
|
-
if (marker) additions.push(buildPostCompactionDriverInstructions(loaded.snapshot, marker));
|
|
3753
3772
|
maybeWriteTestSnapshot(completionTestSystemReminderPath(), additions.join("\n\n"));
|
|
3754
3773
|
const systemPrompt = getSystemPromptSafe(ctx);
|
|
3755
3774
|
if (!systemPrompt) return;
|
|
@@ -3760,7 +3779,7 @@ export default function completionExtension(pi: ExtensionAPI) {
|
|
|
3760
3779
|
|
|
3761
3780
|
pi.on("session_before_compact", async (event, ctx) => {
|
|
3762
3781
|
const loaded = await loadCompletionDataForReminder(getCtxCwd(ctx));
|
|
3763
|
-
if (!loaded ||
|
|
3782
|
+
if (!loaded || isWorkflowDone(loaded.snapshot)) return;
|
|
3764
3783
|
const { preparation } = event;
|
|
3765
3784
|
const summary = buildResumeCapsule(loaded.snapshot, loaded.sliceHistory, loaded.stopHistory);
|
|
3766
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.
|
|
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,
|
|
@@ -431,9 +431,17 @@ PI_COMPLETION_TEST_SYSTEM_REMINDER_PATH="$SYSTEM_REMINDER" \
|
|
|
431
431
|
pi -e "$PKG_ROOT" -p "Summarize the latest release briefly." \
|
|
432
432
|
>"$TMPDIR/pi-canonical-evidence-done-reminder.out" 2>"$TMPDIR/pi-canonical-evidence-done-reminder.err"
|
|
433
433
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
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
|
|
438
446
|
|
|
439
447
|
echo "canonical evidence artifact test passed: $TMPDIR"
|