@akanjs/cli 3.2.0-rc.0 → 3.2.0-rc.10

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 (98) hide show
  1. package/.build-stamp +2 -1
  2. package/{CodeAgent-h6g8dg3a.js → CodeAgent-fk66n37w.js} +3 -3
  3. package/{CodeTui-n9gacepn.js → CodeTui-4rf1mqmv.js} +1 -1
  4. package/README.ko.md +26 -1
  5. package/README.md +26 -1
  6. package/TunnelShare-44er4e29.js +15 -0
  7. package/{agent.command-2f657613.js → agent.command-7g9czkkd.js} +20 -19
  8. package/akanCode.js +6 -6
  9. package/{application.command-yb8v177e.js → application.command-00spg55s.js} +31 -24
  10. package/{applicationBuildRunner-sctcmkyx.js → applicationBuildRunner-f4yf0qyc.js} +9 -7
  11. package/buildBatch.proc.js +7 -6
  12. package/{cloud.command-et06ja22.js → cloud.command-ab704p0g.js} +24 -25
  13. package/cloud.script-4p4y0s7e.js +31 -0
  14. package/{code.command-7m67c7zc.js → code.command-m6c9xk56.js} +7 -6
  15. package/{context.command-569z0rqf.js → context.command-hgcgxtdk.js} +20 -19
  16. package/context.runner-w071gmc3.js +30 -0
  17. package/{devTui-evr3b35y.js → devTui-h77zrjv5.js} +1 -1
  18. package/{guideline.command-gnv3e8p8.js → guideline.command-6yz6d4hf.js} +3 -2
  19. package/guidelines/agentRule/agentRule.instruction.md +4 -3
  20. package/guidelines/conventions/core.md +1 -1
  21. package/guidelines/conventions/rules/app.md +3 -0
  22. package/guidelines/conventions/rules/page.md +5 -0
  23. package/guidelines/errorCodes/errorCodes.instruction.md +140 -0
  24. package/guidelines/fieldRule/fieldRule.instruction.md +2 -1
  25. package/guidelines/mcpRule/mcpRule.instruction.md +28 -0
  26. package/guidelines/pageRule/pageRule.instruction.md +5 -0
  27. package/guidelines/runtimeRule/runtimeRule.instruction.md +5 -1
  28. package/guidelines/transportRule/transportRule.instruction.md +5 -0
  29. package/incrementalBuilder.proc.js +8 -7
  30. package/{index-vkzfk7qt.js → index-097bjwvm.js} +40 -30
  31. package/{index-93ewzmp6.js → index-23d8gw08.js} +165 -102
  32. package/{index-p6hjwt2d.js → index-41mfhgq0.js} +72 -26
  33. package/{index-ktb3wcqz.js → index-4k9nv4m3.js} +71 -81
  34. package/{index-ryrm5z2c.js → index-5jwx4bf2.js} +69 -33
  35. package/{index-5w9my9qe.js → index-6eptmk8z.js} +30 -20
  36. package/{index-d4n1wmrz.js → index-6fnrhpn1.js} +8 -4
  37. package/{index-kpdv34rq.js → index-6qtxs86x.js} +10 -7
  38. package/{index-ed6ea0qp.js → index-6z57w95f.js} +1 -1
  39. package/{index-drz9e84d.js → index-7ky4brfy.js} +2 -2
  40. package/{index-8g7tdsk4.js → index-849qvd7t.js} +58 -29
  41. package/{index-1q1cjn8s.js → index-9xh4zvw3.js} +94 -53
  42. package/{index-48d5qsj3.js → index-adj7qmz9.js} +23 -15
  43. package/{index-fjr4d6yd.js → index-apcr1qgk.js} +458 -304
  44. package/{index-8ts9774g.js → index-aybfcx58.js} +9 -4
  45. package/{index-3wjbhj2n.js → index-b3pr4ee6.js} +1 -1
  46. package/{index-tenw3mah.js → index-b4qq3rq0.js} +32 -7
  47. package/{index-thckcabc.js → index-bper31wr.js} +24 -6
  48. package/{index-jdamtr7e.js → index-bxkx0x03.js} +17 -10
  49. package/{index-0fb3cpbt.js → index-c3r23w24.js} +9 -7
  50. package/{index-8pb9yvp8.js → index-dfsa009c.js} +148 -31
  51. package/{index-zpv14wpy.js → index-dsg50er9.js} +3 -3
  52. package/{index-hqrkqxx2.js → index-e5f6czck.js} +46 -7
  53. package/{index-sy481q2x.js → index-frvjq1rd.js} +1 -1
  54. package/{index-abgh0jve.js → index-grt0e6kk.js} +1 -1
  55. package/{index-e3vmjtph.js → index-hf9nvwam.js} +7 -2
  56. package/{index-zxsygkda.js → index-hhagjhkh.js} +7 -7
  57. package/index-j4yvgfhr.js +70 -0
  58. package/{index-s2grpzef.js → index-k2r3hmbz.js} +6 -4
  59. package/{index-7y5yghjg.js → index-nd39rssn.js} +1162 -435
  60. package/{index-6wpaq392.js → index-p4htjyvk.js} +44 -5
  61. package/{index-aj3ehkcx.js → index-p54s83sz.js} +1 -1
  62. package/{index-7xdpww43.js → index-rdx8cyv2.js} +342 -134
  63. package/{index-sr5da35e.js → index-sq9d0jhj.js} +21 -18
  64. package/{index-eajbmk10.js → index-t4d0ckde.js} +2 -2
  65. package/{index-mqntfzv5.js → index-t8h09yjs.js} +7 -2
  66. package/index-va90m8nd.js +25 -0
  67. package/{index-rc5fvqj2.js → index-xfv2p7b5.js} +95 -58
  68. package/{index-w639tvkd.js → index-xgqz3kak.js} +29 -8
  69. package/{index-9tbgb4d8.js → index-xy70tcv4.js} +1 -1
  70. package/{index-mmym5xmb.js → index-z43wddce.js} +5 -3
  71. package/index.js +24 -23
  72. package/{library.command-1gp5qe3r.js → library.command-kc1zahcg.js} +5 -4
  73. package/{localRegistry.command-v3g21rex.js → localRegistry.command-bz2df40m.js} +19 -18
  74. package/{module.command-4xz9he6h.js → module.command-cchwzz9r.js} +12 -7
  75. package/{package.command-s7qpnn1g.js → package.command-qcjajpv8.js} +8 -7
  76. package/package.json +2 -2
  77. package/{page.command-fan34c49.js → page.command-1t86dx8a.js} +4 -3
  78. package/{pipeline.command-ph4fnn9w.js → pipeline.command-2xx9z3d0.js} +3 -2
  79. package/{primitive.command-3fqh8emf.js → primitive.command-mc0x8txr.js} +8 -7
  80. package/{projectTypecheck-vkb40hjc.js → projectTypecheck-tz497yx7.js} +2 -1
  81. package/{quality.command-ecj6exsh.js → quality.command-11rayf5c.js} +7 -6
  82. package/{repair.command-fe9jw719.js → repair.command-8w41vy78.js} +7 -6
  83. package/{scalar.command-cnvfhk0n.js → scalar.command-rvwh98ny.js} +7 -6
  84. package/skills/akan-debug/SKILL.md +7 -3
  85. package/skills/akan-err/SKILL.md +7 -0
  86. package/skills/akan-mcp/SKILL.md +7 -1
  87. package/skills/akan-scaffold/SKILL.md +3 -2
  88. package/skills/akan-transport/SKILL.md +2 -0
  89. package/skills/akan-validate/SKILL.md +1 -0
  90. package/{subspace.command-yxtt3v3e.js → subspace.command-0970n7kd.js} +9 -8
  91. package/{tunnel.command-ggj38mqf.js → tunnel.command-bcy0rtmh.js} +8 -7
  92. package/typecheck.proc.js +5 -2
  93. package/{verify.command-w9ttxkdz.js → verify.command-ynaztxr2.js} +18 -16
  94. package/{workflow.command-ss8devj0.js → workflow.command-yp9ajthb.js} +45 -16
  95. package/{workspace.command-rw1p0xeq.js → workspace.command-e4wfxm86.js} +39 -34
  96. package/TunnelShare-k3ja4w9x.js +0 -14
  97. package/cloud.script-s6rbrwer.js +0 -30
  98. package/context.runner-ms8v1rxy.js +0 -29
