@edgedive/cli 0.1.5 → 0.1.7
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 +1 -1
- package/.turbo/turbo-clean.log +4 -0
- package/.turbo/turbo-dev.log +8 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/AGENTS.md +135 -0
- package/CLAUDE.md +2 -134
- package/README.md +69 -0
- package/dist/api/client.d.ts +2 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +23 -1
- package/dist/api/client.js.map +1 -1
- package/dist/auth/oauth-flow.d.ts +5 -0
- package/dist/auth/oauth-flow.d.ts.map +1 -1
- package/dist/auth/oauth-flow.js +41 -0
- package/dist/auth/oauth-flow.js.map +1 -1
- package/dist/auth/pkce.js +1 -5
- package/dist/auth/pkce.js.map +1 -1
- package/dist/commands/local.d.ts.map +1 -1
- 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/config/config-manager.d.ts +10 -1
- package/dist/config/config-manager.d.ts.map +1 -1
- package/dist/config/config-manager.js +25 -11
- package/dist/config/config-manager.js.map +1 -1
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -12
- package/dist/constants.js.map +1 -1
- package/dist/utils/claude-launcher.js +1 -1
- package/dist/utils/claude-launcher.js.map +1 -1
- package/dist/utils/git-utils.d.ts.map +1 -1
- package/dist/utils/git-utils.js +1 -3
- package/dist/utils/git-utils.js.map +1 -1
- package/dist/utils/session-downloader.d.ts.map +1 -1
- package/dist/utils/session-downloader.js.map +1 -1
- package/package.json +3 -2
- package/src/api/client.ts +26 -10
- package/src/auth/oauth-flow.ts +53 -0
- package/src/auth/pkce.ts +1 -5
- package/src/commands/local.ts +17 -7
- package/src/config/config-manager.ts +29 -17
- package/src/constants.ts +0 -13
- package/src/utils/claude-launcher.ts +1 -1
- package/src/utils/git-utils.ts +2 -8
- package/src/utils/session-downloader.ts +1 -6
- package/.claude/settings.local.json +0 -9
|
@@ -12,6 +12,7 @@ export interface EdgediveConfig {
|
|
|
12
12
|
tokenType?: string;
|
|
13
13
|
expiresAt?: number;
|
|
14
14
|
scope?: string;
|
|
15
|
+
refreshToken?: string;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export class ConfigManager {
|
|
@@ -45,11 +46,7 @@ export class ConfigManager {
|
|
|
45
46
|
try {
|
|
46
47
|
const configDir = path.dirname(this.configPath);
|
|
47
48
|
await fs.mkdir(configDir, { recursive: true, mode: 0o700 });
|
|
48
|
-
await fs.writeFile(
|
|
49
|
-
this.configPath,
|
|
50
|
-
JSON.stringify(config, null, 2),
|
|
51
|
-
{ mode: 0o600 }
|
|
52
|
-
);
|
|
49
|
+
await fs.writeFile(this.configPath, JSON.stringify(config, null, 2), { mode: 0o600 });
|
|
53
50
|
} catch (error: any) {
|
|
54
51
|
throw new Error(`Failed to save config: ${error.message}`);
|
|
55
52
|
}
|
|
@@ -73,30 +70,45 @@ export class ConfigManager {
|
|
|
73
70
|
*/
|
|
74
71
|
async isAuthenticated(): Promise<boolean> {
|
|
75
72
|
const config = await this.load();
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
|
|
74
|
+
// If we have an access token that's not expired, we're authenticated
|
|
75
|
+
if (config.accessToken && (!config.expiresAt || config.expiresAt > Date.now())) {
|
|
76
|
+
return true;
|
|
78
77
|
}
|
|
79
78
|
|
|
80
|
-
//
|
|
81
|
-
if (config.
|
|
82
|
-
return
|
|
79
|
+
// If we have a refresh token, we can refresh, so consider authenticated
|
|
80
|
+
if (config.refreshToken) {
|
|
81
|
+
return true;
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
return
|
|
84
|
+
return false;
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
/**
|
|
89
|
-
* Get access token
|
|
88
|
+
* Get access token (even if expired - let the API client handle refresh)
|
|
90
89
|
*/
|
|
91
90
|
async getAccessToken(): Promise<string | null> {
|
|
92
91
|
const config = await this.load();
|
|
92
|
+
return config.accessToken || null;
|
|
93
|
+
}
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Get refresh token
|
|
97
|
+
*/
|
|
98
|
+
async getRefreshToken(): Promise<string | null> {
|
|
99
|
+
const config = await this.load();
|
|
100
|
+
return config.refreshToken || null;
|
|
101
|
+
}
|
|
98
102
|
|
|
99
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Check if token is expired or will expire soon (within 5 minutes)
|
|
105
|
+
*/
|
|
106
|
+
isTokenExpiringSoon(config: EdgediveConfig): boolean {
|
|
107
|
+
if (!config.expiresAt) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
// Consider token expiring if less than 5 minutes remaining
|
|
111
|
+
return config.expiresAt < Date.now() + 5 * 60 * 1000;
|
|
100
112
|
}
|
|
101
113
|
|
|
102
114
|
/**
|
package/src/constants.ts
CHANGED
|
@@ -4,19 +4,6 @@ import 'dotenv/config';
|
|
|
4
4
|
* Edgedive CLI Constants
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
// Validate required environment variables
|
|
8
|
-
const getRequiredEnv = (key: string, fallback?: string): string => {
|
|
9
|
-
const value = process.env[key];
|
|
10
|
-
if (!value) {
|
|
11
|
-
if (fallback) {
|
|
12
|
-
console.warn(`Warning: ${key} not set, using default: ${fallback}`);
|
|
13
|
-
return fallback;
|
|
14
|
-
}
|
|
15
|
-
throw new Error(`Missing required environment variable: ${key}`);
|
|
16
|
-
}
|
|
17
|
-
return value;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
7
|
// OAuth configuration
|
|
21
8
|
export const OAUTH_CONFIG = {
|
|
22
9
|
CLIENT_ID: 'edgedive-cli',
|
|
@@ -45,7 +45,7 @@ export async function launchClaudeSession(
|
|
|
45
45
|
await new Promise<void>((resolve, reject) => {
|
|
46
46
|
const shell = getUserShell();
|
|
47
47
|
// Set the CLAUDE_SESSION_END_HOOK environment variable to our hook script
|
|
48
|
-
const child = spawn(shell, ['-i', '-c', `claude -r ${claudeSessionId}`], {
|
|
48
|
+
const child = spawn(shell, ['-i', '-c', `claude -r ${claudeSessionId} --settings '{"includeCoAuthoredBy": false}'`], {
|
|
49
49
|
cwd: workspacePath,
|
|
50
50
|
stdio: 'inherit',
|
|
51
51
|
env: {
|
package/src/utils/git-utils.ts
CHANGED
|
@@ -9,9 +9,7 @@ export interface RepoVerification {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
function parseGithubRemote(remoteUrl: string): { owner: string; repo: string } | null {
|
|
12
|
-
const patterns = [
|
|
13
|
-
/github\.com[:/](?<owner>[^/]+)\/(?<repo>[^/.]+)(?:\.git)?$/,
|
|
14
|
-
];
|
|
12
|
+
const patterns = [/github\.com[:/](?<owner>[^/]+)\/(?<repo>[^/.]+)(?:\.git)?$/];
|
|
15
13
|
|
|
16
14
|
for (const pattern of patterns) {
|
|
17
15
|
const match = remoteUrl.match(pattern);
|
|
@@ -63,10 +61,7 @@ export class GitUtils {
|
|
|
63
61
|
return { rootPath, remoteUrl };
|
|
64
62
|
}
|
|
65
63
|
|
|
66
|
-
static async ensureBranchCheckedOut(
|
|
67
|
-
branch: string,
|
|
68
|
-
rootPath: string
|
|
69
|
-
): Promise<void> {
|
|
64
|
+
static async ensureBranchCheckedOut(branch: string, rootPath: string): Promise<void> {
|
|
70
65
|
// Get current branch
|
|
71
66
|
const currentBranch = await runGit('rev-parse --abbrev-ref HEAD', rootPath);
|
|
72
67
|
|
|
@@ -116,4 +111,3 @@ export class GitUtils {
|
|
|
116
111
|
}
|
|
117
112
|
}
|
|
118
113
|
}
|
|
119
|
-
|
|
@@ -17,12 +17,7 @@ export class SessionDownloader {
|
|
|
17
17
|
private getClaudeProjectDir(workspacePath: string): string {
|
|
18
18
|
const homeDir = os.homedir();
|
|
19
19
|
const sanitized = this.sanitizeWorkspacePath(workspacePath);
|
|
20
|
-
return path.join(
|
|
21
|
-
homeDir,
|
|
22
|
-
LOCAL_CONFIG.CLAUDE_DIR,
|
|
23
|
-
LOCAL_CONFIG.CLAUDE_PROJECTS_DIR,
|
|
24
|
-
sanitized
|
|
25
|
-
);
|
|
20
|
+
return path.join(homeDir, LOCAL_CONFIG.CLAUDE_DIR, LOCAL_CONFIG.CLAUDE_PROJECTS_DIR, sanitized);
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
private async downloadFile(url: string, targetPath: string): Promise<void> {
|