opencode-discipline 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +26 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19652,7 +19652,10 @@ var WAVE_NEXT_STEPS = {
|
|
|
19652
19652
|
4: "plan review and refinement"
|
|
19653
19653
|
};
|
|
19654
19654
|
var PLUGIN_DISPLAY_NAME = "opencode-discipline";
|
|
19655
|
-
var
|
|
19655
|
+
var startupToastShownByDirectory = new Set;
|
|
19656
|
+
var startupToastInFlightByDirectory = new Set;
|
|
19657
|
+
var startupToastAttemptsByDirectory = new Map;
|
|
19658
|
+
var MAX_STARTUP_TOAST_ATTEMPTS = 8;
|
|
19656
19659
|
function parseNotificationMode(raw) {
|
|
19657
19660
|
const value = raw?.trim().toLowerCase();
|
|
19658
19661
|
if (!value) {
|
|
@@ -19679,13 +19682,16 @@ function readPluginVersion(pluginDir) {
|
|
|
19679
19682
|
}
|
|
19680
19683
|
}
|
|
19681
19684
|
async function showStartupToast(client, directory, version2) {
|
|
19682
|
-
|
|
19685
|
+
const attempts = startupToastAttemptsByDirectory.get(directory) ?? 0;
|
|
19686
|
+
if (startupToastShownByDirectory.has(directory) || startupToastInFlightByDirectory.has(directory) || attempts >= MAX_STARTUP_TOAST_ATTEMPTS) {
|
|
19683
19687
|
return;
|
|
19684
19688
|
}
|
|
19685
19689
|
const tuiApi = client.tui;
|
|
19686
19690
|
if (!tuiApi || typeof tuiApi.showToast !== "function") {
|
|
19687
19691
|
return;
|
|
19688
19692
|
}
|
|
19693
|
+
startupToastInFlightByDirectory.add(directory);
|
|
19694
|
+
startupToastAttemptsByDirectory.set(directory, attempts + 1);
|
|
19689
19695
|
try {
|
|
19690
19696
|
await tuiApi.showToast({
|
|
19691
19697
|
query: { directory },
|
|
@@ -19696,8 +19702,20 @@ async function showStartupToast(client, directory, version2) {
|
|
|
19696
19702
|
duration: 3000
|
|
19697
19703
|
}
|
|
19698
19704
|
});
|
|
19699
|
-
|
|
19700
|
-
} catch {}
|
|
19705
|
+
startupToastShownByDirectory.add(directory);
|
|
19706
|
+
} catch {} finally {
|
|
19707
|
+
startupToastInFlightByDirectory.delete(directory);
|
|
19708
|
+
}
|
|
19709
|
+
}
|
|
19710
|
+
async function handleEvent(ctx, input, pluginVersion) {
|
|
19711
|
+
if (startupToastShownByDirectory.has(ctx.directory)) {
|
|
19712
|
+
return;
|
|
19713
|
+
}
|
|
19714
|
+
const eventType = input.event?.type;
|
|
19715
|
+
if (eventType !== "server.connected" && eventType !== "session.created" && eventType !== "session.status" && eventType !== "tui.command.execute") {
|
|
19716
|
+
return;
|
|
19717
|
+
}
|
|
19718
|
+
await showStartupToast(ctx.client, ctx.directory, pluginVersion);
|
|
19701
19719
|
}
|
|
19702
19720
|
function escapeAppleScriptString(value) {
|
|
19703
19721
|
return value.replaceAll("\\", "\\\\").replaceAll('"', "\\\"");
|
|
@@ -20420,7 +20438,9 @@ var DisciplinePlugin = async ({ worktree, directory, client }) => {
|
|
|
20420
20438
|
directory,
|
|
20421
20439
|
client
|
|
20422
20440
|
};
|
|
20423
|
-
|
|
20441
|
+
queueMicrotask(() => {
|
|
20442
|
+
showStartupToast(client, directory, pluginVersion);
|
|
20443
|
+
});
|
|
20424
20444
|
return {
|
|
20425
20445
|
config: async (input) => {
|
|
20426
20446
|
const agents = input.agent;
|
|
@@ -20430,6 +20450,7 @@ var DisciplinePlugin = async ({ worktree, directory, client }) => {
|
|
|
20430
20450
|
}
|
|
20431
20451
|
input.agent = { ...agents, ...merged };
|
|
20432
20452
|
},
|
|
20453
|
+
event: (input) => handleEvent(ctx, input, pluginVersion),
|
|
20433
20454
|
"experimental.session.compacting": (input, output) => handleCompacting(ctx, input, output),
|
|
20434
20455
|
"experimental.chat.system.transform": (input, output) => handleSystemTransform(ctx, input, output),
|
|
20435
20456
|
"tool.execute.before": (input, output) => handleToolExecuteBefore(ctx, input, output),
|