Files
msd-core/examples/dynamic-context-management/demo.cjs
Tom Boucher cc2e33b098 docs(#1672): add ADR-1671 dynamic context management platform + reference example (#1674)
Phase 0 of the Dynamic Context Management epic (#1671): the ADR (documentation) plus a non-shipping reference example under examples/dynamic-context-management/ — the Option-E predicate fact-store parser/selector, a self-contained --check/--write/--select index generator, a sample index, and a runnable demo.

The example is intentionally excluded from the build (src/->bin/lib/), the npm package files[], the installer, and the CI test suite (tests/) — nothing here is compiled into or installed with GSD. Production implementation lands in a later phase.

Resolves #1672

Refs #1671

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 19:48:51 -04:00

31 lines
1021 B
JavaScript

#!/usr/bin/env node
'use strict';
/**
* Runnable usage example for the Option-E predicate fact-store (ADR-1671).
* Reference example only — not shipped, not part of the CI suite.
*
* node examples/dynamic-context-management/demo.cjs
*/
const fs = require('node:fs');
const path = require('node:path');
const { parsePredicates, selectPredicates } = require('./context-predicates.cjs');
const md = fs.readFileSync(path.resolve(__dirname, '..', '..', 'CONTEXT.md'), 'utf8');
const { predicates, duplicates } = parsePredicates(md);
const classes = new Set(predicates.map((p) => p.klass));
process.stdout.write(
`Parsed ${predicates.length} predicates across ${classes.size} classes; ` +
`${duplicates.length} duplicate id(s).\n`,
);
const slice = selectPredicates(predicates, { prefix: 'PRED.k320' });
process.stdout.write(
`\nselectPredicates({ prefix: 'PRED.k320' }) -> ${slice.length} matches ` +
`(a JIT brief slice):\n`,
);
for (const p of slice) process.stdout.write(` ${p.id} = ${p.value}\n`);