@akanjs/cli 3.0.0-alpha.71 → 3.0.0-alpha.73
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/{abstractCompactor-20e0cwbs.js → abstractCompactor-8yjc9sj4.js} +1 -1
- package/{agent.command-xdvw642m.js → agent.command-z0cam80t.js} +6 -6
- package/{application.command-g3f7xj25.js → application.command-2dct57za.js} +11 -12
- package/{applicationBuildRunner-af0wtspv.js → applicationBuildRunner-ds8acdfz.js} +3 -3
- package/{applicationReleasePackager-93nzdfsy.js → applicationReleasePackager-0jf6ejr4.js} +2 -2
- package/buildBatch.proc.js +4 -4
- package/{capacitorApp-b0ppke3m.js → capacitorApp-md7dnt25.js} +2 -2
- package/{cloud.command-0hmsv44q.js → cloud.command-8j7xrxsm.js} +10 -10
- package/{context.command-x92afrnf.js → context.command-xjf4y7em.js} +14 -14
- package/{dependencyScanner-rbs2407b.js → dependencyScanner-aqg3dkks.js} +1 -1
- package/{guideline.command-hpq08q66.js → guideline.command-yzm0qevv.js} +4 -4
- package/guidelines/conventions/conventions.instruction.md +17 -9
- package/guidelines/ssrRule/ssrRule.instruction.md +49 -5
- package/incrementalBuilder.proc.js +5 -5
- package/{index-737aj4fm.js → index-116w1dap.js} +4 -4
- package/{index-cp00yns2.js → index-5r4e65hb.js} +65 -62
- package/{index-abyjt72y.js → index-61x7qthy.js} +17 -21
- package/{index-m5gfc86a.js → index-763h7h9g.js} +1 -1
- package/{index-wnp7hwq7.js → index-94hdqqka.js} +1 -1
- package/{index-r691v756.js → index-9gqzgfsd.js} +4 -4
- package/{index-pehn44hr.js → index-a341yqdh.js} +3 -3
- package/{index-gvq17wqn.js → index-akz5xvyw.js} +17 -5
- package/{index-6d5r8q6k.js → index-bmz9crym.js} +13 -6
- package/{index-nq3avsf6.js → index-eed7vc38.js} +66 -33
- package/{index-46tjzh6s.js → index-h5sr2nnj.js} +24 -24
- package/{index-5f4gnt4c.js → index-h9cybjep.js} +91 -19
- package/{index-sqsfv8wg.js → index-hvbdre8z.js} +4 -10
- package/{index-qnv0aqmm.js → index-jcm6zr20.js} +3 -1
- package/{index-j37qq1f2.js → index-k7731a4v.js} +4 -4
- package/{index-8besc14m.js → index-q0s2dp3y.js} +1 -1
- package/{index-ety6takb.js → index-q13s3e01.js} +3 -3
- package/{index-jybbmwed.js → index-qge1hc70.js} +5 -5
- package/{index-sh01r3pm.js → index-safgeq9a.js} +3 -2
- package/{index-xjd3rqzj.js → index-scemmfpj.js} +6 -15
- package/{index-wbbswwqt.js → index-te6r1b79.js} +5 -5
- package/{index-p27h7535.js → index-vrra4ttx.js} +6 -6
- package/{index-hs70d8ed.js → index-y3wyqcsp.js} +6 -6
- package/{index-cbfp5wyp.js → index-ym9g9ggs.js} +21 -21
- package/{index-fgc8r6dj.js → index-ynf37b66.js} +3 -1
- package/{index-wybbcgxn.js → index-z52nhkjs.js} +4 -4
- package/index.js +18 -18
- package/{library.command-8vgrdtwy.js → library.command-w8b53vtt.js} +4 -4
- package/{localRegistry.command-0gtqj0r0.js → localRegistry.command-ymrgda7e.js} +9 -9
- package/{module.command-rama4zya.js → module.command-7pje37dv.js} +7 -7
- package/{package.command-6jxapdsg.js → package.command-jg4qk8ts.js} +4 -4
- package/package.json +3 -4
- package/{page.command-hxy7x525.js → page.command-abbpj96j.js} +3 -3
- package/{primitive.command-4bf6xcc3.js → primitive.command-jw4yv918.js} +8 -8
- package/{quality.command-h5edwegz.js → quality.command-06j6qy6n.js} +34 -4
- package/{repair.command-rgqf6px6.js → repair.command-x6resn10.js} +5 -5
- package/{scalar.command-6krkz6tw.js → scalar.command-mj2vx6rj.js} +6 -6
- package/templates/appSample/lib/task/task.signal.ts +11 -6
- package/templates/crudPages/[__model__Id]/edit/page.tsx +5 -5
- package/templates/crudPages/[__model__Id]/page.tsx +10 -13
- package/templates/crudPages/new/page.tsx +5 -5
- package/templates/crudPages/page.tsx +9 -9
- package/templates/crudSinglePage/page.tsx +11 -7
- package/templates/module/__model__.dictionary.ts +4 -1
- package/templates/module/__model__.signal.ts +2 -3
- package/templates/module/__model__.store.ts +1 -2
- package/{typeChecker-g6bh0xfv.js → typeChecker-yhs4eht8.js} +1 -1
- package/typecheck.proc.js +1 -1
- package/{workflow.command-dwhwrqhd.js → workflow.command-pmw2tere.js} +11 -11
- package/{workspace.command-f5h11gjn.js → workspace.command-x32k2vma.js} +29 -26
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
RepairRunner
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-q13s3e01.js";
|
|
5
5
|
import {
|
|
6
6
|
WorkflowRunner
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-a341yqdh.js";
|
|
8
8
|
import {
|
|
9
9
|
ScalarScript
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-9gqzgfsd.js";
|
|
11
11
|
import {
|
|
12
12
|
PrimitiveScript
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-z52nhkjs.js";
|
|
14
14
|
import {
|
|
15
15
|
ModuleScript
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-vrra4ttx.js";
|
|
17
17
|
import {
|
|
18
18
|
isPlaceholderAppId
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-ym9g9ggs.js";
|
|
20
20
|
import {
|
|
21
21
|
AkanContextAnalyzer,
|
|
22
22
|
akanMcpInstallConfigPaths,
|
|
23
23
|
akanMcpInstallTargets,
|
|
24
|
+
buildResourceList,
|
|
24
25
|
codexMcpConfigPath,
|
|
25
26
|
createAkanCodexMcpServerBlock,
|
|
26
27
|
createAkanMcpServer,
|
|
27
28
|
renderDoctorText,
|
|
28
|
-
resourceList,
|
|
29
29
|
upsertCodexMcpServerBlock
|
|
30
|
-
} from "./index-
|
|
30
|
+
} from "./index-bmz9crym.js";
|
|
31
31
|
import {
|
|
32
32
|
buildAkanModuleContextIndex,
|
|
33
33
|
createWorkflowBaselineSummary,
|
|
34
34
|
createWorkflowStepRegistry,
|
|
35
35
|
jsonText,
|
|
36
36
|
toolingRolloutGate
|
|
37
|
-
} from "./index-
|
|
37
|
+
} from "./index-q0s2dp3y.js";
|
|
38
38
|
import {
|
|
39
39
|
Prompter
|
|
40
|
-
} from "./index-
|
|
40
|
+
} from "./index-k7731a4v.js";
|
|
41
41
|
import {
|
|
42
42
|
getMobileTargets
|
|
43
43
|
} from "./index-76rn3g2c.js";
|
|
@@ -45,10 +45,10 @@ import {
|
|
|
45
45
|
CommandContainer,
|
|
46
46
|
runner,
|
|
47
47
|
script
|
|
48
|
-
} from "./index-
|
|
48
|
+
} from "./index-akz5xvyw.js";
|
|
49
49
|
import {
|
|
50
50
|
AppExecutor
|
|
51
|
-
} from "./index-
|
|
51
|
+
} from "./index-h9cybjep.js";
|
|
52
52
|
|
|
53
53
|
// pkgs/@akanjs/cli/context/context.script.ts
|
|
54
54
|
import { Logger } from "akanjs/common";
|
|
@@ -380,12 +380,15 @@ var applyMcpTools = [
|
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
];
|
|
383
|
-
var listAkanMcpTools = (mode = "readonly") => {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
383
|
+
var listAkanMcpTools = (mode = "readonly", { guidelineNames = [] } = {}) => {
|
|
384
|
+
const tools = mode === "readonly" ? readonlyMcpTools : mode === "plan" ? [...readonlyMcpTools, ...planMcpTools] : [...readonlyMcpTools, ...planMcpTools, ...applyMcpTools];
|
|
385
|
+
if (guidelineNames.length === 0)
|
|
386
|
+
return tools;
|
|
387
|
+
return tools.map((tool) => tool.name === "get_guideline" ? {
|
|
388
|
+
...tool,
|
|
389
|
+
description: `${tool.description ?? ""} One of: ${guidelineNames.join(", ")}.`.trim(),
|
|
390
|
+
inputSchema: { ...tool.inputSchema, properties: { name: { type: "string", enum: [...guidelineNames] } } }
|
|
391
|
+
} : tool);
|
|
389
392
|
};
|
|
390
393
|
var createAkanValidationContract = (listTools = listAkanMcpTools) => ({
|
|
391
394
|
schemaVersion: 1,
|
|
@@ -604,6 +607,10 @@ var createCliWorkflowStepRegistry = (workspace) => createWorkflowStepRegistry({
|
|
|
604
607
|
});
|
|
605
608
|
|
|
606
609
|
// pkgs/@akanjs/cli/context/context.runner.ts
|
|
610
|
+
var toolErrorText = (error) => {
|
|
611
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
612
|
+
return message.replace(/\/(?:[^\s"'/]+\/)*(?=(?:pkgs|apps|libs|infra)\/)/g, "<workspace>/");
|
|
613
|
+
};
|
|
607
614
|
var workflowDiagnosticFromContext = (diagnostic) => ({
|
|
608
615
|
severity: diagnostic.severity,
|
|
609
616
|
code: diagnostic.code,
|
|
@@ -720,8 +727,8 @@ class ContextRunner extends runner("context") {
|
|
|
720
727
|
await workspace.writeFile(codexMcpConfigPath, merged);
|
|
721
728
|
return codexMcpConfigPath;
|
|
722
729
|
}
|
|
723
|
-
listMcpTools(mode = "readonly") {
|
|
724
|
-
return listAkanMcpTools(mode);
|
|
730
|
+
listMcpTools(mode = "readonly", { guidelineNames = [] } = {}) {
|
|
731
|
+
return listAkanMcpTools(mode, { guidelineNames });
|
|
725
732
|
}
|
|
726
733
|
async callMcpTool(workspace, name, args = {}, { mode = "readonly" } = {}) {
|
|
727
734
|
const availableTools = this.listMcpTools(mode);
|
|
@@ -851,17 +858,20 @@ class ContextRunner extends runner("context") {
|
|
|
851
858
|
${payload}`);
|
|
852
859
|
};
|
|
853
860
|
const respond = (id, result, framing) => {
|
|
854
|
-
writeMessage({ jsonrpc: "2.0", id, result }, framing);
|
|
861
|
+
writeMessage({ jsonrpc: "2.0", id: id ?? null, result }, framing);
|
|
855
862
|
};
|
|
856
863
|
const respondError = (id, code, message, framing) => {
|
|
857
|
-
writeMessage({ jsonrpc: "2.0", id, error: { code, message } }, framing);
|
|
864
|
+
writeMessage({ jsonrpc: "2.0", id: id ?? null, error: { code, message } }, framing);
|
|
858
865
|
};
|
|
866
|
+
const guidelineNames = await Prompter.listGuidelines();
|
|
867
|
+
const resources = buildResourceList(guidelineNames);
|
|
859
868
|
const readResource = async (uri) => {
|
|
860
|
-
|
|
861
|
-
if (uri === "akan://docs/framework" || uri === "akan://guidelines/framework")
|
|
869
|
+
if (uri === "akan://docs/framework")
|
|
862
870
|
return { uri, mimeType: "text/markdown", text: await Prompter.getInstruction("framework") };
|
|
863
|
-
|
|
864
|
-
|
|
871
|
+
const guideline = /^akan:\/\/guidelines\/(.+)$/.exec(uri)?.[1];
|
|
872
|
+
if (guideline)
|
|
873
|
+
return { uri, mimeType: "text/markdown", text: await Prompter.getInstruction(guideline) };
|
|
874
|
+
const context = await AkanContextAnalyzer.analyze(workspace);
|
|
865
875
|
if (uri === "akan://workspace/summary")
|
|
866
876
|
return { uri, mimeType: "application/json", text: jsonText(context, { trailingNewline: false }) };
|
|
867
877
|
if (uri === "akan://workspace/apps")
|
|
@@ -883,7 +893,7 @@ ${payload}`);
|
|
|
883
893
|
}
|
|
884
894
|
throw new Error(`Unknown resource: ${uri}`);
|
|
885
895
|
};
|
|
886
|
-
const
|
|
896
|
+
const handleRequest = async (request, framing) => {
|
|
887
897
|
const params = request.params ?? {};
|
|
888
898
|
if (request.method === "initialize") {
|
|
889
899
|
respond(request.id, {
|
|
@@ -893,7 +903,7 @@ ${payload}`);
|
|
|
893
903
|
}, framing);
|
|
894
904
|
} else if (request.method === "tools/list") {
|
|
895
905
|
respond(request.id, {
|
|
896
|
-
tools: this.listMcpTools(mode)
|
|
906
|
+
tools: this.listMcpTools(mode, { guidelineNames })
|
|
897
907
|
}, framing);
|
|
898
908
|
} else if (request.method === "tools/call") {
|
|
899
909
|
const name = params.name;
|
|
@@ -909,16 +919,39 @@ ${payload}`);
|
|
|
909
919
|
]
|
|
910
920
|
}, framing);
|
|
911
921
|
} catch (error) {
|
|
912
|
-
|
|
922
|
+
respond(request.id, { content: [{ type: "text", text: toolErrorText(error) }], isError: true }, framing);
|
|
913
923
|
}
|
|
914
924
|
} else if (request.method === "resources/list") {
|
|
915
|
-
respond(request.id, { resources
|
|
925
|
+
respond(request.id, { resources }, framing);
|
|
916
926
|
} else if (request.method === "resources/read") {
|
|
917
927
|
respond(request.id, { contents: [await readResource(params.uri)] }, framing);
|
|
918
|
-
} else
|
|
928
|
+
} else {
|
|
919
929
|
respondError(request.id, -32601, `Unknown method: ${request.method}`, framing);
|
|
920
930
|
}
|
|
921
931
|
};
|
|
932
|
+
const handle = async (request, framing) => {
|
|
933
|
+
if (request.id === undefined || request.id === null)
|
|
934
|
+
return;
|
|
935
|
+
try {
|
|
936
|
+
await handleRequest(request, framing);
|
|
937
|
+
} catch (error) {
|
|
938
|
+
respondError(request.id, -32603, error instanceof Error ? error.message : String(error), framing);
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
const handleFrame = async (payload, framing) => {
|
|
942
|
+
let request;
|
|
943
|
+
try {
|
|
944
|
+
request = JSON.parse(payload);
|
|
945
|
+
} catch (error) {
|
|
946
|
+
respondError(null, -32700, error instanceof Error ? error.message : String(error), framing);
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
if (!request || typeof request !== "object" || typeof request.method !== "string") {
|
|
950
|
+
respondError(null, -32600, "Invalid Request: expected a JSON-RPC 2.0 object with a method", framing);
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
await handle(request, framing);
|
|
954
|
+
};
|
|
922
955
|
const parseContentLengthMessage = async () => {
|
|
923
956
|
const headerEnd = buffer.indexOf(`\r
|
|
924
957
|
\r
|
|
@@ -938,7 +971,7 @@ ${payload}`);
|
|
|
938
971
|
return false;
|
|
939
972
|
const body = buffer.slice(bodyStart, bodyEnd);
|
|
940
973
|
buffer = buffer.slice(bodyEnd);
|
|
941
|
-
await
|
|
974
|
+
await handleFrame(body, "content-length");
|
|
942
975
|
return true;
|
|
943
976
|
};
|
|
944
977
|
const parseLineMessage = async () => {
|
|
@@ -950,7 +983,7 @@ ${payload}`);
|
|
|
950
983
|
buffer = buffer.slice(lineEnd + 1);
|
|
951
984
|
if (!line)
|
|
952
985
|
return true;
|
|
953
|
-
await
|
|
986
|
+
await handleFrame(line, "newline");
|
|
954
987
|
return true;
|
|
955
988
|
};
|
|
956
989
|
const parse = async () => {
|
|
@@ -9,6 +9,8 @@ import * as path from "path";
|
|
|
9
9
|
import ignore from "ignore";
|
|
10
10
|
import ts from "typescript";
|
|
11
11
|
var testFileRegex = /\.(?:test|spec)\.[cm]?[tj]sx?$/;
|
|
12
|
+
var skipDirs = ["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android", "__fixtures__"];
|
|
13
|
+
var isSkippedPath = (filePath) => skipDirs.some((dir) => filePath.includes(`/${dir}/`) || filePath.startsWith(`${dir}/`));
|
|
12
14
|
var builtinModuleSet = new Set([...builtinModules, ...builtinModules.map((mod) => `node:${mod}`)]);
|
|
13
15
|
var stripShebang = (source) => source.replace(/^#!.*(?:\r?\n|$)/, "");
|
|
14
16
|
|
|
@@ -19,22 +21,22 @@ class TypeScriptDependencyScanner {
|
|
|
19
21
|
#visitedFiles = new Set;
|
|
20
22
|
#tsTranspiler = new Bun.Transpiler({ loader: "ts" });
|
|
21
23
|
#tsxTranspiler = new Bun.Transpiler({ loader: "tsx" });
|
|
22
|
-
directory;
|
|
23
|
-
rootPackageJson;
|
|
24
|
-
ig;
|
|
25
|
-
workspaceRoot;
|
|
24
|
+
#directory;
|
|
25
|
+
#rootPackageJson;
|
|
26
|
+
#ig;
|
|
27
|
+
#workspaceRoot;
|
|
26
28
|
constructor(directory, {
|
|
27
29
|
workspaceRoot,
|
|
28
30
|
rootPackageJson,
|
|
29
31
|
gitignorePatterns = []
|
|
30
32
|
}) {
|
|
31
|
-
this
|
|
32
|
-
this
|
|
33
|
-
this
|
|
34
|
-
this
|
|
33
|
+
this.#directory = directory;
|
|
34
|
+
this.#rootPackageJson = rootPackageJson;
|
|
35
|
+
this.#ig = ignore().add(gitignorePatterns);
|
|
36
|
+
this.#workspaceRoot = workspaceRoot;
|
|
35
37
|
}
|
|
36
38
|
async getMonorepoDependencies(projectName, { pkgs = [], libs = [] } = {}) {
|
|
37
|
-
const npmSet = new Set(Object.keys({ ...this
|
|
39
|
+
const npmSet = new Set(Object.keys({ ...this.#rootPackageJson.dependencies, ...this.#rootPackageJson.devDependencies }));
|
|
38
40
|
const pkgPathSet = new Set(pkgs);
|
|
39
41
|
const libPathSet = new Set(libs.map((lib) => `@libs/${lib}`));
|
|
40
42
|
await this.getDependencies();
|
|
@@ -52,11 +54,11 @@ class TypeScriptDependencyScanner {
|
|
|
52
54
|
async getPackageBuildDependencies(projectName) {
|
|
53
55
|
const runtimeDeps = new Set;
|
|
54
56
|
const devDeps = new Set;
|
|
55
|
-
const sourceFiles = await this.#findTypeScriptFiles(this
|
|
57
|
+
const sourceFiles = await this.#findTypeScriptFiles(this.#directory, {
|
|
56
58
|
excludeBuildFiles: true,
|
|
57
59
|
excludeTestFiles: true
|
|
58
60
|
});
|
|
59
|
-
const cssFiles = await this.#findCssFiles(this
|
|
61
|
+
const cssFiles = await this.#findCssFiles(this.#directory);
|
|
60
62
|
for (const filePath of sourceFiles) {
|
|
61
63
|
const fileContent = await FileSys.readText(filePath);
|
|
62
64
|
const { imports, typeImports } = this.#extractImports(fileContent, filePath);
|
|
@@ -67,7 +69,7 @@ class TypeScriptDependencyScanner {
|
|
|
67
69
|
const fileContent = await FileSys.readText(filePath);
|
|
68
70
|
this.#addNormalizedImports(runtimeDeps, this.#extractCssPluginImports(fileContent), projectName);
|
|
69
71
|
}
|
|
70
|
-
const buildFilePath = path.join(this
|
|
72
|
+
const buildFilePath = path.join(this.#directory, "build.ts");
|
|
71
73
|
if (await FileSys.fileExists(buildFilePath)) {
|
|
72
74
|
const fileContent = await FileSys.readText(buildFilePath);
|
|
73
75
|
const { imports, typeImports } = this.#extractImports(fileContent, buildFilePath);
|
|
@@ -75,7 +77,7 @@ class TypeScriptDependencyScanner {
|
|
|
75
77
|
}
|
|
76
78
|
for (const dep of runtimeDeps)
|
|
77
79
|
devDeps.delete(dep);
|
|
78
|
-
const rootDeps = { ...this
|
|
80
|
+
const rootDeps = { ...this.#rootPackageJson.dependencies, ...this.#rootPackageJson.devDependencies };
|
|
79
81
|
const missingDeps = [];
|
|
80
82
|
for (const dep of [...runtimeDeps, ...devDeps]) {
|
|
81
83
|
if (rootDeps[dep] || await this.#hasWorkspacePackage(dep))
|
|
@@ -89,7 +91,7 @@ class TypeScriptDependencyScanner {
|
|
|
89
91
|
};
|
|
90
92
|
}
|
|
91
93
|
async#hasWorkspacePackage(dep) {
|
|
92
|
-
const packageJsonPath = path.join(this
|
|
94
|
+
const packageJsonPath = path.join(this.#workspaceRoot, "pkgs", dep, "package.json");
|
|
93
95
|
if (!await Bun.file(packageJsonPath).exists())
|
|
94
96
|
return false;
|
|
95
97
|
try {
|
|
@@ -132,9 +134,9 @@ class TypeScriptDependencyScanner {
|
|
|
132
134
|
this.#fileRuntimeDependencies.clear();
|
|
133
135
|
this.#fileTypeDependencies.clear();
|
|
134
136
|
this.#visitedFiles.clear();
|
|
135
|
-
const files = await this.#findTypeScriptFiles(this
|
|
137
|
+
const files = await this.#findTypeScriptFiles(this.#directory);
|
|
136
138
|
for (const file of files)
|
|
137
|
-
await this.#analyzeFile(file, this
|
|
139
|
+
await this.#analyzeFile(file, this.#directory);
|
|
138
140
|
return this.#fileDependencies;
|
|
139
141
|
}
|
|
140
142
|
async#findTypeScriptFiles(directory, {
|
|
@@ -142,18 +144,17 @@ class TypeScriptDependencyScanner {
|
|
|
142
144
|
excludeTestFiles = false
|
|
143
145
|
} = {}) {
|
|
144
146
|
const files = [];
|
|
145
|
-
const skipDirs = ["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"];
|
|
146
147
|
const glob = new Bun.Glob("**/*.{ts,tsx}");
|
|
147
148
|
for await (const filePath of glob.scan({ cwd: directory, onlyFiles: true })) {
|
|
148
|
-
if (
|
|
149
|
+
if (isSkippedPath(filePath))
|
|
149
150
|
continue;
|
|
150
151
|
if (excludeBuildFiles && filePath === "build.ts")
|
|
151
152
|
continue;
|
|
152
153
|
if (excludeTestFiles && testFileRegex.test(filePath))
|
|
153
154
|
continue;
|
|
154
155
|
const fullPath = path.join(directory, filePath);
|
|
155
|
-
const relativePath = path.relative(this
|
|
156
|
-
if (this
|
|
156
|
+
const relativePath = path.relative(this.#workspaceRoot, fullPath);
|
|
157
|
+
if (this.#ig.ignores(relativePath))
|
|
157
158
|
continue;
|
|
158
159
|
files.push(fullPath);
|
|
159
160
|
}
|
|
@@ -161,14 +162,13 @@ class TypeScriptDependencyScanner {
|
|
|
161
162
|
}
|
|
162
163
|
async#findCssFiles(directory) {
|
|
163
164
|
const files = [];
|
|
164
|
-
const skipDirs = ["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"];
|
|
165
165
|
const glob = new Bun.Glob("**/*.css");
|
|
166
166
|
for await (const filePath of glob.scan({ cwd: directory, onlyFiles: true })) {
|
|
167
|
-
if (
|
|
167
|
+
if (isSkippedPath(filePath))
|
|
168
168
|
continue;
|
|
169
169
|
const fullPath = path.join(directory, filePath);
|
|
170
|
-
const relativePath = path.relative(this
|
|
171
|
-
if (this
|
|
170
|
+
const relativePath = path.relative(this.#workspaceRoot, fullPath);
|
|
171
|
+
if (this.#ig.ignores(relativePath))
|
|
172
172
|
continue;
|
|
173
173
|
files.push(fullPath);
|
|
174
174
|
}
|
|
@@ -720,6 +720,53 @@ import { spawn } from "child_process";
|
|
|
720
720
|
import { existsSync, readFileSync } from "fs";
|
|
721
721
|
import path2 from "path";
|
|
722
722
|
import chalk from "chalk";
|
|
723
|
+
var parseBiomeReport = (output) => {
|
|
724
|
+
for (let start = output.indexOf("{");start !== -1; start = output.indexOf("{", start + 1)) {
|
|
725
|
+
const end = objectEndAt(output, start);
|
|
726
|
+
if (end === -1)
|
|
727
|
+
break;
|
|
728
|
+
const report = asBiomeReport(output.slice(start, end + 1));
|
|
729
|
+
if (report)
|
|
730
|
+
return report;
|
|
731
|
+
}
|
|
732
|
+
throw new Error(output.trim() || "No Biome JSON output");
|
|
733
|
+
};
|
|
734
|
+
var objectEndAt = (output, start) => {
|
|
735
|
+
let depth = 0;
|
|
736
|
+
let inString = false;
|
|
737
|
+
let escaped = false;
|
|
738
|
+
for (let idx = start;idx < output.length; idx += 1) {
|
|
739
|
+
const char = output[idx];
|
|
740
|
+
if (inString) {
|
|
741
|
+
if (escaped)
|
|
742
|
+
escaped = false;
|
|
743
|
+
else if (char === "\\")
|
|
744
|
+
escaped = true;
|
|
745
|
+
else if (char === '"')
|
|
746
|
+
inString = false;
|
|
747
|
+
continue;
|
|
748
|
+
}
|
|
749
|
+
if (char === '"')
|
|
750
|
+
inString = true;
|
|
751
|
+
else if (char === "{")
|
|
752
|
+
depth += 1;
|
|
753
|
+
else if (char === "}" && --depth === 0)
|
|
754
|
+
return idx;
|
|
755
|
+
}
|
|
756
|
+
return -1;
|
|
757
|
+
};
|
|
758
|
+
var asBiomeReport = (candidate) => {
|
|
759
|
+
try {
|
|
760
|
+
const parsed = JSON.parse(candidate);
|
|
761
|
+
if (!parsed || typeof parsed !== "object")
|
|
762
|
+
return null;
|
|
763
|
+
if (!("diagnostics" in parsed) && !("summary" in parsed))
|
|
764
|
+
return null;
|
|
765
|
+
return parsed;
|
|
766
|
+
} catch {
|
|
767
|
+
return null;
|
|
768
|
+
}
|
|
769
|
+
};
|
|
723
770
|
var BIOME_CONFIG_FILES = ["biome.json", "biome.jsonc"];
|
|
724
771
|
|
|
725
772
|
class Linter {
|
|
@@ -776,13 +823,6 @@ class Linter {
|
|
|
776
823
|
proc.stdin.end(input);
|
|
777
824
|
});
|
|
778
825
|
}
|
|
779
|
-
#parseBiomeReport(output) {
|
|
780
|
-
const jsonStart = output.indexOf("{");
|
|
781
|
-
const jsonEnd = output.lastIndexOf("}");
|
|
782
|
-
if (jsonStart === -1 || jsonEnd === -1 || jsonEnd < jsonStart)
|
|
783
|
-
throw new Error(output.trim() || "No Biome JSON output");
|
|
784
|
-
return JSON.parse(output.slice(jsonStart, jsonEnd + 1));
|
|
785
|
-
}
|
|
786
826
|
#diagnosticFilePath(diagnostic, fallbackFilePath) {
|
|
787
827
|
const diagnosticPath = diagnostic.location?.path;
|
|
788
828
|
if (!diagnosticPath)
|
|
@@ -855,7 +895,7 @@ class Linter {
|
|
|
855
895
|
this.configPath,
|
|
856
896
|
this.#toBiomePath(filePath)
|
|
857
897
|
]);
|
|
858
|
-
const report =
|
|
898
|
+
const report = parseBiomeReport(stdout || stderr);
|
|
859
899
|
const results = this.#toLintResults(report, filePath);
|
|
860
900
|
const { errors, warnings } = this.#splitMessages(results);
|
|
861
901
|
const output = write && existsSync(filePath) ? readFileSync(filePath, "utf8") : undefined;
|
|
@@ -977,6 +1017,25 @@ ${errorText}, ${warningText} found`];
|
|
|
977
1017
|
const lintResult = await this.lintFile(resolvedFilePath);
|
|
978
1018
|
return { ...lintResult, fixed: stdout !== source, output: stdout };
|
|
979
1019
|
}
|
|
1020
|
+
async fixFiles(filePaths) {
|
|
1021
|
+
const resolved = filePaths.map((filePath) => this.#resolveFilePath(filePath)).filter(existsSync);
|
|
1022
|
+
if (resolved.length === 0)
|
|
1023
|
+
return { fixed: [] };
|
|
1024
|
+
const before = new Map(resolved.map((filePath) => [filePath, readFileSync(filePath, "utf8")]));
|
|
1025
|
+
await this.#runBiome([
|
|
1026
|
+
"check",
|
|
1027
|
+
"--write",
|
|
1028
|
+
"--reporter=json",
|
|
1029
|
+
"--max-diagnostics=none",
|
|
1030
|
+
"--no-errors-on-unmatched",
|
|
1031
|
+
"--config-path",
|
|
1032
|
+
this.configPath,
|
|
1033
|
+
...resolved.map((filePath) => this.#toBiomePath(filePath))
|
|
1034
|
+
]);
|
|
1035
|
+
return {
|
|
1036
|
+
fixed: resolved.filter((filePath) => readFileSync(filePath, "utf8") !== before.get(filePath))
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
980
1039
|
async getConfigForFile(filePath) {
|
|
981
1040
|
const resolvedFilePath = this.#resolveFilePath(filePath);
|
|
982
1041
|
if (!existsSync(resolvedFilePath))
|
|
@@ -1127,7 +1186,7 @@ var moduleUiFileTypes = {
|
|
|
1127
1186
|
scalar: new Set(["Template", "Unit"])
|
|
1128
1187
|
};
|
|
1129
1188
|
var testFilePattern = /\.(test|spec)\.(ts|tsx)$/;
|
|
1130
|
-
var createDependencyScanner = async (exec) => (await import("./dependencyScanner-
|
|
1189
|
+
var createDependencyScanner = async (exec) => (await import("./dependencyScanner-aqg3dkks.js")).TypeScriptDependencyScanner.from(exec);
|
|
1131
1190
|
var isAllowedTestFile = (filename) => testFilePattern.test(filename);
|
|
1132
1191
|
var getScanPath = (exec, relativePath) => path4.posix.join(`${exec.type}s`, exec.name, relativePath.split(path4.sep).join("/"));
|
|
1133
1192
|
async function clearGeneratedRootCapacitorConfigs(exec) {
|
|
@@ -1544,7 +1603,7 @@ class LibInfo extends ScanInfo {
|
|
|
1544
1603
|
class PkgInfo {
|
|
1545
1604
|
exec;
|
|
1546
1605
|
name;
|
|
1547
|
-
scanResult;
|
|
1606
|
+
#scanResult;
|
|
1548
1607
|
static async scanExecutor(exec) {
|
|
1549
1608
|
const [tsconfig, rootPackageJson] = await Promise.all([exec.getTsConfig(), exec.workspace.getPackageJson()]);
|
|
1550
1609
|
const scanner = await createDependencyScanner(exec);
|
|
@@ -1575,10 +1634,10 @@ class PkgInfo {
|
|
|
1575
1634
|
constructor(exec, scanResult) {
|
|
1576
1635
|
this.exec = exec;
|
|
1577
1636
|
this.name = exec.name;
|
|
1578
|
-
this
|
|
1637
|
+
this.#scanResult = scanResult;
|
|
1579
1638
|
}
|
|
1580
1639
|
getScanResult() {
|
|
1581
|
-
return this
|
|
1640
|
+
return this.#scanResult;
|
|
1582
1641
|
}
|
|
1583
1642
|
}
|
|
1584
1643
|
|
|
@@ -2168,10 +2227,24 @@ class Executor {
|
|
|
2168
2227
|
...options.dict ?? {},
|
|
2169
2228
|
...Object.fromEntries(Object.entries(options.dict ?? {}).map(([key, value]) => [capitalize(key), capitalize(value)]))
|
|
2170
2229
|
};
|
|
2171
|
-
|
|
2230
|
+
const fileContents = await this._applyTemplate({ ...options, dict });
|
|
2231
|
+
await this.#formatAppliedTemplate(fileContents);
|
|
2232
|
+
return fileContents;
|
|
2233
|
+
}
|
|
2234
|
+
async#formatAppliedTemplate(fileContents) {
|
|
2235
|
+
const filePaths = fileContents.map((fileContent) => fileContent.filePath).filter((filePath) => filePath.endsWith(".ts") || filePath.endsWith(".tsx"));
|
|
2236
|
+
if (filePaths.length === 0)
|
|
2237
|
+
return;
|
|
2238
|
+
try {
|
|
2239
|
+
const { fixed } = await this.getLinter().fixFiles(filePaths);
|
|
2240
|
+
if (fixed.length > 0)
|
|
2241
|
+
this.logger.verbose(`Formatted ${fixed.length} scaffolded file(s)`);
|
|
2242
|
+
} catch (err) {
|
|
2243
|
+
this.logger.verbose(`Skipped formatting scaffolded files: ${err instanceof Error ? err.message : String(err)}`);
|
|
2244
|
+
}
|
|
2172
2245
|
}
|
|
2173
2246
|
async getTypeChecker() {
|
|
2174
|
-
const { TypeChecker } = await import("./typeChecker-
|
|
2247
|
+
const { TypeChecker } = await import("./typeChecker-yhs4eht8.js");
|
|
2175
2248
|
this.typeChecker ??= new TypeChecker(this);
|
|
2176
2249
|
return this.typeChecker;
|
|
2177
2250
|
}
|
|
@@ -2357,10 +2430,10 @@ class WorkspaceExecutor extends Executor {
|
|
|
2357
2430
|
}
|
|
2358
2431
|
async commit(message, { init = false, add = true } = {}) {
|
|
2359
2432
|
if (init)
|
|
2360
|
-
await this.
|
|
2433
|
+
await this.spawn("git", ["init", "--quiet"]);
|
|
2361
2434
|
if (add)
|
|
2362
|
-
await this.
|
|
2363
|
-
await this.
|
|
2435
|
+
await this.spawn("git", ["add", "."]);
|
|
2436
|
+
await this.spawn("git", ["commit", "--quiet", "-m", message]);
|
|
2364
2437
|
}
|
|
2365
2438
|
async#getDirHasFile(basePath, targetFilename) {
|
|
2366
2439
|
const AVOID_DIRS = ["node_modules", "dist", "public", "webkit"];
|
|
@@ -2699,8 +2772,7 @@ class AppExecutor extends SysExecutor {
|
|
|
2699
2772
|
if (type === "build") {
|
|
2700
2773
|
this.#excludeDevOnlyPages = true;
|
|
2701
2774
|
this.#pageKeys = null;
|
|
2702
|
-
|
|
2703
|
-
await this.dist.exec(`rm -rf ${this.dist.cwdPath}`);
|
|
2775
|
+
await this.dist.removeDir(this.dist.cwdPath);
|
|
2704
2776
|
await Promise.all([this.dist.mkdir("private"), this.dist.mkdir("public")]);
|
|
2705
2777
|
await Promise.all([
|
|
2706
2778
|
this.cp("private", `${this.dist.cwdPath}/private`, { dereference: true }),
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
runner,
|
|
4
4
|
script
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-akz5xvyw.js";
|
|
6
6
|
import {
|
|
7
7
|
LibExecutor
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-h9cybjep.js";
|
|
9
9
|
|
|
10
10
|
// pkgs/@akanjs/cli/semver.ts
|
|
11
11
|
var stripRangeOperator = (version) => version.replace(/^[\s^~>=<v]+/, "").trim();
|
|
@@ -34,13 +34,13 @@ var compareSemver = (a, b) => {
|
|
|
34
34
|
// pkgs/@akanjs/cli/library/library.runner.ts
|
|
35
35
|
class LibraryRunner extends runner("library") {
|
|
36
36
|
async createLibrary(libName, workspace) {
|
|
37
|
-
await workspace.
|
|
37
|
+
await workspace.mkdir(`libs/${libName}`);
|
|
38
38
|
await workspace.applyTemplate({ basePath: `libs/${libName}`, template: "libRoot", dict: { libName } });
|
|
39
39
|
const lib = LibExecutor.from(workspace, libName);
|
|
40
40
|
return lib;
|
|
41
41
|
}
|
|
42
42
|
async removeLibrary(lib) {
|
|
43
|
-
await lib.workspace.
|
|
43
|
+
await lib.workspace.removeDir(`libs/${lib.name}`);
|
|
44
44
|
}
|
|
45
45
|
async#copyInstalledLibrary(workspace, libName) {
|
|
46
46
|
const installedPackageJson = `node_modules/akanjs/libs/${libName}/package.json`;
|
|
@@ -88,7 +88,6 @@ class LibraryRunner extends runner("library") {
|
|
|
88
88
|
await lib.workspace.spawn("bun", ["install"]);
|
|
89
89
|
await lib.workspace.commit(`Merge ${lib.name} library dependencies`);
|
|
90
90
|
}
|
|
91
|
-
async testLibrary(lib) {}
|
|
92
91
|
}
|
|
93
92
|
|
|
94
93
|
// pkgs/@akanjs/cli/library/library.script.ts
|
|
@@ -118,11 +117,6 @@ class LibraryScript extends script("library", [LibraryRunner]) {
|
|
|
118
117
|
await this.libraryRunner.mergeLibraryDependencies(lib);
|
|
119
118
|
mergeSpinner.succeed(`${libName} library (libs/${libName}) dependencies merged to root package.json`);
|
|
120
119
|
}
|
|
121
|
-
async testLibrary(lib) {
|
|
122
|
-
const spinner = lib.spinning("Testing library...");
|
|
123
|
-
await this.libraryRunner.testLibrary(lib);
|
|
124
|
-
spinner.succeed(`Library ${lib.name} (libs/${lib.name}) test is successful`);
|
|
125
|
-
}
|
|
126
120
|
}
|
|
127
121
|
|
|
128
122
|
export { LibraryScript };
|
|
@@ -349,7 +349,7 @@ var resolveNodePackageExport = async (workspaceRoot, specifier) => {
|
|
|
349
349
|
const subpath = specifier === packageName ? "." : `.${specifier.slice(packageName.length)}`;
|
|
350
350
|
const exported = resolvePackageExport(pkgJson.exports, subpath);
|
|
351
351
|
const rel = exported ?? (subpath === "." ? pkgJson.module ?? pkgJson.main ?? "index.js" : null);
|
|
352
|
-
if (!rel
|
|
352
|
+
if (!rel?.startsWith("."))
|
|
353
353
|
return null;
|
|
354
354
|
const entryFile = await resolveFileCandidate(path2.resolve(pkgDir, rel));
|
|
355
355
|
if (!entryFile)
|
|
@@ -1518,6 +1518,8 @@ class AutoImportSync {
|
|
|
1518
1518
|
const [scope, project, facet] = parts;
|
|
1519
1519
|
if (scope !== "apps" && scope !== "libs" || !project || !facet)
|
|
1520
1520
|
return null;
|
|
1521
|
+
if (facet === "lib" && parts[3] === "__lib")
|
|
1522
|
+
return null;
|
|
1521
1523
|
const role = roleFor(facet, base);
|
|
1522
1524
|
if (!role)
|
|
1523
1525
|
return null;
|
|
@@ -19,7 +19,6 @@ class Prompter {
|
|
|
19
19
|
return candidates[0];
|
|
20
20
|
}
|
|
21
21
|
static async selectGuideline() {
|
|
22
|
-
const guidelineRoot = await Prompter.#getGuidelineRoot();
|
|
23
22
|
const guideNames = await Prompter.listGuidelines();
|
|
24
23
|
return await select({
|
|
25
24
|
message: "Select a guideline",
|
|
@@ -37,10 +36,11 @@ class Prompter {
|
|
|
37
36
|
return JSON.parse(guideJson);
|
|
38
37
|
}
|
|
39
38
|
static async getInstruction(guideName) {
|
|
39
|
+
const guideNames = await Prompter.listGuidelines();
|
|
40
|
+
if (!guideNames.includes(guideName))
|
|
41
|
+
throw new Error(`Unknown guideline "${guideName}". Available: ${guideNames.join(", ")}`);
|
|
40
42
|
const guidelineRoot = await Prompter.#getGuidelineRoot();
|
|
41
|
-
|
|
42
|
-
const content = await fsPromise.readFile(filePath, "utf-8");
|
|
43
|
-
return content;
|
|
43
|
+
return await fsPromise.readFile(`${guidelineRoot}/${guideName}/${guideName}.instruction.md`, "utf-8");
|
|
44
44
|
}
|
|
45
45
|
static async getUpdateRequest(guideName) {
|
|
46
46
|
return await input({
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
AkanContextAnalyzer
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-bmz9crym.js";
|
|
5
5
|
import {
|
|
6
6
|
createRepairReport,
|
|
7
7
|
generatedFilePathsForTarget,
|
|
8
8
|
renderRepairReport,
|
|
9
9
|
writeGeneratedSyncState,
|
|
10
10
|
writeWorkflowRunArtifact
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-q0s2dp3y.js";
|
|
12
12
|
import {
|
|
13
13
|
runner
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-akz5xvyw.js";
|
|
15
15
|
|
|
16
16
|
// pkgs/@akanjs/cli/repair/repair.runner.ts
|
|
17
17
|
var commandForShell = (command) => command.startsWith("akan ") ? `bun run ${command}` : command;
|