@akanjs/cli 3.1.1-rc.8 → 3.1.1

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 (184) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-35wnb7w5.js +9 -0
  3. package/{CodeTui-rqxarxsn.js → CodeTui-h6yz2kvq.js} +1 -1
  4. package/TunnelShare-xyjpa7gx.js +14 -0
  5. package/agent.command-3r4jsck8.js +46 -0
  6. package/akanCode.js +10 -6
  7. package/{application.command-14xsthcr.js → application.command-g7xv6ad0.js} +46 -13
  8. package/{applicationBuildRunner-t2r84sz6.js → applicationBuildRunner-qvjnhr9j.js} +9 -6
  9. package/buildBatch.proc.js +6 -6
  10. package/{cloud.command-rmw1kcf1.js → cloud.command-6ebygmhw.js} +17 -15
  11. package/cloud.script-0s1jybd5.js +26 -0
  12. package/{code.command-719k3e9q.js → code.command-mpkm2emr.js} +6 -6
  13. package/commandManifest.json +1 -1
  14. package/{context.command-c4t4z1vy.js → context.command-svdh6b2w.js} +18 -17
  15. package/context.runner-ch0z3a8g.js +26 -0
  16. package/{devTui-q7k7bakd.js → devTui-evr3b35y.js} +1 -1
  17. package/{guideline.command-snh85ctf.js → guideline.command-qwp3tnjx.js} +3 -3
  18. package/guidelines/conventions/core.md +106 -0
  19. package/guidelines/conventions/rules/app.md +83 -0
  20. package/guidelines/conventions/rules/auth.md +45 -0
  21. package/guidelines/conventions/rules/config.md +56 -0
  22. package/guidelines/conventions/rules/constant.md +24 -0
  23. package/guidelines/conventions/rules/gates.md +31 -0
  24. package/guidelines/conventions/rules/layer.md +25 -0
  25. package/guidelines/conventions/rules/migration.md +27 -0
  26. package/guidelines/conventions/rules/module.md +90 -0
  27. package/guidelines/conventions/rules/page.md +56 -0
  28. package/guidelines/conventions/rules/sensitive.md +16 -0
  29. package/guidelines/conventions/rules/server.md +86 -0
  30. package/guidelines/conventions/rules/ssr.md +47 -0
  31. package/guidelines/conventions/rules/style.md +43 -0
  32. package/guidelines/conventions/rules/test.md +34 -0
  33. package/guidelines/conventions/rules/ts.md +95 -0
  34. package/guidelines/conventions/rules/tsx.md +75 -0
  35. package/guidelines/mcpRule/mcpRule.instruction.md +1 -1
  36. package/guidelines/pageRule/pageRule.instruction.md +4 -3
  37. package/guidelines/queryRule/queryRule.instruction.md +4 -0
  38. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +3 -3
  39. package/incrementalBuilder.proc.js +6 -6
  40. package/{index-pcwzkdqb.js → index-1p0qbq3m.js} +1 -1
  41. package/{index-xb8809yb.js → index-1shvxzt0.js} +3 -3
  42. package/{index-8w76g4rm.js → index-266dewjs.js} +11 -11
  43. package/{index-5max10jx.js → index-3yz30c07.js} +72 -53
  44. package/{index-xjf5j657.js → index-4mj92tsh.js} +952 -47
  45. package/index-4pdts00b.js +1604 -0
  46. package/{index-42j4a8zq.js → index-8559hsz4.js} +4 -3
  47. package/{index-wcej7g4z.js → index-8scw1pjk.js} +93 -23
  48. package/{index-5phjb48k.js → index-96wzdhfh.js} +74 -233
  49. package/index-9bv479q5.js +1 -0
  50. package/index-9rvcs76p.js +653 -0
  51. package/index-am36s3jh.js +3582 -0
  52. package/index-b8c289dx.js +444 -0
  53. package/{index-espk51ah.js → index-dd44g6vz.js} +3 -3
  54. package/{index-3wypz6xj.js → index-eja64h28.js} +7 -3
  55. package/index-fbewhg4g.js +590 -0
  56. package/index-jje9qzyq.js +27 -0
  57. package/{index-j9vyj3dj.js → index-k5jbcxyh.js} +3 -3
  58. package/{index-hmmv2cah.js → index-ksfgqq1x.js} +1 -1
  59. package/index-m5n3ka0p.js +18 -0
  60. package/{index-5nd1wtkv.js → index-p6x5b7hr.js} +1 -1
  61. package/{index-0p37cz91.js → index-payhwt51.js} +21 -29
  62. package/{index-myc22sgv.js → index-qkkdhjm6.js} +5 -4
  63. package/{index-74tjjsnc.js → index-qxzrp5xt.js} +33 -37
  64. package/{index-zrte51fn.js → index-r0k3ham2.js} +4 -4
  65. package/{index-hmt54t45.js → index-r2w2eh93.js} +4 -4
  66. package/index-r2wedvqn.js +138 -0
  67. package/{index-skk9zc1x.js → index-rnphv731.js} +2 -2
  68. package/{index-pa3c2mb8.js → index-s6da8ta9.js} +82 -1227
  69. package/index-tenw3mah.js +225 -0
  70. package/{index-31es1yev.js → index-tgt2fnd6.js} +107 -6
  71. package/{index-8ap5z1n5.js → index-vxmy1p4f.js} +16 -36
  72. package/{index-mdqr41sp.js → index-w4k2ragk.js} +7 -7
  73. package/{index-qd5km521.js → index-w7q6h97v.js} +1 -1
  74. package/{index-dy0jx9ay.js → index-wwe9rsrx.js} +14 -0
  75. package/{index-2xcc2ax5.js → index-xq543a5y.js} +2 -2
  76. package/{index-0fz95kxe.js → index-xqgwjz7a.js} +1 -1
  77. package/{index-40brg4px.js → index-xxfy1jp2.js} +4 -4
  78. package/{index-905qdgqp.js → index-z4b84y6k.js} +1 -1
  79. package/index-zcf6k8a5.js +410 -0
  80. package/index.js +23 -22
  81. package/{library.command-gycrwhf1.js → library.command-2853y6mk.js} +3 -3
  82. package/{localRegistry.command-2t3fghje.js → localRegistry.command-76ds31p4.js} +19 -15
  83. package/{module.command-v6hgs1bc.js → module.command-yfnb0abs.js} +5 -5
  84. package/{package.command-shzpcfph.js → package.command-d9s86hp9.js} +3 -3
  85. package/package.json +2 -2
  86. package/{page.command-ptxn5kqk.js → page.command-6a8a8rd1.js} +3 -3
  87. package/{pipeline.command-zz31pgax.js → pipeline.command-rt3rwd2z.js} +2 -2
  88. package/{primitive.command-a1vse91z.js → primitive.command-emcebgrq.js} +6 -6
  89. package/{projectTypecheck-2ztky9cf.js → projectTypecheck-51m7eh1f.js} +1 -1
  90. package/{prompter-76k56b37.js → prompter-hgcta8pb.js} +1 -1
  91. package/quality.command-xtrk0n3x.js +76 -0
  92. package/{repair.command-cvazbz99.js → repair.command-51szxnxx.js} +5 -5
  93. package/{routeSourceValidator-6jd0q6r6.js → routeSourceValidator-4h947v7c.js} +13 -3
  94. package/{scalar.command-0acvyp26.js → scalar.command-8qv27t82.js} +4 -4
  95. package/skills/akan-agent/SKILL.md +36 -0
  96. package/skills/akan-code/SKILL.md +1 -0
  97. package/skills/akan-debug/SKILL.md +40 -6
  98. package/skills/akan-deps/SKILL.md +1 -2
  99. package/skills/akan-mcp/SKILL.md +40 -0
  100. package/skills/akan-page/SKILL.md +44 -0
  101. package/skills/akan-query/SKILL.md +38 -0
  102. package/skills/akan-runtime/SKILL.md +40 -0
  103. package/skills/akan-scaffold/SKILL.md +16 -6
  104. package/skills/akan-transport/SKILL.md +40 -0
  105. package/skills/akan-validate/SKILL.md +13 -11
  106. package/{subspace.command-kvxmyxtf.js → subspace.command-pn56pnh8.js} +8 -8
  107. package/templates/__scalar/__model__/__model__.constant.ts +3 -5
  108. package/templates/__scalar/__model__/__model__.dictionary.ts +6 -5
  109. package/templates/__scalar/__model__/__model__.document.ts +3 -3
  110. package/templates/app/akan.config.ts +2 -3
  111. package/templates/app/env/env.client.ts +2 -4
  112. package/templates/app/env/env.client.type.ts +2 -3
  113. package/templates/app/env/env.server.ts +2 -3
  114. package/templates/app/lib/___appName__/__appName__.dictionary.ts +1 -2
  115. package/templates/app/lib/___appName__/__appName__.service.ts +3 -3
  116. package/templates/app/lib/___appName__/__appName__.signal.ts +5 -5
  117. package/templates/app/lib/___appName__/__appName__.store.ts +4 -6
  118. package/templates/app/lib/option.ts +2 -3
  119. package/templates/app/main.ts +2 -4
  120. package/templates/app/page/_index.tsx +3 -3
  121. package/templates/app/page/_layout.tsx +13 -10
  122. package/templates/appSample/lib/__scalar/workHistory/workHistory.constant.ts +1 -5
  123. package/templates/appSample/lib/__scalar/workHistory/workHistory.dictionary.ts +1 -1
  124. package/templates/appSample/lib/_noti/noti.signal.ts +1 -1
  125. package/templates/appSample/lib/task/Task.Template.tsx +2 -1
  126. package/templates/appSample/lib/task/Task.Unit.tsx +3 -2
  127. package/templates/appSample/lib/task/Task.Util.tsx +16 -4
  128. package/templates/appSample/lib/task/task.constant.ts +1 -5
  129. package/templates/appSample/lib/task/task.dictionary.ts +2 -8
  130. package/templates/appSample/lib/task/task.document.ts +1 -1
  131. package/templates/appSample/page/task/_index.tsx +2 -1
  132. package/templates/appSample/page/task/new.tsx +2 -1
  133. package/templates/appSample/ui/QuantityControl.tsx +5 -9
  134. package/templates/biomeForm.ts +144 -0
  135. package/templates/crudPages/[__model__Id]/edit/page.tsx +3 -3
  136. package/templates/crudPages/[__model__Id]/page.tsx +5 -5
  137. package/templates/crudPages/new/page.tsx +4 -3
  138. package/templates/crudPages/page.tsx +3 -3
  139. package/templates/crudSinglePage/page.tsx +9 -5
  140. package/templates/libRoot/akan.config.ts +2 -3
  141. package/templates/libRoot/lib/___libName__/__libName__.dictionary.ts +1 -2
  142. package/templates/libRoot/lib/___libName__/__libName__.service.ts +5 -4
  143. package/templates/libRoot/lib/___libName__/__libName__.signal.ts +6 -5
  144. package/templates/libRoot/lib/___libName__/__libName__.store.ts +5 -6
  145. package/templates/libRoot/lib/option.ts +1 -2
  146. package/templates/module/__Model__.Template.tsx +11 -10
  147. package/templates/module/__Model__.Unit.tsx +18 -5
  148. package/templates/module/__Model__.Util.tsx +9 -7
  149. package/templates/module/__Model__.View.tsx +9 -6
  150. package/templates/module/__Model__.Zone.tsx +25 -17
  151. package/templates/module/__model__.constant.ts +8 -9
  152. package/templates/module/__model__.dictionary.ts +16 -17
  153. package/templates/module/__model__.document.ts +6 -8
  154. package/templates/module/__model__.service.ts +3 -3
  155. package/templates/module/__model__.signal.ts +11 -10
  156. package/templates/module/__model__.store.ts +3 -5
  157. package/templates/service/__model__.dictionary.ts +6 -5
  158. package/templates/service/__model__.service.ts +3 -3
  159. package/templates/service/__model__.signal.ts +5 -4
  160. package/templates/service/__model__.store.ts +3 -5
  161. package/templates/workspaceRoot/.gitignore.template +3 -0
  162. package/templates/workspaceRoot/.vscode/settings.json.template +21 -21
  163. package/templates/workspaceRoot/AGENTS.md.template +4 -10
  164. package/{tunnel.command-kxv0ddmp.js → tunnel.command-q2h0j2en.js} +7 -7
  165. package/{typeChecker-px49mezc.js → typeChecker-j2jdnqsr.js} +1 -1
  166. package/typecheck.proc.js +6 -1
  167. package/verify.command-z1dsbmrt.js +91 -0
  168. package/{workflow.command-abb1d5xy.js → workflow.command-r3y67jeq.js} +47 -13
  169. package/workspace.command-t2f0xsrw.js +263 -0
  170. package/CodeAgent-3sy7kjgj.js +0 -9
  171. package/TunnelShare-2ef94kha.js +0 -14
  172. package/agent.command-ydftceda.js +0 -25
  173. package/cloud.script-v1ysyerg.js +0 -24
  174. package/context.runner-qb15sjf8.js +0 -25
  175. package/guidelines/conventions/conventions.instruction.md +0 -617
  176. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +0 -291
  177. package/index-4vgbysa0.js +0 -279
  178. package/index-7md2g9vw.js +0 -6
  179. package/index-b70zct19.js +0 -856
  180. package/index-zzvvc845.js +0 -74
  181. package/quality.command-ah8qcakd.js +0 -1478
  182. package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +0 -69
  183. package/templates/workspaceRoot/docs/GENERATED.md.template +0 -55
  184. package/workspace.command-tsc99yec.js +0 -521
