adhdev 0.9.67 → 0.9.68

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/dist/cli/index.js CHANGED
@@ -2699,6 +2699,19 @@ var init_saved_sessions = __esm({
2699
2699
  });
2700
2700
 
2701
2701
  // ../../oss/packages/daemon-core/src/config/mesh-config.ts
2702
+ var mesh_config_exports = {};
2703
+ __export(mesh_config_exports, {
2704
+ addNode: () => addNode,
2705
+ createMesh: () => createMesh,
2706
+ deleteMesh: () => deleteMesh,
2707
+ getMesh: () => getMesh,
2708
+ getMeshByRepo: () => getMeshByRepo,
2709
+ listMeshes: () => listMeshes,
2710
+ normalizeRepoIdentity: () => normalizeRepoIdentity,
2711
+ removeNode: () => removeNode,
2712
+ updateMesh: () => updateMesh,
2713
+ updateNode: () => updateNode
2714
+ });
2702
2715
  function getMeshConfigPath() {
2703
2716
  return (0, import_path2.join)(getConfigDir(), "meshes.json");
2704
2717
  }
@@ -2843,6 +2856,10 @@ var init_mesh_config = __esm({
2843
2856
  });
2844
2857
 
2845
2858
  // ../../oss/packages/daemon-core/src/mesh/coordinator-prompt.ts
