@staff0rd/assist 0.488.0 → 0.488.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/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.488.0",
9
+ version: "0.488.1",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -10891,6 +10891,18 @@ function resolveNamedRepoWriteLabel(globalRaw, name) {
10891
10891
  return matches[0];
10892
10892
  }
10893
10893
 
10894
+ // src/commands/config/resolveRepoConfigBlock.ts
10895
+ function resolveRepoConfigBlock(repoName, cwd) {
10896
+ const globalRaw = loadGlobalConfigRaw();
10897
+ const label2 = repoName === void 0 ? resolveRepoWriteLabel(globalRaw, getCurrentOrigin(cwd)) : resolveNamedRepoWriteLabel(globalRaw, repoName);
10898
+ const repos2 = isPlainObject3(globalRaw.repos) ? { ...globalRaw.repos } : {};
10899
+ const block = isPlainObject3(repos2[label2]) ? repos2[label2] : {};
10900
+ return { globalRaw, repos: repos2, label: label2, block };
10901
+ }
10902
+ function isPlainObject3(value) {
10903
+ return value !== null && typeof value === "object" && !Array.isArray(value);
10904
+ }
10905
+
10894
10906
  // src/commands/config/applyRepoConfigSet.ts
10895
10907
  function applyRepoConfigSet(key, coerced, repoName, cwd = process.cwd()) {
10896
10908
  if (isGlobalOnlyConfigKey(key)) {
@@ -10901,20 +10913,17 @@ function applyRepoConfigSet(key, coerced, repoName, cwd = process.cwd()) {
10901
10913
  ]
10902
10914
  };
10903
10915
  }
10904
- const globalRaw = loadGlobalConfigRaw();
10905
- const label2 = repoName === void 0 ? resolveRepoWriteLabel(globalRaw, getCurrentOrigin(cwd)) : resolveNamedRepoWriteLabel(globalRaw, repoName);
10906
- const repos2 = isPlainObject3(globalRaw.repos) ? { ...globalRaw.repos } : {};
10907
- const existingBlock = isPlainObject3(repos2[label2]) ? repos2[label2] : {};
10908
- const updatedBlock = setNestedValue(existingBlock, key, coerced);
10916
+ const { globalRaw, repos: repos2, label: label2, block } = resolveRepoConfigBlock(
10917
+ repoName,
10918
+ cwd
10919
+ );
10920
+ const updatedBlock = setNestedValue(block, key, coerced);
10909
10921
  const validation = validateConfig(updatedBlock, key, repoConfigSchema);
10910
10922
  if (!validation.ok) return validation;
10911
10923
  repos2[label2] = updatedBlock;
10912
10924
  saveGlobalConfig({ ...globalRaw, repos: repos2 });
10913
10925
  return { ok: true, target: "repo", label: label2 };
10914
10926
  }
10915
- function isPlainObject3(value) {
10916
- return value !== null && typeof value === "object" && !Array.isArray(value);
10917
- }
10918
10927
 
10919
10928
  // src/commands/sessions/web/applyScopedConfigSet.ts
10920
10929
  function applyScopedConfigSet(key, value, cwd, scope) {
@@ -10994,6 +11003,11 @@ function setConfig(req, res) {
10994
11003
  });
10995
11004
  }
10996
11005
 
11006
+ // src/commands/config/isKnownConfigKey.ts
11007
+ function isKnownConfigKey(key) {
11008
+ return enumerateConfigLeafKeys(assistConfigSchema).includes(key);
11009
+ }
11010
+
10997
11011
  // src/commands/config/unsetNestedValue.ts