@@ -3,6 +3,10 @@ import {
3
3
  getDirname2,
4
4
  FileSys2
5
5
  } from "./index-bns3wcpc.js";
6
+ import {
7
+ CliError,
8
+ TypecheckFailure
9
+ } from "./index-j4yvgfhr.js";
6
10
 
7
11
  // pkgs/@akanjs/devkit/executors.ts
8
12
  import {
@@ -1375,8 +1379,8 @@ class StoreBootstrap {
1375
1379
  const runtime = exports.get("usePage");
1376
1380
  const store = exports.get("st");
1377
1381
  if (!runtime || runtime.namespace || !store || store.namespace)
1378
- return StoreBootstrap.#lines([specifier]);
1379
- return StoreBootstrap.#lines([...new Set([runtime.subpath, store.subpath])]);
1382
+ return [specifier];
1383
+ return [...new Set([runtime.subpath, store.subpath])];
1380
1384
  }
1381
1385
  static #lines(specifiers) {
1382
1386
  return specifiers.map((specifier) => `import ${JSON.stringify(specifier)};`);
@@ -1423,9 +1427,17 @@ function getRootBoundarySegments(key) {
1423
1427
  return [];
1424
1428
  return prefix.split("/").filter(Boolean);
1425
1429
  }
1430
+ var ROOT_LAYOUT_SYSTEM = {
1431
+ specifier: "akanjs/ui/System/index.tsx",
1432
+ ssrShell: "akanjs/ui/System/SSR.tsx",
1433
+ importsNoSsrPageRenders: ["./CSR", "./App"]
1434
+ };
1426
1435
  function implicitRootLayoutKey(segments) {
1427
1436
  return `./${[...segments, "__root_layout"].join("/")}.tsx`;
1428
1437
  }
1438
+ function isImplicitRootLayoutKey(key) {
1439
+ return key.endsWith("/__root_layout.tsx");
1440
+ }
1429
1441
  function implicitRootLayoutAbsPath(appCwdPath, segments) {
1430
1442
  const filename = segments.length ? `${segments.join("__")}__root_layout.tsx` : "__root_layout.tsx";
1431
1443
  return path6.join(path6.resolve(appCwdPath), IMPLICIT_LAYOUT_DIR, filename);
@@ -1535,7 +1547,7 @@ ${layoutBinding} return `;
1535
1547
  const source = opts.includeSystemProvider ? `import type { LayoutModule, LayoutProps, PageProps } from "akanjs/client";
1536
1548
  import { assertGuardOnChain, loadFonts, RouteGuards, resolveRouteModule, RouteHead } from "akanjs/client";
1537
1549
  import type { ReactNode } from "react";
1538
- import { System } from "akanjs/ui/System/index.tsx";
1550
+ import { System } from "${ROOT_LAYOUT_SYSTEM.specifier}";
1539
1551
  import type { McpAppRootProps } from "akanjs/webkit";
1540
1552
  import { env } from "@apps/${opts.appName}/env/env.client";
1541
1553
  import { allDictionary } from ${JSON.stringify(dictMacroSpecifier)};
@@ -1548,6 +1560,7 @@ const defaultFontClassName = defaultFont ? (defaultFont.className ?? \`font-\${d
1548
1560
  export const theme = userLayout.theme ?? inheritedLayout.theme;
1549
1561
  export const viewport = userLayout.viewport ?? inheritedLayout.viewport;
1550
1562
  export const manifest = userLayout.manifest ?? inheritedLayout.manifest;
1563
+ export { RouteLevelBoundary as LevelBoundary } from "akanjs/webkit/RouteLevelBoundary.tsx";
1551
1564
 
1552
1565
  ${layoutExports}(
1553
1566
  <System.Provider
@@ -2972,19 +2985,6 @@ class Spinner {
2972
2985
  // pkgs/@akanjs/devkit/typecheck/projectTypecheck.ts
2973
2986
  import { mkdir as mkdir2, rm as rm3 } from "fs/promises";
2974
2987
  import path13 from "path";
2975
-
2976
- // pkgs/@akanjs/devkit/typecheck/typecheckFailure.ts
2977
- class TypecheckFailure extends Error {
2978
- records;
2979
- constructor(records) {
2980
- super(records.slice(0, 20).map((record) => `${record.file ?? "-"}:${record.line}:${record.col} ${record.code} ${record.message}`).join(`
2981
- `) || "Typecheck failed");
2982
- this.records = records;
2983
- this.name = "TypecheckFailure";
2984
- }
2985
- }
2986
-
2987
- // pkgs/@akanjs/devkit/typecheck/projectTypecheck.ts
2988
2988
  class ProjectTypecheck2 {
2989
2989
  projectDir;
2990
2990
  workspaceRoot;
@@ -3039,7 +3039,10 @@ class ProjectTypecheck2 {
3039
3039
  const records = report === "records" ? ProjectTypecheck2.#parseRecords(stdout) : null;
3040
3040
  if (records?.length)
3041
3041
  throw new TypecheckFailure(records);
3042
- throw new Error((stderr || stdout).trim() || `Typecheck failed with exit code ${exitCode}`);
3042
+ const output = (stderr || stdout).trim();
3043
+ if (exitCode === TypecheckFailure.workerExitCode && report === "pretty")
3044
+ throw new CliError("checkFailed", output || "Typecheck failed");
3045
+ throw new Error(output || `Typecheck failed with exit code ${exitCode}`);
3043
3046
  }
3044
3047
  static #parseRecords(stdout) {
3045
3048
  try {
@@ -4505,4 +4508,4 @@ class ModuleExecutor extends Executor {
4505
4508
  }
4506
4509
  }
4507
4510
 
4508
- export { AGENT_BLOCK_START, AGENT_BLOCK_END, stampBlockVersion, extractBlockVersion, readDevkitVersion, upsertAgentBlock, extractAgentBlock, renderRecipeEntries, collectScopeRecipeSources, renderScopeAgentBlock, CLAUDE_COMMENT_RULE, binPlatforms, ServerEnvProfile, AkanAppConfig, AkanWorkspaceConfig, AsyncDefaultExportDetector, StoreBootstrap, resolveSsrPageEntriesForApp, CodegenLock, JsonFormatter, parseBiomeReport, Linter, LibSource, formatLibStatuses, rootAllowedFiles, rootAllowedDirs, isAllowedLibFacetRootFile, libFacetRootHintOf, barrelFacetDirs, facetIndexShadowOf, rootEntryHintOf, isScannedRootEntry, AppInfo, Spinner, TypecheckFailure, ProjectTypecheck2, CommandExecutionError, parseEnvFile, Executor, WorkspaceExecutor, SysExecutor, AppExecutor, LibExecutor, PkgExecutor, ModuleExecutor };
4511
+ export { AGENT_BLOCK_START, AGENT_BLOCK_END, stampBlockVersion, extractBlockVersion, readDevkitVersion, upsertAgentBlock, extractAgentBlock, renderRecipeEntries, collectScopeRecipeSources, renderScopeAgentBlock, CLAUDE_COMMENT_RULE, binPlatforms, ServerEnvProfile, AkanAppConfig, AkanWorkspaceConfig, AsyncDefaultExportDetector, StoreBootstrap, ROOT_LAYOUT_SYSTEM, isImplicitRootLayoutKey, resolveSsrPageEntriesForApp, CodegenLock, JsonFormatter, parseBiomeReport, Linter, LibSource, formatLibStatuses, rootAllowedFiles, rootAllowedDirs, isAllowedLibFacetRootFile, libFacetRootHintOf, barrelFacetDirs, facetIndexShadowOf, rootEntryHintOf, isScannedRootEntry, AppInfo, Spinner, ProjectTypecheck2, CommandExecutionError, parseEnvFile, Executor, WorkspaceExecutor, SysExecutor, AppExecutor, LibExecutor, PkgExecutor, ModuleExecutor };
@@ -11,7 +11,7 @@ var moduleInput = {
11
11
  module: {
12
12
  type: "string",
13
13
  required: true,
14
- description: "Target domain, service, or scalar module name.",
14
+ description: "An existing database module, one with lib/<module>/<module>.constant.ts; not a service or scalar module.",
15
15
  mustExist: true
16
16
  }
17
17
  };
@@ -95,7 +95,7 @@ var addFieldWorkflowSpec = {
95
95
  type: {
96
96
  type: "string",
97
97
  required: true,
98
- description: "Field type or scalar name. Use Int for integer fields or Float for decimal fields; do not use Number."
98
+ description: "Field type: a built-in or akanjs/base type, or a scalar or model of the target by class name, which apply imports. Use Int for integer fields or Float for decimal fields; do not use Number."
99
99
  },
100
100
  values: { type: "string-list", description: "Comma-separated enum values when type is enum." },
101
101
  default: {
@@ -2,13 +2,16 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-93ewzmp6.js";
5
+ } from "./index-23d8gw08.js";
6
6
  import {
7
7
  LibSource,
8
8
  formatLibStatuses,
9
9
  CommandExecutionError,
10
10
  LibExecutor
11
- } from "./index-sr5da35e.js";
11
+ } from "./index-sq9d0jhj.js";
12
+ import {
13
+ assertPlainName
14
+ } from "./index-va90m8nd.js";
12
15
 
13
16
  // pkgs/@akanjs/cli/library/library.script.ts
14
17
  import { Logger } from "akanjs/common";
@@ -148,6 +151,7 @@ class LibraryScript extends script("library", [LibraryRunner]) {
148
151
  return scanInfo;
149
152
  }
150
153
  async createLibrary(libName, workspace) {
154
+ assertPlainName("lib", libName);
151
155
  const spinner = workspace.spinning(`Creating ${libName} library`);
152
156
  const lib = await this.libraryRunner.createLibrary(libName, workspace);
153
157
  spinner.succeed(`${libName} library (libs/${libName}) is created`);
@@ -166,6 +170,7 @@ class LibraryScript extends script("library", [LibraryRunner]) {
166
170
  Logger.rawLog(format === "json" ? JSON.stringify(statuses, null, 2) : formatLibStatuses(statuses));
167
171
  }
168
172
  async installLibrary(workspace, libName) {
173
+ assertPlainName("lib", libName);
169
174
  const installSpinner = workspace.spinning(`Installing ${libName} library`);
170
175
  const lib = await this.libraryRunner.installLibrary(workspace, libName);
171
176
  installSpinner.succeed(`${libName} library (libs/${libName}) is installed`);
@@ -0,0 +1,25 @@
1
+ // @bun
2
+ // pkgs/@akanjs/devkit/workflow/plainName.ts
3
+ var sysNamePattern = /^[a-z0-9][a-zA-Z0-9_-]*$/;
4
+ var identifierPattern = /^_{0,2}[a-zA-Z][a-zA-Z0-9_-]*$/;
5
+ var packageNamePattern = /^(@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/;
6
+ var isWorkflowSysName = (value) => typeof value === "string" && sysNamePattern.test(value);
7
+ var isWorkflowModuleName = (value) => typeof value === "string" && identifierPattern.test(value);
8
+ var plainNameProblem = (kind, name) => {
9
+ const isSys = kind === "app" || kind === "lib";
10
+ if (isSys ? isWorkflowSysName(name) : isWorkflowModuleName(name))
11
+ return null;
12
+ return `${JSON.stringify(name)} is no ${kind} name; use letters, digits, - and _, starting with ${isSys ? "a lowercase letter or digit" : "a letter"}`;
13
+ };
14
+ var assertPlainName = (kind, name) => {
15
+ const problem = plainNameProblem(kind, name);
16
+ if (problem)
17
+ throw new Error(problem);
18
+ };
19
+ var assertPackageName = (name) => {
20
+ if (packageNamePattern.test(name))
21
+ return;
22
+ throw new Error(`${JSON.stringify(name)} is no package name; use name or @scope/name, each of lowercase letters, digits, -, . and _, starting with a letter or digit`);
23
+ };
24
+
25
+ export { sysNamePattern, identifierPattern, isWorkflowSysName, isWorkflowModuleName, plainNameProblem, assertPlainName, assertPackageName };
@@ -1,13 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  AppExecutor
4
- } from "./index-sr5da35e.js";
5
- import {
6
- jsonText,
7
- createWorkflowBaselineSummary,
8
- buildAkanModuleContextIndex,
9
- toolingRolloutGate
10
- } from "./index-8pb9yvp8.js";
4
+ } from "./index-sq9d0jhj.js";
11
5
  import {
12
6
  buildResourceList,
13
7
  codexMcpConfigPath,
@@ -17,16 +11,23 @@ import {
17
11
  upsertCodexMcpServerBlock,
18
12
  renderDoctorText,
19
13
  AkanContextAnalyzer
20
- } from "./index-thckcabc.js";
14
+ } from "./index-bper31wr.js";
15
+ import {
16
+ jsonText,
17
+ workflowStatus,
18
+ createWorkflowBaselineSummary,
19
+ buildAkanModuleContextIndex,
20
+ toolingRolloutGate
21
+ } from "./index-dfsa009c.js";
21
22
  import {
22
23
  runner
23
- } from "./index-93ewzmp6.js";
24
+ } from "./index-23d8gw08.js";
24
25
  import {
25
26
  NativeApp
26
- } from "./index-zpv14wpy.js";
27
+ } from "./index-dsg50er9.js";
27
28
  import {
28
29
  isPlaceholderAppId
29
- } from "./index-ed6ea0qp.js";
30
+ } from "./index-6z57w95f.js";
30
31
  import {
31
32
  getMobileTargets,
32
33
  appIdsOf
@@ -36,18 +37,32 @@ import {
36
37
  } from "./index-j6eeh5d7.js";
37
38
  import {
38
39
  WorkspaceGraph
39
- } from "./index-w639tvkd.js";
40
+ } from "./index-xgqz3kak.js";
40
41
  import {
41
42
  RepairRunner
42
- } from "./index-0fb3cpbt.js";
43
+ } from "./index-c3r23w24.js";
43
44
  import {
44
45
  WorkflowRunner
45
- } from "./index-vkzfk7qt.js";
46
+ } from "./index-097bjwvm.js";
46
47
 
47
48
  // pkgs/@akanjs/devkit/akanMcpContract.ts
48
49
  import { lstatSync, realpathSync } from "fs";
49
50
  import path from "path";
50
51
  import { isRecord } from "akanjs/common";
52
+
53
+ // pkgs/@akanjs/devkit/akanMcpToolError.ts
54
+ import { AkanError } from "akanjs/base";
55
+
56
+ class AkanMcpToolError extends AkanError {
57
+ constructor(code, message) {
58
+ super(code, message, { statusCode: 400 });
59
+ }
60
+ static failureOf(error) {
61
+ return AkanError.is(error) ? { code: error.code, statusCode: error.statusCode } : { code: "toolFailed", statusCode: 500 };
62
+ }
63
+ }
64
+
65
+ // pkgs/@akanjs/devkit/akanMcpContract.ts
51
66
  var emptySchema = { type: "object", properties: {} };
52
67
  var stringProperty = { type: "string" };
53
68
  var booleanProperty = { type: "boolean" };
@@ -173,7 +188,7 @@ var workflowArtifactPath = (workspace, filePath) => {
173
188
  const root = path.resolve(workspace.workspaceRoot, workflowArtifactDir);
174
189
  const resolved = workflowRunIdPattern.test(filePath) && !filePath.endsWith(".json") ? path.join(root, "runs", `${filePath}.json`) : path.resolve(workspace.workspaceRoot, filePath);
175
190
  if (!isInside(root, resolved) || !staysInside(workspace.workspaceRoot, root, resolved))
176
- throw new Error(`MCP workflow files live under ${workflowArtifactDir}/ of the workspace, not ${JSON.stringify(filePath)}.`);
191
+ throw new AkanMcpToolError("invalidArgument", `MCP workflow files live under ${workflowArtifactDir}/ of the workspace, not ${JSON.stringify(filePath)}.`);
177
192
  return resolved;
178
193
  };
179
194
  var defaultWorkflowPlanPath = (workflow, inputs) => {
@@ -194,7 +209,7 @@ var defaultWorkflowPlanPath = (workflow, inputs) => {
194
209
  var applyFirstPolicy = {
195
210
  mode: "apply-first",
196
211
  directSourceEdits: "fallback-only",
197
- applyRequiredWhen: ["plan_workflow returns planPath", "plan_workflow returns next.tool=apply_workflow"],
212
+ applyRequiredWhen: ["plan_workflow returns next.tool=apply_workflow"],
198
213
  approvalMeaning: "requiresApproval is an agent/user review signal before apply_workflow mutates files; it is not a separate MCP permission gate.",
199
214
  validationRequiredAfterApply: ["validationTarget", "applyReportPath"],
200
215
  fallbackAllowedWhen: [
@@ -207,7 +222,7 @@ var applyFirstPolicy = {
207
222
  var stringArg = (args, key) => {
208
223
  const value = args[key];
209
224
  if (typeof value !== "string" || !value)
210
- throw new Error(`MCP tool argument "${key}" is required.`);
225
+ throw new AkanMcpToolError("invalidArgument", `MCP tool argument "${key}" is required.`);
211
226
  return value;
212
227
  };
213
228
  var workflowInputsArg = (args) => {
@@ -220,14 +235,14 @@ var inspectAkanContextPropsArg = (args) => {
220
235
  const question = stringArg(args, "question");
221
236
  const review = stringArg(args, "review");
222
237
  if (!isRecord(args.draft))
223
- throw new Error('MCP tool argument "draft" is required.');
238
+ throw new AkanMcpToolError("invalidArgument", 'MCP tool argument "draft" is required.');
224
239
  if (!isRecord(args.request))
225
- throw new Error('MCP tool argument "request" is required.');
240
+ throw new AkanMcpToolError("invalidArgument", 'MCP tool argument "request" is required.');
226
241
  if (!isInspectAkanContextRequestType(args.draft.type)) {
227
- throw new Error('MCP tool argument "draft.type" must be a supported inspect_akan_context request type.');
242
+ throw new AkanMcpToolError("invalidArgument", 'MCP tool argument "draft.type" must be a supported inspect_akan_context request type.');
228
243
  }
229
244
  if (!isInspectAkanContextRequestType(args.request.type)) {
230
- throw new Error('MCP tool argument "request.type" must be a supported inspect_akan_context request type.');
245
+ throw new AkanMcpToolError("invalidArgument", 'MCP tool argument "request.type" must be a supported inspect_akan_context request type.');
231
246
  }
232
247
  const base = { question, draft: { reason: stringArg(args.draft, "reason"), type: args.draft.type }, review };
233
248
  const request = args.request;
@@ -299,7 +314,7 @@ var readonlyMcpTools = [
299
314
  },
300
315
  {
301
316
  name: "get_graph",
302
- description: "Read-only Akan Graph from source, no dev server needed: models with their fields and relations, slices and endpoints with the guards they name (each guard keyed by the app or lib that declares it, with its scope and the comment that says what it checks), the service methods and queries each calls, the store actions that fetch them, and the components and routes that use them. A module's jobs (internal: interval, cron, timeout, initialize, destroy, process) read their schedule and server or operation modes and call service methods like endpoints do; each adaptor a service plugs (an adapt() class, or an akanjs role) is a node, a method that calls it links to it, and an adaptor links to the adaptors it plugs itself. Each page/ file is a route (its URL pattern after the locale) or a layout, layouts wrap what they contain, and a route or layout that runs .guard() reads `guard` and links each function its guard calls; a layout's guard gates every route it wraps. A graph too large to answer unscoped drops first the routes and layouts that neither changed nor use a change; app or module brings them back. Every node and edge carries its source location. Pass app and/or module to scope a large workspace. Pass since (a git revision such as main, or HEAD for uncommitted work) for the Change Map instead: what changed since HEAD forked from it, working tree included, with each node, field and edge marked added, removed or changed, the unchanged neighbours they call or are called by, and the changed files no node covers, each marked the same way.",
317
+ description: "Read-only Akan Graph from source, no dev server needed: models with their fields and relations, slices and endpoints with the guards they name (each guard keyed by the app or lib that declares it, with its scope and the comment that says what it checks), the service methods and queries each calls, the store actions that fetch them, and the components and routes that use them. A module's jobs (internal: interval, cron, timeout, initialize, destroy, process) read their schedule and server or operation modes and call service methods like endpoints do; each adaptor a service plugs (an adapt() class, or an akanjs role) is a node, a method that calls it links to it (an app service holds the fields its module's lib services plug, unless it declares the field itself), an adaptor links to the adaptors it plugs itself, a class from a package outside the workspace is adaptor:<package>:<Name>, and a role an app binds with applyAdaptor(Role, Impl) links to that implementation (binds, labelled with the app; a scope keeps its app's bindings). Each page/ file is a route (its URL pattern after the locale) or a layout, layouts wrap what they contain, and a route or layout that runs .guard() reads `guard` and links each function its guard calls; a layout's guard gates every route it wraps. A graph too large to answer unscoped drops first the routes and layouts that neither changed nor use a change; app or module brings them back. Every node and edge carries its source location. Pass app and/or module to scope a large workspace. Pass since (a git revision such as main, or HEAD for uncommitted work) for the Change Map instead: what changed since HEAD forked from it, working tree included, with each node, field and edge marked added, removed or changed, the unchanged neighbours they call or are called by, and the changed files no node covers, each marked the same way.",
303
318
  inputSchema: { type: "object", properties: { app: stringProperty, module: stringProperty, since: stringProperty } }
304
319
  },
305
320
  {
@@ -344,7 +359,7 @@ var planMcpTools = [
344
359
  },
345
360
  {
346
361
  name: "plan_workflow",
347
- description: "Create a read-only workflow plan after context inspection and return planPath plus next.tool=apply_workflow.",
362
+ description: "Create a read-only workflow plan after context inspection and return planPath, plus next.tool=apply_workflow unless a diagnostic is an error.",
348
363
  inputSchema: {
349
364
  type: "object",
350
365
  properties: { workflow: stringProperty, inputs: objectProperty, out: stringProperty },
@@ -355,7 +370,7 @@ var planMcpTools = [
355
370
  var applyMcpTools = [
356
371
  {
357
372
  name: "apply_workflow",
358
- description: "Apply a stored workflow plan before direct edits and return validationTarget for run_validation.",
373
+ description: "Apply a stored workflow plan before direct edits and return validationTarget. Unless it failed, next.tool is run_validation after an apply and apply_workflow without dryRun after a dry run.",
359
374
  inputSchema: {
360
375
  type: "object",
361
376
  properties: { planPath: stringProperty, dryRun: booleanProperty },
@@ -596,10 +611,24 @@ var inspectAkanContext = async (workspace, args) => {
596
611
  };
597
612
 
598
613
  // pkgs/@akanjs/cli/context/context.runner.ts
614
+ import { MCP_FAILURE_META } from "akanjs/common";
599
615
  var toolErrorText = (error) => {
600
616
  const message = error instanceof Error ? error.message : String(error);
601
617
  return message.replace(/\/(?:[^\s"'/]+\/)*(?=(?:pkgs|apps|libs|infra)\/)/g, "<workspace>/");
602
618
  };
619
+ var assertMcpToolListed = (name, mode) => {
620
+ const isListed = (tools) => tools.some((tool) => tool.name === name);
621
+ if (!isListed(listAkanMcpTools("apply")))
622
+ throw new AkanMcpToolError("unknownTool", `Unknown tool: ${name}`);
623
+ if (!isListed(listAkanMcpTools(mode)))
624
+ throw new AkanMcpToolError("toolUnavailable", `MCP tool "${name}" is not available in ${mode} mode.`);
625
+ };
626
+ var guidelineOf = async (name) => {
627
+ const guidelines = await Prompter2.listGuidelines();
628
+ if (!guidelines.includes(name))
629
+ throw new AkanMcpToolError("invalidArgument", `Unknown guideline "${name}". Available: ${guidelines.join(", ")}`);
630
+ return await Prompter2.getInstruction(name);
631
+ };
603
632
  var compactDoctorWorkspaceResult = (result, includeBaselineDetails) => {
604
633
  const baselineDiagnostics = result.baselineDiagnostics ?? [];
605
634
  const baselineSummary = createWorkflowBaselineSummary(baselineDiagnostics.map(({ severity, code, message, scope, context }) => ({
@@ -636,7 +665,7 @@ class ContextRunner2 extends runner("context") {
636
665
  if (ios)
637
666
  return await this.#doctorIos(workspace, format);
638
667
  const result = await AkanContextAnalyzer.doctor(workspace, { strict });
639
- return format === "json" ? jsonText(result) : renderDoctorText(result);
668
+ return { status: result.status, output: format === "json" ? jsonText(result) : renderDoctorText(result) };
640
669
  }
641
670
  async#doctorIos(workspace, format) {
642
671
  const appNames = await workspace.getApps();
@@ -672,7 +701,7 @@ class ContextRunner2 extends runner("context") {
672
701
  }
673
702
  const status = diagnostics.some((diagnostic) => diagnostic.severity === "error") ? "failed" : "passed";
674
703
  if (format === "json")
675
- return jsonText({ schemaVersion: 1, kind: "ios", status, diagnostics });
704
+ return { status, output: jsonText({ schemaVersion: 1, kind: "ios", status, diagnostics }) };
676
705
  const lines = [`Akan iOS diagnostics for ${workspace.repoName}`];
677
706
  if (diagnostics.length === 0)
678
707
  lines.push(" No native configuration issues found.");
@@ -681,8 +710,8 @@ class ContextRunner2 extends runner("context") {
681
710
  lines.push(` [${diagnostic.severity}] ${diagnostic.code}: ${diagnostic.message}`);
682
711
  lines.push(` ${diagnostic.path}`);
683
712
  }
684
- return lines.join(`
685
- `);
713
+ return { status, output: lines.join(`
714
+ `) };
686
715
  }
687
716
  async getGuidelineResource(name) {
688
717
  return await Prompter2.getInstruction(name);
@@ -715,10 +744,7 @@ class ContextRunner2 extends runner("context") {
715
744
  return listAkanMcpTools(mode, { guidelineNames });
716
745
  }
717
746
  async callMcpTool(workspace, name, args = {}, { mode = "readonly" } = {}) {
718
- const availableTools = this.listMcpTools(mode);
719
- if (!availableTools.some((tool) => tool.name === name)) {
720
- throw new Error(`MCP tool "${name}" is not available in ${mode} mode.`);
721
- }
747
+ assertMcpToolListed(name, mode);
722
748
  if (name === "inspect_akan_context")
723
749
  return await inspectAkanContext(workspace, args);
724
750
  if (name === "get_workspace_summary" || name === "list_apps" || name === "list_modules" || name === "get_module_context") {
@@ -764,7 +790,7 @@ class ContextRunner2 extends runner("context") {
764
790
  return typeof args.since === "string" ? WorkspaceGraph.answerChanges(await WorkspaceGraph.changes(workspace, args.since), scope) : WorkspaceGraph.answer(await WorkspaceGraph.build(workspace), scope);
765
791
  }
766
792
  if (name === "get_guideline")
767
- return await Prompter2.getInstruction(stringArg(args, "name"));
793
+ return await guidelineOf(stringArg(args, "name"));
768
794
  if (name === "doctor_workspace")
769
795
  return compactDoctorWorkspaceResult(await AkanContextAnalyzer.doctor(workspace, {
770
796
  strict: !!args.strict,
@@ -785,29 +811,17 @@ class ContextRunner2 extends runner("context") {
785
811
  const planPath = typeof args.out === "string" && args.out ? args.out : defaultWorkflowPlanPath(workflow, inputs);
786
812
  const out = workflowArtifactPath(workspace, planPath);
787
813
  const plan = parseJsonOutput(await new WorkflowRunner().plan(workflow, inputs, { format: "json", out, workspace }));
814
+ const applicable = workflowStatus(plan.diagnostics) === "passed";
788
815
  return {
789
816
  ...plan,
790
817
  planPath,
791
- approval: typeof plan === "object" && plan && "approval" in plan ? { ...plan.approval, canApplyWith: { planPath } } : undefined,
792
- next: { tool: "apply_workflow", args: { planPath } },
793
- policy: applyFirstPolicy
794
- };
795
- }
796
- if (name === "apply_workflow") {
797
- const report = parseJsonOutput(await new WorkflowRunner().apply(workflowArtifactPath(workspace, stringArg(args, "planPath")), {
798
- format: "json",
799
- dryRun: !!args.dryRun,
800
- workspace,
801
- registry: WorkflowRunner.stepRegistry(workspace)
802
- }));
803
- const validationTarget = typeof report.validationTarget === "string" ? report.validationTarget : typeof report.applyReportPath === "string" ? report.applyReportPath : stringArg(args, "planPath");
804
- return {
805
- ...report,
806
- validationTarget,
807
- next: { tool: "run_validation", args: { runIdOrPlan: validationTarget } },
818
+ approval: plan.approval && applicable ? { ...plan.approval, canApplyWith: { planPath } } : plan.approval,
819
+ ...applicable ? { next: { tool: "apply_workflow", args: { planPath } } } : {},
808
820
  policy: applyFirstPolicy
809
821
  };
810
822
  }
823
+ if (name === "apply_workflow")
824
+ return await this.#applyWorkflow(workspace, args);
811
825
  if (name === "run_validation")
812
826
  return parseJsonOutput(await new WorkflowRunner().validate(workflowArtifactPath(workspace, stringArg(args, "runIdOrPlan")), {
813
827
  format: "json",
@@ -831,7 +845,36 @@ class ContextRunner2 extends runner("context") {
831
845
  module: stringArg(args, "module"),
832
846
  format: "json"
833
847
  }));
834
- throw new Error(`Unknown tool: ${name}`);
848
+ throw new AkanMcpToolError("unknownTool", `Unknown tool: ${name}`);
849
+ }
850
+ async answerMcpTool(workspace, name, args, { mode = "readonly" } = {}) {
851
+ try {
852
+ const result = await this.callMcpTool(workspace, name, args, { mode });
853
+ const text = typeof result === "string" ? result : jsonText(result, { trailingNewline: false });
854
+ return { content: [{ type: "text", text }] };
855
+ } catch (error) {
856
+ return {
857
+ content: [{ type: "text", text: toolErrorText(error) }],
858
+ isError: true,
859
+ _meta: { [MCP_FAILURE_META]: AkanMcpToolError.failureOf(error) }
860
+ };
861
+ }
862
+ }
863
+ async#applyWorkflow(workspace, args) {
864
+ const planPath = stringArg(args, "planPath");
865
+ const report = parseJsonOutput(await new WorkflowRunner().apply(workflowArtifactPath(workspace, planPath), {
866
+ format: "json",
867
+ dryRun: !!args.dryRun,
868
+ workspace,
869
+ registry: WorkflowRunner.stepRegistry(workspace)
870
+ }));
871
+ const validationTarget = typeof report.validationTarget === "string" ? report.validationTarget : typeof report.applyReportPath === "string" ? report.applyReportPath : planPath;
872
+ return {
873
+ ...report,
874
+ validationTarget,
875
+ ...report.status === "failed" ? {} : args.dryRun ? { next: { tool: "apply_workflow", args: { planPath } } } : { next: { tool: "run_validation", args: { runIdOrPlan: validationTarget } } },
876
+ policy: applyFirstPolicy
877
+ };
835
878
  }
836
879
  async runMcp(workspace, { mode = "readonly" } = {}) {
837
880
  const decoder = new TextDecoder;
@@ -895,13 +938,7 @@ ${payload}`);
895
938
  } else if (request.method === "tools/call") {
896
939
  const name = params.name;
897
940
  const args = params.arguments ?? {};
898
- try {
899
- const result = await this.callMcpTool(workspace, name, args, { mode });
900
- const text = typeof result === "string" ? result : jsonText(result, { trailingNewline: false });
901
- respond(request.id, { content: [{ type: "text", text }] }, framing);
902
- } catch (error) {
903
- respond(request.id, { content: [{ type: "text", text: toolErrorText(error) }], isError: true }, framing);
904
- }
941
+ respond(request.id, await this.answerMcpTool(workspace, name, args, { mode }), framing);
905
942
  } else if (request.method === "resources/list") {
906
943
  respond(request.id, { resources }, framing);
907
944
  } else if (request.method === "resources/read") {
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  AkanGraphDiff,
4
4
  AkanIndex
5
- } from "./index-7y5yghjg.js";
5
+ } from "./index-nd39rssn.js";
6
6
  import {
7
7
  GitRevision
8
8
  } from "./index-ygdbn9jn.js";
