@akanjs/cli 3.2.0-rc.2 → 3.2.0-rc.21

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 (132) hide show
  1. package/.build-stamp +2 -1
  2. package/CodeAgent-faqv7t4g.js +11 -0
  3. package/{CodeTui-zyc7zaq6.js → CodeTui-vqck9tet.js} +822 -666
  4. package/README.ko.md +26 -1
  5. package/README.md +26 -1
  6. package/TunnelShare-bwe3ddv7.js +18 -0
  7. package/agent.command-p75jvgrd.js +56 -0
  8. package/akanCode.js +12 -12
  9. package/appExecutor-020cyesq.js +11 -0
  10. package/{application.command-vb278qnq.js → application.command-ta2knqxm.js} +72 -34
  11. package/{applicationBuildRunner-bqbyeg84.js → applicationBuildRunner-gkh82j2b.js} +18 -13
  12. package/buildBatch.proc.js +26 -11
  13. package/{cloud.command-ca777ee2.js → cloud.command-v3jhfvm5.js} +31 -28
  14. package/cloud.script-be9s1432.js +35 -0
  15. package/{code.command-j08txqcd.js → code.command-mh7dh1st.js} +14 -9
  16. package/{context.command-2fa6egp9.js → context.command-1ycfjkdd.js} +28 -23
  17. package/context.runner-333jkz86.js +34 -0
  18. package/{dependencyScanner-78sq8m4q.js → dependencyScanner-ge10gb52.js} +2 -2
  19. package/{devTui-w38ch13a.js → devTui-rf374y2w.js} +1 -1
  20. package/{fileSys-zpvt5gtf.js → fileSys-q22646yc.js} +1 -1
  21. package/{guideline.command-w6yqpdec.js → guideline.command-w1grfwh7.js} +9 -4
  22. package/guidelines/agentRule/agentRule.instruction.md +17 -5
  23. package/guidelines/akanApi/akanApi.instruction.md +5 -3
  24. package/guidelines/conventions/core.md +23 -5
  25. package/guidelines/conventions/rules/app.md +4 -1
  26. package/guidelines/conventions/rules/page.md +5 -0
  27. package/guidelines/errorCodes/errorCodes.instruction.md +158 -0
  28. package/guidelines/fieldRule/fieldRule.instruction.md +2 -1
  29. package/guidelines/mcpRule/mcpRule.instruction.md +86 -2
  30. package/guidelines/pageRule/pageRule.instruction.md +11 -1
  31. package/guidelines/runtimeRule/runtimeRule.instruction.md +7 -2
  32. package/guidelines/transportRule/transportRule.instruction.md +8 -1
  33. package/incrementalBuilder.proc.js +574 -410
  34. package/{index-c5ymqb05.js → index-013n6z7m.js} +12 -12
  35. package/{index-w15mg3km.js → index-0dm25wvf.js} +1 -1
  36. package/{index-8nbx607g.js → index-0hj82f9w.js} +136 -48
  37. package/{index-ebwkh7bt.js → index-1c0mjc2b.js} +25 -7
  38. package/{index-6h775rv3.js → index-1jk52ffq.js} +53 -12
  39. package/{index-hj6w4ka1.js → index-1p81ecbz.js} +1 -1
  40. package/{index-ygrdw6jw.js → index-1pjwsh2g.js} +65 -8
  41. package/{index-cbcwxp5v.js → index-22g3jq43.js} +9 -7
  42. package/{index-466z5931.js → index-2d9nm03s.js} +580 -364
  43. package/{index-0fj9ra3q.js → index-2k6mve6a.js} +18 -11
  44. package/{index-qd7xn2bk.js → index-2ny1e95c.js} +2 -2
  45. package/{index-j7p0jgaq.js → index-52w4jb87.js} +6 -6
  46. package/{index-e22zedc2.js → index-5h888r6j.js} +3 -3
  47. package/{index-7kmbqp0b.js → index-6pxmcaq8.js} +1 -1
  48. package/{index-xa0289eg.js → index-6zb17wcm.js} +16 -9
  49. package/{index-qgazn58x.js → index-7a07tdap.js} +50 -38
  50. package/{index-m5sg5spm.js → index-7ehdht84.js} +565 -187
  51. package/{index-y725zb1a.js → index-7v7tvgt7.js} +196 -168
  52. package/{index-pq5rjkch.js → index-88s746ns.js} +7 -2
  53. package/{index-r0a604h4.js → index-99kjwyma.js} +1 -1
  54. package/{index-2mrn1mrg.js → index-9f3reh2y.js} +1 -1
  55. package/{index-386canwe.js → index-9rv2zt48.js} +186 -121
  56. package/{index-wr9magsr.js → index-9zswcze5.js} +3 -3
  57. package/{index-xq97me1h.js → index-a41vv4cy.js} +811 -697
  58. package/{index-yf9wc28h.js → index-bejy9zyc.js} +1 -1
  59. package/{index-bdmgqzb5.js → index-bket1068.js} +58 -29
  60. package/{index-bns3wcpc.js → index-by2tvsq6.js} +1 -1
  61. package/{index-1cb9apzn.js → index-czf94w8c.js} +2 -2
  62. package/{index-65b6ms4c.js → index-d3178asw.js} +15 -11
  63. package/index-dss3ds74.js +127 -0
  64. package/{index-annxfpgz.js → index-eyfty8kk.js} +9 -9
  65. package/{index-ny2k80mv.js → index-ffa52fwf.js} +1 -1
  66. package/{index-8jpc5fqv.js → index-g7jgd4xs.js} +2 -2
  67. package/{index-abfbf01s.js → index-gwsesvqc.js} +2 -2
  68. package/{index-kcpk2d20.js → index-h1w4wqgd.js} +1474 -1139
  69. package/{index-j1hjb477.js → index-hp2c7xc2.js} +1 -1
  70. package/index-j4yvgfhr.js +70 -0
  71. package/{index-84c2pgak.js → index-jx2jcw1r.js} +89 -78
  72. package/{index-j6eeh5d7.js → index-knpm8sdm.js} +5 -5
  73. package/{index-2gees180.js → index-mpp4aas6.js} +62 -33
  74. package/index-na8r4a27.js +30 -0
  75. package/{index-0mqga3h9.js → index-nmxszh6x.js} +525 -440
  76. package/{index-35j83zkd.js → index-p5zh7pmc.js} +2 -2
  77. package/{index-20wvskt8.js → index-pt0agdck.js} +1 -1
  78. package/{index-htxck0pn.js → index-q444k260.js} +15 -10
  79. package/{index-wfmpxke3.js → index-qssq2d41.js} +2775 -3677
  80. package/{index-23860fej.js → index-rwgqba9p.js} +24 -9
  81. package/{index-v50xjbbe.js → index-t4d0ckde.js} +1 -1
  82. package/index-va90m8nd.js +25 -0
  83. package/index-vjbne22r.js +80 -0
  84. package/{index-djc5nxpy.js → index-w23tf30e.js} +6 -6
  85. package/{index-mvwvxgtd.js → index-wa01phm9.js} +289 -210
  86. package/{index-h7hehkw6.js → index-xczjdng6.js} +3 -1
  87. package/{index-vbhx60x5.js → index-xwe7y0gf.js} +2140 -2165
  88. package/index-ze48c0vd.js +788 -0
  89. package/{index-dk4g0x0d.js → index-zttyg7tg.js} +27 -16
  90. package/{index-ygdbn9jn.js → index-zyb0ebm4.js} +1 -1
  91. package/index.js +29 -24
  92. package/libExecutor-tq994592.js +10 -0
  93. package/{library.command-8d03a0pq.js → library.command-x219mhcx.js} +9 -4
  94. package/{localRegistry.command-vyv5k6t0.js → localRegistry.command-4p17wa9t.js} +30 -24
  95. package/{module.command-vy3kg965.js → module.command-tjthnvvr.js} +17 -8
  96. package/{package.command-qjh13rs9.js → package.command-c6df2hxx.js} +13 -8
  97. package/package.json +2 -2
  98. package/{page.command-t0nx1jat.js → page.command-gf06paq2.js} +9 -4
  99. package/{pipeline.command-2yjeas7m.js → pipeline.command-y07dgj9b.js} +14 -8
  100. package/pkgExecutor-stde3yc3.js +10 -0
  101. package/{primitive.command-8vm49279.js → primitive.command-0enfygxn.js} +13 -8
  102. package/{projectTypecheck-s9hhe5sa.js → projectTypecheck-mk8wefvd.js} +2 -1
  103. package/{prompter-qrwx1p17.js → prompter-qyggfhqd.js} +2 -2
  104. package/{quality.command-v76fev72.js → quality.command-dkbdztad.js} +23 -16
  105. package/{recipeScanner-4b69ybe0.js → recipeScanner-rrx69awy.js} +1 -1
  106. package/{repair.command-fp4m3w03.js → repair.command-g5vd95ax.js} +13 -8
  107. package/{routeSourceValidator-4h947v7c.js → routeSourceValidator-8n6j1vn7.js} +4 -2
  108. package/{scalar.command-hxe6try8.js → scalar.command-7909pg0d.js} +11 -6
  109. package/skills/akan-debug/SKILL.md +10 -3
  110. package/skills/akan-err/SKILL.md +7 -0
  111. package/skills/akan-mcp/SKILL.md +13 -2
  112. package/skills/akan-scaffold/SKILL.md +2 -2
  113. package/skills/akan-transport/SKILL.md +2 -0
  114. package/skills/akan-validate/SKILL.md +1 -0
  115. package/{subspace.command-q42n1844.js → subspace.command-at4jt1fb.js} +29 -23
  116. package/templates/biomeForm.ts +1 -1
  117. package/templates/env/_env.server.type.ts +1 -1
  118. package/templates/facetIndex/index.ts +2 -37
  119. package/templates/lib/sig.ts +0 -4
  120. package/templates/lib/useClient.ts +1 -1
  121. package/templates/workspaceRoot/AGENTS.md.template +2 -1
  122. package/{tunnel.command-22g11n0x.js → tunnel.command-91h92dwr.js} +17 -12
  123. package/{typeChecker-s640r6c0.js → typeChecker-bfrd1n9n.js} +1 -1
  124. package/typecheck.proc.js +6 -3
  125. package/{verify.command-rx43bha1.js → verify.command-pzky05ts.js} +26 -20
  126. package/{workflow.command-yg0d8mmq.js → workflow.command-mqqe4n12.js} +37 -19
  127. package/{workspace.command-fcfztvn5.js → workspace.command-y4rznvhx.js} +64 -53
  128. package/CodeAgent-6cpjtj25.js +0 -11
  129. package/TunnelShare-zkfkrw8w.js +0 -14
  130. package/agent.command-kf1g3nh4.js +0 -51
  131. package/cloud.script-agpxzq6j.js +0 -30
  132. package/context.runner-ftv8373t.js +0 -29
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  GlobalConfig,
4
4
  CloudApi
5
- } from "./index-e22zedc2.js";
5
+ } from "./index-5h888r6j.js";
6
6
 
7
7
  // pkgs/@akanjs/cli/tunnel/TunnelShare.ts
8
8
  import { TunnelAgent } from "akanjs/server/tunnel";
@@ -0,0 +1,70 @@
1
+ // @bun
2
+ // pkgs/@akanjs/devkit/commandDecorators/cliError.ts
3
+ import { AkanError } from "akanjs/base";
4
+
5
+ class CliError extends AkanError {
6
+ static exitCodes = {
7
+ failed: 1,
8
+ usage: 2,
9
+ unknownTarget: 2,
10
+ refused: 2,
11
+ checkFailed: 3,
12
+ interrupted: 130
13
+ };
14
+ static usageCodes = ["usage", "unknownTarget"];
15
+ exitCode;
16
+ constructor(code, message, { exitCode, cause } = {}) {
17
+ super(code, message, { cause });
18
+ this.exitCode = exitCode ?? CliError.#exitCodeOfCode(code) ?? 1;
19
+ }
20
+ static failureCodeOf(error) {
21
+ if (AkanError.is(error))
22
+ return error.code;
23
+ return CliError.#isPromptExit(error) ? "interrupted" : "failed";
24
+ }
25
+ static exitCodeOf(error) {
26
+ if (error instanceof CliError)
27
+ return error.exitCode;
28
+ const code = CliError.failureCodeOf(error);
29
+ return code === "failed" ? null : CliError.#exitCodeOfCode(code);
30
+ }
31
+ static messageOf(error) {
32
+ if (error instanceof Error)
33
+ return error.message || error.name;
34
+ if (typeof error === "string")
35
+ return error.trim() || "Unknown error";
36
+ if (error === null || error === undefined)
37
+ return "Unknown error";
38
+ try {
39
+ const json = JSON.stringify(error);
40
+ if (json)
41
+ return json;
42
+ } catch {
43
+ return String(error);
44
+ }
45
+ return String(error) || "Unknown error";
46
+ }
47
+ static failureOf(error) {
48
+ return { ok: false, error: CliError.messageOf(error), code: CliError.failureCodeOf(error) };
49
+ }
50
+ static #exitCodeOfCode(code) {
51
+ return Object.hasOwn(CliError.exitCodes, code) ? CliError.exitCodes[code] : null;
52
+ }
53
+ static #isPromptExit(error) {
54
+ return error instanceof Error && error.name === "ExitPromptError";
55
+ }
56
+ }
57
+
58
+ // pkgs/@akanjs/devkit/typecheck/typecheckFailure.ts
59
+ class TypecheckFailure extends CliError {
60
+ records;
61
+ static workerExitCode = 3;
62
+ constructor(records) {
63
+ super("checkFailed", records.slice(0, 20).map((record) => `${record.file ?? "-"}:${record.line}:${record.col} ${record.code} ${record.message}`).join(`
64
+ `) || "Typecheck failed");
65
+ this.records = records;
66
+ this.name = "TypecheckFailure";
67
+ }
68
+ }
69
+
70
+ export { CliError, TypecheckFailure };
@@ -3,10 +3,10 @@ import {
3
3
  AsyncDefaultExportDetector,
4
4
  StoreBootstrap,
5
5
  resolveSsrPageEntriesForApp
6
- } from "./index-wfmpxke3.js";
6
+ } from "./index-ze48c0vd.js";
7
7
  import {
8
8
  FileSys2
9
- } from "./index-bns3wcpc.js";
9
+ } from "./index-by2tvsq6.js";
10
10
 
11
11
  // pkgs/@akanjs/devkit/transforms/barrelAnalyzer.ts
12
12
  import fs from "fs";
@@ -102,17 +102,18 @@ class BarrelAnalyzer {
102
102
  const map = new Map;
103
103
  const read = new Set;
104
104
  this.#read.set(pkgName, read);
105
- await this.#walk(pkg.entryFile, pkg, map, read);
105
+ await this.#walk(pkg.entryFile, pkg, map, { visited: new Set, read, following: new Set([pkg.entryFile]) });
106
106
  return map;
107
107
  } catch (err) {
108
108
  this.#logger.error(`analyze failed for ${pkgName}: ${err.message}`);
109
109
  return null;
110
110
  }
111
111
  }
112
- async#walk(absFile, pkg, map, visited) {
113
- if (visited.has(absFile))
112
+ async#walk(absFile, pkg, map, walk) {
113
+ if (walk.visited.has(absFile))
114
114
  return;
115
- visited.add(absFile);
115
+ walk.visited.add(absFile);
116
+ walk.read.add(absFile);
116
117
  const file = Bun.file(absFile);
117
118
  if (!await file.exists())
118
119
  return;
@@ -123,13 +124,14 @@ class BarrelAnalyzer {
123
124
  const authoritative = this.#scanExports(source, absFile);
124
125
  authoritative.delete("default");
125
126
  const attributed = new Set;
126
- const attribute = (listBody, subpath) => {
127
+ const attribute = (listBody, subpath, source) => {
127
128
  for (const item of parseNamedList(listBody)) {
128
129
  if (item.isType || item.imported === "default" || !authoritative.has(item.local))
129
130
  continue;
130
131
  attributed.add(item.local);
131
- if (!map.has(item.local))
132
- map.set(item.local, { subpath, originalName: item.imported });
132
+ if (map.has(item.local))
133
+ continue;
134
+ map.set(item.local, source?.get(item.imported) ?? { subpath, originalName: item.imported });
133
135
  }
134
136
  };
135
137
  const starSpecs = [];
@@ -158,7 +160,7 @@ class BarrelAnalyzer {
158
160
  continue;
159
161
  const targetSubpath = this.#subpathFor(pkg, targetAbs);
160
162
  if (targetSubpath)
161
- attribute(namedList, targetSubpath);
163
+ attribute(namedList, targetSubpath, await this.#exportsOf(targetAbs, pkg, walk));
162
164
  }
163
165
  }
164
166
  LOCAL_NAMED_RE.lastIndex = 0;
@@ -178,9 +180,17 @@ class BarrelAnalyzer {
178
180
  for (const spec of starSpecs) {
179
181
  const targetAbs = await this.#resolveRel(absFile, spec);
180
182
  if (targetAbs)
181
- await this.#walk(targetAbs, pkg, map, visited);
183
+ await this.#walk(targetAbs, pkg, map, walk);
182
184
  }
183
185
  }
186
+ async#exportsOf(absFile, pkg, walk) {
187
+ if (walk.following.has(absFile))
188
+ return null;
189
+ const map = new Map;
190
+ const following = new Set([...walk.following, absFile]);
191
+ await this.#walk(absFile, pkg, map, { visited: new Set, read: walk.read, following });
192
+ return map;
193
+ }
184
194
  #scanExports(source, absFile) {
185
195
  try {
186
196
  const transpiler = [".tsx", ".jsx"].includes(path.extname(absFile)) ? this.#tsxTranspiler : this.#tsTranspiler;
@@ -569,6 +579,50 @@ var serializeNamedItem = (item) => {
569
579
  return `${prefix}${item.imported} as ${item.local}`;
570
580
  };
571
581
 
582
+ // pkgs/@akanjs/devkit/transforms/rscUseClientTransform.ts
583
+ import path3 from "path";
584
+ import ts2 from "typescript";
585
+ var USE_CLIENT_RE = /^\s*(?:\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\/\s*|\/\/[^\n]*\n\s*)*["']use client["']/;
586
+ var IMPLICIT_ROOT_LAYOUT_RE = /[/\\]\.akan[/\\]generated[/\\](?:implicit-root-layout|root-layouts[/\\][^/\\]*__root_layout)\.(tsx|ts|jsx|js)$/;
587
+ var STAR_REEXPORT_HINT_RE = /\bexport\s*\*\s*from\b/;
588
+ var hasUseClientDirective = (source) => USE_CLIENT_RE.test(source);
589
+ function toClientReferencePath(absPath, workspaceRoot) {
590
+ return path3.relative(path3.resolve(workspaceRoot), path3.resolve(absPath)).split(path3.sep).join("/");
591
+ }
592
+ var starReexportSpecifiers = (source, filePath) => ts2.createSourceFile(filePath, source, ts2.ScriptTarget.Latest).statements.filter((statement) => ts2.isExportDeclaration(statement) && !statement.exportClause && !statement.isTypeOnly && !!statement.moduleSpecifier && ts2.isStringLiteral(statement.moduleSpecifier)).map((statement) => statement.moduleSpecifier.text);
593
+ var scanUseClientExports = (source, filePath, workspaceRoot) => {
594
+ const stars = USE_CLIENT_RE.test(source) && STAR_REEXPORT_HINT_RE.test(source) ? starReexportSpecifiers(source, filePath) : [];
595
+ if (stars.length) {
596
+ const file = workspaceRoot ? toClientReferencePath(filePath, workspaceRoot) : filePath;
597
+ const listed = stars.slice(0, 3).map((specifier) => `\`export * from ${JSON.stringify(specifier)}\``);
598
+ const written = stars.length > 3 ? `${listed.join(", ")} (and ${stars.length - 3} more)` : listed.join(", ");
599
+ throw new Error(`${file} is a "use client" module, so it cannot ${written}: the server sees only the names a client module ` + `declares, and a star re-export declares none. Re-export them by name \u2014 \`export { \u2026 } from ${JSON.stringify(stars[0])}\`.`);
600
+ }
601
+ return new Bun.Transpiler({ loader: loaderFor(filePath) }).scan(source).exports;
602
+ };
603
+ function transformUseClient(source, args) {
604
+ if (!USE_CLIENT_RE.test(source))
605
+ return null;
606
+ if (IMPLICIT_ROOT_LAYOUT_RE.test(args.path))
607
+ return null;
608
+ const exports = scanUseClientExports(source, args.path, args.workspaceRoot);
609
+ if (exports.length === 0)
610
+ return null;
611
+ args.onClientModule?.(args.path, exports);
612
+ const referencePath = args.workspaceRoot ? toClientReferencePath(args.path, args.workspaceRoot) : args.path;
613
+ const filePathLit = JSON.stringify(referencePath);
614
+ const lines = [`import { registerClientReference } from "react-server-dom-webpack/server.node";`];
615
+ for (const name of exports) {
616
+ const nameLit = JSON.stringify(name);
617
+ const errMsg = JSON.stringify(`Attempted to call '${name}' from '${referencePath}' on the server, but it is a client-only export.`);
618
+ const proxy = `() => { throw new Error(${errMsg}); }`;
619
+ const binding = name === "default" ? `export default registerClientReference(${proxy}, ${filePathLit}, ${nameLit});` : `export const ${name} = registerClientReference(${proxy}, ${filePathLit}, ${nameLit});`;
620
+ lines.push(binding);
621
+ }
622
+ return lines.join(`
623
+ `);
624
+ }
625
+
572
626
  // pkgs/@akanjs/devkit/frontendBuild/bundleDefine.ts
573
627
  var bundleConditions = (command) => command === "build" ? ["production"] : [];
574
628
  var bundleDefine = (app, command, renderEnv) => {
@@ -576,13 +630,14 @@ var bundleDefine = (app, command, renderEnv) => {
576
630
  return {
577
631
  "process.env.NODE_ENV": JSON.stringify(nodeEnv),
578
632
  "process.env.AKAN_PUBLIC_RENDER_ENV": JSON.stringify(renderEnv),
633
+ "process.env.AKAN_BUNDLE_COMMAND": JSON.stringify(command),
579
634
  ...Object.fromEntries(Object.entries(app.getPublicEnv()).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)]))
580
635
  };
581
636
  };
582
637
 
583
638
  // pkgs/@akanjs/devkit/frontendBuild/csrDevPaths.ts
584
639
  import fs2 from "fs";
585
- import path3 from "path";
640
+ import path4 from "path";
586
641
 
587
642
  class CsrDevPaths {
588
643
  static modulePrefix = "akan-module:";
@@ -595,18 +650,18 @@ class CsrDevPaths {
595
650
  }
596
651
  idOf(file) {
597
652
  const real = CsrDevPaths.realpath(file);
598
- const relative = path3.relative(this.root, real);
599
- const id = relative.startsWith("..") || path3.isAbsolute(relative) ? real : relative;
600
- return id.split(path3.sep).join("/");
653
+ const relative = path4.relative(this.root, real);
654
+ const id = relative.startsWith("..") || path4.isAbsolute(relative) ? real : relative;
655
+ return id.split(path4.sep).join("/");
601
656
  }
602
657
  fileOf(id) {
603
- return path3.isAbsolute(id) ? id : path3.join(this.root, id);
658
+ return path4.isAbsolute(id) ? id : path4.join(this.root, id);
604
659
  }
605
660
  static isStub(target) {
606
661
  return target.startsWith(CsrDevPaths.stubPrefix);
607
662
  }
608
663
  static isVendorFile(file) {
609
- return file.includes(`${path3.sep}node_modules${path3.sep}`);
664
+ return file.includes(`${path4.sep}node_modules${path4.sep}`);
610
665
  }
611
666
  static isScript(file) {
612
667
  return /\.[cm]?[jt]sx?$/.test(file);
@@ -619,7 +674,7 @@ class CsrDevPaths {
619
674
  return await source.exists() ? Bun.hash(await source.arrayBuffer()).toString(36) : "";
620
675
  }
621
676
  static realpath(file) {
622
- return fs2.existsSync(file) ? fs2.realpathSync.native(file) : path3.resolve(file);
677
+ return fs2.existsSync(file) ? fs2.realpathSync.native(file) : path4.resolve(file);
623
678
  }
624
679
  static isNamed(file) {
625
680
  try {
@@ -636,7 +691,7 @@ class CsrDevPaths {
636
691
  return CsrDevPaths.#asFile(base, kind) ?? CsrDevPaths.#asFolder(base, kind);
637
692
  }
638
693
  static resolveRelative(dir, specifier, kind = "import") {
639
- const base = path3.resolve(dir, specifier);
694
+ const base = path4.resolve(dir, specifier);
640
695
  const folder = /(^|[\\/])\.\.?$|[\\/]$/.test(specifier);
641
696
  return folder ? CsrDevPaths.#asFolder(base, kind) : CsrDevPaths.resolveOnDisk(base, kind);
642
697
  }
@@ -646,15 +701,15 @@ class CsrDevPaths {
646
701
  }
647
702
  static #asFolder(dir, kind) {
648
703
  const entry = CsrDevPaths.#packageEntryOf(dir, kind);
649
- const named = entry ? CsrDevPaths.#asFile(path3.join(dir, entry), kind) ?? CsrDevPaths.#indexOf(path3.join(dir, entry), kind) : null;
704
+ const named = entry ? CsrDevPaths.#asFile(path4.join(dir, entry), kind) ?? CsrDevPaths.#indexOf(path4.join(dir, entry), kind) : null;
650
705
  return named ?? CsrDevPaths.#indexOf(dir, kind);
651
706
  }
652
707
  static #indexOf(dir, kind) {
653
- return CsrDevPaths.#asFile(path3.join(dir, "index"), kind);
708
+ return CsrDevPaths.#asFile(path4.join(dir, "index"), kind);
654
709
  }
655
710
  static #packageEntryOf(dir, kind) {
656
711
  try {
657
- const pkg = JSON.parse(fs2.readFileSync(path3.join(dir, "package.json"), "utf8"));
712
+ const pkg = JSON.parse(fs2.readFileSync(path4.join(dir, "package.json"), "utf8"));
658
713
  const fields = kind === "require" ? [pkg.browser, pkg.main] : [pkg.browser, pkg.module, pkg.main];
659
714
  const entry = fields.find((field) => typeof field === "string");
660
715
  return typeof entry === "string" ? entry : null;
@@ -667,11 +722,11 @@ class CsrDevPaths {
667
722
  const name = first.startsWith("@") ? `${first}/${second}` : first;
668
723
  if (!name || name.startsWith("."))
669
724
  return false;
670
- for (let dir = path3.resolve(from);; dir = path3.dirname(dir)) {
671
- const pkgDir = path3.join(dir, "node_modules", name);
672
- if (fs2.existsSync(path3.join(pkgDir, "package.json")))
725
+ for (let dir = path4.resolve(from);; dir = path4.dirname(dir)) {
726
+ const pkgDir = path4.join(dir, "node_modules", name);
727
+ if (fs2.existsSync(path4.join(pkgDir, "package.json")))
673
728
  return (fs2.statSync(pkgDir, { throwIfNoEntry: false })?.ctimeMs ?? 0) > since;
674
- if (path3.dirname(dir) === dir)
729
+ if (path4.dirname(dir) === dir)
675
730
  return false;
676
731
  }
677
732
  }
@@ -693,7 +748,7 @@ class CsrDevPaths {
693
748
  }
694
749
 
695
750
  // pkgs/@akanjs/devkit/frontendBuild/csrEntryFiles.ts
696
- import path4 from "path";
751
+ import path5 from "path";
697
752
 
698
753
  class CsrEntryFiles {
699
754
  static entryFilename(basePath) {
@@ -706,7 +761,7 @@ class CsrEntryFiles {
706
761
  });
707
762
  }
708
763
  static basePathOfPageKey(pageKey, basePaths) {
709
- const normalized = pageKey.split(path4.sep).join("/").replace(/^\.\//, "");
764
+ const normalized = pageKey.split(path5.sep).join("/").replace(/^\.\//, "");
710
765
  const segments = normalized.split("/");
711
766
  const firstPublicSegment = segments.find((segment) => segment !== "[lang]" && !/^\(.+\)$/.test(segment));
712
767
  return firstPublicSegment && basePaths.includes(firstPublicSegment) ? firstPublicSegment : null;
@@ -719,7 +774,7 @@ import path9 from "path";
719
774
  import ts3 from "typescript";
720
775
 
721
776
  // pkgs/@akanjs/devkit/transforms/externalizeFrameworkPlugin.ts
722
- import path5 from "path";
777
+ import path6 from "path";
723
778
  var DEFAULT_INCLUDE = ["akanjs/", "@apps/", "@libs/"];
724
779
  var DEFAULT_EXCLUDE_EXACT = new Set(["akanjs/webkit", "@akanjs/cli", "@akanjs/devkit"]);
725
780
  var DEFAULT_EXCLUDE_PREFIX = ["@akanjs/cli/", "@akanjs/devkit/"];
@@ -755,7 +810,7 @@ async function createExternalizeFrameworkPlugin(options) {
755
810
  const replPath = repl?.endsWith("/*") ? repl.slice(0, -1) : repl ?? "";
756
811
  if (!replPath)
757
812
  continue;
758
- const candidate = path5.resolve(workspaceRoot, replPath + suffix);
813
+ const candidate = path6.resolve(workspaceRoot, replPath + suffix);
759
814
  const hit = await firstExisting(candidate);
760
815
  if (hit)
761
816
  return hit;
@@ -765,8 +820,8 @@ async function createExternalizeFrameworkPlugin(options) {
765
820
  if (!spec.startsWith(`${pkg}/`))
766
821
  continue;
767
822
  const suffix = spec.slice(pkg.length + 1);
768
- const pkgDir = path5.dirname(path5.resolve(workspaceRoot, entryFile));
769
- const candidate = path5.join(pkgDir, suffix);
823
+ const pkgDir = path6.dirname(path6.resolve(workspaceRoot, entryFile));
824
+ const candidate = path6.join(pkgDir, suffix);
770
825
  const hit = await firstExisting(candidate);
771
826
  if (hit)
772
827
  return hit;
@@ -811,57 +866,13 @@ async function firstExisting(basePath) {
811
866
  return candidate;
812
867
  }
813
868
  for (const ext of CANDIDATE_EXTS3) {
814
- const candidate = path5.join(basePath, `index${ext}`);
869
+ const candidate = path6.join(basePath, `index${ext}`);
815
870
  if (await Bun.file(candidate).exists())
816
871
  return candidate;
817
872
  }
818
873
  return null;
819
874
  }
820
875
 
821
- // pkgs/@akanjs/devkit/transforms/rscUseClientTransform.ts
822
- import path6 from "path";
823
- import ts2 from "typescript";
824
- var USE_CLIENT_RE = /^\s*(?:\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\/\s*|\/\/[^\n]*\n\s*)*["']use client["']/;
825
- var IMPLICIT_ROOT_LAYOUT_RE = /[/\\]\.akan[/\\]generated[/\\](?:implicit-root-layout|root-layouts[/\\][^/\\]*__root_layout)\.(tsx|ts|jsx|js)$/;
826
- var STAR_REEXPORT_HINT_RE = /\bexport\s*\*\s*from\b/;
827
- var hasUseClientDirective = (source) => USE_CLIENT_RE.test(source);
828
- function toClientReferencePath(absPath, workspaceRoot) {
829
- return path6.relative(path6.resolve(workspaceRoot), path6.resolve(absPath)).split(path6.sep).join("/");
830
- }
831
- var starReexportSpecifiers = (source, filePath) => ts2.createSourceFile(filePath, source, ts2.ScriptTarget.Latest).statements.filter((statement) => ts2.isExportDeclaration(statement) && !statement.exportClause && !statement.isTypeOnly && !!statement.moduleSpecifier && ts2.isStringLiteral(statement.moduleSpecifier)).map((statement) => statement.moduleSpecifier.text);
832
- var scanUseClientExports = (source, filePath, workspaceRoot) => {
833
- const stars = USE_CLIENT_RE.test(source) && STAR_REEXPORT_HINT_RE.test(source) ? starReexportSpecifiers(source, filePath) : [];
834
- if (stars.length) {
835
- const file = workspaceRoot ? toClientReferencePath(filePath, workspaceRoot) : filePath;
836
- const listed = stars.slice(0, 3).map((specifier) => `\`export * from ${JSON.stringify(specifier)}\``);
837
- const written = stars.length > 3 ? `${listed.join(", ")} (and ${stars.length - 3} more)` : listed.join(", ");
838
- throw new Error(`${file} is a "use client" module, so it cannot ${written}: the server sees only the names a client module ` + `declares, and a star re-export declares none. Re-export them by name \u2014 \`export { \u2026 } from ${JSON.stringify(stars[0])}\`.`);
839
- }
840
- return new Bun.Transpiler({ loader: loaderFor(filePath) }).scan(source).exports;
841
- };
842
- function transformUseClient(source, args) {
843
- if (!USE_CLIENT_RE.test(source))
844
- return null;
845
- if (IMPLICIT_ROOT_LAYOUT_RE.test(args.path))
846
- return null;
847
- const exports = scanUseClientExports(source, args.path, args.workspaceRoot);
848
- if (exports.length === 0)
849
- return null;
850
- args.onClientModule?.(args.path, exports);
851
- const referencePath = args.workspaceRoot ? toClientReferencePath(args.path, args.workspaceRoot) : args.path;
852
- const filePathLit = JSON.stringify(referencePath);
853
- const lines = [`import { registerClientReference } from "react-server-dom-webpack/server.node";`];
854
- for (const name of exports) {
855
- const nameLit = JSON.stringify(name);
856
- const errMsg = JSON.stringify(`Attempted to call '${name}' from '${referencePath}' on the server, but it is a client-only export.`);
857
- const proxy = `() => { throw new Error(${errMsg}); }`;
858
- const binding = name === "default" ? `export default registerClientReference(${proxy}, ${filePathLit}, ${nameLit});` : `export const ${name} = registerClientReference(${proxy}, ${filePathLit}, ${nameLit});`;
859
- lines.push(binding);
860
- }
861
- return lines.join(`
862
- `);
863
- }
864
-
865
876
  // pkgs/@akanjs/devkit/transforms/useClientBundlePlugin.ts
866
877
  function createUseClientBundlePlugin(options = {}) {
867
878
  return {
@@ -1181,7 +1192,7 @@ class PagesBundleBuilder {
1181
1192
  edits.push({
1182
1193
  start: tokens[fetchProtoAt].start,
1183
1194
  end: fetchProtoEnd.end,
1184
- text: "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { Err: pageProto.Err, base: serverFetch });"
1195
+ text: "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { base: serverFetch });"
1185
1196
  });
1186
1197
  let transformed = source;
1187
1198
  for (const { start, end, text } of edits.sort((a, b) => b.start - a.start))
@@ -1,9 +1,9 @@
1
1
  // @bun
2
2
  import {
3
3
  getDirname2
4
- } from "./index-bns3wcpc.js";
4
+ } from "./index-by2tvsq6.js";
5
5
 
6
- // pkgs/@akanjs/devkit/conventionSet.ts
6
+ // pkgs/@akanjs/devkit/guideline/conventionSet.ts
7
7
  import fsPromise from "fs/promises";
8
8
  import path from "path";
9
9
 
@@ -25,7 +25,7 @@ class ConventionSet {
25
25
  if (!match)
26
26
  throw new Error(`Convention rule ${name} has no frontmatter`);
27
27
  const front = match[1] ?? "";
28
- const described = /^description:\s*(.+)$/m.exec(front);
28
+ const described = /^description:(.*)$/m.exec(front);
29
29
  const description = described?.[1]?.trim() ?? "";
30
30
  const paths = [...front.matchAll(/^\s+-\s+"([^"]+)"$/gm)].map((entry) => entry[1] ?? "");
31
31
  if (!description || paths.length === 0)
@@ -61,13 +61,13 @@ class ConventionSet {
61
61
  }
62
62
  }
63
63
 
64
- // pkgs/@akanjs/devkit/prompter.ts
64
+ // pkgs/@akanjs/devkit/guideline/prompter.ts
65
65
  import fsPromise2 from "fs/promises";
66
66
  import { input, select } from "@inquirer/prompts";
67
67
  class Prompter2 {
68
68
  static async#getGuidelineRoot() {
69
69
  const dirname = getDirname2(import.meta.url);
70
- const candidates = [`${dirname}/guidelines`, `${dirname}/../cli/guidelines`];
70
+ const candidates = [`${dirname}/guidelines`, `${dirname}/../../cli/guidelines`];
71
71
  for (const candidate of candidates) {
72
72
  try {
73
73
  await fsPromise2.access(candidate);
@@ -2,9 +2,11 @@
2
2
  import {
3
3
  runner,
4
4
  script,
5
- ExitCodeError,
6
5
  markCliErrorPrinted
7
- } from "./index-386canwe.js";
6
+ } from "./index-9rv2zt48.js";
7
+ import {
8
+ CliError
9
+ } from "./index-j4yvgfhr.js";
8
10
  import {
9
11
  AGENT_BLOCK_START,
10
12
  AGENT_BLOCK_END,
@@ -12,41 +14,45 @@ import {
12
14
  readDevkitVersion,
13
15
  upsertAgentBlock,
14
16
  renderRecipeEntries,
15
- CLAUDE_COMMENT_RULE,
16
- AppExecutor,
17
- LibExecutor
18
- } from "./index-wfmpxke3.js";
17
+ CLAUDE_COMMENT_RULE
18
+ } from "./index-qssq2d41.js";
19
19
  import {
20
- akanCodePaths2
21
- } from "./index-35j83zkd.js";
20
+ AppExecutor2
21
+ } from "./index-ze48c0vd.js";
22
22
  import {
23
- ConventionSet,
24
- Prompter2
25
- } from "./index-j6eeh5d7.js";
23
+ LibExecutor2
24
+ } from "./index-na8r4a27.js";
26
25
  import {
27
26
  AkanContextAnalyzer
28
- } from "./index-0mqga3h9.js";
27
+ } from "./index-nmxszh6x.js";
29
28
  import {
30
29
  collectRecipeSources2,
31
30
  scanRecipes2
32
- } from "./index-hj6w4ka1.js";
31
+ } from "./index-1p81ecbz.js";
32
+ import {
33
+ akanCodePaths2
34
+ } from "./index-p5zh7pmc.js";
35
+ import {
36
+ ConventionSet,
37
+ Prompter2
38
+ } from "./index-knpm8sdm.js";
33
39
  import {
34
40
  ApplicationRunner,
35
41
  VerifyScope
36
- } from "./index-kcpk2d20.js";
42
+ } from "./index-h1w4wqgd.js";
37
43
  import {
38
44
  WorkspaceRunner
39
- } from "./index-466z5931.js";
45
+ } from "./index-2d9nm03s.js";
40
46
  import {
41
47
  VerifyComments,
42
48
  VerifyPipeline,
43
49
  VerifyReport
44
- } from "./index-dk4g0x0d.js";
50
+ } from "./index-zttyg7tg.js";
45
51
 
46
52
  // pkgs/@akanjs/cli/agent/agent.script.ts
47
53
  import { Logger as Logger3 } from "akanjs/common";
48
54
 
49
- // pkgs/@akanjs/devkit/agentAssets.ts
55
+ // pkgs/@akanjs/devkit/guideline/agentAssets.ts
50
56
  import fsPromise from "fs/promises";
51
57
  import path from "path";
52
58
  class AgentAssets {
@@ -79,7 +85,7 @@ class AgentAssets {
79
85
  "modelUtil",
80
86
  "framework"
81
87
  ],
82
- "akan-err": [],
88
+ "akan-err": ["errorCodes"],
83
89
  "akan-deps": [],
84
90
  "akan-debug": [],
85
91
  "akan-page": ["pageRule", "akanApi"],
@@ -432,6 +438,21 @@ ${Object.keys(AgentAssets.skillReferences).map((name) => `\`${name}\``).join(",
432
438
  guideline.
433
439
 
434
440
  `;
441
+ var maxListedChars = 160;
442
+ var renderNames = (names) => {
443
+ if (!names.length)
444
+ return "none";
445
+ const shown = [];
446
+ let length = 0;
447
+ for (const name of names) {
448
+ if (shown.length && length + name.length > maxListedChars)
449
+ break;
450
+ shown.push(name);
451
+ length += name.length + 2;
452
+ }
453
+ const rest = names.length - shown.length;
454
+ return rest ? `${shown.join(", ")}, and ${rest} more` : shown.join(", ");
455
+ };
435
456
  var renderManagedBlock = async (workspace) => {
436
457
  const context = await AkanContextAnalyzer.analyze(workspace);
437
458
  const conventions = await Prompter2.getConventionSet();
@@ -441,9 +462,9 @@ var renderManagedBlock = async (workspace) => {
441
462
  const block = `## Workspace
442
463
 
443
464
  - Repo: ${context.repoName}
444
- - Apps: ${appNames.join(", ") || "none"}
445
- - Libraries: ${context.libs.map((lib) => lib.name).join(", ") || "none"}
446
- - Packages: ${context.pkgs.map((pkg) => pkg.name).join(", ") || "none"}
465
+ - Apps: ${renderNames(appNames)}
466
+ - Libraries: ${renderNames(context.libs.map((lib) => lib.name))}
467
+ - Packages: ${renderNames(context.pkgs.map((pkg) => pkg.name))}
447
468
 
448
469
  ${conventions.core}
449
470
 
@@ -593,9 +614,9 @@ class AgentRunner extends runner("agent") {
593
614
  }
594
615
  };
595
616
  for (const name of libNames)
596
- await syncScope(LibExecutor.from(workspace, name));
617
+ await syncScope(LibExecutor2.from(workspace, name));
597
618
  for (const name of appNames)
598
- await syncScope(AppExecutor.from(workspace, name));
619
+ await syncScope(AppExecutor2.from(workspace, name));
599
620
  return written;
600
621
  }
601
622
  }
@@ -610,7 +631,7 @@ var resolveTargets = (target) => {
610
631
  const single = singleTargets.find((name) => name === target);
611
632
  if (single)
612
633
  return [single];
613
- throw new Error(`Unknown agent target: ${target}. Use cursor, agents-md, claude, rules, skills, hooks, or all.`);
634
+ throw new CliError("usage", `Unknown agent target: ${target}. Use cursor, agents-md, claude, rules, skills, hooks, or all.`);
614
635
  };
615
636
 
616
637
  class AgentScript extends script("agent", [AgentRunner]) {
@@ -618,7 +639,7 @@ class AgentScript extends script("agent", [AgentRunner]) {
618
639
  if (action === "hook")
619
640
  return await this.#hook(workspace, target);
620
641
  if (action !== "install")
621
- throw new Error(`Unknown agent action: ${action}. Use "install" or "hook".`);
642
+ throw new CliError("usage", `Unknown agent action: ${action}. Use "install" or "hook".`);
622
643
  if (check)
623
644
  return await this.#check(workspace, resolveTargets(target));
624
645
  const written = await this.agentRunner.install(workspace, resolveTargets(target), { force });
@@ -634,19 +655,27 @@ ${written.map((file) => `- ${file}`).join(`
634
655
  const lines = drift.map(({ path, change }) => `${path} ${change}`);
635
656
  Logger3.rawLog([`agent files differ \xB7 ${files} \xB7 run \`akan agent install\``, ...lines].join(`
636
657
  `));
637
- const failure = new ExitCodeError("agent files differ", 1);
658
+ const failure = new CliError("checkFailed", "agent files differ");
638
659
  markCliErrorPrinted(failure);
639
660
  throw failure;
640
661
  }
641
662
  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}
663
+ try {
664
+ if (!AgentHook.isEvent(event))
665
+ throw new CliError("usage", `Unknown hook: ${event}. Use ${AgentHook.events.join(", ")}.`);
666
+ const raw = (await Bun.stdin.text()).trim();
667
+ const input = raw ? JSON.parse(raw) : {};
668
+ const response = AgentHook.respond(event, await new AgentHook(workspace).run(event, input));
669
+ if (response)
670
+ process.stdout.write(`${response}
649
671
  `);
672
+ } catch (error) {
673
+ const message = CliError.messageOf(error);
674
+ Logger3.rawLog(message, undefined, "error");
675
+ const failure = new CliError("failed", message, { cause: error });
676
+ markCliErrorPrinted(failure);
677
+ throw failure;
678
+ }
650
679
  }
651
680
  }
652
681
 
@@ -0,0 +1,30 @@
1
+ // @bun
2
+ import {
3
+ execEmoji,
4
+ Executor,
5
+ SysExecutor,
6
+ WorkspaceExecutor,
7
+ AkanLibConfig
8
+ } from "./index-qssq2d41.js";
9
+
10
+ // pkgs/@akanjs/devkit/executors/libExecutor.ts
11
+ class LibExecutor2 extends SysExecutor {
12
+ dist;
13
+ emoji = execEmoji.lib;
14
+ constructor({ workspace, name }) {
15
+ super({ workspace, name, type: "lib" });
16
+ this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/libs/${name}`);
17
+ }
18
+ static from(executor, name) {
19
+ return new LibExecutor2({ workspace: executor instanceof WorkspaceExecutor ? executor : executor.workspace, name });
20
+ }
21
+ #akanConfig = null;
22
+ async getConfig({ refresh } = {}) {
23
+ if (this.#akanConfig && !refresh)
24
+ return this.#akanConfig;
25
+ this.#akanConfig = await AkanLibConfig.from(this, { bustImportCache: refresh });
26
+ return this.#akanConfig;
27
+ }
28
+ }
29
+
30
+ export { LibExecutor2 };