@hcmai/cli 0.3.9 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +138 -44
- package/dist/index.js.map +1 -1
- package/dist/skills/hcm-delivery-triage/SKILL.md +100 -0
- package/dist/skills/llms.txt +1 -0
- package/dist/skills/manifest.json +31 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -523,8 +523,8 @@ var init_TerminalRenderer = __esm({
|
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
525
|
/** 来源行(仅子代理触发,agentPath ≥2 段时显示 `↑ 来自 a › b`,对齐 Web)。 */
|
|
526
|
-
originLine(
|
|
527
|
-
const segs =
|
|
526
|
+
originLine(path11) {
|
|
527
|
+
const segs = path11.split(".").filter(Boolean);
|
|
528
528
|
if (segs.length < 2) return "";
|
|
529
529
|
const names = segs.map((k) => agentDisplayName(k));
|
|
530
530
|
return chalk.gray(` \u2191 \u6765\u81EA ${names.join(" \u203A ")}`) + "\n";
|
|
@@ -1706,8 +1706,8 @@ function agentLabel(agentId) {
|
|
|
1706
1706
|
if (/^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(agentId)) return `agent \u2026${agentId.slice(-4)}`;
|
|
1707
1707
|
return agentDisplayName(agentId);
|
|
1708
1708
|
}
|
|
1709
|
-
function originLine(
|
|
1710
|
-
const segs = (
|
|
1709
|
+
function originLine(path11) {
|
|
1710
|
+
const segs = (path11 ?? "").split(".").filter(Boolean);
|
|
1711
1711
|
if (segs.length < 2) return null;
|
|
1712
1712
|
return `\u6765\u81EA ${segs.map((k) => agentDisplayName(k)).join(" \u203A ")}`;
|
|
1713
1713
|
}
|
|
@@ -3059,8 +3059,8 @@ import {
|
|
|
3059
3059
|
formatObject as formatObject7,
|
|
3060
3060
|
fromAxiosError as fromAxiosError8
|
|
3061
3061
|
} from "@hcmai/sdk";
|
|
3062
|
-
function collectYmlFiles(
|
|
3063
|
-
if (statSync(
|
|
3062
|
+
function collectYmlFiles(path11) {
|
|
3063
|
+
if (statSync(path11).isFile()) return [path11];
|
|
3064
3064
|
const out = [];
|
|
3065
3065
|
const walk = (dir) => {
|
|
3066
3066
|
for (const name of readdirSync(dir).sort()) {
|
|
@@ -3069,7 +3069,7 @@ function collectYmlFiles(path10) {
|
|
|
3069
3069
|
else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
|
|
3070
3070
|
}
|
|
3071
3071
|
};
|
|
3072
|
-
walk(
|
|
3072
|
+
walk(path11);
|
|
3073
3073
|
return out.sort();
|
|
3074
3074
|
}
|
|
3075
3075
|
var DRY_RUN_CLIENT = {
|
|
@@ -3077,9 +3077,9 @@ var DRY_RUN_CLIENT = {
|
|
|
3077
3077
|
create: async () => ({ id: "" }),
|
|
3078
3078
|
update: async () => ({})
|
|
3079
3079
|
};
|
|
3080
|
-
async function importCommand(
|
|
3080
|
+
async function importCommand(path11, args) {
|
|
3081
3081
|
try {
|
|
3082
|
-
const files = collectYmlFiles(
|
|
3082
|
+
const files = collectYmlFiles(path11);
|
|
3083
3083
|
const fixtures = files.map(
|
|
3084
3084
|
(f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
|
|
3085
3085
|
);
|
|
@@ -6729,17 +6729,17 @@ async function metaListCommand(args) {
|
|
|
6729
6729
|
fail4(e, args);
|
|
6730
6730
|
}
|
|
6731
6731
|
}
|
|
6732
|
-
async function metaGetCommand(
|
|
6732
|
+
async function metaGetCommand(path11, args) {
|
|
6733
6733
|
try {
|
|
6734
6734
|
const c = await client2(args);
|
|
6735
|
-
const content = await getTenantMeta(c.raw(),
|
|
6735
|
+
const content = await getTenantMeta(c.raw(), path11);
|
|
6736
6736
|
process.stdout.write(content.endsWith("\n") ? content : content + "\n");
|
|
6737
6737
|
process.exit(0);
|
|
6738
6738
|
} catch (e) {
|
|
6739
6739
|
fail4(e, args);
|
|
6740
6740
|
}
|
|
6741
6741
|
}
|
|
6742
|
-
async function metaSetCommand(
|
|
6742
|
+
async function metaSetCommand(path11, args) {
|
|
6743
6743
|
try {
|
|
6744
6744
|
if (!args.file) {
|
|
6745
6745
|
throw new CliError20({
|
|
@@ -6756,7 +6756,7 @@ async function metaSetCommand(path10, args) {
|
|
|
6756
6756
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
6757
6757
|
if (args.dryRun) {
|
|
6758
6758
|
process.stdout.write(
|
|
6759
|
-
`[dry-run] \u5C06\u5199\u5165 ${
|
|
6759
|
+
`[dry-run] \u5C06\u5199\u5165 ${path11}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
|
|
6760
6760
|
---
|
|
6761
6761
|
${content}
|
|
6762
6762
|
`
|
|
@@ -6764,10 +6764,10 @@ ${content}
|
|
|
6764
6764
|
process.exit(0);
|
|
6765
6765
|
}
|
|
6766
6766
|
const c = await client2(args);
|
|
6767
|
-
const result2 = await saveTenantMeta(c.raw(),
|
|
6767
|
+
const result2 = await saveTenantMeta(c.raw(), path11, content);
|
|
6768
6768
|
const fmt = args.output ?? "json";
|
|
6769
6769
|
if (fmt !== "json") {
|
|
6770
|
-
process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${
|
|
6770
|
+
process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path11}
|
|
6771
6771
|
\u8BB0\u5F97\u6E05\u7F13\u5B58\uFF1Ahcm cache clear-meta <Model>
|
|
6772
6772
|
`);
|
|
6773
6773
|
}
|
|
@@ -6778,19 +6778,19 @@ ${content}
|
|
|
6778
6778
|
fail4(e, args);
|
|
6779
6779
|
}
|
|
6780
6780
|
}
|
|
6781
|
-
async function metaDeleteCommand(
|
|
6781
|
+
async function metaDeleteCommand(path11, args) {
|
|
6782
6782
|
try {
|
|
6783
6783
|
if (!args.yes) {
|
|
6784
|
-
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${
|
|
6784
|
+
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path11}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
|
|
6785
6785
|
if (!ok) {
|
|
6786
6786
|
process.stderr.write("\u5DF2\u53D6\u6D88\n");
|
|
6787
6787
|
process.exit(1);
|
|
6788
6788
|
}
|
|
6789
6789
|
}
|
|
6790
6790
|
const c = await client2(args);
|
|
6791
|
-
const result2 = await deleteTenantMeta(c.raw(),
|
|
6791
|
+
const result2 = await deleteTenantMeta(c.raw(), path11);
|
|
6792
6792
|
const fmt = args.output ?? "json";
|
|
6793
|
-
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${
|
|
6793
|
+
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path11}
|
|
6794
6794
|
`);
|
|
6795
6795
|
process.stdout.write(formatObject16(result2, { format: fmt }) + "\n");
|
|
6796
6796
|
process.exit(0);
|
|
@@ -8734,16 +8734,16 @@ async function deliveryGate0Command(args) {
|
|
|
8734
8734
|
const { aclass, problems: aclassProblems } = deriveAclass(reconDir, args.mapping ?? null);
|
|
8735
8735
|
const { facts, problems: factsProblems } = loadProtocolFacts();
|
|
8736
8736
|
const result2 = scan(skillRoot, aclass, facts, { aclassProblems, factsProblems });
|
|
8737
|
-
const
|
|
8737
|
+
const premise2 = checkPremise([
|
|
8738
8738
|
...result2.premise,
|
|
8739
8739
|
...baselineRoundPremise(inspectRound2(reconDir))
|
|
8740
8740
|
]);
|
|
8741
|
-
const merged = { ...result2, premise };
|
|
8741
|
+
const merged = { ...result2, premise: premise2 };
|
|
8742
8742
|
const fmt = args.output ?? "json";
|
|
8743
8743
|
if (fmt !== "json") process.stdout.write(renderGate0(merged, skillRoot));
|
|
8744
8744
|
process.stdout.write(`${formatObject21(merged, { format: fmt })}
|
|
8745
8745
|
`);
|
|
8746
|
-
for (const problem of
|
|
8746
|
+
for (const problem of premise2) {
|
|
8747
8747
|
process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF08${problem.reason}\uFF09\uFF1A${problem.message}
|
|
8748
8748
|
`);
|
|
8749
8749
|
}
|
|
@@ -8755,11 +8755,96 @@ async function deliveryGate0Command(args) {
|
|
|
8755
8755
|
process.exit(code);
|
|
8756
8756
|
}
|
|
8757
8757
|
|
|
8758
|
+
// src/commands/delivery-triage.ts
|
|
8759
|
+
init_auth_guard();
|
|
8760
|
+
init_exit();
|
|
8761
|
+
import {
|
|
8762
|
+
computeReconSourceKey as computeReconSourceKey2,
|
|
8763
|
+
HcmClient as HcmClient20,
|
|
8764
|
+
httpProbe as httpProbe3,
|
|
8765
|
+
ReconLayout as ReconLayout2,
|
|
8766
|
+
runTriageRound
|
|
8767
|
+
} from "@hcmai/sdk";
|
|
8768
|
+
import { mkdirSync, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
|
|
8769
|
+
import * as path9 from "path";
|
|
8770
|
+
var DEFAULT_CAPABILITIES3 = "default";
|
|
8771
|
+
function premise(message, hint) {
|
|
8772
|
+
process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
|
|
8773
|
+
`);
|
|
8774
|
+
process.stderr.write(` ${hint}
|
|
8775
|
+
`);
|
|
8776
|
+
return 1;
|
|
8777
|
+
}
|
|
8778
|
+
var REQUESTS_SHAPE = "`--requests` \u6536\u7684\u662F\u4E00\u4E2A JSON \u6570\u7EC4\uFF0C\u6BCF\u6761\u81F3\u5C11\u8981\u6709 `request` / `verdict` / `evidence` \u4E09\u683C\u3002\u516D\u683C\u6838\u67E5\u8868\u7531\u672C\u547D\u4EE4\u81EA\u5DF1\u586B\uFF0C\u522B\u624B\u5199\u3002";
|
|
8779
|
+
function readRequests(file) {
|
|
8780
|
+
let raw;
|
|
8781
|
+
try {
|
|
8782
|
+
raw = JSON.parse(readFileSync4(file, "utf8"));
|
|
8783
|
+
} catch (e) {
|
|
8784
|
+
throw new Error(`\u9700\u6C42\u6E05\u5355\u8BFB\u4E0D\u51FA\u6765\uFF08${file}\uFF09\uFF1A${e instanceof Error ? e.message : String(e)}`);
|
|
8785
|
+
}
|
|
8786
|
+
if (!Array.isArray(raw)) {
|
|
8787
|
+
throw new Error(`\u9700\u6C42\u6E05\u5355\u4E0D\u662F\u4E00\u4E2A JSON \u6570\u7EC4\uFF08${file}\uFF09\uFF0C\u5B9E\u9645\u662F ${typeof raw}`);
|
|
8788
|
+
}
|
|
8789
|
+
raw.forEach((row, i) => {
|
|
8790
|
+
if (!row || typeof row !== "object" || Array.isArray(row)) {
|
|
8791
|
+
throw new Error(`\u9700\u6C42\u6E05\u5355\u7B2C ${i + 1} \u6761\u4E0D\u662F\u4E00\u4E2A JSON \u5BF9\u8C61\uFF0C\u800C\u662F ${typeof row}`);
|
|
8792
|
+
}
|
|
8793
|
+
});
|
|
8794
|
+
return raw;
|
|
8795
|
+
}
|
|
8796
|
+
function renderProblems(rows) {
|
|
8797
|
+
const lines = ["\u5206\u8BCA\u7ED3\u8BBA\u4E0E\u8BC1\u636E\u6253\u67B6\uFF0C\u8FD9\u4EFD\u4EA7\u51FA\u6CA1\u6709\u843D\u76D8\uFF1A"];
|
|
8798
|
+
for (const row of rows) {
|
|
8799
|
+
lines.push(` [${row.idx}] ${row.request.slice(0, 30)} \xB7 ${row.rule}\uFF1A${row.note}`);
|
|
8800
|
+
}
|
|
8801
|
+
return `${lines.join("\n")}
|
|
8802
|
+
`;
|
|
8803
|
+
}
|
|
8804
|
+
function writeTriageArtifact(outDir, body) {
|
|
8805
|
+
const out = path9.join(outDir, "work", "triage.md");
|
|
8806
|
+
mkdirSync(path9.dirname(out), { recursive: true });
|
|
8807
|
+
writeFileSync2(out, body, "utf8");
|
|
8808
|
+
return out;
|
|
8809
|
+
}
|
|
8810
|
+
async function runTriage(args) {
|
|
8811
|
+
if (!args.requests) return premise("\u6CA1\u7ED9 `--requests`", REQUESTS_SHAPE);
|
|
8812
|
+
let entriesIn;
|
|
8813
|
+
try {
|
|
8814
|
+
entriesIn = readRequests(args.requests);
|
|
8815
|
+
} catch (e) {
|
|
8816
|
+
return premise(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
|
|
8817
|
+
}
|
|
8818
|
+
const ctx = await getActiveAuthContextFromCli(args);
|
|
8819
|
+
const client3 = HcmClient20.fromAuthContext(ctx);
|
|
8820
|
+
const probe = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
|
|
8821
|
+
const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
|
|
8822
|
+
const result2 = await runTriageRound(probe, artifactsDir, entriesIn);
|
|
8823
|
+
if (result2.body === null) {
|
|
8824
|
+
process.stdout.write(renderProblems(result2.problems));
|
|
8825
|
+
return 1;
|
|
8826
|
+
}
|
|
8827
|
+
const out = writeTriageArtifact(args.out ?? ".", result2.body);
|
|
8828
|
+
process.stdout.write(`\u5206\u8BCA\u81EA\u6D3D\uFF0C\u5DF2\u5199 ${out}\uFF08${result2.entries.length} \u6761\uFF09
|
|
8829
|
+
`);
|
|
8830
|
+
return 0;
|
|
8831
|
+
}
|
|
8832
|
+
async function deliveryTriageCommand(args) {
|
|
8833
|
+
let code;
|
|
8834
|
+
try {
|
|
8835
|
+
code = await runTriage(args);
|
|
8836
|
+
} catch (e) {
|
|
8837
|
+
exitWithError(e);
|
|
8838
|
+
code = 1;
|
|
8839
|
+
}
|
|
8840
|
+
process.exit(code);
|
|
8841
|
+
}
|
|
8842
|
+
|
|
8758
8843
|
// src/commands/delivery-execution.ts
|
|
8759
8844
|
import { createHash as createHash7, randomBytes as secureRandomBytes } from "crypto";
|
|
8760
8845
|
import { spawn } from "child_process";
|
|
8761
8846
|
import { createReadStream as createReadStream2, promises as fs8 } from "fs";
|
|
8762
|
-
import
|
|
8847
|
+
import path10 from "path";
|
|
8763
8848
|
import { CliError as CliError22, CliErrorCode as CliErrorCode21, formatObject as formatObject22 } from "@hcmai/sdk";
|
|
8764
8849
|
init_exit();
|
|
8765
8850
|
var EXECUTION_CONTRACT_VERSION = "2026-08-29.controlled-v2";
|
|
@@ -8800,9 +8885,9 @@ async function prepareDeliveryExecution(input) {
|
|
|
8800
8885
|
};
|
|
8801
8886
|
const planId = sha2567(canonicalJson(core)).slice(0, 24);
|
|
8802
8887
|
const plan = { ...core, planId };
|
|
8803
|
-
const plansDir =
|
|
8888
|
+
const plansDir = path10.join(project, ".hcm-delivery", "execution-plans");
|
|
8804
8889
|
await safeManagedDirectory(project, ".hcm-delivery/execution-plans", plansDir);
|
|
8805
|
-
const planFile =
|
|
8890
|
+
const planFile = path10.join(plansDir, `${planId}.json`);
|
|
8806
8891
|
try {
|
|
8807
8892
|
await fs8.writeFile(planFile, `${JSON.stringify(plan, null, 2)}
|
|
8808
8893
|
`, {
|
|
@@ -8821,7 +8906,7 @@ async function executeDeliveryPlan(input) {
|
|
|
8821
8906
|
if (await readProjectMode(project) !== "controlled") {
|
|
8822
8907
|
throw invalid4("\u9879\u76EE\u4E0D\u662F controlled\uFF0C\u4E0D\u80FD\u6267\u884C R2 \u8BA1\u5212");
|
|
8823
8908
|
}
|
|
8824
|
-
const planFile =
|
|
8909
|
+
const planFile = path10.join(project, ".hcm-delivery", "execution-plans", `${input.planId}.json`);
|
|
8825
8910
|
const plan = await readPlan(project, planFile);
|
|
8826
8911
|
if (plan.planId !== input.planId || computePlanId(plan) !== input.planId) {
|
|
8827
8912
|
throw invalid4("\u6267\u884C\u8BA1\u5212\u5185\u5BB9\u4E0E planId \u6458\u8981\u4E0D\u4E00\u81F4");
|
|
@@ -8853,11 +8938,11 @@ async function executeDeliveryPlan(input) {
|
|
|
8853
8938
|
await assertDocumentUnchanged(project, plan.documents.rollback, "\u56DE\u6EDA\u8BF4\u660E");
|
|
8854
8939
|
await assertPayloadsUnchanged(project, plan.payloads);
|
|
8855
8940
|
const evidenceDir = await bindEvidenceDirectory(project, plan.evidenceDir);
|
|
8856
|
-
const receiptFile =
|
|
8941
|
+
const receiptFile = path10.join(evidenceDir.absolute, `${plan.planId}.receipt.json`);
|
|
8857
8942
|
if (await pathExists(receiptFile)) throw invalid4(`\u6267\u884C\u6536\u636E\u5DF2\u5B58\u5728\uFF0C\u62D2\u7EDD\u518D\u6B21\u6267\u884C\uFF1A${plan.planId}`);
|
|
8858
|
-
const claimsDir =
|
|
8943
|
+
const claimsDir = path10.join(project, ".hcm-delivery", "execution-claims");
|
|
8859
8944
|
await safeManagedDirectory(project, ".hcm-delivery/execution-claims", claimsDir);
|
|
8860
|
-
const claimFile =
|
|
8945
|
+
const claimFile = path10.join(claimsDir, `${plan.planId}.json`);
|
|
8861
8946
|
try {
|
|
8862
8947
|
await fs8.writeFile(
|
|
8863
8948
|
claimFile,
|
|
@@ -8935,7 +9020,7 @@ async function deliveryExecuteCommand(planId, argv, args) {
|
|
|
8935
9020
|
}
|
|
8936
9021
|
}
|
|
8937
9022
|
async function readProjectMode(project) {
|
|
8938
|
-
const file =
|
|
9023
|
+
const file = path10.join(project, ".hcm-delivery", "project.yml");
|
|
8939
9024
|
const content = await readSafeFile(project, file, "\u9879\u76EE\u914D\u7F6E");
|
|
8940
9025
|
const match = content.toString("utf8").match(
|
|
8941
9026
|
/^deliveryMode:\s*(?:"(plan-only|controlled)"|'(plan-only|controlled)'|(plan-only|controlled))\s*$/m
|
|
@@ -8947,7 +9032,7 @@ async function readProjectMode(project) {
|
|
|
8947
9032
|
return mode;
|
|
8948
9033
|
}
|
|
8949
9034
|
async function readChironLock(project) {
|
|
8950
|
-
const file =
|
|
9035
|
+
const file = path10.join(project, ".hcm-delivery", "chiron.lock.json");
|
|
8951
9036
|
const bytes = await readSafeFile(project, file, "Chiron \u9501");
|
|
8952
9037
|
let parsed;
|
|
8953
9038
|
try {
|
|
@@ -8964,7 +9049,7 @@ async function bindDocument(project, reference, label) {
|
|
|
8964
9049
|
if (!(relative2.startsWith("work/") || relative2.startsWith("decisions/"))) {
|
|
8965
9050
|
throw invalid4(`${label}\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE work/ \u6216 decisions/ \u4E0B`);
|
|
8966
9051
|
}
|
|
8967
|
-
const file =
|
|
9052
|
+
const file = path10.join(project, relative2);
|
|
8968
9053
|
const bytes = await readSafeFile(project, file, label);
|
|
8969
9054
|
return { path: relative2, sha256: sha2567(bytes) };
|
|
8970
9055
|
}
|
|
@@ -8977,7 +9062,7 @@ async function bindEvidenceDirectory(project, reference) {
|
|
|
8977
9062
|
if (!(relative2 === "evidence" || relative2.startsWith("evidence/"))) {
|
|
8978
9063
|
throw invalid4("evidence \u76EE\u5F55\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE evidence/ \u4E0B");
|
|
8979
9064
|
}
|
|
8980
|
-
const absolute =
|
|
9065
|
+
const absolute = path10.join(project, relative2);
|
|
8981
9066
|
await assertNoSymlinkComponents(project, relative2);
|
|
8982
9067
|
const stat = await fs8.stat(absolute).catch((cause) => {
|
|
8983
9068
|
throw invalid4(`evidence \u76EE\u5F55\u4E0D\u53EF\u7528\uFF1A${relative2}`, cause);
|
|
@@ -9098,7 +9183,7 @@ async function bindPayloadFiles(project, argv) {
|
|
|
9098
9183
|
}
|
|
9099
9184
|
async function bindPayloadFile(project, reference, label) {
|
|
9100
9185
|
const relative2 = safeRelative(reference, label);
|
|
9101
|
-
const file =
|
|
9186
|
+
const file = path10.join(project, relative2);
|
|
9102
9187
|
const bytes = await readSafeFile(project, file, label);
|
|
9103
9188
|
return { path: relative2, sha256: sha2567(bytes) };
|
|
9104
9189
|
}
|
|
@@ -9172,13 +9257,13 @@ async function writeReceiptExclusive(target, receipt) {
|
|
|
9172
9257
|
});
|
|
9173
9258
|
await fs8.link(temp, target);
|
|
9174
9259
|
} catch (cause) {
|
|
9175
|
-
throw invalid4(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${
|
|
9260
|
+
throw invalid4(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${path10.basename(target)}`, cause);
|
|
9176
9261
|
} finally {
|
|
9177
9262
|
await fs8.unlink(temp).catch(() => void 0);
|
|
9178
9263
|
}
|
|
9179
9264
|
}
|
|
9180
9265
|
async function safeManagedDirectory(project, relative2, absolute) {
|
|
9181
|
-
await assertNoSymlinkComponents(project,
|
|
9266
|
+
await assertNoSymlinkComponents(project, path10.dirname(relative2));
|
|
9182
9267
|
const existing = await fs8.lstat(absolute).catch(() => void 0);
|
|
9183
9268
|
if (existing?.isSymbolicLink()) throw invalid4(`\u53D7\u7BA1\u76EE\u5F55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
|
|
9184
9269
|
if (existing && !existing.isDirectory()) throw invalid4(`\u53D7\u7BA1\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${relative2}`);
|
|
@@ -9195,8 +9280,8 @@ async function pathExists(file) {
|
|
|
9195
9280
|
);
|
|
9196
9281
|
}
|
|
9197
9282
|
async function readSafeFile(project, file, label) {
|
|
9198
|
-
const relative2 =
|
|
9199
|
-
if (relative2.startsWith("../") ||
|
|
9283
|
+
const relative2 = path10.relative(project, file).split(path10.sep).join("/");
|
|
9284
|
+
if (relative2.startsWith("../") || path10.isAbsolute(relative2))
|
|
9200
9285
|
throw invalid4(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
|
|
9201
9286
|
await assertNoSymlinkComponents(project, relative2);
|
|
9202
9287
|
let stat;
|
|
@@ -9213,14 +9298,14 @@ async function assertNoSymlinkComponents(project, relative2) {
|
|
|
9213
9298
|
const parts = relative2.split("/").filter(Boolean);
|
|
9214
9299
|
let current = project;
|
|
9215
9300
|
for (const part of parts) {
|
|
9216
|
-
current =
|
|
9301
|
+
current = path10.join(current, part);
|
|
9217
9302
|
const stat = await fs8.lstat(current).catch(() => void 0);
|
|
9218
9303
|
if (stat?.isSymbolicLink()) throw invalid4(`\u8DEF\u5F84\u5305\u542B\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
|
|
9219
9304
|
if (!stat) break;
|
|
9220
9305
|
}
|
|
9221
9306
|
}
|
|
9222
9307
|
async function realProject(requested) {
|
|
9223
|
-
const absolute =
|
|
9308
|
+
const absolute = path10.resolve(requested);
|
|
9224
9309
|
let project;
|
|
9225
9310
|
try {
|
|
9226
9311
|
project = await fs8.realpath(absolute);
|
|
@@ -9232,10 +9317,10 @@ async function realProject(requested) {
|
|
|
9232
9317
|
return project;
|
|
9233
9318
|
}
|
|
9234
9319
|
function safeRelative(reference, label) {
|
|
9235
|
-
if (!reference ||
|
|
9320
|
+
if (!reference || path10.isAbsolute(reference) || /[\r\n\0]/.test(reference)) {
|
|
9236
9321
|
throw invalid4(`${label}\u5FC5\u987B\u662F\u9879\u76EE\u5185\u76F8\u5BF9\u8DEF\u5F84`);
|
|
9237
9322
|
}
|
|
9238
|
-
const normalized =
|
|
9323
|
+
const normalized = path10.normalize(reference).split(path10.sep).join("/");
|
|
9239
9324
|
if (normalized === ".." || normalized.startsWith("../") || normalized === ".") {
|
|
9240
9325
|
throw invalid4(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
|
|
9241
9326
|
}
|
|
@@ -9292,7 +9377,7 @@ function invalid4(message, cause) {
|
|
|
9292
9377
|
init_auth_guard();
|
|
9293
9378
|
init_exit();
|
|
9294
9379
|
import {
|
|
9295
|
-
HcmClient as
|
|
9380
|
+
HcmClient as HcmClient21,
|
|
9296
9381
|
adminResetPassword,
|
|
9297
9382
|
formatObject as formatObject23,
|
|
9298
9383
|
fromAxiosError as fromAxiosError19,
|
|
@@ -9326,7 +9411,7 @@ async function userResetPasswordCommand(args) {
|
|
|
9326
9411
|
try {
|
|
9327
9412
|
const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
|
|
9328
9413
|
const request = buildAdminResetPasswordRequest(args, password);
|
|
9329
|
-
const client3 =
|
|
9414
|
+
const client3 = HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
9330
9415
|
const result2 = await adminResetPassword(client3.raw(), request);
|
|
9331
9416
|
process.stdout.write(formatObject23(result2, { format: args.output ?? "json" }) + "\n");
|
|
9332
9417
|
} catch (cause) {
|
|
@@ -9402,6 +9487,15 @@ delivery.command("gate0").description(
|
|
|
9402
9487
|
"--mapping <file>",
|
|
9403
9488
|
"\u987E\u95EE\u624B\u5199\u7684\u6620\u5C04\u5DE5\u4EF6\uFF08naturalKey \u8FD9\u4E00\u7C7B\u7684\u552F\u4E00\u6765\u6E90\uFF09\uFF1B\u4E0D\u7ED9 \u21D2 \u90A3\u4E00\u7C7B\u6052\u7EFF \u21D2 rc=2"
|
|
9404
9489
|
).option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => deliveryGate0Command(opts));
|
|
9490
|
+
delivery.command("triage").description(
|
|
9491
|
+
"\u9700\u6C42\u5206\u8BCA\uFF1A\u516D\u7C7B\u627F\u8F7D\u7269\u7531\u672C\u547D\u4EE4\u73B0\u63A2\u73B0\u586B\uFF08\u987E\u95EE\u8DF3\u4E0D\u4E86\u6B65\uFF09\uFF0C\u7ED3\u8BBA\u4E0E\u8BC1\u636E\u7531\u4F60\u7ED9\uFF0C\u5B83\u53EA\u5224\u4E24\u8005\u6253\u4E0D\u6253\u67B6"
|
|
9492
|
+
).requiredOption(
|
|
9493
|
+
"--requests <file>",
|
|
9494
|
+
'\u5F85\u5206\u8BCA\u7684\u9700\u6C42\u6E05\u5355\uFF08**\u8FD9\u53F0\u673A\u5668\u4E0A**\u7684\u4E00\u4EFD JSON \u6570\u7EC4\uFF09\uFF1A\u6BCF\u6761 `{"request":\u5BA2\u6237\u539F\u8BDD, "verdict":REUSE|CONFIG|EXTEND|GAP, "evidence":\u51ED\u4EC0\u4E48\u8FD9\u4E48\u5224, "debtAction":\u7F3A\u54EA\u4E2A Action\uFF08GAP \u65F6\uFF09, "blindAcknowledged":true\uFF08\u5224 GAP \u4E14\u6709\u76F2\u533A\u65F6\u5FC5\u987B\u663E\u5F0F\u627F\u8BA4\uFF09}`'
|
|
9495
|
+
).option(
|
|
9496
|
+
"--recon <dir>",
|
|
9497
|
+
"\u57FA\u7EBF\u4EA7\u7269\u76EE\u5F55\uFF08<out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09\uFF1B\u4E0D\u7ED9\u5219\u6309\u722C\u53D6\u8EAB\u4EFD\u73B0\u7B97\u4E00\u4EFD"
|
|
9498
|
+
).option("--out <dir>", "\u4EA7\u7269\u6839\uFF08\u5199 work/triage.md\uFF09", ".").option("--capabilities <caps>", "\u672C\u6B21\u63A2\u6D4B\u58F0\u660E\u7684 capability \u4E32", "default").action((opts) => deliveryTriageCommand(opts));
|
|
9405
9499
|
delivery.command("prepare").description("\u628A\u53D7\u652F\u6301\u7684 R2 argv \u4E0E\u9501\u3001\u8FD0\u884C\u65F6\u548C\u53D8\u66F4/\u56DE\u6EDA\u8BF4\u660E\u7ED1\u5B9A\u4E3A\u77ED\u65F6\u6267\u884C\u8BA1\u5212").requiredOption("--change-ref <file>", "\u9879\u76EE work/ \u6216 decisions/ \u4E0B\u7684\u53D8\u66F4\u8BF4\u660E").requiredOption("--rollback-ref <file>", "\u9879\u76EE work/ \u6216 decisions/ \u4E0B\u7684\u56DE\u6EDA\u8BF4\u660E").requiredOption("--evidence-dir <dir>", "\u9879\u76EE evidence/ \u4E0B\u7684\u6536\u636E\u76EE\u5F55").option("--project <dir>", "HCM \u987E\u95EE\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--ttl-seconds <n>", "\u6709\u6548\u671F\u79D2\u6570\uFF0860-3600\uFF09", "900").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").allowUnknownOption(true).argument("<command...>", "\u88AB\u7ED1\u5B9A\u7684 R2 HCM \u5B50\u547D\u4EE4\u4E0E\u53C2\u6570\uFF0C\u4E0D\u5305\u542B hcm \u672C\u8EAB").action((command, opts) => deliveryPrepareCommand(command, opts));
|
|
9406
9500
|
delivery.command("execute <planId>").description("\u9010\u6B21\u6279\u51C6\u540E\u6D88\u8D39\u77ED\u65F6\u8BA1\u5212\uFF0C\u5E76\u6267\u884C\u4E00\u6B21\u4E0E\u8BA1\u5212\u5B8C\u5168\u76F8\u540C\u7684 R2 argv").option("--project <dir>", "HCM \u987E\u95EE\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--output <fmt>", "\u6536\u636E\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").allowUnknownOption(true).argument("<command...>", "\u4E0E prepare \u5B8C\u5168\u76F8\u540C\u7684 R2 HCM \u5B50\u547D\u4EE4\u4E0E\u53C2\u6570").action((planId, command, opts) => deliveryExecuteCommand(planId, command, opts));
|
|
9407
9501
|
program.command("query <Model>").description("\u67E5\u8BE2 Model \u5217\u8868\u6570\u636E\uFF08\u901A\u8FC7 ModelQueryDsl JSON \u8868\u8FBE\u8FC7\u6EE4/\u6392\u5E8F/\u5206\u9875\uFF09").option(
|