vibe-splain 3.4.2 → 3.5.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 +5 -5
- package/dist/hook.js +0 -0
- package/dist/index.js +1780 -3520
- package/dist/mcp/server.js +1 -24
- package/package.json +2 -2
- 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/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-entry.d.ts +0 -2
- package/dist/hook-entry.js +0 -8
- 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/prepareTaskContext.d.ts +0 -38
- package/dist/mcp/tools/prepareTaskContext.js +0 -93
- 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
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { writeFile, rename, mkdir } from 'fs/promises';
|
|
2
|
-
import { join, dirname } from 'path';
|
|
3
|
-
import { SessionScope, ScopeViolation } from '../SessionScope.js';
|
|
4
|
-
import { hashFile, BlobStore } from '../../store/BlobStore.js';
|
|
5
|
-
import { PointerStore } from '../../store/PointerStore.js';
|
|
6
|
-
import { applyBudgetGuard } from '../BudgetGuard.js';
|
|
7
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
8
|
-
export class StalePatchError extends Error {
|
|
9
|
-
filePath;
|
|
10
|
-
expectedHash;
|
|
11
|
-
actualHash;
|
|
12
|
-
constructor(filePath, expectedHash, actualHash) {
|
|
13
|
-
super(`StalePatchError: ${filePath} hash mismatch — expected ${expectedHash}, got ${actualHash}. ` +
|
|
14
|
-
'File was modified since the expectedPrePatchHash was computed. Re-read the file and regenerate the patch.');
|
|
15
|
-
this.filePath = filePath;
|
|
16
|
-
this.expectedHash = expectedHash;
|
|
17
|
-
this.actualHash = actualHash;
|
|
18
|
-
this.name = 'StalePatchError';
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export const applyPatchTool = {
|
|
22
|
-
name: 'apply_patch',
|
|
23
|
-
description: 'Applies a text patch to a file within the active workOrder scope. Requires expectedPrePatchHash to prevent stale-patch corruption. Records pre- and post-patch hashes.',
|
|
24
|
-
inputSchema: {
|
|
25
|
-
type: 'object',
|
|
26
|
-
properties: {
|
|
27
|
-
projectRoot: { type: 'string', description: 'Absolute project root' },
|
|
28
|
-
filePath: { type: 'string', description: 'Path relative to projectRoot' },
|
|
29
|
-
newContent: { type: 'string', description: 'Full new content of the file after the patch' },
|
|
30
|
-
expectedPrePatchHash: {
|
|
31
|
-
type: 'string',
|
|
32
|
-
description: 'sha256:<hex> hash of the file BEFORE patching. Obtain via hashFile or the sourceHash from get_file_skeleton.',
|
|
33
|
-
},
|
|
34
|
-
scanId: { type: 'string', description: 'Current scan ID for pointer registration' },
|
|
35
|
-
},
|
|
36
|
-
required: ['projectRoot', 'filePath', 'newContent', 'expectedPrePatchHash', 'scanId'],
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
export async function handleApplyPatch(args) {
|
|
40
|
-
const projectRoot = args.projectRoot;
|
|
41
|
-
const filePath = args.filePath;
|
|
42
|
-
const newContent = args.newContent;
|
|
43
|
-
const expectedPrePatchHash = args.expectedPrePatchHash;
|
|
44
|
-
const scanId = args.scanId;
|
|
45
|
-
if (!projectRoot || !filePath || !newContent || !expectedPrePatchHash || !scanId) {
|
|
46
|
-
throw new Error('projectRoot, filePath, newContent, expectedPrePatchHash, and scanId are all required');
|
|
47
|
-
}
|
|
48
|
-
// 1. Scope enforcement
|
|
49
|
-
try {
|
|
50
|
-
SessionScope.enforce(filePath);
|
|
51
|
-
}
|
|
52
|
-
catch (e) {
|
|
53
|
-
if (e instanceof ScopeViolation)
|
|
54
|
-
throw e;
|
|
55
|
-
throw e;
|
|
56
|
-
}
|
|
57
|
-
const absolutePath = filePath.startsWith('/') ? filePath : join(projectRoot, filePath);
|
|
58
|
-
// 2. Preimage hash check
|
|
59
|
-
let actualPreHash;
|
|
60
|
-
try {
|
|
61
|
-
actualPreHash = await hashFile(absolutePath);
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
// File doesn't exist yet — for new files, expectedPrePatchHash must be 'sha256:new'
|
|
65
|
-
actualPreHash = 'sha256:new';
|
|
66
|
-
}
|
|
67
|
-
if (actualPreHash !== expectedPrePatchHash) {
|
|
68
|
-
throw new StalePatchError(filePath, expectedPrePatchHash, actualPreHash);
|
|
69
|
-
}
|
|
70
|
-
// 3. Atomic write
|
|
71
|
-
const dir = dirname(absolutePath);
|
|
72
|
-
await mkdir(dir, { recursive: true });
|
|
73
|
-
const tmpPath = absolutePath + `.tmp_${Date.now()}`;
|
|
74
|
-
await writeFile(tmpPath, newContent, 'utf8');
|
|
75
|
-
await rename(tmpPath, absolutePath);
|
|
76
|
-
// 4. Compute post-patch hash
|
|
77
|
-
const postPatchHash = await hashFile(absolutePath);
|
|
78
|
-
// 5. Record both hashes in blob store
|
|
79
|
-
const blobStore = new BlobStore(projectRoot);
|
|
80
|
-
const pointerStore = PointerStore.open(projectRoot);
|
|
81
|
-
const { blobPath } = await blobStore.writeAtomic(newContent);
|
|
82
|
-
const pointerId = `ptr_patch_${uuidv4().replace(/-/g, '').slice(0, 12)}`;
|
|
83
|
-
await pointerStore.insertPointer({
|
|
84
|
-
pointerId,
|
|
85
|
-
scanId,
|
|
86
|
-
artifactName: 'patch_record',
|
|
87
|
-
contentHash: postPatchHash,
|
|
88
|
-
blobPath,
|
|
89
|
-
schemaVersion: '1.0.0',
|
|
90
|
-
createdAt: Date.now(),
|
|
91
|
-
expiresAt: null,
|
|
92
|
-
});
|
|
93
|
-
const result = {
|
|
94
|
-
ok: true,
|
|
95
|
-
filePath,
|
|
96
|
-
prePatchHash: actualPreHash,
|
|
97
|
-
postPatchHash,
|
|
98
|
-
pointerId,
|
|
99
|
-
message: `Patch applied to ${filePath}`,
|
|
100
|
-
};
|
|
101
|
-
return await applyBudgetGuard(projectRoot, scanId, 'patch_record', result);
|
|
102
|
-
}
|
|
103
|
-
//# sourceMappingURL=apply_patch.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare const explainSpecialistScopeTool: {
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object";
|
|
6
|
-
properties: {
|
|
7
|
-
specialist_id: {
|
|
8
|
-
type: string;
|
|
9
|
-
description: string;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
required: string[];
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export declare function handleExplainSpecialistScope(args: Record<string, unknown>, options?: any): Promise<unknown>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { getSpecialistProfile, isSpecialistId } from '@vibe-splain/brain';
|
|
2
|
-
export const explainSpecialistScopeTool = {
|
|
3
|
-
name: 'vibe_explain_specialist_scope',
|
|
4
|
-
description: 'Explains the jurisdiction scope card and profile definitions for a given specialist ID.',
|
|
5
|
-
inputSchema: {
|
|
6
|
-
type: 'object',
|
|
7
|
-
properties: {
|
|
8
|
-
specialist_id: {
|
|
9
|
-
type: 'string',
|
|
10
|
-
description: 'Specialist ID to explain (control_flow | data_transform | integration_contracts | generic_repo)',
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
required: ['specialist_id'],
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
export async function handleExplainSpecialistScope(args, options = {}) {
|
|
17
|
-
const specialistId = args.specialist_id;
|
|
18
|
-
if (!specialistId)
|
|
19
|
-
throw new Error('specialist_id is required');
|
|
20
|
-
if (!isSpecialistId(specialistId)) {
|
|
21
|
-
throw new Error(`Invalid specialist ID: "${specialistId}". Must be one of: control_flow, data_transform, integration_contracts, generic_repo.`);
|
|
22
|
-
}
|
|
23
|
-
console.error(`[vibe-splain] Fetching scope profile for specialist: "${specialistId}"`);
|
|
24
|
-
const profile = getSpecialistProfile(specialistId);
|
|
25
|
-
return {
|
|
26
|
-
ok: true,
|
|
27
|
-
profile
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=explainSpecialistScope.js.map
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export declare const getCallChainTool: {
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object";
|
|
6
|
-
properties: {
|
|
7
|
-
projectRoot: {
|
|
8
|
-
type: string;
|
|
9
|
-
};
|
|
10
|
-
entrypointPath: {
|
|
11
|
-
type: string;
|
|
12
|
-
description: string;
|
|
13
|
-
};
|
|
14
|
-
maxDepth: {
|
|
15
|
-
type: string;
|
|
16
|
-
description: string;
|
|
17
|
-
};
|
|
18
|
-
targetActionKind: {
|
|
19
|
-
type: string;
|
|
20
|
-
description: string;
|
|
21
|
-
};
|
|
22
|
-
targetModel: {
|
|
23
|
-
type: string;
|
|
24
|
-
description: string;
|
|
25
|
-
};
|
|
26
|
-
targetOperation: {
|
|
27
|
-
type: string;
|
|
28
|
-
description: string;
|
|
29
|
-
};
|
|
30
|
-
targetFunctionName: {
|
|
31
|
-
type: string;
|
|
32
|
-
description: string;
|
|
33
|
-
};
|
|
34
|
-
includeTests: {
|
|
35
|
-
type: string;
|
|
36
|
-
description: string;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
required: string[];
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
export declare function handleGetCallChain(args: Record<string, unknown>): Promise<unknown>;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { traverseCallChain } from '@vibe-splain/brain';
|
|
2
|
-
export const getCallChainTool = {
|
|
3
|
-
name: 'get_call_chain',
|
|
4
|
-
description: `Trace how behavior is reached from an entrypoint by following function call edges through the codebase. Returns a step-by-step chain with exact function names, file paths, line numbers, action kinds, and evidence text. Every edge has a confidence level; unresolved edges are listed explicitly.
|
|
5
|
-
|
|
6
|
-
Use structured filters when you know the target:
|
|
7
|
-
targetModel + targetOperation: "where does Booking get created?"
|
|
8
|
-
targetActionKind: "where is auth enforced?"
|
|
9
|
-
targetFunctionName: "how is function X reached?"
|
|
10
|
-
No filter returns the full call tree up to maxDepth.
|
|
11
|
-
|
|
12
|
-
Run scan_project first — this tool reads from the generated action_bindings.json.`,
|
|
13
|
-
inputSchema: {
|
|
14
|
-
type: 'object',
|
|
15
|
-
properties: {
|
|
16
|
-
projectRoot: { type: 'string' },
|
|
17
|
-
entrypointPath: { type: 'string', description: 'Relative path to the entrypoint file' },
|
|
18
|
-
maxDepth: { type: 'number', description: 'Max traversal depth. Default 6, max 12.' },
|
|
19
|
-
targetActionKind: { type: 'string', description: 'Stop at this semantic action kind.' },
|
|
20
|
-
targetModel: { type: 'string', description: 'Stop at functions touching this model.' },
|
|
21
|
-
targetOperation: { type: 'string', description: 'Narrow targetModel to this operation.' },
|
|
22
|
-
targetFunctionName: { type: 'string', description: 'Stop at a specific function name.' },
|
|
23
|
-
includeTests: { type: 'boolean', description: 'Include test files in traversal. Default false.' },
|
|
24
|
-
},
|
|
25
|
-
required: ['projectRoot', 'entrypointPath'],
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
export async function handleGetCallChain(args) {
|
|
29
|
-
const projectRoot = args.projectRoot;
|
|
30
|
-
const entrypointPath = args.entrypointPath;
|
|
31
|
-
if (!projectRoot || !entrypointPath)
|
|
32
|
-
throw new Error('projectRoot and entrypointPath are required');
|
|
33
|
-
const getCallChainArgs = {
|
|
34
|
-
entrypointPath,
|
|
35
|
-
maxDepth: typeof args.maxDepth === 'number' ? args.maxDepth : undefined,
|
|
36
|
-
targetActionKind: typeof args.targetActionKind === 'string' ? args.targetActionKind : undefined,
|
|
37
|
-
targetModel: typeof args.targetModel === 'string' ? args.targetModel : undefined,
|
|
38
|
-
targetOperation: typeof args.targetOperation === 'string' ? args.targetOperation : undefined,
|
|
39
|
-
targetFunctionName: typeof args.targetFunctionName === 'string' ? args.targetFunctionName : undefined,
|
|
40
|
-
includeTests: typeof args.includeTests === 'boolean' ? args.includeTests : undefined,
|
|
41
|
-
};
|
|
42
|
-
try {
|
|
43
|
-
const result = await traverseCallChain(projectRoot, getCallChainArgs);
|
|
44
|
-
return result;
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
throw new Error(`get_call_chain failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=get_call_chain.js.map
|
|
@@ -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,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>;
|