opencode-auto-loop 0.1.0 → 0.1.1
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/package.json +1 -1
- package/src/index.ts +18 -5
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -52,11 +52,13 @@ function copyIfChanged(src: string, dest: string): void {
|
|
|
52
52
|
cpSync(src, dest, { recursive: true });
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
// Auto-copy skills and commands to opencode config, updating if content changed
|
|
56
|
-
|
|
55
|
+
// Auto-copy skills and commands to opencode config, updating if content changed.
|
|
56
|
+
// Returns true if any new files were copied (first install), false otherwise.
|
|
57
|
+
function setupSkillsAndCommands(log: LogFn): boolean {
|
|
57
58
|
const pluginRoot = getPluginRoot();
|
|
58
59
|
const skillsDir = join(OPENCODE_CONFIG_DIR, "skill");
|
|
59
60
|
const commandsDir = join(OPENCODE_CONFIG_DIR, "command");
|
|
61
|
+
let newFilesCopied = false;
|
|
60
62
|
|
|
61
63
|
// Copy skills
|
|
62
64
|
const pluginSkillsDir = join(pluginRoot, "skills");
|
|
@@ -65,8 +67,10 @@ function setupSkillsAndCommands(log: LogFn): void {
|
|
|
65
67
|
for (const skill of skills) {
|
|
66
68
|
const srcFile = join(pluginSkillsDir, skill, "SKILL.md");
|
|
67
69
|
const destFile = join(skillsDir, skill, "SKILL.md");
|
|
70
|
+
const isNew = !existsSync(destFile);
|
|
68
71
|
try {
|
|
69
72
|
copyIfChanged(srcFile, destFile);
|
|
73
|
+
if (isNew && existsSync(destFile)) newFilesCopied = true;
|
|
70
74
|
} catch (err) {
|
|
71
75
|
log("warn", `Failed to copy skill '${skill}': ${err}`);
|
|
72
76
|
}
|
|
@@ -78,13 +82,18 @@ function setupSkillsAndCommands(log: LogFn): void {
|
|
|
78
82
|
if (existsSync(pluginCommandsDir)) {
|
|
79
83
|
const commands = ["auto-loop.md", "cancel-auto-loop.md", "auto-loop-help.md"];
|
|
80
84
|
for (const cmd of commands) {
|
|
85
|
+
const destCmd = join(commandsDir, cmd);
|
|
86
|
+
const isNew = !existsSync(destCmd);
|
|
81
87
|
try {
|
|
82
|
-
copyIfChanged(join(pluginCommandsDir, cmd),
|
|
88
|
+
copyIfChanged(join(pluginCommandsDir, cmd), destCmd);
|
|
89
|
+
if (isNew && existsSync(destCmd)) newFilesCopied = true;
|
|
83
90
|
} catch (err) {
|
|
84
91
|
log("warn", `Failed to copy command '${cmd}': ${err}`);
|
|
85
92
|
}
|
|
86
93
|
}
|
|
87
94
|
}
|
|
95
|
+
|
|
96
|
+
return newFilesCopied;
|
|
88
97
|
}
|
|
89
98
|
|
|
90
99
|
// Get state file path (project-relative)
|
|
@@ -366,8 +375,12 @@ export const AutoLoopPlugin: Plugin = async (ctx) => {
|
|
|
366
375
|
}
|
|
367
376
|
};
|
|
368
377
|
|
|
369
|
-
// Auto-setup skills and commands
|
|
370
|
-
setupSkillsAndCommands(log);
|
|
378
|
+
// Auto-setup skills and commands — notify on first install
|
|
379
|
+
const isFirstInstall = setupSkillsAndCommands(log);
|
|
380
|
+
if (isFirstInstall) {
|
|
381
|
+
toast("Auto Loop installed — restart opencode to enable /auto-loop commands", "warning");
|
|
382
|
+
log("info", "First install detected — commands copied, restart needed for slash commands");
|
|
383
|
+
}
|
|
371
384
|
|
|
372
385
|
// Debounce tracking for idle events
|
|
373
386
|
let lastContinuation = 0;
|