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

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 (120) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-gtwn7tmb.js → CodeAgent-fbcq8vks.js} +2 -2
  3. package/{CodeTui-v941fqdh.js → CodeTui-0626gxqd.js} +1 -1
  4. package/TunnelShare-2p24xxza.js +14 -0
  5. package/agent.command-hpza0pg9.js +46 -0
  6. package/akanCode.js +5 -3
  7. package/{application.command-j1reb9p1.js → application.command-3a7q1hs2.js} +11 -10
  8. package/{applicationBuildRunner-w20x63mz.js → applicationBuildRunner-s7yt71j4.js} +6 -5
  9. package/buildBatch.proc.js +6 -6
  10. package/{cloud.command-zd2mfkm0.js → cloud.command-4vg0pcea.js} +15 -14
  11. package/cloud.script-nkmeyhet.js +25 -0
  12. package/{code.command-dyet4xn6.js → code.command-fbntb67p.js} +6 -6
  13. package/commandManifest.json +1 -1
  14. package/{context.command-79gxczm4.js → context.command-31rm54v0.js} +18 -17
  15. package/context.runner-w01a32ph.js +26 -0
  16. package/{guideline.command-xwkskvky.js → guideline.command-cv3by2ng.js} +3 -3
  17. package/guidelines/conventions/core.md +104 -0
  18. package/guidelines/conventions/rules/app.md +83 -0
  19. package/guidelines/conventions/rules/auth.md +45 -0
  20. package/guidelines/conventions/rules/config.md +56 -0
  21. package/guidelines/conventions/rules/constant.md +24 -0
  22. package/guidelines/conventions/rules/gates.md +31 -0
  23. package/guidelines/conventions/rules/layer.md +25 -0
  24. package/guidelines/conventions/rules/migration.md +27 -0
  25. package/guidelines/conventions/rules/module.md +90 -0
  26. package/guidelines/conventions/rules/page.md +56 -0
  27. package/guidelines/conventions/rules/sensitive.md +16 -0
  28. package/guidelines/conventions/rules/server.md +86 -0
  29. package/guidelines/conventions/rules/ssr.md +47 -0
  30. package/guidelines/conventions/rules/style.md +43 -0
  31. package/guidelines/conventions/rules/test.md +34 -0
  32. package/guidelines/conventions/rules/ts.md +95 -0
  33. package/guidelines/conventions/rules/tsx.md +75 -0
  34. package/guidelines/mcpRule/mcpRule.instruction.md +1 -1
  35. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +3 -3
  36. package/incrementalBuilder.proc.js +6 -6
  37. package/{index-pqdz7rat.js → index-05nxx4m5.js} +952 -47
  38. package/{index-41d3zx66.js → index-0ht91675.js} +37 -59
  39. package/{index-cz9g85xh.js → index-0zwznvv1.js} +1 -1
  40. package/{index-7ktk2hnz.js → index-0zyatd10.js} +2 -2
  41. package/{index-8jb5ep2e.js → index-12kzwak1.js} +3 -3
  42. package/{index-yknrmkmt.js → index-1dhf8ymv.js} +2 -2
  43. package/{index-qmeh0s05.js → index-3gccwenr.js} +2 -2
  44. package/{index-hdzjaq7s.js → index-3txrjt6n.js} +2 -2
  45. package/{index-tzzs52h0.js → index-57q1ayd2.js} +18 -1240
  46. package/index-5kh9scvs.js +514 -0
  47. package/index-5n5hds19.js +1246 -0
  48. package/{index-pc9ps0hx.js → index-6269mf2s.js} +10 -9
  49. package/{index-1e2955yd.js → index-64g9fsjy.js} +43 -12
  50. package/index-7zeb5r1p.js +653 -0
  51. package/{index-kr62ph5a.js → index-8s8b4eba.js} +45 -4
  52. package/{index-wvvwdzfw.js → index-922k2zwq.js} +3 -3
  53. package/{index-brpk7gd8.js → index-9ndw5d8j.js} +7 -7
  54. package/{index-xeh7m2j5.js → index-et6ce601.js} +1 -1
  55. package/{index-jtydvvq7.js → index-f5adsa58.js} +4 -4
  56. package/index-fbewhg4g.js +590 -0
  57. package/{index-7abjzny1.js → index-hm7x0c11.js} +33 -37
  58. package/{index-rshwdv9w.js → index-hvv5rnaq.js} +2 -2
  59. package/index-jje9qzyq.js +27 -0
  60. package/index-js1gj6f6.js +410 -0
  61. package/{index-2qzzp0c9.js → index-kjrvwzav.js} +3 -3
  62. package/index-m5n3ka0p.js +18 -0
  63. package/index-m6r88hhr.js +3582 -0
  64. package/{index-4rwfh2de.js → index-mt0wa941.js} +4 -4
  65. package/{index-553xyb55.js → index-mwj9q2ya.js} +1 -1
  66. package/{index-5nd1wtkv.js → index-p6x5b7hr.js} +1 -1
  67. package/index-r2wedvqn.js +138 -0
  68. package/{index-ygy8c12j.js → index-rvynj5gz.js} +1 -1
  69. package/{index-nmy1rana.js → index-tdv66eah.js} +4 -4
  70. package/{index-8rvwgd1r.js → index-w134p86k.js} +1 -1
  71. package/{index-jjd97ya6.js → index-wfczhj1z.js} +14 -36
  72. package/{index-dy0jx9ay.js → index-wwe9rsrx.js} +14 -0
  73. package/{index-kbbyzs6j.js → index-x5ecanqh.js} +2 -2
  74. package/{index-ch1sv7ke.js → index-zre4m2ce.js} +9 -21
  75. package/index.js +23 -22
  76. package/{library.command-td8t85kb.js → library.command-sh70fyvy.js} +3 -3
  77. package/{localRegistry.command-jx9zkmxf.js → localRegistry.command-2nbyy84d.js} +17 -14
  78. package/{module.command-j70mqgpp.js → module.command-n0bmtzwy.js} +5 -5
  79. package/{package.command-1b1v6k5v.js → package.command-7h9r51bz.js} +3 -3
  80. package/package.json +2 -2
  81. package/{page.command-m31w2tsz.js → page.command-vjtpfbb1.js} +3 -3
  82. package/{pipeline.command-q7b8wy55.js → pipeline.command-c93se3ar.js} +2 -2
  83. package/{primitive.command-4zrbhkb9.js → primitive.command-a3075qp2.js} +6 -6
  84. package/{projectTypecheck-synx6qff.js → projectTypecheck-sf9xwaga.js} +1 -1
  85. package/{prompter-76k56b37.js → prompter-hgcta8pb.js} +1 -1
  86. package/quality.command-dw1y9hmy.js +76 -0
  87. package/{repair.command-98n6zxg7.js → repair.command-tg57d8yt.js} +5 -5
  88. package/{scalar.command-rak5pjk3.js → scalar.command-cwzge353.js} +4 -4
  89. package/skills/akan-agent/SKILL.md +36 -0
  90. package/skills/akan-debug/SKILL.md +3 -3
  91. package/skills/akan-deps/SKILL.md +1 -2
  92. package/skills/akan-mcp/SKILL.md +40 -0
  93. package/skills/akan-page/SKILL.md +44 -0
  94. package/skills/akan-query/SKILL.md +38 -0
  95. package/skills/akan-runtime/SKILL.md +40 -0
  96. package/skills/akan-scaffold/SKILL.md +16 -6
  97. package/skills/akan-transport/SKILL.md +40 -0
  98. package/skills/akan-validate/SKILL.md +13 -11
  99. package/{subspace.command-ej0rk116.js → subspace.command-3h03c7kc.js} +8 -8
  100. package/templates/workspaceRoot/.gitignore.template +3 -0
  101. package/templates/workspaceRoot/AGENTS.md.template +4 -10
  102. package/{tunnel.command-kdx3amrc.js → tunnel.command-czaz6ys4.js} +7 -7
  103. package/{typeChecker-px49mezc.js → typeChecker-j2jdnqsr.js} +1 -1
  104. package/typecheck.proc.js +6 -1
  105. package/verify.command-nzwhtz71.js +91 -0
  106. package/{workflow.command-gffk9nj9.js → workflow.command-srhky88x.js} +47 -13
  107. package/workspace.command-9stchcd2.js +262 -0
  108. package/TunnelShare-26ty9skr.js +0 -14
  109. package/agent.command-h82gepwn.js +0 -25
  110. package/cloud.script-vdj8ymch.js +0 -24
  111. package/context.runner-ejag7mhr.js +0 -25
  112. package/guidelines/conventions/conventions.instruction.md +0 -617
  113. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +0 -291
  114. package/index-6pzt55w3.js +0 -279
  115. package/index-y5m4j2w6.js +0 -856
  116. package/index-zzvvc845.js +0 -74
  117. package/quality.command-cy0pgqjz.js +0 -1478
  118. package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +0 -69
  119. package/templates/workspaceRoot/docs/GENERATED.md.template +0 -55
  120. package/workspace.command-097hv6n1.js +0 -521
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-qmeh0s05.js";
5
+ } from "./index-3gccwenr.js";
6
6
  import {
7
7
  LibSource,
8
8
  formatLibStatuses,
9
9
  CommandExecutionError,
10
10
  LibExecutor
11
- } from "./index-1e2955yd.js";
11
+ } from "./index-64g9fsjy.js";
12
12
 
13
13
  // pkgs/@akanjs/cli/library/library.script.ts
14
14
  import { Logger } from "akanjs/common";
@@ -0,0 +1,27 @@
1
+ // @bun
2
+ // pkgs/@akanjs/devkit/codeAgent/agent/akanCodePaths.ts
3
+ import { existsSync } from "fs";
4
+ import { homedir } from "os";
5
+ import path from "path";
6
+ var builtinSkillsDir = () => {
7
+ const candidates = [path.join(import.meta.dir, "skills"), path.join(import.meta.dir, "..", "skills")];
8
+ return candidates.find((candidate) => existsSync(candidate));
9
+ };
10
+ var globalDir = () => process.env.AKAN_CODE_HOME ?? path.join(homedir(), ".akan", "code");
11
+ var akanCodePaths2 = {
12
+ workspaceDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code"),
13
+ sessionsDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "sessions"),
14
+ extensionsDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "extensions"),
15
+ skillsDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "skills"),
16
+ mailDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "mail"),
17
+ builtinSkillsDir,
18
+ mcpFile: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "mcp.json"),
19
+ globalMcpFile: () => path.join(globalDir(), "mcp.json"),
20
+ globalSkillsDir: () => path.join(globalDir(), "skills"),
21
+ globalDir,
22
+ authFile: () => path.join(globalDir(), "auth.json"),
23
+ mcpAuthFile: () => path.join(globalDir(), "mcpAuth.json"),
24
+ modelsFile: () => path.join(globalDir(), "models.json")
25
+ };
26
+
27
+ export { akanCodePaths2 };
@@ -0,0 +1,410 @@
1
+ // @bun
2
+ import {
3
+ WorkspaceExecutor
4
+ } from "./index-64g9fsjy.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-05nxx4m5.js";
30
+ import {
31
+ AkanContextAnalyzer
32
+ } from "./index-8s8b4eba.js";
33
+ import {
34
+ CommandContainer,
35
+ runner
36
+ } from "./index-3gccwenr.js";
37
+ import {
38
+ ModuleScript
39
+ } from "./index-tdv66eah.js";
40
+ import {
41
+ PrimitiveScript
42
+ } from "./index-hm7x0c11.js";
43
+ import {
44
+ spawnShell
45
+ } from "./index-922k2zwq.js";
46
+ import {
47
+ ScalarScript
48
+ } from "./index-x5ecanqh.js";
49
+ import {
50
+ workflowSpecs
51
+ } from "./index-fbewhg4g.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+verify\b/.test(command.command))
104
+ return "verify";
105
+ if (/\bakan\s+sync\b/.test(command.command))
106
+ return "sync";
107
+ if (/\bakan\s+lint\b/.test(command.command))
108
+ return "lint";
109
+ if (/\bakan\s+typecheck\b/.test(command.command))
110
+ return "typecheck";
111
+ if (/\bakan\s+doctor\b/.test(command.command))
112
+ return "doctor";
113
+ return "custom";
114
+ };
115
+ var classifyValidationFailure = (command, error) => {
116
+ const output = `${error.stdout ?? ""}
117
+ ${error.stderr ?? ""}
118
+ ${error.message ?? ""}`.toLowerCase();
119
+ if (error.code === 127 || output.includes("command not found") || output.includes("bun: command not found")) {
120
+ return "environment";
121
+ }
122
+ if (output.includes("biome.json") || output.includes("biome configuration") || output.includes("configuration file") || output.includes("invalid configuration") || output.includes("failed to load")) {
123
+ return "workspace-config";
124
+ }
125
+ const kind = inferValidationKind(command);
126
+ if (kind === "verify" || kind === "lint" || kind === "typecheck" || kind === "sync")
127
+ return "source-change";
128
+ return "unknown";
129
+ };
130
+ var defaultValidationExecutor = (workspace) => async (command) => {
131
+ const base = { command: command.command, reason: command.reason, kind: inferValidationKind(command) };
132
+ try {
133
+ return { ...base, status: "passed", exitCode: 0, stdout: await spawnShell(workspace, command.command) };
134
+ } catch (error) {
135
+ const commandError = error;
136
+ return {
137
+ ...base,
138
+ status: "failed",
139
+ exitCode: commandError.code ?? 1,
140
+ failureScope: classifyValidationFailure(command, commandError),
141
+ stdout: commandError.stdout,
142
+ stderr: commandError.stderr ?? commandError.message
143
+ };
144
+ }
145
+ };
146
+ var readJsonFile = async (filePath) => JSON.parse(await readFile(resolvePath(filePath), "utf8"));
147
+ var workflowDiagnosticFromDoctor = ({
148
+ severity,
149
+ code,
150
+ message,
151
+ scope,
152
+ context
153
+ }, fallbackScope) => {
154
+ const resolvedScope = scope ?? fallbackScope;
155
+ const failureScope = resolvedScope === "baseline" ? "workspace-config" : resolvedScope === "workflow" ? "source-change" : "unknown";
156
+ return { severity, code, message, scope: resolvedScope, failureScope, context };
157
+ };
158
+ var baselineBlockerCachePath = (workflow) => `.akan/workflows/baseline/${workflow}.json`;
159
+ var blockerFingerprint = (blocker) => [blocker.failureScope, blocker.code, blocker.command ?? "", blocker.kind ?? "", blocker.message].join("|");
160
+ var applyBaselineBlockerCache = async (workspace, report) => {
161
+ const cacheableBlockers = report.knownBlockers.filter((blocker) => blocker.failureScope === "workspace-config" || blocker.failureScope === "environment");
162
+ if (cacheableBlockers.length === 0)
163
+ return report;
164
+ const cachePath = baselineBlockerCachePath(report.workflow);
165
+ const cached = (await workspace.exists(cachePath) ? await workspace.readJson(cachePath) : null) ?? { schemaVersion: 1, workflow: report.workflow, blockers: [] };
166
+ const knownFingerprints = new Set(cached.blockers.map((blocker) => blocker.fingerprint));
167
+ const now = new Date().toISOString();
168
+ const blockers = new Map(cached.blockers.map((blocker) => [blocker.fingerprint, blocker]));
169
+ for (const blocker of cacheableBlockers) {
170
+ const fingerprint = blockerFingerprint(blocker);
171
+ blockers.set(fingerprint, {
172
+ fingerprint,
173
+ code: blocker.code,
174
+ message: blocker.message,
175
+ failureScope: blocker.failureScope,
176
+ command: blocker.command,
177
+ kind: blocker.kind,
178
+ lastSeenAt: now
179
+ });
180
+ }
181
+ await workspace.writeFile(cachePath, jsonText({ schemaVersion: 1, workflow: report.workflow, blockers: [...blockers.values()] }), { silent: true });
182
+ const knownBlockers = report.knownBlockers.map((blocker) => {
183
+ if (!knownFingerprints.has(blockerFingerprint(blocker)))
184
+ return blocker;
185
+ return {
186
+ ...blocker,
187
+ known: true,
188
+ message: `Known baseline blocker, unrelated to this source change: ${blocker.message}`
189
+ };
190
+ });
191
+ return {
192
+ ...report,
193
+ knownBlockers,
194
+ baselineSummary: {
195
+ ...report.baselineSummary,
196
+ knownBlockerCount: knownBlockers.filter((blocker) => blocker.known).length
197
+ }
198
+ };
199
+ };
200
+ var withBaselineDetailsPolicy = (report, includeBaselineDetails) => {
201
+ const baselineDiagnostics = report.baselineDiagnostics ?? [];
202
+ return {
203
+ ...report,
204
+ baselineSummary: createWorkflowBaselineSummary(baselineDiagnostics, {
205
+ detailsIncluded: includeBaselineDetails,
206
+ knownBlockerCount: report.knownBlockers.filter((blocker) => blocker.known).length
207
+ }),
208
+ baselineDiagnostics: includeBaselineDetails ? baselineDiagnostics : []
209
+ };
210
+ };
211
+
212
+ class WorkflowRunner extends runner("workflow") {
213
+ static stepRegistry(workspace) {
214
+ return createWorkflowStepRegistry({
215
+ workspace,
216
+ createModule: (sys, module) => CommandContainer.get(ModuleScript).createModuleTemplate(sys, module),
217
+ createScalar: (sys, scalar) => CommandContainer.get(ScalarScript).createScalar(sys, scalar),
218
+ createUi: (input) => CommandContainer.get(PrimitiveScript).createUi(workspace, input),
219
+ addField: (input) => CommandContainer.get(PrimitiveScript).addField(workspace, input),
220
+ addEnumField: (input) => CommandContainer.get(PrimitiveScript).addEnumField(workspace, input),
221
+ addMutation: (input) => CommandContainer.get(PrimitiveScript).addMutation(workspace, input),
222
+ addSlice: (input) => CommandContainer.get(PrimitiveScript).addSlice(workspace, input),
223
+ createInteraction: (input) => CommandContainer.get(PrimitiveScript).createInteraction(workspace, input)
224
+ });
225
+ }
226
+ list({ format = "markdown" } = {}) {
227
+ const workflows = listWorkflowSpecs(workflowSpecs);
228
+ if (format === "json")
229
+ return jsonText({
230
+ schemaVersion: 1,
231
+ workflows: workflows.map(({ name, description, whenToUse, replacesRules = [] }) => ({
232
+ name,
233
+ description,
234
+ whenToUse,
235
+ replacesRules
236
+ }))
237
+ });
238
+ return renderWorkflowList(workflows);
239
+ }
240
+ explain(workflow, { format = "markdown" } = {}) {
241
+ const spec = getWorkflowSpec(workflowSpecs, workflow);
242
+ if (!spec)
243
+ throw new Error(`Unknown workflow: ${workflow}. Run \`akan workflow list\` to see available workflows.`);
244
+ return format === "json" ? jsonText(spec) : renderWorkflowExplain(spec);
245
+ }
246
+ async plan(workflow, inputs, {
247
+ format = "markdown",
248
+ out = null,
249
+ workspace
250
+ } = {}) {
251
+ const spec = getWorkflowSpec(workflowSpecs, workflow);
252
+ if (!spec)
253
+ throw new Error(`Unknown workflow: ${workflow}. Run \`akan workflow list\` to see available workflows.`);
254
+ const plan = await inspectWorkflowPlan(workspace ?? WorkspaceExecutor.fromRoot(), createWorkflowPlan(spec, compactWorkflowInputs(inputs)));
255
+ if (out) {
256
+ const outPath = resolvePath(out);
257
+ await mkdir(path.dirname(outPath), { recursive: true });
258
+ await writeFile(outPath, jsonText(plan));
259
+ }
260
+ return format === "json" ? jsonText(plan) : renderWorkflowPlan(plan);
261
+ }
262
+ async apply(planPath, {
263
+ dryRun = false,
264
+ format = "markdown",
265
+ registry,
266
+ workspace
267
+ } = {}) {
268
+ const renderApplyReport = async (report) => {
269
+ if (!workspace)
270
+ return renderWorkflowApply(report, format);
271
+ const { artifact } = await writeWorkflowRunArtifact(workspace, report);
272
+ return renderWorkflowApply(artifact, format);
273
+ };
274
+ let plan;
275
+ try {
276
+ const parsed = await readJsonFile(planPath);
277
+ if (!isWorkflowPlan(parsed))
278
+ return await renderApplyReport(failedApplyReport("unknown", "workflow-plan-invalid", `Workflow plan file is invalid: ${planPath}.`));
279
+ plan = parsed;
280
+ } catch (error) {
281
+ const message = `Could not read workflow plan file: ${planPath}. ${error instanceof Error ? error.message : ""}`;
282
+ return await renderApplyReport(failedApplyReport("unknown", "workflow-plan-read-failed", message.trim()));
283
+ }
284
+ const spec = getWorkflowSpec(workflowSpecs, plan.workflow);
285
+ if (!spec) {
286
+ const message = `Unknown workflow in plan: ${plan.workflow}.`;
287
+ return await renderApplyReport(failedApplyReport(plan.workflow, "workflow-unknown", message, plan));
288
+ }
289
+ if (dryRun)
290
+ return await renderApplyReport(createDryRunWorkflowApplyReport(plan));
291
+ if (!registry) {
292
+ const message = "Workflow apply requires a step runner registry.";
293
+ return await renderApplyReport(failedApplyReport(plan.workflow, "workflow-registry-missing", message, plan));
294
+ }
295
+ return await renderApplyReport(await new WorkflowExecutor(registry, workspace).apply(plan));
296
+ }
297
+ async validate(runIdOrPlan, {
298
+ format = "markdown",
299
+ workspace,
300
+ execute,
301
+ includeBaselineDetails = false
302
+ }) {
303
+ const loaded = await this.loadValidationTarget(runIdOrPlan, workspace);
304
+ const doctor = await AkanContextAnalyzer.doctor(workspace, {
305
+ strict: true,
306
+ runIdOrPlan,
307
+ changedFiles: loaded.changedFiles
308
+ });
309
+ const report = withBaselineDetailsPolicy(await applyBaselineBlockerCache(workspace, await createWorkflowValidationRunReport({
310
+ workflow: loaded.plan?.workflow ?? loaded.workflow,
311
+ source: loaded.source,
312
+ plan: loaded.plan,
313
+ commands: loaded.commands,
314
+ execute: execute ?? defaultValidationExecutor(workspace),
315
+ diagnostics: loaded.diagnostics,
316
+ baselineDiagnostics: (doctor.baselineDiagnostics ?? []).map((diagnostic) => workflowDiagnosticFromDoctor(diagnostic, "baseline")),
317
+ workflowDiagnostics: (doctor.workflowDiagnostics ?? []).map((diagnostic) => workflowDiagnosticFromDoctor(diagnostic, "workflow")),
318
+ repairActions: loaded.repairActions
319
+ })), includeBaselineDetails);
320
+ await writeWorkflowRunArtifact(workspace, report);
321
+ return renderWorkflowValidation(report, format);
322
+ }
323
+ async report(runId, { format = "markdown", workspace }) {
324
+ try {
325
+ return renderWorkflowRunArtifact(await readWorkflowRunArtifact(workspace, runId), format);
326
+ } catch (error) {
327
+ const report = await createWorkflowValidationRunReport({
328
+ runId,
329
+ workflow: "unknown",
330
+ source: { type: "run-report", runId },
331
+ commands: [],
332
+ execute: async (command) => ({
333
+ command: command.command,
334
+ reason: command.reason,
335
+ status: "failed",
336
+ exitCode: 1
337
+ }),
338
+ diagnostics: [
339
+ {
340
+ severity: "error",
341
+ code: "workflow-run-read-failed",
342
+ message: `Could not read workflow run report: ${runId}. ${error instanceof Error ? error.message : ""}`.trim()
343
+ }
344
+ ]
345
+ });
346
+ return renderWorkflowValidation(report, format);
347
+ }
348
+ }
349
+ async loadValidationTarget(runIdOrPlan, workspace) {
350
+ const unreadable = (code, message) => ({
351
+ workflow: "unknown",
352
+ source: { type: "run-report", runId: runIdOrPlan },
353
+ plan: undefined,
354
+ commands: [],
355
+ diagnostics: [{ severity: "error", code, message }],
356
+ changedFiles: [],
357
+ repairActions: []
358
+ });
359
+ const loadFromArtifact = (artifact, sourcePath) => {
360
+ if (isWorkflowApplyReport(artifact)) {
361
+ return {
362
+ workflow: artifact.workflow,
363
+ source: { type: "apply-report", path: sourcePath, runId: artifact.runId },
364
+ plan: artifact.plan,
365
+ commands: artifact.recommendedValidationCommands.length ? artifact.recommendedValidationCommands : workflowCommandsForPlan(artifact.plan),
366
+ diagnostics: artifact.diagnostics,
367
+ changedFiles: artifact.changedFiles.map((file) => file.path),
368
+ repairActions: []
369
+ };
370
+ }
371
+ if ("mode" in artifact && artifact.mode === "validate") {
372
+ return {
373
+ workflow: artifact.workflow,
374
+ source: { type: "run-report", runId: artifact.runId },
375
+ plan: artifact.plan,
376
+ commands: artifact.plan ? workflowCommandsForPlan(artifact.plan) : [],
377
+ diagnostics: artifact.diagnostics,
378
+ changedFiles: [],
379
+ repairActions: artifact.repairActions
380
+ };
381
+ }
382
+ return unreadable("workflow-validation-source-unsupported", `Workflow validation source is not supported: ${runIdOrPlan}.`);
383
+ };
384
+ try {
385
+ const parsed = await readJsonFile(runIdOrPlan);
386
+ if (isWorkflowPlan(parsed)) {
387
+ return {
388
+ workflow: parsed.workflow,
389
+ source: { type: "plan", path: resolvePath(runIdOrPlan) },
390
+ plan: parsed,
391
+ commands: workflowCommandsForPlan(parsed),
392
+ diagnostics: parsed.diagnostics,
393
+ changedFiles: workflowPathsForPlan(parsed),
394
+ repairActions: []
395
+ };
396
+ }
397
+ if (isWorkflowRunArtifact(parsed))
398
+ return loadFromArtifact(parsed, resolvePath(runIdOrPlan));
399
+ } catch {}
400
+ try {
401
+ const artifact = await readWorkflowRunArtifact(workspace, runIdOrPlan);
402
+ return loadFromArtifact(artifact, runIdOrPlan);
403
+ } catch (error) {
404
+ const message = `Could not read workflow validation source: ${runIdOrPlan}. ${error instanceof Error ? error.message : ""}`;
405
+ return unreadable("workflow-validation-source-read-failed", message.trim());
406
+ }
407
+ }
408
+ }
409
+
410
+ export { WorkflowRunner };
@@ -5,17 +5,17 @@ import {
5
5
  AkanAppConfig,
6
6
  Executor,
7
7
  WorkspaceExecutor
8
- } from "./index-1e2955yd.js";
8
+ } from "./index-64g9fsjy.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-1dhf8ymv.js";
16
16
  import {
17
17
  ExitCodeError
18
- } from "./index-qmeh0s05.js";
18
+ } from "./index-3gccwenr.js";
19
19
 
20
20
  // pkgs/@akanjs/devkit/mobile/desktopBin.ts
21
21
  import { chmod, mkdir, rename, rm, writeFile } from "fs/promises";
@@ -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 };