@andorra-labs/code 0.1.4 → 0.1.6

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 (171) hide show
  1. package/dist/src/account-presentation.js +3 -3
  2. package/dist/src/agent-execution.d.ts +2 -0
  3. package/dist/src/agent-execution.js +126 -20
  4. package/dist/src/agent-mcp.d.ts +18 -1
  5. package/dist/src/agent-mcp.js +103 -8
  6. package/dist/src/app-server/protocol.d.ts +33 -3
  7. package/dist/src/app-server/protocol.js +14 -1
  8. package/dist/src/app-server/workspace.d.ts +1 -0
  9. package/dist/src/app-server/workspace.js +7 -1
  10. package/dist/src/app-server.d.ts +115 -41
  11. package/dist/src/app-server.js +1229 -219
  12. package/dist/src/automation-runner.d.ts +9 -0
  13. package/dist/src/automation-runner.js +22 -1
  14. package/dist/src/automation-tool.js +8 -1
  15. package/dist/src/automations.js +1 -1
  16. package/dist/src/browser-captcha-tool.d.ts +54 -0
  17. package/dist/src/browser-captcha-tool.js +374 -0
  18. package/dist/src/browser-panel-tool.d.ts +7 -0
  19. package/dist/src/browser-panel-tool.js +74 -3
  20. package/dist/src/browser-runner.js +19 -4
  21. package/dist/src/browser-server.js +21 -1
  22. package/dist/src/browser-session.d.ts +16 -0
  23. package/dist/src/browser-session.js +35 -0
  24. package/dist/src/browser-ui/app.js +193 -3
  25. package/dist/src/browser-ui/style.css +15 -1
  26. package/dist/src/browser-view.d.ts +72 -4
  27. package/dist/src/browser-view.js +229 -17
  28. package/dist/src/capabilities.js +13 -2
  29. package/dist/src/capsolver.d.ts +60 -0
  30. package/dist/src/capsolver.js +101 -0
  31. package/dist/src/claude-provider.d.ts +6 -0
  32. package/dist/src/claude-provider.js +34 -3
  33. package/dist/src/cli-executable.d.ts +33 -0
  34. package/dist/src/cli-executable.js +64 -0
  35. package/dist/src/cli-process.d.ts +47 -0
  36. package/dist/src/cli-process.js +113 -0
  37. package/dist/src/cli-sign-in.d.ts +68 -0
  38. package/dist/src/cli-sign-in.js +224 -0
  39. package/dist/src/cli.js +54 -23
  40. package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +1 -1
  41. package/dist/src/code-intelligence/CodeIntelligenceManager.js +5 -5
  42. package/dist/src/coding-tools.js +44 -5
  43. package/dist/src/command-output-tap.d.ts +16 -0
  44. package/dist/src/command-output-tap.js +45 -0
  45. package/dist/src/command-screens.js +3 -3
  46. package/dist/src/commands.d.ts +10 -1
  47. package/dist/src/commands.js +7 -7
  48. package/dist/src/completion.d.ts +23 -5
  49. package/dist/src/completion.js +334 -17
  50. package/dist/src/config.d.ts +13 -0
  51. package/dist/src/config.js +28 -2
  52. package/dist/src/deadline.js +6 -0
  53. package/dist/src/extensions.d.ts +1 -0
  54. package/dist/src/extensions.js +16 -3
  55. package/dist/src/graph-provider-portability.js +2 -2
  56. package/dist/src/graph-quota.d.ts +1 -1
  57. package/dist/src/graph-quota.js +1 -1
  58. package/dist/src/graph-runner.js +35 -21
  59. package/dist/src/graph-selection.d.ts +6 -0
  60. package/dist/src/graph-selection.js +10 -0
  61. package/dist/src/graph-server.d.ts +7 -0
  62. package/dist/src/graph-server.js +61 -3
  63. package/dist/src/graph-sync.d.ts +50 -0
  64. package/dist/src/graph-sync.js +383 -12
  65. package/dist/src/graph-ui/app.js +61 -8
  66. package/dist/src/graph-ui/icons.js +1 -0
  67. package/dist/src/graph-ui/index.html +1 -1
  68. package/dist/src/graph-ui/skill-picker.js +242 -0
  69. package/dist/src/graph-ui/style.css +19 -0
  70. package/dist/src/graphs.d.ts +46 -4
  71. package/dist/src/graphs.js +152 -27
  72. package/dist/src/grok-provider.d.ts +50 -0
  73. package/dist/src/grok-provider.js +186 -0
  74. package/dist/src/handoffs.d.ts +13 -0
  75. package/dist/src/handoffs.js +31 -1
  76. package/dist/src/managed-sign-in.d.ts +38 -0
  77. package/dist/src/managed-sign-in.js +169 -0
  78. package/dist/src/markdown.d.ts +5 -0
  79. package/dist/src/markdown.js +5 -2
  80. package/dist/src/mcp.js +11 -0
  81. package/dist/src/membership.d.ts +8 -1
  82. package/dist/src/membership.js +15 -5
  83. package/dist/src/model-metadata.js +14 -2
  84. package/dist/src/model-override.d.ts +10 -0
  85. package/dist/src/model-override.js +20 -0
  86. package/dist/src/opencode-cli-provider.d.ts +122 -0
  87. package/dist/src/opencode-cli-provider.js +415 -0
  88. package/dist/src/opencode-provider.js +23 -8
  89. package/dist/src/palette.d.ts +2 -0
  90. package/dist/src/palette.js +2 -0
  91. package/dist/src/permissions.d.ts +19 -1
  92. package/dist/src/permissions.js +30 -1
  93. package/dist/src/powershell-pool.d.ts +2 -2
  94. package/dist/src/powershell-pool.js +18 -5
  95. package/dist/src/provider-connection.js +36 -0
  96. package/dist/src/provider-engine.d.ts +2 -1
  97. package/dist/src/provider-engine.js +64 -13
  98. package/dist/src/provider-import.js +6 -1
  99. package/dist/src/provider-settings.js +22 -3
  100. package/dist/src/providers.d.ts +12 -1
  101. package/dist/src/providers.js +27 -8
  102. package/dist/src/pull-requests.d.ts +111 -17
  103. package/dist/src/pull-requests.js +308 -76
  104. package/dist/src/qa/qa-authorize.js +9 -1
  105. package/dist/src/react-runtime.js +76 -5
  106. package/dist/src/remote/engine-pool.js +1 -1
  107. package/dist/src/run-progress.js +6 -1
  108. package/dist/src/run-records.d.ts +133 -27
  109. package/dist/src/run-records.js +320 -40
  110. package/dist/src/runtime.d.ts +38 -1
  111. package/dist/src/runtime.js +27 -4
  112. package/dist/src/save-lock.d.ts +11 -0
  113. package/dist/src/save-lock.js +29 -2
  114. package/dist/src/sessions.js +4 -1
  115. package/dist/src/shell.js +4 -1
  116. package/dist/src/side-panel.d.ts +1 -1
  117. package/dist/src/side-panel.js +1 -1
  118. package/dist/src/skill-commands.d.ts +2 -0
  119. package/dist/src/skill-commands.js +2 -0
  120. package/dist/src/skills/bundled/create-agent/SKILL.md +81 -0
  121. package/dist/src/skills/bundled/create-skill/SKILL.md +81 -0
  122. package/dist/src/skills/bundled/doctor/SKILL.md +43 -0
  123. package/dist/src/skills/bundled/graph-manager/SKILL.md +97 -0
  124. package/dist/src/skills/bundled/graph-manager/errors.md +38 -0
  125. package/dist/src/skills/bundled/graph-manager/patterns.md +78 -0
  126. package/dist/src/skills/bundled/manage-mcp/SKILL.md +75 -0
  127. package/dist/src/skills/bundled/manage-mcp/probe.md +165 -0
  128. package/dist/src/skills/bundled/manage-skills/SKILL.md +67 -0
  129. package/dist/src/skills/bundled/provenance.json +50 -0
  130. package/dist/src/skills/bundled/write-instructions/SKILL.md +42 -0
  131. package/dist/src/skills/invocable-skills.d.ts +41 -0
  132. package/dist/src/skills/invocable-skills.js +49 -0
  133. package/dist/src/skills/prompt-skills.d.ts +1 -0
  134. package/dist/src/skills/prompt-skills.js +33 -0
  135. package/dist/src/skills/runtime-skills.d.ts +4 -0
  136. package/dist/src/skills/runtime-skills.js +21 -0
  137. package/dist/src/structured-step.d.ts +55 -0
  138. package/dist/src/structured-step.js +85 -0
  139. package/dist/src/subagent-run.d.ts +1 -1
  140. package/dist/src/subagent-run.js +29 -33
  141. package/dist/src/telemetry/schema.d.ts +2 -2
  142. package/dist/src/telemetry/schema.js +3 -2
  143. package/dist/src/terminal-ui.d.ts +29 -0
  144. package/dist/src/terminal-ui.js +112 -28
  145. package/dist/src/timers.d.ts +21 -2
  146. package/dist/src/timers.js +12 -4
  147. package/dist/src/tool-names.d.ts +18 -0
  148. package/dist/src/tool-names.js +26 -0
  149. package/dist/src/tools.js +45 -11
  150. package/dist/src/trajectory.js +32 -12
  151. package/dist/src/types.d.ts +23 -0
  152. package/dist/src/update.d.ts +26 -16
  153. package/dist/src/update.js +232 -275
  154. package/docs/agents/install-for-agents.md +15 -24
  155. package/docs/agents/mcp-server.md +13 -1
  156. package/docs/agents/subagent-mode.md +7 -4
  157. package/docs/concepts/security.md +2 -0
  158. package/docs/getting-started/README.md +14 -6
  159. package/docs/getting-started/configure-providers.md +29 -2
  160. package/docs/guides/README.md +1 -1
  161. package/docs/guides/browser.md +12 -0
  162. package/docs/guides/desktop-app.md +45 -9
  163. package/docs/guides/graph-builder.md +8 -0
  164. package/docs/guides/update.md +37 -16
  165. package/docs/reference/cli.md +1 -1
  166. package/docs/reference/config.md +2 -2
  167. package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +125 -0
  168. package/docs/superpowers/specs/2026-11-01-pr-section-design.md +7 -0
  169. package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +206 -0
  170. package/package.json +1 -1
  171. package/tests/permissions-test-plan.md +2 -1
