hungry-ghost-hive 0.45.0 → 0.46.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.
Files changed (113) hide show
  1. package/dist/cli/commands/cluster.d.ts.map +1 -1
  2. package/dist/cli/commands/cluster.js +348 -1
  3. package/dist/cli/commands/cluster.js.map +1 -1
  4. package/dist/cli/commands/cluster.test.js +313 -9
  5. package/dist/cli/commands/cluster.test.js.map +1 -1
  6. package/dist/cli/commands/req-spawn.test.d.ts +2 -0
  7. package/dist/cli/commands/req-spawn.test.d.ts.map +1 -0
  8. package/dist/cli/commands/req-spawn.test.js +116 -0
  9. package/dist/cli/commands/req-spawn.test.js.map +1 -0
  10. package/dist/cli/commands/req.d.ts.map +1 -1
  11. package/dist/cli/commands/req.js +21 -13
  12. package/dist/cli/commands/req.js.map +1 -1
  13. package/dist/cluster/cluster-http-server.d.ts +32 -0
  14. package/dist/cluster/cluster-http-server.d.ts.map +1 -1
  15. package/dist/cluster/cluster-http-server.js +42 -0
  16. package/dist/cluster/cluster-http-server.js.map +1 -1
  17. package/dist/cluster/distributed-runtime-coverage.test.js +9 -0
  18. package/dist/cluster/distributed-runtime-coverage.test.js.map +1 -1
  19. package/dist/cluster/distributed-system.test.js +135 -0
  20. package/dist/cluster/distributed-system.test.js.map +1 -1
  21. package/dist/cluster/events.d.ts +23 -0
  22. package/dist/cluster/events.d.ts.map +1 -1
  23. package/dist/cluster/events.js +74 -0
  24. package/dist/cluster/events.js.map +1 -1
  25. package/dist/cluster/heartbeat-manager.d.ts +2 -0
  26. package/dist/cluster/heartbeat-manager.d.ts.map +1 -1
  27. package/dist/cluster/heartbeat-manager.js +42 -6
  28. package/dist/cluster/heartbeat-manager.js.map +1 -1
  29. package/dist/cluster/membership.test.d.ts +2 -0
  30. package/dist/cluster/membership.test.d.ts.map +1 -0
  31. package/dist/cluster/membership.test.js +416 -0
  32. package/dist/cluster/membership.test.js.map +1 -0
  33. package/dist/cluster/partition-safety.test.d.ts +2 -0
  34. package/dist/cluster/partition-safety.test.d.ts.map +1 -0
  35. package/dist/cluster/partition-safety.test.js +440 -0
  36. package/dist/cluster/partition-safety.test.js.map +1 -0
  37. package/dist/cluster/raft-state-machine.d.ts +33 -1
  38. package/dist/cluster/raft-state-machine.d.ts.map +1 -1
  39. package/dist/cluster/raft-state-machine.js +65 -3
  40. package/dist/cluster/raft-state-machine.js.map +1 -1
  41. package/dist/cluster/raft-store.d.ts +26 -1
  42. package/dist/cluster/raft-store.d.ts.map +1 -1
  43. package/dist/cluster/raft-store.js +137 -0
  44. package/dist/cluster/raft-store.js.map +1 -1
  45. package/dist/cluster/replication-lag.test.d.ts +2 -0
  46. package/dist/cluster/replication-lag.test.d.ts.map +1 -0
  47. package/dist/cluster/replication-lag.test.js +239 -0
  48. package/dist/cluster/replication-lag.test.js.map +1 -0
  49. package/dist/cluster/replication.d.ts +2 -2
  50. package/dist/cluster/replication.d.ts.map +1 -1
  51. package/dist/cluster/replication.js +1 -1
  52. package/dist/cluster/replication.js.map +1 -1
  53. package/dist/cluster/runtime.d.ts +78 -0
  54. package/dist/cluster/runtime.d.ts.map +1 -1
  55. package/dist/cluster/runtime.js +400 -13
  56. package/dist/cluster/runtime.js.map +1 -1
  57. package/dist/cluster/state-recovery.test.d.ts +2 -0
  58. package/dist/cluster/state-recovery.test.d.ts.map +1 -0
  59. package/dist/cluster/state-recovery.test.js +310 -0
  60. package/dist/cluster/state-recovery.test.js.map +1 -0
  61. package/dist/cluster/types.d.ts +30 -0
  62. package/dist/cluster/types.d.ts.map +1 -1
  63. package/dist/config/schema.d.ts +48 -0
  64. package/dist/config/schema.d.ts.map +1 -1
  65. package/dist/config/schema.js +11 -0
  66. package/dist/config/schema.js.map +1 -1
  67. package/dist/context-files/generator.js +1 -1
  68. package/dist/context-files/generator.js.map +1 -1
  69. package/dist/context-files/generator.test.js +51 -0
  70. package/dist/context-files/generator.test.js.map +1 -1
  71. package/dist/orchestrator/orphan-recovery.d.ts +1 -1
  72. package/dist/orchestrator/orphan-recovery.d.ts.map +1 -1
  73. package/dist/orchestrator/orphan-recovery.js +4 -4
  74. package/dist/orchestrator/orphan-recovery.js.map +1 -1
  75. package/dist/orchestrator/prompt-templates.d.ts +3 -1
  76. package/dist/orchestrator/prompt-templates.d.ts.map +1 -1
  77. package/dist/orchestrator/prompt-templates.js +45 -8
  78. package/dist/orchestrator/prompt-templates.js.map +1 -1
  79. package/dist/orchestrator/prompt-templates.test.js +210 -0
  80. package/dist/orchestrator/prompt-templates.test.js.map +1 -1
  81. package/dist/orchestrator/scheduler.d.ts +1 -0
  82. package/dist/orchestrator/scheduler.d.ts.map +1 -1
  83. package/dist/orchestrator/scheduler.js +15 -10
  84. package/dist/orchestrator/scheduler.js.map +1 -1
  85. package/dist/orchestrator/scheduler.test.js +97 -6
  86. package/dist/orchestrator/scheduler.test.js.map +1 -1
  87. package/package.json +1 -1
  88. package/src/cli/commands/cluster.test.ts +387 -9
  89. package/src/cli/commands/cluster.ts +486 -1
  90. package/src/cli/commands/req-spawn.test.ts +153 -0
  91. package/src/cli/commands/req.ts +31 -18
  92. package/src/cluster/cluster-http-server.ts +80 -0
  93. package/src/cluster/distributed-runtime-coverage.test.ts +9 -0
  94. package/src/cluster/distributed-system.test.ts +168 -0
  95. package/src/cluster/events.ts +90 -0
  96. package/src/cluster/heartbeat-manager.ts +48 -6
  97. package/src/cluster/membership.test.ts +498 -0
  98. package/src/cluster/partition-safety.test.ts +523 -0
  99. package/src/cluster/raft-state-machine.ts +76 -4
  100. package/src/cluster/raft-store.ts +167 -1
  101. package/src/cluster/replication-lag.test.ts +284 -0
  102. package/src/cluster/replication.ts +6 -0
  103. package/src/cluster/runtime.ts +551 -12
  104. package/src/cluster/state-recovery.test.ts +420 -0
  105. package/src/cluster/types.ts +32 -0
  106. package/src/config/schema.ts +11 -0
  107. package/src/context-files/generator.test.ts +55 -0
  108. package/src/context-files/generator.ts +5 -5
  109. package/src/orchestrator/orphan-recovery.ts +32 -13
  110. package/src/orchestrator/prompt-templates.test.ts +263 -0
  111. package/src/orchestrator/prompt-templates.ts +49 -8
  112. package/src/orchestrator/scheduler.test.ts +129 -6
  113. package/src/orchestrator/scheduler.ts +46 -20
