@ateam-ai/mcp 0.3.27 → 0.3.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/agentDoc.js +17 -9
package/package.json
CHANGED
package/src/agentDoc.js
CHANGED
|
@@ -156,20 +156,28 @@ ${AGENT_DOC_SENTINEL}
|
|
|
156
156
|
* Merge the newly-rendered header with an existing CLAUDE.md, preserving
|
|
157
157
|
* anything below the sentinel (solution-specific notes).
|
|
158
158
|
*
|
|
159
|
+
* Output is deterministic so consecutive merges on the same inputs produce
|
|
160
|
+
* byte-identical output (required for the idempotent-write path in
|
|
161
|
+
* ateam_write_agent_doc).
|
|
162
|
+
*
|
|
159
163
|
* @param {string} freshHeader - Output of renderAgentDocHeader
|
|
160
164
|
* @param {string|null} existing - Current CLAUDE.md contents (or null if new file)
|
|
161
165
|
* @returns {string} merged markdown
|
|
162
166
|
*/
|
|
163
167
|
export function mergeAgentDoc(freshHeader, existing) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
// Normalize freshHeader: strip trailing whitespace, end with exactly "\n".
|
|
169
|
+
// This prevents newline accumulation when the output is read back and merged again.
|
|
170
|
+
const headerNormalized = freshHeader.replace(/\s+$/, "") + "\n";
|
|
171
|
+
|
|
172
|
+
const extractNotes = (src) => {
|
|
173
|
+
if (!src) return "";
|
|
174
|
+
const idx = src.indexOf(AGENT_DOC_SENTINEL);
|
|
175
|
+
const afterSentinel = idx === -1 ? src : src.slice(idx + AGENT_DOC_SENTINEL.length);
|
|
176
|
+
return afterSentinel.trim();
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const notes = extractNotes(existing);
|
|
180
|
+
return notes ? `${headerNormalized}\n${notes}\n` : headerNormalized;
|
|
173
181
|
}
|
|
174
182
|
|
|
175
183
|
// ──────────────────────────────────────────────────────────────────────────
|