several changes
This commit is contained in:
1
pi/files/agent/extensions/matugen-theme-watch/.gitignore
vendored
Normal file
1
pi/files/agent/extensions/matugen-theme-watch/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
@@ -0,0 +1,21 @@
|
||||
import tseslint from "@typescript-eslint/eslint-plugin";
|
||||
import tsParser from "@typescript-eslint/parser";
|
||||
|
||||
export default [
|
||||
{
|
||||
files: ["**/*.ts"],
|
||||
languageOptions: {
|
||||
parser: tsParser,
|
||||
parserOptions: {
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
"@typescript-eslint": tseslint,
|
||||
},
|
||||
rules: {
|
||||
...tseslint.configs.recommended.rules,
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -96,7 +96,7 @@ async function loadThemeFromPath(filePath: string): Promise<PiTheme> {
|
||||
});
|
||||
}
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
export default function matugenThemeWatch(pi: ExtensionAPI) {
|
||||
let watcher: fs.StatWatcher | null = null;
|
||||
let debounce: NodeJS.Timeout | null = null;
|
||||
|
||||
@@ -113,14 +113,14 @@ export default function (pi: ExtensionAPI) {
|
||||
}
|
||||
|
||||
debounce = setTimeout(async () => {
|
||||
try {
|
||||
const theme = await loadThemeFromPath(THEME_PATH);
|
||||
const result = ctx.ui.setTheme(theme);
|
||||
if (!result.success && result.error) {
|
||||
ctx.ui.notify(`Theme reload failed: ${result.error}`, "error");
|
||||
}
|
||||
} catch (error) {
|
||||
ctx.ui.notify(`Theme reload failed: ${String(error)}`, "error");
|
||||
// i wish this fucking worked
|
||||
// pi.sendUserMessage("/reload", { deliverAs: "followUp" });
|
||||
const theme = await loadThemeFromPath(THEME_PATH);
|
||||
const res = ctx.ui.setTheme(theme);
|
||||
if (res.success) {
|
||||
ctx.ui.notify("Background changed. Colors: ", "info");
|
||||
} else {
|
||||
ctx.ui.notify("Theme update failed, fuck", "error");
|
||||
}
|
||||
}, 150);
|
||||
},
|
||||
@@ -132,7 +132,8 @@ export default function (pi: ExtensionAPI) {
|
||||
|
||||
pi.on("session_shutdown", () => {
|
||||
if (watcher) {
|
||||
fs.unwatchFile(THEME_PATH, watcher);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- weird types
|
||||
fs.unwatchFile(THEME_PATH, watcher as any);
|
||||
watcher = null;
|
||||
}
|
||||
if (debounce) {
|
||||
13
pi/files/agent/extensions/matugen-theme-watch/package.json
Normal file
13
pi/files/agent/extensions/matugen-theme-watch/package.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "pi-extensions",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.11.0",
|
||||
"@mariozechner/pi-coding-agent": "^0.54.0",
|
||||
"@sinclair/typebox": "^0.34.0",
|
||||
"eslint": "^9.0.0",
|
||||
"@typescript-eslint/parser": "^8.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.0.0"
|
||||
}
|
||||
}
|
||||
3427
pi/files/agent/extensions/matugen-theme-watch/pnpm-lock.yaml
generated
Normal file
3427
pi/files/agent/extensions/matugen-theme-watch/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
pi/files/agent/extensions/matugen-theme-watch/tsconfig.json
Normal file
12
pi/files/agent/extensions/matugen-theme-watch/tsconfig.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"types": ["node"],
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": ["**/*.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user