fix(sf): inline extractBodyAfterFrontmatter — it is not exported from commands-prefs-wizard
extractBodyAfterFrontmatter is a private function in commands-prefs-wizard.js. Inline a local copy in experimental.js and handleThemeCommand (core.js) rather than importing a non-existent export. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
b34f5997eb
commit
3017663a69
2 changed files with 22 additions and 7 deletions
|
|
@ -958,11 +958,19 @@ async function handleDiffCommand(args, ctx) {
|
|||
|
||||
// ─── /theme ─────────────────────────────────────────────────────────────────
|
||||
|
||||
function extractBodyAfterFrontmatterLocal(content) {
|
||||
const closingIdx = content.indexOf("\n---", content.indexOf("---"));
|
||||
if (closingIdx === -1) return null;
|
||||
const afterFrontmatter = content.slice(closingIdx + 4);
|
||||
return afterFrontmatter.trim() ? afterFrontmatter : null;
|
||||
}
|
||||
|
||||
async function handleThemeCommand(args, ctx) {
|
||||
const THEMES = ["dark", "light", "dim", "auto"];
|
||||
const { loadEffectiveSFPreferences } = await import("../../preferences.js");
|
||||
const { extractBodyAfterFrontmatter, serializePreferencesToFrontmatter } =
|
||||
await import("../../commands-prefs-wizard.js");
|
||||
const { serializePreferencesToFrontmatter } = await import(
|
||||
"../../commands-prefs-wizard.js"
|
||||
);
|
||||
const { readFileSync, writeFileSync, existsSync } = await import("node:fs");
|
||||
|
||||
if (!args) {
|
||||
|
|
@ -990,7 +998,9 @@ async function handleThemeCommand(args, ctx) {
|
|||
let body =
|
||||
"\n# SF Preferences\n\nSee `~/.sf/agent/extensions/sf/docs/preferences-reference.md` for full documentation.\n";
|
||||
if (existsSync(path)) {
|
||||
const preserved = extractBodyAfterFrontmatter(readFileSync(path, "utf-8"));
|
||||
const preserved = extractBodyAfterFrontmatterLocal(
|
||||
readFileSync(path, "utf-8"),
|
||||
);
|
||||
if (preserved) body = preserved;
|
||||
}
|
||||
const { mkdirSync } = await import("node:fs");
|
||||
|
|
|
|||
|
|
@ -10,16 +10,21 @@
|
|||
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { dirname } from "node:path";
|
||||
import {
|
||||
extractBodyAfterFrontmatter,
|
||||
serializePreferencesToFrontmatter,
|
||||
} from "./commands-prefs-wizard.js";
|
||||
import { serializePreferencesToFrontmatter } from "./commands-prefs-wizard.js";
|
||||
import {
|
||||
getProjectSFPreferencesPath,
|
||||
loadEffectiveSFPreferences,
|
||||
loadProjectSFPreferences,
|
||||
} from "./preferences.js";
|
||||
|
||||
/** Extract the body section that follows a YAML frontmatter block. */
|
||||
function extractBodyAfterFrontmatter(content) {
|
||||
const closingIdx = content.indexOf("\n---", content.indexOf("---"));
|
||||
if (closingIdx === -1) return null;
|
||||
const afterFrontmatter = content.slice(closingIdx + 4);
|
||||
return afterFrontmatter.trim() ? afterFrontmatter : null;
|
||||
}
|
||||
|
||||
/** All recognized experimental feature flags with descriptions. */
|
||||
export const EXPERIMENTAL_FLAGS = {
|
||||
status_line:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue