@fro.bot/systematic 3.31.3 → 3.31.5
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/cli.js +43 -6
- package/dist/{index-8rz6cepj.js → index-c95n6n53.js} +190 -25
- package/dist/index.js +1 -1
- package/dist/lib/config.d.ts +32 -0
- package/dist/lib/frontmatter.d.ts +4 -2
- package/dist/pi.js +189 -24
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
_enum,
|
|
26
26
|
literal,
|
|
27
27
|
displaySafe,
|
|
28
|
+
configEntryExists,
|
|
28
29
|
MAX_PROJECT_CONFIG_BYTES,
|
|
29
30
|
readTextBounded,
|
|
30
31
|
loadUserLevelSearchSettings,
|
|
@@ -47,7 +48,7 @@ import {
|
|
|
47
48
|
SEARCH_NOTICES,
|
|
48
49
|
SEARCH_CONFIG_UNREADABLE_NOTE,
|
|
49
50
|
runSearch
|
|
50
|
-
} from "./index-
|
|
51
|
+
} from "./index-c95n6n53.js";
|
|
51
52
|
var __defProp = Object.defineProperty;
|
|
52
53
|
var __returnValue = (v) => v;
|
|
53
54
|
function __exportSetter(name, newValue) {
|
|
@@ -1638,7 +1639,8 @@ function generateEntries(repoRoot, configOptions) {
|
|
|
1638
1639
|
if (!configOptions)
|
|
1639
1640
|
return { entries, disabledFilenames: new Set };
|
|
1640
1641
|
const { config, overlays } = loadConfigWithSources(configOptions.cwd, {
|
|
1641
|
-
includeProject: configOptions.scope === "project"
|
|
1642
|
+
includeProject: configOptions.scope === "project",
|
|
1643
|
+
projectFailure: "throw"
|
|
1642
1644
|
});
|
|
1643
1645
|
const disabledAgents = new Set(config.disabled_agents);
|
|
1644
1646
|
const enabled = [];
|
|
@@ -3876,6 +3878,9 @@ function printResolvedSection() {
|
|
|
3876
3878
|
const hasOverlays = Object.keys(overlays.agents).length > 0 || Object.keys(overlays.categories).length > 0;
|
|
3877
3879
|
console.log(`
|
|
3878
3880
|
Resolved configuration:`);
|
|
3881
|
+
if (loaded.skippedProject !== undefined) {
|
|
3882
|
+
console.log(` Project config skipped: ${displaySafe(loaded.skippedProject.path)} (${displaySafe(loaded.skippedProject.reason)}). Its settings are not applied.`);
|
|
3883
|
+
}
|
|
3879
3884
|
if (!hasProfileSelection && !hasOverlays) {
|
|
3880
3885
|
console.log(" No profiles are selected and no per-agent/category overlays are defined.");
|
|
3881
3886
|
return true;
|
|
@@ -3938,6 +3943,9 @@ function buildConfigShowJson() {
|
|
|
3938
3943
|
}));
|
|
3939
3944
|
return {
|
|
3940
3945
|
locations,
|
|
3946
|
+
...loaded.skippedProject !== undefined && {
|
|
3947
|
+
projectSkipped: loaded.skippedProject
|
|
3948
|
+
},
|
|
3941
3949
|
activeProfile: loaded.metadata.activeProfile,
|
|
3942
3950
|
profileSelectorSource: loaded.metadata.profileSelectorSource,
|
|
3943
3951
|
activeProfileSourcePath: loaded.activeProfileSourcePath,
|
|
@@ -4002,14 +4010,43 @@ Search:`);
|
|
|
4002
4010
|
console.log(` ${kind.kind.padEnd(10)} ${kind.state.padEnd(10)} ${displaySafe(kind.directory)}`);
|
|
4003
4011
|
}
|
|
4004
4012
|
}
|
|
4005
|
-
function
|
|
4006
|
-
|
|
4013
|
+
function stripTerminalControls(text) {
|
|
4014
|
+
return text.replace(/\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)?/g, "").replace(/(?:\u001b\[|\u009b)[0-?]*[ -/]*[@-~]?/g, "").replace(/\u001b[@-Z\\-_]/g, "").replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g, "");
|
|
4015
|
+
}
|
|
4016
|
+
function isWithinRoot(root, target) {
|
|
4017
|
+
const relative = path6.relative(root, target);
|
|
4018
|
+
return relative !== ".." && !relative.startsWith(`..${path6.sep}`) && !path6.isAbsolute(relative);
|
|
4019
|
+
}
|
|
4020
|
+
function resolveProjectFileInRepository(filePath, projectRoot) {
|
|
4021
|
+
try {
|
|
4022
|
+
const realRoot = fs8.realpathSync(projectRoot);
|
|
4023
|
+
const realPath = fs8.realpathSync(filePath);
|
|
4024
|
+
return isWithinRoot(realRoot, realPath) ? { kind: "inside", realPath } : { kind: "withheld", reason: "it resolves outside the repository" };
|
|
4025
|
+
} catch {
|
|
4026
|
+
return { kind: "withheld", reason: "it could not be resolved" };
|
|
4027
|
+
}
|
|
4028
|
+
}
|
|
4029
|
+
function printConfigFile(heading, filePath, projectRoot) {
|
|
4030
|
+
let readPath = filePath;
|
|
4031
|
+
if (projectRoot !== undefined) {
|
|
4032
|
+
if (!configEntryExists(filePath))
|
|
4033
|
+
return;
|
|
4034
|
+
const contained = resolveProjectFileInRepository(filePath, projectRoot);
|
|
4035
|
+
if (contained.kind === "withheld") {
|
|
4036
|
+
console.log(`
|
|
4037
|
+
${heading}:`);
|
|
4038
|
+
console.log(` ${displaySafe(filePath)} is not shown: ${contained.reason}`);
|
|
4039
|
+
return;
|
|
4040
|
+
}
|
|
4041
|
+
readPath = contained.realPath;
|
|
4042
|
+
}
|
|
4043
|
+
const read = readTextBounded(readPath, MAX_PROJECT_CONFIG_BYTES);
|
|
4007
4044
|
if (read.kind === "absent")
|
|
4008
4045
|
return;
|
|
4009
4046
|
console.log(`
|
|
4010
4047
|
${heading}:`);
|
|
4011
4048
|
if (read.kind === "text") {
|
|
4012
|
-
console.log(read.content);
|
|
4049
|
+
console.log(projectRoot === undefined ? read.content : stripTerminalControls(read.content));
|
|
4013
4050
|
return;
|
|
4014
4051
|
}
|
|
4015
4052
|
console.log(` ${displaySafe(filePath)} could not be shown: ${read.reason}`);
|
|
@@ -4038,7 +4075,7 @@ function configShow(options) {
|
|
|
4038
4075
|
if (locations.customLocal !== null) {
|
|
4039
4076
|
console.log(` Custom local config: ${locations.customLocal}`);
|
|
4040
4077
|
}
|
|
4041
|
-
printConfigFile("Project configuration", paths.projectConfig);
|
|
4078
|
+
printConfigFile("Project configuration", paths.projectConfig, paths.projectRoot);
|
|
4042
4079
|
printConfigFile("User configuration", paths.userConfig);
|
|
4043
4080
|
const resolved = printResolvedSection();
|
|
4044
4081
|
printSearchSection(inspectSearchForConfigShow(paths));
|
|
@@ -8215,8 +8215,12 @@ function readSearchBlock(filePath, maxBytes) {
|
|
|
8215
8215
|
if (text.kind !== "text")
|
|
8216
8216
|
return text;
|
|
8217
8217
|
const content = text.content;
|
|
8218
|
+
if (maxBytes !== undefined && content.trim() === "")
|
|
8219
|
+
return { kind: "absent" };
|
|
8218
8220
|
const errors = [];
|
|
8219
|
-
const parsed = parse(content, errors
|
|
8221
|
+
const parsed = parse(content, errors, {
|
|
8222
|
+
allowTrailingComma: true
|
|
8223
|
+
});
|
|
8220
8224
|
const firstError = errors[0];
|
|
8221
8225
|
if (firstError) {
|
|
8222
8226
|
return {
|
|
@@ -9796,6 +9800,12 @@ function warnDroppedNames(dropped, field, warned, removalVersion, warningSink =
|
|
|
9796
9800
|
}
|
|
9797
9801
|
var OVERSIZED_FILE_REASON = `file is larger than ${MAX_PROJECT_CONFIG_BYTES / (1024 * 1024)} MB`;
|
|
9798
9802
|
var USER_LEVEL_CONFIG_MAX_BYTES = Number.POSITIVE_INFINITY;
|
|
9803
|
+
function configFileError(filePath, detail) {
|
|
9804
|
+
return Object.assign(new Error(`Invalid Systematic config in ${filePath}: ${detail}`), { detail });
|
|
9805
|
+
}
|
|
9806
|
+
function hasFailureDetail(error) {
|
|
9807
|
+
return error instanceof Error && typeof error.detail === "string";
|
|
9808
|
+
}
|
|
9799
9809
|
function readConfigText(filePath, maxBytes) {
|
|
9800
9810
|
const read = readBytesBounded(filePath, maxBytes);
|
|
9801
9811
|
switch (read.kind) {
|
|
@@ -9804,28 +9814,32 @@ function readConfigText(filePath, maxBytes) {
|
|
|
9804
9814
|
case "absent":
|
|
9805
9815
|
if (!configEntryExists(filePath))
|
|
9806
9816
|
return null;
|
|
9807
|
-
throw
|
|
9817
|
+
throw configFileError(filePath, "unable to read file");
|
|
9808
9818
|
case "too-large":
|
|
9809
|
-
throw
|
|
9819
|
+
throw configFileError(filePath, `unable to read file (${OVERSIZED_FILE_REASON})`);
|
|
9810
9820
|
case "not-regular":
|
|
9811
|
-
throw
|
|
9821
|
+
throw configFileError(filePath, "unable to read file (not a regular file)");
|
|
9812
9822
|
default:
|
|
9813
|
-
throw
|
|
9823
|
+
throw configFileError(filePath, "unable to read file");
|
|
9814
9824
|
}
|
|
9815
9825
|
}
|
|
9816
|
-
function loadJsoncFile(filePath, maxBytes) {
|
|
9826
|
+
function loadJsoncFile(filePath, maxBytes, emptyIsAbsent) {
|
|
9817
9827
|
const content = readConfigText(filePath, maxBytes);
|
|
9818
9828
|
if (content === null)
|
|
9819
9829
|
return null;
|
|
9830
|
+
if (emptyIsAbsent && content.trim() === "")
|
|
9831
|
+
return null;
|
|
9820
9832
|
const errors = [];
|
|
9821
|
-
const parsed = parse(content, errors
|
|
9833
|
+
const parsed = parse(content, errors, {
|
|
9834
|
+
allowTrailingComma: true
|
|
9835
|
+
});
|
|
9822
9836
|
if (errors.length > 0) {
|
|
9823
9837
|
const error = errors[0];
|
|
9824
9838
|
const message = error ? `${printParseErrorCode(error.error)} at offset ${error.offset}` : "unknown parse error";
|
|
9825
|
-
throw
|
|
9839
|
+
throw configFileError(filePath, `JSONC parse error: ${message}`);
|
|
9826
9840
|
}
|
|
9827
9841
|
if (!isRecord3(parsed)) {
|
|
9828
|
-
throw
|
|
9842
|
+
throw configFileError(filePath, "root must be an object");
|
|
9829
9843
|
}
|
|
9830
9844
|
return parsed;
|
|
9831
9845
|
}
|
|
@@ -9926,7 +9940,7 @@ function loadConfigSource(input) {
|
|
|
9926
9940
|
} = input;
|
|
9927
9941
|
const trust = LAYER_TRUST[layer];
|
|
9928
9942
|
try {
|
|
9929
|
-
const rawConfig = loadJsoncFile(filePath, layer === "project" ? MAX_PROJECT_CONFIG_BYTES : USER_LEVEL_CONFIG_MAX_BYTES);
|
|
9943
|
+
const rawConfig = loadJsoncFile(filePath, layer === "project" ? MAX_PROJECT_CONFIG_BYTES : USER_LEVEL_CONFIG_MAX_BYTES, layer === "project");
|
|
9930
9944
|
if (!rawConfig) {
|
|
9931
9945
|
return {
|
|
9932
9946
|
metadata: { kind: trust, presence: "absent" },
|
|
@@ -9959,10 +9973,12 @@ function loadConfigSource(input) {
|
|
|
9959
9973
|
if (invalidSource === "throw")
|
|
9960
9974
|
throw error;
|
|
9961
9975
|
const errorCode = classifyConfigSourceError(error);
|
|
9962
|
-
|
|
9976
|
+
const reason = describeConfigSourceFailure(error, errorCode);
|
|
9977
|
+
input.reportInvalid(filePath, errorCode, reason);
|
|
9963
9978
|
return {
|
|
9964
9979
|
metadata: { errorCode, kind: trust, presence: "invalid" },
|
|
9965
|
-
source: null
|
|
9980
|
+
source: null,
|
|
9981
|
+
failure: reason
|
|
9966
9982
|
};
|
|
9967
9983
|
}
|
|
9968
9984
|
}
|
|
@@ -9994,6 +10010,61 @@ function classifyConfigSourceError(error) {
|
|
|
9994
10010
|
function isConfigSchemaError(error) {
|
|
9995
10011
|
return isRecord3(error) && error._tag === "ConfigSchemaError";
|
|
9996
10012
|
}
|
|
10013
|
+
function schemaDefinition(node) {
|
|
10014
|
+
if (!isRecord3(node))
|
|
10015
|
+
return;
|
|
10016
|
+
const internals = node._zod;
|
|
10017
|
+
const definition = isRecord3(internals) ? internals.def : node.def;
|
|
10018
|
+
return isRecord3(definition) ? definition : undefined;
|
|
10019
|
+
}
|
|
10020
|
+
function unwrapSchemaNode(node) {
|
|
10021
|
+
let current = node;
|
|
10022
|
+
for (let depth = 0;depth < 16; depth += 1) {
|
|
10023
|
+
const definition = schemaDefinition(current);
|
|
10024
|
+
if (definition === undefined)
|
|
10025
|
+
return current;
|
|
10026
|
+
const inner = definition.innerType ?? definition.in;
|
|
10027
|
+
if (inner === undefined)
|
|
10028
|
+
return current;
|
|
10029
|
+
current = inner;
|
|
10030
|
+
}
|
|
10031
|
+
return current;
|
|
10032
|
+
}
|
|
10033
|
+
function redactedSchemaPath(path, root) {
|
|
10034
|
+
const segments = [];
|
|
10035
|
+
let node = root;
|
|
10036
|
+
for (const segment of path) {
|
|
10037
|
+
const definition = schemaDefinition(unwrapSchemaNode(node));
|
|
10038
|
+
const shape = definition?.type === "object" ? definition.shape : undefined;
|
|
10039
|
+
if (isRecord3(shape) && Object.hasOwn(shape, String(segment))) {
|
|
10040
|
+
segments.push(String(segment));
|
|
10041
|
+
node = shape[String(segment)];
|
|
10042
|
+
} else if (definition?.type === "array") {
|
|
10043
|
+
segments.push("<index>");
|
|
10044
|
+
node = definition.element;
|
|
10045
|
+
} else {
|
|
10046
|
+
segments.push("<key>");
|
|
10047
|
+
node = definition?.type === "record" ? definition.valueType : undefined;
|
|
10048
|
+
}
|
|
10049
|
+
}
|
|
10050
|
+
return segments;
|
|
10051
|
+
}
|
|
10052
|
+
function describeConfigSourceFailure(error, code) {
|
|
10053
|
+
if (isConfigSchemaError(error)) {
|
|
10054
|
+
const [issue] = error.issues;
|
|
10055
|
+
if (issue === undefined)
|
|
10056
|
+
return "schema validation failed";
|
|
10057
|
+
const segments = redactedSchemaPath(issue.path, SystematicConfigSchema);
|
|
10058
|
+
const where = sanitizeDiagnosticText(segments.join("."));
|
|
10059
|
+
if (issue.code === "unrecognized_keys") {
|
|
10060
|
+
return segments.length === 0 ? "schema validation failed: unrecognized key at the top level" : `schema validation failed: unrecognized key under \`${where}\``;
|
|
10061
|
+
}
|
|
10062
|
+
return segments.length === 0 ? "schema validation failed" : `schema validation failed at \`${where}\``;
|
|
10063
|
+
}
|
|
10064
|
+
if (hasFailureDetail(error))
|
|
10065
|
+
return error.detail;
|
|
10066
|
+
return code;
|
|
10067
|
+
}
|
|
9997
10068
|
function resolveConfigSourcePath(filePath) {
|
|
9998
10069
|
try {
|
|
9999
10070
|
return fs5.realpathSync(filePath);
|
|
@@ -10314,6 +10385,15 @@ function createInvalidFileReporter(warningSink) {
|
|
|
10314
10385
|
warningSink(`[systematic] config file (${sanitizeDiagnosticText(filePath)}) is invalid (${code}) and was not loaded.`);
|
|
10315
10386
|
};
|
|
10316
10387
|
}
|
|
10388
|
+
var skippedProjectNotices = new Set;
|
|
10389
|
+
function noticeSkippedProjectConfig(filePath, reason, warningSink) {
|
|
10390
|
+
const identity = `${resolveConfigSourcePath(filePath)}\x00${reason}`;
|
|
10391
|
+
if (skippedProjectNotices.has(identity))
|
|
10392
|
+
return;
|
|
10393
|
+
skippedProjectNotices.add(identity);
|
|
10394
|
+
warningSink(`[systematic] project config (${sanitizeDiagnosticText(filePath)}) was skipped: ${reason}. None of its settings were loaded. Fix the file to apply them.`);
|
|
10395
|
+
}
|
|
10396
|
+
var PROJECT_CONFIG_MERGE_FAILURE_REASON = "it could not be combined with the other config layers";
|
|
10317
10397
|
function reassignLayer(loaded, layer) {
|
|
10318
10398
|
const trust = LAYER_TRUST[layer];
|
|
10319
10399
|
return {
|
|
@@ -10401,10 +10481,60 @@ function mergeBootstrap(sources) {
|
|
|
10401
10481
|
return merged;
|
|
10402
10482
|
}
|
|
10403
10483
|
function loadConfigWithSources(projectDir, options) {
|
|
10484
|
+
const warningSink = options?.warningSink ?? console.warn;
|
|
10485
|
+
if (!(options?.includeProject ?? true) || options?.projectFailure === "throw") {
|
|
10486
|
+
return loadConfigLayers(projectDir, options, {
|
|
10487
|
+
warningSink,
|
|
10488
|
+
projectContributed: false
|
|
10489
|
+
});
|
|
10490
|
+
}
|
|
10491
|
+
const held = [];
|
|
10492
|
+
const flush = (messages) => {
|
|
10493
|
+
for (const message of messages)
|
|
10494
|
+
warningSink(message);
|
|
10495
|
+
};
|
|
10496
|
+
const attempt = {
|
|
10497
|
+
warningSink: (message) => {
|
|
10498
|
+
held.push(message);
|
|
10499
|
+
},
|
|
10500
|
+
projectContributed: false
|
|
10501
|
+
};
|
|
10502
|
+
try {
|
|
10503
|
+
const result = loadConfigLayers(projectDir, options, attempt);
|
|
10504
|
+
flush(held);
|
|
10505
|
+
return result;
|
|
10506
|
+
} catch (error) {
|
|
10507
|
+
if (!attempt.projectContributed) {
|
|
10508
|
+
flush(held);
|
|
10509
|
+
throw error;
|
|
10510
|
+
}
|
|
10511
|
+
const retryHeld = [];
|
|
10512
|
+
let retried;
|
|
10513
|
+
try {
|
|
10514
|
+
retried = loadConfigLayers(projectDir, options, {
|
|
10515
|
+
warningSink: (message) => {
|
|
10516
|
+
retryHeld.push(message);
|
|
10517
|
+
},
|
|
10518
|
+
omitProjectBecause: PROJECT_CONFIG_MERGE_FAILURE_REASON,
|
|
10519
|
+
projectContributed: false
|
|
10520
|
+
});
|
|
10521
|
+
} catch {
|
|
10522
|
+
flush(held);
|
|
10523
|
+
throw error;
|
|
10524
|
+
}
|
|
10525
|
+
flush(retryHeld);
|
|
10526
|
+
if (retried.skippedProject) {
|
|
10527
|
+
noticeSkippedProjectConfig(retried.skippedProject.path, retried.skippedProject.reason, warningSink);
|
|
10528
|
+
}
|
|
10529
|
+
return retried;
|
|
10530
|
+
}
|
|
10531
|
+
}
|
|
10532
|
+
function loadConfigLayers(projectDir, options, attempt) {
|
|
10404
10533
|
const includeProject = options?.includeProject ?? true;
|
|
10405
10534
|
const invalidSource = options?.invalidSource ?? "throw";
|
|
10535
|
+
const projectFailure = options?.projectFailure ?? "skip";
|
|
10406
10536
|
const paths = getConfigPaths(projectDir, options);
|
|
10407
|
-
const warningSink =
|
|
10537
|
+
const warningSink = attempt.warningSink;
|
|
10408
10538
|
const reportInvalid = createInvalidFileReporter(warningSink);
|
|
10409
10539
|
if (includeProject)
|
|
10410
10540
|
emitProjectLocationWarnings(paths, warningSink);
|
|
@@ -10422,19 +10552,17 @@ function loadConfigWithSources(projectDir, options) {
|
|
|
10422
10552
|
const homeDir = resolveUserLevelConfigDirs(options).homeDir || os3.homedir();
|
|
10423
10553
|
const projectAllowed = () => isAllowedProject(resolveProjectIdentity(paths.projectRoot), mergedSearch.settings?.allow_project_sources ?? [], { homeDir });
|
|
10424
10554
|
const aliasLoaded = aliasedFiles.some(({ layer }) => userLevel[USER_LEVEL_SLOT[layer]].source !== null);
|
|
10425
|
-
const project =
|
|
10426
|
-
|
|
10427
|
-
|
|
10428
|
-
|
|
10429
|
-
|
|
10430
|
-
|
|
10555
|
+
const project = loadProjectSource({
|
|
10556
|
+
attempt,
|
|
10557
|
+
includeProject,
|
|
10558
|
+
paths,
|
|
10559
|
+
projectFailure,
|
|
10560
|
+
stripSink: boundedProjectStrip.sink,
|
|
10431
10561
|
allowProjectProfiles,
|
|
10432
10562
|
projectAllowed
|
|
10433
|
-
})
|
|
10434
|
-
metadata: { kind: "project", presence: "absent" },
|
|
10435
|
-
source: null
|
|
10436
|
-
};
|
|
10563
|
+
});
|
|
10437
10564
|
const projectSource = project.source;
|
|
10565
|
+
attempt.projectContributed = projectSource !== null;
|
|
10438
10566
|
emitTopLevelProtectedFieldWarning(projectSource, "profiles", `\`profiles\` in project config (%PATH%) is only valid in user config or OPENCODE_CONFIG_DIR config and has been ignored. Its bundles are not selectable even if this project also sets \`profile\`.`, boundedProjectStrip.sink);
|
|
10439
10567
|
emitTopLevelProtectedFieldWarning(projectSource, "allow_project_profiles", `\`allow_project_profiles\` in project config (%PATH%) is only valid in user config or OPENCODE_CONFIG_DIR config and has been ignored.`, boundedProjectStrip.sink);
|
|
10440
10568
|
emitProjectSearchProtectedWarnings(projectSource, boundedProjectStrip.sink);
|
|
@@ -10537,9 +10665,46 @@ function loadConfigWithSources(projectDir, options) {
|
|
|
10537
10665
|
}),
|
|
10538
10666
|
overlays,
|
|
10539
10667
|
piSubagentsOverlays: mergedPiSubagentsOverlays,
|
|
10540
|
-
activeProfileSourcePath: profileSelection.bundleSource?.path ?? null
|
|
10668
|
+
activeProfileSourcePath: profileSelection.bundleSource?.path ?? null,
|
|
10669
|
+
...project.failure !== undefined && {
|
|
10670
|
+
skippedProject: { path: paths.projectConfig, reason: project.failure }
|
|
10671
|
+
}
|
|
10541
10672
|
};
|
|
10542
10673
|
}
|
|
10674
|
+
function loadProjectSource(input) {
|
|
10675
|
+
const { attempt, paths } = input;
|
|
10676
|
+
if (!input.includeProject) {
|
|
10677
|
+
return { metadata: { kind: "project", presence: "absent" }, source: null };
|
|
10678
|
+
}
|
|
10679
|
+
if (attempt.omitProjectBecause !== undefined) {
|
|
10680
|
+
return {
|
|
10681
|
+
metadata: {
|
|
10682
|
+
errorCode: "source-invalid",
|
|
10683
|
+
kind: "project",
|
|
10684
|
+
presence: "invalid"
|
|
10685
|
+
},
|
|
10686
|
+
source: null,
|
|
10687
|
+
failure: attempt.omitProjectBecause
|
|
10688
|
+
};
|
|
10689
|
+
}
|
|
10690
|
+
const held = [];
|
|
10691
|
+
const loaded = loadConfigSource({
|
|
10692
|
+
filePath: paths.projectConfig,
|
|
10693
|
+
layer: "project",
|
|
10694
|
+
invalidSource: input.projectFailure === "throw" ? "throw" : "report",
|
|
10695
|
+
warningSink: (message) => {
|
|
10696
|
+
held.push(message);
|
|
10697
|
+
},
|
|
10698
|
+
reportInvalid: (filePath, _code, reason) => noticeSkippedProjectConfig(filePath, reason, attempt.warningSink),
|
|
10699
|
+
allowProjectProfiles: input.allowProjectProfiles,
|
|
10700
|
+
projectAllowed: input.projectAllowed
|
|
10701
|
+
});
|
|
10702
|
+
if (loaded.source !== null) {
|
|
10703
|
+
for (const message of held)
|
|
10704
|
+
input.stripSink(message);
|
|
10705
|
+
}
|
|
10706
|
+
return loaded;
|
|
10707
|
+
}
|
|
10543
10708
|
function mergeUserLevelSearch(userLevel) {
|
|
10544
10709
|
return mergeSearchSettings(["user", "userLocal", "custom", "customLocal"].flatMap((slot) => {
|
|
10545
10710
|
const source = userLevel[slot].source;
|
|
@@ -13183,4 +13348,4 @@ async function runExternalSearch(checked, options) {
|
|
|
13183
13348
|
};
|
|
13184
13349
|
}
|
|
13185
13350
|
|
|
13186
|
-
export { parseFrontmatter, parse, parseTree, modify, applyEdits, CONFIG_PROTECTED_FIELD_PATHS, _isoDateTime, _isoDate, _isoTime, _isoDuration, string, ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration, number, boolean, array, object, union, discriminatedUnion, _enum, literal, displaySafe, MAX_PROJECT_CONFIG_BYTES, readTextBounded, loadUserLevelSearchSettings, AgentOverlaySchema, CategoryOverlaySchema, isRecord, isPermissionSetting, isAgentMode, extractString, toSourcedPiSubagentsOverlays, resolveRouting, loadConfig, loadConfigWithSources, isAgentDisabled, collectRoutingTargets, getConfigPaths, isDiscoverableMarkdown, findAgentsInDir, extractAgentFrontmatter, findCommandsInDir, extractCommandFrontmatter, findSkillsInDir, discoverSkills, inspectSearch, SEARCH_TOOL_NAME, SEARCH_ARGS, MIN_LIMIT, MAX_LIMIT, KIND_SELECTOR_EXTERNAL, SEARCH_TOOL_DESCRIPTION, SEARCH_ARG_DESCRIPTIONS, SEARCH_NOTICES, SEARCH_CONFIG_UNREADABLE_NOTE, runSearch };
|
|
13351
|
+
export { parseFrontmatter, parse, parseTree, modify, applyEdits, CONFIG_PROTECTED_FIELD_PATHS, _isoDateTime, _isoDate, _isoTime, _isoDuration, string, ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration, number, boolean, array, object, union, discriminatedUnion, _enum, literal, displaySafe, configEntryExists, MAX_PROJECT_CONFIG_BYTES, readTextBounded, loadUserLevelSearchSettings, AgentOverlaySchema, CategoryOverlaySchema, isRecord, isPermissionSetting, isAgentMode, extractString, toSourcedPiSubagentsOverlays, resolveRouting, loadConfig, loadConfigWithSources, isAgentDisabled, collectRoutingTargets, getConfigPaths, isDiscoverableMarkdown, findAgentsInDir, extractAgentFrontmatter, findCommandsInDir, extractCommandFrontmatter, findSkillsInDir, discoverSkills, inspectSearch, SEARCH_TOOL_NAME, SEARCH_ARGS, MIN_LIMIT, MAX_LIMIT, KIND_SELECTOR_EXTERNAL, SEARCH_TOOL_DESCRIPTION, SEARCH_ARG_DESCRIPTIONS, SEARCH_NOTICES, SEARCH_CONFIG_UNREADABLE_NOTE, runSearch };
|
package/dist/index.js
CHANGED
package/dist/lib/config.d.ts
CHANGED
|
@@ -158,6 +158,16 @@ export interface SourceAwareConfigResult {
|
|
|
158
158
|
* for a symlinked config directory.
|
|
159
159
|
*/
|
|
160
160
|
activeProfileSourcePath: string | null;
|
|
161
|
+
/**
|
|
162
|
+
* Set when the project config file was not loaded because it failed, on its
|
|
163
|
+
* own or in combination with the other layers. `reason` holds no value and no
|
|
164
|
+
* file content. Deliberately not on `ConfigObservationMetadata`, for the same
|
|
165
|
+
* reason as `activeProfileSourcePath`.
|
|
166
|
+
*/
|
|
167
|
+
skippedProject?: {
|
|
168
|
+
readonly path: string;
|
|
169
|
+
readonly reason: string;
|
|
170
|
+
};
|
|
161
171
|
}
|
|
162
172
|
export interface PiSubagentsOverlayMap {
|
|
163
173
|
categories?: OverlayConfigMap;
|
|
@@ -214,13 +224,35 @@ export interface LoadConfigOptions {
|
|
|
214
224
|
* start directory (see `getConfigPaths`).
|
|
215
225
|
*/
|
|
216
226
|
includeProject?: boolean;
|
|
227
|
+
/** What a failing user, user.local, custom or custom.local file does. Defaults to `throw`. The project file follows `projectFailure`. */
|
|
217
228
|
invalidSource?: 'throw' | 'report';
|
|
229
|
+
/**
|
|
230
|
+
* What a failing project file does. `skip` (the default) leaves the file out
|
|
231
|
+
* with one warning, so a repository's config cannot take the plugin down.
|
|
232
|
+
* `throw` makes it fatal, for a caller that writes into the repository.
|
|
233
|
+
*/
|
|
234
|
+
projectFailure?: 'skip' | 'throw';
|
|
218
235
|
homeDir?: string;
|
|
219
236
|
userConfigDir?: string;
|
|
220
237
|
customConfigDir?: string | null;
|
|
221
238
|
warningSink?: (message: string) => void;
|
|
222
239
|
}
|
|
223
240
|
export declare function loadConfig(projectDir: string, options?: LoadConfigOptions): SystematicConfig;
|
|
241
|
+
/** Forget which skipped project files were reported. For tests. */
|
|
242
|
+
export declare function resetSkippedProjectConfigNotices(): void;
|
|
243
|
+
/**
|
|
244
|
+
* Load every config layer into one config.
|
|
245
|
+
*
|
|
246
|
+
* User, user.local, custom and custom.local files are strict: a broken one
|
|
247
|
+
* throws. The project file comes from a repository, so by default it never
|
|
248
|
+
* takes the plugin down. A file that fails on its own (it cannot be read,
|
|
249
|
+
* is over the size cap, is not valid JSONC, or fails the schema) is skipped
|
|
250
|
+
* with one warning. A project file that loads alone but breaks the load once
|
|
251
|
+
* merged with the other layers is skipped the same way: the load is retried
|
|
252
|
+
* without it, and the original error stands if the retry fails too.
|
|
253
|
+
* `projectFailure: 'throw'` makes any project failure fatal instead, for a
|
|
254
|
+
* caller that writes into the repository and must not act on a partial view.
|
|
255
|
+
*/
|
|
224
256
|
export declare function loadConfigWithSources(projectDir: string, options?: LoadConfigOptions): SourceAwareConfigResult;
|
|
225
257
|
/**
|
|
226
258
|
* Whether a bundled persona is disabled by config, for harnesses that filter
|
|
@@ -12,8 +12,10 @@ export interface FrontmatterResult<T = Record<string, unknown>> {
|
|
|
12
12
|
* returned verbatim as part of the block — callers that scan individual lines
|
|
13
13
|
* (e.g. parse-safety checks) must skip indented lines themselves.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* The closing `---` must be a whole line, matching {@link parseFrontmatter}: a
|
|
16
|
+
* value that merely contains or ends in `---` (`title: a---b`) cannot close the
|
|
17
|
+
* block. Handles LF and CRLF line endings. The closing `---` does not need a
|
|
18
|
+
* trailing newline (handles files that end immediately after the delimiter).
|
|
17
19
|
*/
|
|
18
20
|
export declare function extractFrontmatterBlock(content: string): string | null;
|
|
19
21
|
/**
|
package/dist/pi.js
CHANGED
|
@@ -11116,8 +11116,12 @@ function readSearchBlock(filePath, maxBytes) {
|
|
|
11116
11116
|
if (text.kind !== "text")
|
|
11117
11117
|
return text;
|
|
11118
11118
|
const content = text.content;
|
|
11119
|
+
if (maxBytes !== undefined && content.trim() === "")
|
|
11120
|
+
return { kind: "absent" };
|
|
11119
11121
|
const errors = [];
|
|
11120
|
-
const parsed = parseJsonc(content, errors
|
|
11122
|
+
const parsed = parseJsonc(content, errors, {
|
|
11123
|
+
allowTrailingComma: true
|
|
11124
|
+
});
|
|
11121
11125
|
const firstError = errors[0];
|
|
11122
11126
|
if (firstError) {
|
|
11123
11127
|
return {
|
|
@@ -13495,6 +13499,12 @@ function warnDroppedNames(dropped, field, warned, removalVersion, warningSink =
|
|
|
13495
13499
|
}
|
|
13496
13500
|
var OVERSIZED_FILE_REASON = `file is larger than ${MAX_PROJECT_CONFIG_BYTES / (1024 * 1024)} MB`;
|
|
13497
13501
|
var USER_LEVEL_CONFIG_MAX_BYTES = Number.POSITIVE_INFINITY;
|
|
13502
|
+
function configFileError(filePath, detail) {
|
|
13503
|
+
return Object.assign(new Error(`Invalid Systematic config in ${filePath}: ${detail}`), { detail });
|
|
13504
|
+
}
|
|
13505
|
+
function hasFailureDetail(error) {
|
|
13506
|
+
return error instanceof Error && typeof error.detail === "string";
|
|
13507
|
+
}
|
|
13498
13508
|
function readConfigText(filePath, maxBytes) {
|
|
13499
13509
|
const read = readBytesBounded(filePath, maxBytes);
|
|
13500
13510
|
switch (read.kind) {
|
|
@@ -13503,28 +13513,32 @@ function readConfigText(filePath, maxBytes) {
|
|
|
13503
13513
|
case "absent":
|
|
13504
13514
|
if (!configEntryExists(filePath))
|
|
13505
13515
|
return null;
|
|
13506
|
-
throw
|
|
13516
|
+
throw configFileError(filePath, "unable to read file");
|
|
13507
13517
|
case "too-large":
|
|
13508
|
-
throw
|
|
13518
|
+
throw configFileError(filePath, `unable to read file (${OVERSIZED_FILE_REASON})`);
|
|
13509
13519
|
case "not-regular":
|
|
13510
|
-
throw
|
|
13520
|
+
throw configFileError(filePath, "unable to read file (not a regular file)");
|
|
13511
13521
|
default:
|
|
13512
|
-
throw
|
|
13522
|
+
throw configFileError(filePath, "unable to read file");
|
|
13513
13523
|
}
|
|
13514
13524
|
}
|
|
13515
|
-
function loadJsoncFile(filePath, maxBytes) {
|
|
13525
|
+
function loadJsoncFile(filePath, maxBytes, emptyIsAbsent) {
|
|
13516
13526
|
const content = readConfigText(filePath, maxBytes);
|
|
13517
13527
|
if (content === null)
|
|
13518
13528
|
return null;
|
|
13529
|
+
if (emptyIsAbsent && content.trim() === "")
|
|
13530
|
+
return null;
|
|
13519
13531
|
const errors = [];
|
|
13520
|
-
const parsed = parseJsonc2(content, errors
|
|
13532
|
+
const parsed = parseJsonc2(content, errors, {
|
|
13533
|
+
allowTrailingComma: true
|
|
13534
|
+
});
|
|
13521
13535
|
if (errors.length > 0) {
|
|
13522
13536
|
const error = errors[0];
|
|
13523
13537
|
const message = error ? `${printParseErrorCode2(error.error)} at offset ${error.offset}` : "unknown parse error";
|
|
13524
|
-
throw
|
|
13538
|
+
throw configFileError(filePath, `JSONC parse error: ${message}`);
|
|
13525
13539
|
}
|
|
13526
13540
|
if (!isRecord3(parsed)) {
|
|
13527
|
-
throw
|
|
13541
|
+
throw configFileError(filePath, "root must be an object");
|
|
13528
13542
|
}
|
|
13529
13543
|
return parsed;
|
|
13530
13544
|
}
|
|
@@ -13625,7 +13639,7 @@ function loadConfigSource(input) {
|
|
|
13625
13639
|
} = input;
|
|
13626
13640
|
const trust = LAYER_TRUST[layer];
|
|
13627
13641
|
try {
|
|
13628
|
-
const rawConfig = loadJsoncFile(filePath, layer === "project" ? MAX_PROJECT_CONFIG_BYTES : USER_LEVEL_CONFIG_MAX_BYTES);
|
|
13642
|
+
const rawConfig = loadJsoncFile(filePath, layer === "project" ? MAX_PROJECT_CONFIG_BYTES : USER_LEVEL_CONFIG_MAX_BYTES, layer === "project");
|
|
13629
13643
|
if (!rawConfig) {
|
|
13630
13644
|
return {
|
|
13631
13645
|
metadata: { kind: trust, presence: "absent" },
|
|
@@ -13658,10 +13672,12 @@ function loadConfigSource(input) {
|
|
|
13658
13672
|
if (invalidSource === "throw")
|
|
13659
13673
|
throw error;
|
|
13660
13674
|
const errorCode = classifyConfigSourceError(error);
|
|
13661
|
-
|
|
13675
|
+
const reason = describeConfigSourceFailure(error, errorCode);
|
|
13676
|
+
input.reportInvalid(filePath, errorCode, reason);
|
|
13662
13677
|
return {
|
|
13663
13678
|
metadata: { errorCode, kind: trust, presence: "invalid" },
|
|
13664
|
-
source: null
|
|
13679
|
+
source: null,
|
|
13680
|
+
failure: reason
|
|
13665
13681
|
};
|
|
13666
13682
|
}
|
|
13667
13683
|
}
|
|
@@ -13693,6 +13709,61 @@ function classifyConfigSourceError(error) {
|
|
|
13693
13709
|
function isConfigSchemaError(error) {
|
|
13694
13710
|
return isRecord3(error) && error._tag === "ConfigSchemaError";
|
|
13695
13711
|
}
|
|
13712
|
+
function schemaDefinition(node) {
|
|
13713
|
+
if (!isRecord3(node))
|
|
13714
|
+
return;
|
|
13715
|
+
const internals = node._zod;
|
|
13716
|
+
const definition = isRecord3(internals) ? internals.def : node.def;
|
|
13717
|
+
return isRecord3(definition) ? definition : undefined;
|
|
13718
|
+
}
|
|
13719
|
+
function unwrapSchemaNode(node) {
|
|
13720
|
+
let current = node;
|
|
13721
|
+
for (let depth = 0;depth < 16; depth += 1) {
|
|
13722
|
+
const definition = schemaDefinition(current);
|
|
13723
|
+
if (definition === undefined)
|
|
13724
|
+
return current;
|
|
13725
|
+
const inner = definition.innerType ?? definition.in;
|
|
13726
|
+
if (inner === undefined)
|
|
13727
|
+
return current;
|
|
13728
|
+
current = inner;
|
|
13729
|
+
}
|
|
13730
|
+
return current;
|
|
13731
|
+
}
|
|
13732
|
+
function redactedSchemaPath(path, root) {
|
|
13733
|
+
const segments = [];
|
|
13734
|
+
let node = root;
|
|
13735
|
+
for (const segment of path) {
|
|
13736
|
+
const definition = schemaDefinition(unwrapSchemaNode(node));
|
|
13737
|
+
const shape = definition?.type === "object" ? definition.shape : undefined;
|
|
13738
|
+
if (isRecord3(shape) && Object.hasOwn(shape, String(segment))) {
|
|
13739
|
+
segments.push(String(segment));
|
|
13740
|
+
node = shape[String(segment)];
|
|
13741
|
+
} else if (definition?.type === "array") {
|
|
13742
|
+
segments.push("<index>");
|
|
13743
|
+
node = definition.element;
|
|
13744
|
+
} else {
|
|
13745
|
+
segments.push("<key>");
|
|
13746
|
+
node = definition?.type === "record" ? definition.valueType : undefined;
|
|
13747
|
+
}
|
|
13748
|
+
}
|
|
13749
|
+
return segments;
|
|
13750
|
+
}
|
|
13751
|
+
function describeConfigSourceFailure(error, code) {
|
|
13752
|
+
if (isConfigSchemaError(error)) {
|
|
13753
|
+
const [issue] = error.issues;
|
|
13754
|
+
if (issue === undefined)
|
|
13755
|
+
return "schema validation failed";
|
|
13756
|
+
const segments = redactedSchemaPath(issue.path, SystematicConfigSchema);
|
|
13757
|
+
const where = sanitizeDiagnosticText(segments.join("."));
|
|
13758
|
+
if (issue.code === "unrecognized_keys") {
|
|
13759
|
+
return segments.length === 0 ? "schema validation failed: unrecognized key at the top level" : `schema validation failed: unrecognized key under \`${where}\``;
|
|
13760
|
+
}
|
|
13761
|
+
return segments.length === 0 ? "schema validation failed" : `schema validation failed at \`${where}\``;
|
|
13762
|
+
}
|
|
13763
|
+
if (hasFailureDetail(error))
|
|
13764
|
+
return error.detail;
|
|
13765
|
+
return code;
|
|
13766
|
+
}
|
|
13696
13767
|
function resolveConfigSourcePath(filePath) {
|
|
13697
13768
|
try {
|
|
13698
13769
|
return fs10.realpathSync(filePath);
|
|
@@ -14010,6 +14081,15 @@ function createInvalidFileReporter(warningSink) {
|
|
|
14010
14081
|
warningSink(`[systematic] config file (${sanitizeDiagnosticText(filePath)}) is invalid (${code}) and was not loaded.`);
|
|
14011
14082
|
};
|
|
14012
14083
|
}
|
|
14084
|
+
var skippedProjectNotices = new Set;
|
|
14085
|
+
function noticeSkippedProjectConfig(filePath, reason, warningSink) {
|
|
14086
|
+
const identity = `${resolveConfigSourcePath(filePath)}\x00${reason}`;
|
|
14087
|
+
if (skippedProjectNotices.has(identity))
|
|
14088
|
+
return;
|
|
14089
|
+
skippedProjectNotices.add(identity);
|
|
14090
|
+
warningSink(`[systematic] project config (${sanitizeDiagnosticText(filePath)}) was skipped: ${reason}. None of its settings were loaded. Fix the file to apply them.`);
|
|
14091
|
+
}
|
|
14092
|
+
var PROJECT_CONFIG_MERGE_FAILURE_REASON = "it could not be combined with the other config layers";
|
|
14013
14093
|
function reassignLayer(loaded, layer) {
|
|
14014
14094
|
const trust = LAYER_TRUST[layer];
|
|
14015
14095
|
return {
|
|
@@ -14097,10 +14177,60 @@ function mergeBootstrap(sources) {
|
|
|
14097
14177
|
return merged;
|
|
14098
14178
|
}
|
|
14099
14179
|
function loadConfigWithSources(projectDir, options) {
|
|
14180
|
+
const warningSink = options?.warningSink ?? console.warn;
|
|
14181
|
+
if (!(options?.includeProject ?? true) || options?.projectFailure === "throw") {
|
|
14182
|
+
return loadConfigLayers(projectDir, options, {
|
|
14183
|
+
warningSink,
|
|
14184
|
+
projectContributed: false
|
|
14185
|
+
});
|
|
14186
|
+
}
|
|
14187
|
+
const held = [];
|
|
14188
|
+
const flush = (messages) => {
|
|
14189
|
+
for (const message of messages)
|
|
14190
|
+
warningSink(message);
|
|
14191
|
+
};
|
|
14192
|
+
const attempt = {
|
|
14193
|
+
warningSink: (message) => {
|
|
14194
|
+
held.push(message);
|
|
14195
|
+
},
|
|
14196
|
+
projectContributed: false
|
|
14197
|
+
};
|
|
14198
|
+
try {
|
|
14199
|
+
const result = loadConfigLayers(projectDir, options, attempt);
|
|
14200
|
+
flush(held);
|
|
14201
|
+
return result;
|
|
14202
|
+
} catch (error) {
|
|
14203
|
+
if (!attempt.projectContributed) {
|
|
14204
|
+
flush(held);
|
|
14205
|
+
throw error;
|
|
14206
|
+
}
|
|
14207
|
+
const retryHeld = [];
|
|
14208
|
+
let retried;
|
|
14209
|
+
try {
|
|
14210
|
+
retried = loadConfigLayers(projectDir, options, {
|
|
14211
|
+
warningSink: (message) => {
|
|
14212
|
+
retryHeld.push(message);
|
|
14213
|
+
},
|
|
14214
|
+
omitProjectBecause: PROJECT_CONFIG_MERGE_FAILURE_REASON,
|
|
14215
|
+
projectContributed: false
|
|
14216
|
+
});
|
|
14217
|
+
} catch {
|
|
14218
|
+
flush(held);
|
|
14219
|
+
throw error;
|
|
14220
|
+
}
|
|
14221
|
+
flush(retryHeld);
|
|
14222
|
+
if (retried.skippedProject) {
|
|
14223
|
+
noticeSkippedProjectConfig(retried.skippedProject.path, retried.skippedProject.reason, warningSink);
|
|
14224
|
+
}
|
|
14225
|
+
return retried;
|
|
14226
|
+
}
|
|
14227
|
+
}
|
|
14228
|
+
function loadConfigLayers(projectDir, options, attempt) {
|
|
14100
14229
|
const includeProject = options?.includeProject ?? true;
|
|
14101
14230
|
const invalidSource = options?.invalidSource ?? "throw";
|
|
14231
|
+
const projectFailure = options?.projectFailure ?? "skip";
|
|
14102
14232
|
const paths = getConfigPaths(projectDir, options);
|
|
14103
|
-
const warningSink =
|
|
14233
|
+
const warningSink = attempt.warningSink;
|
|
14104
14234
|
const reportInvalid = createInvalidFileReporter(warningSink);
|
|
14105
14235
|
if (includeProject)
|
|
14106
14236
|
emitProjectLocationWarnings(paths, warningSink);
|
|
@@ -14118,19 +14248,17 @@ function loadConfigWithSources(projectDir, options) {
|
|
|
14118
14248
|
const homeDir = resolveUserLevelConfigDirs(options).homeDir || os5.homedir();
|
|
14119
14249
|
const projectAllowed = () => isAllowedProject(resolveProjectIdentity(paths.projectRoot), mergedSearch.settings?.allow_project_sources ?? [], { homeDir });
|
|
14120
14250
|
const aliasLoaded = aliasedFiles.some(({ layer }) => userLevel[USER_LEVEL_SLOT[layer]].source !== null);
|
|
14121
|
-
const project =
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14251
|
+
const project = loadProjectSource({
|
|
14252
|
+
attempt,
|
|
14253
|
+
includeProject,
|
|
14254
|
+
paths,
|
|
14255
|
+
projectFailure,
|
|
14256
|
+
stripSink: boundedProjectStrip.sink,
|
|
14127
14257
|
allowProjectProfiles,
|
|
14128
14258
|
projectAllowed
|
|
14129
|
-
})
|
|
14130
|
-
metadata: { kind: "project", presence: "absent" },
|
|
14131
|
-
source: null
|
|
14132
|
-
};
|
|
14259
|
+
});
|
|
14133
14260
|
const projectSource = project.source;
|
|
14261
|
+
attempt.projectContributed = projectSource !== null;
|
|
14134
14262
|
emitTopLevelProtectedFieldWarning(projectSource, "profiles", `\`profiles\` in project config (%PATH%) is only valid in user config or OPENCODE_CONFIG_DIR config and has been ignored. Its bundles are not selectable even if this project also sets \`profile\`.`, boundedProjectStrip.sink);
|
|
14135
14263
|
emitTopLevelProtectedFieldWarning(projectSource, "allow_project_profiles", `\`allow_project_profiles\` in project config (%PATH%) is only valid in user config or OPENCODE_CONFIG_DIR config and has been ignored.`, boundedProjectStrip.sink);
|
|
14136
14264
|
emitProjectSearchProtectedWarnings(projectSource, boundedProjectStrip.sink);
|
|
@@ -14233,9 +14361,46 @@ function loadConfigWithSources(projectDir, options) {
|
|
|
14233
14361
|
}),
|
|
14234
14362
|
overlays,
|
|
14235
14363
|
piSubagentsOverlays: mergedPiSubagentsOverlays,
|
|
14236
|
-
activeProfileSourcePath: profileSelection.bundleSource?.path ?? null
|
|
14364
|
+
activeProfileSourcePath: profileSelection.bundleSource?.path ?? null,
|
|
14365
|
+
...project.failure !== undefined && {
|
|
14366
|
+
skippedProject: { path: paths.projectConfig, reason: project.failure }
|
|
14367
|
+
}
|
|
14237
14368
|
};
|
|
14238
14369
|
}
|
|
14370
|
+
function loadProjectSource(input) {
|
|
14371
|
+
const { attempt, paths } = input;
|
|
14372
|
+
if (!input.includeProject) {
|
|
14373
|
+
return { metadata: { kind: "project", presence: "absent" }, source: null };
|
|
14374
|
+
}
|
|
14375
|
+
if (attempt.omitProjectBecause !== undefined) {
|
|
14376
|
+
return {
|
|
14377
|
+
metadata: {
|
|
14378
|
+
errorCode: "source-invalid",
|
|
14379
|
+
kind: "project",
|
|
14380
|
+
presence: "invalid"
|
|
14381
|
+
},
|
|
14382
|
+
source: null,
|
|
14383
|
+
failure: attempt.omitProjectBecause
|
|
14384
|
+
};
|
|
14385
|
+
}
|
|
14386
|
+
const held = [];
|
|
14387
|
+
const loaded = loadConfigSource({
|
|
14388
|
+
filePath: paths.projectConfig,
|
|
14389
|
+
layer: "project",
|
|
14390
|
+
invalidSource: input.projectFailure === "throw" ? "throw" : "report",
|
|
14391
|
+
warningSink: (message) => {
|
|
14392
|
+
held.push(message);
|
|
14393
|
+
},
|
|
14394
|
+
reportInvalid: (filePath, _code, reason) => noticeSkippedProjectConfig(filePath, reason, attempt.warningSink),
|
|
14395
|
+
allowProjectProfiles: input.allowProjectProfiles,
|
|
14396
|
+
projectAllowed: input.projectAllowed
|
|
14397
|
+
});
|
|
14398
|
+
if (loaded.source !== null) {
|
|
14399
|
+
for (const message of held)
|
|
14400
|
+
input.stripSink(message);
|
|
14401
|
+
}
|
|
14402
|
+
return loaded;
|
|
14403
|
+
}
|
|
14239
14404
|
function mergeUserLevelSearch(userLevel) {
|
|
14240
14405
|
return mergeSearchSettings(["user", "userLocal", "custom", "customLocal"].flatMap((slot) => {
|
|
14241
14406
|
const source = userLevel[slot].source;
|