@@ -47,12 +47,14 @@ class WorkspaceGraph {
47
47
  const mapped = new Set([
48
48
  ...changes.nodes.filter((node) => node.change).flatMap((node) => [
49
49
  node.at?.file,
50
+ ...node.sources ?? [],
50
51
  ...(node.fields ?? []).filter((field) => field.change).map(({ at }) => at.file)
51
52
  ]),
52
53
  ...changes.edges.filter((edge) => edge.change).map((edge) => edge.at?.file)
53
54
  ]);
54
55
  const unmapped = files.filter(({ file }) => !mapped.has(file) && !hiddenPath.test(file));
55
- return { ...changes, since: sha.slice(0, 12), unmapped };
56
+ const nodes = changes.nodes.map(({ sources: _sources, ...node }) => node);
57
+ return { ...changes, nodes, since: sha.slice(0, 12), unmapped };
56
58
  }
57
59
  static #baseAt(root, sha) {
58
60
  const key = `${root}
@@ -84,9 +86,22 @@ ${sha}`;
84
86
  const seeds = new Set(graph.nodes.filter((node) => (!owners || owners.has(node.owner ?? "")) && (!module || node.module === module)).map((node) => node.id));
85
87
  const guards = new Set(graph.nodes.filter((node) => node.kind === "guard").map((node) => node.id));
86
88
  const reaches = (id) => seeds.has(id) && !guards.has(id);
87
- const edges = graph.edges.filter((edge) => reaches(edge.from) || reaches(edge.to));
88
- const ids = new Set([...seeds, ...edges.flatMap((edge) => [edge.from, edge.to])]);
89
- return { version: 1, nodes: graph.nodes.filter((node) => ids.has(node.id)), edges };
89
+ const edges = graph.edges.filter((edge) => edge.kind !== "binds" && (reaches(edge.from) || reaches(edge.to)));
90
+ const kept = new Set([...seeds, ...edges.flatMap((edge) => [edge.from, edge.to])]);
91
+ const isLib = !!app && graph.nodes.some((node) => node.owner === `libs/${app}`) && !graph.nodes.some((node) => node.owner === `apps/${app}`);
92
+ const applicable = WorkspaceGraph.#bindingsOf(graph, app && !isLib ? `apps/${app}` : null);
93
+ const isOwn = (edge) => !module && !!owners?.has(edge.label ?? "");
94
+ const roles = new Set(applicable.filter((edge) => isOwn(edge) || kept.has(edge.from) || reaches(edge.to)).map((edge) => edge.from));
95
+ const bindings = applicable.filter((edge) => roles.has(edge.from));
96
+ const ids = new Set([...kept, ...bindings.flatMap((edge) => [edge.from, edge.to])]);
97
+ return { version: 1, nodes: graph.nodes.filter((node) => ids.has(node.id)), edges: [...edges, ...bindings] };
98
+ }
99
+ static #bindingsOf(graph, appOwner) {
100
+ const binds = graph.edges.filter((edge) => edge.kind === "binds");
101
+ if (!appOwner)
102
+ return binds;
103
+ const own = new Set(binds.filter((edge) => edge.label === appOwner && edge.change !== "removed").map((edge) => edge.from));
104
+ return binds.filter((edge) => edge.label === appOwner || !edge.label?.startsWith("apps/") && !own.has(edge.from));
90
105
  }
