@pellux/goodvibes-tui 1.19.6 → 1.20.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 +6 -0
- package/LICENSE +21 -0
- package/README.md +143 -1613
- package/docs/README.md +4 -4
- package/docs/foundation-artifacts/operator-contract.json +1 -1
- package/package.json +7 -7
- package/src/cli/ensure-goodvibes-gitignore.ts +16 -4
- package/src/cli/entrypoint.ts +5 -1
- package/src/cli/launch-auto-update.ts +63 -4
- package/src/cli/tui-startup.ts +131 -15
- package/src/config/surface.ts +21 -0
- package/src/config/tui-extension-settings.ts +9 -1
- package/src/core/conversation-line-cache.ts +1 -1
- package/src/core/conversation-rendering.ts +70 -24
- package/src/core/conversation-tool-groups.ts +23 -10
- package/src/core/conversation-types.ts +9 -0
- package/src/core/rewind-turn-anchors.ts +12 -13
- package/src/core/session-recovery.ts +59 -2
- package/src/core/session-resume-core.ts +206 -0
- package/src/core/transcript-journal.ts +32 -6
- package/src/core/turn-event-wiring.ts +55 -12
- package/src/input/command-args-hint.ts +11 -2
- package/src/input/command-registry.ts +19 -0
- package/src/input/commands/checkpoint-runtime.ts +3 -3
- package/src/input/commands/health-runtime.ts +1 -3
- package/src/input/commands/local-runtime.ts +1 -1
- package/src/input/commands/rewind-runtime.ts +132 -1
- package/src/input/commands/runtime-services.ts +11 -1
- package/src/input/commands/secret-runtime.ts +1 -1
- package/src/input/commands/session-content.ts +9 -1
- package/src/input/commands/session-picker-filter.ts +28 -0
- package/src/input/commands/session-workflow.ts +62 -73
- package/src/input/commands/session.ts +36 -1
- package/src/input/commands/shell-core.ts +57 -5
- package/src/input/commands/update-runtime.ts +120 -4
- package/src/input/commands/websearch-runtime.ts +1 -1
- package/src/input/handler-content-actions.ts +63 -39
- package/src/input/handler-feed-routes.ts +17 -3
- package/src/input/handler-feed.ts +3 -0
- package/src/input/handler-interactions.ts +19 -23
- package/src/input/handler-modal-token-routes.ts +5 -0
- package/src/input/handler-types.ts +4 -1
- package/src/input/handler-ui-state.ts +6 -2
- package/src/input/handler.ts +19 -9
- package/src/input/search.ts +94 -2
- package/src/input/selection-modal-queue.ts +176 -0
- package/src/main.ts +48 -44
- package/src/panels/builtin/operations.ts +2 -1
- package/src/panels/provider-health-domains.ts +2 -2
- package/src/renderer/block-actions-overlay.ts +59 -0
- package/src/renderer/block-actions.ts +1 -3
- package/src/renderer/context-status-hint.ts +73 -5
- package/src/renderer/conversation-layout.ts +16 -0
- package/src/renderer/conversation-overlays.ts +6 -0
- package/src/renderer/help-overlay.ts +69 -53
- package/src/renderer/selection-modal-overlay.ts +66 -10
- package/src/renderer/shell-surface.ts +15 -0
- package/src/renderer/tool-result-expanded-lines.ts +48 -0
- package/src/renderer/ui-factory.ts +1 -1
- package/src/runtime/bootstrap-command-context.ts +5 -1
- package/src/runtime/bootstrap-command-parts.ts +5 -2
- package/src/runtime/bootstrap-core.ts +3 -3
- package/src/runtime/bootstrap-hook-bridge.ts +62 -44
- package/src/runtime/bootstrap-shell.ts +31 -16
- package/src/runtime/bootstrap.ts +13 -18
- package/src/runtime/code-index-services.ts +19 -0
- package/src/runtime/durability-services.ts +11 -7
- package/src/runtime/index.ts +12 -0
- package/src/runtime/process-lifecycle.ts +63 -2
- package/src/runtime/recovery-autosave.ts +48 -0
- package/src/runtime/recovery-offer-wiring.ts +89 -0
- package/src/runtime/recovery-prompt.ts +312 -0
- package/src/runtime/resume-notice.ts +28 -93
- package/src/runtime/services.ts +14 -16
- package/src/runtime/session-liveness-marker.ts +120 -0
- package/src/runtime/session-pointer-surface.ts +22 -0
- package/src/runtime/session-resume-liveness-confirm.ts +84 -0
- package/src/runtime/session-storage-services.ts +41 -0
- package/src/runtime/workspace-checkpointing.ts +10 -2
- package/src/shell/recovery-input-helpers.ts +7 -3
- package/src/shell/retry-affordance.ts +123 -0
- package/src/shell/ui-openers.ts +9 -0
- package/src/utils/splash-lines.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -6,9 +6,9 @@ import type { TranscriptEventKind } from '@pellux/goodvibes-sdk/platform/core';
|
|
|
6
6
|
import type { ConversationTitleSource } from '../../core/conversation';
|
|
7
7
|
import type { SessionReturnContextSummary } from '@/runtime/index.ts';
|
|
8
8
|
import { formatReturnContextForDisplay, getReturnContextMode, maybeAssistReturnContextSummary } from '@/runtime/index.ts';
|
|
9
|
-
import { requirePanelManager, requireProviderApi, requireSessionManager,
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { requirePanelManager, requireProviderApi, requireSessionManager, requireSurface } from './runtime-services.ts';
|
|
10
|
+
import { resumeSessionCore, reopenPanelsWithModalSkip, DEFAULT_PANEL_REOPEN_LIMIT } from '../../core/session-resume-core.ts';
|
|
11
|
+
import { checkSessionLiveness } from '../../runtime/session-liveness-marker.ts';
|
|
12
12
|
import { summarizeError } from '@pellux/goodvibes-sdk/platform/utils';
|
|
13
13
|
|
|
14
14
|
function parseTranscriptKind(raw: string | undefined): TranscriptEventKind | 'all' {
|
|
@@ -83,32 +83,20 @@ function buildTranscriptReviewLines(
|
|
|
83
83
|
// Exported (test-only concern) so the MIGRATE-TO-MODAL redirect-skip honesty
|
|
84
84
|
// (W6 review, finding 3: saved-layout restore with 'sessions' must not lie)
|
|
85
85
|
// can be unit-tested directly instead of through a full /resume harness.
|
|
86
|
+
// Delegates to the shared reopenPanelsWithModalSkip (core/session-resume-core.ts)
|
|
87
|
+
// — the same routine resumeSessionCore uses — so this standalone entry point
|
|
88
|
+
// and the canonical resume sequence can never diverge on panel-reopen behavior.
|
|
86
89
|
export function reopenPanelsFromReturnContext(ctx: CommandContext, summary: SessionReturnContextSummary | undefined): string[] {
|
|
87
90
|
if (!summary?.openPanels || summary.openPanels.length === 0) return [];
|
|
88
91
|
const panelManager = requirePanelManager(ctx);
|
|
89
|
-
const reopened
|
|
90
|
-
const movedToModal: string[] = [];
|
|
91
|
-
for (const panelId of summary.openPanels.slice(0, 4)) {
|
|
92
|
-
// (the purge): a MIGRATE-TO-MODAL id has no panel to restore — a modal
|
|
93
|
-
// is not part of the saved panel layout. Skip it (don't pop a modal
|
|
94
|
-
// mid-resume) and note it once, rather than firing openModal + revealing an
|
|
95
|
-
// empty workspace during resume.
|
|
96
|
-
if (panelManager.getModalRedirect(panelId) !== undefined) {
|
|
97
|
-
movedToModal.push(panelId);
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
try {
|
|
101
|
-
panelManager.open(panelId);
|
|
102
|
-
reopened.push(panelId);
|
|
103
|
-
} catch {
|
|
104
|
-
// Ignore unknown or currently unavailable panel ids during resume.
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (reopened.length > 0) panelManager.show();
|
|
92
|
+
const { reopened, movedToModal, notReopened } = reopenPanelsWithModalSkip(panelManager, summary.openPanels, DEFAULT_PANEL_REOPEN_LIMIT);
|
|
108
93
|
if (movedToModal.length > 0) {
|
|
109
94
|
ctx.print(`Note: ${movedToModal.join(', ')} moved to a modal — reopen via its command instead of as a panel.`);
|
|
110
95
|
}
|
|
111
|
-
|
|
96
|
+
if (notReopened.length > 0) {
|
|
97
|
+
ctx.print(` …and ${notReopened.length} more not reopened (/panels to open)`);
|
|
98
|
+
}
|
|
99
|
+
return [...reopened];
|
|
112
100
|
}
|
|
113
101
|
|
|
114
102
|
function printSessionExport(
|
|
@@ -198,7 +186,9 @@ export async function handleSessionWorkflowCommand(args: string[], ctx: CommandC
|
|
|
198
186
|
session.returnContext.activeTasks ? `active=${session.returnContext.activeTasks}` : null,
|
|
199
187
|
session.returnContext.blockedTasks ? `blocked=${session.returnContext.blockedTasks}` : null,
|
|
200
188
|
session.returnContext.pendingApprovals ? `approvals=${session.returnContext.pendingApprovals}` : null,
|
|
201
|
-
session.returnContext.openPanels?.length
|
|
189
|
+
session.returnContext.openPanels?.length
|
|
190
|
+
? `panels=${session.returnContext.openPanels.slice(0, 3).join(',')}${session.returnContext.openPanels.length > 3 ? ` (+${session.returnContext.openPanels.length - 3} more)` : ''}`
|
|
191
|
+
: null,
|
|
202
192
|
].filter(Boolean).join(' ');
|
|
203
193
|
if (posture) lines.push(` posture: ${posture}`);
|
|
204
194
|
}
|
|
@@ -222,6 +212,10 @@ export async function handleSessionWorkflowCommand(args: string[], ctx: CommandC
|
|
|
222
212
|
model: ctx.session.runtime.model,
|
|
223
213
|
provider: ctx.session.runtime.provider,
|
|
224
214
|
timestamp: Date.now(),
|
|
215
|
+
// Naming a session is an act of curation, so the file this
|
|
216
|
+
// materializes for rename to act on is a user save, not machinery —
|
|
217
|
+
// the retention sweep must not expire something the user named.
|
|
218
|
+
saveSource: 'user',
|
|
225
219
|
});
|
|
226
220
|
}
|
|
227
221
|
sm.rename(ctx.session.runtime.sessionId, newName);
|
|
@@ -235,9 +229,13 @@ export async function handleSessionWorkflowCommand(args: string[], ctx: CommandC
|
|
|
235
229
|
}
|
|
236
230
|
|
|
237
231
|
if (sub === 'resume') {
|
|
238
|
-
|
|
232
|
+
// '--force' bypasses the multi-instance liveness confirm below — never a
|
|
233
|
+
// session-id/name token itself (session ids never start with '--').
|
|
234
|
+
const rawArgs = args.slice(1);
|
|
235
|
+
const force = rawArgs.includes('--force');
|
|
236
|
+
const target = rawArgs.filter((a) => a !== '--force').join(' ').trim();
|
|
239
237
|
if (!target) {
|
|
240
|
-
ctx.print('Usage: /session resume <session-id-or-name>');
|
|
238
|
+
ctx.print('Usage: /session resume <session-id-or-name> [--force]');
|
|
241
239
|
return true;
|
|
242
240
|
}
|
|
243
241
|
const sessions = sm.list();
|
|
@@ -250,56 +248,36 @@ export async function handleSessionWorkflowCommand(args: string[], ctx: CommandC
|
|
|
250
248
|
ctx.print(`Session not found: ${target}\nUse /session list to see available sessions.`);
|
|
251
249
|
return true;
|
|
252
250
|
}
|
|
253
|
-
try {
|
|
254
|
-
const { meta, messages } = sm.load(found.name);
|
|
255
|
-
const providerApi = requireProviderApi(ctx);
|
|
256
|
-
ctx.session.conversationManager.resetAll();
|
|
257
|
-
ctx.session.conversationManager.fromJSON({ messages: messages as never[], title: meta.title, titleSource: meta.titleSource });
|
|
258
|
-
ctx.session.conversationManager.rebuildHistory();
|
|
259
|
-
ctx.session.runtime.sessionId = found.name;
|
|
260
251
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
252
|
+
// Multi-instance safety: warn (and require --force) when this session
|
|
253
|
+
// looks open in another still-running terminal right now — resuming it
|
|
254
|
+
// here would fork its live state out from under that other instance.
|
|
255
|
+
// Best-effort: a missing/stale marker (or this process's OWN marker,
|
|
256
|
+
// e.g. re-resuming the session already active here) never blocks anything.
|
|
257
|
+
const liveness = checkSessionLiveness(requireSurface(ctx), found.name);
|
|
258
|
+
if (liveness.live && liveness.pid !== process.pid && !force) {
|
|
259
|
+
ctx.print(
|
|
260
|
+
`Session appears open in another terminal (pid ${liveness.pid}) — resuming will fork its live state.\n` +
|
|
261
|
+
`Re-run \`/session resume ${found.name} --force\` to proceed anyway.`,
|
|
262
|
+
);
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
266
265
|
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
snapshotTimestamp: meta.timestamp,
|
|
266
|
+
try {
|
|
267
|
+
const providerApi = requireProviderApi(ctx);
|
|
268
|
+
const outcome = await resumeSessionCore(found.name, {
|
|
269
|
+
sessionManager: sm,
|
|
272
270
|
conversation: ctx.session.conversationManager,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
provider: meta.provider,
|
|
279
|
-
timestamp: Date.now(),
|
|
280
|
-
titleSource: meta.titleSource,
|
|
281
|
-
returnContext: meta.returnContext,
|
|
282
|
-
});
|
|
283
|
-
},
|
|
271
|
+
runtime: ctx.session.runtime,
|
|
272
|
+
surface: requireSurface(ctx),
|
|
273
|
+
panelManager: requirePanelManager(ctx),
|
|
274
|
+
selectModel: (model) => providerApi.selectModel(model),
|
|
275
|
+
hydrateSessionUsage: ctx.session.hydrateSessionUsage,
|
|
284
276
|
});
|
|
285
|
-
|
|
286
|
-
// history now, before ctx.renderRequest() below.
|
|
287
|
-
ctx.session.hydrateSessionUsage?.();
|
|
277
|
+
const { meta, journalReplay, restoredAnchorCount, resumedMessageCount, panels } = outcome;
|
|
288
278
|
|
|
289
|
-
if (meta.model) {
|
|
290
|
-
try {
|
|
291
|
-
const selected = await providerApi.selectModel(meta.model);
|
|
292
|
-
ctx.session.runtime.model = selected.registryKey;
|
|
293
|
-
ctx.session.runtime.provider = selected.providerId;
|
|
294
|
-
} catch {
|
|
295
|
-
ctx.session.runtime.model = meta.model;
|
|
296
|
-
// model may not exist locally
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
if (meta.provider) ctx.session.runtime.provider = meta.provider;
|
|
300
279
|
ctx.renderRequest();
|
|
301
|
-
|
|
302
|
-
ctx.print(`Resumed session: ${found.name}\n Name: ${meta.title || '(untitled)'}\n Messages: ${resumedMsgCount}\n Model: ${meta.model || ctx.session.runtime.model}`);
|
|
280
|
+
ctx.print(`Resumed session: ${found.name}\n Name: ${meta.title || '(untitled)'}\n Messages: ${resumedMessageCount}\n Model: ${meta.model || ctx.session.runtime.model}`);
|
|
303
281
|
if (restoredAnchorCount > 0) {
|
|
304
282
|
ctx.print(` Rewind: restored ${restoredAnchorCount} turn anchor(s) — /rewind is available for this resumed session.`);
|
|
305
283
|
}
|
|
@@ -311,14 +289,19 @@ export async function handleSessionWorkflowCommand(args: string[], ctx: CommandC
|
|
|
311
289
|
} else if (journalReplay.hadCorruptTail) {
|
|
312
290
|
ctx.print(' [Recovery] Journal tail was partially corrupt (quarantined). Replay stopped at last good record.');
|
|
313
291
|
}
|
|
314
|
-
|
|
292
|
+
if (panels.movedToModal.length > 0) {
|
|
293
|
+
ctx.print(`Note: ${panels.movedToModal.join(', ')} moved to a modal — reopen via its command instead of as a panel.`);
|
|
294
|
+
}
|
|
295
|
+
if (panels.notReopened.length > 0) {
|
|
296
|
+
ctx.print(` …and ${panels.notReopened.length} more not reopened (/panels to open)`);
|
|
297
|
+
}
|
|
315
298
|
const returnContextMode = getReturnContextMode(ctx.platform.configManager);
|
|
316
299
|
if (returnContextMode !== 'off' && meta.returnContext) {
|
|
317
300
|
for (const line of formatReturnContextForDisplay(meta.returnContext)) {
|
|
318
301
|
ctx.print(` ${line}`);
|
|
319
302
|
}
|
|
320
|
-
if (
|
|
321
|
-
ctx.print(` Reopened panels: ${
|
|
303
|
+
if (panels.reopened.length > 0) {
|
|
304
|
+
ctx.print(` Reopened panels: ${panels.reopened.join(', ')}`);
|
|
322
305
|
}
|
|
323
306
|
if ((meta.returnContext.remoteRunners?.length ?? 0) > 0) {
|
|
324
307
|
ctx.print(` Remote re-entry: /remote recover ${meta.returnContext.remoteRunners![0]}`);
|
|
@@ -354,6 +337,8 @@ export async function handleSessionWorkflowCommand(args: string[], ctx: CommandC
|
|
|
354
337
|
timestamp: Date.now(),
|
|
355
338
|
titleSource: exportData.titleSource,
|
|
356
339
|
returnContext: exportData.returnContext,
|
|
340
|
+
// The operator asked for this fork by name; it is not turn machinery.
|
|
341
|
+
saveSource: 'user',
|
|
357
342
|
};
|
|
358
343
|
try {
|
|
359
344
|
sm.save(newId, messages, meta);
|
|
@@ -378,6 +363,10 @@ export async function handleSessionWorkflowCommand(args: string[], ctx: CommandC
|
|
|
378
363
|
timestamp: Date.now(),
|
|
379
364
|
titleSource: exportData.titleSource,
|
|
380
365
|
returnContext: exportData.returnContext,
|
|
366
|
+
// The one unambiguous "keep this" act in the app. Marked so the
|
|
367
|
+
// session-conversations retention sweep never expires it, unlike the
|
|
368
|
+
// automatic per-turn snapshot (turn-event-wiring.ts, saveSource 'auto').
|
|
369
|
+
saveSource: 'user',
|
|
381
370
|
};
|
|
382
371
|
try {
|
|
383
372
|
const { filePath, sanitizedName } = sm.save(rawName, messages, meta);
|
|
@@ -22,6 +22,7 @@ import type { CancellationScope, CrossSessionTaskRef } from '@pellux/goodvibes-s
|
|
|
22
22
|
import { VALID_SCOPES } from '@pellux/goodvibes-sdk/platform/sessions';
|
|
23
23
|
import { handleSessionWorkflowCommand } from './session-workflow.ts';
|
|
24
24
|
import { requireSessionOrchestration, requireSessionManager } from './runtime-services.ts';
|
|
25
|
+
import { filterUserFacingSessions } from './session-picker-filter.ts';
|
|
25
26
|
|
|
26
27
|
// ── Argument parsing helpers ──────────────────────────────────────────────────
|
|
27
28
|
|
|
@@ -316,6 +317,37 @@ function handleCancel(args: string[], context: CommandContext): void {
|
|
|
316
317
|
|
|
317
318
|
// ── Top-level command definition ───────────────────────────────────────────────
|
|
318
319
|
|
|
320
|
+
/**
|
|
321
|
+
* SESSION_SUBCOMMAND_ARG_HINTS — the single source of truth for each
|
|
322
|
+
* `/session <subcommand>` argument hint, co-located with the switch below so
|
|
323
|
+
* the two can't silently drift apart (command-args-hint.ts imports this
|
|
324
|
+
* directly instead of hand-maintaining its own copy; a drift test —
|
|
325
|
+
* src/test/input/command-args-hint.test.ts — cross-checks every key here
|
|
326
|
+
* against the default usage text's own subcommand list). Aliases (`link`,
|
|
327
|
+
* `ho`, `g`) share their canonical subcommand's hint text.
|
|
328
|
+
*/
|
|
329
|
+
export const SESSION_SUBCOMMAND_ARG_HINTS: Record<string, string> = {
|
|
330
|
+
list: '',
|
|
331
|
+
rename: '<name>',
|
|
332
|
+
resume: '<id|name>',
|
|
333
|
+
fork: '[name]',
|
|
334
|
+
save: '[name]',
|
|
335
|
+
info: '[id]',
|
|
336
|
+
export: '<id|.> [markdown|text]',
|
|
337
|
+
search: '<query>',
|
|
338
|
+
delete: '<id>',
|
|
339
|
+
events: '[kind]',
|
|
340
|
+
groups: '[kind]',
|
|
341
|
+
hotspots: '',
|
|
342
|
+
'link-task': '<taskId> [--session <sid>] [--depends-on <sid:taskId>] [--label <label>]',
|
|
343
|
+
link: '<taskId> [--session <sid>] [--depends-on <sid:taskId>] [--label <label>]',
|
|
344
|
+
handoff: '<taskId> --to <sid> [--session <sid>] [--reason <reason>]',
|
|
345
|
+
ho: '<taskId> --to <sid> [--session <sid>] [--reason <reason>]',
|
|
346
|
+
graph: '[--session <sid>] [--format text|json]',
|
|
347
|
+
g: '[--session <sid>] [--format text|json]',
|
|
348
|
+
cancel: '<taskId> [--scope task|subtree|session] [--session <sid>] [--reason <reason>]',
|
|
349
|
+
};
|
|
350
|
+
|
|
319
351
|
/**
|
|
320
352
|
* sessionCommand — The `/session` slash command.
|
|
321
353
|
*
|
|
@@ -446,7 +478,10 @@ export const resumeCommand: SlashCommand = {
|
|
|
446
478
|
return;
|
|
447
479
|
}
|
|
448
480
|
const sm = requireSessionManager(ctx);
|
|
449
|
-
|
|
481
|
+
// Excludes the current session and subagent-shaped transcripts (see
|
|
482
|
+
// session-picker-filter.ts) — a direct `/resume agent-xxxxxxxx` still
|
|
483
|
+
// reaches them, this only keeps the picker itself readable.
|
|
484
|
+
const sessions = filterUserFacingSessions(sm.list()).filter((s) => s.name !== ctx.session.runtime.sessionId);
|
|
450
485
|
if (sessions.length === 0) {
|
|
451
486
|
ctx.print('No previous sessions to resume yet. /session save [name] stores the current one explicitly.');
|
|
452
487
|
return;
|
|
@@ -71,7 +71,20 @@ export function registerShellCoreCommands(registry: CommandRegistry): void {
|
|
|
71
71
|
ctx.openShortcutsOverlay();
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
ctx.print('Use
|
|
74
|
+
ctx.print('Use /commands for shortcuts');
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
registry.register({
|
|
79
|
+
name: 'find',
|
|
80
|
+
aliases: ['findtext'],
|
|
81
|
+
description: 'Search THIS conversation transcript (same as Ctrl+F) — searching the web instead? use /search',
|
|
82
|
+
handler(_args, ctx) {
|
|
83
|
+
if (ctx.openTranscriptSearch) {
|
|
84
|
+
ctx.openTranscriptSearch();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
ctx.print('Transcript search is not available in this context — try Ctrl+F.');
|
|
75
88
|
},
|
|
76
89
|
});
|
|
77
90
|
|
|
@@ -81,10 +94,18 @@ export function registerShellCoreCommands(registry: CommandRegistry): void {
|
|
|
81
94
|
description: 'List current keyboard bindings and their config file path',
|
|
82
95
|
handler(_args, ctx) {
|
|
83
96
|
const km = requireKeybindingsManager(ctx);
|
|
97
|
+
// The full binding table (~45 rows) is presented via the same
|
|
98
|
+
// generated, scrollable overlay /shortcuts opens (see
|
|
99
|
+
// renderShortcutsOverlay) rather than a one-shot transcript dump —
|
|
100
|
+
// the file path (dynamic, per-user) still gets a short transcript
|
|
101
|
+
// line since the overlay itself doesn't show it.
|
|
102
|
+
ctx.print(`Keybindings config: ${km.getConfigPath()} (create it to override any binding: { "action": { "key": "x", "ctrl": true } })`);
|
|
103
|
+
if (ctx.openShortcutsOverlay) {
|
|
104
|
+
ctx.openShortcutsOverlay();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
84
107
|
const all = km.getAll();
|
|
85
108
|
const lines: string[] = [
|
|
86
|
-
`Keybindings config: ${km.getConfigPath()}`,
|
|
87
|
-
'',
|
|
88
109
|
` ${'Action'.padEnd(28)} ${'Binding'.padEnd(20)} Description`,
|
|
89
110
|
` ${'─'.repeat(28)} ${'─'.repeat(20)} ${'─'.repeat(34)}`,
|
|
90
111
|
];
|
|
@@ -92,8 +113,6 @@ export function registerShellCoreCommands(registry: CommandRegistry): void {
|
|
|
92
113
|
const label = combos.map((combo) => km.formatCombo(combo)).join(', ');
|
|
93
114
|
lines.push(` ${action.padEnd(28)} ${label.padEnd(20)} ${description}`);
|
|
94
115
|
}
|
|
95
|
-
lines.push('');
|
|
96
|
-
lines.push('To customize: create the config file with { "action": { "key": "x", "ctrl": true } }');
|
|
97
116
|
ctx.print(lines.join('\n'));
|
|
98
117
|
},
|
|
99
118
|
});
|
|
@@ -114,6 +133,39 @@ export function registerShellCoreCommands(registry: CommandRegistry): void {
|
|
|
114
133
|
},
|
|
115
134
|
});
|
|
116
135
|
|
|
136
|
+
registry.register({
|
|
137
|
+
name: 'pastes',
|
|
138
|
+
aliases: ['pending-pastes'],
|
|
139
|
+
description: 'Preview the actual content behind each [TEXT: pN, M lines] fold in the composer, before you submit',
|
|
140
|
+
usage: '[pN]',
|
|
141
|
+
argsHint: '[pN]',
|
|
142
|
+
handler(args, ctx) {
|
|
143
|
+
const pending = ctx.getPendingPastes?.();
|
|
144
|
+
if (!pending || pending.size === 0) {
|
|
145
|
+
ctx.print('[Pastes] No folded pastes are currently in the composer (pastes over 8 lines fold to [TEXT: pN, M lines]).');
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const requestedId = args[0]?.trim();
|
|
149
|
+
if (requestedId) {
|
|
150
|
+
const content = pending.get(requestedId);
|
|
151
|
+
if (!content) {
|
|
152
|
+
ctx.print(`[Pastes] No pending paste with id "${requestedId}". Pending: ${[...pending.keys()].join(', ')}`);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
ctx.print(`[Pastes] ${requestedId} (${content.split('\n').length} lines):\n${content}`);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const lines = ['[Pastes] Folded in the composer right now:'];
|
|
159
|
+
for (const [id, content] of pending) {
|
|
160
|
+
const contentLines = content.split('\n');
|
|
161
|
+
const preview = contentLines[0].slice(0, 80);
|
|
162
|
+
lines.push(` ${id} — ${contentLines.length} lines — ${preview}${contentLines.length > 1 || preview.length < contentLines[0].length ? '…' : ''}`);
|
|
163
|
+
}
|
|
164
|
+
lines.push('', 'Full text: /pastes <id>');
|
|
165
|
+
ctx.print(lines.join('\n'));
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
|
|
117
169
|
registry.register({
|
|
118
170
|
name: 'help',
|
|
119
171
|
aliases: ['h', '?'],
|
|
@@ -82,6 +82,91 @@ async function downloadText(fetchImpl: UpdateFetchLike, url: string): Promise<st
|
|
|
82
82
|
return await response.text();
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Where cancellation stops being allowed. An update is genuinely abortable up
|
|
87
|
+
* to and including the moment BEFORE the first file is written: every fetch on
|
|
88
|
+
* the way there carries the caller's signal, and every await boundary re-checks
|
|
89
|
+
* it. From the first write onward the swap owns the installed files and always
|
|
90
|
+
* runs to completion — a half-applied swap is the one outcome worse than a slow
|
|
91
|
+
* one.
|
|
92
|
+
*
|
|
93
|
+
* This record makes that boundary readable from outside the call. The launch
|
|
94
|
+
* updater gives `applyUpdate` a budget and abandons the promise when it runs
|
|
95
|
+
* out, so it cannot learn from the return value which side of the line the work
|
|
96
|
+
* was on — it reads these flags instead, and prints the receipt that is
|
|
97
|
+
* actually true (see src/cli/launch-auto-update.ts).
|
|
98
|
+
*/
|
|
99
|
+
export interface UpdateSwapProgress {
|
|
100
|
+
/** True from the first file write of the swap phase; from here the swap is never interrupted. */
|
|
101
|
+
begun: boolean;
|
|
102
|
+
/** True once every target file has been swapped into place and the update is fully installed. */
|
|
103
|
+
committed: boolean;
|
|
104
|
+
/** The release tag being installed, set as soon as the target is resolved (before any download). */
|
|
105
|
+
targetTag: string | null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function createUpdateSwapProgress(): UpdateSwapProgress {
|
|
109
|
+
return { begun: false, committed: false, targetTag: null };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** The failure an aborted update ends with — raised only while nothing has been written yet. */
|
|
113
|
+
export const UPDATE_ABORTED_MESSAGE = 'update cancelled before any file was replaced';
|
|
114
|
+
|
|
115
|
+
function throwIfAborted(signal: AbortSignal | undefined): void {
|
|
116
|
+
if (signal?.aborted) {
|
|
117
|
+
throw new Error(UPDATE_ABORTED_MESSAGE);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The shared UpdateFetchLike init shape predates cancellation, so the signal
|
|
123
|
+
* rides on a widened version of it: the real `fetch` reads it — which is what
|
|
124
|
+
* makes the DOWNLOAD itself cancellable rather than merely abandoned — and a
|
|
125
|
+
* test stub that ignores the extra field behaves exactly as it did before.
|
|
126
|
+
*/
|
|
127
|
+
type AbortableFetchInit = NonNullable<Parameters<UpdateFetchLike>[1]> & { signal?: AbortSignal };
|
|
128
|
+
|
|
129
|
+
function abortableFetch(fetchImpl: UpdateFetchLike, signal: AbortSignal | undefined): UpdateFetchLike {
|
|
130
|
+
if (!signal) return fetchImpl;
|
|
131
|
+
const withSignal = fetchImpl as (url: string, init?: AbortableFetchInit) => ReturnType<UpdateFetchLike>;
|
|
132
|
+
return async (url, init) => {
|
|
133
|
+
throwIfAborted(signal);
|
|
134
|
+
return await withSignal(url, { ...init, signal });
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Wraps the filesystem seam so the first MUTATING call flips `begun`. The swap
|
|
140
|
+
* phase is the only part of the apply path that writes anything, so that first
|
|
141
|
+
* write is exactly the point after which cancellation must no longer be
|
|
142
|
+
* honoured. Reads (the daemon-present probe, the target-exists check inside the
|
|
143
|
+
* swap) leave the flag alone.
|
|
144
|
+
*/
|
|
145
|
+
function trackSwapProgress(io: UpdateFileIo, progress: UpdateSwapProgress): UpdateFileIo {
|
|
146
|
+
const begin = (): void => {
|
|
147
|
+
progress.begun = true;
|
|
148
|
+
};
|
|
149
|
+
return {
|
|
150
|
+
writeFile: (path, data) => {
|
|
151
|
+
begin();
|
|
152
|
+
io.writeFile(path, data);
|
|
153
|
+
},
|
|
154
|
+
rename: (from, to) => {
|
|
155
|
+
begin();
|
|
156
|
+
io.rename(from, to);
|
|
157
|
+
},
|
|
158
|
+
chmod: (path, mode) => {
|
|
159
|
+
begin();
|
|
160
|
+
io.chmod(path, mode);
|
|
161
|
+
},
|
|
162
|
+
mkdir: (path) => {
|
|
163
|
+
begin();
|
|
164
|
+
io.mkdir(path);
|
|
165
|
+
},
|
|
166
|
+
exists: (path) => io.exists(path),
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
85
170
|
/**
|
|
86
171
|
* Suffix under which every swap keeps the file it replaced — re-exported
|
|
87
172
|
* from the SDK's canonical update policy module so rollback and swap share
|
|
@@ -153,6 +238,16 @@ export interface ApplyUpdateOptions {
|
|
|
153
238
|
readonly runCommand?: RunCommand;
|
|
154
239
|
/** Injectable filesystem seam (the SDK's UpdateFileIo) so tests observe swaps in memory. */
|
|
155
240
|
readonly io?: UpdateFileIo;
|
|
241
|
+
/**
|
|
242
|
+
* Cancels the update — for real: it is passed to every fetch in the path and
|
|
243
|
+
* re-checked at every await boundary, so an abort stops the download instead
|
|
244
|
+
* of leaving it running unwatched. Honoured only up to the moment before the
|
|
245
|
+
* swap begins; from the first file write onward it is deliberately ignored
|
|
246
|
+
* (see UpdateSwapProgress).
|
|
247
|
+
*/
|
|
248
|
+
readonly signal?: AbortSignal;
|
|
249
|
+
/** Shared record letting the caller tell a cancelled update apart from one whose swap had already started. */
|
|
250
|
+
readonly progress?: UpdateSwapProgress;
|
|
156
251
|
}
|
|
157
252
|
|
|
158
253
|
/**
|
|
@@ -178,7 +273,14 @@ export async function applyUpdate(options: ApplyUpdateOptions): Promise<void> {
|
|
|
178
273
|
return;
|
|
179
274
|
}
|
|
180
275
|
|
|
181
|
-
|
|
276
|
+
// Every network call from here carries the caller's signal, so an abort
|
|
277
|
+
// cancels the request in flight rather than orphaning it.
|
|
278
|
+
const signal = options.signal;
|
|
279
|
+
const progress = options.progress;
|
|
280
|
+
const fetchImpl = abortableFetch(options.fetchImpl, signal);
|
|
281
|
+
|
|
282
|
+
throwIfAborted(signal);
|
|
283
|
+
const latestTag = await resolveLatestReleaseTag(fetchImpl, REPO_RELEASES_LATEST_URL);
|
|
182
284
|
if (compareVersions(options.currentVersion, latestTag) >= 0) {
|
|
183
285
|
options.print(`Already current: running v${normalizeVersion(options.currentVersion)}, latest release is ${latestTag}.`);
|
|
184
286
|
return;
|
|
@@ -190,6 +292,10 @@ export async function applyUpdate(options: ApplyUpdateOptions): Promise<void> {
|
|
|
190
292
|
return;
|
|
191
293
|
}
|
|
192
294
|
|
|
295
|
+
// Named before the first download, so a caller that gives up on a slow apply
|
|
296
|
+
// can still report WHICH version the work was installing.
|
|
297
|
+
if (progress) progress.targetTag = latestTag;
|
|
298
|
+
|
|
193
299
|
options.print(`Update available: ${latestTag} (running v${normalizeVersion(options.currentVersion)}). Downloading and verifying...`);
|
|
194
300
|
|
|
195
301
|
const baseUrl = releaseDownloadBaseUrl(latestTag);
|
|
@@ -209,7 +315,8 @@ export async function applyUpdate(options: ApplyUpdateOptions): Promise<void> {
|
|
|
209
315
|
// file is refreshed for consistency even though the platform blocks extension
|
|
210
316
|
// loading. This inclusion decision needs one manifest pre-read; the swap
|
|
211
317
|
// itself re-verifies every included artifact inside applyVerifiedUpdate.
|
|
212
|
-
|
|
318
|
+
throwIfAborted(signal);
|
|
319
|
+
const checksumText = await downloadText(fetchImpl, `${baseUrl}/${CHECKSUM_MANIFEST_NAME}`);
|
|
213
320
|
const checksums = parseChecksumFile(checksumText);
|
|
214
321
|
const addon = resolveSqliteVecAsset(options.platform, options.arch);
|
|
215
322
|
const addonIncluded = addon !== null && checksums.get(addon.assetName) !== undefined;
|
|
@@ -230,13 +337,22 @@ export async function applyUpdate(options: ApplyUpdateOptions): Promise<void> {
|
|
|
230
337
|
// One mechanism everywhere: downloads + verifies ALL targets before any
|
|
231
338
|
// write, then swaps each atomically with the outgoing file kept at
|
|
232
339
|
// `<path>.previous`.
|
|
340
|
+
//
|
|
341
|
+
// This is the last point at which the update can be called off. The
|
|
342
|
+
// downloads inside applyVerifiedUpdate are still cancellable (the signal
|
|
343
|
+
// rides on every request), but its swap loop is synchronous and runs to
|
|
344
|
+
// completion once its first write lands — which is precisely what
|
|
345
|
+
// `progress.begun` records, and why nothing below this call re-checks the
|
|
346
|
+
// signal.
|
|
347
|
+
throwIfAborted(signal);
|
|
233
348
|
await applyVerifiedUpdate({
|
|
234
|
-
fetchImpl
|
|
349
|
+
fetchImpl,
|
|
235
350
|
downloadBaseUrl: baseUrl,
|
|
236
351
|
targets,
|
|
237
|
-
io,
|
|
352
|
+
io: progress ? trackSwapProgress(io, progress) : io,
|
|
238
353
|
platform: options.platform,
|
|
239
354
|
});
|
|
355
|
+
if (progress) progress.committed = true;
|
|
240
356
|
|
|
241
357
|
const serviceInfo = detectDaemonServiceManaged(options.platform, options.configManager, options.runCommand);
|
|
242
358
|
|
|
@@ -35,7 +35,7 @@ function parseSearchArgs(args: string[]): ParsedSearchArgs {
|
|
|
35
35
|
export function registerWebSearchRuntimeCommands(registry: CommandRegistry): void {
|
|
36
36
|
registry.register({
|
|
37
37
|
name: 'search',
|
|
38
|
-
description: '
|
|
38
|
+
description: 'Web search — ranked results with source labels (searching THIS transcript? use /find)',
|
|
39
39
|
usage: '<query> [--limit <n>]',
|
|
40
40
|
argsHint: '<query> [--limit <n>]',
|
|
41
41
|
async handler(args, ctx) {
|