@@ -6,44 +6,32 @@ import {
6
6
  CloudApi,
7
7
  CloudUpdates,
8
8
  PipelineSecrets
9
- } from "./index-myc22sgv.js";
9
+ } from "./index-qkkdhjm6.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-wcej7g4z.js";
16
+ } from "./index-8scw1pjk.js";
17
17
  import {
18
18
  NativeApp
19
- } from "./index-5max10jx.js";
19
+ } from "./index-3yz30c07.js";
20
20
  import {
21
21
  runner,
22
22
  assertPromptable
23
- } from "./index-3wypz6xj.js";
23
+ } from "./index-eja64h28.js";
24
24
  import {
25
25
  SubspaceConfig
26
26
  } from "./index-4pf8g7ff.js";
27
+ import {
28
+ getNpmRegistryUrl,
29
+ getLatestPackageVersion
30
+ } from "./index-m5n3ka0p.js";
27
31
  import {
28
32
  openBrowser
29
33
  } from "./index-9dp031by.js";
30
34
 
31
- // pkgs/@akanjs/cli/npmRegistry.ts
32
- var defaultNpmRegistry = "https://registry.npmjs.org";
33
- var getNpmRegistryUrl = (registryUrl = process.env.AKAN_NPM_REGISTRY ?? defaultNpmRegistry) => registryUrl.replace(/\/+$/, "");
34
- async function getLatestPackageVersion(packageName, tag = "latest", registryUrl) {
35
- const registry = getNpmRegistryUrl(registryUrl);
36
- const url = `${registry}/${encodeURIComponent(packageName).replace(/^%40/, "@")}`;
37
- const res = await fetch(url);
38
- if (!res.ok)
39
- throw new Error(`Failed to fetch ${packageName} metadata from ${registry}`);
40
- const metadata = await res.json();
41
- const version = metadata["dist-tags"]?.[tag];
42
- if (!version)
43
- throw new Error(`No npm dist-tag "${tag}" found for ${packageName}`);
44
- return version;
45
- }
46
-
47
35
  // pkgs/@akanjs/cli/cloud/cloud.runner.ts
