@gajae-code/coding-agent 0.7.9 → 0.7.10

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +2 -0
  3. package/dist/types/config/settings-schema.d.ts +10 -1
  4. package/dist/types/extensibility/extensions/types.d.ts +11 -0
  5. package/dist/types/gjc-runtime/launch-tmux.d.ts +7 -0
  6. package/dist/types/gjc-runtime/ultragoal-guard.d.ts +4 -0
  7. package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +0 -4
  8. package/dist/types/modes/components/hook-selector.d.ts +5 -0
  9. package/dist/types/modes/shared/agent-wire/deep-interview-gate.d.ts +20 -6
  10. package/dist/types/notifications/html-format.d.ts +2 -0
  11. package/dist/types/notifications/recent-activity.d.ts +5 -1
  12. package/dist/types/notifications/telegram-daemon-control.d.ts +8 -0
  13. package/dist/types/notifications/telegram-reference.d.ts +4 -0
  14. package/dist/types/notifications/threaded-render.d.ts +1 -0
  15. package/dist/types/tools/ask.d.ts +2 -0
  16. package/dist/types/utils/cmux-workspace.d.ts +23 -0
  17. package/dist/types/web/search/index.d.ts +1 -1
  18. package/dist/types/web/search/provider.d.ts +5 -0
  19. package/dist/types/web/search/render.d.ts +1 -0
  20. package/package.json +7 -7
  21. package/src/cli/web-search-cli.ts +3 -2
  22. package/src/config/settings-schema.ts +11 -1
  23. package/src/coordinator-mcp/server.ts +1 -1
  24. package/src/defaults/gjc/skills/deep-interview/SKILL.md +26 -2
  25. package/src/defaults/gjc/skills/ultragoal/SKILL.md +37 -112
  26. package/src/extensibility/extensions/types.ts +11 -0
  27. package/src/gjc-runtime/launch-tmux.ts +63 -2
  28. package/src/gjc-runtime/ultragoal-guard.ts +139 -19
  29. package/src/gjc-runtime/ultragoal-runtime.ts +16 -124
  30. package/src/gjc-runtime/workflow-manifest.generated.json +0 -8
  31. package/src/gjc-runtime/workflow-manifest.ts +0 -1
  32. package/src/hooks/skill-state.ts +33 -73
  33. package/src/internal-urls/docs-index.generated.ts +2 -1
  34. package/src/modes/components/hook-selector.ts +21 -3
  35. package/src/modes/components/settings-selector.ts +47 -3
  36. package/src/modes/components/status-line/presets.ts +11 -0
  37. package/src/modes/controllers/extension-ui-controller.ts +18 -2
  38. package/src/modes/shared/agent-wire/deep-interview-gate.ts +53 -9
  39. package/src/notifications/html-format.ts +75 -1
  40. package/src/notifications/index.ts +12 -1
  41. package/src/notifications/recent-activity.ts +32 -8
  42. package/src/notifications/telegram-daemon-control.ts +9 -0
  43. package/src/notifications/telegram-daemon.ts +67 -24
  44. package/src/notifications/telegram-reference.ts +36 -14
  45. package/src/notifications/threaded-render.ts +14 -6
  46. package/src/prompts/system/system-prompt.md +5 -1
  47. package/src/sdk.ts +3 -5
  48. package/src/tools/ask.ts +136 -16
  49. package/src/utils/cmux-workspace.ts +106 -0
  50. package/src/utils/title-generator.ts +2 -0
  51. package/src/web/search/index.ts +22 -10
  52. package/src/web/search/provider.ts +15 -0
  53. package/src/web/search/render.ts +3 -0
@@ -11,7 +11,7 @@ Use when the user asks for `ultragoal`, `create-goals`, `complete-goals`, durabl
11
11
 
12
12
  ## Purpose
13
13
 
14
- `ultragoal` turns a brief into repo-native artifacts and then drives a GJC goal safely through the unified `goal` tool. New plans default to a stable pointer-style aggregate GJC goal for the whole durable plan in `.gjc/_session-{sessionid}/ultragoal/goals.json`, including later accepted/appended stories under the original brief constraints, while GJC tracks G001/G002 story progress in the ledger. Ultragoal does not require any `/goal` slash-command between runs. For back-to-back ultragoal runs in one session/thread, call `goal({"op":"drop"})` only when `goal({"op":"get"})` still reports an active aggregate; then call `goal({"op":"create"})`. The goal tool stays armed across drop so the next create works in-session, and no slash-command cleanup exists or is required.
14
+ `ultragoal` turns a brief into repo-native durable artifacts and then drives execution through the unified `goal` tool as a UX bridge only. `goals.json` is the canonical source of goal identity and state; `ledger.jsonl` is the canonical proof stream for checkpoints, receipts, blockers, steering, and reviews. The inline `goal` tool and goal-mode-request create-bridge exist only to keep the agent's interactive loop focused on the current aggregate or story objective. Completion is verified purely from durable `goals.json` plus fresh `ledger.jsonl` receipts, never from inline goal state. The agent, not the CLI or hooks, calls `goal({"op":"complete"})` or `goal({"op":"drop"})` after durable run completion or cleanup; CLI commands and hooks never mutate goal state.
15
15
 
