@artifactshare/cli 0.6.1 → 0.7.1

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 CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to `@artifactshare/cli` are documented here.
4
4
  For user-facing announcements, see https://artifactshare.com/updates?product=cli.
5
5
 
6
+ ## 0.7.1 - 2026-07-14
7
+
8
+ - Rework `home_audience` guidance in command help and the bundled skill: purpose-based examples for user and repository scopes, the `--visibility` one-time override, and checking the resolved audience with `--scope effective`.
9
+
10
+ ## 0.7.0 - 2026-07-13
11
+
12
+ - Share without a destination now posts to home, so agents and automation have a predictable first destination.
13
+ - Configure `home_audience` for a user or repository to choose whether home posts are private or visible to the workspace.
14
+ - Repository settings take precedence over user settings, giving teams a shared default while preserving a personal fallback.
15
+
6
16
  ## 0.6.1 - 2026-07-12
7
17
 
8
18
  - Fix `--insecure-localhost` failing every command with `network_failed` on Node 22/24 by routing all CLI HTTP requests through undici's own fetch
package/README.md CHANGED
@@ -26,6 +26,8 @@ npx --yes @artifactshare/cli edit <artifact-id-or-url> --visibility private --gr
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
28
  npx --yes @artifactshare/cli logout --profile default --json