91
106
  static #withoutPages(graph) {
92
107
  const changed = new Set(graph.nodes.filter((node) => node.change).map((node) => node.id));
@@ -103,7 +118,12 @@ ${sha}`;
103
118
  const isVisible = ({ owner }) => !owner || owner === appOwner || owner.startsWith("libs/");
104
119
  const nodes = graph.nodes.filter(isVisible);
105
120
  const ids = new Set(nodes.map((node) => node.id));
106
- return { version: 1, nodes, edges: graph.edges.filter((edge) => ids.has(edge.from) && ids.has(edge.to)) };
121
+ const bindings = new Set(WorkspaceGraph.#bindingsOf(graph, appOwner));
122
+ return {
123
+ version: 1,
124
+ nodes,
125
+ edges: graph.edges.filter((edge) => ids.has(edge.from) && ids.has(edge.to) && (edge.kind !== "binds" || bindings.has(edge)))
126
+ };
107
127
  }
108
128
  static changesVisibleTo(changes, app) {
109
129
  const visible = WorkspaceGraph.visibleTo(changes, app);
@@ -145,16 +165,17 @@ ${sha}`;
145
165
  const unscoped = WorkspaceGraph.#withoutPages(graph);
146
166
  if (unscoped.nodes.length <= unscopedNodeLimit)
