源码快照 @ 2026-09-02 (source-only, 剔除非源码素材)
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
const PORTABLE_OPENCODE_TOP_LEVEL_KEYS = [
|
||||
"agent",
|
||||
"command",
|
||||
"instructions",
|
||||
"mcp",
|
||||
"permission",
|
||||
"plugin",
|
||||
"share",
|
||||
"tools",
|
||||
"watcher",
|
||||
] as const;
|
||||
|
||||
function cloneJson<T>(value: T): T {
|
||||
return JSON.parse(JSON.stringify(value));
|
||||
}
|
||||
|
||||
export function sanitizePortableOpencodeConfig(opencode: Record<string, unknown> | null | undefined): Record<string, unknown> {
|
||||
const source = opencode && typeof opencode === "object" && !Array.isArray(opencode) ? opencode : {};
|
||||
const next: Record<string, unknown> = {};
|
||||
|
||||
for (const key of PORTABLE_OPENCODE_TOP_LEVEL_KEYS) {
|
||||
if (!(key in source)) continue;
|
||||
next[key] = cloneJson(source[key]);
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
Reference in New Issue
Block a user