vibe-splain 3.4.1 → 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.
Files changed (41) hide show
  1. package/README.md +26 -20
  2. package/dist/commands/hook.d.ts +9 -0
  3. package/dist/commands/hook.js +84 -0
  4. package/dist/commands/install.d.ts +5 -0
  5. package/dist/commands/install.js +58 -9
  6. package/dist/export/ExportOrchestrator.js +8 -6
  7. package/dist/export/renderers/AgentMarkdownRenderer.d.ts +1 -2
  8. package/dist/export/renderers/AgentMarkdownRenderer.js +1 -17
  9. package/dist/hook/preToolUse.d.ts +30 -0
  10. package/dist/hook/preToolUse.js +81 -0
  11. package/dist/hook.d.ts +1 -0
  12. package/dist/hook.js +337 -0
  13. package/dist/index.js +2336 -2825
  14. package/dist/mcp/server.js +1 -25
  15. package/dist/mcp/tools/hydration/get_evidence_slice.js +1 -3
  16. package/dist/mcp/tools/scan_project.d.ts +15 -0
  17. package/dist/mcp/tools/scan_project.js +16 -13
  18. package/dist/ui/index.html +3 -3
  19. package/package.json +2 -2
  20. package/dist/commands/bundle.d.ts +0 -4
  21. package/dist/commands/bundle.js +0 -68
  22. package/dist/commands/export.d.ts +0 -1
  23. package/dist/commands/export.js +0 -19
  24. package/dist/commands/gc.d.ts +0 -3
  25. package/dist/commands/gc.js +0 -59
  26. package/dist/commands/importBundle.d.ts +0 -4
  27. package/dist/commands/importBundle.js +0 -80
  28. package/dist/export/renderers/DeltaRenderer.d.ts +0 -6
  29. package/dist/export/renderers/DeltaRenderer.js +0 -22
  30. package/dist/mcp/tools/apply_patch.d.ts +0 -37
  31. package/dist/mcp/tools/apply_patch.js +0 -103
  32. package/dist/mcp/tools/get_call_chain.d.ts +0 -42
  33. package/dist/mcp/tools/get_call_chain.js +0 -50
  34. package/dist/mcp/tools/set_session_scope.d.ts +0 -19
  35. package/dist/mcp/tools/set_session_scope.js +0 -40
  36. package/dist/mcp/tools/submit_receipt.d.ts +0 -68
  37. package/dist/mcp/tools/submit_receipt.js +0 -94
  38. package/dist/mcp/tools/work_orders.d.ts +0 -79
  39. package/dist/mcp/tools/work_orders.js +0 -126
  40. package/dist/mcp/tools/yield_for_scope_expansion.d.ts +0 -29
  41. package/dist/mcp/tools/yield_for_scope_expansion.js +0 -59
@@ -11,14 +11,8 @@ import { handleGetStrategicOverview, getStrategicOverviewTool } from './tools/ge
11
11
  import { handleInspectPillar, inspectPillarTool } from './tools/inspect_pillar.js';
12
12
  import { handleGetWildDiscoveries, getWildDiscoveriesTool } from './tools/get_wild_discoveries.js';
13
13
  import { handleMarkStale, markStaleTool } from './tools/mark_stale.js';
14
- import { handleGetCallChain, getCallChainTool } from './tools/get_call_chain.js';
15
14
  import { handleGetFileSkeleton, getFileSkeletonTool } from './tools/get_file_skeleton.js';
16
15
  import { handleReadFile, readFileTool } from './tools/read_file.js';
17
- import { handleApplyPatch, applyPatchTool } from './tools/apply_patch.js';
18
- import { handleCreateWorkOrder, createWorkOrderTool, handleSpawnWorker, spawnWorkerTool } from './tools/work_orders.js';
19
- import { handleSubmitReceipt, submitReceiptTool } from './tools/submit_receipt.js';
20
- import { handleSetSessionScope, setSessionScopeTool } from './tools/set_session_scope.js';
21
- import { handleYieldForScopeExpansion, yieldForScopeExpansionTool } from './tools/yield_for_scope_expansion.js';
22
16
  import { handleGetStartHere, getStartHereTool } from './tools/hydration/get_start_here.js';