147
167
  return unscoped;
168
+ const kept = new Set(unscoped.nodes.map((node) => node.id));
148
169
  const owners = new Map;
149
170
  for (const node of counted)
150
- if (node.owner && !pageKinds.has(node.kind))
171
+ if (node.owner && kept.has(node.id))
151
172
  owners.set(node.owner, (owners.get(node.owner) ?? 0) + 1);
152
173
  return {
153
174
  diagnostics: [
154
175
  {
155
176
  severity: "error",
156
177
  code: "graph-scope-required",
157
- message: `The graph has ${unscoped.nodes.length} nodes besides its pages. Pass app, module or both to scope it.`,
178
+ message: `The graph has ${unscoped.nodes.length} nodes once unchanged pages are set aside. Pass app, module or both to scope it.`,
158
179
  input: "app"
159
180
  }
160
181
  ],
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  GlobalConfig,
4
4
  CloudApi
5
- } from "./index-drz9e84d.js";
5
+ } from "./index-7ky4brfy.js";
6
6
 
7
7
  // pkgs/@akanjs/cli/tunnel/TunnelShare.ts
8
8
  import { TunnelAgent } from "akanjs/server/tunnel";
@@ -1,15 +1,16 @@
1
1
  // @bun
2
2
  import {
3
3
  resolveSsrPageEntriesForApp
4
- } from "./index-sr5da35e.js";
4
+ } from "./index-sq9d0jhj.js";
5
5
  import {
6
6
  createBarrelImportsPlugin,
7
+ workspaceBarrels,
7
8
  bundleConditions,
8
9
  bundleDefine,
9
10
  CsrEntryFiles,
10
11
  PagesEntrySourceGenerator,
11
12
  PagesBundleBuilder
12
- } from "./index-1q1cjn8s.js";
13
+ } from "./index-9xh4zvw3.js";
13
14
 
14
15
  // pkgs/@akanjs/devkit/frontendBuild/csrArtifactBuilder.ts
15
16
  import { mkdir as mkdir2, rm as rm2, unlink as unlink2 } from "fs/promises";
@@ -462,7 +463,8 @@ ${logs}` : ""}`);
462
463
  };
463
464
  }
464
465
  static async barrelImportsPlugin(app, pipeAfter) {
465
- return await createBarrelImportsPlugin(app, { barrels: ["akanjs/ui"], pipeAfter });
466
+ const barrels = ["akanjs/ui", ...workspaceBarrels((await app.getConfig()).barrelImports)];
467
+ return await createBarrelImportsPlugin(app, { barrels, pipeAfter });
466
468
  }
467
469
  static publicEnvPath(app) {
468
470
  return path4.join(app.dist.cwdPath, ".akan", "artifact", "csr-public-env.json");