@gaoding/cli 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,6 +30,9 @@ gd-cli tool list
30
30
  gd-cli model list --tool <tool>
31
31
  gd-cli model get <model>
32
32
  gd-cli editor apply --schema
33
+ gd-cli credits --json
34
+ gd-cli credits usage list --help
35
+ gd-cli credits usage get --schema
33
36
  ```
34
37
 
35
38
  选定 Model 后,以 `model get` 返回的 `parameters` 与 `usageDescription` 构造实际输入;其中 `cost` 是当前上架 SKU 的稿豆价格区间,不表示某次调用的实际扣费。`tool call <tool> --schema` 只给出整个 Tool 的参数并集。运行 `gd-cli --help` 查看当前命令;运行任一命令的 `--help` 查看参数。`editor apply --schema` 无需登录或连接编辑器,输出当前版本的 Action 输入契约;与执行模式 `--input` 互斥。
@@ -38,6 +41,8 @@ CLI 最多每小时检查一次 npm `latest`,发现新版本后每天最多在
38
41
 
39
42
  发布只由仓库受保护 `main` 的 CI 执行:先发布并验证 `candidate` 与精确版本安装,再提升 `latest` 并验证默认安装。版本与 dist-tag 不由本地手工修改。
40
43
 
44
+ `credits` 读取当前身份和组织的余额;`credits usage list` 查询一页消费、归还、回收与过期记录,`credits usage get <record-id>` 读取来源拆分。三个命令的 `--schema` 无需登录,输出本地输入与输出 Schema。流水默认当前 UTC 月份;翻页沿用返回区间和 `nextCursor`,不把本页数量当作完整消费合计。
45
+
41
46
  ## License
42
47
 
43
48
  MIT
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.gaoding.com/operations/credits.get/input.schema.json",
4
+ "title": "CreditsGetInput",
5
+ "description": "查询当前身份及组织上下文的余额,无业务参数。",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "properties": {}
9
+ }
@@ -0,0 +1,107 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.gaoding.com/operations/credits.get/output.schema.json",
4
+ "title": "CreditsResult",
5
+ "description": "当前身份及组织上下文的权益概览;保留池余额与成员周期限额的区别。",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "credits"
10
+ ],
11
+ "properties": {
12
+ "credits": {
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "required": [
16
+ "unit",
17
+ "total",
18
+ "used",
19
+ "pending",
20
+ "available"
21
+ ],
22
+ "properties": {
23
+ "unit": {
24
+ "type": "string",
25
+ "enum": [
26
+ "gaodou",
27
+ "credit"
28
+ ],
29
+ "description": "产品配置决定的计量单位;稿豆或 insMind credit,不代表货币。"
30
+ },
31
+ "total": {
32
+ "type": "number",
33
+ "minimum": 0,
34
+ "maximum": 9007199254740991,
35
+ "description": "该权益行的 total;不等同于终身累计充值。"
36
+ },
37
+ "used": {
38
+ "type": "number",
39
+ "minimum": 0,
40
+ "maximum": 9007199254740991,
41
+ "description": "与该权益行总量配对的已用量;不等同于所选日期消费合计。"
42
+ },
43
+ "pending": {
44
+ "type": "number",
45
+ "minimum": 0,
46
+ "maximum": 9007199254740991,
47
+ "description": "服务端 wait 的数值;含义由服务端定义,不承诺待生效或冻结。"
48
+ },
49
+ "available": {
50
+ "type": "number",
51
+ "minimum": 0,
52
+ "maximum": 9007199254740991,
53
+ "description": "max(0,total-used);不扣除 wait,不代表成员限额内可用量。"
54
+ }
55
+ }
56
+ },
57
+ "balances": {
58
+ "type": "array",
59
+ "description": "多行概览或存在成员限额时返回完整权益行;不按 identifier 去重。",
60
+ "items": {
61
+ "type": "object",
62
+ "additionalProperties": false,
63
+ "required": [
64
+ "total",
65
+ "used",
66
+ "pending",
67
+ "available"
68
+ ],
69
+ "properties": {
70
+ "identifier": {
71
+ "type": "string"
72
+ },
73
+ "total": {
74
+ "type": "number",
75
+ "minimum": 0,
76
+ "maximum": 9007199254740991,
77
+ "description": "该权益行的 total;不等同于终身累计充值。"
78
+ },
79
+ "used": {
80
+ "type": "number",
81
+ "minimum": 0,
82
+ "maximum": 9007199254740991,
83
+ "description": "与该权益行总量配对的已用量;不等同于所选日期消费合计。"
84
+ },
85
+ "pending": {
86
+ "type": "number",
87
+ "minimum": 0,
88
+ "maximum": 9007199254740991,
89
+ "description": "服务端 wait 的数值;含义由服务端定义,不承诺待生效或冻结。"
90
+ },
91
+ "available": {
92
+ "type": "number",
93
+ "minimum": 0,
94
+ "maximum": 9007199254740991,
95
+ "description": "max(0,total-used);不扣除 wait,不代表成员限额内可用量。"
96
+ },
97
+ "memberPeriodLimit": {
98
+ "type": "number",
99
+ "minimum": 0,
100
+ "maximum": 9007199254740991,
101
+ "description": "服务端成员周期限额,0 是有效限额;不以它覆盖权益池余额。"
102
+ }
103
+ }
104
+ }
105
+ }
106
+ }
107
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.gaoding.com/operations/credits.usage.get/input.schema.json",
4
+ "title": "CreditsUsageGetInput",
5
+ "description": "按列表返回的记录 ID 查询来源拆分。",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "id"
10
+ ],
11
+ "properties": {
12
+ "id": {
13
+ "type": "string",
14
+ "minLength": 1,
15
+ "pattern": ".*\\S.*"
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.gaoding.com/operations/credits.usage.get/output.schema.json",
4
+ "title": "CreditsUsageGetResult",
5
+ "description": "服务端提供的单条记录来源拆分;空数组不表示该记录数量为零。",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "id",
10
+ "unit",
11
+ "breakdown"
12
+ ],
13
+ "properties": {
14
+ "id": {
15
+ "type": "string",
16
+ "minLength": 1,
17
+ "pattern": ".*\\S.*"
18
+ },
19
+ "unit": {
20
+ "type": "string",
21
+ "enum": [
22
+ "gaodou",
23
+ "credit"
24
+ ],
25
+ "description": "产品配置决定的计量单位;稿豆或 insMind credit,不代表货币。"
26
+ },
27
+ "breakdown": {
28
+ "type": "array",
29
+ "items": {
30
+ "type": "object",
31
+ "additionalProperties": false,
32
+ "required": [
33
+ "amount"
34
+ ],
35
+ "properties": {
36
+ "amount": {
37
+ "type": "number",
38
+ "minimum": 0,
39
+ "maximum": 9007199254740991
40
+ },
41
+ "usageType": {
42
+ "type": "number",
43
+ "description": "服务端 usage_type;1 为消费、2 为归还,其他值保留不推断方向。"
44
+ },
45
+ "sourceType": {
46
+ "type": "string",
47
+ "description": "服务端权益来源类型;保留未知值。"
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.gaoding.com/operations/credits.usage.list/input.schema.json",
4
+ "title": "CreditsUsageListInput",
5
+ "description": "按含端点的时间区间读取一页服务端变动流水;默认 UTC 本月,20 条。",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "from": {
10
+ "type": "string",
11
+ "format": "date-time",
12
+ "description": "含起始时刻;ISO 8601 时间戳,必须含 Z 或时区偏移。省略为当前 UTC 月首。"
13
+ },
14
+ "to": {
15
+ "type": "string",
16
+ "format": "date-time",
17
+ "description": "含结束时刻;ISO 8601 时间戳,必须含 Z 或时区偏移。省略为当前 UTC 月末。"
18
+ },
19
+ "limit": {
20
+ "type": "integer",
21
+ "minimum": 1,
22
+ "default": 20,
23
+ "description": "每页条数;不在 CLI 声明未经确认的服务端最大值。"
24
+ },
25
+ "cursor": {
26
+ "type": "string",
27
+ "minLength": 1,
28
+ "pattern": ".*\\S.*",
29
+ "description": "上一页 nextCursor,原样传递;翻页时保持相同时间区间。"
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,144 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.gaoding.com/operations/credits.usage.list/output.schema.json",
4
+ "title": "CreditsUsageListResult",
5
+ "description": "带实际 UTC 区间和继续游标的一页变动流水。",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "unit",
10
+ "range",
11
+ "items",
12
+ "hasMore",
13
+ "nextCursor"
14
+ ],
15
+ "properties": {
16
+ "unit": {
17
+ "type": "string",
18
+ "enum": [
19
+ "gaodou",
20
+ "credit"
21
+ ],
22
+ "description": "产品配置决定的计量单位;稿豆或 insMind credit,不代表货币。"
23
+ },
24
+ "range": {
25
+ "type": "object",
26
+ "additionalProperties": false,
27
+ "required": [
28
+ "from",
29
+ "to"
30
+ ],
31
+ "properties": {
32
+ "from": {
33
+ "type": "string",
34
+ "format": "date-time"
35
+ },
36
+ "to": {
37
+ "type": "string",
38
+ "format": "date-time"
39
+ }
40
+ }
41
+ },
42
+ "items": {
43
+ "type": "array",
44
+ "items": {
45
+ "type": "object",
46
+ "additionalProperties": false,
47
+ "required": [
48
+ "id",
49
+ "changeType",
50
+ "amount",
51
+ "recordedAt"
52
+ ],
53
+ "properties": {
54
+ "id": {
55
+ "type": "string",
56
+ "minLength": 1,
57
+ "pattern": ".*\\S.*"
58
+ },
59
+ "changeType": {
60
+ "type": "string",
61
+ "minLength": 1,
62
+ "pattern": ".*\\S.*",
63
+ "description": "服务端变动类型。CONSUME 消费、RESTORE 归还、RECYCLE 回收、EXPIRE 过期;其他值保留,不假设方向。"
64
+ },
65
+ "amount": {
66
+ "type": "number",
67
+ "minimum": 0,
68
+ "maximum": 9007199254740991,
69
+ "description": "该条变动的无符号数量,不是所有类型均属于消费。"
70
+ },
71
+ "recordedAt": {
72
+ "type": "string",
73
+ "format": "date-time"
74
+ },
75
+ "recordMode": {
76
+ "type": "string"
77
+ },
78
+ "description": {
79
+ "type": "string"
80
+ },
81
+ "scene": {
82
+ "type": "number"
83
+ },
84
+ "referenceId": {
85
+ "type": "string"
86
+ },
87
+ "user": {
88
+ "type": "object",
89
+ "additionalProperties": false,
90
+ "properties": {
91
+ "id": {
92
+ "type": "string"
93
+ },
94
+ "name": {
95
+ "type": "string"
96
+ }
97
+ }
98
+ }
99
+ }
100
+ },
101
+ "description": "本页记录,不代表区间完整账本,不提供推测的总数或总消费。"
102
+ },
103
+ "hasMore": {
104
+ "type": "boolean"
105
+ },
106
+ "nextCursor": {
107
+ "type": [
108
+ "string",
109
+ "null"
110
+ ],
111
+ "description": "后续页的 opaque cursor;无后续页时为 null。"
112
+ }
113
+ },
114
+ "allOf": [
115
+ {
116
+ "if": {
117
+ "properties": {
118
+ "hasMore": {
119
+ "const": true
120
+ }
121
+ },
122
+ "required": [
123
+ "hasMore"
124
+ ]
125
+ },
126
+ "then": {
127
+ "properties": {
128
+ "nextCursor": {
129
+ "type": "string",
130
+ "minLength": 1,
131
+ "pattern": ".*\\S.*"
132
+ }
133
+ }
134
+ },
135
+ "else": {
136
+ "properties": {
137
+ "nextCursor": {
138
+ "type": "null"
139
+ }
140
+ }
141
+ }
142
+ }
143
+ ]
144
+ }
@@ -35,22 +35,19 @@ export function createCli(runtime, options) {
35
35
  writeErr: () => undefined
36
36
  });
37
37
  program.addHelpText("after", runtime.product.id === "insmind"
38
- ? "\nstdout contains command results; stderr contains progress, warnings and errors. Fixed JSON commands, --json and --json-errors use {error:{code,message,details?,trace_id?}} for final errors. stderr may contain multiple messages.\nExit codes: 0 success, 1 execution failure, 2 invalid input, 130 local interruption; dispatched work may still be active.\n"
39
- : "\nstdout 输出命令结果;stderr 输出进度、警告和错误。固定 JSON 命令、--json 和 --json-errors 的最终错误使用 {error:{code,message,details?,trace_id?}},stderr 可能包含多条信息。\n退出码:0 成功,1 执行失败,2 输入无效,130 本地中断;已派发的工作可能仍在继续。\n");
38
+ ? "\nstdout contains command results; human-readable views can include an update notice. stderr contains progress, warnings and errors. Fixed JSON commands, --json and --json-errors use {error:{code,message,details?,trace_id?}} for final errors. stderr may contain multiple messages.\nExit codes: 0 success, 1 execution failure, 2 invalid input, 130 local interruption; dispatched work may still be active.\n"
39
+ : "\nstdout 输出命令结果,人类可读视图可以附带升级提醒;stderr 输出进度、警告和错误。固定 JSON 命令、--json 和 --json-errors 的最终错误使用 {error:{code,message,details?,trace_id?}},stderr 可能包含多条信息。\n退出码:0 成功,1 执行失败,2 输入无效,130 本地中断;已派发的工作可能仍在继续。\n");
40
40
  if (runtime.product.id === "insmind") {
41
41
  program.option("--locale <locale>", "locale for service-owned business descriptions");
42
42
  }
43
43
  configureActionEnvironment(program, {
44
44
  policies: runtime.accessPolicies,
45
45
  signal: options.signal,
46
- telemetry: runtime.telemetry,
47
- updateNotification: runtime.updateNotification
46
+ telemetry: runtime.telemetry
48
47
  });
49
48
  registerAuthCommands(program, runtime);
50
49
  if (runtime.product.exposesOrganizations)
51
50
  registerOrgCommands(program, runtime);
52
- else
53
- registerCreditsCommand(program, runtime);
54
51
  registerAgentCommands(program, runtime);
55
52
  registerToolCommands(program, runtime);
56
53
  registerModelCommands(program, runtime);
@@ -58,6 +55,7 @@ export function createCli(runtime, options) {
58
55
  registerDamCommands(program, runtime);
59
56
  registerUpdateCommand(program, runtime);
60
57
  registerTaskCommands(program, runtime);
58
+ registerCreditsCommand(program, runtime);
61
59
  assertAllLeafCommandsBound(program);
62
60
  outputs.set(program, runtime);
63
61
  if (runtime.analytics)
@@ -65,7 +63,11 @@ export function createCli(runtime, options) {
65
63
  return program;
66
64
  }
67
65
  export async function executeCli(options) {
68
- await options.telemetry.issue(invocationDefinition(options.program, options.argv));
66
+ const definition = invocationDefinition(options.program, options.argv);
67
+ await options.telemetry.issue(definition);
68
+ const automaticNotice = definition.operation !== "update" && !definition.operation.startsWith("update.");
69
+ let informational = false;
70
+ let help = false;
69
71
  try {
70
72
  try {
71
73
  await options.program.parseAsync(options.argv, { from: "user" });
@@ -73,12 +75,16 @@ export async function executeCli(options) {
73
75
  catch (error) {
74
76
  if (!isHelpOutcome(error))
75
77
  throw error;
76
- if (options.argv[0] !== "update")
77
- await checkUpdateNotification(options.updateNotification, options.signal);
78
+ informational = true;
79
+ help = error instanceof CommanderError && error.code === "commander.helpDisplayed";
78
80
  options.signal.throwIfAborted();
79
81
  }
80
82
  await options.telemetry.stage("output", async () => { await outputs.get(options.program)?.io.flush?.(); });
81
83
  await outputs.get(options.program)?.tasks.outputCompleted();
84
+ if (automaticNotice)
85
+ await checkUpdateNotification(options.updateNotification, options.signal, help || options.presenter.humanResult ? "text" : "machine");
86
+ if (informational)
87
+ options.signal.throwIfAborted();
82
88
  await sendFinished(options, { outcome: "success" });
83
89
  return 0;
84
90
  }
@@ -129,6 +135,9 @@ export async function executeCli(options) {
129
135
  }
130
136
  if (errorDelivered)
131
137
  await outputs.get(options.program)?.tasks.outputCompleted(error);
138
+ if (errorDelivered && automaticNotice && outcome.exitCode === 1 && definition.operation !== "unknown") {
139
+ await checkUpdateNotification(options.updateNotification, options.signal, "machine");
140
+ }
132
141
  await sendFinished(options, outcome.kind === "interrupted"
133
142
  ? { outcome: "interrupted", error }
134
143
  : {
@@ -149,9 +158,9 @@ export async function executeCli(options) {
149
158
  return outcome.exitCode;
150
159
  }
151
160
  }
152
- async function checkUpdateNotification(updateNotification, signal) {
161
+ async function checkUpdateNotification(updateNotification, signal, output) {
153
162
  try {
154
- await updateNotification.check(signal);
163
+ await updateNotification.check(signal, output);
155
164
  }
156
165
  catch {
157
166
  // Version availability must never change the requested command outcome.
@@ -1,5 +1,6 @@
1
1
  import { createWindAnalytics } from "../analytics/wind.js";
2
2
  import { taskScope } from "../features/task/store.js";
3
+ import { noticeWriter, sameTerminal } from "../features/update/notice-output.js";
3
4
  import { createTextOutput } from "../platform/text-output.js";
4
5
  import { TaskNotFoundError } from "../features/task/use-cases.js";
5
6
  import { homedir } from "node:os";
@@ -213,7 +214,8 @@ export function createProductionRuntime(options = {}) {
213
214
  });
214
215
  const credits = createCreditsUseCases({
215
216
  transport: creditsTransport,
216
- billingUnit: product.billingUnit
217
+ billingUnit: product.billingUnit,
218
+ now
217
219
  });
218
220
  const storageUpload = createDamStorageUploader({
219
221
  transport: damTransport,
@@ -504,7 +506,8 @@ export function createProductionRuntime(options = {}) {
504
506
  installationOwner,
505
507
  ...(options.homeDirectory ? { homeDirectory: options.homeDirectory } : {}),
506
508
  ...(options.env ? { env: options.env } : {}),
507
- notify: (message) => { presenter.notice(message); },
509
+ diagnosticOnly: !io.stderrTerminal && env.CLI_UPDATE_NOTICE_FORMAT !== "offer",
510
+ notify: noticeWriter(stdout, stderr, sameTerminal(rawIo.stdout, rawIo.stderr), env.CLI_UPDATE_NOTICE_FORMAT === "offer", text("提示: ", "Notice: ")),
508
511
  ...(product.id === "insmind" ? {
509
512
  stateDirectoryName: product.stateDirectory,
510
513
  registryUrl: `https://registry.npmjs.org/${encodeURIComponent(product.npmPackage)}`,
