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/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 = [];
@@ -37487,6 +37504,7 @@ function validateProviderDefinition(raw) {
37487
37504
  }
37488
37505
  validateCapabilities(provider, controls, errors);
37489
37506
  validateCanonicalHistory(provider.canonicalHistory, errors);
37507
+ validateMeshCoordinator(provider.meshCoordinator, errors);
37490
37508
  for (const control of controls) {
37491
37509
  validateControl(control, errors);
37492
37510
  }
@@ -37577,6 +37595,60 @@ function validateCanonicalHistory(raw, errors) {
37577
37595
  }
37578
37596
  }
37579
37597
  }
37598
+ function validateMeshCoordinator(raw, errors) {
37599
+ if (raw === void 0) return;
37600
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
37601
+ errors.push("meshCoordinator must be an object");
37602
+ return;
37603
+ }
37604
+ const meshCoordinator = raw;
37605
+ if (typeof meshCoordinator.supported !== "boolean") {
37606
+ errors.push("meshCoordinator.supported must be boolean");
37607
+ }
37608
+ if (meshCoordinator.reason !== void 0 && (typeof meshCoordinator.reason !== "string" || !meshCoordinator.reason.trim())) {
37609
+ errors.push("meshCoordinator.reason must be a non-empty string when provided");
37610
+ }
37611
+ const mcpConfig = meshCoordinator.mcpConfig;
37612
+ if (mcpConfig === void 0) return;
37613
+ if (!mcpConfig || typeof mcpConfig !== "object" || Array.isArray(mcpConfig)) {
37614
+ errors.push("meshCoordinator.mcpConfig must be an object");
37615
+ return;
37616
+ }
37617
+ const config2 = mcpConfig;
37618
+ const mode = config2.mode;
37619
+ if (!["auto_import", "manual", "none"].includes(String(mode))) {
37620
+ errors.push("meshCoordinator.mcpConfig.mode must be one of: auto_import, manual, none");
37621
+ }
37622
+ const format = config2.format;
37623
+ if (format !== void 0 && !["claude_mcp_json", "hermes_config_yaml"].includes(String(format))) {
37624
+ errors.push("meshCoordinator.mcpConfig.format must be one of: claude_mcp_json, hermes_config_yaml");
37625
+ }
37626
+ for (const key of ["path", "serverName", "configPathCommand", "instructions", "template"]) {
37627
+ const value = config2[key];
37628
+ if (value !== void 0 && (typeof value !== "string" || !value.trim())) {
37629
+ errors.push(`meshCoordinator.mcpConfig.${key} must be a non-empty string when provided`);
37630
+ }
37631
+ }
37632
+ if (config2.requiresRestart !== void 0 && typeof config2.requiresRestart !== "boolean") {
37633
+ errors.push("meshCoordinator.mcpConfig.requiresRestart must be boolean when provided");
37634
+ }
37635
+ if (mode === "auto_import") {
37636
+ if (format === void 0) {
37637
+ errors.push("meshCoordinator.mcpConfig.format is required for auto_import MCP setup");
37638
+ }
37639
+ if (typeof config2.path !== "string" || !config2.path.trim()) {
37640
+ errors.push("meshCoordinator.mcpConfig.path is required for auto_import MCP setup");
37641
+ }
37642
+ }
37643
+ if (mode === "manual") {
37644
+ if (typeof config2.instructions !== "string" || !config2.instructions.trim()) {
37645
+ errors.push("meshCoordinator.mcpConfig.instructions is required for manual MCP setup");
37646
+ }
37647
+ if (typeof config2.template !== "string" || !config2.template.trim()) {
37648
+ errors.push("meshCoordinator.mcpConfig.template is required for manual MCP setup");
37649
+ }
37650
+ }
37651
+ }
37580
37652
  function validateControl(control, errors) {
37581
37653
  if (!control || typeof control !== "object") {
37582
37654
  errors.push("controls: each control must be an object");
@@ -37618,6 +37690,8 @@ var init_provider_schema = __esm({
37618
37690
  "type",
37619
37691
  "name",
37620
37692
  "category",
37693
+ "transcriptAuthority",
37694
+ "transcriptContext",
37621
37695
  "aliases",
37622
37696
  "cdpPorts",
37623
37697
  "targetFilter",
@@ -37662,6 +37736,7 @@ var init_provider_schema = __esm({
37662
37736
  "staticConfigOptions",
37663
37737
  "spawnArgBuilder",
37664
37738
  "auth",
37739
+ "meshCoordinator",
37665
37740
  "contractVersion",
37666
37741
  "capabilities",
37667
37742
  "providerVersion",
@@ -39831,6 +39906,75 @@ var init_command_log = __esm({
39831
39906
  }
39832
39907
  });
39833
39908
 
39909
+ // ../../oss/packages/daemon-core/src/commands/mesh-coordinator.ts
39910
+ function resolveMeshCoordinatorSetup(options) {
39911
+ const { provider, meshId, workspace } = options;
39912
+ const config2 = provider?.meshCoordinator;
39913
+ if (!config2?.supported) {
39914
+ return {
39915
+ kind: "unsupported",
39916
+ reason: config2?.reason || "Provider does not declare Repo Mesh coordinator support"
39917
+ };
39918
+ }
39919
+ const mcpConfig = config2.mcpConfig;
39920
+ if (!mcpConfig || mcpConfig.mode === "none") {
39921
+ return {
39922
+ kind: "unsupported",
39923
+ reason: config2.reason || "Provider does not declare a usable Repo Mesh MCP configuration mode"
39924
+ };
39925
+ }
39926
+ const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
39927
+ if (mcpConfig.mode === "auto_import") {
39928
+ const path40 = mcpConfig.path?.trim();
39929
+ if (!path40) {
39930
+ return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
39931
+ }
39932
+ return {
39933
+ kind: "auto_import",
39934
+ serverName,
39935
+ configPath: (0, import_path4.join)(workspace, path40),
39936
+ configFormat: mcpConfig.format
39937
+ };
39938
+ }
39939
+ if (mcpConfig.mode === "manual") {
39940
+ const instructions = mcpConfig.instructions?.trim();
39941
+ const template = mcpConfig.template;
39942
+ if (!instructions || !template?.trim()) {
39943
+ return { kind: "unsupported", reason: "Provider manual MCP setup is missing instructions or template" };
39944
+ }
39945
+ return {
39946
+ kind: "manual",
39947
+ serverName,
39948
+ configFormat: mcpConfig.format,
39949
+ configPathCommand: mcpConfig.configPathCommand,
39950
+ requiresRestart: mcpConfig.requiresRestart === true,
39951
+ instructions,
39952
+ template: renderMeshCoordinatorTemplate(template, {
39953
+ meshId,
39954
+ workspace,
39955
+ serverName,
39956
+ adhdevMcpCommand: options.adhdevMcpCommand || DEFAULT_ADHDEV_MCP_COMMAND
39957
+ })
39958
+ };
39959
+ }
39960
+ return {
39961
+ kind: "unsupported",
39962
+ reason: `Unsupported Repo Mesh MCP configuration mode: ${String(mcpConfig.mode)}`
39963
+ };
39964
+ }
39965
+ function renderMeshCoordinatorTemplate(template, values) {
39966
+ return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand)\s*\}\}/g, (_2, key) => values[key] || "");
39967
+ }
39968
+ var import_path4, DEFAULT_SERVER_NAME, DEFAULT_ADHDEV_MCP_COMMAND;
39969
+ var init_mesh_coordinator = __esm({
39970
+ "../../oss/packages/daemon-core/src/commands/mesh-coordinator.ts"() {
39971
+ "use strict";
39972
+ import_path4 = require("path");
39973
+ DEFAULT_SERVER_NAME = "adhdev-mesh";
39974
+ DEFAULT_ADHDEV_MCP_COMMAND = "adhdev-mcp";
39975
+ }
39976
+ });
39977
+
39834
39978
  // ../../oss/packages/daemon-core/src/status/snapshot.ts
39835
39979
  function buildRecentReadDebugSignature(snapshot) {
39836
39980
  return [
@@ -39876,7 +40020,8 @@ function buildAvailableProviders(providerLoader) {
39876
40020
  ...provider.enabled !== void 0 ? { enabled: provider.enabled } : {},
39877
40021
  ...provider.machineStatus !== void 0 ? { machineStatus: provider.machineStatus } : {},
39878
40022
  ...provider.lastDetection !== void 0 ? { lastDetection: provider.lastDetection } : {},
39879
- ...provider.lastVerification !== void 0 ? { lastVerification: provider.lastVerification } : {}
40023
+ ...provider.lastVerification !== void 0 ? { lastVerification: provider.lastVerification } : {},
40024
+ ...provider.meshCoordinator !== void 0 ? { meshCoordinator: provider.meshCoordinator } : {}
39880
40025
  }));
39881
40026
  }
