@artifactshare/cli 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
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.0 - 2026-07-13
7
+
8
+ - Share without a destination now posts to home, so agents and automation have a predictable first destination.
9
+ - Configure `home_audience` for a user or repository to choose whether home posts are private or visible to the workspace.
10
+ - Repository settings take precedence over user settings, giving teams a shared default while preserving a personal fallback.
11
+
6
12
  ## 0.6.1 - 2026-07-12
7
13
 
8
14
  - 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 get home_audience --json
30
+ npx --yes @artifactshare/cli config set home_audience private --scope repository --json
29
31
  ```
30
32
 
31
33
  To keep an existing share URL, update it with
@@ -63,6 +65,23 @@ 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. The repository `home_audience` selects `private` (only you) or `workspace` (everyone in the workspace/company):
75
+
76
+ ```sh
77
+ npx --yes @artifactshare/cli config get home_audience --json
78
+ npx --yes @artifactshare/cli config set home_audience private --scope repository --json
79
+ ```
80
+
81
+ Pass `--visibility` to override the destination default for that post only. For project creation, pass `projects create <name> --visibility private|workspace`; persistent project defaults are documented in `projects create --help`.
82
+
83
+ 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. 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.
84
+
66
85
  ## For AI agents
67
86
 
68
87
  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,13 @@ 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. The repository home_audience selects
5437
+ private (only you) or workspace (everyone in the workspace/company):
5438
+ npx --yes @artifactshare/cli config get home_audience --json
5439
+ npx --yes @artifactshare/cli config set home_audience private --scope repository --json
5440
+ Use --visibility as a per-post override of the destination default.
5441
+
5069
5442
  To keep an existing share URL, use update:
5070
5443
  npx --yes @artifactshare/cli update <artifact-id-or-url> <path> --json
5071
5444
 
@@ -5073,7 +5446,6 @@ For repeat jobs, use --key: first share creates the artifact, later runs add ver
5073
5446
 
5074
5447
  Common failures:
5075
5448
  auth_required Set ARTIFACTSHARE_TOKEN before share
5076
- destination_required Non-interactive share needs --project-id, config default, or --home
5077
5449
  upload_not_allowed Your account cannot share yet; request access from an operator
5078
5450
  file_too_large Reduce file or directory size and retry
5079
5451
  validation_failed Check file type (.html / .md for single files) and directory layout
@@ -5643,6 +6015,85 @@ Common failures:
5643
6015
  profile_not_found Run profiles list to see saved profiles
5644
6016
  token_store_unavailable Credential removal failed; the profile entry is kept`
5645
6017
  });
