@akanjs/cli 3.1.1-rc.9 → 3.1.2-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 (207) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-dyc45f5w.js +11 -0
  3. package/{CodeAgentRpcHost-9g27hmer.js → CodeAgentRpcHost-6dzfkvsc.js} +1 -1
  4. package/CodeAgentRpcListener-tcwrdvst.js +182 -0
  5. package/{CodeTui-z5vkm9ea.js → CodeTui-q55b2zrn.js} +25 -8
  6. package/TunnelShare-hdq9h1hr.js +14 -0
  7. package/agent.command-20zaqe60.js +49 -0
  8. package/akanCode.js +13 -8
  9. package/{application.command-wthg8nn9.js → application.command-nd0fshsk.js} +45 -12
  10. package/{applicationBuildRunner-t2r84sz6.js → applicationBuildRunner-s13x3zqb.js} +14 -10
  11. package/buildBatch.proc.js +7 -7
  12. package/{cloud.command-sz11hpre.js → cloud.command-8kbddsz9.js} +28 -19
  13. package/cloud.script-hgvvajm3.js +27 -0
  14. package/code.command-625bg8s8.js +345 -0
  15. package/commandManifest.json +1 -1
  16. package/{context.command-15j9b7c0.js → context.command-p6haqjay.js} +20 -18
  17. package/context.runner-rsnqnk9j.js +27 -0
  18. package/{dependencyScanner-3afj2vt1.js → dependencyScanner-78sq8m4q.js} +2 -2
  19. package/{devTui-q7k7bakd.js → devTui-evr3b35y.js} +1 -1
  20. package/{fileSys-wzzrntkw.js → fileSys-zpvt5gtf.js} +1 -1
  21. package/{guideline.command-snh85ctf.js → guideline.command-195g0h9a.js} +4 -4
  22. package/guidelines/agentRule/agentRule.instruction.md +22 -8
  23. package/guidelines/conventions/core.md +106 -0
  24. package/guidelines/conventions/rules/app.md +83 -0
  25. package/guidelines/conventions/rules/auth.md +46 -0
  26. package/guidelines/conventions/rules/config.md +60 -0
  27. package/guidelines/conventions/rules/constant.md +24 -0
  28. package/guidelines/conventions/rules/gates.md +32 -0
  29. package/guidelines/conventions/rules/layer.md +25 -0
  30. package/guidelines/conventions/rules/migration.md +27 -0
  31. package/guidelines/conventions/rules/module.md +90 -0
  32. package/guidelines/conventions/rules/page.md +56 -0
  33. package/guidelines/conventions/rules/sensitive.md +16 -0
  34. package/guidelines/conventions/rules/server.md +91 -0
  35. package/guidelines/conventions/rules/ssr.md +47 -0
  36. package/guidelines/conventions/rules/style.md +43 -0
  37. package/guidelines/conventions/rules/test.md +34 -0
  38. package/guidelines/conventions/rules/ts.md +95 -0
  39. package/guidelines/conventions/rules/tsx.md +76 -0
  40. package/guidelines/mcpRule/mcpRule.instruction.md +1 -1
  41. package/guidelines/pageRule/pageRule.instruction.md +8 -7
  42. package/guidelines/queryRule/queryRule.instruction.md +4 -0
  43. package/guidelines/runtimeRule/runtimeRule.instruction.md +35 -25
  44. package/guidelines/ssrRule/ssrRule.instruction.md +11 -10
  45. package/guidelines/transportRule/transportRule.instruction.md +5 -4
  46. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +4 -4
  47. package/incrementalBuilder.proc.js +7 -7
  48. package/{index-301pdbzz.js → index-00a7j05x.js} +7 -7
  49. package/{index-js6geqjn.js → index-0j1t1h2b.js} +3 -1
  50. package/{index-6txx6a9p.js → index-1h2jc0x3.js} +154 -88
  51. package/{index-55j120r8.js → index-1qsd8ft1.js} +65 -145
  52. package/{index-9th4gszy.js → index-2mwjshz5.js} +233 -1271
  53. package/index-2nxk8wgs.js +266 -0
  54. package/{index-j9vyj3dj.js → index-2phm56a1.js} +49 -8
  55. package/index-35j83zkd.js +61 -0
  56. package/index-4am4dvmf.js +29 -0
  57. package/index-75y7bcz4.js +28 -0
  58. package/index-7apsdr5g.js +487 -0
  59. package/{index-42j4a8zq.js → index-84h43kg6.js} +8 -6
  60. package/index-9bv479q5.js +1 -0
  61. package/{index-3wypz6xj.js → index-9zy8479y.js} +11 -5
  62. package/{index-a5dhqkdr.js → index-a1vb3x7t.js} +273 -259
  63. package/{index-52w0fvh8.js → index-bns3wcpc.js} +15 -0
  64. package/index-cjmjvg4r.js +3622 -0
  65. package/{index-pcwzkdqb.js → index-defp4gmb.js} +1 -1
  66. package/index-ewbmfarf.js +1606 -0
  67. package/index-fbewhg4g.js +590 -0
  68. package/index-fhw7yq2d.js +653 -0
  69. package/{index-wcej7g4z.js → index-g500c5j9.js} +271 -105
  70. package/{index-74tjjsnc.js → index-g841cap9.js} +33 -37
  71. package/{index-2azahjaw.js → index-gr9thy79.js} +5 -5
  72. package/{index-4pf8g7ff.js → index-h7hehkw6.js} +3 -0
  73. package/{index-xjf5j657.js → index-hm0tn7qv.js} +1001 -91
  74. package/index-j6eeh5d7.js +138 -0
  75. package/{index-31es1yev.js → index-j7hwy56s.js} +108 -7
  76. package/{index-skk9zc1x.js → index-jc2zbwra.js} +2 -2
  77. package/{index-905qdgqp.js → index-khk05tsf.js} +1 -1
  78. package/{index-5nd1wtkv.js → index-p6x5b7hr.js} +1 -1
  79. package/{index-tvehn2sp.js → index-qd7xn2bk.js} +1 -1
  80. package/{index-a58emady.js → index-qw6814m4.js} +55 -17
  81. package/index-raz588b3.js +445 -0
  82. package/{index-at7bz0xq.js → index-s4nvxpzm.js} +2 -0
  83. package/{index-bt438yxm.js → index-sp0qsr7a.js} +116 -13
  84. package/{index-xb8809yb.js → index-sveq36gh.js} +40 -43
  85. package/{index-hmt54t45.js → index-t1t9wq9a.js} +4 -4
  86. package/index-t78230d7.js +191 -0
  87. package/index-tenw3mah.js +225 -0
  88. package/{index-qfp55x1y.js → index-tgqameyb.js} +4 -4
  89. package/{index-espk51ah.js → index-tp56652m.js} +6 -6
  90. package/index-w15mg3km.js +389 -0
  91. package/{index-dy0jx9ay.js → index-wwe9rsrx.js} +14 -0
  92. package/{index-2xcc2ax5.js → index-y4kcmbt2.js} +2 -2
  93. package/index-yf9wc28h.js +52 -0
  94. package/{index-0fz95kxe.js → index-zbrwnmf1.js} +9 -7
  95. package/{index-40brg4px.js → index-zttm13c3.js} +5 -5
  96. package/index.js +24 -23
  97. package/{library.command-gycrwhf1.js → library.command-63hgt9te.js} +4 -4
  98. package/{localRegistry.command-jtd8gaes.js → localRegistry.command-g3f8k25t.js} +46 -22
  99. package/{module.command-v6hgs1bc.js → module.command-r4sa2khp.js} +7 -6
  100. package/{package.command-shzpcfph.js → package.command-96eheyvd.js} +5 -5
  101. package/package.json +2 -2
  102. package/{page.command-ptxn5kqk.js → page.command-gs6d841d.js} +4 -4
  103. package/{pipeline.command-zz31pgax.js → pipeline.command-wdfvdbfj.js} +3 -3
  104. package/{primitive.command-a1vse91z.js → primitive.command-dfsv4mpe.js} +8 -7
  105. package/{projectTypecheck-2ztky9cf.js → projectTypecheck-kqj1t6hb.js} +1 -1
  106. package/{prompter-76k56b37.js → prompter-qrwx1p17.js} +2 -2
  107. package/quality.command-webzxee2.js +78 -0
  108. package/{repair.command-cvazbz99.js → repair.command-3r3j1xre.js} +7 -6
  109. package/{routeSourceValidator-6jd0q6r6.js → routeSourceValidator-4h947v7c.js} +13 -3
  110. package/{scalar.command-0acvyp26.js → scalar.command-e8y47j6d.js} +6 -5
  111. package/skills/akan-agent/SKILL.md +43 -0
  112. package/skills/akan-code/SKILL.md +38 -11
  113. package/skills/akan-debug/SKILL.md +41 -6
  114. package/skills/akan-deps/SKILL.md +1 -2
  115. package/skills/akan-err/SKILL.md +2 -1
  116. package/skills/akan-mcp/SKILL.md +40 -0
  117. package/skills/akan-page/SKILL.md +44 -0
  118. package/skills/akan-query/SKILL.md +39 -0
  119. package/skills/akan-runtime/SKILL.md +43 -0
  120. package/skills/akan-scaffold/SKILL.md +16 -6
  121. package/skills/akan-transport/SKILL.md +40 -0
  122. package/skills/akan-validate/SKILL.md +13 -11
  123. package/{subspace.command-822qx2bx.js → subspace.command-a1sf9n5a.js} +12 -10
  124. package/templates/__scalar/__model__/__model__.constant.ts +3 -5
  125. package/templates/__scalar/__model__/__model__.dictionary.ts +6 -5
  126. package/templates/__scalar/__model__/__model__.document.ts +3 -3
  127. package/templates/app/akan.config.ts +2 -3
  128. package/templates/app/env/env.client.ts +2 -4
  129. package/templates/app/env/env.client.type.ts +2 -3
  130. package/templates/app/env/env.server.ts +2 -3
  131. package/templates/app/lib/___appName__/__appName__.dictionary.ts +1 -2
  132. package/templates/app/lib/___appName__/__appName__.service.ts +3 -3
  133. package/templates/app/lib/___appName__/__appName__.signal.ts +5 -5
  134. package/templates/app/lib/___appName__/__appName__.store.ts +4 -6
  135. package/templates/app/lib/option.ts +2 -3
  136. package/templates/app/main.ts +2 -4
  137. package/templates/app/page/_index.tsx +3 -3
  138. package/templates/app/page/_layout.tsx +13 -10
  139. package/templates/appSample/lib/__scalar/workHistory/workHistory.constant.ts +1 -5
  140. package/templates/appSample/lib/__scalar/workHistory/workHistory.dictionary.ts +1 -1
  141. package/templates/appSample/lib/_noti/noti.signal.ts +1 -1
  142. package/templates/appSample/lib/task/Task.Template.tsx +2 -1
  143. package/templates/appSample/lib/task/Task.Unit.tsx +3 -2
  144. package/templates/appSample/lib/task/Task.Util.tsx +16 -4
  145. package/templates/appSample/lib/task/task.constant.ts +1 -5
  146. package/templates/appSample/lib/task/task.dictionary.ts +2 -8
  147. package/templates/appSample/lib/task/task.document.ts +1 -1
  148. package/templates/appSample/lib/task/task.signal.ts +14 -9
  149. package/templates/appSample/page/task/_index.tsx +2 -1
  150. package/templates/appSample/page/task/new.tsx +2 -1
  151. package/templates/appSample/srvkit/guards.ts +11 -0
  152. package/templates/appSample/ui/QuantityControl.tsx +5 -9
  153. package/templates/biomeForm.ts +144 -0
  154. package/templates/crudPages/[__model__Id]/edit/page.tsx +3 -3
  155. package/templates/crudPages/[__model__Id]/page.tsx +5 -5
  156. package/templates/crudPages/new/page.tsx +4 -3
  157. package/templates/crudPages/page.tsx +3 -3
  158. package/templates/crudSinglePage/page.tsx +9 -5
  159. package/templates/libRoot/akan.config.ts +2 -3
  160. package/templates/libRoot/lib/___libName__/__libName__.dictionary.ts +1 -2
  161. package/templates/libRoot/lib/___libName__/__libName__.service.ts +5 -4
  162. package/templates/libRoot/lib/___libName__/__libName__.signal.ts +6 -5
  163. package/templates/libRoot/lib/___libName__/__libName__.store.ts +5 -6
  164. package/templates/libRoot/lib/option.ts +1 -2
  165. package/templates/module/__Model__.Template.tsx +11 -10
  166. package/templates/module/__Model__.Unit.tsx +18 -5
  167. package/templates/module/__Model__.Util.tsx +9 -7
  168. package/templates/module/__Model__.View.tsx +9 -6
  169. package/templates/module/__Model__.Zone.tsx +25 -17
  170. package/templates/module/__model__.constant.ts +8 -9
  171. package/templates/module/__model__.dictionary.ts +16 -17
  172. package/templates/module/__model__.document.ts +6 -8
  173. package/templates/module/__model__.service.ts +3 -3
  174. package/templates/module/__model__.signal.ts +11 -10
  175. package/templates/module/__model__.store.ts +3 -5
  176. package/templates/service/__model__.dictionary.ts +5 -6
  177. package/templates/service/__model__.service.ts +3 -3
  178. package/templates/service/__model__.signal.ts +5 -4
  179. package/templates/service/__model__.store.ts +3 -5
  180. package/templates/workspaceRoot/.gitignore.template +4 -0
  181. package/templates/workspaceRoot/.vscode/settings.json.template +21 -21
  182. package/templates/workspaceRoot/AGENTS.md.template +4 -10
  183. package/{tunnel.command-ycmja19q.js → tunnel.command-dcb0wg93.js} +25 -13
  184. package/{typeChecker-px49mezc.js → typeChecker-j2jdnqsr.js} +1 -1
  185. package/typecheck.proc.js +6 -1
  186. package/verify.command-yyepccbh.js +93 -0
  187. package/{workflow.command-abb1d5xy.js → workflow.command-z5pg9ay0.js} +49 -14
  188. package/workspace.command-d7x5jttw.js +290 -0
  189. package/CodeAgent-8d5qs787.js +0 -9
  190. package/CodeAgentRpcListener-7p7z5dd7.js +0 -97
  191. package/TunnelShare-qkm8zp03.js +0 -14
  192. package/agent.command-ydftceda.js +0 -25
  193. package/cloud.script-nqevg5qw.js +0 -24
  194. package/code.command-9h3yrzhe.js +0 -167
  195. package/context.runner-8gg030b0.js +0 -25
  196. package/guidelines/conventions/conventions.instruction.md +0 -617
  197. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +0 -291
  198. package/index-2mwc0g0d.js +0 -49
  199. package/index-4vgbysa0.js +0 -279
  200. package/index-7md2g9vw.js +0 -6
  201. package/index-b70zct19.js +0 -856
  202. package/index-c6eggbee.js +0 -123
  203. package/index-zzvvc845.js +0 -74
  204. package/quality.command-ah8qcakd.js +0 -1478
  205. package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +0 -69
  206. package/templates/workspaceRoot/docs/GENERATED.md.template +0 -55
  207. package/workspace.command-qm7cw29v.js +0 -521
