@edgedive/cli 0.1.8 → 0.2.1
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/.env +2 -0
- package/.env.local +2 -0
- package/.turbo/turbo-build.log +4 -5
- package/.turbo/turbo-dev.log +3 -3
- package/.turbo/turbo-typecheck.log +1 -1
- package/dist/commands/local.d.ts +2 -1
- package/dist/commands/local.d.ts.map +1 -1
- package/dist/commands/local.js +17 -9
- package/dist/commands/local.js.map +1 -1
- package/dist/commands/takeover.d.ts +10 -0
- package/dist/commands/takeover.d.ts.map +1 -0
- package/dist/commands/takeover.js +108 -0
- package/dist/commands/takeover.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/git-utils.d.ts +5 -0
- package/dist/utils/git-utils.d.ts.map +1 -1
- package/dist/utils/git-utils.js +59 -0
- package/dist/utils/git-utils.js.map +1 -1
- package/package.json +1 -1
- package/src/api/client.ts +44 -0
- package/src/commands/local.ts +76 -15
- package/src/constants.ts +1 -1
- package/src/index.ts +15 -3
- package/src/utils/git-utils.ts +66 -0
package/.env
ADDED
package/.env.local
ADDED
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
|
|
2
|
+
> @edgedive/cli@0.2.0 build /Users/nimesh/edgedive/nimesh-workstream-3/packages/edgedive-cli
|
|
3
|
+
> tsc
|
|
4
|
+
|
package/.turbo/turbo-dev.log
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @edgedive/cli@0.
|
|
2
|
+
> @edgedive/cli@0.2.0 dev /Users/nimesh/edgedive/edgedive-monorepo/packages/edgedive-cli
|
|
3
3
|
> tsc --watch
|
|
4
4
|
|
|
5
|
-
[2J[3J[H[[
|
|
5
|
+
[2J[3J[H[[90m12:59:03 AM[0m] Starting compilation in watch mode...
|
|
6
6
|
|
|
7
|
-
[[
|
|
7
|
+
[[90m12:59:04 AM[0m] Found 0 errors. Watching for file changes.
|
|
8
8
|
|
package/dist/commands/local.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ interface LocalOptions {
|
|
|
5
5
|
prUrl?: string;
|
|
6
6
|
issueUrl?: string;
|
|
7
7
|
threadUrl?: string;
|
|
8
|
+
worktree?: boolean;
|
|
8
9
|
}
|
|
9
|
-
export declare function localCommand({ prUrl, issueUrl, threadUrl }: LocalOptions): Promise<void>;
|
|
10
|
+
export declare function localCommand({ prUrl, issueUrl, threadUrl, worktree, }: LocalOptions): Promise<void>;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=local.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/commands/local.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,UAAU,YAAY;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/commands/local.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,UAAU,YAAY;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAsB,YAAY,CAAC,EACjC,KAAK,EACL,QAAQ,EACR,SAAS,EACT,QAAQ,GACT,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA8K9B"}
|
package/dist/commands/local.js
CHANGED
|
@@ -7,7 +7,7 @@ import { EdgediveApiClient } from '../api/client.js';
|
|
|
7
7
|
import { SessionDownloader } from '../utils/session-downloader.js';
|
|
8
8
|
import { GitUtils } from '../utils/git-utils.js';
|
|
9
9
|
import { launchClaudeSession } from '../utils/claude-launcher.js';
|
|
10
|
-
export async function localCommand({ prUrl, issueUrl, threadUrl }) {
|
|
10
|
+
export async function localCommand({ prUrl, issueUrl, threadUrl, worktree, }) {
|
|
11
11
|
const configManager = new ConfigManager();
|
|
12
12
|
const apiClient = new EdgediveApiClient(configManager);
|
|
13
13
|
const downloader = new SessionDownloader();
|
|
@@ -89,21 +89,29 @@ export async function localCommand({ prUrl, issueUrl, threadUrl }) {
|
|
|
89
89
|
process.exit(1);
|
|
90
90
|
}
|
|
91
91
|
console.log(chalk.green(`✅ Using repository at ${repoInfo.rootPath}`));
|
|
92
|
-
//
|
|
93
|
-
|
|
94
|
-
// Ensure PR branch is checked out locally
|
|
92
|
+
// Ensure PR branch is checked out locally or in a worktree
|
|
93
|
+
let workingPath = repoInfo.rootPath;
|
|
95
94
|
try {
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
if (worktree) {
|
|
96
|
+
workingPath = await GitUtils.ensureBranchInWorktree(sessionData.repository.branch, repoInfo.rootPath);
|
|
97
|
+
console.log(chalk.green(`✅ Created worktree for branch ${sessionData.repository.branch} at ${workingPath}`));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
await GitUtils.ensureBranchCheckedOut(sessionData.repository.branch, repoInfo.rootPath);
|
|
101
|
+
console.log(chalk.green(`✅ Checked out branch ${sessionData.repository.branch}`));
|
|
102
|
+
}
|
|
98
103
|
}
|
|
99
104
|
catch (error) {
|
|
100
|
-
console.error(chalk.red(`\n❌ Failed to checkout branch ${sessionData.repository.branch}: ${error.message}\n`));
|
|
105
|
+
console.error(chalk.red(`\n❌ Failed to ${worktree ? 'create worktree for' : 'checkout'} branch ${sessionData.repository.branch}: ${error.message}\n`));
|
|
101
106
|
console.log(chalk.yellow('Resolve the git issue above and rerun the local command.'));
|
|
102
107
|
process.exit(1);
|
|
103
108
|
}
|
|
109
|
+
// Download session files into Claude projects directory
|
|
110
|
+
// Use workingPath so the session goes to the correct directory (worktree path if --worktree is used)
|
|
111
|
+
const { claudeSessionId, claudeSessionPath } = await downloader.downloadSession(sessionData, workingPath);
|
|
104
112
|
console.log(chalk.blue(`\n🚀 Launching Claude session ${claudeSessionId}...\n`));
|
|
105
113
|
try {
|
|
106
|
-
const sessionEndInfo = await launchClaudeSession(claudeSessionId,
|
|
114
|
+
const sessionEndInfo = await launchClaudeSession(claudeSessionId, workingPath);
|
|
107
115
|
console.log(chalk.green('\n✅ Claude session closed. Happy debugging!\n'));
|
|
108
116
|
// Upload Claude session file back to server
|
|
109
117
|
// Use the session info from the SessionEnd hook if available, otherwise fall back to original path
|
|
@@ -111,7 +119,7 @@ export async function localCommand({ prUrl, issueUrl, threadUrl }) {
|
|
|
111
119
|
}
|
|
112
120
|
catch (error) {
|
|
113
121
|
console.error(chalk.red(`\n❌ Failed to start Claude automatically: ${error.message}\n`));
|
|
114
|
-
console.log(chalk.yellow(`You can resume manually with: claude -r ${claudeSessionId} (from ${
|
|
122
|
+
console.log(chalk.yellow(`You can resume manually with: claude -r ${claudeSessionId} (from ${workingPath})`));
|
|
115
123
|
process.exit(1);
|
|
116
124
|
}
|
|
117
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/commands/local.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAyB,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/commands/local.ts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|
+
issueUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function takeoverCommand({ prUrl, issueUrl }: TakeoverOptions): Promise<void>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=takeover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"takeover.d.ts","sourceRoot":"","sources":["../../src/commands/takeover.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,UAAU,eAAe;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,eAAe,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA6HzF"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Takeover command - download agent session for local development
|
|
3
|
+
*/
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { ConfigManager } from '../config/config-manager.js';
|
|
6
|
+
import { EdgediveApiClient } from '../api/client.js';
|
|
7
|
+
import { SessionDownloader } from '../utils/session-downloader.js';
|
|
8
|
+
import { GitUtils } from '../utils/git-utils.js';
|
|
9
|
+
import { launchClaudeSession } from '../utils/claude-launcher.js';
|
|
10
|
+
export async function takeoverCommand({ prUrl, issueUrl }) {
|
|
11
|
+
const configManager = new ConfigManager();
|
|
12
|
+
const apiClient = new EdgediveApiClient(configManager);
|
|
13
|
+
const downloader = new SessionDownloader();
|
|
14
|
+
try {
|
|
15
|
+
console.log(chalk.bold('\n🔧 Edgedive Session Takeover\n'));
|
|
16
|
+
// Check for Windows platform
|
|
17
|
+
if (process.platform === 'win32') {
|
|
18
|
+
console.log(chalk.red('❌ Windows is not currently supported for the takeover command.\n'));
|
|
19
|
+
console.log(chalk.yellow('Please use macOS or Linux to takeover agent sessions.\n'));
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
// Check if authenticated
|
|
23
|
+
if (!(await configManager.isAuthenticated())) {
|
|
24
|
+
console.log(chalk.red('❌ You are not logged in.\n'));
|
|
25
|
+
console.log(chalk.yellow('Please run: edgedive login\n'));
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
if (!prUrl && !issueUrl) {
|
|
29
|
+
console.log(chalk.red('❌ Missing takeover identifier.\n'));
|
|
30
|
+
console.log(chalk.yellow('Provide either --pr-url https://github.com/owner/repo/pull/123 or --issue-url https://linear.app/...\n'));
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
let takeoverData;
|
|
34
|
+
if (prUrl) {
|
|
35
|
+
// Validate PR URL format
|
|
36
|
+
const prUrlPattern = /^https?:\/\/github\.com\/([^\/]+)\/([^\/]+)\/pull\/(\d+)/;
|
|
37
|
+
if (!prUrlPattern.test(prUrl)) {
|
|
38
|
+
console.log(chalk.red('❌ Invalid PR URL format.\n'));
|
|
39
|
+
console.log(chalk.yellow('Expected format: https://github.com/owner/repo/pull/123\n'));
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
console.log(chalk.dim(`PR URL: ${prUrl}\n`));
|
|
43
|
+
console.log('🔍 Fetching session information...\n');
|
|
44
|
+
takeoverData = await apiClient.getTakeoverByPrUrl(prUrl);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
console.log(chalk.dim(`Linear Issue URL: ${issueUrl}\n`));
|
|
48
|
+
console.log('🔍 Fetching session information...\n');
|
|
49
|
+
takeoverData = await apiClient.getTakeoverByLinearIssueUrl(issueUrl);
|
|
50
|
+
}
|
|
51
|
+
console.log(chalk.green('✅ Found agent session!\n'));
|
|
52
|
+
if (takeoverData.github_pr?.url) {
|
|
53
|
+
console.log(chalk.dim(`PR URL: ${takeoverData.github_pr.url}`));
|
|
54
|
+
}
|
|
55
|
+
console.log(chalk.bold('Session Information:'));
|
|
56
|
+
console.log(chalk.dim(` Session ID: ${takeoverData.session_id}`));
|
|
57
|
+
console.log(chalk.dim(` Agent Type: ${takeoverData.agent_type}`));
|
|
58
|
+
console.log(chalk.dim(` Status: ${takeoverData.status}`));
|
|
59
|
+
console.log(chalk.dim(` Repository: ${takeoverData.repository.owner}/${takeoverData.repository.name}`));
|
|
60
|
+
console.log(chalk.dim(` Branch: ${takeoverData.repository.branch}`));
|
|
61
|
+
if (takeoverData.linear_issue) {
|
|
62
|
+
console.log(chalk.dim(` Linear Issue: ${takeoverData.linear_issue.identifier}`));
|
|
63
|
+
console.log(chalk.dim(` Linear URL: ${takeoverData.linear_issue.url}`));
|
|
64
|
+
}
|
|
65
|
+
// Verify current repository matches PR source
|
|
66
|
+
const cwd = process.cwd();
|
|
67
|
+
let repoInfo;
|
|
68
|
+
try {
|
|
69
|
+
repoInfo = await GitUtils.verifyRepoMatches(takeoverData.repository.owner, takeoverData.repository.name, cwd);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console.error(chalk.red(`\n❌ ${error.message}\n`));
|
|
73
|
+
console.log(chalk.yellow('Run this command from within the target repository checked out locally.'));
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
console.log(chalk.green(`✅ Using repository at ${repoInfo.rootPath}`));
|
|
77
|
+
// Download session files into Claude projects directory
|
|
78
|
+
const { claudeSessionId, claudeSessionPath } = await downloader.downloadSession(takeoverData, repoInfo.rootPath);
|
|
79
|
+
// Ensure PR branch is checked out locally
|
|
80
|
+
try {
|
|
81
|
+
await GitUtils.ensureBranchCheckedOut(takeoverData.repository.branch, repoInfo.rootPath);
|
|
82
|
+
console.log(chalk.green(`✅ Checked out branch ${takeoverData.repository.branch}`));
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
console.error(chalk.red(`\n❌ Failed to checkout branch ${takeoverData.repository.branch}: ${error.message}\n`));
|
|
86
|
+
console.log(chalk.yellow('Resolve the git issue above and rerun the takeover command.'));
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
console.log(chalk.blue(`\n🚀 Launching Claude session ${claudeSessionId}...\n`));
|
|
90
|
+
try {
|
|
91
|
+
await launchClaudeSession(claudeSessionId, repoInfo.rootPath);
|
|
92
|
+
console.log(chalk.green('\n✅ Claude session closed. Happy debugging!\n'));
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
console.error(chalk.red(`\n❌ Failed to start Claude automatically: ${error.message}\n`));
|
|
96
|
+
console.log(chalk.yellow(`You can resume manually with: claude -r ${claudeSessionId} (from ${repoInfo.rootPath})`));
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
console.error(chalk.red(`\n❌ Takeover failed: ${error.message}\n`));
|
|
102
|
+
if (error.message.includes('401') || error.message.includes('Unauthorized')) {
|
|
103
|
+
console.log(chalk.yellow('Your session may have expired. Please run: edgedive login\n'));
|
|
104
|
+
}
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=takeover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"takeover.js","sourceRoot":"","sources":["../../src/commands/takeover.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAOlE,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAmB;IACxE,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;IAC1C,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC,a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AAC,MAAM,CACV,2CAA2C,eAAe,UAAU,QAAQ,CAAC,QAAQ,GAAG,CACzF,CACF,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,wBAAwB,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;QAEpE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YAC5E,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,6DAA6D,CAAC,CAAC,CAAC;QAC3F,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ program
|
|
|
34
34
|
.option('--pr-url <prUrl>', 'GitHub PR URL to load locally')
|
|
35
35
|
.option('--issue-url <issueUrl>', 'Linear issue URL to load locally')
|
|
36
36
|
.option('--thread-url <threadUrl>', 'Slack thread URL to load locally')
|
|
37
|
+
.option('--worktree', 'Create branch in a worktree instead of checking out')
|
|
37
38
|
.action(async (options) => {
|
|
38
39
|
await localCommand(options);
|
|
39
40
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAA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 -6,5 +6,10 @@ export declare class GitUtils {
|
|
|
6
6
|
static getRepoRoot(cwd: string): Promise<string>;
|
|
7
7
|
static verifyRepoMatches(expectedOwner: string, expectedName: string, cwd: string): Promise<RepoVerification>;
|
|
8
8
|
static ensureBranchCheckedOut(branch: string, rootPath: string): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Ensure a branch exists in a git worktree at a sibling directory.
|
|
11
|
+
* Returns the path to the worktree.
|
|
12
|
+
*/
|
|
13
|
+
static ensureBranchInWorktree(branch: string, rootPath: string): Promise<string>;
|
|
9
14
|
}
|
|
10
15
|
//# sourceMappingURL=git-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-utils.d.ts","sourceRoot":"","sources":["../../src/utils/git-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"git-utils.d.ts","sourceRoot":"","sources":["../../src/utils/git-utils.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAuBD,qBAAa,QAAQ;WACN,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAIzC,iBAAiB,CAC5B,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,gBAAgB,CAAC;WAuBf,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkDpF;;;OAGG;WACU,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CA2DvF"}
|
package/dist/utils/git-utils.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { promisify } from 'util';
|
|
2
2
|
import { exec as execCb } from 'child_process';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import * as fs from 'fs/promises';
|
|
3
5
|
const exec = promisify(execCb);
|
|
4
6
|
function parseGithubRemote(remoteUrl) {
|
|
5
7
|
const patterns = [/github\.com[:/](?<owner>[^/]+)\/(?<repo>[^/.]+)(?:\.git)?$/];
|
|
@@ -82,5 +84,62 @@ export class GitUtils {
|
|
|
82
84
|
await runGit(`checkout -b ${branch}`, rootPath);
|
|
83
85
|
}
|
|
84
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Ensure a branch exists in a git worktree at a sibling directory.
|
|
89
|
+
* Returns the path to the worktree.
|
|
90
|
+
*/
|
|
91
|
+
static async ensureBranchInWorktree(branch, rootPath) {
|
|
92
|
+
// Sanitize branch name for directory: replace slashes with dashes
|
|
93
|
+
const sanitizedBranchName = branch.replace(/\//g, '-');
|
|
94
|
+
// Calculate worktree path as sibling directory
|
|
95
|
+
const parentDir = path.dirname(rootPath);
|
|
96
|
+
const worktreePath = path.join(parentDir, sanitizedBranchName);
|
|
97
|
+
// Check if worktree already exists
|
|
98
|
+
try {
|
|
99
|
+
await fs.access(worktreePath);
|
|
100
|
+
// Worktree directory exists, verify it's a valid git worktree
|
|
101
|
+
try {
|
|
102
|
+
await runGit('rev-parse --git-dir', worktreePath);
|
|
103
|
+
// It's a valid git directory, return the path
|
|
104
|
+
return worktreePath;
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// Directory exists but is not a git worktree
|
|
108
|
+
throw new Error(`Directory ${worktreePath} already exists but is not a git worktree. ` +
|
|
109
|
+
`Please remove it or choose a different branch name.`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
// Worktree doesn't exist, we'll create it
|
|
114
|
+
}
|
|
115
|
+
// Check if local branch exists
|
|
116
|
+
const localBranchExists = await exec(`git rev-parse --verify ${branch}`, { cwd: rootPath })
|
|
117
|
+
.then(() => true)
|
|
118
|
+
.catch(() => false);
|
|
119
|
+
// Try to fetch from remote
|
|
120
|
+
let remoteBranchExists = false;
|
|
121
|
+
try {
|
|
122
|
+
await runGit(`fetch origin ${branch}`, rootPath);
|
|
123
|
+
await runGit(`rev-parse --verify origin/${branch}`, rootPath);
|
|
124
|
+
remoteBranchExists = true;
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
remoteBranchExists = false;
|
|
128
|
+
}
|
|
129
|
+
// Create worktree based on what exists
|
|
130
|
+
if (localBranchExists) {
|
|
131
|
+
// Local branch exists, create worktree from it
|
|
132
|
+
await runGit(`worktree add "${worktreePath}" ${branch}`, rootPath);
|
|
133
|
+
}
|
|
134
|
+
else if (remoteBranchExists) {
|
|
135
|
+
// Remote branch exists, create worktree tracking it
|
|
136
|
+
await runGit(`worktree add --track -b ${branch} "${worktreePath}" origin/${branch}`, rootPath);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
// Neither exists, create new branch in worktree from current HEAD
|
|
140
|
+
await runGit(`worktree add -b ${branch} "${worktreePath}"`, rootPath);
|
|
141
|
+
}
|
|
142
|
+
return worktreePath;
|
|
143
|
+
}
|
|
85
144
|
}
|
|
86
145
|
//# sourceMappingURL=git-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-utils.js","sourceRoot":"","sources":["../../src/utils/git-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"git-utils.js","sourceRoot":"","sources":["../../src/utils/git-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAElC,MAAM,IAAI,GAA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+27,10 @@ export interface TakeoverResponse {
|
|
|
27
27
|
identifier: string;
|
|
28
28
|
url: string;
|
|
29
29
|
};
|
|
30
|
+
asana_task?: {
|
|
31
|
+
gid: string;
|
|
32
|
+
url: string;
|
|
33
|
+
};
|
|
30
34
|
status: string;
|
|
31
35
|
agent_type: string;
|
|
32
36
|
download_urls: {
|
|
@@ -136,6 +140,46 @@ export class EdgediveApiClient {
|
|
|
136
140
|
}
|
|
137
141
|
}
|
|
138
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Get session takeover information by Asana task URL
|
|
145
|
+
*/
|
|
146
|
+
async getTakeoverByAsanaTaskUrl(asanaTaskUrl: string): Promise<TakeoverResponse> {
|
|
147
|
+
try {
|
|
148
|
+
const response = await this.client.get<TakeoverResponse>(API_CONFIG.TAKEOVER_PATH, {
|
|
149
|
+
params: {
|
|
150
|
+
asana_task_url: asanaTaskUrl,
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
return response.data;
|
|
154
|
+
} catch (error: any) {
|
|
155
|
+
if (error.response) {
|
|
156
|
+
const errorData = error.response.data;
|
|
157
|
+
throw new Error(errorData?.error || `API request failed: ${error.response.status}`);
|
|
158
|
+
}
|
|
159
|
+
throw new Error(`API request failed: ${error.message}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Get session takeover information by session URL (share link)
|
|
165
|
+
*/
|
|
166
|
+
async getTakeoverBySessionUrl(sessionUrl: string): Promise<TakeoverResponse> {
|
|
167
|
+
try {
|
|
168
|
+
const response = await this.client.get<TakeoverResponse>(API_CONFIG.TAKEOVER_PATH, {
|
|
169
|
+
params: {
|
|
170
|
+
session_url: sessionUrl,
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
return response.data;
|
|
174
|
+
} catch (error: any) {
|
|
175
|
+
if (error.response) {
|
|
176
|
+
const errorData = error.response.data;
|
|
177
|
+
throw new Error(errorData?.error || `API request failed: ${error.response.status}`);
|
|
178
|
+
}
|
|
179
|
+
throw new Error(`API request failed: ${error.message}`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
139
183
|
/**
|
|
140
184
|
* Upload Claude session file for an agent session
|
|
141
185
|
*/
|
package/src/commands/local.ts
CHANGED
|
@@ -13,9 +13,19 @@ interface LocalOptions {
|
|
|
13
13
|
prUrl?: string;
|
|
14
14
|
issueUrl?: string;
|
|
15
15
|
threadUrl?: string;
|
|
16
|
+
taskUrl?: string;
|
|
17
|
+
sessionUrl?: string;
|
|
18
|
+
worktree?: boolean;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
export async function localCommand({
|
|
21
|
+
export async function localCommand({
|
|
22
|
+
prUrl,
|
|
23
|
+
issueUrl,
|
|
24
|
+
threadUrl,
|
|
25
|
+
taskUrl,
|
|
26
|
+
sessionUrl,
|
|
27
|
+
worktree,
|
|
28
|
+
}: LocalOptions): Promise<void> {
|
|
19
29
|
const configManager = new ConfigManager();
|
|
20
30
|
const apiClient = new EdgediveApiClient(configManager);
|
|
21
31
|
const downloader = new SessionDownloader();
|
|
@@ -37,14 +47,16 @@ export async function localCommand({ prUrl, issueUrl, threadUrl }: LocalOptions)
|
|
|
37
47
|
process.exit(1);
|
|
38
48
|
}
|
|
39
49
|
|
|
40
|
-
if (!prUrl && !issueUrl && !threadUrl) {
|
|
50
|
+
if (!prUrl && !issueUrl && !threadUrl && !taskUrl && !sessionUrl) {
|
|
41
51
|
console.log(chalk.red('❌ Missing session identifier.\n'));
|
|
42
52
|
console.log(
|
|
43
53
|
chalk.yellow(
|
|
44
54
|
'Provide one of:\n' +
|
|
45
55
|
' --pr-url https://github.com/owner/repo/pull/123\n' +
|
|
46
56
|
' --issue-url https://linear.app/...\n' +
|
|
47
|
-
' --thread-url https://workspace.slack.com/archives/C12345/p1234567890123456\n'
|
|
57
|
+
' --thread-url https://workspace.slack.com/archives/C12345/p1234567890123456\n' +
|
|
58
|
+
' --task-url https://app.asana.com/0/PROJECT_ID/TASK_ID\n' +
|
|
59
|
+
' --session-url https://app.edgedive.com/agent-sessions?session={session_id}\n'
|
|
48
60
|
)
|
|
49
61
|
);
|
|
50
62
|
process.exit(1);
|
|
@@ -68,6 +80,37 @@ export async function localCommand({ prUrl, issueUrl, threadUrl }: LocalOptions)
|
|
|
68
80
|
console.log(chalk.dim(`Linear Issue URL: ${issueUrl}\n`));
|
|
69
81
|
console.log('🔍 Fetching session information...\n');
|
|
70
82
|
sessionData = await apiClient.getTakeoverByLinearIssueUrl(issueUrl);
|
|
83
|
+
} else if (taskUrl) {
|
|
84
|
+
// Validate it's an Asana URL — let the server handle detailed format parsing
|
|
85
|
+
const asanaTaskPattern = /^https?:\/\/app\.asana\.com\//;
|
|
86
|
+
if (!asanaTaskPattern.test(taskUrl)) {
|
|
87
|
+
console.log(
|
|
88
|
+
chalk.red(
|
|
89
|
+
'❌ Invalid Asana task URL. Expected a URL starting with https://app.asana.com/\n'
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
console.log(chalk.dim(`Asana Task URL: ${taskUrl}\n`));
|
|
96
|
+
console.log('🔍 Fetching session information...\n');
|
|
97
|
+
sessionData = await apiClient.getTakeoverByAsanaTaskUrl(taskUrl);
|
|
98
|
+
} else if (sessionUrl) {
|
|
99
|
+
// Validate session URL format
|
|
100
|
+
const sessionUrlPattern = /^https?:\/\/[^\/]+\/agent-sessions\?session=([a-f0-9-]+)/i;
|
|
101
|
+
if (!sessionUrlPattern.test(sessionUrl)) {
|
|
102
|
+
console.log(chalk.red('❌ Invalid session URL format.\n'));
|
|
103
|
+
console.log(
|
|
104
|
+
chalk.yellow(
|
|
105
|
+
'Expected format: https://app.edgedive.com/agent-sessions?session={session_id}\n'
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
console.log(chalk.dim(`Session URL: ${sessionUrl}\n`));
|
|
112
|
+
console.log('🔍 Fetching session information...\n');
|
|
113
|
+
sessionData = await apiClient.getTakeoverBySessionUrl(sessionUrl);
|
|
71
114
|
} else {
|
|
72
115
|
// Validate Slack thread URL format
|
|
73
116
|
const slackThreadPattern = /^https?:\/\/[^\/]+\.slack\.com\/archives\/([A-Z0-9]+)\/p(\d{16})/;
|
|
@@ -104,6 +147,10 @@ export async function localCommand({ prUrl, issueUrl, threadUrl }: LocalOptions)
|
|
|
104
147
|
console.log(chalk.dim(` Linear URL: ${sessionData.linear_issue.url}`));
|
|
105
148
|
}
|
|
106
149
|
|
|
150
|
+
if (sessionData.asana_task) {
|
|
151
|
+
console.log(chalk.dim(` Asana Task: ${sessionData.asana_task.url}`));
|
|
152
|
+
}
|
|
153
|
+
|
|
107
154
|
// Verify current repository matches PR source
|
|
108
155
|
const cwd = process.cwd();
|
|
109
156
|
let repoInfo;
|
|
@@ -124,30 +171,44 @@ export async function localCommand({ prUrl, issueUrl, threadUrl }: LocalOptions)
|
|
|
124
171
|
|
|
125
172
|
console.log(chalk.green(`✅ Using repository at ${repoInfo.rootPath}`));
|
|
126
173
|
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
sessionData,
|
|
130
|
-
repoInfo.rootPath
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
// Ensure PR branch is checked out locally
|
|
174
|
+
// Ensure PR branch is checked out locally or in a worktree
|
|
175
|
+
let workingPath = repoInfo.rootPath;
|
|
134
176
|
try {
|
|
135
|
-
|
|
136
|
-
|
|
177
|
+
if (worktree) {
|
|
178
|
+
workingPath = await GitUtils.ensureBranchInWorktree(
|
|
179
|
+
sessionData.repository.branch,
|
|
180
|
+
repoInfo.rootPath
|
|
181
|
+
);
|
|
182
|
+
console.log(
|
|
183
|
+
chalk.green(
|
|
184
|
+
`✅ Created worktree for branch ${sessionData.repository.branch} at ${workingPath}`
|
|
185
|
+
)
|
|
186
|
+
);
|
|
187
|
+
} else {
|
|
188
|
+
await GitUtils.ensureBranchCheckedOut(sessionData.repository.branch, repoInfo.rootPath);
|
|
189
|
+
console.log(chalk.green(`✅ Checked out branch ${sessionData.repository.branch}`));
|
|
190
|
+
}
|
|
137
191
|
} catch (error: any) {
|
|
138
192
|
console.error(
|
|
139
193
|
chalk.red(
|
|
140
|
-
`\n❌ Failed to checkout branch ${sessionData.repository.branch}: ${error.message}\n`
|
|
194
|
+
`\n❌ Failed to ${worktree ? 'create worktree for' : 'checkout'} branch ${sessionData.repository.branch}: ${error.message}\n`
|
|
141
195
|
)
|
|
142
196
|
);
|
|
143
197
|
console.log(chalk.yellow('Resolve the git issue above and rerun the local command.'));
|
|
144
198
|
process.exit(1);
|
|
145
199
|
}
|
|
146
200
|
|
|
201
|
+
// Download session files into Claude projects directory
|
|
202
|
+
// Use workingPath so the session goes to the correct directory (worktree path if --worktree is used)
|
|
203
|
+
const { claudeSessionId, claudeSessionPath } = await downloader.downloadSession(
|
|
204
|
+
sessionData,
|
|
205
|
+
workingPath
|
|
206
|
+
);
|
|
207
|
+
|
|
147
208
|
console.log(chalk.blue(`\n🚀 Launching Claude session ${claudeSessionId}...\n`));
|
|
148
209
|
|
|
149
210
|
try {
|
|
150
|
-
const sessionEndInfo = await launchClaudeSession(claudeSessionId,
|
|
211
|
+
const sessionEndInfo = await launchClaudeSession(claudeSessionId, workingPath);
|
|
151
212
|
console.log(chalk.green('\n✅ Claude session closed. Happy debugging!\n'));
|
|
152
213
|
|
|
153
214
|
// Upload Claude session file back to server
|
|
@@ -161,7 +222,7 @@ export async function localCommand({ prUrl, issueUrl, threadUrl }: LocalOptions)
|
|
|
161
222
|
console.error(chalk.red(`\n❌ Failed to start Claude automatically: ${error.message}\n`));
|
|
162
223
|
console.log(
|
|
163
224
|
chalk.yellow(
|
|
164
|
-
`You can resume manually with: claude -r ${claudeSessionId} (from ${
|
|
225
|
+
`You can resume manually with: claude -r ${claudeSessionId} (from ${workingPath})`
|
|
165
226
|
)
|
|
166
227
|
);
|
|
167
228
|
process.exit(1);
|
package/src/constants.ts
CHANGED
|
@@ -13,7 +13,7 @@ export const OAUTH_CONFIG = {
|
|
|
13
13
|
|
|
14
14
|
// API configuration
|
|
15
15
|
export const API_CONFIG = {
|
|
16
|
-
BASE_URL: 'https://api.edgedive.com',
|
|
16
|
+
BASE_URL: process.env.EDGEDIVE_API_URL || 'https://api.edgedive.com',
|
|
17
17
|
AUTHORIZE_PATH: '/api/oauth/authorize',
|
|
18
18
|
TOKEN_PATH: '/api/oauth/token',
|
|
19
19
|
TAKEOVER_PATH: '/api/agents/agent-sessions/takeover',
|
package/src/index.ts
CHANGED
|
@@ -43,8 +43,20 @@ program
|
|
|
43
43
|
.option('--pr-url <prUrl>', 'GitHub PR URL to load locally')
|
|
44
44
|
.option('--issue-url <issueUrl>', 'Linear issue URL to load locally')
|
|
45
45
|
.option('--thread-url <threadUrl>', 'Slack thread URL to load locally')
|
|
46
|
-
.
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
.option('--task-url <taskUrl>', 'Asana task URL to load locally')
|
|
47
|
+
.option('--session-url <sessionUrl>', 'Session share URL to load locally')
|
|
48
|
+
.option('--worktree', 'Create branch in a worktree instead of checking out')
|
|
49
|
+
.action(
|
|
50
|
+
async (options: {
|
|
51
|
+
prUrl?: string;
|
|
52
|
+
issueUrl?: string;
|
|
53
|
+
threadUrl?: string;
|
|
54
|
+
taskUrl?: string;
|
|
55
|
+
sessionUrl?: string;
|
|
56
|
+
worktree?: boolean;
|
|
57
|
+
}) => {
|
|
58
|
+
await localCommand(options);
|
|
59
|
+
}
|
|
60
|
+
);
|
|
49
61
|
|
|
50
62
|
program.parse();
|
package/src/utils/git-utils.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { promisify } from 'util';
|
|
2
2
|
import { exec as execCb } from 'child_process';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import * as fs from 'fs/promises';
|
|
3
5
|
|
|
4
6
|
const exec = promisify(execCb);
|
|
5
7
|
|
|
@@ -110,4 +112,68 @@ export class GitUtils {
|
|
|
110
112
|
await runGit(`checkout -b ${branch}`, rootPath);
|
|
111
113
|
}
|
|
112
114
|
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Ensure a branch exists in a git worktree at a sibling directory.
|
|
118
|
+
* Returns the path to the worktree.
|
|
119
|
+
*/
|
|
120
|
+
static async ensureBranchInWorktree(branch: string, rootPath: string): Promise<string> {
|
|
121
|
+
// Sanitize branch name for directory: replace slashes with dashes
|
|
122
|
+
const sanitizedBranchName = branch.replace(/\//g, '-');
|
|
123
|
+
|
|
124
|
+
// Calculate worktree path as sibling directory
|
|
125
|
+
const parentDir = path.dirname(rootPath);
|
|
126
|
+
const worktreePath = path.join(parentDir, sanitizedBranchName);
|
|
127
|
+
|
|
128
|
+
// Check if worktree already exists
|
|
129
|
+
try {
|
|
130
|
+
await fs.access(worktreePath);
|
|
131
|
+
// Worktree directory exists, verify it's a valid git worktree
|
|
132
|
+
try {
|
|
133
|
+
await runGit('rev-parse --git-dir', worktreePath);
|
|
134
|
+
// It's a valid git directory, return the path
|
|
135
|
+
return worktreePath;
|
|
136
|
+
} catch {
|
|
137
|
+
// Directory exists but is not a git worktree
|
|
138
|
+
throw new Error(
|
|
139
|
+
`Directory ${worktreePath} already exists but is not a git worktree. ` +
|
|
140
|
+
`Please remove it or choose a different branch name.`
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
} catch {
|
|
144
|
+
// Worktree doesn't exist, we'll create it
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Check if local branch exists
|
|
148
|
+
const localBranchExists = await exec(`git rev-parse --verify ${branch}`, { cwd: rootPath })
|
|
149
|
+
.then(() => true)
|
|
150
|
+
.catch(() => false);
|
|
151
|
+
|
|
152
|
+
// Try to fetch from remote
|
|
153
|
+
let remoteBranchExists = false;
|
|
154
|
+
try {
|
|
155
|
+
await runGit(`fetch origin ${branch}`, rootPath);
|
|
156
|
+
await runGit(`rev-parse --verify origin/${branch}`, rootPath);
|
|
157
|
+
remoteBranchExists = true;
|
|
158
|
+
} catch {
|
|
159
|
+
remoteBranchExists = false;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Create worktree based on what exists
|
|
163
|
+
if (localBranchExists) {
|
|
164
|
+
// Local branch exists, create worktree from it
|
|
165
|
+
await runGit(`worktree add "${worktreePath}" ${branch}`, rootPath);
|
|
166
|
+
} else if (remoteBranchExists) {
|
|
167
|
+
// Remote branch exists, create worktree tracking it
|
|
168
|
+
await runGit(
|
|
169
|
+
`worktree add --track -b ${branch} "${worktreePath}" origin/${branch}`,
|
|
170
|
+
rootPath
|
|
171
|
+
);
|
|
172
|
+
} else {
|
|
173
|
+
// Neither exists, create new branch in worktree from current HEAD
|
|
174
|
+
await runGit(`worktree add -b ${branch} "${worktreePath}"`, rootPath);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return worktreePath;
|
|
178
|
+
}
|
|
113
179
|
}
|