@dashclaw/cli 0.6.2 → 0.7.1

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 CHANGED
@@ -66,6 +66,15 @@ Stop the local server (and the Docker DB if `up` started it).
66
66
  npx dashclaw down
67
67
  ```
68
68
 
69
+ ### `dashclaw import <bundle.json>`
70
+
71
+ Load a workspace carry-out bundle — the file **Export workspace** downloads on a trial's `/connect` card (or `GET /api/workspace/export` on any instance) — into the configured instance. Policies, guard decisions, action records, open loops, assumptions, and agent identities carry over; API keys, OAuth tokens, and secret values never ride a bundle. Idempotent: re-running skips rows that already exist.
72
+
73
+ ```bash
74
+ DASHCLAW_BASE_URL=http://localhost:3000 DASHCLAW_API_KEY=oc_live_... \
75
+ dashclaw import dashclaw-workspace-*.json
76
+ ```
77
+
69
78
  ### `dashclaw approvals`
70
79
 
71
80
  Interactive inbox for all pending approval requests. Use arrow keys to navigate, `A` to approve, `D` to deny, `O` to open the replay link, `Q` to quit.
package/bin/dashclaw.js CHANGED
@@ -86,6 +86,8 @@ ${bold('Usage:')}
86
86
  --port <n> Server port (default: 3000)
87
87
  --no-browser Do not open the browser when ready
88
88
  dashclaw down Stop the local DashClaw server (and Docker DB if we started it)
89
+ dashclaw import <bundle.json> Import a workspace carry-out bundle (from /api/workspace/export)
90
+ into this instance — idempotent; keys/secrets never ride a bundle
89
91
  dashclaw approvals Interactive approval inbox
90
92
  dashclaw approve <actionId> [--reason] Approve an action
91
93
  dashclaw deny <actionId> [--reason] Deny an action
@@ -565,6 +567,38 @@ async function cmdInstall() {
565
567
  }
566
568
  }
567
569
 
570
+ // -- import (v7.2 graduation path) --------------------------------------------
571
+
572
+ /*
573
+ * Ingest a workspace carry-out bundle (the file /api/workspace/export
574
+ * downloads) into the configured instance. HTTP like every other post-up
575
+ * command; the route is idempotent so re-running is safe.
576
+ */
577
+ async function cmdImport() {
578
+ const file = args[1];
579
+ if (!file || file.startsWith('--')) {
580
+ console.error('Usage: dashclaw import <bundle.json> (the file downloaded from your trial\'s "Export workspace")');
581
+ process.exitCode = 1;
582
+ return;
583
+ }
584
+ try {
585
+ let bundle;
586
+ try {
587
+ bundle = JSON.parse(readFileSync(file, 'utf8'));
588
+ } catch (err) {
589
+ throw new Error(err.code === 'ENOENT' ? `File not found: ${file}` : `${file} is not valid JSON`);
590
+ }
591
+ const data = await apiRequest({ baseUrl, apiKey }, 'POST', '/api/workspace/import', { body: bundle });
592
+ console.log(green(`Imported ${data.imported} rows (${data.skipped} skipped — already present or missing their id).`));
593
+ for (const [table, c] of Object.entries(data.counts || {})) {
594
+ console.log(` ${table}: +${c.imported}${c.skipped ? ` (${c.skipped} skipped)` : ''}`);
595
+ }
596
+ } catch (err) {
597
+ console.error(red(`Error: ${err.message}`));
598
+ process.exitCode = 1;
599
+ }
600
+ }
601
+
568
602
  // -- up / down (one-command local install) -----------------------------------
569
603
 
570
604
  async function cmdUp() {
@@ -1298,7 +1332,7 @@ async function cmdEnv() {
1298
1332
 
1299
1333
  // -- Router -------------------------------------------------------------------
1300
1334
 
1301
- const COMMANDS_NEEDING_CONFIG = new Set(['approvals', 'approve', 'deny', 'doctor', 'code', 'prompts', 'inbox', 'behavior', 'posture', 'next', 'env', 'halt']);
1335
+ const COMMANDS_NEEDING_CONFIG = new Set(['approvals', 'approve', 'deny', 'doctor', 'code', 'prompts', 'inbox', 'behavior', 'posture', 'next', 'env', 'halt', 'import']);
1302
1336
  // `install` deliberately omitted: provisioning hooks and AGENTS.md shouldn't
1303
1337
  // require the user to have already configured API keys. If config happens to
1304
1338
  // be present, install will pick up baseUrl for the AGENTS.md instance link.
@@ -1344,6 +1378,7 @@ const COMMAND_HANDLERS = {
1344
1378
  code: cmdCode,
1345
1379
  up: cmdUp,
1346
1380
  down: cmdDown,
1381
+ import: cmdImport,
1347
1382
  install: cmdInstall,
1348
1383
  codex: cmdCodex,
1349
1384
  prompts: cmdPrompts,
@@ -13,40 +13,55 @@ import * as tar from 'tar';
13
13
  const REPO = 'ucsandman/DashClaw';
14
14
 
15
15
  /**
16
- * Fetch the latest published platform version from the npm registry.
17
- * The `dashclaw` npm package version mirrors the platform version (unified versioning).
16
+ * Resolve the latest installable platform version.
18
17
  *
19
- * npm's version number is only trusted after verifying its git tag exists —
20
- * a publish that shipped without cutting its tag would otherwise 404 every
21
- * install. When the tag is missing, fall back to the latest GitHub release.
18
+ * GitHub releases are the platform-version pointer: a GitHub Release rides
19
+ * every ship, while npm's `dashclaw` version lags behind on platform-only
20
+ * releases the SDK packages republish only when SDK source changes, which
21
+ * once froze fresh installs at platform 4.63.2 while main was at 4.66.0
22
+ * (dropping, among others, the workspace-import route that trial graduation
23
+ * depends on). npm latest stays as the fallback for GitHub API failures or
24
+ * rate limits; either path is only trusted after a HEAD check confirms the
25
+ * tag's tarball actually exists.
22
26
  *
23
27
  * @param {typeof fetch} fetchImpl - injectable for tests
24
28
  * @param {{ error: (...args: any[]) => void }} logger
25
- * @returns {Promise<string>} semver string e.g. '4.21.0'
29
+ * @returns {Promise<string>} semver string e.g. '4.66.0'
26
30
  */
27
31
  export async function resolveAppVersion(fetchImpl = fetch, logger = console) {
32
+ try {
33
+ const rel = await fetchImpl(`https://api.github.com/repos/${REPO}/releases/latest`, {
34
+ headers: { accept: 'application/vnd.github+json' },
35
+ });
36
+ if (rel.ok) {
37
+ const tagName = (await rel.json()).tag_name;
38
+ const version = typeof tagName === 'string' ? tagName.replace(/^v/, '') : null;
39
+ if (version) {
40
+ const head = await fetchImpl(tarballUrl(version), { method: 'HEAD' });
41
+ if (head.ok) return version;
42
+ }
43
+ }
44
+ } catch {
45
+ // Network/API failure — fall through to the npm path below.
46
+ }
47
+
28
48
  const res = await fetchImpl('https://registry.npmjs.org/dashclaw/latest');
