@aliou/pi-ts-aperture 0.0.1 → 0.1.0

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.json +12 -19
  3. package/src/commands/settings.ts +7 -4
  4. package/src/commands/setup.ts +6 -3
  5. package/src/index.ts +56 -18
  6. package/.envrc +0 -21
  7. package/.osgrep/cache/meta.lmdb +0 -0
  8. package/.osgrep/cache/meta.lmdb-lock +0 -0
  9. package/.osgrep/lancedb/chunks.lance/_indices/b9016ebf-b6e6-4c43-be9f-7413728f6389/metadata.lance +0 -0
  10. package/.osgrep/lancedb/chunks.lance/_indices/b9016ebf-b6e6-4c43-be9f-7413728f6389/part_11_docs.lance +0 -0
  11. package/.osgrep/lancedb/chunks.lance/_indices/b9016ebf-b6e6-4c43-be9f-7413728f6389/part_11_invert.lance +0 -0
  12. package/.osgrep/lancedb/chunks.lance/_indices/b9016ebf-b6e6-4c43-be9f-7413728f6389/part_11_tokens.lance +0 -0
  13. package/.osgrep/lancedb/chunks.lance/_indices/cc7bd185-bc88-4dbd-af7f-6aac2f6b29d3/metadata.lance +0 -0
  14. package/.osgrep/lancedb/chunks.lance/_indices/cc7bd185-bc88-4dbd-af7f-6aac2f6b29d3/part_0_docs.lance +0 -0
  15. package/.osgrep/lancedb/chunks.lance/_indices/cc7bd185-bc88-4dbd-af7f-6aac2f6b29d3/part_0_invert.lance +0 -0
  16. package/.osgrep/lancedb/chunks.lance/_indices/cc7bd185-bc88-4dbd-af7f-6aac2f6b29d3/part_0_tokens.lance +0 -0
  17. package/.osgrep/lancedb/chunks.lance/_indices/cd01c8d9-fae8-4482-b01f-59f06abe1b48/metadata.lance +0 -0
  18. package/.osgrep/lancedb/chunks.lance/_indices/cd01c8d9-fae8-4482-b01f-59f06abe1b48/part_0_docs.lance +0 -0
  19. package/.osgrep/lancedb/chunks.lance/_indices/cd01c8d9-fae8-4482-b01f-59f06abe1b48/part_0_invert.lance +0 -0
  20. package/.osgrep/lancedb/chunks.lance/_indices/cd01c8d9-fae8-4482-b01f-59f06abe1b48/part_0_tokens.lance +0 -0
  21. package/.osgrep/lancedb/chunks.lance/_indices/dedba042-4a7b-44d7-ac2f-258233b62681/metadata.lance +0 -0
  22. package/.osgrep/lancedb/chunks.lance/_indices/dedba042-4a7b-44d7-ac2f-258233b62681/part_0_docs.lance +0 -0
  23. package/.osgrep/lancedb/chunks.lance/_indices/dedba042-4a7b-44d7-ac2f-258233b62681/part_0_invert.lance +0 -0
  24. package/.osgrep/lancedb/chunks.lance/_indices/dedba042-4a7b-44d7-ac2f-258233b62681/part_0_tokens.lance +0 -0
  25. package/.osgrep/lancedb/chunks.lance/_transactions/0-fd59fbcc-e229-4069-b8b0-764b34f2d645.txn +0 -0
  26. package/.osgrep/lancedb/chunks.lance/_transactions/1-f130f13d-123c-4e71-b806-b6b4f6cdd6d8.txn +0 -0
  27. package/.osgrep/lancedb/chunks.lance/_transactions/2-5f641c2a-07a9-45a1-b450-72c7d4d38754.txn +0 -1
  28. package/.osgrep/lancedb/chunks.lance/_transactions/3-83167775-6ec4-4cb6-9388-6549f583087a.txn +0 -0
  29. package/.osgrep/lancedb/chunks.lance/_transactions/4-feb1627d-f860-4c02-b8a6-6b93cf42ec22.txn +0 -0
  30. package/.osgrep/lancedb/chunks.lance/_transactions/5-e00ef82b-90b4-4c91-a7ec-d7b4903e1c61.txn +0 -0
  31. package/.osgrep/lancedb/chunks.lance/_transactions/6-ccc1d487-f511-4e48-afa0-2edf42f8effd.txn +0 -0
  32. package/.osgrep/lancedb/chunks.lance/_transactions/7-b26d7d18-4411-44cd-b559-54bfa2999b70.txn +0 -0
  33. package/.osgrep/lancedb/chunks.lance/_versions/1.manifest +0 -0
  34. package/.osgrep/lancedb/chunks.lance/_versions/2.manifest +0 -0
  35. package/.osgrep/lancedb/chunks.lance/_versions/3.manifest +0 -0
  36. package/.osgrep/lancedb/chunks.lance/_versions/4.manifest +0 -0
  37. package/.osgrep/lancedb/chunks.lance/_versions/5.manifest +0 -0
  38. package/.osgrep/lancedb/chunks.lance/_versions/6.manifest +0 -0
  39. package/.osgrep/lancedb/chunks.lance/_versions/7.manifest +0 -0
  40. package/.osgrep/lancedb/chunks.lance/_versions/8.manifest +0 -0
  41. package/.osgrep/lancedb/chunks.lance/data/0110110100011111000100108ca476475fac277950ba4295de.lance +0 -0
  42. package/.osgrep/lancedb/chunks.lance/data/111110011111110001101001d059cb4ceab8147482b4391458.lance +0 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # @aliou/pi-ts-aperture
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ebb9556: Initial release. Route Pi LLM providers through Tailscale Aperture.
8
+
9
+ - `/aperture:setup` interactive wizard (base URL + provider multi-select)
10
+ - `/aperture:settings` settings UI for updating configuration
11
+ - Auto-registers selected providers with Aperture base URL on load
12
+
13
+ ### Patch Changes
14
+
15
+ - 7388139: Fix providers not taking effect immediately after setup/settings save. Register directly on modelRegistry and re-resolve the active model when it belongs to a reconfigured provider.
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@aliou/pi-ts-aperture",
3
3
  "description": "Route Pi LLM providers through Tailscale Aperture",
4
- "version": "0.0.1",
5
- "packageManager": "pnpm@10.26.1",
4
+ "version": "0.1.0",
6
5
  "repository": {
7
6
  "type": "git",
8
7
  "url": "https://github.com/aliou/pi-ts-aperture"
@@ -11,7 +10,8 @@
11
10
  "pi-package"
12
11
  ],
13
12
  "publishConfig": {
14
- "access": "public"
13
+ "access": "public",
14
+ "provenance": true
15
15
  },
16
16
  "pi": {
17
17
  "extensions": [
@@ -20,21 +20,12 @@
20
20
  "video": "https://assets.aliou.me/pi-extensions/demos/pi-ts-aperture.mp4"
21
21
  },
22
22
  "dependencies": {
23
- "@aliou/pi-utils-settings": "^0.3.0"
23
+ "@aliou/pi-utils-settings": "^0.4.0"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@mariozechner/pi-ai": ">=0.52.12",
27
27
  "@mariozechner/pi-coding-agent": ">=0.52.12"
28
28
  },
29
- "scripts": {
30
- "typecheck": "tsc --noEmit",
31
- "lint": "biome check",
32
- "format": "biome check --write",
33
- "prepare": "husky",
34
- "changeset": "changeset",
35
- "version": "changeset version",
36
- "release": "pnpm changeset publish"
37
- },
38
29
  "devDependencies": {
39
30
  "@biomejs/biome": "^2.3.13",
40
31
  "@changesets/cli": "^2.27.11",
@@ -45,10 +36,12 @@
45
36
  "husky": "^9.1.7",
46
37
  "typescript": "^5.9.3"
47
38
  },
48
- "pnpm": {
49
- "overrides": {
50
- "@mariozechner/pi-ai": "$@mariozechner/pi-coding-agent",
51
- "@mariozechner/pi-tui": "$@mariozechner/pi-coding-agent"
52
- }
39
+ "scripts": {
40
+ "typecheck": "tsc --noEmit",
41
+ "lint": "biome check",
42
+ "format": "biome check --write",
43
+ "changeset": "changeset",
44
+ "version": "changeset version",
45
+ "release": "pnpm changeset publish"
53
46
  }
54
- }
47
+ }
@@ -12,14 +12,17 @@ import {
12
12
  type SettingsSection,
13
13
  setNestedValue,
14
14
  } from "@aliou/pi-utils-settings";
