cyrus-ai 0.2.5 → 0.2.6

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.
@@ -1,28 +0,0 @@
1
- import type { Issue } from "@linear/sdk";
2
- import type { RepositoryConfig } from "cyrus-core";
3
- import type { Workspace } from "../config/types.js";
4
- import type { Logger } from "./Logger.js";
5
- /**
6
- * Service responsible for Git worktree operations
7
- */
8
- export declare class GitService {
9
- private logger;
10
- constructor(logger: Logger);
11
- /**
12
- * Check if a branch exists locally or remotely
13
- */
14
- branchExists(branchName: string, repoPath: string): Promise<boolean>;
15
- /**
16
- * Sanitize branch name by removing backticks to prevent command injection
17
- */
18
- private sanitizeBranchName;
19
- /**
20
- * Run a setup script with proper error handling and logging
21
- */
22
- private runSetupScript;
23
- /**
24
- * Create a git worktree for an issue
25
- */
26
- createGitWorktree(issue: Issue, repository: RepositoryConfig, globalSetupScript?: string): Promise<Workspace>;
27
- }
28
- //# sourceMappingURL=GitService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GitService.d.ts","sourceRoot":"","sources":["../../../src/services/GitService.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;GAEG;AACH,qBAAa,UAAU;IACV,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAClC;;OAEG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA0B1E;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAI1B;;OAEG;YACW,cAAc;IA4F5B;;OAEG;IACG,iBAAiB,CACtB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,gBAAgB,EAC5B,iBAAiB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,SAAS,CAAC;CAoRrB"}
@@ -1,339 +0,0 @@
1
- import { execSync } from "node:child_process";
2
- import { existsSync, mkdirSync, statSync } from "node:fs";
3
- import { homedir } from "node:os";
4
- import { basename, join } from "node:path";
5
- /**
6
- * Service responsible for Git worktree operations
7
- */
8
- export class GitService {
9
- logger;
10
- constructor(logger) {
11
- this.logger = logger;
12
- }
13
- /**
14
- * Check if a branch exists locally or remotely
15
- */
16
- async branchExists(branchName, repoPath) {
17
- try {
18
- // Check if branch exists locally
19
- execSync(`git rev-parse --verify "${branchName}"`, {
20
- cwd: repoPath,
21
- stdio: "pipe",
22
- });
23
- return true;
24
- }
25
- catch {
26
- // Branch doesn't exist locally, check remote
27
- try {
28
- const remoteOutput = execSync(`git ls-remote --heads origin "${branchName}"`, {
29
- cwd: repoPath,
30
- stdio: "pipe",
31
- });
32
- // Check if output is non-empty (branch actually exists on remote)
33
- return remoteOutput && remoteOutput.toString().trim().length > 0;
34
- }
35
- catch {
36
- return false;
37
- }
38
- }
39
- }
40
- /**
41
- * Sanitize branch name by removing backticks to prevent command injection
42
- */
43
- sanitizeBranchName(name) {
44
- return name ? name.replace(/`/g, "") : name;
45
- }
46
- /**
47
- * Run a setup script with proper error handling and logging
48
- */
49
- async runSetupScript(scriptPath, scriptType, workspacePath, issue) {
50
- // Expand ~ to home directory
51
- const expandedPath = scriptPath.replace(/^~/, homedir());
52
- // Check if script exists
53
- if (!existsSync(expandedPath)) {
54
- this.logger.warn(`⚠️ ${scriptType === "global" ? "Global" : "Repository"} setup script not found: ${scriptPath}`);
55
- return;
56
- }
57
- // Check if script is executable (Unix only)
58
- if (process.platform !== "win32") {
59
- try {
60
- const stats = statSync(expandedPath);
61
- // Check if file has execute permission for the owner
62
- if (!(stats.mode & 0o100)) {
63
- this.logger.warn(`⚠️ ${scriptType === "global" ? "Global" : "Repository"} setup script is not executable: ${scriptPath}`);
64
- this.logger.warn(` Run: chmod +x "${expandedPath}"`);
65
- return;
66
- }
67
- }
68
- catch (error) {
69
- this.logger.warn(`⚠️ Cannot check permissions for ${scriptType} setup script: ${error.message}`);
70
- return;
71
- }
72
- }
73
- const scriptName = basename(expandedPath);
74
- this.logger.info(`ℹ️ Running ${scriptType} setup script: ${scriptName}`);
75
- try {
76
- // Determine the command based on the script extension and platform
77
- let command;
78
- const isWindows = process.platform === "win32";
79
- if (scriptPath.endsWith(".ps1")) {
80
- command = `powershell -ExecutionPolicy Bypass -File "${expandedPath}"`;
81
- }
82
- else if (scriptPath.endsWith(".cmd") || scriptPath.endsWith(".bat")) {
83
- command = `"${expandedPath}"`;
84
- }
85
- else if (isWindows) {
86
- // On Windows, try to run with bash if available (Git Bash/WSL)
87
- command = `bash "${expandedPath}"`;
88
- }
89
- else {
90
- // On Unix, run directly with bash
91
- command = `bash "${expandedPath}"`;
92
- }
93
- execSync(command, {
94
- cwd: workspacePath,
95
- stdio: "inherit",
96
- env: {
97
- ...process.env,
98
- LINEAR_ISSUE_ID: issue.id,
99
- LINEAR_ISSUE_IDENTIFIER: issue.identifier,
100
- LINEAR_ISSUE_TITLE: issue.title || "",
101
- },
102
- timeout: 5 * 60 * 1000, // 5 minute timeout
103
- });
104
- this.logger.info(`✅ ${scriptType === "global" ? "Global" : "Repository"} setup script completed successfully`);
105
- }
106
- catch (error) {
107
- const errorMessage = error.signal === "SIGTERM"
108
- ? "Script execution timed out (exceeded 5 minutes)"
109
- : error.message;
110
- this.logger.error(`❌ ${scriptType === "global" ? "Global" : "Repository"} setup script failed: ${errorMessage}`);
111
- // Log stderr if available
112
- if (error.stderr) {
113
- this.logger.error(" stderr:", error.stderr.toString());
114
- }
115
- // Continue execution despite setup script failure
116
- this.logger.info(` Continuing with worktree creation...`);
117
- }
118
- }
119
- /**
120
- * Create a git worktree for an issue
121
- */
122
- async createGitWorktree(issue, repository, globalSetupScript) {
123
- try {
124
- // Verify this is a git repository
125
- try {
126
- execSync("git rev-parse --git-dir", {
127
- cwd: repository.repositoryPath,
128
- stdio: "pipe",
129
- });
130
- }
131
- catch (_e) {
132
- this.logger.error(`${repository.repositoryPath} is not a git repository`);
133
- throw new Error("Not a git repository");
134
- }
135
- // Use Linear's preferred branch name, or generate one if not available
136
- const rawBranchName = issue.branchName ||
137
- `${issue.identifier}-${issue.title
138
- ?.toLowerCase()
139
- .replace(/\s+/g, "-")
140
- .substring(0, 30)}`;
141
- const branchName = this.sanitizeBranchName(rawBranchName);
142
- const workspacePath = join(repository.workspaceBaseDir, issue.identifier);
143
- // Ensure workspace directory exists
144
- mkdirSync(repository.workspaceBaseDir, { recursive: true });
145
- // Check if worktree already exists
146
- try {
147
- const worktrees = execSync("git worktree list --porcelain", {
148
- cwd: repository.repositoryPath,
149
- encoding: "utf-8",
150
- });
151
- if (worktrees.includes(workspacePath)) {
152
- this.logger.info(`Worktree already exists at ${workspacePath}, using existing`);
153
- return {
154
- path: workspacePath,
155
- isGitWorktree: true,
156
- };
157
- }
158
- }
159
- catch (_e) {
160
- // git worktree command failed, continue with creation
161
- }
162
- // Check if branch already exists
163
- let createBranch = true;
164
- try {
165
- execSync(`git rev-parse --verify "${branchName}"`, {
166
- cwd: repository.repositoryPath,
167
- stdio: "pipe",
168
- });
169
- createBranch = false;
170
- }
171
- catch (_e) {
172
- // Branch doesn't exist, we'll create it
173
- }
174
- // Determine base branch for this issue
175
- let baseBranch = repository.baseBranch;
176
- // Check if issue has a parent
177
- try {
178
- const parent = await issue.parent;
179
- if (parent) {
180
- this.logger.info(`Issue ${issue.identifier} has parent: ${parent.identifier}`);
181
- // Get parent's branch name
182
- const parentRawBranchName = parent.branchName ||
183
- `${parent.identifier}-${parent.title
184
- ?.toLowerCase()
185
- .replace(/\s+/g, "-")
186
- .substring(0, 30)}`;
187
- const parentBranchName = this.sanitizeBranchName(parentRawBranchName);
188
- // Check if parent branch exists
189
- const parentBranchExists = await this.branchExists(parentBranchName, repository.repositoryPath);
190
- if (parentBranchExists) {
191
- baseBranch = parentBranchName;
192
- this.logger.info(`Using parent issue branch '${parentBranchName}' as base for sub-issue ${issue.identifier}`);
193
- }
194
- else {
195
- this.logger.info(`Parent branch '${parentBranchName}' not found, using default base branch '${repository.baseBranch}'`);
196
- }
197
- }
198
- }
199
- catch (_error) {
200
- // Parent field might not exist or couldn't be fetched, use default base branch
201
- this.logger.info(`No parent issue found for ${issue.identifier}, using default base branch '${repository.baseBranch}'`);
202
- }
203
- // Fetch latest changes from remote
204
- this.logger.info("Fetching latest changes from remote...");
205
- let hasRemote = true;
206
- try {
207
- execSync("git fetch origin", {
208
- cwd: repository.repositoryPath,
209
- stdio: "pipe",
210
- });
211
- }
212
- catch (e) {
213
- this.logger.warn("Warning: git fetch failed, proceeding with local branch:", e.message);
214
- hasRemote = false;
215
- }
216
- // Create the worktree - use determined base branch
217
- let worktreeCmd;
218
- if (createBranch) {
219
- if (hasRemote) {
220
- // Check if the base branch exists remotely
221
- let useRemoteBranch = false;
222
- try {
223
- const remoteOutput = execSync(`git ls-remote --heads origin "${baseBranch}"`, {
224
- cwd: repository.repositoryPath,
225
- stdio: "pipe",
226
- });
227
- // Check if output is non-empty (branch actually exists on remote)
228
- useRemoteBranch =
229
- remoteOutput && remoteOutput.toString().trim().length > 0;
230
- if (!useRemoteBranch) {
231
- this.logger.info(`Base branch '${baseBranch}' not found on remote, checking locally...`);
232
- }
233
- }
234
- catch {
235
- // Base branch doesn't exist remotely, use local or fall back to default
236
- this.logger.info(`Base branch '${baseBranch}' not found on remote, checking locally...`);
237
- }
238
- if (useRemoteBranch) {
239
- // Use remote version of base branch
240
- const remoteBranch = `origin/${baseBranch}`;
241
- this.logger.info(`Creating git worktree at ${workspacePath} from ${remoteBranch}`);
242
- worktreeCmd = `git worktree add "${workspacePath}" -b "${branchName}" "${remoteBranch}"`;
243
- }
244
- else {
245
- // Check if base branch exists locally
246
- try {
247
- execSync(`git rev-parse --verify "${baseBranch}"`, {
248
- cwd: repository.repositoryPath,
249
- stdio: "pipe",
250
- });
251
- // Use local base branch
252
- this.logger.info(`Creating git worktree at ${workspacePath} from local ${baseBranch}`);
253
- worktreeCmd = `git worktree add "${workspacePath}" -b "${branchName}" "${baseBranch}"`;
254
- }
255
- catch {
256
- // Base branch doesn't exist locally either, fall back to remote default
257
- this.logger.info(`Base branch '${baseBranch}' not found locally, falling back to remote ${repository.baseBranch}`);
258
- const defaultRemoteBranch = `origin/${repository.baseBranch}`;
259
- worktreeCmd = `git worktree add "${workspacePath}" -b "${branchName}" "${defaultRemoteBranch}"`;
260
- }
261
- }
262
- }
263
- else {
264
- // No remote, use local branch
265
- this.logger.info(`Creating git worktree at ${workspacePath} from local ${baseBranch}`);
266
- worktreeCmd = `git worktree add "${workspacePath}" -b "${branchName}" "${baseBranch}"`;
267
- }
268
- }
269
- else {
270
- // Branch already exists, just check it out
271
- this.logger.info(`Creating git worktree at ${workspacePath} with existing branch ${branchName}`);
272
- worktreeCmd = `git worktree add "${workspacePath}" "${branchName}"`;
273
- }
274
- execSync(worktreeCmd, {
275
- cwd: repository.repositoryPath,
276
- stdio: "pipe",
277
- });
278
- // First, run the global setup script if configured
279
- if (globalSetupScript) {
280
- await this.runSetupScript(globalSetupScript, "global", workspacePath, issue);
281
- }
282
- // Then, check for repository setup scripts (cross-platform)
283
- const isWindows = process.platform === "win32";
284
- const setupScripts = [
285
- {
286
- file: "cyrus-setup.sh",
287
- platform: "unix",
288
- },
289
- {
290
- file: "cyrus-setup.ps1",
291
- platform: "windows",
292
- },
293
- {
294
- file: "cyrus-setup.cmd",
295
- platform: "windows",
296
- },
297
- {
298
- file: "cyrus-setup.bat",
299
- platform: "windows",
300
- },
301
- ];
302
- // Find the first available setup script for the current platform
303
- const availableScript = setupScripts.find((script) => {
304
- const scriptPath = join(repository.repositoryPath, script.file);
305
- const isCompatible = isWindows
306
- ? script.platform === "windows"
307
- : script.platform === "unix";
308
- return existsSync(scriptPath) && isCompatible;
309
- });
310
- // Fallback: on Windows, try bash if no Windows scripts found (for Git Bash/WSL users)
311
- const fallbackScript = !availableScript && isWindows
312
- ? setupScripts.find((script) => {
313
- const scriptPath = join(repository.repositoryPath, script.file);
314
- return script.platform === "unix" && existsSync(scriptPath);
315
- })
316
- : null;
317
- const scriptToRun = availableScript || fallbackScript;
318
- if (scriptToRun) {
319
- const scriptPath = join(repository.repositoryPath, scriptToRun.file);
320
- await this.runSetupScript(scriptPath, "repository", workspacePath, issue);
321
- }
322
- return {
323
- path: workspacePath,
324
- isGitWorktree: true,
325
- };
326
- }
327
- catch (error) {
328
- this.logger.error("Failed to create git worktree:", error.message);
329
- // Fall back to regular directory if git worktree fails
330
- const fallbackPath = join(repository.workspaceBaseDir, issue.identifier);
331
- mkdirSync(fallbackPath, { recursive: true });
332
- return {
333
- path: fallbackPath,
334
- isGitWorktree: false,
335
- };
336
- }
337
- }
338
- }
339
- //# sourceMappingURL=GitService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GitService.js","sourceRoot":"","sources":["../../../src/services/GitService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAM3C;;GAEG;AACH,MAAM,OAAO,UAAU;IACF;IAApB,YAAoB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IACtC;;OAEG;IACH,KAAK,CAAC,YAAY,CAAC,UAAkB,EAAE,QAAgB;QACtD,IAAI,CAAC;YACJ,iCAAiC;YACjC,QAAQ,CAAC,2BAA2B,UAAU,GAAG,EAAE;gBAClD,GAAG,EAAE,QAAQ;gBACb,KAAK,EAAE,MAAM;aACb,CAAC,CAAC;YACH,OAAO,IAAI,C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