29
49
  if (!res.ok) {
30
- throw new Error(`npm registry lookup failed (${res.status}) — check your network and retry.`);
50
+ throw new Error(
51
+ `Version lookup failed: GitHub releases unavailable and npm registry answered ${res.status} — check your network and retry.`,
52
+ );
31
53
  }
32
54
  const { version } = await res.json();
33
55
  if (!version) throw new Error('npm registry returned no version for dashclaw.');
34
56
 
35
57
  const head = await fetchImpl(tarballUrl(version), { method: 'HEAD' });
36
- if (head.ok) return version;
37
-
38
- const rel = await fetchImpl(`https://api.github.com/repos/${REPO}/releases/latest`, {
39
- headers: { accept: 'application/vnd.github+json' },
40
- });
41
- const tagName = rel.ok ? (await rel.json()).tag_name : null;
42
- const fallback = typeof tagName === 'string' ? tagName.replace(/^v/, '') : null;
43
- if (!fallback) {
58
+ if (!head.ok) {
44
59
  throw new Error(
45
- `Tag v${version} (npm latest) is missing on GitHub and no release fallback was found — report this at https://github.com/${REPO}/issues.`,
60
+ `No installable version found: GitHub releases lookup failed and tag v${version} (npm latest) is missing on GitHub — report this at https://github.com/${REPO}/issues.`,
46
61
  );
47
62
  }
48
- logger.error(`[warn] npm reports ${version} but tag v${version} is missing; using latest GitHub release ${fallback} instead.`);
49
- return fallback;
63
+ logger.error(`[warn] GitHub releases lookup failed; using npm latest ${version} (may lag behind the newest platform release).`);
64
+ return version;
50
65
  }
51
66
 
52
67
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashclaw/cli",
3
- "version": "0.6.2",
3
+ "version": "0.7.1",
4
4
  "description": "DashClaw terminal client — approve agent actions and diagnose your instance",
5
5
  "type": "module",
6
6
  "keywords": [