ai-project-manage-cli 8.1.8 → 8.1.10
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 +21 -7
- package/dist/worker-script.js +43 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -80,7 +80,14 @@ function buildAgentWsUrl(httpBase, apiKey) {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// src/commands/sync-webide-agent.ts
|
|
83
|
-
import {
|
|
83
|
+
import {
|
|
84
|
+
existsSync as existsSync2,
|
|
85
|
+
mkdirSync as mkdirSync3,
|
|
86
|
+
readdirSync as readdirSync2,
|
|
87
|
+
readFileSync as readFileSync2,
|
|
88
|
+
unlinkSync,
|
|
89
|
+
writeFileSync as writeFileSync2
|
|
90
|
+
} from "fs";
|
|
84
91
|
import { join as join3 } from "path";
|
|
85
92
|
|
|
86
93
|
// src/api/client.ts
|
|
@@ -368,7 +375,7 @@ async function ensureWorkspaceApmDirForInit(cwd = resolveWorkdirPath()) {
|
|
|
368
375
|
|
|
369
376
|
// src/commands/sync-webide-agent.ts
|
|
370
377
|
var REVISION_FILE = ".webide-agent.json";
|
|
371
|
-
var RULE_KEY = /^
|
|
378
|
+
var RULE_KEY = /^[a-z0-9_]+$/;
|
|
372
379
|
function withTrailingNewline(text) {
|
|
373
380
|
return text.endsWith("\n") ? text : `${text}
|
|
374
381
|
`;
|
|
@@ -413,17 +420,24 @@ async function syncWebIdeAgentFiles(workdir, cfg) {
|
|
|
413
420
|
withTrailingNewline(bundle.guide ?? ""),
|
|
414
421
|
"utf8"
|
|
415
422
|
);
|
|
423
|
+
const keep = /* @__PURE__ */ new Set();
|
|
416
424
|
for (const rule of bundle.rules ?? []) {
|
|
417
425
|
const key = rule.key?.trim() ?? "";
|
|
418
426
|
if (!RULE_KEY.test(key)) {
|
|
419
427
|
throw new Error(`[apm] \u975E\u6CD5\u89C4\u5219\u540D: ${key || "(\u7A7A)"}`);
|
|
420
428
|
}
|
|
429
|
+
keep.add(`${key}.md`);
|
|
421
430
|
writeFileSync2(
|
|
422
431
|
toFsPath(join3(rulesDir, `${key}.md`)),
|
|
423
432
|
withTrailingNewline(rule.body ?? ""),
|
|
424
433
|
"utf8"
|
|
425
434
|
);
|
|
426
435
|
}
|
|
436
|
+
for (const name of readdirSync2(toFsPath(rulesDir))) {
|
|
437
|
+
if (!name.endsWith(".md")) continue;
|
|
438
|
+
if (keep.has(name)) continue;
|
|
439
|
+
unlinkSync(toFsPath(join3(rulesDir, name)));
|
|
440
|
+
}
|
|
427
441
|
writeRevision(apmDir, revision);
|
|
428
442
|
return {
|
|
429
443
|
revision,
|
|
@@ -754,7 +768,7 @@ async function runUpdateSkills() {
|
|
|
754
768
|
// src/utils/project-documents.ts
|
|
755
769
|
import {
|
|
756
770
|
existsSync as existsSync5,
|
|
757
|
-
readdirSync as
|
|
771
|
+
readdirSync as readdirSync3,
|
|
758
772
|
readFileSync as readFileSync4,
|
|
759
773
|
rmSync,
|
|
760
774
|
writeFileSync as writeFileSync3
|
|
@@ -880,7 +894,7 @@ function listLocalDocumentPaths(apmRoot, projectId) {
|
|
|
880
894
|
}
|
|
881
895
|
const paths = [];
|
|
882
896
|
const walk = (dir) => {
|
|
883
|
-
for (const entry of
|
|
897
|
+
for (const entry of readdirSync3(dir, { withFileTypes: true })) {
|
|
884
898
|
const abs = join6(dir, entry.name);
|
|
885
899
|
if (entry.isDirectory()) {
|
|
886
900
|
walk(abs);
|
|
@@ -1716,7 +1730,7 @@ import {
|
|
|
1716
1730
|
existsSync as existsSync6,
|
|
1717
1731
|
mkdirSync as mkdirSync4,
|
|
1718
1732
|
readFileSync as readFileSync5,
|
|
1719
|
-
unlinkSync,
|
|
1733
|
+
unlinkSync as unlinkSync2,
|
|
1720
1734
|
writeFileSync as writeFileSync4
|
|
1721
1735
|
} from "fs";
|
|
1722
1736
|
import { join as join8 } from "path";
|
|
@@ -1751,7 +1765,7 @@ function pruneStaleConnectLock() {
|
|
|
1751
1765
|
if (!lock) return;
|
|
1752
1766
|
if (isProcessAlive(lock.pid)) return;
|
|
1753
1767
|
try {
|
|
1754
|
-
|
|
1768
|
+
unlinkSync2(CONNECT_LOCK_PATH);
|
|
1755
1769
|
} catch {
|
|
1756
1770
|
}
|
|
1757
1771
|
}
|
|
@@ -1780,7 +1794,7 @@ function releaseConnectLock() {
|
|
|
1780
1794
|
const lock = readConnectLock();
|
|
1781
1795
|
if (lock?.pid !== process.pid) return;
|
|
1782
1796
|
try {
|
|
1783
|
-
|
|
1797
|
+
unlinkSync2(CONNECT_LOCK_PATH);
|
|
1784
1798
|
} catch {
|
|
1785
1799
|
}
|
|
1786
1800
|
}
|
package/dist/worker-script.js
CHANGED
|
@@ -3138,10 +3138,17 @@ function createThrottledWebIdeMessageLogSync(cfg2, ctx, onError, options) {
|
|
|
3138
3138
|
}
|
|
3139
3139
|
|
|
3140
3140
|
// src/commands/sync-webide-agent.ts
|
|
3141
|
-
import {
|
|
3141
|
+
import {
|
|
3142
|
+
existsSync as existsSync5,
|
|
3143
|
+
mkdirSync as mkdirSync4,
|
|
3144
|
+
readdirSync as readdirSync3,
|
|
3145
|
+
readFileSync as readFileSync4,
|
|
3146
|
+
unlinkSync,
|
|
3147
|
+
writeFileSync as writeFileSync3
|
|
3148
|
+
} from "fs";
|
|
3142
3149
|
import { join as join4 } from "path";
|
|
3143
3150
|
var REVISION_FILE = ".webide-agent.json";
|
|
3144
|
-
var RULE_KEY = /^
|
|
3151
|
+
var RULE_KEY = /^[a-z0-9_]+$/;
|
|
3145
3152
|
function withTrailingNewline(text) {
|
|
3146
3153
|
return text.endsWith("\n") ? text : `${text}
|
|
3147
3154
|
`;
|
|
@@ -3186,17 +3193,24 @@ async function syncWebIdeAgentFiles(workdir, cfg2) {
|
|
|
3186
3193
|
withTrailingNewline(bundle.guide ?? ""),
|
|
3187
3194
|
"utf8"
|
|
3188
3195
|
);
|
|
3196
|
+
const keep = /* @__PURE__ */ new Set();
|
|
3189
3197
|
for (const rule of bundle.rules ?? []) {
|
|
3190
3198
|
const key = rule.key?.trim() ?? "";
|
|
3191
3199
|
if (!RULE_KEY.test(key)) {
|
|
3192
3200
|
throw new Error(`[apm] \u975E\u6CD5\u89C4\u5219\u540D: ${key || "(\u7A7A)"}`);
|
|
3193
3201
|
}
|
|
3202
|
+
keep.add(`${key}.md`);
|
|
3194
3203
|
writeFileSync3(
|
|
3195
3204
|
toFsPath(join4(rulesDir, `${key}.md`)),
|
|
3196
3205
|
withTrailingNewline(rule.body ?? ""),
|
|
3197
3206
|
"utf8"
|
|
3198
3207
|
);
|
|
3199
3208
|
}
|
|
3209
|
+
for (const name of readdirSync3(toFsPath(rulesDir))) {
|
|
3210
|
+
if (!name.endsWith(".md")) continue;
|
|
3211
|
+
if (keep.has(name)) continue;
|
|
3212
|
+
unlinkSync(toFsPath(join4(rulesDir, name)));
|
|
3213
|
+
}
|
|
3200
3214
|
writeRevision(apmDir, revision);
|
|
3201
3215
|
return {
|
|
3202
3216
|
revision,
|
|
@@ -3221,7 +3235,7 @@ async function ensureWorkspaceInitialized(workdir) {
|
|
|
3221
3235
|
// src/utils/project-documents.ts
|
|
3222
3236
|
import {
|
|
3223
3237
|
existsSync as existsSync6,
|
|
3224
|
-
readdirSync as
|
|
3238
|
+
readdirSync as readdirSync4,
|
|
3225
3239
|
readFileSync as readFileSync5,
|
|
3226
3240
|
rmSync,
|
|
3227
3241
|
writeFileSync as writeFileSync4
|
|
@@ -3287,7 +3301,7 @@ function listLocalDocumentPaths(apmRoot, projectId) {
|
|
|
3287
3301
|
}
|
|
3288
3302
|
const paths = [];
|
|
3289
3303
|
const walk = (dir) => {
|
|
3290
|
-
for (const entry of
|
|
3304
|
+
for (const entry of readdirSync4(dir, { withFileTypes: true })) {
|
|
3291
3305
|
const abs = join5(dir, entry.name);
|
|
3292
3306
|
if (entry.isDirectory()) {
|
|
3293
3307
|
walk(abs);
|
|
@@ -4531,8 +4545,23 @@ async function syncWebIdeAttachments(cfg2, taskId, workdir, attachments) {
|
|
|
4531
4545
|
|
|
4532
4546
|
// src/commands/sync-webide-design.ts
|
|
4533
4547
|
import { createHash as createHash3 } from "crypto";
|
|
4534
|
-
import { existsSync as existsSync10, readdirSync as
|
|
4548
|
+
import { existsSync as existsSync10, readdirSync as readdirSync5, readFileSync as readFileSync8, statSync as statSync5, writeFileSync as writeFileSync7 } from "fs";
|
|
4535
4549
|
import { join as join7 } from "path";
|
|
4550
|
+
|
|
4551
|
+
// src/opc-shared-types.ts
|
|
4552
|
+
function webIdeDesignObjectKey(taskId, fileName) {
|
|
4553
|
+
const safe = fileName.replace(/[/\\:*?"<>|]/g, "_").trim() || "index.html";
|
|
4554
|
+
return `tasks/${taskId.trim()}/design/${safe}`;
|
|
4555
|
+
}
|
|
4556
|
+
function isWebIdeDesignArtifactName(name) {
|
|
4557
|
+
const lower = name.trim().toLowerCase();
|
|
4558
|
+
return lower.endsWith(".html") || lower.endsWith(".css");
|
|
4559
|
+
}
|
|
4560
|
+
function webIdeDesignArtifactContentType(name) {
|
|
4561
|
+
return name.trim().toLowerCase().endsWith(".css") ? "text/css; charset=utf-8" : "text/html; charset=utf-8";
|
|
4562
|
+
}
|
|
4563
|
+
|
|
4564
|
+
// src/commands/sync-webide-design.ts
|
|
4536
4565
|
var MANIFEST_FILE3 = ".sync-manifest.json";
|
|
4537
4566
|
function hashBuffer(buf) {
|
|
4538
4567
|
return createHash3("sha256").update(buf).digest("hex");
|
|
@@ -4580,7 +4609,7 @@ async function syncWebIdeDesign(cfg2, taskId, workdir, artifacts) {
|
|
|
4580
4609
|
const synced = [];
|
|
4581
4610
|
for (const art of artifacts) {
|
|
4582
4611
|
const name = art.name?.trim();
|
|
4583
|
-
if (!name || !name
|
|
4612
|
+
if (!name || !isWebIdeDesignArtifactName(name)) continue;
|
|
4584
4613
|
const localPath = join7(dir, name);
|
|
4585
4614
|
const entry = manifest.files[name];
|
|
4586
4615
|
if (entry?.contentHash === art.contentHash && existsSync10(localPath)) {
|
|
@@ -4594,13 +4623,14 @@ async function syncWebIdeDesign(cfg2, taskId, workdir, artifacts) {
|
|
|
4594
4623
|
saveManifest2(dir, manifest);
|
|
4595
4624
|
return synced;
|
|
4596
4625
|
}
|
|
4597
|
-
function
|
|
4626
|
+
function listLocalDesignArtifactFiles(taskId, workdir) {
|
|
4598
4627
|
const dir = webideDesignDir(taskId, workdir);
|
|
4599
4628
|
if (!existsSync10(dir)) return [];
|
|
4600
4629
|
const out = [];
|
|
4601
|
-
for (const name of
|
|
4602
|
-
if (!name
|
|
4630
|
+
for (const name of readdirSync5(dir)) {
|
|
4631
|
+
if (!isWebIdeDesignArtifactName(name)) continue;
|
|
4603
4632
|
const absPath = join7(dir, name);
|
|
4633
|
+
if (!statSync5(absPath).isFile()) continue;
|
|
4604
4634
|
const buf = readFileSync8(absPath);
|
|
4605
4635
|
if (buf.length === 0) continue;
|
|
4606
4636
|
out.push({ name, absPath, contentHash: hashBuffer(buf) });
|
|
@@ -4608,25 +4638,17 @@ function listLocalDesignHtmlFiles(taskId, workdir) {
|
|
|
4608
4638
|
return out;
|
|
4609
4639
|
}
|
|
4610
4640
|
|
|
4611
|
-
// src/opc-shared-types.ts
|
|
4612
|
-
function webIdeDesignObjectKey(taskId, fileName) {
|
|
4613
|
-
const safe = fileName.replace(/[/\\:*?"<>|]/g, "_").trim() || "index.html";
|
|
4614
|
-
return `tasks/${taskId.trim()}/design/${safe}`;
|
|
4615
|
-
}
|
|
4616
|
-
|
|
4617
4641
|
// src/commands/connect/upload-webide-design.ts
|
|
4618
4642
|
async function uploadWebIdeDesignArtifacts(cfg2, taskId, workdir) {
|
|
4619
|
-
const locals =
|
|
4620
|
-
if (locals.
|
|
4643
|
+
const locals = listLocalDesignArtifactFiles(taskId, workdir);
|
|
4644
|
+
if (!locals.some((file) => file.name.toLowerCase().endsWith(".html"))) {
|
|
4621
4645
|
throw new Error(
|
|
4622
4646
|
`\u8BBE\u8BA1\u76EE\u5F55\u65E0 HTML \u4EA7\u7269\uFF1A.apm/webide/${taskId}/design/\uFF08\u8BF7\u5199\u5165\u81F3\u5C11\u4E00\u4EFD .html\uFF09`
|
|
4623
4647
|
);
|
|
4624
4648
|
}
|
|
4625
4649
|
const api = createApmApiClient(cfg2);
|
|
4626
4650
|
const remote = await api.cli.webideListDesignArtifacts({ taskId }) ?? [];
|
|
4627
|
-
const remoteByName = new Map(
|
|
4628
|
-
remote.map((r) => [r.name, r])
|
|
4629
|
-
);
|
|
4651
|
+
const remoteByName = new Map(remote.map((r) => [r.name, r]));
|
|
4630
4652
|
const { client, bucket } = await createApmLogMinioClient(cfg2);
|
|
4631
4653
|
await client.ensureBucket(bucket);
|
|
4632
4654
|
let uploaded = 0;
|
|
@@ -4645,7 +4667,7 @@ async function uploadWebIdeDesignArtifacts(cfg2, taskId, workdir) {
|
|
|
4645
4667
|
continue;
|
|
4646
4668
|
}
|
|
4647
4669
|
await client.fPutObject(bucket, objectKey, file.absPath, {
|
|
4648
|
-
"Content-Type":
|
|
4670
|
+
"Content-Type": webIdeDesignArtifactContentType(file.name)
|
|
4649
4671
|
});
|
|
4650
4672
|
uploaded += 1;
|
|
4651
4673
|
artifacts.push({
|