@knid/agentx 0.1.6 → 0.1.8
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/index.js +103 -17
- package/package.json +11 -9
package/dist/index.js
CHANGED
|
@@ -315,6 +315,89 @@ function buildPromptWithPipe(prompt, pipedContent) {
|
|
|
315
315
|
${prompt}`;
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
+
// src/ui/colors.ts
|
|
319
|
+
import chalk from "chalk";
|
|
320
|
+
var noColor = process.env.NO_COLOR !== void 0 || process.argv.includes("--no-color");
|
|
321
|
+
var identity = (s) => s;
|
|
322
|
+
var colors = {
|
|
323
|
+
success: noColor ? identity : chalk.green,
|
|
324
|
+
error: noColor ? identity : chalk.red,
|
|
325
|
+
warn: noColor ? identity : chalk.yellow,
|
|
326
|
+
info: noColor ? identity : chalk.blue,
|
|
327
|
+
dim: noColor ? identity : chalk.dim,
|
|
328
|
+
bold: noColor ? identity : chalk.bold,
|
|
329
|
+
cyan: noColor ? identity : chalk.cyan,
|
|
330
|
+
magenta: noColor ? identity : chalk.magenta
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
// src/ui/markdown.ts
|
|
334
|
+
import { marked } from "marked";
|
|
335
|
+
import { markedTerminal } from "marked-terminal";
|
|
336
|
+
import chalk2 from "chalk";
|
|
337
|
+
marked.use(
|
|
338
|
+
markedTerminal({
|
|
339
|
+
firstHeading: chalk2.magenta.bold,
|
|
340
|
+
heading: chalk2.magenta.bold,
|
|
341
|
+
strong: chalk2.bold,
|
|
342
|
+
em: chalk2.italic,
|
|
343
|
+
codespan: chalk2.yellow,
|
|
344
|
+
code: chalk2.yellow,
|
|
345
|
+
blockquote: chalk2.gray.italic,
|
|
346
|
+
link: chalk2.cyan,
|
|
347
|
+
href: chalk2.cyan.underline,
|
|
348
|
+
del: chalk2.dim.strikethrough,
|
|
349
|
+
reflowText: true,
|
|
350
|
+
width: Math.min(process.stdout.columns || 80, 100),
|
|
351
|
+
showSectionPrefix: false,
|
|
352
|
+
tab: 2
|
|
353
|
+
})
|
|
354
|
+
);
|
|
355
|
+
marked.use({
|
|
356
|
+
renderer: {
|
|
357
|
+
text(token) {
|
|
358
|
+
if (typeof token === "object" && "tokens" in token && token.tokens) {
|
|
359
|
+
return this.parser.parseInline(token.tokens);
|
|
360
|
+
}
|
|
361
|
+
return typeof token === "object" ? token.text : token;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
function renderMarkdown(text3) {
|
|
366
|
+
return marked.parse(text3);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// src/runtime/output-formatter.ts
|
|
370
|
+
var SEPARATOR = "\u2500".repeat(40);
|
|
371
|
+
function printRunHeader(opts) {
|
|
372
|
+
console.log();
|
|
373
|
+
console.log(` ${colors.magenta("\u25B6")} ${colors.bold(opts.agentName)} ${colors.dim(`v${opts.version}`)}`);
|
|
374
|
+
console.log(` ${colors.dim(SEPARATOR)}`);
|
|
375
|
+
console.log();
|
|
376
|
+
}
|
|
377
|
+
function printRunOutput(raw, opts) {
|
|
378
|
+
const trimmed = raw.trim();
|
|
379
|
+
if (!trimmed) return;
|
|
380
|
+
if (opts.format === "json") {
|
|
381
|
+
try {
|
|
382
|
+
const parsed = JSON.parse(trimmed);
|
|
383
|
+
console.log(JSON.stringify(parsed, null, 2));
|
|
384
|
+
} catch {
|
|
385
|
+
console.log(trimmed);
|
|
386
|
+
}
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const rendered = renderMarkdown(trimmed);
|
|
390
|
+
const indented = rendered.replace(/\n$/, "").split("\n").map((line) => ` ${line}`).join("\n");
|
|
391
|
+
console.log(indented);
|
|
392
|
+
}
|
|
393
|
+
function printRunFooter(opts) {
|
|
394
|
+
const seconds = (opts.durationMs / 1e3).toFixed(1);
|
|
395
|
+
console.log();
|
|
396
|
+
console.log(` ${colors.dim(SEPARATOR)}`);
|
|
397
|
+
console.log(` ${colors.success("\u2713")} ${colors.dim(`Completed in ${seconds}s`)}`);
|
|
398
|
+
console.log();
|
|
399
|
+
}
|
|
400
|
+
|
|
318
401
|
// src/telemetry/reporter.ts
|
|
319
402
|
function sendTelemetry(event) {
|
|
320
403
|
try {
|
|
@@ -494,14 +577,32 @@ async function runAgent(agentName, options) {
|
|
|
494
577
|
});
|
|
495
578
|
return "";
|
|
496
579
|
}
|
|
497
|
-
|
|
580
|
+
const outputFormat = options.outputFormat ?? "text";
|
|
581
|
+
if (!options.quiet) {
|
|
582
|
+
printRunHeader({
|
|
583
|
+
agentName: agentFullName,
|
|
584
|
+
version: manifest.version
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
const result = await execa(claudePath, claudeArgs, {
|
|
588
|
+
stdout: "pipe",
|
|
589
|
+
stderr: "inherit",
|
|
590
|
+
stdin: "inherit"
|
|
591
|
+
});
|
|
592
|
+
const rawOutput = result.stdout ?? "";
|
|
593
|
+
if (!options.quiet) {
|
|
594
|
+
printRunOutput(rawOutput, { format: outputFormat });
|
|
595
|
+
printRunFooter({ durationMs: Date.now() - startTime });
|
|
596
|
+
} else if (rawOutput) {
|
|
597
|
+
console.log(rawOutput);
|
|
598
|
+
}
|
|
498
599
|
sendTelemetry({
|
|
499
600
|
agent: agentFullName,
|
|
500
601
|
version: manifest.version,
|
|
501
602
|
success: true,
|
|
502
603
|
duration_ms: Date.now() - startTime
|
|
503
604
|
});
|
|
504
|
-
return
|
|
605
|
+
return rawOutput;
|
|
505
606
|
} catch (error) {
|
|
506
607
|
sendTelemetry({
|
|
507
608
|
agent: agentFullName,
|
|
@@ -521,21 +622,6 @@ async function runAgent(agentName, options) {
|
|
|
521
622
|
}
|
|
522
623
|
}
|
|
523
624
|
|
|
524
|
-
// src/ui/colors.ts
|
|
525
|
-
import chalk from "chalk";
|
|
526
|
-
var noColor = process.env.NO_COLOR !== void 0 || process.argv.includes("--no-color");
|
|
527
|
-
var identity = (s) => s;
|
|
528
|
-
var colors = {
|
|
529
|
-
success: noColor ? identity : chalk.green,
|
|
530
|
-
error: noColor ? identity : chalk.red,
|
|
531
|
-
warn: noColor ? identity : chalk.yellow,
|
|
532
|
-
info: noColor ? identity : chalk.blue,
|
|
533
|
-
dim: noColor ? identity : chalk.dim,
|
|
534
|
-
bold: noColor ? identity : chalk.bold,
|
|
535
|
-
cyan: noColor ? identity : chalk.cyan,
|
|
536
|
-
magenta: noColor ? identity : chalk.magenta
|
|
537
|
-
};
|
|
538
|
-
|
|
539
625
|
// src/commands/run.ts
|
|
540
626
|
var runCommand = new Command("run").description("Run a local or installed agent").argument("<agent>", 'Agent name, path, or "." for current directory').argument("[prompt...]", "Prompt to send to the agent").option("-i, --interactive", "Run in interactive mode (stdin/stdout)").option("--file <path>", "Include file content in the prompt").option("--json", "Output in JSON format").option("--quiet", "Suppress output (useful for scripting)").option("--debug", "Show debug information").option("--output-format <format>", "Output format: text or json", "text").addHelpText("after", `
|
|
541
627
|
Examples:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knid/agentx",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "The package manager for AI agents powered by Claude Code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -25,21 +25,23 @@
|
|
|
25
25
|
"prepublishOnly": "npm run build"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@clack/prompts": "^0.9.0",
|
|
29
|
+
"chalk": "^5.4.0",
|
|
28
30
|
"commander": "^12.0.0",
|
|
29
31
|
"execa": "^9.0.0",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"yaml": "^2.6.0",
|
|
32
|
+
"marked": "^15.0.12",
|
|
33
|
+
"marked-terminal": "^7.3.0",
|
|
33
34
|
"ofetch": "^1.4.0",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
35
|
+
"tar": "^7.0.0",
|
|
36
|
+
"yaml": "^2.6.0",
|
|
37
|
+
"zod": "^3.23.0"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
40
|
+
"@types/node": "^22.0.0",
|
|
41
|
+
"@types/tar": "^6.1.0",
|
|
38
42
|
"tsup": "^8.0.0",
|
|
39
|
-
"vitest": "^3.0.0",
|
|
40
43
|
"typescript": "^5.7.0",
|
|
41
|
-
"
|
|
42
|
-
"@types/tar": "^6.1.0"
|
|
44
|
+
"vitest": "^3.0.0"
|
|
43
45
|
},
|
|
44
46
|
"keywords": [
|
|
45
47
|
"ai",
|