@akanjs/cli 3.1.1-rc.15 → 3.1.1-rc.16

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 (71) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-gtwn7tmb.js → CodeAgent-23ewzxqa.js} +2 -2
  3. package/{CodeTui-v941fqdh.js → CodeTui-kc99fk78.js} +1 -1
  4. package/TunnelShare-dk2gw78d.js +14 -0
  5. package/{agent.command-h82gepwn.js → agent.command-knp5j7bq.js} +5 -5
  6. package/akanCode.js +2 -2
  7. package/{application.command-j1reb9p1.js → application.command-bvfd1680.js} +9 -9
  8. package/{applicationBuildRunner-w20x63mz.js → applicationBuildRunner-4ajaesk1.js} +6 -5
  9. package/buildBatch.proc.js +5 -5
  10. package/{cloud.command-zd2mfkm0.js → cloud.command-f2w40fyy.js} +13 -13
  11. package/cloud.script-2r82sv0f.js +24 -0
  12. package/{code.command-dyet4xn6.js → code.command-dbhhnahn.js} +6 -6
  13. package/{context.command-79gxczm4.js → context.command-yswjwv6y.js} +17 -16
  14. package/context.runner-c3wsh2jw.js +26 -0
  15. package/{guideline.command-xwkskvky.js → guideline.command-ztx6dkpk.js} +2 -2
  16. package/guidelines/conventions/conventions.instruction.md +56 -10
  17. package/incrementalBuilder.proc.js +3 -3
  18. package/{index-yknrmkmt.js → index-005dqc83.js} +2 -2
  19. package/{index-qmeh0s05.js → index-00ke4phc.js} +2 -2
  20. package/{index-hdzjaq7s.js → index-2epb3wgh.js} +2 -2
  21. package/{index-rshwdv9w.js → index-2p1brf5e.js} +2 -2
  22. package/{index-wvvwdzfw.js → index-4332q6yj.js} +3 -3
  23. package/{index-6pzt55w3.js → index-4t4qb8jg.js} +3 -3
  24. package/{index-7ktk2hnz.js → index-76jwsm3g.js} +2 -2
  25. package/{index-tzzs52h0.js → index-7ndgffg4.js} +9 -9
  26. package/{index-1e2955yd.js → index-921cxqrd.js} +3 -1
  27. package/{index-8jb5ep2e.js → index-97fsvy66.js} +2 -2
  28. package/{index-pc9ps0hx.js → index-9sa6abze.js} +8 -8
  29. package/{index-jjd97ya6.js → index-deeskxjh.js} +1 -1
  30. package/{index-cz9g85xh.js → index-er16p89s.js} +1 -1
  31. package/{index-ygy8c12j.js → index-gxj80jz7.js} +1 -1
  32. package/index-hvg3esm0.js +1844 -0
  33. package/{index-41d3zx66.js → index-k9k18vq9.js} +3 -3
  34. package/{index-nmy1rana.js → index-m54n0v29.js} +4 -4
  35. package/index-m5n3ka0p.js +18 -0
  36. package/{index-brpk7gd8.js → index-m6qgr1rx.js} +7 -7
  37. package/{index-553xyb55.js → index-m93qg20j.js} +1 -1
  38. package/{index-4rwfh2de.js → index-mk391h0z.js} +3 -3
  39. package/{index-ch1sv7ke.js → index-nzfgyw3b.js} +9 -21
  40. package/{index-2qzzp0c9.js → index-p2pahmsa.js} +3 -3
  41. package/{index-kbbyzs6j.js → index-qx4r4cj2.js} +2 -2
  42. package/index-rxse80x6.js +408 -0
  43. package/{index-kr62ph5a.js → index-s4c2y5gs.js} +2 -2
  44. package/{index-jtydvvq7.js → index-saj9cx3a.js} +4 -4
  45. package/index-vgt25eh1.js +615 -0
  46. package/{index-8rvwgd1r.js → index-vq77g679.js} +1 -1
  47. package/{index-xeh7m2j5.js → index-xfp4dcnx.js} +1 -1
  48. package/{index-pqdz7rat.js → index-xjwcp91m.js} +910 -36
  49. package/{index-7abjzny1.js → index-ysyt782g.js} +33 -37
  50. package/index.js +22 -22
  51. package/{library.command-td8t85kb.js → library.command-hmbkcwzw.js} +3 -3
  52. package/{localRegistry.command-jx9zkmxf.js → localRegistry.command-sq5p4c9x.js} +15 -13
  53. package/{module.command-j70mqgpp.js → module.command-n4z29zcv.js} +5 -5
  54. package/{package.command-1b1v6k5v.js → package.command-20025dy3.js} +3 -3
  55. package/package.json +2 -2
  56. package/{page.command-m31w2tsz.js → page.command-q8fvpjer.js} +3 -3
  57. package/{pipeline.command-q7b8wy55.js → pipeline.command-8j97fq88.js} +2 -2
  58. package/{primitive.command-4zrbhkb9.js → primitive.command-e5y6dqp1.js} +6 -6
  59. package/{projectTypecheck-synx6qff.js → projectTypecheck-tbdye9k3.js} +1 -1
  60. package/{quality.command-cy0pgqjz.js → quality.command-168pt5vm.js} +621 -311
  61. package/{repair.command-98n6zxg7.js → repair.command-dq1gckth.js} +5 -5
  62. package/{scalar.command-rak5pjk3.js → scalar.command-5vwf152w.js} +4 -4
  63. package/{subspace.command-ej0rk116.js → subspace.command-182be8vj.js} +8 -8
  64. package/{tunnel.command-kdx3amrc.js → tunnel.command-bfzj7xkb.js} +7 -7
  65. package/{workflow.command-gffk9nj9.js → workflow.command-3g53242s.js} +37 -13
  66. package/workspace.command-h7399jwv.js +260 -0
  67. package/TunnelShare-26ty9skr.js +0 -14
  68. package/cloud.script-vdj8ymch.js +0 -24
  69. package/context.runner-ejag7mhr.js +0 -25
  70. package/index-y5m4j2w6.js +0 -856
  71. package/workspace.command-097hv6n1.js +0 -521
@@ -5,7 +5,7 @@ import {
5
5
  McpServerConfig,
6
6
  McpSignIn,
7
7
  AkanCodeCompaction2
8
- } from "./index-jjd97ya6.js";
8
+ } from "./index-deeskxjh.js";
9
9
  import {
10
10
  stripAnsi
11
11
  } from "./index-7md2g9vw.js";
@@ -809,7 +809,7 @@ class AkanToolPack2 {
809
809
  return { name: "akan-tools", factory: async (pi) => await this.#register(pi) };
810
810
  }
811
811
  async names() {
812
- const { ContextRunner } = await import("./context.runner-ejag7mhr.js");
812
+ const { ContextRunner } = await import("./context.runner-c3wsh2jw.js");
813
813
  return [
814
814
  ...new ContextRunner().listMcpTools(this.#options.mode).map((tool) => tool.name),
815
815
  AkanToolPack2.verifyToolName
@@ -817,7 +817,7 @@ class AkanToolPack2 {
817
817
  }
818
818
  static verifyToolName = "akan_verify";
819
819
  async#register(pi) {
820
- const { ContextRunner } = await import("./context.runner-ejag7mhr.js");
820
+ const { ContextRunner } = await import("./context.runner-c3wsh2jw.js");
821
821
  const runner = new ContextRunner;
822
822
  const guidelineNames = await AkanToolPack2.#guidelineNames();
823
823
  for (const tool of runner.listMcpTools(this.#options.mode, { guidelineNames })) {
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-qmeh0s05.js";
5
+ } from "./index-00ke4phc.js";
6
6
  import {
7
7
  ModuleExecutor
8
- } from "./index-1e2955yd.js";
8
+ } from "./index-921cxqrd.js";
9
9
  import {
10
10
  sourceFile,
11
11
  moduleSourcePaths,
@@ -13,10 +13,10 @@ import {
13
13
  createPassedPrimitiveReport,
14
14
  bilingualLabelForField,
15
15
  bilingualDescriptionForField
16
- } from "./index-pqdz7rat.js";
16
+ } from "./index-xjwcp91m.js";
17
17
  import {
18
18
  PageScript
19
- } from "./index-ygy8c12j.js";
19
+ } from "./index-gxj80jz7.js";
20
20
  import {
21
21
  pluralizeName
22
22
  } from "./index-nz8prx9g.js";
@@ -0,0 +1,18 @@
1
+ // @bun
2
+ // pkgs/@akanjs/cli/npmRegistry.ts
3
+ var defaultNpmRegistry = "https://registry.npmjs.org";
4
+ var getNpmRegistryUrl = (registryUrl = process.env.AKAN_NPM_REGISTRY ?? defaultNpmRegistry) => registryUrl.replace(/\/+$/, "");
5
+ async function getLatestPackageVersion(packageName, tag = "latest", registryUrl) {
6
+ const registry = getNpmRegistryUrl(registryUrl);
7
+ const url = `${registry}/${encodeURIComponent(packageName).replace(/^%40/, "@")}`;
8
+ const res = await fetch(url);
9
+ if (!res.ok)
10
+ throw new Error(`Failed to fetch ${packageName} metadata from ${registry}`);
11
+ const metadata = await res.json();
12
+ const version = metadata["dist-tags"]?.[tag];
13
+ if (!version)
14
+ throw new Error(`No npm dist-tag "${tag}" found for ${packageName}`);
15
+ return version;
16
+ }
17
+
18
+ export { getNpmRegistryUrl, getLatestPackageVersion };
@@ -4,27 +4,27 @@ import {
4
4
  CloudApi,
5
5
  CloudUpdates,
6
6
  PipelineSecrets
7
- } from "./index-7ktk2hnz.js";
7
+ } from "./index-76jwsm3g.js";
8
8
  import {
9
9
  PkgExecutor
10
- } from "./index-1e2955yd.js";
10
+ } from "./index-921cxqrd.js";
11
11
  import {
12
12
  UpdatePackFolder,
13
13
  NativePublicEnv,
14
14
  NativeApp
15
- } from "./index-2qzzp0c9.js";
15
+ } from "./index-p2pahmsa.js";
16
16
  import {
17
17
  script
18
- } from "./index-qmeh0s05.js";
18
+ } from "./index-00ke4phc.js";
19
19
  import {
20
20
  ApplicationScript
21
- } from "./index-tzzs52h0.js";
21
+ } from "./index-7ndgffg4.js";
22
22
  import {
23
23
  PackageScript
24
- } from "./index-hdzjaq7s.js";
24
+ } from "./index-2epb3wgh.js";
25
25
  import {
26
26
  CloudRunner
27
- } from "./index-ch1sv7ke.js";
27
+ } from "./index-nzfgyw3b.js";
28
28
 
29
29
  // pkgs/@akanjs/cli/cloud/cloud.script.ts
30
30
  import { Logger } from "akanjs/common";
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  AppInfo
4
- } from "./index-1e2955yd.js";
4
+ } from "./index-921cxqrd.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/slicePlanner.ts
7
7
  class SlicePlanner {
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  resolveSsrPageEntriesForApp
4
- } from "./index-1e2955yd.js";
4
+ } from "./index-921cxqrd.js";
5
5
  import {
6
6
  computeRouteSeedIndex,
7
7
  saveRouteSeedIndex,
@@ -9,7 +9,7 @@ import {
9
9
  ClientEntriesBundler,
10
10
  VENDOR_SPECIFIERS,
11
11
  RouteClientBuilder
12
- } from "./index-8jb5ep2e.js";
12
+ } from "./index-97fsvy66.js";
13
13
  import {
14
14
  SOURCE_EXTS
15
15
  } from "./index-5nd1wtkv.js";
@@ -19,7 +19,7 @@ import {
19
19
  createTsconfigPackageResolver,
20
20
  rewriteBarrelImports,
21
21
  PagesBundleBuilder
22
- } from "./index-cz9g85xh.js";
22
+ } from "./index-er16p89s.js";
23
23
  import {
24
24
  CssBlockParser
25
25
  } from "./index-62md4dwy.js";
@@ -6,44 +6,32 @@ import {
6
6
  CloudApi,
7
7
  CloudUpdates,
8
8
  PipelineSecrets
9
- } from "./index-7ktk2hnz.js";
9
+ } from "./index-76jwsm3g.js";
10
10
  import {
11
11
  resolveMobileTargets
12
12
  } from "./index-m9jj544v.js";
13
13
  import {
14
14
  WorkspaceExecutor,
15
15
  AppExecutor
16
- } from "./index-1e2955yd.js";
16
+ } from "./index-921cxqrd.js";
17
17
  import {
18
18
  NativeApp
19
- } from "./index-2qzzp0c9.js";
19
+ } from "./index-p2pahmsa.js";
20
20
  import {
21
21
  runner,
22
22
  assertPromptable
23
- } from "./index-qmeh0s05.js";
23
+ } from "./index-00ke4phc.js";
24
24
  import {
25
25
  SubspaceConfig
26
26
  } from "./index-4pf8g7ff.js";
27
+ import {
28
+ getNpmRegistryUrl,
29
+ getLatestPackageVersion
30
+ } from "./index-m5n3ka0p.js";
27
31
  import {
28
32
  openBrowser
29
33
  } from "./index-9dp031by.js";
30
34
 
31
- // pkgs/@akanjs/cli/npmRegistry.ts
32
- var defaultNpmRegistry = "https://registry.npmjs.org";
33
- var getNpmRegistryUrl = (registryUrl = process.env.AKAN_NPM_REGISTRY ?? defaultNpmRegistry) => registryUrl.replace(/\/+$/, "");
34
- async function getLatestPackageVersion(packageName, tag = "latest", registryUrl) {
35
- const registry = getNpmRegistryUrl(registryUrl);
36
- const url = `${registry}/${encodeURIComponent(packageName).replace(/^%40/, "@")}`;
37
- const res = await fetch(url);
38
- if (!res.ok)
39
- throw new Error(`Failed to fetch ${packageName} metadata from ${registry}`);
40
- const metadata = await res.json();
41
- const version = metadata["dist-tags"]?.[tag];
42
- if (!version)
43
- throw new Error(`No npm dist-tag "${tag}" found for ${packageName}`);
44
- return version;
45
- }
46
-
47
35
  // pkgs/@akanjs/cli/cloud/cloud.runner.ts
48
36
  import path7 from "path";
49
37
 
@@ -1327,4 +1315,4 @@ ${run.format(results)}
1327
1315
  }
1328
1316
  }
1329
1317
 
1330
- export { getNpmRegistryUrl, getLatestPackageVersion, PlatformTestRun, CloudRunner };
1318
+ export { PlatformTestRun, CloudRunner };
@@ -5,17 +5,17 @@ import {
5
5
  AkanAppConfig,
6
6
  Executor,
7
7
  WorkspaceExecutor
8
- } from "./index-1e2955yd.js";
8
+ } from "./index-921cxqrd.js";
9
9
  import {
10
10
  resolveAppId,
11
11
  targetHtmlFilename
12
12
  } from "./index-m9jj544v.js";
13
13
  import {
14
14
  CsrArtifactBuilder
15
- } from "./index-yknrmkmt.js";
15
+ } from "./index-005dqc83.js";
16
16
  import {
17
17
  ExitCodeError
18
- } from "./index-qmeh0s05.js";
18
+ } from "./index-00ke4phc.js";
19
19
 
20
20
  // pkgs/@akanjs/devkit/mobile/desktopBin.ts
21
21
  import { chmod, mkdir, rename, rm, writeFile } from "fs/promises";
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-qmeh0s05.js";
5
+ } from "./index-00ke4phc.js";
6
6
  import {
7
7
  generatedFilesForSync,
8
8
  createPassedPrimitiveReport,
9
9
  scalarChangedFiles
10
- } from "./index-pqdz7rat.js";
10
+ } from "./index-xjwcp91m.js";
11
11
  import {
12
12
  pluralizeName
13
13
  } from "./index-nz8prx9g.js";
@@ -0,0 +1,408 @@
1
+ // @bun
2
+ import {
3
+ WorkspaceExecutor
4
+ } from "./index-921cxqrd.js";
5
+ import {
6
+ jsonText,
7
+ workflowPlanApproval,
8
+ createWorkflowApplyReport,
9
+ workflowCommandsForPlan,
10
+ workflowPathsForPlan,
11
+ writeWorkflowRunArtifact,
12
+ readWorkflowRunArtifact,
13
+ createWorkflowBaselineSummary,
14
+ createWorkflowValidationRunReport,
15
+ createDryRunWorkflowApplyReport,
16
+ createWorkflowStepRegistry,
17
+ WorkflowExecutor,
18
+ listWorkflowSpecs,
19
+ getWorkflowSpec,
20
+ compactWorkflowInputs,
21
+ createWorkflowPlan,
22
+ inspectWorkflowPlan,
23
+ renderWorkflowList,
24
+ renderWorkflowExplain,
25
+ renderWorkflowPlan,
26
+ renderWorkflowApply,
27
+ renderWorkflowValidation,
28
+ renderWorkflowRunArtifact
29
+ } from "./index-xjwcp91m.js";
30
+ import {
31
+ AkanContextAnalyzer
32
+ } from "./index-s4c2y5gs.js";
33
+ import {
34
+ CommandContainer,
35
+ runner
36
+ } from "./index-00ke4phc.js";
37
+ import {
38
+ ModuleScript
39
+ } from "./index-m54n0v29.js";
40
+ import {
41
+ PrimitiveScript
42
+ } from "./index-ysyt782g.js";
43
+ import {
44
+ spawnShell
45
+ } from "./index-4332q6yj.js";
46
+ import {
47
+ ScalarScript
48
+ } from "./index-qx4r4cj2.js";
49
+ import {
50
+ workflowSpecs
51
+ } from "./index-vgt25eh1.js";
52
+
53
+ // pkgs/@akanjs/cli/workflow/workflow.runner.ts
54
+ import { mkdir, readFile, writeFile } from "fs/promises";
55
+ import path from "path";
56
+ import { isRecord } from "akanjs/common";
57
+ var resolvePath = (filePath) => path.isAbsolute(filePath) ? filePath : path.join(process.cwd(), filePath);
58
+ var isWorkflowPlan = (value) => {
59
+ if (!isRecord(value))
60
+ return false;
61
+ return value.schemaVersion === 1 && value.mode === "plan" && typeof value.workflow === "string";
62
+ };
63
+ var isWorkflowApplyReport = (value) => {
64
+ if (!isRecord(value))
65
+ return false;
66
+ return value.schemaVersion === 1 && (value.mode === "apply" || value.mode === "dry-run") && isWorkflowPlan(value.plan);
67
+ };
68
+ var isWorkflowRunArtifact = (value) => {
69
+ if (!isRecord(value))
70
+ return false;
71
+ return value.schemaVersion === 1 && (typeof value.mode === "string" || typeof value.command === "string");
72
+ };
73
+ var failedPlan = (workflow, diagnostics) => ({
74
+ schemaVersion: 1,
75
+ workflow,
76
+ mode: "plan",
77
+ inputs: {},
78
+ optionalSurfaces: {},
79
+ steps: [],
80
+ predictedChanges: [],
81
+ validation: [],
82
+ diagnostics,
83
+ recommendations: [],
84
+ requiresApproval: true,
85
+ approval: workflowPlanApproval
86
+ });
87
+ var failedApplyReport = (workflow, code, message, plan) => {
88
+ const diagnostics = [{ severity: "error", code, message }];
89
+ return createWorkflowApplyReport({
90
+ workflow,
91
+ mode: "apply",
92
+ changedFiles: [],
93
+ generatedFiles: [],
94
+ commands: [],
95
+ diagnostics,
96
+ nextActions: [],
97
+ plan: plan ?? failedPlan(workflow, diagnostics)
98
+ });
99
+ };
100
+ var inferValidationKind = (command) => {
101
+ if (command.kind)
102
+ return command.kind;
103
+ if (/\bakan\s+sync\b/.test(command.command))
104
+ return "sync";
105
+ if (/\bakan\s+lint\b/.test(command.command))
106
+ return "lint";
107
+ if (/\bakan\s+typecheck\b/.test(command.command))
108
+ return "typecheck";
109
+ if (/\bakan\s+doctor\b/.test(command.command))
110
+ return "doctor";
111
+ return "custom";
112
+ };
113
+ var classifyValidationFailure = (command, error) => {
114
+ const output = `${error.stdout ?? ""}
115
+ ${error.stderr ?? ""}
116
+ ${error.message ?? ""}`.toLowerCase();
117
+ if (error.code === 127 || output.includes("command not found") || output.includes("bun: command not found")) {
118
+ return "environment";
119
+ }
120
+ if (output.includes("biome.json") || output.includes("biome configuration") || output.includes("configuration file") || output.includes("invalid configuration") || output.includes("failed to load")) {
121
+ return "workspace-config";
122
+ }
123
+ const kind = inferValidationKind(command);
124
+ if (kind === "lint" || kind === "typecheck" || kind === "sync")
125
+ return "source-change";
126
+ return "unknown";
127
+ };
128
+ var defaultValidationExecutor = (workspace) => async (command) => {
129
+ const base = { command: command.command, reason: command.reason, kind: inferValidationKind(command) };
130
+ try {
131
+ return { ...base, status: "passed", exitCode: 0, stdout: await spawnShell(workspace, command.command) };
132
+ } catch (error) {
133
+ const commandError = error;
134
+ return {
135
+ ...base,
136
+ status: "failed",
137
+ exitCode: commandError.code ?? 1,
138
+ failureScope: classifyValidationFailure(command, commandError),
139
+ stdout: commandError.stdout,
140
+ stderr: commandError.stderr ?? commandError.message
141
+ };
142
+ }
143
+ };
144
+ var readJsonFile = async (filePath) => JSON.parse(await readFile(resolvePath(filePath), "utf8"));
145
+ var workflowDiagnosticFromDoctor = ({
146
+ severity,
147
+ code,
148
+ message,
149
+ scope,
150
+ context
151
+ }, fallbackScope) => {
152
+ const resolvedScope = scope ?? fallbackScope;
153
+ const failureScope = resolvedScope === "baseline" ? "workspace-config" : resolvedScope === "workflow" ? "source-change" : "unknown";
154
+ return { severity, code, message, scope: resolvedScope, failureScope, context };
155
+ };
156
+ var baselineBlockerCachePath = (workflow) => `.akan/workflows/baseline/${workflow}.json`;
157
+ var blockerFingerprint = (blocker) => [blocker.failureScope, blocker.code, blocker.command ?? "", blocker.kind ?? "", blocker.message].join("|");
158
+ var applyBaselineBlockerCache = async (workspace, report) => {
159
+ const cacheableBlockers = report.knownBlockers.filter((blocker) => blocker.failureScope === "workspace-config" || blocker.failureScope === "environment");
160
+ if (cacheableBlockers.length === 0)
161
+ return report;
162
+ const cachePath = baselineBlockerCachePath(report.workflow);
163
+ const cached = (await workspace.exists(cachePath) ? await workspace.readJson(cachePath) : null) ?? { schemaVersion: 1, workflow: report.workflow, blockers: [] };
164
+ const knownFingerprints = new Set(cached.blockers.map((blocker) => blocker.fingerprint));
165
+ const now = new Date().toISOString();
166
+ const blockers = new Map(cached.blockers.map((blocker) => [blocker.fingerprint, blocker]));
167
+ for (const blocker of cacheableBlockers) {
168
+ const fingerprint = blockerFingerprint(blocker);
169
+ blockers.set(fingerprint, {
170
+ fingerprint,
171
+ code: blocker.code,
172
+ message: blocker.message,
173
+ failureScope: blocker.failureScope,
174
+ command: blocker.command,
175
+ kind: blocker.kind,
176
+ lastSeenAt: now
177
+ });
178
+ }
179
+ await workspace.writeFile(cachePath, jsonText({ schemaVersion: 1, workflow: report.workflow, blockers: [...blockers.values()] }), { silent: true });
180
+ const knownBlockers = report.knownBlockers.map((blocker) => {
181
+ if (!knownFingerprints.has(blockerFingerprint(blocker)))
182
+ return blocker;
183
+ return {
184
+ ...blocker,
185
+ known: true,
186
+ message: `Known baseline blocker, unrelated to this source change: ${blocker.message}`
187
+ };
188
+ });
189
+ return {
190
+ ...report,
191
+ knownBlockers,
192
+ baselineSummary: {
193
+ ...report.baselineSummary,
194
+ knownBlockerCount: knownBlockers.filter((blocker) => blocker.known).length
195
+ }
196
+ };
197
+ };
198
+ var withBaselineDetailsPolicy = (report, includeBaselineDetails) => {
199
+ const baselineDiagnostics = report.baselineDiagnostics ?? [];
200
+ return {
201
+ ...report,
202
+ baselineSummary: createWorkflowBaselineSummary(baselineDiagnostics, {
203
+ detailsIncluded: includeBaselineDetails,
204
+ knownBlockerCount: report.knownBlockers.filter((blocker) => blocker.known).length
205
+ }),
206
+ baselineDiagnostics: includeBaselineDetails ? baselineDiagnostics : []
207
+ };
208
+ };
209
+
210
+ class WorkflowRunner extends runner("workflow") {
211
+ static stepRegistry(workspace) {
212
+ return createWorkflowStepRegistry({
213
+ workspace,
214
+ createModule: (sys, module) => CommandContainer.get(ModuleScript).createModuleTemplate(sys, module),
215
+ createScalar: (sys, scalar) => CommandContainer.get(ScalarScript).createScalar(sys, scalar),
216
+ createUi: (input) => CommandContainer.get(PrimitiveScript).createUi(workspace, input),
217
+ addField: (input) => CommandContainer.get(PrimitiveScript).addField(workspace, input),
218
+ addEnumField: (input) => CommandContainer.get(PrimitiveScript).addEnumField(workspace, input),
219
+ addMutation: (input) => CommandContainer.get(PrimitiveScript).addMutation(workspace, input),
220
+ addSlice: (input) => CommandContainer.get(PrimitiveScript).addSlice(workspace, input),
221
+ createInteraction: (input) => CommandContainer.get(PrimitiveScript).createInteraction(workspace, input)
222
+ });
223
+ }
224
+ list({ format = "markdown" } = {}) {
225
+ const workflows = listWorkflowSpecs(workflowSpecs);
226
+ if (format === "json")
227
+ return jsonText({
228
+ schemaVersion: 1,
229
+ workflows: workflows.map(({ name, description, whenToUse, replacesRules = [] }) => ({
230
+ name,
231
+ description,
232
+ whenToUse,
233
+ replacesRules
234
+ }))
235
+ });
236
+ return renderWorkflowList(workflows);
237
+ }
238
+ explain(workflow, { format = "markdown" } = {}) {
239
+ const spec = getWorkflowSpec(workflowSpecs, workflow);
240
+ if (!spec)
241
+ throw new Error(`Unknown workflow: ${workflow}. Run \`akan workflow list\` to see available workflows.`);
242
+ return format === "json" ? jsonText(spec) : renderWorkflowExplain(spec);
243
+ }
244
+ async plan(workflow, inputs, {
245
+ format = "markdown",
246
+ out = null,
247
+ workspace
248
+ } = {}) {
249
+ const spec = getWorkflowSpec(workflowSpecs, workflow);
250
+ if (!spec)
251
+ throw new Error(`Unknown workflow: ${workflow}. Run \`akan workflow list\` to see available workflows.`);
252
+ const plan = await inspectWorkflowPlan(workspace ?? WorkspaceExecutor.fromRoot(), createWorkflowPlan(spec, compactWorkflowInputs(inputs)));
253
+ if (out) {
254
+ const outPath = resolvePath(out);
255
+ await mkdir(path.dirname(outPath), { recursive: true });
256
+ await writeFile(outPath, jsonText(plan));
257
+ }
258
+ return format === "json" ? jsonText(plan) : renderWorkflowPlan(plan);
259
+ }
260
+ async apply(planPath, {
261
+ dryRun = false,
262
+ format = "markdown",
263
+ registry,
264
+ workspace
265
+ } = {}) {
266
+ const renderApplyReport = async (report) => {
267
+ if (!workspace)
268
+ return renderWorkflowApply(report, format);
269
+ const { artifact } = await writeWorkflowRunArtifact(workspace, report);
270
+ return renderWorkflowApply(artifact, format);
271
+ };
272
+ let plan;
273
+ try {
274
+ const parsed = await readJsonFile(planPath);
275
+ if (!isWorkflowPlan(parsed))
276
+ return await renderApplyReport(failedApplyReport("unknown", "workflow-plan-invalid", `Workflow plan file is invalid: ${planPath}.`));
277
+ plan = parsed;
278
+ } catch (error) {
279
+ const message = `Could not read workflow plan file: ${planPath}. ${error instanceof Error ? error.message : ""}`;
280
+ return await renderApplyReport(failedApplyReport("unknown", "workflow-plan-read-failed", message.trim()));
281
+ }
282
+ const spec = getWorkflowSpec(workflowSpecs, plan.workflow);
283
+ if (!spec) {
284
+ const message = `Unknown workflow in plan: ${plan.workflow}.`;
285
+ return await renderApplyReport(failedApplyReport(plan.workflow, "workflow-unknown", message, plan));
286
+ }
287
+ if (dryRun)
288
+ return await renderApplyReport(createDryRunWorkflowApplyReport(plan));
289
+ if (!registry) {
290
+ const message = "Workflow apply requires a step runner registry.";
291
+ return await renderApplyReport(failedApplyReport(plan.workflow, "workflow-registry-missing", message, plan));
292
+ }
293
+ return await renderApplyReport(await new WorkflowExecutor(registry, workspace).apply(plan));
294
+ }
295
+ async validate(runIdOrPlan, {
296
+ format = "markdown",
297
+ workspace,
298
+ execute,
299
+ includeBaselineDetails = false
300
+ }) {
301
+ const loaded = await this.loadValidationTarget(runIdOrPlan, workspace);
302
+ const doctor = await AkanContextAnalyzer.doctor(workspace, {
303
+ strict: true,
304
+ runIdOrPlan,
305
+ changedFiles: loaded.changedFiles
306
+ });
307
+ const report = withBaselineDetailsPolicy(await applyBaselineBlockerCache(workspace, await createWorkflowValidationRunReport({
308
+ workflow: loaded.plan?.workflow ?? loaded.workflow,
309
+ source: loaded.source,
310
+ plan: loaded.plan,
311
+ commands: loaded.commands,
312
+ execute: execute ?? defaultValidationExecutor(workspace),
313
+ diagnostics: loaded.diagnostics,
314
+ baselineDiagnostics: (doctor.baselineDiagnostics ?? []).map((diagnostic) => workflowDiagnosticFromDoctor(diagnostic, "baseline")),
315
+ workflowDiagnostics: (doctor.workflowDiagnostics ?? []).map((diagnostic) => workflowDiagnosticFromDoctor(diagnostic, "workflow")),
316
+ repairActions: loaded.repairActions
317
+ })), includeBaselineDetails);
318
+ await writeWorkflowRunArtifact(workspace, report);
319
+ return renderWorkflowValidation(report, format);
320
+ }
321
+ async report(runId, { format = "markdown", workspace }) {
322
+ try {
323
+ return renderWorkflowRunArtifact(await readWorkflowRunArtifact(workspace, runId), format);
324
+ } catch (error) {
325
+ const report = await createWorkflowValidationRunReport({
326
+ runId,
327
+ workflow: "unknown",
328
+ source: { type: "run-report", runId },
329
+ commands: [],
330
+ execute: async (command) => ({
331
+ command: command.command,
332
+ reason: command.reason,
333
+ status: "failed",
334
+ exitCode: 1
335
+ }),
336
+ diagnostics: [
337
+ {
338
+ severity: "error",
339
+ code: "workflow-run-read-failed",
340
+ message: `Could not read workflow run report: ${runId}. ${error instanceof Error ? error.message : ""}`.trim()
341
+ }
342
+ ]
343
+ });
344
+ return renderWorkflowValidation(report, format);
345
+ }
346
+ }
347
+ async loadValidationTarget(runIdOrPlan, workspace) {
348
+ const unreadable = (code, message) => ({
349
+ workflow: "unknown",
350
+ source: { type: "run-report", runId: runIdOrPlan },
351
+ plan: undefined,
352
+ commands: [],
353
+ diagnostics: [{ severity: "error", code, message }],
354
+ changedFiles: [],
355
+ repairActions: []
356
+ });
357
+ const loadFromArtifact = (artifact, sourcePath) => {
358
+ if (isWorkflowApplyReport(artifact)) {
359
+ return {
360
+ workflow: artifact.workflow,
361
+ source: { type: "apply-report", path: sourcePath, runId: artifact.runId },
362
+ plan: artifact.plan,
363
+ commands: artifact.recommendedValidationCommands.length ? artifact.recommendedValidationCommands : workflowCommandsForPlan(artifact.plan),
364
+ diagnostics: artifact.diagnostics,
365
+ changedFiles: artifact.changedFiles.map((file) => file.path),
366
+ repairActions: []
367
+ };
368
+ }
369
+ if ("mode" in artifact && artifact.mode === "validate") {
370
+ return {
371
+ workflow: artifact.workflow,
372
+ source: { type: "run-report", runId: artifact.runId },
373
+ plan: artifact.plan,
374
+ commands: artifact.plan ? workflowCommandsForPlan(artifact.plan) : [],
375
+ diagnostics: artifact.diagnostics,
376
+ changedFiles: [],
377
+ repairActions: artifact.repairActions
378
+ };
379
+ }
380
+ return unreadable("workflow-validation-source-unsupported", `Workflow validation source is not supported: ${runIdOrPlan}.`);
381
+ };
382
+ try {
383
+ const parsed = await readJsonFile(runIdOrPlan);
384
+ if (isWorkflowPlan(parsed)) {
385
+ return {
386
+ workflow: parsed.workflow,
387
+ source: { type: "plan", path: resolvePath(runIdOrPlan) },
388
+ plan: parsed,
389
+ commands: workflowCommandsForPlan(parsed),
390
+ diagnostics: parsed.diagnostics,
391
+ changedFiles: workflowPathsForPlan(parsed),
392
+ repairActions: []
393
+ };
394
+ }
395
+ if (isWorkflowRunArtifact(parsed))
396
+ return loadFromArtifact(parsed, resolvePath(runIdOrPlan));
397
+ } catch {}
398
+ try {
399
+ const artifact = await readWorkflowRunArtifact(workspace, runIdOrPlan);
400
+ return loadFromArtifact(artifact, runIdOrPlan);
401
+ } catch (error) {
402
+ const message = `Could not read workflow validation source: ${runIdOrPlan}. ${error instanceof Error ? error.message : ""}`;
403
+ return unreadable("workflow-validation-source-read-failed", message.trim());
404
+ }
405
+ }
406
+ }
407
+
408
+ export { WorkflowRunner };
@@ -10,7 +10,7 @@ import {
10
10
  isScannedRootEntry,
11
11
  AppExecutor,
12
12
  LibExecutor
13
- } from "./index-1e2955yd.js";
13
+ } from "./index-921cxqrd.js";
14
14
  import {
15
15
  FileSys2
16
16
  } from "./index-52w0fvh8.js";
@@ -23,7 +23,7 @@ import {
23
23
  workflowPathsForPlan,
24
24
  workflowRunArtifactPath,
25
25
  workflowSyncDir
26
- } from "./index-pqdz7rat.js";
26
+ } from "./index-xjwcp91m.js";
27
27
 
28
28
  // pkgs/@akanjs/devkit/akanContext.ts
29
29
  import { readdir } from "fs/promises";
@@ -1,16 +1,16 @@
1
1
  // @bun
2
2
  import {
3
3
  jsonText
4
- } from "./index-pqdz7rat.js";
4
+ } from "./index-xjwcp91m.js";
5
5
  import {
6
6
  akanMcpInstallTargets
7
- } from "./index-kr62ph5a.js";
7
+ } from "./index-s4c2y5gs.js";
8
8
  import {
9
9
  script
10
- } from "./index-qmeh0s05.js";
10
+ } from "./index-00ke4phc.js";
11
11
  import {
12
12
  ContextRunner2
13
- } from "./index-pc9ps0hx.js";
13
+ } from "./index-9sa6abze.js";
14
14
 
15
15
  // pkgs/@akanjs/cli/context/context.script.ts
16
16
  import { Logger } from "akanjs/common";