@akanjs/cli 3.1.2-rc.3 → 3.2.0-rc.0

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 (130) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-n2tkg59z.js → CodeAgent-h6g8dg3a.js} +2 -2
  3. package/{CodeTui-9wsdx7ap.js → CodeTui-n9gacepn.js} +1 -1
  4. package/README.ko.md +9 -0
  5. package/README.md +9 -0
  6. package/TunnelShare-k3ja4w9x.js +14 -0
  7. package/{agent.command-tffz6wdn.js → agent.command-2f657613.js} +19 -17
  8. package/akanCode.js +2 -2
  9. package/{application.command-7bkxbrsp.js → application.command-yb8v177e.js} +45 -22
  10. package/{applicationBuildRunner-s13x3zqb.js → applicationBuildRunner-sctcmkyx.js} +57 -17
  11. package/buildBatch.proc.js +7 -7
  12. package/{cloud.command-a792bc10.js → cloud.command-et06ja22.js} +35 -18
  13. package/cloud.script-s6rbrwer.js +30 -0
  14. package/{code.command-ma8dtzww.js → code.command-7m67c7zc.js} +6 -6
  15. package/commandManifest.json +1 -1
  16. package/{context.command-80a1qhps.js → context.command-569z0rqf.js} +20 -19
  17. package/context.runner-ms8v1rxy.js +29 -0
  18. package/{guideline.command-195g0h9a.js → guideline.command-gnv3e8p8.js} +2 -2
  19. package/guidelines/akanApi/akanApi.instruction.md +317 -0
  20. package/guidelines/conventions/rules/app.md +5 -5
  21. package/guidelines/conventions/rules/config.md +1 -1
  22. package/guidelines/conventions/rules/gates.md +10 -5
  23. package/guidelines/conventions/rules/page.md +4 -2
  24. package/guidelines/conventions/rules/server.md +2 -0
  25. package/guidelines/conventions/rules/style.md +3 -1
  26. package/guidelines/conventions/rules/ts.md +2 -1
  27. package/guidelines/cssRule/cssRule.instruction.md +3 -1
  28. package/guidelines/pageRule/pageRule.instruction.md +3 -0
  29. package/incrementalBuilder.proc.js +70 -14
  30. package/{index-tns543wd.js → index-0fb3cpbt.js} +3 -3
  31. package/{index-zbrwnmf1.js → index-1q1cjn8s.js} +21 -11
  32. package/{index-wrmq92vk.js → index-3wjbhj2n.js} +1 -1
  33. package/{index-361ex3rb.js → index-48d5qsj3.js} +4 -4
  34. package/{index-aayg4dqf.js → index-5w9my9qe.js} +8 -8
  35. package/{index-1h2jc0x3.js → index-6wpaq392.js} +61 -15
  36. package/{index-tp56652m.js → index-7xdpww43.js} +69 -12
  37. package/index-7y5yghjg.js +2969 -0
  38. package/{index-zttm13c3.js → index-8g7tdsk4.js} +249 -696
  39. package/{index-m02tdq8a.js → index-8pb9yvp8.js} +63 -21
  40. package/{index-gbp1q1b5.js → index-8ts9774g.js} +4 -4
  41. package/{index-9zy8479y.js → index-93ewzmp6.js} +43 -14
  42. package/{index-zdpte1pj.js → index-9tbgb4d8.js} +1 -1
  43. package/index-abgh0jve.js +126 -0
  44. package/{index-khk05tsf.js → index-aj3ehkcx.js} +1 -1
  45. package/{index-84h43kg6.js → index-d4n1wmrz.js} +37 -4
  46. package/{index-gr9thy79.js → index-drz9e84d.js} +22 -8
  47. package/{index-hapx5myy.js → index-e3vmjtph.js} +2 -2
  48. package/{index-k64mhwbw.js → index-eajbmk10.js} +2 -1
  49. package/{index-0j1t1h2b.js → index-ed6ea0qp.js} +1 -1
  50. package/{index-sjabnf7j.js → index-fjr4d6yd.js} +444 -368
  51. package/index-hqrkqxx2.js +176 -0
  52. package/{index-z7kbxdqg.js → index-jdamtr7e.js} +3 -3
  53. package/{index-scck6h6d.js → index-kpdv34rq.js} +4 -4
  54. package/{index-ppvqy5bc.js → index-ktb3wcqz.js} +73 -34
  55. package/{index-sveq36gh.js → index-mmym5xmb.js} +4 -2
  56. package/{index-y4kcmbt2.js → index-mqntfzv5.js} +2 -2
  57. package/{index-4am4dvmf.js → index-ny2k80mv.js} +15 -3
  58. package/index-p6hjwt2d.js +1668 -0
  59. package/{index-wwe9rsrx.js → index-r0a604h4.js} +12 -2
  60. package/{index-jb2sreps.js → index-rc5fvqj2.js} +18 -18
  61. package/{index-db2nqrad.js → index-ryrm5z2c.js} +71 -19
  62. package/{index-eft5c2mp.js → index-s2grpzef.js} +331 -27
  63. package/{index-g500c5j9.js → index-sr5da35e.js} +33 -10
  64. package/{index-defp4gmb.js → index-sy481q2x.js} +1 -1
  65. package/{index-j9d3mjx1.js → index-thckcabc.js} +2 -2
  66. package/{index-9z3egsmg.js → index-vkzfk7qt.js} +25 -23
  67. package/index-w639tvkd.js +166 -0
  68. package/index-ygdbn9jn.js +122 -0
  69. package/{index-sp0qsr7a.js → index-zpv14wpy.js} +3 -3
  70. package/{index-sx91nf4z.js → index-zxsygkda.js} +18 -9
  71. package/index.js +24 -23
  72. package/{library.command-63hgt9te.js → library.command-1gp5qe3r.js} +3 -3
  73. package/{localRegistry.command-343ksmn9.js → localRegistry.command-v3g21rex.js} +25 -16
  74. package/{module.command-2hce9m6k.js → module.command-4xz9he6h.js} +6 -6
  75. package/{package.command-96eheyvd.js → package.command-s7qpnn1g.js} +12 -3
  76. package/package.json +2 -2
  77. package/{page.command-gs6d841d.js → page.command-fan34c49.js} +3 -3
  78. package/{pipeline.command-wdfvdbfj.js → pipeline.command-ph4fnn9w.js} +2 -2
  79. package/{primitive.command-7tdj12wn.js → primitive.command-3fqh8emf.js} +7 -7
  80. package/{projectTypecheck-kqj1t6hb.js → projectTypecheck-vkb40hjc.js} +1 -1
  81. package/{quality.command-29bgarh1.js → quality.command-ecj6exsh.js} +15 -10
  82. package/{repair.command-yng4rf5d.js → repair.command-fe9jw719.js} +6 -6
  83. package/{scalar.command-1nk4329t.js → scalar.command-cnvfhk0n.js} +5 -5
  84. package/skills/akan-debug/SKILL.md +2 -1
  85. package/skills/akan-page/SKILL.md +30 -2
  86. package/skills/akan-service/SKILL.md +77 -1
  87. package/{subspace.command-5cehmcdd.js → subspace.command-yxtt3v3e.js} +8 -8
  88. package/templates/app/lib/___appName__/__appName__.abstract.md.template +6 -0
  89. package/templates/app/page/_index.tsx +4 -284
  90. package/templates/app/page/_layout.tsx +1 -26
  91. package/templates/app/page/styles.css.template +58 -318
  92. package/templates/appSample/page/_index.tsx +281 -0
  93. package/templates/appSample/page/_layout.tsx +55 -0
  94. package/templates/appSample/page/styles.css.template +327 -0
  95. package/templates/libRoot/lib/___libName__/__libName__.abstract.md.template +6 -0
  96. package/templates/workspaceRoot/package.json.template +1 -12
  97. package/{tunnel.command-yrd4atqy.js → tunnel.command-ggj38mqf.js} +7 -7
  98. package/{typeChecker-j2jdnqsr.js → typeChecker-s640r6c0.js} +1 -1
  99. package/typecheck.proc.js +1 -1
  100. package/{verify.command-kbq0fcg8.js → verify.command-w9ttxkdz.js} +16 -14
  101. package/{workflow.command-274qfa8z.js → workflow.command-ss8devj0.js} +12 -12
  102. package/{workspace.command-r6hgmawy.js → workspace.command-rw1p0xeq.js} +50 -38
  103. package/TunnelShare-6d7z36sr.js +0 -14
  104. package/cloud.script-t2n13gv6.js +0 -27
  105. package/context.runner-wxqb3qcy.js +0 -28
  106. package/index-j2dgmzbj.js +0 -1259
  107. package/index-p6x5b7hr.js +0 -839
  108. package/index-vzpnr12w.js +0 -65
  109. package/templates/workspaceRoot/patches/zod@3.25.76.patch.template +0 -22
  110. package/templates/workspaceRoot/patches/zod@4.4.3.patch.template +0 -11
  111. /package/templates/{app → appSample}/page/_overrides.tsx +0 -0
  112. /package/templates/{app → appSample}/public/fonts/Pretendard-Black.woff2 +0 -0
  113. /package/templates/{app → appSample}/public/fonts/Pretendard-Bold.woff2 +0 -0
  114. /package/templates/{app → appSample}/public/fonts/Pretendard-ExtraBold.woff2 +0 -0
  115. /package/templates/{app → appSample}/public/fonts/Pretendard-ExtraLight.woff2 +0 -0
  116. /package/templates/{app → appSample}/public/fonts/Pretendard-Light.woff2 +0 -0
  117. /package/templates/{app → appSample}/public/fonts/Pretendard-Medium.woff2 +0 -0
  118. /package/templates/{app → appSample}/public/fonts/Pretendard-Regular.woff2 +0 -0
  119. /package/templates/{app → appSample}/public/fonts/Pretendard-SemiBold.woff2 +0 -0
  120. /package/templates/{app → appSample}/public/fonts/Pretendard-Thin.woff2 +0 -0
  121. /package/templates/{app → appSample}/public/jelly/cloud.webp +0 -0
  122. /package/templates/{app → appSample}/public/jelly/comet.webp +0 -0
  123. /package/templates/{app → appSample}/public/jelly/moon.webp +0 -0
  124. /package/templates/{app → appSample}/public/jelly/planet.webp +0 -0
  125. /package/templates/{app → appSample}/public/jelly/rocket.webp +0 -0
  126. /package/templates/{app → appSample}/public/jelly/star.webp +0 -0
  127. /package/templates/{app → appSample}/public/jelly/sugar.webp +0 -0
  128. /package/templates/{app → appSample}/public/logo.png +0 -0
  129. /package/templates/{app → appSample}/ui/Recipe/index.ts +0 -0
  130. /package/templates/{app → appSample}/ui/Recipe/jellyButton.ts +0 -0
@@ -3,12 +3,12 @@ import {
3
3
  HmrWatcher,
4
4
  WatchRootResolver,
5
5
  ApplicationBuildReporter
6
- } from "./index-p6x5b7hr.js";
6
+ } from "./index-p6hjwt2d.js";
7
7
  import {
8
8
  CodegenLock,
9
9
  WorkspaceExecutor,
10
10
  AppExecutor
11
- } from "./index-g500c5j9.js";
11
+ } from "./index-sr5da35e.js";
12
12
  import"./index-bns3wcpc.js";
13
13
  import {
14
14
  GraphClientEntryDiscovery,
@@ -19,14 +19,20 @@ import {
19
19
  DevChangePlanner,
20
20
  DevGeneratedIndexSync,
21
21
  SsrDevBundler
22
- } from "./index-tp56652m.js";
22
+ } from "./index-7xdpww43.js";
23
23
  import {
24
24
  ServerGraphFile
25
- } from "./index-zbrwnmf1.js";
26
- import"./index-j2dgmzbj.js";
25
+ } from "./index-1q1cjn8s.js";
26
+ import"./index-7y5yghjg.js";
27
+ import {
28
+ FrameworkGraph
29
+ } from "./index-abgh0jve.js";
30
+ import {
31
+ GitRevision
32
+ } from "./index-ygdbn9jn.js";
27
33
  import {
28
34
  WorkspaceGraph
29
- } from "./index-vzpnr12w.js";
35
+ } from "./index-w639tvkd.js";
30
36
  import {
31
37
  prepareDevWatchBatch
32
38
  } from "./index-a5vmm6x4.js";
@@ -143,6 +149,59 @@ class BuilderChannel {
143
149
  }
144
150
  }
145
151
 
152
+ // pkgs/@akanjs/devkit/incrementalBuilder/builderGraphPayloads.ts
153
+ class BuilderGraphPayloads {
154
+ #app;
155
+ #generation;
156
+ #graph = null;
157
+ #changes = null;
158
+ constructor(app, generation) {
159
+ this.#app = app;
160
+ this.#generation = generation;
161
+ }
162
+ touched(files) {
163
+ FrameworkGraph.touched(this.#app.workspace.workspaceRoot, files);
164
+ }
165
+ async of(msg) {
166
+ if (msg.framework)
167
+ return await this.#framework();
168
+ return msg.changes ? await this.#changesSince(msg.changes.since) : await this.#workspaceGraph();
169
+ }
170
+ async#workspaceGraph() {
171
+ const generation = this.#generation();
172
+ if (this.#graph?.generation !== generation) {
173
+ const { workspace } = this.#app;
174
+ const graph = WorkspaceGraph.visibleTo(await WorkspaceGraph.build(workspace), this.#app.name);
175
+ this.#graph = { generation, payload: { workspaceRoot: workspace.workspaceRoot, graph } };
176
+ }
177
+ return this.#graph.payload;
178
+ }
179
+ async#framework() {
180
+ const { workspaceRoot } = this.#app.workspace;
181
+ return { workspaceRoot, framework: await FrameworkGraph.cached(workspaceRoot) };
182
+ }
183
+ async#changesSince(since) {
184
+ const { workspace, name } = this.#app;
185
+ const { workspaceRoot } = workspace;
186
+ const forkPoint = await new GitRevision(workspaceRoot).forkPointOf(since);
187
+ if (forkPoint.error !== undefined)
188
+ return { workspaceRoot, changes: { error: forkPoint.error } };
189
+ const key = `${this.#generation()}:${forkPoint.sha}`;
190
+ if (this.#changes?.key !== key) {
191
+ const payload = WorkspaceGraph.changesAt(workspace, forkPoint.sha).then((changes) => ({
192
+ workspaceRoot,
193
+ changes: WorkspaceGraph.changesVisibleTo(changes, name)
194
+ }));
195
+ payload.catch(() => {
196
+ if (this.#changes?.payload === payload)
197
+ this.#changes = null;
198
+ });
199
+ this.#changes = { key, payload };
200
+ }
201
+ return await this.#changes.payload;
202
+ }
203
+ }
204
+
146
205
  // pkgs/@akanjs/devkit/incrementalBuilder/builderWorkQueue.ts
147
206
  class BuilderWorkQueue {
148
207
  #runBatch;
@@ -242,7 +301,7 @@ class IncrementalBuilder {
242
301
  #watcher = null;
243
302
  #generation = 0;
244
303
  #shellKey = null;
245
- #graph = null;
304
+ #graphPayloads;
246
305
  #discoveredThrough = 0;
247
306
  #csrActive = IncrementalBuilder.#csrArmedByEnv();
248
307
  #csrBundler;
@@ -280,6 +339,7 @@ class IncrementalBuilder {
280
339
  this.#discovery = options.discovery;
281
340
  this.#generation = options.initialGeneration ?? 0;
282
341
  this.#discoveredThrough = this.#generation;
342
+ this.#graphPayloads = new BuilderGraphPayloads(options.app, () => this.#generation);
283
343
  this.#batchRunner = new BuildBatchRunner({
284
344
  workspaceRoot: options.app.workspace.workspaceRoot,
285
345
  cwd: options.app.cwdPath
@@ -513,6 +573,7 @@ class IncrementalBuilder {
513
573
  this.#logger.verbose(`watching ${roots.length} roots`);
514
574
  }
515
575
  async#handleWatchBatch(batch) {
576
+ this.#graphPayloads.touched(batch.files);
516
577
  const rawKinds = new Set(batch.kinds);
517
578
  if (rawKinds.size === 0)
518
579
  return;
@@ -924,14 +985,9 @@ class IncrementalBuilder {
924
985
  this.#logger.verbose(`announced boot state after recycle generation=${generation}`);
925
986
  }
926
987
  async handleBuildGraph(msg) {
927
- const generation = this.#generation;
928
988
  try {
929
- if (this.#graph?.generation !== generation) {
930
- const { workspace } = this.#app;
931
- const graph = WorkspaceGraph.visibleTo(await WorkspaceGraph.build(workspace), this.#app.name);
932
- this.#graph = { generation, payload: { workspaceRoot: workspace.workspaceRoot, graph } };
933
- }
934
- await BuilderChannel.send({ type: "build-graph-res", id: msg.id, ok: true, data: this.#graph.payload });
989
+ const data = await this.#graphPayloads.of(msg);
990
+ await BuilderChannel.send({ type: "build-graph-res", id: msg.id, ok: true, data });
935
991
  } catch (err) {
936
992
  const error = ApplicationBuildReporter.formatError(err, this.#app.workspace.workspaceRoot);
937
993
  this.#logger.error(`build-graph failed: ${error}`);
@@ -7,13 +7,13 @@ import {
7
7
  isWorkflowSysName,
8
8
  isWorkflowModuleName,
9
9
  renderRepairReport
10
- } from "./index-m02tdq8a.js";
10
+ } from "./index-8pb9yvp8.js";
11
11
  import {
12
12
  AkanContextAnalyzer
13
- } from "./index-j9d3mjx1.js";
13
+ } from "./index-thckcabc.js";
14
14
  import {
15
15
  runner
16
- } from "./index-9zy8479y.js";
16
+ } from "./index-93ewzmp6.js";
17
17
 
18
18
  // pkgs/@akanjs/cli/repair/repair.runner.ts
19
19
  var akanArgPattern = /^(?:--?[a-z][a-zA-Z0-9-]*|[A-Za-z0-9@_][A-Za-z0-9@._/:,=-]*)$/;
@@ -1,8 +1,9 @@
1
1
  // @bun
2
2
  import {
3
3
  AsyncDefaultExportDetector,
4
+ StoreBootstrap,
4
5
  resolveSsrPageEntriesForApp
5
- } from "./index-g500c5j9.js";
6
+ } from "./index-sr5da35e.js";
6
7
  import {
7
8
  FileSys2
8
9
  } from "./index-bns3wcpc.js";
@@ -110,10 +111,15 @@ class BarrelAnalyzer {
110
111
  if (!isRelative(spec))
111
112
  continue;
112
113
  if (star) {
113
- if (nsAs)
114
- authoritative.delete(nsAs);
115
- else
114
+ if (!nsAs)
116
115
  starSpecs.push(spec);
116
+ else if (authoritative.has(nsAs)) {
117
+ attributed.add(nsAs);
118
+ const targetAbs = await this.#resolveRel(absFile, spec);
119
+ const targetSubpath = targetAbs ? this.#subpathFor(pkg, targetAbs) : null;
120
+ if (targetSubpath && !map.has(nsAs))
121
+ map.set(nsAs, { subpath: targetSubpath, originalName: nsAs, namespace: true });
122
+ }
117
123
  continue;
118
124
  }
119
125
  if (namedList !== undefined) {
@@ -263,7 +269,7 @@ var createTsconfigPackageResolver = async (app) => {
263
269
  continue;
264
270
  const replPath = repl.endsWith("/*") ? repl.slice(0, -1) : repl;
265
271
  const candidate = path2.resolve(app.workspace.workspaceRoot, replPath + suffix);
266
- for (const ext of CANDIDATE_EXTS2) {
272
+ for (const ext of CANDIDATE_EXTS2.includes(path2.extname(candidate)) ? ["", ...CANDIDATE_EXTS2] : CANDIDATE_EXTS2) {
267
273
  const file = `${candidate}${ext}`;
268
274
  if (await Bun.file(file).exists()) {
269
275
  const lastSlash = pkgName.lastIndexOf("/");
@@ -479,6 +485,7 @@ var rewriteSingleStatement = (stmt, map) => {
479
485
  return null;
480
486
  const remaining = [];
481
487
  const rewrites = new Map;
488
+ const namespaceLines = [];
482
489
  for (const item of clause.named) {
483
490
  if (item.isType) {
484
491
  remaining.push(item);
@@ -489,15 +496,17 @@ var rewriteSingleStatement = (stmt, map) => {
489
496
  remaining.push(item);
490
497
  continue;
491
498
  }
499
+ if (target.namespace) {
500
+ namespaceLines.push(`import * as ${item.local} from "${target.subpath}";`);
501
+ continue;
502
+ }
492
503
  const list = rewrites.get(target.subpath) ?? [];
493
504
  list.push({ imported: target.originalName, local: item.local, isType: false });
494
505
  rewrites.set(target.subpath, list);
495
506
  }
496
- if (rewrites.size === 0)
507
+ if (rewrites.size === 0 && namespaceLines.length === 0)
497
508
  return null;
498
- const lines = [];
499
- if (shouldPreserveBarrelSideEffects(stmt.specifier))
500
- lines.push(`import "${stmt.specifier}";`);
509
+ const lines = [...StoreBootstrap.ofClientBarrel(stmt.specifier, map) ?? []];
501
510
  if (clause.defaultImport || remaining.length > 0) {
502
511
  const parts = [];
503
512
  if (clause.defaultImport)
@@ -509,10 +518,10 @@ var rewriteSingleStatement = (stmt, map) => {
509
518
  for (const [subpath, items] of rewrites) {
510
519
  lines.push(`import { ${items.map(serializeNamedItem).join(", ")} } from "${subpath}";`);
511
520
  }
521
+ lines.push(...namespaceLines);
512
522
  return lines.join(`
513
523
  `);
514
524
  };
515
- var shouldPreserveBarrelSideEffects = (specifier) => /^@(apps|libs)\/[^/]+\/client$/.test(specifier);
516
525
  var serializeNamedItem = (item) => {
517
526
  const prefix = item.isType ? "type " : "";
518
527
  if (item.imported === item.local)
@@ -521,6 +530,7 @@ var serializeNamedItem = (item) => {
521
530
  };
522
531
 
523
532
  // pkgs/@akanjs/devkit/frontendBuild/bundleDefine.ts
533
+ var bundleConditions = (command) => command === "build" ? ["production"] : [];
524
534
  var bundleDefine = (app, command, renderEnv) => {
525
535
  const nodeEnv = command === "build" ? "production" : "development";
526
536
  return {
@@ -1172,4 +1182,4 @@ class PagesBundleBuilder {
1172
1182
  }
1173
1183
  }
1174
1184
 
1175
- export { loaderFor, BarrelAnalyzer, createBarrelImportsPlugin, createTsconfigPackageResolver, rewriteBarrelImports, bundleDefine, CsrEntryFiles, toClientReferencePath, scanUseClientExports, CsrDevPaths, PagesEntrySourceGenerator, ServerGraphFile, PagesBundleBuilder };
1185
+ export { loaderFor, BarrelAnalyzer, createBarrelImportsPlugin, createTsconfigPackageResolver, rewriteBarrelImports, bundleConditions, bundleDefine, CsrEntryFiles, toClientReferencePath, scanUseClientExports, CsrDevPaths, PagesEntrySourceGenerator, ServerGraphFile, PagesBundleBuilder };
@@ -157,7 +157,7 @@ class SubagentPool2 {
157
157
  }
158
158
  }
159
159
  async#run(id, kind, prompt, signal) {
160
- const { CodeAgent } = await import("./CodeAgent-n2tkg59z.js");
160
+ const { CodeAgent } = await import("./CodeAgent-h6g8dg3a.js");
161
161
  const budget = this.#options.parent.tools.subagent;
162
162
  const child = SubagentPool2.childOf(this.#options.parent, kind);
163
163
  const model = this.#options.model?.();
@@ -1,12 +1,12 @@
1
1
  // @bun
2
2
  import {
3
3
  script
4
- } from "./index-9zy8479y.js";
4
+ } from "./index-93ewzmp6.js";
5
5
  import {
6
6
  AppExecutor,
7
7
  LibExecutor,
8
8
  ModuleExecutor
9
- } from "./index-g500c5j9.js";
9
+ } from "./index-sr5da35e.js";
10
10
  import {
11
11
  InteractionScaffold,
12
12
  workflowStatus,
@@ -45,10 +45,10 @@ import {
45
45
  addFieldUiPolicyForType,
46
46
  KeyRename,
47
47
  MutationScaffold
48
- } from "./index-m02tdq8a.js";
48
+ } from "./index-8pb9yvp8.js";
49
49
  import {
50
50
  ModuleScript
51
- } from "./index-gbp1q1b5.js";
51
+ } from "./index-8ts9774g.js";
52
52
 
53
53
  // pkgs/@akanjs/cli/primitive/primitive.script.ts
54
54
  import { capitalize, lowerlize } from "akanjs/common";
@@ -4,7 +4,7 @@ import {
4
4
  script,
5
5
  ExitCodeError,
6
6
  markCliErrorPrinted
7
- } from "./index-9zy8479y.js";
7
+ } from "./index-93ewzmp6.js";
8
8
  import {
9
9
  AGENT_BLOCK_START,
10
10
  AGENT_BLOCK_END,
@@ -15,7 +15,7 @@ import {
15
15
  CLAUDE_COMMENT_RULE,
16
16
  AppExecutor,
17
17
  LibExecutor
18
- } from "./index-g500c5j9.js";
18
+ } from "./index-sr5da35e.js";
19
19
  import {
20
20
  akanCodePaths2
21
21
  } from "./index-35j83zkd.js";
@@ -29,19 +29,19 @@ import {
29
29
  } from "./index-hj6w4ka1.js";
30
30
  import {
31
31
  AkanContextAnalyzer
32
- } from "./index-j9d3mjx1.js";
32
+ } from "./index-thckcabc.js";
33
33
  import {
34
34
  ApplicationRunner,
35
35
  VerifyScope
36
- } from "./index-ppvqy5bc.js";
36
+ } from "./index-ktb3wcqz.js";
37
37
  import {
38
38
  WorkspaceRunner
39
- } from "./index-sjabnf7j.js";
39
+ } from "./index-fjr4d6yd.js";
40
40
  import {
41
41
  VerifyComments,
42
42
  VerifyPipeline,
43
43
  VerifyReport
44
- } from "./index-eft5c2mp.js";
44
+ } from "./index-s2grpzef.js";
45
45
 
46
46
  // pkgs/@akanjs/cli/agent/agent.script.ts
47
47
  import { Logger as Logger3 } from "akanjs/common";
@@ -65,7 +65,7 @@ class AgentAssets {
65
65
  "akan-scaffold": ["workspaceRecipes"],
66
66
  "akan-module": ["moduleOverview", "modelConstant", "modelDictionary", "fieldRule"],
67
67
  "akan-scalar": ["scalarModule", "scalarConstant", "scalarDictionary"],
68
- "akan-service": ["modelService", "modelSignal", "modelDocument"],
68
+ "akan-service": ["modelService", "modelSignal", "modelDocument", "akanApi"],
69
69
  "akan-store": ["modelStore"],
70
70
  "akan-ui": [
71
71
  "ssrRule",
@@ -82,7 +82,7 @@ class AgentAssets {
82
82
  "akan-err": [],
83
83
  "akan-deps": [],
84
84
  "akan-debug": [],
85
- "akan-page": ["pageRule"],
85
+ "akan-page": ["pageRule", "akanApi"],
86
86
  "akan-query": ["queryRule"],
87
87
  "akan-transport": ["transportRule"],
88
88
  "akan-runtime": ["runtimeRule"],
@@ -6,25 +6,26 @@ import {
6
6
  CloudApi,
7
7
  CloudUpdates,
8
8
  PipelineSecrets
9
- } from "./index-gr9thy79.js";
9
+ } from "./index-drz9e84d.js";
10
10
  import {
11
11
  resolveMobileTargets
12
12
  } from "./index-m9jj544v.js";
13
13
  import {
14
14
  WorkspaceExecutor,
15
15
  AppExecutor
16
- } from "./index-g500c5j9.js";
16
+ } from "./index-sr5da35e.js";
17
17
  import {
18
18
  NativeApp
19
- } from "./index-sp0qsr7a.js";
19
+ } from "./index-zpv14wpy.js";
20
20
  import {
21
21
  runner,
22
22
  assertPromptable
23
- } from "./index-9zy8479y.js";
23
+ } from "./index-93ewzmp6.js";
24
24
  import {
25
25
  getNpmRegistryUrl,
26
+ getPublishedVersions,
26
27
  getLatestPackageVersion
27
- } from "./index-4am4dvmf.js";
28
+ } from "./index-ny2k80mv.js";
28
29
  import {
29
30
  SubspaceConfig
30
31
  } from "./index-h7hehkw6.js";
@@ -993,7 +994,7 @@ class CloudRunner extends runner("cloud") {
993
994
  }
994
995
  async login(host, workspace) {
995
996
  const cloudApi = await CloudApi.fromHost(workspace, host);
996
- const signedIn = await cloudApi.getRemoteSelf().catch(() => null);
997
+ const signedIn = cloudApi.needsSignIn ? null : await cloudApi.getRemoteSelf().catch(() => null);
997
998
  if (signedIn) {
998
999
  Logger3.rawLog(chalk3.green(`
999
1000
  \u2713 Already logged in akan cloud as ${signedIn.nickname}
@@ -1109,18 +1110,28 @@ ${run.format(results)}
1109
1110
  const isPrivate = await Promise.all(pkgs.map(async (pkg) => (await workspace.readJson(`pkgs/${pkg}/package.json`)).private));
1110
1111
  return pkgs.filter((_, idx) => isPrivate[idx] !== true);
1111
1112
  }
1112
- async deployAkan(workspace, akanPkgs, { registryUrl, confirmPublish = true, tag: distTag } = {}) {
1113
+ async deployAkan(workspace, akanPkgs, { registryUrl, confirmPublish = true, npmLogin = true, tag: distTag, prerelease, packTo } = {}) {
1114
+ if (prerelease != null && (prerelease === "latest" || !/^[a-z][a-z0-9-]*$/.test(prerelease)))
1115
+ throw new Error(`--prerelease takes a lowercase identifier other than latest, such as rc, not "${prerelease}"`);
1113
1116
  const registry = registryUrl ? getNpmRegistryUrl(registryUrl) : undefined;
1114
1117
  const akanPackageJson = await workspace.readJson("pkgs/akanjs/package.json");
1115
1118
  const [majorVersion, minorVersion, patchVersion, devPatchVersion] = akanPackageJson.version.split(".");
1116
- const isOfficialRelease = !devPatchVersion;
1117
- const targetVersionPrefix = isOfficialRelease ? `${majorVersion}.${minorVersion}` : `${majorVersion}.${minorVersion}.${patchVersion}`;
1118
- const tag = distTag ?? (isOfficialRelease ? "latest" : patchVersion.split("-").at(1) ?? "dev");
1119
- const latestPublishedVersion = await getLatestPackageVersion("akanjs", tag, registry).catch(() => null);
1120
- const latestPatch = latestPublishedVersion?.startsWith(targetVersionPrefix) ? parseInt(latestPublishedVersion.split(".").at(-1) ?? "-1") : -1;
1119
+ const releaseVersion = `${majorVersion}.${minorVersion}.${patchVersion.split("-")[0]}`;
1120
+ const isOfficialRelease = !devPatchVersion && !prerelease;
1121
+ const prereleasePrefix = prerelease ? `${releaseVersion}-${prerelease}` : `${majorVersion}.${minorVersion}.${patchVersion}`;
1122
+ const targetVersionPrefix = isOfficialRelease ? `${majorVersion}.${minorVersion}` : prereleasePrefix;
1123
+ const tag = distTag ?? (isOfficialRelease ? "latest" : prerelease ?? patchVersion.split("-").at(1) ?? "dev");
1124
+ const published = await Promise.all(akanPkgs.map((library) => getPublishedVersions(library, registry)));
1125
+ if (prerelease) {
1126
+ const released = published.flatMap((entry) => entry?.tags.latest ?? []).sort(Bun.semver.order).at(-1);
1127
+ if (released && Bun.semver.order(releaseVersion, released) <= 0)
1128
+ throw new Error(`akanjs ${released} is already released, so ${targetVersionPrefix}.N would sort below it; run \`changeset version\` first so the packages carry the next release`);
1129
+ }
1130
+ const latestPatch = Math.max(-1, ...published.flatMap((entry) => entry ? [...entry.versions, ...Object.values(entry.tags)] : []).filter((version) => version.startsWith(`${targetVersionPrefix}.`)).map((version) => version.slice(targetVersionPrefix.length + 1)).filter((patch) => /^\d+$/.test(patch)).map(Number));
1121
1131
  const nextVersion = `${targetVersionPrefix}.${latestPatch + 1}`;
1122
- Logger3.info(`Latest published version of akanjs: ${latestPublishedVersion ?? "none"}`);
1132
+ Logger3.info(`Highest published ${targetVersionPrefix}.N: ${latestPatch < 0 ? "none" : latestPatch}`);
1123
1133
  Logger3.info(`Next version of akanjs: ${nextVersion}`);
1134
+ const internalDependencies = new Map;
1124
1135
  for (const library of akanPkgs) {
1125
1136
  const packageJson = await workspace.readJson(`pkgs/${library}/package.json`);
1126
1137
  const newPackageJson = this.#normalizeAkanPackageJson(packageJson, library, nextVersion);
@@ -1128,6 +1139,12 @@ ${run.format(results)}
1128
1139
  const distPackageJson = await workspace.readJson(`dist/pkgs/${library}/package.json`);
1129
1140
  const newDistPackageJson = this.#normalizeAkanPackageJson(distPackageJson, library, nextVersion);
1130
1141
  await workspace.writeJson(`dist/pkgs/${library}/package.json`, newDistPackageJson);
1142
+ internalDependencies.set(library, Object.keys({ ...newDistPackageJson.dependencies, ...newDistPackageJson.peerDependencies }).filter((dep) => dep !== library && akanPkgs.includes(dep)));
1143
+ }
1144
+ const publishOrder = this.#dependenciesFirst(akanPkgs, internalDependencies);
1145
+ if (packTo) {
1146
+ await this.#packForPublish(workspace, publishOrder, { packTo, tag, version: nextVersion });
1147
+ return;
1131
1148
  }
1132
1149
  if (confirmPublish)
1133
1150
  assertPromptable(`Publishing ${akanPkgs.join(", ")}@${nextVersion} asks for a confirmation`, {
@@ -1137,12 +1154,12 @@ ${run.format(results)}
1137
1154
  Logger3.error("Deployment cancelled");
1138
1155
  return;
1139
1156
  }
1140
- if (!registry) {
1157
+ if (!registry && npmLogin) {
1141
1158
  Logger3.info("Logging in to npm...");
1142
1159
  await workspace.spawn("npm", ["login"], { stdio: "inherit" });
1143
1160
  Logger3.info("Logged in to npm");
1144
1161
  }
1145
- for (const library of akanPkgs) {
1162
+ for (const library of publishOrder) {
1146
1163
  Logger3.info(`Publishing ${library}@${nextVersion} to ${registry ?? "npm"}...`);
1147
1164
  await workspace.spawn("npm", ["publish", "--tag", tag, ...this.#getRegistryArgs(registry), ...this.#getLocalRegistryAuthArgs(registry)], {
1148
1165
  cwd: path8.join(workspace.workspaceRoot, "dist/pkgs", library),
@@ -1153,6 +1170,35 @@ ${run.format(results)}
1153
1170
  }
1154
1171
  Logger3.info(`All libraries are published to ${registry ?? "npm"}`);
1155
1172
  }
1173
+ #dependenciesFirst(libraries, dependencies) {
1174
+ const ordered = [];
1175
+ const visiting = new Set;
1176
+ const visit = (library) => {
1177
+ if (ordered.includes(library) || visiting.has(library))
1178
+ return;
1179
+ visiting.add(library);
1180
+ for (const dependency of dependencies.get(library) ?? [])
1181
+ visit(dependency);
1182
+ ordered.push(library);
1183
+ };
1184
+ for (const library of libraries)
1185
+ visit(library);
1186
+ return ordered;
1187
+ }
1188
+ async#packForPublish(workspace, libraries, { packTo, tag, version }) {
1189
+ const packDir = path8.resolve(workspace.workspaceRoot, packTo);
1190
+ await workspace.mkdir(packDir);
1191
+ const tarballs = [];
1192
+ for (const library of libraries) {
1193
+ const output = await workspace.spawn("npm", ["pack", "--json", "--pack-destination", packDir], {
1194
+ cwd: path8.join(workspace.workspaceRoot, "dist/pkgs", library)
1195
+ });
1196
+ const [{ filename }] = JSON.parse(output);
1197
+ tarballs.push(filename);
1198
+ }
1199
+ await workspace.writeJson(path8.join(packDir, "publish.json"), { version, tag, tarballs });
1200
+ Logger3.info(`Packed ${libraries.join(", ")}@${version} for \`npm publish --tag ${tag}\` into ${packDir}`);
1201
+ }
1156
1202
  async update(workspace, tag = "latest", { registryUrl } = {}) {
1157
1203
  const registry = registryUrl ? getNpmRegistryUrl(registryUrl) : undefined;
1158
1204
  const registryArgs = this.#getRegistryArgs(registry);