16
16
  - `.gjc/_session-{sessionid}/ultragoal/brief.md`
17
17
  - `.gjc/_session-{sessionid}/ultragoal/goals.json`
@@ -36,7 +36,7 @@ gjc ultragoal complete-goals
36
36
  gjc ultragoal complete-goals --retry-failed
37
37
  gjc ultragoal checkpoint --goal-id <id> --status complete --evidence "<evidence>" --quality-gate-json <quality-gate-json-or-path>
38
38
  gjc ultragoal checkpoint --goal-id <id> --status failed --evidence "<blocker/evidence>"
39
- gjc ultragoal record-review-blockers --goal-id <id> --title "Resolve final review blockers" --objective "<blocker-resolution objective>" --evidence "<review findings>" --gjc-goal-json <active-goal-get-json-or-path>
39
+ gjc ultragoal record-review-blockers --goal-id <id> --title "Resolve final review blockers" --objective "<blocker-resolution objective>" --evidence "<review findings>"
40
40
  ```
41
41
 
42
42
  Use these exact goal-tool calls for the inline goal state:
@@ -50,7 +50,7 @@ goal({"op":"resume"})
50
50
  ```
51
51
  `drop` clears the active goal without exiting goal mode; `resume` reactivates a paused goal.
52
52
 
53
- Complete checkpoints source the active GJC goal snapshot from the current session when `--gjc-goal-json` is omitted. Use an explicit `--gjc-goal-json` only as an override; supplied values are still strictly validated and must be active goal-mode snapshots, not `.gjc/ultragoal/goals.json` records.
53
+ Durable completion is single-source: `goals.json` defines which goals exist and their required state, while `ledger.jsonl` provides the receipt proof used to verify completion. Inline goal state is UX-only and is reconciled by the agent after durable completion, not by CLI checkpoints or hooks.
54
54
 
55
55
  ## Create goals
56
56
 
@@ -98,13 +98,13 @@ Loop until `gjc ultragoal status` reports all goals complete:
98
98
  5. Complete the current GJC story only.
99
99
  6. Run a completion audit against the story objective and real artifacts/tests.
100
100
  7. Before any `--status complete` checkpoint, run the mandatory final cleanup/review gate below. In aggregate mode, do **not** call `goal({"op":"complete"})` for intermediate stories; checkpoint each story while the aggregate objective is still `active`. On the final story, create the final aggregate receipt first; only after that receipt exists may `goal({"op":"complete"})` run.
101
- 8. Checkpoint the durable ledger. Complete checkpoints require `--quality-gate-json`; the runtime sources the active GJC goal snapshot from current session state when `--gjc-goal-json` is omitted, and rejects any explicitly supplied bad snapshot:
101
+ 8. Checkpoint the durable ledger. Complete checkpoints require `--quality-gate-json` only:
102
102
  `gjc ultragoal checkpoint --goal-id <id> --status complete --evidence "<evidence>" --quality-gate-json <quality-gate-json-or-path>`
103
103
  A successful complete checkpoint is story completion, not automatic run completion. Read the checkpoint output: when it prints `Next ultragoal goal: <id>`, continue that active story under the same aggregate GJC goal; when it prints `All ultragoal goals are complete`, the durable run is terminal. `gjc ultragoal complete-goals` remains the supported manual next-story command if continuation output was missed.
104
104
  9. If blocked or failed, checkpoint failure:
105
105
  `gjc ultragoal checkpoint --goal-id <id> --status failed --evidence "<blocker/evidence>"`
106
106
  10. For legacy per-story completed-goal blockers, preserve the non-terminal blocker with:
107
- `gjc ultragoal checkpoint --goal-id <id> --status blocked --evidence "<completed legacy GJC goal blocks goal create in this thread>" --gjc-goal-json <goal-get-json-or-path>`
107
+ `gjc ultragoal checkpoint --goal-id <id> --status blocked --evidence "<completed legacy GJC goal blocks goal create in this thread>"`
108
108
  11. Resume failed goals with `gjc ultragoal complete-goals --retry-failed`.
109
109
 
110
110
  ## Blocker triage and pause discipline
@@ -167,19 +167,36 @@ Ultragoal execution should use GJC's bundled role-agent roster when a durable st
167
167
  - Use `architect` for read-only architecture and code-review lanes, including `CLEAR` / `WATCH` / `BLOCK` status.
168
168
  - Use `critic` for read-only plan or handoff critique before execution proceeds.
169
169
 
