adhdev 0.9.67 → 0.9.69

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/index.js CHANGED
@@ -2179,6 +2179,19 @@ var init_saved_sessions = __esm({
2179
2179
  });
2180
2180
 
2181
2181
  // ../../oss/packages/daemon-core/src/config/mesh-config.ts
2182
+ var mesh_config_exports = {};
2183
+ __export(mesh_config_exports, {
2184
+ addNode: () => addNode,
2185
+ createMesh: () => createMesh,
2186
+ deleteMesh: () => deleteMesh,
2187
+ getMesh: () => getMesh,
2188
+ getMeshByRepo: () => getMeshByRepo,
2189
+ listMeshes: () => listMeshes,
2190
+ normalizeRepoIdentity: () => normalizeRepoIdentity,
2191
+ removeNode: () => removeNode,
2192
+ updateMesh: () => updateMesh,
2193
+ updateNode: () => updateNode
2194
+ });
2182
2195
  function getMeshConfigPath() {
2183
2196
  return (0, import_path2.join)(getConfigDir(), "meshes.json");
2184
2197
  }
@@ -2323,6 +2336,10 @@ var init_mesh_config = __esm({
2323
2336
  });
2324
2337
 
2325
2338
  // ../../oss/packages/daemon-core/src/mesh/coordinator-prompt.ts
2339
+ var coordinator_prompt_exports = {};
2340
+ __export(coordinator_prompt_exports, {
2341
+ buildCoordinatorSystemPrompt: () => buildCoordinatorSystemPrompt
2342
+ });
2326
2343
  function buildCoordinatorSystemPrompt(ctx) {
2327
2344
  const { mesh, status, userInstruction } = ctx;
2328
2345
  const sections = [];
@@ -36530,6 +36547,7 @@ function validateProviderDefinition(raw) {
36530
36547
  }
36531
36548
  validateCapabilities(provider, controls, errors);
36532
36549
  validateCanonicalHistory(provider.canonicalHistory, errors);
36550
+ validateMeshCoordinator(provider.meshCoordinator, errors);
36533
36551
  for (const control of controls) {
36534
36552
  validateControl(control, errors);
36535
36553
  }
@@ -36620,6 +36638,60 @@ function validateCanonicalHistory(raw, errors) {
36620
36638
  }
36621
36639
  }
36622
36640
  }
