[bug] Review.ts: --help and mistyped flags are dropped silently and start a full review

Aperta Adatta ai principianti
#3,055 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 5 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
bun, typescript
Ambito
cli

Direzione di ricerca

Leggi il blocco import.meta.main in install/LIFEOS/TOOLS/Review.ts intorno alle righe 2238–2251 e le note di parseReviewFlags intorno alle righe 800–821. Aggiungi la gestione della guida e la convalida delle opzioni sconosciute nel punto di ingresso della CLI, lasciando invariato il parser condiviso. Verifica che --help, -h e un’opzione sconosciuta terminino senza avviare una revisione; le istruzioni d’uso devono includere --past-round-cap.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What happened

Review.ts has no help and no unknown-option check. bun Review.ts --help does not print usage: it drops --help and runs a full cross-vendor review of the current directory, which also counts as a review round. A mistyped flag behaves the same way.

Mechanism

  • parseReviewFlags (install/LIFEOS/TOOLS/Review.ts:806-821) takes out --allow-dirty, --waive-blockers and --past-round-cap, rejects the retired --accept, and passes every other argument through in rest (:814).

  • The CLI then drops every ---prefixed argument from the positionals without a check (:2238), so --help, --jsno or --allow-dirt "reason" leave pos empty and review({ dir: "." }) runs (:2251).

  • A value after a mistyped flag becomes the directory: --range a..b reviews the directory a..b.

  • The parser cannot reject unknown flags itself, because CfEnv shares it and forwards its own flags in rest (doc comment at :800-805). The check belongs in the import.meta.main block.

  • The usage text exists only as a header comment (:12-15), and it does not mention --past-round-cap.

Reproduction

v8.761.0 install/ payload (byte-identical to main as of 2026-11-30). This shows the parser result without starting a review:

cd install/LIFEOS/TOOLS
bun -e 'import { parseReviewFlags } from "./Review.ts";
for (const a of [["--help"], ["--bogus"], ["--range", "a..b"]]) {
  const f = parseReviewFlags(a);
  console.log(JSON.stringify(a), "->", JSON.stringify(f), "pos =", JSON.stringify(f.ok ? f.rest.filter((x) => !x.startsWith("--")) : null));
}'

Observed:

["--help"] -> {"ok":true,"rest":["--help"]} pos = []
["--bogus"] -> {"ok":true,"rest":["--bogus"]} pos = []
["--range","a..b"] -> {"ok":true,"rest":["--range","a..b"]} pos = ["a..b"]

With an empty pos, the CLI runs review({ dir: "." }).

Expected: --help and -h print usage and exit 0 without reviewing. An unknown option prints unknown option <arg> and exits 2 without reviewing.

This actually happened: on my install, an agent ran Review.ts --help to learn the arguments, which is the natural first move with an unfamiliar CLI. That started a real review of an 89-file span, and the round counted toward the round cap.

Suggested fix

The fix goes in the import.meta.main block only, so the shared parser and CfEnv stay unchanged. This is a sketch and has not been run:

const USAGE = `usage: bun Review.ts [dir] [--allow-dirty "<reason>"] [--waive-blockers "<reason>"] [--past-round-cap "<reason>"] [--json]
       bun Review.ts status [dir] [--json]
       bun Review.ts audit [--json]`;
if (argv.includes("--help") || argv.includes("-h")) { console.log(USAGE); process.exit(0); }
// after parseReviewFlags:
const unknown = flags.rest.find((a) => a.startsWith("-") && a !== "--json");
if (unknown) { console.error(`review: unknown option ${unknown}\n${USAGE}`); process.exit(2); }
const pos = flags.rest.filter((a) => a !== "--json");

Same class as #1690 (lifeos.ts), #2290 (Upgrade --help ran a full scan) and #2430 (Er.ts filed --help as a complaint).

Lingua principale
TypeScript
Stelle
20k
Fork
2.5k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di danielmiessler/LifeOS

Tutte le issue di danielmiessler/LifeOS

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.