@artifactshare/cli 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/dist/index.js +421 -169
- package/package.json +1 -1
- package/skills/artifactshare/SKILL.md +5 -1
- package/skills/artifactshare/artifactshare.mdc +5 -1
package/README.md
CHANGED
|
@@ -9,19 +9,21 @@ Artifact Share hosts AI-built reports, documents, and static sites so you can sh
|
|
|
9
9
|
Requires Node.js 22 or later.
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npx @artifactshare/cli publish ./report.html
|
|
12
|
+
npx --yes @artifactshare/cli publish ./report.html
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
`--yes` lets agents and CI fetch the package without stopping for an npx install prompt.
|
|
16
|
+
|
|
15
17
|
On the first run in an interactive terminal, the CLI prints a sign-in link — open it in your browser, and the publish completes and prints the share URL. Folders work too:
|
|
16
18
|
|
|
17
19
|
```sh
|
|
18
|
-
npx @artifactshare/cli publish ./dist --project "Weekly Reports"
|
|
19
|
-
npx @artifactshare/cli update <share-url> ./dist
|
|
20
|
+
npx --yes @artifactshare/cli publish ./dist --project "Weekly Reports"
|
|
21
|
+
npx --yes @artifactshare/cli update <share-url> ./dist
|
|
20
22
|
```
|
|
21
23
|
|
|
22
24
|
## Authentication
|
|
23
25
|
|
|
24
|
-
- **Interactive**: run `npx @artifactshare/cli login`, or just run any command — unauthenticated `publish` / `update` / `download` start the sign-in for you (the CLI prints a link and code to open in your browser).
|
|
26
|
+
- **Interactive**: run `npx --yes @artifactshare/cli login`, or just run any command — unauthenticated `publish` / `update` / `download` start the sign-in for you (the CLI prints a link and code to open in your browser).
|
|
25
27
|
- **CI / non-interactive**: set `ARTIFACTSHARE_TOKEN` (or pass `--token`). Without a token, non-interactive runs fail with `error.code: "auth_required"` instead of hanging.
|
|
26
28
|
- Multiple accounts: keep one local profile per account (`profiles list` / `profiles use <name>`), no re-linking required.
|
|
27
29
|
|
|
@@ -48,7 +50,7 @@ npx @artifactshare/cli update <share-url> ./dist
|
|
|
48
50
|
Teach your agent how to use Artifact Share once:
|
|
49
51
|
|
|
50
52
|
```sh
|
|
51
|
-
npx @artifactshare/cli skills install
|
|
53
|
+
npx --yes @artifactshare/cli skills install
|
|
52
54
|
```
|
|
53
55
|
|
|
54
56
|
This installs a skill (for Claude Code, Codex, and Cursor) that covers publishing, updating, and reading comments.
|
|
@@ -56,7 +58,7 @@ This installs a skill (for Claude Code, Codex, and Cursor) that covers publishin
|
|
|
56
58
|
All commands emit stable JSON when run non-interactively, piped, or with `--json`: success on stdout as `{ "schema_version": 1, "ok": true, "command": ..., "data": ... }`, failures on stderr as `{ "schema_version": 1, "ok": false, "command": ..., "error": ... }` with exit code 1. The `error` object carries a machine-readable `code`, a `hint`, and a structured `recovery` field (for example `{ "kind": "run_command", ... }`), so agents and scripts can branch and recover without parsing prose.
|
|
57
59
|
|
|
58
60
|
```sh
|
|
59
|
-
npx @artifactshare/cli publish ./dist --json
|
|
61
|
+
npx --yes @artifactshare/cli publish ./dist --json
|
|
60
62
|
```
|
|
61
63
|
|
|
62
64
|
## Links
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { chmod, lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
|
|
2
|
+
import { appendFile, chmod, lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
|
|
3
3
|
import { cli, define, lazy } from "gunshi";
|
|
4
|
-
import { Agent } from "undici";
|
|
5
4
|
import { spawn } from "node:child_process";
|
|
6
5
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
7
6
|
import { createReadStream } from "node:fs";
|
|
@@ -9,6 +8,7 @@ import { createHash } from "node:crypto";
|
|
|
9
8
|
import { setTimeout } from "node:timers/promises";
|
|
10
9
|
import { homedir } from "node:os";
|
|
11
10
|
const DEVICE_CLIENT_ID = "artifactshare-cli";
|
|
11
|
+
const CLI_INVOCATION = "npx --yes @artifactshare/cli";
|
|
12
12
|
const IGNORED_FILENAMES = new Set([
|
|
13
13
|
".DS_Store",
|
|
14
14
|
"Thumbs.db",
|
|
@@ -88,8 +88,8 @@ const UPDATE_OPTION_KEYS = new Set([
|
|
|
88
88
|
]);
|
|
89
89
|
//#endregion
|
|
90
90
|
//#region src/errors.ts
|
|
91
|
-
const REQUEST_ACCESS_COMMAND$1 =
|
|
92
|
-
const PROJECTS_LIST_COMMAND =
|
|
91
|
+
const REQUEST_ACCESS_COMMAND$1 = `${CLI_INVOCATION} request-access --json`;
|
|
92
|
+
const PROJECTS_LIST_COMMAND = `${CLI_INVOCATION} projects list --json`;
|
|
93
93
|
function apiError(body) {
|
|
94
94
|
const error = body?.error;
|
|
95
95
|
if (typeof error === "string") return {
|
|
@@ -103,7 +103,7 @@ function apiError(body) {
|
|
|
103
103
|
}
|
|
104
104
|
function mapApiError(status, body, options = {}) {
|
|
105
105
|
const { code: apiCode, message: apiMessage } = apiError(body);
|
|
106
|
-
if (status === 401) return options.authenticated ? tokenInvalidError() : authRequiredError();
|
|
106
|
+
if (status === 401) return options.authenticated ? tokenInvalidError() : authRequiredError(options.baseUrl ?? "https://artifactshare.com");
|
|
107
107
|
if (apiCode === "upload-not-allowed") return cliError({
|
|
108
108
|
code: "upload_not_allowed",
|
|
109
109
|
message: "This account cannot publish yet.",
|
|
@@ -178,7 +178,7 @@ function mapApiError(status, body, options = {}) {
|
|
|
178
178
|
code: "thread_not_found",
|
|
179
179
|
message: apiMessage ?? "Comment thread was not found.",
|
|
180
180
|
why: "No comment thread with that ID exists on this artifact.",
|
|
181
|
-
hint:
|
|
181
|
+
hint: `Run ${CLI_INVOCATION} comments list <artifact-id> --json and retry with a listed thread id.`,
|
|
182
182
|
agentRecoverable: true,
|
|
183
183
|
requiresHuman: false,
|
|
184
184
|
recovery: { kind: "change_input" }
|
|
@@ -205,7 +205,7 @@ function mapApiError(status, body, options = {}) {
|
|
|
205
205
|
code: "quote_not_found",
|
|
206
206
|
message: apiMessage ?? "The quoted text was not found in the artifact.",
|
|
207
207
|
why: "The --quote value must match the artifact text exactly.",
|
|
208
|
-
hint:
|
|
208
|
+
hint: `Copy the exact text from ${CLI_INVOCATION} artifacts get <artifact-id>, or add --quote-before / --quote-after to pick the right occurrence.`,
|
|
209
209
|
agentRecoverable: true,
|
|
210
210
|
requiresHuman: false,
|
|
211
211
|
recovery: { kind: "change_input" }
|
|
@@ -338,12 +338,15 @@ function serviceError(message) {
|
|
|
338
338
|
recovery: { kind: "retry_later" }
|
|
339
339
|
});
|
|
340
340
|
}
|
|
341
|
-
function
|
|
341
|
+
function tokensUrl(baseUrl) {
|
|
342
|
+
return `${baseUrl.replace(/\/$/, "")}/settings/tokens`;
|
|
343
|
+
}
|
|
344
|
+
function authRequiredError(baseUrl) {
|
|
342
345
|
return cliError({
|
|
343
346
|
code: "auth_required",
|
|
344
347
|
message: "Login is required.",
|
|
345
348
|
why: "No ARTIFACTSHARE_TOKEN or --token value was provided.",
|
|
346
|
-
hint:
|
|
349
|
+
hint: `Run ${CLI_INVOCATION} login --profile default, or set ARTIFACTSHARE_TOKEN. You can issue a token at ${tokensUrl(baseUrl)}.`,
|
|
347
350
|
agentRecoverable: false,
|
|
348
351
|
requiresHuman: true,
|
|
349
352
|
recovery: { kind: "ask_human" }
|
|
@@ -365,13 +368,13 @@ function authDeniedError(profile) {
|
|
|
365
368
|
code: "auth_denied",
|
|
366
369
|
message: "Login was denied.",
|
|
367
370
|
why: "The device login request was denied in the browser.",
|
|
368
|
-
hint: `Run
|
|
371
|
+
hint: `Run ${CLI_INVOCATION} login --profile ${profile} again if you want to sign in.`,
|
|
369
372
|
agentRecoverable: false,
|
|
370
373
|
requiresHuman: true,
|
|
371
374
|
recovery: { kind: "ask_human" },
|
|
372
375
|
details: {
|
|
373
376
|
profile,
|
|
374
|
-
suggested_command:
|
|
377
|
+
suggested_command: `${CLI_INVOCATION} login --profile ${profile}`
|
|
375
378
|
}
|
|
376
379
|
});
|
|
377
380
|
}
|
|
@@ -380,13 +383,13 @@ function authExpiredError(profile) {
|
|
|
380
383
|
code: "auth_expired",
|
|
381
384
|
message: "Login expired.",
|
|
382
385
|
why: "The device login was not completed before the code expired.",
|
|
383
|
-
hint: `Run
|
|
386
|
+
hint: `Run ${CLI_INVOCATION} login --profile ${profile} again.`,
|
|
384
387
|
agentRecoverable: false,
|
|
385
388
|
requiresHuman: true,
|
|
386
389
|
recovery: { kind: "ask_human" },
|
|
387
390
|
details: {
|
|
388
391
|
profile,
|
|
389
|
-
suggested_command:
|
|
392
|
+
suggested_command: `${CLI_INVOCATION} login --profile ${profile}`
|
|
390
393
|
}
|
|
391
394
|
});
|
|
392
395
|
}
|
|
@@ -411,7 +414,7 @@ function profileNotFoundError(profile) {
|
|
|
411
414
|
code: "profile_not_found",
|
|
412
415
|
message: `Profile "${profile}" was not found.`,
|
|
413
416
|
why: "No saved CLI profile has that name.",
|
|
414
|
-
hint: `Run
|
|
417
|
+
hint: `Run ${CLI_INVOCATION} profiles list to see saved profiles, or ${CLI_INVOCATION} login --profile ${profile} to create it.`,
|
|
415
418
|
agentRecoverable: true,
|
|
416
419
|
requiresHuman: false,
|
|
417
420
|
recovery: { kind: "change_input" },
|
|
@@ -447,12 +450,12 @@ function unknownCommandError(command) {
|
|
|
447
450
|
code: "unknown_command",
|
|
448
451
|
message: `Unknown command: ${command}`,
|
|
449
452
|
why: "The command is not part of Artifact Share CLI.",
|
|
450
|
-
hint:
|
|
453
|
+
hint: `Run ${CLI_INVOCATION} --help.`,
|
|
451
454
|
agentRecoverable: true,
|
|
452
455
|
requiresHuman: false,
|
|
453
456
|
recovery: {
|
|
454
457
|
kind: "run_command",
|
|
455
|
-
command:
|
|
458
|
+
command: `${CLI_INVOCATION} --help`
|
|
456
459
|
}
|
|
457
460
|
});
|
|
458
461
|
}
|
|
@@ -855,11 +858,12 @@ let insecureLocalhostDispatcher;
|
|
|
855
858
|
function baseUrlOf(options) {
|
|
856
859
|
return String(options.baseUrl ?? process.env.ARTIFACTSHARE_BASE_URL ?? "https://artifactshare.com").replace(/\/$/, "");
|
|
857
860
|
}
|
|
858
|
-
function requestConfig(options) {
|
|
861
|
+
async function requestConfig(options) {
|
|
859
862
|
if (!insecureLocalhostEnabled(options)) return { init: {} };
|
|
860
863
|
const baseUrl = baseUrlOf(options);
|
|
861
864
|
const url = new URL(baseUrl);
|
|
862
865
|
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].") };
|
|
866
|
+
const { Agent } = await import("undici");
|
|
863
867
|
return { init: { dispatcher: insecureLocalhostDispatcher ??= new Agent({ connect: { rejectUnauthorized: false } }) } };
|
|
864
868
|
}
|
|
865
869
|
function insecureLocalhostEnabled(options) {
|
|
@@ -969,21 +973,60 @@ function resolveDestination(options, config) {
|
|
|
969
973
|
code: "destination_required",
|
|
970
974
|
message: "A publish destination is required.",
|
|
971
975
|
why: "Non-interactive publish never guesses a project or home destination.",
|
|
972
|
-
hint: "Retry with --project-id <id>, configure .artifactshare/config.json, or pass --home.",
|
|
976
|
+
hint: "Retry with --project-id <id>, configure .artifactshare/config.local.json, or pass --home.",
|
|
973
977
|
agentRecoverable: true,
|
|
974
978
|
requiresHuman: false,
|
|
975
979
|
recovery: { kind: "change_input" }
|
|
976
980
|
}) };
|
|
977
981
|
}
|
|
978
982
|
const PROJECT_CONFIG_PATH = ".artifactshare/config.json";
|
|
979
|
-
|
|
980
|
-
|
|
983
|
+
const PROJECT_CONFIG_LOCAL_PATH = ".artifactshare/config.local.json";
|
|
984
|
+
function projectConfigLocalPath(cwd = process.cwd()) {
|
|
985
|
+
return resolve(cwd, PROJECT_CONFIG_LOCAL_PATH);
|
|
986
|
+
}
|
|
987
|
+
function relativeProjectConfigPath(cwd, directory, filename) {
|
|
988
|
+
const absolute = join(directory, filename);
|
|
989
|
+
const rel = relative(cwd, absolute);
|
|
990
|
+
return rel.startsWith("..") ? absolute : rel;
|
|
991
|
+
}
|
|
992
|
+
async function resolveProjectConfig(cwd = process.cwd()) {
|
|
993
|
+
let current = resolve(cwd);
|
|
994
|
+
const root = resolve(current, "/");
|
|
995
|
+
while (true) {
|
|
996
|
+
const localPath = join(current, PROJECT_CONFIG_LOCAL_PATH);
|
|
997
|
+
const sharedPath = join(current, PROJECT_CONFIG_PATH);
|
|
998
|
+
const localRaw = await readJsonFile(localPath);
|
|
999
|
+
if (localRaw !== null) return {
|
|
1000
|
+
config: localRaw,
|
|
1001
|
+
raw: localRaw,
|
|
1002
|
+
kind: "local",
|
|
1003
|
+
path: relativeProjectConfigPath(cwd, current, PROJECT_CONFIG_LOCAL_PATH),
|
|
1004
|
+
directory: current
|
|
1005
|
+
};
|
|
1006
|
+
const sharedRaw = await readJsonFile(sharedPath);
|
|
1007
|
+
if (sharedRaw !== null) return {
|
|
1008
|
+
config: sharedRaw,
|
|
1009
|
+
raw: sharedRaw,
|
|
1010
|
+
kind: "shared",
|
|
1011
|
+
path: relativeProjectConfigPath(cwd, current, PROJECT_CONFIG_PATH),
|
|
1012
|
+
directory: current
|
|
1013
|
+
};
|
|
1014
|
+
if (current === root) break;
|
|
1015
|
+
current = dirname(current);
|
|
1016
|
+
}
|
|
1017
|
+
return {
|
|
1018
|
+
config: null,
|
|
1019
|
+
raw: null,
|
|
1020
|
+
kind: null,
|
|
1021
|
+
path: null,
|
|
1022
|
+
directory: null
|
|
1023
|
+
};
|
|
981
1024
|
}
|
|
982
|
-
async function
|
|
983
|
-
return await readJsonFile(
|
|
1025
|
+
async function readProjectConfigAtDirectory(directory, kind) {
|
|
1026
|
+
return await readJsonFile(join(directory, kind === "local" ? PROJECT_CONFIG_LOCAL_PATH : PROJECT_CONFIG_PATH));
|
|
984
1027
|
}
|
|
985
|
-
async function
|
|
986
|
-
return await readJsonFile(
|
|
1028
|
+
async function readRawLocalProjectConfig(cwd = process.cwd()) {
|
|
1029
|
+
return await readJsonFile(projectConfigLocalPath(cwd));
|
|
987
1030
|
}
|
|
988
1031
|
function configString(value) {
|
|
989
1032
|
return nonEmpty(typeof value === "string" ? value : void 0) ?? null;
|
|
@@ -1168,7 +1211,7 @@ function configHome() {
|
|
|
1168
1211
|
}
|
|
1169
1212
|
//#endregion
|
|
1170
1213
|
//#region src/credentials.ts
|
|
1171
|
-
async function resolveCredential(options,
|
|
1214
|
+
async function resolveCredential(options, projectInput = null) {
|
|
1172
1215
|
const envToken = nonEmpty(process.env.ARTIFACTSHARE_TOKEN);
|
|
1173
1216
|
const optionToken = nonEmpty(options.token);
|
|
1174
1217
|
const profile = nonEmpty(options.profile);
|
|
@@ -1189,18 +1232,36 @@ async function resolveCredential(options, projectConfig = null) {
|
|
|
1189
1232
|
token: envToken
|
|
1190
1233
|
};
|
|
1191
1234
|
const globalConfig = await readGlobalConfig();
|
|
1192
|
-
if (profile) return await resolveProfileCredential("profile", profile, options, globalConfig);
|
|
1193
|
-
const
|
|
1194
|
-
|
|
1235
|
+
if (profile) return await resolveProfileCredential("profile", profile, options, globalConfig, null, null);
|
|
1236
|
+
const project = normalizeProjectInput(projectInput);
|
|
1237
|
+
const projectProfile = nonEmpty(project.config?.default_profile);
|
|
1238
|
+
if (projectProfile) return await resolveProfileCredential(project.kind === "local" ? "local_config" : "project_config", projectProfile, options, globalConfig, project.path, project.kind);
|
|
1195
1239
|
const globalProfile = nonEmpty(globalConfig?.default_profile);
|
|
1196
|
-
if (globalProfile) return await resolveProfileCredential("global_profile", globalProfile, options, globalConfig);
|
|
1240
|
+
if (globalProfile) return await resolveProfileCredential("global_profile", globalProfile, options, globalConfig, null, null);
|
|
1197
1241
|
return {
|
|
1198
1242
|
ok: false,
|
|
1199
1243
|
source: "none",
|
|
1200
|
-
error: authRequiredError()
|
|
1244
|
+
error: authRequiredError(baseUrlOf(options))
|
|
1201
1245
|
};
|
|
1202
1246
|
}
|
|
1203
|
-
|
|
1247
|
+
function normalizeProjectInput(projectInput) {
|
|
1248
|
+
if (!projectInput) return {
|
|
1249
|
+
config: null,
|
|
1250
|
+
raw: null,
|
|
1251
|
+
kind: null,
|
|
1252
|
+
path: null,
|
|
1253
|
+
directory: null
|
|
1254
|
+
};
|
|
1255
|
+
if ("kind" in projectInput) return projectInput;
|
|
1256
|
+
return {
|
|
1257
|
+
config: projectInput,
|
|
1258
|
+
raw: projectInput,
|
|
1259
|
+
kind: "shared",
|
|
1260
|
+
path: null,
|
|
1261
|
+
directory: null
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
async function resolveProfileCredential(source, profile, options, globalConfig, configPath, configKind) {
|
|
1204
1265
|
const profileBaseUrl = nonEmpty(globalConfig?.profiles?.[profile]?.base_url);
|
|
1205
1266
|
if (profileBaseUrl && !nonEmpty(options.baseUrl) && !nonEmpty(process.env.ARTIFACTSHARE_BASE_URL)) options.baseUrl = profileBaseUrl;
|
|
1206
1267
|
const stored = await readProfileToken(profile, options);
|
|
@@ -1210,11 +1271,46 @@ async function resolveProfileCredential(source, profile, options, globalConfig)
|
|
|
1210
1271
|
profile,
|
|
1211
1272
|
token: stored.token
|
|
1212
1273
|
};
|
|
1213
|
-
return profileAuthRequired(source, profile, stored.reason);
|
|
1274
|
+
return profileAuthRequired(source, profile, stored.reason, options, globalConfig, configPath, configKind);
|
|
1214
1275
|
}
|
|
1215
|
-
function profileAuthRequired(source, profile, reason) {
|
|
1216
|
-
const
|
|
1276
|
+
async function profileAuthRequired(source, profile, reason, options, globalConfig, configPath, configKind) {
|
|
1277
|
+
const baseUrl = baseUrlOf(options);
|
|
1278
|
+
const url = tokensUrl(baseUrl);
|
|
1279
|
+
const error = authRequiredError(baseUrl);
|
|
1217
1280
|
const why = reason === "unavailable" ? `No safe token store is available for profile "${profile}".` : `No saved credential was found for profile "${profile}".`;
|
|
1281
|
+
const alternative = await findAlternativeProfileWithToken(globalConfig, options, profile);
|
|
1282
|
+
const details = {
|
|
1283
|
+
credential_source: source,
|
|
1284
|
+
profile
|
|
1285
|
+
};
|
|
1286
|
+
if (configPath) {
|
|
1287
|
+
details.config_path = configPath;
|
|
1288
|
+
if (configKind) details.config_kind = configKind;
|
|
1289
|
+
}
|
|
1290
|
+
if (alternative) {
|
|
1291
|
+
const switchHint = profileSwitchHint(alternative);
|
|
1292
|
+
return {
|
|
1293
|
+
ok: false,
|
|
1294
|
+
source,
|
|
1295
|
+
profile,
|
|
1296
|
+
error: {
|
|
1297
|
+
...error,
|
|
1298
|
+
why,
|
|
1299
|
+
hint: `${switchHint} Or run ${CLI_INVOCATION} login --profile ${profile}, or set ARTIFACTSHARE_TOKEN. You can issue a token at ${url}.`,
|
|
1300
|
+
agent_recoverable: true,
|
|
1301
|
+
requires_human: false,
|
|
1302
|
+
recovery: {
|
|
1303
|
+
kind: "run_command",
|
|
1304
|
+
command: `${CLI_INVOCATION} profiles use ${alternative}`
|
|
1305
|
+
},
|
|
1306
|
+
details: {
|
|
1307
|
+
...details,
|
|
1308
|
+
alternative_profile: alternative,
|
|
1309
|
+
suggested_profile_command: `${CLI_INVOCATION} profiles use ${alternative}`
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1218
1314
|
return {
|
|
1219
1315
|
ok: false,
|
|
1220
1316
|
source,
|
|
@@ -1222,14 +1318,66 @@ function profileAuthRequired(source, profile, reason) {
|
|
|
1222
1318
|
error: {
|
|
1223
1319
|
...error,
|
|
1224
1320
|
why,
|
|
1225
|
-
hint: `Run
|
|
1226
|
-
details
|
|
1227
|
-
credential_source: source,
|
|
1228
|
-
profile
|
|
1229
|
-
}
|
|
1321
|
+
hint: `Run ${CLI_INVOCATION} login --profile ${profile}, or set ARTIFACTSHARE_TOKEN. You can issue a token at ${url}.`,
|
|
1322
|
+
details
|
|
1230
1323
|
}
|
|
1231
1324
|
};
|
|
1232
1325
|
}
|
|
1326
|
+
function profileSwitchHint(profile) {
|
|
1327
|
+
return `Run with --profile ${profile}, init --profile ${profile}, or profiles use ${profile}.`;
|
|
1328
|
+
}
|
|
1329
|
+
async function findAlternativeProfileWithToken(globalConfig, options, excludeProfile) {
|
|
1330
|
+
const profiles = globalConfig?.profiles ?? {};
|
|
1331
|
+
const candidates = [];
|
|
1332
|
+
for (const name of Object.keys(profiles)) {
|
|
1333
|
+
if (name === excludeProfile) continue;
|
|
1334
|
+
const baseUrl = nonEmpty(profiles[name]?.base_url) ?? baseUrlOf(options);
|
|
1335
|
+
candidates.push({
|
|
1336
|
+
name,
|
|
1337
|
+
localDev: isLocalDevUrl(baseUrl)
|
|
1338
|
+
});
|
|
1339
|
+
}
|
|
1340
|
+
if (candidates.length === 0) return null;
|
|
1341
|
+
candidates.sort((left, right) => {
|
|
1342
|
+
if (left.localDev !== right.localDev) return left.localDev ? 1 : -1;
|
|
1343
|
+
return left.name.localeCompare(right.name);
|
|
1344
|
+
});
|
|
1345
|
+
for (const candidate of candidates) {
|
|
1346
|
+
const baseUrl = nonEmpty(profiles[candidate.name]?.base_url) ?? baseUrlOf(options);
|
|
1347
|
+
if ((await readProfileToken(candidate.name, {
|
|
1348
|
+
...options,
|
|
1349
|
+
baseUrl
|
|
1350
|
+
})).ok) return candidate.name;
|
|
1351
|
+
}
|
|
1352
|
+
return null;
|
|
1353
|
+
}
|
|
1354
|
+
function isLocalDevUrl(baseUrl) {
|
|
1355
|
+
try {
|
|
1356
|
+
return isLocalHostname(new URL(baseUrl).hostname);
|
|
1357
|
+
} catch {
|
|
1358
|
+
return false;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
async function resolveEffectiveDefaultProfile(projectInput = null) {
|
|
1362
|
+
const project = normalizeProjectInput(projectInput);
|
|
1363
|
+
const projectProfile = nonEmpty(project.config?.default_profile);
|
|
1364
|
+
if (projectProfile) return {
|
|
1365
|
+
profile: projectProfile,
|
|
1366
|
+
source: project.kind === "local" ? "local" : "project",
|
|
1367
|
+
path: project.path
|
|
1368
|
+
};
|
|
1369
|
+
const globalProfile = nonEmpty((await readGlobalConfig())?.default_profile);
|
|
1370
|
+
if (globalProfile) return {
|
|
1371
|
+
profile: globalProfile,
|
|
1372
|
+
source: "global",
|
|
1373
|
+
path: null
|
|
1374
|
+
};
|
|
1375
|
+
return {
|
|
1376
|
+
profile: null,
|
|
1377
|
+
source: "none",
|
|
1378
|
+
path: null
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1233
1381
|
//#endregion
|
|
1234
1382
|
//#region src/command-runners/artifacts-get.ts
|
|
1235
1383
|
async function runArtifactsGet(parsed, mode) {
|
|
@@ -1241,9 +1389,9 @@ async function runArtifactsGet(parsed, mode) {
|
|
|
1241
1389
|
if (offset.error) return writeFailure(command, offset.error, mode, 1);
|
|
1242
1390
|
const include = parseIncludeOptions(parsed.options.include);
|
|
1243
1391
|
if (include.error) return writeFailure(command, include.error, mode, 1);
|
|
1244
|
-
const credential = await resolveCredential(parsed.options, await
|
|
1392
|
+
const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
|
|
1245
1393
|
if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
|
|
1246
|
-
const request = requestConfig(parsed.options);
|
|
1394
|
+
const request = await requestConfig(parsed.options);
|
|
1247
1395
|
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
1248
1396
|
const url = apiUrl(`/api/cli/artifacts/${encodeURIComponent(artifactId)}`, baseUrlOf(parsed.options));
|
|
1249
1397
|
if (offset.value !== void 0) url.searchParams.set("offset", offset.value);
|
|
@@ -1268,9 +1416,9 @@ async function runCommentsList(parsed, mode) {
|
|
|
1268
1416
|
const target = parseArtifactTarget(parsed.positionals[0], command, "Pass an artifact ID or share URL.");
|
|
1269
1417
|
if (target.error) return writeFailure(command, target.error, mode, 1);
|
|
1270
1418
|
const artifactId = target.artifactId;
|
|
1271
|
-
const credential = await resolveCredential(parsed.options, await
|
|
1419
|
+
const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
|
|
1272
1420
|
if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
|
|
1273
|
-
const request = requestConfig(parsed.options);
|
|
1421
|
+
const request = await requestConfig(parsed.options);
|
|
1274
1422
|
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
1275
1423
|
const result = await apiGet(`/api/cli/artifacts/${encodeURIComponent(artifactId)}/comments`, credential.token, parsed.options, request.init, { artifactTarget: true });
|
|
1276
1424
|
if (result.error) return writeFailure(command, result.error, mode, 1);
|
|
@@ -1294,9 +1442,9 @@ async function runCommentsPost(parsed, mode) {
|
|
|
1294
1442
|
const quote = parsed.options.quote;
|
|
1295
1443
|
if (quote !== void 0 && replyTo !== void 0) return writeFailure(command, validationError("Choose either --quote or --reply-to.", "A quote anchors a new thread; a reply joins an existing thread. Remove one and retry."), mode, 1);
|
|
1296
1444
|
if (quote === void 0 && (parsed.options.quoteBefore !== void 0 || parsed.options.quoteAfter !== void 0)) return writeFailure(command, validationError("--quote-before and --quote-after require --quote.", "Add --quote <text>, or remove the context options."), mode, 1);
|
|
1297
|
-
const credential = await resolveCredential(parsed.options, await
|
|
1445
|
+
const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
|
|
1298
1446
|
if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
|
|
1299
|
-
const request = requestConfig(parsed.options);
|
|
1447
|
+
const request = await requestConfig(parsed.options);
|
|
1300
1448
|
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
1301
1449
|
const result = await apiPost(`/api/cli/artifacts/${encodeURIComponent(artifactId)}/comments`, credential.token, {
|
|
1302
1450
|
body,
|
|
@@ -1318,12 +1466,16 @@ async function runCommentsPost(parsed, mode) {
|
|
|
1318
1466
|
}
|
|
1319
1467
|
//#endregion
|
|
1320
1468
|
//#region src/command-runners/doctor.ts
|
|
1321
|
-
const LOGIN_COMMAND =
|
|
1322
|
-
const REQUEST_ACCESS_COMMAND =
|
|
1469
|
+
const LOGIN_COMMAND = `${CLI_INVOCATION} login`;
|
|
1470
|
+
const REQUEST_ACCESS_COMMAND = `${CLI_INVOCATION} request-access`;
|
|
1323
1471
|
function bearerTokenBlocksLogin(data) {
|
|
1324
1472
|
return data.auth.credential_source === "env" || data.auth.credential_source === "token_option";
|
|
1325
1473
|
}
|
|
1326
1474
|
function resolveDoctorNextCommand(data) {
|
|
1475
|
+
if (data.config.local.code === "token_store_unsafe") {
|
|
1476
|
+
if (bearerTokenBlocksLogin(data)) return null;
|
|
1477
|
+
return LOGIN_COMMAND;
|
|
1478
|
+
}
|
|
1327
1479
|
if (data.config.project.code === "token_store_unsafe") {
|
|
1328
1480
|
if (bearerTokenBlocksLogin(data)) return null;
|
|
1329
1481
|
return LOGIN_COMMAND;
|
|
@@ -1344,14 +1496,13 @@ function doctorDataWithNextCommand(data) {
|
|
|
1344
1496
|
}
|
|
1345
1497
|
async function runDoctor(parsed, mode) {
|
|
1346
1498
|
const command = "doctor";
|
|
1347
|
-
const
|
|
1348
|
-
const
|
|
1349
|
-
const
|
|
1350
|
-
const destination = resolveDestination(parsed.options, config);
|
|
1499
|
+
const project = await resolveProjectConfig();
|
|
1500
|
+
const credential = await resolveCredential(parsed.options, project);
|
|
1501
|
+
const destination = resolveDestination(parsed.options, project.config);
|
|
1351
1502
|
const data = {
|
|
1352
1503
|
next_command: null,
|
|
1353
1504
|
base_url: baseUrlOf(parsed.options),
|
|
1354
|
-
config: await configDiagnostics(
|
|
1505
|
+
config: await configDiagnostics(project),
|
|
1355
1506
|
auth: {
|
|
1356
1507
|
credential_source: credential.source,
|
|
1357
1508
|
...credential.profile ? { profile: credential.profile } : {},
|
|
@@ -1379,7 +1530,7 @@ async function runDoctor(parsed, mode) {
|
|
|
1379
1530
|
data.auth.hint = credential.error.hint;
|
|
1380
1531
|
return writeSuccess(command, doctorDataWithNextCommand(data), mode);
|
|
1381
1532
|
}
|
|
1382
|
-
const request = requestConfig(parsed.options);
|
|
1533
|
+
const request = await requestConfig(parsed.options);
|
|
1383
1534
|
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
1384
1535
|
const response = await fetch(apiUrl("/api/cli/doctor", baseUrlOf(parsed.options)), {
|
|
1385
1536
|
headers: { Authorization: `Bearer ${credential.token}` },
|
|
@@ -1412,24 +1563,52 @@ async function runDoctor(parsed, mode) {
|
|
|
1412
1563
|
}
|
|
1413
1564
|
return writeSuccess(command, doctorDataWithNextCommand(data), mode);
|
|
1414
1565
|
}
|
|
1415
|
-
async function configDiagnostics(
|
|
1566
|
+
async function configDiagnostics(project) {
|
|
1416
1567
|
const globalConfig = await readGlobalConfig();
|
|
1417
|
-
const
|
|
1568
|
+
const cwd = process.cwd();
|
|
1569
|
+
const directory = project.directory;
|
|
1570
|
+
const localRaw = directory ? await readProjectConfigAtDirectory(directory, "local") : null;
|
|
1571
|
+
const sharedRaw = directory ? await readProjectConfigAtDirectory(directory, "shared") : null;
|
|
1418
1572
|
return {
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
default_profile: configString(rawProjectConfig?.default_profile),
|
|
1422
|
-
default_project_id: configString(rawProjectConfig?.default_project_id),
|
|
1423
|
-
...unsafeKey ? {
|
|
1424
|
-
code: "token_store_unsafe",
|
|
1425
|
-
hint: `Remove "${unsafeKey}" from ${PROJECT_CONFIG_PATH} and run npx @artifactshare/cli login instead; the working-directory config must never hold secrets.`
|
|
1426
|
-
} : {}
|
|
1427
|
-
},
|
|
1573
|
+
local: fileDiagnostics(localRaw, directory ? relativeProjectConfigPath(cwd, directory, PROJECT_CONFIG_LOCAL_PATH) : null),
|
|
1574
|
+
project: fileDiagnostics(sharedRaw, directory ? relativeProjectConfigPath(cwd, directory, PROJECT_CONFIG_PATH) : null),
|
|
1428
1575
|
global: {
|
|
1429
1576
|
present: globalConfig !== null,
|
|
1430
1577
|
default_profile: configString(globalConfig?.default_profile),
|
|
1431
1578
|
profile_count: Object.keys(globalConfig?.profiles ?? {}).length
|
|
1432
|
-
}
|
|
1579
|
+
},
|
|
1580
|
+
effective: effectiveDiagnostics(project, globalConfig)
|
|
1581
|
+
};
|
|
1582
|
+
}
|
|
1583
|
+
function fileDiagnostics(raw, path) {
|
|
1584
|
+
const unsafeKey = Object.keys(raw ?? {}).find((key) => key.toLowerCase().includes("token"));
|
|
1585
|
+
return {
|
|
1586
|
+
present: raw !== null,
|
|
1587
|
+
path,
|
|
1588
|
+
default_profile: configString(raw?.default_profile),
|
|
1589
|
+
default_project_id: configString(raw?.default_project_id),
|
|
1590
|
+
...unsafeKey ? {
|
|
1591
|
+
code: "token_store_unsafe",
|
|
1592
|
+
hint: `Remove "${unsafeKey}" from ${path ?? "the working-directory config"} and run ${CLI_INVOCATION} login instead; the working-directory config must never hold secrets.`
|
|
1593
|
+
} : {}
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
function effectiveDiagnostics(project, globalConfig) {
|
|
1597
|
+
const projectProfile = configString(project.config?.default_profile);
|
|
1598
|
+
const projectProjectId = configString(project.config?.default_project_id);
|
|
1599
|
+
const globalProfile = configString(globalConfig?.default_profile);
|
|
1600
|
+
const defaultProfile = projectProfile ?? globalProfile;
|
|
1601
|
+
const defaultProfileSource = projectProfile ? project.kind === "local" ? "local" : "project" : globalProfile ? "global" : "none";
|
|
1602
|
+
const defaultProfilePath = defaultProfileSource === "local" || defaultProfileSource === "project" ? project.path : null;
|
|
1603
|
+
const defaultProjectId = projectProjectId;
|
|
1604
|
+
const defaultProjectIdSource = projectProjectId ? project.kind === "local" ? "local" : "project" : "none";
|
|
1605
|
+
return {
|
|
1606
|
+
default_profile: defaultProfile,
|
|
1607
|
+
default_profile_source: defaultProfileSource,
|
|
1608
|
+
default_profile_path: defaultProfilePath,
|
|
1609
|
+
default_project_id: defaultProjectId,
|
|
1610
|
+
default_project_id_source: defaultProjectIdSource,
|
|
1611
|
+
default_project_id_path: defaultProjectIdSource === "local" || defaultProjectIdSource === "project" ? project.path : null
|
|
1433
1612
|
};
|
|
1434
1613
|
}
|
|
1435
1614
|
//#endregion
|
|
@@ -1600,7 +1779,7 @@ function artifactKindForFile(path) {
|
|
|
1600
1779
|
//#endregion
|
|
1601
1780
|
//#region src/command-runners/login.ts
|
|
1602
1781
|
async function performDeviceLogin(profile, options, mode) {
|
|
1603
|
-
const request = requestConfig(options);
|
|
1782
|
+
const request = await requestConfig(options);
|
|
1604
1783
|
if (request.error) return {
|
|
1605
1784
|
ok: false,
|
|
1606
1785
|
error: request.error
|
|
@@ -1651,24 +1830,30 @@ async function performDeviceLogin(profile, options, mode) {
|
|
|
1651
1830
|
error: tokenStoreUnavailableError(profile)
|
|
1652
1831
|
};
|
|
1653
1832
|
await writeProfileConfig(profile, options, saved.store, whoami);
|
|
1833
|
+
const effective = await resolveEffectiveDefaultProfile(await resolveProjectConfig());
|
|
1834
|
+
const data = {
|
|
1835
|
+
profile,
|
|
1836
|
+
status: "completed",
|
|
1837
|
+
credential_source: "profile",
|
|
1838
|
+
token_store: saved.store,
|
|
1839
|
+
user: { email: whoami.email },
|
|
1840
|
+
workspace: {
|
|
1841
|
+
id: whoami.workspace_id,
|
|
1842
|
+
hosted_domain: whoami.hosted_domain
|
|
1843
|
+
},
|
|
1844
|
+
verification_uri: code.verification_uri,
|
|
1845
|
+
verification_uri_complete: code.verification_uri_complete ?? null,
|
|
1846
|
+
user_code: code.user_code,
|
|
1847
|
+
expires_at: sessionExpiresAt,
|
|
1848
|
+
interval_seconds: code.interval
|
|
1849
|
+
};
|
|
1850
|
+
if (effective.profile && effective.profile !== profile) {
|
|
1851
|
+
data.effective_default_profile = effective.profile;
|
|
1852
|
+
data.profile_switch_hint = `Saved credentials for "${profile}", but the current default profile is "${effective.profile}". Run with --profile ${profile}, init --profile ${profile}, or profiles use ${profile} before the next command.`;
|
|
1853
|
+
}
|
|
1654
1854
|
return {
|
|
1655
1855
|
ok: true,
|
|
1656
|
-
data
|
|
1657
|
-
profile,
|
|
1658
|
-
status: "completed",
|
|
1659
|
-
credential_source: "profile",
|
|
1660
|
-
token_store: saved.store,
|
|
1661
|
-
user: { email: whoami.email },
|
|
1662
|
-
workspace: {
|
|
1663
|
-
id: whoami.workspace_id,
|
|
1664
|
-
hosted_domain: whoami.hosted_domain
|
|
1665
|
-
},
|
|
1666
|
-
verification_uri: code.verification_uri,
|
|
1667
|
-
verification_uri_complete: code.verification_uri_complete ?? null,
|
|
1668
|
-
user_code: code.user_code,
|
|
1669
|
-
expires_at: sessionExpiresAt,
|
|
1670
|
-
interval_seconds: code.interval
|
|
1671
|
-
}
|
|
1856
|
+
data
|
|
1672
1857
|
};
|
|
1673
1858
|
}
|
|
1674
1859
|
async function runLogin(parsed, mode) {
|
|
@@ -1688,7 +1873,7 @@ async function requestDeviceCode(options, init) {
|
|
|
1688
1873
|
}).catch((error) => ({ networkError: error }));
|
|
1689
1874
|
if ("networkError" in response) return { error: networkError(response.networkError) };
|
|
1690
1875
|
const body = await readJson(response);
|
|
1691
|
-
if (!response.ok) return { error: mapApiError(response.status, body) };
|
|
1876
|
+
if (!response.ok) return { error: mapApiError(response.status, body, { baseUrl: baseUrlOf(options) }) };
|
|
1692
1877
|
if (!isDeviceCodeResponse(body)) return { error: validationError("Device login response was invalid.", "Retry login. If this repeats, report the response shape.", "service_error") };
|
|
1693
1878
|
return body;
|
|
1694
1879
|
}
|
|
@@ -1723,7 +1908,7 @@ async function pollForToken(options, code, init, profile, deadline) {
|
|
|
1723
1908
|
}
|
|
1724
1909
|
if (authError === "access_denied") return { error: authDeniedError(profile) };
|
|
1725
1910
|
if (authError === "expired_token") return { error: authExpiredError(profile) };
|
|
1726
|
-
return { error: mapApiError(response.status, body) };
|
|
1911
|
+
return { error: mapApiError(response.status, body, { baseUrl: baseUrlOf(options) }) };
|
|
1727
1912
|
}
|
|
1728
1913
|
return { error: authExpiredError(profile) };
|
|
1729
1914
|
}
|
|
@@ -1791,9 +1976,9 @@ async function runDownload(parsed, mode, isRetry = false) {
|
|
|
1791
1976
|
const target = parseArtifactTarget(parsed.positionals[0], "download", "Pass an artifact ID or share URL to download.");
|
|
1792
1977
|
if (target.error) return writeFailure(command, target.error, mode, 1);
|
|
1793
1978
|
const artifactId = target.artifactId;
|
|
1794
|
-
const credential = await resolveCredential(parsed.options, await
|
|
1979
|
+
const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
|
|
1795
1980
|
if (!credential.ok) return handleCredentialFailure(command, credential, parsed.options, mode, () => runDownload(parsed, mode, true), isRetry);
|
|
1796
|
-
const request = requestConfig(parsed.options);
|
|
1981
|
+
const request = await requestConfig(parsed.options);
|
|
1797
1982
|
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
1798
1983
|
const baseUrl = baseUrlOf(parsed.options);
|
|
1799
1984
|
const manifestUrl = apiUrl(`/api/cli/artifacts/${encodeURIComponent(artifactId)}/download`, baseUrl);
|
|
@@ -1864,36 +2049,103 @@ async function runDownload(parsed, mode, isRetry = false) {
|
|
|
1864
2049
|
}, mode);
|
|
1865
2050
|
}
|
|
1866
2051
|
//#endregion
|
|
2052
|
+
//#region src/git-exclude.ts
|
|
2053
|
+
async function ensureGitExclude(cwd) {
|
|
2054
|
+
const git = await findGitDir(cwd);
|
|
2055
|
+
if (!git) return {
|
|
2056
|
+
applied: false,
|
|
2057
|
+
warning: null
|
|
2058
|
+
};
|
|
2059
|
+
const excludePath = join(git.gitDir, "info", "exclude");
|
|
2060
|
+
const excludeEntry = gitPattern(relative(git.workTree, resolve(cwd, PROJECT_CONFIG_LOCAL_PATH)));
|
|
2061
|
+
try {
|
|
2062
|
+
const existing = await readFile(excludePath, "utf8").catch(() => "");
|
|
2063
|
+
if (excludeLines(existing).includes(excludeEntry)) return {
|
|
2064
|
+
applied: false,
|
|
2065
|
+
warning: null
|
|
2066
|
+
};
|
|
2067
|
+
await mkdir(dirname(excludePath), { recursive: true });
|
|
2068
|
+
await appendFile(excludePath, `${existing.endsWith("\n") || existing.length === 0 ? "" : "\n"}${excludeEntry}\n`, "utf8");
|
|
2069
|
+
return {
|
|
2070
|
+
applied: true,
|
|
2071
|
+
warning: null
|
|
2072
|
+
};
|
|
2073
|
+
} catch {
|
|
2074
|
+
return {
|
|
2075
|
+
applied: false,
|
|
2076
|
+
warning: `Could not update ${excludePath}; keep ${PROJECT_CONFIG_LOCAL_PATH} out of version control manually.`
|
|
2077
|
+
};
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
function excludeLines(text) {
|
|
2081
|
+
return text.split("\n").map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
|
|
2082
|
+
}
|
|
2083
|
+
async function findGitDir(start) {
|
|
2084
|
+
let current = resolve(start);
|
|
2085
|
+
const root = resolve(current, "/");
|
|
2086
|
+
while (true) {
|
|
2087
|
+
const gitDir = await resolveGitDir(join(current, ".git"));
|
|
2088
|
+
if (gitDir) return {
|
|
2089
|
+
gitDir,
|
|
2090
|
+
workTree: current
|
|
2091
|
+
};
|
|
2092
|
+
if (current === root) return null;
|
|
2093
|
+
current = dirname(current);
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
async function resolveGitDir(gitPath) {
|
|
2097
|
+
const info = await stat(gitPath).catch(() => null);
|
|
2098
|
+
if (!info) return null;
|
|
2099
|
+
if (info.isDirectory()) return gitPath;
|
|
2100
|
+
if (!info.isFile()) return null;
|
|
2101
|
+
const text = await readFile(gitPath, "utf8").catch(() => null);
|
|
2102
|
+
if (!text) return null;
|
|
2103
|
+
const gitDir = text.match(/^gitdir:\s*(.+)$/m)?.[1]?.trim();
|
|
2104
|
+
if (!gitDir) return null;
|
|
2105
|
+
const resolvedGitDir = resolve(dirname(gitPath), gitDir);
|
|
2106
|
+
const commonDir = await readFile(join(resolvedGitDir, "commondir"), "utf8").then((value) => value.trim()).catch(() => null);
|
|
2107
|
+
return commonDir ? resolve(resolvedGitDir, commonDir) : resolvedGitDir;
|
|
2108
|
+
}
|
|
2109
|
+
function gitPattern(path) {
|
|
2110
|
+
return path.split("\\").join("/");
|
|
2111
|
+
}
|
|
2112
|
+
//#endregion
|
|
1867
2113
|
//#region src/command-runners/init.ts
|
|
1868
2114
|
async function runInit(parsed, mode) {
|
|
1869
2115
|
const command = "init";
|
|
1870
2116
|
const profile = nonEmpty(parsed.options.profile);
|
|
1871
2117
|
const projectId = nonEmpty(parsed.options.projectId);
|
|
1872
|
-
const
|
|
1873
|
-
if (!profile && !projectId) return writeSuccess(command, initData(false,
|
|
2118
|
+
const resolved = await resolveProjectConfig();
|
|
2119
|
+
if (!profile && !projectId) return writeSuccess(command, initData(false, resolved.raw ?? {}, resolved), mode);
|
|
1874
2120
|
if (profile) {
|
|
1875
2121
|
if (!configHome()) return writeFailure(command, tokenStoreUnavailableError(profile), mode, 1);
|
|
1876
2122
|
const globalConfig = await readGlobalConfig();
|
|
1877
2123
|
if (!Object.hasOwn(globalConfig?.profiles ?? {}, profile)) return writeFailure(command, profileNotFoundError(profile), mode, 1);
|
|
1878
2124
|
}
|
|
1879
2125
|
const next = {
|
|
1880
|
-
...
|
|
2126
|
+
...await readRawLocalProjectConfig() ?? {},
|
|
1881
2127
|
...profile ? { default_profile: profile } : {},
|
|
1882
2128
|
...projectId ? { default_project_id: projectId } : {}
|
|
1883
2129
|
};
|
|
1884
|
-
const path =
|
|
2130
|
+
const path = projectConfigLocalPath();
|
|
1885
2131
|
await mkdir(dirname(path), { recursive: true });
|
|
1886
2132
|
await writeFile(path, `${JSON.stringify(next, null, 2)}\n`);
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
2133
|
+
const gitExclude = await ensureGitExclude(process.cwd());
|
|
2134
|
+
const data = initData(true, next, resolved);
|
|
2135
|
+
delete data.read_path;
|
|
2136
|
+
if (gitExclude.warning) data.git_exclude_warning = gitExclude.warning;
|
|
2137
|
+
if (gitExclude.applied) data.git_exclude_applied = true;
|
|
2138
|
+
return writeSuccess(command, data, mode);
|
|
2139
|
+
}
|
|
2140
|
+
function initData(written, config, resolved) {
|
|
1890
2141
|
return {
|
|
1891
|
-
path:
|
|
2142
|
+
path: PROJECT_CONFIG_LOCAL_PATH,
|
|
1892
2143
|
written,
|
|
1893
2144
|
config: {
|
|
1894
2145
|
default_profile: configString(config.default_profile),
|
|
1895
2146
|
default_project_id: configString(config.default_project_id)
|
|
1896
|
-
}
|
|
2147
|
+
},
|
|
2148
|
+
...resolved.path ? { read_path: resolved.path } : {}
|
|
1897
2149
|
};
|
|
1898
2150
|
}
|
|
1899
2151
|
//#endregion
|
|
@@ -1924,12 +2176,12 @@ async function runProfilesList(parsed, mode) {
|
|
|
1924
2176
|
default_profile: defaultProfile,
|
|
1925
2177
|
profiles
|
|
1926
2178
|
}, mode);
|
|
1927
|
-
if (!mode.json && profiles.length === 0) writeText(
|
|
2179
|
+
if (!mode.json && profiles.length === 0) writeText(`No profiles yet. Run ${CLI_INVOCATION} login --profile default to create one.\n`);
|
|
1928
2180
|
}
|
|
1929
2181
|
async function runProfilesUse(parsed, mode) {
|
|
1930
2182
|
const command = "profiles use";
|
|
1931
2183
|
const name = nonEmpty(parsed.positionals[0]);
|
|
1932
|
-
if (!name) return writeFailure(command, validationError("A profile name is required.",
|
|
2184
|
+
if (!name) return writeFailure(command, validationError("A profile name is required.", `Run ${CLI_INVOCATION} profiles use <name>.`), mode, 1);
|
|
1933
2185
|
if (!configHome()) return writeFailure(command, tokenStoreUnavailableError(), mode, 1);
|
|
1934
2186
|
const config = await readGlobalConfig() ?? {};
|
|
1935
2187
|
if (!Object.hasOwn(config.profiles ?? {}, name)) return writeFailure(command, profileNotFoundError(name), mode, 1);
|
|
@@ -1963,14 +2215,14 @@ async function fetchProjects(token, options, init) {
|
|
|
1963
2215
|
}
|
|
1964
2216
|
async function runProjectsList(parsed, mode) {
|
|
1965
2217
|
const command = "projects list";
|
|
1966
|
-
const
|
|
1967
|
-
const credential = await resolveCredential(parsed.options,
|
|
2218
|
+
const projectConfig = await resolveProjectConfig();
|
|
2219
|
+
const credential = await resolveCredential(parsed.options, projectConfig);
|
|
1968
2220
|
if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
|
|
1969
|
-
const request = requestConfig(parsed.options);
|
|
2221
|
+
const request = await requestConfig(parsed.options);
|
|
1970
2222
|
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
1971
2223
|
const result = await fetchProjects(credential.token, parsed.options, request.init);
|
|
1972
2224
|
if (result.error) return writeFailure(command, result.error, mode, 1);
|
|
1973
|
-
const defaultProjectId = configString(config?.default_project_id);
|
|
2225
|
+
const defaultProjectId = configString(projectConfig.config?.default_project_id);
|
|
1974
2226
|
const projects = result.projects.map((project) => ({
|
|
1975
2227
|
...project,
|
|
1976
2228
|
is_default: project.id === defaultProjectId
|
|
@@ -1993,8 +2245,8 @@ async function runPublish(parsed, mode, isRetry = false) {
|
|
|
1993
2245
|
publishKey = (typeof parsed.options.key === "string" ? parsed.options.key : "").trim();
|
|
1994
2246
|
if (publishKey.length === 0 || publishKey.length > MAX_PUBLISH_KEY_LENGTH) return writeFailure(command, validationError(`--key must be 1-${MAX_PUBLISH_KEY_LENGTH} characters after trimming.`, "Pass a short stable identifier, like a job name or PR number."), mode, 1);
|
|
1995
2247
|
}
|
|
1996
|
-
const
|
|
1997
|
-
const credential = await resolveCredential(parsed.options,
|
|
2248
|
+
const project = await resolveProjectConfig();
|
|
2249
|
+
const credential = await resolveCredential(parsed.options, project);
|
|
1998
2250
|
if (!credential.ok) return handleCredentialFailure(command, credential, parsed.options, mode, () => runPublish(parsed, mode, true), isRetry);
|
|
1999
2251
|
const baseUrl = baseUrlOf(parsed.options);
|
|
2000
2252
|
const hasProjectFlag = "project" in parsed.options;
|
|
@@ -2006,12 +2258,12 @@ async function runPublish(parsed, mode, isRetry = false) {
|
|
|
2006
2258
|
const conflict = destinationConflictError(parsed.options);
|
|
2007
2259
|
if (conflict) return writeFailure(command, conflict, mode, 1);
|
|
2008
2260
|
} else {
|
|
2009
|
-
const earlyDestination = resolveDestination(parsed.options, config);
|
|
2261
|
+
const earlyDestination = resolveDestination(parsed.options, project.config);
|
|
2010
2262
|
if (earlyDestination.error) return writeFailure(command, earlyDestination.error, mode, 1);
|
|
2011
2263
|
}
|
|
2012
2264
|
const fileStat = await stat(targetPath).catch(() => null);
|
|
2013
2265
|
if (!fileStat) return writeFailure(command, validationError("Path was not found.", `Check the path and retry: ${targetPath}`), mode, 1);
|
|
2014
|
-
const request = requestConfig(parsed.options);
|
|
2266
|
+
const request = await requestConfig(parsed.options);
|
|
2015
2267
|
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
2016
2268
|
if (hasProjectFlag && projectName) {
|
|
2017
2269
|
const resolved = await resolveProjectIdByName(projectName, credential.token, parsed.options, request.init);
|
|
@@ -2022,7 +2274,7 @@ async function runPublish(parsed, mode, isRetry = false) {
|
|
|
2022
2274
|
projectId: resolved.projectId
|
|
2023
2275
|
};
|
|
2024
2276
|
}
|
|
2025
|
-
const destination = resolveDestination(destinationOptions, config);
|
|
2277
|
+
const destination = resolveDestination(destinationOptions, project.config);
|
|
2026
2278
|
if (destination.error) return writeFailure(command, destination.error, mode, 1);
|
|
2027
2279
|
const initialForm = new FormData();
|
|
2028
2280
|
const grantEmails = arrayOption(parsed.options.grantEmail);
|
|
@@ -2089,9 +2341,9 @@ async function runRequestAccess(parsed, mode) {
|
|
|
2089
2341
|
const command = "request-access";
|
|
2090
2342
|
const note = parsed.options.note;
|
|
2091
2343
|
if (note !== void 0 && note.length > NOTE_MAX) return writeFailure(command, validationError(`A note can be at most ${NOTE_MAX} characters.`, "Shorten --note and retry."), mode, 1);
|
|
2092
|
-
const credential = await resolveCredential(parsed.options, await
|
|
2344
|
+
const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
|
|
2093
2345
|
if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
|
|
2094
|
-
const request = requestConfig(parsed.options);
|
|
2346
|
+
const request = await requestConfig(parsed.options);
|
|
2095
2347
|
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
2096
2348
|
const result = await apiPost("/api/cli/request-access", credential.token, { note }, parsed.options, request.init);
|
|
2097
2349
|
if (result.error) return writeFailure(command, result.error, mode, 1);
|
|
@@ -2113,9 +2365,9 @@ async function runResolve(parsed, mode) {
|
|
|
2113
2365
|
const command = "resolve";
|
|
2114
2366
|
const value = parsed.positionals[0]?.trim();
|
|
2115
2367
|
if (!value) return writeFailure(command, validationError("Resolve value is required.", "Pass a URL, ID, title, or project name to resolve."), mode, 1);
|
|
2116
|
-
const credential = await resolveCredential(parsed.options, await
|
|
2368
|
+
const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
|
|
2117
2369
|
if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
|
|
2118
|
-
const request = requestConfig(parsed.options);
|
|
2370
|
+
const request = await requestConfig(parsed.options);
|
|
2119
2371
|
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
2120
2372
|
const url = apiUrl("/api/cli/resolve", baseUrlOf(parsed.options));
|
|
2121
2373
|
url.searchParams.set("q", value);
|
|
@@ -2402,12 +2654,12 @@ async function runUpdate(parsed, mode, isRetry = false) {
|
|
|
2402
2654
|
if (unsupportedOption) return writeFailure(command, validationError(`Update does not accept --${unsupportedOption}.`, "Update only adds a new version. Remove unsupported options and retry."), mode, 1);
|
|
2403
2655
|
const artifactId = resolveArtifactId(artifactInput);
|
|
2404
2656
|
if (!artifactId) return writeFailure(command, targetResolutionError(artifactInput, "update"), mode, 1);
|
|
2405
|
-
const credential = await resolveCredential(parsed.options, await
|
|
2657
|
+
const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
|
|
2406
2658
|
if (!credential.ok) return handleCredentialFailure(command, credential, parsed.options, mode, () => runUpdate(parsed, mode, true), isRetry);
|
|
2407
2659
|
const fileStat = await stat(targetPath).catch(() => null);
|
|
2408
2660
|
if (!fileStat) return writeFailure(command, validationError("Path was not found.", `Check the path and retry: ${targetPath}`), mode, 1);
|
|
2409
2661
|
const baseUrl = baseUrlOf(parsed.options);
|
|
2410
|
-
const request = requestConfig(parsed.options);
|
|
2662
|
+
const request = await requestConfig(parsed.options);
|
|
2411
2663
|
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
2412
2664
|
const upload = await prepareUploadPayload(targetPath, fileStat);
|
|
2413
2665
|
if (upload.error) return writeFailure(command, upload.error, mode, 1);
|
|
@@ -2442,9 +2694,9 @@ async function runUpdate(parsed, mode, isRetry = false) {
|
|
|
2442
2694
|
//#region src/command-runners/whoami.ts
|
|
2443
2695
|
async function runWhoami(parsed, mode) {
|
|
2444
2696
|
const command = "whoami";
|
|
2445
|
-
const credential = await resolveCredential(parsed.options, await
|
|
2697
|
+
const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
|
|
2446
2698
|
if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
|
|
2447
|
-
const request = requestConfig(parsed.options);
|
|
2699
|
+
const request = await requestConfig(parsed.options);
|
|
2448
2700
|
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
2449
2701
|
const whoami = await apiGet("/api/cli/whoami", credential.token, parsed.options, request.init);
|
|
2450
2702
|
if (whoami.error) return writeFailure(command, whoami.error, mode, 1);
|
|
@@ -2534,7 +2786,7 @@ async function doctorRunner(ctx) {
|
|
|
2534
2786
|
function parentCommandRunner(command) {
|
|
2535
2787
|
return (ctx) => {
|
|
2536
2788
|
const parsed = parsedArgsFromContext(command, ctx);
|
|
2537
|
-
writeFailure(command, validationError("A subcommand is required.", `Run
|
|
2789
|
+
writeFailure(command, validationError("A subcommand is required.", `Run ${CLI_INVOCATION} ${command} <${(SUBCOMMANDS[command] ?? []).join(" | ")}>.`), outputMode(parsed.options), 1);
|
|
2538
2790
|
};
|
|
2539
2791
|
}
|
|
2540
2792
|
//#endregion
|
|
@@ -2630,24 +2882,24 @@ const entryCommand = define({
|
|
|
2630
2882
|
description: "Artifact Share CLI",
|
|
2631
2883
|
toKebab: true,
|
|
2632
2884
|
args: commonArgs,
|
|
2633
|
-
examples: `npx @artifactshare/cli publish <path> --project-id <id> --json
|
|
2634
|
-
npx @artifactshare/cli update <artifact-id-or-url> <path> --json
|
|
2635
|
-
npx @artifactshare/cli resolve <url-id-or-title> --json
|
|
2636
|
-
npx @artifactshare/cli artifacts get <artifact-id-or-url> --json
|
|
2637
|
-
npx @artifactshare/cli comments list <artifact-id-or-url> --json
|
|
2638
|
-
npx @artifactshare/cli comments post <artifact-id-or-url> --body "<text>" --json
|
|
2639
|
-
npx @artifactshare/cli download <artifact-id-or-url> --output ./artifact --json
|
|
2640
|
-
npx @artifactshare/cli login --profile default
|
|
2641
|
-
npx @artifactshare/cli profiles list --json
|
|
2642
|
-
npx @artifactshare/cli profiles use <name> --json
|
|
2643
|
-
npx @artifactshare/cli projects list --json
|
|
2644
|
-
npx @artifactshare/cli skills install --tool codex --json
|
|
2645
|
-
npx @artifactshare/cli skills list --json
|
|
2646
|
-
npx @artifactshare/cli init --profile <name> --project-id <id> --json
|
|
2647
|
-
npx @artifactshare/cli publish <path> --home --json
|
|
2648
|
-
npx @artifactshare/cli request-access --json
|
|
2649
|
-
npx @artifactshare/cli whoami --json
|
|
2650
|
-
npx @artifactshare/cli doctor --json
|
|
2885
|
+
examples: `npx --yes @artifactshare/cli publish <path> --project-id <id> --json
|
|
2886
|
+
npx --yes @artifactshare/cli update <artifact-id-or-url> <path> --json
|
|
2887
|
+
npx --yes @artifactshare/cli resolve <url-id-or-title> --json
|
|
2888
|
+
npx --yes @artifactshare/cli artifacts get <artifact-id-or-url> --json
|
|
2889
|
+
npx --yes @artifactshare/cli comments list <artifact-id-or-url> --json
|
|
2890
|
+
npx --yes @artifactshare/cli comments post <artifact-id-or-url> --body "<text>" --json
|
|
2891
|
+
npx --yes @artifactshare/cli download <artifact-id-or-url> --output ./artifact --json
|
|
2892
|
+
npx --yes @artifactshare/cli login --profile default
|
|
2893
|
+
npx --yes @artifactshare/cli profiles list --json
|
|
2894
|
+
npx --yes @artifactshare/cli profiles use <name> --json
|
|
2895
|
+
npx --yes @artifactshare/cli projects list --json
|
|
2896
|
+
npx --yes @artifactshare/cli skills install --tool codex --json
|
|
2897
|
+
npx --yes @artifactshare/cli skills list --json
|
|
2898
|
+
npx --yes @artifactshare/cli init --profile <name> --project-id <id> --json
|
|
2899
|
+
npx --yes @artifactshare/cli publish <path> --home --json
|
|
2900
|
+
npx --yes @artifactshare/cli request-access --json
|
|
2901
|
+
npx --yes @artifactshare/cli whoami --json
|
|
2902
|
+
npx --yes @artifactshare/cli doctor --json
|
|
2651
2903
|
|
|
2652
2904
|
Common failures:
|
|
2653
2905
|
auth_required Set ARTIFACTSHARE_TOKEN or pass --token
|
|
@@ -2661,8 +2913,8 @@ const loginDefinition = define({
|
|
|
2661
2913
|
description: "Sign in with device authorization and save a CLI profile.",
|
|
2662
2914
|
toKebab: true,
|
|
2663
2915
|
args: commonArgs,
|
|
2664
|
-
examples: `npx @artifactshare/cli login --profile default
|
|
2665
|
-
npx @artifactshare/cli login --profile client-a --json
|
|
2916
|
+
examples: `npx --yes @artifactshare/cli login --profile default
|
|
2917
|
+
npx --yes @artifactshare/cli login --profile client-a --json
|
|
2666
2918
|
|
|
2667
2919
|
Common failures:
|
|
2668
2920
|
auth_denied The browser approval was denied
|
|
@@ -2711,7 +2963,7 @@ const publishDefinition = define({
|
|
|
2711
2963
|
description: "Stable key for create-or-update: the first publish creates the artifact, repeats add versions. Not a secret; it appears in logs and JSON"
|
|
2712
2964
|
}
|
|
2713
2965
|
},
|
|
2714
|
-
examples: `npx @artifactshare/cli publish report.html --project-id <id> --key nightly-report --json
|
|
2966
|
+
examples: `npx --yes @artifactshare/cli publish report.html --project-id <id> --key nightly-report --json
|
|
2715
2967
|
|
|
2716
2968
|
Common failures:
|
|
2717
2969
|
auth_required Set ARTIFACTSHARE_TOKEN before publish
|
|
@@ -2761,8 +3013,8 @@ const resolveDefinition = define({
|
|
|
2761
3013
|
description: "Share URL, sandbox URL, ID, title, or project name"
|
|
2762
3014
|
}
|
|
2763
3015
|
},
|
|
2764
|
-
examples: `npx @artifactshare/cli resolve "Weekly report" --json
|
|
2765
|
-
npx @artifactshare/cli resolve https://artifactshare.com/a/abc123def4 --json
|
|
3016
|
+
examples: `npx --yes @artifactshare/cli resolve "Weekly report" --json
|
|
3017
|
+
npx --yes @artifactshare/cli resolve https://artifactshare.com/a/abc123def4 --json
|
|
2766
3018
|
|
|
2767
3019
|
Use resolve before write commands when a user gives a title or project name.
|
|
2768
3020
|
Pass the returned artifact id or project id to the next command.
|
|
@@ -2794,8 +3046,8 @@ const downloadDefinition = define({
|
|
|
2794
3046
|
description: "Allow writing into an existing output directory"
|
|
2795
3047
|
}
|
|
2796
3048
|
},
|
|
2797
|
-
examples: `npx @artifactshare/cli download abc123def4 --json
|
|
2798
|
-
npx @artifactshare/cli download https://artifactshare.com/a/abc123def4 --output ./artifact --json
|
|
3049
|
+
examples: `npx --yes @artifactshare/cli download abc123def4 --json
|
|
3050
|
+
npx --yes @artifactshare/cli download https://artifactshare.com/a/abc123def4 --output ./artifact --json
|
|
2799
3051
|
|
|
2800
3052
|
Use resolve first when a user gives a title or project name, then pass the id here.
|
|
2801
3053
|
Download writes files to a directory so the result can be inspected or passed to update.
|
|
@@ -2834,9 +3086,9 @@ const artifactsDefinition = define({
|
|
|
2834
3086
|
description: "Extra data to include: versions or comments"
|
|
2835
3087
|
}
|
|
2836
3088
|
},
|
|
2837
|
-
examples: `npx @artifactshare/cli artifacts get abc123def4 --json
|
|
2838
|
-
npx @artifactshare/cli artifacts get https://artifactshare.com/a/abc123def4 --include versions --include comments --json
|
|
2839
|
-
npx @artifactshare/cli artifacts get abc123def4 --offset 200000 --json
|
|
3089
|
+
examples: `npx --yes @artifactshare/cli artifacts get abc123def4 --json
|
|
3090
|
+
npx --yes @artifactshare/cli artifacts get https://artifactshare.com/a/abc123def4 --include versions --include comments --json
|
|
3091
|
+
npx --yes @artifactshare/cli artifacts get abc123def4 --offset 200000 --json
|
|
2840
3092
|
|
|
2841
3093
|
Use resolve first when a user gives a title or project name, then pass the id here.
|
|
2842
3094
|
If truncated is true, call again with --offset set to next_offset before updating.
|
|
@@ -2847,7 +3099,7 @@ Common failures:
|
|
|
2847
3099
|
unsupported_kind Use download for static sites or other multi-file artifacts
|
|
2848
3100
|
validation_failed Check --offset and --include values`
|
|
2849
3101
|
}), artifactsGetRunner) },
|
|
2850
|
-
examples: `npx @artifactshare/cli artifacts get <artifact-id-or-url> --json
|
|
3102
|
+
examples: `npx --yes @artifactshare/cli artifacts get <artifact-id-or-url> --json
|
|
2851
3103
|
|
|
2852
3104
|
Use artifacts get to read back Markdown or HTML before update.`,
|
|
2853
3105
|
run: parentCommandRunner("artifacts")
|
|
@@ -2864,7 +3116,7 @@ const commentsListDefinition = define({
|
|
|
2864
3116
|
description: "Artifact ID, /a/<id> share URL, or <id>.sandbox.* URL"
|
|
2865
3117
|
}
|
|
2866
3118
|
},
|
|
2867
|
-
examples: `npx @artifactshare/cli comments list abc123def4 --json
|
|
3119
|
+
examples: `npx --yes @artifactshare/cli comments list abc123def4 --json
|
|
2868
3120
|
|
|
2869
3121
|
Returns up to 50 threads (open threads first); has_more reports whether more exist.
|
|
2870
3122
|
Each thread carries its messages, status, and quoted-text anchor when present.
|
|
@@ -2910,9 +3162,9 @@ const commentsPostDefinition = define({
|
|
|
2910
3162
|
description: "Text just after the quote, to pick the right occurrence"
|
|
2911
3163
|
}
|
|
2912
3164
|
},
|
|
2913
|
-
examples: `npx @artifactshare/cli comments post abc123def4 --body "Looks good" --json
|
|
2914
|
-
npx @artifactshare/cli comments post abc123def4 --body "Done" --reply-to <thread-id> --json
|
|
2915
|
-
npx @artifactshare/cli comments post abc123def4 --body "Fix this" --quote "exact text" --json
|
|
3165
|
+
examples: `npx --yes @artifactshare/cli comments post abc123def4 --body "Looks good" --json
|
|
3166
|
+
npx --yes @artifactshare/cli comments post abc123def4 --body "Done" --reply-to <thread-id> --json
|
|
3167
|
+
npx --yes @artifactshare/cli comments post abc123def4 --body "Fix this" --quote "exact text" --json
|
|
2916
3168
|
|
|
2917
3169
|
Copy quote text from artifacts get so it matches the artifact exactly.
|
|
2918
3170
|
|
|
@@ -2933,8 +3185,8 @@ const commentsDefinition = define({
|
|
|
2933
3185
|
list: lazyCommand(commentsListDefinition, commentsListRunner),
|
|
2934
3186
|
post: lazyCommand(commentsPostDefinition, commentsPostRunner)
|
|
2935
3187
|
},
|
|
2936
|
-
examples: `npx @artifactshare/cli comments list <artifact-id-or-url> --json
|
|
2937
|
-
npx @artifactshare/cli comments post <artifact-id-or-url> --body "<text>" --json`,
|
|
3188
|
+
examples: `npx --yes @artifactshare/cli comments list <artifact-id-or-url> --json
|
|
3189
|
+
npx --yes @artifactshare/cli comments post <artifact-id-or-url> --body "<text>" --json`,
|
|
2938
3190
|
run: parentCommandRunner("comments")
|
|
2939
3191
|
});
|
|
2940
3192
|
const profilesListDefinition = define({
|
|
@@ -2942,7 +3194,7 @@ const profilesListDefinition = define({
|
|
|
2942
3194
|
description: "List saved CLI profiles and the default profile.",
|
|
2943
3195
|
toKebab: true,
|
|
2944
3196
|
args: commonArgs,
|
|
2945
|
-
examples: `npx @artifactshare/cli profiles list --json
|
|
3197
|
+
examples: `npx --yes @artifactshare/cli profiles list --json
|
|
2946
3198
|
|
|
2947
3199
|
token_present shows whether a saved credential exists; token values are never printed.`
|
|
2948
3200
|
});
|
|
@@ -2957,7 +3209,7 @@ const profilesUseDefinition = define({
|
|
|
2957
3209
|
description: "Profile name to make the default"
|
|
2958
3210
|
}
|
|
2959
3211
|
},
|
|
2960
|
-
examples: `npx @artifactshare/cli profiles use client-a --json
|
|
3212
|
+
examples: `npx --yes @artifactshare/cli profiles use client-a --json
|
|
2961
3213
|
|
|
2962
3214
|
Common failures:
|
|
2963
3215
|
profile_not_found Run profiles list to see saved profiles, or login --profile <name>`
|
|
@@ -2971,8 +3223,8 @@ const profilesDefinition = define({
|
|
|
2971
3223
|
list: lazyCommand(profilesListDefinition, profilesListRunner),
|
|
2972
3224
|
use: lazyCommand(profilesUseDefinition, profilesUseRunner)
|
|
2973
3225
|
},
|
|
2974
|
-
examples: `npx @artifactshare/cli profiles list --json
|
|
2975
|
-
npx @artifactshare/cli profiles use client-a --json`,
|
|
3226
|
+
examples: `npx --yes @artifactshare/cli profiles list --json
|
|
3227
|
+
npx --yes @artifactshare/cli profiles use client-a --json`,
|
|
2976
3228
|
run: parentCommandRunner("profiles")
|
|
2977
3229
|
});
|
|
2978
3230
|
const projectsDefinition = define({
|
|
@@ -2985,12 +3237,12 @@ const projectsDefinition = define({
|
|
|
2985
3237
|
description: "List projects you can publish into.",
|
|
2986
3238
|
toKebab: true,
|
|
2987
3239
|
args: commonArgs,
|
|
2988
|
-
examples: `npx @artifactshare/cli projects list --json
|
|
3240
|
+
examples: `npx --yes @artifactshare/cli projects list --json
|
|
2989
3241
|
|
|
2990
3242
|
is_default marks the working-directory default project from .artifactshare/config.json.
|
|
2991
3243
|
Use a project id with publish --project-id or init --project-id.`
|
|
2992
3244
|
}), projectsListRunner) },
|
|
2993
|
-
examples: `npx @artifactshare/cli projects list --json`,
|
|
3245
|
+
examples: `npx --yes @artifactshare/cli projects list --json`,
|
|
2994
3246
|
run: parentCommandRunner("projects")
|
|
2995
3247
|
});
|
|
2996
3248
|
const skillsToolArgs = {
|
|
@@ -3024,8 +3276,8 @@ const skillsInstallDefinition = define({
|
|
|
3024
3276
|
description: "Overwrite an existing unmanaged file or reinstall the same version"
|
|
3025
3277
|
}
|
|
3026
3278
|
},
|
|
3027
|
-
examples: `npx @artifactshare/cli skills install --tool codex --scope project --json
|
|
3028
|
-
npx @artifactshare/cli skills install --tool claude --tool cursor --dry-run --json
|
|
3279
|
+
examples: `npx --yes @artifactshare/cli skills install --tool codex --scope project --json
|
|
3280
|
+
npx --yes @artifactshare/cli skills install --tool claude --tool cursor --dry-run --json
|
|
3029
3281
|
|
|
3030
3282
|
Writes a managed SKILL.md (codex, claude) or Cursor rule (cursor).
|
|
3031
3283
|
Files without the Artifact Share managed marker are never overwritten without --force.
|
|
@@ -3039,7 +3291,7 @@ const skillsListDefinition = define({
|
|
|
3039
3291
|
description: "Show skill install status for each supported agent tool.",
|
|
3040
3292
|
toKebab: true,
|
|
3041
3293
|
args: commonArgs,
|
|
3042
|
-
examples: `npx @artifactshare/cli skills list --json
|
|
3294
|
+
examples: `npx --yes @artifactshare/cli skills list --json
|
|
3043
3295
|
|
|
3044
3296
|
Reports each tool and scope with detection, install state, and update availability.
|
|
3045
3297
|
Runs locally; no network or authentication is used.`
|
|
@@ -3057,8 +3309,8 @@ const skillsUpdateDefinition = define({
|
|
|
3057
3309
|
description: "Rewrite managed files even when the version already matches"
|
|
3058
3310
|
}
|
|
3059
3311
|
},
|
|
3060
|
-
examples: `npx @artifactshare/cli skills update --json
|
|
3061
|
-
npx @artifactshare/cli skills update --tool codex --scope user --json
|
|
3312
|
+
examples: `npx --yes @artifactshare/cli skills update --json
|
|
3313
|
+
npx --yes @artifactshare/cli skills update --tool codex --scope user --json
|
|
3062
3314
|
|
|
3063
3315
|
Only files created by skills install (managed marker present) are updated.
|
|
3064
3316
|
|
|
@@ -3073,8 +3325,8 @@ const skillsRemoveDefinition = define({
|
|
|
3073
3325
|
...commonArgs,
|
|
3074
3326
|
...skillsToolArgs
|
|
3075
3327
|
},
|
|
3076
|
-
examples: `npx @artifactshare/cli skills remove --json
|
|
3077
|
-
npx @artifactshare/cli skills remove --tool cursor --json
|
|
3328
|
+
examples: `npx --yes @artifactshare/cli skills remove --json
|
|
3329
|
+
npx --yes @artifactshare/cli skills remove --tool cursor --json
|
|
3078
3330
|
|
|
3079
3331
|
Only files created by skills install are deleted; unmanaged files are skipped.`
|
|
3080
3332
|
});
|
|
@@ -3089,8 +3341,8 @@ const skillsDefinition = define({
|
|
|
3089
3341
|
update: lazyCommand(skillsUpdateDefinition, skillsUpdateRunner),
|
|
3090
3342
|
remove: lazyCommand(skillsRemoveDefinition, skillsRemoveRunner)
|
|
3091
3343
|
},
|
|
3092
|
-
examples: `npx @artifactshare/cli skills install --tool codex --json
|
|
3093
|
-
npx @artifactshare/cli skills list --json`,
|
|
3344
|
+
examples: `npx --yes @artifactshare/cli skills install --tool codex --json
|
|
3345
|
+
npx --yes @artifactshare/cli skills list --json`,
|
|
3094
3346
|
run: parentCommandRunner("skills")
|
|
3095
3347
|
});
|
|
3096
3348
|
const initDefinition = define({
|
|
@@ -3105,8 +3357,8 @@ const initDefinition = define({
|
|
|
3105
3357
|
description: "Default project for publish in this directory"
|
|
3106
3358
|
}
|
|
3107
3359
|
},
|
|
3108
|
-
examples: `npx @artifactshare/cli init --profile client-a --project-id <id> --json
|
|
3109
|
-
npx @artifactshare/cli init --json
|
|
3360
|
+
examples: `npx --yes @artifactshare/cli init --profile client-a --project-id <id> --json
|
|
3361
|
+
npx --yes @artifactshare/cli init --json
|
|
3110
3362
|
|
|
3111
3363
|
Without flags, init reports the current config and writes nothing.
|
|
3112
3364
|
Secrets are never written to .artifactshare/config.json.
|
|
@@ -3126,8 +3378,8 @@ const requestAccessDefinition = define({
|
|
|
3126
3378
|
description: "Optional message for the Artifact Share team (max 2000 characters)"
|
|
3127
3379
|
}
|
|
3128
3380
|
},
|
|
3129
|
-
examples: `npx @artifactshare/cli request-access --json
|
|
3130
|
-
npx @artifactshare/cli request-access --note "Publishing weekly reports for my team" --json
|
|
3381
|
+
examples: `npx --yes @artifactshare/cli request-access --json
|
|
3382
|
+
npx --yes @artifactshare/cli request-access --note "Publishing weekly reports for my team" --json
|
|
3131
3383
|
|
|
3132
3384
|
Joining the waitlist does not enable publishing immediately; an operator opens it.
|
|
3133
3385
|
Re-running updates your note without creating a duplicate entry.
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ description: Publish, update, and read back shared artifacts with the Artifact S
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<!-- artifactshare-skill
|
|
7
|
-
version:
|
|
7
|
+
version: 3
|
|
8
8
|
managed: true
|
|
9
9
|
-->
|
|
10
10
|
|
|
@@ -17,6 +17,10 @@ designed for agents: every command supports `--json` with a stable contract.
|
|
|
17
17
|
Run commands with `npx --yes @artifactshare/cli`. When unsure about a
|
|
18
18
|
command or flag, read `npx --yes @artifactshare/cli --help` first.
|
|
19
19
|
|
|
20
|
+
Use the CLI whenever the artifact already exists as a local file or folder.
|
|
21
|
+
The remote MCP tools accept HTML or Markdown source strings; they cannot read
|
|
22
|
+
paths like `/Users/.../report.html` from the user's filesystem.
|
|
23
|
+
|
|
20
24
|
## Output contract
|
|
21
25
|
|
|
22
26
|
- Always pass `--json`. Success prints `{"schema_version":1,"ok":true,"command":...,"data":...}` to stdout; failure prints `{"ok":false,"error":...}` to stderr with exit code 1.
|
|
@@ -4,7 +4,7 @@ alwaysApply: false
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<!-- artifactshare-skill
|
|
7
|
-
version:
|
|
7
|
+
version: 3
|
|
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
|
publish from the terminal, and read
|
|
16
16
|
`npx --yes @artifactshare/cli --help` before choosing a command.
|
|
17
17
|
|
|
18
|
+
Use the CLI for local files and folders. The remote MCP tools accept HTML or
|
|
19
|
+
Markdown source strings; they cannot read paths like `/Users/.../report.html`
|
|
20
|
+
from the user's filesystem.
|
|
21
|
+
|
|
18
22
|
- Always pass `--json`; on failure read `error.code`, `error.hint`, and `error.recovery`.
|
|
19
23
|
- Pick the destination with `projects list --json`, `init --project-id <id>`, or `--project-id`.
|
|
20
24
|
- Publish with `publish <path> --json`; add a version with `update <artifact-id-or-url> <path> --json`.
|