@scotteza/opencode-spoken-replies 1.0.5 → 1.0.6

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/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  OpenCode Spoken Replies lets OpenCode read assistant replies aloud as they arrive. Choose a voice, adjust the speed, and pause or replay speech from the terminal interface.
4
4
 
5
- This independently maintained fork builds on [opencode-tts-voice](https://github.com/semirhuduti/opencode-tts-voice). It is not maintained, endorsed, or supported by the original author.
5
+ This independently maintained fork builds on [opencode-tts-voice](https://github.com/semirhuduti/opencode-tts-voice) from Semir Huduti. It is not maintained, endorsed, or supported by the original author.
6
6
 
7
- If you appreciate the original author's work, please [buy Semir Huduti a coffee](https://www.buymeacoffee.com/semirhuduti).
7
+ If you appreciate the original author's work, please buy him a coffee using the link below .
8
8
 
9
9
  [![Buy Semir Huduti a coffee](https://cdn.buymeacoffee.com/buttons/default-orange.png)](https://www.buymeacoffee.com/semirhuduti)
10
10
 
@@ -27,6 +27,30 @@ Install the published npm package with:
27
27
  opencode plugin add @scotteza/opencode-spoken-replies
28
28
  ```
29
29
 
30
+ ### Windows setup
31
+
32
+ The TTS helper needs Node.js or Bun available to the OpenCode process. If OpenCode reports that it cannot find either runtime, install [Node.js](https://nodejs.org/en/download/) for Windows and enable the installer option to add Node to `PATH`. Then fully exit and restart OpenCode so it inherits the updated `PATH`. Verify Node is available in PowerShell with:
33
+
34
+ ```powershell
35
+ node --version
36
+ where.exe node
37
+ ```
38
+
39
+ Windows also needs an audio player on `PATH`; install a Windows build of `ffplay` or `mpv`. If OpenCode still cannot find Node, set `ttsServiceCommand` in this plugin's `options` to the full path to `node.exe`, for example:
40
+
41
+ ```jsonc
42
+ {
43
+ "plugins": [
44
+ {
45
+ "package": "@scotteza/opencode-spoken-replies",
46
+ "options": {
47
+ "ttsServiceCommand": "C:\\Program Files\\nodejs\\node.exe"
48
+ }
49
+ }
50
+ ]
51
+ }
52
+ ```
53
+
30
54
  Or add it to the `plugins` array in your OpenCode `opencode.json` or `opencode.jsonc`:
31
55
 
32
56
  ```jsonc
@@ -43,6 +43,7 @@ import { Rpc } from "@opencode/plugin/rpc";
43
43
 
44
44
  // src/voice-constants.ts
45
45
  var PLUGIN_ID = "opencode-spoken-replies";
46
+ var PLUGIN_PACKAGE = "@scotteza/opencode-spoken-replies";
46
47
  var KV_ENABLED = `${PLUGIN_ID}.enabled`;
47
48
  var DEFAULT_MODEL = "onnx-community/Kokoro-82M-v1.0-ONNX";
48
49
  var DEFAULT_CONFIG = {
@@ -1434,6 +1434,7 @@ import * as path3 from "path";
1434
1434
 
1435
1435
  // src/voice-constants.ts
1436
1436
  var PLUGIN_ID = "opencode-spoken-replies";
1437
+ var PLUGIN_PACKAGE = "@scotteza/opencode-spoken-replies";
1437
1438
  var KV_ENABLED = `${PLUGIN_ID}.enabled`;
1438
1439
  var DEFAULT_MODEL = "onnx-community/Kokoro-82M-v1.0-ONNX";
1439
1440
  var DEFAULT_CONFIG = {
@@ -2981,6 +2982,46 @@ function resolveVoiceConfig(options) {
2981
2982
  };
2982
2983
  }
2983
2984
 
2985
+ // src/voice-plugin-options.ts
2986
+ function isRecord2(value) {
2987
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
2988
+ }
2989
+ function optionsFromEntry(entry) {
2990
+ if (isRecord2(entry) && entry.package === PLUGIN_PACKAGE && isRecord2(entry.options)) {
2991
+ return entry.options;
2992
+ }
2993
+ if (Array.isArray(entry) && entry[0] === PLUGIN_PACKAGE && isRecord2(entry[1])) {
2994
+ return entry[1];
2995
+ }
2996
+ return;
2997
+ }
2998
+ function findVoicePluginOptions(response) {
2999
+ const payload = isRecord2(response) && "data" in response ? response.data : response;
3000
+ const documents = Array.isArray(payload) ? payload : [payload];
3001
+ const options = {};
3002
+ let found = false;
3003
+ for (const document of documents) {
3004
+ if (!isRecord2(document))
3005
+ continue;
3006
+ const info = isRecord2(document.info) ? document.info : document;
3007
+ const entries = Array.isArray(info.plugins) ? info.plugins : Array.isArray(info.plugin) ? info.plugin : [];
3008
+ for (const entry of entries) {
3009
+ const configured = optionsFromEntry(entry);
3010
+ if (!configured)
3011
+ continue;
3012
+ Object.assign(options, configured);
3013
+ found = true;
3014
+ }
3015
+ }
3016
+ return found ? options : undefined;
3017
+ }
3018
+ function mergeVoicePluginOptions(configured, runtime) {
3019
+ return {
3020
+ ...configured ?? {},
3021
+ ...isRecord2(runtime) ? runtime : {}
3022
+ };
3023
+ }
3024
+
2984
3025
  // src/voice-rpc.ts
2985
3026
  import { Rpc } from "@opencode/plugin/rpc";
2986
3027
  var state = {
@@ -3018,7 +3059,15 @@ function Status(props) {
3018
3059
  var tui_plugin_default = Plugin.define({
3019
3060
  id: PLUGIN_ID,
3020
3061
  async setup(api) {
3021
- const config = resolveVoiceConfig(api.options);
3062
+ let configuredOptions;
3063
+ try {
3064
+ configuredOptions = findVoicePluginOptions(await api.client.config.get());
3065
+ } catch (error) {
3066
+ log.warn("could not read plugin options from OpenCode config", {
3067
+ error: String(error)
3068
+ });
3069
+ }
3070
+ const config = resolveVoiceConfig(mergeVoicePluginOptions(configuredOptions, api.options));
3022
3071
  const voice = api.client.rpc(VoiceRpc);
3023
3072
  const location = api.location ?? api.data.location.default();
3024
3073
  let enabled = true;
@@ -1,5 +1,6 @@
1
1
  import type { VoiceConfig } from "./voice-types.js";
2
2
  export declare const PLUGIN_ID = "opencode-spoken-replies";
3
+ export declare const PLUGIN_PACKAGE = "@scotteza/opencode-spoken-replies";
3
4
  export declare const KV_ENABLED = "opencode-spoken-replies.enabled";
4
5
  export declare const DEFAULT_MODEL = "onnx-community/Kokoro-82M-v1.0-ONNX";
5
6
  export declare const DEFAULT_CONFIG: VoiceConfig;
@@ -0,0 +1,3 @@
1
+ import type { VoicePluginOptions } from "./voice-types.js";
2
+ export declare function findVoicePluginOptions(response: unknown): VoicePluginOptions | undefined;
3
+ export declare function mergeVoicePluginOptions(configured: VoicePluginOptions | undefined, runtime: unknown): VoicePluginOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scotteza/opencode-spoken-replies",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Local Kokoro text-to-speech for OpenCode assistant replies",
5
5
  "keywords": [
6
6
  "opencode",