36641
+ function validateMeshCoordinator(raw, errors) {
36642
+ if (raw === void 0) return;
36643
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
36644
+ errors.push("meshCoordinator must be an object");
36645
+ return;
36646
+ }
36647
+ const meshCoordinator = raw;
36648
+ if (typeof meshCoordinator.supported !== "boolean") {
36649
+ errors.push("meshCoordinator.supported must be boolean");
36650
+ }
36651
+ if (meshCoordinator.reason !== void 0 && (typeof meshCoordinator.reason !== "string" || !meshCoordinator.reason.trim())) {
36652
+ errors.push("meshCoordinator.reason must be a non-empty string when provided");
36653
+ }
36654
+ const mcpConfig = meshCoordinator.mcpConfig;
36655
+ if (mcpConfig === void 0) return;
36656
+ if (!mcpConfig || typeof mcpConfig !== "object" || Array.isArray(mcpConfig)) {
36657
+ errors.push("meshCoordinator.mcpConfig must be an object");
36658
+ return;
36659
+ }
36660
+ const config2 = mcpConfig;
36661
+ const mode = config2.mode;
36662
+ if (!["auto_import", "manual", "none"].includes(String(mode))) {
36663
+ errors.push("meshCoordinator.mcpConfig.mode must be one of: auto_import, manual, none");
36664
+ }
36665
+ const format = config2.format;
36666
+ if (format !== void 0 && !["claude_mcp_json", "hermes_config_yaml"].includes(String(format))) {
36667
+ errors.push("meshCoordinator.mcpConfig.format must be one of: claude_mcp_json, hermes_config_yaml");
36668
+ }
36669
+ for (const key of ["path", "serverName", "configPathCommand", "instructions", "template"]) {
36670
+ const value = config2[key];
36671
+ if (value !== void 0 && (typeof value !== "string" || !value.trim())) {
36672
+ errors.push(`meshCoordinator.mcpConfig.${key} must be a non-empty string when provided`);
36673
+ }
36674
+ }
36675
+ if (config2.requiresRestart !== void 0 && typeof config2.requiresRestart !== "boolean") {
36676
+ errors.push("meshCoordinator.mcpConfig.requiresRestart must be boolean when provided");
36677
+ }
36678
+ if (mode === "auto_import") {
36679
+ if (format === void 0) {
36680
+ errors.push("meshCoordinator.mcpConfig.format is required for auto_import MCP setup");
36681
+ }
36682
+ if (typeof config2.path !== "string" || !config2.path.trim()) {
36683
+ errors.push("meshCoordinator.mcpConfig.path is required for auto_import MCP setup");
36684
+ }
36685
+ }
36686
+ if (mode === "manual") {
36687
+ if (typeof config2.instructions !== "string" || !config2.instructions.trim()) {
36688
+ errors.push("meshCoordinator.mcpConfig.instructions is required for manual MCP setup");
36689
+ }
36690
+ if (typeof config2.template !== "string" || !config2.template.trim()) {
36691
+ errors.push("meshCoordinator.mcpConfig.template is required for manual MCP setup");
36692
+ }
36693
+ }
36694
+ }
36623
36695
  function validateControl(control, errors) {
36624
36696
  if (!control || typeof control !== "object") {
36625
36697
  errors.push("controls: each control must be an object");
@@ -36661,6 +36733,8 @@ var init_provider_schema = __esm({
36661
36733
  "type",
36662
36734
  "name",
36663
36735
  "category",
36736
+ "transcriptAuthority",
36737
+ "transcriptContext",
36664
36738
  "aliases",
36665
36739
  "cdpPorts",
36666
36740
  "targetFilter",
@@ -36705,6 +36779,7 @@ var init_provider_schema = __esm({
36705
36779
  "staticConfigOptions",
36706
36780
  "spawnArgBuilder",
36707
36781
  "auth",
36782
+ "meshCoordinator",
36708
36783
  "contractVersion",
36709
36784
  "capabilities",
36710
36785
  "providerVersion",
@@ -38874,6 +38949,75 @@ var init_command_log = __esm({
38874
38949
  }
38875
38950
  });
38876
38951
 
38952
+ // ../../oss/packages/daemon-core/src/commands/mesh-coordinator.ts
38953
+ function resolveMeshCoordinatorSetup(options) {
38954
+ const { provider, meshId, workspace } = options;
38955
+ const config2 = provider?.meshCoordinator;
38956
+ if (!config2?.supported) {
38957
+ return {
38958
+ kind: "unsupported",
38959
+ reason: config2?.reason || "Provider does not declare Repo Mesh coordinator support"
38960
+ };
38961
+ }
38962
+ const mcpConfig = config2.mcpConfig;
38963
+ if (!mcpConfig || mcpConfig.mode === "none") {
38964
+ return {
38965
+ kind: "unsupported",
38966
+ reason: config2.reason || "Provider does not declare a usable Repo Mesh MCP configuration mode"
38967
+ };
38968
+ }
38969
+ const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
38970
+ if (mcpConfig.mode === "auto_import") {
38971
+ const path33 = mcpConfig.path?.trim();
38972
+ if (!path33) {
38973
+ return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
38974
+ }
38975
+ return {
38976
+ kind: "auto_import",
38977
+ serverName,
38978
+ configPath: (0, import_path4.join)(workspace, path33),
38979
+ configFormat: mcpConfig.format
38980
+ };
38981
+ }
38982
+ if (mcpConfig.mode === "manual") {
38983
+ const instructions = mcpConfig.instructions?.trim();
38984
+ const template = mcpConfig.template;
38985
+ if (!instructions || !template?.trim()) {
38986
+ return { kind: "unsupported", reason: "Provider manual MCP setup is missing instructions or template" };
38987
+ }
38988
+ return {
38989
+ kind: "manual",
38990
+ serverName,
38991
+ configFormat: mcpConfig.format,
38992
+ configPathCommand: mcpConfig.configPathCommand,
38993
+ requiresRestart: mcpConfig.requiresRestart === true,
38994
+ instructions,
38995
+ template: renderMeshCoordinatorTemplate(template, {
38996
+ meshId,
38997
+ workspace,
38998
+ serverName,
38999
+ adhdevMcpCommand: options.adhdevMcpCommand || DEFAULT_ADHDEV_MCP_COMMAND
39000
+ })
39001
+ };
39002
+ }
39003
+ return {
39004
+ kind: "unsupported",
39005
+ reason: `Unsupported Repo Mesh MCP configuration mode: ${String(mcpConfig.mode)}`
39006
+ };
39007
+ }
39008
+ function renderMeshCoordinatorTemplate(template, values) {
39009
+ return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand)\s*\}\}/g, (_2, key) => values[key] || "");
39010
+ }
39011
+ var import_path4, DEFAULT_SERVER_NAME, DEFAULT_ADHDEV_MCP_COMMAND;
39012
+ var init_mesh_coordinator = __esm({
39013
+ "../../oss/packages/daemon-core/src/commands/mesh-coordinator.ts"() {
39014
+ "use strict";
39015
+ import_path4 = require("path");
39016
+ DEFAULT_SERVER_NAME = "adhdev-mesh";
39017
+ DEFAULT_ADHDEV_MCP_COMMAND = "adhdev-mcp";
39018
+ }
39019
+ });
39020
+
38877
39021
  // ../../oss/packages/daemon-core/src/status/snapshot.ts
38878
39022
  function buildRecentReadDebugSignature(snapshot) {
38879
39023
  return [
@@ -38919,7 +39063,8 @@ function buildAvailableProviders(providerLoader) {
38919
39063
  ...provider.enabled !== void 0 ? { enabled: provider.enabled } : {},
38920
39064
  ...provider.machineStatus !== void 0 ? { machineStatus: provider.machineStatus } : {},
38921
39065
  ...provider.lastDetection !== void 0 ? { lastDetection: provider.lastDetection } : {},
38922
- ...provider.lastVerification !== void 0 ? { lastVerification: provider.lastVerification } : {}
39066
+ ...provider.lastVerification !== void 0 ? { lastVerification: provider.lastVerification } : {},
39067
+ ...provider.meshCoordinator !== void 0 ? { meshCoordinator: provider.meshCoordinator } : {}
38923
39068
  }));
38924
39069
  }
