opencode-agent-modes 0.1.1 → 0.1.2

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.
@@ -1,9 +1,34 @@
1
+ /**
2
+ * @fileoverview Command file installer for OpenCode slash commands.
3
+ *
4
+ * This module handles copying slash command markdown files from the plugin's
5
+ * commands directory to OpenCode's configuration directory during plugin
6
+ * initialization. This ensures command files are available without requiring
7
+ * manual postinstall script execution.
8
+ *
9
+ * @module config/command-installer
10
+ */
1
11
  /**
2
12
  * Copies slash command markdown files to OpenCode's command directory.
3
13
  *
4
14
  * This function is called during plugin initialization to ensure
5
15
  * command files are available without manual postinstall execution.
16
+ * It creates the destination directory if it doesn't exist and copies
17
+ * all `.md` files from the source commands directory.
18
+ *
19
+ * The function is designed to be non-fatal: if copying fails (e.g., due to
20
+ * permission issues), it logs a warning but doesn't throw an error,
21
+ * allowing the plugin to continue initializing.
22
+ *
23
+ * @returns Number of files successfully copied, or -1 if source directory
24
+ * not found or an error occurred during copying
6
25
  *
7
- * @returns Number of files copied, or -1 if source directory not found
26
+ * @example
27
+ * ```typescript
28
+ * const copied = copyCommandFiles();
29
+ * if (copied > 0) {
30
+ * console.log(`Copied ${copied} command files`);
31
+ * }
32
+ * ```
8
33
  */
9
34
  export declare function copyCommandFiles(): number;
package/dist/index.js CHANGED
@@ -14033,11 +14033,17 @@ import { homedir as homedir2 } from "os";
14033
14033
  import { dirname, join as join2 } from "path";
14034
14034
  import { fileURLToPath } from "url";
14035
14035
  var COMMANDS_DEST = join2(homedir2(), ".config", "opencode", "command");
14036
- function copyCommandFiles() {
14036
+ function findCommandsDir() {
14037
14037
  const __dirname2 = dirname(fileURLToPath(import.meta.url));
14038
- const commandsSrc = join2(__dirname2, "..", "..", "commands");
14039
- if (!existsSync(commandsSrc)) {
14040
- console.warn("[agent-mode-switcher] Commands directory not found:", commandsSrc);
14038
+ const candidates = [
14039
+ join2(__dirname2, "..", "commands"),
14040
+ join2(__dirname2, "..", "..", "commands")
14041
+ ];
14042
+ return candidates.find(existsSync) ?? null;
14043
+ }
14044
+ function copyCommandFiles() {
14045
+ const commandsSrc = findCommandsDir();
14046
+ if (!commandsSrc) {
14041
14047
  return -1;
14042
14048
  }
14043
14049
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-agent-modes",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "OpenCode plugin to switch agent modes between performance and economy presets",
5
5
  "module": "src/index.ts",
6
6
  "main": "dist/index.js",