@akanjs/cli 3.1.1-rc.5 → 3.1.1-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-8hfzq1zs.js → CodeAgent-3sy7kjgj.js} +2 -2
  3. package/{CodeTui-kj6ng91g.js → CodeTui-rqxarxsn.js} +1 -1
  4. package/TunnelShare-q38dxrrr.js +14 -0
  5. package/{agent.command-2gay26y4.js → agent.command-ydftceda.js} +5 -5
  6. package/akanCode.js +2 -2
  7. package/{application.command-a3aepayy.js → application.command-fm2yn6hj.js} +9 -9
  8. package/{applicationBuildRunner-xye2sqrm.js → applicationBuildRunner-t2r84sz6.js} +72 -26
  9. package/buildBatch.proc.js +5 -5
  10. package/{cloud.command-10j4z1cy.js → cloud.command-ya0evzfq.js} +22 -17
  11. package/cloud.script-zg43jse2.js +24 -0
  12. package/{code.command-184jfjtk.js → code.command-719k3e9q.js} +6 -6
  13. package/{context.command-kx0kzz3t.js → context.command-c4t4z1vy.js} +16 -16
  14. package/context.runner-qb15sjf8.js +25 -0
  15. package/{guideline.command-72psmnpx.js → guideline.command-snh85ctf.js} +2 -2
  16. package/guidelines/agentRule/agentRule.instruction.md +5 -2
  17. package/guidelines/conventions/conventions.instruction.md +10 -7
  18. package/guidelines/pageRule/pageRule.instruction.md +8 -0
  19. package/guidelines/queryRule/queryRule.instruction.md +7 -0
  20. package/guidelines/runtimeRule/runtimeRule.instruction.md +12 -0
  21. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +2 -1
  22. package/incrementalBuilder.proc.js +3 -3
  23. package/{index-0fpeb7x7.js → index-0fz95kxe.js} +1 -1
  24. package/{index-sxqjxb4j.js → index-2xcc2ax5.js} +2 -2
  25. package/{index-md6026rp.js → index-31es1yev.js} +24 -2
  26. package/{index-azrhhgtb.js → index-3wypz6xj.js} +59 -8
  27. package/{index-kb51mayy.js → index-40brg4px.js} +3 -3
  28. package/{index-mtf0cx8t.js → index-42j4a8zq.js} +2 -2
  29. package/{index-qp73c26e.js → index-4vgbysa0.js} +3 -3
  30. package/{index-s28awecf.js → index-5max10jx.js} +536 -140
  31. package/{index-bxjacq5c.js → index-5phjb48k.js} +3 -3
  32. package/{index-5anqj3bm.js → index-74tjjsnc.js} +4 -4
  33. package/{index-v1gz5vja.js → index-8ap5z1n5.js} +1 -1
  34. package/{index-hqaa4y3y.js → index-8w76g4rm.js} +10 -10
  35. package/{index-q0e6604h.js → index-905qdgqp.js} +1 -1
  36. package/{index-0dnv1039.js → index-b70zct19.js} +7 -7
  37. package/{index-eyhqttvh.js → index-espk51ah.js} +2 -2
  38. package/{index-3wfw8jb8.js → index-hmt54t45.js} +4 -4
  39. package/{index-rvqk63qp.js → index-hqegmnb5.js} +56 -9
  40. package/{index-zz5731qs.js → index-j9vyj3dj.js} +3 -3
  41. package/{index-b2hkbyf0.js → index-jh72e64b.js} +44 -3
  42. package/{index-jn8gfj2b.js → index-pbtzb54h.js} +17 -15
  43. package/{index-yaz7yks8.js → index-pcwzkdqb.js} +1 -1
  44. package/{index-xhnw8n74.js → index-qd5km521.js} +4 -97
  45. package/{index-4q1amb3p.js → index-skk9zc1x.js} +2 -2
  46. package/{index-ggfjqpp4.js → index-vah0fgkr.js} +1 -1
  47. package/{index-trjhp735.js → index-wcej7g4z.js} +5 -5
  48. package/{index-4g6te8sa.js → index-xb8809yb.js} +2 -2
  49. package/{index-9z37veck.js → index-xjf5j657.js} +1 -1
  50. package/{index-hrc7q2e6.js → index-xy97mqgq.js} +35 -4
  51. package/{index-ssseyt0n.js → index-zrte51fn.js} +4 -4
  52. package/index.js +22 -22
  53. package/{library.command-tnxw0yb4.js → library.command-gycrwhf1.js} +3 -3
  54. package/{localRegistry.command-xw0c03g4.js → localRegistry.command-h924ek5g.js} +12 -12
  55. package/{module.command-8pjk6vmm.js → module.command-v6hgs1bc.js} +5 -5
  56. package/{package.command-b831nx2n.js → package.command-shzpcfph.js} +3 -3
  57. package/package.json +2 -2
  58. package/{page.command-earjccmn.js → page.command-ptxn5kqk.js} +3 -3
  59. package/{pipeline.command-yt8bq91c.js → pipeline.command-zz31pgax.js} +2 -2
  60. package/{primitive.command-8dw8ra1x.js → primitive.command-a1vse91z.js} +6 -6
  61. package/{projectTypecheck-btbw3nyf.js → projectTypecheck-2ztky9cf.js} +1 -1
  62. package/{quality.command-j2c4a2zg.js → quality.command-ah8qcakd.js} +2 -2
  63. package/{repair.command-7jv7bgc4.js → repair.command-cvazbz99.js} +5 -5
  64. package/{scalar.command-vwjk94zr.js → scalar.command-0acvyp26.js} +4 -4
  65. package/{subspace.command-fwzrs526.js → subspace.command-vem71tr5.js} +8 -8
  66. package/templates/app/tsconfig.json.template +2 -7
  67. package/templates/workspaceRoot/bunfig.toml.template +0 -4
  68. package/{tunnel.command-zm29dgkr.js → tunnel.command-vy08ecyp.js} +7 -7
  69. package/{workflow.command-nyjc1mxx.js → workflow.command-abb1d5xy.js} +10 -10
  70. package/{workspace.command-mkqtxg1x.js → workspace.command-fmgycnbr.js} +24 -24
  71. package/TunnelShare-ycmz33ve.js +0 -14
  72. package/cloud.script-qb9jfncf.js +0 -24
  73. package/context.runner-d7dhvbc7.js +0 -25
@@ -253,7 +253,8 @@ Declared in `akan.config.ts`, narrowed — never widened — by an env at boot;
253
253
  `ca-certificates` and `tzdata`.
254
254
  - **Native apps are the `native` section** (iOS, Android, desktop). A desktop app's carried server listens on a
255
255
  loopback port any local program can call — guard it as a network server — and ships `private/` and its env
256
- readable on the user's computer; read runtime files from `AKAN_APP_DIR`.
256
+ readable on the user's computer; read runtime files from `AKAN_APP_DIR`, and keep a secret the user gives it with
257
+ `NativeSecret` (the OS credential store), never in a file.
257
258
  - **`database: { modes: [...] }`** (`single`, `multiple`, `cluster`), chosen by `AKAN_DATABASE_MODE`; an app running
258
259
  in two modes avoids `q.raw`.
259
260
 
@@ -334,8 +335,9 @@ orchestration in `service`, client state in `store`; `Template` is forms, `Unit`
334
335
  `remove<Model>(id)`, and `pickAndWrite` writes through the save hooks (`queryRule`).
335
336
  - **`<model>.service.ts`** — a few lines: load → chain → `return await ….save()` (keep the `return await`). Side
336
337
  effects go in `override async _preUpdate` / `_postCreate`; fire-and-forget is `void`-ed. Load every referenced
337
- document, then save, then notify. Return `null` / `false` for not allowed or not found; the signal decides
338
- whether that is an error.
338
+ document, then save, then notify; writes that must land together go in `this.transaction(async () => …)` and
339
+ their notification in `this.afterCommit(…)` (`queryRule`). Return `null` / `false` for not allowed or not found;
340
+ the signal decides whether that is an error.
339
341
  - **`<model>.signal.ts`** — `XInternal` → `XSlice` → `XEndpoint`, all three even when empty; `exec` is a one-liner
340
342
  calling the service.
341
343
  - **`<model>.store.ts`** — custom actions only for a toast, an optimistic update, or a multi-field write:
@@ -395,9 +397,9 @@ orchestration in `service`, client state in `store`; `Template` is forms, `Unit`
395
397
  wrong JSON type, a value outside its enum or a missing required field answers 400 with `data.name` naming the
396
398
  path (`data.items.2.price`); a defaulted field may be left out, an undeclared key is dropped, and a stored model's
