feat: preserve user edits in CLAUDE.md/AGENTS.md via auto/user blocks#43
Merged
Conversation
- add lib/content-merger mergeManagedDoc: in-place auto-block swap, migrate unmarked existing content into the user block, idempotent (function replacers) - add lib/fs-utils readFileIfExists (ENOENT -> '', other errors propagate) - agent-sync generateEntryConfig reads existing -> mergeManagedDoc -> atomicWrite instead of unconditional overwrite (REQ-AGNT-008 / REQ-AGNT-023) - init merges the managed AGENTS.md while trust-zone docs keep skip-if-exists (REQ-SETUP-018) - wrap entry.md.hbs and init/agents.md.hbs in prospec:auto / prospec:user blocks (REQ-TEMPLATES-104) - tests: mergeManagedDoc, readFileIfExists, agent-sync/init merge, init->sync integration (+22) - docs: note block preservation in README.md / README.zh-TW.md
…dge services - export hasAutoBlock/replaceAutoBlock from lib/content-merger as the single source for the prospec:auto block matcher; mergeManagedDoc reuses them - knowledge-update.service: drop the duplicated literal auto-block regex for the shared helpers - knowledge.service + knowledge-update.service: replace 4 inline read-or-empty try/catch sites with fs-utils readFileIfExists, so non-ENOENT read errors propagate instead of being masked as an absent file (created/updated unchanged) - tests: unit-cover hasAutoBlock/replaceAutoBlock
…ledge - graduate REQs: agent-integration (US-435 + REQ-AGNT-027/LIB-021/TEMPLATES-123 added, REQ-AGNT-008 modified), project-setup (REQ-SETUP-018 modified); renumbered from colliding LIB-014/AGNT-023/TEMPLATES-104 - add lib to agent-integration feature-map modules (REQ-LIB-021 ownership) - sync lib/services/templates module READMEs to the merge behavior - reconcile drifted test counts to 1786 across README x2 + _index + tests README - harvest lessons ledger (refactor/duplicated-helper -> suggest-promote) - refresh raw-scan; add _archived-history record
- promote refactor/duplicated-helper-parallel-sites to _playbook PB-006 (freq=3, modules=2 lib+services; kind convention; approved benwu95) - flip ledger entry suggest-promote -> promoted with provenance
Prospec Check |
Test Coverage
|
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.
Summary
prospec agent syncpreviously overwroteCLAUDE.md/AGENTS.mdunconditionally, andprospec initskipped an existingAGENTS.mdentirely — destroying or ignoring any hand-written content. This change applies the sameprospec:auto/prospec:userblock contract that_index.mdalready uses, so user edits surviveinit/agent sync/quickstart/upgrade.What changed
mergeManagedDoc(generated, existing)— in-place auto-block swap preserving the user block; migrates a marker-less existing file into the user block instead of discarding it; idempotent. Plus sharedhasAutoBlock/replaceAutoBlock(single-source auto-block matcher, function-replacer so$-sequences stay literal).readFileIfExists(ENOENT →'', other read errors propagate).agent-sync.generateEntryConfigandinit's write loop route through the merge;initmerges the managedAGENTS.mdwhile curated trust-zone docs keep skip-if-exists.entry.md.hbsandinit/agents.md.hbswrapped in the blocks.Behavior
CLAUDE.md/AGENTS.md→ content migrated into the user block on first sync.CONSTITUTION.md/_conventions.md/_index.md) unchanged — still skip-if-exists.SDD trail
Full Prospec lifecycle (story → plan → tasks → implement → review → verify → archive → learn):
6d20b16099eb18readFileIfExistsadoption across knowledge services)eba90fad1a2c7dVerification
prospec check: 8/8 structural checks pass (0 fail / 0 warn).CLAUDE.md/AGENTS.mdmigrated into the user block and preserved acrossinit → agent sync; idempotent on re-sync.🤖 Generated with Claude Code