39882
40027
  function buildMachineInfo(profile = "full") {
@@ -40603,6 +40748,7 @@ var init_router = __esm({
40603
40748
  init_logger();
40604
40749
  init_debug_trace();
40605
40750
  init_runtime_surface();
40751
+ init_mesh_coordinator();
40606
40752
  init_builders();
40607
40753
  init_snapshot();
40608
40754
  init_snapshot();
@@ -41251,6 +41397,178 @@ var init_router = __esm({
41251
41397
  updateConfig({ machineNickname: nickname || null });
41252
41398
  return { success: true };
41253
41399
  }
41400
+ // ─── Mesh CRUD (local meshes.json) ───
41401
+ case "list_meshes": {
41402
+ try {
41403
+ const { listMeshes: listMeshes2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41404
+ return { success: true, meshes: listMeshes2() };
41405
+ } catch (e) {
41406
+ return { success: false, error: e.message };
41407
+ }
41408
+ }
41409
+ case "get_mesh": {
41410
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
41411
+ if (!meshId) return { success: false, error: "meshId required" };
41412
+ try {
41413
+ const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41414
+ const mesh = getMesh3(meshId);
41415
+ if (!mesh) return { success: false, error: "Mesh not found" };
41416
+ return { success: true, mesh };
41417
+ } catch (e) {
41418
+ return { success: false, error: e.message };
41419
+ }
41420
+ }
41421
+ case "create_mesh": {
41422
+ const name = typeof args?.name === "string" ? args.name.trim() : "";
41423
+ const repoIdentity = typeof args?.repoIdentity === "string" ? args.repoIdentity.trim() : "";
41424
+ const repoRemoteUrl = typeof args?.repoRemoteUrl === "string" ? args.repoRemoteUrl.trim() : void 0;
41425
+ const defaultBranch = typeof args?.defaultBranch === "string" ? args.defaultBranch.trim() : void 0;
41426
+ if (!name) return { success: false, error: "name required" };
41427
+ try {
41428
+ const { createMesh: createMesh2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41429
+ const mesh = createMesh2({ name, repoIdentity, repoRemoteUrl, defaultBranch });
41430
+ return { success: true, mesh };
41431
+ } catch (e) {
41432
+ return { success: false, error: e.message };
41433
+ }
41434
+ }
41435
+ case "delete_mesh": {
41436
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
41437
+ if (!meshId) return { success: false, error: "meshId required" };
41438
+ try {
41439
+ const { deleteMesh: deleteMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41440
+ const deleted = deleteMesh3(meshId);
41441
+ return { success: true, deleted };
41442
+ } catch (e) {
41443
+ return { success: false, error: e.message };
41444
+ }
41445
+ }
41446
+ case "add_mesh_node": {
41447
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
41448
+ const workspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
41449
+ if (!meshId) return { success: false, error: "meshId required" };
41450
+ if (!workspace) return { success: false, error: "workspace required" };
41451
+ try {
41452
+ const { addNode: addNode3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41453
+ const node = addNode3(meshId, { workspace });
41454
+ if (!node) return { success: false, error: "Mesh not found" };
41455
+ return { success: true, node };
41456
+ } catch (e) {
41457
+ return { success: false, error: e.message };
41458
+ }
41459
+ }
41460
+ case "remove_mesh_node": {
41461
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
41462
+ const nodeId = typeof args?.nodeId === "string" ? args.nodeId.trim() : "";
41463
+ if (!meshId || !nodeId) return { success: false, error: "meshId and nodeId required" };
41464
+ try {
41465
+ const { removeNode: removeNode3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41466
+ const removed = removeNode3(meshId, nodeId);
41467
+ return { success: true, removed };
41468
+ } catch (e) {
41469
+ return { success: false, error: e.message };
41470
+ }
41471
+ }
41472
+ // ─── Mesh Coordinator Launch ───
41473
+ case "launch_mesh_coordinator": {
41474
+ const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
41475
+ const cliType = typeof args?.cliType === "string" ? args.cliType.trim() : "claude-cli";
41476
+ if (!meshId) return { success: false, error: "meshId required" };
41477
+ try {
41478
+ const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41479
+ const { buildCoordinatorSystemPrompt: buildCoordinatorSystemPrompt2 } = await Promise.resolve().then(() => (init_coordinator_prompt(), coordinator_prompt_exports));
41480
+ const mesh = getMesh3(meshId);
41481
+ if (!mesh) return { success: false, error: "Mesh not found" };
41482
+ if (mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
41483
+ const workspace = mesh.nodes[0].workspace;
41484
+ const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
41485
+ const coordinatorSetup = resolveMeshCoordinatorSetup({
41486
+ provider: providerMeta,
41487
+ meshId,
41488
+ workspace
41489
+ });
41490
+ if (coordinatorSetup.kind === "unsupported") {
41491
+ return {
41492
+ success: false,
41493
+ code: "mesh_coordinator_unsupported",
41494
+ error: coordinatorSetup.reason,
41495
+ meshId,
41496
+ cliType,
41497
+ workspace
41498
+ };
41499
+ }
41500
+ if (coordinatorSetup.kind === "manual") {
41501
+ return {
41502
+ success: false,
41503
+ code: "mesh_coordinator_manual_mcp_setup_required",
41504
+ error: coordinatorSetup.instructions,
41505
+ meshId,
41506
+ cliType,
41507
+ workspace,
41508
+ meshCoordinatorSetup: coordinatorSetup
41509
+ };
41510
+ }
41511
+ if (coordinatorSetup.configFormat !== "claude_mcp_json") {
41512
+ return {
41513
+ success: false,
41514
+ code: "mesh_coordinator_unsupported",
41515
+ error: `Unsupported auto-import MCP config format: ${String(coordinatorSetup.configFormat)}`,
41516
+ meshId,
41517
+ cliType,
41518
+ workspace
41519
+ };
41520
+ }
41521
+ const { existsSync: existsSync28, readFileSync: readFileSync21, writeFileSync: writeFileSync15, copyFileSync: copyFileSync4 } = await import("fs");
41522
+ const mcpConfigPath = coordinatorSetup.configPath;
41523
+ const hadExistingMcpConfig = existsSync28(mcpConfigPath);
41524
+ let existingMcpConfig = {};
41525
+ if (hadExistingMcpConfig) {
41526
+ try {
41527
+ existingMcpConfig = JSON.parse(readFileSync21(mcpConfigPath, "utf-8"));
41528
+ copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
41529
+ } catch {
41530
+ }
41531
+ }
41532
+ const mcpConfig = {
41533
+ ...existingMcpConfig,
41534
+ mcpServers: {
41535
+ ...existingMcpConfig.mcpServers || {},
41536
+ [coordinatorSetup.serverName]: {
41537
+ command: "adhdev-mcp",
41538
+ args: ["--repo-mesh", meshId]
41539
+ }
41540
+ }
41541
+ };
41542
+ writeFileSync15(mcpConfigPath, JSON.stringify(mcpConfig, null, 2), "utf-8");
41543
+ LOG.info("MeshCoordinator", `Wrote ${mcpConfigPath} with ${coordinatorSetup.serverName} server`);
41544
+ let systemPrompt = "";
41545
+ try {
41546
+ systemPrompt = buildCoordinatorSystemPrompt2({ mesh });
41547
+ } catch {
41548
+ 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).`;
41549
+ }
41550
+ const launchResult = await this.deps.cliManager.handleCliCommand("launch_cli", {
41551
+ cliType,
41552
+ dir: workspace,
41553
+ initialPrompt: systemPrompt
41554
+ });
41555
+ if (!launchResult?.success) {
41556
+ return { success: false, error: launchResult?.error || "Failed to launch CLI session" };
41557
+ }
41558
+ LOG.info("MeshCoordinator", `Launched ${cliType} coordinator for mesh ${meshId} in ${workspace}`);
41559
+ return {
41560
+ success: true,
41561
+ meshId,
41562
+ cliType,
41563
+ workspace,
41564
+ sessionId: launchResult.sessionId || launchResult.id,
41565
+ mcpConfigWritten: true
41566
+ };
41567
+ } catch (e) {
41568
+ LOG.error("MeshCoordinator", `Failed: ${e.message}`);
41569
+ return { success: false, error: e.message };
41570
+ }
41571
+ }
41254
41572
  default:
41255
41573
  break;
41256
41574
  }
@@ -64418,7 +64736,7 @@ var require_buffer_list = __commonJS({
64418
64736
  }
64419
64737
  }, {
64420
64738
  key: "join",
64421
- value: function join35(s) {
64739
+ value: function join36(s) {
64422
64740
  if (this.length === 0) return "";
64423
64741
  var p = this.head;
64424
64742
  var ret = "" + p.data;
@@ -80284,9 +80602,9 @@ function resolvePackageVersion(options) {
80284
80602
  const injectedVersion = options?.injectedVersion || "unknown";
80285
80603
  const dir = options?.dirname || __dirname;
80286
80604
  const possiblePaths = [
80287
- (0, import_path4.join)(dir, "..", "..", "package.json"),
80288
- (0, import_path4.join)(dir, "..", "package.json"),
80289
- (0, import_path4.join)(dir, "package.json")
80605
+ (0, import_path5.join)(dir, "..", "..", "package.json"),
80606
+ (0, import_path5.join)(dir, "..", "package.json"),
80607
+ (0, import_path5.join)(dir, "package.json")
80290
80608
  ];
80291
80609
  for (const p of possiblePaths) {
80292
80610
  try {
@@ -80297,12 +80615,12 @@ function resolvePackageVersion(options) {
80297
80615
  }
80298
80616
  return injectedVersion;
80299
80617
  }
80300
- var import_fs8, import_path4;
80618
+ var import_fs8, import_path5;
80301
80619
  var init_version = __esm({
80302
80620
  "src/version.ts"() {
80303
80621
  "use strict";
80304
80622
  import_fs8 = require("fs");
80305
- import_path4 = require("path");
80623
+ import_path5 = require("path");
80306
80624
  }
80307
80625
  });
80308
80626
 
@@ -89739,7 +90057,7 @@ var init_adhdev_daemon = __esm({
89739
90057
  init_version();
89740
90058
  init_src();
89741
90059
  init_runtime_defaults();
89742
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.67" });
90060
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.69" });
89743
90061
  AdhdevDaemon = class _AdhdevDaemon {
89744
90062
  localHttpServer = null;
89745
90063
  localWss = null;