397
399
  input keeps an absent field absent.
398
- - **Reserved names**: generated CRUD (`create<Model>`, `update<Model>`, `remove<Model>`, …) exists for every model.
399
- The service layer reports a collision as a typecheck error, but a colliding signal name can pass sync, typecheck
400
- and build and fail at runtime — treat it as an error.
400
+ - **Reserved names**: generated CRUD (`create<Model>`, `update<Model>`, `remove<Model>`, …) exists for every model
401
+ whose slice mounts the verb. `fetch.*` is one namespace across modules and a pubsub or message is routed by its bare
402
+ name, so the server refuses to boot on two claims of one name (`[DI:fetch]`, `[DI:socket]`), naming both.
401
403
  - **Queries (`queryRule`)**: the root slice takes `queryKey` + `args`, never a raw query. A slice `exec` returns a
402
404
  `query<Filter>(…)` descriptor (never a `list<Filter>` array) and is paged through `initX(…, { sort, page, limit })`.
403
405
  A projection is bare on the facade (`pickById(id, { secret: true })`), under `select` on a filter accessor — the
@@ -415,7 +417,8 @@ orchestration in `service`, client state in `store`; `Template` is forms, `Unit`
415
417
  screen with `page().prompt(name, description)`, and publish one component a host draws with
416
418
  `page().app(name, description, load)` — a read-only tool whose `load` may only query.
417
419
  - **In-page agent (`agentRule`)**: mount `<Agent.Chat />` once in a layout; it never executes tools and refuses
418
- every call until `option.setAgentAccess(<guard>)`; the LLM is `option.setLlm({ apiKey, model, host })`, never env.
420
+ every call until `option.setAgentAccess(<guard>)`, which decides who — what a turn may ask is
421
+ `option.setAgentRequestPolicy`; the LLM is `option.setLlm({ apiKey, model, host })`, never env.
419
422
  The surface is what components declare — `st.tool(…).exec(fn)` beside its control, `st.use` / `st.sel` /
420
423
  `st.ref` keys — never a store class. `st.use.x({ agent: false })` hides a key; its model's `hidden` / `secret` /
421
424
  `visual` fields are stripped at read. A tool value is capped at 20,000 characters. Route guidance is
@@ -78,6 +78,14 @@ body shape — this is the full contract behind them. Before changing route beha
78
78
  - **A route guard is not authorization for data.** It keeps a person off a screen and redirects early; every query
79
79
  the screen makes is still judged by that endpoint's own `guards`. Write both: the signal guard is the gate, the
80
80
  route guard is the courtesy that answers before the screen draws.
81
+ - **Keeping a person on a page is `router.addNavigationGuard(guard)`, not `.guard()`.** `guard({ kind, from, to })`
82
+ is asked before every in-app move — `push`, `replace`, `back`, a `Link`, the browser's back and forward (`pop`), a
83
+ native back or swipe, the agent's `navigate` and `goBack` — with routes free of locale and basePath and `to: null`
84
+ for a `back`. `false`, a throw or a rejection keeps the page, `router.navigation()` rejects with
85
+ `NavigationRefused`, and a refused browser back is undone before the page redraws. Guards answer one at a time; a
86
+ move started while one decides is refused. Register it from an effect and return the remover
87
+ (`useEffect(() => router.addNavigationGuard(…), [isDirty])`). Redirects, `notFound()`, `setLang` and moves off the
88
+ origin are not asked; a closing tab is `beforeunload`'s.
81
89
 
82
90
  ## MCP Apps — `.app()`
83
91
 
@@ -120,6 +120,13 @@ this is the full contract behind them.
120
120
  still run — a nudge that re-sends a row its rooms must re-read, with no edit to stamp.
121
121
  - `upsertById(data, { preserveTimestamps })` writes a record whole under its own id, new or in place, with no
122
122
  hook: the write a sync or a backfill repeats safely, keeping the record's `createdAt`/`updatedAt` when asked.
123
+ - **Writes that must land together go in `this.transaction(async () => …)`**, which every service has: it commits
124
+ when the body resolves, returns its value, and rolls back when it throws, rethrowing that error unchanged. A
125
+ server has one database, so it covers every model, hooks and query-level writes included; a nested call joins the
126
+ outer one, with no savepoint. Cache, `memory` and outside calls are not in it — hand them to
127
+ `this.afterCommit(fn)`, run once the commit lands, never after a rollback, at once outside one; one that throws is
128
+ logged, never thrown, and the rest still run. On SQLite it holds the only write turn: keep it short.
129
+ `@Transaction()` is deprecated.
123
130
 
124
131
  ## Text Search In A Filter — `q.search()`
125
132
 
@@ -239,6 +239,10 @@ const config: AppConfig = { docker: "FROM oven/bun:1.4.4-slim\n…" }; // verbat
239
239
  `RUN if [ "$TARGETARCH" = "<arch>" ]` guard, so a multi-arch build runs it on one leg only. `preRuns` land
240
240
  before `bun install --production` (where a native dependency's build tools have to be), `postRuns` after it
241
241
  and before the app files are copied.
242
+ - **The image installs the versions the workspace locked.** `akan build` writes a `bun.lock` beside the image's
243
+ `package.json`, cut down from the workspace's to what the server needs, and the image installs it
244
+ `--frozen-lockfile`. A workspace without a root `bun.lock` gets a warning and an unlocked install; a Dockerfile
245
+ written whole copies `bun.lock` itself.
242
246
  - **A lib declares the steps its own runtime needs**, and every app that mounts it inherits them:
243
247
  `libs/<lib>/akan.config.ts` takes `docker: { preRuns, postRuns }` and nothing else — the base image and the
244
248
  command belong to the app. Lib steps are emitted before the app's own, and an identical step declared twice
@@ -513,6 +517,14 @@ The carried server asks the shell that showed the dialog over its IPC channel, s
513
517
  and nothing else, and no page ever holds a path. Behind a dev build `akan start` checks the grant's signature
514
518
  against a key in `~/.akan/native` instead, in `operationMode` local only; every other server refuses a grant.
515
519
 
520
+ **A secret the user gives the server is kept by the OS, never in a file.** `NativeSecret.set(key, value)`,
521
+ `get(key)` (null when none is kept) and `remove(key)` from `akanjs/server` reach the OS credential store through the
522
+ shell that carries the server — the macOS Keychain, the Windows Credential Manager, the Secret Service on Linux — in a
523
+ store of the server's own, apart from the page's `secretStorage`, so no page script reads it. Anywhere but a carried
524
+ server `NativeSecret.available` is false and every call rejects: keep secrets in the env there. On macOS without a
525
+ Team ID signature, any program of the same user can read the store's key through `security`, as with
526
+ `secretStorage`.
527
+
516
528
  **Devices belong to the shell, not the server.** Displays and their changes (`screen`), windows placed on them
517
529
  (`window`), the system volume and mute (`volume`), global shortcuts (`global-shortcut`), keep-awake (`keep-awake`)
518
530
  and launch at login (`autostart`) are native runtime plugins, each added to `native.plugins`. Every builtin plugin's
@@ -250,7 +250,8 @@ query-level writes are in `queryRule`; these are the shapes that build green and
250
250
  a `list<Filter>(...)` / `listBy...(...)` array. Returning an array type-checks but fails at runtime with
251
251
  `Unknown document field path: 0`. (See Recipe 3.)
252
252
  - **Custom endpoint names must not collide with generated CRUD.** `create/update/remove/view/edit/merge<Model>`
253
- already exist. A collision can build green and fail only at runtime — pick a distinct verb.
253
+ already exist wherever the slice mounts the verb. A collision builds green and the server refuses to boot
254
+ (`[DI:fetch]`) — pick a distinct verb.
254
255
  - **Numbers are `Int` or `Float`, never `Number`.** `field(Number)` / `.body("x", Number)` fail to typecheck.
255
256
  - **Array fields use `field([T])`** — `tags: field([String])`, `images: field([File])`.
256
257
  - **Reading a secret field needs an explicit select, and the two call sites spell it differently.**
@@ -8,7 +8,7 @@ import {
8
8
  CodegenLock,
9
9
  WorkspaceExecutor,
10
10
  AppExecutor
11
- } from "./index-trjhp735.js";
11
+ } from "./index-wcej7g4z.js";
12
12
  import"./index-52w0fvh8.js";
13
13
  import {
14
14
  GraphClientEntryDiscovery,
@@ -19,10 +19,10 @@ import {
19
19
  DevChangePlanner,
20
20
  DevGeneratedIndexSync,
21
21
  SsrDevBundler
22
- } from "./index-eyhqttvh.js";
22
+ } from "./index-espk51ah.js";
23
23
  import {
24
24
  ServerGraphFile
25
- } from "./index-0fpeb7x7.js";
25
+ } from "./index-0fz95kxe.js";
26
26
  import {
27
27
  prepareDevWatchBatch
28
28
  } from "./index-a5vmm6x4.js";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  AsyncDefaultExportDetector,
4
4
  resolveSsrPageEntriesForApp
5
- } from "./index-trjhp735.js";
5
+ } from "./index-wcej7g4z.js";
6
6
  import {
7
7
  FileSys2
8
8
  } from "./index-52w0fvh8.js";
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-azrhhgtb.js";
5
+ } from "./index-3wypz6xj.js";
6
6
  import {
7
7
  LibSource,
8
8
  formatLibStatuses,
9
9
  CommandExecutionError,
10
10
  LibExecutor
11
- } from "./index-trjhp735.js";
11
+ } from "./index-wcej7g4z.js";
12
12
 
13
13
  // pkgs/@akanjs/cli/library/library.script.ts
14
14
  import { Logger } from "akanjs/common";
@@ -10,7 +10,7 @@ import {
10
10
  isScannedRootEntry,
11
11
  AppExecutor,
12
12
  LibExecutor
13
- } from "./index-trjhp735.js";
13
+ } from "./index-wcej7g4z.js";
14
14
  import {
15
15
  FileSys2
16
16
  } from "./index-52w0fvh8.js";
@@ -23,7 +23,7 @@ import {
23
23
  workflowPathsForPlan,
24
24
  workflowRunArtifactPath,
25
25
  workflowSyncDir
26
- } from "./index-9z37veck.js";
26
+ } from "./index-xjf5j657.js";
27
27
 
28
28
  // pkgs/@akanjs/devkit/akanContext.ts
29
29
  import { readdir } from "fs/promises";
@@ -372,6 +372,25 @@ class AkanContextAnalyzer {
372
372
  hint
373
373
  };
374
374
  }
