@akanjs/cli 3.1.1 → 3.1.2-rc.1

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 (113) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-dyc45f5w.js +11 -0
  3. package/{CodeAgentRpcHost-9g27hmer.js → CodeAgentRpcHost-6dzfkvsc.js} +1 -1
  4. package/CodeAgentRpcListener-tcwrdvst.js +182 -0
  5. package/{CodeTui-h6yz2kvq.js → CodeTui-q55b2zrn.js} +25 -8
  6. package/TunnelShare-hdq9h1hr.js +14 -0
  7. package/{agent.command-3r4jsck8.js → agent.command-20zaqe60.js} +18 -15
  8. package/akanCode.js +8 -7
  9. package/{application.command-g7xv6ad0.js → application.command-nd0fshsk.js} +11 -11
  10. package/{applicationBuildRunner-qvjnhr9j.js → applicationBuildRunner-s13x3zqb.js} +10 -9
  11. package/buildBatch.proc.js +6 -6
  12. package/{cloud.command-6ebygmhw.js → cloud.command-8kbddsz9.js} +25 -18
  13. package/cloud.script-hgvvajm3.js +27 -0
  14. package/code.command-625bg8s8.js +345 -0
  15. package/{context.command-svdh6b2w.js → context.command-p6haqjay.js} +19 -18
  16. package/context.runner-rsnqnk9j.js +27 -0
  17. package/{dependencyScanner-3afj2vt1.js → dependencyScanner-78sq8m4q.js} +2 -2
  18. package/{fileSys-wzzrntkw.js → fileSys-zpvt5gtf.js} +1 -1
  19. package/{guideline.command-qwp3tnjx.js → guideline.command-195g0h9a.js} +4 -4
  20. package/guidelines/agentRule/agentRule.instruction.md +22 -8
  21. package/guidelines/conventions/rules/auth.md +5 -4
  22. package/guidelines/conventions/rules/config.md +5 -1
  23. package/guidelines/conventions/rules/gates.md +2 -1
  24. package/guidelines/conventions/rules/module.md +1 -1
  25. package/guidelines/conventions/rules/server.md +8 -3
  26. package/guidelines/conventions/rules/ssr.md +2 -2
  27. package/guidelines/conventions/rules/tsx.md +2 -1
  28. package/guidelines/pageRule/pageRule.instruction.md +4 -4
  29. package/guidelines/runtimeRule/runtimeRule.instruction.md +35 -25
  30. package/guidelines/ssrRule/ssrRule.instruction.md +11 -10
  31. package/guidelines/transportRule/transportRule.instruction.md +5 -4
  32. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +1 -1
  33. package/incrementalBuilder.proc.js +4 -4
  34. package/{index-w4k2ragk.js → index-00a7j05x.js} +7 -7
  35. package/{index-w7q6h97v.js → index-0j1t1h2b.js} +3 -1
  36. package/{index-payhwt51.js → index-1h2jc0x3.js} +141 -67
  37. package/{index-vxmy1p4f.js → index-1qsd8ft1.js} +63 -123
  38. package/{index-s6da8ta9.js → index-2mwjshz5.js} +158 -51
  39. package/index-2nxk8wgs.js +266 -0
  40. package/{index-k5jbcxyh.js → index-2phm56a1.js} +49 -8
  41. package/{index-jje9qzyq.js → index-35j83zkd.js} +37 -3
  42. package/{index-m5n3ka0p.js → index-4am4dvmf.js} +13 -2
  43. package/index-75y7bcz4.js +28 -0
  44. package/{index-b8c289dx.js → index-7apsdr5g.js} +55 -12
  45. package/{index-8559hsz4.js → index-84h43kg6.js} +6 -5
  46. package/{index-eja64h28.js → index-9zy8479y.js} +5 -3
  47. package/{index-96wzdhfh.js → index-a1vb3x7t.js} +209 -36
  48. package/{index-52w0fvh8.js → index-bns3wcpc.js} +15 -0
  49. package/{index-am36s3jh.js → index-cjmjvg4r.js} +157 -117
  50. package/{index-1p0qbq3m.js → index-defp4gmb.js} +1 -1
  51. package/{index-4pdts00b.js → index-ewbmfarf.js} +10 -8
  52. package/{index-9rvcs76p.js → index-fhw7yq2d.js} +10 -10
  53. package/{index-8scw1pjk.js → index-g500c5j9.js} +178 -82
  54. package/{index-qxzrp5xt.js → index-g841cap9.js} +4 -4
  55. package/{index-qkkdhjm6.js → index-gr9thy79.js} +5 -5
  56. package/{index-4pf8g7ff.js → index-h7hehkw6.js} +3 -0
  57. package/{index-4mj92tsh.js → index-hm0tn7qv.js} +73 -68
  58. package/{index-r2wedvqn.js → index-j6eeh5d7.js} +1 -1
  59. package/{index-tgt2fnd6.js → index-j7hwy56s.js} +3 -3
  60. package/{index-rnphv731.js → index-jc2zbwra.js} +2 -2
  61. package/{index-z4b84y6k.js → index-khk05tsf.js} +1 -1
  62. package/{index-tvehn2sp.js → index-qd7xn2bk.js} +1 -1
  63. package/{index-266dewjs.js → index-qw6814m4.js} +53 -15
  64. package/{index-zcf6k8a5.js → index-raz588b3.js} +47 -12
  65. package/{index-at7bz0xq.js → index-s4nvxpzm.js} +2 -0
  66. package/{index-3yz30c07.js → index-sp0qsr7a.js} +114 -12
  67. package/{index-1shvxzt0.js → index-sveq36gh.js} +39 -42
  68. package/{index-r2w2eh93.js → index-t1t9wq9a.js} +4 -4
  69. package/index-t78230d7.js +191 -0
  70. package/{index-r0k3ham2.js → index-tgqameyb.js} +4 -4
  71. package/{index-dd44g6vz.js → index-tp56652m.js} +5 -5
  72. package/index-w15mg3km.js +389 -0
  73. package/{index-xq543a5y.js → index-y4kcmbt2.js} +2 -2
  74. package/index-yf9wc28h.js +52 -0
  75. package/{index-xqgwjz7a.js → index-zbrwnmf1.js} +9 -7
  76. package/{index-xxfy1jp2.js → index-zttm13c3.js} +4 -4
  77. package/index.js +24 -24
  78. package/{library.command-2853y6mk.js → library.command-63hgt9te.js} +4 -4
  79. package/{localRegistry.command-76ds31p4.js → localRegistry.command-g3f8k25t.js} +43 -23
  80. package/{module.command-yfnb0abs.js → module.command-r4sa2khp.js} +7 -6
  81. package/{package.command-d9s86hp9.js → package.command-96eheyvd.js} +5 -5
  82. package/package.json +2 -2
  83. package/{page.command-6a8a8rd1.js → page.command-gs6d841d.js} +4 -4
  84. package/{pipeline.command-rt3rwd2z.js → pipeline.command-wdfvdbfj.js} +3 -3
  85. package/{primitive.command-emcebgrq.js → primitive.command-dfsv4mpe.js} +8 -7
  86. package/{projectTypecheck-51m7eh1f.js → projectTypecheck-kqj1t6hb.js} +1 -1
  87. package/{prompter-hgcta8pb.js → prompter-qrwx1p17.js} +2 -2
  88. package/{quality.command-xtrk0n3x.js → quality.command-webzxee2.js} +6 -4
  89. package/{repair.command-51szxnxx.js → repair.command-3r3j1xre.js} +7 -6
  90. package/{scalar.command-8qv27t82.js → scalar.command-e8y47j6d.js} +6 -5
  91. package/skills/akan-agent/SKILL.md +8 -1
  92. package/skills/akan-code/SKILL.md +37 -11
  93. package/skills/akan-debug/SKILL.md +2 -1
  94. package/skills/akan-err/SKILL.md +2 -1
  95. package/skills/akan-query/SKILL.md +3 -2
  96. package/skills/akan-runtime/SKILL.md +3 -0
  97. package/{subspace.command-pn56pnh8.js → subspace.command-a1sf9n5a.js} +12 -10
  98. package/templates/appSample/lib/task/task.signal.ts +14 -9
  99. package/templates/appSample/srvkit/guards.ts +11 -0
  100. package/templates/service/__model__.dictionary.ts +3 -5
  101. package/templates/workspaceRoot/.gitignore.template +1 -0
  102. package/{tunnel.command-q2h0j2en.js → tunnel.command-dcb0wg93.js} +25 -13
  103. package/{verify.command-z1dsbmrt.js → verify.command-yyepccbh.js} +13 -11
  104. package/{workflow.command-r3y67jeq.js → workflow.command-z5pg9ay0.js} +12 -11
  105. package/{workspace.command-t2f0xsrw.js → workspace.command-d7x5jttw.js} +74 -47
  106. package/CodeAgent-35wnb7w5.js +0 -9
  107. package/CodeAgentRpcListener-7p7z5dd7.js +0 -97
  108. package/TunnelShare-xyjpa7gx.js +0 -14
  109. package/cloud.script-0s1jybd5.js +0 -26
  110. package/code.command-mpkm2emr.js +0 -167
  111. package/context.runner-ch0z3a8g.js +0 -26
  112. package/index-c6eggbee.js +0 -123
  113. package/index-ksfgqq1x.js +0 -49
@@ -0,0 +1,266 @@
1
+ // @bun
2
+ // pkgs/@akanjs/language/ast.ts
3
+ var createAst = (ts) => {
4
+ const sourceFileFor = (fileName, content, scriptKind = ts.ScriptKind.TS) => ts.createSourceFile(fileName, content, ts.ScriptTarget.Latest, true, scriptKind);
5
+ const nodeName = (node) => {
6
+ if (!node)
7
+ return null;
8
+ if (ts.isIdentifier(node) || ts.isStringLiteral(node) || ts.isNumericLiteral(node))
9
+ return node.text;
10
+ return null;
11
+ };
12
+ const propertyName = (node) => ts.isPropertyAssignment(node) || ts.isShorthandPropertyAssignment(node) || ts.isMethodDeclaration(node) ? nodeName(node.name) : null;
13
+ const expressionName = (expression) => {
14
+ if (ts.isIdentifier(expression))
15
+ return expression.text;
16
+ if (ts.isPropertyAccessExpression(expression))
17
+ return expression.name.text;
18
+ if (ts.isCallExpression(expression))
19
+ return expressionName(expression.expression);
20
+ if (ts.isAsExpression(expression))
21
+ return expressionName(expression.expression);
22
+ return null;
23
+ };
24
+ const callExpressionName = (node) => ts.isPropertyAccessExpression(node.expression) ? node.expression.name.text : expressionName(node.expression);
25
+ const firstObjectReturnedByArrow = (node) => {
26
+ if (!ts.isArrowFunction(node) && !ts.isFunctionExpression(node))
27
+ return null;
28
+ if (ts.isObjectLiteralExpression(node.body))
29
+ return node.body;
30
+ if (ts.isParenthesizedExpression(node.body) && ts.isObjectLiteralExpression(node.body.expression)) {
31
+ return node.body.expression;
32
+ }
33
+ if (!ts.isBlock(node.body))
34
+ return null;
35
+ for (const statement of node.body.statements) {
36
+ if (ts.isReturnStatement(statement) && statement.expression && ts.isObjectLiteralExpression(statement.expression)) {
37
+ return statement.expression;
38
+ }
39
+ }
40
+ return null;
41
+ };
42
+ const heritageCallNamed = (node, names) => {
43
+ const heritage = node.heritageClauses?.flatMap((clause) => [...clause.types]) ?? [];
44
+ for (const { expression } of heritage) {
45
+ if (!ts.isCallExpression(expression))
46
+ continue;
47
+ const callee = expressionName(expression.expression);
48
+ if (callee && names.has(callee))
49
+ return { callee, call: expression };
50
+ }
51
+ return null;
52
+ };
53
+ const viaNames = new Set(["via"]);
54
+ const heritageCall = (node) => heritageCallNamed(node, viaNames)?.call ?? null;
55
+ return {
56
+ sourceFileFor,
57
+ nodeName,
58
+ propertyName,
59
+ expressionName,
60
+ callExpressionName,
61
+ firstObjectReturnedByArrow,
62
+ heritageCallNamed,
63
+ heritageCall
64
+ };
65
+ };
66
+
67
+ // pkgs/@akanjs/language/moduleFacts.ts
68
+ var moduleCallees = new Set(["via", "from", "into", "serve", "slice", "endpoint", "store"]);
69
+ var argMethods = new Set(["param", "body", "search", "room", "msg"]);
70
+ var createFactReader = (ts, ast) => {
71
+ const spanOf = (source, node) => {
72
+ const start = node.getStart(source);
73
+ const end = node.getEnd();
74
+ const head = source.getLineAndCharacterOfPosition(start);
75
+ const tail = source.getLineAndCharacterOfPosition(end);
76
+ return {
77
+ fileName: source.fileName,
78
+ start,
79
+ end,
80
+ line: head.line,
81
+ character: head.character,
82
+ endLine: tail.line,
83
+ endCharacter: tail.character
84
+ };
85
+ };
86
+ const unwrap = (expression) => {
87
+ let current = expression;
88
+ while (ts.isParenthesizedExpression(current) || ts.isAsExpression(current) || ts.isSatisfiesExpression(current))
89
+ current = current.expression;
90
+ return current;
91
+ };
92
+ const moduleRefOf = (expression, holder) => {
93
+ let current = expression && unwrap(expression);
94
+ while (current && ts.isCallExpression(current) && ts.isPropertyAccessExpression(current.expression))
95
+ current = current.expression.expression;
96
+ if (current && ts.isStringLiteral(current))
97
+ return current.text;
98
+ if (!current || !ts.isPropertyAccessExpression(current))
99
+ return null;
100
+ return ts.isIdentifier(current.expression) && current.expression.text === holder ? current.name.text : null;
101
+ };
102
+ const returnedObject = (builder) => builder ? ast.firstObjectReturnedByArrow(builder) : null;
103
+ const builderOf = (call) => [...call.arguments].reverse().find((arg) => ts.isArrowFunction(arg) || ts.isFunctionExpression(arg));
104
+ const guardsIn = (object) => {
105
+ const guards = object?.properties.find((property) => ts.isPropertyAssignment(property) && ast.nodeName(property.name) === "guards")?.initializer;
106
+ if (!guards)
107
+ return [];
108
+ if (ts.isArrayLiteralExpression(guards))
109
+ return guards.elements.map((element) => ast.expressionName(element)).filter((name) => name !== null);
110
+ if (ts.isObjectLiteralExpression(guards))
111
+ return guards.properties.filter(ts.isPropertyAssignment).map((property) => `${ast.nodeName(property.name)} ${ast.expressionName(property.initializer) ?? "?"}`);
112
+ const single = ast.expressionName(guards);
113
+ return single ? [single] : [];
114
+ };
115
+ const optionObjectOf = (call) => call.arguments.find((arg) => ts.isObjectLiteralExpression(arg) && arg.properties.some((property) => ast.propertyName(property) === "guards"));
116
+ const chainOf = (initializer) => {
117
+ let root = unwrap(initializer);
118
+ const methods = [];
119
+ while (ts.isCallExpression(root) && ts.isPropertyAccessExpression(root.expression) && ts.isCallExpression(unwrap(root.expression.expression))) {
120
+ methods.push(root.expression.name.text);
121
+ root = unwrap(root.expression.expression);
122
+ }
123
+ return { root: ts.isCallExpression(root) ? root : null, methods };
124
+ };
125
+ const keyName = (property) => ts.isPropertyAssignment(property) || ts.isMethodDeclaration(property) || ts.isShorthandPropertyAssignment(property) ? property.name : null;
126
+ const objectKeys = (source, object) => (object?.properties ?? []).flatMap((property) => {
127
+ const name = ast.propertyName(property);
128
+ const node = keyName(property);
129
+ return name && node ? [{ name, span: spanOf(source, node) }] : [];
130
+ });
131
+ const sliceKeysOf = (source, builder) => (returnedObject(builder)?.properties ?? []).flatMap((property) => {
132
+ if (!ts.isPropertyAssignment(property))
133
+ return [];
134
+ const name = ast.nodeName(property.name);
135
+ if (!name)
136
+ return [];
137
+ const { root, methods } = chainOf(property.initializer);
138
+ return [
139
+ {
140
+ name,
141
+ span: spanOf(source, property.name),
142
+ guards: root ? guardsIn(optionObjectOf(root)) : [],
143
+ live: methods.includes("live"),
144
+ argCount: methods.filter((method) => argMethods.has(method)).length
145
+ }
146
+ ];
147
+ });
148
+ const verbReaderOf = (parameter) => {
149
+ const verbs = new Map;
150
+ if (parameter && ts.isObjectBindingPattern(parameter.name))
151
+ for (const element of parameter.name.elements) {
152
+ const verb = element.propertyName ?? element.name;
153
+ if (ts.isIdentifier(verb) && ts.isIdentifier(element.name))
154
+ verbs.set(element.name.text, verb.text);
155
+ }
156
+ const holder = parameter && ts.isIdentifier(parameter.name) ? parameter.name.text : null;
157
+ return (callee) => {
158
+ if (callee && ts.isIdentifier(callee))
159
+ return verbs.get(callee.text) ?? null;
160
+ if (callee && ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression) && callee.expression.text === holder)
161
+ return callee.name.text;
162
+ return null;
163
+ };
164
+ };
165
+ const endpointKeysOf = (source, builder) => {
166
+ const verbOf = verbReaderOf(builder?.parameters[0]);
167
+ return (returnedObject(builder)?.properties ?? []).flatMap((property) => {
168
+ if (!ts.isPropertyAssignment(property))
169
+ return [];
170
+ const name = ast.nodeName(property.name);
171
+ if (!name)
172
+ return [];
173
+ const { root, methods } = chainOf(property.initializer);
174
+ return [
175
+ {
176
+ name,
177
+ span: spanOf(source, property.name),
178
+ verb: root ? verbOf(root.expression) : null,
179
+ guards: root ? guardsIn(optionObjectOf(root)) : [],
180
+ argCount: methods.filter((method) => argMethods.has(method)).length
181
+ }
182
+ ];
183
+ });
184
+ };
185
+ const filterQueriesOf = (source, builder) => {
186
+ const query = returnedObject(builder)?.properties.find((property) => ts.isPropertyAssignment(property) && ast.nodeName(property.name) === "query")?.initializer;
187
+ return query && ts.isObjectLiteralExpression(query) ? objectKeys(source, query) : [];
188
+ };
189
+ const constantOf = (source, name, call) => {
190
+ const parents = call.arguments.map(unwrap).filter((arg) => ts.isIdentifier(arg) || ts.isPropertyAccessExpression(arg)).map((arg) => ast.expressionName(arg)).filter((parent) => parent !== null);
191
+ const fields = call.arguments.flatMap((arg) => objectKeys(source, ast.firstObjectReturnedByArrow(arg)));
192
+ return { ...name, parents, fields };
193
+ };
194
+ const lowerFirst = (text) => text.charAt(0).toLowerCase() + text.slice(1);
195
+ const read = (source, owner) => {
196
+ const facts = {
197
+ fileName: source.fileName,
198
+ owner,
199
+ constants: [],
200
+ filters: [],
201
+ models: [],
202
+ services: [],
203
+ slices: [],
204
+ endpoints: [],
205
+ stores: []
206
+ };
207
+ for (const statement of source.statements) {
208
+ if (!ts.isClassDeclaration(statement) || !statement.name)
209
+ continue;
210
+ const heritage = ast.heritageCallNamed(statement, moduleCallees);
211
+ if (!heritage)
212
+ continue;
213
+ const { callee, call } = heritage;
214
+ const name = { name: statement.name.text, span: spanOf(source, statement.name) };
215
+ const builder = builderOf(call);
216
+ if (callee === "via")
217
+ facts.constants.push(constantOf(source, name, call));
218
+ else if (callee === "from")
219
+ facts.filters.push({ ...name, queries: filterQueriesOf(source, builder) });
220
+ else if (callee === "into")
221
+ facts.models.push({ ...name, model: name.name.endsWith("Model") ? lowerFirst(name.name.slice(0, -5)) : null });
222
+ else if (callee === "serve")
223
+ facts.services.push({ ...name, model: moduleRefOf(call.arguments[0], "db") });
224
+ else if (callee === "slice")
225
+ facts.slices.push({
226
+ ...name,
227
+ model: moduleRefOf(call.arguments[0], "srv"),
228
+ guards: guardsIn(call.arguments.find(ts.isObjectLiteralExpression)),
229
+ keys: sliceKeysOf(source, builder)
230
+ });
231
+ else if (callee === "endpoint")
232
+ facts.endpoints.push({
233
+ ...name,
234
+ model: moduleRefOf(call.arguments[0], "srv"),
235
+ keys: endpointKeysOf(source, builder)
236
+ });
237
+ else if (callee === "store")
238
+ facts.stores.push({
239
+ ...name,
240
+ model: moduleRefOf(call.arguments[0], "sig"),
241
+ stateKeys: objectKeys(source, returnedObject(builder))
242
+ });
243
+ }
244
+ return facts;
245
+ };
246
+ return { read, spanOf, moduleRefOf, chainOf, unwrap };
247
+ };
248
+
249
+ // pkgs/@akanjs/language/nameTable.ts
250
+ import {
251
+ databaseStateNames,
252
+ endpointNames,
253
+ formSetterNames,
254
+ modelNames,
255
+ moduleNames,
256
+ queryNames,
257
+ sliceNames,
258
+ stateSetterName
259
+ } from "akanjs/common/akanNames.ts";
260
+
261
+ // pkgs/@akanjs/language/akanIndex.ts
262
+ var stateReceivers = new Set(["use", "sel", "get", "do"]);
263
+ var lensFamilies = new Set(["slice", "query", "formSetter", "storeState", "endpoint"]);
264
+ var modellessFamilies = new Set(["query", "storeState", "endpoint"]);
265
+ var receiverGap = String.raw`(?:\s|\)|\/\*[\s\S]*?\*\/)*`;
266
+ export { createAst, createFactReader };
@@ -4,23 +4,45 @@ import {
4
4
  generatedFilePathsForTarget,
5
5
  writeGeneratedSyncState,
6
6
  createRepairReport,
7
+ isWorkflowSysName,
8
+ isWorkflowModuleName,
7
9
  renderRepairReport
8
- } from "./index-4mj92tsh.js";
10
+ } from "./index-hm0tn7qv.js";
9
11
  import {
10
12
  AkanContextAnalyzer
11
- } from "./index-tgt2fnd6.js";
13
+ } from "./index-j7hwy56s.js";
12
14
  import {
13
15
  runner
14
- } from "./index-eja64h28.js";
16
+ } from "./index-9zy8479y.js";
15
17
 
16
18
  // pkgs/@akanjs/cli/repair/repair.runner.ts
17
- var spawnShell = async (workspace, command) => await workspace.spawn("bash", ["-lc", command.startsWith("akan ") ? `bun run ${command}` : command], {
18
- cwd: workspace.workspaceRoot
19
- });
19
+ var akanArgPattern = /^(?:--?[a-z][a-zA-Z0-9-]*|[A-Za-z0-9@_][A-Za-z0-9@._/:,=-]*)$/;
20
+ var akanCommandArgs = (command) => {
21
+ if (/[^\x20-\x7e]/.test(command))
22
+ return null;
23
+ const [head, ...args] = command.trim().split(/ +/);
24
+ if (head !== "akan" || args.length === 0)
25
+ return null;
26
+ return args.every((arg) => akanArgPattern.test(arg) && !arg.includes("..")) ? args : null;
27
+ };
28
+ var spawnAkan = async (workspace, command) => {
29
+ const args = akanCommandArgs(command);
30
+ if (!args)
31
+ throw Object.assign(new Error(`Not run: only an akan command with plain arguments runs here, not ${JSON.stringify(command)}.`), {
32
+ code: 2
33
+ });
34
+ return await workspace.spawn("bun", ["run", "akan", ...args], { cwd: workspace.workspaceRoot });
35
+ };
36
+ var isWorkspaceTarget = async (workspace, target, { withPkgs = false } = {}) => {
37
+ const [apps, libs] = await workspace.getSyss();
38
+ if (isWorkflowSysName(target) && (apps.includes(target) || libs.includes(target)))
39
+ return true;
40
+ return withPkgs && (await workspace.getPkgs()).includes(target);
41
+ };
20
42
  var defaultExecutor = (workspace) => async (command) => {
21
43
  const base = { command: command.command, reason: command.reason };
22
44
  try {
23
- return { ...base, status: "passed", exitCode: 0, stdout: await spawnShell(workspace, command.command) };
45
+ return { ...base, status: "passed", exitCode: 0, stdout: await spawnAkan(workspace, command.command) };
24
46
  } catch (error) {
25
47
  const commandError = error;
26
48
  return {
@@ -38,6 +60,17 @@ var targetMissing = (input) => ({
38
60
  input,
39
61
  message: `Repair command requires "${input}".`
40
62
  });
63
+ var repairInputNouns = {
64
+ app: "an app or library of this workspace",
65
+ target: "an app, library or package of this workspace",
66
+ module: "a module name"
67
+ };
68
+ var targetUnknown = (input, value) => ({
69
+ severity: "error",
70
+ code: "repair-input-unknown",
71
+ input,
72
+ message: `Repair input "${input}" is not ${repairInputNouns[input] ?? "a known name"}: ${JSON.stringify(value)}.`
73
+ });
41
74
  var repairAction = (kind, command, reason, safeToRun) => ({
42
75
  kind,
43
76
  command,
@@ -82,6 +115,8 @@ class RepairRunner extends runner("repair") {
82
115
  if (!app) {
83
116
  return createRepairReport({ command: "repair generated", kind, diagnostics: [targetMissing("app")] });
84
117
  }
118
+ if (!await isWorkspaceTarget(workspace, app))
119
+ return createRepairReport({ command: "repair generated", kind, diagnostics: [targetUnknown("app", app)] });
85
120
  const command = { command: `akan sync ${app}`, reason: "Refresh generated Akan files from source conventions." };
86
121
  const result = await execute(command);
87
122
  const [apps] = await workspace.getSyss();
@@ -103,6 +138,8 @@ class RepairRunner extends runner("repair") {
103
138
  if (!target) {
104
139
  return createRepairReport({ command: `repair ${kind}`, kind, diagnostics: [targetMissing("target")] });
105
140
  }
141
+ if (!await isWorkspaceTarget(workspace, target, { withPkgs: true }))
142
+ return createRepairReport({ command: `repair ${kind}`, kind, diagnostics: [targetUnknown("target", target)] });
106
143
  const command = { command: `akan lint ${target}`, reason: "Run Biome lint/fix path for formatting and imports." };
107
144
  return createRepairReport({
108
145
  command: `repair ${kind}`,
@@ -121,6 +158,10 @@ class RepairRunner extends runner("repair") {
121
158
  diagnostics: [!app ? targetMissing("app") : targetMissing("module")]
122
159
  });
123
160
  }
161
+ if (!await isWorkspaceTarget(workspace, app) || !isWorkflowModuleName(module)) {
162
+ const unknown = isWorkflowModuleName(module) ? targetUnknown("app", app) : targetUnknown("module", module);
163
+ return createRepairReport({ command: `repair ${kind}`, kind, diagnostics: [unknown] });
164
+ }
124
165
  const doctor = await AkanContextAnalyzer.doctor(workspace, { strict: true });
125
166
  const diagnostics = doctor.diagnostics.filter((diagnostic) => {
126
167
  if (kind === "dictionary")
@@ -151,4 +192,4 @@ class RepairRunner extends runner("repair") {
151
192
  }
152
193
  }
153
194
 
154
- export { spawnShell, RepairRunner };
195
+ export { spawnAkan, isWorkspaceTarget, RepairRunner };
@@ -1,13 +1,44 @@
1
1
  // @bun
2
+ import {
3
+ FileSys2
4
+ } from "./index-bns3wcpc.js";
5
+ import {
6
+ ShellOnlyEnv
7
+ } from "./index-yf9wc28h.js";
8
+
2
9
  // pkgs/@akanjs/devkit/codeAgent/agent/akanCodePaths.ts
3
10
  import { existsSync } from "fs";
4
11
  import { homedir } from "os";
5
12
  import path from "path";
13
+
14
+ // pkgs/@akanjs/devkit/codeAgent/agent/AkanCodeEnv.ts
15
+ var akanCodeGuardedEnv = [
16
+ "AKAN_CODE_HOME",
17
+ "AKAN_CODE_CAN_PROMPT",
18
+ "AKAN_CODE_PROXY_URL",
19
+ "AKAN_CODE_PROXY_TOKEN",
20
+ "AKAN_CODE_PROXY_TOKEN_FILE",
21
+ "AKAN_CODE_PROXY_PROVIDERS",
22
+ "AKAN_CODE_RPC_TOKEN_FILE"
23
+ ];
24
+
25
+ class AkanCodeEnv {
26
+ static #env = new ShellOnlyEnv(akanCodeGuardedEnv);
27
+ static get(key) {
28
+ return AkanCodeEnv.#env.get(key);
29
+ }
30
+ static ignored() {
31
+ return AkanCodeEnv.#env.ignored();
32
+ }
33
+ }
34
+
35
+ // pkgs/@akanjs/devkit/codeAgent/agent/akanCodePaths.ts
6
36
  var builtinSkillsDir = () => {
7
37
  const candidates = [path.join(import.meta.dir, "skills"), path.join(import.meta.dir, "..", "skills")];
8
38
  return candidates.find((candidate) => existsSync(candidate));
9
39
  };
10
- var globalDir = () => process.env.AKAN_CODE_HOME ?? path.join(homedir(), ".akan", "code");
40
+ var globalDir = () => AkanCodeEnv.get("AKAN_CODE_HOME") ?? path.join(homedir(), ".akan", "code");
41
+ var ensureGlobalDir = () => FileSys2.ensurePrivateDir(globalDir());
11
42
  var akanCodePaths2 = {
12
43
  workspaceDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code"),
13
44
  sessionsDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "sessions"),
@@ -19,9 +50,12 @@ var akanCodePaths2 = {
19
50
  globalMcpFile: () => path.join(globalDir(), "mcp.json"),
20
51
  globalSkillsDir: () => path.join(globalDir(), "skills"),
21
52
  globalDir,
53
+ ensureGlobalDir,
22
54
  authFile: () => path.join(globalDir(), "auth.json"),
23
55
  mcpAuthFile: () => path.join(globalDir(), "mcpAuth.json"),
24
- modelsFile: () => path.join(globalDir(), "models.json")
56
+ modelsFile: () => path.join(globalDir(), "models.json"),
57
+ trustFile: () => path.join(globalDir(), "trust.json"),
58
+ rpcTokenFile: (port) => path.join(globalDir(), "rpc", `${port}.token`)
25
59
  };
26
60
 
27
- export { akanCodePaths2 };
61
+ export { AkanCodeEnv, akanCodePaths2 };
@@ -1,7 +1,18 @@
1
1
  // @bun
2
+ import {
3
+ ShellOnlyEnv
4
+ } from "./index-yf9wc28h.js";
5
+
2
6
  // pkgs/@akanjs/cli/npmRegistry.ts
7
+ import { Logger } from "akanjs/common";
3
8
  var defaultNpmRegistry = "https://registry.npmjs.org";
4
- var getNpmRegistryUrl = (registryUrl = process.env.AKAN_NPM_REGISTRY ?? defaultNpmRegistry) => registryUrl.replace(/\/+$/, "");
9
+ var registryEnv = new ShellOnlyEnv(["AKAN_NPM_REGISTRY"]);
10
+ var npmRegistryFromEnv = () => registryEnv.get("AKAN_NPM_REGISTRY");
11
+ var warnIgnoredNpmRegistry = () => {
12
+ for (const line of registryEnv.ignored())
13
+ Logger.warn(line);
14
+ };
15
+ var getNpmRegistryUrl = (registryUrl = npmRegistryFromEnv() ?? defaultNpmRegistry) => registryUrl.replace(/\/+$/, "");
5
16
  async function getLatestPackageVersion(packageName, tag = "latest", registryUrl) {
6
17
  const registry = getNpmRegistryUrl(registryUrl);
7
18
  const url = `${registry}/${encodeURIComponent(packageName).replace(/^%40/, "@")}`;
@@ -15,4 +26,4 @@ async function getLatestPackageVersion(packageName, tag = "latest", registryUrl)
15
26
  return version;
16
27
  }
17
28
 
18
- export { getNpmRegistryUrl, getLatestPackageVersion };
29
+ export { npmRegistryFromEnv, warnIgnoredNpmRegistry, getNpmRegistryUrl, getLatestPackageVersion };
@@ -0,0 +1,28 @@
1
+ // @bun
2
+ // pkgs/@akanjs/devkit/codeAgent/agent/codeAgentHosts.ts
3
+ import { isIP } from "net";
4
+ var bare = (hostname) => hostname.replace(/^\[|\]$/g, "").replace(/\.$/, "").toLowerCase();
5
+ var codeAgentIsLoopback = (hostname) => {
6
+ const host = bare(hostname);
7
+ if (host === "localhost" || host.endsWith(".localhost"))
8
+ return true;
9
+ if (isIP(host) === 4)
10
+ return host.startsWith("127.");
11
+ if (isIP(host) === 6)
12
+ return host === "::1" || /^::ffff:(127\.\d+\.\d+\.\d+|7f[0-9a-f]{2}:[0-9a-f]{1,4})$/.test(host);
13
+ return false;
14
+ };
15
+ var codeAgentHostListed = (hostname, hosts) => {
16
+ const host = bare(hostname);
17
+ return hosts.some((entry) => host === entry || host.endsWith(`.${entry}`));
18
+ };
19
+ var codeAgentHostOf = (url) => {
20
+ try {
21
+ const parsed = new URL(url);
22
+ return parsed.protocol === "http:" || parsed.protocol === "https:" ? parsed.hostname : undefined;
23
+ } catch {
24
+ return;
25
+ }
26
+ };
27
+
28
+ export { codeAgentIsLoopback, codeAgentHostListed, codeAgentHostOf };
@@ -10,11 +10,11 @@ import {
10
10
  AppExecutor,
11
11
  LibExecutor,
12
12
  PkgExecutor
13
- } from "./index-8scw1pjk.js";
13
+ } from "./index-g500c5j9.js";
14
14
  import {
15
15
  WorkspaceRunner,
16
16
  AkanQualityScanner
17
- } from "./index-am36s3jh.js";
17
+ } from "./index-cjmjvg4r.js";
18
18
 
19
19
  // pkgs/@akanjs/cli/verify/verifyComments.ts
20
20
  import { existsSync } from "fs";
@@ -26,6 +26,7 @@ class VerifyComments {
26
26
  static #codeFile = /\.[cm]?[jt]sx?$/;
27
27
  static #directive = /^(\/\/\/?|\/\*+)\s*(biome-ignore|@ts-|eslint-|prettier-ignore|#region|#endregion|<reference|[#@]__PURE__|@__NO_SIDE_EFFECTS__)/;
28
28
  static #typescriptLoad;
29
+ static #templateCommentsLoad;
29
30
  static #loadTypescript() {
30
31
  VerifyComments.#typescriptLoad ??= import("typescript").then((mod) => mod.default ?? mod);
31
32
  return VerifyComments.#typescriptLoad;
@@ -38,6 +39,7 @@ class VerifyComments {
38
39
  if (!changed)
39
40
  return [];
40
41
  const typescript = await VerifyComments.#loadTypescript();
42
+ const templateComments = await VerifyComments.#loadTemplateComments();
41
43
  const diagnostics = [];
42
44
  for (const file of code) {
43
45
  const lines = changed.get(file);
@@ -47,6 +49,8 @@ class VerifyComments {
47
49
  for (const comment of VerifyComments.commentsOf(typescript, file, text)) {
48
50
  if (VerifyComments.#directive.test(comment.text))
49
51
  continue;
52
+ if (VerifyComments.#scaffolded(comment, templateComments))
53
+ continue;
50
54
  if (lines && !VerifyComments.#touches(comment, lines))
51
55
  continue;
52
56
  diagnostics.push({
@@ -98,6 +102,26 @@ class VerifyComments {
98
102
  };
99
103
  });
100
104
  }
105
+ static #scaffolded(comment, templateComments) {
106
+ return comment.text.split(`
107
+ `).every((line) => !line.trim() || templateComments.has(line.trim()));
108
+ }
109
+ static #loadTemplateComments() {
110
+ VerifyComments.#templateCommentsLoad ??= (async () => {
111
+ const comments = new Set;
112
+ const root = ["templates", "../templates"].map((dir) => path.join(import.meta.dir, dir)).find(existsSync);
113
+ if (!root)
114
+ return comments;
115
+ for (const file of new Bun.Glob("**/*.{ts,tsx,template}").scanSync({ cwd: root, dot: true }))
116
+ for (const raw of (await Bun.file(path.join(root, file)).text()).split(/\n|\\n/)) {
117
+ const line = raw.replace(/\\([`$\\])/g, "$1").trim();
118
+ for (const { index } of line.matchAll(/\/\/|\/\*|^\*/g))
119
+ comments.add(line.slice(index).trim());
120
+ }
121
+ return comments;
122
+ })();
123
+ return VerifyComments.#templateCommentsLoad;
124
+ }
101
125
  static #touches(comment, lines) {
102
126
  for (let line = comment.line;line <= comment.lastLine; line++)
103
127
  if (lines.has(line))
@@ -166,16 +190,35 @@ import path2 from "path";
166
190
  // pkgs/@akanjs/cli/verify/verifyDiagnostics.ts
167
191
  class VerifyDiagnostics {
168
192
  static fromTypecheck(records) {
169
- return records.map((record) => ({
170
- step: "typecheck",
171
- file: record.file,
172
- line: record.line,
173
- col: record.col,
174
- code: record.code,
175
- severity: record.severity,
176
- message: record.message.split(`
177
- `)[0] ?? record.message
178
- }));
193
+ return records.map((record) => {
194
+ const message = record.message.split(`
195
+ `)[0] ?? record.message;
196
+ return {
197
+ step: "typecheck",
198
+ file: record.file,
199
+ line: record.line,
200
+ col: record.col,
201
+ code: record.code,
202
+ severity: record.severity,
203
+ ...VerifyDiagnostics.#dictionaryKeyMiss(message) ?? { message }
204
+ };
205
+ });
206
+ }
207
+ static #dictionaryKeyArg = /^(?:Argument of type|Type) '"([\w$-]+)\.([\w$.-]+)"' is not assignable to (?:parameter of )?type '(?:"base\.|ServiceTranslatorKey<"base")/;
208
+ static #dictionaryKeyMiss(message) {
209
+ const [, refName, key] = message.match(VerifyDiagnostics.#dictionaryKeyArg) ?? [];
210
+ if (!refName || !key)
211
+ return null;
212
+ const dictionaryFile = `${refName}.dictionary.ts`;
213
+ if (key.startsWith("error."))
214
+ return {
215
+ message: `"${refName}.${key}" is not an error key of the ${refName} dictionary`,
216
+ fix: `add ${key.slice("error.".length)}: [en, ko] to .error({}) in ${dictionaryFile} (a service module's dictionary must be a serviceDictionary)`
217
+ };
218
+ return {
219
+ message: `"${refName}.${key}" is not a key of the ${refName} dictionary`,
220
+ fix: `check the spelling, or add ${key}: [en, ko] to .translate({}) in ${dictionaryFile}; one-off text takes l.trans({ en, ko })`
221
+ };
179
222
  }
180
223
  static fromBiome(report) {
181
224
  return (report.diagnostics ?? []).filter((diagnostic) => diagnostic.severity === "error" || diagnostic.severity === "warning").map((diagnostic) => ({
@@ -2,16 +2,16 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-eja64h28.js";
5
+ } from "./index-9zy8479y.js";
6
6
  import {
7
7
  FileSys2
8
- } from "./index-52w0fvh8.js";
8
+ } from "./index-bns3wcpc.js";
9
9
  import {
10
10
  PkgExecutor
11
- } from "./index-8scw1pjk.js";
11
+ } from "./index-g500c5j9.js";
12
12
  import {
13
13
  TypeScriptDependencyScanner2
14
- } from "./index-tvehn2sp.js";
14
+ } from "./index-qd7xn2bk.js";
15
15
 
16
16
  // pkgs/@akanjs/cli/package/package.runner.ts
17
17
  import path2 from "path";
@@ -109,6 +109,7 @@ class PackageRunner extends runner("package") {
109
109
  "akanjs",
110
110
  "@akanjs/cli",
111
111
  "@akanjs/devkit",
112
+ "@akanjs/language",
112
113
  "create-akan-workspace"
113
114
  ];
114
115
  static #bundledRuntimeDependencies = {
@@ -179,7 +180,7 @@ class PackageRunner extends runner("package") {
179
180
  packageRuntimeDependencies[pkg.name] = [
180
181
  ...Object.keys(devkitPackageJson.dependencies ?? {}),
181
182
  "tailwind-scrollbar"
182
- ].filter((dep) => dep !== "akanjs" && dep !== "@akanjs/devkit");
183
+ ].filter((dep) => dep !== "akanjs" && dep !== "@akanjs/devkit" && dep !== "@akanjs/language");
183
184
  }
184
185
  const bundledRuntimeDeps = new Set(PackageRunner.#bundledRuntimeDependencies[pkg.name] ?? []);
185
186
  const forcedRuntimeDeps = packageRuntimeDependencies[pkg.name] ?? [];
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  getDirname2,
4
4
  FileSys2
5
- } from "./index-52w0fvh8.js";
5
+ } from "./index-bns3wcpc.js";
6
6
  import {
7
7
  Executor,
8
8
  WorkspaceExecutor,
@@ -10,7 +10,7 @@ import {
10
10
  LibExecutor,
11
11
  PkgExecutor,
12
12
  ModuleExecutor
13
- } from "./index-8scw1pjk.js";
13
+ } from "./index-g500c5j9.js";
14
14
 
15
15
  // pkgs/@akanjs/devkit/commandDecorators/camelToKebabCase.ts
16
16
  var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -738,8 +738,10 @@ ${versionWarning}`), undefined, "error");
738
738
  const opt = args[args.length - 2];
739
739
  reportFailure = async (failure) => await onFailure?.(failure, { usage: false, given: givenOptionsOf(allArgMetas, opt) });
740
740
  const commandArgs = [];
741
- if (targetMeta.targetOption.runsOnWorkspaceRoot)
741
+ if (targetMeta.targetOption.runsOnWorkspaceRoot) {
742
742
  await assertCurrentDirectoryIsWorkspaceRoot();
743
+ WorkspaceExecutor.defaultCloneToLocalEnv(process.cwd());
744
+ }
743
745
  const workspace = WorkspaceExecutor.fromRoot();
744
746
  const commandContext = { values: {} };
745
747
  for (const argMeta of allArgMetas) {