Skip to content

Commit eaa3f09

Browse files
Copilotclduab11
andcommitted
Improve type safety and documentation in helper functions
- Add ExecutionResultData interface for type safety - Add comprehensive JSDoc comments with @param and @returns tags - Remove unused checkMcpProfile function - Update function signatures to use proper types instead of any Co-authored-by: clduab11 <185000089+clduab11@users.noreply.github.com>
1 parent a18598d commit eaa3f09

2 files changed

Lines changed: 56 additions & 28 deletions

File tree

src/cli/doctor-helpers.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -79,32 +79,6 @@ export function checkCodexAuth(): HealthCheck {
7979
};
8080
}
8181

82-
/**
83-
* Check MCP profile health
84-
* Note: This function is not used in the refactored code as the doctor command
85-
* handles MCP checks directly using serviceManager from env/service-manager.ts
86-
*/
87-
export async function checkMcpProfile(
88-
profileName: string
89-
): Promise<HealthCheck> {
90-
try {
91-
// This function is kept for potential future use but not currently called
92-
return {
93-
id: `mcp.${profileName}`,
94-
ok: false,
95-
details: `Profile checking not implemented in this helper`,
96-
remediation: `Use serviceManager.status(${profileName}) directly`
97-
};
98-
} catch (error) {
99-
return {
100-
id: `mcp.${profileName}`,
101-
ok: false,
102-
details: `Error checking profile ${profileName}: ${error instanceof Error ? error.message : String(error)}`,
103-
remediation: `Verify profile ${profileName} exists and is configured correctly.`
104-
};
105-
}
106-
}
107-
10882
/**
10983
* Render health check results
11084
*/

src/cli/hive-mind-helpers.ts

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,43 @@ import type {
99
CodexContext
1010
} from '../types/codex-context.js';
1111

12+
/**
13+
* Execution result data structure
14+
*/
15+
export interface ExecutionResultData {
16+
executionId: string;
17+
status: string;
18+
duration: number;
19+
originalPrompt: string;
20+
summary?: string;
21+
artifacts: Record<string, any>;
22+
stages: any[];
23+
agentCount: number;
24+
taskCount: number;
25+
meshStatus: {
26+
nodeCount: number;
27+
connectionCount: number;
28+
};
29+
consensusStatus: {
30+
performed: boolean;
31+
proposalId?: string;
32+
accepted?: boolean;
33+
votes?: any;
34+
timedOut?: boolean;
35+
error?: string;
36+
};
37+
swarmStatus: {
38+
algorithm: string;
39+
isOptimizing: boolean;
40+
};
41+
totPlan?: any;
42+
codexContext: {
43+
enabled: boolean;
44+
contextHash?: string;
45+
sizeBytes?: number;
46+
};
47+
}
48+
1249
/**
1350
* Execute GOAP workflow
1451
*/
@@ -49,6 +86,14 @@ export async function executeGoapWorkflow(
4986

5087
/**
5188
* Execute task with timeout and consensus
89+
* @param system - The Codex Synaptic system instance
90+
* @param prompt - The task prompt to execute
91+
* @param originalPrompt - The original user prompt before enrichment
92+
* @param config - The hive-mind configuration
93+
* @param startTime - The execution start timestamp
94+
* @param shouldRequireConsensus - Function to check if consensus is needed
95+
* @param orchestrateConsensus - Function to orchestrate consensus voting
96+
* @returns Object containing outcome, consensusResult, and totalTime
5297
*/
5398
export async function executeTaskWithConsensus(
5499
system: CodexSynapticSystem,
@@ -90,6 +135,13 @@ export async function executeTaskWithConsensus(
90135

91136
/**
92137
* Collect and format execution results
138+
* @param outcome - The task execution outcome
139+
* @param consensusResult - The consensus voting result
140+
* @param totalTime - Total execution time in milliseconds
141+
* @param originalPrompt - The original user prompt
142+
* @param system - The Codex Synaptic system instance
143+
* @param codexContext - Optional Codex context if enabled
144+
* @returns Structured execution result data
93145
*/
94146
export function collectExecutionResults(
95147
outcome: any,
@@ -98,7 +150,7 @@ export function collectExecutionResults(
98150
originalPrompt: string,
99151
system: CodexSynapticSystem,
100152
codexContext?: CodexContext
101-
): any {
153+
): ExecutionResultData {
102154
const swarmStatus = system.getSwarmCoordinator().getStatus();
103155
const meshStatus = system.getNeuralMesh().getStatus();
104156
const agentRegistry = system.getAgentRegistry().getStatus();
@@ -143,9 +195,11 @@ export function collectExecutionResults(
143195

144196
/**
145197
* Render execution summary
198+
* @param resultData - Structured execution result data
199+
* @param options - Rendering options (yaml and debug flags)
146200
*/
147201
export async function renderExecutionSummary(
148-
resultData: any,
202+
resultData: ExecutionResultData,
149203
options: { yaml?: boolean; debug?: boolean }
150204
): Promise<void> {
151205
console.log(chalk.green(`\n🎉 Hive-mind execution completed in ${resultData.duration}ms`));

0 commit comments

Comments
 (0)