@sandbaseai/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/dist/skills.js CHANGED
@@ -8,12 +8,21 @@ import { clientProfiles, skillTiers } from "./clients.js";
8
8
  import { sandbaseHome } from "./paths.js";
9
9
  const ownershipMarker = "<!-- sandbase-cli-managed: sandbase -->";
10
10
  const sharedClients = ["cursor", "codex"];
11
- const privateClients = ["claude-code"];
11
+ const privateClients = ["claude-code", "hermes", "kiro"];
12
12
  function sha256(content) { return createHash("sha256").update(content, "utf8").digest("hex"); }
13
13
  function sharedRoot(env = process.env) { const home = env.HOME || sandbaseHome(env); return join(home, ".agents", "skills", "sandbase"); }
14
14
  export function sharedSkillPath(env = process.env) { return join(sharedRoot(env), "SKILL.md"); }
15
15
  function metadataPath(env = process.env) { return join(sharedRoot(env), ".sandbase-managed.json"); }
16
- function privateRoot(client, env = process.env) { const home = env.HOME || sandbaseHome(env); return client === "claude-code" ? join(home, ".claude", "skills", "sandbase") : undefined; }
16
+ function privateRoot(client, env = process.env) {
17
+ const home = env.HOME || sandbaseHome(env);
18
+ if (client === "claude-code")
19
+ return join(home, ".claude", "skills", "sandbase");
20
+ if (client === "hermes")
21
+ return join(env.HERMES_HOME || join(home, ".hermes"), "skills", "sandbase");
22
+ if (client === "kiro")
23
+ return join(home, ".kiro", "skills", "sandbase");
24
+ return undefined;
25
+ }
17
26
  function privateSkillPath(client, env = process.env) { const root = privateRoot(client, env); return root ? join(root, "SKILL.md") : undefined; }
18
27
  function privateMetadataPath(client, env = process.env) { const root = privateRoot(client, env); return root ? join(root, ".sandbase-managed.json") : undefined; }
19
28
  function legacySkillPath(client, env = process.env) {
@@ -26,7 +35,7 @@ function legacySkillPath(client, env = process.env) {
26
35
  }
27
36
  export function skillPath(client, env = process.env) { return sharedClients.includes(client) ? sharedSkillPath(env) : privateSkillPath(client, env); }
28
37
  export function skillFallback(client) {
29
- if (client === "claude-code" || client === "hermes")
38
+ if (client === "claude-code")
30
39
  return `${clientProfiles[client].label} native SandBase Skill is not available yet. Use the configured SandBase MCP tools directly in chat.`;
31
40
  return "No native SandBase Skill is available for this client. Use the configured SandBase MCP tools directly.";
32
41
  }
@@ -118,7 +127,7 @@ export async function probeSkill(client, env = process.env) {
118
127
  if (privateClients.includes(client)) {
119
128
  if ((await privateOwnership(client, env)) === "ambiguous")
120
129
  return { compatible: false, message: `The ${clientProfiles[client].label} SandBase Skill ownership or checksum is invalid. It was left untouched; resolve it manually, then retry.` };
121
- return { compatible: true, message: `${clientProfiles[client].label} personal Skills root is available for installation.` };
130
+ return { compatible: true, message: `${clientProfiles[client].label} managed Skills root is available for installation.` };
122
131
  }
123
132
  if ((await sharedOwnership(env)) === "ambiguous")
124
133
  return { compatible: false, message: "The shared SandBase Skill ownership or checksum is invalid. It was left untouched; resolve it manually, then retry." };
@@ -212,7 +221,9 @@ async function installPrivateSkill(client, env) {
212
221
  await restore(meta, metaBackup);
213
222
  throw error;
214
223
  }
215
- return skillBackup ? { state: needsWrite ? "configured" : "already_configured", message: `${clientProfiles[client].label} personal SandBase Skill is installed; /sandbase still requires real-client verification.`, path, backup: skillBackup, metadataPath: meta, metadataBackup: metaBackup, changed: needsWrite } : { state: needsWrite ? "configured" : "already_configured", message: `${clientProfiles[client].label} personal SandBase Skill is installed; /sandbase still requires real-client verification.`, path, metadataPath: meta, metadataBackup: metaBackup, changed: needsWrite };
224
+ const invocation = client === "claude-code" ? "/sandbase" : "the native Skill";
225
+ const message = `${clientProfiles[client].label} managed SandBase Skill is installed; ${invocation} still requires real-client verification.`;
226
+ return skillBackup ? { state: needsWrite ? "configured" : "already_configured", message, path, backup: skillBackup, metadataPath: meta, metadataBackup: metaBackup, changed: needsWrite } : { state: needsWrite ? "configured" : "already_configured", message, path, metadataPath: meta, metadataBackup: metaBackup, changed: needsWrite };
216
227
  });
