maskweaver 0.9.4 → 0.9.6
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/README.ko.md +638 -592
- package/README.md +671 -667
- package/dist/cli/doctor.js +5 -21
- package/dist/cli/install.d.ts +0 -8
- package/dist/cli/install.js +0 -39
- package/dist/context/config.d.ts +0 -22
- package/dist/context/config.js +0 -28
- package/dist/context/feature.d.ts +0 -39
- package/dist/context/feature.js +0 -77
- package/dist/context/files.d.ts +0 -13
- package/dist/context/files.js +1 -24
- package/dist/context/index.d.ts +0 -7
- package/dist/context/index.js +0 -12
- package/dist/context/project.d.ts +0 -21
- package/dist/context/project.js +0 -30
- package/dist/context/types.d.ts +0 -48
- package/dist/context/types.js +0 -12
- package/dist/context/utils.d.ts +0 -18
- package/dist/context/utils.js +0 -27
- package/dist/core/engine/promptBuilder.d.ts +0 -17
- package/dist/core/engine/promptBuilder.js +0 -28
- package/dist/core/index.d.ts +0 -6
- package/dist/core/index.js +0 -9
- package/dist/core/loader/MaskLoader.d.ts +0 -23
- package/dist/core/loader/MaskLoader.js +0 -29
- package/dist/core/schema/types.d.ts +0 -47
- package/dist/core/schema/types.js +0 -6
- package/dist/core/schema/validator.d.ts +0 -14
- package/dist/core/schema/validator.js +0 -18
- package/dist/i18n/index.d.ts +0 -18
- package/dist/i18n/index.js +4 -23
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/lib.d.ts +0 -5
- package/dist/lib.js +0 -12
- package/dist/memory/chunking.d.ts +0 -22
- package/dist/memory/chunking.js +2 -37
- package/dist/memory/core.d.ts +0 -29
- package/dist/memory/core.js +1 -52
- package/dist/memory/index.d.ts +0 -5
- package/dist/memory/index.js +0 -10
- package/dist/memory/indexer.d.ts +0 -21
- package/dist/memory/indexer.js +0 -44
- package/dist/memory/providers/examples.d.ts +0 -5
- package/dist/memory/providers/examples.js +4 -64
- package/dist/memory/providers/factory.d.ts +0 -44
- package/dist/memory/providers/factory.js +0 -46
- package/dist/memory/providers/index.d.ts +0 -26
- package/dist/memory/providers/index.js +0 -28
- package/dist/memory/providers/ollama.d.ts +0 -6
- package/dist/memory/providers/ollama.js +1 -8
- package/dist/memory/providers/openai.d.ts +0 -6
- package/dist/memory/providers/openai.js +1 -8
- package/dist/memory/providers/openrouter.d.ts +0 -6
- package/dist/memory/providers/openrouter.js +0 -8
- package/dist/memory/providers/text-only.d.ts +0 -13
- package/dist/memory/providers/text-only.js +0 -17
- package/dist/memory/providers/types.d.ts +0 -39
- package/dist/memory/providers/types.js +0 -7
- package/dist/memory/providers/voyage.d.ts +0 -22
- package/dist/memory/providers/voyage.js +1 -24
- package/dist/memory/search/hybrid.d.ts +0 -12
- package/dist/memory/search/hybrid.js +1 -22
- package/dist/memory/store/sqlite.d.ts +0 -72
- package/dist/memory/store/sqlite.js +4 -127
- package/dist/plugin/config/index.d.ts +0 -112
- package/dist/plugin/config/index.js +0 -115
- package/dist/plugin/index.d.ts +0 -13
- package/dist/plugin/index.js +1 -123
- package/dist/plugin/tools/command-registry.d.ts +0 -6
- package/dist/plugin/tools/command-registry.js +0 -14
- package/dist/plugin/tools/context.d.ts +0 -12
- package/dist/plugin/tools/context.js +0 -58
- package/dist/plugin/tools/maskSave.d.ts +0 -3
- package/dist/plugin/tools/maskSave.js +0 -3
- package/dist/plugin/tools/memoryGet.d.ts +0 -3
- package/dist/plugin/tools/memoryGet.js +0 -3
- package/dist/plugin/tools/memoryIndexer.d.ts +0 -3
- package/dist/plugin/tools/memoryIndexer.js +0 -10
- package/dist/plugin/tools/memorySearch.d.ts +0 -31
- package/dist/plugin/tools/memorySearch.js +0 -79
- package/dist/plugin/tools/memoryWrite.d.ts +0 -8
- package/dist/plugin/tools/memoryWrite.js +0 -32
- package/dist/plugin/tools/retrospect.d.ts +0 -3
- package/dist/plugin/tools/retrospect.js +0 -3
- package/dist/plugin/tools/slashcommand.d.ts +0 -11
- package/dist/plugin/tools/slashcommand.js +0 -38
- package/dist/plugin/tools/squad.d.ts +0 -12
- package/dist/plugin/tools/squad.js +11 -83
- package/dist/plugin/tools/weave.d.ts +0 -6
- package/dist/plugin/tools/weave.js +0 -78
- package/dist/plugin/types.d.ts +0 -20
- package/dist/plugin/types.js +0 -7
- package/dist/retrospect/index.d.ts +0 -7
- package/dist/retrospect/index.js +0 -9
- package/dist/retrospect/mask-save.d.ts +0 -12
- package/dist/retrospect/mask-save.js +1 -80
- package/dist/retrospect/retrospect.d.ts +0 -18
- package/dist/retrospect/retrospect.js +0 -63
- package/dist/retrospect/strategies/base.d.ts +0 -15
- package/dist/retrospect/strategies/base.js +0 -7
- package/dist/retrospect/strategies/deep.d.ts +0 -12
- package/dist/retrospect/strategies/deep.js +0 -24
- package/dist/retrospect/strategies/index.d.ts +0 -12
- package/dist/retrospect/strategies/index.js +0 -12
- package/dist/retrospect/strategies/quick.d.ts +0 -12
- package/dist/retrospect/strategies/quick.js +0 -19
- package/dist/retrospect/strategies/standard.d.ts +0 -12
- package/dist/retrospect/strategies/standard.js +0 -15
- package/dist/retrospect/types.d.ts +0 -7
- package/dist/retrospect/types.js +0 -7
- package/dist/shared/config.d.ts +0 -105
- package/dist/shared/config.js +0 -33
- package/dist/shared/errors.d.ts +0 -18
- package/dist/shared/errors.js +0 -19
- package/dist/shared/generate-agents.d.ts +0 -69
- package/dist/shared/generate-agents.js +2 -86
- package/dist/shared/image.d.ts +0 -67
- package/dist/shared/image.js +6 -104
- package/dist/shared/index.d.ts +0 -5
- package/dist/shared/index.js +0 -7
- package/dist/shared/model-registry.d.ts +0 -72
- package/dist/shared/model-registry.js +5 -95
- package/dist/shared/types.d.ts +0 -15
- package/dist/shared/types.js +0 -3
- package/dist/shared-context/dag.d.ts +0 -105
- package/dist/shared-context/dag.js +3 -114
- package/dist/shared-context/index.d.ts +0 -5
- package/dist/shared-context/index.js +0 -15
- package/dist/shared-context/logger.d.ts +0 -37
- package/dist/shared-context/logger.js +0 -41
- package/dist/shared-context/parallel-executor.d.ts +0 -54
- package/dist/shared-context/parallel-executor.js +4 -56
- package/dist/shared-context/session.d.ts +0 -56
- package/dist/shared-context/session.js +0 -47
- package/dist/shared-context/squad.d.ts +0 -68
- package/dist/shared-context/squad.js +0 -63
- package/dist/shared-context/storage.d.ts +0 -132
- package/dist/shared-context/storage.js +0 -116
- package/dist/shared-context/task.d.ts +0 -120
- package/dist/shared-context/task.js +0 -152
- package/dist/shared-context/test/dag.test.js +9 -14
- package/dist/shared-context/test/logger.test.d.ts +0 -8
- package/dist/shared-context/test/logger.test.js +0 -52
- package/dist/shared-context/test/session.test.d.ts +0 -7
- package/dist/shared-context/test/session.test.js +0 -63
- package/dist/shared-context/test/squad.test.d.ts +0 -10
- package/dist/shared-context/test/squad.test.js +2 -68
- package/dist/shared-context/test/storage.test.d.ts +0 -8
- package/dist/shared-context/test/storage.test.js +0 -68
- package/dist/shared-context/test/task.test.d.ts +0 -7
- package/dist/shared-context/test/task.test.js +0 -54
- package/dist/shared-context/test/watchdog.test.d.ts +0 -7
- package/dist/shared-context/test/watchdog.test.js +3 -58
- package/dist/shared-context/types.d.ts +0 -215
- package/dist/shared-context/types.js +0 -125
- package/dist/shared-context/watchdog.d.ts +0 -127
- package/dist/shared-context/watchdog.js +0 -148
- package/dist/shared-context/worktree.d.ts +0 -68
- package/dist/shared-context/worktree.js +2 -34
- package/dist/verify/budget.d.ts +0 -29
- package/dist/verify/budget.js +0 -34
- package/dist/verify/critical-files.d.ts +0 -17
- package/dist/verify/critical-files.js +0 -37
- package/dist/verify/escalation.d.ts +0 -20
- package/dist/verify/escalation.js +0 -22
- package/dist/verify/index.d.ts +0 -5
- package/dist/verify/index.js +0 -11
- package/dist/verify/prompts.d.ts +0 -20
- package/dist/verify/prompts.js +0 -20
- package/dist/verify/types.d.ts +0 -26
- package/dist/verify/types.js +1 -12
- package/dist/verify/verifier.d.ts +0 -29
- package/dist/verify/verifier.js +0 -54
- package/dist/version.d.ts +1 -16
- package/dist/version.js +1 -16
- package/dist/weave/bridge.d.ts +0 -35
- package/dist/weave/bridge.js +0 -51
- package/dist/weave/environment/detector.d.ts +0 -6
- package/dist/weave/environment/detector.js +4 -45
- package/dist/weave/environment/index.d.ts +0 -19
- package/dist/weave/environment/index.js +1 -39
- package/dist/weave/environment/issues.d.ts +0 -35
- package/dist/weave/environment/issues.js +0 -59
- package/dist/weave/git.d.ts +0 -8
- package/dist/weave/git.js +0 -8
- package/dist/weave/index.d.ts +0 -13
- package/dist/weave/index.js +2 -28
- package/dist/weave/knowledge/global.d.ts +0 -39
- package/dist/weave/knowledge/global.js +2 -78
- package/dist/weave/loop.js +0 -3
- package/dist/weave/orchestrator.d.ts +0 -69
- package/dist/weave/orchestrator.js +1 -101
- package/dist/weave/phase-manager.d.ts +0 -64
- package/dist/weave/phase-manager.js +0 -89
- package/dist/weave/security/secret-scan.d.ts +0 -14
- package/dist/weave/security/secret-scan.js +0 -19
- package/dist/weave/stages/build.js +0 -15
- package/dist/weave/stages/execute.d.ts +0 -42
- package/dist/weave/stages/execute.js +4 -86
- package/dist/weave/stages/handoff.d.ts +0 -7
- package/dist/weave/stages/handoff.js +0 -43
- package/dist/weave/stages/index.d.ts +0 -3
- package/dist/weave/stages/index.js +0 -3
- package/dist/weave/stages/intake.d.ts +0 -8
- package/dist/weave/stages/intake.js +5 -65
- package/dist/weave/stages/map.d.ts +0 -1
- package/dist/weave/stages/openspec.d.ts +0 -1
- package/dist/weave/stages/plan.d.ts +0 -11
- package/dist/weave/stages/plan.js +1 -53
- package/dist/weave/stages/refine.d.ts +0 -7
- package/dist/weave/stages/refine.js +0 -7
- package/dist/weave/stages/research.d.ts +0 -6
- package/dist/weave/stages/research.js +0 -6
- package/dist/weave/stages/spec.d.ts +0 -12
- package/dist/weave/stages/spec.js +0 -17
- package/dist/weave/types.d.ts +0 -20
- package/dist/weave/types.js +0 -5
- package/dist/weave/verification/commands.d.ts +0 -12
- package/dist/weave/verification/commands.js +0 -19
- package/dist/weave/verification/index.d.ts +0 -6
- package/dist/weave/verification/index.js +1 -19
- package/dist/weave/verification/playwright.d.ts +0 -47
- package/dist/weave/verification/playwright.js +1 -90
- package/dist/weave/worktree.d.ts +0 -16
- package/dist/weave/worktree.js +0 -23
- package/dist/weave/yaml-repair.d.ts +0 -39
- package/dist/weave/yaml-repair.js +13 -116
- package/package.json +1 -1
|
@@ -1,41 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Event Logger
|
|
3
|
-
*
|
|
4
|
-
* Append-only event logging for squad activities.
|
|
5
|
-
* Uses JSONL format for efficient streaming and recovery.
|
|
6
|
-
*
|
|
7
|
-
* @author Kent Beck's Dummy Human
|
|
8
|
-
*/
|
|
9
1
|
import type { LogEvent, LogEventInput } from "./types.js";
|
|
10
2
|
import type { Session } from "./session.js";
|
|
11
|
-
/**
|
|
12
|
-
* Append an event to a squad's log.
|
|
13
|
-
* Automatically adds a timestamp to the event.
|
|
14
|
-
*
|
|
15
|
-
* @param session - The parent session
|
|
16
|
-
* @param squadId - ID of the squad to log to
|
|
17
|
-
* @param event - Event data (without timestamp)
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* await logEvent(session, "squad-a1b2c3d4", {
|
|
21
|
-
* type: "task_assigned",
|
|
22
|
-
* taskId: "task-001",
|
|
23
|
-
* assignee: "worker-1",
|
|
24
|
-
* description: "Implement login form"
|
|
25
|
-
* });
|
|
26
|
-
*/
|
|
27
3
|
export declare function logEvent(session: Session, squadId: string, event: LogEventInput): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Read all events from a squad's log.
|
|
30
|
-
* Returns an empty array if the log doesn't exist.
|
|
31
|
-
*
|
|
32
|
-
* @param session - The parent session
|
|
33
|
-
* @param squadId - ID of the squad to read from
|
|
34
|
-
* @returns Array of log events in chronological order
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* const events = await readLog(session, "squad-a1b2c3d4");
|
|
38
|
-
* const completedTasks = events.filter(e => e.type === "task_completed");
|
|
39
|
-
* console.log(`Completed tasks: ${completedTasks.length}`);
|
|
40
|
-
*/
|
|
41
4
|
export declare function readLog(session: Session, squadId: string): Promise<LogEvent[]>;
|
|
@@ -1,31 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Event Logger
|
|
3
|
-
*
|
|
4
|
-
* Append-only event logging for squad activities.
|
|
5
|
-
* Uses JSONL format for efficient streaming and recovery.
|
|
6
|
-
*
|
|
7
|
-
* @author Kent Beck's Dummy Human
|
|
8
|
-
*/
|
|
9
1
|
import { readFile } from "fs/promises";
|
|
10
|
-
// ============================================================================
|
|
11
|
-
// Event Logging
|
|
12
|
-
// ============================================================================
|
|
13
|
-
/**
|
|
14
|
-
* Append an event to a squad's log.
|
|
15
|
-
* Automatically adds a timestamp to the event.
|
|
16
|
-
*
|
|
17
|
-
* @param session - The parent session
|
|
18
|
-
* @param squadId - ID of the squad to log to
|
|
19
|
-
* @param event - Event data (without timestamp)
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* await logEvent(session, "squad-a1b2c3d4", {
|
|
23
|
-
* type: "task_assigned",
|
|
24
|
-
* taskId: "task-001",
|
|
25
|
-
* assignee: "worker-1",
|
|
26
|
-
* description: "Implement login form"
|
|
27
|
-
* });
|
|
28
|
-
*/
|
|
29
2
|
export async function logEvent(session, squadId, event) {
|
|
30
3
|
const logPath = `${session.sessionPath}/squads/${squadId}/log.jsonl`;
|
|
31
4
|
const fullEvent = {
|
|
@@ -34,19 +7,6 @@ export async function logEvent(session, squadId, event) {
|
|
|
34
7
|
};
|
|
35
8
|
await session.storage.append(logPath, JSON.stringify(fullEvent));
|
|
36
9
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Read all events from a squad's log.
|
|
39
|
-
* Returns an empty array if the log doesn't exist.
|
|
40
|
-
*
|
|
41
|
-
* @param session - The parent session
|
|
42
|
-
* @param squadId - ID of the squad to read from
|
|
43
|
-
* @returns Array of log events in chronological order
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* const events = await readLog(session, "squad-a1b2c3d4");
|
|
47
|
-
* const completedTasks = events.filter(e => e.type === "task_completed");
|
|
48
|
-
* console.log(`Completed tasks: ${completedTasks.length}`);
|
|
49
|
-
*/
|
|
50
10
|
export async function readLog(session, squadId) {
|
|
51
11
|
const logPath = `${session.sessionPath}/squads/${squadId}/log.jsonl`;
|
|
52
12
|
const fullPath = session.storage.getFullPath(logPath);
|
|
@@ -58,7 +18,6 @@ export async function readLog(session, squadId) {
|
|
|
58
18
|
.map((line) => JSON.parse(line));
|
|
59
19
|
}
|
|
60
20
|
catch {
|
|
61
|
-
// Log doesn't exist yet - return empty array
|
|
62
21
|
return [];
|
|
63
22
|
}
|
|
64
23
|
}
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parallel Execution Engine
|
|
3
|
-
*
|
|
4
|
-
* Executes task waves in parallel using DAG analysis and git worktrees.
|
|
5
|
-
* Each wave contains independent tasks that can run concurrently.
|
|
6
|
-
*
|
|
7
|
-
* @author Jeff Dean's Dummy Human
|
|
8
|
-
*/
|
|
9
1
|
import type { Session } from './session.js';
|
|
10
2
|
import type { ExecutionWave, DAGAnalysis } from './dag.js';
|
|
11
3
|
export interface ParallelExecutionPlan {
|
|
@@ -26,58 +18,12 @@ export interface WaveExecutionResult {
|
|
|
26
18
|
allSucceeded: boolean;
|
|
27
19
|
}
|
|
28
20
|
export interface ParallelExecutionOptions {
|
|
29
|
-
/** Maximum concurrent tasks per wave (default: LIMITS.maxWorkersPerSquad) */
|
|
30
21
|
maxConcurrency?: number;
|
|
31
|
-
/** Whether to use git worktrees for isolation (default: true) */
|
|
32
22
|
useWorktrees?: boolean;
|
|
33
|
-
/** Whether to abort remaining tasks on first failure (default: false) */
|
|
34
23
|
failFast?: boolean;
|
|
35
|
-
/** Callback when a task starts */
|
|
36
24
|
onTaskStart?: (taskId: string, worktreePath?: string) => void;
|
|
37
|
-
/** Callback when a task completes */
|
|
38
25
|
onTaskComplete?: (taskId: string, success: boolean, error?: string) => void;
|
|
39
|
-
/** Callback when a wave completes */
|
|
40
26
|
onWaveComplete?: (waveIndex: number, results: WaveExecutionResult) => void;
|
|
41
27
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Create a parallel execution plan from squad tasks.
|
|
44
|
-
* Analyzes dependencies and groups into waves.
|
|
45
|
-
* @param session - The current session object.
|
|
46
|
-
* @param squadId - The ID of the squad to create the plan for.
|
|
47
|
-
* @returns A promise that resolves to the ParallelExecutionPlan.
|
|
48
|
-
* @throws {ValidationError} If DAG analysis fails (e.g., cycle detected).
|
|
49
|
-
* @example
|
|
50
|
-
* import { createExecutionPlan } from './parallel-executor.ts';
|
|
51
|
-
* import { Session } from './types.ts';
|
|
52
|
-
* // Assume 'mockSession' and 'squad-abc' exist
|
|
53
|
-
* const plan = await createExecutionPlan(mockSession, 'squad-abc');
|
|
54
|
-
* console.log(plan.waves.length);
|
|
55
|
-
*/
|
|
56
28
|
export declare function createExecutionPlan(session: Session, squadId: string): Promise<ParallelExecutionPlan>;
|
|
57
|
-
/**
|
|
58
|
-
* Execute a single wave of tasks in parallel.
|
|
59
|
-
* - Creates worktrees for each task (if useWorktrees=true)
|
|
60
|
-
* - Dispatches tasks concurrently
|
|
61
|
-
* - Waits for all to complete
|
|
62
|
-
* - Cleans up worktrees
|
|
63
|
-
* - Returns aggregated results
|
|
64
|
-
* @param session - The current session object.
|
|
65
|
-
* @param squadId - The ID of the squad.
|
|
66
|
-
* @param wave - The ExecutionWave to execute.
|
|
67
|
-
* @param executor - A function that takes a taskId and worktreePath, and returns a promise resolving to true for success, false for failure.
|
|
68
|
-
* @param options - Optional execution options.
|
|
69
|
-
* @returns A promise that resolves to the WaveExecutionResult.
|
|
70
|
-
* @example
|
|
71
|
-
* import { executeWave } from './parallel-executor.ts';
|
|
72
|
-
* import { Session, TaskState } from './types.ts';
|
|
73
|
-
* // Assume 'mockSession', 'squad-abc', 'mockWave' exist
|
|
74
|
-
* // mockExecutor would simulate running a task
|
|
75
|
-
* const mockExecutor = async (taskId: string, worktreePath?: string) => {
|
|
76
|
-
* console.log(`Executing ${taskId} in ${worktreePath || 'main repo'}`);
|
|
77
|
-
* await new Promise(resolve => setTimeout(resolve, 1000)); // Simulate work
|
|
78
|
-
* return Math.random() > 0.1; // 90% success rate
|
|
79
|
-
* };
|
|
80
|
-
* const result = await executeWave(mockSession, 'squad-abc', mockWave, mockExecutor);
|
|
81
|
-
* console.log(result.allSucceeded);
|
|
82
|
-
*/
|
|
83
29
|
export declare function executeWave(session: Session, squadId: string, wave: ExecutionWave, executor: (taskId: string, worktreePath?: string) => Promise<boolean>, options?: ParallelExecutionOptions): Promise<WaveExecutionResult>;
|
|
@@ -1,29 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parallel Execution Engine
|
|
3
|
-
*
|
|
4
|
-
* Executes task waves in parallel using DAG analysis and git worktrees.
|
|
5
|
-
* Each wave contains independent tasks that can run concurrently.
|
|
6
|
-
*
|
|
7
|
-
* @author Jeff Dean's Dummy Human
|
|
8
|
-
*/
|
|
9
1
|
import { LIMITS } from './types.js';
|
|
10
2
|
import { buildDAG } from './dag.js';
|
|
11
3
|
import { createWorktreeManager } from './worktree.js';
|
|
12
4
|
import { getSquad, updateSquadState } from './squad.js';
|
|
13
|
-
/**
|
|
14
|
-
* Create a parallel execution plan from squad tasks.
|
|
15
|
-
* Analyzes dependencies and groups into waves.
|
|
16
|
-
* @param session - The current session object.
|
|
17
|
-
* @param squadId - The ID of the squad to create the plan for.
|
|
18
|
-
* @returns A promise that resolves to the ParallelExecutionPlan.
|
|
19
|
-
* @throws {ValidationError} If DAG analysis fails (e.g., cycle detected).
|
|
20
|
-
* @example
|
|
21
|
-
* import { createExecutionPlan } from './parallel-executor.ts';
|
|
22
|
-
* import { Session } from './types.ts';
|
|
23
|
-
* // Assume 'mockSession' and 'squad-abc' exist
|
|
24
|
-
* const plan = await createExecutionPlan(mockSession, 'squad-abc');
|
|
25
|
-
* console.log(plan.waves.length);
|
|
26
|
-
*/
|
|
27
5
|
export async function createExecutionPlan(session, squadId) {
|
|
28
6
|
const squad = await getSquad(session, squadId);
|
|
29
7
|
if (!squad) {
|
|
@@ -37,32 +15,6 @@ export async function createExecutionPlan(session, squadId) {
|
|
|
37
15
|
estimatedParallelism: dag.parallelismFactor,
|
|
38
16
|
};
|
|
39
17
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Execute a single wave of tasks in parallel.
|
|
42
|
-
* - Creates worktrees for each task (if useWorktrees=true)
|
|
43
|
-
* - Dispatches tasks concurrently
|
|
44
|
-
* - Waits for all to complete
|
|
45
|
-
* - Cleans up worktrees
|
|
46
|
-
* - Returns aggregated results
|
|
47
|
-
* @param session - The current session object.
|
|
48
|
-
* @param squadId - The ID of the squad.
|
|
49
|
-
* @param wave - The ExecutionWave to execute.
|
|
50
|
-
* @param executor - A function that takes a taskId and worktreePath, and returns a promise resolving to true for success, false for failure.
|
|
51
|
-
* @param options - Optional execution options.
|
|
52
|
-
* @returns A promise that resolves to the WaveExecutionResult.
|
|
53
|
-
* @example
|
|
54
|
-
* import { executeWave } from './parallel-executor.ts';
|
|
55
|
-
* import { Session, TaskState } from './types.ts';
|
|
56
|
-
* // Assume 'mockSession', 'squad-abc', 'mockWave' exist
|
|
57
|
-
* // mockExecutor would simulate running a task
|
|
58
|
-
* const mockExecutor = async (taskId: string, worktreePath?: string) => {
|
|
59
|
-
* console.log(`Executing ${taskId} in ${worktreePath || 'main repo'}`);
|
|
60
|
-
* await new Promise(resolve => setTimeout(resolve, 1000)); // Simulate work
|
|
61
|
-
* return Math.random() > 0.1; // 90% success rate
|
|
62
|
-
* };
|
|
63
|
-
* const result = await executeWave(mockSession, 'squad-abc', mockWave, mockExecutor);
|
|
64
|
-
* console.log(result.allSucceeded);
|
|
65
|
-
*/
|
|
66
18
|
export async function executeWave(session, squadId, wave, executor, options) {
|
|
67
19
|
const { maxConcurrency = LIMITS.maxWorkersPerSquad, useWorktrees = true, failFast = false, onTaskStart, onTaskComplete, onWaveComplete, } = options || {};
|
|
68
20
|
const squad = await getSquad(session, squadId);
|
|
@@ -70,7 +22,7 @@ export async function executeWave(session, squadId, wave, executor, options) {
|
|
|
70
22
|
throw new Error(`Squad with ID ${squadId} not found.`);
|
|
71
23
|
}
|
|
72
24
|
const worktreeManager = useWorktrees
|
|
73
|
-
? createWorktreeManager({ repoRoot: session.sessionPath })
|
|
25
|
+
? createWorktreeManager({ repoRoot: session.sessionPath })
|
|
74
26
|
: undefined;
|
|
75
27
|
const waveResults = [];
|
|
76
28
|
let allSucceeded = true;
|
|
@@ -113,21 +65,19 @@ export async function executeWave(session, squadId, wave, executor, options) {
|
|
|
113
65
|
}
|
|
114
66
|
finally {
|
|
115
67
|
const endTime = process.hrtime.bigint();
|
|
116
|
-
const duration = Number(endTime - startTime) / 1_000_000;
|
|
68
|
+
const duration = Number(endTime - startTime) / 1_000_000;
|
|
117
69
|
waveResults.push({ taskId, success, worktreePath, duration, error });
|
|
118
70
|
if (!success) {
|
|
119
71
|
allSucceeded = false;
|
|
120
72
|
}
|
|
121
73
|
onTaskComplete?.(taskId, success, error);
|
|
122
|
-
// Update task status in squad
|
|
123
74
|
const taskIndex = squad.state.tasks.findIndex(t => t.taskId === taskId);
|
|
124
75
|
if (taskIndex !== -1) {
|
|
125
76
|
squad.state.tasks[taskIndex].status = success ? 'completed' : 'failed';
|
|
126
77
|
squad.state.tasks[taskIndex].completedAt = new Date().toISOString();
|
|
127
|
-
squad.state.tasks[taskIndex].result = { success, error };
|
|
128
|
-
await updateSquadState(session, squad.state.squadId, squad.state);
|
|
78
|
+
squad.state.tasks[taskIndex].result = { success, error };
|
|
79
|
+
await updateSquadState(session, squad.state.squadId, squad.state);
|
|
129
80
|
}
|
|
130
|
-
// Clean up worktree
|
|
131
81
|
if (useWorktrees && worktreeManager) {
|
|
132
82
|
try {
|
|
133
83
|
await worktreeManager.remove(taskId);
|
|
@@ -137,12 +87,10 @@ export async function executeWave(session, squadId, wave, executor, options) {
|
|
|
137
87
|
}
|
|
138
88
|
}
|
|
139
89
|
}
|
|
140
|
-
// Continue executing next task if not aborted
|
|
141
90
|
if (!abortController?.signal.aborted && taskQueue.length > 0) {
|
|
142
91
|
runningTasks.push(executeNextTask());
|
|
143
92
|
}
|
|
144
93
|
};
|
|
145
|
-
// Start initial tasks up to maxConcurrency
|
|
146
94
|
for (let i = 0; i < Math.min(maxConcurrency, tasksToExecute.length); i++) {
|
|
147
95
|
runningTasks.push(executeNextTask());
|
|
148
96
|
}
|
|
@@ -1,73 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session Management
|
|
3
|
-
*
|
|
4
|
-
* Creates and manages shared context sessions for multi-agent collaboration.
|
|
5
|
-
* A session is the top-level container that holds squads and their shared state.
|
|
6
|
-
*
|
|
7
|
-
* @author Kent Beck's Dummy Human
|
|
8
|
-
*/
|
|
9
1
|
import type { Manifest } from "./types.js";
|
|
10
2
|
import type { StorageAdapter } from "./storage.js";
|
|
11
|
-
/**
|
|
12
|
-
* Options for creating a new collaboration session.
|
|
13
|
-
*/
|
|
14
3
|
export interface CreateSessionOptions {
|
|
15
|
-
/** The high-level goal for this session */
|
|
16
4
|
goal: string;
|
|
17
|
-
/** Agent ID of the session creator */
|
|
18
5
|
createdBy: string;
|
|
19
|
-
/** Optional resource constraints */
|
|
20
6
|
constraints?: {
|
|
21
|
-
/** Maximum duration (e.g., "1h", "30m") */
|
|
22
7
|
timeout?: string;
|
|
23
|
-
/** Maximum token budget across all squads */
|
|
24
8
|
tokenBudget?: number;
|
|
25
9
|
};
|
|
26
10
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Represents an active collaboration session.
|
|
29
|
-
* Contains the manifest, storage adapter, and path information.
|
|
30
|
-
*/
|
|
31
11
|
export interface Session {
|
|
32
|
-
/** Session metadata and configuration */
|
|
33
12
|
manifest: Manifest;
|
|
34
|
-
/** Storage adapter for persisting session data */
|
|
35
13
|
storage: StorageAdapter;
|
|
36
|
-
/** Relative path to session directory */
|
|
37
14
|
sessionPath: string;
|
|
38
15
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Create a new collaboration session with the specified goal.
|
|
41
|
-
* Initializes the directory structure and persists the manifest.
|
|
42
|
-
*
|
|
43
|
-
* @param storage - Storage adapter for persistence
|
|
44
|
-
* @param options - Session configuration options
|
|
45
|
-
* @returns The created session with manifest and storage
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* const storage = new FileStorageAdapter("/data");
|
|
49
|
-
* const session = await createSession(storage, {
|
|
50
|
-
* goal: "Implement OAuth login feature",
|
|
51
|
-
* createdBy: "operator-agent",
|
|
52
|
-
* constraints: { timeout: "2h", tokenBudget: 100000 }
|
|
53
|
-
* });
|
|
54
|
-
* console.log(session.manifest.sessionId);
|
|
55
|
-
*/
|
|
56
16
|
export declare function createSession(storage: StorageAdapter, options: CreateSessionOptions): Promise<Session>;
|
|
57
|
-
/**
|
|
58
|
-
* Load an existing session by its ID.
|
|
59
|
-
* Returns null if the session doesn't exist.
|
|
60
|
-
* Validates manifest data at system boundary.
|
|
61
|
-
*
|
|
62
|
-
* @param storage - Storage adapter to read from
|
|
63
|
-
* @param sessionId - UUID of the session to load
|
|
64
|
-
* @returns The session if found, null otherwise
|
|
65
|
-
* @throws ValidationError if manifest data is corrupted
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* const session = await loadSession(storage, "550e8400-e29b-41d4-a716-446655440000");
|
|
69
|
-
* if (session) {
|
|
70
|
-
* console.log(`Loaded session: ${session.manifest.goal}`);
|
|
71
|
-
* }
|
|
72
|
-
*/
|
|
73
17
|
export declare function loadSession(storage: StorageAdapter, sessionId: string): Promise<Session | null>;
|
|
@@ -1,34 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session Management
|
|
3
|
-
*
|
|
4
|
-
* Creates and manages shared context sessions for multi-agent collaboration.
|
|
5
|
-
* A session is the top-level container that holds squads and their shared state.
|
|
6
|
-
*
|
|
7
|
-
* @author Kent Beck's Dummy Human
|
|
8
|
-
*/
|
|
9
1
|
import { randomUUID } from "crypto";
|
|
10
2
|
import { validateManifest } from "./types.js";
|
|
11
3
|
import { ValidationError } from "../shared/errors.js";
|
|
12
|
-
// ============================================================================
|
|
13
|
-
// Session Operations
|
|
14
|
-
// ============================================================================
|
|
15
|
-
/**
|
|
16
|
-
* Create a new collaboration session with the specified goal.
|
|
17
|
-
* Initializes the directory structure and persists the manifest.
|
|
18
|
-
*
|
|
19
|
-
* @param storage - Storage adapter for persistence
|
|
20
|
-
* @param options - Session configuration options
|
|
21
|
-
* @returns The created session with manifest and storage
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* const storage = new FileStorageAdapter("/data");
|
|
25
|
-
* const session = await createSession(storage, {
|
|
26
|
-
* goal: "Implement OAuth login feature",
|
|
27
|
-
* createdBy: "operator-agent",
|
|
28
|
-
* constraints: { timeout: "2h", tokenBudget: 100000 }
|
|
29
|
-
* });
|
|
30
|
-
* console.log(session.manifest.sessionId);
|
|
31
|
-
*/
|
|
32
4
|
export async function createSession(storage, options) {
|
|
33
5
|
const sessionId = randomUUID();
|
|
34
6
|
const sessionPath = `shared/${sessionId}`;
|
|
@@ -41,36 +13,17 @@ export async function createSession(storage, options) {
|
|
|
41
13
|
squads: [],
|
|
42
14
|
constraints: options.constraints,
|
|
43
15
|
};
|
|
44
|
-
// Create directory structure
|
|
45
16
|
await storage.ensureDir(sessionPath);
|
|
46
17
|
await storage.ensureDir(`${sessionPath}/events`);
|
|
47
18
|
await storage.ensureDir(`${sessionPath}/squads`);
|
|
48
|
-
// Persist manifest
|
|
49
19
|
await storage.write(`${sessionPath}/manifest.json`, manifest);
|
|
50
20
|
return { manifest, storage, sessionPath };
|
|
51
21
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Load an existing session by its ID.
|
|
54
|
-
* Returns null if the session doesn't exist.
|
|
55
|
-
* Validates manifest data at system boundary.
|
|
56
|
-
*
|
|
57
|
-
* @param storage - Storage adapter to read from
|
|
58
|
-
* @param sessionId - UUID of the session to load
|
|
59
|
-
* @returns The session if found, null otherwise
|
|
60
|
-
* @throws ValidationError if manifest data is corrupted
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* const session = await loadSession(storage, "550e8400-e29b-41d4-a716-446655440000");
|
|
64
|
-
* if (session) {
|
|
65
|
-
* console.log(`Loaded session: ${session.manifest.goal}`);
|
|
66
|
-
* }
|
|
67
|
-
*/
|
|
68
22
|
export async function loadSession(storage, sessionId) {
|
|
69
23
|
const sessionPath = `shared/${sessionId}`;
|
|
70
24
|
const rawManifest = await storage.read(`${sessionPath}/manifest.json`);
|
|
71
25
|
if (!rawManifest)
|
|
72
26
|
return null;
|
|
73
|
-
// 경계에서 검증 - Parse, don't validate
|
|
74
27
|
try {
|
|
75
28
|
const manifest = validateManifest(rawManifest);
|
|
76
29
|
return { manifest, storage, sessionPath };
|
|
@@ -1,92 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Squad Management
|
|
3
|
-
*
|
|
4
|
-
* Squads are work units within a session, each with their own mission,
|
|
5
|
-
* constraints, and set of tasks. This module handles squad lifecycle.
|
|
6
|
-
*
|
|
7
|
-
* @author Kent Beck's Dummy Human
|
|
8
|
-
*/
|
|
9
1
|
import type { SquadSpec, SquadState } from "./types.js";
|
|
10
2
|
import type { Session } from "./session.js";
|
|
11
|
-
/**
|
|
12
|
-
* Options for creating a new squad within a session.
|
|
13
|
-
*/
|
|
14
3
|
export interface CreateSquadOptions {
|
|
15
|
-
/** The squad's mission objective */
|
|
16
4
|
mission: string;
|
|
17
|
-
/** Agent ID of the squad operator */
|
|
18
5
|
operator: string;
|
|
19
|
-
/** Optional resource constraints for the squad */
|
|
20
6
|
constraints?: {
|
|
21
|
-
/** Maximum duration (e.g., "1h", "30m") */
|
|
22
7
|
timeout?: string;
|
|
23
|
-
/** Maximum token budget for this squad */
|
|
24
8
|
tokenBudget?: number;
|
|
25
|
-
/** Maximum number of worker agents */
|
|
26
9
|
maxWorkers?: number;
|
|
27
10
|
};
|
|
28
|
-
/** File/directory scope for the squad's work */
|
|
29
11
|
scope?: {
|
|
30
|
-
/** Files the squad can modify */
|
|
31
12
|
files?: string[];
|
|
32
|
-
/** Directories the squad can access */
|
|
33
13
|
directories?: string[];
|
|
34
14
|
};
|
|
35
15
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Create a new squad within a session.
|
|
38
|
-
* A squad is a unit of work with its own mission and constraints.
|
|
39
|
-
*
|
|
40
|
-
* @param session - The parent session
|
|
41
|
-
* @param options - Squad configuration options
|
|
42
|
-
* @returns The created squad's spec and initial state
|
|
43
|
-
* @throws {ValidationError} If session has reached max squad limit
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* const { spec, state } = await createSquad(session, {
|
|
47
|
-
* mission: "Implement user authentication",
|
|
48
|
-
* operator: "auth-operator",
|
|
49
|
-
* constraints: { maxWorkers: 3 },
|
|
50
|
-
* scope: { directories: ["src/auth"] }
|
|
51
|
-
* });
|
|
52
|
-
*/
|
|
53
16
|
export declare function createSquad(session: Session, options: CreateSquadOptions): Promise<{
|
|
54
17
|
spec: SquadSpec;
|
|
55
18
|
state: SquadState;
|
|
56
19
|
}>;
|
|
57
|
-
/**
|
|
58
|
-
* Retrieve a squad's specification and current state.
|
|
59
|
-
* Validates data at system boundary.
|
|
60
|
-
*
|
|
61
|
-
* @param session - The parent session
|
|
62
|
-
* @param squadId - ID of the squad to retrieve
|
|
63
|
-
* @returns Squad spec and state, or null if not found
|
|
64
|
-
* @throws ValidationError if data is corrupted
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* const squad = await getSquad(session, "squad-a1b2c3d4");
|
|
68
|
-
* if (squad) {
|
|
69
|
-
* console.log(`Squad status: ${squad.state.status}`);
|
|
70
|
-
* }
|
|
71
|
-
*/
|
|
72
20
|
export declare function getSquad(session: Session, squadId: string): Promise<{
|
|
73
21
|
spec: SquadSpec;
|
|
74
22
|
state: SquadState;
|
|
75
23
|
} | null>;
|
|
76
|
-
/**
|
|
77
|
-
* Update a squad's state with partial changes.
|
|
78
|
-
* Automatically updates the `updatedAt` timestamp.
|
|
79
|
-
*
|
|
80
|
-
* @param session - The parent session
|
|
81
|
-
* @param squadId - ID of the squad to update
|
|
82
|
-
* @param updates - Partial state updates to apply
|
|
83
|
-
* @returns The new state after update
|
|
84
|
-
* @throws {StorageError} If the squad doesn't exist
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* const newState = await updateSquadState(session, "squad-a1b2c3d4", {
|
|
88
|
-
* status: "active",
|
|
89
|
-
* progress: 50
|
|
90
|
-
* });
|
|
91
|
-
*/
|
|
92
24
|
export declare function updateSquadState(session: Session, squadId: string, updates: Partial<SquadState>): Promise<SquadState>;
|
|
@@ -1,36 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Squad Management
|
|
3
|
-
*
|
|
4
|
-
* Squads are work units within a session, each with their own mission,
|
|
5
|
-
* constraints, and set of tasks. This module handles squad lifecycle.
|
|
6
|
-
*
|
|
7
|
-
* @author Kent Beck's Dummy Human
|
|
8
|
-
*/
|
|
9
1
|
import { randomUUID } from "crypto";
|
|
10
2
|
import { LIMITS, validateSquadSpec, validateSquadState } from "./types.js";
|
|
11
3
|
import { StorageError, ValidationError } from "../shared/errors.js";
|
|
12
|
-
// ============================================================================
|
|
13
|
-
// Squad Operations
|
|
14
|
-
// ============================================================================
|
|
15
|
-
/**
|
|
16
|
-
* Create a new squad within a session.
|
|
17
|
-
* A squad is a unit of work with its own mission and constraints.
|
|
18
|
-
*
|
|
19
|
-
* @param session - The parent session
|
|
20
|
-
* @param options - Squad configuration options
|
|
21
|
-
* @returns The created squad's spec and initial state
|
|
22
|
-
* @throws {ValidationError} If session has reached max squad limit
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* const { spec, state } = await createSquad(session, {
|
|
26
|
-
* mission: "Implement user authentication",
|
|
27
|
-
* operator: "auth-operator",
|
|
28
|
-
* constraints: { maxWorkers: 3 },
|
|
29
|
-
* scope: { directories: ["src/auth"] }
|
|
30
|
-
* });
|
|
31
|
-
*/
|
|
32
4
|
export async function createSquad(session, options) {
|
|
33
|
-
// Enforce squad limit
|
|
34
5
|
if (session.manifest.squads.length >= LIMITS.maxSquadsPerSession) {
|
|
35
6
|
throw new ValidationError("Maximum squads per session exceeded", {
|
|
36
7
|
limit: LIMITS.maxSquadsPerSession,
|
|
@@ -60,38 +31,20 @@ export async function createSquad(session, options) {
|
|
|
60
31
|
sharedContext: {},
|
|
61
32
|
updatedAt: new Date().toISOString(),
|
|
62
33
|
};
|
|
63
|
-
// Create directory structure and persist data
|
|
64
34
|
await session.storage.ensureDir(squadPath);
|
|
65
35
|
await session.storage.ensureDir(`${squadPath}/scratch`);
|
|
66
36
|
await session.storage.write(`${squadPath}/spec.json`, spec);
|
|
67
37
|
await session.storage.write(`${squadPath}/state.json`, state);
|
|
68
|
-
// Update session manifest with new squad
|
|
69
38
|
session.manifest.squads.push(squadId);
|
|
70
39
|
await session.storage.write(`${session.sessionPath}/manifest.json`, session.manifest);
|
|
71
40
|
return { spec, state };
|
|
72
41
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Retrieve a squad's specification and current state.
|
|
75
|
-
* Validates data at system boundary.
|
|
76
|
-
*
|
|
77
|
-
* @param session - The parent session
|
|
78
|
-
* @param squadId - ID of the squad to retrieve
|
|
79
|
-
* @returns Squad spec and state, or null if not found
|
|
80
|
-
* @throws ValidationError if data is corrupted
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* const squad = await getSquad(session, "squad-a1b2c3d4");
|
|
84
|
-
* if (squad) {
|
|
85
|
-
* console.log(`Squad status: ${squad.state.status}`);
|
|
86
|
-
* }
|
|
87
|
-
*/
|
|
88
42
|
export async function getSquad(session, squadId) {
|
|
89
43
|
const squadPath = `${session.sessionPath}/squads/${squadId}`;
|
|
90
44
|
const rawSpec = await session.storage.read(`${squadPath}/spec.json`);
|
|
91
45
|
const rawState = await session.storage.read(`${squadPath}/state.json`);
|
|
92
46
|
if (!rawSpec || !rawState)
|
|
93
47
|
return null;
|
|
94
|
-
// 경계에서 검증 - Parse, don't validate
|
|
95
48
|
try {
|
|
96
49
|
const spec = validateSquadSpec(rawSpec);
|
|
97
50
|
const state = validateSquadState(rawState);
|
|
@@ -101,22 +54,6 @@ export async function getSquad(session, squadId) {
|
|
|
101
54
|
throw new ValidationError(`Invalid squad data for ${squadId}`, { squadId, error: error instanceof Error ? error.message : String(error) });
|
|
102
55
|
}
|
|
103
56
|
}
|
|
104
|
-
/**
|
|
105
|
-
* Update a squad's state with partial changes.
|
|
106
|
-
* Automatically updates the `updatedAt` timestamp.
|
|
107
|
-
*
|
|
108
|
-
* @param session - The parent session
|
|
109
|
-
* @param squadId - ID of the squad to update
|
|
110
|
-
* @param updates - Partial state updates to apply
|
|
111
|
-
* @returns The new state after update
|
|
112
|
-
* @throws {StorageError} If the squad doesn't exist
|
|
113
|
-
*
|
|
114
|
-
* @example
|
|
115
|
-
* const newState = await updateSquadState(session, "squad-a1b2c3d4", {
|
|
116
|
-
* status: "active",
|
|
117
|
-
* progress: 50
|
|
118
|
-
* });
|
|
119
|
-
*/
|
|
120
57
|
export async function updateSquadState(session, squadId, updates) {
|
|
121
58
|
const squad = await getSquad(session, squadId);
|
|
122
59
|
if (!squad) {
|