29
+ npx --yes @artifactshare/cli config set home_audience private --scope user --json
30
+ npx --yes @artifactshare/cli config get home_audience --scope effective --json
29
31
  ```
30
32
 
31
33
  To keep an existing share URL, update it with
@@ -63,6 +65,25 @@ runs add versions to the same file.
63
65
  | `init` | Set up this directory: detect Claude Code, Codex, or Cursor and install the skill in user scope, then show next steps; or save defaults with `--profile` / `--project-id` |
64
66
  | `skills ensure / install / list / update / remove` | Install or update the bundled usage guide in your AI agent's skills |
65
67
 
68
+ Public command paths covered by this reference:
69
+
70
+ `artifacts`, `artifacts get`, `artifacts list`, `changelog`, `comments`, `comments delete`, `comments edit`, `comments list`, `comments post`, `comments reopen`, `comments resolve`, `config`, `config get`, `config set`, `config unset`, `delete`, `doctor`, `download`, `edit`, `init`, `login`, `logout`, `move`, `open`, `profiles`, `profiles delete`, `profiles import-token`, `profiles list`, `profiles use`, `projects`, `projects create`, `projects edit`, `projects list`, `request-access`, `resolve`, `share`, `skills`, `skills ensure`, `skills install`, `skills list`, `skills remove`, `skills update`, `update`, `whoami`.
71
+
72
+ ## Where shared files are delivered
73
+
74
+ Posting to a project delivers to the audience defined by that project. With no destination, `share` posts to home. Choose the home audience by purpose:
75
+
76
+ ```sh
77
+ npx --yes @artifactshare/cli config set home_audience private --scope user --json
78
+ npx --yes @artifactshare/cli config set home_audience workspace --scope repository --json
79
+ npx --yes @artifactshare/cli share ./report.html --visibility private --json
80
+ npx --yes @artifactshare/cli config get home_audience --scope effective --json
81
+ ```
82
+
83
+ Use `--scope repository` only for a policy agreed by all repository participants, and pass `--visibility private|workspace` for a one-time home override. For project creation, pass `projects create <name> --visibility private|workspace`; persistent project defaults are documented in `projects create --help`.
84
+
85
+ For the complete settings reference, `home_audience` is the canonical home key. `default_artifact_visibility` remains a compatibility alias, and `default_project_visibility` is the advanced default for `projects create`. User and repository settings are resolved with repository taking precedence, followed by user and product default `workspace`; home also checks the compatibility alias at each scope. Use `config get home_audience --scope effective --json` to confirm the resolved audience. Keyless `config get --json` returns only `home_audience`; pass an explicit key to read either other setting. These settings only affect new home posts and project creation; update, edit, Web, and MCP defaults are unchanged.
86
+
66
87
  ## For AI agents
67
88
 
68
89
  For first-time setup in a project, start here:
package/dist/index.js CHANGED
@@ -88,7 +88,8 @@ const COMMAND_NAMES = /* @__PURE__ */ new Set([
88
88
  "projects",
89
89
  "skills",
90
90
  "init",
91
- "changelog"
91
+ "changelog",
92
+ "config"
92
93
  ]);
93
94
  const SUBCOMMANDS = {
94
95
  artifacts: ["list", "get"],
@@ -117,6 +118,11 @@ const SUBCOMMANDS = {
117
118
  "update",
118
119
  "remove",
119
120
  "ensure"
121
+ ],
122
+ config: [
123
+ "get",
124
+ "set",
125
+ "unset"
120
126
  ]
121
127
  };
122
128
  const UPDATE_OPTION_KEYS = /* @__PURE__ */ new Set([
@@ -186,11 +192,11 @@ function mapApiError(status, body, options = {}) {
186
192
  recovery: { kind: "ask_human" },
187
193
  details: { limit: "self_upload" }
188
194
  });
189
- if (apiCode === "upload-suspended") return cliError({
190
- code: "upload_suspended",
191
- message: apiMessage ?? "Your upload permission is suspended.",
192
- why: "Artifact Share suspended upload access for this account.",
193
- hint: "Ask an operator to restore upload access, then retry share.",
195
+ if (apiCode === "workspace-access-revoked") return cliError({
196
+ code: "workspace_access_revoked",
197
+ message: apiMessage ?? "Your access to this workspace has been revoked.",
198
+ why: "Artifact Share revoked this account’s workspace membership.",
199
+ hint: "Ask a workspace administrator to restore membership, then retry share.",
194
200
  agentRecoverable: false,
195
201
  requiresHuman: true,
196
202
  recovery: { kind: "ask_human" }
@@ -1442,15 +1448,7 @@ function resolveDestination(options, config) {
1442
1448
  if (options.home) return { containerId: null };
1443
1449
  const containerId = options.projectId ?? config?.default_project_id ?? null;
1444
1450
  if (containerId) return { containerId };
1445
- return { error: cliError({
1446
- code: "destination_required",
1447
- message: "A share destination is required.",
1448
- why: "Non-interactive share never guesses a project or home destination.",
1449
- hint: "Retry with --project-id <id>, configure .artifactshare/config.local.json, or pass --home.",
1450
- agentRecoverable: true,
1451
- requiresHuman: false,
1452
- recovery: { kind: "change_input" }
1453
- }) };
1451
+ return { containerId: null };
1454
1452
  }
1455
1453
  const PROJECT_CONFIG_PATH = ".artifactshare/config.json";
1456
1454
  const PROJECT_CONFIG_LOCAL_PATH = ".artifactshare/config.local.json";
@@ -1495,6 +1493,154 @@ async function resolveProjectConfig(cwd = process.cwd()) {
1495
1493
  directory: null
1496
1494
  };
1497
1495
  }
1496
+ async function resolveSharedProjectConfig(cwd = process.cwd()) {
1497
+ let current = resolve(cwd);
1498
+ const root = resolve(current, "/");
1499
+ while (true) {
1500
+ const path = join(current, PROJECT_CONFIG_PATH);
1501
+ try {
1502
+ const text = await readFile(path, "utf8");
1503
+ let parsed;
1504
+ try {
1505
+ parsed = JSON.parse(text);
1506
+ } catch {
1507
+ return invalidProjectConfigResolution(path, "Repository config contains invalid JSON.");
1508
+ }
1509
+ if (!isRecord(parsed)) return invalidProjectConfigResolution(path, "Repository config must contain a JSON object.");
1510
+ return {
1511
+ config: parsed,
1512
+ raw: parsed,
1513
+ kind: "shared",
1514
+ path: relativeProjectConfigPath(cwd, current, PROJECT_CONFIG_PATH),
1515
+ directory: current
1516
+ };
1517
+ } catch (error) {
1518
+ if (error.code !== "ENOENT") return invalidProjectConfigResolution(path, "Repository config could not be read.");
1519
+ }
1520
+ if (current === root) break;
1521
+ current = dirname(current);
1522
+ }
1523
+ return {
1524
+ config: null,
1525
+ raw: null,
1526
+ kind: null,
1527
+ path: null,
1528
+ directory: null
1529
+ };
1530
+ }
1531
+ function invalidProjectConfigResolution(path, message) {
1532
+ return {
1533
+ config: null,
1534
+ raw: null,
1535
+ kind: null,
1536
+ path,
1537
+ directory: dirname(path),
1538
+ error: validationError(message, `Fix or restore access to ${path} before resolving visibility settings.`)
1539
+ };
1540
+ }
1541
+ function resolveVisibility(explicitValue, repositoryValue, userValue) {
1542
+ const candidates = [
1543
+ {
1544
+ value: explicitValue,
1545
+ source: "explicit"
1546
+ },
1547
+ {
1548
+ value: repositoryValue,
1549
+ source: "repository"
1550
+ },
1551
+ {
1552
+ value: userValue,
1553
+ source: "user"
1554
+ }
1555
+ ];
1556
+ for (const candidate of candidates) {
1557
+ if (candidate.value === void 0) continue;
1558
+ if (candidate.value === "workspace" || candidate.value === "private") return {
1559
+ value: candidate.value,
1560
+ source: candidate.source
1561
+ };
1562
+ return { invalid: candidate.source };
1563
+ }
1564
+ return {
1565
+ value: "workspace",
1566
+ source: "product_default"
1567
+ };
1568
+ }
1569
+ function resolveHomeVisibility(explicitValue, repositoryHomeValue, repositoryLegacyValue, userHomeValue, userLegacyValue) {
1570
+ const candidates = [
1571
+ {
1572
+ value: explicitValue,
1573
+ source: "explicit"
1574
+ },
1575
+ {
1576
+ value: repositoryHomeValue,
1577
+ source: "repository"
1578
+ },
1579
+ {
1580
+ value: repositoryLegacyValue,
1581
+ source: "repository"
1582
+ },
1583
+ {
1584
+ value: userHomeValue,
1585
+ source: "user"
1586
+ },
1587
+ {
1588
+ value: userLegacyValue,
1589
+ source: "user"
1590
+ }
1591
+ ];
1592
+ for (const candidate of candidates) {
1593
+ if (candidate.value === void 0) continue;
1594
+ if (candidate.value === "workspace" || candidate.value === "private") return {
1595
+ value: candidate.value,
1596
+ source: candidate.source
1597
+ };
1598
+ return { invalid: candidate.source };
1599
+ }
1600
+ return {
1601
+ value: "workspace",
1602
+ source: "product_default"
1603
+ };
1604
+ }
1605
+ async function resolveDefaultVisibility(key, repositoryConfig) {
1606
+ const shared = repositoryConfig ?? await resolveSharedProjectConfig();
1607
+ if (shared.error) return { error: shared.error };
1608
+ const homeKey = key === "home_audience" || key === "default_artifact_visibility";
1609
+ const repositoryValue = homeKey ? shared.config?.home_audience : shared.config?.[key];
1610
+ const repositoryLegacyValue = homeKey ? shared.config?.default_artifact_visibility : void 0;
1611
+ if (homeKey && repositoryValue === void 0) {
1612
+ if (repositoryLegacyValue !== void 0) {
1613
+ const resolution = resolveHomeVisibility(void 0, void 0, repositoryLegacyValue, void 0, void 0);
1614
+ if (!("invalid" in resolution)) return resolution;
1615
+ return { error: validationError("Repository home_audience must be workspace or private.", "Fix the repository config before resolving visibility settings.") };
1616
+ }
1617
+ } else if (repositoryValue !== void 0) {
1618
+ const resolution = homeKey ? resolveHomeVisibility(void 0, repositoryValue, repositoryLegacyValue, void 0, void 0) : resolveVisibility(void 0, repositoryValue, void 0);
1619
+ if (!("invalid" in resolution)) return resolution;
1620
+ return { error: validationError(`Repository ${key} must be workspace or private.`, "Fix the repository config before resolving visibility settings.") };
1621
+ }
1622
+ const home = configHome();
1623
+ let global = null;
1624
+ if (home) {
1625
+ const path = join(home, "config.json");
1626
+ try {
1627
+ const text = await readFile(path, "utf8");
1628
+ let parsed;
1629
+ try {
1630
+ parsed = JSON.parse(text);
1631
+ } catch {
1632
+ return { error: validationError("User config contains invalid JSON.", `Fix ${path} before resolving visibility settings.`) };
1633
+ }
1634
+ if (!isRecord(parsed)) return { error: validationError("User config must contain a JSON object.", `Fix ${path} before resolving visibility settings.`) };
1635
+ global = parsed;
1636
+ } catch (error) {
1637
+ if (error.code !== "ENOENT") return { error: validationError("User config could not be read.", `Check access to ${path} before resolving visibility settings.`) };
1638
+ }
1639
+ } else global = await readGlobalConfig();
1640
+ const resolution = homeKey ? resolveHomeVisibility(void 0, void 0, void 0, global?.home_audience, global?.default_artifact_visibility) : resolveVisibility(void 0, void 0, global?.[key]);
1641
+ if (!("invalid" in resolution)) return resolution;
1642
+ return { error: validationError(`User ${homeKey ? "home_audience" : key} must be workspace or private.`, "Fix the user config before resolving visibility settings.") };
1643
+ }
1498
1644
  async function readProjectConfigAtDirectory(directory, kind) {
1499
1645
  return await readJsonFile(join(directory, kind === "local" ? PROJECT_CONFIG_LOCAL_PATH : PROJECT_CONFIG_PATH));
1500
1646
  }
@@ -4283,6 +4429,8 @@ async function runProjectsCreate(parsed, mode) {
4283
4429
  const visibility = parsed.options.visibility;
4284
4430
  if (visibility !== void 0 && visibility !== "workspace" && visibility !== "private") return writeFailure(command, validationError("--visibility must be workspace or private.", "Retry with --visibility workspace or --visibility private."), mode, 1);
4285
4431
  const projectConfig = await resolveProjectConfig();
4432
+ const defaultVisibility = visibility ? null : await resolveDefaultVisibility("default_project_visibility", await resolveSharedProjectConfig());
4433
+ if (defaultVisibility && "error" in defaultVisibility) return writeFailure(command, defaultVisibility.error, mode, 1);
4286
4434
  const credential = await resolveCredential(parsed.options, projectConfig);
4287
4435
  if (!credential.ok) return writeFailure(command, credential.error, mode, 1);
4288
4436
  const request = await requestConfig(parsed.options);
@@ -4291,7 +4439,7 @@ async function runProjectsCreate(parsed, mode) {
4291
4439
  const created = await apiPost("/api/cli/projects", current.token, {
4292
4440
  name,
4293
4441
  description: parsed.options.description ?? null,
4294
- base_visibility: visibility ?? null
4442
+ base_visibility: visibility ?? defaultVisibility.value
4295
4443
  }, parsed.options, request.init, {
4296
4444
  credentialSource: current.source,
4297
4445
  profile: current.profile,
@@ -4453,7 +4601,9 @@ async function runShare(parsed, mode, isRetry = false) {
4453
4601
  if (destination.error) return writeFailure(command, destination.error, mode, 1);
4454
4602
  const initialForm = await createUploadForm();
4455
4603
  const grantEmails = arrayOption(parsed.options.grantEmail);
4456
- const requestedVisibility = parsed.options.visibility ?? (destination.containerId && grantEmails.length === 0 ? "project" : "private");
4604
+ const defaultVisibility = parsed.options.visibility || destination.containerId ? null : await resolveDefaultVisibility("home_audience", await resolveSharedProjectConfig());
4605
+ if (defaultVisibility && "error" in defaultVisibility) return writeFailure(command, defaultVisibility.error, mode, 1);
4606
+ const requestedVisibility = parsed.options.visibility ?? (destination.containerId ? "project" : defaultVisibility.value);
4457
4607
  initialForm.set("visibility", requestedVisibility);
4458
4608
  for (const email of grantEmails) initialForm.append("grant_email", email);
4459
4609
  if (destination.containerId) initialForm.set("container_id", destination.containerId);
@@ -4655,6 +4805,209 @@ async function runWhoami(parsed, mode) {
4655
4805
  } : { credential_source: credential.source }, mode);
4656
4806
  }
4657
4807
  //#endregion
4808
+ //#region src/command-runners/config.ts
4809
+ const KEYS = ["home_audience", "default_project_visibility"];
4810
+ const ACCEPTED_KEYS = [
4811
+ "home_audience",
4812
+ "default_artifact_visibility",
4813
+ "default_project_visibility"
4814
+ ];
4815
+ const SCOPES = ["user", "repository"];
4816
+ function keyOf(value) {
4817
+ if (value === "default_artifact_visibility") return value;
4818
+ return KEYS.includes(value) ? value : null;
4819
+ }
4820
+ function isHomeKey(key) {
4821
+ return key === "home_audience" || key === "default_artifact_visibility";
4822
+ }
4823
+ function logicalValue(config, key) {
4824
+ if (isHomeKey(key)) return Object.hasOwn(config, "home_audience") ? config.home_audience : config.default_artifact_visibility;
4825
+ return config[key];
4826
+ }
4827
+ function withConfigValue(config, key, value) {
4828
+ const next = { ...config };
4829
+ if (isHomeKey(key)) {
4830
+ delete next.default_artifact_visibility;
4831
+ if (value === null) delete next.home_audience;
4832
+ else next.home_audience = value;
4833
+ } else if (value === null) delete next[key];
4834
+ else next[key] = value;
4835
+ return next;
4836
+ }
4837
+ function scopeOf(value) {
4838
+ return SCOPES.includes(value) ? value : null;
4839
+ }
4840
+ function invalid(message, hint) {
4841
+ return validationError(message, hint, "validation_failed");
4842
+ }
4843
+ function invalidConfiguredValue(scope, key, value) {
4844
+ if (value === void 0 || value === "workspace" || value === "private") return null;
4845
+ return invalid(`${scope === "repository" ? "Repository" : "User"} ${isHomeKey(key) ? "home_audience" : key} must be workspace or private.`, `Fix the ${scope} config before using this setting.`);
4846
+ }
4847
+ function selectedKeys(positionals) {
4848
+ if (positionals.length === 0) return ["home_audience"];
4849
+ const key = keyOf(positionals[0]);
4850
+ return key && positionals.length === 1 ? [key] : null;
4851
+ }
4852
+ async function readUserConfig() {
4853
+ const home = configHome();
4854
+ if (!home) return { config: {} };
4855
+ const path = join(home, "config.json");
4856
+ try {
4857
+ const text = await readFile(path, "utf8");
4858
+ let parsed;
4859
+ try {
4860
+ parsed = JSON.parse(text);
4861
+ } catch {
4862
+ return { error: invalid("User config contains invalid JSON.", `Fix ${path} before reading user settings.`) };
4863
+ }
4864
+ if (!isRecord(parsed)) return { error: invalid("User config must contain a JSON object.", `Fix ${path} before reading user settings.`) };
4865
+ return { config: parsed };
4866
+ } catch (error) {
4867
+ if (error.code === "ENOENT") return { config: {} };
4868
+ return { error: invalid("User config could not be read.", `Check access to ${path} before reading user settings.`) };
4869
+ }
4870
+ }
4871
+ async function runConfigGet(parsed, mode) {
4872
+ const command = "config get";
4873
+ const keys = selectedKeys(parsed.positionals);
4874
+ if (!keys) return writeFailure(command, invalid("Unknown config key.", `Use one of: ${ACCEPTED_KEYS.join(", ")}.`), mode, 1);
4875
+ const scope = parsed.options.scope;
4876
+ if (scope !== void 0 && ![
4877
+ "user",
4878
+ "repository",
4879
+ "effective"
4880
+ ].includes(scope)) return writeFailure(command, invalid("Scope must be user, repository, or effective.", "Pass --scope user, --scope repository, or --scope effective."), mode, 1);
4881
+ const effective = scope === void 0 || scope === "effective";
4882
+ const shared = await resolveSharedProjectConfig();
4883
+ if (scope === "repository" && shared.error) return writeFailure(command, shared.error, mode, 1);
4884
+ const user = scope === "user" ? await readUserConfig() : { config: {} };
4885
+ if ("error" in user) return writeFailure(command, user.error, mode, 1);
4886
+ const data = {};
4887
+ for (const key of keys) if (effective) {
4888
+ const item = await resolveDefaultVisibility(key, shared);
4889
+ if ("error" in item) return writeFailure(command, item.error, mode, 1);
4890
+ data[key] = item;
4891
+ } else {
4892
+ const scoped = scope === "repository" ? "repository" : "user";
4893
+ const raw = scoped === "repository" ? logicalValue(shared.config ?? {}, key) : logicalValue(user.config, key);
4894
+ const valueError = invalidConfiguredValue(scoped, key, raw);
4895
+ if (valueError) return writeFailure(command, valueError, mode, 1);
4896
+ data[key] = {
4897
+ value: raw === "workspace" || raw === "private" ? raw : null,
4898
+ source: scoped
4899
+ };
4900
+ }
4901
+ return writeSuccess(command, data, mode);
4902
+ }
4903
+ async function writeRepository(key, value) {
4904
+ let directory = resolve(process.cwd());
4905
+ const root = resolve(directory, "/");
4906
+ let path = join(directory, PROJECT_CONFIG_PATH);
4907
+ let current = {};
4908
+ while (true) {
4909
+ path = join(directory, PROJECT_CONFIG_PATH);
4910
+ try {
4911
+ const text = await readFile(path, "utf8");
4912
+ let parsed;
4913
+ try {
4914
+ parsed = JSON.parse(text);
4915
+ } catch {
4916
+ return { error: invalid("Repository config contains invalid JSON.", `Fix ${path} before changing repository settings.`) };
4917
+ }
4918
+ if (!isRecord(parsed)) return { error: invalid("Repository config must contain a JSON object.", `Fix ${path} before changing repository settings.`) };
4919
+ current = parsed;
4920
+ break;
4921
+ } catch (error) {
4922
+ if (error.code !== "ENOENT") return { error: invalid("Repository config could not be read.", `Check access to ${path} before changing repository settings.`) };
4923
+ }
4924
+ if (directory === root) {
4925
+ directory = resolve(process.cwd());
4926
+ path = join(directory, PROJECT_CONFIG_PATH);
4927
+ break;
4928
+ }
4929
+ directory = dirname(directory);
4930
+ }
4931
+ const next = withConfigValue(current, key, value);
4932
+ try {
4933
+ await mkdir(dirname(path), { recursive: true });
4934
+ await writeFile(path, `${JSON.stringify(next, null, 2)}\n`);
4935
+ } catch {
4936
+ return { error: invalid("Repository config could not be written.", `Check access to ${path} before changing repository settings.`) };
4937
+ }
4938
+ return { path };
4939
+ }
4940
+ async function writeConfig(scope, key, value) {
4941
+ if (scope === "repository") return writeRepository(key, value);
4942
+ const home = configHome();
4943
+ if (!home) return { path: null };
4944
+ const path = join(home, "config.json");
4945
+ let current = {};
4946
+ try {
4947
+ const text = await readFile(path, "utf8");
4948
+ let parsed;
4949
+ try {
4950
+ parsed = JSON.parse(text);
4951
+ } catch {
4952
+ return { error: invalid("User config contains invalid JSON.", `Fix ${path} before changing user settings.`) };
4953
+ }
4954
+ if (!isRecord(parsed)) return { error: invalid("User config must contain a JSON object.", `Fix ${path} before changing user settings.`) };
4955
+ current = parsed;
4956
+ } catch (error) {
4957
+ if (error.code !== "ENOENT") return { error: invalid("User config could not be read.", `Check access to ${path} before changing user settings.`) };
4958
+ }
4959
+ const next = withConfigValue(current, key, value);
4960
+ try {
4961
+ if (!await writeGlobalConfig(next)) return { path: null };
4962
+ } catch {
4963
+ return { error: invalid("User config could not be written.", `Check access to ${path} before changing user settings.`) };
4964
+ }
4965
+ return { path };
4966
+ }
4967
+ async function runMutation(parsed, mode, unset) {
4968
+ const command = unset ? "config unset" : "config set";
4969
+ const key = keyOf(parsed.positionals[0]);
4970
+ const value = parsed.positionals[1];
4971
+ const scope = scopeOf(parsed.options.scope);
4972
+ if (!key) return writeFailure(command, invalid("Unknown config key.", `Use one of: ${ACCEPTED_KEYS.join(", ")}.`), mode, 1);
4973
+ if (!scope) return writeFailure(command, invalid("--scope is required and must be user or repository.", "Pass --scope user or --scope repository."), mode, 1);
4974
+ if (unset ? parsed.positionals.length !== 1 : parsed.positionals.length !== 2) return writeFailure(command, invalid(unset ? "A single config key is required." : "A config key and value are required.", `Use ${command} <key>${unset ? "" : " <workspace|private>"} --scope ${scope}.`), mode, 1);
4975
+ if (!unset && value !== "workspace" && value !== "private") return writeFailure(command, invalid("Config value must be workspace or private.", "Use workspace or private."), mode, 1);
4976
+ const shared = await resolveSharedProjectConfig();
4977
+ if (shared.error) return writeFailure(command, shared.error, mode, 1);
4978
+ const user = scope === "repository" && !unset ? { config: {} } : await readUserConfig();
4979
+ if ("error" in user) return writeFailure(command, user.error, mode, 1);
4980
+ if (scope !== "repository") {
4981
+ const repositoryValueError = invalidConfiguredValue("repository", key, logicalValue(shared.config ?? {}, key));
4982
+ if (repositoryValueError) return writeFailure(command, repositoryValueError, mode, 1);
4983
+ }
4984
+ if (scope === "repository" && unset) {
4985
+ const userValueError = invalidConfiguredValue("user", key, logicalValue(user.config, key));
4986
+ if (userValueError) return writeFailure(command, userValueError, mode, 1);
4987
+ }
4988
+ const writtenValue = unset ? null : value;
4989
+ const written = await writeConfig(scope, key, writtenValue);
4990
+ if ("error" in written) return writeFailure(command, written.error, mode, 1);
4991
+ if (!written.path) return writeFailure(command, invalid("The config store is unavailable.", "Set ARTIFACTSHARE_CONFIG_HOME to a writable directory."), mode, 1);
4992
+ const repositoryConfig = scope === "repository" ? withConfigValue(shared.config ?? {}, key, writtenValue) : shared.config ?? {};
4993
+ const userConfig = scope === "user" ? withConfigValue(user.config, key, writtenValue) : user.config;
4994
+ const repositoryValue = logicalValue(repositoryConfig, key);
4995
+ const userValue = logicalValue(userConfig, key);
4996
+ const item = isHomeKey(key) ? resolveHomeVisibility(void 0, repositoryConfig.home_audience, repositoryConfig.default_artifact_visibility, userConfig.home_audience, userConfig.default_artifact_visibility) : resolveVisibility(void 0, repositoryValue, userValue);
4997
+ if ("invalid" in item) return writeFailure(command, invalid("Config value must be workspace or private.", "Fix the config before using this setting."), mode, 1);
4998
+ return writeSuccess(command, {
4999
+ scope,
5000
+ path: written.path,
5001
+ [key]: item
5002
+ }, mode);
5003
+ }
5004
+ function runConfigSet(parsed, mode) {
5005
+ return runMutation(parsed, mode, false);
5006
+ }
5007
+ function runConfigUnset(parsed, mode) {
5008
+ return runMutation(parsed, mode, true);
5009
+ }
5010
+ //#endregion
4658
5011
  //#region src/commands.ts
4659
5012
  async function shareRunner(ctx) {
4660
5013
  const parsed = parsedArgsFromContext("share", ctx);
@@ -4741,6 +5094,18 @@ async function profilesListRunner(ctx) {
4741
5094
  const parsed = parsedArgsFromContext("profiles list", ctx);
4742
5095
  return await runWithSkillAutoUpdate(parsed, () => runProfilesList(parsed, outputMode(parsed.options)));
4743
5096
  }
5097
+ async function configGetRunner(ctx) {
5098
+ const parsed = parsedArgsFromContext("config get", ctx);
5099
+ return await runConfigGet(parsed, outputMode(parsed.options));
5100
+ }
5101
+ async function configSetRunner(ctx) {
5102
+ const parsed = parsedArgsFromContext("config set", ctx);
5103
+ return await runConfigSet(parsed, outputMode(parsed.options));
5104
+ }
5105
+ async function configUnsetRunner(ctx) {
5106
+ const parsed = parsedArgsFromContext("config unset", ctx);
5107
+ return await runConfigUnset(parsed, outputMode(parsed.options));
5108
+ }
4744
5109
  async function profilesUseRunner(ctx) {
4745
5110
  const parsed = parsedArgsFromContext("profiles use", ctx);
4746
5111
  return await runWithSkillAutoUpdate(parsed, () => runProfilesUse(parsed, outputMode(parsed.options)));
@@ -4901,6 +5266,7 @@ async function runGunshi(argv) {
4901
5266
  changelog: lazyCommand(changelogDefinition, changelogRunner),
4902
5267
  profiles: profilesDefinition,
4903
5268
  projects: projectsDefinition,
5269
+ config: configDefinition,
4904
5270
  skills: skillsDefinition,
4905
5271
  init: lazyCommand(initDefinition, initRunner)
4906
5272
  },
@@ -4969,6 +5335,7 @@ npx --yes @artifactshare/cli logout --profile default --json
4969
5335
  npx --yes @artifactshare/cli profiles list --json
4970
5336
  npx --yes @artifactshare/cli profiles use <name> --json
4971
5337
  npx --yes @artifactshare/cli projects list --json
5338
+ npx --yes @artifactshare/cli config get home_audience --json
4972
5339
  npx --yes @artifactshare/cli skills install --tool codex --json
4973
5340
  npx --yes @artifactshare/cli skills list --json
4974
5341
  npx --yes @artifactshare/cli init --profile <name> --project-id <id> --json
@@ -4983,7 +5350,6 @@ Authentication:
4983
5350
 
4984
5351
  Common failures:
4985
5352
  auth_required Use ${TOKEN_ENV_VAR} or ${TOKEN_OPTION}; tokens are issued at ${DEFAULT_BASE_URL}/settings/tokens
4986
- destination_required Add --project-id, configure .artifactshare/config.json, or pass --home
4987
5353
  invalid_destination Choose --project-id <id> or --home
4988
5354
  target_not_found Use an artifact ID, share URL, or sandbox URL
4989
5355
  upload_not_allowed Upload access is limited; run request-access to join the waitlist`,
