@ftarganski/omni-ai 0.1.1 → 1.1.5
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/{chunk-PPTEJ2FH.js → chunk-6KQE3NUV.js} +18 -10
- package/dist/{chunk-6APAA6WD.js → chunk-A7SDO64L.js} +54 -54
- package/dist/{chunk-AWMSN7OB.js → chunk-AU3KUCI7.js} +47 -45
- package/dist/{chunk-S5MK6LBH.js → chunk-BU7KK25R.js} +33 -18
- package/dist/{chunk-6OPRALDC.js → chunk-E2JJOPZB.js} +30 -18
- package/dist/{chunk-6YFFZMXY.js → chunk-GQL6DDF4.js} +7 -4
- package/dist/{chunk-TFU437SW.js → chunk-IVDHCLGS.js} +5 -4
- package/dist/{chunk-M4QJF7CV.js → chunk-JQRNMPWC.js} +11 -6
- package/dist/{chunk-3RZELMF2.js → chunk-LEW34E32.js} +27 -18
- package/dist/{chunk-JTXDF5KG.js → chunk-MQWOX2ZJ.js} +11 -6
- package/dist/{chunk-5WELBZWN.js → chunk-WRBBQFKB.js} +10 -8
- package/dist/{chunk-Y4EYGADJ.js → chunk-YRGG3PAL.js} +15 -10
- package/dist/{chunk-AG6NZIJ3.js → chunk-ZSNUHWSC.js} +10 -10
- package/dist/cli/bin.js +297 -254
- package/dist/{src-6MUVU5ML.js → dist-KBUP5623.js} +2 -2
- package/dist/{src-ZHTGR7T6.js → dist-Z76P5KV4.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/mcp.js +15 -18
- package/dist/memory.js +27 -32
- package/dist/provider-anthropic.js +10 -10
- package/dist/provider-google.js +15 -14
- package/dist/provider-openai.js +15 -10
- package/dist/skills/backend.js +1 -1
- package/dist/skills/code.js +1 -1
- package/dist/skills/frontend.js +1 -1
- package/dist/skills/fs.js +1 -1
- package/dist/skills/git.js +1 -1
- package/dist/skills/http.js +1 -1
- package/dist/skills/index.js +9 -9
- package/dist/skills/multimodal.js +1 -1
- package/dist/skills/qa.js +1 -1
- package/dist/skills/ux.js +1 -1
- package/package.json +18 -17
package/dist/cli/bin.js
CHANGED
|
@@ -1,34 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "../chunk-
|
|
3
|
-
import "../chunk-
|
|
2
|
+
import "../chunk-ZSNUHWSC.js";
|
|
3
|
+
import "../chunk-YRGG3PAL.js";
|
|
4
4
|
import {
|
|
5
5
|
createRuntime,
|
|
6
6
|
getRegisteredProviders,
|
|
7
7
|
registerProvider
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-AU3KUCI7.js";
|
|
9
9
|
|
|
10
|
-
//
|
|
10
|
+
// ../../packages/cli/dist/bin.js
|
|
11
11
|
import { dirname as dirname4, resolve as resolve17 } from "path";
|
|
12
12
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
13
13
|
import { Command } from "commander";
|
|
14
14
|
import { config as loadDotenv } from "dotenv";
|
|
15
15
|
|
|
16
|
-
//
|
|
16
|
+
// ../../packages/provider-google/dist/provider.js
|
|
17
17
|
import { GoogleGenerativeAI } from "@google/generative-ai";
|
|
18
18
|
|
|
19
|
-
//
|
|
19
|
+
// ../../packages/provider-google/dist/mappers.js
|
|
20
20
|
function toGeminiPart(part) {
|
|
21
|
-
if (part.type === "text")
|
|
21
|
+
if (part.type === "text")
|
|
22
|
+
return { text: part.text };
|
|
22
23
|
return { inlineData: { mimeType: part.mimeType, data: part.data } };
|
|
23
24
|
}
|
|
24
25
|
function contentToParts(content) {
|
|
25
|
-
if (typeof content === "string")
|
|
26
|
+
if (typeof content === "string")
|
|
27
|
+
return [{ text: content }];
|
|
26
28
|
return content.map(toGeminiPart);
|
|
27
29
|
}
|
|
28
30
|
function extractSystemInstruction(request) {
|
|
29
31
|
const systemMsg = request.messages.find((m) => m.role === "system");
|
|
30
32
|
const raw = request.systemPrompt ?? systemMsg?.content;
|
|
31
|
-
if (raw === void 0)
|
|
33
|
+
if (raw === void 0)
|
|
34
|
+
return void 0;
|
|
32
35
|
return typeof raw === "string" ? raw : raw.map((p) => p.type === "text" ? p.text : "").join("");
|
|
33
36
|
}
|
|
34
37
|
function toGeminiContents(messages) {
|
|
@@ -74,7 +77,7 @@ function fromGeminiResponse(response, modelName, providerName) {
|
|
|
74
77
|
};
|
|
75
78
|
}
|
|
76
79
|
|
|
77
|
-
//
|
|
80
|
+
// ../../packages/provider-google/dist/provider.js
|
|
78
81
|
var GoogleProvider = class {
|
|
79
82
|
name;
|
|
80
83
|
capabilities = {
|
|
@@ -126,17 +129,15 @@ var GoogleProvider = class {
|
|
|
126
129
|
const modelName = "text-embedding-004";
|
|
127
130
|
const model = this.client.getGenerativeModel({ model: modelName });
|
|
128
131
|
const inputs = Array.isArray(request.input) ? request.input : [request.input];
|
|
129
|
-
const embeddings = await Promise.all(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
})
|
|
134
|
-
);
|
|
132
|
+
const embeddings = await Promise.all(inputs.map(async (text) => {
|
|
133
|
+
const result = await model.embedContent(text);
|
|
134
|
+
return result.embedding.values;
|
|
135
|
+
}));
|
|
135
136
|
return { embeddings, model: modelName, provider: this.name };
|
|
136
137
|
}
|
|
137
138
|
};
|
|
138
139
|
|
|
139
|
-
//
|
|
140
|
+
// ../../packages/provider-google/dist/index.js
|
|
140
141
|
registerProvider("google", (config) => {
|
|
141
142
|
if (!config.apiKey) {
|
|
142
143
|
throw new Error(`Provider "${config.name}" (google) requires GOOGLE_API_KEY to be set in the environment.`);
|
|
@@ -148,10 +149,10 @@ registerProvider("google", (config) => {
|
|
|
148
149
|
});
|
|
149
150
|
});
|
|
150
151
|
|
|
151
|
-
//
|
|
152
|
+
// ../../packages/cli/dist/commands/chain.js
|
|
152
153
|
import { writeFile as writeFile2 } from "fs/promises";
|
|
153
154
|
|
|
154
|
-
//
|
|
155
|
+
// ../../packages/skills/dist/code/search-code.js
|
|
155
156
|
import { readdir, readFile } from "fs/promises";
|
|
156
157
|
import { join } from "path";
|
|
157
158
|
import { z } from "zod";
|
|
@@ -163,22 +164,27 @@ var InputSchema = z.object({
|
|
|
163
164
|
useRegex: z.boolean().default(false).describe("Treat pattern as a regular expression")
|
|
164
165
|
});
|
|
165
166
|
async function searchInFile(filePath, matcher, results, maxResults) {
|
|
166
|
-
if (results.length >= maxResults)
|
|
167
|
+
if (results.length >= maxResults)
|
|
168
|
+
return;
|
|
167
169
|
const text = await readFile(filePath, "utf-8");
|
|
168
170
|
const lines = text.split("\n");
|
|
169
171
|
for (let i = 0; i < lines.length; i++) {
|
|
170
|
-
if (results.length >= maxResults)
|
|
172
|
+
if (results.length >= maxResults)
|
|
173
|
+
break;
|
|
171
174
|
if (matcher(lines[i])) {
|
|
172
175
|
results.push({ file: filePath, line: i + 1, content: lines[i].trim() });
|
|
173
176
|
}
|
|
174
177
|
}
|
|
175
178
|
}
|
|
176
179
|
async function walkAndSearch(dir, extensions, matcher, results, maxResults) {
|
|
177
|
-
if (results.length >= maxResults)
|
|
180
|
+
if (results.length >= maxResults)
|
|
181
|
+
return;
|
|
178
182
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
179
183
|
for (const entry of entries) {
|
|
180
|
-
if (results.length >= maxResults)
|
|
181
|
-
|
|
184
|
+
if (results.length >= maxResults)
|
|
185
|
+
break;
|
|
186
|
+
if (entry.name === "node_modules" || entry.name === "dist")
|
|
187
|
+
continue;
|
|
182
188
|
const fullPath = join(dir, entry.name);
|
|
183
189
|
if (entry.isDirectory()) {
|
|
184
190
|
await walkAndSearch(fullPath, extensions, matcher, results, maxResults);
|
|
@@ -205,7 +211,7 @@ var searchCodeSkill = {
|
|
|
205
211
|
}
|
|
206
212
|
};
|
|
207
213
|
|
|
208
|
-
//
|
|
214
|
+
// ../../packages/skills/dist/fs/list-directory.js
|
|
209
215
|
import { readdir as readdir2 } from "fs/promises";
|
|
210
216
|
import { join as join2, resolve, sep } from "path";
|
|
211
217
|
import { z as z2 } from "zod";
|
|
@@ -234,7 +240,8 @@ async function walk(dir, recursive, extensions) {
|
|
|
234
240
|
}
|
|
235
241
|
} else if (entry.isFile()) {
|
|
236
242
|
const include = !extensions || extensions.some((ext) => entry.name.endsWith(ext));
|
|
237
|
-
if (include)
|
|
243
|
+
if (include)
|
|
244
|
+
results.push(fullPath);
|
|
238
245
|
}
|
|
239
246
|
}
|
|
240
247
|
return results;
|
|
@@ -249,7 +256,7 @@ var listDirectorySkill = {
|
|
|
249
256
|
}
|
|
250
257
|
};
|
|
251
258
|
|
|
252
|
-
//
|
|
259
|
+
// ../../packages/skills/dist/fs/read-file.js
|
|
253
260
|
import { readFile as readFile2 } from "fs/promises";
|
|
254
261
|
import { resolve as resolve2, sep as sep2 } from "path";
|
|
255
262
|
import { z as z3 } from "zod";
|
|
@@ -275,7 +282,7 @@ var readFileSkill = {
|
|
|
275
282
|
}
|
|
276
283
|
};
|
|
277
284
|
|
|
278
|
-
//
|
|
285
|
+
// ../../packages/skills/dist/fs/write-file.js
|
|
279
286
|
import { mkdir, writeFile } from "fs/promises";
|
|
280
287
|
import { dirname, resolve as resolve3, sep as sep3 } from "path";
|
|
281
288
|
import { z as z4 } from "zod";
|
|
@@ -307,11 +314,11 @@ var writeFileSkill = {
|
|
|
307
314
|
}
|
|
308
315
|
};
|
|
309
316
|
|
|
310
|
-
//
|
|
317
|
+
// ../../packages/skills/dist/git/git-commit-message.js
|
|
311
318
|
import { resolve as resolve4 } from "path";
|
|
312
319
|
import { z as z5 } from "zod";
|
|
313
320
|
|
|
314
|
-
//
|
|
321
|
+
// ../../packages/skills/dist/git/shared.js
|
|
315
322
|
import { spawn } from "child_process";
|
|
316
323
|
function runGit(args, cwd) {
|
|
317
324
|
return new Promise((resolve18, reject) => {
|
|
@@ -331,7 +338,7 @@ function runGit(args, cwd) {
|
|
|
331
338
|
});
|
|
332
339
|
}
|
|
333
340
|
|
|
334
|
-
//
|
|
341
|
+
// ../../packages/skills/dist/git/git-commit-message.js
|
|
335
342
|
var InputSchema5 = z5.object({
|
|
336
343
|
cwd: z5.string().default(".").describe("Repository root directory"),
|
|
337
344
|
staged: z5.boolean().default(true).describe("Use staged diff (true) or full working-tree diff (false)"),
|
|
@@ -350,7 +357,8 @@ var gitCommitMessageSkill = {
|
|
|
350
357
|
const { cwd, staged, hint } = InputSchema5.parse(input5);
|
|
351
358
|
const dir = resolve4(cwd);
|
|
352
359
|
const diffArgs = ["diff"];
|
|
353
|
-
if (staged)
|
|
360
|
+
if (staged)
|
|
361
|
+
diffArgs.push("--cached");
|
|
354
362
|
const diff = await runGit(diffArgs, dir);
|
|
355
363
|
if (!diff.trim()) {
|
|
356
364
|
return { message: "chore: no changes staged" };
|
|
@@ -366,7 +374,7 @@ var gitCommitMessageSkill = {
|
|
|
366
374
|
}
|
|
367
375
|
};
|
|
368
376
|
|
|
369
|
-
//
|
|
377
|
+
// ../../packages/skills/dist/git/git-diff.js
|
|
370
378
|
import { resolve as resolve5 } from "path";
|
|
371
379
|
import { z as z6 } from "zod";
|
|
372
380
|
var InputSchema6 = z6.object({
|
|
@@ -382,20 +390,26 @@ var gitDiffSkill = {
|
|
|
382
390
|
const { cwd, staged, file, base } = InputSchema6.parse(input5);
|
|
383
391
|
const dir = resolve5(cwd);
|
|
384
392
|
const diffArgs = ["diff"];
|
|
385
|
-
if (staged)
|
|
386
|
-
|
|
387
|
-
if (
|
|
393
|
+
if (staged)
|
|
394
|
+
diffArgs.push("--cached");
|
|
395
|
+
if (base)
|
|
396
|
+
diffArgs.push(base);
|
|
397
|
+
if (file)
|
|
398
|
+
diffArgs.push("--", file);
|
|
388
399
|
const nameArgs = ["diff", "--name-only"];
|
|
389
|
-
if (staged)
|
|
390
|
-
|
|
391
|
-
if (
|
|
400
|
+
if (staged)
|
|
401
|
+
nameArgs.push("--cached");
|
|
402
|
+
if (base)
|
|
403
|
+
nameArgs.push(base);
|
|
404
|
+
if (file)
|
|
405
|
+
nameArgs.push("--", file);
|
|
392
406
|
const [diff, names] = await Promise.all([runGit(diffArgs, dir), runGit(nameArgs, dir)]);
|
|
393
407
|
const changedFiles = names.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
394
408
|
return { diff, changedFiles };
|
|
395
409
|
}
|
|
396
410
|
};
|
|
397
411
|
|
|
398
|
-
//
|
|
412
|
+
// ../../packages/skills/dist/git/git-log.js
|
|
399
413
|
import { resolve as resolve6 } from "path";
|
|
400
414
|
import { z as z7 } from "zod";
|
|
401
415
|
var InputSchema7 = z7.object({
|
|
@@ -413,8 +427,10 @@ var gitLogSkill = {
|
|
|
413
427
|
const { cwd, maxEntries, branch, since } = InputSchema7.parse(input5);
|
|
414
428
|
const dir = resolve6(cwd);
|
|
415
429
|
const args = ["log", `--format=${FORMAT}`, `-n`, String(maxEntries)];
|
|
416
|
-
if (since)
|
|
417
|
-
|
|
430
|
+
if (since)
|
|
431
|
+
args.push(`--since=${since}`);
|
|
432
|
+
if (branch)
|
|
433
|
+
args.push(branch);
|
|
418
434
|
const raw = await runGit(args, dir);
|
|
419
435
|
const commits = raw.split("\n").filter(Boolean).map((line) => {
|
|
420
436
|
const [hash, shortHash, author, date, ...rest] = line.split(SEP);
|
|
@@ -424,7 +440,7 @@ var gitLogSkill = {
|
|
|
424
440
|
}
|
|
425
441
|
};
|
|
426
442
|
|
|
427
|
-
//
|
|
443
|
+
// ../../packages/skills/dist/git/git-status.js
|
|
428
444
|
import { resolve as resolve7 } from "path";
|
|
429
445
|
import { z as z8 } from "zod";
|
|
430
446
|
var InputSchema8 = z8.object({
|
|
@@ -435,15 +451,18 @@ function parsePorcelain(raw) {
|
|
|
435
451
|
const unstaged = [];
|
|
436
452
|
const untracked = [];
|
|
437
453
|
for (const line of raw.split("\n")) {
|
|
438
|
-
if (!line || line.startsWith("##"))
|
|
454
|
+
if (!line || line.startsWith("##"))
|
|
455
|
+
continue;
|
|
439
456
|
const x = line[0];
|
|
440
457
|
const y = line[1];
|
|
441
458
|
const path = line.slice(3);
|
|
442
459
|
if (x === "?" && y === "?") {
|
|
443
460
|
untracked.push(path);
|
|
444
461
|
} else {
|
|
445
|
-
if (x !== " " && x !== "?")
|
|
446
|
-
|
|
462
|
+
if (x !== " " && x !== "?")
|
|
463
|
+
staged.push({ path, status: x });
|
|
464
|
+
if (y !== " " && y !== "?")
|
|
465
|
+
unstaged.push({ path, status: y });
|
|
447
466
|
}
|
|
448
467
|
}
|
|
449
468
|
return { staged, unstaged, untracked };
|
|
@@ -464,7 +483,7 @@ var gitStatusSkill = {
|
|
|
464
483
|
}
|
|
465
484
|
};
|
|
466
485
|
|
|
467
|
-
//
|
|
486
|
+
// ../../packages/skills/dist/http/http-request.js
|
|
468
487
|
import { z as z9 } from "zod";
|
|
469
488
|
var BearerAuthSchema = z9.object({
|
|
470
489
|
type: z9.literal("bearer"),
|
|
@@ -492,7 +511,8 @@ var InputSchema9 = z9.object({
|
|
|
492
511
|
timeoutMs: z9.number().int().positive().default(3e4).describe("Request timeout in milliseconds")
|
|
493
512
|
});
|
|
494
513
|
async function resolveToken(auth) {
|
|
495
|
-
if (auth.type === "bearer")
|
|
514
|
+
if (auth.type === "bearer")
|
|
515
|
+
return `Bearer ${auth.token}`;
|
|
496
516
|
if (auth.type === "basic") {
|
|
497
517
|
const encoded = Buffer.from(`${auth.username}:${auth.password}`).toString("base64");
|
|
498
518
|
return `Basic ${encoded}`;
|
|
@@ -502,7 +522,8 @@ async function resolveToken(auth) {
|
|
|
502
522
|
client_id: auth.clientId,
|
|
503
523
|
client_secret: auth.clientSecret
|
|
504
524
|
});
|
|
505
|
-
if (auth.scope)
|
|
525
|
+
if (auth.scope)
|
|
526
|
+
params.set("scope", auth.scope);
|
|
506
527
|
const tokenRes = await fetch(auth.tokenUrl, {
|
|
507
528
|
method: "POST",
|
|
508
529
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
@@ -512,7 +533,8 @@ async function resolveToken(auth) {
|
|
|
512
533
|
throw new Error(`OAuth2 token request failed: ${tokenRes.status} ${tokenRes.statusText}`);
|
|
513
534
|
}
|
|
514
535
|
const json = await tokenRes.json();
|
|
515
|
-
if (!json.access_token)
|
|
536
|
+
if (!json.access_token)
|
|
537
|
+
throw new Error("OAuth2 response did not include access_token");
|
|
516
538
|
const tokenType = json.token_type ?? "Bearer";
|
|
517
539
|
return `${tokenType} ${json.access_token}`;
|
|
518
540
|
}
|
|
@@ -565,7 +587,7 @@ var httpRequestSkill = {
|
|
|
565
587
|
}
|
|
566
588
|
};
|
|
567
589
|
|
|
568
|
-
//
|
|
590
|
+
// ../../packages/skills/dist/multimodal/analyze-image.js
|
|
569
591
|
import { readFile as readFile3 } from "fs/promises";
|
|
570
592
|
import { extname } from "path";
|
|
571
593
|
import { z as z10 } from "zod";
|
|
@@ -590,21 +612,25 @@ async function loadImage(input5) {
|
|
|
590
612
|
if (input5.imagePath) {
|
|
591
613
|
const ext = extname(input5.imagePath).toLowerCase();
|
|
592
614
|
const mimeType2 = input5.mimeType ?? EXT_TO_MIME[ext];
|
|
593
|
-
if (!mimeType2)
|
|
615
|
+
if (!mimeType2)
|
|
616
|
+
throw new Error(`Unsupported image extension "${ext}". Use: ${Object.keys(EXT_TO_MIME).join(", ")}`);
|
|
594
617
|
const data = (await readFile3(input5.imagePath)).toString("base64");
|
|
595
618
|
return { data, mimeType: mimeType2 };
|
|
596
619
|
}
|
|
597
620
|
if (input5.imageUrl) {
|
|
598
621
|
const res = await fetch(input5.imageUrl);
|
|
599
|
-
if (!res.ok)
|
|
622
|
+
if (!res.ok)
|
|
623
|
+
throw new Error(`Failed to fetch image: ${res.status} ${res.statusText}`);
|
|
600
624
|
const contentType = res.headers.get("content-type") ?? "";
|
|
601
625
|
const mimeType2 = input5.mimeType ?? SUPPORTED_MIME.find((m) => contentType.startsWith(m));
|
|
602
|
-
if (!mimeType2)
|
|
626
|
+
if (!mimeType2)
|
|
627
|
+
throw new Error(`Unsupported content-type "${contentType}"`);
|
|
603
628
|
const buffer = await res.arrayBuffer();
|
|
604
629
|
return { data: Buffer.from(buffer).toString("base64"), mimeType: mimeType2 };
|
|
605
630
|
}
|
|
606
631
|
const mimeType = input5.mimeType;
|
|
607
|
-
if (!mimeType)
|
|
632
|
+
if (!mimeType)
|
|
633
|
+
throw new Error("mimeType is required when supplying imageBase64");
|
|
608
634
|
return { data: input5.imageBase64, mimeType };
|
|
609
635
|
}
|
|
610
636
|
var analyzeImageSkill = {
|
|
@@ -613,9 +639,7 @@ var analyzeImageSkill = {
|
|
|
613
639
|
async execute(input5, ctx) {
|
|
614
640
|
const parsed = InputSchema10.parse(input5);
|
|
615
641
|
if (!ctx.provider.capabilities.vision) {
|
|
616
|
-
throw new Error(
|
|
617
|
-
`Provider "${ctx.provider.name}" does not support vision. Configure a vision-capable provider (e.g. Anthropic claude-3, OpenAI gpt-4o).`
|
|
618
|
-
);
|
|
642
|
+
throw new Error(`Provider "${ctx.provider.name}" does not support vision. Configure a vision-capable provider (e.g. Anthropic claude-3, OpenAI gpt-4o).`);
|
|
619
643
|
}
|
|
620
644
|
const { data, mimeType } = await loadImage(parsed);
|
|
621
645
|
const imagePart = { type: "image", mimeType, data };
|
|
@@ -632,7 +656,7 @@ var analyzeImageSkill = {
|
|
|
632
656
|
}
|
|
633
657
|
};
|
|
634
658
|
|
|
635
|
-
//
|
|
659
|
+
// ../../packages/skills/dist/ux/audit-accessibility.js
|
|
636
660
|
import { readdir as readdir3, readFile as readFile4 } from "fs/promises";
|
|
637
661
|
import { join as join3 } from "path";
|
|
638
662
|
import { z as z11 } from "zod";
|
|
@@ -721,9 +745,11 @@ async function auditFile(filePath) {
|
|
|
721
745
|
for (const rule of RULES) {
|
|
722
746
|
rule.pattern.lastIndex = 0;
|
|
723
747
|
const match = rule.pattern.exec(line);
|
|
724
|
-
if (!match)
|
|
748
|
+
if (!match)
|
|
749
|
+
continue;
|
|
725
750
|
const isIssue = rule.isIssue ? rule.isIssue(match, line, lines, i) : true;
|
|
726
|
-
if (!isIssue)
|
|
751
|
+
if (!isIssue)
|
|
752
|
+
continue;
|
|
727
753
|
issues.push({
|
|
728
754
|
file: filePath,
|
|
729
755
|
line: i + 1,
|
|
@@ -740,11 +766,14 @@ async function auditFile(filePath) {
|
|
|
740
766
|
var MAX_DEPTH = 10;
|
|
741
767
|
var MAX_FILES = 500;
|
|
742
768
|
async function collectFiles(dir, recursive, depth = 0, results = []) {
|
|
743
|
-
if (depth > MAX_DEPTH || results.length >= MAX_FILES)
|
|
769
|
+
if (depth > MAX_DEPTH || results.length >= MAX_FILES)
|
|
770
|
+
return results;
|
|
744
771
|
const entries = await readdir3(dir, { withFileTypes: true });
|
|
745
772
|
for (const entry of entries) {
|
|
746
|
-
if (results.length >= MAX_FILES)
|
|
747
|
-
|
|
773
|
+
if (results.length >= MAX_FILES)
|
|
774
|
+
break;
|
|
775
|
+
if (entry.name === "node_modules" || entry.name === "dist")
|
|
776
|
+
continue;
|
|
748
777
|
const full = join3(dir, entry.name);
|
|
749
778
|
if (entry.isDirectory() && recursive) {
|
|
750
779
|
await collectFiles(full, recursive, depth + 1, results);
|
|
@@ -785,10 +814,10 @@ var auditAccessibilitySkill = {
|
|
|
785
814
|
}
|
|
786
815
|
};
|
|
787
816
|
|
|
788
|
-
//
|
|
817
|
+
// ../../packages/cli/dist/commands/chain.js
|
|
789
818
|
import chalk2 from "chalk";
|
|
790
819
|
|
|
791
|
-
//
|
|
820
|
+
// ../../packages/cli/dist/utils/config-path.js
|
|
792
821
|
import { dirname as dirname2, resolve as resolve8 } from "path";
|
|
793
822
|
import { fileURLToPath } from "url";
|
|
794
823
|
function resolveConfigPath() {
|
|
@@ -797,16 +826,14 @@ function resolveConfigPath() {
|
|
|
797
826
|
return resolve8(omniRoot, "config", "omni-ai.yaml");
|
|
798
827
|
}
|
|
799
828
|
|
|
800
|
-
//
|
|
829
|
+
// ../../packages/cli/dist/utils/format.js
|
|
801
830
|
import chalk from "chalk";
|
|
802
831
|
function agentHeader(name, providerModel) {
|
|
803
832
|
return chalk.bold.cyan(`\u25C6 ${name}`) + chalk.gray(` [${providerModel}]`);
|
|
804
833
|
}
|
|
805
834
|
function tokenSummary(inputTokens, outputTokens) {
|
|
806
835
|
const cost = ((inputTokens * 3 + outputTokens * 15) / 1e6).toFixed(4);
|
|
807
|
-
return chalk.gray(
|
|
808
|
-
`Tokens: ${inputTokens.toLocaleString("en-US")} entrada \xB7 ${outputTokens.toLocaleString("en-US")} sa\xEDda \xB7 ~$${cost}`
|
|
809
|
-
);
|
|
836
|
+
return chalk.gray(`Tokens: ${inputTokens.toLocaleString("en-US")} entrada \xB7 ${outputTokens.toLocaleString("en-US")} sa\xEDda \xB7 ~$${cost}`);
|
|
810
837
|
}
|
|
811
838
|
function iterationLine(n) {
|
|
812
839
|
return chalk.gray(` ... (${n} itera\xE7${n === 1 ? "\xE3o" : "\xF5es"})`);
|
|
@@ -818,7 +845,7 @@ function savedLine(path) {
|
|
|
818
845
|
return chalk.green(`Output salvo em: ${path}`);
|
|
819
846
|
}
|
|
820
847
|
|
|
821
|
-
//
|
|
848
|
+
// ../../packages/cli/dist/commands/chain.js
|
|
822
849
|
async function chainCommand(prompt, agents, opts) {
|
|
823
850
|
if (agents.length < 2) {
|
|
824
851
|
console.error(errorLine("omni chain requires at least 2 agents"));
|
|
@@ -852,7 +879,8 @@ async function chainCommand(prompt, agents, opts) {
|
|
|
852
879
|
for (let i = 0; i < agents.length; i++) {
|
|
853
880
|
const agentName = agents[i];
|
|
854
881
|
console.log(agentHeader(agentName, providerLabel));
|
|
855
|
-
if (opts.stream)
|
|
882
|
+
if (opts.stream)
|
|
883
|
+
process.stdout.write("\n");
|
|
856
884
|
const result = await runtime.run(agentName, currentInput, { onToken }).catch((err) => {
|
|
857
885
|
console.error(errorLine(err instanceof Error ? err.message : String(err)));
|
|
858
886
|
process.exit(1);
|
|
@@ -892,7 +920,7 @@ ${lastOutput}
|
|
|
892
920
|
console.log();
|
|
893
921
|
}
|
|
894
922
|
|
|
895
|
-
//
|
|
923
|
+
// ../../packages/cli/dist/commands/eval.js
|
|
896
924
|
import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
|
|
897
925
|
import chalk3 from "chalk";
|
|
898
926
|
function normalize(s) {
|
|
@@ -901,8 +929,10 @@ function normalize(s) {
|
|
|
901
929
|
function matchCase(expected, actual) {
|
|
902
930
|
const normExpected = normalize(expected);
|
|
903
931
|
const normActual = normalize(actual);
|
|
904
|
-
if (normActual === normExpected)
|
|
905
|
-
|
|
932
|
+
if (normActual === normExpected)
|
|
933
|
+
return "exact";
|
|
934
|
+
if (normActual.includes(normExpected))
|
|
935
|
+
return "contains";
|
|
906
936
|
return "miss";
|
|
907
937
|
}
|
|
908
938
|
function buildReport(agent, results) {
|
|
@@ -955,43 +985,38 @@ ${agentHeader(agent, providerLabel)}`);
|
|
|
955
985
|
console.log(chalk3.gray(` Dataset: ${datasetPath} (${cases.length} cases, concurrency ${concurrency})
|
|
956
986
|
`));
|
|
957
987
|
const matchSymbol = (m) => {
|
|
958
|
-
if (m === "exact")
|
|
959
|
-
|
|
988
|
+
if (m === "exact")
|
|
989
|
+
return chalk3.green("\u2713");
|
|
990
|
+
if (m === "contains")
|
|
991
|
+
return chalk3.yellow("~");
|
|
960
992
|
return chalk3.red("\u2716");
|
|
961
993
|
};
|
|
962
|
-
const results = await runBatch(
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
concurrency,
|
|
973
|
-
(r, done, total) => {
|
|
974
|
-
console.log(` ${matchSymbol(r.match)} ${String(done).padStart(String(total).length)}/${total} [${r.match}]`);
|
|
975
|
-
}
|
|
976
|
-
);
|
|
994
|
+
const results = await runBatch(cases, async (c) => {
|
|
995
|
+
const result = await runtime.run(agent, c.input).catch((err) => ({
|
|
996
|
+
output: `ERROR: ${err instanceof Error ? err.message : String(err)}`,
|
|
997
|
+
iterations: 0
|
|
998
|
+
}));
|
|
999
|
+
const match = matchCase(c.expected, result.output);
|
|
1000
|
+
return { input: c.input, expected: c.expected, actual: result.output, match };
|
|
1001
|
+
}, concurrency, (r, done, total) => {
|
|
1002
|
+
console.log(` ${matchSymbol(r.match)} ${String(done).padStart(String(total).length)}/${total} [${r.match}]`);
|
|
1003
|
+
});
|
|
977
1004
|
const report = buildReport(agent, results);
|
|
978
1005
|
const scoreColor = report.score >= 0.8 ? chalk3.green : report.score >= 0.5 ? chalk3.yellow : chalk3.red;
|
|
979
1006
|
const misses = report.total - report.passed;
|
|
980
|
-
console.log(
|
|
981
|
-
`
|
|
1007
|
+
console.log(`
|
|
982
1008
|
${chalk3.bold("Resultado:")} ${scoreColor(`${report.passed}/${report.total} (${Math.round(report.score * 100)}%)`)} \xB7 ${misses === 0 ? chalk3.green("0 erros") : chalk3.red(`${misses} erros`)}
|
|
983
|
-
`
|
|
984
|
-
);
|
|
1009
|
+
`);
|
|
985
1010
|
if (opts.output) {
|
|
986
1011
|
await writeFile3(opts.output, JSON.stringify(report, null, 2), "utf-8");
|
|
987
1012
|
console.log(chalk3.green(`Report saved to: ${opts.output}`));
|
|
988
1013
|
}
|
|
989
1014
|
}
|
|
990
1015
|
|
|
991
|
-
//
|
|
1016
|
+
// ../../packages/cli/dist/commands/export.js
|
|
992
1017
|
import { writeFile as writeFile4 } from "fs/promises";
|
|
993
1018
|
|
|
994
|
-
//
|
|
1019
|
+
// ../../packages/memory/dist/stores/sqlite.js
|
|
995
1020
|
import Database from "better-sqlite3";
|
|
996
1021
|
var SQLiteMemoryStore = class {
|
|
997
1022
|
db;
|
|
@@ -1036,10 +1061,8 @@ var SQLiteMemoryStore = class {
|
|
|
1036
1061
|
`);
|
|
1037
1062
|
}
|
|
1038
1063
|
async saveMessages(session, messages) {
|
|
1039
|
-
const insert = this.db.prepare(
|
|
1040
|
-
|
|
1041
|
-
VALUES (@resourceId, @threadId, @role, @content, @timestamp)`
|
|
1042
|
-
);
|
|
1064
|
+
const insert = this.db.prepare(`INSERT INTO messages (resource_id, thread_id, role, content, timestamp)
|
|
1065
|
+
VALUES (@resourceId, @threadId, @role, @content, @timestamp)`);
|
|
1043
1066
|
const insertMany = this.db.transaction((entries) => {
|
|
1044
1067
|
for (const e of entries) {
|
|
1045
1068
|
insert.run({ ...session, role: e.role, content: e.content, timestamp: e.timestamp });
|
|
@@ -1049,24 +1072,20 @@ var SQLiteMemoryStore = class {
|
|
|
1049
1072
|
}
|
|
1050
1073
|
async loadMessages(session, limit) {
|
|
1051
1074
|
const n = limit ?? this.defaultLimit;
|
|
1052
|
-
const rows = this.db.prepare(
|
|
1053
|
-
`SELECT role, content, timestamp FROM (
|
|
1075
|
+
const rows = this.db.prepare(`SELECT role, content, timestamp FROM (
|
|
1054
1076
|
SELECT role, content, timestamp FROM messages
|
|
1055
1077
|
WHERE resource_id = ? AND thread_id = ?
|
|
1056
1078
|
ORDER BY id DESC LIMIT ?
|
|
1057
|
-
) ORDER BY timestamp ASC`
|
|
1058
|
-
).all(session.resourceId, session.threadId, n);
|
|
1079
|
+
) ORDER BY timestamp ASC`).all(session.resourceId, session.threadId, n);
|
|
1059
1080
|
return rows;
|
|
1060
1081
|
}
|
|
1061
1082
|
async search(session, query, topK = 5) {
|
|
1062
|
-
const rows = this.db.prepare(
|
|
1063
|
-
`SELECT m.content, rank AS score
|
|
1083
|
+
const rows = this.db.prepare(`SELECT m.content, rank AS score
|
|
1064
1084
|
FROM messages_fts fts
|
|
1065
1085
|
JOIN messages m ON m.id = fts.rowid
|
|
1066
1086
|
WHERE fts.content MATCH ?
|
|
1067
1087
|
AND m.resource_id = ? AND m.thread_id = ?
|
|
1068
|
-
ORDER BY rank LIMIT ?`
|
|
1069
|
-
).all(query, session.resourceId, session.threadId, topK);
|
|
1088
|
+
ORDER BY rank LIMIT ?`).all(query, session.resourceId, session.threadId, topK);
|
|
1070
1089
|
return rows.map((r) => ({ content: r.content, score: r.score }));
|
|
1071
1090
|
}
|
|
1072
1091
|
async getWorkingMemory(session) {
|
|
@@ -1074,18 +1093,16 @@ var SQLiteMemoryStore = class {
|
|
|
1074
1093
|
return row?.content ?? null;
|
|
1075
1094
|
}
|
|
1076
1095
|
async setWorkingMemory(session, content) {
|
|
1077
|
-
this.db.prepare(
|
|
1078
|
-
`INSERT INTO working_memory (resource_id, thread_id, content, updated_at)
|
|
1096
|
+
this.db.prepare(`INSERT INTO working_memory (resource_id, thread_id, content, updated_at)
|
|
1079
1097
|
VALUES (?, ?, ?, ?)
|
|
1080
|
-
ON CONFLICT (resource_id, thread_id) DO UPDATE SET content = excluded.content, updated_at = excluded.updated_at`
|
|
1081
|
-
).run(session.resourceId, session.threadId, content, Date.now());
|
|
1098
|
+
ON CONFLICT (resource_id, thread_id) DO UPDATE SET content = excluded.content, updated_at = excluded.updated_at`).run(session.resourceId, session.threadId, content, Date.now());
|
|
1082
1099
|
}
|
|
1083
1100
|
async close() {
|
|
1084
1101
|
this.db.close();
|
|
1085
1102
|
}
|
|
1086
1103
|
};
|
|
1087
1104
|
|
|
1088
|
-
//
|
|
1105
|
+
// ../../packages/cli/dist/commands/export.js
|
|
1089
1106
|
import chalk4 from "chalk";
|
|
1090
1107
|
function getDbPath() {
|
|
1091
1108
|
const home = process.env.HOME ?? process.env.USERPROFILE ?? ".";
|
|
@@ -1138,7 +1155,7 @@ async function exportCommand(sessionArg, opts) {
|
|
|
1138
1155
|
${messages.length} message(s) exported.`));
|
|
1139
1156
|
}
|
|
1140
1157
|
|
|
1141
|
-
//
|
|
1158
|
+
// ../../packages/cli/dist/commands/init.js
|
|
1142
1159
|
import { access, readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
|
|
1143
1160
|
import { dirname as dirname3, resolve as resolve9 } from "path";
|
|
1144
1161
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
@@ -1162,9 +1179,11 @@ async function readEnvFile(path) {
|
|
|
1162
1179
|
const content = await readFile6(path, "utf-8");
|
|
1163
1180
|
for (const line of content.split("\n")) {
|
|
1164
1181
|
const trimmed = line.trim();
|
|
1165
|
-
if (!trimmed || trimmed.startsWith("#"))
|
|
1182
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
1183
|
+
continue;
|
|
1166
1184
|
const eq = trimmed.indexOf("=");
|
|
1167
|
-
if (eq === -1)
|
|
1185
|
+
if (eq === -1)
|
|
1186
|
+
continue;
|
|
1168
1187
|
map.set(trimmed.slice(0, eq).trim(), trimmed.slice(eq + 1).trim());
|
|
1169
1188
|
}
|
|
1170
1189
|
} catch {
|
|
@@ -1200,7 +1219,8 @@ function buildYaml(primary, extras) {
|
|
|
1200
1219
|
const allProviders = [primary, ...extras];
|
|
1201
1220
|
const providerBlocks = allProviders.map((p) => {
|
|
1202
1221
|
const lines = [` - name: ${p.name}`, ` type: ${p.type}`, ` apiKey: \${${p.envKey}}`];
|
|
1203
|
-
if (p.baseUrl)
|
|
1222
|
+
if (p.baseUrl)
|
|
1223
|
+
lines.push(` baseUrl: ${p.baseUrl}`);
|
|
1204
1224
|
lines.push(` defaultModel: ${p.defaultModel}`);
|
|
1205
1225
|
return lines.join("\n");
|
|
1206
1226
|
}).join("\n\n");
|
|
@@ -1460,13 +1480,13 @@ async function initCommand() {
|
|
|
1460
1480
|
console.log();
|
|
1461
1481
|
}
|
|
1462
1482
|
|
|
1463
|
-
//
|
|
1483
|
+
// ../../packages/cli/dist/commands/list.js
|
|
1464
1484
|
import chalk6 from "chalk";
|
|
1465
1485
|
async function listCommand(target, opts) {
|
|
1466
1486
|
const configPath = opts.config ?? resolveConfigPath();
|
|
1467
1487
|
if (target === "providers") {
|
|
1468
|
-
await import("../
|
|
1469
|
-
await import("../
|
|
1488
|
+
await import("../dist-Z76P5KV4.js");
|
|
1489
|
+
await import("../dist-KBUP5623.js");
|
|
1470
1490
|
const names = getRegisteredProviders();
|
|
1471
1491
|
console.log(chalk6.bold("Registered providers:"));
|
|
1472
1492
|
for (const name of names) {
|
|
@@ -1513,7 +1533,7 @@ async function listCommand(target, opts) {
|
|
|
1513
1533
|
process.exit(1);
|
|
1514
1534
|
}
|
|
1515
1535
|
|
|
1516
|
-
//
|
|
1536
|
+
// ../../packages/mcp/dist/server.js
|
|
1517
1537
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
1518
1538
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
1519
1539
|
import { z as z12 } from "zod";
|
|
@@ -1534,22 +1554,18 @@ function createMcpServer(skills2, options) {
|
|
|
1534
1554
|
config: options?.ctx?.config ?? {}
|
|
1535
1555
|
};
|
|
1536
1556
|
for (const skill of skills2) {
|
|
1537
|
-
server.registerTool(
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
content: [{ type: "text", text: `Error: ${err instanceof Error ? err.message : String(err)}` }],
|
|
1548
|
-
isError: true
|
|
1549
|
-
};
|
|
1550
|
-
}
|
|
1557
|
+
server.registerTool(skill.name, { description: skill.description, inputSchema: z12.record(z12.unknown()) }, async (args) => {
|
|
1558
|
+
try {
|
|
1559
|
+
const result = await skill.execute(args, ctx);
|
|
1560
|
+
const text = typeof result === "string" ? result : JSON.stringify(result);
|
|
1561
|
+
return { content: [{ type: "text", text }] };
|
|
1562
|
+
} catch (err) {
|
|
1563
|
+
return {
|
|
1564
|
+
content: [{ type: "text", text: `Error: ${err instanceof Error ? err.message : String(err)}` }],
|
|
1565
|
+
isError: true
|
|
1566
|
+
};
|
|
1551
1567
|
}
|
|
1552
|
-
);
|
|
1568
|
+
});
|
|
1553
1569
|
}
|
|
1554
1570
|
return server;
|
|
1555
1571
|
}
|
|
@@ -1563,10 +1579,10 @@ async function serveStdioMcp(skills2, options) {
|
|
|
1563
1579
|
return serveMcp(skills2, transport, options);
|
|
1564
1580
|
}
|
|
1565
1581
|
|
|
1566
|
-
//
|
|
1582
|
+
// ../../packages/mcp/dist/skill.js
|
|
1567
1583
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
1568
1584
|
|
|
1569
|
-
//
|
|
1585
|
+
// ../../packages/skills/dist/backend/analyze-dynamo-schema.js
|
|
1570
1586
|
import { readFile as readFile7 } from "fs/promises";
|
|
1571
1587
|
import { resolve as resolve10 } from "path";
|
|
1572
1588
|
import { z as z13 } from "zod";
|
|
@@ -1583,13 +1599,16 @@ function extractEntityType(source) {
|
|
|
1583
1599
|
}
|
|
1584
1600
|
function extractFields(source) {
|
|
1585
1601
|
const fieldsKeyIdx = source.indexOf("fields:");
|
|
1586
|
-
if (fieldsKeyIdx === -1)
|
|
1602
|
+
if (fieldsKeyIdx === -1)
|
|
1603
|
+
return [];
|
|
1587
1604
|
const braceOpen = source.indexOf("{", fieldsKeyIdx);
|
|
1588
|
-
if (braceOpen === -1)
|
|
1605
|
+
if (braceOpen === -1)
|
|
1606
|
+
return [];
|
|
1589
1607
|
let depth = 0;
|
|
1590
1608
|
let fieldsEnd = -1;
|
|
1591
1609
|
for (let i = braceOpen; i < source.length; i++) {
|
|
1592
|
-
if (source[i] === "{")
|
|
1610
|
+
if (source[i] === "{")
|
|
1611
|
+
depth++;
|
|
1593
1612
|
else if (source[i] === "}") {
|
|
1594
1613
|
depth--;
|
|
1595
1614
|
if (depth === 0) {
|
|
@@ -1598,7 +1617,8 @@ function extractFields(source) {
|
|
|
1598
1617
|
}
|
|
1599
1618
|
}
|
|
1600
1619
|
}
|
|
1601
|
-
if (fieldsEnd === -1)
|
|
1620
|
+
if (fieldsEnd === -1)
|
|
1621
|
+
return [];
|
|
1602
1622
|
const fieldsBlock = source.slice(braceOpen + 1, fieldsEnd);
|
|
1603
1623
|
const fields = [];
|
|
1604
1624
|
for (const m of fieldsBlock.matchAll(/(\w+)\s*:\s*\{([^}]*)\}/g)) {
|
|
@@ -1642,7 +1662,7 @@ var analyzeDynamoSchemaSkill = {
|
|
|
1642
1662
|
}
|
|
1643
1663
|
};
|
|
1644
1664
|
|
|
1645
|
-
//
|
|
1665
|
+
// ../../packages/skills/dist/backend/analyze-graphql-schema.js
|
|
1646
1666
|
import { readFile as readFile8 } from "fs/promises";
|
|
1647
1667
|
import { resolve as resolve11 } from "path";
|
|
1648
1668
|
import { z as z14 } from "zod";
|
|
@@ -1652,7 +1672,8 @@ var InputSchema13 = z14.object({
|
|
|
1652
1672
|
function extractOperations(source, section) {
|
|
1653
1673
|
const sectionRe = new RegExp(`extend\\s+type\\s+${section}\\s*\\{([^}]*)\\}`, "s");
|
|
1654
1674
|
const match = sectionRe.exec(source);
|
|
1655
|
-
if (!match)
|
|
1675
|
+
if (!match)
|
|
1676
|
+
return [];
|
|
1656
1677
|
const ops = [];
|
|
1657
1678
|
for (const m of match[1].matchAll(/(\w+)\s*(\([^)]*\))?\s*:\s*([^\n@#]+)((?:\s*@\w+[^\n]*)*)/g)) {
|
|
1658
1679
|
const directives = m[4].trim().split(/\s*@/).filter(Boolean).map((d) => `@${d.trim()}`);
|
|
@@ -1668,7 +1689,8 @@ function extractOperations(source, section) {
|
|
|
1668
1689
|
function extractTypes(source) {
|
|
1669
1690
|
const types = [];
|
|
1670
1691
|
for (const m of source.matchAll(/(?:^|\n)\s*(?:extend\s+)?type\s+(\w+)\s*(?:implements[^{]*)?\{/g)) {
|
|
1671
|
-
if (!["Query", "Mutation", "Subscription"].includes(m[1]))
|
|
1692
|
+
if (!["Query", "Mutation", "Subscription"].includes(m[1]))
|
|
1693
|
+
types.push(m[1]);
|
|
1672
1694
|
}
|
|
1673
1695
|
return [...new Set(types)];
|
|
1674
1696
|
}
|
|
@@ -1694,7 +1716,7 @@ var analyzeGraphqlSchemaSkill = {
|
|
|
1694
1716
|
}
|
|
1695
1717
|
};
|
|
1696
1718
|
|
|
1697
|
-
//
|
|
1719
|
+
// ../../packages/skills/dist/backend/analyze-nestjs-module.js
|
|
1698
1720
|
import { readFile as readFile9 } from "fs/promises";
|
|
1699
1721
|
import { resolve as resolve12 } from "path";
|
|
1700
1722
|
import { z as z15 } from "zod";
|
|
@@ -1704,10 +1726,9 @@ var InputSchema14 = z15.object({
|
|
|
1704
1726
|
function extractArrayItems(source, key) {
|
|
1705
1727
|
const re = new RegExp(`${key}\\s*:\\s*\\[([^\\]]*?)\\]`, "s");
|
|
1706
1728
|
const match = re.exec(source);
|
|
1707
|
-
if (!match)
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
).filter(Boolean);
|
|
1729
|
+
if (!match)
|
|
1730
|
+
return [];
|
|
1731
|
+
return match[1].split(",").map((s) => s.trim().replace(/\/\/.*$/m, "").trim()).filter(Boolean);
|
|
1711
1732
|
}
|
|
1712
1733
|
function extractModuleName(source) {
|
|
1713
1734
|
const match = /export\s+class\s+(\w+Module)/.exec(source);
|
|
@@ -1729,7 +1750,7 @@ var analyzeNestjsModuleSkill = {
|
|
|
1729
1750
|
}
|
|
1730
1751
|
};
|
|
1731
1752
|
|
|
1732
|
-
//
|
|
1753
|
+
// ../../packages/skills/dist/backend/find-code-pattern.js
|
|
1733
1754
|
import { readdir as readdir4, readFile as readFile10 } from "fs/promises";
|
|
1734
1755
|
import { join as join4 } from "path";
|
|
1735
1756
|
import { z as z16 } from "zod";
|
|
@@ -1747,12 +1768,16 @@ var InputSchema15 = z16.object({
|
|
|
1747
1768
|
maxExamples: z16.number().int().positive().default(3).describe("Maximum number of examples to return")
|
|
1748
1769
|
});
|
|
1749
1770
|
async function walkForPattern(dir, suffixes, results, max) {
|
|
1750
|
-
if (results.length >= max)
|
|
1771
|
+
if (results.length >= max)
|
|
1772
|
+
return;
|
|
1751
1773
|
const entries = await readdir4(dir, { withFileTypes: true }).catch(() => null);
|
|
1752
|
-
if (!entries)
|
|
1774
|
+
if (!entries)
|
|
1775
|
+
return;
|
|
1753
1776
|
for (const entry of entries) {
|
|
1754
|
-
if (results.length >= max)
|
|
1755
|
-
|
|
1777
|
+
if (results.length >= max)
|
|
1778
|
+
break;
|
|
1779
|
+
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git")
|
|
1780
|
+
continue;
|
|
1756
1781
|
const fullPath = join4(dir, entry.name);
|
|
1757
1782
|
if (entry.isDirectory()) {
|
|
1758
1783
|
await walkForPattern(fullPath, suffixes, results, max);
|
|
@@ -1774,7 +1799,7 @@ var findCodePatternSkill = {
|
|
|
1774
1799
|
}
|
|
1775
1800
|
};
|
|
1776
1801
|
|
|
1777
|
-
//
|
|
1802
|
+
// ../../packages/skills/dist/frontend/analyze-component.js
|
|
1778
1803
|
import { readFile as readFile11 } from "fs/promises";
|
|
1779
1804
|
import { resolve as resolve13 } from "path";
|
|
1780
1805
|
import { z as z17 } from "zod";
|
|
@@ -1783,15 +1808,18 @@ var InputSchema16 = z17.object({
|
|
|
1783
1808
|
});
|
|
1784
1809
|
function extractComponentName(source, filePath) {
|
|
1785
1810
|
const fnMatch = /(?:export\s+(?:default\s+)?function\s+|const\s+)([A-Z]\w*)/.exec(source);
|
|
1786
|
-
if (fnMatch)
|
|
1811
|
+
if (fnMatch)
|
|
1812
|
+
return fnMatch[1];
|
|
1787
1813
|
const parts = filePath.split(/[/\\]/);
|
|
1788
1814
|
return (parts[parts.length - 1] ?? "").replace(/\.(tsx?|jsx?)$/, "");
|
|
1789
1815
|
}
|
|
1790
1816
|
function extractPropsInterface(source) {
|
|
1791
1817
|
const ifaceMatch = /interface\s+(\w*Props\w*)\s*\{([^}]*)\}/.exec(source);
|
|
1792
|
-
if (ifaceMatch)
|
|
1818
|
+
if (ifaceMatch)
|
|
1819
|
+
return `interface ${ifaceMatch[1]} {${ifaceMatch[2]}}`;
|
|
1793
1820
|
const typeMatch = /type\s+(\w*Props\w*)\s*=\s*\{([^}]*)\}/.exec(source);
|
|
1794
|
-
if (typeMatch)
|
|
1821
|
+
if (typeMatch)
|
|
1822
|
+
return `type ${typeMatch[1]} = {${typeMatch[2]}}`;
|
|
1795
1823
|
return null;
|
|
1796
1824
|
}
|
|
1797
1825
|
function extractHooksUsed(source) {
|
|
@@ -1817,7 +1845,7 @@ var analyzeComponentSkill = {
|
|
|
1817
1845
|
}
|
|
1818
1846
|
};
|
|
1819
1847
|
|
|
1820
|
-
//
|
|
1848
|
+
// ../../packages/skills/dist/frontend/analyze-module-structure.js
|
|
1821
1849
|
import { readdir as readdir5 } from "fs/promises";
|
|
1822
1850
|
import { join as join5 } from "path";
|
|
1823
1851
|
import { z as z18 } from "zod";
|
|
@@ -1826,10 +1854,12 @@ var InputSchema17 = z18.object({
|
|
|
1826
1854
|
});
|
|
1827
1855
|
async function collectFiles2(dir) {
|
|
1828
1856
|
const entries = await readdir5(dir, { withFileTypes: true }).catch(() => null);
|
|
1829
|
-
if (!entries)
|
|
1857
|
+
if (!entries)
|
|
1858
|
+
return [];
|
|
1830
1859
|
const files = [];
|
|
1831
1860
|
for (const entry of entries) {
|
|
1832
|
-
if (entry.name === "node_modules" || entry.name === "dist")
|
|
1861
|
+
if (entry.name === "node_modules" || entry.name === "dist")
|
|
1862
|
+
continue;
|
|
1833
1863
|
const fullPath = join5(dir, entry.name);
|
|
1834
1864
|
if (entry.isDirectory()) {
|
|
1835
1865
|
files.push(...await collectFiles2(fullPath));
|
|
@@ -1843,12 +1873,18 @@ function categorize(files) {
|
|
|
1843
1873
|
const result = { components: [], hooks: [], pages: [], stores: [], indexFiles: [] };
|
|
1844
1874
|
for (const f of files) {
|
|
1845
1875
|
const name = f.split(/[/\\]/).pop() ?? "";
|
|
1846
|
-
if (name.includes(".spec.") || name.includes(".test."))
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
else if (
|
|
1851
|
-
|
|
1876
|
+
if (name.includes(".spec.") || name.includes(".test."))
|
|
1877
|
+
continue;
|
|
1878
|
+
if (name === "index.ts" || name === "index.tsx")
|
|
1879
|
+
result.indexFiles.push(f);
|
|
1880
|
+
else if (name.startsWith("use"))
|
|
1881
|
+
result.hooks.push(f);
|
|
1882
|
+
else if (/page|route/i.test(name))
|
|
1883
|
+
result.pages.push(f);
|
|
1884
|
+
else if (/store|context|provider/i.test(name))
|
|
1885
|
+
result.stores.push(f);
|
|
1886
|
+
else if (/^[A-Z]/.test(name))
|
|
1887
|
+
result.components.push(f);
|
|
1852
1888
|
}
|
|
1853
1889
|
return result;
|
|
1854
1890
|
}
|
|
@@ -1862,7 +1898,7 @@ var analyzeModuleStructureSkill = {
|
|
|
1862
1898
|
}
|
|
1863
1899
|
};
|
|
1864
1900
|
|
|
1865
|
-
//
|
|
1901
|
+
// ../../packages/skills/dist/frontend/find-component-pattern.js
|
|
1866
1902
|
import { readdir as readdir6, readFile as readFile12 } from "fs/promises";
|
|
1867
1903
|
import { join as join6 } from "path";
|
|
1868
1904
|
import { z as z19 } from "zod";
|
|
@@ -1878,12 +1914,16 @@ var InputSchema18 = z19.object({
|
|
|
1878
1914
|
maxExamples: z19.number().int().positive().default(3).describe("Maximum number of examples to return")
|
|
1879
1915
|
});
|
|
1880
1916
|
async function walkForComponent(dir, filter, results, max) {
|
|
1881
|
-
if (results.length >= max)
|
|
1917
|
+
if (results.length >= max)
|
|
1918
|
+
return;
|
|
1882
1919
|
const entries = await readdir6(dir, { withFileTypes: true }).catch(() => null);
|
|
1883
|
-
if (!entries)
|
|
1920
|
+
if (!entries)
|
|
1921
|
+
return;
|
|
1884
1922
|
for (const entry of entries) {
|
|
1885
|
-
if (results.length >= max)
|
|
1886
|
-
|
|
1923
|
+
if (results.length >= max)
|
|
1924
|
+
break;
|
|
1925
|
+
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git")
|
|
1926
|
+
continue;
|
|
1887
1927
|
const fullPath = join6(dir, entry.name);
|
|
1888
1928
|
if (entry.isDirectory()) {
|
|
1889
1929
|
await walkForComponent(fullPath, filter, results, max);
|
|
@@ -1905,7 +1945,7 @@ var findComponentPatternSkill = {
|
|
|
1905
1945
|
}
|
|
1906
1946
|
};
|
|
1907
1947
|
|
|
1908
|
-
//
|
|
1948
|
+
// ../../packages/skills/dist/qa/analyze-test-coverage.js
|
|
1909
1949
|
import { readdir as readdir7 } from "fs/promises";
|
|
1910
1950
|
import { join as join7 } from "path";
|
|
1911
1951
|
import { z as z20 } from "zod";
|
|
@@ -1916,10 +1956,12 @@ var InputSchema19 = z20.object({
|
|
|
1916
1956
|
});
|
|
1917
1957
|
async function collectFiles3(dir, exts, ignore) {
|
|
1918
1958
|
const entries = await readdir7(dir, { withFileTypes: true }).catch(() => null);
|
|
1919
|
-
if (!entries)
|
|
1959
|
+
if (!entries)
|
|
1960
|
+
return [];
|
|
1920
1961
|
const files = [];
|
|
1921
1962
|
for (const entry of entries) {
|
|
1922
|
-
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git")
|
|
1963
|
+
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git")
|
|
1964
|
+
continue;
|
|
1923
1965
|
const fullPath = join7(dir, entry.name);
|
|
1924
1966
|
if (entry.isDirectory()) {
|
|
1925
1967
|
files.push(...await collectFiles3(fullPath, exts, ignore));
|
|
@@ -1948,8 +1990,10 @@ var analyzeTestCoverageSkill = {
|
|
|
1948
1990
|
const uncovered = [];
|
|
1949
1991
|
for (const file of sourceFiles) {
|
|
1950
1992
|
const hasSpec = specPathCandidates(file).some((s) => allFiles.has(s));
|
|
1951
|
-
if (hasSpec)
|
|
1952
|
-
|
|
1993
|
+
if (hasSpec)
|
|
1994
|
+
covered.push(file);
|
|
1995
|
+
else
|
|
1996
|
+
uncovered.push(file);
|
|
1953
1997
|
}
|
|
1954
1998
|
const total = covered.length + uncovered.length;
|
|
1955
1999
|
return {
|
|
@@ -1960,7 +2004,7 @@ var analyzeTestCoverageSkill = {
|
|
|
1960
2004
|
}
|
|
1961
2005
|
};
|
|
1962
2006
|
|
|
1963
|
-
//
|
|
2007
|
+
// ../../packages/skills/dist/qa/find-test-pattern.js
|
|
1964
2008
|
import { readdir as readdir8, readFile as readFile13 } from "fs/promises";
|
|
1965
2009
|
import { join as join8 } from "path";
|
|
1966
2010
|
import { z as z21 } from "zod";
|
|
@@ -1976,12 +2020,16 @@ var InputSchema20 = z21.object({
|
|
|
1976
2020
|
maxExamples: z21.number().int().positive().default(2).describe("Maximum number of test examples to return")
|
|
1977
2021
|
});
|
|
1978
2022
|
async function walkForTests(dir, filter, results, max) {
|
|
1979
|
-
if (results.length >= max)
|
|
2023
|
+
if (results.length >= max)
|
|
2024
|
+
return;
|
|
1980
2025
|
const entries = await readdir8(dir, { withFileTypes: true }).catch(() => null);
|
|
1981
|
-
if (!entries)
|
|
2026
|
+
if (!entries)
|
|
2027
|
+
return;
|
|
1982
2028
|
for (const entry of entries) {
|
|
1983
|
-
if (results.length >= max)
|
|
1984
|
-
|
|
2029
|
+
if (results.length >= max)
|
|
2030
|
+
break;
|
|
2031
|
+
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git")
|
|
2032
|
+
continue;
|
|
1985
2033
|
const fullPath = join8(dir, entry.name);
|
|
1986
2034
|
if (entry.isDirectory()) {
|
|
1987
2035
|
await walkForTests(fullPath, filter, results, max);
|
|
@@ -2003,7 +2051,7 @@ var findTestPatternSkill = {
|
|
|
2003
2051
|
}
|
|
2004
2052
|
};
|
|
2005
2053
|
|
|
2006
|
-
//
|
|
2054
|
+
// ../../packages/cli/dist/commands/mcp-serve.js
|
|
2007
2055
|
import chalk7 from "chalk";
|
|
2008
2056
|
var skills = [
|
|
2009
2057
|
readFileSkill,
|
|
@@ -2039,20 +2087,20 @@ async function mcpServeCommand() {
|
|
|
2039
2087
|
});
|
|
2040
2088
|
}
|
|
2041
2089
|
|
|
2042
|
-
//
|
|
2090
|
+
// ../../packages/cli/dist/commands/new.js
|
|
2043
2091
|
import { readFile as readFile14 } from "fs/promises";
|
|
2044
2092
|
import { join as join12 } from "path";
|
|
2045
2093
|
import { select as select4 } from "@inquirer/prompts";
|
|
2046
2094
|
import chalk11 from "chalk";
|
|
2047
2095
|
import YAML from "yaml";
|
|
2048
2096
|
|
|
2049
|
-
//
|
|
2097
|
+
// ../../packages/cli/dist/commands/new/scaffold-agent.js
|
|
2050
2098
|
import { access as access2, mkdir as mkdir2, writeFile as writeFile6 } from "fs/promises";
|
|
2051
2099
|
import { join as join9, resolve as resolve14 } from "path";
|
|
2052
2100
|
import { checkbox as checkbox2, confirm as confirm2, input as input2, select as select2 } from "@inquirer/prompts";
|
|
2053
2101
|
import chalk8 from "chalk";
|
|
2054
2102
|
|
|
2055
|
-
//
|
|
2103
|
+
// ../../packages/cli/dist/commands/new/templates.js
|
|
2056
2104
|
function kebabToPascal(s) {
|
|
2057
2105
|
return s.replace(/(^|-)([a-z])/g, (_, __, c) => c.toUpperCase());
|
|
2058
2106
|
}
|
|
@@ -2124,57 +2172,49 @@ export class ${pascal}Provider implements IProvider {
|
|
|
2124
2172
|
|
|
2125
2173
|
ProviderRegistry.register(new ${pascal}Provider());
|
|
2126
2174
|
`;
|
|
2127
|
-
const packageJson = JSON.stringify(
|
|
2128
|
-
{
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
"."
|
|
2134
|
-
|
|
2135
|
-
types: "./dist/index.d.ts"
|
|
2136
|
-
}
|
|
2137
|
-
},
|
|
2138
|
-
scripts: {
|
|
2139
|
-
build: "tsc",
|
|
2140
|
-
typecheck: "tsc --noEmit"
|
|
2141
|
-
},
|
|
2142
|
-
dependencies: {
|
|
2143
|
-
"@omni-ai/core": "workspace:*"
|
|
2144
|
-
},
|
|
2145
|
-
devDependencies: {
|
|
2146
|
-
typescript: "^5.7.0",
|
|
2147
|
-
"@types/node": "^22.0.0"
|
|
2175
|
+
const packageJson = JSON.stringify({
|
|
2176
|
+
name: `@omni-ai/provider-${params.kebabName}`,
|
|
2177
|
+
version: "0.1.0",
|
|
2178
|
+
type: "module",
|
|
2179
|
+
exports: {
|
|
2180
|
+
".": {
|
|
2181
|
+
import: "./dist/index.js",
|
|
2182
|
+
types: "./dist/index.d.ts"
|
|
2148
2183
|
}
|
|
2149
2184
|
},
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
const tsconfigJson = JSON.stringify(
|
|
2154
|
-
{
|
|
2155
|
-
compilerOptions: {
|
|
2156
|
-
target: "ES2022",
|
|
2157
|
-
module: "NodeNext",
|
|
2158
|
-
moduleResolution: "NodeNext",
|
|
2159
|
-
lib: ["ES2022"],
|
|
2160
|
-
outDir: "dist",
|
|
2161
|
-
rootDir: "src",
|
|
2162
|
-
declaration: true,
|
|
2163
|
-
declarationDir: "dist",
|
|
2164
|
-
strict: true,
|
|
2165
|
-
esModuleInterop: false,
|
|
2166
|
-
skipLibCheck: true
|
|
2167
|
-
},
|
|
2168
|
-
include: ["src"],
|
|
2169
|
-
references: [{ path: "../core" }]
|
|
2185
|
+
scripts: {
|
|
2186
|
+
build: "tsc",
|
|
2187
|
+
typecheck: "tsc --noEmit"
|
|
2170
2188
|
},
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2189
|
+
dependencies: {
|
|
2190
|
+
"@omni-ai/core": "workspace:*"
|
|
2191
|
+
},
|
|
2192
|
+
devDependencies: {
|
|
2193
|
+
typescript: "^5.7.0",
|
|
2194
|
+
"@types/node": "^22.0.0"
|
|
2195
|
+
}
|
|
2196
|
+
}, null, 2);
|
|
2197
|
+
const tsconfigJson = JSON.stringify({
|
|
2198
|
+
compilerOptions: {
|
|
2199
|
+
target: "ES2022",
|
|
2200
|
+
module: "NodeNext",
|
|
2201
|
+
moduleResolution: "NodeNext",
|
|
2202
|
+
lib: ["ES2022"],
|
|
2203
|
+
outDir: "dist",
|
|
2204
|
+
rootDir: "src",
|
|
2205
|
+
declaration: true,
|
|
2206
|
+
declarationDir: "dist",
|
|
2207
|
+
strict: true,
|
|
2208
|
+
esModuleInterop: false,
|
|
2209
|
+
skipLibCheck: true
|
|
2210
|
+
},
|
|
2211
|
+
include: ["src"],
|
|
2212
|
+
references: [{ path: "../core" }]
|
|
2213
|
+
}, null, 2);
|
|
2174
2214
|
return { indexTs, packageJson, tsconfigJson };
|
|
2175
2215
|
}
|
|
2176
2216
|
|
|
2177
|
-
//
|
|
2217
|
+
// ../../packages/cli/dist/commands/new/scaffold-agent.js
|
|
2178
2218
|
var ALL_SKILLS = [
|
|
2179
2219
|
// Layer 1 — primitives
|
|
2180
2220
|
"read-file",
|
|
@@ -2262,7 +2302,7 @@ async function agentWizard(agentsDir) {
|
|
|
2262
2302
|
console.log();
|
|
2263
2303
|
}
|
|
2264
2304
|
|
|
2265
|
-
//
|
|
2305
|
+
// ../../packages/cli/dist/commands/new/scaffold-provider.js
|
|
2266
2306
|
import { access as access3, mkdir as mkdir3, writeFile as writeFile7 } from "fs/promises";
|
|
2267
2307
|
import { join as join10, resolve as resolve15 } from "path";
|
|
2268
2308
|
import { confirm as confirm3, input as input3 } from "@inquirer/prompts";
|
|
@@ -2311,17 +2351,13 @@ async function providerWizard(providersDir) {
|
|
|
2311
2351
|
console.log(`${chalk9.green(" \u2713")} Provider criado: ${chalk9.cyan(`${packageDir}/`)}`);
|
|
2312
2352
|
console.log(chalk9.dim(" Pr\xF3ximos passos:"));
|
|
2313
2353
|
console.log(chalk9.dim(` 1. Implemente complete() em src/index.ts`));
|
|
2314
|
-
console.log(
|
|
2315
|
-
|
|
2316
|
-
);
|
|
2317
|
-
console.log(
|
|
2318
|
-
chalk9.dim(` 3. Importe em packages/cli/src/commands/run.ts: import "@omni-ai/provider-${kebabName}";`)
|
|
2319
|
-
);
|
|
2354
|
+
console.log(chalk9.dim(` 2. Adicione \xE0 raiz tsconfig.json \u2192 references: { path: "./${providersDir}/provider-${kebabName}" }`));
|
|
2355
|
+
console.log(chalk9.dim(` 3. Importe em packages/cli/src/commands/run.ts: import "@omni-ai/provider-${kebabName}";`));
|
|
2320
2356
|
console.log(chalk9.dim(` 4. Adicione a chave de API ao .env.example`));
|
|
2321
2357
|
console.log();
|
|
2322
2358
|
}
|
|
2323
2359
|
|
|
2324
|
-
//
|
|
2360
|
+
// ../../packages/cli/dist/commands/new/scaffold-skill.js
|
|
2325
2361
|
import { access as access4, mkdir as mkdir4, writeFile as writeFile8 } from "fs/promises";
|
|
2326
2362
|
import { join as join11, resolve as resolve16 } from "path";
|
|
2327
2363
|
import { confirm as confirm4, input as input4, select as select3 } from "@inquirer/prompts";
|
|
@@ -2372,7 +2408,7 @@ async function skillWizard(skillsDir) {
|
|
|
2372
2408
|
console.log();
|
|
2373
2409
|
}
|
|
2374
2410
|
|
|
2375
|
-
//
|
|
2411
|
+
// ../../packages/cli/dist/commands/new.js
|
|
2376
2412
|
var DEFAULTS = {
|
|
2377
2413
|
agentsDir: "agents",
|
|
2378
2414
|
skills: "src/skills",
|
|
@@ -2382,7 +2418,8 @@ async function loadScaffoldConfig() {
|
|
|
2382
2418
|
try {
|
|
2383
2419
|
const raw = await readFile14(join12(process.cwd(), "config", "omni-ai.yaml"), "utf-8");
|
|
2384
2420
|
const data = YAML.parse(raw);
|
|
2385
|
-
if (!data)
|
|
2421
|
+
if (!data)
|
|
2422
|
+
return DEFAULTS;
|
|
2386
2423
|
const sp = data.scaffoldPaths;
|
|
2387
2424
|
return {
|
|
2388
2425
|
agentsDir: data.agentsDir ?? DEFAULTS.agentsDir,
|
|
@@ -2419,7 +2456,7 @@ async function newCommand() {
|
|
|
2419
2456
|
}
|
|
2420
2457
|
}
|
|
2421
2458
|
|
|
2422
|
-
//
|
|
2459
|
+
// ../../packages/cli/dist/commands/run.js
|
|
2423
2460
|
import { writeFile as writeFile9 } from "fs/promises";
|
|
2424
2461
|
function parseSession(raw) {
|
|
2425
2462
|
const [resourceId, ...rest] = raw.split(":");
|
|
@@ -2470,7 +2507,8 @@ async function runCommand(agent, prompt, opts) {
|
|
|
2470
2507
|
console.log(`
|
|
2471
2508
|
${agentHeader(agent, providerLabel)}`);
|
|
2472
2509
|
const onToken = opts.stream ? (chunk) => process.stdout.write(chunk) : void 0;
|
|
2473
|
-
if (opts.stream)
|
|
2510
|
+
if (opts.stream)
|
|
2511
|
+
process.stdout.write("\n");
|
|
2474
2512
|
const result = await runtime.run(agent, prompt, { session: sessionId, onToken }).catch(async (err) => {
|
|
2475
2513
|
console.error(errorLine(err instanceof Error ? err.message : String(err)));
|
|
2476
2514
|
await memoryStore?.close?.();
|
|
@@ -2495,7 +2533,7 @@ ${result.output}
|
|
|
2495
2533
|
await memoryStore?.close?.();
|
|
2496
2534
|
}
|
|
2497
2535
|
|
|
2498
|
-
//
|
|
2536
|
+
// ../../packages/cli/dist/commands/serve.js
|
|
2499
2537
|
import chalk12 from "chalk";
|
|
2500
2538
|
import express from "express";
|
|
2501
2539
|
function getDbPath3() {
|
|
@@ -2613,13 +2651,14 @@ async function serveCommand(opts) {
|
|
|
2613
2651
|
});
|
|
2614
2652
|
}
|
|
2615
2653
|
|
|
2616
|
-
//
|
|
2654
|
+
// ../../packages/cli/dist/commands/watch.js
|
|
2617
2655
|
import chalk13 from "chalk";
|
|
2618
2656
|
import chokidar from "chokidar";
|
|
2619
2657
|
function buildDebounce(fn, ms) {
|
|
2620
2658
|
let timer = null;
|
|
2621
2659
|
return () => {
|
|
2622
|
-
if (timer)
|
|
2660
|
+
if (timer)
|
|
2661
|
+
clearTimeout(timer);
|
|
2623
2662
|
timer = setTimeout(fn, ms);
|
|
2624
2663
|
};
|
|
2625
2664
|
}
|
|
@@ -2638,17 +2677,20 @@ async function runOnce(agent, prompt, configPath, stream) {
|
|
|
2638
2677
|
console.error(errorLine(`Failed to load config: ${err instanceof Error ? err.message : String(err)}`));
|
|
2639
2678
|
return null;
|
|
2640
2679
|
});
|
|
2641
|
-
if (!runtime)
|
|
2680
|
+
if (!runtime)
|
|
2681
|
+
return;
|
|
2642
2682
|
const providerLabel = `${runtime.config.defaultProvider} / ${runtime.config.providers.find((p) => p.name === runtime.config.defaultProvider)?.defaultModel ?? "default"}`;
|
|
2643
2683
|
console.log(`
|
|
2644
2684
|
${agentHeader(agent, providerLabel)}`);
|
|
2645
2685
|
const onToken = stream ? (chunk) => process.stdout.write(chunk) : void 0;
|
|
2646
|
-
if (stream)
|
|
2686
|
+
if (stream)
|
|
2687
|
+
process.stdout.write("\n");
|
|
2647
2688
|
const result = await runtime.run(agent, prompt, { onToken }).catch((err) => {
|
|
2648
2689
|
console.error(errorLine(err instanceof Error ? err.message : String(err)));
|
|
2649
2690
|
return null;
|
|
2650
2691
|
});
|
|
2651
|
-
if (!result)
|
|
2692
|
+
if (!result)
|
|
2693
|
+
return;
|
|
2652
2694
|
if (stream) {
|
|
2653
2695
|
process.stdout.write("\n");
|
|
2654
2696
|
} else {
|
|
@@ -2657,7 +2699,8 @@ ${result.output}
|
|
|
2657
2699
|
`);
|
|
2658
2700
|
}
|
|
2659
2701
|
console.log(iterationLine(result.iterations));
|
|
2660
|
-
if (result.usage)
|
|
2702
|
+
if (result.usage)
|
|
2703
|
+
console.log(tokenSummary(result.usage.inputTokens, result.usage.outputTokens));
|
|
2661
2704
|
}
|
|
2662
2705
|
async function watchCommand(agent, prompt, opts) {
|
|
2663
2706
|
const configPath = opts.config ?? resolveConfigPath();
|
|
@@ -2698,7 +2741,7 @@ async function watchCommand(agent, prompt, opts) {
|
|
|
2698
2741
|
});
|
|
2699
2742
|
}
|
|
2700
2743
|
|
|
2701
|
-
//
|
|
2744
|
+
// ../../packages/cli/dist/bin.js
|
|
2702
2745
|
var __dirname2 = dirname4(fileURLToPath3(import.meta.url));
|
|
2703
2746
|
loadDotenv({ path: resolve17(__dirname2, "..", "..", "..", ".env") });
|
|
2704
2747
|
var program = new Command();
|