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

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 (70) hide show
  1. package/.package.json.release.bak +5 -3
  2. package/CHANGELOG.md +12 -0
  3. package/README.md +31 -1
  4. package/dist/src/docker-git/main.js +10259 -12
  5. package/dist/src/docker-git/main.js.map +1 -0
  6. package/package.json +4 -4
  7. package/src/app/program.ts +16 -13
  8. package/src/docker-git/cli/parser-options.ts +6 -0
  9. package/src/docker-git/cli/parser.ts +1 -0
  10. package/src/docker-git/cli/usage.ts +9 -4
  11. package/src/docker-git/menu-actions.ts +5 -2
  12. package/src/docker-git/menu-create.ts +9 -13
  13. package/src/docker-git/menu-render.ts +1 -1
  14. package/tests/docker-git/parser-helpers.ts +76 -0
  15. package/tests/docker-git/parser-network-options.test.ts +47 -0
  16. package/tests/docker-git/parser.test.ts +30 -71
  17. package/vite.docker-git.config.ts +34 -0
  18. package/dist/main.js +0 -930
  19. package/dist/main.js.map +0 -1
  20. package/dist/src/app/main.js +0 -15
  21. package/dist/src/app/program.js +0 -61
  22. package/dist/src/docker-git/cli/input.js +0 -21
  23. package/dist/src/docker-git/cli/parser-apply.js +0 -22
  24. package/dist/src/docker-git/cli/parser-attach.js +0 -19
  25. package/dist/src/docker-git/cli/parser-auth.js +0 -90
  26. package/dist/src/docker-git/cli/parser-clone.js +0 -40
  27. package/dist/src/docker-git/cli/parser-create.js +0 -1
  28. package/dist/src/docker-git/cli/parser-mcp-playwright.js +0 -18
  29. package/dist/src/docker-git/cli/parser-options.js +0 -134
  30. package/dist/src/docker-git/cli/parser-panes.js +0 -19
  31. package/dist/src/docker-git/cli/parser-scrap.js +0 -74
  32. package/dist/src/docker-git/cli/parser-sessions.js +0 -69
  33. package/dist/src/docker-git/cli/parser-shared.js +0 -26
  34. package/dist/src/docker-git/cli/parser-state.js +0 -62
  35. package/dist/src/docker-git/cli/parser.js +0 -47
  36. package/dist/src/docker-git/cli/read-command.js +0 -17
  37. package/dist/src/docker-git/cli/usage.js +0 -113
  38. package/dist/src/docker-git/menu-actions.js +0 -135
  39. package/dist/src/docker-git/menu-auth-data.js +0 -90
  40. package/dist/src/docker-git/menu-auth-helpers.js +0 -20
  41. package/dist/src/docker-git/menu-auth.js +0 -159
  42. package/dist/src/docker-git/menu-buffer-input.js +0 -9
  43. package/dist/src/docker-git/menu-create.js +0 -199
  44. package/dist/src/docker-git/menu-input-handler.js +0 -109
  45. package/dist/src/docker-git/menu-input-utils.js +0 -47
  46. package/dist/src/docker-git/menu-input.js +0 -2
  47. package/dist/src/docker-git/menu-labeled-env.js +0 -33
  48. package/dist/src/docker-git/menu-menu.js +0 -46
  49. package/dist/src/docker-git/menu-project-auth-claude.js +0 -43
  50. package/dist/src/docker-git/menu-project-auth-data.js +0 -165
  51. package/dist/src/docker-git/menu-project-auth.js +0 -124
  52. package/dist/src/docker-git/menu-render-auth.js +0 -45
  53. package/dist/src/docker-git/menu-render-common.js +0 -26
  54. package/dist/src/docker-git/menu-render-layout.js +0 -14
  55. package/dist/src/docker-git/menu-render-project-auth.js +0 -37
  56. package/dist/src/docker-git/menu-render-select.js +0 -129
  57. package/dist/src/docker-git/menu-render.js +0 -137
  58. package/dist/src/docker-git/menu-select-actions.js +0 -66
  59. package/dist/src/docker-git/menu-select-connect.js +0 -6
  60. package/dist/src/docker-git/menu-select-load.js +0 -12
  61. package/dist/src/docker-git/menu-select-order.js +0 -21
  62. package/dist/src/docker-git/menu-select-runtime.js +0 -82
  63. package/dist/src/docker-git/menu-select-view.js +0 -15
  64. package/dist/src/docker-git/menu-select.js +0 -98
  65. package/dist/src/docker-git/menu-shared.js +0 -180
  66. package/dist/src/docker-git/menu-startup.js +0 -57
  67. package/dist/src/docker-git/menu-types.js +0 -21
  68. package/dist/src/docker-git/menu.js +0 -226
  69. package/dist/src/docker-git/program.js +0 -43
  70. package/dist/src/docker-git/tmux.js +0 -176
@@ -1,109 +0,0 @@
1
- import { handleAuthInput } from "./menu-auth.js";
2
- import { handleCreateInput } from "./menu-create.js";
3
- import { handleMenuInput } from "./menu-menu.js";
4
- import { handleProjectAuthInput } from "./menu-project-auth.js";
5
- import { handleSelectInput } from "./menu-select.js";
6
- const activateInput = (input, key, context) => {
7
- if (context.inputStage === "active") {
8
- return { activated: false, allowProcessing: true };
9
- }
10
- if (input.trim().length > 0) {
11
- context.setInputStage("active");
12
- return { activated: true, allowProcessing: true };
13
- }
14
- if (key.upArrow || key.downArrow || key.return) {
15
- context.setInputStage("active");
16
- return { activated: true, allowProcessing: false };
17
- }
18
- if (input.length > 0) {
19
- context.setInputStage("active");
20
- return { activated: true, allowProcessing: true };
21
- }
22
- return { activated: false, allowProcessing: false };
23
- };
24
- const shouldHandleMenuInput = (input, key, context) => {
25
- const activation = activateInput(input, key, context);
26
- if (activation.activated && !activation.allowProcessing) {
27
- return false;
28
- }
29
- return activation.allowProcessing;
30
- };
31
- const handleMenuViewInput = (input, key, context) => {
32
- if (!shouldHandleMenuInput(input, key, context)) {
33
- return;
34
- }
35
- handleMenuInput(input, key, {
36
- selected: context.selected,
37
- setSelected: context.setSelected,
38
- state: context.state,
39
- runner: context.runner,
40
- exit: context.exit,
41
- setView: context.setView,
42
- setMessage: context.setMessage,
43
- setActiveDir: context.setActiveDir
44
- });
45
- };
46
- const handleCreateViewInput = (input, key, view, context) => {
47
- handleCreateInput(input, key, view, {
48
- state: context.state,
49
- setView: context.setView,
50
- setMessage: context.setMessage,
51
- runner: context.runner,
52
- setActiveDir: context.setActiveDir
53
- });
54
- };
55
- const handleAuthViewInput = (input, key, view, context) => {
56
- handleAuthInput(input, key, view, {
57
- state: context.state,
58
- setView: context.setView,
59
- setMessage: context.setMessage,
60
- setActiveDir: context.setActiveDir,
61
- runner: context.runner,
62
- setSshActive: context.setSshActive,
63
- setSkipInputs: context.setSkipInputs
64
- });
65
- };
66
- const handleProjectAuthViewInput = (input, key, view, context) => {
67
- handleProjectAuthInput(input, key, view, {
68
- runner: context.runner,
69
- setView: context.setView,
70
- setMessage: context.setMessage,
71
- setActiveDir: context.setActiveDir
72
- });
73
- };
74
- const handleSelectViewInput = (input, key, view, context) => {
75
- handleSelectInput(input, key, view, {
76
- setView: context.setView,
77
- setMessage: context.setMessage,
78
- setActiveDir: context.setActiveDir,
79
- activeDir: context.state.activeDir,
80
- runner: context.runner,
81
- setSshActive: context.setSshActive,
82
- setSkipInputs: context.setSkipInputs
83
- });
84
- };
85
- const handleActiveViewInput = (input, key, view, context) => {
86
- if (view._tag === "Create") {
87
- handleCreateViewInput(input, key, view, context);
88
- return;
89
- }
90
- if (view._tag === "AuthMenu" || view._tag === "AuthPrompt") {
91
- handleAuthViewInput(input, key, view, context);
92
- return;
93
- }
94
- if (view._tag === "ProjectAuthMenu" || view._tag === "ProjectAuthPrompt") {
95
- handleProjectAuthViewInput(input, key, view, context);
96
- return;
97
- }
98
- handleSelectViewInput(input, key, view, context);
99
- };
100
- export const handleUserInput = (input, key, context) => {
101
- if (context.busy || context.sshActive) {
102
- return;
103
- }
104
- if (context.view._tag === "Menu") {
105
- handleMenuViewInput(input, key, context);
106
- return;
107
- }
108
- handleActiveViewInput(input, key, context.view, context);
109
- };
@@ -1,47 +0,0 @@
1
- export const parseMenuIndex = (input) => {
2
- const trimmed = input.trim();
3
- if (trimmed.length === 0) {
4
- return null;
5
- }
6
- const parsed = Number(trimmed);
7
- if (!Number.isInteger(parsed)) {
8
- return null;
9
- }
10
- const index = parsed - 1;
11
- return index >= 0 ? index : null;
12
- };
13
- export const submitPromptStep = (view, steps, context, onCancel, onSubmit) => {
14
- const step = steps[view.step];
15
- if (!step) {
16
- onCancel();
17
- return;
18
- }
19
- const value = view.buffer.trim();
20
- if (step.required && value.length === 0) {
21
- context.setMessage(`${step.label} is required.`);
22
- return;
23
- }
24
- const nextValues = { ...view.values, [step.key]: value };
25
- const nextStep = view.step + 1;
26
- if (nextStep < steps.length) {
27
- context.setView({ ...view, step: nextStep, buffer: "", values: nextValues });
28
- context.setMessage(null);
29
- return;
30
- }
31
- onSubmit(nextValues);
32
- };
33
- export const handleMenuNumberInput = (input, context, actionByIndex, runAction) => {
34
- const index = parseMenuIndex(input);
35
- if (index === null) {
36
- if (input.trim().length > 0) {
37
- context.setMessage("Use arrows + Enter, or type a number from the list.");
38
- }
39
- return;
40
- }
41
- const action = actionByIndex(index);
42
- if (action === null) {
43
- context.setMessage(`Unknown action: ${input.trim()}`);
44
- return;
45
- }
46
- runAction(action);
47
- };
@@ -1,2 +0,0 @@
1
- export { buildCreateArgs, handleCreateInput, resolveCreateInputs, startCreateView } from "./menu-create.js";
2
- export { handleMenuInput } from "./menu-menu.js";
@@ -1,33 +0,0 @@
1
- import { parseEnvEntries } from "@effect-template/lib/usecases/env-file";
2
- export const normalizeLabel = (value) => {
3
- const trimmed = value.trim();
4
- if (trimmed.length === 0) {
5
- return "";
6
- }
7
- const normalized = trimmed
8
- .toUpperCase()
9
- .replaceAll(/[^A-Z0-9]+/g, "_");
10
- let start = 0;
11
- while (start < normalized.length && normalized[start] === "_") {
12
- start += 1;
13
- }
14
- let end = normalized.length;
15
- while (end > start && normalized[end - 1] === "_") {
16
- end -= 1;
17
- }
18
- const cleaned = normalized.slice(start, end);
19
- return cleaned.length > 0 ? cleaned : "";
20
- };
21
- export const buildLabeledEnvKey = (baseKey, label) => {
22
- const normalized = normalizeLabel(label);
23
- if (normalized.length === 0 || normalized === "DEFAULT") {
24
- return baseKey;
25
- }
26
- return `${baseKey}__${normalized}`;
27
- };
28
- export const countKeyEntries = (envText, baseKey) => {
29
- const prefix = `${baseKey}__`;
30
- return parseEnvEntries(envText)
31
- .filter((entry) => entry.value.trim().length > 0 && (entry.key === baseKey || entry.key.startsWith(prefix)))
32
- .length;
33
- };
@@ -1,46 +0,0 @@
1
- import { parseMenuSelection } from "@effect-template/lib/core/domain";
2
- import { isRepoUrlInput } from "@effect-template/lib/usecases/menu-helpers";
3
- import { Either } from "effect";
4
- import { handleMenuActionSelection } from "./menu-actions.js";
5
- import { startCreateView } from "./menu-create.js";
6
- import { menuItems } from "./menu-types.js";
7
- const handleMenuNavigation = (key, setSelected) => {
8
- if (key.upArrow) {
9
- setSelected((prev) => (prev === 0 ? menuItems.length - 1 : prev - 1));
10
- return;
11
- }
12
- if (key.downArrow) {
13
- setSelected((prev) => (prev === menuItems.length - 1 ? 0 : prev + 1));
14
- }
15
- };
16
- const handleMenuEnter = (context) => {
17
- const action = menuItems[context.selected]?.id;
18
- if (!action) {
19
- return;
20
- }
21
- handleMenuActionSelection(action, context);
22
- };
23
- const handleMenuTextInput = (input, context) => {
24
- const trimmed = input.trim();
25
- if (trimmed.length > 0 && isRepoUrlInput(trimmed)) {
26
- startCreateView(context.setView, context.setMessage, trimmed);
27
- return true;
28
- }
29
- const selection = parseMenuSelection(input);
30
- if (Either.isRight(selection)) {
31
- handleMenuActionSelection(selection.right, context);
32
- return true;
33
- }
34
- return false;
35
- };
36
- export const handleMenuInput = (input, key, context) => {
37
- if (key.upArrow || key.downArrow) {
38
- handleMenuNavigation(key, context.setSelected);
39
- return;
40
- }
41
- if (key.return) {
42
- handleMenuEnter(context);
43
- return;
44
- }
45
- handleMenuTextInput(input, context);
46
- };
@@ -1,43 +0,0 @@
1
- import { Effect } from "effect";
2
- const oauthTokenFileName = ".oauth-token";
3
- const legacyConfigFileName = ".config.json";
4
- const hasFileAtPath = (fs, filePath) => Effect.gen(function* (_) {
5
- const exists = yield* _(fs.exists(filePath));
6
- if (!exists) {
7
- return false;
8
- }
9
- const info = yield* _(fs.stat(filePath));
10
- return info.type === "File";
11
- });
12
- const hasNonEmptyOauthToken = (fs, tokenPath) => Effect.gen(function* (_) {
13
- const hasFile = yield* _(hasFileAtPath(fs, tokenPath));
14
- if (!hasFile) {
15
- return false;
16
- }
17
- const tokenValue = yield* _(fs.readFileString(tokenPath), Effect.orElseSucceed(() => ""));
18
- return tokenValue.trim().length > 0;
19
- });
20
- const hasLegacyClaudeAuthFile = (fs, accountPath) => Effect.gen(function* (_) {
21
- const entries = yield* _(fs.readDirectory(accountPath));
22
- for (const entry of entries) {
23
- if (!entry.startsWith(".claude") || !entry.endsWith(".json")) {
24
- continue;
25
- }
26
- const isFile = yield* _(hasFileAtPath(fs, `${accountPath}/${entry}`));
27
- if (isFile) {
28
- return true;
29
- }
30
- }
31
- return false;
32
- });
33
- export const hasClaudeAccountCredentials = (fs, accountPath) => hasFileAtPath(fs, `${accountPath}/${legacyConfigFileName}`).pipe(Effect.flatMap((hasConfig) => {
34
- if (hasConfig) {
35
- return Effect.succeed(true);
36
- }
37
- return hasNonEmptyOauthToken(fs, `${accountPath}/${oauthTokenFileName}`).pipe(Effect.flatMap((hasOauthToken) => {
38
- if (hasOauthToken) {
39
- return Effect.succeed(true);
40
- }
41
- return hasLegacyClaudeAuthFile(fs, accountPath);
42
- }));
43
- }));
@@ -1,165 +0,0 @@
1
- import * as FileSystem from "@effect/platform/FileSystem";
2
- import * as Path from "@effect/platform/Path";
3
- import { Effect, Match, pipe } from "effect";
4
- import { AuthError } from "@effect-template/lib/shell/errors";
5
- import { normalizeAccountLabel } from "@effect-template/lib/usecases/auth-helpers";
6
- import { ensureEnvFile, findEnvValue, readEnvText, upsertEnvKey } from "@effect-template/lib/usecases/env-file";
7
- import { defaultProjectsRoot } from "@effect-template/lib/usecases/menu-helpers";
8
- import { autoSyncState } from "@effect-template/lib/usecases/state-repo";
9
- import { countAuthAccountDirectories } from "./menu-auth-helpers.js";
10
- import { buildLabeledEnvKey, countKeyEntries, normalizeLabel } from "./menu-labeled-env.js";
11
- import { hasClaudeAccountCredentials } from "./menu-project-auth-claude.js";
12
- const projectAuthMenuItems = [
13
- { action: "ProjectGithubConnect", label: "Project: GitHub connect label" },
14
- { action: "ProjectGithubDisconnect", label: "Project: GitHub disconnect" },
15
- { action: "ProjectGitConnect", label: "Project: Git connect label" },
16
- { action: "ProjectGitDisconnect", label: "Project: Git disconnect" },
17
- { action: "ProjectClaudeConnect", label: "Project: Claude connect label" },
18
- { action: "ProjectClaudeDisconnect", label: "Project: Claude disconnect" },
19
- { action: "Refresh", label: "Refresh snapshot" },
20
- { action: "Back", label: "Back to main menu" }
21
- ];
22
- const flowSteps = {
23
- ProjectGithubConnect: [
24
- { key: "label", label: "Label (empty = default)", required: false, secret: false }
25
- ],
26
- ProjectGithubDisconnect: [],
27
- ProjectGitConnect: [
28
- { key: "label", label: "Label (empty = default)", required: false, secret: false }
29
- ],
30
- ProjectGitDisconnect: [],
31
- ProjectClaudeConnect: [
32
- { key: "label", label: "Label (empty = default)", required: false, secret: false }
33
- ],
34
- ProjectClaudeDisconnect: []
35
- };
36
- const resolveCanonicalLabel = (value) => {
37
- const normalized = normalizeLabel(value);
38
- return normalized.length === 0 || normalized === "DEFAULT" ? "default" : normalized;
39
- };
40
- const githubTokenBaseKey = "GITHUB_TOKEN";
41
- const gitTokenBaseKey = "GIT_AUTH_TOKEN";
42
- const gitUserBaseKey = "GIT_AUTH_USER";
43
- const projectGithubLabelKey = "GITHUB_AUTH_LABEL";
44
- const projectGitLabelKey = "GIT_AUTH_LABEL";
45
- const projectClaudeLabelKey = "CLAUDE_AUTH_LABEL";
46
- const defaultGitUser = "x-access-token";
47
- const buildGlobalEnvPath = (cwd) => `${defaultProjectsRoot(cwd)}/.orch/env/global.env`;
48
- const buildClaudeAuthPath = (cwd) => `${defaultProjectsRoot(cwd)}/.orch/auth/claude`;
49
- const loadProjectAuthEnvText = (project) => Effect.gen(function* (_) {
50
- const fs = yield* _(FileSystem.FileSystem);
51
- const path = yield* _(Path.Path);
52
- const globalEnvPath = buildGlobalEnvPath(process.cwd());
53
- const claudeAuthPath = buildClaudeAuthPath(process.cwd());
54
- yield* _(ensureEnvFile(fs, path, globalEnvPath));
55
- yield* _(ensureEnvFile(fs, path, project.envProjectPath));
56
- const globalEnvText = yield* _(readEnvText(fs, globalEnvPath));
57
- const projectEnvText = yield* _(readEnvText(fs, project.envProjectPath));
58
- return {
59
- fs,
60
- path,
61
- globalEnvPath,
62
- projectEnvPath: project.envProjectPath,
63
- claudeAuthPath,
64
- globalEnvText,
65
- projectEnvText
66
- };
67
- });
68
- export const readProjectAuthSnapshot = (project) => pipe(loadProjectAuthEnvText(project), Effect.flatMap(({ claudeAuthPath, fs, globalEnvPath, globalEnvText, path, projectEnvPath, projectEnvText }) => pipe(countAuthAccountDirectories(fs, path, claudeAuthPath), Effect.map((claudeAuthEntries) => ({
69
- projectDir: project.projectDir,
70
- projectName: project.displayName,
71
- envGlobalPath: globalEnvPath,
72
- envProjectPath: projectEnvPath,
73
- claudeAuthPath,
74
- githubTokenEntries: countKeyEntries(globalEnvText, githubTokenBaseKey),
75
- gitTokenEntries: countKeyEntries(globalEnvText, gitTokenBaseKey),
76
- claudeAuthEntries,
77
- activeGithubLabel: findEnvValue(projectEnvText, projectGithubLabelKey),
78
- activeGitLabel: findEnvValue(projectEnvText, projectGitLabelKey),
79
- activeClaudeLabel: findEnvValue(projectEnvText, projectClaudeLabelKey)
80
- })))));
81
- const missingSecret = (provider, label, envPath) => new AuthError({
82
- message: `${provider} not connected: label '${label}' not found in ${envPath}`
83
- });
84
- const updateProjectGithubConnect = (spec) => {
85
- const key = buildLabeledEnvKey(githubTokenBaseKey, spec.rawLabel);
86
- const token = findEnvValue(spec.globalEnvText, key);
87
- if (token === null) {
88
- return Effect.fail(missingSecret("GitHub token", spec.canonicalLabel, spec.globalEnvPath));
89
- }
90
- const withGitToken = upsertEnvKey(spec.projectEnvText, "GIT_AUTH_TOKEN", token);
91
- const withGhToken = upsertEnvKey(withGitToken, "GH_TOKEN", token);
92
- const withoutGitLabel = upsertEnvKey(withGhToken, projectGitLabelKey, "");
93
- return Effect.succeed(upsertEnvKey(withoutGitLabel, projectGithubLabelKey, spec.canonicalLabel));
94
- };
95
- const clearProjectGitLabels = (envText) => {
96
- const withoutGhToken = upsertEnvKey(envText, "GH_TOKEN", "");
97
- const withoutGitLabel = upsertEnvKey(withoutGhToken, projectGitLabelKey, "");
98
- return upsertEnvKey(withoutGitLabel, projectGithubLabelKey, "");
99
- };
100
- const updateProjectGithubDisconnect = (spec) => {
101
- const withoutGitToken = upsertEnvKey(spec.projectEnvText, "GIT_AUTH_TOKEN", "");
102
- return Effect.succeed(clearProjectGitLabels(withoutGitToken));
103
- };
104
- const updateProjectGitConnect = (spec) => {
105
- const tokenKey = buildLabeledEnvKey(gitTokenBaseKey, spec.rawLabel);
106
- const userKey = buildLabeledEnvKey(gitUserBaseKey, spec.rawLabel);
107
- const token = findEnvValue(spec.globalEnvText, tokenKey);
108
- if (token === null) {
109
- return Effect.fail(missingSecret("Git credentials", spec.canonicalLabel, spec.globalEnvPath));
110
- }
111
- const defaultUser = findEnvValue(spec.globalEnvText, gitUserBaseKey) ?? defaultGitUser;
112
- const user = findEnvValue(spec.globalEnvText, userKey) ?? defaultUser;
113
- const withToken = upsertEnvKey(spec.projectEnvText, "GIT_AUTH_TOKEN", token);
114
- const withUser = upsertEnvKey(withToken, "GIT_AUTH_USER", user);
115
- const withGhToken = upsertEnvKey(withUser, "GH_TOKEN", token);
116
- const withGitLabel = upsertEnvKey(withGhToken, projectGitLabelKey, spec.canonicalLabel);
117
- return Effect.succeed(upsertEnvKey(withGitLabel, projectGithubLabelKey, spec.canonicalLabel));
118
- };
119
- const updateProjectGitDisconnect = (spec) => {
120
- const withoutToken = upsertEnvKey(spec.projectEnvText, "GIT_AUTH_TOKEN", "");
121
- const withoutUser = upsertEnvKey(withoutToken, "GIT_AUTH_USER", "");
122
- return Effect.succeed(clearProjectGitLabels(withoutUser));
123
- };
124
- const updateProjectClaudeConnect = (spec) => {
125
- const accountLabel = normalizeAccountLabel(spec.rawLabel, "default");
126
- const accountPath = `${spec.claudeAuthPath}/${accountLabel}`;
127
- return Effect.gen(function* (_) {
128
- const exists = yield* _(spec.fs.exists(accountPath));
129
- if (!exists) {
130
- return yield* _(Effect.fail(missingSecret("Claude Code login", spec.canonicalLabel, spec.claudeAuthPath)));
131
- }
132
- const hasCredentials = yield* _(hasClaudeAccountCredentials(spec.fs, accountPath), Effect.orElseSucceed(() => false));
133
- if (hasCredentials) {
134
- return upsertEnvKey(spec.projectEnvText, projectClaudeLabelKey, spec.canonicalLabel);
135
- }
136
- return yield* _(Effect.fail(missingSecret("Claude Code login", spec.canonicalLabel, spec.claudeAuthPath)));
137
- });
138
- };
139
- const updateProjectClaudeDisconnect = (spec) => {
140
- return Effect.succeed(upsertEnvKey(spec.projectEnvText, projectClaudeLabelKey, ""));
141
- };
142
- const resolveProjectEnvUpdate = (flow, spec) => Match.value(flow).pipe(Match.when("ProjectGithubConnect", () => updateProjectGithubConnect(spec)), Match.when("ProjectGithubDisconnect", () => updateProjectGithubDisconnect(spec)), Match.when("ProjectGitConnect", () => updateProjectGitConnect(spec)), Match.when("ProjectGitDisconnect", () => updateProjectGitDisconnect(spec)), Match.when("ProjectClaudeConnect", () => updateProjectClaudeConnect(spec)), Match.when("ProjectClaudeDisconnect", () => updateProjectClaudeDisconnect(spec)), Match.exhaustive);
143
- export const writeProjectAuthFlow = (project, flow, values) => pipe(loadProjectAuthEnvText(project), Effect.flatMap(({ claudeAuthPath, fs, globalEnvPath, globalEnvText, projectEnvPath, projectEnvText }) => {
144
- const rawLabel = values["label"] ?? "";
145
- const canonicalLabel = resolveCanonicalLabel(rawLabel);
146
- const spec = {
147
- fs,
148
- rawLabel,
149
- canonicalLabel,
150
- globalEnvPath,
151
- globalEnvText,
152
- projectEnvText,
153
- claudeAuthPath
154
- };
155
- const nextProjectEnv = resolveProjectEnvUpdate(flow, spec);
156
- const syncMessage = Match.value(flow).pipe(Match.when("ProjectGithubConnect", () => `chore(state): project auth gh ${canonicalLabel} ${project.displayName}`), Match.when("ProjectGithubDisconnect", () => `chore(state): project auth gh logout ${project.displayName}`), Match.when("ProjectGitConnect", () => `chore(state): project auth git ${canonicalLabel} ${project.displayName}`), Match.when("ProjectGitDisconnect", () => `chore(state): project auth git logout ${project.displayName}`), Match.when("ProjectClaudeConnect", () => `chore(state): project auth claude ${canonicalLabel} ${project.displayName}`), Match.when("ProjectClaudeDisconnect", () => `chore(state): project auth claude logout ${project.displayName}`), Match.exhaustive);
157
- return pipe(nextProjectEnv, Effect.flatMap((nextText) => fs.writeFileString(projectEnvPath, nextText)), Effect.zipRight(autoSyncState(syncMessage)));
158
- }), Effect.asVoid);
159
- export const projectAuthViewSteps = (flow) => flowSteps[flow];
160
- export const projectAuthMenuLabels = () => projectAuthMenuItems.map((item) => item.label);
161
- export const projectAuthMenuActionByIndex = (index) => {
162
- const item = projectAuthMenuItems[index];
163
- return item ? item.action : null;
164
- };
165
- export const projectAuthMenuSize = () => projectAuthMenuItems.length;
@@ -1,124 +0,0 @@
1
- import { Effect, Match, pipe } from "effect";
2
- import { nextBufferValue } from "./menu-buffer-input.js";
3
- import { handleMenuNumberInput, submitPromptStep } from "./menu-input-utils.js";
4
- import { projectAuthMenuActionByIndex, projectAuthMenuSize, projectAuthViewSteps, readProjectAuthSnapshot, writeProjectAuthFlow } from "./menu-project-auth-data.js";
5
- import { resetToMenu } from "./menu-shared.js";
6
- const startProjectAuthMenu = (project, snapshot, context) => {
7
- context.setView({ _tag: "ProjectAuthMenu", selected: 0, project, snapshot });
8
- context.setMessage(null);
9
- };
10
- const startProjectAuthPrompt = (project, snapshot, flow, context) => {
11
- context.setView({
12
- _tag: "ProjectAuthPrompt",
13
- flow,
14
- step: 0,
15
- buffer: "",
16
- values: {},
17
- project,
18
- snapshot
19
- });
20
- context.setMessage(null);
21
- };
22
- const loadProjectAuthMenuView = (project, context) => pipe(readProjectAuthSnapshot(project), Effect.tap((snapshot) => Effect.sync(() => {
23
- startProjectAuthMenu(project, snapshot, context);
24
- })), Effect.asVoid);
25
- const successMessage = (flow, label) => Match.value(flow).pipe(Match.when("ProjectGithubConnect", () => `Connected GitHub label (${label}) to project.`), Match.when("ProjectGithubDisconnect", () => "Disconnected GitHub from project."), Match.when("ProjectGitConnect", () => `Connected Git label (${label}) to project.`), Match.when("ProjectGitDisconnect", () => "Disconnected Git from project."), Match.when("ProjectClaudeConnect", () => `Connected Claude label (${label}) to project.`), Match.when("ProjectClaudeDisconnect", () => "Disconnected Claude from project."), Match.exhaustive);
26
- const runProjectAuthEffect = (project, flow, values, label, context) => {
27
- context.runner.runEffect(pipe(writeProjectAuthFlow(project, flow, values), Effect.zipRight(readProjectAuthSnapshot(project)), Effect.tap((snapshot) => Effect.sync(() => {
28
- startProjectAuthMenu(project, snapshot, context);
29
- context.setMessage(successMessage(flow, label));
30
- })), Effect.asVoid));
31
- };
32
- const submitProjectAuthPrompt = (view, context) => {
33
- const steps = projectAuthViewSteps(view.flow);
34
- submitPromptStep(view, steps, context, () => {
35
- startProjectAuthMenu(view.project, view.snapshot, context);
36
- }, (nextValues) => {
37
- const rawLabel = (nextValues["label"] ?? "").trim();
38
- const label = rawLabel.length > 0 ? rawLabel : "default";
39
- runProjectAuthEffect(view.project, view.flow, nextValues, label, context);
40
- });
41
- };
42
- const runProjectAuthAction = (action, view, context) => {
43
- if (action === "Back") {
44
- resetToMenu(context);
45
- return;
46
- }
47
- if (action === "Refresh") {
48
- context.runner.runEffect(loadProjectAuthMenuView(view.project, context));
49
- return;
50
- }
51
- if (action === "ProjectGithubDisconnect" || action === "ProjectGitDisconnect" || action === "ProjectClaudeDisconnect") {
52
- runProjectAuthEffect(view.project, action, {}, "default", context);
53
- return;
54
- }
55
- startProjectAuthPrompt(view.project, view.snapshot, action, context);
56
- };
57
- const setProjectAuthMenuSelection = (view, selected, context) => {
58
- context.setView({ ...view, selected });
59
- };
60
- const shiftProjectAuthMenuSelection = (view, delta, context) => {
61
- const menuSize = projectAuthMenuSize();
62
- const selected = (view.selected + delta + menuSize) % menuSize;
63
- setProjectAuthMenuSelection(view, selected, context);
64
- };
65
- const runProjectAuthMenuSelection = (selected, view, context) => {
66
- const action = projectAuthMenuActionByIndex(selected);
67
- if (action === null) {
68
- return;
69
- }
70
- runProjectAuthAction(action, view, context);
71
- };
72
- const handleProjectAuthMenuNumberInput = (input, view, context) => {
73
- handleMenuNumberInput(input, context, projectAuthMenuActionByIndex, (action) => {
74
- runProjectAuthAction(action, view, context);
75
- });
76
- };
77
- const handleProjectAuthMenuInput = (input, key, view, context) => {
78
- if (key.escape) {
79
- resetToMenu(context);
80
- return;
81
- }
82
- if (key.upArrow) {
83
- shiftProjectAuthMenuSelection(view, -1, context);
84
- return;
85
- }
86
- if (key.downArrow) {
87
- shiftProjectAuthMenuSelection(view, 1, context);
88
- return;
89
- }
90
- if (key.return) {
91
- runProjectAuthMenuSelection(view.selected, view, context);
92
- return;
93
- }
94
- handleProjectAuthMenuNumberInput(input, view, context);
95
- };
96
- const setProjectAuthPromptBuffer = (args) => {
97
- const nextBuffer = nextBufferValue(args.input, args.key, args.view.buffer);
98
- if (nextBuffer === null) {
99
- return;
100
- }
101
- args.context.setView({ ...args.view, buffer: nextBuffer });
102
- };
103
- const handleProjectAuthPromptInput = (input, key, view, context) => {
104
- if (key.escape) {
105
- startProjectAuthMenu(view.project, view.snapshot, context);
106
- return;
107
- }
108
- if (key.return) {
109
- submitProjectAuthPrompt(view, context);
110
- return;
111
- }
112
- setProjectAuthPromptBuffer({ input, key, view, context });
113
- };
114
- export const openProjectAuthMenu = (context) => {
115
- context.setMessage(`Loading project auth (${context.project.displayName})...`);
116
- context.runner.runEffect(loadProjectAuthMenuView(context.project, context));
117
- };
118
- export const handleProjectAuthInput = (input, key, view, context) => {
119
- if (view._tag === "ProjectAuthMenu") {
120
- handleProjectAuthMenuInput(input, key, view, context);
121
- return;
122
- }
123
- handleProjectAuthPromptInput(input, key, view, context);
124
- };
@@ -1,45 +0,0 @@
1
- import { Box, Text } from "ink";
2
- import React from "react";
3
- import { authMenuLabels, authViewSteps, authViewTitle } from "./menu-auth-data.js";
4
- import { renderMenuHelp, renderPromptLayout, renderSelectableMenuList, resolvePromptState } from "./menu-render-common.js";
5
- import { renderLayout } from "./menu-render-layout.js";
6
- const renderCountLine = (title, count) => `${title}: ${count}`;
7
- export const renderAuthMenu = (snapshot, selected, message) => {
8
- const el = React.createElement;
9
- const list = renderSelectableMenuList(authMenuLabels(), selected);
10
- return renderLayout("docker-git / Auth profiles", [
11
- el(Text, null, `Global env: ${snapshot.globalEnvPath}`),
12
- el(Text, null, `Claude auth: ${snapshot.claudeAuthPath}`),
13
- el(Text, { color: "gray" }, renderCountLine("Entries", snapshot.totalEntries)),
14
- el(Text, { color: "gray" }, renderCountLine("GitHub tokens", snapshot.githubTokenEntries)),
15
- el(Text, { color: "gray" }, renderCountLine("Git tokens", snapshot.gitTokenEntries)),
16
- el(Text, { color: "gray" }, renderCountLine("Git users", snapshot.gitUserEntries)),
17
- el(Text, { color: "gray" }, renderCountLine("Claude logins", snapshot.claudeAuthEntries)),
18
- el(Box, { flexDirection: "column", marginTop: 1 }, ...list),
19
- renderMenuHelp("Use arrows + Enter, or type a number.")
20
- ], message);
21
- };
22
- export const renderAuthPrompt = (view, message) => {
23
- const el = React.createElement;
24
- const { prompt, visibleBuffer } = resolvePromptState(authViewSteps(view.flow), view.step, view.buffer);
25
- let helpLine = "Enter = next, Esc = cancel.";
26
- if (view.flow === "GithubOauth" || view.flow === "ClaudeOauth") {
27
- helpLine = "Enter = start OAuth, Esc = cancel.";
28
- }
29
- else if (view.flow === "ClaudeLogout") {
30
- helpLine = "Enter = logout, Esc = cancel.";
31
- }
32
- return renderPromptLayout({
33
- title: `docker-git / Auth / ${authViewTitle(view.flow)}`,
34
- header: [
35
- el(Text, { color: "gray" }, `Global env: ${view.snapshot.globalEnvPath}`),
36
- ...(view.flow === "ClaudeOauth" || view.flow === "ClaudeLogout"
37
- ? [el(Text, { color: "gray" }, `Claude auth: ${view.snapshot.claudeAuthPath}`)]
38
- : [])
39
- ],
40
- prompt,
41
- visibleBuffer,
42
- helpLine,
43
- message
44
- });
45
- };
@@ -1,26 +0,0 @@
1
- import { Box, Text } from "ink";
2
- import React from "react";
3
- import { renderLayout } from "./menu-render-layout.js";
4
- export const renderSelectableMenuList = (labels, selected) => {
5
- const el = React.createElement;
6
- return labels.map((label, index) => el(Text, { key: `${index}-${label}`, color: index === selected ? "green" : "white" }, `${index === selected ? ">" : " "} ${index + 1}) ${label}`));
7
- };
8
- export const renderMenuHelp = (primaryLine) => {
9
- const el = React.createElement;
10
- return el(Box, { marginTop: 1, flexDirection: "column" }, el(Text, { color: "gray" }, primaryLine), el(Text, { color: "gray" }, "Esc returns to the main menu."));
11
- };
12
- export const resolvePromptState = (steps, step, buffer) => {
13
- const current = steps[step];
14
- const prompt = current?.label ?? "Value";
15
- const isSecret = current?.secret === true;
16
- const visibleBuffer = isSecret ? "*".repeat(buffer.length) : buffer;
17
- return { prompt, visibleBuffer };
18
- };
19
- export const renderPromptLayout = (args) => {
20
- const el = React.createElement;
21
- return renderLayout(args.title, [
22
- ...args.header,
23
- el(Box, { marginTop: 1 }, el(Text, null, `${args.prompt}: `), el(Text, { color: "green" }, args.visibleBuffer)),
24
- el(Box, { marginTop: 1, flexDirection: "column" }, el(Text, { color: "gray" }, args.helpLine))
25
- ], args.message);
26
- };
@@ -1,14 +0,0 @@
1
- import { Box, Text } from "ink";
2
- import React from "react";
3
- const renderMessage = (message) => {
4
- if (!message) {
5
- return null;
6
- }
7
- return React.createElement(Box, { marginTop: 1 }, React.createElement(Text, { color: "magenta" }, message));
8
- };
9
- export const renderLayout = (title, body, message) => {
10
- const el = React.createElement;
11
- const messageView = renderMessage(message);
12
- const tail = messageView ? [messageView] : [];
13
- return el(Box, { flexDirection: "column", padding: 1, borderStyle: "round" }, el(Text, { color: "cyan", bold: true }, title), ...body, ...tail);
14
- };