t3code-cli 0.5.1 → 0.6.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.
- package/README.md +41 -16
- package/dist/Context-DueQ9iMH.js +4916 -0
- package/dist/Path-D8WPdPwR.js +11406 -0
- package/dist/Schema-DsQxYh6_.js +13581 -0
- package/dist/UrlParams-BA6gBvaY.js +205 -0
- package/dist/application.js +2 -0
- package/dist/auth.js +3 -0
- package/dist/base-dir-R12OMDso.js +20 -0
- package/dist/bin.js +236 -13526
- package/dist/chunk-B5meny8j.js +36 -0
- package/dist/cli.js +2 -0
- package/dist/config.js +4 -0
- package/dist/connection.js +15 -0
- package/dist/contracts.js +1 -0
- package/dist/error-B2t1bAP9.js +169 -0
- package/dist/error-BHRnjLux.js +15 -0
- package/dist/error-jwMt3VoW.js +54 -0
- package/dist/flags-CM7_iGdA.js +13371 -0
- package/dist/index.js +5 -12
- package/dist/layer-CfC5qZol.js +1508 -0
- package/dist/layer-DHhKS5jd.js +13 -0
- package/dist/layer-DIg0RxSO.js +1217 -0
- package/dist/layer-DUv99vsS.js +72 -0
- package/dist/layer-DvHnKBYj.js +29466 -0
- package/dist/layout.js +2 -0
- package/dist/orchestration.js +2 -0
- package/dist/rpc.js +2 -0
- package/dist/runtime.js +3 -0
- package/dist/scope-GycYiJ54.js +29 -0
- package/dist/scope.js +2 -0
- package/dist/service-CLmRO2Dp.js +8 -0
- package/dist/service-ybOWV9pL.js +5 -0
- package/dist/src/application/index.d.ts +3 -0
- package/dist/src/application/layer.d.ts +4 -4
- package/dist/src/application/projects.d.ts +1 -1
- package/dist/src/application/service.d.ts +1 -1
- package/dist/src/application/threads.d.ts +4 -4
- package/dist/src/auth/index.d.ts +10 -0
- package/dist/src/auth/local-base-dir.d.ts +5 -7
- package/dist/src/auth/local-token.d.ts +2 -2
- package/dist/src/auth/type.d.ts +1 -0
- package/dist/src/cli/flags.d.ts +15 -0
- package/dist/src/cli/index.d.ts +1 -0
- package/dist/src/cli/output-format.d.ts +9 -0
- package/dist/src/config/index.d.ts +5 -0
- package/dist/src/config/layer.d.ts +2 -0
- package/dist/src/config/service.d.ts +2 -0
- package/dist/src/connection/index.d.ts +5 -0
- package/dist/src/contracts/index.d.ts +1 -0
- package/dist/src/domain/helpers.d.ts +164 -32
- package/dist/src/index.d.ts +4 -28
- package/dist/src/layout/base-dir.d.ts +12 -0
- package/dist/src/layout/index.d.ts +1 -0
- package/dist/src/orchestration/index.d.ts +2 -0
- package/dist/src/rpc/index.d.ts +1 -0
- package/dist/src/runtime/index.d.ts +2 -0
- package/dist/src/runtime/layer.d.ts +11 -0
- package/dist/src/scope/index.d.ts +1 -0
- package/dist/src/scope/resolve.d.ts +19 -0
- package/dist/src/t3tools/index.d.ts +1 -0
- package/dist/src-KdbHqrex.js +8874 -0
- package/dist/t3tools.js +2 -0
- package/dist/transport-D3zBdZ1h.js +539 -0
- package/dist/url-SlsaG8nY.js +165 -0
- package/package.json +50 -1
- package/src/application/index.ts +3 -0
- package/src/application/service.ts +1 -1
- package/src/application/threads.ts +40 -11
- package/src/auth/index.ts +28 -0
- package/src/auth/layer.ts +13 -6
- package/src/auth/local-base-dir.ts +15 -19
- package/src/auth/local-origin.ts +4 -1
- package/src/auth/local-token.ts +4 -1
- package/src/auth/type.ts +1 -0
- package/src/bin.ts +1 -1
- package/src/cli/app.ts +6 -6
- package/src/cli/auth-format.ts +2 -0
- package/src/cli/auth.ts +19 -9
- package/src/cli/error.ts +7 -0
- package/src/cli/flags.ts +51 -0
- package/src/cli/index.ts +10 -0
- package/src/cli/{models.ts → model.ts} +5 -4
- package/src/cli/{projects.ts → project.ts} +8 -7
- package/src/cli/require.ts +31 -0
- package/src/cli/{threads.ts → thread.ts} +2 -2
- package/src/cli/threads/archive.ts +24 -8
- package/src/cli/threads/list.ts +12 -5
- package/src/cli/threads/messages.ts +20 -5
- package/src/cli/threads/send.ts +27 -23
- package/src/cli/threads/start.ts +22 -21
- package/src/cli/threads/wait.ts +22 -12
- package/src/config/index.ts +5 -0
- package/src/config/layer.ts +2 -0
- package/src/config/service.ts +2 -0
- package/src/connection/index.ts +9 -0
- package/src/contracts/index.ts +8 -0
- package/src/domain/helpers.ts +136 -16
- package/src/index.ts +4 -87
- package/src/layout/base-dir.ts +35 -0
- package/src/layout/index.ts +1 -0
- package/src/orchestration/index.ts +7 -0
- package/src/rpc/index.ts +1 -0
- package/src/runtime/index.ts +12 -0
- package/src/{runtime.ts → runtime/layer.ts} +15 -15
- package/src/scope/index.ts +6 -0
- package/src/scope/resolve.ts +62 -0
- package/src/t3tools/index.ts +1 -0
- package/dist/runtime-KQVRmRk-.js +0 -71499
- package/dist/src/connection.d.ts +0 -5
- package/dist/src/runtime.d.ts +0 -10
- package/src/connection.ts +0 -9
package/src/domain/helpers.ts
CHANGED
|
@@ -1,27 +1,38 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
5
|
+
export type ResolvedProjectScope = {
|
|
6
|
+
readonly project: OrchestrationProjectShell;
|
|
7
|
+
readonly inferredWorktreePath?: string;
|
|
8
|
+
};
|
|
5
9
|
|
|
6
|
-
export function
|
|
10
|
+
export const resolveProjectScope = Effect.fn("resolveProjectScope")(function* (
|
|
7
11
|
snapshot: OrchestrationShellSnapshot,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
input: {
|
|
13
|
+
readonly ref: string;
|
|
14
|
+
readonly cwd: string;
|
|
15
|
+
},
|
|
11
16
|
) {
|
|
12
|
-
const
|
|
17
|
+
const absoluteRef = yield* resolveAbsolutePath(input.ref, input.cwd);
|
|
18
|
+
|
|
19
|
+
const byId = findProjectById(snapshot, input.ref);
|
|
13
20
|
if (byId !== null) {
|
|
14
|
-
return byId;
|
|
21
|
+
return { project: byId };
|
|
15
22
|
}
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (byPath !== undefined) {
|
|
21
|
-
return byPath;
|
|
23
|
+
|
|
24
|
+
const byExactPath = yield* findProjectByWorkspaceRoot(snapshot, absoluteRef, input.cwd);
|
|
25
|
+
if (byExactPath !== undefined) {
|
|
26
|
+
return { project: byExactPath };
|
|
22
27
|
}
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
|
|
29
|
+
const byAncestor = yield* findProjectByAncestorPath(snapshot, absoluteRef, input.cwd);
|
|
30
|
+
if (byAncestor !== undefined) {
|
|
31
|
+
return byAncestor;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return yield* findProjectByKnownWorktreePath(snapshot, absoluteRef, input.cwd);
|
|
35
|
+
});
|
|
25
36
|
|
|
26
37
|
export function findProjectById(
|
|
27
38
|
snapshot: OrchestrationShellSnapshot,
|
|
@@ -29,3 +40,112 @@ export function findProjectById(
|
|
|
29
40
|
): OrchestrationProjectShell | null {
|
|
30
41
|
return snapshot.projects.find((project) => project.id === projectId) ?? null;
|
|
31
42
|
}
|
|
43
|
+
|
|
44
|
+
const resolveAbsolutePath = Effect.fn("resolveAbsolutePath")(function* (ref: string, cwd: string) {
|
|
45
|
+
const path = yield* Path.Path;
|
|
46
|
+
return path.isAbsolute(ref) ? path.normalize(ref) : path.normalize(path.resolve(cwd, ref));
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const isDescendantPath = Effect.fn("isDescendantPath")(function* (parent: string, child: string) {
|
|
50
|
+
const path = yield* Path.Path;
|
|
51
|
+
if (child === parent) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
const relative = path.relative(parent, child);
|
|
55
|
+
return relative.length > 0 && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const findProjectByWorkspaceRoot = Effect.fn("findProjectByWorkspaceRoot")(function* (
|
|
59
|
+
snapshot: OrchestrationShellSnapshot,
|
|
60
|
+
absolutePath: string,
|
|
61
|
+
cwd: string,
|
|
62
|
+
) {
|
|
63
|
+
for (const project of snapshot.projects) {
|
|
64
|
+
const workspaceRoot = yield* resolveAbsolutePath(project.workspaceRoot, cwd);
|
|
65
|
+
if (workspaceRoot === absolutePath) {
|
|
66
|
+
return project;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const findProjectByAncestorPath = Effect.fn("findProjectByAncestorPath")(function* (
|
|
73
|
+
snapshot: OrchestrationShellSnapshot,
|
|
74
|
+
absolutePath: string,
|
|
75
|
+
cwd: string,
|
|
76
|
+
) {
|
|
77
|
+
let bestProject: OrchestrationProjectShell | undefined;
|
|
78
|
+
let bestWorkspaceRoot = "";
|
|
79
|
+
|
|
80
|
+
for (const project of snapshot.projects) {
|
|
81
|
+
const workspaceRoot = yield* resolveAbsolutePath(project.workspaceRoot, cwd);
|
|
82
|
+
if (!(yield* isDescendantPath(workspaceRoot, absolutePath))) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (workspaceRoot.length > bestWorkspaceRoot.length) {
|
|
86
|
+
bestProject = project;
|
|
87
|
+
bestWorkspaceRoot = workspaceRoot;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (bestProject === undefined) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (absolutePath === bestWorkspaceRoot) {
|
|
96
|
+
return { project: bestProject };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
project: bestProject,
|
|
101
|
+
inferredWorktreePath: absolutePath,
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const findProjectByKnownWorktreePath = Effect.fn("findProjectByKnownWorktreePath")(function* (
|
|
106
|
+
snapshot: OrchestrationShellSnapshot,
|
|
107
|
+
absolutePath: string,
|
|
108
|
+
cwd: string,
|
|
109
|
+
) {
|
|
110
|
+
const projectsById = new Map(snapshot.projects.map((project) => [project.id, project]));
|
|
111
|
+
let bestProject: OrchestrationProjectShell | undefined;
|
|
112
|
+
let bestKnownPath = "";
|
|
113
|
+
|
|
114
|
+
for (const thread of snapshot.threads) {
|
|
115
|
+
if (thread.worktreePath === null) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const project = projectsById.get(thread.projectId);
|
|
119
|
+
if (project === undefined) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const knownPath = yield* resolveAbsolutePath(thread.worktreePath, cwd);
|
|
123
|
+
if (!(yield* isDescendantPath(knownPath, absolutePath))) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (knownPath.length > bestKnownPath.length) {
|
|
127
|
+
bestProject = project;
|
|
128
|
+
bestKnownPath = knownPath;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (bestProject === undefined) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const workspaceRoot = yield* resolveAbsolutePath(bestProject.workspaceRoot, cwd);
|
|
137
|
+
if (absolutePath === workspaceRoot) {
|
|
138
|
+
return { project: bestProject };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (absolutePath === bestKnownPath) {
|
|
142
|
+
return bestKnownPath === workspaceRoot
|
|
143
|
+
? { project: bestProject }
|
|
144
|
+
: { project: bestProject, inferredWorktreePath: bestKnownPath };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
project: bestProject,
|
|
149
|
+
inferredWorktreePath: absolutePath,
|
|
150
|
+
};
|
|
151
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -1,92 +1,9 @@
|
|
|
1
|
-
export { T3Application } from "./application/
|
|
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/
|
|
8
|
-
export type { ApplicationError } from "./application/
|
|
9
|
-
export {
|
|
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";
|
package/src/rpc/index.ts
ADDED
|
@@ -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 {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { T3OrchestrationLive } from "
|
|
18
|
-
import { T3RpcLive } from "
|
|
19
|
-
import { NodeSqlClientFactoryLive } from "
|
|
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,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";
|