48
36
  import path7 from "path";
49
37
 
@@ -294,6 +282,7 @@ class LinuxDockerTarget extends PlatformTestTarget {
294
282
  "run",
295
283
  "-d",
296
284
  "--rm",
285
+ "--init",
297
286
  "--name",
298
287
  container,
299
288
  "--cpus",
@@ -743,7 +732,7 @@ ${chalk2.green("\u27A4")} Authentication Required`));
743
732
  }
744
733
  Logger.rawLog(`
745
734
  ${chalk2.bold("Your code:")} ${chalk2.bold.inverse(` ${await RemoteAuthCode.of(remoteId)} `)}`);
746
- Logger.rawLog(chalk2.dim(`Enter this code on the sign-in page, and approve only if it matches what this terminal shows.
735
+ Logger.rawLog(chalk2.dim(`Enter this code on the sign-in page. Never enter a code that did not come from your own terminal.
747
736
  `));
748
737
  }
749
738
  async#awaitApproval(remoteId, loginId) {
@@ -778,17 +767,20 @@ ${chalk2.bold("Your code:")} ${chalk2.bold.inverse(` ${await RemoteAuthCode.of(r
778
767
  async#readSelf() {
779
768
  let reason = "";
780
769
  for (let attempt = 1;attempt <= this.#selfAttempts; attempt++) {
770
+ let self;
781
771
  try {
782
- const self = await this.#api.getRemoteSelf();
783
- if (self)
784
- return self;
785
- reason = "the server did not take the new session";
786
- break;
772
+ self = await this.#api.getRemoteSelf();
787
773
  } catch (error) {
788
774
  reason = RemoteLogin.#reasonOf(error);
775
+ if (attempt < this.#selfAttempts)
776
+ await this.#wait(Backoff.delay(attempt, { min: 1000, max: 8000 }));
777
+ continue;
789
778
  }
790
- if (attempt < this.#selfAttempts)
791
- await this.#wait(Backoff.delay(attempt, { min: 1000, max: 8000 }));
779
+ if (self)
780
+ return self;
781
+ const { host } = this.#api;
782
+ await GlobalConfig.setHostConfig(getDefaultHostConfig(host));
783
+ throw new Error(chalk2.red(`\u2716 ${host} did not take the session it handed out. Run akan login again.`));
792
784
  }
793
785
  Logger.rawLog(chalk2.yellow(`Could not read the signed-in account (${reason}).`));
794
786
  return null;
@@ -1323,4 +1315,4 @@ ${run.format(results)}
1323
1315
  }
1324
1316
  }
1325
1317
 
1326
- export { getNpmRegistryUrl, getLatestPackageVersion, PlatformTestRun, CloudRunner };
1318
+ export { PlatformTestRun, CloudRunner };
@@ -9,10 +9,10 @@ import {
9
9
  UpdatePackFolder,
10
10
  NativePublicEnv,
11
11
  NativeApp
12
- } from "./index-5max10jx.js";
12
+ } from "./index-3yz30c07.js";
13
13
  import {
14
14
  ExitCodeError
15
- } from "./index-3wypz6xj.js";
15
+ } from "./index-eja64h28.js";
16
16
  import {
17
17
  ConfigLock
18
18
  } from "./index-bqbf654f.js";
@@ -583,8 +583,9 @@ ${(release.problems ?? []).map((problem) => ` - ${problem}`).join(`
583
583
  if (record.status === "rejected")
584
584
  throw new ExitCodeError(`The project rejected ${label}:
585
585
  ${problems}`, 2);
586
- const manifestUrl = typeof record.manifestUrl === "string" ? record.manifestUrl : `${url}/${platform}-${arch}/${channel}.json`;
587
- const what = `${label} (${release.manifest.bundle}, ${release.payloads.length + 3} files)`;
586
+ const manifestUrl = typeof record.manifestUrl === "string" ? record.manifestUrl : `${url}/${platform}-${arch}/${channel}/app.json`;
587
+ const files = 1 + release.manifestFiles.length + release.payloads.length;
588
+ const what = `${label} (${release.manifest.bundle}, ${files} files)`;
588
589
  Logger3.rawLog(record.status === "published" ? `Published ${what}. Installed apps read ${manifestUrl}.` : `Staged ${what}. Publish it from the project's release screen; installed apps read ${manifestUrl}.`);
589
590
  if (problems)
590
591
  Logger3.rawLog(`The project noted:
@@ -1,13 +1,14 @@
1
1
  // @bun
2
2
  import {
3
3
  script
4
- } from "./index-3wypz6xj.js";
4
+ } from "./index-eja64h28.js";
5
5
  import {
6
6
  AppExecutor,
7
7
  LibExecutor,
8
8
  ModuleExecutor
9
- } from "./index-wcej7g4z.js";
9
+ } from "./index-8scw1pjk.js";
10
10
  import {
11
+ InteractionScaffold,
11
12
  workflowStatus,
12
13
  compactDiagnostics,
13
14
  sourceFile,
@@ -40,11 +41,12 @@ import {
40
41
  insertClassMethod,
41
42
  hasSignalFactoryEntry,
42
43
  insertSignalFactoryEntry,
43
- addFieldUiPolicyForType
44
- } from "./index-xjf5j657.js";
44
+ addFieldUiPolicyForType,
45
+ MutationScaffold
46
+ } from "./index-4mj92tsh.js";
45
47
  import {
46
48
  ModuleScript
47
- } from "./index-hmt54t45.js";
49
+ } from "./index-r2w2eh93.js";
48
50
 
49
51
  // pkgs/@akanjs/cli/primitive/primitive.script.ts
50
52
  import { capitalize, lowerlize } from "akanjs/common";
@@ -269,38 +271,22 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
269
271
  return PrimitiveScript.#report(command, sys, changedFiles, diagnostics);
270
272
  }
271
273
  async addMutation(workspace, input) {
272
- const moduleClassName = input.module ? moduleComponentName(input.module) : "";
273
- const serviceRef = lowerlize(moduleClassName);
274
- const name = input.mutation;
275
- return await this.#writeServiceSignalEntry(workspace, {
276
- command: "add-mutation",
277
- app: input.app,
278
- module: input.module,
279
- entryKind: "mutation",
280
- entryName: name,
281
- requiredInput: "mutation",
282
- serviceMethod: name ? {
283
- name,
284
- block: [
285
- ` async ${name}() {`,
286
- ` // TODO(service): implement ${moduleClassName}Service.${name}`,
287
- ` return true;`,
288
- ` }`
289
- ].join(`
290
- `)
291
- } : null,
292
- signal: name ? {
293
- className: `${moduleClassName}Endpoint`,
294
- entryLine: [
295
- `${name}: mutation(Boolean, { guards: [None] })`,
296
- ` .exec(async function () {`,
297
- ` return await this.${serviceRef}Service.${name}();`,
298
- ` }),`
299
- ].join(`
300
- `),
301
- param: { mode: "destructure", name: "mutation" }
302
- } : null
303
- });
274
+ const sys = await this.resolveSys(workspace, input.app);
275
+ if (!sys || !input.module || !input.mutation)
276
+ return PrimitiveScript.#refuse("add-mutation", compactDiagnostics([
277
+ !sys && PrimitiveScript.#targetMissing(),
278
+ !input.module && PrimitiveScript.#inputMissing("module"),
279
+ !input.mutation && PrimitiveScript.#inputMissing("mutation", "Mutation name is required.")
280
+ ]));
281
+ const { diagnostics, files } = await MutationScaffold.build(sys, input);
282
+ return await PrimitiveScript.#writeScaffold("add-mutation", sys, files, diagnostics);
283
+ }
284
+ async createInteraction(workspace, input) {
285
+ const sys = await this.resolveSys(workspace, input.app);
286
+ if (!sys)
287
+ return PrimitiveScript.#refuse("create-interaction", [PrimitiveScript.#targetMissing()]);
288
+ const { diagnostics, files } = await InteractionScaffold.build(sys, input.interaction);
289
+ return await PrimitiveScript.#writeScaffold("create-interaction", sys, files, diagnostics);
304
290
  }
