Skip to content
Merged
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
24 changes: 21 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,16 @@ packages/insights/ @codegraph/insights — the bottom-up EXPLANATION walk: uni
context packs, prompts, Merkle fingerprints, plan/run, the
insights STORE (a port + a SQLite adapter handed an open
database) and its export, the `.insights.jsonl` side-car
(Specy domain vocabulary). Pure computation: source, model
calls and the database are injected.
(Specy domain vocabulary). The engine asks its question
through ONE seam (`WalkSpec`): explain is the built-in
spec; a `codegraph.walk/1` DEFINITION (data: a task per
level, instructions, a closed field grammar → Zod) is
another; a SELECTION (analyzer selectors, nearest-container
rule, closure) picks the units asked, never the units
walked. ONE STORE PER WALK: `<model>.N.walk.db`/`.jsonl`,
header `codegraph.walkRecords/1`, refused to any other
walk. Pure computation: source, model calls and the
database are injected.
packages/llm/ @codegraph/llm — LlmClient (the PORT) + its adapters: OpenRouter
(SDK), Cloudflare AI Gateway (REST), Claude Code headless
(subprocess: `claude -p`, found by discovery, no key) + a
Expand Down Expand Up @@ -194,7 +202,7 @@ extractors/csharp/dist/linux-x64/codegraph-csharp --src <dir> --out model.jsonl

./build.sh --ts --sea # ONE Node single-executable of the CLI + daemon + both frontends
packages/cli/dist-sea/<rid>/codegraph --version # for THIS platform only (the image is this Node)
node packages/cli/scripts/sea-smoke.mjs packages/cli/dist-sea/<rid>/codegraph # its three gates (test.sh runs it)
node packages/cli/scripts/sea-smoke.mjs packages/cli/dist-sea/<rid>/codegraph # its five gates (test.sh runs it)