@@ -123,6 +123,9 @@ export function createContractValidators(options = {}) {
123
123
  const taskResult = ajv.compile(runOutputSchema);
124
124
  const taskListResult = ajv.compile(contractSchema("task.list", "output"));
125
125
  return {
126
+ creditsOutput: assertion(ajv.compile(contractSchema("credits.get", "output")), OutputContractError),
127
+ creditsUsageListOutput: assertion(ajv.compile(contractSchema("credits.usage.list", "output")), OutputContractError),
128
+ creditsUsageGetOutput: assertion(ajv.compile(contractSchema("credits.usage.get", "output")), OutputContractError),
126
129
  taskResult: assertion(taskResult, OutputContractError),
127
130
  taskListResult: assertion(taskListResult, OutputContractError),
128
131
  agentSendInput: assertion(agentSendInput, InputContractError),
@@ -3,6 +3,7 @@ const environments = new WeakMap();
3
3
  const boundPolicies = new WeakMap();
4
4
  const jsonCommands = new WeakSet();
5
5
  const selectedCommands = new WeakMap();
6
+ const commandDefinitions = new WeakMap();
6
7
  /** Declare the existing fixed JSON contract alongside the command registration. */
7
8
  export function jsonOutput(command) {
8
9
  jsonCommands.add(command);
@@ -15,7 +16,7 @@ export function errorUsesJson(program, argv) {
15
16
  return true;
16
17
  const command = selectedCommands.get(program);
17
18
  if (command)
18
- return jsonCommands.has(command) || command.opts().json === true;
19
+ return jsonCommands.has(command) || command.optsWithGlobals().json === true;
19
20
  return jsonErrorsRequested(argv);
20
21
  }
21
22
  export function configureActionEnvironment(program, environment) {
@@ -30,7 +31,6 @@ export function bindAction(command, policy, handler, telemetry) {
30
31
  const environment = environments.get(rootCommand(command));
31
32
  if (!environment)
32
33
  throw new Error("CLI action environment is missing.");
33
- await checkUpdateNotification(environment, telemetry);
34
34
  const context = await environment.telemetry.stage("access", async () => {
35
35
  const authorized = await environment.policies[policy].authorize(environment.signal);
36
36
  if (authorized.policy !== policy) {
@@ -51,7 +51,6 @@ export function bindPreparedAction(command, policy, prepare, run, telemetry) {
51
51
  const environment = environments.get(rootCommand(command));
52
52
  if (!environment)
53
53
  throw new Error("CLI action environment is missing.");
54
- await checkUpdateNotification(environment, telemetry);
55
54
  const prepared = await environment.telemetry.stage("input", () => prepare(environment.signal));
56
55
  if (prepared.handled)
57
56
  return;
@@ -66,16 +65,6 @@ export function bindPreparedAction(command, policy, prepare, run, telemetry) {
66
65
  await run(context, prepared.input, environment.signal);
67
66
  });
68
67
  }
69
- async function checkUpdateNotification(environment, telemetry) {
70
- if (telemetry?.operation === "update")
71
- return;
72
- try {
73
- await environment.updateNotification.check(environment.signal);
74
- }
75
- catch {
76
- // Version availability must never change the requested command outcome.
77
- }
78
- }
79
68
  export function assertAllLeafCommandsBound(program) {
80
69
  for (const command of leafCommands(program)) {
81
70
  if (!boundPolicies.has(command)) {
@@ -96,6 +85,7 @@ function rootCommand(command) {
96
85
  }
97
86
  function bindTelemetrySelection(command, definition) {
98
87
  definition ??= { operation: commandPath(command).split(" ").slice(1).join(".") };
88
+ commandDefinitions.set(command, definition);
99
89
  if (!command.parent)
100
90
  throw new Error(`Telemetry command has no parent: ${command.name()}`);
101
91
  command.parent.hook("preSubcommand", (parent, selected) => {
@@ -152,7 +142,7 @@ export function invocationDefinition(program, argv) {
152
142
  }
153
143
  }
154
144
  const path = commandPath(command).split(" ").slice(1).join(".");
155
- const operation = mode === "version" ? "version" : unknown ? "unknown" : path || (mode === "help" ? "help" : "unknown");
145
+ const operation = mode === "version" ? "version" : unknown ? "unknown" : commandDefinitions.get(command)?.operation ?? (path || (mode === "help" ? "help" : "unknown"));
156
146
  return { operation, mode: () => mode };
157
147
  }
158
148
  function commandPath(command) {