@@ -0,0 +1,85 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { isDeepStrictEqual } from 'node:util';
3
+ /**
4
+ * The structured step a vendor CLI returns in place of native tool calls.
5
+ *
6
+ * The CLI providers ask their model for exactly this object, so Andorra keeps tool execution,
7
+ * permissions and graph state: the vendor only ever sees tool names and JSON arguments as data.
8
+ */
9
+ export const STRUCTURED_STEP_SCHEMA = {
10
+ type: 'object', additionalProperties: false, required: ['text', 'toolCalls'],
11
+ properties: {
12
+ text: { type: 'string' },
13
+ toolCalls: { type: 'array', items: {
14
+ type: 'object', additionalProperties: false, required: ['name', 'arguments'],
15
+ properties: { name: { type: 'string' }, arguments: { type: 'string' } },
16
+ } },
17
+ },
18
+ };
19
+ export const STRUCTURED_STEP_PROMPT = 'You are the model component of Andorra Code. The supplied conversation is the complete context. Return one structured response with text and toolCalls. To request an Andorra tool, return its name and JSON-encoded arguments in toolCalls. Andorra authorizes and executes tools and supplies observations in the next conversation. Do not use built-in tools. Otherwise return text and an empty toolCalls array.';
20
+ export const TEXT_STEP_PROMPT = 'You are the text-only model component of Andorra Code. The supplied conversation is the complete context. Follow its instructions and return only the requested text. Do not call tools.';
21
+ /** The instruction that states a bounded text step's output allowance to the model. */
22
+ export function allowanceInstruction(maxTokens) {
23
+ return `Keep the answer within ${maxTokens} tokens.`;
24
+ }
25
+ /**
26
+ * Hold a text step to its output allowance.
27
+ *
28
+ * The vendor CLIs have no output cap a caller can set, so the allowance is stated to the model and
29
+ * then enforced on what comes back: an answer whose measured visible output — or, unmeasured, its
30
+ * length at about four characters a token — exceeds the allowance is cut to fit and reported as
31
+ * `length`, which is how callers such as context compaction learn to shrink their request.
32
+ */
33
+ export function boundTextStep(response, maxTokens, visibleOutputTokens) {
34
+ const measured = visibleOutputTokens !== undefined && visibleOutputTokens > 0 ? visibleOutputTokens : undefined;
35
+ const over = measured !== undefined ? measured > maxTokens : response.text.length > maxTokens * 4;
36
+ if (!over)
37
+ return response;
38
+ const keep = measured !== undefined ? Math.floor(response.text.length * maxTokens / measured) : maxTokens * 4;
39
+ return { ...response, text: response.text.slice(0, keep), stopReason: 'length' };
40
+ }
41
+ /** The conversation as one JSON document; images travel separately where the vendor accepts them. */
42
+ export function structuredStepPrompt(request) {
43
+ return JSON.stringify({
44
+ conversation: request.messages.map(({ images, providerContinuation, reasoningContent, ...message }) => ({ ...message, ...(images?.length ? { imageCount: images.length } : {}) })),
45
+ availableTools: request.tools,
46
+ });
47
+ }
48
+ function argumentObject(value, vendor) {
49
+ if (!value || typeof value !== 'object' || Array.isArray(value))
50
+ throw new Error(`${vendor} returned invalid Andorra tool arguments`);
51
+ return value;
52
+ }
53
+ function sameCalls(first, second) {
54
+ return isDeepStrictEqual(first.map(call => ({ name: call.name, arguments: JSON.parse(call.arguments) })), second.map(call => ({ name: call.name, arguments: JSON.parse(call.arguments) })));
55
+ }
56
+ /**
57
+ * Validate one structured step against the tool manifest the request offered.
58
+ *
59
+ * A call outside the manifest, malformed arguments, or a repeated call is refused rather than
60
+ * repaired: Andorra would otherwise run something the model did not cleanly ask for.
61
+ */
62
+ export function parseStructuredStep(value, tools, vendor) {
63
+ const step = value;
64
+ if (!step || typeof step !== 'object' || Array.isArray(step) || typeof step.text !== 'string' || !Array.isArray(step.toolCalls) || step.toolCalls.length > 100
65
+ || Object.keys(step).some(key => key !== 'text' && key !== 'toolCalls'))
66
+ throw new Error(`${vendor} returned an invalid Andorra response`);
67
+ const names = new Set(tools.map(tool => tool.name));
68
+ const calls = step.toolCalls.map((call) => {
69
+ if (!call || typeof call.name !== 'string' || !call.name.trim() || typeof call.arguments !== 'string')
70
+ throw new Error(`${vendor} returned a malformed Andorra tool call`);
71
+ if (!names.has(call.name))
72
+ throw new Error(`${vendor} requested a tool outside the Andorra manifest`);
73
+ try {
74
+ argumentObject(JSON.parse(call.arguments), vendor);
75
+ }
76
+ catch {
77
+ throw new Error(`${vendor} returned invalid Andorra tool arguments`);
78
+ }
79
+ return { id: randomUUID(), name: call.name, arguments: call.arguments };
80
+ });
81
+ if (calls.some((call, index) => calls.slice(0, index).some(previous => sameCalls([previous], [call])))) {
82
+ throw new Error(`${vendor} returned duplicate Andorra tool calls`);
83
+ }
84
+ return { text: step.text, toolCalls: calls };
85
+ }
@@ -10,7 +10,7 @@ import type { ModelAdapter } from './types.js';
10
10
  *
