opencode-agent-modes 0.3.1 → 0.3.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.
@@ -27,12 +27,15 @@ export type HierarchicalPreset = Record<string, ModelConfig | HierarchicalPreset
27
27
  * Both opencode and oh-my-opencode use the same HierarchicalPreset type,
28
28
  * allowing them to have arbitrary nested structures that are handled
29
29
  * uniformly by recursive merge functions.
30
+ *
31
+ * The `oh-my-opencode` field is optional to support users who do not use the
32
+ * oh-my-opencode plugin. When absent, all oh-my-opencode related processing is skipped.
30
33
  */
31
34
  export interface ModePreset {
32
35
  description: string;
33
36
  model?: string;
34
37
  opencode: HierarchicalPreset;
35
- 'oh-my-opencode': HierarchicalPreset;
38
+ 'oh-my-opencode'?: HierarchicalPreset;
36
39
  }
37
40
  /**
38
41
  * Main configuration for the mode switcher plugin
package/dist/index.js CHANGED
@@ -13831,7 +13831,7 @@ async function buildPerformancePreset() {
13831
13831
  description: "High-performance models for complex tasks",
13832
13832
  ...globalModel && { model: globalModel },
13833
13833
  opencode: opencodePreset,
13834
- "oh-my-opencode": ohMyOpencodePreset
13834
+ ...ohMyOpencodeConfig && { "oh-my-opencode": ohMyOpencodePreset }
13835
13835
  };
13836
13836
  }
13837
13837
  async function buildEconomyPreset() {
@@ -13843,7 +13843,7 @@ async function buildEconomyPreset() {
13843
13843
  description: "Cost-efficient free model for routine tasks",
13844
13844
  model: DEFAULT_ECONOMY_MODEL,
13845
13845
  opencode: opencodePreset,
13846
- "oh-my-opencode": ohMyOpencodePreset
13846
+ ...ohMyOpencodeConfig && { "oh-my-opencode": ohMyOpencodePreset }
13847
13847
  };
13848
13848
  }
13849
13849
  async function initializeConfig() {
@@ -13991,7 +13991,9 @@ class ModeManager {
13991
13991
  return;
13992
13992
  }
13993
13993
  await this.updateOpencodeConfig(preset.model, preset.opencode);
13994
- await this.updateOhMyOpencodeConfig(preset["oh-my-opencode"]);
13994
+ if (preset["oh-my-opencode"]) {
13995
+ await this.updateOhMyOpencodeConfig(preset["oh-my-opencode"]);
13996
+ }
13995
13997
  this.client.tui.showToast({
13996
13998
  body: {
13997
13999
  title: "Mode Applied",
@@ -14013,7 +14015,7 @@ class ModeManager {
14013
14015
  if (opencodeConfig?.agent && hasDriftRecursive(opencodeConfig.agent, preset.opencode)) {
14014
14016
  return true;
14015
14017
  }
14016
- if (ohMyConfig && hasDriftRecursive(ohMyConfig, preset["oh-my-opencode"])) {
14018
+ if (ohMyConfig && preset["oh-my-opencode"] && hasDriftRecursive(ohMyConfig, preset["oh-my-opencode"])) {
14017
14019
  return true;
14018
14020
  }
14019
14021
  return false;
@@ -14046,7 +14048,7 @@ ${modes}`;
14046
14048
  }
14047
14049
  const globalModel = preset.model ? `Global model: ${preset.model}` : "Global model: (not set)";
14048
14050
  const opencodeTree = formatHierarchicalTree(preset.opencode);
14049
- const ohMyOpencodeTree = formatHierarchicalTree(preset["oh-my-opencode"]);
14051
+ const ohMyOpencodeTree = preset["oh-my-opencode"] ? formatHierarchicalTree(preset["oh-my-opencode"]) : "";
14050
14052
  return [
14051
14053
  `Current mode: ${currentMode}`,
14052
14054
  `Description: ${preset.description}`,
@@ -14070,7 +14072,7 @@ ${modes}`;
14070
14072
  const results = [];
14071
14073
  const opencodeResult = await this.updateOpencodeConfig(preset.model, preset.opencode);
14072
14074
  results.push(`opencode.json: ${opencodeResult}`);
14073
- const ohMyResult = await this.updateOhMyOpencodeConfig(preset["oh-my-opencode"]);
14075
+ const ohMyResult = preset["oh-my-opencode"] ? await this.updateOhMyOpencodeConfig(preset["oh-my-opencode"]) : "skipped (not configured)";
14074
14076
  results.push(`oh-my-opencode.json: ${ohMyResult}`);
14075
14077
  config2.currentMode = modeName;
14076
14078
  this.config = config2;
@@ -79,6 +79,10 @@ export declare class ModeManager {
79
79
  * Checks global model and per-agent model values recursively. Returns true
80
80
  * if any expected value differs from the actual file content.
81
81
  *
82
+ * If the preset does not include an `'oh-my-opencode'` key (i.e., the user
83
+ * does not use the oh-my-opencode plugin), drift checking for that config
84
+ * file is skipped entirely.
85
+ *
82
86
  * @param preset - The mode preset to compare against
83
87
  * @returns True if actual configs differ from the preset
84
88
  * @private
@@ -161,7 +165,7 @@ export declare class ModeManager {
161
165
  * This method performs the following operations:
162
166
  * 1. Validates that the requested mode exists
163
167
  * 2. Updates `opencode.json` with new global model and agent settings
164
- * 3. Updates `oh-my-opencode.json` with new agent settings
168
+ * 3. Updates `oh-my-opencode.json` with new agent settings (skipped if preset has no `'oh-my-opencode'` key)
165
169
  * 4. Updates `agent-mode-switcher.json` with the new current mode
166
170
  * 5. Shows a toast notification (if available)
167
171
  *
@@ -172,6 +176,7 @@ export declare class ModeManager {
172
176
  * @returns Promise resolving to a formatted result message with status of each config update
173
177
  * @example
174
178
  * ```typescript
179
+ * // With oh-my-opencode configured:
175
180
  * const result = await manager.switchMode('economy');
176
181
  * console.log(result);
177
182
  * // Output:
@@ -184,6 +189,18 @@ export declare class ModeManager {
184
189
  * // - agent-mode-switcher.json: updated
185
190
  * //
186
191
  * // Note: Restart opencode to apply changes.
192
+ *
193
+ * // Without oh-my-opencode configured:
194
+ * // Output:
195
+ * // Switched to economy mode
196
+ * // Cost-efficient free model for routine tasks
197
+ * //
198
+ * // Results:
199
+ * // - opencode.json: updated
200
+ * // - oh-my-opencode.json: skipped (not configured)
201
+ * // - agent-mode-switcher.json: updated
202
+ * //
203
+ * // Note: Restart opencode to apply changes.
187
204
  * ```
188
205
  */
189
206
  switchMode(modeName: string): Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-agent-modes",
3
- "version": "0.3.1",
3
+ "version": "0.3.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",