pnpm --filter @codegraph/desktop tauri:dev # the desktop shell (after --sea): copies the image as the
# sidecar, then `tauri dev` — needs Rust + the platform's WebKit (apps/desktop/README.md)
Expand Down Expand Up @@ -269,6 +277,16 @@ OPENROUTER_API_KEY=… ./bin/codegraph explain model.jsonl --src DIR [--max-call
./bin/codegraph insights model.jsonl --id ID # one explanation whole; --failures, --runs, --json
# reads <model>.insights.db and NOTHING else (not the model, no provider); writes nothing
./bin/codegraph serve model.jsonl --insights FILE # the explanation panel's store, if not beside the model
./bin/codegraph walk model.jsonl --src DIR --prompt "…" --include 'edge:annotationUse>name:Audited' --dry-run
# your question, bottom-up, of the selected units (--include/--exclude SEL, --levels, --closure);
# every explain run flag; → model.adhoc.walk.db + .jsonl (--name N: model.N.walk.*), never explain's store
./bin/codegraph walk --print-definition [explain] # a codegraph.walk/1 file to start from; no model read
./bin/codegraph walk model.jsonl --src DIR --walk FILE [--name N] [--estimate] # task per level, instructions, answer fields
# output tokens per block: operation 500, type/module 620, measured on ONE PetClinic run (sonnet,
# claude-code, no field declared; module and fields unmeasured); docs/insights.md IN-9 "Cost"
./bin/codegraph explain model.jsonl --src DIR --exclude 'file:**/generated/**' --instructions @context.md
# explain customized (also --include, --levels, --closure, --walk FILE); --scope a,b = --include id:a --include id:b
./bin/codegraph insights model.jsonl --walk N [--id ID] # a walk's store (or --store FILE: whichever walk its header names)
```

## Metamodel invariants (violating these is a bug, not a style choice)
Expand Down
538 changes: 534 additions & 4 deletions PLAN.md

Large diffs are not rendered by default.

34 changes: 29 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,30 @@ installed and logged in — found on `PATH` or named with `--claude-path`; no
key). `auto` prefers a key over the installed CLI; a direct Anthropic API
adapter is a named slot for later.

### Ask it your own question

`codegraph walk` runs the same bottom-up walk with a question of yours, over
the units a selector picks, into a store of its own (`<model>.NAME.walk.db`;
explain's is never touched):

```bash
codegraph walk fixtures/java/expected/model.jsonl --src fixtures/java/src \
--prompt "Which of these is audited, and what does the audit record?" \
--include 'edge:annotationUse>name:Audited' --dry-run # 2 calls: the two @Audited operations
codegraph walk --print-definition > audit.json # a file to edit: "name": "audit", a task per level, instructions, answer fields
codegraph walk fixtures/java/expected/model.jsonl --src fixtures/java/src --walk audit.json --estimate
codegraph insights fixtures/java/expected/model.jsonl --walk audit # once it has run: its answers, field by field with --id
```

Every answer carries the fields the definition declares plus a one-line
`description`, which is what the units above it are shown. `explain` takes the
same selection flags and `--instructions` without changing its own question.
The output-token estimate of a defined walk uses 500 tokens per operation
answer and 620 per type answer, measured on one live run (Spring PetClinic,
`sonnet` through Claude Code); a module, not measured, takes the type's
figure, and declared fields add to an answer but not to the estimate. Design: [`docs/insights.md`](docs/insights.md)
IN-9; reference: [`docs/cli.md`](docs/cli.md).

### Feed it to something else

`codegraph export --format json|csv` gives you the folded graph;
Expand Down Expand Up @@ -373,9 +397,9 @@ Read these before you commit an afternoon.
repeatable, but the same package declared under several roots at once (main
and test sources, or one package split across modules) confuses noClasspath
resolution; pass such roots in separate runs.
- **`explain` costs money and needs a network** (or an installed Claude Code,
which spends the subscription). It is the only command that
does. `--dry-run` and `--estimate` tell you what it would do first, a real
- **`explain` and `walk` cost money and need a network** (or an installed
Claude Code, which spends the subscription). They are the only commands that
do. `--dry-run` and `--estimate` tell you what a run would do first, a real
run asks for confirmation after showing the estimate (`--yes` in scripts),
and `--max-calls` caps it.
- **Not a linter.** Codegraph reports structure, coupling and cycles; it does
Expand Down Expand Up @@ -426,7 +450,7 @@ so a model file has one direction of truth. The full reference is
| `packages/scm` | git history miner |
| `packages/city`, `packages/viz` | city model, Three.js renderer |
| `packages/navigator`, `packages/navigator-ui` | navigator model, React browser |
| `packages/insights`, `packages/llm` | the explanation walk, the provider clients |
| `packages/insights`, `packages/llm` | the bottom-up walk (`explain`, and `walk`'s definitions and selection), the provider clients |
| `packages/cli` | the `codegraph` command |

## Documentation
Expand All @@ -444,7 +468,7 @@ so a model file has one direction of truth. The full reference is
- [`docs/metrics.md`](docs/metrics.md) — the metrics pass: what it measures, how it joins a model, change history
- [`docs/distribution.md`](docs/distribution.md) — the Homebrew tap, what a tagged release produces, what is signed and how
- [`docs/navigator.md`](docs/navigator.md) — the navigator's design
- [`docs/insights.md`](docs/insights.md) — the explanation walk's design
- [`docs/insights.md`](docs/insights.md) — the explanation walk's design, and `walk`: definitions, selectors, one store per walk
- [`docs/vocabulary.md`](docs/vocabulary.md) — the vocabulary's design: the lexicons, the split, the classes and weights, `vocabulary.json`, the cloud, the words a model defines and the glossary readers
- [`PLAN.md`](PLAN.md) — milestones, decisions and their rationale
- [`CLAUDE.md`](CLAUDE.md) — architecture boundaries and the metamodel invariants
Expand Down
2 changes: 1 addition & 1 deletion WEBSITE.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ Each page links to the tutorial or how-to that applies it.
| `time-as-structure.md` | Hotspots, ownership, co-change, hidden coupling and deadweight; why history is a dependency source cannot show; the replay design. | PLAN §11, Tornhill | write |
| `explaining-bottom-up.md` | Units, cycles as one unit, context packs, fingerprints, the side-car rule. | docs/insights.md | exists |
| `architecture.md` | The packages, the hard boundaries and why each exists. | CLAUDE.md, PLAN §1–2 | partial |
| `decisions.md` | The decision log. | PLAN §23 | exists |
| `decisions.md` | The decision log. | PLAN §24 | exists |
| `prior-art.md` | Moose/FamixNG, CodeCity, Structure101, Gource and Tornhill, Sourcetrail, jQAssistant, ArchUnit: what each does and where codegraph differs. | README credits | write |

### 4.5 Documentation debt found while writing (repository docs, not the site)
Expand Down
Loading
Loading