mano-coding 0.1.30 → 0.1.31
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/bin.js +497 -342
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -14962,49 +14962,49 @@ var require_fast_uri = __commonJS({
|
|
|
14962
14962
|
schemelessOptions.skipEscape = true;
|
|
14963
14963
|
return serialize(resolved, schemelessOptions);
|
|
14964
14964
|
}
|
|
14965
|
-
function resolveComponent(base,
|
|
14965
|
+
function resolveComponent(base, relative9, options, skipNormalization) {
|
|
14966
14966
|
const target = {};
|
|
14967
14967
|
if (!skipNormalization) {
|
|
14968
14968
|
base = parse(serialize(base, options), options);
|
|
14969
|
-
|
|
14969
|
+
relative9 = parse(serialize(relative9, options), options);
|
|
14970
14970
|
}
|
|
14971
14971
|
options = options || {};
|
|
14972
|
-
if (!options.tolerant &&
|
|
14973
|
-
target.scheme =
|
|
14974
|
-
target.userinfo =
|
|
14975
|
-
target.host =
|
|
14976
|
-
target.port =
|
|
14977
|
-
target.path = removeDotSegments(
|
|
14978
|
-
target.query =
|
|
14972
|
+
if (!options.tolerant && relative9.scheme) {
|
|
14973
|
+
target.scheme = relative9.scheme;
|
|
14974
|
+
target.userinfo = relative9.userinfo;
|
|
14975
|
+
target.host = relative9.host;
|
|
14976
|
+
target.port = relative9.port;
|
|
14977
|
+
target.path = removeDotSegments(relative9.path || "");
|
|
14978
|
+
target.query = relative9.query;
|
|
14979
14979
|
} else {
|
|
14980
|
-
if (
|
|
14981
|
-
target.userinfo =
|
|
14982
|
-
target.host =
|
|
14983
|
-
target.port =
|
|
14984
|
-
target.path = removeDotSegments(
|
|
14985
|
-
target.query =
|
|
14980
|
+
if (relative9.userinfo !== void 0 || relative9.host !== void 0 || relative9.port !== void 0) {
|
|
14981
|
+
target.userinfo = relative9.userinfo;
|
|
14982
|
+
target.host = relative9.host;
|
|
14983
|
+
target.port = relative9.port;
|
|
14984
|
+
target.path = removeDotSegments(relative9.path || "");
|
|
14985
|
+
target.query = relative9.query;
|
|
14986
14986
|
} else {
|
|
14987
|
-
if (!
|
|
14987
|
+
if (!relative9.path) {
|
|
14988
14988
|
target.path = base.path;
|
|
14989
|
-
if (
|
|
14990
|
-
target.query =
|
|
14989
|
+
if (relative9.query !== void 0) {
|
|
14990
|
+
target.query = relative9.query;
|
|
14991
14991
|
} else {
|
|
14992
14992
|
target.query = base.query;
|
|
14993
14993
|
}
|
|
14994
14994
|
} else {
|
|
14995
|
-
if (
|
|
14996
|
-
target.path = removeDotSegments(
|
|
14995
|
+
if (relative9.path[0] === "/") {
|
|
14996
|
+
target.path = removeDotSegments(relative9.path);
|
|
14997
14997
|
} else {
|
|
14998
14998
|
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
14999
|
-
target.path = "/" +
|
|
14999
|
+
target.path = "/" + relative9.path;
|
|
15000
15000
|
} else if (!base.path) {
|
|
15001
|
-
target.path =
|
|
15001
|
+
target.path = relative9.path;
|
|
15002
15002
|
} else {
|
|
15003
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
15003
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative9.path;
|
|
15004
15004
|
}
|
|
15005
15005
|
target.path = removeDotSegments(target.path);
|
|
15006
15006
|
}
|
|
15007
|
-
target.query =
|
|
15007
|
+
target.query = relative9.query;
|
|
15008
15008
|
}
|
|
15009
15009
|
target.userinfo = base.userinfo;
|
|
15010
15010
|
target.host = base.host;
|
|
@@ -15012,7 +15012,7 @@ var require_fast_uri = __commonJS({
|
|
|
15012
15012
|
}
|
|
15013
15013
|
target.scheme = base.scheme;
|
|
15014
15014
|
}
|
|
15015
|
-
target.fragment =
|
|
15015
|
+
target.fragment = relative9.fragment;
|
|
15016
15016
|
return target;
|
|
15017
15017
|
}
|
|
15018
15018
|
function equal(uriA, uriB, options) {
|
|
@@ -23352,10 +23352,10 @@ async function persistGitCheckout(workDir, targetDir) {
|
|
|
23352
23352
|
return targetDir;
|
|
23353
23353
|
}
|
|
23354
23354
|
async function copyGitCheckout(src, dest) {
|
|
23355
|
-
const { readdir:
|
|
23355
|
+
const { readdir: readdir11, mkdir: mkdir19, copyFile: copyFile2 } = await import("node:fs/promises");
|
|
23356
23356
|
const { join: joinPath } = await import("node:path");
|
|
23357
|
-
await
|
|
23358
|
-
const entries = await
|
|
23357
|
+
await mkdir19(dest, { recursive: true });
|
|
23358
|
+
const entries = await readdir11(src, { withFileTypes: true });
|
|
23359
23359
|
for (const entry of entries) {
|
|
23360
23360
|
if (entry.name === ".git") continue;
|
|
23361
23361
|
const srcPath = joinPath(src, entry.name);
|
|
@@ -23548,8 +23548,8 @@ var init_git_resolver = __esm({
|
|
|
23548
23548
|
}
|
|
23549
23549
|
const cacheBase = join6(cacheRoot, "git", encodePackageId(packageId));
|
|
23550
23550
|
try {
|
|
23551
|
-
const { readdir:
|
|
23552
|
-
const commits = await
|
|
23551
|
+
const { readdir: readdir11 } = await import("node:fs/promises");
|
|
23552
|
+
const commits = await readdir11(cacheBase, { withFileTypes: true });
|
|
23553
23553
|
for (const entry of commits) {
|
|
23554
23554
|
if (!entry.isDirectory()) continue;
|
|
23555
23555
|
const cacheDir = join6(cacheBase, entry.name);
|
|
@@ -26934,10 +26934,10 @@ var init_tarball_loader = __esm({
|
|
|
26934
26934
|
return targetDir;
|
|
26935
26935
|
}
|
|
26936
26936
|
async copyDirRecursive(src, dest) {
|
|
26937
|
-
const { readdir:
|
|
26937
|
+
const { readdir: readdir11, mkdir: mkdir19, copyFile: copyFile2 } = await import("node:fs/promises");
|
|
26938
26938
|
const { join: joinPath } = await import("node:path");
|
|
26939
|
-
await
|
|
26940
|
-
const entries = await
|
|
26939
|
+
await mkdir19(dest, { recursive: true });
|
|
26940
|
+
const entries = await readdir11(src, { withFileTypes: true });
|
|
26941
26941
|
for (const entry of entries) {
|
|
26942
26942
|
const srcPath = joinPath(src, entry.name);
|
|
26943
26943
|
const destPath = joinPath(dest, entry.name);
|
|
@@ -26996,18 +26996,18 @@ var init_tarball_loader = __esm({
|
|
|
26996
26996
|
}
|
|
26997
26997
|
async findAndReadManifest(workDir, packageId, version) {
|
|
26998
26998
|
const packageRoot = await this.findPackageRoot(workDir, packageId, version);
|
|
26999
|
-
const { readFile:
|
|
27000
|
-
return
|
|
26999
|
+
const { readFile: readFile34 } = await import("node:fs/promises");
|
|
27000
|
+
return readFile34(join7(packageRoot, "manifest.yaml"), "utf-8");
|
|
27001
27001
|
}
|
|
27002
27002
|
async findPackageRoot(workDir, packageId, version) {
|
|
27003
|
-
const { access: access12, readdir:
|
|
27003
|
+
const { access: access12, readdir: readdir11 } = await import("node:fs/promises");
|
|
27004
27004
|
const { resolve: resolvePath10 } = await import("node:path");
|
|
27005
27005
|
const candidates = [
|
|
27006
27006
|
resolvePath10(workDir),
|
|
27007
27007
|
resolvePath10(workDir, "package")
|
|
27008
27008
|
];
|
|
27009
27009
|
try {
|
|
27010
|
-
const entries = await
|
|
27010
|
+
const entries = await readdir11(workDir, { withFileTypes: true });
|
|
27011
27011
|
for (const entry of entries) {
|
|
27012
27012
|
if (entry.isDirectory()) {
|
|
27013
27013
|
candidates.push(resolvePath10(workDir, entry.name));
|
|
@@ -28735,11 +28735,11 @@ var init_claude_code_adapter = __esm({
|
|
|
28735
28735
|
return diagnostics;
|
|
28736
28736
|
}
|
|
28737
28737
|
const { capability, content, packageRoot } = request;
|
|
28738
|
-
const { readFile:
|
|
28738
|
+
const { readFile: readFile34 } = await import("node:fs/promises");
|
|
28739
28739
|
const { resolve: resolvePath10 } = await import("node:path");
|
|
28740
28740
|
const variantPath = resolvePath10(packageRoot, content.path);
|
|
28741
28741
|
try {
|
|
28742
|
-
const raw = await
|
|
28742
|
+
const raw = await readFile34(variantPath, "utf-8");
|
|
28743
28743
|
switch (capability.type) {
|
|
28744
28744
|
case "rule":
|
|
28745
28745
|
if (!variantPath.endsWith(".md")) {
|
|
@@ -28899,7 +28899,7 @@ var init_codex_adapter = __esm({
|
|
|
28899
28899
|
return diagnostics;
|
|
28900
28900
|
}
|
|
28901
28901
|
const { capability, content, packageRoot } = request;
|
|
28902
|
-
const { readFile:
|
|
28902
|
+
const { readFile: readFile34 } = await import("node:fs/promises");
|
|
28903
28903
|
const { resolve: resolvePath10 } = await import("node:path");
|
|
28904
28904
|
const variantPath = resolvePath10(packageRoot, content.path);
|
|
28905
28905
|
switch (capability.type) {
|
|
@@ -28925,7 +28925,7 @@ var init_codex_adapter = __esm({
|
|
|
28925
28925
|
});
|
|
28926
28926
|
}
|
|
28927
28927
|
try {
|
|
28928
|
-
const raw = await
|
|
28928
|
+
const raw = await readFile34(variantPath, "utf-8");
|
|
28929
28929
|
if (!raw.trim()) {
|
|
28930
28930
|
diagnostics.push({
|
|
28931
28931
|
severity: "error",
|
|
@@ -28940,7 +28940,7 @@ var init_codex_adapter = __esm({
|
|
|
28940
28940
|
break;
|
|
28941
28941
|
case "mcp":
|
|
28942
28942
|
try {
|
|
28943
|
-
const raw = await
|
|
28943
|
+
const raw = await readFile34(variantPath, "utf-8");
|
|
28944
28944
|
if (!raw.trim()) {
|
|
28945
28945
|
diagnostics.push({
|
|
28946
28946
|
severity: "error",
|
|
@@ -29067,7 +29067,7 @@ var init_opencode_adapter = __esm({
|
|
|
29067
29067
|
return diagnostics;
|
|
29068
29068
|
}
|
|
29069
29069
|
const { capability, content, packageRoot } = request;
|
|
29070
|
-
const { readFile:
|
|
29070
|
+
const { readFile: readFile34 } = await import("node:fs/promises");
|
|
29071
29071
|
const { resolve: resolvePath10 } = await import("node:path");
|
|
29072
29072
|
const variantPath = resolvePath10(packageRoot, content.path);
|
|
29073
29073
|
switch (capability.type) {
|
|
@@ -29104,7 +29104,7 @@ var init_opencode_adapter = __esm({
|
|
|
29104
29104
|
break;
|
|
29105
29105
|
case "mcp":
|
|
29106
29106
|
try {
|
|
29107
|
-
const raw = await
|
|
29107
|
+
const raw = await readFile34(variantPath, "utf-8");
|
|
29108
29108
|
JSON.parse(raw);
|
|
29109
29109
|
} catch {
|
|
29110
29110
|
diagnostics.push({
|
|
@@ -29241,11 +29241,11 @@ var init_codebuddy_adapter = __esm({
|
|
|
29241
29241
|
return diagnostics;
|
|
29242
29242
|
}
|
|
29243
29243
|
const { capability, content, packageRoot } = request;
|
|
29244
|
-
const { readFile:
|
|
29244
|
+
const { readFile: readFile34 } = await import("node:fs/promises");
|
|
29245
29245
|
const { resolve: resolvePath10 } = await import("node:path");
|
|
29246
29246
|
const variantPath = resolvePath10(packageRoot, content.path);
|
|
29247
29247
|
try {
|
|
29248
|
-
const raw = await
|
|
29248
|
+
const raw = await readFile34(variantPath, "utf-8");
|
|
29249
29249
|
switch (capability.type) {
|
|
29250
29250
|
case "rule":
|
|
29251
29251
|
if (!variantPath.endsWith(".mdc")) {
|
|
@@ -29403,11 +29403,11 @@ var init_trae_adapter = __esm({
|
|
|
29403
29403
|
return diagnostics;
|
|
29404
29404
|
}
|
|
29405
29405
|
const { capability, content, packageRoot } = request;
|
|
29406
|
-
const { readFile:
|
|
29406
|
+
const { readFile: readFile34 } = await import("node:fs/promises");
|
|
29407
29407
|
const { resolve: resolvePath10 } = await import("node:path");
|
|
29408
29408
|
const variantPath = resolvePath10(packageRoot, content.path);
|
|
29409
29409
|
try {
|
|
29410
|
-
const raw = await
|
|
29410
|
+
const raw = await readFile34(variantPath, "utf-8");
|
|
29411
29411
|
switch (capability.type) {
|
|
29412
29412
|
case "rule":
|
|
29413
29413
|
if (!variantPath.endsWith(".md")) {
|
|
@@ -29798,11 +29798,11 @@ var init_host_packages = __esm({
|
|
|
29798
29798
|
import { resolve as resolve9 } from "node:path";
|
|
29799
29799
|
import { pathToFileURL } from "node:url";
|
|
29800
29800
|
async function loadAdapterModule(packageRoot) {
|
|
29801
|
-
const { readFile:
|
|
29801
|
+
const { readFile: readFile34 } = await import("node:fs/promises");
|
|
29802
29802
|
const packageJsonPath = resolve9(packageRoot, "package.json");
|
|
29803
29803
|
let packageJson;
|
|
29804
29804
|
try {
|
|
29805
|
-
const raw = await
|
|
29805
|
+
const raw = await readFile34(packageJsonPath, "utf-8");
|
|
29806
29806
|
packageJson = JSON.parse(raw);
|
|
29807
29807
|
} catch {
|
|
29808
29808
|
throw new AdapterLoaderError(
|
|
@@ -31496,7 +31496,11 @@ function validateTaskVariables(tasks, ctx) {
|
|
|
31496
31496
|
if (ctx.targets && ctx.targets.length > 1) {
|
|
31497
31497
|
errors.push(`\u4EFB\u52A1 '${taskId}' \u7684 ${field} \u5F15\u7528\u4E86\u5355\u503C '\${target}'\uFF0C\u4F46\u5F53\u524D\u9009\u62E9\u4E86\u591A\u4E2A target: [${ctx.targets.join(", ")}]\u3002\u8BF7\u5728 manifest \u4E2D\u4F7F\u7528 '\${targets}' \u6216\u4EC5\u9009\u62E9\u5355\u4E2A target`);
|
|
31498
31498
|
}
|
|
31499
|
-
} else if (varName === "
|
|
31499
|
+
} else if (varName === "stagingDir") {
|
|
31500
|
+
if (!ctx.stagingDir) {
|
|
31501
|
+
errors.push(`\u4EFB\u52A1 '${taskId}' \u7684 ${field} \u4E2D\u5F15\u7528\u4E86 '\${stagingDir}'\uFF0C\u4F46\u5F53\u524D\u64CD\u4F5C\u4E0A\u4E0B\u6587\u4E2D\u672A\u5206\u914D stagingDir\uFF08\u4EC5\u5728 before:create \u94A9\u5B50\u4E2D\u53EF\u7528\uFF09`);
|
|
31502
|
+
}
|
|
31503
|
+
} else if (varName === "projectName" || varName === "projectDir" || varName === "projectParentDir" || varName === "templateDir" || varName === "targets" || varName === "operation" || varName === "version" || varName === "previousVersion" || varName.startsWith("inputs.")) {
|
|
31500
31504
|
} else {
|
|
31501
31505
|
errors.push(`\u4EFB\u52A1 '${taskId}' \u7684 ${field} \u4E2D\u5F15\u7528\u4E86\u672A\u77E5\u53D8\u91CF '\${${varName}}'`);
|
|
31502
31506
|
}
|
|
@@ -31522,7 +31526,15 @@ function interpolateString(template, ctx, allowEnv = false) {
|
|
|
31522
31526
|
if (varName === "projectDir") return ctx.projectDir;
|
|
31523
31527
|
if (varName === "projectParentDir") return ctx.projectParentDir;
|
|
31524
31528
|
if (varName === "templateDir") return ctx.templateDir;
|
|
31525
|
-
if (varName === "stagingDir")
|
|
31529
|
+
if (varName === "stagingDir") {
|
|
31530
|
+
if (!ctx.stagingDir) {
|
|
31531
|
+
throw new TaskExecutionError(
|
|
31532
|
+
`\u4EFB\u52A1\u5F15\u7528\u4E86 '\${stagingDir}'\uFF0C\u4F46\u5F53\u524D\u64CD\u4F5C\u4E0A\u4E0B\u6587\u4E2D\u672A\u5206\u914D stagingDir\u3002\u8BE5\u53D8\u91CF\u4EC5\u5728 before:create \u94A9\u5B50\u4E2D\u53EF\u7528\u3002`,
|
|
31533
|
+
1
|
|
31534
|
+
);
|
|
31535
|
+
}
|
|
31536
|
+
return ctx.stagingDir;
|
|
31537
|
+
}
|
|
31526
31538
|
if (varName === "operation") return ctx.operation ?? "";
|
|
31527
31539
|
if (varName === "version") return ctx.version ?? "";
|
|
31528
31540
|
if (varName === "previousVersion") return ctx.previousVersion ?? "";
|
|
@@ -33215,6 +33227,68 @@ var init_staging_manager = __esm({
|
|
|
33215
33227
|
}
|
|
33216
33228
|
});
|
|
33217
33229
|
|
|
33230
|
+
// packages/core/src/orchestrator/staging-scanner.ts
|
|
33231
|
+
import { readFile as readFile23, readdir as readdir8, stat as stat6 } from "node:fs/promises";
|
|
33232
|
+
import { join as join18, relative as relative7 } from "node:path";
|
|
33233
|
+
async function scanStagingDirectory(options) {
|
|
33234
|
+
const { stagingDir, packageId, ownerKind = "template" } = options;
|
|
33235
|
+
const ignoredDirs = /* @__PURE__ */ new Set([...DEFAULT_IGNORED_DIRS, ...options.ignoredDirs ?? []]);
|
|
33236
|
+
const intents = [];
|
|
33237
|
+
async function walk(currentDir) {
|
|
33238
|
+
let entries;
|
|
33239
|
+
try {
|
|
33240
|
+
entries = await readdir8(currentDir, { withFileTypes: true });
|
|
33241
|
+
} catch {
|
|
33242
|
+
return;
|
|
33243
|
+
}
|
|
33244
|
+
for (const entry of entries) {
|
|
33245
|
+
const fullPath = join18(currentDir, entry.name);
|
|
33246
|
+
if (entry.isDirectory()) {
|
|
33247
|
+
if (ignoredDirs.has(entry.name)) {
|
|
33248
|
+
continue;
|
|
33249
|
+
}
|
|
33250
|
+
await walk(fullPath);
|
|
33251
|
+
} else if (entry.isFile()) {
|
|
33252
|
+
const relPath = relative7(stagingDir, fullPath).replaceAll("\\", "/");
|
|
33253
|
+
if (relPath === "aicoding-lock.yaml" || relPath === "mano-lock.yaml") {
|
|
33254
|
+
continue;
|
|
33255
|
+
}
|
|
33256
|
+
const fileStat = await stat6(fullPath);
|
|
33257
|
+
const content = await readFile23(fullPath);
|
|
33258
|
+
const executable = Boolean(fileStat.mode & 73);
|
|
33259
|
+
intents.push({
|
|
33260
|
+
action: "upsert",
|
|
33261
|
+
type: "file",
|
|
33262
|
+
path: relPath,
|
|
33263
|
+
content,
|
|
33264
|
+
executable: executable ? true : void 0,
|
|
33265
|
+
packageId,
|
|
33266
|
+
ownerKind,
|
|
33267
|
+
assetType: "project-seed"
|
|
33268
|
+
});
|
|
33269
|
+
}
|
|
33270
|
+
}
|
|
33271
|
+
}
|
|
33272
|
+
await walk(stagingDir);
|
|
33273
|
+
return {
|
|
33274
|
+
intents,
|
|
33275
|
+
fileCount: intents.length
|
|
33276
|
+
};
|
|
33277
|
+
}
|
|
33278
|
+
var DEFAULT_IGNORED_DIRS;
|
|
33279
|
+
var init_staging_scanner = __esm({
|
|
33280
|
+
"packages/core/src/orchestrator/staging-scanner.ts"() {
|
|
33281
|
+
"use strict";
|
|
33282
|
+
DEFAULT_IGNORED_DIRS = /* @__PURE__ */ new Set([
|
|
33283
|
+
".git",
|
|
33284
|
+
"node_modules",
|
|
33285
|
+
".pnpm-store",
|
|
33286
|
+
".turbo",
|
|
33287
|
+
".cache"
|
|
33288
|
+
]);
|
|
33289
|
+
}
|
|
33290
|
+
});
|
|
33291
|
+
|
|
33218
33292
|
// packages/core/src/orchestrator/qualification.ts
|
|
33219
33293
|
function inspectPackageFacts(resolution) {
|
|
33220
33294
|
const manifest = resolution.manifest;
|
|
@@ -33305,7 +33379,8 @@ var init_qualification = __esm({
|
|
|
33305
33379
|
|
|
33306
33380
|
// packages/core/src/orchestrator/lifecycle-orchestrator.ts
|
|
33307
33381
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
33308
|
-
import {
|
|
33382
|
+
import { writeFile as writeFile7, mkdir as mkdir15 } from "node:fs/promises";
|
|
33383
|
+
import { basename as basename3, dirname as dirname14, join as join19 } from "node:path";
|
|
33309
33384
|
function resolveStringInputs(globalInputs, packageInputs, packageId) {
|
|
33310
33385
|
const merged = {};
|
|
33311
33386
|
const raw = {
|
|
@@ -33342,6 +33417,7 @@ var init_lifecycle_orchestrator = __esm({
|
|
|
33342
33417
|
init_journal();
|
|
33343
33418
|
init_task_runner();
|
|
33344
33419
|
init_staging_manager();
|
|
33420
|
+
init_staging_scanner();
|
|
33345
33421
|
init_qualification();
|
|
33346
33422
|
OrchestratorError = class extends Error {
|
|
33347
33423
|
code;
|
|
@@ -33395,6 +33471,7 @@ var init_lifecycle_orchestrator = __esm({
|
|
|
33395
33471
|
options.resolutions,
|
|
33396
33472
|
options.targets
|
|
33397
33473
|
);
|
|
33474
|
+
const stagingIntents = [];
|
|
33398
33475
|
if (hasBeforeCreate) {
|
|
33399
33476
|
options.onProgress?.("bootstrap-plan", "\u51C6\u5907\u4E24\u9636\u6BB5 Bootstrap Plan");
|
|
33400
33477
|
for (const res of options.resolutions) {
|
|
@@ -33417,6 +33494,17 @@ var init_lifecycle_orchestrator = __esm({
|
|
|
33417
33494
|
await executeTasks(beforeTasks, ctx);
|
|
33418
33495
|
}
|
|
33419
33496
|
}
|
|
33497
|
+
for (const res of options.resolutions) {
|
|
33498
|
+
const stagingDir = this.stagingManager.getStagingDir(res.packageId);
|
|
33499
|
+
if (stagingDir) {
|
|
33500
|
+
const scanRes = await scanStagingDirectory({
|
|
33501
|
+
stagingDir,
|
|
33502
|
+
packageId: res.packageId,
|
|
33503
|
+
ownerKind: "template"
|
|
33504
|
+
});
|
|
33505
|
+
stagingIntents.push(...scanRes.intents);
|
|
33506
|
+
}
|
|
33507
|
+
}
|
|
33420
33508
|
}
|
|
33421
33509
|
options.onProgress?.("materialized-plan", "\u8BA1\u7B97 Materialized Plan \u5E76\u9A8C\u8BC1\u51B2\u7A81");
|
|
33422
33510
|
const validation = validatePlan(planResult.plan);
|
|
@@ -33438,12 +33526,21 @@ var init_lifecycle_orchestrator = __esm({
|
|
|
33438
33526
|
success: true,
|
|
33439
33527
|
operationId,
|
|
33440
33528
|
plan: planResult.plan,
|
|
33441
|
-
intents:
|
|
33529
|
+
intents: stagingIntents
|
|
33442
33530
|
};
|
|
33443
33531
|
}
|
|
33444
33532
|
options.onProgress?.("commit-core", "\u8FDB\u5165\u4E8B\u52A1\u6267\u884C\u6838\u5FC3\u8D44\u6E90\u5199\u5165");
|
|
33445
33533
|
const journal = await createJournal(options.userDataDir, options.projectRoot, { operationId });
|
|
33446
33534
|
let executingJournal = await updateJournal(journal, "executing");
|
|
33535
|
+
if (stagingIntents.length > 0) {
|
|
33536
|
+
for (const intent of stagingIntents) {
|
|
33537
|
+
if (intent.action === "upsert" && intent.type === "file") {
|
|
33538
|
+
const targetPath = join19(options.projectRoot, intent.path);
|
|
33539
|
+
await mkdir15(dirname14(targetPath), { recursive: true });
|
|
33540
|
+
await writeFile7(targetPath, intent.content);
|
|
33541
|
+
}
|
|
33542
|
+
}
|
|
33543
|
+
}
|
|
33447
33544
|
if (options.operation !== "create") {
|
|
33448
33545
|
const beforeHookName = `before:${options.operation}`;
|
|
33449
33546
|
for (const res of options.resolutions) {
|
|
@@ -33492,6 +33589,7 @@ var init_orchestrator = __esm({
|
|
|
33492
33589
|
"use strict";
|
|
33493
33590
|
init_types5();
|
|
33494
33591
|
init_staging_manager();
|
|
33592
|
+
init_staging_scanner();
|
|
33495
33593
|
init_qualification();
|
|
33496
33594
|
init_lifecycle_orchestrator();
|
|
33497
33595
|
}
|
|
@@ -33684,6 +33782,7 @@ __export(src_exports, {
|
|
|
33684
33782
|
sanitizeEnvValue: () => sanitizeEnvValue,
|
|
33685
33783
|
sanitizeUrl: () => sanitizeUrl,
|
|
33686
33784
|
scanJournals: () => scanJournals,
|
|
33785
|
+
scanStagingDirectory: () => scanStagingDirectory,
|
|
33687
33786
|
scanTemplateDirectoryContract: () => scanTemplateDirectoryContract,
|
|
33688
33787
|
selectRelease: () => selectRelease,
|
|
33689
33788
|
serializeTomlValue: () => serializeTomlValue,
|
|
@@ -43623,7 +43722,7 @@ var require_dist3 = __commonJS({
|
|
|
43623
43722
|
});
|
|
43624
43723
|
|
|
43625
43724
|
// packages/cli/src/commands/extension-pipeline.ts
|
|
43626
|
-
import { readFile as
|
|
43725
|
+
import { readFile as readFile24, writeFile as writeFile8 } from "node:fs/promises";
|
|
43627
43726
|
import { existsSync as existsSync5 } from "node:fs";
|
|
43628
43727
|
import { resolve as resolve14 } from "node:path";
|
|
43629
43728
|
function generateGitlabCiYaml(packageId) {
|
|
@@ -43705,7 +43804,7 @@ async function executeExtensionPipeline(directory, options) {
|
|
|
43705
43804
|
if (!packageId) {
|
|
43706
43805
|
if (existsSync5(manifestPath)) {
|
|
43707
43806
|
try {
|
|
43708
|
-
const manifestContent = await
|
|
43807
|
+
const manifestContent = await readFile24(manifestPath, "utf-8");
|
|
43709
43808
|
const parsed = import_yaml4.default.parse(manifestContent);
|
|
43710
43809
|
if (parsed && typeof parsed.id === "string") {
|
|
43711
43810
|
packageId = parsed.id;
|
|
@@ -43715,7 +43814,7 @@ async function executeExtensionPipeline(directory, options) {
|
|
|
43715
43814
|
}
|
|
43716
43815
|
if (!packageId && existsSync5(pkgJsonPath)) {
|
|
43717
43816
|
try {
|
|
43718
|
-
const pkgContent = await
|
|
43817
|
+
const pkgContent = await readFile24(pkgJsonPath, "utf-8");
|
|
43719
43818
|
const parsed = JSON.parse(pkgContent);
|
|
43720
43819
|
if (parsed && typeof parsed.name === "string") {
|
|
43721
43820
|
packageId = parsed.name;
|
|
@@ -43756,16 +43855,16 @@ async function executeExtensionPipeline(directory, options) {
|
|
|
43756
43855
|
}
|
|
43757
43856
|
}
|
|
43758
43857
|
const ciContent = generateGitlabCiYaml(packageId);
|
|
43759
|
-
await
|
|
43858
|
+
await writeFile8(ciFilePath, ciContent, "utf-8");
|
|
43760
43859
|
let addedReleaseScript = false;
|
|
43761
43860
|
if (existsSync5(pkgJsonPath)) {
|
|
43762
43861
|
try {
|
|
43763
|
-
const pkgContent = await
|
|
43862
|
+
const pkgContent = await readFile24(pkgJsonPath, "utf-8");
|
|
43764
43863
|
const parsed = JSON.parse(pkgContent);
|
|
43765
43864
|
parsed.scripts = parsed.scripts || {};
|
|
43766
43865
|
if (!parsed.scripts.release) {
|
|
43767
43866
|
parsed.scripts.release = "npm version patch";
|
|
43768
|
-
await
|
|
43867
|
+
await writeFile8(pkgJsonPath, JSON.stringify(parsed, null, 2) + "\n", "utf-8");
|
|
43769
43868
|
addedReleaseScript = true;
|
|
43770
43869
|
}
|
|
43771
43870
|
} catch {
|
|
@@ -43809,7 +43908,7 @@ var init_extension_pipeline = __esm({
|
|
|
43809
43908
|
});
|
|
43810
43909
|
|
|
43811
43910
|
// packages/cli/src/commands/extension-create.ts
|
|
43812
|
-
import { mkdir as
|
|
43911
|
+
import { mkdir as mkdir16, writeFile as writeFile9, readdir as readdir9 } from "node:fs/promises";
|
|
43813
43912
|
import { basename as basename4, resolve as resolve15 } from "node:path";
|
|
43814
43913
|
function createExtensionCreateCommand() {
|
|
43815
43914
|
const cmd = new Command("create");
|
|
@@ -43858,7 +43957,7 @@ async function executeExtensionCreate(directory, options) {
|
|
|
43858
43957
|
const dirBase = basename4(targetDir);
|
|
43859
43958
|
const isInteractive = !options.yes && !options.json && Boolean(process.stdin.isTTY);
|
|
43860
43959
|
try {
|
|
43861
|
-
const entries = await
|
|
43960
|
+
const entries = await readdir9(targetDir);
|
|
43862
43961
|
if (entries.length > 0) {
|
|
43863
43962
|
if (output.json) {
|
|
43864
43963
|
emitFailureJson(
|
|
@@ -43922,7 +44021,7 @@ async function executeExtensionCreate(directory, options) {
|
|
|
43922
44021
|
default: true
|
|
43923
44022
|
});
|
|
43924
44023
|
}
|
|
43925
|
-
await
|
|
44024
|
+
await mkdir16(targetDir, { recursive: true });
|
|
43926
44025
|
const scripts = {
|
|
43927
44026
|
test: "vitest"
|
|
43928
44027
|
};
|
|
@@ -43948,7 +44047,7 @@ async function executeExtensionCreate(directory, options) {
|
|
|
43948
44047
|
vitest: "^3.0.5"
|
|
43949
44048
|
}
|
|
43950
44049
|
};
|
|
43951
|
-
await
|
|
44050
|
+
await writeFile9(resolve15(targetDir, "package.json"), JSON.stringify(pkgJson, null, 2) + "\n", "utf-8");
|
|
43952
44051
|
const manifestLines = [
|
|
43953
44052
|
`id: "${packageId}"`,
|
|
43954
44053
|
"version: 0.1.0",
|
|
@@ -43970,7 +44069,7 @@ async function executeExtensionCreate(directory, options) {
|
|
|
43970
44069
|
manifestLines.push(" on:");
|
|
43971
44070
|
manifestLines.push(" - after:create");
|
|
43972
44071
|
}
|
|
43973
|
-
await
|
|
44072
|
+
await writeFile9(resolve15(targetDir, "manifest.yaml"), manifestLines.join("\n") + "\n", "utf-8");
|
|
43974
44073
|
const agentsMdContent = `# ${templateName} Agent \u6307\u5357
|
|
43975
44074
|
|
|
43976
44075
|
\u672C\u9879\u76EE\u57FA\u4E8E ${templateName} \u6A21\u677F\u6784\u5EFA\u3002\u5728\u8FDB\u884C AI \u8F85\u52A9\u7F16\u7801\u65F6\uFF0C\u8BF7\u9075\u5FAA\u4EE5\u4E0B\u6838\u5FC3\u539F\u5219\u4E0E\u7EA6\u5B9A\uFF1A
|
|
@@ -43982,9 +44081,9 @@ async function executeExtensionCreate(directory, options) {
|
|
|
43982
44081
|
## 2. \u4EA4\u4E92\u4E0E\u6CE8\u91CA
|
|
43983
44082
|
- \u4EE3\u7801\u6CE8\u91CA\u4E0E\u56DE\u7B54\u8BF7\u59CB\u7EC8\u4F7F\u7528\u7B80\u4F53\u4E2D\u6587\u3002
|
|
43984
44083
|
`;
|
|
43985
|
-
await
|
|
44084
|
+
await writeFile9(resolve15(targetDir, "AGENTS.md"), agentsMdContent, "utf-8");
|
|
43986
44085
|
const skillDir = resolve15(targetDir, "skills", "example-skill");
|
|
43987
|
-
await
|
|
44086
|
+
await mkdir16(skillDir, { recursive: true });
|
|
43988
44087
|
const skillContent = `---
|
|
43989
44088
|
name: example-skill
|
|
43990
44089
|
description: ${templateName} \u793A\u4F8B Agent \u6280\u80FD\uFF0C\u6307\u5BFC AI \u6309\u7167\u6700\u4F73\u5B9E\u8DF5\u5B8C\u6210\u7279\u5B9A\u4EFB\u52A1
|
|
@@ -44000,9 +44099,9 @@ description: ${templateName} \u793A\u4F8B Agent \u6280\u80FD\uFF0C\u6307\u5BFC A
|
|
|
44000
44099
|
2. \u9075\u5FAA\u672C\u9879\u76EE\u7684\u67B6\u6784\u8BBE\u8BA1\u539F\u5219\u5B9E\u73B0\u4EE3\u7801\u3002
|
|
44001
44100
|
3. \u7F16\u5199\u5BF9\u5E94\u6D4B\u8BD5\u5E76\u9A8C\u8BC1\u3002
|
|
44002
44101
|
`;
|
|
44003
|
-
await
|
|
44102
|
+
await writeFile9(resolve15(skillDir, "SKILL.md"), skillContent, "utf-8");
|
|
44004
44103
|
const cursorRulesDir = resolve15(targetDir, "rules", "cursor");
|
|
44005
|
-
await
|
|
44104
|
+
await mkdir16(cursorRulesDir, { recursive: true });
|
|
44006
44105
|
const cursorRuleContent = `---
|
|
44007
44106
|
description: ${templateName} Cursor \u7F16\u7801\u89C4\u5219
|
|
44008
44107
|
globs: *
|
|
@@ -44014,17 +44113,17 @@ alwaysApply: false
|
|
|
44014
44113
|
- \u4F18\u5148\u4F7F\u7528\u73B0\u6709\u7684\u8BBE\u8BA1\u7CFB\u7EDF\u548C\u516C\u5171\u7EC4\u4EF6\u3002
|
|
44015
44114
|
- \u4FDD\u6301\u51FD\u6570\u4E0E\u6A21\u5757\u7B80\u6D01\uFF0C\u5355\u4E00\u804C\u8D23\u3002
|
|
44016
44115
|
`;
|
|
44017
|
-
await
|
|
44116
|
+
await writeFile9(resolve15(cursorRulesDir, "example-rule.mdc"), cursorRuleContent, "utf-8");
|
|
44018
44117
|
const codebuddyRulesDir = resolve15(targetDir, "rules", "codebuddy");
|
|
44019
|
-
await
|
|
44118
|
+
await mkdir16(codebuddyRulesDir, { recursive: true });
|
|
44020
44119
|
const codebuddyRuleContent = `# ${templateName} \u7F16\u7801\u89C4\u5219 (CodeBuddy)
|
|
44021
44120
|
|
|
44022
44121
|
- \u9075\u5FAA\u4EE3\u7801\u8BBE\u8BA1\u539F\u5219\u3002
|
|
44023
44122
|
- \u5355\u5143\u6D4B\u8BD5\u8986\u76D6\u6838\u5FC3\u903B\u8F91\u5206\u652F\u3002
|
|
44024
44123
|
`;
|
|
44025
|
-
await
|
|
44124
|
+
await writeFile9(resolve15(codebuddyRulesDir, "example-rule.md"), codebuddyRuleContent, "utf-8");
|
|
44026
44125
|
const mcpDir = resolve15(targetDir, "mcp");
|
|
44027
|
-
await
|
|
44126
|
+
await mkdir16(mcpDir, { recursive: true });
|
|
44028
44127
|
const mcpJsonContent = {
|
|
44029
44128
|
mcpServers: {
|
|
44030
44129
|
"example-server": {
|
|
@@ -44033,9 +44132,9 @@ alwaysApply: false
|
|
|
44033
44132
|
}
|
|
44034
44133
|
}
|
|
44035
44134
|
};
|
|
44036
|
-
await
|
|
44135
|
+
await writeFile9(resolve15(mcpDir, "mcp.json"), JSON.stringify(mcpJsonContent, null, 2) + "\n", "utf-8");
|
|
44037
44136
|
const testDir = resolve15(targetDir, "test");
|
|
44038
|
-
await
|
|
44137
|
+
await mkdir16(testDir, { recursive: true });
|
|
44039
44138
|
const testContent = `import { describe, expect, it } from 'vitest';
|
|
44040
44139
|
import { readFile } from 'node:fs/promises';
|
|
44041
44140
|
import { resolve } from 'node:path';
|
|
@@ -44048,7 +44147,7 @@ describe('${packageId} template manifest', () => {
|
|
|
44048
44147
|
});
|
|
44049
44148
|
});
|
|
44050
44149
|
`;
|
|
44051
|
-
await
|
|
44150
|
+
await writeFile9(resolve15(testDir, "manifest.test.ts"), testContent, "utf-8");
|
|
44052
44151
|
const createdFiles = [
|
|
44053
44152
|
"manifest.yaml",
|
|
44054
44153
|
"AGENTS.md",
|
|
@@ -44061,7 +44160,7 @@ describe('${packageId} template manifest', () => {
|
|
|
44061
44160
|
"test/manifest.test.ts"
|
|
44062
44161
|
];
|
|
44063
44162
|
if (withPipeline) {
|
|
44064
|
-
await
|
|
44163
|
+
await writeFile9(
|
|
44065
44164
|
resolve15(targetDir, ".gitlab-ci.yml"),
|
|
44066
44165
|
generateGitlabCiYaml(packageId),
|
|
44067
44166
|
"utf-8"
|
|
@@ -44075,7 +44174,7 @@ describe('${packageId} template manifest', () => {
|
|
|
44075
44174
|
withTasks: Boolean(withTasks),
|
|
44076
44175
|
withPipeline: Boolean(withPipeline)
|
|
44077
44176
|
});
|
|
44078
|
-
await
|
|
44177
|
+
await writeFile9(resolve15(targetDir, "README.md"), readmeContent, "utf-8");
|
|
44079
44178
|
if (output.json) {
|
|
44080
44179
|
emitSuccessJson("extension create", {
|
|
44081
44180
|
directory: targetDir,
|
|
@@ -44380,9 +44479,9 @@ var init_shared_options = __esm({
|
|
|
44380
44479
|
});
|
|
44381
44480
|
|
|
44382
44481
|
// packages/cli/src/commands/extension-dev.ts
|
|
44383
|
-
import { mkdtemp as mkdtemp6, readFile as
|
|
44482
|
+
import { mkdtemp as mkdtemp6, readFile as readFile25 } from "node:fs/promises";
|
|
44384
44483
|
import { tmpdir as tmpdir6 } from "node:os";
|
|
44385
|
-
import { join as
|
|
44484
|
+
import { join as join20, resolve as resolvePath9, relative as relative8, isAbsolute as isAbsolute6, sep as sep4 } from "node:path";
|
|
44386
44485
|
function createExtensionDevCommand() {
|
|
44387
44486
|
const cmd = new Command("dev");
|
|
44388
44487
|
cmd.description(t("extension.dev.description")).argument("[package-directory]", t("extension.dev.argPackageDirectory"), ".").requiredOption("--project <fixture-directory>", t("extension.dev.optionProject")).option("--operation <create|apply|sync|remove>", t("extension.dev.optionOperation"), "apply").option("--target <id>", t("mutation.target"), collectString2, []).option("--set <name=value>", t("mutation.set"), collectString2, []).option("--dry-run", t("mutation.dryRun")).option("--yes", t("mutation.yes")).option("--allow <permission>", t("mutation.allow"), collectString2, []).option("--watch", t("extension.dev.optionWatch")).action(async (packageDirectory, opts) => {
|
|
@@ -44436,7 +44535,7 @@ async function executeExtensionDev(packageDirectory, options) {
|
|
|
44436
44535
|
return ExitCode.SchemaInvalid;
|
|
44437
44536
|
}
|
|
44438
44537
|
const effectiveDryRun = options.dryRun || options.watch;
|
|
44439
|
-
const isolatedUserData = await mkdtemp6(
|
|
44538
|
+
const isolatedUserData = await mkdtemp6(join20(tmpdir6(), "aicoding-dev-userdata-"));
|
|
44440
44539
|
const prevUserData = process.env["AICODING_USER_DATA"];
|
|
44441
44540
|
process.env["AICODING_USER_DATA"] = isolatedUserData;
|
|
44442
44541
|
try {
|
|
@@ -44497,7 +44596,7 @@ async function readPackageId(packageDirectory) {
|
|
|
44497
44596
|
const manifestPath = resolvePath9(process.cwd(), packageDirectory, "manifest.yaml");
|
|
44498
44597
|
let content;
|
|
44499
44598
|
try {
|
|
44500
|
-
content = await
|
|
44599
|
+
content = await readFile25(manifestPath, "utf-8");
|
|
44501
44600
|
} catch {
|
|
44502
44601
|
throw new CliError(`\u672A\u5728 '${packageDirectory}' \u4E0B\u627E\u5230 manifest.yaml`, ExitCode.ResolveFailed, "DEV_MANIFEST_NOT_FOUND");
|
|
44503
44602
|
}
|
|
@@ -44510,7 +44609,7 @@ async function readPackageId(packageDirectory) {
|
|
|
44510
44609
|
function getProjectRelativeSourcePath(packageDirectory, project) {
|
|
44511
44610
|
const packageAbs = resolvePath9(process.cwd(), packageDirectory);
|
|
44512
44611
|
const projectAbs = resolvePath9(process.cwd(), project);
|
|
44513
|
-
const relativePath =
|
|
44612
|
+
const relativePath = relative8(projectAbs, packageAbs).split(sep4).join("/");
|
|
44514
44613
|
if (relativePath === ".." || relativePath.startsWith("../") || isAbsolute6(relativePath)) {
|
|
44515
44614
|
throw new CliError(
|
|
44516
44615
|
`\u6269\u5C55\u5305\u76EE\u5F55\u5FC5\u987B\u5728 fixture \u9879\u76EE\u76EE\u5F55\u5185\uFF08local \u6E90\u8DEF\u5F84\u9700\u4E3A\u9879\u76EE\u76F8\u5BF9\u8DEF\u5F84\uFF09\u3002\u8BF7\u5C06 '${packageDirectory}' \u79FB\u52A8\u6216\u94FE\u63A5\u5230 '${project}' \u5185\u3002`,
|
|
@@ -44532,7 +44631,7 @@ var init_extension_dev = __esm({
|
|
|
44532
44631
|
});
|
|
44533
44632
|
|
|
44534
44633
|
// packages/cli/src/commands/extension-test.ts
|
|
44535
|
-
import { readFile as
|
|
44634
|
+
import { readFile as readFile26 } from "node:fs/promises";
|
|
44536
44635
|
import { resolve as resolve16 } from "node:path";
|
|
44537
44636
|
import { execFile as execFile3 } from "node:child_process";
|
|
44538
44637
|
import { promisify as promisify4 } from "node:util";
|
|
@@ -44597,7 +44696,7 @@ async function executeExtensionTest(packageDirectory, options, cliVersion) {
|
|
|
44597
44696
|
let hasTestScript = false;
|
|
44598
44697
|
let isNpmPackage = false;
|
|
44599
44698
|
try {
|
|
44600
|
-
const pkgJsonContent = await
|
|
44699
|
+
const pkgJsonContent = await readFile26(resolve16(pkgDir, "package.json"), "utf-8");
|
|
44601
44700
|
const pkgJson = JSON.parse(pkgJsonContent);
|
|
44602
44701
|
hasTestScript = Boolean(pkgJson.scripts?.test);
|
|
44603
44702
|
isNpmPackage = Boolean(pkgJson.name);
|
|
@@ -44676,8 +44775,8 @@ var init_extension_test = __esm({
|
|
|
44676
44775
|
});
|
|
44677
44776
|
|
|
44678
44777
|
// packages/cli/src/commands/extension-pack.ts
|
|
44679
|
-
import { readFile as
|
|
44680
|
-
import { resolve as resolve17, join as
|
|
44778
|
+
import { readFile as readFile27, mkdir as mkdir17 } from "node:fs/promises";
|
|
44779
|
+
import { resolve as resolve17, join as join21, dirname as dirname15 } from "node:path";
|
|
44681
44780
|
import { execFile as execFile4 } from "node:child_process";
|
|
44682
44781
|
import { promisify as promisify5 } from "node:util";
|
|
44683
44782
|
import { createHash as createHash13 } from "node:crypto";
|
|
@@ -44747,7 +44846,7 @@ async function executeExtensionPack(packageDirectory, options, cliVersion) {
|
|
|
44747
44846
|
let pkgJson;
|
|
44748
44847
|
let pkgJsonRaw;
|
|
44749
44848
|
try {
|
|
44750
|
-
pkgJsonRaw = await
|
|
44849
|
+
pkgJsonRaw = await readFile27(resolve17(pkgDir, "package.json"), "utf-8");
|
|
44751
44850
|
pkgJson = JSON.parse(pkgJsonRaw);
|
|
44752
44851
|
} catch {
|
|
44753
44852
|
if (output.json) {
|
|
@@ -44826,11 +44925,11 @@ async function executeExtensionPack(packageDirectory, options, cliVersion) {
|
|
|
44826
44925
|
}
|
|
44827
44926
|
}
|
|
44828
44927
|
const outputDir = options.output ? resolve17(options.output) : resolve17(pkgDir, "dist-package");
|
|
44829
|
-
await
|
|
44928
|
+
await mkdir17(outputDir, { recursive: true });
|
|
44830
44929
|
let tarballName;
|
|
44831
44930
|
let tarballPath;
|
|
44832
44931
|
tarballName = `${pkgName.replace(/^@/, "").replace(/\//g, "-")}-${pkgVersion}.tgz`;
|
|
44833
|
-
tarballPath =
|
|
44932
|
+
tarballPath = join21(outputDir, tarballName);
|
|
44834
44933
|
try {
|
|
44835
44934
|
await packWithNpm(pkgDir, outputDir);
|
|
44836
44935
|
} catch (err) {
|
|
@@ -44847,7 +44946,7 @@ async function executeExtensionPack(packageDirectory, options, cliVersion) {
|
|
|
44847
44946
|
let sri = "";
|
|
44848
44947
|
let manifestDigest = "";
|
|
44849
44948
|
try {
|
|
44850
|
-
const tarballContent = await
|
|
44949
|
+
const tarballContent = await readFile27(tarballPath);
|
|
44851
44950
|
sri = "sha512-" + createHash13("sha512").update(tarballContent).digest("base64");
|
|
44852
44951
|
} catch {
|
|
44853
44952
|
if (output.json) {
|
|
@@ -44859,7 +44958,7 @@ async function executeExtensionPack(packageDirectory, options, cliVersion) {
|
|
|
44859
44958
|
return ExitCode.ExecuteFailed;
|
|
44860
44959
|
}
|
|
44861
44960
|
try {
|
|
44862
|
-
const manifestContent = await
|
|
44961
|
+
const manifestContent = await readFile27(resolve17(pkgDir, "manifest.yaml"));
|
|
44863
44962
|
manifestDigest = createHash13("sha256").update(manifestContent).digest("hex");
|
|
44864
44963
|
} catch {
|
|
44865
44964
|
}
|
|
@@ -44899,7 +44998,7 @@ var init_extension_pack = __esm({
|
|
|
44899
44998
|
});
|
|
44900
44999
|
|
|
44901
45000
|
// packages/cli/src/commands/extension-submit.ts
|
|
44902
|
-
import { readFile as
|
|
45001
|
+
import { readFile as readFile28 } from "node:fs/promises";
|
|
44903
45002
|
import { resolve as resolve18 } from "node:path";
|
|
44904
45003
|
function createExtensionSubmitCommand(cliVersion) {
|
|
44905
45004
|
const cmd = new Command("submit");
|
|
@@ -44962,7 +45061,7 @@ async function executeExtensionSubmit(packageDirectory, options, cliVersion) {
|
|
|
44962
45061
|
let pkgName = "";
|
|
44963
45062
|
let pkgVersion = "";
|
|
44964
45063
|
try {
|
|
44965
|
-
const pkgJsonRaw = await
|
|
45064
|
+
const pkgJsonRaw = await readFile28(resolve18(pkgDir, "package.json"), "utf-8");
|
|
44966
45065
|
const pkgJson = JSON.parse(pkgJsonRaw);
|
|
44967
45066
|
pkgName = pkgJson.name ?? "";
|
|
44968
45067
|
pkgVersion = pkgJson.version ?? "";
|
|
@@ -45070,7 +45169,7 @@ var init_extension_submit = __esm({
|
|
|
45070
45169
|
});
|
|
45071
45170
|
|
|
45072
45171
|
// packages/cli/src/commands/extension-adapter.ts
|
|
45073
|
-
import { readFile as
|
|
45172
|
+
import { readFile as readFile29, mkdir as mkdir18 } from "node:fs/promises";
|
|
45074
45173
|
import { dirname as dirname16, resolve as resolve19 } from "node:path";
|
|
45075
45174
|
import { execFile as execFile5 } from "node:child_process";
|
|
45076
45175
|
import { promisify as promisify6 } from "node:util";
|
|
@@ -45293,7 +45392,7 @@ async function executeAdapterTest(packageDirectory, options) {
|
|
|
45293
45392
|
}
|
|
45294
45393
|
let hasTestScript = false;
|
|
45295
45394
|
try {
|
|
45296
|
-
const pkgJsonRaw = await
|
|
45395
|
+
const pkgJsonRaw = await readFile29(resolve19(pkgDir, "package.json"), "utf-8");
|
|
45297
45396
|
const pkgJson = JSON.parse(pkgJsonRaw);
|
|
45298
45397
|
hasTestScript = Boolean(pkgJson.scripts?.test);
|
|
45299
45398
|
} catch {
|
|
@@ -45381,7 +45480,7 @@ async function executeAdapterPack(packageDirectory, options) {
|
|
|
45381
45480
|
let pkgVersion = "";
|
|
45382
45481
|
let files = [];
|
|
45383
45482
|
try {
|
|
45384
|
-
const pkgJsonRaw = await
|
|
45483
|
+
const pkgJsonRaw = await readFile29(resolve19(pkgDir, "package.json"), "utf-8");
|
|
45385
45484
|
const pkgJson = JSON.parse(pkgJsonRaw);
|
|
45386
45485
|
pkgName = pkgJson.name ?? "";
|
|
45387
45486
|
pkgVersion = pkgJson.version ?? "";
|
|
@@ -45414,7 +45513,7 @@ async function executeAdapterPack(packageDirectory, options) {
|
|
|
45414
45513
|
return ExitCode.SchemaInvalid;
|
|
45415
45514
|
}
|
|
45416
45515
|
const outputDir = options.output ? resolve19(options.output) : resolve19(pkgDir, "dist-package");
|
|
45417
|
-
await
|
|
45516
|
+
await mkdir18(outputDir, { recursive: true });
|
|
45418
45517
|
const tarballName = `${pkgName.replace(/^@/, "").replace(/\//g, "-")}-${pkgVersion}.tgz`;
|
|
45419
45518
|
const tarballPath = resolve19(outputDir, tarballName);
|
|
45420
45519
|
try {
|
|
@@ -45429,7 +45528,7 @@ async function executeAdapterPack(packageDirectory, options) {
|
|
|
45429
45528
|
}
|
|
45430
45529
|
return ExitCode.ExecuteFailed;
|
|
45431
45530
|
}
|
|
45432
|
-
const tarballContent = await
|
|
45531
|
+
const tarballContent = await readFile29(tarballPath);
|
|
45433
45532
|
const sri = "sha512-" + createHash14("sha512").update(tarballContent).digest("base64");
|
|
45434
45533
|
if (output.json) {
|
|
45435
45534
|
emitSuccessJson("extension adapter pack", {
|
|
@@ -45615,7 +45714,7 @@ var init_journal_helper = __esm({
|
|
|
45615
45714
|
|
|
45616
45715
|
// packages/cli/src/commands/service-locator.ts
|
|
45617
45716
|
import { homedir as homedir2 } from "node:os";
|
|
45618
|
-
import { join as
|
|
45717
|
+
import { join as join22, resolve as resolve20 } from "node:path";
|
|
45619
45718
|
var ServiceLocator;
|
|
45620
45719
|
var init_service_locator = __esm({
|
|
45621
45720
|
"packages/cli/src/commands/service-locator.ts"() {
|
|
@@ -45649,13 +45748,13 @@ var init_service_locator = __esm({
|
|
|
45649
45748
|
return `mano-coding@${this.config.cliVersion}`;
|
|
45650
45749
|
}
|
|
45651
45750
|
getUserDataDir() {
|
|
45652
|
-
return this.config.userDataDir ?? process.env["MANO_USER_DATA"] ?? process.env["AICODING_USER_DATA"] ??
|
|
45751
|
+
return this.config.userDataDir ?? process.env["MANO_USER_DATA"] ?? process.env["AICODING_USER_DATA"] ?? join22(homedir2(), ".mano-coding");
|
|
45653
45752
|
}
|
|
45654
45753
|
getRegistryUrl() {
|
|
45655
45754
|
return this.config.registryUrl || process.env["MANO_REGISTRY"] || process.env["AICODING_REGISTRY"] || DEFAULT_PUBLIC_REGISTRY_URL;
|
|
45656
45755
|
}
|
|
45657
45756
|
getCacheRoot() {
|
|
45658
|
-
return this.config.cacheRoot ??
|
|
45757
|
+
return this.config.cacheRoot ?? join22(this.getUserDataDir(), "cache");
|
|
45659
45758
|
}
|
|
45660
45759
|
getRegistryClient() {
|
|
45661
45760
|
if (!this._registryClient) {
|
|
@@ -45810,8 +45909,8 @@ var init_service_locator = __esm({
|
|
|
45810
45909
|
});
|
|
45811
45910
|
|
|
45812
45911
|
// packages/cli/src/commands/plan-execution.ts
|
|
45813
|
-
import { readFile as
|
|
45814
|
-
import { join as
|
|
45912
|
+
import { readFile as readFile30, readdir as readdir10, stat as stat7 } from "node:fs/promises";
|
|
45913
|
+
import { join as join23, resolve as resolve21 } from "node:path";
|
|
45815
45914
|
import { createHash as createHash15 } from "node:crypto";
|
|
45816
45915
|
async function buildIntentsFromPlan(_plan, resolutions, service, projectTargets, _userInstallationKeys, options) {
|
|
45817
45916
|
const adapterRegistry = service.getAdapterRegistry();
|
|
@@ -45920,14 +46019,14 @@ async function executeUserCapabilityInstallations(_resolutions, _service, _input
|
|
|
45920
46019
|
}
|
|
45921
46020
|
async function collectAssetIntents(packageRoot, source, destination, metadata) {
|
|
45922
46021
|
const sourcePath = resolve21(packageRoot, source);
|
|
45923
|
-
const sourceStat = await
|
|
46022
|
+
const sourceStat = await stat7(sourcePath);
|
|
45924
46023
|
if (sourceStat.isFile()) {
|
|
45925
|
-
return [{ action: "upsert", type: "file", path: destination, content: await
|
|
46024
|
+
return [{ action: "upsert", type: "file", path: destination, content: await readFile30(sourcePath), executable: metadata.executable, packageId: metadata.packageId, ownerKind: metadata.ownerKind }];
|
|
45926
46025
|
}
|
|
45927
46026
|
if (!sourceStat.isDirectory()) throw new Error(`Asset '${source}' \u65E2\u4E0D\u662F\u6587\u4EF6\u4E5F\u4E0D\u662F\u76EE\u5F55`);
|
|
45928
46027
|
const intents = [];
|
|
45929
|
-
for (const entry of await
|
|
45930
|
-
intents.push(...await collectAssetIntents(packageRoot,
|
|
46028
|
+
for (const entry of await readdir10(sourcePath, { withFileTypes: true })) {
|
|
46029
|
+
intents.push(...await collectAssetIntents(packageRoot, join23(source, entry.name), join23(destination, entry.name).replaceAll("\\", "/"), metadata));
|
|
45931
46030
|
}
|
|
45932
46031
|
return intents;
|
|
45933
46032
|
}
|
|
@@ -46764,243 +46863,300 @@ ${taskValidation.missingInputs.map((k2) => `--input ${pkgId}:${k2}=<value>`).joi
|
|
|
46764
46863
|
await service.registerThirdPartyAdapters(
|
|
46765
46864
|
allResolutions.map((r) => ({ manifest: r.manifest, resolution: r }))
|
|
46766
46865
|
);
|
|
46767
|
-
const
|
|
46768
|
-
|
|
46769
|
-
|
|
46770
|
-
|
|
46771
|
-
|
|
46772
|
-
|
|
46773
|
-
|
|
46774
|
-
|
|
46775
|
-
|
|
46776
|
-
|
|
46777
|
-
|
|
46778
|
-
|
|
46779
|
-
|
|
46780
|
-
|
|
46781
|
-
|
|
46782
|
-
failText: "\u2716 \u6267\u884C\u8BA1\u5212\u751F\u6210\u5931\u8D25"
|
|
46783
|
-
}
|
|
46784
|
-
);
|
|
46785
|
-
planResult = materializePlan(planResult.plan, intents);
|
|
46786
|
-
events.report("plan", "success", Date.now() - planStartedAt, { planDigest: planResult.plan.planDigest, details: { intentCount: intents.length } });
|
|
46787
|
-
if (planResult.conflicts.length > 0) {
|
|
46788
|
-
events.report("plan", "failure", 0, { errorCode: "PLAN_CONFLICT", planDigest: planResult.plan.planDigest });
|
|
46789
|
-
const conflictDiags = planResult.conflicts.flatMap((c) => c.diagnostics);
|
|
46790
|
-
writeDiagnostics(conflictDiags, output);
|
|
46791
|
-
if (output.json) {
|
|
46792
|
-
emitFailureJson(
|
|
46793
|
-
"create",
|
|
46794
|
-
"PLAN_CONFLICT",
|
|
46795
|
-
t("create.planConflict"),
|
|
46796
|
-
{ conflicts: planResult.conflicts.map((c) => ({ type: c.type, resourceKey: c.resourceKey })) },
|
|
46797
|
-
[],
|
|
46798
|
-
conflictDiags,
|
|
46799
|
-
jsonEvents()
|
|
46800
|
-
);
|
|
46801
|
-
} else {
|
|
46802
|
-
process.stderr.write(`error: PLAN_CONFLICT: ${t("create.planConflict")}
|
|
46803
|
-
`);
|
|
46866
|
+
const stagingManager = new StagingManager();
|
|
46867
|
+
try {
|
|
46868
|
+
const hasBeforeCreate = allResolutions.some((res) => {
|
|
46869
|
+
const tasks = res.manifest.tasks ?? [];
|
|
46870
|
+
return filterTasksByHook2(tasks, "before:create").length > 0;
|
|
46871
|
+
});
|
|
46872
|
+
const stagingDirMap = /* @__PURE__ */ new Map();
|
|
46873
|
+
if (hasBeforeCreate) {
|
|
46874
|
+
for (const res of allResolutions) {
|
|
46875
|
+
const tasks = res.manifest.tasks ?? [];
|
|
46876
|
+
if (filterTasksByHook2(tasks, "before:create").length > 0) {
|
|
46877
|
+
const sDir = await stagingManager.getOrCreateStagingDir(res.manifest.id);
|
|
46878
|
+
stagingDirMap.set(res.manifest.id, sDir);
|
|
46879
|
+
}
|
|
46880
|
+
}
|
|
46804
46881
|
}
|
|
46805
|
-
|
|
46806
|
-
|
|
46807
|
-
|
|
46808
|
-
|
|
46809
|
-
|
|
46810
|
-
|
|
46882
|
+
const planStartedAt = Date.now();
|
|
46883
|
+
const planBuilder = service.getPlanBuilder();
|
|
46884
|
+
let planResult = planBuilder.build(
|
|
46885
|
+
"create",
|
|
46886
|
+
service.projectRoot,
|
|
46887
|
+
allResolutions,
|
|
46888
|
+
projectTargets
|
|
46889
|
+
);
|
|
46890
|
+
const userInstallationKeys = /* @__PURE__ */ new Set();
|
|
46891
|
+
let staticIntents = await withSpinner(
|
|
46892
|
+
"\u6B63\u5728\u8BA1\u7B97\u53D7\u7BA1\u8D44\u6E90\u5E76\u751F\u6210\u6267\u884C\u8BA1\u5212...",
|
|
46893
|
+
() => buildIntentsFromPlan(planResult.plan, allResolutions, service, projectTargets, userInstallationKeys),
|
|
46894
|
+
{
|
|
46895
|
+
enabled: spinnerEnabled,
|
|
46896
|
+
successText: (res) => `\u2714 \u6267\u884C\u8BA1\u5212\u5DF2\u5C31\u7EEA (\u5171 ${res.length} \u9879\u8D44\u6E90\u53D8\u66F4)`,
|
|
46897
|
+
failText: "\u2716 \u6267\u884C\u8BA1\u5212\u751F\u6210\u5931\u8D25"
|
|
46898
|
+
}
|
|
46899
|
+
);
|
|
46900
|
+
planResult = materializePlan(planResult.plan, staticIntents);
|
|
46901
|
+
events.report("plan", "success", Date.now() - planStartedAt, { planDigest: planResult.plan.planDigest, details: { intentCount: staticIntents.length } });
|
|
46902
|
+
if (planResult.conflicts.length > 0) {
|
|
46903
|
+
events.report("plan", "failure", 0, { errorCode: "PLAN_CONFLICT", planDigest: planResult.plan.planDigest });
|
|
46904
|
+
const conflictDiags = planResult.conflicts.flatMap((c) => c.diagnostics);
|
|
46905
|
+
writeDiagnostics(conflictDiags, output);
|
|
46811
46906
|
if (output.json) {
|
|
46812
46907
|
emitFailureJson(
|
|
46813
46908
|
"create",
|
|
46814
|
-
"
|
|
46815
|
-
t("create.
|
|
46816
|
-
{
|
|
46817
|
-
[],
|
|
46909
|
+
"PLAN_CONFLICT",
|
|
46910
|
+
t("create.planConflict"),
|
|
46911
|
+
{ conflicts: planResult.conflicts.map((c) => ({ type: c.type, resourceKey: c.resourceKey })) },
|
|
46818
46912
|
[],
|
|
46913
|
+
conflictDiags,
|
|
46819
46914
|
jsonEvents()
|
|
46820
46915
|
);
|
|
46821
46916
|
} else {
|
|
46822
|
-
process.stderr.write(
|
|
46823
|
-
|
|
46917
|
+
process.stderr.write(`error: PLAN_CONFLICT: ${t("create.planConflict")}
|
|
46918
|
+
`);
|
|
46919
|
+
}
|
|
46920
|
+
return ExitCode.ConflictOrDrift;
|
|
46921
|
+
}
|
|
46922
|
+
let grantedPermissions = [];
|
|
46923
|
+
if (!options.dryRun && !options.yes) {
|
|
46924
|
+
if (options.noInput || !process.stdin.isTTY) {
|
|
46925
|
+
events.report("authorize", "failure", 0, { errorCode: "NEEDS_CONFIRMATION", planDigest: planResult.plan.planDigest });
|
|
46926
|
+
if (output.json) {
|
|
46927
|
+
emitFailureJson(
|
|
46928
|
+
"create",
|
|
46929
|
+
"NEEDS_CONFIRMATION",
|
|
46930
|
+
t("create.needsConfirmation"),
|
|
46931
|
+
{ planDigest: planResult.plan.planDigest },
|
|
46932
|
+
[],
|
|
46933
|
+
[],
|
|
46934
|
+
jsonEvents()
|
|
46935
|
+
);
|
|
46936
|
+
} else {
|
|
46937
|
+
process.stderr.write(
|
|
46938
|
+
`error: NEEDS_CONFIRMATION: ${t("create.needsConfirmation")}
|
|
46824
46939
|
`
|
|
46825
|
-
|
|
46940
|
+
);
|
|
46941
|
+
}
|
|
46942
|
+
return ExitCode.NeedsInputOrDenied;
|
|
46826
46943
|
}
|
|
46827
|
-
|
|
46944
|
+
const { confirmPlanInteractive: confirmPlanInteractive2 } = await Promise.resolve().then(() => (init_tty_confirm(), tty_confirm_exports));
|
|
46945
|
+
const confirmResult = await confirmPlanInteractive2({
|
|
46946
|
+
output,
|
|
46947
|
+
command: "create",
|
|
46948
|
+
plan: planResult.plan,
|
|
46949
|
+
allowedPermissions: options.allow
|
|
46950
|
+
});
|
|
46951
|
+
if (!confirmResult.confirmed) {
|
|
46952
|
+
events.report("authorize", "failure", 0, { errorCode: "PERMISSION_DENIED", planDigest: planResult.plan.planDigest });
|
|
46953
|
+
if (output.json) {
|
|
46954
|
+
emitFailureJson("create", "PERMISSION_DENIED", t("create.userDeclined"), { planDigest: planResult.plan.planDigest }, [], [], jsonEvents());
|
|
46955
|
+
} else {
|
|
46956
|
+
process.stderr.write(`error: PERMISSION_DENIED: ${t("create.userDeclined")}
|
|
46957
|
+
`);
|
|
46958
|
+
}
|
|
46959
|
+
return ExitCode.NeedsInputOrDenied;
|
|
46960
|
+
}
|
|
46961
|
+
events.report("authorize", "success", 0, { planDigest: planResult.plan.planDigest });
|
|
46962
|
+
grantedPermissions = confirmResult.granted;
|
|
46828
46963
|
}
|
|
46829
|
-
|
|
46830
|
-
|
|
46831
|
-
|
|
46832
|
-
|
|
46833
|
-
|
|
46834
|
-
allowedPermissions: options.allow
|
|
46835
|
-
});
|
|
46836
|
-
if (!confirmResult.confirmed) {
|
|
46837
|
-
events.report("authorize", "failure", 0, { errorCode: "PERMISSION_DENIED", planDigest: planResult.plan.planDigest });
|
|
46964
|
+
if (options.dryRun) {
|
|
46965
|
+
events.report("authorize", "skipped", 0, { planDigest: planResult.plan.planDigest });
|
|
46966
|
+
events.report("execute", "skipped", 0, { planDigest: planResult.plan.planDigest });
|
|
46967
|
+
events.report("record", "skipped", 0, { planDigest: planResult.plan.planDigest });
|
|
46968
|
+
const summary2 = summarizePlan(planResult.plan);
|
|
46838
46969
|
if (output.json) {
|
|
46839
|
-
|
|
46970
|
+
emitSuccessJson("create", { dryRun: true, ...summary2 }, [], [], jsonEvents());
|
|
46840
46971
|
} else {
|
|
46841
|
-
|
|
46842
|
-
`);
|
|
46972
|
+
printPlanSummary(summary2);
|
|
46843
46973
|
}
|
|
46844
|
-
return ExitCode.
|
|
46845
|
-
}
|
|
46846
|
-
events.report("authorize", "success", 0, { planDigest: planResult.plan.planDigest });
|
|
46847
|
-
grantedPermissions = confirmResult.granted;
|
|
46848
|
-
}
|
|
46849
|
-
if (options.dryRun) {
|
|
46850
|
-
events.report("authorize", "skipped", 0, { planDigest: planResult.plan.planDigest });
|
|
46851
|
-
events.report("execute", "skipped", 0, { planDigest: planResult.plan.planDigest });
|
|
46852
|
-
events.report("record", "skipped", 0, { planDigest: planResult.plan.planDigest });
|
|
46853
|
-
const summary2 = summarizePlan(planResult.plan);
|
|
46854
|
-
if (output.json) {
|
|
46855
|
-
emitSuccessJson("create", { dryRun: true, ...summary2 }, [], [], jsonEvents());
|
|
46856
|
-
} else {
|
|
46857
|
-
printPlanSummary(summary2);
|
|
46974
|
+
return ExitCode.Success;
|
|
46858
46975
|
}
|
|
46859
|
-
|
|
46860
|
-
|
|
46861
|
-
|
|
46862
|
-
|
|
46863
|
-
|
|
46864
|
-
|
|
46865
|
-
|
|
46866
|
-
|
|
46867
|
-
|
|
46868
|
-
|
|
46869
|
-
|
|
46870
|
-
|
|
46871
|
-
|
|
46872
|
-
|
|
46873
|
-
|
|
46874
|
-
|
|
46875
|
-
|
|
46876
|
-
|
|
46877
|
-
|
|
46878
|
-
|
|
46879
|
-
|
|
46976
|
+
const { basename: basename8, dirname: dirname20 } = await import("node:path");
|
|
46977
|
+
const dynamicIntents = [];
|
|
46978
|
+
for (let pkgIdx = 0; pkgIdx < allResolutions.length; pkgIdx++) {
|
|
46979
|
+
const resolution = allResolutions[pkgIdx];
|
|
46980
|
+
const pkgTasks = filterTasksByHook2(resolution.manifest.tasks ?? [], "before:create");
|
|
46981
|
+
if (pkgTasks.length > 0) {
|
|
46982
|
+
const templateDir = service.getPackageRoot(resolution) ?? service.projectRoot;
|
|
46983
|
+
const stagingDir = stagingDirMap.get(resolution.manifest.id);
|
|
46984
|
+
const taskContext = {
|
|
46985
|
+
projectName: basename8(service.projectRoot),
|
|
46986
|
+
projectDir: service.projectRoot,
|
|
46987
|
+
projectParentDir: dirname20(service.projectRoot),
|
|
46988
|
+
templateDir,
|
|
46989
|
+
stagingDir,
|
|
46990
|
+
inputs: { ...inputValues, ...packageValues[resolution.manifest.id] ?? {} },
|
|
46991
|
+
target: projectTargets[0]?.id,
|
|
46992
|
+
targets: projectTargets.map((t2) => t2.id),
|
|
46993
|
+
operation: "create",
|
|
46994
|
+
version: resolution.manifest.version
|
|
46995
|
+
};
|
|
46996
|
+
if (!output.json) {
|
|
46997
|
+
writeHumanOutput(`
|
|
46880
46998
|
\u6B63\u5728\u6267\u884C\u524D\u7F6E\u521B\u5EFA\u4EFB\u52A1 (before:create) [${pkgIdx + 1}/${allResolutions.length}] (${resolution.manifest.id}):
|
|
46881
46999
|
`);
|
|
46882
|
-
|
|
46883
|
-
|
|
46884
|
-
|
|
46885
|
-
|
|
46886
|
-
|
|
47000
|
+
}
|
|
47001
|
+
try {
|
|
47002
|
+
await executeTasks2(pkgTasks, taskContext, {
|
|
47003
|
+
onProgress: (msg) => {
|
|
47004
|
+
if (!output.json) writeHumanOutput(`> ${msg}
|
|
46887
47005
|
`);
|
|
46888
|
-
|
|
46889
|
-
|
|
46890
|
-
|
|
46891
|
-
|
|
46892
|
-
|
|
46893
|
-
|
|
47006
|
+
},
|
|
47007
|
+
stdio: output.json ? "ignore" : "inherit"
|
|
47008
|
+
});
|
|
47009
|
+
} catch (err) {
|
|
47010
|
+
if (err instanceof Error) {
|
|
47011
|
+
throw new CliError(err.message, ExitCode.ExecuteFailed, "TASK_EXECUTION_FAILED");
|
|
47012
|
+
}
|
|
47013
|
+
throw err;
|
|
47014
|
+
}
|
|
47015
|
+
if (stagingDir) {
|
|
47016
|
+
const scanRes = await scanStagingDirectory({
|
|
47017
|
+
stagingDir,
|
|
47018
|
+
packageId: resolution.manifest.id,
|
|
47019
|
+
ownerKind: "template"
|
|
47020
|
+
});
|
|
47021
|
+
dynamicIntents.push(...scanRes.intents);
|
|
46894
47022
|
}
|
|
46895
|
-
throw err;
|
|
46896
47023
|
}
|
|
46897
47024
|
}
|
|
46898
|
-
|
|
46899
|
-
|
|
46900
|
-
|
|
46901
|
-
|
|
46902
|
-
|
|
46903
|
-
|
|
46904
|
-
|
|
46905
|
-
|
|
46906
|
-
|
|
46907
|
-
|
|
46908
|
-
|
|
46909
|
-
|
|
46910
|
-
|
|
47025
|
+
let intents = staticIntents;
|
|
47026
|
+
if (hasBeforeCreate && dynamicIntents.length > 0) {
|
|
47027
|
+
const mergedIntents = deduplicateIntents([...staticIntents, ...dynamicIntents]);
|
|
47028
|
+
planResult = materializePlan(planResult.plan, mergedIntents);
|
|
47029
|
+
if (planResult.conflicts.length > 0) {
|
|
47030
|
+
events.report("plan", "failure", 0, { errorCode: "PLAN_CONFLICT", planDigest: planResult.plan.planDigest });
|
|
47031
|
+
const conflictDiags = planResult.conflicts.flatMap((c) => c.diagnostics);
|
|
47032
|
+
writeDiagnostics(conflictDiags, output);
|
|
47033
|
+
if (output.json) {
|
|
47034
|
+
emitFailureJson(
|
|
47035
|
+
"create",
|
|
47036
|
+
"PLAN_CONFLICT",
|
|
47037
|
+
t("create.planConflict"),
|
|
47038
|
+
{ conflicts: planResult.conflicts.map((c) => ({ type: c.type, resourceKey: c.resourceKey })) },
|
|
47039
|
+
[],
|
|
47040
|
+
conflictDiags,
|
|
47041
|
+
jsonEvents()
|
|
47042
|
+
);
|
|
47043
|
+
} else {
|
|
47044
|
+
process.stderr.write(`error: PLAN_CONFLICT: ${t("create.planConflict")}
|
|
47045
|
+
`);
|
|
47046
|
+
}
|
|
47047
|
+
return ExitCode.ConflictOrDrift;
|
|
46911
47048
|
}
|
|
46912
|
-
|
|
46913
|
-
|
|
46914
|
-
|
|
46915
|
-
|
|
46916
|
-
|
|
46917
|
-
|
|
46918
|
-
|
|
46919
|
-
|
|
46920
|
-
|
|
46921
|
-
|
|
46922
|
-
{
|
|
46923
|
-
|
|
46924
|
-
|
|
46925
|
-
|
|
47049
|
+
intents = mergedIntents;
|
|
47050
|
+
}
|
|
47051
|
+
const executor = service.getExecutor();
|
|
47052
|
+
const executeStartedAt = Date.now();
|
|
47053
|
+
if (!output.json) writeHumanOutput(t("create.writingResources", intents.length));
|
|
47054
|
+
const { journal, result: executeResult } = await withJournalTransaction(service, async (journal2) => {
|
|
47055
|
+
await prepareJournalRecovery(journal2, service.projectRoot, intents, ["aicoding-lock.yaml"]);
|
|
47056
|
+
return executor.execute(
|
|
47057
|
+
planResult.plan,
|
|
47058
|
+
intents,
|
|
47059
|
+
{
|
|
47060
|
+
projectRoot: service.projectRoot,
|
|
47061
|
+
dryRun: false,
|
|
47062
|
+
deferCommit: true
|
|
47063
|
+
}
|
|
46926
47064
|
);
|
|
46927
|
-
}
|
|
46928
|
-
|
|
47065
|
+
});
|
|
47066
|
+
if (!executeResult.success) {
|
|
47067
|
+
events.report("execute", "failure", Date.now() - executeStartedAt, { errorCode: "EXECUTE_FAILED", planDigest: planResult.plan.planDigest });
|
|
47068
|
+
writeDiagnostics(executeResult.diagnostics, output);
|
|
47069
|
+
if (output.json) {
|
|
47070
|
+
emitFailureJson(
|
|
47071
|
+
"create",
|
|
47072
|
+
"EXECUTE_FAILED",
|
|
47073
|
+
t("create.executionFailed"),
|
|
47074
|
+
{ planDigest: planResult.plan.planDigest, operationId: journal.operationId },
|
|
47075
|
+
[],
|
|
47076
|
+
executeResult.diagnostics,
|
|
47077
|
+
jsonEvents()
|
|
47078
|
+
);
|
|
47079
|
+
} else {
|
|
47080
|
+
process.stderr.write(`error: EXECUTE_FAILED: ${t("create.executionFailedShort")}
|
|
46929
47081
|
`);
|
|
46930
|
-
|
|
46931
|
-
|
|
46932
|
-
|
|
46933
|
-
|
|
46934
|
-
|
|
46935
|
-
|
|
46936
|
-
|
|
46937
|
-
|
|
46938
|
-
|
|
46939
|
-
|
|
46940
|
-
|
|
46941
|
-
|
|
46942
|
-
|
|
46943
|
-
|
|
46944
|
-
|
|
46945
|
-
|
|
46946
|
-
|
|
46947
|
-
|
|
46948
|
-
|
|
46949
|
-
|
|
46950
|
-
|
|
46951
|
-
|
|
46952
|
-
|
|
46953
|
-
|
|
46954
|
-
|
|
46955
|
-
|
|
46956
|
-
|
|
46957
|
-
|
|
46958
|
-
|
|
46959
|
-
|
|
46960
|
-
|
|
46961
|
-
|
|
46962
|
-
|
|
46963
|
-
|
|
46964
|
-
|
|
46965
|
-
|
|
46966
|
-
|
|
46967
|
-
|
|
46968
|
-
|
|
46969
|
-
|
|
46970
|
-
|
|
46971
|
-
|
|
46972
|
-
|
|
46973
|
-
|
|
46974
|
-
|
|
46975
|
-
|
|
47082
|
+
}
|
|
47083
|
+
return ExitCode.ExecuteFailed;
|
|
47084
|
+
}
|
|
47085
|
+
events.report("execute", "success", Date.now() - executeStartedAt, { planDigest: planResult.plan.planDigest, details: { intentCount: intents.length } });
|
|
47086
|
+
if (!output.json) writeHumanOutput(t("create.wroteResources", formatElapsed(executeStartedAt)));
|
|
47087
|
+
const previousLock = await lockRepo.read().catch(() => void 0);
|
|
47088
|
+
const recordStartedAt = Date.now();
|
|
47089
|
+
await commitExecution(executor, executeResult, async (addRollback) => {
|
|
47090
|
+
const userInstallationStartedAt = Date.now();
|
|
47091
|
+
if (!output.json && userInstallationKeys.size > 0) writeHumanOutput(t("create.installingUserTools", userInstallationKeys.size));
|
|
47092
|
+
const userLifecycle = await executeUserCapabilityInstallations(
|
|
47093
|
+
allResolutions,
|
|
47094
|
+
service,
|
|
47095
|
+
inputValues,
|
|
47096
|
+
[...options.allow, ...grantedPermissions],
|
|
47097
|
+
userInstallationKeys,
|
|
47098
|
+
journal,
|
|
47099
|
+
output.json ? void 0 : (progress) => writeUserInstallationProgress(progress)
|
|
47100
|
+
);
|
|
47101
|
+
if (!output.json && userInstallationKeys.size > 0) writeHumanOutput(t("create.userToolsInstalled", formatElapsed(userInstallationStartedAt)));
|
|
47102
|
+
addRollback(userLifecycle.rollback);
|
|
47103
|
+
const lock = await buildLock("create", templateResolution, addonResolutions, projectTargets, planResult.plan, service.cliVersion, inputValues, service, intents, userInstallationKeys);
|
|
47104
|
+
await lockRepo.write(lock);
|
|
47105
|
+
addRollback(async () => previousLock ? lockRepo.write(previousLock) : unlink9(lockRepo.path).catch(() => void 0));
|
|
47106
|
+
await userLifecycle.addReferences(lock);
|
|
47107
|
+
await finishJournal(journal);
|
|
47108
|
+
});
|
|
47109
|
+
events.report("record", "success", Date.now() - recordStartedAt, { planDigest: planResult.plan.planDigest });
|
|
47110
|
+
for (let pkgIdx = 0; pkgIdx < allResolutions.length; pkgIdx++) {
|
|
47111
|
+
const resolution = allResolutions[pkgIdx];
|
|
47112
|
+
const pkgTasks = filterTasksByHook2(resolution.manifest.tasks ?? [], "after:create");
|
|
47113
|
+
if (pkgTasks.length > 0) {
|
|
47114
|
+
const templateDir = service.getPackageRoot(resolution) ?? service.projectRoot;
|
|
47115
|
+
const taskContext = {
|
|
47116
|
+
projectName: basename8(service.projectRoot),
|
|
47117
|
+
projectDir: service.projectRoot,
|
|
47118
|
+
projectParentDir: dirname20(service.projectRoot),
|
|
47119
|
+
templateDir,
|
|
47120
|
+
inputs: { ...inputValues, ...packageValues[resolution.manifest.id] ?? {} },
|
|
47121
|
+
target: projectTargets[0]?.id,
|
|
47122
|
+
targets: projectTargets.map((t2) => t2.id),
|
|
47123
|
+
operation: "create",
|
|
47124
|
+
version: resolution.manifest.version
|
|
47125
|
+
};
|
|
47126
|
+
if (!output.json) {
|
|
47127
|
+
writeHumanOutput(`
|
|
46976
47128
|
\u6B63\u5728\u6267\u884C\u540E\u7F6E\u521D\u59CB\u5316\u4EFB\u52A1 (after:create) [${pkgIdx + 1}/${allResolutions.length}] (${resolution.manifest.id}):
|
|
46977
47129
|
`);
|
|
46978
|
-
|
|
46979
|
-
|
|
46980
|
-
|
|
46981
|
-
|
|
46982
|
-
|
|
47130
|
+
}
|
|
47131
|
+
try {
|
|
47132
|
+
await executeTasks2(pkgTasks, taskContext, {
|
|
47133
|
+
onProgress: (msg) => {
|
|
47134
|
+
if (!output.json) writeHumanOutput(`> [${resolution.manifest.id}] ${msg}
|
|
46983
47135
|
`);
|
|
46984
|
-
|
|
46985
|
-
|
|
46986
|
-
|
|
46987
|
-
|
|
46988
|
-
|
|
46989
|
-
|
|
47136
|
+
},
|
|
47137
|
+
stdio: output.json ? "ignore" : "inherit"
|
|
47138
|
+
});
|
|
47139
|
+
} catch (err) {
|
|
47140
|
+
if (err instanceof Error) {
|
|
47141
|
+
throw new CliError(err.message, ExitCode.ExecuteFailed, "TASK_EXECUTION_FAILED");
|
|
47142
|
+
}
|
|
47143
|
+
throw err;
|
|
46990
47144
|
}
|
|
46991
|
-
throw err;
|
|
46992
47145
|
}
|
|
46993
47146
|
}
|
|
47147
|
+
const summary = summarizePlan(planResult.plan);
|
|
47148
|
+
if (output.json) {
|
|
47149
|
+
emitSuccessJson("create", { dryRun: false, ...summary, lockPath: lockRepo.path, operationId: journal.operationId }, [], [], jsonEvents());
|
|
47150
|
+
} else {
|
|
47151
|
+
printPlanSummary(summary);
|
|
47152
|
+
writeHumanOutput(t("create.createdProject", service.projectRoot) + "\n");
|
|
47153
|
+
writeHumanOutput(t("create.lockFile", lockRepo.path) + "\n");
|
|
47154
|
+
}
|
|
47155
|
+
return ExitCode.Success;
|
|
47156
|
+
} finally {
|
|
47157
|
+
await stagingManager.cleanup().catch(() => {
|
|
47158
|
+
});
|
|
46994
47159
|
}
|
|
46995
|
-
const summary = summarizePlan(planResult.plan);
|
|
46996
|
-
if (output.json) {
|
|
46997
|
-
emitSuccessJson("create", { dryRun: false, ...summary, lockPath: lockRepo.path, operationId: journal.operationId }, [], [], jsonEvents());
|
|
46998
|
-
} else {
|
|
46999
|
-
printPlanSummary(summary);
|
|
47000
|
-
writeHumanOutput(t("create.createdProject", service.projectRoot) + "\n");
|
|
47001
|
-
writeHumanOutput(t("create.lockFile", lockRepo.path) + "\n");
|
|
47002
|
-
}
|
|
47003
|
-
return ExitCode.Success;
|
|
47004
47160
|
});
|
|
47005
47161
|
}
|
|
47006
47162
|
function formatElapsed(startedAt) {
|
|
@@ -47052,7 +47208,6 @@ var init_create = __esm({
|
|
|
47052
47208
|
init_src2();
|
|
47053
47209
|
init_resolve_helper();
|
|
47054
47210
|
init_journal_helper();
|
|
47055
|
-
init_src2();
|
|
47056
47211
|
init_shared_options();
|
|
47057
47212
|
init_cli_output();
|
|
47058
47213
|
init_service_locator();
|
|
@@ -47984,8 +48139,8 @@ var init_config = __esm({
|
|
|
47984
48139
|
|
|
47985
48140
|
// packages/cli/src/commands/remove.ts
|
|
47986
48141
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
47987
|
-
import { unlink as unlink11, readFile as
|
|
47988
|
-
import { basename as basename6, dirname as dirname18, join as
|
|
48142
|
+
import { unlink as unlink11, readFile as readFile31 } from "node:fs/promises";
|
|
48143
|
+
import { basename as basename6, dirname as dirname18, join as join24, resolve as resolve23 } from "node:path";
|
|
47989
48144
|
function createRemoveCommand(cliVersion) {
|
|
47990
48145
|
const cmd = new Command("remove");
|
|
47991
48146
|
cmd.description(t("remove.description")).option("--package <package-id>", t("remove.optionPackage")).action(async (opts) => {
|
|
@@ -48162,7 +48317,7 @@ async function executeRemove(packageId, options, cliVersion, events) {
|
|
|
48162
48317
|
templateDir = service.projectRoot;
|
|
48163
48318
|
}
|
|
48164
48319
|
try {
|
|
48165
|
-
const manifestContent = await
|
|
48320
|
+
const manifestContent = await readFile31(join24(templateDir, "manifest.yaml"), "utf-8");
|
|
48166
48321
|
const parsed = parseManifest(manifestContent);
|
|
48167
48322
|
if (parsed.manifest) {
|
|
48168
48323
|
packageManifests.push({
|
|
@@ -48735,7 +48890,7 @@ var init_inspect = __esm({
|
|
|
48735
48890
|
// packages/cli/src/commands/doctor.ts
|
|
48736
48891
|
import { execFile as execFile6 } from "node:child_process";
|
|
48737
48892
|
import { createHash as createHash16 } from "node:crypto";
|
|
48738
|
-
import { access as access11, readFile as
|
|
48893
|
+
import { access as access11, readFile as readFile32 } from "node:fs/promises";
|
|
48739
48894
|
import { resolve as resolve25 } from "node:path";
|
|
48740
48895
|
import { promisify as promisify7 } from "node:util";
|
|
48741
48896
|
function createDoctorCommand(cliVersion) {
|
|
@@ -48809,7 +48964,7 @@ async function checkSecretReferences(findings, projectRoot, lock) {
|
|
|
48809
48964
|
const sourcePath = pkg.source.path ?? ".";
|
|
48810
48965
|
const manifestPath = resolve25(projectRoot, sourcePath, "manifest.yaml");
|
|
48811
48966
|
try {
|
|
48812
|
-
const manifestContent = await
|
|
48967
|
+
const manifestContent = await readFile32(manifestPath, "utf-8");
|
|
48813
48968
|
const manifest = parseManifest(manifestContent).manifest;
|
|
48814
48969
|
if (!manifest.capabilities) continue;
|
|
48815
48970
|
for (const cap of manifest.capabilities) {
|
|
@@ -49191,7 +49346,7 @@ async function executeDoctor(projectRoot, repair, drift, yes, online, offline, c
|
|
|
49191
49346
|
});
|
|
49192
49347
|
}
|
|
49193
49348
|
try {
|
|
49194
|
-
const stateLock = JSON.parse(await
|
|
49349
|
+
const stateLock = JSON.parse(await readFile32(`${lockRepo.path}.lock`, "utf8"));
|
|
49195
49350
|
findings.push({ severity: "warning", code: "DOCTOR_TRANSACTION_LOCK", message: `\u53D1\u73B0\u672A\u91CA\u653E\u7684\u72B6\u6001\u9501 (pid=${String(stateLock.pid ?? "unknown")})`, category: "transaction", path: `${lockRepo.path}.lock`, fix: "\u786E\u8BA4\u5BF9\u5E94\u8FDB\u7A0B\u5DF2\u9000\u51FA\u540E\u518D\u6B21\u5199\u5165\uFF0C\u7CFB\u7EDF\u4F1A\u6E05\u7406\u5931\u6548\u9501" });
|
|
49196
49351
|
} catch (error) {
|
|
49197
49352
|
if (error.code !== "ENOENT") findings.push({ severity: "warning", code: "DOCTOR_TRANSACTION_LOCK_INVALID", message: "\u72B6\u6001\u9501\u6587\u4EF6\u65E0\u6CD5\u89E3\u6790", category: "transaction" });
|
|
@@ -49634,8 +49789,8 @@ var init_upgrade = __esm({
|
|
|
49634
49789
|
|
|
49635
49790
|
// packages/cli/src/commands/cache.ts
|
|
49636
49791
|
import { homedir as homedir3 } from "node:os";
|
|
49637
|
-
import { join as
|
|
49638
|
-
import { rm as rm7, stat as
|
|
49792
|
+
import { join as join25, resolve as resolve26 } from "node:path";
|
|
49793
|
+
import { rm as rm7, stat as stat8 } from "node:fs/promises";
|
|
49639
49794
|
function createCacheCommand(cliVersion) {
|
|
49640
49795
|
const cmd = new Command("cache");
|
|
49641
49796
|
cmd.description(t("cache.description"));
|
|
@@ -49676,7 +49831,7 @@ function createCacheCommand(cliVersion) {
|
|
|
49676
49831
|
return cmd;
|
|
49677
49832
|
}
|
|
49678
49833
|
function getUserDataDir() {
|
|
49679
|
-
return process.env["MANO_USER_DATA"] ?? process.env["AICODING_USER_DATA"] ??
|
|
49834
|
+
return process.env["MANO_USER_DATA"] ?? process.env["AICODING_USER_DATA"] ?? join25(homedir3(), ".mano-coding");
|
|
49680
49835
|
}
|
|
49681
49836
|
function parsePositiveInt(value, name) {
|
|
49682
49837
|
if (value === void 0) return void 0;
|
|
@@ -49821,7 +49976,7 @@ async function executeGc(opts, cliVersion) {
|
|
|
49821
49976
|
continue;
|
|
49822
49977
|
}
|
|
49823
49978
|
try {
|
|
49824
|
-
const stats = await
|
|
49979
|
+
const stats = await stat8(rootPath);
|
|
49825
49980
|
if (!stats.isDirectory()) {
|
|
49826
49981
|
failedRoots.push(`${rootPath} (${t("cache.notDirectory")})`);
|
|
49827
49982
|
continue;
|
|
@@ -49878,8 +50033,8 @@ async function executeClean(opts, cliVersion) {
|
|
|
49878
50033
|
throw new CliError(t("cache.cleanRequiresYes"), ExitCode.NeedsInputOrDenied, "NEEDS_CONFIRMATION");
|
|
49879
50034
|
}
|
|
49880
50035
|
if (cleanRegistry && !dryRun) await updateCache.clear();
|
|
49881
|
-
if (cleanAudit && !dryRun) await rm7(
|
|
49882
|
-
if (!dryRun) await rm7(
|
|
50036
|
+
if (cleanAudit && !dryRun) await rm7(join25(userDataDir, "audit"), { recursive: true, force: true });
|
|
50037
|
+
if (!dryRun) await rm7(join25(userDataDir, "cache"), { recursive: true, force: true });
|
|
49883
50038
|
if (json) {
|
|
49884
50039
|
emitSuccessJson("cache clean", { dryRun, cleanedLeases: 0, clearedUpdateCache: cleanRegistry, clearedAudit: cleanAudit, message: t("cache.noInstallationsClean") });
|
|
49885
50040
|
} else {
|
|
@@ -49894,8 +50049,8 @@ async function executeClean(opts, cliVersion) {
|
|
|
49894
50049
|
throw new CliError(t("cache.cleanRequiresYes"), ExitCode.NeedsInputOrDenied, "NEEDS_CONFIRMATION");
|
|
49895
50050
|
}
|
|
49896
50051
|
if (cleanRegistry && !dryRun) await updateCache.clear();
|
|
49897
|
-
if (cleanAudit && !dryRun) await rm7(
|
|
49898
|
-
if (!dryRun) await rm7(
|
|
50052
|
+
if (cleanAudit && !dryRun) await rm7(join25(userDataDir, "audit"), { recursive: true, force: true });
|
|
50053
|
+
if (!dryRun) await rm7(join25(userDataDir, "cache"), { recursive: true, force: true });
|
|
49899
50054
|
if (json) {
|
|
49900
50055
|
emitSuccessJson("cache clean", { dryRun, cleanedLeases: 0, clearedUpdateCache: cleanRegistry, clearedAudit: cleanAudit, message: t("cache.noInstallationsClean") });
|
|
49901
50056
|
} else {
|
|
@@ -49940,8 +50095,8 @@ async function executeClean(opts, cliVersion) {
|
|
|
49940
50095
|
totalCleaned += cleaned;
|
|
49941
50096
|
}
|
|
49942
50097
|
if (cleanRegistry && !dryRun) await updateCache.clear();
|
|
49943
|
-
if (cleanAudit && !dryRun) await rm7(
|
|
49944
|
-
if (!dryRun) await rm7(
|
|
50098
|
+
if (cleanAudit && !dryRun) await rm7(join25(userDataDir, "audit"), { recursive: true, force: true });
|
|
50099
|
+
if (!dryRun) await rm7(join25(userDataDir, "cache"), { recursive: true, force: true });
|
|
49945
50100
|
if (json) {
|
|
49946
50101
|
emitSuccessJson("cache clean", { dryRun: false, cleanedLeases: totalCleaned, clearedUpdateCache: cleanRegistry, clearedAudit: cleanAudit });
|
|
49947
50102
|
} else {
|
|
@@ -49963,7 +50118,7 @@ var init_cache = __esm({
|
|
|
49963
50118
|
// packages/cli/src/commands/launch.ts
|
|
49964
50119
|
import { spawn as spawn2 } from "node:child_process";
|
|
49965
50120
|
import { homedir as homedir4 } from "node:os";
|
|
49966
|
-
import { join as
|
|
50121
|
+
import { join as join26 } from "node:path";
|
|
49967
50122
|
function createLaunchCommand() {
|
|
49968
50123
|
const cmd = new Command("_launch");
|
|
49969
50124
|
cmd.description(t("launch.description")).option("--kind <kind>", t("launch.optionKind")).option("--package <package-id>", t("launch.optionPackage")).option("--id <id>", t("launch.optionId")).option("--version <version>", t("launch.optionVersion")).option("--command <name>", t("launch.optionCommand")).allowUnknownOption(true).allowExcessArguments(true).action(async (_opts, command) => {
|
|
@@ -49996,7 +50151,7 @@ function createLaunchCommand() {
|
|
|
49996
50151
|
return cmd;
|
|
49997
50152
|
}
|
|
49998
50153
|
function getUserDataDir2() {
|
|
49999
|
-
return process.env["AICODING_USER_DATA"] ??
|
|
50154
|
+
return process.env["AICODING_USER_DATA"] ?? join26(homedir4(), ".aicoding");
|
|
50000
50155
|
}
|
|
50001
50156
|
async function executeLaunch(launcherArgs) {
|
|
50002
50157
|
const userDataDir = getUserDataDir2();
|
|
@@ -50047,9 +50202,9 @@ var init_launch = __esm({
|
|
|
50047
50202
|
|
|
50048
50203
|
// packages/cli/src/commands/self-upgrade.ts
|
|
50049
50204
|
import { spawn as spawn3 } from "node:child_process";
|
|
50050
|
-
import { readFile as
|
|
50205
|
+
import { readFile as readFile33, realpath as realpath2 } from "node:fs/promises";
|
|
50051
50206
|
import { homedir as homedir5 } from "node:os";
|
|
50052
|
-
import { extname, join as
|
|
50207
|
+
import { extname, join as join27, resolve as resolve27 } from "node:path";
|
|
50053
50208
|
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
50054
50209
|
import { stdin, stderr } from "node:process";
|
|
50055
50210
|
function createSelfUpgradeCommand(cliVersion) {
|
|
@@ -50111,7 +50266,7 @@ async function executeSelfUpgrade(options, cliVersion) {
|
|
|
50111
50266
|
});
|
|
50112
50267
|
await auditLog.prune().catch(() => void 0);
|
|
50113
50268
|
try {
|
|
50114
|
-
const result = await withStateLock(
|
|
50269
|
+
const result = await withStateLock(join27(userDataDir, "cli-update"), async () => {
|
|
50115
50270
|
const target = await resolveTarget(options, cacheRepository, registry);
|
|
50116
50271
|
ensureTargetAllowed(target.version, installation.currentVersion, options.allowDowngrade);
|
|
50117
50272
|
if (!isCliVersionCompatible(process.version, target.enginesNode)) {
|
|
@@ -50163,7 +50318,7 @@ function validateOptions(options) {
|
|
|
50163
50318
|
}
|
|
50164
50319
|
}
|
|
50165
50320
|
function getUserDataDir3() {
|
|
50166
|
-
return process.env["AICODING_USER_DATA"] ??
|
|
50321
|
+
return process.env["AICODING_USER_DATA"] ?? join27(homedir5(), ".aicoding");
|
|
50167
50322
|
}
|
|
50168
50323
|
function getRegistryUrl() {
|
|
50169
50324
|
const raw = process.env["AICODING_NPM_REGISTRY"] || DEFAULT_NPM_REGISTRY;
|
|
@@ -50276,13 +50431,13 @@ async function detectGlobalCliInstallation(cliPath = process.argv[1], runner = r
|
|
|
50276
50431
|
}
|
|
50277
50432
|
async function isWindowsCmdShimFor(shimPath, expectedBin) {
|
|
50278
50433
|
if (process.platform !== "win32" || extname(shimPath).toLowerCase() !== ".cmd") return false;
|
|
50279
|
-
const shim = await
|
|
50434
|
+
const shim = await readFile33(shimPath, "utf8").catch(() => void 0);
|
|
50280
50435
|
if (!shim) return false;
|
|
50281
50436
|
return shim.replaceAll("/", "\\").toLowerCase().includes(expectedBin.replaceAll("/", "\\").toLowerCase());
|
|
50282
50437
|
}
|
|
50283
50438
|
async function readPackageJson(root) {
|
|
50284
50439
|
try {
|
|
50285
|
-
const value = JSON.parse(await
|
|
50440
|
+
const value = JSON.parse(await readFile33(join27(root, "package.json"), "utf8"));
|
|
50286
50441
|
if (!value || typeof value !== "object") return void 0;
|
|
50287
50442
|
const item = value;
|
|
50288
50443
|
return typeof item["name"] === "string" && typeof item["version"] === "string" ? { name: item["name"], version: item["version"], bin: item["bin"] } : void 0;
|
|
@@ -50347,11 +50502,11 @@ var init_self_upgrade = __esm({
|
|
|
50347
50502
|
|
|
50348
50503
|
// packages/cli/src/commands/update-notice.ts
|
|
50349
50504
|
import { homedir as homedir6 } from "node:os";
|
|
50350
|
-
import { join as
|
|
50505
|
+
import { join as join28 } from "node:path";
|
|
50351
50506
|
async function getCachedUpdateNotice(argv, currentVersion) {
|
|
50352
50507
|
const json = argv.includes("--json");
|
|
50353
50508
|
const disabled = argv.includes("--offline") || argv[2] === "self-upgrade" || Boolean(process.env["AICODING_NO_UPDATE_CHECK"]) || Boolean(process.env["CI"]);
|
|
50354
|
-
const repository = new CliUpdateCacheRepository(process.env["AICODING_USER_DATA"] ??
|
|
50509
|
+
const repository = new CliUpdateCacheRepository(process.env["AICODING_USER_DATA"] ?? join28(homedir6(), ".aicoding"));
|
|
50355
50510
|
if (disabled || !json && !process.stdout.isTTY) return { json, markNotified: async () => void 0 };
|
|
50356
50511
|
const cache = await repository.read();
|
|
50357
50512
|
const notifiedAt = cache?.lastNotifiedAt ? Date.parse(cache.lastNotifiedAt) : Number.NaN;
|
|
@@ -50383,7 +50538,7 @@ import { createRequire as createRequire2 } from "node:module";
|
|
|
50383
50538
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
50384
50539
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
50385
50540
|
function resolveVersion() {
|
|
50386
|
-
if (true) return "0.1.
|
|
50541
|
+
if (true) return "0.1.31";
|
|
50387
50542
|
const candidates = [
|
|
50388
50543
|
new URL("../package.json", import.meta.url),
|
|
50389
50544
|
new URL("../../package.json", import.meta.url),
|