ai-project-manage-cli 8.1.24 → 8.1.25
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 +18 -4
- package/dist/worker-script.js +43 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1641,6 +1641,9 @@ async function pushCurrentBranch(cwd) {
|
|
|
1641
1641
|
});
|
|
1642
1642
|
}
|
|
1643
1643
|
|
|
1644
|
+
// src/commands/branch.ts
|
|
1645
|
+
import { basename as basename2 } from "path";
|
|
1646
|
+
|
|
1644
1647
|
// src/utils/workspace-repos.ts
|
|
1645
1648
|
import {
|
|
1646
1649
|
existsSync as existsSync7,
|
|
@@ -1754,6 +1757,7 @@ function formatRepoLabel(workdir, repoAbs) {
|
|
|
1754
1757
|
}
|
|
1755
1758
|
|
|
1756
1759
|
// src/commands/branch.ts
|
|
1760
|
+
import { existsSync as existsSync8 } from "fs";
|
|
1757
1761
|
var TASK_BRANCH_PREFIX = "feat/task-";
|
|
1758
1762
|
async function syncTaskRepos(workdir, options = {}) {
|
|
1759
1763
|
const opts = typeof options === "string" ? { message: options } : options;
|
|
@@ -1825,9 +1829,12 @@ async function ensureTaskFeatureBranch(branch, projectId, options) {
|
|
|
1825
1829
|
await ensureFeatureBranch(gitRoot, branch, projectId);
|
|
1826
1830
|
return branch;
|
|
1827
1831
|
}
|
|
1832
|
+
function isWorkspaceReposManifestFile(manifestPath2) {
|
|
1833
|
+
return basename2(manifestPath2.replace(/\\/g, "/")) === WORKSPACE_REPOS_MANIFEST;
|
|
1834
|
+
}
|
|
1828
1835
|
function resolveTaskBranchRepoRoots(workdirPath, reposManifest) {
|
|
1829
1836
|
const manifestPath2 = resolveReposManifestPath(reposManifest);
|
|
1830
|
-
if (manifestPath2) {
|
|
1837
|
+
if (manifestPath2 && !isWorkspaceReposManifestFile(manifestPath2)) {
|
|
1831
1838
|
const entries = loadHomeRepositoryEntries(manifestPath2);
|
|
1832
1839
|
const roots2 = resolveHomeRepositoryAbsolutePaths(workdirPath, entries);
|
|
1833
1840
|
console.log(
|
|
@@ -1835,6 +1842,13 @@ function resolveTaskBranchRepoRoots(workdirPath, reposManifest) {
|
|
|
1835
1842
|
);
|
|
1836
1843
|
return roots2;
|
|
1837
1844
|
}
|
|
1845
|
+
if (manifestPath2 && isWorkspaceReposManifestFile(manifestPath2)) {
|
|
1846
|
+
const fsPath = toFsPath(manifestPath2);
|
|
1847
|
+
if (!existsSync8(fsPath)) {
|
|
1848
|
+
throw new Error(`[apm] \u672A\u627E\u5230\u5DE5\u4F5C\u533A\u4ED3\u5E93\u6E05\u5355 ${manifestPath2}`);
|
|
1849
|
+
}
|
|
1850
|
+
console.log(`[apm] \u4F7F\u7528\u663E\u5F0F\u5DE5\u4F5C\u533A\u4ED3\u5E93\u6E05\u5355 ${manifestPath2}`);
|
|
1851
|
+
}
|
|
1838
1852
|
const workspace = loadWorkspaceReposCache(workdirPath);
|
|
1839
1853
|
const roots = resolveWorkspaceRepoAbsolutePaths(workspace);
|
|
1840
1854
|
console.log(
|
|
@@ -1919,7 +1933,7 @@ async function runEnsureTaskBranchCli(options = {}) {
|
|
|
1919
1933
|
|
|
1920
1934
|
// src/utils/user-prompt-cache.ts
|
|
1921
1935
|
import { createHash } from "crypto";
|
|
1922
|
-
import { existsSync as
|
|
1936
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "fs";
|
|
1923
1937
|
import { join as join11 } from "path";
|
|
1924
1938
|
import { tmpdir } from "os";
|
|
1925
1939
|
var CACHE_ROOT = join11(tmpdir(), "apm-hooks");
|
|
@@ -1941,7 +1955,7 @@ function formatUserPromptAsCommitMessage(prompt) {
|
|
|
1941
1955
|
}
|
|
1942
1956
|
function loadUserPromptCommitMessage(workdirInput) {
|
|
1943
1957
|
const path = toFsPath(userPromptCachePath(workdirInput));
|
|
1944
|
-
if (!
|
|
1958
|
+
if (!existsSync9(path)) return null;
|
|
1945
1959
|
try {
|
|
1946
1960
|
const raw = readFileSync7(path, "utf8");
|
|
1947
1961
|
const msg = formatUserPromptAsCommitMessage(raw);
|
|
@@ -1991,7 +2005,7 @@ async function runCommitTaskReposCli(options = {}) {
|
|
|
1991
2005
|
);
|
|
1992
2006
|
if (result.failed.length > 0) {
|
|
1993
2007
|
throw new Error(
|
|
1994
|
-
`[apm] \
|
|
2008
|
+
`[apm] \u591A\u4ED3\u6536\u5C3E\u90E8\u5206\u5931\u8D25: ${result.failed.join(", ")}`
|
|
1995
2009
|
);
|
|
1996
2010
|
}
|
|
1997
2011
|
}
|
package/dist/worker-script.js
CHANGED
|
@@ -579,6 +579,9 @@ function resolveHomeRepositoryAbsolutePaths(workdirInput, entries) {
|
|
|
579
579
|
return entries.map((entry) => resolve3(join4(workdir, entry.path)));
|
|
580
580
|
}
|
|
581
581
|
|
|
582
|
+
// src/commands/branch.ts
|
|
583
|
+
import { basename as basename2 } from "path";
|
|
584
|
+
|
|
582
585
|
// src/utils/workspace-repos.ts
|
|
583
586
|
import {
|
|
584
587
|
existsSync as existsSync3,
|
|
@@ -861,6 +864,7 @@ function formatRepoLabel(workdir, repoAbs) {
|
|
|
861
864
|
}
|
|
862
865
|
|
|
863
866
|
// src/commands/branch.ts
|
|
867
|
+
import { existsSync as existsSync4 } from "fs";
|
|
864
868
|
var TASK_BRANCH_PREFIX = "feat/task-";
|
|
865
869
|
async function commitWorkspaceReposIfDirty(workdir, message, reposManifest) {
|
|
866
870
|
const result = await commitTaskReposIfDirty(workdir, message, reposManifest);
|
|
@@ -970,9 +974,12 @@ async function resolveProjectIdForTask(taskId) {
|
|
|
970
974
|
}
|
|
971
975
|
return projectId;
|
|
972
976
|
}
|
|
977
|
+
function isWorkspaceReposManifestFile(manifestPath2) {
|
|
978
|
+
return basename2(manifestPath2.replace(/\\/g, "/")) === WORKSPACE_REPOS_MANIFEST;
|
|
979
|
+
}
|
|
973
980
|
function resolveTaskBranchRepoRoots(workdirPath, reposManifest) {
|
|
974
981
|
const manifestPath2 = resolveReposManifestPath(reposManifest);
|
|
975
|
-
if (manifestPath2) {
|
|
982
|
+
if (manifestPath2 && !isWorkspaceReposManifestFile(manifestPath2)) {
|
|
976
983
|
const entries = loadHomeRepositoryEntries(manifestPath2);
|
|
977
984
|
const roots2 = resolveHomeRepositoryAbsolutePaths(workdirPath, entries);
|
|
978
985
|
console.log(
|
|
@@ -980,6 +987,13 @@ function resolveTaskBranchRepoRoots(workdirPath, reposManifest) {
|
|
|
980
987
|
);
|
|
981
988
|
return roots2;
|
|
982
989
|
}
|
|
990
|
+
if (manifestPath2 && isWorkspaceReposManifestFile(manifestPath2)) {
|
|
991
|
+
const fsPath = toFsPath(manifestPath2);
|
|
992
|
+
if (!existsSync4(fsPath)) {
|
|
993
|
+
throw new Error(`[apm] \u672A\u627E\u5230\u5DE5\u4F5C\u533A\u4ED3\u5E93\u6E05\u5355 ${manifestPath2}`);
|
|
994
|
+
}
|
|
995
|
+
console.log(`[apm] \u4F7F\u7528\u663E\u5F0F\u5DE5\u4F5C\u533A\u4ED3\u5E93\u6E05\u5355 ${manifestPath2}`);
|
|
996
|
+
}
|
|
983
997
|
const workspace = loadWorkspaceReposCache(workdirPath);
|
|
984
998
|
const roots = resolveWorkspaceRepoAbsolutePaths(workspace);
|
|
985
999
|
console.log(
|
|
@@ -1690,7 +1704,7 @@ function createUpsertWebIdeTestCasesTool(options) {
|
|
|
1690
1704
|
}
|
|
1691
1705
|
|
|
1692
1706
|
// src/commands/connect/tools/mysql-tools.ts
|
|
1693
|
-
import { existsSync as
|
|
1707
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4, statSync as statSync3 } from "node:fs";
|
|
1694
1708
|
import { isAbsolute, relative as relative2, resolve as resolve5 } from "node:path";
|
|
1695
1709
|
import mysql from "mysql2/promise";
|
|
1696
1710
|
var MAX_RESULT_ROWS = 100;
|
|
@@ -1769,7 +1783,7 @@ function resolveSqlArtifactPath(workdir, absolutePath) {
|
|
|
1769
1783
|
return { ok: false, error: "path \u5FC5\u987B\u4F4D\u4E8E\u5F53\u524D\u5DE5\u4F5C\u533A\u5185" };
|
|
1770
1784
|
}
|
|
1771
1785
|
const fsPath = toFsPath(targetAbs);
|
|
1772
|
-
if (!
|
|
1786
|
+
if (!existsSync5(fsPath)) {
|
|
1773
1787
|
return { ok: false, error: `\u6587\u4EF6\u4E0D\u5B58\u5728: ${absolutePath}` };
|
|
1774
1788
|
}
|
|
1775
1789
|
let st;
|
|
@@ -2644,14 +2658,14 @@ async function runCursorAgent(cfg2, ctx, options) {
|
|
|
2644
2658
|
}
|
|
2645
2659
|
|
|
2646
2660
|
// src/commands/connect/webide-agent-registry.ts
|
|
2647
|
-
import { existsSync as
|
|
2661
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "node:fs";
|
|
2648
2662
|
import { dirname as dirname3, resolve as resolve6 } from "node:path";
|
|
2649
2663
|
function registryPath(workdir, taskId, fileName = "cursor-agent.json") {
|
|
2650
2664
|
return resolve6(workdir, ".apm", "webide", taskId, fileName);
|
|
2651
2665
|
}
|
|
2652
2666
|
var DESIGN_AGENT_FILE = "design-agent.json";
|
|
2653
2667
|
function readRegistry(path) {
|
|
2654
|
-
if (!
|
|
2668
|
+
if (!existsSync6(path)) {
|
|
2655
2669
|
return {};
|
|
2656
2670
|
}
|
|
2657
2671
|
try {
|
|
@@ -2726,7 +2740,7 @@ function saveWebIdeAgentId(workdir, taskId, agentId) {
|
|
|
2726
2740
|
}
|
|
2727
2741
|
function clearWebIdeAgentId(workdir, taskId) {
|
|
2728
2742
|
const path = registryPath(workdir, taskId);
|
|
2729
|
-
if (!
|
|
2743
|
+
if (!existsSync6(path)) return;
|
|
2730
2744
|
syncWebIdeTaskState(workdir, taskId, { agentId: "" });
|
|
2731
2745
|
}
|
|
2732
2746
|
function loadWebIdeDesignAgentId(workdir, taskId) {
|
|
@@ -2746,7 +2760,7 @@ function saveWebIdeDesignAgentId(workdir, taskId, agentId) {
|
|
|
2746
2760
|
}
|
|
2747
2761
|
function clearWebIdeDesignAgentId(workdir, taskId) {
|
|
2748
2762
|
const path = registryPath(workdir, taskId, DESIGN_AGENT_FILE);
|
|
2749
|
-
if (!
|
|
2763
|
+
if (!existsSync6(path)) return;
|
|
2750
2764
|
const current = readRegistry(path);
|
|
2751
2765
|
const next = { ...current };
|
|
2752
2766
|
delete next.agentId;
|
|
@@ -2802,24 +2816,27 @@ async function fetchAssumptionAnswersAndContinueAssessment(options) {
|
|
|
2802
2816
|
if (ids.length === 0) {
|
|
2803
2817
|
throw new Error("\u6CA1\u6709\u5DF2\u786E\u8BA4\u7684\u5047\u8BBE");
|
|
2804
2818
|
}
|
|
2805
|
-
const
|
|
2819
|
+
const lines = [];
|
|
2820
|
+
if (title?.trim()) {
|
|
2821
|
+
lines.push(title.trim(), "");
|
|
2822
|
+
}
|
|
2823
|
+
let index = 0;
|
|
2806
2824
|
for (const id of ids) {
|
|
2807
2825
|
const row = byId.get(id);
|
|
2808
2826
|
if (!row || row.status !== "RESOLVED") {
|
|
2809
2827
|
throw new Error(`\u5047\u8BBE\u5C1A\u672A\u5168\u90E8\u786E\u8BA4: ${id}`);
|
|
2810
2828
|
}
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
});
|
|
2829
|
+
const text = asString4(row.resolution) || asString4(row.customAnswer) || asString4(row.selectedOptionId);
|
|
2830
|
+
if (!text) {
|
|
2831
|
+
throw new Error(`\u5047\u8BBE\u7B54\u6848\u4E3A\u7A7A: ${id}`);
|
|
2832
|
+
}
|
|
2833
|
+
index += 1;
|
|
2834
|
+
lines.push(`${index}. ${text}`);
|
|
2818
2835
|
}
|
|
2819
2836
|
console.log(
|
|
2820
|
-
`[apm] \u5047\u8BBE\u7ED3\u679C\u5DF2\u62C9\u53D6 taskId=${taskId} count=${
|
|
2837
|
+
`[apm] \u5047\u8BBE\u7ED3\u679C\u5DF2\u62C9\u53D6 taskId=${taskId} count=${index}`
|
|
2821
2838
|
);
|
|
2822
|
-
return
|
|
2839
|
+
return lines.join("\n");
|
|
2823
2840
|
}
|
|
2824
2841
|
function createWebIdeAskQuestionExecute(options) {
|
|
2825
2842
|
const { cfg: cfg2, taskId, onAwaitingAssumptions } = options;
|
|
@@ -3083,7 +3100,7 @@ function resolveMessageReplyFallback(fallback) {
|
|
|
3083
3100
|
|
|
3084
3101
|
// src/commands/sync-webide-agent.ts
|
|
3085
3102
|
import {
|
|
3086
|
-
existsSync as
|
|
3103
|
+
existsSync as existsSync7,
|
|
3087
3104
|
mkdirSync as mkdirSync5,
|
|
3088
3105
|
readdirSync as readdirSync3,
|
|
3089
3106
|
readFileSync as readFileSync6,
|
|
@@ -3099,7 +3116,7 @@ function withTrailingNewline(text) {
|
|
|
3099
3116
|
}
|
|
3100
3117
|
function readRevision(apmDir) {
|
|
3101
3118
|
const path = toFsPath(join6(apmDir, REVISION_FILE));
|
|
3102
|
-
if (!
|
|
3119
|
+
if (!existsSync7(path)) return null;
|
|
3103
3120
|
try {
|
|
3104
3121
|
const parsed = JSON.parse(readFileSync6(path, "utf8"));
|
|
3105
3122
|
if (parsed?.version === 1 && parsed.revision?.trim()) {
|
|
@@ -3400,7 +3417,7 @@ async function ensureWebIdePullRequests(cfg2, taskId, workdir) {
|
|
|
3400
3417
|
}
|
|
3401
3418
|
|
|
3402
3419
|
// src/commands/sync-webide-attachments.ts
|
|
3403
|
-
import { existsSync as
|
|
3420
|
+
import { existsSync as existsSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "fs";
|
|
3404
3421
|
import { join as join7 } from "path";
|
|
3405
3422
|
var MANIFEST_FILE = ".sync-manifest.json";
|
|
3406
3423
|
async function downloadAttachment(cfg2, attachmentId) {
|
|
@@ -3418,7 +3435,7 @@ async function downloadAttachment(cfg2, attachmentId) {
|
|
|
3418
3435
|
}
|
|
3419
3436
|
function loadManifest(dir) {
|
|
3420
3437
|
const path = join7(dir, MANIFEST_FILE);
|
|
3421
|
-
if (!
|
|
3438
|
+
if (!existsSync8(path)) {
|
|
3422
3439
|
return { version: 1, attachments: {} };
|
|
3423
3440
|
}
|
|
3424
3441
|
try {
|
|
@@ -3441,7 +3458,7 @@ function saveManifest(dir, manifest) {
|
|
|
3441
3458
|
);
|
|
3442
3459
|
}
|
|
3443
3460
|
function isAttachmentUpToDate(entry, item, dest) {
|
|
3444
|
-
if (!entry || !
|
|
3461
|
+
if (!entry || !existsSync8(dest)) return false;
|
|
3445
3462
|
if (entry.name !== item.name) return false;
|
|
3446
3463
|
const createdAt = item.createdAt ?? "";
|
|
3447
3464
|
return entry.createdAt === createdAt;
|
|
@@ -3488,7 +3505,7 @@ async function syncWebIdeAttachments(cfg2, taskId, workdir, attachments) {
|
|
|
3488
3505
|
|
|
3489
3506
|
// src/commands/sync-webide-design.ts
|
|
3490
3507
|
import { createHash } from "crypto";
|
|
3491
|
-
import { existsSync as
|
|
3508
|
+
import { existsSync as existsSync9, readdirSync as readdirSync4, readFileSync as readFileSync8, statSync as statSync4, writeFileSync as writeFileSync6 } from "fs";
|
|
3492
3509
|
import { join as join8 } from "path";
|
|
3493
3510
|
|
|
3494
3511
|
// src/opc-shared-types.ts
|
|
@@ -3511,7 +3528,7 @@ function hashBuffer(buf) {
|
|
|
3511
3528
|
}
|
|
3512
3529
|
function loadManifest2(dir) {
|
|
3513
3530
|
const path = join8(dir, MANIFEST_FILE2);
|
|
3514
|
-
if (!
|
|
3531
|
+
if (!existsSync9(path)) {
|
|
3515
3532
|
return { version: 1, files: {} };
|
|
3516
3533
|
}
|
|
3517
3534
|
try {
|
|
@@ -3555,7 +3572,7 @@ async function syncWebIdeDesign(cfg2, taskId, workdir, artifacts) {
|
|
|
3555
3572
|
if (!name || !isWebIdeDesignArtifactName(name)) continue;
|
|
3556
3573
|
const localPath = join8(dir, name);
|
|
3557
3574
|
const entry = manifest.files[name];
|
|
3558
|
-
if (entry?.contentHash === art.contentHash &&
|
|
3575
|
+
if (entry?.contentHash === art.contentHash && existsSync9(localPath)) {
|
|
3559
3576
|
continue;
|
|
3560
3577
|
}
|
|
3561
3578
|
const buf = await downloadDesignFile(cfg2, taskId, name);
|
|
@@ -3568,7 +3585,7 @@ async function syncWebIdeDesign(cfg2, taskId, workdir, artifacts) {
|
|
|
3568
3585
|
}
|
|
3569
3586
|
function listLocalDesignArtifactFiles(taskId, workdir) {
|
|
3570
3587
|
const dir = webideDesignDir(taskId, workdir);
|
|
3571
|
-
if (!
|
|
3588
|
+
if (!existsSync9(dir)) return [];
|
|
3572
3589
|
const out = [];
|
|
3573
3590
|
for (const name of readdirSync4(dir)) {
|
|
3574
3591
|
if (!isWebIdeDesignArtifactName(name)) continue;
|