@akanjs/cli 3.0.0-beta.3 → 3.0.0-beta.30

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 (194) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-xnfyyz8h.js +9 -0
  3. package/CodeAgentRpcHost-p7h6n2hp.js +7 -0
  4. package/CodeAgentRpcListener-7p7z5dd7.js +97 -0
  5. package/CodeTui-h66xb1fh.js +1457 -0
  6. package/README.md +3 -0
  7. package/TunnelShare-cwh9ezsm.js +9 -0
  8. package/{agent.command-d2gfxfck.js → agent.command-c4v7kjff.js} +8 -9
  9. package/akanCode.js +102 -0
  10. package/application.command-yzsswrz6.js +241 -0
  11. package/{applicationBuildRunner-kxwbssgn.js → applicationBuildRunner-qkt6spd5.js} +121 -77
  12. package/buildBatch.proc.js +120 -32
  13. package/cloud.command-v8h688jc.js +95 -0
  14. package/cloud.script-yct1sk4k.js +20 -0
  15. package/code.command-jff3tw7y.js +154 -0
  16. package/commandManifest.json +1 -1
  17. package/consoleToStderr-h5bryj94.js +7 -0
  18. package/context.command-y5sevk3c.js +48 -0
  19. package/context.runner-90hsmacr.js +21 -0
  20. package/{dependencyScanner-shs82ynp.js → dependencyScanner-06z2dmrr.js} +2 -2
  21. package/{devTui-40ggmd99.js → devTui-q7k7bakd.js} +122 -40
  22. package/fileSys-wzzrntkw.js +9 -0
  23. package/guideline.command-11cndccb.js +42 -0
  24. package/guidelines/agentRule/agentRule.instruction.md +209 -33
  25. package/guidelines/conventions/conventions.instruction.md +143 -41
  26. package/guidelines/fieldRule/fieldRule.instruction.md +1 -0
  27. package/guidelines/mcpRule/mcpRule.instruction.md +7 -5
  28. package/guidelines/queryRule/queryRule.instruction.md +21 -7
  29. package/guidelines/runtimeRule/runtimeRule.instruction.md +268 -6
  30. package/guidelines/ssrRule/ssrRule.instruction.md +4 -2
  31. package/guidelines/transportRule/transportRule.instruction.md +51 -0
  32. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +20 -0
  33. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +66 -3
  34. package/incrementalBuilder.proc.js +564 -109
  35. package/{index-fz5q3gd7.js → index-0ncc0mbk.js} +10 -17
  36. package/index-167c77aq.js +69 -0
  37. package/{index-kcxmv48c.js → index-2ahj896a.js} +45 -79
  38. package/index-2wc41k5w.js +49 -0
  39. package/{index-j9yhg404.js → index-35mmm9ca.js} +4 -7
  40. package/{index-a64esmtb.js → index-376gpdds.js} +523 -1022
  41. package/index-3hx1z96c.js +87 -0
  42. package/{index-v0qh106m.js → index-3rh7thcx.js} +961 -892
  43. package/{index-hwkygn9s.js → index-48k96p55.js} +325 -36
  44. package/{index-q0y2jq9j.js → index-52w0fvh8.js} +21 -4
  45. package/index-5rp0h6na.js +1119 -0
  46. package/index-6x9p8dpb.js +4300 -0
  47. package/index-7md2g9vw.js +6 -0
  48. package/index-8tv7356t.js +700 -0
  49. package/index-94s080qm.js +266 -0
  50. package/index-9dp031by.js +12 -0
  51. package/{index-ws5e0j51.js → index-a4s954kq.js} +43 -26
  52. package/{index-3d9y066c.js → index-bjwxs904.js} +9 -8
  53. package/{index-ne2qy0nk.js → index-bxmejydw.js} +12 -12
  54. package/index-c6eggbee.js +123 -0
  55. package/index-d2242ksy.js +99 -0
  56. package/{index-92zztqy1.js → index-dy0jx9ay.js} +2 -17
  57. package/{index-259dsnz3.js → index-gxamdf18.js} +5 -8
  58. package/{index-4edzf1gr.js → index-hf6f4xnb.js} +77 -150
  59. package/{index-by5gpp8x.js → index-hj6w4ka1.js} +2 -1
  60. package/{index-gyd220p2.js → index-hmdq5pqm.js} +554 -577
  61. package/{index-600zhnve.js → index-hqd0h1pb.js} +75 -203
  62. package/index-kb16nzyt.js +997 -0
  63. package/index-mk3b9rk1.js +2729 -0
  64. package/{index-2tv3fdx4.js → index-n3jk2501.js} +1205 -1458
  65. package/index-p6pbz9n5.js +25 -0
  66. package/{index-zry5nz81.js → index-qcejqgts.js} +51 -30
  67. package/{index-7737gxcp.js → index-rtwhw4aq.js} +107 -241
  68. package/{index-pnqbkf5p.js → index-se643zvp.js} +6 -2
  69. package/index-tsb0f8ya.js +53 -0
  70. package/{index-ktb5njgy.js → index-tzc1gtrg.js} +49 -99
  71. package/index-wa5jbxj1.js +760 -0
  72. package/index-wfwgcnyc.js +187 -0
  73. package/{index-mak3cd28.js → index-xb7qhxa8.js} +137 -255
  74. package/{index-h7yw2z9n.js → index-zzvvc845.js} +8 -14
  75. package/index.js +23 -22
  76. package/{library.command-nbsky672.js → library.command-n9kp7yms.js} +4 -5
  77. package/{localRegistry.command-yeq57wjr.js → localRegistry.command-jx6kxt2x.js} +23 -42
  78. package/{module.command-29vqzrh8.js → module.command-q2xjf6cx.js} +8 -11
  79. package/{package.command-axv0abmn.js → package.command-q5a3nsw5.js} +6 -7
  80. package/package.json +15 -7
  81. package/{page.command-vs9s3zrh.js → page.command-ppenrxjn.js} +4 -5
  82. package/{primitive.command-cbxmqbtc.js → primitive.command-dvgg8nem.js} +9 -22
  83. package/prompter-76k56b37.js +8 -0
  84. package/{quality.command-gmbs7nws.js → quality.command-pz7kg3pc.js} +205 -377
  85. package/{recipeScanner-fpagtgc1.js → recipeScanner-4b69ybe0.js} +1 -1
  86. package/{repair.command-bqsjptsj.js → repair.command-a6py9xvz.js} +11 -35
  87. package/{routeSourceValidator-apyqw7wk.js → routeSourceValidator-7ycnfz0e.js} +0 -6
  88. package/{scalar.command-6k1vhe9s.js → scalar.command-7f3xfpen.js} +7 -10
  89. package/skills/akan-code/SKILL.md +130 -0
  90. package/skills/akan-debug/SKILL.md +42 -0
  91. package/skills/akan-deps/SKILL.md +50 -0
  92. package/skills/akan-err/SKILL.md +39 -0
  93. package/skills/akan-module/SKILL.md +45 -0
  94. package/skills/akan-scaffold/SKILL.md +76 -0
  95. package/skills/akan-scalar/SKILL.md +52 -0
  96. package/skills/akan-service/SKILL.md +34 -0
  97. package/skills/akan-store/SKILL.md +67 -0
  98. package/skills/akan-ui/SKILL.md +63 -0
  99. package/skills/akan-validate/SKILL.md +44 -0
  100. package/{subspace.command-fwjfcts7.js → subspace.command-z7nqs508.js} +138 -67
  101. package/templates/__scalar/__model__/__model__.abstract.md.template +8 -0
  102. package/templates/appSample/lib/__scalar/workHistory/workHistory.abstract.ts +8 -39
  103. package/templates/appSample/lib/_noti/noti.abstract.ts +6 -29
  104. package/templates/appSample/lib/task/task.abstract.ts +12 -32
  105. package/templates/appSample/lib/task/task.signal.spec.ts +15 -18
  106. package/templates/appSample/lib/task/task.signal.test.ts +15 -1
  107. package/templates/appSample/lib/task/task.signal.ts +1 -1
  108. package/templates/appSample/srvkit/{AuthGuard.ts → guards.ts} +7 -4
  109. package/templates/appSample/srvkit/{SessionInternalArg.ts → internalArgs.ts} +6 -4
  110. package/templates/client.ts +7 -30
  111. package/templates/crudPages/[__model__Id]/edit/page.tsx +2 -1
  112. package/templates/crudPages/[__model__Id]/page.tsx +2 -1
  113. package/templates/crudPages/new/page.tsx +2 -1
  114. package/templates/crudPages/page.tsx +2 -1
  115. package/templates/crudSinglePage/page.tsx +2 -1
  116. package/templates/lib/__lib/lib.dictionary.ts +0 -2
  117. package/templates/lib/__lib/lib.document.ts +0 -2
  118. package/templates/lib/sig.ts +8 -30
  119. package/templates/localDev/docker-compose.yaml.template +3 -14
  120. package/templates/module/__model__.signal.ts +12 -4
  121. package/templates/pkgRoot/tsconfig.json.template +2 -7
  122. package/templates/server.ts +1 -3
  123. package/templates/service/__model__.abstract.md.template +8 -0
  124. package/templates/workspaceRoot/.gitignore.template +0 -1
  125. package/templates/workspaceRoot/package.json.template +1 -3
  126. package/tunnel.command-zy4wbcgt.js +129 -0
  127. package/{typeChecker-3xgrzc2v.js → typeChecker-px49mezc.js} +1 -1
  128. package/typecheck.proc.js +1 -1
  129. package/workflow.command-f142t17s.js +79 -0
  130. package/{workspace.command-8s050m0h.js → workspace.command-gpk1149x.js} +77 -109
  131. package/abstractCompactor-mjh5ppsq.js +0 -101
  132. package/application.command-pj2m7584.js +0 -204
  133. package/applicationReleasePackager-4yasxwv9.js +0 -244
  134. package/capacitorApp-36rbr858.js +0 -12
  135. package/cloud.command-jshwdq22.js +0 -93
  136. package/context.command-ez8a0zyz.js +0 -80
  137. package/devTuiView-c08ccbat.js +0 -9
  138. package/getDirname-dr3jz1xg.js +0 -7
  139. package/guideline.command-xmqwx8zm.js +0 -359
  140. package/guidelines/agentRule/agentRule.generate.json +0 -31
  141. package/guidelines/componentRule/componentRule.generate.json +0 -31
  142. package/guidelines/conventions/conventions.generate.json +0 -25
  143. package/guidelines/cssRule/cssRule.generate.json +0 -31
  144. package/guidelines/docPageRule/docPageRule.generate.json +0 -31
  145. package/guidelines/docPageRule/docPageRule.instruction.md +0 -25
  146. package/guidelines/docSyncRule/docSyncRule.generate.json +0 -31
  147. package/guidelines/docSyncRule/docSyncRule.instruction.md +0 -25
  148. package/guidelines/enumConstant/enumConstant.generate.json +0 -31
  149. package/guidelines/enumConstant/enumConstant.instruction.md +0 -28
  150. package/guidelines/fieldRule/fieldRule.generate.json +0 -31
  151. package/guidelines/framework/framework.generate.json +0 -32
  152. package/guidelines/mcpRule/mcpRule.generate.json +0 -35
  153. package/guidelines/modelConstant/modelConstant.generate.json +0 -32
  154. package/guidelines/modelDictionary/modelDictionary.generate.json +0 -32
  155. package/guidelines/modelDocument/modelDocument.generate.json +0 -31
  156. package/guidelines/modelService/modelService.generate.json +0 -31
  157. package/guidelines/modelSignal/modelSignal.generate.json +0 -31
  158. package/guidelines/modelStore/modelStore.generate.json +0 -31
  159. package/guidelines/modelTemplate/modelTemplate.generate.json +0 -31
  160. package/guidelines/modelUnit/modelUnit.generate.json +0 -31
  161. package/guidelines/modelUtil/modelUtil.generate.json +0 -31
  162. package/guidelines/modelView/modelView.generate.json +0 -31
  163. package/guidelines/modelZone/modelZone.generate.json +0 -31
  164. package/guidelines/moduleCodegen/moduleCodegen.generate.json +0 -31
  165. package/guidelines/moduleCodegen/moduleCodegen.instruction.md +0 -28
  166. package/guidelines/moduleOverview/moduleOverview.generate.json +0 -31
  167. package/guidelines/queryRule/queryRule.generate.json +0 -31
  168. package/guidelines/recipeRule/recipeRule.generate.json +0 -31
  169. package/guidelines/runtimeRule/runtimeRule.generate.json +0 -25
  170. package/guidelines/scalarConstant/scalarConstant.generate.json +0 -32
  171. package/guidelines/scalarDictionary/scalarDictionary.generate.json +0 -32
  172. package/guidelines/scalarModule/scalarModule.generate.json +0 -31
  173. package/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -31
  174. package/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -25
  175. package/guidelines/ssrRule/ssrRule.generate.json +0 -31
  176. package/guidelines/transportRule/transportRule.generate.json +0 -31
  177. package/guidelines/utilUiUsage/utilUiUsage.generate.json +0 -31
  178. package/guidelines/utilUiUsage/utilUiUsage.instruction.md +0 -25
  179. package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +0 -24
  180. package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +0 -33
  181. package/index-2hq52jq3.js +0 -465
  182. package/index-47pj3aee.js +0 -76
  183. package/index-6wwzs1bc.js +0 -7
  184. package/index-8pm30m73.js +0 -841
  185. package/index-kn1h7p1x.js +0 -560
  186. package/index-meh558jy.js +0 -65
  187. package/index-rwg2aa4f.js +0 -229
  188. package/index-w8kmx1b6.js +0 -2176
  189. package/index-wt7qrtd4.js +0 -1516
  190. package/templates/__scalar/__model__/__model__.abstract.md +0 -28
  191. package/templates/module/__model__.abstract.md +0 -28
  192. package/templates/service/__model__.abstract.md +0 -28
  193. package/templates/workspaceRoot/patches/react-dom@19.2.7.patch.template +0 -62
  194. package/workflow.command-nwpcdc8p.js +0 -107
@@ -0,0 +1,266 @@
1
+ // @bun
2
+ import {
3
+ FileSys2
4
+ } from "./index-52w0fvh8.js";
5
+ import {
6
+ ConfigLock
7
+ } from "./index-3hx1z96c.js";
8
+
9
+ // pkgs/@akanjs/devkit/cloud/globalConfig.ts
10
+ import { mkdir, rm, writeFile } from "fs/promises";
11
+ import dayjs from "dayjs";
12
+
13
+ // pkgs/@akanjs/devkit/cloud/constants.ts
14
+ import path from "path";
15
+ var basePath = path.join(Bun.env.HOME ?? Bun.env.USERPROFILE ?? "", ".akan");
16
+ var configPath = path.join(basePath, "config.json");
17
+ var getDefaultHostConfig = (host = GlobalConfig.akanCloudHost) => ({ host });
18
+ var defaultAkanGlobalConfig = {
19
+ cloudHost: {},
20
+ remoteEnvServers: {},
21
+ testTargets: {}
22
+ };
23
+
24
+ // pkgs/@akanjs/devkit/cloud/globalConfig.ts
25
+ class GlobalConfig {
26
+ static akanCloudHost = process.env.USE_AKANJS_PKGS === "true" ? `http://localhost:${process.env.CLOUD_HOST_PORT ?? 8283}` : "https://cloud.akanjs.com";
27
+ static async#getAkanGlobalConfig() {
28
+ const exists = await FileSys2.fileExists(configPath);
29
+ const akanConfig = exists ? await FileSys2.readJson(configPath) : {};
30
+ return {
31
+ ...defaultAkanGlobalConfig,
32
+ ...akanConfig,
33
+ cloudHost: akanConfig.cloudHost ?? defaultAkanGlobalConfig.cloudHost,
34
+ remoteEnvServers: akanConfig.remoteEnvServers ?? defaultAkanGlobalConfig.remoteEnvServers,
35
+ testTargets: akanConfig.testTargets ?? defaultAkanGlobalConfig.testTargets
36
+ };
37
+ }
38
+ static async#setAkanGlobalConfig(akanConfig) {
39
+ await mkdir(basePath, { recursive: true, mode: 448 });
40
+ const temp = `${configPath}.${process.pid}.${crypto.randomUUID()}.tmp`;
41
+ try {
42
+ await writeFile(temp, JSON.stringify(akanConfig, null, 2), { mode: 384 });
43
+ await FileSys2.replace(temp, configPath);
44
+ } catch (error) {
45
+ await rm(temp, { force: true });
46
+ throw error;
47
+ }
48
+ }
49
+ static #lockPath = `${configPath}.lock`;
50
+ static async#update(mutate) {
51
+ await ConfigLock.run(GlobalConfig.#lockPath, async () => {
52
+ await GlobalConfig.#setAkanGlobalConfig(mutate(await GlobalConfig.#getAkanGlobalConfig()));
53
+ });
54
+ }
55
+ static async getHostConfig(host = GlobalConfig.akanCloudHost) {
56
+ const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
57
+ return GlobalConfig.toHostConfig(akanConfig.cloudHost[host] ?? getDefaultHostConfig(host));
58
+ }
59
+ static async setHostConfig(config = getDefaultHostConfig()) {
60
+ await GlobalConfig.#update((akanConfig) => GlobalConfig.#withHost(akanConfig, config));
61
+ }
62
+ static #withHost(akanConfig, config) {
63
+ return {
64
+ ...akanConfig,
65
+ cloudHost: { ...akanConfig.cloudHost, [config.host]: GlobalConfig.toHostConfigDto(config) }
66
+ };
67
+ }
68
+ static async refreshHostAuth(host, refresh) {
69
+ try {
70
+ return await ConfigLock.run(GlobalConfig.#lockPath, async () => {
71
+ const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
72
+ const current = GlobalConfig.toHostConfig(akanConfig.cloudHost[host] ?? getDefaultHostConfig(host));
73
+ const accessToken = current.auth?.accessToken;
74
+ const refreshToken = accessToken?.refreshToken;
75
+ if (!accessToken || !refreshToken || !GlobalConfig.needRefreshToken(accessToken))
76
+ return current;
77
+ const claimed = {
78
+ ...current,
79
+ auth: { ...current.auth, accessToken: { ...accessToken, refreshToken: null } }
80
+ };
81
+ await GlobalConfig.#setAkanGlobalConfig(GlobalConfig.#withHost(akanConfig, claimed));
82
+ const next = await refresh(refreshToken).catch(() => null);
83
+ if (!next?.jwt)
84
+ return claimed;
85
+ const refreshed = { ...current, auth: { ...current.auth, accessToken: next } };
86
+ await GlobalConfig.#setAkanGlobalConfig(GlobalConfig.#withHost(await GlobalConfig.#getAkanGlobalConfig(), refreshed));
87
+ return refreshed;
88
+ });
89
+ } catch {
90
+ return await GlobalConfig.getHostConfig(host);
91
+ }
92
+ }
93
+ static async getRemoteEnvServers() {
94
+ return (await GlobalConfig.#getAkanGlobalConfig()).remoteEnvServers;
95
+ }
96
+ static async setRemoteEnvServer(name, config) {
97
+ await GlobalConfig.#update((akanConfig) => ({
98
+ ...akanConfig,
99
+ remoteEnvServers: { ...akanConfig.remoteEnvServers, [name]: config }
100
+ }));
101
+ }
102
+ static async removeRemoteEnvServer(name) {
103
+ await GlobalConfig.#update((akanConfig) => {
104
+ const { [name]: _, ...remoteEnvServers } = akanConfig.remoteEnvServers;
105
+ return { ...akanConfig, remoteEnvServers };
106
+ });
107
+ }
108
+ static async getTestTargets() {
109
+ return (await GlobalConfig.#getAkanGlobalConfig()).testTargets;
110
+ }
111
+ static async setTestTargets(testTargets) {
112
+ await GlobalConfig.#update((akanConfig) => ({
113
+ ...akanConfig,
114
+ testTargets: { ...akanConfig.testTargets, ...testTargets }
115
+ }));
116
+ }
117
+ static needRefreshToken(accessToken) {
118
+ return !!accessToken?.expiresAt?.isBefore(dayjs().add(1, "hour"));
119
+ }
120
+ static toAccessToken(accessToken) {
121
+ return {
122
+ jwt: accessToken.jwt,
123
+ refreshToken: accessToken.refreshToken ?? null,
124
+ expiresAt: accessToken.expiresAt ? dayjs(accessToken.expiresAt) : null
125
+ };
126
+ }
127
+ static toAccessTokenDto(accessToken) {
128
+ return {
129
+ jwt: accessToken.jwt,
130
+ refreshToken: accessToken.refreshToken ?? null,
131
+ expiresAt: accessToken.expiresAt?.toString() ?? null
132
+ };
133
+ }
134
+ static toHostConfigDto(hostConfig) {
135
+ return {
136
+ host: hostConfig.host,
137
+ auth: {
138
+ accessToken: hostConfig.auth?.accessToken ? GlobalConfig.toAccessTokenDto(hostConfig.auth.accessToken) : undefined,
139
+ self: hostConfig.auth?.self
140
+ }
141
+ };
142
+ }
143
+ static toHostConfig(hostConfigDto) {
144
+ return {
145
+ host: hostConfigDto.host,
146
+ auth: {
147
+ accessToken: hostConfigDto.auth?.accessToken ? GlobalConfig.toAccessToken(hostConfigDto.auth.accessToken) : undefined,
148
+ self: hostConfigDto.auth?.self
149
+ }
150
+ };
151
+ }
152
+ }
153
+
154
+ // pkgs/@akanjs/devkit/cloud/cloudApi.ts
155
+ class HttpClient {
156
+ baseUrl;
157
+ headers = {};
158
+ constructor(baseUrl, headers = {}) {
159
+ this.baseUrl = baseUrl;
160
+ this.headers = headers;
161
+ }
162
+ async get(url, { headers, signal } = {}) {
163
+ const response = await fetch(`${this.baseUrl}${url}`, {
164
+ headers: { "Content-Type": "application/json", ...this.headers, ...headers },
165
+ ...signal ? { signal } : {}
166
+ });
167
+ return await HttpClient.#body(response, url);
168
+ }
169
+ async getFile(url, localPath, headers) {
170
+ const response = await fetch(`${this.baseUrl}${url}`, {
171
+ headers: { ...this.headers, ...headers }
172
+ });
173
+ if (!response.ok)
174
+ throw new Error(`Failed to download file: ${response.status} ${response.statusText}`);
175
+ await Bun.write(localPath, response);
176
+ }
177
+ async post(url, data, { headers, signal } = {}) {
178
+ const isFormData = data instanceof FormData;
179
+ const response = await fetch(`${this.baseUrl}${url}`, {
180
+ method: "POST",
181
+ body: isFormData ? data : JSON.stringify(data),
182
+ headers: isFormData ? { ...this.headers, ...headers } : { "Content-Type": "application/json", ...this.headers, ...headers },
183
+ ...signal ? { signal } : {}
184
+ });
185
+ return await HttpClient.#body(response, url);
186
+ }
187
+ static async#body(response, url) {
188
+ const text = await response.text();
189
+ if (!response.ok)
190
+ throw new Error(`${response.status} ${response.statusText} from ${url}: ${text.slice(0, 200)}`);
191
+ return JSON.parse(text);
192
+ }
193
+ setHeaders(headers) {
194
+ Object.assign(this.headers, headers);
195
+ return this;
196
+ }
197
+ }
198
+
199
+ class CloudApi {
200
+ #api;
201
+ #accessToken = null;
202
+ #workspace;
203
+ host;
204
+ url;
205
+ static async fromHost(workspace, host) {
206
+ const hostConfig = await GlobalConfig.getHostConfig(host);
207
+ const accessToken = hostConfig.auth?.accessToken;
208
+ if (!accessToken || !GlobalConfig.needRefreshToken(accessToken))
209
+ return new CloudApi(workspace, hostConfig);
210
+ const tokenless = new CloudApi(workspace, hostConfig);
211
+ const refreshed = await GlobalConfig.refreshHostAuth(hostConfig.host, (refreshToken) => tokenless.refreshAuthToken(refreshToken));
212
+ return new CloudApi(workspace, refreshed);
213
+ }
214
+ constructor(workspace, hostConfig) {
215
+ this.#workspace = workspace;
216
+ this.#accessToken = hostConfig.auth?.accessToken ?? null;
217
+ this.host = hostConfig.host;
218
+ this.url = `${this.host}/api`;
219
+ this.#api = new HttpClient(this.url);
220
+ if (this.#accessToken && !GlobalConfig.needRefreshToken(this.#accessToken))
221
+ this.#api.setHeaders({ Authorization: `Bearer ${this.#accessToken.jwt}` });
222
+ }
223
+ #authorize(accessTokenDto) {
224
+ this.#accessToken = GlobalConfig.toAccessToken(accessTokenDto);
225
+ this.#api.setHeaders({ Authorization: `Bearer ${this.#accessToken.jwt}` });
226
+ return this.#accessToken;
227
+ }
228
+ async uploadEnv(devProjectId, file) {
229
+ const formData = new FormData;
230
+ formData.append("devProjectId", devProjectId);
231
+ formData.append("file", file);
232
+ return await this.#api.post(`/uploadEnv/${devProjectId}`, formData);
233
+ }
234
+ async downloadEnv(devProjectId) {
235
+ const localPath = `${this.#workspace.workspaceRoot}/local/env.tar`;
236
+ await this.#api.getFile(`/downloadEnv/${devProjectId}`, localPath);
237
+ return localPath;
238
+ }
239
+ async getRemoteAuthToken(remoteId) {
240
+ try {
241
+ return this.#authorize(await this.#api.get(`/getRemoteAuthToken/${remoteId}`));
242
+ } catch (_) {
243
+ return null;
244
+ }
245
+ }
246
+ async refreshAuthToken(refreshToken) {
247
+ return this.#authorize(await this.#api.post(`/refreshAuthToken`, { refreshToken }, { signal: AbortSignal.timeout(20000) }));
248
+ }
249
+ async requestTunnel(input) {
250
+ return await this.#api.post(`/tunnel/requestTunnel`, input);
251
+ }
252
+ async tunnelListInSelf() {
253
+ return await this.#api.get(`/tunnel/tunnelListInSelf`);
254
+ }
255
+ async revokeTunnel(code) {
256
+ return await this.#api.post(`/tunnel/revokeTunnel`, { code }, { signal: AbortSignal.timeout(5000) });
257
+ }
258
+ async getRemoteSelf() {
259
+ try {
260
+ return await this.#api.get(`/getRemoteSelf`);
261
+ } catch {
262
+ return null;
263
+ }
264
+ }
265
+ }
266
+ export { getDefaultHostConfig, GlobalConfig, CloudApi };
@@ -0,0 +1,12 @@
1
+ // @bun
2
+ // pkgs/@akanjs/cli/openBrowser.ts
3
+ import { spawn } from "child_process";
4
+ function openBrowser(url) {
5
+ const command = process.platform === "darwin" ? ["open", url] : process.platform === "win32" ? ["cmd", "/c", "start", "", url] : ["xdg-open", url];
6
+ const child = spawn(command[0], command.slice(1), { detached: true, stdio: "ignore" });
7
+ child.on("error", () => {});
8
+ child.unref();
9
+ return Promise.resolve();
10
+ }
11
+
12
+ export { openBrowser };
@@ -2,16 +2,16 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-mak3cd28.js";
5
+ } from "./index-xb7qhxa8.js";
6
6
  import {
7
- FileSys
8
- } from "./index-q0y2jq9j.js";
7
+ FileSys2
8
+ } from "./index-52w0fvh8.js";
9
9
  import {
10
10
  PkgExecutor
11
- } from "./index-2tv3fdx4.js";
11
+ } from "./index-n3jk2501.js";
12
12
  import {
13
13
  TypeScriptDependencyScanner2
14
- } from "./index-kcxmv48c.js";
14
+ } from "./index-2ahj896a.js";
15
15
 
16
16
  // pkgs/@akanjs/cli/package/package.runner.ts
17
17
  import path2 from "path";
@@ -112,7 +112,7 @@ class PackageRunner extends runner("package") {
112
112
  "create-akan-workspace"
113
113
  ];
114
114
  async version(workspace, { log = true } = {}) {
115
- const pkgJson = process.env.USE_AKANJS_PKGS === "true" ? await FileSys.readJson(`${workspace?.workspaceRoot ?? process.cwd()}/pkgs/akanjs/package.json`) : await this.#getInstalledPackageJson();
115
+ const pkgJson = process.env.USE_AKANJS_PKGS === "true" ? await FileSys2.readJson(`${workspace?.workspaceRoot ?? process.cwd()}/pkgs/akanjs/package.json`) : await this.#getInstalledPackageJson();
116
116
  const version = pkgJson.name === "akanjs" ? pkgJson.version : pkgJson.dependencies?.akanjs ?? pkgJson.version;
117
117
  if (log)
118
118
  Logger.rawLog(`akanjs@${version}`);
@@ -129,14 +129,19 @@ class PackageRunner extends runner("package") {
129
129
  for (const packageJsonPath of packageJsonCandidates) {
130
130
  if (!await Bun.file(packageJsonPath).exists())
131
131
  continue;
132
- const packageJson = await FileSys.readJson(packageJsonPath);
132
+ const packageJson = await FileSys2.readJson(packageJsonPath);
133
133
  if (packageJson.name === "akanjs" || packageJson.name === "@akanjs/cli")
134
134
  return packageJson;
135
135
  }
136
136
  throw new Error(`[package] failed to locate akanjs package.json from ${path2.dirname(Bun.main)}`);
137
137
  }
138
138
  async createPackage(workspace, pkgName) {
139
- await workspace.applyTemplate({ basePath: `pkgs/${pkgName}`, template: "pkgRoot", dict: { pkgName } });
139
+ const workspaceRootPath = ["pkgs", ...pkgName.split("/")].map(() => "..").join("/");
140
+ await workspace.applyTemplate({
141
+ basePath: `pkgs/${pkgName}`,
142
+ template: "pkgRoot",
143
+ dict: { pkgName, workspaceRootPath }
144
+ });
140
145
  await workspace.setPkgTsPaths(pkgName);
141
146
  }
142
147
  async removePackage(pkg) {
@@ -144,8 +149,7 @@ class PackageRunner extends runner("package") {
144
149
  await pkg.workspace.unsetPkgTsPaths(pkg.name);
145
150
  }
146
151
  async scanSync(pkg) {
147
- const scanResult = await pkg.scan();
148
- return scanResult;
152
+ return await pkg.scan();
149
153
  }
150
154
  async buildPackage(pkg) {
151
155
  await $`rm -rf ${pkg.dist.cwdPath}`;
@@ -153,7 +157,14 @@ class PackageRunner extends runner("package") {
153
157
  const scanner = await TypeScriptDependencyScanner2.from(pkg);
154
158
  const { npmDeps, npmDevDeps, missingDeps } = await scanner.getPackageBuildDependencies(pkg.name);
155
159
  const packageRuntimeDependencies = {
156
- "@akanjs/devkit": ["tailwind-scrollbar"]
160
+ "@akanjs/devkit": [
161
+ "tailwind-scrollbar",
162
+ "@earendil-works/chord",
163
+ "@earendil-works/pi-agent-core",
164
+ "@earendil-works/pi-ai",
165
+ "@earendil-works/pi-telemetry",
166
+ "@earendil-works/pi-tui"
167
+ ]
157
168
  };
158
169
  const packageRuntimeDevDependencies = { akanjs: ["@biomejs/biome", "@types/bun"] };
159
170
  if (pkg.name === "@akanjs/cli") {
@@ -164,17 +175,23 @@ class PackageRunner extends runner("package") {
164
175
  ].filter((dep) => dep !== "akanjs" && dep !== "@akanjs/devkit");
165
176
  }
166
177
  const packageBundledRuntimeDependencies = {
167
- "@akanjs/cli": ["@akanjs/devkit"],
168
- akanjs: ["use-agentic"]
178
+ "@akanjs/cli": ["@akanjs/devkit", "@akanjs/native"],
179
+ "@akanjs/devkit": ["@akanjs/native"],
180
+ akanjs: ["use-agentic", "@akanjs/native"]
169
181
  };
170
182
  const bundledRuntimeDeps = new Set(packageBundledRuntimeDependencies[pkg.name] ?? []);
171
183
  const forcedRuntimeDeps = packageRuntimeDependencies[pkg.name] ?? [];
172
184
  const forcedRuntimeDevDeps = packageRuntimeDevDependencies[pkg.name] ?? [];
173
185
  const [rootPackageJson, pkgJson] = await Promise.all([pkg.workspace.getPackageJson(), pkg.getPackageJson()]);
174
186
  const optionalPeerDeps = new Set(Object.entries(pkgJson.peerDependenciesMeta ?? {}).filter(([, meta]) => meta.optional).map(([dep]) => dep));
175
- const packageRuntimeDeps = [...new Set([...npmDeps, ...forcedRuntimeDeps])].filter((dep) => !optionalPeerDeps.has(dep) && !bundledRuntimeDeps.has(dep));
176
- const packageRuntimeDevDeps = [...new Set([...npmDevDeps, ...forcedRuntimeDevDeps])].filter((dep) => !optionalPeerDeps.has(dep) && !bundledRuntimeDeps.has(dep));
177
- const rootDeps = { ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies };
187
+ const isShipped = (dep) => !optionalPeerDeps.has(dep) && !bundledRuntimeDeps.has(dep);
188
+ const packageRuntimeDeps = [...new Set([...npmDeps, ...forcedRuntimeDeps])].filter(isShipped);
189
+ const packageRuntimeDevDeps = [...new Set([...npmDevDeps, ...forcedRuntimeDevDeps])].filter(isShipped);
190
+ const rootDeps = {
191
+ ...rootPackageJson.overrides,
192
+ ...rootPackageJson.dependencies,
193
+ ...rootPackageJson.devDependencies
194
+ };
178
195
  const missingForcedDeps = forcedRuntimeDeps.filter((dep) => !rootDeps[dep]);
179
196
  const missingForcedDevDeps = forcedRuntimeDevDeps.filter((dep) => !rootDeps[dep]);
180
197
  const requiredMissingDeps = missingDeps.filter((dep) => !optionalPeerDeps.has(dep));
@@ -192,7 +209,8 @@ class PackageRunner extends runner("package") {
192
209
  stdio: "inherit"
193
210
  });
194
211
  } else {
195
- await $`cp -r ${pkg.cwdPath}/. ${pkg.dist.cwdPath}`;
212
+ await pkg.dist.cp(pkg.cwdPath, pkg.dist.cwdPath);
213
+ await $`rm -rf ${pkg.dist.cwdPath}/local`;
196
214
  await Promise.all([
197
215
  pkg.generateDistPackageJson(packageRuntimeDeps, packageRuntimeDevDeps),
198
216
  pkg.generateTsconfigJson()
@@ -266,7 +284,7 @@ class PackageRunner extends runner("package") {
266
284
  if (!await Bun.file(distPackageJsonPath).exists()) {
267
285
  throw new Error(`[package] dist package not found for ${pkg.name}. Run build-package first.`);
268
286
  }
269
- const pkgJson = await FileSys.readJson(distPackageJsonPath);
287
+ const pkgJson = await FileSys2.readJson(distPackageJsonPath);
270
288
  if (pkgJson.name !== pkg.name) {
271
289
  throw new Error(`[package] dist package name mismatch: expected ${pkg.name}, got ${pkgJson.name ?? "(missing)"}`);
272
290
  }
@@ -275,12 +293,9 @@ class PackageRunner extends runner("package") {
275
293
  if (pkgJson.publishConfig?.access !== "public") {
276
294
  throw new Error(`[package] ${pkg.name} must publish with publishConfig.access=public`);
277
295
  }
278
- if (!await Bun.file(`${pkg.dist.cwdPath}/README.md`).exists()) {
279
- throw new Error(`[package] README.md is missing from dist package ${pkg.name}`);
280
- }
281
- if (!await Bun.file(`${pkg.dist.cwdPath}/README.ko.md`).exists()) {
282
- throw new Error(`[package] README.ko.md is missing from dist package ${pkg.name}`);
283
- }
296
+ for (const readme of ["README.md", "README.ko.md"])
297
+ if (!await Bun.file(`${pkg.dist.cwdPath}/${readme}`).exists())
298
+ throw new Error(`[package] ${readme} is missing from dist package ${pkg.name}`);
284
299
  const binEntries = typeof pkgJson.bin === "string" ? [pkgJson.bin] : Object.values(pkgJson.bin ?? {});
285
300
  if (binEntries.some((binPath) => binPath.endsWith(".ts"))) {
286
301
  throw new Error(`[package] ${pkg.name} dist bin entries must not point at TypeScript sources`);
@@ -297,6 +312,9 @@ class PackageRunner extends runner("package") {
297
312
  cwd: pkg.workspace.workspaceRoot
298
313
  });
299
314
  const [packResult] = JSON.parse(packOutput);
315
+ const localFiles = (packResult?.files ?? []).filter((file) => file.path?.startsWith("local/"));
316
+ if (localFiles.length > 0)
317
+ throw new Error(`[package] ${pkg.name} would publish ${localFiles.length} test-run files under local/`);
300
318
  return {
301
319
  name: pkg.name,
302
320
  version: pkgJson.version,
@@ -313,9 +331,8 @@ class PackageRunner extends runner("package") {
313
331
  peerExportsMaps.set(pkg.name, await PackageExportsMap.from(pkg.dist.cwdPath));
314
332
  }
315
333
  const results = [];
316
- for (const pkg of pkgs) {
334
+ for (const pkg of pkgs)
317
335
  results.push(await this.verifyDistPackage(pkg, { peerExportsMaps }));
318
- }
319
336
  return results;
320
337
  }
321
338
  async#copyPackageReadmes(pkg) {
@@ -14,25 +14,26 @@ class LibSource {
14
14
  const relative = file.slice(this.#prefix.length);
15
15
  return !LibSource.unhashedDirs.includes(relative.split("/")[0] ?? "");
16
16
  }
17
- async#hashableContent(file) {
18
- const content = await this.#lib.workspace.readFile(file);
19
- if (file !== `${this.#prefix}package.json`)
20
- return content;
21
- const manifest = JSON.parse(content);
17
+ static unstamped(manifestContent) {
18
+ const manifest = JSON.parse(manifestContent);
22
19
  delete manifest[LibSource.manifestKey];
23
20
  return JSON.stringify(manifest);
24
21
  }
25
- async computeHash() {
26
- const files = (await this.#lib.workspace.listGitFiles([`libs/${this.#lib.name}`], { untracked: true })).filter((file) => this.#isHashed(file));
22
+ static async hashFiles(files, manifestFile, read) {
27
23
  const hasher = new Bun.CryptoHasher("sha256");
28
24
  for (const file of files) {
25
+ const content = await read(file);
29
26
  hasher.update(file);
30
27
  hasher.update("\x00");
31
- hasher.update(await this.#hashableContent(file));
28
+ hasher.update(file === manifestFile ? LibSource.unstamped(content) : content);
32
29
  hasher.update("\x00");
33
30
  }
34
31
  return hasher.digest("hex").slice(0, 32);
35
32
  }
33
+ async computeHash() {
34
+ const files = (await this.#lib.workspace.listGitFiles([`libs/${this.#lib.name}`], { untracked: true })).filter((file) => this.#isHashed(file));
35
+ return await LibSource.hashFiles(files, `${this.#prefix}package.json`, (file) => this.#lib.workspace.readFile(file));
36
+ }
36
37
  async read() {
37
38
  const manifest = await this.#lib.getPackageJson();
38
39
  const akan = manifest[LibSource.manifestKey];
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-mak3cd28.js";
5
+ } from "./index-xb7qhxa8.js";
6
6
  import {
7
7
  AGENT_BLOCK_START,
8
8
  AGENT_BLOCK_END,
@@ -13,17 +13,17 @@ import {
13
13
  CLAUDE_COMMENT_RULE,
14
14
  AppExecutor,
15
15
  LibExecutor
16
- } from "./index-2tv3fdx4.js";
16
+ } from "./index-n3jk2501.js";
17
17
  import {
18
18
  collectRecipeSources2,
19
19
  scanRecipes2
20
- } from "./index-by5gpp8x.js";
20
+ } from "./index-hj6w4ka1.js";
21
21
  import {
22
22
  AkanContextAnalyzer
23
- } from "./index-ktb5njgy.js";
23
+ } from "./index-tzc1gtrg.js";
24
24
  import {
25
- Prompter
26
- } from "./index-h7yw2z9n.js";
25
+ Prompter2
26
+ } from "./index-zzvvc845.js";
27
27
 
28
28
  // pkgs/@akanjs/cli/agent/agent.script.ts
29
29
  import { Logger as Logger2 } from "akanjs/common";
@@ -106,10 +106,10 @@ ${scopeIndexPointer}
106
106
  `;
107
107
  };
108
108
  var renderGuides = async (context) => {
109
- const conventions = (await Prompter.getInstruction("conventions")).trim();
109
+ const conventions = (await Prompter2.getInstruction("conventions")).trim();
110
110
  if (context.pkgs.some((pkg) => pkg.name === "akanjs"))
111
111
  return conventions;
112
- const onboarding = (await Prompter.getInstruction("workspaceOnboarding")).trim();
112
+ const onboarding = (await Prompter2.getInstruction("workspaceOnboarding")).trim();
113
113
  const appName = context.apps[0]?.name ?? "app";
114
114
  return `${conventions}
115
115
 
@@ -117,7 +117,7 @@ ${onboarding.replaceAll("<%= appName %>", appName)}`;
117
117
  };
118
118
  var renderManagedBlock = async (workspace) => {
119
119
  const context = await AkanContextAnalyzer.analyze(workspace);
120
- const frameworkGuide = await Prompter.getInstruction("framework");
120
+ const frameworkGuide = await Prompter2.getInstruction("framework");
121
121
  const appNames = context.apps.map((app) => app.name);
122
122
  const sampleCleanup = await renderSampleCleanup(workspace, appNames);
123
123
  const recipeIndex = await renderRecipeIndex(workspace);
@@ -126,7 +126,7 @@ var renderManagedBlock = async (workspace) => {
126
126
  const block = `## Workspace
127
127
 
128
128
  - Repo: ${context.repoName}
129
- - Apps: ${context.apps.map((app) => app.name).join(", ") || "none"}
129
+ - Apps: ${appNames.join(", ") || "none"}
130
130
  - Libraries: ${context.libs.map((lib) => lib.name).join(", ") || "none"}
131
131
  - Packages: ${context.pkgs.map((pkg) => pkg.name).join(", ") || "none"}
132
132
 
@@ -138,7 +138,7 @@ ${sampleCleanup}## Akan Module Abstracts
138
138
  - Update the abstract when business invariants, workflows, or public behavior change.
139
139
  - Do not update the abstract for formatting-only, import-only, or style-only changes.
140
140
  - Service modules live in \`lib/_<service>\`, but their abstract file is \`<service>.abstract.md\`.
141
- - Keep an abstract short. Run \`akan compact <app-or-lib>\` to rewrite bloated abstracts down to the invariants the code cannot show; \`akan quality scan\` warns past 300 lines.
141
+ - Keep an abstract short \u2014 the invariants the code cannot show, and nothing it already states. \`akan quality scan\` warns past 300 lines.
142
142
 
143
143
  ## Generated Files
144
144
 
@@ -148,7 +148,7 @@ If generated output is stale or broken, update the owning source file and run \`
148
148
  ${recipeIndex}## MCP Workflow Policy
149
149
 
150
150
  - **Prefer an Akan workflow to a direct source edit.** A direct edit is denied when an allowlisted workflow or repair tool can make the change.
151
- - Inspect with \`akan mcp --mode plan\` (\`list_workflows\`, \`explain_workflow\`, \`plan_workflow\`); apply with \`akan mcp --mode apply\`, which allowlists \`apply_workflow\`, \`run_validation\`, and the repair tools.
151
+ - Inspect with \`akan mcp --mode plan\` (\`list_workflows\`, \`explain_workflow\`, \`plan_workflow\`); apply with \`akan mcp --mode apply\`, which allowlists \`apply_workflow\`, \`run_validation\`, and three of the five repair tools \u2014 \`repair_generated\`, \`repair_imports\` and \`repair_module_shape\`. \`akan repair format\` and \`akan repair dictionary\` are CLI-only.
152
152
  - If \`plan_workflow\` returns \`planPath\` or \`next.tool=apply_workflow\`, call \`apply_workflow({ planPath })\` before editing source. Then run \`run_validation\` with \`validationTarget\` when present, otherwise \`applyReportPath\`.
153
153
  - Split a compound request into workflows and apply each \`planPath\` in order, such as \`create-module\` followed by \`add-field\`.
154
154
  - When no workflow exists, or apply reports unsupported/no-op/failed diagnostics needing manual action, keep edits scoped to owning source files and never patch generated files directly.
@@ -0,0 +1,123 @@
1
+ // @bun
2
+ // pkgs/@akanjs/devkit/codeAgent/agent/akanCodeModel.ts
3
+ var akanCodeDefaultModel2 = { provider: "deepseek", id: "deepseek-flash" };
4
+ var catalogueMissesImages = new Set(["deepseek/deepseek-v4-flash"]);
5
+ var correctInputs = (model) => {
6
+ if (!model || model.input.includes("image"))
7
+ return model;
8
+ if (!catalogueMissesImages.has(`${model.provider}/${model.id}`))
9
+ return model;
10
+ return { ...model, input: [...model.input, "image"] };
11
+ };
12
+ var akanCodeModel2 = async (runtime, ref) => {
13
+ if (ref) {
14
+ const requested = runtime.getModel(ref.provider, ref.id);
15
+ if (!requested)
16
+ throw new Error(`Unknown model: ${ref.provider}/${ref.id}`);
17
+ if (!runtime.hasConfiguredAuth(ref.provider))
18
+ throw new Error(`No API key configured for ${ref.provider}. Set ${ref.provider.toUpperCase()}_API_KEY.`);
19
+ return correctInputs(requested);
20
+ }
21
+ const fallback = runtime.getModel(akanCodeDefaultModel2.provider, akanCodeDefaultModel2.id);
22
+ if (fallback && runtime.hasConfiguredAuth(fallback.provider))
23
+ return correctInputs(fallback);
24
+ return correctInputs((await runtime.getAvailable())[0]);
25
+ };
26
+ var akanCodeModelSupportsImages2 = (model) => !!model?.input.includes("image");
27
+ var akanCodeModelWarnings2 = (model, compactionFloor) => {
28
+ if (!model)
29
+ return [];
30
+ if (model.contextWindow >= compactionFloor)
31
+ return [];
32
+ return [
33
+ `${model.provider}/${model.id} declares a ${model.contextWindow}-token context window, below the ${compactionFloor} the compaction policy needs, so every turn will compact immediately. Check the model entry in ~/.akan/code/models.json.`
34
+ ];
35
+ };
36
+
37
+ // pkgs/@akanjs/devkit/codeAgent/agent/CodeAgentStreamPrinter.ts
38
+ import { codeAgentEventLabel } from "akanjs/common";
39
+ import chalk from "chalk";
40
+
41
+ class CodeAgentStreamPrinter2 {
42
+ #options;
43
+ #write;
44
+ #streaming = false;
45
+ constructor(options = {}) {
46
+ this.#options = options;
47
+ this.#write = options.write ?? ((text) => process.stdout.write(text));
48
+ }
49
+ print(event) {
50
+ if (this.#options.json)
51
+ return this.#write(`${JSON.stringify(event)}
52
+ `);
53
+ switch (event.type) {
54
+ case "text_delta":
55
+ this.#streaming = true;
56
+ return this.#write(event.text);
57
+ case "thinking_delta":
58
+ if (!this.#options.thinking)
59
+ return;
60
+ this.#streaming = true;
61
+ return this.#write(chalk.dim(event.text));
62
+ case "tool_start":
63
+ return this.#line(chalk.cyan(`\u2192 ${event.tool.title}`));
64
+ case "tool_end":
65
+ return this.#line(CodeAgentStreamPrinter2.#toolEnd(event));
66
+ case "session":
67
+ return this.#line(chalk.dim(codeAgentEventLabel(event)));
68
+ case "turn_end":
69
+ if (event.stopReason === "truncated")
70
+ return this.#line(chalk.yellow(codeAgentEventLabel(event)));
71
+ return;
72
+ case "message":
73
+ case "tool_progress":
74
+ case "turn_start":
75
+ case "idle":
76
+ case "queue":
77
+ case "context":
78
+ case "subagent":
79
+ return;
80
+ case "question":
81
+ return this.#line(chalk.yellow(`? ${event.question.prompt}`));
82
+ case "approval":
83
+ return this.#line(chalk.yellow(`approve? ${event.request.summary}`));
84
+ case "notice":
85
+ return this.#line(CodeAgentStreamPrinter2.#notice(event.level, event.message));
86
+ case "error":
87
+ return this.#line(chalk.red(`error: ${event.message}`));
88
+ default:
89
+ return this.#line(chalk.dim(codeAgentEventLabel(event)));
90
+ }
91
+ }
92
+ finish() {
93
+ if (this.#streaming)
94
+ this.#write(`
95
+ `);
96
+ this.#streaming = false;
97
+ }
98
+ #line(text) {
99
+ if (this.#streaming)
100
+ this.#write(`
101
+ `);
102
+ this.#streaming = false;
103
+ this.#write(`${text}
104
+ `);
105
+ }
106
+ static #toolEnd(event) {
107
+ if (event.outcome === "ok")
108
+ return chalk.green(`\u2713 ${event.tool.title}`);
109
+ if (event.outcome === "blocked")
110
+ return chalk.yellow(`\u29B8 ${event.tool.title} \u2014 ${event.output}`);
111
+ return chalk.red(`\u2717 ${event.tool.title} \u2014 ${event.output.split(`
112
+ `)[0] ?? ""}`);
113
+ }
114
+ static #notice(level, message) {
115
+ if (level === "error")
116
+ return chalk.red(message);
117
+ if (level === "warning")
118
+ return chalk.yellow(message);
119
+ return chalk.dim(message);
120
+ }
121
+ }
122
+
123
+ export { akanCodeDefaultModel2, akanCodeModel2, akanCodeModelSupportsImages2, akanCodeModelWarnings2, CodeAgentStreamPrinter2 };