feat(ms-ai-architect): Sesjon 20 — B3 create_skill (dvelende, konstruktiv op) [skip-docs]
B3 + Spor B (krav 5+6) KOMPLETT. create_skill er speilbildet av de destruktive ops: merge/saner/retire beviser "ingen kuratert verdi TAPT"; create beviser "ingen sub-bar skill FØDT" (kvalitetsgulv). Ingen ny domene-skill shippet (svar 3) — mekanismen bevist, ikke brukt. - planCreateSkill (ren): genererer scaffold + selv-validerer mot eval.mjs sine EGNE checkers (K2/K3/K5/K6/refTall + K10) — rubrikken har én kilde. Guardrail ok iff alle deterministiske K passerer + K10<terskel + navn ledig. - TEST_DOMAIN_SPEC: kanonisk dvelende-scaffold (born compliant, K5 ratio 1.0). - runCreatePlan (uren): gated dry-run, 0 skriving til skills/. - applyApprovedAction create-gren: re-plan fersk → revalider (drift+kollisjon) → skriv scaffold + persister taksonomi-tillegg → flipp ledger. - applyCategoryAdditions (taxonomy.mjs): additiv, klobrer aldri eksisterende eier. - CLI create-verb i plan-skill-op + apply-skill-op. TDD: ny test-skill-ops-create.test.mjs (16). kb-eval 84→100. Suiter uendret: validate 239 · kb-update 139 · kb-integrity 192/192. Deterministisk eval K1–K10 for de 5 ekte: 0 regresjon. 0 ekte skills/-mutasjon. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
de3a9a483b
commit
e47fc9bd59
5 changed files with 758 additions and 11 deletions
|
|
@ -21,26 +21,59 @@
|
|||
// node scripts/kb-eval/apply-skill-op.mjs retire <skill> [--apply] [--date YYYY-MM-DD]
|
||||
// node scripts/kb-eval/apply-skill-op.mjs merge <absorber> <absorbed> [--apply] [--date YYYY-MM-DD]
|
||||
|
||||
import { readFileSync, readdirSync, existsSync } from 'node:fs';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { splitFrontmatter, extractDescription } from './eval.mjs';
|
||||
import { loadTaxonomy } from '../kb-update/lib/taxonomy.mjs';
|
||||
import { loadDecisions, listActions, actionKey } from '../kb-update/lib/decisions-io.mjs';
|
||||
import { applyApprovedAction, SANITIZE_OPERATION, RETIRE_OPERATION, MERGE_OPERATION } from './lib/skill-ops.mjs';
|
||||
import {
|
||||
applyApprovedAction,
|
||||
SANITIZE_OPERATION,
|
||||
RETIRE_OPERATION,
|
||||
MERGE_OPERATION,
|
||||
CREATE_OPERATION,
|
||||
TEST_DOMAIN_SPEC,
|
||||
} from './lib/skill-ops.mjs';
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const PLUGIN_ROOT = join(__dirname, '..', '..');
|
||||
const SKILLS_DIR = join(PLUGIN_ROOT, 'skills');
|
||||
const AGENTS_DIR = join(PLUGIN_ROOT, 'agents');
|
||||
const LEDGER_DATA_DIR = join(__dirname, '..', 'kb-update', 'data');
|
||||
const PROMPTS_FILE = join(__dirname, 'data', 'k1-trigger-prompts.json');
|
||||
|
||||
const OP_BY_VERB = { sanitize: SANITIZE_OPERATION, retire: RETIRE_OPERATION, merge: MERGE_OPERATION };
|
||||
const OP_BY_VERB = {
|
||||
sanitize: SANITIZE_OPERATION,
|
||||
retire: RETIRE_OPERATION,
|
||||
merge: MERGE_OPERATION,
|
||||
create: CREATE_OPERATION,
|
||||
};
|
||||
|
||||
/** Read the SKILL.md descriptions from disk (read-only) — create's K10 siblings. */
|
||||
function loadDescriptions() {
|
||||
const out = {};
|
||||
for (const e of readdirSync(SKILLS_DIR, { withFileTypes: true })) {
|
||||
if (!e.isDirectory()) continue;
|
||||
const md = join(SKILLS_DIR, e.name, 'SKILL.md');
|
||||
if (!existsSync(md)) continue;
|
||||
out[e.name] = extractDescription(splitFrontmatter(readFileSync(md, 'utf8')).frontmatter);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Read the curated K1 trigger-prompt set (boundary-tension source for K10). */
|
||||
function loadPromptSet() {
|
||||
return existsSync(PROMPTS_FILE) ? JSON.parse(readFileSync(PROMPTS_FILE, 'utf8')) : {};
|
||||
}
|
||||
|
||||
const USAGE =
|
||||
'Usage:\n' +
|
||||
' node scripts/kb-eval/apply-skill-op.mjs list\n' +
|
||||
' node scripts/kb-eval/apply-skill-op.mjs sanitize <skill> [--apply] [--date YYYY-MM-DD]\n' +
|
||||
' node scripts/kb-eval/apply-skill-op.mjs retire <skill> [--apply] [--date YYYY-MM-DD]\n' +
|
||||
' node scripts/kb-eval/apply-skill-op.mjs merge <absorber> <absorbed> [--apply] [--date YYYY-MM-DD]';
|
||||
' node scripts/kb-eval/apply-skill-op.mjs merge <absorber> <absorbed> [--apply] [--date YYYY-MM-DD]\n' +
|
||||
' node scripts/kb-eval/apply-skill-op.mjs create <name> [--apply] [--date YYYY-MM-DD]';
|
||||
|
||||
/** List approved actions awaiting apply (operator's apply queue). */
|
||||
function listApproved() {
|
||||
|
|
@ -51,7 +84,7 @@ function listApproved() {
|
|||
if (!approved.length) console.log(' (ingen — kjør plan-skill-op … --write og sett status:approved i decisions.json)');
|
||||
for (const a of approved) {
|
||||
const t = a.targets ?? {};
|
||||
const tgt = t.skill ?? `${t.absorbed} -> ${t.absorber}`;
|
||||
const tgt = t.skill ?? t.name ?? `${t.absorbed} -> ${t.absorber}`;
|
||||
console.log(` • ${a.operation_type}: ${tgt} [guardrail ${a.guardrail?.ok ? 'OK' : 'FAILED'}]`);
|
||||
}
|
||||
if (applied.length) console.log(`\nAllerede anvendt (${applied.length}): ${applied.map((a) => actionKey(a)).join(', ')}`);
|
||||
|
|
@ -73,6 +106,12 @@ function printResult(res, verb, label, apply) {
|
|||
`${d.taxonomyReassignments?.length ?? 0} kategori(er), arkivert absorbed-SKILL.md. ` +
|
||||
`Kjør på nytt med --apply for å eksekvere.`,
|
||||
);
|
||||
} else if (verb === 'create') {
|
||||
const sc = res.plan?.scaffold ?? {};
|
||||
console.log(
|
||||
`\n Ville opprettet skills/${label}/ — 1 SKILL.md + ${sc.files?.length ?? 0} ref-fil(er), ` +
|
||||
`${sc.taxonomyAdditions?.length ?? 0} taksonomi-tillegg. Kjør på nytt med --apply for å eksekvere.`,
|
||||
);
|
||||
} else {
|
||||
const n = verb === 'sanitize' ? (d.removals?.length ?? 0) : (d.archiveMoves?.length ?? 0);
|
||||
console.log(`\n Ville arkivert+fjernet ${n} fil(er). Kjør på nytt med --apply for å eksekvere.`);
|
||||
|
|
@ -87,6 +126,9 @@ function printResult(res, verb, label, apply) {
|
|||
console.log(` flyttet: ${rep.refMoves} ref-fil(er) -> absorber`);
|
||||
console.log(` taksonomi: ${rep.taxonomyReassignments} kategori(er) reassignet + persistert`);
|
||||
if (rep.archivedSkillMd) console.log(` arkivert: ${rep.archivedSkillMd}`);
|
||||
} else if (rep.op === CREATE_OPERATION) {
|
||||
console.log(` opprettet: ${rep.filesWritten} fil(er) under ${rep.createdDir} (1 SKILL.md + ${rep.filesWritten - 1} ref-filer)`);
|
||||
console.log(` taksonomi: ${rep.taxonomyAdditions} tillegg (additivt)`);
|
||||
} else {
|
||||
console.log(` arkivert: ${rep.moves} fil(er) -> archive/`);
|
||||
}
|
||||
|
|
@ -111,7 +153,8 @@ function main() {
|
|||
process.exit(2);
|
||||
}
|
||||
|
||||
// Resolve targets + ledger key per op arity (merge takes two skills).
|
||||
// Resolve targets + ledger key per op arity (merge takes two skills; create
|
||||
// is keyed on its new name; sanitize/retire on their one skill).
|
||||
let targets, label;
|
||||
if (op === MERGE_OPERATION) {
|
||||
if (positional.length < 3) {
|
||||
|
|
@ -120,6 +163,13 @@ function main() {
|
|||
}
|
||||
targets = { absorber: positional[1], absorbed: positional[2] };
|
||||
label = `${targets.absorbed} -> ${targets.absorber}`;
|
||||
} else if (op === CREATE_OPERATION) {
|
||||
if (positional.length < 2) {
|
||||
console.error(USAGE);
|
||||
process.exit(2);
|
||||
}
|
||||
targets = { name: positional[1] };
|
||||
label = positional[1];
|
||||
} else {
|
||||
if (positional.length < 2) {
|
||||
console.error(USAGE);
|
||||
|
|
@ -141,8 +191,10 @@ function main() {
|
|||
process.exit(1);
|
||||
}
|
||||
|
||||
// retire + merge both consult the taxonomy (owned-category awareness / repoint).
|
||||
// retire + merge both consult the taxonomy (owned-category awareness / repoint);
|
||||
// create re-supplies its scaffold spec + K10 siblings for drift-safe revalidation.
|
||||
const needsTaxonomy = op === RETIRE_OPERATION || op === MERGE_OPERATION;
|
||||
const isCreate = op === CREATE_OPERATION;
|
||||
const res = applyApprovedAction(entry, {
|
||||
pluginRoot: PLUGIN_ROOT,
|
||||
skillsDir: SKILLS_DIR,
|
||||
|
|
@ -152,6 +204,9 @@ function main() {
|
|||
apply,
|
||||
decided_at: apply ? decided_at : null,
|
||||
categorySkill: needsTaxonomy ? loadTaxonomy(LEDGER_DATA_DIR).category_skill : undefined,
|
||||
createSpec: isCreate ? { description: TEST_DOMAIN_SPEC.description, categories: TEST_DOMAIN_SPEC.categories } : undefined,
|
||||
existingDescriptions: isCreate ? loadDescriptions() : undefined,
|
||||
promptSet: isCreate ? loadPromptSet() : undefined,
|
||||
});
|
||||
printResult(res, verb, label, apply);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue