@akanjs/cli 3.2.0-rc.7 → 3.2.0-rc.9

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 (81) hide show
  1. package/.build-stamp +2 -2
  2. package/{CodeAgent-aq43sq64.js → CodeAgent-x2p3a3e0.js} +2 -2
  3. package/{CodeTui-pmychb3m.js → CodeTui-qstk5vpj.js} +1 -1
  4. package/README.ko.md +23 -0
  5. package/README.md +23 -0
  6. package/TunnelShare-c4xsfzg5.js +15 -0
  7. package/{agent.command-pdmb75bk.js → agent.command-9et2e27p.js} +19 -18
  8. package/akanCode.js +2 -2
  9. package/{application.command-xwch7rww.js → application.command-m4rq4wc2.js} +23 -16
  10. package/{applicationBuildRunner-6yjrxfqs.js → applicationBuildRunner-df7rx3ra.js} +7 -6
  11. package/buildBatch.proc.js +7 -6
  12. package/{cloud.command-6angaryd.js → cloud.command-a0gy0qq2.js} +21 -22
  13. package/cloud.script-xze4zh7n.js +31 -0
  14. package/{code.command-ceyhrgrc.js → code.command-5rsdqw8s.js} +7 -6
  15. package/{context.command-n7dbh0ca.js → context.command-rk1dwrg4.js} +18 -17
  16. package/context.runner-83ky5m1b.js +30 -0
  17. package/{guideline.command-h5dfzrng.js → guideline.command-mffxknbr.js} +3 -2
  18. package/guidelines/mcpRule/mcpRule.instruction.md +9 -0
  19. package/incrementalBuilder.proc.js +5 -4
  20. package/{index-bza4z89k.js → index-0gg15zwa.js} +4 -4
  21. package/{index-t0a5mng5.js → index-0hbtve0a.js} +10 -9
  22. package/{index-mtxbw4fy.js → index-28x1aszt.js} +13 -10
  23. package/{index-mcdezskv.js → index-2mf1aen9.js} +2 -2
  24. package/{index-g6ss1r1w.js → index-2r9ff9qm.js} +1 -1
  25. package/{index-z0r6bhqe.js → index-2vgv7fs7.js} +98 -18
  26. package/{index-dnqznx16.js → index-34792nh7.js} +1 -1
  27. package/{index-0fq1b5jp.js → index-3ghdb7p5.js} +9 -15
  28. package/{index-y9xbhs20.js → index-43f4h4cm.js} +3 -3
  29. package/{index-8bh9en9m.js → index-5radqwn2.js} +9 -9
  30. package/{index-dtxntsfx.js → index-5zwr4n6k.js} +1 -1
  31. package/{index-yp6mpazs.js → index-99qvtff2.js} +3 -3
  32. package/{index-df0r4008.js → index-an76bdrv.js} +1 -1
  33. package/{index-ggzb32a9.js → index-exn38bzx.js} +106 -69
  34. package/{index-y1a7dc7t.js → index-gcx48get.js} +1 -1
  35. package/{index-2b3n00gz.js → index-grxs6fts.js} +27 -17
  36. package/{index-qn5xmscz.js → index-gxav1bjz.js} +7 -7
  37. package/{index-ttrrm805.js → index-hqv34wzq.js} +4 -4
  38. package/{index-2m6gaatn.js → index-j3v29pq7.js} +78 -43
  39. package/index-j4yvgfhr.js +70 -0
  40. package/{index-n0vev0fv.js → index-j6gc8n14.js} +2 -2
  41. package/{index-kj7vyjng.js → index-j9790rhk.js} +67 -77
  42. package/{index-xzscbgx2.js → index-k92x3vne.js} +1 -1
  43. package/{index-qx12c8k5.js → index-nmvhjn8c.js} +1 -1
  44. package/{index-146p5x0r.js → index-ra9fvn7s.js} +6 -4
  45. package/{index-9km2h20g.js → index-rfzp4pqs.js} +2 -2
  46. package/{index-1kj847m5.js → index-rp4yf32g.js} +5 -4
  47. package/{index-80yc5q5y.js → index-skmtj8rm.js} +13 -6
  48. package/{index-w0nztbs0.js → index-swwjakt0.js} +3 -3
  49. package/{index-v50xjbbe.js → index-t4d0ckde.js} +1 -1
  50. package/{index-p9f6dsf2.js → index-vm0dn0mt.js} +3 -4
  51. package/{index-qtcm6s8p.js → index-w8yasvpc.js} +3 -3
  52. package/{index-wnxc9n5v.js → index-x40bdsca.js} +4 -4
  53. package/{index-36dywqhv.js → index-xvk2a75m.js} +2 -2
  54. package/{index-1xfdzwrt.js → index-xyn02k0w.js} +4 -4
  55. package/{index-fq72hk0a.js → index-yckz5t8b.js} +2 -2
  56. package/index.js +24 -23
  57. package/{library.command-4c2yjfqa.js → library.command-bmd7zc5m.js} +4 -3
  58. package/{localRegistry.command-mgb4fg60.js → localRegistry.command-y6en1599.js} +16 -15
  59. package/{module.command-c6284z1b.js → module.command-7exfffqw.js} +6 -5
  60. package/{package.command-3wh1hh2j.js → package.command-adskw2rj.js} +5 -4
  61. package/package.json +2 -2
  62. package/{page.command-sx22j4yv.js → page.command-dw01272p.js} +4 -3
  63. package/{pipeline.command-8kdcgy47.js → pipeline.command-0b1r3y5r.js} +3 -2
  64. package/{primitive.command-4jaegn0m.js → primitive.command-byw6vc04.js} +7 -6
  65. package/{projectTypecheck-t0r9argb.js → projectTypecheck-kkrpq60a.js} +2 -1
  66. package/{quality.command-46jhrbm2.js → quality.command-6rqnhzct.js} +6 -5
  67. package/{repair.command-dj4ke29k.js → repair.command-rw5zymak.js} +6 -5
  68. package/{scalar.command-qwvbhytf.js → scalar.command-2dyp9nh9.js} +5 -4
  69. package/skills/akan-debug/SKILL.md +1 -1
  70. package/skills/akan-mcp/SKILL.md +2 -1
  71. package/skills/akan-scaffold/SKILL.md +1 -1
  72. package/skills/akan-validate/SKILL.md +1 -0
  73. package/{subspace.command-48d86hvc.js → subspace.command-111ynwv1.js} +9 -8
  74. package/{tunnel.command-00v81x42.js → tunnel.command-2gcpfbdj.js} +8 -7
  75. package/typecheck.proc.js +5 -2
  76. package/{verify.command-sz542tvy.js → verify.command-djgs86ma.js} +17 -15
  77. package/{workflow.command-0ra9304f.js → workflow.command-n0k2mxr5.js} +30 -16
  78. package/{workspace.command-5mm9ahzc.js → workspace.command-fh1qwxfx.js} +31 -30
  79. package/TunnelShare-11a3fqxb.js +0 -14
  80. package/cloud.script-w5b0a1sm.js +0 -30
  81. package/context.runner-9d5rbt2p.js +0 -29
@@ -1,4 +1,7 @@
1
1
  // @bun
2
+ import {
3
+ CliError
4
+ } from "./index-j4yvgfhr.js";
2
5
  import {
3
6
  getDirname2,
4
7
  FileSys2
@@ -10,7 +13,7 @@ import {
10
13
  LibExecutor,
11
14
  PkgExecutor,
12
15
  ModuleExecutor
13
- } from "./index-0fq1b5jp.js";
16
+ } from "./index-3ghdb7p5.js";
14
17
 
15
18
  // pkgs/@akanjs/devkit/commandDecorators/camelToKebabCase.ts
16
19
  var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -161,19 +164,6 @@ var script = (refName, deps = []) => {
161
164
  return ScriptBase;
162
165
  };
163
166
 
164
- // pkgs/@akanjs/devkit/commandDecorators/exitCodeError.ts
165
- class ExitCodeError extends Error {
166
- exitCode;
167
- name = "ExitCodeError";
168
- constructor(message, exitCode) {
169
- super(message);
170
- this.exitCode = exitCode;
171
- }
172
- static codeOf(error) {
173
- return error instanceof ExitCodeError ? error.exitCode : null;
174
- }
175
- }
176
-
177
167
  // pkgs/@akanjs/devkit/commandDecorators/helpFormatter.ts