@@ -1,20 +1,30 @@
1
1
  // @bun
2
2
  import {
3
- SubagentPool2,
4
- akanCodePaths2,
3
+ AkanCodeEnv,
4
+ akanCodePaths2
5
+ } from "./index-35j83zkd.js";
6
+ import {
7
+ akanCodeDefaultModel2,
8
+ akanCodeModel2,
9
+ akanCodeModelSupportsImages2,
10
+ akanCodeModelWarnings2,
5
11
  McpServerConfig,
12
+ WorkspaceTrust
13
+ } from "./index-w15mg3km.js";
14
+ import {
15
+ SubagentPool2,
6
16
  McpSignIn,
7
17
  AkanCodeCompaction2
8
- } from "./index-55j120r8.js";
18
+ } from "./index-1qsd8ft1.js";
9
19
  import {
20
+ PreviewView2,
10
21
  stripAnsi
11
- } from "./index-7md2g9vw.js";
22
+ } from "./index-tenw3mah.js";
12
23
  import {
13
- akanCodeDefaultModel2,
14
- akanCodeModel2,
15
- akanCodeModelSupportsImages2,
16
- akanCodeModelWarnings2
17
- } from "./index-c6eggbee.js";
24
+ codeAgentIsLoopback,
25
+ codeAgentHostListed,
26
+ codeAgentHostOf
27
+ } from "./index-75y7bcz4.js";
18
28
 
19
29
  // pkgs/@akanjs/devkit/codeAgent/agent/AkanCodeServices.ts
20
30
  import { existsSync as existsSync4, mkdirSync, mkdtempSync } from "fs";
