Skip to content

Commit 45aa004

Browse files
ContextForgeclaude
andcommitted
docs: add ARCHITECTURE.md and fix documentation gaps
- Add docs/ARCHITECTURE.md covering internal data flow, module map, bundle system, health scoring, and model routing classifier - Fix MCP_SETUP.md: document missing create_checkpoint and get_routing tools; add Windsurf manual config example - Fix SESSION_DISCIPLINE.md: replace non-existent --generate flag with correct bare invocation - Fix CONTRIBUTING.md: add bundling section (scripts/bundle.js) and integration test guide - Fix README.md: complete project structure (src/map/, all docs), add output targets table, add docs index Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ba72a03 commit 45aa004

5 files changed

Lines changed: 519 additions & 7 deletions

File tree

CONTRIBUTING.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,42 @@ Types: feat / fix / docs / test / chore / refactor / perf
4141
Scopes: core / extractor / mcp / security / config / map / ci / docs / test
4242
```
4343

44+
## Adding an integration test
45+
46+
1. Create `test/integration/<area>.test.js` following the existing test files.
47+
2. Use only Node.js built-ins — no Jest, no Mocha, no external test frameworks.
48+
3. Export a `run()` function that returns `{ passed, failed, total }`.
49+
4. Register it in `test/run.js` by requiring it in the integration suite array.
50+
5. Run `node test/run.js` — the new suite appears in the count.
51+
52+
## Bundling
53+
54+
The repository ships two forms of the main entry point:
55+
56+
- `src/` — modular source files (edit these)
57+
- `gen-context.js` — standalone bundle (generated; checked in for zero-install use)
58+
59+
After changing anything in `src/`:
60+
61+
```bash
62+
node scripts/bundle.js
63+
# Writes gen-context.js (overwrites)
64+
# Prints: lines, KB, modules inlined
65+
```
66+
67+
`scripts/bundle.js` works by:
68+
69+
1. Collecting every `.js` file under `src/` and assigning each a canonical key
70+
(e.g. `./src/config/loader`).
71+
2. Rewriting internal `require('./...')` calls to `__require('./src/...')`.
72+
3. Wrapping each module in a factory function stored in `__factories`.
73+
4. Prepending a tiny `__require` loader that evaluates factories on first call
74+
and caches exports — behaviorally identical to Node's module system.
75+
5. Appending the main entry with its requires patched to the same loader.
76+
77+
**Never edit `gen-context.js` directly.** Changes there will be overwritten the
78+
next time `scripts/bundle.js` runs. The `src/` tree is the source of truth.
79+
4480
## Running tests
4581

4682
```bash

README.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,24 @@ Copy `gen-context.config.json.example` to `gen-context.config.json`:
282282
}
283283
```
284284

285+
### Output targets
286+
287+
The `outputs` array controls which files are written. Each maps to the path an
288+
AI tool reads automatically:
289+
290+
| Target | Output path | Read by |
291+
|---|---|---|
292+
| `copilot` (default) | `.github/copilot-instructions.md` | GitHub Copilot in VS Code |
293+
| `claude` | `CLAUDE.md` | Claude Code |
294+
| `cursor` | `.cursor/rules` | Cursor IDE |
295+
| `windsurf` | `.windsurf/rules` | Windsurf IDE |
296+
297+
Write to multiple targets at once:
298+
299+
```json
300+
{ "outputs": ["copilot", "claude", "cursor"] }
301+
```
302+
285303
Exclusions go in `.contextignore` (gitignore syntax). Also reads `.repomixignore` if present.
286304

287305
---
@@ -319,23 +337,29 @@ sleep 2
319337
## Project structure
320338

321339
```
322-
gen-context.js ← single-file entry point
340+
gen-context.js ← standalone bundle (generated from src/ — do not edit directly)
323341
gen-project-map.js ← import graph, class hierarchy, route table
342+
scripts/bundle.js ← bundles src/ into gen-context.js
343+
src/config/ ← config loader + defaults
324344
src/extractors/ ← 21 language extractors
325345
src/format/cache.js ← Anthropic prompt-cache JSON formatter (v0.8)
326-
src/routing/ ← model routing hints (v0.7)
327-
src/tracking/logger.js ← NDJSON usage log (v0.9)
328346
src/health/scorer.js ← composite health score (v1.0)
347+
src/map/ ← import graph, class hierarchy, route table (used by gen-project-map.js)
329348
src/mcp/ ← MCP stdio server (v0.3)
349+
src/routing/ ← model routing hints (v0.7)
330350
src/security/ ← secret scanner (v0.2)
331-
src/config/ ← config loader + defaults
351+
src/tracking/logger.js ← NDJSON usage log (v0.9)
332352
test/fixtures/ ← one fixture per language
333353
test/expected/ ← expected extractor output
334354
test/run.js ← zero-dep test runner
355+
docs/ARCHITECTURE.md ← internal design, data flow, module map
335356
docs/CONTEXT_STRATEGIES.md ← full/per-module/hot-cold strategy guide (v1.1)
336357
docs/ENTERPRISE_SETUP.md ← enterprise & CI observability guide (v0.9)
358+
docs/MCP_SETUP.md ← MCP server setup for Claude Code, Cursor, Windsurf
337359
docs/REPOMIX_CACHE.md ← prompt cache strategy guide (v0.8)
338360
docs/MODEL_ROUTING.md ← model routing guide (v0.7)
361+
docs/SESSION_DISCIPLINE.md ← session lifecycle and token hygiene guide
362+
docs/CI_GUIDE.md ← CI/CD integration and monorepo setup
339363
examples/self-healing-github-action.yml ← auto-regeneration CI workflow (v1.0)
340364
scripts/ci-update.sh ← CI helper for pipelines (v1.0)
341365
.contextignore.example ← exclusion template
@@ -344,6 +368,22 @@ gen-context.config.json.example ← annotated config reference
344368

345369
---
346370

371+
## Docs
372+
373+
| Guide | Description |
374+
|---|---|
375+
| [ARCHITECTURE.md](docs/ARCHITECTURE.md) | Internal design, data flow, module map, bundle system |
376+
| [CONTEXT_STRATEGIES.md](docs/CONTEXT_STRATEGIES.md) | full / per-module / hot-cold strategy guide |
377+
| [MCP_SETUP.md](docs/MCP_SETUP.md) | MCP server for Claude Code, Cursor, Windsurf |
378+
| [MODEL_ROUTING.md](docs/MODEL_ROUTING.md) | Model tier routing and `--suggest-tool` |
379+
| [SESSION_DISCIPLINE.md](docs/SESSION_DISCIPLINE.md) | Session lifecycle and token hygiene |
380+
| [CI_GUIDE.md](docs/CI_GUIDE.md) | GitHub Actions, monorepo, health gates |
381+
| [ENTERPRISE_SETUP.md](docs/ENTERPRISE_SETUP.md) | Observability, Prometheus/Grafana, self-healing CI |
382+
| [REPOMIX_CACHE.md](docs/REPOMIX_CACHE.md) | Prompt caching with Anthropic API |
383+
| [REPOMIX_INTEGRATION.md](docs/REPOMIX_INTEGRATION.md) | Using ContextForge + Repomix together |
384+
385+
---
386+
347387
## Support
348388

349389
If ContextForge saves you time — a ⭐ on [GitHub](https://github.com/manojmallick/context-forge) helps others find it.

0 commit comments

Comments
 (0)