170
+ ### Mandatory implementation delegation on big scope
171
+
172
+ When a story's implementation scope is **big enough**, the Ultragoal leader MUST delegate the implementation to one or more `executor` subagents instead of writing the code inline itself. This is a hard requirement, not a preference: solo inline implementation of a big-scope story is a gate violation, and the completion cleanup/review gate must treat missing delegation on a big-scope story as a blocker.
173
+
174
+ A story's implementation scope is **big enough** to force delegation when any of the following hold:
175
+
176
+ - It spans **3+ files** or **2+ cleanly separable surfaces/modules** that can be implemented against bounded, independent acceptance criteria.
177
+ - It is estimated at **~200+ lines of net implementation change**, or is otherwise large enough that a single inline pass would crowd out the leader's checkpoint/verification duties.
178
+ - It decomposes into **independent slices** that can proceed in parallel without shared-file contention.
179
+ - The leader has already made **2+ inline edit passes** on the same story and implementation is still materially incomplete.
180
+
181
+ Forced-delegation rules:
182
+
183
+ - Split the story into cleanly separable slices, give each `executor` bounded targets and explicit acceptance criteria, and keep checkpoint/goal-state ownership in the leader.
184
+ - Prefer **parallel** `executor` subagents for independent slices; sequence only slices with a real dependency.
185
+ - If a big-scope story cannot be cleanly split, record the reason as a durable ledger note and delegate the whole implementation to a single `executor` rather than doing it inline; the leader still owns verification.
186
+ - Small, atomic, single-file changes below these thresholds stay with the leader — do not over-delegate trivial work.
187
+ - After integrating delegated slices, run `architect` / `critic` review lanes; worker agents never mutate `.gjc/_session-{sessionid}/ultragoal` or call goal tools.
188
+
170
189
  When delegating with native subagents, an await timeout only limits the leader's wait. It is not subagent failure evidence and must not be used as a cancellation reason; inspect or continue independent work, and cancel only when the subagent has actually failed, gone off-track, or become unrecoverably wrong.
171
190
 
172
191
  If an Ultragoal request has no approved plan or consensus artifact, run `ralplan` first and preserve its PRD, test spec, role roster, and verification guidance in the Ultragoal ledger. Do not silently substitute ad-hoc execution for missing planning.
173
192
 
174
193
  The Ultragoal leader owns `.gjc/_session-{sessionid}/ultragoal/goals.json` and `.gjc/_session-{sessionid}/ultragoal/ledger.jsonl`. Role agents return implementation/review evidence; they do not checkpoint Ultragoal or mutate goal state.
175
194
 
176
- For large subgoals with independent slices, the Ultragoal leader must spawn parallel `executor` subagents instead of doing serial solo work. Split only cleanly separable files/surfaces, give each executor bounded targets and acceptance criteria, and keep checkpoint ownership in the leader. Use `architect` / `critic` review lanes after integration; do not let worker agents mutate `.gjc/_session-{sessionid}/ultragoal` or call goal tools.
177
-
178
195
  ## Use Ultragoal and Team together
179
196
 
180
197
  Use ultragoal and team together for a durable Ultragoal story that benefits from one visible tmux worker session. Ultragoal remains leader-owned: `.gjc/_session-{sessionid}/ultragoal/goals.json` stores the story plan and `.gjc/_session-{sessionid}/ultragoal/ledger.jsonl` stores checkpoints. Team is the single-worker tmux execution engine and returns task/evidence status to the leader.
181
198
 
182
- The leader checkpoints Ultragoal from Team evidence; the runtime uses the active current-session GJC goal snapshot unless an explicit `--gjc-goal-json` override is supplied:
199
+ The leader checkpoints Ultragoal from Team evidence plus the current-session GJC goal snapshot; durable state remains leader-owned in `goals.json` and `ledger.jsonl`:
183
200
 
184
201
  ```sh
185
202
  gjc ultragoal checkpoint --goal-id <id> --status complete --evidence "<team evidence mentioning .gjc/_session-{sessionid}/ultragoal and <id>>" --quality-gate-json <quality-gate-json-or-path>
@@ -219,10 +236,10 @@ An ultragoal story cannot be checkpointed `complete` until the active agent has
219
236
  8. Run a final code review pass and fold it into the strict quality gate. Clean means `architectReview.architectureStatus`, `architectReview.productStatus`, and `architectReview.codeStatus` are all `"CLEAR"`, `architectReview.recommendation` is `"APPROVE"`, executor QA statuses are `"passed"`, iteration is `"passed"` with `fullRerun: true`, every evidence field is non-empty, every required matrix row is present, and every blockers array is empty. `COMMENT`, `WATCH`, `REQUEST CHANGES`, `BLOCK`, missing evidence, missing or shallow matrix rows, plan/code mismatches, or non-empty blockers are non-clean.
220
237
  9. If any lane finds an issue, do **not** checkpoint `complete` and do **not** call `goal({"op":"complete"})`. Record durable blocker work instead:
221
238
  ```sh
