-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetupWorkspace.ts
More file actions
80 lines (71 loc) · 3.08 KB
/
Copy pathsetupWorkspace.ts
File metadata and controls
80 lines (71 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import * as vscode from "vscode";
import { PATCHLOOM_DOCS_URL, PATCHLOOM_RELEASES_URL, patchloomNeedsUpgrade, resolvePatchloomStatus } from "../binary/patchloom.js";
import { describeWorkspaceEnvironment, inspectWorkspaceReadiness } from "../workspace/readiness.js";
export async function setupWorkspace(): Promise<void> {
const status = await resolvePatchloomStatus();
if (!status.ready) {
const choice = await vscode.window.showWarningMessage(
`${status.message}\n\nPatchloom needs a working binary before workspace setup can continue.`,
"Open Settings"
);
if (choice === "Open Settings") {
await vscode.commands.executeCommand("patchloom.openPatchloomSettings");
}
return;
}
const readiness = await inspectWorkspaceReadiness({
promptIfMany: true,
placeHolder: "Select the workspace folder to inspect for Patchloom setup"
});
if (patchloomNeedsUpgrade(status)) {
const choice = await vscode.window.showWarningMessage(
`${status.compatibilityMessage}\n\nUpgrade Patchloom before workspace setup can continue.`,
"Open Releases"
);
if (choice === "Open Releases") {
await vscode.commands.executeCommand("patchloom.openPatchloomReleases");
}
return;
}
if (!readiness.hasWorkspace) {
await vscode.window.showWarningMessage("Open a workspace folder before running Patchloom: Setup Workspace.");
return;
}
if (readiness.hasAgentsFile === false) {
const choice = await vscode.window.showInformationMessage(
"Step 1/2: AGENTS.md is missing for this workspace. Create it now from patchloom agent-rules?",
"Initialize Project",
"Skip"
);
if (choice === "Initialize Project") {
await vscode.commands.executeCommand("patchloom.initializeProject");
}
}
if (readiness.hasMcpConfig === false) {
const choice = await vscode.window.showInformationMessage(
`${readiness.hasAgentsFile === false ? "Step 2/2: " : ""}Patchloom MCP config is missing. Configure supported editors now?`,
"Configure MCP",
"Skip"
);
if (choice === "Configure MCP") {
await vscode.commands.executeCommand("patchloom.configureMcp");
}
}
if (readiness.hasAgentsFile !== false && readiness.hasMcpConfig !== false) {
const environment = describeWorkspaceEnvironment(vscode.env.remoteName);
const environmentSuffix = environment.note ? ` ${environment.note}` : "";
const workspaceTarget = readiness.workspaceName ? ` for ${readiness.workspaceName}` : "";
await vscode.window.showInformationMessage(
`Patchloom workspace setup looks good${workspaceTarget}. Binary, AGENTS.md, and MCP config are already in place.${environmentSuffix}`
);
}
}
export async function openPatchloomSettings(): Promise<void> {
await vscode.commands.executeCommand("workbench.action.openSettings", "patchloom");
}
export async function openPatchloomReleases(): Promise<void> {
await vscode.env.openExternal(vscode.Uri.parse(PATCHLOOM_RELEASES_URL));
}
export async function openDocumentation(): Promise<void> {
await vscode.env.openExternal(vscode.Uri.parse(PATCHLOOM_DOCS_URL));
}