@akanjs/cli 3.1.0 → 3.1.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.build-stamp +1 -1
- package/{CodeAgent-c53dm40p.js → CodeAgent-4pnxwptq.js} +2 -2
- package/{CodeTui-xz9jtrn3.js → CodeTui-hhndze8h.js} +1 -1
- package/TunnelShare-8qtffcex.js +14 -0
- package/{agent.command-qawf7z4s.js → agent.command-p02330r6.js} +5 -5
- package/akanCode.js +2 -2
- package/{application.command-jqrgqk6j.js → application.command-1117fgq9.js} +16 -11
- package/{applicationBuildRunner-grgrey5c.js → applicationBuildRunner-9cnnsdm5.js} +5 -5
- package/buildBatch.proc.js +5 -5
- package/{cloud.command-p9067ssj.js → cloud.command-ttb2s2x6.js} +13 -13
- package/cloud.script-fqp3zh02.js +24 -0
- package/{code.command-t6j55sbk.js → code.command-16pm1p2v.js} +6 -6
- package/{context.command-eqbzbgth.js → context.command-6ys86sqf.js} +16 -16
- package/context.runner-3jrypwe3.js +25 -0
- package/{guideline.command-w905q73w.js → guideline.command-3zay3d8g.js} +2 -2
- package/guidelines/conventions/conventions.instruction.md +7 -3
- package/guidelines/mcpRule/mcpRule.instruction.md +13 -6
- package/guidelines/pageRule/pageRule.instruction.md +13 -5
- package/guidelines/runtimeRule/runtimeRule.instruction.md +8 -2
- package/guidelines/ssrRule/ssrRule.instruction.md +6 -1
- package/guidelines/transportRule/transportRule.instruction.md +12 -5
- package/incrementalBuilder.proc.js +3 -3
- package/{index-z5cxrbvv.js → index-1cq1hq12.js} +30 -15
- package/{index-wt7m1hfc.js → index-1mfyyxh5.js} +3 -3
- package/{index-yfy3t4kw.js → index-2ar6tffh.js} +17 -12
- package/{index-vtj332gj.js → index-4w3skd33.js} +3 -3
- package/{index-48n4yhm4.js → index-7f0edwsj.js} +172 -70
- package/{index-bs9yr4we.js → index-9hbhm6cs.js} +1 -1
- package/{index-j4dzazmw.js → index-b5vptvnt.js} +4 -4
- package/{index-cgexcnwd.js → index-bb4hj03s.js} +8 -8
- package/{index-avjqbtkj.js → index-e9e9cebg.js} +74 -24
- package/{index-3hvmytbs.js → index-ekpp5tax.js} +1 -1
- package/{index-eabfsarf.js → index-fmder14z.js} +1 -1
- package/{index-qh73jnyb.js → index-g2s33373.js} +1 -1
- package/{index-fnqj2d2w.js → index-jaa81e9r.js} +4 -4
- package/{index-64pjry21.js → index-jgs8z8xb.js} +3 -3
- package/{index-45c0mxb6.js → index-ngpn9hzy.js} +6 -4
- package/{index-fbw3kmt5.js → index-p4dnj2wc.js} +1 -1
- package/{index-25ks6x4k.js → index-q8age5az.js} +2 -2
- package/{index-0dd6z4b9.js → index-qfzfaq96.js} +3 -3
- package/{index-er62k6w3.js → index-qkcwsg6r.js} +2 -2
- package/{index-n8dsax1f.js → index-rr7jk14m.js} +1 -1
- package/{index-dkfadmrx.js → index-sh9mmp5v.js} +7 -7
- package/{index-f2gfq0yh.js → index-sng3vt0p.js} +2 -2
- package/{index-1de5f0qq.js → index-sww1x1mv.js} +7 -7
- package/{index-1enc9rga.js → index-tk3jg2bm.js} +25 -8
- package/{index-3aynkpf8.js → index-vcpbrrf2.js} +1 -1
- package/{index-yyxy7aff.js → index-ynqxpwx6.js} +1 -1
- package/{index-aqwdjn4x.js → index-z6v7k9sb.js} +2 -2
- package/{index-nr8m4j21.js → index-z9xepn8t.js} +3 -3
- package/{index-hqh4mpgt.js → index-zn6bn1s2.js} +4 -4
- package/index.js +22 -22
- package/{library.command-z1v7zepj.js → library.command-a8n9h8j4.js} +3 -3
- package/{localRegistry.command-48n23bjy.js → localRegistry.command-c2mxqf4h.js} +12 -12
- package/{module.command-rv307dk7.js → module.command-b6f1p1xa.js} +5 -5
- package/{package.command-7xkzc8m1.js → package.command-tc27ftmy.js} +3 -3
- package/package.json +2 -2
- package/{page.command-34hpdt7v.js → page.command-m5wyqfkd.js} +3 -3
- package/{pipeline.command-ckvhrpyg.js → pipeline.command-4qxyafpz.js} +2 -2
- package/{primitive.command-em0twr5a.js → primitive.command-9yaatk0d.js} +6 -6
- package/{projectTypecheck-fy6hn05y.js → projectTypecheck-87k6z6ab.js} +1 -1
- package/{quality.command-c6p2819k.js → quality.command-fxn07zwp.js} +387 -73
- package/{repair.command-j6czdgrv.js → repair.command-evg9g911.js} +5 -5
- package/{scalar.command-17e20sj2.js → scalar.command-xsejjeq1.js} +4 -4
- package/{subspace.command-n3j7vv0w.js → subspace.command-4mjjxgmf.js} +8 -8
- package/{tunnel.command-cm578f4s.js → tunnel.command-7f41pm7y.js} +7 -7
- package/{workflow.command-h9vkr6jb.js → workflow.command-qpyq0ya5.js} +10 -10
- package/{workspace.command-tp8ysvjs.js → workspace.command-qvwdqmnd.js} +24 -24
- package/TunnelShare-59zd4j8n.js +0 -14
- package/cloud.script-f0r4ce7j.js +0 -24
- package/context.runner-1cs88ags.js +0 -25
|
@@ -41,19 +41,20 @@ import {
|
|
|
41
41
|
script,
|
|
42
42
|
markCliErrorPrinted,
|
|
43
43
|
assertPromptable
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-p4dnj2wc.js";
|
|
45
45
|
import {
|
|
46
46
|
AppInfo,
|
|
47
47
|
CommandExecutionError,
|
|
48
48
|
WorkspaceExecutor,
|
|
49
|
+
SysExecutor,
|
|
49
50
|
AppExecutor,
|
|
50
51
|
LibExecutor,
|
|
51
52
|
PkgExecutor
|
|
52
|
-
} from "./index-
|
|
53
|
+
} from "./index-rr7jk14m.js";
|
|
53
54
|
import {
|
|
54
55
|
DesktopServerStage,
|
|
55
56
|
UpdateUploader
|
|
56
|
-
} from "./index-
|
|
57
|
+
} from "./index-ekpp5tax.js";
|
|
57
58
|
import {
|
|
58
59
|
resolveMobileTargets,
|
|
59
60
|
resolveAppId
|
|
@@ -62,17 +63,17 @@ import {
|
|
|
62
63
|
NativePublicEnv,
|
|
63
64
|
UpdatePackFolder,
|
|
64
65
|
NativeApp
|
|
65
|
-
} from "./index-
|
|
66
|
+
} from "./index-z9xepn8t.js";
|
|
66
67
|
import {
|
|
67
68
|
LibraryScript
|
|
68
|
-
} from "./index-
|
|
69
|
+
} from "./index-qkcwsg6r.js";
|
|
69
70
|
import {
|
|
70
71
|
stripAnsi
|
|
71
72
|
} from "./index-7md2g9vw.js";
|
|
72
73
|
import {
|
|
73
74
|
SlicePlanner,
|
|
74
75
|
formatSlicePlan
|
|
75
|
-
} from "./index-
|
|
76
|
+
} from "./index-fmder14z.js";
|
|
76
77
|
import {
|
|
77
78
|
openBrowser
|
|
78
79
|
} from "./index-9dp031by.js";
|
|
@@ -82,7 +83,7 @@ import { confirm } from "@inquirer/prompts";
|
|
|
82
83
|
import { Logger as Logger6, toError as toError2 } from "akanjs/common";
|
|
83
84
|
|
|
84
85
|
// pkgs/@akanjs/cli/application/application.runner.ts
|
|
85
|
-
import { realpathSync } from "fs";
|
|
86
|
+
import { existsSync, realpathSync } from "fs";
|
|
86
87
|
import path5 from "path";
|
|
87
88
|
|
|
88
89
|
// pkgs/@akanjs/devkit/akanApp/akanApp.host.ts
|
|
@@ -1899,7 +1900,7 @@ ${uniqueCandidates.map((candidate) => ` - ${candidate}`).join(`
|
|
|
1899
1900
|
|
|
1900
1901
|
// pkgs/@akanjs/cli/application/application.runner.ts
|
|
1901
1902
|
import { Logger as Logger3, toError } from "akanjs/common";
|
|
1902
|
-
var loadBuildRunner = async () => (await import("./applicationBuildRunner-
|
|
1903
|
+
var loadBuildRunner = async () => (await import("./applicationBuildRunner-9cnnsdm5.js")).ApplicationBuildRunner;
|
|
1903
1904
|
var loadPrompts = async () => await import("@inquirer/prompts");
|
|
1904
1905
|
|
|
1905
1906
|
class ApplicationRunner extends runner("application") {
|
|
@@ -2100,7 +2101,7 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
|
|
|
2100
2101
|
await new (await loadBuildRunner())(app).typecheck(options);
|
|
2101
2102
|
}
|
|
2102
2103
|
async typecheckLibrary(lib, options = {}) {
|
|
2103
|
-
const { ProjectTypecheck } = await import("./projectTypecheck-
|
|
2104
|
+
const { ProjectTypecheck } = await import("./projectTypecheck-87k6z6ab.js");
|
|
2104
2105
|
const root = lib.workspace.workspaceRoot;
|
|
2105
2106
|
await new ProjectTypecheck(lib.cwdPath, root, { ...process.env, AKAN_WORKSPACE_ROOT: root }).run([
|
|
2106
2107
|
"../../server.ts",
|
|
@@ -2111,7 +2112,20 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
|
|
|
2111
2112
|
"../../../../pkgs/akanjs/*/types/**/*.d.ts"
|
|
2112
2113
|
], options);
|
|
2113
2114
|
}
|
|
2114
|
-
|
|
2115
|
+
resolveTestPaths(exec, files) {
|
|
2116
|
+
const root = exec instanceof SysExecutor || exec instanceof PkgExecutor ? exec.workspace.workspaceRoot : process.cwd();
|
|
2117
|
+
const target = path5.relative(root, exec.cwdPath).split(path5.sep).join("/");
|
|
2118
|
+
const isInside = (relative) => relative !== ".." && !relative.startsWith(`..${path5.sep}`) && !path5.isAbsolute(relative);
|
|
2119
|
+
return files.map((file) => {
|
|
2120
|
+
const candidates = path5.isAbsolute(file) ? [file] : [path5.resolve(exec.cwdPath, file), path5.resolve(root, file)];
|
|
2121
|
+
const existing = candidates.filter((candidate) => existsSync(candidate)).map((candidate) => path5.relative(exec.cwdPath, candidate));
|
|
2122
|
+
const found = existing.find(isInside);
|
|
2123
|
+
if (found === undefined)
|
|
2124
|
+
throw new Error(existing.length ? `${file} is outside ${target}: akan test ${exec.name} runs its own tests only` : `${file} names no file or folder in ${target}`);
|
|
2125
|
+
return `./${found.split(path5.sep).join("/")}`;
|
|
2126
|
+
});
|
|
2127
|
+
}
|
|
2128
|
+
async test(exec, testPaths = []) {
|
|
2115
2129
|
const isSignalTarget = exec instanceof AppExecutor || exec instanceof LibExecutor;
|
|
2116
2130
|
const preloadPath = isSignalTarget ? await resolveSignalTestPreloadPath(exec) : null;
|
|
2117
2131
|
const env = isSignalTarget ? {
|
|
@@ -2121,7 +2135,7 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
|
|
|
2121
2135
|
AKAN_TEST_LIBS: exec.getScanInfo({ allowEmpty: true })?.getLibs().join(",") ?? "",
|
|
2122
2136
|
AKAN_RUNTIME_DIR: path5.join(exec.workspace.workspaceRoot, "local", `${exec.type}s`, exec.name, "runtime")
|
|
2123
2137
|
} : {};
|
|
2124
|
-
const args =
|
|
2138
|
+
const args = ["test", "--isolate", ...preloadPath ? ["--preload", preloadPath] : [], ...testPaths];
|
|
2125
2139
|
await exec.spawn("bun", args, {
|
|
2126
2140
|
...isSignalTarget ? { env: { ...process.env, ...env } } : {},
|
|
2127
2141
|
stdio: "inherit"
|
|
@@ -3437,14 +3451,15 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
|
|
|
3437
3451
|
throw error;
|
|
3438
3452
|
}
|
|
3439
3453
|
}
|
|
3440
|
-
async test(exec, { write = true } = {}) {
|
|
3454
|
+
async test(exec, { write = true, files = [] } = {}) {
|
|
3455
|
+
const testPaths = this.applicationRunner.resolveTestPaths(exec, files);
|
|
3441
3456
|
if (exec instanceof LibExecutor) {
|
|
3442
3457
|
if (write)
|
|
3443
3458
|
await this.libraryScript.syncLibrary(exec);
|
|
3444
3459
|
else
|
|
3445
3460
|
await exec.scan({ write: false });
|
|
3446
3461
|
exec.spinning(`Preparing ${exec.name}...`).succeed(`${exec.name} prepared`);
|
|
3447
|
-
await this.applicationRunner.test(exec);
|
|
3462
|
+
await this.applicationRunner.test(exec, testPaths);
|
|
3448
3463
|
return;
|
|
3449
3464
|
}
|
|
3450
3465
|
const spinner = exec.spinning(`Preparing ${exec.name}...`);
|
|
@@ -3458,7 +3473,7 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
|
|
|
3458
3473
|
spinner.fail(`${exec.name} prepare failed`);
|
|
3459
3474
|
throw error;
|
|
3460
3475
|
}
|
|
3461
|
-
await this.applicationRunner.test(exec);
|
|
3476
|
+
await this.applicationRunner.test(exec, testPaths);
|
|
3462
3477
|
}
|
|
3463
3478
|
async start(apps, {
|
|
3464
3479
|
open = false,
|
|
@@ -3691,7 +3706,7 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
|
|
|
3691
3706
|
await Promise.all(shares.map(async (share) => await share.close()));
|
|
3692
3707
|
}, "Abandoning the tunnel release; the shares expire on their own.");
|
|
3693
3708
|
await Promise.all(apps.map(async (app) => {
|
|
3694
|
-
const { TunnelShare } = await import("./TunnelShare-
|
|
3709
|
+
const { TunnelShare } = await import("./TunnelShare-8qtffcex.js");
|
|
3695
3710
|
const share = await TunnelShare.open(app, { workspace: app.workspace });
|
|
3696
3711
|
shares.push(share);
|
|
3697
3712
|
urls.set(app.name, share.url);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
runner,
|
|
4
4
|
script
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-p4dnj2wc.js";
|
|
6
6
|
import {
|
|
7
7
|
AGENT_BLOCK_START,
|
|
8
8
|
AGENT_BLOCK_END,
|
|
@@ -13,14 +13,14 @@ import {
|
|
|
13
13
|
CLAUDE_COMMENT_RULE,
|
|
14
14
|
AppExecutor,
|
|
15
15
|
LibExecutor
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-rr7jk14m.js";
|
|
17
17
|
import {
|
|
18
18
|
collectRecipeSources2,
|
|
19
19
|
scanRecipes2
|
|
20
20
|
} from "./index-hj6w4ka1.js";
|
|
21
21
|
import {
|
|
22
22
|
AkanContextAnalyzer
|
|
23
|
-
} from "./index-
|
|
23
|
+
} from "./index-z6v7k9sb.js";
|
|
24
24
|
import {
|
|
25
25
|
Prompter2
|
|
26
26
|
} from "./index-zzvvc845.js";
|
|
@@ -9,14 +9,17 @@ import {
|
|
|
9
9
|
NativePublicEnv,
|
|
10
10
|
UpdatePackFolder,
|
|
11
11
|
NativeApp
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-z9xepn8t.js";
|
|
13
13
|
import {
|
|
14
14
|
ExitCodeError
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-p4dnj2wc.js";
|
|
16
16
|
import {
|
|
17
17
|
ConfigLock
|
|
18
18
|
} from "./index-bqbf654f.js";
|
|
19
19
|
|
|
20
|
+
// pkgs/@akanjs/devkit/cloud/cloudApi.ts
|
|
21
|
+
import { isRecord as isRecord2 } from "akanjs/common";
|
|
22
|
+
|
|
20
23
|
// pkgs/@akanjs/devkit/cloud/cloudHttpError.ts
|
|
21
24
|
import { isRecord } from "akanjs/common";
|
|
22
25
|
|
|
@@ -278,6 +281,7 @@ class CloudApi {
|
|
|
278
281
|
return new Error(`${unavailable}: ${errKey}.`, { cause: error });
|
|
279
282
|
return error;
|
|
280
283
|
}
|
|
284
|
+
static #remoteAuthTimeoutMs = 20000;
|
|
281
285
|
#api;
|
|
282
286
|
#accessToken = null;
|
|
283
287
|
#workspace;
|
|
@@ -345,11 +349,14 @@ class CloudApi {
|
|
|
345
349
|
return localPath;
|
|
346
350
|
}
|
|
347
351
|
async getRemoteAuthToken(remoteId) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
352
|
+
const answer = await this.#api.get(`/getRemoteAuthToken/${encodeURIComponent(remoteId)}`, {
|
|
353
|
+
signal: AbortSignal.timeout(CloudApi.#remoteAuthTimeoutMs)
|
|
354
|
+
});
|
|
355
|
+
if (answer === null)
|
|
351
356
|
return null;
|
|
352
|
-
|
|
357
|
+
if (!isRecord2(answer) || typeof answer.jwt !== "string" || !answer.jwt)
|
|
358
|
+
throw new Error(`${this.host} answered the sign-in poll with something other than a session.`);
|
|
359
|
+
return this.#authorize(answer);
|
|
353
360
|
}
|
|
354
361
|
async refreshAuthToken(refreshToken) {
|
|
355
362
|
return this.#authorize(await this.#api.post(`/refreshAuthToken`, { refreshToken }, { signal: AbortSignal.timeout(20000) }));
|
|
@@ -364,11 +371,9 @@ class CloudApi {
|
|
|
364
371
|
return await this.#api.post(`/tunnel/revokeTunnel`, { code }, { signal: AbortSignal.timeout(5000) });
|
|
365
372
|
}
|
|
366
373
|
async getRemoteSelf() {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}
|
|
370
|
-
return null;
|
|
371
|
-
}
|
|
374
|
+
return await this.#api.get(`/getRemoteSelf`, {
|
|
375
|
+
signal: AbortSignal.timeout(CloudApi.#remoteAuthTimeoutMs)
|
|
376
|
+
});
|
|
372
377
|
}
|
|
373
378
|
}
|
|
374
379
|
// pkgs/@akanjs/devkit/cloud/cloudUpdates.ts
|
|
@@ -664,4 +669,4 @@ class PipelineSecrets {
|
|
|
664
669
|
throw new Error(`--branch ${branch} is not a deployed branch: ${PipelineSecrets.#secretBranches.join(", ")}.`);
|
|
665
670
|
}
|
|
666
671
|
}
|
|
667
|
-
export { getDefaultHostConfig, GlobalConfig, CloudApi, CloudUpdates, PipelineSecrets };
|
|
672
|
+
export { CloudHttpError, getDefaultHostConfig, GlobalConfig, CloudApi, CloudUpdates, PipelineSecrets };
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
McpServerConfig,
|
|
6
6
|
McpSignIn,
|
|
7
7
|
AkanCodeCompaction2
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-9hbhm6cs.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-
|
|
812
|
+
const { ContextRunner } = await import("./context.runner-3jrypwe3.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-
|
|
820
|
+
const { ContextRunner } = await import("./context.runner-3jrypwe3.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 })) {
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
+
CloudHttpError,
|
|
3
4
|
getDefaultHostConfig,
|
|
4
5
|
GlobalConfig,
|
|
5
6
|
CloudApi,
|
|
6
7
|
CloudUpdates,
|
|
7
8
|
PipelineSecrets
|
|
8
|
-
} from "./index-
|
|
9
|
+
} from "./index-2ar6tffh.js";
|
|
9
10
|
import {
|
|
10
11
|
WorkspaceExecutor,
|
|
11
12
|
AppExecutor
|
|
12
|
-
} from "./index-
|
|
13
|
+
} from "./index-rr7jk14m.js";
|
|
13
14
|
import {
|
|
14
15
|
runner,
|
|
15
16
|
assertPromptable
|
|
16
|
-
} from "./index-
|
|
17
|
+
} from "./index-p4dnj2wc.js";
|
|
17
18
|
import {
|
|
18
19
|
SubspaceConfig
|
|
19
20
|
} from "./index-4pf8g7ff.js";
|
|
@@ -675,9 +676,136 @@ class PlatformTestRun {
|
|
|
675
676
|
|
|
676
677
|
// pkgs/@akanjs/cli/cloud/cloud.runner.ts
|
|
677
678
|
import { confirm, input, select } from "@inquirer/prompts";
|
|
678
|
-
import { Logger
|
|
679
|
+
import { Logger as Logger2 } from "akanjs/common";
|
|
680
|
+
import chalk3 from "chalk";
|
|
681
|
+
|
|
682
|
+
// pkgs/@akanjs/cli/cloud/remoteLogin.ts
|
|
683
|
+
import { Backoff, Logger, RemoteAuthCode, sleep } from "akanjs/common";
|
|
679
684
|
import chalk2 from "chalk";
|
|
680
685
|
import * as QRcode from "qrcode";
|
|
686
|
+
class RemoteLogin {
|
|
687
|
+
#api;
|
|
688
|
+
#pollMs;
|
|
689
|
+
#limitMs;
|
|
690
|
+
#maxBackoffMs;
|
|
691
|
+
#selfAttempts;
|
|
692
|
+
#open;
|
|
693
|
+
#wait;
|
|
694
|
+
#now;
|
|
695
|
+
constructor(api, {
|
|
696
|
+
pollMs = 2000,
|
|
697
|
+
limitMs = 10 * 60000,
|
|
698
|
+
maxBackoffMs = 30000,
|
|
699
|
+
selfAttempts = 5,
|
|
700
|
+
open = openBrowser,
|
|
701
|
+
wait = sleep,
|
|
702
|
+
now = Date.now
|
|
703
|
+
} = {}) {
|
|
704
|
+
this.#api = api;
|
|
705
|
+
this.#pollMs = pollMs;
|
|
706
|
+
this.#limitMs = limitMs;
|
|
707
|
+
this.#maxBackoffMs = maxBackoffMs;
|
|
708
|
+
this.#selfAttempts = selfAttempts;
|
|
709
|
+
this.#open = open;
|
|
710
|
+
this.#wait = wait;
|
|
711
|
+
this.#now = now;
|
|
712
|
+
}
|
|
713
|
+
async signIn(remoteId = crypto.randomUUID()) {
|
|
714
|
+
const loginId = await RemoteAuthCode.loginIdOf(remoteId);
|
|
715
|
+
await this.#prompt(remoteId, loginId);
|
|
716
|
+
const accessToken = await this.#awaitApproval(remoteId, loginId);
|
|
717
|
+
const { host } = this.#api;
|
|
718
|
+
await GlobalConfig.setHostConfig({ host, auth: { accessToken } });
|
|
719
|
+
const self = await this.#readSelf();
|
|
720
|
+
if (self)
|
|
721
|
+
await GlobalConfig.setHostConfig({ host, auth: { accessToken, self } });
|
|
722
|
+
return self;
|
|
723
|
+
}
|
|
724
|
+
async#prompt(remoteId, loginId) {
|
|
725
|
+
const signinUrl = `${this.#api.host}/remoteAuth?remoteId=${encodeURIComponent(loginId)}`;
|
|
726
|
+
Logger.rawLog(chalk2.bold(`
|
|
727
|
+
${chalk2.green("\u27A4")} Authentication Required`));
|
|
728
|
+
Logger.rawLog(chalk2.dim("Please visit or click the following URL:"));
|
|
729
|
+
Logger.rawLog(`${chalk2.cyan.underline(signinUrl)}
|
|
730
|
+
`);
|
|
731
|
+
try {
|
|
732
|
+
Logger.rawLog(await QRcode.toString(signinUrl, { type: "terminal", small: true }));
|
|
733
|
+
await this.#open(signinUrl);
|
|
734
|
+
Logger.rawLog(chalk2.dim("Opening browser..."));
|
|
735
|
+
} catch {
|
|
736
|
+
Logger.rawLog(chalk2.yellow("Could not open browser. Please visit the URL manually."));
|
|
737
|
+
}
|
|
738
|
+
Logger.rawLog(`
|
|
739
|
+
${chalk2.bold("Your code:")} ${chalk2.bold.inverse(` ${await RemoteAuthCode.of(remoteId)} `)}`);
|
|
740
|
+
Logger.rawLog(chalk2.dim(`Enter this code on the sign-in page, and approve only if it matches what this terminal shows.
|
|
741
|
+
`));
|
|
742
|
+
}
|
|
743
|
+
async#awaitApproval(remoteId, loginId) {
|
|
744
|
+
Logger.rawLog(chalk2.dim("Waiting for authentication..."));
|
|
745
|
+
const deadline = this.#now() + this.#limitMs;
|
|
746
|
+
const ids = [remoteId, loginId];
|
|
747
|
+
let failures = 0;
|
|
748
|
+
while (this.#now() < deadline) {
|
|
749
|
+
const answers = await Promise.allSettled(ids.map((id) => this.#api.getRemoteAuthToken(id)));
|
|
750
|
+
for (const answer of answers)
|
|
751
|
+
if (answer.status === "fulfilled" && answer.value)
|
|
752
|
+
return answer.value;
|
|
753
|
+
const [device, legacy] = answers.map((answer) => answer.status === "rejected" ? answer.reason : null);
|
|
754
|
+
if (RemoteLogin.#isFinal(device))
|
|
755
|
+
throw this.#refusal(device);
|
|
756
|
+
if (RemoteLogin.#isFinal(legacy))
|
|
757
|
+
ids.pop();
|
|
758
|
+
const errors = [device, legacy].filter((error) => error && !RemoteLogin.#isFinal(error));
|
|
759
|
+
const retryAfterMs = Math.max(0, ...errors.map((error) => (error instanceof CloudHttpError ? error.retryAfterMs : null) ?? 0));
|
|
760
|
+
let waitMs = Math.max(this.#pollMs, retryAfterMs);
|
|
761
|
+
if (answers.some((answer) => answer.status === "fulfilled"))
|
|
762
|
+
failures = 0;
|
|
763
|
+
else {
|
|
764
|
+
if (failures++ === 0)
|
|
765
|
+
Logger.rawLog(chalk2.yellow(`Could not check the sign-in (${RemoteLogin.#reasonOf(errors[0])}); retrying...`));
|
|
766
|
+
waitMs = Math.max(retryAfterMs, Backoff.delay(failures + 1, { min: this.#pollMs, max: this.#maxBackoffMs }));
|
|
767
|
+
}
|
|
768
|
+
await this.#wait(Math.min(waitMs, Math.max(0, deadline - this.#now())));
|
|
769
|
+
}
|
|
770
|
+
throw new Error(chalk2.red(`\u2716 Authentication timed out after ${Math.round(this.#limitMs / 60000)} minutes. Please try again.`));
|
|
771
|
+
}
|
|
772
|
+
async#readSelf() {
|
|
773
|
+
let reason = "";
|
|
774
|
+
for (let attempt = 1;attempt <= this.#selfAttempts; attempt++) {
|
|
775
|
+
try {
|
|
776
|
+
const self = await this.#api.getRemoteSelf();
|
|
777
|
+
if (self)
|
|
778
|
+
return self;
|
|
779
|
+
reason = "the server did not take the new session";
|
|
780
|
+
break;
|
|
781
|
+
} catch (error) {
|
|
782
|
+
reason = RemoteLogin.#reasonOf(error);
|
|
783
|
+
}
|
|
784
|
+
if (attempt < this.#selfAttempts)
|
|
785
|
+
await this.#wait(Backoff.delay(attempt, { min: 1000, max: 8000 }));
|
|
786
|
+
}
|
|
787
|
+
Logger.rawLog(chalk2.yellow(`Could not read the signed-in account (${reason}).`));
|
|
788
|
+
return null;
|
|
789
|
+
}
|
|
790
|
+
static #isFinal(error) {
|
|
791
|
+
return error instanceof CloudHttpError && error.status < 500 && error.status !== 408 && error.status !== 429;
|
|
792
|
+
}
|
|
793
|
+
#refusal(error) {
|
|
794
|
+
const { host } = this.#api;
|
|
795
|
+
if (error.status === 404 && !error.errKey)
|
|
796
|
+
return new Error(chalk2.red(`\u2716 ${host} does not serve Akan CLI sign-ins (HTTP 404): check --host.`), {
|
|
797
|
+
cause: error
|
|
798
|
+
});
|
|
799
|
+
return new Error(chalk2.red(`\u2716 ${host} refused this sign-in (${error.errKey ?? `HTTP ${error.status}`}). Run akan login to start over.`), { cause: error });
|
|
800
|
+
}
|
|
801
|
+
static #reasonOf(error) {
|
|
802
|
+
if (error instanceof CloudHttpError)
|
|
803
|
+
return error.errKey ?? `HTTP ${error.status}`;
|
|
804
|
+
return error instanceof Error ? error.message : String(error);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// pkgs/@akanjs/cli/cloud/cloud.runner.ts
|
|
681
809
|
var addRemoteEnvServerValue = "__addRemoteEnvServer";
|
|
682
810
|
var removeRemoteEnvServerValue = "__removeRemoteEnvServer";
|
|
683
811
|
|
|
@@ -726,7 +854,7 @@ class CloudRunner extends runner("cloud") {
|
|
|
726
854
|
const servers = await GlobalConfig.getRemoteEnvServers();
|
|
727
855
|
const serverEntries = Object.entries(servers).sort(([nameA], [nameB]) => nameA.localeCompare(nameB));
|
|
728
856
|
if (serverEntries.length === 0) {
|
|
729
|
-
|
|
857
|
+
Logger2.info("No remote env servers configured. Add the first remote server for SCP mode.");
|
|
730
858
|
return await this.#addRemoteEnvServer();
|
|
731
859
|
}
|
|
732
860
|
const selectedName = await select({
|
|
@@ -756,7 +884,7 @@ class CloudRunner extends runner("cloud") {
|
|
|
756
884
|
if (!await confirm({ message: `Remove remote env server "${selectedName}"?`, default: false }))
|
|
757
885
|
return;
|
|
758
886
|
await GlobalConfig.removeRemoteEnvServer(selectedName);
|
|
759
|
-
|
|
887
|
+
Logger2.info(`Removed remote env server "${selectedName}"`);
|
|
760
888
|
}
|
|
761
889
|
#serverChoice([name, config]) {
|
|
762
890
|
return { name: `${name} (${this.#getSshTarget(config)}${config.port ? `:${config.port}` : ""})`, value: name };
|
|
@@ -792,67 +920,41 @@ class CloudRunner extends runner("cloud") {
|
|
|
792
920
|
}
|
|
793
921
|
async login(host, workspace) {
|
|
794
922
|
const cloudApi = await CloudApi.fromHost(workspace, host);
|
|
795
|
-
const
|
|
796
|
-
if (
|
|
797
|
-
|
|
798
|
-
\u2713 Already logged in akan cloud as ${
|
|
923
|
+
const signedIn = await cloudApi.getRemoteSelf().catch(() => null);
|
|
924
|
+
if (signedIn) {
|
|
925
|
+
Logger2.rawLog(chalk3.green(`
|
|
926
|
+
\u2713 Already logged in akan cloud as ${signedIn.nickname}
|
|
799
927
|
`));
|
|
800
928
|
return true;
|
|
801
929
|
}
|
|
802
|
-
const
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
`);
|
|
809
|
-
try {
|
|
810
|
-
const qrcode = await new Promise((resolve, reject) => {
|
|
811
|
-
QRcode.toString(signinUrl, { type: "terminal", small: true }, (err, data) => {
|
|
812
|
-
if (err)
|
|
813
|
-
reject(err);
|
|
814
|
-
resolve(data);
|
|
815
|
-
});
|
|
816
|
-
});
|
|
817
|
-
Logger.rawLog(qrcode);
|
|
818
|
-
await openBrowser(signinUrl);
|
|
819
|
-
Logger.rawLog(chalk2.dim("Opening browser..."));
|
|
820
|
-
} catch {
|
|
821
|
-
Logger.rawLog(chalk2.yellow("Could not open browser. Please visit the URL manually."));
|
|
930
|
+
const self = await new RemoteLogin(cloudApi).signIn();
|
|
931
|
+
Logger2.rawLog(chalk3.green(`\r\u2713 Authentication successful!`));
|
|
932
|
+
if (!self) {
|
|
933
|
+
Logger2.rawLog(chalk3.yellow(`The session is saved; run akan login again to check which account it signed in.
|
|
934
|
+
`));
|
|
935
|
+
return true;
|
|
822
936
|
}
|
|
823
|
-
|
|
824
|
-
const MAX_RETRY = 300;
|
|
825
|
-
for (let i = 0;i < MAX_RETRY; i++) {
|
|
826
|
-
const accessToken = await cloudApi.getRemoteAuthToken(remoteId);
|
|
827
|
-
const self = await cloudApi.getRemoteSelf();
|
|
828
|
-
if (accessToken && self) {
|
|
829
|
-
await GlobalConfig.setHostConfig({ host: cloudApi.host, auth: { accessToken, self } });
|
|
830
|
-
Logger.rawLog(chalk2.green(`\r\u2713 Authentication successful!`));
|
|
831
|
-
Logger.rawLog(chalk2.green.bold(`
|
|
937
|
+
Logger2.rawLog(chalk3.green.bold(`
|
|
832
938
|
\u2728 Welcome aboard, ${self.nickname ?? "anonymous"}!`));
|
|
833
|
-
|
|
939
|
+
Logger2.rawLog(chalk3.dim(`You're now ready to use Akan CLI!
|
|
834
940
|
`));
|
|
835
|
-
|
|
836
|
-
}
|
|
837
|
-
await sleep(2000);
|
|
838
|
-
}
|
|
839
|
-
throw new Error(chalk2.red("\u2716 Authentication timed out after 10 minutes. Please try again."));
|
|
941
|
+
return true;
|
|
840
942
|
}
|
|
841
943
|
async logout(host) {
|
|
842
944
|
const config = await GlobalConfig.getHostConfig(host);
|
|
843
|
-
if (config.auth?.self) {
|
|
945
|
+
if (config.auth?.self || config.auth?.accessToken) {
|
|
844
946
|
await GlobalConfig.setHostConfig(getDefaultHostConfig(config.host));
|
|
845
|
-
|
|
846
|
-
\uD83D\uDC4B Goodbye, ${config.auth.self
|
|
847
|
-
|
|
947
|
+
Logger2.rawLog(chalk3.magenta.bold(`
|
|
948
|
+
\uD83D\uDC4B Goodbye, ${config.auth.self?.nickname ?? "anonymous"}!`));
|
|
949
|
+
Logger2.rawLog(chalk3.dim(`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
848
950
|
`));
|
|
849
|
-
|
|
850
|
-
|
|
951
|
+
Logger2.rawLog(chalk3.cyan("You have been successfully logged out."));
|
|
952
|
+
Logger2.rawLog(chalk3.dim(`Thank you for using Akan CLI. Come back soon! \uD83C\uDF1F
|
|
851
953
|
`));
|
|
852
954
|
} else {
|
|
853
|
-
|
|
955
|
+
Logger2.rawLog(chalk3.yellow.bold(`
|
|
854
956
|
\u26A0\uFE0F No active session found`));
|
|
855
|
-
|
|
957
|
+
Logger2.rawLog(chalk3.dim(`You were not logged in to begin with
|
|
856
958
|
`));
|
|
857
959
|
}
|
|
858
960
|
}
|
|
@@ -862,24 +964,24 @@ ${chalk2.green("\u27A4")} Authentication Required`));
|
|
|
862
964
|
targets.windows = await this.#askWindowsTestTarget();
|
|
863
965
|
await GlobalConfig.setTestTargets({ windows: targets.windows });
|
|
864
966
|
}
|
|
865
|
-
|
|
967
|
+
Logger2.info(`Testing ${pkgs.join(", ")} on ${platforms.join(", ")} in the background...`);
|
|
866
968
|
return await PlatformTestRun.start({
|
|
867
969
|
workspaceRoot: workspace.workspaceRoot,
|
|
868
970
|
platforms,
|
|
869
971
|
pkgs,
|
|
870
972
|
targets,
|
|
871
|
-
onProgress: (message) =>
|
|
973
|
+
onProgress: (message) => Logger2.info(message)
|
|
872
974
|
});
|
|
873
975
|
}
|
|
874
976
|
async settlePlatformTests(run, { interactive, recordStreaks, checkDrift }) {
|
|
875
977
|
const results = await run.results();
|
|
876
|
-
|
|
978
|
+
Logger2.rawLog(`
|
|
877
979
|
${run.format(results)}
|
|
878
980
|
`);
|
|
879
981
|
if (recordStreaks) {
|
|
880
982
|
const streak = await PlatformTestRun.recordStreaks(results);
|
|
881
983
|
if (streak?.promoted)
|
|
882
|
-
|
|
984
|
+
Logger2.info(`${streak.platform} passed ${streak.greenStreak} deploys in a row and now gates every deploy`);
|
|
883
985
|
}
|
|
884
986
|
const { blocking, warning } = PlatformTestRun.verdict(results);
|
|
885
987
|
const unreachable = blocking.filter((result) => result.infraError && !result.packages.length);
|
|
@@ -914,7 +1016,7 @@ ${run.format(results)}
|
|
|
914
1016
|
assertPromptable("No Windows test target is configured", {
|
|
915
1017
|
remedy: "run it once in a terminal, which saves the target to ~/.akan/config.json"
|
|
916
1018
|
});
|
|
917
|
-
|
|
1019
|
+
Logger2.info("No Windows test target is configured yet; it is saved to ~/.akan/config.json once entered.");
|
|
918
1020
|
const required = (value) => !!value.trim();
|
|
919
1021
|
const host = await this.#ask("Windows host (ip or name): ", required);
|
|
920
1022
|
const user = await this.#ask("SSH user: ", required);
|
|
@@ -944,8 +1046,8 @@ ${run.format(results)}
|
|
|
944
1046
|
const latestPublishedVersion = await getLatestPackageVersion("akanjs", tag, registry).catch(() => null);
|
|
945
1047
|
const latestPatch = latestPublishedVersion?.startsWith(targetVersionPrefix) ? parseInt(latestPublishedVersion.split(".").at(-1) ?? "-1") : -1;
|
|
946
1048
|
const nextVersion = `${targetVersionPrefix}.${latestPatch + 1}`;
|
|
947
|
-
|
|
948
|
-
|
|
1049
|
+
Logger2.info(`Latest published version of akanjs: ${latestPublishedVersion ?? "none"}`);
|
|
1050
|
+
Logger2.info(`Next version of akanjs: ${nextVersion}`);
|
|
949
1051
|
for (const library of akanPkgs) {
|
|
950
1052
|
const packageJson = await workspace.readJson(`pkgs/${library}/package.json`);
|
|
951
1053
|
const newPackageJson = this.#normalizeAkanPackageJson(packageJson, library, nextVersion);
|
|
@@ -959,24 +1061,24 @@ ${run.format(results)}
|
|
|
959
1061
|
remedy: "run it in a terminal"
|
|
960
1062
|
});
|
|
961
1063
|
if (confirmPublish && !await confirm({ message: "Are you sure you want to deploy the libraries?" })) {
|
|
962
|
-
|
|
1064
|
+
Logger2.error("Deployment cancelled");
|
|
963
1065
|
return;
|
|
964
1066
|
}
|
|
965
1067
|
if (!registry) {
|
|
966
|
-
|
|
1068
|
+
Logger2.info("Logging in to npm...");
|
|
967
1069
|
await workspace.spawn("npm", ["login"], { stdio: "inherit" });
|
|
968
|
-
|
|
1070
|
+
Logger2.info("Logged in to npm");
|
|
969
1071
|
}
|
|
970
1072
|
for (const library of akanPkgs) {
|
|
971
|
-
|
|
1073
|
+
Logger2.info(`Publishing ${library}@${nextVersion} to ${registry ?? "npm"}...`);
|
|
972
1074
|
await workspace.spawn("npm", ["publish", "--tag", tag, ...this.#getRegistryArgs(registry), ...this.#getLocalRegistryAuthArgs(registry)], {
|
|
973
1075
|
cwd: path7.join(workspace.workspaceRoot, "dist/pkgs", library),
|
|
974
1076
|
env: this.#getRegistryEnv(registry),
|
|
975
1077
|
stdio: "inherit"
|
|
976
1078
|
});
|
|
977
|
-
|
|
1079
|
+
Logger2.info(`${library}@${nextVersion} is published to ${registry ?? "npm"}`);
|
|
978
1080
|
}
|
|
979
|
-
|
|
1081
|
+
Logger2.info(`All libraries are published to ${registry ?? "npm"}`);
|
|
980
1082
|
}
|
|
981
1083
|
async update(workspace, tag = "latest", { registryUrl } = {}) {
|
|
982
1084
|
const registry = registryUrl ? getNpmRegistryUrl(registryUrl) : undefined;
|
|
@@ -1043,7 +1145,7 @@ ${run.format(results)}
|
|
|
1043
1145
|
await workspace.mkdir("local");
|
|
1044
1146
|
await workspace.remove(envArchivePath);
|
|
1045
1147
|
try {
|
|
1046
|
-
|
|
1148
|
+
Logger2.info(`Downloading env archive from remote server "${remoteServer.name}"...`);
|
|
1047
1149
|
await workspace.spawn("scp", this.#getScpArgs(remoteServer.config, remoteTarget, envArchivePath), {
|
|
1048
1150
|
cwd: workspace.workspaceRoot,
|
|
1049
1151
|
stdio: "inherit"
|
|
@@ -1064,7 +1166,7 @@ ${run.format(results)}
|
|
|
1064
1166
|
cwd: workspace.workspaceRoot,
|
|
1065
1167
|
stdio: "inherit"
|
|
1066
1168
|
});
|
|
1067
|
-
|
|
1169
|
+
Logger2.info(`Uploading env archive to remote server "${remoteServer.name}"...`);
|
|
1068
1170
|
await workspace.spawn("scp", this.#getScpArgs(remoteServer.config, filePath, remoteTarget), {
|
|
1069
1171
|
cwd: workspace.workspaceRoot,
|
|
1070
1172
|
stdio: "inherit"
|
|
@@ -1091,7 +1193,7 @@ ${run.format(results)}
|
|
|
1091
1193
|
if (envFilePaths.length === 0)
|
|
1092
1194
|
throw new Error(scope ? `No environment files found to archive for ${appNames.join(", ") || "(no apps)"}` : "No environment files found to archive");
|
|
1093
1195
|
await workspace.spawn("tar", ["-cf", archivePath, ...envFilePaths], { cwd: workspace.workspaceRoot });
|
|
1094
|
-
|
|
1196
|
+
Logger2.info(`Archived ${envFilePaths.length} environment files to ${archivePath}`);
|
|
1095
1197
|
return { files: envFilePaths, path: archivePath };
|
|
1096
1198
|
}
|
|
1097
1199
|
async#gatherCustomSecretFiles(workspace, appNames) {
|
|
@@ -1154,7 +1256,7 @@ ${run.format(results)}
|
|
|
1154
1256
|
if (nextContent === existing)
|
|
1155
1257
|
return;
|
|
1156
1258
|
await workspace.writeFile(".gitignore", nextContent);
|
|
1157
|
-
|
|
1259
|
+
Logger2.info(uniquePatterns.length ? `Synced ${uniquePatterns.length} secret pattern(s) from akan.config.ts to .gitignore` : "Removed managed secret patterns from .gitignore");
|
|
1158
1260
|
}
|
|
1159
1261
|
#applySecretGitignoreBlock(content, patterns) {
|
|
1160
1262
|
const beginMarker = "# akan:secrets (managed by akan.config.ts \u2014 do not edit)";
|
|
@@ -179,7 +179,7 @@ class SubagentPool2 {
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
async#run(id, kind, prompt, signal) {
|
|
182
|
-
const { CodeAgent } = await import("./CodeAgent-
|
|
182
|
+
const { CodeAgent } = await import("./CodeAgent-4pnxwptq.js");
|
|
183
183
|
const budget = this.#options.parent.tools.subagent;
|
|
184
184
|
const child = SubagentPool2.childOf(this.#options.parent, kind);
|
|
185
185
|
const agent = await CodeAgent.create({
|