docs: document plugin program cli helpers · openclaw/openclaw@f7e54ac
steipete
·
2026-06-04
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Plugin install command implementation for bundled, npm, path, git, ClawHub, and hook packs. |
1 | 2 | import fs from "node:fs"; |
2 | 3 | import { isRecord } from "@openclaw/normalization-core/record-coerce"; |
3 | 4 | import { uniqueStrings } from "@openclaw/normalization-core/string-normalization"; |
@@ -152,6 +153,7 @@ async function installBundledPluginSource(params: {
|
152 | 153 | invalidateRuntimeCache?: boolean; |
153 | 154 | runtime?: RuntimeEnv; |
154 | 155 | }) { |
| 156 | +// Bundled plugins with required config are recorded but not enabled until config validates. |
155 | 157 | const existingEntry = params.snapshot.config.plugins?.entries?.[params.bundledSource.pluginId]; |
156 | 158 | const shouldEnable = hasValidBundledPluginConfig({ |
157 | 159 | bundledSource: params.bundledSource, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Persistence helpers for plugin and hook-pack installs plus related config mutation. |
1 | 2 | import { theme } from "../../packages/terminal-core/src/theme.js"; |
2 | 3 | import { replaceConfigFile } from "../config/config.js"; |
3 | 4 | import type { OpenClawConfig } from "../config/types.openclaw.js"; |
@@ -83,6 +84,7 @@ function logShadowedNpmInstallWarning(params: {
|
83 | 84 | install: Omit<PluginInstallUpdate, "pluginId">; |
84 | 85 | runtime: RuntimeEnv; |
85 | 86 | }): void { |
| 87 | +// Warn when a newly installed npm plugin is shadowed by an explicit config source. |
86 | 88 | if (params.install.source !== "npm") { |
87 | 89 | return; |
88 | 90 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Text formatter for plugin list rows and verbose plugin details. |
1 | 2 | import { sanitizeTerminalText } from "../../packages/terminal-core/src/safe-text.js"; |
2 | 3 | import { theme } from "../../packages/terminal-core/src/theme.js"; |
3 | 4 | import type { PluginRecord } from "../plugins/registry.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Plugin uninstall command implementation and confirmation-driven removal plan execution. |
1 | 2 | import os from "node:os"; |
2 | 3 | import path from "node:path"; |
3 | 4 | import { theme } from "../../packages/terminal-core/src/theme.js"; |
@@ -32,6 +33,7 @@ export async function runPluginUninstallCommand(
|
32 | 33 | opts: PluginUninstallOptions = {}, |
33 | 34 | runtime: RuntimeEnv = defaultRuntime, |
34 | 35 | ): Promise<void> { |
| 36 | +// Uninstall mutates config/install records and optionally managed files, so guard write mode first. |
35 | 37 | assertConfigWriteAllowedInCurrentMode(); |
36 | 38 | |
37 | 39 | const { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Port inspection and force-free helpers used by gateway run/install flows. |
1 | 2 | import { execFileSync } from "node:child_process"; |
2 | 3 | import { createServer } from "node:net"; |
3 | 4 | import { formatErrorMessage } from "../infra/errors.js"; |
@@ -62,6 +63,7 @@ function getErrnoCode(err: unknown): string | undefined {
|
62 | 63 | } |
63 | 64 | |
64 | 65 | function isRecoverableLsofError(err: unknown): boolean { |
| 66 | +// Permission or missing-binary failures can fall back to fuser on Linux. |
65 | 67 | const code = getErrnoCode(err); |
66 | 68 | if (code === "ENOENT" || code === "EACCES" || code === "EPERM") { |
67 | 69 | return true; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Profile name validation and normalization helpers for root CLI profile routing. |
1 | 2 | import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce"; |
2 | 3 | |
3 | 4 | const PROFILE_NAME_RE = /^[a-z0-9][a-z0-9_-]{0,63}$/i; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Root --profile/--dev parsing and environment projection for profile-specific state. |
1 | 2 | import os from "node:os"; |
2 | 3 | import path from "node:path"; |
3 | 4 | import { |
@@ -21,6 +22,7 @@ function isCommandLocalProfileOption(out: string[]): boolean {
|
21 | 22 | } |
22 | 23 | |
23 | 24 | export function parseCliProfileArgs(argv: string[]): CliProfileParseResult { |
| 25 | +// Root profile flags are stripped before Commander sees argv, except command-local cases. |
24 | 26 | let profile: string | null = null; |
25 | 27 | let sawDev = false; |
26 | 28 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Builds the root Commander program, context, help, hooks, and command registry. |
1 | 2 | import process from "node:process"; |
2 | 3 | import { Command } from "commander"; |
3 | 4 | import { registerProgramCommands } from "./command-registry.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Core command registry that lazily imports command groups based on parsed argv. |
1 | 2 | import type { Command } from "commander"; |
2 | 3 | import { resolveCliArgvInvocation } from "../argv-invocation.js"; |
3 | 4 | import { shouldRegisterPrimaryCommandOnly } from "../command-registration-policy.js"; |
@@ -142,6 +143,7 @@ const coreEntrySpecs: readonly CommandGroupDescriptorSpec<
|
142 | 143 | ]; |
143 | 144 | |
144 | 145 | function resolveCoreCommandGroups(ctx: ProgramContext, argv: string[]): CommandGroupEntry[] { |
| 146 | +// Descriptor metadata and import specs stay separate so help can stay cheap. |
145 | 147 | return buildCommandGroupEntries( |
146 | 148 | getCoreCliCommandDescriptors(), |
147 | 149 | coreEntrySpecs, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// CLI config readiness guard, legacy-state migration routing, and invalid-config allowances. |
1 | 2 | import fs from "node:fs"; |
2 | 3 | import os from "node:os"; |
3 | 4 | import path from "node:path"; |
@@ -97,6 +98,7 @@ function hasBundledChannelLegacyStateMigrationInputs(stateDir: string, oauthDir:
|
97 | 98 | } |
98 | 99 | |
99 | 100 | function hasLegacyStateMigrationInputs(): boolean { |
| 101 | +// Only run migration prompts when old state actually exists in known legacy locations. |
100 | 102 | const stateDir = resolveStateDir(process.env, os.homedir); |
101 | 103 | const oauthDir = resolveOAuthDir(process.env, stateDir); |
102 | 104 | if ( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。