15
- import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
15
+ import type {
16
+ ExtensionAPI,
17
+ ExtensionContext,
18
+ } from "@mariozechner/pi-coding-agent";
16
19
  import { getSettingsListTheme } from "@mariozechner/pi-coding-agent";
17
20
  import type { ApertureConfig, ResolvedConfig } from "../config";
18
21
  import { configLoader } from "../config";
19
22
 
20
23
  export function registerApertureSettings(
21
24
  pi: ExtensionAPI,
22
- onConfigChange: () => void,
25
+ onConfigChange: (ctx: ExtensionContext) => void,
23
26
  ): void {
24
27
  registerSettingsCommand<ApertureConfig, ResolvedConfig>(pi, {
25
28
  commandName: "aperture:settings",
@@ -89,8 +92,8 @@ export function registerApertureSettings(
89
92
  }
90
93
  return updated;
91
94
  },
92
- onSave: () => {
93
- onConfigChange();
95
+ onSave: (ctx) => {
96
+ onConfigChange(ctx);
94
97
  },
95
98
  });
96
99
  }
@@ -9,7 +9,10 @@
9
9
 
10
10
  import { FuzzySelector } from "@aliou/pi-utils-settings";
11
11
  import { getProviders } from "@mariozechner/pi-ai";
12
- import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
12
+ import type {
13
+ ExtensionAPI,
14
+ ExtensionContext,
15
+ } from "@mariozechner/pi-coding-agent";
13
16
  import { getSettingsListTheme } from "@mariozechner/pi-coding-agent";
14
17
  import type { Component } from "@mariozechner/pi-tui";
15
18
  import { Input, Key, matchesKey } from "@mariozechner/pi-tui";
