@akanjs/cli 3.0.0-beta.19 → 3.0.0-beta.20
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-6cm97kay.js → CodeAgent-awv258wb.js} +2 -2
- package/{CodeTui-za4jsm41.js → CodeTui-1nqh35ez.js} +20 -22
- package/TunnelShare-scf4e4pd.js +9 -0
- package/{agent.command-e0wpbbyg.js → agent.command-1s9ag7sb.js} +8 -9
- package/akanCode.js +4 -4
- package/{application.command-8wyxqc8q.js → application.command-49hwy6va.js} +25 -56
- package/{applicationBuildRunner-n9gzaxd0.js → applicationBuildRunner-ybyp97pv.js} +33 -59
- package/{applicationReleasePackager-vpggfqgq.js → applicationReleasePackager-esnrphw8.js} +40 -60
- package/buildBatch.proc.js +19 -24
- package/{capacitorApp-q3z0qht0.js → capacitorApp-1synz4en.js} +3 -4
- package/{cloud.command-4zwa5dsx.js → cloud.command-d7rqtzt9.js} +16 -26
- package/cloud.script-bkbpcr96.js +19 -0
- package/{code.command-468c9d7s.js → code.command-nn48xzej.js} +22 -37
- package/context.command-s3mcmvpa.js +48 -0
- package/context.runner-k99nb5pk.js +21 -0
- package/{dependencyScanner-0z2h2tks.js → dependencyScanner-ye2e6pdz.js} +2 -2
- package/{devTui-ffjsarqa.js → devTui-q7k7bakd.js} +5 -9
- package/fileSys-5ngz93ga.js +9 -0
- package/{guideline.command-vhw13pqr.js → guideline.command-sct4qnt5.js} +4 -5
- package/guidelines/conventions/conventions.instruction.md +5 -1
- package/guidelines/mcpRule/mcpRule.instruction.md +7 -5
- package/incrementalBuilder.proc.js +30 -48
- package/{index-s5rhm04y.js → index-0bq14vr1.js} +1 -1
- package/{index-10dkrrww.js → index-13ffe9wp.js} +4 -4
- package/{index-srmay5jw.js → index-22d57v4c.js} +84 -67
- package/{index-53176s7j.js → index-31yr441d.js} +10 -17
- package/index-3hx1z96c.js +87 -0
- package/{index-4m929vvn.js → index-3sq321ak.js} +10 -18
- package/{index-bhtmj233.js → index-3t7g9e4r.js} +41 -78
- package/{index-q0y2jq9j.js → index-5b6tavv3.js} +6 -3
- package/{index-47pj3aee.js → index-5e0n4hqx.js} +11 -12
- package/{index-7ep8qtvp.js → index-5pc1qrbv.js} +5 -8
- package/{index-esk82rvk.js → index-8mna0947.js} +34 -71
- package/{index-sq2dzkzm.js → index-8sf7wmdr.js} +6 -6
- package/{index-crmeqnmf.js → index-9d9bgcx4.js} +283 -722
- package/{index-bwf965h6.js → index-ahemdr5n.js} +6 -6
- package/{index-ab0c38ea.js → index-as7xmyz8.js} +20 -20
- package/{index-bc88j1ry.js → index-axzjaqve.js} +94 -142
- package/{index-3d9y066c.js → index-bjwxs904.js} +9 -8
- package/{index-667w0yah.js → index-c6eggbee.js} +2 -5
- package/{index-a1w6934z.js → index-ddxvdd1p.js} +169 -305
- package/{index-92zztqy1.js → index-dy0jx9ay.js} +2 -17
- package/{index-22xtgmhn.js → index-dzf3r49a.js} +1 -1
- package/{index-89hy31kf.js → index-fgq75haa.js} +172 -287
- package/{index-by5gpp8x.js → index-hj6w4ka1.js} +2 -1
- package/{index-hwkygn9s.js → index-khpfpcsd.js} +302 -33
- package/{index-vqx8bdxz.js → index-mxav6j3c.js} +78 -231
- package/{index-2446k7b4.js → index-myhc3c1j.js} +512 -588
- package/{index-3jrp517k.js → index-nv5976x3.js} +45 -128
- package/{index-zqgj2rt2.js → index-przybvy5.js} +69 -147
- package/{index-n3cv0tm4.js → index-smme4r47.js} +1 -1
- package/{index-qdgzsnhg.js → index-w2zdcw3k.js} +110 -231
- package/{index-14zrtgfa.js → index-wa5jbxj1.js} +6 -39
- package/{index-bftkz6cp.js → index-ww4z397j.js} +198 -555
- package/{index-kwaq3n9n.js → index-xqjwd384.js} +4 -7
- package/{index-txr7dj2g.js → index-xqpzbab5.js} +106 -240
- package/{index-e4v6vhxq.js → index-xsjh6nzh.js} +178 -165
- package/{index-18zybgkc.js → index-ygn77a5w.js} +47 -99
- package/{index-9d6nvkz2.js → index-ztp3e73t.js} +79 -35
- package/index.js +23 -24
- package/{library.command-cqr175dy.js → library.command-1gx04jgn.js} +4 -5
- package/{localRegistry.command-49z55qqz.js → localRegistry.command-zndxj1q6.js} +21 -42
- package/{module.command-9p8mm3b0.js → module.command-3waddk95.js} +6 -7
- package/{package.command-wxyz909t.js → package.command-zrc7br1y.js} +5 -6
- package/package.json +2 -2
- package/{page.command-gsrsfqqs.js → page.command-vpjgardh.js} +4 -5
- package/{primitive.command-ns1mptje.js → primitive.command-sz84tk4t.js} +9 -20
- package/{prompter-1f8d9pcc.js → prompter-ptaa3nk0.js} +2 -2
- package/{quality.command-e76k2q9k.js → quality.command-g869hafs.js} +129 -363
- package/{recipeScanner-fpagtgc1.js → recipeScanner-4b69ybe0.js} +1 -1
- package/{repair.command-pkrsm3cw.js → repair.command-chsnjvvv.js} +11 -35
- package/{scalar.command-0cpt3fc8.js → scalar.command-2v21newx.js} +5 -6
- package/skills/akan-code/SKILL.md +12 -4
- package/{subspace.command-fktpwp0g.js → subspace.command-ckcbwfp1.js} +39 -58
- package/templates/appSample/srvkit/{AuthGuard.ts → guards.ts} +3 -3
- package/templates/appSample/srvkit/{SessionInternalArg.ts → internalArgs.ts} +3 -3
- package/templates/client.ts +7 -30
- 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/server.ts +0 -2
- package/{tunnel.command-d5jy9gk8.js → tunnel.command-kd2yr4fx.js} +5 -6
- package/{typeChecker-3xgrzc2v.js → typeChecker-px49mezc.js} +1 -1
- package/typecheck.proc.js +1 -1
- package/workflow.command-44252cqv.js +79 -0
- package/{workspace.command-gv84eh1p.js → workspace.command-fqcztt5p.js} +72 -107
- package/TunnelShare-2j6s511d.js +0 -9
- package/cloud.script-fwx3vb34.js +0 -20
- package/context.command-dsnw0jby.js +0 -80
- package/context.runner-rs4rj15d.js +0 -22
- package/devTuiView-1q1mdgrv.js +0 -9
- package/getDirname-dr3jz1xg.js +0 -7
- package/index-6wwzs1bc.js +0 -7
- package/workflow.command-6tkcysmx.js +0 -105
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
AppExecutor
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-9d9bgcx4.js";
|
|
5
5
|
import {
|
|
6
6
|
jsonText,
|
|
7
7
|
createWorkflowBaselineSummary,
|
|
8
8
|
buildAkanModuleContextIndex,
|
|
9
|
-
createWorkflowStepRegistry,
|
|
10
9
|
toolingRolloutGate
|
|
11
|
-
} from "./index-
|
|
10
|
+
} from "./index-myhc3c1j.js";
|
|
12
11
|
import {
|
|
13
12
|
buildResourceList,
|
|
14
13
|
codexMcpConfigPath,
|
|
@@ -18,38 +17,29 @@ import {
|
|
|
18
17
|
upsertCodexMcpServerBlock,
|
|
19
18
|
renderDoctorText,
|
|
20
19
|
AkanContextAnalyzer
|
|
21
|
-
} from "./index-
|
|
20
|
+
} from "./index-ygn77a5w.js";
|
|
22
21
|
import {
|
|
23
22
|
isPlaceholderAppId2
|
|
24
|
-
} from "./index-
|
|
23
|
+
} from "./index-mxav6j3c.js";
|
|
25
24
|
import {
|
|
26
|
-
CommandContainer,
|
|
27
25
|
runner
|
|
28
|
-
} from "./index-
|
|
26
|
+
} from "./index-w2zdcw3k.js";
|
|
29
27
|
import {
|
|
30
28
|
Prompter2
|
|
31
|
-
} from "./index-
|
|
29
|
+
} from "./index-0bq14vr1.js";
|
|
32
30
|
import {
|
|
33
31
|
RepairRunner
|
|
34
|
-
} from "./index-
|
|
32
|
+
} from "./index-31yr441d.js";
|
|
35
33
|
import {
|
|
36
34
|
WorkflowRunner
|
|
37
|
-
} from "./index-
|
|
38
|
-
import {
|
|
39
|
-
ModuleScript
|
|
40
|
-
} from "./index-esk82rvk.js";
|
|
41
|
-
import {
|
|
42
|
-
PrimitiveScript
|
|
43
|
-
} from "./index-zqgj2rt2.js";
|
|
44
|
-
import {
|
|
45
|
-
ScalarScript
|
|
46
|
-
} from "./index-4m929vvn.js";
|
|
35
|
+
} from "./index-xqpzbab5.js";
|
|
47
36
|
import {
|
|
48
37
|
getMobileTargets
|
|
49
|
-
} from "./index-
|
|
38
|
+
} from "./index-5e0n4hqx.js";
|
|
50
39
|
|
|
51
40
|
// pkgs/@akanjs/devkit/akanMcpContract.ts
|
|
52
41
|
import path from "path";
|
|
42
|
+
import { isRecord } from "akanjs/common";
|
|
53
43
|
var emptySchema = { type: "object", properties: {} };
|
|
54
44
|
var stringProperty = { type: "string" };
|
|
55
45
|
var booleanProperty = { type: "boolean" };
|
|
@@ -133,18 +123,11 @@ var inspectAkanContextInputSchema = {
|
|
|
133
123
|
},
|
|
134
124
|
required: ["question", "draft", "review", "request"]
|
|
135
125
|
};
|
|
136
|
-
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
137
126
|
var slugPart = (value) => typeof value === "string" ? value.trim().replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase() : "";
|
|
138
127
|
var optionalString = (args, key) => {
|
|
139
128
|
const value = args[key];
|
|
140
129
|
return typeof value === "string" && value ? value : undefined;
|
|
141
130
|
};
|
|
142
|
-
var nestedStringArg = (args, key) => {
|
|
143
|
-
const value = args[key];
|
|
144
|
-
if (typeof value !== "string" || !value)
|
|
145
|
-
throw new Error(`MCP tool argument "${key}" is required.`);
|
|
146
|
-
return value;
|
|
147
|
-
};
|
|
148
131
|
var isInspectAkanContextRequestType = (value) => typeof value === "string" && inspectAkanContextRequestTypes.includes(value);
|
|
149
132
|
var parseJsonOutput = (output) => JSON.parse(output);
|
|
150
133
|
var workspacePath = (workspace, filePath) => path.isAbsolute(filePath) ? filePath : path.join(workspace.workspaceRoot, filePath);
|
|
@@ -199,50 +182,31 @@ var inspectAkanContextPropsArg = (args) => {
|
|
|
199
182
|
if (!isInspectAkanContextRequestType(args.request.type)) {
|
|
200
183
|
throw new Error('MCP tool argument "request.type" must be a supported inspect_akan_context request type.');
|
|
201
184
|
}
|
|
202
|
-
const
|
|
185
|
+
const base = { question, draft: { reason: stringArg(args.draft, "reason"), type: args.draft.type }, review };
|
|
203
186
|
const request = args.request;
|
|
204
187
|
if (request.type === "workspaceOverview")
|
|
205
|
-
return {
|
|
188
|
+
return { ...base, request: { type: request.type } };
|
|
206
189
|
if (request.type === "moduleContext")
|
|
207
190
|
return {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
review,
|
|
211
|
-
request: {
|
|
212
|
-
type: request.type,
|
|
213
|
-
app: nestedStringArg(request, "app"),
|
|
214
|
-
module: nestedStringArg(request, "module")
|
|
215
|
-
}
|
|
191
|
+
...base,
|
|
192
|
+
request: { type: request.type, app: stringArg(request, "app"), module: stringArg(request, "module") }
|
|
216
193
|
};
|
|
217
194
|
if (request.type === "fieldInsertionContext")
|
|
218
195
|
return {
|
|
219
|
-
|
|
220
|
-
draft,
|
|
221
|
-
review,
|
|
196
|
+
...base,
|
|
222
197
|
request: {
|
|
223
198
|
type: request.type,
|
|
224
|
-
app:
|
|
225
|
-
module:
|
|
226
|
-
field:
|
|
227
|
-
fieldType:
|
|
199
|
+
app: stringArg(request, "app"),
|
|
200
|
+
module: stringArg(request, "module"),
|
|
201
|
+
field: stringArg(request, "field"),
|
|
202
|
+
fieldType: stringArg(request, "fieldType")
|
|
228
203
|
}
|
|
229
204
|
};
|
|
230
205
|
if (request.type === "workflowDiagnostics")
|
|
231
|
-
return {
|
|
232
|
-
question,
|
|
233
|
-
draft,
|
|
234
|
-
review,
|
|
235
|
-
request: { type: request.type, runIdOrPlan: nestedStringArg(request, "runIdOrPlan") }
|
|
236
|
-
};
|
|
206
|
+
return { ...base, request: { type: request.type, runIdOrPlan: stringArg(request, "runIdOrPlan") } };
|
|
237
207
|
return {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
review,
|
|
241
|
-
request: {
|
|
242
|
-
type: "escape",
|
|
243
|
-
reason: nestedStringArg(request, "reason"),
|
|
244
|
-
nextStep: optionalString(request, "nextStep")
|
|
245
|
-
}
|
|
208
|
+
...base,
|
|
209
|
+
request: { type: "escape", reason: stringArg(request, "reason"), nextStep: optionalString(request, "nextStep") }
|
|
246
210
|
};
|
|
247
211
|
};
|
|
248
212
|
var inspectDiagnostic = (severity, code, message) => ({ severity, code, message });
|
|
@@ -466,22 +430,11 @@ var inspectAkanContext = async (workspace, args) => {
|
|
|
466
430
|
strict: true,
|
|
467
431
|
runIdOrPlan: workspacePath(workspace, props.request.runIdOrPlan)
|
|
468
432
|
});
|
|
469
|
-
const
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
context: diagnostic.context
|
|
475
|
-
})), { detailsIncluded: false });
|
|
476
|
-
diagnostics.push(...(doctor.workflowDiagnostics ?? doctor.diagnostics).map((diagnostic) => ({
|
|
477
|
-
severity: diagnostic.severity,
|
|
478
|
-
code: diagnostic.code,
|
|
479
|
-
message: diagnostic.message,
|
|
480
|
-
scope: diagnostic.scope,
|
|
481
|
-
context: {
|
|
482
|
-
...diagnostic.context,
|
|
483
|
-
...diagnostic.path ? { paths: [diagnostic.path] } : {}
|
|
484
|
-
}
|
|
433
|
+
const toWorkflowDiagnostic = ({ severity, code, message, scope }, context) => ({ severity, code, message, scope, context });
|
|
434
|
+
const baselineSummary = createWorkflowBaselineSummary((doctor.baselineDiagnostics ?? []).map((diagnostic) => toWorkflowDiagnostic(diagnostic, diagnostic.context)), { detailsIncluded: false });
|
|
435
|
+
diagnostics.push(...(doctor.workflowDiagnostics ?? doctor.diagnostics).map((diagnostic) => toWorkflowDiagnostic(diagnostic, {
|
|
436
|
+
...diagnostic.context,
|
|
437
|
+
...diagnostic.path ? { paths: [diagnostic.path] } : {}
|
|
485
438
|
})));
|
|
486
439
|
return baseResult("workflowDiagnostics", [
|
|
487
440
|
{
|
|
@@ -499,9 +452,10 @@ var inspectAkanContext = async (workspace, args) => {
|
|
|
499
452
|
workflowDiagnostics: doctor.workflowDiagnostics?.length ?? 0
|
|
500
453
|
});
|
|
501
454
|
}
|
|
455
|
+
const moduleRequest = props.request.type === "moduleContext" || props.request.type === "fieldInsertionContext" ? props.request : null;
|
|
502
456
|
const context = await AkanContextAnalyzer.analyze(workspace, {
|
|
503
|
-
app:
|
|
504
|
-
module:
|
|
457
|
+
app: moduleRequest?.app ?? null,
|
|
458
|
+
module: moduleRequest?.module ?? null,
|
|
505
459
|
includeAbstractContent: false
|
|
506
460
|
});
|
|
507
461
|
if (props.request.type === "workspaceOverview") {
|
|
@@ -589,41 +543,22 @@ var inspectAkanContext = async (workspace, args) => {
|
|
|
589
543
|
});
|
|
590
544
|
};
|
|
591
545
|
|
|
592
|
-
// pkgs/@akanjs/cli/context/context.workflowRegistry.ts
|
|
593
|
-
var createCliWorkflowStepRegistry = (workspace) => createWorkflowStepRegistry({
|
|
594
|
-
workspace,
|
|
595
|
-
createModule: (sys, module) => CommandContainer.get(ModuleScript).createModuleTemplate(sys, module),
|
|
596
|
-
createScalar: (sys, scalar) => CommandContainer.get(ScalarScript).createScalar(sys, scalar),
|
|
597
|
-
createUi: (input) => CommandContainer.get(PrimitiveScript).createUi(workspace, input),
|
|
598
|
-
addField: (input) => CommandContainer.get(PrimitiveScript).addField(workspace, input),
|
|
599
|
-
addEnumField: (input) => CommandContainer.get(PrimitiveScript).addEnumField(workspace, input),
|
|
600
|
-
addMutation: (input) => CommandContainer.get(PrimitiveScript).addMutation(workspace, input),
|
|
601
|
-
addSlice: (input) => CommandContainer.get(PrimitiveScript).addSlice(workspace, input)
|
|
602
|
-
});
|
|
603
|
-
|
|
604
546
|
// pkgs/@akanjs/cli/context/context.runner.ts
|
|
605
547
|
var toolErrorText = (error) => {
|
|
606
548
|
const message = error instanceof Error ? error.message : String(error);
|
|
607
549
|
return message.replace(/\/(?:[^\s"'/]+\/)*(?=(?:pkgs|apps|libs|infra)\/)/g, "<workspace>/");
|
|
608
550
|
};
|
|
609
|
-
var workflowDiagnosticFromContext = (diagnostic) => ({
|
|
610
|
-
severity: diagnostic.severity,
|
|
611
|
-
code: diagnostic.code,
|
|
612
|
-
message: diagnostic.message,
|
|
613
|
-
scope: diagnostic.scope,
|
|
614
|
-
context: diagnostic.context
|
|
615
|
-
});
|
|
616
551
|
var compactDoctorWorkspaceResult = (result, includeBaselineDetails) => {
|
|
617
552
|
const baselineDiagnostics = result.baselineDiagnostics ?? [];
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
553
|
+
const baselineSummary = createWorkflowBaselineSummary(baselineDiagnostics.map(({ severity, code, message, scope, context }) => ({
|
|
554
|
+
severity,
|
|
555
|
+
code,
|
|
556
|
+
message,
|
|
557
|
+
scope,
|
|
558
|
+
context
|
|
559
|
+
})), { detailsIncluded: includeBaselineDetails });
|
|
560
|
+
if (baselineDiagnostics.length === 0)
|
|
561
|
+
return { ...result, baselineSummary };
|
|
627
562
|
return {
|
|
628
563
|
...result,
|
|
629
564
|
baselineSummary,
|
|
@@ -638,11 +573,7 @@ class ContextRunner2 extends runner("context") {
|
|
|
638
573
|
app = null,
|
|
639
574
|
module = null
|
|
640
575
|
} = {}) {
|
|
641
|
-
const context = await AkanContextAnalyzer.analyze(workspace, {
|
|
642
|
-
app,
|
|
643
|
-
module,
|
|
644
|
-
includeAbstractContent: !!module
|
|
645
|
-
});
|
|
576
|
+
const context = await AkanContextAnalyzer.analyze(workspace, { app, module, includeAbstractContent: !!module });
|
|
646
577
|
return format === "json" ? jsonText(context) : AkanContextAnalyzer.renderMarkdown(context, { module });
|
|
647
578
|
}
|
|
648
579
|
async doctor(workspace, {
|
|
@@ -705,13 +636,7 @@ class ContextRunner2 extends runner("context") {
|
|
|
705
636
|
if (currentAkanServer && !force && JSON.stringify(currentAkanServer) !== JSON.stringify(nextAkanServer)) {
|
|
706
637
|
throw new Error(`${configPath} already has an "akan" MCP server. Re-run with --force to overwrite it.`);
|
|
707
638
|
}
|
|
708
|
-
const nextConfig = {
|
|
709
|
-
...existing,
|
|
710
|
-
mcpServers: {
|
|
711
|
-
...mcpServers,
|
|
712
|
-
akan: nextAkanServer
|
|
713
|
-
}
|
|
714
|
-
};
|
|
639
|
+
const nextConfig = { ...existing, mcpServers: { ...mcpServers, akan: nextAkanServer } };
|
|
715
640
|
await workspace.writeFile(configPath, `${JSON.stringify(nextConfig, null, 2)}
|
|
716
641
|
`);
|
|
717
642
|
return configPath;
|
|
@@ -804,7 +729,7 @@ class ContextRunner2 extends runner("context") {
|
|
|
804
729
|
format: "json",
|
|
805
730
|
dryRun: !!args.dryRun,
|
|
806
731
|
workspace,
|
|
807
|
-
registry:
|
|
732
|
+
registry: WorkflowRunner.stepRegistry(workspace)
|
|
808
733
|
}));
|
|
809
734
|
const validationTarget = typeof report.validationTarget === "string" ? report.validationTarget : typeof report.applyReportPath === "string" ? report.applyReportPath : stringArg(args, "planPath");
|
|
810
735
|
return {
|
|
@@ -897,22 +822,14 @@ ${payload}`);
|
|
|
897
822
|
serverInfo: { name: "akan", version: process.env.AKAN_VERSION ?? "0.0.0" }
|
|
898
823
|
}, framing);
|
|
899
824
|
} else if (request.method === "tools/list") {
|
|
900
|
-
respond(request.id, {
|
|
901
|
-
tools: this.listMcpTools(mode, { guidelineNames })
|
|
902
|
-
}, framing);
|
|
825
|
+
respond(request.id, { tools: this.listMcpTools(mode, { guidelineNames }) }, framing);
|
|
903
826
|
} else if (request.method === "tools/call") {
|
|
904
827
|
const name = params.name;
|
|
905
828
|
const args = params.arguments ?? {};
|
|
906
829
|
try {
|
|
907
830
|
const result = await this.callMcpTool(workspace, name, args, { mode });
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
{
|
|
911
|
-
type: "text",
|
|
912
|
-
text: typeof result === "string" ? result : jsonText(result, { trailingNewline: false })
|
|
913
|
-
}
|
|
914
|
-
]
|
|
915
|
-
}, framing);
|
|
831
|
+
const text = typeof result === "string" ? result : jsonText(result, { trailingNewline: false });
|
|
832
|
+
respond(request.id, { content: [{ type: "text", text }] }, framing);
|
|
916
833
|
} catch (error) {
|
|
917
834
|
respond(request.id, { content: [{ type: "text", text: toolErrorText(error) }], isError: true }, framing);
|
|
918
835
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
script
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-w2zdcw3k.js";
|
|
5
5
|
import {
|
|
6
6
|
AppExecutor,
|
|
7
7
|
LibExecutor,
|
|
8
8
|
ModuleExecutor
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-9d9bgcx4.js";
|
|
10
10
|
import {
|
|
11
|
+
workflowStatus,
|
|
11
12
|
compactDiagnostics,
|
|
12
|
-
createPrimitiveWriteReport,
|
|
13
13
|
sourceFile,
|
|
14
14
|
moduleComponentName,
|
|
15
15
|
moduleSourcePaths,
|
|
16
16
|
generatedFilesForSync,
|
|
17
17
|
validationCommandsForTarget,
|
|
18
18
|
nextActionsForTarget,
|
|
19
|
-
|
|
19
|
+
createPrimitiveWriteReport,
|
|
20
20
|
normalizeFieldType,
|
|
21
21
|
ensureNamedImport,
|
|
22
22
|
ensureBaseImport,
|
|
@@ -41,13 +41,13 @@ import {
|
|
|
41
41
|
hasSignalFactoryEntry,
|
|
42
42
|
insertSignalFactoryEntry,
|
|
43
43
|
addFieldUiPolicyForType
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-myhc3c1j.js";
|
|
45
45
|
import {
|
|
46
46
|
ModuleScript
|
|
47
|
-
} from "./index-
|
|
47
|
+
} from "./index-8mna0947.js";
|
|
48
48
|
|
|
49
49
|
// pkgs/@akanjs/cli/primitive/primitive.script.ts
|
|
50
|
-
import { capitalize } from "akanjs/common";
|
|
50
|
+
import { capitalize, lowerlize } from "akanjs/common";
|
|
51
51
|
class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
52
52
|
async resolveSys(workspace, target) {
|
|
53
53
|
if (!target)
|
|
@@ -61,28 +61,11 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
61
61
|
}
|
|
62
62
|
async createUi(workspace, input) {
|
|
63
63
|
const sys = await this.resolveSys(workspace, input.app);
|
|
64
|
-
if (!sys || !input.module)
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
validationCommands: [],
|
|
70
|
-
diagnostics: compactDiagnostics([
|
|
71
|
-
!sys && {
|
|
72
|
-
severity: "error",
|
|
73
|
-
code: "primitive-target-missing",
|
|
74
|
-
message: "Target app or library was not found."
|
|
75
|
-
},
|
|
76
|
-
!input.module && {
|
|
77
|
-
severity: "error",
|
|
78
|
-
code: "primitive-input-missing",
|
|
79
|
-
message: "Module is required.",
|
|
80
|
-
input: "module"
|
|
81
|
-
}
|
|
82
|
-
]),
|
|
83
|
-
nextActions: []
|
|
84
|
-
});
|
|
85
|
-
}
|
|
64
|
+
if (!sys || !input.module)
|
|
65
|
+
return PrimitiveScript.#refuse("create-ui", compactDiagnostics([
|
|
66
|
+
!sys && PrimitiveScript.#targetMissing(),
|
|
67
|
+
!input.module && PrimitiveScript.#inputMissing("module")
|
|
68
|
+
]));
|
|
86
69
|
const mod = ModuleExecutor.from(sys, input.module);
|
|
87
70
|
if (input.surface === "view")
|
|
88
71
|
return await this.moduleScript.createView(mod);
|
|
@@ -98,30 +81,16 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
98
81
|
return await this.addFieldToSources(workspace, { ...input, type: `${capitalize(input.field ?? "")}` }, { enumValues: values });
|
|
99
82
|
}
|
|
100
83
|
async addFieldToSources(workspace, input, { enumValues }) {
|
|
84
|
+
const command = enumValues ? "add-enum-field" : "add-field";
|
|
101
85
|
const sys = await this.resolveSys(workspace, input.app);
|
|
102
86
|
const ambiguousNumberTypes = new Set(["number", "numeric"]);
|
|
103
87
|
const normalizedType = input.type ? normalizeFieldType(input.type) : null;
|
|
104
88
|
const diagnostics = compactDiagnostics([
|
|
105
|
-
!sys &&
|
|
106
|
-
!input.module &&
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
input: "module"
|
|
111
|
-
},
|
|
112
|
-
!input.field && {
|
|
113
|
-
severity: "error",
|
|
114
|
-
code: "primitive-input-missing",
|
|
115
|
-
message: "Field is required.",
|
|
116
|
-
input: "field"
|
|
117
|
-
},
|
|
118
|
-
!input.type && {
|
|
119
|
-
severity: "error",
|
|
120
|
-
code: "primitive-input-missing",
|
|
121
|
-
message: "Type is required.",
|
|
122
|
-
input: "type"
|
|
123
|
-
},
|
|
124
|
-
enumValues && enumValues.length === 0 ? { severity: "error", code: "primitive-input-missing", message: "Enum values are required.", input: "values" } : null,
|
|
89
|
+
!sys && PrimitiveScript.#targetMissing(),
|
|
90
|
+
!input.module && PrimitiveScript.#inputMissing("module"),
|
|
91
|
+
!input.field && PrimitiveScript.#inputMissing("field"),
|
|
92
|
+
!input.type && PrimitiveScript.#inputMissing("type"),
|
|
93
|
+
enumValues?.length === 0 && PrimitiveScript.#inputMissing("values", "Enum values are required."),
|
|
125
94
|
input.type && ambiguousNumberTypes.has(input.type.toLowerCase()) ? {
|
|
126
95
|
severity: "error",
|
|
127
96
|
code: "primitive-field-type-unsupported",
|
|
@@ -135,16 +104,8 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
135
104
|
input: "type"
|
|
136
105
|
} : null
|
|
137
106
|
]);
|
|
138
|
-
if (!sys || !input.module || !input.field || !input.type || diagnostics
|
|
139
|
-
return
|
|
140
|
-
command: enumValues ? "add-enum-field" : "add-field",
|
|
141
|
-
changedFiles: [],
|
|
142
|
-
generatedFiles: [],
|
|
143
|
-
validationCommands: [],
|
|
144
|
-
diagnostics,
|
|
145
|
-
nextActions: []
|
|
146
|
-
});
|
|
147
|
-
}
|
|
107
|
+
if (!sys || !input.module || !input.field || !input.type || workflowStatus(diagnostics) === "failed")
|
|
108
|
+
return PrimitiveScript.#refuse(command, diagnostics);
|
|
148
109
|
const moduleClassName = moduleComponentName(input.module);
|
|
149
110
|
const inputClassName = `${moduleClassName}Input`;
|
|
150
111
|
const paths = moduleSourcePaths(input.module);
|
|
@@ -152,32 +113,13 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
152
113
|
const dictionaryPath = paths.dictionary;
|
|
153
114
|
const templatePath = paths.template;
|
|
154
115
|
const changedFiles = [];
|
|
155
|
-
const generatedFiles = generatedFilesForSync(sys);
|
|
156
116
|
const [hasConstant, hasDictionary] = await Promise.all([sys.exists(constantPath), sys.exists(dictionaryPath)]);
|
|
157
|
-
if (!hasConstant)
|
|
158
|
-
diagnostics.push(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
if (!hasDictionary) {
|
|
165
|
-
diagnostics.push({
|
|
166
|
-
severity: "error",
|
|
167
|
-
code: "primitive-source-missing",
|
|
168
|
-
message: `Dictionary source file was not found: ${dictionaryPath}.`
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
if (diagnostics.some((diagnostic) => diagnostic.severity === "error")) {
|
|
172
|
-
return createPrimitiveWriteReport({
|
|
173
|
-
command: enumValues ? "add-enum-field" : "add-field",
|
|
174
|
-
changedFiles,
|
|
175
|
-
generatedFiles,
|
|
176
|
-
validationCommands: validationCommandsForTarget(sys.name),
|
|
177
|
-
diagnostics,
|
|
178
|
-
nextActions: nextActionsForTarget(sys.name)
|
|
179
|
-
});
|
|
180
|
-
}
|
|
117
|
+
if (!hasConstant)
|
|
118
|
+
diagnostics.push(PrimitiveScript.#sourceMissing("Constant", constantPath));
|
|
119
|
+
if (!hasDictionary)
|
|
120
|
+
diagnostics.push(PrimitiveScript.#sourceMissing("Dictionary", dictionaryPath));
|
|
121
|
+
if (workflowStatus(diagnostics) === "failed")
|
|
122
|
+
return PrimitiveScript.#report(command, sys, changedFiles, diagnostics);
|
|
181
123
|
let constantContent = await sys.readFile(constantPath);
|
|
182
124
|
let dictionaryContent = await sys.readFile(dictionaryPath);
|
|
183
125
|
const fieldBuilderName = viaBuilderParameterName(constantContent, inputClassName) ?? "field";
|
|
@@ -315,7 +257,7 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
315
257
|
}
|
|
316
258
|
}
|
|
317
259
|
}
|
|
318
|
-
if (
|
|
260
|
+
if (workflowStatus(diagnostics) === "passed" && nextConstantContentWithLight && nextDictionaryContent) {
|
|
319
261
|
await sys.writeFile(constantPath, nextConstantContentWithLight);
|
|
320
262
|
await sys.writeFile(dictionaryPath, nextDictionaryContent);
|
|
321
263
|
changedFiles.push(sourceFile(sys, constantPath, "modify", "Field source shape was updated."), sourceFile(sys, dictionaryPath, "modify", "Field dictionary labels were updated."));
|
|
@@ -324,14 +266,7 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
324
266
|
changedFiles.push(sourceFile(sys, templatePath, "modify", "Template field surface was updated."));
|
|
325
267
|
}
|
|
326
268
|
}
|
|
327
|
-
return
|
|
328
|
-
command: enumValues ? "add-enum-field" : "add-field",
|
|
329
|
-
changedFiles,
|
|
330
|
-
generatedFiles,
|
|
331
|
-
validationCommands: validationCommandsForTarget(sys.name),
|
|
332
|
-
diagnostics,
|
|
333
|
-
nextActions: nextActionsForTarget(sys.name)
|
|
334
|
-
});
|
|
269
|
+
return PrimitiveScript.#report(command, sys, changedFiles, diagnostics);
|
|
335
270
|
}
|
|
336
271
|
async addMutation(workspace, input) {
|
|
337
272
|
const moduleClassName = input.module ? moduleComponentName(input.module) : "";
|
|
@@ -405,60 +340,21 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
405
340
|
async#writeServiceSignalEntry(workspace, spec) {
|
|
406
341
|
const sys = await this.resolveSys(workspace, spec.app);
|
|
407
342
|
const diagnostics = compactDiagnostics([
|
|
408
|
-
!sys &&
|
|
409
|
-
!spec.module &&
|
|
410
|
-
|
|
411
|
-
code: "primitive-input-missing",
|
|
412
|
-
message: "Module is required.",
|
|
413
|
-
input: "module"
|
|
414
|
-
},
|
|
415
|
-
!spec.entryName && {
|
|
416
|
-
severity: "error",
|
|
417
|
-
code: "primitive-input-missing",
|
|
418
|
-
message: `${capitalize(spec.requiredInput)} name is required.`,
|
|
419
|
-
input: spec.requiredInput
|
|
420
|
-
}
|
|
343
|
+
!sys && PrimitiveScript.#targetMissing(),
|
|
344
|
+
!spec.module && PrimitiveScript.#inputMissing("module"),
|
|
345
|
+
!spec.entryName && PrimitiveScript.#inputMissing(spec.requiredInput, `${capitalize(spec.requiredInput)} name is required.`)
|
|
421
346
|
]);
|
|
422
|
-
if (!sys || !spec.module || !spec.entryName || !spec.serviceMethod || !spec.signal)
|
|
423
|
-
return
|
|
424
|
-
|
|
425
|
-
changedFiles: [],
|
|
426
|
-
generatedFiles: [],
|
|
427
|
-
validationCommands: [],
|
|
428
|
-
diagnostics,
|
|
429
|
-
nextActions: []
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
const paths = moduleSourcePaths(spec.module);
|
|
433
|
-
const servicePath = paths.service;
|
|
434
|
-
const signalPath = paths.signal;
|
|
347
|
+
if (!sys || !spec.module || !spec.entryName || !spec.serviceMethod || !spec.signal)
|
|
348
|
+
return PrimitiveScript.#refuse(spec.command, diagnostics);
|
|
349
|
+
const { service: servicePath, signal: signalPath } = moduleSourcePaths(spec.module);
|
|
435
350
|
const changedFiles = [];
|
|
436
|
-
const generatedFiles = generatedFilesForSync(sys);
|
|
437
351
|
const [hasServiceFile, hasSignalFile] = await Promise.all([sys.exists(servicePath), sys.exists(signalPath)]);
|
|
438
|
-
if (!hasServiceFile)
|
|
439
|
-
diagnostics.push(
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
if (!hasSignalFile) {
|
|
446
|
-
diagnostics.push({
|
|
447
|
-
severity: "error",
|
|
448
|
-
code: "primitive-source-missing",
|
|
449
|
-
message: `Signal source file was not found: ${signalPath}.`
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
if (diagnostics.some((diagnostic) => diagnostic.severity === "error")) {
|
|
453
|
-
return createPrimitiveWriteReport({
|
|
454
|
-
command: spec.command,
|
|
455
|
-
changedFiles,
|
|
456
|
-
generatedFiles,
|
|
457
|
-
validationCommands: validationCommandsForTarget(sys.name),
|
|
458
|
-
diagnostics,
|
|
459
|
-
nextActions: nextActionsForTarget(sys.name)
|
|
460
|
-
});
|
|
461
|
-
}
|
|
352
|
+
if (!hasServiceFile)
|
|
353
|
+
diagnostics.push(PrimitiveScript.#sourceMissing("Service", servicePath));
|
|
354
|
+
if (!hasSignalFile)
|
|
355
|
+
diagnostics.push(PrimitiveScript.#sourceMissing("Signal", signalPath));
|
|
356
|
+
if (workflowStatus(diagnostics) === "failed")
|
|
357
|
+
return PrimitiveScript.#report(spec.command, sys, changedFiles, diagnostics);
|
|
462
358
|
const serviceClassName = `${moduleComponentName(spec.module)}Service`;
|
|
463
359
|
const serviceContent = await sys.readFile(servicePath);
|
|
464
360
|
const signalContent = await sys.readFile(signalPath);
|
|
@@ -520,20 +416,46 @@ class PrimitiveScript extends script("primitive", [ModuleScript]) {
|
|
|
520
416
|
message: `Edited ${signalPath} did not contain entry "${spec.entryName}" in ${spec.signal.className}.`
|
|
521
417
|
});
|
|
522
418
|
}
|
|
523
|
-
if (
|
|
419
|
+
if (workflowStatus(diagnostics) === "passed" && nextServiceContent && nextSignalContent) {
|
|
524
420
|
await sys.writeFile(servicePath, nextServiceContent);
|
|
525
421
|
await sys.writeFile(signalPath, nextSignalContent);
|
|
526
422
|
changedFiles.push(sourceFile(sys, servicePath, "modify", `Service ${spec.entryKind} was added.`), sourceFile(sys, signalPath, "modify", `Signal ${spec.entryKind} was added.`));
|
|
527
423
|
}
|
|
424
|
+
return PrimitiveScript.#report(spec.command, sys, changedFiles, diagnostics);
|
|
425
|
+
}
|
|
426
|
+
static #refuse(command, diagnostics) {
|
|
427
|
+
return createPrimitiveWriteReport({
|
|
428
|
+
command,
|
|
429
|
+
changedFiles: [],
|
|
430
|
+
generatedFiles: [],
|
|
431
|
+
validationCommands: [],
|
|
432
|
+
diagnostics,
|
|
433
|
+
nextActions: []
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
static #report(command, sys, changedFiles, diagnostics) {
|
|
528
437
|
return createPrimitiveWriteReport({
|
|
529
|
-
command
|
|
438
|
+
command,
|
|
530
439
|
changedFiles,
|
|
531
|
-
generatedFiles,
|
|
440
|
+
generatedFiles: generatedFilesForSync(sys),
|
|
532
441
|
validationCommands: validationCommandsForTarget(sys.name),
|
|
533
442
|
diagnostics,
|
|
534
443
|
nextActions: nextActionsForTarget(sys.name)
|
|
535
444
|
});
|
|
536
445
|
}
|
|
446
|
+
static #targetMissing() {
|
|
447
|
+
return { severity: "error", code: "primitive-target-missing", message: "Target app or library was not found." };
|
|
448
|
+
}
|
|
449
|
+
static #inputMissing(input, message = `${capitalize(input)} is required.`) {
|
|
450
|
+
return { severity: "error", code: "primitive-input-missing", message, input };
|
|
451
|
+
}
|
|
452
|
+
static #sourceMissing(kind, path) {
|
|
453
|
+
return {
|
|
454
|
+
severity: "error",
|
|
455
|
+
code: "primitive-source-missing",
|
|
456
|
+
message: `${kind} source file was not found: ${path}.`
|
|
457
|
+
};
|
|
458
|
+
}
|
|
537
459
|
}
|
|
538
460
|
|
|
539
461
|
export { PrimitiveScript };
|