chore(ultraplan-local): Spor 0 — foundation for v3.1.0 kvalitetsprogram
- package.json med node:test runner og scripts (test, simulate), zero deps - settings.json: fjern vestigial exploration- og agentTeam-blokker (verifisert leset av ingen kode via grep) - docs/: commit subagent-delegation-audit.md og ultraexecute-v2-observations-from-config-audit-v4.md (begge real arkitektur-notater) - docs/: arkiver ultra-suite-brief_2.md som _archive- (var paste fra annet plugin-arbeid, irrelevant her) - tests/helpers/hook-helper.mjs kopiert fra llm-security m/ provenance-kommentar Forberedelse for Spor 1 (lib/-moduler), Spor 2 (HANDOVER-CONTRACTS + PreCompact-hook), Spor 3 (bug-fixes + CC-features). Plan: ~/.claude/plans/det-neste-vi-gj-r-eventual-adleman.md Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
ab504bdf8c
commit
1016914fc1
6 changed files with 487 additions and 39 deletions
45
plugins/ultraplan-local/tests/helpers/hook-helper.mjs
Normal file
45
plugins/ultraplan-local/tests/helpers/hook-helper.mjs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// hook-helper.mjs — Shared test helper for hook scripts.
|
||||
// Spawns a hook as a child process and feeds it JSON via stdin.
|
||||
//
|
||||
// Source: ../../../llm-security/tests/hooks/hook-helper.mjs (verbatim copy)
|
||||
// Provenance: borrowed within the same marketplace (same author, MIT).
|
||||
|
||||
import { execFile } from 'node:child_process';
|
||||
|
||||
/**
|
||||
* Run a hook script by spawning `node <scriptPath>` and piping `input` to stdin.
|
||||
*
|
||||
* @param {string} scriptPath - Absolute path to the hook .mjs file
|
||||
* @param {object|string} input - JSON payload (object will be stringified)
|
||||
* @returns {Promise<{ code: number, stdout: string, stderr: string }>}
|
||||
*/
|
||||
export function runHook(scriptPath, input) {
|
||||
return runHookWithEnv(scriptPath, input, {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a hook script with custom environment variables.
|
||||
*
|
||||
* @param {string} scriptPath - Absolute path to the hook .mjs file
|
||||
* @param {object|string} input - JSON payload (object will be stringified)
|
||||
* @param {Record<string, string>} envOverrides - Extra env vars to set
|
||||
* @returns {Promise<{ code: number, stdout: string, stderr: string }>}
|
||||
*/
|
||||
export function runHookWithEnv(scriptPath, input, envOverrides) {
|
||||
return new Promise((resolve) => {
|
||||
const env = { ...process.env, ...envOverrides };
|
||||
const child = execFile(
|
||||
'node',
|
||||
[scriptPath],
|
||||
{ timeout: 5000, env },
|
||||
(err, stdout, stderr) => {
|
||||
resolve({
|
||||
code: child.exitCode ?? (err && err.code === 'ERR_CHILD_PROCESS_STDIO_FINAL' ? 0 : 1),
|
||||
stdout: stdout || '',
|
||||
stderr: stderr || '',
|
||||
});
|
||||
}
|
||||
);
|
||||
child.stdin.end(typeof input === 'string' ? input : JSON.stringify(input));
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue