Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions LifeOS/install/hooks/DocIntegrity.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { readHookInput, parseTranscriptFromInput } from './lib/hook-io';
import { handleDocCrossRefIntegrity } from './handlers/DocCrossRefIntegrity';
import { handleRebuildArchSummary } from './handlers/RebuildArchSummary';
import { handleMemoryDirIntegrity } from './handlers/MemoryDirIntegrity';
import { handleRebuildKnowledgeSchema } from './handlers/RebuildKnowledgeSchema';

async function main() {
const input = await readHookInput();
Expand Down Expand Up @@ -59,6 +60,12 @@ async function main() {
console.error('[DocIntegrity] Memory-dir handler failed:', err);
}

try {
await handleRebuildKnowledgeSchema();
} catch (err) {
console.error('[DocIntegrity] Knowledge-schema regen failed:', err);
}

process.exit(0);
}

Expand Down
21 changes: 21 additions & 0 deletions LifeOS/install/hooks/handlers/RebuildKnowledgeSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* RebuildKnowledgeSchema — regenerate `MEMORY/KNOWLEDGE/_schema.md` from
* `KnowledgeSchema.ts` (the pure-data source of truth) on the doc-integrity
* pass, so the schema doc never drifts from the schema and exists on every
* install. Fire-and-forget; a failure is non-fatal (logged by the caller).
*
* Runs the standalone generator as a subprocess rather than importing it,
* because `GenerateKnowledgeSchemaDoc.ts` executes `main()` on import.
*/
import { spawn } from "child_process";
import { join } from "path";
import { getLifeosDir } from "../lib/paths";

export async function handleRebuildKnowledgeSchema(): Promise<void> {
const generator = join(getLifeosDir(), "TOOLS", "GenerateKnowledgeSchemaDoc.ts");
await new Promise<void>((resolve) => {
const child = spawn("bun", [generator], { stdio: "ignore" });
child.on("close", () => resolve());
child.on("error", () => resolve());
});
}