Live Demo: Adaptive Context Package for LLM Prompts
iw index context-pack builds a single, token-budgeted RAG bundle — ranked files, symbols,
architecture rules, cross-layer connections, rationale, and doc drift — in one call, so you
can hand an LLM real context instead of letting it guess. The adaptive ranking layer
reorders that bundle using signals CARI already has: your import graph and directory shape.
The example below is a real run against IntentWeave’s own .iw/index.db — same query,
same anchor file, two adaptive modes. Toggle between them to see the ranking change.
Raw FTS + annotation ranking. Notice the zero-score files near the bottom — generic term matches with no real relevance (PR templates, unrelated ADRs, skill files).
- #1
docs/PLAN-ADAPTIVITY-CONTEXT-PACKAGE.md3.93 annotation match - #2
CHANGELOG.md3.39 annotation match - #3
packages/core/src/errors.ts2.25 annotated symbol: context - #4
packages/core/src/interfaces.ts2.25 annotated symbol: index - #5
packages/index/src/queries/contextPack.ts1.20 annotated symbol: contextPack - #6
docs/LIBRARY-API.md1.06 annotation + co-occurrence - #7
docs/LAYERED-GRAPH-ARCHITECTURE.md0.94 annotation + co-occurrence - #8
docs/PRODUCT-CONCEPT.md0.94 annotation: "noise reduction strategy" - #9
packages/core/src/types/kwg.ts0.75 annotated symbol: mentions - #10
packages/index/src/export/prescriptiveReport.ts0.75 annotated symbol: documentation - #11
packages/core/src/types/hooks.ts0.75 annotated symbol: strategy - #12
packages/index/src/__tests__/topology.test.ts0.12 annotation: "Ranking" - #13
packages/index/src/queries/surprises.ts0.12 annotation: "Ranking" - #14
.github/pull_request_template.md0.00 FTS fallback — co-occurs with "added" - #15
docs/ADR-001-INTENT-ENGINE.md0.00 FTS fallback - #16
.github/copilot-instructions.md0.00 FTS fallback - #17
.github/prompts/focused-architecture.prompt.md0.00 FTS fallback - #18
.github/skills/iw-drift-detection/SKILL.md0.00 FTS fallback - #19
README.md0.00 FTS fallback
iw index eval, real M2 validation reports)
| Repo | Noisy-path share (off → conservative) | Anchor hit rate (off → conservative) | Latency p50 / p95 (conservative) |
|---|---|---|---|
intentweave | 0% → 0% | 100% → 100% | 7.5ms / 17.9ms |
backstage | 21% → 0% | 0% → 88.9% | 35.9ms / 113.6ms |
codegraphchat-v2 | 14% → 3.7% | 70% → 90% | 111.3ms / 523.2ms |
IntentWeave’s own repo already sits at 0% noise / 100% hit rate without adaptation — it’s
small and well-curated, so there’s little for adaptive ranking to fix. The real gains show up
on larger, messier repos like Backstage and codegraphchat-v2. codegraphchat-v2’s p95
latency (523ms) is higher than the sub-100ms figure quoted elsewhere on this site for a single
iw index retrieve query — that’s expected: context-pack composes multiple sections (files,
rules, connections, rationale, doc drift) in one call, not a single ranked-retrieval query.
The eval methodology, target thresholds, and boost algorithm are documented in
the adaptivity rollout plan —
the same spec these numbers were measured against. The raw per-repo query sets
(.iw/eval/queries.json) are currently local fixtures, not yet published; if you want to
reproduce the Backstage/codegraphchat-v2 numbers independently, open an issue
and we’ll publish the fixture.
How This Works
Section titled “How This Works”- Baseline (
--adaptive=off) ranks files by annotation match, FTS relevance, and co-occurrence only — the same scoringiw index retrievehas always used. - Repo-shape adaptation (Phase B) downweights low-signal and “meta” directories
(
.changeset/,.specstory/,archive/,node_modules/, etc.) using per-directory annotation density computed straight from theannotationstable — no config needed, though.iw/config.yamllets you pin exceptions for paths you always want surfaced. - Anchor-aware adaptation (Phase C) boosts files that are actually connected to the
file(s) you pass via
--files: exact anchor (1.5×), same folder (1.2×), same package (1.1×), 1-hop import-neighbor (1.05×) — all read directly from theimportstable CARI already builds. In the demo above,check.ts,connections.ts,retrieve.ts,shared.ts, andtypes.tsall get promoted because they’re real imports of the anchor file,contextPack.ts.
Both are shipped and on by default (conservative mode). Intent classification, per-section
confidence budgeting, and a feedback-loop cache are specced in the roadmap but not yet
implemented — see Adaptive Context Package for the full rollout plan.
# Reproduce this locally, on your own repoiw index buildiw index context-pack \ --query "context-pack ranking noise" \ --files packages/index/src/queries/contextPack.ts \ --adaptive conservative --adaptive-explain \ --sections files --format json
# Measure it on a fixed query setiw index eval --queries .iw/eval/queries.json --adaptive conservative