@hcmai/cli 0.15.3 → 0.15.5
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 +260 -199
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +13 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3281,9 +3281,9 @@ async function loginCommand(args) {
|
|
|
3281
3281
|
}
|
|
3282
3282
|
const err = e;
|
|
3283
3283
|
if (err.isAxiosError) {
|
|
3284
|
-
const { fromAxiosError:
|
|
3284
|
+
const { fromAxiosError: fromAxiosError25 } = await import("@hcmai/sdk");
|
|
3285
3285
|
exitWithError(
|
|
3286
|
-
|
|
3286
|
+
fromAxiosError25(
|
|
3287
3287
|
e,
|
|
3288
3288
|
envName
|
|
3289
3289
|
)
|
|
@@ -5265,10 +5265,32 @@ async function downloadCommand(documentId, args) {
|
|
|
5265
5265
|
}
|
|
5266
5266
|
}
|
|
5267
5267
|
|
|
5268
|
+
// src/commands/document.ts
|
|
5269
|
+
init_auth_guard();
|
|
5270
|
+
init_exit();
|
|
5271
|
+
import {
|
|
5272
|
+
deleteDocument,
|
|
5273
|
+
HcmClient as HcmClient13,
|
|
5274
|
+
fromAxiosError as fromAxiosError11,
|
|
5275
|
+
formatObject as formatObject10
|
|
5276
|
+
} from "@hcmai/sdk";
|
|
5277
|
+
async function documentDeleteCommand(documentId, args) {
|
|
5278
|
+
try {
|
|
5279
|
+
const client3 = HcmClient13.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
5280
|
+
await deleteDocument(client3.raw(), documentId);
|
|
5281
|
+
process.stdout.write(formatObject10({ success: true, documentId }, { format: args.output ?? "json" }) + "\n");
|
|
5282
|
+
process.exitCode = 0;
|
|
5283
|
+
} catch (e) {
|
|
5284
|
+
const err = e;
|
|
5285
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError11(err, args.env));
|
|
5286
|
+
exitWithError(e);
|
|
5287
|
+
}
|
|
5288
|
+
}
|
|
5289
|
+
|
|
5268
5290
|
// src/commands/trace.ts
|
|
5269
5291
|
init_exit();
|
|
5270
5292
|
init_auth_guard();
|
|
5271
|
-
import { HcmClient as
|
|
5293
|
+
import { HcmClient as HcmClient14, formatObject as formatObject11, formatRows as formatRows4, fromAxiosError as fromAxiosError12 } from "@hcmai/sdk";
|
|
5272
5294
|
function parsePositiveInt2(value, fallback, flag) {
|
|
5273
5295
|
const n = Number(value ?? fallback);
|
|
5274
5296
|
if (!Number.isInteger(n) || n <= 0) {
|
|
@@ -5663,14 +5685,14 @@ async function gatherLlmTraceTree(http, rootConvId, maxDepth = 3) {
|
|
|
5663
5685
|
}
|
|
5664
5686
|
async function traceCommand(traceId, args) {
|
|
5665
5687
|
try {
|
|
5666
|
-
const client3 =
|
|
5688
|
+
const client3 = HcmClient14.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
5667
5689
|
const http = client3.raw();
|
|
5668
5690
|
const convId = args.conv ?? (args.llmCalls ? traceId ?? void 0 : void 0);
|
|
5669
5691
|
if (convId) {
|
|
5670
5692
|
if (args.raw || args.output === "json" || args.output === "yaml") {
|
|
5671
5693
|
const body = await fetchLlmTrace(http, convId);
|
|
5672
5694
|
const fmt = args.raw ? "json" : args.output;
|
|
5673
|
-
process.stdout.write(
|
|
5695
|
+
process.stdout.write(formatObject11(body.rows, { format: fmt }) + "\n");
|
|
5674
5696
|
if (!body.rows.length) {
|
|
5675
5697
|
for (const line of describeLlmTraceEmpty(convId, body.envelope)) {
|
|
5676
5698
|
process.stderr.write(line + "\n");
|
|
@@ -5695,12 +5717,12 @@ async function traceCommand(traceId, args) {
|
|
|
5695
5717
|
const resp = await http.get(`/api/trace/${traceId}`);
|
|
5696
5718
|
const agg = resp.data ?? {};
|
|
5697
5719
|
if (args.raw) {
|
|
5698
|
-
process.stdout.write(
|
|
5720
|
+
process.stdout.write(formatObject11(agg, { format: "json" }) + "\n");
|
|
5699
5721
|
process.exitCode = 0;
|
|
5700
5722
|
return;
|
|
5701
5723
|
}
|
|
5702
5724
|
if (args.output === "json" || args.output === "yaml") {
|
|
5703
|
-
process.stdout.write(
|
|
5725
|
+
process.stdout.write(formatObject11(agg, { format: args.output }) + "\n");
|
|
5704
5726
|
process.exitCode = 0;
|
|
5705
5727
|
return;
|
|
5706
5728
|
}
|
|
@@ -5711,7 +5733,7 @@ async function traceCommand(traceId, args) {
|
|
|
5711
5733
|
exitWithError(`Span #${args.span} \u8D8A\u754C\uFF08\u5171 ${spans.length} \u6761 Tempo span\uFF09`);
|
|
5712
5734
|
return;
|
|
5713
5735
|
}
|
|
5714
|
-
process.stdout.write(
|
|
5736
|
+
process.stdout.write(formatObject11(spans[idx], { format: "yaml" }) + "\n");
|
|
5715
5737
|
process.exitCode = 0;
|
|
5716
5738
|
return;
|
|
5717
5739
|
}
|
|
@@ -5725,7 +5747,7 @@ async function traceCommand(traceId, args) {
|
|
|
5725
5747
|
} catch (e) {
|
|
5726
5748
|
const err = e;
|
|
5727
5749
|
if (err?.isAxiosError) {
|
|
5728
|
-
exitWithError(
|
|
5750
|
+
exitWithError(fromAxiosError12(err, args.profile));
|
|
5729
5751
|
}
|
|
5730
5752
|
exitWithError(e);
|
|
5731
5753
|
}
|
|
@@ -5735,27 +5757,27 @@ async function traceCommand(traceId, args) {
|
|
|
5735
5757
|
init_exit();
|
|
5736
5758
|
init_auth_guard();
|
|
5737
5759
|
import {
|
|
5738
|
-
HcmClient as
|
|
5739
|
-
formatObject as
|
|
5740
|
-
fromAxiosError as
|
|
5760
|
+
HcmClient as HcmClient15,
|
|
5761
|
+
formatObject as formatObject12,
|
|
5762
|
+
fromAxiosError as fromAxiosError13,
|
|
5741
5763
|
getCacheStats,
|
|
5742
5764
|
clearModelCache,
|
|
5743
5765
|
clearMetaCache
|
|
5744
5766
|
} from "@hcmai/sdk";
|
|
5745
5767
|
async function withClient(args, fn) {
|
|
5746
|
-
const client3 =
|
|
5768
|
+
const client3 = HcmClient15.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
5747
5769
|
return fn(client3);
|
|
5748
5770
|
}
|
|
5749
5771
|
function emit(result, args, human) {
|
|
5750
5772
|
const fmt = args.output ?? "json";
|
|
5751
5773
|
if (fmt !== "json") process.stdout.write(human + "\n");
|
|
5752
|
-
process.stdout.write(
|
|
5774
|
+
process.stdout.write(formatObject12(result, { format: fmt }) + "\n");
|
|
5753
5775
|
process.exitCode = 0;
|
|
5754
5776
|
return;
|
|
5755
5777
|
}
|
|
5756
5778
|
function fail3(e, args) {
|
|
5757
5779
|
const err = e;
|
|
5758
|
-
if (err?.isAxiosError) exitWithError(
|
|
5780
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError13(err, args.env));
|
|
5759
5781
|
exitWithError(e);
|
|
5760
5782
|
process.exit(1);
|
|
5761
5783
|
}
|
|
@@ -5793,28 +5815,28 @@ init_exit();
|
|
|
5793
5815
|
init_auth_guard();
|
|
5794
5816
|
import { readFileSync as readFileSync3 } from "fs";
|
|
5795
5817
|
import {
|
|
5796
|
-
HcmClient as
|
|
5797
|
-
formatObject as
|
|
5798
|
-
fromAxiosError as
|
|
5818
|
+
HcmClient as HcmClient16,
|
|
5819
|
+
formatObject as formatObject13,
|
|
5820
|
+
fromAxiosError as fromAxiosError14,
|
|
5799
5821
|
scriptDryRun,
|
|
5800
5822
|
validateScriptManifest,
|
|
5801
5823
|
queryScriptLogs,
|
|
5802
5824
|
getScriptTask
|
|
5803
5825
|
} from "@hcmai/sdk";
|
|
5804
5826
|
async function withClient2(args, fn) {
|
|
5805
|
-
const client3 =
|
|
5827
|
+
const client3 = HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
5806
5828
|
return fn(client3);
|
|
5807
5829
|
}
|
|
5808
5830
|
function emit2(result, args, human) {
|
|
5809
5831
|
const fmt = args.output ?? "json";
|
|
5810
5832
|
if (fmt !== "json") process.stdout.write(human + "\n");
|
|
5811
|
-
process.stdout.write(
|
|
5833
|
+
process.stdout.write(formatObject13(result, { format: fmt }) + "\n");
|
|
5812
5834
|
process.exitCode = 0;
|
|
5813
5835
|
return;
|
|
5814
5836
|
}
|
|
5815
5837
|
function fail4(e, args) {
|
|
5816
5838
|
const err = e;
|
|
5817
|
-
if (err?.isAxiosError) exitWithError(
|
|
5839
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError14(err, args.env));
|
|
5818
5840
|
exitWithError(e);
|
|
5819
5841
|
process.exit(1);
|
|
5820
5842
|
}
|
|
@@ -5904,16 +5926,16 @@ async function scriptTaskCommand(taskId, args) {
|
|
|
5904
5926
|
init_exit();
|
|
5905
5927
|
init_auth_guard();
|
|
5906
5928
|
import {
|
|
5907
|
-
HcmClient as
|
|
5908
|
-
formatObject as
|
|
5909
|
-
fromAxiosError as
|
|
5929
|
+
HcmClient as HcmClient17,
|
|
5930
|
+
formatObject as formatObject14,
|
|
5931
|
+
fromAxiosError as fromAxiosError15,
|
|
5910
5932
|
uploadDocument as uploadDocument2
|
|
5911
5933
|
} from "@hcmai/sdk";
|
|
5912
5934
|
var DEFAULT_UPLOAD_CATEGORY = "attachment";
|
|
5913
5935
|
async function uploadCommand(filePath, args) {
|
|
5914
5936
|
try {
|
|
5915
5937
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
5916
|
-
const client3 =
|
|
5938
|
+
const client3 = HcmClient17.fromAuthContext(ctx);
|
|
5917
5939
|
const meta2 = await uploadDocument2(
|
|
5918
5940
|
client3.raw(),
|
|
5919
5941
|
filePath,
|
|
@@ -5926,7 +5948,7 @@ async function uploadCommand(filePath, args) {
|
|
|
5926
5948
|
`
|
|
5927
5949
|
);
|
|
5928
5950
|
}
|
|
5929
|
-
process.stdout.write(
|
|
5951
|
+
process.stdout.write(formatObject14(meta2, { format: fmt }) + "\n");
|
|
5930
5952
|
process.exitCode = 0;
|
|
5931
5953
|
return;
|
|
5932
5954
|
} catch (e) {
|
|
@@ -5937,7 +5959,7 @@ async function uploadCommand(filePath, args) {
|
|
|
5937
5959
|
} else if (status === 413) {
|
|
5938
5960
|
exitWithError(new Error("\u6587\u4EF6\u8D85\u51FA\u670D\u52A1\u7AEF\u5927\u5C0F\u4E0A\u9650\uFF08413\uFF09"));
|
|
5939
5961
|
} else if (err?.isAxiosError) {
|
|
5940
|
-
exitWithError(
|
|
5962
|
+
exitWithError(fromAxiosError15(err, args.env));
|
|
5941
5963
|
} else {
|
|
5942
5964
|
exitWithError(e);
|
|
5943
5965
|
}
|
|
@@ -5948,9 +5970,9 @@ async function uploadCommand(filePath, args) {
|
|
|
5948
5970
|
init_exit();
|
|
5949
5971
|
init_auth_guard();
|
|
5950
5972
|
import {
|
|
5951
|
-
HcmClient as
|
|
5952
|
-
formatObject as
|
|
5953
|
-
fromAxiosError as
|
|
5973
|
+
HcmClient as HcmClient18,
|
|
5974
|
+
formatObject as formatObject15,
|
|
5975
|
+
fromAxiosError as fromAxiosError16,
|
|
5954
5976
|
packDataPackage,
|
|
5955
5977
|
installDataPackageArtifactAsync,
|
|
5956
5978
|
waitForInstallRun,
|
|
@@ -5975,7 +5997,7 @@ async function datapackagePackCommand(packageDir, args) {
|
|
|
5975
5997
|
`
|
|
5976
5998
|
);
|
|
5977
5999
|
}
|
|
5978
|
-
process.stdout.write(
|
|
6000
|
+
process.stdout.write(formatObject15(result, { format: fmt }) + "\n");
|
|
5979
6001
|
process.exitCode = 0;
|
|
5980
6002
|
return;
|
|
5981
6003
|
} catch (e) {
|
|
@@ -5985,7 +6007,7 @@ async function datapackagePackCommand(packageDir, args) {
|
|
|
5985
6007
|
async function datapackageInstallCommand(artifactPath, args) {
|
|
5986
6008
|
try {
|
|
5987
6009
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
5988
|
-
const client3 =
|
|
6010
|
+
const client3 = HcmClient18.fromAuthContext(ctx);
|
|
5989
6011
|
const fmt = args.output ?? "json";
|
|
5990
6012
|
const human = fmt !== "json";
|
|
5991
6013
|
const accepted = await installDataPackageArtifactAsync(client3, artifactPath, {
|
|
@@ -6053,7 +6075,7 @@ async function datapackageInstallCommand(artifactPath, args) {
|
|
|
6053
6075
|
if (err?.code === "ENOENT") {
|
|
6054
6076
|
exitWithError(new Error(`\u5236\u54C1\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${artifactPath}`));
|
|
6055
6077
|
} else if (err?.isAxiosError) {
|
|
6056
|
-
exitWithError(
|
|
6078
|
+
exitWithError(fromAxiosError16(err, args.env));
|
|
6057
6079
|
} else {
|
|
6058
6080
|
exitWithError(e);
|
|
6059
6081
|
}
|
|
@@ -6062,7 +6084,7 @@ async function datapackageInstallCommand(artifactPath, args) {
|
|
|
6062
6084
|
async function datapackageStatusCommand(runId, args) {
|
|
6063
6085
|
try {
|
|
6064
6086
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
6065
|
-
const client3 =
|
|
6087
|
+
const client3 = HcmClient18.fromAuthContext(ctx);
|
|
6066
6088
|
const run3 = await fetchInstallRun(client3, runId);
|
|
6067
6089
|
const fmt = args.output ?? "json";
|
|
6068
6090
|
if (!run3) {
|
|
@@ -6085,7 +6107,7 @@ async function datapackageStatusCommand(runId, args) {
|
|
|
6085
6107
|
return;
|
|
6086
6108
|
} catch (e) {
|
|
6087
6109
|
const err = e;
|
|
6088
|
-
if (err?.isAxiosError) exitWithError(
|
|
6110
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError16(err, args.env));
|
|
6089
6111
|
else exitWithError(e);
|
|
6090
6112
|
}
|
|
6091
6113
|
}
|
|
@@ -6102,7 +6124,7 @@ function truncateTail(text, max) {
|
|
|
6102
6124
|
return text.length <= max ? text : "\u2026" + text.slice(text.length - max + 1);
|
|
6103
6125
|
}
|
|
6104
6126
|
function emit3(payload, fmt) {
|
|
6105
|
-
process.stdout.write(
|
|
6127
|
+
process.stdout.write(formatObject15(payload, { format: fmt }) + "\n");
|
|
6106
6128
|
}
|
|
6107
6129
|
|
|
6108
6130
|
// src/commands/skills.ts
|
|
@@ -6126,8 +6148,8 @@ import {
|
|
|
6126
6148
|
resolveAllSkillsInstallOrder,
|
|
6127
6149
|
matchSkills,
|
|
6128
6150
|
filterByStage,
|
|
6129
|
-
formatObject as
|
|
6130
|
-
fromAxiosError as
|
|
6151
|
+
formatObject as formatObject18,
|
|
6152
|
+
fromAxiosError as fromAxiosError17,
|
|
6131
6153
|
loadGlobalConfig as loadGlobalConfig6,
|
|
6132
6154
|
discoverProjectEnv as discoverProjectEnv3,
|
|
6133
6155
|
resolveEnvContext as resolveEnvContext5,
|
|
@@ -6335,7 +6357,7 @@ import { execFileSync } from "child_process";
|
|
|
6335
6357
|
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync as readFileSync4, rmSync, statSync as statSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
6336
6358
|
import os2 from "os";
|
|
6337
6359
|
import path4 from "path";
|
|
6338
|
-
import { CASES_REPO_SLUG, CASES_REPO_URL, CNB_ORIGIN, CliError as CliError18, CliErrorCode as CliErrorCode17, formatObject as
|
|
6360
|
+
import { CASES_REPO_SLUG, CASES_REPO_URL, CNB_ORIGIN, CliError as CliError18, CliErrorCode as CliErrorCode17, formatObject as formatObject16 } from "@hcmai/sdk";
|
|
6339
6361
|
var casesCacheDir = () => process.env.HCM_CASES_CACHE?.trim() || path4.join(os2.homedir(), ".cache", "hcm", "chiron-cases");
|
|
6340
6362
|
var INDEX_CACHE = () => path4.join(casesCacheDir(), "index.json");
|
|
6341
6363
|
var INDEX_TTL_MS = 60 * 60 * 1e3;
|
|
@@ -6434,7 +6456,7 @@ function matchTag(c, fp) {
|
|
|
6434
6456
|
}
|
|
6435
6457
|
function emit4(args, data, text) {
|
|
6436
6458
|
if (args.output === "json" || args.output === "yaml") {
|
|
6437
|
-
process.stdout.write(
|
|
6459
|
+
process.stdout.write(formatObject16(data, { format: args.output }) + "\n");
|
|
6438
6460
|
} else {
|
|
6439
6461
|
process.stdout.write(text() + "\n");
|
|
6440
6462
|
}
|
|
@@ -6715,7 +6737,7 @@ import { readFileSync as readFileSync5, readdirSync as readdirSync2, statSync as
|
|
|
6715
6737
|
import { createHash as createHash3 } from "crypto";
|
|
6716
6738
|
import * as path6 from "path";
|
|
6717
6739
|
import { fileURLToPath } from "url";
|
|
6718
|
-
import { formatObject as
|
|
6740
|
+
import { formatObject as formatObject17, parseSkillFrontmatter } from "@hcmai/sdk";
|
|
6719
6741
|
function collectCommandSurface(root) {
|
|
6720
6742
|
const out = [];
|
|
6721
6743
|
const walk = (cmd, prefix) => {
|
|
@@ -6791,7 +6813,7 @@ function buildManifest(root, skillsDir = bundledSkillsDir()) {
|
|
|
6791
6813
|
}
|
|
6792
6814
|
function skillsManifestCommand(root, args) {
|
|
6793
6815
|
const manifest2 = buildManifest(root);
|
|
6794
|
-
process.stdout.write(
|
|
6816
|
+
process.stdout.write(formatObject17(manifest2, { format: args.output ?? "json" }) + "\n");
|
|
6795
6817
|
}
|
|
6796
6818
|
function str(v) {
|
|
6797
6819
|
return typeof v === "string" && v ? v : void 0;
|
|
@@ -6870,14 +6892,14 @@ async function resolveBundledClosure(targetId, dir = bundledSkillsDir()) {
|
|
|
6870
6892
|
}
|
|
6871
6893
|
state.set(id, "visiting");
|
|
6872
6894
|
stack.push(id);
|
|
6873
|
-
const
|
|
6874
|
-
for (const need of parseSkillRequirements(
|
|
6895
|
+
const document2 = await readBundledSkillDocument(id, dir);
|
|
6896
|
+
for (const need of parseSkillRequirements(document2.markdown, id)) {
|
|
6875
6897
|
if (available.has(need)) await visit(need);
|
|
6876
6898
|
else external.add(need);
|
|
6877
6899
|
}
|
|
6878
6900
|
stack.pop();
|
|
6879
6901
|
state.set(id, "done");
|
|
6880
|
-
documents.push(
|
|
6902
|
+
documents.push(document2);
|
|
6881
6903
|
};
|
|
6882
6904
|
await visit(targetId);
|
|
6883
6905
|
return { documents, external: [...external].sort() };
|
|
@@ -7016,7 +7038,7 @@ function fail6(e, args) {
|
|
|
7016
7038
|
if (err?.response?.status === 404) {
|
|
7017
7039
|
exitWithError(new Error("\u8BE5\u73AF\u5883\u6CA1\u6709\u8FD9\u4E2A\u6280\u80FD \u2014\u2014 \u8DD1 `hcm skills list` \u770B\u76EE\u5F55\uFF08\u6280\u80FD\u968F\u4EA7\u54C1\u7248\u672C\u8D70\uFF09"));
|
|
7018
7040
|
}
|
|
7019
|
-
if (err?.isAxiosError) exitWithError(
|
|
7041
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError17(err, args.env));
|
|
7020
7042
|
exitWithError(e);
|
|
7021
7043
|
process.exit(1);
|
|
7022
7044
|
}
|
|
@@ -7067,7 +7089,7 @@ async function skillsListCommand(keyword, args, cwd = process.cwd()) {
|
|
|
7067
7089
|
}
|
|
7068
7090
|
if (fmt === "json" || fmt === "yaml") {
|
|
7069
7091
|
process.stdout.write(
|
|
7070
|
-
|
|
7092
|
+
formatObject18(
|
|
7071
7093
|
{
|
|
7072
7094
|
...manifest2 ?? {},
|
|
7073
7095
|
categories: cats,
|
|
@@ -7156,7 +7178,7 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
7156
7178
|
const legacy = await detectLegacyFlatLayout(layout);
|
|
7157
7179
|
const legacyState = legacy ? await readSkillsState(legacy) : void 0;
|
|
7158
7180
|
if (fmt === "json" || fmt === "yaml") {
|
|
7159
|
-
process.stdout.write(
|
|
7181
|
+
process.stdout.write(formatObject18({
|
|
7160
7182
|
baseDir: layout.baseDir,
|
|
7161
7183
|
target: layout.target,
|
|
7162
7184
|
all: false,
|
|
@@ -7215,7 +7237,7 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
7215
7237
|
const shown = sourceFilter === "all" ? byKeyword : byKeyword.filter((row) => row.sourceKind === sourceFilter);
|
|
7216
7238
|
const groupOf = (kind) => kind === "cli" ? "CLI \u81EA\u5E26" : kind === "local" ? "\u672C\u9879\u76EE\u81EA\u5DF1\u7684\uFF08hcm-skills/local/\uFF09" : "\u777F\u620E\u6280\u80FD\u5E93";
|
|
7217
7239
|
if (fmt === "json" || fmt === "yaml") {
|
|
7218
|
-
process.stdout.write(
|
|
7240
|
+
process.stdout.write(formatObject18({
|
|
7219
7241
|
baseDir: layout.baseDir,
|
|
7220
7242
|
target: layout.target,
|
|
7221
7243
|
endpoint: state?.endpoint,
|
|
@@ -7275,8 +7297,8 @@ async function skillsShowCommand(id, args) {
|
|
|
7275
7297
|
assertSafeSkillId(id);
|
|
7276
7298
|
const source = parseSourceFilter(args.source);
|
|
7277
7299
|
if (source !== "chiron" && listBundledSkills().some((s) => s.id === id)) {
|
|
7278
|
-
const
|
|
7279
|
-
process.stdout.write(
|
|
7300
|
+
const document2 = await readBundledSkillDocument(id);
|
|
7301
|
+
process.stdout.write(document2.markdown.endsWith("\n") ? document2.markdown : document2.markdown + "\n");
|
|
7280
7302
|
process.exitCode = 0;
|
|
7281
7303
|
return;
|
|
7282
7304
|
}
|
|
@@ -7312,10 +7334,10 @@ async function skillsInstallCommand(id, args) {
|
|
|
7312
7334
|
const seen = /* @__PURE__ */ new Set();
|
|
7313
7335
|
documents = [];
|
|
7314
7336
|
for (const one of requestedIds) {
|
|
7315
|
-
for (const
|
|
7316
|
-
if (seen.has(
|
|
7317
|
-
seen.add(
|
|
7318
|
-
documents.push(
|
|
7337
|
+
for (const document2 of await resolveLocalSkillDocuments(root, one)) {
|
|
7338
|
+
if (seen.has(document2.id)) continue;
|
|
7339
|
+
seen.add(document2.id);
|
|
7340
|
+
documents.push(document2);
|
|
7319
7341
|
}
|
|
7320
7342
|
}
|
|
7321
7343
|
} else {
|
|
@@ -7422,7 +7444,7 @@ async function skillsInstallCommand(id, args) {
|
|
|
7422
7444
|
const legacyState = await readSkillsState(legacyForCheck);
|
|
7423
7445
|
const count = Object.keys(legacyState?.skills ?? {}).length;
|
|
7424
7446
|
if (fmtCheck === "json" || fmtCheck === "yaml") {
|
|
7425
|
-
process.stdout.write(
|
|
7447
|
+
process.stdout.write(formatObject18({
|
|
7426
7448
|
dryRun: true,
|
|
7427
7449
|
legacyFlatLayout: { dir: legacyForCheck, skills: count },
|
|
7428
7450
|
wouldMigrate: true,
|
|
@@ -7440,7 +7462,7 @@ async function skillsInstallCommand(id, args) {
|
|
|
7440
7462
|
}
|
|
7441
7463
|
const would = documents.map((d) => d.id).sort();
|
|
7442
7464
|
if (fmtCheck === "json" || fmtCheck === "yaml") {
|
|
7443
|
-
process.stdout.write(
|
|
7465
|
+
process.stdout.write(formatObject18({
|
|
7444
7466
|
dryRun: true,
|
|
7445
7467
|
baseDir: layout.baseDir,
|
|
7446
7468
|
target: layout.target,
|
|
@@ -7475,7 +7497,7 @@ async function skillsInstallCommand(id, args) {
|
|
|
7475
7497
|
const agents = agentIndexes[0]?.status;
|
|
7476
7498
|
const fmt = args.output ?? "table";
|
|
7477
7499
|
if (fmt === "json" || fmt === "yaml") {
|
|
7478
|
-
process.stdout.write(
|
|
7500
|
+
process.stdout.write(formatObject18({ ...result, all, target_agent: layout.target, agentsFile: layout.agentsFile, agents, agentIndexes, conflictCheck: conflictNote ? { checked: false, note: conflictNote } : { checked: true } }, { format: fmt }) + "\n");
|
|
7479
7501
|
} else {
|
|
7480
7502
|
const headline = all ? `\u2705 \u5168\u90E8 ${requestedIds.length} \u4E2A\u6280\u80FD \u2192 ${result.baseDir}` : `\u2705 ${id} \u2192 ${path8.join(result.baseDir, id, "SKILL.md")}`;
|
|
7481
7503
|
process.stdout.write(`${headline}
|
|
@@ -7633,7 +7655,7 @@ async function skillsPathCommand(id, args) {
|
|
|
7633
7655
|
const resolved = await resolveSkillPath(layout, id);
|
|
7634
7656
|
const fmt = args.output ?? "table";
|
|
7635
7657
|
if (fmt === "json" || fmt === "yaml") {
|
|
7636
|
-
process.stdout.write(
|
|
7658
|
+
process.stdout.write(formatObject18(resolved, { format: fmt }) + "\n");
|
|
7637
7659
|
process.exitCode = 0;
|
|
7638
7660
|
return;
|
|
7639
7661
|
}
|
|
@@ -7770,7 +7792,7 @@ async function resolveLocalSkillDocuments(sourceRoot, targetId) {
|
|
|
7770
7792
|
if (!markdown.trim()) throw invalid(`\u6280\u80FD ${id} \u5185\u5BB9\u4E3A\u7A7A`);
|
|
7771
7793
|
state.set(id, "visiting");
|
|
7772
7794
|
pathStack.push(id);
|
|
7773
|
-
const
|
|
7795
|
+
const document2 = {
|
|
7774
7796
|
id,
|
|
7775
7797
|
markdown,
|
|
7776
7798
|
source: local,
|
|
@@ -7782,7 +7804,7 @@ async function resolveLocalSkillDocuments(sourceRoot, targetId) {
|
|
|
7782
7804
|
}
|
|
7783
7805
|
pathStack.pop();
|
|
7784
7806
|
state.set(id, "done");
|
|
7785
|
-
order.push(
|
|
7807
|
+
order.push(document2);
|
|
7786
7808
|
};
|
|
7787
7809
|
await visit(targetId);
|
|
7788
7810
|
return order;
|
|
@@ -7851,15 +7873,15 @@ async function installSkillDocuments(documents, requestedIds, baseDir, force, me
|
|
|
7851
7873
|
if (requestedIds.length === 0) throw invalid("\u6CA1\u6709\u6307\u5B9A\u8981\u88C5\u7684\u6280\u80FD");
|
|
7852
7874
|
for (const id of requestedIds) assertSafeSkillId(id);
|
|
7853
7875
|
const seen = /* @__PURE__ */ new Set();
|
|
7854
|
-
const candidates = documents.map((
|
|
7855
|
-
assertSafeSkillId(
|
|
7856
|
-
if (seen.has(
|
|
7857
|
-
seen.add(
|
|
7858
|
-
if (!
|
|
7876
|
+
const candidates = documents.map((document2) => {
|
|
7877
|
+
assertSafeSkillId(document2.id);
|
|
7878
|
+
if (seen.has(document2.id)) throw invalid(`\u5B89\u88C5\u95ED\u5305\u5305\u542B\u91CD\u590D\u6280\u80FD: ${document2.id}`);
|
|
7879
|
+
seen.add(document2.id);
|
|
7880
|
+
if (!document2.markdown.trim()) throw invalid(`\u6280\u80FD ${document2.id} \u5185\u5BB9\u4E3A\u7A7A`);
|
|
7859
7881
|
return {
|
|
7860
|
-
...
|
|
7861
|
-
target: path8.join(baseDir,
|
|
7862
|
-
bytes: Buffer.byteLength(
|
|
7882
|
+
...document2,
|
|
7883
|
+
target: path8.join(baseDir, document2.id, "SKILL.md"),
|
|
7884
|
+
bytes: Buffer.byteLength(document2.markdown)
|
|
7863
7885
|
};
|
|
7864
7886
|
});
|
|
7865
7887
|
for (const id of requestedIds) {
|
|
@@ -7938,18 +7960,18 @@ async function readLocalReferences(skillDir) {
|
|
|
7938
7960
|
async function planStaleReferences(state, documents, baseDir) {
|
|
7939
7961
|
const remove = [];
|
|
7940
7962
|
const keptLocallyModified = [];
|
|
7941
|
-
for (const
|
|
7942
|
-
const recorded = state.skills[
|
|
7943
|
-
const fresh = new Set((
|
|
7963
|
+
for (const document2 of documents) {
|
|
7964
|
+
const recorded = state.skills[document2.id]?.references ?? {};
|
|
7965
|
+
const fresh = new Set((document2.references ?? []).map((r) => r.path));
|
|
7944
7966
|
for (const [relative2, recordedSha] of Object.entries(recorded)) {
|
|
7945
7967
|
if (fresh.has(relative2)) continue;
|
|
7946
|
-
const onDisk = await readInstalledReference(baseDir,
|
|
7968
|
+
const onDisk = await readInstalledReference(baseDir, document2.id, relative2);
|
|
7947
7969
|
if (onDisk === void 0) continue;
|
|
7948
7970
|
if (sha2562(onDisk) !== recordedSha) {
|
|
7949
|
-
keptLocallyModified.push({ id:
|
|
7971
|
+
keptLocallyModified.push({ id: document2.id, path: relative2 });
|
|
7950
7972
|
continue;
|
|
7951
7973
|
}
|
|
7952
|
-
remove.push({ id:
|
|
7974
|
+
remove.push({ id: document2.id, path: relative2 });
|
|
7953
7975
|
}
|
|
7954
7976
|
}
|
|
7955
7977
|
const byKey = (a, b) => `${a.id}/${a.path}`.localeCompare(`${b.id}/${b.path}`);
|
|
@@ -7987,15 +8009,15 @@ async function writeSkillDocuments(documents, baseDir, removals = []) {
|
|
|
7987
8009
|
const staged = [];
|
|
7988
8010
|
const removed = [];
|
|
7989
8011
|
try {
|
|
7990
|
-
for (const
|
|
7991
|
-
const target = path8.join(baseDir,
|
|
8012
|
+
for (const document2 of documents) {
|
|
8013
|
+
const target = path8.join(baseDir, document2.id, "SKILL.md");
|
|
7992
8014
|
await fsp2.mkdir(path8.dirname(target), { recursive: true });
|
|
7993
8015
|
const temp = path8.join(path8.dirname(target), `.SKILL.md.${process.pid}.${Date.now()}.tmp`);
|
|
7994
|
-
await fsp2.writeFile(temp,
|
|
8016
|
+
await fsp2.writeFile(temp, document2.markdown, "utf8");
|
|
7995
8017
|
staged.push({ temp, target });
|
|
7996
|
-
for (const reference of
|
|
8018
|
+
for (const reference of document2.references ?? []) {
|
|
7997
8019
|
assertSafeReferencePath2(reference.path);
|
|
7998
|
-
const referenceTarget = path8.join(baseDir,
|
|
8020
|
+
const referenceTarget = path8.join(baseDir, document2.id, "references", reference.path);
|
|
7999
8021
|
await fsp2.mkdir(path8.dirname(referenceTarget), { recursive: true });
|
|
8000
8022
|
const referenceTemp = `${referenceTarget}.${process.pid}.${Date.now()}.tmp`;
|
|
8001
8023
|
await fsp2.writeFile(referenceTemp, reference.content, "utf8");
|
|
@@ -8030,19 +8052,19 @@ async function recordInstalled(baseDir, documents, meta2) {
|
|
|
8030
8052
|
if (meta2.base !== void 0) state.base = meta2.base;
|
|
8031
8053
|
if (meta2.all) state.all = true;
|
|
8032
8054
|
state.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
8033
|
-
for (const
|
|
8034
|
-
const previous = state.skills[
|
|
8035
|
-
state.skills[
|
|
8036
|
-
source:
|
|
8055
|
+
for (const document2 of documents) {
|
|
8056
|
+
const previous = state.skills[document2.id];
|
|
8057
|
+
state.skills[document2.id] = {
|
|
8058
|
+
source: document2.source,
|
|
8037
8059
|
// 🔴 两个键同值:`source` 留给旧 CLI 读(降级不炸),新代码只读 `sourceLocator`。
|
|
8038
|
-
sourceKind:
|
|
8039
|
-
sourceLocator:
|
|
8040
|
-
sha256: sha2562(
|
|
8041
|
-
installedAt: meta2.keepInstalledAt?.has(
|
|
8060
|
+
sourceKind: document2.sourceKind ?? previous?.sourceKind ?? "chiron",
|
|
8061
|
+
sourceLocator: document2.source,
|
|
8062
|
+
sha256: sha2562(document2.markdown),
|
|
8063
|
+
installedAt: meta2.keepInstalledAt?.has(document2.id) && previous ? previous.installedAt : state.updatedAt,
|
|
8042
8064
|
// 已经是直接安装的,不因为这次作为依赖被带进来就降级
|
|
8043
|
-
direct: meta2.directIds.has(
|
|
8065
|
+
direct: meta2.directIds.has(document2.id) || Boolean(previous?.direct),
|
|
8044
8066
|
references: Object.fromEntries(
|
|
8045
|
-
(
|
|
8067
|
+
(document2.references ?? []).map((reference) => [reference.path, sha2562(reference.content)])
|
|
8046
8068
|
)
|
|
8047
8069
|
};
|
|
8048
8070
|
}
|
|
@@ -8335,7 +8357,7 @@ async function skillsUpdateCommand(args) {
|
|
|
8335
8357
|
base,
|
|
8336
8358
|
target: layout.target,
|
|
8337
8359
|
all,
|
|
8338
|
-
directIds: all ? new Set(plan.documents.map((
|
|
8360
|
+
directIds: all ? new Set(plan.documents.map((document2) => document2.id)) : /* @__PURE__ */ new Set()
|
|
8339
8361
|
});
|
|
8340
8362
|
for (const k of await removeRenamedSkills(layout.baseDir, plan.renamed)) {
|
|
8341
8363
|
process.stderr.write(`[hcm] \u6539\u540D\u6E05\u7406\u8DF3\u8FC7 ${k.from}\uFF1A${k.kept}
|
|
@@ -8347,7 +8369,7 @@ async function skillsUpdateCommand(args) {
|
|
|
8347
8369
|
const changed = plan.entries.filter((e) => e.status === "updated" || e.status === "added");
|
|
8348
8370
|
const fmt = args.output ?? "table";
|
|
8349
8371
|
if (fmt === "json" || fmt === "yaml") {
|
|
8350
|
-
process.stdout.write(
|
|
8372
|
+
process.stdout.write(formatObject18({
|
|
8351
8373
|
endpoint,
|
|
8352
8374
|
baseDir: layout.baseDir,
|
|
8353
8375
|
target: layout.target,
|
|
@@ -8577,8 +8599,8 @@ import {
|
|
|
8577
8599
|
assertDangerWrite as assertDangerWrite3,
|
|
8578
8600
|
normalizeOrigin as normalizeOrigin4,
|
|
8579
8601
|
createHttpClient as createHttpClient3,
|
|
8580
|
-
formatObject as
|
|
8581
|
-
fromAxiosError as
|
|
8602
|
+
formatObject as formatObject19,
|
|
8603
|
+
fromAxiosError as fromAxiosError18,
|
|
8582
8604
|
loadGlobalConfig as loadGlobalConfig7,
|
|
8583
8605
|
resolveEnvContext as resolveEnvContext6,
|
|
8584
8606
|
printResolvedEnvironment as printResolvedEnvironment5,
|
|
@@ -8675,7 +8697,7 @@ async function tenantBootstrapCommand(args) {
|
|
|
8675
8697
|
`
|
|
8676
8698
|
);
|
|
8677
8699
|
}
|
|
8678
|
-
process.stdout.write(
|
|
8700
|
+
process.stdout.write(formatObject19(result, { format: fmt }) + "\n");
|
|
8679
8701
|
process.exitCode = 0;
|
|
8680
8702
|
return;
|
|
8681
8703
|
} catch (e) {
|
|
@@ -8683,7 +8705,7 @@ async function tenantBootstrapCommand(args) {
|
|
|
8683
8705
|
if (err?.response?.status === 403) {
|
|
8684
8706
|
exitWithError(new Error("bootstrap key \u65E0\u6548\uFF08403\uFF09\u2014\u2014 \u6838\u5BF9\u90E8\u7F72\u65B9\u63D0\u4F9B\u7684 key\uFF0C\u52FF\u590D\u7528\u5176\u4ED6\u73AF\u5883\u7684"));
|
|
8685
8707
|
} else if (err?.isAxiosError) {
|
|
8686
|
-
exitWithError(
|
|
8708
|
+
exitWithError(fromAxiosError18(err, args.env));
|
|
8687
8709
|
} else {
|
|
8688
8710
|
exitWithError(e);
|
|
8689
8711
|
}
|
|
@@ -8695,9 +8717,9 @@ import { promises as fsp3 } from "fs";
|
|
|
8695
8717
|
import os4 from "os";
|
|
8696
8718
|
import nodePath from "path";
|
|
8697
8719
|
import {
|
|
8698
|
-
HcmClient as
|
|
8699
|
-
formatObject as
|
|
8700
|
-
fromAxiosError as
|
|
8720
|
+
HcmClient as HcmClient19,
|
|
8721
|
+
formatObject as formatObject20,
|
|
8722
|
+
fromAxiosError as fromAxiosError19,
|
|
8701
8723
|
listTenantMeta,
|
|
8702
8724
|
getTenantMeta,
|
|
8703
8725
|
saveTenantMeta,
|
|
@@ -8714,7 +8736,7 @@ init_exit();
|
|
|
8714
8736
|
init_impersonation_lifecycle();
|
|
8715
8737
|
init_auth_guard();
|
|
8716
8738
|
async function client2(args) {
|
|
8717
|
-
return
|
|
8739
|
+
return HcmClient19.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
8718
8740
|
}
|
|
8719
8741
|
function formatMetaForbiddenMessage(mode = "write") {
|
|
8720
8742
|
if (mode === "read") {
|
|
@@ -8729,7 +8751,7 @@ function fail7(e, args, mode = "write") {
|
|
|
8729
8751
|
new Error(formatMetaForbiddenMessage(mode))
|
|
8730
8752
|
);
|
|
8731
8753
|
}
|
|
8732
|
-
if (err?.isAxiosError) exitWithError(
|
|
8754
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError19(err, args.env));
|
|
8733
8755
|
exitWithError(e);
|
|
8734
8756
|
process.exit(1);
|
|
8735
8757
|
}
|
|
@@ -8745,7 +8767,7 @@ async function metaListCommand(args) {
|
|
|
8745
8767
|
const fmt = args.output ?? "json";
|
|
8746
8768
|
if (fmt !== "json") process.stdout.write(`\u{1F4C4} ${items.length} \u4EFD${total ? ` / \u5171 ${total}` : ""}
|
|
8747
8769
|
`);
|
|
8748
|
-
process.stdout.write(
|
|
8770
|
+
process.stdout.write(formatObject20(items, { format: fmt }) + "\n");
|
|
8749
8771
|
process.exitCode = 0;
|
|
8750
8772
|
return;
|
|
8751
8773
|
} catch (e) {
|
|
@@ -8866,7 +8888,7 @@ async function metaSetCommand(path18, args) {
|
|
|
8866
8888
|
const dryFmt = args.output;
|
|
8867
8889
|
if (dryFmt === "json" || dryFmt === "yaml") {
|
|
8868
8890
|
process.stdout.write(
|
|
8869
|
-
|
|
8891
|
+
formatObject20(
|
|
8870
8892
|
{ dryRun: true, path: path18, bytes: Buffer.byteLength(content), content },
|
|
8871
8893
|
{ format: dryFmt }
|
|
8872
8894
|
) + "\n"
|
|
@@ -8949,7 +8971,7 @@ ${content}
|
|
|
8949
8971
|
process.stdout.write(" \u5DF2\u6E05\u5143\u6570\u636E\u7F13\u5B58\uFF0C\u5E76\u771F\u8BFB\u4E86\u4E00\u904D\uFF1A\u670D\u52A1\u7AEF\u8BFB\u5F97\u52A8 \u2714\n");
|
|
8950
8972
|
}
|
|
8951
8973
|
}
|
|
8952
|
-
process.stdout.write(
|
|
8974
|
+
process.stdout.write(formatObject20(result, { format: fmt }) + "\n");
|
|
8953
8975
|
process.exitCode = 0;
|
|
8954
8976
|
return;
|
|
8955
8977
|
} catch (e) {
|
|
@@ -8971,7 +8993,7 @@ async function metaDeleteCommand(path18, args) {
|
|
|
8971
8993
|
const fmt = args.output ?? "json";
|
|
8972
8994
|
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path18}
|
|
8973
8995
|
`);
|
|
8974
|
-
process.stdout.write(
|
|
8996
|
+
process.stdout.write(formatObject20(result, { format: fmt }) + "\n");
|
|
8975
8997
|
process.exitCode = 0;
|
|
8976
8998
|
return;
|
|
8977
8999
|
} catch (e) {
|
|
@@ -8997,7 +9019,7 @@ async function metaValidateCommand(path18, args) {
|
|
|
8997
9019
|
const fmt = args.output ?? "table";
|
|
8998
9020
|
if (fmt === "json" || fmt === "yaml") {
|
|
8999
9021
|
process.stdout.write(
|
|
9000
|
-
|
|
9022
|
+
formatObject20(
|
|
9001
9023
|
{
|
|
9002
9024
|
path: path18,
|
|
9003
9025
|
kind: result.kind,
|
|
@@ -9038,10 +9060,10 @@ import {
|
|
|
9038
9060
|
createWorkspaceFile,
|
|
9039
9061
|
deleteWorkspaceFile,
|
|
9040
9062
|
formatMiniVerifyReport,
|
|
9041
|
-
formatObject as
|
|
9063
|
+
formatObject as formatObject21,
|
|
9042
9064
|
formatRows as formatRows5,
|
|
9043
9065
|
getMiniStatus,
|
|
9044
|
-
HcmClient as
|
|
9066
|
+
HcmClient as HcmClient20,
|
|
9045
9067
|
initMiniAppProject,
|
|
9046
9068
|
inferMiniWritableTemplateOptionsFromModel,
|
|
9047
9069
|
listWorkspaceFiles,
|
|
@@ -9051,7 +9073,7 @@ import {
|
|
|
9051
9073
|
runMiniSmokeChecks,
|
|
9052
9074
|
saveWorkspaceFileContent,
|
|
9053
9075
|
validateMiniProject,
|
|
9054
|
-
fromAxiosError as
|
|
9076
|
+
fromAxiosError as fromAxiosError20
|
|
9055
9077
|
} from "@hcmai/sdk";
|
|
9056
9078
|
|
|
9057
9079
|
// src/commands/workspace-format.ts
|
|
@@ -9098,7 +9120,7 @@ var RAW_WORKSPACE_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
|
9098
9120
|
var RAW_WORKSPACE_EXCLUDED_FILES = /* @__PURE__ */ new Set([WORKSPACE_CONTEXT_FILE, ".DS_Store"]);
|
|
9099
9121
|
async function workspaceListCommand(args) {
|
|
9100
9122
|
try {
|
|
9101
|
-
const client3 =
|
|
9123
|
+
const client3 = HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
9102
9124
|
const limit = parsePositiveInt3(args.limit, 50, "--limit");
|
|
9103
9125
|
const result = await client3.query("TenantExtensionWorkspace", {
|
|
9104
9126
|
keyword: args.keyword,
|
|
@@ -9131,7 +9153,7 @@ async function workspaceActiveCommand(args) {
|
|
|
9131
9153
|
const ctx = await getActiveAuthContextFromCli(args, {
|
|
9132
9154
|
fallbackEnv: localContext?.profile
|
|
9133
9155
|
});
|
|
9134
|
-
const client3 =
|
|
9156
|
+
const client3 = HcmClient20.fromAuthContext(ctx);
|
|
9135
9157
|
const result = await client3.query("TenantExtensionWorkspace", {
|
|
9136
9158
|
filter: { devModeEnabled: true },
|
|
9137
9159
|
fields: ["workspaceKey", "devModeEnabled"],
|
|
@@ -9189,7 +9211,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
|
|
|
9189
9211
|
`${WORKSPACE_CONTEXT_FILE} already binds workspace '${existing.workspaceKey}'; use --force to rebind`
|
|
9190
9212
|
);
|
|
9191
9213
|
}
|
|
9192
|
-
const client3 =
|
|
9214
|
+
const client3 = HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
9193
9215
|
const normalizedWorkspaceKey = normalizeWorkspaceKey(workspaceKey);
|
|
9194
9216
|
const resp = await client3.raw().post("/api/models/TenantExtensionWorkspace", {
|
|
9195
9217
|
workspaceKey: normalizedWorkspaceKey,
|
|
@@ -9237,7 +9259,7 @@ async function workspacePullCommand(args) {
|
|
|
9237
9259
|
`workspace key is required; pass --workspace <key> or run hcm workspace bind <key> first`
|
|
9238
9260
|
);
|
|
9239
9261
|
}
|
|
9240
|
-
const client3 =
|
|
9262
|
+
const client3 = HcmClient20.fromAuthContext(
|
|
9241
9263
|
await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
|
|
9242
9264
|
);
|
|
9243
9265
|
const context = buildWorkspaceContext({
|
|
@@ -9391,7 +9413,7 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
9391
9413
|
if (!stat) {
|
|
9392
9414
|
if (manifestEntry) {
|
|
9393
9415
|
process.stdout.write(
|
|
9394
|
-
|
|
9416
|
+
formatObject21(
|
|
9395
9417
|
{
|
|
9396
9418
|
workspaceKey: context.workspaceKey,
|
|
9397
9419
|
file: normalized,
|
|
@@ -9416,7 +9438,7 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
9416
9438
|
next: `hcm workspace push --dir ${args.dir ?? "."}`
|
|
9417
9439
|
};
|
|
9418
9440
|
if (args.output === "json" || args.output === "yaml") {
|
|
9419
|
-
process.stdout.write(
|
|
9441
|
+
process.stdout.write(formatObject21(result, { format: args.output }) + "\n");
|
|
9420
9442
|
} else {
|
|
9421
9443
|
process.stdout.write(`workspace file staged for deletion: ${normalized}
|
|
9422
9444
|
`);
|
|
@@ -9463,7 +9485,7 @@ async function workspaceStatusCommand(args) {
|
|
|
9463
9485
|
}
|
|
9464
9486
|
if (args.output === "json" || args.output === "yaml") {
|
|
9465
9487
|
process.stdout.write(
|
|
9466
|
-
|
|
9488
|
+
formatObject21({ rootDir, miniApps: rows2 }, { format: args.output }) + "\n"
|
|
9467
9489
|
);
|
|
9468
9490
|
} else {
|
|
9469
9491
|
process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
|
|
@@ -9497,7 +9519,7 @@ async function workspacePushCommand(args) {
|
|
|
9497
9519
|
const rootDir = resolveRootDir(args.dir);
|
|
9498
9520
|
const context = await requireWorkspaceContext(rootDir);
|
|
9499
9521
|
const miniApps = await discoverMiniApps(rootDir);
|
|
9500
|
-
const client3 =
|
|
9522
|
+
const client3 = HcmClient20.fromAuthContext(
|
|
9501
9523
|
await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
|
|
9502
9524
|
);
|
|
9503
9525
|
const activeWorkspaceKey = args.dryRun ? null : await probeActiveWorkspaceKey(client3);
|
|
@@ -9568,7 +9590,7 @@ async function workspacePreviewCommand(args) {
|
|
|
9568
9590
|
);
|
|
9569
9591
|
}
|
|
9570
9592
|
if (args.output === "json" || args.output === "yaml") {
|
|
9571
|
-
process.stdout.write(
|
|
9593
|
+
process.stdout.write(formatObject21(rows2, { format: args.output }) + "\n");
|
|
9572
9594
|
} else {
|
|
9573
9595
|
process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
|
|
9574
9596
|
}
|
|
@@ -10045,7 +10067,7 @@ async function readMiniStatusSafely(app) {
|
|
|
10045
10067
|
async function loadProfileClient(args) {
|
|
10046
10068
|
try {
|
|
10047
10069
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
10048
|
-
return
|
|
10070
|
+
return HcmClient20.fromAuthContext(ctx);
|
|
10049
10071
|
} catch (e) {
|
|
10050
10072
|
if (args.env || args.profile) throw e;
|
|
10051
10073
|
return null;
|
|
@@ -10212,7 +10234,7 @@ function optionalText(value) {
|
|
|
10212
10234
|
}
|
|
10213
10235
|
function writeWorkspaceListResult(rows2, format, total) {
|
|
10214
10236
|
if (format !== "table") {
|
|
10215
|
-
process.stdout.write(
|
|
10237
|
+
process.stdout.write(formatObject21({ rows: rows2, total }, { format }) + "\n");
|
|
10216
10238
|
return;
|
|
10217
10239
|
}
|
|
10218
10240
|
process.stdout.write(formatRows5(toWorkspaceListRows(rows2), { format: "table" }) + "\n");
|
|
@@ -10223,7 +10245,7 @@ function writeWorkspaceListResult(rows2, format, total) {
|
|
|
10223
10245
|
}
|
|
10224
10246
|
function writeWorkspaceActiveResult(view, format) {
|
|
10225
10247
|
if (format !== "table") {
|
|
10226
|
-
process.stdout.write(
|
|
10248
|
+
process.stdout.write(formatObject21(view, { format }) + "\n");
|
|
10227
10249
|
return;
|
|
10228
10250
|
}
|
|
10229
10251
|
const rows2 = [
|
|
@@ -10245,7 +10267,7 @@ function writeWorkspaceActiveResult(view, format) {
|
|
|
10245
10267
|
}
|
|
10246
10268
|
function writeWorkspaceBindResult(context, rootDir, format) {
|
|
10247
10269
|
if (format !== "table") {
|
|
10248
|
-
process.stdout.write(
|
|
10270
|
+
process.stdout.write(formatObject21({ ...context, rootDir }, { format }) + "\n");
|
|
10249
10271
|
return;
|
|
10250
10272
|
}
|
|
10251
10273
|
process.stdout.write(
|
|
@@ -10259,7 +10281,7 @@ function writeWorkspaceBindResult(context, rootDir, format) {
|
|
|
10259
10281
|
}
|
|
10260
10282
|
function writeWorkspaceCreateResult(result, format) {
|
|
10261
10283
|
if (format !== "table") {
|
|
10262
|
-
process.stdout.write(
|
|
10284
|
+
process.stdout.write(formatObject21(result, { format }) + "\n");
|
|
10263
10285
|
return;
|
|
10264
10286
|
}
|
|
10265
10287
|
process.stdout.write(
|
|
@@ -10275,7 +10297,7 @@ function writeWorkspaceCreateResult(result, format) {
|
|
|
10275
10297
|
}
|
|
10276
10298
|
function writeWorkspacePullResult(result, format) {
|
|
10277
10299
|
if (format !== "table") {
|
|
10278
|
-
process.stdout.write(
|
|
10300
|
+
process.stdout.write(formatObject21(result, { format }) + "\n");
|
|
10279
10301
|
return;
|
|
10280
10302
|
}
|
|
10281
10303
|
const lines = [
|
|
@@ -10293,7 +10315,7 @@ function writeWorkspacePullResult(result, format) {
|
|
|
10293
10315
|
}
|
|
10294
10316
|
function writeWorkspaceAddMiniResult(result, rootDir, format) {
|
|
10295
10317
|
if (format !== "table") {
|
|
10296
|
-
process.stdout.write(
|
|
10318
|
+
process.stdout.write(formatObject21({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
|
|
10297
10319
|
return;
|
|
10298
10320
|
}
|
|
10299
10321
|
process.stdout.write(
|
|
@@ -10309,7 +10331,7 @@ function writeWorkspaceAddMiniResult(result, rootDir, format) {
|
|
|
10309
10331
|
function writeWorkspaceValidateResult(results, format) {
|
|
10310
10332
|
if (format !== "table") {
|
|
10311
10333
|
process.stdout.write(
|
|
10312
|
-
|
|
10334
|
+
formatObject21(
|
|
10313
10335
|
results.map((item) => ({ artifact: `mini:${item.app.appCode}`, ...item.result })),
|
|
10314
10336
|
{ format }
|
|
10315
10337
|
) + "\n"
|
|
@@ -10337,7 +10359,7 @@ mini:${item.app.appCode}
|
|
|
10337
10359
|
function writeWorkspacePushResult(rawResult, results, format) {
|
|
10338
10360
|
if (format !== "table") {
|
|
10339
10361
|
process.stdout.write(
|
|
10340
|
-
|
|
10362
|
+
formatObject21(
|
|
10341
10363
|
{
|
|
10342
10364
|
workspaceFiles: { artifact: "workspace", ...rawResult },
|
|
10343
10365
|
miniApps: results.map((item) => ({
|
|
@@ -10396,7 +10418,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
10396
10418
|
const ok = rawOk && reports.every((item) => item.report.ok);
|
|
10397
10419
|
if (format === "json") {
|
|
10398
10420
|
process.stdout.write(
|
|
10399
|
-
|
|
10421
|
+
formatObject21(
|
|
10400
10422
|
{
|
|
10401
10423
|
ok,
|
|
10402
10424
|
workspaceKey: context.workspaceKey,
|
|
@@ -10423,7 +10445,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
10423
10445
|
}
|
|
10424
10446
|
if (format !== "table") {
|
|
10425
10447
|
process.stdout.write(
|
|
10426
|
-
|
|
10448
|
+
formatObject21(
|
|
10427
10449
|
{
|
|
10428
10450
|
ok,
|
|
10429
10451
|
workspaceKey: context.workspaceKey,
|
|
@@ -10475,7 +10497,7 @@ function formatStatusSummary(summary) {
|
|
|
10475
10497
|
function exitWorkspaceError(err, profile) {
|
|
10476
10498
|
const maybeAxios = err;
|
|
10477
10499
|
if (maybeAxios?.isAxiosError) {
|
|
10478
|
-
exitWithError(
|
|
10500
|
+
exitWithError(fromAxiosError20(err, profile));
|
|
10479
10501
|
}
|
|
10480
10502
|
exitWithError(err);
|
|
10481
10503
|
}
|
|
@@ -10532,7 +10554,7 @@ async function requestWorkspaceDeactivation(client3) {
|
|
|
10532
10554
|
}
|
|
10533
10555
|
async function workspaceActivateCommand(workspaceKey, args) {
|
|
10534
10556
|
try {
|
|
10535
|
-
const client3 =
|
|
10557
|
+
const client3 = HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
10536
10558
|
const key2 = normalizeWorkspaceKey(workspaceKey);
|
|
10537
10559
|
await setDevModeBinding(client3, key2);
|
|
10538
10560
|
const fmt = args.output ?? "table";
|
|
@@ -10542,7 +10564,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
10542
10564
|
process.stdout.write("\u8BE5\u7A7A\u95F4\u7684 metas / scripts / menus / mini_apps \u73B0\u5DF2\u5728\u5F53\u524D\u79DF\u6237\u751F\u6548\u3002\n");
|
|
10543
10565
|
} else {
|
|
10544
10566
|
process.stdout.write(
|
|
10545
|
-
|
|
10567
|
+
formatObject21({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
|
|
10546
10568
|
);
|
|
10547
10569
|
}
|
|
10548
10570
|
process.exitCode = 0;
|
|
@@ -10553,7 +10575,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
10553
10575
|
}
|
|
10554
10576
|
async function workspaceDeactivateCommand(args) {
|
|
10555
10577
|
try {
|
|
10556
|
-
const client3 =
|
|
10578
|
+
const client3 = HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
10557
10579
|
const binding = await requestWorkspaceDeactivation(client3);
|
|
10558
10580
|
const result = { ...binding, deactivated: true };
|
|
10559
10581
|
const fmt = args.output ?? "table";
|
|
@@ -10561,7 +10583,7 @@ async function workspaceDeactivateCommand(args) {
|
|
|
10561
10583
|
process.stdout.write("workspace deactivated\n");
|
|
10562
10584
|
process.stdout.write("\u5F53\u524D\u8EAB\u4EFD\u5DF2\u9000\u51FA\u5F00\u53D1\u8005\u6A21\u5F0F\uFF1B\u5F00\u53D1\u7A7A\u95F4\u3001\u672C\u5730\u6587\u4EF6\u4E0E\u5DF2\u53D1\u5E03\u8D44\u4EA7\u5747\u672A\u5220\u9664\u3002\n");
|
|
10563
10585
|
} else {
|
|
10564
|
-
process.stdout.write(
|
|
10586
|
+
process.stdout.write(formatObject21(result, { format: fmt }) + "\n");
|
|
10565
10587
|
}
|
|
10566
10588
|
process.exitCode = 0;
|
|
10567
10589
|
return;
|
|
@@ -10577,9 +10599,9 @@ import {
|
|
|
10577
10599
|
AUTH_INFO_PATH,
|
|
10578
10600
|
CliError as CliError23,
|
|
10579
10601
|
CliErrorCode as CliErrorCode22,
|
|
10580
|
-
formatObject as
|
|
10602
|
+
formatObject as formatObject22,
|
|
10581
10603
|
formatRows as formatRows6,
|
|
10582
|
-
fromAxiosError as
|
|
10604
|
+
fromAxiosError as fromAxiosError21,
|
|
10583
10605
|
loadEnv as loadEnv4,
|
|
10584
10606
|
saveEnv as saveEnv3,
|
|
10585
10607
|
loadIdentity as loadIdentity4,
|
|
@@ -10632,9 +10654,9 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
|
|
|
10632
10654
|
async function identityShow(name, args) {
|
|
10633
10655
|
try {
|
|
10634
10656
|
const details = await inspectIdentity(name);
|
|
10635
|
-
return exitOk(
|
|
10657
|
+
return exitOk(formatObject22(details, { format: args.output ?? "json" }));
|
|
10636
10658
|
} catch (e) {
|
|
10637
|
-
exitWithError(axios4.isAxiosError(e) ?
|
|
10659
|
+
exitWithError(axios4.isAxiosError(e) ? fromAxiosError21(e, name) : e);
|
|
10638
10660
|
}
|
|
10639
10661
|
}
|
|
10640
10662
|
async function identityList(args) {
|
|
@@ -10644,7 +10666,7 @@ async function identityList(args) {
|
|
|
10644
10666
|
const names = await listIdentities4(filter);
|
|
10645
10667
|
const fmt = args.output ?? "table";
|
|
10646
10668
|
if (names.length === 0) {
|
|
10647
|
-
return exitOk(fmt === "table" ? "(no identities)" :
|
|
10669
|
+
return exitOk(fmt === "table" ? "(no identities)" : formatObject22([], { format: fmt }));
|
|
10648
10670
|
}
|
|
10649
10671
|
const rows2 = [];
|
|
10650
10672
|
for (const n of names) {
|
|
@@ -10658,7 +10680,7 @@ async function identityList(args) {
|
|
|
10658
10680
|
isDefault: env2?.defaultIdentity === n
|
|
10659
10681
|
});
|
|
10660
10682
|
}
|
|
10661
|
-
return exitOk(fmt === "table" ? formatRows6(rows2, { format: fmt }) :
|
|
10683
|
+
return exitOk(fmt === "table" ? formatRows6(rows2, { format: fmt }) : formatObject22(rows2, { format: fmt }));
|
|
10662
10684
|
} catch (e) {
|
|
10663
10685
|
exitWithError(e);
|
|
10664
10686
|
}
|
|
@@ -10710,9 +10732,9 @@ import path10 from "path";
|
|
|
10710
10732
|
import {
|
|
10711
10733
|
CliError as CliError24,
|
|
10712
10734
|
CliErrorCode as CliErrorCode23,
|
|
10713
|
-
HcmClient as
|
|
10735
|
+
HcmClient as HcmClient21,
|
|
10714
10736
|
fetchReconIdentity,
|
|
10715
|
-
formatObject as
|
|
10737
|
+
formatObject as formatObject23,
|
|
10716
10738
|
httpProbe,
|
|
10717
10739
|
isTempEnv as isTempEnv3,
|
|
10718
10740
|
listIdentities as listIdentities5,
|
|
@@ -10724,7 +10746,7 @@ import {
|
|
|
10724
10746
|
} from "@hcmai/sdk";
|
|
10725
10747
|
async function probeTokenTenant(envName, requested) {
|
|
10726
10748
|
const ctx = await getActiveAuthContextFromCli({ env: envName });
|
|
10727
|
-
const client3 =
|
|
10749
|
+
const client3 = HcmClient21.fromAuthContext(ctx);
|
|
10728
10750
|
const identity2 = await fetchReconIdentity(httpProbe(client3.raw(), "default"), requested);
|
|
10729
10751
|
return identity2?.tenantId ? String(identity2.tenantId) : void 0;
|
|
10730
10752
|
}
|
|
@@ -10822,8 +10844,8 @@ async function scaffoldChironProject(root, env2, envName) {
|
|
|
10822
10844
|
const envFile = path10.join(root, ENV_FILE);
|
|
10823
10845
|
const existing = await fs9.readFile(envFile, "utf8").catch(() => null);
|
|
10824
10846
|
if (existing !== null) {
|
|
10825
|
-
const
|
|
10826
|
-
const recorded = Object.values(
|
|
10847
|
+
const document2 = parseEnvYaml(existing);
|
|
10848
|
+
const recorded = Object.values(document2.environments).find((candidate) => candidate.endpoint === env2.endpoint && candidate.tenant === env2.tenant) ?? document2.environments[document2.default];
|
|
10827
10849
|
if (recorded.endpoint !== env2.endpoint) {
|
|
10828
10850
|
throw new CliError24({
|
|
10829
10851
|
code: CliErrorCode23.INVALID_ARGUMENT,
|
|
@@ -10909,7 +10931,7 @@ async function chironInitCommand(args, deps) {
|
|
|
10909
10931
|
const result = await runChironInit(args, deps);
|
|
10910
10932
|
const fmt = args.output ?? "table";
|
|
10911
10933
|
if (fmt === "json" || fmt === "yaml") {
|
|
10912
|
-
process.stdout.write(
|
|
10934
|
+
process.stdout.write(formatObject23(result, { format: fmt }) + "\n");
|
|
10913
10935
|
} else {
|
|
10914
10936
|
const mark = { verified: "\u2705", mismatch: "\u274C", unreachable: "\u26A0\uFE0F", skipped: "\xB7" }[result.tenantCheck.status];
|
|
10915
10937
|
process.stdout.write(
|
|
@@ -10932,7 +10954,7 @@ async function chironInitCommand(args, deps) {
|
|
|
10932
10954
|
import { readFileSync as readFileSync6 } from "fs";
|
|
10933
10955
|
import {
|
|
10934
10956
|
createHttpClient as createHttpClient4,
|
|
10935
|
-
formatObject as
|
|
10957
|
+
formatObject as formatObject24,
|
|
10936
10958
|
loadGlobalConfig as loadGlobalConfig10,
|
|
10937
10959
|
resolveEnvContext as resolveEnvContext7,
|
|
10938
10960
|
printResolvedEnvironment as printResolvedEnvironment7
|
|
@@ -11325,7 +11347,7 @@ async function gapDeps(deps) {
|
|
|
11325
11347
|
return { client: await deps.client() };
|
|
11326
11348
|
}
|
|
11327
11349
|
function emit5(fmt, data, text) {
|
|
11328
|
-
if (fmt === "json" || fmt === "yaml") process.stdout.write(
|
|
11350
|
+
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject24(data, { format: fmt }) + "\n");
|
|
11329
11351
|
else process.stdout.write(text() + "\n");
|
|
11330
11352
|
}
|
|
11331
11353
|
async function run2(fn) {
|
|
@@ -11423,10 +11445,10 @@ init_exit();
|
|
|
11423
11445
|
import { promises as fs10 } from "fs";
|
|
11424
11446
|
import path11 from "path";
|
|
11425
11447
|
import {
|
|
11426
|
-
HcmClient as
|
|
11448
|
+
HcmClient as HcmClient22,
|
|
11427
11449
|
CliError as CliError25,
|
|
11428
11450
|
fetchReconIdentity as fetchReconIdentity2,
|
|
11429
|
-
formatObject as
|
|
11451
|
+
formatObject as formatObject25,
|
|
11430
11452
|
httpProbe as httpProbe2,
|
|
11431
11453
|
conversationWebSocketEndpoint as conversationWebSocketEndpoint3,
|
|
11432
11454
|
probeConversationHandshake,
|
|
@@ -11435,7 +11457,7 @@ import {
|
|
|
11435
11457
|
var defaultDeps2 = {
|
|
11436
11458
|
anchors: async (envName, tenant2, as) => {
|
|
11437
11459
|
const ctx = await getActiveAuthContextFromCli({ env: envName, as });
|
|
11438
|
-
const client3 =
|
|
11460
|
+
const client3 = HcmClient22.fromAuthContext(ctx);
|
|
11439
11461
|
const probe = httpProbe2(client3.raw(), "default");
|
|
11440
11462
|
const identity2 = await fetchReconIdentity2(probe, tenant2);
|
|
11441
11463
|
const report = await runDoctor(probe, identity2, () => probeConversationHandshake({
|
|
@@ -11591,7 +11613,7 @@ async function chironDoctorCommand(args, deps) {
|
|
|
11591
11613
|
try {
|
|
11592
11614
|
const report = await runChironDoctor(args, deps);
|
|
11593
11615
|
const fmt = args.output ?? "table";
|
|
11594
|
-
if (fmt === "json" || fmt === "yaml") process.stdout.write(
|
|
11616
|
+
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject25(report, { format: fmt }) + "\n");
|
|
11595
11617
|
else process.stdout.write(renderChironDoctor(report) + "\n");
|
|
11596
11618
|
process.exitCode = report.ok ? 0 : 1;
|
|
11597
11619
|
} catch (e) {
|
|
@@ -11611,7 +11633,7 @@ import {
|
|
|
11611
11633
|
discoverProjectEnv as discoverProjectEnv6,
|
|
11612
11634
|
ENV_FILE as ENV_FILE2,
|
|
11613
11635
|
findEnvByEndpoint as findEnvByEndpoint5,
|
|
11614
|
-
formatObject as
|
|
11636
|
+
formatObject as formatObject26,
|
|
11615
11637
|
listIdentities as listIdentities6,
|
|
11616
11638
|
parseEnvYaml as parseEnvYaml2,
|
|
11617
11639
|
renderEnvYaml as renderEnvYaml2,
|
|
@@ -11813,7 +11835,7 @@ async function runChironEnv(action, args = {}) {
|
|
|
11813
11835
|
return report;
|
|
11814
11836
|
}
|
|
11815
11837
|
function formatChironEnvReport(report, output = "table") {
|
|
11816
|
-
if (output !== "table") return
|
|
11838
|
+
if (output !== "table") return formatObject26(report, { format: output });
|
|
11817
11839
|
const lines = [
|
|
11818
11840
|
report.action === "list" ? `\u9879\u76EE\u73AF\u5883\uFF1A${report.path}` : `\u5DF2\u5199\u5165\uFF1A${report.path}`,
|
|
11819
11841
|
formatTable(report.environments.map((env2) => ({
|
|
@@ -11847,7 +11869,7 @@ import { spawnSync } from "child_process";
|
|
|
11847
11869
|
import { accessSync, constants } from "fs";
|
|
11848
11870
|
import fs12 from "fs/promises";
|
|
11849
11871
|
import path13 from "path";
|
|
11850
|
-
import { CliError as CliError27, CliErrorCode as CliErrorCode25, formatObject as
|
|
11872
|
+
import { CliError as CliError27, CliErrorCode as CliErrorCode25, formatObject as formatObject27, HcmClient as HcmClient23, loadEnv as loadEnv6 } from "@hcmai/sdk";
|
|
11851
11873
|
var EVIDENCE_DIR = "evidence";
|
|
11852
11874
|
var WAIT_MS_MAX = 6e4;
|
|
11853
11875
|
var VIEWPORT_MIN = { width: 320, height: 240 };
|
|
@@ -12031,7 +12053,7 @@ var defaultChironPageDeps = {
|
|
|
12031
12053
|
context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
|
|
12032
12054
|
});
|
|
12033
12055
|
}
|
|
12034
|
-
const client3 =
|
|
12056
|
+
const client3 = HcmClient23.fromAuthContext(ctx);
|
|
12035
12057
|
const { ticket } = await mintBrowserTicket(client3, ctx.env)();
|
|
12036
12058
|
return { url: buildBrowserLoginUrl(frontend, ticket, sitePath), environment: ctx.env, identity: ctx.identity ?? null };
|
|
12037
12059
|
},
|
|
@@ -12067,7 +12089,7 @@ async function chironPageCommand(target, args, deps = defaultChironPageDeps) {
|
|
|
12067
12089
|
try {
|
|
12068
12090
|
const receipt = await runChironPage(target, args, deps);
|
|
12069
12091
|
const fmt = args.output ?? "table";
|
|
12070
|
-
if (fmt === "json" || fmt === "yaml") process.stdout.write(
|
|
12092
|
+
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject27(receipt, { format: fmt }) + "\n");
|
|
12071
12093
|
else process.stdout.write(renderChironPage(receipt) + "\n");
|
|
12072
12094
|
process.exitCode = receipt.ok ? 0 : 3;
|
|
12073
12095
|
} catch (e) {
|
|
@@ -12078,14 +12100,15 @@ async function chironPageCommand(target, args, deps = defaultChironPageDeps) {
|
|
|
12078
12100
|
// src/commands/chiron-test.ts
|
|
12079
12101
|
init_exit();
|
|
12080
12102
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
12103
|
+
import { randomUUID } from "crypto";
|
|
12081
12104
|
import { promises as fs13 } from "fs";
|
|
12082
12105
|
import path14 from "path";
|
|
12083
12106
|
import yaml2 from "js-yaml";
|
|
12084
|
-
import { formatObject as
|
|
12107
|
+
import { formatObject as formatObject28 } from "@hcmai/sdk";
|
|
12085
12108
|
|
|
12086
12109
|
// src/commands/delivery-action-policy.ts
|
|
12087
12110
|
init_auth_guard();
|
|
12088
|
-
import { HcmClient as
|
|
12111
|
+
import { HcmClient as HcmClient24, classifyEffect } from "@hcmai/sdk";
|
|
12089
12112
|
|
|
12090
12113
|
// src/commands/delivery.ts
|
|
12091
12114
|
import { createHash as createHash6 } from "crypto";
|
|
@@ -12376,6 +12399,10 @@ function classify(argv, actionResolution) {
|
|
|
12376
12399
|
}
|
|
12377
12400
|
if (name === "upload") return guarded("tenant-write", "document-upload");
|
|
12378
12401
|
if (name === "download") return direct("R1", "managed-local-write", "document-download");
|
|
12402
|
+
if (name === "document") {
|
|
12403
|
+
if (subcommand === "delete") return guarded("tenant-write", "document-delete");
|
|
12404
|
+
return forbidden("unknown-command", "\u672A\u77E5 document \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
|
|
12405
|
+
}
|
|
12379
12406
|
if (name === "action") {
|
|
12380
12407
|
if (actionResolution?.status === "resolved") {
|
|
12381
12408
|
return classifyAction(actionResolution.policy);
|
|
@@ -12595,7 +12622,7 @@ async function resolveCoreAction(request) {
|
|
|
12595
12622
|
as: request.identity,
|
|
12596
12623
|
profile: request.profile
|
|
12597
12624
|
});
|
|
12598
|
-
const description = await
|
|
12625
|
+
const description = await HcmClient24.fromAuthContext(auth).describe(request.model);
|
|
12599
12626
|
const named = description.actions.filter((action) => action.name === request.action);
|
|
12600
12627
|
if (named.length === 0) {
|
|
12601
12628
|
const degraded = description.effectiveActionsAvailable ? "" : `\u26A0\uFE0F \u672C\u6B21\u6BD4\u5BF9\u4E0D\u542B\u811A\u672C Action\u2014\u2014${description.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}\u3002`;
|
|
@@ -12879,14 +12906,23 @@ function matches(actual, rule) {
|
|
|
12879
12906
|
return String(actual) === want;
|
|
12880
12907
|
}
|
|
12881
12908
|
}
|
|
12909
|
+
function selfCliInvocation(argv, runtime = process) {
|
|
12910
|
+
const entry = runtime.argv[1];
|
|
12911
|
+
if (!entry) throw new Error("\u65E0\u6CD5\u786E\u5B9A\u5F53\u524D hcm CLI \u5165\u53E3\uFF0C\u4E0D\u80FD\u5B89\u5168\u6267\u884C\u56DE\u5F52\u5B50\u6B65\u9AA4");
|
|
12912
|
+
return { command: runtime.execPath, args: [entry, ...argv] };
|
|
12913
|
+
}
|
|
12914
|
+
function runSelf(argv, cwd, maxBuffer, timeout) {
|
|
12915
|
+
const invocation = selfCliInvocation(argv);
|
|
12916
|
+
return spawnSync2(invocation.command, invocation.args, { cwd, encoding: "utf8", maxBuffer, timeout });
|
|
12917
|
+
}
|
|
12882
12918
|
var defaultDeps3 = {
|
|
12883
12919
|
assess: (argv) => assessEffectiveDeliveryCommand(argv),
|
|
12884
12920
|
hcm: (argv, cwd) => {
|
|
12885
|
-
const r =
|
|
12921
|
+
const r = runSelf(argv, cwd, 1 << 26, 6e5);
|
|
12886
12922
|
return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
12887
12923
|
},
|
|
12888
12924
|
page: (root, argv) => {
|
|
12889
|
-
const r =
|
|
12925
|
+
const r = runSelf(["chiron", "page", ...argv], root, 1 << 24, 3e5);
|
|
12890
12926
|
return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
12891
12927
|
},
|
|
12892
12928
|
readXlsx: (file) => xlsxRows(file),
|
|
@@ -12924,13 +12960,20 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
|
|
|
12924
12960
|
const want = c.expect ?? {};
|
|
12925
12961
|
const bad = [];
|
|
12926
12962
|
if (want.exit !== void 0 && r2.status !== want.exit) bad.push(`\u9000\u51FA\u7801 ${r2.status} \u2260 ${want.exit}`);
|
|
12927
|
-
for (const
|
|
12928
|
-
|
|
12963
|
+
for (const raw of want.stdout_contains ?? []) {
|
|
12964
|
+
const t = fill(raw);
|
|
12965
|
+
if (!r2.stdout.includes(t)) bad.push(`\u8F93\u51FA\u91CC\u6CA1\u6709\u300C${t}\u300D`);
|
|
12966
|
+
}
|
|
12967
|
+
for (const raw of want.stdout_not_contains ?? []) {
|
|
12968
|
+
const t = fill(raw);
|
|
12969
|
+
if (r2.stdout.includes(t)) bad.push(`\u8F93\u51FA\u91CC\u51FA\u73B0\u4E86\u4E0D\u8BE5\u6709\u7684\u300C${t}\u300D`);
|
|
12970
|
+
}
|
|
12929
12971
|
if (want.json) {
|
|
12930
12972
|
const parsed = parseJsonLoose(r2.stdout);
|
|
12931
12973
|
if (parsed === void 0) bad.push("\u8F93\u51FA\u4E0D\u662F JSON\uFF0C\u65E0\u6CD5\u6309 json \u5224\u636E\u6BD4\u5BF9");
|
|
12932
12974
|
if (parsed !== void 0) {
|
|
12933
|
-
for (const [expr,
|
|
12975
|
+
for (const [expr, rawRule] of Object.entries(want.json)) {
|
|
12976
|
+
const rule = fill(rawRule);
|
|
12934
12977
|
const actual = pick(parsed, expr);
|
|
12935
12978
|
if (!matches(actual, rule)) bad.push(`${expr} \u5B9E\u9645 ${JSON.stringify(actual)}\uFF0C\u671F\u671B ${rule}`);
|
|
12936
12979
|
}
|
|
@@ -12954,23 +12997,34 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
|
|
|
12954
12997
|
if (want.xlsx_header || want.xlsx_min_rows !== void 0) {
|
|
12955
12998
|
const rows2 = deps.readXlsx(file);
|
|
12956
12999
|
const header = (rows2[0] ?? []).map((x) => String(x).trim());
|
|
12957
|
-
for (const
|
|
13000
|
+
for (const raw of want.xlsx_header ?? []) {
|
|
13001
|
+
const h = fill(raw);
|
|
13002
|
+
if (!header.includes(h)) bad.push(`\u8868\u5934\u91CC\u6CA1\u6709\u300C${h}\u300D\uFF0C\u5B9E\u9645\u662F [${header.slice(0, 8).join(", ")}]`);
|
|
13003
|
+
}
|
|
12958
13004
|
if (want.xlsx_min_rows !== void 0 && rows2.length - 1 < want.xlsx_min_rows) bad.push(`\u6570\u636E\u884C ${Math.max(rows2.length - 1, 0)} \u5C11\u4E8E ${want.xlsx_min_rows}`);
|
|
12959
13005
|
}
|
|
12960
13006
|
if (want.text_contains) {
|
|
12961
13007
|
const text = await deps.readText(file);
|
|
12962
|
-
for (const
|
|
13008
|
+
for (const raw of want.text_contains) {
|
|
13009
|
+
const t = fill(raw);
|
|
13010
|
+
if (!text.includes(t)) bad.push(`\u6587\u4EF6\u91CC\u6CA1\u6709\u300C${t}\u300D`);
|
|
13011
|
+
}
|
|
12963
13012
|
}
|
|
12964
13013
|
results.push(bad.length ? { name: c.name, verdict: "fail", detail: bad.join("\uFF1B") } : { name: c.name, verdict: "pass", detail: "" });
|
|
12965
13014
|
continue;
|
|
12966
13015
|
}
|
|
12967
|
-
const out = path14.join(
|
|
13016
|
+
const out = path14.join(
|
|
13017
|
+
"evidence",
|
|
13018
|
+
"test",
|
|
13019
|
+
opts.evidenceRunId ?? "current",
|
|
13020
|
+
`${spec.name}-${c.name}`.replace(/[^\w一-龥-]+/g, "_") + ".png"
|
|
13021
|
+
);
|
|
12968
13022
|
const argv = [fill(c.page), "--out", out, "--project", root];
|
|
12969
13023
|
if (opts.env) argv.push("--env", opts.env);
|
|
12970
13024
|
const as = c.as ?? opts.as;
|
|
12971
13025
|
if (as) argv.push("--as", as);
|
|
12972
|
-
for (const t of c.expect_text ?? []) argv.push("--expect-text", t);
|
|
12973
|
-
for (const t of c.reject_text ?? []) argv.push("--reject-text", t);
|
|
13026
|
+
for (const t of c.expect_text ?? []) argv.push("--expect-text", fill(t));
|
|
13027
|
+
for (const t of c.reject_text ?? []) argv.push("--reject-text", fill(t));
|
|
12974
13028
|
const r = deps.page(root, argv);
|
|
12975
13029
|
results.push(r.status === 0 ? { name: c.name, verdict: "pass", detail: out } : { name: c.name, verdict: "fail", detail: (r.stderr || r.stdout).trim().split("\n").slice(-1)[0] ?? `\u9000\u51FA\u7801 ${r.status}` });
|
|
12976
13030
|
} catch (e) {
|
|
@@ -12999,13 +13053,18 @@ async function chironTestCommand(target, args, deps) {
|
|
|
12999
13053
|
const report = [];
|
|
13000
13054
|
let failed2 = 0;
|
|
13001
13055
|
for (const { file, spec } of cases) {
|
|
13002
|
-
const results = await runCase(
|
|
13056
|
+
const results = await runCase(
|
|
13057
|
+
spec,
|
|
13058
|
+
root,
|
|
13059
|
+
{ env: args.env, as: args.as, evidenceRunId: randomUUID() },
|
|
13060
|
+
deps
|
|
13061
|
+
);
|
|
13003
13062
|
failed2 += results.filter((r) => r.verdict === "fail").length;
|
|
13004
13063
|
report.push({ case: spec.name, file: path14.relative(root, file), results });
|
|
13005
13064
|
}
|
|
13006
13065
|
const fmt = args.output ?? "table";
|
|
13007
13066
|
if (fmt === "json" || fmt === "yaml") {
|
|
13008
|
-
process.stdout.write(
|
|
13067
|
+
process.stdout.write(formatObject28({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
|
|
13009
13068
|
} else {
|
|
13010
13069
|
for (const c of report) {
|
|
13011
13070
|
process.stdout.write(`
|
|
@@ -13034,12 +13093,12 @@ ${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4
|
|
|
13034
13093
|
init_auth_guard();
|
|
13035
13094
|
init_exit();
|
|
13036
13095
|
import {
|
|
13037
|
-
HcmClient as
|
|
13096
|
+
HcmClient as HcmClient25,
|
|
13038
13097
|
ReconLayout,
|
|
13039
13098
|
ROUND_EXIT_CODES,
|
|
13040
13099
|
computeReconSourceKey,
|
|
13041
|
-
formatObject as
|
|
13042
|
-
fromAxiosError as
|
|
13100
|
+
formatObject as formatObject29,
|
|
13101
|
+
fromAxiosError as fromAxiosError22,
|
|
13043
13102
|
httpProbe as httpProbe3,
|
|
13044
13103
|
inspectRound,
|
|
13045
13104
|
renderRound,
|
|
@@ -13049,7 +13108,7 @@ var DEFAULT_CAPABILITIES = "default";
|
|
|
13049
13108
|
async function deliveryReconCommand(args) {
|
|
13050
13109
|
try {
|
|
13051
13110
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
13052
|
-
const client3 =
|
|
13111
|
+
const client3 = HcmClient25.fromAuthContext(ctx);
|
|
13053
13112
|
const probe = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
|
|
13054
13113
|
const sourceKey = await computeReconSourceKey(probe);
|
|
13055
13114
|
const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
|
|
@@ -13058,10 +13117,10 @@ async function deliveryReconCommand(args) {
|
|
|
13058
13117
|
onlyModel: args.model ?? null,
|
|
13059
13118
|
identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
|
|
13060
13119
|
});
|
|
13061
|
-
process.stdout.write(
|
|
13120
|
+
process.stdout.write(formatObject29(summary, { format: args.output ?? "json" }) + "\n");
|
|
13062
13121
|
} catch (e) {
|
|
13063
13122
|
const err = e;
|
|
13064
|
-
if (err?.isAxiosError) exitWithError(
|
|
13123
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.env));
|
|
13065
13124
|
exitWithError(e);
|
|
13066
13125
|
process.exit(1);
|
|
13067
13126
|
}
|
|
@@ -13072,7 +13131,7 @@ async function deliveryReconRoundCommand(args) {
|
|
|
13072
13131
|
const result = inspectRound(args.dir ?? ".");
|
|
13073
13132
|
const fmt = args.output ?? "json";
|
|
13074
13133
|
if (fmt !== "json") process.stdout.write(renderRound(result));
|
|
13075
|
-
process.stdout.write(
|
|
13134
|
+
process.stdout.write(formatObject29(result, { format: fmt }) + "\n");
|
|
13076
13135
|
code = ROUND_EXIT_CODES[result.state];
|
|
13077
13136
|
} catch (e) {
|
|
13078
13137
|
exitWithError(e);
|
|
@@ -13092,7 +13151,7 @@ import {
|
|
|
13092
13151
|
DRY_RUN_TAIL,
|
|
13093
13152
|
DriftDetected,
|
|
13094
13153
|
FORCE_STALE_FLAG,
|
|
13095
|
-
HcmClient as
|
|
13154
|
+
HcmClient as HcmClient26,
|
|
13096
13155
|
fetchReconIdentity as fetchReconIdentity3,
|
|
13097
13156
|
INIT_EXIT_CODES,
|
|
13098
13157
|
JOURNAL_STOP_KINDS,
|
|
@@ -13232,7 +13291,7 @@ async function authOrSignpost(args, cmd) {
|
|
|
13232
13291
|
}
|
|
13233
13292
|
async function deliverySeedPlanCommand(args) {
|
|
13234
13293
|
const ctx = await authOrSignpost(args, "plan");
|
|
13235
|
-
const client3 =
|
|
13294
|
+
const client3 = HcmClient26.fromAuthContext(ctx);
|
|
13236
13295
|
process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
|
|
13237
13296
|
}
|
|
13238
13297
|
function seedClient(client3, ctx) {
|
|
@@ -13406,7 +13465,7 @@ async function runSeedApply(args, client3) {
|
|
|
13406
13465
|
}
|
|
13407
13466
|
async function deliverySeedApplyCommand(args) {
|
|
13408
13467
|
const ctx = await authOrSignpost(args, "apply");
|
|
13409
|
-
const client3 =
|
|
13468
|
+
const client3 = HcmClient26.fromAuthContext(ctx);
|
|
13410
13469
|
process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
|
|
13411
13470
|
}
|
|
13412
13471
|
async function runSeedVerify(args, client3) {
|
|
@@ -13430,7 +13489,7 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
13430
13489
|
return;
|
|
13431
13490
|
}
|
|
13432
13491
|
const ctx = await authOrSignpost(args, "verify");
|
|
13433
|
-
const client3 =
|
|
13492
|
+
const client3 = HcmClient26.fromAuthContext(ctx);
|
|
13434
13493
|
process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
|
|
13435
13494
|
}
|
|
13436
13495
|
|
|
@@ -13545,7 +13604,7 @@ import {
|
|
|
13545
13604
|
CHANGE_STATES,
|
|
13546
13605
|
CHANGE_UNKNOWN,
|
|
13547
13606
|
CODE_WORDS,
|
|
13548
|
-
HcmClient as
|
|
13607
|
+
HcmClient as HcmClient27,
|
|
13549
13608
|
INIT_EXIT_CODES as INIT_EXIT_CODES3,
|
|
13550
13609
|
META_WRITE_STEPS,
|
|
13551
13610
|
META_VERIFY_STEPS,
|
|
@@ -13773,7 +13832,7 @@ function lowerCaseHeaders2(headers) {
|
|
|
13773
13832
|
}
|
|
13774
13833
|
async function deliveryMetaCommand(args) {
|
|
13775
13834
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
13776
|
-
const client3 =
|
|
13835
|
+
const client3 = HcmClient27.fromAuthContext(ctx);
|
|
13777
13836
|
process.exitCode = await runDeliveryMeta(
|
|
13778
13837
|
{ ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
|
|
13779
13838
|
metaClient(client3, ctx)
|
|
@@ -13785,7 +13844,7 @@ init_auth_guard();
|
|
|
13785
13844
|
init_exit();
|
|
13786
13845
|
import {
|
|
13787
13846
|
computeReconSourceKey as computeReconSourceKey2,
|
|
13788
|
-
HcmClient as
|
|
13847
|
+
HcmClient as HcmClient28,
|
|
13789
13848
|
httpProbe as httpProbe4,
|
|
13790
13849
|
ReconLayout as ReconLayout2,
|
|
13791
13850
|
runTriageRound
|
|
@@ -13841,7 +13900,7 @@ async function runTriage(args) {
|
|
|
13841
13900
|
return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
|
|
13842
13901
|
}
|
|
13843
13902
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
13844
|
-
const client3 =
|
|
13903
|
+
const client3 = HcmClient28.fromAuthContext(ctx);
|
|
13845
13904
|
const probe = httpProbe4(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
|
|
13846
13905
|
const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
|
|
13847
13906
|
const result = await runTriageRound(probe, artifactsDir, entriesIn);
|
|
@@ -13870,10 +13929,10 @@ async function deliveryTriageCommand(args) {
|
|
|
13870
13929
|
init_auth_guard();
|
|
13871
13930
|
init_exit();
|
|
13872
13931
|
import {
|
|
13873
|
-
HcmClient as
|
|
13932
|
+
HcmClient as HcmClient29,
|
|
13874
13933
|
adminResetPassword,
|
|
13875
|
-
formatObject as
|
|
13876
|
-
fromAxiosError as
|
|
13934
|
+
formatObject as formatObject30,
|
|
13935
|
+
fromAxiosError as fromAxiosError23,
|
|
13877
13936
|
CliError as CliError28,
|
|
13878
13937
|
CliErrorCode as CliErrorCode26
|
|
13879
13938
|
} from "@hcmai/sdk";
|
|
@@ -13904,12 +13963,12 @@ async function userResetPasswordCommand(args) {
|
|
|
13904
13963
|
try {
|
|
13905
13964
|
const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
|
|
13906
13965
|
const request = buildAdminResetPasswordRequest(args, password);
|
|
13907
|
-
const client3 =
|
|
13966
|
+
const client3 = HcmClient29.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
13908
13967
|
const result = await adminResetPassword(client3.raw(), request);
|
|
13909
|
-
process.stdout.write(
|
|
13968
|
+
process.stdout.write(formatObject30(result, { format: args.output ?? "json" }) + "\n");
|
|
13910
13969
|
} catch (cause) {
|
|
13911
13970
|
const err = cause;
|
|
13912
|
-
if (err?.isAxiosError) exitWithError(
|
|
13971
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError23(err, args.env));
|
|
13913
13972
|
exitWithError(cause);
|
|
13914
13973
|
}
|
|
13915
13974
|
}
|
|
@@ -13929,19 +13988,19 @@ async function promptPasswordTwice() {
|
|
|
13929
13988
|
init_exit();
|
|
13930
13989
|
init_auth_guard();
|
|
13931
13990
|
import {
|
|
13932
|
-
HcmClient as
|
|
13933
|
-
formatObject as
|
|
13934
|
-
fromAxiosError as
|
|
13991
|
+
HcmClient as HcmClient30,
|
|
13992
|
+
formatObject as formatObject31,
|
|
13993
|
+
fromAxiosError as fromAxiosError24
|
|
13935
13994
|
} from "@hcmai/sdk";
|
|
13936
13995
|
async function modelsCommand(keyword, args) {
|
|
13937
13996
|
try {
|
|
13938
|
-
const client3 =
|
|
13997
|
+
const client3 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
13939
13998
|
const all = await client3.listModels();
|
|
13940
13999
|
const needle = keyword?.trim().toLowerCase();
|
|
13941
14000
|
const rows2 = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
|
|
13942
14001
|
const fmt = args.output ?? "table";
|
|
13943
14002
|
if (fmt !== "table") {
|
|
13944
|
-
process.stdout.write(
|
|
14003
|
+
process.stdout.write(formatObject31({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
|
|
13945
14004
|
process.exitCode = 0;
|
|
13946
14005
|
return;
|
|
13947
14006
|
}
|
|
@@ -13968,7 +14027,7 @@ async function modelsCommand(keyword, args) {
|
|
|
13968
14027
|
return;
|
|
13969
14028
|
} catch (e) {
|
|
13970
14029
|
const err = e;
|
|
13971
|
-
if (err?.isAxiosError) exitWithError(
|
|
14030
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError24(err, args.profile));
|
|
13972
14031
|
exitWithError(e);
|
|
13973
14032
|
}
|
|
13974
14033
|
}
|
|
@@ -14177,6 +14236,8 @@ program.command("chat [prompt]").description("\u4E0E\u6570\u5B57\u5458\u5DE5 Moi
|
|
|
14177
14236
|
[]
|
|
14178
14237
|
).action((prompt, opts) => chatCommand(prompt, opts));
|
|
14179
14238
|
program.command("download <documentId>").description("\u4E0B\u8F7D HCM \u6587\u6863\u5230\u672C\u5730\uFF08\u4F1A\u8BDD\u9644\u4EF6 / \u62A5\u8868\u4EA7\u7269\uFF1B\u9ED8\u8BA4 ~/Downloads/hcm\uFF09").option("-o, --output <path>", "\u8F93\u51FA\u6587\u4EF6\u6216\u76EE\u5F55").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").action((documentId, opts) => downloadCommand(documentId, opts));
|
|
14239
|
+
var document = program.command("document").description("\u7BA1\u7406 HCM \u6587\u6863\uFF08\u4F7F\u7528\u6587\u6863\u4E13\u7528 API\uFF09");
|
|
14240
|
+
document.command("delete <documentId>").description("\u5220\u9664\u6587\u6863\u5143\u6570\u636E\u53CA\u5E95\u5C42\u5B58\u50A8\u5BF9\u8C61").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((documentId, opts) => documentDeleteCommand(documentId, opts));
|
|
14180
14241
|
var workspace = program.command("workspace").description("\u5F00\u53D1\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4\u6587\u4EF6\u5305\uFF08mini_apps / menus / metas / scripts\uFF09");
|
|
14181
14242
|
workspace.command("list").description("\u5217\u51FA\u5F53\u524D\u7528\u6237\u53EF\u8BBF\u95EE\u7684\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4").option("--keyword <text>", "\u6309\u7A7A\u95F4 Key / \u8BF4\u660E / Owner \u641C\u7D22").option("--limit <n>", "\u8FD4\u56DE\u6761\u6570", "50").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspaceListCommand(opts));
|
|
14182
14243
|
workspace.command("active").description("\u67E5\u770B\u5F53\u524D HCM \u5F00\u53D1\u6A21\u5F0F\u6FC0\u6D3B\u7A7A\u95F4\uFF0C\u5E76\u5BF9\u6BD4\u672C\u5730\u76EE\u5F55\u7ED1\u5B9A").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspaceActiveCommand(opts));
|