mirror of
http://192.168.0.88:13333/lywsvip/openclaw-zero-token.git
synced 2026-05-08 00:02:20 +08:00
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { replaceCliName, resolveCliName } from "./cli-name.js";
|
|
import { normalizeProfileName } from "./profile-utils.js";
|
|
|
|
const CLI_PREFIX_RE = /^(?:pnpm|npm|bunx|npx)\s+openclaw\b|^openclaw\b/;
|
|
const CONTAINER_FLAG_RE = /(?:^|\s)--container(?:\s|=|$)/;
|
|
const PROFILE_FLAG_RE = /(?:^|\s)--profile(?:\s|=|$)/;
|
|
const DEV_FLAG_RE = /(?:^|\s)--dev(?:\s|$)/;
|
|
const UPDATE_COMMAND_RE =
|
|
/^(?:pnpm|npm|bunx|npx)\s+openclaw\b.*(?:^|\s)update(?:\s|$)|^openclaw\b.*(?:^|\s)update(?:\s|$)/;
|
|
|
|
export function formatCliCommand(
|
|
command: string,
|
|
env: Record<string, string | undefined> = process.env as Record<string, string | undefined>,
|
|
): string {
|
|
const cliName = resolveCliName();
|
|
const normalizedCommand = replaceCliName(command, cliName);
|
|
const container = env.OPENCLAW_CONTAINER_HINT?.trim();
|
|
const profile = normalizeProfileName(env.OPENCLAW_PROFILE);
|
|
if (!container && !profile) {
|
|
return normalizedCommand;
|
|
}
|
|
if (!CLI_PREFIX_RE.test(normalizedCommand)) {
|
|
return normalizedCommand;
|
|
}
|
|
const additions: string[] = [];
|
|
if (
|
|
container &&
|
|
!CONTAINER_FLAG_RE.test(normalizedCommand) &&
|
|
!UPDATE_COMMAND_RE.test(normalizedCommand)
|
|
) {
|
|
additions.push(`--container ${container}`);
|
|
}
|
|
if (
|
|
!container &&
|
|
profile &&
|
|
!PROFILE_FLAG_RE.test(normalizedCommand) &&
|
|
!DEV_FLAG_RE.test(normalizedCommand)
|
|
) {
|
|
additions.push(`--profile ${profile}`);
|
|
}
|
|
if (additions.length === 0) {
|
|
return normalizedCommand;
|
|
}
|
|
return normalizedCommand.replace(CLI_PREFIX_RE, (match) => `${match} ${additions.join(" ")}`);
|
|
}
|