feat: каркас bhl и валидатор спецификации (BHL-020, BHL-011)
packages/bhl: @baseline-harness/bhl 0.0.1 — детерминированный CLI без LLM/оркестрации/сервера/БД; JSON-конверт и коды выхода 0/1/2/3/4 задокументированы и закреплены тестами. validate: Ajv 2020-12 по схемам <root>/schemas, семантическая сверка ID, ссылок, RFC-2119 слов и циклов depends-on. Местный строгий gate (prettier, eslint --max-warnings 0, tsc strict) зелёный: 10 тестов.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
export interface EnvelopeError {
|
||||
code: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface Envelope {
|
||||
ok: boolean;
|
||||
command: string;
|
||||
data?: Record<string, unknown>;
|
||||
error?: EnvelopeError;
|
||||
}
|
||||
|
||||
export const ExitCode = {
|
||||
Ok: 0,
|
||||
ValidationFailed: 1,
|
||||
Usage: 2,
|
||||
NotImplemented: 3,
|
||||
Internal: 4,
|
||||
} as const;
|
||||
|
||||
export type ExitCodeValue = (typeof ExitCode)[keyof typeof ExitCode];
|
||||
|
||||
export function okEnvelope(command: string, data: Record<string, unknown>): Envelope {
|
||||
return { ok: true, command, data };
|
||||
}
|
||||
|
||||
export function failEnvelope(command: string, code: string, message: string): Envelope {
|
||||
return { ok: false, command, error: { code, message } };
|
||||
}
|
||||
|
||||
export function emit(envelope: Envelope): void {
|
||||
process.stdout.write(`${JSON.stringify(envelope, null, 2)}\n`);
|
||||
}
|
||||
Reference in New Issue
Block a user