Skip to content

feat: interactive replace-or-exit choice for symlinked adapter targets - #37

Merged
whitelonng merged 1 commit into
mainfrom
feat/init-symlink-choice
Aug 13, 2026
Merged

feat: interactive replace-or-exit choice for symlinked adapter targets#37
whitelonng merged 1 commit into
mainfrom
feat/init-symlink-choice

Conversation

@whitelonng

Copy link
Copy Markdown
Owner

背景

mancode init 遇到仓库里固定适配器目标为符号链接(如 CLAUDE.md -> AGENTS.md,openai/codex 惯例)时不再直接报错:交互式初始化会先检测,然后给用户两个选项:

  1. 退出(干净取消,不写任何文件);
  2. 将符号链接替换为普通文件并继续(复制链接解析目标的内容,原内容保留,之后 mancode 托管块照常追加)。

非交互调用(无 TTY)保持原有描述性错误不变。

变更

  • v3-adapter.ts:新增 inspectUnsafeV3AdapterPaths / replaceUnsafeV3AdapterSymlinks;安全检查重构为共享的收集式 walker,报错文案不变
  • init-onboarding.tsInitPrompter.resolveUnsafeAdapterPaths + 终端提示(中英双语)
  • init.ts:greenfield V3 流程接入检测-询问-替换
  • 测试:inspect/replace 契约测试;交互两个分支的集成测试;DSH_SHELL 补入平台提示环境变量 scrub(修复在 DeepSeek Harness 会话内跑 npm test 时 6 个用例的误失败)

验证

  • 全量测试 127 文件 / 939 用例通过(未 unset 环境变量)
  • typecheck + biome 通过
  • 伪终端端到端验证:选 2 → 链接变为普通文件、原内容保留、8 平台全部初始化完成;选 1 → 干净退出、链接与仓库均未改动

Interactive greenfield init now detects symlinked fixed adapter targets
(like the CLAUDE.md -> AGENTS.md convention) before installing and offers
the user two options: exit cleanly, or replace the link with a regular
file that preserves the resolved content and continue. Non-interactive
invocations keep the descriptive MANCODE_ARTIFACT_PATH_UNSAFE error.

- v3-adapter: inspectUnsafeV3AdapterPaths / replaceUnsafeV3AdapterSymlinks
- init-onboarding: InitPrompter.resolveUnsafeAdapterPaths (terminal prompt)
- init: resolveUnsafeInitAdapterPaths wired into initializeV3 greenfield
- tests: contract coverage for inspect/replace plus both interactive
  choices; DSH_SHELL added to the platform-hint env scrubs so the suite
  is deterministic inside a DeepSeek Harness session
@whitelonng
whitelonng merged commit 33d92b1 into main Aug 13, 2026
6 checks passed
@whitelonng
whitelonng deleted the feat/init-symlink-choice branch August 13, 2026 18:46
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.

1 participant