@akanjs/cli 3.1.2-rc.1 → 3.1.2-rc.2

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 (36) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-dyc45f5w.js → CodeAgent-nkk70v5h.js} +2 -2
  3. package/{CodeTui-q55b2zrn.js → CodeTui-sdqz2gxb.js} +1 -1
  4. package/{agent.command-20zaqe60.js → agent.command-5gfrfh8d.js} +7 -7
  5. package/akanCode.js +2 -2
  6. package/{code.command-625bg8s8.js → code.command-5djp5c0n.js} +4 -4
  7. package/{context.command-p6haqjay.js → context.command-5d0bscv6.js} +11 -11
  8. package/{context.runner-rsnqnk9j.js → context.runner-2v5pq18d.js} +10 -10
  9. package/{index-hm0tn7qv.js → index-1404hqcj.js} +102 -4
  10. package/{index-t1t9wq9a.js → index-19cspack.js} +1 -1
  11. package/{index-a1vb3x7t.js → index-3q4kkyd4.js} +3 -3
  12. package/{index-cjmjvg4r.js → index-chjaw222.js} +2 -2
  13. package/{index-j7hwy56s.js → index-dbxac7mz.js} +1 -1
  14. package/{index-qw6814m4.js → index-f6zrhcnk.js} +7 -5
  15. package/index-gf4fcw1n.js +876 -0
  16. package/{index-fbewhg4g.js → index-k64mhwbw.js} +60 -1
  17. package/{index-2phm56a1.js → index-ms1am2wr.js} +2 -2
  18. package/{index-raz588b3.js → index-mzjwq4dd.js} +8 -7
  19. package/{index-jc2zbwra.js → index-pnk67cqd.js} +1 -1
  20. package/{index-g841cap9.js → index-pqdyyxz0.js} +23 -2
  21. package/{index-tgqameyb.js → index-q9q6jjk1.js} +3 -3
  22. package/{index-7apsdr5g.js → index-tw27n941.js} +1 -1
  23. package/{index-fhw7yq2d.js → index-tyt7cw99.js} +3 -3
  24. package/{index-1qsd8ft1.js → index-yep9xcz0.js} +1 -1
  25. package/index.js +11 -11
  26. package/{module.command-r4sa2khp.js → module.command-myykfb6s.js} +3 -3
  27. package/package.json +2 -2
  28. package/{primitive.command-dfsv4mpe.js → primitive.command-eg2c3m97.js} +4 -4
  29. package/{quality.command-webzxee2.js → quality.command-b840977n.js} +3 -3
  30. package/{repair.command-3r3j1xre.js → repair.command-r7z709yf.js} +4 -4
  31. package/{scalar.command-e8y47j6d.js → scalar.command-t6hhty3f.js} +3 -3
  32. package/skills/akan-scaffold/SKILL.md +1 -0
  33. package/{verify.command-yyepccbh.js → verify.command-07fqhpak.js} +4 -4
  34. package/{workflow.command-z5pg9ay0.js → workflow.command-c2jhzf7v.js} +13 -11
  35. package/{workspace.command-d7x5jttw.js → workspace.command-gv20zq1z.js} +14 -14
  36. package/index-2nxk8wgs.js +0 -266
package/index-2nxk8wgs.js DELETED
@@ -1,266 +0,0 @@
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 };