@sandbaseai/cli 0.1.3 → 0.1.4
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/assets/skills/sandbase/SKILL.md +10 -0
- package/dist/clients.d.ts +2 -0
- package/dist/clients.js +4 -0
- package/dist/commands.js +19 -3
- package/dist/skills.d.ts +16 -0
- package/dist/skills.js +89 -0
- package/package.json +2 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sandbase
|
|
3
|
+
description: Use the already configured SandBase MCP tools for relevant requests.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SandBase
|
|
7
|
+
|
|
8
|
+
<!-- sandbase-cli-managed: sandbase -->
|
|
9
|
+
|
|
10
|
+
Use the already configured SandBase MCP tools when they are relevant to the user's request. First inspect the available SandBase tools, then choose the smallest suitable tool call. Keep the user informed of meaningful failures and do not change unrelated local settings.
|
package/dist/clients.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Client } from "./types.js";
|
|
2
2
|
export type InstallMode = "auto" | "manual" | "skill";
|
|
3
|
+
export type SkillTier = "s1_slash" | "s2_skill" | "s3_fallback" | "s4_none";
|
|
3
4
|
export interface ClientProfile {
|
|
4
5
|
id: Client;
|
|
5
6
|
label: string;
|
|
@@ -8,5 +9,6 @@ export interface ClientProfile {
|
|
|
8
9
|
adapter?: "codex" | "json" | "yaml";
|
|
9
10
|
}
|
|
10
11
|
export declare const clientProfiles: Record<Client, ClientProfile>;
|
|
12
|
+
export declare const skillTiers: Record<Client, SkillTier>;
|
|
11
13
|
export declare function clientList(): string;
|
|
12
14
|
export declare function autoClients(): Client[];
|
package/dist/clients.js
CHANGED
|
@@ -24,6 +24,10 @@ export const clientProfiles = {
|
|
|
24
24
|
cowork: { id: "cowork", label: "Cowork", mode: "manual" },
|
|
25
25
|
pi: { id: "pi", label: "Pi", mode: "skill" },
|
|
26
26
|
};
|
|
27
|
+
export const skillTiers = {
|
|
28
|
+
codex: "s2_skill", "claude-code": "s1_slash", cursor: "s3_fallback", hermes: "s3_fallback",
|
|
29
|
+
windsurf: "s4_none", "gemini-cli": "s4_none", opencode: "s4_none", chatgpt: "s4_none", openclaw: "s4_none", antigravity: "s4_none", "claude-desktop": "s4_none", "cursor-cli": "s4_none", warp: "s4_none", trae: "s4_none", "kimi-cli": "s4_none", "qwen-code": "s4_none", "kiro-cli": "s4_none", amp: "s4_none", crush: "s4_none", "iflow-cli": "s4_none", qoder: "s4_none", workbuddy: "s4_none", cowork: "s4_none", pi: "s4_none",
|
|
30
|
+
};
|
|
27
31
|
export function clientList() {
|
|
28
32
|
return Object.keys(clientProfiles).join("|");
|
|
29
33
|
}
|
package/dist/commands.js
CHANGED
|
@@ -5,6 +5,7 @@ import { authorize } from "./auth/flow.js";
|
|
|
5
5
|
import { autoClients, clientProfiles } from "./clients.js";
|
|
6
6
|
import { FileCredentialStore } from "./credentials/store.js";
|
|
7
7
|
import { configure, detectClient, installBridge, isConfigured, rollback, rollbackBridge, unregister as removeAdapter } from "./adapters/index.js";
|
|
8
|
+
import { inspectSkill, installSkill, removeSkill, skillFallback, skillInvocation } from "./skills.js";
|
|
8
9
|
const sleep = (ms, signal) => new Promise((resolve, reject) => { const t = setTimeout(resolve, ms); signal?.addEventListener("abort", () => { clearTimeout(t); reject(new Error("Authorization cancelled")); }, { once: true }); });
|
|
9
10
|
async function compensate(api, authorizationId, token) { for (const delay of [0, 250, 750]) {
|
|
10
11
|
if (delay)
|
|
@@ -34,6 +35,16 @@ async function restoreCredential(store, client, previous) { if (previous)
|
|
|
34
35
|
await store.save(previous);
|
|
35
36
|
else
|
|
36
37
|
await store.remove(client); }
|
|
38
|
+
async function configureSkill(client, log) {
|
|
39
|
+
try {
|
|
40
|
+
const result = await installSkill(client);
|
|
41
|
+
log(`Native Skill for ${client}: ${result.state}. ${result.message}`);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
const message = error instanceof Error ? error.message : "Unknown native Skill failure";
|
|
45
|
+
log(`Native Skill for ${client}: failed. ${message}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
37
48
|
async function connectOne(client, deps) {
|
|
38
49
|
const api = deps.api || new AuthorizationApi((process.env.SANDBASE_API_URL || "https://sandbase.ai").replace(/\/$/, ""));
|
|
39
50
|
const store = deps.store || new FileCredentialStore();
|
|
@@ -55,6 +66,7 @@ async function connectOne(client, deps) {
|
|
|
55
66
|
if (profile.mode === "auto" && !(await isConfigured(client)))
|
|
56
67
|
throw new Error("Client configuration verification failed");
|
|
57
68
|
log(successMessage(client, record, bridgeResult.path, configured.path));
|
|
69
|
+
await configureSkill(client, log);
|
|
58
70
|
exchange.cleanup_token = "";
|
|
59
71
|
}
|
|
60
72
|
catch (e) {
|
|
@@ -93,6 +105,7 @@ async function connectAuto(deps) {
|
|
|
93
105
|
configured = await configure(client, bridgeResult.path);
|
|
94
106
|
if (!(await isConfigured(client)))
|
|
95
107
|
throw new Error("Client configuration verification failed");
|
|
108
|
+
await configureSkill(client, log);
|
|
96
109
|
succeeded.push(client);
|
|
97
110
|
}
|
|
98
111
|
catch {
|
|
@@ -132,8 +145,10 @@ export async function doctor(client = "auto", store = new FileCredentialStore(),
|
|
|
132
145
|
const profile = clientProfiles[target];
|
|
133
146
|
const configured = profile.mode === "auto" ? await isConfigured(target) : !!credential;
|
|
134
147
|
const detected = detect(target);
|
|
135
|
-
|
|
136
|
-
|
|
148
|
+
const skill = await inspectSkill(target);
|
|
149
|
+
const skillDetail = skill === "installed" ? skillInvocation(target) : skill === "fallback" ? skillFallback(target) : skill === "unsupported" ? "No native SandBase Skill is available for this client." : skill === "modified" ? "Managed native Skill is missing or modified; it was left untouched." : "Native SandBase Skill is not installed.";
|
|
150
|
+
console.log(`${target}: mode=${profile.mode}, installed=${detected.installed ? "yes" : "no"}, config=${configured ? profile.mode === "auto" ? "ok" : "manual" : "missing"}, skill=${skill}, credential=${credential ? credential.keyPrefix + "…" : "missing"}, url=${credential?.mcpUrl || "unknown"}, scope=${credential?.scope.join(",") || "unknown"}. ${skillDetail}`);
|
|
151
|
+
healthy = healthy && detected.installed && !!credential && configured && !["missing", "modified"].includes(skill);
|
|
137
152
|
}
|
|
138
153
|
return healthy;
|
|
139
154
|
}
|
|
@@ -145,7 +160,8 @@ export async function unregister(client = "auto", store = new FileCredentialStor
|
|
|
145
160
|
}
|
|
146
161
|
for (const target of targets) {
|
|
147
162
|
const removed = await removeAdapter(target);
|
|
163
|
+
const removedSkill = await removeSkill(target);
|
|
148
164
|
await store.remove(target);
|
|
149
|
-
console.log(`Removed local SandBase registration for ${target}.${removed ? "" : " No managed client configuration was changed."} Revoke the server credential in SandBase Dashboard if it is no longer needed.`);
|
|
165
|
+
console.log(`Removed local SandBase registration for ${target}.${removed || removedSkill ? "" : " No managed client configuration or Skill was changed."} Revoke the server credential in SandBase Dashboard if it is no longer needed.`);
|
|
150
166
|
}
|
|
151
167
|
}
|
package/dist/skills.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Client } from "./types.js";
|
|
2
|
+
export type SkillState = "installed" | "missing" | "modified" | "fallback" | "unsupported";
|
|
3
|
+
export interface SkillInstallResult {
|
|
4
|
+
state: "configured" | "already_configured" | "fallback" | "skipped";
|
|
5
|
+
message: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
backup?: string;
|
|
8
|
+
changed: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function skillPath(client: Client, env?: NodeJS.ProcessEnv): string | undefined;
|
|
11
|
+
export declare function skillFallback(client: Client): string;
|
|
12
|
+
export declare function skillInvocation(client: Client): string;
|
|
13
|
+
export declare function inspectSkill(client: Client, env?: NodeJS.ProcessEnv): Promise<SkillState>;
|
|
14
|
+
export declare function installSkill(client: Client, env?: NodeJS.ProcessEnv): Promise<SkillInstallResult>;
|
|
15
|
+
export declare function rollbackSkill(result: SkillInstallResult): Promise<void>;
|
|
16
|
+
export declare function removeSkill(client: Client, env?: NodeJS.ProcessEnv): Promise<boolean>;
|
package/dist/skills.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { mkdir, readFile, rm } from "node:fs/promises";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { atomicWrite, backup, readOptional, restore } from "./fs-safe.js";
|
|
5
|
+
import { clientProfiles, skillTiers } from "./clients.js";
|
|
6
|
+
import { sandbaseHome } from "./paths.js";
|
|
7
|
+
const ownershipMarker = "<!-- sandbase-cli-managed: sandbase -->";
|
|
8
|
+
export function skillPath(client, env = process.env) {
|
|
9
|
+
const home = env.HOME || sandbaseHome(env);
|
|
10
|
+
if (client === "claude-code")
|
|
11
|
+
return join(home, ".claude", "skills", "sandbase", "SKILL.md");
|
|
12
|
+
if (client === "codex")
|
|
13
|
+
return join(env.CODEX_HOME || join(home, ".codex"), "skills", "sandbase", "SKILL.md");
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
export function skillFallback(client) {
|
|
17
|
+
if (client === "cursor" || client === "hermes")
|
|
18
|
+
return `${clientProfiles[client].label} native SandBase Skill is not available yet. Use the configured SandBase MCP tools directly in chat.`;
|
|
19
|
+
return "No native SandBase Skill is available for this client. Use the configured SandBase MCP tools directly.";
|
|
20
|
+
}
|
|
21
|
+
export function skillInvocation(client) { return client === "claude-code" ? "Type / and select /sandbase to get SandBase MCP tool guidance." : "Open Codex's Skill picker and select SandBase, or reference $sandbase where that native affordance is available."; }
|
|
22
|
+
function nativeTier(client) { const tier = skillTiers[client]; return tier === "s1_slash" || tier === "s2_skill"; }
|
|
23
|
+
function isOwned(content) { return content.includes(ownershipMarker) && /^name:\s*sandbase\s*$/m.test(content); }
|
|
24
|
+
async function asset() {
|
|
25
|
+
const bundled = fileURLToPath(new URL("../assets/skills/sandbase/SKILL.md", import.meta.url));
|
|
26
|
+
try {
|
|
27
|
+
return await readFile(bundled, "utf8");
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (error.code !== "ENOENT")
|
|
31
|
+
throw error;
|
|
32
|
+
return readFile(join(process.cwd(), "assets", "skills", "sandbase", "SKILL.md"), "utf8");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export async function inspectSkill(client, env = process.env) {
|
|
36
|
+
const tier = skillTiers[client];
|
|
37
|
+
if (tier === "s3_fallback")
|
|
38
|
+
return "fallback";
|
|
39
|
+
if (tier === "s4_none")
|
|
40
|
+
return "unsupported";
|
|
41
|
+
const current = await readOptional(skillPath(client, env));
|
|
42
|
+
return !current ? "missing" : isOwned(current) ? "installed" : "modified";
|
|
43
|
+
}
|
|
44
|
+
export async function installSkill(client, env = process.env) {
|
|
45
|
+
if (!nativeTier(client)) {
|
|
46
|
+
const fallback = skillTiers[client] === "s3_fallback";
|
|
47
|
+
return { state: fallback ? "fallback" : "skipped", message: fallback ? skillFallback(client) : "No native SandBase Skill is available for this client.", changed: false };
|
|
48
|
+
}
|
|
49
|
+
const path = skillPath(client, env);
|
|
50
|
+
const desired = await asset();
|
|
51
|
+
const current = await readOptional(path);
|
|
52
|
+
if (current && !isOwned(current))
|
|
53
|
+
throw new Error(`Refusing to overwrite an unmanaged ${clientProfiles[client].label} SandBase Skill artifact. Resolve it manually, then retry.`);
|
|
54
|
+
if (current === desired)
|
|
55
|
+
return { state: "already_configured", message: skillInvocation(client), path, changed: false };
|
|
56
|
+
await mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
57
|
+
const backupPath = await backup(path);
|
|
58
|
+
try {
|
|
59
|
+
await atomicWrite(path, desired, 0o600);
|
|
60
|
+
if ((await readOptional(path)) !== desired || !isOwned(desired))
|
|
61
|
+
throw new Error("Native Skill verification failed");
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
await restore(path, backupPath);
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
return backupPath ? { state: "configured", message: skillInvocation(client), path, backup: backupPath, changed: true } : { state: "configured", message: skillInvocation(client), path, changed: true };
|
|
68
|
+
}
|
|
69
|
+
export async function rollbackSkill(result) { if (result.changed && result.path)
|
|
70
|
+
await restore(result.path, result.backup); }
|
|
71
|
+
export async function removeSkill(client, env = process.env) {
|
|
72
|
+
if (!nativeTier(client))
|
|
73
|
+
return false;
|
|
74
|
+
const path = skillPath(client, env);
|
|
75
|
+
const current = await readOptional(path);
|
|
76
|
+
if (!current)
|
|
77
|
+
return false;
|
|
78
|
+
if (!isOwned(current))
|
|
79
|
+
throw new Error(`Refusing to remove an unmanaged ${clientProfiles[client].label} SandBase Skill artifact. Remove it manually if intended.`);
|
|
80
|
+
const backupPath = await backup(path);
|
|
81
|
+
try {
|
|
82
|
+
await rm(path);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
await restore(path, backupPath);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
return true;
|
|
89
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sandbaseai/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Secure SandBase MCP onboarding CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"dist",
|
|
14
|
-
"assets
|
|
14
|
+
"assets",
|
|
15
15
|
"README.md",
|
|
16
16
|
"LICENSE"
|
|
17
17
|
],
|