@artifactshare/cli 0.5.1 → 0.6.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/README.md CHANGED
@@ -42,25 +42,25 @@ runs add versions to the same file.
42
42
 
43
43
  ## Commands
44
44
 
45
- | Command | What it does |
46
- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
47
- | `open <target>` | First command for agents opening a shared URL; ensures skills, then reads or suggests download |
48
- | `share <path>` | Share a file or folder as a new shared file (`--project`, `--home`, `--visibility`, `--key`) |
49
- | `update <target> <path>` | Add a new version to an existing file (ID or share URL) |
50
- | `edit <target>` | Change title, sharing, explicit viewers, or project placement |
51
- | `delete <target>` | Permanently delete a file you shared |
52
- | `resolve <value>` | Find files by URL, ID, title, or project name |
53
- | `artifacts get <target>` | Read a file's content and metadata back |
54
- | `download <target>` | Save a file or a whole static site locally |
55
- | `comments list / post / edit / resolve / reopen / delete <target>` | Read, write, edit, resolve, reopen, and permanently delete comments |
56
- | `projects list / create / edit` | List, create, and edit project destinations and audience |
57
- | `move <target>` | Move an existing file into a project or back home; `edit` is preferred for new automation |
58
- | `request-access` | Join the waitlist when sharing is not enabled yet |
59
- | `login` / `logout` / `whoami` | Sign in, remove a saved local credential, and check who you are |
60
- | `doctor` | Diagnose auth, destination, network, and upload readiness — tells you the next command to run |
61
- | `profiles list / use / import-token / delete` | Switch between local account profiles, import an issued token from stdin, and delete profile entries |
62
- | `init` | Set up this directory: detect the agent and install the skill, then show next steps; or save defaults with `--profile` / `--project-id` |
63
- | `skills ensure / install / list / update / remove` | Install or update the bundled usage guide in your AI agent's skills |
45
+ | Command | What it does |
46
+ | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
47
+ | `open <target>` | First command for agents opening a shared URL; ensures skills, then reads or suggests download |
48
+ | `share <path>` | Share a file or folder as a new shared file (`--project`, `--home`, `--visibility`, `--key`) |
49
+ | `update <target> <path>` | Add a new version to an existing file (ID or share URL) |
50
+ | `edit <target>` | Change title, sharing, explicit viewers, or project placement |
51
+ | `delete <target>` | Permanently delete a file you shared |
52
+ | `resolve <value>` | Find files by URL, ID, title, or project name |
53
+ | `artifacts get <target>` | Read a file's content and metadata back |
54
+ | `download <target>` | Save a file or a whole static site locally |
55
+ | `comments list / post / edit / resolve / reopen / delete <target>` | Read, write, edit, resolve, reopen, and permanently delete comments |
56
+ | `projects list / create / edit` | List, create, and edit project destinations and audience |
57
+ | `move <target>` | Move an existing file into a project or back home; `edit` is preferred for new automation |
58
+ | `request-access` | Join the waitlist when sharing is not enabled yet |
59
+ | `login` / `logout` / `whoami` | Sign in, remove a saved local credential, and check who you are |
60
+ | `doctor` | Diagnose auth, destination, network, and upload readiness — tells you the next command to run |
61
+ | `profiles list / use / import-token / delete` | Switch between local account profiles, import an issued token from stdin, and delete profile entries |
62
+ | `init` | Set up this directory: detect Claude Code, Codex, or Cursor and install the skill in user scope, then show next steps; or save defaults with `--profile` / `--project-id` |
63
+ | `skills ensure / install / list / update / remove` | Install or update the bundled usage guide in your AI agent's skills |
64
64
 
65
65
  ## For AI agents
66
66
 
@@ -70,7 +70,7 @@ For first-time setup in a project, start here:
70
70
  npx --yes @artifactshare/cli init --json