38925
39070
  function buildMachineInfo(profile = "full") {
@@ -39646,6 +39791,7 @@ var init_router = __esm({
39646
39791
  init_logger();
39647
39792
  init_debug_trace();
39648
39793
  init_runtime_surface();
39794
+ init_mesh_coordinator();
39649
39795
  init_builders();
39650
39796
  init_snapshot();
39651
39797
  init_snapshot();
@@ -40294,6 +40440,178 @@ var init_router = __esm({
40294
40440
  updateConfig({ machineNickname: nickname || null });
40295
40441
  return { success: true };
40296
40442
  }
40443
+ // ─── Mesh CRUD (local meshes.json) ───
40444
+ case "list_meshes": {
40445
+ try {
40446
+ const { listMeshes: listMeshes2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
40447
+ return { success: true, meshes: listMeshes2() };
40448
+ } catch (e) {
40449
+ return { success: false, error: e.message };
40450
+ }
40451
+ }
40452
+ case "get_mesh": {
40453
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
40454
+ if (!meshId) return { success: false, error: "meshId required" };
40455
+ try {
40456
+ const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
40457
+ const mesh = getMesh3(meshId);
40458
+ if (!mesh) return { success: false, error: "Mesh not found" };
40459
+ return { success: true, mesh };
40460
+ } catch (e) {
40461
+ return { success: false, error: e.message };
40462
+ }
40463
+ }
40464
+ case "create_mesh": {
40465
+ const name = typeof args?.name === "string" ? args.name.trim() : "";
40466
+ const repoIdentity = typeof args?.repoIdentity === "string" ? args.repoIdentity.trim() : "";
40467
+ const repoRemoteUrl = typeof args?.repoRemoteUrl === "string" ? args.repoRemoteUrl.trim() : void 0;
40468
+ const defaultBranch = typeof args?.defaultBranch === "string" ? args.defaultBranch.trim() : void 0;
40469
+ if (!name) return { success: false, error: "name required" };
40470
+ try {
40471
+ const { createMesh: createMesh2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
40472
+ const mesh = createMesh2({ name, repoIdentity, repoRemoteUrl, defaultBranch });
40473
+ return { success: true, mesh };
40474
+ } catch (e) {
40475
+ return { success: false, error: e.message };
40476
+ }
40477
+ }
40478
+ case "delete_mesh": {
40479
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
40480
+ if (!meshId) return { success: false, error: "meshId required" };
40481
+ try {
40482
+ const { deleteMesh: deleteMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
40483
+ const deleted = deleteMesh3(meshId);
40484
+ return { success: true, deleted };
40485
+ } catch (e) {
40486
+ return { success: false, error: e.message };
40487
+ }
40488
+ }
40489
+ case "add_mesh_node": {
40490
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
40491
+ const workspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
40492
+ if (!meshId) return { success: false, error: "meshId required" };
40493
+ if (!workspace) return { success: false, error: "workspace required" };
40494
+ try {
40495
+ const { addNode: addNode3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
40496
+ const node = addNode3(meshId, { workspace });
40497
+ if (!node) return { success: false, error: "Mesh not found" };
40498
+ return { success: true, node };
40499
+ } catch (e) {
40500
+ return { success: false, error: e.message };
40501
+ }
40502
+ }
40503
+ case "remove_mesh_node": {
40504
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
40505
+ const nodeId = typeof args?.nodeId === "string" ? args.nodeId.trim() : "";
40506
+ if (!meshId || !nodeId) return { success: false, error: "meshId and nodeId required" };
40507
+ try {
40508
+ const { removeNode: removeNode3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
40509
+ const removed = removeNode3(meshId, nodeId);
40510
+ return { success: true, removed };
40511
+ } catch (e) {
40512
+ return { success: false, error: e.message };
40513
+ }
40514
+ }
40515
+ // ─── Mesh Coordinator Launch ───
40516
+ case "launch_mesh_coordinator": {
40517
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
40518
+ const cliType = typeof args?.cliType === "string" ? args.cliType.trim() : "claude-cli";
40519
+ if (!meshId) return { success: false, error: "meshId required" };
40520
+ try {
40521
+ const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
40522
+ const { buildCoordinatorSystemPrompt: buildCoordinatorSystemPrompt2 } = await Promise.resolve().then(() => (init_coordinator_prompt(), coordinator_prompt_exports));
40523
+ const mesh = getMesh3(meshId);
40524
+ if (!mesh) return { success: false, error: "Mesh not found" };
40525
+ if (mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
40526
+ const workspace = mesh.nodes[0].workspace;
40527
+ const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
40528
+ const coordinatorSetup = resolveMeshCoordinatorSetup({
40529
+ provider: providerMeta,
40530
+ meshId,
40531
+ workspace
40532
+ });
40533
+ if (coordinatorSetup.kind === "unsupported") {
40534
+ return {
40535
+ success: false,
40536
+ code: "mesh_coordinator_unsupported",
40537
+ error: coordinatorSetup.reason,
40538
+ meshId,
40539
+ cliType,
40540
+ workspace
40541
+ };
40542
+ }
40543
+ if (coordinatorSetup.kind === "manual") {
40544
+ return {
40545
+ success: false,
40546
+ code: "mesh_coordinator_manual_mcp_setup_required",
40547
+ error: coordinatorSetup.instructions,
40548
+ meshId,
40549
+ cliType,
40550
+ workspace,
40551
+ meshCoordinatorSetup: coordinatorSetup
40552
+ };
40553
+ }
40554
+ if (coordinatorSetup.configFormat !== "claude_mcp_json") {
40555
+ return {
40556
+ success: false,
40557
+ code: "mesh_coordinator_unsupported",
40558
+ error: `Unsupported auto-import MCP config format: ${String(coordinatorSetup.configFormat)}`,
40559
+ meshId,
40560
+ cliType,
40561
+ workspace
40562
+ };
40563
+ }
40564
+ const { existsSync: existsSync25, readFileSync: readFileSync20, writeFileSync: writeFileSync14, copyFileSync: copyFileSync4 } = await import("fs");
40565
+ const mcpConfigPath = coordinatorSetup.configPath;
40566
+ const hadExistingMcpConfig = existsSync25(mcpConfigPath);
40567
+ let existingMcpConfig = {};
40568
+ if (hadExistingMcpConfig) {
40569
+ try {
40570
+ existingMcpConfig = JSON.parse(readFileSync20(mcpConfigPath, "utf-8"));
40571
+ copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
40572
+ } catch {
40573
+ }
40574
+ }
40575
+ const mcpConfig = {
40576
+ ...existingMcpConfig,
40577
+ mcpServers: {
40578
+ ...existingMcpConfig.mcpServers || {},
40579
+ [coordinatorSetup.serverName]: {
40580
+ command: "adhdev-mcp",
40581
+ args: ["--repo-mesh", meshId]
40582
+ }
40583
+ }
40584
+ };
40585
+ writeFileSync14(mcpConfigPath, JSON.stringify(mcpConfig, null, 2), "utf-8");
40586
+ LOG.info("MeshCoordinator", `Wrote ${mcpConfigPath} with ${coordinatorSetup.serverName} server`);
40587
+ let systemPrompt = "";
40588
+ try {
40589
+ systemPrompt = buildCoordinatorSystemPrompt2({ mesh });
40590
+ } catch {
40591
+ 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).`;
40592
+ }
40593
+ const launchResult = await this.deps.cliManager.handleCliCommand("launch_cli", {
40594
+ cliType,
40595
+ dir: workspace,
40596
+ initialPrompt: systemPrompt
40597
+ });
40598
+ if (!launchResult?.success) {
40599
+ return { success: false, error: launchResult?.error || "Failed to launch CLI session" };
40600
+ }
40601
+ LOG.info("MeshCoordinator", `Launched ${cliType} coordinator for mesh ${meshId} in ${workspace}`);
40602
+ return {
40603
+ success: true,
40604
+ meshId,
40605
+ cliType,
40606
+ workspace,
40607
+ sessionId: launchResult.sessionId || launchResult.id,
40608
+ mcpConfigWritten: true
40609
+ };
40610
+ } catch (e) {
40611
+ LOG.error("MeshCoordinator", `Failed: ${e.message}`);
40612
+ return { success: false, error: e.message };
40613
+ }
40614
+ }
40297
40615
  default:
40298
40616
  break;
40299
40617
  }
@@ -58250,9 +58568,9 @@ function resolvePackageVersion(options) {
58250
58568
  const injectedVersion = options?.injectedVersion || "unknown";
58251
58569
  const dir = options?.dirname || __dirname;
58252
58570
  const possiblePaths = [
58253
- (0, import_path4.join)(dir, "..", "..", "package.json"),
58254
- (0, import_path4.join)(dir, "..", "package.json"),
58255
- (0, import_path4.join)(dir, "package.json")
58571
+ (0, import_path5.join)(dir, "..", "..", "package.json"),
58572
+ (0, import_path5.join)(dir, "..", "package.json"),
58573
+ (0, import_path5.join)(dir, "package.json")
58256
58574
  ];
58257
58575
  for (const p of possiblePaths) {
58258
58576
  try {
@@ -58263,12 +58581,12 @@ function resolvePackageVersion(options) {
58263
58581
  }
58264
58582
  return injectedVersion;
58265
58583
  }
58266
- var import_fs7, import_path4;
58584
+ var import_fs7, import_path5;
58267
58585
  var init_version = __esm({
58268
58586
  "src/version.ts"() {
58269
58587
  "use strict";
58270
58588
  import_fs7 = require("fs");
58271
- import_path4 = require("path");
58589
+ import_path5 = require("path");
58272
58590
  }
58273
58591
  });
58274
58592
 
@@ -58597,7 +58915,7 @@ var init_adhdev_daemon = __esm({
58597
58915
  init_version();
58598
58916
  init_src();
58599
58917
  init_runtime_defaults();
58600
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.67" });
58918
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.69" });
58601
58919
  AdhdevDaemon = class _AdhdevDaemon {
58602
58920
  localHttpServer = null;
58603
58921
  localWss = null;
@@ -74465,7 +74783,7 @@ var require_buffer_list = __commonJS({
74465
74783
  }
74466
74784
  }, {
74467
74785
  key: "join",
74468
- value: function join32(s) {
74786
+ value: function join33(s) {
74469
74787
  if (this.length === 0) return "";
74470
74788
  var p = this.head;
74471
74789
  var ret = "" + p.data;