222
- gjc ultragoal record-review-blockers --goal-id <id> --title "Resolve verification blockers" --objective "<blocker-resolution objective>" --evidence "<architect/executor findings>" --gjc-goal-json <active-goal-get-json-or-path>
239
+ gjc ultragoal record-review-blockers --goal-id <id> --title "Resolve verification blockers" --objective "<blocker-resolution objective>" --evidence "<architect/executor findings>"
223
240
  ```
224
241
  10. Complete or steer through the blocker story, then rerun the full blocking verification loop. Repeat until all verifier lanes are clean.
225
- 11. Only after the loop is clean, checkpoint the story as complete with a structured quality gate and current-session active goal snapshot. The checkpoint creates a receipt; `goals.json.status` alone is not proof. In aggregate mode, the final aggregate receipt must exist before `goal({"op":"complete"})` is allowed.
242
+ 11. Only after the loop is clean, checkpoint the story as complete with a structured quality gate. The checkpoint creates a receipt in `ledger.jsonl`; `goals.json.status` alone is not proof. In aggregate mode, the final aggregate receipt must exist before the agent calls `goal({"op":"complete"})` to reconcile the inline UX goal state.
226
243
 
227
244
  While an Ultragoal run is active, the `ask` tool is blocked for all agents. Record unresolved review decisions as durable blockers with `gjc ultragoal record-review-blockers` instead of prompting interactively.
228
245
 
@@ -235,7 +252,7 @@ The native `checkpoint --status complete` command rejects missing or shallow gat
235
252
  "productStatus": "CLEAR",
236
253
  "codeStatus": "CLEAR",
237
254
  "recommendation": "APPROVE",
238
- "evidence": "architect review synthesis with architecture/product/code coverage",
255
+ "evidence": "architect review synthesis across architecture/product/code",
239
256
  "commands": ["architect review command or agent evidence id"],
240
257
  "blockers": []
241
258
  },
@@ -247,116 +264,22 @@ The native `checkpoint --status complete` command rejects missing or shallow gat
247
264
  "e2eCommands": ["bun test:e2e"],
248
265
  "redTeamCommands": ["bun test:red-team"],
249
266
  "artifactRefs": [
250
- {
251
- "id": "browser-run",
252
- "kind": "browser-automation",
253
- "path": "artifacts/browser-run.json",
254
- "description": "valid automation transcript with actions, monotonic timestamps, and selectors"
255
- },
256
- {
257
- "id": "gui-screenshot",
258
- "kind": "screenshot",
259
- "path": "artifacts/gui-screenshot.png",
260
- "description": "non-uniform screenshot evidence for the GUI/web result"
261
- },
262
- {
263
- "id": "cli-replay",
264
- "kind": "command-replay",
265
- "path": "artifacts/cli-replay.json",
266
- "description": "artifact file containing argv-only CLI replay JSON: schemaVersion 1, kind cli-replay, replaySafe true, allowlisted command such as bun/node --version or deterministic bun/node -e console.log(...), recordedStdout"
267
- },
268
- {
269
- "id": "adversarial-report",
270
- "kind": "failure-mode-test",
271
- "path": "artifacts/adversarial-report.txt",
272
- "description": "boundary, property, adversarial, or failure-mode result"
273
- },
274
- {
275
- "id": "api-package-report",
276
- "kind": "api-package-test-report",
277
- "path": "artifacts/api-package-report.txt",
278
- "description": "API/package consumer or endpoint verification output"
279
- },
280
- {
281
- "id": "algorithm-report",
282
- "kind": "property-test-report",
283
- "path": "artifacts/algorithm-report.txt",
284
- "description": "Algorithm/math property, boundary, or invariant verification output"
285
- }
267
+ { "id": "<ref-id>", "kind": "<surface-appropriate kind; see step 6>", "path": "artifacts/<file>", "description": "live-surface evidence" }
286
268
  ],
287
269
  "contractCoverage": [
288
- {
289
- "id": "contract-goal",
290
- "contractRef": "approved plan/spec/acceptance criterion or user-facing contract id",
291
- "obligation": "required behavior from the approved contract",
292
- "status": "covered",
293
- "surfaceEvidenceRefs": ["surface-gui"],
294
- "adversarialCaseRefs": ["case-invalid-input"]
295
- },
296
- {
297
- "id": "contract-out-of-scope",
298
- "contractRef": "contract intentionally outside this story",
299
- "obligation": "explicitly omitted approved-contract surface",
300
- "status": "not_applicable",
301
- "reason": "why this contract does not apply to the current story"
302
- }
270
+ { "id": "<id>", "contractRef": "<approved contract id>", "obligation": "<required behavior>", "status": "covered", "surfaceEvidenceRefs": ["<surface-id>"], "adversarialCaseRefs": ["<case-id>"] }
303
271
  ],
304
272
  "surfaceEvidence": [
305
- {
306
- "id": "surface-gui",
307
- "contractRef": "user-facing surface or public interface under test",
308
- "surface": "gui|web|cli|api|package|algorithm|math|native|desktop|tui",
309
- "invocation": "real browser action, CLI command, API/package consumer call, or algorithm/property check",
310
- "verdict": "passed",
311
- "artifactRefs": ["browser-run", "gui-screenshot"]
312
- },
313
- {
314
- "id": "surface-cli",
315
- "contractRef": "CLI or command-line interface under test",
316
- "surface": "cli",
317
- "invocation": "argv replay executed by the Ultragoal runtime",
318
- "verdict": "passed",
319
- "artifactRefs": ["cli-replay"]
320
- },
321
- {
322
- "id": "surface-api",
323
- "contractRef": "API/package public interface under test",
324
- "surface": "api/package",
325
- "invocation": "real endpoint call, package consumer call, or schema contract check",
326
- "verdict": "passed",
327
- "artifactRefs": ["api-package-report"]
328
- },
329
- {
330
- "id": "surface-algorithm",
331
- "contractRef": "algorithm/math invariant under test",
332
- "surface": "algorithm/math",
333
- "invocation": "property, boundary, or invariant test run",
334
- "verdict": "passed",
335
- "artifactRefs": ["algorithm-report"]
336
- },
337
- {
338
- "id": "surface-out-of-scope",
339
- "contractRef": "surface intentionally outside this story",
340
- "surface": "gui|web|cli|api|package|algorithm|math|native|desktop|tui",
341
- "status": "not_applicable",
342
- "reason": "why this surface does not apply to the current story"
343
- }
273
+ { "id": "<surface-id>", "contractRef": "<surface under test>", "surface": "gui|web|cli|api|package|algorithm|math|native|desktop|tui", "invocation": "<real invocation>", "verdict": "passed", "artifactRefs": ["<ref-id>"] }
344
274
  ],
345
275
  "adversarialCases": [
346
- {
347
- "id": "case-invalid-input",
348
- "contractRef": "approved plan/spec/acceptance criterion or user-facing contract id",
349
- "scenario": "boundary/property/adversarial/failure-mode input or user action",
350
- "expectedBehavior": "contract-required rejection, handling, or invariant preservation",
351
- "verdict": "passed",
352
- "artifactRefs": ["adversarial-report"]
353
- }
276
+ { "id": "<case-id>", "contractRef": "<approved contract id>", "scenario": "<boundary/adversarial input>", "expectedBehavior": "<required handling>", "verdict": "passed", "artifactRefs": ["<ref-id>"] }
354
277
  ],
355
278
  "blockers": []
356
279
  },
357
280
  "iteration": {
358
281
  "status": "passed",
359
- "evidence": "blockers were absent or resolved and the full verification loop was rerun cleanly",
282
+ "evidence": "blockers absent or resolved and the full loop was rerun cleanly",
360
283
  "fullRerun": true,
361
284
  "rerunCommands": ["bun test:e2e", "bun test:red-team"],
362
285
  "blockers": []
@@ -364,6 +287,8 @@ The native `checkpoint --status complete` command rejects missing or shallow gat
364
287
  }
365
288
  ```