@@ -152,7 +155,7 @@ class ProviderMultiSelect implements Component {
152
155
 
153
156
  export function registerSetupCommand(
154
157
  pi: ExtensionAPI,
155
- onConfigChange: () => void,
158
+ onConfigChange: (ctx: ExtensionContext) => void,
156
159
  ): void {
157
160
  pi.registerCommand("aperture:setup", {
158
161
  description: "Configure Tailscale Aperture integration",
@@ -194,7 +197,7 @@ export function registerSetupCommand(
194
197
 
195
198
  // Step 3: save and register
196
199
  await configLoader.save("global", { baseUrl, providers });
197
- onConfigChange();
200
+ onConfigChange(ctx);
198
201
  ctx.ui.notify(
199
202
  `Aperture configured: ${providers.length} provider(s) via ${baseUrl}`,
200
203
  "info",
package/src/index.ts CHANGED
@@ -6,34 +6,72 @@
6
6
  * overrides each provider's baseUrl and sets a dummy apiKey.
7
7
  */
8
8
 
9
- import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
9
+ import type {
10
+ ExtensionAPI,
11
+ ExtensionContext,
12
+ } from "@mariozechner/pi-coding-agent";
10
13
  import { registerApertureSettings } from "./commands/settings";
11
14
  import { registerSetupCommand } from "./commands/setup";
12
15
  import { configLoader } from "./config";
13
16
 
14
- function registerProviders(pi: ExtensionAPI): void {
17
+ function getApertureBaseUrl(): string | null {
15
18
  const config = configLoader.getConfig();
16
- if (!config.baseUrl || config.providers.length === 0) return;
17
-
18
- const baseUrl = config.baseUrl.replace(/\/+$/, "");
19
-
20
- for (const provider of config.providers) {
21
- pi.registerProvider(provider, {
22
- baseUrl: `${baseUrl}/v1`,
23
- apiKey: "-",
24
- });
25
- }
19
+ if (!config.baseUrl || config.providers.length === 0) return null;
20
+ return `${config.baseUrl.replace(/\/+$/, "")}/v1`;
26
21
  }
27
22
 
28
23
  export default async function (pi: ExtensionAPI): Promise<void> {
29
24
  await configLoader.load();
30
25
 
31
- const onConfigChange = () => {
32
- // Config is already reloaded by configLoader.save(), just re-register.
33
- registerProviders(pi);
26
+ const config = configLoader.getConfig();
27
+ let lastRegisteredProviders = [...config.providers];
28
+
29
+ // At load time, pi.registerProvider() queue is flushed by the runner.
30
+ const baseUrl = getApertureBaseUrl();
31
+ if (baseUrl) {
32
+ for (const provider of config.providers) {
33
+ pi.registerProvider(provider, { baseUrl, apiKey: "-" });
34
+ }
35
+ }
36
+
37
+ const onSetupComplete = (ctx: ExtensionContext) => {
38
+ const cfg = configLoader.getConfig();
39
+ const removedProviders = lastRegisteredProviders.filter(
40
+ (p) => !cfg.providers.includes(p),
41
+ );
42
+
43
+ const url = getApertureBaseUrl();
44
+ if (url) {
45
+ for (const provider of cfg.providers) {
46
+ ctx.modelRegistry.registerProvider(provider, {
47
+ baseUrl: url,
48
+ apiKey: "-",
49
+ });
50
+ }
51
+ }
52
+ lastRegisteredProviders = [...cfg.providers];
53
+
54
+ // The active model is a snapshot. If it belongs to a provider we just
55
+ // reconfigured, re-resolve it so the new baseUrl takes effect.
56
+ if (ctx.model && cfg.providers.includes(ctx.model.provider)) {
57
+ const updated = ctx.modelRegistry.find(ctx.model.provider, ctx.model.id);
58
+ if (updated) {
59
+ ctx.ui.notify(
60
+ `[aperture] re-routing ${ctx.model.id} through ${updated.baseUrl}`,
61
+ "info",
62
+ );
63
+ pi.setModel(updated);
64
+ }
65
+ }
66
+
67
+ if (removedProviders.length > 0) {
68
+ ctx.ui.notify(
69
+ `Removed providers (${removedProviders.join(", ")}) will revert after /reload`,
70
+ "warning",
71
+ );
72
+ }
34
73
  };
35
74
 
36
- registerProviders(pi);
37
- registerSetupCommand(pi, onConfigChange);
38
- registerApertureSettings(pi, onConfigChange);
75
+ registerSetupCommand(pi, onSetupComplete);
76
+ registerApertureSettings(pi, onSetupComplete);
39
77
  }
package/.envrc DELETED
@@ -1,21 +0,0 @@
1
- # shellcheck disable=2148,2086
2
-
3
- # Use `source_up` if part of a monorepo.
4
-
5
- use nix
6
-
7
- # Load layouts. This basically just sets up PATH and other env vars.
8
- # Possible values are "node", "bun", and "uv".
9
- #
10
- # Options:
11
- # --deny bin1,bin2,... Exclude binaries from local PATH, falling back to system.
12
- # Useful when a local binary shadows a system one you need.
13
- #
14
- # Examples:
15
- # layout node
16
- # layout node --deny pi,prettier
17
- # layout uv --deny python
18
-
19
- if has node; then
20
- layout node --deny pi
21
- fi
Binary file
Binary file
@@ -1 +0,0 @@
1
- $5f641c2a-07a9-45a1-b450-72c7d4d38754�(&path IN ('tsconfig.json','biome.json')