pi-dev-flow 0.86.0 → 0.86.2
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 +14 -0
- package/extensions/dev-flow.ts +47 -9
- package/package.json +1 -1
- package/src/core.ts +20 -0
- package/src/runtime/base.ts +21 -6
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.86.2] - 2026-11-09
|
|
8
|
+
|
|
9
|
+
**Stale stage chips in pi-web clear themselves after a dropped connection.**
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
- **pi-web no longer piles up old stage chips beside the current one.** dev-flow's chip in pi-web is labelled with the stage, so each stage change removes the old chip and adds a new one. If the browser's connection was down at that moment (a phone in the background, say), it missed the removal, and pi-web does not re-sync chips on reconnect, so one stale chip was left per missed stage change. Every repaint now re-sends the removal for the last few chips the session showed, so a missed one disappears at the next turn.
|
|
13
|
+
|
|
14
|
+
## [0.86.1] - 2026-11-08
|
|
15
|
+
|
|
16
|
+
**A reply that stops mid-thought resumes on its own instead of stalling the flow.**
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- **A reply that stops mid-thought no longer stalls a flow.** Some providers end a reply inside the model's reasoning with a normal "stop": no answer, no tool call. pi took that as a finished turn and went idle, so the flow sat mid-stage until you typed "continue". With a flow bound, dev-flow now shows a one-line note and asks pi for one more request. It does this once in a row: a second hollow stop is reported instead of retried, so a broken model cannot loop. Errors, aborts and stage workers (which have their own nudges) are left alone.
|
|
20
|
+
|
|
7
21
|
## [0.86.0] - 2026-11-08
|
|
8
22
|
|
|
9
23
|
**Gate results show you facts and the one question waiting on you, never a command to type, and the stage line is written by the gate.**
|
package/extensions/dev-flow.ts
CHANGED
|
@@ -24,12 +24,12 @@ import path from "node:path";
|
|
|
24
24
|
import { Type } from "typebox";
|
|
25
25
|
import { compact, defineTool, isToolCallEventType, type AgentSession, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
26
26
|
import { type ExtensionAPI, type ToolCallEvent, type ToolCallEventResult, type TurnEndEvent, type TurnEndEventResult } from "@earendil-works/pi-coding-agent";
|
|
27
|
-
import { ALLOW_REWRITE, applicableItems, bashFlowGuard, checklistPending, checkoutInvocation, claimBlocks, featureBranchPrefix, FLOW_SHELL_HINT, flowShellInvocation, forcePushInvocation, freshenChecks, gitInvocation, guardBash, guardPath, mergeStyleInvocation, parsePushRefs, playbookTamper, playbookOnlyChange, pluginVersion, reflectionNudges, buildReflectBrief, parseReflectReport, renderReflectFindings, childSessionFiles, workerSteer, WORKER_STEER_AT, WORKER_SALVAGE, WORKER_SALVAGE_MS, WORKER_NUDGE_READONLY, stageReference, needsOperator, NEEDS_OPERATOR, nextHint, roadmapOpenCount, shouldTakeOverCompaction, stageGuidance, stateTamper, statusFor, sq, featureTmpDir, compactionStateBlock, withTmpDir, widgetLines, chipLabel, writeGuard, buildWorkerBrief, clampBudgetMin, parseWorkerReport, workerTurnError, workerOpError, WORKER_NUDGE, WORKER_NUDGES, releaseOrderInvocation, type WorkerOp, type FlowState, type PushRef } from "../src/core.ts";
|
|
27
|
+
import { ALLOW_REWRITE, applicableItems, bashFlowGuard, checklistPending, checkoutInvocation, claimBlocks, featureBranchPrefix, FLOW_SHELL_HINT, flowShellInvocation, forcePushInvocation, freshenChecks, gitInvocation, guardBash, guardPath, mergeStyleInvocation, parsePushRefs, playbookTamper, playbookOnlyChange, pluginVersion, reflectionNudges, buildReflectBrief, parseReflectReport, renderReflectFindings, childSessionFiles, workerSteer, WORKER_STEER_AT, WORKER_SALVAGE, WORKER_SALVAGE_MS, WORKER_NUDGE_READONLY, stageReference, needsOperator, NEEDS_OPERATOR, nextHint, roadmapOpenCount, shouldTakeOverCompaction, stageGuidance, stateTamper, statusFor, sq, featureTmpDir, compactionStateBlock, withTmpDir, widgetLines, chipLabel, writeGuard, buildWorkerBrief, clampBudgetMin, parseWorkerReport, workerTurnError, hollowStop, hollowStopNote, workerOpError, WORKER_NUDGE, WORKER_NUDGES, releaseOrderInvocation, type WorkerOp, type FlowState, type PushRef } from "../src/core.ts";
|
|
28
28
|
import { loadProject } from "../src/projectmd.ts";
|
|
29
29
|
import { bashTimeout, requireTimeout, timeoutClass } from "../src/timeouts.ts";
|
|
30
30
|
import { AGENT_MARK, operatorCommandAsks, operatorCommandCorrection, viewHeader, askLine, type GateView } from "../src/present.ts";
|
|
31
31
|
import { Text } from "@earendil-works/pi-tui";
|
|
32
|
-
import { CONTEXT_EMITTED, COPIES, GATE_HELP, SELF_BUILD, SKILL_DIR, type Ui, WEB_CHIP_KEYS, baseSeams, bindings, boundFeature, claimBlocker, claimFile, compacting, compactionTakeover, coreInjected, coreStale, currentBranch, dfDir, featDir, featureRefs, flowCompactInstructions, flowRoot, guardsAreMine, initiated, lastContext, loadedVersion, maybeCompactNow, noteFriction, now, readClaim, readReflections, readReflectionsText, readRoadmap, readState, registerCopy, releaseSession, sessionKey, sh, skillCore, unfinishedStates, worktreeAbs, writeClaim, writeState } from "../src/runtime/base.ts";
|
|
32
|
+
import { CONTEXT_EMITTED, COPIES, GATE_HELP, SELF_BUILD, SKILL_DIR, type Ui, WEB_CHIP_KEYS, LEGACY_CHIP_KEYS, nextChipKeys, baseSeams, bindings, boundFeature, claimBlocker, claimFile, compacting, compactionTakeover, coreInjected, coreStale, currentBranch, dfDir, featDir, featureRefs, flowCompactInstructions, flowRoot, guardsAreMine, initiated, lastContext, loadedVersion, maybeCompactNow, noteFriction, now, readClaim, readReflections, readReflectionsText, readRoadmap, readState, registerCopy, releaseSession, sessionKey, sh, skillCore, unfinishedStates, worktreeAbs, writeClaim, writeState } from "../src/runtime/base.ts";
|
|
33
33
|
import { type Session, presentRun } from "../src/runtime/checks.ts";
|
|
34
34
|
import { isSelfRepo } from "../src/runtime/setup.ts";
|
|
35
35
|
import { foldView, pluginUpstream } from "../src/runtime/reflect.ts";
|
|
@@ -51,14 +51,20 @@ function refreshStatus(ctx: ExtensionContext, root: string): void {
|
|
|
51
51
|
if (!ctx.hasUI) return;
|
|
52
52
|
const web = ctx.mode !== "tui";
|
|
53
53
|
const sk = sessionKey(ctx);
|
|
54
|
+
// Old keys are cleared on EVERY repaint, not once — a clear the browser missed while its event stream
|
|
55
|
+
// was down (pi-web never re-syncs widgets on reconnect) is re-sent until the history ages it out.
|
|
54
56
|
const setChip = (key: string | undefined, lines?: string[]) => {
|
|
55
|
-
|
|
56
|
-
if (prev
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
ctx.ui.setWidget(key, lines);
|
|
57
|
+
let prev = WEB_CHIP_KEYS.get(sk);
|
|
58
|
+
if (prev === undefined) {
|
|
59
|
+
const legacy = LEGACY_CHIP_KEYS?.get(sk);
|
|
60
|
+
LEGACY_CHIP_KEYS?.delete(sk);
|
|
61
|
+
prev = legacy === undefined ? [] : [legacy];
|
|
61
62
|
}
|
|
63
|
+
const next = nextChipKeys(prev, key);
|
|
64
|
+
for (const k of next.clear) ctx.ui.setWidget(k, undefined);
|
|
65
|
+
if (next.keys.length) WEB_CHIP_KEYS.set(sk, next.keys);
|
|
66
|
+
else WEB_CHIP_KEYS.delete(sk);
|
|
67
|
+
if (key !== undefined) ctx.ui.setWidget(key, lines);
|
|
62
68
|
};
|
|
63
69
|
if (!initiated(root)) {
|
|
64
70
|
ctx.ui.setStatus("dev-flow", undefined);
|
|
@@ -508,6 +514,7 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
508
514
|
// after one ends, and a stale claim there is a permanent lock (its pid is the server's, always alive).
|
|
509
515
|
pi.on("session_shutdown", async (_event, ctx) => {
|
|
510
516
|
WEB_CHIP_KEYS.delete(sessionKey(ctx)); // the session's UI is gone; a long-lived server must not keep its slot
|
|
517
|
+
hollowStreak.delete(sessionKey(ctx));
|
|
511
518
|
if (!guardsAreMine()) return;
|
|
512
519
|
const root = await flowRoot(ctx.cwd);
|
|
513
520
|
if (!existsSync(dfDir(root))) return;
|
|
@@ -519,7 +526,7 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
519
526
|
refreshStatus(ctx, root);
|
|
520
527
|
// pi checks its compaction threshold between every turn; our safe points must be as frequent.
|
|
521
528
|
maybeCompactNow(ctx, root);
|
|
522
|
-
return commandAskCorrection(event, ctx, root);
|
|
529
|
+
return commandAskCorrection(event, ctx, root) ?? hollowStopResume(event, ctx, root);
|
|
523
530
|
});
|
|
524
531
|
// Idle backstop: long between-gate runs compact here instead of letting pi hit the threshold mid-work.
|
|
525
532
|
pi.on("agent_settled", async (_event, ctx) => {
|
|
@@ -767,6 +774,36 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
767
774
|
return { entries: [...event.entries, { type: "custom_message", customType: "dev-flow-correction", content: operatorCommandCorrection(hits), display: false } as unknown as TurnEndEvent["entries"][number]] };
|
|
768
775
|
};
|
|
769
776
|
|
|
777
|
+
/** Hollow stops in a row per session: one resume, then stop resuming so a broken model cannot loop. */
|
|
778
|
+
const hollowStreak = new Map<string, number>();
|
|
779
|
+
|
|
780
|
+
/** The model ended its reply as a normal stop with no answer and no tool call (a provider that closed the
|
|
781
|
+
* stream inside the reasoning). pi would go idle and a bound flow would sit mid-stage with nothing for the
|
|
782
|
+
* operator to answer, so dev-flow appends a visible note and asks pi for one more request. Only when a flow
|
|
783
|
+
* is bound in this session and it is not a stage worker (workers have their own nudge loop). */
|
|
784
|
+
const hollowStopResume = (event: TurnEndEvent, ctx: ExtensionContext, root: string): TurnEndEventResult | undefined => {
|
|
785
|
+
const e = event as { outcome?: string; toolResults?: unknown[]; message?: unknown };
|
|
786
|
+
const key = sessionKey(ctx);
|
|
787
|
+
const hollow = e.outcome === "completed" && (e.toolResults?.length ?? 0) === 0 ? hollowStop(e.message) : null;
|
|
788
|
+
if (!hollow) {
|
|
789
|
+
hollowStreak.delete(key);
|
|
790
|
+
return undefined;
|
|
791
|
+
}
|
|
792
|
+
if (!initiated(root) || !boundFeature(root, key)) return undefined;
|
|
793
|
+
try {
|
|
794
|
+
if (workerSessions.has(ctx.sessionManager.getSessionId())) return undefined;
|
|
795
|
+
} catch {
|
|
796
|
+
/* not a worker */
|
|
797
|
+
}
|
|
798
|
+
const streak = (hollowStreak.get(key) ?? 0) + 1;
|
|
799
|
+
hollowStreak.set(key, streak);
|
|
800
|
+
const resume = streak === 1;
|
|
801
|
+
const content = resume ? hollowStopNote(hollow) : "[dev-flow] The model ended with no answer again after one resume, so dev-flow stopped resuming. Say continue to retry, or check the provider.";
|
|
802
|
+
// SAFETY: a custom_message draft is one of the documented boundary entry types; the draft union is not re-exported
|
|
803
|
+
const entry = { type: "custom_message", customType: "dev-flow-resume", content, display: true } as unknown as TurnEndEvent["entries"][number];
|
|
804
|
+
return resume ? { entries: [...event.entries, entry], continue: true } : { entries: [...event.entries, entry] };
|
|
805
|
+
};
|
|
806
|
+
|
|
770
807
|
/** The full note when it changed (or the core was just re-sent), else the one-line reminder. */
|
|
771
808
|
const sameAsLast = (key: string, full: string, short: string): string => {
|
|
772
809
|
if (lastContext.get(key) === full) return short;
|
|
@@ -776,6 +813,7 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
776
813
|
|
|
777
814
|
pi.on("before_agent_start", async (_event, ctx) => {
|
|
778
815
|
if (!guardsAreMine()) return undefined;
|
|
816
|
+
hollowStreak.delete(sessionKey(ctx)); // a new prompt earns a fresh resume
|
|
779
817
|
// One [dev-flow] line per run, whatever number of copies of this package are installed. The same
|
|
780
818
|
// package can reach one runtime twice (a project pin beside the npm install) and pi dedupes
|
|
781
819
|
// extensions by file path only; equal-version copies both pass the election, so the first pass
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dev-flow",
|
|
3
|
-
"version": "0.86.
|
|
3
|
+
"version": "0.86.2",
|
|
4
4
|
"description": "Enforced feature workflow for Pi: plan → implement → pre-release → release, gated checkpoints, self-improvement reflections, one git worktree per feature, changelog + publish as part of the release",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
package/src/core.ts
CHANGED
|
@@ -2362,6 +2362,26 @@ export function workerTurnError(messages: readonly unknown[]): { reason: string;
|
|
|
2362
2362
|
return { reason: last.stopReason, message: String(last.errorMessage ?? "").trim() || "(no error message)", streak };
|
|
2363
2363
|
}
|
|
2364
2364
|
|
|
2365
|
+
/** A reply that ended as a normal stop yet said nothing: no visible text and no tool call (typically a
|
|
2366
|
+
* provider that closed the stream inside the reasoning block). pi reads it as a finished turn and goes idle,
|
|
2367
|
+
* so a flow stops mid-stage with nothing for the operator to answer. Error and aborted ends are not hollow:
|
|
2368
|
+
* pi has its own handling for those. Returns whether the reply carried reasoning, for the note. */
|
|
2369
|
+
export function hollowStop(message: unknown): { thinking: boolean } | null {
|
|
2370
|
+
if (!message || typeof message !== "object") return null;
|
|
2371
|
+
const m = message as { role?: unknown; stopReason?: unknown; content?: unknown };
|
|
2372
|
+
if (m.role !== "assistant" || m.stopReason !== "stop") return null;
|
|
2373
|
+
const parts = Array.isArray(m.content) ? (m.content as { type?: unknown; text?: unknown; thinking?: unknown }[]) : [];
|
|
2374
|
+
if (parts.some((p) => p?.type === "toolCall" || (p?.type === "text" && typeof p.text === "string" && p.text.trim()))) return null;
|
|
2375
|
+
return { thinking: parts.some((p) => p?.type === "thinking" && typeof p.thinking === "string" && p.thinking.trim() !== "") };
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
/** The note that resumes a hollow stop. The operator sees it too; the model reads it as the next user turn. */
|
|
2379
|
+
export function hollowStopNote(h: { thinking: boolean }): string {
|
|
2380
|
+
return h.thinking
|
|
2381
|
+
? "[dev-flow] Your last reply ended inside your reasoning: no answer and no tool call reached the operator. Continue from where your reasoning stopped."
|
|
2382
|
+
: "[dev-flow] Your last reply was empty: no answer and no tool call reached the operator. Continue the task.";
|
|
2383
|
+
}
|
|
2384
|
+
|
|
2365
2385
|
/** The REPORT section of a worker's final message: everything after the last `REPORT` heading line. */
|
|
2366
2386
|
export function parseWorkerReport(text: string): { found: boolean; body: string; verdict: "PASS" | "FAIL" | null } {
|
|
2367
2387
|
const lines = (text ?? "").split("\n");
|
package/src/runtime/base.ts
CHANGED
|
@@ -546,9 +546,24 @@ export function tail(out: string, n = 15): string {
|
|
|
546
546
|
|
|
547
547
|
// ------------------------------------------------------------------ extension
|
|
548
548
|
|
|
549
|
-
/** The pi-web chip
|
|
550
|
-
* footer text and the
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
* the
|
|
554
|
-
|
|
549
|
+
/** The pi-web chip keys a session has painted, oldest first, the current one last: the chip's label IS the
|
|
550
|
+
* widget key, so it changes with the footer text and the old ones must be cleared. Every repaint re-sends
|
|
551
|
+
* the clear for each old key, not just once: pi-web delivers a clear to the browser only over a live
|
|
552
|
+
* event stream and does not re-sync widgets on reconnect, so a phone that was backgrounded across a stage
|
|
553
|
+
* change kept the old chip beside the new one (one per missed stage). Clearing a key the browser no
|
|
554
|
+
* longer has is a no-op, and the next repaint after reconnect retracts what was missed. Bounded to
|
|
555
|
+
* CHIP_KEY_HISTORY keys. Per session, not per process — one pi-web server repaints many sessions, and a
|
|
556
|
+
* shared slot let session B's repaint overwrite A's key. On globalThis so a /reload or a duplicate copy
|
|
557
|
+
* still knows what was painted (a new name: older copies kept a single string per session there). */
|
|
558
|
+
export const WEB_CHIP_KEYS: Map<string, string[]> = ((globalThis as { __piDevFlowChipKeyHistory?: Map<string, string[]> }).__piDevFlowChipKeyHistory ??= new Map());
|
|
559
|
+
export const CHIP_KEY_HISTORY = 8;
|
|
560
|
+
/** The previous copy's single-key slot, read once per session so the first repaint after an upgrade still
|
|
561
|
+
* retracts the chip that copy painted. */
|
|
562
|
+
export const LEGACY_CHIP_KEYS: Map<string, string> | undefined = (globalThis as { __piDevFlowChipKeys?: Map<string, string> }).__piDevFlowChipKeys;
|
|
563
|
+
|
|
564
|
+
/** Next chip-key history for a repaint: every key except the current one is to be cleared (again), and
|
|
565
|
+
* the current key moves to the end. `key` undefined (uninitiated folder) clears them all. Pure. */
|
|
566
|
+
export function nextChipKeys(prev: readonly string[], key: string | undefined): { clear: string[]; keys: string[] } {
|
|
567
|
+
const clear = prev.filter((k) => k !== key);
|
|
568
|
+
return { clear, keys: key === undefined ? clear.slice(-CHIP_KEY_HISTORY) : [...clear, key].slice(-CHIP_KEY_HISTORY) };
|
|
569
|
+
}
|