366
289
 
290
+ Provide one `artifactRefs` entry per live surface actually exercised, using the surface-appropriate `kind` and evidence rules from steps 6–7 above; the CLI rejects missing or shallow gates. `status: "not_applicable"` rows are allowed only in `contractCoverage` and `surfaceEvidence` and each requires `contractRef` plus `reason`.
291
+
367
292
  For CLI replay artifacts, the JSON at `path` must be an object like `{"schemaVersion":1,"kind":"cli-replay","replaySafe":true,"command":["bun","-e","console.log(\"ultragoal-cli-ok\")"],"recordedStdout":"ultragoal-cli-ok\n"}`. Use `replayExempt` only for audited unsafe/non-deterministic invocations, with exact fields `reasonCode`, `reason`, `approvedBy`, and `fallbackArtifactRefs`. `reason` must be substantive and audited, `approvedBy` must identify the verifier, and `fallbackArtifactRefs` must reference same-surface structurally valid fallback artifacts. Allowed `reasonCode` values are exactly `unsafe_side_effect`, `requires_credentials`, `requires_network`, `non_deterministic_external`, `destructive`, `interactive_only`, and `platform_unavailable`.
368
293
 
369
294
  ## Review mode
@@ -392,6 +317,6 @@ The skill tool then dispatches `/skill:ralplan` or `/skill:deep-interview` same-
392
317
  - For back-to-back ultragoal runs in the same session/thread, when `goal({"op":"get"})` still reports an active aggregate, call `goal({"op":"drop"})` before `goal({"op":"create"})`; when no active goal exists or the prior aggregate is already complete or dropped, call `goal({"op":"create"})` directly. The goal tool remains callable across drop; no slash-command cleanup exists or is required.
393
318
  - Never call `goal({"op":"create"})` when `goal({"op":"get"})` reports a different active goal.
394
319
  - Never call `goal({"op":"complete"})` unless the aggregate run or legacy per-story goal is actually complete.
395
- - In aggregate mode, intermediate and final story checkpoints require a matching `active` GJC goal snapshot; omitted complete-checkpoint `--gjc-goal-json` reads that snapshot from current session state, and the final story checkpoint creates the final aggregate receipt before `goal({"op":"complete"})` may reconcile the inline goal state.
396
- - Completion checkpoints require read-only goal snapshot reconciliation: omit `--gjc-goal-json` to use current session state, or pass an explicit JSON/path override that remains strictly validated; shell commands and hooks must not mutate goal state.
320
+ - In aggregate mode, intermediate and final story checkpoints update durable `goals.json` state and append receipt proof to `ledger.jsonl`; the final story checkpoint creates the final aggregate receipt before the agent may call `goal({"op":"complete"})`.
321
+ - Completion checkpoints require `--quality-gate-json` only. Shell commands and hooks must not mutate goal state; the agent reconciles inline goal-tool state after durable completion.
397
322
  - Treat `ledger.jsonl` as the durable audit trail; checkpoint after every success or failure.
