@solidactions/cli 1.26.0 → 1.28.0
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.
|
@@ -56,6 +56,7 @@ async function rolePushWithConfig(dir, options, config) {
|
|
|
56
56
|
let body;
|
|
57
57
|
try {
|
|
58
58
|
({ name, description, properties, body } = (0, skill_push_1.parseSkillFile)(skillMdContent));
|
|
59
|
+
(0, skill_push_1.assertNoReservedFrontmatterKeys)(properties);
|
|
59
60
|
}
|
|
60
61
|
catch (e) {
|
|
61
62
|
process.stderr.write(chalk_1.default.red(`error: ${e.message}\n`));
|
|
@@ -99,14 +100,15 @@ async function rolePushWithConfig(dir, options, config) {
|
|
|
99
100
|
}
|
|
100
101
|
// Upsert: try create first; on name_collision switch to edit.
|
|
101
102
|
// Roles carry NO references — do not send references key.
|
|
103
|
+
// Frontmatter extras are spread FIRST so the fixed protocol keys always win.
|
|
102
104
|
let result;
|
|
103
105
|
try {
|
|
104
106
|
result = await (0, mcp_1.callCrewsTool)(config, 'roles', {
|
|
107
|
+
...properties,
|
|
105
108
|
action: 'create',
|
|
106
109
|
name,
|
|
107
110
|
description,
|
|
108
111
|
body,
|
|
109
|
-
properties,
|
|
110
112
|
});
|
|
111
113
|
}
|
|
112
114
|
catch (e) {
|
|
@@ -114,15 +116,15 @@ async function rolePushWithConfig(dir, options, config) {
|
|
|
114
116
|
process.exit(1);
|
|
115
117
|
}
|
|
116
118
|
// On name collision, switch to the edit path.
|
|
117
|
-
// Roles edit uses 'name' (NOT 'identifier')
|
|
119
|
+
// Roles edit uses 'name' (NOT 'identifier').
|
|
118
120
|
if (!result.ok && result.data?.code === 'name_collision') {
|
|
119
121
|
try {
|
|
120
122
|
result = await (0, mcp_1.callCrewsTool)(config, 'roles', {
|
|
123
|
+
...properties,
|
|
121
124
|
action: 'edit',
|
|
122
125
|
name,
|
|
123
126
|
description,
|
|
124
127
|
body,
|
|
125
|
-
properties_patch: properties,
|
|
126
128
|
});
|
|
127
129
|
}
|
|
128
130
|
catch (e) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* solidactions skill publish <name>
|
|
4
|
+
*
|
|
5
|
+
* Publishes (snapshots) a shared skill so its latest pushed revision goes live
|
|
6
|
+
* for agents.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.skillPublishWithConfig = skillPublishWithConfig;
|
|
10
|
+
exports.skillPublish = skillPublish;
|
|
11
|
+
const api_1 = require("../utils/api");
|
|
12
|
+
const skill_snapshot_1 = require("../utils/skill-snapshot");
|
|
13
|
+
/** Core implementation — accepts an injected config for tests. */
|
|
14
|
+
async function skillPublishWithConfig(name, options, config) {
|
|
15
|
+
const outcome = await (0, skill_snapshot_1.publishSkillByName)(config, name);
|
|
16
|
+
(0, skill_snapshot_1.emitPublishOutcome)(name, outcome, { json: options.json });
|
|
17
|
+
}
|
|
18
|
+
/** Entry point called from index.ts. */
|
|
19
|
+
async function skillPublish(name, options) {
|
|
20
|
+
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
21
|
+
await skillPublishWithConfig(name, options, config);
|
|
22
|
+
}
|
|
@@ -13,11 +13,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.RESERVED_PARAM_KEYS = void 0;
|
|
17
|
+
exports.assertNoReservedFrontmatterKeys = assertNoReservedFrontmatterKeys;
|
|
16
18
|
exports.parseSkillFile = parseSkillFile;
|
|
17
19
|
exports.readReferences = readReferences;
|
|
18
20
|
exports.readSkillDir = readSkillDir;
|
|
19
21
|
exports.parseCommandFile = parseCommandFile;
|
|
20
22
|
exports.pushParsedSkill = pushParsedSkill;
|
|
23
|
+
exports.stagedPushWarning = stagedPushWarning;
|
|
21
24
|
exports.skillPushWithConfig = skillPushWithConfig;
|
|
22
25
|
exports.skillPush = skillPush;
|
|
23
26
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -26,6 +29,23 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
26
29
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
27
30
|
const api_1 = require("../utils/api");
|
|
28
31
|
const mcp_1 = require("../utils/mcp");
|
|
32
|
+
const skill_snapshot_1 = require("../utils/skill-snapshot");
|
|
33
|
+
/**
|
|
34
|
+
* Protocol param names reserved by the skills/roles MCP tool actions. Frontmatter
|
|
35
|
+
* keys that collide with these would silently corrupt the request once spread
|
|
36
|
+
* top-level into the call arguments.
|
|
37
|
+
*/
|
|
38
|
+
exports.RESERVED_PARAM_KEYS = ['action', 'identifier', 'role', 'name', 'description', 'body', 'references', 'base_version_id'];
|
|
39
|
+
/**
|
|
40
|
+
* Throws if any frontmatter-derived property key collides with a reserved
|
|
41
|
+
* protocol param name.
|
|
42
|
+
*/
|
|
43
|
+
function assertNoReservedFrontmatterKeys(properties) {
|
|
44
|
+
const offending = Object.keys(properties).filter((key) => exports.RESERVED_PARAM_KEYS.includes(key));
|
|
45
|
+
if (offending.length > 0) {
|
|
46
|
+
throw new Error(`SKILL.md frontmatter contains reserved key(s) that would collide with protocol params: ${offending.join(', ')}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
29
49
|
/**
|
|
30
50
|
* Parse a SKILL.md file that begins with a YAML frontmatter block.
|
|
31
51
|
*
|
|
@@ -177,6 +197,7 @@ function parseCommandFile(filename, content) {
|
|
|
177
197
|
*/
|
|
178
198
|
async function pushParsedSkill(payload, options, config) {
|
|
179
199
|
const { name, description, properties, body, references } = payload;
|
|
200
|
+
assertNoReservedFrontmatterKeys(properties);
|
|
180
201
|
const isRole = !!options.role;
|
|
181
202
|
const tool = isRole ? 'roles' : 'skills';
|
|
182
203
|
// --dry-run: pre-flight a read to detect existence; make NO create/edit calls.
|
|
@@ -207,9 +228,10 @@ async function pushParsedSkill(payload, options, config) {
|
|
|
207
228
|
// Read succeeded → skill exists → would update
|
|
208
229
|
return { status: 'would-update', name, data: {} };
|
|
209
230
|
}
|
|
231
|
+
// Spread frontmatter extras FIRST so the fixed protocol keys always win.
|
|
210
232
|
const createArgs = isRole
|
|
211
|
-
? { action: 'create_skill', role: options.role, name, description, body,
|
|
212
|
-
: { action: 'create', name, description, body,
|
|
233
|
+
? { ...properties, action: 'create_skill', role: options.role, name, description, body, references }
|
|
234
|
+
: { ...properties, action: 'create', name, description, body, references };
|
|
213
235
|
let result;
|
|
214
236
|
try {
|
|
215
237
|
result = await (0, mcp_1.callCrewsTool)(config, tool, createArgs);
|
|
@@ -217,11 +239,11 @@ async function pushParsedSkill(payload, options, config) {
|
|
|
217
239
|
catch (e) {
|
|
218
240
|
throw new Error(`${e.message}`);
|
|
219
241
|
}
|
|
220
|
-
// On name collision, switch to the edit path.
|
|
242
|
+
// On name collision, switch to the edit path.
|
|
221
243
|
if (!result.ok && result.data?.code === 'name_collision') {
|
|
222
244
|
const editArgs = isRole
|
|
223
|
-
? { action: 'edit_skill', role: options.role, name, description, body,
|
|
224
|
-
: { action: 'edit', identifier: name, description, body,
|
|
245
|
+
? { ...properties, action: 'edit_skill', role: options.role, name, description, body, references }
|
|
246
|
+
: { ...properties, action: 'edit', identifier: name, description, body, references };
|
|
225
247
|
try {
|
|
226
248
|
result = await (0, mcp_1.callCrewsTool)(config, tool, editArgs);
|
|
227
249
|
}
|
|
@@ -268,6 +290,41 @@ function printPushResult(result, options) {
|
|
|
268
290
|
console.log(chalk_1.default.green(`created skill '${name}' (doc ${skillDocId}, ${refCount} refs)`));
|
|
269
291
|
}
|
|
270
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* Build the "staged, not published" warning for a successful single-skill push,
|
|
295
|
+
* or null when nothing needs publishing.
|
|
296
|
+
*
|
|
297
|
+
* Edit path (status 'updated'): default reads return the active snapshot, so a
|
|
298
|
+
* new revision is dark to agents until published — warn when the server reports
|
|
299
|
+
* has_unpublished_revisions === true.
|
|
300
|
+
* Create path (status 'created'): a brand-new skill has no snapshot, so reads
|
|
301
|
+
* fall back to the unversioned draft (it runs, just isn't pinned) — warn on a
|
|
302
|
+
* truthy snapshot_hint (null when the skill is version_mode=live).
|
|
303
|
+
* Dry-run statuses never warn.
|
|
304
|
+
*/
|
|
305
|
+
function stagedPushWarning(result, isRole) {
|
|
306
|
+
const { status, name, data } = result;
|
|
307
|
+
if (status === 'created') {
|
|
308
|
+
if (!data.snapshot_hint) {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
else if (status === 'updated') {
|
|
313
|
+
if (data.has_unpublished_revisions !== true) {
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
const publishLine = isRole
|
|
321
|
+
? ` Publish this role-scoped skill via the MCP crews_versions take_snapshot tool.\n`
|
|
322
|
+
: ` Run: solidactions skill publish ${name}\n`;
|
|
323
|
+
const headline = status === 'updated'
|
|
324
|
+
? `⚠ Staged, not published. This revision won't run for agents until you publish it.\n`
|
|
325
|
+
: `⚠ Not yet published. Agents read the unversioned draft until you publish to pin a version.\n`;
|
|
326
|
+
return headline + publishLine;
|
|
327
|
+
}
|
|
271
328
|
/**
|
|
272
329
|
* Core implementation — accepts an injected config so tests can point at a
|
|
273
330
|
* stub server without touching the filesystem config.
|
|
@@ -281,6 +338,10 @@ async function skillPushWithConfig(dir, options, config) {
|
|
|
281
338
|
process.stderr.write(chalk_1.default.red(`error: "${dir}" is not a directory.\n`));
|
|
282
339
|
process.exit(1);
|
|
283
340
|
}
|
|
341
|
+
if (options.publish && options.role) {
|
|
342
|
+
process.stderr.write(chalk_1.default.red('error: --publish is not supported with --role yet; publish the role-scoped skill via the MCP take_snapshot tool.\n'));
|
|
343
|
+
process.exit(1);
|
|
344
|
+
}
|
|
284
345
|
const topLevelSkillMd = path_1.default.join(absDir, 'SKILL.md');
|
|
285
346
|
// -------------------------------------------------------------------------
|
|
286
347
|
// Single-skill mode: <dir>/SKILL.md exists
|
|
@@ -302,17 +363,45 @@ async function skillPushWithConfig(dir, options, config) {
|
|
|
302
363
|
process.stderr.write(chalk_1.default.red(`error: ${e.message}\n`));
|
|
303
364
|
process.exit(1);
|
|
304
365
|
}
|
|
366
|
+
// Optionally publish (snapshot) the just-pushed revision (single-skill mode).
|
|
367
|
+
let publishOutcome = null;
|
|
368
|
+
if (options.publish && !options.dryRun) {
|
|
369
|
+
if (pushResult.status === 'created') {
|
|
370
|
+
if (!pushResult.data.snapshot_hint) {
|
|
371
|
+
// Live-mode (version_mode=live) skill: no snapshot to take — already live.
|
|
372
|
+
publishOutcome = { status: 'live_mode' };
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
const createdDocId = (pushResult.data.skill_doc_id ?? pushResult.data.doc_id ?? pushResult.data.id);
|
|
376
|
+
publishOutcome = await (0, skill_snapshot_1.publishSkillByDocId)(config, createdDocId);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
publishOutcome = await (0, skill_snapshot_1.publishSkillByName)(config, pushResult.name);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
305
383
|
if (options.json) {
|
|
306
|
-
|
|
384
|
+
const payload = publishOutcome ? { ...pushResult.data, publish: publishOutcome } : pushResult.data;
|
|
385
|
+
console.log(JSON.stringify(payload));
|
|
386
|
+
process.exit(publishOutcome?.status === 'error' ? 1 : 0);
|
|
307
387
|
}
|
|
308
|
-
|
|
309
|
-
|
|
388
|
+
printPushResult(pushResult, options);
|
|
389
|
+
if (publishOutcome) {
|
|
390
|
+
(0, skill_snapshot_1.emitPublishOutcome)(pushResult.name, publishOutcome, { pushed: true });
|
|
391
|
+
}
|
|
392
|
+
const warning = stagedPushWarning(pushResult, !!options.role);
|
|
393
|
+
if (warning) {
|
|
394
|
+
process.stderr.write(chalk_1.default.yellow(warning));
|
|
310
395
|
}
|
|
311
396
|
process.exit(0);
|
|
312
397
|
}
|
|
313
398
|
// -------------------------------------------------------------------------
|
|
314
399
|
// Plugin mode: push skills/<name>/SKILL.md + commands/<name>.md
|
|
315
400
|
// -------------------------------------------------------------------------
|
|
401
|
+
if (options.publish) {
|
|
402
|
+
process.stderr.write(chalk_1.default.red('error: --publish is not supported when pushing a plugin bundle (multiple skills); publish each with "solidactions skill publish <name>".\n'));
|
|
403
|
+
process.exit(1);
|
|
404
|
+
}
|
|
316
405
|
const payloads = [];
|
|
317
406
|
// One-level glob: skills/*/SKILL.md
|
|
318
407
|
const skillsDir = path_1.default.join(absDir, 'skills');
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ const oauth_actions_show_1 = require("./commands/oauth-actions-show");
|
|
|
36
36
|
const oauth_actions_platforms_1 = require("./commands/oauth-actions-platforms");
|
|
37
37
|
const workspaces_1 = require("./commands/workspaces");
|
|
38
38
|
const skill_push_1 = require("./commands/skill-push");
|
|
39
|
+
const skill_publish_1 = require("./commands/skill-publish");
|
|
39
40
|
const skill_pull_1 = require("./commands/skill-pull");
|
|
40
41
|
const skill_list_1 = require("./commands/skill-list");
|
|
41
42
|
const skill_view_1 = require("./commands/skill-view");
|
|
@@ -459,9 +460,18 @@ skill
|
|
|
459
460
|
.option('--role <name>', 'Scope the skill to a role instead of the shared library')
|
|
460
461
|
.option('--json', 'Output result as JSON')
|
|
461
462
|
.option('--dry-run', 'Preview create vs update without writing')
|
|
463
|
+
.option('--publish', 'Publish (snapshot) the skill after pushing, making it live for agents')
|
|
462
464
|
.action(async (dir, options) => {
|
|
463
465
|
await (0, skill_push_1.skillPush)(dir, options);
|
|
464
466
|
});
|
|
467
|
+
skill
|
|
468
|
+
.command('publish')
|
|
469
|
+
.description('Publish (snapshot) a skill so its latest pushed revision goes live for agents')
|
|
470
|
+
.argument('<name>', 'Skill name/identifier (e.g. "my-skill" or "shared/my-skill")')
|
|
471
|
+
.option('--json', 'Output result as JSON')
|
|
472
|
+
.action(async (name, options) => {
|
|
473
|
+
await (0, skill_publish_1.skillPublish)(name, options);
|
|
474
|
+
});
|
|
465
475
|
skill
|
|
466
476
|
.command('pull')
|
|
467
477
|
.description('Fetch a skill from the library to a local folder for editing (inverse of push)')
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Publish (snapshot) helpers for crews skills.
|
|
4
|
+
*
|
|
5
|
+
* Composes two existing MCP actions: crews_skills.read resolves a skill name to
|
|
6
|
+
* its doc_id and reports whether the current revision is unpublished, and
|
|
7
|
+
* crews_versions.take_snapshot promotes that revision to all agents.
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.publishSkillByDocId = publishSkillByDocId;
|
|
14
|
+
exports.publishSkillByName = publishSkillByName;
|
|
15
|
+
exports.emitPublishOutcome = emitPublishOutcome;
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const mcp_1 = require("./mcp");
|
|
18
|
+
/** Snapshot a skill by its doc_id (crews_versions.take_snapshot). */
|
|
19
|
+
async function publishSkillByDocId(config, docId) {
|
|
20
|
+
let result;
|
|
21
|
+
try {
|
|
22
|
+
result = await (0, mcp_1.callCrewsTool)(config, 'crews_versions', { action: 'take_snapshot', doc_id: docId });
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
return { status: 'error', code: 'mcp_request_failed', message: e.message };
|
|
26
|
+
}
|
|
27
|
+
if (!result.ok) {
|
|
28
|
+
return { status: 'error', code: result.data?.code ?? 'unknown_error', message: result.data?.message ?? 'take_snapshot returned an error with no message' };
|
|
29
|
+
}
|
|
30
|
+
return { status: 'published', snapshotId: result.data.snapshot_id };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resolve a skill name to its doc_id, then publish — short-circuiting when the
|
|
34
|
+
* current revision is already live (no take_snapshot call). Detection uses the
|
|
35
|
+
* read response, NOT the take_snapshot error code (the server maps both
|
|
36
|
+
* "nothing to snapshot" and "live-mode" to the same not_snapshotable code).
|
|
37
|
+
*/
|
|
38
|
+
async function publishSkillByName(config, name) {
|
|
39
|
+
let read;
|
|
40
|
+
try {
|
|
41
|
+
read = await (0, mcp_1.callCrewsTool)(config, 'skills', { action: 'read', identifier: name });
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
return { status: 'error', code: 'mcp_request_failed', message: e.message };
|
|
45
|
+
}
|
|
46
|
+
if (!read.ok) {
|
|
47
|
+
return { status: 'error', code: read.data?.code ?? 'unknown_error', message: read.data?.message ?? 'read returned an error with no message' };
|
|
48
|
+
}
|
|
49
|
+
const data = read.data;
|
|
50
|
+
// Metadata absent entirely → live-mode doc (edits are already live).
|
|
51
|
+
if (data.has_unpublished_revisions === undefined) {
|
|
52
|
+
return { status: 'live_mode' };
|
|
53
|
+
}
|
|
54
|
+
// HEAD already snapshotted → nothing to publish.
|
|
55
|
+
if (data.has_unpublished_revisions === false) {
|
|
56
|
+
return { status: 'already_published' };
|
|
57
|
+
}
|
|
58
|
+
return publishSkillByDocId(config, data.doc_id);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Print a PublishOutcome and exit. `opts.pushed` tailors error copy for the
|
|
62
|
+
* `skill push --publish` case (push succeeded, publish failed). `opts.json`
|
|
63
|
+
* prints the raw outcome as JSON instead of human text.
|
|
64
|
+
*/
|
|
65
|
+
function emitPublishOutcome(name, outcome, opts = {}) {
|
|
66
|
+
if (opts.json) {
|
|
67
|
+
console.log(JSON.stringify(outcome));
|
|
68
|
+
process.exit(outcome.status === 'error' ? 1 : 0);
|
|
69
|
+
}
|
|
70
|
+
switch (outcome.status) {
|
|
71
|
+
case 'published':
|
|
72
|
+
console.log(chalk_1.default.green(`✔ published '${name}' — now live for agents`));
|
|
73
|
+
process.exit(0);
|
|
74
|
+
case 'already_published':
|
|
75
|
+
console.log(chalk_1.default.green('already published — nothing to do'));
|
|
76
|
+
process.exit(0);
|
|
77
|
+
case 'live_mode':
|
|
78
|
+
console.log(chalk_1.default.green('live-mode skill — edits are already live, nothing to publish'));
|
|
79
|
+
process.exit(0);
|
|
80
|
+
case 'error': {
|
|
81
|
+
const prefix = opts.pushed ? 'pushed, but publish failed — ' : '';
|
|
82
|
+
process.stderr.write(chalk_1.default.red(`${prefix}${outcome.code}: ${outcome.message}\n`));
|
|
83
|
+
if (opts.pushed) {
|
|
84
|
+
process.stderr.write(chalk_1.default.yellow(` The skill was pushed. Retry: solidactions skill publish ${name}\n`));
|
|
85
|
+
}
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|