t3code-cli 0.11.0 → 0.12.0

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 (317) hide show
  1. package/README.md +42 -10
  2. package/dist/application.js +2 -2
  3. package/dist/auth.js +1 -1
  4. package/dist/bin.js +85526 -2662
  5. package/dist/cli.js +15 -2
  6. package/dist/config.js +120 -2
  7. package/dist/connection.js +2 -2
  8. package/dist/index.js +1 -1
  9. package/dist/node.js +6 -2
  10. package/dist/orchestration.js +2 -2
  11. package/dist/rpc.js +1 -1
  12. package/dist/runtime.js +2 -2
  13. package/dist/shared.js +42956 -38119
  14. package/dist/src/application/actions.d.ts +25 -0
  15. package/dist/src/application/index.d.ts +3 -3
  16. package/dist/src/application/layer.d.ts +51 -35
  17. package/dist/src/application/model-selection.d.ts +2 -2
  18. package/dist/src/application/models.d.ts +1 -1
  19. package/dist/src/application/project-commands.d.ts +22 -2
  20. package/dist/src/application/projects.d.ts +7 -7
  21. package/dist/src/application/service.d.ts +65 -2
  22. package/dist/src/application/shell-sequence.d.ts +11 -0
  23. package/dist/src/application/terminals.d.ts +2 -2
  24. package/dist/src/application/thread-commands.d.ts +1 -1
  25. package/dist/src/application/thread-wait.d.ts +9 -0
  26. package/dist/src/application/threads.d.ts +56 -5
  27. package/dist/src/auth/error.d.ts +2 -1
  28. package/dist/src/auth/index.d.ts +1 -1
  29. package/dist/src/auth/layer.d.ts +34 -6
  30. package/dist/src/auth/local-base-dir.d.ts +5 -2
  31. package/dist/src/auth/local-origin.d.ts +3 -3
  32. package/dist/src/auth/local-token.d.ts +3 -3
  33. package/dist/src/auth/service.d.ts +15 -3
  34. package/dist/src/auth/type.d.ts +40 -1
  35. package/dist/src/cli/env/flag.d.ts +2 -0
  36. package/dist/src/cli/env/index.d.ts +2 -0
  37. package/dist/src/cli/env/selection-layer.d.ts +3 -0
  38. package/dist/src/cli/flags.d.ts +2 -0
  39. package/dist/src/cli/format/index.d.ts +1 -0
  40. package/dist/src/cli/format/output.d.ts +12 -0
  41. package/dist/src/cli/index.d.ts +4 -0
  42. package/dist/src/cli/runtime/index.d.ts +1 -0
  43. package/dist/src/cli/runtime/service.d.ts +16 -0
  44. package/dist/src/{scope → cli/scope}/resolve.d.ts +5 -4
  45. package/dist/src/config/config.d.ts +49 -0
  46. package/dist/src/config/credential/cipher-node.d.ts +3 -0
  47. package/dist/src/config/credential/cipher-web.d.ts +3 -0
  48. package/dist/src/config/credential/cipher.d.ts +29 -0
  49. package/dist/src/config/credential/env.d.ts +3 -0
  50. package/dist/src/config/credential/error.d.ts +8 -0
  51. package/dist/src/config/credential/index.d.ts +6 -0
  52. package/dist/src/config/credential/service.d.ts +34 -0
  53. package/dist/src/config/env/env.d.ts +55 -0
  54. package/dist/src/config/env/index.d.ts +2 -0
  55. package/dist/src/{layout/base-dir.d.ts → config/env/layout.d.ts} +0 -1
  56. package/dist/src/config/environment-name/index.d.ts +1 -0
  57. package/dist/src/config/environment-name/name.d.ts +10 -0
  58. package/dist/src/config/error.d.ts +4 -11
  59. package/dist/src/config/index.d.ts +10 -5
  60. package/dist/src/config/keystore/error.d.ts +8 -0
  61. package/dist/src/config/keystore/file.d.ts +9 -0
  62. package/dist/src/config/keystore/index.d.ts +4 -0
  63. package/dist/src/config/keystore/keyring-node.d.ts +4 -0
  64. package/dist/src/config/keystore/service.d.ts +33 -0
  65. package/dist/src/config/paths/index.d.ts +1 -0
  66. package/dist/src/config/paths/paths.d.ts +6 -0
  67. package/dist/src/config/persist/file-mode.d.ts +4 -0
  68. package/dist/src/config/persist/migration.d.ts +68 -0
  69. package/dist/src/config/persist/persist.d.ts +40 -0
  70. package/dist/src/config/persist/schema.d.ts +68 -0
  71. package/dist/src/config/resolve/resolve.d.ts +40 -0
  72. package/dist/src/config/selection/index.d.ts +1 -0
  73. package/dist/src/config/selection/resolve.d.ts +4 -0
  74. package/dist/src/config/selection/service.d.ts +10 -0
  75. package/dist/src/config/types.d.ts +36 -0
  76. package/dist/src/config/url/error.d.ts +10 -0
  77. package/dist/src/config/url/index.d.ts +2 -0
  78. package/dist/src/connection/index.d.ts +0 -1
  79. package/dist/src/contracts/index.d.ts +1 -1
  80. package/dist/src/domain/error.d.ts +14 -1
  81. package/dist/src/domain/helpers.d.ts +16 -1
  82. package/dist/src/domain/model-config.d.ts +4 -1
  83. package/dist/src/domain/thread-activities.d.ts +1 -1
  84. package/dist/src/domain/thread-lifecycle.d.ts +10 -1
  85. package/dist/src/index.d.ts +1 -2
  86. package/dist/src/{connection/node.d.ts → node/connection.d.ts} +1 -1
  87. package/dist/src/node/index.d.ts +1 -2
  88. package/dist/src/orchestration/index.d.ts +0 -1
  89. package/dist/src/orchestration/layer.d.ts +153 -7
  90. package/dist/src/orchestration/service.d.ts +1 -1
  91. package/dist/src/rpc/error.d.ts +2 -2
  92. package/dist/src/rpc/index.d.ts +2 -3
  93. package/dist/src/rpc/layer.d.ts +574 -46
  94. package/dist/src/rpc/operation.d.ts +574 -46
  95. package/dist/src/rpc/ws-group.d.ts +184 -19
  96. package/dist/src/runtime/index.d.ts +1 -2
  97. package/dist/src/runtime/layer.d.ts +12 -8
  98. package/dist/src/t3tools/index.d.ts +1 -1
  99. package/dist/t3tools.js +2 -2
  100. package/package.json +25 -21
  101. package/src/application/actions.test.ts +328 -0
  102. package/src/application/actions.ts +475 -0
  103. package/src/application/index.ts +9 -5
  104. package/src/application/layer.ts +9 -0
  105. package/src/application/model-selection.ts +2 -2
  106. package/src/application/project-commands.ts +23 -5
  107. package/src/application/projects.ts +6 -7
  108. package/src/application/service.ts +79 -1
  109. package/src/application/shell-sequence.ts +1 -1
  110. package/src/application/terminals.ts +2 -1
  111. package/src/application/thread-commands.ts +1 -1
  112. package/src/application/thread-update.ts +1 -1
  113. package/src/application/thread-wait.ts +1 -1
  114. package/src/application/threads.test.ts +9 -3
  115. package/src/application/threads.ts +6 -6
  116. package/src/auth/error.ts +2 -1
  117. package/src/auth/index.ts +7 -0
  118. package/src/auth/layer.test-utils.ts +34 -0
  119. package/src/auth/layer.ts +116 -34
  120. package/src/auth/local-base-dir.ts +13 -6
  121. package/src/auth/local-origin.ts +10 -7
  122. package/src/auth/local-token.ts +28 -23
  123. package/src/auth/service.test.ts +200 -0
  124. package/src/auth/service.ts +27 -3
  125. package/src/auth/transport.ts +2 -2
  126. package/src/auth/type.ts +47 -1
  127. package/src/bin.ts +24 -6
  128. package/src/cli/action-format.ts +110 -0
  129. package/src/cli/action.ts +398 -0
  130. package/src/cli/app.ts +6 -0
  131. package/src/cli/auth.ts +76 -23
  132. package/src/cli/env/flag.ts +8 -0
  133. package/src/cli/env/index.ts +2 -0
  134. package/src/cli/env/selection-layer.test.ts +49 -0
  135. package/src/cli/env/selection-layer.ts +27 -0
  136. package/src/cli/env.ts +107 -0
  137. package/src/cli/extra-args.test.ts +32 -0
  138. package/src/cli/extra-args.ts +22 -0
  139. package/src/cli/flags.ts +11 -1
  140. package/src/cli/format/auth.ts +92 -0
  141. package/src/cli/format/human.ts +131 -0
  142. package/src/cli/format/index.ts +12 -0
  143. package/src/cli/format/model.ts +29 -0
  144. package/src/cli/format/output.ts +51 -0
  145. package/src/cli/format/project.ts +32 -0
  146. package/src/cli/format/terminal.ts +87 -0
  147. package/src/cli/{thread-format.test.ts → format/thread.test.ts} +6 -4
  148. package/src/cli/format/thread.ts +185 -0
  149. package/src/cli/index.ts +20 -0
  150. package/src/cli/interaction/confirm.ts +64 -0
  151. package/src/cli/{self-action.ts → interaction/self-action.ts} +8 -6
  152. package/src/cli/message-input.ts +1 -1
  153. package/src/cli/model.ts +9 -5
  154. package/src/cli/project.ts +13 -7
  155. package/src/cli/projects/delete.ts +13 -12
  156. package/src/cli/require.ts +9 -7
  157. package/src/cli/runtime/index.ts +1 -0
  158. package/src/cli/runtime/service.ts +28 -0
  159. package/src/{scope → cli/scope}/resolve.ts +11 -9
  160. package/src/cli/terminal/attach.ts +3 -6
  161. package/src/cli/terminal/create.ts +10 -9
  162. package/src/cli/terminal/destroy.ts +13 -11
  163. package/src/cli/terminal/list.ts +10 -9
  164. package/src/cli/terminal/read.test-utils.ts +48 -0
  165. package/src/cli/terminal/read.test.ts +35 -0
  166. package/src/cli/terminal/read.ts +3 -6
  167. package/src/cli/terminal/scope.ts +10 -5
  168. package/src/cli/terminal/shared.ts +1 -1
  169. package/src/cli/terminal/stream.ts +3 -6
  170. package/src/cli/terminal/wait.test.ts +5 -3
  171. package/src/cli/terminal/wait.ts +10 -9
  172. package/src/cli/terminal/write.test.ts +34 -0
  173. package/src/cli/terminal/write.ts +10 -9
  174. package/src/cli/threads/approve.ts +11 -7
  175. package/src/cli/threads/archive.ts +14 -9
  176. package/src/cli/threads/callback.ts +6 -4
  177. package/src/cli/threads/delete.ts +17 -11
  178. package/src/cli/threads/interrupt.ts +14 -9
  179. package/src/cli/threads/list.test.ts +5 -3
  180. package/src/cli/threads/list.ts +10 -10
  181. package/src/cli/threads/messages.ts +11 -7
  182. package/src/cli/threads/respond.ts +11 -7
  183. package/src/cli/threads/send.ts +19 -9
  184. package/src/cli/threads/show.ts +11 -7
  185. package/src/cli/threads/start.ts +18 -13
  186. package/src/cli/threads/unarchive.ts +11 -7
  187. package/src/cli/threads/update.ts +14 -9
  188. package/src/cli/threads/wait.ts +11 -7
  189. package/src/cli/wait-events.ts +1 -1
  190. package/src/config/config.ts +260 -0
  191. package/src/config/credential/cipher-node.ts +40 -0
  192. package/src/config/credential/cipher-web.ts +82 -0
  193. package/src/config/credential/cipher.ts +39 -0
  194. package/src/config/credential/env.ts +13 -0
  195. package/src/config/credential/error.ts +9 -0
  196. package/src/config/credential/index.ts +6 -0
  197. package/src/config/credential/service.test-utils.ts +25 -0
  198. package/src/config/credential/service.test.ts +116 -0
  199. package/src/config/credential/service.ts +205 -0
  200. package/src/config/env/env.test-utils.ts +14 -0
  201. package/src/config/env/env.ts +81 -0
  202. package/src/config/env/index.ts +2 -0
  203. package/src/{layout/base-dir.ts → config/env/layout.ts} +0 -9
  204. package/src/config/environment-name/index.ts +7 -0
  205. package/src/config/environment-name/name.test.ts +66 -0
  206. package/src/config/environment-name/name.ts +49 -0
  207. package/src/config/error.ts +6 -8
  208. package/src/config/index.ts +16 -5
  209. package/src/config/keystore/error.ts +9 -0
  210. package/src/config/keystore/file.ts +96 -0
  211. package/src/config/keystore/index.ts +4 -0
  212. package/src/config/keystore/keyring-node.test.ts +12 -0
  213. package/src/config/keystore/keyring-node.ts +100 -0
  214. package/src/config/keystore/service.test-utils.ts +15 -0
  215. package/src/config/keystore/service.test.ts +18 -0
  216. package/src/config/keystore/service.ts +29 -0
  217. package/src/config/layer.test-utils.ts +45 -0
  218. package/src/config/layer.test.ts +209 -0
  219. package/src/config/paths/index.ts +1 -0
  220. package/src/config/paths/paths.ts +36 -0
  221. package/src/config/persist/file-mode.ts +21 -0
  222. package/src/config/persist/migration.test.ts +71 -0
  223. package/src/config/persist/migration.ts +82 -0
  224. package/src/config/persist/persist.test.ts +113 -0
  225. package/src/config/persist/persist.ts +65 -0
  226. package/src/config/persist/schema.ts +37 -0
  227. package/src/config/platform.test-utils.ts +20 -0
  228. package/src/config/resolve/resolve.test-utils.ts +20 -0
  229. package/src/config/resolve/resolve.test.ts +137 -0
  230. package/src/config/resolve/resolve.ts +104 -0
  231. package/src/config/selection/index.ts +1 -0
  232. package/src/config/selection/resolve.ts +14 -0
  233. package/src/config/selection/service.ts +29 -0
  234. package/src/config/temp-home.test-utils.ts +7 -0
  235. package/src/config/types.ts +49 -0
  236. package/src/config/url/error.ts +8 -0
  237. package/src/config/url/index.ts +7 -0
  238. package/src/config/url/url.test.ts +31 -0
  239. package/src/connection/index.ts +0 -1
  240. package/src/contracts/index.ts +1 -1
  241. package/src/domain/error.ts +20 -1
  242. package/src/domain/helpers.test.ts +1 -1
  243. package/src/domain/helpers.ts +1 -1
  244. package/src/domain/model-config.ts +1 -1
  245. package/src/domain/thread-activities.test.ts +1 -1
  246. package/src/domain/thread-activities.ts +1 -1
  247. package/src/domain/thread-lifecycle.test.ts +1 -1
  248. package/src/domain/thread-lifecycle.ts +1 -1
  249. package/src/effect.test-utils.ts +25 -0
  250. package/src/index.ts +1 -1
  251. package/src/{connection/node.ts → node/connection.ts} +1 -1
  252. package/src/node/index.ts +1 -2
  253. package/src/orchestration/index.ts +0 -1
  254. package/src/orchestration/layer.ts +1 -1
  255. package/src/orchestration/service.ts +1 -1
  256. package/src/rpc/error.ts +2 -2
  257. package/src/rpc/index.ts +2 -3
  258. package/src/rpc/layer.ts +1 -1
  259. package/src/rpc/ws-group.ts +1 -1
  260. package/src/runtime/index.ts +2 -1
  261. package/src/runtime/layer.test-utils.ts +32 -0
  262. package/src/runtime/layer.test.ts +66 -0
  263. package/src/runtime/layer.ts +15 -9
  264. package/src/t3tools/index.ts +1 -1
  265. package/src/types/marked-terminal.d.ts +11 -0
  266. package/dist/layout.js +0 -2
  267. package/dist/scope.js +0 -2
  268. package/dist/src/cli/output-format.d.ts +0 -11
  269. package/dist/src/config/layer.d.ts +0 -22
  270. package/dist/src/config/service.d.ts +0 -22
  271. package/dist/src/environment/layer.d.ts +0 -3
  272. package/dist/src/environment/service.d.ts +0 -12
  273. package/dist/src/layout/index.d.ts +0 -1
  274. package/dist/upstream-t3code/packages/contracts/src/auth.d.ts +0 -441
  275. package/dist/upstream-t3code/packages/contracts/src/baseSchemas.d.ts +0 -38
  276. package/dist/upstream-t3code/packages/contracts/src/desktopBootstrap.d.ts +0 -14
  277. package/dist/upstream-t3code/packages/contracts/src/editor.d.ts +0 -124
  278. package/dist/upstream-t3code/packages/contracts/src/environment.d.ts +0 -64
  279. package/dist/upstream-t3code/packages/contracts/src/environmentHttp.d.ts +0 -762
  280. package/dist/upstream-t3code/packages/contracts/src/filesystem.d.ts +0 -26
  281. package/dist/upstream-t3code/packages/contracts/src/git.d.ts +0 -500
  282. package/dist/upstream-t3code/packages/contracts/src/index.d.ts +0 -25
  283. package/dist/upstream-t3code/packages/contracts/src/ipc.d.ts +0 -490
  284. package/dist/upstream-t3code/packages/contracts/src/keybindings.d.ts +0 -133
  285. package/dist/upstream-t3code/packages/contracts/src/model.d.ts +0 -112
  286. package/dist/upstream-t3code/packages/contracts/src/orchestration.d.ts +0 -6682
  287. package/dist/upstream-t3code/packages/contracts/src/project.d.ts +0 -45
  288. package/dist/upstream-t3code/packages/contracts/src/provider.d.ts +0 -116
  289. package/dist/upstream-t3code/packages/contracts/src/providerInstance.d.ts +0 -99
  290. package/dist/upstream-t3code/packages/contracts/src/providerRuntime.d.ts +0 -4276
  291. package/dist/upstream-t3code/packages/contracts/src/relay.d.ts +0 -1262
  292. package/dist/upstream-t3code/packages/contracts/src/relayClient.d.ts +0 -48
  293. package/dist/upstream-t3code/packages/contracts/src/remoteAccess.d.ts +0 -45
  294. package/dist/upstream-t3code/packages/contracts/src/review.d.ts +0 -37
  295. package/dist/upstream-t3code/packages/contracts/src/rpc.d.ts +0 -8218
  296. package/dist/upstream-t3code/packages/contracts/src/server.d.ts +0 -2291
  297. package/dist/upstream-t3code/packages/contracts/src/settings.d.ts +0 -271
  298. package/dist/upstream-t3code/packages/contracts/src/sourceControl.d.ts +0 -177
  299. package/dist/upstream-t3code/packages/contracts/src/terminal.d.ts +0 -330
  300. package/dist/upstream-t3code/packages/contracts/src/vcs.d.ts +0 -148
  301. package/src/cli/auth-format.ts +0 -45
  302. package/src/cli/confirm.ts +0 -31
  303. package/src/cli/model-format.ts +0 -18
  304. package/src/cli/output-format.ts +0 -45
  305. package/src/cli/project-format.ts +0 -18
  306. package/src/cli/terminal/commands.test.ts +0 -101
  307. package/src/cli/terminal-format.ts +0 -167
  308. package/src/cli/thread-format.ts +0 -128
  309. package/src/config/layer.ts +0 -105
  310. package/src/config/service.ts +0 -26
  311. package/src/environment/layer.ts +0 -12
  312. package/src/environment/service.ts +0 -13
  313. package/src/layout/index.ts +0 -1
  314. /package/dist/src/{scope → cli/scope}/index.d.ts +0 -0
  315. /package/dist/src/config/{url.d.ts → url/url.d.ts} +0 -0
  316. /package/src/{scope → cli/scope}/index.ts +0 -0
  317. /package/src/config/{url.ts → url/url.ts} +0 -0
@@ -55,6 +55,23 @@ export class TerminalLookupError extends Schema.TaggedErrorClass<TerminalLookupE
55
55
  },
56
56
  ) {}
57
57
 
58
+ export class ProjectActionLookupError extends Schema.TaggedErrorClass<ProjectActionLookupError>()(
59
+ "ProjectActionLookupError",
60
+ {
61
+ message: Schema.String,
62
+ projectId: Schema.String,
63
+ selector: Schema.String,
64
+ },
65
+ ) {}
66
+
67
+ export class ProjectActionValidationError extends Schema.TaggedErrorClass<ProjectActionValidationError>()(
68
+ "ProjectActionValidationError",
69
+ {
70
+ message: Schema.String,
71
+ projectId: Schema.String,
72
+ },
73
+ ) {}
74
+
58
75
  export type DomainError =
59
76
  | ProjectLookupError
60
77
  | ModelSelectionError
@@ -62,4 +79,6 @@ export type DomainError =
62
79
  | ThreadSessionError
63
80
  | ThreadLookupError
64
81
  | ProjectCreateVisibilityError
65
- | TerminalLookupError;
82
+ | TerminalLookupError
83
+ | ProjectActionLookupError
84
+ | ProjectActionValidationError;
@@ -5,7 +5,7 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
5
5
  import { assert, describe, it } from "@effect/vitest";
6
6
  import { fromPartial } from "@total-typescript/shoehorn";
7
7
 
8
- import type { OrchestrationShellSnapshot } from "#t3tools/contracts";
8
+ import type { OrchestrationShellSnapshot } from "@t3tools/contracts";
9
9
 
10
10
  import { resolveProjectScope } from "./helpers.ts";
11
11
 
@@ -1,6 +1,6 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import * as Path from "effect/Path";
3
- import type { OrchestrationProjectShell, OrchestrationShellSnapshot } from "#t3tools/contracts";
3
+ import type { OrchestrationProjectShell, OrchestrationShellSnapshot } from "@t3tools/contracts";
4
4
 
5
5
  export type ResolvedProjectScope = {
6
6
  readonly project: OrchestrationProjectShell;
@@ -1,4 +1,4 @@
1
- import type { ServerProvider } from "#t3tools/contracts";
1
+ import type { ServerProvider } from "@t3tools/contracts";
2
2
 
3
3
  export function isSelectableProvider(provider: ServerProvider) {
4
4
  return provider.status === "ready" && provider.models.length > 0;
@@ -1,6 +1,6 @@
1
1
  import "vite-plus/test/config";
2
2
 
3
- import { EventId, TurnId, type OrchestrationThreadActivity } from "#t3tools/contracts";
3
+ import { EventId, TurnId, type OrchestrationThreadActivity } from "@t3tools/contracts";
4
4
  import { describe, expect, it } from "vite-plus/test";
5
5
 
6
6
  import { derivePendingApprovals, derivePendingUserInputs } from "./thread-activities.ts";
@@ -2,7 +2,7 @@ import {
2
2
  ApprovalRequestId,
3
3
  type OrchestrationThreadActivity,
4
4
  type UserInputQuestion,
5
- } from "#t3tools/contracts";
5
+ } from "@t3tools/contracts";
6
6
 
7
7
  export type PendingApproval = {
8
8
  readonly requestId: ApprovalRequestId;
@@ -3,7 +3,7 @@ import "vite-plus/test/config";
3
3
  import { describe, expect, it } from "vite-plus/test";
4
4
  import { fromPartial } from "@total-typescript/shoehorn";
5
5
 
6
- import type { OrchestrationThread } from "#t3tools/contracts";
6
+ import type { OrchestrationThread } from "@t3tools/contracts";
7
7
 
8
8
  import { isThreadActive, isThreadCompleteEnough } from "./thread-lifecycle.ts";
9
9
 
@@ -5,7 +5,7 @@ import {
5
5
  type OrchestrationSession,
6
6
  type OrchestrationThread,
7
7
  type OrchestrationThreadShell,
8
- } from "#t3tools/contracts";
8
+ } from "@t3tools/contracts";
9
9
  import * as Schema from "effect/Schema";
10
10
 
11
11
  type SessionStatusForDelete = OrchestrationSession["status"] | "closed";
@@ -0,0 +1,25 @@
1
+ import { assert } from "@effect/vitest";
2
+ import { assertInstanceOf } from "@effect/vitest/utils";
3
+ import * as Cause from "effect/Cause";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Exit from "effect/Exit";
6
+ import * as Option from "effect/Option";
7
+
8
+ export const expectFailWithMessage = <E extends { readonly message: string }, R>(
9
+ effect: Effect.Effect<unknown, E, R>,
10
+ ErrorClass: new (...args: never) => E,
11
+ message: string,
12
+ ): Effect.Effect<void, never, R> =>
13
+ Effect.gen(function* () {
14
+ const exit = yield* effect.pipe(Effect.exit);
15
+ if (!Exit.isFailure(exit)) {
16
+ return yield* Effect.die("expected failure");
17
+ }
18
+ const error = Cause.findErrorOption(exit.cause);
19
+ if (Option.isNone(error)) {
20
+ return yield* Effect.die("expected failure cause");
21
+ }
22
+ assertInstanceOf(error.value, ErrorClass);
23
+ assert.equal(error.value.message, message);
24
+ return yield* Effect.void;
25
+ });
package/src/index.ts CHANGED
@@ -4,6 +4,6 @@ export type {
4
4
  StartThreadInput,
5
5
  StartThreadPolicy,
6
6
  WaitEvent,
7
+ ApplicationError,
7
8
  } from "./application/index.ts";
8
- export type { ApplicationError } from "./application/index.ts";
9
9
  export { AppLayer, AuthAppLayer } from "./runtime/index.ts";
@@ -2,7 +2,7 @@ import * as Layer from "effect/Layer";
2
2
  import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient";
3
3
  import * as NodeSocket from "@effect/platform-node/NodeSocket";
4
4
 
5
- import { T3CodeRpcLayer } from "./layer.ts";
5
+ import { T3CodeRpcLayer } from "../connection/index.ts";
6
6
 
7
7
  const NodeConnectionPlatformLayer = Layer.mergeAll(
8
8
  NodeHttpClient.layerUndici,
package/src/node/index.ts CHANGED
@@ -1,2 +1 @@
1
- export { T3CodeNodeRpcLayer } from "../connection/node.ts";
2
- export { NodeEnvironmentLive } from "../environment/layer.ts";
1
+ export { T3CodeNodeRpcLayer } from "./connection.ts";
@@ -5,4 +5,3 @@ export {
5
5
  type OrchestrationError,
6
6
  } from "./service.ts";
7
7
  export { makeT3Orchestration, T3OrchestrationLive } from "./layer.ts";
8
- export { T3OrchestrationLayer } from "../runtime/layer.ts";
@@ -10,7 +10,7 @@ import {
10
10
  type ClientOrchestrationCommand,
11
11
  type OrchestrationShellStreamItem,
12
12
  type OrchestrationThreadStreamItem,
13
- } from "#t3tools/contracts";
13
+ } from "@t3tools/contracts";
14
14
 
15
15
  import { RpcError } from "../rpc/error.ts";
16
16
  import { T3RpcOperations } from "../rpc/operation.ts";
@@ -10,7 +10,7 @@ import type {
10
10
  OrchestrationThread,
11
11
  OrchestrationThreadStreamItem,
12
12
  ServerProviders,
13
- } from "#t3tools/contracts";
13
+ } from "@t3tools/contracts";
14
14
 
15
15
  import type { RpcError } from "../rpc/error.ts";
16
16
 
package/src/rpc/error.ts CHANGED
@@ -9,13 +9,13 @@ import {
9
9
  TerminalHistoryError,
10
10
  TerminalNotRunningError,
11
11
  TerminalSessionLookupError,
12
- } from "#t3tools/contracts";
12
+ } from "@t3tools/contracts";
13
13
  import { HttpClientError } from "effect/unstable/http";
14
14
  import { RpcClientError } from "effect/unstable/rpc";
15
15
 
16
16
  import { AuthTransportError } from "../auth/error.ts";
17
17
  import { T3CodeConnectionError } from "../connection/error.ts";
18
- import { UrlError } from "../config/error.ts";
18
+ import { UrlError } from "../config/url/error.ts";
19
19
 
20
20
  const RpcErrorCauseSchema = Schema.Union([
21
21
  RpcClientError.RpcClientError,
package/src/rpc/index.ts CHANGED
@@ -1,6 +1,5 @@
1
- export { RpcError, type OrchestrationError } from "./error.ts";
1
+ export { RpcError } from "./error.ts";
2
2
  export { makeT3RpcLayer, T3RpcLive } from "./layer.ts";
3
3
  export { T3RpcOperations, T3RpcOperationsLive, makeT3RpcOperations } from "./operation.ts";
4
- export type { T3RpcOperationsService } from "./operation.ts";
5
4
  export { T3Rpc } from "./service.ts";
6
- export type { T3RpcService, WsClient } from "./service.ts";
5
+ export type { WsClient } from "./service.ts";
package/src/rpc/layer.ts CHANGED
@@ -12,7 +12,7 @@ import * as Socket from "effect/unstable/socket/Socket";
12
12
 
13
13
  import { T3AuthTransport } from "../auth/transport.ts";
14
14
  import { T3CodeConnectionProvider } from "../connection/service.ts";
15
- import { normalizeHttpBaseUrl, toWebSocketEndpointUrl } from "../config/url.ts";
15
+ import { normalizeHttpBaseUrl, toWebSocketEndpointUrl } from "../config/url/url.ts";
16
16
  import { CliWsRpcGroup } from "./ws-group.ts";
17
17
  import { RpcError } from "./error.ts";
18
18
  import { T3Rpc, type WsClient } from "./service.ts";
@@ -22,7 +22,7 @@ import {
22
22
  WsOrchestrationGetArchivedShellSnapshotRpc,
23
23
  WsOrchestrationSubscribeShellRpc,
24
24
  WsOrchestrationSubscribeThreadRpc,
25
- } from "#t3tools/contracts";
25
+ } from "@t3tools/contracts";
26
26
  import * as Schema from "effect/Schema";
27
27
  import { Rpc, RpcGroup } from "effect/unstable/rpc";
28
28
 
@@ -1,6 +1,8 @@
1
1
  export {
2
2
  AppLayer,
3
3
  AuthAppLayer,
4
+ BaseAppLayer,
5
+ BaseAuthAppLayer,
4
6
  T3AuthLayer,
5
7
  T3AuthPairingLayer,
6
8
  T3AuthTransportLayer,
@@ -9,4 +11,3 @@ export {
9
11
  T3LocalAuthTokenLayer,
10
12
  T3OrchestrationLayer,
11
13
  } from "./layer.ts";
12
- export { NodeEnvironmentLive } from "../environment/layer.ts";
@@ -0,0 +1,32 @@
1
+ import * as Layer from "effect/Layer";
2
+
3
+ import * as CliSelection from "../cli/env/selection-layer.ts";
4
+ import * as CliRuntime from "../cli/runtime/service.ts";
5
+ import * as Config from "../config/config.ts";
6
+ import * as Credential from "../config/credential/service.ts";
7
+ import * as CredentialCipherNode from "../config/credential/cipher-node.ts";
8
+ import { ConfigPlatformLayer } from "../config/platform.test-utils.ts";
9
+ import { t3CliEnvConfigLayer } from "../config/env/env.test-utils.ts";
10
+ import * as Keystore from "../config/keystore/service.test-utils.ts";
11
+
12
+ export function cliConfigRoutingLayerTest(homeDir: string) {
13
+ const cliRuntimeLayer = CliRuntime.CliRuntime.layerTest({ cwd: homeDir });
14
+ const configLayer = t3CliEnvConfigLayer(homeDir, { T3CLI_ENV: "home" });
15
+ const platformEnvLayer = Layer.mergeAll(cliRuntimeLayer, configLayer);
16
+
17
+ return Layer.mergeAll(
18
+ ConfigPlatformLayer,
19
+ platformEnvLayer,
20
+ Config.layer.pipe(
21
+ Layer.provide(Credential.layer),
22
+ Layer.provide(
23
+ Layer.mergeAll(
24
+ platformEnvLayer,
25
+ CliSelection.layer.pipe(Layer.provide(platformEnvLayer)),
26
+ CredentialCipherNode.layerNode,
27
+ Keystore.unavailableKeystoreFactoryLayer,
28
+ ),
29
+ ),
30
+ ),
31
+ );
32
+ }
@@ -0,0 +1,66 @@
1
+ import "vite-plus/test/config";
2
+
3
+ import * as Effect from "effect/Effect";
4
+ import * as Ref from "effect/Ref";
5
+ import * as NodeServices from "@effect/platform-node/NodeServices";
6
+ import { assert, describe, it } from "@effect/vitest";
7
+ import { Command } from "effect/unstable/cli";
8
+
9
+ import { cliEnvironmentSetting } from "../cli/env/flag.ts";
10
+ import type { ResolvedConfig } from "../config/types.ts";
11
+ import { T3Config } from "../config/config.ts";
12
+ import { makeTempHomeScoped } from "../config/temp-home.test-utils.ts";
13
+ import { cliConfigRoutingLayerTest } from "./layer.test-utils.ts";
14
+
15
+ describe("CLI config routing", () => {
16
+ it.effect(
17
+ "routes --environment through Command.run to T3Config.resolve ahead of default and T3CLI_ENV",
18
+ () =>
19
+ Effect.gen(function* () {
20
+ return yield* makeTempHomeScoped("t3cli-runtime-");
21
+ }).pipe(
22
+ Effect.flatMap((homeDir) => {
23
+ const testLayer = cliConfigRoutingLayerTest(homeDir);
24
+ return Effect.gen(function* () {
25
+ const resolvedRef = yield* Ref.make<ResolvedConfig | undefined>(undefined);
26
+ const resolveProbeCommand = Command.make("resolve-probe", {}, () =>
27
+ Effect.gen(function* () {
28
+ const config = yield* T3Config;
29
+ const resolved = yield* config.resolve();
30
+ yield* Ref.set(resolvedRef, resolved);
31
+ }),
32
+ ).pipe(Command.withGlobalFlags([cliEnvironmentSetting]));
33
+ const runResolveProbe = Command.runWith(resolveProbeCommand, { version: "0.0.0-test" });
34
+
35
+ yield* Effect.gen(function* () {
36
+ const config = yield* T3Config;
37
+ yield* config.upsertEnvironment({
38
+ name: "home",
39
+ url: "https://home.example",
40
+ token: "home-token",
41
+ local: false,
42
+ });
43
+ yield* config.upsertEnvironment({
44
+ name: "work",
45
+ url: "https://work.example",
46
+ token: "work-token",
47
+ local: false,
48
+ });
49
+ }).pipe(Effect.provide(testLayer));
50
+
51
+ yield* runResolveProbe(["--environment", "work"]).pipe(Effect.provide(testLayer));
52
+
53
+ const resolved = yield* Ref.get(resolvedRef);
54
+ assert.isDefined(resolved);
55
+ assert.equal(resolved.source, "config");
56
+ if (resolved.source === "config") {
57
+ assert.equal(resolved.environment, "work");
58
+ assert.equal(resolved.token, "work-token");
59
+ }
60
+ });
61
+ }),
62
+ Effect.provide(NodeServices.layer),
63
+ Effect.scoped,
64
+ ),
65
+ );
66
+ });
@@ -10,8 +10,9 @@ import { T3LocalAuthOriginLive } from "../auth/local-origin.ts";
10
10
  import { T3LocalAuthTokenLive } from "../auth/local-token.ts";
11
11
  import { T3AuthPairingLive } from "../auth/pairing.ts";
12
12
  import { T3AuthTransportLive } from "../auth/transport.ts";
13
- import { T3ConfigLive } from "../config/layer.ts";
14
- import { T3Config } from "../config/service.ts";
13
+ import * as Config from "../config/config.ts";
14
+ import * as Credential from "../config/credential/service.ts";
15
+ import * as Selection from "../config/selection/service.ts";
15
16
  import { T3CodeConnectionError } from "../connection/error.ts";
16
17
  import { T3CodeConnectionProvider, makeT3CodeConnectionProvider } from "../connection/service.ts";
17
18
  import { T3OrchestrationLive } from "../orchestration/layer.ts";
@@ -20,6 +21,7 @@ import { T3RpcOperationsLive } from "../rpc/operation.ts";
20
21
  import { NodeSqlClientFactoryLive } from "../sql/node-sqlite-client.ts";
21
22
  import { NodeCliPathLayer } from "../cli-path/layer.ts";
22
23
 
24
+ export const T3ConfigLayer = Config.layer.pipe(Layer.provide(Credential.layer));
23
25
  export const T3AuthTransportLayer = T3AuthTransportLive.pipe(
24
26
  Layer.provide(NodeHttpClient.layerUndici),
25
27
  );
@@ -33,13 +35,13 @@ export const T3LocalAuthLayer = T3LocalAuthLive.pipe(
33
35
  export const T3AuthPairingLayer = T3AuthPairingLive.pipe(Layer.provide(T3AuthTransportLayer));
34
36
  export const T3AuthLayer = T3AuthLive.pipe(
35
37
  Layer.provide(
36
- Layer.mergeAll(T3ConfigLive, T3AuthTransportLayer, T3LocalAuthLayer, T3AuthPairingLayer),
38
+ Layer.mergeAll(T3ConfigLayer, T3AuthTransportLayer, T3LocalAuthLayer, T3AuthPairingLayer),
37
39
  ),
38
40
  );
39
41
  const T3ConfigConnectionProviderLayer = Layer.effect(
40
42
  T3CodeConnectionProvider,
41
43
  Effect.gen(function* () {
42
- const config = yield* T3Config;
44
+ const config = yield* Config.T3Config;
43
45
  return makeT3CodeConnectionProvider(
44
46
  config.resolve().pipe(
45
47
  Effect.map((resolved) => ({
@@ -56,7 +58,7 @@ const T3ConfigConnectionProviderLayer = Layer.effect(
56
58
  ),
57
59
  );
58
60
  }),
59
- ).pipe(Layer.provide(T3ConfigLive));
61
+ ).pipe(Layer.provide(T3ConfigLayer));
60
62
 
61
63
  const T3RpcLayer = T3RpcLive.pipe(
62
64
  Layer.provide(
@@ -73,10 +75,8 @@ const T3ApplicationLayer = T3ApplicationLive.pipe(
73
75
  Layer.provide(Layer.mergeAll(T3RpcOperationsLayer, T3OrchestrationLayer)),
74
76
  );
75
77
 
76
- export const AuthAppLayer = Layer.mergeAll(T3ConfigLive, T3AuthLayer);
77
-
78
- export const AppLayer = Layer.mergeAll(
79
- T3ConfigLive,
78
+ export const BaseAppLayer = Layer.mergeAll(
79
+ T3ConfigLayer,
80
80
  T3AuthLayer,
81
81
  T3RpcLayer,
82
82
  T3RpcOperationsLayer,
@@ -84,3 +84,9 @@ export const AppLayer = Layer.mergeAll(
84
84
  T3ApplicationLayer,
85
85
  NodeCliPathLayer,
86
86
  );
87
+
88
+ export const BaseAuthAppLayer = Layer.mergeAll(T3ConfigLayer, T3AuthLayer);
89
+
90
+ export const AuthAppLayer = BaseAuthAppLayer.pipe(Layer.provideMerge(Selection.layer));
91
+
92
+ export const AppLayer = BaseAppLayer.pipe(Layer.provideMerge(Selection.layer));
@@ -1 +1 @@
1
- export * from "#t3tools/contracts";
1
+ export * from "@t3tools/contracts";
@@ -0,0 +1,11 @@
1
+ declare module "marked-terminal" {
2
+ import type { MarkedExtension } from "marked";
3
+
4
+ export type TerminalRendererOptions = {
5
+ readonly reflowText?: boolean;
6
+ readonly showSectionPrefix?: boolean;
7
+ readonly width?: number;
8
+ };
9
+
10
+ export function markedTerminal(options?: TerminalRendererOptions): MarkedExtension;
11
+ }
package/dist/layout.js DELETED
@@ -1,2 +0,0 @@
1
- import { L as readT3LayoutFromNodeProcess, R as resolveT3BaseDir } from "./shared.js";
2
- export { readT3LayoutFromNodeProcess, resolveT3BaseDir };
package/dist/scope.js DELETED
@@ -1,2 +0,0 @@
1
- import { Fd as resolveWorktreePath, Md as resolveCommandProjectRef, Nd as resolveProjectRef, Pd as resolveThreadId } from "./shared.js";
2
- export { resolveCommandProjectRef, resolveProjectRef, resolveThreadId, resolveWorktreePath };
@@ -1,11 +0,0 @@
1
- import type { EnvironmentShape } from "../environment/service.ts";
2
- export declare const humanJsonFormatChoices: readonly ["auto", "human", "json"];
3
- export declare const humanNdjsonFormatChoices: readonly ["auto", "human", "ndjson"];
4
- export declare const humanJsonNdjsonFormatChoices: readonly ["auto", "human", "json", "ndjson"];
5
- export type HumanJsonFormat = (typeof humanJsonFormatChoices)[number];
6
- export type HumanNdjsonFormat = (typeof humanNdjsonFormatChoices)[number];
7
- export type HumanJsonNdjsonFormat = (typeof humanJsonNdjsonFormatChoices)[number];
8
- export declare function resolveOutputFormat<T extends "json" | "ndjson">(format: "auto" | "human" | T, environment: EnvironmentShape, nonHumanFormat: T): "human" | T;
9
- export declare function canRenderLiveTerminal(environment: EnvironmentShape): boolean;
10
- export declare function isInteractiveHumanTerminal(environment: EnvironmentShape): boolean;
11
- export declare function isAgentEnvironment(environment: EnvironmentShape): boolean;
@@ -1,22 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as FileSystem from "effect/FileSystem";
3
- import * as Layer from "effect/Layer";
4
- import * as Path from "effect/Path";
5
- import { Environment } from "../environment/service.ts";
6
- import { ConfigError } from "./error.ts";
7
- import { T3Config, type StoredConfig } from "./service.ts";
8
- export declare const makeT3Config: () => Effect.Effect<{
9
- readStored: () => Effect.Effect<{
10
- readonly url?: string;
11
- readonly token?: string;
12
- readonly local?: boolean;
13
- }, ConfigError, never>;
14
- writeStored: (config: StoredConfig) => Effect.Effect<void, ConfigError, never>;
15
- resolve: () => Effect.Effect<{
16
- url: string;
17
- token: string;
18
- source: "config" | "env";
19
- local: boolean;
20
- }, import("./error.ts").UrlError | ConfigError, never>;
21
- }, never, Environment | Path.Path | FileSystem.FileSystem>;
22
- export declare const T3ConfigLive: Layer.Layer<T3Config, never, Environment | Path.Path | FileSystem.FileSystem>;
@@ -1,22 +0,0 @@
1
- import * as Context from "effect/Context";
2
- import type * as Effect from "effect/Effect";
3
- import type { ConfigError, ConfigServiceError } from "./error.ts";
4
- export type StoredConfig = {
5
- readonly url?: string;
6
- readonly token?: string;
7
- readonly local?: boolean;
8
- };
9
- export type ResolvedConfig = {
10
- readonly url: string;
11
- readonly token: string;
12
- readonly source: "env" | "config";
13
- readonly local: boolean;
14
- };
15
- declare const T3Config_base: Context.ServiceClass<T3Config, "t3cli/T3Config", {
16
- readonly readStored: () => Effect.Effect<StoredConfig, ConfigError>;
17
- readonly writeStored: (config: StoredConfig) => Effect.Effect<void, ConfigError>;
18
- readonly resolve: () => Effect.Effect<ResolvedConfig, ConfigServiceError>;
19
- }>;
20
- export declare class T3Config extends T3Config_base {
21
- }
22
- export {};
@@ -1,3 +0,0 @@
1
- import * as Layer from "effect/Layer";
2
- import { Environment } from "./service.ts";
3
- export declare const NodeEnvironmentLive: Layer.Layer<Environment, never, never>;
@@ -1,12 +0,0 @@
1
- import * as Context from "effect/Context";
2
- export type EnvironmentShape = {
3
- readonly cwd: string;
4
- readonly homeDir: string;
5
- readonly env: Readonly<Record<string, string | undefined>>;
6
- readonly stdoutIsTTY: boolean;
7
- readonly stderrIsTTY: boolean;
8
- };
9
- declare const Environment_base: Context.ServiceClass<Environment, "t3cli/Environment", EnvironmentShape>;
10
- export declare class Environment extends Environment_base {
11
- }
12
- export {};
@@ -1 +0,0 @@
1
- export { readT3LayoutFromNodeProcess, resolveT3BaseDir, type T3Layout } from "./base-dir.ts";