@artifactshare/cli 0.1.4 → 0.1.6
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 +27 -17
- package/dist/index.js +1006 -51
- package/package.json +2 -2
- package/skills/artifactshare/SKILL.md +31 -7
- package/skills/artifactshare/artifactshare.mdc +11 -6
package/dist/index.js
CHANGED
|
@@ -26,30 +26,41 @@ const EXCLUDED_DIR_NAMES = new Set([
|
|
|
26
26
|
]);
|
|
27
27
|
const BOOLEAN_FLAGS = new Set([
|
|
28
28
|
"allow-plaintext-token-store",
|
|
29
|
+
"archive",
|
|
29
30
|
"dry-run",
|
|
30
31
|
"force",
|
|
31
32
|
"json",
|
|
32
33
|
"help",
|
|
33
34
|
"home",
|
|
34
|
-
"insecure-localhost"
|
|
35
|
+
"insecure-localhost",
|
|
36
|
+
"unarchive"
|
|
35
37
|
]);
|
|
36
38
|
const VALUE_FLAGS = new Set([
|
|
39
|
+
"add-email",
|
|
37
40
|
"base-url",
|
|
38
41
|
"body",
|
|
42
|
+
"description",
|
|
39
43
|
"grant-email",
|
|
40
44
|
"include",
|
|
41
45
|
"key",
|
|
46
|
+
"message-id",
|
|
47
|
+
"name",
|
|
42
48
|
"note",
|
|
43
49
|
"offset",
|
|
44
50
|
"output",
|
|
45
51
|
"profile",
|
|
46
52
|
"project",
|
|
47
53
|
"project-id",
|
|
54
|
+
"query",
|
|
48
55
|
"quote",
|
|
49
56
|
"quote-after",
|
|
50
57
|
"quote-before",
|
|
51
58
|
"reply-to",
|
|
59
|
+
"remove-email",
|
|
60
|
+
"revoke-email",
|
|
52
61
|
"scope",
|
|
62
|
+
"thread-id",
|
|
63
|
+
"title",
|
|
53
64
|
"token",
|
|
54
65
|
"tool",
|
|
55
66
|
"visibility"
|
|
@@ -58,8 +69,11 @@ const COMMAND_NAMES = new Set([
|
|
|
58
69
|
"login",
|
|
59
70
|
"publish",
|
|
60
71
|
"update",
|
|
72
|
+
"edit",
|
|
73
|
+
"delete",
|
|
61
74
|
"resolve",
|
|
62
75
|
"download",
|
|
76
|
+
"move",
|
|
63
77
|
"artifacts",
|
|
64
78
|
"comments",
|
|
65
79
|
"request-access",
|
|
@@ -71,14 +85,25 @@ const COMMAND_NAMES = new Set([
|
|
|
71
85
|
"init"
|
|
72
86
|
]);
|
|
73
87
|
const SUBCOMMANDS = {
|
|
74
|
-
artifacts: ["get"],
|
|
75
|
-
comments: [
|
|
88
|
+
artifacts: ["list", "get"],
|
|
89
|
+
comments: [
|
|
90
|
+
"list",
|
|
91
|
+
"post",
|
|
92
|
+
"edit",
|
|
93
|
+
"resolve",
|
|
94
|
+
"reopen",
|
|
95
|
+
"delete"
|
|
96
|
+
],
|
|
76
97
|
profiles: [
|
|
77
98
|
"list",
|
|
78
99
|
"use",
|
|
79
100
|
"import-token"
|
|
80
101
|
],
|
|
81
|
-
projects: [
|
|
102
|
+
projects: [
|
|
103
|
+
"list",
|
|
104
|
+
"create",
|
|
105
|
+
"edit"
|
|
106
|
+
],
|
|
82
107
|
skills: [
|
|
83
108
|
"install",
|
|
84
109
|
"list",
|
|
@@ -192,6 +217,15 @@ function mapApiError(status, body, options = {}) {
|
|
|
192
217
|
requiresHuman: false,
|
|
193
218
|
recovery: { kind: "change_input" }
|
|
194
219
|
});
|
|
220
|
+
if (apiCode === "message-not-found") return cliError({
|
|
221
|
+
code: "message_not_found",
|
|
222
|
+
message: apiMessage ?? "Comment message was not found.",
|
|
223
|
+
why: "No comment message with that ID exists in the selected thread.",
|
|
224
|
+
hint: `Run ${CLI_INVOCATION} comments list <artifact-id> --json and retry with a listed message_id.`,
|
|
225
|
+
agentRecoverable: true,
|
|
226
|
+
requiresHuman: false,
|
|
227
|
+
recovery: { kind: "change_input" }
|
|
228
|
+
});
|
|
195
229
|
if (apiCode === "thread-resolved") return cliError({
|
|
196
230
|
code: "thread_resolved",
|
|
197
231
|
message: apiMessage ?? "Comment thread is resolved.",
|
|
@@ -201,6 +235,7 @@ function mapApiError(status, body, options = {}) {
|
|
|
201
235
|
requiresHuman: false,
|
|
202
236
|
recovery: { kind: "change_input" }
|
|
203
237
|
});
|
|
238
|
+
if (apiCode === "invalid-comment") return validationError(apiMessage ?? "Invalid comment payload.", "Check the comment body and IDs, then retry.");
|
|
204
239
|
if (apiCode === "quote-unsupported") return cliError({
|
|
205
240
|
code: "quote_unsupported",
|
|
206
241
|
message: apiMessage ?? "This artifact does not support quoted comments.",
|
|
@@ -228,6 +263,18 @@ function mapApiError(status, body, options = {}) {
|
|
|
228
263
|
requiresHuman: false,
|
|
229
264
|
recovery: { kind: "change_input" }
|
|
230
265
|
});
|
|
266
|
+
if (options.projectTarget && (apiCode === "not-found" || status === 404)) return cliError({
|
|
267
|
+
code: "target_not_found",
|
|
268
|
+
message: apiMessage ?? "Project target was not found.",
|
|
269
|
+
why: "The specified project does not exist or is not available in the current workspace.",
|
|
270
|
+
hint: `Run ${PROJECTS_LIST_COMMAND}, then retry with a listed project id.`,
|
|
271
|
+
agentRecoverable: true,
|
|
272
|
+
requiresHuman: false,
|
|
273
|
+
recovery: {
|
|
274
|
+
kind: "run_command",
|
|
275
|
+
command: PROJECTS_LIST_COMMAND
|
|
276
|
+
}
|
|
277
|
+
});
|
|
231
278
|
if (options.artifactTarget && apiCode === "unsupported-kind") return cliError({
|
|
232
279
|
code: "unsupported_kind",
|
|
233
280
|
message: apiMessage ?? "This artifact cannot be read as a single source file.",
|
|
@@ -255,6 +302,15 @@ function mapApiError(status, body, options = {}) {
|
|
|
255
302
|
requiresHuman: false,
|
|
256
303
|
recovery: { kind: "change_input" }
|
|
257
304
|
});
|
|
305
|
+
if (apiCode === "forbidden" || status === 403) return cliError({
|
|
306
|
+
code: "forbidden",
|
|
307
|
+
message: apiMessage ?? "You do not have permission to do that.",
|
|
308
|
+
why: "The current account is not allowed to change this comment or artifact.",
|
|
309
|
+
hint: "Use an account with permission, or ask the artifact owner or a workspace admin to make the change.",
|
|
310
|
+
agentRecoverable: false,
|
|
311
|
+
requiresHuman: true,
|
|
312
|
+
recovery: { kind: "ask_human" }
|
|
313
|
+
});
|
|
258
314
|
if (apiCode === "key-target-moved") return cliError({
|
|
259
315
|
code: "key_target_moved",
|
|
260
316
|
message: apiMessage ?? "The artifact for this key moved.",
|
|
@@ -282,6 +338,45 @@ function mapApiError(status, body, options = {}) {
|
|
|
282
338
|
requiresHuman: false,
|
|
283
339
|
recovery: { kind: "retry_later" }
|
|
284
340
|
});
|
|
341
|
+
if (apiCode === "invalid-destination") return cliError({
|
|
342
|
+
code: "invalid_destination",
|
|
343
|
+
message: apiMessage ?? "The move destination is invalid.",
|
|
344
|
+
why: "The destination project does not exist, is archived, or is not available in this workspace.",
|
|
345
|
+
hint: `Run ${PROJECTS_LIST_COMMAND}, then retry with --project-id <id> or --home.`,
|
|
346
|
+
agentRecoverable: true,
|
|
347
|
+
requiresHuman: false,
|
|
348
|
+
recovery: {
|
|
349
|
+
kind: "run_command",
|
|
350
|
+
command: PROJECTS_LIST_COMMAND
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
if (options.editSettings && apiCode === "workspace-unavailable") return cliError({
|
|
354
|
+
code: "workspace_unavailable",
|
|
355
|
+
message: apiMessage ?? "Workspace visibility is unavailable for this account.",
|
|
356
|
+
why: "Personal Google accounts cannot share with a whole workspace.",
|
|
357
|
+
hint: "Retry with --visibility private and explicit --grant-email values.",
|
|
358
|
+
agentRecoverable: true,
|
|
359
|
+
requiresHuman: false,
|
|
360
|
+
recovery: { kind: "change_input" }
|
|
361
|
+
});
|
|
362
|
+
if ((options.editSettings || options.projectTarget) && apiCode === "too-many-grants") return cliError({
|
|
363
|
+
code: "too_many_grants",
|
|
364
|
+
message: apiMessage ?? "Too many people are shared.",
|
|
365
|
+
why: "The target reached the maximum number of explicit viewers.",
|
|
366
|
+
hint: "Remove one or more viewers, or use a narrower set of email values.",
|
|
367
|
+
agentRecoverable: true,
|
|
368
|
+
requiresHuman: false,
|
|
369
|
+
recovery: { kind: "change_input" }
|
|
370
|
+
});
|
|
371
|
+
if (options.projectTarget && apiCode === "project-archived") return cliError({
|
|
372
|
+
code: "project_archived",
|
|
373
|
+
message: apiMessage ?? "Project is archived.",
|
|
374
|
+
why: "Archived projects must be unarchived before changing their settings or audience.",
|
|
375
|
+
hint: "Retry with --unarchive in the same command, or unarchive the project first.",
|
|
376
|
+
agentRecoverable: true,
|
|
377
|
+
requiresHuman: false,
|
|
378
|
+
recovery: { kind: "change_input" }
|
|
379
|
+
});
|
|
285
380
|
if (apiCode !== null && [
|
|
286
381
|
"unsupported-type",
|
|
287
382
|
"invalid-key",
|
|
@@ -608,6 +703,9 @@ function parseIncludeOptions(value) {
|
|
|
608
703
|
}
|
|
609
704
|
return { values: [...new Set(values)] };
|
|
610
705
|
}
|
|
706
|
+
function hasProjectIdHomeConflict(options) {
|
|
707
|
+
return options.projectId !== void 0 && Boolean(options.home);
|
|
708
|
+
}
|
|
611
709
|
function unsupportedUpdateOption(options) {
|
|
612
710
|
for (const key of Object.keys(options)) if (!UPDATE_OPTION_KEYS.has(key)) return kebabCase(key);
|
|
613
711
|
return null;
|
|
@@ -632,7 +730,14 @@ const TARGET_COMMAND_LABELS = {
|
|
|
632
730
|
"artifacts get": "Artifacts get",
|
|
633
731
|
download: "Download",
|
|
634
732
|
"comments list": "Comments list",
|
|
635
|
-
"comments post": "Comments post"
|
|
733
|
+
"comments post": "Comments post",
|
|
734
|
+
"comments edit": "Comments edit",
|
|
735
|
+
"comments resolve": "Comments resolve",
|
|
736
|
+
"comments reopen": "Comments reopen",
|
|
737
|
+
"comments delete": "Comments delete",
|
|
738
|
+
move: "Move",
|
|
739
|
+
edit: "Edit",
|
|
740
|
+
delete: "Delete"
|
|
636
741
|
};
|
|
637
742
|
function targetResolutionError(input, command) {
|
|
638
743
|
return cliError({
|
|
@@ -669,6 +774,14 @@ function parsedArgsFromContext(command, ctx) {
|
|
|
669
774
|
const name = camelCase(rawName);
|
|
670
775
|
if (options[name] === void 0 && !UPDATE_OPTION_KEYS.has(name)) options[name] = true;
|
|
671
776
|
}
|
|
777
|
+
if (command === "edit") for (const token of ctx.tokens) {
|
|
778
|
+
if (token.kind !== "option") continue;
|
|
779
|
+
if ((token.name ?? token.rawName?.replace(/^--?/, "")) === "title" && options.title === void 0) options.title = "";
|
|
780
|
+
}
|
|
781
|
+
if (command === "projects edit") for (const token of ctx.tokens) {
|
|
782
|
+
if (token.kind !== "option") continue;
|
|
783
|
+
if ((token.name ?? token.rawName?.replace(/^--?/, "")) === "description" && options.description === void 0) options.description = "";
|
|
784
|
+
}
|
|
672
785
|
return {
|
|
673
786
|
command,
|
|
674
787
|
options,
|
|
@@ -712,16 +825,20 @@ function validateRawArgs(argv) {
|
|
|
712
825
|
const eqIndex = arg.indexOf("=");
|
|
713
826
|
if (eqIndex === -1) {
|
|
714
827
|
const rawName = arg.slice(2);
|
|
715
|
-
|
|
828
|
+
const next = argv[i + 1];
|
|
829
|
+
if (VALUE_FLAGS.has(rawName) && (next === void 0 || isKnownFlagToken(next) || next === "" && !allowsEmptyValue(rawName))) return validationError(`--${rawName} requires a value.`, `Pass --${rawName} <value> and retry.`);
|
|
716
830
|
continue;
|
|
717
831
|
}
|
|
718
832
|
const rawName = arg.slice(2, eqIndex);
|
|
719
833
|
const value = arg.slice(eqIndex + 1);
|
|
720
834
|
if (BOOLEAN_FLAGS.has(rawName)) return validationError(`--${rawName} does not accept a value.`, `Use --${rawName} without =value.`);
|
|
721
|
-
if (VALUE_FLAGS.has(rawName) && value === "") return validationError(`--${rawName} requires a value.`, `Pass --${rawName} <value> and retry.`);
|
|
835
|
+
if (VALUE_FLAGS.has(rawName) && value === "" && !allowsEmptyValue(rawName)) return validationError(`--${rawName} requires a value.`, `Pass --${rawName} <value> and retry.`);
|
|
722
836
|
}
|
|
723
837
|
return null;
|
|
724
838
|
}
|
|
839
|
+
function allowsEmptyValue(rawName) {
|
|
840
|
+
return rawName === "title" || rawName === "description";
|
|
841
|
+
}
|
|
725
842
|
function commandNameFromArgv(argv) {
|
|
726
843
|
const found = findCommandCandidate(argv);
|
|
727
844
|
const command = found?.command;
|
|
@@ -893,6 +1010,17 @@ function artifactGetSuccessFields(data) {
|
|
|
893
1010
|
if (!isRecord(data)) return false;
|
|
894
1011
|
return typeof data.id === "string" && typeof data.share_url === "string" && typeof data.version_id === "string" && (data.format === "html" || data.format === "markdown") && typeof data.content === "string" && typeof data.size_bytes === "number" && typeof data.truncated === "boolean" && (typeof data.next_offset === "number" || data.next_offset === null);
|
|
895
1012
|
}
|
|
1013
|
+
function artifactsListSuccessFields(data) {
|
|
1014
|
+
if (!isRecord(data)) return false;
|
|
1015
|
+
return Array.isArray(data.artifacts) && data.artifacts.every((item) => {
|
|
1016
|
+
if (!isRecord(item)) return false;
|
|
1017
|
+
return typeof item.id === "string" && typeof item.title === "string" && typeof item.share_url === "string" && typeof item.visibility === "string" && typeof item.updated_at === "string" && (typeof item.project_id === "string" || item.project_id === null);
|
|
1018
|
+
}) && typeof data.limit === "number" && typeof data.has_more === "boolean" && (typeof data.next_cursor === "string" || data.next_cursor === null);
|
|
1019
|
+
}
|
|
1020
|
+
function deleteSuccessFields(data) {
|
|
1021
|
+
if (!isRecord(data)) return false;
|
|
1022
|
+
return typeof data.id === "string" && data.deleted === true;
|
|
1023
|
+
}
|
|
896
1024
|
function downloadManifestFields(data) {
|
|
897
1025
|
if (!isRecord(data)) return false;
|
|
898
1026
|
return typeof data.id === "string" && typeof data.share_url === "string" && typeof data.version_id === "string" && typeof data.artifact_kind === "string" && Array.isArray(data.files) && data.files.every(downloadManifestFileFields) && typeof data.total_size_bytes === "number";
|
|
@@ -957,6 +1085,13 @@ async function apiPost(path, token, payload, options, init, errorOptions = {}) {
|
|
|
957
1085
|
...init
|
|
958
1086
|
}, errorOptions);
|
|
959
1087
|
}
|
|
1088
|
+
async function apiDelete(path, token, options, init, errorOptions = {}) {
|
|
1089
|
+
return await apiRequest(path, options, {
|
|
1090
|
+
method: "DELETE",
|
|
1091
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
1092
|
+
...init
|
|
1093
|
+
}, errorOptions);
|
|
1094
|
+
}
|
|
960
1095
|
async function apiRequest(path, options, init, errorOptions) {
|
|
961
1096
|
const response = await fetch(apiUrl(path, baseUrlOf(options)), init).catch((error) => ({ networkError: error }));
|
|
962
1097
|
if ("networkError" in response) return { error: networkError(response.networkError) };
|
|
@@ -1528,6 +1663,33 @@ async function runArtifactsGet(parsed, mode) {
|
|
|
1528
1663
|
if (!artifactGetSuccessFields(body)) return writeFailure(command, serviceError("Artifact read succeeded but the response did not include source metadata."), mode, 1);
|
|
1529
1664
|
return writeSuccess(command, body, mode);
|
|
1530
1665
|
}
|
|
1666
|
+
async function runArtifactsList(parsed, mode) {
|
|
1667
|
+
const command = "artifacts list";
|
|
1668
|
+
const hasProjectId = parsed.options.projectId !== void 0;
|
|
1669
|
+
const projectId = parsed.options.projectId?.trim() ?? "";
|
|
1670
|
+
const home = Boolean(parsed.options.home);
|
|
1671
|
+
if (hasProjectId && !projectId) return writeFailure(command, validationError("--project-id must not be empty.", "Pass --project-id <id>, use --home, or omit the destination filter."), mode, 1);
|
|
1672
|
+
if (hasProjectIdHomeConflict(parsed.options)) return writeFailure(command, validationError("Artifact list destination is ambiguous.", "Choose only one destination filter: --project-id <id> or --home.", "destination_conflict"), mode, 1);
|
|
1673
|
+
const query = parsed.options.query?.trim();
|
|
1674
|
+
if (parsed.options.query !== void 0 && !query) return writeFailure(command, validationError("--query must not be empty.", "Pass --query <text> or omit --query."), mode, 1);
|
|
1675
|
+
const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
|
|
1676
|
+
if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
|
|
1677
|
+
const request = await requestConfig(parsed.options);
|
|
1678
|
+
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
1679
|
+
const url = apiUrl("/api/cli/artifacts", baseUrlOf(parsed.options));
|
|
1680
|
+
if (home) url.searchParams.set("project_id", "");
|
|
1681
|
+
else if (projectId) url.searchParams.set("project_id", projectId);
|
|
1682
|
+
if (query) url.searchParams.set("query", query);
|
|
1683
|
+
const response = await fetch(url, {
|
|
1684
|
+
headers: { Authorization: `Bearer ${credential.token}` },
|
|
1685
|
+
...request.init
|
|
1686
|
+
}).catch((error) => ({ networkError: error }));
|
|
1687
|
+
if ("networkError" in response) return writeFailure(command, networkError(response.networkError), mode, 1);
|
|
1688
|
+
const body = await readJson(response);
|
|
1689
|
+
if (!response.ok) return writeFailure(command, mapApiError(response.status, body, { authenticated: true }), mode, 1);
|
|
1690
|
+
if (!artifactsListSuccessFields(body)) return writeFailure(command, serviceError("Artifact list succeeded but the response did not include list metadata."), mode, 1);
|
|
1691
|
+
return writeSuccess(command, body, mode);
|
|
1692
|
+
}
|
|
1531
1693
|
//#endregion
|
|
1532
1694
|
//#region src/command-runners/comments.ts
|
|
1533
1695
|
async function runCommentsList(parsed, mode) {
|
|
@@ -1583,6 +1745,127 @@ async function runCommentsPost(parsed, mode) {
|
|
|
1583
1745
|
thread: result.body?.thread ?? null
|
|
1584
1746
|
}, mode);
|
|
1585
1747
|
}
|
|
1748
|
+
async function runCommentsEdit(parsed, mode) {
|
|
1749
|
+
const command = "comments edit";
|
|
1750
|
+
const target = parseArtifactTarget(parsed.positionals[0], command, "Pass an artifact ID or share URL.");
|
|
1751
|
+
if (target.error) return writeFailure(command, target.error, mode, 1);
|
|
1752
|
+
const messageId = requiredOption(parsed.options.messageId, "--message-id is required.", "Run comments list and retry with a listed message_id.");
|
|
1753
|
+
if (messageId.error) return writeFailure(command, messageId.error, mode, 1);
|
|
1754
|
+
const body = requiredOption(parsed.options.body, "--body is required.", "Pass --body <text> with the updated comment.");
|
|
1755
|
+
if (body.error) return writeFailure(command, body.error, mode, 1);
|
|
1756
|
+
const result = await postCommentAction(parsed, command, target.artifactId, {
|
|
1757
|
+
action: "edit",
|
|
1758
|
+
message_id: messageId.value,
|
|
1759
|
+
body: body.value
|
|
1760
|
+
}, mode);
|
|
1761
|
+
if (!result) return;
|
|
1762
|
+
const threadId = configString(result.thread_id);
|
|
1763
|
+
if (!threadId || result.thread === void 0) return writeFailure(command, serviceError("Comment was changed but the response had no thread."), mode, 1);
|
|
1764
|
+
writeSuccess(command, {
|
|
1765
|
+
artifact_id: target.artifactId,
|
|
1766
|
+
share_url: configString(result.share_url),
|
|
1767
|
+
thread_id: threadId,
|
|
1768
|
+
thread: result.thread
|
|
1769
|
+
}, mode);
|
|
1770
|
+
}
|
|
1771
|
+
async function runCommentsResolve(parsed, mode) {
|
|
1772
|
+
return await runCommentsStatus(parsed, mode, "comments resolve", "resolve");
|
|
1773
|
+
}
|
|
1774
|
+
async function runCommentsReopen(parsed, mode) {
|
|
1775
|
+
return await runCommentsStatus(parsed, mode, "comments reopen", "reopen");
|
|
1776
|
+
}
|
|
1777
|
+
async function runCommentsDelete(parsed, mode) {
|
|
1778
|
+
const command = "comments delete";
|
|
1779
|
+
const target = parseArtifactTarget(parsed.positionals[0], command, "Pass an artifact ID or share URL.");
|
|
1780
|
+
if (target.error) return writeFailure(command, target.error, mode, 1);
|
|
1781
|
+
const threadId = requiredOption(parsed.options.threadId, "--thread-id is required.", "Run comments list and retry with a listed thread_id.");
|
|
1782
|
+
if (threadId.error) return writeFailure(command, threadId.error, mode, 1);
|
|
1783
|
+
const payload = {
|
|
1784
|
+
action: "delete",
|
|
1785
|
+
thread_id: threadId.value
|
|
1786
|
+
};
|
|
1787
|
+
if (parsed.options.messageId !== void 0) {
|
|
1788
|
+
if (!parsed.options.messageId.trim()) return writeFailure(command, validationError("--message-id cannot be empty.", "Run comments list and retry with a listed message_id."), mode, 1);
|
|
1789
|
+
payload.message_id = parsed.options.messageId.trim();
|
|
1790
|
+
}
|
|
1791
|
+
const result = await postCommentAction(parsed, command, target.artifactId, payload, mode);
|
|
1792
|
+
if (!result) return;
|
|
1793
|
+
const responseThreadId = configString(result.thread_id);
|
|
1794
|
+
if (!responseThreadId || result.deleted !== true) return writeFailure(command, serviceError("Comment was deleted but the response was incomplete."), mode, 1);
|
|
1795
|
+
writeSuccess(command, {
|
|
1796
|
+
artifact_id: target.artifactId,
|
|
1797
|
+
share_url: configString(result.share_url),
|
|
1798
|
+
thread_id: responseThreadId,
|
|
1799
|
+
deleted: true,
|
|
1800
|
+
thread_deleted: result.thread_deleted === true,
|
|
1801
|
+
...result.thread !== void 0 ? { thread: result.thread } : {}
|
|
1802
|
+
}, mode);
|
|
1803
|
+
}
|
|
1804
|
+
async function runCommentsStatus(parsed, mode, command, action) {
|
|
1805
|
+
const target = parseArtifactTarget(parsed.positionals[0], command, "Pass an artifact ID or share URL.");
|
|
1806
|
+
if (target.error) return writeFailure(command, target.error, mode, 1);
|
|
1807
|
+
const threadId = requiredOption(parsed.options.threadId, "--thread-id is required.", "Run comments list and retry with a listed thread_id.");
|
|
1808
|
+
if (threadId.error) return writeFailure(command, threadId.error, mode, 1);
|
|
1809
|
+
const result = await postCommentAction(parsed, command, target.artifactId, {
|
|
1810
|
+
action,
|
|
1811
|
+
thread_id: threadId.value
|
|
1812
|
+
}, mode);
|
|
1813
|
+
if (!result) return;
|
|
1814
|
+
const responseThreadId = configString(result.thread_id);
|
|
1815
|
+
if (!responseThreadId || result.thread === void 0) return writeFailure(command, serviceError("Comment was changed but the response had no thread."), mode, 1);
|
|
1816
|
+
writeSuccess(command, {
|
|
1817
|
+
artifact_id: target.artifactId,
|
|
1818
|
+
share_url: configString(result.share_url),
|
|
1819
|
+
thread_id: responseThreadId,
|
|
1820
|
+
thread: result.thread
|
|
1821
|
+
}, mode);
|
|
1822
|
+
}
|
|
1823
|
+
async function postCommentAction(parsed, command, artifactId, payload, mode) {
|
|
1824
|
+
const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
|
|
1825
|
+
if (!credential.ok) {
|
|
1826
|
+
writeFailure(command, credential.error, mode, 1);
|
|
1827
|
+
return null;
|
|
1828
|
+
}
|
|
1829
|
+
const request = await requestConfig(parsed.options);
|
|
1830
|
+
if (request.error) {
|
|
1831
|
+
writeFailure(command, request.error, mode, 1);
|
|
1832
|
+
return null;
|
|
1833
|
+
}
|
|
1834
|
+
const result = await apiPost(`/api/cli/artifacts/${encodeURIComponent(artifactId)}/comments`, credential.token, payload, parsed.options, request.init, { artifactTarget: true });
|
|
1835
|
+
if (result.error) {
|
|
1836
|
+
writeFailure(command, result.error, mode, 1);
|
|
1837
|
+
return null;
|
|
1838
|
+
}
|
|
1839
|
+
if (result.body === null) {
|
|
1840
|
+
writeFailure(command, serviceError("Comment was changed but the response was empty."), mode, 1);
|
|
1841
|
+
return null;
|
|
1842
|
+
}
|
|
1843
|
+
return result.body;
|
|
1844
|
+
}
|
|
1845
|
+
function requiredOption(value, message, hint) {
|
|
1846
|
+
if (!value || !value.trim()) return { error: validationError(message, hint) };
|
|
1847
|
+
return { value: value.trim() };
|
|
1848
|
+
}
|
|
1849
|
+
//#endregion
|
|
1850
|
+
//#region src/command-runners/delete.ts
|
|
1851
|
+
async function runDelete(parsed, mode) {
|
|
1852
|
+
const command = "delete";
|
|
1853
|
+
const target = parseArtifactTarget(parsed.positionals[0], command, "Pass an artifact ID or share URL to delete.");
|
|
1854
|
+
if (target.error) return writeFailure(command, target.error, mode, 1);
|
|
1855
|
+
const artifactId = target.artifactId;
|
|
1856
|
+
const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
|
|
1857
|
+
if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
|
|
1858
|
+
const request = await requestConfig(parsed.options);
|
|
1859
|
+
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
1860
|
+
const result = await apiDelete(`/api/cli/artifacts/${encodeURIComponent(artifactId)}`, credential.token, parsed.options, request.init, {
|
|
1861
|
+
authenticated: true,
|
|
1862
|
+
artifactTarget: true
|
|
1863
|
+
});
|
|
1864
|
+
if (result.error) return writeFailure(command, result.error, mode, 1);
|
|
1865
|
+
const body = result.body;
|
|
1866
|
+
if (!deleteSuccessFields(body)) return writeFailure(command, serviceError("Delete succeeded but the response did not include deletion metadata."), mode, 1);
|
|
1867
|
+
return writeSuccess(command, body, mode);
|
|
1868
|
+
}
|
|
1586
1869
|
//#endregion
|
|
1587
1870
|
//#region src/command-runners/doctor.ts
|
|
1588
1871
|
const LOGIN_COMMAND = `${CLI_INVOCATION} login`;
|
|
@@ -2279,6 +2562,104 @@ async function runDownload(parsed, mode, isRetry = false) {
|
|
|
2279
2562
|
}, mode);
|
|
2280
2563
|
}
|
|
2281
2564
|
//#endregion
|
|
2565
|
+
//#region src/command-runners/edit.ts
|
|
2566
|
+
async function runEdit(parsed, mode) {
|
|
2567
|
+
const command = "edit";
|
|
2568
|
+
const target = parseArtifactTarget(parsed.positionals[0], command, "Pass an artifact ID or share URL to edit.");
|
|
2569
|
+
if (target.error) return writeFailure(command, target.error, mode, 1);
|
|
2570
|
+
const payload = buildEditPayload(parsed);
|
|
2571
|
+
if (payload.error) return writeFailure(command, payload.error, mode, 1);
|
|
2572
|
+
const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
|
|
2573
|
+
if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
|
|
2574
|
+
const request = await requestConfig(parsed.options);
|
|
2575
|
+
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
2576
|
+
const result = await apiPost(`/api/cli/shareables/${encodeURIComponent(target.artifactId)}/edit`, credential.token, payload.body, parsed.options, request.init, {
|
|
2577
|
+
artifactTarget: true,
|
|
2578
|
+
editSettings: true
|
|
2579
|
+
});
|
|
2580
|
+
if (result.error) return writeFailure(command, result.error, mode, 1);
|
|
2581
|
+
const data = parseEditData(result.body);
|
|
2582
|
+
if (!data) return writeFailure(command, serviceError("Edit succeeded but the response did not include edit data."), mode, 1);
|
|
2583
|
+
writeSuccess(command, data, mode);
|
|
2584
|
+
}
|
|
2585
|
+
function buildEditPayload(parsed) {
|
|
2586
|
+
const body = {};
|
|
2587
|
+
let hasChange = false;
|
|
2588
|
+
if (parsed.options.title !== void 0) {
|
|
2589
|
+
body.title = parsed.options.title;
|
|
2590
|
+
hasChange = true;
|
|
2591
|
+
}
|
|
2592
|
+
if (parsed.options.visibility !== void 0) {
|
|
2593
|
+
const visibility = parsed.options.visibility.trim();
|
|
2594
|
+
if (visibility !== "private" && visibility !== "workspace") return { error: validationError("--visibility must be private or workspace.", "Retry with --visibility private or --visibility workspace.") };
|
|
2595
|
+
body.visibility = visibility;
|
|
2596
|
+
hasChange = true;
|
|
2597
|
+
}
|
|
2598
|
+
const addEmails = normalizedEmailOptions$1(parsed.options.grantEmail);
|
|
2599
|
+
if (addEmails.error) return { error: addEmails.error };
|
|
2600
|
+
if (parsed.options.grantEmail !== void 0) {
|
|
2601
|
+
body.add_emails = addEmails.values;
|
|
2602
|
+
hasChange = true;
|
|
2603
|
+
}
|
|
2604
|
+
const removeEmails = normalizedEmailOptions$1(parsed.options.revokeEmail);
|
|
2605
|
+
if (removeEmails.error) return { error: removeEmails.error };
|
|
2606
|
+
if (parsed.options.revokeEmail !== void 0) {
|
|
2607
|
+
body.remove_emails = removeEmails.values;
|
|
2608
|
+
hasChange = true;
|
|
2609
|
+
}
|
|
2610
|
+
if (hasProjectIdHomeConflict(parsed.options)) return { error: validationError("Edit destination is conflicting.", "Choose either --project-id <id> or --home.", "destination_conflict") };
|
|
2611
|
+
if (parsed.options.home) {
|
|
2612
|
+
body.destination = "home";
|
|
2613
|
+
hasChange = true;
|
|
2614
|
+
} else if (parsed.options.projectId !== void 0) {
|
|
2615
|
+
const projectId = parsed.options.projectId.trim();
|
|
2616
|
+
if (!projectId) return { error: validationError("--project-id must not be blank.", "Retry with an active project id from projects list, or use --home.", "invalid_destination") };
|
|
2617
|
+
body.destination = { project_id: projectId };
|
|
2618
|
+
hasChange = true;
|
|
2619
|
+
}
|
|
2620
|
+
if (!hasChange) return { error: validationError("At least one edit option is required.", "Pass --title, --visibility, --grant-email, --revoke-email, --project-id, or --home.") };
|
|
2621
|
+
return { body };
|
|
2622
|
+
}
|
|
2623
|
+
function normalizedEmailOptions$1(value) {
|
|
2624
|
+
const values = arrayOption(value).map((email) => email.trim()).filter(Boolean);
|
|
2625
|
+
if (value !== void 0 && values.length === 0) return { error: validationError("Email option must not be blank.", "Pass a non-empty email address.") };
|
|
2626
|
+
return { values };
|
|
2627
|
+
}
|
|
2628
|
+
function parseEditData(body) {
|
|
2629
|
+
if (!isRecord(body)) return null;
|
|
2630
|
+
const artifact = body.artifact;
|
|
2631
|
+
const destination = body.destination;
|
|
2632
|
+
const share = body.share;
|
|
2633
|
+
if (!isRecord(artifact) || !isRecord(destination) || !isRecord(share)) return null;
|
|
2634
|
+
if (typeof artifact.id !== "string" || typeof body.title !== "string" || typeof destination.type !== "string" || typeof share.visibility !== "string") return null;
|
|
2635
|
+
const base = {
|
|
2636
|
+
artifact: {
|
|
2637
|
+
id: artifact.id,
|
|
2638
|
+
url: typeof artifact.url === "string" ? artifact.url : null
|
|
2639
|
+
},
|
|
2640
|
+
title: body.title,
|
|
2641
|
+
share: { visibility: share.visibility }
|
|
2642
|
+
};
|
|
2643
|
+
if (destination.type === "project") {
|
|
2644
|
+
if (typeof destination.project_id !== "string") return null;
|
|
2645
|
+
return {
|
|
2646
|
+
...base,
|
|
2647
|
+
destination: {
|
|
2648
|
+
type: "project",
|
|
2649
|
+
project_id: destination.project_id
|
|
2650
|
+
}
|
|
2651
|
+
};
|
|
2652
|
+
}
|
|
2653
|
+
if (destination.type === "home" && destination.project_id === null) return {
|
|
2654
|
+
...base,
|
|
2655
|
+
destination: {
|
|
2656
|
+
type: "home",
|
|
2657
|
+
project_id: null
|
|
2658
|
+
}
|
|
2659
|
+
};
|
|
2660
|
+
return null;
|
|
2661
|
+
}
|
|
2662
|
+
//#endregion
|
|
2282
2663
|
//#region src/git-exclude.ts
|
|
2283
2664
|
async function ensureGitExclude(cwd) {
|
|
2284
2665
|
const git = await findGitDir(cwd);
|
|
@@ -2379,6 +2760,67 @@ function initData(written, config, resolved) {
|
|
|
2379
2760
|
};
|
|
2380
2761
|
}
|
|
2381
2762
|
//#endregion
|
|
2763
|
+
//#region src/command-runners/move.ts
|
|
2764
|
+
async function runMove(parsed, mode) {
|
|
2765
|
+
const command = "move";
|
|
2766
|
+
const target = parseArtifactTarget(parsed.positionals[0], command, "Pass an artifact ID or share URL to move.");
|
|
2767
|
+
if (target.error) return writeFailure(command, target.error, mode, 1);
|
|
2768
|
+
parsed.options.projectId;
|
|
2769
|
+
const projectId = parsed.options.projectId?.trim() ?? "";
|
|
2770
|
+
const home = Boolean(parsed.options.home);
|
|
2771
|
+
const destinationConflict = hasProjectIdHomeConflict(parsed.options);
|
|
2772
|
+
if (destinationConflict || !projectId && !home) return writeFailure(command, validationError("Move destination is required.", "Choose exactly one destination: --project-id <id> or --home.", destinationConflict ? "destination_conflict" : "invalid_destination"), mode, 1);
|
|
2773
|
+
const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
|
|
2774
|
+
if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
|
|
2775
|
+
const request = await requestConfig(parsed.options);
|
|
2776
|
+
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
2777
|
+
const result = await apiPost(`/api/cli/shareables/${encodeURIComponent(target.artifactId)}/move`, credential.token, { destination: home ? "home" : { project_id: projectId } }, parsed.options, request.init, { artifactTarget: true });
|
|
2778
|
+
if (result.error) return writeFailure(command, result.error, mode, 1);
|
|
2779
|
+
const data = parseMoveData(result.body);
|
|
2780
|
+
if (!data) return writeFailure(command, serviceError("Move succeeded but the response did not include move data."), mode, 1);
|
|
2781
|
+
writeSuccess(command, data, mode);
|
|
2782
|
+
}
|
|
2783
|
+
function parseMoveData(body) {
|
|
2784
|
+
if (!isRecord(body)) return null;
|
|
2785
|
+
const artifact = body.artifact;
|
|
2786
|
+
const destination = body.destination;
|
|
2787
|
+
const share = body.share;
|
|
2788
|
+
if (!isRecord(artifact) || !isRecord(destination) || !isRecord(share)) return null;
|
|
2789
|
+
if (typeof artifact.id !== "string" || typeof destination.type !== "string" || typeof share.visibility !== "string" || typeof share.project_audience_may_change !== "boolean") return null;
|
|
2790
|
+
if (destination.type === "project") {
|
|
2791
|
+
if (typeof destination.project_id !== "string") return null;
|
|
2792
|
+
return {
|
|
2793
|
+
artifact: {
|
|
2794
|
+
id: artifact.id,
|
|
2795
|
+
url: typeof artifact.url === "string" ? artifact.url : null
|
|
2796
|
+
},
|
|
2797
|
+
destination: {
|
|
2798
|
+
type: "project",
|
|
2799
|
+
project_id: destination.project_id
|
|
2800
|
+
},
|
|
2801
|
+
share: {
|
|
2802
|
+
visibility: share.visibility,
|
|
2803
|
+
project_audience_may_change: share.project_audience_may_change
|
|
2804
|
+
}
|
|
2805
|
+
};
|
|
2806
|
+
}
|
|
2807
|
+
if (destination.type === "home" && destination.project_id === null) return {
|
|
2808
|
+
artifact: {
|
|
2809
|
+
id: artifact.id,
|
|
2810
|
+
url: typeof artifact.url === "string" ? artifact.url : null
|
|
2811
|
+
},
|
|
2812
|
+
destination: {
|
|
2813
|
+
type: "home",
|
|
2814
|
+
project_id: null
|
|
2815
|
+
},
|
|
2816
|
+
share: {
|
|
2817
|
+
visibility: share.visibility,
|
|
2818
|
+
project_audience_may_change: share.project_audience_may_change
|
|
2819
|
+
}
|
|
2820
|
+
};
|
|
2821
|
+
return null;
|
|
2822
|
+
}
|
|
2823
|
+
//#endregion
|
|
2382
2824
|
//#region src/command-runners/profiles.ts
|
|
2383
2825
|
async function readStdinToken() {
|
|
2384
2826
|
if (process.stdin.isTTY === true) return "";
|
|
@@ -2495,6 +2937,117 @@ async function runProjectsList(parsed, mode) {
|
|
|
2495
2937
|
}, mode);
|
|
2496
2938
|
if (!mode.json && projects.length === 0) writeText("No projects yet. Create one on the web, then publish with --project-id.\n");
|
|
2497
2939
|
}
|
|
2940
|
+
async function runProjectsCreate(parsed, mode) {
|
|
2941
|
+
const command = "projects create";
|
|
2942
|
+
const name = parsed.positionals[0]?.trim();
|
|
2943
|
+
if (!name) return writeFailure(command, validationError("Project name is required.", "Pass a project name: projects create <name>."), mode, 1);
|
|
2944
|
+
const visibility = parsed.options.visibility;
|
|
2945
|
+
if (visibility !== void 0 && visibility !== "workspace" && visibility !== "private") return writeFailure(command, validationError("--visibility must be workspace or private.", "Retry with --visibility workspace or --visibility private."), mode, 1);
|
|
2946
|
+
const projectConfig = await resolveProjectConfig();
|
|
2947
|
+
const credential = await resolveCredential(parsed.options, projectConfig);
|
|
2948
|
+
if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
|
|
2949
|
+
const request = await requestConfig(parsed.options);
|
|
2950
|
+
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
2951
|
+
const result = await apiPost("/api/cli/projects", credential.token, {
|
|
2952
|
+
name,
|
|
2953
|
+
description: parsed.options.description ?? null,
|
|
2954
|
+
base_visibility: visibility ?? null
|
|
2955
|
+
}, parsed.options, request.init);
|
|
2956
|
+
if (result.error) return writeFailure(command, result.error, mode, 1);
|
|
2957
|
+
const project = isRecord(result.body?.project) ? result.body.project : null;
|
|
2958
|
+
const id = configString(project?.id);
|
|
2959
|
+
if (!id) return writeFailure(command, serviceError("Project create succeeded but no project id was returned."), mode, 1);
|
|
2960
|
+
writeSuccess(command, {
|
|
2961
|
+
project: {
|
|
2962
|
+
id,
|
|
2963
|
+
name: configString(project?.name),
|
|
2964
|
+
description: configString(project?.description),
|
|
2965
|
+
base_visibility: configString(project?.base_visibility)
|
|
2966
|
+
},
|
|
2967
|
+
next_command: `npx --yes @artifactshare/cli publish <path> --project-id ${id} --json`
|
|
2968
|
+
}, mode);
|
|
2969
|
+
}
|
|
2970
|
+
async function runProjectsEdit(parsed, mode) {
|
|
2971
|
+
const command = "projects edit";
|
|
2972
|
+
const projectId = parsed.positionals[0]?.trim();
|
|
2973
|
+
if (!projectId) return writeFailure(command, validationError("Project id is required.", "Pass a project id: projects edit <id>."), mode, 1);
|
|
2974
|
+
const payload = buildProjectsEditPayload(parsed);
|
|
2975
|
+
if (payload.error) return writeFailure(command, payload.error, mode, 1);
|
|
2976
|
+
const projectConfig = await resolveProjectConfig();
|
|
2977
|
+
const credential = await resolveCredential(parsed.options, projectConfig);
|
|
2978
|
+
if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
|
|
2979
|
+
const request = await requestConfig(parsed.options);
|
|
2980
|
+
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
2981
|
+
const result = await apiPost(`/api/cli/projects/${encodeURIComponent(projectId)}`, credential.token, payload.body, parsed.options, request.init, { projectTarget: true });
|
|
2982
|
+
if (result.error) return writeFailure(command, result.error, mode, 1);
|
|
2983
|
+
const data = parseProjectsEditData(result.body);
|
|
2984
|
+
if (!data) return writeFailure(command, serviceError("Project edit succeeded but the response did not include project data."), mode, 1);
|
|
2985
|
+
writeSuccess(command, data, mode);
|
|
2986
|
+
}
|
|
2987
|
+
function buildProjectsEditPayload(parsed) {
|
|
2988
|
+
const body = {};
|
|
2989
|
+
let hasChange = false;
|
|
2990
|
+
if (parsed.options.name !== void 0) {
|
|
2991
|
+
const name = parsed.options.name.trim();
|
|
2992
|
+
if (!name) return { error: validationError("--name must not be blank.", "Retry with a non-empty project name.") };
|
|
2993
|
+
body.name = name;
|
|
2994
|
+
hasChange = true;
|
|
2995
|
+
}
|
|
2996
|
+
if (parsed.options.description !== void 0) {
|
|
2997
|
+
body.description = parsed.options.description;
|
|
2998
|
+
hasChange = true;
|
|
2999
|
+
}
|
|
3000
|
+
if (parsed.options.visibility !== void 0) {
|
|
3001
|
+
const visibility = parsed.options.visibility.trim();
|
|
3002
|
+
if (visibility !== "workspace" && visibility !== "private") return { error: validationError("--visibility must be workspace or private.", "Retry with --visibility workspace or --visibility private.") };
|
|
3003
|
+
body.base_visibility = visibility;
|
|
3004
|
+
hasChange = true;
|
|
3005
|
+
}
|
|
3006
|
+
const addEmails = normalizedEmailOptions(parsed.options.addEmail);
|
|
3007
|
+
if (addEmails.error) return { error: addEmails.error };
|
|
3008
|
+
if (parsed.options.addEmail !== void 0) {
|
|
3009
|
+
body.add_emails = addEmails.values;
|
|
3010
|
+
hasChange = true;
|
|
3011
|
+
}
|
|
3012
|
+
const removeEmails = normalizedEmailOptions(parsed.options.removeEmail);
|
|
3013
|
+
if (removeEmails.error) return { error: removeEmails.error };
|
|
3014
|
+
if (parsed.options.removeEmail !== void 0) {
|
|
3015
|
+
body.remove_emails = removeEmails.values;
|
|
3016
|
+
hasChange = true;
|
|
3017
|
+
}
|
|
3018
|
+
if (parsed.options.archive && parsed.options.unarchive) return { error: validationError("Archive state is conflicting.", "Choose either --archive or --unarchive.") };
|
|
3019
|
+
if (parsed.options.archive) {
|
|
3020
|
+
body.archived = true;
|
|
3021
|
+
hasChange = true;
|
|
3022
|
+
}
|
|
3023
|
+
if (parsed.options.unarchive) {
|
|
3024
|
+
body.archived = false;
|
|
3025
|
+
hasChange = true;
|
|
3026
|
+
}
|
|
3027
|
+
if (!hasChange) return { error: validationError("At least one project edit option is required.", "Pass --name, --description, --visibility, --add-email, --remove-email, --archive, or --unarchive.") };
|
|
3028
|
+
return { body };
|
|
3029
|
+
}
|
|
3030
|
+
function normalizedEmailOptions(value) {
|
|
3031
|
+
const values = arrayOption(value).map((email) => email.trim()).filter(Boolean);
|
|
3032
|
+
if (value !== void 0 && values.length === 0) return { error: validationError("Email option must not be blank.", "Pass a non-empty email address.") };
|
|
3033
|
+
return { values };
|
|
3034
|
+
}
|
|
3035
|
+
function parseProjectsEditData(body) {
|
|
3036
|
+
if (!isRecord(body) || !isRecord(body.project)) return null;
|
|
3037
|
+
const { project } = body;
|
|
3038
|
+
if (typeof project.id !== "string" || typeof project.archived !== "boolean" || !Array.isArray(body.audience) || body.audience.some((email) => typeof email !== "string")) return null;
|
|
3039
|
+
return {
|
|
3040
|
+
project: {
|
|
3041
|
+
id: project.id,
|
|
3042
|
+
name: configString(project.name),
|
|
3043
|
+
description: configString(project.description),
|
|
3044
|
+
base_visibility: configString(project.base_visibility),
|
|
3045
|
+
file_count: typeof project.file_count === "number" ? project.file_count : null,
|
|
3046
|
+
archived: project.archived
|
|
3047
|
+
},
|
|
3048
|
+
audience: body.audience
|
|
3049
|
+
};
|
|
3050
|
+
}
|
|
2498
3051
|
//#endregion
|
|
2499
3052
|
//#region src/command-runners/publish.ts
|
|
2500
3053
|
const MAX_PUBLISH_KEY_LENGTH = 128;
|
|
@@ -2981,6 +3534,14 @@ async function updateRunner(ctx) {
|
|
|
2981
3534
|
const parsed = parsedArgsFromContext("update", ctx);
|
|
2982
3535
|
return await runUpdate(parsed, outputMode(parsed.options));
|
|
2983
3536
|
}
|
|
3537
|
+
async function editRunner(ctx) {
|
|
3538
|
+
const parsed = parsedArgsFromContext("edit", ctx);
|
|
3539
|
+
return await runEdit(parsed, outputMode(parsed.options));
|
|
3540
|
+
}
|
|
3541
|
+
async function deleteRunner(ctx) {
|
|
3542
|
+
const parsed = parsedArgsFromContext("delete", ctx);
|
|
3543
|
+
return await runDelete(parsed, outputMode(parsed.options));
|
|
3544
|
+
}
|
|
2984
3545
|
async function resolveRunner(ctx) {
|
|
2985
3546
|
const parsed = parsedArgsFromContext("resolve", ctx);
|
|
2986
3547
|
return await runResolve(parsed, outputMode(parsed.options));
|
|
@@ -2989,10 +3550,18 @@ async function downloadRunner(ctx) {
|
|
|
2989
3550
|
const parsed = parsedArgsFromContext("download", ctx);
|
|
2990
3551
|
return await runDownload(parsed, outputMode(parsed.options));
|
|
2991
3552
|
}
|
|
3553
|
+
async function moveRunner(ctx) {
|
|
3554
|
+
const parsed = parsedArgsFromContext("move", ctx);
|
|
3555
|
+
return await runMove(parsed, outputMode(parsed.options));
|
|
3556
|
+
}
|
|
2992
3557
|
async function artifactsGetRunner(ctx) {
|
|
2993
3558
|
const parsed = parsedArgsFromContext("artifacts get", ctx);
|
|
2994
3559
|
return await runArtifactsGet(parsed, outputMode(parsed.options));
|
|
2995
3560
|
}
|
|
3561
|
+
async function artifactsListRunner(ctx) {
|
|
3562
|
+
const parsed = parsedArgsFromContext("artifacts list", ctx);
|
|
3563
|
+
return await runArtifactsList(parsed, outputMode(parsed.options));
|
|
3564
|
+
}
|
|
2996
3565
|
async function commentsListRunner(ctx) {
|
|
2997
3566
|
const parsed = parsedArgsFromContext("comments list", ctx);
|
|
2998
3567
|
return await runCommentsList(parsed, outputMode(parsed.options));
|
|
@@ -3001,6 +3570,22 @@ async function commentsPostRunner(ctx) {
|
|
|
3001
3570
|
const parsed = parsedArgsFromContext("comments post", ctx);
|
|
3002
3571
|
return await runCommentsPost(parsed, outputMode(parsed.options));
|
|
3003
3572
|
}
|
|
3573
|
+
async function commentsEditRunner(ctx) {
|
|
3574
|
+
const parsed = parsedArgsFromContext("comments edit", ctx);
|
|
3575
|
+
return await runCommentsEdit(parsed, outputMode(parsed.options));
|
|
3576
|
+
}
|
|
3577
|
+
async function commentsResolveRunner(ctx) {
|
|
3578
|
+
const parsed = parsedArgsFromContext("comments resolve", ctx);
|
|
3579
|
+
return await runCommentsResolve(parsed, outputMode(parsed.options));
|
|
3580
|
+
}
|
|
3581
|
+
async function commentsReopenRunner(ctx) {
|
|
3582
|
+
const parsed = parsedArgsFromContext("comments reopen", ctx);
|
|
3583
|
+
return await runCommentsReopen(parsed, outputMode(parsed.options));
|
|
3584
|
+
}
|
|
3585
|
+
async function commentsDeleteRunner(ctx) {
|
|
3586
|
+
const parsed = parsedArgsFromContext("comments delete", ctx);
|
|
3587
|
+
return await runCommentsDelete(parsed, outputMode(parsed.options));
|
|
3588
|
+
}
|
|
3004
3589
|
async function requestAccessRunner(ctx) {
|
|
3005
3590
|
const parsed = parsedArgsFromContext("request-access", ctx);
|
|
3006
3591
|
return await runRequestAccess(parsed, outputMode(parsed.options));
|
|
@@ -3026,6 +3611,14 @@ async function projectsListRunner(ctx) {
|
|
|
3026
3611
|
const parsed = parsedArgsFromContext("projects list", ctx);
|
|
3027
3612
|
return await runProjectsList(parsed, outputMode(parsed.options));
|
|
3028
3613
|
}
|
|
3614
|
+
async function projectsCreateRunner(ctx) {
|
|
3615
|
+
const parsed = parsedArgsFromContext("projects create", ctx);
|
|
3616
|
+
return await runProjectsCreate(parsed, outputMode(parsed.options));
|
|
3617
|
+
}
|
|
3618
|
+
async function projectsEditRunner(ctx) {
|
|
3619
|
+
const parsed = parsedArgsFromContext("projects edit", ctx);
|
|
3620
|
+
return await runProjectsEdit(parsed, outputMode(parsed.options));
|
|
3621
|
+
}
|
|
3029
3622
|
async function initRunner(ctx) {
|
|
3030
3623
|
const parsed = parsedArgsFromContext("init", ctx);
|
|
3031
3624
|
return await runInit(parsed, outputMode(parsed.options));
|
|
@@ -3099,8 +3692,11 @@ async function runGunshi(argv) {
|
|
|
3099
3692
|
login: lazyCommand(loginDefinition, loginRunner),
|
|
3100
3693
|
publish: lazyCommand(publishDefinition, publishRunner),
|
|
3101
3694
|
update: lazyCommand(updateDefinition, updateRunner),
|
|
3695
|
+
edit: lazyCommand(editDefinition, editRunner),
|
|
3696
|
+
delete: lazyCommand(deleteDefinition, deleteRunner),
|
|
3102
3697
|
resolve: lazyCommand(resolveDefinition, resolveRunner),
|
|
3103
3698
|
download: lazyCommand(downloadDefinition, downloadRunner),
|
|
3699
|
+
move: lazyCommand(moveDefinition, moveRunner),
|
|
3104
3700
|
artifacts: artifactsDefinition,
|
|
3105
3701
|
comments: commentsDefinition,
|
|
3106
3702
|
"request-access": lazyCommand(requestAccessDefinition, requestAccessRunner),
|
|
@@ -3158,7 +3754,13 @@ const entryCommand = define({
|
|
|
3158
3754
|
args: commonArgs,
|
|
3159
3755
|
examples: `npx --yes @artifactshare/cli publish <path> --project-id <id> --json
|
|
3160
3756
|
npx --yes @artifactshare/cli update <artifact-id-or-url> <path> --json
|
|
3757
|
+
npx --yes @artifactshare/cli edit <artifact-id-or-url> --title "New title" --json
|
|
3758
|
+
npx --yes @artifactshare/cli delete <artifact-id-or-url> --json
|
|
3161
3759
|
npx --yes @artifactshare/cli resolve <url-id-or-title> --json
|
|
3760
|
+
npx --yes @artifactshare/cli projects create "Launch review" --json
|
|
3761
|
+
npx --yes @artifactshare/cli projects edit <id> --add-email viewer@example.com --json
|
|
3762
|
+
npx --yes @artifactshare/cli move <artifact-id-or-url> --project-id <id> --json
|
|
3763
|
+
npx --yes @artifactshare/cli artifacts list --json
|
|
3162
3764
|
npx --yes @artifactshare/cli artifacts get <artifact-id-or-url> --json
|
|
3163
3765
|
npx --yes @artifactshare/cli comments list <artifact-id-or-url> --json
|
|
3164
3766
|
npx --yes @artifactshare/cli comments post <artifact-id-or-url> --body "<text>" --json
|
|
@@ -3182,6 +3784,7 @@ Authentication:
|
|
|
3182
3784
|
Common failures:
|
|
3183
3785
|
auth_required Use ${TOKEN_ENV_VAR} or ${TOKEN_OPTION}; tokens are issued at ${DEFAULT_BASE_URL}/settings/tokens
|
|
3184
3786
|
destination_required Add --project-id, configure .artifactshare/config.json, or pass --home
|
|
3787
|
+
invalid_destination Choose --project-id <id> or --home
|
|
3185
3788
|
target_not_found Use an artifact ID, share URL, or sandbox URL
|
|
3186
3789
|
upload_not_allowed Upload access is limited; run request-access to join the waitlist`,
|
|
3187
3790
|
run: () => {}
|
|
@@ -3225,7 +3828,7 @@ const publishDefinition = define({
|
|
|
3225
3828
|
home: {
|
|
3226
3829
|
type: "boolean",
|
|
3227
3830
|
toKebab: true,
|
|
3228
|
-
description: "Publish
|
|
3831
|
+
description: "Publish to home instead of a project"
|
|
3229
3832
|
},
|
|
3230
3833
|
visibility: {
|
|
3231
3834
|
type: "string",
|
|
@@ -3283,6 +3886,89 @@ Common failures:
|
|
|
3283
3886
|
file_too_large Reduce file or directory size and retry
|
|
3284
3887
|
validation_failed Check file type (.html / .md for single files) and directory layout`
|
|
3285
3888
|
});
|
|
3889
|
+
const editDefinition = define({
|
|
3890
|
+
name: "edit",
|
|
3891
|
+
description: "Edit artifact title, sharing, or project placement.",
|
|
3892
|
+
toKebab: true,
|
|
3893
|
+
args: {
|
|
3894
|
+
...commonArgs,
|
|
3895
|
+
artifactIdOrUrl: {
|
|
3896
|
+
type: "positional",
|
|
3897
|
+
toKebab: true,
|
|
3898
|
+
description: "Artifact ID, /a/<id> share URL, or <id>.sandbox.* URL"
|
|
3899
|
+
},
|
|
3900
|
+
title: {
|
|
3901
|
+
type: "string",
|
|
3902
|
+
toKebab: true,
|
|
3903
|
+
description: "Set display title; pass an empty value to clear it"
|
|
3904
|
+
},
|
|
3905
|
+
visibility: {
|
|
3906
|
+
type: "string",
|
|
3907
|
+
toKebab: true,
|
|
3908
|
+
description: "private or workspace"
|
|
3909
|
+
},
|
|
3910
|
+
grantEmail: {
|
|
3911
|
+
type: "string",
|
|
3912
|
+
multiple: true,
|
|
3913
|
+
toKebab: true,
|
|
3914
|
+
description: "Add an explicit viewer; repeat for multiple viewers"
|
|
3915
|
+
},
|
|
3916
|
+
revokeEmail: {
|
|
3917
|
+
type: "string",
|
|
3918
|
+
multiple: true,
|
|
3919
|
+
toKebab: true,
|
|
3920
|
+
description: "Remove an explicit viewer; repeat for multiple viewers"
|
|
3921
|
+
},
|
|
3922
|
+
projectId: {
|
|
3923
|
+
type: "string",
|
|
3924
|
+
toKebab: true,
|
|
3925
|
+
description: "Move into this project"
|
|
3926
|
+
},
|
|
3927
|
+
home: {
|
|
3928
|
+
type: "boolean",
|
|
3929
|
+
toKebab: true,
|
|
3930
|
+
description: "Move back to the owner home area"
|
|
3931
|
+
}
|
|
3932
|
+
},
|
|
3933
|
+
examples: `npx --yes @artifactshare/cli edit abc123def4 --title "Launch plan" --json
|
|
3934
|
+
npx --yes @artifactshare/cli edit abc123def4 --visibility private --grant-email viewer@example.com --json
|
|
3935
|
+
npx --yes @artifactshare/cli edit https://artifactshare.com/a/abc123def4 --project-id prj123 --json
|
|
3936
|
+
npx --yes @artifactshare/cli edit abc123def4 --home --json
|
|
3937
|
+
|
|
3938
|
+
Edit changes artifact settings without adding a new version. Use update to replace content.
|
|
3939
|
+
Move remains available for placement-only automation; edit is the main command for post-publish settings.
|
|
3940
|
+
|
|
3941
|
+
Common failures:
|
|
3942
|
+
auth_required Set ARTIFACTSHARE_TOKEN before edit
|
|
3943
|
+
target_not_found Retry with an artifact ID, share URL, or sandbox URL
|
|
3944
|
+
destination_conflict Choose either --project-id or --home
|
|
3945
|
+
invalid_destination Use an active project id from projects list, or --home
|
|
3946
|
+
workspace_unavailable Use --visibility private for personal Google accounts
|
|
3947
|
+
too_many_grants Remove viewers or grant fewer email addresses`
|
|
3948
|
+
});
|
|
3949
|
+
const deleteDefinition = define({
|
|
3950
|
+
name: "delete",
|
|
3951
|
+
description: "Permanently delete an artifact you published.",
|
|
3952
|
+
toKebab: true,
|
|
3953
|
+
args: {
|
|
3954
|
+
...commonArgs,
|
|
3955
|
+
artifactIdOrUrl: {
|
|
3956
|
+
type: "positional",
|
|
3957
|
+
toKebab: true,
|
|
3958
|
+
description: "Artifact ID, /a/<id> share URL, or <id>.sandbox.* URL"
|
|
3959
|
+
}
|
|
3960
|
+
},
|
|
3961
|
+
examples: `npx --yes @artifactshare/cli delete abc123def4 --json
|
|
3962
|
+
npx --yes @artifactshare/cli delete https://artifactshare.com/a/abc123def4 --json
|
|
3963
|
+
|
|
3964
|
+
Delete permanently removes the artifact and its version history. This cannot be undone.
|
|
3965
|
+
Use resolve first when a user gives a title or project name, then pass the id here.
|
|
3966
|
+
|
|
3967
|
+
Common failures:
|
|
3968
|
+
auth_required Set ARTIFACTSHARE_TOKEN before delete
|
|
3969
|
+
target_not_found Retry with an artifact ID, share URL, or sandbox URL
|
|
3970
|
+
service_error Retry later if deletion could not complete`
|
|
3971
|
+
});
|
|
3286
3972
|
const resolveDefinition = define({
|
|
3287
3973
|
name: "resolve",
|
|
3288
3974
|
description: "Find artifact, version, and project candidates before writing.",
|
|
@@ -3339,35 +4025,65 @@ Common failures:
|
|
|
3339
4025
|
output_exists Choose another --output path or pass --force
|
|
3340
4026
|
validation_failed Check --output and downloaded file paths`
|
|
3341
4027
|
});
|
|
3342
|
-
const
|
|
3343
|
-
name: "
|
|
3344
|
-
description: "
|
|
4028
|
+
const moveDefinition = define({
|
|
4029
|
+
name: "move",
|
|
4030
|
+
description: "Move an artifact into a project or back home.",
|
|
3345
4031
|
toKebab: true,
|
|
3346
|
-
args:
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
},
|
|
3358
|
-
offset: {
|
|
3359
|
-
type: "string",
|
|
3360
|
-
toKebab: true,
|
|
3361
|
-
description: "Character offset for continuing a truncated read"
|
|
3362
|
-
},
|
|
3363
|
-
include: {
|
|
3364
|
-
type: "string",
|
|
3365
|
-
multiple: true,
|
|
3366
|
-
toKebab: true,
|
|
3367
|
-
description: "Extra data to include: versions or comments"
|
|
3368
|
-
}
|
|
4032
|
+
args: {
|
|
4033
|
+
...commonArgs,
|
|
4034
|
+
artifactIdOrUrl: {
|
|
4035
|
+
type: "positional",
|
|
4036
|
+
toKebab: true,
|
|
4037
|
+
description: "Artifact ID or /a/<id> share URL"
|
|
4038
|
+
},
|
|
4039
|
+
projectId: {
|
|
4040
|
+
type: "string",
|
|
4041
|
+
toKebab: true,
|
|
4042
|
+
description: "Move into this project"
|
|
3369
4043
|
},
|
|
3370
|
-
|
|
4044
|
+
home: {
|
|
4045
|
+
type: "boolean",
|
|
4046
|
+
toKebab: true,
|
|
4047
|
+
description: "Move back to the owner home area"
|
|
4048
|
+
}
|
|
4049
|
+
},
|
|
4050
|
+
examples: `npx --yes @artifactshare/cli move abc123def4 --project-id prj123 --json
|
|
4051
|
+
npx --yes @artifactshare/cli move https://artifactshare.com/a/abc123def4 --home --json
|
|
4052
|
+
|
|
4053
|
+
Move changes the artifact destination. It does not add grants. Project visibility
|
|
4054
|
+
artifacts may change audience when moved between projects; the JSON response
|
|
4055
|
+
reports project_audience_may_change.
|
|
4056
|
+
|
|
4057
|
+
Common failures:
|
|
4058
|
+
auth_required Set ARTIFACTSHARE_TOKEN before move
|
|
4059
|
+
target_not_found Retry with an artifact ID or share URL
|
|
4060
|
+
destination_conflict Choose either --project-id or --home
|
|
4061
|
+
invalid_destination Use an active project id from projects list, or --home`
|
|
4062
|
+
});
|
|
4063
|
+
const artifactsGetDefinition = define({
|
|
4064
|
+
name: "get",
|
|
4065
|
+
description: "Read a single-file artifact source and metadata.",
|
|
4066
|
+
toKebab: true,
|
|
4067
|
+
args: {
|
|
4068
|
+
...commonArgs,
|
|
4069
|
+
artifactIdOrUrl: {
|
|
4070
|
+
type: "positional",
|
|
4071
|
+
toKebab: true,
|
|
4072
|
+
description: "Artifact ID, /a/<id> share URL, or <id>.sandbox.* URL"
|
|
4073
|
+
},
|
|
4074
|
+
offset: {
|
|
4075
|
+
type: "string",
|
|
4076
|
+
toKebab: true,
|
|
4077
|
+
description: "Character offset for continuing a truncated read"
|
|
4078
|
+
},
|
|
4079
|
+
include: {
|
|
4080
|
+
type: "string",
|
|
4081
|
+
multiple: true,
|
|
4082
|
+
toKebab: true,
|
|
4083
|
+
description: "Extra data to include: versions or comments"
|
|
4084
|
+
}
|
|
4085
|
+
},
|
|
4086
|
+
examples: `npx --yes @artifactshare/cli artifacts get abc123def4 --json
|
|
3371
4087
|
npx --yes @artifactshare/cli artifacts get https://artifactshare.com/a/abc123def4 --include versions --include comments --json
|
|
3372
4088
|
npx --yes @artifactshare/cli artifacts get abc123def4 --offset 200000 --json
|
|
3373
4089
|
|
|
@@ -3379,9 +4095,52 @@ Common failures:
|
|
|
3379
4095
|
target_not_found Retry with an artifact ID, share URL, or sandbox URL
|
|
3380
4096
|
unsupported_kind Use download for static sites or other multi-file artifacts
|
|
3381
4097
|
validation_failed Check --offset and --include values`
|
|
3382
|
-
|
|
3383
|
-
|
|
4098
|
+
});
|
|
4099
|
+
const artifactsDefinition = define({
|
|
4100
|
+
name: "artifacts",
|
|
4101
|
+
description: "Read Artifact Share artifacts.",
|
|
4102
|
+
toKebab: true,
|
|
4103
|
+
args: commonArgs,
|
|
4104
|
+
subCommands: {
|
|
4105
|
+
list: lazyCommand(define({
|
|
4106
|
+
name: "list",
|
|
4107
|
+
description: "List artifacts you published, newest first.",
|
|
4108
|
+
toKebab: true,
|
|
4109
|
+
args: {
|
|
4110
|
+
...commonArgs,
|
|
4111
|
+
projectId: {
|
|
4112
|
+
type: "string",
|
|
4113
|
+
toKebab: true,
|
|
4114
|
+
description: "Only artifacts in this project"
|
|
4115
|
+
},
|
|
4116
|
+
home: {
|
|
4117
|
+
type: "boolean",
|
|
4118
|
+
toKebab: true,
|
|
4119
|
+
description: "Only artifacts in the unfiled home area"
|
|
4120
|
+
},
|
|
4121
|
+
query: {
|
|
4122
|
+
type: "string",
|
|
4123
|
+
toKebab: true,
|
|
4124
|
+
description: "Only artifacts whose title contains this text"
|
|
4125
|
+
}
|
|
4126
|
+
},
|
|
4127
|
+
examples: `npx --yes @artifactshare/cli artifacts list --json
|
|
4128
|
+
npx --yes @artifactshare/cli artifacts list --project-id <id> --json
|
|
4129
|
+
npx --yes @artifactshare/cli artifacts list --home --query report --json
|
|
4130
|
+
|
|
4131
|
+
Use an id from this list with update, edit, move, delete, artifacts get, or comments list.
|
|
4132
|
+
|
|
4133
|
+
Common failures:
|
|
4134
|
+
auth_required Set ARTIFACTSHARE_TOKEN before artifacts list
|
|
4135
|
+
invalid_destination Run projects list, then retry with --project-id <id> or --home
|
|
4136
|
+
validation_failed Choose only one of --project-id or --home`
|
|
4137
|
+
}), artifactsListRunner),
|
|
4138
|
+
get: lazyCommand(artifactsGetDefinition, artifactsGetRunner)
|
|
4139
|
+
},
|
|
4140
|
+
examples: `npx --yes @artifactshare/cli artifacts list --json
|
|
4141
|
+
npx --yes @artifactshare/cli artifacts get <artifact-id-or-url> --json
|
|
3384
4142
|
|
|
4143
|
+
Use artifacts list to find IDs for update, edit, move, delete, artifacts get, and comments list.
|
|
3385
4144
|
Use artifacts get to read back Markdown or HTML before update.`,
|
|
3386
4145
|
run: parentCommandRunner("artifacts")
|
|
3387
4146
|
});
|
|
@@ -3457,17 +4216,115 @@ Common failures:
|
|
|
3457
4216
|
quote_not_found Copy the exact text from artifacts get
|
|
3458
4217
|
validation_failed Pass --body, and do not combine --quote with --reply-to`
|
|
3459
4218
|
});
|
|
4219
|
+
const commentThreadActionArgs = {
|
|
4220
|
+
...commonArgs,
|
|
4221
|
+
artifactIdOrUrl: {
|
|
4222
|
+
type: "positional",
|
|
4223
|
+
toKebab: true,
|
|
4224
|
+
description: "Artifact ID, /a/<id> share URL, or <id>.sandbox.* URL"
|
|
4225
|
+
},
|
|
4226
|
+
threadId: {
|
|
4227
|
+
type: "string",
|
|
4228
|
+
toKebab: true,
|
|
4229
|
+
description: "Thread id from comments list"
|
|
4230
|
+
}
|
|
4231
|
+
};
|
|
4232
|
+
const commentsEditDefinition = define({
|
|
4233
|
+
name: "edit",
|
|
4234
|
+
description: "Edit a comment message you wrote.",
|
|
4235
|
+
toKebab: true,
|
|
4236
|
+
args: {
|
|
4237
|
+
...commonArgs,
|
|
4238
|
+
artifactIdOrUrl: {
|
|
4239
|
+
type: "positional",
|
|
4240
|
+
toKebab: true,
|
|
4241
|
+
description: "Artifact ID, /a/<id> share URL, or <id>.sandbox.* URL"
|
|
4242
|
+
},
|
|
4243
|
+
messageId: {
|
|
4244
|
+
type: "string",
|
|
4245
|
+
toKebab: true,
|
|
4246
|
+
description: "Message id from comments list"
|
|
4247
|
+
},
|
|
4248
|
+
body: {
|
|
4249
|
+
type: "string",
|
|
4250
|
+
toKebab: true,
|
|
4251
|
+
description: "Updated comment text (required)"
|
|
4252
|
+
}
|
|
4253
|
+
},
|
|
4254
|
+
examples: `npx --yes @artifactshare/cli comments edit abc123def4 --message-id <message-id> --body "Updated text" --json
|
|
4255
|
+
|
|
4256
|
+
Common failures:
|
|
4257
|
+
message_not_found Run comments list and retry with a listed message_id
|
|
4258
|
+
forbidden You can edit only your own comments
|
|
4259
|
+
validation_failed Pass --message-id and --body`
|
|
4260
|
+
});
|
|
4261
|
+
const commentsResolveDefinition = define({
|
|
4262
|
+
name: "resolve",
|
|
4263
|
+
description: "Mark a comment thread as resolved.",
|
|
4264
|
+
toKebab: true,
|
|
4265
|
+
args: commentThreadActionArgs,
|
|
4266
|
+
examples: `npx --yes @artifactshare/cli comments resolve abc123def4 --thread-id <thread-id> --json
|
|
4267
|
+
|
|
4268
|
+
Common failures:
|
|
4269
|
+
thread_not_found Run comments list and retry with a listed thread_id
|
|
4270
|
+
forbidden Resolving needs the thread author, artifact owner, or workspace admin
|
|
4271
|
+
validation_failed Pass --thread-id`
|
|
4272
|
+
});
|
|
4273
|
+
const commentsReopenDefinition = define({
|
|
4274
|
+
name: "reopen",
|
|
4275
|
+
description: "Reopen a resolved comment thread.",
|
|
4276
|
+
toKebab: true,
|
|
4277
|
+
args: commentThreadActionArgs,
|
|
4278
|
+
examples: `npx --yes @artifactshare/cli comments reopen abc123def4 --thread-id <thread-id> --json
|
|
4279
|
+
|
|
4280
|
+
Common failures:
|
|
4281
|
+
thread_not_found Run comments list and retry with a listed thread_id
|
|
4282
|
+
forbidden Reopening needs the thread author, artifact owner, or workspace admin
|
|
4283
|
+
validation_failed Pass --thread-id`
|
|
4284
|
+
});
|
|
4285
|
+
const commentsDeleteDefinition = define({
|
|
4286
|
+
name: "delete",
|
|
4287
|
+
description: "Permanently delete a comment message or a whole thread.",
|
|
4288
|
+
toKebab: true,
|
|
4289
|
+
args: {
|
|
4290
|
+
...commentThreadActionArgs,
|
|
4291
|
+
messageId: {
|
|
4292
|
+
type: "string",
|
|
4293
|
+
toKebab: true,
|
|
4294
|
+
description: "Message id from comments list; omit to delete the thread"
|
|
4295
|
+
}
|
|
4296
|
+
},
|
|
4297
|
+
examples: `npx --yes @artifactshare/cli comments delete abc123def4 --thread-id <thread-id> --message-id <message-id> --json
|
|
4298
|
+
npx --yes @artifactshare/cli comments delete abc123def4 --thread-id <thread-id> --json
|
|
4299
|
+
|
|
4300
|
+
Deleting comments cannot be undone. Omit --message-id only when deleting the whole thread.
|
|
4301
|
+
|
|
4302
|
+
Common failures:
|
|
4303
|
+
thread_not_found Run comments list and retry with a listed thread_id
|
|
4304
|
+
message_not_found Retry with a message_id from that thread
|
|
4305
|
+
forbidden You can delete your own comments; owners/admins can delete any thread
|
|
4306
|
+
validation_failed Pass --thread-id`
|
|
4307
|
+
});
|
|
3460
4308
|
const commentsDefinition = define({
|
|
3461
4309
|
name: "comments",
|
|
3462
|
-
description: "Read and
|
|
4310
|
+
description: "Read, write, edit, resolve, reopen, and delete artifact comments.",
|
|
3463
4311
|
toKebab: true,
|
|
3464
4312
|
args: commonArgs,
|
|
3465
4313
|
subCommands: {
|
|
3466
4314
|
list: lazyCommand(commentsListDefinition, commentsListRunner),
|
|
3467
|
-
post: lazyCommand(commentsPostDefinition, commentsPostRunner)
|
|
4315
|
+
post: lazyCommand(commentsPostDefinition, commentsPostRunner),
|
|
4316
|
+
edit: lazyCommand(commentsEditDefinition, commentsEditRunner),
|
|
4317
|
+
resolve: lazyCommand(commentsResolveDefinition, commentsResolveRunner),
|
|
4318
|
+
reopen: lazyCommand(commentsReopenDefinition, commentsReopenRunner),
|
|
4319
|
+
delete: lazyCommand(commentsDeleteDefinition, commentsDeleteRunner)
|
|
3468
4320
|
},
|
|
3469
4321
|
examples: `npx --yes @artifactshare/cli comments list <artifact-id-or-url> --json
|
|
3470
|
-
npx --yes @artifactshare/cli comments post <artifact-id-or-url> --body "<text>" --json
|
|
4322
|
+
npx --yes @artifactshare/cli comments post <artifact-id-or-url> --body "<text>" --json
|
|
4323
|
+
npx --yes @artifactshare/cli comments edit <artifact-id-or-url> --message-id <message-id> --body "<text>" --json
|
|
4324
|
+
npx --yes @artifactshare/cli comments resolve <artifact-id-or-url> --thread-id <thread-id> --json
|
|
4325
|
+
npx --yes @artifactshare/cli comments delete <artifact-id-or-url> --thread-id <thread-id> --json
|
|
4326
|
+
|
|
4327
|
+
Deleting comments cannot be undone.`,
|
|
3471
4328
|
run: parentCommandRunner("comments")
|
|
3472
4329
|
});
|
|
3473
4330
|
const profilesListDefinition = define({
|
|
@@ -3531,22 +4388,120 @@ npx --yes @artifactshare/cli profiles use client-a --json
|
|
|
3531
4388
|
printf '%s' "$TOKEN" | npx --yes @artifactshare/cli profiles import-token --profile client-a --json`,
|
|
3532
4389
|
run: parentCommandRunner("profiles")
|
|
3533
4390
|
});
|
|
3534
|
-
const
|
|
3535
|
-
name: "
|
|
3536
|
-
description: "
|
|
4391
|
+
const projectsListDefinition = define({
|
|
4392
|
+
name: "list",
|
|
4393
|
+
description: "List projects you can publish into.",
|
|
3537
4394
|
toKebab: true,
|
|
3538
4395
|
args: commonArgs,
|
|
3539
|
-
|
|
3540
|
-
name: "list",
|
|
3541
|
-
description: "List projects you can publish into.",
|
|
3542
|
-
toKebab: true,
|
|
3543
|
-
args: commonArgs,
|
|
3544
|
-
examples: `npx --yes @artifactshare/cli projects list --json
|
|
4396
|
+
examples: `npx --yes @artifactshare/cli projects list --json
|
|
3545
4397
|
|
|
3546
4398
|
is_default marks the working-directory default project from .artifactshare/config.json.
|
|
3547
4399
|
Use a project id with publish --project-id or init --project-id.`
|
|
3548
|
-
|
|
3549
|
-
|
|
4400
|
+
});
|
|
4401
|
+
const projectsCreateDefinition = define({
|
|
4402
|
+
name: "create",
|
|
4403
|
+
description: "Create a project you can publish into.",
|
|
4404
|
+
toKebab: true,
|
|
4405
|
+
args: {
|
|
4406
|
+
...commonArgs,
|
|
4407
|
+
name: {
|
|
4408
|
+
type: "positional",
|
|
4409
|
+
description: "Project name"
|
|
4410
|
+
},
|
|
4411
|
+
description: {
|
|
4412
|
+
type: "string",
|
|
4413
|
+
toKebab: true,
|
|
4414
|
+
description: "Project description"
|
|
4415
|
+
},
|
|
4416
|
+
visibility: {
|
|
4417
|
+
type: "string",
|
|
4418
|
+
toKebab: true,
|
|
4419
|
+
description: "workspace or private (default: workspace)"
|
|
4420
|
+
}
|
|
4421
|
+
},
|
|
4422
|
+
examples: `npx --yes @artifactshare/cli projects create "Launch review" --json
|
|
4423
|
+
npx --yes @artifactshare/cli projects create "Client" --description "Weekly reports" --visibility private --json
|
|
4424
|
+
|
|
4425
|
+
The response includes project.id and next_command for publish --project-id.
|
|
4426
|
+
|
|
4427
|
+
Common failures:
|
|
4428
|
+
auth_required Set ARTIFACTSHARE_TOKEN before projects create
|
|
4429
|
+
upload_not_allowed Your account cannot publish yet; request access from an operator
|
|
4430
|
+
validation_failed Pass a non-empty name and valid --visibility`
|
|
4431
|
+
});
|
|
4432
|
+
const projectsEditDefinition = define({
|
|
4433
|
+
name: "edit",
|
|
4434
|
+
description: "Edit project settings and audience.",
|
|
4435
|
+
toKebab: true,
|
|
4436
|
+
args: {
|
|
4437
|
+
...commonArgs,
|
|
4438
|
+
id: {
|
|
4439
|
+
type: "positional",
|
|
4440
|
+
description: "Project id"
|
|
4441
|
+
},
|
|
4442
|
+
name: {
|
|
4443
|
+
type: "string",
|
|
4444
|
+
toKebab: true,
|
|
4445
|
+
description: "New project name"
|
|
4446
|
+
},
|
|
4447
|
+
description: {
|
|
4448
|
+
type: "string",
|
|
4449
|
+
toKebab: true,
|
|
4450
|
+
description: "New project description; pass an empty value to clear it"
|
|
4451
|
+
},
|
|
4452
|
+
visibility: {
|
|
4453
|
+
type: "string",
|
|
4454
|
+
toKebab: true,
|
|
4455
|
+
description: "workspace or private"
|
|
4456
|
+
},
|
|
4457
|
+
addEmail: {
|
|
4458
|
+
type: "string",
|
|
4459
|
+
multiple: true,
|
|
4460
|
+
toKebab: true,
|
|
4461
|
+
description: "Add an audience email address; repeat for multiple"
|
|
4462
|
+
},
|
|
4463
|
+
removeEmail: {
|
|
4464
|
+
type: "string",
|
|
4465
|
+
multiple: true,
|
|
4466
|
+
toKebab: true,
|
|
4467
|
+
description: "Remove an audience email address; repeat for multiple"
|
|
4468
|
+
},
|
|
4469
|
+
archive: {
|
|
4470
|
+
type: "boolean",
|
|
4471
|
+
toKebab: true,
|
|
4472
|
+
description: "Archive the project after other edits"
|
|
4473
|
+
},
|
|
4474
|
+
unarchive: {
|
|
4475
|
+
type: "boolean",
|
|
4476
|
+
toKebab: true,
|
|
4477
|
+
description: "Unarchive the project before other edits"
|
|
4478
|
+
}
|
|
4479
|
+
},
|
|
4480
|
+
examples: `npx --yes @artifactshare/cli projects edit <id> --name "Launch review" --json
|
|
4481
|
+
npx --yes @artifactshare/cli projects edit <id> --visibility private --add-email viewer@example.com --json
|
|
4482
|
+
npx --yes @artifactshare/cli projects edit <id> --archive --json
|
|
4483
|
+
npx --yes @artifactshare/cli projects edit <id> --unarchive --description "" --json
|
|
4484
|
+
|
|
4485
|
+
Common failures:
|
|
4486
|
+
target_not_found Use a project id from projects list
|
|
4487
|
+
forbidden Only the creator or workspace admin can edit project settings
|
|
4488
|
+
project_archived Retry with --unarchive, or unarchive first
|
|
4489
|
+
too_many_grants Remove project audience entries before adding more
|
|
4490
|
+
validation_failed Pass a project id and at least one valid edit option`
|
|
4491
|
+
});
|
|
4492
|
+
const projectsDefinition = define({
|
|
4493
|
+
name: "projects",
|
|
4494
|
+
description: "Create, find, and edit publish destinations.",
|
|
4495
|
+
toKebab: true,
|
|
4496
|
+
args: commonArgs,
|
|
4497
|
+
subCommands: {
|
|
4498
|
+
list: lazyCommand(projectsListDefinition, projectsListRunner),
|
|
4499
|
+
create: lazyCommand(projectsCreateDefinition, projectsCreateRunner),
|
|
4500
|
+
edit: lazyCommand(projectsEditDefinition, projectsEditRunner)
|
|
4501
|
+
},
|
|
4502
|
+
examples: `npx --yes @artifactshare/cli projects list --json
|
|
4503
|
+
npx --yes @artifactshare/cli projects create "Launch review" --json
|
|
4504
|
+
npx --yes @artifactshare/cli projects edit <id> --add-email viewer@example.com --json`,
|
|
3550
4505
|
run: parentCommandRunner("projects")
|
|
3551
4506
|
});
|
|
3552
4507
|
const skillsToolArgs = {
|