@akanjs/cli 3.1.1-rc.8 → 3.1.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.
- package/.build-stamp +1 -1
- package/CodeAgent-35wnb7w5.js +9 -0
- package/{CodeTui-rqxarxsn.js → CodeTui-h6yz2kvq.js} +1 -1
- package/TunnelShare-xyjpa7gx.js +14 -0
- package/agent.command-3r4jsck8.js +46 -0
- package/akanCode.js +10 -6
- package/{application.command-14xsthcr.js → application.command-g7xv6ad0.js} +46 -13
- package/{applicationBuildRunner-t2r84sz6.js → applicationBuildRunner-qvjnhr9j.js} +9 -6
- package/buildBatch.proc.js +6 -6
- package/{cloud.command-rmw1kcf1.js → cloud.command-6ebygmhw.js} +17 -15
- package/cloud.script-0s1jybd5.js +26 -0
- package/{code.command-719k3e9q.js → code.command-mpkm2emr.js} +6 -6
- package/commandManifest.json +1 -1
- package/{context.command-c4t4z1vy.js → context.command-svdh6b2w.js} +18 -17
- package/context.runner-ch0z3a8g.js +26 -0
- package/{devTui-q7k7bakd.js → devTui-evr3b35y.js} +1 -1
- package/{guideline.command-snh85ctf.js → guideline.command-qwp3tnjx.js} +3 -3
- package/guidelines/conventions/core.md +106 -0
- package/guidelines/conventions/rules/app.md +83 -0
- package/guidelines/conventions/rules/auth.md +45 -0
- package/guidelines/conventions/rules/config.md +56 -0
- package/guidelines/conventions/rules/constant.md +24 -0
- package/guidelines/conventions/rules/gates.md +31 -0
- package/guidelines/conventions/rules/layer.md +25 -0
- package/guidelines/conventions/rules/migration.md +27 -0
- package/guidelines/conventions/rules/module.md +90 -0
- package/guidelines/conventions/rules/page.md +56 -0
- package/guidelines/conventions/rules/sensitive.md +16 -0
- package/guidelines/conventions/rules/server.md +86 -0
- package/guidelines/conventions/rules/ssr.md +47 -0
- package/guidelines/conventions/rules/style.md +43 -0
- package/guidelines/conventions/rules/test.md +34 -0
- package/guidelines/conventions/rules/ts.md +95 -0
- package/guidelines/conventions/rules/tsx.md +75 -0
- package/guidelines/mcpRule/mcpRule.instruction.md +1 -1
- package/guidelines/pageRule/pageRule.instruction.md +4 -3
- package/guidelines/queryRule/queryRule.instruction.md +4 -0
- package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +3 -3
- package/incrementalBuilder.proc.js +6 -6
- package/{index-pcwzkdqb.js → index-1p0qbq3m.js} +1 -1
- package/{index-xb8809yb.js → index-1shvxzt0.js} +3 -3
- package/{index-8w76g4rm.js → index-266dewjs.js} +11 -11
- package/{index-5max10jx.js → index-3yz30c07.js} +72 -53
- package/{index-xjf5j657.js → index-4mj92tsh.js} +952 -47
- package/index-4pdts00b.js +1604 -0
- package/{index-42j4a8zq.js → index-8559hsz4.js} +4 -3
- package/{index-wcej7g4z.js → index-8scw1pjk.js} +93 -23
- package/{index-5phjb48k.js → index-96wzdhfh.js} +74 -233
- package/index-9bv479q5.js +1 -0
- package/index-9rvcs76p.js +653 -0
- package/index-am36s3jh.js +3582 -0
- package/index-b8c289dx.js +444 -0
- package/{index-espk51ah.js → index-dd44g6vz.js} +3 -3
- package/{index-3wypz6xj.js → index-eja64h28.js} +7 -3
- package/index-fbewhg4g.js +590 -0
- package/index-jje9qzyq.js +27 -0
- package/{index-j9vyj3dj.js → index-k5jbcxyh.js} +3 -3
- package/{index-hmmv2cah.js → index-ksfgqq1x.js} +1 -1
- package/index-m5n3ka0p.js +18 -0
- package/{index-5nd1wtkv.js → index-p6x5b7hr.js} +1 -1
- package/{index-0p37cz91.js → index-payhwt51.js} +21 -29
- package/{index-myc22sgv.js → index-qkkdhjm6.js} +5 -4
- package/{index-74tjjsnc.js → index-qxzrp5xt.js} +33 -37
- package/{index-zrte51fn.js → index-r0k3ham2.js} +4 -4
- package/{index-hmt54t45.js → index-r2w2eh93.js} +4 -4
- package/index-r2wedvqn.js +138 -0
- package/{index-skk9zc1x.js → index-rnphv731.js} +2 -2
- package/{index-pa3c2mb8.js → index-s6da8ta9.js} +82 -1227
- package/index-tenw3mah.js +225 -0
- package/{index-31es1yev.js → index-tgt2fnd6.js} +107 -6
- package/{index-8ap5z1n5.js → index-vxmy1p4f.js} +16 -36
- package/{index-mdqr41sp.js → index-w4k2ragk.js} +7 -7
- package/{index-qd5km521.js → index-w7q6h97v.js} +1 -1
- package/{index-dy0jx9ay.js → index-wwe9rsrx.js} +14 -0
- package/{index-2xcc2ax5.js → index-xq543a5y.js} +2 -2
- package/{index-0fz95kxe.js → index-xqgwjz7a.js} +1 -1
- package/{index-40brg4px.js → index-xxfy1jp2.js} +4 -4
- package/{index-905qdgqp.js → index-z4b84y6k.js} +1 -1
- package/index-zcf6k8a5.js +410 -0
- package/index.js +23 -22
- package/{library.command-gycrwhf1.js → library.command-2853y6mk.js} +3 -3
- package/{localRegistry.command-2t3fghje.js → localRegistry.command-76ds31p4.js} +19 -15
- package/{module.command-v6hgs1bc.js → module.command-yfnb0abs.js} +5 -5
- package/{package.command-shzpcfph.js → package.command-d9s86hp9.js} +3 -3
- package/package.json +2 -2
- package/{page.command-ptxn5kqk.js → page.command-6a8a8rd1.js} +3 -3
- package/{pipeline.command-zz31pgax.js → pipeline.command-rt3rwd2z.js} +2 -2
- package/{primitive.command-a1vse91z.js → primitive.command-emcebgrq.js} +6 -6
- package/{projectTypecheck-2ztky9cf.js → projectTypecheck-51m7eh1f.js} +1 -1
- package/{prompter-76k56b37.js → prompter-hgcta8pb.js} +1 -1
- package/quality.command-xtrk0n3x.js +76 -0
- package/{repair.command-cvazbz99.js → repair.command-51szxnxx.js} +5 -5
- package/{routeSourceValidator-6jd0q6r6.js → routeSourceValidator-4h947v7c.js} +13 -3
- package/{scalar.command-0acvyp26.js → scalar.command-8qv27t82.js} +4 -4
- package/skills/akan-agent/SKILL.md +36 -0
- package/skills/akan-code/SKILL.md +1 -0
- package/skills/akan-debug/SKILL.md +40 -6
- package/skills/akan-deps/SKILL.md +1 -2
- package/skills/akan-mcp/SKILL.md +40 -0
- package/skills/akan-page/SKILL.md +44 -0
- package/skills/akan-query/SKILL.md +38 -0
- package/skills/akan-runtime/SKILL.md +40 -0
- package/skills/akan-scaffold/SKILL.md +16 -6
- package/skills/akan-transport/SKILL.md +40 -0
- package/skills/akan-validate/SKILL.md +13 -11
- package/{subspace.command-kvxmyxtf.js → subspace.command-pn56pnh8.js} +8 -8
- package/templates/__scalar/__model__/__model__.constant.ts +3 -5
- package/templates/__scalar/__model__/__model__.dictionary.ts +6 -5
- package/templates/__scalar/__model__/__model__.document.ts +3 -3
- package/templates/app/akan.config.ts +2 -3
- package/templates/app/env/env.client.ts +2 -4
- package/templates/app/env/env.client.type.ts +2 -3
- package/templates/app/env/env.server.ts +2 -3
- package/templates/app/lib/___appName__/__appName__.dictionary.ts +1 -2
- package/templates/app/lib/___appName__/__appName__.service.ts +3 -3
- package/templates/app/lib/___appName__/__appName__.signal.ts +5 -5
- package/templates/app/lib/___appName__/__appName__.store.ts +4 -6
- package/templates/app/lib/option.ts +2 -3
- package/templates/app/main.ts +2 -4
- package/templates/app/page/_index.tsx +3 -3
- package/templates/app/page/_layout.tsx +13 -10
- package/templates/appSample/lib/__scalar/workHistory/workHistory.constant.ts +1 -5
- package/templates/appSample/lib/__scalar/workHistory/workHistory.dictionary.ts +1 -1
- package/templates/appSample/lib/_noti/noti.signal.ts +1 -1
- package/templates/appSample/lib/task/Task.Template.tsx +2 -1
- package/templates/appSample/lib/task/Task.Unit.tsx +3 -2
- package/templates/appSample/lib/task/Task.Util.tsx +16 -4
- package/templates/appSample/lib/task/task.constant.ts +1 -5
- package/templates/appSample/lib/task/task.dictionary.ts +2 -8
- package/templates/appSample/lib/task/task.document.ts +1 -1
- package/templates/appSample/page/task/_index.tsx +2 -1
- package/templates/appSample/page/task/new.tsx +2 -1
- package/templates/appSample/ui/QuantityControl.tsx +5 -9
- package/templates/biomeForm.ts +144 -0
- package/templates/crudPages/[__model__Id]/edit/page.tsx +3 -3
- package/templates/crudPages/[__model__Id]/page.tsx +5 -5
- package/templates/crudPages/new/page.tsx +4 -3
- package/templates/crudPages/page.tsx +3 -3
- package/templates/crudSinglePage/page.tsx +9 -5
- package/templates/libRoot/akan.config.ts +2 -3
- package/templates/libRoot/lib/___libName__/__libName__.dictionary.ts +1 -2
- package/templates/libRoot/lib/___libName__/__libName__.service.ts +5 -4
- package/templates/libRoot/lib/___libName__/__libName__.signal.ts +6 -5
- package/templates/libRoot/lib/___libName__/__libName__.store.ts +5 -6
- package/templates/libRoot/lib/option.ts +1 -2
- package/templates/module/__Model__.Template.tsx +11 -10
- package/templates/module/__Model__.Unit.tsx +18 -5
- package/templates/module/__Model__.Util.tsx +9 -7
- package/templates/module/__Model__.View.tsx +9 -6
- package/templates/module/__Model__.Zone.tsx +25 -17
- package/templates/module/__model__.constant.ts +8 -9
- package/templates/module/__model__.dictionary.ts +16 -17
- package/templates/module/__model__.document.ts +6 -8
- package/templates/module/__model__.service.ts +3 -3
- package/templates/module/__model__.signal.ts +11 -10
- package/templates/module/__model__.store.ts +3 -5
- package/templates/service/__model__.dictionary.ts +6 -5
- package/templates/service/__model__.service.ts +3 -3
- package/templates/service/__model__.signal.ts +5 -4
- package/templates/service/__model__.store.ts +3 -5
- package/templates/workspaceRoot/.gitignore.template +3 -0
- package/templates/workspaceRoot/.vscode/settings.json.template +21 -21
- package/templates/workspaceRoot/AGENTS.md.template +4 -10
- package/{tunnel.command-kxv0ddmp.js → tunnel.command-q2h0j2en.js} +7 -7
- package/{typeChecker-px49mezc.js → typeChecker-j2jdnqsr.js} +1 -1
- package/typecheck.proc.js +6 -1
- package/verify.command-z1dsbmrt.js +91 -0
- package/{workflow.command-abb1d5xy.js → workflow.command-r3y67jeq.js} +47 -13
- package/workspace.command-t2f0xsrw.js +263 -0
- package/CodeAgent-3sy7kjgj.js +0 -9
- package/TunnelShare-2ef94kha.js +0 -14
- package/agent.command-ydftceda.js +0 -25
- package/cloud.script-v1ysyerg.js +0 -24
- package/context.runner-qb15sjf8.js +0 -25
- package/guidelines/conventions/conventions.instruction.md +0 -617
- package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +0 -291
- package/index-4vgbysa0.js +0 -279
- package/index-7md2g9vw.js +0 -6
- package/index-b70zct19.js +0 -856
- package/index-zzvvc845.js +0 -74
- package/quality.command-ah8qcakd.js +0 -1478
- package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +0 -69
- package/templates/workspaceRoot/docs/GENERATED.md.template +0 -55
- package/workspace.command-tsc99yec.js +0 -521
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
ApplicationBuildReporter
|
|
4
|
+
} from "./index-p6x5b7hr.js";
|
|
5
|
+
import {
|
|
6
|
+
parseBiomeReport,
|
|
7
|
+
Linter,
|
|
8
|
+
TypecheckFailure,
|
|
9
|
+
ProjectTypecheck2,
|
|
10
|
+
AppExecutor,
|
|
11
|
+
LibExecutor,
|
|
12
|
+
PkgExecutor
|
|
13
|
+
} from "./index-8scw1pjk.js";
|
|
14
|
+
import {
|
|
15
|
+
WorkspaceRunner,
|
|
16
|
+
AkanQualityScanner
|
|
17
|
+
} from "./index-am36s3jh.js";
|
|
18
|
+
|
|
19
|
+
// pkgs/@akanjs/cli/verify/verifyComments.ts
|
|
20
|
+
import { existsSync } from "fs";
|
|
21
|
+
import path from "path";
|
|
22
|
+
|
|
23
|
+
class VerifyComments {
|
|
24
|
+
static code = "akan.comment.added";
|
|
25
|
+
static fix = "keep only a fact the code cannot say (vendor quirk, constraint, security, domain meaning, rejected alternative); delete the rest";
|
|
26
|
+
static #codeFile = /\.[cm]?[jt]sx?$/;
|
|
27
|
+
static #directive = /^(\/\/\/?|\/\*+)\s*(biome-ignore|@ts-|eslint-|prettier-ignore|#region|#endregion|<reference|[#@]__PURE__|@__NO_SIDE_EFFECTS__)/;
|
|
28
|
+
static #typescriptLoad;
|
|
29
|
+
static #loadTypescript() {
|
|
30
|
+
VerifyComments.#typescriptLoad ??= import("typescript").then((mod) => mod.default ?? mod);
|
|
31
|
+
return VerifyComments.#typescriptLoad;
|
|
32
|
+
}
|
|
33
|
+
static async added(root, files) {
|
|
34
|
+
const code = files.filter((file) => VerifyComments.#codeFile.test(file) && existsSync(path.join(root, file)));
|
|
35
|
+
if (!code.length)
|
|
36
|
+
return [];
|
|
37
|
+
const changed = await VerifyComments.#addedLines(root, code);
|
|
38
|
+
if (!changed)
|
|
39
|
+
return [];
|
|
40
|
+
const typescript = await VerifyComments.#loadTypescript();
|
|
41
|
+
const diagnostics = [];
|
|
42
|
+
for (const file of code) {
|
|
43
|
+
const lines = changed.get(file);
|
|
44
|
+
if (lines?.size === 0)
|
|
45
|
+
continue;
|
|
46
|
+
const text = await Bun.file(path.join(root, file)).text();
|
|
47
|
+
for (const comment of VerifyComments.commentsOf(typescript, file, text)) {
|
|
48
|
+
if (VerifyComments.#directive.test(comment.text))
|
|
49
|
+
continue;
|
|
50
|
+
if (lines && !VerifyComments.#touches(comment, lines))
|
|
51
|
+
continue;
|
|
52
|
+
diagnostics.push({
|
|
53
|
+
step: "lint",
|
|
54
|
+
file,
|
|
55
|
+
line: comment.line,
|
|
56
|
+
col: comment.col,
|
|
57
|
+
code: VerifyComments.code,
|
|
58
|
+
severity: "warning",
|
|
59
|
+
message: VerifyComments.#excerpt(comment.text)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const [first] = diagnostics;
|
|
64
|
+
if (first)
|
|
65
|
+
first.fix = VerifyComments.fix;
|
|
66
|
+
return diagnostics;
|
|
67
|
+
}
|
|
68
|
+
static commentsOf(typescript, file, text) {
|
|
69
|
+
const kind = file.endsWith("x") ? typescript.ScriptKind.TSX : typescript.ScriptKind.TS;
|
|
70
|
+
const source = typescript.createSourceFile(file, text, typescript.ScriptTarget.Latest, true, kind);
|
|
71
|
+
const ranges = new Map;
|
|
72
|
+
const visit = (node) => {
|
|
73
|
+
if (node.kind === typescript.SyntaxKind.JsxText)
|
|
74
|
+
return;
|
|
75
|
+
if (node.kind >= typescript.SyntaxKind.FirstJSDocNode && node.kind <= typescript.SyntaxKind.LastJSDocNode)
|
|
76
|
+
return;
|
|
77
|
+
const children = node.getChildren(source);
|
|
78
|
+
for (const child of children)
|
|
79
|
+
visit(child);
|
|
80
|
+
if (children.length)
|
|
81
|
+
return;
|
|
82
|
+
const start = node.getFullStart();
|
|
83
|
+
for (const range of [
|
|
84
|
+
...typescript.getTrailingCommentRanges(text, start) ?? [],
|
|
85
|
+
...typescript.getLeadingCommentRanges(text, start) ?? []
|
|
86
|
+
])
|
|
87
|
+
ranges.set(range.pos, range);
|
|
88
|
+
};
|
|
89
|
+
visit(source);
|
|
90
|
+
return [...ranges.values()].sort((a, b) => a.pos - b.pos).map((range) => {
|
|
91
|
+
const start = source.getLineAndCharacterOfPosition(range.pos);
|
|
92
|
+
const end = source.getLineAndCharacterOfPosition(range.end);
|
|
93
|
+
return {
|
|
94
|
+
text: text.slice(range.pos, range.end),
|
|
95
|
+
line: start.line + 1,
|
|
96
|
+
col: start.character + 1,
|
|
97
|
+
lastLine: end.line + 1
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
static #touches(comment, lines) {
|
|
102
|
+
for (let line = comment.line;line <= comment.lastLine; line++)
|
|
103
|
+
if (lines.has(line))
|
|
104
|
+
return true;
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
static #excerpt(comment) {
|
|
108
|
+
const first = comment.split(`
|
|
109
|
+
`).find((line) => line.replace(/^[\s/*]+/, "").trim()) ?? comment;
|
|
110
|
+
const flat = first.replace(/\s+/g, " ").trim();
|
|
111
|
+
return flat.length <= 60 ? flat : `${flat.slice(0, 59)}\u2026`;
|
|
112
|
+
}
|
|
113
|
+
static async#addedLines(root, files) {
|
|
114
|
+
const tracked = await VerifyComments.#git(root, ["ls-files", "-z", "--", ...files]);
|
|
115
|
+
const diff = await VerifyComments.#git(root, [
|
|
116
|
+
"-c",
|
|
117
|
+
"core.quotePath=false",
|
|
118
|
+
"diff",
|
|
119
|
+
"-U0",
|
|
120
|
+
"--no-color",
|
|
121
|
+
"--no-ext-diff",
|
|
122
|
+
"--relative",
|
|
123
|
+
"HEAD",
|
|
124
|
+
"--",
|
|
125
|
+
...files
|
|
126
|
+
]);
|
|
127
|
+
if (tracked === null || diff === null)
|
|
128
|
+
return null;
|
|
129
|
+
const trackedFiles = new Set(tracked.split("\x00").filter(Boolean));
|
|
130
|
+
const added = VerifyComments.parseDiff(diff);
|
|
131
|
+
return new Map(files.map((file) => [file, trackedFiles.has(file) ? added.get(file) ?? new Set : undefined]));
|
|
132
|
+
}
|
|
133
|
+
static parseDiff(diff) {
|
|
134
|
+
const added = new Map;
|
|
135
|
+
let current = null;
|
|
136
|
+
for (const line of diff.split(`
|
|
137
|
+
`)) {
|
|
138
|
+
if (line.startsWith("+++ ")) {
|
|
139
|
+
const file = line.slice(4).replace(/^b\//, "");
|
|
140
|
+
current = file === "/dev/null" ? null : new Set;
|
|
141
|
+
if (current)
|
|
142
|
+
added.set(file, current);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const [, from, length] = line.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/) ?? [];
|
|
146
|
+
if (from === undefined || !current)
|
|
147
|
+
continue;
|
|
148
|
+
const start = Number(from);
|
|
149
|
+
const count = length === undefined ? 1 : Number(length);
|
|
150
|
+
for (let offset = 0;offset < count; offset++)
|
|
151
|
+
current.add(start + offset);
|
|
152
|
+
}
|
|
153
|
+
return added;
|
|
154
|
+
}
|
|
155
|
+
static async#git(root, args) {
|
|
156
|
+
const proc = Bun.spawn(["git", ...args], { cwd: root, stdout: "pipe", stderr: "ignore" });
|
|
157
|
+
const [stdout, code] = await Promise.all([new Response(proc.stdout).text(), proc.exited]);
|
|
158
|
+
return code === 0 ? stdout : null;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// pkgs/@akanjs/cli/verify/verifyPipeline.ts
|
|
163
|
+
import { existsSync as existsSync2 } from "fs";
|
|
164
|
+
import path2 from "path";
|
|
165
|
+
|
|
166
|
+
// pkgs/@akanjs/cli/verify/verifyDiagnostics.ts
|
|
167
|
+
class VerifyDiagnostics {
|
|
168
|
+
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
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
static fromBiome(report) {
|
|
181
|
+
return (report.diagnostics ?? []).filter((diagnostic) => diagnostic.severity === "error" || diagnostic.severity === "warning").map((diagnostic) => ({
|
|
182
|
+
step: "lint",
|
|
183
|
+
file: diagnostic.location?.path?.replaceAll("\\", "/") ?? null,
|
|
184
|
+
line: diagnostic.location?.start?.line ?? 0,
|
|
185
|
+
col: diagnostic.location?.start?.column ?? 0,
|
|
186
|
+
code: diagnostic.category ?? "biome",
|
|
187
|
+
severity: diagnostic.severity === "error" ? "error" : "warning",
|
|
188
|
+
message: diagnostic.message
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
191
|
+
static fromMaintainability(entries) {
|
|
192
|
+
return entries.map((entry) => ({
|
|
193
|
+
step: "lint",
|
|
194
|
+
file: entry.file,
|
|
195
|
+
line: entry.line,
|
|
196
|
+
col: 0,
|
|
197
|
+
code: entry.rule,
|
|
198
|
+
severity: "error",
|
|
199
|
+
message: entry.problem,
|
|
200
|
+
fix: entry.path ? `${entry.fix} Path: ${entry.path}` : entry.fix
|
|
201
|
+
}));
|
|
202
|
+
}
|
|
203
|
+
static fromQuality(warnings, changedFiles) {
|
|
204
|
+
return warnings.filter((warning) => warning.file && changedFiles.has(warning.file)).map((warning) => ({
|
|
205
|
+
step: "ssr",
|
|
206
|
+
file: warning.file ?? null,
|
|
207
|
+
line: warning.line ?? 0,
|
|
208
|
+
col: 0,
|
|
209
|
+
code: warning.rule,
|
|
210
|
+
severity: "warning",
|
|
211
|
+
message: warning.message,
|
|
212
|
+
...warning.fix ? { fix: warning.fix } : {}
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
static #prefix = /^\[([\w.-]+)\]\s*/;
|
|
216
|
+
static #location = /((?:apps|libs|pkgs)\/[^\s:()`'"]+\.[a-z]+)(?::(\d+)(?::(\d+))?)?/;
|
|
217
|
+
static fromMessage(step, message, code = `akan.${step}`) {
|
|
218
|
+
const prefix = VerifyDiagnostics.#prefix.exec(message);
|
|
219
|
+
const location = VerifyDiagnostics.#location.exec(message);
|
|
220
|
+
return {
|
|
221
|
+
step,
|
|
222
|
+
file: location ? location[1] ?? null : null,
|
|
223
|
+
line: Number(location?.[2] ?? 0),
|
|
224
|
+
col: Number(location?.[3] ?? 0),
|
|
225
|
+
code: prefix?.[1] ?? code,
|
|
226
|
+
severity: "error",
|
|
227
|
+
message: message.slice(prefix?.[0].length ?? 0).trim()
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// pkgs/@akanjs/cli/verify/verifyPipeline.ts
|
|
233
|
+
class VerifyPipeline {
|
|
234
|
+
#workspace;
|
|
235
|
+
#workspaceRunner;
|
|
236
|
+
#applicationRunner;
|
|
237
|
+
#steps = new Map;
|
|
238
|
+
#diagnostics = [];
|
|
239
|
+
constructor(workspace, workspaceRunner, applicationRunner) {
|
|
240
|
+
this.#workspace = workspace;
|
|
241
|
+
this.#workspaceRunner = workspaceRunner;
|
|
242
|
+
this.#applicationRunner = applicationRunner;
|
|
243
|
+
}
|
|
244
|
+
get #root() {
|
|
245
|
+
return this.#workspace.workspaceRoot;
|
|
246
|
+
}
|
|
247
|
+
async run(scope, { lintOnly = false, build = true } = {}) {
|
|
248
|
+
const startedAt = performance.now();
|
|
249
|
+
const systems = scope.targets.filter((target) => target.type !== "pkg");
|
|
250
|
+
if (!lintOnly)
|
|
251
|
+
await this.#each("sync", systems, (target) => this.#sync(target));
|
|
252
|
+
const synced = !this.#failed("sync");
|
|
253
|
+
await Promise.all([
|
|
254
|
+
this.#each("lint", scope.targets, (target) => this.#lint(target, { comments: !lintOnly })),
|
|
255
|
+
lintOnly || !synced ? null : this.#each("typecheck", scope.targets, (target) => this.#typecheck(target))
|
|
256
|
+
]);
|
|
257
|
+
const apps = scope.targets.filter((target) => target.type === "app");
|
|
258
|
+
const clean = !this.#diagnostics.some((diagnostic) => diagnostic.severity === "error");
|
|
259
|
+
if (!lintOnly && build && apps.length) {
|
|
260
|
+
if (clean)
|
|
261
|
+
await this.#each("build", apps, (target) => this.#build(target));
|
|
262
|
+
else
|
|
263
|
+
this.#skip("build");
|
|
264
|
+
}
|
|
265
|
+
if (!lintOnly && scope.touchesTsx)
|
|
266
|
+
await this.#each("ssr", [null], () => this.#ssr(scope));
|
|
267
|
+
return {
|
|
268
|
+
ok: !this.#diagnostics.some((diagnostic) => diagnostic.severity === "error"),
|
|
269
|
+
targets: scope.targets.map((target) => target.name),
|
|
270
|
+
ms: Math.round(performance.now() - startedAt),
|
|
271
|
+
steps: [...this.#steps.values()],
|
|
272
|
+
diagnostics: this.#diagnostics
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
async#each(name, items, step) {
|
|
276
|
+
if (!items.length)
|
|
277
|
+
return;
|
|
278
|
+
const startedAt = performance.now();
|
|
279
|
+
let fixed = 0;
|
|
280
|
+
let failed = false;
|
|
281
|
+
for (const item of items) {
|
|
282
|
+
const outcome = await step(item).catch((error) => ({
|
|
283
|
+
diagnostics: [VerifyDiagnostics.fromMessage(name, ApplicationBuildReporter.formatError(error, this.#root))]
|
|
284
|
+
}));
|
|
285
|
+
fixed += outcome.fixed ?? 0;
|
|
286
|
+
failed ||= outcome.diagnostics.some((diagnostic) => diagnostic.severity === "error");
|
|
287
|
+
this.#diagnostics.push(...outcome.diagnostics);
|
|
288
|
+
}
|
|
289
|
+
const ms = Math.round(performance.now() - startedAt);
|
|
290
|
+
this.#steps.set(name, { name, status: failed ? "fail" : "pass", ms, fixed });
|
|
291
|
+
}
|
|
292
|
+
#skip(name) {
|
|
293
|
+
this.#steps.set(name, { name, status: "skip", ms: 0, fixed: 0 });
|
|
294
|
+
}
|
|
295
|
+
#failed(name) {
|
|
296
|
+
return this.#steps.get(name)?.status === "fail";
|
|
297
|
+
}
|
|
298
|
+
async#sync(target) {
|
|
299
|
+
if (target.type === "app")
|
|
300
|
+
await AppExecutor.from(this.#workspace, target.name).scanSync();
|
|
301
|
+
else
|
|
302
|
+
await LibExecutor.from(this.#workspace, target.name).scan();
|
|
303
|
+
return { diagnostics: [] };
|
|
304
|
+
}
|
|
305
|
+
async#lint(target, { comments }) {
|
|
306
|
+
const files = target.files.length ? target.files.filter((file) => existsSync2(path2.join(this.#root, file))) : [target.dir];
|
|
307
|
+
const biome = files.length ? await this.#biome(files) : { diagnostics: [], fixed: 0 };
|
|
308
|
+
const exec = this.#execOf(target);
|
|
309
|
+
const gates = await this.#workspaceRunner.lintGateFailures(exec, true);
|
|
310
|
+
const added = comments && target.files.length ? await VerifyComments.added(this.#root, target.files) : [];
|
|
311
|
+
return {
|
|
312
|
+
diagnostics: [
|
|
313
|
+
...biome.diagnostics,
|
|
314
|
+
...added,
|
|
315
|
+
...gates.messages.map((message) => VerifyDiagnostics.fromMessage("lint", message, "akan.lint")),
|
|
316
|
+
...VerifyDiagnostics.fromMaintainability(gates.maintainability)
|
|
317
|
+
],
|
|
318
|
+
fixed: biome.fixed
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
async#biome(files) {
|
|
322
|
+
const configPath = await WorkspaceRunner.resolveBiomeConfigPath(this.#workspace);
|
|
323
|
+
const [biome, ...biomeArgs] = Linter.biomeCommand(this.#root);
|
|
324
|
+
const proc = Bun.spawn([
|
|
325
|
+
biome,
|
|
326
|
+
...biomeArgs,
|
|
327
|
+
"check",
|
|
328
|
+
"--write",
|
|
329
|
+
"--reporter=json",
|
|
330
|
+
"--max-diagnostics=none",
|
|
331
|
+
"--no-errors-on-unmatched",
|
|
332
|
+
...configPath ? ["--config-path", configPath] : [],
|
|
333
|
+
...files
|
|
334
|
+
], { cwd: this.#root, stdout: "pipe", stderr: "pipe" });
|
|
335
|
+
const [stdout, stderr] = await Promise.all([
|
|
336
|
+
new Response(proc.stdout).text(),
|
|
337
|
+
new Response(proc.stderr).text(),
|
|
338
|
+
proc.exited
|
|
339
|
+
]);
|
|
340
|
+
try {
|
|
341
|
+
const report = parseBiomeReport(stdout);
|
|
342
|
+
return { diagnostics: VerifyDiagnostics.fromBiome(report), fixed: report.summary?.changed ?? 0 };
|
|
343
|
+
} catch {
|
|
344
|
+
return { diagnostics: [VerifyDiagnostics.fromMessage("lint", (stderr || stdout).trim(), "biome")] };
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
async#typecheck(target) {
|
|
348
|
+
try {
|
|
349
|
+
if (target.type === "app")
|
|
350
|
+
await this.#applicationRunner.typecheck(AppExecutor.from(this.#workspace, target.name), {
|
|
351
|
+
tests: true,
|
|
352
|
+
report: "records"
|
|
353
|
+
});
|
|
354
|
+
else if (target.type === "lib")
|
|
355
|
+
await this.#applicationRunner.typecheckLibrary(LibExecutor.from(this.#workspace, target.name), {
|
|
356
|
+
tests: true,
|
|
357
|
+
report: "records"
|
|
358
|
+
});
|
|
359
|
+
else {
|
|
360
|
+
const tsconfigPath = path2.join(this.#root, target.dir, "tsconfig.json");
|
|
361
|
+
if (!existsSync2(tsconfigPath))
|
|
362
|
+
return { diagnostics: [] };
|
|
363
|
+
await new ProjectTypecheck2(path2.join(this.#root, target.dir), this.#root, process.env).check(tsconfigPath, "records");
|
|
364
|
+
}
|
|
365
|
+
return { diagnostics: [] };
|
|
366
|
+
} catch (error) {
|
|
367
|
+
if (error instanceof TypecheckFailure)
|
|
368
|
+
return { diagnostics: VerifyDiagnostics.fromTypecheck(error.records) };
|
|
369
|
+
throw error;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
async#build(target) {
|
|
373
|
+
await this.#applicationRunner.build(AppExecutor.from(this.#workspace, target.name), { fast: true });
|
|
374
|
+
return { diagnostics: [] };
|
|
375
|
+
}
|
|
376
|
+
async#ssr(scope) {
|
|
377
|
+
const scanned = await new AkanQualityScanner().scan(this.#root);
|
|
378
|
+
const warnings = scanned.warnings.filter((warning) => warning.scope === "ssr");
|
|
379
|
+
return { diagnostics: VerifyDiagnostics.fromQuality(warnings, scope.changedFiles) };
|
|
380
|
+
}
|
|
381
|
+
#execOf(target) {
|
|
382
|
+
if (target.type === "app")
|
|
383
|
+
return AppExecutor.from(this.#workspace, target.name);
|
|
384
|
+
if (target.type === "lib")
|
|
385
|
+
return LibExecutor.from(this.#workspace, target.name);
|
|
386
|
+
return PkgExecutor.from(this.#workspace, target.name);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// pkgs/@akanjs/cli/verify/verifyReport.ts
|
|
391
|
+
class VerifyReport {
|
|
392
|
+
static lineMax = 280;
|
|
393
|
+
static defaultMax = 20;
|
|
394
|
+
static text(result, { max = VerifyReport.defaultMax } = {}) {
|
|
395
|
+
if (!result.targets.length)
|
|
396
|
+
return "verify ok \xB7 nothing changed under apps/, libs/ or pkgs/";
|
|
397
|
+
const lines = [VerifyReport.#header(result), ...VerifyReport.#diagnosticLines(result.diagnostics, max)];
|
|
398
|
+
return lines.join(`
|
|
399
|
+
`);
|
|
400
|
+
}
|
|
401
|
+
static json(result) {
|
|
402
|
+
return JSON.stringify(result);
|
|
403
|
+
}
|
|
404
|
+
static #header(result) {
|
|
405
|
+
const ran = result.steps.filter((step) => step.name !== "sync" || step.status === "fail");
|
|
406
|
+
const fixed = result.steps.reduce((sum, step) => sum + step.fixed, 0);
|
|
407
|
+
const seconds = `${(result.ms / 1000).toFixed(1)}s`;
|
|
408
|
+
const fixedNote = fixed ? `fixed ${fixed} file${fixed === 1 ? "" : "s"}` : null;
|
|
409
|
+
const steps = result.ok ? ran.filter((step) => step.status === "pass").map((step) => step.name).join(" ") : ran.map((step) => VerifyReport.#stepLabel(step, result.diagnostics)).join(" \xB7 ");
|
|
410
|
+
return [`verify ${result.ok ? "ok" : "fail"}`, result.targets.join(", "), steps, fixedNote, seconds].filter(Boolean).join(" \xB7 ");
|
|
411
|
+
}
|
|
412
|
+
static #stepLabel(step, diagnostics) {
|
|
413
|
+
if (step.status === "skip")
|
|
414
|
+
return `${step.name} skipped`;
|
|
415
|
+
if (step.status === "pass")
|
|
416
|
+
return `${step.name} ok`;
|
|
417
|
+
const errors = diagnostics.filter((entry) => entry.step === step.name && entry.severity === "error").length;
|
|
418
|
+
return `${step.name} ${errors} error${errors === 1 ? "" : "s"}`;
|
|
419
|
+
}
|
|
420
|
+
static #diagnosticLines(diagnostics, max) {
|
|
421
|
+
const groups = new Map;
|
|
422
|
+
const ordered = [...diagnostics].sort((a, b) => Number(a.severity === "warning") - Number(b.severity === "warning"));
|
|
423
|
+
for (const diagnostic of ordered) {
|
|
424
|
+
const key = `${diagnostic.code}\x00${diagnostic.message}`;
|
|
425
|
+
groups.set(key, [...groups.get(key) ?? [], diagnostic]);
|
|
426
|
+
}
|
|
427
|
+
const lines = [...groups.values()].map((group) => VerifyReport.#lineOf(group));
|
|
428
|
+
if (max <= 0 || lines.length <= max)
|
|
429
|
+
return lines;
|
|
430
|
+
return [...lines.slice(0, max), `+${lines.length - max} more \xB7 akan verify --max 0`];
|
|
431
|
+
}
|
|
432
|
+
static #lineOf([first, ...rest]) {
|
|
433
|
+
if (!first)
|
|
434
|
+
return "";
|
|
435
|
+
const where = first.file ? `${first.file}${first.line ? `:${first.line}${first.col ? `:${first.col}` : ""}` : ""}` : "-";
|
|
436
|
+
const others = rest.length ? ` (\xD7${rest.length + 1}: ${rest.slice(0, 2).map((entry) => entry.file === first.file ? `:${entry.line}` : entry.file ?? "-").join(", ")}${rest.length > 2 ? `, +${rest.length - 2}` : ""})` : "";
|
|
437
|
+
const fix = first.fix ? ` fix: ${first.fix}` : "";
|
|
438
|
+
const warning = first.severity === "warning" ? " warning" : "";
|
|
439
|
+
const line = `${where}${others}${warning} ${first.code} ${first.message}${fix}`.replace(/\s+/g, " ").trim();
|
|
440
|
+
return line.length <= VerifyReport.lineMax ? line : `${line.slice(0, VerifyReport.lineMax - 1)}\u2026`;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
export { VerifyComments, VerifyPipeline, VerifyReport };
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
SOURCE_EXTS,
|
|
7
7
|
WatchRootResolver
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-p6x5b7hr.js";
|
|
9
9
|
import {
|
|
10
10
|
bundleDefine,
|
|
11
11
|
CsrEntryFiles,
|
|
@@ -19,11 +19,11 @@ import {
|
|
|
19
19
|
CsrDevPaths,
|
|
20
20
|
PagesEntrySourceGenerator,
|
|
21
21
|
PagesBundleBuilder
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-xqgwjz7a.js";
|
|
23
23
|
import {
|
|
24
24
|
AsyncDefaultExportDetector,
|
|
25
25
|
resolveSsrPageEntriesForApp
|
|
26
|
-
} from "./index-
|
|
26
|
+
} from "./index-8scw1pjk.js";
|
|
27
27
|
|
|
28
28
|
// pkgs/@akanjs/devkit/frontendBuild/autoImportSync.ts
|
|
29
29
|
import { readdir, readFile, stat } from "fs/promises";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
LibExecutor,
|
|
11
11
|
PkgExecutor,
|
|
12
12
|
ModuleExecutor
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-8scw1pjk.js";
|
|
14
14
|
|
|
15
15
|
// pkgs/@akanjs/devkit/commandDecorators/camelToKebabCase.ts
|
|
16
16
|
var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
@@ -348,7 +348,11 @@ class WorkspaceVersionCheck {
|
|
|
348
348
|
return JSON.parse(readFileSync(packageJsonPath, "utf8")).version ?? null;
|
|
349
349
|
}
|
|
350
350
|
static #quote(arg) {
|
|
351
|
-
|
|
351
|
+
if (/^[\w@%+=:,./-]+$/.test(arg))
|
|
352
|
+
return arg;
|
|
353
|
+
if (process.platform === "win32")
|
|
354
|
+
return `"${arg.replaceAll('"', "\\\"")}"`;
|
|
355
|
+
return `'${arg.replaceAll("'", `'\\''`)}'`;
|
|
352
356
|
}
|
|
353
357
|
}
|
|
354
358
|
|
|
@@ -853,4 +857,4 @@ function command(refName, depsOrBuilder, builder) {
|
|
|
853
857
|
}
|
|
854
858
|
return CommandBase;
|
|
855
859
|
}
|
|
856
|
-
export { getTargetMetas, getTargetCommandNames, App, Apps, Lib, Sys, SysOrOnlyApp, Exec, Pkg, Module, Workspace, CommandContainer, runner, script, ExitCodeError, markCliErrorPrinted, assertPromptable, runCommands, command };
|
|
860
|
+
export { camelToKebabCase, getTargetMetas, getTargetCommandNames, App, Apps, Lib, Sys, SysOrOnlyApp, Exec, Pkg, Module, Workspace, CommandContainer, runner, script, ExitCodeError, markCliErrorPrinted, assertPromptable, runCommands, command };
|