@artifactshare/cli 0.2.0 → 0.3.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
@@ -41,43 +41,45 @@ runs add versions to the same file.
41
41
 
42
42
  ## Commands
43
43
 
44
- | Command | What it does |
45
- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- |
46
- | `open <target>` | First command for agents opening a shared URL; ensures skills, then reads or suggests download |
47
- | `share <path>` | Share a file or folder as a new shared file (`--project`, `--home`, `--visibility`, `--key`) |
48
- | `update <target> <path>` | Add a new version to an existing file (ID or share URL) |
49
- | `edit <target>` | Change title, sharing, explicit viewers, or project placement |
50
- | `delete <target>` | Permanently delete a file you shared |
51
- | `resolve <value>` | Find files by URL, ID, title, or project name |
52
- | `artifacts get <target>` | Read a file's content and metadata back |
53
- | `download <target>` | Save a file or a whole static site locally |
54
- | `comments list / post / edit / resolve / reopen / delete <target>` | Read, write, edit, resolve, reopen, and permanently delete comments |
55
- | `projects list / create / edit` | List, create, and edit project destinations and audience |
56
- | `move <target>` | Move an existing file into a project or back home; `edit` is preferred for new automation |
57
- | `request-access` | Join the waitlist when sharing is not enabled yet |
58
- | `login` / `whoami` | Sign in and check who you are |
59
- | `doctor` | Diagnose auth, destination, network, and upload readiness — tells you the next command to run |
60
- | `profiles list / use / import-token` | Switch between local account profiles and import an issued token from stdin |
61
- | `init` | Save a default project for the current directory |
62
- | `skills ensure / install / list / update / remove` | Install or update the bundled usage guide in your AI agent's skills |
44
+ | Command | What it does |
45
+ | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
46
+ | `open <target>` | First command for agents opening a shared URL; ensures skills, then reads or suggests download |
47
+ | `share <path>` | Share a file or folder as a new shared file (`--project`, `--home`, `--visibility`, `--key`) |
48
+ | `update <target> <path>` | Add a new version to an existing file (ID or share URL) |
49
+ | `edit <target>` | Change title, sharing, explicit viewers, or project placement |
50
+ | `delete <target>` | Permanently delete a file you shared |
51
+ | `resolve <value>` | Find files by URL, ID, title, or project name |
52
+ | `artifacts get <target>` | Read a file's content and metadata back |
53
+ | `download <target>` | Save a file or a whole static site locally |
54
+ | `comments list / post / edit / resolve / reopen / delete <target>` | Read, write, edit, resolve, reopen, and permanently delete comments |
55
+ | `projects list / create / edit` | List, create, and edit project destinations and audience |
56
+ | `move <target>` | Move an existing file into a project or back home; `edit` is preferred for new automation |
57
+ | `request-access` | Join the waitlist when sharing is not enabled yet |
58
+ | `login` / `whoami` | Sign in and check who you are |
59
+ | `doctor` | Diagnose auth, destination, network, and upload readiness — tells you the next command to run |
60
+ | `profiles list / use / import-token` | Switch between local account profiles and import an issued token from stdin |
61
+ | `init` | Set up this directory: detect the agent and install the skill, then show next steps; or save defaults with `--profile` / `--project-id` |
62
+ | `skills ensure / install / list / update / remove` | Install or update the bundled usage guide in your AI agent's skills |
63
63
 
64
64
  ## For AI agents
65
65
 
66
- When an agent receives an Artifact Share URL, start here:
66
+ For first-time setup in a project, start here:
67
67
 
68
68
  ```sh
69
- npx --yes @artifactshare/cli open <artifact-id-or-url> --json
69
+ npx --yes @artifactshare/cli init --json
70
70
  ```
71
71
 
72
- This installs or updates the local skill first, then reads single-file artifacts. Static sites and multi-file artifacts return a `download` next command.
72
+ `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
73
 
74
- To prepare the local skills without opening a URL:
74
+ When an agent receives an Artifact Share URL instead, start with `open`:
75
75
 
76
76
  ```sh
