@artifactshare/cli 0.5.2 → 0.6.1
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/CHANGELOG.md +39 -0
- package/README.md +23 -21
- package/dist/index.js +239 -105
- package/package.json +2 -1
- package/skills/artifactshare/SKILL.md +15 -6
- package/skills/artifactshare/artifactshare.mdc +3 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@artifactshare/cli` are documented here.
|
|
4
|
+
For user-facing announcements, see https://artifactshare.com/updates?product=cli.
|
|
5
|
+
|
|
6
|
+
## 0.6.1 - 2026-07-12
|
|
7
|
+
|
|
8
|
+
- Fix `--insecure-localhost` failing every command with `network_failed` on Node 22/24 by routing all CLI HTTP requests through undici's own fetch
|
|
9
|
+
|
|
10
|
+
## 0.6.0 - 2026-07-11
|
|
11
|
+
|
|
12
|
+
- Add Cursor user-scope skill install and update support
|
|
13
|
+
- Move automatic skill install and update to user scope by default
|
|
14
|
+
|
|
15
|
+
## 0.5.2 - 2026-07-09
|
|
16
|
+
|
|
17
|
+
- Auto-update outdated managed user-scope skills after successful commands
|
|
18
|
+
|
|
19
|
+
## 0.5.1 - 2026-07-09
|
|
20
|
+
|
|
21
|
+
- Refresh expired session profiles automatically across authenticated API calls
|
|
22
|
+
|
|
23
|
+
## 0.5.0 - 2026-06-23
|
|
24
|
+
|
|
25
|
+
- Add `logout` to remove saved local credentials
|
|
26
|
+
|
|
27
|
+
## 0.4.1 - 2026-06-22
|
|
28
|
+
|
|
29
|
+
- Start browser approval automatically during non-interactive JSON login
|
|
30
|
+
|
|
31
|
+
## 0.4.0 - 2026-06-21
|
|
32
|
+
|
|
33
|
+
- Expand bundled skill coverage to match current CLI commands
|
|
34
|
+
- Refresh CLI login sessions during normal use
|
|
35
|
+
- Report outdated managed skills from `doctor`
|
|
36
|
+
|
|
37
|
+
## 0.1.0 - 2026-06-11
|
|
38
|
+
|
|
39
|
+
- Initial public releases (0.1.x through 0.3.x): npm publish, agent onboarding with `init` and `open`, bundled skills, `request-access`, and core share, update, download, and comment commands
|
package/README.md
CHANGED
|
@@ -42,25 +42,26 @@ 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
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
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
|
+
| `changelog` | Show the installed version, this release's notes, and the public updates page |
|
|
62
|
+
| `profiles list / use / import-token / delete` | Switch between local account profiles, import an issued token from stdin, and delete profile entries |
|
|
63
|
+
| `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` |
|
|
64
|
+
| `skills ensure / install / list / update / remove` | Install or update the bundled usage guide in your AI agent's skills |
|
|
64
65
|
|
|
65
66
|
## For AI agents
|
|
66
67
|
|
|
@@ -70,7 +71,7 @@ For first-time setup in a project, start here:
|
|
|
70
71
|
npx --yes @artifactshare/cli init --json
|
|
71
72
|
```
|
|
72
73
|
|
|
73
|
-
`init` detects
|
|
74
|
+
`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
75
|
|
|
75
76
|
When an agent receives an Artifact Share URL instead, start with `open`:
|
|
76
77
|
|
|
@@ -80,7 +81,7 @@ npx --yes @artifactshare/cli open <artifact-id-or-url> --json
|
|
|
80
81
|
|
|
81
82
|
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
83
|
|
|
83
|
-
To target a specific tool manually, use `skills install --tool <codex|claude|cursor
|
|
84
|
+
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
85
|
|
|
85
86
|
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
87
|
|
|
@@ -95,4 +96,5 @@ Quote paths and free-form text before passing them through a shell. Artifact Sha
|
|
|
95
96
|
## Links
|
|
96
97
|
|
|
97
98
|
- Setup guide for AI tools and terminals: https://artifactshare.com/connect
|
|
99
|
+
- Public updates (Web, CLI, Agent, MCP): https://artifactshare.com/updates
|
|
98
100
|
- Artifact Share: https://artifactshare.com
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { appendFile, chmod, lstat, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
|
|
3
2
|
import { cli, define, lazy } from "gunshi";
|
|
4
3
|
import { spawn } from "node:child_process";
|
|
4
|
+
import { appendFile, chmod, lstat, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
6
6
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import { createReadStream } from "node:fs";
|
|
9
|
+
import { Blob } from "node:buffer";
|
|
9
10
|
import { createHash } from "node:crypto";
|
|
10
11
|
//#region src/constants.ts
|
|
11
12
|
const DEFAULT_BASE_URL = "https://artifactshare.com";
|
|
@@ -86,7 +87,8 @@ const COMMAND_NAMES = /* @__PURE__ */ new Set([
|
|
|
86
87
|
"profiles",
|
|
87
88
|
"projects",
|
|
88
89
|
"skills",
|
|
89
|
-
"init"
|
|
90
|
+
"init",
|
|
91
|
+
"changelog"
|
|
90
92
|
]);
|
|
91
93
|
const SUBCOMMANDS = {
|
|
92
94
|
artifacts: ["list", "get"],
|
|
@@ -174,6 +176,16 @@ function mapApiError(status, body, options = {}) {
|
|
|
174
176
|
suggested_command: REQUEST_ACCESS_COMMAND$1
|
|
175
177
|
}
|
|
176
178
|
});
|
|
179
|
+
if (apiCode === "self-upload-disabled") return cliError({
|
|
180
|
+
code: "self_upload_disabled",
|
|
181
|
+
message: "This account cannot upload its own files.",
|
|
182
|
+
why: "Email-code sign-in creates a viewer workspace for shared files only.",
|
|
183
|
+
hint: "Sign in with Google or Microsoft on the Artifact Share website, then retry share.",
|
|
184
|
+
agentRecoverable: false,
|
|
185
|
+
requiresHuman: true,
|
|
186
|
+
recovery: { kind: "ask_human" },
|
|
187
|
+
details: { limit: "self_upload" }
|
|
188
|
+
});
|
|
177
189
|
if (apiCode === "upload-suspended") return cliError({
|
|
178
190
|
code: "upload_suspended",
|
|
179
191
|
message: apiMessage ?? "Your upload permission is suspended.",
|
|
@@ -665,6 +677,7 @@ function normalizeApiCode(value) {
|
|
|
665
677
|
return typeof value === "string" ? value : null;
|
|
666
678
|
}
|
|
667
679
|
function uploadBlockedHint(code) {
|
|
680
|
+
if (code === "self-upload-disabled") return "Sign in with Google or Microsoft on the Artifact Share website, then retry share.";
|
|
668
681
|
if (code === "upload-not-allowed") return `Run ${REQUEST_ACCESS_COMMAND$1} to join the waitlist, then retry share once an operator opens sharing.`;
|
|
669
682
|
if (code === "upload-policy-unavailable") return "Retry doctor later; upload permission could not be checked.";
|
|
670
683
|
return "Resolve the upload issue, then retry share.";
|
|
@@ -1046,6 +1059,7 @@ function humanSuccess(command, data) {
|
|
|
1046
1059
|
if (command === "doctor") return doctorHumanOutput(data);
|
|
1047
1060
|
if (command === "open") return openHumanOutput(data);
|
|
1048
1061
|
if (command === "init") return initHumanOutput(data);
|
|
1062
|
+
if (command === "changelog") return changelogHumanOutput(data);
|
|
1049
1063
|
const output = `${JSON.stringify(data, null, 2)}\n`;
|
|
1050
1064
|
return suffix ? `${output}${suffix}` : output;
|
|
1051
1065
|
}
|
|
@@ -1102,6 +1116,23 @@ function doctorNextCommand(data) {
|
|
|
1102
1116
|
if (!isRecord(data) || !("next_command" in data)) return null;
|
|
1103
1117
|
return typeof data.next_command === "string" ? data.next_command : null;
|
|
1104
1118
|
}
|
|
1119
|
+
function changelogHumanOutput(data) {
|
|
1120
|
+
if (!isRecord(data)) return `${JSON.stringify(data, null, 2)}\n`;
|
|
1121
|
+
const version = typeof data.version === "string" ? data.version : "";
|
|
1122
|
+
const updatesUrl = typeof data.updates_url === "string" ? data.updates_url : "";
|
|
1123
|
+
const lines = [
|
|
1124
|
+
`Artifact Share CLI ${version}`,
|
|
1125
|
+
"",
|
|
1126
|
+
`Updates: ${updatesUrl}`
|
|
1127
|
+
];
|
|
1128
|
+
const latest = data.latest;
|
|
1129
|
+
if (isRecord(latest) && typeof latest.body === "string" && latest.body) {
|
|
1130
|
+
const latestVersion = typeof latest.version === "string" ? latest.version : version;
|
|
1131
|
+
const latestDate = typeof latest.date === "string" ? latest.date : "";
|
|
1132
|
+
lines.push("", `Changes in ${latestVersion} (${latestDate}):`, latest.body);
|
|
1133
|
+
}
|
|
1134
|
+
return `${lines.join("\n")}\n`;
|
|
1135
|
+
}
|
|
1105
1136
|
function shareSuccessFields(data) {
|
|
1106
1137
|
if (!isRecord(data)) return null;
|
|
1107
1138
|
const artifact = data.artifact;
|
|
@@ -1159,16 +1190,32 @@ function downloadManifestFileFields(data) {
|
|
|
1159
1190
|
//#endregion
|
|
1160
1191
|
//#region src/api.ts
|
|
1161
1192
|
let insecureLocalhostDispatcher;
|
|
1193
|
+
let undiciModule$1;
|
|
1194
|
+
async function loadUndici() {
|
|
1195
|
+
return undiciModule$1 ??= await import("undici");
|
|
1196
|
+
}
|
|
1162
1197
|
function baseUrlOf(options) {
|
|
1163
1198
|
return String(options.baseUrl ?? process.env.ARTIFACTSHARE_BASE_URL ?? "https://artifactshare.com").replace(/\/$/, "");
|
|
1164
1199
|
}
|
|
1165
|
-
|
|
1200
|
+
function requestConfig(options) {
|
|
1166
1201
|
if (!insecureLocalhostEnabled(options)) return { init: {} };
|
|
1167
1202
|
const baseUrl = baseUrlOf(options);
|
|
1168
1203
|
const url = new URL(baseUrl);
|
|
1169
1204
|
if (url.protocol !== "https:" || !isLocalHostname(url.hostname)) return { error: validationError("--insecure-localhost only works with local HTTPS base URLs.", "Use it only with https://localhost, https://127.0.0.1, or https://[::1].") };
|
|
1170
|
-
|
|
1171
|
-
|
|
1205
|
+
return { init: { insecureLocalhost: true } };
|
|
1206
|
+
}
|
|
1207
|
+
async function cliFetch(input, init = {}) {
|
|
1208
|
+
const { insecureLocalhost, ...fetchInit } = init;
|
|
1209
|
+
const { fetch, Agent } = await loadUndici();
|
|
1210
|
+
const requestInit = insecureLocalhost ? {
|
|
1211
|
+
...fetchInit,
|
|
1212
|
+
dispatcher: insecureLocalhostDispatcher ??= new Agent({ connect: { rejectUnauthorized: false } })
|
|
1213
|
+
} : fetchInit;
|
|
1214
|
+
try {
|
|
1215
|
+
return await fetch(input, requestInit);
|
|
1216
|
+
} catch (error) {
|
|
1217
|
+
return { networkError: error };
|
|
1218
|
+
}
|
|
1172
1219
|
}
|
|
1173
1220
|
function insecureLocalhostEnabled(options) {
|
|
1174
1221
|
return Boolean(options.insecureLocalhost) || process.env.ARTIFACTSHARE_INSECURE_LOCALHOST === "1";
|
|
@@ -1239,7 +1286,7 @@ async function apiRequest(path, options, init, errorOptions) {
|
|
|
1239
1286
|
return { body };
|
|
1240
1287
|
}
|
|
1241
1288
|
async function apiRequestRaw(path, options, init) {
|
|
1242
|
-
const response = await
|
|
1289
|
+
const response = await cliFetch(apiUrl(path, baseUrlOf(options)), init);
|
|
1243
1290
|
if ("networkError" in response) return { error: networkError(response.networkError) };
|
|
1244
1291
|
return {
|
|
1245
1292
|
response,
|
|
@@ -2070,12 +2117,12 @@ async function runLogin(parsed, mode) {
|
|
|
2070
2117
|
return writeSuccess(command, result.data, mode);
|
|
2071
2118
|
}
|
|
2072
2119
|
async function requestDeviceCode(options, init) {
|
|
2073
|
-
const response = await
|
|
2120
|
+
const response = await cliFetch(apiUrl("/api/auth/device/code", baseUrlOf(options)), {
|
|
2074
2121
|
method: "POST",
|
|
2075
2122
|
headers: { "content-type": "application/json" },
|
|
2076
2123
|
body: JSON.stringify({ client_id: DEVICE_CLIENT_ID }),
|
|
2077
2124
|
...init
|
|
2078
|
-
})
|
|
2125
|
+
});
|
|
2079
2126
|
if ("networkError" in response) return { error: networkError(response.networkError) };
|
|
2080
2127
|
const body = await readJson(response);
|
|
2081
2128
|
if (!response.ok) return { error: mapApiError(response.status, body, { baseUrl: baseUrlOf(options) }) };
|
|
@@ -2083,7 +2130,7 @@ async function requestDeviceCode(options, init) {
|
|
|
2083
2130
|
return body;
|
|
2084
2131
|
}
|
|
2085
2132
|
async function exchangeDeviceTokenOnce(options, deviceCode, init) {
|
|
2086
|
-
const response = await
|
|
2133
|
+
const response = await cliFetch(apiUrl("/api/auth/device/token", baseUrlOf(options)), {
|
|
2087
2134
|
method: "POST",
|
|
2088
2135
|
headers: { "content-type": "application/json" },
|
|
2089
2136
|
body: JSON.stringify({
|
|
@@ -2092,7 +2139,7 @@ async function exchangeDeviceTokenOnce(options, deviceCode, init) {
|
|
|
2092
2139
|
client_id: DEVICE_CLIENT_ID
|
|
2093
2140
|
}),
|
|
2094
2141
|
...init
|
|
2095
|
-
})
|
|
2142
|
+
});
|
|
2096
2143
|
if ("networkError" in response) return { error: networkError(response.networkError) };
|
|
2097
2144
|
const body = await readJson(response);
|
|
2098
2145
|
if (response.ok && isDeviceTokenResponse(body)) return {
|
|
@@ -2125,7 +2172,7 @@ async function pollForToken(options, code, init, profile, deadline) {
|
|
|
2125
2172
|
let networkFailures = 0;
|
|
2126
2173
|
while (Date.now() < deadline) {
|
|
2127
2174
|
await setTimeout$1(intervalMs);
|
|
2128
|
-
const response = await
|
|
2175
|
+
const response = await cliFetch(apiUrl("/api/auth/device/token", baseUrlOf(options)), {
|
|
2129
2176
|
method: "POST",
|
|
2130
2177
|
headers: { "content-type": "application/json" },
|
|
2131
2178
|
body: JSON.stringify({
|
|
@@ -2134,7 +2181,7 @@ async function pollForToken(options, code, init, profile, deadline) {
|
|
|
2134
2181
|
client_id: DEVICE_CLIENT_ID
|
|
2135
2182
|
}),
|
|
2136
2183
|
...init
|
|
2137
|
-
})
|
|
2184
|
+
});
|
|
2138
2185
|
if ("networkError" in response) {
|
|
2139
2186
|
networkFailures += 1;
|
|
2140
2187
|
if (networkFailures >= 5) return { error: networkError(response.networkError) };
|
|
@@ -2473,10 +2520,10 @@ async function fetchArtifact(parsed, target, credential) {
|
|
|
2473
2520
|
const url = apiUrl(`/api/cli/artifacts/${encodeURIComponent(target.artifactId)}`, baseUrlOf(parsed.options));
|
|
2474
2521
|
if (target.offset !== void 0) url.searchParams.set("offset", target.offset);
|
|
2475
2522
|
for (const item of target.include) url.searchParams.append("include", item);
|
|
2476
|
-
const response = await
|
|
2523
|
+
const response = await cliFetch(url, {
|
|
2477
2524
|
headers: { Authorization: `Bearer ${credential.token}` },
|
|
2478
2525
|
...request.init
|
|
2479
|
-
})
|
|
2526
|
+
});
|
|
2480
2527
|
if ("networkError" in response) return { error: networkError(response.networkError) };
|
|
2481
2528
|
const body = await readJson(response);
|
|
2482
2529
|
if (!response.ok) return { error: mapApiError(response.status, body, {
|
|
@@ -2508,10 +2555,10 @@ async function runArtifactsList(parsed, mode) {
|
|
|
2508
2555
|
else if (projectId) url.searchParams.set("project_id", projectId);
|
|
2509
2556
|
if (query) url.searchParams.set("query", query);
|
|
2510
2557
|
const result = await runAuthenticatedApi(credential, parsed.options, async (current) => {
|
|
2511
|
-
const response = await
|
|
2558
|
+
const response = await cliFetch(url, {
|
|
2512
2559
|
headers: { Authorization: `Bearer ${current.token}` },
|
|
2513
2560
|
...request.init
|
|
2514
|
-
})
|
|
2561
|
+
});
|
|
2515
2562
|
if ("networkError" in response) return { error: networkError(response.networkError) };
|
|
2516
2563
|
const body = await readJson(response);
|
|
2517
2564
|
if (!response.ok) return { error: mapApiError(response.status, body, {
|
|
@@ -2538,29 +2585,39 @@ const SKILL_TOOLS = [
|
|
|
2538
2585
|
const SKILL_FILE_PATH = join("skills", "artifactshare", "SKILL.md");
|
|
2539
2586
|
const TOOL_CONFIG = {
|
|
2540
2587
|
codex: {
|
|
2541
|
-
relativePath: join(".agents", SKILL_FILE_PATH),
|
|
2542
2588
|
scopes: ["project", "user"],
|
|
2543
|
-
detectDirs: [".codex", ".agents"]
|
|
2544
|
-
bundledFile: "SKILL.md",
|
|
2545
|
-
pruneDirs: ["artifactshare", "skills"]
|
|
2589
|
+
detectDirs: [".codex", ".agents"]
|
|
2546
2590
|
},
|
|
2547
2591
|
claude: {
|
|
2548
|
-
relativePath: join(".claude", SKILL_FILE_PATH),
|
|
2549
2592
|
scopes: ["project", "user"],
|
|
2550
|
-
detectDirs: [".claude"]
|
|
2551
|
-
bundledFile: "SKILL.md",
|
|
2552
|
-
pruneDirs: ["artifactshare", "skills"]
|
|
2593
|
+
detectDirs: [".claude"]
|
|
2553
2594
|
},
|
|
2554
2595
|
cursor: {
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
detectDirs: [".cursor"],
|
|
2558
|
-
bundledFile: "artifactshare.mdc",
|
|
2559
|
-
pruneDirs: []
|
|
2596
|
+
scopes: ["project", "user"],
|
|
2597
|
+
detectDirs: [".cursor"]
|
|
2560
2598
|
}
|
|
2561
2599
|
};
|
|
2600
|
+
function scopeTargetConfig(tool, scope) {
|
|
2601
|
+
if (tool === "cursor") {
|
|
2602
|
+
if (scope === "project") return {
|
|
2603
|
+
relativePath: join(".cursor", "rules", "artifactshare.mdc"),
|
|
2604
|
+
bundledFile: "artifactshare.mdc",
|
|
2605
|
+
pruneDirs: []
|
|
2606
|
+
};
|
|
2607
|
+
return {
|
|
2608
|
+
relativePath: join(".cursor", "skills", "artifactshare", "SKILL.md"),
|
|
2609
|
+
bundledFile: "SKILL.md",
|
|
2610
|
+
pruneDirs: ["artifactshare", "skills"]
|
|
2611
|
+
};
|
|
2612
|
+
}
|
|
2613
|
+
return {
|
|
2614
|
+
relativePath: join(tool === "codex" ? ".agents" : ".claude", SKILL_FILE_PATH),
|
|
2615
|
+
bundledFile: "SKILL.md",
|
|
2616
|
+
pruneDirs: ["artifactshare", "skills"]
|
|
2617
|
+
};
|
|
2618
|
+
}
|
|
2562
2619
|
function skillTarget(tool, scope) {
|
|
2563
|
-
const relative =
|
|
2620
|
+
const relative = scopeTargetConfig(tool, scope).relativePath;
|
|
2564
2621
|
const path = scope === "project" ? relative : join(homedir(), relative);
|
|
2565
2622
|
return {
|
|
2566
2623
|
tool,
|
|
@@ -2569,6 +2626,10 @@ function skillTarget(tool, scope) {
|
|
|
2569
2626
|
absolutePath: resolve(path)
|
|
2570
2627
|
};
|
|
2571
2628
|
}
|
|
2629
|
+
function bundledContentForTarget(bundled, target) {
|
|
2630
|
+
const file = scopeTargetConfig(target.tool, target.scope).bundledFile;
|
|
2631
|
+
return bundled.contentsByFile[file];
|
|
2632
|
+
}
|
|
2572
2633
|
function allTargets() {
|
|
2573
2634
|
return SKILL_TOOLS.flatMap((tool) => TOOL_CONFIG[tool].scopes.map((scope) => skillTarget(tool, scope)));
|
|
2574
2635
|
}
|
|
@@ -2588,23 +2649,17 @@ async function readTarget(target) {
|
|
|
2588
2649
|
return managedState(await readFile(target.absolutePath, "utf8").catch(() => null));
|
|
2589
2650
|
}
|
|
2590
2651
|
async function loadBundledSkills() {
|
|
2591
|
-
const
|
|
2592
|
-
const contents = {};
|
|
2652
|
+
const contentsByFile = {};
|
|
2593
2653
|
let version;
|
|
2594
|
-
for (const
|
|
2595
|
-
const
|
|
2596
|
-
|
|
2597
|
-
if (
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
if (state.kind !== "managed" || (version ?? state.version) !== state.version) throw new Error(`The bundled ${file} has a missing or mismatched managed marker.`);
|
|
2601
|
-
version = state.version;
|
|
2602
|
-
byFile.set(file, content);
|
|
2603
|
-
}
|
|
2604
|
-
contents[tool] = content;
|
|
2654
|
+
for (const file of ["SKILL.md", "artifactshare.mdc"]) {
|
|
2655
|
+
const content = await readFile(new URL(`../skills/artifactshare/${file}`, import.meta.url), "utf8");
|
|
2656
|
+
const state = managedState(content);
|
|
2657
|
+
if (state.kind !== "managed" || (version ?? state.version) !== state.version) throw new Error(`The bundled ${file} has a missing or mismatched managed marker.`);
|
|
2658
|
+
version = state.version;
|
|
2659
|
+
contentsByFile[file] = content;
|
|
2605
2660
|
}
|
|
2606
2661
|
return {
|
|
2607
|
-
|
|
2662
|
+
contentsByFile,
|
|
2608
2663
|
version
|
|
2609
2664
|
};
|
|
2610
2665
|
}
|
|
@@ -2642,7 +2697,7 @@ function parseFilters(parsed, options = {}) {
|
|
|
2642
2697
|
if (tools.error) return { error: tools.error };
|
|
2643
2698
|
const scope = parseScope(parsed.options.scope);
|
|
2644
2699
|
if (scope.error) return { error: scope.error };
|
|
2645
|
-
if (tools.auto && scope.scope === "
|
|
2700
|
+
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.") };
|
|
2646
2701
|
const unsupported = scope.scope === void 0 ? void 0 : tools.tools.find((tool) => !TOOL_CONFIG[tool].scopes.includes(scope.scope));
|
|
2647
2702
|
if (unsupported) return { error: validationError(`The ${unsupported} tool does not support --scope ${scope.scope}.`, `Use --tool ${unsupported} --scope project.`) };
|
|
2648
2703
|
return {
|
|
@@ -2662,16 +2717,23 @@ async function isToolDetected(tool, scope) {
|
|
|
2662
2717
|
for (const dir of TOOL_CONFIG[tool].detectDirs) if ((await stat(join(base, dir)).catch(() => null))?.isDirectory()) return true;
|
|
2663
2718
|
return false;
|
|
2664
2719
|
}
|
|
2665
|
-
async function
|
|
2666
|
-
const targetScope = scope ?? "project";
|
|
2720
|
+
async function autoDetectedTools() {
|
|
2667
2721
|
const autoOrder = [
|
|
2668
2722
|
"claude",
|
|
2669
2723
|
"codex",
|
|
2670
2724
|
"cursor"
|
|
2671
2725
|
];
|
|
2672
|
-
const detected =
|
|
2673
|
-
for (const tool of autoOrder) if (
|
|
2674
|
-
return
|
|
2726
|
+
const detected = [];
|
|
2727
|
+
for (const tool of autoOrder) if (await isToolDetected(tool, "project")) detected.push(tool);
|
|
2728
|
+
return detected.length > 0 ? detected : [
|
|
2729
|
+
"codex",
|
|
2730
|
+
"claude",
|
|
2731
|
+
"cursor"
|
|
2732
|
+
];
|
|
2733
|
+
}
|
|
2734
|
+
async function autoTargets(scope) {
|
|
2735
|
+
const targetScope = scope ?? "user";
|
|
2736
|
+
return (await autoDetectedTools()).filter((tool) => TOOL_CONFIG[tool].scopes.includes(targetScope)).map((tool) => skillTarget(tool, targetScope));
|
|
2675
2737
|
}
|
|
2676
2738
|
function targetPathKey(target) {
|
|
2677
2739
|
return realpath(target.absolutePath).catch(() => target.absolutePath);
|
|
@@ -2689,7 +2751,7 @@ async function applyAction({ target, action, content }) {
|
|
|
2689
2751
|
}
|
|
2690
2752
|
async function cleanupSkillDirs(target) {
|
|
2691
2753
|
let dir = dirname(target.absolutePath);
|
|
2692
|
-
for (const expected of
|
|
2754
|
+
for (const expected of scopeTargetConfig(target.tool, target.scope).pruneDirs) {
|
|
2693
2755
|
if (basename(dir) !== expected) return;
|
|
2694
2756
|
try {
|
|
2695
2757
|
await rmdir(dir);
|
|
@@ -2766,7 +2828,7 @@ async function runSkillsInstall(parsed, mode) {
|
|
|
2766
2828
|
planned.push({
|
|
2767
2829
|
target,
|
|
2768
2830
|
action: state.kind === "missing" ? "installed" : "updated",
|
|
2769
|
-
content: bundled
|
|
2831
|
+
content: bundledContentForTarget(bundled, target)
|
|
2770
2832
|
});
|
|
2771
2833
|
}
|
|
2772
2834
|
await runActions(command, planned, parsed.options.dryRun === true, mode);
|
|
@@ -2789,21 +2851,18 @@ async function ensureSkills(parsed, mode, options = {}) {
|
|
|
2789
2851
|
for (const target of targets) {
|
|
2790
2852
|
const state = await readTarget(target);
|
|
2791
2853
|
if (state.kind === "unmanaged" || state.kind === "broken") {
|
|
2854
|
+
if (options.skipBrokenUserSkills && state.kind === "broken") continue;
|
|
2792
2855
|
writeFailure(command, skillUpdateConflictError(target.path), mode, 1);
|
|
2793
2856
|
return;
|
|
2794
2857
|
}
|
|
2795
2858
|
const unchanged = state.kind === "managed" && state.version === bundled.version;
|
|
2796
|
-
const recommendUpdate = options.recommendProjectUpdates && target.scope === "project" && state.kind === "managed" && state.version !== bundled.version;
|
|
2797
2859
|
planned.push(unchanged ? {
|
|
2798
2860
|
target,
|
|
2799
2861
|
action: "unchanged"
|
|
2800
|
-
} : recommendUpdate ? {
|
|
2801
|
-
target,
|
|
2802
|
-
action: "update_recommended"
|
|
2803
2862
|
} : {
|
|
2804
2863
|
target,
|
|
2805
2864
|
action: state.kind === "missing" ? "installed" : "updated",
|
|
2806
|
-
content: bundled
|
|
2865
|
+
content: bundledContentForTarget(bundled, target)
|
|
2807
2866
|
});
|
|
2808
2867
|
}
|
|
2809
2868
|
if (options.autoUpdateUserManaged) {
|
|
@@ -2815,7 +2874,7 @@ async function ensureSkills(parsed, mode, options = {}) {
|
|
|
2815
2874
|
planned.push({
|
|
2816
2875
|
target,
|
|
2817
2876
|
action: "updated",
|
|
2818
|
-
content: bundled
|
|
2877
|
+
content: bundledContentForTarget(bundled, target),
|
|
2819
2878
|
fallbackAction: "update_recommended"
|
|
2820
2879
|
});
|
|
2821
2880
|
}
|
|
@@ -2832,7 +2891,7 @@ async function autoUpdateUserManagedSkills() {
|
|
|
2832
2891
|
planned.push({
|
|
2833
2892
|
target,
|
|
2834
2893
|
action: "updated",
|
|
2835
|
-
content: bundled
|
|
2894
|
+
content: bundledContentForTarget(bundled, target),
|
|
2836
2895
|
fallbackAction: "update_recommended",
|
|
2837
2896
|
installedVersion: state.version
|
|
2838
2897
|
});
|
|
@@ -2935,7 +2994,7 @@ async function runSkillsUpdate(parsed, mode) {
|
|
|
2935
2994
|
else if (state.version !== bundled.version || force) planned.push({
|
|
2936
2995
|
target,
|
|
2937
2996
|
action: "updated",
|
|
2938
|
-
content: bundled
|
|
2997
|
+
content: bundledContentForTarget(bundled, target)
|
|
2939
2998
|
});
|
|
2940
2999
|
else planned.push({
|
|
2941
3000
|
target,
|
|
@@ -2967,13 +3026,12 @@ async function runOpen(parsed, mode, isRetry = false) {
|
|
|
2967
3026
|
...parsed,
|
|
2968
3027
|
options: {
|
|
2969
3028
|
...parsed.options,
|
|
2970
|
-
tool: "auto"
|
|
2971
|
-
scope: "project"
|
|
3029
|
+
tool: "auto"
|
|
2972
3030
|
}
|
|
2973
3031
|
}, mode, {
|
|
2974
3032
|
command,
|
|
2975
3033
|
autoUpdateUserManaged: true,
|
|
2976
|
-
|
|
3034
|
+
skipBrokenUserSkills: true
|
|
2977
3035
|
});
|
|
2978
3036
|
if (!skills) return;
|
|
2979
3037
|
const target = parseArtifactTarget(parsed.positionals[0], command, "Pass an artifact ID or share URL to read.");
|
|
@@ -3292,10 +3350,10 @@ async function runDoctor(parsed, mode) {
|
|
|
3292
3350
|
const request = await requestConfig(parsed.options);
|
|
3293
3351
|
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
3294
3352
|
const result = await runAuthenticatedApi(credential, parsed.options, async (current) => {
|
|
3295
|
-
const response = await
|
|
3353
|
+
const response = await cliFetch(apiUrl("/api/cli/doctor", baseUrlOf(parsed.options)), {
|
|
3296
3354
|
headers: { Authorization: `Bearer ${current.token}` },
|
|
3297
3355
|
...request.init
|
|
3298
|
-
})
|
|
3356
|
+
});
|
|
3299
3357
|
if ("networkError" in response) return { data: {
|
|
3300
3358
|
kind: "network_failed",
|
|
3301
3359
|
hint: networkError(response.networkError).hint
|
|
@@ -3395,8 +3453,75 @@ function effectiveDiagnostics(project, globalConfig) {
|
|
|
3395
3453
|
};
|
|
3396
3454
|
}
|
|
3397
3455
|
//#endregion
|
|
3456
|
+
//#region src/changelog.ts
|
|
3457
|
+
const CLI_UPDATES_URL = "https://artifactshare.com/updates?product=cli";
|
|
3458
|
+
const SECTION_HEADING = /^## (\S+) - (\d{4}-\d{2}-\d{2})$/;
|
|
3459
|
+
function extractChangelogSection(content, version) {
|
|
3460
|
+
const lines = content.split("\n");
|
|
3461
|
+
let bodyStart = -1;
|
|
3462
|
+
let date = "";
|
|
3463
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
3464
|
+
const match = lines[index]?.match(SECTION_HEADING);
|
|
3465
|
+
if (!match || match[1] !== version) continue;
|
|
3466
|
+
bodyStart = index + 1;
|
|
3467
|
+
date = match[2] ?? "";
|
|
3468
|
+
break;
|
|
3469
|
+
}
|
|
3470
|
+
if (bodyStart === -1) return null;
|
|
3471
|
+
const bodyLines = [];
|
|
3472
|
+
for (let index = bodyStart; index < lines.length; index += 1) {
|
|
3473
|
+
const line = lines[index] ?? "";
|
|
3474
|
+
if (line.startsWith("## ")) break;
|
|
3475
|
+
bodyLines.push(line);
|
|
3476
|
+
}
|
|
3477
|
+
return {
|
|
3478
|
+
version,
|
|
3479
|
+
date,
|
|
3480
|
+
body: bodyLines.join("\n").trim()
|
|
3481
|
+
};
|
|
3482
|
+
}
|
|
3483
|
+
async function readBundledChangelog() {
|
|
3484
|
+
try {
|
|
3485
|
+
return await readFile(new URL("../CHANGELOG.md", import.meta.url), "utf8");
|
|
3486
|
+
} catch {
|
|
3487
|
+
return null;
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
function changelogDataFromContent(version, content) {
|
|
3491
|
+
return {
|
|
3492
|
+
version,
|
|
3493
|
+
updates_url: CLI_UPDATES_URL,
|
|
3494
|
+
latest: content ? extractChangelogSection(content, version) : null
|
|
3495
|
+
};
|
|
3496
|
+
}
|
|
3497
|
+
async function buildChangelogData(version) {
|
|
3498
|
+
return changelogDataFromContent(version, await readBundledChangelog());
|
|
3499
|
+
}
|
|
3500
|
+
//#endregion
|
|
3501
|
+
//#region src/version.ts
|
|
3502
|
+
async function loadCliVersion() {
|
|
3503
|
+
try {
|
|
3504
|
+
const content = await readFile(new URL("../package.json", import.meta.url), "utf8");
|
|
3505
|
+
const pkg = JSON.parse(content);
|
|
3506
|
+
return typeof pkg.version === "string" ? pkg.version : "0.0.0";
|
|
3507
|
+
} catch {
|
|
3508
|
+
return "0.0.0";
|
|
3509
|
+
}
|
|
3510
|
+
}
|
|
3511
|
+
//#endregion
|
|
3512
|
+
//#region src/command-runners/changelog.ts
|
|
3513
|
+
async function runChangelog(_parsed, mode) {
|
|
3514
|
+
return writeSuccess("changelog", await buildChangelogData(await loadCliVersion()), mode);
|
|
3515
|
+
}
|
|
3516
|
+
//#endregion
|
|
3398
3517
|
//#region src/files.ts
|
|
3399
|
-
|
|
3518
|
+
let undiciModule;
|
|
3519
|
+
async function createUploadForm() {
|
|
3520
|
+
const { FormData } = undiciModule ??= await import("undici");
|
|
3521
|
+
return new FormData();
|
|
3522
|
+
}
|
|
3523
|
+
async function prepareUploadPayload(targetPath, fileStat, initialForm) {
|
|
3524
|
+
const form = initialForm ?? await createUploadForm();
|
|
3400
3525
|
if (fileStat.isDirectory()) {
|
|
3401
3526
|
let files;
|
|
3402
3527
|
try {
|
|
@@ -3406,16 +3531,16 @@ async function prepareUploadPayload(targetPath, fileStat, initialForm = new Form
|
|
|
3406
3531
|
throw error;
|
|
3407
3532
|
}
|
|
3408
3533
|
if (files.length === 0) return { error: validationError("Directory has no shareable files.", "Add index.html or index.md and retry.") };
|
|
3409
|
-
for (const file of files)
|
|
3534
|
+
for (const file of files) form.append("file", await blobFor(file.path), file.relativePath);
|
|
3410
3535
|
return { payload: {
|
|
3411
|
-
form
|
|
3536
|
+
form,
|
|
3412
3537
|
kind: "static_site"
|
|
3413
3538
|
} };
|
|
3414
3539
|
}
|
|
3415
3540
|
if (fileStat.isFile()) {
|
|
3416
|
-
|
|
3541
|
+
form.append("file", await blobFor(targetPath), basename(targetPath));
|
|
3417
3542
|
return { payload: {
|
|
3418
|
-
form
|
|
3543
|
+
form,
|
|
3419
3544
|
kind: artifactKindForFile(targetPath)
|
|
3420
3545
|
} };
|
|
3421
3546
|
}
|
|
@@ -3571,11 +3696,10 @@ async function runDownload(parsed, mode, isRetry = false) {
|
|
|
3571
3696
|
const request = await requestConfig(parsed.options);
|
|
3572
3697
|
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
3573
3698
|
const baseUrl = baseUrlOf(parsed.options);
|
|
3574
|
-
const
|
|
3575
|
-
const manifestResponse = await fetch(manifestUrl, {
|
|
3699
|
+
const manifestResponse = await cliFetch(apiUrl(`/api/cli/artifacts/${encodeURIComponent(artifactId)}/download`, baseUrl), {
|
|
3576
3700
|
headers: { Authorization: `Bearer ${credential.token}` },
|
|
3577
3701
|
...request.init
|
|
3578
|
-
})
|
|
3702
|
+
});
|
|
3579
3703
|
if ("networkError" in manifestResponse) return writeFailure(command, networkError(manifestResponse.networkError), mode, 1);
|
|
3580
3704
|
const body = await readJson(manifestResponse);
|
|
3581
3705
|
if (!manifestResponse.ok) return handleAuthenticatedCredentialFailure(command, mapApiError(manifestResponse.status, body, {
|
|
@@ -3593,11 +3717,10 @@ async function runDownload(parsed, mode, isRetry = false) {
|
|
|
3593
3717
|
let backupRoot = null;
|
|
3594
3718
|
try {
|
|
3595
3719
|
for (const file of plan.value.files) {
|
|
3596
|
-
const
|
|
3597
|
-
const fileResponse = await fetch(fileUrl, {
|
|
3720
|
+
const fileResponse = await cliFetch(downloadFileUrl(baseUrl, artifactId, file.path), {
|
|
3598
3721
|
headers: { Authorization: `Bearer ${credential.token}` },
|
|
3599
3722
|
...request.init
|
|
3600
|
-
})
|
|
3723
|
+
});
|
|
3601
3724
|
if ("networkError" in fileResponse) return writeFailure(command, networkError(fileResponse.networkError), mode, 1);
|
|
3602
3725
|
if (!fileResponse.ok) return handleAuthenticatedCredentialFailure(command, mapApiError(fileResponse.status, await readJson(fileResponse), {
|
|
3603
3726
|
authenticated: true,
|
|
@@ -3825,13 +3948,12 @@ async function runInitOnboarding(parsed, mode) {
|
|
|
3825
3948
|
...parsed,
|
|
3826
3949
|
options: {
|
|
3827
3950
|
...parsed.options,
|
|
3828
|
-
tool: "auto"
|
|
3829
|
-
scope: "project"
|
|
3951
|
+
tool: "auto"
|
|
3830
3952
|
}
|
|
3831
3953
|
}, mode, {
|
|
3832
3954
|
command,
|
|
3833
3955
|
autoUpdateUserManaged: true,
|
|
3834
|
-
|
|
3956
|
+
skipBrokenUserSkills: true
|
|
3835
3957
|
});
|
|
3836
3958
|
if (!skills) return;
|
|
3837
3959
|
const project = await resolveProjectConfig();
|
|
@@ -4329,7 +4451,7 @@ async function runShare(parsed, mode, isRetry = false) {
|
|
|
4329
4451
|
}
|
|
4330
4452
|
const destination = resolveDestination(destinationOptions, project.config);
|
|
4331
4453
|
if (destination.error) return writeFailure(command, destination.error, mode, 1);
|
|
4332
|
-
const initialForm =
|
|
4454
|
+
const initialForm = await createUploadForm();
|
|
4333
4455
|
const grantEmails = arrayOption(parsed.options.grantEmail);
|
|
4334
4456
|
const requestedVisibility = parsed.options.visibility ?? (destination.containerId && grantEmails.length === 0 ? "project" : "private");
|
|
4335
4457
|
initialForm.set("visibility", requestedVisibility);
|
|
@@ -4343,12 +4465,12 @@ async function runShare(parsed, mode, isRetry = false) {
|
|
|
4343
4465
|
uploadUrl.searchParams.set("artifact_kind", "static_site");
|
|
4344
4466
|
if (destination.containerId) uploadUrl.searchParams.set("container_id", destination.containerId);
|
|
4345
4467
|
}
|
|
4346
|
-
const response = await
|
|
4468
|
+
const response = await cliFetch(uploadUrl, {
|
|
4347
4469
|
method: "POST",
|
|
4348
4470
|
headers: { Authorization: `Bearer ${credential.token}` },
|
|
4349
4471
|
body: upload.payload.form,
|
|
4350
4472
|
...request.init
|
|
4351
|
-
})
|
|
4473
|
+
});
|
|
4352
4474
|
if ("networkError" in response) return writeFailure(command, networkError(response.networkError), mode, 1);
|
|
4353
4475
|
const body = await readJson(response);
|
|
4354
4476
|
if (!response.ok) return handleAuthenticatedCredentialFailure(command, mapApiError(response.status, body, {
|
|
@@ -4438,10 +4560,10 @@ async function runResolve(parsed, mode) {
|
|
|
4438
4560
|
const url = apiUrl("/api/cli/resolve", baseUrlOf(parsed.options));
|
|
4439
4561
|
url.searchParams.set("q", value);
|
|
4440
4562
|
const result = await runAuthenticatedApi(credential, parsed.options, async (current) => {
|
|
4441
|
-
const response = await
|
|
4563
|
+
const response = await cliFetch(url, {
|
|
4442
4564
|
headers: { Authorization: `Bearer ${current.token}` },
|
|
4443
4565
|
...request.init
|
|
4444
|
-
})
|
|
4566
|
+
});
|
|
4445
4567
|
if ("networkError" in response) return { error: networkError(response.networkError) };
|
|
4446
4568
|
const body = await readJson(response);
|
|
4447
4569
|
if (!response.ok) return { error: mapApiError(response.status, body, {
|
|
@@ -4481,12 +4603,12 @@ async function runUpdate(parsed, mode, isRetry = false) {
|
|
|
4481
4603
|
if (upload.error) return writeFailure(command, upload.error, mode, 1);
|
|
4482
4604
|
const updateUrl = apiUrl(`/api/shareables/${encodeURIComponent(artifactId)}/versions`, baseUrl);
|
|
4483
4605
|
if (upload.payload.kind === "static_site") updateUrl.searchParams.set("artifact_kind", "static_site");
|
|
4484
|
-
const response = await
|
|
4606
|
+
const response = await cliFetch(updateUrl, {
|
|
4485
4607
|
method: "POST",
|
|
4486
4608
|
headers: { Authorization: `Bearer ${credential.token}` },
|
|
4487
4609
|
body: upload.payload.form,
|
|
4488
4610
|
...request.init
|
|
4489
|
-
})
|
|
4611
|
+
});
|
|
4490
4612
|
if ("networkError" in response) return writeFailure(command, networkError(response.networkError), mode, 1);
|
|
4491
4613
|
const body = await readJson(response);
|
|
4492
4614
|
if (!response.ok) return handleAuthenticatedCredentialFailure(command, mapApiError(response.status, body, {
|
|
@@ -4672,6 +4794,10 @@ async function doctorRunner(ctx) {
|
|
|
4672
4794
|
const parsed = parsedArgsFromContext("doctor", ctx);
|
|
4673
4795
|
return await runDoctor(parsed, outputMode(parsed.options));
|
|
4674
4796
|
}
|
|
4797
|
+
async function changelogRunner(ctx) {
|
|
4798
|
+
const parsed = parsedArgsFromContext("changelog", ctx);
|
|
4799
|
+
return await runChangelog(parsed, outputMode(parsed.options));
|
|
4800
|
+
}
|
|
4675
4801
|
async function runWithSkillAutoUpdate(parsed, runner) {
|
|
4676
4802
|
const mode = outputMode(parsed.options);
|
|
4677
4803
|
if (!mode.json) {
|
|
@@ -4751,15 +4877,6 @@ async function main(rawArgv) {
|
|
|
4751
4877
|
});
|
|
4752
4878
|
if (usage) writeText(usage);
|
|
4753
4879
|
}
|
|
4754
|
-
async function loadCliVersion() {
|
|
4755
|
-
try {
|
|
4756
|
-
const content = await readFile(new URL("../package.json", import.meta.url), "utf8");
|
|
4757
|
-
const pkg = JSON.parse(content);
|
|
4758
|
-
return typeof pkg.version === "string" ? pkg.version : "0.0.0";
|
|
4759
|
-
} catch {
|
|
4760
|
-
return "0.0.0";
|
|
4761
|
-
}
|
|
4762
|
-
}
|
|
4763
4880
|
async function runGunshi(argv) {
|
|
4764
4881
|
return cli(argv, entryCommand, {
|
|
4765
4882
|
name: "artifactshare",
|
|
@@ -4781,6 +4898,7 @@ async function runGunshi(argv) {
|
|
|
4781
4898
|
"request-access": lazyCommand(requestAccessDefinition, requestAccessRunner),
|
|
4782
4899
|
whoami: lazyCommand(whoamiDefinition, whoamiRunner),
|
|
4783
4900
|
doctor: lazyCommand(doctorDefinition, doctorRunner),
|
|
4901
|
+
changelog: lazyCommand(changelogDefinition, changelogRunner),
|
|
4784
4902
|
profiles: profilesDefinition,
|
|
4785
4903
|
projects: projectsDefinition,
|
|
4786
4904
|
skills: skillsDefinition,
|
|
@@ -5145,8 +5263,12 @@ const openDefinition = define({
|
|
|
5145
5263
|
npx --yes @artifactshare/cli open abc123def4 --json
|
|
5146
5264
|
|
|
5147
5265
|
Use this as the first command when an agent receives an Artifact Share URL.
|
|
5148
|
-
It installs or updates the
|
|
5149
|
-
|
|
5266
|
+
It installs or updates the bundled Artifact Share skill in user scope (Claude Code,
|
|
5267
|
+
Codex, or Cursor detected from the working directory; all three if none are
|
|
5268
|
+
detected), then reads single-file artifacts. Cursor project scope is not
|
|
5269
|
+
auto-installed; use skills install --tool cursor --scope project. Existing
|
|
5270
|
+
project-scope skills are not modified. For static sites or multi-file artifacts,
|
|
5271
|
+
the JSON includes a download next_command.
|
|
5150
5272
|
|
|
5151
5273
|
Common failures:
|
|
5152
5274
|
auth_required Set ARTIFACTSHARE_TOKEN before open
|
|
@@ -5664,7 +5786,7 @@ const skillsToolArgs = {
|
|
|
5664
5786
|
scope: {
|
|
5665
5787
|
type: "string",
|
|
5666
5788
|
toKebab: true,
|
|
5667
|
-
description: "Install scope: project (default
|
|
5789
|
+
description: "Install scope: project or user (default: project for install; user for ensure --tool auto)"
|
|
5668
5790
|
},
|
|
5669
5791
|
dryRun: {
|
|
5670
5792
|
type: "boolean",
|
|
@@ -5739,15 +5861,17 @@ const skillsEnsureDefinition = define({
|
|
|
5739
5861
|
description: "Show planned file changes without writing"
|
|
5740
5862
|
}
|
|
5741
5863
|
},
|
|
5742
|
-
examples: `npx --yes @artifactshare/cli skills ensure --tool auto --
|
|
5864
|
+
examples: `npx --yes @artifactshare/cli skills ensure --tool auto --json
|
|
5865
|
+
npx --yes @artifactshare/cli skills ensure --tool auto --scope user --json
|
|
5743
5866
|
npx --yes @artifactshare/cli skills ensure --tool claude --json
|
|
5744
5867
|
|
|
5745
|
-
Use --tool auto from an agent workspace. It detects .claude, .agents
|
|
5746
|
-
|
|
5747
|
-
|
|
5868
|
+
Use --tool auto from an agent workspace. It detects .claude, .codex/.agents, or
|
|
5869
|
+
.cursor in the current directory and installs or updates the matching user-scope
|
|
5870
|
+
skills. If none are present, it prepares user-scope Codex, Claude Code, and Cursor
|
|
5871
|
+
skills. Cursor project scope needs skills install --tool cursor --scope project.
|
|
5748
5872
|
|
|
5749
5873
|
Common failures:
|
|
5750
|
-
validation_failed Pass --tool auto|codex|claude|cursor; auto supports --scope
|
|
5874
|
+
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
|
|
5751
5875
|
skill_update_conflict An unmanaged or broken skill file exists; inspect it before overwriting`
|
|
5752
5876
|
});
|
|
5753
5877
|
const skillsRemoveDefinition = define({
|
|
@@ -5801,8 +5925,12 @@ const initDefinition = define({
|
|
|
5801
5925
|
npx --yes @artifactshare/cli init --dry-run --json
|
|
5802
5926
|
npx --yes @artifactshare/cli init --profile client-a --project-id <id> --json
|
|
5803
5927
|
|
|
5804
|
-
Without flags, init detects
|
|
5805
|
-
bundled skill, and shows the next steps (sign
|
|
5928
|
+
Without flags, init detects Claude Code, Codex, or Cursor in the working directory,
|
|
5929
|
+
installs or updates the bundled skill in user scope, and shows the next steps (sign
|
|
5930
|
+
in, then share). With no agent detected, it prepares user-scope Codex, Claude Code,
|
|
5931
|
+
and Cursor skills. Cursor project scope is not auto-installed; use skills install
|
|
5932
|
+
--tool cursor --scope project. Existing project-scope skills are not modified.
|
|
5933
|
+
data.mode is "onboarding".
|
|
5806
5934
|
With --profile or --project-id, init saves working-directory defaults to
|
|
5807
5935
|
.artifactshare/config.local.json instead (data.mode is "config"); secrets are never written there.
|
|
5808
5936
|
|
|
@@ -5843,6 +5971,12 @@ const doctorDefinition = define({
|
|
|
5843
5971
|
toKebab: true,
|
|
5844
5972
|
args: commonArgs
|
|
5845
5973
|
});
|
|
5974
|
+
const changelogDefinition = define({
|
|
5975
|
+
name: "changelog",
|
|
5976
|
+
description: "Show the installed CLI version, recent changes, and the public updates page.",
|
|
5977
|
+
toKebab: true,
|
|
5978
|
+
args: { json: commonArgs.json }
|
|
5979
|
+
});
|
|
5846
5980
|
const cliArgv = process.argv.slice(2);
|
|
5847
5981
|
main(cliArgv).catch((error) => {
|
|
5848
5982
|
writeFailure("unknown", unexpectedError(error), outputModeFromArgv(cliArgv), 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artifactshare/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
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",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"dist",
|
|
26
26
|
"skills",
|
|
27
27
|
"README.md",
|
|
28
|
+
"CHANGELOG.md",
|
|
28
29
|
"LICENSE"
|
|
29
30
|
],
|
|
30
31
|
"publishConfig": {
|
|
@@ -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:
|
|
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`
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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:
|
|
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
|
|
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
|
|
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.
|