@synergenius/flow-weaver-pack-weaver 0.9.0 → 0.9.3
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/dist/bot/ai-client.d.ts +22 -2
- package/dist/bot/ai-client.d.ts.map +1 -1
- package/dist/bot/ai-client.js +168 -20
- package/dist/bot/ai-client.js.map +1 -1
- package/dist/bot/assistant-core.d.ts +25 -0
- package/dist/bot/assistant-core.d.ts.map +1 -0
- package/dist/bot/assistant-core.js +265 -0
- package/dist/bot/assistant-core.js.map +1 -0
- package/dist/bot/assistant-tools.d.ts +9 -0
- package/dist/bot/assistant-tools.d.ts.map +1 -0
- package/dist/bot/assistant-tools.js +602 -0
- package/dist/bot/assistant-tools.js.map +1 -0
- package/dist/bot/audit-logger.d.ts.map +1 -1
- package/dist/bot/audit-logger.js +9 -5
- package/dist/bot/audit-logger.js.map +1 -1
- package/dist/bot/bot-manager.d.ts +49 -0
- package/dist/bot/bot-manager.d.ts.map +1 -0
- package/dist/bot/bot-manager.js +279 -0
- package/dist/bot/bot-manager.js.map +1 -0
- package/dist/bot/child-process-tracker.d.ts +6 -0
- package/dist/bot/child-process-tracker.d.ts.map +1 -0
- package/dist/bot/child-process-tracker.js +35 -0
- package/dist/bot/child-process-tracker.js.map +1 -0
- package/dist/bot/cli-provider.d.ts.map +1 -1
- package/dist/bot/cli-provider.js +13 -8
- package/dist/bot/cli-provider.js.map +1 -1
- package/dist/bot/conversation-store.d.ts +40 -0
- package/dist/bot/conversation-store.d.ts.map +1 -0
- package/dist/bot/conversation-store.js +182 -0
- package/dist/bot/conversation-store.js.map +1 -0
- package/dist/bot/error-guide.d.ts +10 -0
- package/dist/bot/error-guide.d.ts.map +1 -0
- package/dist/bot/error-guide.js +34 -0
- package/dist/bot/error-guide.js.map +1 -0
- package/dist/bot/knowledge-store.d.ts +17 -0
- package/dist/bot/knowledge-store.d.ts.map +1 -0
- package/dist/bot/knowledge-store.js +53 -0
- package/dist/bot/knowledge-store.js.map +1 -0
- package/dist/bot/retry-utils.d.ts +19 -0
- package/dist/bot/retry-utils.d.ts.map +1 -0
- package/dist/bot/retry-utils.js +64 -0
- package/dist/bot/retry-utils.js.map +1 -0
- package/dist/bot/runner.d.ts.map +1 -1
- package/dist/bot/runner.js +12 -1
- package/dist/bot/runner.js.map +1 -1
- package/dist/bot/session-state.d.ts.map +1 -1
- package/dist/bot/session-state.js +3 -1
- package/dist/bot/session-state.js.map +1 -1
- package/dist/bot/steering.js +1 -1
- package/dist/bot/steering.js.map +1 -1
- package/dist/bot/step-executor.d.ts +10 -5
- package/dist/bot/step-executor.d.ts.map +1 -1
- package/dist/bot/step-executor.js +252 -3
- package/dist/bot/step-executor.js.map +1 -1
- package/dist/bot/system-prompt.d.ts +1 -1
- package/dist/bot/system-prompt.d.ts.map +1 -1
- package/dist/bot/system-prompt.js +69 -43
- package/dist/bot/system-prompt.js.map +1 -1
- package/dist/bot/task-decomposer.d.ts +24 -0
- package/dist/bot/task-decomposer.d.ts.map +1 -0
- package/dist/bot/task-decomposer.js +75 -0
- package/dist/bot/task-decomposer.js.map +1 -0
- package/dist/bot/task-queue.d.ts +17 -4
- package/dist/bot/task-queue.d.ts.map +1 -1
- package/dist/bot/task-queue.js +95 -4
- package/dist/bot/task-queue.js.map +1 -1
- package/dist/bot/terminal-renderer.d.ts +60 -0
- package/dist/bot/terminal-renderer.d.ts.map +1 -0
- package/dist/bot/terminal-renderer.js +205 -0
- package/dist/bot/terminal-renderer.js.map +1 -0
- package/dist/bot/types.d.ts +7 -0
- package/dist/bot/types.d.ts.map +1 -1
- package/dist/bot/weaver-tools.d.ts +18 -0
- package/dist/bot/weaver-tools.d.ts.map +1 -0
- package/dist/bot/weaver-tools.js +215 -0
- package/dist/bot/weaver-tools.js.map +1 -0
- package/dist/cli-bridge.d.ts.map +1 -1
- package/dist/cli-bridge.js +5 -1
- package/dist/cli-bridge.js.map +1 -1
- package/dist/cli-handlers.d.ts +13 -1
- package/dist/cli-handlers.d.ts.map +1 -1
- package/dist/cli-handlers.js +616 -48
- package/dist/cli-handlers.js.map +1 -1
- package/dist/mcp-tools.js +2 -2
- package/dist/mcp-tools.js.map +1 -1
- package/dist/node-types/abort-task.d.ts.map +1 -1
- package/dist/node-types/abort-task.js +4 -3
- package/dist/node-types/abort-task.js.map +1 -1
- package/dist/node-types/agent-execute.d.ts +38 -0
- package/dist/node-types/agent-execute.d.ts.map +1 -0
- package/dist/node-types/agent-execute.js +256 -0
- package/dist/node-types/agent-execute.js.map +1 -0
- package/dist/node-types/bot-report.d.ts +5 -3
- package/dist/node-types/bot-report.d.ts.map +1 -1
- package/dist/node-types/bot-report.js +39 -7
- package/dist/node-types/bot-report.js.map +1 -1
- package/dist/node-types/build-context.d.ts +3 -3
- package/dist/node-types/build-context.d.ts.map +1 -1
- package/dist/node-types/build-context.js +108 -24
- package/dist/node-types/build-context.js.map +1 -1
- package/dist/node-types/detect-provider.d.ts +2 -2
- package/dist/node-types/detect-provider.d.ts.map +1 -1
- package/dist/node-types/detect-provider.js +3 -1
- package/dist/node-types/detect-provider.js.map +1 -1
- package/dist/node-types/exec-validate-retry.d.ts.map +1 -1
- package/dist/node-types/exec-validate-retry.js +43 -6
- package/dist/node-types/exec-validate-retry.js.map +1 -1
- package/dist/node-types/execute-plan.d.ts.map +1 -1
- package/dist/node-types/execute-plan.js +31 -8
- package/dist/node-types/execute-plan.js.map +1 -1
- package/dist/node-types/execute-target.d.ts.map +1 -1
- package/dist/node-types/execute-target.js +3 -1
- package/dist/node-types/execute-target.js.map +1 -1
- package/dist/node-types/fix-errors.d.ts.map +1 -1
- package/dist/node-types/fix-errors.js +21 -5
- package/dist/node-types/fix-errors.js.map +1 -1
- package/dist/node-types/genesis-observe.d.ts.map +1 -1
- package/dist/node-types/genesis-observe.js +3 -1
- package/dist/node-types/genesis-observe.js.map +1 -1
- package/dist/node-types/genesis-report.js +4 -1
- package/dist/node-types/genesis-report.js.map +1 -1
- package/dist/node-types/git-ops.d.ts.map +1 -1
- package/dist/node-types/git-ops.js +98 -4
- package/dist/node-types/git-ops.js.map +1 -1
- package/dist/node-types/index.d.ts +2 -0
- package/dist/node-types/index.d.ts.map +1 -1
- package/dist/node-types/index.js +2 -0
- package/dist/node-types/index.js.map +1 -1
- package/dist/node-types/load-config.d.ts +2 -2
- package/dist/node-types/load-config.d.ts.map +1 -1
- package/dist/node-types/load-config.js.map +1 -1
- package/dist/node-types/plan-task.d.ts.map +1 -1
- package/dist/node-types/plan-task.js +14 -2
- package/dist/node-types/plan-task.js.map +1 -1
- package/dist/node-types/read-workflow.js +8 -2
- package/dist/node-types/read-workflow.js.map +1 -1
- package/dist/node-types/receive-task.d.ts.map +1 -1
- package/dist/node-types/receive-task.js +35 -26
- package/dist/node-types/receive-task.js.map +1 -1
- package/dist/node-types/send-notify.js +2 -1
- package/dist/node-types/send-notify.js.map +1 -1
- package/dist/node-types/validate-gate.d.ts +18 -0
- package/dist/node-types/validate-gate.d.ts.map +1 -0
- package/dist/node-types/validate-gate.js +96 -0
- package/dist/node-types/validate-gate.js.map +1 -0
- package/dist/workflows/genesis-task.d.ts +20 -12
- package/dist/workflows/genesis-task.d.ts.map +1 -1
- package/dist/workflows/genesis-task.js +20 -12
- package/dist/workflows/genesis-task.js.map +1 -1
- package/dist/workflows/weaver-agent.d.ts +35 -0
- package/dist/workflows/weaver-agent.d.ts.map +1 -0
- package/dist/workflows/weaver-agent.js +777 -0
- package/dist/workflows/weaver-agent.js.map +1 -0
- package/dist/workflows/weaver-bot-batch.d.ts +19 -26
- package/dist/workflows/weaver-bot-batch.d.ts.map +1 -1
- package/dist/workflows/weaver-bot-batch.js +1043 -27
- package/dist/workflows/weaver-bot-batch.js.map +1 -1
- package/dist/workflows/weaver-bot.d.ts +21 -35
- package/dist/workflows/weaver-bot.d.ts.map +1 -1
- package/dist/workflows/weaver-bot.js +1119 -36
- package/dist/workflows/weaver-bot.js.map +1 -1
- package/flowweaver.manifest.json +21 -1
- package/package.json +5 -2
- package/src/bot/ai-client.ts +180 -19
- package/src/bot/assistant-core.ts +306 -0
- package/src/bot/assistant-tools.ts +605 -0
- package/src/bot/audit-logger.ts +6 -5
- package/src/bot/bot-manager.ts +293 -0
- package/src/bot/child-process-tracker.ts +40 -0
- package/src/bot/cli-provider.ts +13 -8
- package/src/bot/conversation-store.ts +222 -0
- package/src/bot/error-guide.ts +34 -0
- package/src/bot/knowledge-store.ts +59 -0
- package/src/bot/retry-utils.ts +76 -0
- package/src/bot/runner.ts +12 -1
- package/src/bot/session-state.ts +2 -1
- package/src/bot/steering.ts +1 -1
- package/src/bot/step-executor.ts +313 -5
- package/src/bot/system-prompt.ts +70 -47
- package/src/bot/task-decomposer.ts +100 -0
- package/src/bot/task-queue.ts +113 -7
- package/src/bot/terminal-renderer.ts +241 -0
- package/src/bot/types.ts +8 -0
- package/src/bot/weaver-tools.ts +225 -0
- package/src/cli-bridge.ts +7 -1
- package/src/cli-handlers.ts +625 -48
- package/src/mcp-tools.ts +2 -2
- package/src/node-types/abort-task.ts +5 -4
- package/src/node-types/agent-execute.ts +306 -0
- package/src/node-types/bot-report.ts +40 -9
- package/src/node-types/build-context.ts +112 -25
- package/src/node-types/detect-provider.ts +4 -3
- package/src/node-types/exec-validate-retry.ts +47 -8
- package/src/node-types/execute-plan.ts +32 -8
- package/src/node-types/execute-target.ts +2 -1
- package/src/node-types/fix-errors.ts +20 -5
- package/src/node-types/genesis-observe.ts +2 -1
- package/src/node-types/genesis-report.ts +1 -1
- package/src/node-types/git-ops.ts +93 -4
- package/src/node-types/index.ts +2 -0
- package/src/node-types/load-config.ts +3 -3
- package/src/node-types/plan-task.ts +15 -3
- package/src/node-types/read-workflow.ts +2 -2
- package/src/node-types/receive-task.ts +31 -26
- package/src/node-types/send-notify.ts +1 -1
- package/src/node-types/validate-gate.ts +112 -0
- package/src/workflows/genesis-task.ts +20 -12
- package/src/workflows/weaver-agent.ts +799 -0
- package/src/workflows/weaver-bot-batch.ts +1049 -27
- package/src/workflows/weaver-bot.ts +1123 -36
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Weaver-specific tool definitions and executor.
|
|
3
|
+
*
|
|
4
|
+
* These are the tools the weaver bot uses: validate, read_file, patch_file,
|
|
5
|
+
* run_shell, list_files, write_file. Tool execution delegates to step-executor
|
|
6
|
+
* with all safety guards (path traversal, shrink detection, blocked commands).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { execFileSync } from 'node:child_process';
|
|
10
|
+
import { executeStep } from './step-executor.js';
|
|
11
|
+
import type { ToolDefinition } from '@synergenius/flow-weaver/agent';
|
|
12
|
+
|
|
13
|
+
export const WEAVER_TOOLS: ToolDefinition[] = [
|
|
14
|
+
{
|
|
15
|
+
name: 'validate',
|
|
16
|
+
description: 'Run flow-weaver validate on a workflow file. Returns JSON with errors and warnings. Use this FIRST to discover issues, and AFTER patching to confirm fixes.',
|
|
17
|
+
inputSchema: { type: 'object', properties: { file: { type: 'string', description: 'Path to the workflow file to validate' } }, required: ['file'] },
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'read_file',
|
|
21
|
+
description: 'Read a file and return its full contents. Use this to understand file structure before patching.',
|
|
22
|
+
inputSchema: { type: 'object', properties: { file: { type: 'string', description: 'Path to the file to read' } }, required: ['file'] },
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'patch_file',
|
|
26
|
+
description: 'Apply surgical find-and-replace patches to a file. Each patch must have exact "find" and "replace" strings. Preferred over write_file for modifications.',
|
|
27
|
+
inputSchema: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
file: { type: 'string', description: 'Path to the file to patch' },
|
|
31
|
+
patches: {
|
|
32
|
+
type: 'array',
|
|
33
|
+
items: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
find: { type: 'string', description: 'Exact string to find' },
|
|
37
|
+
replace: { type: 'string', description: 'String to replace with' },
|
|
38
|
+
},
|
|
39
|
+
required: ['find', 'replace'],
|
|
40
|
+
},
|
|
41
|
+
description: 'Array of find/replace patches',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
required: ['file', 'patches'],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'run_shell',
|
|
49
|
+
description: 'Execute a shell command and return output. Use for: npx flow-weaver validate, git status, etc. Blocked: rm -rf, git push, sudo.',
|
|
50
|
+
inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'Shell command to execute' } }, required: ['command'] },
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'list_files',
|
|
54
|
+
description: 'List files in a directory, optionally filtered by regex pattern.',
|
|
55
|
+
inputSchema: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: {
|
|
58
|
+
directory: { type: 'string', description: 'Directory to list' },
|
|
59
|
+
pattern: { type: 'string', description: 'Optional regex filter pattern' },
|
|
60
|
+
},
|
|
61
|
+
required: ['directory'],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'write_file',
|
|
66
|
+
description: 'Write content to a file (creates or overwrites). Use patch_file instead for modifications to existing files.',
|
|
67
|
+
inputSchema: {
|
|
68
|
+
type: 'object',
|
|
69
|
+
properties: {
|
|
70
|
+
file: { type: 'string', description: 'Path to the file to write' },
|
|
71
|
+
content: { type: 'string', description: 'Complete file content' },
|
|
72
|
+
},
|
|
73
|
+
required: ['file', 'content'],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'web_fetch',
|
|
78
|
+
description: 'Fetch HTTP content. Returns text body (max 10KB).',
|
|
79
|
+
inputSchema: { type: 'object', properties: { url: { type: 'string' }, method: { type: 'string', enum: ['GET', 'POST'] } }, required: ['url'] },
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'tsc_check',
|
|
83
|
+
description: 'Run TypeScript compiler check (no emit). Returns errors if any.',
|
|
84
|
+
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'run_tests',
|
|
88
|
+
description: 'Run project tests. Returns structured results with pass/fail counts.',
|
|
89
|
+
inputSchema: { type: 'object', properties: { pattern: { type: 'string', description: 'Test file pattern (optional)' } }, required: [] },
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'ask_user',
|
|
93
|
+
description: 'Ask the user a question and wait for response. Use when you need a decision.',
|
|
94
|
+
inputSchema: { type: 'object', properties: { question: { type: 'string' } }, required: ['question'] },
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'learn',
|
|
98
|
+
description: 'Store a fact for future tasks. Key should be descriptive (e.g. "file:src/agent.ts:port-issue").',
|
|
99
|
+
inputSchema: { type: 'object', properties: { key: { type: 'string' }, value: { type: 'string' } }, required: ['key', 'value'] },
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'recall',
|
|
103
|
+
description: 'Look up stored knowledge. Returns matching entries.',
|
|
104
|
+
inputSchema: { type: 'object', properties: { query: { type: 'string' } }, required: ['query'] },
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
|
|
108
|
+
/** Map tool names to step-executor operations. */
|
|
109
|
+
const OPERATION_MAP: Record<string, string> = {
|
|
110
|
+
validate: 'run-shell',
|
|
111
|
+
read_file: 'read-file',
|
|
112
|
+
patch_file: 'patch-file',
|
|
113
|
+
run_shell: 'run-shell',
|
|
114
|
+
list_files: 'list-files',
|
|
115
|
+
write_file: 'write-file',
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Execute a weaver tool call. Delegates to step-executor with safety guards.
|
|
120
|
+
* Bound to a specific project directory via closure.
|
|
121
|
+
*/
|
|
122
|
+
export function createWeaverExecutor(projectDir: string) {
|
|
123
|
+
return async (
|
|
124
|
+
name: string,
|
|
125
|
+
args: Record<string, unknown>,
|
|
126
|
+
): Promise<{ result: string; isError: boolean }> => {
|
|
127
|
+
// Handle new tools that bypass step-executor
|
|
128
|
+
switch (name) {
|
|
129
|
+
case 'web_fetch': {
|
|
130
|
+
const url = String(args.url);
|
|
131
|
+
// Safety: block localhost, internal IPs
|
|
132
|
+
if (/localhost|127\.0\.0\.1|0\.0\.0\.0|10\.\d|172\.(1[6-9]|2\d|3[01])\.|192\.168\./i.test(url)) {
|
|
133
|
+
return { result: 'Blocked: cannot fetch internal/localhost URLs.', isError: true };
|
|
134
|
+
}
|
|
135
|
+
const resp = await fetch(url, { method: (args.method as string) ?? 'GET', signal: AbortSignal.timeout(15_000) });
|
|
136
|
+
const text = await resp.text();
|
|
137
|
+
return { result: text.slice(0, 10_000), isError: !resp.ok };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
case 'tsc_check': {
|
|
141
|
+
try {
|
|
142
|
+
const output = execFileSync('npx', ['tsc', '--noEmit', '--pretty'], { cwd: projectDir, encoding: 'utf-8', timeout: 60_000, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
143
|
+
return { result: output.trim() || 'No TypeScript errors.', isError: false };
|
|
144
|
+
} catch (err: any) {
|
|
145
|
+
return { result: (err.stdout ?? err.message ?? '').slice(0, 5000), isError: true };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
case 'run_tests': {
|
|
150
|
+
try {
|
|
151
|
+
const pattern = args.pattern ? String(args.pattern) : '';
|
|
152
|
+
const testArgs = ['vitest', 'run', '--reporter', 'json'];
|
|
153
|
+
if (pattern) testArgs.push(pattern);
|
|
154
|
+
const output = execFileSync('npx', testArgs, { cwd: projectDir, encoding: 'utf-8', timeout: 120_000, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
155
|
+
try {
|
|
156
|
+
const json = JSON.parse(output);
|
|
157
|
+
const passed = json.numPassedTests ?? 0;
|
|
158
|
+
const failed = json.numFailedTests ?? 0;
|
|
159
|
+
const failures = (json.testResults ?? []).filter((t: any) => t.status === 'failed').map((t: any) => t.name).slice(0, 10);
|
|
160
|
+
return { result: JSON.stringify({ passed, failed, total: passed + failed, failures }), isError: failed > 0 };
|
|
161
|
+
} catch {
|
|
162
|
+
return { result: output.slice(0, 5000), isError: false };
|
|
163
|
+
}
|
|
164
|
+
} catch (err: any) {
|
|
165
|
+
return { result: (err.stdout ?? err.stderr ?? err.message ?? '').slice(0, 5000), isError: true };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
case 'ask_user': {
|
|
170
|
+
const question = String(args.question);
|
|
171
|
+
if (process.env.WEAVER_AUTO_APPROVE) {
|
|
172
|
+
return { result: '(Auto-approved — no user input available in autonomous mode)', isError: false };
|
|
173
|
+
}
|
|
174
|
+
// In interactive mode, prompt via readline
|
|
175
|
+
const readline = await import('node:readline');
|
|
176
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
177
|
+
const answer = await new Promise<string>((resolve) => {
|
|
178
|
+
rl.question(`\n Bot asks: ${question}\n > `, (ans) => { rl.close(); resolve(ans); });
|
|
179
|
+
});
|
|
180
|
+
return { result: answer || '(no answer)', isError: false };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
case 'learn': {
|
|
184
|
+
const { KnowledgeStore } = await import('./knowledge-store.js');
|
|
185
|
+
const store = new KnowledgeStore(projectDir);
|
|
186
|
+
store.learn(String(args.key), String(args.value), 'bot');
|
|
187
|
+
return { result: `Learned: ${args.key}`, isError: false };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
case 'recall': {
|
|
191
|
+
const { KnowledgeStore } = await import('./knowledge-store.js');
|
|
192
|
+
const store = new KnowledgeStore(projectDir);
|
|
193
|
+
const entries = store.recall(String(args.query));
|
|
194
|
+
if (entries.length === 0) return { result: 'No knowledge found.', isError: false };
|
|
195
|
+
return { result: entries.map(e => `${e.key}: ${e.value}`).join('\n'), isError: false };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
default:
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Existing step-executor-based tools
|
|
203
|
+
const operation = OPERATION_MAP[name];
|
|
204
|
+
if (!operation) {
|
|
205
|
+
return { result: `Unknown tool: ${name}`, isError: true };
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Transform validate tool to run-shell with flow-weaver validate command
|
|
209
|
+
let stepArgs = { ...args };
|
|
210
|
+
if (name === 'validate') {
|
|
211
|
+
stepArgs = { command: `npx flow-weaver validate ${args.file} --json` };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
try {
|
|
215
|
+
const result = await executeStep({ operation, args: stepArgs }, projectDir);
|
|
216
|
+
if (result.blocked) {
|
|
217
|
+
return { result: result.blockReason ?? 'Blocked by safety guard', isError: true };
|
|
218
|
+
}
|
|
219
|
+
return { result: result.output ?? 'Done', isError: false };
|
|
220
|
+
} catch (err: unknown) {
|
|
221
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
222
|
+
return { result: msg, isError: true };
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
package/src/cli-bridge.ts
CHANGED
|
@@ -3,7 +3,9 @@ import {
|
|
|
3
3
|
handleRun, handleHistory, handleCosts, handleWatch,
|
|
4
4
|
handleCron, handlePipeline, handleDashboard, handleProviders,
|
|
5
5
|
handleEject, handleBot, handleSession, handleSteer, handleQueue,
|
|
6
|
-
handleGenesis, handleAudit, handleInit,
|
|
6
|
+
handleStatus, handleGenesis, handleAudit, handleInit, handleAssistant,
|
|
7
|
+
handleExamples, handleDoctor,
|
|
8
|
+
printHelp,
|
|
7
9
|
} from './cli-handlers.js';
|
|
8
10
|
|
|
9
11
|
const handlers: Record<string, (opts: ParsedArgs) => Promise<void>> = {
|
|
@@ -20,9 +22,13 @@ const handlers: Record<string, (opts: ParsedArgs) => Promise<void>> = {
|
|
|
20
22
|
session: handleSession,
|
|
21
23
|
steer: handleSteer,
|
|
22
24
|
queue: handleQueue,
|
|
25
|
+
status: handleStatus,
|
|
23
26
|
genesis: handleGenesis,
|
|
24
27
|
audit: handleAudit,
|
|
25
28
|
init: handleInit,
|
|
29
|
+
assistant: handleAssistant,
|
|
30
|
+
examples: handleExamples,
|
|
31
|
+
doctor: handleDoctor,
|
|
26
32
|
};
|
|
27
33
|
|
|
28
34
|
export async function handleCommand(
|