@akanjs/cli 3.2.0-rc.6 → 3.2.0-rc.8

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.
Files changed (81) hide show
  1. package/.build-stamp +2 -2
  2. package/{CodeAgent-aq43sq64.js → CodeAgent-x2p3a3e0.js} +2 -2
  3. package/{CodeTui-pmychb3m.js → CodeTui-qstk5vpj.js} +1 -1
  4. package/README.ko.md +26 -1
  5. package/README.md +26 -1
  6. package/TunnelShare-c4xsfzg5.js +15 -0
  7. package/{agent.command-pdmb75bk.js → agent.command-9et2e27p.js} +19 -18
  8. package/akanCode.js +2 -2
  9. package/{application.command-xwch7rww.js → application.command-m4rq4wc2.js} +23 -16
  10. package/{applicationBuildRunner-6yjrxfqs.js → applicationBuildRunner-df7rx3ra.js} +7 -6
  11. package/buildBatch.proc.js +7 -6
  12. package/{cloud.command-g9k7zb5s.js → cloud.command-a0gy0qq2.js} +21 -22
  13. package/cloud.script-xze4zh7n.js +31 -0
  14. package/{code.command-ceyhrgrc.js → code.command-5rsdqw8s.js} +7 -6
  15. package/{context.command-n7dbh0ca.js → context.command-rk1dwrg4.js} +18 -17
  16. package/context.runner-83ky5m1b.js +30 -0
  17. package/{guideline.command-h5dfzrng.js → guideline.command-mffxknbr.js} +3 -2
  18. package/guidelines/mcpRule/mcpRule.instruction.md +9 -0
  19. package/incrementalBuilder.proc.js +5 -4
  20. package/{index-bza4z89k.js → index-0gg15zwa.js} +4 -4
  21. package/{index-t0a5mng5.js → index-0hbtve0a.js} +10 -9
  22. package/{index-mtxbw4fy.js → index-28x1aszt.js} +13 -10
  23. package/{index-mcdezskv.js → index-2mf1aen9.js} +2 -2
  24. package/{index-g6ss1r1w.js → index-2r9ff9qm.js} +1 -1
  25. package/{index-z0r6bhqe.js → index-2vgv7fs7.js} +98 -18
  26. package/{index-dnqznx16.js → index-34792nh7.js} +1 -1
  27. package/{index-0fq1b5jp.js → index-3ghdb7p5.js} +9 -15
  28. package/{index-y9xbhs20.js → index-43f4h4cm.js} +3 -3
  29. package/{index-8bh9en9m.js → index-5radqwn2.js} +9 -9
  30. package/{index-dtxntsfx.js → index-5zwr4n6k.js} +1 -1
  31. package/{index-yp6mpazs.js → index-99qvtff2.js} +3 -3
  32. package/{index-df0r4008.js → index-an76bdrv.js} +1 -1
  33. package/{index-ggzb32a9.js → index-exn38bzx.js} +106 -69
  34. package/{index-y1a7dc7t.js → index-gcx48get.js} +1 -1
  35. package/{index-2b3n00gz.js → index-grxs6fts.js} +27 -17
  36. package/{index-h4xv44b2.js → index-gxav1bjz.js} +7 -7
  37. package/{index-ttrrm805.js → index-hqv34wzq.js} +4 -4
  38. package/{index-2m6gaatn.js → index-j3v29pq7.js} +78 -43
  39. package/index-j4yvgfhr.js +70 -0
  40. package/{index-n0vev0fv.js → index-j6gc8n14.js} +2 -2
  41. package/{index-kj7vyjng.js → index-j9790rhk.js} +67 -77
  42. package/{index-xzscbgx2.js → index-k92x3vne.js} +1 -1
  43. package/{index-qx12c8k5.js → index-nmvhjn8c.js} +1 -1
  44. package/{index-146p5x0r.js → index-ra9fvn7s.js} +6 -4
  45. package/{index-9km2h20g.js → index-rfzp4pqs.js} +2 -2
  46. package/{index-3wvc8cfa.js → index-rp4yf32g.js} +43 -4
  47. package/{index-80yc5q5y.js → index-skmtj8rm.js} +13 -6
  48. package/{index-w0nztbs0.js → index-swwjakt0.js} +3 -3
  49. package/{index-v50xjbbe.js → index-t4d0ckde.js} +1 -1
  50. package/{index-p9f6dsf2.js → index-vm0dn0mt.js} +3 -4
  51. package/{index-qtcm6s8p.js → index-w8yasvpc.js} +3 -3
  52. package/{index-wnxc9n5v.js → index-x40bdsca.js} +4 -4
  53. package/{index-36dywqhv.js → index-xvk2a75m.js} +2 -2
  54. package/{index-1xfdzwrt.js → index-xyn02k0w.js} +4 -4
  55. package/{index-fq72hk0a.js → index-yckz5t8b.js} +2 -2
  56. package/index.js +24 -23
  57. package/{library.command-4c2yjfqa.js → library.command-bmd7zc5m.js} +4 -3
  58. package/{localRegistry.command-ef65g36k.js → localRegistry.command-y6en1599.js} +16 -15
  59. package/{module.command-c6284z1b.js → module.command-7exfffqw.js} +6 -5
  60. package/{package.command-3wh1hh2j.js → package.command-adskw2rj.js} +5 -4
  61. package/package.json +2 -2
  62. package/{page.command-sx22j4yv.js → page.command-dw01272p.js} +4 -3
  63. package/{pipeline.command-8kdcgy47.js → pipeline.command-0b1r3y5r.js} +3 -2
  64. package/{primitive.command-4jaegn0m.js → primitive.command-byw6vc04.js} +7 -6
  65. package/{projectTypecheck-t0r9argb.js → projectTypecheck-kkrpq60a.js} +2 -1
  66. package/{quality.command-46jhrbm2.js → quality.command-6rqnhzct.js} +6 -5
  67. package/{repair.command-dj4ke29k.js → repair.command-rw5zymak.js} +6 -5
  68. package/{scalar.command-qwvbhytf.js → scalar.command-2dyp9nh9.js} +5 -4
  69. package/skills/akan-debug/SKILL.md +1 -1
  70. package/skills/akan-mcp/SKILL.md +2 -1
  71. package/skills/akan-scaffold/SKILL.md +1 -1
  72. package/skills/akan-validate/SKILL.md +1 -0
  73. package/{subspace.command-hg0hqscf.js → subspace.command-111ynwv1.js} +9 -8
  74. package/{tunnel.command-00v81x42.js → tunnel.command-2gcpfbdj.js} +8 -7
  75. package/typecheck.proc.js +5 -2
  76. package/{verify.command-sz542tvy.js → verify.command-djgs86ma.js} +17 -15
  77. package/{workflow.command-0ra9304f.js → workflow.command-n0k2mxr5.js} +30 -16
  78. package/{workspace.command-zvnybhr6.js → workspace.command-fh1qwxfx.js} +31 -30
  79. package/TunnelShare-11a3fqxb.js +0 -14
  80. package/cloud.script-jttgtbch.js +0 -30
  81. package/context.runner-9d5rbt2p.js +0 -29
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  AppExecutor
4
- } from "./index-0fq1b5jp.js";
4
+ } from "./index-3ghdb7p5.js";
5
5
  import {
6
6
  buildResourceList,
7
7
  codexMcpConfigPath,
@@ -11,23 +11,23 @@ import {
11
11
  upsertCodexMcpServerBlock,
12
12
  renderDoctorText,
13
13
  AkanContextAnalyzer
14
- } from "./index-fq72hk0a.js";
14
+ } from "./index-yckz5t8b.js";
15
15
  import {
16
16
  jsonText,
17
17
  workflowStatus,
18
18
  createWorkflowBaselineSummary,
19
19
  buildAkanModuleContextIndex,
20
20
  toolingRolloutGate
21
- } from "./index-z0r6bhqe.js";
21
+ } from "./index-2vgv7fs7.js";
22
22
  import {
23
23
  runner
24
- } from "./index-ggzb32a9.js";
24
+ } from "./index-exn38bzx.js";
25
25
  import {
26
26
  NativeApp
27
- } from "./index-y9xbhs20.js";
27
+ } from "./index-43f4h4cm.js";
28
28
  import {
29
29
  isPlaceholderAppId
30
- } from "./index-df0r4008.js";
30
+ } from "./index-an76bdrv.js";
31
31
  import {
32
32
  getMobileTargets,
33
33
  appIdsOf
@@ -40,15 +40,29 @@ import {
40
40
  } from "./index-39jz41jb.js";
41
41
  import {
42
42
  RepairRunner
43
- } from "./index-yp6mpazs.js";
43
+ } from "./index-99qvtff2.js";
44
44
  import {
45
45
  WorkflowRunner
46
- } from "./index-8bh9en9m.js";
46
+ } from "./index-5radqwn2.js";
47
47
 
48
48
  // pkgs/@akanjs/devkit/akanMcpContract.ts
49
49
  import { lstatSync, realpathSync } from "fs";
50
50
  import path from "path";
51
51
  import { isRecord } from "akanjs/common";
52
+
53
+ // pkgs/@akanjs/devkit/akanMcpToolError.ts
54
+ import { AkanError } from "akanjs/base";
55
+
56
+ class AkanMcpToolError extends AkanError {
57
+ constructor(code, message) {
58
+ super(code, message, { statusCode: 400 });
59
+ }
60
+ static failureOf(error) {
61
+ return AkanError.is(error) ? { code: error.code, statusCode: error.statusCode } : { code: "toolFailed", statusCode: 500 };
62
+ }
63
+ }
64
+
65
+ // pkgs/@akanjs/devkit/akanMcpContract.ts
52
66
  var emptySchema = { type: "object", properties: {} };
53
67
  var stringProperty = { type: "string" };
54
68
  var booleanProperty = { type: "boolean" };
@@ -174,7 +188,7 @@ var workflowArtifactPath = (workspace, filePath) => {
174
188
  const root = path.resolve(workspace.workspaceRoot, workflowArtifactDir);
175
189
  const resolved = workflowRunIdPattern.test(filePath) && !filePath.endsWith(".json") ? path.join(root, "runs", `${filePath}.json`) : path.resolve(workspace.workspaceRoot, filePath);
176
190
  if (!isInside(root, resolved) || !staysInside(workspace.workspaceRoot, root, resolved))
177
- throw new Error(`MCP workflow files live under ${workflowArtifactDir}/ of the workspace, not ${JSON.stringify(filePath)}.`);
191
+ throw new AkanMcpToolError("invalidArgument", `MCP workflow files live under ${workflowArtifactDir}/ of the workspace, not ${JSON.stringify(filePath)}.`);
178
192
  return resolved;
179
193
  };
180
194
  var defaultWorkflowPlanPath = (workflow, inputs) => {
@@ -208,7 +222,7 @@ var applyFirstPolicy = {
208
222
  var stringArg = (args, key) => {
209
223
  const value = args[key];
210
224
  if (typeof value !== "string" || !value)
211
- throw new Error(`MCP tool argument "${key}" is required.`);
225
+ throw new AkanMcpToolError("invalidArgument", `MCP tool argument "${key}" is required.`);
212
226
  return value;
213
227
  };
214
228
  var workflowInputsArg = (args) => {
@@ -221,14 +235,14 @@ var inspectAkanContextPropsArg = (args) => {
221
235
  const question = stringArg(args, "question");
222
236
  const review = stringArg(args, "review");
223
237
  if (!isRecord(args.draft))
224
- throw new Error('MCP tool argument "draft" is required.');
238
+ throw new AkanMcpToolError("invalidArgument", 'MCP tool argument "draft" is required.');
225
239
  if (!isRecord(args.request))
226
- throw new Error('MCP tool argument "request" is required.');
240
+ throw new AkanMcpToolError("invalidArgument", 'MCP tool argument "request" is required.');
227
241
  if (!isInspectAkanContextRequestType(args.draft.type)) {
228
- throw new Error('MCP tool argument "draft.type" must be a supported inspect_akan_context request type.');
242
+ throw new AkanMcpToolError("invalidArgument", 'MCP tool argument "draft.type" must be a supported inspect_akan_context request type.');
229
243
  }
230
244
  if (!isInspectAkanContextRequestType(args.request.type)) {
231
- throw new Error('MCP tool argument "request.type" must be a supported inspect_akan_context request type.');
245
+ throw new AkanMcpToolError("invalidArgument", 'MCP tool argument "request.type" must be a supported inspect_akan_context request type.');
232
246
  }
233
247
  const base = { question, draft: { reason: stringArg(args.draft, "reason"), type: args.draft.type }, review };
234
248
  const request = args.request;
@@ -356,7 +370,7 @@ var planMcpTools = [
356
370
  var applyMcpTools = [
357
371
  {
358
372
  name: "apply_workflow",
359
- description: "Apply a stored workflow plan before direct edits and return validationTarget, plus next.tool=run_validation unless the apply failed.",
373
+ description: "Apply a stored workflow plan before direct edits and return validationTarget. Unless it failed, next.tool is run_validation after an apply and apply_workflow without dryRun after a dry run.",
360
374
  inputSchema: {
361
375
  type: "object",
362
376
  properties: { planPath: stringProperty, dryRun: booleanProperty },
@@ -597,10 +611,24 @@ var inspectAkanContext = async (workspace, args) => {
597
611
  };
598
612
 
599
613
  // pkgs/@akanjs/cli/context/context.runner.ts
614
+ import { MCP_FAILURE_META } from "akanjs/common";
600
615
  var toolErrorText = (error) => {
601
616
  const message = error instanceof Error ? error.message : String(error);
602
617
  return message.replace(/\/(?:[^\s"'/]+\/)*(?=(?:pkgs|apps|libs|infra)\/)/g, "<workspace>/");
603
618
  };
619
+ var assertMcpToolListed = (name, mode) => {
620
+ const isListed = (tools) => tools.some((tool) => tool.name === name);
621
+ if (!isListed(listAkanMcpTools("apply")))
622
+ throw new AkanMcpToolError("unknownTool", `Unknown tool: ${name}`);
623
+ if (!isListed(listAkanMcpTools(mode)))
624
+ throw new AkanMcpToolError("toolUnavailable", `MCP tool "${name}" is not available in ${mode} mode.`);
625
+ };
626
+ var guidelineOf = async (name) => {
627
+ const guidelines = await Prompter2.listGuidelines();
628
+ if (!guidelines.includes(name))
629
+ throw new AkanMcpToolError("invalidArgument", `Unknown guideline "${name}". Available: ${guidelines.join(", ")}`);
630
+ return await Prompter2.getInstruction(name);
631
+ };
604
632
  var compactDoctorWorkspaceResult = (result, includeBaselineDetails) => {
605
633
  const baselineDiagnostics = result.baselineDiagnostics ?? [];
606
634
  const baselineSummary = createWorkflowBaselineSummary(baselineDiagnostics.map(({ severity, code, message, scope, context }) => ({
@@ -716,10 +744,7 @@ class ContextRunner2 extends runner("context") {
716
744
  return listAkanMcpTools(mode, { guidelineNames });
717
745
  }
718
746
  async callMcpTool(workspace, name, args = {}, { mode = "readonly" } = {}) {
719
- const availableTools = this.listMcpTools(mode);
720
- if (!availableTools.some((tool) => tool.name === name)) {
721
- throw new Error(`MCP tool "${name}" is not available in ${mode} mode.`);
722
- }
747
+ assertMcpToolListed(name, mode);
723
748
  if (name === "inspect_akan_context")
724
749
  return await inspectAkanContext(workspace, args);
725
750
  if (name === "get_workspace_summary" || name === "list_apps" || name === "list_modules" || name === "get_module_context") {
@@ -765,7 +790,7 @@ class ContextRunner2 extends runner("context") {
765
790
  return typeof args.since === "string" ? WorkspaceGraph.answerChanges(await WorkspaceGraph.changes(workspace, args.since), scope) : WorkspaceGraph.answer(await WorkspaceGraph.build(workspace), scope);
766
791
  }
767
792
  if (name === "get_guideline")
768
- return await Prompter2.getInstruction(stringArg(args, "name"));
793
+ return await guidelineOf(stringArg(args, "name"));
769
794
  if (name === "doctor_workspace")
770
795
  return compactDoctorWorkspaceResult(await AkanContextAnalyzer.doctor(workspace, {
771
796
  strict: !!args.strict,
@@ -795,21 +820,8 @@ class ContextRunner2 extends runner("context") {
795
820
  policy: applyFirstPolicy
796
821
  };
797
822
  }
798
- if (name === "apply_workflow") {
799
- const report = parseJsonOutput(await new WorkflowRunner().apply(workflowArtifactPath(workspace, stringArg(args, "planPath")), {
800
- format: "json",
801
- dryRun: !!args.dryRun,
802
- workspace,
803
- registry: WorkflowRunner.stepRegistry(workspace)
804
- }));
805
- const validationTarget = typeof report.validationTarget === "string" ? report.validationTarget : typeof report.applyReportPath === "string" ? report.applyReportPath : stringArg(args, "planPath");
806
- return {
807
- ...report,
808
- validationTarget,
809
- ...report.status === "failed" ? {} : { next: { tool: "run_validation", args: { runIdOrPlan: validationTarget } } },
810
- policy: applyFirstPolicy
811
- };
812
- }
823
+ if (name === "apply_workflow")
824
+ return await this.#applyWorkflow(workspace, args);
813
825
  if (name === "run_validation")
814
826
  return parseJsonOutput(await new WorkflowRunner().validate(workflowArtifactPath(workspace, stringArg(args, "runIdOrPlan")), {
815
827
  format: "json",
@@ -833,7 +845,36 @@ class ContextRunner2 extends runner("context") {
833
845
  module: stringArg(args, "module"),
834
846
  format: "json"
835
847
  }));
836
- throw new Error(`Unknown tool: ${name}`);
848
+ throw new AkanMcpToolError("unknownTool", `Unknown tool: ${name}`);
849
+ }
850
+ async answerMcpTool(workspace, name, args, { mode = "readonly" } = {}) {
851
+ try {
852
+ const result = await this.callMcpTool(workspace, name, args, { mode });
853
+ const text = typeof result === "string" ? result : jsonText(result, { trailingNewline: false });
854
+ return { content: [{ type: "text", text }] };
855
+ } catch (error) {
856
+ return {
857
+ content: [{ type: "text", text: toolErrorText(error) }],
858
+ isError: true,
859
+ _meta: { [MCP_FAILURE_META]: AkanMcpToolError.failureOf(error) }
860
+ };
861
+ }
862
+ }
863
+ async#applyWorkflow(workspace, args) {
864
+ const planPath = stringArg(args, "planPath");
865
+ const report = parseJsonOutput(await new WorkflowRunner().apply(workflowArtifactPath(workspace, planPath), {
866
+ format: "json",
867
+ dryRun: !!args.dryRun,
868
+ workspace,
869
+ registry: WorkflowRunner.stepRegistry(workspace)
870
+ }));
871
+ const validationTarget = typeof report.validationTarget === "string" ? report.validationTarget : typeof report.applyReportPath === "string" ? report.applyReportPath : planPath;
872
+ return {
873
+ ...report,
874
+ validationTarget,
875
+ ...report.status === "failed" ? {} : args.dryRun ? { next: { tool: "apply_workflow", args: { planPath } } } : { next: { tool: "run_validation", args: { runIdOrPlan: validationTarget } } },
876
+ policy: applyFirstPolicy
877
+ };
837
878
  }
838
879
  async runMcp(workspace, { mode = "readonly" } = {}) {
839
880
  const decoder = new TextDecoder;
@@ -897,13 +938,7 @@ ${payload}`);
897
938
  } else if (request.method === "tools/call") {
898
939
  const name = params.name;
899
940
  const args = params.arguments ?? {};
900
- try {
901
- const result = await this.callMcpTool(workspace, name, args, { mode });
902
- const text = typeof result === "string" ? result : jsonText(result, { trailingNewline: false });
903
- respond(request.id, { content: [{ type: "text", text }] }, framing);
904
- } catch (error) {
905
- respond(request.id, { content: [{ type: "text", text: toolErrorText(error) }], isError: true }, framing);
906
- }
941
+ respond(request.id, await this.answerMcpTool(workspace, name, args, { mode }), framing);
907
942
  } else if (request.method === "resources/list") {
908
943
  respond(request.id, { resources }, framing);
909
944
  } else if (request.method === "resources/read") {
@@ -0,0 +1,70 @@
1
+ // @bun
2
+ // pkgs/@akanjs/devkit/commandDecorators/cliError.ts
3
+ import { AkanError } from "akanjs/base";
4
+
5
+ class CliError extends AkanError {
6
+ static exitCodes = {
7
+ failed: 1,
8
+ usage: 2,
9
+ unknownTarget: 2,
10
+ refused: 2,
11
+ checkFailed: 3,
12
+ interrupted: 130
13
+ };
14
+ static usageCodes = ["usage", "unknownTarget"];
15
+ exitCode;
16
+ constructor(code, message, { exitCode, cause } = {}) {
17
+ super(code, message, { cause });
18
+ this.exitCode = exitCode ?? CliError.#exitCodeOfCode(code) ?? 1;
19
+ }
20
+ static failureCodeOf(error) {
21
+ if (AkanError.is(error))
22
+ return error.code;
23
+ return CliError.#isPromptExit(error) ? "interrupted" : "failed";
24
+ }
25
+ static exitCodeOf(error) {
26
+ if (error instanceof CliError)
27
+ return error.exitCode;
28
+ const code = CliError.failureCodeOf(error);
29
+ return code === "failed" ? null : CliError.#exitCodeOfCode(code);
30
+ }
31
+ static messageOf(error) {
32
+ if (error instanceof Error)
33
+ return error.message || error.name;
34
+ if (typeof error === "string")
35
+ return error.trim() || "Unknown error";
36
+ if (error === null || error === undefined)
37
+ return "Unknown error";
38
+ try {
39
+ const json = JSON.stringify(error);
40
+ if (json)
41
+ return json;
42
+ } catch {
43
+ return String(error);
44
+ }
45
+ return String(error) || "Unknown error";
46
+ }
47
+ static failureOf(error) {
48
+ return { ok: false, error: CliError.messageOf(error), code: CliError.failureCodeOf(error) };
49
+ }
50
+ static #exitCodeOfCode(code) {
51
+ return Object.hasOwn(CliError.exitCodes, code) ? CliError.exitCodes[code] : null;
52
+ }
53
+ static #isPromptExit(error) {
54
+ return error instanceof Error && error.name === "ExitPromptError";
55
+ }
56
+ }
57
+
58
+ // pkgs/@akanjs/devkit/typecheck/typecheckFailure.ts
59
+ class TypecheckFailure extends CliError {
60
+ records;
61
+ static workerExitCode = 3;
62
+ constructor(records) {
63
+ super("checkFailed", records.slice(0, 20).map((record) => `${record.file ?? "-"}:${record.line}:${record.col} ${record.code} ${record.message}`).join(`
64
+ `) || "Typecheck failed");
65
+ this.records = records;
66
+ this.name = "TypecheckFailure";
67
+ }
68
+ }
69
+
70
+ export { CliError, TypecheckFailure };
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-ggzb32a9.js";
5
+ } from "./index-exn38bzx.js";
6
6
  import {
7
7
  LibSource,
8
8
  formatLibStatuses,
9
9
  CommandExecutionError,
10
10
  LibExecutor
11
- } from "./index-0fq1b5jp.js";
11
+ } from "./index-3ghdb7p5.js";
12
12
  import {
13
13
  assertPlainName
14
14
  } from "./index-va90m8nd.js";