t3code-cli 0.5.1 → 0.7.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 (112) hide show
  1. package/README.md +41 -16
  2. package/dist/Context-DueQ9iMH.js +4916 -0
  3. package/dist/Path-D8WPdPwR.js +11406 -0
  4. package/dist/Schema-DsQxYh6_.js +13581 -0
  5. package/dist/UrlParams-BA6gBvaY.js +205 -0
  6. package/dist/application.js +2 -0
  7. package/dist/auth.js +3 -0
  8. package/dist/base-dir-R12OMDso.js +20 -0
  9. package/dist/bin.js +236 -13526
  10. package/dist/chunk-B5meny8j.js +36 -0
  11. package/dist/cli.js +2 -0
  12. package/dist/config.js +4 -0
  13. package/dist/connection.js +15 -0
  14. package/dist/contracts.js +1 -0
  15. package/dist/error-B2t1bAP9.js +169 -0
  16. package/dist/error-BHRnjLux.js +15 -0
  17. package/dist/error-jwMt3VoW.js +54 -0
  18. package/dist/flags-CM7_iGdA.js +13371 -0
  19. package/dist/index.js +5 -12
  20. package/dist/layer-CfC5qZol.js +1508 -0
  21. package/dist/layer-DHhKS5jd.js +13 -0
  22. package/dist/layer-DUv99vsS.js +72 -0
  23. package/dist/layer-DvHnKBYj.js +29466 -0
  24. package/dist/layer-MqCKkIGD.js +1206 -0
  25. package/dist/layout.js +2 -0
  26. package/dist/orchestration.js +2 -0
  27. package/dist/rpc.js +2 -0
  28. package/dist/runtime.js +3 -0
  29. package/dist/scope-GycYiJ54.js +29 -0
  30. package/dist/scope.js +2 -0
  31. package/dist/service-CLmRO2Dp.js +8 -0
  32. package/dist/service-ybOWV9pL.js +5 -0
  33. package/dist/src/application/index.d.ts +3 -0
  34. package/dist/src/application/layer.d.ts +4 -4
  35. package/dist/src/application/projects.d.ts +1 -1
  36. package/dist/src/application/service.d.ts +1 -1
  37. package/dist/src/application/threads.d.ts +4 -4
  38. package/dist/src/auth/index.d.ts +10 -0
  39. package/dist/src/auth/local-base-dir.d.ts +5 -7
  40. package/dist/src/auth/local-token.d.ts +2 -2
  41. package/dist/src/auth/type.d.ts +1 -0
  42. package/dist/src/cli/flags.d.ts +15 -0
  43. package/dist/src/cli/index.d.ts +1 -0
  44. package/dist/src/cli/output-format.d.ts +9 -0
  45. package/dist/src/config/index.d.ts +5 -0
  46. package/dist/src/config/layer.d.ts +2 -0
  47. package/dist/src/config/service.d.ts +2 -0
  48. package/dist/src/connection/index.d.ts +5 -0
  49. package/dist/src/contracts/index.d.ts +1 -0
  50. package/dist/src/domain/helpers.d.ts +163 -32
  51. package/dist/src/index.d.ts +4 -28
  52. package/dist/src/layout/base-dir.d.ts +12 -0
  53. package/dist/src/layout/index.d.ts +1 -0
  54. package/dist/src/orchestration/index.d.ts +2 -0
  55. package/dist/src/rpc/index.d.ts +1 -0
  56. package/dist/src/runtime/index.d.ts +2 -0
  57. package/dist/src/runtime/layer.d.ts +11 -0
  58. package/dist/src/scope/index.d.ts +1 -0
  59. package/dist/src/scope/resolve.d.ts +19 -0
  60. package/dist/src/t3tools/index.d.ts +1 -0
  61. package/dist/src-KdbHqrex.js +8874 -0
  62. package/dist/t3tools.js +2 -0
  63. package/dist/transport-D3zBdZ1h.js +539 -0
  64. package/dist/url-SlsaG8nY.js +165 -0
  65. package/package.json +54 -2
  66. package/src/application/index.ts +3 -0
  67. package/src/application/service.ts +1 -1
  68. package/src/application/threads.ts +38 -11
  69. package/src/auth/index.ts +28 -0
  70. package/src/auth/layer.ts +13 -6
  71. package/src/auth/local-base-dir.ts +15 -19
  72. package/src/auth/local-origin.ts +4 -1
  73. package/src/auth/local-token.ts +4 -1
  74. package/src/auth/type.ts +1 -0
  75. package/src/bin.ts +1 -1
  76. package/src/cli/app.ts +6 -6
  77. package/src/cli/auth-format.ts +2 -0
  78. package/src/cli/auth.ts +19 -9
  79. package/src/cli/error.ts +7 -0
  80. package/src/cli/flags.ts +51 -0
  81. package/src/cli/index.ts +10 -0
  82. package/src/cli/{models.ts → model.ts} +5 -4
  83. package/src/cli/{projects.ts → project.ts} +8 -7
  84. package/src/cli/require.ts +31 -0
  85. package/src/cli/{threads.ts → thread.ts} +2 -2
  86. package/src/cli/threads/archive.ts +24 -8
  87. package/src/cli/threads/list.ts +12 -5
  88. package/src/cli/threads/messages.ts +20 -5
  89. package/src/cli/threads/send.ts +27 -23
  90. package/src/cli/threads/start.ts +22 -21
  91. package/src/cli/threads/wait.ts +22 -12
  92. package/src/config/index.ts +5 -0
  93. package/src/config/layer.ts +2 -0
  94. package/src/config/service.ts +2 -0
  95. package/src/connection/index.ts +9 -0
  96. package/src/contracts/index.ts +8 -0
  97. package/src/domain/helpers.test.ts +103 -0
  98. package/src/domain/helpers.ts +112 -16
  99. package/src/index.ts +4 -87
  100. package/src/layout/base-dir.ts +35 -0
  101. package/src/layout/index.ts +1 -0
  102. package/src/orchestration/index.ts +7 -0
  103. package/src/rpc/index.ts +1 -0
  104. package/src/runtime/index.ts +12 -0
  105. package/src/{runtime.ts → runtime/layer.ts} +15 -15
  106. package/src/scope/index.ts +6 -0
  107. package/src/scope/resolve.ts +62 -0
  108. package/src/t3tools/index.ts +1 -0
  109. package/dist/runtime-KQVRmRk-.js +0 -71499
  110. package/dist/src/connection.d.ts +0 -5
  111. package/dist/src/runtime.d.ts +0 -10
  112. package/src/connection.ts +0 -9
@@ -0,0 +1,103 @@
1
+ import "vite-plus/test/config";
2
+
3
+ import * as Effect from "effect/Effect";
4
+ import * as NodeServices from "@effect/platform-node/NodeServices";
5
+ import { assert, describe, it } from "@effect/vitest";
6
+ import { fromPartial } from "@total-typescript/shoehorn";
7
+
8
+ import type { OrchestrationShellSnapshot } from "#t3tools/contracts";
9
+
10
+ import { resolveProjectScope } from "./helpers.ts";
11
+
12
+ describe("resolveProjectScope", () => {
13
+ it.layer(NodeServices.layer)("resolveProjectScope", (t) => {
14
+ t.effect("resolves by id first (even if ref not absolute)", () =>
15
+ Effect.gen(function* () {
16
+ const snapshot: OrchestrationShellSnapshot = fromPartial({
17
+ projects: [{ id: "proj-1", workspaceRoot: "/workspace" }],
18
+ threads: [],
19
+ });
20
+
21
+ const scope = yield* resolveProjectScope(snapshot, { ref: "proj-1" });
22
+ assert.equal(scope?.project.id, "proj-1");
23
+ assert.equal(scope?.inferredWorktreePath, undefined);
24
+ }),
25
+ );
26
+
27
+ t.effect("returns undefined for non-absolute path refs", () =>
28
+ Effect.gen(function* () {
29
+ const snapshot: OrchestrationShellSnapshot = fromPartial({
30
+ projects: [{ id: "proj-1", workspaceRoot: "/workspace" }],
31
+ threads: [],
32
+ });
33
+
34
+ const scope = yield* resolveProjectScope(snapshot, { ref: "workspace/subdir" });
35
+ assert.equal(scope, undefined);
36
+ }),
37
+ );
38
+
39
+ t.effect("prefers longest matching workspaceRoot", () =>
40
+ Effect.gen(function* () {
41
+ const snapshot: OrchestrationShellSnapshot = fromPartial({
42
+ projects: [
43
+ { id: "proj-a", workspaceRoot: "/workspace" },
44
+ { id: "proj-b", workspaceRoot: "/workspace/sub" },
45
+ ],
46
+ threads: [],
47
+ });
48
+
49
+ const scope = yield* resolveProjectScope(snapshot, { ref: "/workspace/sub/deep" });
50
+ assert.equal(scope?.project.id, "proj-b");
51
+ assert.equal(scope?.inferredWorktreePath, "/workspace/sub/deep");
52
+ }),
53
+ );
54
+
55
+ t.effect("does not infer worktree when ref equals workspaceRoot", () =>
56
+ Effect.gen(function* () {
57
+ const snapshot: OrchestrationShellSnapshot = fromPartial({
58
+ projects: [
59
+ { id: "proj-a", workspaceRoot: "/workspace" },
60
+ { id: "proj-b", workspaceRoot: "/workspace/sub" },
61
+ ],
62
+ threads: [],
63
+ });
64
+
65
+ const scope = yield* resolveProjectScope(snapshot, { ref: "/workspace/sub" });
66
+ assert.equal(scope?.project.id, "proj-b");
67
+ assert.equal(scope?.inferredWorktreePath, undefined);
68
+ }),
69
+ );
70
+
71
+ t.effect("prefers worktree candidate over project candidate for same match path", () =>
72
+ Effect.gen(function* () {
73
+ const snapshot: OrchestrationShellSnapshot = fromPartial({
74
+ projects: [
75
+ { id: "proj-a", workspaceRoot: "/workspace" },
76
+ { id: "proj-b", workspaceRoot: "/workspace/proj" },
77
+ ],
78
+ threads: [{ projectId: "proj-a", worktreePath: "/workspace/proj" }],
79
+ });
80
+
81
+ const scope = yield* resolveProjectScope(snapshot, { ref: "/workspace/proj" });
82
+ assert.equal(scope?.project.id, "proj-a");
83
+ assert.equal(scope?.inferredWorktreePath, "/workspace/proj");
84
+ }),
85
+ );
86
+
87
+ t.effect("prefers longest matching worktree path", () =>
88
+ Effect.gen(function* () {
89
+ const snapshot: OrchestrationShellSnapshot = fromPartial({
90
+ projects: [{ id: "proj-a", workspaceRoot: "/workspace" }],
91
+ threads: [
92
+ { projectId: "proj-a", worktreePath: "/workspace/proj" },
93
+ { projectId: "proj-a", worktreePath: "/workspace/proj/deep" },
94
+ ],
95
+ });
96
+
97
+ const scope = yield* resolveProjectScope(snapshot, { ref: "/workspace/proj/deep/child" });
98
+ assert.equal(scope?.project.id, "proj-a");
99
+ assert.equal(scope?.inferredWorktreePath, "/workspace/proj/deep/child");
100
+ }),
101
+ );
102
+ });
103
+ });
@@ -1,27 +1,31 @@
1
- import type * as Path from "effect/Path";
1
+ import * as Effect from "effect/Effect";
2
+ import * as Path from "effect/Path";
2
3
  import type { OrchestrationProjectShell, OrchestrationShellSnapshot } from "#t3tools/contracts";
3
4
 
4
- import { ProjectLookupError } from "./error.ts";
5
+ export type ResolvedProjectScope = {
6
+ readonly project: OrchestrationProjectShell;
7
+ readonly inferredWorktreePath?: string;
8
+ };
5
9
 
6
- export function resolveProject(
10
+ export const resolveProjectScope = Effect.fn("resolveProjectScope")(function* (
7
11
  snapshot: OrchestrationShellSnapshot,
8
- ref: string,
9
- path: Path.Path,
10
- cwd: string,
12
+ input: {
13
+ readonly ref: string;
14
+ },
11
15
  ) {
12
- const byId = findProjectById(snapshot, ref);
16
+ const path = yield* Path.Path;
17
+
18
+ const byId = findProjectById(snapshot, input.ref);
13
19
  if (byId !== null) {
14
- return byId;
20
+ return { project: byId };
15
21
  }
16
- const absolute = path.resolve(cwd, ref);
17
- const byPath = snapshot.projects.find(
18
- (project) => path.resolve(cwd, project.workspaceRoot) === absolute,
19
- );
20
- if (byPath !== undefined) {
21
- return byPath;
22
+
23
+ if (!path.isAbsolute(input.ref)) {
24
+ return undefined;
22
25
  }
23
- throw new ProjectLookupError({ message: `project not found: ${ref}`, ref });
24
- }
26
+
27
+ return yield* findProjectByPathPriority(snapshot, path.normalize(input.ref));
28
+ });
25
29
 
26
30
  export function findProjectById(
27
31
  snapshot: OrchestrationShellSnapshot,
@@ -29,3 +33,95 @@ export function findProjectById(
29
33
  ): OrchestrationProjectShell | null {
30
34
  return snapshot.projects.find((project) => project.id === projectId) ?? null;
31
35
  }
36
+
37
+ const isDescendantPath = Effect.fn("isDescendantPath")(function* (parent: string, child: string) {
38
+ const path = yield* Path.Path;
39
+ if (child === parent) {
40
+ return true;
41
+ }
42
+ const relative = path.relative(parent, child);
43
+ return relative.length > 0 && !relative.startsWith("..") && !path.isAbsolute(relative);
44
+ });
45
+
46
+ const findProjectByPathPriority = Effect.fn("findProjectByPathPriority")(function* (
47
+ snapshot: OrchestrationShellSnapshot,
48
+ absolutePath: string,
49
+ ) {
50
+ const path = yield* Path.Path;
51
+ const projectsById = new Map(snapshot.projects.map((project) => [project.id, project]));
52
+ const workspaceRoots = new Map(
53
+ snapshot.projects.map(
54
+ (project) => [project.id, path.normalize(project.workspaceRoot)] as const,
55
+ ),
56
+ );
57
+ const candidates: Array<{
58
+ readonly project: OrchestrationProjectShell;
59
+ readonly matchPath: string;
60
+ readonly workspaceRoot: string;
61
+ readonly source: "worktree" | "project";
62
+ }> = [];
63
+
64
+ for (const thread of snapshot.threads) {
65
+ if (thread.worktreePath === null) {
66
+ continue;
67
+ }
68
+ const project = projectsById.get(thread.projectId);
69
+ if (project === undefined) {
70
+ continue;
71
+ }
72
+ const workspaceRoot = workspaceRoots.get(thread.projectId);
73
+ if (workspaceRoot === undefined) {
74
+ continue;
75
+ }
76
+ const matchPath = path.normalize(thread.worktreePath);
77
+ if (!(yield* isDescendantPath(matchPath, absolutePath))) {
78
+ continue;
79
+ }
80
+ candidates.push({
81
+ project,
82
+ matchPath,
83
+ workspaceRoot,
84
+ source: "worktree",
85
+ });
86
+ }
87
+
88
+ for (const project of snapshot.projects) {
89
+ const workspaceRoot = workspaceRoots.get(project.id);
90
+ if (workspaceRoot === undefined) {
91
+ continue;
92
+ }
93
+ if (!(yield* isDescendantPath(workspaceRoot, absolutePath))) {
94
+ continue;
95
+ }
96
+ candidates.push({
97
+ project,
98
+ matchPath: workspaceRoot,
99
+ workspaceRoot,
100
+ source: "project",
101
+ });
102
+ }
103
+
104
+ if (candidates.length === 0) {
105
+ return undefined;
106
+ }
107
+
108
+ candidates.sort((left, right) => {
109
+ if (left.matchPath.length !== right.matchPath.length) {
110
+ return right.matchPath.length - left.matchPath.length;
111
+ }
112
+ if (left.source === right.source) {
113
+ return 0;
114
+ }
115
+ return left.source === "worktree" ? -1 : 1;
116
+ });
117
+
118
+ const best = candidates[0]!;
119
+ if (absolutePath === best.matchPath) {
120
+ if (best.source === "worktree" && best.matchPath !== best.workspaceRoot) {
121
+ return { project: best.project, inferredWorktreePath: best.matchPath };
122
+ }
123
+ return { project: best.project };
124
+ }
125
+
126
+ return { project: best.project, inferredWorktreePath: absolutePath };
127
+ });
package/src/index.ts CHANGED
@@ -1,92 +1,9 @@
1
- export { T3Application } from "./application/service.ts";
1
+ export { T3Application } from "./application/index.ts";
2
2
  export type {
3
3
  SendThreadInput,
4
4
  StartThreadInput,
5
5
  StartThreadPolicy,
6
6
  WaitEvent,
7
- } from "./application/service.ts";
8
- export type { ApplicationError } from "./application/error.ts";
9
- export { T3Auth } from "./auth/service.ts";
10
- export { T3AuthLive, makeT3Auth } from "./auth/layer.ts";
11
- export { T3LocalAuth, T3LocalAuthLive, makeT3LocalAuth } from "./auth/local.ts";
12
- export {
13
- T3LocalAuthOrigin,
14
- T3LocalAuthOriginLive,
15
- makeT3LocalAuthOrigin,
16
- } from "./auth/local-origin.ts";
17
- export {
18
- T3LocalAuthToken,
19
- T3LocalAuthTokenLive,
20
- makeT3LocalAuthToken,
21
- } from "./auth/local-token.ts";
22
- export {
23
- T3AuthPairing,
24
- T3AuthPairingLive,
25
- makeT3AuthPairing,
26
- parsePairingUrl,
27
- } from "./auth/pairing.ts";
28
- export {
29
- AuthConfigError,
30
- AuthLocalDatabaseError,
31
- AuthLocalError,
32
- AuthLocalSecretError,
33
- AuthLocalSigningError,
34
- AuthPairingUrlError,
35
- AuthTransportError,
36
- } from "./auth/error.ts";
37
- export type { AuthError } from "./auth/error.ts";
38
- export type { AuthSessionState, AuthWebSocketTicketResult } from "./auth/schema.ts";
39
- export type {
40
- AuthConfigInput,
41
- AuthSessionRole,
42
- LocalAuthInput,
43
- LocalAuthOriginInput,
44
- LocalAuthResult,
45
- LocalAuthTokenInput,
46
- LocalAuthTokenResult,
47
- PairingUrl,
48
- PairResult,
49
- } from "./auth/type.ts";
50
- export { T3Config } from "./config/service.ts";
51
- export type { ResolvedConfig, StoredConfig } from "./config/service.ts";
52
- export { T3ConfigLive, makeT3Config } from "./config/layer.ts";
53
- export { ConfigError, UrlError } from "./config/error.ts";
54
- export type { ConfigServiceError } from "./config/error.ts";
55
- export {
56
- makeT3CodeConnectionProvider,
57
- makeT3CodeRpcLayer,
58
- T3CodeConnectionProvider,
59
- T3CodeConnectionProviderLive,
60
- T3CodeNodeRpcLayer,
61
- T3CodeRpcLayer,
62
- T3CodeConnectionError,
63
- } from "./connection.ts";
64
- export type { T3CodeAuth, T3CodeConnection, T3CodeOrigin } from "./connection.ts";
65
- export { Environment } from "./environment/service.ts";
66
- export type { EnvironmentShape } from "./environment/service.ts";
67
- export { NodeEnvironmentLive } from "./environment/layer.ts";
68
- export {
69
- AppLayer,
70
- AuthAppLayer,
71
- T3AuthLayer,
72
- T3AuthPairingLayer,
73
- T3AuthTransportLayer,
74
- T3LocalAuthLayer,
75
- T3LocalAuthOriginLayer,
76
- T3LocalAuthTokenLayer,
77
- } from "./runtime.ts";
78
- export { SqlClientFactory } from "./sql/service.ts";
79
- export type { SqlClientFactoryShape, SqliteClientConfig } from "./sql/service.ts";
80
- export {
81
- NodeSqlClientFactoryLive,
82
- NodeSqliteClientLive,
83
- makeNodeSqliteClient,
84
- } from "./sql/node-sqlite-client.ts";
85
- export type {
86
- OrchestrationMessage,
87
- OrchestrationProjectShell,
88
- OrchestrationShellSnapshot,
89
- OrchestrationThread,
90
- OrchestrationThreadShell,
91
- ServerProvider,
92
- } from "#t3tools/contracts";
7
+ } from "./application/index.ts";
8
+ export type { ApplicationError } from "./application/index.ts";
9
+ export { AppLayer, AuthAppLayer } from "./runtime/index.ts";
@@ -0,0 +1,35 @@
1
+ import { homedir } from "node:os";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Path from "effect/Path";
4
+
5
+ export type T3Layout = {
6
+ readonly cwd: string;
7
+ readonly homeDir: string;
8
+ readonly t3codeHome?: string | undefined;
9
+ };
10
+
11
+ export function readT3LayoutFromNodeProcess(): T3Layout {
12
+ return {
13
+ cwd: process.cwd(),
14
+ homeDir: homedir(),
15
+ t3codeHome: process.env["T3CODE_HOME"],
16
+ };
17
+ }
18
+
19
+ export const resolveT3BaseDir = Effect.fn("resolveT3BaseDir")(function* (input: {
20
+ readonly layout: T3Layout;
21
+ readonly baseDir?: string | undefined;
22
+ }) {
23
+ const path = yield* Path.Path;
24
+ const raw = input.baseDir ?? input.layout.t3codeHome;
25
+ if (raw === undefined || raw.length === 0) {
26
+ return path.join(input.layout.homeDir, ".t3");
27
+ }
28
+ if (raw === "~") {
29
+ return input.layout.homeDir;
30
+ }
31
+ if (raw.startsWith("~/") || raw.startsWith("~\\")) {
32
+ return path.join(input.layout.homeDir, raw.slice(2));
33
+ }
34
+ return path.resolve(input.layout.cwd, raw);
35
+ });
@@ -0,0 +1 @@
1
+ export { readT3LayoutFromNodeProcess, resolveT3BaseDir, type T3Layout } from "./base-dir.ts";
@@ -0,0 +1,7 @@
1
+ export {
2
+ T3Orchestration,
3
+ type OpenThread,
4
+ type Orchestration,
5
+ type OrchestrationError,
6
+ } from "./service.ts";
7
+ export { T3OrchestrationLayer } from "../runtime/layer.ts";
@@ -0,0 +1 @@
1
+ export { RpcError, type OrchestrationError } from "./error.ts";
@@ -0,0 +1,12 @@
1
+ export {
2
+ AppLayer,
3
+ AuthAppLayer,
4
+ T3AuthLayer,
5
+ T3AuthPairingLayer,
6
+ T3AuthTransportLayer,
7
+ T3LocalAuthLayer,
8
+ T3LocalAuthOriginLayer,
9
+ T3LocalAuthTokenLayer,
10
+ T3OrchestrationLayer,
11
+ } from "./layer.ts";
12
+ export { NodeEnvironmentLive } from "../environment/layer.ts";
@@ -3,20 +3,20 @@ import * as Layer from "effect/Layer";
3
3
  import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient";
4
4
  import * as NodeSocket from "@effect/platform-node/NodeSocket";
5
5
 
6
- import { T3AuthLive } from "./auth/layer.ts";
7
- import { T3LocalAuthLive } from "./auth/local.ts";
8
- import { T3LocalAuthOriginLive } from "./auth/local-origin.ts";
9
- import { T3LocalAuthTokenLive } from "./auth/local-token.ts";
10
- import { T3AuthPairingLive } from "./auth/pairing.ts";
11
- import { T3AuthTransportLive } from "./auth/transport.ts";
12
- import { T3CodeConnectionError } from "./connection/error.ts";
13
- import { T3CodeConnectionProvider, makeT3CodeConnectionProvider } from "./connection/service.ts";
14
- import { T3ConfigLive } from "./config/layer.ts";
15
- import { T3Config } from "./config/service.ts";
16
- import { T3ApplicationLive } from "./application/layer.ts";
17
- import { T3OrchestrationLive } from "./orchestration/layer.ts";
18
- import { T3RpcLive } from "./rpc/layer.ts";
19
- import { NodeSqlClientFactoryLive } from "./sql/node-sqlite-client.ts";
6
+ import { T3ApplicationLive } from "../application/layer.ts";
7
+ import { T3AuthLive } from "../auth/layer.ts";
8
+ import { T3LocalAuthLive } from "../auth/local.ts";
9
+ import { T3LocalAuthOriginLive } from "../auth/local-origin.ts";
10
+ import { T3LocalAuthTokenLive } from "../auth/local-token.ts";
11
+ import { T3AuthPairingLive } from "../auth/pairing.ts";
12
+ import { T3AuthTransportLive } from "../auth/transport.ts";
13
+ import { T3ConfigLive } from "../config/layer.ts";
14
+ import { T3Config } from "../config/service.ts";
15
+ import { T3CodeConnectionError } from "../connection/error.ts";
16
+ import { T3CodeConnectionProvider, makeT3CodeConnectionProvider } from "../connection/service.ts";
17
+ import { T3OrchestrationLive } from "../orchestration/layer.ts";
18
+ import { T3RpcLive } from "../rpc/layer.ts";
19
+ import { NodeSqlClientFactoryLive } from "../sql/node-sqlite-client.ts";
20
20
 
21
21
  export const T3AuthTransportLayer = T3AuthTransportLive.pipe(
22
22
  Layer.provide(NodeHttpClient.layerUndici),
@@ -65,7 +65,7 @@ const T3RpcLayer = T3RpcLive.pipe(
65
65
  ),
66
66
  ),
67
67
  );
68
- const T3OrchestrationLayer = T3OrchestrationLive.pipe(Layer.provide(T3RpcLayer));
68
+ export const T3OrchestrationLayer = T3OrchestrationLive.pipe(Layer.provide(T3RpcLayer));
69
69
  const T3ApplicationLayer = T3ApplicationLive.pipe(Layer.provide(T3OrchestrationLayer));
70
70
 
71
71
  export const AuthAppLayer = Layer.mergeAll(T3ConfigLive, T3AuthLayer);
@@ -0,0 +1,6 @@
1
+ export {
2
+ resolveCommandProjectRef,
3
+ resolveProjectRef,
4
+ resolveThreadId,
5
+ resolveWorktreePath,
6
+ } from "./resolve.ts";
@@ -0,0 +1,62 @@
1
+ export function resolveProjectRef(input: {
2
+ readonly value: string | undefined;
3
+ readonly env: Readonly<Record<string, string | undefined>>;
4
+ }): string | undefined {
5
+ if (input.value !== undefined && input.value.length > 0) {
6
+ return input.value;
7
+ }
8
+ const fromRoot = input.env.T3CODE_PROJECT_ROOT;
9
+ if (fromRoot !== undefined && fromRoot.length > 0) {
10
+ return fromRoot;
11
+ }
12
+ const fromId = input.env.T3CODE_PROJECT_ID;
13
+ if (fromId !== undefined && fromId.length > 0) {
14
+ return fromId;
15
+ }
16
+ return undefined;
17
+ }
18
+
19
+ export function resolveCommandProjectRef(input: {
20
+ readonly value: string | undefined;
21
+ readonly env: Readonly<Record<string, string | undefined>>;
22
+ readonly cwd: string;
23
+ readonly isLocal?: boolean;
24
+ }): string | undefined {
25
+ const explicit = resolveProjectRef({ value: input.value, env: input.env });
26
+ if (explicit !== undefined) {
27
+ return explicit;
28
+ }
29
+ if (input.isLocal ?? false) {
30
+ return input.cwd;
31
+ }
32
+ return undefined;
33
+ }
34
+
35
+ export function resolveWorktreePath(input: {
36
+ readonly value: string | undefined;
37
+ readonly env: Readonly<Record<string, string | undefined>>;
38
+ readonly inferred?: string;
39
+ }): string | undefined {
40
+ if (input.value !== undefined && input.value.length > 0) {
41
+ return input.value;
42
+ }
43
+ const fromEnv = input.env.T3CODE_WORKTREE_PATH;
44
+ if (fromEnv !== undefined && fromEnv.length > 0) {
45
+ return fromEnv;
46
+ }
47
+ return input.inferred;
48
+ }
49
+
50
+ export function resolveThreadId(input: {
51
+ readonly value: string | undefined;
52
+ readonly env: Readonly<Record<string, string | undefined>>;
53
+ }): string | undefined {
54
+ if (input.value !== undefined && input.value.length > 0) {
55
+ return input.value;
56
+ }
57
+ const fromEnv = input.env.T3CODE_THREAD_ID;
58
+ if (fromEnv !== undefined && fromEnv.length > 0) {
59
+ return fromEnv;
60
+ }
61
+ return undefined;
62
+ }
@@ -0,0 +1 @@
1
+ export * from "#t3tools/contracts";