agent-comm-hub 0.5.0 → 0.7.0

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/lib/setup.js CHANGED
@@ -255,12 +255,13 @@ function escapeRegExp(value) {
255
255
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
256
256
  }
257
257
  var DSH_PATCH_MARKER = "# \u2500\u2500 agent-comm-hub MCP client";
258
+ var DSH_PLUGIN_NAME = "@deepseek-ai/dsh-mcp-client";
258
259
  function dshPatchBlock(url, serverName) {
259
260
  return `
260
261
  ${DSH_PATCH_MARKER} (installed by \`agent-comm-hub setup\`; undo with \`setup --remove\`) \u2500
261
262
  - insert:
262
263
  - id: ${serverName}
263
- name: '@deepseek-ai/dsh-mcp-client'
264
+ name: '${DSH_PLUGIN_NAME}'
264
265
  config:
265
266
  serverName: ${serverName}
266
267
  transport: streamable-http
@@ -271,49 +272,41 @@ async function mergeDshPatch(file, opts) {
271
272
  if (!existsSync2(file)) return "skipped";
272
273
  const text = await readFile(file, "utf8");
273
274
  const lines = text.split("\n");
274
- const markerLine = lines.findIndex((line) => line.includes(DSH_PATCH_MARKER));
275
- const hasBlock = markerLine >= 0;
276
- const blockRange = () => {
277
- let entryStart = -1;
278
- for (let i = markerLine + 1; i < lines.length; i++) {
279
- if (/^- /.test(lines[i])) {
280
- entryStart = i;
281
- break;
282
- }
275
+ const hubEntryRanges = () => {
276
+ const tops = [];
277
+ for (let i = 0; i < lines.length; i++) {
278
+ if (/^- /.test(lines[i])) tops.push(i);
283
279
  }
284
- let end = lines.length;
285
- if (entryStart >= 0) {
286
- for (let i = entryStart + 1; i < lines.length; i++) {
287
- if (/^- /.test(lines[i])) {
288
- end = i;
289
- break;
290
- }
291
- }
280
+ const ranges2 = [];
281
+ for (let k = 0; k < tops.length; k++) {
282
+ const end = k + 1 < tops.length ? tops[k + 1] : lines.length;
283
+ if (!lines.slice(tops[k], end).some((line) => line.includes(DSH_PLUGIN_NAME))) continue;
284
+ let start = tops[k];
285
+ while (start > 0 && lines[start - 1].trim() === "") start--;
286
+ if (start > 0 && lines[start - 1].includes(DSH_PATCH_MARKER)) start--;
287
+ ranges2.push({ start, end });
292
288
  }
293
- let start = markerLine;
294
- while (start > 0 && lines[start - 1].trim() === "") start--;
295
- return { start, end };
289
+ return ranges2;
296
290
  };
297
- const withoutBlock = () => {
298
- const { start, end } = blockRange();
299
- return lines.slice(0, start).concat(lines.slice(end)).join("\n");
291
+ const withoutHubEntries = () => {
292
+ let out = lines;
293
+ for (const range of hubEntryRanges().reverse()) {
294
+ out = out.slice(0, range.start).concat(out.slice(range.end));
295
+ }
296
+ return out.join("\n");
300
297
  };
301
298
  if (opts.remove) {
302
- if (!hasBlock) return "absent";
303
- const cleaned = withoutBlock();
299
+ if (hubEntryRanges().length === 0) return "absent";
304
300
  await backup(file);
305
- await writeFile(file, cleaned, "utf8");
301
+ await writeFile(file, withoutHubEntries(), "utf8");
306
302
  return "removed";
307
303
  }
308
- if (hasBlock) {
309
- if (lines.some((line) => line.includes(`url: ${opts.url}`))) return "unchanged";
310
- const replaced = withoutBlock();
311
- await backup(file);
312
- await writeFile(file, replaced.trimEnd() + dshPatchBlock(opts.url, opts.serverName), "utf8");
313
- return "changed";
304
+ const ranges = hubEntryRanges();
305
+ if (ranges.length === 1 && lines.slice(ranges[0].start, ranges[0].end).some((line) => line.includes(`url: ${opts.url}`))) {
306
+ return "unchanged";
314
307
  }
315
308
  await backup(file);
316
- await writeFile(file, text.trimEnd() + dshPatchBlock(opts.url, opts.serverName), "utf8");
309
+ await writeFile(file, withoutHubEntries().trimEnd() + dshPatchBlock(opts.url, opts.serverName), "utf8");
317
310
  return "changed";
318
311
  }
319
312
  async function syncSkill(skillDir, skillSrc, remove, log) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-comm-hub",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Generic multi-peer MCP hub: any MCP-capable agent (MiniMax Code, Claude Code, opencode, Codex, Gemini CLI, DSH, ...) connects to one local streamable-http endpoint and they chat, delegate tasks, and acknowledge in real time",
5
5
  "keywords": [
6
6
  "mcp",