@knid/agentx 0.1.3 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +99 -18
  2. package/package.json +11 -9
package/dist/index.js CHANGED
@@ -77,6 +77,7 @@ var agentYamlSchema = z.object({
77
77
  mcp_servers: z.record(mcpServerSchema).optional(),
78
78
  secrets: z.array(secretSchema).optional(),
79
79
  permissions: permissionsSchema.optional(),
80
+ allowed_tools: z.array(z.string()).optional(),
80
81
  config: z.array(configOptionSchema).optional(),
81
82
  examples: z.array(exampleSchema).optional()
82
83
  });
@@ -314,6 +315,79 @@ function buildPromptWithPipe(prompt, pipedContent) {
314
315
  ${prompt}`;
315
316
  }
316
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
+ function renderMarkdown(text3) {
356
+ return marked.parse(text3);
357
+ }
358
+
359
+ // src/runtime/output-formatter.ts
360
+ var SEPARATOR = "\u2500".repeat(40);
361
+ function printRunHeader(opts) {
362
+ console.log();
363
+ console.log(` ${colors.magenta("\u25B6")} ${colors.bold(opts.agentName)} ${colors.dim(`v${opts.version}`)}`);
364
+ console.log(` ${colors.dim(SEPARATOR)}`);
365
+ console.log();
366
+ }
367
+ function printRunOutput(raw, opts) {
368
+ const trimmed = raw.trim();
369
+ if (!trimmed) return;
370
+ if (opts.format === "json") {
371
+ try {
372
+ const parsed = JSON.parse(trimmed);
373
+ console.log(JSON.stringify(parsed, null, 2));
374
+ } catch {
375
+ console.log(trimmed);
376
+ }
377
+ return;
378
+ }
379
+ const rendered = renderMarkdown(trimmed);
380
+ const indented = rendered.replace(/\n$/, "").split("\n").map((line) => ` ${line}`).join("\n");
381
+ console.log(indented);
382
+ }
383
+ function printRunFooter(opts) {
384
+ const seconds = (opts.durationMs / 1e3).toFixed(1);
385
+ console.log();
386
+ console.log(` ${colors.dim(SEPARATOR)}`);
387
+ console.log(` ${colors.success("\u2713")} ${colors.dim(`Completed in ${seconds}s`)}`);
388
+ console.log();
389
+ }
390
+
317
391
  // src/telemetry/reporter.ts
318
392
  function sendTelemetry(event) {
319
393
  try {
@@ -429,6 +503,9 @@ function buildClaudeArgs(options) {
429
503
  if (options.mcpConfigPath) {
430
504
  args.push("--mcp-config", options.mcpConfigPath);
431
505
  }
506
+ if (options.allowedTools && options.allowedTools.length > 0) {
507
+ args.push("--allowedTools", ...options.allowedTools);
508
+ }
432
509
  if (options.maxTurns !== void 0) {
433
510
  args.push("--max-turns", String(options.maxTurns));
434
511
  }
@@ -473,7 +550,8 @@ async function runAgent(agentName, options) {
473
550
  mcpConfigPath,
474
551
  maxTurns: globalConfig.claude_defaults.max_turns,
475
552
  outputFormat: options.outputFormat ?? globalConfig.default_output,
476
- interactive: options.interactive
553
+ interactive: options.interactive,
554
+ allowedTools: manifest.allowed_tools
477
555
  });
478
556
  if (options.debug) {
479
557
  console.error(`[debug] claude ${claudeArgs.join(" ")}`);
@@ -489,14 +567,32 @@ async function runAgent(agentName, options) {
489
567
  });
490
568
  return "";
491
569
  }
492
- await execa(claudePath, claudeArgs, { stdio: "inherit" });
570
+ const outputFormat = options.outputFormat ?? "text";
571
+ if (!options.quiet) {
572
+ printRunHeader({
573
+ agentName: agentFullName,
574
+ version: manifest.version
575
+ });
576
+ }
577
+ const result = await execa(claudePath, claudeArgs, {
578
+ stdout: "pipe",
579
+ stderr: "inherit",
580
+ stdin: "inherit"
581
+ });
582
+ const rawOutput = result.stdout ?? "";
583
+ if (!options.quiet) {
584
+ printRunOutput(rawOutput, { format: outputFormat });
585
+ printRunFooter({ durationMs: Date.now() - startTime });
586
+ } else if (rawOutput) {
587
+ console.log(rawOutput);
588
+ }
493
589
  sendTelemetry({
494
590
  agent: agentFullName,
495
591
  version: manifest.version,
496
592
  success: true,
497
593
  duration_ms: Date.now() - startTime
498
594
  });
499
- return "";
595
+ return rawOutput;
500
596
  } catch (error) {
501
597
  sendTelemetry({
502
598
  agent: agentFullName,
@@ -516,21 +612,6 @@ async function runAgent(agentName, options) {
516
612
  }
517
613
  }
518
614
 
519
- // src/ui/colors.ts
520
- import chalk from "chalk";
521
- var noColor = process.env.NO_COLOR !== void 0 || process.argv.includes("--no-color");
522
- var identity = (s) => s;
523
- var colors = {
524
- success: noColor ? identity : chalk.green,
525
- error: noColor ? identity : chalk.red,
526
- warn: noColor ? identity : chalk.yellow,
527
- info: noColor ? identity : chalk.blue,
528
- dim: noColor ? identity : chalk.dim,
529
- bold: noColor ? identity : chalk.bold,
530
- cyan: noColor ? identity : chalk.cyan,
531
- magenta: noColor ? identity : chalk.magenta
532
- };
533
-
534
615
  // src/commands/run.ts
535
616
  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", `
536
617
  Examples:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knid/agentx",
3
- "version": "0.1.3",
3
+ "version": "0.1.7",
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
- "@clack/prompts": "^0.9.0",
31
- "zod": "^3.23.0",
32
- "yaml": "^2.6.0",
32
+ "marked": "^15.0.12",
33
+ "marked-terminal": "^7.3.0",
33
34
  "ofetch": "^1.4.0",
34
- "chalk": "^5.4.0",
35
- "tar": "^7.0.0"
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
- "@types/node": "^22.0.0",
42
- "@types/tar": "^6.1.0"
44
+ "vitest": "^3.0.0"
43
45
  },
44
46
  "keywords": [
45
47
  "ai",