@prover-coder-ai/docker-git 1.0.19 → 1.0.21

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.
@@ -2,6 +2,7 @@ import { describe, expect, it } from "@effect/vitest"
2
2
  import { Effect, Either } from "effect"
3
3
 
4
4
  import { type Command, defaultTemplateConfig } from "@effect-template/lib/core/domain"
5
+ import { expandContainerHome } from "@effect-template/lib/usecases/scrap-path"
5
6
  import { parseArgs } from "../../src/docker-git/cli/parser.js"
6
7
 
7
8
  type CreateCommand = Extract<Command, { _tag: "Create" }>
@@ -32,6 +33,26 @@ const parseOrThrow = (args: ReadonlyArray<string>): Command => {
32
33
  })
33
34
  }
34
35
 
36
+ type ProjectDirRunUpCommand = Extract<Command, { readonly projectDir: string; readonly runUp: boolean }>
37
+
38
+ const expectProjectDirRunUpCommand = (
39
+ args: ReadonlyArray<string>,
40
+ expectedTag: ProjectDirRunUpCommand["_tag"],
41
+ expectedProjectDir: string,
42
+ expectedRunUp: boolean
43
+ ) =>
44
+ Effect.sync(() => {
45
+ const command = parseOrThrow(args)
46
+ if (command._tag !== expectedTag) {
47
+ throw new Error(`expected ${expectedTag} command`)
48
+ }
49
+ if (!("projectDir" in command) || !("runUp" in command)) {
50
+ throw new Error("expected command with projectDir and runUp")
51
+ }
52
+ expect(command.projectDir).toBe(expectedProjectDir)
53
+ expect(command.runUp).toBe(expectedRunUp)
54
+ })
55
+
35
56
  const expectCreateCommand = (
36
57
  args: ReadonlyArray<string>,
37
58
  onRight: (command: CreateCommand) => void
@@ -52,6 +73,8 @@ const expectCreateDefaults = (command: CreateCommand) => {
52
73
  expect(command.forceEnv).toBe(false)
53
74
  }
54
75
 
76
+ const expandDefaultTargetDir = (path: string): string => expandContainerHome(defaultTemplateConfig.sshUser, path)
77
+
55
78
  describe("parseArgs", () => {
56
79
  it.effect("parses create command with defaults", () =>
57
80
  expectCreateCommand(["create", "--repo-url", "https://github.com/org/repo.git"], (command) => {
@@ -83,7 +106,9 @@ describe("parseArgs", () => {
83
106
  expectCreateDefaults(command)
84
107
  expect(command.openSsh).toBe(true)
85
108
  expect(command.waitForClone).toBe(true)
86
- expect(command.config.targetDir).toBe("/home/dev/org/repo")
109
+ expect(command.config.targetDir).toBe(
110
+ expandDefaultTargetDir("~/workspaces/org/repo")
111
+ )
87
112
  }))
88
113
 
89
114
  it.effect("parses clone branch alias", () =>
@@ -96,6 +121,25 @@ describe("parseArgs", () => {
96
121
  expect(command.openSsh).toBe(false)
97
122
  }))
98
123
 
124
+ it.effect("parses clone git token label from inline option and normalizes it", () =>
125
+ expectCreateCommand(["clone", "https://github.com/org/repo.git", "--git-token=#agiens"], (command) => {
126
+ expect(command.config.gitTokenLabel).toBe("AGIENS")
127
+ }))
128
+
129
+ it.effect("parses clone codex/claude token labels from inline options and normalizes them", () =>
130
+ expectCreateCommand(
131
+ [
132
+ "clone",
133
+ "https://github.com/org/repo.git",
134
+ "--codex-token= Team A ",
135
+ "--claude-token=---AGIENS:::Claude---"
136
+ ],
137
+ (command) => {
138
+ expect(command.config.codexAuthLabel).toBe("team-a")
139
+ expect(command.config.claudeAuthLabel).toBe("agiens-claude")
140
+ }
141
+ ))
142
+
99
143
  it.effect("supports enabling SSH auto-open for create", () =>
100
144
  expectCreateCommand(["create", "--repo-url", "https://github.com/org/repo.git", "--ssh"], (command) => {
101
145
  expect(command.openSsh).toBe(true)
@@ -118,7 +162,9 @@ describe("parseArgs", () => {
118
162
  expect(command.config.repoUrl).toBe("https://github.com/agiens/crm.git")
119
163
  expect(command.config.repoRef).toBe("vova-fork")
120
164
  expect(command.outDir).toBe(".docker-git/agiens/crm")
121
- expect(command.config.targetDir).toBe("/home/dev/agiens/crm")
165
+ expect(command.config.targetDir).toBe(
166
+ expandDefaultTargetDir("~/workspaces/agiens/crm")
167
+ )
122
168
  }))
123
169
 
124
170
  it.effect("parses GitHub issue url as isolated project + issue branch", () =>
@@ -126,7 +172,9 @@ describe("parseArgs", () => {
126
172
  expect(command.config.repoUrl).toBe("https://github.com/org/repo.git")
127
173
  expect(command.config.repoRef).toBe("issue-5")
128
174
  expect(command.outDir).toBe(".docker-git/org/repo/issue-5")
129
- expect(command.config.targetDir).toBe("/home/dev/org/repo/issue-5")
175
+ expect(command.config.targetDir).toBe(
176
+ expandDefaultTargetDir("~/workspaces/org/repo/issue-5")
177
+ )
130
178
  expect(command.config.containerName).toBe("dg-repo-issue-5")
131
179
  expect(command.config.serviceName).toBe("dg-repo-issue-5")
132
180
  expect(command.config.volumeName).toBe("dg-repo-issue-5-home")
@@ -137,7 +185,9 @@ describe("parseArgs", () => {
137
185
  expect(command.config.repoUrl).toBe("https://github.com/org/repo.git")
138
186
  expect(command.config.repoRef).toBe("refs/pull/42/head")
139
187
  expect(command.outDir).toBe(".docker-git/org/repo/pr-42")
140
- expect(command.config.targetDir).toBe("/home/dev/org/repo/pr-42")
188
+ expect(command.config.targetDir).toBe(
189
+ expandDefaultTargetDir("~/workspaces/org/repo/pr-42")
190
+ )
141
191
  expect(command.config.containerName).toBe("dg-repo-pr-42")
142
192
  expect(command.config.serviceName).toBe("dg-repo-pr-42")
143
193
  expect(command.config.volumeName).toBe("dg-repo-pr-42-home")
@@ -153,31 +203,53 @@ describe("parseArgs", () => {
153
203
  }))
154
204
 
155
205
  it.effect("parses mcp-playwright command in current directory", () =>
206
+ expectProjectDirRunUpCommand(["mcp-playwright"], "McpPlaywrightUp", ".", true))
207
+
208
+ it.effect("parses mcp-playwright command with --no-up", () =>
209
+ expectProjectDirRunUpCommand(["mcp-playwright", "--no-up"], "McpPlaywrightUp", ".", false))
210
+
211
+ it.effect("parses mcp-playwright with positional repo url into project dir", () =>
156
212
  Effect.sync(() => {
157
- const command = parseOrThrow(["mcp-playwright"])
213
+ const command = parseOrThrow(["mcp-playwright", "https://github.com/org/repo.git"])
158
214
  if (command._tag !== "McpPlaywrightUp") {
159
215
  throw new Error("expected McpPlaywrightUp command")
160
216
  }
161
- expect(command.projectDir).toBe(".")
162
- expect(command.runUp).toBe(true)
217
+ expect(command.projectDir).toBe(".docker-git/org/repo")
163
218
  }))
164
219
 
165
- it.effect("parses mcp-playwright command with --no-up", () =>
220
+ it.effect("parses apply command in current directory", () =>
221
+ expectProjectDirRunUpCommand(["apply"], "Apply", ".", true))
222
+
223
+ it.effect("parses apply command with --no-up", () =>
224
+ expectProjectDirRunUpCommand(["apply", "--no-up"], "Apply", ".", false))
225
+
226
+ it.effect("parses apply with positional repo url into project dir", () =>
166
227
  Effect.sync(() => {
167
- const command = parseOrThrow(["mcp-playwright", "--no-up"])
168
- if (command._tag !== "McpPlaywrightUp") {
169
- throw new Error("expected McpPlaywrightUp command")
228
+ const command = parseOrThrow(["apply", "https://github.com/org/repo.git"])
229
+ if (command._tag !== "Apply") {
230
+ throw new Error("expected Apply command")
170
231
  }
171
- expect(command.runUp).toBe(false)
232
+ expect(command.projectDir).toBe(".docker-git/org/repo")
172
233
  }))
173
234
 
174
- it.effect("parses mcp-playwright with positional repo url into project dir", () =>
235
+ it.effect("parses apply token and mcp overrides", () =>
175
236
  Effect.sync(() => {
176
- const command = parseOrThrow(["mcp-playwright", "https://github.com/org/repo.git"])
177
- if (command._tag !== "McpPlaywrightUp") {
178
- throw new Error("expected McpPlaywrightUp command")
237
+ const command = parseOrThrow([
238
+ "apply",
239
+ "--git-token=agien_main",
240
+ "--codex-token=Team A",
241
+ "--claude-token=Team B",
242
+ "--mcp-playwright",
243
+ "--no-up"
244
+ ])
245
+ if (command._tag !== "Apply") {
246
+ throw new Error("expected Apply command")
179
247
  }
180
- expect(command.projectDir).toBe(".docker-git/org/repo")
248
+ expect(command.runUp).toBe(false)
249
+ expect(command.gitTokenLabel).toBe("agien_main")
250
+ expect(command.codexTokenLabel).toBe("Team A")
251
+ expect(command.claudeTokenLabel).toBe("Team B")
252
+ expect(command.enableMcpPlaywright).toBe(true)
181
253
  }))
182
254
 
183
255
  it.effect("parses down-all command", () =>