fix(okr): B2 ingestion-kode-hygiene + bump 1.7.1 (patch-lane)
8 hygiene-fikser fra review 2026-07-16 par.4 kode-lista, TDD roed-groenn (suite 138 -> 149): - innboks-split: slugify translittererer ae/oe (datatap-fiks) - innboks-frontmatter: beskrivende feil ved manglende sourceMtime - okf-index: --okf-version bumper eksisterende rot, flagg-tolerant CLI (exit 2 ved manglende verdi), sanitizeEntry strip C1/zero-width/bidi/ Unicode-tag - write-org-profile: circuit-breaker MERGER i stedet for aa overskrive full config (M4); test beviser at eksisterende config overlever - compose-org-profile: intern ----linje trunkerer ikke blokken - coaching-hook: at-risk teller status-markerte tabellrader (M1/m1) - inject-okr-context: topic-guard treffer boeyningsformer (maalene) - frontmatter: BOM/CRLF-toleranse (falsk mangler-type-fiks) Versjonsflater bumpet til 1.7.1 (package/plugin/lock/CLAUDE/README/ SKILL x2/package-shape-test) + CHANGELOG 1.7.1-seksjon (B1+B2). Release-tag + katalog-ref venter paa [G-B] operatoer-go. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
6028ac2f90
commit
482effbad1
25 changed files with 289 additions and 29 deletions
|
|
@ -12,7 +12,7 @@
|
|||
// Mirrors the canonical home path defined in
|
||||
// hooks/scripts/inject-okr-context.mjs:14 (the most-specific-wins read side).
|
||||
|
||||
import { readFileSync, writeFileSync, mkdirSync, renameSync } from 'node:fs';
|
||||
import { readFileSync, writeFileSync, mkdirSync, renameSync, existsSync } from 'node:fs';
|
||||
import { join, dirname } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
|
||||
|
|
@ -39,6 +39,22 @@ function writeAtomic(target, data) {
|
|||
renameSync(tmp, target);
|
||||
}
|
||||
|
||||
// M4 (B2): the fallback target (.claude/okr.local.md) may already carry the
|
||||
// FULL project config (cycle id, fase, onboarding, Linear). The circuit-breaker
|
||||
// must never overwrite it -- merge instead: the incoming profile's frontmatter
|
||||
// lines go FIRST inside ONE block (the flat parser is first-match, so the new
|
||||
// profile wins per key), the existing frontmatter lines and body follow intact.
|
||||
function mergeIntoExisting(target, incoming) {
|
||||
const prior = readFileSync(target, 'utf8');
|
||||
const incomingInner = (incoming.match(/^---\r?\n([\s\S]*?)\r?\n---/) || [])[1] ?? incoming.trim();
|
||||
const m = prior.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
|
||||
if (!m) {
|
||||
// Existing file without frontmatter: preserve it verbatim as body.
|
||||
return `---\n${incomingInner}\n---\n${prior}`;
|
||||
}
|
||||
return `---\n${incomingInner}\n${m[1]}\n---\n${m[2]}`;
|
||||
}
|
||||
|
||||
try {
|
||||
writeAtomic(homeTarget, content);
|
||||
process.stdout.write(homeTarget);
|
||||
|
|
@ -49,7 +65,7 @@ try {
|
|||
// historikk tree remains cwd-bound regardless; only the profile migrates.
|
||||
const fallback = join(process.cwd(), '.claude', 'okr.local.md');
|
||||
try {
|
||||
writeAtomic(fallback, content);
|
||||
writeAtomic(fallback, existsSync(fallback) ? mergeIntoExisting(fallback, content) : content);
|
||||
process.stderr.write(
|
||||
`notice: kunne ikke skrive hjem-profil (${err.code || err.message}); ` +
|
||||
`falt tilbake til prosjektlokal ${fallback}\n`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue