vibe-splain 3.4.2 → 4.0.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.
- package/README.md +110 -158
- package/dist/commands/install.d.ts +0 -5
- package/dist/commands/install.js +5 -55
- package/dist/commands/serve.js +1 -1
- package/dist/export/ArtifactBundleWriter.js +3 -3
- package/dist/export/ExportOrchestrator.d.ts +2 -20
- package/dist/export/ExportOrchestrator.js +5 -116
- package/dist/export/Watcher.js +5 -5
- package/dist/export/renderers/AgentMarkdownRenderer.d.ts +1 -1
- package/dist/export/renderers/GraphRenderer.d.ts +2 -2
- package/dist/export/renderers/HtmlRenderer.d.ts +1 -1
- package/dist/export/renderers/HtmlRenderer.js +1 -1
- package/dist/export/renderers/JsonRenderer.d.ts +1 -1
- package/dist/export/renderers/RawAnalysisRenderer.d.ts +1 -1
- package/dist/export/renderers/Renderer.d.ts +1 -1
- package/dist/export/renderers/ValidationRenderer.d.ts +1 -1
- package/dist/index.js +1425 -6511
- package/dist/mcp/server.js +6 -46
- package/dist/mcp/tools/get_file_context.js +1 -1
- package/dist/mcp/tools/get_project_map.js +1 -1
- package/dist/mcp/tools/get_strategic_overview.js +1 -1
- package/dist/mcp/tools/get_wild_discoveries.js +1 -1
- package/dist/mcp/tools/inspect_pillar.js +1 -1
- package/dist/mcp/tools/mark_stale.js +1 -1
- package/dist/mcp/tools/scan_project.d.ts +2 -3
- package/dist/mcp/tools/scan_project.js +12 -13
- package/dist/mcp/tools/set_project_brief.js +1 -1
- package/dist/mcp/tools/write_decision_card.d.ts +1 -1
- package/dist/mcp/tools/write_decision_card.js +2 -2
- package/dist/ui/index.html +1 -1
- package/package.json +9 -14
- package/dist/commands/bundle.d.ts +0 -4
- package/dist/commands/bundle.js +0 -68
- package/dist/commands/export.d.ts +0 -1
- package/dist/commands/export.js +0 -19
- package/dist/commands/gc.d.ts +0 -3
- package/dist/commands/gc.js +0 -59
- package/dist/commands/hook.d.ts +0 -9
- package/dist/commands/hook.js +0 -84
- package/dist/commands/importBundle.d.ts +0 -4
- package/dist/commands/importBundle.js +0 -80
- package/dist/commands/network.d.ts +0 -1
- package/dist/commands/network.js +0 -91
- package/dist/commands/scan.d.ts +0 -13
- package/dist/commands/scan.js +0 -97
- package/dist/export/renderers/DeltaRenderer.d.ts +0 -6
- package/dist/export/renderers/DeltaRenderer.js +0 -22
- package/dist/hook/preToolUse.d.ts +0 -30
- package/dist/hook/preToolUse.js +0 -81
- package/dist/hook-entry.d.ts +0 -2
- package/dist/hook-entry.js +0 -8
- package/dist/hook.d.ts +0 -1
- package/dist/hook.js +0 -337
- package/dist/mcp/BudgetGuard.d.ts +0 -13
- package/dist/mcp/BudgetGuard.js +0 -55
- package/dist/mcp/SessionScope.d.ts +0 -26
- package/dist/mcp/SessionScope.js +0 -56
- package/dist/mcp/tools/apply_patch.d.ts +0 -37
- package/dist/mcp/tools/apply_patch.js +0 -103
- package/dist/mcp/tools/explainSpecialistScope.d.ts +0 -15
- package/dist/mcp/tools/explainSpecialistScope.js +0 -30
- package/dist/mcp/tools/get_call_chain.d.ts +0 -42
- package/dist/mcp/tools/get_call_chain.js +0 -50
- package/dist/mcp/tools/get_file_skeleton.d.ts +0 -23
- package/dist/mcp/tools/get_file_skeleton.js +0 -124
- package/dist/mcp/tools/hydration/get_evidence_slice.d.ts +0 -31
- package/dist/mcp/tools/hydration/get_evidence_slice.js +0 -57
- package/dist/mcp/tools/hydration/get_project_summary.d.ts +0 -23
- package/dist/mcp/tools/hydration/get_project_summary.js +0 -58
- package/dist/mcp/tools/hydration/get_start_here.d.ts +0 -23
- package/dist/mcp/tools/hydration/get_start_here.js +0 -52
- package/dist/mcp/tools/prepareTaskContext.d.ts +0 -38
- package/dist/mcp/tools/prepareTaskContext.js +0 -93
- package/dist/mcp/tools/read_file.d.ts +0 -31
- package/dist/mcp/tools/read_file.js +0 -90
- package/dist/mcp/tools/set_session_scope.d.ts +0 -19
- package/dist/mcp/tools/set_session_scope.js +0 -40
- package/dist/mcp/tools/submit_receipt.d.ts +0 -68
- package/dist/mcp/tools/submit_receipt.js +0 -94
- package/dist/mcp/tools/work_orders.d.ts +0 -79
- package/dist/mcp/tools/work_orders.js +0 -126
- package/dist/mcp/tools/yield_for_scope_expansion.d.ts +0 -29
- package/dist/mcp/tools/yield_for_scope_expansion.js +0 -59
- package/dist/store/BlobStore.d.ts +0 -22
- package/dist/store/BlobStore.js +0 -96
- package/dist/store/PointerStore.d.ts +0 -52
- package/dist/store/PointerStore.js +0 -154
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export declare const prepareTaskContextTool: {
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object";
|
|
6
|
-
properties: {
|
|
7
|
-
projectRoot: {
|
|
8
|
-
type: string;
|
|
9
|
-
description: string;
|
|
10
|
-
};
|
|
11
|
-
task: {
|
|
12
|
-
type: string;
|
|
13
|
-
description: string;
|
|
14
|
-
};
|
|
15
|
-
files: {
|
|
16
|
-
type: string;
|
|
17
|
-
items: {
|
|
18
|
-
type: string;
|
|
19
|
-
};
|
|
20
|
-
description: string;
|
|
21
|
-
};
|
|
22
|
-
error_trace: {
|
|
23
|
-
type: string;
|
|
24
|
-
description: string;
|
|
25
|
-
};
|
|
26
|
-
intended_behavior: {
|
|
27
|
-
type: string;
|
|
28
|
-
description: string;
|
|
29
|
-
};
|
|
30
|
-
max_files: {
|
|
31
|
-
type: string;
|
|
32
|
-
description: string;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
required: string[];
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export declare function handlePrepareTaskContext(args: Record<string, unknown>, options?: any): Promise<unknown>;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import { readFile, writeFile, mkdir } from 'fs/promises';
|
|
3
|
-
import { buildExpertNetworkPacket } from '@vibe-splain/brain';
|
|
4
|
-
export const prepareTaskContextTool = {
|
|
5
|
-
name: 'vibe_prepare_task_context',
|
|
6
|
-
description: 'Prepares the ExpertNetworkPacket for a given task, selecting relevant files, routing to a specialist panel, analyzing risk warnings, and slicing scopes without running model inference.',
|
|
7
|
-
inputSchema: {
|
|
8
|
-
type: 'object',
|
|
9
|
-
properties: {
|
|
10
|
-
projectRoot: {
|
|
11
|
-
type: 'string',
|
|
12
|
-
description: 'Absolute path to the project root directory',
|
|
13
|
-
},
|
|
14
|
-
task: {
|
|
15
|
-
type: 'string',
|
|
16
|
-
description: 'Description of the task or issue to resolve',
|
|
17
|
-
},
|
|
18
|
-
files: {
|
|
19
|
-
type: 'array',
|
|
20
|
-
items: { type: 'string' },
|
|
21
|
-
description: 'Optional list of files to explicitly focus on',
|
|
22
|
-
},
|
|
23
|
-
error_trace: {
|
|
24
|
-
type: 'string',
|
|
25
|
-
description: 'Optional error stack trace or exception output',
|
|
26
|
-
},
|
|
27
|
-
intended_behavior: {
|
|
28
|
-
type: 'string',
|
|
29
|
-
description: 'Optional description of the intended behavior',
|
|
30
|
-
},
|
|
31
|
-
max_files: {
|
|
32
|
-
type: 'number',
|
|
33
|
-
description: 'Optional maximum files to select',
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
required: ['projectRoot', 'task'],
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
export async function handlePrepareTaskContext(args, options = {}) {
|
|
40
|
-
const projectRoot = args.projectRoot;
|
|
41
|
-
const task = args.task;
|
|
42
|
-
const files = args.files;
|
|
43
|
-
const errorTrace = args.error_trace;
|
|
44
|
-
const intendedBehavior = args.intended_behavior;
|
|
45
|
-
const maxFiles = args.max_files;
|
|
46
|
-
if (!projectRoot)
|
|
47
|
-
throw new Error('projectRoot is required');
|
|
48
|
-
if (!task)
|
|
49
|
-
throw new Error('task is required');
|
|
50
|
-
console.error(`[vibe-splain] Preparing task context for task: "${task}"`);
|
|
51
|
-
// Try to load scan artifact
|
|
52
|
-
let scanArtifact = null;
|
|
53
|
-
const artifactPath = join(projectRoot, '.vibe-splainer', 'analysis.json');
|
|
54
|
-
try {
|
|
55
|
-
const raw = await readFile(artifactPath, 'utf8');
|
|
56
|
-
scanArtifact = JSON.parse(raw);
|
|
57
|
-
}
|
|
58
|
-
catch (err) {
|
|
59
|
-
console.error(`[vibe-splain] No scan artifact found at ${artifactPath}, proceeding with fallback routing.`);
|
|
60
|
-
}
|
|
61
|
-
// Build the packet
|
|
62
|
-
const packet = buildExpertNetworkPacket({
|
|
63
|
-
task,
|
|
64
|
-
projectRoot,
|
|
65
|
-
scanArtifact,
|
|
66
|
-
files,
|
|
67
|
-
errorTrace,
|
|
68
|
-
intendedBehavior,
|
|
69
|
-
maxFiles
|
|
70
|
-
});
|
|
71
|
-
// Save network packet locally
|
|
72
|
-
const networkDir = join(projectRoot, '.vibe-splainer', 'network');
|
|
73
|
-
const packetsDir = join(networkDir, 'packets');
|
|
74
|
-
try {
|
|
75
|
-
await mkdir(packetsDir, { recursive: true });
|
|
76
|
-
// Save latest
|
|
77
|
-
const latestPath = join(networkDir, 'latest_packet.json');
|
|
78
|
-
await writeFile(latestPath, JSON.stringify(packet, null, 2), 'utf8');
|
|
79
|
-
// Save timestamped
|
|
80
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
81
|
-
const timestampedPath = join(packetsDir, `${timestamp}.json`);
|
|
82
|
-
await writeFile(timestampedPath, JSON.stringify(packet, null, 2), 'utf8');
|
|
83
|
-
console.error(`[vibe-splain] Network packets saved under ${networkDir}`);
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
console.error('[vibe-splain] Failed to save network packets locally:', err.message);
|
|
87
|
-
}
|
|
88
|
-
return {
|
|
89
|
-
ok: true,
|
|
90
|
-
packet
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=prepareTaskContext.js.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export declare const readFileTool: {
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object";
|
|
6
|
-
properties: {
|
|
7
|
-
projectRoot: {
|
|
8
|
-
type: string;
|
|
9
|
-
description: string;
|
|
10
|
-
};
|
|
11
|
-
filePath: {
|
|
12
|
-
type: string;
|
|
13
|
-
description: string;
|
|
14
|
-
};
|
|
15
|
-
scanId: {
|
|
16
|
-
type: string;
|
|
17
|
-
description: string;
|
|
18
|
-
};
|
|
19
|
-
startLine: {
|
|
20
|
-
type: string;
|
|
21
|
-
description: string;
|
|
22
|
-
};
|
|
23
|
-
endLine: {
|
|
24
|
-
type: string;
|
|
25
|
-
description: string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
required: string[];
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
export declare function handleReadFile(args: Record<string, unknown>): Promise<unknown>;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'fs/promises';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import { SessionScope, ScopeViolation } from '../SessionScope.js';
|
|
4
|
-
import { hashFile } from '../../store/BlobStore.js';
|
|
5
|
-
import { BlobStore } from '../../store/BlobStore.js';
|
|
6
|
-
import { PointerStore } from '../../store/PointerStore.js';
|
|
7
|
-
import { applyBudgetGuard } from '../BudgetGuard.js';
|
|
8
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
9
|
-
export const readFileTool = {
|
|
10
|
-
name: 'read_file',
|
|
11
|
-
description: 'Reads a file within the active workOrder scope. Enforces allowedFiles/allowedGlobs/deniedGlobs. Records content hash. Output is budgeted.',
|
|
12
|
-
inputSchema: {
|
|
13
|
-
type: 'object',
|
|
14
|
-
properties: {
|
|
15
|
-
projectRoot: { type: 'string', description: 'Absolute project root' },
|
|
16
|
-
filePath: { type: 'string', description: 'Path relative to projectRoot' },
|
|
17
|
-
scanId: { type: 'string', description: 'Current scan ID for pointer registration' },
|
|
18
|
-
startLine: { type: 'number', description: 'Optional: 1-based start line to return a slice' },
|
|
19
|
-
endLine: { type: 'number', description: 'Optional: 1-based end line (inclusive). Capped at startLine+500.' },
|
|
20
|
-
},
|
|
21
|
-
required: ['projectRoot', 'filePath', 'scanId'],
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
export async function handleReadFile(args) {
|
|
25
|
-
const projectRoot = args.projectRoot;
|
|
26
|
-
const filePath = args.filePath;
|
|
27
|
-
const scanId = args.scanId;
|
|
28
|
-
const startLine = args.startLine !== undefined ? Number(args.startLine) : undefined;
|
|
29
|
-
const endLine = args.endLine !== undefined
|
|
30
|
-
? Math.min(Number(args.endLine), (startLine ?? 1) + 500)
|
|
31
|
-
: undefined;
|
|
32
|
-
if (!projectRoot || !filePath || !scanId) {
|
|
33
|
-
throw new Error('projectRoot, filePath, and scanId are required');
|
|
34
|
-
}
|
|
35
|
-
// 1. Scope enforcement
|
|
36
|
-
try {
|
|
37
|
-
SessionScope.enforce(filePath);
|
|
38
|
-
}
|
|
39
|
-
catch (e) {
|
|
40
|
-
if (e instanceof ScopeViolation)
|
|
41
|
-
throw e;
|
|
42
|
-
throw e;
|
|
43
|
-
}
|
|
44
|
-
const absolutePath = filePath.startsWith('/') ? filePath : join(projectRoot, filePath);
|
|
45
|
-
// 2. Read file
|
|
46
|
-
let content;
|
|
47
|
-
try {
|
|
48
|
-
content = await readFile(absolutePath, 'utf8');
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
throw new Error(`FileNotFound: cannot read ${filePath}`);
|
|
52
|
-
}
|
|
53
|
-
// 3. Content hash recording
|
|
54
|
-
const contentHash = await hashFile(absolutePath);
|
|
55
|
-
// 4. Apply line slice if requested
|
|
56
|
-
let output = content;
|
|
57
|
-
let sliceInfo;
|
|
58
|
-
if (startLine !== undefined) {
|
|
59
|
-
const lines = content.split('\n');
|
|
60
|
-
const end = endLine ?? lines.length;
|
|
61
|
-
output = lines.slice(startLine - 1, end).join('\n');
|
|
62
|
-
sliceInfo = { startLine, endLine: end, totalLines: lines.length };
|
|
63
|
-
}
|
|
64
|
-
// 5. Record content hash in pointer store
|
|
65
|
-
const blobStore = new BlobStore(projectRoot);
|
|
66
|
-
const pointerStore = PointerStore.open(projectRoot);
|
|
67
|
-
const { blobPath } = await blobStore.writeAtomic(content);
|
|
68
|
-
const pointerId = `ptr_file_${uuidv4().replace(/-/g, '').slice(0, 12)}`;
|
|
69
|
-
await pointerStore.insertPointer({
|
|
70
|
-
pointerId,
|
|
71
|
-
scanId,
|
|
72
|
-
artifactName: 'file_read',
|
|
73
|
-
contentHash,
|
|
74
|
-
blobPath,
|
|
75
|
-
schemaVersion: '1.0.0',
|
|
76
|
-
createdAt: Date.now(),
|
|
77
|
-
expiresAt: null,
|
|
78
|
-
});
|
|
79
|
-
const result = {
|
|
80
|
-
filePath,
|
|
81
|
-
contentHash,
|
|
82
|
-
pointerId,
|
|
83
|
-
content: output,
|
|
84
|
-
};
|
|
85
|
-
if (sliceInfo)
|
|
86
|
-
result.slice = sliceInfo;
|
|
87
|
-
// 6. Budget enforcement
|
|
88
|
-
return await applyBudgetGuard(projectRoot, scanId, 'file_read', result);
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=read_file.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare const setSessionScopeTool: {
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object";
|
|
6
|
-
properties: {
|
|
7
|
-
projectRoot: {
|
|
8
|
-
type: string;
|
|
9
|
-
description: string;
|
|
10
|
-
};
|
|
11
|
-
workOrderId: {
|
|
12
|
-
type: string;
|
|
13
|
-
description: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
required: string[];
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export declare function handleSetSessionScope(args: Record<string, unknown>): Promise<unknown>;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { PointerStore } from '../../store/PointerStore.js';
|
|
2
|
-
import { SessionScope } from '../SessionScope.js';
|
|
3
|
-
export const setSessionScopeTool = {
|
|
4
|
-
name: 'set_session_scope',
|
|
5
|
-
description: 'Sets the active session scope from a Work Order. All subsequent file tools (read_file, get_file_skeleton, apply_patch) will enforce this scope until overwritten or the server restarts.',
|
|
6
|
-
inputSchema: {
|
|
7
|
-
type: 'object',
|
|
8
|
-
properties: {
|
|
9
|
-
projectRoot: { type: 'string', description: 'Absolute project root' },
|
|
10
|
-
workOrderId: { type: 'string', description: 'Work Order ID to load scope from' },
|
|
11
|
-
},
|
|
12
|
-
required: ['projectRoot', 'workOrderId'],
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
export async function handleSetSessionScope(args) {
|
|
16
|
-
const projectRoot = args.projectRoot;
|
|
17
|
-
const workOrderId = args.workOrderId;
|
|
18
|
-
if (!projectRoot || !workOrderId) {
|
|
19
|
-
throw new Error('projectRoot and workOrderId are required');
|
|
20
|
-
}
|
|
21
|
-
const pointerStore = PointerStore.open(projectRoot);
|
|
22
|
-
const row = pointerStore.getWorkOrder(workOrderId);
|
|
23
|
-
if (!row) {
|
|
24
|
-
throw new Error(`WorkOrderNotFound: ${workOrderId}`);
|
|
25
|
-
}
|
|
26
|
-
const policy = SessionScope.fromWorkOrderRow(row);
|
|
27
|
-
SessionScope.set(policy);
|
|
28
|
-
return {
|
|
29
|
-
ok: true,
|
|
30
|
-
workOrderId,
|
|
31
|
-
scope: {
|
|
32
|
-
allowedFiles: policy.allowedFiles,
|
|
33
|
-
allowedGlobs: policy.allowedGlobs,
|
|
34
|
-
deniedGlobs: policy.deniedGlobs,
|
|
35
|
-
requiredProofCount: policy.requiredProof.length,
|
|
36
|
-
},
|
|
37
|
-
message: `Session scope set from work order ${workOrderId}. All file tools will enforce this scope.`,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=set_session_scope.js.map
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
export declare const submitReceiptTool: {
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object";
|
|
6
|
-
properties: {
|
|
7
|
-
projectRoot: {
|
|
8
|
-
type: string;
|
|
9
|
-
description: string;
|
|
10
|
-
};
|
|
11
|
-
receipt: {
|
|
12
|
-
type: string;
|
|
13
|
-
description: string;
|
|
14
|
-
properties: {
|
|
15
|
-
workOrderId: {
|
|
16
|
-
type: string;
|
|
17
|
-
};
|
|
18
|
-
status: {
|
|
19
|
-
type: string;
|
|
20
|
-
enum: string[];
|
|
21
|
-
};
|
|
22
|
-
proofPointers: {
|
|
23
|
-
type: string;
|
|
24
|
-
items: {
|
|
25
|
-
type: string;
|
|
26
|
-
properties: {
|
|
27
|
-
pointer: {
|
|
28
|
-
type: string;
|
|
29
|
-
};
|
|
30
|
-
schemaName: {
|
|
31
|
-
type: string;
|
|
32
|
-
};
|
|
33
|
-
contentHash: {
|
|
34
|
-
type: string;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
required: string[];
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
changedFiles: {
|
|
41
|
-
type: string;
|
|
42
|
-
items: {
|
|
43
|
-
type: string;
|
|
44
|
-
properties: {
|
|
45
|
-
path: {
|
|
46
|
-
type: string;
|
|
47
|
-
};
|
|
48
|
-
prePatchHash: {
|
|
49
|
-
type: string;
|
|
50
|
-
};
|
|
51
|
-
postPatchHash: {
|
|
52
|
-
type: string;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
required: string[];
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
summary: {
|
|
59
|
-
type: string;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
required: string[];
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
required: string[];
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
export declare function handleSubmitReceipt(args: Record<string, unknown>): Promise<unknown>;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import { PointerStore } from '../../store/PointerStore.js';
|
|
3
|
-
import { ProofValidator } from '@vibe-splain/brain';
|
|
4
|
-
import { minimatch } from 'minimatch';
|
|
5
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
-
export const submitReceiptTool = {
|
|
7
|
-
name: 'submit_receipt',
|
|
8
|
-
description: 'Worker submits a WorkerReceipt for a completed Work Order. The ProofValidator checks all 8 proof conditions. Returns accept/reject with detailed errors.',
|
|
9
|
-
inputSchema: {
|
|
10
|
-
type: 'object',
|
|
11
|
-
properties: {
|
|
12
|
-
projectRoot: { type: 'string', description: 'Absolute project root' },
|
|
13
|
-
receipt: {
|
|
14
|
-
type: 'object',
|
|
15
|
-
description: 'WorkerReceipt object',
|
|
16
|
-
properties: {
|
|
17
|
-
workOrderId: { type: 'string' },
|
|
18
|
-
status: { type: 'string', enum: ['completed', 'failed', 'blocked'] },
|
|
19
|
-
proofPointers: {
|
|
20
|
-
type: 'array',
|
|
21
|
-
items: {
|
|
22
|
-
type: 'object',
|
|
23
|
-
properties: {
|
|
24
|
-
pointer: { type: 'string' },
|
|
25
|
-
schemaName: { type: 'string' },
|
|
26
|
-
contentHash: { type: 'string' },
|
|
27
|
-
},
|
|
28
|
-
required: ['pointer', 'schemaName', 'contentHash'],
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
changedFiles: {
|
|
32
|
-
type: 'array',
|
|
33
|
-
items: {
|
|
34
|
-
type: 'object',
|
|
35
|
-
properties: {
|
|
36
|
-
path: { type: 'string' },
|
|
37
|
-
prePatchHash: { type: 'string' },
|
|
38
|
-
postPatchHash: { type: 'string' },
|
|
39
|
-
},
|
|
40
|
-
required: ['path', 'prePatchHash', 'postPatchHash'],
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
summary: { type: 'string' },
|
|
44
|
-
},
|
|
45
|
-
required: ['workOrderId', 'status', 'proofPointers', 'changedFiles', 'summary'],
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
required: ['projectRoot', 'receipt'],
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
export async function handleSubmitReceipt(args) {
|
|
52
|
-
const projectRoot = args.projectRoot;
|
|
53
|
-
const receipt = args.receipt;
|
|
54
|
-
if (!projectRoot || !receipt) {
|
|
55
|
-
throw new Error('projectRoot and receipt are required');
|
|
56
|
-
}
|
|
57
|
-
const pointerStore = PointerStore.open(projectRoot);
|
|
58
|
-
const workOrder = pointerStore.getWorkOrder(receipt.workOrderId);
|
|
59
|
-
if (!workOrder) {
|
|
60
|
-
throw new Error(`WorkOrderNotFound: ${receipt.workOrderId}`);
|
|
61
|
-
}
|
|
62
|
-
if (workOrder.status !== 'active') {
|
|
63
|
-
throw new Error(`WorkOrderNotActive: ${receipt.workOrderId} is "${workOrder.status}", expected "active"`);
|
|
64
|
-
}
|
|
65
|
-
const allowedFiles = JSON.parse(workOrder.allowedFiles);
|
|
66
|
-
const allowedGlobs = JSON.parse(workOrder.allowedGlobs);
|
|
67
|
-
const requiredProof = JSON.parse(workOrder.requiredProof);
|
|
68
|
-
const blobDir = join(projectRoot, '.vibe-splainer', 'blobs');
|
|
69
|
-
const isAllowedFile = (filePath) => {
|
|
70
|
-
const inExplicit = allowedFiles.some(f => filePath === f || filePath.endsWith('/' + f) || filePath.endsWith(f));
|
|
71
|
-
const inGlobs = allowedGlobs.some(g => minimatch(filePath, g, { matchBase: true }));
|
|
72
|
-
return inExplicit || inGlobs;
|
|
73
|
-
};
|
|
74
|
-
const validation = await ProofValidator.validate(receipt, requiredProof, isAllowedFile, blobDir);
|
|
75
|
-
const receiptId = `rcpt_${uuidv4().replace(/-/g, '').slice(0, 16)}`;
|
|
76
|
-
const finalStatus = validation.valid ? receipt.status : 'failed';
|
|
77
|
-
await pointerStore.insertReceipt({
|
|
78
|
-
receiptId,
|
|
79
|
-
workOrderId: receipt.workOrderId,
|
|
80
|
-
status: finalStatus,
|
|
81
|
-
proofPointers: receipt.proofPointers,
|
|
82
|
-
changedFiles: receipt.changedFiles,
|
|
83
|
-
summary: receipt.summary,
|
|
84
|
-
});
|
|
85
|
-
await pointerStore.updateWorkOrderStatus(receipt.workOrderId, validation.valid ? (receipt.status === 'completed' ? 'completed' : 'failed') : 'failed');
|
|
86
|
-
return {
|
|
87
|
-
receiptId,
|
|
88
|
-
accepted: validation.valid,
|
|
89
|
-
workOrderId: receipt.workOrderId,
|
|
90
|
-
validation,
|
|
91
|
-
finalStatus,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=submit_receipt.js.map
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
export declare const createWorkOrderTool: {
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object";
|
|
6
|
-
properties: {
|
|
7
|
-
projectRoot: {
|
|
8
|
-
type: string;
|
|
9
|
-
description: string;
|
|
10
|
-
};
|
|
11
|
-
intent: {
|
|
12
|
-
type: string;
|
|
13
|
-
description: string;
|
|
14
|
-
};
|
|
15
|
-
allowedFiles: {
|
|
16
|
-
type: string;
|
|
17
|
-
items: {
|
|
18
|
-
type: string;
|
|
19
|
-
};
|
|
20
|
-
description: string;
|
|
21
|
-
};
|
|
22
|
-
allowedGlobs: {
|
|
23
|
-
type: string;
|
|
24
|
-
items: {
|
|
25
|
-
type: string;
|
|
26
|
-
};
|
|
27
|
-
description: string;
|
|
28
|
-
};
|
|
29
|
-
deniedGlobs: {
|
|
30
|
-
type: string;
|
|
31
|
-
items: {
|
|
32
|
-
type: string;
|
|
33
|
-
};
|
|
34
|
-
description: string;
|
|
35
|
-
};
|
|
36
|
-
requiredProof: {
|
|
37
|
-
type: string;
|
|
38
|
-
items: {
|
|
39
|
-
type: string;
|
|
40
|
-
properties: {
|
|
41
|
-
proofId: {
|
|
42
|
-
type: string;
|
|
43
|
-
};
|
|
44
|
-
schemaName: {
|
|
45
|
-
type: string;
|
|
46
|
-
description: string;
|
|
47
|
-
};
|
|
48
|
-
description: {
|
|
49
|
-
type: string;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
required: string[];
|
|
53
|
-
};
|
|
54
|
-
description: string;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
required: string[];
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
export declare function handleCreateWorkOrder(args: Record<string, unknown>): Promise<unknown>;
|
|
61
|
-
export declare const spawnWorkerTool: {
|
|
62
|
-
name: string;
|
|
63
|
-
description: string;
|
|
64
|
-
inputSchema: {
|
|
65
|
-
type: "object";
|
|
66
|
-
properties: {
|
|
67
|
-
projectRoot: {
|
|
68
|
-
type: string;
|
|
69
|
-
description: string;
|
|
70
|
-
};
|
|
71
|
-
workOrderId: {
|
|
72
|
-
type: string;
|
|
73
|
-
description: string;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
required: string[];
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
export declare function handleSpawnWorker(args: Record<string, unknown>): Promise<unknown>;
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { PointerStore } from '../../store/PointerStore.js';
|
|
2
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
3
|
-
export const createWorkOrderTool = {
|
|
4
|
-
name: 'create_work_order',
|
|
5
|
-
description: 'Creates a new Work Order defining intent, allowed file scope, and required verifiable proof. Returns the workOrderId and a manifestPointer for use with spawn_worker.',
|
|
6
|
-
inputSchema: {
|
|
7
|
-
type: 'object',
|
|
8
|
-
properties: {
|
|
9
|
-
projectRoot: { type: 'string', description: 'Absolute project root' },
|
|
10
|
-
intent: { type: 'string', description: 'Plain-language description of what the worker should do' },
|
|
11
|
-
allowedFiles: {
|
|
12
|
-
type: 'array',
|
|
13
|
-
items: { type: 'string' },
|
|
14
|
-
description: 'Explicit file paths (relative to projectRoot) the worker may read/write',
|
|
15
|
-
},
|
|
16
|
-
allowedGlobs: {
|
|
17
|
-
type: 'array',
|
|
18
|
-
items: { type: 'string' },
|
|
19
|
-
description: 'Glob patterns for allowed files',
|
|
20
|
-
},
|
|
21
|
-
deniedGlobs: {
|
|
22
|
-
type: 'array',
|
|
23
|
-
items: { type: 'string' },
|
|
24
|
-
description: 'Glob patterns that override allowedFiles/allowedGlobs',
|
|
25
|
-
},
|
|
26
|
-
requiredProof: {
|
|
27
|
-
type: 'array',
|
|
28
|
-
items: {
|
|
29
|
-
type: 'object',
|
|
30
|
-
properties: {
|
|
31
|
-
proofId: { type: 'string' },
|
|
32
|
-
schemaName: { type: 'string', description: 'e.g. test_report.v1, patch_hash' },
|
|
33
|
-
description: { type: 'string' },
|
|
34
|
-
},
|
|
35
|
-
required: ['proofId', 'schemaName', 'description'],
|
|
36
|
-
},
|
|
37
|
-
description: 'Machine-verifiable evidence the worker must provide',
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
required: ['projectRoot', 'intent', 'allowedFiles'],
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
export async function handleCreateWorkOrder(args) {
|
|
44
|
-
const projectRoot = args.projectRoot;
|
|
45
|
-
const intent = args.intent;
|
|
46
|
-
const allowedFiles = args.allowedFiles ?? [];
|
|
47
|
-
const allowedGlobs = args.allowedGlobs ?? [];
|
|
48
|
-
const deniedGlobs = args.deniedGlobs ?? [];
|
|
49
|
-
const requiredProof = args.requiredProof ?? [];
|
|
50
|
-
if (!projectRoot || !intent) {
|
|
51
|
-
throw new Error('projectRoot and intent are required');
|
|
52
|
-
}
|
|
53
|
-
const workOrderId = `wo_${uuidv4().replace(/-/g, '').slice(0, 16)}`;
|
|
54
|
-
const pointerStore = PointerStore.open(projectRoot);
|
|
55
|
-
await pointerStore.insertWorkOrder({
|
|
56
|
-
workOrderId,
|
|
57
|
-
intent,
|
|
58
|
-
allowedFiles: JSON.stringify(allowedFiles),
|
|
59
|
-
allowedGlobs: JSON.stringify(allowedGlobs),
|
|
60
|
-
deniedGlobs: JSON.stringify(deniedGlobs),
|
|
61
|
-
requiredProof: JSON.stringify(requiredProof),
|
|
62
|
-
status: 'pending',
|
|
63
|
-
createdAt: Date.now(),
|
|
64
|
-
});
|
|
65
|
-
return {
|
|
66
|
-
ok: true,
|
|
67
|
-
workOrderId,
|
|
68
|
-
intent,
|
|
69
|
-
allowedFiles,
|
|
70
|
-
allowedGlobs,
|
|
71
|
-
deniedGlobs,
|
|
72
|
-
requiredProof,
|
|
73
|
-
nextStep: `Call spawn_worker with workOrderId "${workOrderId}" to generate a DelegationRequest`,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
export const spawnWorkerTool = {
|
|
77
|
-
name: 'spawn_worker',
|
|
78
|
-
description: 'Generates a DelegationRequest from a Work Order. The Client Orchestrator uses this object to spawn an isolated Worker session. The MCP server does NOT spawn any subprocess.',
|
|
79
|
-
inputSchema: {
|
|
80
|
-
type: 'object',
|
|
81
|
-
properties: {
|
|
82
|
-
projectRoot: { type: 'string', description: 'Absolute project root' },
|
|
83
|
-
workOrderId: { type: 'string', description: 'ID returned by create_work_order' },
|
|
84
|
-
},
|
|
85
|
-
required: ['projectRoot', 'workOrderId'],
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
export async function handleSpawnWorker(args) {
|
|
89
|
-
const projectRoot = args.projectRoot;
|
|
90
|
-
const workOrderId = args.workOrderId;
|
|
91
|
-
if (!projectRoot || !workOrderId) {
|
|
92
|
-
throw new Error('projectRoot and workOrderId are required');
|
|
93
|
-
}
|
|
94
|
-
const pointerStore = PointerStore.open(projectRoot);
|
|
95
|
-
const row = pointerStore.getWorkOrder(workOrderId);
|
|
96
|
-
if (!row) {
|
|
97
|
-
throw new Error(`WorkOrderNotFound: ${workOrderId}`);
|
|
98
|
-
}
|
|
99
|
-
if (row.status === 'completed' || row.status === 'failed' || row.status === 'active') {
|
|
100
|
-
throw new Error(`WorkOrderClosed: ${workOrderId} is already ${row.status}`);
|
|
101
|
-
}
|
|
102
|
-
await pointerStore.updateWorkOrderStatus(workOrderId, 'active');
|
|
103
|
-
const delegationRequest = {
|
|
104
|
-
schemaVersion: '1.0.0',
|
|
105
|
-
workOrderId: row.workOrderId,
|
|
106
|
-
intent: row.intent,
|
|
107
|
-
sessionScope: {
|
|
108
|
-
allowedFiles: JSON.parse(row.allowedFiles),
|
|
109
|
-
allowedGlobs: JSON.parse(row.allowedGlobs),
|
|
110
|
-
deniedGlobs: JSON.parse(row.deniedGlobs),
|
|
111
|
-
},
|
|
112
|
-
requiredProof: JSON.parse(row.requiredProof),
|
|
113
|
-
instructions: [
|
|
114
|
-
`1. Call set_session_scope with workOrderId "${workOrderId}" before any file operations.`,
|
|
115
|
-
'2. Only read/write files within the sessionScope.',
|
|
116
|
-
'3. If you need a file outside scope, call yield_for_scope_expansion — do NOT proceed.',
|
|
117
|
-
'4. On completion, call submit_receipt with proof for every requiredProof entry.',
|
|
118
|
-
],
|
|
119
|
-
};
|
|
120
|
-
return {
|
|
121
|
-
ok: true,
|
|
122
|
-
delegationRequest,
|
|
123
|
-
note: 'The Client Orchestrator must spawn the Worker session using this DelegationRequest. The MCP server does not spawn subprocesses.',
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
//# sourceMappingURL=work_orders.js.map
|