You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "shaokeyibb (via GitHub)" <gi...@apache.org> on 2026/08/23 08:48:40 UTC
[PR] fix(runtime): collapse duplicate workspace instruction files in one directory [maka]
shaokeyibb opened a new pull request, #3578:
URL: https://github.com/apache/maka/pull/3578
## Summary
`readWorkspaceInstructions` reads every candidate name in a directory and appends each result, so a repository that shares one instruction file across the names different agent CLIs read gets it injected twice. That sharing is the documented way to do it — Claude Code's docs recommend `ln -s AGENTS.md CLAUDE.md`, and `apache/airflow` and `deepseek-ai/deepseek-harness` both ship that link — and the duplicate then consumes most of the 14000-character workspace-instruction budget, squeezing out whatever genuinely different file sits beside it.
Deduplicate on the digest of the cleaned text, scoped to one directory. Digesting rather than comparing `realpath` catches a byte-identical copy as well as a link, which is the other common way people share these files. Directories stay independent, because the same text at global and project scope is a user repeating themselves on purpose and collapsing it would silently drop a layer. The digest is taken before truncation, so two files that diverge only past the per-file cap still count as different.
Fixes #3577
## Verification
Four new tests in `workspace-instructions.test.ts`: a symlinked `CLAUDE.md` collapses, a byte-identical copy collapses, files in one directory that genuinely differ are both kept, and identical text at global and project scope is kept at both scopes. The first two fail on `main` with `expected: 1, actual: 2`; the last two pass either way and are there so the fix cannot over-collapse.
End-to-end against a directory holding a real `AGENTS.md`, in both duplicate forms:
```
before blocks = project/AGENTS.md, project/CLAUDE.md
after blocks = project/AGENTS.md
```
Ran: `workspace-instructions` (9) and `ai-sdk-backend` (204) green; `biome check` on both changed files; `npm run check:asf-headers`.
`packages/runtime` typecheck reports one error in `responses-wire-contract.test.ts` about an `alibaba-cn` provider literal. Verified pre-existing — the same error appears on a clean `origin/main` build, and this change touches neither file.
Not run: the rest of the runtime suite, Desktop, Playwright.
## Notes
`@AGENTS.md` — the import form Claude Code's docs also suggest — is not addressed here. Maka does not expand imports, so a one-line `CLAUDE.md` containing `@AGENTS.md` is injected as that literal text. It is small and harmless rather than wasteful, but it is also an instruction that means nothing; worth a separate decision about whether to expand or ignore it.
For reference, the three strategies other agents use: read a single filename (Claude Code, Codex CLI, Gemini CLI), first-match-wins across a candidate list (opencode, Pi), or content deduplication (deepseek-harness). First-match-wins would be simpler here, but it discards a `CLAUDE.md` that genuinely differs from `AGENTS.md`, which is a supported thing to have.
## AI use
Select exactly one:
- [ ] No generative tool made a substantive contribution
- [x] Generative tooling made a substantive contribution
Tool(s) and scope: Claude Code — investigation, comparison of other agents' loaders, the tests, and the fix.
## Checklist
- [x] Tests cover the change and fail without it
- [x] Lint, format, typecheck and the affected suites pass locally
Does this PR entail a change in behavior?
- [x] Yes — described under Summary above
- [ ] No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime): collapse duplicate workspace instruction files in one directory [maka]
Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on code in PR #3578:
URL: https://github.com/apache/maka/pull/3578#discussion_r3839063348
##########
packages/runtime/src/system-prompt/workspace-instructions.ts:
##########
@@ -107,6 +108,16 @@ async function readWorkspaceInstructions(
}
const out: WorkspaceInstruction[] = [];
+ // Content already accepted from this directory. Sharing one instruction file
+ // across the names different agent CLIs read — Claude Code reads CLAUDE.md,
+ // Codex reads AGENTS.md, Gemini CLI reads GEMINI.md — is the documented way
+ // to do it, whether by symlink or by copy, so identical bytes arriving under
+ // two names here are redundancy rather than two instructions. Digesting the
+ // cleaned text catches both forms; `realpath` alone would miss the copy.
+ // Scoped to one directory on purpose: the same text at global and project
+ // scope is a user repeating themselves deliberately, and collapsing that
+ // would silently drop a layer.
+ const seenDigests = new Set<string>();
Review Comment:
[P3] This set is recreated for each scope read, so the same physical directory is not actually deduplicated when it is both the global and project root. A production-function repro with `cwd === <home>/.maka` and one `<home>/.maka/AGENTS.md` produces `blocks=2`, `copies=2`, and scopes `[global, project]`: `buildWorkspaceInstructionsPromptFragment` calls this function twice, and each call starts with an empty set. This is inside the PR's stated ‘one directory’ contract, not an unrelated enhancement. It is non-blocking because ordinary project roots differ from `~/.maka`, but editing the config directory (or a realpath alias of it) still reproduces the duplicate-budget bug. Please share dedupe state by resolved root, or special-case identical resolved roots, and add the same-root regression.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime): collapse duplicate workspace instruction files in one directory [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han merged PR #3578:
URL: https://github.com/apache/maka/pull/3578
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org