@arbidocs/tui 0.3.110 → 0.3.112
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/dist/index.js +35 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -587,9 +587,14 @@ function toSlashCommands() {
|
|
|
587
587
|
}
|
|
588
588
|
return cmds;
|
|
589
589
|
}
|
|
590
|
-
function toSlashCommandsWithSkills(skills) {
|
|
590
|
+
function toSlashCommandsWithSkills(skills, builtins = []) {
|
|
591
591
|
const out = toSlashCommands();
|
|
592
592
|
const taken = new Set(out.map((c) => c.name));
|
|
593
|
+
for (const b of builtins) {
|
|
594
|
+
if (taken.has(b.name)) continue;
|
|
595
|
+
taken.add(b.name);
|
|
596
|
+
out.push({ name: b.name, description: b.description });
|
|
597
|
+
}
|
|
593
598
|
for (const s of skills) {
|
|
594
599
|
if (taken.has(s.slug)) continue;
|
|
595
600
|
out.push({ name: s.slug, description: s.description });
|
|
@@ -639,7 +644,8 @@ async function dispatchCommand(tui, input2) {
|
|
|
639
644
|
showMessage(tui, meta, "info");
|
|
640
645
|
return false;
|
|
641
646
|
}
|
|
642
|
-
|
|
647
|
+
const isBuiltinServerCommand = tui.commandsCache?.some((c) => c.name === cmdName) || KNOWN_SERVER_COMMANDS.has(cmdName);
|
|
648
|
+
if (isBuiltinServerCommand) {
|
|
643
649
|
return false;
|
|
644
650
|
}
|
|
645
651
|
showMessage(tui, `Unknown command: /${cmdName}. Type /help for available commands.`, "warning");
|
|
@@ -2298,6 +2304,12 @@ var ArbiTui = class {
|
|
|
2298
2304
|
* commands. ``null`` means "haven't fetched yet"; ``[]`` means
|
|
2299
2305
|
* "fetched, no skills exist". */
|
|
2300
2306
|
skillsCache = [];
|
|
2307
|
+
/** Cached built-in slash commands (``GET /v1/assistant/commands``) available
|
|
2308
|
+
* to the caller — the shipped ``/image`` / ``/compact`` / ``/goal`` … set,
|
|
2309
|
+
* gated per-user. Refreshed alongside ``skillsCache`` on workspace switch.
|
|
2310
|
+
* Drives autocomplete and the "known server command" passthrough so the TUI
|
|
2311
|
+
* never hardcodes (and drifts from) the backend's command vocabulary. */
|
|
2312
|
+
commandsCache = [];
|
|
2301
2313
|
/** Active citation overlay handle (null when not showing). */
|
|
2302
2314
|
citationOverlay = null;
|
|
2303
2315
|
/** Input listener ID for overlay dismiss (null when no overlay). */
|
|
@@ -2442,6 +2454,7 @@ var ArbiTui = class {
|
|
|
2442
2454
|
this.updateHeader();
|
|
2443
2455
|
this.connectWebSocket();
|
|
2444
2456
|
void this.refreshSkillsCache();
|
|
2457
|
+
void this.refreshCommandsCache();
|
|
2445
2458
|
}
|
|
2446
2459
|
/** Refresh the cached skills list for the current workspace. Called
|
|
2447
2460
|
* on workspace switch and from ``/skills`` itself so a freshly
|
|
@@ -2459,6 +2472,24 @@ var ArbiTui = class {
|
|
|
2459
2472
|
}
|
|
2460
2473
|
this.rebuildAutocomplete();
|
|
2461
2474
|
}
|
|
2475
|
+
/** Refresh the cached built-in commands for the current workspace. The
|
|
2476
|
+
* endpoint resolves via WorkspaceContext (like ``/skills``) and applies
|
|
2477
|
+
* per-user gates, so it's refreshed on workspace switch. Failures are
|
|
2478
|
+
* swallowed — older backends without ``GET /v1/assistant/commands`` fall
|
|
2479
|
+
* back to the static ``KNOWN_SERVER_COMMANDS`` passthrough set. */
|
|
2480
|
+
async refreshCommandsCache() {
|
|
2481
|
+
if (!this.workspaceContext) {
|
|
2482
|
+
this.commandsCache = [];
|
|
2483
|
+
this.rebuildAutocomplete();
|
|
2484
|
+
return;
|
|
2485
|
+
}
|
|
2486
|
+
try {
|
|
2487
|
+
this.commandsCache = await sdk.assistant.listCommands(this.workspaceContext.arbi);
|
|
2488
|
+
} catch {
|
|
2489
|
+
this.commandsCache = [];
|
|
2490
|
+
}
|
|
2491
|
+
this.rebuildAutocomplete();
|
|
2492
|
+
}
|
|
2462
2493
|
/** Re-feed the editor's autocomplete provider with the merged
|
|
2463
2494
|
* static-commands + skills list. Called on workspace switch and
|
|
2464
2495
|
* after every ``refreshSkillsCache`` so a newly uploaded skill
|
|
@@ -2466,7 +2497,8 @@ var ArbiTui = class {
|
|
|
2466
2497
|
rebuildAutocomplete() {
|
|
2467
2498
|
if (!this.editor) return;
|
|
2468
2499
|
const merged = toSlashCommandsWithSkills(
|
|
2469
|
-
this.skillsCache.map((s) => ({ slug: s.slug, description: s.description }))
|
|
2500
|
+
this.skillsCache.map((s) => ({ slug: s.slug, description: s.description })),
|
|
2501
|
+
this.commandsCache.map((c) => ({ name: c.name, description: c.description }))
|
|
2470
2502
|
);
|
|
2471
2503
|
this.editor.setAutocompleteProvider(new piTui.CombinedAutocompleteProvider(merged, process.cwd()));
|
|
2472
2504
|
}
|