@saturn-universe/cli 0.1.2-dev.2 → 0.1.2-dev.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.
@@ -2,6 +2,7 @@ import { parseArgs } from 'node:util';
2
2
  import { CliError } from './cli-diagnostics.js';
3
3
  import { workspaceRoot } from './client.js';
4
4
  import { sendHostCommand } from './host-command.js';
5
+ import { inspectHostModes } from './host-launcher.js';
5
6
  import { renderConfigCheck, renderConfigInit, renderConfigSummary } from './renderer.js';
6
7
  import { initUserConfig, inspectUserConfig } from './user-config.js';
7
8
  export async function runConfigCommand(configArgs) {
@@ -37,11 +38,22 @@ export async function runConfigCommand(configArgs) {
37
38
  }
38
39
  const workdir = await workspaceRoot(typeof parsed.values.workspace === 'string' ? parsed.values.workspace : process.cwd());
39
40
  const inspection = await inspectUserConfig(workdir);
40
- const status = await sendHostCommand(workdir, { type: 'host.status' }, { timeoutMs: 2000 }).catch(() => undefined);
41
+ const [status, availableModes] = await Promise.all([
42
+ sendHostCommand(workdir, { type: 'host.status' }, { timeoutMs: 2000 }).catch(() => undefined),
43
+ sub === 'check' ? inspectHostModes(workdir) : undefined,
44
+ ]);
41
45
  if (json) {
42
- process.stdout.write(JSON.stringify({ ok: true, result: { ...inspection, ...(status ? { host: status } : {}) } }) + '\n');
46
+ process.stdout.write(JSON.stringify({
47
+ ok: true,
48
+ result: {
49
+ ...inspection,
50
+ ...(status ? { host: status } : {}),
51
+ ...(availableModes ? { availableModes } : {}),
52
+ },
53
+ }) + '\n');
43
54
  return;
44
55
  }
45
- process.stdout.write((sub === 'check' ? renderConfigCheck(inspection, status) : renderConfigSummary(inspection, status)) +
46
- '\n');
56
+ process.stdout.write((sub === 'check'
57
+ ? renderConfigCheck(inspection, status, availableModes)
58
+ : renderConfigSummary(inspection, status)) + '\n');
47
59
  }
@@ -1,4 +1,4 @@
1
- import type { HostStatusSnapshot } from '@saturn-universe/protocol';
1
+ import type { HostStatusSnapshot, ModeSummary } from '@saturn-universe/protocol';
2
2
  export interface HostLaunchOptions {
3
3
  readonly config?: string;
4
4
  readonly profile?: string;
@@ -15,6 +15,7 @@ export interface ManagedHost {
15
15
  export declare const DEFAULT_HOST_READY_TIMEOUT_MS = 60000;
16
16
  export declare function resolveHostReadyTimeoutMs(env?: NodeJS.ProcessEnv): number;
17
17
  export declare function resolveHostEntry(): Promise<string>;
18
+ export declare function inspectHostModes(root: string): Promise<readonly ModeSummary[]>;
18
19
  export declare function shouldEnableEnvProxy(env: NodeJS.ProcessEnv): boolean;
19
20
  export declare function buildHostSpawnEnv(baseEnv?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
20
21
  export declare function ensureHost(root: string, options?: HostLaunchOptions): Promise<ManagedHost>;
@@ -1,10 +1,11 @@
1
- import { spawn } from 'node:child_process';
1
+ import { execFile, spawn } from 'node:child_process';
2
2
  import { randomUUID } from 'node:crypto';
3
3
  import { access, realpath } from 'node:fs/promises';
4
4
  import path from 'node:path';
5
5
  import { createRequire } from 'node:module';
6
6
  import { setTimeout as delay } from 'node:timers/promises';
7
7
  import { fileURLToPath } from 'node:url';
8
+ import { promisify } from 'node:util';
8
9
  import { matchesModeSelector, parseHostStatusResult } from '@saturn-universe/protocol';
9
10
  import { request } from './client.js';
10
11
  import { CliError, isHostConnectionError, safeCode } from './cli-diagnostics.js';
@@ -71,6 +72,20 @@ function parseHostStartupError(stderrText) {
71
72
  }
72
73
  return undefined;
73
74
  }
75
+ export async function inspectHostModes(root) {
76
+ const hostEntry = await resolveHostEntry();
77
+ try {
78
+ const { stdout } = await promisify(execFile)(process.execPath, [hostEntry, root, '--inspect-modes'], {
79
+ timeout: resolveHostReadyTimeoutMs(),
80
+ windowsHide: true,
81
+ });
82
+ return JSON.parse(stdout);
83
+ }
84
+ catch (error) {
85
+ const { stderr } = error;
86
+ throw (stderr && parseHostStartupError(stderr)) || new CliError('HOST_UNAVAILABLE');
87
+ }
88
+ }
74
89
  export function shouldEnableEnvProxy(env) {
75
90
  return (env.NODE_USE_ENV_PROXY === undefined &&
76
91
  Boolean(env.HTTPS_PROXY?.trim() || env.https_proxy?.trim() || env.HTTP_PROXY?.trim() || env.http_proxy?.trim()));
@@ -197,7 +197,7 @@ export declare function renderTeamBoard(team: TeamQueryResult): string;
197
197
  export declare function renderHostStatus(status: HostStatusSnapshot): string;
198
198
  export declare function renderRunDetails(details: Partial<RunQueryResult>): string;
199
199
  export declare function renderConfigSummary(inspection: UserConfigInspection, status?: HostStatusSnapshot): string;
200
- export declare function renderConfigCheck(inspection: UserConfigInspection, status?: HostStatusSnapshot): string;
200
+ export declare function renderConfigCheck(inspection: UserConfigInspection, status?: HostStatusSnapshot, availableModes?: readonly import("@saturn-universe/protocol").ModeSummary[] | undefined): string;
201
201
  export declare function renderConfigInit(result: InitUserConfigResult): string;
202
202
  export declare function renderUsageCard(usage: SessionUsageView): string;
203
203
  export declare function renderReplHelp(): string;
package/dist/renderer.js CHANGED
@@ -4,7 +4,7 @@ import { reconciliationUsage } from './reconcile-command.js';
4
4
  import { createTerminalPainter, padEndDisplay, paintSgr, stringDisplayWidth, stripAnsi, terminalColorEnabled, } from './terminal-text.js';
5
5
  import { formatDuration } from './duration.js';
6
6
  import { estimateUsageCostUsd, formatCacheRate, formatTokenCompact, formatTokenExact, formatUsd, resolveModelPricing, } from './usage.js';
7
- const SATURN_CLI_VERSION = '0.1.2-dev.2';
7
+ const SATURN_CLI_VERSION = '0.1.2-dev.4';
8
8
  const { bold, dim, cyan, brightCyan, green, yellow, red, magenta, whiteBold } = createTerminalPainter();
9
9
  function padLogoLines(lines) {
10
10
  const maxWidth = Math.max(0, ...lines.map(stringDisplayWidth));
@@ -1002,12 +1002,14 @@ export function renderConfigSummary(inspection, status) {
1002
1002
  return [
1003
1003
  cyan('[Config] 当前设置'),
1004
1004
  ' 工作区:' + inspection.workdir,
1005
- active ? ' 使用的配置文件:' + active.path : ' 目前使用内置设置。',
1005
+ active ? ' 使用的配置文件:' + active.path : ' 未找到 config.toml。',
1006
1006
  status ? ' 工作台已连接。默认模型:' + (status.defaultProfile ?? '尚未选择') : ' 工作台未连接。',
1007
1007
  ].join('\n');
1008
1008
  }
1009
- export function renderConfigCheck(inspection, status) {
1009
+ export function renderConfigCheck(inspection, status, availableModes = status?.availableModes) {
1010
1010
  const lines = [renderConfigSummary(inspection, status)];
1011
+ if (availableModes?.length)
1012
+ lines.push(' 可用模式:' + availableModes.map(({ ref }) => ref).join('、'));
1011
1013
  if (!inspection.files.workspaceConfig.exists && !inspection.files.userConfig.exists) {
1012
1014
  lines.push(' 运行 saturn provider add 连接第一个 AI 服务。');
1013
1015
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saturn-universe/cli",
3
- "version": "0.1.2-dev.2",
3
+ "version": "0.1.2-dev.4",
4
4
  "description": "Saturn local multi-agent runtime CLI",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -9,8 +9,8 @@
9
9
  ],
10
10
  "dependencies": {
11
11
  "@clack/prompts": "1.9.0",
12
- "@saturn-universe/protocol": "0.1.2-dev.2",
13
- "@saturn-universe/runtime-host": "0.1.2-dev.2",
12
+ "@saturn-universe/protocol": "0.1.2-dev.4",
13
+ "@saturn-universe/runtime-host": "0.1.2-dev.4",
14
14
  "mdast-util-from-markdown": "^2.1.0",
15
15
  "mdast-util-gfm": "^3.1.0",
16
16
  "micromark-extension-gfm": "^3.0.0",