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

未关闭 适合新手
#3,055 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 5 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
bun, typescript
领域
cli

调研方向

阅读 install/LIFEOS/TOOLS/Review.ts 中约第 2238–2251 行的 import.meta.main 代码块,以及约第 800–821 行的 parseReviewFlags 说明。在 CLI 入口处添加帮助处理和未知选项验证,保持共享解析器不变。验证 --help、-h 和未知标志会退出且不会启动评审;用法说明应包含 --past-round-cap。

由索引模型根据 Issue 内容生成。

描述

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).

主要语言
TypeScript
星标
20k
派生
2.5k
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

danielmiessler/LifeOS 的其他 Issue

查看 danielmiessler/LifeOS 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。