ai-project-manage-cli 4.0.2 → 4.0.4
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 +51 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -121,6 +121,10 @@ var requestConfig = {
|
|
|
121
121
|
method: "GET",
|
|
122
122
|
path: "/requirement-artifacts/list"
|
|
123
123
|
}),
|
|
124
|
+
get: defineEndpoint({
|
|
125
|
+
method: "GET",
|
|
126
|
+
path: "/requirement-artifacts/get"
|
|
127
|
+
}),
|
|
124
128
|
create: defineEndpoint({
|
|
125
129
|
method: "POST",
|
|
126
130
|
path: "/requirement-artifacts/create"
|
|
@@ -443,6 +447,38 @@ async function runUploadArtifact(requirementId, workspaceDir) {
|
|
|
443
447
|
import { writeFileSync as writeFileSync2 } from "fs";
|
|
444
448
|
import { join as join4 } from "path";
|
|
445
449
|
import { stringify as yamlStringify } from "yaml";
|
|
450
|
+
var PULL_ARTIFACT_FILE_NAMES = ["api.md", "backend.md"];
|
|
451
|
+
function normalizeArtifactPath(fileName) {
|
|
452
|
+
return fileName.trim().replace(/\\/g, "/").replace(/^\/+/, "");
|
|
453
|
+
}
|
|
454
|
+
function artifactFileNameMatches(itemFileName, targetFileName) {
|
|
455
|
+
const norm = normalizeArtifactPath(itemFileName);
|
|
456
|
+
const target = normalizeArtifactPath(targetFileName);
|
|
457
|
+
if (norm === target) return true;
|
|
458
|
+
const base = norm.split("/").filter(Boolean).pop() ?? norm;
|
|
459
|
+
return base === target;
|
|
460
|
+
}
|
|
461
|
+
async function fetchArtifactContentByFileName(api, requirementId, fileName) {
|
|
462
|
+
const pageSize = 500;
|
|
463
|
+
let page = 1;
|
|
464
|
+
const items = [];
|
|
465
|
+
while (true) {
|
|
466
|
+
const batch = await api.requirementArtifact.list({
|
|
467
|
+
requirementId,
|
|
468
|
+
page,
|
|
469
|
+
pageSize
|
|
470
|
+
});
|
|
471
|
+
items.push(...batch.items);
|
|
472
|
+
if (batch.total === 0 || items.length >= batch.total) break;
|
|
473
|
+
page += 1;
|
|
474
|
+
}
|
|
475
|
+
const hit = items.find(
|
|
476
|
+
(item) => artifactFileNameMatches(item.fileName, fileName)
|
|
477
|
+
);
|
|
478
|
+
if (!hit) return null;
|
|
479
|
+
const art = await api.requirementArtifact.get({ artifactId: hit.id });
|
|
480
|
+
return art.content;
|
|
481
|
+
}
|
|
446
482
|
function valueToXmlContent(value) {
|
|
447
483
|
if (value === null || value === void 0) return "";
|
|
448
484
|
if (typeof value === "string") return xmlEscape(value);
|
|
@@ -554,6 +590,16 @@ async function runPull(requirementId, workspaceDir) {
|
|
|
554
590
|
data.testCases ?? []
|
|
555
591
|
);
|
|
556
592
|
writeFileSync2(join4(WORKITEMS_DIR, "testcase.xml"), testCasesXml, "utf8");
|
|
593
|
+
for (const fileName of PULL_ARTIFACT_FILE_NAMES) {
|
|
594
|
+
const content = await fetchArtifactContentByFileName(
|
|
595
|
+
api,
|
|
596
|
+
requirementId,
|
|
597
|
+
fileName
|
|
598
|
+
);
|
|
599
|
+
if (content !== null) {
|
|
600
|
+
writeFileSync2(join4(WORKITEMS_DIR, fileName), content, "utf8");
|
|
601
|
+
}
|
|
602
|
+
}
|
|
557
603
|
return WORKITEMS_DIR;
|
|
558
604
|
}
|
|
559
605
|
|
|
@@ -634,6 +680,11 @@ function runConnect(opts) {
|
|
|
634
680
|
for await (const event of run.stream()) {
|
|
635
681
|
if (event.type === "status") {
|
|
636
682
|
console.log(`[Status]`, event.message || event.status);
|
|
683
|
+
if (event.status === "ERROR") {
|
|
684
|
+
console.log("===============================================");
|
|
685
|
+
console.log(JSON.stringify(event, null, 2));
|
|
686
|
+
console.log("===============================================");
|
|
687
|
+
}
|
|
637
688
|
continue;
|
|
638
689
|
}
|
|
639
690
|
if (event.type === "assistant") {
|