mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 08:33:36 +00:00
Merge branch 'main' into feature-dependency-improvements
This commit is contained in:
@@ -158,7 +158,10 @@ export interface SpecRegenerationAPI {
|
||||
analyzeProject?: boolean,
|
||||
maxFeatures?: number
|
||||
) => Promise<{ success: boolean; error?: string }>;
|
||||
generateFeatures: (projectPath: string, maxFeatures?: number) => Promise<{
|
||||
generateFeatures: (
|
||||
projectPath: string,
|
||||
maxFeatures?: number
|
||||
) => Promise<{
|
||||
success: boolean;
|
||||
error?: string;
|
||||
}>;
|
||||
@@ -224,7 +227,8 @@ export interface AutoModeAPI {
|
||||
runFeature: (
|
||||
projectPath: string,
|
||||
featureId: string,
|
||||
useWorktrees?: boolean
|
||||
useWorktrees?: boolean,
|
||||
worktreePath?: string
|
||||
) => Promise<{ success: boolean; passes?: boolean; error?: string }>;
|
||||
verifyFeature: (
|
||||
projectPath: string,
|
||||
@@ -232,7 +236,8 @@ export interface AutoModeAPI {
|
||||
) => Promise<{ success: boolean; passes?: boolean; error?: string }>;
|
||||
resumeFeature: (
|
||||
projectPath: string,
|
||||
featureId: string
|
||||
featureId: string,
|
||||
useWorktrees?: boolean
|
||||
) => Promise<{ success: boolean; passes?: boolean; error?: string }>;
|
||||
contextExists: (
|
||||
projectPath: string,
|
||||
@@ -245,11 +250,13 @@ export interface AutoModeAPI {
|
||||
projectPath: string,
|
||||
featureId: string,
|
||||
prompt: string,
|
||||
imagePaths?: string[]
|
||||
imagePaths?: string[],
|
||||
worktreePath?: string
|
||||
) => Promise<{ success: boolean; passes?: boolean; error?: string }>;
|
||||
commitFeature: (
|
||||
projectPath: string,
|
||||
featureId: string
|
||||
featureId: string,
|
||||
worktreePath?: string
|
||||
) => Promise<{ success: boolean; error?: string }>;
|
||||
onEvent: (callback: (event: AutoModeEvent) => void) => () => void;
|
||||
}
|
||||
@@ -317,7 +324,11 @@ export interface ElectronAPI {
|
||||
features?: FeaturesAPI;
|
||||
runningAgents?: RunningAgentsAPI;
|
||||
enhancePrompt?: {
|
||||
enhance: (originalText: string, enhancementMode: string, model?: string) => Promise<{
|
||||
enhance: (
|
||||
originalText: string,
|
||||
enhancementMode: string,
|
||||
model?: string
|
||||
) => Promise<{
|
||||
success: boolean;
|
||||
enhancedText?: string;
|
||||
error?: string;
|
||||
@@ -384,6 +395,15 @@ export interface ElectronAPI {
|
||||
authenticated: boolean;
|
||||
error?: string;
|
||||
}>;
|
||||
getGhStatus?: () => Promise<{
|
||||
success: boolean;
|
||||
installed: boolean;
|
||||
authenticated: boolean;
|
||||
version: string | null;
|
||||
path: string | null;
|
||||
user: string | null;
|
||||
error?: string;
|
||||
}>;
|
||||
onInstallProgress?: (callback: (progress: any) => void) => () => void;
|
||||
onAuthProgress?: (callback: (progress: any) => void) => () => void;
|
||||
};
|
||||
@@ -400,7 +420,8 @@ export interface ElectronAPI {
|
||||
sessionId: string,
|
||||
message: string,
|
||||
workingDirectory?: string,
|
||||
imagePaths?: string[]
|
||||
imagePaths?: string[],
|
||||
model?: string
|
||||
) => Promise<{ success: boolean; error?: string }>;
|
||||
getHistory: (sessionId: string) => Promise<{
|
||||
success: boolean;
|
||||
@@ -906,6 +927,15 @@ interface SetupAPI {
|
||||
authenticated: boolean;
|
||||
error?: string;
|
||||
}>;
|
||||
getGhStatus?: () => Promise<{
|
||||
success: boolean;
|
||||
installed: boolean;
|
||||
authenticated: boolean;
|
||||
version: string | null;
|
||||
path: string | null;
|
||||
user: string | null;
|
||||
error?: string;
|
||||
}>;
|
||||
onInstallProgress?: (callback: (progress: any) => void) => () => void;
|
||||
onAuthProgress?: (callback: (progress: any) => void) => () => void;
|
||||
}
|
||||
@@ -992,6 +1022,18 @@ function createMockSetupAPI(): SetupAPI {
|
||||
};
|
||||
},
|
||||
|
||||
getGhStatus: async () => {
|
||||
console.log("[Mock] Getting GitHub CLI status");
|
||||
return {
|
||||
success: true,
|
||||
installed: false,
|
||||
authenticated: false,
|
||||
version: null,
|
||||
path: null,
|
||||
user: null,
|
||||
};
|
||||
},
|
||||
|
||||
onInstallProgress: (callback) => {
|
||||
// Mock progress events
|
||||
return () => {};
|
||||
@@ -1007,11 +1049,6 @@ function createMockSetupAPI(): SetupAPI {
|
||||
// Mock Worktree API implementation
|
||||
function createMockWorktreeAPI(): WorktreeAPI {
|
||||
return {
|
||||
revertFeature: async (projectPath: string, featureId: string) => {
|
||||
console.log("[Mock] Reverting feature:", { projectPath, featureId });
|
||||
return { success: true, removedPath: `/mock/worktree/${featureId}` };
|
||||
},
|
||||
|
||||
mergeFeature: async (
|
||||
projectPath: string,
|
||||
featureId: string,
|
||||
@@ -1057,6 +1094,106 @@ function createMockWorktreeAPI(): WorktreeAPI {
|
||||
return { success: true, worktrees: [] };
|
||||
},
|
||||
|
||||
listAll: async (projectPath: string, includeDetails?: boolean) => {
|
||||
console.log("[Mock] Listing all worktrees:", {
|
||||
projectPath,
|
||||
includeDetails,
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
worktrees: [
|
||||
{
|
||||
path: projectPath,
|
||||
branch: "main",
|
||||
isMain: true,
|
||||
isCurrent: true,
|
||||
hasWorktree: true,
|
||||
hasChanges: false,
|
||||
changedFilesCount: 0,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
|
||||
create: async (
|
||||
projectPath: string,
|
||||
branchName: string,
|
||||
baseBranch?: string
|
||||
) => {
|
||||
console.log("[Mock] Creating worktree:", {
|
||||
projectPath,
|
||||
branchName,
|
||||
baseBranch,
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
worktree: {
|
||||
path: `${projectPath}/.worktrees/${branchName}`,
|
||||
branch: branchName,
|
||||
isNew: true,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
delete: async (
|
||||
projectPath: string,
|
||||
worktreePath: string,
|
||||
deleteBranch?: boolean
|
||||
) => {
|
||||
console.log("[Mock] Deleting worktree:", {
|
||||
projectPath,
|
||||
worktreePath,
|
||||
deleteBranch,
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
deleted: {
|
||||
worktreePath,
|
||||
branch: deleteBranch ? "feature-branch" : null,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
commit: async (worktreePath: string, message: string) => {
|
||||
console.log("[Mock] Committing changes:", { worktreePath, message });
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
committed: true,
|
||||
commitHash: "abc123",
|
||||
branch: "feature-branch",
|
||||
message,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
push: async (worktreePath: string, force?: boolean) => {
|
||||
console.log("[Mock] Pushing worktree:", { worktreePath, force });
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
branch: "feature-branch",
|
||||
pushed: true,
|
||||
message: "Successfully pushed to origin/feature-branch",
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
createPR: async (worktreePath: string, options?: any) => {
|
||||
console.log("[Mock] Creating PR:", { worktreePath, options });
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
branch: "feature-branch",
|
||||
committed: true,
|
||||
commitHash: "abc123",
|
||||
pushed: true,
|
||||
prUrl: "https://github.com/example/repo/pull/1",
|
||||
prCreated: true,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
getDiffs: async (projectPath: string, featureId: string) => {
|
||||
console.log("[Mock] Getting file diffs:", { projectPath, featureId });
|
||||
return {
|
||||
@@ -1086,6 +1223,129 @@ function createMockWorktreeAPI(): WorktreeAPI {
|
||||
filePath,
|
||||
};
|
||||
},
|
||||
|
||||
pull: async (worktreePath: string) => {
|
||||
console.log("[Mock] Pulling latest changes for:", worktreePath);
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
branch: "main",
|
||||
pulled: true,
|
||||
message: "Pulled latest changes",
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
checkoutBranch: async (worktreePath: string, branchName: string) => {
|
||||
console.log("[Mock] Creating and checking out branch:", {
|
||||
worktreePath,
|
||||
branchName,
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
previousBranch: "main",
|
||||
newBranch: branchName,
|
||||
message: `Created and checked out branch '${branchName}'`,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
listBranches: async (worktreePath: string) => {
|
||||
console.log("[Mock] Listing branches for:", worktreePath);
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
currentBranch: "main",
|
||||
branches: [
|
||||
{ name: "main", isCurrent: true, isRemote: false },
|
||||
{ name: "develop", isCurrent: false, isRemote: false },
|
||||
{ name: "feature/example", isCurrent: false, isRemote: false },
|
||||
],
|
||||
aheadCount: 2,
|
||||
behindCount: 0,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
switchBranch: async (worktreePath: string, branchName: string) => {
|
||||
console.log("[Mock] Switching to branch:", { worktreePath, branchName });
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
previousBranch: "main",
|
||||
currentBranch: branchName,
|
||||
message: `Switched to branch '${branchName}'`,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
openInEditor: async (worktreePath: string) => {
|
||||
console.log("[Mock] Opening in editor:", worktreePath);
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
message: `Opened ${worktreePath} in VS Code`,
|
||||
editorName: "VS Code",
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
getDefaultEditor: async () => {
|
||||
console.log("[Mock] Getting default editor");
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
editorName: "VS Code",
|
||||
editorCommand: "code",
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
initGit: async (projectPath: string) => {
|
||||
console.log("[Mock] Initializing git:", projectPath);
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
initialized: true,
|
||||
message: `Initialized git repository in ${projectPath}`,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
startDevServer: async (projectPath: string, worktreePath: string) => {
|
||||
console.log("[Mock] Starting dev server:", { projectPath, worktreePath });
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
worktreePath,
|
||||
port: 3001,
|
||||
url: "http://localhost:3001",
|
||||
message: "Dev server started on port 3001",
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
stopDevServer: async (worktreePath: string) => {
|
||||
console.log("[Mock] Stopping dev server:", worktreePath);
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
worktreePath,
|
||||
message: "Dev server stopped",
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
listDevServers: async () => {
|
||||
console.log("[Mock] Listing dev servers");
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
servers: [],
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1192,7 +1452,8 @@ function createMockAutoModeAPI(): AutoModeAPI {
|
||||
runFeature: async (
|
||||
projectPath: string,
|
||||
featureId: string,
|
||||
useWorktrees?: boolean
|
||||
useWorktrees?: boolean,
|
||||
worktreePath?: string
|
||||
) => {
|
||||
if (mockRunningFeatures.has(featureId)) {
|
||||
return {
|
||||
@@ -1202,7 +1463,7 @@ function createMockAutoModeAPI(): AutoModeAPI {
|
||||
}
|
||||
|
||||
console.log(
|
||||
`[Mock] Running feature ${featureId} with useWorktrees: ${useWorktrees}`
|
||||
`[Mock] Running feature ${featureId} with useWorktrees: ${useWorktrees}, worktreePath: ${worktreePath}`
|
||||
);
|
||||
mockRunningFeatures.add(featureId);
|
||||
simulateAutoModeLoop(projectPath, featureId);
|
||||
@@ -1224,7 +1485,11 @@ function createMockAutoModeAPI(): AutoModeAPI {
|
||||
return { success: true, passes: true };
|
||||
},
|
||||
|
||||
resumeFeature: async (projectPath: string, featureId: string) => {
|
||||
resumeFeature: async (
|
||||
projectPath: string,
|
||||
featureId: string,
|
||||
useWorktrees?: boolean
|
||||
) => {
|
||||
if (mockRunningFeatures.has(featureId)) {
|
||||
return {
|
||||
success: false,
|
||||
@@ -1362,7 +1627,8 @@ function createMockAutoModeAPI(): AutoModeAPI {
|
||||
projectPath: string,
|
||||
featureId: string,
|
||||
prompt: string,
|
||||
imagePaths?: string[]
|
||||
imagePaths?: string[],
|
||||
worktreePath?: string
|
||||
) => {
|
||||
if (mockRunningFeatures.has(featureId)) {
|
||||
return {
|
||||
@@ -1387,8 +1653,16 @@ function createMockAutoModeAPI(): AutoModeAPI {
|
||||
return { success: true };
|
||||
},
|
||||
|
||||
commitFeature: async (projectPath: string, featureId: string) => {
|
||||
console.log("[Mock] Committing feature:", { projectPath, featureId });
|
||||
commitFeature: async (
|
||||
projectPath: string,
|
||||
featureId: string,
|
||||
worktreePath?: string
|
||||
) => {
|
||||
console.log("[Mock] Committing feature:", {
|
||||
projectPath,
|
||||
featureId,
|
||||
worktreePath,
|
||||
});
|
||||
|
||||
// Simulate commit operation
|
||||
emitAutoModeEvent({
|
||||
|
||||
@@ -468,12 +468,24 @@ export class HttpApiClient implements ElectronAPI {
|
||||
isLinux: boolean;
|
||||
}> => this.get("/api/setup/platform"),
|
||||
|
||||
verifyClaudeAuth: (authMethod?: "cli" | "api_key"): Promise<{
|
||||
verifyClaudeAuth: (
|
||||
authMethod?: "cli" | "api_key"
|
||||
): Promise<{
|
||||
success: boolean;
|
||||
authenticated: boolean;
|
||||
error?: string;
|
||||
}> => this.post("/api/setup/verify-claude-auth", { authMethod }),
|
||||
|
||||
getGhStatus: (): Promise<{
|
||||
success: boolean;
|
||||
installed: boolean;
|
||||
authenticated: boolean;
|
||||
version: string | null;
|
||||
path: string | null;
|
||||
user: string | null;
|
||||
error?: string;
|
||||
}> => this.get("/api/setup/gh-status"),
|
||||
|
||||
onInstallProgress: (callback: (progress: unknown) => void) => {
|
||||
return this.subscribeToEvent("agent:stream", callback);
|
||||
},
|
||||
@@ -515,17 +527,27 @@ export class HttpApiClient implements ElectronAPI {
|
||||
runFeature: (
|
||||
projectPath: string,
|
||||
featureId: string,
|
||||
useWorktrees?: boolean
|
||||
useWorktrees?: boolean,
|
||||
worktreePath?: string
|
||||
) =>
|
||||
this.post("/api/auto-mode/run-feature", {
|
||||
projectPath,
|
||||
featureId,
|
||||
useWorktrees,
|
||||
worktreePath,
|
||||
}),
|
||||
verifyFeature: (projectPath: string, featureId: string) =>
|
||||
this.post("/api/auto-mode/verify-feature", { projectPath, featureId }),
|
||||
resumeFeature: (projectPath: string, featureId: string) =>
|
||||
this.post("/api/auto-mode/resume-feature", { projectPath, featureId }),
|
||||
resumeFeature: (
|
||||
projectPath: string,
|
||||
featureId: string,
|
||||
useWorktrees?: boolean
|
||||
) =>
|
||||
this.post("/api/auto-mode/resume-feature", {
|
||||
projectPath,
|
||||
featureId,
|
||||
useWorktrees,
|
||||
}),
|
||||
contextExists: (projectPath: string, featureId: string) =>
|
||||
this.post("/api/auto-mode/context-exists", { projectPath, featureId }),
|
||||
analyzeProject: (projectPath: string) =>
|
||||
@@ -534,16 +556,26 @@ export class HttpApiClient implements ElectronAPI {
|
||||
projectPath: string,
|
||||
featureId: string,
|
||||
prompt: string,
|
||||
imagePaths?: string[]
|
||||
imagePaths?: string[],
|
||||
worktreePath?: string
|
||||
) =>
|
||||
this.post("/api/auto-mode/follow-up-feature", {
|
||||
projectPath,
|
||||
featureId,
|
||||
prompt,
|
||||
imagePaths,
|
||||
worktreePath,
|
||||
}),
|
||||
commitFeature: (
|
||||
projectPath: string,
|
||||
featureId: string,
|
||||
worktreePath?: string
|
||||
) =>
|
||||
this.post("/api/auto-mode/commit-feature", {
|
||||
projectPath,
|
||||
featureId,
|
||||
worktreePath,
|
||||
}),
|
||||
commitFeature: (projectPath: string, featureId: string) =>
|
||||
this.post("/api/auto-mode/commit-feature", { projectPath, featureId }),
|
||||
onEvent: (callback: (event: AutoModeEvent) => void) => {
|
||||
return this.subscribeToEvent(
|
||||
"auto-mode:event",
|
||||
@@ -568,8 +600,6 @@ export class HttpApiClient implements ElectronAPI {
|
||||
|
||||
// Worktree API
|
||||
worktree: WorktreeAPI = {
|
||||
revertFeature: (projectPath: string, featureId: string) =>
|
||||
this.post("/api/worktree/revert", { projectPath, featureId }),
|
||||
mergeFeature: (projectPath: string, featureId: string, options?: object) =>
|
||||
this.post("/api/worktree/merge", { projectPath, featureId, options }),
|
||||
getInfo: (projectPath: string, featureId: string) =>
|
||||
@@ -578,6 +608,30 @@ export class HttpApiClient implements ElectronAPI {
|
||||
this.post("/api/worktree/status", { projectPath, featureId }),
|
||||
list: (projectPath: string) =>
|
||||
this.post("/api/worktree/list", { projectPath }),
|
||||
listAll: (projectPath: string, includeDetails?: boolean) =>
|
||||
this.post("/api/worktree/list", { projectPath, includeDetails }),
|
||||
create: (projectPath: string, branchName: string, baseBranch?: string) =>
|
||||
this.post("/api/worktree/create", {
|
||||
projectPath,
|
||||
branchName,
|
||||
baseBranch,
|
||||
}),
|
||||
delete: (
|
||||
projectPath: string,
|
||||
worktreePath: string,
|
||||
deleteBranch?: boolean
|
||||
) =>
|
||||
this.post("/api/worktree/delete", {
|
||||
projectPath,
|
||||
worktreePath,
|
||||
deleteBranch,
|
||||
}),
|
||||
commit: (worktreePath: string, message: string) =>
|
||||
this.post("/api/worktree/commit", { worktreePath, message }),
|
||||
push: (worktreePath: string, force?: boolean) =>
|
||||
this.post("/api/worktree/push", { worktreePath, force }),
|
||||
createPR: (worktreePath: string, options?: any) =>
|
||||
this.post("/api/worktree/create-pr", { worktreePath, ...options }),
|
||||
getDiffs: (projectPath: string, featureId: string) =>
|
||||
this.post("/api/worktree/diffs", { projectPath, featureId }),
|
||||
getFileDiff: (projectPath: string, featureId: string, filePath: string) =>
|
||||
@@ -586,6 +640,24 @@ export class HttpApiClient implements ElectronAPI {
|
||||
featureId,
|
||||
filePath,
|
||||
}),
|
||||
pull: (worktreePath: string) =>
|
||||
this.post("/api/worktree/pull", { worktreePath }),
|
||||
checkoutBranch: (worktreePath: string, branchName: string) =>
|
||||
this.post("/api/worktree/checkout-branch", { worktreePath, branchName }),
|
||||
listBranches: (worktreePath: string) =>
|
||||
this.post("/api/worktree/list-branches", { worktreePath }),
|
||||
switchBranch: (worktreePath: string, branchName: string) =>
|
||||
this.post("/api/worktree/switch-branch", { worktreePath, branchName }),
|
||||
openInEditor: (worktreePath: string) =>
|
||||
this.post("/api/worktree/open-in-editor", { worktreePath }),
|
||||
getDefaultEditor: () => this.get("/api/worktree/default-editor"),
|
||||
initGit: (projectPath: string) =>
|
||||
this.post("/api/worktree/init-git", { projectPath }),
|
||||
startDevServer: (projectPath: string, worktreePath: string) =>
|
||||
this.post("/api/worktree/start-dev", { projectPath, worktreePath }),
|
||||
stopDevServer: (worktreePath: string) =>
|
||||
this.post("/api/worktree/stop-dev", { worktreePath }),
|
||||
listDevServers: () => this.post("/api/worktree/list-dev-servers", {}),
|
||||
};
|
||||
|
||||
// Git API
|
||||
@@ -641,7 +713,10 @@ export class HttpApiClient implements ElectronAPI {
|
||||
maxFeatures,
|
||||
}),
|
||||
generateFeatures: (projectPath: string, maxFeatures?: number) =>
|
||||
this.post("/api/spec-regeneration/generate-features", { projectPath, maxFeatures }),
|
||||
this.post("/api/spec-regeneration/generate-features", {
|
||||
projectPath,
|
||||
maxFeatures,
|
||||
}),
|
||||
stop: () => this.post("/api/spec-regeneration/stop"),
|
||||
status: () => this.get("/api/spec-regeneration/status"),
|
||||
onEvent: (callback: (event: SpecRegenerationEvent) => void) => {
|
||||
@@ -699,13 +774,15 @@ export class HttpApiClient implements ElectronAPI {
|
||||
sessionId: string,
|
||||
message: string,
|
||||
workingDirectory?: string,
|
||||
imagePaths?: string[]
|
||||
imagePaths?: string[],
|
||||
model?: string
|
||||
): Promise<{ success: boolean; error?: string }> =>
|
||||
this.post("/api/agent/send", {
|
||||
sessionId,
|
||||
message,
|
||||
workingDirectory,
|
||||
imagePaths,
|
||||
model,
|
||||
}),
|
||||
|
||||
getHistory: (
|
||||
|
||||
@@ -48,6 +48,31 @@ export async function initializeProject(
|
||||
const existingFiles: string[] = [];
|
||||
|
||||
try {
|
||||
// Initialize git repository if it doesn't exist
|
||||
const gitDirExists = await api.exists(`${projectPath}/.git`);
|
||||
if (!gitDirExists) {
|
||||
console.log("[project-init] Initializing git repository...");
|
||||
try {
|
||||
// Initialize git and create an initial empty commit via server route
|
||||
const result = await api.worktree?.initGit(projectPath);
|
||||
if (result?.success && result.result?.initialized) {
|
||||
createdFiles.push(".git");
|
||||
console.log("[project-init] Git repository initialized with initial commit");
|
||||
} else if (result?.success && !result.result?.initialized) {
|
||||
// Git already existed (shouldn't happen since we checked, but handle it)
|
||||
existingFiles.push(".git");
|
||||
console.log("[project-init] Git repository already exists");
|
||||
} else {
|
||||
console.warn("[project-init] Failed to initialize git repository:", result?.error);
|
||||
}
|
||||
} catch (gitError) {
|
||||
console.warn("[project-init] Failed to initialize git repository:", gitError);
|
||||
// Don't fail the whole initialization if git init fails
|
||||
}
|
||||
} else {
|
||||
existingFiles.push(".git");
|
||||
}
|
||||
|
||||
// Create all required directories
|
||||
for (const dir of REQUIRED_STRUCTURE.directories) {
|
||||
const fullPath = `${projectPath}/${dir}`;
|
||||
|
||||
@@ -35,3 +35,20 @@ export function truncateDescription(description: string, maxLength = 50): string
|
||||
}
|
||||
return `${description.slice(0, maxLength)}...`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a file path to use forward slashes consistently.
|
||||
* This is important for cross-platform compatibility (Windows uses backslashes).
|
||||
*/
|
||||
export function normalizePath(p: string): string {
|
||||
return p.replace(/\\/g, "/");
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two paths for equality, handling cross-platform differences.
|
||||
* Normalizes both paths to forward slashes before comparison.
|
||||
*/
|
||||
export function pathsEqual(p1: string | undefined | null, p2: string | undefined | null): boolean {
|
||||
if (!p1 || !p2) return p1 === p2;
|
||||
return normalizePath(p1) === normalizePath(p2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user