pi-dev-flow 0.86.0 → 0.86.1
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 +7 -0
- package/extensions/dev-flow.ts +34 -2
- package/package.json +1 -1
- package/src/core.ts +20 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.86.1] - 2026-11-08
|
|
8
|
+
|
|
9
|
+
**A reply that stops mid-thought resumes on its own instead of stalling the flow.**
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
- **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.
|
|
13
|
+
|
|
7
14
|
## [0.86.0] - 2026-11-08
|
|
8
15
|
|
|
9
16
|
**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,7 +24,7 @@ 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";
|
|
@@ -508,6 +508,7 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
508
508
|
// after one ends, and a stale claim there is a permanent lock (its pid is the server's, always alive).
|
|
509
509
|
pi.on("session_shutdown", async (_event, ctx) => {
|
|
510
510
|
WEB_CHIP_KEYS.delete(sessionKey(ctx)); // the session's UI is gone; a long-lived server must not keep its slot
|
|
511
|
+
hollowStreak.delete(sessionKey(ctx));
|
|
511
512
|
if (!guardsAreMine()) return;
|
|
512
513
|
const root = await flowRoot(ctx.cwd);
|
|
513
514
|
if (!existsSync(dfDir(root))) return;
|
|
@@ -519,7 +520,7 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
519
520
|
refreshStatus(ctx, root);
|
|
520
521
|
// pi checks its compaction threshold between every turn; our safe points must be as frequent.
|
|
521
522
|
maybeCompactNow(ctx, root);
|
|
522
|
-
return commandAskCorrection(event, ctx, root);
|
|
523
|
+
return commandAskCorrection(event, ctx, root) ?? hollowStopResume(event, ctx, root);
|
|
523
524
|
});
|
|
524
525
|
// Idle backstop: long between-gate runs compact here instead of letting pi hit the threshold mid-work.
|
|
525
526
|
pi.on("agent_settled", async (_event, ctx) => {
|
|
@@ -767,6 +768,36 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
767
768
|
return { entries: [...event.entries, { type: "custom_message", customType: "dev-flow-correction", content: operatorCommandCorrection(hits), display: false } as unknown as TurnEndEvent["entries"][number]] };
|
|
768
769
|
};
|
|
769
770
|
|
|
771
|
+
/** Hollow stops in a row per session: one resume, then stop resuming so a broken model cannot loop. */
|
|
772
|
+
const hollowStreak = new Map<string, number>();
|
|
773
|
+
|
|
774
|
+
/** The model ended its reply as a normal stop with no answer and no tool call (a provider that closed the
|
|
775
|
+
* stream inside the reasoning). pi would go idle and a bound flow would sit mid-stage with nothing for the
|
|
776
|
+
* operator to answer, so dev-flow appends a visible note and asks pi for one more request. Only when a flow
|
|
777
|
+
* is bound in this session and it is not a stage worker (workers have their own nudge loop). */
|
|
778
|
+
const hollowStopResume = (event: TurnEndEvent, ctx: ExtensionContext, root: string): TurnEndEventResult | undefined => {
|
|
779
|
+
const e = event as { outcome?: string; toolResults?: unknown[]; message?: unknown };
|
|
780
|
+
const key = sessionKey(ctx);
|
|
781
|
+
const hollow = e.outcome === "completed" && (e.toolResults?.length ?? 0) === 0 ? hollowStop(e.message) : null;
|
|
782
|
+
if (!hollow) {
|
|
783
|
+
hollowStreak.delete(key);
|
|
784
|
+
return undefined;
|
|
785
|
+
}
|
|
786
|
+
if (!initiated(root) || !boundFeature(root, key)) return undefined;
|
|
787
|
+
try {
|
|
788
|
+
if (workerSessions.has(ctx.sessionManager.getSessionId())) return undefined;
|
|
789
|
+
} catch {
|
|
790
|
+
/* not a worker */
|
|
791
|
+
}
|
|
792
|
+
const streak = (hollowStreak.get(key) ?? 0) + 1;
|
|
793
|
+
hollowStreak.set(key, streak);
|
|
794
|
+
const resume = streak === 1;
|
|
795
|
+
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.";
|
|
796
|
+
// SAFETY: a custom_message draft is one of the documented boundary entry types; the draft union is not re-exported
|
|
797
|
+
const entry = { type: "custom_message", customType: "dev-flow-resume", content, display: true } as unknown as TurnEndEvent["entries"][number];
|
|
798
|
+
return resume ? { entries: [...event.entries, entry], continue: true } : { entries: [...event.entries, entry] };
|
|
799
|
+
};
|
|
800
|
+
|
|
770
801
|
/** The full note when it changed (or the core was just re-sent), else the one-line reminder. */
|
|
771
802
|
const sameAsLast = (key: string, full: string, short: string): string => {
|
|
772
803
|
if (lastContext.get(key) === full) return short;
|
|
@@ -776,6 +807,7 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
776
807
|
|
|
777
808
|
pi.on("before_agent_start", async (_event, ctx) => {
|
|
778
809
|
if (!guardsAreMine()) return undefined;
|
|
810
|
+
hollowStreak.delete(sessionKey(ctx)); // a new prompt earns a fresh resume
|
|
779
811
|
// One [dev-flow] line per run, whatever number of copies of this package are installed. The same
|
|
780
812
|
// package can reach one runtime twice (a project pin beside the npm install) and pi dedupes
|
|
781
813
|
// 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.1",
|
|
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");
|