fix: CLI routing bugs found during DX review

- Fixed subArgs reference error in handleCliOnly (used wrong variable name)
- Renamed gbrain backlinks check/fix to gbrain check-backlinks to avoid
  conflict with existing backlinks operation (per-page incoming links)
- Added TOOLS section to --help output showing publish, check-backlinks,
  lint, report
- Added upload-raw and signed-url to FILES section in --help
- Updated all docs/migration references to use check-backlinks
This commit is contained in:
Garry Tan
2026-04-11 21:32:03 -10:00
parent d798d81462
commit 54fdd4ba81
4 changed files with 32 additions and 24 deletions

View File

@@ -18,7 +18,7 @@ for (const op of operations) {
}
// CLI-only commands that bypass the operation layer
const CLI_ONLY = new Set(['init', 'upgrade', 'post-upgrade', 'check-update', 'integrations', 'publish', 'backlinks', 'lint', 'report', 'import', 'export', 'files', 'embed', 'serve', 'call', 'config', 'doctor', 'migrate']);
const CLI_ONLY = new Set(['init', 'upgrade', 'post-upgrade', 'check-update', 'integrations', 'publish', 'check-backlinks', 'lint', 'report', 'import', 'export', 'files', 'embed', 'serve', 'call', 'config', 'doctor', 'migrate']);
async function main() {
const args = process.argv.slice(2);
@@ -249,22 +249,22 @@ async function handleCliOnly(command: string, args: string[]) {
}
if (command === 'publish') {
const { runPublish } = await import('./commands/publish.ts');
await runPublish(subArgs);
await runPublish(args);
return;
}
if (command === 'backlinks') {
if (command === 'check-backlinks') {
const { runBacklinks } = await import('./commands/backlinks.ts');
await runBacklinks(subArgs);
await runBacklinks(args);
return;
}
if (command === 'lint') {
const { runLint } = await import('./commands/lint.ts');
await runLint(subArgs);
await runLint(args);
return;
}
if (command === 'report') {
const { runReport } = await import('./commands/report.ts');
await runReport(subArgs);
await runReport(args);
return;
}
@@ -388,6 +388,8 @@ IMPORT/EXPORT
FILES
files list [slug] List stored files
files upload <file> --page <slug> Upload file to storage
files upload-raw <file> --page <s> Smart upload (size routing + .redirect.yaml)
files signed-url <path> Generate signed URL (1-hour)
files sync <dir> Bulk upload directory
files verify Verify all uploads
@@ -409,6 +411,12 @@ TIMELINE
timeline [<slug>] View timeline
timeline-add <slug> <date> <text> Add timeline entry
TOOLS
publish <page.md> [--password] Shareable HTML (strips private data, optional AES-256)
check-backlinks <check|fix> [dir] Find/fix missing back-links across brain
lint <dir|file> [--fix] Catch LLM artifacts, placeholder dates, bad frontmatter
report --type <name> --content ... Save timestamped report to brain/reports/
ADMIN
stats Brain statistics
health Brain health dashboard

View File

@@ -1,13 +1,13 @@
/**
* gbrain backlinks — Check and fix missing back-links across brain pages.
* gbrain check-backlinks — Check and fix missing back-links across brain pages.
*
* Deterministic: zero LLM calls. Scans pages for entity mentions,
* checks if back-links exist, and optionally creates them.
*
* Usage:
* gbrain backlinks check [--dir <brain-dir>] # report missing back-links
* gbrain backlinks fix [--dir <brain-dir>] # create missing back-links
* gbrain backlinks fix --dry-run # preview fixes
* gbrain check-backlinks check [--dir <brain-dir>] # report missing back-links
* gbrain check-backlinks fix [--dir <brain-dir>] # create missing back-links
* gbrain check-backlinks fix --dry-run # preview fixes
*/
import { readFileSync, writeFileSync, readdirSync, statSync, existsSync } from 'fs';
@@ -175,7 +175,7 @@ export async function runBacklinks(args: string[]) {
const dryRun = args.includes('--dry-run');
if (!subcommand || !['check', 'fix'].includes(subcommand)) {
console.error('Usage: gbrain backlinks <check|fix> [--dir <brain-dir>] [--dry-run]');
console.error('Usage: gbrain check-backlinks <check|fix> [--dir <brain-dir>] [--dry-run]');
console.error(' check Report missing back-links');
console.error(' fix Create missing back-links (appends to Timeline)');
console.error(' --dir Brain directory (default: current directory)');
@@ -201,7 +201,7 @@ export async function runBacklinks(args: string[]) {
console.log(` ${gap.targetPage} <- ${gap.sourcePage}`);
console.log(` "${gap.entityName}" mentioned in "${gap.sourceTitle}"`);
}
console.log(`\nRun 'gbrain backlinks fix --dir ${brainDir}' to create them.`);
console.log(`\nRun 'gbrain check-backlinks fix --dir ${brainDir}' to create them.`);
} else {
const label = dryRun ? '(dry run) ' : '';
const fixed = fixBacklinkGaps(brainDir, gaps, dryRun);