305
291
  async addSlice(workspace, input) {
306
292
  const moduleClassName = input.module ? moduleComponentName(input.module) : "";
@@ -423,6 +409,16 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
423
409
  }
424
410
  return PrimitiveScript.#report(spec.command, sys, changedFiles, diagnostics);
425
411
  }
412
+ static async#writeScaffold(command, sys, files, diagnostics) {
413
+ const changedFiles = [];
414
+ if (workflowStatus(diagnostics) === "passed") {
415
+ for (const file of files) {
416
+ await sys.writeFile(file.path, file.content, { silent: true });
417
+ changedFiles.push(sourceFile(sys, file.path, file.action, file.reason));
418
+ }
419
+ }
420
+ return PrimitiveScript.#report(command, sys, changedFiles, diagnostics);
421
+ }
426
422
  static #refuse(command, diagnostics) {
427
423
  return createPrimitiveWriteReport({
428
424
  command,
@@ -1,16 +1,16 @@
1
1
  // @bun
2
2
  import {
3
3
  jsonText
4
- } from "./index-xjf5j657.js";
4
+ } from "./index-4mj92tsh.js";
5
5
  import {
6
6
  akanMcpInstallTargets
7
- } from "./index-31es1yev.js";
7
+ } from "./index-tgt2fnd6.js";
8
8
  import {
9
9
  script
10
- } from "./index-3wypz6xj.js";
10
+ } from "./index-eja64h28.js";
11
11
  import {
12
12
  ContextRunner2
13
- } from "./index-8w76g4rm.js";
13
+ } from "./index-266dewjs.js";
14
14
 
