@akanjs/cli 3.0.0-alpha.8 → 3.0.0-alpha.80
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/README.ko.md +1 -1
- package/README.md +1 -1
- package/{abstractCompactor-e5yq60qz.js → abstractCompactor-pwc6d6yk.js} +3 -5
- package/{agent.command-pggr92jj.js → agent.command-180hh0ye.js} +11 -12
- package/{application.command-692yap1d.js → application.command-gmcgen9y.js} +59 -35
- package/{applicationBuildRunner-ha3y8ew8.js → applicationBuildRunner-tavpx3fv.js} +22 -20
- package/{applicationReleasePackager-gg8ccbeh.js → applicationReleasePackager-ktjt0erc.js} +8 -9
- package/buildBatch.proc.js +12 -13
- package/capacitorApp-kwa67kzs.js +12 -0
- package/{cloud.command-wqfsyzv2.js → cloud.command-gpq7qxrc.js} +15 -17
- package/commandManifest.json +1 -1
- package/{context.command-9bxtdn0w.js → context.command-dk2m2sjx.js} +19 -22
- package/dependencyScanner-c64m6fxp.js +8 -0
- package/fleet.command-3bkyyd3a.js +836 -0
- package/getDirname-dr3jz1xg.js +7 -0
- package/{guideline.command-nfqahxex.js → guideline.command-w6ddv13r.js} +16 -17
- package/guidelines/agentRule/agentRule.generate.json +31 -0
- package/guidelines/agentRule/agentRule.instruction.md +525 -0
- package/guidelines/conventions/conventions.generate.json +25 -0
- package/guidelines/conventions/conventions.instruction.md +847 -0
- package/guidelines/cssRule/cssRule.instruction.md +7 -0
- package/guidelines/framework/framework.generate.json +3 -2
- package/guidelines/framework/framework.instruction.md +1 -9
- package/guidelines/mcpRule/mcpRule.generate.json +25 -0
- package/guidelines/mcpRule/mcpRule.instruction.md +217 -0
- package/guidelines/queryRule/queryRule.generate.json +31 -0
- package/guidelines/queryRule/queryRule.instruction.md +143 -0
- package/guidelines/runtimeRule/runtimeRule.generate.json +25 -0
- package/guidelines/runtimeRule/runtimeRule.instruction.md +176 -0
- package/guidelines/ssrRule/ssrRule.instruction.md +49 -5
- package/guidelines/transportRule/transportRule.generate.json +31 -0
- package/guidelines/transportRule/transportRule.instruction.md +60 -0
- package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +24 -0
- package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +263 -0
- package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +33 -0
- package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +402 -0
- package/incrementalBuilder.proc.js +21 -22
- package/{index-4hek879p.js → index-1kzsn94d.js} +1 -1
- package/{index-p3f4q532.js → index-3c9n3nt8.js} +31 -30
- package/index-3d9y066c.js +76 -0
- package/{index-76rn3g2c.js → index-47pj3aee.js} +4 -4
- package/{index-gex7c8kd.js → index-5n0hf8r9.js} +65 -38
- package/{index-mssqn2sq.js → index-5y7qba1c.js} +79 -33
- package/index-6wwzs1bc.js +7 -0
- package/{index-wnp7hwq7.js → index-92zztqy1.js} +7 -7
- package/{index-fgc8r6dj.js → index-a5vmm6x4.js} +3 -1
- package/{index-azv0xjb5.js → index-a8h184wr.js} +15 -11
- package/{index-67546d0j.js → index-ayy5ecax.js} +1 -1
- package/{index-xhgtkekh.js → index-b2nt0w0k.js} +27 -27
- package/{index-xys926f2.js → index-by5gpp8x.js} +4 -4
- package/{index-bz2sfzzt.js → index-cd5x18qh.js} +32 -32
- package/{index-bjpxzr6s.js → index-ctphds8v.js} +1 -1
- package/{index-w6wbb612.js → index-dq6wq1tv.js} +94 -61
- package/{index-js368gk9.js → index-ee8z8adx.js} +13 -13
- package/{index-5dw57f0d.js → index-f7wewj2v.js} +155 -76
- package/{index-6rhabeev.js → index-ft1sfjz0.js} +36 -25
- package/{index-7myvn0f0.js → index-h7yw2z9n.js} +7 -7
- package/{index-5pmx7bkg.js → index-j9vnq8tr.js} +18 -18
- package/{index-vg0sj9nc.js → index-k1n0h7dk.js} +840 -201
- package/{index-vtj3zps1.js → index-k86zc21w.js} +57 -57
- package/{index-46tjzh6s.js → index-mfm35dhh.js} +29 -29
- package/{index-xjd3rqzj.js → index-n68jx79w.js} +6 -15
- package/{index-ztpw544k.js → index-qcracvc9.js} +8 -8
- package/{index-2c3e2xh8.js → index-saheq2bs.js} +4 -4
- package/{index-gmy45vz2.js → index-v0s24t8j.js} +14 -14
- package/{index-0cj2zxbm.js → index-wet2ytnr.js} +12 -11
- package/{index-j9cxndc0.js → index-x23688ar.js} +12 -7
- package/index-xnhf8tr9.js +109 -0
- package/{index-a1e0j63x.js → index-xxe90kqy.js} +58 -25
- package/{index-qb61h0k7.js → index-z3c9mmw4.js} +1098 -1360
- package/index.js +22 -24
- package/{library.command-md9715jz.js → library.command-wpedct6c.js} +11 -9
- package/{localRegistry.command-exkbamyj.js → localRegistry.command-pjdxa01g.js} +20 -22
- package/{module.command-w5aaddxk.js → module.command-8n4kct3e.js} +13 -15
- package/{package.command-yfkrcy0z.js → package.command-fcbd0b1d.js} +8 -9
- package/package.json +5 -7
- package/{page.command-echbavp4.js → page.command-x4379grq.js} +7 -8
- package/{primitive.command-9fbhspw2.js → primitive.command-8etmnqhq.js} +13 -15
- package/{quality.command-3pnt9yep.js → quality.command-hfx7z8yr.js} +226 -104
- package/recipeScanner-fpagtgc1.js +11 -0
- package/{repair.command-carj4vax.js → repair.command-j0fs5qkz.js} +12 -13
- package/{routeSourceValidator-e4jmbfcx.js → routeSourceValidator-ze6x894c.js} +0 -2
- package/{scalar.command-51ryzypc.js → scalar.command-2emk89eh.js} +11 -13
- package/templates/app/env/env.client.debug.ts.template +1 -5
- package/templates/app/env/env.client.develop.ts.template +1 -5
- package/templates/app/env/env.client.local.ts.template +1 -5
- package/templates/app/env/env.client.main.ts.template +1 -5
- package/templates/app/env/env.client.testing.ts.template +1 -5
- package/templates/app/env/env.client.type.ts +2 -6
- package/templates/app/env/env.server.debug.ts.template +1 -5
- package/templates/app/env/env.server.develop.ts.template +1 -5
- package/templates/app/env/env.server.local.ts.template +1 -5
- package/templates/app/env/env.server.main.ts.template +1 -5
- package/templates/app/main.ts +3 -1
- package/templates/appSample/lib/task/task.signal.ts +11 -6
- package/templates/appSample/srvkit/AuthGuard.ts +9 -5
- package/templates/appSample/srvkit/SessionInternalArg.ts +4 -3
- package/templates/crudPages/[__model__Id]/edit/page.tsx +6 -6
- package/templates/crudPages/[__model__Id]/page.tsx +10 -13
- package/templates/crudPages/new/page.tsx +6 -6
- package/templates/crudPages/page.tsx +9 -9
- package/templates/crudSinglePage/page.tsx +11 -7
- package/templates/env/_env.server.type.ts +7 -5
- package/templates/lib/db.ts +1 -1
- package/templates/lib/dict.ts +1 -1
- package/templates/lib/sig.ts +1 -1
- package/templates/lib/srv.ts +6 -2
- package/templates/module/__Model__.Util.tsx +1 -1
- package/templates/module/__Model__.Zone.tsx +3 -5
- package/templates/module/__model__.dictionary.ts +4 -1
- package/templates/module/__model__.signal.ts +2 -3
- package/templates/module/__model__.store.ts +1 -2
- package/templates/workspaceRoot/.gitignore.template +0 -1
- package/templates/workspaceRoot/AGENTS.md.template +4 -972
- package/templates/workspaceRoot/CLAUDE.md.template +19 -0
- package/templates/workspaceRoot/biome.json.template +4 -244
- package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +10 -14
- package/templates/workspaceRoot/docs/GENERATED.md.template +12 -10
- package/templates/workspaceRoot/package.json.template +2 -4
- package/typeChecker-3xgrzc2v.js +7 -0
- package/typecheck.proc.js +4 -5
- package/{workflow.command-91wmvm8k.js → workflow.command-cvpmzwjg.js} +21 -23
- package/{workspace.command-wa10mfd9.js → workspace.command-mbb5s3wx.js} +108 -91
- package/capacitorApp-p0z5yab2.js +0 -60
- package/dependencyScanner-f6grrep3.js +0 -9
- package/index-mxvakhsm.js +0 -66
- package/index-r24hmh0q.js +0 -4
- package/recipeScanner-tghkzrrt.js +0 -12
- package/templates/workspaceRoot/.cursor/rules/akan-page-routing.mdc.template +0 -43
- package/templates/workspaceRoot/.cursor/rules/akan-sync-conventions.mdc.template +0 -34
- package/templates/workspaceRoot/.cursor/rules/application-test-commands.mdc.template +0 -16
- package/templates/workspaceRoot/.cursor/rules/change-scope.mdc.template +0 -12
- package/templates/workspaceRoot/.cursor/rules/client-server-boundaries.mdc.template +0 -18
- package/templates/workspaceRoot/.cursor/rules/coding-comments.mdc.template +0 -25
- package/templates/workspaceRoot/.cursor/rules/coding-style.mdc.template +0 -44
- package/templates/workspaceRoot/.cursor/rules/domain-module-conventions.mdc.template +0 -17
- package/templates/workspaceRoot/.cursor/rules/format-lint.mdc.template +0 -12
- package/templates/workspaceRoot/.cursor/rules/lint-enforced-rules.mdc.template +0 -19
- package/templates/workspaceRoot/.cursor/rules/module-file-playbook.mdc.template +0 -62
- package/templates/workspaceRoot/.cursor/rules/naming-conventions.mdc.template +0 -15
- package/templates/workspaceRoot/.cursor/rules/react-component-style.mdc.template +0 -21
- package/templates/workspaceRoot/.cursor/rules/repo-overview.mdc.template +0 -17
- package/templates/workspaceRoot/.cursor/rules/scalar-modeling.mdc.template +0 -99
- package/templates/workspaceRoot/.cursor/rules/secrets-and-env.mdc.template +0 -13
- package/templates/workspaceRoot/.cursor/rules/service-signal-conventions.mdc.template +0 -83
- package/templates/workspaceRoot/.cursor/rules/srvkit-adapters-and-guards.mdc.template +0 -50
- package/templates/workspaceRoot/.cursor/rules/ssr-first.mdc.template +0 -59
- package/templates/workspaceRoot/.cursor/rules/typescript-imports.mdc.template +0 -16
- package/typeChecker-kravn7ns.js +0 -8
- /package/{index-0wae5ebk.js → index-meh558jy.js} +0 -0
- /package/{index-ss469dec.js → index-nz8prx9g.js} +0 -0
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import {
|
|
3
|
-
resolveMobileTargets
|
|
4
|
-
} from "./index-76rn3g2c.js";
|
|
5
|
-
import {
|
|
6
|
-
LibraryScript
|
|
7
|
-
} from "./index-a1e0j63x.js";
|
|
8
2
|
import {
|
|
9
3
|
runner,
|
|
10
4
|
script
|
|
11
|
-
} from "./index-
|
|
5
|
+
} from "./index-ft1sfjz0.js";
|
|
6
|
+
import {
|
|
7
|
+
WorkspaceExecutor,
|
|
8
|
+
AppExecutor,
|
|
9
|
+
LibExecutor,
|
|
10
|
+
PkgExecutor
|
|
11
|
+
} from "./index-k1n0h7dk.js";
|
|
12
|
+
import {
|
|
13
|
+
LibraryScript
|
|
14
|
+
} from "./index-xxe90kqy.js";
|
|
12
15
|
import {
|
|
13
16
|
HmrWatcher,
|
|
14
17
|
WatchRootResolver
|
|
15
|
-
} from "./index-
|
|
18
|
+
} from "./index-ctphds8v.js";
|
|
16
19
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
WorkspaceExecutor
|
|
21
|
-
} from "./index-vg0sj9nc.js";
|
|
20
|
+
SlicePlanner,
|
|
21
|
+
formatSlicePlan
|
|
22
|
+
} from "./index-xnhf8tr9.js";
|
|
22
23
|
import {
|
|
23
|
-
|
|
24
|
-
} from "./index-
|
|
24
|
+
resolveMobileTargets
|
|
25
|
+
} from "./index-47pj3aee.js";
|
|
25
26
|
|
|
26
27
|
// pkgs/@akanjs/devkit/applicationBuildReporter.ts
|
|
27
28
|
import { Logger } from "akanjs/common";
|
|
@@ -72,9 +73,10 @@ Caused by: ${ApplicationBuildReporter.formatError(error.cause)}` : "";
|
|
|
72
73
|
import { confirm } from "@inquirer/prompts";
|
|
73
74
|
import { Logger as Logger5 } from "akanjs/common";
|
|
74
75
|
|
|
76
|
+
// pkgs/@akanjs/cli/application/application.runner.ts
|
|
77
|
+
import path5 from "path";
|
|
78
|
+
|
|
75
79
|
// pkgs/@akanjs/devkit/akanApp/akanApp.host.ts
|
|
76
|
-
import { stat } from "fs/promises";
|
|
77
|
-
import path2 from "path";
|
|
78
80
|
import { Logger as Logger3 } from "akanjs/common";
|
|
79
81
|
|
|
80
82
|
// pkgs/@akanjs/devkit/sshTunnel.ts
|
|
@@ -350,7 +352,7 @@ class IncrementalBuilderHost {
|
|
|
350
352
|
return false;
|
|
351
353
|
this.#recycleRequested = true;
|
|
352
354
|
this.#status = "recycling";
|
|
353
|
-
this.logger.
|
|
355
|
+
this.logger.debug(`recycling builder pid=${proc.pid} (${reason})`);
|
|
354
356
|
this.#recycleTimer = setTimeout(() => {
|
|
355
357
|
this.#recycleTimer = null;
|
|
356
358
|
if (this.#proc !== proc)
|
|
@@ -470,38 +472,23 @@ class BuilderRequestRouter {
|
|
|
470
472
|
}
|
|
471
473
|
}
|
|
472
474
|
|
|
473
|
-
// pkgs/@akanjs/devkit/akanApp/
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
475
|
+
// pkgs/@akanjs/devkit/akanApp/BackendImportGraph.ts
|
|
476
|
+
import { stat } from "fs/promises";
|
|
477
|
+
import path3 from "path";
|
|
478
|
+
|
|
479
|
+
// pkgs/@akanjs/devkit/akanApp/devHostPolicy.ts
|
|
480
|
+
import path2 from "path";
|
|
479
481
|
var BACKEND_RECOVERY_MAX_ATTEMPTS = 5;
|
|
480
|
-
var BACKEND_STDERR_TAIL_LIMIT = 40;
|
|
481
|
-
var BUILDER_READY_TIMEOUT_MS = 150000;
|
|
482
|
-
var BUILDER_START_MAX_ATTEMPTS = 3;
|
|
483
482
|
var HELD_BUILDER_REQUEST_LIMIT = 64;
|
|
484
|
-
var BUILDER_RSS_RECYCLE_QUIET_MS = 750;
|
|
485
483
|
var BUILDER_MIN_RSS_RECYCLE_INTERVAL_MS = 30000;
|
|
486
484
|
var BUILDER_TIGHT_RSS_REPORT_LIMIT = 2;
|
|
487
|
-
var BUILDER_RSS_SETTLE_MS = 20000;
|
|
488
|
-
var PS_RSS_TIMEOUT_MS = 2000;
|
|
489
485
|
var BUILDER_RSS_HARD_MULTIPLE = 1.5;
|
|
490
486
|
var DEV_IDLE_SUSPEND_MS = 300000;
|
|
491
487
|
var DEV_IDLE_MIN_UPTIME_MS = 30000;
|
|
492
|
-
var BUILDER_RECOVERY_BASE_DELAY_MS = 2000;
|
|
493
|
-
var BUILDER_RECOVERY_MAX_DELAY_MS = 60000;
|
|
494
488
|
var SOURCE_EXTS = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"]);
|
|
495
|
-
var NON_SOURCE_EXT_RE = /\.(css|scss|sass|less|json|svg|png|jpe?g|webp|gif|avif|ico|woff2?|ttf|otf|mp3|mp4|wav|html)$/i;
|
|
496
489
|
var SERVER_SUFFIXES = [".service.ts", ".document.ts"];
|
|
497
490
|
var SHARED_SUFFIXES = [".constant.ts", ".dictionary.ts", ".signal.ts"];
|
|
498
491
|
var RUNTIME_METADATA_BASENAMES = new Set(["dict.ts", "sig.ts", "useClient.ts", "useServer.ts"]);
|
|
499
|
-
var GRAPH_IMPORT_KINDS = new Set([
|
|
500
|
-
"import-statement",
|
|
501
|
-
"require-call",
|
|
502
|
-
"require-resolve",
|
|
503
|
-
"dynamic-import"
|
|
504
|
-
]);
|
|
505
492
|
var shouldRestartBackendByDevPlan = (message) => {
|
|
506
493
|
if (!message.devPlan)
|
|
507
494
|
return null;
|
|
@@ -682,6 +669,15 @@ var mergeInvalidateMessages = (current, next) => {
|
|
|
682
669
|
var buildStatusReplaySequence = (pendingReplay, latestByPhase) => [...pendingReplay, ...latestByPhase.values()];
|
|
683
670
|
var filesChangedSince = (before, after) => [...before].filter(([file, stamp]) => after.get(file) !== stamp).map(([file]) => file);
|
|
684
671
|
|
|
672
|
+
// pkgs/@akanjs/devkit/akanApp/BackendImportGraph.ts
|
|
673
|
+
var NON_SOURCE_EXT_RE = /\.(css|scss|sass|less|json|svg|png|jpe?g|webp|gif|avif|ico|woff2?|ttf|otf|mp3|mp4|wav|html)$/i;
|
|
674
|
+
var GRAPH_IMPORT_KINDS = new Set([
|
|
675
|
+
"import-statement",
|
|
676
|
+
"require-call",
|
|
677
|
+
"require-resolve",
|
|
678
|
+
"dynamic-import"
|
|
679
|
+
]);
|
|
680
|
+
|
|
685
681
|
class BackendImportGraph {
|
|
686
682
|
#app;
|
|
687
683
|
#logger;
|
|
@@ -704,7 +700,7 @@ class BackendImportGraph {
|
|
|
704
700
|
return this.#lastRefreshSucceeded;
|
|
705
701
|
}
|
|
706
702
|
has(file) {
|
|
707
|
-
return this.#files.has(
|
|
703
|
+
return this.#files.has(path3.resolve(file));
|
|
708
704
|
}
|
|
709
705
|
async fingerprint() {
|
|
710
706
|
const stamps = await Promise.all([...this.#files].map(async (file) => {
|
|
@@ -732,9 +728,9 @@ class BackendImportGraph {
|
|
|
732
728
|
const roots = await this.#entrypoints();
|
|
733
729
|
const files = new Set;
|
|
734
730
|
const queue = [...roots];
|
|
735
|
-
const workspaceRoot =
|
|
731
|
+
const workspaceRoot = path3.resolve(this.#app.workspace.workspaceRoot);
|
|
736
732
|
while (queue.length > 0) {
|
|
737
|
-
const current =
|
|
733
|
+
const current = path3.resolve(queue.pop());
|
|
738
734
|
if (files.has(current))
|
|
739
735
|
continue;
|
|
740
736
|
if (!this.#isWorkspaceSource(current, workspaceRoot))
|
|
@@ -743,7 +739,7 @@ class BackendImportGraph {
|
|
|
743
739
|
if (!imports)
|
|
744
740
|
continue;
|
|
745
741
|
files.add(current);
|
|
746
|
-
const importerDir =
|
|
742
|
+
const importerDir = path3.dirname(current);
|
|
747
743
|
for (const imp of imports) {
|
|
748
744
|
if (!GRAPH_IMPORT_KINDS.has(imp.kind) || !imp.path || NON_SOURCE_EXT_RE.test(imp.path))
|
|
749
745
|
continue;
|
|
@@ -774,7 +770,7 @@ class BackendImportGraph {
|
|
|
774
770
|
const roots = [`${this.#app.cwdPath}/main.ts`, `${this.#app.cwdPath}/server.ts`];
|
|
775
771
|
const existing = [];
|
|
776
772
|
for (const root of roots) {
|
|
777
|
-
const abs =
|
|
773
|
+
const abs = path3.resolve(root);
|
|
778
774
|
if (await Bun.file(abs).exists())
|
|
779
775
|
existing.push(abs);
|
|
780
776
|
}
|
|
@@ -783,25 +779,25 @@ class BackendImportGraph {
|
|
|
783
779
|
#resolve(specifier, importerDir) {
|
|
784
780
|
try {
|
|
785
781
|
const resolved = Bun.resolveSync(specifier, importerDir);
|
|
786
|
-
if (!
|
|
782
|
+
if (!path3.isAbsolute(resolved))
|
|
787
783
|
return null;
|
|
788
|
-
if (!SOURCE_EXTS.has(
|
|
784
|
+
if (!SOURCE_EXTS.has(path3.extname(resolved).toLowerCase()))
|
|
789
785
|
return null;
|
|
790
|
-
return
|
|
786
|
+
return path3.resolve(resolved);
|
|
791
787
|
} catch {
|
|
792
788
|
return null;
|
|
793
789
|
}
|
|
794
790
|
}
|
|
795
791
|
#isWorkspaceSource(file, workspaceRoot) {
|
|
796
|
-
const rel =
|
|
797
|
-
if (rel.startsWith("..") ||
|
|
792
|
+
const rel = path3.relative(workspaceRoot, file);
|
|
793
|
+
if (rel.startsWith("..") || path3.isAbsolute(rel))
|
|
798
794
|
return false;
|
|
799
|
-
if (rel.includes(`${
|
|
795
|
+
if (rel.includes(`${path3.sep}node_modules${path3.sep}`) || rel.includes(`${path3.sep}.akan${path3.sep}`))
|
|
800
796
|
return false;
|
|
801
|
-
return SOURCE_EXTS.has(
|
|
797
|
+
return SOURCE_EXTS.has(path3.extname(file).toLowerCase());
|
|
802
798
|
}
|
|
803
799
|
#scanImports(file, source) {
|
|
804
|
-
const ext =
|
|
800
|
+
const ext = path3.extname(file).toLowerCase();
|
|
805
801
|
if (ext === ".tsx")
|
|
806
802
|
return this.#tsxTranspiler.scanImports(source);
|
|
807
803
|
if (ext === ".jsx")
|
|
@@ -812,6 +808,21 @@ class BackendImportGraph {
|
|
|
812
808
|
}
|
|
813
809
|
}
|
|
814
810
|
|
|
811
|
+
// pkgs/@akanjs/devkit/akanApp/akanApp.host.ts
|
|
812
|
+
var backendMsgTypeSet = new Set(["build-route", "build-csr"]);
|
|
813
|
+
var BACKEND_RESTART_DEBOUNCE_MS = 120;
|
|
814
|
+
var BACKEND_GRACEFUL_TIMEOUT_MS = 8000;
|
|
815
|
+
var BACKEND_RECOVERY_BASE_DELAY_MS = 1000;
|
|
816
|
+
var BACKEND_RECOVERY_MAX_DELAY_MS = 30000;
|
|
817
|
+
var BACKEND_STDERR_TAIL_LIMIT = 40;
|
|
818
|
+
var BUILDER_READY_TIMEOUT_MS = 150000;
|
|
819
|
+
var BUILDER_START_MAX_ATTEMPTS = 3;
|
|
820
|
+
var BUILDER_RSS_RECYCLE_QUIET_MS = 750;
|
|
821
|
+
var BUILDER_RSS_SETTLE_MS = 20000;
|
|
822
|
+
var PS_RSS_TIMEOUT_MS = 2000;
|
|
823
|
+
var BUILDER_RECOVERY_BASE_DELAY_MS = 2000;
|
|
824
|
+
var BUILDER_RECOVERY_MAX_DELAY_MS = 60000;
|
|
825
|
+
|
|
815
826
|
class AkanAppHost {
|
|
816
827
|
app;
|
|
817
828
|
logger = new Logger3("AkanAppHost");
|
|
@@ -907,6 +918,7 @@ class AkanAppHost {
|
|
|
907
918
|
}
|
|
908
919
|
#startBackend(startStatus = null) {
|
|
909
920
|
this.#builderRequests.startGeneration();
|
|
921
|
+
this.#discardPendingBuilderMessages("the backend restarted while the builder was away");
|
|
910
922
|
this.#backendStartStatus = startStatus;
|
|
911
923
|
this.#backendGaveUp = false;
|
|
912
924
|
this.#setBackendLifecycleState("starting");
|
|
@@ -1498,6 +1510,12 @@ ${this.#backendStderrTail.join(`
|
|
|
1498
1510
|
this.#pendingBuilderMessages.push(message);
|
|
1499
1511
|
this.logger.verbose(`[builder] holding ${message.type} until the builder is ready (${this.#pendingBuilderMessages.length} waiting)`);
|
|
1500
1512
|
}
|
|
1513
|
+
#discardPendingBuilderMessages(reason) {
|
|
1514
|
+
const held = this.#pendingBuilderMessages.splice(0);
|
|
1515
|
+
if (held.length === 0)
|
|
1516
|
+
return;
|
|
1517
|
+
this.logger.verbose(`[builder] dropped ${held.length} held builder request(s): ${reason}`);
|
|
1518
|
+
}
|
|
1501
1519
|
#failPendingBuilderMessages(reason) {
|
|
1502
1520
|
const held = this.#pendingBuilderMessages.splice(0);
|
|
1503
1521
|
if (held.length === 0)
|
|
@@ -1858,20 +1876,20 @@ ${this.#backendStderrTail.join(`
|
|
|
1858
1876
|
}
|
|
1859
1877
|
}
|
|
1860
1878
|
// pkgs/@akanjs/devkit/applicationTestPreload.ts
|
|
1861
|
-
import
|
|
1879
|
+
import path4 from "path";
|
|
1862
1880
|
var SIGNAL_TEST_PRELOAD_PATH = "test/signalTest.preload.ts";
|
|
1863
1881
|
async function resolveSignalTestPreloadPath(target) {
|
|
1864
1882
|
const candidates = [];
|
|
1865
1883
|
const addResolvedPackageCandidate = (basePath) => {
|
|
1866
1884
|
try {
|
|
1867
|
-
candidates.push(
|
|
1885
|
+
candidates.push(path4.join(path4.dirname(Bun.resolveSync("akanjs/package.json", basePath)), SIGNAL_TEST_PRELOAD_PATH));
|
|
1868
1886
|
} catch {}
|
|
1869
1887
|
};
|
|
1870
1888
|
addResolvedPackageCandidate(target.cwdPath);
|
|
1871
1889
|
addResolvedPackageCandidate(process.cwd());
|
|
1872
|
-
addResolvedPackageCandidate(
|
|
1890
|
+
addResolvedPackageCandidate(path4.dirname(Bun.main));
|
|
1873
1891
|
addResolvedPackageCandidate(import.meta.dir);
|
|
1874
|
-
candidates.push(
|
|
1892
|
+
candidates.push(path4.join(target.cwdPath, "../../node_modules/akanjs", SIGNAL_TEST_PRELOAD_PATH), path4.join(target.cwdPath, "../../pkgs/akanjs", SIGNAL_TEST_PRELOAD_PATH), path4.join(process.cwd(), "node_modules/akanjs", SIGNAL_TEST_PRELOAD_PATH), path4.join(process.cwd(), "pkgs/akanjs", SIGNAL_TEST_PRELOAD_PATH), path4.join(path4.dirname(Bun.main), "../../akanjs", SIGNAL_TEST_PRELOAD_PATH), path4.resolve(import.meta.dir, "../../akanjs", SIGNAL_TEST_PRELOAD_PATH));
|
|
1875
1893
|
const uniqueCandidates = [...new Set(candidates)];
|
|
1876
1894
|
for (const candidate of uniqueCandidates) {
|
|
1877
1895
|
if (await Bun.file(candidate).exists())
|
|
@@ -1898,10 +1916,10 @@ function openBrowser(url) {
|
|
|
1898
1916
|
}
|
|
1899
1917
|
|
|
1900
1918
|
// pkgs/@akanjs/cli/application/application.runner.ts
|
|
1901
|
-
var loadBuildRunner = async () => (await import("./applicationBuildRunner-
|
|
1902
|
-
var loadReleasePackager = async () => (await import("./applicationReleasePackager-
|
|
1903
|
-
var loadCapacitorApp = async () => (await import("./capacitorApp-
|
|
1904
|
-
var loadAbstractCompactor = async () => (await import("./abstractCompactor-
|
|
1919
|
+
var loadBuildRunner = async () => (await import("./applicationBuildRunner-tavpx3fv.js")).ApplicationBuildRunner;
|
|
1920
|
+
var loadReleasePackager = async () => (await import("./applicationReleasePackager-ktjt0erc.js")).ApplicationReleasePackager;
|
|
1921
|
+
var loadCapacitorApp = async () => (await import("./capacitorApp-kwa67kzs.js")).CapacitorApp;
|
|
1922
|
+
var loadAbstractCompactor = async () => (await import("./abstractCompactor-pwc6d6yk.js")).AbstractCompactor;
|
|
1905
1923
|
var loadPrompts = async () => await import("@inquirer/prompts");
|
|
1906
1924
|
|
|
1907
1925
|
class ApplicationRunner extends runner("application") {
|
|
@@ -1914,8 +1932,11 @@ class ApplicationRunner extends runner("application") {
|
|
|
1914
1932
|
});
|
|
1915
1933
|
return AppExecutor.from(workspace, appName);
|
|
1916
1934
|
}
|
|
1935
|
+
async planSlice(app) {
|
|
1936
|
+
return await new SlicePlanner(app).plan();
|
|
1937
|
+
}
|
|
1917
1938
|
async removeApplication(app) {
|
|
1918
|
-
await app.workspace.
|
|
1939
|
+
await app.workspace.removeDir(`apps/${app.name}`);
|
|
1919
1940
|
}
|
|
1920
1941
|
async getConfig(app) {
|
|
1921
1942
|
return await app.getConfig();
|
|
@@ -1945,10 +1966,69 @@ class ApplicationRunner extends runner("application") {
|
|
|
1945
1966
|
stdio: "inherit"
|
|
1946
1967
|
});
|
|
1947
1968
|
}
|
|
1969
|
+
#runtimeDirOf(app, override) {
|
|
1970
|
+
return path5.resolve(override ?? process.env.AKAN_RUNTIME_DIR ?? path5.join(app.workspace.workspaceRoot, "local", "apps", app.name, "runtime"));
|
|
1971
|
+
}
|
|
1972
|
+
async runLogs(app, options) {
|
|
1973
|
+
const { LogControlUnavailableError, LogTailClient } = await import("akanjs/server/logging/logTailClient");
|
|
1974
|
+
const { LogQueryMatcher } = await import("akanjs/server/logging/logQuery");
|
|
1975
|
+
const runtimeDir = this.#runtimeDirOf(app, options.runtimeDir);
|
|
1976
|
+
const socketPath = LogTailClient.socketPath(runtimeDir);
|
|
1977
|
+
const { level, grep, endpoint, trace, child, role, origin, since } = options;
|
|
1978
|
+
const query = Object.fromEntries(Object.entries({ level, grep, endpoint, trace, child, role, origin, since }).filter(([, value]) => value !== undefined && value !== null && value !== ""));
|
|
1979
|
+
const print = (record) => process.stdout.write(options.json ? `${JSON.stringify(record)}
|
|
1980
|
+
` : Logger4.render(record));
|
|
1981
|
+
const note = (text) => process.stderr.write(`[akan logs] ${text}
|
|
1982
|
+
`);
|
|
1983
|
+
let finish = null;
|
|
1984
|
+
const closed = new Promise((resolve) => {
|
|
1985
|
+
finish = resolve;
|
|
1986
|
+
});
|
|
1987
|
+
let client;
|
|
1988
|
+
try {
|
|
1989
|
+
client = await LogTailClient.connect(socketPath, {
|
|
1990
|
+
onRecord: (entry) => print(entry.record),
|
|
1991
|
+
onEvent: (response) => {
|
|
1992
|
+
if (response.type === "dropped")
|
|
1993
|
+
note(`${response.count} records dropped (reader too slow)`);
|
|
1994
|
+
},
|
|
1995
|
+
onClose: () => finish?.()
|
|
1996
|
+
});
|
|
1997
|
+
} catch (error) {
|
|
1998
|
+
if (error instanceof LogControlUnavailableError)
|
|
1999
|
+
throw new Error(`${app.name} is not running (no ${path5.basename(socketPath)} in ${runtimeDir}). Start it with \`akan start ${app.name}\`, or pass --runtime-dir for a built app.`);
|
|
2000
|
+
throw error;
|
|
2001
|
+
}
|
|
2002
|
+
const sinceMs = since ? LogQueryMatcher.parseSince(since) : undefined;
|
|
2003
|
+
const noteCoverage = (coverage) => {
|
|
2004
|
+
if (sinceMs !== undefined && coverage.from !== null && sinceMs < coverage.from)
|
|
2005
|
+
note(`${LogTailClient.describeCoverage(coverage)}; older records are not retained`);
|
|
2006
|
+
};
|
|
2007
|
+
if (endpoint)
|
|
2008
|
+
note("requests served by the primitive query fast path carry no endpoint and are not shown");
|
|
2009
|
+
if (options.follow === false) {
|
|
2010
|
+
const { entries, coverage } = await client.history({
|
|
2011
|
+
...query,
|
|
2012
|
+
...options.replay ? { limit: options.replay } : {}
|
|
2013
|
+
});
|
|
2014
|
+
for (const entry of entries)
|
|
2015
|
+
print(entry.record);
|
|
2016
|
+
noteCoverage(coverage);
|
|
2017
|
+
client.close();
|
|
2018
|
+
return;
|
|
2019
|
+
}
|
|
2020
|
+
const subscribed = await client.subscribe(query, { replay: options.replay });
|
|
2021
|
+
noteCoverage(subscribed.coverage);
|
|
2022
|
+
const stop = () => client.close();
|
|
2023
|
+
process.once("SIGINT", stop);
|
|
2024
|
+
process.once("SIGTERM", stop);
|
|
2025
|
+
await closed;
|
|
2026
|
+
}
|
|
1948
2027
|
async runConsole(app) {
|
|
1949
2028
|
const serverPath = `${app.cwdPath}/server.ts`;
|
|
1950
2029
|
if (!await app.exists("server.ts"))
|
|
1951
2030
|
throw new Error(`Server file not found: apps/${app.name}/server.ts`);
|
|
2031
|
+
const runtimeDir = this.#runtimeDirOf(app);
|
|
1952
2032
|
const code = `
|
|
1953
2033
|
const serverModule = await import(${JSON.stringify(serverPath)});
|
|
1954
2034
|
const { assertAkanConsoleAllowed, startAkanConsole } = await import("akanjs/server");
|
|
@@ -1958,6 +2038,7 @@ assertAkanConsoleAllowed(server.env);
|
|
|
1958
2038
|
await server.start({ listen: false, web: false });
|
|
1959
2039
|
try {
|
|
1960
2040
|
await startAkanConsole(server, {
|
|
2041
|
+
runtimeDir: ${JSON.stringify(runtimeDir)},
|
|
1961
2042
|
globals: {
|
|
1962
2043
|
srv: serverModule.srv,
|
|
1963
2044
|
sig: serverModule.sig,
|
|
@@ -2329,6 +2410,12 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
|
|
|
2329
2410
|
await this.applicationRunner.removeApplication(app);
|
|
2330
2411
|
spinner.succeed(`Application ${app.name} (apps/${app.name}) removed`);
|
|
2331
2412
|
}
|
|
2413
|
+
async planSlice(app, format = "text") {
|
|
2414
|
+
const spinner = app.spinning("Planning distributable slice...");
|
|
2415
|
+
const plan = await this.applicationRunner.planSlice(app);
|
|
2416
|
+
spinner.succeed(`Slice planned (${plan.libs.length} libs, ${plan.warnings.length} warnings)`);
|
|
2417
|
+
Logger5.rawLog(format === "json" ? JSON.stringify(plan, null, 2) : formatSlicePlan(plan));
|
|
2418
|
+
}
|
|
2332
2419
|
async sync(sys) {
|
|
2333
2420
|
if (sys.type === "app")
|
|
2334
2421
|
await sys.scanSync();
|
|
@@ -2355,6 +2442,9 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
|
|
|
2355
2442
|
await app.scanSync();
|
|
2356
2443
|
await this.applicationRunner.runConsole(app);
|
|
2357
2444
|
}
|
|
2445
|
+
async logs(app, options) {
|
|
2446
|
+
await this.applicationRunner.runLogs(app, options);
|
|
2447
|
+
}
|
|
2358
2448
|
async build(app, { write = true, fast = false, quiet = false } = {}) {
|
|
2359
2449
|
await app.scanSync({ write });
|
|
2360
2450
|
if (!quiet)
|
|
@@ -2388,8 +2478,8 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
|
|
|
2388
2478
|
async test(exec, { write = true } = {}) {
|
|
2389
2479
|
if (exec instanceof LibExecutor) {
|
|
2390
2480
|
await this.libraryScript.syncLibrary(exec);
|
|
2391
|
-
const
|
|
2392
|
-
|
|
2481
|
+
const spinner = exec.spinning(`Preparing ${exec.name}...`);
|
|
2482
|
+
spinner.succeed(`${exec.name} prepared`);
|
|
2393
2483
|
await this.applicationRunner.test(exec);
|
|
2394
2484
|
return;
|
|
2395
2485
|
}
|
|
@@ -2528,7 +2618,7 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
|
|
|
2528
2618
|
let stopping = false;
|
|
2529
2619
|
process.on("SIGINT", () => {
|
|
2530
2620
|
if (stopping) {
|
|
2531
|
-
Logger5.rawLog("Abandoning the local database teardown; containers are left running.", undefined, "
|
|
2621
|
+
Logger5.rawLog("Abandoning the local database teardown; containers are left running.", undefined, "error");
|
|
2532
2622
|
process.exit(130);
|
|
2533
2623
|
}
|
|
2534
2624
|
stopping = true;
|
|
@@ -2542,18 +2632,7 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
|
|
|
2542
2632
|
}), timeout]);
|
|
2543
2633
|
if (result !== "timeout")
|
|
2544
2634
|
return;
|
|
2545
|
-
Logger5.rawLog(`Local database did not stop within ${ApplicationScript.dbShutdownTimeoutMs}ms; run \`akan dbdown\` once Docker responds.`, undefined, "
|
|
2546
|
-
}
|
|
2547
|
-
async testSys(sys) {
|
|
2548
|
-
if (sys.type === "app")
|
|
2549
|
-
await this.testApplication(sys);
|
|
2550
|
-
else
|
|
2551
|
-
await this.libraryScript.testLibrary(sys);
|
|
2552
|
-
}
|
|
2553
|
-
async testApplication(app) {
|
|
2554
|
-
const spinner = app.spinning("Testing application...");
|
|
2555
|
-
await this.applicationRunner.test(app);
|
|
2556
|
-
spinner.succeed(`Application ${app.name} (apps/${app.name}) test is successful`);
|
|
2635
|
+
Logger5.rawLog(`Local database did not stop within ${ApplicationScript.dbShutdownTimeoutMs}ms; run \`akan dbdown\` once Docker responds.`, undefined, "error");
|
|
2557
2636
|
}
|
|
2558
2637
|
}
|
|
2559
2638
|
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
AppExecutor,
|
|
4
3
|
Executor,
|
|
4
|
+
WorkspaceExecutor,
|
|
5
|
+
AppExecutor,
|
|
5
6
|
LibExecutor,
|
|
6
|
-
ModuleExecutor,
|
|
7
7
|
PkgExecutor,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "./index-vg0sj9nc.js";
|
|
8
|
+
ModuleExecutor
|
|
9
|
+
} from "./index-k1n0h7dk.js";
|
|
11
10
|
import {
|
|
12
11
|
FileSys
|
|
13
|
-
} from "./index-
|
|
12
|
+
} from "./index-ayy5ecax.js";
|
|
14
13
|
import {
|
|
15
|
-
|
|
16
|
-
} from "./index-
|
|
14
|
+
getDirname2
|
|
15
|
+
} from "./index-6wwzs1bc.js";
|
|
17
16
|
|
|
18
17
|
// pkgs/@akanjs/devkit/commandDecorators/targetMeta.ts
|
|
19
18
|
var COMMAND_META = Symbol("akan.command.meta");
|
|
@@ -381,6 +380,16 @@ var prompts = async () => await import("@inquirer/prompts");
|
|
|
381
380
|
var select = (config, context) => prompts().then((m) => m.select(config, context));
|
|
382
381
|
var confirm = (config, context) => prompts().then((m) => m.confirm(config, context));
|
|
383
382
|
var input = (config, context) => prompts().then((m) => m.input(config, context));
|
|
383
|
+
var assertEnumChoice = (argMeta, value) => {
|
|
384
|
+
const enumChoices = argMeta.argsOption.enum;
|
|
385
|
+
if (!enumChoices || typeof enumChoices === "function")
|
|
386
|
+
return;
|
|
387
|
+
const choices = normalizeEnumChoices(enumChoices);
|
|
388
|
+
if (choices.some((choice) => String(choice.value) === String(value)))
|
|
389
|
+
return;
|
|
390
|
+
const label = argMeta.type === "Option" ? `option '--${camelToKebabCase3(argMeta.name)}'` : `argument '${argMeta.name}'`;
|
|
391
|
+
throw new Error(`${label} argument '${String(value)}' is invalid. Allowed choices are ${choices.map((choice) => choice.name).join(", ")}.`);
|
|
392
|
+
};
|
|
384
393
|
var resolveEnumChoices = async (argMeta, context) => {
|
|
385
394
|
const enumChoices = argMeta.argsOption.enum;
|
|
386
395
|
if (!enumChoices)
|
|
@@ -394,9 +403,10 @@ var getOptionValue = async (argMeta, opt, context) => {
|
|
|
394
403
|
name,
|
|
395
404
|
argsOption: { enum: enumChoices, default: defaultValue, type, desc, nullable, example, ask }
|
|
396
405
|
} = argMeta;
|
|
397
|
-
if (opt[argMeta.name] !== undefined)
|
|
406
|
+
if (opt[argMeta.name] !== undefined) {
|
|
407
|
+
assertEnumChoice(argMeta, opt[argMeta.name]);
|
|
398
408
|
return convertArgValue(opt[argMeta.name], type ?? "string");
|
|
399
|
-
else if (defaultValue !== undefined)
|
|
409
|
+
} else if (defaultValue !== undefined)
|
|
400
410
|
return defaultValue;
|
|
401
411
|
if (enumChoices) {
|
|
402
412
|
const choices = normalizeEnumChoices(await resolveEnumChoices(argMeta, context) ?? []);
|
|
@@ -422,9 +432,10 @@ var getArgumentValue = async (argMeta, value) => {
|
|
|
422
432
|
name,
|
|
423
433
|
argsOption: { default: defaultValue, type, desc, nullable, example, ask }
|
|
424
434
|
} = argMeta;
|
|
425
|
-
if (value !== undefined)
|
|
435
|
+
if (value !== undefined) {
|
|
436
|
+
assertEnumChoice(argMeta, value);
|
|
426
437
|
return convertArgValue(value, type ?? "string");
|
|
427
|
-
else if (defaultValue !== undefined)
|
|
438
|
+
} else if (defaultValue !== undefined)
|
|
428
439
|
return defaultValue;
|
|
429
440
|
else if (nullable)
|
|
430
441
|
return null;
|
|
@@ -526,36 +537,36 @@ var getInternalArgumentValue = async (argMeta, value, workspace) => {
|
|
|
526
537
|
return PkgExecutor.from(workspace, pkgName);
|
|
527
538
|
} else if (sysType === "module") {
|
|
528
539
|
if (value) {
|
|
529
|
-
const [sysName,
|
|
530
|
-
if (!sysName || !
|
|
540
|
+
const [sysName, moduleName] = value.split(":");
|
|
541
|
+
if (!sysName || !moduleName)
|
|
531
542
|
throw new Error(`Invalid module name: ${value}`);
|
|
532
543
|
if (appNames.includes(sysName)) {
|
|
533
544
|
const app = AppExecutor.from(workspace, sysName);
|
|
534
|
-
const
|
|
535
|
-
if (
|
|
536
|
-
return ModuleExecutor.from(app,
|
|
545
|
+
const modules = await app.getModules();
|
|
546
|
+
if (modules.includes(moduleName))
|
|
547
|
+
return ModuleExecutor.from(app, moduleName);
|
|
537
548
|
else
|
|
538
|
-
throw new Error(`Invalid module name: ${
|
|
549
|
+
throw new Error(`Invalid module name: ${moduleName}`);
|
|
539
550
|
} else if (libNames.includes(sysName)) {
|
|
540
551
|
const lib = LibExecutor.from(workspace, sysName);
|
|
541
|
-
const
|
|
542
|
-
if (
|
|
543
|
-
return ModuleExecutor.from(lib,
|
|
552
|
+
const modules = await lib.getModules();
|
|
553
|
+
if (modules.includes(moduleName))
|
|
554
|
+
return ModuleExecutor.from(lib, moduleName);
|
|
544
555
|
} else
|
|
545
556
|
throw new Error(`Invalid system name: ${sysName}`);
|
|
546
557
|
}
|
|
547
558
|
const { type, name } = await select({
|
|
548
559
|
message: `select the App or Lib name`,
|
|
549
560
|
choices: [
|
|
550
|
-
...appNames.map((
|
|
551
|
-
...libNames.map((
|
|
561
|
+
...appNames.map((name) => ({ name, value: { type: "app", name } })),
|
|
562
|
+
...libNames.map((name) => ({ name, value: { type: "lib", name } }))
|
|
552
563
|
]
|
|
553
564
|
});
|
|
554
565
|
const executor = type === "app" ? AppExecutor.from(workspace, name) : LibExecutor.from(workspace, name);
|
|
555
566
|
const modules = await executor.getModules();
|
|
556
567
|
const moduleName = await select({
|
|
557
568
|
message: `Select the module name`,
|
|
558
|
-
choices: modules.map((
|
|
569
|
+
choices: modules.map((name) => ({ name: `${executor.name}:${name}`, value: name }))
|
|
559
570
|
});
|
|
560
571
|
return ModuleExecutor.from(executor, moduleName);
|
|
561
572
|
} else
|
|
@@ -566,7 +577,7 @@ var runCommands = async (...commands) => {
|
|
|
566
577
|
printCliError(error);
|
|
567
578
|
process.exit(1);
|
|
568
579
|
});
|
|
569
|
-
const __dirname2 =
|
|
580
|
+
const __dirname2 = getDirname2(import.meta.url);
|
|
570
581
|
const packageJsonCandidates = [`${path.dirname(Bun.main)}/package.json`, `${__dirname2}/../package.json`];
|
|
571
582
|
let cliPackageJson = null;
|
|
572
583
|
for (const packageJsonPath of packageJsonCandidates) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
} from "./index-
|
|
3
|
+
getDirname2
|
|
4
|
+
} from "./index-6wwzs1bc.js";
|
|
5
5
|
|
|
6
6
|
// pkgs/@akanjs/devkit/prompter.ts
|
|
7
7
|
import fsPromise from "fs/promises";
|
|
8
8
|
import { input, select } from "@inquirer/prompts";
|
|
9
9
|
class Prompter {
|
|
10
10
|
static async#getGuidelineRoot() {
|
|
11
|
-
const dirname =
|
|
11
|
+
const dirname = getDirname2(import.meta.url);
|
|
12
12
|
const candidates = [`${dirname}/guidelines`, `${dirname}/../cli/guidelines`];
|
|
13
13
|
for (const candidate of candidates) {
|
|
14
14
|
try {
|
|
@@ -19,7 +19,6 @@ class Prompter {
|
|
|
19
19
|
return candidates[0];
|
|
20
20
|
}
|
|
21
21
|
static async selectGuideline() {
|
|
22
|
-
const guidelineRoot = await Prompter.#getGuidelineRoot();
|
|
23
22
|
const guideNames = await Prompter.listGuidelines();
|
|
24
23
|
return await select({
|
|
25
24
|
message: "Select a guideline",
|
|
@@ -37,10 +36,11 @@ class Prompter {
|
|
|
37
36
|
return JSON.parse(guideJson);
|
|
38
37
|
}
|
|
39
38
|
static async getInstruction(guideName) {
|
|
39
|
+
const guideNames = await Prompter.listGuidelines();
|
|
40
|
+
if (!guideNames.includes(guideName))
|
|
41
|
+
throw new Error(`Unknown guideline "${guideName}". Available: ${guideNames.join(", ")}`);
|
|
40
42
|
const guidelineRoot = await Prompter.#getGuidelineRoot();
|
|
41
|
-
|
|
42
|
-
const content = await fsPromise.readFile(filePath, "utf-8");
|
|
43
|
-
return content;
|
|
43
|
+
return await fsPromise.readFile(`${guidelineRoot}/${guideName}/${guideName}.instruction.md`, "utf-8");
|
|
44
44
|
}
|
|
45
45
|
static async getUpdateRequest(guideName) {
|
|
46
46
|
return await input({
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
WorkflowExecutor,
|
|
7
|
-
compactWorkflowInputs,
|
|
8
|
-
createDryRunWorkflowApplyReport,
|
|
3
|
+
jsonText,
|
|
4
|
+
workflowPlanApproval,
|
|
9
5
|
createWorkflowApplyReport,
|
|
6
|
+
workflowCommandsForPlan,
|
|
7
|
+
writeWorkflowRunArtifact,
|
|
8
|
+
readWorkflowRunArtifact,
|
|
10
9
|
createWorkflowBaselineSummary,
|
|
11
|
-
createWorkflowPlan,
|
|
12
10
|
createWorkflowValidationRunReport,
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
createDryRunWorkflowApplyReport,
|
|
12
|
+
WorkflowExecutor,
|
|
15
13
|
listWorkflowSpecs,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
getWorkflowSpec,
|
|
15
|
+
compactWorkflowInputs,
|
|
16
|
+
createWorkflowPlan,
|
|
19
17
|
renderWorkflowList,
|
|
18
|
+
renderWorkflowExplain,
|
|
20
19
|
renderWorkflowPlan,
|
|
21
|
-
|
|
20
|
+
renderWorkflowApply,
|
|
22
21
|
renderWorkflowValidation,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
renderWorkflowRunArtifact
|
|
23
|
+
} from "./index-saheq2bs.js";
|
|
24
|
+
import {
|
|
25
|
+
AkanContextAnalyzer
|
|
26
|
+
} from "./index-5y7qba1c.js";
|
|
27
27
|
import {
|
|
28
28
|
runner
|
|
29
|
-
} from "./index-
|
|
29
|
+
} from "./index-ft1sfjz0.js";
|
|
30
30
|
|
|
31
31
|
// pkgs/@akanjs/cli/workflow/workflow.runner.ts
|
|
32
32
|
import { mkdir, readFile, writeFile } from "fs/promises";
|