@hcmai/cli 0.15.2 → 0.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +240 -196
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +13 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2085,7 +2085,7 @@ __export(run_exports, {
|
|
|
2085
2085
|
});
|
|
2086
2086
|
import React3 from "react";
|
|
2087
2087
|
import { render } from "ink";
|
|
2088
|
-
import { HcmClient as HcmClient10, WsClient, DEFAULT_AGENT_ID as DEFAULT_AGENT_ID2, assertDangerWrite } from "@hcmai/sdk";
|
|
2088
|
+
import { HcmClient as HcmClient10, WsClient, DEFAULT_AGENT_ID as DEFAULT_AGENT_ID2, assertDangerWrite, conversationWebSocketEndpoint } from "@hcmai/sdk";
|
|
2089
2089
|
async function runInkRepl(args) {
|
|
2090
2090
|
if (process.stdout.isTTY) {
|
|
2091
2091
|
process.stdout.write("\x1B[>4;1m");
|
|
@@ -2096,7 +2096,7 @@ async function runInkRepl(args) {
|
|
|
2096
2096
|
assertDangerWrite(ctx.environmentSafety, "\u542F\u52A8\u4EA4\u4E92\u4F1A\u8BDD\uFF08\u53EF\u80FD\u6267\u884C\u4E1A\u52A1\u5199\u5165\uFF09");
|
|
2097
2097
|
const client3 = HcmClient10.fromAuthContext(ctx);
|
|
2098
2098
|
const ws = new WsClient({
|
|
2099
|
-
endpoint: ctx.endpoint
|
|
2099
|
+
endpoint: conversationWebSocketEndpoint(ctx.endpoint),
|
|
2100
2100
|
getAccessToken: () => client3.getAccessToken(),
|
|
2101
2101
|
onTokenExpiring: () => client3.handleRefresh()
|
|
2102
2102
|
});
|
|
@@ -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
|
)
|
|
@@ -4589,6 +4589,7 @@ init_auth_guard();
|
|
|
4589
4589
|
import {
|
|
4590
4590
|
HcmClient as HcmClient11,
|
|
4591
4591
|
WsClient as WsClient2,
|
|
4592
|
+
conversationWebSocketEndpoint as conversationWebSocketEndpoint2,
|
|
4592
4593
|
assertDangerWrite as assertDangerWrite2,
|
|
4593
4594
|
oneShot,
|
|
4594
4595
|
sendMessageAndStream as sendMessageAndStream2,
|
|
@@ -4940,7 +4941,7 @@ async function chatCommand(prompt, args) {
|
|
|
4940
4941
|
const injectOn = args.injectOn ? parseInjectOn(args.injectOn) : void 0;
|
|
4941
4942
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
4942
4943
|
assertDangerWrite2(ctx.environmentSafety, "\u53D1\u9001\u6216\u7EE7\u7EED\u4F1A\u8BDD\uFF08\u53EF\u80FD\u6267\u884C\u4E1A\u52A1\u5199\u5165\uFF09");
|
|
4943
|
-
const wsUrl = ctx.endpoint
|
|
4944
|
+
const wsUrl = conversationWebSocketEndpoint2(ctx.endpoint);
|
|
4944
4945
|
const client3 = HcmClient11.fromAuthContext(ctx);
|
|
4945
4946
|
const stateKey = ctx.env;
|
|
4946
4947
|
const agentId = args.agent ?? DEFAULT_AGENT_ID3;
|
|
@@ -5264,10 +5265,32 @@ async function downloadCommand(documentId, args) {
|
|
|
5264
5265
|
}
|
|
5265
5266
|
}
|
|
5266
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
|
+
|
|
5267
5290
|
// src/commands/trace.ts
|
|
5268
5291
|
init_exit();
|
|
5269
5292
|
init_auth_guard();
|
|
5270
|
-
import { HcmClient as
|
|
5293
|
+
import { HcmClient as HcmClient14, formatObject as formatObject11, formatRows as formatRows4, fromAxiosError as fromAxiosError12 } from "@hcmai/sdk";
|
|
5271
5294
|
function parsePositiveInt2(value, fallback, flag) {
|
|
5272
5295
|
const n = Number(value ?? fallback);
|
|
5273
5296
|
if (!Number.isInteger(n) || n <= 0) {
|
|
@@ -5662,14 +5685,14 @@ async function gatherLlmTraceTree(http, rootConvId, maxDepth = 3) {
|
|
|
5662
5685
|
}
|
|
5663
5686
|
async function traceCommand(traceId, args) {
|
|
5664
5687
|
try {
|
|
5665
|
-
const client3 =
|
|
5688
|
+
const client3 = HcmClient14.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
5666
5689
|
const http = client3.raw();
|
|
5667
5690
|
const convId = args.conv ?? (args.llmCalls ? traceId ?? void 0 : void 0);
|
|
5668
5691
|
if (convId) {
|
|
5669
5692
|
if (args.raw || args.output === "json" || args.output === "yaml") {
|
|
5670
5693
|
const body = await fetchLlmTrace(http, convId);
|
|
5671
5694
|
const fmt = args.raw ? "json" : args.output;
|
|
5672
|
-
process.stdout.write(
|
|
5695
|
+
process.stdout.write(formatObject11(body.rows, { format: fmt }) + "\n");
|
|
5673
5696
|
if (!body.rows.length) {
|
|
5674
5697
|
for (const line of describeLlmTraceEmpty(convId, body.envelope)) {
|
|
5675
5698
|
process.stderr.write(line + "\n");
|
|
@@ -5694,12 +5717,12 @@ async function traceCommand(traceId, args) {
|
|
|
5694
5717
|
const resp = await http.get(`/api/trace/${traceId}`);
|
|
5695
5718
|
const agg = resp.data ?? {};
|
|
5696
5719
|
if (args.raw) {
|
|
5697
|
-
process.stdout.write(
|
|
5720
|
+
process.stdout.write(formatObject11(agg, { format: "json" }) + "\n");
|
|
5698
5721
|
process.exitCode = 0;
|
|
5699
5722
|
return;
|
|
5700
5723
|
}
|
|
5701
5724
|
if (args.output === "json" || args.output === "yaml") {
|
|
5702
|
-
process.stdout.write(
|
|
5725
|
+
process.stdout.write(formatObject11(agg, { format: args.output }) + "\n");
|
|
5703
5726
|
process.exitCode = 0;
|
|
5704
5727
|
return;
|
|
5705
5728
|
}
|
|
@@ -5710,7 +5733,7 @@ async function traceCommand(traceId, args) {
|
|
|
5710
5733
|
exitWithError(`Span #${args.span} \u8D8A\u754C\uFF08\u5171 ${spans.length} \u6761 Tempo span\uFF09`);
|
|
5711
5734
|
return;
|
|
5712
5735
|
}
|
|
5713
|
-
process.stdout.write(
|
|
5736
|
+
process.stdout.write(formatObject11(spans[idx], { format: "yaml" }) + "\n");
|
|
5714
5737
|
process.exitCode = 0;
|
|
5715
5738
|
return;
|
|
5716
5739
|
}
|
|
@@ -5724,7 +5747,7 @@ async function traceCommand(traceId, args) {
|
|
|
5724
5747
|
} catch (e) {
|
|
5725
5748
|
const err = e;
|
|
5726
5749
|
if (err?.isAxiosError) {
|
|
5727
|
-
exitWithError(
|
|
5750
|
+
exitWithError(fromAxiosError12(err, args.profile));
|
|
5728
5751
|
}
|
|
5729
5752
|
exitWithError(e);
|
|
5730
5753
|
}
|
|
@@ -5734,27 +5757,27 @@ async function traceCommand(traceId, args) {
|
|
|
5734
5757
|
init_exit();
|
|
5735
5758
|
init_auth_guard();
|
|
5736
5759
|
import {
|
|
5737
|
-
HcmClient as
|
|
5738
|
-
formatObject as
|
|
5739
|
-
fromAxiosError as
|
|
5760
|
+
HcmClient as HcmClient15,
|
|
5761
|
+
formatObject as formatObject12,
|
|
5762
|
+
fromAxiosError as fromAxiosError13,
|
|
5740
5763
|
getCacheStats,
|
|
5741
5764
|
clearModelCache,
|
|
5742
5765
|
clearMetaCache
|
|
5743
5766
|
} from "@hcmai/sdk";
|
|
5744
5767
|
async function withClient(args, fn) {
|
|
5745
|
-
const client3 =
|
|
5768
|
+
const client3 = HcmClient15.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
5746
5769
|
return fn(client3);
|
|
5747
5770
|
}
|
|
5748
5771
|
function emit(result, args, human) {
|
|
5749
5772
|
const fmt = args.output ?? "json";
|
|
5750
5773
|
if (fmt !== "json") process.stdout.write(human + "\n");
|
|
5751
|
-
process.stdout.write(
|
|
5774
|
+
process.stdout.write(formatObject12(result, { format: fmt }) + "\n");
|
|
5752
5775
|
process.exitCode = 0;
|
|
5753
5776
|
return;
|
|
5754
5777
|
}
|
|
5755
5778
|
function fail3(e, args) {
|
|
5756
5779
|
const err = e;
|
|
5757
|
-
if (err?.isAxiosError) exitWithError(
|
|
5780
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError13(err, args.env));
|
|
5758
5781
|
exitWithError(e);
|
|
5759
5782
|
process.exit(1);
|
|
5760
5783
|
}
|
|
@@ -5792,28 +5815,28 @@ init_exit();
|
|
|
5792
5815
|
init_auth_guard();
|
|
5793
5816
|
import { readFileSync as readFileSync3 } from "fs";
|
|
5794
5817
|
import {
|
|
5795
|
-
HcmClient as
|
|
5796
|
-
formatObject as
|
|
5797
|
-
fromAxiosError as
|
|
5818
|
+
HcmClient as HcmClient16,
|
|
5819
|
+
formatObject as formatObject13,
|
|
5820
|
+
fromAxiosError as fromAxiosError14,
|
|
5798
5821
|
scriptDryRun,
|
|
5799
5822
|
validateScriptManifest,
|
|
5800
5823
|
queryScriptLogs,
|
|
5801
5824
|
getScriptTask
|
|
5802
5825
|
} from "@hcmai/sdk";
|
|
5803
5826
|
async function withClient2(args, fn) {
|
|
5804
|
-
const client3 =
|
|
5827
|
+
const client3 = HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
5805
5828
|
return fn(client3);
|
|
5806
5829
|
}
|
|
5807
5830
|
function emit2(result, args, human) {
|
|
5808
5831
|
const fmt = args.output ?? "json";
|
|
5809
5832
|
if (fmt !== "json") process.stdout.write(human + "\n");
|
|
5810
|
-
process.stdout.write(
|
|
5833
|
+
process.stdout.write(formatObject13(result, { format: fmt }) + "\n");
|
|
5811
5834
|
process.exitCode = 0;
|
|
5812
5835
|
return;
|
|
5813
5836
|
}
|
|
5814
5837
|
function fail4(e, args) {
|
|
5815
5838
|
const err = e;
|
|
5816
|
-
if (err?.isAxiosError) exitWithError(
|
|
5839
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError14(err, args.env));
|
|
5817
5840
|
exitWithError(e);
|
|
5818
5841
|
process.exit(1);
|
|
5819
5842
|
}
|
|
@@ -5903,16 +5926,16 @@ async function scriptTaskCommand(taskId, args) {
|
|
|
5903
5926
|
init_exit();
|
|
5904
5927
|
init_auth_guard();
|
|
5905
5928
|
import {
|
|
5906
|
-
HcmClient as
|
|
5907
|
-
formatObject as
|
|
5908
|
-
fromAxiosError as
|
|
5929
|
+
HcmClient as HcmClient17,
|
|
5930
|
+
formatObject as formatObject14,
|
|
5931
|
+
fromAxiosError as fromAxiosError15,
|
|
5909
5932
|
uploadDocument as uploadDocument2
|
|
5910
5933
|
} from "@hcmai/sdk";
|
|
5911
5934
|
var DEFAULT_UPLOAD_CATEGORY = "attachment";
|
|
5912
5935
|
async function uploadCommand(filePath, args) {
|
|
5913
5936
|
try {
|
|
5914
5937
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
5915
|
-
const client3 =
|
|
5938
|
+
const client3 = HcmClient17.fromAuthContext(ctx);
|
|
5916
5939
|
const meta2 = await uploadDocument2(
|
|
5917
5940
|
client3.raw(),
|
|
5918
5941
|
filePath,
|
|
@@ -5925,7 +5948,7 @@ async function uploadCommand(filePath, args) {
|
|
|
5925
5948
|
`
|
|
5926
5949
|
);
|
|
5927
5950
|
}
|
|
5928
|
-
process.stdout.write(
|
|
5951
|
+
process.stdout.write(formatObject14(meta2, { format: fmt }) + "\n");
|
|
5929
5952
|
process.exitCode = 0;
|
|
5930
5953
|
return;
|
|
5931
5954
|
} catch (e) {
|
|
@@ -5936,7 +5959,7 @@ async function uploadCommand(filePath, args) {
|
|
|
5936
5959
|
} else if (status === 413) {
|
|
5937
5960
|
exitWithError(new Error("\u6587\u4EF6\u8D85\u51FA\u670D\u52A1\u7AEF\u5927\u5C0F\u4E0A\u9650\uFF08413\uFF09"));
|
|
5938
5961
|
} else if (err?.isAxiosError) {
|
|
5939
|
-
exitWithError(
|
|
5962
|
+
exitWithError(fromAxiosError15(err, args.env));
|
|
5940
5963
|
} else {
|
|
5941
5964
|
exitWithError(e);
|
|
5942
5965
|
}
|
|
@@ -5947,9 +5970,9 @@ async function uploadCommand(filePath, args) {
|
|
|
5947
5970
|
init_exit();
|
|
5948
5971
|
init_auth_guard();
|
|
5949
5972
|
import {
|
|
5950
|
-
HcmClient as
|
|
5951
|
-
formatObject as
|
|
5952
|
-
fromAxiosError as
|
|
5973
|
+
HcmClient as HcmClient18,
|
|
5974
|
+
formatObject as formatObject15,
|
|
5975
|
+
fromAxiosError as fromAxiosError16,
|
|
5953
5976
|
packDataPackage,
|
|
5954
5977
|
installDataPackageArtifactAsync,
|
|
5955
5978
|
waitForInstallRun,
|
|
@@ -5974,7 +5997,7 @@ async function datapackagePackCommand(packageDir, args) {
|
|
|
5974
5997
|
`
|
|
5975
5998
|
);
|
|
5976
5999
|
}
|
|
5977
|
-
process.stdout.write(
|
|
6000
|
+
process.stdout.write(formatObject15(result, { format: fmt }) + "\n");
|
|
5978
6001
|
process.exitCode = 0;
|
|
5979
6002
|
return;
|
|
5980
6003
|
} catch (e) {
|
|
@@ -5984,7 +6007,7 @@ async function datapackagePackCommand(packageDir, args) {
|
|
|
5984
6007
|
async function datapackageInstallCommand(artifactPath, args) {
|
|
5985
6008
|
try {
|
|
5986
6009
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
5987
|
-
const client3 =
|
|
6010
|
+
const client3 = HcmClient18.fromAuthContext(ctx);
|
|
5988
6011
|
const fmt = args.output ?? "json";
|
|
5989
6012
|
const human = fmt !== "json";
|
|
5990
6013
|
const accepted = await installDataPackageArtifactAsync(client3, artifactPath, {
|
|
@@ -6052,7 +6075,7 @@ async function datapackageInstallCommand(artifactPath, args) {
|
|
|
6052
6075
|
if (err?.code === "ENOENT") {
|
|
6053
6076
|
exitWithError(new Error(`\u5236\u54C1\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${artifactPath}`));
|
|
6054
6077
|
} else if (err?.isAxiosError) {
|
|
6055
|
-
exitWithError(
|
|
6078
|
+
exitWithError(fromAxiosError16(err, args.env));
|
|
6056
6079
|
} else {
|
|
6057
6080
|
exitWithError(e);
|
|
6058
6081
|
}
|
|
@@ -6061,7 +6084,7 @@ async function datapackageInstallCommand(artifactPath, args) {
|
|
|
6061
6084
|
async function datapackageStatusCommand(runId, args) {
|
|
6062
6085
|
try {
|
|
6063
6086
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
6064
|
-
const client3 =
|
|
6087
|
+
const client3 = HcmClient18.fromAuthContext(ctx);
|
|
6065
6088
|
const run3 = await fetchInstallRun(client3, runId);
|
|
6066
6089
|
const fmt = args.output ?? "json";
|
|
6067
6090
|
if (!run3) {
|
|
@@ -6084,7 +6107,7 @@ async function datapackageStatusCommand(runId, args) {
|
|
|
6084
6107
|
return;
|
|
6085
6108
|
} catch (e) {
|
|
6086
6109
|
const err = e;
|
|
6087
|
-
if (err?.isAxiosError) exitWithError(
|
|
6110
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError16(err, args.env));
|
|
6088
6111
|
else exitWithError(e);
|
|
6089
6112
|
}
|
|
6090
6113
|
}
|
|
@@ -6101,7 +6124,7 @@ function truncateTail(text, max) {
|
|
|
6101
6124
|
return text.length <= max ? text : "\u2026" + text.slice(text.length - max + 1);
|
|
6102
6125
|
}
|
|
6103
6126
|
function emit3(payload, fmt) {
|
|
6104
|
-
process.stdout.write(
|
|
6127
|
+
process.stdout.write(formatObject15(payload, { format: fmt }) + "\n");
|
|
6105
6128
|
}
|
|
6106
6129
|
|
|
6107
6130
|
// src/commands/skills.ts
|
|
@@ -6125,8 +6148,8 @@ import {
|
|
|
6125
6148
|
resolveAllSkillsInstallOrder,
|
|
6126
6149
|
matchSkills,
|
|
6127
6150
|
filterByStage,
|
|
6128
|
-
formatObject as
|
|
6129
|
-
fromAxiosError as
|
|
6151
|
+
formatObject as formatObject18,
|
|
6152
|
+
fromAxiosError as fromAxiosError17,
|
|
6130
6153
|
loadGlobalConfig as loadGlobalConfig6,
|
|
6131
6154
|
discoverProjectEnv as discoverProjectEnv3,
|
|
6132
6155
|
resolveEnvContext as resolveEnvContext5,
|
|
@@ -6334,7 +6357,7 @@ import { execFileSync } from "child_process";
|
|
|
6334
6357
|
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync as readFileSync4, rmSync, statSync as statSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
6335
6358
|
import os2 from "os";
|
|
6336
6359
|
import path4 from "path";
|
|
6337
|
-
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";
|
|
6338
6361
|
var casesCacheDir = () => process.env.HCM_CASES_CACHE?.trim() || path4.join(os2.homedir(), ".cache", "hcm", "chiron-cases");
|
|
6339
6362
|
var INDEX_CACHE = () => path4.join(casesCacheDir(), "index.json");
|
|
6340
6363
|
var INDEX_TTL_MS = 60 * 60 * 1e3;
|
|
@@ -6433,7 +6456,7 @@ function matchTag(c, fp) {
|
|
|
6433
6456
|
}
|
|
6434
6457
|
function emit4(args, data, text) {
|
|
6435
6458
|
if (args.output === "json" || args.output === "yaml") {
|
|
6436
|
-
process.stdout.write(
|
|
6459
|
+
process.stdout.write(formatObject16(data, { format: args.output }) + "\n");
|
|
6437
6460
|
} else {
|
|
6438
6461
|
process.stdout.write(text() + "\n");
|
|
6439
6462
|
}
|
|
@@ -6714,7 +6737,7 @@ import { readFileSync as readFileSync5, readdirSync as readdirSync2, statSync as
|
|
|
6714
6737
|
import { createHash as createHash3 } from "crypto";
|
|
6715
6738
|
import * as path6 from "path";
|
|
6716
6739
|
import { fileURLToPath } from "url";
|
|
6717
|
-
import { formatObject as
|
|
6740
|
+
import { formatObject as formatObject17, parseSkillFrontmatter } from "@hcmai/sdk";
|
|
6718
6741
|
function collectCommandSurface(root) {
|
|
6719
6742
|
const out = [];
|
|
6720
6743
|
const walk = (cmd, prefix) => {
|
|
@@ -6790,7 +6813,7 @@ function buildManifest(root, skillsDir = bundledSkillsDir()) {
|
|
|
6790
6813
|
}
|
|
6791
6814
|
function skillsManifestCommand(root, args) {
|
|
6792
6815
|
const manifest2 = buildManifest(root);
|
|
6793
|
-
process.stdout.write(
|
|
6816
|
+
process.stdout.write(formatObject17(manifest2, { format: args.output ?? "json" }) + "\n");
|
|
6794
6817
|
}
|
|
6795
6818
|
function str(v) {
|
|
6796
6819
|
return typeof v === "string" && v ? v : void 0;
|
|
@@ -6869,14 +6892,14 @@ async function resolveBundledClosure(targetId, dir = bundledSkillsDir()) {
|
|
|
6869
6892
|
}
|
|
6870
6893
|
state.set(id, "visiting");
|
|
6871
6894
|
stack.push(id);
|
|
6872
|
-
const
|
|
6873
|
-
for (const need of parseSkillRequirements(
|
|
6895
|
+
const document2 = await readBundledSkillDocument(id, dir);
|
|
6896
|
+
for (const need of parseSkillRequirements(document2.markdown, id)) {
|
|
6874
6897
|
if (available.has(need)) await visit(need);
|
|
6875
6898
|
else external.add(need);
|
|
6876
6899
|
}
|
|
6877
6900
|
stack.pop();
|
|
6878
6901
|
state.set(id, "done");
|
|
6879
|
-
documents.push(
|
|
6902
|
+
documents.push(document2);
|
|
6880
6903
|
};
|
|
6881
6904
|
await visit(targetId);
|
|
6882
6905
|
return { documents, external: [...external].sort() };
|
|
@@ -7015,7 +7038,7 @@ function fail6(e, args) {
|
|
|
7015
7038
|
if (err?.response?.status === 404) {
|
|
7016
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"));
|
|
7017
7040
|
}
|
|
7018
|
-
if (err?.isAxiosError) exitWithError(
|
|
7041
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError17(err, args.env));
|
|
7019
7042
|
exitWithError(e);
|
|
7020
7043
|
process.exit(1);
|
|
7021
7044
|
}
|
|
@@ -7066,7 +7089,7 @@ async function skillsListCommand(keyword, args, cwd = process.cwd()) {
|
|
|
7066
7089
|
}
|
|
7067
7090
|
if (fmt === "json" || fmt === "yaml") {
|
|
7068
7091
|
process.stdout.write(
|
|
7069
|
-
|
|
7092
|
+
formatObject18(
|
|
7070
7093
|
{
|
|
7071
7094
|
...manifest2 ?? {},
|
|
7072
7095
|
categories: cats,
|
|
@@ -7155,7 +7178,7 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
7155
7178
|
const legacy = await detectLegacyFlatLayout(layout);
|
|
7156
7179
|
const legacyState = legacy ? await readSkillsState(legacy) : void 0;
|
|
7157
7180
|
if (fmt === "json" || fmt === "yaml") {
|
|
7158
|
-
process.stdout.write(
|
|
7181
|
+
process.stdout.write(formatObject18({
|
|
7159
7182
|
baseDir: layout.baseDir,
|
|
7160
7183
|
target: layout.target,
|
|
7161
7184
|
all: false,
|
|
@@ -7214,7 +7237,7 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
7214
7237
|
const shown = sourceFilter === "all" ? byKeyword : byKeyword.filter((row) => row.sourceKind === sourceFilter);
|
|
7215
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";
|
|
7216
7239
|
if (fmt === "json" || fmt === "yaml") {
|
|
7217
|
-
process.stdout.write(
|
|
7240
|
+
process.stdout.write(formatObject18({
|
|
7218
7241
|
baseDir: layout.baseDir,
|
|
7219
7242
|
target: layout.target,
|
|
7220
7243
|
endpoint: state?.endpoint,
|
|
@@ -7274,8 +7297,8 @@ async function skillsShowCommand(id, args) {
|
|
|
7274
7297
|
assertSafeSkillId(id);
|
|
7275
7298
|
const source = parseSourceFilter(args.source);
|
|
7276
7299
|
if (source !== "chiron" && listBundledSkills().some((s) => s.id === id)) {
|
|
7277
|
-
const
|
|
7278
|
-
process.stdout.write(
|
|
7300
|
+
const document2 = await readBundledSkillDocument(id);
|
|
7301
|
+
process.stdout.write(document2.markdown.endsWith("\n") ? document2.markdown : document2.markdown + "\n");
|
|
7279
7302
|
process.exitCode = 0;
|
|
7280
7303
|
return;
|
|
7281
7304
|
}
|
|
@@ -7311,10 +7334,10 @@ async function skillsInstallCommand(id, args) {
|
|
|
7311
7334
|
const seen = /* @__PURE__ */ new Set();
|
|
7312
7335
|
documents = [];
|
|
7313
7336
|
for (const one of requestedIds) {
|
|
7314
|
-
for (const
|
|
7315
|
-
if (seen.has(
|
|
7316
|
-
seen.add(
|
|
7317
|
-
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);
|
|
7318
7341
|
}
|
|
7319
7342
|
}
|
|
7320
7343
|
} else {
|
|
@@ -7421,7 +7444,7 @@ async function skillsInstallCommand(id, args) {
|
|
|
7421
7444
|
const legacyState = await readSkillsState(legacyForCheck);
|
|
7422
7445
|
const count = Object.keys(legacyState?.skills ?? {}).length;
|
|
7423
7446
|
if (fmtCheck === "json" || fmtCheck === "yaml") {
|
|
7424
|
-
process.stdout.write(
|
|
7447
|
+
process.stdout.write(formatObject18({
|
|
7425
7448
|
dryRun: true,
|
|
7426
7449
|
legacyFlatLayout: { dir: legacyForCheck, skills: count },
|
|
7427
7450
|
wouldMigrate: true,
|
|
@@ -7439,7 +7462,7 @@ async function skillsInstallCommand(id, args) {
|
|
|
7439
7462
|
}
|
|
7440
7463
|
const would = documents.map((d) => d.id).sort();
|
|
7441
7464
|
if (fmtCheck === "json" || fmtCheck === "yaml") {
|
|
7442
|
-
process.stdout.write(
|
|
7465
|
+
process.stdout.write(formatObject18({
|
|
7443
7466
|
dryRun: true,
|
|
7444
7467
|
baseDir: layout.baseDir,
|
|
7445
7468
|
target: layout.target,
|
|
@@ -7474,7 +7497,7 @@ async function skillsInstallCommand(id, args) {
|
|
|
7474
7497
|
const agents = agentIndexes[0]?.status;
|
|
7475
7498
|
const fmt = args.output ?? "table";
|
|
7476
7499
|
if (fmt === "json" || fmt === "yaml") {
|
|
7477
|
-
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");
|
|
7478
7501
|
} else {
|
|
7479
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")}`;
|
|
7480
7503
|
process.stdout.write(`${headline}
|
|
@@ -7632,7 +7655,7 @@ async function skillsPathCommand(id, args) {
|
|
|
7632
7655
|
const resolved = await resolveSkillPath(layout, id);
|
|
7633
7656
|
const fmt = args.output ?? "table";
|
|
7634
7657
|
if (fmt === "json" || fmt === "yaml") {
|
|
7635
|
-
process.stdout.write(
|
|
7658
|
+
process.stdout.write(formatObject18(resolved, { format: fmt }) + "\n");
|
|
7636
7659
|
process.exitCode = 0;
|
|
7637
7660
|
return;
|
|
7638
7661
|
}
|
|
@@ -7769,7 +7792,7 @@ async function resolveLocalSkillDocuments(sourceRoot, targetId) {
|
|
|
7769
7792
|
if (!markdown.trim()) throw invalid(`\u6280\u80FD ${id} \u5185\u5BB9\u4E3A\u7A7A`);
|
|
7770
7793
|
state.set(id, "visiting");
|
|
7771
7794
|
pathStack.push(id);
|
|
7772
|
-
const
|
|
7795
|
+
const document2 = {
|
|
7773
7796
|
id,
|
|
7774
7797
|
markdown,
|
|
7775
7798
|
source: local,
|
|
@@ -7781,7 +7804,7 @@ async function resolveLocalSkillDocuments(sourceRoot, targetId) {
|
|
|
7781
7804
|
}
|
|
7782
7805
|
pathStack.pop();
|
|
7783
7806
|
state.set(id, "done");
|
|
7784
|
-
order.push(
|
|
7807
|
+
order.push(document2);
|
|
7785
7808
|
};
|
|
7786
7809
|
await visit(targetId);
|
|
7787
7810
|
return order;
|
|
@@ -7850,15 +7873,15 @@ async function installSkillDocuments(documents, requestedIds, baseDir, force, me
|
|
|
7850
7873
|
if (requestedIds.length === 0) throw invalid("\u6CA1\u6709\u6307\u5B9A\u8981\u88C5\u7684\u6280\u80FD");
|
|
7851
7874
|
for (const id of requestedIds) assertSafeSkillId(id);
|
|
7852
7875
|
const seen = /* @__PURE__ */ new Set();
|
|
7853
|
-
const candidates = documents.map((
|
|
7854
|
-
assertSafeSkillId(
|
|
7855
|
-
if (seen.has(
|
|
7856
|
-
seen.add(
|
|
7857
|
-
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`);
|
|
7858
7881
|
return {
|
|
7859
|
-
...
|
|
7860
|
-
target: path8.join(baseDir,
|
|
7861
|
-
bytes: Buffer.byteLength(
|
|
7882
|
+
...document2,
|
|
7883
|
+
target: path8.join(baseDir, document2.id, "SKILL.md"),
|
|
7884
|
+
bytes: Buffer.byteLength(document2.markdown)
|
|
7862
7885
|
};
|
|
7863
7886
|
});
|
|
7864
7887
|
for (const id of requestedIds) {
|
|
@@ -7937,18 +7960,18 @@ async function readLocalReferences(skillDir) {
|
|
|
7937
7960
|
async function planStaleReferences(state, documents, baseDir) {
|
|
7938
7961
|
const remove = [];
|
|
7939
7962
|
const keptLocallyModified = [];
|
|
7940
|
-
for (const
|
|
7941
|
-
const recorded = state.skills[
|
|
7942
|
-
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));
|
|
7943
7966
|
for (const [relative2, recordedSha] of Object.entries(recorded)) {
|
|
7944
7967
|
if (fresh.has(relative2)) continue;
|
|
7945
|
-
const onDisk = await readInstalledReference(baseDir,
|
|
7968
|
+
const onDisk = await readInstalledReference(baseDir, document2.id, relative2);
|
|
7946
7969
|
if (onDisk === void 0) continue;
|
|
7947
7970
|
if (sha2562(onDisk) !== recordedSha) {
|
|
7948
|
-
keptLocallyModified.push({ id:
|
|
7971
|
+
keptLocallyModified.push({ id: document2.id, path: relative2 });
|
|
7949
7972
|
continue;
|
|
7950
7973
|
}
|
|
7951
|
-
remove.push({ id:
|
|
7974
|
+
remove.push({ id: document2.id, path: relative2 });
|
|
7952
7975
|
}
|
|
7953
7976
|
}
|
|
7954
7977
|
const byKey = (a, b) => `${a.id}/${a.path}`.localeCompare(`${b.id}/${b.path}`);
|
|
@@ -7986,15 +8009,15 @@ async function writeSkillDocuments(documents, baseDir, removals = []) {
|
|
|
7986
8009
|
const staged = [];
|
|
7987
8010
|
const removed = [];
|
|
7988
8011
|
try {
|
|
7989
|
-
for (const
|
|
7990
|
-
const target = path8.join(baseDir,
|
|
8012
|
+
for (const document2 of documents) {
|
|
8013
|
+
const target = path8.join(baseDir, document2.id, "SKILL.md");
|
|
7991
8014
|
await fsp2.mkdir(path8.dirname(target), { recursive: true });
|
|
7992
8015
|
const temp = path8.join(path8.dirname(target), `.SKILL.md.${process.pid}.${Date.now()}.tmp`);
|
|
7993
|
-
await fsp2.writeFile(temp,
|
|
8016
|
+
await fsp2.writeFile(temp, document2.markdown, "utf8");
|
|
7994
8017
|
staged.push({ temp, target });
|
|
7995
|
-
for (const reference of
|
|
8018
|
+
for (const reference of document2.references ?? []) {
|
|
7996
8019
|
assertSafeReferencePath2(reference.path);
|
|
7997
|
-
const referenceTarget = path8.join(baseDir,
|
|
8020
|
+
const referenceTarget = path8.join(baseDir, document2.id, "references", reference.path);
|
|
7998
8021
|
await fsp2.mkdir(path8.dirname(referenceTarget), { recursive: true });
|
|
7999
8022
|
const referenceTemp = `${referenceTarget}.${process.pid}.${Date.now()}.tmp`;
|
|
8000
8023
|
await fsp2.writeFile(referenceTemp, reference.content, "utf8");
|
|
@@ -8029,19 +8052,19 @@ async function recordInstalled(baseDir, documents, meta2) {
|
|
|
8029
8052
|
if (meta2.base !== void 0) state.base = meta2.base;
|
|
8030
8053
|
if (meta2.all) state.all = true;
|
|
8031
8054
|
state.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
8032
|
-
for (const
|
|
8033
|
-
const previous = state.skills[
|
|
8034
|
-
state.skills[
|
|
8035
|
-
source:
|
|
8055
|
+
for (const document2 of documents) {
|
|
8056
|
+
const previous = state.skills[document2.id];
|
|
8057
|
+
state.skills[document2.id] = {
|
|
8058
|
+
source: document2.source,
|
|
8036
8059
|
// 🔴 两个键同值:`source` 留给旧 CLI 读(降级不炸),新代码只读 `sourceLocator`。
|
|
8037
|
-
sourceKind:
|
|
8038
|
-
sourceLocator:
|
|
8039
|
-
sha256: sha2562(
|
|
8040
|
-
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,
|
|
8041
8064
|
// 已经是直接安装的,不因为这次作为依赖被带进来就降级
|
|
8042
|
-
direct: meta2.directIds.has(
|
|
8065
|
+
direct: meta2.directIds.has(document2.id) || Boolean(previous?.direct),
|
|
8043
8066
|
references: Object.fromEntries(
|
|
8044
|
-
(
|
|
8067
|
+
(document2.references ?? []).map((reference) => [reference.path, sha2562(reference.content)])
|
|
8045
8068
|
)
|
|
8046
8069
|
};
|
|
8047
8070
|
}
|
|
@@ -8334,7 +8357,7 @@ async function skillsUpdateCommand(args) {
|
|
|
8334
8357
|
base,
|
|
8335
8358
|
target: layout.target,
|
|
8336
8359
|
all,
|
|
8337
|
-
directIds: all ? new Set(plan.documents.map((
|
|
8360
|
+
directIds: all ? new Set(plan.documents.map((document2) => document2.id)) : /* @__PURE__ */ new Set()
|
|
8338
8361
|
});
|
|
8339
8362
|
for (const k of await removeRenamedSkills(layout.baseDir, plan.renamed)) {
|
|
8340
8363
|
process.stderr.write(`[hcm] \u6539\u540D\u6E05\u7406\u8DF3\u8FC7 ${k.from}\uFF1A${k.kept}
|
|
@@ -8346,7 +8369,7 @@ async function skillsUpdateCommand(args) {
|
|
|
8346
8369
|
const changed = plan.entries.filter((e) => e.status === "updated" || e.status === "added");
|
|
8347
8370
|
const fmt = args.output ?? "table";
|
|
8348
8371
|
if (fmt === "json" || fmt === "yaml") {
|
|
8349
|
-
process.stdout.write(
|
|
8372
|
+
process.stdout.write(formatObject18({
|
|
8350
8373
|
endpoint,
|
|
8351
8374
|
baseDir: layout.baseDir,
|
|
8352
8375
|
target: layout.target,
|
|
@@ -8576,8 +8599,8 @@ import {
|
|
|
8576
8599
|
assertDangerWrite as assertDangerWrite3,
|
|
8577
8600
|
normalizeOrigin as normalizeOrigin4,
|
|
8578
8601
|
createHttpClient as createHttpClient3,
|
|
8579
|
-
formatObject as
|
|
8580
|
-
fromAxiosError as
|
|
8602
|
+
formatObject as formatObject19,
|
|
8603
|
+
fromAxiosError as fromAxiosError18,
|
|
8581
8604
|
loadGlobalConfig as loadGlobalConfig7,
|
|
8582
8605
|
resolveEnvContext as resolveEnvContext6,
|
|
8583
8606
|
printResolvedEnvironment as printResolvedEnvironment5,
|
|
@@ -8674,7 +8697,7 @@ async function tenantBootstrapCommand(args) {
|
|
|
8674
8697
|
`
|
|
8675
8698
|
);
|
|
8676
8699
|
}
|
|
8677
|
-
process.stdout.write(
|
|
8700
|
+
process.stdout.write(formatObject19(result, { format: fmt }) + "\n");
|
|
8678
8701
|
process.exitCode = 0;
|
|
8679
8702
|
return;
|
|
8680
8703
|
} catch (e) {
|
|
@@ -8682,7 +8705,7 @@ async function tenantBootstrapCommand(args) {
|
|
|
8682
8705
|
if (err?.response?.status === 403) {
|
|
8683
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"));
|
|
8684
8707
|
} else if (err?.isAxiosError) {
|
|
8685
|
-
exitWithError(
|
|
8708
|
+
exitWithError(fromAxiosError18(err, args.env));
|
|
8686
8709
|
} else {
|
|
8687
8710
|
exitWithError(e);
|
|
8688
8711
|
}
|
|
@@ -8694,9 +8717,9 @@ import { promises as fsp3 } from "fs";
|
|
|
8694
8717
|
import os4 from "os";
|
|
8695
8718
|
import nodePath from "path";
|
|
8696
8719
|
import {
|
|
8697
|
-
HcmClient as
|
|
8698
|
-
formatObject as
|
|
8699
|
-
fromAxiosError as
|
|
8720
|
+
HcmClient as HcmClient19,
|
|
8721
|
+
formatObject as formatObject20,
|
|
8722
|
+
fromAxiosError as fromAxiosError19,
|
|
8700
8723
|
listTenantMeta,
|
|
8701
8724
|
getTenantMeta,
|
|
8702
8725
|
saveTenantMeta,
|
|
@@ -8713,7 +8736,7 @@ init_exit();
|
|
|
8713
8736
|
init_impersonation_lifecycle();
|
|
8714
8737
|
init_auth_guard();
|
|
8715
8738
|
async function client2(args) {
|
|
8716
|
-
return
|
|
8739
|
+
return HcmClient19.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
8717
8740
|
}
|
|
8718
8741
|
function formatMetaForbiddenMessage(mode = "write") {
|
|
8719
8742
|
if (mode === "read") {
|
|
@@ -8728,7 +8751,7 @@ function fail7(e, args, mode = "write") {
|
|
|
8728
8751
|
new Error(formatMetaForbiddenMessage(mode))
|
|
8729
8752
|
);
|
|
8730
8753
|
}
|
|
8731
|
-
if (err?.isAxiosError) exitWithError(
|
|
8754
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError19(err, args.env));
|
|
8732
8755
|
exitWithError(e);
|
|
8733
8756
|
process.exit(1);
|
|
8734
8757
|
}
|
|
@@ -8744,7 +8767,7 @@ async function metaListCommand(args) {
|
|
|
8744
8767
|
const fmt = args.output ?? "json";
|
|
8745
8768
|
if (fmt !== "json") process.stdout.write(`\u{1F4C4} ${items.length} \u4EFD${total ? ` / \u5171 ${total}` : ""}
|
|
8746
8769
|
`);
|
|
8747
|
-
process.stdout.write(
|
|
8770
|
+
process.stdout.write(formatObject20(items, { format: fmt }) + "\n");
|
|
8748
8771
|
process.exitCode = 0;
|
|
8749
8772
|
return;
|
|
8750
8773
|
} catch (e) {
|
|
@@ -8865,7 +8888,7 @@ async function metaSetCommand(path18, args) {
|
|
|
8865
8888
|
const dryFmt = args.output;
|
|
8866
8889
|
if (dryFmt === "json" || dryFmt === "yaml") {
|
|
8867
8890
|
process.stdout.write(
|
|
8868
|
-
|
|
8891
|
+
formatObject20(
|
|
8869
8892
|
{ dryRun: true, path: path18, bytes: Buffer.byteLength(content), content },
|
|
8870
8893
|
{ format: dryFmt }
|
|
8871
8894
|
) + "\n"
|
|
@@ -8948,7 +8971,7 @@ ${content}
|
|
|
8948
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");
|
|
8949
8972
|
}
|
|
8950
8973
|
}
|
|
8951
|
-
process.stdout.write(
|
|
8974
|
+
process.stdout.write(formatObject20(result, { format: fmt }) + "\n");
|
|
8952
8975
|
process.exitCode = 0;
|
|
8953
8976
|
return;
|
|
8954
8977
|
} catch (e) {
|
|
@@ -8970,7 +8993,7 @@ async function metaDeleteCommand(path18, args) {
|
|
|
8970
8993
|
const fmt = args.output ?? "json";
|
|
8971
8994
|
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path18}
|
|
8972
8995
|
`);
|
|
8973
|
-
process.stdout.write(
|
|
8996
|
+
process.stdout.write(formatObject20(result, { format: fmt }) + "\n");
|
|
8974
8997
|
process.exitCode = 0;
|
|
8975
8998
|
return;
|
|
8976
8999
|
} catch (e) {
|
|
@@ -8996,7 +9019,7 @@ async function metaValidateCommand(path18, args) {
|
|
|
8996
9019
|
const fmt = args.output ?? "table";
|
|
8997
9020
|
if (fmt === "json" || fmt === "yaml") {
|
|
8998
9021
|
process.stdout.write(
|
|
8999
|
-
|
|
9022
|
+
formatObject20(
|
|
9000
9023
|
{
|
|
9001
9024
|
path: path18,
|
|
9002
9025
|
kind: result.kind,
|
|
@@ -9037,10 +9060,10 @@ import {
|
|
|
9037
9060
|
createWorkspaceFile,
|
|
9038
9061
|
deleteWorkspaceFile,
|
|
9039
9062
|
formatMiniVerifyReport,
|
|
9040
|
-
formatObject as
|
|
9063
|
+
formatObject as formatObject21,
|
|
9041
9064
|
formatRows as formatRows5,
|
|
9042
9065
|
getMiniStatus,
|
|
9043
|
-
HcmClient as
|
|
9066
|
+
HcmClient as HcmClient20,
|
|
9044
9067
|
initMiniAppProject,
|
|
9045
9068
|
inferMiniWritableTemplateOptionsFromModel,
|
|
9046
9069
|
listWorkspaceFiles,
|
|
@@ -9050,7 +9073,7 @@ import {
|
|
|
9050
9073
|
runMiniSmokeChecks,
|
|
9051
9074
|
saveWorkspaceFileContent,
|
|
9052
9075
|
validateMiniProject,
|
|
9053
|
-
fromAxiosError as
|
|
9076
|
+
fromAxiosError as fromAxiosError20
|
|
9054
9077
|
} from "@hcmai/sdk";
|
|
9055
9078
|
|
|
9056
9079
|
// src/commands/workspace-format.ts
|
|
@@ -9097,7 +9120,7 @@ var RAW_WORKSPACE_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
|
9097
9120
|
var RAW_WORKSPACE_EXCLUDED_FILES = /* @__PURE__ */ new Set([WORKSPACE_CONTEXT_FILE, ".DS_Store"]);
|
|
9098
9121
|
async function workspaceListCommand(args) {
|
|
9099
9122
|
try {
|
|
9100
|
-
const client3 =
|
|
9123
|
+
const client3 = HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
9101
9124
|
const limit = parsePositiveInt3(args.limit, 50, "--limit");
|
|
9102
9125
|
const result = await client3.query("TenantExtensionWorkspace", {
|
|
9103
9126
|
keyword: args.keyword,
|
|
@@ -9130,7 +9153,7 @@ async function workspaceActiveCommand(args) {
|
|
|
9130
9153
|
const ctx = await getActiveAuthContextFromCli(args, {
|
|
9131
9154
|
fallbackEnv: localContext?.profile
|
|
9132
9155
|
});
|
|
9133
|
-
const client3 =
|
|
9156
|
+
const client3 = HcmClient20.fromAuthContext(ctx);
|
|
9134
9157
|
const result = await client3.query("TenantExtensionWorkspace", {
|
|
9135
9158
|
filter: { devModeEnabled: true },
|
|
9136
9159
|
fields: ["workspaceKey", "devModeEnabled"],
|
|
@@ -9188,7 +9211,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
|
|
|
9188
9211
|
`${WORKSPACE_CONTEXT_FILE} already binds workspace '${existing.workspaceKey}'; use --force to rebind`
|
|
9189
9212
|
);
|
|
9190
9213
|
}
|
|
9191
|
-
const client3 =
|
|
9214
|
+
const client3 = HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
9192
9215
|
const normalizedWorkspaceKey = normalizeWorkspaceKey(workspaceKey);
|
|
9193
9216
|
const resp = await client3.raw().post("/api/models/TenantExtensionWorkspace", {
|
|
9194
9217
|
workspaceKey: normalizedWorkspaceKey,
|
|
@@ -9236,7 +9259,7 @@ async function workspacePullCommand(args) {
|
|
|
9236
9259
|
`workspace key is required; pass --workspace <key> or run hcm workspace bind <key> first`
|
|
9237
9260
|
);
|
|
9238
9261
|
}
|
|
9239
|
-
const client3 =
|
|
9262
|
+
const client3 = HcmClient20.fromAuthContext(
|
|
9240
9263
|
await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
|
|
9241
9264
|
);
|
|
9242
9265
|
const context = buildWorkspaceContext({
|
|
@@ -9390,7 +9413,7 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
9390
9413
|
if (!stat) {
|
|
9391
9414
|
if (manifestEntry) {
|
|
9392
9415
|
process.stdout.write(
|
|
9393
|
-
|
|
9416
|
+
formatObject21(
|
|
9394
9417
|
{
|
|
9395
9418
|
workspaceKey: context.workspaceKey,
|
|
9396
9419
|
file: normalized,
|
|
@@ -9415,7 +9438,7 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
9415
9438
|
next: `hcm workspace push --dir ${args.dir ?? "."}`
|
|
9416
9439
|
};
|
|
9417
9440
|
if (args.output === "json" || args.output === "yaml") {
|
|
9418
|
-
process.stdout.write(
|
|
9441
|
+
process.stdout.write(formatObject21(result, { format: args.output }) + "\n");
|
|
9419
9442
|
} else {
|
|
9420
9443
|
process.stdout.write(`workspace file staged for deletion: ${normalized}
|
|
9421
9444
|
`);
|
|
@@ -9462,7 +9485,7 @@ async function workspaceStatusCommand(args) {
|
|
|
9462
9485
|
}
|
|
9463
9486
|
if (args.output === "json" || args.output === "yaml") {
|
|
9464
9487
|
process.stdout.write(
|
|
9465
|
-
|
|
9488
|
+
formatObject21({ rootDir, miniApps: rows2 }, { format: args.output }) + "\n"
|
|
9466
9489
|
);
|
|
9467
9490
|
} else {
|
|
9468
9491
|
process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
|
|
@@ -9496,7 +9519,7 @@ async function workspacePushCommand(args) {
|
|
|
9496
9519
|
const rootDir = resolveRootDir(args.dir);
|
|
9497
9520
|
const context = await requireWorkspaceContext(rootDir);
|
|
9498
9521
|
const miniApps = await discoverMiniApps(rootDir);
|
|
9499
|
-
const client3 =
|
|
9522
|
+
const client3 = HcmClient20.fromAuthContext(
|
|
9500
9523
|
await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
|
|
9501
9524
|
);
|
|
9502
9525
|
const activeWorkspaceKey = args.dryRun ? null : await probeActiveWorkspaceKey(client3);
|
|
@@ -9567,7 +9590,7 @@ async function workspacePreviewCommand(args) {
|
|
|
9567
9590
|
);
|
|
9568
9591
|
}
|
|
9569
9592
|
if (args.output === "json" || args.output === "yaml") {
|
|
9570
|
-
process.stdout.write(
|
|
9593
|
+
process.stdout.write(formatObject21(rows2, { format: args.output }) + "\n");
|
|
9571
9594
|
} else {
|
|
9572
9595
|
process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
|
|
9573
9596
|
}
|
|
@@ -10044,7 +10067,7 @@ async function readMiniStatusSafely(app) {
|
|
|
10044
10067
|
async function loadProfileClient(args) {
|
|
10045
10068
|
try {
|
|
10046
10069
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
10047
|
-
return
|
|
10070
|
+
return HcmClient20.fromAuthContext(ctx);
|
|
10048
10071
|
} catch (e) {
|
|
10049
10072
|
if (args.env || args.profile) throw e;
|
|
10050
10073
|
return null;
|
|
@@ -10211,7 +10234,7 @@ function optionalText(value) {
|
|
|
10211
10234
|
}
|
|
10212
10235
|
function writeWorkspaceListResult(rows2, format, total) {
|
|
10213
10236
|
if (format !== "table") {
|
|
10214
|
-
process.stdout.write(
|
|
10237
|
+
process.stdout.write(formatObject21({ rows: rows2, total }, { format }) + "\n");
|
|
10215
10238
|
return;
|
|
10216
10239
|
}
|
|
10217
10240
|
process.stdout.write(formatRows5(toWorkspaceListRows(rows2), { format: "table" }) + "\n");
|
|
@@ -10222,7 +10245,7 @@ function writeWorkspaceListResult(rows2, format, total) {
|
|
|
10222
10245
|
}
|
|
10223
10246
|
function writeWorkspaceActiveResult(view, format) {
|
|
10224
10247
|
if (format !== "table") {
|
|
10225
|
-
process.stdout.write(
|
|
10248
|
+
process.stdout.write(formatObject21(view, { format }) + "\n");
|
|
10226
10249
|
return;
|
|
10227
10250
|
}
|
|
10228
10251
|
const rows2 = [
|
|
@@ -10244,7 +10267,7 @@ function writeWorkspaceActiveResult(view, format) {
|
|
|
10244
10267
|
}
|
|
10245
10268
|
function writeWorkspaceBindResult(context, rootDir, format) {
|
|
10246
10269
|
if (format !== "table") {
|
|
10247
|
-
process.stdout.write(
|
|
10270
|
+
process.stdout.write(formatObject21({ ...context, rootDir }, { format }) + "\n");
|
|
10248
10271
|
return;
|
|
10249
10272
|
}
|
|
10250
10273
|
process.stdout.write(
|
|
@@ -10258,7 +10281,7 @@ function writeWorkspaceBindResult(context, rootDir, format) {
|
|
|
10258
10281
|
}
|
|
10259
10282
|
function writeWorkspaceCreateResult(result, format) {
|
|
10260
10283
|
if (format !== "table") {
|
|
10261
|
-
process.stdout.write(
|
|
10284
|
+
process.stdout.write(formatObject21(result, { format }) + "\n");
|
|
10262
10285
|
return;
|
|
10263
10286
|
}
|
|
10264
10287
|
process.stdout.write(
|
|
@@ -10274,7 +10297,7 @@ function writeWorkspaceCreateResult(result, format) {
|
|
|
10274
10297
|
}
|
|
10275
10298
|
function writeWorkspacePullResult(result, format) {
|
|
10276
10299
|
if (format !== "table") {
|
|
10277
|
-
process.stdout.write(
|
|
10300
|
+
process.stdout.write(formatObject21(result, { format }) + "\n");
|
|
10278
10301
|
return;
|
|
10279
10302
|
}
|
|
10280
10303
|
const lines = [
|
|
@@ -10292,7 +10315,7 @@ function writeWorkspacePullResult(result, format) {
|
|
|
10292
10315
|
}
|
|
10293
10316
|
function writeWorkspaceAddMiniResult(result, rootDir, format) {
|
|
10294
10317
|
if (format !== "table") {
|
|
10295
|
-
process.stdout.write(
|
|
10318
|
+
process.stdout.write(formatObject21({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
|
|
10296
10319
|
return;
|
|
10297
10320
|
}
|
|
10298
10321
|
process.stdout.write(
|
|
@@ -10308,7 +10331,7 @@ function writeWorkspaceAddMiniResult(result, rootDir, format) {
|
|
|
10308
10331
|
function writeWorkspaceValidateResult(results, format) {
|
|
10309
10332
|
if (format !== "table") {
|
|
10310
10333
|
process.stdout.write(
|
|
10311
|
-
|
|
10334
|
+
formatObject21(
|
|
10312
10335
|
results.map((item) => ({ artifact: `mini:${item.app.appCode}`, ...item.result })),
|
|
10313
10336
|
{ format }
|
|
10314
10337
|
) + "\n"
|
|
@@ -10336,7 +10359,7 @@ mini:${item.app.appCode}
|
|
|
10336
10359
|
function writeWorkspacePushResult(rawResult, results, format) {
|
|
10337
10360
|
if (format !== "table") {
|
|
10338
10361
|
process.stdout.write(
|
|
10339
|
-
|
|
10362
|
+
formatObject21(
|
|
10340
10363
|
{
|
|
10341
10364
|
workspaceFiles: { artifact: "workspace", ...rawResult },
|
|
10342
10365
|
miniApps: results.map((item) => ({
|
|
@@ -10395,7 +10418,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
10395
10418
|
const ok = rawOk && reports.every((item) => item.report.ok);
|
|
10396
10419
|
if (format === "json") {
|
|
10397
10420
|
process.stdout.write(
|
|
10398
|
-
|
|
10421
|
+
formatObject21(
|
|
10399
10422
|
{
|
|
10400
10423
|
ok,
|
|
10401
10424
|
workspaceKey: context.workspaceKey,
|
|
@@ -10422,7 +10445,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
10422
10445
|
}
|
|
10423
10446
|
if (format !== "table") {
|
|
10424
10447
|
process.stdout.write(
|
|
10425
|
-
|
|
10448
|
+
formatObject21(
|
|
10426
10449
|
{
|
|
10427
10450
|
ok,
|
|
10428
10451
|
workspaceKey: context.workspaceKey,
|
|
@@ -10474,7 +10497,7 @@ function formatStatusSummary(summary) {
|
|
|
10474
10497
|
function exitWorkspaceError(err, profile) {
|
|
10475
10498
|
const maybeAxios = err;
|
|
10476
10499
|
if (maybeAxios?.isAxiosError) {
|
|
10477
|
-
exitWithError(
|
|
10500
|
+
exitWithError(fromAxiosError20(err, profile));
|
|
10478
10501
|
}
|
|
10479
10502
|
exitWithError(err);
|
|
10480
10503
|
}
|
|
@@ -10531,7 +10554,7 @@ async function requestWorkspaceDeactivation(client3) {
|
|
|
10531
10554
|
}
|
|
10532
10555
|
async function workspaceActivateCommand(workspaceKey, args) {
|
|
10533
10556
|
try {
|
|
10534
|
-
const client3 =
|
|
10557
|
+
const client3 = HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
10535
10558
|
const key2 = normalizeWorkspaceKey(workspaceKey);
|
|
10536
10559
|
await setDevModeBinding(client3, key2);
|
|
10537
10560
|
const fmt = args.output ?? "table";
|
|
@@ -10541,7 +10564,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
10541
10564
|
process.stdout.write("\u8BE5\u7A7A\u95F4\u7684 metas / scripts / menus / mini_apps \u73B0\u5DF2\u5728\u5F53\u524D\u79DF\u6237\u751F\u6548\u3002\n");
|
|
10542
10565
|
} else {
|
|
10543
10566
|
process.stdout.write(
|
|
10544
|
-
|
|
10567
|
+
formatObject21({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
|
|
10545
10568
|
);
|
|
10546
10569
|
}
|
|
10547
10570
|
process.exitCode = 0;
|
|
@@ -10552,7 +10575,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
10552
10575
|
}
|
|
10553
10576
|
async function workspaceDeactivateCommand(args) {
|
|
10554
10577
|
try {
|
|
10555
|
-
const client3 =
|
|
10578
|
+
const client3 = HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
10556
10579
|
const binding = await requestWorkspaceDeactivation(client3);
|
|
10557
10580
|
const result = { ...binding, deactivated: true };
|
|
10558
10581
|
const fmt = args.output ?? "table";
|
|
@@ -10560,7 +10583,7 @@ async function workspaceDeactivateCommand(args) {
|
|
|
10560
10583
|
process.stdout.write("workspace deactivated\n");
|
|
10561
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");
|
|
10562
10585
|
} else {
|
|
10563
|
-
process.stdout.write(
|
|
10586
|
+
process.stdout.write(formatObject21(result, { format: fmt }) + "\n");
|
|
10564
10587
|
}
|
|
10565
10588
|
process.exitCode = 0;
|
|
10566
10589
|
return;
|
|
@@ -10576,9 +10599,9 @@ import {
|
|
|
10576
10599
|
AUTH_INFO_PATH,
|
|
10577
10600
|
CliError as CliError23,
|
|
10578
10601
|
CliErrorCode as CliErrorCode22,
|
|
10579
|
-
formatObject as
|
|
10602
|
+
formatObject as formatObject22,
|
|
10580
10603
|
formatRows as formatRows6,
|
|
10581
|
-
fromAxiosError as
|
|
10604
|
+
fromAxiosError as fromAxiosError21,
|
|
10582
10605
|
loadEnv as loadEnv4,
|
|
10583
10606
|
saveEnv as saveEnv3,
|
|
10584
10607
|
loadIdentity as loadIdentity4,
|
|
@@ -10631,9 +10654,9 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
|
|
|
10631
10654
|
async function identityShow(name, args) {
|
|
10632
10655
|
try {
|
|
10633
10656
|
const details = await inspectIdentity(name);
|
|
10634
|
-
return exitOk(
|
|
10657
|
+
return exitOk(formatObject22(details, { format: args.output ?? "json" }));
|
|
10635
10658
|
} catch (e) {
|
|
10636
|
-
exitWithError(axios4.isAxiosError(e) ?
|
|
10659
|
+
exitWithError(axios4.isAxiosError(e) ? fromAxiosError21(e, name) : e);
|
|
10637
10660
|
}
|
|
10638
10661
|
}
|
|
10639
10662
|
async function identityList(args) {
|
|
@@ -10643,7 +10666,7 @@ async function identityList(args) {
|
|
|
10643
10666
|
const names = await listIdentities4(filter);
|
|
10644
10667
|
const fmt = args.output ?? "table";
|
|
10645
10668
|
if (names.length === 0) {
|
|
10646
|
-
return exitOk(fmt === "table" ? "(no identities)" :
|
|
10669
|
+
return exitOk(fmt === "table" ? "(no identities)" : formatObject22([], { format: fmt }));
|
|
10647
10670
|
}
|
|
10648
10671
|
const rows2 = [];
|
|
10649
10672
|
for (const n of names) {
|
|
@@ -10657,7 +10680,7 @@ async function identityList(args) {
|
|
|
10657
10680
|
isDefault: env2?.defaultIdentity === n
|
|
10658
10681
|
});
|
|
10659
10682
|
}
|
|
10660
|
-
return exitOk(fmt === "table" ? formatRows6(rows2, { format: fmt }) :
|
|
10683
|
+
return exitOk(fmt === "table" ? formatRows6(rows2, { format: fmt }) : formatObject22(rows2, { format: fmt }));
|
|
10661
10684
|
} catch (e) {
|
|
10662
10685
|
exitWithError(e);
|
|
10663
10686
|
}
|
|
@@ -10709,9 +10732,9 @@ import path10 from "path";
|
|
|
10709
10732
|
import {
|
|
10710
10733
|
CliError as CliError24,
|
|
10711
10734
|
CliErrorCode as CliErrorCode23,
|
|
10712
|
-
HcmClient as
|
|
10735
|
+
HcmClient as HcmClient21,
|
|
10713
10736
|
fetchReconIdentity,
|
|
10714
|
-
formatObject as
|
|
10737
|
+
formatObject as formatObject23,
|
|
10715
10738
|
httpProbe,
|
|
10716
10739
|
isTempEnv as isTempEnv3,
|
|
10717
10740
|
listIdentities as listIdentities5,
|
|
@@ -10723,7 +10746,7 @@ import {
|
|
|
10723
10746
|
} from "@hcmai/sdk";
|
|
10724
10747
|
async function probeTokenTenant(envName, requested) {
|
|
10725
10748
|
const ctx = await getActiveAuthContextFromCli({ env: envName });
|
|
10726
|
-
const client3 =
|
|
10749
|
+
const client3 = HcmClient21.fromAuthContext(ctx);
|
|
10727
10750
|
const identity2 = await fetchReconIdentity(httpProbe(client3.raw(), "default"), requested);
|
|
10728
10751
|
return identity2?.tenantId ? String(identity2.tenantId) : void 0;
|
|
10729
10752
|
}
|
|
@@ -10821,8 +10844,8 @@ async function scaffoldChironProject(root, env2, envName) {
|
|
|
10821
10844
|
const envFile = path10.join(root, ENV_FILE);
|
|
10822
10845
|
const existing = await fs9.readFile(envFile, "utf8").catch(() => null);
|
|
10823
10846
|
if (existing !== null) {
|
|
10824
|
-
const
|
|
10825
|
-
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];
|
|
10826
10849
|
if (recorded.endpoint !== env2.endpoint) {
|
|
10827
10850
|
throw new CliError24({
|
|
10828
10851
|
code: CliErrorCode23.INVALID_ARGUMENT,
|
|
@@ -10908,7 +10931,7 @@ async function chironInitCommand(args, deps) {
|
|
|
10908
10931
|
const result = await runChironInit(args, deps);
|
|
10909
10932
|
const fmt = args.output ?? "table";
|
|
10910
10933
|
if (fmt === "json" || fmt === "yaml") {
|
|
10911
|
-
process.stdout.write(
|
|
10934
|
+
process.stdout.write(formatObject23(result, { format: fmt }) + "\n");
|
|
10912
10935
|
} else {
|
|
10913
10936
|
const mark = { verified: "\u2705", mismatch: "\u274C", unreachable: "\u26A0\uFE0F", skipped: "\xB7" }[result.tenantCheck.status];
|
|
10914
10937
|
process.stdout.write(
|
|
@@ -10931,7 +10954,7 @@ async function chironInitCommand(args, deps) {
|
|
|
10931
10954
|
import { readFileSync as readFileSync6 } from "fs";
|
|
10932
10955
|
import {
|
|
10933
10956
|
createHttpClient as createHttpClient4,
|
|
10934
|
-
formatObject as
|
|
10957
|
+
formatObject as formatObject24,
|
|
10935
10958
|
loadGlobalConfig as loadGlobalConfig10,
|
|
10936
10959
|
resolveEnvContext as resolveEnvContext7,
|
|
10937
10960
|
printResolvedEnvironment as printResolvedEnvironment7
|
|
@@ -11324,7 +11347,7 @@ async function gapDeps(deps) {
|
|
|
11324
11347
|
return { client: await deps.client() };
|
|
11325
11348
|
}
|
|
11326
11349
|
function emit5(fmt, data, text) {
|
|
11327
|
-
if (fmt === "json" || fmt === "yaml") process.stdout.write(
|
|
11350
|
+
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject24(data, { format: fmt }) + "\n");
|
|
11328
11351
|
else process.stdout.write(text() + "\n");
|
|
11329
11352
|
}
|
|
11330
11353
|
async function run2(fn) {
|
|
@@ -11422,20 +11445,26 @@ init_exit();
|
|
|
11422
11445
|
import { promises as fs10 } from "fs";
|
|
11423
11446
|
import path11 from "path";
|
|
11424
11447
|
import {
|
|
11425
|
-
HcmClient as
|
|
11448
|
+
HcmClient as HcmClient22,
|
|
11426
11449
|
CliError as CliError25,
|
|
11427
11450
|
fetchReconIdentity as fetchReconIdentity2,
|
|
11428
|
-
formatObject as
|
|
11451
|
+
formatObject as formatObject25,
|
|
11429
11452
|
httpProbe as httpProbe2,
|
|
11453
|
+
conversationWebSocketEndpoint as conversationWebSocketEndpoint3,
|
|
11454
|
+
probeConversationHandshake,
|
|
11430
11455
|
runDoctor
|
|
11431
11456
|
} from "@hcmai/sdk";
|
|
11432
11457
|
var defaultDeps2 = {
|
|
11433
11458
|
anchors: async (envName, tenant2, as) => {
|
|
11434
11459
|
const ctx = await getActiveAuthContextFromCli({ env: envName, as });
|
|
11435
|
-
const client3 =
|
|
11460
|
+
const client3 = HcmClient22.fromAuthContext(ctx);
|
|
11436
11461
|
const probe = httpProbe2(client3.raw(), "default");
|
|
11437
11462
|
const identity2 = await fetchReconIdentity2(probe, tenant2);
|
|
11438
|
-
|
|
11463
|
+
const report = await runDoctor(probe, identity2, () => probeConversationHandshake({
|
|
11464
|
+
endpoint: conversationWebSocketEndpoint3(ctx.endpoint),
|
|
11465
|
+
getAccessToken: () => client3.getAccessToken()
|
|
11466
|
+
}));
|
|
11467
|
+
return { report, tokenTenant: identity2?.tenantId ? String(identity2.tenantId) : void 0 };
|
|
11439
11468
|
},
|
|
11440
11469
|
inspectCases: () => inspectCaseLibrary(),
|
|
11441
11470
|
inspectJira: () => inspectJira()
|
|
@@ -11478,7 +11507,8 @@ async function runChironDoctor(args, deps = defaultDeps2) {
|
|
|
11478
11507
|
for (const name of targets) {
|
|
11479
11508
|
const env3 = file.environments[name];
|
|
11480
11509
|
const isDefault = name === file.default;
|
|
11481
|
-
const
|
|
11510
|
+
const selected = isDefault || args.env !== void 0;
|
|
11511
|
+
const severity = () => selected ? "fail" : "warn";
|
|
11482
11512
|
const label = `${name}${isDefault ? "\uFF08default\uFF09" : ""}${env3.danger ? " \xB7 danger" : ""}`;
|
|
11483
11513
|
const found = await findEnvByEndpoint3(env3.endpoint, env3.tenant);
|
|
11484
11514
|
const loginCmd = names.length > 1 ? `hcm login --env ${name}` : `hcm login ${env3.endpoint}`;
|
|
@@ -11486,11 +11516,12 @@ async function runChironDoctor(args, deps = defaultDeps2) {
|
|
|
11486
11516
|
report.lines.push({ item: "\u767B\u5F55", verdict: severity(), detail: `${label} \xB7 \u672C\u673A\u6CA1\u6709\u767B\u5F55\u8FC7 ${env3.endpoint}`, nextStep: loginCmd });
|
|
11487
11517
|
continue;
|
|
11488
11518
|
}
|
|
11489
|
-
if (
|
|
11519
|
+
if (selected) report.envName = found.name;
|
|
11490
11520
|
try {
|
|
11491
11521
|
const targetEnv = name;
|
|
11492
11522
|
const { report: anchors, tokenTenant: tokenTenant2 } = await deps.anchors(targetEnv, env3.tenant, args.as);
|
|
11493
|
-
if (
|
|
11523
|
+
if (selected) report.anchors = anchors;
|
|
11524
|
+
(report.environmentAnchors ??= {})[name] = anchors;
|
|
11494
11525
|
const tenantMismatch = tokenTenant2 && tokenTenant2 !== env3.tenant;
|
|
11495
11526
|
const bad = anchors.checks.filter((c) => !c.ok && !(tenantMismatch && c.anchor === "identity"));
|
|
11496
11527
|
if (bad.length === 0 && !tenantMismatch) {
|
|
@@ -11567,6 +11598,13 @@ function renderChironDoctor(report) {
|
|
|
11567
11598
|
out.push(`${mark[l.verdict]} ${l.item.padEnd(3, "\u3000")} ${l.detail}`);
|
|
11568
11599
|
if (l.nextStep && l.verdict !== "ok") out.push(` \u2192 ${l.nextStep}`);
|
|
11569
11600
|
}
|
|
11601
|
+
const environments = report.environmentAnchors ?? (report.anchors ? { default: report.anchors } : {});
|
|
11602
|
+
for (const [name, anchors] of Object.entries(environments)) {
|
|
11603
|
+
for (const check of anchors.checks) {
|
|
11604
|
+
out.push(`${check.ok ? mark.ok : mark.fail} ${name} \xB7 ${check.anchor} ${check.detail}`);
|
|
11605
|
+
if (check.nextStep) out.push(` \u2192 ${check.nextStep}`);
|
|
11606
|
+
}
|
|
11607
|
+
}
|
|
11570
11608
|
out.push("");
|
|
11571
11609
|
out.push(report.ok ? "\u53EF\u4EE5\u5F00\u5DE5\uFF1A\u5728\u8FD9\u4E2A\u76EE\u5F55\u91CC\u542F\u52A8 codex\u3002" : "\u5148\u6309 \u2192 \u5904\u7406\u7EA2\u9879\uFF0C\u518D\u8DD1\u4E00\u6B21 hcm chiron doctor\u3002");
|
|
11572
11610
|
return out.join("\n");
|
|
@@ -11575,7 +11613,7 @@ async function chironDoctorCommand(args, deps) {
|
|
|
11575
11613
|
try {
|
|
11576
11614
|
const report = await runChironDoctor(args, deps);
|
|
11577
11615
|
const fmt = args.output ?? "table";
|
|
11578
|
-
if (fmt === "json" || fmt === "yaml") process.stdout.write(
|
|
11616
|
+
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject25(report, { format: fmt }) + "\n");
|
|
11579
11617
|
else process.stdout.write(renderChironDoctor(report) + "\n");
|
|
11580
11618
|
process.exitCode = report.ok ? 0 : 1;
|
|
11581
11619
|
} catch (e) {
|
|
@@ -11595,7 +11633,7 @@ import {
|
|
|
11595
11633
|
discoverProjectEnv as discoverProjectEnv6,
|
|
11596
11634
|
ENV_FILE as ENV_FILE2,
|
|
11597
11635
|
findEnvByEndpoint as findEnvByEndpoint5,
|
|
11598
|
-
formatObject as
|
|
11636
|
+
formatObject as formatObject26,
|
|
11599
11637
|
listIdentities as listIdentities6,
|
|
11600
11638
|
parseEnvYaml as parseEnvYaml2,
|
|
11601
11639
|
renderEnvYaml as renderEnvYaml2,
|
|
@@ -11797,7 +11835,7 @@ async function runChironEnv(action, args = {}) {
|
|
|
11797
11835
|
return report;
|
|
11798
11836
|
}
|
|
11799
11837
|
function formatChironEnvReport(report, output = "table") {
|
|
11800
|
-
if (output !== "table") return
|
|
11838
|
+
if (output !== "table") return formatObject26(report, { format: output });
|
|
11801
11839
|
const lines = [
|
|
11802
11840
|
report.action === "list" ? `\u9879\u76EE\u73AF\u5883\uFF1A${report.path}` : `\u5DF2\u5199\u5165\uFF1A${report.path}`,
|
|
11803
11841
|
formatTable(report.environments.map((env2) => ({
|
|
@@ -11831,7 +11869,7 @@ import { spawnSync } from "child_process";
|
|
|
11831
11869
|
import { accessSync, constants } from "fs";
|
|
11832
11870
|
import fs12 from "fs/promises";
|
|
11833
11871
|
import path13 from "path";
|
|
11834
|
-
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";
|
|
11835
11873
|
var EVIDENCE_DIR = "evidence";
|
|
11836
11874
|
var WAIT_MS_MAX = 6e4;
|
|
11837
11875
|
var VIEWPORT_MIN = { width: 320, height: 240 };
|
|
@@ -12015,7 +12053,7 @@ var defaultChironPageDeps = {
|
|
|
12015
12053
|
context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
|
|
12016
12054
|
});
|
|
12017
12055
|
}
|
|
12018
|
-
const client3 =
|
|
12056
|
+
const client3 = HcmClient23.fromAuthContext(ctx);
|
|
12019
12057
|
const { ticket } = await mintBrowserTicket(client3, ctx.env)();
|
|
12020
12058
|
return { url: buildBrowserLoginUrl(frontend, ticket, sitePath), environment: ctx.env, identity: ctx.identity ?? null };
|
|
12021
12059
|
},
|
|
@@ -12051,7 +12089,7 @@ async function chironPageCommand(target, args, deps = defaultChironPageDeps) {
|
|
|
12051
12089
|
try {
|
|
12052
12090
|
const receipt = await runChironPage(target, args, deps);
|
|
12053
12091
|
const fmt = args.output ?? "table";
|
|
12054
|
-
if (fmt === "json" || fmt === "yaml") process.stdout.write(
|
|
12092
|
+
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject27(receipt, { format: fmt }) + "\n");
|
|
12055
12093
|
else process.stdout.write(renderChironPage(receipt) + "\n");
|
|
12056
12094
|
process.exitCode = receipt.ok ? 0 : 3;
|
|
12057
12095
|
} catch (e) {
|
|
@@ -12065,11 +12103,11 @@ import { spawnSync as spawnSync2 } from "child_process";
|
|
|
12065
12103
|
import { promises as fs13 } from "fs";
|
|
12066
12104
|
import path14 from "path";
|
|
12067
12105
|
import yaml2 from "js-yaml";
|
|
12068
|
-
import { formatObject as
|
|
12106
|
+
import { formatObject as formatObject28 } from "@hcmai/sdk";
|
|
12069
12107
|
|
|
12070
12108
|
// src/commands/delivery-action-policy.ts
|
|
12071
12109
|
init_auth_guard();
|
|
12072
|
-
import { HcmClient as
|
|
12110
|
+
import { HcmClient as HcmClient24, classifyEffect } from "@hcmai/sdk";
|
|
12073
12111
|
|
|
12074
12112
|
// src/commands/delivery.ts
|
|
12075
12113
|
import { createHash as createHash6 } from "crypto";
|
|
@@ -12360,6 +12398,10 @@ function classify(argv, actionResolution) {
|
|
|
12360
12398
|
}
|
|
12361
12399
|
if (name === "upload") return guarded("tenant-write", "document-upload");
|
|
12362
12400
|
if (name === "download") return direct("R1", "managed-local-write", "document-download");
|
|
12401
|
+
if (name === "document") {
|
|
12402
|
+
if (subcommand === "delete") return guarded("tenant-write", "document-delete");
|
|
12403
|
+
return forbidden("unknown-command", "\u672A\u77E5 document \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
|
|
12404
|
+
}
|
|
12363
12405
|
if (name === "action") {
|
|
12364
12406
|
if (actionResolution?.status === "resolved") {
|
|
12365
12407
|
return classifyAction(actionResolution.policy);
|
|
@@ -12579,7 +12621,7 @@ async function resolveCoreAction(request) {
|
|
|
12579
12621
|
as: request.identity,
|
|
12580
12622
|
profile: request.profile
|
|
12581
12623
|
});
|
|
12582
|
-
const description = await
|
|
12624
|
+
const description = await HcmClient24.fromAuthContext(auth).describe(request.model);
|
|
12583
12625
|
const named = description.actions.filter((action) => action.name === request.action);
|
|
12584
12626
|
if (named.length === 0) {
|
|
12585
12627
|
const degraded = description.effectiveActionsAvailable ? "" : `\u26A0\uFE0F \u672C\u6B21\u6BD4\u5BF9\u4E0D\u542B\u811A\u672C Action\u2014\u2014${description.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}\u3002`;
|
|
@@ -12989,7 +13031,7 @@ async function chironTestCommand(target, args, deps) {
|
|
|
12989
13031
|
}
|
|
12990
13032
|
const fmt = args.output ?? "table";
|
|
12991
13033
|
if (fmt === "json" || fmt === "yaml") {
|
|
12992
|
-
process.stdout.write(
|
|
13034
|
+
process.stdout.write(formatObject28({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
|
|
12993
13035
|
} else {
|
|
12994
13036
|
for (const c of report) {
|
|
12995
13037
|
process.stdout.write(`
|
|
@@ -13018,12 +13060,12 @@ ${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4
|
|
|
13018
13060
|
init_auth_guard();
|
|
13019
13061
|
init_exit();
|
|
13020
13062
|
import {
|
|
13021
|
-
HcmClient as
|
|
13063
|
+
HcmClient as HcmClient25,
|
|
13022
13064
|
ReconLayout,
|
|
13023
13065
|
ROUND_EXIT_CODES,
|
|
13024
13066
|
computeReconSourceKey,
|
|
13025
|
-
formatObject as
|
|
13026
|
-
fromAxiosError as
|
|
13067
|
+
formatObject as formatObject29,
|
|
13068
|
+
fromAxiosError as fromAxiosError22,
|
|
13027
13069
|
httpProbe as httpProbe3,
|
|
13028
13070
|
inspectRound,
|
|
13029
13071
|
renderRound,
|
|
@@ -13033,7 +13075,7 @@ var DEFAULT_CAPABILITIES = "default";
|
|
|
13033
13075
|
async function deliveryReconCommand(args) {
|
|
13034
13076
|
try {
|
|
13035
13077
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
13036
|
-
const client3 =
|
|
13078
|
+
const client3 = HcmClient25.fromAuthContext(ctx);
|
|
13037
13079
|
const probe = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
|
|
13038
13080
|
const sourceKey = await computeReconSourceKey(probe);
|
|
13039
13081
|
const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
|
|
@@ -13042,10 +13084,10 @@ async function deliveryReconCommand(args) {
|
|
|
13042
13084
|
onlyModel: args.model ?? null,
|
|
13043
13085
|
identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
|
|
13044
13086
|
});
|
|
13045
|
-
process.stdout.write(
|
|
13087
|
+
process.stdout.write(formatObject29(summary, { format: args.output ?? "json" }) + "\n");
|
|
13046
13088
|
} catch (e) {
|
|
13047
13089
|
const err = e;
|
|
13048
|
-
if (err?.isAxiosError) exitWithError(
|
|
13090
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.env));
|
|
13049
13091
|
exitWithError(e);
|
|
13050
13092
|
process.exit(1);
|
|
13051
13093
|
}
|
|
@@ -13056,7 +13098,7 @@ async function deliveryReconRoundCommand(args) {
|
|
|
13056
13098
|
const result = inspectRound(args.dir ?? ".");
|
|
13057
13099
|
const fmt = args.output ?? "json";
|
|
13058
13100
|
if (fmt !== "json") process.stdout.write(renderRound(result));
|
|
13059
|
-
process.stdout.write(
|
|
13101
|
+
process.stdout.write(formatObject29(result, { format: fmt }) + "\n");
|
|
13060
13102
|
code = ROUND_EXIT_CODES[result.state];
|
|
13061
13103
|
} catch (e) {
|
|
13062
13104
|
exitWithError(e);
|
|
@@ -13076,7 +13118,7 @@ import {
|
|
|
13076
13118
|
DRY_RUN_TAIL,
|
|
13077
13119
|
DriftDetected,
|
|
13078
13120
|
FORCE_STALE_FLAG,
|
|
13079
|
-
HcmClient as
|
|
13121
|
+
HcmClient as HcmClient26,
|
|
13080
13122
|
fetchReconIdentity as fetchReconIdentity3,
|
|
13081
13123
|
INIT_EXIT_CODES,
|
|
13082
13124
|
JOURNAL_STOP_KINDS,
|
|
@@ -13216,7 +13258,7 @@ async function authOrSignpost(args, cmd) {
|
|
|
13216
13258
|
}
|
|
13217
13259
|
async function deliverySeedPlanCommand(args) {
|
|
13218
13260
|
const ctx = await authOrSignpost(args, "plan");
|
|
13219
|
-
const client3 =
|
|
13261
|
+
const client3 = HcmClient26.fromAuthContext(ctx);
|
|
13220
13262
|
process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
|
|
13221
13263
|
}
|
|
13222
13264
|
function seedClient(client3, ctx) {
|
|
@@ -13390,7 +13432,7 @@ async function runSeedApply(args, client3) {
|
|
|
13390
13432
|
}
|
|
13391
13433
|
async function deliverySeedApplyCommand(args) {
|
|
13392
13434
|
const ctx = await authOrSignpost(args, "apply");
|
|
13393
|
-
const client3 =
|
|
13435
|
+
const client3 = HcmClient26.fromAuthContext(ctx);
|
|
13394
13436
|
process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
|
|
13395
13437
|
}
|
|
13396
13438
|
async function runSeedVerify(args, client3) {
|
|
@@ -13414,7 +13456,7 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
13414
13456
|
return;
|
|
13415
13457
|
}
|
|
13416
13458
|
const ctx = await authOrSignpost(args, "verify");
|
|
13417
|
-
const client3 =
|
|
13459
|
+
const client3 = HcmClient26.fromAuthContext(ctx);
|
|
13418
13460
|
process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
|
|
13419
13461
|
}
|
|
13420
13462
|
|
|
@@ -13529,7 +13571,7 @@ import {
|
|
|
13529
13571
|
CHANGE_STATES,
|
|
13530
13572
|
CHANGE_UNKNOWN,
|
|
13531
13573
|
CODE_WORDS,
|
|
13532
|
-
HcmClient as
|
|
13574
|
+
HcmClient as HcmClient27,
|
|
13533
13575
|
INIT_EXIT_CODES as INIT_EXIT_CODES3,
|
|
13534
13576
|
META_WRITE_STEPS,
|
|
13535
13577
|
META_VERIFY_STEPS,
|
|
@@ -13757,7 +13799,7 @@ function lowerCaseHeaders2(headers) {
|
|
|
13757
13799
|
}
|
|
13758
13800
|
async function deliveryMetaCommand(args) {
|
|
13759
13801
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
13760
|
-
const client3 =
|
|
13802
|
+
const client3 = HcmClient27.fromAuthContext(ctx);
|
|
13761
13803
|
process.exitCode = await runDeliveryMeta(
|
|
13762
13804
|
{ ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
|
|
13763
13805
|
metaClient(client3, ctx)
|
|
@@ -13769,7 +13811,7 @@ init_auth_guard();
|
|
|
13769
13811
|
init_exit();
|
|
13770
13812
|
import {
|
|
13771
13813
|
computeReconSourceKey as computeReconSourceKey2,
|
|
13772
|
-
HcmClient as
|
|
13814
|
+
HcmClient as HcmClient28,
|
|
13773
13815
|
httpProbe as httpProbe4,
|
|
13774
13816
|
ReconLayout as ReconLayout2,
|
|
13775
13817
|
runTriageRound
|
|
@@ -13825,7 +13867,7 @@ async function runTriage(args) {
|
|
|
13825
13867
|
return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
|
|
13826
13868
|
}
|
|
13827
13869
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
13828
|
-
const client3 =
|
|
13870
|
+
const client3 = HcmClient28.fromAuthContext(ctx);
|
|
13829
13871
|
const probe = httpProbe4(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
|
|
13830
13872
|
const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
|
|
13831
13873
|
const result = await runTriageRound(probe, artifactsDir, entriesIn);
|
|
@@ -13854,10 +13896,10 @@ async function deliveryTriageCommand(args) {
|
|
|
13854
13896
|
init_auth_guard();
|
|
13855
13897
|
init_exit();
|
|
13856
13898
|
import {
|
|
13857
|
-
HcmClient as
|
|
13899
|
+
HcmClient as HcmClient29,
|
|
13858
13900
|
adminResetPassword,
|
|
13859
|
-
formatObject as
|
|
13860
|
-
fromAxiosError as
|
|
13901
|
+
formatObject as formatObject30,
|
|
13902
|
+
fromAxiosError as fromAxiosError23,
|
|
13861
13903
|
CliError as CliError28,
|
|
13862
13904
|
CliErrorCode as CliErrorCode26
|
|
13863
13905
|
} from "@hcmai/sdk";
|
|
@@ -13888,12 +13930,12 @@ async function userResetPasswordCommand(args) {
|
|
|
13888
13930
|
try {
|
|
13889
13931
|
const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
|
|
13890
13932
|
const request = buildAdminResetPasswordRequest(args, password);
|
|
13891
|
-
const client3 =
|
|
13933
|
+
const client3 = HcmClient29.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
13892
13934
|
const result = await adminResetPassword(client3.raw(), request);
|
|
13893
|
-
process.stdout.write(
|
|
13935
|
+
process.stdout.write(formatObject30(result, { format: args.output ?? "json" }) + "\n");
|
|
13894
13936
|
} catch (cause) {
|
|
13895
13937
|
const err = cause;
|
|
13896
|
-
if (err?.isAxiosError) exitWithError(
|
|
13938
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError23(err, args.env));
|
|
13897
13939
|
exitWithError(cause);
|
|
13898
13940
|
}
|
|
13899
13941
|
}
|
|
@@ -13913,19 +13955,19 @@ async function promptPasswordTwice() {
|
|
|
13913
13955
|
init_exit();
|
|
13914
13956
|
init_auth_guard();
|
|
13915
13957
|
import {
|
|
13916
|
-
HcmClient as
|
|
13917
|
-
formatObject as
|
|
13918
|
-
fromAxiosError as
|
|
13958
|
+
HcmClient as HcmClient30,
|
|
13959
|
+
formatObject as formatObject31,
|
|
13960
|
+
fromAxiosError as fromAxiosError24
|
|
13919
13961
|
} from "@hcmai/sdk";
|
|
13920
13962
|
async function modelsCommand(keyword, args) {
|
|
13921
13963
|
try {
|
|
13922
|
-
const client3 =
|
|
13964
|
+
const client3 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
13923
13965
|
const all = await client3.listModels();
|
|
13924
13966
|
const needle = keyword?.trim().toLowerCase();
|
|
13925
13967
|
const rows2 = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
|
|
13926
13968
|
const fmt = args.output ?? "table";
|
|
13927
13969
|
if (fmt !== "table") {
|
|
13928
|
-
process.stdout.write(
|
|
13970
|
+
process.stdout.write(formatObject31({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
|
|
13929
13971
|
process.exitCode = 0;
|
|
13930
13972
|
return;
|
|
13931
13973
|
}
|
|
@@ -13952,7 +13994,7 @@ async function modelsCommand(keyword, args) {
|
|
|
13952
13994
|
return;
|
|
13953
13995
|
} catch (e) {
|
|
13954
13996
|
const err = e;
|
|
13955
|
-
if (err?.isAxiosError) exitWithError(
|
|
13997
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError24(err, args.profile));
|
|
13956
13998
|
exitWithError(e);
|
|
13957
13999
|
}
|
|
13958
14000
|
}
|
|
@@ -14035,7 +14077,7 @@ chiron.command("init").description("\u5EFA\u987E\u95EE\u9879\u76EE\u4ED3\uFF1A\u
|
|
|
14035
14077
|
chiron.command("test").description("\u6309\u7528\u4F8B\u8DD1\u4E00\u904D\u5E76\u628A\u95EE\u9898\u627E\u51FA\u6765\uFF1A\u7528\u4F8B\u5728\u9879\u76EE\u4ED3 tests/\uFF0C\u5224\u636E\u5FC5\u987B\u770B\u5185\u5BB9\uFF08\u53EA\u5224\u9000\u51FA\u7801\u7684\u7528\u4F8B\u4F1A\u88AB\u62D2\u7EDD\u52A0\u8F7D\uFF09").argument("[target]", "\u7528\u4F8B\u6587\u4EF6\u6216\u76EE\u5F55\uFF08\u9ED8\u8BA4 tests/\uFF09").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u76EE\u6807\u73AF\u5883\uFF1B\u7528\u4F8B\u91CC\u6CA1\u5199 --env \u65F6\u8865\u4E0A").option("--as <identity>", "\u8EAB\u4EFD\uFF1B\u7528\u4F8B\u91CC\u6CA1\u5199 --as \u65F6\u8865\u4E0A").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((target, opts) => chironTestCommand(target, opts));
|
|
14036
14078
|
chiron.command("page").description("\u6253\u5F00\u9875\u9762\u622A\u56FE\u5E76\u5BF9\u7740\u9875\u9762\u5185\u5BB9\u5224\u4E00\u6B21\uFF1A\u81F3\u5C11\u8981\u7ED9\u4E00\u6761 --expect-text\uFF0C\u53EA\u622A\u56FE\u4E0D\u7B97\u9A8C\u6536").argument("<\u8DEF\u5F84>", "\u7AD9\u5185\u8DEF\u5F84\uFF0C\u5982 /dashboard/xxx").requiredOption("--out <file>", "\u622A\u56FE\u843D\u70B9\uFF0C\u5FC5\u987B\u5728\u9879\u76EE\u7684 evidence/ \u4E0B\u4E14\u4EE5 .png \u7ED3\u5C3E").option("--expect-text <text...>", "\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C\uFF08\u81F3\u5C11\u4E00\u6761\uFF09").option("--reject-text <text...>", "\u9875\u9762\u4E0A\u4E0D\u5F97\u51FA\u73B0\u7684\u6587\u672C").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--wait-ms <ms>", "\u9875\u9762\u6E32\u67D3\u9884\u7B97\u6BEB\u79D2\u6570", "10000").option("--size <WxH>", "\u89C6\u53E3\u5C3A\u5BF8", "1440x900").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((target, opts) => chironPageCommand(target, opts));
|
|
14037
14079
|
chiron.command("doctor").description(
|
|
14038
|
-
"\u6838\u5BF9\uFF1A\u672C\u673A\u767B\u5F55\u662F\u5426\u5BF9\u7740 env.yaml \u7684\u73AF\u5883\uFF08\u542B\
|
|
14080
|
+
"\u6838\u5BF9\uFF1A\u672C\u673A\u767B\u5F55\u662F\u5426\u5BF9\u7740 env.yaml \u7684\u73AF\u5883\uFF08\u542B\u4E94\u6761\u951A\u70B9\u4E0E\u5BF9\u8BDD\u63E1\u624B\uFF09/ \u6280\u80FD\u88C5\u6CA1\u88C5 / \u6848\u4F8B\u5E93\u8BFB\u4E0D\u8BFB\u5F97\u5230 / Jira \u80FD\u4E0D\u80FD\u63D0\u5355"
|
|
14039
14081
|
).option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u8986\u76D6\u8981\u6838\u7684\u73AF\u5883\u522B\u540D\uFF08\u9ED8\u8BA4\u53D6 env.yaml\uFF1B\u591A\u73AF\u5883\u9879\u76EE\u7528\u5B83\u6328\u4E2A\u63A2\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\u63A2\u951A\u70B9").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => chironDoctorCommand(opts));
|
|
14040
14082
|
var chironSkills = chiron.command("skills").description("\u8FD9\u4E2A\u9879\u76EE\u4ED3\u7684\u6280\u80FD\uFF1A\u8DDF\u76EE\u6807\u73AF\u5883\u5BF9\u9F50");
|
|
14041
14083
|
chironSkills.command("sync").description("\u8BA9\u8FD9\u4E2A\u4ED3\u7684\u6280\u80FD\u8DDF\u76EE\u6807\u73AF\u5883\u5BF9\u9F50\uFF1A\u7B2C\u4E00\u6B21\u5C31\u88C5\u9F50\uFF0C\u4E4B\u540E\u6309\u4EA7\u54C1\u5F53\u524D\u5168\u96C6\u5BF9\u8D26\u3002\u5E42\u7B49\uFF0C\u4EA7\u54C1\u5347\u7EA7\u540E\u8DD1\u5B83").option("--only <id...>", "\u53EA\u8981\u8FD9\u51E0\u4E2A\u6280\u80FD\uFF08\u8FDE\u540C requires \u524D\u7F6E\uFF09\uFF0C\u4E0D\u8BA2\u9605\u5168\u96C6\uFF1B\u8BAD\u7EC3\u573A blind \u6863\u7528").option("--check", "\u53EA\u770B\u4F1A\u53D8\u4EC0\u4E48\uFF0C\u4E0D\u5199\u76D8").option("--target <agent>", "claude\uFF08.claude/skills/\uFF09| codex\uFF08hcm-skills/ + Agent \u7D22\u5F15\uFF09| auto", "auto").option("--global", "\u540C\u6B65\u7528\u6237\u7EA7\u76EE\u5F55\u800C\u975E\u5F53\u524D\u9879\u76EE").option("--dir <path>", "\u540C\u6B65\u6307\u5B9A\u76EE\u5F55").option("--from <dir>", "\u4ECE\u672C\u5730\u76EE\u5F55\u53D6\uFF08\u73B0\u573A\u6539\u8FC7\u7684\u7248\u672C\uFF09\uFF0C\u4E0D\u8D70\u7F51\u7EDC").option("--force", "\u8FDE\u672C\u5730\u6539\u8FC7\u7684\u6280\u80FD\u4E00\u8D77\u8986\u76D6\u6210\u4EA7\u54C1\u8FD9\u4E00\u7248").option("--prune-max <n>", `\u4E00\u8D9F\u6700\u591A\u6E05\u51E0\u4EFD\u4E0A\u6E38\u4E0D\u518D\u53D1\u7684\u6280\u80FD\uFF0C\u8D85\u4E86\u6574\u6279\u62D2\u7EDD\uFF1B0 = \u4E00\u4EFD\u90FD\u522B\u6E05\uFF08\u7F3A\u7701 ${PRUNE_DEFAULT_MAX}\uFF09`).option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u9879\u76EE\u73AF\u5883\u6216\u5B89\u88C5\u65F6\u8BB0\u5F55\u7684\u5730\u5740\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => skillsSyncCommand(opts));
|
|
@@ -14161,6 +14203,8 @@ program.command("chat [prompt]").description("\u4E0E\u6570\u5B57\u5458\u5DE5 Moi
|
|
|
14161
14203
|
[]
|
|
14162
14204
|
).action((prompt, opts) => chatCommand(prompt, opts));
|
|
14163
14205
|
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));
|
|
14206
|
+
var document = program.command("document").description("\u7BA1\u7406 HCM \u6587\u6863\uFF08\u4F7F\u7528\u6587\u6863\u4E13\u7528 API\uFF09");
|
|
14207
|
+
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));
|
|
14164
14208
|
var workspace = program.command("workspace").description("\u5F00\u53D1\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4\u6587\u4EF6\u5305\uFF08mini_apps / menus / metas / scripts\uFF09");
|
|
14165
14209
|
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));
|
|
14166
14210
|
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));
|