71
71
  ```
72
72
 
73
- `init` detects the agent (Claude Code, Codex, Cursor) in the working directory, installs or updates the bundled skill, and reports the next steps (sign in, then share). With no agent detected, it installs the Codex and Claude Code project skills. Add `--dry-run` to preview without writing.
73
+ `init` detects Claude Code, Codex, or Cursor in the working directory, installs or updates the bundled skill in user scope, and reports the next steps (sign in, then share). With no agent detected, it installs user-scope Codex, Claude Code, and Cursor skills. Cursor project scope is not auto-installed; use `skills install --tool cursor --scope project`. Existing project-scope skills are not modified. Add `--dry-run` to preview without writing.
74
74
 
75
75
  When an agent receives an Artifact Share URL instead, start with `open`:
76
76
 
@@ -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> [--scope project|user]`; project scope is opt-in for team commits. `skills ensure --tool auto` is the same user-scope detection `init` and `open` use (omit `--scope` or pass `--scope user`; `--scope project` fails). Regular successful commands also update outdated managed user-scope Codex, Claude Code, and Cursor skills when they are already installed, but do not create a missing Cursor user-scope skill.
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
- return [
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
- return `${JSON.stringify(data, null, 2)}\n`;
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)}`;
@@ -2510,29 +2538,39 @@ const SKILL_TOOLS = [
2510
2538
  const SKILL_FILE_PATH = join("skills", "artifactshare", "SKILL.md");
2511
2539
  const TOOL_CONFIG = {
2512
2540
  codex: {
2513
- relativePath: join(".agents", SKILL_FILE_PATH),
2514
2541
  scopes: ["project", "user"],
2515
- detectDirs: [".codex", ".agents"],
2516
- bundledFile: "SKILL.md",
2517
- pruneDirs: ["artifactshare", "skills"]
2542
+ detectDirs: [".codex", ".agents"]
2518
2543
  },
2519
2544
  claude: {
2520
- relativePath: join(".claude", SKILL_FILE_PATH),
2521
2545
  scopes: ["project", "user"],
2522
- detectDirs: [".claude"],
2523
- bundledFile: "SKILL.md",
2524
- pruneDirs: ["artifactshare", "skills"]
2546
+ detectDirs: [".claude"]
2525
2547
  },
2526
2548
  cursor: {
2527
- relativePath: join(".cursor", "rules", "artifactshare.mdc"),
2528
- scopes: ["project"],
2529
- detectDirs: [".cursor"],
2530
- bundledFile: "artifactshare.mdc",
2531
- pruneDirs: []
2549
+ scopes: ["project", "user"],
2550
+ detectDirs: [".cursor"]
2532
2551
  }
2533
2552
  };
2553
+ function scopeTargetConfig(tool, scope) {
2554
+ if (tool === "cursor") {
2555
+ if (scope === "project") return {
2556
+ relativePath: join(".cursor", "rules", "artifactshare.mdc"),
2557
+ bundledFile: "artifactshare.mdc",
2558
+ pruneDirs: []
2559
+ };
2560
+ return {
2561
+ relativePath: join(".cursor", "skills", "artifactshare", "SKILL.md"),
2562
+ bundledFile: "SKILL.md",
2563
+ pruneDirs: ["artifactshare", "skills"]
2564
+ };
2565
+ }
2566
+ return {
2567
+ relativePath: join(tool === "codex" ? ".agents" : ".claude", SKILL_FILE_PATH),
2568
+ bundledFile: "SKILL.md",
2569
+ pruneDirs: ["artifactshare", "skills"]
2570
+ };
2571
+ }
2534
2572
  function skillTarget(tool, scope) {
2535
- const relative = TOOL_CONFIG[tool].relativePath;
2573
+ const relative = scopeTargetConfig(tool, scope).relativePath;
2536
2574
  const path = scope === "project" ? relative : join(homedir(), relative);
2537
2575
  return {
2538
2576
  tool,
@@ -2541,6 +2579,10 @@ function skillTarget(tool, scope) {
2541
2579
  absolutePath: resolve(path)
2542
2580
  };
2543
2581
  }
2582
+ function bundledContentForTarget(bundled, target) {
2583
+ const file = scopeTargetConfig(target.tool, target.scope).bundledFile;
2584
+ return bundled.contentsByFile[file];
2585
+ }
2544
2586
  function allTargets() {
2545
2587
  return SKILL_TOOLS.flatMap((tool) => TOOL_CONFIG[tool].scopes.map((scope) => skillTarget(tool, scope)));
2546
2588
  }
@@ -2560,23 +2602,17 @@ async function readTarget(target) {
2560
2602
  return managedState(await readFile(target.absolutePath, "utf8").catch(() => null));
2561
2603
  }
2562
2604
  async function loadBundledSkills() {
2563
- const byFile = /* @__PURE__ */ new Map();
2564
- const contents = {};
2605
+ const contentsByFile = {};
2565
2606
  let version;
2566
- for (const tool of SKILL_TOOLS) {
2567
- const file = TOOL_CONFIG[tool].bundledFile;
2568
- let content = byFile.get(file);
2569
- if (content === void 0) {
2570
- content = await readFile(new URL(`../skills/artifactshare/${file}`, import.meta.url), "utf8");
2571
- const state = managedState(content);
2572
- if (state.kind !== "managed" || (version ?? state.version) !== state.version) throw new Error(`The bundled ${file} has a missing or mismatched managed marker.`);
2573
- version = state.version;
2574
- byFile.set(file, content);
2575
- }
2576
- contents[tool] = content;
2607
+ for (const file of ["SKILL.md", "artifactshare.mdc"]) {
2608
+ const content = await readFile(new URL(`../skills/artifactshare/${file}`, import.meta.url), "utf8");
2609
+ const state = managedState(content);
2610
+ if (state.kind !== "managed" || (version ?? state.version) !== state.version) throw new Error(`The bundled ${file} has a missing or mismatched managed marker.`);
2611
+ version = state.version;
2612
+ contentsByFile[file] = content;
2577
2613
  }
2578
2614
  return {
2579
- contents,
2615
+ contentsByFile,
2580
2616
  version
2581
2617
  };
2582
2618
  }
@@ -2614,7 +2650,7 @@ function parseFilters(parsed, options = {}) {
2614
2650
  if (tools.error) return { error: tools.error };
2615
2651
  const scope = parseScope(parsed.options.scope);
2616
2652
  if (scope.error) return { error: scope.error };
2617
- if (tools.auto && scope.scope === "user") return { error: validationError("--tool auto supports project scope only.", "Use --tool auto --scope project, or pass an explicit --tool for user scope.") };
2653
+ if (tools.auto && scope.scope === "project") return { error: validationError("--tool auto does not support project scope.", "Use --tool auto --scope user, or pass an explicit --tool for project scope.") };
2618
2654
  const unsupported = scope.scope === void 0 ? void 0 : tools.tools.find((tool) => !TOOL_CONFIG[tool].scopes.includes(scope.scope));
2619
2655
  if (unsupported) return { error: validationError(`The ${unsupported} tool does not support --scope ${scope.scope}.`, `Use --tool ${unsupported} --scope project.`) };
2620
2656
  return {
@@ -2634,16 +2670,23 @@ async function isToolDetected(tool, scope) {
2634
2670
  for (const dir of TOOL_CONFIG[tool].detectDirs) if ((await stat(join(base, dir)).catch(() => null))?.isDirectory()) return true;
2635
2671
  return false;
2636
2672
  }
2637
- async function autoTargets(scope) {
2638
- const targetScope = scope ?? "project";
2673
+ async function autoDetectedTools() {
2639
2674
  const autoOrder = [
2640
2675
  "claude",
2641
2676
  "codex",
2642
2677
  "cursor"
2643
2678
  ];
2644
- const detected = /* @__PURE__ */ new Set();
2645
- for (const tool of autoOrder) if (TOOL_CONFIG[tool].scopes.includes(targetScope) && await isToolDetected(tool, targetScope)) detected.add(tool);
2646
- return (detected.size > 0 ? [...detected] : ["codex", "claude"]).filter((tool) => TOOL_CONFIG[tool].scopes.includes(targetScope)).map((tool) => skillTarget(tool, targetScope));
2679
+ const detected = [];
2680
+ for (const tool of autoOrder) if (await isToolDetected(tool, "project")) detected.push(tool);
2681
+ return detected.length > 0 ? detected : [
2682
+ "codex",
2683
+ "claude",
2684
+ "cursor"
2685
+ ];
2686
+ }
2687
+ async function autoTargets(scope) {
2688
+ const targetScope = scope ?? "user";
2689
+ return (await autoDetectedTools()).filter((tool) => TOOL_CONFIG[tool].scopes.includes(targetScope)).map((tool) => skillTarget(tool, targetScope));
2647
2690
  }
2648
2691
  function targetPathKey(target) {
2649
2692
  return realpath(target.absolutePath).catch(() => target.absolutePath);
@@ -2661,7 +2704,7 @@ async function applyAction({ target, action, content }) {
2661
2704
  }
2662
2705
  async function cleanupSkillDirs(target) {
2663
2706
  let dir = dirname(target.absolutePath);
2664
- for (const expected of TOOL_CONFIG[target.tool].pruneDirs) {
2707
+ for (const expected of scopeTargetConfig(target.tool, target.scope).pruneDirs) {
2665
2708
  if (basename(dir) !== expected) return;
2666
2709
  try {
2667
2710
  await rmdir(dir);
@@ -2738,7 +2781,7 @@ async function runSkillsInstall(parsed, mode) {
2738
2781
  planned.push({
2739
2782
  target,
2740
2783
  action: state.kind === "missing" ? "installed" : "updated",
2741
- content: bundled.contents[tool]
2784
+ content: bundledContentForTarget(bundled, target)
2742
2785
  });
2743
2786
  }
2744
2787
  await runActions(command, planned, parsed.options.dryRun === true, mode);
@@ -2761,21 +2804,18 @@ async function ensureSkills(parsed, mode, options = {}) {
2761
2804
  for (const target of targets) {
2762
2805
  const state = await readTarget(target);
2763
2806
  if (state.kind === "unmanaged" || state.kind === "broken") {
2807
+ if (options.skipBrokenUserSkills && state.kind === "broken") continue;
2764
2808
  writeFailure(command, skillUpdateConflictError(target.path), mode, 1);
2765
2809
  return;
2766
2810
  }
2767
2811
  const unchanged = state.kind === "managed" && state.version === bundled.version;
2768
- const recommendUpdate = options.recommendProjectUpdates && target.scope === "project" && state.kind === "managed" && state.version !== bundled.version;
2769
2812
  planned.push(unchanged ? {
2770
2813
  target,
2771
2814
  action: "unchanged"
2772
- } : recommendUpdate ? {
2773
- target,
2774
- action: "update_recommended"
2775
2815
  } : {
2776
2816
  target,
2777
2817
  action: state.kind === "missing" ? "installed" : "updated",
2778
- content: bundled.contents[target.tool]
2818
+ content: bundledContentForTarget(bundled, target)
2779
2819
  });
2780
2820
  }
2781
2821
  if (options.autoUpdateUserManaged) {
@@ -2787,13 +2827,53 @@ async function ensureSkills(parsed, mode, options = {}) {
2787
2827
  planned.push({
2788
2828
  target,
2789
2829
  action: "updated",
2790
- content: bundled.contents[target.tool],
2830
+ content: bundledContentForTarget(bundled, target),
2791
2831
  fallbackAction: "update_recommended"
2792
2832
  });
2793
2833
  }
2794
2834
  }
2795
2835
  return finishActions(command, planned, parsed.options.dryRun === true, mode);
2796
2836
  }
2837
+ async function autoUpdateUserManagedSkills() {
2838
+ try {
2839
+ const bundled = await loadBundledSkills();
2840
+ const planned = [];
2841
+ for (const target of allTargets().filter((candidate) => candidate.scope === "user")) {
2842
+ const state = await readTarget(target);
2843
+ if (state.kind !== "managed" || state.version >= bundled.version) continue;
2844
+ planned.push({
2845
+ target,
2846
+ action: "updated",
2847
+ content: bundledContentForTarget(bundled, target),
2848
+ fallbackAction: "update_recommended",
2849
+ installedVersion: state.version
2850
+ });
2851
+ }
2852
+ if (planned.length === 0) return void 0;
2853
+ const completed = [...planned];
2854
+ for (const [index, item] of planned.entries()) try {
2855
+ await applyAction(item);
2856
+ completed[index] = item;
2857
+ } catch {
2858
+ completed[index] = {
2859
+ target: item.target,
2860
+ action: "update_recommended",
2861
+ ...item.installedVersion !== void 0 ? { installedVersion: item.installedVersion } : {}
2862
+ };
2863
+ }
2864
+ return { targets: completed.map(({ target, action, installedVersion }) => ({
2865
+ tool: target.tool,
2866
+ scope: "user",
2867
+ path: target.path,
2868
+ action: action === "updated" ? "updated" : "update_recommended",
2869
+ installed_version: installedVersion ?? bundled.version,
2870
+ bundled_version: bundled.version,
2871
+ ...action === "update_recommended" ? { update_command: skillUpdateCommand(target) } : {}
2872
+ })) };
2873
+ } catch {
2874
+ return;
2875
+ }
2876
+ }
2797
2877
  async function runSkillsEnsure(parsed, mode) {
2798
2878
  const data = await ensureSkills(parsed, mode);
2799
2879
  if (data) writeSuccess("skills ensure", data, mode);
@@ -2867,7 +2947,7 @@ async function runSkillsUpdate(parsed, mode) {
2867
2947
  else if (state.version !== bundled.version || force) planned.push({
2868
2948
  target,
2869
2949
  action: "updated",
2870
- content: bundled.contents[target.tool]
2950
+ content: bundledContentForTarget(bundled, target)
2871
2951
  });
2872
2952
  else planned.push({
2873
2953
  target,
@@ -2899,13 +2979,12 @@ async function runOpen(parsed, mode, isRetry = false) {
2899
2979
  ...parsed,
2900
2980
  options: {
2901
2981
  ...parsed.options,
2902
- tool: "auto",
2903
- scope: "project"
2982
+ tool: "auto"
2904
2983
  }
2905
2984
  }, mode, {
2906
2985
  command,
2907
2986
  autoUpdateUserManaged: true,
2908
- recommendProjectUpdates: true
2987
+ skipBrokenUserSkills: true
2909
2988
  });
2910
2989
  if (!skills) return;
2911
2990
  const target = parseArtifactTarget(parsed.positionals[0], command, "Pass an artifact ID or share URL to read.");
@@ -3757,13 +3836,12 @@ async function runInitOnboarding(parsed, mode) {
3757
3836
  ...parsed,
3758
3837
  options: {
3759
3838
  ...parsed.options,
3760
- tool: "auto",
3761
- scope: "project"
3839
+ tool: "auto"
3762
3840
  }
3763
3841
  }, mode, {
3764
3842
  command,
3765
3843
  autoUpdateUserManaged: true,
3766
- recommendProjectUpdates: true
3844
+ skipBrokenUserSkills: true
3767
3845
  });
3768
3846
  if (!skills) return;
3769
3847
  const project = await resolveProjectConfig();
@@ -4468,35 +4546,36 @@ async function runWhoami(parsed, mode) {
4468
4546
  //#region src/commands.ts
4469
4547
  async function shareRunner(ctx) {
4470
4548
  const parsed = parsedArgsFromContext("share", ctx);
4471
- return await runShare(parsed, outputMode(parsed.options));
4549
+ return await runWithSkillAutoUpdate(parsed, () => runShare(parsed, outputMode(parsed.options)));
4472
4550
  }
4473
4551
  async function loginRunner(ctx) {
4474
4552
  const parsed = parsedArgsFromContext("login", ctx);
4475
- return await runLogin(parsed, outputMode(parsed.options));
4553
+ const mode = outputMode(parsed.options);
4554
+ return await runWithSkillAutoUpdate(parsed, () => runLogin(parsed, mode));
4476
4555
  }
4477
4556
  async function logoutRunner(ctx) {
4478
4557
  const parsed = parsedArgsFromContext("logout", ctx);
4479
- return await runLogout(parsed, outputMode(parsed.options));
4558
+ return await runWithSkillAutoUpdate(parsed, () => runLogout(parsed, outputMode(parsed.options)));
4480
4559
  }
4481
4560
  async function updateRunner(ctx) {
4482
4561
  const parsed = parsedArgsFromContext("update", ctx);
4483
- return await runUpdate(parsed, outputMode(parsed.options));
4562
+ return await runWithSkillAutoUpdate(parsed, () => runUpdate(parsed, outputMode(parsed.options)));
4484
4563
  }
4485
4564
  async function editRunner(ctx) {
4486
4565
  const parsed = parsedArgsFromContext("edit", ctx);
4487
- return await runEdit(parsed, outputMode(parsed.options));
4566
+ return await runWithSkillAutoUpdate(parsed, () => runEdit(parsed, outputMode(parsed.options)));
4488
4567
  }
4489
4568
  async function deleteRunner(ctx) {
4490
4569
  const parsed = parsedArgsFromContext("delete", ctx);
4491
- return await runDelete(parsed, outputMode(parsed.options));
4570
+ return await runWithSkillAutoUpdate(parsed, () => runDelete(parsed, outputMode(parsed.options)));
4492
4571
  }
4493
4572
  async function resolveRunner(ctx) {
4494
4573
  const parsed = parsedArgsFromContext("resolve", ctx);
4495
- return await runResolve(parsed, outputMode(parsed.options));
4574
+ return await runWithSkillAutoUpdate(parsed, () => runResolve(parsed, outputMode(parsed.options)));
4496
4575
  }
4497
4576
  async function downloadRunner(ctx) {
4498
4577
  const parsed = parsedArgsFromContext("download", ctx);
4499
- return await runDownload(parsed, outputMode(parsed.options));
4578
+ return await runWithSkillAutoUpdate(parsed, () => runDownload(parsed, outputMode(parsed.options)));
4500
4579
  }
4501
4580
  async function openRunner(ctx) {
4502
4581
  const parsed = parsedArgsFromContext("open", ctx);
@@ -4504,76 +4583,76 @@ async function openRunner(ctx) {
4504
4583
  }
4505
4584
  async function moveRunner(ctx) {
4506
4585
  const parsed = parsedArgsFromContext("move", ctx);
4507
- return await runMove(parsed, outputMode(parsed.options));
4586
+ return await runWithSkillAutoUpdate(parsed, () => runMove(parsed, outputMode(parsed.options)));
4508
4587
  }
4509
4588
  async function artifactsGetRunner(ctx) {
4510
4589
  const parsed = parsedArgsFromContext("artifacts get", ctx);
4511
- return await runArtifactsGet(parsed, outputMode(parsed.options));
4590
+ return await runWithSkillAutoUpdate(parsed, () => runArtifactsGet(parsed, outputMode(parsed.options)));
4512
4591
  }
4513
4592
  async function artifactsListRunner(ctx) {
4514
4593
  const parsed = parsedArgsFromContext("artifacts list", ctx);
4515
- return await runArtifactsList(parsed, outputMode(parsed.options));
4594
+ return await runWithSkillAutoUpdate(parsed, () => runArtifactsList(parsed, outputMode(parsed.options)));
4516
4595
  }
4517
4596
  async function commentsListRunner(ctx) {
4518
4597
  const parsed = parsedArgsFromContext("comments list", ctx);
4519
- return await runCommentsList(parsed, outputMode(parsed.options));
4598
+ return await runWithSkillAutoUpdate(parsed, () => runCommentsList(parsed, outputMode(parsed.options)));
4520
4599
  }
4521
4600
  async function commentsPostRunner(ctx) {
4522
4601
  const parsed = parsedArgsFromContext("comments post", ctx);
4523
- return await runCommentsPost(parsed, outputMode(parsed.options));
4602
+ return await runWithSkillAutoUpdate(parsed, () => runCommentsPost(parsed, outputMode(parsed.options)));
4524
4603
  }
4525
4604
  async function commentsEditRunner(ctx) {
4526
4605
  const parsed = parsedArgsFromContext("comments edit", ctx);
4527
- return await runCommentsEdit(parsed, outputMode(parsed.options));
4606
+ return await runWithSkillAutoUpdate(parsed, () => runCommentsEdit(parsed, outputMode(parsed.options)));
4528
4607
  }
4529
4608
  async function commentsResolveRunner(ctx) {
4530
4609
  const parsed = parsedArgsFromContext("comments resolve", ctx);
4531
- return await runCommentsResolve(parsed, outputMode(parsed.options));
4610
+ return await runWithSkillAutoUpdate(parsed, () => runCommentsResolve(parsed, outputMode(parsed.options)));
4532
4611
  }
4533
4612
  async function commentsReopenRunner(ctx) {
4534
4613
  const parsed = parsedArgsFromContext("comments reopen", ctx);
4535
- return await runCommentsReopen(parsed, outputMode(parsed.options));
4614
+ return await runWithSkillAutoUpdate(parsed, () => runCommentsReopen(parsed, outputMode(parsed.options)));
4536
4615
  }
4537
4616
  async function commentsDeleteRunner(ctx) {
4538
4617
  const parsed = parsedArgsFromContext("comments delete", ctx);
4539
- return await runCommentsDelete(parsed, outputMode(parsed.options));
4618
+ return await runWithSkillAutoUpdate(parsed, () => runCommentsDelete(parsed, outputMode(parsed.options)));
4540
4619
  }
4541
4620
  async function requestAccessRunner(ctx) {
4542
4621
  const parsed = parsedArgsFromContext("request-access", ctx);
4543
- return await runRequestAccess(parsed, outputMode(parsed.options));
4622
+ return await runWithSkillAutoUpdate(parsed, () => runRequestAccess(parsed, outputMode(parsed.options)));
4544
4623
  }
4545
4624
  async function whoamiRunner(ctx) {
4546
4625
  const parsed = parsedArgsFromContext("whoami", ctx);
4547
- return await runWhoami(parsed, outputMode(parsed.options));
4626
+ return await runWithSkillAutoUpdate(parsed, () => runWhoami(parsed, outputMode(parsed.options)));
4548
4627
  }
4549
4628
  async function profilesListRunner(ctx) {
4550
4629
  const parsed = parsedArgsFromContext("profiles list", ctx);
4551
- return await runProfilesList(parsed, outputMode(parsed.options));
4630
+ return await runWithSkillAutoUpdate(parsed, () => runProfilesList(parsed, outputMode(parsed.options)));
4552
4631
  }
4553
4632
  async function profilesUseRunner(ctx) {
4554
4633
  const parsed = parsedArgsFromContext("profiles use", ctx);
4555
- return await runProfilesUse(parsed, outputMode(parsed.options));
4634
+ return await runWithSkillAutoUpdate(parsed, () => runProfilesUse(parsed, outputMode(parsed.options)));
4556
4635
  }
4557
4636
  async function profilesImportTokenRunner(ctx) {
4558
4637
  const parsed = parsedArgsFromContext("profiles import-token", ctx);
4559
4638
  if (hasOptionToken(ctx, "token")) parsed.options.token = "<redacted>";
4560
- return await runProfilesImportToken(parsed, outputMode(parsed.options));
4639
+ return await runWithSkillAutoUpdate(parsed, () => runProfilesImportToken(parsed, outputMode(parsed.options)));
4561
4640
  }
4562
4641
  async function profilesDeleteRunner(ctx) {
4563
4642
  const parsed = parsedArgsFromContext("profiles delete", ctx);
4564
- return await runProfilesDelete(parsed, outputMode(parsed.options));
4643
+ return await runWithSkillAutoUpdate(parsed, () => runProfilesDelete(parsed, outputMode(parsed.options)));
4565
4644
  }
4566
4645
  async function projectsListRunner(ctx) {
4567
4646
  const parsed = parsedArgsFromContext("projects list", ctx);
4568
- return await runProjectsList(parsed, outputMode(parsed.options));
4647
+ return await runWithSkillAutoUpdate(parsed, () => runProjectsList(parsed, outputMode(parsed.options)));
4569
4648
  }
4570
4649
  async function projectsCreateRunner(ctx) {
4571
4650
  const parsed = parsedArgsFromContext("projects create", ctx);
4572
- return await runProjectsCreate(parsed, outputMode(parsed.options));
4651
+ return await runWithSkillAutoUpdate(parsed, () => runProjectsCreate(parsed, outputMode(parsed.options)));
4573
4652
  }
4574
4653
  async function projectsEditRunner(ctx) {
4575
4654
  const parsed = parsedArgsFromContext("projects edit", ctx);
4576
- return await runProjectsEdit(parsed, outputMode(parsed.options));
4655
+ return await runWithSkillAutoUpdate(parsed, () => runProjectsEdit(parsed, outputMode(parsed.options)));
4577
4656
  }
4578
4657
  async function initRunner(ctx) {
4579
4658
  const parsed = parsedArgsFromContext("init", ctx);
@@ -4603,6 +4682,54 @@ async function doctorRunner(ctx) {
4603
4682
  const parsed = parsedArgsFromContext("doctor", ctx);
4604
4683
  return await runDoctor(parsed, outputMode(parsed.options));
4605
4684
  }
4685
+ async function runWithSkillAutoUpdate(parsed, runner) {
4686
+ const mode = outputMode(parsed.options);
4687
+ if (!mode.json) {
4688
+ const originalExitCode = process.exitCode;
4689
+ await runner();
4690
+ if (process.exitCode !== originalExitCode && process.exitCode !== 0) return;
4691
+ const autoUpdate = await autoUpdateUserManagedSkills();
4692
+ if (autoUpdate && autoUpdate.targets.length > 0) process.stdout.write(skillAutoUpdateHumanOutput({ skills: { auto_update: autoUpdate } }));
4693
+ return;
4694
+ }
4695
+ const originalWrite = process.stdout.write.bind(process.stdout);
4696
+ const originalExitCode = process.exitCode;
4697
+ let buffered = "";
4698
+ process.stdout.write = ((chunk, encoding, cb) => {
4699
+ buffered += Buffer.isBuffer(chunk) ? chunk.toString(typeof encoding === "string" ? encoding : void 0) : String(chunk);
4700
+ if (typeof encoding === "function") encoding();
4701
+ if (typeof cb === "function") cb();
4702
+ return true;
4703
+ });
4704
+ try {
4705
+ await runner();
4706
+ } catch (error) {
4707
+ process.stdout.write = originalWrite;
4708
+ originalWrite(buffered);
4709
+ throw error;
4710
+ }
4711
+ process.stdout.write = originalWrite;
4712
+ if (process.exitCode !== originalExitCode && process.exitCode !== 0) {
4713
+ originalWrite(buffered);
4714
+ return;
4715
+ }
4716
+ const autoUpdate = await autoUpdateUserManagedSkills();
4717
+ if (!autoUpdate || autoUpdate.targets.length === 0) {
4718
+ originalWrite(buffered);
4719
+ return;
4720
+ }
4721
+ if (mode.json) try {
4722
+ const payload = JSON.parse(buffered);
4723
+ payload.data = dataWithSkillAutoUpdate(payload.data, autoUpdate);
4724
+ originalWrite(`${JSON.stringify(payload, null, 2)}\n`);
4725
+ return;
4726
+ } catch {
4727
+ originalWrite(buffered);
4728
+ return;
4729
+ }
4730
+ originalWrite(buffered);
4731
+ originalWrite(skillAutoUpdateHumanOutput({ skills: { auto_update: autoUpdate } }));
4732
+ }
4606
4733
  function parentCommandRunner(command) {
4607
4734
  return (ctx) => {
4608
4735
  const parsed = parsedArgsFromContext(command, ctx);
@@ -5028,8 +5155,12 @@ const openDefinition = define({
5028
5155
  npx --yes @artifactshare/cli open abc123def4 --json
5029
5156
 
5030
5157
  Use this as the first command when an agent receives an Artifact Share URL.
5031
- It installs or updates the local Artifact Share skill, then reads single-file artifacts.
5032
- For static sites or multi-file artifacts, the JSON includes a download next_command.
5158
+ It installs or updates the bundled Artifact Share skill in user scope (Claude Code,
5159
+ Codex, or Cursor detected from the working directory; all three if none are
5160
+ detected), then reads single-file artifacts. Cursor project scope is not
5161
+ auto-installed; use skills install --tool cursor --scope project. Existing
5162
+ project-scope skills are not modified. For static sites or multi-file artifacts,
5163
+ the JSON includes a download next_command.
5033
5164
 
5034
5165
  Common failures:
5035
5166
  auth_required Set ARTIFACTSHARE_TOKEN before open
@@ -5547,7 +5678,7 @@ const skillsToolArgs = {
5547
5678
  scope: {
5548
5679
  type: "string",
5549
5680
  toKebab: true,
5550
- description: "Install scope: project (default) or user"
5681
+ description: "Install scope: project or user (default: project for install; user for ensure --tool auto)"
5551
5682
  },
5552
5683
  dryRun: {
5553
5684
  type: "boolean",
@@ -5622,15 +5753,17 @@ const skillsEnsureDefinition = define({
5622
5753
  description: "Show planned file changes without writing"
5623
5754
  }
5624
5755
  },
5625
- examples: `npx --yes @artifactshare/cli skills ensure --tool auto --scope project --json
5756
+ examples: `npx --yes @artifactshare/cli skills ensure --tool auto --json
5757
+ npx --yes @artifactshare/cli skills ensure --tool auto --scope user --json
5626
5758
  npx --yes @artifactshare/cli skills ensure --tool claude --json
5627
5759
 
5628
- Use --tool auto from an agent workspace. It detects .claude, .agents/.codex,
5629
- and .cursor in the current directory; if none are present, it prepares Codex
5630
- and Claude Code project skills.
5760
+ Use --tool auto from an agent workspace. It detects .claude, .codex/.agents, or
5761
+ .cursor in the current directory and installs or updates the matching user-scope
5762
+ skills. If none are present, it prepares user-scope Codex, Claude Code, and Cursor
5763
+ skills. Cursor project scope needs skills install --tool cursor --scope project.
5631
5764
 
5632
5765
  Common failures:
5633
- validation_failed Pass --tool auto|codex|claude|cursor; auto supports --scope project only
5766
+ validation_failed Pass --tool auto|codex|claude|cursor; --tool auto supports --scope user only (omit --scope or pass --scope user). Project scope needs skills install --tool <tool> --scope project
5634
5767
  skill_update_conflict An unmanaged or broken skill file exists; inspect it before overwriting`