6018
+ const configGetDefinition = define({
6019
+ name: "get",
6020
+ description: "Read where home posts are delivered and other visibility settings.",
6021
+ toKebab: true,
6022
+ args: {
6023
+ ...commonArgs,
6024
+ key: {
6025
+ type: "positional",
6026
+ required: false,
6027
+ description: "home_audience (default; keyless JSON returns only this key), default_artifact_visibility (compatibility alias), or default_project_visibility"
6028
+ },
6029
+ scope: {
6030
+ type: "string",
6031
+ toKebab: true,
6032
+ description: "user, repository, or effective"
6033
+ }
6034
+ }
6035
+ });
6036
+ const configSetDefinition = define({
6037
+ name: "set",
6038
+ description: "Set home audience or a default visibility setting.",
6039
+ toKebab: true,
6040
+ args: {
6041
+ ...commonArgs,
6042
+ key: {
6043
+ type: "positional",
6044
+ description: "Configuration key"
6045
+ },
6046
+ value: {
6047
+ type: "positional",
6048
+ description: "workspace or private"
6049
+ },
6050
+ scope: {
6051
+ type: "string",
6052
+ toKebab: true,
6053
+ description: "user or repository"
6054
+ }
6055
+ }
6056
+ });
6057
+ const configUnsetDefinition = define({
6058
+ name: "unset",
6059
+ description: "Remove a home audience or default visibility setting.",
6060
+ toKebab: true,
6061
+ args: {
6062
+ ...commonArgs,
6063
+ key: {
6064
+ type: "positional",
6065
+ description: "Configuration key"
6066
+ },
6067
+ scope: {
6068
+ type: "string",
6069
+ toKebab: true,
6070
+ description: "user or repository"
6071
+ }
6072
+ }
6073
+ });
6074
+ const configDefinition = define({
6075
+ name: "config",
6076
+ description: "Manage where home posts are delivered and project defaults.",
6077
+ toKebab: true,
6078
+ args: commonArgs,
6079
+ subCommands: {
6080
+ get: lazyCommand(configGetDefinition, configGetRunner),
6081
+ set: lazyCommand(configSetDefinition, configSetRunner),
6082
+ unset: lazyCommand(configUnsetDefinition, configUnsetRunner)
6083
+ },
6084
+ examples: `Posting to a project delivers to that project's audience. Without a destination, share posts to home.
6085
+ Set the repository home audience to private (only you) or workspace (everyone in the workspace/company):
6086
+ npx --yes @artifactshare/cli config get home_audience --json
6087
+ npx --yes @artifactshare/cli config set home_audience private --scope repository --json
6088
+
6089
+ Keys:
6090
+ home_audience Canonical home-post audience.
6091
+ default_artifact_visibility Compatibility alias for home_audience.
6092
+ default_project_visibility Advanced default for projects create.
6093
+
6094
+ 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.`,
6095
+ run: parentCommandRunner("config")
6096
+ });
5646
6097
  const profilesDefinition = define({
5647
6098
  name: "profiles",
5648
6099
  description: "Manage saved CLI profiles.",
@@ -5688,12 +6139,16 @@ const projectsCreateDefinition = define({
5688
6139
  visibility: {
5689
6140
  type: "string",
5690
6141
  toKebab: true,
5691
- description: "workspace or private (default: workspace)"
6142
+ description: "workspace or private (default: default_project_visibility, resolved from repository, user, then workspace)"
5692
6143
  }
5693
6144
  },
5694
6145
  examples: `npx --yes @artifactshare/cli projects create "Launch review" --json
5695
6146
  npx --yes @artifactshare/cli projects create "Client" --description "Weekly reports" --visibility private --json
5696
6147
 
6148
+ Persist the default for project creation in the repository:
6149
+ npx --yes @artifactshare/cli config get default_project_visibility --json
6150
+ npx --yes @artifactshare/cli config set default_project_visibility private --scope repository --json
6151
+
5697
6152
  The response includes project.id and next_command for share --project-id.
5698
6153
 
5699
6154
  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.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: Share, publish, upload, host, update, open, or read back existing f
4
4
  ---
5
5
 
6
6
  <!-- artifactshare-skill
7
- version: 24
7
+ version: 26
8
8
  managed: true
9
9
  -->
10
10
 
@@ -92,14 +92,43 @@ 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
+ - The repository `home_audience` selects `private` (only you) or `workspace`
98
+ (everyone in the workspace/company). Check or set it with:
99
+ `config get home_audience --json` and
100
+ `config set home_audience private --scope repository --json`.
96
101
  - Set visibility at share time with `--visibility private|workspace|project`.
97
- When `--grant-email` is passed, the default becomes `private`.
102
+ This is a per-post override; `--grant-email` does not change the resolved
103
+ default visibility.
98
104
  - For repeat jobs with a stable caller-owned name, use
99
105
  `share <path> --key <key> --json`: the first run creates the artifact, later
100
106
  runs add versions to the same artifact.
101
107
  - Run `share --help` for all flags.
102
108
 
109
+ ## Audience and visibility settings
110
+
111
+ Posting to a project delivers to the audience defined by that project. Without
112
+ a destination, `share` posts to home, whose repository `home_audience` is
113
+ `private` (only you) or `workspace` (everyone in the workspace/company). Check
114
+ or set it with `config get home_audience --json` and
115
+ `config set home_audience private --scope repository --json`.
116
+
117
+ Use `--visibility private|workspace|project` as a per-post override. For new
118
+ projects, pass `projects create --visibility private|workspace`; persistent
119
+ project defaults are documented in `projects create --help`.
120
+
121
+ The complete `config --help` reference covers user and repository scopes,
122
+ effective resolution, and the canonical `home_audience` key. The old
123
+ `default_artifact_visibility` remains a compatibility alias, while
124
+ `default_project_visibility` is the advanced `projects create` default. Home
125
+ resolution checks repository then user settings (including the alias at each
126
+ scope), then product default `workspace`; project defaults use repository,
127
+ user, then `workspace`. Keyless `config get --json` returns only
128
+ `home_audience`; pass an explicit key for either other setting. These settings
129
+ only affect new home posts and project creation; update, edit, Web, and MCP
130
+ defaults are unchanged.
131
+
103
132
  ## Update
104
133
 
105
134
  Use `update` to add a new version to an existing artifact while keeping its URL.
@@ -199,8 +228,8 @@ npx --yes @artifactshare/cli projects edit <id> --add-email viewer@example.com -
199
228
  npx --yes @artifactshare/cli projects edit <id> --archive --json
200
229
  ```
201
230
 
202
- - `projects create` defaults to `--visibility workspace`. Pass
203
- `--visibility private` for confidential projects.
231
+ - `projects create` uses `default_project_visibility` when saved, otherwise
232
+ `workspace`. Pass `--visibility private` for a confidential project.
204
233
  - `projects edit` changes name, description, visibility, audience
205
234
  (`--add-email` / `--remove-email`), and archive state (`--archive` /
206
235
  `--unarchive`).
@@ -4,7 +4,7 @@ alwaysApply: false
4
4
  ---
5
5
 
6
6
  <!-- artifactshare-skill
7
- version: 24
7
+ version: 26
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. The repository `home_audience` selects `private` (only you) or `workspace` (everyone in the workspace/company): inspect with `config get home_audience --json` and set with `config set home_audience private --scope repository --json`. Use `--visibility private|workspace|project` as a per-post override; `--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.