Skip to content

feat(cli): route Wiki Graph URIs by scope kind - #96

Merged
Moskize91 merged 3 commits into
mainfrom
codex/archive-inspect-report
Jul 4, 2026
Merged

Moskize91 merged 3 commits into
mainfrom
codex/archive-inspect-report

Conversation

@Moskize91

@Moskize91 Moskize91 commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • classify Wiki Graph URIs as explicit scope or object targets for no-verb routing
  • route scope URIs to list/search via --query, and object URIs to get by default
  • remove source/summary list/search scope handling and expose chapter titles as searchable objects
  • update CLI help and tests for the scope/object URI contract

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test:run
  • pnpm format:check
  • pnpm run cli:install-local
    chapter 3 Reading Graph and Knowledge Graph coverage, and manually tested chapter/title/source/chunk/entity/triple list/search/get/related/evidence routing

Notes

  • This intentionally drops legacy source/summary list/search behavior.
  • The branch also includes the existing feat: add archive inspect report commit.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR replaces the archive estimate command with inspect, updates CLI parsing to use --query and scope/object URI routing, and adds chapter-title as a first-class archive object type. Archive query, search, and CLI output now treat wikg://chapter/<id>/title as a readable object, while chapter remains a scope URI. Help text, docs, and tests were updated to match the new command shapes and output.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Args as src/cli/args.ts
  participant CLI as src/cli/archive.ts
  participant ArchiveView as src/archive/query/archive-view.ts
  participant SearchIndex as src/archive/search-index/search-index.ts
  User->>Args: wikigraph <archive-uri> inspect
  Args->>CLI: parsed inspect action
  CLI->>SearchIndex: check index currency / settings
  CLI->>ArchiveView: read chapters, titles, coverage data
  CLI-->>User: inspect report

  User->>Args: wikigraph <scope-uri> --query <text>
  Args->>CLI: parsed search/list action
  CLI->>ArchiveView: query archive objects
  ArchiveView-->>CLI: chapter-title / chunk / entity hits
  CLI-->>User: formatted results
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title follows the required format and accurately summarizes the URI routing changes.
Description check ✅ Passed The description is directly related to the scope/object URI routing, help, and test updates in this changeset.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch codex/archive-inspect-report

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/cli/args.ts (1)

1628-1677: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Reject bare chapter get

  • wikg://chapter/<id> is a scope URI, but this branch still routes get to parseArchiveArguments, so the CLI accepts it and only fails later with the scope-URI error from archive-view.ts. Reject get here and point users to /title or /state.
  • inspect still doesn’t reject --query, --chapter, --from, or --cursor, so those flags are silently ignored on this path.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli/args.ts` around lines 1628 - 1677, The chapter URI parser still
accepts bare `get` for `wikg://chapter/<id>` and lets invalid scope URIs fail
later, so update `parseSingleChapterUriArguments` to reject `get` for chapter
objects and return a help/error pointing users to `/title` or `/state`. Also
tighten the `inspect` branch in
`parseArchiveArguments`/`parseSingleChapterUriArguments` so `--query`,
`--chapter`, `--from`, and `--cursor` are explicitly rejected instead of being
ignored on this path.
docs/en/quickstart.md (1)

77-81: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reword the URI guidance around /source and /summary.

This paragraph still presents those lenses as search targets, but the new routing contract treats object URIs as get-by-default and reserves search/list behavior for scope URIs. Please rewrite this to distinguish scope vs. object routing.