15
15
  // pkgs/@akanjs/cli/context/context.script.ts
16
16
  import { Logger } from "akanjs/common";
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-3wypz6xj.js";
5
+ } from "./index-eja64h28.js";
6
6
  import {
7
7
  ModuleExecutor
8
- } from "./index-wcej7g4z.js";
8
+ } from "./index-8scw1pjk.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-xjf5j657.js";
16
+ } from "./index-4mj92tsh.js";
17
17
  import {
18
18
  PageScript
19
- } from "./index-905qdgqp.js";
19
+ } from "./index-z4b84y6k.js";
20
20
  import {
21
21
  pluralizeName
22
22
  } from "./index-nz8prx9g.js";
@@ -0,0 +1,138 @@
1
+ // @bun
2
+ import {
3
+ getDirname2
4
+ } from "./index-52w0fvh8.js";
5
+
6
+ // pkgs/@akanjs/devkit/conventionSet.ts
7
+ import fsPromise from "fs/promises";
8
+ import path from "path";
9
+
10
+ class ConventionSet {
11
+ core;
12
+ rules;
13
+ constructor(core, rules) {
14
+ this.core = core;
15
+ this.rules = rules;
16
+ }
17
+ static async load(dir) {
18
+ const core = await fsPromise.readFile(path.join(dir, "core.md"), "utf-8");
19
+ const files = (await fsPromise.readdir(path.join(dir, "rules"))).filter((file) => file.endsWith(".md")).sort();
20
+ const rules = await Promise.all(files.map(async (file) => ConventionSet.parseRule(file.slice(0, -3), await fsPromise.readFile(path.join(dir, "rules", file), "utf-8"))));
21
+ return new ConventionSet(core.trim(), rules);
22
+ }
23
+ static parseRule(name, text) {
24
+ const match = /^---\n([\s\S]*?)\n---\n/.exec(text);
25
+ if (!match)
26
+ throw new Error(`Convention rule ${name} has no frontmatter`);
27
+ const front = match[1] ?? "";
28
+ const described = /^description:\s*(.+)$/m.exec(front);
29
+ const description = described?.[1]?.trim() ?? "";
30
+ const paths = [...front.matchAll(/^\s+-\s+"([^"]+)"$/gm)].map((entry) => entry[1] ?? "");
31
+ if (!description || paths.length === 0)
32
+ throw new Error(`Convention rule ${name} needs a description and paths`);
33
+ return { name, description, paths, body: text.slice(match[0].length).trim() };
34
+ }
35
+ static expand(glob) {
36
+ const open = glob.indexOf("{");
37
+ if (open === -1)
38
+ return [glob];
39
+ const close = glob.indexOf("}", open);
40
+ if (close === -1)
41
+ return [glob];
42
+ const head = glob.slice(0, open);
43
+ const tail = glob.slice(close + 1);
44
+ return glob.slice(open + 1, close).split(",").flatMap((choice) => ConventionSet.expand(`${head}${choice}${tail}`));
45
+ }
46
+ static demote(markdown) {
47
+ let fenced = false;
48
+ return markdown.split(`
49
+ `).map((line) => {
50
+ if (line.startsWith("```"))
51
+ fenced = !fenced;
52
+ return !fenced && /^#{1,5} /.test(line) ? `#${line}` : line;
53
+ }).join(`
54
+ `);
55
+ }
56
+ get instruction() {
57
+ return `${[this.core, ...this.rules.map((rule) => ConventionSet.demote(rule.body))].join(`
58
+
59
+ `)}
60
+ `;
61
+ }
62
+ }
63
+
64
+ // pkgs/@akanjs/devkit/prompter.ts
65
+ import fsPromise2 from "fs/promises";
66
+ import { input, select } from "@inquirer/prompts";
67
+ class Prompter2 {
68
+ static async#getGuidelineRoot() {
69
+ const dirname = getDirname2(import.meta.url);
70
+ const candidates = [`${dirname}/guidelines`, `${dirname}/../cli/guidelines`];
71
+ for (const candidate of candidates) {
72
+ try {
73
+ await fsPromise2.access(candidate);
74
+ return candidate;
75
+ } catch {}
76
+ }
77
+ return candidates[0];
78
+ }
79
+ static async selectGuideline() {
80
+ const guideNames = await Prompter2.listGuidelines();
81
+ return await select({
82
+ message: "Select a guideline",
83
+ choices: guideNames.map((name) => ({ name, value: name }))
84
+ });
85
+ }
86
+ static async listGuidelines() {
87
+ const guidelineRoot = await Prompter2.#getGuidelineRoot();
88
+ return (await fsPromise2.readdir(guidelineRoot)).filter((name) => !name.startsWith("_")).sort();
89
+ }
90
+ static async getInstruction(guideName) {
91
+ const guideNames = await Prompter2.listGuidelines();
92
+ if (!guideNames.includes(guideName))
93
+ throw new Error(`Unknown guideline "${guideName}". Available: ${guideNames.join(", ")}`);
94
+ const guidelineRoot = await Prompter2.#getGuidelineRoot();
95
+ const composed = `${guidelineRoot}/${guideName}/core.md`;
96
+ if (await Bun.file(composed).exists())
97
+ return (await ConventionSet.load(`${guidelineRoot}/${guideName}`)).instruction;
98
+ return await fsPromise2.readFile(`${guidelineRoot}/${guideName}/${guideName}.instruction.md`, "utf-8");
99
+ }
100
+ static async getConventionSet() {
101
+ return await ConventionSet.load(`${await Prompter2.#getGuidelineRoot()}/conventions`);
102
+ }
103
+ static async getUpdateRequest(guideName) {
104
+ return await input({
105
+ message: `What do you want to update in ${guideName}?`
106
+ });
107
+ }
108
+ async makeTsFileUpdatePrompt({ context, request }) {
109
+ return `You are a senior developer writing TypeScript-based programs using Akan.js, an in-house framework. Here's an overview of the Akan.js framework:
110
+ ${await this.getDocumentation("framework")}
111
+ Please understand the following background information, write code that meets the requirements, verify that it satisfies the validation conditions, and return the result.
112
+
113
+ # Code Style
114
+ - Use double quotes for all string literals in TypeScript/TSX code. Do not use single quotes.
115
+
116
+ # Background Information
117
+ \`\`\`markdown
118
+ ${context}
119
+ \`\`\`
120
+
121
+ # Requirements
122
+ \`\`\`markdown
123
+ ${request}
124
+ \`\`\`
125
+ `;
126
+ }
127
+ async getDocumentation(guideName) {
128
+ const guidelineRoot = await Prompter2.#getGuidelineRoot();
129
+ const filePath = `${guidelineRoot}/${guideName}/${guideName}.instruction.md`;
130
+ const document = await fsPromise2.readFile(filePath, "utf-8");
131
+ return `\`\`\`markdown
132
+ ${document}
133
+ \`\`\`
134
+ `;
135
+ }
136
+ }
137
+
138
+ export { ConventionSet, Prompter2 };
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-3wypz6xj.js";
5
+ } from "./index-eja64h28.js";
6
6
  import {
7
7
  generatedFilesForSync,
8
8
  createPassedPrimitiveReport,
9
9
  scalarChangedFiles
10
- } from "./index-xjf5j657.js";
10
+ } from "./index-4mj92tsh.js";
11
11
  import {
12
12
  pluralizeName
13
13
  } from "./index-nz8prx9g.js";