77
- npx --yes @artifactshare/cli skills ensure --tool auto --scope project --json
77
+ npx --yes @artifactshare/cli open <artifact-id-or-url> --json
78
78
  ```
79
79
 
80
- `skills ensure --tool auto` detects Claude Code, Codex, and Cursor project markers. Use `skills install --tool <codex|claude|cursor>` only when you want to target a specific tool manually.
80
+ This installs or updates the local skill first, then reads single-file artifacts. Static sites and multi-file artifacts return a `download` next command.
81
+
82
+ To target a specific tool manually, use `skills install --tool <codex|claude|cursor>`; `skills ensure --tool auto` is the same detection `init` uses.
81
83
 
82
84
  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.
83
85
 
package/dist/index.js CHANGED
@@ -1009,8 +1009,22 @@ function humanSuccess(command, data) {
1009
1009
  }
1010
1010
  if (command === "doctor") return doctorHumanOutput(data);
1011
1011
  if (command === "open") return openHumanOutput(data);
1012
+ if (command === "init") return initHumanOutput(data);
1012
1013
  return `${JSON.stringify(data, null, 2)}\n`;
1013
1014
  }
1015
+ function initHumanOutput(data) {
1016
+ const body = `${JSON.stringify(data, null, 2)}`;
1017
+ const nextCommand = initNextCommand(data);
1018
+ if (!nextCommand) return `${body}\n`;
1019
+ return `${body}\nNext command: ${nextCommand}\n`;
1020
+ }
1021
+ function initNextCommand(data) {
1022
+ if (!isRecord(data) || data.mode !== "onboarding") return null;
1023
+ const steps = data.next_steps;
1024
+ if (!Array.isArray(steps)) return null;
1025
+ const pending = steps.find((step) => isRecord(step) && step.done !== true && typeof step.command === "string");
1026
+ return isRecord(pending) && typeof pending.command === "string" ? pending.command : null;
1027
+ }
1014
1028
  function openHumanOutput(data) {
1015
1029
  const body = `${JSON.stringify(data, null, 2)}`;
1016
1030
  const nextCommand = openNextCommand(data);
@@ -3234,12 +3248,48 @@ function gitPattern(path) {
3234
3248
  }
3235
3249
  //#endregion
3236
3250
  //#region src/command-runners/init.ts
3237
- async function runInit(parsed, mode) {
3238
- const command = "init";
3251
+ function runInit(parsed, mode) {
3239
3252
  const profile = nonEmpty(parsed.options.profile);
3240
3253
  const projectId = nonEmpty(parsed.options.projectId);
3254
+ if (!profile && !projectId) return runInitOnboarding(parsed, mode);
3255
+ return runInitConfig(parsed, mode, profile, projectId);
3256
+ }
3257
+ async function runInitOnboarding(parsed, mode) {
3258
+ const command = "init";
3259
+ const skills = await ensureSkills({
3260
+ ...parsed,
3261
+ options: {
3262
+ ...parsed.options,
3263
+ tool: "auto",
3264
+ scope: "project"
3265
+ }
3266
+ }, mode, { command });
3267
+ if (!skills) return;
3268
+ const project = await resolveProjectConfig();
3269
+ const signedIn = (await resolveCredential(parsed.options, project)).ok;
3270
+ return writeSuccess(command, {
3271
+ mode: "onboarding",
3272
+ skills,
3273
+ signed_in: signedIn,
3274
+ next_steps: onboardingNextSteps(signedIn)
3275
+ }, mode);
3276
+ }
3277
+ function onboardingNextSteps(signedIn) {
3278
+ return [{
3279
+ id: "login",
3280
+ title: signedIn ? "Already signed in." : "Sign in so you can share files.",
3281
+ command: `${CLI_INVOCATION} login`,
3282
+ done: signedIn
3283
+ }, {
3284
+ id: "share",
3285
+ title: "Share a file or folder to get a link.",
3286
+ command: `${CLI_INVOCATION} share <path> --json`
3287
+ }];
3288
+ }
3289
+ async function runInitConfig(parsed, mode, profile, projectId) {
3290
+ const command = "init";
3291
+ if (parsed.options.dryRun === true) return writeFailure(command, validationError("--dry-run is only supported without --profile or --project-id.", "Run init --dry-run by itself to preview the skill install, or drop --dry-run to save the defaults."), mode, 1);
3241
3292
  const resolved = await resolveProjectConfig();
3242
- if (!profile && !projectId) return writeSuccess(command, initData(false, resolved.raw ?? {}, resolved), mode);
3243
3293
  if (profile) {
3244
3294
  if (!configHome()) return writeFailure(command, tokenStoreUnavailableError(profile), mode, 1);
3245
3295
  const globalConfig = await readGlobalConfig();
@@ -3254,16 +3304,17 @@ async function runInit(parsed, mode) {
3254
3304
  await mkdir(dirname(path), { recursive: true });
3255
3305
  await writeFile(path, `${JSON.stringify(next, null, 2)}\n`);
3256
3306
  const gitExclude = await ensureGitExclude(process.cwd());
3257
- const data = initData(true, next, resolved);
3307
+ const data = configData(next, resolved);
3258
3308
  delete data.read_path;
3259
3309
  if (gitExclude.warning) data.git_exclude_warning = gitExclude.warning;
3260
3310
  if (gitExclude.applied) data.git_exclude_applied = true;
3261
3311
  return writeSuccess(command, data, mode);
3262
3312
  }
3263
- function initData(written, config, resolved) {
3313
+ function configData(config, resolved) {
3264
3314
  return {
3315
+ mode: "config",
3265
3316
  path: PROJECT_CONFIG_LOCAL_PATH,
3266
- written,
3317
+ written: true,
3267
3318
  config: {
3268
3319
  default_profile: configString(config.default_profile),
3269
3320
  default_project_id: configString(config.default_project_id)
@@ -4050,7 +4101,8 @@ const entryCommand = define({
4050
4101
  description: "Artifact Share CLI",
4051
4102
  toKebab: true,
4052
4103
  args: commonArgs,
4053
- examples: `npx --yes @artifactshare/cli open <artifact-id-or-url> --json
4104
+ examples: `npx --yes @artifactshare/cli init --json
4105
+ npx --yes @artifactshare/cli open <artifact-id-or-url> --json
4054
4106
  npx --yes @artifactshare/cli share <path> --json
4055
4107
  npx --yes @artifactshare/cli update <artifact-id-or-url> <path> --json
4056
4108
  npx --yes @artifactshare/cli edit <artifact-id-or-url> --title "New title" --json
@@ -4962,7 +5014,7 @@ npx --yes @artifactshare/cli skills list --json`,
4962
5014
  });
