@tryarcanist/cli 0.1.8 → 0.1.10
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 +12 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,9 +4,14 @@
|
|
|
4
4
|
import { createRequire } from "module";
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
|
|
7
|
+
// ../../shared/utils/url.ts
|
|
8
|
+
function normalizeBaseUrl(url) {
|
|
9
|
+
return url.replace(/\/+$/, "");
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
// src/api.ts
|
|
8
13
|
async function apiRequest(config, path, init) {
|
|
9
|
-
const res = await fetch(`${config.apiUrl}${path}`, {
|
|
14
|
+
const res = await fetch(`${normalizeBaseUrl(config.apiUrl)}${path}`, {
|
|
10
15
|
...init,
|
|
11
16
|
headers: {
|
|
12
17
|
"Content-Type": "application/json",
|
|
@@ -40,14 +45,15 @@ var CONFIG_DIR = join(homedir(), ".arcanist");
|
|
|
40
45
|
var CONFIG_FILE = join(CONFIG_DIR, "config.json");
|
|
41
46
|
function loadConfig() {
|
|
42
47
|
try {
|
|
43
|
-
|
|
48
|
+
const config = JSON.parse(readFileSync(CONFIG_FILE, "utf-8"));
|
|
49
|
+
return { ...config, apiUrl: normalizeBaseUrl(config.apiUrl) };
|
|
44
50
|
} catch {
|
|
45
51
|
return null;
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
54
|
function saveConfig(config) {
|
|
49
55
|
mkdirSync(CONFIG_DIR, { recursive: true, mode: 448 });
|
|
50
|
-
writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + "\n", { mode: 384 });
|
|
56
|
+
writeFileSync(CONFIG_FILE, JSON.stringify({ ...config, apiUrl: normalizeBaseUrl(config.apiUrl) }, null, 2) + "\n", { mode: 384 });
|
|
51
57
|
}
|
|
52
58
|
function requireConfig() {
|
|
53
59
|
const config = loadConfig();
|
|
@@ -146,7 +152,7 @@ async function loginCommand(options) {
|
|
|
146
152
|
process.exit(1);
|
|
147
153
|
}
|
|
148
154
|
}
|
|
149
|
-
const apiUrl = options.apiUrl ?? loadConfig()?.apiUrl ?? "https://app.tryarcanist.com";
|
|
155
|
+
const apiUrl = normalizeBaseUrl(options.apiUrl ?? loadConfig()?.apiUrl ?? "https://app.tryarcanist.com");
|
|
150
156
|
saveConfig({ apiUrl, token });
|
|
151
157
|
console.log(`Logged in. API: ${apiUrl}`);
|
|
152
158
|
try {
|
|
@@ -533,12 +539,6 @@ function resolveAuthoritativePromptEvents(raw) {
|
|
|
533
539
|
}
|
|
534
540
|
|
|
535
541
|
// src/utils/session-output.ts
|
|
536
|
-
function flattenSessionEvents2(raw) {
|
|
537
|
-
return flattenSessionEvents(raw);
|
|
538
|
-
}
|
|
539
|
-
function partitionEventsByPrompt2(allEvents, promptIds) {
|
|
540
|
-
return partitionEventsByPrompt(allEvents, promptIds);
|
|
541
|
-
}
|
|
542
542
|
function formatDate(value) {
|
|
543
543
|
const date = new Date(value);
|
|
544
544
|
if (Number.isNaN(date.getTime())) return value;
|
|
@@ -599,7 +599,7 @@ function formatNumber(value) {
|
|
|
599
599
|
function renderSessionTranscript(exportData) {
|
|
600
600
|
const lines = [];
|
|
601
601
|
const promptIds = exportData.prompts.map((prompt) => prompt.id);
|
|
602
|
-
const eventBuckets =
|
|
602
|
+
const eventBuckets = partitionEventsByPrompt(exportData.events, promptIds);
|
|
603
603
|
lines.push("# Session transcript\n");
|
|
604
604
|
if (exportData.session.repoUrl) lines.push(`**Repo:** ${exportData.session.repoUrl} `);
|
|
605
605
|
lines.push(`**Session:** ${exportData.session.id.slice(0, 8)} `);
|
|
@@ -613,7 +613,7 @@ function renderSessionTranscript(exportData) {
|
|
|
613
613
|
for (let i = 0; i < exportData.prompts.length; i++) {
|
|
614
614
|
const prompt = exportData.prompts[i];
|
|
615
615
|
const rawEvents = eventBuckets.get(prompt.id) ?? [];
|
|
616
|
-
const events =
|
|
616
|
+
const events = flattenSessionEvents(resolveAuthoritativePromptEvents(rawEvents));
|
|
617
617
|
lines.push("---\n");
|
|
618
618
|
lines.push(`## Turn ${i + 1}
|
|
619
619
|
`);
|