2859
+ var coordinator_prompt_exports = {};
2860
+ __export(coordinator_prompt_exports, {
2861
+ buildCoordinatorSystemPrompt: () => buildCoordinatorSystemPrompt
2862
+ });
2846
2863
  function buildCoordinatorSystemPrompt(ctx) {
2847
2864
  const { mesh, status, userInstruction } = ctx;
2848
2865
  const sections = [];
@@ -41251,6 +41268,142 @@ var init_router = __esm({
41251
41268
  updateConfig({ machineNickname: nickname || null });
41252
41269
  return { success: true };
41253
41270
  }
41271
+ // ─── Mesh CRUD (local meshes.json) ───
41272
+ case "list_meshes": {
41273
+ try {
41274
+ const { listMeshes: listMeshes2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41275
+ return { success: true, meshes: listMeshes2() };
41276
+ } catch (e) {
41277
+ return { success: false, error: e.message };
41278
+ }
41279
+ }
41280
+ case "get_mesh": {
41281
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
41282
+ if (!meshId) return { success: false, error: "meshId required" };
41283
+ try {
41284
+ const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41285
+ const mesh = getMesh3(meshId);
41286
+ if (!mesh) return { success: false, error: "Mesh not found" };
41287
+ return { success: true, mesh };
41288
+ } catch (e) {
41289
+ return { success: false, error: e.message };
41290
+ }
41291
+ }
41292
+ case "create_mesh": {
41293
+ const name = typeof args?.name === "string" ? args.name.trim() : "";
41294
+ const repoIdentity = typeof args?.repoIdentity === "string" ? args.repoIdentity.trim() : "";
41295
+ const repoRemoteUrl = typeof args?.repoRemoteUrl === "string" ? args.repoRemoteUrl.trim() : void 0;
41296
+ const defaultBranch = typeof args?.defaultBranch === "string" ? args.defaultBranch.trim() : void 0;
41297
+ if (!name) return { success: false, error: "name required" };
41298
+ try {
41299
+ const { createMesh: createMesh2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41300
+ const mesh = createMesh2({ name, repoIdentity, repoRemoteUrl, defaultBranch });
41301
+ return { success: true, mesh };
41302
+ } catch (e) {
41303
+ return { success: false, error: e.message };
41304
+ }
41305
+ }
41306
+ case "delete_mesh": {
41307
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
41308
+ if (!meshId) return { success: false, error: "meshId required" };
41309
+ try {
41310
+ const { deleteMesh: deleteMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41311
+ const deleted = deleteMesh3(meshId);
41312
+ return { success: true, deleted };
41313
+ } catch (e) {
41314
+ return { success: false, error: e.message };
41315
+ }
41316
+ }
41317
+ case "add_mesh_node": {
41318
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
41319
+ const workspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
41320
+ if (!meshId) return { success: false, error: "meshId required" };
41321
+ if (!workspace) return { success: false, error: "workspace required" };
41322
+ try {
41323
+ const { addNode: addNode3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41324
+ const node = addNode3(meshId, { workspace });
41325
+ if (!node) return { success: false, error: "Mesh not found" };
41326
+ return { success: true, node };
41327
+ } catch (e) {
41328
+ return { success: false, error: e.message };
41329
+ }
41330
+ }
41331
+ case "remove_mesh_node": {
41332
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
41333
+ const nodeId = typeof args?.nodeId === "string" ? args.nodeId.trim() : "";
41334
+ if (!meshId || !nodeId) return { success: false, error: "meshId and nodeId required" };
41335
+ try {
41336
+ const { removeNode: removeNode3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41337
+ const removed = removeNode3(meshId, nodeId);
41338
+ return { success: true, removed };
41339
+ } catch (e) {
41340
+ return { success: false, error: e.message };
41341
+ }
41342
+ }
41343
+ // ─── Mesh Coordinator Launch ───
41344
+ case "launch_mesh_coordinator": {
41345
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
41346
+ const cliType = typeof args?.cliType === "string" ? args.cliType.trim() : "claude-cli";
41347
+ if (!meshId) return { success: false, error: "meshId required" };
41348
+ try {
41349
+ const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41350
+ const { buildCoordinatorSystemPrompt: buildCoordinatorSystemPrompt2 } = await Promise.resolve().then(() => (init_coordinator_prompt(), coordinator_prompt_exports));
41351
+ const mesh = getMesh3(meshId);
41352
+ if (!mesh) return { success: false, error: "Mesh not found" };
41353
+ if (mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
41354
+ const workspace = mesh.nodes[0].workspace;
41355
+ const { existsSync: existsSync28, readFileSync: readFileSync21, writeFileSync: writeFileSync15, copyFileSync: copyFileSync4 } = await import("fs");
41356
+ const { join: join35 } = await import("path");
41357
+ const mcpConfigPath = join35(workspace, ".mcp.json");
41358
+ const hadExistingMcpConfig = existsSync28(mcpConfigPath);
41359
+ let existingMcpConfig = {};
41360
+ if (hadExistingMcpConfig) {
41361
+ try {
41362
+ existingMcpConfig = JSON.parse(readFileSync21(mcpConfigPath, "utf-8"));
41363
+ copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
41364
+ } catch {
41365
+ }
41366
+ }
41367
+ const mcpConfig = {
41368
+ ...existingMcpConfig,
41369
+ mcpServers: {
41370
+ ...existingMcpConfig.mcpServers || {},
41371
+ "adhdev-mesh": {
41372
+ command: "adhdev-mcp",
41373
+ args: ["--repo-mesh", meshId]
41374
+ }
41375
+ }
41376
+ };
41377
+ writeFileSync15(mcpConfigPath, JSON.stringify(mcpConfig, null, 2), "utf-8");
41378
+ LOG.info("MeshCoordinator", `Wrote .mcp.json to ${workspace} with adhdev-mesh server`);
41379
+ let systemPrompt = "";
41380
+ try {
41381
+ systemPrompt = buildCoordinatorSystemPrompt2({ mesh });
41382
+ } catch {
41383
+ systemPrompt = `You are a Repo Mesh Coordinator for "${mesh.name}". Use the adhdev-mesh MCP tools (mesh_status, mesh_list_nodes, mesh_send_task, mesh_read_chat, mesh_launch_session, etc.) to orchestrate work across ${mesh.nodes.length} node(s).`;
41384
+ }
41385
+ const launchResult = await this.deps.cliManager.handleCliCommand("launch_cli", {
41386
+ cliType,
41387
+ dir: workspace,
41388
+ initialPrompt: systemPrompt
41389
+ });
41390
+ if (!launchResult?.success) {
41391
+ return { success: false, error: launchResult?.error || "Failed to launch CLI session" };
41392
+ }
41393
+ LOG.info("MeshCoordinator", `Launched ${cliType} coordinator for mesh ${meshId} in ${workspace}`);
41394
+ return {
41395
+ success: true,
41396
+ meshId,
41397
+ cliType,
41398
+ workspace,
41399
+ sessionId: launchResult.sessionId || launchResult.id,
41400
+ mcpConfigWritten: true
41401
+ };
41402
+ } catch (e) {
41403
+ LOG.error("MeshCoordinator", `Failed: ${e.message}`);
41404
+ return { success: false, error: e.message };
41405
+ }
41406
+ }
41254
41407
  default:
41255
41408
  break;
41256
41409
  }
@@ -89739,7 +89892,7 @@ var init_adhdev_daemon = __esm({
89739
89892
  init_version();
89740
89893
  init_src();
89741
89894
  init_runtime_defaults();
89742
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.67" });
89895
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.68" });
89743
89896
  AdhdevDaemon = class _AdhdevDaemon {
89744
89897
  localHttpServer = null;
89745
89898
  localWss = null;