4963
5015
  const initDefinition = define({
4964
5016
  name: "init",
4965
- description: "Save working-directory defaults to .artifactshare/config.json.",
5017
+ description: "Set up Artifact Share for this directory, or save its defaults.",
4966
5018
  toKebab: true,
4967
5019
  args: {
4968
5020
  ...commonArgs,
@@ -4970,16 +5022,25 @@ const initDefinition = define({
4970
5022
  type: "string",
4971
5023
  toKebab: true,
4972
5024
  description: "Default project for sharing in this directory"
5025
+ },
5026
+ dryRun: {
5027
+ type: "boolean",
5028
+ toKebab: true,
5029
+ description: "Show the planned skill changes without writing (onboarding)"
4973
5030
  }
4974
5031
  },
4975
- examples: `npx --yes @artifactshare/cli init --profile client-a --project-id <id> --json
4976
- npx --yes @artifactshare/cli init --json
5032
+ examples: `npx --yes @artifactshare/cli init --json
5033
+ npx --yes @artifactshare/cli init --dry-run --json
5034
+ npx --yes @artifactshare/cli init --profile client-a --project-id <id> --json
4977
5035
 
4978
- Without flags, init reports the current config and writes nothing.
4979
- Secrets are never written to .artifactshare/config.json.
5036
+ Without flags, init detects your agent (Claude Code, Codex, Cursor), installs the
5037
+ bundled skill, and shows the next steps (sign in, then share). data.mode is "onboarding".
5038
+ With --profile or --project-id, init saves working-directory defaults to
5039
+ .artifactshare/config.local.json instead (data.mode is "config"); secrets are never written there.
4980
5040
 
4981
5041
  Common failures:
4982
- profile_not_found Run profiles list to see saved profiles, or login --profile <name>`
5042
+ skill_update_conflict An unmanaged or broken skill file exists; inspect it before overwriting
5043
+ profile_not_found Run profiles list to see saved profiles, or login --profile <name>`
4983
5044
  });
4984
5045
  const requestAccessDefinition = define({
4985
5046
  name: "request-access",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artifactshare/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.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: Open, share, update, and read back shared files with the Artifact S
4
4
  ---
5
5
 
6
6
  <!-- artifactshare-skill
7
- version: 15
7
+ version: 16
8
8
  managed: true
9
9
  -->
10
10
 
@@ -18,6 +18,11 @@ with a stable contract.
18
18
  Run commands with `npx --yes @artifactshare/cli`. When unsure about a
19
19
  command or flag, read `npx --yes @artifactshare/cli --help` first.
20
20
 
21
+ First-time setup in a project: `npx --yes @artifactshare/cli init` detects the
22
+ agent (Claude Code, Codex, Cursor), installs or updates this skill, and reports
23
+ the next steps (sign in, then share). When you receive a share URL instead,
24
+ start with `open <artifact-id-or-url> --json`.
25
+
21
26
  Use the CLI whenever the file already exists locally as a file or folder.
22
27
  The remote MCP tools accept HTML or Markdown source strings; they cannot read
23
28
  paths like `/Users/.../report.html` from the user's filesystem.
@@ -4,7 +4,7 @@ alwaysApply: false
4
4
  ---
5
5
 
6
6
  <!-- artifactshare-skill
7
- version: 15
7
+ version: 16
8
8
  managed: true
9
9
  -->
10
10
 
@@ -15,6 +15,10 @@ sites) with versions and comments. Use `npx --yes @artifactshare/cli` to
15
15
  open shared URLs and share local files from the terminal, and read
16
16
  `npx --yes @artifactshare/cli --help` before choosing a command.
17
17
 
18
+ First-time setup in a project: `npx --yes @artifactshare/cli init` detects the
19
+ agent (Claude Code, Codex, Cursor), installs or updates this rule, and reports
20
+ the next steps (sign in, then share).
21
+
18
22
  Use the CLI for local files and folders. The remote MCP tools accept HTML or
19
23
  Markdown source strings; they cannot read paths like `/Users/.../report.html`
20
24
  from the user's filesystem.