@arbidocs/tui 0.3.79 → 0.3.80
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 +17 -21
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -444,11 +444,6 @@ var ArbiEditor = class extends piTui.Editor {
|
|
|
444
444
|
onCtrlW;
|
|
445
445
|
/** Callback when Ctrl+N is pressed (new conversation). */
|
|
446
446
|
onCtrlN;
|
|
447
|
-
/** Callback when Alt+1..9 is pressed (jump to citation N from
|
|
448
|
-
* the last response). The handler gets the integer ``1`` through
|
|
449
|
-
* ``9``; it is responsible for checking whether that citation
|
|
450
|
-
* exists and surfacing a useful message if not. */
|
|
451
|
-
onCitationKey;
|
|
452
447
|
/**
|
|
453
448
|
* Callback fired after every keystroke that mutates the buffer.
|
|
454
449
|
*
|
|
@@ -502,14 +497,6 @@ var ArbiEditor = class extends piTui.Editor {
|
|
|
502
497
|
this.onCtrlN?.();
|
|
503
498
|
return;
|
|
504
499
|
}
|
|
505
|
-
if (this.onCitationKey) {
|
|
506
|
-
for (let n = 1; n <= 9; n++) {
|
|
507
|
-
if (piTui.matchesKey(data, piTui.Key.alt(String(n)))) {
|
|
508
|
-
this.onCitationKey(n);
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
500
|
super.handleInput(data);
|
|
514
501
|
if (this.onBufferChange) {
|
|
515
502
|
const current = this.getText();
|
|
@@ -630,7 +617,6 @@ function formatHelpText() {
|
|
|
630
617
|
" Ctrl+W \u2014 Switch workspace",
|
|
631
618
|
" Ctrl+D \u2014 Exit",
|
|
632
619
|
" Escape \u2014 Abort streaming",
|
|
633
|
-
" Alt+1..9 \u2014 Jump to citation N from the last response",
|
|
634
620
|
"",
|
|
635
621
|
"Skills: any workspace SKILL.md with `user-invocable: true` becomes a",
|
|
636
622
|
" ``/<slug>`` command \u2014 type it like a regular slash command and the",
|
|
@@ -1971,13 +1957,15 @@ function extractStepDetails(data) {
|
|
|
1971
1957
|
if (d.message) result.args = d.message;
|
|
1972
1958
|
return result.tool || result.args || result.result ? result : void 0;
|
|
1973
1959
|
}
|
|
1974
|
-
async function streamResponse(tui, response) {
|
|
1960
|
+
async function streamResponse(tui, response, docNames) {
|
|
1975
1961
|
tui.chatLog.startAssistant();
|
|
1976
1962
|
tui.state.activityStatus = "streaming";
|
|
1977
1963
|
tui.requestRender();
|
|
1978
1964
|
let accumulated = "";
|
|
1979
1965
|
let elapsedTime = null;
|
|
1980
1966
|
let firstToken = true;
|
|
1967
|
+
let lastStepIndex = null;
|
|
1968
|
+
let lastStepLabel = "";
|
|
1981
1969
|
const callbacks = {
|
|
1982
1970
|
onStreamStart: (data) => {
|
|
1983
1971
|
if (data.assistant_message_ext_id) {
|
|
@@ -1994,8 +1982,11 @@ async function streamResponse(tui, response) {
|
|
|
1994
1982
|
tui.requestRender();
|
|
1995
1983
|
},
|
|
1996
1984
|
onAgentStep: (data) => {
|
|
1997
|
-
const label = sdk.formatAgentStepLabel(data);
|
|
1985
|
+
const label = sdk.formatAgentStepLabel(data, docNames);
|
|
1998
1986
|
if (label) {
|
|
1987
|
+
if (data.index === lastStepIndex && label === lastStepLabel) return;
|
|
1988
|
+
lastStepIndex = data.index;
|
|
1989
|
+
lastStepLabel = label;
|
|
1999
1990
|
tui.chatLog.addAgentStep(label, extractStepDetails(data));
|
|
2000
1991
|
tui.requestRender();
|
|
2001
1992
|
}
|
|
@@ -2386,7 +2377,6 @@ var ArbiTui = class {
|
|
|
2386
2377
|
editor.onCtrlD = () => this.shutdown();
|
|
2387
2378
|
editor.onCtrlW = () => this.handleSubmit("/workspaces");
|
|
2388
2379
|
editor.onCtrlN = () => this.handleSubmit("/new");
|
|
2389
|
-
editor.onCitationKey = (n) => this.handleSubmit(`/cite ${n}`);
|
|
2390
2380
|
editor.onBufferChange = (text) => this.handleBufferChange(text);
|
|
2391
2381
|
return editor;
|
|
2392
2382
|
}
|
|
@@ -2553,6 +2543,10 @@ var ArbiTui = class {
|
|
|
2553
2543
|
try {
|
|
2554
2544
|
const docs = await sdk.documents.listDocuments(this.workspaceContext.arbi);
|
|
2555
2545
|
const docIds = docs.map((d) => d.external_id);
|
|
2546
|
+
const docNames = {};
|
|
2547
|
+
for (const d of docs) {
|
|
2548
|
+
if (d.external_id && d.file_name) docNames[d.external_id] = d.file_name;
|
|
2549
|
+
}
|
|
2556
2550
|
const session = this.store.getChatSession();
|
|
2557
2551
|
const previousResponseId = this.state.conversationMessageId ?? session.lastMessageExtId;
|
|
2558
2552
|
const response = await sdk.assistant.queryAssistant({
|
|
@@ -2563,13 +2557,15 @@ var ArbiTui = class {
|
|
|
2563
2557
|
docIds,
|
|
2564
2558
|
previousResponseId
|
|
2565
2559
|
});
|
|
2566
|
-
const result = await streamResponse(this, response);
|
|
2560
|
+
const result = await streamResponse(this, response, docNames);
|
|
2567
2561
|
if (this.lastMetadata) {
|
|
2568
2562
|
const n = sdk.countCitations(this.lastMetadata);
|
|
2569
2563
|
if (n > 0) {
|
|
2570
|
-
const
|
|
2571
|
-
|
|
2572
|
-
|
|
2564
|
+
const plural = n === 1 ? "" : "s";
|
|
2565
|
+
this.chatLog.addSystem(
|
|
2566
|
+
`${n} citation${plural} \u2014 type /cite to browse, /cite N to view one`,
|
|
2567
|
+
"info"
|
|
2568
|
+
);
|
|
2573
2569
|
}
|
|
2574
2570
|
}
|
|
2575
2571
|
if (result.assistantMessageExtId) {
|