ai-project-manage-cli 7.1.6 → 7.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.
|
@@ -2581,9 +2581,66 @@ async function ensureWebIdeDraftPullRequests(cfg, taskId, workdir) {
|
|
|
2581
2581
|
}
|
|
2582
2582
|
}
|
|
2583
2583
|
|
|
2584
|
-
// src/commands/connect/ensure-workspace-
|
|
2585
|
-
import { mkdirSync as mkdirSync7,
|
|
2584
|
+
// src/commands/connect/ensure-workspace-permissions.ts
|
|
2585
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync7, readFileSync as readFileSync8, writeFileSync as writeFileSync9 } from "fs";
|
|
2586
2586
|
import { join as join8 } from "path";
|
|
2587
|
+
var WEBIDE_MCP_ALLOWLIST = ["custom-user-tools:*"];
|
|
2588
|
+
function parsePermissionsConfig(raw) {
|
|
2589
|
+
try {
|
|
2590
|
+
const parsed = JSON.parse(raw);
|
|
2591
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
2592
|
+
return void 0;
|
|
2593
|
+
}
|
|
2594
|
+
return parsed;
|
|
2595
|
+
} catch {
|
|
2596
|
+
return void 0;
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
function mergeMcpAllowlist(existing) {
|
|
2600
|
+
const merged = /* @__PURE__ */ new Set([
|
|
2601
|
+
...existing ?? [],
|
|
2602
|
+
...WEBIDE_MCP_ALLOWLIST
|
|
2603
|
+
]);
|
|
2604
|
+
return [...merged];
|
|
2605
|
+
}
|
|
2606
|
+
function needsMcpAllowlistUpdate(existing) {
|
|
2607
|
+
const current = existing ?? [];
|
|
2608
|
+
return WEBIDE_MCP_ALLOWLIST.some((entry) => !current.includes(entry));
|
|
2609
|
+
}
|
|
2610
|
+
function ensureWorkspacePermissionsConfig(workdir) {
|
|
2611
|
+
const cursorDir = toFsPath(join8(workdir, ".cursor"));
|
|
2612
|
+
const permissionsPath = toFsPath(join8(cursorDir, "permissions.json"));
|
|
2613
|
+
let config = {};
|
|
2614
|
+
if (existsSync6(permissionsPath)) {
|
|
2615
|
+
const raw = readFileSync8(permissionsPath, "utf8");
|
|
2616
|
+
const parsed = parsePermissionsConfig(raw);
|
|
2617
|
+
if (!parsed) {
|
|
2618
|
+
console.warn(
|
|
2619
|
+
`[apm] \u5DE5\u4F5C\u533A permissions.json \u65E0\u6CD5\u89E3\u6790\uFF0C\u8DF3\u8FC7\u5199\u5165\uFF1A${permissionsPath}`
|
|
2620
|
+
);
|
|
2621
|
+
return;
|
|
2622
|
+
}
|
|
2623
|
+
config = parsed;
|
|
2624
|
+
}
|
|
2625
|
+
if (!needsMcpAllowlistUpdate(config.mcpAllowlist)) {
|
|
2626
|
+
return;
|
|
2627
|
+
}
|
|
2628
|
+
config.mcpAllowlist = mergeMcpAllowlist(config.mcpAllowlist);
|
|
2629
|
+
mkdirSync7(cursorDir, { recursive: true });
|
|
2630
|
+
writeFileSync9(
|
|
2631
|
+
permissionsPath,
|
|
2632
|
+
`${JSON.stringify(config, null, 2)}
|
|
2633
|
+
`,
|
|
2634
|
+
"utf8"
|
|
2635
|
+
);
|
|
2636
|
+
console.log(
|
|
2637
|
+
`[apm] \u5DF2\u66F4\u65B0\u5DE5\u4F5C\u533A permissions \u914D\u7F6E\uFF08mcpAllowlist\uFF09\uFF1A${permissionsPath}`
|
|
2638
|
+
);
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
// src/commands/connect/ensure-workspace-sandbox.ts
|
|
2642
|
+
import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync10, existsSync as existsSync7 } from "fs";
|
|
2643
|
+
import { join as join9 } from "path";
|
|
2587
2644
|
var DEFAULT_SANDBOX_JSON = `{
|
|
2588
2645
|
"type": "workspace_readwrite",
|
|
2589
2646
|
"networkPolicy": {
|
|
@@ -2592,11 +2649,11 @@ var DEFAULT_SANDBOX_JSON = `{
|
|
|
2592
2649
|
}
|
|
2593
2650
|
`;
|
|
2594
2651
|
function ensureWorkspaceSandboxConfig(workdir) {
|
|
2595
|
-
const cursorDir = toFsPath(
|
|
2596
|
-
const sandboxPath = toFsPath(
|
|
2597
|
-
if (
|
|
2598
|
-
|
|
2599
|
-
|
|
2652
|
+
const cursorDir = toFsPath(join9(workdir, ".cursor"));
|
|
2653
|
+
const sandboxPath = toFsPath(join9(cursorDir, "sandbox.json"));
|
|
2654
|
+
if (existsSync7(sandboxPath)) return;
|
|
2655
|
+
mkdirSync8(cursorDir, { recursive: true });
|
|
2656
|
+
writeFileSync10(sandboxPath, DEFAULT_SANDBOX_JSON, "utf8");
|
|
2600
2657
|
console.log(`[apm] \u5DF2\u5199\u5165\u5DE5\u4F5C\u533A sandbox \u914D\u7F6E\uFF1A${sandboxPath}`);
|
|
2601
2658
|
}
|
|
2602
2659
|
|
|
@@ -2629,6 +2686,7 @@ async function handleWebIdeInboundMessage(cfg, msg, signal) {
|
|
|
2629
2686
|
assertApmGitignoredInRepo(workdir);
|
|
2630
2687
|
}
|
|
2631
2688
|
ensureWorkspaceSandboxConfig(workdir);
|
|
2689
|
+
ensureWorkspacePermissionsConfig(workdir);
|
|
2632
2690
|
resolveWorkspaceRepos(workdir);
|
|
2633
2691
|
if (shouldRunBranch(branchCacheKey, workdir)) {
|
|
2634
2692
|
if (signal.aborted) throw new Error("\u4EFB\u52A1\u5DF2\u53D6\u6D88");
|