375
+ static async#configLeftovers(workspace, sysPaths) {
376
+ const leftovers = [];
377
+ for (const sysPath of sysPaths) {
378
+ const tsconfigPath = `${sysPath}/tsconfig.json`;
379
+ const tsconfig = await safeReadText(path.join(workspace.workspaceRoot, tsconfigPath));
380
+ if (tsconfig && (/"name"\s*:\s*"next"/.test(tsconfig) || tsconfig.includes(".next/types")))
381
+ leftovers.push({
382
+ path: tsconfigPath,
383
+ message: `${tsconfigPath} still names the Next.js TS plugin or .next/types, which Akan never uses \u2014 delete the "next" plugin entry and the ".next/types/**/*.ts" include.`
384
+ });
385
+ }
386
+ const bunfig = await safeReadText(path.join(workspace.workspaceRoot, "bunfig.toml"));
387
+ if (bunfig?.includes("bun-plugin-tailwind"))
388
+ leftovers.push({
389
+ path: "bunfig.toml",
390
+ message: "bunfig.toml still loads bun-plugin-tailwind, which is not installed and which Akan never uses (it compiles Tailwind itself) \u2014 delete the [serve.static] section, which Akan never reads."
391
+ });
392
+ return leftovers;
393
+ }
375
394
  static async doctor(workspace, {
376
395
  strict = false,
377
396
  runIdOrPlan = null,
@@ -415,6 +434,9 @@ class AkanContextAnalyzer {
415
434
  const agentDrift = await AkanContextAnalyzer.#agentGuideDrift(workspace);
416
435
  if (agentDrift)
417
436
  report({ severity: "warning", code: agentDrift.code, path: "AGENTS.md", message: agentDrift.message }, repairAction("generated", "akan agent install agents-md", agentDrift.hint, true));
437
+ const sysPaths = [...context.apps, ...context.libs].map((sys) => sys.path);
438
+ for (const leftover of await AkanContextAnalyzer.#configLeftovers(workspace, sysPaths))
439
+ diagnostics.push({ severity: "warning", code: "config-leftover", ...leftover });
418
440
  for (const sys of [...context.apps, ...context.libs]) {
419
441
  for (const module of sys.modules) {
420
442
  const moduleShapeCommand = `akan repair module-shape --app ${sys.name} --module ${module.name}`;
@@ -10,7 +10,7 @@ import {
10
10
  LibExecutor,
11
11
  PkgExecutor,
12
12
  ModuleExecutor
13
- } from "./index-trjhp735.js";
13
+ } from "./index-wcej7g4z.js";
14
14
 
15
15
  // pkgs/@akanjs/devkit/commandDecorators/camelToKebabCase.ts
16
16
  var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -60,7 +60,7 @@ var Pkg = createInternalArgToken("Pkg");
60
60
  var Module = createInternalArgToken("Module");
61
61
  var Workspace = createInternalArgToken("Workspace");
62
62
  // pkgs/@akanjs/devkit/commandDecorators/command.ts
63
- import path2 from "path";
63
+ import path3 from "path";
64
64
  import { Logger } from "akanjs/common";
65
65
  import chalk2 from "chalk";
66
66
  import { program } from "commander";
@@ -299,6 +299,59 @@ var formatCommandHelp = (command, key) => {
299
299
  `);
300
300
  };
301
301
 
302
+ // pkgs/@akanjs/devkit/commandDecorators/workspaceVersionCheck.ts
303
+ import { existsSync, readFileSync, realpathSync } from "fs";
304
+ import path2 from "path";
305
+
306
+ class WorkspaceVersionCheck {
307
+ static #exemptCommands = new Set(["update", "create-workspace"]);
308
+ static #infoFlags = new Set(["--help", "-h", "--version", "-V"]);
309
+ static #updateTags = new Set(["dev", "canary", "beta", "rc", "alpha"]);
310
+ static warning(cliVersion, argv, workspaceRoot) {
311
+ const args = argv.slice(2);
312
+ if (!cliVersion || WorkspaceVersionCheck.#exemptCommands.has(args[0] ?? ""))
313
+ return null;
314
+ if (args.some((arg) => WorkspaceVersionCheck.#infoFlags.has(arg)))
315
+ return null;
316
+ const installed = WorkspaceVersionCheck.installedAkanVersion(workspaceRoot);
317
+ if (!installed || installed === cliVersion)
318
+ return null;
319
+ const pinnedCli = WorkspaceVersionCheck.#versionAt(path2.join(workspaceRoot, "node_modules/@akanjs/cli"));
320
+ const runner = pinnedCli === installed ? ["bunx"] : ["bunx", "-p", `@akanjs/cli@${installed}`];
321
+ const rerun = [...runner, "akan", ...args].map(WorkspaceVersionCheck.#quote).join(" ");
322
+ const [, prerelease = ""] = cliVersion.split("-");
323
+ const tag = prerelease.split(".")[0];
324
+ const update = `akan update${WorkspaceVersionCheck.#updateTags.has(tag) ? ` --tag ${tag}` : ""}`;
325
+ const lines = [
326
+ `This akan is @akanjs/cli ${cliVersion}, but this workspace has akanjs ${installed}: what it generates may not match the installed framework.`,
327
+ `Run the matching CLI: ${rerun}`
328
+ ];
329
+ if (Bun.semver.order(cliVersion, installed) > 0)
330
+ lines.push(`Or move the workspace and this CLI to the newest release of the line together: ${update}`);
331
+ else if (pinnedCli !== installed)
332
+ lines.push(`Pin it so \`bunx akan\` runs it: bun add -d @akanjs/cli@${installed}`);
333
+ return lines.join(`
334
+ `);
335
+ }
336
+ static installedAkanVersion(workspaceRoot) {
337
+ const packageDir = path2.join(workspaceRoot, "node_modules", "akanjs");
338
+ if (!existsSync(packageDir))
339
+ return null;
340
+ if (!realpathSync(packageDir).split(path2.sep).includes("node_modules"))
341
+ return null;
342
+ return WorkspaceVersionCheck.#versionAt(packageDir);
343
+ }
344
+ static #versionAt(packageDir) {
345
+ const packageJsonPath = path2.join(packageDir, "package.json");
346
+ if (!existsSync(packageJsonPath))
347
+ return null;
348
+ return JSON.parse(readFileSync(packageJsonPath, "utf8")).version ?? null;
349
+ }
350
+ static #quote(arg) {
351
+ return /^[\w@%+=:,./-]+$/.test(arg) ? arg : `'${arg.replaceAll("'", `'\\''`)}'`;
352
+ }
353
+ }
354
+
302
355
  // pkgs/@akanjs/devkit/commandDecorators/command.ts
303
356
  var loggedCliErrorObjects = new WeakSet;
304
357
  var loggedCliErrorMessages = new Set;
@@ -607,7 +660,7 @@ var runCommands = async (...commands) => {
607
660
  process.exit(ExitCodeError.codeOf(error) ?? failureExitCode);
608
661
  });
609
662
  const __dirname2 = getDirname2(import.meta.url);
610
- const packageJsonCandidates = [`${path2.dirname(Bun.main)}/package.json`, `${__dirname2}/../package.json`];
663
+ const packageJsonCandidates = [`${path3.dirname(Bun.main)}/package.json`, `${__dirname2}/../package.json`];
611
664
  let cliPackageJson = null;
612
665
  for (const packageJsonPath of packageJsonCandidates) {
613
666
  if (!await FileSys2.fileExists(packageJsonPath))
@@ -627,12 +680,10 @@ var runCommands = async (...commands) => {
627
680
  program.version(process.env.AKAN_VERSION).description("Akan CLI").configureHelp({
628
681
  helpWidth: 100
629
682
  });
630
- const installedAkanPackageJson = await FileSys2.fileExists("./node_modules/akanjs/package.json") ? await FileSys2.readJson("./node_modules/akanjs/package.json") : null;
631
- if (installedAkanPackageJson && installedAkanPackageJson.version !== process.env.AKAN_VERSION) {
683
+ const versionWarning = WorkspaceVersionCheck.warning(cliPackageJson?.version, process.argv, process.cwd());
684
+ if (versionWarning)
632
685
  Logger.rawLog(chalk2.yellow(`
633
- Akan CLI version is mismatch with installed package. ${process.env.AKAN_VERSION} (global) vs ${installedAkanPackageJson.version} (akanjs)
634
- It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`), undefined, "error");
635
- }
686
+ ${versionWarning}`), undefined, "error");
636
687
  for (const command of commands) {
637
688
  const targetMetas = getTargetMetas(command);
638
689
  for (const targetMeta of targetMetas) {
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  resolveSsrPageEntriesForApp
4
- } from "./index-trjhp735.js";
4
+ } from "./index-wcej7g4z.js";
5
5
  import {
6
6
  computeRouteSeedIndex,
7
7
  saveRouteSeedIndex,
@@ -9,7 +9,7 @@ import {
9
9
  ClientEntriesBundler,
10
10
  VENDOR_SPECIFIERS,
11
11
  RouteClientBuilder
12
- } from "./index-eyhqttvh.js";
12
+ } from "./index-espk51ah.js";
13
13
  import {
14
14
  SOURCE_EXTS
15
15
  } from "./index-5nd1wtkv.js";
@@ -19,7 +19,7 @@ import {
19
19
  createTsconfigPackageResolver,
20
20
  rewriteBarrelImports,
21
21
  PagesBundleBuilder
22
- } from "./index-0fpeb7x7.js";
22
+ } from "./index-0fz95kxe.js";
23
23
  import {
24
24
  CssBlockParser
25
25
  } from "./index-62md4dwy.js";
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-azrhhgtb.js";
5
+ } from "./index-3wypz6xj.js";
6
6
  import {
7
7
  FileSys2
8
8
  } from "./index-52w0fvh8.js";
9
9
  import {
10
10
  PkgExecutor
11
- } from "./index-trjhp735.js";
11
+ } from "./index-wcej7g4z.js";
12
12
  import {
13
13
  TypeScriptDependencyScanner2
14
14
  } from "./index-tvehn2sp.js";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-azrhhgtb.js";
5
+ } from "./index-3wypz6xj.js";
6
6
  import {
7
7
  AGENT_BLOCK_START,
8
8
  AGENT_BLOCK_END,
@@ -13,14 +13,14 @@ import {
13
13
  CLAUDE_COMMENT_RULE,
14
14
  AppExecutor,
15
15
  LibExecutor
16
- } from "./index-trjhp735.js";
16
+ } from "./index-wcej7g4z.js";
17
17
  import {
18
18
  collectRecipeSources2,
19
19
  scanRecipes2
20
20
  } from "./index-hj6w4ka1.js";
21
21
  import {
22
22
  AkanContextAnalyzer
23
- } from "./index-md6026rp.js";
23
+ } from "./index-31es1yev.js";
24
24
  import {
25
25
  Prompter2
26
26
  } from "./index-zzvvc845.js";