@@ -150,7 +160,7 @@ var akanSystemPrompt2 = (profile) => {
150
160
  "- Never hand-edit a generated file (`lib/cnst.ts`, `db.ts`, `st.ts`, any `*/index.ts` barrel). Fix the owning source and run `repair_generated` or `akan sync`."
151
161
  ];
152
162
  if (profile.tools.builtin.includes("write"))
153
- lines.push("- After editing, call `akan_verify`. It runs sync, lint, typecheck and the SSR check over what the working tree changed. A turn that edits and does not verify is not finished.");
163
+ lines.push("- After editing, call `akan_verify` once. It runs sync, lint, typecheck, a fast build and the SSR check over what the working tree changed; never run `akan lint`, `akan typecheck` or `akan build` separately. A turn that edits and does not verify is not finished.");
154
164
  else
155
165
  lines.push("- This session is read-only: there is no write, edit or bash tool. Report what should change instead of changing it.");
156
166
  if (profile.tools.subagent)
@@ -159,6 +169,8 @@ var akanSystemPrompt2 = (profile) => {
159
169
  lines.push("- Ask with `ask_user` when two readings of the request would lead to materially different work, and offer the options you can name. Do not ask for a choice that has an obvious default, and do not ask permission for work you were already asked to do \u2014 make the call, say the assumption, and carry on.");
160
170
  if (profile.approval !== "never")
161
171
  lines.push(`- Some tool calls need the user's approval (policy: ${profile.approval}). A refusal is an answer; do not retry it a different way.`);
172
+ if (profile.network.askOutside)
173
+ lines.push("- `web_fetch` to a host outside a short list of documentation sites, and a shell command that reaches the network (`curl`, `wget`, `ssh`, \u2026), wait for the user's approval. A refusal is an answer; do not retry it a different way.");
162
174
  lines.push("- Secrets are refused at the tool boundary. If you need a value from `.env`, ask the user for it rather than looking for another way to read the file.", "", "## How to answer", "", "- Answer in as few words as carry the answer. A short question gets one sentence with no heading.", "- Do not open with what you are about to do, and do not close with a summary of what you did. The tool calls are already on the user's screen.", "- Skip headings, bold labels and bullet lists unless the answer is genuinely a list. Prose is shorter.", "- State a file as `path:line`. Do not paste a file back that the user can open.", "- Say what you could not do, and why, in one line. Do not offer alternatives nobody asked for.");
163
175
  return lines.join(`
164
176
  `);
@@ -259,7 +271,7 @@ class AkanCodeServices2 {
259
271
  });
260
272
  }