@@ -136,6 +136,17 @@ export interface ExtensionUIDialogOptions {
136
136
  optionLabel: string;
137
137
  onSubmit: (text: string) => void;
138
138
  };
139
+ /**
140
+ * Inline free-text input for a non-answer clarification action. It is
141
+ * separate from `customInput` so callers can distinguish "ask about these
142
+ * choices" from "provide my own answer". Empty/whitespace-only submissions
143
+ * may be rejected by the selector when `allowEmpty` is false.
144
+ */
145
+ clarificationInput?: {
146
+ optionLabel: string;
147
+ onSubmit: (text: string) => void;
148
+ allowEmpty?: boolean;
149
+ };
139
150
  }
140
151
 
141
152
  /** Raw terminal input listener for extensions. */
@@ -44,6 +44,8 @@ type LaunchPolicy = "direct" | "tmux";
44
44
  interface TtyState {
45
45
  stdin: boolean;
46
46
  stdout: boolean;
47
+ columns?: number;
48
+ rows?: number;
47
49
  }
48
50
 
49
51
  export interface TmuxLaunchContext {
@@ -69,6 +71,10 @@ export interface TmuxSpawnResult {
69
71
  signalCode?: string | null;
70
72
  stderr?: string;
71
73
  }
74
+ export interface TmuxTerminalSize {
75
+ columns: number;
76
+ rows: number;
77
+ }
72
78
 
73
79
  export type TmuxSpawnSync = (command: string, args: string[], options: TmuxSpawnOptions) => TmuxSpawnResult;
74
80
 
@@ -95,6 +101,7 @@ export interface TmuxLaunchPlan {
95
101
  cwd: string;
96
102
  innerCommand: string;
97
103
  newSessionArgs: string[];
104
+ initialSize?: TmuxTerminalSize;
98
105
  branch?: string | null;
99
106
  attachSessionName?: string;
100
107
  project?: string | null;
@@ -537,6 +544,43 @@ function isTmuxAttachDisconnectError(result: TmuxSpawnResult): boolean {
537
544
  const stderr = result.stderr?.toLowerCase() ?? "";
538
545
  return stderr.includes("eio") || stderr.includes("input/output error");
539
546
  }
547
+ function normalizeTmuxTerminalDimension(value: number | undefined): number | undefined {
548
+ if (value === undefined || !Number.isSafeInteger(value) || value <= 0) return undefined;
549
+ return value;
550
+ }
551
+
552
+ function resolveCallerTmuxTerminalSize(tty: TtyState): TmuxTerminalSize | undefined {
553
+ if (!tty.stdout) return undefined;
554
+ const columns = normalizeTmuxTerminalDimension(tty.columns);
555
+ const rows = normalizeTmuxTerminalDimension(tty.rows);
556
+ if (columns === undefined || rows === undefined) return undefined;
557
+ return { columns, rows };
558
+ }
559
+
560
+ function buildTmuxNewSessionSizeArgs(size: TmuxTerminalSize | undefined): string[] {
561
+ return size ? ["-x", String(size.columns), "-y", String(size.rows)] : [];
562
+ }
563
+
564
+ function resizeCreatedTmuxWindowToCallerTerminalSize(
565
+ plan: TmuxLaunchPlan,
566
+ spawnSync: TmuxSpawnSync,
567
+ options: TmuxSpawnOptions,
568
+ ): void {
569
+ if (!plan.initialSize) return;
570
+ spawnSync(
571
+ plan.tmuxCommand,
572
+ [
573
+ "resize-window",
574
+ "-t",
575
+ buildGjcTmuxExactOptionTarget(plan.sessionName, { env: options.env }),
576
+ "-x",
577
+ String(plan.initialSize.columns),
578
+ "-y",
579
+ String(plan.initialSize.rows),
580
+ ],
581
+ options,
582
+ );
583
+ }
540
584
 
541
585
  export function buildDefaultTmuxLaunchPlan(context: TmuxLaunchContext): TmuxLaunchPlan | undefined {
542
586
  const env = context.env ?? process.env;
@@ -544,7 +588,12 @@ export function buildDefaultTmuxLaunchPlan(context: TmuxLaunchContext): TmuxLaun
544
588
  if (!context.parsed.tmux || policy === "direct") return undefined;
545
589
  if (env.TMUX || env[GJC_TMUX_LAUNCHED_ENV] === "1") return undefined;
546
590
  const platform = context.platform ?? process.platform;
547
- const tty = context.tty ?? { stdin: Boolean(process.stdin.isTTY), stdout: Boolean(process.stdout.isTTY) };
591
+ const tty = context.tty ?? {
592
+ stdin: Boolean(process.stdin.isTTY),
593
+ stdout: Boolean(process.stdout.isTTY),
594
+ columns: process.stdout.columns,
595
+ rows: process.stdout.rows,
596
+ };
548
597
  if (policy === "tmux" && !isInteractiveRootLaunch(context.parsed, tty)) return undefined;
549
598
 
550
599
  const cwd = context.cwd ?? process.cwd();
@@ -592,12 +641,23 @@ export function buildDefaultTmuxLaunchPlan(context: TmuxLaunchContext): TmuxLaun
592
641
  },
593
642
  context.rawArgs,
594
643
  );
644
+ const initialSize = resolveCallerTmuxTerminalSize(tty);
595
645
  return {
596
646
  tmuxCommand,
597
647
  sessionName,
598
648
  cwd,
599
649
  innerCommand,
600
- newSessionArgs: ["new-session", "-d", "-s", sessionName, "-c", cwd, innerCommand],
650
+ newSessionArgs: [
651
+ "new-session",
652
+ "-d",
653
+ ...buildTmuxNewSessionSizeArgs(initialSize),
654
+ "-s",
655
+ sessionName,
656
+ "-c",
657
+ cwd,
658
+ innerCommand,
659
+ ],
660
+ initialSize,
601
661
  branch,
602
662
  project,
603
663
  sessionId,
@@ -791,6 +851,7 @@ export function launchDefaultTmuxIfNeeded(context: TmuxLaunchContext): boolean {
791
851
  }
792
852
  // Recovery succeeded via retry — fall through to attach-session below.
793
853
  }
854
+ resizeCreatedTmuxWindowToCallerTerminalSize(plan, spawnSync, controlOptions);
794
855
  applyGjcTmuxRootTerminalTitleProfile({
795
856
  tmuxCommand: plan.tmuxCommand,
796
857
  target: plan.sessionName,
@@ -253,13 +253,6 @@ export function validateCompletionReceipt(input: {
253
253
  goalId: input.goal.id,
254
254
  };
255
255
  }
256
- if (hashStructuredValue(event.gjcGoalJson) !== receipt.gjcGoalSnapshotHash) {
257
- return {
258
- state: "active_stale_receipt",
259
- message: `Ultragoal ${input.goal.id} receipt goal({"op":"get"}) snapshot hash does not match ledger.`,
260
- goalId: input.goal.id,
261
- };
262
- }
263
256
  if (input.goal.updatedAt !== receipt.verifiedAt) {
264
257
  return {
265
258
  state: "active_stale_receipt",
@@ -276,15 +269,28 @@ export function validateCompletionReceipt(input: {
276
269
  goalId: input.goal.id,
277
270
  };
278
271
  }
279
- const missingReceipts = requiredGoals(input.plan).filter(
280
- goal => goal.id !== input.goal.id && !goal.completionVerification,
281
- );
282
- if (missingReceipts.length > 0) {
283
- return {
284
- state: "active_missing_receipt",
285
- message: `Ultragoal final receipt is missing per-goal evidence for: ${missingReceipts.map(goal => goal.id).join(", ")}.`,
286
- goalId: input.goal.id,
287
- };
272
+ for (const priorGoal of requiredGoals(input.plan)) {
273
+ if (priorGoal.id === input.goal.id) continue;
274
+ if (!priorGoal.completionVerification) {
275
+ return {
276
+ state: "active_missing_receipt",
277
+ message: `Ultragoal final receipt is missing per-goal evidence for: ${priorGoal.id}.`,
278
+ goalId: input.goal.id,
279
+ };
280
+ }
281
+ const priorDiagnostic = validateCompletionReceipt({
282
+ plan: input.plan,
283
+ ledger: input.ledger,
284
+ goal: priorGoal,
285
+ receiptKind: "per-goal",
286
+ });
287
+ if (priorDiagnostic.state !== "active_verified_complete") {
288
+ return {
289
+ state: priorDiagnostic.state,
290
+ message: `Ultragoal final receipt requires a valid per-goal receipt for ${priorGoal.id}: ${priorDiagnostic.message}`,
291
+ goalId: input.goal.id,
292
+ };
293
+ }
288
294
  }
289
295
  }
290
296
  return {
@@ -375,6 +381,120 @@ export async function readUltragoalVerificationState(input: {
375
381
  return receiptDiagnostic;
376
382
  }
377
383
 
384
+ export async function verifyUltragoalDurableCompletionState(input: {
385
+ cwd: string;
386
+ sessionId?: string | null;
387
+ }): Promise<UltragoalGuardDiagnostic> {
388
+ let paths: UltragoalPaths;
389
+ let sessionId: string | null;
390
+ try {
391
+ ({ paths, sessionId } = await ultragoalReadPaths(input.cwd, { sessionId: input.sessionId }));
392
+ } catch (error) {
393
+ return {
394
+ state: "unreadable_fail_closed",
395
+ message: `Unable to resolve durable Ultragoal state: ${error instanceof Error ? error.message : String(error)}`,
396
+ };
397
+ }
398
+ if (sessionId === null)
399
+ return { state: "inactive", message: "No active GJC session resolved; ultragoal is inactive." };
400
+ try {
401
+ await fs.stat(paths.dir);
402
+ } catch (error) {
403
+ if (isEnoent(error)) return { state: "inactive", message: "No durable .gjc/ultragoal state exists." };
404
+ return {
405
+ state: "unreadable_fail_closed",
406
+ message: `Durable .gjc/ultragoal state is present but unreadable: ${error instanceof Error ? error.message : String(error)}`,
407
+ };
408
+ }
409
+
410
+ let plan: UltragoalPlan | null;
411
+ let ledger: UltragoalLedgerEvent[];
412
+ try {
413
+ plan = await readUltragoalPlan(input.cwd, sessionId);
414
+ ledger = await readUltragoalLedger(input.cwd, sessionId);
415
+ } catch (error) {
416
+ return {
417
+ state: "unreadable_fail_closed",
418
+ message: `Unable to read durable Ultragoal state: ${error instanceof Error ? error.message : String(error)}`,
419
+ };
420
+ }
421
+ if (!plan) return { state: "inactive", message: "No Ultragoal plan exists." };
422
+
423
+ if (plan.goals.some(goal => goal.status === "review_blocked")) {
424
+ return {
425
+ state: "active_review_blocked_recorded",
426
+ message: "Ultragoal has recorded review blockers; complete blocker work and rerun verification.",
427
+ };
428
+ }
429
+
430
+ const runState = getUltragoalRunCompletionState(plan);
431
+ if (runState.incompleteGoals.some(goal => goal.status === "blocked" || goal.status === "failed")) {
432
+ return {
433
+ state: "active_dirty_quality_gate",
434
+ message: "Ultragoal has blocked or failed goals; record blockers or rerun verification.",
435
+ };
436
+ }
437
+
438
+ if (plan.gjcGoalMode === "per-story") {
439
+ const incomplete = requiredGoals(plan).filter(goal => goal.status !== "complete");
440
+ if (incomplete.length > 0) {
441
+ return {
442
+ state: "active_missing_receipt",
443
+ message: `Ultragoal per-story completion requires all required stories to be complete; incomplete: ${incomplete.map(goal => goal.id).join(", ")}.`,
444
+ goalId: incomplete[0]?.id,
445
+ };
446
+ }
447
+ for (const goal of requiredGoals(plan)) {
448
+ const diagnostic = validateCompletionReceipt({
449
+ plan,
450
+ ledger,
451
+ goal,
452
+ receiptKind: "per-goal",
453
+ });
454
+ if (diagnostic.state !== "active_verified_complete") return diagnostic;
455
+ }
456
+ return {
457
+ state: "active_verified_complete",
458
+ message: "Ultragoal per-story run is verified complete.",
459
+ };
460
+ }
461
+
462
+ const ask = await isUltragoalAskBlocked(input.cwd, { sessionId });
463
+ if (!ask.active) {
464
+ return {
465
+ state: "active_verified_complete",
466
+ message: ask.reason,
467
+ goalId: ask.goalIds?.at(0),
468
+ };
469
+ }
470
+ if (ask.source === "durable_state_unreadable") {
471
+ return {
472
+ state: "unreadable_fail_closed",
473
+ message: ask.reason,
474
+ goalId: ask.goalIds?.at(0),
475
+ };
476
+ }
477
+ if (ask.reason.includes("recorded review blockers")) {
478
+ return {
479
+ state: "active_review_blocked_recorded",
480
+ message: ask.reason,
481
+ goalId: ask.goalIds?.at(0),
482
+ };
483
+ }
484
+ if (ask.reason.includes("incomplete required goals")) {
485
+ return {
486
+ state: "active_missing_final_receipt",
487
+ message: ask.reason,
488
+ goalId: ask.goalIds?.at(0),
489
+ };
490
+ }
491
+ return {
492
+ state: "active_missing_final_receipt",
493
+ message: ask.reason,
494
+ goalId: ask.goalIds?.at(0),
495
+ };
496
+ }
497
+
378
498
  export async function isUltragoalAskBlocked(
379
499
  cwd: string,
380
500
  options: { sessionId?: string | null } = {},
@@ -600,8 +720,8 @@ export async function assertCanCompleteCurrentGoal(input: {
600
720
  sessionId?: string | null;
601
721
  }): Promise<void> {
602
722
  if (!input.cwd) return;
603
- const diagnostic = await readUltragoalVerificationState(input);
604
- if (["inactive", "unrelated_goal", "active_verified_complete"].includes(diagnostic.state)) return;
723
+ const diagnostic = await verifyUltragoalDurableCompletionState(input);
724
+ if (["inactive", "active_verified_complete"].includes(diagnostic.state)) return;
605
725
  const nudge = await consumeUltragoalNudge({
606
726
  cwd: input.cwd,
607
727
  surface: "premature_complete",
@@ -610,7 +730,7 @@ export async function assertCanCompleteCurrentGoal(input: {
610
730
  });
611
731
  if (nudge.nudged) throw new Error(nudge.message);
612
732
  throw new Error(
613
- `${diagnostic.message} Run strict \`gjc ultragoal checkpoint --status complete --quality-gate-json <file> --gjc-goal-json <file>\` first, or record review blockers and rerun verification.`,
733
+ `${diagnostic.message} Run \`gjc ultragoal checkpoint --status complete --quality-gate-json <file>\` first, or record review blockers and rerun verification.`,
614
734
  );
615
735
  }
616
736