@akanjs/cli 3.2.0-rc.17 → 3.2.0-rc.19

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 (94) hide show
  1. package/.build-stamp +2 -2
  2. package/{CodeAgent-18qg03re.js → CodeAgent-q0xkt4at.js} +2 -2
  3. package/{CodeTui-zkm51zf3.js → CodeTui-n56kpaca.js} +819 -663
  4. package/TunnelShare-844s9te4.js +18 -0
  5. package/{agent.command-5k2zegmj.js → agent.command-k07raqft.js} +20 -20
  6. package/akanCode.js +8 -8
  7. package/{appExecutor-1bgs9a69.js → appExecutor-xav1zemr.js} +3 -3
  8. package/{application.command-ge27047n.js → application.command-dv8y8r12.js} +52 -25
  9. package/{applicationBuildRunner-7skfg8zn.js → applicationBuildRunner-vhx7zq97.js} +9 -10
  10. package/buildBatch.proc.js +20 -11
  11. package/{cloud.command-d18qj1v2.js → cloud.command-0vjy3x96.js} +22 -22
  12. package/cloud.script-jp48r0kw.js +35 -0
  13. package/{code.command-tz4x5zm6.js → code.command-xc5exq4b.js} +10 -10
  14. package/{context.command-x1smtm5q.js → context.command-etsat8yk.js} +22 -22
  15. package/context.runner-e52ak0cx.js +34 -0
  16. package/{guideline.command-rdcwxf8g.js → guideline.command-zqkntk7b.js} +6 -6
  17. package/guidelines/agentRule/agentRule.instruction.md +5 -4
  18. package/guidelines/conventions/core.md +18 -0
  19. package/guidelines/errorCodes/errorCodes.instruction.md +6 -0
  20. package/guidelines/mcpRule/mcpRule.instruction.md +4 -2
  21. package/guidelines/transportRule/transportRule.instruction.md +3 -1
  22. package/incrementalBuilder.proc.js +559 -409
  23. package/{index-gh4brxzn.js → index-12js5pj4.js} +1 -1
  24. package/{index-jfkh776h.js → index-12vv4g80.js} +1 -1
  25. package/index-4zqebbqb.js +80 -0
  26. package/{index-er2ja34m.js → index-6bryy19d.js} +500 -422
  27. package/{index-3641r8q0.js → index-6pzncry1.js} +4 -4
  28. package/{index-fcrr79gh.js → index-6rrh0ffr.js} +44 -32
  29. package/{index-nd39rssn.js → index-7jr9mfp2.js} +286 -144
  30. package/{index-sp331bww.js → index-81qt1jyj.js} +1 -1
  31. package/{index-2mrn1mrg.js → index-9f3reh2y.js} +1 -1
  32. package/{index-e82xwj3x.js → index-a05ewnnp.js} +1 -1
  33. package/{index-bjnebzzc.js → index-bxevbjw7.js} +8 -8
  34. package/{index-vm6pr11y.js → index-c1vym3gx.js} +2 -2
  35. package/{index-t8tysbxv.js → index-c9hd79py.js} +4 -4
  36. package/{index-j2eqe3jk.js → index-c9mnfy9r.js} +38 -23
  37. package/{index-dtpeyts6.js → index-cc9pevta.js} +1 -1
  38. package/{index-trp7jdr1.js → index-cet2s7xk.js} +7 -6
  39. package/{index-yr5jv8yd.js → index-dasa0kbj.js} +3 -3
  40. package/{index-bxqbt5p3.js → index-ddc2zjj5.js} +1 -1
  41. package/{index-g7e58wz2.js → index-dz7z9n9t.js} +25 -25
  42. package/{index-z7t6neq1.js → index-e4vna9dn.js} +4 -4
  43. package/{index-669sg3yp.js → index-ean2tff1.js} +723 -691
  44. package/{index-ttfz2sc7.js → index-fgp04fh7.js} +6 -6
  45. package/{index-bzdq8wfw.js → index-g541mhzw.js} +3 -3
  46. package/{index-t329y8am.js → index-gh741qft.js} +8 -8
  47. package/{index-d2r762fk.js → index-k51718xz.js} +2136 -2175
  48. package/{index-39byv35b.js → index-m6r3pvf5.js} +2 -2
  49. package/{index-emf3wzvh.js → index-my17308p.js} +7 -7
  50. package/{index-xywq95wk.js → index-nd8bq17n.js} +6 -6
  51. package/{index-q4e18ne4.js → index-nxcmgqk3.js} +3 -3
  52. package/{index-b2sptt87.js → index-pkgha3rt.js} +5 -5
  53. package/{index-s75h0455.js → index-q2t2w996.js} +1 -1
  54. package/{index-6p02be7n.js → index-qtqhsb33.js} +204 -160
  55. package/{index-h7yd92c8.js → index-rj2n5kfk.js} +67 -67
  56. package/{index-1ts8vfsk.js → index-s5gvwvkb.js} +103 -138
  57. package/{index-neassptx.js → index-sh3yzse2.js} +8 -7
  58. package/{index-f482h2hj.js → index-syn4vm3y.js} +1 -1
  59. package/{index-n8mxyy3f.js → index-t00xrkey.js} +1 -1
  60. package/{index-g56xae1n.js → index-v72mh89f.js} +7 -8
  61. package/{index-q57rsax4.js → index-wq8pnev4.js} +3 -3
  62. package/{index-dp7sht3v.js → index-wxr3941g.js} +8 -8
  63. package/{index-0c8zj1da.js → index-y8mqkhcf.js} +1 -1
  64. package/{index-9mx3b3zh.js → index-zk1gjk46.js} +4 -4
  65. package/index.js +27 -27
  66. package/{libExecutor-hxe5eqfh.js → libExecutor-mr3vxtnr.js} +2 -2
  67. package/{library.command-83shs8fw.js → library.command-ps9q5t37.js} +7 -7
  68. package/{localRegistry.command-sz713jg3.js → localRegistry.command-rszxmvd0.js} +21 -21
  69. package/{module.command-jhhm0nmw.js → module.command-fcybnn1a.js} +10 -10
  70. package/{package.command-42syy96v.js → package.command-zen3rhye.js} +10 -10
  71. package/package.json +2 -2
  72. package/{page.command-jkv29zzs.js → page.command-gwrxymms.js} +7 -7
  73. package/{pipeline.command-6sg9g4hq.js → pipeline.command-m1brkqqw.js} +6 -6
  74. package/{pkgExecutor-6p82w5y1.js → pkgExecutor-x51agavp.js} +2 -2
  75. package/{primitive.command-tt6aq7m9.js → primitive.command-5vkxvvmk.js} +11 -11
  76. package/{projectTypecheck-wfrz0cxr.js → projectTypecheck-9dzfah37.js} +1 -1
  77. package/{quality.command-tqar7ss5.js → quality.command-gqry7eas.js} +9 -9
  78. package/{repair.command-qkcn329t.js → repair.command-qs4ejcrg.js} +10 -10
  79. package/{routeSourceValidator-8aph1dsr.js → routeSourceValidator-8n6j1vn7.js} +3 -1
  80. package/{scalar.command-6nvq11ag.js → scalar.command-ny0vchqq.js} +9 -9
  81. package/skills/akan-scaffold/SKILL.md +1 -1
  82. package/{subspace.command-dvwds4cv.js → subspace.command-5pxqjgmw.js} +12 -12
  83. package/templates/biomeForm.ts +1 -1
  84. package/templates/env/_env.server.type.ts +1 -1
  85. package/templates/facetIndex/index.ts +2 -37
  86. package/templates/workspaceRoot/AGENTS.md.template +2 -1
  87. package/{tunnel.command-h8r69a7v.js → tunnel.command-ndajt0xk.js} +11 -11
  88. package/{verify.command-ynec8kt2.js → verify.command-m59ashc7.js} +17 -17
  89. package/{workflow.command-f70fx73a.js → workflow.command-jchqey88.js} +15 -15
  90. package/{workspace.command-vagjy1q9.js → workspace.command-g0gzxkpd.js} +36 -36
  91. package/TunnelShare-6t4rwyc0.js +0 -19
  92. package/cloud.script-0hbhm3mw.js +0 -35
  93. package/context.runner-vb7jc0k8.js +0 -34
  94. package/index-dqsc1b5t.js +0 -18
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-neassptx.js";
5
+ } from "./index-sh3yzse2.js";
6
6
  import {
7
7
  generatedFilesForSync,
8
8
  createPassedPrimitiveReport,
9
9
  scalarChangedFiles
10
- } from "./index-669sg3yp.js";
10
+ } from "./index-ean2tff1.js";
11
11
  import {
12
12
  pluralizeName
13
13
  } from "./index-nz8prx9g.js";
@@ -4,27 +4,27 @@ import {
4
4
  CloudApi,
5
5
  CloudUpdates,
6
6
  PipelineSecrets
7
- } from "./index-vm6pr11y.js";
7
+ } from "./index-c1vym3gx.js";
8
8
  import {
9
9
  PkgExecutor2
10
- } from "./index-dtpeyts6.js";
10
+ } from "./index-cc9pevta.js";
11
11
  import {
12
12
  UpdatePackFolder,
13
13
  NativePublicEnv,
14
14
  NativeApp
15
- } from "./index-q57rsax4.js";
15
+ } from "./index-wq8pnev4.js";
16
16
  import {
17
17
  script
18
- } from "./index-neassptx.js";
18
+ } from "./index-sh3yzse2.js";
19
19
  import {
20
20
  ApplicationScript
21
- } from "./index-fcrr79gh.js";
21
+ } from "./index-6rrh0ffr.js";
22
22
  import {
23
23
  PackageScript
24
- } from "./index-z7t6neq1.js";
24
+ } from "./index-e4vna9dn.js";
25
25
  import {
26
26
  CloudRunner
27
- } from "./index-b2sptt87.js";
27
+ } from "./index-pkgha3rt.js";
28
28
 
29
29
  // pkgs/@akanjs/cli/cloud/cloud.script.ts
30
30
  import { Logger } from "akanjs/common";
@@ -1,28 +1,28 @@
1
1
  // @bun
2
2
  import {
3
3
  ApplicationBuildReporter
4
- } from "./index-1ts8vfsk.js";
4
+ } from "./index-s5gvwvkb.js";
5
5
  import {
6
6
  parseBiomeReport,
7
7
  Linter,
8
8
  ProjectTypecheck2
9
- } from "./index-g56xae1n.js";
9
+ } from "./index-v72mh89f.js";
10
10
  import {
11
11
  TypecheckFailure
12
12
  } from "./index-j4yvgfhr.js";
13
13
  import {
14
14
  AppExecutor2
15
- } from "./index-trp7jdr1.js";
15
+ } from "./index-cet2s7xk.js";
16
16
  import {
17
17
  LibExecutor2
18
- } from "./index-n8mxyy3f.js";
18
+ } from "./index-t00xrkey.js";
19
19
  import {
20
20
  PkgExecutor2
21
- } from "./index-dtpeyts6.js";
21
+ } from "./index-cc9pevta.js";
22
22
  import {
23
23
  WorkspaceRunner,
24
24
  AkanQualityScanner
25
- } from "./index-ttfz2sc7.js";
25
+ } from "./index-fgp04fh7.js";
26
26
 
27
27
  // pkgs/@akanjs/cli/verify/verifyComments.ts
28
28
  import { existsSync } from "fs";
@@ -2,15 +2,15 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-neassptx.js";
5
+ } from "./index-sh3yzse2.js";
6
6
  import {
7
7
  CommandExecutionError,
8
8
  LibSource,
9
9
  formatLibStatuses
10
- } from "./index-g56xae1n.js";
10
+ } from "./index-v72mh89f.js";
11
11
  import {
12
12
  LibExecutor2
13
- } from "./index-n8mxyy3f.js";
13
+ } from "./index-t00xrkey.js";
14
14
  import {
15
15
  assertPlainName
16
16
  } from "./index-va90m8nd.js";
@@ -6,23 +6,23 @@ import {
6
6
  CloudApi,
7
7
  CloudUpdates,
8
8
  PipelineSecrets
9
- } from "./index-vm6pr11y.js";
9
+ } from "./index-c1vym3gx.js";
10
10
  import {
11
11
  resolveMobileTargets
12
12
  } from "./index-m9jj544v.js";
13
13
  import {
14
14
  WorkspaceExecutor
15
- } from "./index-g56xae1n.js";
15
+ } from "./index-v72mh89f.js";
16
16
  import {
17
17
  AppExecutor2
18
- } from "./index-trp7jdr1.js";
18
+ } from "./index-cet2s7xk.js";
19
19
  import {
20
20
  NativeApp
21
- } from "./index-q57rsax4.js";
21
+ } from "./index-wq8pnev4.js";
22
22
  import {
23
23
  runner,
24
24
  assertPromptable
25
- } from "./index-neassptx.js";
25
+ } from "./index-sh3yzse2.js";
26
26
  import {
27
27
  getNpmRegistryUrl,
28
28
  getPublishedVersions,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  FrameworkMapBuilder,
4
4
  FrameworkMapDoc
5
- } from "./index-nd39rssn.js";
5
+ } from "./index-7jr9mfp2.js";
6
6
 
7
7
  // pkgs/@akanjs/devkit/docs/frameworkGraph.ts
8
8
  import { readdir, readFile, realpath, stat } from "fs/promises";
@@ -1,17 +1,17 @@
1
1
  // @bun
2
2
  import {
3
3
  runner
4
- } from "./index-neassptx.js";
4
+ } from "./index-sh3yzse2.js";
5
5
  import {
6
6
  AppExecutor2
7
- } from "./index-trp7jdr1.js";
7
+ } from "./index-cet2s7xk.js";
8
8
  import {
9
9
  jsonText,
10
10
  workflowStatus,
11
11
  createWorkflowBaselineSummary,
12
12
  buildAkanModuleContextIndex,
13
13
  toolingRolloutGate
14
- } from "./index-669sg3yp.js";
14
+ } from "./index-ean2tff1.js";
15
15
  import {
16
16
  buildResourceList,
17
17
  codexMcpConfigPath,
@@ -21,35 +21,219 @@ import {
21
21
  upsertCodexMcpServerBlock,
22
22
  renderDoctorText,
23
23
  AkanContextAnalyzer
24
- } from "./index-er2ja34m.js";
24
+ } from "./index-6bryy19d.js";
25
25
  import {
26
26
  Prompter2
27
27
  } from "./index-89x8tp7z.js";
28
28
  import {
29
29
  NativeApp
30
- } from "./index-q57rsax4.js";
30
+ } from "./index-wq8pnev4.js";
31
31
  import {
32
32
  isPlaceholderAppId
33
- } from "./index-jfkh776h.js";
33
+ } from "./index-12vv4g80.js";
34
34
  import {
35
35
  getMobileTargets,
36
36
  appIdsOf
37
37
  } from "./index-m9jj544v.js";
38
38
  import {
39
39
  WorkspaceGraph
40
- } from "./index-sp331bww.js";
40
+ } from "./index-81qt1jyj.js";
41
41
  import {
42
42
  RepairRunner
43
- } from "./index-bzdq8wfw.js";
43
+ } from "./index-g541mhzw.js";
44
44
  import {
45
45
  WorkflowRunner
46
- } from "./index-t329y8am.js";
46
+ } from "./index-gh741qft.js";
47
47
 
48
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/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
+
53
237
  // pkgs/@akanjs/devkit/context/akanMcpToolError.ts
54
238
  import { AkanError } from "akanjs/base";
55
239
 
@@ -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