@arbidocs/cli 0.3.14 → 0.3.16
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 +24 -0
- package/dist/index.js +113 -9
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.3.16
|
|
4
|
+
|
|
5
|
+
[compare changes](https://github.com/arbicity/ARBI-frontend/compare/v0.3.15...HEAD)
|
|
6
|
+
|
|
7
|
+
### 🚀 Enhancements
|
|
8
|
+
|
|
9
|
+
- Handle arbi.message_queued SSE event in SDK and UI ([b5495225](https://github.com/arbicity/ARBI-frontend/commit/b5495225))
|
|
10
|
+
|
|
11
|
+
### 🏡 Chore
|
|
12
|
+
|
|
13
|
+
- Update OpenAPI schema with MessageQueuedEvent ([4b36ac65](https://github.com/arbicity/ARBI-frontend/commit/4b36ac65))
|
|
14
|
+
|
|
15
|
+
## v0.3.15
|
|
16
|
+
|
|
17
|
+
[compare changes](https://github.com/arbicity/ARBI-frontend/compare/v0.3.14...HEAD)
|
|
18
|
+
|
|
19
|
+
### 🚀 Enhancements
|
|
20
|
+
|
|
21
|
+
- Adopt message status field for failed message UI ([b267e7b8](https://github.com/arbicity/ARBI-frontend/commit/b267e7b8))
|
|
22
|
+
|
|
23
|
+
### 🩹 Fixes
|
|
24
|
+
|
|
25
|
+
- **cli:** Always start fresh conversation for background queries ([891ed884](https://github.com/arbicity/ARBI-frontend/commit/891ed884))
|
|
26
|
+
|
|
3
27
|
## v0.3.14
|
|
4
28
|
|
|
5
29
|
[compare changes](https://github.com/arbicity/ARBI-frontend/compare/v0.3.13...HEAD)
|
package/dist/index.js
CHANGED
|
@@ -3537,7 +3537,7 @@ function getLatestVersion(skipCache = false) {
|
|
|
3537
3537
|
}
|
|
3538
3538
|
}
|
|
3539
3539
|
function getCurrentVersion() {
|
|
3540
|
-
return "0.3.
|
|
3540
|
+
return "0.3.16";
|
|
3541
3541
|
}
|
|
3542
3542
|
function readChangelog(fromVersion, toVersion) {
|
|
3543
3543
|
try {
|
|
@@ -3590,17 +3590,17 @@ function showChangelog(fromVersion, toVersion) {
|
|
|
3590
3590
|
async function checkForUpdates(autoUpdate) {
|
|
3591
3591
|
try {
|
|
3592
3592
|
const latest = getLatestVersion();
|
|
3593
|
-
if (!latest || latest === "0.3.
|
|
3593
|
+
if (!latest || latest === "0.3.16") return;
|
|
3594
3594
|
if (autoUpdate) {
|
|
3595
3595
|
warn(`
|
|
3596
|
-
Your arbi version is out of date (${"0.3.
|
|
3596
|
+
Your arbi version is out of date (${"0.3.16"} \u2192 ${latest}). Updating...`);
|
|
3597
3597
|
child_process.execSync("npm install -g @arbidocs/cli@latest", { stdio: "inherit" });
|
|
3598
|
-
showChangelog("0.3.
|
|
3598
|
+
showChangelog("0.3.16", latest);
|
|
3599
3599
|
console.log(`Updated to ${latest}.`);
|
|
3600
3600
|
} else {
|
|
3601
3601
|
warn(
|
|
3602
3602
|
`
|
|
3603
|
-
Your arbi version is out of date (${"0.3.
|
|
3603
|
+
Your arbi version is out of date (${"0.3.16"} \u2192 ${latest}).
|
|
3604
3604
|
Run "arbi update" to upgrade, or "arbi update auto" to always stay up to date.`
|
|
3605
3605
|
);
|
|
3606
3606
|
}
|
|
@@ -3610,9 +3610,9 @@ Run "arbi update" to upgrade, or "arbi update auto" to always stay up to date.`
|
|
|
3610
3610
|
function hintUpdateOnError() {
|
|
3611
3611
|
try {
|
|
3612
3612
|
const cached = readCache();
|
|
3613
|
-
if (cached && cached.latest !== "0.3.
|
|
3613
|
+
if (cached && cached.latest !== "0.3.16") {
|
|
3614
3614
|
warn(
|
|
3615
|
-
`Your arbi version is out of date (${"0.3.
|
|
3615
|
+
`Your arbi version is out of date (${"0.3.16"} \u2192 ${cached.latest}). Run "arbi update".`
|
|
3616
3616
|
);
|
|
3617
3617
|
}
|
|
3618
3618
|
} catch {
|
|
@@ -4632,7 +4632,7 @@ function registerAskCommand(program2) {
|
|
|
4632
4632
|
workspaceId,
|
|
4633
4633
|
question,
|
|
4634
4634
|
docIds,
|
|
4635
|
-
previousResponseId,
|
|
4635
|
+
previousResponseId: null,
|
|
4636
4636
|
model: opts.config
|
|
4637
4637
|
});
|
|
4638
4638
|
addTask({
|
|
@@ -4735,6 +4735,109 @@ Error: ${message}`))
|
|
|
4735
4735
|
})()
|
|
4736
4736
|
);
|
|
4737
4737
|
}
|
|
4738
|
+
function chunkScore(chunk) {
|
|
4739
|
+
return chunk.metadata.rerank_score ?? chunk.metadata.score ?? 0;
|
|
4740
|
+
}
|
|
4741
|
+
function truncate(text, max) {
|
|
4742
|
+
const oneLine = text.replace(/\n/g, " ").trim();
|
|
4743
|
+
return oneLine.length > max ? oneLine.slice(0, max - 1) + "\u2026" : oneLine;
|
|
4744
|
+
}
|
|
4745
|
+
function fmtScore(score) {
|
|
4746
|
+
const pct = Math.min(Math.round(score * 100), 100);
|
|
4747
|
+
return `[${pct}%]`;
|
|
4748
|
+
}
|
|
4749
|
+
function registerFindCommand(program2) {
|
|
4750
|
+
program2.command("find <query...>").description("Search documents without LLM generation (retrieve only)").option("-w, --workspace <id>", "Workspace ID (defaults to selected workspace)").option("-m, --mode <mode>", "Search mode: semantic, keyword, hybrid", "semantic").option("-d, --docs <ids>", "Comma-separated document IDs to search within").option("--min-score <n>", "Minimum relevance score 0-1", "0.2").option("-l, --limit <n>", "Max results to display", "20").option("--flat", "Flat list sorted by relevance (instead of grouped by document)").option("--toc <ids>", "Comma-separated doc IDs to fetch table of contents for").option("--full-context <ids>", "Comma-separated doc IDs to fetch full content for").option("--json", "Raw JSON output for scripting").action(
|
|
4751
|
+
(words, opts) => runAction(async () => {
|
|
4752
|
+
const query = words.join(" ");
|
|
4753
|
+
const { arbi, workspaceId } = await resolveWorkspace(opts.workspace);
|
|
4754
|
+
let docIds;
|
|
4755
|
+
if (opts.docs) {
|
|
4756
|
+
docIds = opts.docs.split(",").map((id) => id.trim());
|
|
4757
|
+
} else {
|
|
4758
|
+
const docs = await sdk.documents.listDocuments(arbi);
|
|
4759
|
+
docIds = docs.map((d) => d.external_id);
|
|
4760
|
+
}
|
|
4761
|
+
if (docIds.length === 0) {
|
|
4762
|
+
console.log("No documents found in workspace.");
|
|
4763
|
+
return;
|
|
4764
|
+
}
|
|
4765
|
+
const searchMode = opts.mode ?? "semantic";
|
|
4766
|
+
const tocDocIds = opts.toc ? opts.toc.split(",").map((id) => id.trim()) : void 0;
|
|
4767
|
+
const fullContextDocIds = opts.fullContext ? opts.fullContext.split(",").map((id) => id.trim()) : void 0;
|
|
4768
|
+
const result = await sdk.assistant.retrieve({
|
|
4769
|
+
arbi,
|
|
4770
|
+
workspaceId,
|
|
4771
|
+
query,
|
|
4772
|
+
docIds,
|
|
4773
|
+
searchMode,
|
|
4774
|
+
tocDocIds,
|
|
4775
|
+
fullContextDocIds
|
|
4776
|
+
});
|
|
4777
|
+
const allChunks = [];
|
|
4778
|
+
if (result.retrieval_chunk?.tool_responses) {
|
|
4779
|
+
for (const chunks of Object.values(result.retrieval_chunk.tool_responses)) {
|
|
4780
|
+
allChunks.push(...chunks);
|
|
4781
|
+
}
|
|
4782
|
+
}
|
|
4783
|
+
const minScore = parseFloat(opts.minScore ?? "0.2");
|
|
4784
|
+
const limit = parseInt(opts.limit ?? "20", 10);
|
|
4785
|
+
const filtered = allChunks.filter((c) => chunkScore(c) >= minScore).sort((a, b) => chunkScore(b) - chunkScore(a)).slice(0, limit);
|
|
4786
|
+
const uniqueDocs = new Set(filtered.map((c) => c.metadata.doc_ext_id));
|
|
4787
|
+
if (opts.json) {
|
|
4788
|
+
console.log(JSON.stringify(result, null, 2));
|
|
4789
|
+
return;
|
|
4790
|
+
}
|
|
4791
|
+
if (filtered.length === 0) {
|
|
4792
|
+
console.log("No results found.");
|
|
4793
|
+
return;
|
|
4794
|
+
}
|
|
4795
|
+
console.log(
|
|
4796
|
+
`
|
|
4797
|
+
Found ${chalk2__default.default.bold(String(filtered.length))} result${filtered.length === 1 ? "" : "s"} across ${chalk2__default.default.bold(String(uniqueDocs.size))} document${uniqueDocs.size === 1 ? "" : "s"}
|
|
4798
|
+
`
|
|
4799
|
+
);
|
|
4800
|
+
if (opts.flat) {
|
|
4801
|
+
for (let i = 0; i < filtered.length; i++) {
|
|
4802
|
+
const chunk = filtered[i];
|
|
4803
|
+
const score = fmtScore(chunkScore(chunk));
|
|
4804
|
+
const doc = chunk.metadata.doc_title ?? chunk.metadata.doc_ext_id ?? "";
|
|
4805
|
+
const page = chunk.metadata.page_number ? `p.${chunk.metadata.page_number}` : "";
|
|
4806
|
+
const preview = truncate(chunk.content, 80);
|
|
4807
|
+
console.log(
|
|
4808
|
+
` ${chalk2__default.default.dim(String(i + 1).padStart(2, " "))}. ${chalk2__default.default.yellow(score)} ${chalk2__default.default.cyan(doc)} ${chalk2__default.default.dim(page)}`
|
|
4809
|
+
);
|
|
4810
|
+
console.log(` ${chalk2__default.default.dim(preview)}`);
|
|
4811
|
+
}
|
|
4812
|
+
console.log();
|
|
4813
|
+
return;
|
|
4814
|
+
}
|
|
4815
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
4816
|
+
for (const chunk of filtered) {
|
|
4817
|
+
const key = chunk.metadata.doc_ext_id ?? "unknown";
|
|
4818
|
+
if (!grouped.has(key)) grouped.set(key, []);
|
|
4819
|
+
grouped.get(key).push(chunk);
|
|
4820
|
+
}
|
|
4821
|
+
for (const [, chunks] of grouped) {
|
|
4822
|
+
const docTitle = chunks[0].metadata.doc_title ?? chunks[0].metadata.doc_ext_id ?? "Unknown";
|
|
4823
|
+
const hitCount = chunks.length;
|
|
4824
|
+
const header = `${docTitle} (${hitCount} hit${hitCount === 1 ? "" : "s"})`;
|
|
4825
|
+
console.log(
|
|
4826
|
+
`${chalk2__default.default.dim("\u2500\u2500")} ${chalk2__default.default.bold(header)} ${chalk2__default.default.dim("\u2500".repeat(Math.max(0, 50 - header.length)))}`
|
|
4827
|
+
);
|
|
4828
|
+
for (const chunk of chunks) {
|
|
4829
|
+
const score = fmtScore(chunkScore(chunk));
|
|
4830
|
+
const page = chunk.metadata.page_number ? `p.${chunk.metadata.page_number}` : "";
|
|
4831
|
+
const preview = truncate(chunk.content, 72);
|
|
4832
|
+
console.log(
|
|
4833
|
+
` ${chalk2__default.default.yellow(score)} ${chalk2__default.default.dim(page.padEnd(6))} ${chalk2__default.default.dim(preview)}`
|
|
4834
|
+
);
|
|
4835
|
+
}
|
|
4836
|
+
console.log();
|
|
4837
|
+
}
|
|
4838
|
+
})()
|
|
4839
|
+
);
|
|
4840
|
+
}
|
|
4738
4841
|
function colorize2(level, text) {
|
|
4739
4842
|
if (level === "success") return chalk2__default.default.green(text);
|
|
4740
4843
|
if (level === "error") return chalk2__default.default.red(text);
|
|
@@ -5959,7 +6062,7 @@ console.info = (...args) => {
|
|
|
5959
6062
|
_origInfo(...args);
|
|
5960
6063
|
};
|
|
5961
6064
|
var program = new commander.Command();
|
|
5962
|
-
program.name("arbi").description("ARBI CLI \u2014 interact with ARBI from the terminal").version("0.3.
|
|
6065
|
+
program.name("arbi").description("ARBI CLI \u2014 interact with ARBI from the terminal").version("0.3.16");
|
|
5963
6066
|
registerConfigCommand(program);
|
|
5964
6067
|
registerLoginCommand(program);
|
|
5965
6068
|
registerRegisterCommand(program);
|
|
@@ -5970,6 +6073,7 @@ registerDocsCommand(program);
|
|
|
5970
6073
|
registerUploadCommand(program);
|
|
5971
6074
|
registerDownloadCommand(program);
|
|
5972
6075
|
registerAskCommand(program);
|
|
6076
|
+
registerFindCommand(program);
|
|
5973
6077
|
registerWatchCommand(program);
|
|
5974
6078
|
registerContactsCommand(program);
|
|
5975
6079
|
registerDmCommand(program);
|