Skip to content

feat(ux): drop command-not-found package search hints; add opt-in wpm-only hint - #251

Merged
caomengxuan666 merged 1 commit into
masterfrom
ux/remove-cnf-hint
Oct 10, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
ux/remove-cnf-hint

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Closes #249

What

command-not-found 不再默认插播包管理器搜索建议(owner 实测反感,判定过度防御):

  • 默认移除 winget/scoop/choco 的 niubash: package search hints 块——第三方管理器永不再推荐;win 这类纯手滑只输出 GNU 形态的一行 niu: win: command not found。
  • 保留既有 recipe/wpm install hint(rg/awk 等精确命中已知工具名时的定向建议——非拼写错误触发的广告)。
  • opt-in 开关:niu config set command-not-found-hint wpm 持久化到新增的 ~/.niubash/config.toml(mirrors.toml 约定;NIU_CONFIG 可重定位,NIU_COMMAND_NOT_FOUND_HINT 环境变量覆盖文件,任何读取问题一律降级为 off,不阻塞 command-not-found 路径)。
  • 开启后建议仅 wpm(wpm search --name '<word>',仅 Windows 构建),且触发收紧为高置信邻近命中:去掉尾部字符(截断式编辑距离 ≤1)后命中已安装命令或已知包命令名——纯手滑(如 win)即使开着开关也保持安静。
  • 新增 niu config get/list/set 子命令面。

验收对照

  • 默认配置 win 只输出一行(交互 -C 与脚本 -c 两条路径均验证)✓
  • 开关开启:jqq(jq 邻近命中)→ niubash: package search hints: + wpm search --name 'jqq';win → 无第二段 ✓
  • set off 恢复默认;env 覆盖双向验证;非法值/未知键报错 ✓
  • 回归测试覆盖两态(新 12 个相关用例全绿);runtime lib 423 通过;workspace 其余集成套件全绿

测试

  • cargo fmt --check -p niubash ✓
  • cargo test -p niubash-runtime --lib --locked:423 passed
  • cargo test --workspace --locked --no-fail-fast:除 host_contract 的 closed_stdout_pipe_does_not_print_broken_pipe_error 外全绿。该用例在 base(origin/master e8b7b5c)上同样确定性失败(已用 HEAD 基线构建复跑确认),为本机既有失败,与本 PR 无关。
  • 注:sh scripts/check-rename-clean.sh 在 base 上即失败(docs/audit、scripts/audit、harvest 快照中的既有 Winuxsh 残留),非本 PR 引入。

…-only hint

niubash#249: every typo triggered an unsolicited package-manager search
suggestion — naming winget (third-party) over niu's own wpm. Owner ruled
it over-defensive and harmful UX.

- Remove the unconditional 'niubash: package search hints' block
  (winget/scoop/choco) entirely; third-party managers are never
  recommended again. Recipe/wpm install hints for exact, known tool
  names (rg, awk, ...) stay - targeted advice, not typo-triggered ads.
- New opt-in channel: 'niu config set command-not-found-hint wpm'
  persists the policy in the new ~/.niubash/config.toml (mirrors.toml
  convention; NIU_CONFIG relocates it, NIU_COMMAND_NOT_FOUND_HINT
  overrides, everything degrades to off on any read problem).
- When enabled, the suggestion is wpm-only ('wpm search --name ...',
  Windows builds) and fires only for high-confidence near-misses:
  dropping the word's last character (edit distance <= 1 by truncation)
  hits an installed command or a known package command name, so pure
  typos like 'win' stay quiet even with the switch on.
- New 'niu config get/list/set' subcommand manages the setting.
- Tests: default-policy repro ('win' -> zero hint lines), third-party
  managers never named, wpm-only near-miss shapes, silence for
  arbitrary typos under the opt-in, Shell-field emission gating via
  the channel capture seam, config parse/round-trip/degradation.
@caomengxuan666
caomengxuan666 merged commit 297669d into master Oct 10, 2026
3 of 9 checks passed
@caomengxuan666
caomengxuan666 deleted the ux/remove-cnf-hint branch October 10, 2026 06:18
caomengxuan666 added a commit that referenced this pull request Oct 10, 2026
…notes draft (#254)

- Version 1.3.4 -> 1.4.0 (workspace root + crates/niubash-runtime;
  Cargo.lock synced; internal niubash-runtime dep requirement aligned
  1.2.5 -> 1.4.0). The rubash engine requirement stays 1.3.4: it is
  semver-open (^1.3.4 admits the engine's 1.4.0), and the committed
  [patch] resolves it to the local ../rubash worktree, whose Cargo.toml
  still says 1.3.4 until the engine cuts its own release.
- CHANGELOG: the Unreleased section becomes [1.4.0] - 2026-10-10. Also
  repairs the committed merge damage from #243 (stray conflict marker
  and the #241 doctor-advice entry glued onto the carapace entry) and
  folds in the merged cycle: #235 #239 #246 #247 #250 #251 #252 #253
  plus a compact rubash 1.4.0 engine summary. #240's P2-batch content
  stays under [1.3.4] where the file already records it (no dup).
- docs/release-notes-1.4.0-draft.md: zh+en draft release notes
  (Added / Fixed / Performance), winuxcmd #1151/#1154-#1157 marked as
  in-flight for the coordinator, plus the local verification log:
  release build PASS (niu.exe 10.6 MB), MSIX packed unsigned with a
  placeholder identity (5.1 MB), wpm-source main carries all four
  preinstall packages, and cargo publish --dry-run chain findings
  (rubash -> niubash-runtime -> niubash, blocked on the engine's
  crates.io release).

No tag, no release workflow trigger, no in-flight PRs merged.
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.

[ux] command-not-found 的 package search hints 过度防御:每次拼写错误都插播 winget 广告(owner 实测反感)

1 participant