feat(okr): UserPromptSubmit emne-guard + test (SC6) [skip-docs]
This commit is contained in:
parent
b594eeb88c
commit
c7a0323a81
3 changed files with 116 additions and 3 deletions
|
|
@ -31,15 +31,21 @@ function makeProjectConfig(workDir, navn) {
|
|||
writeFileSync(join(p, 'okr.local.md'), `---\nnavn: "${navn}"\n---\n`);
|
||||
}
|
||||
|
||||
function runHook(cwd, home) {
|
||||
function runHook(cwd, home, input = '') {
|
||||
// execFileSync returns stdout; the hook always exits 0.
|
||||
// input pipes a UserPromptSubmit payload through stdin so the emne-guard
|
||||
// (topic guard) sees an explicit OKR-relevant prompt instead of suppressing.
|
||||
return execFileSync('node', [HOOK], {
|
||||
cwd,
|
||||
env: { ...process.env, HOME: home },
|
||||
input,
|
||||
encoding: 'utf8',
|
||||
});
|
||||
}
|
||||
|
||||
// OKR-relevant prompt slik at emne-guarden injiserer i stedet for aa suppresse.
|
||||
const OKR_PROMPT = JSON.stringify({ prompt: 'hjelp meg skrive OKR' });
|
||||
|
||||
function withDirs(fn) {
|
||||
const home = mkdtempSync(join(tmpdir(), 'okrhome-'));
|
||||
const work = mkdtempSync(join(tmpdir(), 'okrwork-'));
|
||||
|
|
@ -54,7 +60,7 @@ function withDirs(fn) {
|
|||
test('kun-hjem: leser org fra hjem-profil, ingen syklus-kontekst', () => {
|
||||
withDirs((home, work) => {
|
||||
makeHomeProfil(home, 'HjemOrg');
|
||||
const out = runHook(work, home);
|
||||
const out = runHook(work, home, OKR_PROMPT);
|
||||
assert.match(out, /HjemOrg/, 'org skal komme fra hjem-profil naar prosjekt-config mangler');
|
||||
assert.doesNotMatch(out, /Tilgjengelige kontekstfiler/, 'kun-hjem har ingen prosjekt-lokalt syklus-tre (okrDir er cwd-bundet)');
|
||||
});
|
||||
|
|
@ -64,7 +70,7 @@ test('begge: prosjekt-lokal vinner over hjem (mest-spesifikk-vinner)', () => {
|
|||
withDirs((home, work) => {
|
||||
makeHomeProfil(home, 'HjemOrg');
|
||||
makeProjectConfig(work, 'ProsjektOrg');
|
||||
const out = runHook(work, home);
|
||||
const out = runHook(work, home, OKR_PROMPT);
|
||||
assert.match(out, /ProsjektOrg/, 'prosjekt-lokal skal vinne');
|
||||
assert.doesNotMatch(out, /HjemOrg/, 'hjem skal ikke leses naar prosjekt-config finnes');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue