fix: expand @-imports when syncing personalization from CLAUDE.md#3405
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
😎 Merged successfully - details. |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
pauldambra
approved these changes
Jul 14, 2026
Contributor
|
Reviews (1): Last reviewed commit: "Merge branch 'main' into matt/personaliz..." | Re-trigger Greptile |
…mport expansion A closing fence must now match the opening character, be at least as long, and carry no info string, so a three-backtick line inside a four-backtick block no longer closes it. Indented code blocks (4+ spaces or tab after a blank line) stay literal without skipping list continuations. Inline spans match equal-length backtick runs per CommonMark, so double-backtick spans stay literal and an unmatched backtick run no longer swallows the rest of the line. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
/trunk merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PostHog Code's Settings → Personalization "Sync from AGENTS.md / CLAUDE.md" toggle (added in #3286) reads the first non-empty of
~/.agents/AGENTS.md,~/.codex/AGENTS.md,~/.claude/AGENTS.md,~/.claude/CLAUDE.mdand mirrors it into personalization.Many users'
~/.claude/CLAUDE.mdis a stub that only composes Claude Code@-imports (e.g.@./claude/engineering.md). Reading the file plainly ships the stub and none of the actual rules the imports pull in, so those users sync an almost-empty personalization.Two wrinkles make a naive fix wrong:
~/.claude/CLAUDE.mdis often a symlink into a dotfiles repo. Its relative imports resolve against the symlink target's directory, not~/.claude.Changes
getUserAgentInstructionsinpackages/workspace-server/src/services/os/os.tsnow expands@-imports before applying the length cap, matching Claude Code's memory-import behavior (docs: https://code.claude.com/docs/en/memory):realpathof the instructions file first, and resolves each@pathrelative to the directory of the file that contains it (after realpath), so symlinked stubs resolve their relative imports against the real dotfiles directory.~/import paths.@pathreference in place rather than throwing.USER_AGENT_INSTRUCTIONS_MAX_LENGTHcap after expansion, preserving thetruncatedflag semantics.Divergences from Claude Code's import spec
@preceded by start-of-line or whitespace, then a run of non-whitespace characters. This intentionally avoids treatingfoo@bar(e.g. emails) as imports; a trailing punctuation character on a bare path is included in the path rather than stripped.How did you test this?
Added unit tests in
packages/workspace-server/src/services/os/os.test.tscovering: no-imports passthrough, single import, nested import, cycle guard, missing import, inline-code-span literal, fenced-code-block literal, max-depth cutoff, symlinked root file with a relative import resolving against the real directory, and the length cap applied after expansion, fence length/info-string rules (shorter fence inside a longer one, tilde vs backtick isolation), indented code blocks (blank-line context, tab indent, list continuations still expanding, three-space boundary), and multi-backtick / unmatched-run inline spans.pnpm exec vitest run src/services/os/os.test.ts— 30 passed@posthog/workspace-serversuite — 697 passedpnpm --filter @posthog/workspace-server typecheck— cleanbiome checkon the changed files — cleanAutomatic notifications