261
273
  static async runtime(workspaceRoot, proxy = null) {
262
- mkdirSync(akanCodePaths2.globalDir(), { recursive: true, mode: 448 });
274
+ akanCodePaths2.ensureGlobalDir();
263
275
  const runtime = await ModelRuntime.create({
264
276
  authPath: proxy ? path4.join(mkdtempSync(path4.join(tmpdir(), "akan-code-proxy-")), "auth.json") : akanCodePaths2.authFile(),
265
277
  modelsPath: akanCodePaths2.modelsFile()
@@ -306,7 +318,7 @@ class AkanCodeServices2 {
306
318
  agentsFiles: options.profile.context.projectFiles ? AkanContextFiles.extend(agentsFiles, { workspaceRoot: options.workspaceRoot, cwd: options.cwd }) : agentsFiles
307
319
  }),
308
320
  appendSystemPrompt: [akanSystemPrompt2(options.profile)],
309
- additionalExtensionPaths: present(akanCodePaths2.extensionsDir(options.workspaceRoot)),
321
+ additionalExtensionPaths: WorkspaceTrust.isTrusted(options.workspaceRoot, "extensions") ? present(akanCodePaths2.extensionsDir(options.workspaceRoot)) : [],
310
322
  additionalSkillPaths: AkanCodeServices2.#skillPaths(options.profile, options.workspaceRoot),
311
323
  extensionFactories: options.extensions
312
324
  };
@@ -330,7 +342,7 @@ import { existsSync as existsSync5, statSync as statSync4 } from "fs";
330
342
  import path5 from "path";
331
343
 
332
344
  // pkgs/@akanjs/devkit/codeAgent/tools/AkanEditScope.ts
333
- var empty = { paths: [], apps: [], libs: [], needsSync: false, touchesTsx: false };
345
+ var empty = { paths: [], apps: [], libs: [], pkgs: [], needsSync: false, touchesTsx: false };
334
346
 
335
347
  class AkanEditScope2 {
336
348
  static async since(cwd, baseline) {
@@ -344,6 +356,7 @@ class AkanEditScope2 {
344
356
  paths,
345
357
  apps: AkanEditScope2.#targets(paths, "apps"),
346
358
  libs: AkanEditScope2.#targets(paths, "libs"),
359
+ pkgs: AkanEditScope2.#targets(paths, "pkgs"),
347
360
  needsSync: entries.some((entry) => /[ARD?]/.test(entry.code) && /^(apps|libs)\//.test(entry.file)),
348
361
  touchesTsx: paths.some((file) => file.endsWith(".tsx"))
349
362
  };
@@ -360,7 +373,10 @@ class AkanEditScope2 {
360
373
  `).filter((line) => line.trim().length > 3));
361
374
  }
362
375
  static #targets(paths, root) {
363
- const names = paths.filter((file) => file.startsWith(`${root}/`)).map((file) => file.split("/")[1] ?? "").filter(Boolean);
376
+ const names = paths.filter((file) => file.startsWith(`${root}/`)).map((file) => {
377
+ const [, first = "", second = ""] = file.split("/");
378
+ return first.startsWith("@") && second ? `${first}/${second}` : first;
379
+ }).filter(Boolean);
364
380
  return [...new Set(names)];
365
381
  }
366
382
  }
@@ -435,149 +451,6 @@ ${lines.join(`
435
451
  }
436
452
  }
437
453
 
438
- // pkgs/@akanjs/devkit/codeAgent/feedback/PreviewChrome.ts
439
- import { existsSync as existsSync6 } from "fs";
440
- import { homedir } from "os";
441
- import path6 from "path";
442
-
443
- class PreviewChrome2 {
444
- static pathEnvKey = "BUN_CHROME_PATH";
445
- static backendEnvKey = "AKAN_CODE_WEBVIEW_BACKEND";
446
- static executables = [
447
- "chromium",
448
- "chromium-browser",
449
- "google-chrome-stable",
450
- "google-chrome",
451
- "brave-browser",
452
- "microsoft-edge",
453
- "chrome"
454
- ];
455
- static appBundles = [
456
- "Google Chrome.app/Contents/MacOS/Google Chrome",
457
- "Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
458
- "Chromium.app/Contents/MacOS/Chromium",
459
- "Brave Browser.app/Contents/MacOS/Brave Browser",
460
- "Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
461
- ];
462
- static get backend() {
463
- const declared = process.env[PreviewChrome2.backendEnvKey];
464
- if (declared === "webkit" || declared === "chrome")
465
- return declared;
466
- return process.platform === "darwin" ? "webkit" : "chrome";
467
- }
468
- static executable() {
469
- const declared = process.env[PreviewChrome2.pathEnvKey];
470
- if (declared)
471
- return declared;
472
- for (const name of PreviewChrome2.executables) {
473
- const found = Bun.which(name);
474
- if (found)
475
- return found;
476
- }
477
- if (process.platform !== "darwin")
478
- return;
479
- for (const root of ["/Applications", path6.join(homedir(), "Applications")])
480
- for (const bundle of PreviewChrome2.appBundles) {
481
- const candidate = path6.join(root, bundle);
482
- if (existsSync6(candidate))
483
- return candidate;
484
- }
485
- return;
486
- }
487
- static get available() {
488
- return PreviewChrome2.backend === "webkit" ? process.platform === "darwin" : !!PreviewChrome2.executable();
489
- }
490
- static backendOption() {
491
- if (PreviewChrome2.backend === "webkit")
492
- return "webkit";
493
- const argv = ["--disable-dev-shm-usage"];
494
- if (process.getuid?.() === 0)
495
- argv.push("--no-sandbox");
496
- return { type: "chrome", argv };
497
- }
498
- static dockerRuns = [
499
- "apt-get update && apt-get install -y --no-install-recommends chromium fonts-liberation fonts-noto-color-emoji fonts-noto-cjk && rm -rf /var/lib/apt/lists/*"
500
- ];
501
- static unavailableReason() {
502
- if (PreviewChrome2.available)
503
- return;
504
- if (PreviewChrome2.backend === "webkit")
505
- return `The webkit WebView backend exists only on macOS. Set ${PreviewChrome2.backendEnvKey}=chrome and install a browser.`;
506
- return [
507
- "The page preview needs a browser and this machine has none on PATH.",
508
- `Install one (${PreviewChrome2.dockerRuns[0]}) or point ${PreviewChrome2.pathEnvKey} at an existing Chrome.`
509
- ].join(" ");
510
- }
511
- }
512
-
513
- // pkgs/@akanjs/devkit/codeAgent/feedback/PreviewView.ts
514
- class PreviewView2 {
515
- static get available() {
516
- return typeof Bun.WebView === "function" && PreviewChrome2.available;
517
- }
518
- static unavailableReason() {
519
- if (typeof Bun.WebView !== "function")
520
- return "This Bun build has no WebView, so the page preview is off.";
521
- return PreviewChrome2.unavailableReason();
522
- }
523
- static async probe(url, { screenshot = false, width = 1280, height = 800 } = {}) {
524
- const logs = [];
525
- const view = PreviewView2.#open({ width, height, onConsole: (line) => logs.push(line) });
526
- try {
527
- await view.navigate(url);
528
- const result = {
529
- url,
530
- title: view.title,
531
- consoleErrors: logs.filter((line) => line.startsWith("error") || line.startsWith("warn")),
532
- pageErrors: PreviewView2.#strings(await view.evaluate(pageErrorsExpression)),
533
- domFindings: PreviewView2.#strings(await view.evaluate(domFindingsExpression))
534
- };
535
- if (screenshot)
536
- result.screenshot = await view.screenshot({ encoding: "base64" });
537
- return result;
538
- } finally {
539
- await view.close();
540
- }
541
- }
542
- static #open({ width, height, onConsole }) {
543
- const Ctor = Bun.WebView;
544
- return new Ctor({
545
- width,
546
- height,
547
- dataStore: "ephemeral",
548
- backend: PreviewChrome2.backendOption(),
549
- console: (type, ...args) => onConsole(`${type} ${args.map(String).join(" ")}`)
550
- });
551
- }
552
- static #strings(value) {
553
- return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
554
- }
555
- }
556
- var pageErrorsExpression = `(() => {
557
- const found = [];
558
- const root = document.getElementById("__next") || document.body;
559
- const rendered = root ? Array.from(root.children).filter((el) => !["SCRIPT", "STYLE", "TEMPLATE", "LINK", "NOSCRIPT"].includes(el.tagName)) : [];
560
- if (!rendered.length && !(root && root.innerText && root.innerText.trim())) found.push("The page body rendered empty.");
561
- const overlay = document.querySelector("[data-nextjs-dialog], .error-overlay, #akan-error");
562
- if (overlay) found.push("An error overlay is on the page: " + overlay.textContent.slice(0, 400));
563
- return found;
564
- })()`;
565
- var domFindingsExpression = `(() => {
566
- const found = [];
567
- const all = Array.from(document.querySelectorAll("body *"));
568
- const overflowing = all.filter((el) => el.scrollWidth > document.documentElement.clientWidth + 8);
569
- if (overflowing.length) found.push(overflowing.length + " element(s) overflow the viewport horizontally, first: " + (overflowing[0].tagName + "." + overflowing[0].className).slice(0, 120));
570
- const invisibleText = all.filter((el) => {
571
- if (!el.textContent || !el.textContent.trim()) return false;
572
- const style = getComputedStyle(el);
573
- return style.color === style.backgroundColor && style.backgroundColor !== "rgba(0, 0, 0, 0)";
574
- });
575
- if (invisibleText.length) found.push(invisibleText.length + " element(s) render text in the same colour as their background.");
576
- const unresolved = all.filter((el) => /(^|\\s)(bg|text|border)-(base-100|base-content|primary-content|error)(\\s|$)/.test(el.className || ""));
577
- if (unresolved.length) found.push(unresolved.length + " element(s) use a dropped daisyUI colour slot that renders no CSS.");
578
- return found;
579
- })()`;
580
-
581
454
  // pkgs/@akanjs/devkit/codeAgent/feedback/PreviewFeedback.ts
582
455
  class PreviewFeedback2 {
583
456
  key = "preview";
@@ -600,7 +473,7 @@ class PreviewFeedback2 {
600
473
  for (const route of this.#options.routes ?? ["/en/"]) {
601
474
  const url = new URL(route, this.#options.previewUrl).toString();
602
475
  const probe = await PreviewView2.probe(url, { screenshot: !!this.#options.canSeeImages });
603
- const problems = [...probe.pageErrors, ...probe.consoleErrors, ...probe.domFindings];
476
+ const problems = [...probe.pageErrors, ...probe.consoleErrors, ...probe.consoleWarnings, ...probe.domFindings];
604
477
  if (!problems.length)
605
478
  continue;
606
479
  findings.push(`**${url}**
@@ -686,8 +559,8 @@ class TurnFeedback2 {
686
559
  }
687
560
 
688
561
  // pkgs/@akanjs/devkit/codeAgent/tools/AkanCli.ts
689
- import { existsSync as existsSync7 } from "fs";
690
- import path7 from "path";
562
+ import { existsSync as existsSync6 } from "fs";
563
+ import path6 from "path";
691
564
  class AkanCli2 {
692
565
  #cwd;
693
566
  #entry;
@@ -700,7 +573,7 @@ class AkanCli2 {
700
573
  cwd: this.#cwd,
701
574
  stdout: "pipe",
702
575
  stderr: "pipe",
703
- env: { ...process.env, FORCE_COLOR: "0", NO_COLOR: "1" }
576
+ env: { ...process.env, FORCE_COLOR: "0", NO_COLOR: "1", AKAN_LOG_STDOUT_LEVEL: "warn" }
704
577
  });
705
578
  const timer = setTimeout(() => proc.kill(), timeoutMs);
706
579
  const [stdout, stderr, exitCode] = await Promise.all([
@@ -714,58 +587,37 @@ class AkanCli2 {
714
587
  }
715
588
  static #resolveEntry() {
716
589
  const candidates = [
717
- path7.join(import.meta.dir, "index.js"),
718
- path7.join(import.meta.dir, "..", "..", "..", "cli", "index.ts")
590
+ path6.join(import.meta.dir, "index.js"),
591
+ path6.join(import.meta.dir, "..", "..", "..", "cli", "index.ts")
719
592
  ];
720
- return candidates.find((candidate) => existsSync7(candidate)) ?? Bun.main;
593
+ return candidates.find((candidate) => existsSync6(candidate)) ?? Bun.main;
721
594
  }
722
595
  }
723
596
 
724
597
  // pkgs/@akanjs/devkit/codeAgent/tools/AkanVerifier.ts
725
598
  class AkanVerifier2 {
599
+ static tailLines = 20;
726
600
  #cli;
727
601
  constructor(cwd) {
728
602
  this.#cli = new AkanCli2(cwd);
729
603
  }
730
- async verify(scope) {
731
- const steps = [];
732
- const targets = [...scope.apps, ...scope.libs];
733
- if (scope.needsSync)
734
- for (const target of targets)
735
- steps.push(await this.#cli.run(["sync", target]));
736
- for (const target of targets)
737
- steps.push(await this.#cli.run(["lint", target]));
738
- for (const app of scope.apps)
739
- steps.push(await this.#cli.run(["typecheck", app]));
740
- if (scope.touchesTsx)
741
- steps.push(await this.#cli.run(["quality", "ssr"]));
742
- return { ok: steps.every((step) => step.ok), steps, scope };
743
- }
744
- static summarize(report, { tailLines = 40 } = {}) {
745
- if (!report.steps.length)
746
- return "No akan target was touched, so there was nothing to verify.";
747
- if (report.ok)
748
- return `Verification passed: ${report.steps.map((step) => step.command).join(", ")}.`;
749
- const failed = report.steps.filter((step) => !step.ok);
750
- const passed = report.steps.filter((step) => step.ok).map((step) => step.command);
751
- const blocks = failed.map((step) => `### ${step.command} (exit ${step.exitCode})
752
- ${tail(step.output, tailLines)}`);
753
- return [
754
- `Verification failed: ${failed.map((step) => step.command).join(", ")}.`,
755
- passed.length ? `Passed: ${passed.join(", ")}.` : "",
756
- ...blocks
757
- ].filter(Boolean).join(`
758
-
759
- `);
604
+ async verify(paths = []) {
605
+ const args = ["verify", ...paths.length ? ["--files", paths.join(",")] : []];
606
+ const result = await this.#cli.run(args, { timeoutMs: 600000 });
607
+ return { ok: result.ok, text: AkanVerifier2.summarize(result) };
760
608
  }
761
- }
762
- var tail = (text, lines) => {
763
- const all = text.split(`
609
+ static summarize(result) {
610
+ if (result.output.startsWith("verify "))
611
+ return result.output;
612
+ const lines = result.output.split(`
764
613
  `);
765
- return all.length <= lines ? text : `\u2026
766
- ${all.slice(-lines).join(`
614
+ const tail = lines.length <= AkanVerifier2.tailLines ? result.output : `\u2026
615
+ ${lines.slice(-AkanVerifier2.tailLines).join(`
767
616
  `)}`;
768
- };
617
+ return `${result.command} exited ${result.exitCode} before reporting:
618
+ ${tail}`;
619
+ }
620
+ }
769
621
 
770
622
  // pkgs/@akanjs/devkit/codeAgent/feedback/VerifyFeedback.ts
771
623
  class VerifyFeedback2 {
@@ -782,14 +634,12 @@ class VerifyFeedback2 {
782
634
  }
783
635
  async observe() {
784
636
  const scope = await AkanEditScope2.since(this.#options.cwd, this.#baseline);
785
- if (!scope.apps.length && !scope.libs.length)
637
+ if (!scope.apps.length && !scope.libs.length && !scope.pkgs.length)
786
638
  return;
787
639
  if (this.#options.readOnly)
788
640
  return VerifyFeedback2.#readOnlyNotice(scope.needsSync, [...scope.apps, ...scope.libs]);
789
- const report = await this.#verifier.verify(scope);
790
- if (report.ok)
791
- return;
792
- return AkanVerifier2.summarize(report);
641
+ const report = await this.#verifier.verify(scope.paths);
642
+ return report.ok ? undefined : report.text;
793
643
  }
794
644
  static #readOnlyNotice(needsSync, targets) {
795
645
  if (!needsSync)
@@ -809,7 +659,7 @@ class AkanToolPack2 {
809
659
  return { name: "akan-tools", factory: async (pi) => await this.#register(pi) };
810
660
  }
811
661
  async names() {
812
- const { ContextRunner } = await import("./context.runner-8gg030b0.js");
662
+ const { ContextRunner } = await import("./context.runner-rsnqnk9j.js");
813
663
  return [
814
664
  ...new ContextRunner().listMcpTools(this.#options.mode).map((tool) => tool.name),
815
665
  AkanToolPack2.verifyToolName
@@ -817,7 +667,7 @@ class AkanToolPack2 {
817
667
  }
818
668
  static verifyToolName = "akan_verify";
819
669
  async#register(pi) {
820
- const { ContextRunner } = await import("./context.runner-8gg030b0.js");
670
+ const { ContextRunner } = await import("./context.runner-rsnqnk9j.js");
821
671
  const runner = new ContextRunner;
822
672
  const guidelineNames = await AkanToolPack2.#guidelineNames();
823
673
  for (const tool of runner.listMcpTools(this.#options.mode, { guidelineNames })) {
@@ -844,23 +694,18 @@ class AkanToolPack2 {
844
694
  pi.registerTool({
845
695
  name: AkanToolPack2.verifyToolName,
846
696
  label: "akan verify",
847
- description: "Run the akan validation chain (sync, lint, typecheck, and quality ssr for .tsx changes) over everything the working tree has changed, and report what failed. Call this after editing before you finish.",
848
- promptSnippet: "akan_verify: run sync/lint/typecheck/quality over the working tree's changes",
697
+ description: "Run `akan verify` over everything the working tree has changed: sync, lint (with fixes), typecheck, a fast build of each changed app, and the SSR check for .tsx changes, in one call. It prints one line when it passes and one line per problem when it fails. Call this after editing, before you finish; never run lint, typecheck or build separately.",
698
+ promptSnippet: "akan_verify: sync, lint, typecheck and build what the working tree changed, in one call",
849
699
  parameters: Type.Object({}),
850
700
  execute: async () => {
851
- const scope = await AkanEditScope2.since(this.#options.cwd, new Set);
852
- const report = await verifier.verify(scope);
853
- return {
854
- content: [{ type: "text", text: AkanVerifier2.summarize(report) }],
855
- details: undefined,
856
- isError: !report.ok
857
- };
701
+ const report = await verifier.verify();
702
+ return { content: [{ type: "text", text: report.text }], details: undefined, isError: !report.ok };
858
703
  }
859
704
  });
860
705
  }
861
706
  static async#guidelineNames() {
862
707
  try {
863
- const { Prompter } = await import("./prompter-76k56b37.js");
708
+ const { Prompter } = await import("./prompter-qrwx1p17.js");
864
709
  return await Prompter.listGuidelines();
865
710
  } catch {
866
711
  return [];
@@ -1320,7 +1165,11 @@ class McpToolPack2 {
1320
1165
  if (options.profile.tools.mcp === "off")
1321
1166
  return [];
1322
1167
  const declared = Array.isArray(options.profile.tools.mcp) ? options.profile.tools.mcp : [];
1323
- return [...McpServerConfig.read(options.workspaceRoot), ...declared];
1168
+ if (WorkspaceTrust.isTrusted(options.workspaceRoot, "mcp"))
1169
+ return [...McpServerConfig.read(options.workspaceRoot), ...declared];
1170
+ const skipped = McpServerConfig.read(options.workspaceRoot, ["workspace"]).map((ref) => ref.name);
1171
+ options.onNotice?.(`Not started, because this repo's MCP servers are not approved: ${skipped.join(", ")}. Start akan code in a terminal to approve them, or pass --trust-workspace.`);
1172
+ return [...McpServerConfig.read(options.workspaceRoot, ["global"]), ...declared];
1324
1173
  }
1325
1174
  }
1326
1175
 
@@ -1508,6 +1357,7 @@ class DeepSeekWeb {
1508
1357
  class WebToolPack2 {
1509
1358
  static pageChars = 1e4;
1510
1359
  static maxResults = 10;
1360
+ static maxRedirects = 5;
1511
1361
  static #rememberedPages = 16;
1512
1362
  #options;
1513
1363
  #pages = new Map;
@@ -1630,8 +1480,9 @@ class WebToolPack2 {
1630
1480
  return deepseek ? { name: "deepseek", search: (query, count, signal) => deepseek.search(query, count, signal) } : undefined;
1631
1481
  }
1632
1482
  async#read(url, signal) {
1483
+ const within = this.#boundOf(new URL(url).hostname);
1633
1484
  const deepseek = this.#options.deepseek;
1634
- if (deepseek && !await this.#isLocal(new URL(url).hostname)) {
1485
+ if (deepseek && !within && !await this.#isLocal(new URL(url).hostname)) {
1635
1486
  try {
1636
1487
  const page = await deepseek.fetch(url, signal);
1637
1488
  return { status: 200, ok: true, title: page.title, text: page.content };
@@ -1640,11 +1491,50 @@ class WebToolPack2 {
1640
1491
  throw error;
1641
1492
  }
1642
1493
  }
1643
- const response = await fetch(url, {
1644
- signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(20000)]) : AbortSignal.timeout(20000),
1645
- redirect: "follow"
1646
- });
1647
- return { status: response.status, ok: response.ok, title: "", text: WebToolPack2.#readable(await response.text()) };
1494
+ const timeout = signal ? AbortSignal.any([signal, AbortSignal.timeout(20000)]) : AbortSignal.timeout(20000);
1495
+ if (!within) {
1496
+ const response = await fetch(url, { signal: timeout, redirect: "follow" });
1497
+ return {
1498
+ status: response.status,
1499
+ ok: response.ok,
1500
+ title: "",
1501
+ text: WebToolPack2.#readable(await response.text())
1502
+ };
1503
+ }
1504
+ return await WebToolPack2.#readWithin(url, within, timeout);
1505
+ }
1506
+ #boundOf(hostname) {
1507
+ const { allowHosts, askOutside } = this.#options.profile.network;
1508
+ if (allowHosts?.length)
1509
+ return (host) => allowHosts.includes(host);
1510
+ const quiet = (host) => codeAgentIsLoopback(host) || codeAgentHostListed(host, askOutside ?? []);
1511
+ return askOutside && quiet(hostname) ? quiet : undefined;
1512
+ }
1513
+ static async#readWithin(url, within, signal) {
1514
+ let current = url;
1515
+ for (let hop = 0;hop <= WebToolPack2.maxRedirects; hop += 1) {
1516
+ const response = await fetch(current, { signal, redirect: "manual" });
1517
+ const location = response.headers.get("location");
1518
+ if (response.status < 300 || response.status >= 400 || !location)
1519
+ return {
1520
+ status: response.status,
1521
+ ok: response.ok,
1522
+ title: "",
1523
+ text: WebToolPack2.#readable(await response.text())
1524
+ };
1525
+ await response.body?.cancel();
1526
+ const next = new URL(location, current).href;
1527
+ const host = codeAgentHostOf(next);
1528
+ if (!host || !within(host))
1529
+ return {
1530
+ status: response.status,
1531
+ ok: false,
1532
+ title: "",
1533
+ text: `Redirected to ${next}, which this profile does not reach without asking. web_fetch that URL to follow it.`
1534
+ };
1535
+ current = next;
1536
+ }
1537
+ return { status: 310, ok: false, title: "", text: `More than ${WebToolPack2.maxRedirects} redirects.` };
1648
1538
  }
1649
1539
  #remember(url, page) {
1650
1540
  this.#pages.delete(url);
@@ -1765,6 +1655,7 @@ class AkanCodePlugins2 {
1765
1655
  workspace: options.workspace,
1766
1656
  cwd: options.cwd,
1767
1657
  parent: options.profile,
1658
+ ...options.model ? { model: options.model } : {},
1768
1659
  depth: options.depth,
1769
1660
  ...options.subagentSpend ? { spend: options.subagentSpend } : {},
1770
1661
  ...options.onNotice ? { onNotice: options.onNotice } : {},
@@ -2085,20 +1976,45 @@ class CodeAgentEventMapper2 {
2085
1976
  }
2086
1977
 
2087
1978
  // pkgs/@akanjs/devkit/codeAgent/agent/CodeAgentGate.ts
2088
- import path8 from "path";
1979
+ import { realpathSync } from "fs";
1980
+ import { homedir } from "os";
1981
+ import path7 from "path";
1982
+ import { fileURLToPath } from "url";
2089
1983
  var writeTools = new Set(["write", "edit"]);
2090
1984
  var commandTools = new Set(["bash"]);
1985
+ var networkClients = /(?:^[ \t]*|[\n;&|(`{][ \t]*|\s-\w*c\s+['"][ \t]*|\s-exec(?:dir)?\s+)(?:(?:[A-Za-z_]\w*=\S*|sudo|env|command|exec|nohup|time|timeout|nice|watch|stdbuf|xargs|-\S+|\d\S*)[ \t]+)*(?:[^\s;&|()`'"]*\/)?(curl|wget|nc|ncat|netcat|socat|telnet|ssh|scp|sftp|rsync|ftp)(?=$|[\s;&|)`'"])/g;
1986
+ var urlPattern = /\b[a-z][a-z0-9+.-]*:\/\/[^\s'"`<>|;&()]+/gi;
1987
+ var hostPortPattern = /(?<=^|[\s'"=])(?:\[[0-9a-f:.]+\]|[a-z0-9.-]+):\d{1,5}(?=[/?#\s'"]|$)/gi;
1988
+ var ordinaryNames = ["index.ts", "a.ts", "a.tsx", "a.js", "a.json", "a.yaml", "a.md", "a.txt", "a.log", "README"];
2091
1989
 
2092
1990
  class CodeAgentGate2 {
2093
1991
  #profile;
1992
+ #realRoot;
2094
1993
  #deny;
2095
1994
  #allow;
2096
1995
  #deniedFragments;
1996
+ #nameRules;
2097
1997
  constructor(profile) {
2098
1998
  this.#profile = profile;
2099
- this.#deny = (profile.paths.deny ?? []).map((pattern) => new Bun.Glob(pattern));
1999
+ this.#realRoot = CodeAgentGate2.#real(path7.resolve(profile.paths.root));
2000
+ const home = homedir();
2001
+ const codeHome = path7.resolve(akanCodePaths2.globalDir());
2002
+ const patterns = [
2003
+ ...(profile.paths.deny ?? []).map((pattern) => pattern.startsWith("~/") ? path7.join(home, pattern.slice(2)) : pattern),
2004
+ ...profile.paths.deny?.length ? [`${codeHome}/**`] : []
2005
+ ];
2006
+ this.#deny = patterns.map((pattern) => new Bun.Glob(pattern));
2100
2007
  this.#allow = (profile.paths.allow ?? []).map((pattern) => new Bun.Glob(pattern));
2101
- this.#deniedFragments = [...new Set((profile.paths.deny ?? []).map(CodeAgentGate2.#fragmentOf).filter(Boolean))];
2008
+ this.#deniedFragments = [
2009
+ ...new Set((profile.paths.deny ?? []).flatMap(CodeAgentGate2.#expandBraces).flatMap((pattern) => CodeAgentGate2.#fragmentsOf(pattern, home)))
2010
+ ].filter(Boolean);
2011
+ this.#nameRules = (profile.paths.deny ?? []).flatMap((pattern) => {
2012
+ const name = /^\*\*\/([^/]+)$/.exec(pattern)?.[1];
2013
+ if (!name || name === "**")
2014
+ return [];
2015
+ const samples = CodeAgentGate2.#expandBraces(name).map((entry) => entry.replace(/[*?]/g, "x"));
2016
+ return [{ glob: new Bun.Glob(name), samples }];
2017
+ });
2102
2018
  }
2103
2019
  verdict(toolName, args) {
2104
2020
  const target = stringArg(args, "path");
@@ -2113,27 +2029,73 @@ class CodeAgentGate2 {
2113
2029
  if (denied)
2114
2030
  return { block: denied };
2115
2031
  }
2032
+ const network = this.#networkApproval(toolName, args);
2033
+ if (network)
2034
+ return { approval: network, strict: true };
2116
2035
  if (!this.#needsApproval(toolName))
2117
2036
  return {};
2118
2037
  return { approval: CodeAgentGate2.#summarize(toolName, args) };
2119
2038
  }
2120
2039
  #deniedCommandReason(command) {
2121
- const hit = this.#deniedFragments.find((fragment) => command.includes(fragment));
2040
+ const hit = this.#deniedFragments.find((fragment) => command.includes(fragment)) ?? CodeAgentGate2.#wordsOf(command).find((word) => this.#namesDeniedFile(word));
2122
2041
  if (!hit)
2123
2042
  return;
2124
2043
  return `The command names "${hit}", which the profile's deny list covers. Ask the user for the value instead of reading the file.`;
2125
2044
  }
2045
+ #namesDeniedFile(word) {
2046
+ const expanded = CodeAgentGate2.#expandHome(word);
2047
+ const name = path7.basename(expanded);
2048
+ if (/[*?[{]/.test(name)) {
2049
+ const swept = new Bun.Glob(name);
2050
+ if (ordinaryNames.some((ordinary) => swept.match(ordinary)))
2051
+ return false;
2052
+ return this.#nameRules.some((rule) => rule.samples.some((sample) => swept.match(sample)));
2053
+ }
2054
+ const absolute = path7.resolve(this.#profile.paths.root, expanded);
2055
+ return this.#deny.some((glob) => glob.match(expanded) || glob.match(absolute));
2056
+ }
2126
2057
  #deniedReason(target) {
2127
- const absolute = path8.isAbsolute(target) ? target : path8.resolve(this.#profile.paths.root, target);
2128
- const relative = path8.relative(this.#profile.paths.root, absolute);
2129
- if (relative.startsWith("..") || path8.isAbsolute(relative))
2058
+ const absolute = path7.resolve(this.#profile.paths.root, CodeAgentGate2.#expandPath(target));
2059
+ const relative = path7.relative(path7.resolve(this.#profile.paths.root), absolute);
2060
+ if (relative === ".." || relative.startsWith(`..${path7.sep}`) || path7.isAbsolute(relative))
2130
2061
  return `Path is outside the agent root (${this.#profile.paths.root}).`;
2131
- if (this.#deny.some((glob) => glob.match(absolute) || glob.match(relative)))
2062
+ const real = CodeAgentGate2.#real(absolute);
2063
+ const candidates = [
2064
+ [absolute, relative],
2065
+ [real, path7.relative(this.#realRoot, real)]
2066
+ ];
2067
+ if (candidates.some(([candidate, rel]) => this.#deny.some((glob) => glob.match(candidate) || glob.match(rel))))
2132
2068
  return "Path is on the profile's deny list (secrets and environment files are never readable).";
2133
2069
  if (this.#allow.length && !this.#allow.some((glob) => glob.match(absolute) || glob.match(relative)))
2134
2070
  return "Path is outside the profile's allow list.";
2135
2071
  return;
2136
2072
  }
2073
+ #networkApproval(toolName, args) {
2074
+ const quiet = this.#profile.network.askOutside;
2075
+ if (!quiet)
2076
+ return;
2077
+ if (toolName === "web_fetch") {
2078
+ const url = stringArg(args, "url");
2079
+ const host = url ? codeAgentHostOf(url) : undefined;
2080
+ if (!host || codeAgentIsLoopback(host) || codeAgentHostListed(host, quiet))
2081
+ return;
2082
+ return `fetch ${url}`;
2083
+ }
2084
+ const command = stringArg(args, "command");
2085
+ if (!command || !commandTools.has(toolName))
2086
+ return;
2087
+ const clients = [...command.matchAll(networkClients)].map((match) => match[1]);
2088
+ if (!clients.length)
2089
+ return;
2090
+ const hosts = [
2091
+ ...[...command.matchAll(urlPattern)].map((match) => codeAgentHostOf(match[0])),
2092
+ ...[...command.matchAll(hostPortPattern)].map((match) => codeAgentHostOf(`http://${match[0]}`))
2093
+ ];
2094
+ const httpOnly = clients.every((client) => client === "curl" || client === "wget");
2095
+ if (httpOnly && hosts.length && hosts.every((host) => host && codeAgentIsLoopback(host)))
2096
+ return;
2097
+ return `reach the network: ${command.slice(0, 200)}`;
2098
+ }
2137
2099
  #needsApproval(toolName) {
2138
2100
  switch (this.#profile.approval) {
2139
2101
  case "never":
@@ -2148,9 +2110,55 @@ class CodeAgentGate2 {
2148
2110
  return false;
2149
2111
  }
2150
2112
  }
2151
- static #fragmentOf(pattern) {
2152
- const trimmed = pattern.replace(/^\*\*\//, "").replace(/\/\*\*$/, "/").replace(/^\*+/, "");
2153
- return trimmed.includes("*") ? "" : trimmed;
2113
+ static #expandPath(target) {
2114
+ const value = target.replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g, " ").replace(/^@/, "");
2115
+ if (/^file:\/\//.test(value)) {
2116
+ try {
2117
+ return fileURLToPath(value);
2118
+ } catch {
2119
+ return value;
2120
+ }
2121
+ }
2122
+ return CodeAgentGate2.#expandHome(value);
2123
+ }
2124
+ static #expandHome(value) {
2125
+ const home = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(value);
2126
+ return home ? path7.join(homedir(), value.slice(home[0].length)) : value;
2127
+ }
2128
+ static #real(absolute) {
2129
+ const rest = [];
2130
+ let head = absolute;
2131
+ for (;; ) {
2132
+ try {
2133
+ return path7.join(realpathSync(head), ...rest);
2134
+ } catch {
2135
+ const parent = path7.dirname(head);
2136
+ if (parent === head)
2137
+ return absolute;
2138
+ rest.unshift(path7.basename(head));
2139
+ head = parent;
2140
+ }
2141
+ }
2142
+ }
2143
+ static #wordsOf(command) {
2144
+ return command.split(/[\s;&|<>()`'"=,@]+/).filter(Boolean);
2145
+ }
2146
+ static #expandBraces(pattern) {
2147
+ const open = pattern.indexOf("{");
2148
+ const close = open >= 0 ? pattern.indexOf("}", open) : -1;
2149
+ if (close < 0)
2150
+ return [pattern];
2151
+ const head = pattern.slice(0, open);
2152
+ const tail = pattern.slice(close + 1);
2153
+ return pattern.slice(open + 1, close).split(",").flatMap((choice) => CodeAgentGate2.#expandBraces(`${head}${choice}${tail}`));
2154
+ }
2155
+ static #fragmentsOf(pattern, home) {
2156
+ if (pattern.startsWith("~/")) {
2157
+ const rest = pattern.slice(2).replace(/\/\*\*$/, "");
2158
+ return rest.includes("*") ? [] : ["~/", "$HOME/", "$" + "{HOME}/", `${home}/`].map((prefix) => `${prefix}${rest}`);
2159
+ }
2160
+ const trimmed = pattern.replace(/^\*\*\//, "").replace(/\/\*\*$/, "/").replace(/^\*+/, "").replace(/\*+$/, "");
2161
+ return trimmed.includes("*") ? [] : [trimmed];
2154
2162
  }
2155
2163
  static #summarize(toolName, args) {
2156
2164
  const record = args ?? {};
@@ -2179,15 +2187,15 @@ class CodeAgentProxy {
2179
2187
  throw new Error("AKAN_CODE_PROXY_URL needs AKAN_CODE_PROXY_TOKEN_FILE or AKAN_CODE_PROXY_TOKEN");
2180
2188
  }
2181
2189
  static fromEnv(profile) {
2182
- const baseUrl = process.env.AKAN_CODE_PROXY_URL?.trim() || profile?.network.proxyBaseUrl;
2190
+ const baseUrl = AkanCodeEnv.get("AKAN_CODE_PROXY_URL")?.trim() || profile?.network.proxyBaseUrl;
2183
2191
  if (!baseUrl)
2184
2192
  return null;
2185
- const providers = (process.env.AKAN_CODE_PROXY_PROVIDERS ?? akanCodeDefaultModel2.provider).split(",").map((provider) => provider.trim()).filter(Boolean);
2193
+ const providers = (AkanCodeEnv.get("AKAN_CODE_PROXY_PROVIDERS") ?? akanCodeDefaultModel2.provider).split(",").map((provider) => provider.trim()).filter(Boolean);
2186
2194
  return new CodeAgentProxy({
2187
2195
  baseUrl,
2188
2196
  providers,
2189
- tokenFile: process.env.AKAN_CODE_PROXY_TOKEN_FILE?.trim() || undefined,
2190
- token: process.env.AKAN_CODE_PROXY_TOKEN?.trim() || undefined
2197
+ tokenFile: AkanCodeEnv.get("AKAN_CODE_PROXY_TOKEN_FILE")?.trim() || undefined,
2198
+ token: AkanCodeEnv.get("AKAN_CODE_PROXY_TOKEN")?.trim() || undefined
2191
2199
  });
2192
2200
  }
2193
2201
  baseUrlFor(provider) {
@@ -2221,8 +2229,8 @@ class CodeAgentProxy {
2221
2229
  }
2222
2230
 
2223
2231
  // pkgs/@akanjs/devkit/codeAgent/agent/CodeAgentSuspended.ts
2224
- import { existsSync as existsSync8, mkdirSync as mkdirSync2, readFileSync as readFileSync4, rmSync, writeFileSync } from "fs";
2225
- import path9 from "path";
2232
+ import { existsSync as existsSync7, mkdirSync as mkdirSync2, readFileSync as readFileSync4, rmSync, writeFileSync } from "fs";
2233
+ import path8 from "path";
2226
2234
 
2227
2235
  class CodeAgentSuspended {
2228
2236
  #file;
@@ -2232,7 +2240,7 @@ class CodeAgentSuspended {
2232
2240
  this.#state = CodeAgentSuspended.#read(file);
2233
2241
  }
2234
2242
  static fileOf(sessionDir, sessionId) {
2235
- return sessionDir ? path9.join(sessionDir, `${sessionId}.suspended.json`) : null;
2243
+ return sessionDir ? path8.join(sessionDir, `${sessionId}.suspended.json`) : null;
2236
2244
  }
2237
2245
  get question() {
2238
2246
  return this.#state.question;
@@ -2277,12 +2285,12 @@ class CodeAgentSuspended {
2277
2285
  rmSync(this.#file, { force: true });
2278
2286
  return;
2279
2287
  }
2280
- mkdirSync2(path9.dirname(this.#file), { recursive: true });
2288
+ mkdirSync2(path8.dirname(this.#file), { recursive: true });
2281
2289
  writeFileSync(this.#file, `${JSON.stringify(this.#state)}
2282
2290
  `);
2283
2291
  }
2284
2292
  static #read(file) {
2285
- if (!file || !existsSync8(file))
2293
+ if (!file || !existsSync7(file))
2286
2294
  return { approvals: [] };
2287
2295
  try {
2288
2296
  const parsed = JSON.parse(readFileSync4(file, "utf8"));
@@ -2336,7 +2344,7 @@ class CodeAgentUi2 {
2336
2344
  // pkgs/@akanjs/devkit/codeAgent/agent/CodeMailbox.ts
2337
2345
  import {
2338
2346
  appendFileSync,
2339
- existsSync as existsSync9,
2347
+ existsSync as existsSync8,
2340
2348
  mkdirSync as mkdirSync3,
2341
2349
  readdirSync as readdirSync3,
2342
2350
  readFileSync as readFileSync5,
@@ -2344,7 +2352,7 @@ import {
2344
2352
  statSync as statSync5,
2345
2353
  writeFileSync as writeFileSync2
2346
2354
  } from "fs";
2347
- import path10 from "path";
2355
+ import path9 from "path";
2348
2356
  class CodeMailbox2 {
2349
2357
  static staleMs = 20000;
2350
2358
  static beatMs = 5000;
@@ -2363,11 +2371,11 @@ class CodeMailbox2 {
2363
2371
  this.#name = name;
2364
2372
  }
2365
2373
  get inbox() {
2366
- return path10.join(this.#dir, "inbox", `${this.#id}.jsonl`);
2374
+ return path9.join(this.#dir, "inbox", `${this.#id}.jsonl`);
2367
2375
  }
2368
2376
  open(cwd, onMail) {
2369
- mkdirSync3(path10.join(this.#dir, "live"), { recursive: true });
2370
- mkdirSync3(path10.join(this.#dir, "inbox"), { recursive: true });
2377
+ mkdirSync3(path9.join(this.#dir, "live"), { recursive: true });
2378
+ mkdirSync3(path9.join(this.#dir, "inbox"), { recursive: true });
2371
2379
  this.#read = readJsonLines(this.inbox).length;
2372
2380
  this.beat(cwd);
2373
2381
  this.#beat = setInterval(() => this.beat(cwd), CodeMailbox2.beatMs);
@@ -2384,7 +2392,7 @@ class CodeMailbox2 {
2384
2392
  this.#beat = null;
2385
2393
  this.#poll = null;
2386
2394
  try {
2387
- rmSync2(path10.join(this.#dir, "live", `${this.#id}.json`), { force: true });
2395
+ rmSync2(path9.join(this.#dir, "live", `${this.#id}.json`), { force: true });
2388
2396
  } catch {}
2389
2397
  }
2390
2398
  rename(name, cwd) {
@@ -2394,15 +2402,15 @@ class CodeMailbox2 {
2394
2402
  beat(cwd) {
2395
2403
  const peer = { id: this.#id, name: this.#name, cwd, pid: process.pid, at: Date.now() };
2396
2404
  try {
2397
- writeFileSync2(path10.join(this.#dir, "live", `${this.#id}.json`), JSON.stringify(peer));
2405
+ writeFileSync2(path9.join(this.#dir, "live", `${this.#id}.json`), JSON.stringify(peer));
2398
2406
  } catch {}
2399
2407
  }
2400
2408
  peers() {
2401
- const dir = path10.join(this.#dir, "live");
2402
- if (!existsSync9(dir))
2409
+ const dir = path9.join(this.#dir, "live");
2410
+ if (!existsSync8(dir))
2403
2411
  return [];
2404
2412
  const now = Date.now();
2405
- return readdirSync3(dir).filter((entry) => entry.endsWith(".json")).map((entry) => CodeMailbox2.#peer(path10.join(dir, entry))).filter((peer) => !!peer && peer.id !== this.#id && now - peer.at < CodeMailbox2.staleMs).sort((left, right) => right.at - left.at);
2413
+ return readdirSync3(dir).filter((entry) => entry.endsWith(".json")).map((entry) => CodeMailbox2.#peer(path9.join(dir, entry))).filter((peer) => !!peer && peer.id !== this.#id && now - peer.at < CodeMailbox2.staleMs).sort((left, right) => right.at - left.at);
2406
2414
  }
2407
2415
  find(target) {
2408
2416
  const needle = target.trim().toLowerCase();
@@ -2420,8 +2428,8 @@ class CodeMailbox2 {
2420
2428
  throw new Error(`Too many messages: ${CodeMailbox2.sendsPerMinute} a minute is the ceiling.`);
2421
2429
  this.#sent.push(now);
2422
2430
  const mail = { at: now, from: this.#id, fromName: this.#name, text };
2423
- mkdirSync3(path10.join(this.#dir, "inbox"), { recursive: true });
2424
- appendFileSync(path10.join(this.#dir, "inbox", `${to}.jsonl`), `${JSON.stringify(mail)}
2431
+ mkdirSync3(path9.join(this.#dir, "inbox"), { recursive: true });
2432
+ appendFileSync(path9.join(this.#dir, "inbox", `${to}.jsonl`), `${JSON.stringify(mail)}
2425
2433
  `);
2426
2434
  }
2427
2435
  #drain() {
@@ -2445,7 +2453,7 @@ class CodeMailbox2 {
2445
2453
  // pkgs/@akanjs/devkit/codeAgent/agent/CodeSessionFork.ts
2446
2454
  import { randomBytes } from "crypto";
2447
2455
  import { readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "fs";
2448
- import path11 from "path";
2456
+ import path10 from "path";
2449
2457
  import { codeAgentSessionName } from "akanjs/common";
2450
2458
  class CodeSessionFork2 {
2451
2459
  static fork(dir, id, name) {
@@ -2465,7 +2473,7 @@ class CodeSessionFork2 {
2465
2473
  first.id = forked;
2466
2474
  first.timestamp = at.toISOString();
2467
2475
  records.push(CodeSessionFork2.#named(records, name ?? CodeSessionFork2.#nameOf(records), at));
2468
- const file = path11.join(dir, `${at.toISOString().replace(/[:.]/g, "-")}_${forked}.jsonl`);
2476
+ const file = path10.join(dir, `${at.toISOString().replace(/[:.]/g, "-")}_${forked}.jsonl`);
2469
2477
  writeFileSync3(file, `${records.map((record) => JSON.stringify(record)).join(`
2470
2478
  `)}
2471
2479
  `);
@@ -2529,6 +2537,10 @@ class CodeAgent2 {
2529
2537
  profile: options.profile,
2530
2538
  apps: options.apps ?? [],
2531
2539
  canSeeImages: akanCodeModelSupportsImages2(model),
2540
+ model: () => {
2541
+ const current = agent.#session?.model;
2542
+ return current ? { provider: current.provider, id: current.id } : undefined;
2543
+ },
2532
2544
  deepseek: await DeepSeekWeb.fromRuntime(modelRuntime, !!proxy),
2533
2545
  depth: options.depth ?? 0,
2534
2546
  ...options.subagentSpend ? { subagentSpend: options.subagentSpend } : {},
@@ -2903,6 +2915,8 @@ Continue the task.`);
2903
2915
  return this.#refuse(event.toolCallId, event.toolName, event.input, verdict.block);
2904
2916
  if (!verdict.approval)
2905
2917
  return;
2918
+ if (verdict.strict && !this.#profile.ui.canPrompt)
2919
+ return this.#refuse(event.toolCallId, event.toolName, event.input, "This reaches a host outside the profile's list, which needs the user's approval, and nobody can be asked in this session. Use a listed host, or say what you need fetched.");
2906
2920
  const approved = await this.#requestApproval(event.toolCallId, event.toolName, event.input, verdict.approval);
2907
2921
  if (approved)
2908
2922
  return;
@@ -2962,4 +2976,4 @@ Continue the task.`);
2962
2976
  }
2963
2977
  }
2964
2978
 
2965
- export { AkanEditScope2, DevLogFeedback2, PreviewChrome2, PreviewView2, PreviewFeedback2, TurnFeedback2, AkanCli2, AkanVerifier2, VerifyFeedback2, AkanToolPack2, MailToolPack2, McpUnauthorized2, McpClient2, McpToolPack2, SessionToolPack2, WebToolPack2, AkanCodePlugins2, AkanEnvKeys2, akanSystemPrompt2, CodeSessionIndex2, AkanCodeServices2, CodeAgentAsks2, CodeAgentEventMapper2, CodeAgentGate2, CodeAgentUi2, CodeMailbox2, CodeSessionFork2, CodeAgent2 };
2979
+ export { AkanEditScope2, DevLogFeedback2, PreviewFeedback2, TurnFeedback2, AkanCli2, AkanVerifier2, VerifyFeedback2, AkanToolPack2, MailToolPack2, McpUnauthorized2, McpClient2, McpToolPack2, SessionToolPack2, WebToolPack2, AkanCodePlugins2, AkanEnvKeys2, akanSystemPrompt2, CodeSessionIndex2, AkanCodeServices2, CodeAgentAsks2, CodeAgentEventMapper2, CodeAgentGate2, CodeAgentUi2, CodeMailbox2, CodeSessionFork2, CodeAgent2 };