@artifactshare/cli 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +65 -29
- package/dist/cursor-acp-entry.d.ts +1 -0
- package/dist/cursor-acp-entry.js +413 -0
- package/dist/cursor-notification-BBGHJ5v5.js +520 -0
- package/dist/index.js +813 -443
- package/package.json +5 -3
- package/skills/artifactshare/SKILL.md +87 -61
- package/skills/artifactshare/artifactshare.mdc +6 -6
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { C as defaultPreviewNotificationRegistration, D as isPreviewAnchor, O as isPreviewAnnotation, S as createPreviewNotificationCoordinator, T as PREVIEW_MUTATION_HEADER, _ as resolveLiveSession, a as annotationsFilePath, b as updateSessionNotificationRegistration, c as isSessionId, d as previewsDir, f as probeSession, g as removeSessionFile, h as releaseStaleClaim, i as cursorNotificationRegistration, k as isPreviewDoneItemInput, l as previewIdentityPath, m as readSessionFile, n as CURSOR_ACP_NOTIFICATION_TIMEOUT_MS, o as claimSessionStart, p as processAlive, r as createCursorAcpAdapter, s as isConnectionRefused, u as previewRealpath, v as sessionIdForPath, w as samePreviewNotificationRegistration, x as writeSessionFile, y as tokenFingerprint } from "./cursor-notification-BBGHJ5v5.js";
|
|
2
3
|
import { cli, define, lazy } from "gunshi";
|
|
3
4
|
import { generate } from "gunshi/generator";
|
|
4
|
-
import {
|
|
5
|
+
import { chmodSync, createReadStream, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, statSync, watch, writeFileSync } from "node:fs";
|
|
5
6
|
import { pathToFileURL } from "node:url";
|
|
6
|
-
import { spawn } from "node:child_process";
|
|
7
|
+
import { execFile, spawn } from "node:child_process";
|
|
7
8
|
import { appendFile, chmod, lstat, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
|
|
8
9
|
import { arch, homedir, platform } from "node:os";
|
|
9
10
|
import { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
|
|
@@ -12,10 +13,11 @@ import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
|
12
13
|
import { Blob, Buffer as Buffer$1 } from "node:buffer";
|
|
13
14
|
import { EventEmitter } from "node:events";
|
|
14
15
|
import { createServer } from "node:http";
|
|
16
|
+
import { promisify } from "node:util";
|
|
15
17
|
//#region src/constants.ts
|
|
16
18
|
const DEFAULT_BASE_URL = "https://artifactshare.com";
|
|
17
19
|
const DEVICE_CLIENT_ID = "artifactshare-cli";
|
|
18
|
-
const CLI_INVOCATION = "
|
|
20
|
+
const CLI_INVOCATION = "npm exec --yes --package=@artifactshare/cli -- artifactshare";
|
|
19
21
|
const AGENT_DOWNLOAD_OUTPUT = "./artifact";
|
|
20
22
|
const TOKEN_ENV_VAR = "ARTIFACTSHARE_TOKEN";
|
|
21
23
|
const TOKEN_OPTION = "--token";
|
|
@@ -3806,252 +3808,109 @@ async function runOpen(parsed, mode, isRetry = false) {
|
|
|
3806
3808
|
}, mode);
|
|
3807
3809
|
}
|
|
3808
3810
|
//#endregion
|
|
3809
|
-
//#region src/preview/
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
* headers, so cross-origin writes fail in the browser. */
|
|
3813
|
-
const PREVIEW_MUTATION_HEADER = "x-artifactshare-preview";
|
|
3814
|
-
/** Identification endpoint used for stale-session detection and reuse. */
|
|
3815
|
-
const PREVIEW_SESSION_ENDPOINT = "/__preview/session";
|
|
3816
|
-
function isPreviewSessionIdentity(value) {
|
|
3817
|
-
if (typeof value !== "object" || value === null) return false;
|
|
3818
|
-
const record = value;
|
|
3819
|
-
return record.service === "artifactshare-preview" && typeof record.session_id === "string" && typeof record.realpath === "string" && typeof record.share_port === "number";
|
|
3820
|
-
}
|
|
3821
|
-
function isPreviewDoneItemInput(value) {
|
|
3822
|
-
if (typeof value !== "object" || value === null) return false;
|
|
3823
|
-
const record = value;
|
|
3824
|
-
return typeof record.thread === "string" && typeof record.generation === "number" && Number.isInteger(record.generation) && (record.outcome === "fixed" || record.outcome === "skipped") && (record.note === void 0 || typeof record.note === "string");
|
|
3825
|
-
}
|
|
3826
|
-
const ANNOTATION_STATUSES = /* @__PURE__ */ new Set([
|
|
3827
|
-
"draft",
|
|
3828
|
-
"requested",
|
|
3829
|
-
"in_progress",
|
|
3830
|
-
"resolved",
|
|
3831
|
-
"dismissed"
|
|
3832
|
-
]);
|
|
3833
|
-
function isThreadMessage(value) {
|
|
3834
|
-
if (typeof value !== "object" || value === null) return false;
|
|
3835
|
-
const record = value;
|
|
3836
|
-
return typeof record.id === "string" && (record.author === "human" || record.author === "agent") && typeof record.body === "string" && typeof record.created_at === "string";
|
|
3811
|
+
//#region src/preview/store.ts
|
|
3812
|
+
function nowIso() {
|
|
3813
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
3837
3814
|
}
|
|
3838
|
-
|
|
3839
|
-
* has to be checked: one malformed record would otherwise crash rendering and
|
|
3840
|
-
* delivery with no way back. */
|
|
3841
|
-
function isPreviewAnnotation(value) {
|
|
3815
|
+
function isBatch(value) {
|
|
3842
3816
|
if (typeof value !== "object" || value === null) return false;
|
|
3843
3817
|
const record = value;
|
|
3844
|
-
return typeof record.
|
|
3818
|
+
return typeof record.id === "string" && Array.isArray(record.members) && record.members.every((member) => {
|
|
3819
|
+
if (typeof member !== "object" || member === null) return false;
|
|
3820
|
+
const item = member;
|
|
3821
|
+
return typeof item.thread === "string" && Number.isInteger(item.generation) && (item.terminal_result === null || item.terminal_result === "resolved" || item.terminal_result === "dismissed");
|
|
3822
|
+
}) && [
|
|
3823
|
+
"queued",
|
|
3824
|
+
"processing",
|
|
3825
|
+
"completed",
|
|
3826
|
+
"failed",
|
|
3827
|
+
"manual_required"
|
|
3828
|
+
].includes(String(record.state)) && (record.failure_code === null || [
|
|
3829
|
+
"target_unavailable",
|
|
3830
|
+
"rejected",
|
|
3831
|
+
"timeout",
|
|
3832
|
+
"invalid_response",
|
|
3833
|
+
"adapter_error"
|
|
3834
|
+
].includes(String(record.failure_code))) && (record.retryable === null || typeof record.retryable === "boolean") && (record.dispatch_status === null || record.dispatch_status === "started" || record.dispatch_status === "accepted" || record.dispatch_status === "failed") && typeof record.created_at === "string" && typeof record.updated_at === "string";
|
|
3845
3835
|
}
|
|
3846
|
-
function
|
|
3836
|
+
function isAnnotationsFile(value) {
|
|
3847
3837
|
if (typeof value !== "object" || value === null) return false;
|
|
3848
3838
|
const record = value;
|
|
3849
|
-
if (record.
|
|
3850
|
-
|
|
3851
|
-
const
|
|
3852
|
-
if (
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
//#endregion
|
|
3857
|
-
//#region src/preview/session.ts
|
|
3858
|
-
function previewsDir(env = process.env) {
|
|
3859
|
-
const override = env.ARTIFACTSHARE_CONFIG_HOME;
|
|
3860
|
-
const base = override !== void 0 && override !== "" ? override : join(homedir(), ".artifactshare");
|
|
3861
|
-
return join(base, "previews");
|
|
3862
|
-
}
|
|
3863
|
-
/** A recorded pid that still exists means the process is alive, even when its
|
|
3864
|
-
* port is not answering probes. */
|
|
3865
|
-
function processAlive(pid) {
|
|
3866
|
-
try {
|
|
3867
|
-
process.kill(pid, 0);
|
|
3868
|
-
return true;
|
|
3869
|
-
} catch (error) {
|
|
3870
|
-
return error?.code === "EPERM";
|
|
3871
|
-
}
|
|
3872
|
-
}
|
|
3873
|
-
function tokenFingerprint(token) {
|
|
3874
|
-
return createHash("sha256").update(token).digest("hex").slice(0, 16);
|
|
3875
|
-
}
|
|
3876
|
-
function sessionIdForPath(realpath) {
|
|
3877
|
-
return createHash("sha256").update(realpath).digest("hex").slice(0, 16);
|
|
3878
|
-
}
|
|
3879
|
-
/** Session ids are the 16-hex prefix of a sha256; anything else could escape
|
|
3880
|
-
* the previews directory when interpolated into a path. */
|
|
3881
|
-
function isSessionId(value) {
|
|
3882
|
-
return /^[0-9a-f]{16}$/.test(value);
|
|
3883
|
-
}
|
|
3884
|
-
function sessionFilePath(sessionId, env = process.env) {
|
|
3885
|
-
if (!isSessionId(sessionId)) throw new Error("invalid preview session id");
|
|
3886
|
-
return join(previewsDir(env), `${sessionId}.json`);
|
|
3887
|
-
}
|
|
3888
|
-
function annotationsFilePath(sessionId, env = process.env) {
|
|
3889
|
-
if (!isSessionId(sessionId)) throw new Error("invalid preview session id");
|
|
3890
|
-
return join(previewsDir(env), `annotations-${sessionId}.json`);
|
|
3891
|
-
}
|
|
3892
|
-
function previewRealpath(input) {
|
|
3893
|
-
try {
|
|
3894
|
-
return {
|
|
3895
|
-
ok: true,
|
|
3896
|
-
realpath: realpathSync(input)
|
|
3897
|
-
};
|
|
3898
|
-
} catch {
|
|
3899
|
-
return {
|
|
3900
|
-
ok: false,
|
|
3901
|
-
reason: "not_found"
|
|
3902
|
-
};
|
|
3903
|
-
}
|
|
3904
|
-
}
|
|
3905
|
-
/** A source deleted or renamed while its server runs has no realpath of its
|
|
3906
|
-
* own, but its directory usually still does, and the recorded identity was
|
|
3907
|
-
* built from the resolved path. */
|
|
3908
|
-
function previewIdentityPath(input) {
|
|
3909
|
-
const real = previewRealpath(input);
|
|
3910
|
-
if (real.ok) return real.realpath;
|
|
3911
|
-
const absolute = resolve(input);
|
|
3912
|
-
const parent = previewRealpath(dirname(absolute));
|
|
3913
|
-
return parent.ok ? join(parent.realpath, basename(absolute)) : absolute;
|
|
3914
|
-
}
|
|
3915
|
-
function writeSessionFile(session, env = process.env) {
|
|
3916
|
-
const dir = previewsDir(env);
|
|
3917
|
-
mkdirSync(dir, {
|
|
3918
|
-
recursive: true,
|
|
3919
|
-
mode: 448
|
|
3839
|
+
if (!(record.schema_version === 2 && Array.isArray(record.annotations) && record.annotations.every(isPreviewAnnotation) && Array.isArray(record.batches) && record.batches.every(isBatch))) return false;
|
|
3840
|
+
const annotations = record.annotations;
|
|
3841
|
+
const batches = record.batches;
|
|
3842
|
+
if (batches.filter((batch) => batch.state !== "completed").length > 1) return false;
|
|
3843
|
+
return annotations.every((annotation) => {
|
|
3844
|
+
if (annotation.status !== "requested" && annotation.status !== "in_progress") return true;
|
|
3845
|
+
return batches.find((candidate) => candidate.id === annotation.batch_id)?.members.some((member) => member.thread === annotation.thread && member.generation === annotation.generation && member.terminal_result === null);
|
|
3920
3846
|
});
|
|
3921
|
-
const path = sessionFilePath(session.session_id, env);
|
|
3922
|
-
const payload = {
|
|
3923
|
-
schema_version: 1,
|
|
3924
|
-
...session
|
|
3925
|
-
};
|
|
3926
|
-
writeFileSync(path, JSON.stringify(payload, null, 2), { mode: 384 });
|
|
3927
|
-
return path;
|
|
3928
3847
|
}
|
|
3929
|
-
function
|
|
3930
|
-
let parsed;
|
|
3931
|
-
try {
|
|
3932
|
-
parsed = JSON.parse(readFileSync(sessionFilePath(sessionId, env), "utf8"));
|
|
3933
|
-
} catch {
|
|
3934
|
-
return null;
|
|
3935
|
-
}
|
|
3936
|
-
if (typeof parsed !== "object" || parsed === null) return null;
|
|
3937
|
-
const record = parsed;
|
|
3938
|
-
if (record.schema_version !== 1 || typeof record.session_id !== "string" || typeof record.realpath !== "string" || typeof record.port !== "number" || typeof record.share_port !== "number" || typeof record.pid !== "number" || typeof record.started_at !== "string" || !isSessionCredentials(record.credentials)) return null;
|
|
3939
|
-
return parsed;
|
|
3940
|
-
}
|
|
3941
|
-
function isSessionCredentials(value) {
|
|
3942
|
-
if (typeof value !== "object" || value === null) return false;
|
|
3943
|
-
const record = value;
|
|
3944
|
-
const optional = (name) => record[name] === null || typeof record[name] === "string";
|
|
3945
|
-
return optional("profile") && optional("base_url") && optional("token_fingerprint") && typeof record.cwd === "string";
|
|
3946
|
-
}
|
|
3947
|
-
function removeSessionFile(sessionId, env = process.env) {
|
|
3948
|
-
rmSync(sessionFilePath(sessionId, env), { force: true });
|
|
3949
|
-
}
|
|
3950
|
-
async function resolveLiveSession(filePath, fetchImpl = globalThis.fetch, env = process.env) {
|
|
3951
|
-
const session = readSessionFile(sessionIdForPath(previewIdentityPath(filePath)), env);
|
|
3952
|
-
if (!session) return { state: "none" };
|
|
3953
|
-
return await probeSession(session, fetchImpl, env);
|
|
3954
|
-
}
|
|
3955
|
-
/** Probe a record the caller already holds. `--session <id>` names one exactly,
|
|
3956
|
-
* and re-deriving its id from the recorded path would follow a symlink that has
|
|
3957
|
-
* since been repointed and miss the record the caller asked for. */
|
|
3958
|
-
async function probeSession(session, fetchImpl = globalThis.fetch, env = process.env) {
|
|
3959
|
-
const sessionId = session.session_id;
|
|
3960
|
-
let identity = null;
|
|
3961
|
-
let answered = false;
|
|
3962
|
-
try {
|
|
3963
|
-
const response = await fetchImpl(`http://127.0.0.1:${session.port}${PREVIEW_SESSION_ENDPOINT}`, { signal: AbortSignal.timeout(2e3) });
|
|
3964
|
-
answered = true;
|
|
3965
|
-
if (response.ok) identity = await response.json().catch(() => null);
|
|
3966
|
-
} catch (error) {
|
|
3967
|
-
identity = null;
|
|
3968
|
-
answered = isConnectionRefused(error);
|
|
3969
|
-
}
|
|
3970
|
-
if (isPreviewSessionIdentity(identity) && identity.session_id === session.session_id && identity.realpath === session.realpath && identity.share_port === session.share_port) return {
|
|
3971
|
-
state: "live",
|
|
3972
|
-
session
|
|
3973
|
-
};
|
|
3974
|
-
if (!answered) return {
|
|
3975
|
-
state: "unverified",
|
|
3976
|
-
session
|
|
3977
|
-
};
|
|
3978
|
-
removeSessionFile(sessionId, env);
|
|
3979
|
-
return {
|
|
3980
|
-
state: "none",
|
|
3981
|
-
reclaimed: true
|
|
3982
|
-
};
|
|
3983
|
-
}
|
|
3984
|
-
/** A refused connection proves nothing listens on the recorded port. */
|
|
3985
|
-
function isConnectionRefused(error) {
|
|
3986
|
-
const causeCode = error?.cause?.code;
|
|
3987
|
-
const code = error?.code;
|
|
3988
|
-
return causeCode === "ECONNREFUSED" || code === "ECONNREFUSED";
|
|
3989
|
-
}
|
|
3990
|
-
/** Claim the right to start a session for this path. The lock file is created
|
|
3991
|
-
* exclusively, so two `preview <same file>` invocations racing before either
|
|
3992
|
-
* writes its session file cannot both win and end up sharing one annotation
|
|
3993
|
-
* store. */
|
|
3994
|
-
function claimSessionStart(sessionId, env = process.env) {
|
|
3995
|
-
const dir = previewsDir(env);
|
|
3996
|
-
mkdirSync(dir, {
|
|
3997
|
-
recursive: true,
|
|
3998
|
-
mode: 448
|
|
3999
|
-
});
|
|
4000
|
-
const lockPath = join(dir, `${sessionId}.lock`);
|
|
4001
|
-
try {
|
|
4002
|
-
const handle = openSync(lockPath, "wx", 384);
|
|
4003
|
-
writeSync(handle, String(process.pid));
|
|
4004
|
-
closeSync(handle);
|
|
4005
|
-
} catch {
|
|
4006
|
-
return { ok: false };
|
|
4007
|
-
}
|
|
4008
|
-
return {
|
|
4009
|
-
ok: true,
|
|
4010
|
-
release: () => {
|
|
4011
|
-
rmSync(lockPath, { force: true });
|
|
4012
|
-
}
|
|
4013
|
-
};
|
|
4014
|
-
}
|
|
4015
|
-
/** Clears an abandoned claim and reports whether none remains. A live
|
|
4016
|
-
* claimant means a start is still in flight: freeing its lock would let a
|
|
4017
|
-
* second server open the same annotation store. */
|
|
4018
|
-
function releaseStaleClaim(sessionId, env = process.env) {
|
|
4019
|
-
const lockPath = join(previewsDir(env), `${sessionId}.lock`);
|
|
4020
|
-
let recorded;
|
|
4021
|
-
try {
|
|
4022
|
-
recorded = readFileSync(lockPath, "utf8").trim();
|
|
4023
|
-
} catch {
|
|
4024
|
-
return true;
|
|
4025
|
-
}
|
|
4026
|
-
const pid = Number.parseInt(recorded, 10);
|
|
4027
|
-
if (Number.isInteger(pid) && pid > 0 && processAlive(pid)) return false;
|
|
4028
|
-
rmSync(lockPath, { force: true });
|
|
4029
|
-
return true;
|
|
4030
|
-
}
|
|
4031
|
-
//#endregion
|
|
4032
|
-
//#region src/preview/store.ts
|
|
4033
|
-
function nowIso() {
|
|
4034
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
4035
|
-
}
|
|
4036
|
-
function isAnnotationsFile(value) {
|
|
3848
|
+
function isAnnotationsFileV1(value) {
|
|
4037
3849
|
if (typeof value !== "object" || value === null) return false;
|
|
4038
3850
|
const record = value;
|
|
4039
3851
|
return record.schema_version === 1 && Array.isArray(record.annotations) && record.annotations.every(isPreviewAnnotation);
|
|
4040
3852
|
}
|
|
4041
3853
|
function createPreviewStore(annotationsPath) {
|
|
4042
3854
|
let annotations = [];
|
|
3855
|
+
let batches = [];
|
|
4043
3856
|
let quarantined = null;
|
|
3857
|
+
let migrated = false;
|
|
4044
3858
|
if (existsSync(annotationsPath)) {
|
|
4045
3859
|
let parsed = null;
|
|
4046
|
-
let valid = false;
|
|
4047
3860
|
try {
|
|
4048
3861
|
parsed = JSON.parse(readFileSync(annotationsPath, "utf8"));
|
|
4049
|
-
valid = isAnnotationsFile(parsed);
|
|
4050
3862
|
} catch {
|
|
4051
|
-
|
|
4052
|
-
}
|
|
4053
|
-
if (
|
|
4054
|
-
|
|
3863
|
+
parsed = null;
|
|
3864
|
+
}
|
|
3865
|
+
if (isAnnotationsFile(parsed)) {
|
|
3866
|
+
annotations = parsed.annotations;
|
|
3867
|
+
batches = parsed.batches;
|
|
3868
|
+
} else if (isAnnotationsFileV1(parsed)) {
|
|
3869
|
+
annotations = parsed.annotations;
|
|
3870
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
3871
|
+
for (const annotation of annotations) {
|
|
3872
|
+
if (!annotation.batch_id) continue;
|
|
3873
|
+
const current = grouped.get(annotation.batch_id) ?? [];
|
|
3874
|
+
current.push(annotation);
|
|
3875
|
+
grouped.set(annotation.batch_id, current);
|
|
3876
|
+
}
|
|
3877
|
+
const migratedBatches = [...grouped.entries()].map(([id, members]) => {
|
|
3878
|
+
const completed = members.every((item) => item.status === "resolved" || item.status === "dismissed");
|
|
3879
|
+
const processing = members.some((item) => item.status === "in_progress");
|
|
3880
|
+
const created = members[0]?.created_at ?? nowIso();
|
|
3881
|
+
return {
|
|
3882
|
+
id,
|
|
3883
|
+
members: members.map((item) => ({
|
|
3884
|
+
thread: item.thread,
|
|
3885
|
+
generation: item.generation,
|
|
3886
|
+
terminal_result: item.status === "resolved" || item.status === "dismissed" ? item.status : null
|
|
3887
|
+
})),
|
|
3888
|
+
state: completed ? "completed" : processing ? "processing" : "manual_required",
|
|
3889
|
+
failure_code: null,
|
|
3890
|
+
retryable: null,
|
|
3891
|
+
dispatch_status: null,
|
|
3892
|
+
created_at: created,
|
|
3893
|
+
updated_at: members.at(-1)?.updated_at ?? created
|
|
3894
|
+
};
|
|
3895
|
+
});
|
|
3896
|
+
const unfinished = migratedBatches.filter((batch) => batch.state !== "completed");
|
|
3897
|
+
if (unfinished.length > 1) {
|
|
3898
|
+
const active = unfinished.at(-1);
|
|
3899
|
+
const unfinishedIds = new Set(unfinished.map((batch) => batch.id));
|
|
3900
|
+
const activeAnnotations = annotations.filter((annotation) => annotation.batch_id !== null && unfinishedIds.has(annotation.batch_id));
|
|
3901
|
+
active.members = activeAnnotations.map((item) => ({
|
|
3902
|
+
thread: item.thread,
|
|
3903
|
+
generation: item.generation,
|
|
3904
|
+
terminal_result: item.status === "resolved" || item.status === "dismissed" ? item.status : null
|
|
3905
|
+
}));
|
|
3906
|
+
active.state = activeAnnotations.some((item) => item.status === "in_progress") ? "processing" : "manual_required";
|
|
3907
|
+
active.created_at = unfinished.at(0)?.created_at ?? active.created_at;
|
|
3908
|
+
active.updated_at = unfinished.at(-1)?.updated_at ?? active.updated_at;
|
|
3909
|
+
for (const annotation of activeAnnotations) annotation.batch_id = active.id;
|
|
3910
|
+
batches = [...migratedBatches.filter((batch) => batch.state === "completed"), active];
|
|
3911
|
+
} else batches = migratedBatches;
|
|
3912
|
+
migrated = true;
|
|
3913
|
+
} else {
|
|
4055
3914
|
const target = `${annotationsPath}.corrupt-${nowIso().replaceAll(":", "")}`;
|
|
4056
3915
|
renameSync(annotationsPath, target);
|
|
4057
3916
|
quarantined = target;
|
|
@@ -4059,21 +3918,46 @@ function createPreviewStore(annotationsPath) {
|
|
|
4059
3918
|
}
|
|
4060
3919
|
function save() {
|
|
4061
3920
|
const payload = {
|
|
4062
|
-
schema_version:
|
|
4063
|
-
annotations
|
|
3921
|
+
schema_version: 2,
|
|
3922
|
+
annotations,
|
|
3923
|
+
batches
|
|
4064
3924
|
};
|
|
4065
3925
|
const dir = dirname(annotationsPath);
|
|
4066
|
-
mkdirSync(dir, {
|
|
3926
|
+
mkdirSync(dir, {
|
|
3927
|
+
recursive: true,
|
|
3928
|
+
mode: 448
|
|
3929
|
+
});
|
|
4067
3930
|
const temp = join(dir, `.annotations-${randomUUID()}.tmp`);
|
|
4068
|
-
writeFileSync(temp, JSON.stringify(payload, null, 2));
|
|
3931
|
+
writeFileSync(temp, JSON.stringify(payload, null, 2), { mode: 384 });
|
|
4069
3932
|
renameSync(temp, annotationsPath);
|
|
3933
|
+
chmodSync(annotationsPath, 384);
|
|
4070
3934
|
}
|
|
3935
|
+
if (migrated) save();
|
|
4071
3936
|
function find(thread) {
|
|
4072
3937
|
return annotations.find((annotation) => annotation.thread === thread);
|
|
4073
3938
|
}
|
|
3939
|
+
function findBatch(batchId) {
|
|
3940
|
+
return batches.find((batch) => batch.id === batchId);
|
|
3941
|
+
}
|
|
3942
|
+
function activeBatch() {
|
|
3943
|
+
return [...batches].reverse().find((batch) => batch.state !== "completed") ?? null;
|
|
3944
|
+
}
|
|
4074
3945
|
function touch(annotation) {
|
|
4075
3946
|
annotation.updated_at = nowIso();
|
|
4076
3947
|
}
|
|
3948
|
+
function touchBatch(batch) {
|
|
3949
|
+
batch.updated_at = nowIso();
|
|
3950
|
+
}
|
|
3951
|
+
function setBatchState(batchId, state, failureCode = null, retryable = null) {
|
|
3952
|
+
const batch = findBatch(batchId);
|
|
3953
|
+
if (!batch) return;
|
|
3954
|
+
if (batch.state === "processing" || batch.state === "completed") return;
|
|
3955
|
+
batch.state = state;
|
|
3956
|
+
batch.failure_code = failureCode;
|
|
3957
|
+
batch.retryable = retryable;
|
|
3958
|
+
touchBatch(batch);
|
|
3959
|
+
save();
|
|
3960
|
+
}
|
|
4077
3961
|
function message(author, body) {
|
|
4078
3962
|
return {
|
|
4079
3963
|
id: randomUUID(),
|
|
@@ -4131,25 +4015,65 @@ function createPreviewStore(annotationsPath) {
|
|
|
4131
4015
|
return drafts;
|
|
4132
4016
|
},
|
|
4133
4017
|
submitDrafts() {
|
|
4018
|
+
const active = activeBatch();
|
|
4019
|
+
if (active) return {
|
|
4020
|
+
ok: false,
|
|
4021
|
+
reason: "batch_in_progress",
|
|
4022
|
+
batch: active
|
|
4023
|
+
};
|
|
4134
4024
|
const drafts = annotations.filter((entry) => entry.status === "draft");
|
|
4135
|
-
if (drafts.length === 0) return
|
|
4025
|
+
if (drafts.length === 0) return {
|
|
4026
|
+
ok: true,
|
|
4027
|
+
annotations: [],
|
|
4028
|
+
batch: null
|
|
4029
|
+
};
|
|
4136
4030
|
const batchId = randomUUID();
|
|
4031
|
+
const created = nowIso();
|
|
4137
4032
|
for (const draft of drafts) {
|
|
4138
4033
|
draft.status = "requested";
|
|
4139
4034
|
draft.batch_id = batchId;
|
|
4140
4035
|
touch(draft);
|
|
4141
4036
|
}
|
|
4037
|
+
const batch = {
|
|
4038
|
+
id: batchId,
|
|
4039
|
+
members: drafts.map((draft) => ({
|
|
4040
|
+
thread: draft.thread,
|
|
4041
|
+
generation: draft.generation,
|
|
4042
|
+
terminal_result: null
|
|
4043
|
+
})),
|
|
4044
|
+
state: "manual_required",
|
|
4045
|
+
failure_code: null,
|
|
4046
|
+
retryable: null,
|
|
4047
|
+
dispatch_status: null,
|
|
4048
|
+
created_at: created,
|
|
4049
|
+
updated_at: created
|
|
4050
|
+
};
|
|
4051
|
+
batches.push(batch);
|
|
4142
4052
|
save();
|
|
4143
|
-
return
|
|
4053
|
+
return {
|
|
4054
|
+
ok: true,
|
|
4055
|
+
annotations: drafts,
|
|
4056
|
+
batch
|
|
4057
|
+
};
|
|
4144
4058
|
},
|
|
4145
4059
|
deliver() {
|
|
4146
|
-
const
|
|
4060
|
+
const batch = activeBatch();
|
|
4061
|
+
if (!batch) return [];
|
|
4062
|
+
const memberKeys = new Set(batch.members.filter((member) => member.terminal_result === null).map((member) => `${member.thread}:${member.generation}`));
|
|
4063
|
+
const pending = annotations.filter((entry) => memberKeys.has(`${entry.thread}:${entry.generation}`) && (entry.status === "requested" || entry.status === "in_progress"));
|
|
4147
4064
|
let changed = false;
|
|
4148
4065
|
for (const entry of pending) if (entry.status !== "in_progress") {
|
|
4149
4066
|
entry.status = "in_progress";
|
|
4150
4067
|
touch(entry);
|
|
4151
4068
|
changed = true;
|
|
4152
4069
|
}
|
|
4070
|
+
if (pending.length > 0 && batch.state !== "processing") {
|
|
4071
|
+
batch.state = "processing";
|
|
4072
|
+
batch.failure_code = null;
|
|
4073
|
+
batch.retryable = null;
|
|
4074
|
+
touchBatch(batch);
|
|
4075
|
+
changed = true;
|
|
4076
|
+
}
|
|
4153
4077
|
if (changed) save();
|
|
4154
4078
|
return pending.map((entry) => ({
|
|
4155
4079
|
thread: entry.thread,
|
|
@@ -4178,18 +4102,87 @@ function createPreviewStore(annotationsPath) {
|
|
|
4178
4102
|
results.push("already_reported");
|
|
4179
4103
|
continue;
|
|
4180
4104
|
}
|
|
4181
|
-
|
|
4105
|
+
const batch = annotation.batch_id ? findBatch(annotation.batch_id) : void 0;
|
|
4106
|
+
const member = batch?.members.find((candidate) => candidate.thread === item.thread && candidate.generation === item.generation);
|
|
4107
|
+
if (!batch || !member) {
|
|
4108
|
+
results.push("stale");
|
|
4109
|
+
continue;
|
|
4110
|
+
}
|
|
4111
|
+
const terminal = item.outcome === "fixed" ? "resolved" : "dismissed";
|
|
4112
|
+
annotation.status = terminal;
|
|
4113
|
+
member.terminal_result = terminal;
|
|
4182
4114
|
if (item.note !== void 0) {
|
|
4183
4115
|
annotation.summary = item.note;
|
|
4184
4116
|
annotation.messages.push(message("agent", item.note));
|
|
4185
4117
|
}
|
|
4186
4118
|
touch(annotation);
|
|
4119
|
+
touchBatch(batch);
|
|
4120
|
+
if (batch.members.every((candidate) => candidate.terminal_result !== null)) {
|
|
4121
|
+
batch.state = "completed";
|
|
4122
|
+
batch.failure_code = null;
|
|
4123
|
+
batch.retryable = null;
|
|
4124
|
+
}
|
|
4187
4125
|
changed = true;
|
|
4188
4126
|
results.push("accepted");
|
|
4189
4127
|
}
|
|
4190
4128
|
if (changed) save();
|
|
4191
4129
|
return results;
|
|
4192
4130
|
},
|
|
4131
|
+
markManualRequired(batchId) {
|
|
4132
|
+
setBatchState(batchId, "manual_required");
|
|
4133
|
+
},
|
|
4134
|
+
markDispatchStarted(batchId) {
|
|
4135
|
+
const batch = findBatch(batchId);
|
|
4136
|
+
if (!batch || batch.state === "processing" || batch.state === "completed") return;
|
|
4137
|
+
batch.dispatch_status = "started";
|
|
4138
|
+
batch.state = "queued";
|
|
4139
|
+
batch.failure_code = null;
|
|
4140
|
+
batch.retryable = null;
|
|
4141
|
+
touchBatch(batch);
|
|
4142
|
+
save();
|
|
4143
|
+
},
|
|
4144
|
+
markDispatchAccepted(batchId) {
|
|
4145
|
+
const batch = findBatch(batchId);
|
|
4146
|
+
if (!batch) return;
|
|
4147
|
+
batch.dispatch_status = "accepted";
|
|
4148
|
+
if (batch.state !== "processing" && batch.state !== "completed") {
|
|
4149
|
+
batch.state = "queued";
|
|
4150
|
+
batch.failure_code = null;
|
|
4151
|
+
batch.retryable = null;
|
|
4152
|
+
}
|
|
4153
|
+
touchBatch(batch);
|
|
4154
|
+
save();
|
|
4155
|
+
},
|
|
4156
|
+
markDispatchFailed(batchId, failureCode, retryable) {
|
|
4157
|
+
const batch = findBatch(batchId);
|
|
4158
|
+
if (!batch) return;
|
|
4159
|
+
batch.dispatch_status = "failed";
|
|
4160
|
+
if (batch.state !== "processing" && batch.state !== "completed") {
|
|
4161
|
+
batch.state = "failed";
|
|
4162
|
+
batch.failure_code = failureCode;
|
|
4163
|
+
batch.retryable = retryable;
|
|
4164
|
+
}
|
|
4165
|
+
touchBatch(batch);
|
|
4166
|
+
save();
|
|
4167
|
+
},
|
|
4168
|
+
recoverInterruptedBatch() {
|
|
4169
|
+
const batch = activeBatch();
|
|
4170
|
+
if (!batch) return;
|
|
4171
|
+
if (batch.state !== "processing") {
|
|
4172
|
+
batch.state = "manual_required";
|
|
4173
|
+
batch.failure_code = null;
|
|
4174
|
+
batch.retryable = null;
|
|
4175
|
+
touchBatch(batch);
|
|
4176
|
+
save();
|
|
4177
|
+
}
|
|
4178
|
+
},
|
|
4179
|
+
activeBatch,
|
|
4180
|
+
latestBatch() {
|
|
4181
|
+
return batches.at(-1) ?? null;
|
|
4182
|
+
},
|
|
4183
|
+
batches() {
|
|
4184
|
+
return batches;
|
|
4185
|
+
},
|
|
4193
4186
|
reply(thread, body, author) {
|
|
4194
4187
|
const annotation = find(thread);
|
|
4195
4188
|
if (!annotation) return {
|
|
@@ -4335,7 +4328,7 @@ async function runProjectsCreate(parsed, mode) {
|
|
|
4335
4328
|
description: configString(project?.description),
|
|
4336
4329
|
base_visibility: configString(project?.base_visibility)
|
|
4337
4330
|
},
|
|
4338
|
-
next_command: `
|
|
4331
|
+
next_command: `npm exec --yes --package=@artifactshare/cli -- artifactshare share <path> --project-id ${id} --json`
|
|
4339
4332
|
}, mode);
|
|
4340
4333
|
}
|
|
4341
4334
|
async function runProjectsEdit(parsed, mode) {
|
|
@@ -4467,13 +4460,14 @@ const PREVIEW_MESSAGES = {
|
|
|
4467
4460
|
"preview.localBadge": "Local preview",
|
|
4468
4461
|
"preview.watching": "Watching for changes",
|
|
4469
4462
|
"preview.share": "Share",
|
|
4470
|
-
"preview.annotateMode": "
|
|
4463
|
+
"preview.annotateMode": "Comment mode",
|
|
4471
4464
|
"preview.panelTitle": "Comments",
|
|
4472
4465
|
"preview.emptyHint": "Click any element to annotate it. Turn the toggle off to use links normally.",
|
|
4473
4466
|
"preview.requestFixesOne": "Request fixes ({n})",
|
|
4474
4467
|
"preview.requestFixesOther": "Request fixes ({n})",
|
|
4475
4468
|
"preview.discardDrafts": "Discard drafts",
|
|
4476
4469
|
"preview.stateDraft": "Draft",
|
|
4470
|
+
"preview.stateSaved": "Saved",
|
|
4477
4471
|
"preview.stateQueued": "Queued",
|
|
4478
4472
|
"preview.stateWorking": "Fixing",
|
|
4479
4473
|
"preview.stateResolved": "Resolved",
|
|
@@ -4483,7 +4477,28 @@ const PREVIEW_MESSAGES = {
|
|
|
4483
4477
|
"preview.reopenNote": "Reopened annotations stay local until you submit them again.",
|
|
4484
4478
|
"preview.batchWorkingOne": "Agent is fixing {n} annotation",
|
|
4485
4479
|
"preview.batchWorkingOther": "Agent is fixing {n} annotations",
|
|
4486
|
-
"preview.
|
|
4480
|
+
"preview.batchQueuedOne": "Sent to the agent; {n} annotation is waiting for pickup. If it stays queued, ask the agent to run preview next.",
|
|
4481
|
+
"preview.batchQueuedOther": "Sent to the agent; {n} annotations are waiting for pickup. If they stay queued, ask the agent to run preview next.",
|
|
4482
|
+
"preview.batchQueuedCodexOne": "Sent to Codex; {n} comment is waiting for pickup. If it stays queued, reopen the session with codex resume.",
|
|
4483
|
+
"preview.batchQueuedCodexOther": "Sent to Codex; {n} comments are waiting for pickup. If they stay queued, reopen the session with codex resume.",
|
|
4484
|
+
"preview.batchQueuedClaudeOne": "Claude Code acknowledged the request; {n} comment is waiting for pickup.",
|
|
4485
|
+
"preview.batchQueuedClaudeOther": "Claude Code acknowledged the request; {n} comments are waiting for pickup.",
|
|
4486
|
+
"preview.batchQueuedCursorOne": "Sent to the managed Cursor session; {n} comment is waiting for pickup.",
|
|
4487
|
+
"preview.batchQueuedCursorOther": "Sent to the managed Cursor session; {n} comments are waiting for pickup.",
|
|
4488
|
+
"preview.batchManualOne": "Saved {n} annotation. Ask the agent to run preview next.",
|
|
4489
|
+
"preview.batchManualOther": "Saved {n} annotations. Ask the agent to run preview next.",
|
|
4490
|
+
"preview.batchManualClaudeOne": "Saved {n} comment. Open Claude Code and ask it to run preview next.",
|
|
4491
|
+
"preview.batchManualClaudeOther": "Saved {n} comments. Open Claude Code and ask it to run preview next.",
|
|
4492
|
+
"preview.batchManualCursorOne": "Saved {n} comment. Open Cursor and ask it to run preview next.",
|
|
4493
|
+
"preview.batchManualCursorOther": "Saved {n} comments. Open Cursor and ask it to run preview next.",
|
|
4494
|
+
"preview.batchFailedOne": "Agent notification failed. {n} annotation is saved; ask the agent to run preview next.",
|
|
4495
|
+
"preview.batchFailedOther": "Agent notification failed. {n} annotations are saved; ask the agent to run preview next.",
|
|
4496
|
+
"preview.batchFailedCodexOne": "Codex notification did not complete. {n} comment is saved. Open the Codex session, then ask it to run preview next.",
|
|
4497
|
+
"preview.batchFailedCodexOther": "Codex notification did not complete. {n} comments are saved. Open the Codex session, then ask it to run preview next.",
|
|
4498
|
+
"preview.batchFailedClaudeOne": "Claude Code did not acknowledge the request. {n} comment is saved. Open the session and run preview next.",
|
|
4499
|
+
"preview.batchFailedClaudeOther": "Claude Code did not acknowledge the request. {n} comments are saved. Open the session and run preview next.",
|
|
4500
|
+
"preview.batchFailedCursorOne": "The Cursor session did not accept the request. {n} comment is saved. Open the session and run preview next.",
|
|
4501
|
+
"preview.batchFailedCursorOther": "The Cursor session did not accept the request. {n} comments are saved. Open the session and run preview next.",
|
|
4487
4502
|
"preview.resolvedToastOne": "Resolved {n} annotation",
|
|
4488
4503
|
"preview.resolvedToastOther": "Resolved {n} annotations",
|
|
4489
4504
|
"preview.orphanNoticeOne": "The page changed a lot; {n} annotation lost its target",
|
|
@@ -4538,6 +4553,7 @@ const PREVIEW_MESSAGES = {
|
|
|
4538
4553
|
"preview.requestFixesOther": "修正を依頼する({n} 件)",
|
|
4539
4554
|
"preview.discardDrafts": "下書きを破棄",
|
|
4540
4555
|
"preview.stateDraft": "下書き",
|
|
4556
|
+
"preview.stateSaved": "保存済み",
|
|
4541
4557
|
"preview.stateQueued": "順番待ち",
|
|
4542
4558
|
"preview.stateWorking": "修正中",
|
|
4543
4559
|
"preview.stateResolved": "解決済み",
|
|
@@ -4547,7 +4563,28 @@ const PREVIEW_MESSAGES = {
|
|
|
4547
4563
|
"preview.reopenNote": "差し戻したコメントは、再度依頼するまでエージェントには届きません",
|
|
4548
4564
|
"preview.batchWorkingOne": "エージェントが {n} 件を修正中",
|
|
4549
4565
|
"preview.batchWorkingOther": "エージェントが {n} 件を修正中",
|
|
4550
|
-
"preview.
|
|
4566
|
+
"preview.batchQueuedOne": "エージェントへ通知済みです。{n} 件の取得を待っています。待機が続く場合は preview next の実行を依頼してください",
|
|
4567
|
+
"preview.batchQueuedOther": "エージェントへ通知済みです。{n} 件の取得を待っています。待機が続く場合は preview next の実行を依頼してください",
|
|
4568
|
+
"preview.batchQueuedCodexOne": "Codexへ通知済みです。{n} 件の取得待ちです。続く場合は codex resume でセッションを再開してください",
|
|
4569
|
+
"preview.batchQueuedCodexOther": "Codexへ通知済みです。{n} 件の取得待ちです。続く場合は codex resume でセッションを再開してください",
|
|
4570
|
+
"preview.batchQueuedClaudeOne": "Claude Codeが依頼を確認しました。{n} 件の取得を待っています",
|
|
4571
|
+
"preview.batchQueuedClaudeOther": "Claude Codeが依頼を確認しました。{n} 件の取得を待っています",
|
|
4572
|
+
"preview.batchQueuedCursorOne": "管理対象のCursorセッションへ通知済みです。{n} 件の取得を待っています",
|
|
4573
|
+
"preview.batchQueuedCursorOther": "管理対象のCursorセッションへ通知済みです。{n} 件の取得を待っています",
|
|
4574
|
+
"preview.batchManualOne": "{n} 件を保存しました。エージェントに preview next の実行を依頼してください",
|
|
4575
|
+
"preview.batchManualOther": "{n} 件を保存しました。エージェントに preview next の実行を依頼してください",
|
|
4576
|
+
"preview.batchManualClaudeOne": "{n} 件を保存しました。Claude Codeを開き、preview next の実行を依頼してください",
|
|
4577
|
+
"preview.batchManualClaudeOther": "{n} 件を保存しました。Claude Codeを開き、preview next の実行を依頼してください",
|
|
4578
|
+
"preview.batchManualCursorOne": "{n} 件を保存しました。Cursorを開き、preview next の実行を依頼してください",
|
|
4579
|
+
"preview.batchManualCursorOther": "{n} 件を保存しました。Cursorを開き、preview next の実行を依頼してください",
|
|
4580
|
+
"preview.batchFailedOne": "エージェントへの通知に失敗しました。{n} 件は保存済みです。preview next の実行を依頼してください",
|
|
4581
|
+
"preview.batchFailedOther": "エージェントへの通知に失敗しました。{n} 件は保存済みです。preview next の実行を依頼してください",
|
|
4582
|
+
"preview.batchFailedCodexOne": "Codexへの通知を完了できませんでした。{n} 件は保存済みです。Codexのセッションを開き、preview next の実行を依頼してください",
|
|
4583
|
+
"preview.batchFailedCodexOther": "Codexへの通知を完了できませんでした。{n} 件は保存済みです。Codexのセッションを開き、preview next の実行を依頼してください",
|
|
4584
|
+
"preview.batchFailedClaudeOne": "Claude Codeが依頼を確認できませんでした。{n} 件は保存済みです。セッションを開き、preview next を実行してください",
|
|
4585
|
+
"preview.batchFailedClaudeOther": "Claude Codeが依頼を確認できませんでした。{n} 件は保存済みです。セッションを開き、preview next を実行してください",
|
|
4586
|
+
"preview.batchFailedCursorOne": "Cursorセッションが依頼を受け付けませんでした。{n} 件は保存済みです。セッションを開き、preview next を実行してください",
|
|
4587
|
+
"preview.batchFailedCursorOther": "Cursorセッションが依頼を受け付けませんでした。{n} 件は保存済みです。セッションを開き、preview next を実行してください",
|
|
4551
4588
|
"preview.resolvedToastOne": "{n} 件を解決しました",
|
|
4552
4589
|
"preview.resolvedToastOther": "{n} 件を解決しました",
|
|
4553
4590
|
"preview.orphanNoticeOne": "ページが大きく変わったため {n} 件のコメントが対象を見失いました",
|
|
@@ -10224,6 +10261,7 @@ function renderPreviewShell(options) {
|
|
|
10224
10261
|
--border: rgba(55,53,47,0.1); --border-strong: rgba(55,53,47,0.22);
|
|
10225
10262
|
--accent: rgba(55,53,47,0.04); --link: #116bb1; --primary: #1766ad;
|
|
10226
10263
|
--coral: #ff6f61; --pending: #e07b00; --success: #1a7f4b; --card: #ffffff;
|
|
10264
|
+
--badge-on-link: #ffffff; --badge-on-dismissed: #37352f;
|
|
10227
10265
|
--r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-full: 9999px;
|
|
10228
10266
|
--shadow-md: rgba(15,15,15,0.05) 0 0 0 1px, rgba(15,15,15,0.1) 0 3px 6px;
|
|
10229
10267
|
--shadow-lg: rgba(15,15,15,0.05) 0 0 0 1px, rgba(15,15,15,0.1) 0 8px 24px;
|
|
@@ -10234,6 +10272,7 @@ function renderPreviewShell(options) {
|
|
|
10234
10272
|
--muted-foreground: rgba(231,226,216,0.77); --faint: rgba(231,226,216,0.4);
|
|
10235
10273
|
--border: rgba(231,226,216,0.13); --border-strong: rgba(231,226,216,0.28);
|
|
10236
10274
|
--accent: rgba(231,226,216,0.07); --link: #7db7ff; --primary: #7db7ff; --card: #191c1f;
|
|
10275
|
+
--badge-on-link: #111315; --badge-on-dismissed: #ffffff;
|
|
10237
10276
|
--shadow-md: rgba(0,0,0,0.4) 0 0 0 1px, rgba(0,0,0,0.5) 0 3px 6px;
|
|
10238
10277
|
--shadow-lg: rgba(0,0,0,0.4) 0 0 0 1px, rgba(0,0,0,0.5) 0 8px 24px;
|
|
10239
10278
|
}
|
|
@@ -10242,12 +10281,14 @@ function renderPreviewShell(options) {
|
|
|
10242
10281
|
body { margin: 0; background: var(--surface-warm); color: var(--foreground);
|
|
10243
10282
|
font-family: ui-sans-serif, -apple-system, "Segoe UI", "Hiragino Sans", sans-serif;
|
|
10244
10283
|
font-size: 14px; line-height: 1.5; }
|
|
10284
|
+
html[lang="ja"] body { line-break: strict; word-break: auto-phrase; }
|
|
10245
10285
|
.topbar { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px;
|
|
10246
10286
|
background: var(--background); border-bottom: 1px solid var(--border);
|
|
10247
10287
|
position: sticky; top: 0; z-index: 40; }
|
|
10248
10288
|
.brand { width: 20px; height: 20px; border-radius: 5px; background: var(--coral);
|
|
10249
10289
|
color: #fff; font-weight: 700; font-size: 11px; display: grid; place-items: center; }
|
|
10250
|
-
.file-name { font-weight: 600; font-size: 13px;
|
|
10290
|
+
.file-name { font-weight: 600; font-size: 13px; min-width: 0;
|
|
10291
|
+
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
10251
10292
|
.local-badge { font-size: 11px; color: var(--muted-foreground);
|
|
10252
10293
|
border: 1px solid var(--border); border-radius: var(--r-full);
|
|
10253
10294
|
padding: 1px 8px; background: var(--accent); }
|
|
@@ -10260,6 +10301,8 @@ function renderPreviewShell(options) {
|
|
|
10260
10301
|
padding: 5px 12px; }
|
|
10261
10302
|
.btn:hover { background: var(--accent); }
|
|
10262
10303
|
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
|
|
10304
|
+
.btn:disabled { cursor: default; opacity: 0.5; }
|
|
10305
|
+
.btn-primary:disabled:hover { background: var(--primary); }
|
|
10263
10306
|
.layout { display: flex; height: calc(100vh - 46px); }
|
|
10264
10307
|
.doc-wrap { flex: 1; display: flex; position: relative; }
|
|
10265
10308
|
#artifactFrame { flex: 1; width: 100%; height: 100%; border: 0; background: var(--background); }
|
|
@@ -10273,14 +10316,14 @@ function renderPreviewShell(options) {
|
|
|
10273
10316
|
width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
|
|
10274
10317
|
body.annotate .mode-toggle .knob { background: var(--link); }
|
|
10275
10318
|
body.annotate .mode-toggle .knob::after { transform: translateX(12px); }
|
|
10276
|
-
.mode-toggle .count { background: var(--pending); color: #
|
|
10319
|
+
.mode-toggle .count { background: var(--pending); color: #2a1800; border-radius: var(--r-full);
|
|
10277
10320
|
font-size: 11px; min-width: 18px; height: 18px; display: none; place-items: center; padding: 0 5px; }
|
|
10278
10321
|
.mode-toggle .count.show { display: grid; }
|
|
10279
10322
|
.popover { position: fixed; z-index: 50; width: min(300px, 80vw);
|
|
10280
10323
|
background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
|
|
10281
10324
|
padding: 10px; display: none; }
|
|
10282
10325
|
.popover.show { display: block; }
|
|
10283
|
-
.popover .target-label { font-size: 11px; color: var(--
|
|
10326
|
+
.popover .target-label { font-size: 11px; color: var(--muted-foreground); margin-bottom: 6px;
|
|
10284
10327
|
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
10285
10328
|
.popover textarea { width: 100%; border: 1px solid var(--border);
|
|
10286
10329
|
border-radius: var(--r-md); font: inherit; font-size: 13px; padding: 7px 9px;
|
|
@@ -10295,22 +10338,23 @@ function renderPreviewShell(options) {
|
|
|
10295
10338
|
.thread:hover { border-color: var(--border-strong); }
|
|
10296
10339
|
.thread .head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
|
|
10297
10340
|
.thread .num { width: 17px; height: 17px; border-radius: 50%; background: var(--pending);
|
|
10298
|
-
color: #
|
|
10299
|
-
.thread.working .num { background: var(--link); }
|
|
10300
|
-
.thread.resolved .num { background: var(--success); }
|
|
10301
|
-
.thread.dismissed .num { background: var(--faint); }
|
|
10302
|
-
.thread .state { font-size: 11px; color: var(--
|
|
10303
|
-
.thread .anchor-label { color: var(--
|
|
10341
|
+
color: #2a1800; font-size: 10px; font-weight: 700; display: grid; place-items: center; flex: none; }
|
|
10342
|
+
.thread.working .num { background: var(--link); color: var(--badge-on-link); }
|
|
10343
|
+
.thread.resolved .num { background: var(--success); color: #fff; }
|
|
10344
|
+
.thread.dismissed .num { background: var(--faint); color: var(--badge-on-dismissed); }
|
|
10345
|
+
.thread .state { font-size: 11px; color: var(--muted-foreground); margin-left: auto; flex: none; }
|
|
10346
|
+
.thread .anchor-label { color: var(--muted-foreground); font-size: 11px; overflow: hidden;
|
|
10304
10347
|
text-overflow: ellipsis; white-space: nowrap; }
|
|
10305
10348
|
.thread .msg { margin: 4px 0 0; }
|
|
10306
10349
|
.thread .msg.agent { color: var(--muted-foreground); border-left: 2px solid var(--border);
|
|
10307
10350
|
padding-left: 8px; margin-top: 8px; }
|
|
10308
|
-
.thread .msg .who { font-weight: 600; font-size: 11px; display: block; color: var(--
|
|
10351
|
+
.thread .msg .who { font-weight: 600; font-size: 11px; display: block; color: var(--muted-foreground); }
|
|
10309
10352
|
.thread .draft-del, .thread .reopen-btn { margin-left: 6px; background: none; border: none;
|
|
10310
|
-
cursor: pointer; color: var(--
|
|
10353
|
+
cursor: pointer; color: var(--muted-foreground); font-size: 12px; padding: 3px 4px;
|
|
10354
|
+
min-width: 24px; min-height: 24px; flex: none; }
|
|
10311
10355
|
.thread .draft-del:hover, .thread .reopen-btn:hover { color: var(--foreground); }
|
|
10312
10356
|
.thread.orphaned .anchor-label { text-decoration: line-through; }
|
|
10313
|
-
.panel .empty { color: var(--
|
|
10357
|
+
.panel .empty { color: var(--muted-foreground); font-size: 12.5px; padding: 20px 4px; text-align: center; }
|
|
10314
10358
|
.submit-bar { display: none; align-items: center; gap: 8px; }
|
|
10315
10359
|
.submit-bar.show { display: flex; }
|
|
10316
10360
|
.submit-bar .btn { white-space: nowrap; }
|
|
@@ -10319,11 +10363,18 @@ function renderPreviewShell(options) {
|
|
|
10319
10363
|
color: var(--muted-foreground); background: var(--surface-warm);
|
|
10320
10364
|
border-radius: var(--r-md); padding: 8px 10px; }
|
|
10321
10365
|
.batch-status.show { display: flex; }
|
|
10366
|
+
.batch-status.manual { border-left: 3px solid var(--pending); }
|
|
10367
|
+
.batch-status.error { border-left: 3px solid var(--coral); }
|
|
10322
10368
|
.batch-status .spin { width: 12px; height: 12px; border-radius: 50%; flex: none;
|
|
10323
10369
|
border: 2px solid var(--link); border-top-color: transparent;
|
|
10324
10370
|
animation: spin .8s linear infinite; }
|
|
10371
|
+
.batch-status.static .spin { display: none; }
|
|
10325
10372
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
10326
|
-
|
|
10373
|
+
@media (prefers-reduced-motion: reduce) {
|
|
10374
|
+
.watch-dot { animation: none; }
|
|
10375
|
+
.batch-status .spin { display: none; }
|
|
10376
|
+
.mode-toggle .knob, .mode-toggle .knob::after, .toast { transition: none; }
|
|
10377
|
+
}
|
|
10327
10378
|
.toast { position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%);
|
|
10328
10379
|
background: var(--foreground); color: var(--background); font-size: 12.5px;
|
|
10329
10380
|
border-radius: var(--r-full); padding: 8px 16px; z-index: 90;
|
|
@@ -10353,7 +10404,6 @@ function renderPreviewShell(options) {
|
|
|
10353
10404
|
border-left: none; border-top: 1px solid var(--border);
|
|
10354
10405
|
box-shadow: var(--shadow-lg); z-index: 55; border-radius: 12px 12px 0 0; }
|
|
10355
10406
|
.local-badge { display: none; }
|
|
10356
|
-
.watch-label { display: none; }
|
|
10357
10407
|
.mode-toggle { right: 20px; bottom: calc(min(42vh, 340px) + 14px); }
|
|
10358
10408
|
.toast { bottom: calc(min(42vh, 340px) + 60px); }
|
|
10359
10409
|
}
|
|
@@ -10363,8 +10413,8 @@ function renderPreviewShell(options) {
|
|
|
10363
10413
|
<header class="topbar">
|
|
10364
10414
|
<div class="brand">as</div>
|
|
10365
10415
|
<span class="file-name">${escapeHtml(fileName)}</span>
|
|
10366
|
-
<span class="local-badge" data-msg="preview.localBadge"></span>
|
|
10367
|
-
<span style="font-size:12px;color:var(--muted-foreground)"><span class="watch-dot"></span><span class="watch-label" data-msg="preview.watching"></span></span>
|
|
10416
|
+
<span class="local-badge" data-msg="preview.localBadge" aria-hidden="true"></span>
|
|
10417
|
+
<span id="watchStatus" role="status" style="font-size:12px;color:var(--muted-foreground)"><span class="watch-dot" aria-hidden="true"></span><span class="watch-label" data-msg="preview.watching"></span></span>
|
|
10368
10418
|
<div class="spacer"></div>
|
|
10369
10419
|
<button class="btn btn-primary" id="shareBtn" data-msg="preview.share"></button>
|
|
10370
10420
|
</header>
|
|
@@ -10375,11 +10425,11 @@ function renderPreviewShell(options) {
|
|
|
10375
10425
|
<aside class="panel">
|
|
10376
10426
|
<h2 data-msg="preview.panelTitle"></h2>
|
|
10377
10427
|
<div class="submit-bar" id="submitBar">
|
|
10378
|
-
<button class="btn btn-primary" id="submitBtn"></button>
|
|
10428
|
+
<button class="btn btn-primary" id="submitBtn" aria-describedby="batchStatus"></button>
|
|
10379
10429
|
<button class="btn" id="discardAll" data-msg="preview.discardDrafts"></button>
|
|
10380
10430
|
</div>
|
|
10381
|
-
<div class="batch-status" id="batchStatus">
|
|
10382
|
-
<span class="spin"></span>
|
|
10431
|
+
<div class="batch-status" id="batchStatus" role="status" aria-live="polite" aria-atomic="true">
|
|
10432
|
+
<span class="spin" aria-hidden="true"></span>
|
|
10383
10433
|
<span id="batchText"></span>
|
|
10384
10434
|
</div>
|
|
10385
10435
|
<div class="empty" id="panelEmpty" data-msg="preview.emptyHint"></div>
|
|
@@ -10399,7 +10449,7 @@ function renderPreviewShell(options) {
|
|
|
10399
10449
|
<button class="btn btn-primary" id="popAdd" data-msg="preview.add"></button>
|
|
10400
10450
|
</div>
|
|
10401
10451
|
</div>
|
|
10402
|
-
<div class="toast" id="toast"></div>
|
|
10452
|
+
<div class="toast" id="toast" role="status" aria-live="polite" aria-atomic="true"></div>
|
|
10403
10453
|
<div class="notice" id="orphanNotice">
|
|
10404
10454
|
<span id="orphanText"></span>
|
|
10405
10455
|
<button class="btn" id="orphanDiscard" data-msg="preview.orphanDiscard"></button>
|
|
@@ -10436,6 +10486,9 @@ function renderPreviewShell(options) {
|
|
|
10436
10486
|
document.querySelectorAll('[data-msg]').forEach((el) => {
|
|
10437
10487
|
el.textContent = t(el.getAttribute('data-msg'));
|
|
10438
10488
|
});
|
|
10489
|
+
const watchStatus = document.getElementById('watchStatus');
|
|
10490
|
+
watchStatus.setAttribute('aria-label', t('preview.localBadge') + ' · ' + t('preview.watching'));
|
|
10491
|
+
watchStatus.title = t('preview.watching');
|
|
10439
10492
|
|
|
10440
10493
|
const frame = document.getElementById('artifactFrame');
|
|
10441
10494
|
|
|
@@ -10462,18 +10515,47 @@ function renderPreviewShell(options) {
|
|
|
10462
10515
|
endedBody.querySelector('code').textContent = CONFIG.resumeCommand;
|
|
10463
10516
|
|
|
10464
10517
|
let annotations = [];
|
|
10518
|
+
let agent = { state: 'manual_required' };
|
|
10465
10519
|
let pendingAnchor = null;
|
|
10466
10520
|
let annotateMode = true;
|
|
10467
10521
|
let revision = null;
|
|
10468
10522
|
let pendingReload = null;
|
|
10469
10523
|
let orphanedThreads = new Set();
|
|
10470
10524
|
let verifyPending = false;
|
|
10471
|
-
let batchTimer = null;
|
|
10472
|
-
let batchStartedAt = null;
|
|
10473
10525
|
let batchWorkingCount = 0;
|
|
10474
10526
|
function renderBatchStatus() {
|
|
10475
|
-
|
|
10476
|
-
|
|
10527
|
+
if (agent.state === 'processing') {
|
|
10528
|
+
batchText.textContent = tCount('preview.batchWorking', batchWorkingCount);
|
|
10529
|
+
return;
|
|
10530
|
+
}
|
|
10531
|
+
if (agent.state === 'queued') {
|
|
10532
|
+
const key = agent.provider === 'codex'
|
|
10533
|
+
? 'preview.batchQueuedCodex'
|
|
10534
|
+
: agent.provider === 'claude_code'
|
|
10535
|
+
? 'preview.batchQueuedClaude'
|
|
10536
|
+
: agent.provider === 'cursor'
|
|
10537
|
+
? 'preview.batchQueuedCursor'
|
|
10538
|
+
: 'preview.batchQueued';
|
|
10539
|
+
batchText.textContent = tCount(key, batchWorkingCount);
|
|
10540
|
+
return;
|
|
10541
|
+
}
|
|
10542
|
+
if (agent.state === 'failed') {
|
|
10543
|
+
const key = agent.provider === 'codex'
|
|
10544
|
+
? 'preview.batchFailedCodex'
|
|
10545
|
+
: agent.provider === 'claude_code'
|
|
10546
|
+
? 'preview.batchFailedClaude'
|
|
10547
|
+
: agent.provider === 'cursor'
|
|
10548
|
+
? 'preview.batchFailedCursor'
|
|
10549
|
+
: 'preview.batchFailed';
|
|
10550
|
+
batchText.textContent = tCount(key, batchWorkingCount);
|
|
10551
|
+
return;
|
|
10552
|
+
}
|
|
10553
|
+
const key = agent.provider === 'claude_code'
|
|
10554
|
+
? 'preview.batchManualClaude'
|
|
10555
|
+
: agent.provider === 'cursor'
|
|
10556
|
+
? 'preview.batchManualCursor'
|
|
10557
|
+
: 'preview.batchManual';
|
|
10558
|
+
batchText.textContent = tCount(key, batchWorkingCount);
|
|
10477
10559
|
}
|
|
10478
10560
|
let ended = false;
|
|
10479
10561
|
|
|
@@ -10617,7 +10699,11 @@ function renderPreviewShell(options) {
|
|
|
10617
10699
|
}
|
|
10618
10700
|
function stateLabel(status) {
|
|
10619
10701
|
if (status === 'draft') return t('preview.stateDraft');
|
|
10620
|
-
if (status === 'requested')
|
|
10702
|
+
if (status === 'requested') {
|
|
10703
|
+
return agent.state === 'queued'
|
|
10704
|
+
? t('preview.stateQueued')
|
|
10705
|
+
: t('preview.stateSaved');
|
|
10706
|
+
}
|
|
10621
10707
|
if (status === 'in_progress') return t('preview.stateWorking');
|
|
10622
10708
|
if (status === 'resolved') return t('preview.stateResolved');
|
|
10623
10709
|
return t('preview.stateDismissed');
|
|
@@ -10684,7 +10770,10 @@ function renderPreviewShell(options) {
|
|
|
10684
10770
|
});
|
|
10685
10771
|
panelEmpty.style.display = annotations.length === 0 ? '' : 'none';
|
|
10686
10772
|
const drafts = annotations.filter((entry) => entry.status === 'draft');
|
|
10773
|
+
const hasActiveBatch = annotations.some(
|
|
10774
|
+
(entry) => entry.status === 'requested' || entry.status === 'in_progress');
|
|
10687
10775
|
submitBtn.textContent = tCount('preview.requestFixes', drafts.length);
|
|
10776
|
+
submitBtn.disabled = hasActiveBatch;
|
|
10688
10777
|
submitBar.classList.toggle('show', drafts.length > 0);
|
|
10689
10778
|
const open = annotations.filter(
|
|
10690
10779
|
(entry) => entry.status !== 'resolved' && entry.status !== 'dismissed');
|
|
@@ -10694,26 +10783,22 @@ function renderPreviewShell(options) {
|
|
|
10694
10783
|
}
|
|
10695
10784
|
|
|
10696
10785
|
// --- batch status -------------------------------------------------------
|
|
10697
|
-
function fmtElapsed(ms) {
|
|
10698
|
-
const total = Math.floor(ms / 1000);
|
|
10699
|
-
return Math.floor(total / 60) + ':' + String(total % 60).padStart(2, '0');
|
|
10700
|
-
}
|
|
10701
10786
|
function updateBatchStatus() {
|
|
10702
10787
|
const working = annotations.filter(
|
|
10703
10788
|
(entry) => entry.status === 'requested' || entry.status === 'in_progress');
|
|
10704
10789
|
if (working.length === 0) {
|
|
10705
10790
|
batchStatus.classList.remove('show');
|
|
10706
|
-
|
|
10707
|
-
|
|
10791
|
+
batchStatus.classList.remove('manual');
|
|
10792
|
+
batchStatus.classList.remove('error');
|
|
10793
|
+
batchText.textContent = '';
|
|
10708
10794
|
return;
|
|
10709
10795
|
}
|
|
10710
|
-
if (batchStartedAt === null) batchStartedAt = Date.now();
|
|
10711
10796
|
batchStatus.classList.add('show');
|
|
10712
|
-
|
|
10713
|
-
|
|
10797
|
+
batchStatus.classList.toggle('static', agent.state !== 'processing');
|
|
10798
|
+
batchStatus.classList.toggle('manual', agent.state === 'manual_required');
|
|
10799
|
+
batchStatus.classList.toggle('error', agent.state === 'failed');
|
|
10714
10800
|
batchWorkingCount = working.length;
|
|
10715
10801
|
renderBatchStatus();
|
|
10716
|
-
if (!batchTimer) batchTimer = setInterval(renderBatchStatus, 1000);
|
|
10717
10802
|
}
|
|
10718
10803
|
|
|
10719
10804
|
submitBtn.addEventListener('click', () => { api('POST', '/api/annotations/submit'); });
|
|
@@ -10834,7 +10919,11 @@ function renderPreviewShell(options) {
|
|
|
10834
10919
|
// --- SSE ----------------------------------------------------------------
|
|
10835
10920
|
const events = new EventSource('/events');
|
|
10836
10921
|
events.addEventListener('annotations', (event) => {
|
|
10837
|
-
try {
|
|
10922
|
+
try {
|
|
10923
|
+
const data = JSON.parse(event.data);
|
|
10924
|
+
annotations = data.annotations || [];
|
|
10925
|
+
agent = data.agent || agent;
|
|
10926
|
+
}
|
|
10838
10927
|
catch (error) { return; }
|
|
10839
10928
|
renderPanel();
|
|
10840
10929
|
});
|
|
@@ -10884,6 +10973,7 @@ function renderPreviewShell(options) {
|
|
|
10884
10973
|
.then((response) => response.json())
|
|
10885
10974
|
.then((data) => {
|
|
10886
10975
|
annotations = (data && data.annotations) || [];
|
|
10976
|
+
agent = (data && data.agent) || agent;
|
|
10887
10977
|
revision = data ? data.revision : null;
|
|
10888
10978
|
renderPanel();
|
|
10889
10979
|
if (data && data.quarantined) {
|
|
@@ -10908,12 +10998,12 @@ function renderPreviewShell(options) {
|
|
|
10908
10998
|
const MAX_BODY_BYTES = 1048576;
|
|
10909
10999
|
const WATCH_DEBOUNCE_MS = 200;
|
|
10910
11000
|
const SSE_HEARTBEAT_MS = 15e3;
|
|
10911
|
-
/**
|
|
10912
|
-
*
|
|
11001
|
+
/** Name the main binary explicitly because the package also installs provider
|
|
11002
|
+
* launchers, and keep subdirectory paths relative to the current workspace. */
|
|
10913
11003
|
function previewResumeCommand(filePath) {
|
|
10914
11004
|
const from = relative(process.cwd(), filePath);
|
|
10915
11005
|
const relative$1 = from === "" || from.startsWith("..") ? filePath : from;
|
|
10916
|
-
return `
|
|
11006
|
+
return `npm exec --yes --package=@artifactshare/cli -- artifactshare preview ${/^[\w./@-]+$/.test(relative$1) ? relative$1 : `'${relative$1.replaceAll("'", `'\\''`)}'`}`;
|
|
10917
11007
|
}
|
|
10918
11008
|
function sha256Hex(input) {
|
|
10919
11009
|
return createHash("sha256").update(input).digest("hex");
|
|
@@ -11001,6 +11091,14 @@ function doneEventThreads(store, items) {
|
|
|
11001
11091
|
}
|
|
11002
11092
|
async function startPreviewServer(options) {
|
|
11003
11093
|
const { filePath, store, sessionId } = options;
|
|
11094
|
+
const notification = createPreviewNotificationCoordinator({
|
|
11095
|
+
sessionId,
|
|
11096
|
+
registration: options.notificationRegistration ?? defaultPreviewNotificationRegistration(),
|
|
11097
|
+
store,
|
|
11098
|
+
...options.notificationAdapter ? { adapter: options.notificationAdapter } : {},
|
|
11099
|
+
...options.notificationTimeoutMs !== void 0 ? { timeoutMs: options.notificationTimeoutMs } : {},
|
|
11100
|
+
...options.onNotificationRegistrationChange ? { onRegistrationChange: options.onNotificationRegistrationChange } : {}
|
|
11101
|
+
});
|
|
11004
11102
|
const fileName = basename(filePath);
|
|
11005
11103
|
const isMarkdown = filePath.toLowerCase().endsWith(".md");
|
|
11006
11104
|
let revision = "";
|
|
@@ -11017,12 +11115,16 @@ async function startPreviewServer(options) {
|
|
|
11017
11115
|
const events = new EventEmitter();
|
|
11018
11116
|
events.setMaxListeners(0);
|
|
11019
11117
|
const sseClients = /* @__PURE__ */ new Set();
|
|
11118
|
+
let activeWait = false;
|
|
11020
11119
|
function broadcast(event, data) {
|
|
11021
11120
|
const frame = `event: ${event}\ndata: ${JSON.stringify(data)}\n\n`;
|
|
11022
11121
|
for (const client of sseClients) client.response.write(frame);
|
|
11023
11122
|
}
|
|
11024
11123
|
function broadcastAnnotations() {
|
|
11025
|
-
broadcast("annotations", {
|
|
11124
|
+
broadcast("annotations", {
|
|
11125
|
+
annotations: store.all(),
|
|
11126
|
+
agent: notification.projection()
|
|
11127
|
+
});
|
|
11026
11128
|
}
|
|
11027
11129
|
let watcher = null;
|
|
11028
11130
|
let debounceTimer = null;
|
|
@@ -11089,7 +11191,10 @@ async function startPreviewServer(options) {
|
|
|
11089
11191
|
}, SSE_HEARTBEAT_MS)
|
|
11090
11192
|
};
|
|
11091
11193
|
sseClients.add(client);
|
|
11092
|
-
response.write(`event: annotations\ndata: ${JSON.stringify({
|
|
11194
|
+
response.write(`event: annotations\ndata: ${JSON.stringify({
|
|
11195
|
+
annotations: store.all(),
|
|
11196
|
+
agent: notification.projection()
|
|
11197
|
+
})}\n\n`);
|
|
11093
11198
|
response.on("close", () => {
|
|
11094
11199
|
clearInterval(client.heartbeat);
|
|
11095
11200
|
sseClients.delete(client);
|
|
@@ -11100,24 +11205,40 @@ async function startPreviewServer(options) {
|
|
|
11100
11205
|
if (!read.ok) return sendJson(response, read.status, { error: "bad_body" });
|
|
11101
11206
|
const body = read.body ?? {};
|
|
11102
11207
|
const waitSeconds = typeof body.wait === "number" && Number.isFinite(body.wait) ? Math.max(0, Math.min(3600, body.wait)) : 0;
|
|
11208
|
+
if (activeWait) return sendJson(response, 409, {
|
|
11209
|
+
error: "active_wait_conflict",
|
|
11210
|
+
agent: notification.projection()
|
|
11211
|
+
});
|
|
11103
11212
|
const immediate = store.deliver();
|
|
11104
11213
|
if (immediate.length > 0 || waitSeconds === 0) {
|
|
11105
11214
|
const result = {
|
|
11106
11215
|
items: immediate,
|
|
11107
11216
|
...immediate.length === 0 && waitSeconds === 0 ? { timed_out: true } : {},
|
|
11108
|
-
revision
|
|
11217
|
+
revision,
|
|
11218
|
+
agent: notification.projection()
|
|
11109
11219
|
};
|
|
11110
11220
|
if (immediate.length > 0) broadcastAnnotations();
|
|
11111
11221
|
return sendJson(response, 200, result);
|
|
11112
11222
|
}
|
|
11223
|
+
activeWait = true;
|
|
11224
|
+
notification.setWaitConnected(true);
|
|
11225
|
+
broadcastAnnotations();
|
|
11113
11226
|
let settled = false;
|
|
11227
|
+
const releaseWait = () => {
|
|
11228
|
+
if (!activeWait) return;
|
|
11229
|
+
activeWait = false;
|
|
11230
|
+
notification.setWaitConnected(false);
|
|
11231
|
+
};
|
|
11114
11232
|
const finish = (result) => {
|
|
11115
11233
|
if (settled) return;
|
|
11116
11234
|
settled = true;
|
|
11117
11235
|
events.off("submitted", onSubmit);
|
|
11118
11236
|
events.off("closing", onClosing);
|
|
11119
11237
|
clearTimeout(timer);
|
|
11238
|
+
releaseWait();
|
|
11239
|
+
result.agent = notification.projection();
|
|
11120
11240
|
sendJson(response, 200, result);
|
|
11241
|
+
broadcastAnnotations();
|
|
11121
11242
|
};
|
|
11122
11243
|
const onSubmit = () => {
|
|
11123
11244
|
const items = store.deliver();
|
|
@@ -11125,21 +11246,24 @@ async function startPreviewServer(options) {
|
|
|
11125
11246
|
broadcastAnnotations();
|
|
11126
11247
|
finish({
|
|
11127
11248
|
items,
|
|
11128
|
-
revision
|
|
11249
|
+
revision,
|
|
11250
|
+
agent: notification.projection()
|
|
11129
11251
|
});
|
|
11130
11252
|
};
|
|
11131
11253
|
const onClosing = () => {
|
|
11132
11254
|
finish({
|
|
11133
11255
|
items: [],
|
|
11134
11256
|
session_ended: true,
|
|
11135
|
-
revision
|
|
11257
|
+
revision,
|
|
11258
|
+
agent: notification.projection()
|
|
11136
11259
|
});
|
|
11137
11260
|
};
|
|
11138
11261
|
const timer = setTimeout(() => {
|
|
11139
11262
|
finish({
|
|
11140
11263
|
items: [],
|
|
11141
11264
|
timed_out: true,
|
|
11142
|
-
revision
|
|
11265
|
+
revision,
|
|
11266
|
+
agent: notification.projection()
|
|
11143
11267
|
});
|
|
11144
11268
|
}, waitSeconds * 1e3);
|
|
11145
11269
|
events.on("submitted", onSubmit);
|
|
@@ -11150,6 +11274,8 @@ async function startPreviewServer(options) {
|
|
|
11150
11274
|
events.off("submitted", onSubmit);
|
|
11151
11275
|
events.off("closing", onClosing);
|
|
11152
11276
|
clearTimeout(timer);
|
|
11277
|
+
releaseWait();
|
|
11278
|
+
broadcastAnnotations();
|
|
11153
11279
|
});
|
|
11154
11280
|
}
|
|
11155
11281
|
async function handleArtifactRequest(request, response) {
|
|
@@ -11176,6 +11302,7 @@ async function startPreviewServer(options) {
|
|
|
11176
11302
|
if (path === "/events") return serveEvents(response);
|
|
11177
11303
|
if (path === "/api/annotations") return sendJson(response, 200, {
|
|
11178
11304
|
annotations: store.all(),
|
|
11305
|
+
agent: notification.projection(),
|
|
11179
11306
|
revision,
|
|
11180
11307
|
quarantined: store.quarantinedPath !== null
|
|
11181
11308
|
});
|
|
@@ -11204,11 +11331,25 @@ async function startPreviewServer(options) {
|
|
|
11204
11331
|
return sendJson(response, 200, { discarded: discarded.length });
|
|
11205
11332
|
}
|
|
11206
11333
|
if (method === "POST" && path === "/api/annotations/submit") {
|
|
11207
|
-
await readBodyJson(request);
|
|
11334
|
+
const read = await readBodyJson(request);
|
|
11335
|
+
if (!read.ok) return sendJson(response, read.status, { error: "bad_body" });
|
|
11336
|
+
if (typeof read.body !== "object" || read.body === null || Array.isArray(read.body) || Object.keys(read.body).length > 0) return sendJson(response, 400, { error: "invalid_submit_body" });
|
|
11208
11337
|
const submitted = store.submitDrafts();
|
|
11338
|
+
if (!submitted.ok) return sendJson(response, 409, {
|
|
11339
|
+
error: submitted.reason,
|
|
11340
|
+
batch_id: submitted.batch.id,
|
|
11341
|
+
agent: notification.projection()
|
|
11342
|
+
});
|
|
11343
|
+
if (submitted.batch) {
|
|
11344
|
+
if (notification.registration.capability === "wait" && activeWait) events.emit("submitted");
|
|
11345
|
+
else await notification.notifyBatch(submitted.batch.id);
|
|
11346
|
+
}
|
|
11209
11347
|
broadcastAnnotations();
|
|
11210
|
-
|
|
11211
|
-
|
|
11348
|
+
return sendJson(response, 200, {
|
|
11349
|
+
submitted: submitted.annotations.length,
|
|
11350
|
+
...submitted.batch ? { batch_id: submitted.batch.id } : {},
|
|
11351
|
+
agent: notification.projection()
|
|
11352
|
+
});
|
|
11212
11353
|
}
|
|
11213
11354
|
const reopenMatch = path.match(/^\/api\/annotations\/([^/]+)\/reopen$/);
|
|
11214
11355
|
if (method === "POST" && reopenMatch) {
|
|
@@ -11279,7 +11420,8 @@ async function startPreviewServer(options) {
|
|
|
11279
11420
|
broadcastAnnotations();
|
|
11280
11421
|
return sendJson(response, 200, {
|
|
11281
11422
|
results,
|
|
11282
|
-
revision
|
|
11423
|
+
revision,
|
|
11424
|
+
agent: notification.projection()
|
|
11283
11425
|
});
|
|
11284
11426
|
}
|
|
11285
11427
|
if (method === "POST" && path === "/api/agent/reply") {
|
|
@@ -11367,24 +11509,178 @@ async function startPreviewServer(options) {
|
|
|
11367
11509
|
port,
|
|
11368
11510
|
sharePort,
|
|
11369
11511
|
url: `http://127.0.0.1:${port}/`,
|
|
11512
|
+
agent: notification.projection(),
|
|
11513
|
+
get notificationRegistration() {
|
|
11514
|
+
return notification.registration;
|
|
11515
|
+
},
|
|
11370
11516
|
closed,
|
|
11371
11517
|
close
|
|
11372
11518
|
};
|
|
11373
11519
|
}
|
|
11374
11520
|
//#endregion
|
|
11521
|
+
//#region src/preview/codex-notification.ts
|
|
11522
|
+
const execFileAsync = promisify(execFile);
|
|
11523
|
+
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
11524
|
+
const PREVIEW_SESSION_PATTERN = /^[0-9a-f]{16}$/;
|
|
11525
|
+
const BATCH_ID_PATTERN = /^[a-z0-9_-]{1,128}$/i;
|
|
11526
|
+
function codexEnvironmentTarget(environment) {
|
|
11527
|
+
const thread = environment.CODEX_THREAD_ID?.trim() ?? "";
|
|
11528
|
+
const session = environment.CODEX_SESSION_ID?.trim() ?? "";
|
|
11529
|
+
if (thread === "" && session === "") return {
|
|
11530
|
+
detected: false,
|
|
11531
|
+
target: null
|
|
11532
|
+
};
|
|
11533
|
+
const target = UUID_PATTERN.test(thread) ? thread : UUID_PATTERN.test(session) ? session : "";
|
|
11534
|
+
return {
|
|
11535
|
+
detected: true,
|
|
11536
|
+
target: UUID_PATTERN.test(target) ? target : null
|
|
11537
|
+
};
|
|
11538
|
+
}
|
|
11539
|
+
function codexNotificationRegistration(environment = process.env, now = () => /* @__PURE__ */ new Date()) {
|
|
11540
|
+
const detected = codexEnvironmentTarget(environment);
|
|
11541
|
+
if (!detected.detected) return null;
|
|
11542
|
+
return {
|
|
11543
|
+
provider: "codex",
|
|
11544
|
+
transport: "codex_queue",
|
|
11545
|
+
capability: detected.target === null ? "manual" : "push",
|
|
11546
|
+
target: detected.target,
|
|
11547
|
+
registered_at: now().toISOString()
|
|
11548
|
+
};
|
|
11549
|
+
}
|
|
11550
|
+
function codexQueueMessage(event) {
|
|
11551
|
+
return [
|
|
11552
|
+
"Artifact Share preview batch ready.",
|
|
11553
|
+
`event=${event.event}`,
|
|
11554
|
+
`preview_session_id=${event.preview_session_id}`,
|
|
11555
|
+
`batch_id=${event.batch_id}`,
|
|
11556
|
+
`Run: npm exec --yes --package=@artifactshare/cli -- artifactshare preview next --session ${event.preview_session_id} --json`
|
|
11557
|
+
].join(" ");
|
|
11558
|
+
}
|
|
11559
|
+
async function defaultQueueRunner(invocation) {
|
|
11560
|
+
await execFileAsync(invocation.command, invocation.args, {
|
|
11561
|
+
windowsHide: true,
|
|
11562
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments,
|
|
11563
|
+
timeout: 1e4
|
|
11564
|
+
});
|
|
11565
|
+
}
|
|
11566
|
+
function codexQueueInvocation(target, event, platform = process.platform, commandInterpreter = process.env.ComSpec || "cmd.exe") {
|
|
11567
|
+
if (!UUID_PATTERN.test(target) || !PREVIEW_SESSION_PATTERN.test(event.preview_session_id) || !BATCH_ID_PATTERN.test(event.batch_id)) return null;
|
|
11568
|
+
const args = [
|
|
11569
|
+
"queue",
|
|
11570
|
+
"--thread",
|
|
11571
|
+
target,
|
|
11572
|
+
"--message",
|
|
11573
|
+
codexQueueMessage(event)
|
|
11574
|
+
];
|
|
11575
|
+
if (platform !== "win32") return {
|
|
11576
|
+
command: "codex",
|
|
11577
|
+
args
|
|
11578
|
+
};
|
|
11579
|
+
return {
|
|
11580
|
+
command: commandInterpreter,
|
|
11581
|
+
windowsVerbatimArguments: true,
|
|
11582
|
+
args: [
|
|
11583
|
+
"/d",
|
|
11584
|
+
"/s",
|
|
11585
|
+
"/c",
|
|
11586
|
+
`codex queue --thread ${target} --message "${codexQueueMessage(event)}"`
|
|
11587
|
+
]
|
|
11588
|
+
};
|
|
11589
|
+
}
|
|
11590
|
+
function queueFailure(error) {
|
|
11591
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") return {
|
|
11592
|
+
status: "failed",
|
|
11593
|
+
code: "target_unavailable",
|
|
11594
|
+
retryable: false
|
|
11595
|
+
};
|
|
11596
|
+
return {
|
|
11597
|
+
status: "failed",
|
|
11598
|
+
code: "rejected",
|
|
11599
|
+
retryable: false
|
|
11600
|
+
};
|
|
11601
|
+
}
|
|
11602
|
+
function createCodexQueueAdapter(target, runQueue = defaultQueueRunner, platform = process.platform) {
|
|
11603
|
+
if (!UUID_PATTERN.test(target)) throw new Error("Codex queue target must be a UUID.");
|
|
11604
|
+
return { async dispatch(event) {
|
|
11605
|
+
const invocation = codexQueueInvocation(target, event, platform);
|
|
11606
|
+
if (!invocation) return {
|
|
11607
|
+
status: "failed",
|
|
11608
|
+
code: "invalid_response",
|
|
11609
|
+
retryable: false
|
|
11610
|
+
};
|
|
11611
|
+
try {
|
|
11612
|
+
await runQueue(invocation);
|
|
11613
|
+
return { status: "accepted" };
|
|
11614
|
+
} catch (error) {
|
|
11615
|
+
return queueFailure(error);
|
|
11616
|
+
}
|
|
11617
|
+
} };
|
|
11618
|
+
}
|
|
11619
|
+
//#endregion
|
|
11620
|
+
//#region src/preview/claude-notification.ts
|
|
11621
|
+
const CLAUDE_SESSION_PATTERN = /^[a-zA-Z0-9_-]{1,128}$/;
|
|
11622
|
+
function backgroundAvailable(environment) {
|
|
11623
|
+
const disabled = environment.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS?.trim().toLowerCase();
|
|
11624
|
+
return disabled !== "1" && disabled !== "true";
|
|
11625
|
+
}
|
|
11626
|
+
function claudeNotificationRegistration(environment = process.env, now = () => /* @__PURE__ */ new Date()) {
|
|
11627
|
+
const sessionId = environment.CLAUDE_CODE_SESSION_ID?.trim() ?? "";
|
|
11628
|
+
if (sessionId === "") return null;
|
|
11629
|
+
if (!CLAUDE_SESSION_PATTERN.test(sessionId)) return {
|
|
11630
|
+
provider: "claude_code",
|
|
11631
|
+
transport: "manual",
|
|
11632
|
+
capability: "manual",
|
|
11633
|
+
target: null,
|
|
11634
|
+
registered_at: now().toISOString()
|
|
11635
|
+
};
|
|
11636
|
+
const available = backgroundAvailable(environment);
|
|
11637
|
+
return {
|
|
11638
|
+
provider: "claude_code",
|
|
11639
|
+
transport: available ? "background_wait" : "manual",
|
|
11640
|
+
capability: available ? "wait" : "manual",
|
|
11641
|
+
target: null,
|
|
11642
|
+
registered_at: now().toISOString()
|
|
11643
|
+
};
|
|
11644
|
+
}
|
|
11645
|
+
//#endregion
|
|
11375
11646
|
//#region src/command-runners/preview.ts
|
|
11647
|
+
function previewNotificationForEnvironment() {
|
|
11648
|
+
const codex = codexNotificationRegistration();
|
|
11649
|
+
if (codex) return {
|
|
11650
|
+
registration: codex,
|
|
11651
|
+
adapter: codex.capability === "push" && codex.target !== null ? createCodexQueueAdapter(codex.target) : void 0,
|
|
11652
|
+
timeoutMs: void 0
|
|
11653
|
+
};
|
|
11654
|
+
const claude = claudeNotificationRegistration();
|
|
11655
|
+
if (claude) return {
|
|
11656
|
+
registration: claude,
|
|
11657
|
+
adapter: void 0,
|
|
11658
|
+
timeoutMs: void 0
|
|
11659
|
+
};
|
|
11660
|
+
const cursor = cursorNotificationRegistration();
|
|
11661
|
+
if (cursor) return {
|
|
11662
|
+
registration: cursor,
|
|
11663
|
+
adapter: cursor.capability === "push" && cursor.target !== null ? createCursorAcpAdapter(cursor.target) : void 0,
|
|
11664
|
+
timeoutMs: cursor.capability === "push" ? CURSOR_ACP_NOTIFICATION_TIMEOUT_MS : void 0
|
|
11665
|
+
};
|
|
11666
|
+
return {
|
|
11667
|
+
registration: defaultPreviewNotificationRegistration(),
|
|
11668
|
+
adapter: void 0,
|
|
11669
|
+
timeoutMs: void 0
|
|
11670
|
+
};
|
|
11671
|
+
}
|
|
11376
11672
|
function sessionNotFoundError(target) {
|
|
11377
11673
|
return cliError({
|
|
11378
11674
|
code: "preview_session_not_found",
|
|
11379
11675
|
message: "No live preview session was found.",
|
|
11380
11676
|
why: target ? `No running preview serves ${target}.` : "No running preview session matches the request.",
|
|
11381
|
-
hint: "Start one with:
|
|
11677
|
+
hint: "Start one with: npm exec --yes --package=@artifactshare/cli -- artifactshare preview <file>",
|
|
11382
11678
|
agentRecoverable: false,
|
|
11383
11679
|
requiresHuman: true,
|
|
11384
11680
|
recovery: { kind: "ask_human" }
|
|
11385
11681
|
});
|
|
11386
11682
|
}
|
|
11387
|
-
async function resolveTarget(parsed) {
|
|
11683
|
+
async function resolveTarget(parsed, allowLegacy = false) {
|
|
11388
11684
|
const explicitSession = typeof parsed.options.session === "string" ? parsed.options.session : null;
|
|
11389
11685
|
const positional = parsed.positionals[0];
|
|
11390
11686
|
if (explicitSession !== null && positional !== void 0) return { error: validationError("Pass a file or --session, not both.", "Drop one selector so the target is unambiguous.") };
|
|
@@ -11393,7 +11689,15 @@ async function resolveTarget(parsed) {
|
|
|
11393
11689
|
const session = readSessionFile(explicitSession);
|
|
11394
11690
|
if (!session) return { error: sessionNotFoundError(explicitSession) };
|
|
11395
11691
|
const live = await probeSession(session);
|
|
11396
|
-
if (live.state === "
|
|
11692
|
+
if (live.state === "legacy") {
|
|
11693
|
+
if (allowLegacy) return { target: {
|
|
11694
|
+
port: live.session.port,
|
|
11695
|
+
sessionId: live.session.session_id,
|
|
11696
|
+
realpath: live.session.realpath
|
|
11697
|
+
} };
|
|
11698
|
+
return { error: sessionUnverifiedError(live.session.realpath, true) };
|
|
11699
|
+
}
|
|
11700
|
+
if (live.state === "unverified") return { error: sessionUnverifiedError(live.session.realpath, live.session.legacy === true) };
|
|
11397
11701
|
if (live.state !== "live") return { error: sessionNotFoundError(explicitSession) };
|
|
11398
11702
|
return { target: {
|
|
11399
11703
|
port: live.session.port,
|
|
@@ -11404,7 +11708,15 @@ async function resolveTarget(parsed) {
|
|
|
11404
11708
|
if (positional) {
|
|
11405
11709
|
const path = previewIdentityPath(positional);
|
|
11406
11710
|
const live = await resolveLiveSession(path);
|
|
11407
|
-
if (live.state === "
|
|
11711
|
+
if (live.state === "legacy") {
|
|
11712
|
+
if (allowLegacy) return { target: {
|
|
11713
|
+
port: live.session.port,
|
|
11714
|
+
sessionId: live.session.session_id,
|
|
11715
|
+
realpath: live.session.realpath
|
|
11716
|
+
} };
|
|
11717
|
+
return { error: sessionUnverifiedError(path, true) };
|
|
11718
|
+
}
|
|
11719
|
+
if (live.state === "unverified") return { error: sessionUnverifiedError(path, live.session.legacy === true) };
|
|
11408
11720
|
if (live.state !== "live") return { error: sessionNotFoundError(positional) };
|
|
11409
11721
|
return { target: {
|
|
11410
11722
|
port: live.session.port,
|
|
@@ -11425,19 +11737,23 @@ async function resolveTarget(parsed) {
|
|
|
11425
11737
|
const session = readSessionFile(name.replace(/\.json$/, ""));
|
|
11426
11738
|
if (!session) continue;
|
|
11427
11739
|
const live = await probeSession(session);
|
|
11428
|
-
if (live.state === "live") liveSessions.push({
|
|
11740
|
+
if (live.state === "live" || live.state === "legacy" && allowLegacy) liveSessions.push({
|
|
11429
11741
|
port: live.session.port,
|
|
11430
11742
|
sessionId: live.session.session_id,
|
|
11431
11743
|
realpath: live.session.realpath
|
|
11432
11744
|
});
|
|
11433
|
-
else if (live.state === "unverified") unverified.push(
|
|
11745
|
+
else if (live.state === "legacy" || live.state === "unverified") unverified.push({
|
|
11746
|
+
realpath: live.session.realpath,
|
|
11747
|
+
legacy: live.session.legacy === true
|
|
11748
|
+
});
|
|
11434
11749
|
}
|
|
11435
11750
|
const only = liveSessions[0];
|
|
11436
11751
|
if (liveSessions.length === 1 && only && unverified.length === 0) return { target: only };
|
|
11437
11752
|
if (liveSessions.length === 1 && unverified.length > 0) return { error: validationError("A preview session could not be verified, so the target is ambiguous.", "Pass the file path or --session <id> to pick one.") };
|
|
11753
|
+
if (unverified.length > 1) return { error: validationError("Multiple preview sessions could not be verified.", "Pass the file path or --session <id> to pick one.") };
|
|
11438
11754
|
if (liveSessions.length === 0) {
|
|
11439
11755
|
const wedged = unverified[0];
|
|
11440
|
-
if (unverified.length === 1 && wedged !== void 0) return { error: sessionUnverifiedError(wedged) };
|
|
11756
|
+
if (unverified.length === 1 && wedged !== void 0) return { error: sessionUnverifiedError(wedged.realpath, wedged.legacy) };
|
|
11441
11757
|
return { error: sessionNotFoundError(null) };
|
|
11442
11758
|
}
|
|
11443
11759
|
return { error: validationError("Multiple preview sessions are live.", "Pass the file path or --session <id> to pick one.") };
|
|
@@ -11461,6 +11777,21 @@ function requestedCredentials(options) {
|
|
|
11461
11777
|
function sameCredentials(a, b) {
|
|
11462
11778
|
return a.profile === b.profile && a.base_url === b.base_url && a.token_fingerprint === b.token_fingerprint && a.cwd === b.cwd;
|
|
11463
11779
|
}
|
|
11780
|
+
async function readAgentProjection(port, fallback) {
|
|
11781
|
+
try {
|
|
11782
|
+
const response = await fetch(`http://127.0.0.1:${port}/api/annotations`, { signal: AbortSignal.timeout(2e3) });
|
|
11783
|
+
const agent = (await response.json()).agent;
|
|
11784
|
+
if (response.ok && agent && typeof agent.provider === "string" && typeof agent.transport === "string" && (agent.capability === "push" || agent.capability === "wait" || agent.capability === "manual") && [
|
|
11785
|
+
"waiting",
|
|
11786
|
+
"queued",
|
|
11787
|
+
"processing",
|
|
11788
|
+
"completed",
|
|
11789
|
+
"failed",
|
|
11790
|
+
"manual_required"
|
|
11791
|
+
].includes(String(agent.state))) return agent;
|
|
11792
|
+
} catch {}
|
|
11793
|
+
return fallback;
|
|
11794
|
+
}
|
|
11464
11795
|
function sessionIdOfPath(input) {
|
|
11465
11796
|
return sessionIdForPath(previewIdentityPath(input));
|
|
11466
11797
|
}
|
|
@@ -11471,7 +11802,7 @@ function startInProgressError(target) {
|
|
|
11471
11802
|
code: "preview_session_unverified",
|
|
11472
11803
|
message: "Another preview for this file is starting.",
|
|
11473
11804
|
why: `A start is already in progress for ${target}.`,
|
|
11474
|
-
hint: "Retry in a moment, or clear it with:
|
|
11805
|
+
hint: "Retry in a moment, or clear it with: npm exec --yes --package=@artifactshare/cli -- artifactshare preview stop <file> --force",
|
|
11475
11806
|
agentRecoverable: true,
|
|
11476
11807
|
requiresHuman: false,
|
|
11477
11808
|
recovery: { kind: "retry_later" }
|
|
@@ -11484,28 +11815,47 @@ function previewUnreachableError(target) {
|
|
|
11484
11815
|
code: "preview_session_unverified",
|
|
11485
11816
|
message: "The preview session did not respond.",
|
|
11486
11817
|
why: `The request to the preview for ${target} timed out or was interrupted.`,
|
|
11487
|
-
hint: "Retry in a moment. If it stays stuck, ask the user to stop that preview process, then clear the record with:
|
|
11818
|
+
hint: "Retry in a moment. If it stays stuck, ask the user to stop that preview process, then clear the record with: npm exec --yes --package=@artifactshare/cli -- artifactshare preview stop <file> --force",
|
|
11488
11819
|
agentRecoverable: true,
|
|
11489
11820
|
requiresHuman: false,
|
|
11490
11821
|
recovery: { kind: "retry_later" }
|
|
11491
11822
|
});
|
|
11492
11823
|
}
|
|
11493
|
-
function sessionUnverifiedError(target) {
|
|
11824
|
+
function sessionUnverifiedError(target, legacy = false) {
|
|
11825
|
+
if (legacy) return cliError({
|
|
11826
|
+
code: "preview_session_unverified",
|
|
11827
|
+
message: "This preview session must be restarted.",
|
|
11828
|
+
why: `The preview serving ${target} was started by a CLI without the current notification contract.`,
|
|
11829
|
+
hint: "Stop that preview process, then start the preview again with the current CLI.",
|
|
11830
|
+
agentRecoverable: false,
|
|
11831
|
+
requiresHuman: true,
|
|
11832
|
+
recovery: { kind: "ask_human" }
|
|
11833
|
+
});
|
|
11494
11834
|
return cliError({
|
|
11495
11835
|
code: "preview_session_unverified",
|
|
11496
11836
|
message: "A preview session for this file could not be verified.",
|
|
11497
11837
|
why: `A session is recorded for ${target} but it did not answer.`,
|
|
11498
|
-
hint: "Retry in a moment. If it stays stuck, ask the user to stop that preview process, then clear the record with:
|
|
11838
|
+
hint: "Retry in a moment. If it stays stuck, ask the user to stop that preview process, then clear the record with: npm exec --yes --package=@artifactshare/cli -- artifactshare preview stop <file> --force",
|
|
11499
11839
|
agentRecoverable: true,
|
|
11500
11840
|
requiresHuman: false,
|
|
11501
11841
|
recovery: { kind: "retry_later" }
|
|
11502
11842
|
});
|
|
11503
11843
|
}
|
|
11504
11844
|
function previewRequestError(reason, target) {
|
|
11845
|
+
const detail = typeof reason === "string" ? reason : "request_failed";
|
|
11846
|
+
if (detail === "active_wait_conflict") return cliError({
|
|
11847
|
+
code: "preview_wait_conflict",
|
|
11848
|
+
message: "Another preview wait already reserves this session.",
|
|
11849
|
+
why: `The preview serving ${target} accepts only one active long poll.`,
|
|
11850
|
+
hint: "Use the existing wait, or retry after it returns or is cancelled.",
|
|
11851
|
+
agentRecoverable: true,
|
|
11852
|
+
requiresHuman: false,
|
|
11853
|
+
recovery: { kind: "retry_later" }
|
|
11854
|
+
});
|
|
11505
11855
|
return cliError({
|
|
11506
11856
|
code: "preview_request_failed",
|
|
11507
11857
|
message: "The preview server rejected the request.",
|
|
11508
|
-
why: `The preview serving ${target} answered with ${
|
|
11858
|
+
why: `The preview serving ${target} answered with ${detail}.`,
|
|
11509
11859
|
hint: "Check the annotation payload, then retry against the same session.",
|
|
11510
11860
|
agentRecoverable: true,
|
|
11511
11861
|
requiresHuman: false,
|
|
@@ -11568,15 +11918,24 @@ async function runPreview(parsed, mode) {
|
|
|
11568
11918
|
const lower = real.realpath.toLowerCase();
|
|
11569
11919
|
if (!lower.endsWith(".md") && !lower.endsWith(".html")) return writeFailure(command, validationError("Only .md and .html files can be previewed.", "Pass a single Markdown or HTML file."), mode, 1);
|
|
11570
11920
|
const existing = await resolveLiveSession(real.realpath);
|
|
11571
|
-
|
|
11921
|
+
const requestedNotification = previewNotificationForEnvironment();
|
|
11922
|
+
if (existing.state === "legacy" || existing.state === "unverified") return writeFailure(command, sessionUnverifiedError(real.realpath, existing.session.legacy === true), mode, 1);
|
|
11572
11923
|
if (existing.state === "live") {
|
|
11573
|
-
if (!sameCredentials(existing.session.credentials, requestedCredentials(parsed.options))) return writeFailure(command, validationError("The live preview was started with different credentials.", `Stop it first:
|
|
11924
|
+
if (!sameCredentials(existing.session.credentials, requestedCredentials(parsed.options))) return writeFailure(command, validationError("The live preview was started with different credentials.", `Stop it first: npm exec --yes --package=@artifactshare/cli -- artifactshare preview stop ${positional}`), mode, 1);
|
|
11925
|
+
if (!samePreviewNotificationRegistration(existing.session.agent_notification, requestedNotification.registration)) return writeFailure(command, validationError("The live preview belongs to a different agent session.", `Stop it first: npm exec --yes --package=@artifactshare/cli -- artifactshare preview stop ${positional}`), mode, 1);
|
|
11574
11926
|
const reusedUrl = `http://127.0.0.1:${existing.session.port}/`;
|
|
11927
|
+
const reusedAgent = await readAgentProjection(existing.session.port, {
|
|
11928
|
+
provider: existing.session.agent_notification.provider,
|
|
11929
|
+
transport: existing.session.agent_notification.transport,
|
|
11930
|
+
capability: existing.session.agent_notification.capability,
|
|
11931
|
+
state: "manual_required"
|
|
11932
|
+
});
|
|
11575
11933
|
writeSuccessLine(command, {
|
|
11576
11934
|
url: reusedUrl,
|
|
11577
11935
|
session: existing.session.session_id,
|
|
11578
11936
|
share_origin: `http://127.0.0.1:${existing.session.share_port}`,
|
|
11579
|
-
reused: true
|
|
11937
|
+
reused: true,
|
|
11938
|
+
agent: reusedAgent
|
|
11580
11939
|
}, mode);
|
|
11581
11940
|
if (parsed.options.noOpen !== true) await openDeviceAuthorizationUrl(reusedUrl).catch(() => void 0);
|
|
11582
11941
|
return;
|
|
@@ -11593,6 +11952,12 @@ async function runPreview(parsed, mode) {
|
|
|
11593
11952
|
filePath: real.realpath,
|
|
11594
11953
|
store,
|
|
11595
11954
|
sessionId,
|
|
11955
|
+
notificationRegistration: requestedNotification.registration,
|
|
11956
|
+
...requestedNotification.adapter ? { notificationAdapter: requestedNotification.adapter } : {},
|
|
11957
|
+
...requestedNotification.timeoutMs !== void 0 ? { notificationTimeoutMs: requestedNotification.timeoutMs } : {},
|
|
11958
|
+
onNotificationRegistrationChange(registration) {
|
|
11959
|
+
updateSessionNotificationRegistration(sessionId, registration);
|
|
11960
|
+
},
|
|
11596
11961
|
cliOptions: parsed.options
|
|
11597
11962
|
});
|
|
11598
11963
|
started = server;
|
|
@@ -11603,7 +11968,8 @@ async function runPreview(parsed, mode) {
|
|
|
11603
11968
|
share_port: server.sharePort,
|
|
11604
11969
|
pid: process.pid,
|
|
11605
11970
|
started_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11606
|
-
credentials: requestedCredentials(parsed.options)
|
|
11971
|
+
credentials: requestedCredentials(parsed.options),
|
|
11972
|
+
agent_notification: server.notificationRegistration
|
|
11607
11973
|
});
|
|
11608
11974
|
} catch (error) {
|
|
11609
11975
|
claim.release();
|
|
@@ -11612,14 +11978,6 @@ async function runPreview(parsed, mode) {
|
|
|
11612
11978
|
}
|
|
11613
11979
|
claim.release();
|
|
11614
11980
|
const url = `http://127.0.0.1:${server.port}/`;
|
|
11615
|
-
writeSuccessLine(command, {
|
|
11616
|
-
url,
|
|
11617
|
-
session: sessionId,
|
|
11618
|
-
share_origin: `http://127.0.0.1:${server.sharePort}`,
|
|
11619
|
-
reused: false,
|
|
11620
|
-
...store.quarantinedPath ? { quarantined: true } : {}
|
|
11621
|
-
}, mode);
|
|
11622
|
-
if (parsed.options.noOpen !== true) await openDeviceAuthorizationUrl(url).catch(() => void 0);
|
|
11623
11981
|
const handlers = ["SIGINT", "SIGTERM"].map((signal) => {
|
|
11624
11982
|
const handler = () => {
|
|
11625
11983
|
process.exitCode = 130;
|
|
@@ -11628,6 +11986,15 @@ async function runPreview(parsed, mode) {
|
|
|
11628
11986
|
process.once(signal, handler);
|
|
11629
11987
|
return [signal, handler];
|
|
11630
11988
|
});
|
|
11989
|
+
writeSuccessLine(command, {
|
|
11990
|
+
url,
|
|
11991
|
+
session: sessionId,
|
|
11992
|
+
share_origin: `http://127.0.0.1:${server.sharePort}`,
|
|
11993
|
+
reused: false,
|
|
11994
|
+
agent: server.agent,
|
|
11995
|
+
...store.quarantinedPath ? { quarantined: true } : {}
|
|
11996
|
+
}, mode);
|
|
11997
|
+
if (parsed.options.noOpen !== true) await openDeviceAuthorizationUrl(url).catch(() => void 0);
|
|
11631
11998
|
try {
|
|
11632
11999
|
await server.closed;
|
|
11633
12000
|
} finally {
|
|
@@ -11684,7 +12051,7 @@ async function runPreviewReply(parsed, mode) {
|
|
|
11684
12051
|
}
|
|
11685
12052
|
async function runPreviewStop(parsed, mode) {
|
|
11686
12053
|
const command = "preview stop";
|
|
11687
|
-
const resolved = await resolveTarget(parsed);
|
|
12054
|
+
const resolved = await resolveTarget(parsed, true);
|
|
11688
12055
|
if ("error" in resolved) {
|
|
11689
12056
|
const explicitSession = typeof parsed.options.session === "string" ? parsed.options.session : null;
|
|
11690
12057
|
if (explicitSession && !isSessionId(explicitSession)) return writeFailure(command, resolved.error, mode, 1);
|
|
@@ -11693,7 +12060,7 @@ async function runPreviewStop(parsed, mode) {
|
|
|
11693
12060
|
const sessionId = explicitSession ? explicitSession : positional ? sessionIdOfPath(positional) : null;
|
|
11694
12061
|
if (sessionId) {
|
|
11695
12062
|
const record = readSessionFile(sessionId);
|
|
11696
|
-
if (record && processAlive(record.pid)) return writeFailure(command, sessionUnverifiedError(record.realpath), mode, 1);
|
|
12063
|
+
if (record && processAlive(record.pid)) return writeFailure(command, sessionUnverifiedError(record.realpath, record.legacy === true), mode, 1);
|
|
11697
12064
|
if (!releaseStaleClaim(sessionId)) return writeFailure(command, startInProgressError(record?.realpath ?? positional ?? sessionId), mode, 1);
|
|
11698
12065
|
const cleared = record !== null;
|
|
11699
12066
|
removeSessionFile(sessionId);
|
|
@@ -14108,33 +14475,33 @@ const entryCommand = define({
|
|
|
14108
14475
|
description: "Artifact Share CLI",
|
|
14109
14476
|
toKebab: true,
|
|
14110
14477
|
args: commonArgs,
|
|
14111
|
-
examples: `
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14478
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare init --json
|
|
14479
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare open <artifact-id-or-url> --json
|
|
14480
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare share <path> --json
|
|
14481
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare update <artifact-id-or-url> <path> --json
|
|
14482
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare edit <artifact-id-or-url> --title "New title" --json
|
|
14483
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare delete <artifact-id-or-url> --json
|
|
14484
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare resolve <url-id-or-title> --json
|
|
14485
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare projects create "Launch review" --json
|
|
14486
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare projects edit <id> --add-email viewer@example.com --json
|
|
14487
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare move <artifact-id-or-url> --project-id <id> --json
|
|
14488
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare artifacts list --json
|
|
14489
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare artifacts get <artifact-id-or-url> --json
|
|
14490
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare comments list <artifact-id-or-url> --json
|
|
14491
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare comments post <artifact-id-or-url> --body "<text>" --json
|
|
14125
14492
|
${agentDownloadCommand("<artifact-id-or-url>")}
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
|
|
14129
|
-
|
|
14130
|
-
|
|
14131
|
-
|
|
14132
|
-
|
|
14133
|
-
|
|
14134
|
-
|
|
14135
|
-
|
|
14136
|
-
|
|
14137
|
-
|
|
14493
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare login --profile default
|
|
14494
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare logout --profile default --json
|
|
14495
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare profiles list --json
|
|
14496
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare profiles use <name> --json
|
|
14497
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare projects list --json
|
|
14498
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare config get home_audience --json
|
|
14499
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare skills install --tool codex --json
|
|
14500
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare skills list --json
|
|
14501
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare init --profile <name> --project-id <id> --json
|
|
14502
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare share <path> --home --json
|
|
14503
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare whoami --json
|
|
14504
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare doctor --json
|
|
14138
14505
|
|
|
14139
14506
|
Authentication:
|
|
14140
14507
|
Interactive terminal: run ${CLI_INVOCATION} login --profile default, then approve in your browser.
|
|
@@ -14163,8 +14530,8 @@ const loginDefinition = define({
|
|
|
14163
14530
|
description: "Exact project name or id to confirm with --preset agent (login only)"
|
|
14164
14531
|
}
|
|
14165
14532
|
},
|
|
14166
|
-
examples: `
|
|
14167
|
-
|
|
14533
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare login --profile default
|
|
14534
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare login --profile client-a --preset agent --project 'Weekly Reports' --json
|
|
14168
14535
|
|
|
14169
14536
|
login requires browser approval in an interactive terminal.
|
|
14170
14537
|
For an attended agent on your machine, use --preset agent; --project makes the browser confirm one fixed project, while omitting it keeps the project picker.
|
|
@@ -14180,8 +14547,8 @@ const logoutDefinition = define({
|
|
|
14180
14547
|
description: "Revoke and remove the saved credential for a CLI profile.",
|
|
14181
14548
|
toKebab: true,
|
|
14182
14549
|
args: commonArgs,
|
|
14183
|
-
examples: `
|
|
14184
|
-
|
|
14550
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare logout --profile client-a --json
|
|
14551
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare logout --json
|
|
14185
14552
|
|
|
14186
14553
|
logout revokes a device-login refresh credential before removing it locally. API-token profiles are removed locally only. Profile metadata stays in config.json for re-login hints.
|
|
14187
14554
|
When no --profile is passed, the global default profile is used.
|
|
@@ -14248,24 +14615,24 @@ const shareDefinition = define({
|
|
|
14248
14615
|
description: "Stable key for create-or-update: the first share creates the artifact, repeats add versions. Not a secret; it appears in logs and JSON"
|
|
14249
14616
|
}
|
|
14250
14617
|
},
|
|
14251
|
-
examples: `
|
|
14252
|
-
|
|
14618
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare share report.html --project-id <id> --json
|
|
14619
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare share report.html --project-id <id> --key nightly-report --json
|
|
14253
14620
|
|
|
14254
14621
|
Posting to a project delivers to the audience defined by that project.
|
|
14255
14622
|
With no destination, share posts to home. Choose the setting by purpose:
|
|
14256
14623
|
Personal safe default (this CLI environment only):
|
|
14257
|
-
|
|
14624
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare config set home_audience private --scope user --json
|
|
14258
14625
|
Shared policy agreed by all repository participants:
|
|
14259
|
-
|
|
14626
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare config set home_audience workspace --scope repository --json
|
|
14260
14627
|
One-time audience for a single post: pass --visibility private|workspace|link.
|
|
14261
14628
|
Link sharing accepts --link-expires-at <RFC3339 UTC> or --no-link-expiry;
|
|
14262
14629
|
these expiry options are mutually exclusive.
|
|
14263
14630
|
Pass --no-slack-notify to suppress the project Slack notification for this post.
|
|
14264
14631
|
Check the resolved audience before posting:
|
|
14265
|
-
|
|
14632
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare config get home_audience --scope effective --json
|
|
14266
14633
|
|
|
14267
14634
|
To keep an existing share URL, use update:
|
|
14268
|
-
|
|
14635
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare update <artifact-id-or-url> <path> --json
|
|
14269
14636
|
|
|
14270
14637
|
For repeat jobs, use --key: first share creates the artifact, later runs add versions.
|
|
14271
14638
|
|
|
@@ -14377,10 +14744,10 @@ const editDefinition = define({
|
|
|
14377
14744
|
description: "Move back to the owner home area"
|
|
14378
14745
|
}
|
|
14379
14746
|
},
|
|
14380
|
-
examples: `
|
|
14381
|
-
|
|
14382
|
-
|
|
14383
|
-
|
|
14747
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare edit abc123def4 --title "Launch plan" --json
|
|
14748
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare edit abc123def4 --visibility private --grant-email viewer@example.com --json
|
|
14749
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare edit https://artifactshare.com/a/abc123def4 --project-id prj123 --json
|
|
14750
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare edit abc123def4 --home --json
|
|
14384
14751
|
|
|
14385
14752
|
Link sharing accepts --visibility link with either --link-expires-at <RFC3339 UTC> or --no-link-expiry. These expiry options are mutually exclusive.
|
|
14386
14753
|
|
|
@@ -14407,8 +14774,8 @@ const deleteDefinition = define({
|
|
|
14407
14774
|
description: "Artifact ID, /a/<id> share URL, or <id>.sandbox.* URL"
|
|
14408
14775
|
}
|
|
14409
14776
|
},
|
|
14410
|
-
examples: `
|
|
14411
|
-
|
|
14777
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare delete abc123def4 --json
|
|
14778
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare delete https://artifactshare.com/a/abc123def4 --json
|
|
14412
14779
|
|
|
14413
14780
|
Delete permanently removes the artifact and its version history. This cannot be undone.
|
|
14414
14781
|
Use resolve first when a user gives a title or project name, then pass the id here.
|
|
@@ -14429,8 +14796,8 @@ const resolveDefinition = define({
|
|
|
14429
14796
|
description: "Share URL, sandbox URL, ID, title, or project name"
|
|
14430
14797
|
}
|
|
14431
14798
|
},
|
|
14432
|
-
examples: `
|
|
14433
|
-
|
|
14799
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare resolve "Weekly report" --json
|
|
14800
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare resolve https://artifactshare.com/a/abc123def4 --json
|
|
14434
14801
|
|
|
14435
14802
|
Use resolve before write commands when a user gives a title or project name.
|
|
14436
14803
|
Pass the returned artifact id or project id to the next command.
|
|
@@ -14468,8 +14835,8 @@ const downloadDefinition = define({
|
|
|
14468
14835
|
description: "Allow writing into an existing output directory"
|
|
14469
14836
|
}
|
|
14470
14837
|
},
|
|
14471
|
-
examples: `
|
|
14472
|
-
|
|
14838
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare download abc123def4 --json
|
|
14839
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare download --project-id <id> --output ./project-download --json
|
|
14473
14840
|
${agentDownloadCommand("https://artifactshare.com/a/abc123def4")}
|
|
14474
14841
|
|
|
14475
14842
|
Use resolve first when a user gives a title or project name, then pass the id here.
|
|
@@ -14493,8 +14860,8 @@ const openDefinition = define({
|
|
|
14493
14860
|
description: "Artifact ID, /a/<id> share URL, or <id>.sandbox.* URL"
|
|
14494
14861
|
}
|
|
14495
14862
|
},
|
|
14496
|
-
examples: `
|
|
14497
|
-
|
|
14863
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare open https://artifactshare.com/a/abc123def4 --json
|
|
14864
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare open abc123def4 --json
|
|
14498
14865
|
|
|
14499
14866
|
Use this as the first command when an agent receives an Artifact Share URL.
|
|
14500
14867
|
It installs or updates the bundled Artifact Share skill in user scope (Claude Code,
|
|
@@ -14532,8 +14899,8 @@ const moveDefinition = define({
|
|
|
14532
14899
|
description: "Move back to the owner home area"
|
|
14533
14900
|
}
|
|
14534
14901
|
},
|
|
14535
|
-
examples: `
|
|
14536
|
-
|
|
14902
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare move abc123def4 --project-id prj123 --json
|
|
14903
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare move https://artifactshare.com/a/abc123def4 --home --json
|
|
14537
14904
|
|
|
14538
14905
|
Move changes the artifact destination. It does not add grants. Project visibility
|
|
14539
14906
|
artifacts may change audience when moved between projects; the JSON response
|
|
@@ -14568,9 +14935,9 @@ const artifactsGetDefinition = define({
|
|
|
14568
14935
|
description: "Extra data to include: versions or comments"
|
|
14569
14936
|
}
|
|
14570
14937
|
},
|
|
14571
|
-
examples: `
|
|
14572
|
-
|
|
14573
|
-
|
|
14938
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare artifacts get abc123def4 --json
|
|
14939
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare artifacts get https://artifactshare.com/a/abc123def4 --include versions --include comments --json
|
|
14940
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare artifacts get abc123def4 --offset 200000 --json
|
|
14574
14941
|
|
|
14575
14942
|
Use resolve first when a user gives a title or project name, then pass the id here.
|
|
14576
14943
|
Read the successful JSON from data.content (the source) and data.version_id (the current version).
|
|
@@ -14609,10 +14976,10 @@ const artifactsListDefinition = define({
|
|
|
14609
14976
|
description: "Continue listing from the cursor returned by the previous page"
|
|
14610
14977
|
}
|
|
14611
14978
|
},
|
|
14612
|
-
examples: `
|
|
14613
|
-
|
|
14614
|
-
|
|
14615
|
-
|
|
14979
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare artifacts list --json
|
|
14980
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare artifacts list --project-id <id> --json
|
|
14981
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare artifacts list --home --query report --json
|
|
14982
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare artifacts list --project-id <id> --cursor <token> --json
|
|
14616
14983
|
|
|
14617
14984
|
Use an id from this list with update, edit, move, delete, artifacts get, or comments list.
|
|
14618
14985
|
|
|
@@ -14630,8 +14997,8 @@ const artifactsDefinition = define({
|
|
|
14630
14997
|
list: lazyCommand(artifactsListDefinition, artifactsListRunner),
|
|
14631
14998
|
get: lazyCommand(artifactsGetDefinition, artifactsGetRunner)
|
|
14632
14999
|
},
|
|
14633
|
-
examples: `
|
|
14634
|
-
|
|
15000
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare artifacts list --json
|
|
15001
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare artifacts get <artifact-id-or-url> --json
|
|
14635
15002
|
|
|
14636
15003
|
Use artifacts list to find IDs for update, edit, move, delete, artifacts get, and comments list.
|
|
14637
15004
|
Use artifacts get to read back Markdown or HTML before update.`,
|
|
@@ -14649,7 +15016,7 @@ const commentsListDefinition = define({
|
|
|
14649
15016
|
description: "Artifact ID, /a/<id> share URL, or <id>.sandbox.* URL"
|
|
14650
15017
|
}
|
|
14651
15018
|
},
|
|
14652
|
-
examples: `
|
|
15019
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare comments list abc123def4 --json
|
|
14653
15020
|
|
|
14654
15021
|
Returns up to 50 threads (open threads first); has_more reports whether more exist.
|
|
14655
15022
|
Each thread carries its messages, status, and quoted-text anchor when present.
|
|
@@ -14700,9 +15067,9 @@ const commentsPostDefinition = define({
|
|
|
14700
15067
|
description: "Agent name posting on behalf of the user (e.g. Claude, Cursor)"
|
|
14701
15068
|
}
|
|
14702
15069
|
},
|
|
14703
|
-
examples: `
|
|
14704
|
-
|
|
14705
|
-
|
|
15070
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare comments post abc123def4 --body "Looks good" --json
|
|
15071
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare comments post abc123def4 --body "Done" --reply-to <thread-id> --json
|
|
15072
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare comments post abc123def4 --body "Fix this" --quote "exact text" --json
|
|
14706
15073
|
|
|
14707
15074
|
Copy quote text from artifacts get so it matches the artifact exactly.
|
|
14708
15075
|
|
|
@@ -14752,7 +15119,7 @@ const commentsEditDefinition = define({
|
|
|
14752
15119
|
description: "Updated comment text (required)"
|
|
14753
15120
|
}
|
|
14754
15121
|
},
|
|
14755
|
-
examples: `
|
|
15122
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare comments edit abc123def4 --message-id <message-id> --body "Updated text" --json
|
|
14756
15123
|
|
|
14757
15124
|
Common failures:
|
|
14758
15125
|
message_not_found Run comments list and retry with a listed message_id
|
|
@@ -14764,7 +15131,7 @@ const commentsResolveDefinition = define({
|
|
|
14764
15131
|
description: "Mark a comment thread as resolved.",
|
|
14765
15132
|
toKebab: true,
|
|
14766
15133
|
args: commentThreadActionArgs,
|
|
14767
|
-
examples: `
|
|
15134
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare comments resolve abc123def4 --thread-id <thread-id> --json
|
|
14768
15135
|
|
|
14769
15136
|
Common failures:
|
|
14770
15137
|
thread_not_found Run comments list and retry with a listed thread_id
|
|
@@ -14776,7 +15143,7 @@ const commentsReopenDefinition = define({
|
|
|
14776
15143
|
description: "Reopen a resolved comment thread.",
|
|
14777
15144
|
toKebab: true,
|
|
14778
15145
|
args: commentThreadActionArgs,
|
|
14779
|
-
examples: `
|
|
15146
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare comments reopen abc123def4 --thread-id <thread-id> --json
|
|
14780
15147
|
|
|
14781
15148
|
Common failures:
|
|
14782
15149
|
thread_not_found Run comments list and retry with a listed thread_id
|
|
@@ -14795,8 +15162,8 @@ const commentsDeleteDefinition = define({
|
|
|
14795
15162
|
description: "Message id from comments list; omit to delete the thread"
|
|
14796
15163
|
}
|
|
14797
15164
|
},
|
|
14798
|
-
examples: `
|
|
14799
|
-
|
|
15165
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare comments delete abc123def4 --thread-id <thread-id> --message-id <message-id> --json
|
|
15166
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare comments delete abc123def4 --thread-id <thread-id> --json
|
|
14800
15167
|
|
|
14801
15168
|
Deleting comments cannot be undone. Omit --message-id only when deleting the whole thread.
|
|
14802
15169
|
|
|
@@ -14829,14 +15196,16 @@ const previewNextDefinition = define({
|
|
|
14829
15196
|
description: "Preview session id from the ready JSON"
|
|
14830
15197
|
}
|
|
14831
15198
|
},
|
|
14832
|
-
examples: `
|
|
14833
|
-
|
|
15199
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare preview next ./lp.html --wait 90
|
|
15200
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare preview next --session 0123456789abcdef
|
|
14834
15201
|
|
|
14835
15202
|
Returns {items: []} with timed_out: true when the wait expires, and
|
|
14836
|
-
session_ended: true when the preview shuts down while waiting.
|
|
15203
|
+
session_ended: true when the preview shuts down while waiting. Successful
|
|
15204
|
+
results include the sanitized agent notification projection.
|
|
14837
15205
|
|
|
14838
15206
|
Common failures:
|
|
14839
15207
|
preview_session_not_found Start a session with: preview <file>
|
|
15208
|
+
preview_wait_conflict Use the existing wait, or retry after it returns
|
|
14840
15209
|
preview_request_failed The preview rejected the request; check the input`
|
|
14841
15210
|
});
|
|
14842
15211
|
const previewDoneDefinition = define({
|
|
@@ -14862,9 +15231,10 @@ const previewDoneDefinition = define({
|
|
|
14862
15231
|
description: "Preview session id from the ready JSON"
|
|
14863
15232
|
}
|
|
14864
15233
|
},
|
|
14865
|
-
examples: `printf '%s' '{"items":[{"thread":"t1","generation":1,"outcome":"fixed","note":"Tightened the headline"}]}' |
|
|
15234
|
+
examples: `printf '%s' '{"items":[{"thread":"t1","generation":1,"outcome":"fixed","note":"Tightened the headline"}]}' | npm exec --yes --package=@artifactshare/cli -- artifactshare preview done ./lp.html --stdin
|
|
14866
15235
|
|
|
14867
|
-
Each item returns accepted | stale | already_reported | unknown_thread.
|
|
15236
|
+
Each item returns accepted | stale | already_reported | unknown_thread. The
|
|
15237
|
+
result also includes the sanitized agent notification projection.
|
|
14868
15238
|
|
|
14869
15239
|
Common failures:
|
|
14870
15240
|
preview_session_not_found Start a session with: preview <file>
|
|
@@ -14898,7 +15268,7 @@ const previewReplyDefinition = define({
|
|
|
14898
15268
|
description: "Preview session id from the ready JSON"
|
|
14899
15269
|
}
|
|
14900
15270
|
},
|
|
14901
|
-
examples: `
|
|
15271
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare preview reply ./lp.html --thread t1 --body "Which shade of coral?"
|
|
14902
15272
|
|
|
14903
15273
|
Common failures:
|
|
14904
15274
|
preview_session_not_found Start a session with: preview <file>
|
|
@@ -14927,8 +15297,8 @@ const previewStopDefinition = define({
|
|
|
14927
15297
|
description: "Clear a session record once its process is gone (refused while it is alive)"
|
|
14928
15298
|
}
|
|
14929
15299
|
},
|
|
14930
|
-
examples: `
|
|
14931
|
-
|
|
15300
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare preview stop ./lp.html
|
|
15301
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare preview stop ./lp.html --force
|
|
14932
15302
|
|
|
14933
15303
|
Common failures:
|
|
14934
15304
|
preview_session_not_found Nothing to stop; the session already ended
|
|
@@ -14952,15 +15322,15 @@ const previewStartDefinition = define({
|
|
|
14952
15322
|
description: "Do not open the browser automatically"
|
|
14953
15323
|
}
|
|
14954
15324
|
},
|
|
14955
|
-
examples: `
|
|
14956
|
-
|
|
15325
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare preview ./lp.html
|
|
15326
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare preview ./lp.html --no-open
|
|
14957
15327
|
|
|
14958
|
-
Prints one ready JSON line ({url, session, share_origin, reused}) and
|
|
15328
|
+
Prints one ready JSON line ({url, session, share_origin, reused, agent}) and
|
|
14959
15329
|
keeps serving until stopped. Re-running against a live session reuses it.
|
|
14960
15330
|
|
|
14961
15331
|
Common failures:
|
|
14962
15332
|
validation_failed Pass a single local .md or .html file
|
|
14963
|
-
preview_session_unverified
|
|
15333
|
+
preview_session_unverified Retry an unresponsive session; stop and restart a session created by an older CLI`
|
|
14964
15334
|
});
|
|
14965
15335
|
const previewDefinition = define({
|
|
14966
15336
|
name: "preview",
|
|
@@ -14974,12 +15344,12 @@ const previewDefinition = define({
|
|
|
14974
15344
|
reply: lazyCommand(previewReplyDefinition, previewReplyRunner),
|
|
14975
15345
|
stop: lazyCommand(previewStopDefinition, previewStopRunner)
|
|
14976
15346
|
},
|
|
14977
|
-
examples: `
|
|
14978
|
-
|
|
15347
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare preview ./lp.html
|
|
15348
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare preview next ./lp.html --wait 90
|
|
14979
15349
|
|
|
14980
15350
|
Common failures:
|
|
14981
15351
|
validation_failed Pass a single local .md or .html file
|
|
14982
|
-
preview_session_unverified
|
|
15352
|
+
preview_session_unverified Retry an unresponsive session; stop and restart a session created by an older CLI
|
|
14983
15353
|
preview_session_not_found No live session; start one with preview <file>`,
|
|
14984
15354
|
run: parentCommandRunner("preview")
|
|
14985
15355
|
});
|
|
@@ -14996,11 +15366,11 @@ const commentsDefinition = define({
|
|
|
14996
15366
|
reopen: lazyCommand(commentsReopenDefinition, commentsReopenRunner),
|
|
14997
15367
|
delete: lazyCommand(commentsDeleteDefinition, commentsDeleteRunner)
|
|
14998
15368
|
},
|
|
14999
|
-
examples: `
|
|
15000
|
-
|
|
15001
|
-
|
|
15002
|
-
|
|
15003
|
-
|
|
15369
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare comments list <artifact-id-or-url> --json
|
|
15370
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare comments post <artifact-id-or-url> --body "<text>" --json
|
|
15371
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare comments edit <artifact-id-or-url> --message-id <message-id> --body "<text>" --json
|
|
15372
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare comments resolve <artifact-id-or-url> --thread-id <thread-id> --json
|
|
15373
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare comments delete <artifact-id-or-url> --thread-id <thread-id> --json
|
|
15004
15374
|
|
|
15005
15375
|
Deleting comments cannot be undone.`,
|
|
15006
15376
|
run: parentCommandRunner("comments")
|
|
@@ -15010,7 +15380,7 @@ const profilesListDefinition = define({
|
|
|
15010
15380
|
description: "List saved CLI profiles and the default profile.",
|
|
15011
15381
|
toKebab: true,
|
|
15012
15382
|
args: commonArgs,
|
|
15013
|
-
examples: `
|
|
15383
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare profiles list --json
|
|
15014
15384
|
|
|
15015
15385
|
token_present shows whether a saved credential exists; token values are never printed.`
|
|
15016
15386
|
});
|
|
@@ -15025,7 +15395,7 @@ const profilesUseDefinition = define({
|
|
|
15025
15395
|
description: "Profile name to make the default"
|
|
15026
15396
|
}
|
|
15027
15397
|
},
|
|
15028
|
-
examples: `
|
|
15398
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare profiles use client-a --json
|
|
15029
15399
|
|
|
15030
15400
|
Common failures:
|
|
15031
15401
|
profile_not_found Run profiles list to see saved profiles, or login --profile <name>`
|
|
@@ -15046,7 +15416,7 @@ const profilesImportTokenDefinition = define({
|
|
|
15046
15416
|
description: "Replace an existing profile credential when importing a bot token (no-op for API tokens)"
|
|
15047
15417
|
}
|
|
15048
15418
|
},
|
|
15049
|
-
examples: `printf '%s' "$TOKEN" |
|
|
15419
|
+
examples: `printf '%s' "$TOKEN" | npm exec --yes --package=@artifactshare/cli -- artifactshare profiles import-token --profile client-a --json
|
|
15050
15420
|
|
|
15051
15421
|
Reads the token from standard input only. Use this in unattended CI or scripts without browser approval after issuing a token at ${DEFAULT_BASE_URL}/settings/tokens.
|
|
15052
15422
|
|
|
@@ -15064,7 +15434,7 @@ const profilesDeleteDefinition = define({
|
|
|
15064
15434
|
description: "Delete a saved CLI profile and its credential.",
|
|
15065
15435
|
toKebab: true,
|
|
15066
15436
|
args: commonArgs,
|
|
15067
|
-
examples: `
|
|
15437
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare profiles delete client-a --json
|
|
15068
15438
|
|
|
15069
15439
|
Removes the profile from config.json and clears its saved credential.
|
|
15070
15440
|
If the deleted profile was the default, default_profile becomes null.
|
|
@@ -15142,12 +15512,12 @@ const configDefinition = define({
|
|
|
15142
15512
|
examples: `Posting to a project delivers to that project's audience. Without a destination, share posts to home.
|
|
15143
15513
|
Choose the home audience by purpose:
|
|
15144
15514
|
Personal safe default (this CLI environment only):
|
|
15145
|
-
|
|
15515
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare config set home_audience private --scope user --json
|
|
15146
15516
|
Shared policy agreed by all repository participants:
|
|
15147
|
-
|
|
15517
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare config set home_audience workspace --scope repository --json
|
|
15148
15518
|
One-time audience for a single post: pass --visibility private|workspace.
|
|
15149
15519
|
Check the resolved audience with:
|
|
15150
|
-
|
|
15520
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare config get home_audience --scope effective --json
|
|
15151
15521
|
|
|
15152
15522
|
Keys:
|
|
15153
15523
|
home_audience Canonical home-post audience.
|
|
@@ -15168,10 +15538,10 @@ const profilesDefinition = define({
|
|
|
15168
15538
|
"import-token": lazyCommand(profilesImportTokenDefinition, profilesImportTokenRunner),
|
|
15169
15539
|
delete: lazyCommand(profilesDeleteDefinition, profilesDeleteRunner)
|
|
15170
15540
|
},
|
|
15171
|
-
examples: `
|
|
15172
|
-
|
|
15173
|
-
printf '%s' "$TOKEN" |
|
|
15174
|
-
|
|
15541
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare profiles list --json
|
|
15542
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare profiles use client-a --json
|
|
15543
|
+
printf '%s' "$TOKEN" | npm exec --yes --package=@artifactshare/cli -- artifactshare profiles import-token --profile client-a --json
|
|
15544
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare profiles delete client-a --json`,
|
|
15175
15545
|
run: parentCommandRunner("profiles")
|
|
15176
15546
|
});
|
|
15177
15547
|
const projectsListDefinition = define({
|
|
@@ -15179,7 +15549,7 @@ const projectsListDefinition = define({
|
|
|
15179
15549
|
description: "List projects you can share into.",
|
|
15180
15550
|
toKebab: true,
|
|
15181
15551
|
args: commonArgs,
|
|
15182
|
-
examples: `
|
|
15552
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare projects list --json
|
|
15183
15553
|
|
|
15184
15554
|
is_default marks the working-directory default project from .artifactshare/config.json.
|
|
15185
15555
|
Use a project id with share --project-id or init --project-id.`
|
|
@@ -15205,12 +15575,12 @@ const projectsCreateDefinition = define({
|
|
|
15205
15575
|
description: "workspace or private (default: default_project_visibility, resolved from repository, user, then workspace)"
|
|
15206
15576
|
}
|
|
15207
15577
|
},
|
|
15208
|
-
examples: `
|
|
15209
|
-
|
|
15578
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare projects create "Launch review" --json
|
|
15579
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare projects create "Client" --description "Weekly reports" --visibility private --json
|
|
15210
15580
|
|
|
15211
15581
|
Persist the default for project creation in the repository:
|
|
15212
|
-
|
|
15213
|
-
|
|
15582
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare config get default_project_visibility --json
|
|
15583
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare config set default_project_visibility private --scope repository --json
|
|
15214
15584
|
|
|
15215
15585
|
The response includes project.id and next_command for share --project-id.
|
|
15216
15586
|
|
|
@@ -15268,10 +15638,10 @@ const projectsEditDefinition = define({
|
|
|
15268
15638
|
description: "Unarchive the project before other edits"
|
|
15269
15639
|
}
|
|
15270
15640
|
},
|
|
15271
|
-
examples: `
|
|
15272
|
-
|
|
15273
|
-
|
|
15274
|
-
|
|
15641
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare projects edit <id> --name "Launch review" --json
|
|
15642
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare projects edit <id> --visibility private --add-email viewer@example.com --json
|
|
15643
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare projects edit <id> --archive --json
|
|
15644
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare projects edit <id> --unarchive --description "" --json
|
|
15275
15645
|
|
|
15276
15646
|
Common failures:
|
|
15277
15647
|
target_not_found Use a project id from projects list
|
|
@@ -15291,9 +15661,9 @@ const projectsDefinition = define({
|
|
|
15291
15661
|
create: lazyCommand(projectsCreateDefinition, projectsCreateRunner),
|
|
15292
15662
|
edit: lazyCommand(projectsEditDefinition, projectsEditRunner)
|
|
15293
15663
|
},
|
|
15294
|
-
examples: `
|
|
15295
|
-
|
|
15296
|
-
|
|
15664
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare projects list --json
|
|
15665
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare projects create "Launch review" --json
|
|
15666
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare projects edit <id> --add-email viewer@example.com --json`,
|
|
15297
15667
|
run: parentCommandRunner("projects")
|
|
15298
15668
|
});
|
|
15299
15669
|
const skillsToolArgs = {
|
|
@@ -15327,8 +15697,8 @@ const skillsInstallDefinition = define({
|
|
|
15327
15697
|
description: "Overwrite an existing unmanaged file or reinstall the same version"
|
|
15328
15698
|
}
|
|
15329
15699
|
},
|
|
15330
|
-
examples: `
|
|
15331
|
-
|
|
15700
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare skills install --tool codex --scope project --json
|
|
15701
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare skills install --tool claude --tool cursor --dry-run --json
|
|
15332
15702
|
|
|
15333
15703
|
Writes a managed SKILL.md (codex, claude) or Cursor rule (cursor).
|
|
15334
15704
|
Files without the Artifact Share managed marker are never overwritten without --force.
|
|
@@ -15342,7 +15712,7 @@ const skillsListDefinition = define({
|
|
|
15342
15712
|
description: "Show skill install status for each supported agent tool.",
|
|
15343
15713
|
toKebab: true,
|
|
15344
15714
|
args: commonArgs,
|
|
15345
|
-
examples: `
|
|
15715
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare skills list --json
|
|
15346
15716
|
|
|
15347
15717
|
Reports each tool and scope with detection, install state, and update availability.
|
|
15348
15718
|
Runs locally; no network or authentication is used.`
|
|
@@ -15360,8 +15730,8 @@ const skillsUpdateDefinition = define({
|
|
|
15360
15730
|
description: "Rewrite managed files even when the version already matches"
|
|
15361
15731
|
}
|
|
15362
15732
|
},
|
|
15363
|
-
examples: `
|
|
15364
|
-
|
|
15733
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare skills update --json
|
|
15734
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare skills update --tool codex --scope user --json
|
|
15365
15735
|
|
|
15366
15736
|
Only files created by skills install (managed marker present) are updated.
|
|
15367
15737
|
|
|
@@ -15381,9 +15751,9 @@ const skillsEnsureDefinition = define({
|
|
|
15381
15751
|
description: "Show planned file changes without writing"
|
|
15382
15752
|
}
|
|
15383
15753
|
},
|
|
15384
|
-
examples: `
|
|
15385
|
-
|
|
15386
|
-
|
|
15754
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare skills ensure --tool auto --json
|
|
15755
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare skills ensure --tool auto --scope user --json
|
|
15756
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare skills ensure --tool claude --json
|
|
15387
15757
|
|
|
15388
15758
|
Use --tool auto from an agent workspace. It detects .claude, .codex/.agents, or
|
|
15389
15759
|
.cursor in the current directory and installs or updates the matching user-scope
|
|
@@ -15402,8 +15772,8 @@ const skillsRemoveDefinition = define({
|
|
|
15402
15772
|
...commonArgs,
|
|
15403
15773
|
...skillsToolArgs
|
|
15404
15774
|
},
|
|
15405
|
-
examples: `
|
|
15406
|
-
|
|
15775
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare skills remove --json
|
|
15776
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare skills remove --tool cursor --json
|
|
15407
15777
|
|
|
15408
15778
|
Only files created by skills install are deleted; unmanaged files are skipped.`
|
|
15409
15779
|
});
|
|
@@ -15419,9 +15789,9 @@ const skillsDefinition = define({
|
|
|
15419
15789
|
ensure: lazyCommand(skillsEnsureDefinition, skillsEnsureRunner),
|
|
15420
15790
|
remove: lazyCommand(skillsRemoveDefinition, skillsRemoveRunner)
|
|
15421
15791
|
},
|
|
15422
|
-
examples: `
|
|
15423
|
-
|
|
15424
|
-
|
|
15792
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare skills install --tool codex --json
|
|
15793
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare skills ensure --tool auto --json
|
|
15794
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare skills list --json`,
|
|
15425
15795
|
run: parentCommandRunner("skills")
|
|
15426
15796
|
});
|
|
15427
15797
|
const initDefinition = define({
|
|
@@ -15441,9 +15811,9 @@ const initDefinition = define({
|
|
|
15441
15811
|
description: "Show the planned skill changes without writing (onboarding)"
|
|
15442
15812
|
}
|
|
15443
15813
|
},
|
|
15444
|
-
examples: `
|
|
15445
|
-
|
|
15446
|
-
|
|
15814
|
+
examples: `npm exec --yes --package=@artifactshare/cli -- artifactshare init --json
|
|
15815
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare init --dry-run --json
|
|
15816
|
+
npm exec --yes --package=@artifactshare/cli -- artifactshare init --profile client-a --project-id <id> --json
|
|
15447
15817
|
|
|
15448
15818
|
Without flags, init detects Claude Code, Codex, or Cursor in the working directory,
|
|
15449
15819
|
installs or updates the bundled skill in user scope, and shows the next steps (sign
|