@akanjs/cli 3.0.0-beta.2 → 3.0.0-beta.21
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-q2m47rqp.js +9 -0
- package/CodeAgentRpcHost-p7h6n2hp.js +7 -0
- package/CodeAgentRpcListener-7p7z5dd7.js +97 -0
- package/CodeTui-pdqhc3sn.js +1457 -0
- package/README.md +3 -0
- package/TunnelShare-scf4e4pd.js +9 -0
- package/{agent.command-d2gfxfck.js → agent.command-ttn09rx3.js} +8 -9
- package/akanCode.js +102 -0
- package/application.command-7gweenv7.js +179 -0
- package/{applicationBuildRunner-kxwbssgn.js → applicationBuildRunner-38exmejd.js} +63 -64
- package/buildBatch.proc.js +26 -25
- package/cloud.command-bhztw7c2.js +95 -0
- package/cloud.script-aabyhgba.js +20 -0
- package/code.command-6s8c0k91.js +154 -0
- package/commandManifest.json +1 -1
- package/consoleToStderr-h5bryj94.js +7 -0
- package/context.command-phmgywt2.js +48 -0
- package/context.runner-yvyw5g2d.js +21 -0
- package/{dependencyScanner-shs82ynp.js → dependencyScanner-ye2e6pdz.js} +2 -2
- package/{devTui-40ggmd99.js → devTui-q7k7bakd.js} +122 -40
- package/fileSys-5ngz93ga.js +9 -0
- package/guideline.command-7jk47fgq.js +42 -0
- package/guidelines/agentRule/agentRule.instruction.md +209 -28
- package/guidelines/conventions/conventions.instruction.md +96 -29
- package/guidelines/fieldRule/fieldRule.instruction.md +1 -0
- package/guidelines/mcpRule/mcpRule.instruction.md +7 -5
- package/guidelines/queryRule/queryRule.instruction.md +17 -7
- package/guidelines/runtimeRule/runtimeRule.instruction.md +77 -3
- package/guidelines/ssrRule/ssrRule.instruction.md +4 -2
- package/guidelines/transportRule/transportRule.instruction.md +51 -0
- package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +66 -3
- package/incrementalBuilder.proc.js +31 -48
- package/{index-h7yw2z9n.js → index-0bq14vr1.js} +8 -14
- package/{index-259dsnz3.js → index-1db2cw0y.js} +5 -8
- package/index-22d57v4c.js +266 -0
- package/index-3hx1z96c.js +87 -0
- package/{index-kcxmv48c.js → index-3t7g9e4r.js} +45 -79
- package/{index-ne2qy0nk.js → index-4dn1p115.js} +12 -12
- package/{index-q0y2jq9j.js → index-5b6tavv3.js} +6 -3
- package/index-7cqjvraf.js +69 -0
- package/index-7md2g9vw.js +6 -0
- package/{index-zry5nz81.js → index-8kb5p54p.js} +51 -30
- package/{index-ktb5njgy.js → index-9629w7ns.js} +49 -99
- package/index-9dp031by.js +12 -0
- package/{index-a64esmtb.js → index-aadpbnt2.js} +172 -308
- package/{index-3d9y066c.js → index-bjwxs904.js} +9 -8
- package/index-c6eggbee.js +123 -0
- package/index-d0arnrm8.js +700 -0
- package/index-d2242ksy.js +99 -0
- package/{index-600zhnve.js → index-dg97qp24.js} +70 -200
- package/{index-92zztqy1.js → index-dy0jx9ay.js} +2 -17
- package/{index-w8kmx1b6.js → index-fgq75haa.js} +198 -290
- package/{index-2tv3fdx4.js → index-ga6hygxr.js} +944 -1333
- package/{index-by5gpp8x.js → index-hj6w4ka1.js} +2 -1
- package/index-hr5n7t4x.js +465 -0
- package/{index-hwkygn9s.js → index-khpfpcsd.js} +302 -33
- package/{index-7737gxcp.js → index-m0ms3n1c.js} +107 -241
- package/{index-ws5e0j51.js → index-mgfx3mfs.js} +43 -26
- package/index-p6pbz9n5.js +25 -0
- package/index-pp54p5zk.js +53 -0
- package/{index-j9yhg404.js → index-q44jbw48.js} +4 -7
- package/{index-mak3cd28.js → index-rmcw8yc8.js} +137 -255
- package/{index-pnqbkf5p.js → index-rnt66vym.js} +6 -2
- package/index-smme4r47.js +49 -0
- package/index-tgjy8xf3.js +187 -0
- package/index-v5eayqqw.js +2729 -0
- package/index-wa5jbxj1.js +760 -0
- package/{index-4edzf1gr.js → index-wp43xrjv.js} +77 -150
- package/{index-fz5q3gd7.js → index-ya5qbmyg.js} +10 -17
- package/index-yjkte9aj.js +1119 -0
- package/{index-gyd220p2.js → index-yy4s1j72.js} +554 -577
- package/{index-v0qh106m.js → index-z50k041j.js} +580 -862
- package/index.js +23 -22
- package/{library.command-nbsky672.js → library.command-ccb1cp92.js} +4 -5
- package/{localRegistry.command-yeq57wjr.js → localRegistry.command-ajb9n87j.js} +23 -42
- package/{module.command-29vqzrh8.js → module.command-5k6h407d.js} +8 -11
- package/{package.command-axv0abmn.js → package.command-e6ntvpez.js} +6 -7
- package/package.json +14 -6
- package/{page.command-vs9s3zrh.js → page.command-v4f90wb8.js} +4 -5
- package/{primitive.command-cbxmqbtc.js → primitive.command-g6km57q5.js} +9 -22
- package/prompter-ptaa3nk0.js +8 -0
- package/{quality.command-gmbs7nws.js → quality.command-de3p36pz.js} +205 -377
- package/{recipeScanner-fpagtgc1.js → recipeScanner-4b69ybe0.js} +1 -1
- package/{repair.command-bqsjptsj.js → repair.command-d3x1javq.js} +11 -35
- package/{routeSourceValidator-apyqw7wk.js → routeSourceValidator-7ycnfz0e.js} +0 -6
- package/{scalar.command-6k1vhe9s.js → scalar.command-7ezrac2b.js} +7 -10
- package/skills/akan-code/SKILL.md +130 -0
- package/skills/akan-debug/SKILL.md +42 -0
- package/skills/akan-deps/SKILL.md +50 -0
- package/skills/akan-err/SKILL.md +39 -0
- package/skills/akan-module/SKILL.md +45 -0
- package/skills/akan-scaffold/SKILL.md +76 -0
- package/skills/akan-scalar/SKILL.md +52 -0
- package/skills/akan-service/SKILL.md +34 -0
- package/skills/akan-store/SKILL.md +67 -0
- package/skills/akan-ui/SKILL.md +63 -0
- package/skills/akan-validate/SKILL.md +44 -0
- package/{subspace.command-fwjfcts7.js → subspace.command-ps71ynp6.js} +138 -67
- package/templates/__scalar/__model__/__model__.abstract.md.template +8 -0
- package/templates/appSample/lib/__scalar/workHistory/workHistory.abstract.ts +8 -39
- package/templates/appSample/lib/_noti/noti.abstract.ts +6 -29
- package/templates/appSample/lib/task/task.abstract.ts +12 -32
- package/templates/appSample/lib/task/task.signal.spec.ts +15 -18
- package/templates/appSample/lib/task/task.signal.test.ts +15 -1
- package/templates/appSample/lib/task/task.signal.ts +1 -1
- package/templates/appSample/srvkit/{AuthGuard.ts → guards.ts} +7 -4
- package/templates/appSample/srvkit/{SessionInternalArg.ts → internalArgs.ts} +6 -4
- package/templates/client.ts +7 -30
- package/templates/crudPages/[__model__Id]/edit/page.tsx +2 -1
- package/templates/crudPages/[__model__Id]/page.tsx +2 -1
- package/templates/crudPages/new/page.tsx +2 -1
- package/templates/crudPages/page.tsx +2 -1
- package/templates/crudSinglePage/page.tsx +2 -1
- package/templates/lib/__lib/lib.dictionary.ts +0 -2
- package/templates/lib/__lib/lib.document.ts +0 -2
- package/templates/lib/sig.ts +8 -30
- package/templates/localDev/docker-compose.yaml.template +3 -14
- package/templates/module/__model__.signal.ts +12 -4
- package/templates/pkgRoot/tsconfig.json.template +2 -7
- package/templates/server.ts +0 -2
- package/templates/service/__model__.abstract.md.template +8 -0
- package/templates/workspaceRoot/.gitignore.template +0 -1
- package/tunnel.command-hsrv2mny.js +129 -0
- package/{typeChecker-3xgrzc2v.js → typeChecker-px49mezc.js} +1 -1
- package/typecheck.proc.js +1 -1
- package/workflow.command-z2p32nmf.js +79 -0
- package/{workspace.command-8s050m0h.js → workspace.command-tmdqkrh0.js} +77 -109
- package/abstractCompactor-mjh5ppsq.js +0 -101
- package/application.command-pj2m7584.js +0 -204
- package/applicationReleasePackager-4yasxwv9.js +0 -244
- package/capacitorApp-36rbr858.js +0 -12
- package/cloud.command-jshwdq22.js +0 -93
- package/context.command-ez8a0zyz.js +0 -80
- package/devTuiView-c08ccbat.js +0 -9
- package/getDirname-dr3jz1xg.js +0 -7
- package/guideline.command-xmqwx8zm.js +0 -359
- package/guidelines/agentRule/agentRule.generate.json +0 -31
- package/guidelines/componentRule/componentRule.generate.json +0 -31
- package/guidelines/conventions/conventions.generate.json +0 -25
- package/guidelines/cssRule/cssRule.generate.json +0 -31
- package/guidelines/docPageRule/docPageRule.generate.json +0 -31
- package/guidelines/docPageRule/docPageRule.instruction.md +0 -25
- package/guidelines/docSyncRule/docSyncRule.generate.json +0 -31
- package/guidelines/docSyncRule/docSyncRule.instruction.md +0 -25
- package/guidelines/enumConstant/enumConstant.generate.json +0 -31
- package/guidelines/enumConstant/enumConstant.instruction.md +0 -28
- package/guidelines/fieldRule/fieldRule.generate.json +0 -31
- package/guidelines/framework/framework.generate.json +0 -32
- package/guidelines/mcpRule/mcpRule.generate.json +0 -35
- package/guidelines/modelConstant/modelConstant.generate.json +0 -32
- package/guidelines/modelDictionary/modelDictionary.generate.json +0 -32
- package/guidelines/modelDocument/modelDocument.generate.json +0 -31
- package/guidelines/modelService/modelService.generate.json +0 -31
- package/guidelines/modelSignal/modelSignal.generate.json +0 -31
- package/guidelines/modelStore/modelStore.generate.json +0 -31
- package/guidelines/modelTemplate/modelTemplate.generate.json +0 -31
- package/guidelines/modelUnit/modelUnit.generate.json +0 -31
- package/guidelines/modelUtil/modelUtil.generate.json +0 -31
- package/guidelines/modelView/modelView.generate.json +0 -31
- package/guidelines/modelZone/modelZone.generate.json +0 -31
- package/guidelines/moduleCodegen/moduleCodegen.generate.json +0 -31
- package/guidelines/moduleCodegen/moduleCodegen.instruction.md +0 -28
- package/guidelines/moduleOverview/moduleOverview.generate.json +0 -31
- package/guidelines/queryRule/queryRule.generate.json +0 -31
- package/guidelines/recipeRule/recipeRule.generate.json +0 -31
- package/guidelines/runtimeRule/runtimeRule.generate.json +0 -25
- package/guidelines/scalarConstant/scalarConstant.generate.json +0 -32
- package/guidelines/scalarDictionary/scalarDictionary.generate.json +0 -32
- package/guidelines/scalarModule/scalarModule.generate.json +0 -31
- package/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -31
- package/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -25
- package/guidelines/ssrRule/ssrRule.generate.json +0 -31
- package/guidelines/transportRule/transportRule.generate.json +0 -31
- package/guidelines/utilUiUsage/utilUiUsage.generate.json +0 -31
- package/guidelines/utilUiUsage/utilUiUsage.instruction.md +0 -25
- package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +0 -24
- package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +0 -33
- package/index-2hq52jq3.js +0 -465
- package/index-47pj3aee.js +0 -76
- package/index-6wwzs1bc.js +0 -7
- package/index-8pm30m73.js +0 -841
- package/index-kn1h7p1x.js +0 -560
- package/index-meh558jy.js +0 -65
- package/index-rwg2aa4f.js +0 -229
- package/index-wt7qrtd4.js +0 -1516
- package/templates/__scalar/__model__/__model__.abstract.md +0 -28
- package/templates/module/__model__.abstract.md +0 -28
- package/templates/service/__model__.abstract.md +0 -28
- package/workflow.command-nwpcdc8p.js +0 -107
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// pkgs/@akanjs/devkit/codeAgent/agent/CodeAgentRpcHost.ts
|
|
3
|
+
class CodeAgentRpcHost2 {
|
|
4
|
+
#agent;
|
|
5
|
+
#write;
|
|
6
|
+
#buffer = "";
|
|
7
|
+
#started = false;
|
|
8
|
+
#resolveShutdown = () => {};
|
|
9
|
+
shutdown = new Promise((resolve) => {
|
|
10
|
+
this.#resolveShutdown = resolve;
|
|
11
|
+
});
|
|
12
|
+
constructor(agent, write = (line) => process.stdout.write(line)) {
|
|
13
|
+
this.#agent = agent;
|
|
14
|
+
this.#write = write;
|
|
15
|
+
}
|
|
16
|
+
async serve(input = process.stdin) {
|
|
17
|
+
this.start();
|
|
18
|
+
const decoder = new TextDecoder;
|
|
19
|
+
for await (const chunk of input)
|
|
20
|
+
await this.feed(decoder.decode(chunk, { stream: true }));
|
|
21
|
+
await this.#agent.abort().catch(() => {});
|
|
22
|
+
}
|
|
23
|
+
start() {
|
|
24
|
+
if (this.#started)
|
|
25
|
+
return;
|
|
26
|
+
this.#started = true;
|
|
27
|
+
this.#agent.on((event) => this.#emit(event));
|
|
28
|
+
this.#agent.announce();
|
|
29
|
+
}
|
|
30
|
+
attach(write) {
|
|
31
|
+
this.#write = write;
|
|
32
|
+
this.#buffer = "";
|
|
33
|
+
}
|
|
34
|
+
async feed(text) {
|
|
35
|
+
this.#buffer += text;
|
|
36
|
+
let index = this.#buffer.indexOf(`
|
|
37
|
+
`);
|
|
38
|
+
while (index >= 0) {
|
|
39
|
+
const line = this.#buffer.slice(0, index).trim();
|
|
40
|
+
this.#buffer = this.#buffer.slice(index + 1);
|
|
41
|
+
if (line)
|
|
42
|
+
await this.#handle(line);
|
|
43
|
+
index = this.#buffer.indexOf(`
|
|
44
|
+
`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async#handle(line) {
|
|
48
|
+
let request;
|
|
49
|
+
try {
|
|
50
|
+
request = JSON.parse(line);
|
|
51
|
+
} catch {
|
|
52
|
+
return this.#emit({ type: "error", message: "malformed command frame", fatal: false, seq: -1 });
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
this.#reply({ type: "reply", id: request.id, ok: true, data: await this.#run(request.command) });
|
|
56
|
+
} catch (error) {
|
|
57
|
+
this.#reply({ type: "reply", id: request.id, ok: false, error: String(error) });
|
|
58
|
+
}
|
|
59
|
+
if (request.command?.type === "shutdown")
|
|
60
|
+
this.#resolveShutdown();
|
|
61
|
+
}
|
|
62
|
+
async#run(command) {
|
|
63
|
+
switch (command.type) {
|
|
64
|
+
case "prompt":
|
|
65
|
+
this.#agent.prompt(command.message, command.images);
|
|
66
|
+
return { accepted: true };
|
|
67
|
+
case "answer":
|
|
68
|
+
return { handled: await this.#agent.answer(command.questionId, command.answer) };
|
|
69
|
+
case "approve":
|
|
70
|
+
return { handled: await this.#agent.approve(command.approvalId, command.approved) };
|
|
71
|
+
case "abort":
|
|
72
|
+
await this.#agent.abort();
|
|
73
|
+
return { aborted: true };
|
|
74
|
+
case "compact":
|
|
75
|
+
await this.#agent.compact(command.instructions);
|
|
76
|
+
return { compacted: true };
|
|
77
|
+
case "set_model":
|
|
78
|
+
await this.#agent.setModel({ provider: command.provider, id: command.modelId });
|
|
79
|
+
return await this.#agent.state();
|
|
80
|
+
case "get_state":
|
|
81
|
+
return await this.#agent.state(command.sinceSeq === undefined ? {} : { sinceSeq: command.sinceSeq });
|
|
82
|
+
case "shutdown":
|
|
83
|
+
this.#agent.dispose();
|
|
84
|
+
return { shutdown: true };
|
|
85
|
+
default:
|
|
86
|
+
throw new Error(`Unsupported command: ${command.type}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
#emit(event) {
|
|
90
|
+
this.#write?.(`${JSON.stringify({ type: "event", event })}
|
|
91
|
+
`);
|
|
92
|
+
}
|
|
93
|
+
#reply(reply) {
|
|
94
|
+
this.#write?.(`${JSON.stringify(reply)}
|
|
95
|
+
`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { CodeAgentRpcHost2 };
|
|
@@ -1,60 +1,44 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
AppExecutor
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-ga6hygxr.js";
|
|
5
5
|
import {
|
|
6
6
|
jsonText,
|
|
7
7
|
createWorkflowBaselineSummary,
|
|
8
8
|
buildAkanModuleContextIndex,
|
|
9
|
-
createWorkflowStepRegistry,
|
|
10
9
|
toolingRolloutGate
|
|
11
|
-
} from "./index-
|
|
10
|
+
} from "./index-yy4s1j72.js";
|
|
12
11
|
import {
|
|
13
12
|
buildResourceList,
|
|
14
13
|
codexMcpConfigPath,
|
|
15
|
-
akanMcpInstallTargets,
|
|
16
14
|
akanMcpInstallConfigPaths,
|
|
17
15
|
createAkanMcpServer,
|
|
18
16
|
createAkanCodexMcpServerBlock,
|
|
19
17
|
upsertCodexMcpServerBlock,
|
|
20
18
|
renderDoctorText,
|
|
21
19
|
AkanContextAnalyzer
|
|
22
|
-
} from "./index-
|
|
20
|
+
} from "./index-9629w7ns.js";
|
|
23
21
|
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
script
|
|
27
|
-
} from "./index-mak3cd28.js";
|
|
22
|
+
runner
|
|
23
|
+
} from "./index-rmcw8yc8.js";
|
|
28
24
|
import {
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
getMobileTargets,
|
|
26
|
+
NativeApp,
|
|
27
|
+
isPlaceholderAppId
|
|
28
|
+
} from "./index-hr5n7t4x.js";
|
|
31
29
|
import {
|
|
32
|
-
|
|
33
|
-
} from "./index-
|
|
30
|
+
Prompter2
|
|
31
|
+
} from "./index-0bq14vr1.js";
|
|
34
32
|
import {
|
|
35
33
|
RepairRunner
|
|
36
|
-
} from "./index-
|
|
34
|
+
} from "./index-ya5qbmyg.js";
|
|
37
35
|
import {
|
|
38
36
|
WorkflowRunner
|
|
39
|
-
} from "./index-
|
|
40
|
-
import {
|
|
41
|
-
ModuleScript
|
|
42
|
-
} from "./index-8pm30m73.js";
|
|
43
|
-
import {
|
|
44
|
-
PrimitiveScript
|
|
45
|
-
} from "./index-4edzf1gr.js";
|
|
46
|
-
import {
|
|
47
|
-
ScalarScript
|
|
48
|
-
} from "./index-rwg2aa4f.js";
|
|
49
|
-
import {
|
|
50
|
-
getMobileTargets
|
|
51
|
-
} from "./index-47pj3aee.js";
|
|
52
|
-
|
|
53
|
-
// pkgs/@akanjs/cli/context/context.script.ts
|
|
54
|
-
import { Logger } from "akanjs/common";
|
|
37
|
+
} from "./index-m0ms3n1c.js";
|
|
55
38
|
|
|
56
39
|
// pkgs/@akanjs/devkit/akanMcpContract.ts
|
|
57
40
|
import path from "path";
|
|
41
|
+
import { isRecord } from "akanjs/common";
|
|
58
42
|
var emptySchema = { type: "object", properties: {} };
|
|
59
43
|
var stringProperty = { type: "string" };
|
|
60
44
|
var booleanProperty = { type: "boolean" };
|
|
@@ -138,18 +122,11 @@ var inspectAkanContextInputSchema = {
|
|
|
138
122
|
},
|
|
139
123
|
required: ["question", "draft", "review", "request"]
|
|
140
124
|
};
|
|
141
|
-
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
142
125
|
var slugPart = (value) => typeof value === "string" ? value.trim().replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase() : "";
|
|
143
126
|
var optionalString = (args, key) => {
|
|
144
127
|
const value = args[key];
|
|
145
128
|
return typeof value === "string" && value ? value : undefined;
|
|
146
129
|
};
|
|
147
|
-
var nestedStringArg = (args, key) => {
|
|
148
|
-
const value = args[key];
|
|
149
|
-
if (typeof value !== "string" || !value)
|
|
150
|
-
throw new Error(`MCP tool argument "${key}" is required.`);
|
|
151
|
-
return value;
|
|
152
|
-
};
|
|
153
130
|
var isInspectAkanContextRequestType = (value) => typeof value === "string" && inspectAkanContextRequestTypes.includes(value);
|
|
154
131
|
var parseJsonOutput = (output) => JSON.parse(output);
|
|
155
132
|
var workspacePath = (workspace, filePath) => path.isAbsolute(filePath) ? filePath : path.join(workspace.workspaceRoot, filePath);
|
|
@@ -204,50 +181,31 @@ var inspectAkanContextPropsArg = (args) => {
|
|
|
204
181
|
if (!isInspectAkanContextRequestType(args.request.type)) {
|
|
205
182
|
throw new Error('MCP tool argument "request.type" must be a supported inspect_akan_context request type.');
|
|
206
183
|
}
|
|
207
|
-
const
|
|
184
|
+
const base = { question, draft: { reason: stringArg(args.draft, "reason"), type: args.draft.type }, review };
|
|
208
185
|
const request = args.request;
|
|
209
186
|
if (request.type === "workspaceOverview")
|
|
210
|
-
return {
|
|
187
|
+
return { ...base, request: { type: request.type } };
|
|
211
188
|
if (request.type === "moduleContext")
|
|
212
189
|
return {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
review,
|
|
216
|
-
request: {
|
|
217
|
-
type: request.type,
|
|
218
|
-
app: nestedStringArg(request, "app"),
|
|
219
|
-
module: nestedStringArg(request, "module")
|
|
220
|
-
}
|
|
190
|
+
...base,
|
|
191
|
+
request: { type: request.type, app: stringArg(request, "app"), module: stringArg(request, "module") }
|
|
221
192
|
};
|
|
222
193
|
if (request.type === "fieldInsertionContext")
|
|
223
194
|
return {
|
|
224
|
-
|
|
225
|
-
draft,
|
|
226
|
-
review,
|
|
195
|
+
...base,
|
|
227
196
|
request: {
|
|
228
197
|
type: request.type,
|
|
229
|
-
app:
|
|
230
|
-
module:
|
|
231
|
-
field:
|
|
232
|
-
fieldType:
|
|
198
|
+
app: stringArg(request, "app"),
|
|
199
|
+
module: stringArg(request, "module"),
|
|
200
|
+
field: stringArg(request, "field"),
|
|
201
|
+
fieldType: stringArg(request, "fieldType")
|
|
233
202
|
}
|
|
234
203
|
};
|
|
235
204
|
if (request.type === "workflowDiagnostics")
|
|
236
|
-
return {
|
|
237
|
-
question,
|
|
238
|
-
draft,
|
|
239
|
-
review,
|
|
240
|
-
request: { type: request.type, runIdOrPlan: nestedStringArg(request, "runIdOrPlan") }
|
|
241
|
-
};
|
|
205
|
+
return { ...base, request: { type: request.type, runIdOrPlan: stringArg(request, "runIdOrPlan") } };
|
|
242
206
|
return {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
review,
|
|
246
|
-
request: {
|
|
247
|
-
type: "escape",
|
|
248
|
-
reason: nestedStringArg(request, "reason"),
|
|
249
|
-
nextStep: optionalString(request, "nextStep")
|
|
250
|
-
}
|
|
207
|
+
...base,
|
|
208
|
+
request: { type: "escape", reason: stringArg(request, "reason"), nextStep: optionalString(request, "nextStep") }
|
|
251
209
|
};
|
|
252
210
|
};
|
|
253
211
|
var inspectDiagnostic = (severity, code, message) => ({ severity, code, message });
|
|
@@ -471,22 +429,11 @@ var inspectAkanContext = async (workspace, args) => {
|
|
|
471
429
|
strict: true,
|
|
472
430
|
runIdOrPlan: workspacePath(workspace, props.request.runIdOrPlan)
|
|
473
431
|
});
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
context: diagnostic.context
|
|
480
|
-
})), { detailsIncluded: false });
|
|
481
|
-
diagnostics.push(...(doctor.workflowDiagnostics ?? doctor.diagnostics).map((diagnostic) => ({
|
|
482
|
-
severity: diagnostic.severity,
|
|
483
|
-
code: diagnostic.code,
|
|
484
|
-
message: diagnostic.message,
|
|
485
|
-
scope: diagnostic.scope,
|
|
486
|
-
context: {
|
|
487
|
-
...diagnostic.context,
|
|
488
|
-
...diagnostic.path ? { paths: [diagnostic.path] } : {}
|
|
489
|
-
}
|
|
432
|
+
const toWorkflowDiagnostic = ({ severity, code, message, scope }, context) => ({ severity, code, message, scope, context });
|
|
433
|
+
const baselineSummary = createWorkflowBaselineSummary((doctor.baselineDiagnostics ?? []).map((diagnostic) => toWorkflowDiagnostic(diagnostic, diagnostic.context)), { detailsIncluded: false });
|
|
434
|
+
diagnostics.push(...(doctor.workflowDiagnostics ?? doctor.diagnostics).map((diagnostic) => toWorkflowDiagnostic(diagnostic, {
|
|
435
|
+
...diagnostic.context,
|
|
436
|
+
...diagnostic.path ? { paths: [diagnostic.path] } : {}
|
|
490
437
|
})));
|
|
491
438
|
return baseResult("workflowDiagnostics", [
|
|
492
439
|
{
|
|
@@ -504,9 +451,10 @@ var inspectAkanContext = async (workspace, args) => {
|
|
|
504
451
|
workflowDiagnostics: doctor.workflowDiagnostics?.length ?? 0
|
|
505
452
|
});
|
|
506
453
|
}
|
|
454
|
+
const moduleRequest = props.request.type === "moduleContext" || props.request.type === "fieldInsertionContext" ? props.request : null;
|
|
507
455
|
const context = await AkanContextAnalyzer.analyze(workspace, {
|
|
508
|
-
app:
|
|
509
|
-
module:
|
|
456
|
+
app: moduleRequest?.app ?? null,
|
|
457
|
+
module: moduleRequest?.module ?? null,
|
|
510
458
|
includeAbstractContent: false
|
|
511
459
|
});
|
|
512
460
|
if (props.request.type === "workspaceOverview") {
|
|
@@ -594,41 +542,22 @@ var inspectAkanContext = async (workspace, args) => {
|
|
|
594
542
|
});
|
|
595
543
|
};
|
|
596
544
|
|
|
597
|
-
// pkgs/@akanjs/cli/context/context.workflowRegistry.ts
|
|
598
|
-
var createCliWorkflowStepRegistry = (workspace) => createWorkflowStepRegistry({
|
|
599
|
-
workspace,
|
|
600
|
-
createModule: (sys, module) => CommandContainer.get(ModuleScript).createModuleTemplate(sys, module),
|
|
601
|
-
createScalar: (sys, scalar) => CommandContainer.get(ScalarScript).createScalar(sys, scalar),
|
|
602
|
-
createUi: (input) => CommandContainer.get(PrimitiveScript).createUi(workspace, input),
|
|
603
|
-
addField: (input) => CommandContainer.get(PrimitiveScript).addField(workspace, input),
|
|
604
|
-
addEnumField: (input) => CommandContainer.get(PrimitiveScript).addEnumField(workspace, input),
|
|
605
|
-
addMutation: (input) => CommandContainer.get(PrimitiveScript).addMutation(workspace, input),
|
|
606
|
-
addSlice: (input) => CommandContainer.get(PrimitiveScript).addSlice(workspace, input)
|
|
607
|
-
});
|
|
608
|
-
|
|
609
545
|
// pkgs/@akanjs/cli/context/context.runner.ts
|
|
610
546
|
var toolErrorText = (error) => {
|
|
611
547
|
const message = error instanceof Error ? error.message : String(error);
|
|
612
548
|
return message.replace(/\/(?:[^\s"'/]+\/)*(?=(?:pkgs|apps|libs|infra)\/)/g, "<workspace>/");
|
|
613
549
|
};
|
|
614
|
-
var workflowDiagnosticFromContext = (diagnostic) => ({
|
|
615
|
-
severity: diagnostic.severity,
|
|
616
|
-
code: diagnostic.code,
|
|
617
|
-
message: diagnostic.message,
|
|
618
|
-
scope: diagnostic.scope,
|
|
619
|
-
context: diagnostic.context
|
|
620
|
-
});
|
|
621
550
|
var compactDoctorWorkspaceResult = (result, includeBaselineDetails) => {
|
|
622
551
|
const baselineDiagnostics = result.baselineDiagnostics ?? [];
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
552
|
+
const baselineSummary = createWorkflowBaselineSummary(baselineDiagnostics.map(({ severity, code, message, scope, context }) => ({
|
|
553
|
+
severity,
|
|
554
|
+
code,
|
|
555
|
+
message,
|
|
556
|
+
scope,
|
|
557
|
+
context
|
|
558
|
+
})), { detailsIncluded: includeBaselineDetails });
|
|
559
|
+
if (baselineDiagnostics.length === 0)
|
|
560
|
+
return { ...result, baselineSummary };
|
|
632
561
|
return {
|
|
633
562
|
...result,
|
|
634
563
|
baselineSummary,
|
|
@@ -637,17 +566,13 @@ var compactDoctorWorkspaceResult = (result, includeBaselineDetails) => {
|
|
|
637
566
|
};
|
|
638
567
|
};
|
|
639
568
|
|
|
640
|
-
class
|
|
569
|
+
class ContextRunner2 extends runner("context") {
|
|
641
570
|
async getContext(workspace, {
|
|
642
571
|
format = "markdown",
|
|
643
572
|
app = null,
|
|
644
573
|
module = null
|
|
645
574
|
} = {}) {
|
|
646
|
-
const context = await AkanContextAnalyzer.analyze(workspace, {
|
|
647
|
-
app,
|
|
648
|
-
module,
|
|
649
|
-
includeAbstractContent: !!module
|
|
650
|
-
});
|
|
575
|
+
const context = await AkanContextAnalyzer.analyze(workspace, { app, module, includeAbstractContent: !!module });
|
|
651
576
|
return format === "json" ? jsonText(context) : AkanContextAnalyzer.renderMarkdown(context, { module });
|
|
652
577
|
}
|
|
653
578
|
async doctor(workspace, {
|
|
@@ -663,13 +588,25 @@ class ContextRunner extends runner("context") {
|
|
|
663
588
|
async#doctorIos(workspace, format) {
|
|
664
589
|
const appNames = await workspace.getApps();
|
|
665
590
|
const diagnostics = [];
|
|
591
|
+
let toolchainChecked = false;
|
|
666
592
|
for (const appName of appNames) {
|
|
667
593
|
const app = AppExecutor.from(workspace, appName);
|
|
668
594
|
const config = await app.getConfig();
|
|
669
595
|
if (!config.hasMobileConfig)
|
|
670
596
|
continue;
|
|
597
|
+
if (!toolchainChecked) {
|
|
598
|
+
toolchainChecked = true;
|
|
599
|
+
const report = await NativeApp.doctor(app.cwdPath, ["ios"]);
|
|
600
|
+
for (const check of report.checks.filter((check) => !check.ok || check.warn))
|
|
601
|
+
diagnostics.push({
|
|
602
|
+
severity: check.ok ? "warning" : "error",
|
|
603
|
+
code: "native-toolchain",
|
|
604
|
+
path: `${check.group} \u203A ${check.name}`,
|
|
605
|
+
message: [check.detail, check.hint].filter(Boolean).join(" ")
|
|
606
|
+
});
|
|
607
|
+
}
|
|
671
608
|
for (const { name, config: target } of await getMobileTargets(app)) {
|
|
672
|
-
if (!
|
|
609
|
+
if (!isPlaceholderAppId(target.appId))
|
|
673
610
|
continue;
|
|
674
611
|
diagnostics.push({
|
|
675
612
|
severity: "warning",
|
|
@@ -694,7 +631,7 @@ class ContextRunner extends runner("context") {
|
|
|
694
631
|
`);
|
|
695
632
|
}
|
|
696
633
|
async getGuidelineResource(name) {
|
|
697
|
-
return await
|
|
634
|
+
return await Prompter2.getInstruction(name);
|
|
698
635
|
}
|
|
699
636
|
async installMcp(workspace, target, { force = false, mode = "readonly" } = {}) {
|
|
700
637
|
if (target === "codex")
|
|
@@ -710,13 +647,7 @@ class ContextRunner extends runner("context") {
|
|
|
710
647
|
if (currentAkanServer && !force && JSON.stringify(currentAkanServer) !== JSON.stringify(nextAkanServer)) {
|
|
711
648
|
throw new Error(`${configPath} already has an "akan" MCP server. Re-run with --force to overwrite it.`);
|
|
712
649
|
}
|
|
713
|
-
const nextConfig = {
|
|
714
|
-
...existing,
|
|
715
|
-
mcpServers: {
|
|
716
|
-
...mcpServers,
|
|
717
|
-
akan: nextAkanServer
|
|
718
|
-
}
|
|
719
|
-
};
|
|
650
|
+
const nextConfig = { ...existing, mcpServers: { ...mcpServers, akan: nextAkanServer } };
|
|
720
651
|
await workspace.writeFile(configPath, `${JSON.stringify(nextConfig, null, 2)}
|
|
721
652
|
`);
|
|
722
653
|
return configPath;
|
|
@@ -773,7 +704,7 @@ class ContextRunner extends runner("context") {
|
|
|
773
704
|
return modules;
|
|
774
705
|
}
|
|
775
706
|
if (name === "get_guideline")
|
|
776
|
-
return await
|
|
707
|
+
return await Prompter2.getInstruction(stringArg(args, "name"));
|
|
777
708
|
if (name === "doctor_workspace")
|
|
778
709
|
return compactDoctorWorkspaceResult(await AkanContextAnalyzer.doctor(workspace, {
|
|
779
710
|
strict: !!args.strict,
|
|
@@ -809,7 +740,7 @@ class ContextRunner extends runner("context") {
|
|
|
809
740
|
format: "json",
|
|
810
741
|
dryRun: !!args.dryRun,
|
|
811
742
|
workspace,
|
|
812
|
-
registry:
|
|
743
|
+
registry: WorkflowRunner.stepRegistry(workspace)
|
|
813
744
|
}));
|
|
814
745
|
const validationTarget = typeof report.validationTarget === "string" ? report.validationTarget : typeof report.applyReportPath === "string" ? report.applyReportPath : stringArg(args, "planPath");
|
|
815
746
|
return {
|
|
@@ -863,14 +794,14 @@ ${payload}`);
|
|
|
863
794
|
const respondError = (id, code, message, framing) => {
|
|
864
795
|
writeMessage({ jsonrpc: "2.0", id: id ?? null, error: { code, message } }, framing);
|
|
865
796
|
};
|
|
866
|
-
const guidelineNames = await
|
|
797
|
+
const guidelineNames = await Prompter2.listGuidelines();
|
|
867
798
|
const resources = buildResourceList(guidelineNames);
|
|
868
799
|
const readResource = async (uri) => {
|
|
869
800
|
if (uri === "akan://docs/framework")
|
|
870
|
-
return { uri, mimeType: "text/markdown", text: await
|
|
801
|
+
return { uri, mimeType: "text/markdown", text: await Prompter2.getInstruction("framework") };
|
|
871
802
|
const guideline = /^akan:\/\/guidelines\/(.+)$/.exec(uri)?.[1];
|
|
872
803
|
if (guideline)
|
|
873
|
-
return { uri, mimeType: "text/markdown", text: await
|
|
804
|
+
return { uri, mimeType: "text/markdown", text: await Prompter2.getInstruction(guideline) };
|
|
874
805
|
const context = await AkanContextAnalyzer.analyze(workspace);
|
|
875
806
|
if (uri === "akan://workspace/summary")
|
|
876
807
|
return { uri, mimeType: "application/json", text: jsonText(context, { trailingNewline: false }) };
|
|
@@ -902,22 +833,14 @@ ${payload}`);
|
|
|
902
833
|
serverInfo: { name: "akan", version: process.env.AKAN_VERSION ?? "0.0.0" }
|
|
903
834
|
}, framing);
|
|
904
835
|
} else if (request.method === "tools/list") {
|
|
905
|
-
respond(request.id, {
|
|
906
|
-
tools: this.listMcpTools(mode, { guidelineNames })
|
|
907
|
-
}, framing);
|
|
836
|
+
respond(request.id, { tools: this.listMcpTools(mode, { guidelineNames }) }, framing);
|
|
908
837
|
} else if (request.method === "tools/call") {
|
|
909
838
|
const name = params.name;
|
|
910
839
|
const args = params.arguments ?? {};
|
|
911
840
|
try {
|
|
912
841
|
const result = await this.callMcpTool(workspace, name, args, { mode });
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
{
|
|
916
|
-
type: "text",
|
|
917
|
-
text: typeof result === "string" ? result : jsonText(result, { trailingNewline: false })
|
|
918
|
-
}
|
|
919
|
-
]
|
|
920
|
-
}, framing);
|
|
842
|
+
const text = typeof result === "string" ? result : jsonText(result, { trailingNewline: false });
|
|
843
|
+
respond(request.id, { content: [{ type: "text", text }] }, framing);
|
|
921
844
|
} catch (error) {
|
|
922
845
|
respond(request.id, { content: [{ type: "text", text: toolErrorText(error) }], isError: true }, framing);
|
|
923
846
|
}
|
|
@@ -1026,7 +949,7 @@ ${payload}`);
|
|
|
1026
949
|
test: "`akan test <app-or-lib-or-pkg>` prepares the target and runs its tests.",
|
|
1027
950
|
build: "`akan build <app-name>` creates a production build after preparing generated files.",
|
|
1028
951
|
doctor: "`akan doctor --strict --format json` reports agent-readable workspace convention diagnostics and validation hints.",
|
|
1029
|
-
"guideline show": "`akan guideline show <name>` prints an Akan
|
|
952
|
+
"guideline show": "`akan guideline show <name>` prints an Akan guideline instruction.",
|
|
1030
953
|
workflow: "`akan workflow list|explain|plan|apply|validate|report` lists, plans, applies, validates, and reports agent-readable Akan workflows.",
|
|
1031
954
|
"workflow list": "`akan workflow list` lists parseable read-only workflow specs.",
|
|
1032
955
|
"workflow explain": "`akan workflow explain <workflow>` explains inputs, optional surfaces, steps, and validation.",
|
|
@@ -1049,57 +972,4 @@ ${payload}`);
|
|
|
1049
972
|
}
|
|
1050
973
|
}
|
|
1051
974
|
|
|
1052
|
-
|
|
1053
|
-
var resolveMcpInstallTargets = (target) => {
|
|
1054
|
-
if (!target || target === "all")
|
|
1055
|
-
return [...akanMcpInstallTargets];
|
|
1056
|
-
if (akanMcpInstallTargets.includes(target))
|
|
1057
|
-
return [target];
|
|
1058
|
-
throw new Error(`Unknown MCP install target: ${target}. Use cursor, claude, codex, or all.`);
|
|
1059
|
-
};
|
|
1060
|
-
var mcpTargetLabels = {
|
|
1061
|
-
cursor: "Cursor",
|
|
1062
|
-
claude: "Claude Code",
|
|
1063
|
-
codex: "Codex"
|
|
1064
|
-
};
|
|
1065
|
-
|
|
1066
|
-
class ContextScript extends script("context", [ContextRunner]) {
|
|
1067
|
-
async context(workspace, options = {}) {
|
|
1068
|
-
Logger.rawLog(await this.contextRunner.getContext(workspace, options));
|
|
1069
|
-
}
|
|
1070
|
-
async doctor(workspace, options = {}) {
|
|
1071
|
-
Logger.rawLog(await this.contextRunner.doctor(workspace, options));
|
|
1072
|
-
}
|
|
1073
|
-
async mcpInstall(workspace, target, { force = false, mode = "apply" } = {}) {
|
|
1074
|
-
const targets = resolveMcpInstallTargets(target);
|
|
1075
|
-
const written = [];
|
|
1076
|
-
for (const t of targets) {
|
|
1077
|
-
const configPath = await this.contextRunner.installMcp(workspace, t, { force, mode });
|
|
1078
|
-
written.push(`${mcpTargetLabels[t]}: ${configPath}`);
|
|
1079
|
-
}
|
|
1080
|
-
Logger.rawLog(`Akan MCP server installed (${mode} mode):
|
|
1081
|
-
${written.map((line) => `- ${line}`).join(`
|
|
1082
|
-
`)}`);
|
|
1083
|
-
}
|
|
1084
|
-
async mcp(workspace, { mode = "apply" } = {}) {
|
|
1085
|
-
await this.contextRunner.runMcp(workspace, { mode });
|
|
1086
|
-
}
|
|
1087
|
-
async mcpCall(workspace, tool, {
|
|
1088
|
-
mode = "readonly",
|
|
1089
|
-
args = null,
|
|
1090
|
-
format = "json"
|
|
1091
|
-
} = {}) {
|
|
1092
|
-
let parsedArgs = {};
|
|
1093
|
-
if (args) {
|
|
1094
|
-
const parsed = JSON.parse(args);
|
|
1095
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1096
|
-
throw new Error("MCP call args must be a JSON object.");
|
|
1097
|
-
}
|
|
1098
|
-
parsedArgs = parsed;
|
|
1099
|
-
}
|
|
1100
|
-
const result = await this.contextRunner.callMcpTool(workspace, tool, parsedArgs, { mode });
|
|
1101
|
-
Logger.rawLog(format === "json" ? jsonText(result) : String(result));
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
export { ContextScript };
|
|
975
|
+
export { ContextRunner2 };
|
|
@@ -57,29 +57,14 @@ ${errorMessages}`);
|
|
|
57
57
|
warningCount++;
|
|
58
58
|
else if (diagnostic.category === ts.DiagnosticCategory.Suggestion)
|
|
59
59
|
suggestionCount++;
|
|
60
|
-
|
|
61
|
-
const fileName = diagnostic.file.fileName;
|
|
62
|
-
if (!diagnosticsByFile.has(fileName))
|
|
63
|
-
diagnosticsByFile.set(fileName, []);
|
|
64
|
-
const fileDiagnostics = diagnosticsByFile.get(fileName);
|
|
65
|
-
if (fileDiagnostics)
|
|
66
|
-
fileDiagnostics.push(diagnostic);
|
|
67
|
-
} else {
|
|
68
|
-
if (!diagnosticsByFile.has(""))
|
|
69
|
-
diagnosticsByFile.set("", []);
|
|
70
|
-
const fileDiagnostics = diagnosticsByFile.get("");
|
|
71
|
-
if (fileDiagnostics)
|
|
72
|
-
fileDiagnostics.push(diagnostic);
|
|
73
|
-
}
|
|
60
|
+
diagnosticsByFile.getOrInsert(diagnostic.file?.fileName ?? "", []).push(diagnostic);
|
|
74
61
|
});
|
|
75
62
|
diagnosticsByFile.forEach((fileDiagnostics, fileName) => {
|
|
76
63
|
if (fileName)
|
|
77
64
|
output.push(`
|
|
78
65
|
${chalk.cyan(fileName)}`);
|
|
79
66
|
fileDiagnostics.forEach((diagnostic) => {
|
|
80
|
-
const categoryText = diagnostic.category === ts.DiagnosticCategory.Error ? "error" : diagnostic.category === ts.DiagnosticCategory.Warning ? "warning" : "suggestion";
|
|
81
|
-
const categoryColor = diagnostic.category === ts.DiagnosticCategory.Error ? chalk.red : diagnostic.category === ts.DiagnosticCategory.Warning ? chalk.yellow : chalk.blue;
|
|
82
|
-
const icon = diagnostic.category === ts.DiagnosticCategory.Error ? "\u274C" : diagnostic.category === ts.DiagnosticCategory.Warning ? "\u26A0\uFE0F" : "\uD83D\uDCA1";
|
|
67
|
+
const [categoryText, categoryColor, icon] = diagnostic.category === ts.DiagnosticCategory.Error ? ["error", chalk.red, "\u274C"] : diagnostic.category === ts.DiagnosticCategory.Warning ? ["warning", chalk.yellow, "\u26A0\uFE0F"] : ["suggestion", chalk.blue, "\uD83D\uDCA1"];
|
|
83
68
|
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, `
|
|
84
69
|
`);
|
|
85
70
|
const tsCode = chalk.dim(`(TS${diagnostic.code})`);
|