178
168
  import chalk from "chalk";
179
169
  var formatChoice = (choice) => typeof choice === "object" ? choice.label : choice.toString();
@@ -359,39 +349,54 @@ class WorkspaceVersionCheck {
359
349
 
360
350
  // pkgs/@akanjs/devkit/commandDecorators/command.ts
361
351
  var loggedCliErrorObjects = new WeakSet;
352
+ var answeredCliErrors = new WeakSet;
362
353
  var loggedCliErrorMessages = new Set;
363
354
  var markCliErrorPrinted = (error) => {
364
- if (typeof error === "object" && error !== null)
365
- loggedCliErrorObjects.add(error);
355
+ if (typeof error !== "object" || error === null)
356
+ return;
357
+ loggedCliErrorObjects.add(error);
358
+ answeredCliErrors.add(error);
366
359
  };
367
- var formatCliError = (error) => {
368
- if (error instanceof Error)
369
- return error.message || error.name;
370
- if (typeof error === "string")
371
- return error.trim() || "Unknown error";
372
- if (error === null || error === undefined)
373
- return "Unknown error";
374
- try {
375
- const json = JSON.stringify(error);
376
- if (json)
377
- return json;
378
- } catch {
379
- return String(error);
380
- }
381
- return String(error) || "Unknown error";
382
- };
383
- var printCliError = (error) => {
360
+ var printCliError = (error, stream = "log") => {
384
361
  if (typeof error === "object" && error !== null) {
385
362
  if (loggedCliErrorObjects.has(error))
386
363
  return;
387
364
  loggedCliErrorObjects.add(error);
388
365
  }
389
- const message = formatCliError(error);
366
+ const message = CliError.messageOf(error);
390
367
  if (loggedCliErrorMessages.has(message))
391
368
  return;
392
369
  loggedCliErrorMessages.add(message);
393
370
  Logger.rawLog(`
394
- ${chalk2.red(message)}`);
371
+ ${chalk2.red(message)}`, undefined, stream);
372
+ };
373
+ var asksJson = (argMetas, opt) => argMetas.some((argMeta) => {
374
+ if (argMeta.type !== "Option")
375
+ return false;
376
+ const value = opt[argMeta.name] ?? argMeta.argsOption.default;
377
+ if (argMeta.name === "json")
378
+ return value === true || value === "true";
379
+ return argMeta.name === "format" && value === "json";
380
+ });
381
+ var writeJsonFailure = async (error) => {
382
+ if (typeof error === "object" && error !== null && answeredCliErrors.has(error))
383
+ return;
384
+ const line = `${JSON.stringify(CliError.failureOf(error))}
385
+ `;
386
+ await new Promise((resolve) => process.stdout.write(line, () => resolve()));
387
+ };
388
+ var failureReporterOf = (json, onFailure, failure) => async (error) => {
389
+ if (onFailure)
390
+ await onFailure(error, failure);
391
+ else if (json)
392
+ await writeJsonFailure(error);
393
+ };
394
+ var usageRefusalOf = (error) => {
395
+ if (error.exitCode === 0)
396
+ process.exit(0);
397
+ const refused = new CliError("usage", error.message.replace(/^error: /, ""));
398
+ loggedCliErrorObjects.add(refused);
399
+ return refused;
395
400
  };
396
401
  var handleOption = (programCommand, argMeta) => {
397
402
  const {
@@ -452,14 +457,14 @@ var assertEnumChoice = (argMeta, value) => {
452
457
  const choices = normalizeEnumChoices(enumChoices);
453
458
  if (choices.some((choice) => String(choice.value) === String(value)))
454
459
  return;
455
- throw new Error(`${argLabelOf(argMeta)} argument '${String(value)}' is invalid. Allowed choices are ${choices.map((choice) => choice.name).join(", ")}.`);
460
+ throw new CliError("usage", `${argLabelOf(argMeta)} argument '${String(value)}' is invalid. Allowed choices are ${choices.map((choice) => choice.name).join(", ")}.`);
456
461
  };
457
462
  var assertPromptable = (problem, refusal = {}) => {
458
463
  if (process.stdin.isTTY)
459
464
  return;
460
465
  throw refusalOf(problem, "stdin is not a terminal to prompt on", refusal);
461
466
  };
462
- var refusalOf = (problem, reason, { choices = [], remedy = "pass it on the command line" }) => new Error(`${problem}: ${reason}, so ${remedy}${choices.length ? ` (choices: ${choices.join(", ")})` : ""}.`);
467
+ var refusalOf = (problem, reason, { choices = [], remedy = "pass it on the command line", code = "usage" }) => new CliError(code, `${problem}: ${reason}, so ${remedy}${choices.length ? ` (choices: ${choices.join(", ")})` : ""}.`);
463
468
  var inputMessageOf = ({ name, argsOption: { desc, example, ask } }) => ask ? `${ask}: ` : desc ? `${desc}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
464
469
  var getOptionValue = async (argMeta, opt, context) => {
465
470
  const {
@@ -533,7 +538,7 @@ var assertCurrentDirectoryIsWorkspaceRoot = async () => {
533
538
  ]);
534
539
  if (hasPackageJson && hasTsConfig && hasMemberDirs.some(Boolean))
535
540
  return;
536
- throw new Error([
541
+ throw new CliError("usage", [
537
542
  "Akan CLI commands must be run from the workspace root.",
538
543
  `Current directory: ${cwd}`,
539
544
  "Move to the directory that contains package.json, tsconfig.json, and an apps/, libs/ or pkgs/ folder, then run the command again."
@@ -568,7 +573,7 @@ var getAppsArgumentValue = async (value, workspace, rerun) => {
568
573
  if (requested.length) {
569
574
  const unknown = requested.filter((name) => !appNames.includes(name));
570
575
  if (unknown.length)
571
- throw new Error(`Unknown app${unknown.length > 1 ? "s" : ""}: ${unknown.join(", ")}. Available: ${appNames.join(", ")}, all`);
576
+ throw new CliError("unknownTarget", `Unknown app${unknown.length > 1 ? "s" : ""}: ${unknown.join(", ")}. Available: ${appNames.join(", ")}, all`);
572
577
  return [...new Set(requested)].map((name) => AppExecutor.from(workspace, name));
573
578
  }
574
579
  if (appNames.length === 1 && appNames[0])
@@ -590,7 +595,7 @@ var getInternalArgumentValue = async (argMeta, value, workspace, rerun, { destru
590
595
  const [appNames, libNames, pkgNames] = await workspace.getExecs();
591
596
  const problemOf = (kind) => value ? `Unknown ${kind} '${value}'` : `Missing ${kind}`;
592
597
  const assertAskable = (kind, choices, placeholder) => {
593
- const refusal = { choices, ...rerunRemedyOf(rerun, placeholder) };
598
+ const refusal = { choices, code: value ? "unknownTarget" : "usage", ...rerunRemedyOf(rerun, placeholder) };
594
599
  if (destructive)
595
600
  throw refusalOf(problemOf(kind), "this command deletes files and never picks its target", refusal);
596
601
  assertPromptable(problemOf(kind), refusal);
@@ -631,7 +636,7 @@ var getInternalArgumentValue = async (argMeta, value, workspace, rerun, { destru
631
636
  });
632
637
  const picked = execOf(name);
633
638
  if (!picked)
634
- throw new Error(`Invalid system name: ${name}`);
639
+ throw new CliError("unknownTarget", `Invalid system name: ${name}`);
635
640
  return picked;
636
641
  } else if (sysType === "app") {
637
642
  if (value && appNames.includes(value))
@@ -673,13 +678,14 @@ var getInternalArgumentValue = async (argMeta, value, workspace, rerun, { destru
673
678
  if (value) {
674
679
  const [sysName, moduleName] = value.split(":");
675
680
  if (!sysName || !moduleName)
676
- throw new Error(`Invalid module name: ${value}`);
681
+ throw new CliError("usage", `Invalid module name: ${value}`);
677
682
  const sys = systems.find((each) => each.name === sysName);
678
683
  if (!sys)
679
- throw new Error(`Invalid system name: ${sysName}`);
684
+ throw new CliError("unknownTarget", `Invalid system name: ${sysName}`);
680
685
  if ((await modulesOf(sys)).includes(moduleName))
681
686
  return ModuleExecutor.from(sys, moduleName);
682
687
  throw refusalOf(problemOf("module"), `${sysName} has no such module`, {
688
+ code: "unknownTarget",
683
689
  choices: await listModules(),
684
690
  ...rerunRemedyOf(rerun, "<sys:module>")
685
691
  });
@@ -710,13 +716,33 @@ var getInternalArgumentValue = async (argMeta, value, workspace, rerun, { destru
710
716
  } else
711
717
  throw new Error(`Invalid system type: ${argMeta.type}`);
712
718
  };
719
+ var cliFailureOf = () => {
720
+ let failing = false;
721
+ const failure = {
722
+ exitCode: 1,
723
+ usageExitCode: undefined,
724
+ stream: "log",
725
+ report: async (_error) => {},
726
+ exitCodeOf: (error) => {
727
+ const { usageExitCode } = failure;
728
+ if (usageExitCode !== undefined && error instanceof CliError && CliError.usageCodes.includes(error.code))
729
+ return usageExitCode;
730
+ return CliError.exitCodeOf(error) ?? failure.exitCode;
731
+ },
732
+ fail: async (error) => {
733
+ if (failing)
734
+ return;
735
+ failing = true;
736
+ printCliError(error, failure.stream);
737
+ await failure.report(error).catch((reportError) => printCliError(reportError, "error"));
738
+ process.exit(failure.exitCodeOf(error));
739
+ }
740
+ };
741
+ return failure;
742
+ };
713
743
  var runCommands = async (...commands) => {
714
- let failureExitCode = 1;
715
- let reportFailure = async (_error) => {};
716
- process.on("unhandledRejection", (error) => {
717
- printCliError(error);
718
- process.exit(ExitCodeError.codeOf(error) ?? failureExitCode);
719
- });
744
+ const failure = cliFailureOf();
745
+ process.on("unhandledRejection", (error) => void failure.fail(error));
720
746
  const __dirname2 = getDirname2(import.meta.url);
721
747
  const packageJsonCandidates = [`${path3.dirname(Bun.main)}/package.json`, `${__dirname2}/../package.json`];
722
748
  let cliPackageJson = null;
@@ -750,20 +776,16 @@ ${versionWarning}`), undefined, "error");
750
776
  let programCommand = program.command(commandName, {
751
777
  hidden: targetMeta.targetOption.devOnly
752
778
  });
753
- const targetFailureExitCode = targetMeta.targetOption.failureExitCode;
754
- const usageExitCode = targetMeta.targetOption.usageExitCode ?? targetFailureExitCode;
779
+ const { failureExitCode: targetFailureExitCode, usageExitCode: targetUsageExitCode } = targetMeta.targetOption;
755
780
  const { onFailure } = targetMeta.targetOption;
756
781
  const [allArgMetas] = getArgMetas(command, targetMeta.key);
757
- if (usageExitCode !== undefined || onFailure)
758
- programCommand.exitOverride((error) => {
759
- if (error.exitCode === 0)
760
- process.exit(0);
761
- const refused = new ExitCodeError(error.message.replace(/^error: /, ""), usageExitCode ?? error.exitCode);
762
- markCliErrorPrinted(refused);
763
- const given = givenOptionsOf(allArgMetas, programCommand.opts());
764
- reportFailure = async (failure) => await onFailure?.(failure, { usage: true, given });
765
- throw refused;
766
- });
782
+ programCommand.exitOverride((error) => {
783
+ const refused = usageRefusalOf(error);
784
+ failure.usageExitCode = targetUsageExitCode;
785
+ const given = givenOptionsOf(allArgMetas, programCommand.opts());
786
+ failure.report = failureReporterOf(asksJson(allArgMetas, given), onFailure, { usage: true, given });
787
+ throw refused;
788
+ });
767
789
  for (const argMeta of allArgMetas) {
768
790
  if (argMeta.type === "Option")
769
791
  programCommand = handleOption(programCommand, argMeta);
@@ -785,12 +807,18 @@ ${versionWarning}`), undefined, "error");
785
807
  return formatCommandHelp(command, targetMeta.key);
786
808
  };
787
809
  programCommand.action(async (...args) => {
788
- failureExitCode = targetFailureExitCode ?? 1;
810
+ failure.exitCode = targetFailureExitCode ?? 1;
811
+ failure.usageExitCode = targetUsageExitCode;
789
812
  if (!targetMeta.targetOption.stdio)
790
813
  Logger.rawLog();
791
814
  const cmdArgs = args.slice(0, args.length - 2);
792
815
  const opt = args[args.length - 2];
793
- reportFailure = async (failure) => await onFailure?.(failure, { usage: false, given: givenOptionsOf(allArgMetas, opt) });
816
+ const json = asksJson(allArgMetas, opt);
817
+ failure.stream = json ? "error" : "log";
818
+ failure.report = failureReporterOf(json, onFailure, {
819
+ usage: false,
820
+ given: givenOptionsOf(allArgMetas, opt)
821
+ });
794
822
  const commandArgs = [];
795
823
  if (targetMeta.targetOption.runsOnWorkspaceRoot) {
796
824
  await assertCurrentDirectoryIsWorkspaceRoot();
@@ -825,18 +853,17 @@ ${versionWarning}`), undefined, "error");
825
853
  if (!targetMeta.targetOption.stdio)
826
854
  Logger.rawLog();
827
855
  } catch (e) {
828
- printCliError(e);
856
+ printCliError(e, failure.stream);
829
857
  throw e;
830
858
  }
831
859
  });
832
860
  }
833
861
  }
834
862
  }
835
- await program.parseAsync(process.argv).catch(async (error) => {
836
- printCliError(error);
837
- await reportFailure(error).catch(printCliError);
838
- process.exit(ExitCodeError.codeOf(error) ?? failureExitCode);
863
+ program.exitOverride((error) => {
864
+ throw usageRefusalOf(error);
839
865
  });
866
+ await program.parseAsync(process.argv).catch(failure.fail);
840
867
  };
841
868
  // pkgs/@akanjs/devkit/commandDecorators/commandBuilder.ts
842
869
  var argMetaOf = (type, name, primitive, argsOption, idx) => {
@@ -914,4 +941,14 @@ function command(refName, depsOrBuilder, builder) {
914
941
  }
915
942
  return CommandBase;
916
943
  }
917
- export { camelToKebabCase, getTargetMetas, getTargetCommandNames, App, Apps, Lib, Sys, SysOrOnlyApp, Exec, Pkg, Module, ModuleOrService, Workspace, CommandContainer, runner, script, ExitCodeError, markCliErrorPrinted, assertPromptable, runCommands, command };
944
+ // pkgs/@akanjs/devkit/commandDecorators/exitCodeError.ts
945
+ class ExitCodeError extends CliError {
946
+ name = "ExitCodeError";
947
+ constructor(message, exitCode) {
948
+ super(exitCode === 2 ? "refused" : exitCode === 3 ? "checkFailed" : "failed", message, { exitCode });
949
+ }
950
+ static codeOf(error) {
951
+ return CliError.exitCodeOf(error);
952
+ }
953
+ }
954
+ export { camelToKebabCase, getTargetMetas, getTargetCommandNames, App, Apps, Lib, Sys, SysOrOnlyApp, Exec, Pkg, Module, ModuleOrService, Workspace, CommandContainer, runner, script, markCliErrorPrinted, assertPromptable, runCommands, command, ExitCodeError };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  AppInfo
4
- } from "./index-0fq1b5jp.js";
4
+ } from "./index-3ghdb7p5.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/slicePlanner.ts
7
7
  class SlicePlanner {
@@ -2,9 +2,11 @@
2
2
  import {
3
3
  runner,
4
4
  script,
5
- ExitCodeError,
6
5
  markCliErrorPrinted
7
- } from "./index-ggzb32a9.js";
6
+ } from "./index-exn38bzx.js";
7
+ import {
8
+ CliError
9
+ } from "./index-j4yvgfhr.js";
8
10
  import {
9
11
  AGENT_BLOCK_START,
10
12
  AGENT_BLOCK_END,
@@ -15,7 +17,7 @@ import {
15
17
  CLAUDE_COMMENT_RULE,
16
18
  AppExecutor,
17
19
  LibExecutor
18
- } from "./index-0fq1b5jp.js";
20
+ } from "./index-3ghdb7p5.js";
19
21
  import {
20
22
  akanCodePaths2
21
23
  } from "./index-35j83zkd.js";
@@ -25,7 +27,7 @@ import {
25
27
  } from "./index-j6eeh5d7.js";
26
28
  import {
27
29
  AkanContextAnalyzer
28
- } from "./index-fq72hk0a.js";
30
+ } from "./index-yckz5t8b.js";
29
31
  import {
30
32
  collectRecipeSources2,
31
33
  scanRecipes2
@@ -33,15 +35,15 @@ import {
33
35
  import {
34
36
  ApplicationRunner,
35
37
  VerifyScope
36
- } from "./index-kj7vyjng.js";
38
+ } from "./index-j9790rhk.js";
37
39
  import {
38
40
  WorkspaceRunner
39
- } from "./index-1xfdzwrt.js";
41
+ } from "./index-xyn02k0w.js";
40
42
  import {
41
43
  VerifyComments,
42
44
  VerifyPipeline,
43
45
  VerifyReport
44
- } from "./index-146p5x0r.js";
46
+ } from "./index-ra9fvn7s.js";
45
47
 
46
48
  // pkgs/@akanjs/cli/agent/agent.script.ts
47
49
  import { Logger as Logger3 } from "akanjs/common";
@@ -610,7 +612,7 @@ var resolveTargets = (target) => {
610
612
  const single = singleTargets.find((name) => name === target);
611
613
  if (single)
612
614
  return [single];
613
- throw new Error(`Unknown agent target: ${target}. Use cursor, agents-md, claude, rules, skills, hooks, or all.`);
615
+ throw new CliError("usage", `Unknown agent target: ${target}. Use cursor, agents-md, claude, rules, skills, hooks, or all.`);
614
616
  };
615
617
 
616
618
  class AgentScript extends script("agent", [AgentRunner]) {
@@ -618,7 +620,7 @@ class AgentScript extends script("agent", [AgentRunner]) {
618
620
  if (action === "hook")
619
621
  return await this.#hook(workspace, target);
620
622
  if (action !== "install")
621
- throw new Error(`Unknown agent action: ${action}. Use "install" or "hook".`);
623
+ throw new CliError("usage", `Unknown agent action: ${action}. Use "install" or "hook".`);
622
624
  if (check)
623
625
  return await this.#check(workspace, resolveTargets(target));
624
626
  const written = await this.agentRunner.install(workspace, resolveTargets(target), { force });
@@ -634,19 +636,27 @@ ${written.map((file) => `- ${file}`).join(`
634
636
  const lines = drift.map(({ path, change }) => `${path} ${change}`);
635
637
  Logger3.rawLog([`agent files differ \xB7 ${files} \xB7 run \`akan agent install\``, ...lines].join(`
636
638
  `));
637
- const failure = new ExitCodeError("agent files differ", 1);
639
+ const failure = new CliError("checkFailed", "agent files differ");
638
640
  markCliErrorPrinted(failure);
639
641
  throw failure;
640
642
  }
641
643
  async#hook(workspace, event) {
642
- if (!AgentHook.isEvent(event))
643
- throw new Error(`Unknown hook: ${event}. Use ${AgentHook.events.join(", ")}.`);
644
- const raw = (await Bun.stdin.text()).trim();
645
- const input = raw ? JSON.parse(raw) : {};
646
- const response = AgentHook.respond(event, await new AgentHook(workspace).run(event, input));
647
- if (response)
648
- process.stdout.write(`${response}
644
+ try {
645
+ if (!AgentHook.isEvent(event))
646
+ throw new CliError("usage", `Unknown hook: ${event}. Use ${AgentHook.events.join(", ")}.`);
647
+ const raw = (await Bun.stdin.text()).trim();
648
+ const input = raw ? JSON.parse(raw) : {};
649
+ const response = AgentHook.respond(event, await new AgentHook(workspace).run(event, input));
650
+ if (response)
651
+ process.stdout.write(`${response}
649
652
  `);
653
+ } catch (error) {
654
+ const message = CliError.messageOf(error);
655
+ Logger3.rawLog(message, undefined, "error");
656
+ const failure = new CliError("failed", message, { cause: error });
657
+ markCliErrorPrinted(failure);
658
+ throw failure;
659
+ }
650
660
  }
651
661
  }
652
662
 
@@ -4,27 +4,27 @@ import {
4
4
  CloudApi,
5
5
  CloudUpdates,
6
6
  PipelineSecrets
7
- } from "./index-9km2h20g.js";
7
+ } from "./index-rfzp4pqs.js";
8
8
  import {
9
9
  PkgExecutor
10
- } from "./index-0fq1b5jp.js";
10
+ } from "./index-3ghdb7p5.js";
11
11
  import {
12
12
  UpdatePackFolder,
13
13
  NativePublicEnv,
14
14
  NativeApp
15
- } from "./index-y9xbhs20.js";
15
+ } from "./index-43f4h4cm.js";
16
16
  import {
17
17
  script
18
- } from "./index-ggzb32a9.js";
18
+ } from "./index-exn38bzx.js";
19
19
  import {
20
20
  ApplicationScript
21
- } from "./index-mtxbw4fy.js";
21
+ } from "./index-28x1aszt.js";
22
22
  import {
23
23
  PackageScript
24
- } from "./index-w0nztbs0.js";
24
+ } from "./index-swwjakt0.js";
25
25
  import {
26
26
  CloudRunner
27
- } from "./index-1kj847m5.js";
27
+ } from "./index-rp4yf32g.js";
28
28
 
29
29
  // pkgs/@akanjs/cli/cloud/cloud.script.ts
30
30
  import { Logger } from "akanjs/common";
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-ggzb32a9.js";
5
+ } from "./index-exn38bzx.js";
6
6
  import {
7
7
  ModuleExecutor
8
- } from "./index-0fq1b5jp.js";
8
+ } from "./index-3ghdb7p5.js";
9
9
  import {
10
10
  sourceFile,
11
11
  moduleSourcePaths,
@@ -13,10 +13,10 @@ import {
13
13
  createPassedPrimitiveReport,
14
14
  bilingualLabelForField,
15
15
  bilingualDescriptionForField
16
- } from "./index-z0r6bhqe.js";
16
+ } from "./index-2vgv7fs7.js";
17
17
  import {
18
18
  PageScript
19
- } from "./index-dnqznx16.js";
19
+ } from "./index-34792nh7.js";
20
20
  import {
21
21
  pluralizeName
22
22
  } from "./index-nz8prx9g.js";