Skip to content

Commit f0439f5

Browse files
susiejojoclaude
andauthored
feat(wiki): improve registry visualization scoring and docs (#276)
* feat(wiki): add /visualize-registry skill for cross-campaign knowledge graph Adds the registry visualization — an interactive D3.js HTML page showing campaigns, entities, concepts, and parameters as a force-directed graph with entity clusters and heuristic opportunity scoring. The Opportunities tab computes scores from frontier/interaction/dead-end counts per cluster (no LLM calls needed) and provides copyable /suggest-next commands for users who want detailed recommendations for specific clusters. Delivers: - scripts/visualize_registry.py — generates ~/.nous/wiki/viz/registry.html - .claude/commands/visualize-registry.md — 4-step deterministic skill - docs/nous-wiki.md — updated with /visualize-registry documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(wiki): improve registry visualization scoring and docs - Fix opportunity scoring: use principle-based relevance matching instead of counting all frontiers/interactions from any touching campaign - Use adaptive normalization (max raw score = 1.0) instead of fixed divisor - Remove numerical score display from UI — show only raw counts - Cap entity clusters at 20 per project - Add quickstart section and concurrency warning to docs/nous-wiki.md - Document scripts/visualize_registry.py in the Scripts section Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address PR #276 review — robustness and UX fixes 1. Show all nodes by default on Knowledge tab (was blank until filter) 2. Add try-except to all JSON load paths (graceful degradation) 3. Use D3 CDN directly (remove dead local path fallback) 4. Escape </ in JSON data to prevent </script> injection breakage 5. Remove unused params from build_entity_clusters signature Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 66c8faf commit f0439f5

4 files changed

Lines changed: 2181 additions & 1 deletion

File tree

.claude/commands/index-wiki.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Merge a single campaign's extracted knowledge into the cross-campaign registry.
7171

7272
b. Semantically group entities by functional role/purpose into clusters. Rules:
7373
- Min 2 entities per cluster, max 10
74+
- Max 20 clusters total per project — if grouping would exceed 20, merge the smallest/most-similar clusters
7475
- Each entity belongs to at most one cluster (singletons are valid — omit them)
7576
- Labels: 2-4 words, Title Case, describe the functional group
7677

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Render the cross-campaign knowledge graph from the Nous wiki registry.
2+
3+
This skill verifies prerequisites and runs `visualize_registry.py` to produce an interactive HTML page showing campaigns, entities, concepts, entity clusters, and heuristic opportunity scores — all computed directly from registry data without any LLM calls.
4+
5+
## Steps
6+
7+
1. **Verify registry exists**: Check that `~/.nous/wiki/registry.json` exists and is non-empty.
8+
9+
If missing, **STOP** and tell the user:
10+
11+
> "No registry found. Run `/post-campaign <path>` on at least one campaign first, then re-run `/visualize-registry`."
12+
13+
Do NOT proceed. Do NOT attempt to generate or fix any data yourself.
14+
15+
2. **Run the visualization script**:
16+
```bash
17+
python scripts/visualize_registry.py
18+
```
19+
20+
The script:
21+
- Reads `registry.json` and per-campaign wiki files
22+
- Builds a force-directed graph with campaigns, entities, concepts, and parameters as nodes
23+
- Computes cross-node edges from explicit relationship fields (operates_on, parent_concept, shared principles)
24+
- Computes heuristic opportunity scores per entity cluster from frontier/interaction/dead-end counts
25+
- Renders the Opportunities tab showing per-cluster research potential with copyable `/suggest-next` commands
26+
- Writes `~/.nous/wiki/viz/registry.html`
27+
28+
3. **Open the HTML**:
29+
```bash
30+
open ~/.nous/wiki/viz/registry.html
31+
```
32+
33+
4. **Report** the output path and a brief summary of what's in the graph (number of campaigns, entities, concepts, clusters).
34+
35+
## Important
36+
37+
- This skill does NOT modify registry.json, campaign data, or any existing wiki files.
38+
- The ONLY file this skill writes is `~/.nous/wiki/viz/registry.html` (via the Python script).
39+
- Entity clusters are pre-computed at index time by `/index-wiki` and stored in `registry.json`. The script reads them directly.
40+
- No LLM calls are made. All scoring is heuristic (frontier count, interaction count, recency, dead-end density).
41+
- The Opportunities tab helps users identify where to focus research, then run `/suggest-next` themselves for detailed recommendations.
42+
- If the script fails, report the error output verbatim.

docs/nous-wiki.md

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@ After a Nous campaign finishes, its knowledge lives in raw `ledger.json` and
44
`principles.json` files. The wiki skills extract that knowledge into structured,
55
self-contained files and render them as interactive visualizations.
66

7+
## Quickstart
8+
9+
After a campaign completes, run these in order:
10+
11+
```bash
12+
# 1. Extract knowledge, index into registry, generate per-campaign visualization
13+
/post-campaign path/to/.nous/my-campaign
14+
15+
# 2. Re-render the campaign visualization (e.g., after script updates)
16+
/visualize-campaign path/to/.nous/my-campaign
17+
18+
# 3. (Optional) Render the cross-campaign knowledge graph
19+
/visualize-registry
20+
21+
# 4. Get recommendations for the next campaign
22+
/suggest-next /path/to/repo "your research question"
23+
```
24+
25+
`/post-campaign` already generates the campaign visualization and calls
26+
`/index-wiki` internally, so step 2 is only needed to re-render after script
27+
changes.
28+
729
## Skills
830

931
### `/post-campaign`
@@ -162,6 +184,49 @@ wiki data, or any other existing files.
162184

163185
---
164186

187+
### `/visualize-registry`
188+
189+
Renders the full cross-campaign knowledge graph with heuristic opportunity
190+
scores. No LLM calls — runs in seconds.
191+
192+
**Usage:**
193+
194+
```
195+
/visualize-registry
196+
```
197+
198+
**Prerequisites:** At least one campaign must be indexed via `/index-wiki`
199+
(i.e., `registry.json` must exist with at least one project).
200+
201+
**What it reads:**
202+
203+
| Source | What it uses |
204+
|--------|--------------|
205+
| `~/.nous/wiki/registry.json` | Projects, entities, entity clusters, campaigns |
206+
| Per-campaign wiki files | concepts.json, dead-ends.json, frontiers.json, interactions.json, summary.md |
207+
208+
**What it writes:**
209+
210+
| File | Contents |
211+
|------|----------|
212+
| `~/.nous/wiki/viz/registry.html` | Interactive cross-campaign knowledge graph |
213+
214+
**Algorithm:**
215+
1. Verify registry exists
216+
2. Run `visualize_registry.py` (reads registry + campaign files, computes
217+
heuristic scores, writes HTML)
218+
3. Open HTML in browser
219+
220+
The Opportunities tab shows per-cluster research potential scored by frontier
221+
count, interaction count, and dead-end density. Each cluster card includes a
222+
copyable `/suggest-next` command for users who want detailed LLM-powered
223+
recommendations for that area.
224+
225+
**What doesn't happen:** This skill never modifies registry.json, campaign
226+
data, or any other existing wiki files. No LLM calls are made.
227+
228+
---
229+
165230
## Output Data Model
166231

167232
All output lives under `~/.nous/wiki/` — a user-level directory outside any
@@ -185,7 +250,8 @@ repo. Each campaign gets its own subdirectory.
185250
│ └── campaigns/ # Generated campaign configs
186251
│ └── <date>-<slug>-<N>.yaml
187252
└── viz/
188-
└── <campaign-name>.html
253+
├── <campaign-name>.html # Per-campaign graphs
254+
└── registry.html # Cross-campaign graph
189255
```
190256

191257
### dead-ends.json
@@ -310,3 +376,36 @@ The HTML includes:
310376
- **Knowledge tab** — force-directed graph of entities, concepts, and parameters
311377
- **Insights tab** — dead-ends, frontiers, and interactions as browsable cards
312378
- **Summary tab** — the campaign's narrative summary with key principles
379+
380+
### `scripts/visualize_registry.py`
381+
382+
Generates an interactive cross-campaign HTML page from the registry and
383+
per-campaign wiki files.
384+
385+
```bash
386+
python scripts/visualize_registry.py
387+
```
388+
389+
Reads `~/.nous/wiki/registry.json` plus per-campaign files (concepts.json,
390+
dead-ends.json, frontiers.json, interactions.json, summary.md). Produces
391+
`~/.nous/wiki/viz/registry.html` and opens it in the default browser.
392+
393+
The HTML includes:
394+
- **Graph tab** — force-directed graph of entities, concepts, and parameters across all campaigns, colored by campaign
395+
- **Opportunities tab** — per-cluster research potential scored by frontier count, interaction count, and dead-end density; each card includes a copyable `/suggest-next` command
396+
397+
---
398+
399+
## Concurrency
400+
401+
**Do not run `/post-campaign` in parallel for multiple campaigns targeting the
402+
same project.** The skill writes to `~/.nous/wiki/campaigns/<name>/` and then
403+
invokes `/index-wiki`, which performs a read-modify-write cycle on
404+
`registry.json`. Running two `/post-campaign` invocations concurrently can
405+
cause one to overwrite the other's registry changes (last-writer-wins race
406+
condition).
407+
408+
Safe patterns:
409+
- Run `/post-campaign` sequentially — finish one campaign before starting the next
410+
- Running `/post-campaign` for campaigns in *different* projects is safe (they write to different registry keys), but still shares the same `registry.json` file — so even cross-project parallelism should be avoided
411+
- `/visualize-campaign` and `/visualize-registry` are read-only and safe to run anytime

0 commit comments

Comments
 (0)