217
228
  }
218
229
  export async function rollbackSkill(result) { if (!result.changed || !result.path)
package/dist/types.d.ts CHANGED
@@ -1,5 +1,11 @@
1
- export declare const clients: readonly ["codex", "claude-code", "cursor", "windsurf", "gemini-cli", "opencode", "chatgpt", "hermes", "openclaw", "antigravity", "claude-desktop", "cursor-cli", "warp", "trae", "kimi-cli", "qwen-code", "kiro-cli", "amp", "crush", "iflow-cli", "qoder", "workbuddy", "cowork", "pi"];
1
+ export declare const clients: readonly ["codex", "claude-code", "cursor", "windsurf", "gemini-cli", "opencode", "chatgpt", "hermes", "openclaw", "antigravity", "claude-desktop", "cursor-cli", "warp", "trae", "kimi-cli", "qwen-code", "kiro", "kiro-cli", "amp", "crush", "iflow-cli", "qoder", "workbuddy", "cowork", "pi"];
2
2
  export type Client = typeof clients[number];
3
+ export declare const promptAssistedClients: readonly ["antigravity", "trae", "qoder", "workbuddy", "pi"];
4
+ export type PromptAssistedClient = typeof promptAssistedClients[number];
5
+ export declare const bridgeClients: readonly ["claude-desktop", "cowork", "antigravity", "trae", "qoder", "workbuddy", "pi"];
6
+ export type BridgeClient = typeof bridgeClients[number];
7
+ export declare function isPromptAssistedClient(value: string): value is PromptAssistedClient;
8
+ export declare function isBridgeClient(value: string): value is BridgeClient;
3
9
  export type ConnectClient = Client | "auto";
4
10
  export declare function isClient(value: string): value is Client;
5
11
  export interface CredentialRecord {
package/dist/types.js CHANGED
@@ -1,2 +1,6 @@
1
- export const clients = ["codex", "claude-code", "cursor", "windsurf", "gemini-cli", "opencode", "chatgpt", "hermes", "openclaw", "antigravity", "claude-desktop", "cursor-cli", "warp", "trae", "kimi-cli", "qwen-code", "kiro-cli", "amp", "crush", "iflow-cli", "qoder", "workbuddy", "cowork", "pi"];
1
+ export const clients = ["codex", "claude-code", "cursor", "windsurf", "gemini-cli", "opencode", "chatgpt", "hermes", "openclaw", "antigravity", "claude-desktop", "cursor-cli", "warp", "trae", "kimi-cli", "qwen-code", "kiro", "kiro-cli", "amp", "crush", "iflow-cli", "qoder", "workbuddy", "cowork", "pi"];
2
+ export const promptAssistedClients = ["antigravity", "trae", "qoder", "workbuddy", "pi"];
3
+ export const bridgeClients = ["claude-desktop", "cowork", ...promptAssistedClients];
4
+ export function isPromptAssistedClient(value) { return promptAssistedClients.includes(value); }
5
+ export function isBridgeClient(value) { return bridgeClients.includes(value); }
2
6
  export function isClient(value) { return clients.includes(value); }
@@ -0,0 +1,26 @@
1
+ export type WarpInspectionState = "missing" | "configured" | "confirmation_required" | "conflict" | "invalid";
2
+ export interface WarpInspection {
3
+ state: WarpInspectionState;
4
+ detail: string;
5
+ }
6
+ export interface WarpAdapterResult {
7
+ path: string;
8
+ changed: boolean;
9
+ backup?: string;
10
+ identityPath: string;
11
+ identityChanged: boolean;
12
+ identityPrevious?: string;
13
+ }
14
+ export interface WarpUnregisterSnapshot {
15
+ path: string;
16
+ config: string;
17
+ identityPath: string;
18
+ identity: string;
19
+ }
20
+ export declare function findWarpProjectOverride(env?: NodeJS.ProcessEnv): Promise<string | undefined>;
21
+ export declare function inspectWarp(env?: NodeJS.ProcessEnv, expectedBridge?: string): Promise<WarpInspection>;
22
+ export declare function installWarp(bridge: string, env?: NodeJS.ProcessEnv): Promise<WarpAdapterResult>;
23
+ export declare function rollbackWarp(result: WarpAdapterResult): Promise<void>;
24
+ export declare function snapshotWarpUnregister(env?: NodeJS.ProcessEnv): Promise<WarpUnregisterSnapshot | undefined>;
25
+ export declare function restoreWarpUnregister(snapshot: WarpUnregisterSnapshot): Promise<void>;
26
+ export declare function unregisterWarp(env?: NodeJS.ProcessEnv): Promise<boolean>;
@@ -0,0 +1,154 @@
1
+ import { dirname, isAbsolute, join } from "node:path";
2
+ import { rm } from "node:fs/promises";
3
+ import { atomicWrite, backup, readOptional, restore } from "./fs-safe.js";
4
+ import { configPath, sandbaseHome } from "./paths.js";
5
+ const marker = "sandbase-cli-warp-v1";
6
+ const identityPath = (env = process.env) => join(sandbaseHome(env), "adapters", "warp.json");
7
+ function object(value, label) {
8
+ if (!value || typeof value !== "object" || Array.isArray(value))
9
+ throw new Error(`${label} must be an object`);
10
+ return value;
11
+ }
12
+ function parseRoot(raw, label) { return object(JSON.parse(raw), label); }
13
+ function expected(bridge) { return { command: "node", args: [bridge, "--client", "warp"] }; }
14
+ function owned(value, bridge) {
15
+ if (!value || typeof value !== "object" || Array.isArray(value))
16
+ return false;
17
+ const entry = value;
18
+ return entry.command === "node" && Array.isArray(entry.args) && entry.args.length === 3 && entry.args[0] === bridge && entry.args[1] === "--client" && entry.args[2] === "warp";
19
+ }
20
+ async function identity(env = process.env) {
21
+ const raw = await readOptional(identityPath(env));
22
+ if (raw === undefined)
23
+ return undefined;
24
+ try {
25
+ const value = parseRoot(raw, "Warp identity");
26
+ return value.marker === marker && value.client === "warp" && typeof value.bridge === "string" && isAbsolute(value.bridge) ? { bridge: value.bridge } : undefined;
27
+ }
28
+ catch {
29
+ return undefined;
30
+ }
31
+ }
32
+ function parentDirectories(start) {
33
+ const result = [];
34
+ let current = start;
35
+ for (;;) {
36
+ result.push(current);
37
+ const parent = dirname(current);
38
+ if (parent === current)
39
+ return result;
40
+ current = parent;
41
+ }
42
+ }
43
+ export async function findWarpProjectOverride(env = process.env) {
44
+ const cwd = env.PWD || process.cwd(), globalPath = configPath("warp", env);
45
+ for (const directory of parentDirectories(cwd)) {
46
+ const path = join(directory, ".warp", ".mcp.json");
47
+ const raw = await readOptional(path);
48
+ if (raw === undefined)
49
+ continue;
50
+ if (path === globalPath)
51
+ continue;
52
+ const root = parseRoot(raw, "Warp project configuration");
53
+ const servers = root.mcpServers === undefined ? {} : object(root.mcpServers, "Warp project mcpServers");
54
+ if (servers.sandbase !== undefined)
55
+ return path;
56
+ }
57
+ return undefined;
58
+ }
59
+ export async function inspectWarp(env = process.env, expectedBridge) {
60
+ try {
61
+ const override = await findWarpProjectOverride(env);
62
+ if (override)
63
+ return { state: "confirmation_required", detail: `higher-priority project SandBase entry at ${override} was left untouched` };
64
+ const raw = await readOptional(configPath("warp", env));
65
+ if (raw === undefined)
66
+ return { state: "missing", detail: "Warp user configuration is missing" };
67
+ const root = parseRoot(raw, "Warp user configuration");
68
+ const servers = root.mcpServers === undefined ? {} : object(root.mcpServers, "Warp user mcpServers");
69
+ if (servers.sandbase === undefined)
70
+ return { state: "missing", detail: "SandBase is not registered in the Warp user configuration" };
71
+ const id = await identity(env);
72
+ const bridge = expectedBridge || id?.bridge;
73
+ if (!bridge || !owned(servers.sandbase, bridge))
74
+ return { state: "conflict", detail: "the sandbase entry is not SandBase-owned" };
75
+ return { state: "configured", detail: "user configuration ownership verified; approve with /agent-add-mcp and read back tools in Warp" };
76
+ }
77
+ catch (error) {
78
+ return { state: "invalid", detail: error instanceof Error ? error.message : "Warp configuration is invalid" };
79
+ }
80
+ }
81
+ export async function installWarp(bridge, env = process.env) {
82
+ if (!isAbsolute(bridge))
83
+ throw new Error("warp: managed bridge path must be absolute; no changes were made");
84
+ const before = await inspectWarp(env, bridge);
85
+ if (["confirmation_required", "conflict", "invalid"].includes(before.state))
86
+ throw new Error(`warp: ${before.detail}; no changes were made`);
87
+ const path = configPath("warp", env), raw = await readOptional(path), text = raw === undefined || !raw.trim() ? "{}\n" : raw;
88
+ const root = parseRoot(text, "Warp user configuration"), servers = root.mcpServers === undefined ? {} : object(root.mcpServers, "Warp user mcpServers");
89
+ const nextEntry = expected(bridge), nextIdentity = JSON.stringify({ marker, client: "warp", bridge }, null, 2) + "\n", idPath = identityPath(env), oldIdentity = await readOptional(idPath);
90
+ const changed = !owned(servers.sandbase, bridge), identityChanged = oldIdentity !== nextIdentity;
91
+ const result = { path, changed, identityPath: idPath, identityChanged, ...(oldIdentity === undefined ? {} : { identityPrevious: oldIdentity }) };
92
+ try {
93
+ if (identityChanged)
94
+ await atomicWrite(idPath, nextIdentity);
95
+ if (changed) {
96
+ servers.sandbase = nextEntry;
97
+ root.mcpServers = servers;
98
+ const backupPath = await backup(path);
99
+ if (backupPath !== undefined)
100
+ result.backup = backupPath;
101
+ await atomicWrite(path, JSON.stringify(root, null, 2) + "\n");
102
+ }
103
+ const after = await inspectWarp(env, bridge);
104
+ if (after.state !== "configured")
105
+ throw new Error(`Warp readback failed: ${after.detail}`);
106
+ return result;
107
+ }
108
+ catch (error) {
109
+ await rollbackWarp(result);
110
+ throw error;
111
+ }
112
+ }
113
+ export async function rollbackWarp(result) {
114
+ const operations = [];
115
+ if (result.changed)
116
+ operations.push(restore(result.path, result.backup));
117
+ if (result.identityChanged)
118
+ operations.push(result.identityPrevious === undefined ? rm(result.identityPath, { force: true }) : atomicWrite(result.identityPath, result.identityPrevious));
119
+ const settled = await Promise.allSettled(operations);
120
+ if (settled.some(item => item.status === "rejected"))
121
+ throw new Error("Warp rollback was incomplete");
122
+ }
123
+ export async function snapshotWarpUnregister(env = process.env) {
124
+ const inspection = await inspectWarp(env);
125
+ if (inspection.state === "missing")
126
+ return undefined;
127
+ if (inspection.state !== "configured")
128
+ throw new Error(`warp: ${inspection.detail}; no changes were made`);
129
+ const [config, identityRaw] = await Promise.all([readOptional(configPath("warp", env)), readOptional(identityPath(env))]);
130
+ if (config === undefined || identityRaw === undefined)
131
+ throw new Error("warp: managed ownership state is incomplete; no changes were made");
132
+ return { path: configPath("warp", env), config, identityPath: identityPath(env), identity: identityRaw };
133
+ }
134
+ export async function restoreWarpUnregister(snapshot) { await Promise.all([atomicWrite(snapshot.path, snapshot.config), atomicWrite(snapshot.identityPath, snapshot.identity)]); }
135
+ export async function unregisterWarp(env = process.env) {
136
+ const snapshot = await snapshotWarpUnregister(env);
137
+ if (!snapshot)
138
+ return false;
139
+ try {
140
+ const root = parseRoot(snapshot.config, "Warp user configuration"), servers = object(root.mcpServers, "Warp user mcpServers");
141
+ delete servers.sandbase;
142
+ root.mcpServers = servers;
143
+ await atomicWrite(snapshot.path, JSON.stringify(root, null, 2) + "\n");
144
+ await rm(snapshot.identityPath, { force: true });
145
+ const after = await inspectWarp(env);
146
+ if (after.state !== "missing")
147
+ throw new Error(`Warp removal readback failed: ${after.detail}`);
148
+ return true;
149
+ }
150
+ catch (error) {
151
+ await restoreWarpUnregister(snapshot);
152
+ throw error;
153
+ }
154
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sandbaseai/cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Secure SandBase MCP onboarding CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -37,6 +37,7 @@
37
37
  "provenance": true
38
38
  },
39
39
  "dependencies": {
40
+ "jsonc-parser": "3.3.1",
40
41
  "smol-toml": "1.7.0",
41
42
  "yaml": "2.9.0"
42
43
  }