@tryarcanist/cli 0.1.1 → 0.1.3

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.
Files changed (2) hide show
  1. package/dist/index.js +28 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -73,8 +73,22 @@ function validateApiUrl(url) {
73
73
  }
74
74
 
75
75
  // src/commands/create.ts
76
+ function validateRepoUrl(url) {
77
+ const shorthand = /^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/.test(url);
78
+ if (shorthand) return null;
79
+ const ssh = /^git@[^:]+:[^/]+\/[^/]+?(?:\.git)?$/.test(url);
80
+ if (ssh) return null;
81
+ const https = /^https?:\/\/github\.com\/[^/]+\/[^/]+?(?:\.git)?\/?$/.test(url);
82
+ if (https) return null;
83
+ return `Invalid repo URL: "${url}". Expected a GitHub URL (https://github.com/owner/repo) or owner/repo shorthand.`;
84
+ }
76
85
  async function createCommand(repoUrl, prompt, options) {
77
86
  const config = requireConfig();
87
+ const repoError = validateRepoUrl(repoUrl);
88
+ if (repoError) {
89
+ console.error(`Error: ${repoError}`);
90
+ process.exit(1);
91
+ }
78
92
  let sessionId;
79
93
  try {
80
94
  const sessionData = await apiFetch(config, "/api/sessions", {
@@ -213,18 +227,20 @@ function flattenSessionEvents(raw) {
213
227
  for (const event of raw) {
214
228
  const data = event.data ?? {};
215
229
  if (event.type === "sandbox_compaction_start") {
216
- merged.push({ type: "compaction_start", id: `cs-${data.timestamp ?? merged.length}` });
230
+ merged.push({ type: "compaction_start", id: `cs-${data.timestamp ?? merged.length}`, ...data.contextTokens != null ? { contextTokens: data.contextTokens } : {} });
217
231
  continue;
218
232
  }
219
233
  if (event.type === "sandbox_compaction_complete") {
220
- merged.push({ type: "compaction_complete", id: `cc-${data.timestamp ?? merged.length}` });
234
+ merged.push({ type: "compaction_complete", id: `cc-${data.timestamp ?? merged.length}`, ...data.contextTokensBefore != null ? { contextTokensBefore: data.contextTokensBefore } : {}, ...data.contextTokensAfter != null ? { contextTokensAfter: data.contextTokensAfter } : {} });
221
235
  continue;
222
236
  }
223
237
  if (event.type === "sandbox_context_fill_warning") {
224
238
  merged.push({
225
239
  type: "context_fill_warning",
226
240
  id: `cfw-${data.timestamp ?? merged.length}`,
227
- fillPercent: Number(data.fillPercent ?? 0)
241
+ fillPercent: Number(data.fillPercent ?? 0),
242
+ ...data.contextTokens != null ? { contextTokens: data.contextTokens } : {},
243
+ ...data.contextWindow != null ? { contextWindow: data.contextWindow } : {}
228
244
  });
229
245
  continue;
230
246
  }
@@ -382,11 +398,17 @@ ${event.text}
382
398
  ${event.answer ? `**Answer:** ${event.answer}
383
399
  ` : ""}`;
384
400
  case "compaction_start":
385
- return "*[context compacted]*\n";
401
+ return event.contextTokens ? `*[compacting context at ${Math.round(event.contextTokens / 1e3)}k tokens]*
402
+ ` : "*[compacting context]*\n";
386
403
  case "compaction_complete":
387
- return "";
404
+ if (event.contextTokensBefore && event.contextTokensAfter && event.contextTokensBefore > 0) {
405
+ const savedPct = Math.round((1 - event.contextTokensAfter / event.contextTokensBefore) * 100);
406
+ return `*[context compacted: ${Math.round(event.contextTokensBefore / 1e3)}k \u2192 ${Math.round(event.contextTokensAfter / 1e3)}k (${savedPct}% saved)]*
407
+ `;
408
+ }
409
+ return "*[context compacted]*\n";
388
410
  case "context_fill_warning":
389
- return `*[context ${event.fillPercent}% full]*
411
+ return `*[context ${Math.round(event.fillPercent * 100)}% full]*
390
412
  `;
391
413
  case "tool_truncated":
392
414
  return `*[${event.tool} output truncated]*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryarcanist/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "CLI for Arcanist — create and manage coding agent sessions",
5
5
  "type": "module",
6
6
  "bin": {