ai-project-manage-cli 5.0.4 → 5.0.6
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/README.md +1 -1
- package/dist/index.js +34 -32
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -101,6 +101,11 @@ function documentPlatformName(filePath) {
|
|
|
101
101
|
}
|
|
102
102
|
return base;
|
|
103
103
|
}
|
|
104
|
+
function resolveSessionDocumentPath(sessionId, documentName, apmRoot) {
|
|
105
|
+
const base = basename(documentName.trim().replace(/\\/g, "/"));
|
|
106
|
+
const fileName = documentLocalFileName(base);
|
|
107
|
+
return join2(sessionDocsDir(sessionId, apmRoot), fileName);
|
|
108
|
+
}
|
|
104
109
|
async function ensureLoggedConfig() {
|
|
105
110
|
const cfg = await ensureApmConfig();
|
|
106
111
|
if (!cfg.token) {
|
|
@@ -146,9 +151,6 @@ async function copyTemplateFiles(targetDir) {
|
|
|
146
151
|
})
|
|
147
152
|
);
|
|
148
153
|
}
|
|
149
|
-
function resolveCwdPath(file) {
|
|
150
|
-
return resolve(process.cwd(), file);
|
|
151
|
-
}
|
|
152
154
|
|
|
153
155
|
// src/commands/init.ts
|
|
154
156
|
async function runInit(name) {
|
|
@@ -648,12 +650,16 @@ async function runSyncDocument(sessionId, options) {
|
|
|
648
650
|
}
|
|
649
651
|
const fileArg = options.file?.trim();
|
|
650
652
|
if (!fileArg) {
|
|
651
|
-
console.error("[apm] \u8BF7\u6307\u5B9A --file <\
|
|
653
|
+
console.error("[apm] \u8BF7\u6307\u5B9A --file <\u6587\u6863\u540D\u79F0>");
|
|
652
654
|
process.exit(1);
|
|
653
655
|
}
|
|
654
|
-
const absPath =
|
|
656
|
+
const absPath = resolveSessionDocumentPath(trimmedSessionId, fileArg);
|
|
655
657
|
if (!existsSync3(absPath)) {
|
|
656
|
-
|
|
658
|
+
const docsDir = sessionDocsDir(trimmedSessionId);
|
|
659
|
+
console.error(
|
|
660
|
+
`[apm] \u6587\u6863\u4E0D\u5B58\u5728: ${absPath}
|
|
661
|
+
[apm] \u8BF7\u786E\u8BA4\u5DF2 pull\uFF0C\u4E14 ${docsDir} \u4E0B\u5B58\u5728\u5BF9\u5E94\u6587\u4EF6`
|
|
662
|
+
);
|
|
657
663
|
process.exit(1);
|
|
658
664
|
}
|
|
659
665
|
const content = readFileSync4(absPath, "utf8");
|
|
@@ -669,24 +675,17 @@ async function runSyncDocument(sessionId, options) {
|
|
|
669
675
|
}
|
|
670
676
|
|
|
671
677
|
// src/commands/append-message.ts
|
|
672
|
-
import { existsSync as existsSync4, readFileSync as readFileSync5 } from "fs";
|
|
673
678
|
async function runAppendMessage(options) {
|
|
674
679
|
const messageId = options.id?.trim();
|
|
675
680
|
if (!messageId) {
|
|
676
681
|
console.error("[apm] \u8BF7\u6307\u5B9A --id <messageId>");
|
|
677
682
|
process.exit(1);
|
|
678
683
|
}
|
|
679
|
-
const
|
|
680
|
-
if (!
|
|
681
|
-
console.error("[apm] \u8BF7\u6307\u5B9A --
|
|
684
|
+
const content = options.content ?? "";
|
|
685
|
+
if (!content) {
|
|
686
|
+
console.error("[apm] \u8BF7\u6307\u5B9A --content <\u5185\u5BB9>");
|
|
682
687
|
process.exit(1);
|
|
683
688
|
}
|
|
684
|
-
const absPath = resolveCwdPath(fileArg);
|
|
685
|
-
if (!existsSync4(absPath)) {
|
|
686
|
-
console.error(`[apm] \u6587\u4EF6\u4E0D\u5B58\u5728: ${absPath}`);
|
|
687
|
-
process.exit(1);
|
|
688
|
-
}
|
|
689
|
-
const content = readFileSync5(absPath, "utf8");
|
|
690
689
|
const cfg = await ensureLoggedConfig();
|
|
691
690
|
const api = createApmApiClient(cfg);
|
|
692
691
|
await api.cli.appendMessageContent({ id: messageId, content });
|
|
@@ -723,19 +722,19 @@ async function runUpdateMessageStatus(options) {
|
|
|
723
722
|
import path5 from "node:path";
|
|
724
723
|
|
|
725
724
|
// src/commands/deploy/internal/apm-config.ts
|
|
726
|
-
import { existsSync as
|
|
725
|
+
import { existsSync as existsSync4, readFileSync as readFileSync5 } from "node:fs";
|
|
727
726
|
import { resolve as resolve3 } from "node:path";
|
|
728
727
|
function loadApmConfig(options) {
|
|
729
728
|
const p = resolve3(
|
|
730
729
|
process.cwd(),
|
|
731
730
|
options?.configPath ?? resolve3(workspaceApmDir(), "apm.config.json")
|
|
732
731
|
);
|
|
733
|
-
if (!
|
|
732
|
+
if (!existsSync4(p)) {
|
|
734
733
|
console.error(`\u672A\u627E\u5230\u914D\u7F6E\u6587\u4EF6\uFF1A${p}`);
|
|
735
734
|
process.exit(1);
|
|
736
735
|
}
|
|
737
736
|
try {
|
|
738
|
-
const raw =
|
|
737
|
+
const raw = readFileSync5(p, "utf8");
|
|
739
738
|
return JSON.parse(raw);
|
|
740
739
|
} catch (e) {
|
|
741
740
|
console.error(`\u65E0\u6CD5\u89E3\u6790 apm.config.json\uFF1A${p}`, e);
|
|
@@ -832,7 +831,7 @@ import path4 from "node:path";
|
|
|
832
831
|
import Docker from "dockerode";
|
|
833
832
|
|
|
834
833
|
// src/commands/deploy/internal/backend-deploy/dockerode-client/connection-options.ts
|
|
835
|
-
import { existsSync as
|
|
834
|
+
import { existsSync as existsSync5, readFileSync as readFileSync6 } from "node:fs";
|
|
836
835
|
import path from "node:path";
|
|
837
836
|
function asOptionalTlsBuffer(value) {
|
|
838
837
|
if (typeof value !== "string") {
|
|
@@ -844,8 +843,8 @@ function asOptionalTlsBuffer(value) {
|
|
|
844
843
|
if (normalized === "") {
|
|
845
844
|
return void 0;
|
|
846
845
|
}
|
|
847
|
-
if (
|
|
848
|
-
return
|
|
846
|
+
if (existsSync5(normalized)) {
|
|
847
|
+
return readFileSync6(normalized);
|
|
849
848
|
}
|
|
850
849
|
const looksLikePath = /[\\/]/.test(normalized) || normalized.endsWith(".pem");
|
|
851
850
|
if (looksLikePath) {
|
|
@@ -1055,7 +1054,7 @@ var DockerodeClient = class {
|
|
|
1055
1054
|
var createDockerodeClient = (config) => new DockerodeClient(config);
|
|
1056
1055
|
|
|
1057
1056
|
// src/commands/deploy/internal/backend-deploy/dockerode-client/env.ts
|
|
1058
|
-
import { existsSync as
|
|
1057
|
+
import { existsSync as existsSync6, readFileSync as readFileSync7, statSync as statSync3 } from "node:fs";
|
|
1059
1058
|
import path2 from "node:path";
|
|
1060
1059
|
function stripSurroundingQuotes(value) {
|
|
1061
1060
|
const t = value.trim();
|
|
@@ -1072,10 +1071,10 @@ function loadEnvFromFile(envFilePath) {
|
|
|
1072
1071
|
return {};
|
|
1073
1072
|
}
|
|
1074
1073
|
const targetPath = path2.resolve(envFilePath);
|
|
1075
|
-
if (!
|
|
1074
|
+
if (!existsSync6(targetPath) || !statSync3(targetPath).isFile()) {
|
|
1076
1075
|
return {};
|
|
1077
1076
|
}
|
|
1078
|
-
const raw =
|
|
1077
|
+
const raw = readFileSync7(targetPath, "utf-8");
|
|
1079
1078
|
const result = {};
|
|
1080
1079
|
for (const line of raw.split(/\r?\n/)) {
|
|
1081
1080
|
const normalized = line.trim();
|
|
@@ -1246,12 +1245,12 @@ function dockerPushImage(params, cwd) {
|
|
|
1246
1245
|
}
|
|
1247
1246
|
|
|
1248
1247
|
// src/commands/deploy/internal/backend-deploy/resolve-dockerfile.ts
|
|
1249
|
-
import { existsSync as
|
|
1248
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
1250
1249
|
import path3 from "node:path";
|
|
1251
1250
|
function resolveDockerBuildPaths(cwd) {
|
|
1252
1251
|
const dockerfilePath = path3.join(cwd, "Dockerfile");
|
|
1253
1252
|
Logger.info(`\u67E5\u627EDockerfile\u6587\u4EF6\uFF0C\u8DEF\u5F84: ${dockerfilePath}`);
|
|
1254
|
-
if (!
|
|
1253
|
+
if (!existsSync7(dockerfilePath)) {
|
|
1255
1254
|
throw new Error(`Dockerfile \u4E0D\u5B58\u5728\uFF1A${dockerfilePath}`);
|
|
1256
1255
|
}
|
|
1257
1256
|
Logger.info("\u2713 Dockerfile \u5B58\u5728");
|
|
@@ -1380,16 +1379,16 @@ import { copyFile, readdir as readdir2, stat } from "node:fs/promises";
|
|
|
1380
1379
|
import path7 from "node:path";
|
|
1381
1380
|
|
|
1382
1381
|
// src/commands/deploy/internal/load-apm-dotenv.ts
|
|
1383
|
-
import { existsSync as
|
|
1382
|
+
import { existsSync as existsSync8, readFileSync as readFileSync8 } from "node:fs";
|
|
1384
1383
|
import { join as join8 } from "node:path";
|
|
1385
1384
|
function loadApmDotEnvIfPresent() {
|
|
1386
1385
|
const p = join8(workspaceApmDir(), ".env");
|
|
1387
|
-
if (!
|
|
1386
|
+
if (!existsSync8(p)) {
|
|
1388
1387
|
return;
|
|
1389
1388
|
}
|
|
1390
1389
|
let text;
|
|
1391
1390
|
try {
|
|
1392
|
-
text =
|
|
1391
|
+
text = readFileSync8(p, "utf8");
|
|
1393
1392
|
} catch {
|
|
1394
1393
|
return;
|
|
1395
1394
|
}
|
|
@@ -1773,10 +1772,13 @@ function buildProgram() {
|
|
|
1773
1772
|
).argument("<sessionId>", "\u6C9F\u901A\u7FA4 ID").action(async (sessionId) => {
|
|
1774
1773
|
await runPull(sessionId);
|
|
1775
1774
|
});
|
|
1776
|
-
program.command("sync-document").description("\u5C06\u672C\u5730 Markdown \u8986\u76D6\u5F0F upsert \u5230\u5E73\u53F0\u9700\u6C42\u6587\u6863").argument("<sessionId>", "\u6C9F\u901A\u7FA4 ID").requiredOption(
|
|
1775
|
+
program.command("sync-document").description("\u5C06\u672C\u5730 Markdown \u8986\u76D6\u5F0F upsert \u5230\u5E73\u53F0\u9700\u6C42\u6587\u6863").argument("<sessionId>", "\u6C9F\u901A\u7FA4 ID").requiredOption(
|
|
1776
|
+
"--file <name>",
|
|
1777
|
+
"\u6587\u6863\u540D\u79F0\uFF08\u5982 PRD \u6216 PRD.md\uFF09\uFF0C\u8BFB\u53D6 .apm/sessions/<sessionId>/docs/ \u4E0B\u5BF9\u5E94\u6587\u4EF6"
|
|
1778
|
+
).action(async (sessionId, opts) => {
|
|
1777
1779
|
await runSyncDocument(sessionId, { file: opts.file });
|
|
1778
1780
|
});
|
|
1779
|
-
program.command("append-message").description("\u5411\u5E73\u53F0\u4F1A\u8BDD\u6D88\u606F\u8FFD\u52A0\u5185\u5BB9\uFF08PUT /api/cli/messages/content\uFF09").requiredOption("--id <messageId>", "\u6D88\u606F ID").requiredOption("--
|
|
1781
|
+
program.command("append-message").description("\u5411\u5E73\u53F0\u4F1A\u8BDD\u6D88\u606F\u8FFD\u52A0\u5185\u5BB9\uFF08PUT /api/cli/messages/content\uFF09").requiredOption("--id <messageId>", "\u6D88\u606F ID").requiredOption("--content <content>", "\u8981\u8FFD\u52A0\u7684\u6D88\u606F\u5185\u5BB9").action(async (opts) => {
|
|
1780
1782
|
await runAppendMessage(opts);
|
|
1781
1783
|
});
|
|
1782
1784
|
program.command("update-message-status").description("\u66F4\u65B0\u5E73\u53F0\u4F1A\u8BDD\u6D88\u606F\u72B6\u6001").requiredOption("--id <messageId>", "\u6D88\u606F ID").requiredOption("--status <status>", "CREATED | TYPING | SUCCESS | FAILED").action(async (opts) => {
|