@arjun-shah/agentbar-cli 0.1.7 → 0.1.9
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/README.md +3 -1
- package/bin/agentbar.js +77 -53
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -20,9 +20,11 @@ npm install -g @arjun-shah/agentbar-cli
|
|
|
20
20
|
agentbar init
|
|
21
21
|
agentbar snippet
|
|
22
22
|
agentbar set siteUrl https://your-site.com
|
|
23
|
+
agentbar stats
|
|
23
24
|
```
|
|
24
25
|
|
|
25
|
-
The CLI writes `agentbar.config.json` in your project directory.
|
|
26
|
+
The CLI writes `agentbar.config.json` in your project directory. `agentbar init` only asks
|
|
27
|
+
for your site URL.
|
|
26
28
|
|
|
27
29
|
## Customization
|
|
28
30
|
|
package/bin/agentbar.js
CHANGED
|
@@ -90,6 +90,35 @@ const saveConfig = (config) => {
|
|
|
90
90
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
+
const normalizeUrl = (value) => {
|
|
94
|
+
if (!value || typeof value !== "string") {
|
|
95
|
+
return "";
|
|
96
|
+
}
|
|
97
|
+
const trimmed = value.trim();
|
|
98
|
+
if (!trimmed) {
|
|
99
|
+
return "";
|
|
100
|
+
}
|
|
101
|
+
if (trimmed.startsWith("http://") || trimmed.startsWith("https://")) {
|
|
102
|
+
return trimmed;
|
|
103
|
+
}
|
|
104
|
+
return `https://${trimmed}`;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const resolveSiteKey = (config) => {
|
|
108
|
+
if (config.siteKey) {
|
|
109
|
+
return config.siteKey;
|
|
110
|
+
}
|
|
111
|
+
const normalized = normalizeUrl(config.siteUrl);
|
|
112
|
+
if (!normalized) {
|
|
113
|
+
return "";
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
return new URL(normalized).hostname;
|
|
117
|
+
} catch {
|
|
118
|
+
return "";
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
93
122
|
const renderSnippet = (config) => {
|
|
94
123
|
const lines = [
|
|
95
124
|
"<script",
|
|
@@ -289,6 +318,7 @@ const printHelp = () => {
|
|
|
289
318
|
console.log(" agentbar init Interactive setup and snippet output");
|
|
290
319
|
console.log(" agentbar snippet Print current embed snippet");
|
|
291
320
|
console.log(" agentbar set <key> <v> Update config value");
|
|
321
|
+
console.log(" agentbar stats Fetch indexing status from the API");
|
|
292
322
|
console.log(" agentbar config Print config JSON");
|
|
293
323
|
console.log(" agentbar help Show help\n");
|
|
294
324
|
console.log("Config keys:");
|
|
@@ -343,59 +373,12 @@ const init = async () => {
|
|
|
343
373
|
});
|
|
344
374
|
|
|
345
375
|
try {
|
|
346
|
-
|
|
347
|
-
config.
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
);
|
|
352
|
-
config.siteKey = await ask(rl, "Site key (optional)", config.siteKey);
|
|
353
|
-
config.themeColor = await ask(rl, "Theme color", config.themeColor);
|
|
354
|
-
config.position = await ask(rl, "Position (left/right/bottom)", config.position);
|
|
355
|
-
config.title = await ask(rl, "Widget title", config.title);
|
|
356
|
-
config.subtitle = await ask(rl, "Widget subtitle", config.subtitle);
|
|
357
|
-
config.buttonLabel = await ask(rl, "Button label", config.buttonLabel);
|
|
358
|
-
config.fontFamily = await ask(rl, "Font family", config.fontFamily);
|
|
359
|
-
config.inputPlaceholder = await ask(rl, "Input placeholder", config.inputPlaceholder);
|
|
360
|
-
config.sendLabel = await ask(rl, "Send button label", config.sendLabel);
|
|
361
|
-
const suggestionInput = await ask(
|
|
362
|
-
rl,
|
|
363
|
-
"Suggestions (pipe or comma separated)",
|
|
364
|
-
config.suggestions.join(" | ")
|
|
365
|
-
);
|
|
366
|
-
config.suggestions = suggestionInput
|
|
367
|
-
.split(/[|,]/)
|
|
368
|
-
.map((value) => value.trim())
|
|
369
|
-
.filter(Boolean);
|
|
370
|
-
config.greeting = await ask(rl, "Greeting (optional)", config.greeting);
|
|
371
|
-
config.draggable =
|
|
372
|
-
(await ask(rl, "Draggable launcher (true/false)", String(config.draggable))) === "true";
|
|
373
|
-
config.persistPosition =
|
|
374
|
-
(await ask(rl, "Persist position (true/false)", String(config.persistPosition))) === "true";
|
|
375
|
-
config.openOnLoad = (await ask(rl, "Open on load (true/false)", String(config.openOnLoad))) === "true";
|
|
376
|
-
config.showReset = (await ask(rl, "Show reset button (true/false)", String(config.showReset))) === "true";
|
|
377
|
-
config.persist = (await ask(rl, "Persist chat (true/false)", String(config.persist))) === "true";
|
|
378
|
-
config.showTypingIndicator =
|
|
379
|
-
(await ask(rl, "Show typing indicator (true/false)", String(config.showTypingIndicator))) ===
|
|
380
|
-
"true";
|
|
381
|
-
config.showExport =
|
|
382
|
-
(await ask(rl, "Show export button (true/false)", String(config.showExport))) === "true";
|
|
383
|
-
config.exportLabel = await ask(rl, "Export label", config.exportLabel);
|
|
384
|
-
config.showScrollButton =
|
|
385
|
-
(await ask(rl, "Show scroll button (true/false)", String(config.showScrollButton))) ===
|
|
386
|
-
"true";
|
|
387
|
-
config.scrollLabel = await ask(rl, "Scroll button label", config.scrollLabel);
|
|
388
|
-
config.showMinimize =
|
|
389
|
-
(await ask(rl, "Show minimize button (true/false)", String(config.showMinimize))) ===
|
|
390
|
-
"true";
|
|
391
|
-
config.minimizedOnLoad =
|
|
392
|
-
(await ask(rl, "Minimized on load (true/false)", String(config.minimizedOnLoad))) ===
|
|
393
|
-
"true";
|
|
394
|
-
config.showTimestamps =
|
|
395
|
-
(await ask(rl, "Show timestamps (true/false)", String(config.showTimestamps))) === "true";
|
|
396
|
-
config.autoScroll =
|
|
397
|
-
(await ask(rl, "Auto scroll (true/false)", String(config.autoScroll))) === "true";
|
|
398
|
-
config.autoIngest = (await ask(rl, "Auto ingest (true/false)", String(config.autoIngest))) === "true";
|
|
376
|
+
const siteUrlInput = await ask(rl, "Site URL", config.siteUrl || "https://your-site.com");
|
|
377
|
+
config.siteUrl = normalizeUrl(siteUrlInput);
|
|
378
|
+
if (!config.siteUrl) {
|
|
379
|
+
config.siteUrl = "https://your-site.com";
|
|
380
|
+
}
|
|
381
|
+
config.siteKey = resolveSiteKey(config);
|
|
399
382
|
} finally {
|
|
400
383
|
rl.close();
|
|
401
384
|
}
|
|
@@ -406,6 +389,44 @@ const init = async () => {
|
|
|
406
389
|
console.log(renderSnippet(config));
|
|
407
390
|
};
|
|
408
391
|
|
|
392
|
+
const printStats = async () => {
|
|
393
|
+
const config = loadConfig();
|
|
394
|
+
const apiBase = (config.apiBase || DEFAULT_CONFIG.apiBase).replace(/\/$/, "");
|
|
395
|
+
const siteKey = resolveSiteKey(config);
|
|
396
|
+
|
|
397
|
+
if (!siteKey) {
|
|
398
|
+
console.error("Missing siteUrl. Run `agentbar init` or `agentbar set siteUrl <url>` first.");
|
|
399
|
+
process.exit(1);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
try {
|
|
403
|
+
const response = await fetch(`${apiBase}/api/status`);
|
|
404
|
+
if (!response.ok) {
|
|
405
|
+
const data = await response.json().catch(() => ({}));
|
|
406
|
+
throw new Error(data?.error || `Status request failed (${response.status})`);
|
|
407
|
+
}
|
|
408
|
+
const data = await response.json();
|
|
409
|
+
const items = Array.isArray(data?.items) ? data.items : [];
|
|
410
|
+
const matched = items.filter((item) => item.key === siteKey);
|
|
411
|
+
if (!matched.length) {
|
|
412
|
+
console.log("No indexed content found for", siteKey);
|
|
413
|
+
console.log("Send a message in the widget to trigger ingest.");
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
matched.forEach((item) => {
|
|
417
|
+
console.log(`Site: ${item.url}`);
|
|
418
|
+
console.log(`Pages indexed: ${item.pages?.length ?? 0}`);
|
|
419
|
+
console.log(`Chunks: ${item.chunkCount ?? 0}`);
|
|
420
|
+
console.log(`Updated: ${item.updatedAt ? new Date(item.updatedAt).toLocaleString() : "N/A"}`);
|
|
421
|
+
console.log("");
|
|
422
|
+
});
|
|
423
|
+
} catch (error) {
|
|
424
|
+
const message = error instanceof Error ? error.message : "Failed to load stats.";
|
|
425
|
+
console.error(message);
|
|
426
|
+
process.exit(1);
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
|
|
409
430
|
const setValue = (key, value) => {
|
|
410
431
|
if (!key || typeof value === "undefined") {
|
|
411
432
|
console.error("Usage: agentbar set <key> <value>");
|
|
@@ -483,6 +504,9 @@ const main = async () => {
|
|
|
483
504
|
console.log(renderSnippet(config));
|
|
484
505
|
return;
|
|
485
506
|
}
|
|
507
|
+
case "stats":
|
|
508
|
+
await printStats();
|
|
509
|
+
return;
|
|
486
510
|
case "set":
|
|
487
511
|
setValue(arg1, arg2);
|
|
488
512
|
return;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arjun-shah/agentbar-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Agent Plugin Bar CLI helper.",
|
|
6
6
|
"bin": {
|
|
7
|
-
"agentbar": "
|
|
7
|
+
"agentbar": "bin/agentbar.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"bin"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/arjunkshah/plug-your-agent.git"
|
|
15
|
+
"url": "git+https://github.com/arjunkshah/plug-your-agent.git"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"agent",
|