11
11
  * The restriction is structural — the id is a constant here, never a parameter on any surface —
12
12
  * and the id is `default`, which `loadAccessibleGraph` resolves to the bundled single-agent
13
- * Software Engineer harness: no Orchestrator intake, no per-node provider pins, no account
13
+ * Andorra Agent harness: no Orchestrator intake, no per-node provider pins, no account
14
14
  * membership. That is what makes a one-shot external run headless-safe and lets the caller's
15
15
  * provider/model choice reach every request the run makes.
16
16
  */
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { homedir } from 'node:os';
3
3
  import { realpath, stat } from 'node:fs/promises';
4
- import { appendFile, writeFile } from 'node:fs/promises';
4
+ import { writeFile } from 'node:fs/promises';
5
5
  import { configDirectory, loadConfig, resolveCodeIntelConfig, resolveConfiguredLimits, resolveMemoryConfig } from './config.js';
6
6
  import { createRunHandle, drainTelemetry, reportRunFinished, reportRunStarted } from './telemetry/surface.js';
7
7
  import { configuredContextWindow, createAdapter, providerModels } from './providers.js';
@@ -23,14 +23,14 @@ import { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceMan
23
23
  import { DecisionManager } from './decision/DecisionManager.js';
24
24
  import { permissionMode } from './permissions.js';
25
25
  import { TodoStore } from './todos.js';
26
- import { claimProcessWorkspace, clearOpenRunClaim, noteCheckpointWriteFailure, noteJournalWriteFailure, releaseProcessWorkspace, removeOpenRunRecord, removeRunCheckpoint, repairSessionMarkers, RUNNING_TURN_SUMMARY, runRecordPath, summaryForStoppedRecord, writeOpenRunRecord, writeRunCheckpoint, writeStudioRunSummary } from './run-records.js';
26
+ import { claimProcessWorkspace, clearOpenRunClaim, createCheckpointFailureTracker, createRunJournalWriter, releaseProcessWorkspace, removeOpenRunRecord, removeRunCheckpoint, repairSessionMarkers, RUNNING_TURN_SUMMARY, runRecordPath, summaryForStoppedRecord, writeOpenRunRecord, writeRunCheckpoint, writeStudioRunSummary } from './run-records.js';
27
27
  import { SessionStore, projectIdentity, sessionName } from './sessions.js';
28
28
  /**
29
29
  * External subagent mode: the only graph an external host (Claude CLI, Codex CLI) may run.
30
30
  *
31
31
  * The restriction is structural — the id is a constant here, never a parameter on any surface —
32
32
  * and the id is `default`, which `loadAccessibleGraph` resolves to the bundled single-agent
33
- * Software Engineer harness: no Orchestrator intake, no per-node provider pins, no account
33
+ * Andorra Agent harness: no Orchestrator intake, no per-node provider pins, no account
34
34
  * membership. That is what makes a one-shot external run headless-safe and lets the caller's
35
35
  * provider/model choice reach every request the run makes.
36
36
  */
@@ -193,14 +193,14 @@ const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
193
193
  /**
194
194
  * The health failure a subagent caller is given.
195
195
  *
196
- * A subagent always runs the built-in Software Engineer graph, whose node has no editable model
196
+ * A subagent always runs the built-in Andorra Agent graph, whose node has no editable model
197
197
  * selection, so the ordinary remedy — edit the graph's model selections — cannot be followed. The
198
198
  * caller has to pick another provider and model, or repair that provider's credentials.
199
199
  */
200
200
  function subagentHealthFailure(health) {
201
201
  return ['The provider/model this subagent run would use is not usable:',
202
202
  ...health.failures.map(failure => `- ${failure.provider}/${failure.model}: ${failure.reason}`),
203
- 'A subagent run always uses the built-in Software Engineer graph, whose model is the one you picked, so there is no graph to edit: retry with another provider and model, or repair that provider credentials.',
203
+ 'A subagent run always uses the built-in Andorra Agent graph, whose model is the one you picked, so there is no graph to edit: retry with another provider and model, or repair that provider credentials.',
204
204
  ].join('\n');
205
205
  }
206
206
  /**
@@ -316,12 +316,14 @@ export class SubagentRunner {
316
316
  // ask the gate for the account that owns this run, or a shared installation answers with
317
317
  // whichever account most recently confirmed a plan.
318
318
  const accountSubject = await currentGraphSubject().catch(() => undefined);
319
+ const runId = randomUUID();
319
320
  const run = {
320
- runId: randomUUID(), sessionId: randomUUID(), task: options.task, workspace, directory, telemetryRunId,
321
+ runId, sessionId: randomUUID(), task: options.task, workspace, directory, telemetryRunId,
321
322
  ...(accountSubject === undefined ? {} : { accountSubject }),
322
323
  jevEnabled: config.jevEnabled !== false, decisionRouting: config.decisions?.mode ?? 'off',
323
324
  providerId: provider.id, model, permissions, controller: new AbortController(), startedAt: new Date().toISOString(),
324
325
  events: [], notices: [], journal: Promise.resolve(), finished: Promise.resolve(),
326
+ journalWriter: createRunJournalWriter(directory, runId), checkpoints: createCheckpointFailureTracker(directory, runId),
325
327
  probeUsage: { requests: 0, inputTokens: 0, outputTokens: 0 }, probeModels: new Map(),
326
328
  providerType: provider.type, baseUrl: provider.baseUrl,
327
329
  };
@@ -508,18 +510,11 @@ export class SubagentRunner {
508
510
  if (event.type === 'graph.node.started' && typeof data.nodeId === 'string')
509
511
  run.currentNode = data.nodeId;
510
512
  // The journal keeps the order the events happened in, and the runtime awaits the callback for
511
- // exactly that reason: the writes are chained rather than launched side by side, because the
512
- // filesystem does not finish them in the order they were started.
513
- run.journal = run.journal
514
- .then(() => appendFile(runRecordPath(run.directory, run.runId, 'jsonl'), JSON.stringify(event) + '\n', { mode: 0o600 }))
515
- .catch(async (error) => {
516
- // The run keeps going — a storage hiccup must not kill the work — but the journal is no
517
- // longer a complete account: the events after this failure are written, so nothing in the
518
- // file itself reveals the hole. Left unmarked, a crashed attempt would replay to a
519
- // position missing whatever this append ate, and a resume would repeat that work.
520
- run.journalFailed = true;
521
- await noteJournalWriteFailure(run.directory, run.runId, error instanceof Error ? error.message : String(error)).catch(() => { });
522
- });
513
+ // exactly that reason: the writer chains its appends rather than launching them side by side,
514
+ // because the filesystem does not finish them in the order they were started. The run keeps
515
+ // going when an append fails (a storage hiccup must not kill the work): the writer holds the
516
+ // event and writes it once the file accepts appends again.
517
+ run.journal = run.journalWriter.append(event);
523
518
  return run.journal;
524
519
  }
525
520
  /**
@@ -631,15 +626,11 @@ export class SubagentRunner {
631
626
  ...(meta?.provider === undefined ? {} : { provider: meta.provider }),
632
627
  ...(meta?.model === undefined ? {} : { model: meta.model }),
633
628
  }))
634
- .catch(async (error) => {
635
629
  // The run keeps going — durability is a convenience, never the run's outcome. But a
636
- // checkpoint that could not be written is the conversation a resume re-enters the
637
- // node with: without it the resume re-enters from the node's opening task and repeats
638
- // the tool calls that already ran. The attempt is therefore marked, and a resume of it
639
- // is refused rather than repeating the work.
640
- run.checkpointFailed = true;
641
- await noteCheckpointWriteFailure(run.directory, run.runId, error instanceof Error ? error.message : String(error)).catch(() => { });
642
- });
630
+ // checkpoint that could not be written is the conversation a resume re-enters the node
631
+ // with, so the node stays marked until one of its later writes lands; a resume of an
632
+ // attempt that stopped while it was marked warns that the node may repeat work.
633
+ .then(() => run.checkpoints.succeeded({ nodeId, generation: meta?.generation }), error => run.checkpoints.failed({ nodeId, generation: meta?.generation }, error));
643
634
  // The write is handed back so the runtime can await it: the checkpoint is the conversation
644
635
  // a resume re-enters the node with, and a run that advanced past a mutating tool call
645
636
  // while its checkpoint was still queued could be killed with that conversation unwritten.
@@ -687,7 +678,7 @@ export class SubagentRunner {
687
678
  decisionManager: new DecisionManager({ config: await subagentDecisionConfig(config, () => (options.membership ?? getMembership)(signal)), onEvent: event => this.observe(run, event) }),
688
679
  decisionNodeOptIn: true,
689
680
  // The code intelligence of the installation this run works in, so the run has the same
690
- // repository coverage an ordinary Software Engineer run has.
681
+ // repository coverage an ordinary Andorra Agent run has.
691
682
  ...(codeIntel ? { codeIntel } : {}),
692
683
  // The checkpoints a resume reads: without them a replay re-enters the node from its
693
684
  // opening task and repeats the writes and shell calls that already ran.
@@ -769,15 +760,20 @@ export class SubagentRunner {
769
760
  // The journal is drained before the record that says the run finished: a record that reports a
770
761
  // completed run while its last events are still being written is a record whose journal tail
771
762
  // may never land.
763
+ // Settling also retries whatever the file refused earlier, so space freed since then lets the
764
+ // journal finish whole.
772
765
  await run.journal.catch(() => { });
773
- // The record carries the flag the resume consults when the marker file could not be written:
774
- // an attempt whose journal has a hole is never a resume source.
775
- if (run.journalFailed)
766
+ const journalIntact = await run.journalWriter.settle();
767
+ // The record carries the flag the resume reads when the marker file could not be written: a
768
+ // resume of an attempt whose journal has a hole warns that a step may repeat.
769
+ if (!journalIntact)
776
770
  record.journalIntegrity = 'failed';
777
- // The same flag for a checkpoint that could not be written: a resume would re-enter the node
778
- // from its opening task and repeat the tool calls it had already made.
779
- if (run.checkpointFailed)
771
+ // The same flag for a node whose newest checkpoint could not be written: a resume re-enters
772
+ // that node from an older conversation, and warns that it may repeat work.
773
+ if (!run.checkpoints.intact) {
780
774
  record.checkpointIntegrity = 'failed';
775
+ record.checkpointFailures = run.checkpoints.failures;
776
+ }
781
777
  // The terminal record is written before the session is finalized. A crash between the two
782
778
  // leaves a session whose turn is still marked running, which the startup recovery repairs
783
779
  // from the record; the other order would leave a session that reports the completion while
@@ -27,7 +27,7 @@ export type TelemetryTaskCategory = typeof TELEMETRY_TASK_CATEGORIES[number];
27
27
  export declare const TELEMETRY_WORKSPACE_BUCKETS: readonly ["0", "1-9", "10-99", "100-999", "1000-9999", "10000+"];
28
28
  export type TelemetryWorkspaceBucket = typeof TELEMETRY_WORKSPACE_BUCKETS[number];
29
29
  /** The permission values ordinary runs persist, in the order `PERMISSION_MODES` lists them. */
30
- export declare const TELEMETRY_PERMISSION_MODES: readonly ["read-only", "ask-for-approval", "approve-for-me", "full-access"];
30
+ export declare const TELEMETRY_PERMISSION_MODES: readonly ["read-only", "plan", "ask-for-approval", "approve-for-me", "full-access"];
31
31
  export declare const TELEMETRY_OPERATING_SYSTEMS: readonly ["darwin", "win32", "linux", "freebsd", "openbsd", "sunos", "aix", "android", "other"];
32
32
  export declare const TELEMETRY_ARCHITECTURES: readonly ["x64", "arm64", "arm", "ia32", "ppc64", "s390x", "riscv64", "loong64", "mips", "mipsel", "ppc", "s390", "other"];
33
33
  export declare const TELEMETRY_LANGUAGES: readonly ["typescript", "javascript", "python", "go", "rust", "java", "kotlin", "swift", "csharp", "cpp", "c", "ruby", "php", "scala", "elixir", "dart", "shell", "sql", "html", "css", "other"];
@@ -35,7 +35,7 @@ export type TelemetryLanguage = typeof TELEMETRY_LANGUAGES[number];
35
35
  export declare const TELEMETRY_FRAMEWORKS: readonly ["react", "vue", "angular", "svelte", "nextjs", "nestjs", "express", "fastapi", "django", "flask", "spring", "rails", "laravel", "dotnet", "actix", "axum", "gin", "flutter", "electron", "tauri", "other"];
36
36
  export type TelemetryFramework = typeof TELEMETRY_FRAMEWORKS[number];
37
37
  /** Product-owned tool names, plus the three buckets user- or server-named tools collapse into. */
38
- export declare const TELEMETRY_TOOL_NAMES: readonly ["Read", "Write", "Edit", "Glob", "Grep", "Bash", "PowerShell", "git_read", "read_artifact", "write_artifact", "repo_explore", "memory_search", "set_timer", "pull_request", "read_skill_resource", "ask_user", "spawn_subagent", "qa.browser", "qa.browser_session", "qa.deep", "qa.fast", "qa.inspect_project", "qa.security", "qa.status", "qa.terminal", "qa.test", "browser.panel", "mcp", "plugin", "other"];
38
+ export declare const TELEMETRY_TOOL_NAMES: readonly ["Read", "Write", "Edit", "Glob", "Grep", "Bash", "PowerShell", "git_read", "read_artifact", "write_artifact", "repo_explore", "memory_search", "set_timer", "pull_request", "read_skill_resource", "ask_user", "spawn_subagent", "qa.browser", "qa.browser_session", "qa.deep", "qa.fast", "qa.inspect_project", "qa.security", "qa.status", "qa.terminal", "qa.test", "browser.panel", "browser.incognito", "browser.solve_captcha", "mcp", "plugin", "other"];
39
39
  export type TelemetryToolName = typeof TELEMETRY_TOOL_NAMES[number];
40
40
  /**
41
41
  * Public model ids a run may name. Provider configuration accepts a user-supplied string of up to
@@ -35,7 +35,7 @@ export const TELEMETRY_ROUTING = ['off', 'shadow', 'active'];
35
35
  export const TELEMETRY_TASK_CATEGORIES = ['implement', 'fix', 'test', 'docs', 'investigate'];
36
36
  export const TELEMETRY_WORKSPACE_BUCKETS = ['0', '1-9', '10-99', '100-999', '1000-9999', '10000+'];
37
37
  /** The permission values ordinary runs persist, in the order `PERMISSION_MODES` lists them. */
38
- export const TELEMETRY_PERMISSION_MODES = ['read-only', 'ask-for-approval', 'approve-for-me', 'full-access'];
38
+ export const TELEMETRY_PERMISSION_MODES = ['read-only', 'plan', 'ask-for-approval', 'approve-for-me', 'full-access'];
39
39
  export const TELEMETRY_OPERATING_SYSTEMS = ['darwin', 'win32', 'linux', 'freebsd', 'openbsd', 'sunos', 'aix', 'android', 'other'];
40
40
  export const TELEMETRY_ARCHITECTURES = ['x64', 'arm64', 'arm', 'ia32', 'ppc64', 's390x', 'riscv64', 'loong64', 'mips', 'mipsel', 'ppc', 's390', 'other'];
41
41
  export const TELEMETRY_LANGUAGES = ['typescript', 'javascript', 'python', 'go', 'rust', 'java', 'kotlin', 'swift', 'csharp', 'cpp', 'c', 'ruby', 'php', 'scala', 'elixir', 'dart', 'shell', 'sql', 'html', 'css', 'other'];
@@ -50,7 +50,8 @@ export const TELEMETRY_TOOL_NAMES = [
50
50
  // rides the same browser capability and stays attributable the same way.
51
51
  'qa.browser', 'qa.browser_session', 'qa.deep', 'qa.fast', 'qa.inspect_project', 'qa.security',
52
52
  'qa.status', 'qa.terminal', 'qa.test',
53
- 'browser.panel',
53
+ 'browser.panel', 'browser.incognito',
54
+ 'browser.solve_captcha',
54
55
  'mcp', 'plugin', 'other',
55
56
  ];
56
57
  /**
@@ -355,6 +355,10 @@ export declare class TerminalUI extends EventEmitter {
355
355
  * drained at turn boundaries.
356
356
  */
357
357
  private attachments;
358
+ /** The skills the `/` popup offers after the built-in commands, with the description it shows. */
359
+ private skillCommands;
360
+ /** The command the skill chip in the draft stands for, while one is there. */
361
+ private skillChip?;
358
362
  private attachmentSeq;
359
363
  /**
360
364
  * Generation of the composer's attachment surface. Advanced by every draft clear and steer
@@ -623,6 +627,25 @@ export declare class TerminalUI extends EventEmitter {
623
627
  * to the draft once that composer is armed again.
624
628
  */
625
629
  addAttachment(pending: PendingAttachment): boolean;
630
+ /** The skills the `/` popup lists after the built-in commands; a skill whose command a built-in owns is left out. */
631
+ setSkillCommands(skills: readonly {
632
+ command: string;
633
+ description: string;
634
+ }[]): void;
635
+ private skillCommand;
636
+ /** Replace the draft's leading `command` (and anything typed after it) with the skill chip and a space. */
637
+ private insertSkillChip;
638
+ /**
639
+ * Turn a leading, fully typed skill command into the chip once a space follows it, so a command
640
+ * typed out in full reads the same as one picked from the popup.
641
+ */
642
+ private chipTypedSkill;
643
+ /**
644
+ * Backspace and Delete. Beside the skill chip they remove the chip and the space that follows it in
645
+ * one keystroke, so a picked skill comes out as it went in.
646
+ */
647
+ private backspace;
648
+ private deleteForward;
626
649
  /** Take every queued attachment in draft order, without blocking — the CLI drains this when a task is submitted. */
627
650
  takeAttachments(): PendingAttachment[];
628
651
  /** The amber label a token draws as in the composer. */
@@ -636,6 +659,12 @@ export declare class TerminalUI extends EventEmitter {
636
659
  * command submits without them, so the command runs and the attachments stay queued.
637
660
  */
638
661
  private submittedDraft;
662
+ /**
663
+ * The draft as it is parked (history browsing, a question interrupting steering): the skill chip is
664
+ * written out as its command, so `restoredDraft` can turn it back into a chip — the token alone would
665
+ * not survive the trip, and the draft would lose the skill it names.
666
+ */
667
+ private parkedDraft;
639
668
  /** A parked draft brought back into the composer, keeping only tokens whose attachment is still queued. */
640
669
  private restoredDraft;
641
670
  /** Remove draft elements, dropping the attachment behind every token they held. */
@@ -10,7 +10,7 @@ import { transcriptColor } from './transcript.js';
10
10
  import { ToolCallClock, toolHeaderRows } from './tool-call-clock.js';
11
11
  import { formatDuration } from './duration.js';
12
12
  import { PagedTranscript } from './paged-transcript.js';
13
- import { accentSgr, ATTACHMENT_TOKEN, DIM, FAINT, GRAY, STATUS, SUBTLE, WHITE } from './palette.js';
13
+ import { accentSgr, ATTACHMENT_TOKEN, DIM, FAINT, GRAY, SKILL_CHIP, STATUS, SUBTLE, WHITE } from './palette.js';
14
14
  import { isCustomGraph, panelRowText, panelWidth, PANEL_MIN_COLUMNS, PANEL_MIN_ROWS, sidePanelRows } from './side-panel.js';
15
15
  import { TokenRateMeter } from './token-rate.js';
16
16
  import { attachmentLabel, droppedPaths, formatBytes, isLargePaste, MAX_ATTACHMENTS } from './attachments.js';
@@ -23,6 +23,12 @@ const graphemes = (text) => [...segmenter.segment(text)].map(part => part.segmen
23
23
  */
24
24
  const TOKEN_BASE = 0x100000;
25
25
  const isToken = (part) => (part.codePointAt(0) ?? 0) >= TOKEN_BASE;
26
+ /**
27
+ * The skill chip: the leading `/name` of a picked skill, held as one code point so Backspace, Delete,
28
+ * the arrows and selections treat it as a unit. It sits at the top of the private-use plane, above
29
+ * every attachment marker, and like them it cannot be typed or pasted (`clean` strips the plane).
30
+ */
31
+ const SKILL_TOKEN = String.fromCodePoint(0x10FFFD);
26
32
  /** Graphemes of a draft, keeping each token its own element even when a combining mark follows it. */
27
33
  const composerGraphemes = (text) => graphemes(text).flatMap(part => isToken(part) && part.length > 2 ? [part.slice(0, 2), part.slice(2)] : [part]);
28
34
  const clean = (text) => stripVTControlCharacters(text).replace(/\r\n?/g, '\n').replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/g, '').replace(/[\u{100000}-\u{10FFFF}]/gu, '').replace(/\t/g, ' ');
@@ -47,9 +53,9 @@ const argumentCompletions = {
47
53
  * waits for the argument instead of running it; `/logout` is complete on its own.
48
54
  */
49
55
  const argumentRequired = new Set(['/jev', '/feedback', '/yolo', '/reasoning', '/codegraph', '/attach']);
50
- const completionOptions = (query) => {
56
+ const completionOptions = (query, skills = []) => {
51
57
  const command = /^(\/\S+)\s/.exec(query)?.[1];
52
- return (command === undefined ? commands : argumentCompletions[command] ?? []).filter(option => option.startsWith(query));
58
+ return (command === undefined ? [...commands, ...skills] : argumentCompletions[command] ?? []).filter(option => option.startsWith(query));
53
59
  };
54
60
  /**
55
61
  * Whether the composer text is a command name, or a command with arguments, that the popup completes.
@@ -227,11 +233,11 @@ function composerRow(text, color, selection, tokens) {
227
233
  let painted = '', run = '', style = '';
228
234
  let column = 0;
229
235
  const flush = () => { if (run)
230
- painted += paint(style[1] === 'r' ? `\x1b[7m${run}` : run, style[0] === 't' ? ATTACHMENT_TOKEN : color); run = ''; };
236
+ painted += paint(style[1] === 'r' ? `\x1b[7m${run}` : run, style[0] === 't' ? ATTACHMENT_TOKEN : style[0] === 's' ? `1;38;5;${SKILL_CHIP}` : color); run = ''; };
231
237
  for (const part of graphemes(text)) {
232
- const token = tokens.some(([start, end]) => column >= start && column < end);
238
+ const token = tokens.find(([start, end]) => column >= start && column < end);
233
239
  const selected = !!selection && column >= selection[0] && column < selection[1];
234
- const next = `${token ? 't' : 'p'}${selected ? 'r' : '-'}`;
240
+ const next = `${token ? token[2] === 'skill' ? 's' : 't' : 'p'}${selected ? 'r' : '-'}`;
235
241
  if (next !== style) {
236
242
  flush();
237
243
  style = next;
@@ -246,7 +252,7 @@ function composerRow(text, color, selection, tokens) {
246
252
  function tokenColumns(draft, visible, positions, row) {
247
253
  const spans = [];
248
254
  draft.forEach((part, index) => { const position = positions[index]; if (isToken(part) && position?.row === row)
249
- spans.push([position.column, position.column + stringWidth(visible[index])]); });
255
+ spans.push([position.column, position.column + stringWidth(visible[index]), part === SKILL_TOKEN ? 'skill' : 'attachment']); });
250
256
  return spans;
251
257
  }
252
258
  /** Whitespace as one editor element; a token label is a single element that contains spaces. */
@@ -875,6 +881,10 @@ export class TerminalUI extends EventEmitter {
875
881
  * drained at turn boundaries.
876
882
  */
877
883
  attachments = [];
884
+ /** The skills the `/` popup offers after the built-in commands, with the description it shows. */
885
+ skillCommands = [];
886
+ /** The command the skill chip in the draft stands for, while one is there. */
887
+ skillChip;
878
888
  attachmentSeq = 0;
879
889
  /**
880
890
  * Generation of the composer's attachment surface. Advanced by every draft clear and steer
@@ -964,7 +974,7 @@ export class TerminalUI extends EventEmitter {
964
974
  // A question (approval or clarification) can interrupt a run while a steer is half typed.
965
975
  // Park it, so taking the composer for the question does not silently discard the draft.
966
976
  if (this.steering && this.value.length) {
967
- this.steerDraft = this.value.join('');
977
+ this.steerDraft = this.parkedDraft();
968
978
  this.steerCursor = this.cursor;
969
979
  }
970
980
  this.value = [];
@@ -1816,7 +1826,7 @@ export class TerminalUI extends EventEmitter {
1816
1826
  insert(text) { if ((this.pending?.choices && !this.commandInput && !(this.runInputHandler && text.startsWith('/'))) || (!this.pending && !this.steering) || this.modal || !text)
1817
1827
  return; if (this.pending?.choices && text.startsWith('/'))
1818
1828
  this.commandInput = true; const selected = this.selectionRange(); if (selected)
1819
- this.deleteSelection(selected); const before = this.value.slice(0, this.cursor).join(''), after = this.value.slice(this.cursor).join(''); const insertion = clean(text).slice(0, Math.max(0, MAX_INPUT - before.length - after.length)); this.value = composerGraphemes(before + insertion + after); this.cursor = composerGraphemes(before + insertion).length; this.completion = undefined; this.dismissedCompletion = undefined; this.scroll = 0; this.scheduleRender(); }
1829
+ this.deleteSelection(selected); const before = this.value.slice(0, this.cursor).join(''), after = this.value.slice(this.cursor).join(''); const insertion = clean(text).slice(0, Math.max(0, MAX_INPUT - before.length - after.length)); this.value = composerGraphemes(before + insertion + after); this.cursor = composerGraphemes(before + insertion).length; this.chipTypedSkill(); this.completion = undefined; this.dismissedCompletion = undefined; this.scroll = 0; this.scheduleRender(); }
1820
1830
  /** Whether the surface that owns the composer accepts task input — the only place attachments mean anything. */
1821
1831
  conversationComposer() {
1822
1832
  // Steering owns the conversation only while no question holds the composer: an approval or
@@ -1880,6 +1890,58 @@ export class TerminalUI extends EventEmitter {
1880
1890
  this.scheduleRender();
1881
1891
  return true;
1882
1892
  }
1893
+ /** The skills the `/` popup lists after the built-in commands; a skill whose command a built-in owns is left out. */
1894
+ setSkillCommands(skills) {
1895
+ this.skillCommands = skills.filter(skill => /^\/\S+$/.test(skill.command) && !commands.includes(skill.command)).map(skill => ({ command: skill.command, description: oneLine(skill.description) }));
1896
+ this.completion = undefined;
1897
+ this.scheduleRender();
1898
+ }
1899
+ skillCommand(command) { return this.skillCommands.some(skill => skill.command === command); }
1900
+ /** Replace the draft's leading `command` (and anything typed after it) with the skill chip and a space. */
1901
+ insertSkillChip(command, rest = ' ') {
1902
+ this.skillChip = command;
1903
+ this.value = [SKILL_TOKEN, ...composerGraphemes(rest.startsWith(' ') ? rest : ' ' + rest)];
1904
+ this.cursor = 2;
1905
+ this.completion = undefined;
1906
+ this.dismissedCompletion = undefined;
1907
+ this.selectionAnchor = undefined;
1908
+ }
1909
+ /**
1910
+ * Turn a leading, fully typed skill command into the chip once a space follows it, so a command
1911
+ * typed out in full reads the same as one picked from the popup.
1912
+ */
1913
+ chipTypedSkill() {
1914
+ if (this.value[0] === SKILL_TOKEN)
1915
+ return;
1916
+ const typed = this.value.join('');
1917
+ const match = /^(\/\S+) /.exec(typed);
1918
+ if (!match || !this.skillCommand(match[1]) || this.value.slice(0, match[1].length).some(isToken))
1919
+ return;
1920
+ const length = graphemes(match[1]).length;
1921
+ this.skillChip = match[1];
1922
+ this.value.splice(0, length, SKILL_TOKEN);
1923
+ this.cursor = Math.max(1, this.cursor - length + 1);
1924
+ }
1925
+ /**
1926
+ * Backspace and Delete. Beside the skill chip they remove the chip and the space that follows it in
1927
+ * one keystroke, so a picked skill comes out as it went in.
1928
+ */
1929
+ backspace() {
1930
+ if (this.cursor === 2 && this.value[0] === SKILL_TOKEN && this.value[1] === ' ') {
1931
+ this.removeDraft(0, 2);
1932
+ this.cursor = 0;
1933
+ return;
1934
+ }
1935
+ if (this.cursor)
1936
+ this.removeDraft(--this.cursor, 1);
1937
+ }
1938
+ deleteForward() {
1939
+ if (this.cursor === 0 && this.value[0] === SKILL_TOKEN) {
1940
+ this.removeDraft(0, this.value[1] === ' ' ? 2 : 1);
1941
+ return;
1942
+ }
1943
+ this.removeDraft(this.cursor, 1);
1944
+ }
1883
1945
  /** Take every queued attachment in draft order, without blocking — the CLI drains this when a task is submitted. */
1884
1946
  takeAttachments() { const queued = this.attachments.map(entry => entry.pending); this.attachments = []; this.scheduleRender(); return queued; }
1885
1947
  /** The amber label a token draws as in the composer. */
@@ -1899,6 +1961,8 @@ export class TerminalUI extends EventEmitter {
1899
1961
  if (this.pending?.secret)
1900
1962
  return this.value.map(() => '*');
1901
1963
  const labels = new Map(this.attachments.map(entry => [entry.marker, clip(this.tokenLabel(entry), Math.max(1, width))]));
1964
+ if (this.skillChip)
1965
+ labels.set(SKILL_TOKEN, clip(this.skillChip, Math.max(1, width)));
1902
1966
  return this.value.map(part => labels.get(part) ?? (isToken(part) ? '' : part));
1903
1967
  }
1904
1968
  /**
@@ -1910,22 +1974,36 @@ export class TerminalUI extends EventEmitter {
1910
1974
  submittedDraft() {
1911
1975
  const order = new Map(this.value.map((part, index) => [part, index]));
1912
1976
  this.attachments.sort((left, right) => (order.get(left.marker) ?? Infinity) - (order.get(right.marker) ?? Infinity));
1913
- const typed = this.value.filter(part => !isToken(part)).join('');
1977
+ const draft = this.value.map(part => part === SKILL_TOKEN ? this.skillChip ?? '' : part);
1978
+ const typed = draft.filter(part => !isToken(part)).join('');
1914
1979
  if (!typed.trim())
1915
1980
  return '';
1916
1981
  if (typed.trimStart().startsWith('/'))
1917
1982
  return typed.trimStart();
1918
1983
  const names = new Map(this.attachments.map(({ marker, pending }) => [marker, `[${pending.kind === 'file' ? pending.path : pending.name}]`]));
1919
- return this.value.map(part => isToken(part) ? names.get(part) ?? '' : part).join('');
1984
+ return draft.map(part => isToken(part) ? names.get(part) ?? '' : part).join('');
1920
1985
  }
1986
+ /**
1987
+ * The draft as it is parked (history browsing, a question interrupting steering): the skill chip is
1988
+ * written out as its command, so `restoredDraft` can turn it back into a chip — the token alone would
1989
+ * not survive the trip, and the draft would lose the skill it names.
1990
+ */
1991
+ parkedDraft() { return this.value.map(part => part === SKILL_TOKEN ? this.skillChip ?? '' : part).join(''); }
1921
1992
  /** A parked draft brought back into the composer, keeping only tokens whose attachment is still queued. */
1922
1993
  restoredDraft(text) {
1923
1994
  const live = new Set(this.attachments.map(entry => entry.marker));
1924
- return composerGraphemes(text).filter(part => !isToken(part) || live.has(part));
1995
+ const parts = composerGraphemes(text).filter(part => !isToken(part) || live.has(part));
1996
+ const match = /^(\/\S+)(?=\s|$)/.exec(parts.join(''));
1997
+ if (!match || !this.skillCommand(match[1]))
1998
+ return parts;
1999
+ this.skillChip = match[1];
2000
+ return [SKILL_TOKEN, ...parts.slice(graphemes(match[1]).length)];
1925
2001
  }
1926
2002
  /** Remove draft elements, dropping the attachment behind every token they held. */
1927
2003
  removeDraft(start, count) {
1928
2004
  const removed = new Set(this.value.splice(start, count).filter(isToken));
2005
+ if (removed.has(SKILL_TOKEN))
2006
+ this.skillChip = undefined;
1929
2007
  if (removed.size)
1930
2008
  this.attachments = this.attachments.filter(entry => !removed.has(entry.marker));
1931
2009
  }
@@ -2120,6 +2198,11 @@ export class TerminalUI extends EventEmitter {
2120
2198
  // substituted text is submitted, echoed and recorded exactly as if it had been typed.
2121
2199
  if ((key.name === 'return' || key.name === 'enter') && !key.meta && !key.shift) {
2122
2200
  const selected = this.selectedCompletion();
2201
+ if (selected && this.skillCommand(selected)) {
2202
+ this.insertSkillChip(selected);
2203
+ this.scheduleRender();
2204
+ return;
2205
+ }
2123
2206
  if (selected) {
2124
2207
  this.value = graphemes(selected);
2125
2208
  this.cursor = this.value.length;
@@ -2241,12 +2324,10 @@ export class TerminalUI extends EventEmitter {
2241
2324
  while (this.cursor < this.value.length && this.value[this.cursor] !== '\n')
2242
2325
  this.cursor++;
2243
2326
  }
2244
- else if (key.name === 'backspace') {
2245
- if (this.cursor)
2246
- this.removeDraft(--this.cursor, 1);
2247
- }
2327
+ else if (key.name === 'backspace')
2328
+ this.backspace();
2248
2329
  else if (key.name === 'delete')
2249
- this.removeDraft(this.cursor, 1);
2330
+ this.deleteForward();
2250
2331
  else if (key.name === 'up' || key.name === 'down')
2251
2332
  this.navigate(key.name === 'up' ? -1 : 1);
2252
2333
  else if (key.name === 'tab')
@@ -2339,12 +2420,10 @@ export class TerminalUI extends EventEmitter {
2339
2420
  while (this.cursor < this.value.length && this.value[this.cursor] !== '\n')
2340
2421
  this.cursor++;
2341
2422
  }
2342
- else if (key.name === 'backspace') {
2343
- if (this.cursor)
2344
- this.removeDraft(--this.cursor, 1);
2345
- }
2423
+ else if (key.name === 'backspace')
2424
+ this.backspace();
2346
2425
  else if (key.name === 'delete')
2347
- this.removeDraft(this.cursor, 1);
2426
+ this.deleteForward();
2348
2427
  else if (key.name === 'up' || key.name === 'down')
2349
2428
  this.navigate(key.name === 'up' ? -1 : 1);
2350
2429
  else if (key.name === 'tab')
@@ -2401,7 +2480,7 @@ export class TerminalUI extends EventEmitter {
2401
2480
  // scroll, so there is no exhaustion heuristic reconciling the two gestures.
2402
2481
  if (this.pending?.history) {
2403
2482
  if (this.historyIndex === this.history.length)
2404
- this.draft = this.value.join('');
2483
+ this.draft = this.parkedDraft();
2405
2484
  this.historyIndex = historyAt;
2406
2485
  this.value = this.restoredDraft(this.history[this.historyIndex] ?? this.draft);
2407
2486
  this.cursor = this.value.length;
@@ -2498,6 +2577,8 @@ export class TerminalUI extends EventEmitter {
2498
2577
  return;
2499
2578
  // A token copies as what it stands for: the pasted text itself, a file's path, an image's name.
2500
2579
  const tokens = new Map(this.attachments.map(({ marker, pending }) => [marker, pending.kind === 'text' ? pending.content : pending.kind === 'file' ? pending.path : `[${pending.name}]`]));
2580
+ if (this.skillChip)
2581
+ tokens.set(SKILL_TOKEN, this.skillChip);
2501
2582
  const text = this.value.slice(range[0], range[1]).map(part => tokens.get(part) ?? part).join('');
2502
2583
  const osc52 = () => { if (this.started && !this.closed)
2503
2584
  this.output.write(`\x1b]52;c;${Buffer.from(text, 'utf8').toString('base64')}\x07`); };
@@ -2510,10 +2591,13 @@ export class TerminalUI extends EventEmitter {
2510
2591
  this.scheduleRender();
2511
2592
  }
2512
2593
  complete() { this.dismissedCompletion = undefined; const completion = this.commandMatches(true); const selected = completion?.options[completion.index]; if (!selected)
2513
- return; if (argumentRequired.has(selected)) {
2594
+ return; if (this.skillCommand(selected)) {
2595
+ this.insertSkillChip(selected);
2596
+ return;
2597
+ } if (argumentRequired.has(selected)) {
2514
2598
  this.awaitArgument(selected);
2515
2599
  return;
2516
- } this.value = graphemes(selected); this.cursor = this.value.length; const options = completionOptions(selected); this.completion = { query: selected, options, index: options.indexOf(selected) }; }
2600
+ } this.value = graphemes(selected); this.cursor = this.value.length; const options = completionOptions(selected, this.skillCommands.map(skill => skill.command)); this.completion = { query: selected, options, index: options.indexOf(selected) }; }
2517
2601
  /** Put `command ` in the composer and open its argument list, without submitting anything. */
2518
2602
  awaitArgument(command) { this.value = graphemes(`${command} `); this.cursor = this.value.length; this.completion = undefined; this.dismissedCompletion = undefined; }
2519
2603
  /**
@@ -2548,7 +2632,7 @@ export class TerminalUI extends EventEmitter {
2548
2632
  if (this.pending?.secret || (!this.pending?.conversationPrompt && !this.runInputHandler) || this.modal || query === this.dismissedCompletion || !completable(query))
2549
2633
  return undefined;
2550
2634
  if (this.completion?.query !== query)
2551
- this.completion = { query, options: completionOptions(query), index: 0 };
2635
+ this.completion = { query, options: completionOptions(query, this.skillCommands.map(skill => skill.command)), index: 0 };
2552
2636
  if (visibleOnly) {
2553
2637
  const width = this.chatColumns(), height = Math.max(1, this.output.rows || 24);
2554
2638
  const inputRows = Math.min(editor(this.visibleDraft(width - 4), Math.max(1, width - 4)).lines.length, Math.min(6, Math.max(1, height - 9)));
@@ -2627,7 +2711,7 @@ export class TerminalUI extends EventEmitter {
2627
2711
  const available = Math.max(1, width - 4); // the transcript adds two columns of inset
2628
2712
  const graph = status.graph;
2629
2713
  const selected = status.graphSelection ?? (graph?.id === 'software-engineer' ? 'default' : graph?.id);
2630
- const graphName = selected === 'default' ? 'Default · Software Engineer' : oneLine(graph?.name ?? 'Not selected');
2714
+ const graphName = selected === 'default' ? 'Default · Andorra Agent' : oneLine(graph?.name ?? 'Not selected');
2631
2715
  const nodes = graph ? Object.keys(graph.nodes).length : 0;
2632
2716
  const nodeCount = graph && selected !== 'default' ? ` · ${nodes} ${nodes === 1 ? 'node' : 'nodes'}` : '';
2633
2717
  const activity = oneLine(status.activity || 'Ready');
@@ -2931,7 +3015,7 @@ export class TerminalUI extends EventEmitter {
2931
3015
  for (let index = 0; index < popupRows; index++) {
2932
3016
  const item = completion.options[first + index];
2933
3017
  const selected = !!item && first + index === completion.index;
2934
- const label = item ? `${selected ? '›' : ' '} ${item} ${commandDescriptions[item]}` : 'No matching commands';
3018
+ const label = item ? `${selected ? '›' : ' '} ${item} ${commandDescriptions[item] ?? this.skillCommands.find(skill => skill.command === item)?.description ?? ''}` : 'No matching commands';
2935
3019
  const value = pad(label, cardWidth - 4);
2936
3020
  lines.push(paint(' │ ', GRAY) + (selected ? `\x1b[48;5;236m${paint(value, DIM)}\x1b[0m` : paint(value)) + paint(' │', GRAY));
2937
3021
  }