Phase 11: global on/off toggle — SPEC §7.1, §7.3.
Write skillReinject.enabled to ~/.pi/agent/settings.json via merge write without clobbering other keys. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+21
-1
@@ -1,6 +1,6 @@
|
|||||||
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
||||||
import { resolveDeliveryMode } from "./auto-compact.js";
|
import { resolveDeliveryMode } from "./auto-compact.js";
|
||||||
import { readSettings, type SkillReinjectSettings } from "./settings.js";
|
import { readSettings, writeGlobalSettings, type SkillReinjectSettings } from "./settings.js";
|
||||||
import type { AutoCompactIntegration, ExtensionState, RuntimeFlags } from "./state.js";
|
import type { AutoCompactIntegration, ExtensionState, RuntimeFlags } from "./state.js";
|
||||||
|
|
||||||
export interface SkillReinjectCommandDeps {
|
export interface SkillReinjectCommandDeps {
|
||||||
@@ -104,6 +104,10 @@ async function handleSkillReinjectCommand(
|
|||||||
handleSessionToggle(subcommand, ctx, deps);
|
handleSessionToggle(subcommand, ctx, deps);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (subcommand === "global") {
|
||||||
|
handleGlobalToggle(trimmed, ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ctx.hasUI) {
|
if (ctx.hasUI) {
|
||||||
ctx.ui.notify(`skill-reinject: unknown subcommand "${subcommand}"`, "warning");
|
ctx.ui.notify(`skill-reinject: unknown subcommand "${subcommand}"`, "warning");
|
||||||
@@ -134,3 +138,19 @@ function handleSessionToggle(
|
|||||||
const enabledLine = formatEnabledLine(deps.state.sessionOverride, settings);
|
const enabledLine = formatEnabledLine(deps.state.sessionOverride, settings);
|
||||||
ctx.ui.notify(enabledLine, "info");
|
ctx.ui.notify(enabledLine, "info");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleGlobalToggle(args: string, ctx: ExtensionCommandContext): void {
|
||||||
|
const parts = args.trim().split(/\s+/);
|
||||||
|
const action = parts[1];
|
||||||
|
if (action !== "on" && action !== "off") {
|
||||||
|
if (ctx.hasUI) {
|
||||||
|
ctx.ui.notify("skill-reinject: usage: /skill-reinject global on|off", "warning");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
writeGlobalSettings({ enabled: action === "on" });
|
||||||
|
if (!ctx.hasUI) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ctx.ui.notify(`skill-reinject: global ${action}`, "info");
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user