codegraph upgrade replaces the entire global AGENTS.md with just the CODEGRAPH block, wiping user content outside the markers
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 56/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- nodejs, typescript
- Domain
- tooling
Research direction
The issue identifies codegraph upgrade and the OpenCode global AGENTS.md target, but names no implementation files or tests. Start by tracing the upgrade refresh path added in #1238/#1239 and find where it writes the file. Done when an existing marked block is replaced while surrounding content is preserved, and a file without markers is not truncated.
Written by the indexing model from the issue text.
Description
Problem
codegraph upgrade rewrites the global ~/.config/opencode/AGENTS.md (OpenCode target) with only the <!-- CODEGRAPH_START --> … <!-- CODEGRAPH_END --> block, replacing the entire file and wiping all user content outside the markers.
Our global AGENTS.md is a maintained ~47-line guidance file (toolset inventory, model config, tool-preference policy, runtime notes, conventions, commit policy) with the CodeGraph block appended at the end. After codegraph upgrade it became:
<!-- CODEGRAPH_START -->
## CodeGraph
… (10-line block only)
<!-- CODEGRAPH_END -->
Everything outside the markers was destroyed — no backup, no merge.
Reproduction
- Have a global
~/.config/opencode/AGENTS.mdwith user content plus an existing<!-- CODEGRAPH_START -->…<!-- CODEGRAPH_END -->block (as written by a priorcodegraph install). - Run
codegraph upgrade. cat ~/.config/opencode/AGENTS.md→ only the CodeGraph block remains.
Observed on CodeGraph 1.6.1 (reproduces with the current release line), Ubuntu linux-x64, installed via npm (@colbymchenry/codegraph).
Expected behavior
The refresh (added in #1238/#1239 so that upgrade updates installer-written instructions) should inject/replace only within its markers:
- If
<!-- CODEGRAPH_START -->/<!-- CODEGRAPH_END -->exist → replace just that span, preserving surrounding content. - If markers are absent → append the block (or prepend, matching install behavior) instead of truncating the file.
- Ideally take a backup before modifying (e.g.
AGENTS.md.bak-<timestamp>), consistent with safe-config-change expectations raised in #486.
Workaround (our side)
We added a self-heal to our toolset: verify-toolset.sh detects the clobber (canonical sections missing) and scripts/repair-agents-md.sh restores the canonical content while re-appending any existing CodeGraph block (pfz-smg/opencode-setup#103, PR #145). A marker-scoped replace upstream would make that workaround unnecessary.
Related
- #1238 — upgrade did not refresh installer-written files (the fix for this appears to be what introduced the whole-file replace).
- #800 — size/globality of the injected block (distinct issue).
- #486 — no backup when modifying agent config files (closed, but the backup suggestion is still relevant here).
- Dominant language
- C
- Stars
- 73.2k
- Forks
- 4.7k
- Avg merge
- 2h 16m
- Merged PRs (30d)
- 423
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from colbymchenry/codegraph
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
colbymchenry/codegraph#2634 ·
Maintainers usually reply within 1 day
-
Windows: bundled Node v24.16.0 can abort at exit (nodejs/node#56645); please bundle Node >= 24.20.0Possibly taken @Ancienttwo claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
colbymchenry/codegraph#2617 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 Under an hour Newbie friendliness 72/100
colbymchenry/codegraph#2482 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
colbymchenry/codegraph#1900 · 2 comments · 5 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
colbymchenry/codegraph#1700 ·
Maintainers usually reply within 1 day
All issues in colbymchenry/codegraph
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
micropython/micropython#19786 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
vercel-labs/zerolang#442 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
triage
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
mewencode: base256[] and base128[] are indexed out of bounds by a non-ASCII octetPossibly taken @kazu-yamamoto claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
kazu-yamamoto/Mew#276 ·
Maintainers usually reply within 1 day