pennyrouter 0.2.31 → 0.2.32

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pennyrouter",
3
- "version": "0.2.31",
3
+ "version": "0.2.32",
4
4
  "description": "Install and manage PennyRouter local coding-agent integrations.",
5
5
  "homepage": "https://pennyrouter.com",
6
6
  "bugs": {
@@ -53,6 +53,12 @@ export const opencodeHarness = {
53
53
  const backupPath = await backupFile(configPath, "opencode");
54
54
  const current = await readConfig(configPath);
55
55
  current.provider ||= {};
56
+ current.enabled_providers = Array.isArray(current.enabled_providers)
57
+ ? current.enabled_providers
58
+ : [];
59
+ if (!current.enabled_providers.includes("pennyrouter")) {
60
+ current.enabled_providers.push("pennyrouter");
61
+ }
56
62
  current.provider.pennyrouter = {
57
63
  npm: "@ai-sdk/openai-compatible",
58
64
  name: "PennyRouter",
@@ -97,6 +103,12 @@ export const opencodeHarness = {
97
103
 
98
104
  async uninstall(record) {
99
105
  const current = await readConfig(record.config_path);
106
+ if (Array.isArray(current.enabled_providers)) {
107
+ current.enabled_providers = current.enabled_providers.filter(
108
+ (provider) => provider !== "pennyrouter",
109
+ );
110
+ if (current.enabled_providers.length === 0) delete current.enabled_providers;
111
+ }
100
112
  if (current.provider?.pennyrouter) delete current.provider.pennyrouter;
101
113
  if (current.provider && Object.keys(current.provider).length === 0) delete current.provider;
102
114
  await atomicWrite(record.config_path, `${JSON.stringify(current, null, 2)}\n`);
@@ -18,6 +18,7 @@ async function main() {
18
18
  fs.writeFileSync(configPath, [
19
19
  "{",
20
20
  ' "$schema": "https://opencode.ai/config.json",',
21
+ ' "enabled_providers": ["custom"],',
21
22
  ' "provider": {',
22
23
  ' "custom": { "models": { "model-a": {} } },',
23
24
  " },",
@@ -43,6 +44,7 @@ async function main() {
43
44
  });
44
45
  const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
45
46
  assert.equal(config.provider.custom.models["model-a"] !== undefined, true);
47
+ assert.deepEqual(config.enabled_providers, ["custom", "pennyrouter"]);
46
48
  assert.deepEqual(Object.keys(config.provider.pennyrouter.models), OPENCODE_MODEL_CHOICES.map((model) => model.id));
47
49
  assert.equal(config.provider.pennyrouter.options.baseURL, "https://api.pennyrouter.com/v1");
48
50
  assert.deepEqual(JSON.parse(fs.readFileSync(modelStatePath, "utf8")).recent, ["custom/model-a"]);
@@ -50,6 +52,7 @@ async function main() {
50
52
  await opencodeHarness.uninstall(record);
51
53
  const restored = JSON.parse(fs.readFileSync(configPath, "utf8"));
52
54
  assert.equal(restored.provider.pennyrouter, undefined);
55
+ assert.deepEqual(restored.enabled_providers, ["custom"]);
53
56
  assert.deepEqual(restored.provider.custom.models, { "model-a": {} });
54
57
  const model = JSON.parse(fs.readFileSync(modelStatePath, "utf8"));
55
58
  assert.deepEqual(model.recent, ["custom/model-a"]);