@akanjs/cli 3.0.0-beta.1 → 3.0.0-beta.11

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 (60) hide show
  1. package/.build-stamp +1 -1
  2. package/TunnelShare-sbsaggmb.js +9 -0
  3. package/{abstractCompactor-mjh5ppsq.js → abstractCompactor-bqh31fk5.js} +2 -1
  4. package/{agent.command-d2gfxfck.js → agent.command-7357vxd8.js} +5 -5
  5. package/{application.command-pj2m7584.js → application.command-pc8mdn3w.js} +10 -10
  6. package/{applicationBuildRunner-kxwbssgn.js → applicationBuildRunner-4f1wrba0.js} +2 -2
  7. package/{applicationReleasePackager-4yasxwv9.js → applicationReleasePackager-jkjmy5ee.js} +1 -1
  8. package/buildBatch.proc.js +2 -2
  9. package/{capacitorApp-36rbr858.js → capacitorApp-hqvsrec4.js} +2 -2
  10. package/{cloud.command-jshwdq22.js → cloud.command-cawrd5nq.js} +12 -11
  11. package/cloud.script-1bmptvw0.js +20 -0
  12. package/commandManifest.json +1 -1
  13. package/{context.command-ez8a0zyz.js → context.command-982b6kdp.js} +14 -13
  14. package/{devTui-40ggmd99.js → devTui-hmteztv3.js} +4 -24
  15. package/{devTuiView-c08ccbat.js → devTuiView-40jvjnyz.js} +1 -1
  16. package/{guideline.command-xmqwx8zm.js → guideline.command-jn0vwszx.js} +4 -3
  17. package/guidelines/agentRule/agentRule.instruction.md +109 -4
  18. package/guidelines/conventions/conventions.instruction.md +19 -0
  19. package/guidelines/fieldRule/fieldRule.instruction.md +1 -0
  20. package/guidelines/transportRule/transportRule.instruction.md +49 -0
  21. package/incrementalBuilder.proc.js +1 -1
  22. package/{index-ktb5njgy.js → index-15r9a10e.js} +2 -2
  23. package/{index-259dsnz3.js → index-1nwxbr2y.js} +2 -2
  24. package/{index-600zhnve.js → index-3pvkjza8.js} +10 -10
  25. package/{index-2tv3fdx4.js → index-5nyznra1.js} +1 -0
  26. package/{index-wt7qrtd4.js → index-7f4dsf9v.js} +1 -1
  27. package/{index-7737gxcp.js → index-8pkvrcv1.js} +3 -3
  28. package/{index-2hq52jq3.js → index-8tfmh0v6.js} +25 -19
  29. package/{index-zry5nz81.js → index-ay8wj00x.js} +23 -14
  30. package/{index-mak3cd28.js → index-b3ae16mg.js} +25 -25
  31. package/index-bw2marpf.js +237 -0
  32. package/{index-rwg2aa4f.js → index-ceph7zqj.js} +3 -3
  33. package/{index-fz5q3gd7.js → index-em4swemt.js} +3 -3
  34. package/{index-8pm30m73.js → index-fr2x3qvv.js} +7 -7
  35. package/index-jcekapz4.js +49 -0
  36. package/{index-gyd220p2.js → index-jwjaf9fy.js} +1 -1
  37. package/{index-4edzf1gr.js → index-kbsach1y.js} +4 -4
  38. package/index-p6pbz9n5.js +25 -0
  39. package/{index-v0qh106m.js → index-r8bd61d9.js} +46 -11
  40. package/{index-ne2qy0nk.js → index-s3fvrydw.js} +3 -3
  41. package/{index-pnqbkf5p.js → index-sh88vtye.js} +1 -1
  42. package/{index-ws5e0j51.js → index-t8gvwcrx.js} +2 -2
  43. package/{index-a64esmtb.js → index-vrwdx0zx.js} +1 -1
  44. package/{index-kn1h7p1x.js → index-yc1keaer.js} +4 -226
  45. package/{index-j9yhg404.js → index-ys7dvdb3.js} +1 -1
  46. package/index.js +20 -19
  47. package/{library.command-nbsky672.js → library.command-1f9h2ex6.js} +3 -3
  48. package/{localRegistry.command-yeq57wjr.js → localRegistry.command-rx758ajg.js} +9 -8
  49. package/{module.command-29vqzrh8.js → module.command-c2eve036.js} +7 -6
  50. package/{package.command-axv0abmn.js → package.command-y2rh4np7.js} +3 -3
  51. package/package.json +2 -2
  52. package/{page.command-vs9s3zrh.js → page.command-e5h29fyt.js} +3 -3
  53. package/{primitive.command-cbxmqbtc.js → primitive.command-c44f7z1s.js} +8 -7
  54. package/{quality.command-gmbs7nws.js → quality.command-5evdd263.js} +2 -2
  55. package/{repair.command-bqsjptsj.js → repair.command-c2amvt74.js} +5 -5
  56. package/{scalar.command-6k1vhe9s.js → scalar.command-xyzerygj.js} +6 -5
  57. package/{subspace.command-fwjfcts7.js → subspace.command-ebfwzypw.js} +92 -12
  58. package/tunnel.command-v6a7at16.js +130 -0
  59. package/{workflow.command-nwpcdc8p.js → workflow.command-t174m6sy.js} +11 -10
  60. package/{workspace.command-8s050m0h.js → workspace.command-bg3eveth.js} +23 -22
@@ -0,0 +1,49 @@
1
+ // @bun
2
+ import {
3
+ GlobalConfig,
4
+ CloudApi
5
+ } from "./index-bw2marpf.js";
6
+
7
+ // pkgs/@akanjs/cli/tunnel/TunnelShare.ts
8
+ import { TunnelAgent } from "akanjs/server/tunnel";
9
+
10
+ class TunnelShare2 {
11
+ #api;
12
+ #agent;
13
+ grant;
14
+ #closed = false;
15
+ constructor(api, agent, grant) {
16
+ this.#api = api;
17
+ this.#agent = agent;
18
+ this.grant = grant;
19
+ }
20
+ static async open(app, { workspace, host, port, ttlMinutes, onLost }) {
21
+ const api = await CloudApi.fromHost(workspace, host ?? GlobalConfig.akanCloudHost);
22
+ const grant = await api.requestTunnel({ name: app.name, ...ttlMinutes ? { ttlMinutes } : {} });
23
+ const origin = `http://localhost:${port ?? await app.getDevPort()}`;
24
+ const agent = new TunnelAgent({
25
+ gatewayUrl: grant.gatewayUrl,
26
+ token: grant.token,
27
+ hostnames: [grant.hostname],
28
+ origin,
29
+ name: app.name,
30
+ ...onLost ? { onLost } : {}
31
+ });
32
+ await agent.start();
33
+ return new TunnelShare2(api, agent, grant);
34
+ }
35
+ get url() {
36
+ return this.grant.url;
37
+ }
38
+ async close() {
39
+ if (this.#closed)
40
+ return;
41
+ this.#closed = true;
42
+ await this.#agent.stop("cli exited");
43
+ try {
44
+ await this.#api.revokeTunnel(this.grant.code);
45
+ } catch {}
46
+ }
47
+ }
48
+
49
+ export { TunnelShare2 };
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  AppExecutor,
4
4
  LibExecutor
5
- } from "./index-2tv3fdx4.js";
5
+ } from "./index-5nyznra1.js";
6
6
 
7
7
  // pkgs/@akanjs/devkit/workflow/utils.ts
8
8
  var jsonText = (value, { trailingNewline = true } = {}) => `${JSON.stringify(value, null, 2)}${trailingNewline ? `
@@ -1,12 +1,12 @@
1
1
  // @bun
2
2
  import {
3
3
  script
4
- } from "./index-mak3cd28.js";
4
+ } from "./index-b3ae16mg.js";
5
5
  import {
6
6
  AppExecutor,
7
7
  LibExecutor,
8
8
  ModuleExecutor
9
- } from "./index-2tv3fdx4.js";
9
+ } from "./index-5nyznra1.js";
10
10
  import {
11
11
  compactDiagnostics,
12
12
  createPrimitiveWriteReport,
@@ -39,10 +39,10 @@ import {
39
39
  hasSignalFactoryEntry,
40
40
  insertSignalFactoryEntry,
41
41
  addFieldUiPolicyForType
42
- } from "./index-gyd220p2.js";
42
+ } from "./index-jwjaf9fy.js";
43
43
  import {
44
44
  ModuleScript
45
- } from "./index-8pm30m73.js";
45
+ } from "./index-fr2x3qvv.js";
46
46
 
47
47
  // pkgs/@akanjs/cli/primitive/primitive.script.ts
48
48
  import { capitalize } from "akanjs/common";
@@ -0,0 +1,25 @@
1
+ // @bun
2
+ // pkgs/@akanjs/cli/clipboard.ts
3
+ var clipboardCommands = () => {
4
+ if (process.platform === "darwin")
5
+ return [["pbcopy"]];
6
+ if (process.platform === "win32")
7
+ return [["clip"]];
8
+ return [["wl-copy"], ["xclip", "-selection", "clipboard"], ["xsel", "--clipboard", "--input"]];
9
+ };
10
+ var writeClipboard = async (text) => {
11
+ for (const command of clipboardCommands()) {
12
+ try {
13
+ const proc = Bun.spawn(command, {
14
+ stdin: new TextEncoder().encode(text),
15
+ stdout: "ignore",
16
+ stderr: "ignore"
17
+ });
18
+ if (await proc.exited === 0)
19
+ return true;
20
+ } catch {}
21
+ }
22
+ return false;
23
+ };
24
+
25
+ export { writeClipboard };
@@ -2,16 +2,16 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-mak3cd28.js";
5
+ } from "./index-b3ae16mg.js";
6
6
  import {
7
7
  WorkspaceExecutor,
8
8
  AppExecutor,
9
9
  LibExecutor,
10
10
  PkgExecutor
11
- } from "./index-2tv3fdx4.js";
11
+ } from "./index-5nyznra1.js";
12
12
  import {
13
13
  LibraryScript
14
- } from "./index-259dsnz3.js";
14
+ } from "./index-1nwxbr2y.js";
15
15
  import {
16
16
  HmrWatcher,
17
17
  WatchRootResolver
@@ -19,7 +19,7 @@ import {
19
19
  import {
20
20
  SlicePlanner,
21
21
  formatSlicePlan
22
- } from "./index-j9yhg404.js";
22
+ } from "./index-ys7dvdb3.js";
23
23
  import {
24
24
  resolveMobileTargets
25
25
  } from "./index-47pj3aee.js";
@@ -2049,10 +2049,10 @@ ${uniqueCandidates.map((candidate) => ` - ${candidate}`).join(`
2049
2049
  // pkgs/@akanjs/cli/application/application.runner.ts
2050
2050
  import { Logger as Logger4 } from "akanjs/common";
2051
2051
  import ora from "ora";
2052
- var loadBuildRunner = async () => (await import("./applicationBuildRunner-kxwbssgn.js")).ApplicationBuildRunner;
2053
- var loadReleasePackager = async () => (await import("./applicationReleasePackager-4yasxwv9.js")).ApplicationReleasePackager;
2054
- var loadCapacitorApp = async () => (await import("./capacitorApp-36rbr858.js")).CapacitorApp;
2055
- var loadAbstractCompactor = async () => (await import("./abstractCompactor-mjh5ppsq.js")).AbstractCompactor;
2052
+ var loadBuildRunner = async () => (await import("./applicationBuildRunner-4f1wrba0.js")).ApplicationBuildRunner;
2053
+ var loadReleasePackager = async () => (await import("./applicationReleasePackager-jkjmy5ee.js")).ApplicationReleasePackager;
2054
+ var loadCapacitorApp = async () => (await import("./capacitorApp-hqvsrec4.js")).CapacitorApp;
2055
+ var loadAbstractCompactor = async () => (await import("./abstractCompactor-bqh31fk5.js")).AbstractCompactor;
2056
2056
  var loadPrompts = async () => await import("@inquirer/prompts");
2057
2057
 
2058
2058
  class ApplicationRunner extends runner("application") {
@@ -3230,7 +3230,15 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
3230
3230
  }
3231
3231
  await this.applicationRunner.test(exec);
3232
3232
  }
3233
- async start(apps, { open = false, dbup = true, write = true, plain = false, kill = false, concurrency = null } = {}) {
3233
+ async start(apps, {
3234
+ open = false,
3235
+ dbup = true,
3236
+ write = true,
3237
+ plain = false,
3238
+ kill = false,
3239
+ share = false,
3240
+ concurrency = null
3241
+ } = {}) {
3234
3242
  const first = apps[0];
3235
3243
  if (!first)
3236
3244
  throw new Error("No app selected to start");
@@ -3239,6 +3247,8 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
3239
3247
  first.workspace.log("no sized terminal to draw on; printing prefixed lines instead");
3240
3248
  if (kill)
3241
3249
  await this.reclaimDevPorts(apps);
3250
+ if (share)
3251
+ await this.#shareOnInterrupt(apps);
3242
3252
  if (mode === "stream" && apps.length === 1)
3243
3253
  return await this.startOne(first, { open, dbup, write, ...DevSupervisor.childHooks() });
3244
3254
  await this.#startMany(apps, { open, dbup, write, mode, concurrency });
@@ -3277,13 +3287,19 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
3277
3287
  if (killed.length === 0 && foreign.length === 0)
3278
3288
  workspace.log("dev ports are free; nothing to kill");
3279
3289
  }
3280
- async#startMany(apps, { open, dbup, write, mode, concurrency }) {
3290
+ async#startMany(apps, {
3291
+ open,
3292
+ dbup,
3293
+ write,
3294
+ mode,
3295
+ concurrency
3296
+ }) {
3281
3297
  const workspace = apps[0]?.workspace;
3282
3298
  if (!workspace)
3283
3299
  throw new Error("No app selected to start");
3284
3300
  const startedDatabase = dbup ? await this.#prepareSharedDatabase(apps) : false;
3285
3301
  const supervisor = new DevSupervisor({ apps, mode, concurrency, open, write });
3286
- const view = mode === "tui" ? await (await import("./devTuiView-c08ccbat.js")).createDevTuiView(supervisor) : new DevStreamView(apps.map((app) => app.name));
3302
+ const view = mode === "tui" ? await (await import("./devTuiView-40jvjnyz.js")).createDevTuiView(supervisor) : new DevStreamView(apps.map((app) => app.name));
3287
3303
  await supervisor.run(view);
3288
3304
  if (startedDatabase)
3289
3305
  await this.#stopDatabase(workspace);
@@ -3401,6 +3417,25 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
3401
3417
  }
3402
3418
  spinner.succeed("Local database (/local/docker-compose.yaml) is down");
3403
3419
  }
3420
+ #shareOnInterrupt(apps) {
3421
+ const shares = [];
3422
+ const open = Promise.all(apps.map(async (app) => {
3423
+ const { TunnelShare } = await import("./TunnelShare-sbsaggmb.js");
3424
+ const share = await TunnelShare.open(app, { workspace: app.workspace });
3425
+ shares.push(share);
3426
+ Logger6.rawLog(`${app.name} is shared at ${share.url}`);
3427
+ })).catch((error) => {
3428
+ Logger6.rawLog(`Could not open the tunnel: ${error instanceof Error ? error.message : String(error)}`, undefined, "error");
3429
+ });
3430
+ let closing = false;
3431
+ process.on("SIGINT", () => {
3432
+ if (closing)
3433
+ return;
3434
+ closing = true;
3435
+ Promise.all(shares.map(async (share) => await share.close()));
3436
+ });
3437
+ return open;
3438
+ }
3404
3439
  #stopDatabaseOnInterrupt(workspace) {
3405
3440
  let stopping = false;
3406
3441
  process.on("SIGINT", () => {
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-mak3cd28.js";
5
+ } from "./index-b3ae16mg.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-2tv3fdx4.js";
16
+ } from "./index-5nyznra1.js";
17
17
  import {
18
18
  collectRecipeSources2,
19
19
  scanRecipes2
20
20
  } from "./index-by5gpp8x.js";
21
21
  import {
22
22
  AkanContextAnalyzer
23
- } from "./index-ktb5njgy.js";
23
+ } from "./index-15r9a10e.js";
24
24
  import {
25
25
  Prompter
26
26
  } from "./index-h7yw2z9n.js";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-mak3cd28.js";
5
+ } from "./index-b3ae16mg.js";
6
6
 
7
7
  // pkgs/@akanjs/cli/page/page.runner.ts
8
8
  class PageRunner extends runner("page") {
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-mak3cd28.js";
5
+ } from "./index-b3ae16mg.js";
6
6
  import {
7
7
  FileSys
8
8
  } from "./index-q0y2jq9j.js";
9
9
  import {
10
10
  PkgExecutor
11
- } from "./index-2tv3fdx4.js";
11
+ } from "./index-5nyznra1.js";
12
12
  import {
13
13
  TypeScriptDependencyScanner2
14
14
  } from "./index-kcxmv48c.js";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  AsyncDefaultExportDetector,
4
4
  resolveSsrPageEntriesForApp
5
- } from "./index-2tv3fdx4.js";
5
+ } from "./index-5nyznra1.js";
6
6
  import {
7
7
  BarrelAnalyzer,
8
8
  createBarrelImportsPlugin,
@@ -1,233 +1,11 @@
1
1
  // @bun
2
2
  import {
3
- FileSys
4
- } from "./index-q0y2jq9j.js";
3
+ GlobalConfig
4
+ } from "./index-bw2marpf.js";
5
5
  import {
6
6
  Spinner
7
- } from "./index-2tv3fdx4.js";
7
+ } from "./index-5nyznra1.js";
8
8
 
9
- // pkgs/@akanjs/devkit/cloud/globalConfig.ts
10
- import { chmod, mkdir } from "fs/promises";
11
- import dayjs from "dayjs";
12
-
13
- // pkgs/@akanjs/devkit/cloud/constants.ts
14
- var basePath = `${Bun.env.HOME ?? Bun.env.USERPROFILE}/.akan`;
15
- var configPath = `${basePath}/config.json`;
16
- var getDefaultHostConfig = (host = GlobalConfig.akanCloudHost) => ({ host });
17
- var defaultAkanGlobalConfig = {
18
- cloudHost: {},
19
- remoteEnvServers: {},
20
- llm: null
21
- };
22
-
23
- // pkgs/@akanjs/devkit/cloud/globalConfig.ts
24
- class GlobalConfig {
25
- static akanCloudHost = process.env.USE_AKANJS_PKGS === "true" ? `http://localhost:${process.env.CLOUD_HOST_PORT ?? 8283}` : "https://cloud.akanjs.com";
26
- static async#getAkanGlobalConfig() {
27
- const exists = await FileSys.fileExists(configPath);
28
- const akanConfig = exists ? await FileSys.readJson(configPath) : {};
29
- return {
30
- ...defaultAkanGlobalConfig,
31
- ...akanConfig,
32
- cloudHost: akanConfig.cloudHost ?? defaultAkanGlobalConfig.cloudHost,
33
- remoteEnvServers: akanConfig.remoteEnvServers ?? defaultAkanGlobalConfig.remoteEnvServers
34
- };
35
- }
36
- static async#setAkanGlobalConfig(akanConfig) {
37
- await mkdir(basePath, { recursive: true, mode: 448 });
38
- await Bun.write(configPath, JSON.stringify(akanConfig, null, 2));
39
- await chmod(configPath, 384);
40
- }
41
- static async getHostConfig(host = GlobalConfig.akanCloudHost) {
42
- const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
43
- return GlobalConfig.toHostConfig(akanConfig.cloudHost[host] ?? getDefaultHostConfig(host));
44
- }
45
- static async setHostConfig(config = getDefaultHostConfig()) {
46
- const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
47
- akanConfig.cloudHost[config.host] = GlobalConfig.toHostConfigDto(config);
48
- await GlobalConfig.#setAkanGlobalConfig(akanConfig);
49
- }
50
- static async getLlmConfig() {
51
- const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
52
- return akanConfig.llm ?? null;
53
- }
54
- static async setLlmConfig(llmConfig) {
55
- const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
56
- await GlobalConfig.#setAkanGlobalConfig({ ...akanConfig, llm: llmConfig });
57
- }
58
- static async getRemoteEnvServers() {
59
- const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
60
- return akanConfig.remoteEnvServers;
61
- }
62
- static async setRemoteEnvServer(name, config) {
63
- const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
64
- await GlobalConfig.#setAkanGlobalConfig({
65
- ...akanConfig,
66
- remoteEnvServers: {
67
- ...akanConfig.remoteEnvServers,
68
- [name]: config
69
- }
70
- });
71
- }
72
- static async removeRemoteEnvServer(name) {
73
- const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
74
- const { [name]: _, ...remoteEnvServers } = akanConfig.remoteEnvServers;
75
- await GlobalConfig.#setAkanGlobalConfig({
76
- ...akanConfig,
77
- remoteEnvServers
78
- });
79
- }
80
- static needRefreshToken(accessToken) {
81
- return !!accessToken?.expiresAt?.isBefore(dayjs().add(1, "hour"));
82
- }
83
- static toAccessToken(accessToken) {
84
- return {
85
- jwt: accessToken.jwt,
86
- refreshToken: accessToken.refreshToken ?? null,
87
- expiresAt: accessToken.expiresAt ? dayjs(accessToken.expiresAt) : null
88
- };
89
- }
90
- static toAccessTokenDto(accessToken) {
91
- return {
92
- jwt: accessToken.jwt,
93
- refreshToken: accessToken.refreshToken ?? null,
94
- expiresAt: accessToken.expiresAt?.toString() ?? null
95
- };
96
- }
97
- static toHostConfigDto(hostConfig) {
98
- return {
99
- host: hostConfig.host,
100
- auth: {
101
- accessToken: hostConfig.auth?.accessToken ? GlobalConfig.toAccessTokenDto(hostConfig.auth.accessToken) : undefined,
102
- self: hostConfig.auth?.self
103
- }
104
- };
105
- }
106
- static toHostConfig(hostConfigDto) {
107
- return {
108
- host: hostConfigDto.host,
109
- auth: {
110
- accessToken: hostConfigDto.auth?.accessToken ? GlobalConfig.toAccessToken(hostConfigDto.auth.accessToken) : undefined,
111
- self: hostConfigDto.auth?.self
112
- }
113
- };
114
- }
115
- }
116
-
117
- // pkgs/@akanjs/devkit/cloud/cloudApi.ts
118
- class HttpClient {
119
- baseUrl;
120
- headers = {};
121
- constructor(baseUrl, headers = {}) {
122
- this.baseUrl = baseUrl;
123
- this.headers = headers;
124
- }
125
- async get(url, { headers } = {}) {
126
- const response = await fetch(`${this.baseUrl}${url}`, {
127
- headers: {
128
- "Content-Type": "application/json",
129
- ...this.headers,
130
- ...headers
131
- }
132
- });
133
- return await response.json();
134
- }
135
- async getFile(url, localPath, headers) {
136
- const response = await fetch(`${this.baseUrl}${url}`, {
137
- headers: { ...this.headers, ...headers }
138
- });
139
- if (!response.ok)
140
- throw new Error(`Failed to download file: ${response.status} ${response.statusText}`);
141
- await Bun.write(localPath, response);
142
- }
143
- async post(url, data, { headers } = {}) {
144
- const isFormData = data instanceof FormData;
145
- const response = await fetch(`${this.baseUrl}${url}`, {
146
- method: "POST",
147
- body: isFormData ? data : JSON.stringify(data),
148
- headers: isFormData ? { ...this.headers, ...headers } : { "Content-Type": "application/json", ...this.headers, ...headers }
149
- });
150
- return await response.json();
151
- }
152
- setHeaders(headers) {
153
- Object.assign(this.headers, headers);
154
- return this;
155
- }
156
- }
157
-
158
- class CloudApi {
159
- #api;
160
- #accessToken = null;
161
- #workspace;
162
- host;
163
- url;
164
- static async fromHost(workspace, host) {
165
- const hostConfig = await GlobalConfig.getHostConfig(host);
166
- return new CloudApi(workspace, hostConfig);
167
- }
168
- constructor(workspace, hostConfig) {
169
- this.#workspace = workspace;
170
- this.#accessToken = hostConfig.auth?.accessToken ?? null;
171
- this.host = hostConfig.host;
172
- this.url = `${this.host}/api`;
173
- this.#api = new HttpClient(this.url);
174
- if (this.#accessToken && !GlobalConfig.needRefreshToken(this.#accessToken))
175
- this.#api.setHeaders({
176
- Authorization: `Bearer ${this.#accessToken.jwt}`
177
- });
178
- }
179
- async uploadEnv(devProjectId, file) {
180
- const formData = new FormData;
181
- formData.append("devProjectId", devProjectId);
182
- formData.append("file", file);
183
- const data = await this.#api.post(`/uploadEnv/${devProjectId}`, formData);
184
- return data;
185
- }
186
- async downloadEnv(devProjectId) {
187
- const localPath = `${this.#workspace.workspaceRoot}/local/env.tar`;
188
- await this.#api.getFile(`/downloadEnv/${devProjectId}`, localPath);
189
- return localPath;
190
- }
191
- async getRemoteAuthToken(remoteId) {
192
- try {
193
- const accessToken = await this.#api.get(`/getRemoteAuthToken/${remoteId}`);
194
- this.#accessToken = GlobalConfig.toAccessToken(accessToken);
195
- this.#api.setHeaders({
196
- Authorization: `Bearer ${this.#accessToken.jwt}`
197
- });
198
- return this.#accessToken;
199
- } catch (_) {
200
- return null;
201
- }
202
- }
203
- async#ensureAccessTokenLive({
204
- allowUnauthorized = false
205
- } = {}) {
206
- if (!this.#accessToken)
207
- throw new Error("No access token");
208
- const needRefresh = GlobalConfig.needRefreshToken(this.#accessToken);
209
- if (!needRefresh)
210
- return this.#accessToken;
211
- const refreshToken = this.#accessToken?.refreshToken;
212
- if (!refreshToken)
213
- throw new Error("No refresh token");
214
- return await this.refreshAuthToken(refreshToken);
215
- }
216
- async refreshAuthToken(refreshToken) {
217
- const response = await this.#api.post(`/refreshAuthToken`, { refreshToken });
218
- this.#accessToken = GlobalConfig.toAccessToken(response);
219
- this.#api.setHeaders({ Authorization: `Bearer ${this.#accessToken.jwt}` });
220
- return this.#accessToken;
221
- }
222
- async getRemoteSelf() {
223
- try {
224
- const data = await this.#api.get(`/getRemoteSelf`);
225
- return data;
226
- } catch {
227
- return null;
228
- }
229
- }
230
- }
231
9
  // pkgs/@akanjs/devkit/aiEditor.ts
232
10
  import { input, select } from "@inquirer/prompts";
233
11
  import {
@@ -557,4 +335,4 @@ ${fileCheck.lintResult.message}`);
557
335
  }
558
336
  }
559
337
 
560
- export { getDefaultHostConfig, GlobalConfig, CloudApi, AiSession };
338
+ export { AiSession };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  AppInfo
4
- } from "./index-2tv3fdx4.js";
4
+ } from "./index-5nyznra1.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/slicePlanner.ts
7
7
  class SlicePlanner {
package/index.js CHANGED
@@ -4,9 +4,9 @@ import {
4
4
  getTargetMetas,
5
5
  getTargetCommandNames,
6
6
  runCommands
7
- } from "./index-mak3cd28.js";
7
+ } from "./index-b3ae16mg.js";
8
8
  import"./index-q0y2jq9j.js";
9
- import"./index-2tv3fdx4.js";
9
+ import"./index-5nyznra1.js";
10
10
  import"./index-6wwzs1bc.js";
11
11
 
12
12
  // pkgs/@akanjs/cli/commandManifest.ts
@@ -14,23 +14,24 @@ import path from "path";
14
14
 
15
15
  // pkgs/@akanjs/cli/commandModules.ts
16
16
  var commandModules = {
17
- workspace: async () => (await import("./workspace.command-8s050m0h.js")).WorkspaceCommand,
18
- agent: async () => (await import("./agent.command-d2gfxfck.js")).AgentCommand,
19
- application: async () => (await import("./application.command-pj2m7584.js")).ApplicationCommand,
20
- library: async () => (await import("./library.command-nbsky672.js")).LibraryCommand,
21
- localRegistry: async () => (await import("./localRegistry.command-yeq57wjr.js")).LocalRegistryCommand,
22
- package: async () => (await import("./package.command-axv0abmn.js")).PackageCommand,
23
- module: async () => (await import("./module.command-29vqzrh8.js")).ModuleCommand,
24
- page: async () => (await import("./page.command-vs9s3zrh.js")).PageCommand,
25
- context: async () => (await import("./context.command-ez8a0zyz.js")).ContextCommand,
26
- cloud: async () => (await import("./cloud.command-jshwdq22.js")).CloudCommand,
27
- subspace: async () => (await import("./subspace.command-fwjfcts7.js")).SubspaceCommand,
28
- guideline: async () => (await import("./guideline.command-xmqwx8zm.js")).GuidelineCommand,
29
- scalar: async () => (await import("./scalar.command-6k1vhe9s.js")).ScalarCommand,
30
- primitive: async () => (await import("./primitive.command-cbxmqbtc.js")).PrimitiveCommand,
31
- quality: async () => (await import("./quality.command-gmbs7nws.js")).QualityCommand,
32
- repair: async () => (await import("./repair.command-bqsjptsj.js")).RepairCommand,
33
- workflow: async () => (await import("./workflow.command-nwpcdc8p.js")).WorkflowCommand
17
+ workspace: async () => (await import("./workspace.command-bg3eveth.js")).WorkspaceCommand,
18
+ agent: async () => (await import("./agent.command-7357vxd8.js")).AgentCommand,
19
+ application: async () => (await import("./application.command-pc8mdn3w.js")).ApplicationCommand,
20
+ library: async () => (await import("./library.command-1f9h2ex6.js")).LibraryCommand,
21
+ localRegistry: async () => (await import("./localRegistry.command-rx758ajg.js")).LocalRegistryCommand,
22
+ package: async () => (await import("./package.command-y2rh4np7.js")).PackageCommand,
23
+ module: async () => (await import("./module.command-c2eve036.js")).ModuleCommand,
24
+ page: async () => (await import("./page.command-e5h29fyt.js")).PageCommand,
25
+ context: async () => (await import("./context.command-982b6kdp.js")).ContextCommand,
26
+ cloud: async () => (await import("./cloud.command-cawrd5nq.js")).CloudCommand,
27
+ subspace: async () => (await import("./subspace.command-ebfwzypw.js")).SubspaceCommand,
28
+ guideline: async () => (await import("./guideline.command-jn0vwszx.js")).GuidelineCommand,
29
+ scalar: async () => (await import("./scalar.command-xyzerygj.js")).ScalarCommand,
30
+ primitive: async () => (await import("./primitive.command-c44f7z1s.js")).PrimitiveCommand,
31
+ quality: async () => (await import("./quality.command-5evdd263.js")).QualityCommand,
32
+ repair: async () => (await import("./repair.command-c2amvt74.js")).RepairCommand,
33
+ workflow: async () => (await import("./workflow.command-t174m6sy.js")).WorkflowCommand,
34
+ tunnel: async () => (await import("./tunnel.command-v6a7at16.js")).TunnelCommand
34
35
  };
35
36
  var commandModuleIds = Object.keys(commandModules);
36
37
 
@@ -3,13 +3,13 @@ import {
3
3
  Lib,
4
4
  Workspace,
5
5
  command
6
- } from "./index-mak3cd28.js";
6
+ } from "./index-b3ae16mg.js";
7
7
  import"./index-q0y2jq9j.js";
8
- import"./index-2tv3fdx4.js";
8
+ import"./index-5nyznra1.js";
9
9
  import"./index-6wwzs1bc.js";
10
10
  import {
11
11
  LibraryScript
12
- } from "./index-259dsnz3.js";
12
+ } from "./index-1nwxbr2y.js";
13
13
 
14
14
  // pkgs/@akanjs/cli/library/library.command.ts
15
15
  class LibraryCommand extends command("library", [LibraryScript], ({ public: target }) => ({
@@ -4,27 +4,28 @@ import {
4
4
  runner,
5
5
  script,
6
6
  command
7
- } from "./index-mak3cd28.js";
7
+ } from "./index-b3ae16mg.js";
8
8
  import"./index-q0y2jq9j.js";
9
9
  import {
10
10
  PkgExecutor
11
- } from "./index-2tv3fdx4.js";
11
+ } from "./index-5nyznra1.js";
12
12
  import"./index-6wwzs1bc.js";
13
13
  import {
14
14
  ApplicationScript
15
- } from "./index-v0qh106m.js";
16
- import"./index-259dsnz3.js";
15
+ } from "./index-r8bd61d9.js";
16
+ import"./index-1nwxbr2y.js";
17
17
  import"./index-hwkygn9s.js";
18
- import"./index-kn1h7p1x.js";
18
+ import"./index-bw2marpf.js";
19
+ import"./index-yc1keaer.js";
19
20
  import {
20
21
  getNpmRegistryUrl,
21
22
  CloudRunner
22
- } from "./index-2hq52jq3.js";
23
+ } from "./index-8tfmh0v6.js";
23
24
  import"./index-kcxmv48c.js";
24
25
  import {
25
26
  PackageScript
26
- } from "./index-ws5e0j51.js";
27
- import"./index-j9yhg404.js";
27
+ } from "./index-t8gvwcrx.js";
28
+ import"./index-ys7dvdb3.js";
28
29
 
29
30
  // pkgs/@akanjs/cli/localRegistry/localRegistry.runner.ts
30
31
  import { mkdir, rm } from "fs/promises";