10998
11012
  function isPlainObject4(val) {
10999
11013
  return val !== null && typeof val === "object" && !Array.isArray(val);
@@ -11084,9 +11098,48 @@ function applyConfigUnset(key, global, cwd = process.cwd()) {
11084
11098
  return { ok: true, target, removed: true };
11085
11099
  }
11086
11100
 
11087
- // src/commands/config/isKnownConfigKey.ts
11088
- function isKnownConfigKey(key) {
11089
- return enumerateConfigLeafKeys(assistConfigSchema).includes(key);
11101
+ // src/commands/config/applyRepoConfigUnset.ts
11102
+ function applyRepoConfigUnset(key, repoName, cwd = process.cwd()) {
11103
+ if (isGlobalOnlyConfigKey(key)) {
11104
+ return {
11105
+ ok: false,
11106
+ errors: [
11107
+ `"${key}" is a global-only key. Unset it in ~/.assist.yml rather than under repos:`
11108
+ ]
11109
+ };
11110
+ }
11111
+ const { globalRaw, repos: repos2, label: label2, block } = resolveRepoConfigBlock(
11112
+ repoName,
11113
+ cwd
11114
+ );
11115
+ const { config: updatedBlock, removed } = unsetNestedValue(block, key);
11116
+ if (!removed) return { ok: true, target: "repo", label: label2, removed: false };
11117
+ const validation = validateConfig(updatedBlock, key, repoConfigSchema);
11118
+ if (!validation.ok) return validation;
11119
+ if (Object.keys(updatedBlock).length === 0) delete repos2[label2];
11120
+ else repos2[label2] = updatedBlock;
11121
+ const next3 = { ...globalRaw };
11122
+ if (Object.keys(repos2).length === 0) delete next3.repos;
11123
+ else next3.repos = repos2;
11124
+ saveGlobalConfig(next3);
11125
+ return { ok: true, target: "repo", label: label2, removed: true };
11126
+ }
11127
+
11128
+ // src/commands/sessions/web/applyScopedConfigUnset.ts
11129
+ function applyScopedConfigUnset(key, cwd, scope) {
11130
+ if (scope === "repo") {
11131
+ const result2 = applyRepoConfigUnset(key, void 0, cwd);
11132
+ return result2.ok ? {
11133
+ ok: true,
11134
+ payload: {
11135
+ target: result2.target,
11136
+ repoKey: result2.label,
11137
+ removed: result2.removed
11138
+ }
11139
+ } : result2;
11140
+ }
11141
+ const result = applyConfigUnset(key, scope === "global", cwd);
11142
+ return result.ok ? { ok: true, payload: { target: result.target, removed: result.removed } } : result;
11090
11143
  }
11091
11144
 
11092
11145
  // src/commands/sessions/web/unsetConfig.ts
@@ -11094,22 +11147,7 @@ function unsetConfig(req, res) {
11094
11147
  return handleConfigWrite(req, res, (request) => {
11095
11148
  if (!isKnownConfigKey(request.key))
11096
11149
  return { ok: false, errors: [`Unknown config key "${request.key}"`] };
11097
- if (request.scope === "repo")
11098
- return {
11099
- ok: false,
11100
- errors: [
11101
- "Clearing a repos override is not supported \u2014 remove the key from repos: in ~/.assist.yml"
11102
- ]
11103
- };
11104
- const result = applyConfigUnset(
11105
- request.key,
11106
- request.scope === "global",
11107
- request.cwd
11108
- );
11109
- return result.ok ? {
11110
- ok: true,
11111
- payload: { target: result.target, removed: result.removed }
11112
- } : result;
11150
+ return applyScopedConfigUnset(request.key, request.cwd, request.scope);
11113
11151
  });
11114
11152
  }
11115
11153
 
@@ -16566,16 +16604,48 @@ function applyRepoOrExit(key, coerced, repoName) {
16566
16604
 
16567
16605
  // src/commands/config/configUnset.ts
16568
16606
  import chalk132 from "chalk";
16607
+
16608
+ // src/commands/config/resolveRepoUnsetTarget.ts
16609
+ function resolveRepoUnsetTarget(key, repo) {
16610
+ if (typeof repo === "string") {
16611
+ if (key === void 0)
16612
+ return { key: repo, useRepo: true, repoName: void 0 };
16613
+ return { key, useRepo: true, repoName: repo };
16614
+ }
16615
+ return { key, useRepo: repo === true, repoName: void 0 };
16616
+ }
16617
+
16618
+ // src/commands/config/configUnset.ts
16569
16619
  function configUnset(key, options2 = {}) {
16570
- const result = applyConfigUnset(key, options2.global ?? false);
16620
+ if (options2.repo !== void 0 && !options2.global) {
16621
+ console.error(
16622
+ chalk132.red(
16623
+ "--repo removes from the global config; add -g (e.g. -g --repo)"
16624
+ )
16625
+ );
16626
+ process.exit(1);
16627
+ }
16628
+ const resolved = resolveRepoUnsetTarget(key, options2.repo);
16629
+ if (resolved.key === void 0) {
16630
+ console.error(chalk132.red("Missing required argument 'key'"));
16631
+ process.exit(1);
16632
+ return;
16633
+ }
16634
+ const result = resolved.useRepo ? applyRepoConfigUnset(resolved.key, resolved.repoName) : applyConfigUnset(resolved.key, options2.global ?? false);
16571
16635
  if (!result.ok) exitWithConfigErrors(result.errors);
16572
16636
  if (!result.removed) {
16573
16637
  console.log(
16574
- chalk132.yellow(`${key} is not set in the ${result.target} config`)
16638
+ chalk132.yellow(`${resolved.key} is not set in ${whereLabel(result)}`)
16575
16639
  );
16576
16640
  return;
16577
16641
  }
16578
- console.log(chalk132.green(`Unset ${key} (${result.target})`));
16642
+ console.log(chalk132.green(`Unset ${resolved.key} (${targetLabel(result)})`));
16643
+ }
16644
+ function whereLabel(result) {
16645
+ return result.target === "repo" ? `repos.${result.label}` : `the ${result.target} config`;
16646
+ }
16647
+ function targetLabel(result) {
16648
+ return result.target === "repo" ? `repo: ${result.label}` : result.target;
16579
16649
  }
16580
16650
 
16581
16651
  // src/commands/registerConfig.ts
@@ -16585,7 +16655,10 @@ function registerConfig(program2) {
16585
16655
  "-r, --repo [name]",
16586
16656
  "Requires -g: scope the global write to a repo's identity (defaults to the current repo)"
16587
16657
  ).action((key, value, options2) => configSet(key, value, options2));
16588
- configCommand.command("unset <key>").description("Remove a config value (e.g. commit.push)").option("-g, --global", "Remove from global ~/.assist.yml").action((key, options2) => configUnset(key, options2));
16658
+ configCommand.command("unset [key]").description("Remove a config value (e.g. commit.push)").option("-g, --global", "Remove from global ~/.assist.yml").option(
16659
+ "-r, --repo [name]",
16660
+ "Requires -g: remove the key from a repo's identity block (defaults to the current repo)"
16661
+ ).action((key, options2) => configUnset(key, options2));
16589
16662
  configCommand.command("get <key>").description("Get a config value").action(configGet);
16590
16663
  configCommand.command("list").description("List all config values").action(configList);
16591
16664
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.488.0",
3
+ "version": "0.488.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {