tarsk 0.3.3 → 0.3.16
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/dist/cli.d.ts +3 -0
- package/dist/cli.js +22 -0
- package/dist/index.js +3 -2
- package/dist/public/assets/{index-DJC-p914.js → index-CLr9LKtA.js} +1679 -1682
- package/dist/public/index.html +1 -1
- package/node_modules/@neovate/code/LICENSE +21 -0
- package/node_modules/@neovate/code/README.md +56 -0
- package/node_modules/@neovate/code/dist/cli.mjs +714 -716
- package/node_modules/@neovate/code/dist/index.d.ts +0 -373
- package/node_modules/@neovate/code/dist/index.mjs +790 -792
- package/node_modules/@neovate/code/package.json +138 -2
- package/node_modules/@neovate/code/vendor/ripgrep/COPYING +3 -0
- package/node_modules/@neovate/code/vendor/ripgrep/arm64-darwin/rg +0 -0
- package/node_modules/@neovate/code/vendor/ripgrep/arm64-linux/rg +0 -0
- package/node_modules/@neovate/code/vendor/ripgrep/x64-darwin/rg +0 -0
- package/node_modules/@neovate/code/vendor/ripgrep/x64-linux/rg +0 -0
- package/node_modules/@neovate/code/vendor/ripgrep/x64-win32/rg.exe +0 -0
- package/package.json +2 -2
- package/dist/managers/ConversationManager.d.ts +0 -83
- package/dist/managers/ConversationManager.js +0 -129
- package/dist/managers/GitManager.d.ts +0 -133
- package/dist/managers/GitManager.js +0 -330
- package/dist/managers/MetadataManager.d.ts +0 -139
- package/dist/managers/MetadataManager.js +0 -309
- package/dist/managers/ModelManager.d.ts +0 -57
- package/dist/managers/ModelManager.js +0 -129
- package/dist/managers/NeovateExecutor.d.ts +0 -40
- package/dist/managers/NeovateExecutor.js +0 -138
- package/dist/managers/ProjectManager.d.ts +0 -162
- package/dist/managers/ProjectManager.js +0 -353
- package/dist/managers/ThreadManager.d.ts +0 -181
- package/dist/managers/ThreadManager.js +0 -325
- package/dist/model-info-openai.d.ts +0 -17
- package/dist/model-info-openai.js +0 -59
- package/dist/public/assets/index-B443aj9k.js +0 -8506
- package/dist/routes/chat-old.d.ts +0 -21
- package/dist/routes/chat-old.js +0 -251
- package/dist/routes/projects-old.d.ts +0 -20
- package/dist/routes/projects-old.js +0 -297
- package/dist/routes/threads-old.d.ts +0 -14
- package/dist/routes/threads-old.js +0 -393
- package/dist/utils/openai-pricing-scraper.d.ts +0 -17
- package/dist/utils/openai-pricing-scraper.js +0 -185
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ProjectManager handles project lifecycle and metadata management
|
|
3
|
-
*
|
|
4
|
-
* This manager is responsible for:
|
|
5
|
-
* - Creating new projects from git URLs
|
|
6
|
-
* - Managing project metadata
|
|
7
|
-
* - Coordinating with GitManager for repository cloning
|
|
8
|
-
* - Providing CRUD operations for projects
|
|
9
|
-
*/
|
|
10
|
-
import { Project, ProjectEvent } from '../types/models.js';
|
|
11
|
-
import { MetadataManager } from './MetadataManager.js';
|
|
12
|
-
import { GitManager } from './GitManager.js';
|
|
13
|
-
/**
|
|
14
|
-
* ProjectManager interface defines the contract for project operations
|
|
15
|
-
*/
|
|
16
|
-
export interface ProjectManager {
|
|
17
|
-
/**
|
|
18
|
-
* Creates a new project from a git URL
|
|
19
|
-
* @param gitUrl - The git repository URL
|
|
20
|
-
* @yields ProjectEvent objects during the creation process
|
|
21
|
-
*/
|
|
22
|
-
createProject(gitUrl: string): AsyncGenerator<ProjectEvent>;
|
|
23
|
-
/**
|
|
24
|
-
* Gets a project by ID
|
|
25
|
-
* @param projectId - The project ID
|
|
26
|
-
* @returns The project or null if not found
|
|
27
|
-
*/
|
|
28
|
-
getProject(projectId: string): Promise<Project | null>;
|
|
29
|
-
/**
|
|
30
|
-
* Lists all projects
|
|
31
|
-
* @returns Array of all projects
|
|
32
|
-
*/
|
|
33
|
-
listProjects(): Promise<Project[]>;
|
|
34
|
-
/**
|
|
35
|
-
* Deletes a project and all its threads
|
|
36
|
-
* @param projectId - The project ID to delete
|
|
37
|
-
*/
|
|
38
|
-
deleteProject(projectId: string): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Opens a project in the specified program
|
|
41
|
-
* @param projectId - The project ID
|
|
42
|
-
* @param program - The program to open the project in
|
|
43
|
-
*/
|
|
44
|
-
openWith(projectId: string, program: string): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Updates the project's open-with program preference
|
|
47
|
-
* @param projectId - The project ID
|
|
48
|
-
* @param program - The program name to set
|
|
49
|
-
*/
|
|
50
|
-
updateOpenWith(projectId: string, program: string): Promise<void>;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* ProjectManagerImpl provides the implementation for project operations
|
|
54
|
-
*/
|
|
55
|
-
export declare class ProjectManagerImpl implements ProjectManager {
|
|
56
|
-
private rootFolder;
|
|
57
|
-
private metadataManager;
|
|
58
|
-
private gitManager;
|
|
59
|
-
/**
|
|
60
|
-
* Create a new ProjectManager
|
|
61
|
-
* @param rootFolder - Base directory where projects will be stored
|
|
62
|
-
* @param metadataManager - Manager for persisting metadata
|
|
63
|
-
* @param gitManager - Manager for git operations
|
|
64
|
-
*
|
|
65
|
-
* Requirements:
|
|
66
|
-
* - 1.1 - WHEN a user provides a git URL to create a new Project, THE CLI SHALL clone the repository into a folder under the Root_Folder
|
|
67
|
-
* - 1.4 - THE CLI SHALL determine the storage path for each Project folder
|
|
68
|
-
*/
|
|
69
|
-
constructor(rootFolder: string, metadataManager: MetadataManager, gitManager: GitManager);
|
|
70
|
-
/**
|
|
71
|
-
* Creates a new project from a git URL
|
|
72
|
-
*
|
|
73
|
-
* This method:
|
|
74
|
-
* 1. Validates the git URL
|
|
75
|
-
* 2. Generates a unique project ID
|
|
76
|
-
* 3. Derives the project name from the git URL
|
|
77
|
-
* 4. Generates the project path
|
|
78
|
-
* 5. Delegates to GitManager for cloning
|
|
79
|
-
* 6. Saves project metadata
|
|
80
|
-
* 7. Yields progress events during the operation
|
|
81
|
-
* 8. Creates an initial thread automatically
|
|
82
|
-
*
|
|
83
|
-
* @param gitUrl - The git repository URL
|
|
84
|
-
* @yields ProjectEvent objects during the creation process
|
|
85
|
-
*
|
|
86
|
-
* Requirements:
|
|
87
|
-
* - 1.1 - WHEN a user provides a git URL to create a new Project, THE CLI SHALL clone the repository into a folder under the Root_Folder
|
|
88
|
-
* - 1.2 - WHEN a Project is created, THE App SHALL display the Project in the Side_Panel with its associated Thread
|
|
89
|
-
* - 1.4 - THE CLI SHALL determine the storage path for each Project folder
|
|
90
|
-
* - 1.5 - WHEN a Project folder is created, THE System SHALL associate it with the provided git URL
|
|
91
|
-
*/
|
|
92
|
-
createProject(gitUrl: string): AsyncGenerator<ProjectEvent>;
|
|
93
|
-
/**
|
|
94
|
-
* Gets a project by ID
|
|
95
|
-
* @param projectId - The project ID
|
|
96
|
-
* @returns The project or null if not found
|
|
97
|
-
*/
|
|
98
|
-
getProject(projectId: string): Promise<Project | null>;
|
|
99
|
-
/**
|
|
100
|
-
* Lists all projects
|
|
101
|
-
* @returns Array of all projects
|
|
102
|
-
*/
|
|
103
|
-
listProjects(): Promise<Project[]>;
|
|
104
|
-
/**
|
|
105
|
-
* Deletes a project and all its threads (cascade delete)
|
|
106
|
-
*
|
|
107
|
-
* This method:
|
|
108
|
-
* 1. Finds the project by ID
|
|
109
|
-
* 2. Removes all associated threads from metadata
|
|
110
|
-
* 3. Removes the project directory from filesystem
|
|
111
|
-
* 4. Removes the project from metadata
|
|
112
|
-
*
|
|
113
|
-
* @param projectId - The project ID to delete
|
|
114
|
-
* @throws Error if project not found
|
|
115
|
-
*
|
|
116
|
-
* Requirements:
|
|
117
|
-
* - 1.1 - Cascade delete for projects (remove all threads)
|
|
118
|
-
*/
|
|
119
|
-
deleteProject(projectId: string): Promise<void>;
|
|
120
|
-
/**
|
|
121
|
-
* Derives a project name from a git URL
|
|
122
|
-
*
|
|
123
|
-
* Examples:
|
|
124
|
-
* - https://github.com/user/repo.git -> repo
|
|
125
|
-
* - https://github.com/user/repo -> repo
|
|
126
|
-
* - git@github.com:user/repo.git -> repo
|
|
127
|
-
*
|
|
128
|
-
* @param gitUrl - The git URL
|
|
129
|
-
* @returns The derived project name
|
|
130
|
-
*/
|
|
131
|
-
private deriveProjectName;
|
|
132
|
-
/**
|
|
133
|
-
* Generates a project path under the root folder
|
|
134
|
-
*
|
|
135
|
-
* @param projectName - The project name
|
|
136
|
-
* @returns The absolute path to the project folder
|
|
137
|
-
*
|
|
138
|
-
* Requirements:
|
|
139
|
-
* - 1.4 - THE CLI SHALL determine the storage path for each Project folder
|
|
140
|
-
*/
|
|
141
|
-
private generateProjectPath;
|
|
142
|
-
/**
|
|
143
|
-
* Gets the root folder path
|
|
144
|
-
* @returns The root folder path
|
|
145
|
-
*/
|
|
146
|
-
getRootFolder(): string;
|
|
147
|
-
/**
|
|
148
|
-
* Opens a project in the specified program
|
|
149
|
-
*
|
|
150
|
-
* @param projectId - The project ID
|
|
151
|
-
* @param program - The program to open the project in (VS Code, Cursor, Windsurf, Xcode, Android Studio, Kiro)
|
|
152
|
-
*/
|
|
153
|
-
openWith(projectId: string, program: string): Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* Updates the project's open-with program preference
|
|
156
|
-
*
|
|
157
|
-
* @param projectId - The project ID
|
|
158
|
-
* @param program - The program name to set
|
|
159
|
-
*/
|
|
160
|
-
updateOpenWith(projectId: string, program: string): Promise<void>;
|
|
161
|
-
}
|
|
162
|
-
//# sourceMappingURL=ProjectManager.d.ts.map
|
|
@@ -1,353 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ProjectManager handles project lifecycle and metadata management
|
|
3
|
-
*
|
|
4
|
-
* This manager is responsible for:
|
|
5
|
-
* - Creating new projects from git URLs
|
|
6
|
-
* - Managing project metadata
|
|
7
|
-
* - Coordinating with GitManager for repository cloning
|
|
8
|
-
* - Providing CRUD operations for projects
|
|
9
|
-
*/
|
|
10
|
-
import { randomUUID } from 'crypto';
|
|
11
|
-
import { join } from 'path';
|
|
12
|
-
/**
|
|
13
|
-
* ProjectManagerImpl provides the implementation for project operations
|
|
14
|
-
*/
|
|
15
|
-
export class ProjectManagerImpl {
|
|
16
|
-
rootFolder;
|
|
17
|
-
metadataManager;
|
|
18
|
-
gitManager;
|
|
19
|
-
/**
|
|
20
|
-
* Create a new ProjectManager
|
|
21
|
-
* @param rootFolder - Base directory where projects will be stored
|
|
22
|
-
* @param metadataManager - Manager for persisting metadata
|
|
23
|
-
* @param gitManager - Manager for git operations
|
|
24
|
-
*
|
|
25
|
-
* Requirements:
|
|
26
|
-
* - 1.1 - WHEN a user provides a git URL to create a new Project, THE CLI SHALL clone the repository into a folder under the Root_Folder
|
|
27
|
-
* - 1.4 - THE CLI SHALL determine the storage path for each Project folder
|
|
28
|
-
*/
|
|
29
|
-
constructor(rootFolder, metadataManager, gitManager) {
|
|
30
|
-
this.rootFolder = rootFolder;
|
|
31
|
-
this.metadataManager = metadataManager;
|
|
32
|
-
this.gitManager = gitManager;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Creates a new project from a git URL
|
|
36
|
-
*
|
|
37
|
-
* This method:
|
|
38
|
-
* 1. Validates the git URL
|
|
39
|
-
* 2. Generates a unique project ID
|
|
40
|
-
* 3. Derives the project name from the git URL
|
|
41
|
-
* 4. Generates the project path
|
|
42
|
-
* 5. Delegates to GitManager for cloning
|
|
43
|
-
* 6. Saves project metadata
|
|
44
|
-
* 7. Yields progress events during the operation
|
|
45
|
-
* 8. Creates an initial thread automatically
|
|
46
|
-
*
|
|
47
|
-
* @param gitUrl - The git repository URL
|
|
48
|
-
* @yields ProjectEvent objects during the creation process
|
|
49
|
-
*
|
|
50
|
-
* Requirements:
|
|
51
|
-
* - 1.1 - WHEN a user provides a git URL to create a new Project, THE CLI SHALL clone the repository into a folder under the Root_Folder
|
|
52
|
-
* - 1.2 - WHEN a Project is created, THE App SHALL display the Project in the Side_Panel with its associated Thread
|
|
53
|
-
* - 1.4 - THE CLI SHALL determine the storage path for each Project folder
|
|
54
|
-
* - 1.5 - WHEN a Project folder is created, THE System SHALL associate it with the provided git URL
|
|
55
|
-
*/
|
|
56
|
-
async *createProject(gitUrl) {
|
|
57
|
-
// Validate git URL
|
|
58
|
-
if (!this.gitManager.validateGitUrl(gitUrl)) {
|
|
59
|
-
yield {
|
|
60
|
-
type: 'error',
|
|
61
|
-
message: `Invalid git URL format: ${gitUrl}`
|
|
62
|
-
};
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
// Generate unique project ID
|
|
67
|
-
const projectId = randomUUID();
|
|
68
|
-
// Derive project name from git URL
|
|
69
|
-
const projectName = this.deriveProjectName(gitUrl);
|
|
70
|
-
// Generate project path
|
|
71
|
-
const projectPath = this.generateProjectPath(projectName);
|
|
72
|
-
yield {
|
|
73
|
-
type: 'progress',
|
|
74
|
-
message: `Creating project "${projectName}" from ${gitUrl}...`
|
|
75
|
-
};
|
|
76
|
-
// Generate unique thread ID for the initial thread
|
|
77
|
-
const initialThreadId = randomUUID();
|
|
78
|
-
const firstThreadPath = join(projectPath, initialThreadId);
|
|
79
|
-
yield {
|
|
80
|
-
type: 'progress',
|
|
81
|
-
message: `Cloning repository to ${firstThreadPath}...`
|
|
82
|
-
};
|
|
83
|
-
// Stream git clone events
|
|
84
|
-
for await (const gitEvent of this.gitManager.cloneRepository(gitUrl, firstThreadPath)) {
|
|
85
|
-
if (gitEvent.type === 'error') {
|
|
86
|
-
yield {
|
|
87
|
-
type: 'error',
|
|
88
|
-
message: `Git clone failed: ${gitEvent.message}`
|
|
89
|
-
};
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
else if (gitEvent.type === 'stdout' || gitEvent.type === 'stderr') {
|
|
93
|
-
yield {
|
|
94
|
-
type: 'progress',
|
|
95
|
-
message: gitEvent.data
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
// Create and checkout branch for initial thread
|
|
100
|
-
const initialThreadTitle = 'Thread 1';
|
|
101
|
-
let branchName = this.gitManager.sanitizeBranchName(initialThreadTitle);
|
|
102
|
-
yield {
|
|
103
|
-
type: 'progress',
|
|
104
|
-
message: `Creating initial branch "${branchName}"...`
|
|
105
|
-
};
|
|
106
|
-
// Check if branch exists and find a unique name if needed
|
|
107
|
-
let branchExists = await this.gitManager.checkBranchExists(firstThreadPath, branchName);
|
|
108
|
-
let counter = 2;
|
|
109
|
-
const baseBranchName = branchName;
|
|
110
|
-
while (branchExists) {
|
|
111
|
-
branchName = `${baseBranchName}-${counter}`;
|
|
112
|
-
branchExists = await this.gitManager.checkBranchExists(firstThreadPath, branchName);
|
|
113
|
-
counter++;
|
|
114
|
-
}
|
|
115
|
-
if (branchName !== baseBranchName) {
|
|
116
|
-
yield {
|
|
117
|
-
type: 'progress',
|
|
118
|
-
message: `Branch "${baseBranchName}" exists, using "${branchName}" instead`
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
// Create and checkout the new branch
|
|
122
|
-
for await (const gitEvent of this.gitManager.createAndCheckoutBranch(firstThreadPath, branchName)) {
|
|
123
|
-
if (gitEvent.type === 'error') {
|
|
124
|
-
yield {
|
|
125
|
-
type: 'error',
|
|
126
|
-
message: `Failed to create initial branch: ${gitEvent.message}`
|
|
127
|
-
};
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
else if (gitEvent.type === 'stdout' || gitEvent.type === 'stderr') {
|
|
131
|
-
yield {
|
|
132
|
-
type: 'progress',
|
|
133
|
-
message: gitEvent.data
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
yield {
|
|
138
|
-
type: 'progress',
|
|
139
|
-
message: `Branch "${branchName}" created and checked out`
|
|
140
|
-
};
|
|
141
|
-
// Create project metadata
|
|
142
|
-
const project = {
|
|
143
|
-
id: projectId,
|
|
144
|
-
name: projectName,
|
|
145
|
-
gitUrl,
|
|
146
|
-
path: projectPath,
|
|
147
|
-
createdAt: new Date(),
|
|
148
|
-
threads: [initialThreadId] // Add initial thread ID
|
|
149
|
-
};
|
|
150
|
-
// Create initial thread metadata
|
|
151
|
-
const initialThread = {
|
|
152
|
-
id: initialThreadId,
|
|
153
|
-
projectId,
|
|
154
|
-
title: initialThreadTitle,
|
|
155
|
-
path: firstThreadPath,
|
|
156
|
-
currentBranch: branchName,
|
|
157
|
-
createdAt: new Date()
|
|
158
|
-
};
|
|
159
|
-
// Save project and thread metadata
|
|
160
|
-
const projects = await this.metadataManager.loadProjects();
|
|
161
|
-
projects.push(project);
|
|
162
|
-
await this.metadataManager.saveProjects(projects);
|
|
163
|
-
const threads = await this.metadataManager.loadThreads();
|
|
164
|
-
threads.push(initialThread);
|
|
165
|
-
await this.metadataManager.saveThreads(threads);
|
|
166
|
-
yield {
|
|
167
|
-
type: 'progress',
|
|
168
|
-
message: `Project "${projectName}" created successfully with initial thread`
|
|
169
|
-
};
|
|
170
|
-
// Yield complete event with project data
|
|
171
|
-
yield {
|
|
172
|
-
type: 'complete',
|
|
173
|
-
message: 'Project creation complete',
|
|
174
|
-
project
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
catch (error) {
|
|
178
|
-
yield {
|
|
179
|
-
type: 'error',
|
|
180
|
-
message: `Failed to create project: ${error instanceof Error ? error.message : String(error)}`
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Gets a project by ID
|
|
186
|
-
* @param projectId - The project ID
|
|
187
|
-
* @returns The project or null if not found
|
|
188
|
-
*/
|
|
189
|
-
async getProject(projectId) {
|
|
190
|
-
const projects = await this.metadataManager.loadProjects();
|
|
191
|
-
return projects.find(p => p.id === projectId) || null;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Lists all projects
|
|
195
|
-
* @returns Array of all projects
|
|
196
|
-
*/
|
|
197
|
-
async listProjects() {
|
|
198
|
-
return await this.metadataManager.loadProjects();
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Deletes a project and all its threads (cascade delete)
|
|
202
|
-
*
|
|
203
|
-
* This method:
|
|
204
|
-
* 1. Finds the project by ID
|
|
205
|
-
* 2. Removes all associated threads from metadata
|
|
206
|
-
* 3. Removes the project directory from filesystem
|
|
207
|
-
* 4. Removes the project from metadata
|
|
208
|
-
*
|
|
209
|
-
* @param projectId - The project ID to delete
|
|
210
|
-
* @throws Error if project not found
|
|
211
|
-
*
|
|
212
|
-
* Requirements:
|
|
213
|
-
* - 1.1 - Cascade delete for projects (remove all threads)
|
|
214
|
-
*/
|
|
215
|
-
async deleteProject(projectId) {
|
|
216
|
-
const projects = await this.metadataManager.loadProjects();
|
|
217
|
-
const projectIndex = projects.findIndex(p => p.id === projectId);
|
|
218
|
-
if (projectIndex === -1) {
|
|
219
|
-
throw new Error(`Project not found: ${projectId}`);
|
|
220
|
-
}
|
|
221
|
-
const project = projects[projectIndex];
|
|
222
|
-
// Load threads and remove all threads associated with this project
|
|
223
|
-
const threads = await this.metadataManager.loadThreads();
|
|
224
|
-
const remainingThreads = threads.filter(t => t.projectId !== projectId);
|
|
225
|
-
await this.metadataManager.saveThreads(remainingThreads);
|
|
226
|
-
// Remove project directory from filesystem
|
|
227
|
-
try {
|
|
228
|
-
const { rm } = await import('fs/promises');
|
|
229
|
-
await rm(project.path, { recursive: true, force: true });
|
|
230
|
-
}
|
|
231
|
-
catch (error) {
|
|
232
|
-
throw new Error(`Failed to remove project directory: ${error instanceof Error ? error.message : String(error)}`);
|
|
233
|
-
}
|
|
234
|
-
// Remove project from metadata
|
|
235
|
-
projects.splice(projectIndex, 1);
|
|
236
|
-
await this.metadataManager.saveProjects(projects);
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Derives a project name from a git URL
|
|
240
|
-
*
|
|
241
|
-
* Examples:
|
|
242
|
-
* - https://github.com/user/repo.git -> repo
|
|
243
|
-
* - https://github.com/user/repo -> repo
|
|
244
|
-
* - git@github.com:user/repo.git -> repo
|
|
245
|
-
*
|
|
246
|
-
* @param gitUrl - The git URL
|
|
247
|
-
* @returns The derived project name
|
|
248
|
-
*/
|
|
249
|
-
deriveProjectName(gitUrl) {
|
|
250
|
-
// Remove .git suffix if present
|
|
251
|
-
let name = gitUrl.replace(/\.git$/, '');
|
|
252
|
-
// Extract the last part of the path
|
|
253
|
-
const parts = name.split(/[/:]/).filter(p => p.length > 0);
|
|
254
|
-
name = parts[parts.length - 1] || 'project';
|
|
255
|
-
// Sanitize the name (remove special characters)
|
|
256
|
-
name = name.replace(/[^a-zA-Z0-9._-]/g, '-');
|
|
257
|
-
return name;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Generates a project path under the root folder
|
|
261
|
-
*
|
|
262
|
-
* @param projectName - The project name
|
|
263
|
-
* @returns The absolute path to the project folder
|
|
264
|
-
*
|
|
265
|
-
* Requirements:
|
|
266
|
-
* - 1.4 - THE CLI SHALL determine the storage path for each Project folder
|
|
267
|
-
*/
|
|
268
|
-
generateProjectPath(projectName) {
|
|
269
|
-
return join(this.rootFolder, projectName);
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Gets the root folder path
|
|
273
|
-
* @returns The root folder path
|
|
274
|
-
*/
|
|
275
|
-
getRootFolder() {
|
|
276
|
-
return this.rootFolder;
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Opens a project in the specified program
|
|
280
|
-
*
|
|
281
|
-
* @param projectId - The project ID
|
|
282
|
-
* @param program - The program to open the project in (VS Code, Cursor, Windsurf, Xcode, Android Studio, Kiro)
|
|
283
|
-
*/
|
|
284
|
-
async openWith(projectId, program) {
|
|
285
|
-
const project = await this.getProject(projectId);
|
|
286
|
-
if (!project) {
|
|
287
|
-
throw new Error(`Project not found: ${projectId}`);
|
|
288
|
-
}
|
|
289
|
-
const { spawn } = await import('child_process');
|
|
290
|
-
const projectPath = project.path;
|
|
291
|
-
let command;
|
|
292
|
-
let args = [];
|
|
293
|
-
switch (program) {
|
|
294
|
-
case 'VS Code':
|
|
295
|
-
command = 'code';
|
|
296
|
-
args = [projectPath];
|
|
297
|
-
break;
|
|
298
|
-
case 'Cursor':
|
|
299
|
-
command = 'cursor';
|
|
300
|
-
args = [projectPath];
|
|
301
|
-
break;
|
|
302
|
-
case 'Windsurf':
|
|
303
|
-
command = 'windsurf';
|
|
304
|
-
args = [projectPath];
|
|
305
|
-
break;
|
|
306
|
-
case 'Xcode':
|
|
307
|
-
command = 'open';
|
|
308
|
-
args = [projectPath, '-a', 'Xcode'];
|
|
309
|
-
break;
|
|
310
|
-
case 'Android Studio':
|
|
311
|
-
command = 'open';
|
|
312
|
-
args = [projectPath, '-a', 'Android Studio'];
|
|
313
|
-
break;
|
|
314
|
-
case 'Kiro':
|
|
315
|
-
command = 'kiro';
|
|
316
|
-
args = [projectPath];
|
|
317
|
-
break;
|
|
318
|
-
default:
|
|
319
|
-
throw new Error(`Unsupported program: ${program}`);
|
|
320
|
-
}
|
|
321
|
-
return new Promise((resolve, reject) => {
|
|
322
|
-
const process = spawn(command, args, {
|
|
323
|
-
detached: true,
|
|
324
|
-
stdio: 'ignore'
|
|
325
|
-
});
|
|
326
|
-
process.on('error', (error) => {
|
|
327
|
-
reject(new Error(`Failed to open ${program}: ${error.message}`));
|
|
328
|
-
});
|
|
329
|
-
// Detach the child process so it doesn't block
|
|
330
|
-
process.unref();
|
|
331
|
-
// Resolve immediately as the IDE will open asynchronously
|
|
332
|
-
resolve();
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Updates the project's open-with program preference
|
|
337
|
-
*
|
|
338
|
-
* @param projectId - The project ID
|
|
339
|
-
* @param program - The program name to set
|
|
340
|
-
*/
|
|
341
|
-
async updateOpenWith(projectId, program) {
|
|
342
|
-
const projects = await this.metadataManager.loadProjects();
|
|
343
|
-
const projectIndex = projects.findIndex(p => p.id === projectId);
|
|
344
|
-
if (projectIndex === -1) {
|
|
345
|
-
throw new Error(`Project not found: ${projectId}`);
|
|
346
|
-
}
|
|
347
|
-
// Update the project's open-with program preference
|
|
348
|
-
projects[projectIndex].openWith = program;
|
|
349
|
-
// Save the updated projects back to metadata
|
|
350
|
-
await this.metadataManager.saveProjects(projects);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
//# sourceMappingURL=ProjectManager.js.map
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ThreadManager handles thread lifecycle and metadata management
|
|
3
|
-
*
|
|
4
|
-
* This manager is responsible for:
|
|
5
|
-
* - Creating new threads for existing projects
|
|
6
|
-
* - Managing thread metadata
|
|
7
|
-
* - Coordinating with GitManager for repository cloning
|
|
8
|
-
* - Providing CRUD operations for threads
|
|
9
|
-
* - Ensuring thread path uniqueness
|
|
10
|
-
*/
|
|
11
|
-
import { Thread, ThreadEvent } from '../types/models.js';
|
|
12
|
-
import { MetadataManager } from './MetadataManager.js';
|
|
13
|
-
import { GitManager } from './GitManager.js';
|
|
14
|
-
/**
|
|
15
|
-
* ThreadManager interface defines the contract for thread operations
|
|
16
|
-
*/
|
|
17
|
-
export interface ThreadManager {
|
|
18
|
-
/**
|
|
19
|
-
* Creates a new thread for an existing project
|
|
20
|
-
* @param projectId - The parent project ID
|
|
21
|
-
* @param title - Optional thread title (auto-generated if not provided)
|
|
22
|
-
* @yields ThreadEvent objects during the creation process
|
|
23
|
-
*/
|
|
24
|
-
createThread(projectId: string, title?: string): AsyncGenerator<ThreadEvent>;
|
|
25
|
-
/**
|
|
26
|
-
* Gets a thread by ID
|
|
27
|
-
* @param threadId - The thread ID
|
|
28
|
-
* @returns The thread or null if not found
|
|
29
|
-
*/
|
|
30
|
-
getThread(threadId: string): Promise<Thread | null>;
|
|
31
|
-
/**
|
|
32
|
-
* Lists all threads for a specific project
|
|
33
|
-
* @param projectId - The project ID to filter threads
|
|
34
|
-
* @returns Array of threads for the project
|
|
35
|
-
*/
|
|
36
|
-
listThreads(projectId: string): Promise<Thread[]>;
|
|
37
|
-
/**
|
|
38
|
-
* Deletes a thread and removes its directory
|
|
39
|
-
* @param threadId - The thread ID to delete
|
|
40
|
-
*/
|
|
41
|
-
deleteThread(threadId: string): Promise<void>;
|
|
42
|
-
/**
|
|
43
|
-
* Updates a thread's metadata with partial data
|
|
44
|
-
* @param threadId - The thread ID to update
|
|
45
|
-
* @param updates - Partial thread data to merge
|
|
46
|
-
*/
|
|
47
|
-
updateThread(threadId: string, updates: Partial<Omit<Thread, 'id'>>): Promise<void>;
|
|
48
|
-
/**
|
|
49
|
-
* Selects a thread as the active thread
|
|
50
|
-
* @param threadId - The thread ID to select
|
|
51
|
-
*/
|
|
52
|
-
selectThread(threadId: string): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Gets the currently selected thread ID
|
|
55
|
-
* @returns The selected thread ID or null
|
|
56
|
-
*/
|
|
57
|
-
getSelectedThreadId(): Promise<string | null>;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* ThreadManagerImpl provides the implementation for thread operations
|
|
61
|
-
*/
|
|
62
|
-
export declare class ThreadManagerImpl implements ThreadManager {
|
|
63
|
-
private metadataManager;
|
|
64
|
-
private gitManager;
|
|
65
|
-
/**
|
|
66
|
-
* Create a new ThreadManager
|
|
67
|
-
* @param metadataManager - Manager for persisting metadata
|
|
68
|
-
* @param gitManager - Manager for git operations
|
|
69
|
-
*
|
|
70
|
-
* Requirements:
|
|
71
|
-
* - 2.1 - WHEN a user creates a new Thread for a Project, THE CLI SHALL create a new clone of the Project's git repository
|
|
72
|
-
* - 2.4 - THE System SHALL maintain a title for each Thread
|
|
73
|
-
*/
|
|
74
|
-
constructor(metadataManager: MetadataManager, gitManager: GitManager);
|
|
75
|
-
/**
|
|
76
|
-
* Creates a new thread for an existing project
|
|
77
|
-
*
|
|
78
|
-
* This method:
|
|
79
|
-
* 1. Validates that the project exists
|
|
80
|
-
* 2. Generates a unique thread ID
|
|
81
|
-
* 3. Gets the project's git URL
|
|
82
|
-
* 4. Generates a unique thread path
|
|
83
|
-
* 5. Delegates to GitManager for cloning
|
|
84
|
-
* 6. Saves thread metadata
|
|
85
|
-
* 7. Updates the project's thread list
|
|
86
|
-
* 8. Yields progress events during the operation
|
|
87
|
-
*
|
|
88
|
-
* @param projectId - The parent project ID
|
|
89
|
-
* @param title - Optional thread title (auto-generated if not provided)
|
|
90
|
-
* @yields ThreadEvent objects during the creation process
|
|
91
|
-
*
|
|
92
|
-
* Requirements:
|
|
93
|
-
* - 2.1 - WHEN a user creates a new Thread for a Project, THE CLI SHALL create a new clone of the Project's git repository
|
|
94
|
-
* - 2.2 - WHEN a Thread is created, THE App SHALL display it under its parent Project in the Side_Panel
|
|
95
|
-
* - 2.4 - THE System SHALL maintain a title for each Thread
|
|
96
|
-
* - 7.4 - THE CLI SHALL ensure each Thread clone is stored in a unique directory path
|
|
97
|
-
*/
|
|
98
|
-
createThread(projectId: string, title?: string): AsyncGenerator<ThreadEvent>;
|
|
99
|
-
/**
|
|
100
|
-
* Gets a thread by ID
|
|
101
|
-
* @param threadId - The thread ID
|
|
102
|
-
* @returns The thread or null if not found
|
|
103
|
-
*/
|
|
104
|
-
getThread(threadId: string): Promise<Thread | null>;
|
|
105
|
-
/**
|
|
106
|
-
* Lists all threads for a specific project
|
|
107
|
-
* @param projectId - The project ID to filter threads
|
|
108
|
-
* @returns Array of threads for the project
|
|
109
|
-
*
|
|
110
|
-
* Requirements:
|
|
111
|
-
* - 2.1 - WHEN a Thread is created, THE App SHALL display it under its parent Project in the Side_Panel
|
|
112
|
-
*/
|
|
113
|
-
listThreads(projectId: string): Promise<Thread[]>;
|
|
114
|
-
/**
|
|
115
|
-
* Deletes a thread and removes its directory
|
|
116
|
-
*
|
|
117
|
-
* This method:
|
|
118
|
-
* 1. Finds the thread by ID
|
|
119
|
-
* 2. Removes the thread directory from filesystem
|
|
120
|
-
* 3. Removes the thread from metadata
|
|
121
|
-
* 4. Updates the parent project's thread list
|
|
122
|
-
*
|
|
123
|
-
* @param threadId - The thread ID to delete
|
|
124
|
-
* @throws Error if thread not found
|
|
125
|
-
*
|
|
126
|
-
* Requirements:
|
|
127
|
-
* - 2.3 - WHEN a user deletes a Thread, THE System SHALL remove the Thread's folder and update the Side_Panel display
|
|
128
|
-
* - 7.5 - WHEN a Thread is deleted, THE CLI SHALL remove the associated git repository clone from the filesystem
|
|
129
|
-
*/
|
|
130
|
-
deleteThread(threadId: string): Promise<void>;
|
|
131
|
-
/**
|
|
132
|
-
* Updates a thread's metadata with partial data
|
|
133
|
-
*
|
|
134
|
-
* This method loads all threads, finds the target, merges the updates,
|
|
135
|
-
* and persists the result.
|
|
136
|
-
*
|
|
137
|
-
* @param threadId - The thread ID to update
|
|
138
|
-
* @param updates - Partial thread data to merge
|
|
139
|
-
* @throws Error if thread not found
|
|
140
|
-
*/
|
|
141
|
-
updateThread(threadId: string, updates: Partial<Omit<Thread, 'id'>>): Promise<void>;
|
|
142
|
-
/**
|
|
143
|
-
* Selects a thread as the active thread
|
|
144
|
-
*
|
|
145
|
-
* @param threadId - The thread ID to select
|
|
146
|
-
*/
|
|
147
|
-
selectThread(threadId: string): Promise<void>;
|
|
148
|
-
/**
|
|
149
|
-
* Gets the currently selected thread ID
|
|
150
|
-
*
|
|
151
|
-
* @returns The selected thread ID or null
|
|
152
|
-
*/
|
|
153
|
-
getSelectedThreadId(): Promise<string | null>;
|
|
154
|
-
/**
|
|
155
|
-
* Generates a unique thread path
|
|
156
|
-
*
|
|
157
|
-
* Path format: {projectPath}/{threadId}
|
|
158
|
-
*
|
|
159
|
-
* This ensures thread paths are unique across all projects and threads.
|
|
160
|
-
*
|
|
161
|
-
* @param projectPath - The parent project path
|
|
162
|
-
* @param threadId - The thread ID
|
|
163
|
-
* @returns The absolute path to the thread folder
|
|
164
|
-
*
|
|
165
|
-
* Requirements:
|
|
166
|
-
* - 7.4 - THE CLI SHALL ensure each Thread clone is stored in a unique directory path
|
|
167
|
-
*/
|
|
168
|
-
private generateThreadPath;
|
|
169
|
-
/**
|
|
170
|
-
* Generates a thread title if not provided
|
|
171
|
-
*
|
|
172
|
-
* Format: project-name Thread word1-word2
|
|
173
|
-
*
|
|
174
|
-
* @param existingTitles - Set of titles already in use
|
|
175
|
-
* @param threadId - Thread ID used as a fallback
|
|
176
|
-
* @param projectName - Optional project name to include in title
|
|
177
|
-
* @returns The generated thread title
|
|
178
|
-
*/
|
|
179
|
-
private generateThreadTitle;
|
|
180
|
-
}
|
|
181
|
-
//# sourceMappingURL=ThreadManager.d.ts.map
|