@solidactions/cli 1.27.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.
- package/dist/commands/skill-publish.js +22 -0
- package/dist/commands/skill-push.js +72 -3
- package/dist/index.js +10 -0
- package/dist/utils/skill-snapshot.js +89 -0
- package/package.json +1 -1
|
@@ -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
|
+
}
|
|
@@ -20,6 +20,7 @@ exports.readReferences = readReferences;
|
|
|
20
20
|
exports.readSkillDir = readSkillDir;
|
|
21
21
|
exports.parseCommandFile = parseCommandFile;
|
|
22
22
|
exports.pushParsedSkill = pushParsedSkill;
|
|
23
|
+
exports.stagedPushWarning = stagedPushWarning;
|
|
23
24
|
exports.skillPushWithConfig = skillPushWithConfig;
|
|
24
25
|
exports.skillPush = skillPush;
|
|
25
26
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -28,6 +29,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
28
29
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
29
30
|
const api_1 = require("../utils/api");
|
|
30
31
|
const mcp_1 = require("../utils/mcp");
|
|
32
|
+
const skill_snapshot_1 = require("../utils/skill-snapshot");
|
|
31
33
|
/**
|
|
32
34
|
* Protocol param names reserved by the skills/roles MCP tool actions. Frontmatter
|
|
33
35
|
* keys that collide with these would silently corrupt the request once spread
|
|
@@ -288,6 +290,41 @@ function printPushResult(result, options) {
|
|
|
288
290
|
console.log(chalk_1.default.green(`created skill '${name}' (doc ${skillDocId}, ${refCount} refs)`));
|
|
289
291
|
}
|
|
290
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
|
+
}
|
|
291
328
|
/**
|
|
292
329
|
* Core implementation — accepts an injected config so tests can point at a
|
|
293
330
|
* stub server without touching the filesystem config.
|
|
@@ -301,6 +338,10 @@ async function skillPushWithConfig(dir, options, config) {
|
|
|
301
338
|
process.stderr.write(chalk_1.default.red(`error: "${dir}" is not a directory.\n`));
|
|
302
339
|
process.exit(1);
|
|
303
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
|
+
}
|
|
304
345
|
const topLevelSkillMd = path_1.default.join(absDir, 'SKILL.md');
|
|
305
346
|
// -------------------------------------------------------------------------
|
|
306
347
|
// Single-skill mode: <dir>/SKILL.md exists
|
|
@@ -322,17 +363,45 @@ async function skillPushWithConfig(dir, options, config) {
|
|
|
322
363
|
process.stderr.write(chalk_1.default.red(`error: ${e.message}\n`));
|
|
323
364
|
process.exit(1);
|
|
324
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
|
+
}
|
|
325
383
|
if (options.json) {
|
|
326
|
-
|
|
384
|
+
const payload = publishOutcome ? { ...pushResult.data, publish: publishOutcome } : pushResult.data;
|
|
385
|
+
console.log(JSON.stringify(payload));
|
|
386
|
+
process.exit(publishOutcome?.status === 'error' ? 1 : 0);
|
|
327
387
|
}
|
|
328
|
-
|
|
329
|
-
|
|
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));
|
|
330
395
|
}
|
|
331
396
|
process.exit(0);
|
|
332
397
|
}
|
|
333
398
|
// -------------------------------------------------------------------------
|
|
334
399
|
// Plugin mode: push skills/<name>/SKILL.md + commands/<name>.md
|
|
335
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
|
+
}
|
|
336
405
|
const payloads = [];
|
|
337
406
|
// One-level glob: skills/*/SKILL.md
|
|
338
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
|
+
}
|