Prepare wiki-graph npm release#106
Conversation
Summary by CodeRabbit
WalkthroughThis PR renames the CLI command from Sequence Diagram(s)Not applicable — this change is a systematic renaming/templating update across help text, error messages, and configuration rather than a new feature or control-flow change. Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✨ Finishing Touches✨ Simplify code
Warning Tools execution failed with the following error: Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
src/cli/archive.ts (1)
2000-2004: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate "next page" formatting logic.
formatEvidenceNextCursorandformatNextCursorimplement the same null-check-and-format pattern for"Next page: ${CLI_PRIMARY_COMMAND} next ${cursor}". Both were touched in this rename; worth consolidating into one shared helper to avoid divergence next time the message format changes.Also applies to: 2274-2280
🤖 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/archive.ts` around lines 2000 - 2004, The next-page cursor formatting is duplicated between formatEvidenceNextCursor and formatNextCursor, so consolidate the shared null-check and message construction into one helper and have both call it. Update the renamed cursor-formatting paths in archive.ts to reuse that common helper for the "Next page: ${CLI_PRIMARY_COMMAND} next ${cursor}" string so future message changes stay in sync.src/cli/queue.ts (1)
300-308: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winHardcoded
"wg"bypasses the centralized command constant.This file imports
formatCliCommandand uses it forwatchCommand/Watch:output below, but these two error messages hardcode the literal"wg"instead of interpolatingCLI_PRIMARY_COMMAND. If the primary command name changes again, these strings will silently drift out of sync with the rest of the CLI (which is exactly the maintenance problem the new constants were introduced to solve).♻️ Proposed fix
+import { CLI_PRIMARY_COMMAND } from "../common/cli-command.js"; ... throw new Error( - "Generation tasks can call an LLM, consume tokens, incur provider charges, and run for minutes to hours on large archives. Run `wg <archive-uri> inspect`, then rerun `wg wikg://local/job add` with --accept-cost if the cost and wait time are acceptable.", + `Generation tasks can call an LLM, consume tokens, incur provider charges, and run for minutes to hours on large archives. Run \`${CLI_PRIMARY_COMMAND} <archive-uri> inspect\`, then rerun \`${CLI_PRIMARY_COMMAND} wikg://local/job add\` with --accept-cost if the cost and wait time are acceptable.`, ); ... "Knowledge Graph requires WikiSpine.", - "Configure `wikg://local/config/wikispine` with provider `cli` or `fetch`, then run `wg wikg://local/config/wikispine test`.", + `Configure \`wikg://local/config/wikispine\` with provider \`cli\` or \`fetch\`, then run \`${CLI_PRIMARY_COMMAND} wikg://local/config/wikispine test\`.`,The same pattern (hardcoded
"wg"instead of the constant) also appears insrc/common/wiki-graph-uri.ts,src/facade/chapter-build.ts,src/facade/chapter.ts, andsrc/facade/graph.tsin this cohort.Also applies to: 567-583
🤖 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/queue.ts` around lines 300 - 308, The cost-acceptance error text in assertBuildCostAccepted should stop hardcoding the primary CLI name as "wg" and instead use the centralized command constant already available in this module, matching the existing formatCliCommand/watchCommand usage. Update both command references in the thrown message so they stay aligned if CLI_PRIMARY_COMMAND changes, and apply the same constant-based replacement anywhere this file still emits the literal primary command name.src/facade/spine-digest.ts (1)
65-70: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsistent rename; consider centralizing the duplicated error string.
The "chapter summary is missing" message (lines 119-121) is duplicated verbatim across this file,
src/output/epub/book.ts,src/output/plain-text.ts, andsrc/serial.ts. This PR had to hand-edit thewgprefix in all four places; extracting a small shared helper (e.g. alongsideformatCliCommand) would prevent future renames/wording tweaks from drifting across files.♻️ Example consolidation
+// e.g. in src/common/cli-command.ts +export function chapterSummaryMissingMessage( + documentId: string | number, +): string { + return `Chapter ${documentId} summary is missing. Run \`${formatCliCommand( + "wikg://local/job add --input <chapter-uri> --task reading-summary --accept-cost", + )}\` before export, or inspect the archive with \`${formatCliCommand( + "<archive-uri>/chapter/tree get", + )}\`.`; +}Also applies to: 111-121
🤖 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/facade/spine-digest.ts` around lines 65 - 70, The chapter-missing error text is duplicated in spine-digest-related logic and the same wording is repeated in src/output/epub/book.ts, src/output/plain-text.ts, and src/serial.ts, so future renames like the wg prefix can drift. Extract the shared message into a small helper near formatCliCommand and use it from the chapter summary/missing-summary checks in spine-digest so all call sites reuse one source of truth.
🤖 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 `@src/cli/archive.ts`:
- Line 1219: The help-readiness command string is hardcoded and can drift from
the existing CLI primary command usage. Update the help mapping in archive.ts to
build the readiness help text from CLI_PRIMARY_COMMAND, matching the pattern
already used elsewhere in the file, so the command stays consistent if the
primary command changes.
---
Nitpick comments:
In `@src/cli/archive.ts`:
- Around line 2000-2004: The next-page cursor formatting is duplicated between
formatEvidenceNextCursor and formatNextCursor, so consolidate the shared
null-check and message construction into one helper and have both call it.
Update the renamed cursor-formatting paths in archive.ts to reuse that common
helper for the "Next page: ${CLI_PRIMARY_COMMAND} next ${cursor}" string so
future message changes stay in sync.
In `@src/cli/queue.ts`:
- Around line 300-308: The cost-acceptance error text in assertBuildCostAccepted
should stop hardcoding the primary CLI name as "wg" and instead use the
centralized command constant already available in this module, matching the
existing formatCliCommand/watchCommand usage. Update both command references in
the thrown message so they stay aligned if CLI_PRIMARY_COMMAND changes, and
apply the same constant-based replacement anywhere this file still emits the
literal primary command name.
In `@src/facade/spine-digest.ts`:
- Around line 65-70: The chapter-missing error text is duplicated in
spine-digest-related logic and the same wording is repeated in
src/output/epub/book.ts, src/output/plain-text.ts, and src/serial.ts, so future
renames like the wg prefix can drift. Extract the shared message into a small
helper near formatCliCommand and use it from the chapter summary/missing-summary
checks in spine-digest so all call sites reuse one source of truth.
🪄 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: 39801459-e701-4fbd-be7b-ad2b12849607
📒 Files selected for processing (64)
README.mdREADME_zh-CN.mddata/help/commands/archive/next.jinjadata/help/commands/gc.jinjadata/help/commands/legacy.jinjadata/help/commands/legacy/migrate.jinjadata/help/commands/maintenance/chapter.jinjadata/help/commands/maintenance/chapter/add.jinjadata/help/commands/maintenance/chapter/list.jinjadata/help/commands/maintenance/chapter/move.jinjadata/help/commands/maintenance/chapter/remove.jinjadata/help/commands/maintenance/chapter/reset.jinjadata/help/commands/maintenance/chapter/set-source.jinjadata/help/commands/maintenance/chapter/set-summary.jinjadata/help/commands/maintenance/chapter/set-title.jinjadata/help/commands/maintenance/chapter/tree.jinjadata/help/commands/maintenance/cover.jinjadata/help/commands/maintenance/meta.jinjadata/help/commands/predicate.jinjadata/help/commands/root.jinjadata/help/commands/transform.jinjadata/help/commands/uri.jinjadata/help/topics/config.jinjadata/help/topics/format.jinjadata/help/topics/readiness.jinjadata/help/topics/recipe.jinjadata/help/topics/runtime.jinjadata/help/topics/uri.jinjadocs/wikispine-runtime.mdpackage.jsonscripts/generate-test-fixtures.mjsscripts/smoke-pack-install.mjsscripts/write-esm-wrappers.mjssrc/cli/archive.tssrc/cli/args.tssrc/cli/errors.tssrc/cli/generation-planning.tssrc/cli/help.tssrc/cli/local-config.tssrc/cli/queue.tssrc/cli/shell.tssrc/common/cli-command.tssrc/common/wiki-graph-uri.tssrc/facade/chapter-build.tssrc/facade/chapter.tssrc/facade/graph.tssrc/facade/spine-digest.tssrc/output/epub/book.tssrc/output/plain-text.tssrc/serial.tssrc/wikipage/resolver.tstest/cli/archive.test.tstest/cli/args.test.tstest/cli/config.test.tstest/cli/convert.test.tstest/cli/llm.test.tstest/cli/local-config.test.tstest/cli/main.test.tstest/cli/queue.test.tstest/cli/shell.test.tstest/fixtures/sources/sample-observatory-guide-encrypted.epubtest/fixtures/sources/sample-observatory-guide-mixed.epubtest/fixtures/sources/sample-observatory-guide.epubtest/source/epub-source-adapter.test.ts
| improvements, | ||
| performanceHints, | ||
| help: { readiness: "wikigraph help readiness" }, | ||
| help: { readiness: "wg help readiness" }, |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Inconsistent literal vs. CLI_PRIMARY_COMMAND constant.
This file already imports CLI_PRIMARY_COMMAND (Line 44) and uses it elsewhere (Lines 2003, 2279, 2910), but this help-readiness string is hardcoded as "wg help readiness". If the primary command ever changes again, this line will silently drift out of sync.
diff
- help: { readiness: "wg help readiness" },
+ help: { readiness: `${CLI_PRIMARY_COMMAND} help readiness` },📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| help: { readiness: "wg help readiness" }, | |
| help: { readiness: `${CLI_PRIMARY_COMMAND} help readiness` }, |
🤖 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/archive.ts` at line 1219, The help-readiness command string is
hardcoded and can drift from the existing CLI primary command usage. Update the
help mapping in archive.ts to build the readiness help text from
CLI_PRIMARY_COMMAND, matching the pattern already used elsewhere in the file, so
the command stays consistent if the primary command changes.
Summary
wiki-graphand makewgthe primary CLI commandwikigraphas the full command aliaswiki-graphidentifierVerification
pnpm release:checkpnpm publish:dry-run