Skip to content

feat(wiki): add /suggest-next skill for knowledge-driven campaign recommendations#275

Merged
mtoslalibu merged 3 commits into
AI-native-Systems-Research:mainfrom
susiejojo:feat/suggest-next
Jun 3, 2026
Merged

feat(wiki): add /suggest-next skill for knowledge-driven campaign recommendations#275
mtoslalibu merged 3 commits into
AI-native-Systems-Research:mainfrom
susiejojo:feat/suggest-next

Conversation

@susiejojo
Copy link
Copy Markdown
Contributor

Summary

  • Adds scripts/retrieve_wiki_context.py — a deterministic retrieval script that builds entity-scoped knowledge subgraphs from per-campaign JSON files (principles, dead-ends, frontiers, interactions, cost context)
  • Adds .claude/commands/suggest-next.md — a Claude skill that loads the cross-campaign registry, selects relevant campaigns/entities, runs the retrieval script, and synthesizes top-3 scored campaign framings with predicted cost and model configuration

Context

This is PR 3 of 4 in the wiki persistence strategy (Discussion #269). It builds on:

Closes #274

Test plan

  • Verify python scripts/retrieve_wiki_context.py --help displays usage
  • Run retrieval against a populated ~/.nous/wiki/ directory with at least one indexed campaign
  • Invoke /suggest-next with a research intent and confirm it produces a scored suggestion markdown file
  • Confirm no modifications to existing skills (post-campaign, index-wiki, visualize-campaign)

🤖 Generated with Claude Code

susiejojo and others added 2 commits June 3, 2026 10:24
…ommendations

Add retrieval script and Claude skill that recommend next experiment
framings based on accumulated cross-campaign knowledge from the registry.

- scripts/retrieve_wiki_context.py: deterministic entity-scoped subgraph
  retrieval from per-campaign JSON files (principles, dead-ends, frontiers,
  interactions, cost context)
- .claude/commands/suggest-next.md: skill that selects campaigns/entities
  from registry, runs retrieval, synthesizes scored recommendations

Closes AI-native-Systems-Research#274

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
After producing scored recommendations, the skill now offers to generate
schema-valid campaign.yaml files directly from the recommendations. Users
select which recommendations to convert, and the generated configs are
written to ~/.nous/wiki/suggestions/campaigns/ with full traceability
metadata linking back to the source suggestion.

Also fixes campaign/entity selection to use strict caps (3 campaigns,
6 entities) instead of ambiguous ranges, and documents /suggest-next
in docs/nous-wiki.md.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mtoslalibu
Copy link
Copy Markdown
Collaborator

Hey, nice addition — the architecture is clean and it doesn't touch any existing code. A few issues in scripts/retrieve_wiki_context.py that should be fixed before merge though:


1. Silent data loss — malformed JSON files are skipped with no warning

load_json() catches JSONDecodeError/OSError and returns None silently. If a campaign's concepts.json has a syntax error (realistic — these are written by LLM agents), that campaign vanishes from recommendations with zero indication. The user gets suggestions based on incomplete data without knowing.

Fix: print a warning to stderr when a file exists but can't be parsed.


2. Bare dict["key"] access will crash on missing fields

Entity/concept/parameter iteration uses entity["name"], e["principles"], e["definition"] without .get(). A single missing key in any campaign's data crashes the entire script with an unhelpful KeyError.

Meanwhile other parts of the same script already use safe access (d.get('id', '?'), f.get('title', '')), so it's inconsistent. Should use .get() with defaults everywhere.


3. JSONL metrics parsing has no per-line error handling

A truncated or corrupted line in llm_metrics.jsonl (common — campaigns get interrupted) crashes the whole script. Also accesses entry["model"], entry["num_turns"], entry["duration_ms"] without .get().

Fix: wrap json.loads(line) in try/except per line, and use .get() for field access.


4. Missing campaigns produce empty output with no warning

If --campaigns foo is passed and foo doesn't exist on disk, the script silently outputs an empty context block that looks valid. The LLM then generates recommendations grounded in zero data — exactly what this tool exists to prevent.

Fix: emit a stderr warning per skipped campaign, and if zero campaigns loaded, exit with an error.


Everything else looks good — the skill prompt is consistent with the wiki data model, paths are portable, and the design isn't overengineered. Just needs defensive error handling since the input data is LLM-generated and imperfect by nature.

…d input

Address PR review feedback:

1. load_json() now warns on stderr when a file exists but can't be parsed,
   instead of silently returning None (data loss visibility)
2. All dict["key"] access replaced with .get() defaults throughout entity,
   concept, parameter, and principle iteration (prevents KeyError crashes)
3. JSONL metrics parsing wraps each line in try/except with per-line warning,
   and uses .get() for all field access (handles truncated campaign files)
4. Missing campaigns emit per-campaign stderr warnings, and if zero campaigns
   load successfully the script exits with an error instead of producing
   an empty context block

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@susiejojo
Copy link
Copy Markdown
Contributor Author

All four issues addressed in 490c664:

  1. Silent data lossload_json() now prints to stderr when a file exists but can't be parsed
  2. Bare dict access — all dict["key"] replaced with .get() defaults throughout retrieval and formatting
  3. JSONL parsing — per-line try/except with stderr warning + .get() for field access
  4. Missing campaigns — per-campaign stderr warning, hard exit if zero campaigns load successfully

Pattern: warn-and-degrade for partial failures (one bad line, one missing field), fail-hard for total failures (zero usable campaigns).

@mtoslalibu mtoslalibu merged commit 66c8faf into AI-native-Systems-Research:main Jun 3, 2026
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggest-next: recommend experiments from accumulated knowledge

2 participants