@solidactions/cli 1.30.0 → 1.31.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 +86 -12
- package/dist/commands/crew-env-delete.js +1 -1
- package/dist/commands/crew-env-list.js +9 -7
- package/dist/commands/crew-env-push.js +1 -1
- package/dist/commands/crew-env-set.js +1 -1
- package/dist/commands/docs-upload.js +1 -1
- package/dist/commands/env-delete.js +1 -1
- package/dist/commands/env-list.js +1 -1
- package/dist/commands/env-map.js +1 -1
- package/dist/commands/env-pull.js +2 -2
- package/dist/commands/env-push.js +2 -2
- package/dist/commands/env-set.js +7 -3
- package/dist/commands/login.js +50 -1
- package/dist/commands/oauth-actions-list.js +1 -1
- package/dist/commands/oauth-actions-platforms.js +1 -1
- package/dist/commands/oauth-actions-search.js +1 -1
- package/dist/commands/oauth-actions-show.js +1 -1
- package/dist/commands/project-create.js +1 -1
- package/dist/commands/project-list.js +1 -1
- package/dist/commands/project-logs.js +1 -1
- package/dist/commands/pull.js +1 -1
- package/dist/commands/run-list.js +1 -1
- package/dist/commands/run-start.js +1 -1
- package/dist/commands/run-view.js +1 -1
- package/dist/commands/schedule-delete.js +1 -1
- package/dist/commands/schedule-list.js +1 -1
- package/dist/commands/schedule-set.js +10 -13
- package/dist/commands/skill-dev.js +15 -0
- package/dist/commands/skill-exec.js +179 -7
- package/dist/commands/skill-pull.js +2 -14
- package/dist/commands/skill-push.js +2 -2
- package/dist/commands/skill-run.js +45 -22
- package/dist/commands/webhook-list.js +1 -1
- package/dist/commands/webhook-secret.js +1 -1
- package/dist/index.js +29 -12
- package/dist/utils/api.js +2 -2
- package/dist/utils/crew.js +48 -0
- package/dist/utils/github.js +7 -1
- package/dist/utils/mcp.js +26 -18
- package/dist/utils/skill-bundle.js +123 -0
- package/dist/utils/skill-cache-fs.js +133 -0
- package/dist/utils/skill-cache.js +84 -0
- package/dist/utils/skills.js +4 -2
- package/package.json +8 -5
package/dist/utils/mcp.js
CHANGED
|
@@ -42,6 +42,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
exports.callCrewsTool = callCrewsTool;
|
|
44
44
|
exports.callDocsTool = callDocsTool;
|
|
45
|
+
exports.callCrewsToolContent = callCrewsToolContent;
|
|
45
46
|
const http = __importStar(require("http"));
|
|
46
47
|
const https = __importStar(require("https"));
|
|
47
48
|
const url_1 = require("url");
|
|
@@ -49,14 +50,9 @@ const api_1 = require("./api");
|
|
|
49
50
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
50
51
|
const pkg = require('../../package.json');
|
|
51
52
|
const CLI_VERSION = pkg.version;
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
*
|
|
55
|
-
* Returns { ok: true, data: <success shape> } or { ok: false, data: { code, message } }.
|
|
56
|
-
*/
|
|
57
|
-
async function callMcpTool(config, endpointPath, toolName, args) {
|
|
53
|
+
/** Internal: POST one tools/call and return the raw result envelope (isError + content blocks). */
|
|
54
|
+
async function postMcpTool(config, endpointPath, toolName, args) {
|
|
58
55
|
const baseHeaders = (0, api_1.getApiHeaders)(config, 'application/json');
|
|
59
|
-
// Override Accept to include text/event-stream for streamable-HTTP transport
|
|
60
56
|
const headers = {
|
|
61
57
|
...baseHeaders,
|
|
62
58
|
'Accept': 'application/json, text/event-stream',
|
|
@@ -65,10 +61,7 @@ async function callMcpTool(config, endpointPath, toolName, args) {
|
|
|
65
61
|
jsonrpc: '2.0',
|
|
66
62
|
id: 1,
|
|
67
63
|
method: 'tools/call',
|
|
68
|
-
params: {
|
|
69
|
-
name: toolName,
|
|
70
|
-
arguments: args,
|
|
71
|
-
},
|
|
64
|
+
params: { name: toolName, arguments: args },
|
|
72
65
|
});
|
|
73
66
|
const parsed = new url_1.URL(`${config.host}${endpointPath}`);
|
|
74
67
|
const isHttps = parsed.protocol === 'https:';
|
|
@@ -79,10 +72,7 @@ async function callMcpTool(config, endpointPath, toolName, args) {
|
|
|
79
72
|
port: parsed.port || (isHttps ? 443 : 80),
|
|
80
73
|
path: parsed.pathname + (parsed.search || ''),
|
|
81
74
|
method: 'POST',
|
|
82
|
-
headers: {
|
|
83
|
-
...headers,
|
|
84
|
-
'Content-Length': Buffer.byteLength(body),
|
|
85
|
-
},
|
|
75
|
+
headers: { ...headers, 'Content-Length': Buffer.byteLength(body) },
|
|
86
76
|
};
|
|
87
77
|
const req = transport.request(options, (res) => {
|
|
88
78
|
let raw = '';
|
|
@@ -111,8 +101,16 @@ async function callMcpTool(config, endpointPath, toolName, args) {
|
|
|
111
101
|
throw new Error(`MCP server returned non-JSON response: ${responseData}`);
|
|
112
102
|
}
|
|
113
103
|
const result = parsed2?.result;
|
|
114
|
-
|
|
115
|
-
|
|
104
|
+
return { isError: result?.isError === true, content: result?.content ?? [] };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Internal: call a single MCP tool and JSON-parse its first text content block.
|
|
108
|
+
*
|
|
109
|
+
* Returns { ok: true, data: <success shape> } or { ok: false, data: { code, message } }.
|
|
110
|
+
*/
|
|
111
|
+
async function callMcpTool(config, endpointPath, toolName, args) {
|
|
112
|
+
const raw = await postMcpTool(config, endpointPath, toolName, args);
|
|
113
|
+
const textContent = raw.content?.[0]?.text ?? '{}';
|
|
116
114
|
let toolData;
|
|
117
115
|
try {
|
|
118
116
|
toolData = JSON.parse(textContent);
|
|
@@ -120,7 +118,7 @@ async function callMcpTool(config, endpointPath, toolName, args) {
|
|
|
120
118
|
catch {
|
|
121
119
|
throw new Error(`MCP tool result content is not valid JSON: ${textContent}`);
|
|
122
120
|
}
|
|
123
|
-
return { ok: !isError, data: toolData };
|
|
121
|
+
return { ok: !raw.isError, data: toolData };
|
|
124
122
|
}
|
|
125
123
|
const UNIFIED_MCP_PATH = '/mcp';
|
|
126
124
|
// Server consolidated per-domain MCP servers into one endpoint with namespaced tools.
|
|
@@ -138,3 +136,13 @@ async function callCrewsTool(config, toolName, args) {
|
|
|
138
136
|
async function callDocsTool(config, toolName, args) {
|
|
139
137
|
return callMcpTool(config, UNIFIED_MCP_PATH, toolName, args);
|
|
140
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Call a crews MCP tool and return the RAW content blocks. Needed for
|
|
141
|
+
* read_reference_file, whose success responses can be an MCP image block
|
|
142
|
+
* (base64 bytes) rather than a JSON text block — JSON-parsing content[0].text
|
|
143
|
+
* (callCrewsTool) would throw on those.
|
|
144
|
+
*/
|
|
145
|
+
async function callCrewsToolContent(config, toolName, args) {
|
|
146
|
+
const raw = await postMcpTool(config, UNIFIED_MCP_PATH, CREWS_TOOL_NAMES[toolName] ?? toolName, args);
|
|
147
|
+
return { ok: !raw.isError, content: raw.content };
|
|
148
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.reconstructSkillMd = reconstructSkillMd;
|
|
7
|
+
exports.normalizeBundle = normalizeBundle;
|
|
8
|
+
exports.fetchBinaryReference = fetchBinaryReference;
|
|
9
|
+
/**
|
|
10
|
+
* Normalization of a skills.read / roles.read_skill bundle into the pieces the
|
|
11
|
+
* host-cache needs, plus binary reference fetching.
|
|
12
|
+
*
|
|
13
|
+
* Binary reference values arrive as {binary, mime, size, blob_sha} metadata —
|
|
14
|
+
* bytes come from a separate read_reference_file call which returns EITHER a
|
|
15
|
+
* JSON text block {signed_url,...} (non-image or large) OR an MCP image block
|
|
16
|
+
* (base64) for small images. fetchBinaryReference handles both.
|
|
17
|
+
*/
|
|
18
|
+
const axios_1 = __importDefault(require("axios"));
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
20
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
21
|
+
const mcp_1 = require("./mcp");
|
|
22
|
+
const skill_cache_1 = require("./skill-cache");
|
|
23
|
+
const skill_cache_fs_1 = require("./skill-cache-fs");
|
|
24
|
+
function reconstructSkillMd(properties, body) {
|
|
25
|
+
const { type: _type, name: propName, description: propDescription, ...extraProps } = properties;
|
|
26
|
+
const frontmatterObj = {
|
|
27
|
+
name: propName,
|
|
28
|
+
description: propDescription,
|
|
29
|
+
...extraProps,
|
|
30
|
+
};
|
|
31
|
+
const yamlBlock = js_yaml_1.default.dump(frontmatterObj, { lineWidth: -1 });
|
|
32
|
+
const bodyText = body ?? '';
|
|
33
|
+
return `---\n${yamlBlock}---\n${bodyText.startsWith('\n') ? bodyText : '\n' + bodyText}`;
|
|
34
|
+
}
|
|
35
|
+
function readStorageScopeProp(properties) {
|
|
36
|
+
const nested = properties.storage?.scope;
|
|
37
|
+
const flat = properties['storage.scope'];
|
|
38
|
+
const scope = nested ?? flat ?? null;
|
|
39
|
+
return scope === 'crew' || scope === 'workspace' ? scope : null;
|
|
40
|
+
}
|
|
41
|
+
/** True when a reference key would escape the cache dir (same guards as skill pull). */
|
|
42
|
+
function isUnsafeReferenceKey(key) {
|
|
43
|
+
if (path_1.default.isAbsolute(key))
|
|
44
|
+
return true;
|
|
45
|
+
const root = path_1.default.resolve('/probe-root');
|
|
46
|
+
return !path_1.default.resolve(root, key).startsWith(root + path_1.default.sep);
|
|
47
|
+
}
|
|
48
|
+
function normalizeBundle(data) {
|
|
49
|
+
const properties = (data.properties ?? {});
|
|
50
|
+
const textFiles = {};
|
|
51
|
+
const binaryFiles = {};
|
|
52
|
+
const skippedUnsafe = [];
|
|
53
|
+
for (const [key, value] of Object.entries((data.reference ?? {}))) {
|
|
54
|
+
if (isUnsafeReferenceKey(key)) {
|
|
55
|
+
skippedUnsafe.push(key);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (typeof value === 'string') {
|
|
59
|
+
textFiles[key] = value;
|
|
60
|
+
}
|
|
61
|
+
else if (value && typeof value === 'object' && value.binary === true) {
|
|
62
|
+
const v = value;
|
|
63
|
+
binaryFiles[key] = { blobSha: v.blob_sha, mime: v.mime, size: v.size };
|
|
64
|
+
}
|
|
65
|
+
// else: unreachable — the server wire contract has exactly two reference
|
|
66
|
+
// shapes, string | {binary:true,...} (see ResolvedReference::toWireValue).
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
identifier: data.identifier,
|
|
70
|
+
properties,
|
|
71
|
+
skillMd: reconstructSkillMd(properties, data.body),
|
|
72
|
+
textFiles,
|
|
73
|
+
binaryFiles,
|
|
74
|
+
identity: (0, skill_cache_1.artifactIdentity)(data),
|
|
75
|
+
storageScope: readStorageScopeProp(properties),
|
|
76
|
+
skippedUnsafe,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
async function fetchBinaryReference(config, tool, locator, refPath, expected) {
|
|
80
|
+
const result = await (0, mcp_1.callCrewsToolContent)(config, tool, {
|
|
81
|
+
action: 'read_reference_file',
|
|
82
|
+
...locator,
|
|
83
|
+
path: refPath,
|
|
84
|
+
});
|
|
85
|
+
if (!result.ok) {
|
|
86
|
+
const text = result.content?.[0]?.text ?? '';
|
|
87
|
+
throw new Error(`failed to fetch binary reference '${refPath}': ${text}`);
|
|
88
|
+
}
|
|
89
|
+
let bytes = null;
|
|
90
|
+
for (const block of result.content) {
|
|
91
|
+
if (block?.type === 'image' && typeof block.data === 'string') {
|
|
92
|
+
bytes = Buffer.from(block.data, 'base64');
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (block?.type === 'text' && typeof block.text === 'string') {
|
|
96
|
+
let parsed;
|
|
97
|
+
try {
|
|
98
|
+
parsed = JSON.parse(block.text);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (parsed?.signed_url) {
|
|
104
|
+
const response = await axios_1.default.get(parsed.signed_url, { responseType: 'arraybuffer' });
|
|
105
|
+
bytes = Buffer.from(response.data);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (bytes === null) {
|
|
111
|
+
throw new Error(`failed to fetch binary reference '${refPath}': unrecognized response shape`);
|
|
112
|
+
}
|
|
113
|
+
if (bytes.length !== expected.size) {
|
|
114
|
+
throw new Error(`binary reference '${refPath}' failed validation (got ${bytes.length} bytes, expected ${expected.size}) — refusing to cache a corrupt download`);
|
|
115
|
+
}
|
|
116
|
+
if (/^[0-9a-f]{64}$/.test(expected.blobSha)) {
|
|
117
|
+
const actualHash = (0, skill_cache_fs_1.sha256Hex)(bytes);
|
|
118
|
+
if (actualHash !== expected.blobSha) {
|
|
119
|
+
throw new Error(`binary reference '${refPath}' failed validation (sha256 mismatch: got ${actualHash}, expected ${expected.blobSha}) — refusing to cache a corrupt download`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return bytes;
|
|
123
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.sha256Hex = sha256Hex;
|
|
7
|
+
exports.hashFileOrNull = hashFileOrNull;
|
|
8
|
+
exports.readManifest = readManifest;
|
|
9
|
+
exports.onDiskHashes = onDiskHashes;
|
|
10
|
+
exports.writeFileAtomic = writeFileAtomic;
|
|
11
|
+
exports.applyCachePlan = applyCachePlan;
|
|
12
|
+
exports.withCacheLock = withCacheLock;
|
|
13
|
+
/**
|
|
14
|
+
* Filesystem side of the host skill cache: hashing, atomic writes, the
|
|
15
|
+
* per-cache-key lock, and plan application. Kept separate from the pure
|
|
16
|
+
* planner (skill-cache.ts) so planning stays unit-testable without fs.
|
|
17
|
+
*
|
|
18
|
+
* Write protocol: every managed file is written via temp-file + rename in the
|
|
19
|
+
* same directory (atomic on POSIX); the manifest is written LAST, so a crash
|
|
20
|
+
* mid-refresh leaves a manifest that simply mismatches on the next run and
|
|
21
|
+
* triggers a clean re-refresh. Per-file renames also mean a concurrently
|
|
22
|
+
* RUNNING exec keeps its already-open scripts.
|
|
23
|
+
*
|
|
24
|
+
* Lock ownership: the lock dir carries an `owner` token file written right
|
|
25
|
+
* after `mkdirSync` succeeds. A stale-lock takeover removes the whole dir
|
|
26
|
+
* (token included) before re-acquiring, and release only removes the lock
|
|
27
|
+
* dir when its `owner` file still matches our token — so a holder that ran
|
|
28
|
+
* past the staleness window and had its lock stolen can't rm the new
|
|
29
|
+
* holder's lock out from under it. If a concurrent stale-takeover `rmSync`
|
|
30
|
+
* lands between our `mkdirSync` and the `owner` write, that write sees
|
|
31
|
+
* ENOENT — treated as having lost the race, so acquisition retries.
|
|
32
|
+
*/
|
|
33
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
34
|
+
const fs_1 = __importDefault(require("fs"));
|
|
35
|
+
const path_1 = __importDefault(require("path"));
|
|
36
|
+
const skill_cache_1 = require("./skill-cache");
|
|
37
|
+
function sha256Hex(data) {
|
|
38
|
+
return crypto_1.default.createHash('sha256').update(data).digest('hex');
|
|
39
|
+
}
|
|
40
|
+
function hashFileOrNull(filePath) {
|
|
41
|
+
try {
|
|
42
|
+
return sha256Hex(fs_1.default.readFileSync(filePath));
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function readManifest(cacheDir) {
|
|
49
|
+
try {
|
|
50
|
+
const parsed = JSON.parse(fs_1.default.readFileSync(path_1.default.join(cacheDir, skill_cache_1.CACHE_MANIFEST), 'utf8'));
|
|
51
|
+
if (parsed?.schema_version !== 1 || typeof parsed?.files !== 'object' || parsed.files === null || Array.isArray(parsed.files))
|
|
52
|
+
return null;
|
|
53
|
+
return parsed;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function onDiskHashes(cacheDir, paths) {
|
|
60
|
+
const out = {};
|
|
61
|
+
for (const p of paths) {
|
|
62
|
+
out[p] = hashFileOrNull(path_1.default.join(cacheDir, p));
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
function writeFileAtomic(target, data) {
|
|
67
|
+
fs_1.default.mkdirSync(path_1.default.dirname(target), { recursive: true });
|
|
68
|
+
const tmp = path_1.default.join(path_1.default.dirname(target), `.tmp-${process.pid}-${crypto_1.default.randomBytes(4).toString('hex')}`);
|
|
69
|
+
fs_1.default.writeFileSync(tmp, data);
|
|
70
|
+
fs_1.default.renameSync(tmp, target);
|
|
71
|
+
}
|
|
72
|
+
function applyCachePlan(cacheDir, plan, contents, manifest) {
|
|
73
|
+
fs_1.default.mkdirSync(cacheDir, { recursive: true, mode: 0o700 });
|
|
74
|
+
for (const rel of plan.writes) {
|
|
75
|
+
if (!(rel in contents)) {
|
|
76
|
+
throw new Error(`applyCachePlan: no content provided for planned write '${rel}'`);
|
|
77
|
+
}
|
|
78
|
+
writeFileAtomic(path_1.default.join(cacheDir, rel), contents[rel]);
|
|
79
|
+
}
|
|
80
|
+
for (const rel of plan.deletes) {
|
|
81
|
+
fs_1.default.rmSync(path_1.default.join(cacheDir, rel), { force: true });
|
|
82
|
+
}
|
|
83
|
+
writeFileAtomic(path_1.default.join(cacheDir, skill_cache_1.CACHE_MANIFEST), JSON.stringify(manifest, null, 2) + '\n');
|
|
84
|
+
}
|
|
85
|
+
const LOCK_STALE_MS = 120_000;
|
|
86
|
+
const LOCK_TIMEOUT_MS = 20_000;
|
|
87
|
+
const LOCK_POLL_MS = 100;
|
|
88
|
+
async function withCacheLock(cacheDir, fn) {
|
|
89
|
+
const lockDir = cacheDir + '.lock';
|
|
90
|
+
fs_1.default.mkdirSync(path_1.default.dirname(lockDir), { recursive: true });
|
|
91
|
+
const deadline = Date.now() + LOCK_TIMEOUT_MS;
|
|
92
|
+
const token = `${process.pid}-${crypto_1.default.randomBytes(8).toString('hex')}`;
|
|
93
|
+
for (;;) {
|
|
94
|
+
if (Date.now() > deadline) {
|
|
95
|
+
throw new Error(`timed out waiting for skill cache lock: ${lockDir} (another exec running? delete it if stale)`);
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
fs_1.default.mkdirSync(lockDir);
|
|
99
|
+
fs_1.default.writeFileSync(path_1.default.join(lockDir, 'owner'), token);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
catch (e) {
|
|
103
|
+
if (e?.code !== 'EEXIST' && e?.code !== 'ENOENT')
|
|
104
|
+
throw e;
|
|
105
|
+
let stale = false;
|
|
106
|
+
try {
|
|
107
|
+
stale = Date.now() - fs_1.default.statSync(lockDir).mtimeMs > LOCK_STALE_MS;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
continue; // holder just released — retry immediately
|
|
111
|
+
}
|
|
112
|
+
if (stale) {
|
|
113
|
+
try {
|
|
114
|
+
fs_1.default.rmSync(lockDir, { recursive: true, force: true });
|
|
115
|
+
}
|
|
116
|
+
catch { /* raced another taker */ }
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
await new Promise((r) => setTimeout(r, LOCK_POLL_MS));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
return await fn();
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
try {
|
|
127
|
+
if (fs_1.default.readFileSync(path_1.default.join(lockDir, 'owner'), 'utf8') === token) {
|
|
128
|
+
fs_1.default.rmSync(lockDir, { recursive: true, force: true });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch { /* lock missing or owned by someone else — best-effort, do nothing */ }
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CACHE_MANIFEST = void 0;
|
|
7
|
+
exports.artifactIdentity = artifactIdentity;
|
|
8
|
+
exports.sanitizeSegment = sanitizeSegment;
|
|
9
|
+
exports.cacheOrigin = cacheOrigin;
|
|
10
|
+
exports.cacheDirFor = cacheDirFor;
|
|
11
|
+
exports.planCacheRefresh = planCacheRefresh;
|
|
12
|
+
/**
|
|
13
|
+
* Pure cache-planning core for `skill exec --target host`.
|
|
14
|
+
*
|
|
15
|
+
* The executed artifact is identified by {doc_id, published, execution_revision_id}:
|
|
16
|
+
* reads serve ACTIVE-SNAPSHOT content when published (head may be newer), so the
|
|
17
|
+
* execution revision is active_snapshot_revision_id when published and
|
|
18
|
+
* head_revision_id only for unpublished drafts. Comparing head alone would run
|
|
19
|
+
* stale cached content after a publish that promotes without moving head.
|
|
20
|
+
*
|
|
21
|
+
* planCacheRefresh() is deliberately pure (no fs, no network) so cache
|
|
22
|
+
* correctness — noop detection, per-file skip, upstream deletions, local
|
|
23
|
+
* drift — is unit-testable. The fs side lives in skill-cache-fs.ts.
|
|
24
|
+
*/
|
|
25
|
+
const os_1 = __importDefault(require("os"));
|
|
26
|
+
const path_1 = __importDefault(require("path"));
|
|
27
|
+
const url_1 = require("url");
|
|
28
|
+
exports.CACHE_MANIFEST = '.sa-cache-manifest.json';
|
|
29
|
+
function toNum(v) {
|
|
30
|
+
if (v === null || v === undefined)
|
|
31
|
+
return null;
|
|
32
|
+
const n = typeof v === 'string' ? parseInt(v, 10) : v;
|
|
33
|
+
return Number.isNaN(n) ? null : n;
|
|
34
|
+
}
|
|
35
|
+
function artifactIdentity(bundle) {
|
|
36
|
+
const published = bundle.published !== false;
|
|
37
|
+
const executionRevisionId = published
|
|
38
|
+
// The `?? toNum(bundle.head_revision_id)` fallback guards a domain-unreachable
|
|
39
|
+
// state: a published doc without an active snapshot revision.
|
|
40
|
+
? (toNum(bundle.active_snapshot_revision_id) ?? toNum(bundle.head_revision_id))
|
|
41
|
+
: toNum(bundle.head_revision_id);
|
|
42
|
+
return { docId: toNum(bundle.doc_id), published, executionRevisionId };
|
|
43
|
+
}
|
|
44
|
+
function sanitizeSegment(s) {
|
|
45
|
+
return s.replace(/[^a-zA-Z0-9._-]/g, '_');
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Cache identity for "which server + which workspace": host authority (host:port)
|
|
49
|
+
* plus the canonical workspace id. NOT the workspace slug — Config distinguishes
|
|
50
|
+
* cosmetic `workspace` from canonical `workspaceId`, and custom hosts may collide
|
|
51
|
+
* on ids alone.
|
|
52
|
+
*/
|
|
53
|
+
function cacheOrigin(config) {
|
|
54
|
+
const authority = new url_1.URL(config.host).host; // host[:port]
|
|
55
|
+
return `${sanitizeSegment(authority)}__${sanitizeSegment(config.workspaceId ?? 'default')}`;
|
|
56
|
+
}
|
|
57
|
+
function cacheDirFor(config, scope, skillName) {
|
|
58
|
+
const base = path_1.default.join(os_1.default.homedir(), '.solidactions', 'cache', 'skills', cacheOrigin(config));
|
|
59
|
+
const scopeSegs = scope.kind === 'shared'
|
|
60
|
+
? ['shared']
|
|
61
|
+
: [sanitizeSegment(scope.crewPath), sanitizeSegment(scope.role)];
|
|
62
|
+
return path_1.default.join(base, ...scopeSegs, sanitizeSegment(skillName));
|
|
63
|
+
}
|
|
64
|
+
function planCacheRefresh(args) {
|
|
65
|
+
const { manifest, origin, identity, desired, onDisk } = args;
|
|
66
|
+
const mfiles = manifest?.files ?? {};
|
|
67
|
+
const identityOk = !!manifest
|
|
68
|
+
&& manifest.schema_version === 1
|
|
69
|
+
&& manifest.origin === origin
|
|
70
|
+
&& manifest.doc_id === identity.docId
|
|
71
|
+
&& manifest.published === identity.published
|
|
72
|
+
&& manifest.execution_revision_id === identity.executionRevisionId;
|
|
73
|
+
const writes = [];
|
|
74
|
+
for (const [p, spec] of Object.entries(desired)) {
|
|
75
|
+
const m = mfiles[p];
|
|
76
|
+
const upstreamSame = !!m && (spec.kind === 'text' ? m.sha256 === spec.sha256 : m.blob_sha === spec.blobSha);
|
|
77
|
+
const diskSame = !!m && onDisk[p] !== null && onDisk[p] !== undefined && onDisk[p] === m.sha256;
|
|
78
|
+
if (!upstreamSame || !diskSame)
|
|
79
|
+
writes.push(p);
|
|
80
|
+
}
|
|
81
|
+
const deletes = Object.keys(mfiles).filter((p) => !(p in desired));
|
|
82
|
+
const action = !identityOk || writes.length > 0 || deletes.length > 0 ? 'refresh' : 'noop';
|
|
83
|
+
return { action, writes: action === 'noop' ? [] : writes, deletes: action === 'noop' ? [] : deletes };
|
|
84
|
+
}
|
package/dist/utils/skills.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SOLIDACTIONS_SKILL_NAMES = void 0;
|
|
6
7
|
exports.skillTargetDir = skillTargetDir;
|
|
7
8
|
exports.installSkills = installSkills;
|
|
8
9
|
exports.fetchAiHelperContent = fetchAiHelperContent;
|
|
@@ -11,11 +12,12 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
11
12
|
const path_1 = __importDefault(require("path"));
|
|
12
13
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
13
14
|
const github_1 = require("./github");
|
|
14
|
-
|
|
15
|
+
exports.SOLIDACTIONS_SKILL_NAMES = [
|
|
15
16
|
'solidactions-getting-started',
|
|
16
17
|
'solidactions-workflow-coding',
|
|
17
18
|
'solidactions-deploy-and-config',
|
|
18
19
|
'solidactions-oauth-actions',
|
|
20
|
+
'solidactions-crew-skills',
|
|
19
21
|
];
|
|
20
22
|
const EXAMPLES_OWNER = 'SolidActions';
|
|
21
23
|
const EXAMPLES_REPO = 'solidactions-examples';
|
|
@@ -43,7 +45,7 @@ function skillTargetDir(targetFile, cwd = process.cwd()) {
|
|
|
43
45
|
async function installSkills(targetDir) {
|
|
44
46
|
const written = [];
|
|
45
47
|
fs_extra_1.default.ensureDirSync(targetDir);
|
|
46
|
-
for (const skillName of
|
|
48
|
+
for (const skillName of exports.SOLIDACTIONS_SKILL_NAMES) {
|
|
47
49
|
const remotePath = `${SKILLS_PATH_PREFIX}/${skillName}.md`;
|
|
48
50
|
const content = await (0, github_1.fetchRawFile)(EXAMPLES_OWNER, EXAMPLES_REPO, remotePath);
|
|
49
51
|
const filePath = path_1.default.join(targetDir, `${skillName}.md`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidactions/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.1",
|
|
4
4
|
"description": "SolidActions CLI - Deploy and manage workflow automation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -33,24 +33,27 @@
|
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsc && cp src/commands/dev-shim.mjs dist/commands/dev-shim.mjs",
|
|
36
|
+
"check:release": "npm run build && npm run test && npm run smoke:init",
|
|
36
37
|
"prepublishOnly": "npm run build",
|
|
38
|
+
"smoke:init": "node scripts/smoke-init.mjs",
|
|
37
39
|
"test": "vitest run",
|
|
38
40
|
"test:watch": "vitest"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
43
|
"archiver": "^7.0.0",
|
|
42
|
-
"axios": "^1.
|
|
44
|
+
"axios": "^1.18.1",
|
|
43
45
|
"chalk": "^4.1.2",
|
|
44
46
|
"commander": "^11.0.0",
|
|
45
47
|
"dotenv": "^17.3.1",
|
|
46
|
-
"form-data": "^4.0.
|
|
48
|
+
"form-data": "^4.0.6",
|
|
47
49
|
"fs-extra": "^11.0.0",
|
|
48
50
|
"ignore": "^7.0.5",
|
|
49
|
-
"js-yaml": "^4.
|
|
51
|
+
"js-yaml": "^4.3.0",
|
|
50
52
|
"prompts": "^2.4.2",
|
|
51
|
-
"tar": "^7.5.
|
|
53
|
+
"tar": "^7.5.20"
|
|
52
54
|
},
|
|
53
55
|
"devDependencies": {
|
|
56
|
+
"@solidactions/sdk": "^0.7.3",
|
|
54
57
|
"@types/archiver": "^6.0.0",
|
|
55
58
|
"@types/fs-extra": "^11.0.0",
|
|
56
59
|
"@types/js-yaml": "^4.0.9",
|