Skip to content

feat: support personal local instruction overrides via .local.md#1127

Open
MrSong9957 wants to merge 1 commit into
XiaomiMiMo:mainfrom
MrSong9957:feat/support-agents-local-md-v2
Open

feat: support personal local instruction overrides via .local.md#1127
MrSong9957 wants to merge 1 commit into
XiaomiMiMo:mainfrom
MrSong9957:feat/support-agents-local-md-v2

Conversation

@MrSong9957

Copy link
Copy Markdown

Closes #872

Supersedes #873, which was auto-closed when the repo force-pushed/rewrote main history on 2026-06-18 (a batch of PRs from multiple contributors were closed within seconds). This is the same feature, re-applied on top of the new main.

What

Adds a .local.md personal local instruction override layer in Instruction.systemPaths (packages/opencode/src/session/instruction.ts), stacked on top of the main AGENTS.md / CLAUDE.md (unchanged):

  • Candidates AGENTS.local.md / CLAUDE.local.md, first-match-wins (only one is loaded — AGENTS.local.md wins if present, CLAUDE.local.md is then skipped).
  • Gated behind the existing MIMOCODE_DISABLE_CLAUDE_CODE_PROMPT flag, and sits inside the MIMOCODE_DISABLE_PROJECT_CONFIG gate (added upstream after feat: support personal local instruction overrides via .local.md #873).
  • All ancestor matches of the winning candidate within the worktree are loaded via the existing fs.findUp.

Also adds a CLAUDE.local.md at the repo root as a reference template showing a personal "no-upstream-pollution" constraint (intentionally committed as an example; it does not affect the build).

Motivation and full loading logic in #872.

Verification

  • bun test test/session/instruction.test.ts13 pass / 1 todo / 0 fail (3 new .local.md tests: stacking / CLAUDE.md fallback / first-match-wins; original 10 tests no regression)
  • bun typecheck (@mimo-ai/cli) → clean
  • Manually verified in the TUI (bun dev): CLAUDE.local.md loads when no AGENTS.local.md; adding AGENTS.local.md makes it win and CLAUDE.local.md is skipped.

改动内容

Instruction.systemPathspackages/opencode/src/session/instruction.ts)新增 .local.md 个人本地指令覆盖层,叠加在既有主指令(AGENTS.md / CLAUDE.md,不变)之上:

  • 候选 AGENTS.local.md / CLAUDE.local.mdfirst-match-wins(只加载其中一个——若存在 AGENTS.local.md 则它胜出,随即跳过 CLAUDE.local.md)。
  • 受既有 MIMOCODE_DISABLE_CLAUDE_CODE_PROMPT flag 门控,并位于 feat: support personal local instruction overrides via .local.md #873 之后上游新增的 MIMOCODE_DISABLE_PROJECT_CONFIG 门控之内。
  • 胜出候选在 worktree 内的所有祖先匹配都加载(复用既有 fs.findUp)。

另外在仓库根目录新增 CLAUDE.local.md 作为参考模板,示范一个个人"禁止污染上游"约束(作为示例提交,不影响构建)。

动机与完整加载逻辑见 #872

验证

  • bun test test/session/instruction.test.ts13 pass / 1 todo / 0 fail(3 个新增 .local.md 测试:stacking / CLAUDE.md fallback / first-match-wins;原 10 个测试零回归)
  • bun typecheck@mimo-ai/cli)→ 无错误
  • TUI 手动验证(bun dev):无 AGENTS.local.md 时加载 CLAUDE.local.md;加入 AGENTS.local.md 后它胜出,CLAUDE.local.md 被跳过。

Add a .local.md personal local instruction override layer in
Instruction.systemPaths (packages/opencode/src/session/instruction.ts),
stacked on top of the main AGENTS.md/CLAUDE.md (unchanged):

- Candidates AGENTS.local.md / CLAUDE.local.md, first-match-wins
  (only one is loaded - AGENTS.local.md wins if present, CLAUDE.local.md
  is then skipped).
- Gated behind the existing MIMOCODE_DISABLE_CLAUDE_CODE_PROMPT flag,
  and sits inside the MIMOCODE_DISABLE_PROJECT_CONFIG gate.
- All ancestor matches of the winning candidate within the worktree are
  loaded via the existing fs.findUp.

Includes a CLAUDE.local.md template as a reference for personal
no-upstream-pollution constraints.

Closes XiaomiMiMo#872
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.

[FEATURE]:Support AGENTS.local.md as a personal local instruction override

2 participants