@akanjs/cli 3.1.2-rc.3 → 3.1.2-rc.4
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.
- package/.build-stamp +1 -1
- package/{CodeAgent-n2tkg59z.js → CodeAgent-z34p8m91.js} +2 -2
- package/{CodeTui-9wsdx7ap.js → CodeTui-nvd9fk3g.js} +1 -1
- package/TunnelShare-jwbb50kz.js +14 -0
- package/{agent.command-tffz6wdn.js → agent.command-962mp3kg.js} +15 -15
- package/akanCode.js +2 -2
- package/{application.command-7bkxbrsp.js → application.command-1nr0bqq1.js} +24 -15
- package/{applicationBuildRunner-s13x3zqb.js → applicationBuildRunner-xy7hnfzq.js} +7 -6
- package/buildBatch.proc.js +6 -6
- package/{cloud.command-a792bc10.js → cloud.command-cj7b3m6y.js} +15 -15
- package/cloud.script-8kr7qgfa.js +27 -0
- package/{code.command-ma8dtzww.js → code.command-asq7xrr6.js} +6 -6
- package/{context.command-80a1qhps.js → context.command-fw4g2pw1.js} +18 -18
- package/context.runner-p6m5cxk3.js +28 -0
- package/{guideline.command-195g0h9a.js → guideline.command-43gfjsjv.js} +2 -2
- package/guidelines/conventions/rules/page.md +4 -2
- package/guidelines/conventions/rules/server.md +2 -0
- package/guidelines/conventions/rules/style.md +3 -1
- package/guidelines/conventions/rules/ts.md +2 -1
- package/guidelines/cssRule/cssRule.instruction.md +3 -1
- package/guidelines/pageRule/pageRule.instruction.md +3 -0
- package/incrementalBuilder.proc.js +39 -13
- package/{index-tns543wd.js → index-0tkj05cz.js} +3 -3
- package/{index-sx91nf4z.js → index-2yan1ajk.js} +7 -7
- package/{index-g500c5j9.js → index-38by07nw.js} +1 -1
- package/{index-zttm13c3.js → index-38patcx6.js} +4 -4
- package/{index-jb2sreps.js → index-53h0053j.js} +16 -14
- package/{index-zbrwnmf1.js → index-6t7fkx73.js} +1 -1
- package/{index-361ex3rb.js → index-6zgt7zmx.js} +4 -4
- package/{index-y4kcmbt2.js → index-8d9r465x.js} +2 -2
- package/{index-wrmq92vk.js → index-90q0w90q.js} +1 -1
- package/{index-scck6h6d.js → index-ampz4vgv.js} +4 -4
- package/{index-sjabnf7j.js → index-ap6ac70m.js} +3 -3
- package/{index-j9d3mjx1.js → index-ck64kxrn.js} +2 -2
- package/{index-p6x5b7hr.js → index-d894868w.js} +3 -0
- package/{index-sveq36gh.js → index-dcm66hss.js} +2 -2
- package/{index-84h43kg6.js → index-demt944k.js} +2 -2
- package/{index-0j1t1h2b.js → index-g0yds382.js} +1 -1
- package/{index-hapx5myy.js → index-gfh90r3t.js} +2 -2
- package/{index-gbp1q1b5.js → index-hmj94es2.js} +4 -4
- package/{index-z7kbxdqg.js → index-jzpeny42.js} +3 -3
- package/{index-eft5c2mp.js → index-jzz6ye8x.js} +296 -24
- package/{index-ppvqy5bc.js → index-kc6ffq0s.js} +8 -8
- package/{index-tp56652m.js → index-kc871vpc.js} +3 -3
- package/{index-m02tdq8a.js → index-kdswbvys.js} +3 -3
- package/{index-defp4gmb.js → index-qev8p5wp.js} +1 -1
- package/{index-1h2jc0x3.js → index-qwe079ww.js} +4 -4
- package/{index-wwe9rsrx.js → index-r0a604h4.js} +12 -2
- package/{index-9zy8479y.js → index-r0q2ka2b.js} +1 -1
- package/{index-db2nqrad.js → index-r8t5sq7z.js} +13 -8
- package/{index-j2dgmzbj.js → index-re2kfscb.js} +122 -18
- package/{index-gr9thy79.js → index-sra1a5f8.js} +2 -2
- package/{index-khk05tsf.js → index-t0hk1kxq.js} +1 -1
- package/index-vkpqe29t.js +267 -0
- package/{index-sp0qsr7a.js → index-w60zxxye.js} +3 -3
- package/{index-9z3egsmg.js → index-wymcdsas.js} +8 -8
- package/{index-zdpte1pj.js → index-y0y0pnx8.js} +1 -1
- package/{index-aayg4dqf.js → index-z47rw9ez.js} +6 -6
- package/index.js +23 -23
- package/{library.command-63hgt9te.js → library.command-zh29tjdd.js} +3 -3
- package/{localRegistry.command-343ksmn9.js → localRegistry.command-k9pn9ahj.js} +14 -14
- package/{module.command-2hce9m6k.js → module.command-dgpqs9fz.js} +6 -6
- package/{package.command-96eheyvd.js → package.command-1je4hsca.js} +3 -3
- package/package.json +2 -2
- package/{page.command-gs6d841d.js → page.command-cgsasanh.js} +3 -3
- package/{pipeline.command-wdfvdbfj.js → pipeline.command-tb46sa8v.js} +2 -2
- package/{primitive.command-7tdj12wn.js → primitive.command-bzsy23x5.js} +7 -7
- package/{projectTypecheck-kqj1t6hb.js → projectTypecheck-h8rgaczy.js} +1 -1
- package/{quality.command-29bgarh1.js → quality.command-120m9h6v.js} +4 -4
- package/{repair.command-yng4rf5d.js → repair.command-6m4wd0qv.js} +6 -6
- package/{scalar.command-1nk4329t.js → scalar.command-3dn5hsc6.js} +5 -5
- package/skills/akan-page/SKILL.md +19 -0
- package/skills/akan-service/SKILL.md +47 -0
- package/{subspace.command-5cehmcdd.js → subspace.command-s8nyfqbn.js} +8 -8
- package/{tunnel.command-yrd4atqy.js → tunnel.command-8mwrqkr3.js} +7 -7
- package/{typeChecker-j2jdnqsr.js → typeChecker-s640r6c0.js} +1 -1
- package/typecheck.proc.js +1 -1
- package/{verify.command-kbq0fcg8.js → verify.command-2pspfy7k.js} +12 -12
- package/{workflow.command-274qfa8z.js → workflow.command-7sy5vnsj.js} +11 -11
- package/{workspace.command-r6hgmawy.js → workspace.command-x518tdv4.js} +30 -30
- package/TunnelShare-6d7z36sr.js +0 -14
- package/cloud.script-t2n13gv6.js +0 -27
- package/context.runner-wxqb3qcy.js +0 -28
- package/index-vzpnr12w.js +0 -65
- package/templates/workspaceRoot/patches/zod@3.25.76.patch.template +0 -22
- package/templates/workspaceRoot/patches/zod@4.4.3.patch.template +0 -11
|
@@ -1,4 +1,77 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// pkgs/@akanjs/language/akanGraphDiff.ts
|
|
3
|
+
var edgeKeyOf = ({ from, to, kind, label }) => `${from}
|
|
4
|
+
${to}
|
|
5
|
+
${kind}
|
|
6
|
+
${label ?? ""}`;
|
|
7
|
+
var shapeOf = ({ type, array, optional, declaredIn }) => `${type ?? ""}${array ? "[]" : ""}${optional ? "?" : ""} ${declaredIn}`;
|
|
8
|
+
var isEdited = (before, after) => before.digest !== undefined && after.digest !== undefined && before.digest !== after.digest;
|
|
9
|
+
var byId = (a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
|
10
|
+
|
|
11
|
+
class AkanGraphDiff {
|
|
12
|
+
static between(base, head) {
|
|
13
|
+
const baseNodes = new Map(base.nodes.map((node) => [node.id, node]));
|
|
14
|
+
const headNodes = new Map(head.nodes.map((node) => [node.id, node]));
|
|
15
|
+
const marked = new Map;
|
|
16
|
+
for (const node of head.nodes) {
|
|
17
|
+
const before = baseNodes.get(node.id);
|
|
18
|
+
const next = before ? AkanGraphDiff.#compare(before, node) : AkanGraphDiff.#mark(node, "added");
|
|
19
|
+
if (next)
|
|
20
|
+
marked.set(node.id, next);
|
|
21
|
+
}
|
|
22
|
+
for (const node of base.nodes)
|
|
23
|
+
if (!headNodes.has(node.id))
|
|
24
|
+
marked.set(node.id, AkanGraphDiff.#mark(node, "removed"));
|
|
25
|
+
const baseKeys = new Set(base.edges.map(edgeKeyOf));
|
|
26
|
+
const headKeys = new Set(head.edges.map(edgeKeyOf));
|
|
27
|
+
const edges = [
|
|
28
|
+
...head.edges.flatMap((edge) => !baseKeys.has(edgeKeyOf(edge)) ? [{ ...edge, change: "added" }] : marked.has(edge.from) || marked.has(edge.to) ? [edge] : []),
|
|
29
|
+
...base.edges.filter((edge) => !headKeys.has(edgeKeyOf(edge))).map((edge) => ({ ...edge, change: "removed" }))
|
|
30
|
+
];
|
|
31
|
+
const context = edges.flatMap((edge) => [edge.from, edge.to]).filter((id) => !marked.has(id)).flatMap((id) => {
|
|
32
|
+
const node = headNodes.get(id) ?? baseNodes.get(id);
|
|
33
|
+
return node ? [node] : [];
|
|
34
|
+
});
|
|
35
|
+
const nodes = [...new Map([...marked.values(), ...context].map((node) => [node.id, node])).values()].map(AkanGraphDiff.#withoutDigest).sort(byId);
|
|
36
|
+
const summary = { added: 0, removed: 0, changed: 0 };
|
|
37
|
+
for (const node of marked.values())
|
|
38
|
+
if (node.change)
|
|
39
|
+
summary[node.change] += 1;
|
|
40
|
+
return { version: 1, nodes, edges, summary };
|
|
41
|
+
}
|
|
42
|
+
static #mark(node, change) {
|
|
43
|
+
return node.fields ? { ...node, change, fields: node.fields.map((field) => ({ ...field, change })) } : { ...node, change };
|
|
44
|
+
}
|
|
45
|
+
static #compare(before, after) {
|
|
46
|
+
const fields = AkanGraphDiff.#fieldsBetween(before.fields, after.fields);
|
|
47
|
+
const isChanged = isEdited(before, after) || before.label !== after.label || before.detail.join(`
|
|
48
|
+
`) !== after.detail.join(`
|
|
49
|
+
`) || (before.values ?? []).join(`
|
|
50
|
+
`) !== (after.values ?? []).join(`
|
|
51
|
+
`) || !!fields?.some((field) => field.change);
|
|
52
|
+
if (!isChanged)
|
|
53
|
+
return null;
|
|
54
|
+
return fields ? { ...after, change: "changed", fields } : { ...after, change: "changed" };
|
|
55
|
+
}
|
|
56
|
+
static #fieldsBetween(before, after) {
|
|
57
|
+
if (!before && !after)
|
|
58
|
+
return;
|
|
59
|
+
const previous = new Map((before ?? []).map((field) => [field.name, field]));
|
|
60
|
+
const names = new Set((after ?? []).map((field) => field.name));
|
|
61
|
+
return [
|
|
62
|
+
...(after ?? []).map((field) => {
|
|
63
|
+
const old = previous.get(field.name);
|
|
64
|
+
if (!old)
|
|
65
|
+
return { ...field, change: "added" };
|
|
66
|
+
return shapeOf(old) === shapeOf(field) && !isEdited(old, field) ? field : { ...field, change: "changed" };
|
|
67
|
+
}),
|
|
68
|
+
...(before ?? []).filter((field) => !names.has(field.name)).map((field) => ({ ...field, change: "removed" }))
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
static #withoutDigest({ digest: _digest, ...node }) {
|
|
72
|
+
return node.fields ? { ...node, fields: node.fields.map(({ digest: _field, ...field }) => field) } : node;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
2
75
|
// pkgs/@akanjs/language/akanGraph.ts
|
|
3
76
|
var capitalize = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
4
77
|
var lowerFirst = (text) => text.charAt(0).toLowerCase() + text.slice(1);
|
|
@@ -65,7 +138,7 @@ class GraphBuilder {
|
|
|
65
138
|
const refName = lowerFirst(filter.name.slice(0, -"Filter".length));
|
|
66
139
|
this.#addNode(this.#key("query", owner, refName), "query", owner, refName, "", filter.span);
|
|
67
140
|
for (const query of filter.queries)
|
|
68
|
-
this.#addNode(this.#key("query", owner, refName, query.name), "query", owner, refName, query.name, query.span);
|
|
141
|
+
this.#digest(this.#addNode(this.#key("query", owner, refName, query.name), "query", owner, refName, query.name, query.span), this.#source.readText(file.fileName), query.extent);
|
|
69
142
|
}
|
|
70
143
|
for (const slice of file.slices) {
|
|
71
144
|
const refName = slice.model;
|
|
@@ -142,6 +215,7 @@ class GraphBuilder {
|
|
|
142
215
|
#addMember(kind, owner, refName, member, label, fileName, detail = []) {
|
|
143
216
|
const id = this.#key(kind, owner, refName, member.name);
|
|
144
217
|
const node = this.#addNode(id, kind, owner, refName, member.name, member.span, detail, label);
|
|
218
|
+
this.#digest(node, this.#source.readText(fileName), member.extent);
|
|
145
219
|
this.#contexts.set(fileName, [
|
|
146
220
|
...this.#contexts.get(fileName) ?? [],
|
|
147
221
|
{ id, kind, owner, module: refName, extent: member.extent }
|
|
@@ -150,6 +224,22 @@ class GraphBuilder {
|
|
|
150
224
|
this.#members.set(byName, [...this.#members.get(byName) ?? [], node]);
|
|
151
225
|
return node;
|
|
152
226
|
}
|
|
227
|
+
#hashOf(text, { start, end }) {
|
|
228
|
+
if (!this.#source.digests || text === undefined)
|
|
229
|
+
return null;
|
|
230
|
+
let hash = 2166136261;
|
|
231
|
+
for (let idx = start;idx < end; idx++) {
|
|
232
|
+
const code = text.charCodeAt(idx);
|
|
233
|
+
if (code !== 13)
|
|
234
|
+
hash = Math.imul(hash ^ code, 16777619);
|
|
235
|
+
}
|
|
236
|
+
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
237
|
+
}
|
|
238
|
+
#digest(node, text, extent) {
|
|
239
|
+
const digest = node.digest ? null : this.#hashOf(text, extent);
|
|
240
|
+
if (digest)
|
|
241
|
+
node.digest = digest;
|
|
242
|
+
}
|
|
153
243
|
#addEdge(from, to, kind, label, at) {
|
|
154
244
|
if (from === to)
|
|
155
245
|
return;
|
|
@@ -173,7 +263,8 @@ ${label ?? ""}`;
|
|
|
173
263
|
this.#addEdge(node.id, id, "guard", role, node.at);
|
|
174
264
|
}
|
|
175
265
|
#moduleDirOf(fileName) {
|
|
176
|
-
|
|
266
|
+
const dir = this.#source.relative(fileName).match(moduleDirPattern)?.[1] ?? null;
|
|
267
|
+
return dir?.startsWith("_") && !dir.startsWith("__") ? dir.slice(1) : dir;
|
|
177
268
|
}
|
|
178
269
|
#fieldsOf(constant, scope) {
|
|
179
270
|
const fields = new Map;
|
|
@@ -187,17 +278,21 @@ ${label ?? ""}`;
|
|
|
187
278
|
if (parentClass)
|
|
188
279
|
visit(parentClass);
|
|
189
280
|
}
|
|
190
|
-
for (const field of current.fields)
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
281
|
+
for (const field of current.fields) {
|
|
282
|
+
if (fields.has(field.name))
|
|
283
|
+
continue;
|
|
284
|
+
const digest = this.#hashOf(this.#source.readText(field.span.fileName), field.extent);
|
|
285
|
+
fields.set(field.name, {
|
|
286
|
+
name: field.name,
|
|
287
|
+
type: field.type,
|
|
288
|
+
array: field.array,
|
|
289
|
+
optional: field.optional,
|
|
290
|
+
ref: null,
|
|
291
|
+
declaredIn: current.name,
|
|
292
|
+
at: this.#location(field.span),
|
|
293
|
+
...digest ? { digest } : {}
|
|
294
|
+
});
|
|
295
|
+
}
|
|
201
296
|
};
|
|
202
297
|
visit(constant);
|
|
203
298
|
return [...fields.values()];
|
|
@@ -260,8 +355,10 @@ st
|
|
|
260
355
|
const targets = resolved.length ? resolved : this.#plainTargetsOf(chain, identifier.text, context, owner);
|
|
261
356
|
if (!targets.length)
|
|
262
357
|
return;
|
|
263
|
-
if (context.pending && !this.#nodes.has(context.id))
|
|
358
|
+
if (context.pending && !this.#nodes.has(context.id)) {
|
|
264
359
|
this.#nodes.set(context.id, context.pending);
|
|
360
|
+
this.#digest(context.pending, source.text, context.extent);
|
|
361
|
+
}
|
|
265
362
|
const own = targets.filter((id) => this.#nodes.get(id)?.owner === owner);
|
|
266
363
|
const kind = context.kind === "component" ? "uses" : chain?.[0] === "fetch" ? "fetches" : "calls";
|
|
267
364
|
const position = source.getLineAndCharacterOfPosition(identifier.getStart(source));
|
|
@@ -456,7 +553,7 @@ var createFactReader = (ts, ast) => {
|
|
|
456
553
|
const objectKeys = (source, object) => (object?.properties ?? []).flatMap((property) => {
|
|
457
554
|
const name = ast.propertyName(property);
|
|
458
555
|
const node = keyName(property);
|
|
459
|
-
return name && node ? [{ name, span: spanOf(source, node) }] : [];
|
|
556
|
+
return name && node ? [{ name, span: spanOf(source, node), extent: extentOf(source, property) }] : [];
|
|
460
557
|
});
|
|
461
558
|
const sliceKeysOf = (source, builder) => (returnedObject(builder)?.properties ?? []).flatMap((property) => {
|
|
462
559
|
if (!ts.isPropertyAssignment(property))
|
|
@@ -531,7 +628,13 @@ var createFactReader = (ts, ast) => {
|
|
|
531
628
|
return [];
|
|
532
629
|
const { root, methods } = ts.isPropertyAssignment(property) ? chainOf(property.initializer) : { root: null, methods: [] };
|
|
533
630
|
return [
|
|
534
|
-
{
|
|
631
|
+
{
|
|
632
|
+
name,
|
|
633
|
+
span: spanOf(source, node),
|
|
634
|
+
extent: extentOf(source, property),
|
|
635
|
+
...typeOf(root?.arguments[0]),
|
|
636
|
+
optional: methods.includes("optional")
|
|
637
|
+
}
|
|
535
638
|
];
|
|
536
639
|
});
|
|
537
640
|
const constantOf = (source, name, call) => {
|
|
@@ -995,8 +1098,9 @@ ${[...new Set(text.match(wordPattern))].join(`
|
|
|
995
1098
|
referencesAt(givenName, offset, readText) {
|
|
996
1099
|
return this.#usesOf(this.#sourceEntriesAt(pathOf(givenName), offset), readText).map((use) => use.span);
|
|
997
1100
|
}
|
|
998
|
-
graph(readText) {
|
|
1101
|
+
graph(readText, { digests = false } = {}) {
|
|
999
1102
|
return new GraphBuilder({
|
|
1103
|
+
digests,
|
|
1000
1104
|
ts: this.#ts,
|
|
1001
1105
|
facts: [...this.#facts].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([, facts]) => facts),
|
|
1002
1106
|
files: [...this.#fileWords].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0),
|
|
@@ -1256,4 +1360,4 @@ ${dictionary.className}
|
|
|
1256
1360
|
})).sort((a, b) => Number(b.owner === owner) - Number(a.owner === owner));
|
|
1257
1361
|
}
|
|
1258
1362
|
}
|
|
1259
|
-
export { createAst, createFactReader, AkanIndex };
|
|
1363
|
+
export { AkanGraphDiff, createAst, createFactReader, AkanIndex };
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
UpdatePackFolder,
|
|
10
10
|
NativePublicEnv,
|
|
11
11
|
NativeApp
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-w60zxxye.js";
|
|
13
13
|
import {
|
|
14
14
|
ExitCodeError
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-r0q2ka2b.js";
|
|
16
16
|
import {
|
|
17
17
|
ConfigLock
|
|
18
18
|
} from "./index-bqbf654f.js";
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
AkanGraphDiff,
|
|
4
|
+
AkanIndex
|
|
5
|
+
} from "./index-re2kfscb.js";
|
|
6
|
+
|
|
7
|
+
// pkgs/@akanjs/devkit/gitRevision.ts
|
|
8
|
+
var systemPaths = ["apps", "libs"];
|
|
9
|
+
var changeOfStatus = { A: "added", D: "removed" };
|
|
10
|
+
|
|
11
|
+
class GitRevision {
|
|
12
|
+
static #defaultBranches = ["upstream/HEAD", "upstream/main", "origin/HEAD", "origin/main", "main", "master"];
|
|
13
|
+
static #env = { ...process.env, GIT_OPTIONAL_LOCKS: "0" };
|
|
14
|
+
#root;
|
|
15
|
+
constructor(root) {
|
|
16
|
+
this.#root = root;
|
|
17
|
+
}
|
|
18
|
+
async forkPointOf(since) {
|
|
19
|
+
if ((await this.#git(["rev-parse", "--is-inside-work-tree"]))?.trim() !== "true")
|
|
20
|
+
return { error: "The Change Map compares with git history, and this workspace is not in a git repository." };
|
|
21
|
+
if (since !== null) {
|
|
22
|
+
const sha = /^[^-\s][^\s]*$/.test(since) ? (await this.#git(["rev-parse", "--verify", "--quiet", `${since}^{commit}`]))?.trim() : undefined;
|
|
23
|
+
if (!sha)
|
|
24
|
+
return { error: `${since} is not a commit in this repository.` };
|
|
25
|
+
return await this.#mergeBase(since, sha);
|
|
26
|
+
}
|
|
27
|
+
for (const branch of GitRevision.#defaultBranches)
|
|
28
|
+
if (await this.#git(["rev-parse", "--verify", "--quiet", `${branch}^{commit}`]) !== null)
|
|
29
|
+
return await this.#mergeBase(branch, branch);
|
|
30
|
+
const head = (await this.#git(["rev-parse", "--verify", "--quiet", "HEAD^{commit}"]))?.trim();
|
|
31
|
+
return head ? { sha: head } : { error: "The repository has no commit to compare with yet." };
|
|
32
|
+
}
|
|
33
|
+
async#mergeBase(name, revision) {
|
|
34
|
+
const sha = (await this.#git(["merge-base", "HEAD", revision]))?.trim();
|
|
35
|
+
if (sha)
|
|
36
|
+
return { sha };
|
|
37
|
+
return {
|
|
38
|
+
error: `HEAD shares no commit with ${name} here. In a shallow clone, \`git fetch --unshallow\` brings the history in.`
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async filesAt(sha, isWanted) {
|
|
42
|
+
const listed = await this.#git(["ls-tree", "-r", "-z", "--name-only", sha, "--", ...systemPaths]);
|
|
43
|
+
if (listed === null)
|
|
44
|
+
throw new Error(`git ls-tree failed for ${sha}`);
|
|
45
|
+
const files = listed.split("\x00").filter((file) => file && isWanted(file));
|
|
46
|
+
const texts = new Map;
|
|
47
|
+
if (!files.length)
|
|
48
|
+
return texts;
|
|
49
|
+
const proc = Bun.spawn(["git", "cat-file", "--batch"], {
|
|
50
|
+
cwd: this.#root,
|
|
51
|
+
env: GitRevision.#env,
|
|
52
|
+
stdin: "pipe",
|
|
53
|
+
stdout: "pipe",
|
|
54
|
+
stderr: "ignore"
|
|
55
|
+
});
|
|
56
|
+
const output = new Response(proc.stdout).arrayBuffer();
|
|
57
|
+
proc.stdin.write(files.map((file) => `${sha}:./${file}
|
|
58
|
+
`).join(""));
|
|
59
|
+
await proc.stdin.end();
|
|
60
|
+
const bytes = new Uint8Array(await output);
|
|
61
|
+
if (await proc.exited !== 0)
|
|
62
|
+
throw new Error(`git cat-file failed for ${sha}`);
|
|
63
|
+
const decoder = new TextDecoder;
|
|
64
|
+
let offset = 0;
|
|
65
|
+
for (const file of files) {
|
|
66
|
+
const lineEnd = bytes.indexOf(10, offset);
|
|
67
|
+
if (lineEnd < 0)
|
|
68
|
+
throw new Error(`git cat-file ended before ${file} at ${sha}`);
|
|
69
|
+
const header = decoder.decode(bytes.subarray(offset, lineEnd));
|
|
70
|
+
offset = lineEnd + 1;
|
|
71
|
+
if (header.endsWith(" missing"))
|
|
72
|
+
continue;
|
|
73
|
+
const [, type, size] = header.split(" ");
|
|
74
|
+
const length = Number(size);
|
|
75
|
+
if (type === "blob")
|
|
76
|
+
texts.set(file, decoder.decode(bytes.subarray(offset, offset + length)));
|
|
77
|
+
offset += length + 1;
|
|
78
|
+
}
|
|
79
|
+
return texts;
|
|
80
|
+
}
|
|
81
|
+
async changedFilesSince(sha) {
|
|
82
|
+
const [tracked, untracked] = await Promise.all([
|
|
83
|
+
this.#git(["diff", "--name-status", "--no-renames", "--relative", "-z", sha, "--", ...systemPaths]),
|
|
84
|
+
this.#git(["ls-files", "-z", "--others", "--exclude-standard", "--", ...systemPaths])
|
|
85
|
+
]);
|
|
86
|
+
if (tracked === null || untracked === null)
|
|
87
|
+
throw new Error(`git could not list the changes since ${sha}`);
|
|
88
|
+
const changes = new Map;
|
|
89
|
+
const fields = tracked.split("\x00");
|
|
90
|
+
for (let idx = 0;idx + 1 < fields.length; idx += 2)
|
|
91
|
+
changes.set(fields[idx + 1], changeOfStatus[fields[idx]] ?? "changed");
|
|
92
|
+
for (const file of untracked.split("\x00"))
|
|
93
|
+
if (file)
|
|
94
|
+
changes.set(file, "added");
|
|
95
|
+
return [...changes].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([file, change]) => ({ file, change }));
|
|
96
|
+
}
|
|
97
|
+
async workingFiles() {
|
|
98
|
+
const listed = await this.#git([
|
|
99
|
+
"ls-files",
|
|
100
|
+
"-z",
|
|
101
|
+
"--cached",
|
|
102
|
+
"--others",
|
|
103
|
+
"--exclude-standard",
|
|
104
|
+
"--",
|
|
105
|
+
...systemPaths
|
|
106
|
+
]);
|
|
107
|
+
if (listed === null)
|
|
108
|
+
throw new Error("git ls-files failed");
|
|
109
|
+
return [...new Set(listed.split("\x00").filter(Boolean))];
|
|
110
|
+
}
|
|
111
|
+
async#git(args) {
|
|
112
|
+
try {
|
|
113
|
+
const proc = Bun.spawn(["git", ...args], {
|
|
114
|
+
cwd: this.#root,
|
|
115
|
+
env: GitRevision.#env,
|
|
116
|
+
stdout: "pipe",
|
|
117
|
+
stderr: "ignore"
|
|
118
|
+
});
|
|
119
|
+
const [text, exitCode] = await Promise.all([new Response(proc.stdout).text(), proc.exited]);
|
|
120
|
+
return exitCode === 0 ? text : null;
|
|
121
|
+
} catch {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// pkgs/@akanjs/devkit/workspaceGraph.ts
|
|
128
|
+
import { readFile } from "fs/promises";
|
|
129
|
+
import path from "path";
|
|
130
|
+
import ts from "typescript";
|
|
131
|
+
var indexedPath = /^(apps|libs)\/(?!(?:.*\/)?(?:node_modules|dist|\.akan|env)\/).*\.tsx?$/;
|
|
132
|
+
var hiddenPath = /(?:^|\/)(?:node_modules|dist|\.akan|env)\//;
|
|
133
|
+
var unscopedNodeLimit = 600;
|
|
134
|
+
var cachedBaseLimit = 4;
|
|
135
|
+
var slashed = (fileName) => fileName.replace(/\\/g, "/");
|
|
136
|
+
|
|
137
|
+
class WorkspaceGraph {
|
|
138
|
+
static #bases = new Map;
|
|
139
|
+
static async build(workspace, { digests = false } = {}) {
|
|
140
|
+
const root = workspace.workspaceRoot;
|
|
141
|
+
const files = (await workspace.getAllFiles("{apps,libs}/**/*.{ts,tsx}")).map(slashed).filter((file) => indexedPath.test(file));
|
|
142
|
+
return WorkspaceGraph.#graphOf(root, await WorkspaceGraph.#textsOf(root, files), digests);
|
|
143
|
+
}
|
|
144
|
+
static async#textsOf(root, files) {
|
|
145
|
+
const read = await Promise.all(files.map(async (file) => [file, await readFile(path.join(root, file), "utf8").catch(() => null)]));
|
|
146
|
+
return new Map(read.filter((entry) => entry[1] !== null));
|
|
147
|
+
}
|
|
148
|
+
static async changes(workspace, since) {
|
|
149
|
+
const forkPoint = await new GitRevision(workspace.workspaceRoot).forkPointOf(since);
|
|
150
|
+
if (forkPoint.error !== undefined)
|
|
151
|
+
return { error: forkPoint.error };
|
|
152
|
+
return await WorkspaceGraph.changesAt(workspace, forkPoint.sha);
|
|
153
|
+
}
|
|
154
|
+
static async changesAt(workspace, sha) {
|
|
155
|
+
const root = workspace.workspaceRoot;
|
|
156
|
+
const git = new GitRevision(root);
|
|
157
|
+
const [before, after, files] = await Promise.all([
|
|
158
|
+
WorkspaceGraph.#baseAt(root, sha),
|
|
159
|
+
git.workingFiles().then((working) => WorkspaceGraph.#textsOf(root, working.filter((file) => indexedPath.test(file)))).then((texts) => WorkspaceGraph.#graphOf(root, texts, true)),
|
|
160
|
+
git.changedFilesSince(sha)
|
|
161
|
+
]);
|
|
162
|
+
const changes = AkanGraphDiff.between(before, after);
|
|
163
|
+
const mapped = new Set([
|
|
164
|
+
...changes.nodes.filter((node) => node.change).flatMap((node) => [
|
|
165
|
+
node.at?.file,
|
|
166
|
+
...(node.fields ?? []).filter((field) => field.change).map(({ at }) => at.file)
|
|
167
|
+
]),
|
|
168
|
+
...changes.edges.filter((edge) => edge.change).map((edge) => edge.at?.file)
|
|
169
|
+
]);
|
|
170
|
+
const unmapped = files.filter(({ file }) => !mapped.has(file) && !hiddenPath.test(file));
|
|
171
|
+
return { ...changes, since: sha.slice(0, 12), unmapped };
|
|
172
|
+
}
|
|
173
|
+
static #baseAt(root, sha) {
|
|
174
|
+
const key = `${root}
|
|
175
|
+
${sha}`;
|
|
176
|
+
const cached = WorkspaceGraph.#bases.get(key);
|
|
177
|
+
if (cached)
|
|
178
|
+
return cached;
|
|
179
|
+
const graph = new GitRevision(root).filesAt(sha, (file) => indexedPath.test(file)).then((texts) => WorkspaceGraph.#graphOf(root, texts, true));
|
|
180
|
+
graph.catch(() => WorkspaceGraph.#bases.delete(key));
|
|
181
|
+
WorkspaceGraph.#bases.set(key, graph);
|
|
182
|
+
for (const old of [...WorkspaceGraph.#bases.keys()].slice(0, -cachedBaseLimit))
|
|
183
|
+
WorkspaceGraph.#bases.delete(old);
|
|
184
|
+
return graph;
|
|
185
|
+
}
|
|
186
|
+
static #graphOf(root, texts, digests) {
|
|
187
|
+
const index = new AkanIndex({ ts, root });
|
|
188
|
+
const byFileName = new Map;
|
|
189
|
+
for (const [file, text] of texts) {
|
|
190
|
+
const fileName = slashed(path.join(root, file));
|
|
191
|
+
byFileName.set(fileName, text);
|
|
192
|
+
index.setFile(fileName, text);
|
|
193
|
+
}
|
|
194
|
+
return index.graph((fileName) => byFileName.get(fileName), { digests });
|
|
195
|
+
}
|
|
196
|
+
static scope(graph, { app, module }) {
|
|
197
|
+
if (!app && !module)
|
|
198
|
+
return graph;
|
|
199
|
+
const owners = app ? new Set([`apps/${app}`, `libs/${app}`]) : null;
|
|
200
|
+
const seeds = new Set(graph.nodes.filter((node) => (!owners || owners.has(node.owner ?? "")) && (!module || node.module === module)).map((node) => node.id));
|
|
201
|
+
const edges = graph.edges.filter((edge) => seeds.has(edge.from) || seeds.has(edge.to));
|
|
202
|
+
const ids = new Set([...seeds, ...edges.flatMap((edge) => [edge.from, edge.to])]);
|
|
203
|
+
return { version: 1, nodes: graph.nodes.filter((node) => ids.has(node.id)), edges };
|
|
204
|
+
}
|
|
205
|
+
static visibleTo(graph, app) {
|
|
206
|
+
const appOwner = `apps/${app}`;
|
|
207
|
+
const isVisible = ({ owner }) => !owner || owner === appOwner || owner.startsWith("libs/");
|
|
208
|
+
const nodes = graph.nodes.filter(isVisible);
|
|
209
|
+
const ids = new Set(nodes.map((node) => node.id));
|
|
210
|
+
return { version: 1, nodes, edges: graph.edges.filter((edge) => ids.has(edge.from) && ids.has(edge.to)) };
|
|
211
|
+
}
|
|
212
|
+
static changesVisibleTo(changes, app) {
|
|
213
|
+
const visible = WorkspaceGraph.visibleTo(changes, app);
|
|
214
|
+
const linked = new Set(visible.edges.flatMap((edge) => [edge.from, edge.to]));
|
|
215
|
+
const nodes = visible.nodes.filter((node) => node.change || linked.has(node.id));
|
|
216
|
+
const appPath = `apps/${app}/`;
|
|
217
|
+
return {
|
|
218
|
+
...changes,
|
|
219
|
+
nodes,
|
|
220
|
+
edges: visible.edges,
|
|
221
|
+
summary: WorkspaceGraph.#summaryOf(nodes),
|
|
222
|
+
unmapped: changes.unmapped.filter(({ file }) => file.startsWith(appPath) || file.startsWith("libs/"))
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
static #summaryOf(nodes) {
|
|
226
|
+
const summary = { added: 0, removed: 0, changed: 0 };
|
|
227
|
+
for (const { change } of nodes)
|
|
228
|
+
if (change)
|
|
229
|
+
summary[change] += 1;
|
|
230
|
+
return summary;
|
|
231
|
+
}
|
|
232
|
+
static answerChanges(changes, scope) {
|
|
233
|
+
if ("error" in changes)
|
|
234
|
+
return {
|
|
235
|
+
diagnostics: [{ severity: "error", code: "graph-since-unknown", message: changes.error, input: "since" }]
|
|
236
|
+
};
|
|
237
|
+
const answer = WorkspaceGraph.answer(changes, scope, changes.nodes.filter((node) => node.change));
|
|
238
|
+
if ("diagnostics" in answer)
|
|
239
|
+
return { since: changes.since, summary: changes.summary, ...answer };
|
|
240
|
+
const summary = WorkspaceGraph.#summaryOf(answer.nodes);
|
|
241
|
+
const owners = scope.app ? [`apps/${scope.app}/`, `libs/${scope.app}/`] : null;
|
|
242
|
+
const modules = scope.module ? [`/lib/${scope.module}/`, `/lib/_${scope.module}/`] : null;
|
|
243
|
+
const unmapped = changes.unmapped.filter(({ file }) => (!owners || owners.some((owner) => file.startsWith(owner))) && (!modules || modules.some((segment) => file.includes(segment))));
|
|
244
|
+
return { since: changes.since, summary, ...answer, unmapped };
|
|
245
|
+
}
|
|
246
|
+
static answer(graph, scope, counted = graph.nodes) {
|
|
247
|
+
if (scope.app || scope.module || graph.nodes.length <= unscopedNodeLimit)
|
|
248
|
+
return WorkspaceGraph.scope(graph, scope);
|
|
249
|
+
const owners = new Map;
|
|
250
|
+
for (const node of counted)
|
|
251
|
+
if (node.owner)
|
|
252
|
+
owners.set(node.owner, (owners.get(node.owner) ?? 0) + 1);
|
|
253
|
+
return {
|
|
254
|
+
diagnostics: [
|
|
255
|
+
{
|
|
256
|
+
severity: "error",
|
|
257
|
+
code: "graph-scope-required",
|
|
258
|
+
message: `The graph has ${graph.nodes.length} nodes. Pass app, module or both to scope it.`,
|
|
259
|
+
input: "app"
|
|
260
|
+
}
|
|
261
|
+
],
|
|
262
|
+
owners: Object.fromEntries([...owners].sort(([a], [b]) => a < b ? -1 : 1))
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export { GitRevision, WorkspaceGraph };
|
|
@@ -5,17 +5,17 @@ import {
|
|
|
5
5
|
AkanAppConfig,
|
|
6
6
|
Executor,
|
|
7
7
|
WorkspaceExecutor
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-38by07nw.js";
|
|
9
9
|
import {
|
|
10
10
|
resolveAppId,
|
|
11
11
|
targetHtmlFilename
|
|
12
12
|
} from "./index-m9jj544v.js";
|
|
13
13
|
import {
|
|
14
14
|
CsrArtifactBuilder
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-dcm66hss.js";
|
|
16
16
|
import {
|
|
17
17
|
ExitCodeError
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-r0q2ka2b.js";
|
|
19
19
|
|
|
20
20
|
// pkgs/@akanjs/devkit/mobile/desktopBin.ts
|
|
21
21
|
import { chmod, mkdir, rename, rm, writeFile } from "fs/promises";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
WorkspaceExecutor
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-38by07nw.js";
|
|
5
5
|
import {
|
|
6
6
|
jsonText,
|
|
7
7
|
workflowPlanApproval,
|
|
@@ -26,27 +26,27 @@ import {
|
|
|
26
26
|
renderWorkflowApply,
|
|
27
27
|
renderWorkflowValidation,
|
|
28
28
|
renderWorkflowRunArtifact
|
|
29
|
-
} from "./index-
|
|
29
|
+
} from "./index-kdswbvys.js";
|
|
30
30
|
import {
|
|
31
31
|
AkanContextAnalyzer
|
|
32
|
-
} from "./index-
|
|
32
|
+
} from "./index-ck64kxrn.js";
|
|
33
33
|
import {
|
|
34
34
|
CommandContainer,
|
|
35
35
|
runner
|
|
36
|
-
} from "./index-
|
|
36
|
+
} from "./index-r0q2ka2b.js";
|
|
37
37
|
import {
|
|
38
38
|
ModuleScript
|
|
39
|
-
} from "./index-
|
|
39
|
+
} from "./index-hmj94es2.js";
|
|
40
40
|
import {
|
|
41
41
|
PrimitiveScript
|
|
42
|
-
} from "./index-
|
|
42
|
+
} from "./index-6zgt7zmx.js";
|
|
43
43
|
import {
|
|
44
44
|
spawnAkan,
|
|
45
45
|
isWorkspaceTarget
|
|
46
|
-
} from "./index-
|
|
46
|
+
} from "./index-0tkj05cz.js";
|
|
47
47
|
import {
|
|
48
48
|
ScalarScript
|
|
49
|
-
} from "./index-
|
|
49
|
+
} from "./index-gfh90r3t.js";
|
|
50
50
|
import {
|
|
51
51
|
workflowSpecs
|
|
52
52
|
} from "./index-k64mhwbw.js";
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
script,
|
|
5
5
|
ExitCodeError,
|
|
6
6
|
markCliErrorPrinted
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-r0q2ka2b.js";
|
|
8
8
|
import {
|
|
9
9
|
AGENT_BLOCK_START,
|
|
10
10
|
AGENT_BLOCK_END,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
CLAUDE_COMMENT_RULE,
|
|
16
16
|
AppExecutor,
|
|
17
17
|
LibExecutor
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-38by07nw.js";
|
|
19
19
|
import {
|
|
20
20
|
akanCodePaths2
|
|
21
21
|
} from "./index-35j83zkd.js";
|
|
@@ -29,19 +29,19 @@ import {
|
|
|
29
29
|
} from "./index-hj6w4ka1.js";
|
|
30
30
|
import {
|
|
31
31
|
AkanContextAnalyzer
|
|
32
|
-
} from "./index-
|
|
32
|
+
} from "./index-ck64kxrn.js";
|
|
33
33
|
import {
|
|
34
34
|
ApplicationRunner,
|
|
35
35
|
VerifyScope
|
|
36
|
-
} from "./index-
|
|
36
|
+
} from "./index-kc6ffq0s.js";
|
|
37
37
|
import {
|
|
38
38
|
WorkspaceRunner
|
|
39
|
-
} from "./index-
|
|
39
|
+
} from "./index-ap6ac70m.js";
|
|
40
40
|
import {
|
|
41
41
|
VerifyComments,
|
|
42
42
|
VerifyPipeline,
|
|
43
43
|
VerifyReport
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-jzz6ye8x.js";
|
|
45
45
|
|
|
46
46
|
// pkgs/@akanjs/cli/agent/agent.script.ts
|
|
47
47
|
import { Logger as Logger3 } from "akanjs/common";
|