ai-project-manage-cli 7.1.33 → 7.1.34
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/index.js +38 -42
- package/dist/webide-message-worker.js +78 -82
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7244,7 +7244,7 @@ function cleanSessionWorkspaceCache(sessionId, workdir) {
|
|
|
7244
7244
|
// src/commands/clean-webide-cache.ts
|
|
7245
7245
|
import { existsSync as existsSync24, rmSync as rmSync5 } from "node:fs";
|
|
7246
7246
|
import { resolve as resolve7 } from "node:path";
|
|
7247
|
-
import {
|
|
7247
|
+
import { getDefaultSdkStateRoot } from "@cursor/sdk";
|
|
7248
7248
|
|
|
7249
7249
|
// src/commands/connect/webide-agent-registry.ts
|
|
7250
7250
|
import { existsSync as existsSync23, mkdirSync as mkdirSync10, readFileSync as readFileSync17, writeFileSync as writeFileSync15 } from "node:fs";
|
|
@@ -7290,37 +7290,44 @@ function loadWebIdeAgentId(workdir, taskId) {
|
|
|
7290
7290
|
}
|
|
7291
7291
|
|
|
7292
7292
|
// src/commands/clean-webide-cache.ts
|
|
7293
|
-
function cursorAgentStoreDir(workdir) {
|
|
7294
|
-
return resolve7(workdir, ".apm", "cursor-agent-store");
|
|
7295
|
-
}
|
|
7296
7293
|
async function purgeCursorAgentStoreForAgent(workdir, agentId) {
|
|
7297
7294
|
const trimmedAgentId = agentId.trim();
|
|
7298
7295
|
const trimmedWorkdir = workdir.trim();
|
|
7299
7296
|
if (!trimmedAgentId || !trimmedWorkdir) return false;
|
|
7300
|
-
const
|
|
7301
|
-
if (!existsSync24(
|
|
7302
|
-
const
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7297
|
+
const stateRoot = getDefaultSdkStateRoot(trimmedWorkdir);
|
|
7298
|
+
if (!existsSync24(stateRoot)) return false;
|
|
7299
|
+
const { SqliteLocalAgentStore } = await import(
|
|
7300
|
+
/* @vite-ignore */
|
|
7301
|
+
"@cursor/sdk/sqlite"
|
|
7302
|
+
);
|
|
7303
|
+
const store = await SqliteLocalAgentStore.open({
|
|
7304
|
+
workspaceRef: trimmedWorkdir
|
|
7305
|
+
});
|
|
7306
|
+
try {
|
|
7307
|
+
const runIds = [];
|
|
7308
|
+
let cursor;
|
|
7309
|
+
do {
|
|
7310
|
+
const page = await store.runs.list({
|
|
7311
|
+
filter: {
|
|
7312
|
+
agentIds: [trimmedAgentId],
|
|
7313
|
+
...cursor ? { cursor } : {},
|
|
7314
|
+
limit: 200
|
|
7315
|
+
}
|
|
7316
|
+
});
|
|
7317
|
+
for (const run of page.items) {
|
|
7318
|
+
runIds.push(run.runId);
|
|
7311
7319
|
}
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
await store.
|
|
7320
|
+
cursor = page.nextCursor;
|
|
7321
|
+
} while (cursor);
|
|
7322
|
+
if (runIds.length > 0) {
|
|
7323
|
+
await store.runEvents.delete({ filter: { runIds } });
|
|
7324
|
+
}
|
|
7325
|
+
await store.runs.delete({ filter: { agentIds: [trimmedAgentId] } });
|
|
7326
|
+
await store.checkpoints.delete({ filter: { agentIds: [trimmedAgentId] } });
|
|
7327
|
+
await store.agents.delete({ filter: { agentIds: [trimmedAgentId] } });
|
|
7328
|
+
} finally {
|
|
7329
|
+
await store.dispose();
|
|
7320
7330
|
}
|
|
7321
|
-
await store.runs.delete({ filter: { agentIds: [trimmedAgentId] } });
|
|
7322
|
-
await store.checkpoints.delete({ filter: { agentIds: [trimmedAgentId] } });
|
|
7323
|
-
await store.agents.delete({ filter: { agentIds: [trimmedAgentId] } });
|
|
7324
7331
|
return true;
|
|
7325
7332
|
}
|
|
7326
7333
|
async function cleanWebIdeWorkspaceCache(taskId, workdir) {
|
|
@@ -7349,7 +7356,7 @@ async function cleanWebIdeWorkspaceCache(taskId, workdir) {
|
|
|
7349
7356
|
}
|
|
7350
7357
|
} else {
|
|
7351
7358
|
console.log(
|
|
7352
|
-
`[apm] \u65E0 WebIDE agentId\uFF0C\u8DF3\u8FC7
|
|
7359
|
+
`[apm] \u65E0 WebIDE agentId\uFF0C\u8DF3\u8FC7 agent store \u6E05\u7406 taskId=${trimmedTaskId}`
|
|
7353
7360
|
);
|
|
7354
7361
|
}
|
|
7355
7362
|
const dir = resolve7(trimmedWorkdir, ".apm", "webide", trimmedTaskId);
|
|
@@ -8365,16 +8372,6 @@ function withWorkspaceBoundaryHint(prompt) {
|
|
|
8365
8372
|
${WORKSPACE_BOUNDARY_HINT}`;
|
|
8366
8373
|
}
|
|
8367
8374
|
|
|
8368
|
-
// src/commands/connect/local-agent-store.ts
|
|
8369
|
-
import { mkdirSync as mkdirSync12 } from "node:fs";
|
|
8370
|
-
import { join as join19 } from "node:path";
|
|
8371
|
-
import { JsonlLocalAgentStore as JsonlLocalAgentStore2 } from "@cursor/sdk";
|
|
8372
|
-
function createWorkspaceLocalAgentStore(workdir) {
|
|
8373
|
-
const rootDir = join19(workdir, ".apm", "cursor-agent-store");
|
|
8374
|
-
mkdirSync12(rootDir, { recursive: true });
|
|
8375
|
-
return new JsonlLocalAgentStore2(rootDir);
|
|
8376
|
-
}
|
|
8377
|
-
|
|
8378
8375
|
// src/commands/connect/cursor-agent.ts
|
|
8379
8376
|
setMaxListeners2(100);
|
|
8380
8377
|
installAbortSignalDebug();
|
|
@@ -8421,7 +8418,6 @@ async function obtainAgent(ctx) {
|
|
|
8421
8418
|
model: { id: ctx.model || "default" },
|
|
8422
8419
|
local: {
|
|
8423
8420
|
cwd: ctx.cwd,
|
|
8424
|
-
store: createWorkspaceLocalAgentStore(ctx.workdir),
|
|
8425
8421
|
...ctx.customTools ? { customTools: ctx.customTools } : {},
|
|
8426
8422
|
...ctx.enableSandbox ? {
|
|
8427
8423
|
sandboxOptions: { enabled: true },
|
|
@@ -8673,10 +8669,10 @@ async function ensureMessageHasReply(cfg, sessionId, messageId, fallback) {
|
|
|
8673
8669
|
|
|
8674
8670
|
// src/commands/connect/cli-version-sync.ts
|
|
8675
8671
|
import { existsSync as existsSync26, readFileSync as readFileSync19, writeFileSync as writeFileSync17 } from "fs";
|
|
8676
|
-
import { join as
|
|
8672
|
+
import { join as join19 } from "path";
|
|
8677
8673
|
var CLI_VERSION_FILE = ".cli-version.json";
|
|
8678
8674
|
function manifestPath2(apmDir) {
|
|
8679
|
-
return
|
|
8675
|
+
return join19(apmDir, CLI_VERSION_FILE);
|
|
8680
8676
|
}
|
|
8681
8677
|
function loadManifest4(apmDir) {
|
|
8682
8678
|
const path19 = toFsPath(manifestPath2(apmDir));
|
|
@@ -8783,8 +8779,8 @@ init_webide_terminal_registry();
|
|
|
8783
8779
|
import { Worker } from "node:worker_threads";
|
|
8784
8780
|
import { totalmem } from "node:os";
|
|
8785
8781
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
8786
|
-
import { dirname as dirname9, join as
|
|
8787
|
-
var workerFile =
|
|
8782
|
+
import { dirname as dirname9, join as join20 } from "node:path";
|
|
8783
|
+
var workerFile = join20(
|
|
8788
8784
|
dirname9(fileURLToPath3(import.meta.url)),
|
|
8789
8785
|
"webide-message-worker.js"
|
|
8790
8786
|
);
|
|
@@ -2263,16 +2263,6 @@ function withWorkspaceBoundaryHint(prompt) {
|
|
|
2263
2263
|
${WORKSPACE_BOUNDARY_HINT}`;
|
|
2264
2264
|
}
|
|
2265
2265
|
|
|
2266
|
-
// src/commands/connect/local-agent-store.ts
|
|
2267
|
-
import { mkdirSync as mkdirSync5 } from "node:fs";
|
|
2268
|
-
import { join as join4 } from "node:path";
|
|
2269
|
-
import { JsonlLocalAgentStore } from "@cursor/sdk";
|
|
2270
|
-
function createWorkspaceLocalAgentStore(workdir) {
|
|
2271
|
-
const rootDir = join4(workdir, ".apm", "cursor-agent-store");
|
|
2272
|
-
mkdirSync5(rootDir, { recursive: true });
|
|
2273
|
-
return new JsonlLocalAgentStore(rootDir);
|
|
2274
|
-
}
|
|
2275
|
-
|
|
2276
2266
|
// src/commands/connect/cursor-agent.ts
|
|
2277
2267
|
setMaxListeners2(100);
|
|
2278
2268
|
installAbortSignalDebug();
|
|
@@ -2319,7 +2309,6 @@ async function obtainAgent(ctx) {
|
|
|
2319
2309
|
model: { id: ctx.model || "default" },
|
|
2320
2310
|
local: {
|
|
2321
2311
|
cwd: ctx.cwd,
|
|
2322
|
-
store: createWorkspaceLocalAgentStore(ctx.workdir),
|
|
2323
2312
|
...ctx.customTools ? { customTools: ctx.customTools } : {},
|
|
2324
2313
|
...ctx.enableSandbox ? {
|
|
2325
2314
|
sandboxOptions: { enabled: true },
|
|
@@ -2533,7 +2522,7 @@ async function runCursorAgent(cfg, ctx, options) {
|
|
|
2533
2522
|
}
|
|
2534
2523
|
|
|
2535
2524
|
// src/commands/connect/webide-agent-registry.ts
|
|
2536
|
-
import { existsSync as existsSync4, mkdirSync as
|
|
2525
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync5 } from "node:fs";
|
|
2537
2526
|
import { dirname as dirname4, resolve as resolve5 } from "node:path";
|
|
2538
2527
|
function registryPath2(workdir, taskId) {
|
|
2539
2528
|
return resolve5(workdir, ".apm", "webide", taskId, "cursor-agent.json");
|
|
@@ -2572,7 +2561,7 @@ function readRegistry2(path) {
|
|
|
2572
2561
|
return {};
|
|
2573
2562
|
}
|
|
2574
2563
|
function writeRegistry2(path, registry) {
|
|
2575
|
-
|
|
2564
|
+
mkdirSync5(dirname4(path), { recursive: true });
|
|
2576
2565
|
writeFileSync5(path, `${JSON.stringify(registry, null, 2)}
|
|
2577
2566
|
`, "utf8");
|
|
2578
2567
|
}
|
|
@@ -2621,38 +2610,45 @@ function clearWebIdeAgentId(workdir, taskId) {
|
|
|
2621
2610
|
// src/commands/clean-webide-cache.ts
|
|
2622
2611
|
import { existsSync as existsSync5, rmSync } from "node:fs";
|
|
2623
2612
|
import { resolve as resolve6 } from "node:path";
|
|
2624
|
-
import {
|
|
2625
|
-
function cursorAgentStoreDir(workdir) {
|
|
2626
|
-
return resolve6(workdir, ".apm", "cursor-agent-store");
|
|
2627
|
-
}
|
|
2613
|
+
import { getDefaultSdkStateRoot } from "@cursor/sdk";
|
|
2628
2614
|
async function purgeCursorAgentStoreForAgent(workdir, agentId) {
|
|
2629
2615
|
const trimmedAgentId = agentId.trim();
|
|
2630
2616
|
const trimmedWorkdir = workdir.trim();
|
|
2631
2617
|
if (!trimmedAgentId || !trimmedWorkdir) return false;
|
|
2632
|
-
const
|
|
2633
|
-
if (!existsSync5(
|
|
2634
|
-
const
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2618
|
+
const stateRoot = getDefaultSdkStateRoot(trimmedWorkdir);
|
|
2619
|
+
if (!existsSync5(stateRoot)) return false;
|
|
2620
|
+
const { SqliteLocalAgentStore } = await import(
|
|
2621
|
+
/* @vite-ignore */
|
|
2622
|
+
"@cursor/sdk/sqlite"
|
|
2623
|
+
);
|
|
2624
|
+
const store = await SqliteLocalAgentStore.open({
|
|
2625
|
+
workspaceRef: trimmedWorkdir
|
|
2626
|
+
});
|
|
2627
|
+
try {
|
|
2628
|
+
const runIds = [];
|
|
2629
|
+
let cursor;
|
|
2630
|
+
do {
|
|
2631
|
+
const page = await store.runs.list({
|
|
2632
|
+
filter: {
|
|
2633
|
+
agentIds: [trimmedAgentId],
|
|
2634
|
+
...cursor ? { cursor } : {},
|
|
2635
|
+
limit: 200
|
|
2636
|
+
}
|
|
2637
|
+
});
|
|
2638
|
+
for (const run of page.items) {
|
|
2639
|
+
runIds.push(run.runId);
|
|
2643
2640
|
}
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2641
|
+
cursor = page.nextCursor;
|
|
2642
|
+
} while (cursor);
|
|
2643
|
+
if (runIds.length > 0) {
|
|
2644
|
+
await store.runEvents.delete({ filter: { runIds } });
|
|
2647
2645
|
}
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
await store.checkpoints.delete({ filter: { agentIds: [trimmedAgentId] } });
|
|
2655
|
-
await store.agents.delete({ filter: { agentIds: [trimmedAgentId] } });
|
|
2646
|
+
await store.runs.delete({ filter: { agentIds: [trimmedAgentId] } });
|
|
2647
|
+
await store.checkpoints.delete({ filter: { agentIds: [trimmedAgentId] } });
|
|
2648
|
+
await store.agents.delete({ filter: { agentIds: [trimmedAgentId] } });
|
|
2649
|
+
} finally {
|
|
2650
|
+
await store.dispose();
|
|
2651
|
+
}
|
|
2656
2652
|
return true;
|
|
2657
2653
|
}
|
|
2658
2654
|
async function cleanWebIdeWorkspaceCache(taskId, workdir) {
|
|
@@ -2681,7 +2677,7 @@ async function cleanWebIdeWorkspaceCache(taskId, workdir) {
|
|
|
2681
2677
|
}
|
|
2682
2678
|
} else {
|
|
2683
2679
|
console.log(
|
|
2684
|
-
`[apm] \u65E0 WebIDE agentId\uFF0C\u8DF3\u8FC7
|
|
2680
|
+
`[apm] \u65E0 WebIDE agentId\uFF0C\u8DF3\u8FC7 agent store \u6E05\u7406 taskId=${trimmedTaskId}`
|
|
2685
2681
|
);
|
|
2686
2682
|
}
|
|
2687
2683
|
const dir = resolve6(trimmedWorkdir, ".apm", "webide", trimmedTaskId);
|
|
@@ -3003,11 +2999,11 @@ function resolveMessageReplyFallback(fallback) {
|
|
|
3003
2999
|
}
|
|
3004
3000
|
|
|
3005
3001
|
// src/commands/init.ts
|
|
3006
|
-
import { join as
|
|
3002
|
+
import { join as join6 } from "path";
|
|
3007
3003
|
import { readFileSync as readFileSync7, writeFileSync as writeFileSync8 } from "fs";
|
|
3008
3004
|
|
|
3009
3005
|
// src/deployment-config-sync.ts
|
|
3010
|
-
import { join as
|
|
3006
|
+
import { join as join4 } from "path";
|
|
3011
3007
|
import { writeFileSync as writeFileSync6 } from "fs";
|
|
3012
3008
|
var TEMPLATE_HINT = "\u4FDD\u7559\u6A21\u677F .apm/apm.config.json";
|
|
3013
3009
|
var SYNC_HINT = "\u767B\u8BB0\u5DE5\u4F5C\u7A7A\u95F4\u8DEF\u5F84\u3001\u7ED1\u5B9A\u4ED3\u5E93\u540E\uFF0C\u53EF\u6267\u884C: apm sync-deploy-config";
|
|
@@ -3033,7 +3029,7 @@ async function writeDeploymentConfigContent(apmDir, content, configName) {
|
|
|
3033
3029
|
);
|
|
3034
3030
|
return false;
|
|
3035
3031
|
}
|
|
3036
|
-
const apmConfigPath = toFsPath(
|
|
3032
|
+
const apmConfigPath = toFsPath(join4(apmDir, "apm.config.json"));
|
|
3037
3033
|
writeFileSync6(apmConfigPath, `${JSON.stringify(parsed, null, 2)}
|
|
3038
3034
|
`, "utf8");
|
|
3039
3035
|
console.log(`[apm] \u5DF2\u540C\u6B65\u5E73\u53F0\u90E8\u7F72\u914D\u7F6E: ${configName}`);
|
|
@@ -3095,7 +3091,7 @@ import {
|
|
|
3095
3091
|
writeFileSync as writeFileSync7
|
|
3096
3092
|
} from "fs";
|
|
3097
3093
|
import { createHash } from "crypto";
|
|
3098
|
-
import { dirname as dirname5, join as
|
|
3094
|
+
import { dirname as dirname5, join as join5, relative as relative2, sep } from "path";
|
|
3099
3095
|
var MANIFEST_FILE = "manifest.json";
|
|
3100
3096
|
function normalizeProjectIdForPath(projectId) {
|
|
3101
3097
|
const id = projectId.trim();
|
|
@@ -3109,11 +3105,11 @@ function normalizeProjectIdForPath(projectId) {
|
|
|
3109
3105
|
}
|
|
3110
3106
|
function projectDocumentsDir(apmRoot, projectId) {
|
|
3111
3107
|
const id = normalizeProjectIdForPath(projectId);
|
|
3112
|
-
return
|
|
3108
|
+
return join5(apmRoot ?? workspaceApmDir(), "project", id);
|
|
3113
3109
|
}
|
|
3114
3110
|
function projectDocumentLocalPath(apmRoot, projectId, documentPath) {
|
|
3115
3111
|
const normalized = normalizeLocalDocumentPath(documentPath);
|
|
3116
|
-
return
|
|
3112
|
+
return join5(
|
|
3117
3113
|
projectDocumentsDir(apmRoot, projectId),
|
|
3118
3114
|
...normalized.split("/")
|
|
3119
3115
|
);
|
|
@@ -3133,7 +3129,7 @@ function hashLocalFileContent(content) {
|
|
|
3133
3129
|
return createHash("sha256").update(content, "utf8").digest("hex");
|
|
3134
3130
|
}
|
|
3135
3131
|
function readLocalManifest(apmRoot, projectId) {
|
|
3136
|
-
const manifestPath3 =
|
|
3132
|
+
const manifestPath3 = join5(
|
|
3137
3133
|
projectDocumentsDir(apmRoot, projectId),
|
|
3138
3134
|
MANIFEST_FILE
|
|
3139
3135
|
);
|
|
@@ -3156,7 +3152,7 @@ function listLocalDocumentPaths(apmRoot, projectId) {
|
|
|
3156
3152
|
const paths = [];
|
|
3157
3153
|
const walk = (dir) => {
|
|
3158
3154
|
for (const entry of readdirSync3(dir, { withFileTypes: true })) {
|
|
3159
|
-
const abs =
|
|
3155
|
+
const abs = join5(dir, entry.name);
|
|
3160
3156
|
if (entry.isDirectory()) {
|
|
3161
3157
|
walk(abs);
|
|
3162
3158
|
continue;
|
|
@@ -3290,7 +3286,7 @@ ${diagnostic ?? ""}`);
|
|
|
3290
3286
|
}
|
|
3291
3287
|
}
|
|
3292
3288
|
writeFileSync7(
|
|
3293
|
-
toFsPath(
|
|
3289
|
+
toFsPath(join5(docsDir, MANIFEST_FILE)),
|
|
3294
3290
|
`${JSON.stringify(remoteManifest, null, 2)}
|
|
3295
3291
|
`,
|
|
3296
3292
|
"utf8"
|
|
@@ -3372,7 +3368,7 @@ async function ensureWorkspaceInitialized(workdir, options) {
|
|
|
3372
3368
|
await syncProjectDocumentsPull(workdir, apmDir);
|
|
3373
3369
|
const trimmedName = options?.name?.trim();
|
|
3374
3370
|
if (trimmedName) {
|
|
3375
|
-
const apmConfigPath = toFsPath(
|
|
3371
|
+
const apmConfigPath = toFsPath(join6(apmDir, "apm.config.json"));
|
|
3376
3372
|
const config = readFileSync7(apmConfigPath, "utf8");
|
|
3377
3373
|
const configJson = JSON.parse(config);
|
|
3378
3374
|
configJson.name = trimmedName;
|
|
@@ -3637,12 +3633,12 @@ async function ensureWebIdePullRequests(cfg, taskId, workdir) {
|
|
|
3637
3633
|
|
|
3638
3634
|
// src/version.ts
|
|
3639
3635
|
import { readFileSync as readFileSync8 } from "fs";
|
|
3640
|
-
import { dirname as dirname6, join as
|
|
3636
|
+
import { dirname as dirname6, join as join7 } from "path";
|
|
3641
3637
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
3642
3638
|
function readCliVersion() {
|
|
3643
3639
|
try {
|
|
3644
3640
|
const dir = dirname6(fileURLToPath2(import.meta.url));
|
|
3645
|
-
const pkgPath =
|
|
3641
|
+
const pkgPath = join7(dir, "..", "package.json");
|
|
3646
3642
|
const pkg = JSON.parse(readFileSync8(pkgPath, "utf8"));
|
|
3647
3643
|
return pkg.version ?? "0.0.0";
|
|
3648
3644
|
} catch {
|
|
@@ -3651,24 +3647,24 @@ function readCliVersion() {
|
|
|
3651
3647
|
}
|
|
3652
3648
|
|
|
3653
3649
|
// src/commands/update-skills.ts
|
|
3654
|
-
import { existsSync as existsSync8, mkdirSync as
|
|
3655
|
-
import { join as
|
|
3650
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync7, statSync as statSync4 } from "fs";
|
|
3651
|
+
import { join as join9 } from "path";
|
|
3656
3652
|
|
|
3657
3653
|
// src/skills-sync.ts
|
|
3658
3654
|
import {
|
|
3659
3655
|
copyFileSync as copyFileSync2,
|
|
3660
3656
|
cpSync,
|
|
3661
3657
|
existsSync as existsSync7,
|
|
3662
|
-
mkdirSync as
|
|
3658
|
+
mkdirSync as mkdirSync6,
|
|
3663
3659
|
readdirSync as readdirSync4,
|
|
3664
3660
|
rmSync as rmSync3,
|
|
3665
3661
|
statSync as statSync3,
|
|
3666
3662
|
writeFileSync as writeFileSync9
|
|
3667
3663
|
} from "fs";
|
|
3668
|
-
import { join as
|
|
3669
|
-
var AGENTS_TEMPLATE_PATH =
|
|
3670
|
-
var BASE_SKILLS_TEMPLATE_DIR =
|
|
3671
|
-
var BASE_RULES_TEMPLATE_DIR =
|
|
3664
|
+
import { join as join8 } from "path";
|
|
3665
|
+
var AGENTS_TEMPLATE_PATH = join8(CLI_TEMPLATE_DIR, "AGENTS.md");
|
|
3666
|
+
var BASE_SKILLS_TEMPLATE_DIR = join8(CLI_TEMPLATE_DIR, "skills");
|
|
3667
|
+
var BASE_RULES_TEMPLATE_DIR = join8(CLI_TEMPLATE_DIR, "rules");
|
|
3672
3668
|
function sanitizeSkillDirName(name) {
|
|
3673
3669
|
const trimmed = name.trim();
|
|
3674
3670
|
if (!trimmed) return "skill";
|
|
@@ -3677,39 +3673,39 @@ function sanitizeSkillDirName(name) {
|
|
|
3677
3673
|
function listBaseSkillDirNames() {
|
|
3678
3674
|
if (!existsSync7(BASE_SKILLS_TEMPLATE_DIR)) return [];
|
|
3679
3675
|
return readdirSync4(BASE_SKILLS_TEMPLATE_DIR).filter((name) => {
|
|
3680
|
-
const path =
|
|
3676
|
+
const path = join8(BASE_SKILLS_TEMPLATE_DIR, name);
|
|
3681
3677
|
return statSync3(path).isDirectory();
|
|
3682
3678
|
});
|
|
3683
3679
|
}
|
|
3684
3680
|
function syncAgentsGuide(apmDir) {
|
|
3685
3681
|
if (!existsSync7(AGENTS_TEMPLATE_PATH)) return false;
|
|
3686
|
-
|
|
3687
|
-
copyFileSync2(AGENTS_TEMPLATE_PATH,
|
|
3682
|
+
mkdirSync6(apmDir, { recursive: true });
|
|
3683
|
+
copyFileSync2(AGENTS_TEMPLATE_PATH, join8(apmDir, "AGENTS.md"));
|
|
3688
3684
|
return true;
|
|
3689
3685
|
}
|
|
3690
3686
|
function listBaseRuleFileNames() {
|
|
3691
3687
|
if (!existsSync7(BASE_RULES_TEMPLATE_DIR)) return [];
|
|
3692
3688
|
return readdirSync4(BASE_RULES_TEMPLATE_DIR).filter((name) => {
|
|
3693
|
-
const path =
|
|
3689
|
+
const path = join8(BASE_RULES_TEMPLATE_DIR, name);
|
|
3694
3690
|
return statSync3(path).isFile();
|
|
3695
3691
|
});
|
|
3696
3692
|
}
|
|
3697
3693
|
function syncBaseRules(rulesDir) {
|
|
3698
|
-
|
|
3694
|
+
mkdirSync6(rulesDir, { recursive: true });
|
|
3699
3695
|
const names = listBaseRuleFileNames();
|
|
3700
3696
|
for (const name of names) {
|
|
3701
|
-
const src =
|
|
3702
|
-
const dest =
|
|
3697
|
+
const src = join8(BASE_RULES_TEMPLATE_DIR, name);
|
|
3698
|
+
const dest = join8(rulesDir, name);
|
|
3703
3699
|
copyFileSync2(src, dest);
|
|
3704
3700
|
}
|
|
3705
3701
|
return names;
|
|
3706
3702
|
}
|
|
3707
3703
|
function syncBaseSkills(skillsDir) {
|
|
3708
|
-
|
|
3704
|
+
mkdirSync6(skillsDir, { recursive: true });
|
|
3709
3705
|
const names = listBaseSkillDirNames();
|
|
3710
3706
|
for (const name of names) {
|
|
3711
|
-
const src =
|
|
3712
|
-
const dest =
|
|
3707
|
+
const src = join8(BASE_SKILLS_TEMPLATE_DIR, name);
|
|
3708
|
+
const dest = join8(skillsDir, name);
|
|
3713
3709
|
cpSync(src, dest, { recursive: true, force: true });
|
|
3714
3710
|
}
|
|
3715
3711
|
return names;
|
|
@@ -3726,15 +3722,15 @@ function syncSupplementarySkills(skillsDir, list) {
|
|
|
3726
3722
|
skipped.push(dirName);
|
|
3727
3723
|
continue;
|
|
3728
3724
|
}
|
|
3729
|
-
const skillDir =
|
|
3730
|
-
|
|
3731
|
-
writeFileSync9(
|
|
3725
|
+
const skillDir = join8(skillsDir, dirName);
|
|
3726
|
+
mkdirSync6(skillDir, { recursive: true });
|
|
3727
|
+
writeFileSync9(join8(skillDir, "SKILL.md"), skill.content ?? "", "utf8");
|
|
3732
3728
|
written.push(dirName);
|
|
3733
3729
|
}
|
|
3734
3730
|
const removed = [];
|
|
3735
3731
|
if (!existsSync7(skillsDir)) return { written, skipped, removed };
|
|
3736
3732
|
for (const entry of readdirSync4(skillsDir)) {
|
|
3737
|
-
const full =
|
|
3733
|
+
const full = join8(skillsDir, entry);
|
|
3738
3734
|
if (!statSync3(full).isDirectory()) continue;
|
|
3739
3735
|
if (baseNames.has(entry)) continue;
|
|
3740
3736
|
if (apiDirNames.has(entry)) continue;
|
|
@@ -3760,13 +3756,13 @@ async function syncWorkspaceSkills(cfg, workdir) {
|
|
|
3760
3756
|
if (syncAgentsGuide(apmDir)) {
|
|
3761
3757
|
console.log("[apm] \u5DF2\u540C\u6B65 APM \u6307\u5357: .apm/AGENTS.md");
|
|
3762
3758
|
}
|
|
3763
|
-
const rulesDir =
|
|
3759
|
+
const rulesDir = join9(apmDir, "rules");
|
|
3764
3760
|
const ruleNames = syncBaseRules(rulesDir);
|
|
3765
3761
|
for (const name of ruleNames) {
|
|
3766
3762
|
console.log(`[apm] \u5DF2\u540C\u6B65\u57FA\u7840\u89C4\u5219: rules/${name}`);
|
|
3767
3763
|
}
|
|
3768
|
-
const skillsDir =
|
|
3769
|
-
|
|
3764
|
+
const skillsDir = join9(apmDir, "skills");
|
|
3765
|
+
mkdirSync7(toFsPath(skillsDir), { recursive: true });
|
|
3770
3766
|
const baseNames = syncBaseSkills(skillsDir);
|
|
3771
3767
|
for (const name of baseNames) {
|
|
3772
3768
|
console.log(`[apm] \u5DF2\u540C\u6B65\u57FA\u7840\u6280\u80FD: skills/${name}/`);
|
|
@@ -3793,7 +3789,7 @@ async function syncWorkspaceSkills(cfg, workdir) {
|
|
|
3793
3789
|
|
|
3794
3790
|
// src/commands/sync-session-attachments.ts
|
|
3795
3791
|
import { existsSync as existsSync9, readFileSync as readFileSync9, writeFileSync as writeFileSync10 } from "fs";
|
|
3796
|
-
import { join as
|
|
3792
|
+
import { join as join10 } from "path";
|
|
3797
3793
|
var MANIFEST_FILE2 = ".sync-manifest.json";
|
|
3798
3794
|
async function downloadAttachment(cfg, attachmentId) {
|
|
3799
3795
|
const base = cfg.baseUrl.trim().replace(/\/+$/, "");
|
|
@@ -3809,7 +3805,7 @@ async function downloadAttachment(cfg, attachmentId) {
|
|
|
3809
3805
|
return Buffer.from(await res.arrayBuffer());
|
|
3810
3806
|
}
|
|
3811
3807
|
function loadManifest(dir) {
|
|
3812
|
-
const path =
|
|
3808
|
+
const path = join10(dir, MANIFEST_FILE2);
|
|
3813
3809
|
if (!existsSync9(path)) {
|
|
3814
3810
|
return { version: 1, attachments: {} };
|
|
3815
3811
|
}
|
|
@@ -3826,7 +3822,7 @@ function loadManifest(dir) {
|
|
|
3826
3822
|
}
|
|
3827
3823
|
function saveManifest(dir, manifest) {
|
|
3828
3824
|
writeFileSync10(
|
|
3829
|
-
|
|
3825
|
+
join10(dir, MANIFEST_FILE2),
|
|
3830
3826
|
`${JSON.stringify(manifest, null, 2)}
|
|
3831
3827
|
`,
|
|
3832
3828
|
"utf8"
|
|
@@ -3848,7 +3844,7 @@ async function syncAttachmentsToDirectory(cfg, attachments, dir, logLabel) {
|
|
|
3848
3844
|
const nextManifest = { version: 1, attachments: {} };
|
|
3849
3845
|
const names = [];
|
|
3850
3846
|
for (const item of attachments) {
|
|
3851
|
-
const dest =
|
|
3847
|
+
const dest = join10(dir, item.name);
|
|
3852
3848
|
const entry = manifest.attachments[item.id];
|
|
3853
3849
|
const createdAt = item.createdAt ?? "";
|
|
3854
3850
|
names.push(item.name);
|
|
@@ -3880,10 +3876,10 @@ async function syncWebIdeAttachments(cfg, taskId, workdir, attachments) {
|
|
|
3880
3876
|
|
|
3881
3877
|
// src/commands/connect/cli-version-sync.ts
|
|
3882
3878
|
import { existsSync as existsSync10, readFileSync as readFileSync10, writeFileSync as writeFileSync11 } from "fs";
|
|
3883
|
-
import { join as
|
|
3879
|
+
import { join as join11 } from "path";
|
|
3884
3880
|
var CLI_VERSION_FILE = ".cli-version.json";
|
|
3885
3881
|
function manifestPath2(apmDir) {
|
|
3886
|
-
return
|
|
3882
|
+
return join11(apmDir, CLI_VERSION_FILE);
|
|
3887
3883
|
}
|
|
3888
3884
|
function loadManifest2(apmDir) {
|
|
3889
3885
|
const path = toFsPath(manifestPath2(apmDir));
|