@fro.bot/systematic 3.18.8 → 3.18.10
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 +1 -1
- package/dist/{index-8wrkhjsx.js → index-fpq5hwdt.js} +179 -20
- package/dist/index.js +87 -30
- package/dist/pi.js +179 -20
- package/dist/schemas/systematic-config.schema.json +3 -3
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -7874,7 +7874,7 @@ function createProfileBundleSchema(agentNames, qualifiedAgentIds) {
|
|
|
7874
7874
|
name,
|
|
7875
7875
|
ProfileOverlaySchema.optional()
|
|
7876
7876
|
]))).strict().optional().meta({
|
|
7877
|
-
description: "Per-agent routing overlays for this profile, keyed by bundled agent name (bare or qualified category/name), using the same routing-only field set as every profile entry. Unknown keys are rejected with a Zod parse error
|
|
7877
|
+
description: "Per-agent routing overlays for this profile, keyed by bundled agent name (bare or qualified category/name), using the same routing-only field set as every profile entry. Unknown keys are rejected with a Zod parse error.",
|
|
7878
7878
|
examples: [
|
|
7879
7879
|
{ "correctness-reviewer": { model: "openai/gpt-6-astra" } }
|
|
7880
7880
|
]
|
|
@@ -7977,7 +7977,7 @@ function createSystematicConfigSchema(opts) {
|
|
|
7977
7977
|
name,
|
|
7978
7978
|
AgentOverlaySchema.optional()
|
|
7979
7979
|
]))).strict().default({}).meta({
|
|
7980
|
-
description: "Per-agent configuration overlays keyed by bundled agent name (bare or qualified category/name). Unknown keys are rejected with a Zod parse error. To overlay a user-defined agent, configure it through OpenCode-native config (.opencode/opencode.json) instead.",
|
|
7980
|
+
description: "Per-agent configuration overlays keyed by bundled agent name (bare or qualified category/name). Unknown keys are rejected with a Zod parse error, except that a project config entry under an unknown key is discarded before that check if stripping trust-protected fields leaves it empty. To overlay a user-defined agent, configure it through OpenCode-native config (.opencode/opencode.json) instead. Trust-protected fields (model, variant, skills, permission, opencode, pi) are only valid in user config or OPENCODE_CONFIG_DIR config \u2014 a project config setting them has that field ignored with a warning; other fields in the same overlay still apply.",
|
|
7981
7981
|
examples: [
|
|
7982
7982
|
{ "correctness-reviewer": { temperature: 0.1 } },
|
|
7983
7983
|
{ "review/correctness-reviewer": { temperature: 0.1 } },
|
|
@@ -7985,7 +7985,7 @@ function createSystematicConfigSchema(opts) {
|
|
|
7985
7985
|
]
|
|
7986
7986
|
}),
|
|
7987
7987
|
categories: record(string(), CategoryOverlaySchema).default({}).meta({
|
|
7988
|
-
description: "Per-category configuration overlays keyed by category name",
|
|
7988
|
+
description: "Per-category configuration overlays keyed by category name. Trust-protected fields (model, variant, skills, permission, opencode, pi) are only valid in user config or OPENCODE_CONFIG_DIR config \u2014 a project config setting them has that field ignored with a warning; other fields in the same overlay still apply.",
|
|
7989
7989
|
examples: [{ review: { model: "anthropic/claude-opus-5" } }, {}]
|
|
7990
7990
|
}),
|
|
7991
7991
|
profiles: record(string(), createProfileBundleSchema(agentNames, qualifiedAgentIds)).default({}).meta({
|
|
@@ -8100,6 +8100,46 @@ var PROTECTED_OVERLAY_FIELD_PATHS = {
|
|
|
8100
8100
|
}
|
|
8101
8101
|
};
|
|
8102
8102
|
var PROJECT_PROTECTED_FIELDS = new Set(["workflow_guard", "profiles"]);
|
|
8103
|
+
var MAX_DIAGNOSTIC_TEXT = 200;
|
|
8104
|
+
var MAX_STRIP_WARNINGS = 20;
|
|
8105
|
+
var DIAGNOSTIC_ELLIPSIS = "\u2026";
|
|
8106
|
+
function sanitizeDiagnosticText(input) {
|
|
8107
|
+
const budget = MAX_DIAGNOSTIC_TEXT - DIAGNOSTIC_ELLIPSIS.length;
|
|
8108
|
+
let rendered = "";
|
|
8109
|
+
let truncated = false;
|
|
8110
|
+
for (const char of input) {
|
|
8111
|
+
if (rendered.length >= budget) {
|
|
8112
|
+
truncated = true;
|
|
8113
|
+
break;
|
|
8114
|
+
}
|
|
8115
|
+
const code = char.codePointAt(0) ?? 0;
|
|
8116
|
+
const isControl = code <= 31 || code === 127 || code >= 128 && code <= 159 || code === 8232 || code === 8233;
|
|
8117
|
+
const piece = isControl ? `\\u${code.toString(16).padStart(4, "0")}` : char;
|
|
8118
|
+
if (rendered.length + piece.length > budget) {
|
|
8119
|
+
truncated = true;
|
|
8120
|
+
break;
|
|
8121
|
+
}
|
|
8122
|
+
rendered += piece;
|
|
8123
|
+
}
|
|
8124
|
+
return truncated ? `${rendered}${DIAGNOSTIC_ELLIPSIS}` : rendered;
|
|
8125
|
+
}
|
|
8126
|
+
function createBoundedStripWarningSink(warningSink) {
|
|
8127
|
+
let emitted = 0;
|
|
8128
|
+
let suppressed = 0;
|
|
8129
|
+
return {
|
|
8130
|
+
sink(message) {
|
|
8131
|
+
if (emitted < MAX_STRIP_WARNINGS) {
|
|
8132
|
+
emitted++;
|
|
8133
|
+
warningSink(message);
|
|
8134
|
+
} else {
|
|
8135
|
+
suppressed++;
|
|
8136
|
+
}
|
|
8137
|
+
},
|
|
8138
|
+
suppressedCount() {
|
|
8139
|
+
return suppressed;
|
|
8140
|
+
}
|
|
8141
|
+
};
|
|
8142
|
+
}
|
|
8103
8143
|
var CURRENT_SKILL_NAMES_SET = new Set(BUNDLED_SKILL_NAMES);
|
|
8104
8144
|
var CURRENT_AGENT_NAMES_SET = new Set([
|
|
8105
8145
|
...BUNDLED_AGENT_NAMES,
|
|
@@ -8252,7 +8292,7 @@ ${formatted.map((entry) => ` - ${entry}`).join(`
|
|
|
8252
8292
|
issues
|
|
8253
8293
|
});
|
|
8254
8294
|
}
|
|
8255
|
-
function loadConfigSource(filePath, trust, invalidSource) {
|
|
8295
|
+
function loadConfigSource(filePath, trust, invalidSource, warningSink) {
|
|
8256
8296
|
try {
|
|
8257
8297
|
const rawConfig = loadJsoncFile(filePath);
|
|
8258
8298
|
if (!rawConfig) {
|
|
@@ -8262,7 +8302,8 @@ function loadConfigSource(filePath, trust, invalidSource) {
|
|
|
8262
8302
|
};
|
|
8263
8303
|
}
|
|
8264
8304
|
const protectedFields = collectProjectProtectedFields(rawConfig, trust);
|
|
8265
|
-
const
|
|
8305
|
+
const topLevelStripped = trust === "project" ? stripProjectProtectedFields(rawConfig) : rawConfig;
|
|
8306
|
+
const config = trust === "project" ? stripProjectSecurityOverlayFields(topLevelStripped, filePath, warningSink) : topLevelStripped;
|
|
8266
8307
|
const result = SystematicConfigSchema.safeParse(config);
|
|
8267
8308
|
if (!result.success) {
|
|
8268
8309
|
throwTopLevelConfigSchemaError(filePath, trust, result.error.issues, config);
|
|
@@ -8353,6 +8394,41 @@ function stripProjectProtectedFields(rawConfig) {
|
|
|
8353
8394
|
}
|
|
8354
8395
|
return config;
|
|
8355
8396
|
}
|
|
8397
|
+
function stripProjectSecurityOverlayFields(rawConfig, filePath, warningSink) {
|
|
8398
|
+
const agents = stripSecurityOverlayEntries(rawConfig.agents, "agents", filePath, warningSink);
|
|
8399
|
+
const categories = stripSecurityOverlayEntries(rawConfig.categories, "categories", filePath, warningSink);
|
|
8400
|
+
if (agents === rawConfig.agents && categories === rawConfig.categories) {
|
|
8401
|
+
return rawConfig;
|
|
8402
|
+
}
|
|
8403
|
+
const result = { ...rawConfig };
|
|
8404
|
+
if (agents !== rawConfig.agents)
|
|
8405
|
+
result.agents = agents;
|
|
8406
|
+
if (categories !== rawConfig.categories)
|
|
8407
|
+
result.categories = categories;
|
|
8408
|
+
return result;
|
|
8409
|
+
}
|
|
8410
|
+
function stripSecurityOverlayEntries(overlayMap, mapKey, filePath, warningSink) {
|
|
8411
|
+
if (!isRecord2(overlayMap))
|
|
8412
|
+
return overlayMap;
|
|
8413
|
+
let changed = false;
|
|
8414
|
+
const result = {};
|
|
8415
|
+
for (const [key, value] of Object.entries(overlayMap)) {
|
|
8416
|
+
if (!isRecord2(value)) {
|
|
8417
|
+
result[key] = value;
|
|
8418
|
+
continue;
|
|
8419
|
+
}
|
|
8420
|
+
const stripped = stripProjectSecurityOverlay(filePath, `${mapKey}.${key}`, value, warningSink);
|
|
8421
|
+
if (stripped === value) {
|
|
8422
|
+
result[key] = stripped;
|
|
8423
|
+
continue;
|
|
8424
|
+
}
|
|
8425
|
+
changed = true;
|
|
8426
|
+
if (Object.keys(stripped).length === 0)
|
|
8427
|
+
continue;
|
|
8428
|
+
result[key] = stripped;
|
|
8429
|
+
}
|
|
8430
|
+
return changed ? result : overlayMap;
|
|
8431
|
+
}
|
|
8356
8432
|
function isRecord2(value) {
|
|
8357
8433
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8358
8434
|
}
|
|
@@ -8432,7 +8508,7 @@ function resolveActiveProfile(input) {
|
|
|
8432
8508
|
const trustedDefault = trustedDefaultProfileName(input);
|
|
8433
8509
|
const fallbackLookup = trustedDefault !== undefined && trustedDefault !== requested ? lookupProfileBundle(input, trustedDefault) : undefined;
|
|
8434
8510
|
if (fallbackLookup !== undefined && trustedDefault !== undefined) {
|
|
8435
|
-
input.warningSink(`[systematic] profile "${requested}" (selected by ${selection.source} config) is not defined in \`profiles\`; falling back to your default profile "${trustedDefault}". See ${PROFILE_DOCS_URL} for how to define a profile.`);
|
|
8511
|
+
input.warningSink(`[systematic] profile "${sanitizeDiagnosticText(requested)}" (selected by ${selection.source} config) is not defined in \`profiles\`; falling back to your default profile "${sanitizeDiagnosticText(trustedDefault)}". See ${PROFILE_DOCS_URL} for how to define a profile.`);
|
|
8436
8512
|
return {
|
|
8437
8513
|
activeProfile: trustedDefault,
|
|
8438
8514
|
profileSelectorSource: selection.source,
|
|
@@ -8442,8 +8518,8 @@ function resolveActiveProfile(input) {
|
|
|
8442
8518
|
};
|
|
8443
8519
|
}
|
|
8444
8520
|
const sourceNote = selection.source === "user" ? "" : ` (selected by ${selection.source} config)`;
|
|
8445
|
-
const alsoMissingNote = trustedDefault !== undefined && trustedDefault !== requested ? ` Your default profile "${trustedDefault}" is also not defined in \`profiles\`.` : trustedDefault === undefined ? " No default profile is configured (`profile` in your user config)." : "";
|
|
8446
|
-
input.warningSink(`[systematic] profile "${requested}"${sourceNote} is not defined in \`profiles\`; using base configuration (no profile).${alsoMissingNote} See ${PROFILE_DOCS_URL} for how to define a profile.`);
|
|
8521
|
+
const alsoMissingNote = trustedDefault !== undefined && trustedDefault !== requested ? ` Your default profile "${sanitizeDiagnosticText(trustedDefault)}" is also not defined in \`profiles\`.` : trustedDefault === undefined ? " No default profile is configured (`profile` in your user config)." : "";
|
|
8522
|
+
input.warningSink(`[systematic] profile "${sanitizeDiagnosticText(requested)}"${sourceNote} is not defined in \`profiles\`; using base configuration (no profile).${alsoMissingNote} See ${PROFILE_DOCS_URL} for how to define a profile.`);
|
|
8447
8523
|
return {
|
|
8448
8524
|
activeProfile: null,
|
|
8449
8525
|
profileSelectorSource: selection.source,
|
|
@@ -8455,31 +8531,104 @@ function resolveActiveProfile(input) {
|
|
|
8455
8531
|
function loadConfig(projectDir, options) {
|
|
8456
8532
|
return loadConfigWithSources(projectDir, options).config;
|
|
8457
8533
|
}
|
|
8534
|
+
function resolveAliasedCustomConfigPath(paths, includeProject) {
|
|
8535
|
+
if (!includeProject || paths.customConfig === undefined)
|
|
8536
|
+
return;
|
|
8537
|
+
const sameFile = resolveConfigSourcePath(paths.projectConfig) === resolveConfigSourcePath(paths.customConfig);
|
|
8538
|
+
return sameFile ? paths.customConfig : undefined;
|
|
8539
|
+
}
|
|
8540
|
+
function createAliasStripTracker(warningSink, aliasedCustomConfigPath) {
|
|
8541
|
+
if (aliasedCustomConfigPath === undefined) {
|
|
8542
|
+
return { sink: warningSink, buffered: [] };
|
|
8543
|
+
}
|
|
8544
|
+
const buffered = [];
|
|
8545
|
+
return {
|
|
8546
|
+
sink: (message) => {
|
|
8547
|
+
buffered.push(message);
|
|
8548
|
+
},
|
|
8549
|
+
buffered
|
|
8550
|
+
};
|
|
8551
|
+
}
|
|
8552
|
+
function isAliasNoticeEligible(input) {
|
|
8553
|
+
return input.aliasedCustomConfigPath !== undefined && (input.bufferedCount > 0 || input.hasProtectedFields);
|
|
8554
|
+
}
|
|
8555
|
+
function emitAliasFailureDiagnostics(input) {
|
|
8556
|
+
if (!isAliasNoticeEligible({
|
|
8557
|
+
aliasedCustomConfigPath: input.aliasedCustomConfigPath,
|
|
8558
|
+
bufferedCount: input.buffered.length,
|
|
8559
|
+
hasProtectedFields: input.hasProtectedFields
|
|
8560
|
+
})) {
|
|
8561
|
+
return;
|
|
8562
|
+
}
|
|
8563
|
+
if (input.projectLoaded && input.customLoaded)
|
|
8564
|
+
return;
|
|
8565
|
+
for (const message of input.buffered)
|
|
8566
|
+
input.warningSink(message);
|
|
8567
|
+
}
|
|
8568
|
+
function buildAliasSuccessNotice(input) {
|
|
8569
|
+
if (!isAliasNoticeEligible({
|
|
8570
|
+
aliasedCustomConfigPath: input.aliasedCustomConfigPath,
|
|
8571
|
+
bufferedCount: input.bufferedCount,
|
|
8572
|
+
hasProtectedFields: input.hasProtectedFields
|
|
8573
|
+
}) || !(input.projectLoaded && input.customLoaded) || input.aliasedCustomConfigPath === undefined) {
|
|
8574
|
+
return;
|
|
8575
|
+
}
|
|
8576
|
+
const aliasedCustomConfigPath = input.aliasedCustomConfigPath;
|
|
8577
|
+
const projectConfigPath = input.projectConfigPath;
|
|
8578
|
+
const warningSink = input.warningSink;
|
|
8579
|
+
return () => {
|
|
8580
|
+
warningSink(`[systematic] project config (${sanitizeDiagnosticText(projectConfigPath)}) and custom config (${sanitizeDiagnosticText(aliasedCustomConfigPath)}) resolve to the same file; protected fields stripped from the project pass (security-overlay fields, \`profiles\`, \`workflow_guard\`) apply through the custom-trust pass instead.`);
|
|
8581
|
+
};
|
|
8582
|
+
}
|
|
8458
8583
|
function loadConfigWithSources(projectDir, options) {
|
|
8459
8584
|
const includeProject = options?.includeProject ?? true;
|
|
8460
8585
|
const invalidSource = options?.invalidSource ?? "throw";
|
|
8461
8586
|
const paths = getConfigPaths(projectDir, options);
|
|
8462
8587
|
const warningSink = options?.warningSink ?? console.warn;
|
|
8463
|
-
const
|
|
8464
|
-
const
|
|
8588
|
+
const aliasedCustomConfigPath = resolveAliasedCustomConfigPath(paths, includeProject);
|
|
8589
|
+
const projectStrip = createAliasStripTracker(warningSink, aliasedCustomConfigPath);
|
|
8590
|
+
const boundedProjectStrip = createBoundedStripWarningSink(projectStrip.sink);
|
|
8591
|
+
const user = loadConfigSource(paths.userConfig, "user", invalidSource, warningSink);
|
|
8592
|
+
const project = includeProject ? loadConfigSource(paths.projectConfig, "project", invalidSource, boundedProjectStrip.sink) : {
|
|
8465
8593
|
metadata: { kind: "project", presence: "absent" },
|
|
8466
8594
|
source: null
|
|
8467
8595
|
};
|
|
8468
|
-
const custom = paths.customConfig ? loadConfigSource(paths.customConfig, "custom", invalidSource) : {
|
|
8596
|
+
const custom = paths.customConfig ? loadConfigSource(paths.customConfig, "custom", invalidSource, warningSink) : {
|
|
8469
8597
|
metadata: { kind: "custom", presence: "absent" },
|
|
8470
8598
|
source: null
|
|
8471
8599
|
};
|
|
8472
8600
|
const userSource = user.source;
|
|
8473
8601
|
const projectSource = project.source;
|
|
8474
8602
|
const customSource = custom.source;
|
|
8603
|
+
if (projectSource?.protectedFields.some((field) => field.fieldPath === "profiles")) {
|
|
8604
|
+
boundedProjectStrip.sink(`[systematic] \`profiles\` in project config (${sanitizeDiagnosticText(projectSource.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\`.`);
|
|
8605
|
+
}
|
|
8606
|
+
const suppressedStripCount = boundedProjectStrip.suppressedCount();
|
|
8607
|
+
if (suppressedStripCount > 0) {
|
|
8608
|
+
projectStrip.sink(`[systematic] ${suppressedStripCount} additional project-config protected-field warning(s) in (${sanitizeDiagnosticText(paths.projectConfig)}) were suppressed.`);
|
|
8609
|
+
}
|
|
8610
|
+
emitAliasFailureDiagnostics({
|
|
8611
|
+
aliasedCustomConfigPath,
|
|
8612
|
+
buffered: projectStrip.buffered,
|
|
8613
|
+
customLoaded: custom.source !== null,
|
|
8614
|
+
hasProtectedFields: (projectSource?.protectedFields.length ?? 0) > 0,
|
|
8615
|
+
projectLoaded: project.source !== null,
|
|
8616
|
+
warningSink
|
|
8617
|
+
});
|
|
8618
|
+
const emitAliasSuccessNotice = buildAliasSuccessNotice({
|
|
8619
|
+
aliasedCustomConfigPath,
|
|
8620
|
+
bufferedCount: projectStrip.buffered.length,
|
|
8621
|
+
customLoaded: custom.source !== null,
|
|
8622
|
+
hasProtectedFields: (projectSource?.protectedFields.length ?? 0) > 0,
|
|
8623
|
+
projectConfigPath: paths.projectConfig,
|
|
8624
|
+
projectLoaded: project.source !== null,
|
|
8625
|
+
warningSink
|
|
8626
|
+
});
|
|
8475
8627
|
const sources = [userSource, projectSource, customSource].filter((source) => source !== null);
|
|
8476
8628
|
const userConfig = userSource?.config;
|
|
8477
8629
|
const projectConfig = projectSource?.config;
|
|
8478
8630
|
const customConfig = customSource?.config;
|
|
8479
8631
|
const warned = new Set;
|
|
8480
|
-
if (projectSource?.protectedFields.some((field) => field.fieldPath === "profiles")) {
|
|
8481
|
-
warningSink(`[systematic] \`profiles\` in project config (${projectSource.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\`.`);
|
|
8482
|
-
}
|
|
8483
8632
|
assertAllProfileBundlesAreValid(userConfig, customConfig);
|
|
8484
8633
|
const profileSelection = resolveActiveProfile({
|
|
8485
8634
|
userConfig,
|
|
@@ -8551,6 +8700,7 @@ function loadConfigWithSources(projectDir, options) {
|
|
|
8551
8700
|
disabled_skills: result.disabled_skills.filter((n) => !droppedSkillSet.has(n)),
|
|
8552
8701
|
disabled_agents: result.disabled_agents.filter((n) => !droppedAgentSet.has(n))
|
|
8553
8702
|
};
|
|
8703
|
+
emitAliasSuccessNotice?.();
|
|
8554
8704
|
return {
|
|
8555
8705
|
config: effectiveConfig,
|
|
8556
8706
|
metadata: buildConfigObservationMetadata({
|
|
@@ -8593,7 +8743,7 @@ function buildConfigObservationMetadata(summary) {
|
|
|
8593
8743
|
if (authority)
|
|
8594
8744
|
authorities.push(authority);
|
|
8595
8745
|
}
|
|
8596
|
-
const protectedFields = summary.sources
|
|
8746
|
+
const protectedFields = collectVisibleProtectedFields(summary.sources);
|
|
8597
8747
|
const sources = dedupeSourceMetadata([summary.custom, summary.project, summary.user], sourcePaths);
|
|
8598
8748
|
return {
|
|
8599
8749
|
authorities: sortAuthorities(authorities),
|
|
@@ -8604,6 +8754,12 @@ function buildConfigObservationMetadata(summary) {
|
|
|
8604
8754
|
profileFallback: summary.profileSelection.profileFallback
|
|
8605
8755
|
};
|
|
8606
8756
|
}
|
|
8757
|
+
function collectVisibleProtectedFields(sources) {
|
|
8758
|
+
const projectSource = sources.find((source) => source.trust === "project");
|
|
8759
|
+
const customSource = sources.find((source) => source.trust === "custom");
|
|
8760
|
+
const projectAppliedViaCustom = projectSource !== undefined && customSource !== undefined && projectSource.canonicalPath === customSource.canonicalPath;
|
|
8761
|
+
return sources.flatMap((source) => projectAppliedViaCustom && source.trust === "project" ? [] : source.protectedFields);
|
|
8762
|
+
}
|
|
8607
8763
|
function dedupeSourceMetadata(metadata, sourcePaths) {
|
|
8608
8764
|
const seen = new Set;
|
|
8609
8765
|
return metadata.filter((source) => {
|
|
@@ -8719,9 +8875,6 @@ function mergeOverlayMap(target, source, mapKey) {
|
|
|
8719
8875
|
if (!isRecord2(value)) {
|
|
8720
8876
|
throwInvalidOverlay(source.path, keyPath);
|
|
8721
8877
|
}
|
|
8722
|
-
if (source.kind === "file" && source.trust === "project") {
|
|
8723
|
-
rejectProjectSecurityOverlay(source.path, keyPath, value);
|
|
8724
|
-
}
|
|
8725
8878
|
const previous = target[key];
|
|
8726
8879
|
const nextValue = resolveOverlayEntryValue(previous?.value, value, source);
|
|
8727
8880
|
target[key] = {
|
|
@@ -8741,12 +8894,18 @@ function resolveOverlayEntryValue(previous, next, source) {
|
|
|
8741
8894
|
return preserveSecurityFields(previous, next);
|
|
8742
8895
|
return next;
|
|
8743
8896
|
}
|
|
8744
|
-
function
|
|
8897
|
+
function stripProjectSecurityOverlay(sourcePath, keyPath, value, warningSink) {
|
|
8898
|
+
const safeKeyPath = sanitizeDiagnosticText(keyPath);
|
|
8899
|
+
const safeSourcePath = sanitizeDiagnosticText(sourcePath);
|
|
8900
|
+
let stripped;
|
|
8745
8901
|
for (const field of SECURITY_OVERLAY_FIELDS) {
|
|
8746
8902
|
if (Object.hasOwn(value, field)) {
|
|
8747
|
-
|
|
8903
|
+
stripped ??= { ...value };
|
|
8904
|
+
delete stripped[field];
|
|
8905
|
+
warningSink(`[systematic] \`${safeKeyPath}.${field}\` in project config (${safeSourcePath}) is only valid in user config or OPENCODE_CONFIG_DIR config and has been ignored.`);
|
|
8748
8906
|
}
|
|
8749
8907
|
}
|
|
8908
|
+
return stripped ?? value;
|
|
8750
8909
|
}
|
|
8751
8910
|
function preserveSecurityFields(previous, next) {
|
|
8752
8911
|
const result = { ...next };
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
extractCommandFrontmatter,
|
|
20
20
|
findSkillsInDir,
|
|
21
21
|
discoverSkills
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-fpq5hwdt.js";
|
|
23
23
|
|
|
24
24
|
// src/index.ts
|
|
25
25
|
import { createHash as createHash4 } from "crypto";
|
|
@@ -10847,13 +10847,14 @@ function remoteReadbackInput(operation, local, workspaceIdentity, snapshot, incl
|
|
|
10847
10847
|
function isSuccessfulAfter(output) {
|
|
10848
10848
|
return parseHostOutput(output) !== undefined;
|
|
10849
10849
|
}
|
|
10850
|
-
function statusForTool(status) {
|
|
10850
|
+
function statusForTool(status, unavailableCause) {
|
|
10851
10851
|
return JSON.stringify({
|
|
10852
10852
|
state: status.state,
|
|
10853
10853
|
reasonCode: status.reasonCode,
|
|
10854
10854
|
...status.repair ? { repair: status.repair } : {},
|
|
10855
10855
|
satisfiedOperations: status.satisfiedOperations,
|
|
10856
|
-
missingOperations: status.missingOperations
|
|
10856
|
+
missingOperations: status.missingOperations,
|
|
10857
|
+
...unavailableCause && status.state === "unavailable" ? { firstUnavailableCause: unavailableCause } : {}
|
|
10857
10858
|
});
|
|
10858
10859
|
}
|
|
10859
10860
|
function markerStatusRank(state) {
|
|
@@ -11036,6 +11037,13 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11036
11037
|
const pendingQuestionChallenges = new Map;
|
|
11037
11038
|
const blockedQuestionCalls = new Map;
|
|
11038
11039
|
const consumedQuestionTargets = new Set;
|
|
11040
|
+
let firstUnavailableCause;
|
|
11041
|
+
function startFreshUnit(input, policy) {
|
|
11042
|
+
const result = guard.startUnit(input, policy);
|
|
11043
|
+
if (result.status === "started")
|
|
11044
|
+
firstUnavailableCause = undefined;
|
|
11045
|
+
return result;
|
|
11046
|
+
}
|
|
11039
11047
|
function effectiveTargetContext() {
|
|
11040
11048
|
const parentTargetRoot = options.targetDirectory ?? process.cwd();
|
|
11041
11049
|
return {
|
|
@@ -11627,10 +11635,13 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
11627
11635
|
rolledUpChildren.add(rollupKey);
|
|
11628
11636
|
}
|
|
11629
11637
|
let runtimePolicy = trustedSkillPolicy("unknown", options.runtimeRequiredOperations ?? []);
|
|
11630
|
-
function markUnavailable() {
|
|
11638
|
+
function markUnavailable(cause) {
|
|
11631
11639
|
if (options.config.mode === "disabled")
|
|
11632
11640
|
return;
|
|
11633
|
-
guard.setMode({ mode: "unavailable" });
|
|
11641
|
+
const result = guard.setMode({ mode: "unavailable" });
|
|
11642
|
+
if (cause && result.status === "changed" && !firstUnavailableCause) {
|
|
11643
|
+
firstUnavailableCause = cause;
|
|
11644
|
+
}
|
|
11634
11645
|
}
|
|
11635
11646
|
function bindCall(callDigest, kind, fingerprint) {
|
|
11636
11647
|
const existing = callBindings.get(callDigest);
|
|
@@ -12169,36 +12180,79 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
12169
12180
|
async function seedRemoteScopes(operations) {
|
|
12170
12181
|
const remoteOperations = operations.filter(remoteOperation);
|
|
12171
12182
|
if (remoteOperations.length === 0)
|
|
12172
|
-
return
|
|
12183
|
+
return;
|
|
12173
12184
|
const remoteSnapshot = options.observer?.remoteSnapshot;
|
|
12174
|
-
if (!remoteSnapshot || !options.observer)
|
|
12175
|
-
return
|
|
12185
|
+
if (!remoteSnapshot || !options.observer) {
|
|
12186
|
+
return {
|
|
12187
|
+
site: "seed-remote-scopes",
|
|
12188
|
+
kind: "observer-not-configured",
|
|
12189
|
+
timedOut: false
|
|
12190
|
+
};
|
|
12191
|
+
}
|
|
12176
12192
|
let local;
|
|
12177
12193
|
try {
|
|
12178
12194
|
local = await options.observer.snapshot();
|
|
12179
12195
|
} catch {
|
|
12180
|
-
return
|
|
12196
|
+
return {
|
|
12197
|
+
site: "seed-remote-scopes",
|
|
12198
|
+
kind: "local-snapshot-error",
|
|
12199
|
+
timedOut: false
|
|
12200
|
+
};
|
|
12201
|
+
}
|
|
12202
|
+
if (local.status === "unavailable") {
|
|
12203
|
+
return {
|
|
12204
|
+
site: "seed-remote-scopes",
|
|
12205
|
+
kind: "local-snapshot-unavailable",
|
|
12206
|
+
reasonCode: local.reasonCode,
|
|
12207
|
+
timedOut: local.reasonCode === "command-timeout"
|
|
12208
|
+
};
|
|
12181
12209
|
}
|
|
12182
|
-
if (local.status === "unavailable")
|
|
12183
|
-
return false;
|
|
12184
12210
|
for (const operation of remoteOperations) {
|
|
12185
|
-
|
|
12186
|
-
|
|
12187
|
-
|
|
12211
|
+
const cause = await seedRemoteScope(remoteSnapshot, operation, local.snapshot);
|
|
12212
|
+
if (cause)
|
|
12213
|
+
return cause;
|
|
12188
12214
|
}
|
|
12189
|
-
return
|
|
12215
|
+
return;
|
|
12190
12216
|
}
|
|
12191
12217
|
async function seedRemoteScope(reader, operation, local) {
|
|
12192
12218
|
const result = await readRemoteScope(reader, operation, "before");
|
|
12193
|
-
if (!result)
|
|
12194
|
-
return
|
|
12219
|
+
if (!result) {
|
|
12220
|
+
return {
|
|
12221
|
+
site: "seed-remote-scope",
|
|
12222
|
+
kind: "remote-scope-unreadable",
|
|
12223
|
+
operation,
|
|
12224
|
+
timedOut: false
|
|
12225
|
+
};
|
|
12226
|
+
}
|
|
12195
12227
|
if (result.status === "missing-resource") {
|
|
12196
|
-
|
|
12228
|
+
const allowed = operation === "pr-creation" || operation === "check-readback" || operation === "review-readback";
|
|
12229
|
+
return allowed ? undefined : {
|
|
12230
|
+
site: "seed-remote-scope",
|
|
12231
|
+
kind: "remote-scope-missing-resource",
|
|
12232
|
+
operation,
|
|
12233
|
+
timedOut: false
|
|
12234
|
+
};
|
|
12235
|
+
}
|
|
12236
|
+
if (result.status !== "available") {
|
|
12237
|
+
return {
|
|
12238
|
+
site: "seed-remote-scope",
|
|
12239
|
+
kind: "remote-scope-unavailable",
|
|
12240
|
+
operation,
|
|
12241
|
+
reasonCode: result.reasonCode,
|
|
12242
|
+
timedOut: result.reasonCode === "command-timeout"
|
|
12243
|
+
};
|
|
12197
12244
|
}
|
|
12198
|
-
if (result.status !== "available")
|
|
12199
|
-
return false;
|
|
12200
12245
|
const observed = guard.observeReadback(remoteReadbackInput(operation, local, options.workspaceIdentity, result.snapshot, operation !== "pr-creation"));
|
|
12201
|
-
|
|
12246
|
+
if (observed.status === "rejected") {
|
|
12247
|
+
return {
|
|
12248
|
+
site: "seed-remote-scope",
|
|
12249
|
+
kind: "remote-readback-rejected",
|
|
12250
|
+
operation,
|
|
12251
|
+
reasonCode: observed.reasonCode,
|
|
12252
|
+
timedOut: false
|
|
12253
|
+
};
|
|
12254
|
+
}
|
|
12255
|
+
return;
|
|
12202
12256
|
}
|
|
12203
12257
|
async function finishSkill(host, output) {
|
|
12204
12258
|
const callDigest = digestCall(ledger, host.callID);
|
|
@@ -12254,10 +12308,10 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
12254
12308
|
runtimePolicy = trustedSkillPolicy(skill, options.runtimeRequiredOperations ?? []);
|
|
12255
12309
|
const status = guard.status();
|
|
12256
12310
|
if (!status.unit || status.unit.status === "completed") {
|
|
12257
|
-
|
|
12258
|
-
|
|
12259
|
-
|
|
12260
|
-
|
|
12311
|
+
startFreshUnit({}, runtimePolicy);
|
|
12312
|
+
const cause = await seedRemoteScopes(runtimePolicy.requiredOperations ?? []);
|
|
12313
|
+
if (cause)
|
|
12314
|
+
markUnavailable(cause);
|
|
12261
12315
|
}
|
|
12262
12316
|
}
|
|
12263
12317
|
}
|
|
@@ -12276,12 +12330,14 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
|
|
|
12276
12330
|
}
|
|
12277
12331
|
if (!isSuccessfulAfter(output))
|
|
12278
12332
|
return;
|
|
12279
|
-
const result =
|
|
12333
|
+
const result = startFreshUnit(pending.input, runtimePolicy);
|
|
12280
12334
|
if (result.status === "rejected" && (result.reasonCode === "guard-unavailable" || result.reasonCode === "invalid-configuration")) {
|
|
12281
12335
|
markUnavailable();
|
|
12282
12336
|
}
|
|
12283
|
-
if (result.status === "started"
|
|
12284
|
-
|
|
12337
|
+
if (result.status === "started") {
|
|
12338
|
+
const cause = await seedRemoteScopes(runtimePolicy.requiredOperations ?? []);
|
|
12339
|
+
if (cause)
|
|
12340
|
+
markUnavailable(cause);
|
|
12285
12341
|
}
|
|
12286
12342
|
if (result.status === "started") {
|
|
12287
12343
|
const startedStatus = guard.status();
|
|
@@ -12869,6 +12925,7 @@ ${marker}` : marker;
|
|
|
12869
12925
|
return initialized ? guard.status() : unavailableWorkflowStatus();
|
|
12870
12926
|
},
|
|
12871
12927
|
readStatus,
|
|
12928
|
+
unavailableCause: () => firstUnavailableCause,
|
|
12872
12929
|
refreshReadback,
|
|
12873
12930
|
observeReceipt: (input) => {
|
|
12874
12931
|
ensureSynchronousRuntime();
|
|
@@ -12880,7 +12937,7 @@ ${marker}` : marker;
|
|
|
12880
12937
|
},
|
|
12881
12938
|
startUnit: (input, policy) => {
|
|
12882
12939
|
ensureSynchronousRuntime();
|
|
12883
|
-
return initialized ?
|
|
12940
|
+
return initialized ? startFreshUnit(input, policy) : { status: "rejected", reasonCode: "guard-unavailable" };
|
|
12884
12941
|
},
|
|
12885
12942
|
control,
|
|
12886
12943
|
markUnavailable,
|
|
@@ -12987,7 +13044,7 @@ function createOpencodeWorkflowGuard(options) {
|
|
|
12987
13044
|
await runtime.refreshReadback();
|
|
12988
13045
|
return {
|
|
12989
13046
|
title: "Workflow guard status",
|
|
12990
|
-
output: statusToolSchema.safeParse(input).success ? statusForTool(runtime.readStatus()) : unavailableToolResult()
|
|
13047
|
+
output: statusToolSchema.safeParse(input).success ? statusForTool(runtime.readStatus(), runtime.unavailableCause()) : unavailableToolResult()
|
|
12991
13048
|
};
|
|
12992
13049
|
}),
|
|
12993
13050
|
systematic_workflow_complete: makeWorkflowTool("Request completion of a guarded workflow unit or epoch.", completeToolShape, sessionRuntimeFor, (_runtime, input) => completeToolSchema.safeParse(input).success ? {
|
package/dist/pi.js
CHANGED
|
@@ -9542,7 +9542,7 @@ function createProfileBundleSchema(agentNames, qualifiedAgentIds) {
|
|
|
9542
9542
|
name,
|
|
9543
9543
|
ProfileOverlaySchema.optional()
|
|
9544
9544
|
]))).strict().optional().meta({
|
|
9545
|
-
description: "Per-agent routing overlays for this profile, keyed by bundled agent name (bare or qualified category/name), using the same routing-only field set as every profile entry. Unknown keys are rejected with a Zod parse error
|
|
9545
|
+
description: "Per-agent routing overlays for this profile, keyed by bundled agent name (bare or qualified category/name), using the same routing-only field set as every profile entry. Unknown keys are rejected with a Zod parse error.",
|
|
9546
9546
|
examples: [
|
|
9547
9547
|
{ "correctness-reviewer": { model: "openai/gpt-6-astra" } }
|
|
9548
9548
|
]
|
|
@@ -9645,7 +9645,7 @@ function createSystematicConfigSchema(opts) {
|
|
|
9645
9645
|
name,
|
|
9646
9646
|
AgentOverlaySchema.optional()
|
|
9647
9647
|
]))).strict().default({}).meta({
|
|
9648
|
-
description: "Per-agent configuration overlays keyed by bundled agent name (bare or qualified category/name). Unknown keys are rejected with a Zod parse error. To overlay a user-defined agent, configure it through OpenCode-native config (.opencode/opencode.json) instead.",
|
|
9648
|
+
description: "Per-agent configuration overlays keyed by bundled agent name (bare or qualified category/name). Unknown keys are rejected with a Zod parse error, except that a project config entry under an unknown key is discarded before that check if stripping trust-protected fields leaves it empty. To overlay a user-defined agent, configure it through OpenCode-native config (.opencode/opencode.json) instead. Trust-protected fields (model, variant, skills, permission, opencode, pi) are only valid in user config or OPENCODE_CONFIG_DIR config — a project config setting them has that field ignored with a warning; other fields in the same overlay still apply.",
|
|
9649
9649
|
examples: [
|
|
9650
9650
|
{ "correctness-reviewer": { temperature: 0.1 } },
|
|
9651
9651
|
{ "review/correctness-reviewer": { temperature: 0.1 } },
|
|
@@ -9653,7 +9653,7 @@ function createSystematicConfigSchema(opts) {
|
|
|
9653
9653
|
]
|
|
9654
9654
|
}),
|
|
9655
9655
|
categories: record(string2(), CategoryOverlaySchema).default({}).meta({
|
|
9656
|
-
description: "Per-category configuration overlays keyed by category name",
|
|
9656
|
+
description: "Per-category configuration overlays keyed by category name. Trust-protected fields (model, variant, skills, permission, opencode, pi) are only valid in user config or OPENCODE_CONFIG_DIR config — a project config setting them has that field ignored with a warning; other fields in the same overlay still apply.",
|
|
9657
9657
|
examples: [{ review: { model: "anthropic/claude-opus-5" } }, {}]
|
|
9658
9658
|
}),
|
|
9659
9659
|
profiles: record(string2(), createProfileBundleSchema(agentNames, qualifiedAgentIds)).default({}).meta({
|
|
@@ -9967,6 +9967,46 @@ var PROTECTED_OVERLAY_FIELD_PATHS = {
|
|
|
9967
9967
|
}
|
|
9968
9968
|
};
|
|
9969
9969
|
var PROJECT_PROTECTED_FIELDS = new Set(["workflow_guard", "profiles"]);
|
|
9970
|
+
var MAX_DIAGNOSTIC_TEXT = 200;
|
|
9971
|
+
var MAX_STRIP_WARNINGS = 20;
|
|
9972
|
+
var DIAGNOSTIC_ELLIPSIS = "…";
|
|
9973
|
+
function sanitizeDiagnosticText(input) {
|
|
9974
|
+
const budget = MAX_DIAGNOSTIC_TEXT - DIAGNOSTIC_ELLIPSIS.length;
|
|
9975
|
+
let rendered = "";
|
|
9976
|
+
let truncated = false;
|
|
9977
|
+
for (const char of input) {
|
|
9978
|
+
if (rendered.length >= budget) {
|
|
9979
|
+
truncated = true;
|
|
9980
|
+
break;
|
|
9981
|
+
}
|
|
9982
|
+
const code = char.codePointAt(0) ?? 0;
|
|
9983
|
+
const isControl = code <= 31 || code === 127 || code >= 128 && code <= 159 || code === 8232 || code === 8233;
|
|
9984
|
+
const piece = isControl ? `\\u${code.toString(16).padStart(4, "0")}` : char;
|
|
9985
|
+
if (rendered.length + piece.length > budget) {
|
|
9986
|
+
truncated = true;
|
|
9987
|
+
break;
|
|
9988
|
+
}
|
|
9989
|
+
rendered += piece;
|
|
9990
|
+
}
|
|
9991
|
+
return truncated ? `${rendered}${DIAGNOSTIC_ELLIPSIS}` : rendered;
|
|
9992
|
+
}
|
|
9993
|
+
function createBoundedStripWarningSink(warningSink) {
|
|
9994
|
+
let emitted = 0;
|
|
9995
|
+
let suppressed = 0;
|
|
9996
|
+
return {
|
|
9997
|
+
sink(message) {
|
|
9998
|
+
if (emitted < MAX_STRIP_WARNINGS) {
|
|
9999
|
+
emitted++;
|
|
10000
|
+
warningSink(message);
|
|
10001
|
+
} else {
|
|
10002
|
+
suppressed++;
|
|
10003
|
+
}
|
|
10004
|
+
},
|
|
10005
|
+
suppressedCount() {
|
|
10006
|
+
return suppressed;
|
|
10007
|
+
}
|
|
10008
|
+
};
|
|
10009
|
+
}
|
|
9970
10010
|
var CURRENT_SKILL_NAMES_SET = new Set(BUNDLED_SKILL_NAMES);
|
|
9971
10011
|
var CURRENT_AGENT_NAMES_SET = new Set([
|
|
9972
10012
|
...BUNDLED_AGENT_NAMES,
|
|
@@ -10119,7 +10159,7 @@ ${formatted.map((entry) => ` - ${entry}`).join(`
|
|
|
10119
10159
|
issues
|
|
10120
10160
|
});
|
|
10121
10161
|
}
|
|
10122
|
-
function loadConfigSource(filePath, trust, invalidSource) {
|
|
10162
|
+
function loadConfigSource(filePath, trust, invalidSource, warningSink) {
|
|
10123
10163
|
try {
|
|
10124
10164
|
const rawConfig = loadJsoncFile(filePath);
|
|
10125
10165
|
if (!rawConfig) {
|
|
@@ -10129,7 +10169,8 @@ function loadConfigSource(filePath, trust, invalidSource) {
|
|
|
10129
10169
|
};
|
|
10130
10170
|
}
|
|
10131
10171
|
const protectedFields = collectProjectProtectedFields(rawConfig, trust);
|
|
10132
|
-
const
|
|
10172
|
+
const topLevelStripped = trust === "project" ? stripProjectProtectedFields(rawConfig) : rawConfig;
|
|
10173
|
+
const config = trust === "project" ? stripProjectSecurityOverlayFields(topLevelStripped, filePath, warningSink) : topLevelStripped;
|
|
10133
10174
|
const result = SystematicConfigSchema.safeParse(config);
|
|
10134
10175
|
if (!result.success) {
|
|
10135
10176
|
throwTopLevelConfigSchemaError(filePath, trust, result.error.issues, config);
|
|
@@ -10220,6 +10261,41 @@ function stripProjectProtectedFields(rawConfig) {
|
|
|
10220
10261
|
}
|
|
10221
10262
|
return config;
|
|
10222
10263
|
}
|
|
10264
|
+
function stripProjectSecurityOverlayFields(rawConfig, filePath, warningSink) {
|
|
10265
|
+
const agents = stripSecurityOverlayEntries(rawConfig.agents, "agents", filePath, warningSink);
|
|
10266
|
+
const categories = stripSecurityOverlayEntries(rawConfig.categories, "categories", filePath, warningSink);
|
|
10267
|
+
if (agents === rawConfig.agents && categories === rawConfig.categories) {
|
|
10268
|
+
return rawConfig;
|
|
10269
|
+
}
|
|
10270
|
+
const result = { ...rawConfig };
|
|
10271
|
+
if (agents !== rawConfig.agents)
|
|
10272
|
+
result.agents = agents;
|
|
10273
|
+
if (categories !== rawConfig.categories)
|
|
10274
|
+
result.categories = categories;
|
|
10275
|
+
return result;
|
|
10276
|
+
}
|
|
10277
|
+
function stripSecurityOverlayEntries(overlayMap, mapKey, filePath, warningSink) {
|
|
10278
|
+
if (!isRecord2(overlayMap))
|
|
10279
|
+
return overlayMap;
|
|
10280
|
+
let changed = false;
|
|
10281
|
+
const result = {};
|
|
10282
|
+
for (const [key, value] of Object.entries(overlayMap)) {
|
|
10283
|
+
if (!isRecord2(value)) {
|
|
10284
|
+
result[key] = value;
|
|
10285
|
+
continue;
|
|
10286
|
+
}
|
|
10287
|
+
const stripped = stripProjectSecurityOverlay(filePath, `${mapKey}.${key}`, value, warningSink);
|
|
10288
|
+
if (stripped === value) {
|
|
10289
|
+
result[key] = stripped;
|
|
10290
|
+
continue;
|
|
10291
|
+
}
|
|
10292
|
+
changed = true;
|
|
10293
|
+
if (Object.keys(stripped).length === 0)
|
|
10294
|
+
continue;
|
|
10295
|
+
result[key] = stripped;
|
|
10296
|
+
}
|
|
10297
|
+
return changed ? result : overlayMap;
|
|
10298
|
+
}
|
|
10223
10299
|
function isRecord2(value) {
|
|
10224
10300
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10225
10301
|
}
|
|
@@ -10299,7 +10375,7 @@ function resolveActiveProfile(input) {
|
|
|
10299
10375
|
const trustedDefault = trustedDefaultProfileName(input);
|
|
10300
10376
|
const fallbackLookup = trustedDefault !== undefined && trustedDefault !== requested ? lookupProfileBundle(input, trustedDefault) : undefined;
|
|
10301
10377
|
if (fallbackLookup !== undefined && trustedDefault !== undefined) {
|
|
10302
|
-
input.warningSink(`[systematic] profile "${requested}" (selected by ${selection.source} config) is not defined in \`profiles\`; falling back to your default profile "${trustedDefault}". See ${PROFILE_DOCS_URL} for how to define a profile.`);
|
|
10378
|
+
input.warningSink(`[systematic] profile "${sanitizeDiagnosticText(requested)}" (selected by ${selection.source} config) is not defined in \`profiles\`; falling back to your default profile "${sanitizeDiagnosticText(trustedDefault)}". See ${PROFILE_DOCS_URL} for how to define a profile.`);
|
|
10303
10379
|
return {
|
|
10304
10380
|
activeProfile: trustedDefault,
|
|
10305
10381
|
profileSelectorSource: selection.source,
|
|
@@ -10309,8 +10385,8 @@ function resolveActiveProfile(input) {
|
|
|
10309
10385
|
};
|
|
10310
10386
|
}
|
|
10311
10387
|
const sourceNote = selection.source === "user" ? "" : ` (selected by ${selection.source} config)`;
|
|
10312
|
-
const alsoMissingNote = trustedDefault !== undefined && trustedDefault !== requested ? ` Your default profile "${trustedDefault}" is also not defined in \`profiles\`.` : trustedDefault === undefined ? " No default profile is configured (`profile` in your user config)." : "";
|
|
10313
|
-
input.warningSink(`[systematic] profile "${requested}"${sourceNote} is not defined in \`profiles\`; using base configuration (no profile).${alsoMissingNote} See ${PROFILE_DOCS_URL} for how to define a profile.`);
|
|
10388
|
+
const alsoMissingNote = trustedDefault !== undefined && trustedDefault !== requested ? ` Your default profile "${sanitizeDiagnosticText(trustedDefault)}" is also not defined in \`profiles\`.` : trustedDefault === undefined ? " No default profile is configured (`profile` in your user config)." : "";
|
|
10389
|
+
input.warningSink(`[systematic] profile "${sanitizeDiagnosticText(requested)}"${sourceNote} is not defined in \`profiles\`; using base configuration (no profile).${alsoMissingNote} See ${PROFILE_DOCS_URL} for how to define a profile.`);
|
|
10314
10390
|
return {
|
|
10315
10391
|
activeProfile: null,
|
|
10316
10392
|
profileSelectorSource: selection.source,
|
|
@@ -10319,31 +10395,104 @@ function resolveActiveProfile(input) {
|
|
|
10319
10395
|
bundleSource: null
|
|
10320
10396
|
};
|
|
10321
10397
|
}
|
|
10398
|
+
function resolveAliasedCustomConfigPath(paths, includeProject) {
|
|
10399
|
+
if (!includeProject || paths.customConfig === undefined)
|
|
10400
|
+
return;
|
|
10401
|
+
const sameFile = resolveConfigSourcePath(paths.projectConfig) === resolveConfigSourcePath(paths.customConfig);
|
|
10402
|
+
return sameFile ? paths.customConfig : undefined;
|
|
10403
|
+
}
|
|
10404
|
+
function createAliasStripTracker(warningSink, aliasedCustomConfigPath) {
|
|
10405
|
+
if (aliasedCustomConfigPath === undefined) {
|
|
10406
|
+
return { sink: warningSink, buffered: [] };
|
|
10407
|
+
}
|
|
10408
|
+
const buffered = [];
|
|
10409
|
+
return {
|
|
10410
|
+
sink: (message) => {
|
|
10411
|
+
buffered.push(message);
|
|
10412
|
+
},
|
|
10413
|
+
buffered
|
|
10414
|
+
};
|
|
10415
|
+
}
|
|
10416
|
+
function isAliasNoticeEligible(input) {
|
|
10417
|
+
return input.aliasedCustomConfigPath !== undefined && (input.bufferedCount > 0 || input.hasProtectedFields);
|
|
10418
|
+
}
|
|
10419
|
+
function emitAliasFailureDiagnostics(input) {
|
|
10420
|
+
if (!isAliasNoticeEligible({
|
|
10421
|
+
aliasedCustomConfigPath: input.aliasedCustomConfigPath,
|
|
10422
|
+
bufferedCount: input.buffered.length,
|
|
10423
|
+
hasProtectedFields: input.hasProtectedFields
|
|
10424
|
+
})) {
|
|
10425
|
+
return;
|
|
10426
|
+
}
|
|
10427
|
+
if (input.projectLoaded && input.customLoaded)
|
|
10428
|
+
return;
|
|
10429
|
+
for (const message of input.buffered)
|
|
10430
|
+
input.warningSink(message);
|
|
10431
|
+
}
|
|
10432
|
+
function buildAliasSuccessNotice(input) {
|
|
10433
|
+
if (!isAliasNoticeEligible({
|
|
10434
|
+
aliasedCustomConfigPath: input.aliasedCustomConfigPath,
|
|
10435
|
+
bufferedCount: input.bufferedCount,
|
|
10436
|
+
hasProtectedFields: input.hasProtectedFields
|
|
10437
|
+
}) || !(input.projectLoaded && input.customLoaded) || input.aliasedCustomConfigPath === undefined) {
|
|
10438
|
+
return;
|
|
10439
|
+
}
|
|
10440
|
+
const aliasedCustomConfigPath = input.aliasedCustomConfigPath;
|
|
10441
|
+
const projectConfigPath = input.projectConfigPath;
|
|
10442
|
+
const warningSink = input.warningSink;
|
|
10443
|
+
return () => {
|
|
10444
|
+
warningSink(`[systematic] project config (${sanitizeDiagnosticText(projectConfigPath)}) and custom config (${sanitizeDiagnosticText(aliasedCustomConfigPath)}) resolve to the same file; protected fields stripped from the project pass (security-overlay fields, \`profiles\`, \`workflow_guard\`) apply through the custom-trust pass instead.`);
|
|
10445
|
+
};
|
|
10446
|
+
}
|
|
10322
10447
|
function loadConfigWithSources(projectDir, options) {
|
|
10323
10448
|
const includeProject = options?.includeProject ?? true;
|
|
10324
10449
|
const invalidSource = options?.invalidSource ?? "throw";
|
|
10325
10450
|
const paths = getConfigPaths(projectDir, options);
|
|
10326
10451
|
const warningSink = options?.warningSink ?? console.warn;
|
|
10327
|
-
const
|
|
10328
|
-
const
|
|
10452
|
+
const aliasedCustomConfigPath = resolveAliasedCustomConfigPath(paths, includeProject);
|
|
10453
|
+
const projectStrip = createAliasStripTracker(warningSink, aliasedCustomConfigPath);
|
|
10454
|
+
const boundedProjectStrip = createBoundedStripWarningSink(projectStrip.sink);
|
|
10455
|
+
const user = loadConfigSource(paths.userConfig, "user", invalidSource, warningSink);
|
|
10456
|
+
const project = includeProject ? loadConfigSource(paths.projectConfig, "project", invalidSource, boundedProjectStrip.sink) : {
|
|
10329
10457
|
metadata: { kind: "project", presence: "absent" },
|
|
10330
10458
|
source: null
|
|
10331
10459
|
};
|
|
10332
|
-
const custom = paths.customConfig ? loadConfigSource(paths.customConfig, "custom", invalidSource) : {
|
|
10460
|
+
const custom = paths.customConfig ? loadConfigSource(paths.customConfig, "custom", invalidSource, warningSink) : {
|
|
10333
10461
|
metadata: { kind: "custom", presence: "absent" },
|
|
10334
10462
|
source: null
|
|
10335
10463
|
};
|
|
10336
10464
|
const userSource = user.source;
|
|
10337
10465
|
const projectSource = project.source;
|
|
10338
10466
|
const customSource = custom.source;
|
|
10467
|
+
if (projectSource?.protectedFields.some((field) => field.fieldPath === "profiles")) {
|
|
10468
|
+
boundedProjectStrip.sink(`[systematic] \`profiles\` in project config (${sanitizeDiagnosticText(projectSource.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\`.`);
|
|
10469
|
+
}
|
|
10470
|
+
const suppressedStripCount = boundedProjectStrip.suppressedCount();
|
|
10471
|
+
if (suppressedStripCount > 0) {
|
|
10472
|
+
projectStrip.sink(`[systematic] ${suppressedStripCount} additional project-config protected-field warning(s) in (${sanitizeDiagnosticText(paths.projectConfig)}) were suppressed.`);
|
|
10473
|
+
}
|
|
10474
|
+
emitAliasFailureDiagnostics({
|
|
10475
|
+
aliasedCustomConfigPath,
|
|
10476
|
+
buffered: projectStrip.buffered,
|
|
10477
|
+
customLoaded: custom.source !== null,
|
|
10478
|
+
hasProtectedFields: (projectSource?.protectedFields.length ?? 0) > 0,
|
|
10479
|
+
projectLoaded: project.source !== null,
|
|
10480
|
+
warningSink
|
|
10481
|
+
});
|
|
10482
|
+
const emitAliasSuccessNotice = buildAliasSuccessNotice({
|
|
10483
|
+
aliasedCustomConfigPath,
|
|
10484
|
+
bufferedCount: projectStrip.buffered.length,
|
|
10485
|
+
customLoaded: custom.source !== null,
|
|
10486
|
+
hasProtectedFields: (projectSource?.protectedFields.length ?? 0) > 0,
|
|
10487
|
+
projectConfigPath: paths.projectConfig,
|
|
10488
|
+
projectLoaded: project.source !== null,
|
|
10489
|
+
warningSink
|
|
10490
|
+
});
|
|
10339
10491
|
const sources = [userSource, projectSource, customSource].filter((source) => source !== null);
|
|
10340
10492
|
const userConfig = userSource?.config;
|
|
10341
10493
|
const projectConfig = projectSource?.config;
|
|
10342
10494
|
const customConfig = customSource?.config;
|
|
10343
10495
|
const warned = new Set;
|
|
10344
|
-
if (projectSource?.protectedFields.some((field) => field.fieldPath === "profiles")) {
|
|
10345
|
-
warningSink(`[systematic] \`profiles\` in project config (${projectSource.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\`.`);
|
|
10346
|
-
}
|
|
10347
10496
|
assertAllProfileBundlesAreValid(userConfig, customConfig);
|
|
10348
10497
|
const profileSelection = resolveActiveProfile({
|
|
10349
10498
|
userConfig,
|
|
@@ -10415,6 +10564,7 @@ function loadConfigWithSources(projectDir, options) {
|
|
|
10415
10564
|
disabled_skills: result.disabled_skills.filter((n) => !droppedSkillSet.has(n)),
|
|
10416
10565
|
disabled_agents: result.disabled_agents.filter((n) => !droppedAgentSet.has(n))
|
|
10417
10566
|
};
|
|
10567
|
+
emitAliasSuccessNotice?.();
|
|
10418
10568
|
return {
|
|
10419
10569
|
config: effectiveConfig,
|
|
10420
10570
|
metadata: buildConfigObservationMetadata({
|
|
@@ -10457,7 +10607,7 @@ function buildConfigObservationMetadata(summary) {
|
|
|
10457
10607
|
if (authority)
|
|
10458
10608
|
authorities.push(authority);
|
|
10459
10609
|
}
|
|
10460
|
-
const protectedFields = summary.sources
|
|
10610
|
+
const protectedFields = collectVisibleProtectedFields(summary.sources);
|
|
10461
10611
|
const sources = dedupeSourceMetadata([summary.custom, summary.project, summary.user], sourcePaths);
|
|
10462
10612
|
return {
|
|
10463
10613
|
authorities: sortAuthorities(authorities),
|
|
@@ -10468,6 +10618,12 @@ function buildConfigObservationMetadata(summary) {
|
|
|
10468
10618
|
profileFallback: summary.profileSelection.profileFallback
|
|
10469
10619
|
};
|
|
10470
10620
|
}
|
|
10621
|
+
function collectVisibleProtectedFields(sources) {
|
|
10622
|
+
const projectSource = sources.find((source) => source.trust === "project");
|
|
10623
|
+
const customSource = sources.find((source) => source.trust === "custom");
|
|
10624
|
+
const projectAppliedViaCustom = projectSource !== undefined && customSource !== undefined && projectSource.canonicalPath === customSource.canonicalPath;
|
|
10625
|
+
return sources.flatMap((source) => projectAppliedViaCustom && source.trust === "project" ? [] : source.protectedFields);
|
|
10626
|
+
}
|
|
10471
10627
|
function dedupeSourceMetadata(metadata, sourcePaths) {
|
|
10472
10628
|
const seen = new Set;
|
|
10473
10629
|
return metadata.filter((source) => {
|
|
@@ -10583,9 +10739,6 @@ function mergeOverlayMap(target, source, mapKey) {
|
|
|
10583
10739
|
if (!isRecord2(value)) {
|
|
10584
10740
|
throwInvalidOverlay(source.path, keyPath);
|
|
10585
10741
|
}
|
|
10586
|
-
if (source.kind === "file" && source.trust === "project") {
|
|
10587
|
-
rejectProjectSecurityOverlay(source.path, keyPath, value);
|
|
10588
|
-
}
|
|
10589
10742
|
const previous = target[key];
|
|
10590
10743
|
const nextValue = resolveOverlayEntryValue(previous?.value, value, source);
|
|
10591
10744
|
target[key] = {
|
|
@@ -10605,12 +10758,18 @@ function resolveOverlayEntryValue(previous, next, source) {
|
|
|
10605
10758
|
return preserveSecurityFields(previous, next);
|
|
10606
10759
|
return next;
|
|
10607
10760
|
}
|
|
10608
|
-
function
|
|
10761
|
+
function stripProjectSecurityOverlay(sourcePath, keyPath, value, warningSink) {
|
|
10762
|
+
const safeKeyPath = sanitizeDiagnosticText(keyPath);
|
|
10763
|
+
const safeSourcePath = sanitizeDiagnosticText(sourcePath);
|
|
10764
|
+
let stripped;
|
|
10609
10765
|
for (const field of SECURITY_OVERLAY_FIELDS) {
|
|
10610
10766
|
if (Object.hasOwn(value, field)) {
|
|
10611
|
-
|
|
10767
|
+
stripped ??= { ...value };
|
|
10768
|
+
delete stripped[field];
|
|
10769
|
+
warningSink(`[systematic] \`${safeKeyPath}.${field}\` in project config (${safeSourcePath}) is only valid in user config or OPENCODE_CONFIG_DIR config and has been ignored.`);
|
|
10612
10770
|
}
|
|
10613
10771
|
}
|
|
10772
|
+
return stripped ?? value;
|
|
10614
10773
|
}
|
|
10615
10774
|
function preserveSecurityFields(previous, next) {
|
|
10616
10775
|
const result = { ...next };
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
},
|
|
69
69
|
"__schema2": {
|
|
70
70
|
"default": {},
|
|
71
|
-
"description": "Per-agent configuration overlays keyed by bundled agent name (bare or qualified category/name). Unknown keys are rejected with a Zod parse error. To overlay a user-defined agent, configure it through OpenCode-native config (.opencode/opencode.json) instead.",
|
|
71
|
+
"description": "Per-agent configuration overlays keyed by bundled agent name (bare or qualified category/name). Unknown keys are rejected with a Zod parse error, except that a project config entry under an unknown key is discarded before that check if stripping trust-protected fields leaves it empty. To overlay a user-defined agent, configure it through OpenCode-native config (.opencode/opencode.json) instead. Trust-protected fields (model, variant, skills, permission, opencode, pi) are only valid in user config or OPENCODE_CONFIG_DIR config — a project config setting them has that field ignored with a warning; other fields in the same overlay still apply.",
|
|
72
72
|
"examples": [
|
|
73
73
|
{
|
|
74
74
|
"correctness-reviewer": {
|
|
@@ -994,7 +994,7 @@
|
|
|
994
994
|
},
|
|
995
995
|
"__schema42": {
|
|
996
996
|
"default": {},
|
|
997
|
-
"description": "Per-category configuration overlays keyed by category name",
|
|
997
|
+
"description": "Per-category configuration overlays keyed by category name. Trust-protected fields (model, variant, skills, permission, opencode, pi) are only valid in user config or OPENCODE_CONFIG_DIR config — a project config setting them has that field ignored with a warning; other fields in the same overlay still apply.",
|
|
998
998
|
"examples": [
|
|
999
999
|
{
|
|
1000
1000
|
"review": {
|
|
@@ -1221,7 +1221,7 @@
|
|
|
1221
1221
|
}
|
|
1222
1222
|
},
|
|
1223
1223
|
"__schema58": {
|
|
1224
|
-
"description": "Per-agent routing overlays for this profile, keyed by bundled agent name (bare or qualified category/name), using the same routing-only field set as every profile entry. Unknown keys are rejected with a Zod parse error
|
|
1224
|
+
"description": "Per-agent routing overlays for this profile, keyed by bundled agent name (bare or qualified category/name), using the same routing-only field set as every profile entry. Unknown keys are rejected with a Zod parse error.",
|
|
1225
1225
|
"examples": [
|
|
1226
1226
|
{
|
|
1227
1227
|
"correctness-reviewer": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fro.bot/systematic",
|
|
3
|
-
"version": "3.18.
|
|
3
|
+
"version": "3.18.10",
|
|
4
4
|
"description": "Compound-engineering loops for OpenCode, Pi, and Claude Code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://fro.bot/systematic",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"@tintinweb/pi-subagents": "0.14.3",
|
|
106
106
|
"@types/bun": "latest",
|
|
107
107
|
"@types/js-yaml": "4.0.9",
|
|
108
|
-
"@types/node": "26.
|
|
108
|
+
"@types/node": "26.6.1",
|
|
109
109
|
"agent-browser": "0.34.0",
|
|
110
110
|
"ajv": "8.20.0",
|
|
111
111
|
"ajv-formats": "3.0.1",
|