23
17
  import { handleGetProjectSummary, getProjectSummaryTool } from './tools/hydration/get_project_summary.js';
24
18
  import { handleGetEvidenceSlice, getEvidenceSliceTool } from './tools/hydration/get_evidence_slice.js';
@@ -30,7 +24,6 @@ const ALL_TOOLS = [
30
24
  getProjectMapTool,
31
25
  setProjectBriefTool,
32
26
  getFileContextTool,
33
- getCallChainTool,
34
27
  writeDecisionCardTool,
35
28
  getStrategicOverviewTool,
36
29
  inspectPillarTool,
@@ -42,21 +35,12 @@ const ALL_TOOLS = [
42
35
  getStartHereTool,
43
36
  getProjectSummaryTool,
44
37
  getEvidenceSliceTool,
45
- // Phase 3: Delegation & Proof
46
- createWorkOrderTool,
47
- spawnWorkerTool,
48
- applyPatchTool,
49
- submitReceiptTool,
50
- // Phase 4: Scope & Escalation
51
- setSessionScopeTool,
52
- yieldForScopeExpansionTool,
53
38
  ];
54
39
  const TOOL_HANDLERS = {
55
40
  scan_project: handleScanProject,
56
41
  get_project_map: handleGetProjectMap,
57
42
  set_project_brief: handleSetProjectBrief,
58
43
  get_file_context: handleGetFileContext,
59
- get_call_chain: handleGetCallChain,
60
44
  write_decision_card: handleWriteDecisionCard,
61
45
  get_strategic_overview: handleGetStrategicOverview,
62
46
  inspect_pillar: handleInspectPillar,
@@ -68,20 +52,12 @@ const TOOL_HANDLERS = {
68
52
  get_start_here: handleGetStartHere,
69
53
  get_project_summary: handleGetProjectSummary,
70
54
  get_evidence_slice: handleGetEvidenceSlice,
71
- // Phase 3
72
- create_work_order: handleCreateWorkOrder,
73
- spawn_worker: handleSpawnWorker,
74
- apply_patch: handleApplyPatch,
75
- submit_receipt: handleSubmitReceipt,
76
- // Phase 4
77
- set_session_scope: handleSetSessionScope,
78
- yield_for_scope_expansion: handleYieldForScopeExpansion,
79
55
  };
80
56
  export async function startMCPServer(options = {}) {
81
57
  // Initialize Tree-Sitter WASM once at startup
82
58
  await initParser();
83
59
  console.error('[vibe-splain] Tree-Sitter parser initialized');
84
- const server = new Server({ name: 'vibe-splain', version: '3.0.0' }, { capabilities: { tools: {}, prompts: {} } });
60
+ const server = new Server({ name: 'vibe-splain', version: '3.5.0' }, { capabilities: { tools: {}, prompts: {} } });
85
61
  // Register prompts
86
62
  server.setRequestHandler(ListPromptsRequestSchema, async () => ({
87
63
  prompts: [
@@ -27,8 +27,7 @@ export async function handleGetEvidenceSlice(args) {
27
27
  // 1. Verify pointer, lifetime, hash
28
28
  const { content, row } = await hydratePointer(projectRoot, pointerId);
29
29
  const rawText = content.toString('utf8');
30
- // 2. Scope enforcement for file-type artifacts: if a Worker scope is active,
31
- // file_read and file_skeleton blobs embed the source filePath — enforce it.
30
+ // Scope enforcement: if a Worker scope is active, enforce it for file-type artifacts
32
31
  const scope = SessionScope.get();
33
32
  if (scope && (row.artifactName === 'file_read' || row.artifactName === 'file_skeleton')) {
34
33
  try {
@@ -38,7 +37,6 @@ export async function handleGetEvidenceSlice(args) {
38
37
  }
39
38
  }
40
39
  catch (e) {
41
- // If it's a ScopeViolation, re-throw; JSON parse failures are ignored.
42
40
  if (e.name === 'ScopeViolation')
43
41
  throw e;
44
42
  }
@@ -1,3 +1,5 @@
1
+ import { scanProject } from '@vibe-splain/brain';
2
+ import type { Dossier } from '@vibe-splain/brain';
1
3
  export declare const scanProjectTool: {
2
4
  name: string;
3
5
  description: string;
@@ -12,4 +14,17 @@ export declare const scanProjectTool: {
12
14
  required: string[];
13
15
  };
14
16
  };
17
+ /**
18
+ * Shared scan core: run the brain pipeline, build the dossier, and write the
19
+ * artifact bundle. Both the MCP `scan_project` tool and the headless CLI `scan`
20
+ * command call this — there is exactly one scan path. Side-effects beyond
21
+ * artifact writing (e.g. the staleness watcher) are the caller's concern.
22
+ */
23
+ export interface ScanRun {
24
+ result: Awaited<ReturnType<typeof scanProject>>;
25
+ dossier: Dossier;
26
+ scanId: string;
27
+ manifestPointer: unknown;
28
+ }
29
+ export declare function performScan(projectRoot: string, options?: any): Promise<ScanRun>;
15
30
  export declare function handleScanProject(args: Record<string, unknown>, options?: any): Promise<unknown>;
@@ -15,11 +15,7 @@ export const scanProjectTool = {
15
15
  required: ['projectRoot'],
16
16
  },
17
17
  };
18
- export async function handleScanProject(args, options = {}) {
19
- const projectRoot = args.projectRoot;
20
- if (!projectRoot)
21
- throw new Error('projectRoot is required');
22
- console.error(`[vibe-splain] Scanning project: ${projectRoot}`);
18
+ export async function performScan(projectRoot, options = {}) {
23
19
  const result = await scanProject(projectRoot);
24
20
  // Preserve any existing cards; replace the structural map every scan.
25
21
  const existing = await readDossier(projectRoot);
@@ -54,17 +50,25 @@ export async function handleScanProject(args, options = {}) {
54
50
  budget: options.budget ? parseInt(options.budget, 10) : undefined,
55
51
  scope: options.scope,
56
52
  }, result.store, result.graph, scanId);
57
- // Watch the real-source files for staleness.
58
- await startWatcher(projectRoot, result.files.map(f => f.path));
53
+ return { result, dossier, scanId, manifestPointer };
54
+ }
55
+ export async function handleScanProject(args, options = {}) {
56
+ const projectRoot = args.projectRoot;
57
+ if (!projectRoot)
58
+ throw new Error('projectRoot is required');
59
+ console.error(`[vibe-splain] Scanning project: ${projectRoot}`);
60
+ const { result, scanId, manifestPointer } = await performScan(projectRoot, options);
61
+ // Watch the real-source files for staleness. MCP serve mode keeps this alive
62
+ // for the session; headless callers pass watch:false so the persistent
63
+ // chokidar watcher never pins the event loop open and the process can exit.
64
+ if (options.watch !== false) {
65
+ await startWatcher(projectRoot, result.files.map(f => f.path));
66
+ }
59
67
  console.error(`[vibe-splain] Scan complete. ${result.totalFilesScanned} files, ${result.realSourceCount} real-source, ${result.wildCandidates.length} wild candidates.`);
60
68
  const validation = result.validation ?? { passed: true, errors: 0, warnings: 0, reportPath: '.vibe-splainer/validation_report.json' };
61
- let statusMsg = 'Scan complete.';
62
- if (!validation.passed) {
63
- statusMsg = `SCAN QUALITY WARNING: ${validation.errors} errors and ${validation.warnings} warnings found in validation report. Delta Engine automation may be blocked.`;
64
- }
65
69
  return {
66
70
  ok: true,
67
- message: statusMsg,
71
+ message: 'Scan complete.',
68
72
  scanId,
69
73
  manifestPointer,
70
74
  validation: result.fullValidationReport || {
@@ -75,7 +79,6 @@ export async function handleScanProject(args, options = {}) {
75
79
  },
76
80
  artifacts: {
77
81
  analysis: '.vibe-splainer/analysis.json',
78
- deltaTargets: '.vibe-splainer/delta_targets.json',
79
82
  dossier: '.vibe-splainer/dossier.json',
80
83
  graph: '.vibe-splainer/graph.json',
81
84
  html: '.vibe-splainer/ui/index.html',