pi-goal-list-loop-audit 0.40.1 → 0.41.0
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 +27 -0
- package/README.md +3 -1
- package/docs/INDEX.md +1 -1
- package/docs/RECOVERY.md +16 -0
- package/docs/RUNTIME-INVENTORY.md +9 -9
- package/docs/SETTINGS.md +3 -1
- package/extensions/completion-summary.ts +59 -15
- package/extensions/decision-auto-select.ts +252 -0
- package/extensions/goal-commands.ts +162 -41
- package/extensions/goal-continuation.ts +31 -1
- package/extensions/goal-heartbeat.ts +105 -1
- package/extensions/goal-loop-core.ts +6 -0
- package/extensions/goal-loop-display.ts +14 -0
- package/extensions/goal-settings.ts +29 -0
- package/extensions/human-handoff.ts +6 -4
- package/extensions/loops/goal-activation.ts +24 -2
- package/extensions/loops/goal-orchestrator.ts +7 -0
- package/extensions/loops/goal-settings-ui.ts +24 -0
- package/extensions/loops/goal-tools.ts +1 -1
- package/extensions/loops/goal-ui.ts +4 -0
- package/extensions/loops/goal.ts +6 -2
- package/extensions/settings-menu.ts +9 -0
- package/extensions/summary-renderer.ts +9 -1
- package/package.json +1 -1
- package/prompts/goal-loop-continuation.md +1 -1
- package/schemas/goal.schema.json +1 -0
- package/scripts/summary-readability-capture.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.41.0 — a completion card that restates the goal, and decision pauses that can answer themselves (2026-11-18)
|
|
6
|
+
|
|
7
|
+
### The completion card reminds you what was asked, and rework turns stop resending the whole brief (2026-11-18)
|
|
8
|
+
|
|
9
|
+
Measured against the local record (the active ledger plus all retained segments: 2,091 continuation sends, 2,231 active-ledger events).
|
|
10
|
+
|
|
11
|
+
- **The card restates the goal.** A long autonomous goal ends hours after it was set, and the card never said what had been asked. The chat card now carries `Goal: <first sentence of the objective>` directly above the meta line, in one block (Markdown hard break). The archive is unchanged: it already opens with the full `## Objective`.
|
|
12
|
+
- **One meta line.** When no file list follows, the diff stat joins the meta line (`3h 00m elapsed · 1 audit · 14 files changed, +620 −88`) instead of sitting in its own block.
|
|
13
|
+
- **Sentence case.** Agent text written in lower case (`all six complaints are addressed`, `an in-dialog toggle is not possible`) read as fragments. The headline, finding leads, follow-ups and next steps now start with a capital. Only a plain lower-case leading word is touched; paths, commands and identifiers (`note.md`, `npm run …`, `handleClick`, `iOS`) keep their spelling.
|
|
14
|
+
- **No `· ·`.** A `path:line` pointer moved out of `… existed · path:line` left a bare separator that the join then doubled.
|
|
15
|
+
- **The second "Summary" heading reads as "What changed".** The prose lede above it already is the summary. This is display-only: durable content keeps `Summary`, so the collapsed projection and replayed receipts are unchanged.
|
|
16
|
+
- **A non-complete render never wears `Done`.** `buildTerminalApprovalRender` passed no headline kind, so a stopped goal rendered through it read `## Done — Work stopped`. Every production caller passes `complete` today; the headline now follows the status anyway.
|
|
17
|
+
- **Rework turns ride the marker.** `pendingTasks` (the auditor TODO list) forced a full ~28 KB continuation on *every* turn while rework was open: 160 of the 258 most recent full sends carried a TODO list the model had already been given. Delivery is now fingerprinted per goal, as the audit report already was. A new or edited list still goes full, and an unchanged one sends the 46-char marker. `session_compact` forgets both delivered fingerprints, because a compaction may summarize the brief away. The next send re-teaches it: one full brief per compaction instead of one per turn.
|
|
18
|
+
- **`context_hygiene_dropped` is de-duplicated.** The `context` hook runs once per provider request. While a host retried against a dead provider (402 plan exhausted, 429 token plan), GLLA ledgered the identical projection every 10–30 s: 1,114 of 2,231 active-ledger events. Identical repeats are now silent and counted (`suppressedRepeats` on the next change), matching `payload_guard_eviction`. The projection itself still runs on every request.
|
|
19
|
+
- `tests/context-checkpoint.test.ts` re-pinned: the expanded `HUMAN_HANDOFF_GUIDANCE` (already in Unreleased) adds 382 serialized bytes to the retained payload.
|
|
20
|
+
- Coverage: `tests/summary-human-reminder.test.ts`, `tests/delta-only-continuation.test.ts`, `tests/context-hygiene.test.ts`. Summary pins were migrated to the sentence-cased wording.
|
|
21
|
+
|
|
22
|
+
### A decision pause can answer itself after a delay, so an odd question never parks the work forever (2026-11-18)
|
|
23
|
+
|
|
24
|
+
- **New setting `decisionAutoSelectMinutes` (off by default).** Turn it on in `/glla` → **Keep-going** → *Stuck-decision auto-select* (2 / 10 / 30 minutes). After that long with nobody answering, the RECOMMENDED decision option is adopted and the work continues. When it is unset, a decision pause waits for you forever — exactly as before.
|
|
25
|
+
- **Only a continue-work answer may be adopted.** `/goal resume`, `/list resume`, `/list next`, `/loop resume`, and a prose/content option the picker would steer to the agent are eligible. Cancel, accept-with-follow-ups, tweak, pause, stop/clear, wipe, any `/glla` action, and verification-contract amendments are NOT: those end or rewrite the work, so they keep waiting. An ineligible recommendation still reports once (`decision_auto_select_refused`) that your deadline passed and why it declined.
|
|
26
|
+
- **Both surfaces share one clock.** The `/goal decide` picker carries pi's own dialog countdown and adopts at expiry; a heartbeat backstop adopts the same pause when no dialog ever opened (headless rig, Decision popup off, an Escape, a restart mid-question). An Escape *before* the deadline leaves the pause alone — the adoption happens only when the durable clock says the delay elapsed.
|
|
27
|
+
- **The clock measures the pause EPISODE.** A new `pauseDecidedAt` stamp is written when a pause lands; later goal writes (counter bumps, history appends) do not restart the fuse, so an active goal cannot push its own question out of reach.
|
|
28
|
+
- **The adoption is an assumption, not a silent choice.** It is ledgered (`decision_auto_select_adopted` with the waited time and the option) and recorded on the goal's `autoDefaultLog`, which is what the agent carries into the completion recap. The widget card also states it plainly: `auto-answers with option N in Xm unless you decide first`.
|
|
29
|
+
- **Your own holds still win.** `/glla pause` and the automatic load hold freeze the clock exactly as they freeze every other automatic dispatch, and a stale/handed-off host never consumes a pause it cannot resume.
|
|
30
|
+
- Coverage: `tests/decision-auto-select.test.ts`.
|
|
31
|
+
|
|
5
32
|
## 0.40.1 — status cards and an honest "waiting for the conversation" state (2026-11-13)
|
|
6
33
|
|
|
7
34
|
### Status cards: one place for the version, and an honest "waiting for the conversation" state (2026-11-13)
|
package/README.md
CHANGED
|
@@ -272,6 +272,8 @@ with:
|
|
|
272
272
|
- **Auditor model and thinking level:** choose a verifier that can handle the contract.
|
|
273
273
|
- **Fallback models:** choose providers you can actually authenticate and afford.
|
|
274
274
|
- **Auto-resume:** decide whether loaded work may restart automatically.
|
|
275
|
+
- **Stuck-decision auto-select:** decide how long a decision may sit before its
|
|
276
|
+
recommended continue-work answer is adopted for you (off by default).
|
|
275
277
|
- **State root:** choose where durable work belongs.
|
|
276
278
|
- **Retry and audit limits:** keep failure recovery bounded.
|
|
277
279
|
- **Notifications:** decide how you want to hear about decisions and results.
|
|
@@ -285,7 +287,7 @@ different default. Sections:
|
|
|
285
287
|
|
|
286
288
|
| Section | Example rows |
|
|
287
289
|
|---|---|
|
|
288
|
-
| Keep-going | auto-resume, decision popup, carryover policy, decision-pause budget, auto-accept drafts, aggressive mode, vision assist |
|
|
290
|
+
| Keep-going | auto-resume, decision popup, stuck-decision auto-select, carryover policy, decision-pause budget, auto-accept drafts, aggressive mode, vision assist |
|
|
289
291
|
| Main agent | main-agent model, fallback models, fallback thinking levels, retry minutes, same-model retry budget, primary-probe minutes |
|
|
290
292
|
| Drafter | drafting model used to interview an objective before it activates |
|
|
291
293
|
| Compactor | compaction token target, compactor agent and its fallback models |
|
package/docs/INDEX.md
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
## Versions and shipped content
|
|
35
35
|
|
|
36
36
|
[CHANGELOG.md](../CHANGELOG.md) records the full release history from
|
|
37
|
-
v0.1.0-alpha.1 (2026-07-19) through v0.
|
|
37
|
+
v0.1.0-alpha.1 (2026-07-19) through v0.41.0 (2026-11-18), including an audit
|
|
38
38
|
lane that waits for the provider's quoted reset (even a weekly one) instead of
|
|
39
39
|
re-arming a five-minute timer, uses a configured fallback model instead of
|
|
40
40
|
re-walking the failed one, and stops to ask after six hours without a verdict
|
package/docs/RECOVERY.md
CHANGED
|
@@ -79,6 +79,22 @@ use a genuine pause for decisions, user holds or manual-action blockers. Unknown
|
|
|
79
79
|
worker ids are rejected. Legacy saved standby records have no provable ownership:
|
|
80
80
|
GLLA requests an assessment once eligible, rather than promising automatic wake.
|
|
81
81
|
|
|
82
|
+
**A decision pause can carry a clock of its own.** With
|
|
83
|
+
`decisionAutoSelectMinutes` set (`/glla` → **Keep-going** → *Stuck-decision
|
|
84
|
+
auto-select*), a decision that sits unanswered that long adopts its RECOMMENDED
|
|
85
|
+
**continue-work** answer and the work continues. Only `/goal resume`,
|
|
86
|
+
`/list resume`, `/list next`, `/loop resume`, and the content choice the picker
|
|
87
|
+
would steer to the agent are eligible — cancel, accept-with-follow-ups, tweak,
|
|
88
|
+
pause, stop/clear, wipe, any `/glla` action and verification-contract
|
|
89
|
+
amendments keep waiting for you, and name once why they did
|
|
90
|
+
(`decision_auto_select_refused`). The adoption is ledgered
|
|
91
|
+
(`decision_auto_select_adopted`), stamped into the goal's `autoDefaultLog`, and
|
|
92
|
+
shown on the card as `auto-answers with option N in Xm unless you decide
|
|
93
|
+
first`, so it reaches the completion recap as an assumption rather than a
|
|
94
|
+
silent choice. Unset (the default) keeps every decision paused indefinitely;
|
|
95
|
+
`/glla pause` and the load hold freeze the clock like every other automatic
|
|
96
|
+
dispatch.
|
|
97
|
+
|
|
82
98
|
Use `/goal status`, `/list show`, or `/loop status` to inspect the checkpoint.
|
|
83
99
|
On reload, GLLA reads only the saved identity-matching public status artifacts;
|
|
84
100
|
completed, failed, stopped or missing results are assessed without discarding
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Generated by `node scripts/generate-inventory.mjs`. Run with `--check` to detect drift. Counts describe files and literal registrations, not executed coverage.
|
|
4
4
|
|
|
5
|
-
- Extension/script files:
|
|
6
|
-
- Extension/script lines:
|
|
7
|
-
- Top-level test files:
|
|
5
|
+
- Extension/script files: 155
|
|
6
|
+
- Extension/script lines: 81237
|
|
7
|
+
- Top-level test files: 501
|
|
8
8
|
- Ambient bridge names: 176 (audit baseline: 176)
|
|
9
9
|
- Commands: `/glla`, `/goal`, `/list`, `/loop`, `/review`
|
|
10
10
|
- Tools: `audit_project_increment`, `block_project_requirement`, `claim_project_task`, `complete_goal`, `complete_task`, `list_activate`, `list_add`, `list_status`, `pause_goal`, `plan_project_increment`, `propose_goal_draft`, `propose_loop_draft`, `propose_loop_refine`, `propose_project_refinement`, `propose_project_requirements`, `propose_task_list`, `propose_tweak`, `record_goal_judgment`, `resume_goal`, `unblock_project_requirement`, `update_task_batch`, `update_task_status`, `wait_for_background`
|
|
@@ -13,15 +13,15 @@ Generated by `node scripts/generate-inventory.mjs`. Run with `--check` to detect
|
|
|
13
13
|
|
|
14
14
|
| Module | Lines |
|
|
15
15
|
|---|---:|
|
|
16
|
-
| [extensions/goal-loop-core.ts](../extensions/goal-loop-core.ts) |
|
|
16
|
+
| [extensions/goal-loop-core.ts](../extensions/goal-loop-core.ts) | 6045 |
|
|
17
17
|
| [extensions/loops/goal-tools.ts](../extensions/loops/goal-tools.ts) | 4871 |
|
|
18
|
-
| [extensions/loops/goal-activation.ts](../extensions/loops/goal-activation.ts) |
|
|
19
|
-
| [extensions/goal-commands.ts](../extensions/goal-commands.ts) |
|
|
20
|
-
| [extensions/goal-loop-display.ts](../extensions/goal-loop-display.ts) |
|
|
18
|
+
| [extensions/loops/goal-activation.ts](../extensions/loops/goal-activation.ts) | 4270 |
|
|
19
|
+
| [extensions/goal-commands.ts](../extensions/goal-commands.ts) | 4096 |
|
|
20
|
+
| [extensions/goal-loop-display.ts](../extensions/goal-loop-display.ts) | 3770 |
|
|
21
21
|
| [extensions/goal-loop-auditor-process.ts](../extensions/goal-loop-auditor-process.ts) | 3232 |
|
|
22
22
|
| [extensions/loops/goal-auditor-hooks.ts](../extensions/loops/goal-auditor-hooks.ts) | 3136 |
|
|
23
|
-
| [extensions/loops/goal-settings-ui.ts](../extensions/loops/goal-settings-ui.ts) |
|
|
23
|
+
| [extensions/loops/goal-settings-ui.ts](../extensions/loops/goal-settings-ui.ts) | 2353 |
|
|
24
24
|
| [extensions/goal-recovery.ts](../extensions/goal-recovery.ts) | 2327 |
|
|
25
|
-
| [extensions/goal-continuation.ts](../extensions/goal-continuation.ts) |
|
|
25
|
+
| [extensions/goal-continuation.ts](../extensions/goal-continuation.ts) | 2237 |
|
|
26
26
|
|
|
27
27
|
Settings are defined in [SETTINGS.md](SETTINGS.md); supported host versions and process limits are defined in [COMPATIBILITY.md](COMPATIBILITY.md).
|
package/docs/SETTINGS.md
CHANGED
|
@@ -69,7 +69,8 @@ copies are ignored (GLLA reads the global file for these policies):
|
|
|
69
69
|
`compactionTokenThreshold`,
|
|
70
70
|
`auditorModel`, `auditorModelFallbacks`, `auditorToolTimeoutMs`, `auditorStallMs`,
|
|
71
71
|
`auditJobRetentionMs`, `auditSpotCheckRate`, `auditorStrictChallenge`, `auditorInspection`,
|
|
72
|
-
`autoAcceptDrafts`, `versionDisplay`, `auditorThinkingLevel
|
|
72
|
+
`autoAcceptDrafts`, `versionDisplay`, `auditorThinkingLevel`,
|
|
73
|
+
`decisionAutoSelectMinutes`.
|
|
73
74
|
|
|
74
75
|
This list is `GLOBAL_ONLY_KEYS` in `extensions/goal-settings.ts`, and a
|
|
75
76
|
project-scope write to any of them is stripped on read. Every other key —
|
|
@@ -146,6 +147,7 @@ This authority boundary applies before settings-value normalization.
|
|
|
146
147
|
| `wedgeAlertMinutes` | unset (30, or off while aggressive mode is on — the default) | Busy-but-silent minutes before the wedge alert; `0` = off. The menu shows the effective value. |
|
|
147
148
|
| `autoResume` | `false` | Restored goals/loops/lists auto-resume in fresh sessions. Global-only. |
|
|
148
149
|
| `decisionPopup` | `true` | Decision pauses pop the picker (`false` = widget card only). |
|
|
150
|
+
| `decisionAutoSelectMinutes` | unset (off) | The stuck-question clock: minutes a decision pause may sit before its RECOMMENDED **continue-work** answer is adopted automatically (`/goal resume`, `/list resume`, `/list next`, `/loop resume`, or the content the picker would steer to the agent). Cancel, accept-with-follow-ups, tweak, pause, stop/clear, wipe and verification-contract amendments are never adopted — they end or rewrite the work, so they keep waiting for you. The adoption is ledgered (`decision_auto_select_adopted`) and recorded on the goal's `autoDefaultLog` so the agent carries it into the recap as an assumption. Both the `/goal decide` picker countdown and a heartbeat backstop honour it, so a popup that never opened still unsticks. Global-only. |
|
|
149
151
|
| `decisionPauseBudget` | unset (unlimited) | Budget for unattended decline of promoted suggestions: after N admitted decisions, proceed without executing the suggestion and record the declined command in `autoDefaultLog` and `decision_budget_auto_default` (or `run_to_done_auto_default` for run-to-done). `0` permits that safe decline immediately. It never supplies consent or waives criteria: classified material exceptions remain paused; unclassified human decisions require local classification; known authorized mechanical/reversible work continues without a decision. Run-to-done follows the same consent boundary. |
|
|
150
152
|
| `carryover` | `"pause"` | Stale carryover on new activation: `"pause"` / `"clear"` / `"resume"`. |
|
|
151
153
|
| `autoAcceptDrafts` | `false` | Drafts activate without the Confirm dialog (unattended rigs). |
|
|
@@ -424,6 +424,33 @@ export interface RichTerminalParts {
|
|
|
424
424
|
changeLine?: string;
|
|
425
425
|
/** v0.39.71 (F): largest changed files (`path +A −R`) under the change line. */
|
|
426
426
|
changeFiles?: string[];
|
|
427
|
+
/** Chat only: a one-line reminder of what was asked (`Goal: …`). A long
|
|
428
|
+
* autonomous goal ends hours after it was set, so the card restates the ask
|
|
429
|
+
* next to the result. The archive already carries the full `## Objective`. */
|
|
430
|
+
goalLine?: string;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** Sentence-case a human line the agent wrote in lower case (`all six
|
|
434
|
+
* complaints …` → `All six complaints …`). Only a plain lower-case leading
|
|
435
|
+
* WORD is touched — a path, command, identifier or token with digits/dots
|
|
436
|
+
* (`note.md`, `npm run …`, `iOS`) keeps its exact spelling. */
|
|
437
|
+
const CODE_LEAD_WORDS = new Set(["npm", "npx", "bun", "bunx", "git", "node", "tsc", "pnpm", "yarn", "pi", "gh", "cd", "ls", "rm"]);
|
|
438
|
+
export function sentenceCase(text: string): string {
|
|
439
|
+
const match = /^([a-z][a-z'\u2019-]*)(?=\s)/u.exec(text);
|
|
440
|
+
if (!match || CODE_LEAD_WORDS.has(match[1]!)) return text;
|
|
441
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/** The objective as a one-line reminder: its first line, first sentence when
|
|
445
|
+
* that sentence is a usable title, clipped to one terminal row. Markdown
|
|
446
|
+
* emphasis characters are dropped so the excerpt cannot break the italics it
|
|
447
|
+
* rides in. */
|
|
448
|
+
export function objectiveReminder(objective: string | undefined, limit = 110): string | undefined {
|
|
449
|
+
const first = sanitizeDisplayText(objective ?? "").split(/\n/).map((l) => l.trim()).find(Boolean)
|
|
450
|
+
?.replace(/^>\s*/, "").replace(/[*_`]/g, "").trim();
|
|
451
|
+
if (!first) return undefined;
|
|
452
|
+
const sentence = /^(.{24,}?[.!?])(?=\s|$)/u.exec(first)?.[1] ?? first;
|
|
453
|
+
return clipSummaryValue(sentence.replace(/[.]$/, ""), limit);
|
|
427
454
|
}
|
|
428
455
|
|
|
429
456
|
/** v0.39.70: a gate row, optionally backed by a GLLA-run receipt. */
|
|
@@ -563,7 +590,11 @@ function findingPresentation(finding: string, chat: boolean): { outcome: string;
|
|
|
563
590
|
// card): token extraction can strand leading punctuation when the
|
|
564
591
|
// evidence tokens ride mid-sentence, so strip a leading `,;:` husk.
|
|
565
592
|
// Content words are untouched — only the join seam is cleaned.
|
|
566
|
-
|
|
593
|
+
// A token moved out of `… existed · path:line` left the reason ending in a
|
|
594
|
+
// bare `·`, which the join below then doubled (`existed · · path`). Trim
|
|
595
|
+
// separator husks from every part before joining.
|
|
596
|
+
const seam = (part: string): string => part.replace(/^[\s\u00b7,;:]+|[\s\u00b7,;:]+$/gu, "");
|
|
597
|
+
const normalizedReason = [...new Set(reasonParts.map(seam).filter(Boolean))].join(" · ").trim().replace(/^[,;:]+/, "").trim();
|
|
567
598
|
// v0.39.23 (field 2026-10-10 — Clean-Web card `- , - with …`): the same
|
|
568
599
|
// stranded-punctuation husk can lead the outcome when the agent doubles
|
|
569
600
|
// punctuation around the em-dash split. Strip it like the reason husk.
|
|
@@ -571,7 +602,7 @@ function findingPresentation(finding: string, chat: boolean): { outcome: string;
|
|
|
571
602
|
return {
|
|
572
603
|
// Chat removes machine receipts; the archive keeps the full evidence
|
|
573
604
|
// prose. The outcome/reason split itself is shared by both surfaces.
|
|
574
|
-
outcome: stripHusk(chat ? chatNarrative(parsed.outcome) : sanitizeDisplayText(parsed.outcome)),
|
|
605
|
+
outcome: sentenceCase(stripHusk(chat ? chatNarrative(parsed.outcome) : sanitizeDisplayText(parsed.outcome))),
|
|
575
606
|
reason: chat ? chatNarrative(normalizedReason) : sanitizeDisplayText(normalizedReason),
|
|
576
607
|
evidence: parsed.evidence,
|
|
577
608
|
};
|
|
@@ -903,7 +934,7 @@ export function splitReportTitle(text: string, limit = RICH_HEADLINE_CHARS): { t
|
|
|
903
934
|
}
|
|
904
935
|
|
|
905
936
|
export function requestEchoHeadline(kind: "Done" | "Aborted", outcome: string): string {
|
|
906
|
-
return `## ${kind} \u2014 ${splitReportTitle(outcome).title}`;
|
|
937
|
+
return `## ${kind} \u2014 ${sentenceCase(splitReportTitle(outcome).title)}`;
|
|
907
938
|
}
|
|
908
939
|
|
|
909
940
|
/** The prose lede under the headline. Empty when the headline already carries
|
|
@@ -1335,14 +1366,14 @@ export function buildRichTerminalParts(args: {
|
|
|
1335
1366
|
const [head, ...rest] = expandInlineList(body);
|
|
1336
1367
|
// The section itself names the action, so the per-line `**Next** —` prefix
|
|
1337
1368
|
// is dropped on BOTH surfaces (field 2026-11-11).
|
|
1338
|
-
if (head) nextLines.push(`- ${head}`);
|
|
1369
|
+
if (head) nextLines.push(`- ${sentenceCase(head)}`);
|
|
1339
1370
|
nextLines.push(...rest);
|
|
1340
1371
|
}
|
|
1341
1372
|
const remainingLines: string[] = [];
|
|
1342
1373
|
for (const detail of next.filter((d) => /^\s*(?:Left out|Unresolved)\s*:/i.test(d))) {
|
|
1343
1374
|
const { lead, body } = leadBody(args.chat ? chatNarrative(detail) : detail);
|
|
1344
1375
|
const [head, ...rest] = expandInlineList(body);
|
|
1345
|
-
remainingLines.push(`- **${lead}** — ${head ?? ""}`.trimEnd());
|
|
1376
|
+
remainingLines.push(`- **${lead}** — ${sentenceCase(head ?? "")}`.trimEnd());
|
|
1346
1377
|
remainingLines.push(...rest);
|
|
1347
1378
|
if (/^\s*Unresolved\s*:/i.test(detail)) {
|
|
1348
1379
|
// Paired actions relocate verbatim (the ### Next rendering, moved
|
|
@@ -1371,6 +1402,7 @@ export function buildRichTerminalParts(args: {
|
|
|
1371
1402
|
summaryLines: (args.summaryLines ?? []).map((line) => sanitizeDisplayText(line)),
|
|
1372
1403
|
ledeLines: reportLede(outcome),
|
|
1373
1404
|
...(args.changeLine ? { changeLine: sanitizeDisplayText(args.changeLine) } : {}),
|
|
1405
|
+
...(args.chat && objectiveReminder(args.objective) ? { goalLine: `Goal: ${objectiveReminder(args.objective)}` } : {}),
|
|
1374
1406
|
// v0.39.71 (F): only 5 of 40 recent claims grouped their changes by area,
|
|
1375
1407
|
// so most cards said WHAT changed only in prose. Without groups, name the
|
|
1376
1408
|
// largest files (Codex/OpenCode shape); with groups, the areas do it.
|
|
@@ -1413,8 +1445,21 @@ export function composeRichTerminalLines(parts: RichTerminalParts): string[] {
|
|
|
1413
1445
|
// The prose lede: the whole outcome sentence under the shortened headline
|
|
1414
1446
|
// (field 2026-11-11). Absent when the headline already carries it.
|
|
1415
1447
|
if ((parts.ledeLines ?? []).length > 0) lines.push(...(parts.ledeLines ?? []).map((line) => sanitizeDisplayText(line)), "");
|
|
1416
|
-
|
|
1417
|
-
|
|
1448
|
+
// Context block (chat): what was asked, then how long it took and how much
|
|
1449
|
+
// changed on ONE line. The diff stat folds into the meta line unless a file
|
|
1450
|
+
// list follows it, in which case it heads that list.
|
|
1451
|
+
const foldChange = Boolean(parts.changeLine && !(parts.changeFiles ?? []).length && parts.durationLine && parts.chat);
|
|
1452
|
+
const meta = parts.durationLine
|
|
1453
|
+
? (foldChange ? parts.durationLine.replace(/\*$/, ` \u00b7 ${sanitizeDisplayText(parts.changeLine!).replace(/[*]/g, "")}*`) : parts.durationLine)
|
|
1454
|
+
: null;
|
|
1455
|
+
// A Markdown hard break (two trailing spaces) keeps the ask and the meta in
|
|
1456
|
+
// one block: two rows, no gap, no paragraph merge.
|
|
1457
|
+
if (parts.goalLine) {
|
|
1458
|
+
const goalRow = `*${sanitizeDisplayText(parts.goalLine).replace(/[*]/g, "")}*`;
|
|
1459
|
+
lines.push(...(meta ? [`${goalRow} `] : [goalRow, ""]));
|
|
1460
|
+
}
|
|
1461
|
+
if (meta) lines.push(sanitizeDisplayText(meta), "");
|
|
1462
|
+
if (parts.changeLine && !foldChange) {
|
|
1418
1463
|
lines.push(sanitizeDisplayText(parts.changeLine));
|
|
1419
1464
|
for (const row of parts.changeFiles ?? []) lines.push(`- \`${sanitizeDisplayText(row).replace(/`/g, "")}\``);
|
|
1420
1465
|
lines.push("");
|
|
@@ -1483,7 +1528,7 @@ export function buildRichArchiveSection(goal: Goal, status: Status, archivePath:
|
|
|
1483
1528
|
// final card must use the corrected terminal recap, not a rejected one.
|
|
1484
1529
|
// archiveCurrentGoal captures history before pendingCompletion clears.
|
|
1485
1530
|
const priorWholeWork = priorWholeWorkOverride ?? goal.pendingCompletion?.priorCompletionSummary;
|
|
1486
|
-
const brief = humanCompletionBrief(summary,
|
|
1531
|
+
const brief = humanCompletionBrief(summary, RICH_FULL_VALUE_BUDGET, RICH_FULL_VALUE_BUDGET, priorWholeWork, true);
|
|
1487
1532
|
// v0.39.71 (E): for a STOPPED goal, a recorded-facts recap's Evidence line
|
|
1488
1533
|
// is machine telemetry (goal id, counters) — it stays in the verbatim
|
|
1489
1534
|
// machine record, not in the human report. An approved goal's archive keeps
|
|
@@ -1699,12 +1744,10 @@ export function buildTerminalApprovalRender(input: TerminalApprovalRenderInput):
|
|
|
1699
1744
|
archivePath: input.archivePath,
|
|
1700
1745
|
};
|
|
1701
1746
|
const candidate = input.completionSummary ?? input.goal.completionSummary;
|
|
1702
|
-
//
|
|
1703
|
-
//
|
|
1704
|
-
// the
|
|
1705
|
-
//
|
|
1706
|
-
// v0.38.55 (full parity): values ride unclipped — the card shares
|
|
1707
|
-
// everything the archive knows.
|
|
1747
|
+
// Preserve the outcome before splitting its title from the explanation.
|
|
1748
|
+
// A notification-sized budget here silently discarded the second sentence
|
|
1749
|
+
// even though the rich report has room to wrap it. Compact callers retain
|
|
1750
|
+
// their own budgets; rich chat and archive share the bounded full value.
|
|
1708
1751
|
const resolution = resolveCompletionSummary(facts, candidate);
|
|
1709
1752
|
// A persisted fallback already satisfies the six-label validator. Detect
|
|
1710
1753
|
// the system's reserved template as well as newly resolved fallbacks;
|
|
@@ -1721,7 +1764,7 @@ export function buildTerminalApprovalRender(input: TerminalApprovalRenderInput):
|
|
|
1721
1764
|
// by partitionRichDetails, never shown as a human change finding.
|
|
1722
1765
|
const richBrief = humanCompletionBrief(
|
|
1723
1766
|
humanSource,
|
|
1724
|
-
|
|
1767
|
+
RICH_FULL_VALUE_BUDGET,
|
|
1725
1768
|
RICH_FULL_VALUE_BUDGET,
|
|
1726
1769
|
input.priorCompletionSummary,
|
|
1727
1770
|
true,
|
|
@@ -1781,6 +1824,7 @@ export function buildTerminalApprovalRender(input: TerminalApprovalRenderInput):
|
|
|
1781
1824
|
// for a claim that supplied no gate inventory.
|
|
1782
1825
|
const richParts = buildRichTerminalParts({
|
|
1783
1826
|
chat: true,
|
|
1827
|
+
kind: input.status === "complete" ? "Done" : "Aborted",
|
|
1784
1828
|
showVerification: input.showVerification,
|
|
1785
1829
|
outcome: richBrief.outcome,
|
|
1786
1830
|
details: withoutStaleNext(richDetails),
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* decision-auto-select.ts — the "don't get stuck on an odd question" clock.
|
|
3
|
+
*
|
|
4
|
+
* A decision pause waits for a human. When nobody is there (a long goal, an
|
|
5
|
+
* unattended window, a picker the user walked away from), that wait has no
|
|
6
|
+
* clock and the objective parks indefinitely — field complaint: "we get stuck
|
|
7
|
+
* in case we are thrown an odd question".
|
|
8
|
+
*
|
|
9
|
+
* The operator opts in with `decisionAutoSelectMinutes` (off by default; the
|
|
10
|
+
* menu shows 10 minutes as the suggested fuse). When armed, the RECOMMENDED
|
|
11
|
+
* option may be adopted after that delay — but only a continue-work answer:
|
|
12
|
+
*
|
|
13
|
+
* - a continue-work glla command (`/goal resume`, `/list resume`,
|
|
14
|
+
* `/list next`, `/loop resume`) is executed, or
|
|
15
|
+
* - a prose/content choice is delivered to the agent as the picker itself
|
|
16
|
+
* does, then the work resumes.
|
|
17
|
+
*
|
|
18
|
+
* Cancel, accept-as-complete, tweak, pause, clear, stop, wipe, `/glla`
|
|
19
|
+
* actions and verification-contract amendments are NEVER adopted: each one
|
|
20
|
+
* ends the work, rewrites its scope, or answers content the operator was the
|
|
21
|
+
* one asked about. An absent agent may not substitute consent for those.
|
|
22
|
+
*
|
|
23
|
+
* Two surfaces share this module so they cannot drift:
|
|
24
|
+
* - the `/goal decide` picker renders the remaining time and adopts at
|
|
25
|
+
* expiry (goal-commands.ts);
|
|
26
|
+
* - the heartbeat's durable backstop adopts a lingering decision pause even
|
|
27
|
+
* when no dialog ever opened (headless, popup disabled, Escape, restart).
|
|
28
|
+
*
|
|
29
|
+
* Pure module: types only, no settings/state/UI imports — callers supply the
|
|
30
|
+
* configured delay and the observation time.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import type { Goal } from "./goal-loop-core.js";
|
|
34
|
+
|
|
35
|
+
/** Suggested fuse the menu offers when the operator turns auto-select on. */
|
|
36
|
+
export const DECISION_AUTO_SELECT_DEFAULT_MINUTES = 10;
|
|
37
|
+
/** Upper bound keeps a saved value sane; a longer fuse is just "off". */
|
|
38
|
+
export const DECISION_AUTO_SELECT_MAX_MINUTES = 24 * 60;
|
|
39
|
+
/** A picker countdown shorter than this is pointless — below it, adopt now. */
|
|
40
|
+
export const DECISION_AUTO_SELECT_MIN_COUNTDOWN_MS = 5_000;
|
|
41
|
+
|
|
42
|
+
/** Actions an absent operator MAY adopt: they keep the objective moving. */
|
|
43
|
+
const CONTINUE_WORK_ACTIONS: ReadonlyArray<{ group: string; verb: string }> = [
|
|
44
|
+
{ group: "goal", verb: "resume" },
|
|
45
|
+
{ group: "list", verb: "resume" },
|
|
46
|
+
{ group: "list", verb: "next" },
|
|
47
|
+
{ group: "loop", verb: "resume" },
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
/** Actions that end, rewrite, or park the work — a person's call, always. */
|
|
51
|
+
const RESERVED_ACTIONS: ReadonlyArray<{ group: string; verb: string }> = [
|
|
52
|
+
{ group: "goal", verb: "cancel" },
|
|
53
|
+
{ group: "goal", verb: "accept" },
|
|
54
|
+
{ group: "goal", verb: "tweak" },
|
|
55
|
+
{ group: "goal", verb: "pause" },
|
|
56
|
+
{ group: "list", verb: "cancel" },
|
|
57
|
+
{ group: "list", verb: "pause" },
|
|
58
|
+
{ group: "list", verb: "clear" },
|
|
59
|
+
{ group: "list", verb: "remove" },
|
|
60
|
+
{ group: "list", verb: "rm" },
|
|
61
|
+
{ group: "loop", verb: "stop" },
|
|
62
|
+
{ group: "loop", verb: "cancel" },
|
|
63
|
+
{ group: "loop", verb: "pause" },
|
|
64
|
+
{ group: "loop", verb: "finish" },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
/** A glla slash command named inside an option label. */
|
|
68
|
+
interface NamedAction {
|
|
69
|
+
group: string;
|
|
70
|
+
verb: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The picker's executable suffix form: `Label (/goal resume)`. */
|
|
74
|
+
const EXECUTABLE_SUFFIX = /\(\/(goal|list|loop|glla)\s+([a-z]+)\)\s*$/;
|
|
75
|
+
|
|
76
|
+
function namedActions(label: string): NamedAction[] {
|
|
77
|
+
const out: NamedAction[] = [];
|
|
78
|
+
for (const match of label.matchAll(/\/(goal|list|loop|glla)\s+([a-z]+)/g)) {
|
|
79
|
+
out.push({ group: match[1]!, verb: match[2]! });
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const isNamed = (action: NamedAction, table: ReadonlyArray<NamedAction>): boolean =>
|
|
85
|
+
table.some((entry) => entry.group === action.group && entry.verb === action.verb);
|
|
86
|
+
|
|
87
|
+
/** The clean option text (the picker appends " (recommended)" for display). */
|
|
88
|
+
export function decisionOptionText(option: string): string {
|
|
89
|
+
return option.replace(/ {2}\(recommended\)$/, "");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type AutoSelectVerdict =
|
|
93
|
+
| { adoptable: true; shape: "command" | "steer" }
|
|
94
|
+
| { adoptable: false; reason: string };
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Can an absent operator adopt this recommended option?
|
|
98
|
+
*
|
|
99
|
+
* Mechanical, never a judgment about the prose: a label that NAMES a reserved
|
|
100
|
+
* action is out; a label that names a `/glla` action is out (that is the
|
|
101
|
+
* operator's own settings task); anything else is a continue-work answer —
|
|
102
|
+
* either an executable continue command, or content the picker delivers to
|
|
103
|
+
* the agent before resuming.
|
|
104
|
+
*/
|
|
105
|
+
export function classifyAutoSelectOption(option: string | undefined): AutoSelectVerdict {
|
|
106
|
+
const label = option ? decisionOptionText(option).trim() : "";
|
|
107
|
+
if (!label) return { adoptable: false, reason: "the option text was empty" };
|
|
108
|
+
const actions = namedActions(label);
|
|
109
|
+
const reserved = actions.find((action) => isNamed(action, RESERVED_ACTIONS));
|
|
110
|
+
if (reserved) {
|
|
111
|
+
return { adoptable: false, reason: `\`/${reserved.group} ${reserved.verb}\` ends, rewrites, or parks the work` };
|
|
112
|
+
}
|
|
113
|
+
const settingsTask = actions.find((action) => action.group === "glla");
|
|
114
|
+
if (settingsTask) {
|
|
115
|
+
return { adoptable: false, reason: "it asks for a /glla change, which is the operator's own task" };
|
|
116
|
+
}
|
|
117
|
+
const executable = label.match(EXECUTABLE_SUFFIX);
|
|
118
|
+
if (executable) {
|
|
119
|
+
const [, group, verb] = executable;
|
|
120
|
+
const action = { group: group!, verb: verb! };
|
|
121
|
+
// An executable continue-work command is the picker's own action. Any
|
|
122
|
+
// other executable command that is neither reserved nor continue-work
|
|
123
|
+
// (a verb this build does not know) stays a plain resume of the prose.
|
|
124
|
+
return { adoptable: true, shape: isNamed(action, CONTINUE_WORK_ACTIONS) ? "command" : "steer" };
|
|
125
|
+
}
|
|
126
|
+
return { adoptable: true, shape: "steer" };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** The configured delay, or undefined when the feature is off. */
|
|
130
|
+
export function resolveDecisionAutoSelectMinutes(value: unknown): number | undefined {
|
|
131
|
+
if (typeof value !== "number" || !Number.isInteger(value)) return undefined;
|
|
132
|
+
if (value < 1 || value > DECISION_AUTO_SELECT_MAX_MINUTES) return undefined;
|
|
133
|
+
return value;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** When the current decision question landed. Legacy records fall back to
|
|
137
|
+
* `updatedAt`, which the pause write itself stamped. */
|
|
138
|
+
export function decisionPauseSince(goal: Pick<Goal, "pauseDecidedAt" | "updatedAt" | "createdAt"> | null | undefined): number | undefined {
|
|
139
|
+
const raw = goal?.pauseDecidedAt ?? goal?.updatedAt ?? goal?.createdAt;
|
|
140
|
+
const ms = raw ? Date.parse(raw) : Number.NaN;
|
|
141
|
+
return Number.isFinite(ms) ? ms : undefined;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface DecisionAutoSelectCandidate {
|
|
145
|
+
/** 1-based index the agent recommended. */
|
|
146
|
+
index: number;
|
|
147
|
+
option: string;
|
|
148
|
+
verdict: AutoSelectVerdict;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
type AutoSelectGoal = Pick<Goal,
|
|
152
|
+
"status" | "pauseKind" | "pauseOptions" | "pauseRecommended" | "pauseContractAmendment">;
|
|
153
|
+
|
|
154
|
+
/** A goal record as the clock needs it: the pause fields plus the timestamps
|
|
155
|
+
* the episode is measured from. */
|
|
156
|
+
export type AutoSelectGoalRecord = AutoSelectGoal & Pick<Goal, "pauseDecidedAt" | "updatedAt" | "createdAt">;
|
|
157
|
+
|
|
158
|
+
/** Everything the two surfaces need before they advertise or adopt a pick. */
|
|
159
|
+
export function decisionAutoSelectCandidate(goal: AutoSelectGoal | null | undefined): DecisionAutoSelectCandidate | undefined {
|
|
160
|
+
if (!goal || goal.status !== "paused" || goal.pauseKind !== "decision") return undefined;
|
|
161
|
+
if (!goal.pauseOptions || goal.pauseOptions.length === 0) return undefined;
|
|
162
|
+
const index = typeof goal.pauseRecommended === "number" ? Math.floor(goal.pauseRecommended) : 0;
|
|
163
|
+
if (index < 1 || index > goal.pauseOptions.length) return undefined;
|
|
164
|
+
const option = goal.pauseOptions[index - 1]!;
|
|
165
|
+
// A contract amendment changes what "done" means. Its recommended option is
|
|
166
|
+
// Accept, and that needs a person even when the command inside it is plain.
|
|
167
|
+
const verdict: AutoSelectVerdict = goal.pauseContractAmendment
|
|
168
|
+
? { adoptable: false, reason: "it proposes a verification-contract amendment, which needs your explicit consent" }
|
|
169
|
+
: classifyAutoSelectOption(option);
|
|
170
|
+
return { index, option, verdict };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Remaining milliseconds until the clock is due, or undefined when the clock
|
|
174
|
+
* is off / the pause has no recommendation to consider. Zero/negative means
|
|
175
|
+
* "due now".
|
|
176
|
+
*
|
|
177
|
+
* ARMED for ANY recommended decision option, including one that may not be
|
|
178
|
+
* adopted: the clock's job is also to TELL the operator that their own
|
|
179
|
+
* deadline passed on a question only they can answer (one
|
|
180
|
+
* `decision_auto_select_refused` line). Only the ADOPTION is restricted. */
|
|
181
|
+
export function decisionAutoSelectRemainingMs(
|
|
182
|
+
goal: AutoSelectGoalRecord | null | undefined,
|
|
183
|
+
minutes: unknown,
|
|
184
|
+
now: number,
|
|
185
|
+
): number | undefined {
|
|
186
|
+
const resolved = resolveDecisionAutoSelectMinutes(minutes);
|
|
187
|
+
if (resolved === undefined) return undefined;
|
|
188
|
+
if (!decisionAutoSelectCandidate(goal)) return undefined;
|
|
189
|
+
const since = decisionPauseSince(goal);
|
|
190
|
+
if (since === undefined) return undefined;
|
|
191
|
+
return since + resolved * 60_000 - now;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Is this pause past its configured delay (for ANY recommended option)?
|
|
195
|
+
*
|
|
196
|
+
* Armed means "the operator's own deadline passed". It does NOT mean an
|
|
197
|
+
* adoption may happen: eligibility is `decisionAutoSelectAdoptable`. The
|
|
198
|
+
* distinction is what lets a reserved recommendation (cancel, accept, tweak…)
|
|
199
|
+
* still tell the operator that their clock expired while refusing to answer
|
|
200
|
+
* the question for them.
|
|
201
|
+
*/
|
|
202
|
+
export function decisionAutoSelectDue(
|
|
203
|
+
goal: AutoSelectGoalRecord | null | undefined,
|
|
204
|
+
minutes: unknown,
|
|
205
|
+
now: number,
|
|
206
|
+
): boolean {
|
|
207
|
+
const remaining = decisionAutoSelectRemainingMs(goal, minutes, now);
|
|
208
|
+
return remaining !== undefined && remaining <= 0;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Is the RECOMMENDED option both eligible for unattended adoption AND due?
|
|
212
|
+
* This is the ONE gate the picker and the heartbeat share before adopting. */
|
|
213
|
+
export function decisionAutoSelectAdoptable(
|
|
214
|
+
goal: AutoSelectGoalRecord | null | undefined,
|
|
215
|
+
minutes: unknown,
|
|
216
|
+
now: number,
|
|
217
|
+
): boolean {
|
|
218
|
+
const candidate = decisionAutoSelectCandidate(goal);
|
|
219
|
+
if (!candidate || !candidate.verdict.adoptable) return false;
|
|
220
|
+
return decisionAutoSelectDue(goal, minutes, now);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** The picker countdown: the durable clock, floored so a just-due pick can
|
|
224
|
+
* still be read and cancelled. Undefined keeps the picker timeless — which
|
|
225
|
+
* is deliberate for a recommendation the clock may NOT adopt (the dialog
|
|
226
|
+
* must not dismiss itself on a question only the operator can answer). */
|
|
227
|
+
export function decisionAutoSelectCountdownMs(
|
|
228
|
+
goal: AutoSelectGoalRecord | null | undefined,
|
|
229
|
+
minutes: unknown,
|
|
230
|
+
now: number,
|
|
231
|
+
): number | undefined {
|
|
232
|
+
const candidate = decisionAutoSelectCandidate(goal);
|
|
233
|
+
if (!candidate || !candidate.verdict.adoptable) return undefined;
|
|
234
|
+
const remaining = decisionAutoSelectRemainingMs(goal, minutes, now);
|
|
235
|
+
if (remaining === undefined) return undefined;
|
|
236
|
+
return Math.max(DECISION_AUTO_SELECT_MIN_COUNTDOWN_MS, remaining);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** One-line card truth for an armed pause, or undefined when the clock is off
|
|
240
|
+
* or the recommendation may not be adopted. */
|
|
241
|
+
export function decisionAutoSelectCardLine(
|
|
242
|
+
goal: AutoSelectGoalRecord | null | undefined,
|
|
243
|
+
minutes: unknown,
|
|
244
|
+
now: number,
|
|
245
|
+
): string | undefined {
|
|
246
|
+
const candidate = decisionAutoSelectCandidate(goal);
|
|
247
|
+
if (!candidate || !candidate.verdict.adoptable) return undefined;
|
|
248
|
+
const remaining = decisionAutoSelectRemainingMs(goal, minutes, now);
|
|
249
|
+
if (remaining === undefined) return undefined;
|
|
250
|
+
const when = remaining <= 0 ? "now" : `in ${Math.max(1, Math.ceil(remaining / 60_000))}m`;
|
|
251
|
+
return `auto-answers with option ${candidate.index} ${when} unless you decide first`;
|
|
252
|
+
}
|