5635
5768
  });
5636
5769
  const skillsRemoveDefinition = define({
@@ -5684,8 +5817,12 @@ const initDefinition = define({
5684
5817
  npx --yes @artifactshare/cli init --dry-run --json
5685
5818
  npx --yes @artifactshare/cli init --profile client-a --project-id <id> --json
5686
5819
 
5687
- Without flags, init detects your agent (Claude Code, Codex, Cursor), installs the
5688
- bundled skill, and shows the next steps (sign in, then share). data.mode is "onboarding".
5820
+ Without flags, init detects Claude Code, Codex, or Cursor in the working directory,
5821
+ installs or updates the bundled skill in user scope, and shows the next steps (sign
5822
+ in, then share). With no agent detected, it prepares user-scope Codex, Claude Code,
5823
+ and Cursor skills. Cursor project scope is not auto-installed; use skills install
5824
+ --tool cursor --scope project. Existing project-scope skills are not modified.
5825
+ data.mode is "onboarding".
5689
5826
  With --profile or --project-id, init saves working-directory defaults to
5690
5827
  .artifactshare/config.local.json instead (data.mode is "config"); secrets are never written there.
5691
5828
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artifactshare/cli",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
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",
@@ -4,7 +4,7 @@ description: Share, publish, upload, host, update, open, or read back existing f
4
4
  ---
5
5
 
6
6
  <!-- artifactshare-skill
7
- version: 22
7
+ version: 24
8
8
  managed: true
9
9
  -->
10
10
 
@@ -232,11 +232,20 @@ npx --yes @artifactshare/cli skills update --json
232
232
  npx --yes @artifactshare/cli skills list --json
233
233
  ```
234
234
 
235
- - `skills ensure --tool auto` detects the agent (Claude Code, Codex, Cursor)
236
- and installs this skill if missing, or reports when an update is available.
237
- - `skills update` updates installed skills to the bundled version.
238
- - `skills install --tool <name> --scope user` installs the skill at the user
239
- level instead of the project. `--force` overwrites an unmanaged file.
235
+ - `open`, flag-less `init`, and `skills ensure --tool auto` detect Claude Code,
236
+ Codex, or Cursor in the working directory and install or update this skill in
237
+ user scope (`~/.claude/skills/`, `~/.agents/skills/`, or
238
+ `~/.cursor/skills/artifactshare/SKILL.md`). With no agent detected,
239
+ user-scope Codex, Claude Code, and Cursor skills are prepared.
240
+ - Cursor project scope is not auto-installed. Install the Cursor rule explicitly
241
+ with `skills install --tool cursor --scope project`.
242
+ - Use `skills install --tool cursor --scope user` to install or manage the
243
+ Cursor user-scope skill explicitly.
244
+ - `skills ensure --tool auto` accepts omitted `--scope` or `--scope user`;
245
+ `--scope project` fails with `validation_failed`. Project-scope skills are
246
+ opt-in via `skills install --tool <tool> --scope project`.
247
+ - `skills update` updates installed managed skills to the bundled version.
248
+ - `--force` overwrites an unmanaged file on install.
240
249
  - Run `skills --help` for all subcommands.
241
250
 
242
251
  ## Output contract
@@ -4,7 +4,7 @@ alwaysApply: false
4
4
  ---
5
5
 
6
6
  <!-- artifactshare-skill
7
- version: 22
7
+ version: 24
8
8
  managed: true
9
9
  -->
10
10
 
@@ -55,6 +55,6 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
55
55
  - Permanently remove an artifact only when the user explicitly asks with `delete <artifact-id-or-url> --json`.
56
56
  - Manage projects: `projects list --json`, `projects create <name> --json` (defaults to `--visibility workspace`; pass `--visibility private` for confidential projects), `projects edit <id>` for name, description, visibility, audience (`--add-email`/`--remove-email`), and archive state (`--archive`/`--unarchive`).
57
57
  - Save a default project with `init --project-id <id> --json`. Preview setup with `init --dry-run --json`.
58
- - Manage skills: `skills ensure --tool auto --json` detects the agent and installs or reports updates; `skills update --json` updates installed skills to the bundled version; `skills install --tool <name> --scope user --json` installs at the user level (`--force` overwrites unmanaged files).
58
+ - Manage skills: `skills ensure --tool auto --json` detects Claude Code, Codex, or Cursor and installs or updates user-scope skills; Cursor project scope needs `skills install --tool cursor --scope project --json`. Use `skills install --tool cursor --scope user --json` for the Cursor user-scope skill explicitly. Project scope is opt-in via `skills install --tool <tool> --scope project --json`. `skills update --json` updates installed managed skills; `--force` overwrites unmanaged files on install.
59
59
  - Check the current state with `whoami --json` or `doctor --json` for authentication, destination, network, upload access, and skill update status.
60
- - First-time setup: `npx --yes @artifactshare/cli init --json` detects the agent, installs or updates this rule, and reports the next steps (sign in, then share).
60
+ - First-time setup: `npx --yes @artifactshare/cli init --json` detects Claude Code, Codex, or Cursor, installs or updates user-scope skills, and reports the next steps (sign in, then share). For Cursor project scope, run `skills install --tool cursor --scope project --json` explicitly.