@staff0rd/assist 0.479.0 → 0.479.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/README.md +228 -193
- package/dist/commands/sessions/web/bundle.js +372 -372
- package/dist/index.js +64 -28
- package/package.json +1 -1
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.479.
|
|
9
|
+
version: "0.479.1",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -214,6 +214,19 @@ function loadRawYaml(path71) {
|
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
+
// src/shared/deepMergeRawConfig.ts
|
|
218
|
+
function isPlainObject(value) {
|
|
219
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
220
|
+
}
|
|
221
|
+
function deepMergeRawConfig(base, override) {
|
|
222
|
+
const merged = { ...base };
|
|
223
|
+
for (const [key, value] of Object.entries(override)) {
|
|
224
|
+
const existing = merged[key];
|
|
225
|
+
merged[key] = isPlainObject(existing) && isPlainObject(value) ? deepMergeRawConfig(existing, value) : value;
|
|
226
|
+
}
|
|
227
|
+
return merged;
|
|
228
|
+
}
|
|
229
|
+
|
|
217
230
|
// src/shared/mergeDenyRules.ts
|
|
218
231
|
function mergeDenyRules(globalDeny, projectDeny) {
|
|
219
232
|
if (!globalDeny && !projectDeny) return void 0;
|
|
@@ -248,7 +261,7 @@ function mergeRawConfigs(globalRaw, projectRaw) {
|
|
|
248
261
|
globalRaw.run,
|
|
249
262
|
projectRaw.run
|
|
250
263
|
);
|
|
251
|
-
const merged =
|
|
264
|
+
const merged = deepMergeRawConfig(globalRaw, projectRaw);
|
|
252
265
|
if (deny !== void 0) {
|
|
253
266
|
merged.deny = deny;
|
|
254
267
|
}
|
|
@@ -312,19 +325,25 @@ function originKeyCandidates(origin) {
|
|
|
312
325
|
const bare = segments[segments.length - 1] ?? displayName;
|
|
313
326
|
return /* @__PURE__ */ new Set([origin, displayName, bare]);
|
|
314
327
|
}
|
|
315
|
-
function
|
|
328
|
+
function matchRepoConfigKey(globalRaw, origin) {
|
|
316
329
|
const repos2 = globalRaw.repos;
|
|
317
|
-
if (!repos2 || typeof repos2 !== "object" || Array.isArray(repos2))
|
|
330
|
+
if (!repos2 || typeof repos2 !== "object" || Array.isArray(repos2))
|
|
331
|
+
return void 0;
|
|
318
332
|
const entries = repos2;
|
|
319
333
|
const candidates = originKeyCandidates(origin);
|
|
320
334
|
const matches = Object.keys(entries).filter((key) => candidates.has(key));
|
|
321
|
-
if (matches.length === 0) return
|
|
335
|
+
if (matches.length === 0) return void 0;
|
|
322
336
|
if (matches.length > 1) {
|
|
323
337
|
throw new AmbiguousRepoConfigError(
|
|
324
338
|
`Ambiguous repos config in ~/.assist.yml: keys ${matches.map((m) => `"${m}"`).join(", ")} all match the current repository (${origin}). Keep a single key per repository.`
|
|
325
339
|
);
|
|
326
340
|
}
|
|
327
|
-
|
|
341
|
+
return matches[0];
|
|
342
|
+
}
|
|
343
|
+
function resolveRepoOverride(globalRaw, origin) {
|
|
344
|
+
const matched = matchRepoConfigKey(globalRaw, origin);
|
|
345
|
+
if (matched === void 0) return {};
|
|
346
|
+
const override = globalRaw.repos[matched];
|
|
328
347
|
if (!override || typeof override !== "object" || Array.isArray(override))
|
|
329
348
|
return {};
|
|
330
349
|
return override;
|
|
@@ -9423,19 +9442,30 @@ function isGlobalOnlyConfigKey(key) {
|
|
|
9423
9442
|
// src/commands/config/readRawConfigLayers.ts
|
|
9424
9443
|
function readRawConfigLayers(cwd) {
|
|
9425
9444
|
const global = loadRawYaml(getGlobalConfigPath());
|
|
9445
|
+
if (!global.repos)
|
|
9446
|
+
return {
|
|
9447
|
+
project: loadRawYaml(getConfigPathFrom(cwd)),
|
|
9448
|
+
global,
|
|
9449
|
+
repoOverride: {}
|
|
9450
|
+
};
|
|
9451
|
+
const origin = getCurrentOrigin(cwd);
|
|
9426
9452
|
return {
|
|
9427
9453
|
project: loadRawYaml(getConfigPathFrom(cwd)),
|
|
9428
9454
|
global,
|
|
9429
|
-
repoOverride:
|
|
9455
|
+
repoOverride: resolveRepoOverride(global, origin),
|
|
9456
|
+
repoKey: matchRepoConfigKey(global, origin)
|
|
9430
9457
|
};
|
|
9431
9458
|
}
|
|
9432
9459
|
|
|
9433
|
-
// src/commands/config/
|
|
9434
|
-
function
|
|
9435
|
-
|
|
9436
|
-
if (getNestedValue(layers.
|
|
9437
|
-
|
|
9438
|
-
|
|
9460
|
+
// src/commands/config/resolveConfigSources.ts
|
|
9461
|
+
function resolveConfigSources(key, layers) {
|
|
9462
|
+
const sources = [];
|
|
9463
|
+
if (getNestedValue(layers.project, key) !== void 0)
|
|
9464
|
+
sources.push("project");
|
|
9465
|
+
if (getNestedValue(layers.repoOverride, key) !== void 0)
|
|
9466
|
+
sources.push("repo");
|
|
9467
|
+
if (getNestedValue(layers.global, key) !== void 0) sources.push("global");
|
|
9468
|
+
return sources;
|
|
9439
9469
|
}
|
|
9440
9470
|
|
|
9441
9471
|
// src/shared/configNodeFieldName.ts
|
|
@@ -9530,13 +9560,19 @@ function readConfigEntries(cwd) {
|
|
|
9530
9560
|
const config = loadConfigFrom(cwd);
|
|
9531
9561
|
const layers = readRawConfigLayers(cwd);
|
|
9532
9562
|
const schema2 = describeConfigNode(assistConfigSchema);
|
|
9533
|
-
return describeConfigLeaves(assistConfigSchema).filter((leaf) => !KEYS_STRIPPED_FROM_MERGED_CONFIG.has(leaf.key)).map((leaf) =>
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9563
|
+
return describeConfigLeaves(assistConfigSchema).filter((leaf) => !KEYS_STRIPPED_FROM_MERGED_CONFIG.has(leaf.key)).map((leaf) => {
|
|
9564
|
+
const sources = resolveConfigSources(leaf.key, layers);
|
|
9565
|
+
const source = sources[0] ?? "default";
|
|
9566
|
+
return {
|
|
9567
|
+
...leaf,
|
|
9568
|
+
value: getNestedValue(config, leaf.key),
|
|
9569
|
+
source,
|
|
9570
|
+
sources,
|
|
9571
|
+
...source === "repo" && layers.repoKey ? { repoKey: layers.repoKey } : {},
|
|
9572
|
+
globalOnly: isGlobalOnlyConfigKey(leaf.key),
|
|
9573
|
+
node: configEntryNode(schema2, leaf.key)
|
|
9574
|
+
};
|
|
9575
|
+
});
|
|
9540
9576
|
}
|
|
9541
9577
|
|
|
9542
9578
|
// src/commands/sessions/web/getConfig.ts
|
|
@@ -10367,7 +10403,7 @@ function sessionView(_req, res) {
|
|
|
10367
10403
|
}
|
|
10368
10404
|
|
|
10369
10405
|
// src/commands/config/setNestedValue.ts
|
|
10370
|
-
function
|
|
10406
|
+
function isPlainObject2(val) {
|
|
10371
10407
|
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
10372
10408
|
}
|
|
10373
10409
|
function isNumericKey(key) {
|
|
@@ -10392,7 +10428,7 @@ function ensureArray(container, key) {
|
|
|
10392
10428
|
}
|
|
10393
10429
|
function ensureObject(container, key) {
|
|
10394
10430
|
const existing = getItem(container, key);
|
|
10395
|
-
const obj =
|
|
10431
|
+
const obj = isPlainObject2(existing) ? { ...existing } : {};
|
|
10396
10432
|
setItem(container, key, obj);
|
|
10397
10433
|
return obj;
|
|
10398
10434
|
}
|
|
@@ -10620,11 +10656,11 @@ function setConfig(req, res) {
|
|
|
10620
10656
|
}
|
|
10621
10657
|
|
|
10622
10658
|
// src/commands/config/unsetNestedValue.ts
|
|
10623
|
-
function
|
|
10659
|
+
function isPlainObject3(val) {
|
|
10624
10660
|
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
10625
10661
|
}
|
|
10626
10662
|
function isContainer(val) {
|
|
10627
|
-
return Array.isArray(val) ||
|
|
10663
|
+
return Array.isArray(val) || isPlainObject3(val);
|
|
10628
10664
|
}
|
|
10629
10665
|
function isNumericKey2(key) {
|
|
10630
10666
|
return /^\d+$/.test(key);
|
|
@@ -10660,7 +10696,7 @@ function withChild(container, key, child) {
|
|
|
10660
10696
|
return { ...container, [key]: child };
|
|
10661
10697
|
}
|
|
10662
10698
|
function isPrunable(container) {
|
|
10663
|
-
return
|
|
10699
|
+
return isPlainObject3(container) && Object.keys(container).length === 0;
|
|
10664
10700
|
}
|
|
10665
10701
|
function replaceOrPrune(container, key, child) {
|
|
10666
10702
|
return isPrunable(child) ? withoutKey(container, key) : withChild(container, key, child);
|
|
@@ -16163,8 +16199,8 @@ function exitWithConfigErrors(errors) {
|
|
|
16163
16199
|
function applyRepoConfigSet(key, coerced, repoName) {
|
|
16164
16200
|
const globalRaw = loadGlobalConfigRaw();
|
|
16165
16201
|
const label2 = repoName === void 0 ? resolveRepoWriteLabel(globalRaw, getCurrentOrigin(process.cwd())) : resolveNamedRepoWriteLabel(globalRaw, repoName);
|
|
16166
|
-
const repos2 =
|
|
16167
|
-
const existingBlock =
|
|
16202
|
+
const repos2 = isPlainObject4(globalRaw.repos) ? { ...globalRaw.repos } : {};
|
|
16203
|
+
const existingBlock = isPlainObject4(repos2[label2]) ? repos2[label2] : {};
|
|
16168
16204
|
const updatedBlock = setNestedValue(existingBlock, key, coerced);
|
|
16169
16205
|
const validation = validateConfig(updatedBlock, key);
|
|
16170
16206
|
if (!validation.ok) exitWithConfigErrors(validation.errors);
|
|
@@ -16172,7 +16208,7 @@ function applyRepoConfigSet(key, coerced, repoName) {
|
|
|
16172
16208
|
saveGlobalConfig({ ...globalRaw, repos: repos2 });
|
|
16173
16209
|
return label2;
|
|
16174
16210
|
}
|
|
16175
|
-
function
|
|
16211
|
+
function isPlainObject4(value) {
|
|
16176
16212
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
16177
16213
|
}
|
|
16178
16214
|
|