@synergenius/flow-weaver-pack-weaver 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/dist/bot/assistant-core.d.ts +2 -0
- package/dist/bot/assistant-core.d.ts.map +1 -1
- package/dist/bot/assistant-core.js +130 -17
- package/dist/bot/assistant-core.js.map +1 -1
- package/dist/bot/conversation-store.d.ts +1 -0
- package/dist/bot/conversation-store.d.ts.map +1 -1
- package/dist/bot/conversation-store.js +32 -0
- package/dist/bot/conversation-store.js.map +1 -1
- package/dist/bot/response-formatter.d.ts +15 -0
- package/dist/bot/response-formatter.d.ts.map +1 -0
- package/dist/bot/response-formatter.js +40 -0
- package/dist/bot/response-formatter.js.map +1 -0
- package/dist/bot/rich-input.d.ts +39 -0
- package/dist/bot/rich-input.d.ts.map +1 -0
- package/dist/bot/rich-input.js +308 -0
- package/dist/bot/rich-input.js.map +1 -0
- package/dist/bot/slash-commands.d.ts +20 -0
- package/dist/bot/slash-commands.d.ts.map +1 -0
- package/dist/bot/slash-commands.js +93 -0
- package/dist/bot/slash-commands.js.map +1 -0
- package/dist/cli-handlers.d.ts +1 -0
- package/dist/cli-handlers.d.ts.map +1 -1
- package/dist/cli-handlers.js +103 -2
- package/dist/cli-handlers.js.map +1 -1
- package/dist/node-types/agent-execute.js +15 -3
- package/dist/node-types/agent-execute.js.map +1 -1
- package/flowweaver.manifest.json +1 -1
- package/package.json +1 -1
- package/src/bot/assistant-core.ts +131 -19
- package/src/bot/conversation-store.ts +32 -0
- package/src/bot/response-formatter.ts +42 -0
- package/src/bot/rich-input.ts +307 -0
- package/src/bot/slash-commands.ts +114 -0
- package/src/cli-handlers.ts +105 -3
- package/src/node-types/agent-execute.ts +17 -4
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import * as os from 'node:os';
|
|
4
|
+
import * as readline from 'node:readline';
|
|
5
|
+
export class RichInput {
|
|
6
|
+
history = [];
|
|
7
|
+
historyIndex = -1;
|
|
8
|
+
currentLine = '';
|
|
9
|
+
cursorPos = 0;
|
|
10
|
+
multiLineBuffer = [];
|
|
11
|
+
searchMode = false;
|
|
12
|
+
searchQuery = '';
|
|
13
|
+
ctrlCCount = 0;
|
|
14
|
+
prompt;
|
|
15
|
+
historyFile;
|
|
16
|
+
completionProvider;
|
|
17
|
+
maxHistory;
|
|
18
|
+
constructor(opts = {}) {
|
|
19
|
+
this.prompt = opts.prompt ?? '❯ ';
|
|
20
|
+
this.historyFile = opts.historyFile ?? path.join(os.homedir(), '.weaver', 'input-history.txt');
|
|
21
|
+
this.completionProvider = opts.completionProvider;
|
|
22
|
+
this.maxHistory = opts.maxHistorySize ?? 500;
|
|
23
|
+
this.loadHistory();
|
|
24
|
+
}
|
|
25
|
+
async getInput() {
|
|
26
|
+
// Non-TTY fallback
|
|
27
|
+
if (!process.stdin.isTTY) {
|
|
28
|
+
return this.getInputReadline();
|
|
29
|
+
}
|
|
30
|
+
return new Promise((resolve) => {
|
|
31
|
+
this.ctrlCCount = 0;
|
|
32
|
+
this.historyIndex = -1;
|
|
33
|
+
this.currentLine = '';
|
|
34
|
+
this.cursorPos = 0;
|
|
35
|
+
this.searchMode = false;
|
|
36
|
+
process.stdin.setRawMode(true);
|
|
37
|
+
process.stdin.resume();
|
|
38
|
+
const handler = (key) => {
|
|
39
|
+
this.handleKey(key, (result) => {
|
|
40
|
+
process.stdin.setRawMode(false);
|
|
41
|
+
process.stdin.pause();
|
|
42
|
+
process.stdin.removeListener('data', handler);
|
|
43
|
+
resolve(result);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
process.stdin.on('data', handler);
|
|
47
|
+
this.renderPrompt();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
resetCtrlC() {
|
|
51
|
+
this.ctrlCCount = 0;
|
|
52
|
+
}
|
|
53
|
+
handleKey(key, resolve) {
|
|
54
|
+
const s = key.toString();
|
|
55
|
+
// Handle search mode separately
|
|
56
|
+
if (this.searchMode) {
|
|
57
|
+
this.handleSearchKey(s, resolve);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (s === '\r' || s === '\n') {
|
|
61
|
+
this.handleEnter(resolve);
|
|
62
|
+
}
|
|
63
|
+
else if (s === '\x03') { // Ctrl+C
|
|
64
|
+
this.ctrlCCount++;
|
|
65
|
+
if (this.ctrlCCount >= 2 || this.currentLine === '') {
|
|
66
|
+
process.stderr.write('\n');
|
|
67
|
+
resolve(null);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
this.currentLine = '';
|
|
71
|
+
this.cursorPos = 0;
|
|
72
|
+
process.stderr.write('\n');
|
|
73
|
+
this.renderPrompt();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else if (s === '\x0c') { // Ctrl+L
|
|
77
|
+
process.stderr.write('\x1b[2J\x1b[H'); // clear screen + move to top
|
|
78
|
+
this.renderPrompt();
|
|
79
|
+
}
|
|
80
|
+
else if (s === '\x12') { // Ctrl+R
|
|
81
|
+
this.searchMode = true;
|
|
82
|
+
this.searchQuery = '';
|
|
83
|
+
this.renderSearchPrompt();
|
|
84
|
+
}
|
|
85
|
+
else if (s === '\x09') { // Tab
|
|
86
|
+
this.handleTab();
|
|
87
|
+
}
|
|
88
|
+
else if (s === '\x1b[A') { // Arrow Up
|
|
89
|
+
this.historyUp();
|
|
90
|
+
}
|
|
91
|
+
else if (s === '\x1b[B') { // Arrow Down
|
|
92
|
+
this.historyDown();
|
|
93
|
+
}
|
|
94
|
+
else if (s === '\x1b[C') { // Arrow Right
|
|
95
|
+
if (this.cursorPos < this.currentLine.length) {
|
|
96
|
+
this.cursorPos++;
|
|
97
|
+
process.stderr.write('\x1b[C');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else if (s === '\x1b[D') { // Arrow Left
|
|
101
|
+
if (this.cursorPos > 0) {
|
|
102
|
+
this.cursorPos--;
|
|
103
|
+
process.stderr.write('\x1b[D');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (s === '\x7f' || s === '\b') { // Backspace
|
|
107
|
+
if (this.cursorPos > 0) {
|
|
108
|
+
this.currentLine = this.currentLine.slice(0, this.cursorPos - 1) + this.currentLine.slice(this.cursorPos);
|
|
109
|
+
this.cursorPos--;
|
|
110
|
+
this.renderPrompt();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else if (s === '\x1b[3~') { // Delete
|
|
114
|
+
if (this.cursorPos < this.currentLine.length) {
|
|
115
|
+
this.currentLine = this.currentLine.slice(0, this.cursorPos) + this.currentLine.slice(this.cursorPos + 1);
|
|
116
|
+
this.renderPrompt();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else if (s === '\x01') { // Ctrl+A (home)
|
|
120
|
+
this.cursorPos = 0;
|
|
121
|
+
this.renderPrompt();
|
|
122
|
+
}
|
|
123
|
+
else if (s === '\x05') { // Ctrl+E (end)
|
|
124
|
+
this.cursorPos = this.currentLine.length;
|
|
125
|
+
this.renderPrompt();
|
|
126
|
+
}
|
|
127
|
+
else if (s === '\x15') { // Ctrl+U (clear line)
|
|
128
|
+
this.currentLine = '';
|
|
129
|
+
this.cursorPos = 0;
|
|
130
|
+
this.renderPrompt();
|
|
131
|
+
}
|
|
132
|
+
else if (s >= ' ' && s.length === 1) { // Printable
|
|
133
|
+
this.ctrlCCount = 0;
|
|
134
|
+
this.currentLine = this.currentLine.slice(0, this.cursorPos) + s + this.currentLine.slice(this.cursorPos);
|
|
135
|
+
this.cursorPos++;
|
|
136
|
+
this.renderPrompt();
|
|
137
|
+
}
|
|
138
|
+
else if (s.length > 1 && !s.startsWith('\x1b')) {
|
|
139
|
+
// Pasted text (multiple chars at once)
|
|
140
|
+
this.ctrlCCount = 0;
|
|
141
|
+
this.currentLine = this.currentLine.slice(0, this.cursorPos) + s + this.currentLine.slice(this.cursorPos);
|
|
142
|
+
this.cursorPos += s.length;
|
|
143
|
+
this.renderPrompt();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
handleEnter(resolve) {
|
|
147
|
+
const fullLine = this.multiLineBuffer.length > 0
|
|
148
|
+
? [...this.multiLineBuffer, this.currentLine].join('\n')
|
|
149
|
+
: this.currentLine;
|
|
150
|
+
// Check for multi-line continuation
|
|
151
|
+
if (this.isIncomplete(fullLine)) {
|
|
152
|
+
this.multiLineBuffer.push(this.currentLine);
|
|
153
|
+
this.currentLine = '';
|
|
154
|
+
this.cursorPos = 0;
|
|
155
|
+
process.stderr.write('\n');
|
|
156
|
+
process.stderr.write(' ... ');
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
process.stderr.write('\n');
|
|
160
|
+
const trimmed = fullLine.trim();
|
|
161
|
+
if (trimmed) {
|
|
162
|
+
this.addToHistory(trimmed);
|
|
163
|
+
}
|
|
164
|
+
this.multiLineBuffer = [];
|
|
165
|
+
this.currentLine = '';
|
|
166
|
+
this.cursorPos = 0;
|
|
167
|
+
resolve(trimmed || null);
|
|
168
|
+
}
|
|
169
|
+
isIncomplete(text) {
|
|
170
|
+
const backticks = (text.match(/```/g) || []).length;
|
|
171
|
+
if (backticks % 2 !== 0)
|
|
172
|
+
return true;
|
|
173
|
+
if (text.endsWith('\\'))
|
|
174
|
+
return true;
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
historyUp() {
|
|
178
|
+
if (this.history.length === 0)
|
|
179
|
+
return;
|
|
180
|
+
if (this.historyIndex < this.history.length - 1) {
|
|
181
|
+
this.historyIndex++;
|
|
182
|
+
this.currentLine = this.history[this.history.length - 1 - this.historyIndex];
|
|
183
|
+
this.cursorPos = this.currentLine.length;
|
|
184
|
+
this.renderPrompt();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
historyDown() {
|
|
188
|
+
if (this.historyIndex > 0) {
|
|
189
|
+
this.historyIndex--;
|
|
190
|
+
this.currentLine = this.history[this.history.length - 1 - this.historyIndex];
|
|
191
|
+
this.cursorPos = this.currentLine.length;
|
|
192
|
+
this.renderPrompt();
|
|
193
|
+
}
|
|
194
|
+
else if (this.historyIndex === 0) {
|
|
195
|
+
this.historyIndex = -1;
|
|
196
|
+
this.currentLine = '';
|
|
197
|
+
this.cursorPos = 0;
|
|
198
|
+
this.renderPrompt();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
handleTab() {
|
|
202
|
+
if (!this.completionProvider)
|
|
203
|
+
return;
|
|
204
|
+
const candidates = this.completionProvider(this.currentLine);
|
|
205
|
+
if (candidates.length === 0)
|
|
206
|
+
return;
|
|
207
|
+
if (candidates.length === 1) {
|
|
208
|
+
this.currentLine = candidates[0];
|
|
209
|
+
this.cursorPos = this.currentLine.length;
|
|
210
|
+
this.renderPrompt();
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
// Show candidates below, then redraw prompt
|
|
214
|
+
process.stderr.write('\n ' + candidates.join(' ') + '\n');
|
|
215
|
+
this.renderPrompt();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
handleSearchKey(s, resolve) {
|
|
219
|
+
if (s === '\x1b' || s === '\x03') { // Esc or Ctrl+C — cancel search
|
|
220
|
+
this.searchMode = false;
|
|
221
|
+
this.renderPrompt();
|
|
222
|
+
}
|
|
223
|
+
else if (s === '\r' || s === '\n') { // Enter — accept match
|
|
224
|
+
this.searchMode = false;
|
|
225
|
+
const match = this.searchHistory(this.searchQuery);
|
|
226
|
+
if (match) {
|
|
227
|
+
this.currentLine = match;
|
|
228
|
+
this.cursorPos = this.currentLine.length;
|
|
229
|
+
}
|
|
230
|
+
this.renderPrompt();
|
|
231
|
+
}
|
|
232
|
+
else if (s === '\x7f' || s === '\b') { // Backspace
|
|
233
|
+
this.searchQuery = this.searchQuery.slice(0, -1);
|
|
234
|
+
this.renderSearchPrompt();
|
|
235
|
+
}
|
|
236
|
+
else if (s >= ' ' && s.length === 1) {
|
|
237
|
+
this.searchQuery += s;
|
|
238
|
+
this.renderSearchPrompt();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
searchHistory(query) {
|
|
242
|
+
if (!query)
|
|
243
|
+
return null;
|
|
244
|
+
const lower = query.toLowerCase();
|
|
245
|
+
for (let i = this.history.length - 1; i >= 0; i--) {
|
|
246
|
+
if (this.history[i].toLowerCase().includes(lower))
|
|
247
|
+
return this.history[i];
|
|
248
|
+
}
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
renderPrompt() {
|
|
252
|
+
process.stderr.write(`\r\x1b[K${this.prompt}${this.currentLine}`);
|
|
253
|
+
// Move cursor to correct position
|
|
254
|
+
const offset = this.currentLine.length - this.cursorPos;
|
|
255
|
+
if (offset > 0)
|
|
256
|
+
process.stderr.write(`\x1b[${offset}D`);
|
|
257
|
+
}
|
|
258
|
+
renderSearchPrompt() {
|
|
259
|
+
const match = this.searchHistory(this.searchQuery) ?? '';
|
|
260
|
+
process.stderr.write(`\r\x1b[K\x1b[2m(search): ${this.searchQuery}\x1b[0m ${match}`);
|
|
261
|
+
}
|
|
262
|
+
addToHistory(line) {
|
|
263
|
+
// Don't add duplicates of the last entry
|
|
264
|
+
if (this.history.length > 0 && this.history[this.history.length - 1] === line)
|
|
265
|
+
return;
|
|
266
|
+
this.history.push(line);
|
|
267
|
+
if (this.history.length > this.maxHistory)
|
|
268
|
+
this.history.shift();
|
|
269
|
+
this.saveHistory();
|
|
270
|
+
}
|
|
271
|
+
loadHistory() {
|
|
272
|
+
try {
|
|
273
|
+
if (fs.existsSync(this.historyFile)) {
|
|
274
|
+
this.history = fs.readFileSync(this.historyFile, 'utf-8')
|
|
275
|
+
.split('\n')
|
|
276
|
+
.filter(Boolean)
|
|
277
|
+
.slice(-this.maxHistory);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
catch { /* history not available */ }
|
|
281
|
+
}
|
|
282
|
+
saveHistory() {
|
|
283
|
+
try {
|
|
284
|
+
const dir = path.dirname(this.historyFile);
|
|
285
|
+
if (!fs.existsSync(dir))
|
|
286
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
287
|
+
fs.writeFileSync(this.historyFile, this.history.join('\n') + '\n');
|
|
288
|
+
}
|
|
289
|
+
catch { /* non-fatal */ }
|
|
290
|
+
}
|
|
291
|
+
async getInputReadline() {
|
|
292
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stderr, prompt: this.prompt });
|
|
293
|
+
return new Promise((resolve) => {
|
|
294
|
+
rl.prompt();
|
|
295
|
+
rl.once('line', (line) => { rl.close(); resolve(line.trim() || null); });
|
|
296
|
+
rl.once('close', () => resolve(null));
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
destroy() {
|
|
300
|
+
if (process.stdin.isTTY) {
|
|
301
|
+
try {
|
|
302
|
+
process.stdin.setRawMode(false);
|
|
303
|
+
}
|
|
304
|
+
catch { }
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
//# sourceMappingURL=rich-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-input.js","sourceRoot":"","sources":["../../src/bot/rich-input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAS1C,MAAM,OAAO,SAAS;IACZ,OAAO,GAAa,EAAE,CAAC;IACvB,YAAY,GAAG,CAAC,CAAC,CAAC;IAClB,WAAW,GAAG,EAAE,CAAC;IACjB,SAAS,GAAG,CAAC,CAAC;IACd,eAAe,GAAa,EAAE,CAAC;IAC/B,UAAU,GAAG,KAAK,CAAC;IACnB,WAAW,GAAG,EAAE,CAAC;IACjB,UAAU,GAAG,CAAC,CAAC;IACf,MAAM,CAAS;IACf,WAAW,CAAS;IACpB,kBAAkB,CAAiC;IACnD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,CAAC,MAAM,EAAE,CAAC;YACZ,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACzE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC;gBAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QACnD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ToolExecutor } from '@synergenius/flow-weaver/agent';
|
|
2
|
+
export interface SlashContext {
|
|
3
|
+
executor: ToolExecutor;
|
|
4
|
+
out: (s: string) => void;
|
|
5
|
+
projectDir: string;
|
|
6
|
+
conversationId?: string;
|
|
7
|
+
onClear?: () => void;
|
|
8
|
+
onExit?: () => void;
|
|
9
|
+
onNew?: () => void;
|
|
10
|
+
onVerbose?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export interface SlashCommand {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
handler: (ctx: SlashContext, args: string) => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare const SLASH_COMMANDS: SlashCommand[];
|
|
18
|
+
export declare function getSlashCompletions(partial: string): string[];
|
|
19
|
+
export declare function handleSlashCommand(input: string, ctx: SlashContext): Promise<boolean>;
|
|
20
|
+
//# sourceMappingURL=slash-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slash-commands.d.ts","sourceRoot":"","sources":["../../src/bot/slash-commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGnE,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,YAAY,CAAC;IACvB,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D;AAED,eAAO,MAAM,cAAc,EAAE,YAAY,EA2ExC,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAK7D;AAED,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,YAAY,GAChB,OAAO,CAAC,OAAO,CAAC,CAMlB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { c } from './ansi.js';
|
|
2
|
+
export const SLASH_COMMANDS = [
|
|
3
|
+
{
|
|
4
|
+
name: '/help',
|
|
5
|
+
description: 'Show available commands',
|
|
6
|
+
handler: async (ctx) => {
|
|
7
|
+
ctx.out('\n Available commands:\n');
|
|
8
|
+
for (const cmd of SLASH_COMMANDS) {
|
|
9
|
+
ctx.out(` ${c.cyan(cmd.name.padEnd(12))} ${c.dim(cmd.description)}\n`);
|
|
10
|
+
}
|
|
11
|
+
ctx.out('\n');
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: '/status',
|
|
16
|
+
description: 'Show bots, queue, and conversation summary',
|
|
17
|
+
handler: async (ctx) => {
|
|
18
|
+
const bots = await ctx.executor('bot_list', {});
|
|
19
|
+
const summary = await ctx.executor('conversation_summary', {});
|
|
20
|
+
ctx.out(`\n ${bots.result}\n ${summary.result}\n\n`);
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: '/bots',
|
|
25
|
+
description: 'List running bots',
|
|
26
|
+
handler: async (ctx) => {
|
|
27
|
+
const result = await ctx.executor('bot_list', {});
|
|
28
|
+
ctx.out(`\n ${result.result}\n\n`);
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: '/clear',
|
|
33
|
+
description: 'Clear screen and start new conversation',
|
|
34
|
+
handler: async (ctx) => {
|
|
35
|
+
process.stderr.write('\x1b[2J\x1b[H');
|
|
36
|
+
ctx.onClear?.();
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: '/exit',
|
|
41
|
+
description: 'Exit the assistant',
|
|
42
|
+
handler: async (ctx) => {
|
|
43
|
+
ctx.onExit?.();
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: '/new',
|
|
48
|
+
description: 'Start a new conversation',
|
|
49
|
+
handler: async (ctx) => {
|
|
50
|
+
ctx.onNew?.();
|
|
51
|
+
ctx.out(`\n ${c.dim('New conversation started.')}\n\n`);
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: '/list',
|
|
56
|
+
description: 'List saved conversations',
|
|
57
|
+
handler: async (ctx) => {
|
|
58
|
+
const result = await ctx.executor('conversation_list', {});
|
|
59
|
+
ctx.out(`\n ${result.result}\n\n`);
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: '/verbose',
|
|
64
|
+
description: 'Toggle verbose mode (show AI thinking)',
|
|
65
|
+
handler: async (ctx) => {
|
|
66
|
+
ctx.onVerbose?.();
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: '/history',
|
|
71
|
+
description: 'Show conversation history summary',
|
|
72
|
+
handler: async (ctx) => {
|
|
73
|
+
const result = await ctx.executor('conversation_summary', {});
|
|
74
|
+
ctx.out(`\n ${result.result}\n\n`);
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
export function getSlashCompletions(partial) {
|
|
79
|
+
if (!partial.startsWith('/'))
|
|
80
|
+
return [];
|
|
81
|
+
return SLASH_COMMANDS
|
|
82
|
+
.filter(cmd => cmd.name.startsWith(partial))
|
|
83
|
+
.map(cmd => cmd.name);
|
|
84
|
+
}
|
|
85
|
+
export async function handleSlashCommand(input, ctx) {
|
|
86
|
+
const [name, ...rest] = input.split(' ');
|
|
87
|
+
const cmd = SLASH_COMMANDS.find(c => c.name === name);
|
|
88
|
+
if (!cmd)
|
|
89
|
+
return false;
|
|
90
|
+
await cmd.handler(ctx, rest.join(' '));
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=slash-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slash-commands.js","sourceRoot":"","sources":["../../src/bot/slash-commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAmB9B,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C;QACE,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,yBAAyB;QACtC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;YACrB,GAAG,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;YACrC,KAAK,MAAM,GAAG,IAAI,cAAc,EAAE,CAAC;gBACjC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAA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AC;SAC3C,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAa,EACb,GAAiB;IAEjB,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzC,MAAM,GAAG,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACtD,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,MAAM,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACvC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/cli-handlers.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export interface ParsedArgs {
|
|
|
42
42
|
assistantResume?: string;
|
|
43
43
|
assistantList?: boolean;
|
|
44
44
|
assistantDelete?: string;
|
|
45
|
+
assistantWatch?: string;
|
|
45
46
|
}
|
|
46
47
|
export declare function parseArgs(argv: string[]): ParsedArgs;
|
|
47
48
|
export declare function formatDuration(ms: number): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-handlers.d.ts","sourceRoot":"","sources":["../src/cli-handlers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-handlers.d.ts","sourceRoot":"","sources":["../src/cli-handlers.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,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CrE;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAwGlE"}
|
package/dist/cli-handlers.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as path from 'node:path';
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
|
+
import * as os from 'node:os';
|
|
3
4
|
import { fileURLToPath } from 'node:url';
|
|
4
5
|
import { runWorkflow } from './bot/runner.js';
|
|
5
6
|
import { RunStore } from './bot/run-store.js';
|
|
@@ -250,6 +251,10 @@ export function parseArgs(argv) {
|
|
|
250
251
|
else if (arg === '--watch') {
|
|
251
252
|
result.genesisWatch = true;
|
|
252
253
|
}
|
|
254
|
+
else if (arg === '--watch-dir' && i + 1 < args.length) {
|
|
255
|
+
i++;
|
|
256
|
+
result.assistantWatch = args[i];
|
|
257
|
+
}
|
|
253
258
|
else if (arg === '--new') {
|
|
254
259
|
result.assistantNew = true;
|
|
255
260
|
}
|
|
@@ -1031,6 +1036,41 @@ export async function handleEject(opts) {
|
|
|
1031
1036
|
console.log(`[weaver] Metadata written to ${metaPath}`);
|
|
1032
1037
|
console.log('[weaver] You can now customize the ejected workflow(s) freely.');
|
|
1033
1038
|
console.log('[weaver] The bot will use local files when available.');
|
|
1039
|
+
// Generate CUSTOMIZATION.md guide
|
|
1040
|
+
const customizationGuide = `# Customizing Your Weaver Bot
|
|
1041
|
+
|
|
1042
|
+
## What You Got
|
|
1043
|
+
${results.map(r => `- ${r.file} — ${r.workflow} workflow (${r.nodeTypes.length} node types)`).join('\n')}
|
|
1044
|
+
|
|
1045
|
+
You can edit these files freely. Weaver will use your local versions.
|
|
1046
|
+
|
|
1047
|
+
## Safe Changes
|
|
1048
|
+
- Add a notification node (Slack, Discord, email) after git-ops
|
|
1049
|
+
- Change approval mode: edit the @node approve line
|
|
1050
|
+
- Add custom validation: insert a node between agent and gitOps
|
|
1051
|
+
- Modify the system prompt: edit system-prompt.ts
|
|
1052
|
+
- Add new tools: create a node type and wire it in
|
|
1053
|
+
|
|
1054
|
+
## How to Add a Node
|
|
1055
|
+
1. Create a new file: my-node.ts with @flowWeaver nodeType annotation
|
|
1056
|
+
2. Import it in the workflow file
|
|
1057
|
+
3. Add: @node myNode myNodeType [color: "blue"] [icon: "star"]
|
|
1058
|
+
4. Wire it: @connect existingNode.output -> myNode.input
|
|
1059
|
+
5. Compile: flow-weaver compile <workflow-file>
|
|
1060
|
+
|
|
1061
|
+
## How to Test
|
|
1062
|
+
flow-weaver validate <workflow-file> # check for errors
|
|
1063
|
+
flow-weaver diagram <workflow-file> # visualize the DAG
|
|
1064
|
+
weaver bot "test task" --auto-approve # run a test task
|
|
1065
|
+
|
|
1066
|
+
## Learn More
|
|
1067
|
+
weaver examples # see what's possible
|
|
1068
|
+
weaver doctor # check your setup
|
|
1069
|
+
flow-weaver docs concepts # Flow Weaver documentation
|
|
1070
|
+
`;
|
|
1071
|
+
const customPath = path.resolve(destDir, 'CUSTOMIZATION.md');
|
|
1072
|
+
fs.writeFileSync(customPath, customizationGuide, 'utf-8');
|
|
1073
|
+
console.log(`[weaver] Generated ${customPath}`);
|
|
1034
1074
|
}
|
|
1035
1075
|
export async function handleRun(opts) {
|
|
1036
1076
|
if (!opts.file) {
|
|
@@ -1432,6 +1472,32 @@ export async function handleSession(opts) {
|
|
|
1432
1472
|
}
|
|
1433
1473
|
catch { /* non-fatal */ }
|
|
1434
1474
|
}
|
|
1475
|
+
// Webhook notification if configured
|
|
1476
|
+
if (config?.notify) {
|
|
1477
|
+
try {
|
|
1478
|
+
const webhookUrl = typeof config.notify === 'string' ? config.notify
|
|
1479
|
+
: typeof config.notify === 'object' && 'webhook' in config.notify ? config.notify.webhook
|
|
1480
|
+
: null;
|
|
1481
|
+
if (webhookUrl) {
|
|
1482
|
+
fetch(webhookUrl, {
|
|
1483
|
+
method: 'POST',
|
|
1484
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1485
|
+
body: JSON.stringify({
|
|
1486
|
+
event: 'session.completed',
|
|
1487
|
+
timestamp: new Date().toISOString(),
|
|
1488
|
+
tasks: taskCount,
|
|
1489
|
+
completed: sessionCompleted,
|
|
1490
|
+
failed: sessionFailed,
|
|
1491
|
+
noOp: sessionNoOp,
|
|
1492
|
+
tokens: sessionInputTokens + sessionOutputTokens,
|
|
1493
|
+
cost: sessionCost,
|
|
1494
|
+
elapsed: Date.now() - sessionStartTime,
|
|
1495
|
+
}),
|
|
1496
|
+
}).catch(() => { }); // fire-and-forget
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
catch { /* non-fatal */ }
|
|
1500
|
+
}
|
|
1435
1501
|
}
|
|
1436
1502
|
export async function handleAssistant(opts) {
|
|
1437
1503
|
const projectDir = opts.file ?? process.cwd();
|
|
@@ -1461,12 +1527,37 @@ export async function handleAssistant(opts) {
|
|
|
1461
1527
|
return;
|
|
1462
1528
|
}
|
|
1463
1529
|
const config = await loadConfig(opts.configPath);
|
|
1530
|
+
// Check platform login — override provider if logged in
|
|
1531
|
+
let providerOverride;
|
|
1532
|
+
try {
|
|
1533
|
+
const credPath = path.join(os.homedir(), '.fw', 'credentials.json');
|
|
1534
|
+
if (fs.existsSync(credPath)) {
|
|
1535
|
+
const creds = JSON.parse(fs.readFileSync(credPath, 'utf-8'));
|
|
1536
|
+
if (creds.token && creds.platformUrl && creds.expiresAt > Date.now()) {
|
|
1537
|
+
providerOverride = 'platform';
|
|
1538
|
+
// Make credentials available to the provider
|
|
1539
|
+
process.env.FW_PLATFORM_TOKEN = creds.token;
|
|
1540
|
+
process.env.FW_PLATFORM_URL = creds.platformUrl;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
catch { /* not available */ }
|
|
1464
1545
|
// Create provider
|
|
1465
|
-
const
|
|
1546
|
+
const agentMod = await import('@synergenius/flow-weaver/agent');
|
|
1547
|
+
const { createAnthropicProvider, createClaudeCliProvider } = agentMod;
|
|
1548
|
+
const createPlatformProvider = 'createPlatformProvider' in agentMod
|
|
1549
|
+
? agentMod.createPlatformProvider
|
|
1550
|
+
: null;
|
|
1466
1551
|
const providerSetting = config?.provider ?? 'auto';
|
|
1467
1552
|
const providerType = typeof providerSetting === 'object' ? providerSetting.name : String(providerSetting);
|
|
1468
1553
|
let provider;
|
|
1469
|
-
if (
|
|
1554
|
+
if ((providerOverride === 'platform' || providerType === 'platform') && createPlatformProvider) {
|
|
1555
|
+
provider = createPlatformProvider({
|
|
1556
|
+
token: process.env.FW_PLATFORM_TOKEN,
|
|
1557
|
+
platformUrl: process.env.FW_PLATFORM_URL,
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
else if (providerType === 'anthropic' || (providerType === 'auto' && process.env.ANTHROPIC_API_KEY)) {
|
|
1470
1561
|
const apiKey = process.env.ANTHROPIC_API_KEY ?? (typeof providerSetting === 'object' ? providerSetting.apiKey : undefined);
|
|
1471
1562
|
if (!apiKey) {
|
|
1472
1563
|
console.error('ANTHROPIC_API_KEY required for anthropic provider');
|
|
@@ -1487,6 +1578,7 @@ export async function handleAssistant(opts) {
|
|
|
1487
1578
|
projectDir,
|
|
1488
1579
|
resumeId: opts.assistantResume,
|
|
1489
1580
|
newConversation: opts.assistantNew,
|
|
1581
|
+
watchDir: opts.assistantWatch,
|
|
1490
1582
|
});
|
|
1491
1583
|
}
|
|
1492
1584
|
export async function handleSteer(opts) {
|
|
@@ -1997,6 +2089,15 @@ export async function handleDoctor(opts) {
|
|
|
1997
2089
|
else {
|
|
1998
2090
|
checks.push({ label: 'Connection', status: 'warn', detail: 'Not tested' });
|
|
1999
2091
|
}
|
|
2092
|
+
// Weaver version (this pack)
|
|
2093
|
+
try {
|
|
2094
|
+
const url = await import('node:url');
|
|
2095
|
+
const packPkg = JSON.parse(fs.readFileSync(new url.URL('../package.json', import.meta.url), 'utf-8'));
|
|
2096
|
+
checks.push({ label: 'Weaver', status: 'ok', detail: `v${packPkg.version}` });
|
|
2097
|
+
}
|
|
2098
|
+
catch {
|
|
2099
|
+
checks.push({ label: 'Weaver', status: 'ok', detail: 'unknown version' });
|
|
2100
|
+
}
|
|
2000
2101
|
// Flow Weaver version
|
|
2001
2102
|
try {
|
|
2002
2103
|
const { execFileSync: fwCheck } = await import('node:child_process');
|