@@ -48,6 +48,7 @@ import {
48
48
  } from '../tmux/manager.js';
49
49
  import { getTechLeadSessionName } from '../utils/instance.js';
50
50
  import * as logger from '../utils/logger.js';
51
+ import { getHivePaths } from '../utils/paths.js';
51
52
  import { selectAgentWithLeastWorkload } from './agent-selector.js';
52
53
  import { getCapacityPoints, selectStoriesForCapacity } from './capacity-planner.js';
53
54
  import { areDependenciesSatisfied, topologicalSort } from './dependency-resolver.js';
@@ -106,6 +107,10 @@ export class Scheduler {
106
107
  this.pmQueue = new PMOperationQueue();
107
108
  }
108
109
 
110
+ private get storiesDir(): string {
111
+ return getHivePaths(this.config.rootDir).storiesDir;
112
+ }
113
+
109
114
  /**
110
115
  * Wait for all pending Jira operations to complete.
111
116
  * Call this before closing the database to prevent "Database closed" errors.
@@ -396,10 +401,15 @@ export class Scheduler {
396
401
  await withTransaction(
397
402
  this.db,
398
403
  () => {
399
- updateStory(this.db, story.id, {
400
- assignedAgentId: targetAgent.id,
401
- status: 'in_progress',
402
- });
404
+ updateStory(
405
+ this.db,
406
+ story.id,
407
+ {
408
+ assignedAgentId: targetAgent.id,
409
+ status: 'in_progress',
410
+ },
411
+ this.storiesDir
412
+ );
403
413
 
404
414
  updateAgent(this.db, targetAgent.id, {
405
415
  status: 'working',
@@ -551,10 +561,15 @@ export class Scheduler {
551
561
 
552
562
  if (subtask) {
553
563
  // Persist subtask reference back to the story
554
- updateStory(this.db, freshStory.id, {
555
- externalSubtaskKey: subtask.key,
556
- externalSubtaskId: subtask.id,
557
- });
564
+ updateStory(
565
+ this.db,
566
+ freshStory.id,
567
+ {
568
+ externalSubtaskKey: subtask.key,
569
+ externalSubtaskId: subtask.id,
570
+ },
571
+ this.storiesDir
572
+ );
558
573
  if (this.saveFn) this.saveFn();
559
574
 
560
575
  logger.info(`Created subtask ${subtask.key} for story ${freshStory.id}`);
@@ -711,10 +726,15 @@ export class Scheduler {
711
726
 
712
727
  // If agent was working on a story, mark it for reassignment
713
728
  if (agent.current_story_id) {
714
- updateStory(this.db, agent.current_story_id, {
715
- status: 'planned',
716
- assignedAgentId: null,
717
- });
729
+ updateStory(
730
+ this.db,
731
+ agent.current_story_id,
732
+ {
733
+ status: 'planned',
734
+ assignedAgentId: null,
735
+ },
736
+ this.storiesDir
737
+ );
718
738
  revived.push(agent.current_story_id);
719
739
 
720
740
  // Sync status change to Jira (fire and forget)
@@ -724,7 +744,11 @@ export class Scheduler {
724
744
  }
725
745
 
726
746
  // Detect and recover orphaned stories (assigned to terminated agents)
727
- const orphanedRecovered = detectAndRecoverOrphanedStories(this.db, this.config.rootDir);
747
+ const orphanedRecovered = detectAndRecoverOrphanedStories(
748
+ this.db,
749
+ this.config.rootDir,
750
+ this.storiesDir
751
+ );
728
752
 
729
753
  return { terminated, revived, orphanedRecovered };
730
754
  }
@@ -1008,6 +1032,8 @@ export class Scheduler {
1008
1032
  const includeProgressUpdates = this.shouldIncludeProgressUpdates();
1009
1033
  const hiveDir = join(this.config.rootDir, '.hive');
1010
1034
  const techLeadSession = getTechLeadSessionName(hiveDir);
1035
+ const chromeEnabled =
1036
+ this.config.hiveConfig?.agents?.chrome_enabled === true && cliTool === 'claude';
1011
1037
  let prompt: string;
1012
1038
 
1013
1039
  if (type === 'senior') {
@@ -1018,7 +1044,7 @@ export class Scheduler {
1018
1044
  worktreePath,
1019
1045
  stories,
1020
1046
  targetBranch,
1021
- { includeProgressUpdates, techLeadSession },
1047
+ { includeProgressUpdates, techLeadSession, chromeEnabled },
1022
1048
  sessionName
1023
1049
  );
1024
1050
  } else if (type === 'intermediate') {
@@ -1028,7 +1054,7 @@ export class Scheduler {
1028
1054
  worktreePath,
1029
1055
  sessionName,
1030
1056
  targetBranch,
1031
- { includeProgressUpdates, techLeadSession }
1057
+ { includeProgressUpdates, techLeadSession, chromeEnabled }
1032
1058
  );
1033
1059
  } else if (type === 'junior') {
1034
1060
  prompt = generateJuniorPrompt(
@@ -1037,7 +1063,7 @@ export class Scheduler {
1037
1063
  worktreePath,
1038
1064
  sessionName,
1039
1065
  targetBranch,
1040
- { includeProgressUpdates, techLeadSession }
1066
+ { includeProgressUpdates, techLeadSession, chromeEnabled }
1041
1067
  );
1042
1068
  } else if (type === 'feature_test' && featureTestContext) {
1043
1069
  prompt = generateFeatureTestPrompt(
@@ -1048,11 +1074,12 @@ export class Scheduler {
1048
1074
  featureTestContext.featureBranch,
1049
1075
  featureTestContext.requirementId,
1050
1076
  featureTestContext.e2eTestsPath,
1051
- { includeProgressUpdates, techLeadSession }
1077
+ { includeProgressUpdates, techLeadSession, chromeEnabled }
1052
1078
  );
1053
1079
  } else if (type === 'auditor') {
1054
1080
  prompt = generateAuditorPrompt(sessionName, worktreePath, team?.repo_url || '', {
1055
1081
  techLeadSession,
1082
+ chromeEnabled,
1056
1083
  });
1057
1084
  } else {
1058
1085
  prompt = generateQAPrompt(
@@ -1060,13 +1087,12 @@ export class Scheduler {
1060
1087
  team?.repo_url || '',
1061
1088
  worktreePath,
1062
1089
  sessionName,
1063
- targetBranch
1090
+ targetBranch,
1091
+ { chromeEnabled }
1064
1092
  );
1065
1093
  }
1066
1094
 
1067
1095
  // Build CLI command using the configured runtime
1068
- const chromeEnabled =
1069
- this.config.hiveConfig?.agents?.chrome_enabled === true && cliTool === 'claude';
1070
1096
  const commandArgs = getCliRuntimeBuilder(cliTool).buildSpawnCommand(
1071
1097
  runtimeModel,
1072
1098
  safetyMode,