@@ -5049,7 +5415,7 @@ const shareDefinition = define({
5049
5415
  visibility: {
5050
5416
  type: "string",
5051
5417
  toKebab: true,
5052
- description: "private, workspace, or project (default: project for a project destination, private otherwise or with --grant-email)"
5418
+ description: "private, workspace, or project (default: project for a project destination, otherwise resolved from config)"
5053
5419
  },
5054
5420
  grantEmail: {
5055
5421
  type: "string",
@@ -5066,6 +5432,16 @@ const shareDefinition = define({
5066
5432
  examples: `npx --yes @artifactshare/cli share report.html --project-id <id> --json
5067
5433
  npx --yes @artifactshare/cli share report.html --project-id <id> --key nightly-report --json
5068
5434
 
5435
+ Posting to a project delivers to the audience defined by that project.
5436
+ With no destination, share posts to home. Choose the setting by purpose:
5437
+ Personal safe default (this CLI environment only):
5438
+ npx --yes @artifactshare/cli config set home_audience private --scope user --json
5439
+ Shared policy agreed by all repository participants:
5440
+ npx --yes @artifactshare/cli config set home_audience workspace --scope repository --json
5441
+ One-time audience for a single post: pass --visibility private|workspace.
5442
+ Check the resolved audience before posting:
5443
+ npx --yes @artifactshare/cli config get home_audience --scope effective --json
5444
+
5069
5445
  To keep an existing share URL, use update:
5070
5446
  npx --yes @artifactshare/cli update <artifact-id-or-url> <path> --json
5071
5447
 
@@ -5073,7 +5449,6 @@ For repeat jobs, use --key: first share creates the artifact, later runs add ver
5073
5449
 
5074
5450
  Common failures:
5075
5451
  auth_required Set ARTIFACTSHARE_TOKEN before share
5076
- destination_required Non-interactive share needs --project-id, config default, or --home
5077
5452
  upload_not_allowed Your account cannot share yet; request access from an operator
5078
5453
  file_too_large Reduce file or directory size and retry
5079
5454
  validation_failed Check file type (.html / .md for single files) and directory layout
@@ -5643,6 +6018,90 @@ Common failures:
5643
6018
  profile_not_found Run profiles list to see saved profiles
5644
6019
  token_store_unavailable Credential removal failed; the profile entry is kept`
5645
6020
  });
6021
+ const configGetDefinition = define({
6022
+ name: "get",
6023
+ description: "Read where home posts are delivered and other visibility settings.",
6024
+ toKebab: true,
6025
+ args: {
6026
+ ...commonArgs,
6027
+ key: {
6028
+ type: "positional",
6029
+ required: false,
6030
+ description: "home_audience (default; keyless JSON returns only this key), default_artifact_visibility (compatibility alias), or default_project_visibility"
6031
+ },
6032
+ scope: {
6033
+ type: "string",
6034
+ toKebab: true,
6035
+ description: "user, repository, or effective"
6036
+ }
6037
+ }
6038
+ });
6039
+ const configSetDefinition = define({
6040
+ name: "set",
6041
+ description: "Set home audience or a default visibility setting.",
6042
+ toKebab: true,
6043
+ args: {
6044
+ ...commonArgs,
6045
+ key: {
6046
+ type: "positional",
6047
+ description: "Configuration key"
6048
+ },
6049
+ value: {
6050
+ type: "positional",
6051
+ description: "workspace or private"
6052
+ },
6053
+ scope: {
6054
+ type: "string",
6055
+ toKebab: true,
6056
+ description: "user or repository"
6057
+ }
6058
+ }
6059
+ });
6060
+ const configUnsetDefinition = define({
6061
+ name: "unset",
6062
+ description: "Remove a home audience or default visibility setting.",
6063
+ toKebab: true,
6064
+ args: {
6065
+ ...commonArgs,
6066
+ key: {
6067
+ type: "positional",
6068
+ description: "Configuration key"
6069
+ },
6070
+ scope: {
6071
+ type: "string",
6072
+ toKebab: true,
6073
+ description: "user or repository"
6074
+ }
6075
+ }
6076
+ });
6077
+ const configDefinition = define({
6078
+ name: "config",
6079
+ description: "Manage where home posts are delivered and project defaults.",
6080
+ toKebab: true,
6081
+ args: commonArgs,
6082
+ subCommands: {
6083
+ get: lazyCommand(configGetDefinition, configGetRunner),
6084
+ set: lazyCommand(configSetDefinition, configSetRunner),
6085
+ unset: lazyCommand(configUnsetDefinition, configUnsetRunner)
6086
+ },
6087
+ examples: `Posting to a project delivers to that project's audience. Without a destination, share posts to home.
6088
+ Choose the home audience by purpose:
6089
+ Personal safe default (this CLI environment only):
6090
+ npx --yes @artifactshare/cli config set home_audience private --scope user --json
6091
+ Shared policy agreed by all repository participants:
6092
+ npx --yes @artifactshare/cli config set home_audience workspace --scope repository --json
6093
+ One-time audience for a single post: pass --visibility private|workspace.
6094
+ Check the resolved audience with:
6095
+ npx --yes @artifactshare/cli config get home_audience --scope effective --json
6096
+
6097
+ Keys:
6098
+ home_audience Canonical home-post audience.
6099
+ default_artifact_visibility Compatibility alias for home_audience.
6100
+ default_project_visibility Advanced default for projects create.
6101
+
6102
+ Scopes: user stores in the global config; repository stores in the shared .artifactshare/config.json; effective reads the resolved value. Home audience resolution is repository home_audience, repository alias, user home_audience, user alias, then product default workspace. Project defaults resolve repository, user, then workspace. Keyless config get --json returns only home_audience; pass an explicit key to read default_project_visibility or the compatibility alias. Explicit --visibility overrides the destination default for one post.`,
6103
+ run: parentCommandRunner("config")
6104
+ });
5646
6105
  const profilesDefinition = define({
5647
6106
  name: "profiles",
5648
6107
  description: "Manage saved CLI profiles.",
@@ -5688,12 +6147,16 @@ const projectsCreateDefinition = define({
5688
6147
  visibility: {
5689
6148
  type: "string",
5690
6149
  toKebab: true,
5691
- description: "workspace or private (default: workspace)"
6150
+ description: "workspace or private (default: default_project_visibility, resolved from repository, user, then workspace)"
5692
6151
  }
5693
6152
  },
5694
6153
  examples: `npx --yes @artifactshare/cli projects create "Launch review" --json
5695
6154
  npx --yes @artifactshare/cli projects create "Client" --description "Weekly reports" --visibility private --json
5696
6155
 
6156
+ Persist the default for project creation in the repository:
6157
+ npx --yes @artifactshare/cli config get default_project_visibility --json
6158
+ npx --yes @artifactshare/cli config set default_project_visibility private --scope repository --json
6159
+
5697
6160
  The response includes project.id and next_command for share --project-id.
5698
6161
 
5699
6162
  Common failures:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artifactshare/cli",
3
- "version": "0.6.1",
3
+ "version": "0.7.1",
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: Share, publish, upload, host, update, open, or read back existing f
4
4
  ---
5
5
 
6
6
  <!-- artifactshare-skill
7
- version: 24
7
+ version: 27
8
8
  managed: true
9
9
  -->
10
10
 
@@ -92,14 +92,53 @@ npx --yes @artifactshare/cli share ./site-dir --project-id <id> --json
92
92
  successful run creates a new artifact.
93
93
  - Pick the destination with `--project-id <id>`, `--project <name>` (by exact
94
94
  name, no prior `resolve` needed), the saved default from `init`, or `--home`.
95
- Without any of these it fails with `destination_required`.
95
+ Posting to a project delivers to the audience defined by that project.
96
+ Without any destination it posts to home.
97
+ - Choose `home_audience` by purpose: use `config set home_audience private
98
+ --scope user --json` for a personal safe default in this CLI environment,
99
+ use `--scope repository` only for a policy agreed by all participants, and
100
+ use `--visibility private|workspace` for one home post.
101
+ - Confirm the resolved home audience before posting with
102
+ `config get home_audience --scope effective --json`.
96
103
  - Set visibility at share time with `--visibility private|workspace|project`.
97
- When `--grant-email` is passed, the default becomes `private`.
104
+ This is a per-post override; `--grant-email` does not change the resolved
105
+ default visibility.
98
106
  - For repeat jobs with a stable caller-owned name, use
99
107
  `share <path> --key <key> --json`: the first run creates the artifact, later
100
108
  runs add versions to the same artifact.
101
109
  - Run `share --help` for all flags.
102
110
 
111
+ ## Audience and visibility settings
112
+
113
+ Posting to a project delivers to the audience defined by that project. Without
114
+ a destination, `share` posts to home. Choose the home audience by purpose:
115
+
116
+ ```bash
117
+ npx --yes @artifactshare/cli config set home_audience private --scope user --json
118
+ npx --yes @artifactshare/cli config set home_audience workspace --scope repository --json
119
+ npx --yes @artifactshare/cli share ./report.html --visibility private --json
120
+ npx --yes @artifactshare/cli config get home_audience --scope effective --json
121
+ ```
122
+
123
+ Use the user scope for a personal safe default in this CLI environment, the
124
+ repository scope only for a policy agreed by all participants, and
125
+ `--visibility` for a one-time audience.
126
+
127
+ Use `--visibility private|workspace|project` as a per-post override. For new
128
+ projects, pass `projects create --visibility private|workspace`; persistent
129
+ project defaults are documented in `projects create --help`.
130
+
131
+ The complete `config --help` reference covers user and repository scopes,
132
+ effective resolution, and the canonical `home_audience` key. The old
133
+ `default_artifact_visibility` remains a compatibility alias, while
134
+ `default_project_visibility` is the advanced `projects create` default. Home
135
+ resolution checks repository then user settings (including the alias at each
136
+ scope), then product default `workspace`; project defaults use repository,
137
+ user, then `workspace`. Keyless `config get --json` returns only
138
+ `home_audience`; pass an explicit key for either other setting. These settings
139
+ only affect new home posts and project creation; update, edit, Web, and MCP
140
+ defaults are unchanged.
141
+
103
142
  ## Update
104
143
 
105
144
  Use `update` to add a new version to an existing artifact while keeping its URL.
@@ -199,8 +238,8 @@ npx --yes @artifactshare/cli projects edit <id> --add-email viewer@example.com -
199
238
  npx --yes @artifactshare/cli projects edit <id> --archive --json
200
239
  ```
201
240
 
202
- - `projects create` defaults to `--visibility workspace`. Pass
203
- `--visibility private` for confidential projects.
241
+ - `projects create` uses `default_project_visibility` when saved, otherwise
242
+ `workspace`. Pass `--visibility private` for a confidential project.
204
243
  - `projects edit` changes name, description, visibility, audience
205
244
  (`--add-email` / `--remove-email`), and archive state (`--archive` /
206
245
  `--unarchive`).
@@ -4,7 +4,7 @@ alwaysApply: false
4
4
  ---
5
5
 
6
6
  <!-- artifactshare-skill
7
- version: 24
7
+ version: 27
8
8
  managed: true
9
9
  -->
10
10
 
@@ -43,7 +43,8 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
43
43
  - Remove a saved local credential with `logout --profile <name> --json`; this keeps profile metadata and does not revoke API tokens on the server.
44
44
  - Switch profiles with `profiles use <name> --json`; list with `profiles list --json`; remove a profile entry and its credential with `profiles delete <name> --json`.
45
45
  - 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.
46
- - Share with `share <path> --json`. In JSON output, give the user `data.artifact.url`; the artifact ID is `data.artifact.id`. Do not rerun `share` just to inspect the JSON shape: without `--key`, each successful run creates a new artifact. 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`.
46
+ - Share with `share <path> --json`. In JSON output, give the user `data.artifact.url`; the artifact ID is `data.artifact.id`. Do not rerun `share` just to inspect the JSON shape: without `--key`, each successful run creates a new artifact. Posting to a project delivers to the audience defined by that project. Pick it with `--project-id <id>` or `--project <name>` (by exact name), or use the saved default. With no destination, share posts to home. Choose `home_audience` by purpose: use `config set home_audience private --scope user --json` for a personal safe default in this CLI environment, use `--scope repository` only for a policy agreed by all participants, and use `--visibility private|workspace` for one home post. Confirm the resolved audience with `config get home_audience --scope effective --json`; `--grant-email` does not change the resolved default.
47
+ - For new projects, pass `projects create <name> --visibility private|workspace`; persistent project defaults are documented in `projects create --help`. The complete `config --help` reference covers the canonical `home_audience`, user/repository/effective scopes, and resolution. `default_artifact_visibility` is a compatibility alias; `default_project_visibility` is the advanced project-creation default. Home resolution checks repository then user settings, including the alias at each scope, then product default `workspace`. Keyless `config get --json` returns only `home_audience`; pass an explicit key for either other setting. These settings do not change update, edit, Web, or MCP defaults.
47
48
  - 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.
48
49
  - To keep an existing share URL, do not use `share --artifact-id`; add a version with `update <artifact-id-or-url> <path> --json`. `update` does not change title, visibility, viewers, or placement.
49
50
  - Read back with `artifacts get <target> --json`. Pass `--include versions` or `--include comments` to fetch history or comments in one call. If truncated, call again with `--offset` set to `next_offset`.
@@ -53,7 +54,7 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
53
54
  - Edit, resolve, reopen, and delete comments with `comments edit`, `comments resolve`, `comments reopen`, and `comments delete` using IDs from `comments list`. Comment deletion cannot be undone; omit `--message-id` from `comments delete` only when the user wants the whole thread deleted.
54
55
  - Change post-share settings with `edit <target>`: `--title`, `--visibility`, `--grant-email`, `--revoke-email`, `--project-id`, `--home`. Moving a `project` visibility file home makes it `private`. `move` remains for placement-only automation; prefer `edit`.
55
56
  - Permanently remove an artifact only when the user explicitly asks with `delete <artifact-id-or-url> --json`.
56
- - Manage projects: `projects list --json`, `projects create <name> --json` (defaults to `--visibility workspace`; pass `--visibility private` for confidential projects), `projects edit <id>` for name, description, visibility, audience (`--add-email`/`--remove-email`), and archive state (`--archive`/`--unarchive`).
57
+ - Manage projects: `projects list --json`, `projects create <name> --json` (uses `default_project_visibility` when saved, otherwise `workspace`; pass `--visibility private` for a confidential project), `projects edit <id>` for name, description, visibility, audience (`--add-email`/`--remove-email`), and archive state (`--archive`/`--unarchive`).
57
58
  - Save a default project with `init --project-id <id> --json`. Preview setup with `init --dry-run --json`.
58
59
  - Manage skills: `skills ensure --tool auto --json` detects Claude Code, Codex, or Cursor and installs or updates user-scope skills; Cursor project scope needs `skills install --tool cursor --scope project --json`. Use `skills install --tool cursor --scope user --json` for the Cursor user-scope skill explicitly. Project scope is opt-in via `skills install --tool <tool> --scope project --json`. `skills update --json` updates installed managed skills; `--force` overwrites unmanaged files on install.
59
60
  - Check the current state with `whoami --json` or `doctor --json` for authentication, destination, network, upload access, and skill update status.