@artifactshare/cli 0.5.1 → 0.5.2
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 +1 -1
- package/dist/index.js +145 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,7 +80,7 @@ npx --yes @artifactshare/cli open <artifact-id-or-url> --json
|
|
|
80
80
|
|
|
81
81
|
This installs or updates the local skill first, then reads single-file artifacts. Static sites and multi-file artifacts return a `download` next command.
|
|
82
82
|
|
|
83
|
-
To target a specific tool manually, use `skills install --tool <codex|claude|cursor>`; `skills ensure --tool auto` is the same detection `init` uses.
|
|
83
|
+
To target a specific tool manually, use `skills install --tool <codex|claude|cursor>`; `skills ensure --tool auto` is the same detection `init` uses. Regular successful commands also update outdated managed user-scope Codex and Claude Code skills when they are already installed.
|
|
84
84
|
|
|
85
85
|
Comment deletion is permanent. Use `comments delete <target> --thread-id <id> --message-id <id> --json` for one message, or omit `--message-id` only when deleting the whole thread.
|
|
86
86
|
|
package/dist/index.js
CHANGED
|
@@ -999,6 +999,18 @@ function writeSuccess(command, data, mode) {
|
|
|
999
999
|
}
|
|
1000
1000
|
process.stdout.write(humanSuccess(command, data));
|
|
1001
1001
|
}
|
|
1002
|
+
function dataWithSkillAutoUpdate(data, autoUpdate) {
|
|
1003
|
+
if (!autoUpdate || autoUpdate.targets.length === 0) return data;
|
|
1004
|
+
if (!isRecord(data)) return data;
|
|
1005
|
+
const existingSkills = isRecord(data.skills) ? data.skills : {};
|
|
1006
|
+
return {
|
|
1007
|
+
...data,
|
|
1008
|
+
skills: {
|
|
1009
|
+
...existingSkills,
|
|
1010
|
+
auto_update: autoUpdate
|
|
1011
|
+
}
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1002
1014
|
function writeFailure(command, error, mode, exitCode) {
|
|
1003
1015
|
const payload = {
|
|
1004
1016
|
schema_version: 2,
|
|
@@ -1017,10 +1029,11 @@ function writeEvent(data) {
|
|
|
1017
1029
|
process.stderr.write(`${JSON.stringify(data)}\n`);
|
|
1018
1030
|
}
|
|
1019
1031
|
function humanSuccess(command, data) {
|
|
1032
|
+
const suffix = skillAutoUpdateHumanOutput(data);
|
|
1020
1033
|
if (command === "share") {
|
|
1021
1034
|
const fields = shareSuccessFields(data);
|
|
1022
1035
|
if (!fields) return `${JSON.stringify(data, null, 2)}\n`;
|
|
1023
|
-
|
|
1036
|
+
const output = [
|
|
1024
1037
|
"Shared",
|
|
1025
1038
|
`Artifact ID: ${fields.artifactId}`,
|
|
1026
1039
|
`URL: ${fields.url}`,
|
|
@@ -1028,11 +1041,26 @@ function humanSuccess(command, data) {
|
|
|
1028
1041
|
`Visibility: ${fields.visibility}`,
|
|
1029
1042
|
""
|
|
1030
1043
|
].join("\n");
|
|
1044
|
+
return suffix ? `${output}${suffix}` : output;
|
|
1031
1045
|
}
|
|
1032
1046
|
if (command === "doctor") return doctorHumanOutput(data);
|
|
1033
1047
|
if (command === "open") return openHumanOutput(data);
|
|
1034
1048
|
if (command === "init") return initHumanOutput(data);
|
|
1035
|
-
|
|
1049
|
+
const output = `${JSON.stringify(data, null, 2)}\n`;
|
|
1050
|
+
return suffix ? `${output}${suffix}` : output;
|
|
1051
|
+
}
|
|
1052
|
+
function skillAutoUpdateHumanOutput(data) {
|
|
1053
|
+
if (!isRecord(data)) return "";
|
|
1054
|
+
const skills = data.skills;
|
|
1055
|
+
if (!isRecord(skills)) return "";
|
|
1056
|
+
const autoUpdate = skills.auto_update;
|
|
1057
|
+
if (!isRecord(autoUpdate) || !Array.isArray(autoUpdate.targets)) return "";
|
|
1058
|
+
const lines = autoUpdate.targets.filter(isRecord).map((target) => {
|
|
1059
|
+
const label = typeof target.tool === "string" && typeof target.scope === "string" ? `${target.tool}:${target.scope}` : "unknown";
|
|
1060
|
+
if (target.action === "update_recommended" && typeof target.update_command === "string") return `Skill update recommended: ${label} (${target.update_command})`;
|
|
1061
|
+
return `Skill updated: ${label}`;
|
|
1062
|
+
});
|
|
1063
|
+
return lines.length > 0 ? `${lines.join("\n")}\n` : "";
|
|
1036
1064
|
}
|
|
1037
1065
|
function initHumanOutput(data) {
|
|
1038
1066
|
const body = `${JSON.stringify(data, null, 2)}`;
|
|
@@ -2794,6 +2822,46 @@ async function ensureSkills(parsed, mode, options = {}) {
|
|
|
2794
2822
|
}
|
|
2795
2823
|
return finishActions(command, planned, parsed.options.dryRun === true, mode);
|
|
2796
2824
|
}
|
|
2825
|
+
async function autoUpdateUserManagedSkills() {
|
|
2826
|
+
try {
|
|
2827
|
+
const bundled = await loadBundledSkills();
|
|
2828
|
+
const planned = [];
|
|
2829
|
+
for (const target of allTargets().filter((candidate) => candidate.scope === "user")) {
|
|
2830
|
+
const state = await readTarget(target);
|
|
2831
|
+
if (state.kind !== "managed" || state.version >= bundled.version) continue;
|
|
2832
|
+
planned.push({
|
|
2833
|
+
target,
|
|
2834
|
+
action: "updated",
|
|
2835
|
+
content: bundled.contents[target.tool],
|
|
2836
|
+
fallbackAction: "update_recommended",
|
|
2837
|
+
installedVersion: state.version
|
|
2838
|
+
});
|
|
2839
|
+
}
|
|
2840
|
+
if (planned.length === 0) return void 0;
|
|
2841
|
+
const completed = [...planned];
|
|
2842
|
+
for (const [index, item] of planned.entries()) try {
|
|
2843
|
+
await applyAction(item);
|
|
2844
|
+
completed[index] = item;
|
|
2845
|
+
} catch {
|
|
2846
|
+
completed[index] = {
|
|
2847
|
+
target: item.target,
|
|
2848
|
+
action: "update_recommended",
|
|
2849
|
+
...item.installedVersion !== void 0 ? { installedVersion: item.installedVersion } : {}
|
|
2850
|
+
};
|
|
2851
|
+
}
|
|
2852
|
+
return { targets: completed.map(({ target, action, installedVersion }) => ({
|
|
2853
|
+
tool: target.tool,
|
|
2854
|
+
scope: "user",
|
|
2855
|
+
path: target.path,
|
|
2856
|
+
action: action === "updated" ? "updated" : "update_recommended",
|
|
2857
|
+
installed_version: installedVersion ?? bundled.version,
|
|
2858
|
+
bundled_version: bundled.version,
|
|
2859
|
+
...action === "update_recommended" ? { update_command: skillUpdateCommand(target) } : {}
|
|
2860
|
+
})) };
|
|
2861
|
+
} catch {
|
|
2862
|
+
return;
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2797
2865
|
async function runSkillsEnsure(parsed, mode) {
|
|
2798
2866
|
const data = await ensureSkills(parsed, mode);
|
|
2799
2867
|
if (data) writeSuccess("skills ensure", data, mode);
|
|
@@ -4468,35 +4536,36 @@ async function runWhoami(parsed, mode) {
|
|
|
4468
4536
|
//#region src/commands.ts
|
|
4469
4537
|
async function shareRunner(ctx) {
|
|
4470
4538
|
const parsed = parsedArgsFromContext("share", ctx);
|
|
4471
|
-
return await runShare(parsed, outputMode(parsed.options));
|
|
4539
|
+
return await runWithSkillAutoUpdate(parsed, () => runShare(parsed, outputMode(parsed.options)));
|
|
4472
4540
|
}
|
|
4473
4541
|
async function loginRunner(ctx) {
|
|
4474
4542
|
const parsed = parsedArgsFromContext("login", ctx);
|
|
4475
|
-
|
|
4543
|
+
const mode = outputMode(parsed.options);
|
|
4544
|
+
return await runWithSkillAutoUpdate(parsed, () => runLogin(parsed, mode));
|
|
4476
4545
|
}
|
|
4477
4546
|
async function logoutRunner(ctx) {
|
|
4478
4547
|
const parsed = parsedArgsFromContext("logout", ctx);
|
|
4479
|
-
return await runLogout(parsed, outputMode(parsed.options));
|
|
4548
|
+
return await runWithSkillAutoUpdate(parsed, () => runLogout(parsed, outputMode(parsed.options)));
|
|
4480
4549
|
}
|
|
4481
4550
|
async function updateRunner(ctx) {
|
|
4482
4551
|
const parsed = parsedArgsFromContext("update", ctx);
|
|
4483
|
-
return await runUpdate(parsed, outputMode(parsed.options));
|
|
4552
|
+
return await runWithSkillAutoUpdate(parsed, () => runUpdate(parsed, outputMode(parsed.options)));
|
|
4484
4553
|
}
|
|
4485
4554
|
async function editRunner(ctx) {
|
|
4486
4555
|
const parsed = parsedArgsFromContext("edit", ctx);
|
|
4487
|
-
return await runEdit(parsed, outputMode(parsed.options));
|
|
4556
|
+
return await runWithSkillAutoUpdate(parsed, () => runEdit(parsed, outputMode(parsed.options)));
|
|
4488
4557
|
}
|
|
4489
4558
|
async function deleteRunner(ctx) {
|
|
4490
4559
|
const parsed = parsedArgsFromContext("delete", ctx);
|
|
4491
|
-
return await runDelete(parsed, outputMode(parsed.options));
|
|
4560
|
+
return await runWithSkillAutoUpdate(parsed, () => runDelete(parsed, outputMode(parsed.options)));
|
|
4492
4561
|
}
|
|
4493
4562
|
async function resolveRunner(ctx) {
|
|
4494
4563
|
const parsed = parsedArgsFromContext("resolve", ctx);
|
|
4495
|
-
return await runResolve(parsed, outputMode(parsed.options));
|
|
4564
|
+
return await runWithSkillAutoUpdate(parsed, () => runResolve(parsed, outputMode(parsed.options)));
|
|
4496
4565
|
}
|
|
4497
4566
|
async function downloadRunner(ctx) {
|
|
4498
4567
|
const parsed = parsedArgsFromContext("download", ctx);
|
|
4499
|
-
return await runDownload(parsed, outputMode(parsed.options));
|
|
4568
|
+
return await runWithSkillAutoUpdate(parsed, () => runDownload(parsed, outputMode(parsed.options)));
|
|
4500
4569
|
}
|
|
4501
4570
|
async function openRunner(ctx) {
|
|
4502
4571
|
const parsed = parsedArgsFromContext("open", ctx);
|
|
@@ -4504,76 +4573,76 @@ async function openRunner(ctx) {
|
|
|
4504
4573
|
}
|
|
4505
4574
|
async function moveRunner(ctx) {
|
|
4506
4575
|
const parsed = parsedArgsFromContext("move", ctx);
|
|
4507
|
-
return await runMove(parsed, outputMode(parsed.options));
|
|
4576
|
+
return await runWithSkillAutoUpdate(parsed, () => runMove(parsed, outputMode(parsed.options)));
|
|
4508
4577
|
}
|
|
4509
4578
|
async function artifactsGetRunner(ctx) {
|
|
4510
4579
|
const parsed = parsedArgsFromContext("artifacts get", ctx);
|
|
4511
|
-
return await runArtifactsGet(parsed, outputMode(parsed.options));
|
|
4580
|
+
return await runWithSkillAutoUpdate(parsed, () => runArtifactsGet(parsed, outputMode(parsed.options)));
|
|
4512
4581
|
}
|
|
4513
4582
|
async function artifactsListRunner(ctx) {
|
|
4514
4583
|
const parsed = parsedArgsFromContext("artifacts list", ctx);
|
|
4515
|
-
return await runArtifactsList(parsed, outputMode(parsed.options));
|
|
4584
|
+
return await runWithSkillAutoUpdate(parsed, () => runArtifactsList(parsed, outputMode(parsed.options)));
|
|
4516
4585
|
}
|
|
4517
4586
|
async function commentsListRunner(ctx) {
|
|
4518
4587
|
const parsed = parsedArgsFromContext("comments list", ctx);
|
|
4519
|
-
return await runCommentsList(parsed, outputMode(parsed.options));
|
|
4588
|
+
return await runWithSkillAutoUpdate(parsed, () => runCommentsList(parsed, outputMode(parsed.options)));
|
|
4520
4589
|
}
|
|
4521
4590
|
async function commentsPostRunner(ctx) {
|
|
4522
4591
|
const parsed = parsedArgsFromContext("comments post", ctx);
|
|
4523
|
-
return await runCommentsPost(parsed, outputMode(parsed.options));
|
|
4592
|
+
return await runWithSkillAutoUpdate(parsed, () => runCommentsPost(parsed, outputMode(parsed.options)));
|
|
4524
4593
|
}
|
|
4525
4594
|
async function commentsEditRunner(ctx) {
|
|
4526
4595
|
const parsed = parsedArgsFromContext("comments edit", ctx);
|
|
4527
|
-
return await runCommentsEdit(parsed, outputMode(parsed.options));
|
|
4596
|
+
return await runWithSkillAutoUpdate(parsed, () => runCommentsEdit(parsed, outputMode(parsed.options)));
|
|
4528
4597
|
}
|
|
4529
4598
|
async function commentsResolveRunner(ctx) {
|
|
4530
4599
|
const parsed = parsedArgsFromContext("comments resolve", ctx);
|
|
4531
|
-
return await runCommentsResolve(parsed, outputMode(parsed.options));
|
|
4600
|
+
return await runWithSkillAutoUpdate(parsed, () => runCommentsResolve(parsed, outputMode(parsed.options)));
|
|
4532
4601
|
}
|
|
4533
4602
|
async function commentsReopenRunner(ctx) {
|
|
4534
4603
|
const parsed = parsedArgsFromContext("comments reopen", ctx);
|
|
4535
|
-
return await runCommentsReopen(parsed, outputMode(parsed.options));
|
|
4604
|
+
return await runWithSkillAutoUpdate(parsed, () => runCommentsReopen(parsed, outputMode(parsed.options)));
|
|
4536
4605
|
}
|
|
4537
4606
|
async function commentsDeleteRunner(ctx) {
|
|
4538
4607
|
const parsed = parsedArgsFromContext("comments delete", ctx);
|
|
4539
|
-
return await runCommentsDelete(parsed, outputMode(parsed.options));
|
|
4608
|
+
return await runWithSkillAutoUpdate(parsed, () => runCommentsDelete(parsed, outputMode(parsed.options)));
|
|
4540
4609
|
}
|
|
4541
4610
|
async function requestAccessRunner(ctx) {
|
|
4542
4611
|
const parsed = parsedArgsFromContext("request-access", ctx);
|
|
4543
|
-
return await runRequestAccess(parsed, outputMode(parsed.options));
|
|
4612
|
+
return await runWithSkillAutoUpdate(parsed, () => runRequestAccess(parsed, outputMode(parsed.options)));
|
|
4544
4613
|
}
|
|
4545
4614
|
async function whoamiRunner(ctx) {
|
|
4546
4615
|
const parsed = parsedArgsFromContext("whoami", ctx);
|
|
4547
|
-
return await runWhoami(parsed, outputMode(parsed.options));
|
|
4616
|
+
return await runWithSkillAutoUpdate(parsed, () => runWhoami(parsed, outputMode(parsed.options)));
|
|
4548
4617
|
}
|
|
4549
4618
|
async function profilesListRunner(ctx) {
|
|
4550
4619
|
const parsed = parsedArgsFromContext("profiles list", ctx);
|
|
4551
|
-
return await runProfilesList(parsed, outputMode(parsed.options));
|
|
4620
|
+
return await runWithSkillAutoUpdate(parsed, () => runProfilesList(parsed, outputMode(parsed.options)));
|
|
4552
4621
|
}
|
|
4553
4622
|
async function profilesUseRunner(ctx) {
|
|
4554
4623
|
const parsed = parsedArgsFromContext("profiles use", ctx);
|
|
4555
|
-
return await runProfilesUse(parsed, outputMode(parsed.options));
|
|
4624
|
+
return await runWithSkillAutoUpdate(parsed, () => runProfilesUse(parsed, outputMode(parsed.options)));
|
|
4556
4625
|
}
|
|
4557
4626
|
async function profilesImportTokenRunner(ctx) {
|
|
4558
4627
|
const parsed = parsedArgsFromContext("profiles import-token", ctx);
|
|
4559
4628
|
if (hasOptionToken(ctx, "token")) parsed.options.token = "<redacted>";
|
|
4560
|
-
return await runProfilesImportToken(parsed, outputMode(parsed.options));
|
|
4629
|
+
return await runWithSkillAutoUpdate(parsed, () => runProfilesImportToken(parsed, outputMode(parsed.options)));
|
|
4561
4630
|
}
|
|
4562
4631
|
async function profilesDeleteRunner(ctx) {
|
|
4563
4632
|
const parsed = parsedArgsFromContext("profiles delete", ctx);
|
|
4564
|
-
return await runProfilesDelete(parsed, outputMode(parsed.options));
|
|
4633
|
+
return await runWithSkillAutoUpdate(parsed, () => runProfilesDelete(parsed, outputMode(parsed.options)));
|
|
4565
4634
|
}
|
|
4566
4635
|
async function projectsListRunner(ctx) {
|
|
4567
4636
|
const parsed = parsedArgsFromContext("projects list", ctx);
|
|
4568
|
-
return await runProjectsList(parsed, outputMode(parsed.options));
|
|
4637
|
+
return await runWithSkillAutoUpdate(parsed, () => runProjectsList(parsed, outputMode(parsed.options)));
|
|
4569
4638
|
}
|
|
4570
4639
|
async function projectsCreateRunner(ctx) {
|
|
4571
4640
|
const parsed = parsedArgsFromContext("projects create", ctx);
|
|
4572
|
-
return await runProjectsCreate(parsed, outputMode(parsed.options));
|
|
4641
|
+
return await runWithSkillAutoUpdate(parsed, () => runProjectsCreate(parsed, outputMode(parsed.options)));
|
|
4573
4642
|
}
|
|
4574
4643
|
async function projectsEditRunner(ctx) {
|
|
4575
4644
|
const parsed = parsedArgsFromContext("projects edit", ctx);
|
|
4576
|
-
return await runProjectsEdit(parsed, outputMode(parsed.options));
|
|
4645
|
+
return await runWithSkillAutoUpdate(parsed, () => runProjectsEdit(parsed, outputMode(parsed.options)));
|
|
4577
4646
|
}
|
|
4578
4647
|
async function initRunner(ctx) {
|
|
4579
4648
|
const parsed = parsedArgsFromContext("init", ctx);
|
|
@@ -4603,6 +4672,54 @@ async function doctorRunner(ctx) {
|
|
|
4603
4672
|
const parsed = parsedArgsFromContext("doctor", ctx);
|
|
4604
4673
|
return await runDoctor(parsed, outputMode(parsed.options));
|
|
4605
4674
|
}
|
|
4675
|
+
async function runWithSkillAutoUpdate(parsed, runner) {
|
|
4676
|
+
const mode = outputMode(parsed.options);
|
|
4677
|
+
if (!mode.json) {
|
|
4678
|
+
const originalExitCode = process.exitCode;
|
|
4679
|
+
await runner();
|
|
4680
|
+
if (process.exitCode !== originalExitCode && process.exitCode !== 0) return;
|
|
4681
|
+
const autoUpdate = await autoUpdateUserManagedSkills();
|
|
4682
|
+
if (autoUpdate && autoUpdate.targets.length > 0) process.stdout.write(skillAutoUpdateHumanOutput({ skills: { auto_update: autoUpdate } }));
|
|
4683
|
+
return;
|
|
4684
|
+
}
|
|
4685
|
+
const originalWrite = process.stdout.write.bind(process.stdout);
|
|
4686
|
+
const originalExitCode = process.exitCode;
|
|
4687
|
+
let buffered = "";
|
|
4688
|
+
process.stdout.write = ((chunk, encoding, cb) => {
|
|
4689
|
+
buffered += Buffer.isBuffer(chunk) ? chunk.toString(typeof encoding === "string" ? encoding : void 0) : String(chunk);
|
|
4690
|
+
if (typeof encoding === "function") encoding();
|
|
4691
|
+
if (typeof cb === "function") cb();
|
|
4692
|
+
return true;
|
|
4693
|
+
});
|
|
4694
|
+
try {
|
|
4695
|
+
await runner();
|
|
4696
|
+
} catch (error) {
|
|
4697
|
+
process.stdout.write = originalWrite;
|
|
4698
|
+
originalWrite(buffered);
|
|
4699
|
+
throw error;
|
|
4700
|
+
}
|
|
4701
|
+
process.stdout.write = originalWrite;
|
|
4702
|
+
if (process.exitCode !== originalExitCode && process.exitCode !== 0) {
|
|
4703
|
+
originalWrite(buffered);
|
|
4704
|
+
return;
|
|
4705
|
+
}
|
|
4706
|
+
const autoUpdate = await autoUpdateUserManagedSkills();
|
|
4707
|
+
if (!autoUpdate || autoUpdate.targets.length === 0) {
|
|
4708
|
+
originalWrite(buffered);
|
|
4709
|
+
return;
|
|
4710
|
+
}
|
|
4711
|
+
if (mode.json) try {
|
|
4712
|
+
const payload = JSON.parse(buffered);
|
|
4713
|
+
payload.data = dataWithSkillAutoUpdate(payload.data, autoUpdate);
|
|
4714
|
+
originalWrite(`${JSON.stringify(payload, null, 2)}\n`);
|
|
4715
|
+
return;
|
|
4716
|
+
} catch {
|
|
4717
|
+
originalWrite(buffered);
|
|
4718
|
+
return;
|
|
4719
|
+
}
|
|
4720
|
+
originalWrite(buffered);
|
|
4721
|
+
originalWrite(skillAutoUpdateHumanOutput({ skills: { auto_update: autoUpdate } }));
|
|
4722
|
+
}
|
|
4606
4723
|
function parentCommandRunner(command) {
|
|
4607
4724
|
return (ctx) => {
|
|
4608
4725
|
const parsed = parsedArgsFromContext(command, ctx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artifactshare/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Upload and share HTML, Markdown, folders, and static sites from terminals, AI agents, automation, and CI.",
|
|
5
5
|
"homepage": "https://artifactshare.com/connect",
|
|
6
6
|
"license": "Apache-2.0",
|