@akanjs/cli 3.2.0-rc.9 → 3.2.1-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 (145) hide show
  1. package/.build-stamp +2 -2
  2. package/CodeAgent-xdw73nbz.js +11 -0
  3. package/{CodeTui-qstk5vpj.js → CodeTui-0gewm71c.js} +822 -666
  4. package/README.ko.md +7 -0
  5. package/README.md +7 -0
  6. package/TunnelShare-cccfdgbm.js +16 -0
  7. package/agent.command-g1mj34wz.js +59 -0
  8. package/akanCode.js +12 -12
  9. package/appExecutor-rrx10jya.js +11 -0
  10. package/{application.command-m4rq4wc2.js → application.command-3w4v7t40.js} +84 -40
  11. package/{applicationBuildRunner-df7rx3ra.js → applicationBuildRunner-y5xbetyz.js} +51 -20
  12. package/buildBatch.proc.js +31 -16
  13. package/{cloud.command-a0gy0qq2.js → cloud.command-ph0rz6sw.js} +28 -29
  14. package/cloud.script-8bs9tp4j.js +30 -0
  15. package/{code.command-5rsdqw8s.js → code.command-9b967qpg.js} +13 -9
  16. package/context.command-ndzs5rbf.js +62 -0
  17. package/context.runner-bmstpng2.js +32 -0
  18. package/csrArtifactBuilder-gtvff6k7.js +10 -0
  19. package/{index-qd7xn2bk.js → dependencyScanner-93g8tk0r.js} +7 -6
  20. package/{devTui-h77zrjv5.js → devTui-rf374y2w.js} +1 -1
  21. package/{fileSys-zpvt5gtf.js → fileSys-e5mwt73x.js} +1 -1
  22. package/frameworkGraph-aneq2nwy.js +8 -0
  23. package/{guideline.command-mffxknbr.js → guideline.command-y8qz9kxy.js} +9 -5
  24. package/guidelines/agentRule/agentRule.instruction.md +25 -9
  25. package/guidelines/akanApi/akanApi.instruction.md +6 -4
  26. package/guidelines/conventions/core.md +23 -5
  27. package/guidelines/conventions/rules/app.md +4 -1
  28. package/guidelines/conventions/rules/page.md +5 -4
  29. package/guidelines/conventions/rules/ts.md +3 -3
  30. package/guidelines/errorCodes/errorCodes.instruction.md +165 -0
  31. package/guidelines/fieldRule/fieldRule.instruction.md +2 -1
  32. package/guidelines/mcpRule/mcpRule.instruction.md +225 -5
  33. package/guidelines/pageRule/pageRule.instruction.md +10 -1
  34. package/guidelines/queryRule/queryRule.instruction.md +3 -1
  35. package/guidelines/runtimeRule/runtimeRule.instruction.md +14 -8
  36. package/guidelines/transportRule/transportRule.instruction.md +31 -1
  37. package/incrementalBuilder.proc.js +609 -437
  38. package/{index-skmtj8rm.js → index-02v45hh9.js} +27 -10
  39. package/{index-j6gc8n14.js → index-0csk6jqm.js} +11 -9
  40. package/{index-2r9ff9qm.js → index-0wa5z6rm.js} +2 -2
  41. package/{index-nmvhjn8c.js → index-0z8sbdme.js} +93 -82
  42. package/{index-2vgv7fs7.js → index-1c2807kg.js} +727 -693
  43. package/{index-hj6w4ka1.js → index-1p81ecbz.js} +1 -1
  44. package/{index-2mf1aen9.js → index-1p9bxjmt.js} +2 -2
  45. package/{index-an76bdrv.js → index-2kh4xj3m.js} +1 -1
  46. package/{index-99qvtff2.js → index-2vn0m9z5.js} +5 -5
  47. package/{index-rp4yf32g.js → index-3569fr49.js} +36 -29
  48. package/{index-xvk2a75m.js → index-38x8ynrx.js} +25 -25
  49. package/{index-cmg5ngqa.js → index-3fmzz9sf.js} +20 -20
  50. package/{index-rfzp4pqs.js → index-45aprybg.js} +3 -3
  51. package/{index-k92x3vne.js → index-4a1n0nym.js} +1 -1
  52. package/{index-ra9fvn7s.js → index-4zgm54wf.js} +76 -40
  53. package/{index-exn38bzx.js → index-652f3bs8.js} +116 -54
  54. package/{index-grxs6fts.js → index-6gepp8yn.js} +57 -31
  55. package/{index-vm0dn0mt.js → index-6j351de4.js} +294 -157
  56. package/{index-w15mg3km.js → index-7ssr7wq4.js} +1 -1
  57. package/{index-gxav1bjz.js → index-82cmbpxc.js} +9 -9
  58. package/{index-2mrn1mrg.js → index-9f3reh2y.js} +1 -1
  59. package/{index-gcx48get.js → index-9rymt8d6.js} +2 -2
  60. package/{index-swwjakt0.js → index-ankyx6dj.js} +14 -18
  61. package/{index-28x1aszt.js → index-b0t92k71.js} +154 -58
  62. package/index-b372rck5.js +799 -0
  63. package/{index-yf9wc28h.js → index-bejy9zyc.js} +1 -1
  64. package/{index-r0a604h4.js → index-c669pbyb.js} +5 -4
  65. package/{index-xyn02k0w.js → index-cm9rb480.js} +662 -433
  66. package/{index-j9790rhk.js → index-d0n78fzc.js} +1635 -1139
  67. package/{index-hqv34wzq.js → index-dr1carpr.js} +10 -10
  68. package/index-f2arv0mv.js +30 -0
  69. package/{index-5radqwn2.js → index-gtydr9qc.js} +12 -12
  70. package/{index-j6eeh5d7.js → index-j3fqs8rc.js} +5 -5
  71. package/{index-yckz5t8b.js → index-jdw9m5c4.js} +516 -434
  72. package/{index-ny2k80mv.js → index-jf4vk1s0.js} +9 -2
  73. package/{index-x40bdsca.js → index-jg5rwrf7.js} +77 -115
  74. package/{index-5zwr4n6k.js → index-ktxdfqg5.js} +65 -8
  75. package/index-mnhrqjjq.js +127 -0
  76. package/{index-3ghdb7p5.js → index-pc42gxa5.js} +2777 -3676
  77. package/{index-0hbtve0a.js → index-q8h4eg5y.js} +32 -28
  78. package/{index-j3v29pq7.js → index-qh81drde.js} +219 -175
  79. package/{index-b4qq3rq0.js → index-rwgqba9p.js} +1 -1
  80. package/{index-w8yasvpc.js → index-scfsqen7.js} +2136 -2175
  81. package/{index-9p260r4e.js → index-trffs83s.js} +538 -250
  82. package/{index-0gg15zwa.js → index-twjgmryg.js} +6 -6
  83. package/index-whvhsb5f.js +80 -0
  84. package/{index-h7hehkw6.js → index-xczjdng6.js} +3 -1
  85. package/{index-39jz41jb.js → index-xs9a3ddt.js} +3 -3
  86. package/{index-35j83zkd.js → index-xv3pvdw4.js} +2 -2
  87. package/{index-34792nh7.js → index-y2g0s9tn.js} +1 -1
  88. package/{index-43f4h4cm.js → index-ymgsvhc5.js} +7 -8
  89. package/{index-ygdbn9jn.js → index-zyb0ebm4.js} +1 -1
  90. package/{index-bns3wcpc.js → index-zyjztrvc.js} +2 -2
  91. package/index.js +30 -24
  92. package/libExecutor-nstr00s7.js +10 -0
  93. package/{library.command-bmd7zc5m.js → library.command-b02aw1hm.js} +12 -5
  94. package/{localRegistry.command-y6en1599.js → localRegistry.command-3hg1p4aj.js} +24 -24
  95. package/{module.command-7exfffqw.js → module.command-bd9gz6cv.js} +11 -7
  96. package/{package.command-adskw2rj.js → package.command-xmr0mxze.js} +11 -10
  97. package/package.json +8 -8
  98. package/{page.command-dw01272p.js → page.command-x94qf58g.js} +8 -4
  99. package/{pipeline.command-0b1r3y5r.js → pipeline.command-n2843k6t.js} +15 -9
  100. package/pkgExecutor-cka27e3c.js +10 -0
  101. package/{primitive.command-byw6vc04.js → primitive.command-cs7v376h.js} +12 -8
  102. package/{projectTypecheck-kkrpq60a.js → projectTypecheck-za2n3nbr.js} +1 -1
  103. package/{prompter-qrwx1p17.js → prompter-d33wmdpa.js} +2 -2
  104. package/{quality.command-6rqnhzct.js → quality.command-nqngh1jd.js} +25 -16
  105. package/{recipeScanner-4b69ybe0.js → recipeScanner-rrx69awy.js} +1 -1
  106. package/{repair.command-rw5zymak.js → repair.command-v2medwsm.js} +12 -8
  107. package/{routeSourceValidator-4h947v7c.js → routeSourceValidator-8n6j1vn7.js} +4 -2
  108. package/{scalar.command-2dyp9nh9.js → scalar.command-61cjmxn1.js} +10 -6
  109. package/skills/akan-debug/SKILL.md +8 -5
  110. package/skills/akan-err/SKILL.md +7 -0
  111. package/skills/akan-mcp/SKILL.md +19 -1
  112. package/skills/akan-scaffold/SKILL.md +1 -1
  113. package/skills/akan-validate/SKILL.md +3 -3
  114. package/{subspace.command-111ynwv1.js → subspace.command-dtv8nfh7.js} +30 -24
  115. package/templates/app/page/_layout.tsx +13 -0
  116. package/templates/app/page/styles.css.template +40 -0
  117. package/templates/appSample/page/_index.tsx +9 -9
  118. package/templates/appSample/page/_layout.tsx +1 -0
  119. package/templates/appSample/page/styles.css.template +40 -5
  120. package/templates/appSample/ui/Recipe/jellyButton.ts +1 -1
  121. package/templates/biomeForm.ts +1 -1
  122. package/templates/env/_env.server.type.ts +1 -1
  123. package/templates/facetIndex/index.ts +2 -37
  124. package/templates/lib/sig.ts +0 -4
  125. package/templates/lib/useClient.ts +1 -1
  126. package/templates/workspaceRoot/.devcontainer/devcontainer.json.template +1 -1
  127. package/templates/workspaceRoot/AGENTS.md.template +2 -1
  128. package/templates/workspaceRoot/README.ts +4 -2
  129. package/{tunnel.command-2gcpfbdj.js → tunnel.command-fmwm5fgb.js} +15 -13
  130. package/{typeChecker-s640r6c0.js → typeChecker-7jt6abrs.js} +1 -1
  131. package/typecheck.proc.js +3 -2
  132. package/{verify.command-djgs86ma.js → verify.command-4f260t53.js} +19 -17
  133. package/{workflow.command-n0k2mxr5.js → workflow.command-tm5q9xsm.js} +21 -14
  134. package/{workspace.command-fh1qwxfx.js → workspace.command-75gc280j.js} +56 -54
  135. package/CodeAgent-x2p3a3e0.js +0 -11
  136. package/TunnelShare-c4xsfzg5.js +0 -15
  137. package/agent.command-9et2e27p.js +0 -52
  138. package/cloud.script-xze4zh7n.js +0 -31
  139. package/context.command-rk1dwrg4.js +0 -57
  140. package/context.runner-83ky5m1b.js +0 -30
  141. package/dependencyScanner-78sq8m4q.js +0 -8
  142. /package/templates/{appSample → app}/public/fonts/Pretendard-Bold.woff2 +0 -0
  143. /package/templates/{appSample → app}/public/fonts/Pretendard-Medium.woff2 +0 -0
  144. /package/templates/{appSample → app}/public/fonts/Pretendard-Regular.woff2 +0 -0
  145. /package/templates/{appSample → app}/public/fonts/Pretendard-SemiBold.woff2 +0 -0
@@ -1,57 +1,61 @@
1
1
  // @bun
2
2
  import {
3
3
  script
4
- } from "./index-exn38bzx.js";
4
+ } from "./index-652f3bs8.js";
5
5
  import {
6
- AppExecutor,
7
- LibExecutor,
8
- ModuleExecutor
9
- } from "./index-3ghdb7p5.js";
6
+ AppExecutor2
7
+ } from "./index-b372rck5.js";
8
+ import {
9
+ LibExecutor2
10
+ } from "./index-f2arv0mv.js";
10
11
  import {
11
12
  InteractionScaffold,
12
13
  workflowStatus,
13
14
  compactDiagnostics,
14
15
  generatedFilePathsForTarget,
15
- sourceFile,
16
- moduleComponentName,
17
- moduleSourcePaths,
18
- generatedFilesForSync,
19
- validationCommandsForTarget,
20
- nextActionsForTarget,
21
- createPrimitiveWriteReport,
22
- normalizeFieldType,
16
+ hasSourceParseErrors,
23
17
  ensureNamedImport,
24
18
  ensureBaseImport,
25
- coerceFieldDefault,
26
- fieldExpression,
19
+ ensureEnumImport,
20
+ ensureConstantTypeImport,
27
21
  viaBuilderParameterName,
28
22
  insertIntoObject,
29
23
  insertLightProjectionField,
30
- insertTemplateField,
31
- ensureEnumImport,
32
24
  insertEnumClass,
33
- insertDictionaryModelField,
34
25
  hasConstantInputField,
26
+ insertDictionaryModelField,
35
27
  hasDictionaryModelField,
36
- ensureConstantTypeImport,
37
28
  insertDictionaryEnum,
29
+ normalizeFieldType,
30
+ coerceFieldDefault,
31
+ fieldExpression,
38
32
  parseValues,
39
- hasSourceParseErrors,
33
+ moduleComponentName,
34
+ moduleSourcePaths,
35
+ addFieldUiPolicyForType,
36
+ withFieldTypeImport,
37
+ KeyRename,
40
38
  hasClassMethod,
41
39
  insertClassMethod,
42
40
  hasSignalFactoryEntry,
43
41
  insertSignalFactoryEntry,
44
- addFieldUiPolicyForType,
45
- withFieldTypeImport,
46
- KeyRename,
47
- MutationScaffold
48
- } from "./index-2vgv7fs7.js";
42
+ MutationScaffold,
43
+ sourceFile,
44
+ generatedFilesForSync,
45
+ validationCommandsForTarget,
46
+ nextActionsForTarget,
47
+ createPrimitiveWriteReport,
48
+ insertTemplateField
49
+ } from "./index-1c2807kg.js";
49
50
  import {
50
51
  ModuleScript
51
- } from "./index-hqv34wzq.js";
52
+ } from "./index-dr1carpr.js";
52
53
  import {
53
54
  plainNameProblem
54
55
  } from "./index-va90m8nd.js";
56
+ import {
57
+ ModuleExecutor
58
+ } from "./index-whvhsb5f.js";
55
59
 
56
60
  // pkgs/@akanjs/cli/primitive/primitive.script.ts
57
61
  import { capitalize, lowerlize } from "akanjs/common";
@@ -61,9 +65,9 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
61
65
  return null;
62
66
  const [apps, libs] = await workspace.getSyss();
63
67
  if (apps.includes(target))
64
- return AppExecutor.from(workspace, target);
68
+ return AppExecutor2.from(workspace, target);
65
69
  if (libs.includes(target))
66
- return LibExecutor.from(workspace, target);
70
+ return LibExecutor2.from(workspace, target);
67
71
  return null;
68
72
  }
69
73
  async createUi(workspace, input) {
@@ -1,7 +1,17 @@
1
1
  // @bun
2
2
  import {
3
- AppExecutor
4
- } from "./index-3ghdb7p5.js";
3
+ runner
4
+ } from "./index-652f3bs8.js";
5
+ import {
6
+ AppExecutor2
7
+ } from "./index-b372rck5.js";
8
+ import {
9
+ jsonText,
10
+ workflowStatus,
11
+ createWorkflowBaselineSummary,
12
+ buildAkanModuleContextIndex,
13
+ toolingRolloutGate
14
+ } from "./index-1c2807kg.js";
5
15
  import {
6
16
  buildResourceList,
7
17
  codexMcpConfigPath,
@@ -11,46 +21,220 @@ import {
11
21
  upsertCodexMcpServerBlock,
12
22
  renderDoctorText,
13
23
  AkanContextAnalyzer
14
- } from "./index-yckz5t8b.js";
24
+ } from "./index-jdw9m5c4.js";
15
25
  import {
16
- jsonText,
17
- workflowStatus,
18
- createWorkflowBaselineSummary,
19
- buildAkanModuleContextIndex,
20
- toolingRolloutGate
21
- } from "./index-2vgv7fs7.js";
22
- import {
23
- runner
24
- } from "./index-exn38bzx.js";
26
+ Prompter2
27
+ } from "./index-j3fqs8rc.js";
25
28
  import {
26
29
  NativeApp
27
- } from "./index-43f4h4cm.js";
30
+ } from "./index-ymgsvhc5.js";
28
31
  import {
29
32
  isPlaceholderAppId
30
- } from "./index-an76bdrv.js";
33
+ } from "./index-2kh4xj3m.js";
31
34
  import {
32
35
  getMobileTargets,
33
36
  appIdsOf
34
37
  } from "./index-m9jj544v.js";
35
- import {
36
- Prompter2
37
- } from "./index-j6eeh5d7.js";
38
38
  import {
39
39
  WorkspaceGraph
40
- } from "./index-39jz41jb.js";
40
+ } from "./index-xs9a3ddt.js";
41
41
  import {
42
42
  RepairRunner
43
- } from "./index-99qvtff2.js";
43
+ } from "./index-2vn0m9z5.js";
44
44
  import {
45
45
  WorkflowRunner
46
- } from "./index-5radqwn2.js";
46
+ } from "./index-gtydr9qc.js";
47
47
 
48
- // pkgs/@akanjs/devkit/akanMcpContract.ts
48
+ // pkgs/@akanjs/devkit/context/akanMcpContract.ts
49
49
  import { lstatSync, realpathSync } from "fs";
50
50
  import path from "path";
51
51
  import { isRecord } from "akanjs/common";
52
52
 
53
- // pkgs/@akanjs/devkit/akanMcpToolError.ts
53
+ // pkgs/@akanjs/devkit/context/akanContextInspection.ts
54
+ var inspectDiagnostic = (severity, code, message) => ({ severity, code, message });
55
+ var moduleEvidence = (module) => ({
56
+ kind: "module",
57
+ target: `${module.sysName}:${module.name}`,
58
+ path: module.path,
59
+ summary: `${module.kind} module at ${module.path} with ${module.files.length} source file(s).`
60
+ });
61
+ var moduleCandidate = (module) => ({
62
+ app: module.sysName,
63
+ sysType: module.sysType,
64
+ module: module.name,
65
+ kind: module.kind,
66
+ path: module.path,
67
+ files: module.files
68
+ });
69
+
70
+ class AkanContextInspection {
71
+ #workspace;
72
+ #question;
73
+ #diagnostics = [];
74
+ constructor(workspace, props) {
75
+ this.#workspace = workspace;
76
+ this.#question = props.question;
77
+ if (props.draft.type !== props.request.type) {
78
+ this.#diagnostics.push(inspectDiagnostic("warning", "inspect-draft-request-mismatch", `Draft chose ${props.draft.type}, but request uses ${props.request.type}.`));
79
+ }
80
+ }
81
+ escape(request) {
82
+ return this.#result("escape", [{ kind: "escape", summary: request.reason }], {
83
+ action: "escape",
84
+ reason: request.reason,
85
+ ...request.nextStep ? { args: { nextStep: request.nextStep } } : {}
86
+ }, { reason: request.reason, nextStep: request.nextStep ?? null });
87
+ }
88
+ async workflowDiagnostics(request, artifactPath) {
89
+ const doctor = await AkanContextAnalyzer.doctor(this.#workspace, {
90
+ strict: true,
91
+ runIdOrPlan: artifactPath
92
+ });
93
+ const toWorkflowDiagnostic = ({ severity, code, message, scope }, context) => ({ severity, code, message, scope, context });
94
+ const baselineSummary = createWorkflowBaselineSummary((doctor.baselineDiagnostics ?? []).map((diagnostic) => toWorkflowDiagnostic(diagnostic, diagnostic.context)), { detailsIncluded: false });
95
+ this.#diagnostics.push(...(doctor.workflowDiagnostics ?? doctor.diagnostics).map((diagnostic) => toWorkflowDiagnostic(diagnostic, {
96
+ ...diagnostic.context,
97
+ ...diagnostic.path ? { paths: [diagnostic.path] } : {}
98
+ })));
99
+ return this.#result("workflowDiagnostics", [
100
+ {
101
+ kind: "workflow",
102
+ target: request.runIdOrPlan,
103
+ summary: `Workflow diagnostics status is ${doctor.status}.`
104
+ }
105
+ ], {
106
+ action: doctor.status === "passed" ? "answer" : "validate",
107
+ reason: doctor.status === "passed" ? "No strict workspace diagnostics were found for the workflow context." : "Review diagnostics before applying or manually editing source files."
108
+ }, {
109
+ status: doctor.status,
110
+ baselineSummary,
111
+ baselineDiagnostics: 0,
112
+ workflowDiagnostics: doctor.workflowDiagnostics?.length ?? 0
113
+ });
114
+ }
115
+ async workspaceOverview() {
116
+ const context = await AkanContextAnalyzer.analyze(this.#workspace, {
117
+ app: null,
118
+ module: null,
119
+ includeAbstractContent: false
120
+ });
121
+ return this.#result("workspaceOverview", [
122
+ {
123
+ kind: "workspace",
124
+ summary: `${context.repoName} has ${context.apps.length} app(s), ${context.libs.length} lib(s), and ${context.pkgs.length} package(s).`
125
+ }
126
+ ], {
127
+ action: "inspect",
128
+ reason: "Choose moduleContext or fieldInsertionContext for module-scoped evidence before planning a workflow.",
129
+ tool: "inspect_akan_context"
130
+ }, {
131
+ repoName: context.repoName,
132
+ apps: context.apps.map((app) => ({ name: app.name, path: app.path, modules: app.modules.length })),
133
+ libs: context.libs.map((lib) => ({ name: lib.name, path: lib.path, modules: lib.modules.length })),
134
+ pkgs: context.pkgs.map((pkg) => ({ name: pkg.name, path: pkg.path, version: pkg.version ?? null })),
135
+ generatedFiles: context.generatedFiles,
136
+ validationCommands: context.validationCommands
137
+ });
138
+ }
139
+ async moduleContext(request) {
140
+ const modules = await this.#matchingModules(request);
141
+ const unresolved = this.#unresolvedModule(request, modules);
142
+ if (unresolved)
143
+ return unresolved;
144
+ const module = modules[0];
145
+ return this.#result("moduleContext", [moduleEvidence(module)], {
146
+ action: "inspect",
147
+ reason: "Use fieldInsertionContext when preparing add-field or escape when source body details are required.",
148
+ tool: "inspect_akan_context"
149
+ }, { module: moduleCandidate(module) });
150
+ }
151
+ async fieldInsertionContext(request) {
152
+ const modules = await this.#matchingModules(request);
153
+ const unresolved = this.#unresolvedModule(request, modules);
154
+ if (unresolved)
155
+ return unresolved;
156
+ const module = modules[0];
157
+ if (module.kind !== "domain") {
158
+ this.#diagnostics.push(inspectDiagnostic("error", "field-insertion-unsupported-module-kind", `fieldInsertionContext currently targets domain modules; ${module.sysName}:${module.name} is ${module.kind}.`));
159
+ }
160
+ const moduleIndex = await buildAkanModuleContextIndex(this.#workspace, module, { field: request.field });
161
+ this.#diagnostics.push(...moduleIndex.diagnostics);
162
+ return this.#result("fieldInsertionContext", [
163
+ moduleEvidence(module),
164
+ {
165
+ kind: "field-insertion",
166
+ target: `${module.sysName}:${module.name}.${request.field}`,
167
+ path: module.path,
168
+ summary: "M2 returns source-body-free AST index evidence for constant fields, dictionary model labels, and light projection fields."
169
+ }
170
+ ], module.kind === "domain" ? {
171
+ action: "plan_workflow",
172
+ reason: "The module target is unambiguous; create an add-field workflow plan before source edits.",
173
+ tool: "plan_workflow",
174
+ args: {
175
+ workflow: "add-field",
176
+ inputs: {
177
+ app: module.sysName,
178
+ module: module.name,
179
+ field: request.field,
180
+ type: request.fieldType
181
+ }
182
+ }
183
+ } : {
184
+ action: "escape",
185
+ reason: "This module kind is not a supported add-field target in the P1 context contract."
186
+ }, {
187
+ target: {
188
+ app: module.sysName,
189
+ module: module.name,
190
+ field: request.field,
191
+ fieldType: request.fieldType
192
+ },
193
+ files: moduleIndex.files,
194
+ moduleIndex
195
+ });
196
+ }
197
+ async#matchingModules(request) {
198
+ const context = await AkanContextAnalyzer.analyze(this.#workspace, {
199
+ app: request.app ?? null,
200
+ module: request.module ?? null,
201
+ includeAbstractContent: false
202
+ });
203
+ return AkanContextAnalyzer.findModules(context, request.module, {
204
+ app: request.app ?? null
205
+ });
206
+ }
207
+ #unresolvedModule(request, modules) {
208
+ if (modules.length === 0) {
209
+ this.#diagnostics.push(inspectDiagnostic("error", "inspect-module-not-found", `No module matched ${request.app ? `${request.app}:` : ""}${request.module}.`));
210
+ return this.#result(request.type, [], {
211
+ action: "escape",
212
+ reason: "The requested module was not found in the workspace index; inspect workspace files or clarify the target."
213
+ }, { candidates: [] });
214
+ }
215
+ if (!request.app && modules.length > 1) {
216
+ this.#diagnostics.push(inspectDiagnostic("error", "inspect-module-ambiguous", `Multiple modules match "${request.module}". Re-run with app to disambiguate.`));
217
+ return this.#result(request.type, modules.map(moduleEvidence), {
218
+ action: "clarify",
219
+ reason: "Multiple modules have the same name; choose an app before planning a workflow."
220
+ }, { candidates: modules.map(moduleCandidate) });
221
+ }
222
+ return null;
223
+ }
224
+ #result(type, evidence, next, data) {
225
+ return {
226
+ schemaVersion: 1,
227
+ type,
228
+ question: this.#question,
229
+ diagnostics: this.#diagnostics,
230
+ evidence,
231
+ next,
232
+ ...data ? { data } : {}
233
+ };
234
+ }
235
+ }
236
+
237
+ // pkgs/@akanjs/devkit/context/akanMcpToolError.ts
54
238
  import { AkanError } from "akanjs/base";
55
239
 
56
240
  class AkanMcpToolError extends AkanError {
@@ -62,7 +246,7 @@ class AkanMcpToolError extends AkanError {
62
246
  }
63
247
  }
64
248
 
65
- // pkgs/@akanjs/devkit/akanMcpContract.ts
249
+ // pkgs/@akanjs/devkit/context/akanMcpContract.ts
66
250
  var emptySchema = { type: "object", properties: {} };
67
251
  var stringProperty = { type: "string" };
68
252
  var booleanProperty = { type: "boolean" };
@@ -271,21 +455,6 @@ var inspectAkanContextPropsArg = (args) => {
271
455
  request: { type: "escape", reason: stringArg(request, "reason"), nextStep: optionalString(request, "nextStep") }
272
456
  };
273
457
  };
274
- var inspectDiagnostic = (severity, code, message) => ({ severity, code, message });
275
- var moduleEvidence = (module) => ({
276
- kind: "module",
277
- target: `${module.sysName}:${module.name}`,
278
- path: module.path,
279
- summary: `${module.kind} module at ${module.path} with ${module.files.length} source file(s).`
280
- });
281
- var moduleCandidate = (module) => ({
282
- app: module.sysName,
283
- sysType: module.sysType,
284
- module: module.name,
285
- kind: module.kind,
286
- path: module.path,
287
- files: module.files
288
- });
289
458
  var readonlyMcpTools = [
290
459
  {
291
460
  name: "inspect_akan_context",
@@ -472,142 +641,17 @@ var createAkanValidationContract = (listTools = listAkanMcpTools) => ({
472
641
  });
473
642
  var inspectAkanContext = async (workspace, args) => {
474
643
  const props = inspectAkanContextPropsArg(args);
475
- const diagnostics = [];
476
- if (props.draft.type !== props.request.type) {
477
- diagnostics.push(inspectDiagnostic("warning", "inspect-draft-request-mismatch", `Draft chose ${props.draft.type}, but request uses ${props.request.type}.`));
478
- }
479
- const baseResult = (type, evidence, next, data) => ({
480
- schemaVersion: 1,
481
- type,
482
- question: props.question,
483
- diagnostics,
484
- evidence,
485
- next,
486
- ...data ? { data } : {}
487
- });
488
- if (props.request.type === "escape") {
489
- return baseResult("escape", [{ kind: "escape", summary: props.request.reason }], {
490
- action: "escape",
491
- reason: props.request.reason,
492
- ...props.request.nextStep ? { args: { nextStep: props.request.nextStep } } : {}
493
- }, { reason: props.request.reason, nextStep: props.request.nextStep ?? null });
494
- }
495
- if (props.request.type === "workflowDiagnostics") {
496
- const doctor = await AkanContextAnalyzer.doctor(workspace, {
497
- strict: true,
498
- runIdOrPlan: workflowArtifactPath(workspace, props.request.runIdOrPlan)
499
- });
500
- const toWorkflowDiagnostic = ({ severity, code, message, scope }, context) => ({ severity, code, message, scope, context });
501
- const baselineSummary = createWorkflowBaselineSummary((doctor.baselineDiagnostics ?? []).map((diagnostic) => toWorkflowDiagnostic(diagnostic, diagnostic.context)), { detailsIncluded: false });
502
- diagnostics.push(...(doctor.workflowDiagnostics ?? doctor.diagnostics).map((diagnostic) => toWorkflowDiagnostic(diagnostic, {
503
- ...diagnostic.context,
504
- ...diagnostic.path ? { paths: [diagnostic.path] } : {}
505
- })));
506
- return baseResult("workflowDiagnostics", [
507
- {
508
- kind: "workflow",
509
- target: props.request.runIdOrPlan,
510
- summary: `Workflow diagnostics status is ${doctor.status}.`
511
- }
512
- ], {
513
- action: doctor.status === "passed" ? "answer" : "validate",
514
- reason: doctor.status === "passed" ? "No strict workspace diagnostics were found for the workflow context." : "Review diagnostics before applying or manually editing source files."
515
- }, {
516
- status: doctor.status,
517
- baselineSummary,
518
- baselineDiagnostics: 0,
519
- workflowDiagnostics: doctor.workflowDiagnostics?.length ?? 0
520
- });
521
- }
522
- const moduleRequest = props.request.type === "moduleContext" || props.request.type === "fieldInsertionContext" ? props.request : null;
523
- const context = await AkanContextAnalyzer.analyze(workspace, {
524
- app: moduleRequest?.app ?? null,
525
- module: moduleRequest?.module ?? null,
526
- includeAbstractContent: false
527
- });
528
- if (props.request.type === "workspaceOverview") {
529
- return baseResult("workspaceOverview", [
530
- {
531
- kind: "workspace",
532
- summary: `${context.repoName} has ${context.apps.length} app(s), ${context.libs.length} lib(s), and ${context.pkgs.length} package(s).`
533
- }
534
- ], {
535
- action: "inspect",
536
- reason: "Choose moduleContext or fieldInsertionContext for module-scoped evidence before planning a workflow.",
537
- tool: "inspect_akan_context"
538
- }, {
539
- repoName: context.repoName,
540
- apps: context.apps.map((app) => ({ name: app.name, path: app.path, modules: app.modules.length })),
541
- libs: context.libs.map((lib) => ({ name: lib.name, path: lib.path, modules: lib.modules.length })),
542
- pkgs: context.pkgs.map((pkg) => ({ name: pkg.name, path: pkg.path, version: pkg.version ?? null })),
543
- generatedFiles: context.generatedFiles,
544
- validationCommands: context.validationCommands
545
- });
546
- }
547
- const modules = AkanContextAnalyzer.findModules(context, props.request.module, {
548
- app: props.request.app ?? null
549
- });
550
- if (modules.length === 0) {
551
- diagnostics.push(inspectDiagnostic("error", "inspect-module-not-found", `No module matched ${props.request.app ? `${props.request.app}:` : ""}${props.request.module}.`));
552
- return baseResult(props.request.type, [], {
553
- action: "escape",
554
- reason: "The requested module was not found in the workspace index; inspect workspace files or clarify the target."
555
- }, { candidates: [] });
556
- }
557
- if (!props.request.app && modules.length > 1) {
558
- diagnostics.push(inspectDiagnostic("error", "inspect-module-ambiguous", `Multiple modules match "${props.request.module}". Re-run with app to disambiguate.`));
559
- return baseResult(props.request.type, modules.map(moduleEvidence), {
560
- action: "clarify",
561
- reason: "Multiple modules have the same name; choose an app before planning a workflow."
562
- }, { candidates: modules.map(moduleCandidate) });
563
- }
564
- const module = modules[0];
565
- if (props.request.type === "moduleContext") {
566
- return baseResult("moduleContext", [moduleEvidence(module)], {
567
- action: "inspect",
568
- reason: "Use fieldInsertionContext when preparing add-field or escape when source body details are required.",
569
- tool: "inspect_akan_context"
570
- }, { module: moduleCandidate(module) });
571
- }
572
- if (module.kind !== "domain") {
573
- diagnostics.push(inspectDiagnostic("error", "field-insertion-unsupported-module-kind", `fieldInsertionContext currently targets domain modules; ${module.sysName}:${module.name} is ${module.kind}.`));
574
- }
575
- const moduleIndex = await buildAkanModuleContextIndex(workspace, module, { field: props.request.field });
576
- diagnostics.push(...moduleIndex.diagnostics);
577
- return baseResult("fieldInsertionContext", [
578
- moduleEvidence(module),
579
- {
580
- kind: "field-insertion",
581
- target: `${module.sysName}:${module.name}.${props.request.field}`,
582
- path: module.path,
583
- summary: "M2 returns source-body-free AST index evidence for constant fields, dictionary model labels, and light projection fields."
584
- }
585
- ], module.kind === "domain" ? {
586
- action: "plan_workflow",
587
- reason: "The module target is unambiguous; create an add-field workflow plan before source edits.",
588
- tool: "plan_workflow",
589
- args: {
590
- workflow: "add-field",
591
- inputs: {
592
- app: module.sysName,
593
- module: module.name,
594
- field: props.request.field,
595
- type: props.request.fieldType
596
- }
597
- }
598
- } : {
599
- action: "escape",
600
- reason: "This module kind is not a supported add-field target in the P1 context contract."
601
- }, {
602
- target: {
603
- app: module.sysName,
604
- module: module.name,
605
- field: props.request.field,
606
- fieldType: props.request.fieldType
607
- },
608
- files: moduleIndex.files,
609
- moduleIndex
610
- });
644
+ const inspection = new AkanContextInspection(workspace, props);
645
+ const { request } = props;
646
+ if (request.type === "escape")
647
+ return inspection.escape(request);
648
+ if (request.type === "workflowDiagnostics")
649
+ return await inspection.workflowDiagnostics(request, workflowArtifactPath(workspace, request.runIdOrPlan));
650
+ if (request.type === "workspaceOverview")
651
+ return await inspection.workspaceOverview();
652
+ if (request.type === "moduleContext")
653
+ return await inspection.moduleContext(request);
654
+ return await inspection.fieldInsertionContext(request);
611
655
  };
612
656
 
613
657
  // pkgs/@akanjs/cli/context/context.runner.ts
@@ -672,7 +716,7 @@ class ContextRunner2 extends runner("context") {
672
716
  const diagnostics = [];
673
717
  let toolchainChecked = false;
674
718
  for (const appName of appNames) {
675
- const app = AppExecutor.from(workspace, appName);
719
+ const app = AppExecutor2.from(workspace, appName);
676
720
  const config = await app.getConfig();
677
721
  if (!config.hasNativeConfig)
678
722
  continue;
@@ -243,7 +243,7 @@ var readPageExpression = `(() => {
243
243
  return { href: location.href, title: document.title, text, status, empty, pageErrors, domFindings };
244
244
  })()`;
245
245
 
246
- // pkgs/@akanjs/devkit/stripAnsi.ts
246
+ // pkgs/@akanjs/devkit/util/stripAnsi.ts
247
247
  var ansi = new RegExp(`${String.fromCharCode(27)}(?:[@-Z\\\\-_]|\\[[\\s\\S]*?[@-~])`, "g");
248
248
  var stripAnsi = (text) => text.replace(ansi, "");
249
249