@artifactshare/cli 0.2.0 → 0.4.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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { appendFile, chmod, lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
2
+ import { appendFile, chmod, lstat, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
3
3
  import { cli, define, lazy } from "gunshi";
4
4
  import { spawn } from "node:child_process";
5
5
  import { basename, dirname, join, relative, resolve, sep } from "node:path";
@@ -38,6 +38,7 @@ const BOOLEAN_FLAGS = new Set([
38
38
  ]);
39
39
  const VALUE_FLAGS = new Set([
40
40
  "add-email",
41
+ "agent",
41
42
  "base-url",
42
43
  "body",
43
44
  "description",
@@ -152,7 +153,7 @@ function mapApiError(status, body, options = {}) {
152
153
  if (!options.authenticated) return authRequiredError(options.baseUrl ?? "https://artifactshare.com");
153
154
  const source = options.credentialSource;
154
155
  const profile = options.profile;
155
- if (typeof profile === "string" && profile.length > 0 && isProfileCredentialSource(source)) return profileReauthRequiredError(options.baseUrl ?? "https://artifactshare.com", source, profile);
156
+ if (typeof profile === "string" && profile.length > 0 && isProfileCredentialSource(source) && options.profileCredentialKind !== "api_token") return profileReauthRequiredError(options.baseUrl ?? "https://artifactshare.com", source, profile);
156
157
  return tokenInvalidError();
157
158
  }
158
159
  if (apiCode === "upload-not-allowed") return cliError({
@@ -1009,8 +1010,22 @@ function humanSuccess(command, data) {
1009
1010
  }
1010
1011
  if (command === "doctor") return doctorHumanOutput(data);
1011
1012
  if (command === "open") return openHumanOutput(data);
1013
+ if (command === "init") return initHumanOutput(data);
1012
1014
  return `${JSON.stringify(data, null, 2)}\n`;
1013
1015
  }
1016
+ function initHumanOutput(data) {
1017
+ const body = `${JSON.stringify(data, null, 2)}`;
1018
+ const nextCommand = initNextCommand(data);
1019
+ if (!nextCommand) return `${body}\n`;
1020
+ return `${body}\nNext command: ${nextCommand}\n`;
1021
+ }
1022
+ function initNextCommand(data) {
1023
+ if (!isRecord(data) || data.mode !== "onboarding") return null;
1024
+ const steps = data.next_steps;
1025
+ if (!Array.isArray(steps)) return null;
1026
+ const pending = steps.find((step) => isRecord(step) && step.done !== true && typeof step.command === "string");
1027
+ return isRecord(pending) && typeof pending.command === "string" ? pending.command : null;
1028
+ }
1014
1029
  function openHumanOutput(data) {
1015
1030
  const body = `${JSON.stringify(data, null, 2)}`;
1016
1031
  const nextCommand = openNextCommand(data);
@@ -1148,6 +1163,14 @@ async function apiPost(path, token, payload, options, init, errorOptions = {}) {
1148
1163
  ...init
1149
1164
  }, errorOptions);
1150
1165
  }
1166
+ async function apiPostPublic(path, payload, options, init) {
1167
+ return await apiRequestRaw(path, options, {
1168
+ method: "POST",
1169
+ headers: { "content-type": "application/json" },
1170
+ body: JSON.stringify(payload),
1171
+ ...init
1172
+ });
1173
+ }
1151
1174
  async function apiDelete(path, token, options, init, errorOptions = {}) {
1152
1175
  return await apiRequest(path, options, {
1153
1176
  method: "DELETE",
@@ -1156,9 +1179,9 @@ async function apiDelete(path, token, options, init, errorOptions = {}) {
1156
1179
  }, errorOptions);
1157
1180
  }
1158
1181
  async function apiRequest(path, options, init, errorOptions) {
1159
- const response = await fetch(apiUrl(path, baseUrlOf(options)), init).catch((error) => ({ networkError: error }));
1160
- if ("networkError" in response) return { error: networkError(response.networkError) };
1161
- const body = await readJson(response);
1182
+ const result = await apiRequestRaw(path, options, init);
1183
+ if (result.error) return { error: result.error };
1184
+ const { response, body } = result;
1162
1185
  if (!response.ok) return { error: mapApiError(response.status, body, {
1163
1186
  authenticated: true,
1164
1187
  baseUrl: baseUrlOf(options),
@@ -1166,6 +1189,14 @@ async function apiRequest(path, options, init, errorOptions) {
1166
1189
  }) };
1167
1190
  return { body };
1168
1191
  }
1192
+ async function apiRequestRaw(path, options, init) {
1193
+ const response = await fetch(apiUrl(path, baseUrlOf(options)), init).catch((error) => ({ networkError: error }));
1194
+ if ("networkError" in response) return { error: networkError(response.networkError) };
1195
+ return {
1196
+ response,
1197
+ body: await readJson(response)
1198
+ };
1199
+ }
1169
1200
  //#endregion
1170
1201
  //#region src/process.ts
1171
1202
  function spawnFile(command, args, input) {
@@ -1295,32 +1326,40 @@ async function readProfileToken(profile, options) {
1295
1326
  const account = accountName(profile, baseUrlOf(options));
1296
1327
  const native = await nativeStore();
1297
1328
  if (native) {
1298
- const token = await native.read(account);
1299
- if (token) return {
1300
- ok: true,
1301
- token,
1329
+ const parsed = parseStoredProfileCredential(await native.read(account));
1330
+ if (parsed.ok) return {
1331
+ ...parsed,
1302
1332
  store: native.kind
1303
1333
  };
1334
+ if (parsed.reason === "legacy") return parsed;
1304
1335
  }
1305
- const plaintext = await readPlaintextToken(account);
1306
- if (plaintext) return {
1307
- ok: true,
1308
- token: plaintext,
1336
+ const plaintext = parseStoredProfileCredential(await readPlaintextToken(account));
1337
+ if (plaintext.ok) return {
1338
+ ...plaintext,
1309
1339
  store: "plaintext_file"
1310
1340
  };
1341
+ if (plaintext.reason === "legacy") return plaintext;
1311
1342
  return {
1312
1343
  ok: false,
1313
1344
  reason: native || options.allowPlaintextTokenStore ? "missing" : "unavailable"
1314
1345
  };
1315
1346
  }
1316
- async function saveProfileToken(profile, token, options) {
1347
+ async function saveProfileSessionCredential(profile, credential, options) {
1348
+ return await saveProfileCredential(profile, credential, options);
1349
+ }
1350
+ async function saveProfileApiTokenCredential(profile, credential, options) {
1351
+ return await saveProfileCredential(profile, credential, options);
1352
+ }
1353
+ async function saveProfileCredential(profile, credential, options) {
1317
1354
  const account = accountName(profile, baseUrlOf(options));
1355
+ const value = JSON.stringify(credential);
1318
1356
  const native = await nativeStore();
1319
- if (native && await native.write(account, token)) return {
1357
+ if (native && await native.write(account, value)) return {
1320
1358
  ok: true,
1321
1359
  store: native.kind
1322
1360
  };
1323
- if (options.allowPlaintextTokenStore && await writePlaintextToken(account, token)) return {
1361
+ const hasPlaintextEntry = await readPlaintextToken(account) !== null;
1362
+ if ((options.allowPlaintextTokenStore || hasPlaintextEntry) && await writePlaintextToken(account, value)) return {
1324
1363
  ok: true,
1325
1364
  store: "plaintext_file"
1326
1365
  };
@@ -1329,6 +1368,53 @@ async function saveProfileToken(profile, token, options) {
1329
1368
  reason: "unavailable"
1330
1369
  };
1331
1370
  }
1371
+ function parseStoredProfileCredential(raw) {
1372
+ if (!raw) return {
1373
+ ok: false,
1374
+ reason: "missing"
1375
+ };
1376
+ const parsed = parseJsonRecord(raw);
1377
+ if (!parsed) return {
1378
+ ok: false,
1379
+ reason: "legacy"
1380
+ };
1381
+ if (parsed.kind === "session" && typeof parsed.session_token === "string" && parsed.session_token && typeof parsed.refresh_token === "string" && parsed.refresh_token && (typeof parsed.expires_at === "string" || parsed.expires_at === null || parsed.expires_at === void 0)) {
1382
+ const credential = {
1383
+ kind: "session",
1384
+ session_token: parsed.session_token,
1385
+ refresh_token: parsed.refresh_token,
1386
+ ...parsed.expires_at !== void 0 ? { expires_at: parsed.expires_at } : {}
1387
+ };
1388
+ return {
1389
+ ok: true,
1390
+ token: credential.session_token,
1391
+ credential
1392
+ };
1393
+ }
1394
+ if (parsed.kind === "api_token" && typeof parsed.token === "string" && parsed.token) {
1395
+ const credential = {
1396
+ kind: "api_token",
1397
+ token: parsed.token
1398
+ };
1399
+ return {
1400
+ ok: true,
1401
+ token: credential.token,
1402
+ credential
1403
+ };
1404
+ }
1405
+ return {
1406
+ ok: false,
1407
+ reason: "legacy"
1408
+ };
1409
+ }
1410
+ function parseJsonRecord(raw) {
1411
+ try {
1412
+ const parsed = JSON.parse(raw);
1413
+ return isRecord(parsed) ? parsed : null;
1414
+ } catch {
1415
+ return null;
1416
+ }
1417
+ }
1332
1418
  async function readGlobalConfig() {
1333
1419
  const home = configHome();
1334
1420
  if (!home) return null;
@@ -1586,7 +1672,9 @@ async function resolveProfileCredential(source, profile, options, globalConfig,
1586
1672
  ok: true,
1587
1673
  source,
1588
1674
  profile,
1589
- token: stored.token
1675
+ token: stored.token,
1676
+ profileCredentialKind: stored.credential.kind,
1677
+ ...stored.credential.kind === "session" ? { refreshToken: stored.credential.refresh_token } : {}
1590
1678
  };
1591
1679
  return profileAuthRequired(source, profile, stored.reason, options, globalConfig, configPath, configKind);
1592
1680
  }
@@ -1594,7 +1682,7 @@ async function profileAuthRequired(source, profile, reason, options, globalConfi
1594
1682
  const baseUrl = baseUrlOf(options);
1595
1683
  const url = tokensUrl(baseUrl);
1596
1684
  const error = authRequiredError(baseUrl);
1597
- const why = reason === "unavailable" ? `No safe token store is available for profile "${profile}".` : `No saved credential was found for profile "${profile}".`;
1685
+ const why = reason === "unavailable" ? `No safe token store is available for profile "${profile}".` : reason === "legacy" ? `The saved credential for profile "${profile}" uses an old format.` : `No saved credential was found for profile "${profile}".`;
1598
1686
  const alternative = await findAlternativeProfileWithToken(globalConfig, options, profile);
1599
1687
  const details = {
1600
1688
  ...authRecoveryDetails(baseUrl, `${CLI_INVOCATION} login --profile ${profile}`),
@@ -1732,7 +1820,7 @@ async function performDeviceLogin(profile, options, mode) {
1732
1820
  error: token.error
1733
1821
  };
1734
1822
  const sessionExpiresAt = token.expires_in === void 0 ? null : new Date(Date.now() + token.expires_in * 1e3).toISOString();
1735
- const stored = await verifyAndStoreProfileToken(profile, token.access_token, options, request.init);
1823
+ const stored = await verifyAndStoreProfileToken(profile, token.access_token, options, request.init, sessionExpiresAt);
1736
1824
  if (!stored.ok) return {
1737
1825
  ok: false,
1738
1826
  error: stored.error
@@ -1854,39 +1942,97 @@ async function pollForToken(options, code, init, profile, deadline) {
1854
1942
  }
1855
1943
  return { error: authExpiredError(profile) };
1856
1944
  }
1857
- async function verifyAndStoreProfileToken(profile, token, options, init) {
1858
- const config = await readGlobalConfig() ?? {};
1859
- const whoamiResult = await apiGet("/api/cli/whoami", token, options, init);
1860
- if (whoamiResult.error) return {
1945
+ async function verifyAndStoreProfileToken(profile, token, options, init, sessionExpiresAt = null) {
1946
+ const verified = await verifyProfileTokenAccount(profile, token, options, init);
1947
+ if (!verified.ok) return verified;
1948
+ const refresh = await issueCliRefreshCredential(token, options, init);
1949
+ if ("error" in refresh) return {
1861
1950
  ok: false,
1862
- error: whoamiResult.error
1951
+ error: refresh.error
1863
1952
  };
1864
- const whoami = whoamiProfile(whoamiResult.body);
1865
- const profiles = config.profiles ?? {};
1866
- const expectedEmail = nonEmpty((Object.hasOwn(profiles, profile) ? profiles[profile] : void 0)?.email);
1867
- if (expectedEmail && whoami.email !== expectedEmail) return {
1953
+ const saved = await saveProfileSessionCredential(profile, {
1954
+ kind: "session",
1955
+ session_token: token,
1956
+ refresh_token: refresh.refresh_token,
1957
+ expires_at: sessionExpiresAt
1958
+ }, options);
1959
+ if (!saved.ok) return {
1868
1960
  ok: false,
1869
- error: authAccountMismatchError(profile, expectedEmail, whoami.email)
1961
+ error: tokenStoreUnavailableError(profile)
1962
+ };
1963
+ await writeProfileConfig(profile, options, saved.store, verified.whoami);
1964
+ return {
1965
+ ok: true,
1966
+ data: {
1967
+ profile,
1968
+ token_store: saved.store,
1969
+ user: { email: verified.whoami.email },
1970
+ workspace: {
1971
+ id: verified.whoami.workspace_id,
1972
+ hosted_domain: verified.whoami.hosted_domain
1973
+ }
1974
+ }
1870
1975
  };
1871
- const saved = await saveProfileToken(profile, token, options);
1976
+ }
1977
+ async function verifyAndStoreApiTokenProfile(profile, token, options, init) {
1978
+ const verified = await verifyProfileTokenAccount(profile, token, options, init);
1979
+ if (!verified.ok) return verified;
1980
+ const saved = await saveProfileApiTokenCredential(profile, {
1981
+ kind: "api_token",
1982
+ token
1983
+ }, options);
1872
1984
  if (!saved.ok) return {
1873
1985
  ok: false,
1874
1986
  error: tokenStoreUnavailableError(profile)
1875
1987
  };
1876
- await writeProfileConfig(profile, options, saved.store, whoami);
1988
+ await writeProfileConfig(profile, options, saved.store, verified.whoami);
1877
1989
  return {
1878
1990
  ok: true,
1879
1991
  data: {
1880
1992
  profile,
1881
1993
  token_store: saved.store,
1882
- user: { email: whoami.email },
1994
+ user: { email: verified.whoami.email },
1883
1995
  workspace: {
1884
- id: whoami.workspace_id,
1885
- hosted_domain: whoami.hosted_domain
1996
+ id: verified.whoami.workspace_id,
1997
+ hosted_domain: verified.whoami.hosted_domain
1886
1998
  }
1887
1999
  }
1888
2000
  };
1889
2001
  }
2002
+ async function verifyProfileTokenAccount(profile, token, options, init) {
2003
+ const config = await readGlobalConfig() ?? {};
2004
+ const whoamiResult = await apiGet("/api/cli/whoami", token, options, init, {
2005
+ authenticated: true,
2006
+ baseUrl: baseUrlOf(options)
2007
+ });
2008
+ if (whoamiResult.error) return {
2009
+ ok: false,
2010
+ error: whoamiResult.error
2011
+ };
2012
+ const whoami = whoamiProfile(whoamiResult.body);
2013
+ const profiles = config.profiles ?? {};
2014
+ const expectedEmail = nonEmpty((Object.hasOwn(profiles, profile) ? profiles[profile] : void 0)?.email);
2015
+ if (expectedEmail && whoami.email !== expectedEmail) return {
2016
+ ok: false,
2017
+ error: authAccountMismatchError(profile, expectedEmail, whoami.email)
2018
+ };
2019
+ return {
2020
+ ok: true,
2021
+ whoami
2022
+ };
2023
+ }
2024
+ async function issueCliRefreshCredential(token, options, init) {
2025
+ const result = await apiPost("/api/cli/auth/refresh-credentials", token, {}, options, init, {
2026
+ authenticated: true,
2027
+ baseUrl: baseUrlOf(options)
2028
+ });
2029
+ if (result.error) return { error: result.error };
2030
+ if (typeof result.body?.refresh_token === "string" && typeof result.body.refresh_token_expires_at === "string") return {
2031
+ refresh_token: result.body.refresh_token,
2032
+ refresh_token_expires_at: result.body.refresh_token_expires_at
2033
+ };
2034
+ return { error: validationError("Refresh credential response was invalid.", "Retry login. If this repeats, report the response shape.", "service_error") };
2035
+ }
1890
2036
  async function writeProfileConfig(profile, options, tokenStore, whoami) {
1891
2037
  const config = await readGlobalConfig() ?? {};
1892
2038
  const profiles = config.profiles ?? {};
@@ -1972,6 +2118,11 @@ async function handleCredentialFailure(command, credential, options, mode, rerun
1972
2118
  }
1973
2119
  async function handleAuthenticatedCredentialFailure(command, error, credential, options, mode, rerun, isRetry = false) {
1974
2120
  if (error.code !== "auth_required") return writeFailure(command, error, mode, 1);
2121
+ if (!isRetry && credential.profile && credential.profileCredentialKind === "session" && credential.refreshToken) {
2122
+ const refreshed = await refreshStoredProfileSession(credential.profile, credential.refreshToken, options);
2123
+ if (refreshed.ok) return rerun();
2124
+ if (refreshed.error) return writeFailure(command, refreshed.error, mode, 1);
2125
+ }
1975
2126
  return await handleCredentialFailure(command, {
1976
2127
  ok: false,
1977
2128
  source: credential.source,
@@ -1979,6 +2130,40 @@ async function handleAuthenticatedCredentialFailure(command, error, credential,
1979
2130
  error
1980
2131
  }, options, mode, rerun, isRetry);
1981
2132
  }
2133
+ async function refreshStoredProfileSession(profile, refreshToken, options) {
2134
+ const request = await requestConfig(options);
2135
+ if (request.error) return {
2136
+ ok: false,
2137
+ error: request.error
2138
+ };
2139
+ const result = await apiPostPublic("/api/cli/auth/refresh", { refresh_token: refreshToken }, options, request.init);
2140
+ if (result.error) return {
2141
+ ok: false,
2142
+ error: result.error
2143
+ };
2144
+ const { response, body } = result;
2145
+ if (!response.ok) {
2146
+ if (response.status === 401) return { ok: false };
2147
+ return {
2148
+ ok: false,
2149
+ error: mapApiError(response.status, body, { baseUrl: baseUrlOf(options) })
2150
+ };
2151
+ }
2152
+ if (typeof body?.access_token !== "string" || body.access_token.length === 0 || body.token_type?.toLowerCase() !== "bearer" || typeof body.expires_at !== "string") return {
2153
+ ok: false,
2154
+ error: validationError("Refresh response was invalid.", "Run login again. If this repeats, report the response shape.", "service_error")
2155
+ };
2156
+ if (!(await saveProfileSessionCredential(profile, {
2157
+ kind: "session",
2158
+ session_token: body.access_token,
2159
+ refresh_token: refreshToken,
2160
+ expires_at: body.expires_at
2161
+ }, options)).ok) return {
2162
+ ok: false,
2163
+ error: tokenStoreUnavailableError(profile)
2164
+ };
2165
+ return { ok: true };
2166
+ }
1982
2167
  async function handleJsonPendingAuth(command, credential, options, mode, rerun) {
1983
2168
  const profile = profileForAutoLogin(credential);
1984
2169
  const extraDetails = authRequiredExtraDetails(credential.error);
@@ -1994,7 +2179,7 @@ async function handleJsonPendingAuth(command, credential, options, mode, rerun)
1994
2179
  return writeFailure(command, exchange.error, mode, 1);
1995
2180
  }
1996
2181
  if (exchange.status === "success") {
1997
- const stored = await verifyAndStoreProfileToken(profile, exchange.token.access_token, options, request.init);
2182
+ const stored = await verifyAndStoreProfileToken(profile, exchange.token.access_token, options, request.init, exchange.token.expires_in === void 0 ? null : new Date(Date.now() + exchange.token.expires_in * 1e3).toISOString());
1998
2183
  if (!stored.ok) return writeFailure(command, stored.error, mode, 1);
1999
2184
  await clearPendingDeviceAuth(baseUrl, profile);
2000
2185
  return rerun();
@@ -2028,13 +2213,6 @@ async function runArtifactsGet(parsed, mode, isRetry = false) {
2028
2213
  if (result.error) return handleAuthenticatedCredentialFailure(command, result.error, credential, parsed.options, mode, () => runArtifactsGet(parsed, mode, true), isRetry);
2029
2214
  return writeSuccess(command, result.data, mode);
2030
2215
  }
2031
- async function readArtifact(parsed, command) {
2032
- const target = parseArtifactReadTarget(parsed, command);
2033
- if (target.error) return { error: target.error };
2034
- const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
2035
- if (!credential.ok) return { error: credential.error };
2036
- return await fetchArtifact(parsed, target.value, credential);
2037
- }
2038
2216
  function parseArtifactReadTarget(parsed, command) {
2039
2217
  const target = parseArtifactTarget(parsed.positionals[0], command, "Pass an artifact ID or share URL to read.");
2040
2218
  if (target.error) return { error: target.error };
@@ -2066,7 +2244,8 @@ async function fetchArtifact(parsed, target, credential) {
2066
2244
  artifactTarget: true,
2067
2245
  baseUrl: baseUrlOf(parsed.options),
2068
2246
  credentialSource: credential.source,
2069
- profile: credential.profile
2247
+ profile: credential.profile,
2248
+ profileCredentialKind: credential.profileCredentialKind
2070
2249
  }) };
2071
2250
  if (!artifactGetSuccessFields(body)) return { error: serviceError("Artifact read succeeded but the response did not include source metadata.") };
2072
2251
  return { data: body };
@@ -2098,7 +2277,8 @@ async function runArtifactsList(parsed, mode) {
2098
2277
  authenticated: true,
2099
2278
  baseUrl: baseUrlOf(parsed.options),
2100
2279
  credentialSource: credential.source,
2101
- profile: credential.profile
2280
+ profile: credential.profile,
2281
+ profileCredentialKind: credential.profileCredentialKind
2102
2282
  }), mode, 1);
2103
2283
  if (!artifactsListSuccessFields(body)) return writeFailure(command, serviceError("Artifact list succeeded but the response did not include list metadata."), mode, 1);
2104
2284
  return writeSuccess(command, body, mode);
@@ -2248,6 +2428,9 @@ async function autoTargets(scope) {
2248
2428
  for (const tool of autoOrder) if (TOOL_CONFIG[tool].scopes.includes(targetScope) && await isToolDetected(tool, targetScope)) detected.add(tool);
2249
2429
  return (detected.size > 0 ? [...detected] : ["codex", "claude"]).filter((tool) => TOOL_CONFIG[tool].scopes.includes(targetScope)).map((tool) => skillTarget(tool, targetScope));
2250
2430
  }
2431
+ function targetPathKey(target) {
2432
+ return realpath(target.absolutePath).catch(() => target.absolutePath);
2433
+ }
2251
2434
  async function applyAction({ target, action, content }) {
2252
2435
  if (content !== void 0) {
2253
2436
  await mkdir(dirname(target.absolutePath), { recursive: true });
@@ -2271,20 +2454,33 @@ async function cleanupSkillDirs(target) {
2271
2454
  dir = dirname(dir);
2272
2455
  }
2273
2456
  }
2457
+ function skillUpdateCommand(target) {
2458
+ return `${CLI_INVOCATION} skills update --tool ${target.tool} --scope ${target.scope} --json`;
2459
+ }
2274
2460
  async function finishActions(command, planned, dryRun, mode) {
2275
- if (!dryRun) try {
2276
- for (const item of planned) await applyAction(item);
2461
+ const completed = [...planned];
2462
+ if (!dryRun) for (const [index, item] of planned.entries()) try {
2463
+ await applyAction(item);
2464
+ completed[index] = item;
2277
2465
  } catch (error) {
2466
+ if (item.fallbackAction) {
2467
+ completed[index] = {
2468
+ target: item.target,
2469
+ action: item.fallbackAction
2470
+ };
2471
+ continue;
2472
+ }
2278
2473
  writeFailure(command, unexpectedError(error), mode, 1);
2279
2474
  return;
2280
2475
  }
2281
2476
  return {
2282
2477
  dry_run: dryRun,
2283
- targets: planned.map(({ target, action }) => ({
2478
+ targets: completed.map(({ target, action }) => ({
2284
2479
  tool: target.tool,
2285
2480
  scope: target.scope,
2286
2481
  path: target.path,
2287
- action
2482
+ action,
2483
+ ...action === "update_recommended" ? { update_command: skillUpdateCommand(target) } : {}
2288
2484
  }))
2289
2485
  };
2290
2486
  }
@@ -2352,15 +2548,33 @@ async function ensureSkills(parsed, mode, options = {}) {
2352
2548
  return;
2353
2549
  }
2354
2550
  const unchanged = state.kind === "managed" && state.version === bundled.version;
2551
+ const recommendUpdate = options.recommendProjectUpdates && target.scope === "project" && state.kind === "managed" && state.version !== bundled.version;
2355
2552
  planned.push(unchanged ? {
2356
2553
  target,
2357
2554
  action: "unchanged"
2555
+ } : recommendUpdate ? {
2556
+ target,
2557
+ action: "update_recommended"
2358
2558
  } : {
2359
2559
  target,
2360
2560
  action: state.kind === "missing" ? "installed" : "updated",
2361
2561
  content: bundled.contents[target.tool]
2362
2562
  });
2363
2563
  }
2564
+ if (options.autoUpdateUserManaged) {
2565
+ const plannedPaths = new Set(await Promise.all(planned.map((action) => targetPathKey(action.target))));
2566
+ for (const target of allTargets().filter((candidate) => candidate.scope === "user")) {
2567
+ if (plannedPaths.has(await targetPathKey(target))) continue;
2568
+ const state = await readTarget(target);
2569
+ if (state.kind !== "managed" || state.version === bundled.version) continue;
2570
+ planned.push({
2571
+ target,
2572
+ action: "updated",
2573
+ content: bundled.contents[target.tool],
2574
+ fallbackAction: "update_recommended"
2575
+ });
2576
+ }
2577
+ }
2364
2578
  return finishActions(command, planned, parsed.options.dryRun === true, mode);
2365
2579
  }
2366
2580
  async function runSkillsEnsure(parsed, mode) {
@@ -2389,6 +2603,31 @@ async function runSkillsList(parsed, mode) {
2389
2603
  targets
2390
2604
  }, mode);
2391
2605
  }
2606
+ async function skillDiagnostics() {
2607
+ const bundled = await loadBundledSkills();
2608
+ const targets = [];
2609
+ for (const target of allTargets()) {
2610
+ const state = await readTarget(target);
2611
+ const updateAvailable = state.kind === "managed" && state.version !== bundled.version;
2612
+ targets.push({
2613
+ tool: target.tool,
2614
+ scope: target.scope,
2615
+ path: target.path,
2616
+ installed: state.kind !== "missing",
2617
+ managed: state.kind === "managed",
2618
+ installed_version: state.kind === "managed" ? state.version : null,
2619
+ update_available: updateAvailable,
2620
+ update_command: updateAvailable ? skillUpdateCommand(target) : null
2621
+ });
2622
+ }
2623
+ const updateTargets = targets.filter((target) => target.update_available);
2624
+ return {
2625
+ bundled_version: bundled.version,
2626
+ update_available: updateTargets.length > 0,
2627
+ update_command: updateTargets.length > 0 ? `${CLI_INVOCATION} skills update --json` : null,
2628
+ targets
2629
+ };
2630
+ }
2392
2631
  async function runSkillsUpdate(parsed, mode) {
2393
2632
  const command = "skills update";
2394
2633
  const filters = parseFilters(parsed);
@@ -2437,7 +2676,7 @@ async function runSkillsRemove(parsed, mode) {
2437
2676
  }
2438
2677
  //#endregion
2439
2678
  //#region src/command-runners/open.ts
2440
- async function runOpen(parsed, mode) {
2679
+ async function runOpen(parsed, mode, isRetry = false) {
2441
2680
  const command = "open";
2442
2681
  const skills = await ensureSkills({
2443
2682
  ...parsed,
@@ -2446,11 +2685,21 @@ async function runOpen(parsed, mode) {
2446
2685
  tool: "auto",
2447
2686
  scope: "project"
2448
2687
  }
2449
- }, mode, { command });
2688
+ }, mode, {
2689
+ command,
2690
+ autoUpdateUserManaged: true,
2691
+ recommendProjectUpdates: true
2692
+ });
2450
2693
  if (!skills) return;
2451
2694
  const target = parseArtifactTarget(parsed.positionals[0], command, "Pass an artifact ID or share URL to read.");
2452
2695
  if (target.error) return writeFailure(command, target.error, mode, 1);
2453
- const result = await readArtifact(parsed, command);
2696
+ const credential = await resolveCredential(parsed.options, await resolveProjectConfig());
2697
+ if (!credential.ok) return handleCredentialFailure(command, credential, parsed.options, mode, () => runOpen(parsed, mode, true), isRetry);
2698
+ const result = await fetchArtifact(parsed, {
2699
+ artifactId: target.artifactId,
2700
+ include: [],
2701
+ offset: void 0
2702
+ }, credential);
2454
2703
  if (result.error) {
2455
2704
  if (result.error.code === "unsupported_kind") return writeSuccess(command, {
2456
2705
  skills,
@@ -2459,6 +2708,7 @@ async function runOpen(parsed, mode) {
2459
2708
  next_command: agentDownloadCommand(target.artifactId)
2460
2709
  }
2461
2710
  }, mode);
2711
+ if (result.error.code === "auth_required") return handleAuthenticatedCredentialFailure(command, result.error, credential, parsed.options, mode, () => runOpen(parsed, mode, true), isRetry);
2462
2712
  return writeFailure(command, result.error, mode, 1);
2463
2713
  }
2464
2714
  return writeSuccess(command, {
@@ -2483,7 +2733,8 @@ async function runCommentsList(parsed, mode) {
2483
2733
  const result = await apiGet(`/api/cli/artifacts/${encodeURIComponent(artifactId)}/comments`, credential.token, parsed.options, request.init, {
2484
2734
  artifactTarget: true,
2485
2735
  credentialSource: credential.source,
2486
- profile: credential.profile
2736
+ profile: credential.profile,
2737
+ profileCredentialKind: credential.profileCredentialKind
2487
2738
  });
2488
2739
  if (result.error) return writeFailure(command, result.error, mode, 1);
2489
2740
  const comments = Array.isArray(result.body?.comments) ? result.body.comments : [];
@@ -2510,16 +2761,19 @@ async function runCommentsPost(parsed, mode) {
2510
2761
  if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
2511
2762
  const request = await requestConfig(parsed.options);
2512
2763
  if (request.error) return writeFailure(command, request.error, mode, 1);
2764
+ const agent = parsed.options.agent;
2513
2765
  const result = await apiPost(`/api/cli/artifacts/${encodeURIComponent(artifactId)}/comments`, credential.token, {
2514
2766
  body,
2515
2767
  reply_to: replyTo,
2516
2768
  quote,
2517
2769
  quote_before: parsed.options.quoteBefore,
2518
- quote_after: parsed.options.quoteAfter
2770
+ quote_after: parsed.options.quoteAfter,
2771
+ ...agent ? { agent } : {}
2519
2772
  }, parsed.options, request.init, {
2520
2773
  artifactTarget: true,
2521
2774
  credentialSource: credential.source,
2522
- profile: credential.profile
2775
+ profile: credential.profile,
2776
+ profileCredentialKind: credential.profileCredentialKind
2523
2777
  });
2524
2778
  if (result.error) return writeFailure(command, result.error, mode, 1);
2525
2779
  const threadId = configString(result.body?.thread_id);
@@ -2621,7 +2875,8 @@ async function postCommentAction(parsed, command, artifactId, payload, mode) {
2621
2875
  const result = await apiPost(`/api/cli/artifacts/${encodeURIComponent(artifactId)}/comments`, credential.token, payload, parsed.options, request.init, {
2622
2876
  artifactTarget: true,
2623
2877
  credentialSource: credential.source,
2624
- profile: credential.profile
2878
+ profile: credential.profile,
2879
+ profileCredentialKind: credential.profileCredentialKind
2625
2880
  });
2626
2881
  if (result.error) {
2627
2882
  writeFailure(command, result.error, mode, 1);
@@ -2652,7 +2907,8 @@ async function runDelete(parsed, mode) {
2652
2907
  authenticated: true,
2653
2908
  artifactTarget: true,
2654
2909
  credentialSource: credential.source,
2655
- profile: credential.profile
2910
+ profile: credential.profile,
2911
+ profileCredentialKind: credential.profileCredentialKind
2656
2912
  });
2657
2913
  if (result.error) return writeFailure(command, result.error, mode, 1);
2658
2914
  const body = result.body;
@@ -2708,6 +2964,7 @@ async function runDoctor(parsed, mode) {
2708
2964
  next_command: null,
2709
2965
  base_url: baseUrlOf(parsed.options),
2710
2966
  config: await configDiagnostics(project),
2967
+ skills: await skillDiagnostics(),
2711
2968
  auth: {
2712
2969
  credential_source: credential.source,
2713
2970
  ...credential.profile ? { profile: credential.profile } : {},
@@ -2756,7 +3013,8 @@ async function runDoctor(parsed, mode) {
2756
3013
  authenticated: true,
2757
3014
  baseUrl: baseUrlOf(parsed.options),
2758
3015
  credentialSource: credential.source,
2759
- profile: credential.profile
3016
+ profile: credential.profile,
3017
+ profileCredentialKind: credential.profileCredentialKind
2760
3018
  });
2761
3019
  data.auth.code = error.code;
2762
3020
  data.auth.hint = error.hint;
@@ -3010,7 +3268,8 @@ async function runDownload(parsed, mode, isRetry = false) {
3010
3268
  artifactTarget: true,
3011
3269
  baseUrl,
3012
3270
  credentialSource: credential.source,
3013
- profile: credential.profile
3271
+ profile: credential.profile,
3272
+ profileCredentialKind: credential.profileCredentialKind
3014
3273
  }), credential, parsed.options, mode, () => runDownload(parsed, mode, true), isRetry);
3015
3274
  if (!downloadManifestFields(body)) return writeFailure(command, serviceError("Download manifest succeeded but the response did not include file metadata."), mode, 1);
3016
3275
  const plan = await prepareDownloadPlan(body, parsed.options.output ?? artifactId, Boolean(parsed.options.force));
@@ -3030,7 +3289,8 @@ async function runDownload(parsed, mode, isRetry = false) {
3030
3289
  artifactTarget: true,
3031
3290
  baseUrl,
3032
3291
  credentialSource: credential.source,
3033
- profile: credential.profile
3292
+ profile: credential.profile,
3293
+ profileCredentialKind: credential.profileCredentialKind
3034
3294
  }), credential, parsed.options, mode, () => runDownload(parsed, mode, true), isRetry);
3035
3295
  const bytes = Buffer.from(await fileResponse.arrayBuffer());
3036
3296
  const verified = verifyDownloadedBytes(file, bytes);
@@ -3087,7 +3347,8 @@ async function runEdit(parsed, mode) {
3087
3347
  artifactTarget: true,
3088
3348
  editSettings: true,
3089
3349
  credentialSource: credential.source,
3090
- profile: credential.profile
3350
+ profile: credential.profile,
3351
+ profileCredentialKind: credential.profileCredentialKind
3091
3352
  });
3092
3353
  if (result.error) return writeFailure(command, result.error, mode, 1);
3093
3354
  const data = parseEditData(result.body);
@@ -3234,12 +3495,52 @@ function gitPattern(path) {
3234
3495
  }
3235
3496
  //#endregion
3236
3497
  //#region src/command-runners/init.ts
3237
- async function runInit(parsed, mode) {
3238
- const command = "init";
3498
+ function runInit(parsed, mode) {
3239
3499
  const profile = nonEmpty(parsed.options.profile);
3240
3500
  const projectId = nonEmpty(parsed.options.projectId);
3501
+ if (!profile && !projectId) return runInitOnboarding(parsed, mode);
3502
+ return runInitConfig(parsed, mode, profile, projectId);
3503
+ }
3504
+ async function runInitOnboarding(parsed, mode) {
3505
+ const command = "init";
3506
+ const skills = await ensureSkills({
3507
+ ...parsed,
3508
+ options: {
3509
+ ...parsed.options,
3510
+ tool: "auto",
3511
+ scope: "project"
3512
+ }
3513
+ }, mode, {
3514
+ command,
3515
+ autoUpdateUserManaged: true,
3516
+ recommendProjectUpdates: true
3517
+ });
3518
+ if (!skills) return;
3519
+ const project = await resolveProjectConfig();
3520
+ const signedIn = (await resolveCredential(parsed.options, project)).ok;
3521
+ return writeSuccess(command, {
3522
+ mode: "onboarding",
3523
+ skills,
3524
+ signed_in: signedIn,
3525
+ next_steps: onboardingNextSteps(signedIn)
3526
+ }, mode);
3527
+ }
3528
+ function onboardingNextSteps(signedIn) {
3529
+ return [{
3530
+ id: "login",
3531
+ title: signedIn ? "Already signed in." : "Sign in so you can share files.",
3532
+ command: `${CLI_INVOCATION} login`,
3533
+ done: signedIn
3534
+ }, {
3535
+ id: "share",
3536
+ title: "Share a file or folder to get a link.",
3537
+ command: `${CLI_INVOCATION} share <path> --json`
3538
+ }];
3539
+ }
3540
+ async function runInitConfig(parsed, mode, profile, projectId) {
3541
+ const command = "init";
3542
+ if (parsed.options.dryRun === true) return writeFailure(command, validationError("--dry-run is only supported without --profile or --project-id.", "Run init --dry-run by itself to preview the skill install, or drop --dry-run to save the defaults."), mode, 1);
3241
3543
  const resolved = await resolveProjectConfig();
3242
- if (!profile && !projectId) return writeSuccess(command, initData(false, resolved.raw ?? {}, resolved), mode);
3243
3544
  if (profile) {
3244
3545
  if (!configHome()) return writeFailure(command, tokenStoreUnavailableError(profile), mode, 1);
3245
3546
  const globalConfig = await readGlobalConfig();
@@ -3254,16 +3555,17 @@ async function runInit(parsed, mode) {
3254
3555
  await mkdir(dirname(path), { recursive: true });
3255
3556
  await writeFile(path, `${JSON.stringify(next, null, 2)}\n`);
3256
3557
  const gitExclude = await ensureGitExclude(process.cwd());
3257
- const data = initData(true, next, resolved);
3558
+ const data = configData(next, resolved);
3258
3559
  delete data.read_path;
3259
3560
  if (gitExclude.warning) data.git_exclude_warning = gitExclude.warning;
3260
3561
  if (gitExclude.applied) data.git_exclude_applied = true;
3261
3562
  return writeSuccess(command, data, mode);
3262
3563
  }
3263
- function initData(written, config, resolved) {
3564
+ function configData(config, resolved) {
3264
3565
  return {
3566
+ mode: "config",
3265
3567
  path: PROJECT_CONFIG_LOCAL_PATH,
3266
- written,
3568
+ written: true,
3267
3569
  config: {
3268
3570
  default_profile: configString(config.default_profile),
3269
3571
  default_project_id: configString(config.default_project_id)
@@ -3289,7 +3591,8 @@ async function runMove(parsed, mode) {
3289
3591
  const result = await apiPost(`/api/cli/shareables/${encodeURIComponent(target.artifactId)}/move`, credential.token, { destination: home ? "home" : { project_id: projectId } }, parsed.options, request.init, {
3290
3592
  artifactTarget: true,
3291
3593
  credentialSource: credential.source,
3292
- profile: credential.profile
3594
+ profile: credential.profile,
3595
+ profileCredentialKind: credential.profileCredentialKind
3293
3596
  });
3294
3597
  if (result.error) return writeFailure(command, result.error, mode, 1);
3295
3598
  const data = parseMoveData(result.body);
@@ -3405,7 +3708,7 @@ async function runProfilesImportToken(parsed, mode) {
3405
3708
  if (!token) return writeFailure(command, validationError("A token is required on standard input.", `Pipe a token: printf '%s' "$TOKEN" | ${CLI_INVOCATION} profiles import-token --profile ${profile} --json`), mode, 1);
3406
3709
  const request = await requestConfig(parsed.options);
3407
3710
  if (request.error) return writeFailure(command, request.error, mode, 1);
3408
- const stored = await verifyAndStoreProfileToken(profile, token, parsed.options, request.init);
3711
+ const stored = await verifyAndStoreApiTokenProfile(profile, token, parsed.options, request.init);
3409
3712
  if (!stored.ok) return writeFailure(command, stored.error, mode, 1);
3410
3713
  return writeSuccess(command, {
3411
3714
  profile,
@@ -3442,7 +3745,8 @@ async function runProjectsList(parsed, mode) {
3442
3745
  if (request.error) return writeFailure(command, request.error, mode, 1);
3443
3746
  const result = await fetchProjects(credential.token, parsed.options, request.init, {
3444
3747
  credentialSource: credential.source,
3445
- profile: credential.profile
3748
+ profile: credential.profile,
3749
+ profileCredentialKind: credential.profileCredentialKind
3446
3750
  });
3447
3751
  if (result.error) return writeFailure(command, result.error, mode, 1);
3448
3752
  const defaultProjectId = configString(projectConfig.config?.default_project_id);
@@ -3473,7 +3777,8 @@ async function runProjectsCreate(parsed, mode) {
3473
3777
  base_visibility: visibility ?? null
3474
3778
  }, parsed.options, request.init, {
3475
3779
  credentialSource: credential.source,
3476
- profile: credential.profile
3780
+ profile: credential.profile,
3781
+ profileCredentialKind: credential.profileCredentialKind
3477
3782
  });
3478
3783
  if (result.error) return writeFailure(command, result.error, mode, 1);
3479
3784
  const project = isRecord(result.body?.project) ? result.body.project : null;
@@ -3503,7 +3808,8 @@ async function runProjectsEdit(parsed, mode) {
3503
3808
  const result = await apiPost(`/api/cli/projects/${encodeURIComponent(projectId)}`, credential.token, payload.body, parsed.options, request.init, {
3504
3809
  projectTarget: true,
3505
3810
  credentialSource: credential.source,
3506
- profile: credential.profile
3811
+ profile: credential.profile,
3812
+ profileCredentialKind: credential.profileCredentialKind
3507
3813
  });
3508
3814
  if (result.error) return writeFailure(command, result.error, mode, 1);
3509
3815
  const data = parseProjectsEditData(result.body);
@@ -3611,7 +3917,8 @@ async function runShare(parsed, mode, isRetry = false) {
3611
3917
  authenticated: true,
3612
3918
  baseUrl,
3613
3919
  credentialSource: credential.source,
3614
- profile: credential.profile
3920
+ profile: credential.profile,
3921
+ profileCredentialKind: credential.profileCredentialKind
3615
3922
  });
3616
3923
  if (resolved.error) return handleAuthenticatedCredentialFailure(command, resolved.error, credential, parsed.options, mode, () => runShare(parsed, mode, true), isRetry);
3617
3924
  const { project: _project, ...rest } = parsed.options;
@@ -3648,7 +3955,8 @@ async function runShare(parsed, mode, isRetry = false) {
3648
3955
  authenticated: true,
3649
3956
  baseUrl,
3650
3957
  credentialSource: credential.source,
3651
- profile: credential.profile
3958
+ profile: credential.profile,
3959
+ profileCredentialKind: credential.profileCredentialKind
3652
3960
  }), credential, parsed.options, mode, () => runShare(parsed, mode, true), isRetry);
3653
3961
  const id = body?.id ?? null;
3654
3962
  return writeSuccess(command, {
@@ -3698,7 +4006,8 @@ async function runRequestAccess(parsed, mode) {
3698
4006
  if (request.error) return writeFailure(command, request.error, mode, 1);
3699
4007
  const result = await apiPost("/api/cli/request-access", credential.token, { note }, parsed.options, request.init, {
3700
4008
  credentialSource: credential.source,
3701
- profile: credential.profile
4009
+ profile: credential.profile,
4010
+ profileCredentialKind: credential.profileCredentialKind
3702
4011
  });
3703
4012
  if (result.error) return writeFailure(command, result.error, mode, 1);
3704
4013
  const body = result.body;
@@ -3735,7 +4044,8 @@ async function runResolve(parsed, mode) {
3735
4044
  authenticated: true,
3736
4045
  baseUrl: baseUrlOf(parsed.options),
3737
4046
  credentialSource: credential.source,
3738
- profile: credential.profile
4047
+ profile: credential.profile,
4048
+ profileCredentialKind: credential.profileCredentialKind
3739
4049
  }), mode, 1);
3740
4050
  if (!resolveSuccessFields(body)) return writeFailure(command, serviceError("Resolve succeeded but the response did not include query, candidates, and has_more."), mode, 1);
3741
4051
  return writeSuccess(command, body, mode);
@@ -3776,7 +4086,8 @@ async function runUpdate(parsed, mode, isRetry = false) {
3776
4086
  artifactTarget: true,
3777
4087
  baseUrl,
3778
4088
  credentialSource: credential.source,
3779
- profile: credential.profile
4089
+ profile: credential.profile,
4090
+ profileCredentialKind: credential.profileCredentialKind
3780
4091
  }), credential, parsed.options, mode, () => runUpdate(parsed, mode, true), isRetry);
3781
4092
  const id = body?.id ?? artifactId;
3782
4093
  const result = {
@@ -3801,7 +4112,8 @@ async function runWhoami(parsed, mode) {
3801
4112
  if (request.error) return writeFailure(command, request.error, mode, 1);
3802
4113
  const whoami = await apiGet("/api/cli/whoami", credential.token, parsed.options, request.init, {
3803
4114
  credentialSource: credential.source,
3804
- profile: credential.profile
4115
+ profile: credential.profile,
4116
+ profileCredentialKind: credential.profileCredentialKind
3805
4117
  });
3806
4118
  if (whoami.error) return writeFailure(command, whoami.error, mode, 1);
3807
4119
  return writeSuccess(command, isRecord(whoami.body) ? {
@@ -4050,7 +4362,8 @@ const entryCommand = define({
4050
4362
  description: "Artifact Share CLI",
4051
4363
  toKebab: true,
4052
4364
  args: commonArgs,
4053
- examples: `npx --yes @artifactshare/cli open <artifact-id-or-url> --json
4365
+ examples: `npx --yes @artifactshare/cli init --json
4366
+ npx --yes @artifactshare/cli open <artifact-id-or-url> --json
4054
4367
  npx --yes @artifactshare/cli share <path> --json
4055
4368
  npx --yes @artifactshare/cli update <artifact-id-or-url> <path> --json
4056
4369
  npx --yes @artifactshare/cli edit <artifact-id-or-url> --title "New title" --json
@@ -4530,6 +4843,11 @@ const commentsPostDefinition = define({
4530
4843
  type: "string",
4531
4844
  toKebab: true,
4532
4845
  description: "Text just after the quote, to pick the right occurrence"
4846
+ },
4847
+ agent: {
4848
+ type: "string",
4849
+ toKebab: true,
4850
+ description: "Agent name posting on behalf of the user (e.g. Claude, Cursor)"
4533
4851
  }
4534
4852
  },
4535
4853
  examples: `npx --yes @artifactshare/cli comments post abc123def4 --body "Looks good" --json
@@ -4962,7 +5280,7 @@ npx --yes @artifactshare/cli skills list --json`,
4962
5280
  });
4963
5281
  const initDefinition = define({
4964
5282
  name: "init",
4965
- description: "Save working-directory defaults to .artifactshare/config.json.",
5283
+ description: "Set up Artifact Share for this directory, or save its defaults.",
4966
5284
  toKebab: true,
4967
5285
  args: {
4968
5286
  ...commonArgs,
@@ -4970,16 +5288,25 @@ const initDefinition = define({
4970
5288
  type: "string",
4971
5289
  toKebab: true,
4972
5290
  description: "Default project for sharing in this directory"
5291
+ },
5292
+ dryRun: {
5293
+ type: "boolean",
5294
+ toKebab: true,
5295
+ description: "Show the planned skill changes without writing (onboarding)"
4973
5296
  }
4974
5297
  },
4975
- examples: `npx --yes @artifactshare/cli init --profile client-a --project-id <id> --json
4976
- npx --yes @artifactshare/cli init --json
5298
+ examples: `npx --yes @artifactshare/cli init --json
5299
+ npx --yes @artifactshare/cli init --dry-run --json
5300
+ npx --yes @artifactshare/cli init --profile client-a --project-id <id> --json
4977
5301
 
4978
- Without flags, init reports the current config and writes nothing.
4979
- Secrets are never written to .artifactshare/config.json.
5302
+ Without flags, init detects your agent (Claude Code, Codex, Cursor), installs the
5303
+ bundled skill, and shows the next steps (sign in, then share). data.mode is "onboarding".
5304
+ With --profile or --project-id, init saves working-directory defaults to
5305
+ .artifactshare/config.local.json instead (data.mode is "config"); secrets are never written there.
4980
5306
 
4981
5307
  Common failures:
4982
- profile_not_found Run profiles list to see saved profiles, or login --profile <name>`
5308
+ skill_update_conflict An unmanaged or broken skill file exists; inspect it before overwriting
5309
+ profile_not_found Run profiles list to see saved profiles, or login --profile <name>`
4983
5310
  });
4984
5311
  const requestAccessDefinition = define({
4985
5312
  name: "request-access",