@linimin/pi-letscook 0.1.44 → 0.1.45
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.
|
@@ -223,6 +223,7 @@ class StartupAnalystOverlay extends Container {
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
const liveRoleActivityByRoot = new Map<string, LiveRoleActivity>();
|
|
226
|
+
const activatedCompletionRoutingRoots = new Set<string>();
|
|
226
227
|
const LIVE_ROLE_WAITING_MS = 15_000;
|
|
227
228
|
const LIVE_ROLE_STALLED_MS = 45_000;
|
|
228
229
|
const LIVE_ROLE_HEARTBEAT_MS = 5_000;
|
|
@@ -562,8 +563,19 @@ function isWorkflowDone(snapshot: CompletionStateSnapshot | undefined): boolean
|
|
|
562
563
|
return asString(snapshot?.state?.continuation_policy) === "done";
|
|
563
564
|
}
|
|
564
565
|
|
|
566
|
+
function activateCompletionRoutingForRoot(root: string | undefined): void {
|
|
567
|
+
if (!root) return;
|
|
568
|
+
activatedCompletionRoutingRoots.add(path.resolve(root));
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
function hasCompletionRoutingActivation(snapshot: CompletionStateSnapshot | undefined): boolean {
|
|
572
|
+
if (!snapshot) return false;
|
|
573
|
+
if (roleFromEnv()) return true;
|
|
574
|
+
return activatedCompletionRoutingRoots.has(path.resolve(snapshot.files.root));
|
|
575
|
+
}
|
|
576
|
+
|
|
565
577
|
function shouldInjectCompletionWorkflowContext(snapshot: CompletionStateSnapshot | undefined): boolean {
|
|
566
|
-
return
|
|
578
|
+
return hasCompletionRoutingActivation(snapshot);
|
|
567
579
|
}
|
|
568
580
|
|
|
569
581
|
function buildDoneWorkflowBoundaryReminder(snapshot: CompletionStateSnapshot): string {
|
|
@@ -1933,6 +1945,7 @@ async function autoContinueWorkflowIfNeeded(pi: ExtensionAPI, ctx: { cwd: string
|
|
|
1933
1945
|
clearDriverContinuationTracker(rootKey);
|
|
1934
1946
|
return;
|
|
1935
1947
|
}
|
|
1948
|
+
if (!hasCompletionRoutingActivation(snapshot)) return;
|
|
1936
1949
|
const fingerprint = completionContinuationFingerprint(snapshot);
|
|
1937
1950
|
if (!fingerprint) {
|
|
1938
1951
|
clearDriverContinuationTracker(rootKey);
|
|
@@ -2102,6 +2115,7 @@ async function resumeActiveWorkflowFromCanonicalState(
|
|
|
2102
2115
|
ctx: { cwd: string; hasUI: boolean; ui: any },
|
|
2103
2116
|
snapshot: CompletionStateSnapshot,
|
|
2104
2117
|
): Promise<void> {
|
|
2118
|
+
activateCompletionRoutingForRoot(snapshot.files.root);
|
|
2105
2119
|
const mission = currentMissionAnchor(snapshot);
|
|
2106
2120
|
pi.setSessionName(`completion: ${mission.slice(0, 60)}`);
|
|
2107
2121
|
const resumePrompt = completionResumePrompt(
|
|
@@ -4230,6 +4244,7 @@ export default function completionExtension(pi: ExtensionAPI) {
|
|
|
4230
4244
|
}
|
|
4231
4245
|
}
|
|
4232
4246
|
kickoffMissionAnchor = kickoffMissionAnchor ?? currentMissionAnchor(snapshot);
|
|
4247
|
+
activateCompletionRoutingForRoot(snapshot.files.root);
|
|
4233
4248
|
pi.setSessionName(`completion: ${kickoffMissionAnchor.slice(0, 60)}`);
|
|
4234
4249
|
const kickoffPrompt = completionKickoff(
|
|
4235
4250
|
goal,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linimin/pi-letscook",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.45",
|
|
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,
|
|
@@ -3,7 +3,7 @@ set -euo pipefail
|
|
|
3
3
|
|
|
4
4
|
PKG_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
5
5
|
pi() {
|
|
6
|
-
command pi --no-extensions "$@"
|
|
6
|
+
env -u PI_COMPLETION_ROLE command pi --no-extensions "$@"
|
|
7
7
|
}
|
|
8
8
|
TMPDIR="$(mktemp -d)"
|
|
9
9
|
CURRENT_EVIDENCE_BACKUP=""
|
|
@@ -377,6 +377,7 @@ PY
|
|
|
377
377
|
bash .agent/verify_completion_control_plane.sh >/dev/null
|
|
378
378
|
bash .agent/verify_completion_stop.sh >/dev/null
|
|
379
379
|
|
|
380
|
+
rm -f "$SYSTEM_REMINDER"
|
|
380
381
|
PI_COMPLETION_TEST_SYSTEM_REMINDER_PATH="$SYSTEM_REMINDER" \
|
|
381
382
|
pi -e "$PKG_ROOT" -p "Summarize the completion reminder briefly." \
|
|
382
383
|
>"$TMPDIR/pi-canonical-evidence-reminder.out" 2>"$TMPDIR/pi-canonical-evidence-reminder.err"
|
|
@@ -385,11 +386,8 @@ python3 - "$SYSTEM_REMINDER" <<'PY'
|
|
|
385
386
|
import sys
|
|
386
387
|
from pathlib import Path
|
|
387
388
|
|
|
388
|
-
|
|
389
|
-
assert '
|
|
390
|
-
assert 'Verification evidence artifact: .agent/verification-evidence.json (present)' in text, text
|
|
391
|
-
assert 'Verification evidence summary:' in text, text
|
|
392
|
-
assert 'selected_slice' in text, text
|
|
389
|
+
reminder = Path(sys.argv[1])
|
|
390
|
+
assert not reminder.exists(), 'ordinary non-/cook turn should not inject completion reminder solely from selected-slice canonical state'
|
|
393
391
|
PY
|
|
394
392
|
|
|
395
393
|
python3 - <<'PY'
|
|
@@ -435,13 +433,8 @@ python3 - "$SYSTEM_REMINDER" <<'PY'
|
|
|
435
433
|
import sys
|
|
436
434
|
from pathlib import Path
|
|
437
435
|
|
|
438
|
-
|
|
439
|
-
assert '
|
|
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
|
|
436
|
+
reminder = Path(sys.argv[1])
|
|
437
|
+
assert not reminder.exists(), 'ordinary non-/cook turn should not inject closed-workflow boundary routing before /cook reactivation'
|
|
445
438
|
PY
|
|
446
439
|
|
|
447
440
|
echo "canonical evidence artifact test passed: $TMPDIR"
|
package/scripts/smoke-test.sh
CHANGED
|
@@ -3,7 +3,7 @@ set -euo pipefail
|
|
|
3
3
|
|
|
4
4
|
PKG_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
5
5
|
pi() {
|
|
6
|
-
command pi --no-extensions "$@"
|
|
6
|
+
env -u PI_COMPLETION_ROLE command pi --no-extensions "$@"
|
|
7
7
|
}
|
|
8
8
|
TMPDIR="$(mktemp -d)"
|
|
9
9
|
trap 'rm -rf "$TMPDIR"' EXIT
|
|
@@ -50,8 +50,10 @@ PY
|
|
|
50
50
|
ROOT="$TMPDIR/repo"
|
|
51
51
|
KICKOFF_PROMPT="$TMPDIR/kickoff-prompt.txt"
|
|
52
52
|
RESUME_PROMPT="$TMPDIR/resume-prompt.txt"
|
|
53
|
+
ORDINARY_SYSTEM_REMINDER="$TMPDIR/ordinary-system-reminder.txt"
|
|
53
54
|
UNCLEAR_ROUTING_SNAPSHOT="$TMPDIR/active-unclear-routing.json"
|
|
54
55
|
UNCLEAR_CHOOSER_SNAPSHOT="$TMPDIR/unexpected-existing-workflow-chooser.json"
|
|
56
|
+
ORDINARY_AUTO_RESUME_PROMPT="$TMPDIR/ordinary-auto-resume-prompt.txt"
|
|
55
57
|
AUTO_RESUME_PROMPT="$TMPDIR/auto-resume-prompt.txt"
|
|
56
58
|
INLINE_REJECTION_ROUTING_SNAPSHOT="$TMPDIR/inline-arg-routing.json"
|
|
57
59
|
INLINE_REJECTION_PROPOSAL_SNAPSHOT="$TMPDIR/inline-arg-proposal.json"
|
|
@@ -139,6 +141,27 @@ assert f'- task_type: {expected_task_type}' in kickoff, 'kickoff prompt missing
|
|
|
139
141
|
assert f'- evaluation_profile: {expected_eval_profile}' in kickoff, 'kickoff prompt missing canonical evaluation_profile'
|
|
140
142
|
PY
|
|
141
143
|
|
|
144
|
+
rm -f "$ORDINARY_SYSTEM_REMINDER" "$ORDINARY_AUTO_RESUME_PROMPT"
|
|
145
|
+
PI_COMPLETION_SKIP_DRIVER_KICKOFF=1 \
|
|
146
|
+
PI_COMPLETION_TEST_SYSTEM_REMINDER_PATH="$ORDINARY_SYSTEM_REMINDER" \
|
|
147
|
+
PI_COMPLETION_TEST_AUTO_CONTINUE_ON_SESSION_START=1 \
|
|
148
|
+
PI_COMPLETION_TEST_AUTO_CONTINUE_PROMPT_PATH="$ORDINARY_AUTO_RESUME_PROMPT" \
|
|
149
|
+
pi -e "$PKG_ROOT" -p "Summarize the repo briefly." \
|
|
150
|
+
>"$TMPDIR/pi-completion-smoke-ordinary.out" 2>"$TMPDIR/pi-completion-smoke-ordinary.err"
|
|
151
|
+
|
|
152
|
+
python3 - "$TMPDIR/pi-completion-smoke-ordinary.out" "$TMPDIR/pi-completion-smoke-ordinary.err" "$ORDINARY_SYSTEM_REMINDER" "$ORDINARY_AUTO_RESUME_PROMPT" <<'PY'
|
|
153
|
+
import sys
|
|
154
|
+
from pathlib import Path
|
|
155
|
+
|
|
156
|
+
output = Path(sys.argv[1]).read_text() + Path(sys.argv[2]).read_text()
|
|
157
|
+
reminder = Path(sys.argv[3])
|
|
158
|
+
auto_resume = Path(sys.argv[4])
|
|
159
|
+
|
|
160
|
+
assert not reminder.exists(), 'ordinary non-/cook turn should not inject completion reminder solely from canonical state'
|
|
161
|
+
assert not auto_resume.exists(), 'ordinary non-/cook turn should not queue auto-resume before /cook activation'
|
|
162
|
+
assert 'Skipped completion workflow auto-resume prompt (test mode)' not in output, 'ordinary non-/cook turn should not attempt auto-resume'
|
|
163
|
+
PY
|
|
164
|
+
|
|
142
165
|
PI_COMPLETION_SKIP_DRIVER_KICKOFF=1 \
|
|
143
166
|
PI_COMPLETION_TEST_DRIVER_PROMPT_PATH="$RESUME_PROMPT" \
|
|
144
167
|
PI_COMPLETION_TEST_ACTIVE_WORKFLOW_ROUTING_PATH="$UNCLEAR_ROUTING_SNAPSHOT" \
|