feat(acr,yaml): v5.6 Foundation — load-pattern enumeration + block-seq parser
Foundation chunk of v5.6 "steering-model II" (internal plumbing for B/C;
no command-output change, so --json/--raw/SC-5/6/7 stay byte-stable, count
stays 13).
active-config-reader.mjs:
- deriveLoadPattern(kind,{scoped}) — pure helper mapping each source kind to
loadPattern {always,on-demand,external} + survivesCompaction {yes,no,n/a}
+ derivationConfidence {confirmed,inferred}, traced to the published
loading model (V-rows in docs/v5.5-steering-model-plan.md).
- enumerateRules / enumerateAgents / enumerateOutputStyles — the three
source kinds previously unenumerated (mirror enumerateSkills). Output-style
discovery is direct (not a new file-discovery type) to keep the discovery
surface stable.
- readActiveConfig now exposes rules/agents/outputStyles arrays + totals
counts/subtotals (folded into grandTotal).
yaml-parser.mjs:
- parseSimpleYaml now reads YAML block sequences (paths:\n - a), not just
inline paths:. An empty-valued key with no `- ` items stays null
(backcompat). Resolves a pre-existing RUL false-positive (a block-seq-scoped
rule was misread as unscoped) — fix flows through unchanged RUL code.
Tests +35 (961 -> 996): block-seq parser cases, RUL block-seq regression
(no-misflag + durability-fires), deriveLoadPattern table, three enumerators
(positive+negative). Amended two existing ACR asserts (top-level key shape +
grandTotal sum). self-audit A/A, readmeCheck passed, mismatches []. tests
badge 961+->996+; README testing prose de-staled (635/36 -> 996/56);
CLAUDE.md Foundation note.
B (manifest/tokens render + snapshot regen) and C (CA-OST, count->14)
deferred to their own sessions/GO.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ter3E2JSi1Khgmuf2kady8
This commit is contained in:
parent
d03c3831bd
commit
62d910ed6d
8 changed files with 575 additions and 25 deletions
|
|
@ -34,17 +34,51 @@ export function parseSimpleYaml(yaml) {
|
|||
let currentKey = null;
|
||||
let multiLineValue = '';
|
||||
let inMultiLine = false;
|
||||
// Block-sequence state: an empty-valued key may be a YAML block sequence
|
||||
// key:
|
||||
// - item
|
||||
// - item
|
||||
// We defer the decision until the next line: a `- item` line starts an array;
|
||||
// anything else (or end-of-input) leaves the empty-valued key as `null` —
|
||||
// indistinguishable from a plain null value, preserving backwards compatibility.
|
||||
let seqKey = null; // key awaiting/collecting block-sequence items
|
||||
let seqItems = null; // null until the first `- ` item is seen
|
||||
let seqPending = false; // an empty-valued key was seen; items may follow
|
||||
|
||||
// Commit the current block-sequence (or empty-valued key) to result.
|
||||
const commitSeq = () => {
|
||||
if (seqKey !== null) {
|
||||
result[normalizeKey(seqKey)] = seqItems !== null ? seqItems : null;
|
||||
}
|
||||
seqKey = null;
|
||||
seqItems = null;
|
||||
seqPending = false;
|
||||
};
|
||||
|
||||
for (const line of lines) {
|
||||
// Skip comments and empty lines
|
||||
// Skip comments and empty lines (these do NOT terminate a block sequence)
|
||||
if (line.trim().startsWith('#') || line.trim() === '') {
|
||||
if (inMultiLine) multiLineValue += '\n';
|
||||
continue;
|
||||
}
|
||||
|
||||
// Block-sequence item: only while a sequence is pending or active
|
||||
const seqMatch = (seqPending || seqItems !== null) && !inMultiLine
|
||||
? line.match(/^\s+-\s*(.*)$/)
|
||||
: null;
|
||||
if (seqMatch) {
|
||||
if (seqItems === null) seqItems = [];
|
||||
const itemVal = parseValue(seqMatch[1].trim());
|
||||
if (itemVal !== null && itemVal !== '') seqItems.push(itemVal);
|
||||
seqPending = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Key-value pair
|
||||
const kvMatch = line.match(/^(\w[\w-]*):\s*(.*)/);
|
||||
if (kvMatch && !inMultiLine) {
|
||||
// A new key terminates any pending/active block sequence.
|
||||
commitSeq();
|
||||
if (currentKey && multiLineValue) {
|
||||
result[normalizeKey(currentKey)] = multiLineValue.trim();
|
||||
}
|
||||
|
|
@ -58,6 +92,15 @@ export function parseSimpleYaml(yaml) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (value === '') {
|
||||
// Defer: this may be a block sequence (next line) or a null value.
|
||||
seqKey = currentKey;
|
||||
seqItems = null;
|
||||
seqPending = true;
|
||||
currentKey = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
result[normalizeKey(currentKey)] = parseValue(value);
|
||||
currentKey = null;
|
||||
continue;
|
||||
|
|
@ -79,6 +122,13 @@ export function parseSimpleYaml(yaml) {
|
|||
currentKey = null;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// A non-item, non-key line while a sequence is pending/active terminates it
|
||||
// (then the line is ignored, as before the fix).
|
||||
if (seqPending || seqItems !== null) {
|
||||
commitSeq();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -86,6 +136,8 @@ export function parseSimpleYaml(yaml) {
|
|||
if (inMultiLine && currentKey) {
|
||||
result[normalizeKey(currentKey)] = multiLineValue.trim();
|
||||
}
|
||||
// Flush a trailing block sequence / empty-valued key
|
||||
commitSeq();
|
||||
|
||||
// Normalize arrays for known list fields
|
||||
for (const field of ['allowed_tools', 'tools', 'paths', 'globs']) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue