claudedesk 1.0.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/LICENSE +21 -0
- package/README.md +431 -0
- package/config/repos.example.json +128 -0
- package/config/settings.example.json +64 -0
- package/config/skills/code-review.md +76 -0
- package/config/skills/full-check.md +26 -0
- package/config/skills/lint-fix.md +23 -0
- package/dist/api/agent-routes.d.ts +2 -0
- package/dist/api/agent-routes.d.ts.map +1 -0
- package/dist/api/agent-routes.js +251 -0
- package/dist/api/agent-routes.js.map +1 -0
- package/dist/api/app-routes.d.ts +2 -0
- package/dist/api/app-routes.d.ts.map +1 -0
- package/dist/api/app-routes.js +150 -0
- package/dist/api/app-routes.js.map +1 -0
- package/dist/api/docker-routes.d.ts +2 -0
- package/dist/api/docker-routes.d.ts.map +1 -0
- package/dist/api/docker-routes.js +167 -0
- package/dist/api/docker-routes.js.map +1 -0
- package/dist/api/middleware.d.ts +6 -0
- package/dist/api/middleware.d.ts.map +1 -0
- package/dist/api/middleware.js +293 -0
- package/dist/api/middleware.js.map +1 -0
- package/dist/api/pin-auth.d.ts +65 -0
- package/dist/api/pin-auth.d.ts.map +1 -0
- package/dist/api/pin-auth.js +218 -0
- package/dist/api/pin-auth.js.map +1 -0
- package/dist/api/routes.d.ts +2 -0
- package/dist/api/routes.d.ts.map +1 -0
- package/dist/api/routes.js +473 -0
- package/dist/api/routes.js.map +1 -0
- package/dist/api/settings-routes.d.ts +2 -0
- package/dist/api/settings-routes.d.ts.map +1 -0
- package/dist/api/settings-routes.js +570 -0
- package/dist/api/settings-routes.js.map +1 -0
- package/dist/api/skill-routes.d.ts +2 -0
- package/dist/api/skill-routes.d.ts.map +1 -0
- package/dist/api/skill-routes.js +88 -0
- package/dist/api/skill-routes.js.map +1 -0
- package/dist/api/terminal-routes.d.ts +2 -0
- package/dist/api/terminal-routes.d.ts.map +1 -0
- package/dist/api/terminal-routes.js +3524 -0
- package/dist/api/terminal-routes.js.map +1 -0
- package/dist/api/tunnel-routes.d.ts +2 -0
- package/dist/api/tunnel-routes.d.ts.map +1 -0
- package/dist/api/tunnel-routes.js +196 -0
- package/dist/api/tunnel-routes.js.map +1 -0
- package/dist/api/workspace-routes.d.ts +3 -0
- package/dist/api/workspace-routes.d.ts.map +1 -0
- package/dist/api/workspace-routes.js +649 -0
- package/dist/api/workspace-routes.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +276 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/assets/index-B4r0njGe.js +780 -0
- package/dist/client/assets/index-CY_9MyE0.css +1 -0
- package/dist/client/favicon.svg +5 -0
- package/dist/client/icons/icon-192.svg +5 -0
- package/dist/client/icons/icon-512.svg +5 -0
- package/dist/client/icons/logo-with-message.png +0 -0
- package/dist/client/icons/logo.png +0 -0
- package/dist/client/index.html +25 -0
- package/dist/client/manifest.json +62 -0
- package/dist/client/sw.js +243 -0
- package/dist/config/agent-usage.d.ts +34 -0
- package/dist/config/agent-usage.d.ts.map +1 -0
- package/dist/config/agent-usage.js +87 -0
- package/dist/config/agent-usage.js.map +1 -0
- package/dist/config/repos.d.ts +34 -0
- package/dist/config/repos.d.ts.map +1 -0
- package/dist/config/repos.js +412 -0
- package/dist/config/repos.js.map +1 -0
- package/dist/config/settings.d.ts +634 -0
- package/dist/config/settings.d.ts.map +1 -0
- package/dist/config/settings.js +459 -0
- package/dist/config/settings.js.map +1 -0
- package/dist/config/skills.d.ts +18 -0
- package/dist/config/skills.d.ts.map +1 -0
- package/dist/config/skills.js +174 -0
- package/dist/config/skills.js.map +1 -0
- package/dist/config/workspaces.d.ts +961 -0
- package/dist/config/workspaces.d.ts.map +1 -0
- package/dist/config/workspaces.js +482 -0
- package/dist/config/workspaces.js.map +1 -0
- package/dist/core/app-manager.d.ts +85 -0
- package/dist/core/app-manager.d.ts.map +1 -0
- package/dist/core/app-manager.js +447 -0
- package/dist/core/app-manager.js.map +1 -0
- package/dist/core/claude-invoker.d.ts +49 -0
- package/dist/core/claude-invoker.d.ts.map +1 -0
- package/dist/core/claude-invoker.js +583 -0
- package/dist/core/claude-invoker.js.map +1 -0
- package/dist/core/claude-session-reader.d.ts +25 -0
- package/dist/core/claude-session-reader.d.ts.map +1 -0
- package/dist/core/claude-session-reader.js +184 -0
- package/dist/core/claude-session-reader.js.map +1 -0
- package/dist/core/claude-usage-query.d.ts +78 -0
- package/dist/core/claude-usage-query.d.ts.map +1 -0
- package/dist/core/claude-usage-query.js +294 -0
- package/dist/core/claude-usage-query.js.map +1 -0
- package/dist/core/git-credential-helper.d.ts +57 -0
- package/dist/core/git-credential-helper.d.ts.map +1 -0
- package/dist/core/git-credential-helper.js +176 -0
- package/dist/core/git-credential-helper.js.map +1 -0
- package/dist/core/git-sandbox.d.ts +135 -0
- package/dist/core/git-sandbox.d.ts.map +1 -0
- package/dist/core/git-sandbox.js +907 -0
- package/dist/core/git-sandbox.js.map +1 -0
- package/dist/core/github-integration.d.ts +66 -0
- package/dist/core/github-integration.d.ts.map +1 -0
- package/dist/core/github-integration.js +350 -0
- package/dist/core/github-integration.js.map +1 -0
- package/dist/core/github-oauth.d.ts +88 -0
- package/dist/core/github-oauth.d.ts.map +1 -0
- package/dist/core/github-oauth.js +244 -0
- package/dist/core/github-oauth.js.map +1 -0
- package/dist/core/gitlab-integration.d.ts +66 -0
- package/dist/core/gitlab-integration.d.ts.map +1 -0
- package/dist/core/gitlab-integration.js +353 -0
- package/dist/core/gitlab-integration.js.map +1 -0
- package/dist/core/gitlab-oauth.d.ts +100 -0
- package/dist/core/gitlab-oauth.d.ts.map +1 -0
- package/dist/core/gitlab-oauth.js +366 -0
- package/dist/core/gitlab-oauth.js.map +1 -0
- package/dist/core/insights-extractor.d.ts +68 -0
- package/dist/core/insights-extractor.d.ts.map +1 -0
- package/dist/core/insights-extractor.js +402 -0
- package/dist/core/insights-extractor.js.map +1 -0
- package/dist/core/logger.d.ts +27 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +70 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/process-runner.d.ts +27 -0
- package/dist/core/process-runner.d.ts.map +1 -0
- package/dist/core/process-runner.js +147 -0
- package/dist/core/process-runner.js.map +1 -0
- package/dist/core/project-detector.d.ts +30 -0
- package/dist/core/project-detector.d.ts.map +1 -0
- package/dist/core/project-detector.js +482 -0
- package/dist/core/project-detector.js.map +1 -0
- package/dist/core/qr-generator.d.ts +18 -0
- package/dist/core/qr-generator.d.ts.map +1 -0
- package/dist/core/qr-generator.js +61 -0
- package/dist/core/qr-generator.js.map +1 -0
- package/dist/core/remote-tunnel-manager.d.ts +59 -0
- package/dist/core/remote-tunnel-manager.d.ts.map +1 -0
- package/dist/core/remote-tunnel-manager.js +235 -0
- package/dist/core/remote-tunnel-manager.js.map +1 -0
- package/dist/core/shared-docker-manager.d.ts +41 -0
- package/dist/core/shared-docker-manager.d.ts.map +1 -0
- package/dist/core/shared-docker-manager.js +409 -0
- package/dist/core/shared-docker-manager.js.map +1 -0
- package/dist/core/skill-executor.d.ts +25 -0
- package/dist/core/skill-executor.d.ts.map +1 -0
- package/dist/core/skill-executor.js +171 -0
- package/dist/core/skill-executor.js.map +1 -0
- package/dist/core/terminal-session.d.ts +149 -0
- package/dist/core/terminal-session.d.ts.map +1 -0
- package/dist/core/terminal-session.js +2340 -0
- package/dist/core/terminal-session.js.map +1 -0
- package/dist/core/tunnel-manager.d.ts +35 -0
- package/dist/core/tunnel-manager.d.ts.map +1 -0
- package/dist/core/tunnel-manager.js +137 -0
- package/dist/core/tunnel-manager.js.map +1 -0
- package/dist/core/usage-manager.d.ts +57 -0
- package/dist/core/usage-manager.d.ts.map +1 -0
- package/dist/core/usage-manager.js +363 -0
- package/dist/core/usage-manager.js.map +1 -0
- package/dist/core/ws-manager.d.ts +39 -0
- package/dist/core/ws-manager.d.ts.map +1 -0
- package/dist/core/ws-manager.js +190 -0
- package/dist/core/ws-manager.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +229 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +868 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +119 -0
- package/dist/types.js.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { writeFileSync, unlinkSync, existsSync, mkdirSync, chmodSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { randomUUID } from 'crypto';
|
|
4
|
+
/**
|
|
5
|
+
* Git credential helper utilities for injecting OAuth tokens into git operations.
|
|
6
|
+
* This allows OAuth-authenticated git operations (push, pull, fetch) without
|
|
7
|
+
* requiring separate SSH keys or credential helpers.
|
|
8
|
+
*/
|
|
9
|
+
const TEMP_DIR = join(process.cwd(), 'temp', 'git-credentials');
|
|
10
|
+
// Ensure temp directory exists
|
|
11
|
+
if (!existsSync(TEMP_DIR)) {
|
|
12
|
+
mkdirSync(TEMP_DIR, { recursive: true });
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates a temporary credential helper script that returns the OAuth token.
|
|
16
|
+
* The script is compatible with git's credential helper protocol.
|
|
17
|
+
* @param token - The OAuth access token
|
|
18
|
+
* @param platform - The git platform ('github' or 'gitlab')
|
|
19
|
+
* @returns Path to the temporary credential helper script
|
|
20
|
+
*/
|
|
21
|
+
export function createCredentialHelperScript(token, platform) {
|
|
22
|
+
const scriptId = randomUUID();
|
|
23
|
+
const isWindows = process.platform === 'win32';
|
|
24
|
+
const scriptExt = isWindows ? '.bat' : '.sh';
|
|
25
|
+
const scriptPath = join(TEMP_DIR, `git-askpass-${scriptId}${scriptExt}`);
|
|
26
|
+
// The script simply echoes the token when called by git
|
|
27
|
+
// GIT_ASKPASS is called with a prompt, but we just return the token
|
|
28
|
+
let scriptContent;
|
|
29
|
+
if (isWindows) {
|
|
30
|
+
// Windows batch script
|
|
31
|
+
scriptContent = `@echo off
|
|
32
|
+
echo ${token}
|
|
33
|
+
`;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// Unix shell script
|
|
37
|
+
scriptContent = `#!/bin/sh
|
|
38
|
+
echo "${token}"
|
|
39
|
+
`;
|
|
40
|
+
}
|
|
41
|
+
writeFileSync(scriptPath, scriptContent);
|
|
42
|
+
// Make executable on Unix
|
|
43
|
+
if (!isWindows) {
|
|
44
|
+
try {
|
|
45
|
+
chmodSync(scriptPath, 0o700);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// Ignore chmod errors on Windows
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return scriptPath;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Removes a temporary credential helper script.
|
|
55
|
+
* SEC-06: Improved cleanup with logging for debugging failed deletions.
|
|
56
|
+
* @param scriptPath - Path to the script to remove
|
|
57
|
+
*/
|
|
58
|
+
export function removeCredentialHelperScript(scriptPath) {
|
|
59
|
+
try {
|
|
60
|
+
if (existsSync(scriptPath)) {
|
|
61
|
+
// Overwrite file content before deletion to reduce token exposure window
|
|
62
|
+
try {
|
|
63
|
+
writeFileSync(scriptPath, '# cleaned\n');
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// Continue with deletion even if overwrite fails
|
|
67
|
+
}
|
|
68
|
+
unlinkSync(scriptPath);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
// Log cleanup errors for debugging instead of silently ignoring
|
|
73
|
+
console.warn(`[git-credential-helper] Failed to remove credential script ${scriptPath}:`, error instanceof Error ? error.message : String(error));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get environment variables to inject for git authentication.
|
|
78
|
+
* These environment variables enable git to use the OAuth token for HTTPS operations.
|
|
79
|
+
*
|
|
80
|
+
* @param token - The OAuth access token
|
|
81
|
+
* @param platform - The git platform ('github' or 'gitlab')
|
|
82
|
+
* @param username - Optional username (defaults based on platform)
|
|
83
|
+
* @returns Record of environment variables to set
|
|
84
|
+
*/
|
|
85
|
+
export function getGitCredentialEnv(token, platform, username) {
|
|
86
|
+
const env = {};
|
|
87
|
+
// Set platform-specific tokens that CLI tools and git credential helpers recognize
|
|
88
|
+
if (platform === 'github') {
|
|
89
|
+
// GitHub CLI and many tools recognize these
|
|
90
|
+
env.GH_TOKEN = token;
|
|
91
|
+
env.GITHUB_TOKEN = token;
|
|
92
|
+
}
|
|
93
|
+
else if (platform === 'gitlab') {
|
|
94
|
+
// GitLab CLI and many tools recognize this
|
|
95
|
+
env.GITLAB_TOKEN = token;
|
|
96
|
+
env.GL_TOKEN = token; // Some tools use this
|
|
97
|
+
}
|
|
98
|
+
// Disable interactive prompts - git should fail rather than hang
|
|
99
|
+
env.GIT_TERMINAL_PROMPT = '0';
|
|
100
|
+
// Create a GIT_ASKPASS script that echoes the token
|
|
101
|
+
// This is the most reliable method for HTTPS git auth
|
|
102
|
+
const askpassScript = createCredentialHelperScript(token, platform);
|
|
103
|
+
env.GIT_ASKPASS = askpassScript;
|
|
104
|
+
env._GIT_ASKPASS_CLEANUP = askpassScript; // Store for cleanup
|
|
105
|
+
// Set username for the credential helper
|
|
106
|
+
// GitHub uses 'oauth2' or 'x-access-token' as username for token auth
|
|
107
|
+
// GitLab uses 'oauth2' as well
|
|
108
|
+
const authUsername = username || 'oauth2';
|
|
109
|
+
env.GIT_AUTHOR_NAME = env.GIT_AUTHOR_NAME || authUsername;
|
|
110
|
+
return env;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Clean up any temporary files created by getGitCredentialEnv.
|
|
114
|
+
* Call this after git operations complete.
|
|
115
|
+
*
|
|
116
|
+
* @param env - The environment object returned by getGitCredentialEnv
|
|
117
|
+
*/
|
|
118
|
+
export function cleanupGitCredentialEnv(env) {
|
|
119
|
+
const cleanupPath = env._GIT_ASKPASS_CLEANUP;
|
|
120
|
+
if (cleanupPath) {
|
|
121
|
+
removeCredentialHelperScript(cleanupPath);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Configure git to use token authentication for a specific remote URL.
|
|
126
|
+
* This modifies the URL to include the token inline (for temporary use).
|
|
127
|
+
*
|
|
128
|
+
* @param remoteUrl - The original remote URL (e.g., https://github.com/user/repo.git)
|
|
129
|
+
* @param token - The OAuth access token
|
|
130
|
+
* @param platform - The git platform
|
|
131
|
+
* @returns The modified URL with embedded credentials
|
|
132
|
+
*/
|
|
133
|
+
export function getAuthenticatedRemoteUrl(remoteUrl, token, platform) {
|
|
134
|
+
// Only modify HTTPS URLs
|
|
135
|
+
if (!remoteUrl.startsWith('https://')) {
|
|
136
|
+
return remoteUrl;
|
|
137
|
+
}
|
|
138
|
+
// Insert token into URL: https://oauth2:TOKEN@github.com/user/repo.git
|
|
139
|
+
try {
|
|
140
|
+
const url = new URL(remoteUrl);
|
|
141
|
+
url.username = 'oauth2';
|
|
142
|
+
url.password = token;
|
|
143
|
+
return url.toString();
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
// If URL parsing fails, try simple string replacement
|
|
147
|
+
return remoteUrl.replace('https://', `https://oauth2:${token}@`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Detect the git platform from a remote URL.
|
|
152
|
+
*
|
|
153
|
+
* @param remoteUrl - The remote URL to analyze
|
|
154
|
+
* @returns 'github', 'gitlab', or null if unknown
|
|
155
|
+
*/
|
|
156
|
+
export function detectPlatformFromUrl(remoteUrl) {
|
|
157
|
+
const urlLower = remoteUrl.toLowerCase();
|
|
158
|
+
if (urlLower.includes('github.com') || urlLower.includes('github.')) {
|
|
159
|
+
return 'github';
|
|
160
|
+
}
|
|
161
|
+
if (urlLower.includes('gitlab.com') || urlLower.includes('gitlab.')) {
|
|
162
|
+
return 'gitlab';
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Check if a remote URL is using HTTPS (vs SSH).
|
|
168
|
+
* OAuth tokens only work with HTTPS remotes.
|
|
169
|
+
*
|
|
170
|
+
* @param remoteUrl - The remote URL to check
|
|
171
|
+
* @returns true if the URL is HTTPS
|
|
172
|
+
*/
|
|
173
|
+
export function isHttpsRemote(remoteUrl) {
|
|
174
|
+
return remoteUrl.startsWith('https://') || remoteUrl.startsWith('http://');
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=git-credential-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-credential-helper.js","sourceRoot":"","sources":["../../src/core/git-credential-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACjF,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;;;GAIG;AAEH,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAEhE,+BAA+B;AAC/B,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC1B,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAa,EAAE,QAA6B;IACvF,MAAM,QAAQ,GAAG,UAAU,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;IAC/C,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;IAC7C,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,eAAe,QAAQ,GAAG,SAAS,EAAE,CAAC,CAA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AC/B,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACxB,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC;QACrB,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,sDAAsD;QACtD,OAAO,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE,kBAAkB,KAAK,GAAG,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAiB;IACrD,MAAM,QAAQ,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;IAEzC,IAAI,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACpE,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACpE,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,SAAiB;IAC7C,OAAO,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
export interface SandboxResult {
|
|
2
|
+
branch: string;
|
|
3
|
+
previousBranch: string;
|
|
4
|
+
clean: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface WorktreeResult {
|
|
7
|
+
worktreePath: string;
|
|
8
|
+
branch: string;
|
|
9
|
+
repoPath: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DiffResult {
|
|
12
|
+
patch: string;
|
|
13
|
+
changedFiles: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface BranchOptions {
|
|
16
|
+
prefix?: string;
|
|
17
|
+
summary?: string;
|
|
18
|
+
jobId: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Generate a branch name based on options
|
|
22
|
+
* Format: <prefix>/<summary> (e.g., claudedesk/fix-login-error)
|
|
23
|
+
* Falls back to <prefix>/<jobId-short> if no summary provided
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateBranchName(options: BranchOptions): string;
|
|
26
|
+
export declare class GitSandbox {
|
|
27
|
+
private exec;
|
|
28
|
+
isClean(repoPath: string): boolean;
|
|
29
|
+
getCurrentBranch(repoPath: string): string;
|
|
30
|
+
createSandbox(repoPath: string, branchName: string, skipCleanCheck?: boolean): SandboxResult;
|
|
31
|
+
checkoutExistingBranch(repoPath: string, branch: string): void;
|
|
32
|
+
branchExists(repoPath: string, branch: string): boolean;
|
|
33
|
+
resetAndClean(repoPath: string): void;
|
|
34
|
+
hasChanges(repoPath: string): boolean;
|
|
35
|
+
getChangedFiles(repoPath: string): string[];
|
|
36
|
+
captureDiff(repoPath: string, artifactsPath: string): DiffResult;
|
|
37
|
+
/**
|
|
38
|
+
* Generate a patch file for all changes on a branch compared to main
|
|
39
|
+
* This includes both committed and uncommitted changes
|
|
40
|
+
*/
|
|
41
|
+
generatePatch(repoPath: string, branch?: string): string;
|
|
42
|
+
hasRemote(repoPath: string, remoteName?: string): boolean;
|
|
43
|
+
getMainBranch(repoPath: string): string;
|
|
44
|
+
canMergeCleanly(repoPath: string, branch: string): {
|
|
45
|
+
canMerge: boolean;
|
|
46
|
+
conflictFiles?: string[];
|
|
47
|
+
};
|
|
48
|
+
push(repoPath: string, branch: string, commitMessage?: string): {
|
|
49
|
+
pushed: boolean;
|
|
50
|
+
};
|
|
51
|
+
discard(repoPath: string, branch: string, previousBranch: string): void;
|
|
52
|
+
init(repoPath: string): void;
|
|
53
|
+
/**
|
|
54
|
+
* Create a new worktree for isolated job execution
|
|
55
|
+
* @param repoPath - Path to the main repository
|
|
56
|
+
* @param worktreePath - Path where the worktree should be created
|
|
57
|
+
* @param branchName - Name of the branch to create
|
|
58
|
+
* @returns WorktreeResult with paths and branch info
|
|
59
|
+
*/
|
|
60
|
+
createWorktree(repoPath: string, worktreePath: string, branchName: string): WorktreeResult;
|
|
61
|
+
/**
|
|
62
|
+
* Remove a worktree and optionally its branch
|
|
63
|
+
* @param repoPath - Path to the main repository
|
|
64
|
+
* @param worktreePath - Path to the worktree to remove
|
|
65
|
+
* @param deleteBranch - Branch name to delete (optional)
|
|
66
|
+
*/
|
|
67
|
+
removeWorktree(repoPath: string, worktreePath: string, deleteBranch?: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Check if a worktree exists at the given path
|
|
70
|
+
*/
|
|
71
|
+
worktreeExists(repoPath: string, worktreePath: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Check if a directory is a valid git worktree
|
|
74
|
+
* A valid worktree has a .git file (not directory) that points to the main repo's .git
|
|
75
|
+
* This is useful for detecting corrupted worktrees that exist as directories but aren't valid
|
|
76
|
+
*/
|
|
77
|
+
isValidWorktree(worktreePath: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* List all worktrees for a repository
|
|
80
|
+
*/
|
|
81
|
+
listWorktrees(repoPath: string): string[];
|
|
82
|
+
/**
|
|
83
|
+
* Push changes from a worktree
|
|
84
|
+
* @param worktreePath - Path to the worktree
|
|
85
|
+
* @param repoPath - Path to the main repository (for remote check)
|
|
86
|
+
* @param branch - Branch name to push
|
|
87
|
+
* @param commitMessage - Commit message
|
|
88
|
+
* @returns Object indicating what action was taken and any conflicts
|
|
89
|
+
*/
|
|
90
|
+
pushWorktree(worktreePath: string, repoPath: string, branch: string, commitMessage?: string): {
|
|
91
|
+
pushed: boolean;
|
|
92
|
+
merged: boolean;
|
|
93
|
+
conflict: boolean;
|
|
94
|
+
conflictFiles?: string[];
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Check if the worktree is currently in a merge conflict state
|
|
98
|
+
*/
|
|
99
|
+
isInMergeConflict(worktreePath: string): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Get list of files that have unresolved conflicts
|
|
102
|
+
*/
|
|
103
|
+
getConflictingFiles(worktreePath: string): string[];
|
|
104
|
+
/**
|
|
105
|
+
* Start a merge in the worktree to get into conflict state for resolution
|
|
106
|
+
* This is used when we know there will be conflicts and want to let user resolve them
|
|
107
|
+
*/
|
|
108
|
+
startMergeForResolution(worktreePath: string, repoPath: string): {
|
|
109
|
+
success: boolean;
|
|
110
|
+
conflictFiles: string[];
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Get detailed information about conflicting files
|
|
114
|
+
* Must be called when worktree is in merge conflict state
|
|
115
|
+
*/
|
|
116
|
+
getConflictDetails(worktreePath: string): import('../types.js').ConflictInfo[];
|
|
117
|
+
/**
|
|
118
|
+
* Resolve a single conflicting file using specified strategy
|
|
119
|
+
*/
|
|
120
|
+
resolveConflict(worktreePath: string, filePath: string, strategy: 'ours' | 'theirs'): void;
|
|
121
|
+
/**
|
|
122
|
+
* Resolve all conflicting files using specified strategy
|
|
123
|
+
*/
|
|
124
|
+
resolveAllConflicts(worktreePath: string, strategy: 'ours' | 'theirs'): void;
|
|
125
|
+
/**
|
|
126
|
+
* Abort an ongoing merge and reset to pre-merge state
|
|
127
|
+
*/
|
|
128
|
+
abortMerge(worktreePath: string): void;
|
|
129
|
+
/**
|
|
130
|
+
* Complete a merge after all conflicts are resolved
|
|
131
|
+
*/
|
|
132
|
+
completeMerge(worktreePath: string, commitMessage?: string): void;
|
|
133
|
+
}
|
|
134
|
+
export declare const gitSandbox: GitSandbox;
|
|
135
|
+
//# sourceMappingURL=git-sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-sandbox.d.ts","sourceRoot":"","sources":["../../src/core/git-sandbox.ts"],"names":[],"mappings":"AAmDA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;I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