@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/agentDoc.js +17 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ateam-ai/mcp",
3
- "version": "0.3.27",
3
+ "version": "0.3.28",
4
4
  "mcpName": "io.github.ariekogan/ateam-mcp",
5
5
  "description": "A-Team MCP Server — build, validate, and deploy multi-agent solutions from any AI environment",
6
6
  "type": "module",
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
- if (!existing) return freshHeader;
165
- const idx = existing.indexOf(AGENT_DOC_SENTINEL);
166
- if (idx === -1) {
167
- // Existing file has no sentinel — treat the whole file as manual notes,
168
- // prepend the auto-generated header, separate by sentinel.
169
- return freshHeader + "\n" + existing.trimStart();
170
- }
171
- const tail = existing.slice(idx + AGENT_DOC_SENTINEL.length);
172
- return freshHeader + tail;
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
  // ──────────────────────────────────────────────────────────────────────────