@artifactshare/cli 0.4.0 → 0.5.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/README.md +4 -3
- package/dist/index.js +293 -15
- package/package.json +1 -1
- package/skills/artifactshare/SKILL.md +11 -3
- package/skills/artifactshare/artifactshare.mdc +5 -4
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ npx --yes @artifactshare/cli edit <artifact-id-or-url> --project-id <id> --json
|
|
|
25
25
|
npx --yes @artifactshare/cli edit <artifact-id-or-url> --visibility private --grant-email viewer@example.com --json
|
|
26
26
|
npx --yes @artifactshare/cli update <artifact-id-or-url> ./dist
|
|
27
27
|
npx --yes @artifactshare/cli delete <artifact-id-or-url> --json
|
|
28
|
+
npx --yes @artifactshare/cli logout --profile default --json
|
|
28
29
|
```
|
|
29
30
|
|
|
30
31
|
To keep an existing share URL, update it with
|
|
@@ -37,7 +38,7 @@ runs add versions to the same file.
|
|
|
37
38
|
|
|
38
39
|
- **Interactive**: run `npx --yes @artifactshare/cli login`, or run `share`, `update`, or `download` directly — those commands start sign-in for you when unauthenticated (the CLI prints a link and code to open in your browser). Profiles created by `login` renew expired CLI sessions automatically during normal use.
|
|
39
40
|
- **CI / non-interactive**: issue a token at `https://artifactshare.com/settings/tokens`, then set `ARTIFACTSHARE_TOKEN` (or pass `--token`). Without a token, non-interactive runs fail with `error.code: "auth_required"` instead of hanging.
|
|
40
|
-
- Multiple accounts: keep one local profile per account (`profiles list` / `profiles use <name>`). In non-interactive agents, pipe an issued token into `profiles import-token --profile <name> --json` to create a saved API-token profile without browser login; API-token profiles are not renewed by the CLI.
|
|
41
|
+
- Multiple accounts: keep one local profile per account (`profiles list` / `profiles use <name>`). In non-interactive agents, pipe an issued token into `profiles import-token --profile <name> --json` to create a saved API-token profile without browser login; API-token profiles are not renewed by the CLI. Use `logout --profile <name>` to remove a saved credential while keeping profile metadata, or `profiles delete <name>` to remove the profile entry too.
|
|
41
42
|
|
|
42
43
|
## Commands
|
|
43
44
|
|
|
@@ -55,9 +56,9 @@ runs add versions to the same file.
|
|
|
55
56
|
| `projects list / create / edit` | List, create, and edit project destinations and audience |
|
|
56
57
|
| `move <target>` | Move an existing file into a project or back home; `edit` is preferred for new automation |
|
|
57
58
|
| `request-access` | Join the waitlist when sharing is not enabled yet |
|
|
58
|
-
| `login` / `whoami`
|
|
59
|
+
| `login` / `logout` / `whoami` | Sign in, remove a saved local credential, and check who you are |
|
|
59
60
|
| `doctor` | Diagnose auth, destination, network, and upload readiness — tells you the next command to run |
|
|
60
|
-
| `profiles list / use / import-token`
|
|
61
|
+
| `profiles list / use / import-token / delete` | Switch between local account profiles, import an issued token from stdin, and delete profile entries |
|
|
61
62
|
| `init` | Set up this directory: detect the agent and install the skill, then show next steps; or save defaults with `--profile` / `--project-id` |
|
|
62
63
|
| `skills ensure / install / list / update / remove` | Install or update the bundled usage guide in your AI agent's skills |
|
|
63
64
|
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { appendFile, chmod, lstat, mkdir, mkdtemp, readFile, readdir, realpath,
|
|
|
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";
|
|
6
|
-
import { setTimeout } from "node:timers/promises";
|
|
6
|
+
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import { createReadStream } from "node:fs";
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
@@ -69,6 +69,7 @@ const VALUE_FLAGS = new Set([
|
|
|
69
69
|
]);
|
|
70
70
|
const COMMAND_NAMES = new Set([
|
|
71
71
|
"login",
|
|
72
|
+
"logout",
|
|
72
73
|
"share",
|
|
73
74
|
"open",
|
|
74
75
|
"update",
|
|
@@ -100,7 +101,8 @@ const SUBCOMMANDS = {
|
|
|
100
101
|
profiles: [
|
|
101
102
|
"list",
|
|
102
103
|
"use",
|
|
103
|
-
"import-token"
|
|
104
|
+
"import-token",
|
|
105
|
+
"delete"
|
|
104
106
|
],
|
|
105
107
|
projects: [
|
|
106
108
|
"list",
|
|
@@ -1234,6 +1236,104 @@ function spawnFile(command, args, input) {
|
|
|
1234
1236
|
else child.stdin.end();
|
|
1235
1237
|
});
|
|
1236
1238
|
}
|
|
1239
|
+
function browserOpenSkipReason() {
|
|
1240
|
+
if (process.env.CI === "true") return "ci";
|
|
1241
|
+
if (process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY) return "headless_linux";
|
|
1242
|
+
return null;
|
|
1243
|
+
}
|
|
1244
|
+
function resolveBrowserOpener(url) {
|
|
1245
|
+
if (process.platform === "darwin") return {
|
|
1246
|
+
command: "open",
|
|
1247
|
+
args: [url],
|
|
1248
|
+
label: "open"
|
|
1249
|
+
};
|
|
1250
|
+
if (process.platform === "win32") return {
|
|
1251
|
+
command: "rundll32",
|
|
1252
|
+
args: ["url.dll,FileProtocolHandler", url],
|
|
1253
|
+
label: "rundll32"
|
|
1254
|
+
};
|
|
1255
|
+
return {
|
|
1256
|
+
command: "xdg-open",
|
|
1257
|
+
args: [url],
|
|
1258
|
+
label: "xdg-open"
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
const BROWSER_OPENER_CLOSE_TIMEOUT_MS = 1500;
|
|
1262
|
+
function spawnDetached(command, args) {
|
|
1263
|
+
return new Promise((resolve) => {
|
|
1264
|
+
const child = spawn(command, args, {
|
|
1265
|
+
stdio: "ignore",
|
|
1266
|
+
detached: true
|
|
1267
|
+
});
|
|
1268
|
+
let settled = false;
|
|
1269
|
+
const finish = (result) => {
|
|
1270
|
+
if (settled) return;
|
|
1271
|
+
settled = true;
|
|
1272
|
+
clearTimeout(timeoutId);
|
|
1273
|
+
resolve(result);
|
|
1274
|
+
};
|
|
1275
|
+
const timeoutId = setTimeout(() => {
|
|
1276
|
+
child.unref();
|
|
1277
|
+
finish({ status: "started" });
|
|
1278
|
+
}, BROWSER_OPENER_CLOSE_TIMEOUT_MS);
|
|
1279
|
+
child.once("error", (error) => {
|
|
1280
|
+
finish({
|
|
1281
|
+
status: "failed",
|
|
1282
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
1283
|
+
});
|
|
1284
|
+
});
|
|
1285
|
+
child.once("close", (code, signal) => {
|
|
1286
|
+
if (signal) {
|
|
1287
|
+
finish({
|
|
1288
|
+
status: "failed",
|
|
1289
|
+
reason: `signal_${signal}`
|
|
1290
|
+
});
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
if (code === 0) {
|
|
1294
|
+
finish({ status: "started" });
|
|
1295
|
+
return;
|
|
1296
|
+
}
|
|
1297
|
+
finish({
|
|
1298
|
+
status: "failed",
|
|
1299
|
+
reason: `exit_${code ?? "null"}`
|
|
1300
|
+
});
|
|
1301
|
+
});
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
async function openDeviceAuthorizationUrl(url) {
|
|
1305
|
+
const testOpener = process.env.ARTIFACTSHARE_TEST_BROWSER_OPENER?.trim();
|
|
1306
|
+
if (testOpener === "success") return {
|
|
1307
|
+
attempted: true,
|
|
1308
|
+
status: "started",
|
|
1309
|
+
command: "test"
|
|
1310
|
+
};
|
|
1311
|
+
if (testOpener === "fail") return {
|
|
1312
|
+
attempted: true,
|
|
1313
|
+
status: "failed",
|
|
1314
|
+
command: "test",
|
|
1315
|
+
reason: "spawn_failed"
|
|
1316
|
+
};
|
|
1317
|
+
const skipReason = browserOpenSkipReason();
|
|
1318
|
+
if (skipReason) return {
|
|
1319
|
+
attempted: false,
|
|
1320
|
+
status: "skipped",
|
|
1321
|
+
reason: skipReason
|
|
1322
|
+
};
|
|
1323
|
+
const opener = resolveBrowserOpener(url);
|
|
1324
|
+
const spawnResult = await spawnDetached(opener.command, opener.args);
|
|
1325
|
+
if (spawnResult.status === "failed") return {
|
|
1326
|
+
attempted: true,
|
|
1327
|
+
status: "failed",
|
|
1328
|
+
command: opener.label,
|
|
1329
|
+
reason: spawnResult.reason
|
|
1330
|
+
};
|
|
1331
|
+
return {
|
|
1332
|
+
attempted: true,
|
|
1333
|
+
status: "started",
|
|
1334
|
+
command: opener.label
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1237
1337
|
//#endregion
|
|
1238
1338
|
//#region src/destination.ts
|
|
1239
1339
|
function destinationConflictError(options) {
|
|
@@ -1368,6 +1468,35 @@ async function saveProfileCredential(profile, credential, options) {
|
|
|
1368
1468
|
reason: "unavailable"
|
|
1369
1469
|
};
|
|
1370
1470
|
}
|
|
1471
|
+
async function deleteProfileCredential(profile, options) {
|
|
1472
|
+
const account = accountName(profile, baseUrlOf(options));
|
|
1473
|
+
let credentialRemoved = false;
|
|
1474
|
+
let tokenStore = null;
|
|
1475
|
+
const native = await nativeStore();
|
|
1476
|
+
if (native) {
|
|
1477
|
+
if (await native.read(account)) {
|
|
1478
|
+
if (!await native.delete(account)) return {
|
|
1479
|
+
ok: false,
|
|
1480
|
+
reason: "unavailable"
|
|
1481
|
+
};
|
|
1482
|
+
credentialRemoved = true;
|
|
1483
|
+
tokenStore = native.kind;
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
if (await readPlaintextToken(account) !== null) {
|
|
1487
|
+
if (!await deletePlaintextTokenAccount(account)) return {
|
|
1488
|
+
ok: false,
|
|
1489
|
+
reason: "unavailable"
|
|
1490
|
+
};
|
|
1491
|
+
credentialRemoved = true;
|
|
1492
|
+
tokenStore ??= "plaintext_file";
|
|
1493
|
+
}
|
|
1494
|
+
return {
|
|
1495
|
+
ok: true,
|
|
1496
|
+
credential_removed: credentialRemoved,
|
|
1497
|
+
token_store: tokenStore
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1371
1500
|
function parseStoredProfileCredential(raw) {
|
|
1372
1501
|
if (!raw) return {
|
|
1373
1502
|
ok: false,
|
|
@@ -1468,6 +1597,15 @@ function macosKeychain() {
|
|
|
1468
1597
|
"-w",
|
|
1469
1598
|
securityQuote(token)
|
|
1470
1599
|
].join(" ")}\n`)).status === 0;
|
|
1600
|
+
},
|
|
1601
|
+
delete: async (account) => {
|
|
1602
|
+
return (await spawnFile("security", [
|
|
1603
|
+
"delete-generic-password",
|
|
1604
|
+
"-s",
|
|
1605
|
+
SERVICE,
|
|
1606
|
+
"-a",
|
|
1607
|
+
account
|
|
1608
|
+
])).status === 0;
|
|
1471
1609
|
}
|
|
1472
1610
|
};
|
|
1473
1611
|
}
|
|
@@ -1498,9 +1636,34 @@ async function linuxSecretService() {
|
|
|
1498
1636
|
"account",
|
|
1499
1637
|
account
|
|
1500
1638
|
], token)).status === 0;
|
|
1639
|
+
},
|
|
1640
|
+
delete: async (account) => {
|
|
1641
|
+
return (await spawnFile("secret-tool", [
|
|
1642
|
+
"clear",
|
|
1643
|
+
"service",
|
|
1644
|
+
SERVICE,
|
|
1645
|
+
"account",
|
|
1646
|
+
account
|
|
1647
|
+
])).status === 0;
|
|
1501
1648
|
}
|
|
1502
1649
|
};
|
|
1503
1650
|
}
|
|
1651
|
+
async function deletePlaintextTokenAccount(account) {
|
|
1652
|
+
const tokens = await readPlaintextTokens();
|
|
1653
|
+
if (!tokens || !Object.hasOwn(tokens, account)) return false;
|
|
1654
|
+
const home = configHome();
|
|
1655
|
+
if (!home) return false;
|
|
1656
|
+
const { [account]: _removed, ...rest } = tokens;
|
|
1657
|
+
await mkdir(home, {
|
|
1658
|
+
recursive: true,
|
|
1659
|
+
mode: 448
|
|
1660
|
+
});
|
|
1661
|
+
const path = plaintextTokensPath(home);
|
|
1662
|
+
if (Object.keys(rest).length === 0) await writeFile(path, "{}\n", { mode: 384 });
|
|
1663
|
+
else await writeFile(path, `${JSON.stringify(rest, null, 2)}\n`, { mode: 384 });
|
|
1664
|
+
await chmod(path, 384);
|
|
1665
|
+
return true;
|
|
1666
|
+
}
|
|
1504
1667
|
async function readPlaintextToken(account) {
|
|
1505
1668
|
const token = (await readPlaintextTokens())?.[account];
|
|
1506
1669
|
return typeof token === "string" && token ? token : null;
|
|
@@ -1798,15 +1961,18 @@ async function performDeviceLogin(profile, options, mode) {
|
|
|
1798
1961
|
error: code.error
|
|
1799
1962
|
};
|
|
1800
1963
|
const deadline = Date.now() + code.expires_in * 1e3;
|
|
1801
|
-
if (mode.json)
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1964
|
+
if (mode.json) {
|
|
1965
|
+
const browserOpen = await openDeviceAuthorizationUrl(code.verification_uri_complete ?? code.verification_uri);
|
|
1966
|
+
writeEvent({
|
|
1967
|
+
status: "pending",
|
|
1968
|
+
verification_uri: code.verification_uri,
|
|
1969
|
+
verification_uri_complete: code.verification_uri_complete ?? null,
|
|
1970
|
+
user_code: code.user_code,
|
|
1971
|
+
expires_at: new Date(deadline).toISOString(),
|
|
1972
|
+
interval_seconds: code.interval,
|
|
1973
|
+
browser_open: browserOpen
|
|
1974
|
+
});
|
|
1975
|
+
} else writeText([
|
|
1810
1976
|
"Open this URL in a browser to sign in:",
|
|
1811
1977
|
code.verification_uri_complete ?? code.verification_uri,
|
|
1812
1978
|
"",
|
|
@@ -1911,7 +2077,7 @@ async function pollForToken(options, code, init, profile, deadline) {
|
|
|
1911
2077
|
let intervalMs = Math.max(code.interval, 1) * 1e3;
|
|
1912
2078
|
let networkFailures = 0;
|
|
1913
2079
|
while (Date.now() < deadline) {
|
|
1914
|
-
await setTimeout(intervalMs);
|
|
2080
|
+
await setTimeout$1(intervalMs);
|
|
1915
2081
|
const response = await fetch(apiUrl("/api/auth/device/token", baseUrlOf(options)), {
|
|
1916
2082
|
method: "POST",
|
|
1917
2083
|
headers: { "content-type": "application/json" },
|
|
@@ -3529,7 +3695,11 @@ function onboardingNextSteps(signedIn) {
|
|
|
3529
3695
|
return [{
|
|
3530
3696
|
id: "login",
|
|
3531
3697
|
title: signedIn ? "Already signed in." : "Sign in so you can share files.",
|
|
3532
|
-
command: `${CLI_INVOCATION} login`,
|
|
3698
|
+
command: `${CLI_INVOCATION} login --json`,
|
|
3699
|
+
...!signedIn ? {
|
|
3700
|
+
requires_browser_approval: true,
|
|
3701
|
+
awaits_user_action: true
|
|
3702
|
+
} : {},
|
|
3533
3703
|
done: signedIn
|
|
3534
3704
|
}, {
|
|
3535
3705
|
id: "share",
|
|
@@ -3574,6 +3744,45 @@ function configData(config, resolved) {
|
|
|
3574
3744
|
};
|
|
3575
3745
|
}
|
|
3576
3746
|
//#endregion
|
|
3747
|
+
//#region src/command-runners/profile-credentials.ts
|
|
3748
|
+
async function deleteCredentialForProfileEntry(profile, rawEntry, options) {
|
|
3749
|
+
const entry = isRecord(rawEntry) ? rawEntry : {};
|
|
3750
|
+
return await deleteProfileCredential(profile, {
|
|
3751
|
+
...options,
|
|
3752
|
+
baseUrl: nonEmpty(entry.base_url) ?? "https://artifactshare.com"
|
|
3753
|
+
});
|
|
3754
|
+
}
|
|
3755
|
+
//#endregion
|
|
3756
|
+
//#region src/command-runners/logout.ts
|
|
3757
|
+
async function runLogout(parsed, mode) {
|
|
3758
|
+
const command = "logout";
|
|
3759
|
+
const explicitProfile = nonEmpty(parsed.options.profile);
|
|
3760
|
+
if (!configHome()) return writeFailure(command, tokenStoreUnavailableError(), mode, 1);
|
|
3761
|
+
const config = await readGlobalConfig() ?? {};
|
|
3762
|
+
let profile;
|
|
3763
|
+
if (explicitProfile) {
|
|
3764
|
+
if (!Object.hasOwn(config.profiles ?? {}, explicitProfile)) return writeFailure(command, profileNotFoundError(explicitProfile), mode, 1);
|
|
3765
|
+
profile = explicitProfile;
|
|
3766
|
+
} else {
|
|
3767
|
+
const defaultProfile = nonEmpty(config.default_profile);
|
|
3768
|
+
if (!defaultProfile) {
|
|
3769
|
+
const optionToken = nonEmpty(parsed.options.token);
|
|
3770
|
+
const envToken = nonEmpty(process.env.ARTIFACTSHARE_TOKEN);
|
|
3771
|
+
return writeFailure(command, validationError("No profile is selected for logout.", optionToken || envToken ? `Bearer-token-only auth has no local credential to remove. Pass --profile <name>, set a default profile with ${CLI_INVOCATION} profiles use <name>, or unset ${TOKEN_ENV_VAR} before retrying.` : `Pass --profile <name> or run ${CLI_INVOCATION} profiles use <name> first.`), mode, 1);
|
|
3772
|
+
}
|
|
3773
|
+
if (!Object.hasOwn(config.profiles ?? {}, defaultProfile)) return writeFailure(command, profileNotFoundError(defaultProfile), mode, 1);
|
|
3774
|
+
profile = defaultProfile;
|
|
3775
|
+
}
|
|
3776
|
+
const rawEntry = config.profiles?.[profile];
|
|
3777
|
+
const deleted = await deleteCredentialForProfileEntry(profile, rawEntry, parsed.options);
|
|
3778
|
+
if (!deleted.ok) return writeFailure(command, tokenStoreUnavailableError(profile), mode, 1);
|
|
3779
|
+
return writeSuccess(command, {
|
|
3780
|
+
profile,
|
|
3781
|
+
credential_removed: deleted.credential_removed,
|
|
3782
|
+
token_store: deleted.token_store
|
|
3783
|
+
}, mode);
|
|
3784
|
+
}
|
|
3785
|
+
//#endregion
|
|
3577
3786
|
//#region src/command-runners/move.ts
|
|
3578
3787
|
async function runMove(parsed, mode) {
|
|
3579
3788
|
const command = "move";
|
|
@@ -3718,6 +3927,33 @@ async function runProfilesImportToken(parsed, mode) {
|
|
|
3718
3927
|
base_url: baseUrlOf(parsed.options)
|
|
3719
3928
|
}, mode);
|
|
3720
3929
|
}
|
|
3930
|
+
async function runProfilesDelete(parsed, mode) {
|
|
3931
|
+
const command = "profiles delete";
|
|
3932
|
+
const name = nonEmpty(parsed.positionals[0]);
|
|
3933
|
+
if (!name) return writeFailure(command, validationError("A profile name is required.", `Run ${CLI_INVOCATION} profiles delete <name>.`), mode, 1);
|
|
3934
|
+
if (!configHome()) return writeFailure(command, tokenStoreUnavailableError(), mode, 1);
|
|
3935
|
+
const config = await readGlobalConfig() ?? {};
|
|
3936
|
+
if (!Object.hasOwn(config.profiles ?? {}, name)) return writeFailure(command, profileNotFoundError(name), mode, 1);
|
|
3937
|
+
const rawEntry = config.profiles?.[name];
|
|
3938
|
+
const deleted = await deleteCredentialForProfileEntry(name, rawEntry, parsed.options);
|
|
3939
|
+
if (!deleted.ok) return writeFailure(command, tokenStoreUnavailableError(name), mode, 1);
|
|
3940
|
+
const previousDefault = nonEmpty(config.default_profile) ?? null;
|
|
3941
|
+
const { [name]: _removed, ...restProfiles } = config.profiles ?? {};
|
|
3942
|
+
const defaultProfile = config.default_profile === name ? null : config.default_profile ?? null;
|
|
3943
|
+
await writeGlobalConfig({
|
|
3944
|
+
...config,
|
|
3945
|
+
default_profile: defaultProfile,
|
|
3946
|
+
profiles: restProfiles
|
|
3947
|
+
});
|
|
3948
|
+
return writeSuccess(command, {
|
|
3949
|
+
profile: name,
|
|
3950
|
+
credential_removed: deleted.credential_removed,
|
|
3951
|
+
token_store: deleted.token_store,
|
|
3952
|
+
profile_deleted: true,
|
|
3953
|
+
previous_default: previousDefault,
|
|
3954
|
+
default_profile: defaultProfile
|
|
3955
|
+
}, mode);
|
|
3956
|
+
}
|
|
3721
3957
|
//#endregion
|
|
3722
3958
|
//#region src/command-runners/projects.ts
|
|
3723
3959
|
async function fetchProjects(token, options, init, errorOptions = {}) {
|
|
@@ -4131,6 +4367,10 @@ async function loginRunner(ctx) {
|
|
|
4131
4367
|
const parsed = parsedArgsFromContext("login", ctx);
|
|
4132
4368
|
return await runLogin(parsed, outputMode(parsed.options));
|
|
4133
4369
|
}
|
|
4370
|
+
async function logoutRunner(ctx) {
|
|
4371
|
+
const parsed = parsedArgsFromContext("logout", ctx);
|
|
4372
|
+
return await runLogout(parsed, outputMode(parsed.options));
|
|
4373
|
+
}
|
|
4134
4374
|
async function updateRunner(ctx) {
|
|
4135
4375
|
const parsed = parsedArgsFromContext("update", ctx);
|
|
4136
4376
|
return await runUpdate(parsed, outputMode(parsed.options));
|
|
@@ -4212,6 +4452,10 @@ async function profilesImportTokenRunner(ctx) {
|
|
|
4212
4452
|
if (hasOptionToken(ctx, "token")) parsed.options.token = "<redacted>";
|
|
4213
4453
|
return await runProfilesImportToken(parsed, outputMode(parsed.options));
|
|
4214
4454
|
}
|
|
4455
|
+
async function profilesDeleteRunner(ctx) {
|
|
4456
|
+
const parsed = parsedArgsFromContext("profiles delete", ctx);
|
|
4457
|
+
return await runProfilesDelete(parsed, outputMode(parsed.options));
|
|
4458
|
+
}
|
|
4215
4459
|
async function projectsListRunner(ctx) {
|
|
4216
4460
|
const parsed = parsedArgsFromContext("projects list", ctx);
|
|
4217
4461
|
return await runProjectsList(parsed, outputMode(parsed.options));
|
|
@@ -4299,6 +4543,7 @@ async function runGunshi(argv) {
|
|
|
4299
4543
|
version: await loadCliVersion(),
|
|
4300
4544
|
subCommands: {
|
|
4301
4545
|
login: lazyCommand(loginDefinition, loginRunner),
|
|
4546
|
+
logout: lazyCommand(logoutDefinition, logoutRunner),
|
|
4302
4547
|
share: lazyCommand(shareDefinition, shareRunner),
|
|
4303
4548
|
open: lazyCommand(openDefinition, openRunner),
|
|
4304
4549
|
update: lazyCommand(updateDefinition, updateRunner),
|
|
@@ -4378,6 +4623,7 @@ npx --yes @artifactshare/cli comments list <artifact-id-or-url> --json
|
|
|
4378
4623
|
npx --yes @artifactshare/cli comments post <artifact-id-or-url> --body "<text>" --json
|
|
4379
4624
|
${agentDownloadCommand("<artifact-id-or-url>")}
|
|
4380
4625
|
npx --yes @artifactshare/cli login --profile default
|
|
4626
|
+
npx --yes @artifactshare/cli logout --profile default --json
|
|
4381
4627
|
npx --yes @artifactshare/cli profiles list --json
|
|
4382
4628
|
npx --yes @artifactshare/cli profiles use <name> --json
|
|
4383
4629
|
npx --yes @artifactshare/cli projects list --json
|
|
@@ -4417,6 +4663,22 @@ Common failures:
|
|
|
4417
4663
|
auth_expired The device code expired before approval
|
|
4418
4664
|
token_store_unavailable Configure an OS credential store or use the explicit plaintext fallback`
|
|
4419
4665
|
});
|
|
4666
|
+
const logoutDefinition = define({
|
|
4667
|
+
name: "logout",
|
|
4668
|
+
description: "Remove the saved credential for a CLI profile.",
|
|
4669
|
+
toKebab: true,
|
|
4670
|
+
args: commonArgs,
|
|
4671
|
+
examples: `npx --yes @artifactshare/cli logout --profile client-a --json
|
|
4672
|
+
npx --yes @artifactshare/cli logout --json
|
|
4673
|
+
|
|
4674
|
+
logout removes the local credential only. Profile metadata stays in config.json for re-login hints.
|
|
4675
|
+
When no --profile is passed, the global default profile is used.
|
|
4676
|
+
|
|
4677
|
+
Common failures:
|
|
4678
|
+
validation_failed Pass --profile or set a default profile; bearer-token-only auth has nothing to remove
|
|
4679
|
+
profile_not_found Run profiles list to see saved profiles
|
|
4680
|
+
token_store_unavailable Configure an OS credential store or use the explicit plaintext fallback`
|
|
4681
|
+
});
|
|
4420
4682
|
const shareDefinition = define({
|
|
4421
4683
|
name: "share",
|
|
4422
4684
|
description: "Share a file or directory.",
|
|
@@ -5021,6 +5283,20 @@ Common failures:
|
|
|
5021
5283
|
auth_account_mismatch The token belongs to a different account than the saved profile email
|
|
5022
5284
|
token_store_unavailable Configure an OS credential store or use the explicit plaintext fallback`
|
|
5023
5285
|
});
|
|
5286
|
+
const profilesDeleteDefinition = define({
|
|
5287
|
+
name: "delete",
|
|
5288
|
+
description: "Delete a saved CLI profile and its credential.",
|
|
5289
|
+
toKebab: true,
|
|
5290
|
+
args: commonArgs,
|
|
5291
|
+
examples: `npx --yes @artifactshare/cli profiles delete client-a --json
|
|
5292
|
+
|
|
5293
|
+
Removes the profile from config.json and clears its saved credential.
|
|
5294
|
+
If the deleted profile was the default, default_profile becomes null.
|
|
5295
|
+
|
|
5296
|
+
Common failures:
|
|
5297
|
+
profile_not_found Run profiles list to see saved profiles
|
|
5298
|
+
token_store_unavailable Credential removal failed; the profile entry is kept`
|
|
5299
|
+
});
|
|
5024
5300
|
const profilesDefinition = define({
|
|
5025
5301
|
name: "profiles",
|
|
5026
5302
|
description: "Manage saved CLI profiles.",
|
|
@@ -5029,11 +5305,13 @@ const profilesDefinition = define({
|
|
|
5029
5305
|
subCommands: {
|
|
5030
5306
|
list: lazyCommand(profilesListDefinition, profilesListRunner),
|
|
5031
5307
|
use: lazyCommand(profilesUseDefinition, profilesUseRunner),
|
|
5032
|
-
"import-token": lazyCommand(profilesImportTokenDefinition, profilesImportTokenRunner)
|
|
5308
|
+
"import-token": lazyCommand(profilesImportTokenDefinition, profilesImportTokenRunner),
|
|
5309
|
+
delete: lazyCommand(profilesDeleteDefinition, profilesDeleteRunner)
|
|
5033
5310
|
},
|
|
5034
5311
|
examples: `npx --yes @artifactshare/cli profiles list --json
|
|
5035
5312
|
npx --yes @artifactshare/cli profiles use client-a --json
|
|
5036
|
-
printf '%s' "$TOKEN" | npx --yes @artifactshare/cli profiles import-token --profile client-a --json
|
|
5313
|
+
printf '%s' "$TOKEN" | npx --yes @artifactshare/cli profiles import-token --profile client-a --json
|
|
5314
|
+
npx --yes @artifactshare/cli profiles delete client-a --json`,
|
|
5037
5315
|
run: parentCommandRunner("profiles")
|
|
5038
5316
|
});
|
|
5039
5317
|
const projectsListDefinition = define({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artifactshare/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Upload and share HTML, Markdown, folders, and static sites from terminals, AI agents, automation, and CI.",
|
|
5
5
|
"homepage": "https://artifactshare.com/connect",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -4,7 +4,7 @@ description: Open, share, update, and read back shared files with the Artifact S
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<!-- artifactshare-skill
|
|
7
|
-
version:
|
|
7
|
+
version: 20
|
|
8
8
|
managed: true
|
|
9
9
|
-->
|
|
10
10
|
|
|
@@ -42,15 +42,20 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
|
|
|
42
42
|
| Create a project | `projects create 'Name' --json` |
|
|
43
43
|
| Find an ID from a title | `resolve <value> --json` |
|
|
44
44
|
| Open a share URL | `open <url> --json` |
|
|
45
|
+
| Log out locally | `logout --profile <name> --json` |
|
|
45
46
|
|
|
46
47
|
## Authentication
|
|
47
48
|
|
|
48
49
|
- In non-interactive environments (agents, CI, scripts), ask the user to issue
|
|
49
50
|
an API token at `https://artifactshare.com/settings/tokens`, then use
|
|
50
51
|
`ARTIFACTSHARE_TOKEN` or `--token` for normal commands.
|
|
51
|
-
- `login --profile <name
|
|
52
|
-
|
|
52
|
+
- `login --profile <name> --json` starts device login and may open the OS
|
|
53
|
+
browser for approval. Use it when a user is present; the pending event on
|
|
54
|
+
stderr includes `browser_open`. Do not pass API tokens to `login`.
|
|
53
55
|
Profiles created by `login` renew expired CLI sessions automatically.
|
|
56
|
+
- `logout --profile <name> --json` removes the saved local credential for a
|
|
57
|
+
profile and leaves profile metadata in `config.json`. Without `--profile`,
|
|
58
|
+
it uses the default profile. This does not revoke API tokens on the server.
|
|
54
59
|
- To keep using an issued token as a named profile without TTY or browser
|
|
55
60
|
login, pipe it on standard input:
|
|
56
61
|
`printf '%s' "$TOKEN" | npx --yes @artifactshare/cli profiles import-token --profile <name> --json`.
|
|
@@ -194,10 +199,13 @@ npx --yes @artifactshare/cli projects edit <id> --archive --json
|
|
|
194
199
|
```bash
|
|
195
200
|
npx --yes @artifactshare/cli profiles list --json
|
|
196
201
|
npx --yes @artifactshare/cli profiles use <name> --json
|
|
202
|
+
npx --yes @artifactshare/cli profiles delete <name> --json
|
|
197
203
|
```
|
|
198
204
|
|
|
199
205
|
- `profiles list` shows saved profiles and the default.
|
|
200
206
|
- `profiles use` switches the default profile.
|
|
207
|
+
- `profiles delete` removes the profile entry and its saved credential. Use
|
|
208
|
+
`logout --profile <name>` when you only want to remove the credential.
|
|
201
209
|
- To create a profile, use `login --profile <name>` (interactive) or
|
|
202
210
|
`profiles import-token` (non-interactive, see Authentication).
|
|
203
211
|
|
|
@@ -4,7 +4,7 @@ alwaysApply: false
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<!-- artifactshare-skill
|
|
7
|
-
version:
|
|
7
|
+
version: 20
|
|
8
8
|
managed: true
|
|
9
9
|
-->
|
|
10
10
|
|
|
@@ -26,8 +26,9 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
|
|
|
26
26
|
- Always pass `--json`; on failure read `error.code`, `error.hint`, and `error.recovery`.
|
|
27
27
|
- In agents, CI, or scripts, ask the user to issue an API token at `https://artifactshare.com/settings/tokens`, then run normal commands with `ARTIFACTSHARE_TOKEN` or `--token`; do not pass API tokens to `login`.
|
|
28
28
|
- To save that token as a named profile without TTY or browser login, pipe it on standard input: `printf '%s' "$TOKEN" | npx --yes @artifactshare/cli profiles import-token --profile <name> --json`. Imported API-token profiles are not renewed by the CLI. Add `--allow-plaintext-token-store` only on a trusted machine without a native token store.
|
|
29
|
-
- Use `login --profile <name
|
|
30
|
-
-
|
|
29
|
+
- Use `login --profile <name> --json` when a user is present for browser approval. The pending event on stderr includes `browser_open`. Profiles created by `login` renew expired CLI sessions automatically.
|
|
30
|
+
- Remove a saved local credential with `logout --profile <name> --json`; this keeps profile metadata and does not revoke API tokens on the server.
|
|
31
|
+
- Switch profiles with `profiles use <name> --json`; list with `profiles list --json`; remove a profile entry and its credential with `profiles delete <name> --json`.
|
|
31
32
|
- When the user gives an Artifact Share URL, start with `open <artifact-id-or-url> --json`. It ensures this rule is installed or updated, then reads single-file artifacts or returns a `download` next command for static sites and multi-file artifacts.
|
|
32
33
|
- Share with `share <path> --json`. Pick the destination with `--project-id <id>`, `--project <name>` (by exact name), the saved default, or `--home`. Set visibility with `--visibility private|workspace|project`; when `--grant-email` is passed the default becomes `private`.
|
|
33
34
|
- For repeat jobs with a stable caller-owned name, use `share <path> --key <key> --json`: the first run creates the artifact, later runs add versions to the same artifact.
|
|
@@ -44,4 +45,4 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
|
|
|
44
45
|
- Manage skills: `skills ensure --tool auto --json` detects the agent and installs or reports updates; `skills update --json` updates installed skills to the bundled version; `skills install --tool <name> --scope user --json` installs at the user level (`--force` overwrites unmanaged files).
|
|
45
46
|
- On `upload_not_allowed`, run `request-access --note '<why>' --json` and tell the user an operator opens sharing; do not retry in a loop.
|
|
46
47
|
- Check the current state with `whoami --json` or `doctor --json` for authentication, destination, network, upload access, and skill update status.
|
|
47
|
-
- First-time setup: `npx --yes @artifactshare/cli init` detects the agent, installs or updates this rule, and reports the next steps (sign in, then share).
|
|
48
|
+
- First-time setup: `npx --yes @artifactshare/cli init --json` detects the agent, installs or updates this rule, and reports the next steps (sign in, then share).
|