mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:40:43 +00:00
refactor(config): migrate plugin config access
This commit is contained in:
@@ -2,6 +2,8 @@ import { execFileSync } from "node:child_process";
|
||||
import { appendFileSync, existsSync, readFileSync } from "node:fs";
|
||||
import { booleanFlag, parseFlagArgs, stringFlag } from "./lib/arg-utils.mjs";
|
||||
|
||||
const GIT_OUTPUT_MAX_BUFFER = 64 * 1024 * 1024;
|
||||
|
||||
const DOCS_PATH_RE = /^(?:docs\/|README\.md$|AGENTS\.md$|.*\.mdx?$)/u;
|
||||
const APP_PATH_RE = /^(?:apps\/|Swabble\/|appcast\.xml$)/u;
|
||||
const EXTENSION_PATH_RE = /^extensions\/[^/]+(?:\/|$)/u;
|
||||
@@ -248,6 +250,7 @@ function runGitNameOnlyDiff(extraArgs, cwd = process.cwd()) {
|
||||
cwd,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
encoding: "utf8",
|
||||
maxBuffer: GIT_OUTPUT_MAX_BUFFER,
|
||||
});
|
||||
return output.split("\n").map(normalizeChangedPath).filter(Boolean);
|
||||
}
|
||||
@@ -257,6 +260,7 @@ function runGitLsFiles(extraArgs, cwd = process.cwd()) {
|
||||
cwd,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
encoding: "utf8",
|
||||
maxBuffer: GIT_OUTPUT_MAX_BUFFER,
|
||||
});
|
||||
return output.split("\n").map(normalizeChangedPath).filter(Boolean);
|
||||
}
|
||||
@@ -265,6 +269,7 @@ export function listStagedChangedPaths() {
|
||||
const output = execFileSync("git", ["diff", "--cached", "--name-only", "--diff-filter=ACMR"], {
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
encoding: "utf8",
|
||||
maxBuffer: GIT_OUTPUT_MAX_BUFFER,
|
||||
});
|
||||
return output.split("\n").map(normalizeChangedPath).filter(Boolean);
|
||||
}
|
||||
|
||||
@@ -10,13 +10,19 @@ export async function main(argv = process.argv.slice(2)) {
|
||||
const tailChecks = [
|
||||
{ name: "webhook body guard", args: ["lint:webhook:no-low-level-body-read"] },
|
||||
{ name: "runtime action config guard", args: ["check:no-runtime-action-load-config"] },
|
||||
!includeArchitecture
|
||||
? {
|
||||
name: "deprecated internal config API guard",
|
||||
args: ["check:deprecated-internal-config-api"],
|
||||
}
|
||||
: null,
|
||||
{ name: "temp path guard", args: ["check:temp-path-guardrails"] },
|
||||
{ name: "pairing store guard", args: ["lint:auth:no-pairing-store-group"] },
|
||||
{ name: "pairing account guard", args: ["lint:auth:pairing-account-scope"] },
|
||||
includeArchitecture
|
||||
? { name: "architecture import cycles", args: ["check:architecture"] }
|
||||
: { name: "runtime import cycles", args: ["check:import-cycles"] },
|
||||
];
|
||||
].filter(Boolean);
|
||||
|
||||
const stages = [
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { sendMessageTelegram } from "../../extensions/telegram/runtime-api.js";
|
||||
import { loadConfig } from "../../src/config/config.js";
|
||||
import { getRuntimeConfig } from "../../src/config/config.js";
|
||||
import { matchPluginCommand, executePluginCommand } from "../../src/plugins/commands.js";
|
||||
import { loadOpenClawPlugins } from "../../src/plugins/loader.js";
|
||||
|
||||
@@ -35,7 +35,7 @@ if (!chatId) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const cfg = loadConfig();
|
||||
const cfg = getRuntimeConfig();
|
||||
loadOpenClawPlugins({ config: cfg });
|
||||
|
||||
const match = matchPluginCommand("/pair");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { loadAndMaybeMigrateDoctorConfig } from "../src/commands/doctor-config-flow.js";
|
||||
import { writeConfigFile } from "../src/config/config.js";
|
||||
import { replaceConfigFile } from "../src/config/config.js";
|
||||
|
||||
const result = await loadAndMaybeMigrateDoctorConfig({
|
||||
options: {
|
||||
@@ -11,5 +11,5 @@ const result = await loadAndMaybeMigrateDoctorConfig({
|
||||
});
|
||||
|
||||
if (result.shouldWriteConfig) {
|
||||
await writeConfigFile(result.cfg);
|
||||
await replaceConfigFile({ nextConfig: result.cfg });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user