Suggested fix
-Use URI lenses to choose a search target: `<archive-uri>/chunk` for Reading Graph structure, `<archive-uri>/summary` for quick overview, `<archive-uri>/source` for original source wording, or `<archive-uri>/entity` and `<archive-uri>/triple` for Knowledge Graph objects.
+Use URI lenses to choose a scope or object target: `<archive-uri>/chunk` for Reading Graph structure, `<archive-uri>/entity` and `<archive-uri>/triple` for Knowledge Graph objects, and treat `<archive-uri>/summary` / `<archive-uri>/source` as object URIs that default to `get`.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/en/quickstart.md` around lines 77 - 81, The URI guidance in the
quickstart still describes /source and /summary as search targets, but the
routing contract now treats object URIs as get-by-default and scope URIs as the
ones for search/list behavior. Update the paragraph in the quickstart URI
section to clearly distinguish scope versus object routing, using the existing
wiki graph URI guidance and the retrieval help references, so readers know when
to use object URIs versus scope URIs.
docs/zh-CN/ai-agents.md (1)

17-26: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Update these examples to the new --query syntax.

The prose and sample commands in this block still use positional query arguments (search "keyword", evidence "objectivity", related "objectivity"). That contradicts the new CLI contract and will teach the removed form.

Suggested fix
-wikigraph wkg://book.wikg/source search "keyword"
-wikigraph wkg://book.wikg/entity search "keyword"
+wikigraph wkg://book.wikg/source search --query "keyword"
+wikigraph wkg://book.wikg/entity search --query "keyword"
@@
-wikigraph <archive-uri>/entity/Q830077 evidence "objectivity"
-wikigraph <archive-uri>/entity/Q830077 related "objectivity" --evidence 2
+wikigraph <archive-uri>/entity/Q830077 evidence --query "objectivity"
+wikigraph <archive-uri>/entity/Q830077 related --query "objectivity" --evidence 2

Also applies to: 30-42

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/zh-CN/ai-agents.md` around lines 17 - 26, The command examples in the AI
agents docs still use the old positional query form in wikigraph samples, so
update the affected examples to the new --query syntax instead. In the relevant
markdown section, revise the wikigraph usage examples for search, related, and
evidence to use the updated flag-based form, keeping the surrounding commands
and references like wikigraph and the chapter/entity URI examples consistent
with the current CLI contract.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@data/help/commands/archive/list.jinja`:
- Around line 13-27: The usage signature in the wikigraph help text is missing
the --query option, even though the notes already mention it. Update the command
synopsis in list.jinja so the primary usage line for wikigraph includes --query
<query> alongside the existing flags, keeping the help text consistent with the
guidance in the Notes section.

In `@src/cli/args.ts`:
- Around line 2890-2923: The new inspect branch in parseArchiveAction is missing
several reject checks that sibling read actions enforce, so unsupported flags
are being silently accepted. Update the inspect case to explicitly reject
--query, --chapter, --from, and --cursor using the same
rejectArchiveFlag/rejectArchiveBooleanFlag helpers already used for
list/get/search, alongside the existing validations. Keep the behavior
consistent with the other read-action handlers in src/cli/args.ts so inspect
fails fast on ignored inputs.

---

Outside diff comments:
In `@docs/en/quickstart.md`:
- Around line 77-81: The URI guidance in the quickstart still describes /source
and /summary as search targets, but the routing contract now treats object URIs
as get-by-default and scope URIs as the ones for search/list behavior. Update
the paragraph in the quickstart URI section to clearly distinguish scope versus
object routing, using the existing wiki graph URI guidance and the retrieval
help references, so readers know when to use object URIs versus scope URIs.

In `@docs/zh-CN/ai-agents.md`:
- Around line 17-26: The command examples in the AI agents docs still use the
old positional query form in wikigraph samples, so update the affected examples
to the new --query syntax instead. In the relevant markdown section, revise the
wikigraph usage examples for search, related, and evidence to use the updated
flag-based form, keeping the surrounding commands and references like wikigraph
and the chapter/entity URI examples consistent with the current CLI contract.

In `@src/cli/args.ts`:
- Around line 1628-1677: The chapter URI parser still accepts bare `get` for
`wikg://chapter/<id>` and lets invalid scope URIs fail later, so update
`parseSingleChapterUriArguments` to reject `get` for chapter objects and return
a help/error pointing users to `/title` or `/state`. Also tighten the `inspect`
branch in `parseArchiveArguments`/`parseSingleChapterUriArguments` so `--query`,
`--chapter`, `--from`, and `--cursor` are explicitly rejected instead of being
ignored on this path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a17e3ba3-c26b-40da-a650-ea9a156b8f68

📥 Commits

Reviewing files that changed from the base of the PR and between 586cc6d and 938af81.

📒 Files selected for processing (34)
  • README.md
  • data/help/commands/archive/estimate.jinja
  • data/help/commands/archive/evidence.jinja
  • data/help/commands/archive/inspect.jinja
  • data/help/commands/archive/list.jinja
  • data/help/commands/archive/related.jinja
  • data/help/commands/archive/search.jinja
  • data/help/commands/root.jinja
  • data/help/topics/ai.jinja
  • data/help/topics/command.jinja
  • data/help/topics/recipe.jinja
  • data/help/topics/retrieval.jinja
  • data/help/topics/task.jinja
  • data/help/topics/uri.jinja
  • docs/en/ai-agents.md
  • docs/en/architecture.md
  • docs/en/cli.md
  • docs/en/quickstart.md
  • docs/zh-CN/ai-agents.md
  • docs/zh-CN/architecture.md
  • docs/zh-CN/cli.md
  • docs/zh-CN/quickstart.md
  • src/archive/query/archive-view.ts
  • src/archive/query/index.ts
  • src/archive/search-index/search-index.ts
  • src/cli/archive.ts
  • src/cli/args.ts
  • src/cli/help.ts
  • src/cli/queue.ts
  • src/facade/index.ts
  • test/archive/query/archive-view.test.ts
  • test/cli/archive.test.ts
  • test/cli/args.test.ts
  • test/wikg/spine-digest-file.test.ts
💤 Files with no reviewable changes (3)
  • data/help/commands/archive/estimate.jinja
  • src/archive/query/index.ts
  • src/facade/index.ts

Comment thread data/help/commands/archive/list.jinja Outdated
Comment thread src/cli/args.ts
@Moskize91 Moskize91 changed the title Route Wiki Graph URIs by scope kind feat(cli): route Wiki Graph URIs by scope kind Jul 4, 2026
@Moskize91
Moskize91 merged commit d279ae6 into main Jul 4, 2026
2 of 3 checks passed
@Moskize91
Moskize91 deleted the codex/archive-inspect-report branch July 4, 2026 11:43
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.

1 participant