opencode-openai-profiles 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.
package/dist/paths.js ADDED
@@ -0,0 +1,20 @@
1
+ import { homedir } from "node:os";
2
+ import { join } from "node:path";
3
+ export const OPENAI_PROVIDER_ID = "openai";
4
+ export const PROFILE_FILE_PREFIX = `${OPENAI_PROVIDER_ID}-`;
5
+ export const PROFILE_FILE_EXTENSION = ".json";
6
+ export function getOpenCodeAuthPaths(environment = process.env) {
7
+ const xdgDataHome = environment.XDG_DATA_HOME?.trim();
8
+ const dataHomePath = xdgDataHome && xdgDataHome.length > 0
9
+ ? xdgDataHome
10
+ : join(homedir(), ".local", "share");
11
+ const opencodeDataPath = join(dataHomePath, "opencode");
12
+ return {
13
+ authFilePath: join(opencodeDataPath, "auth.json"),
14
+ profileDirectoryPath: join(opencodeDataPath, "auth-profiles"),
15
+ };
16
+ }
17
+ export function getProfileFileName(profileName) {
18
+ return `${PROFILE_FILE_PREFIX}${profileName}${PROFILE_FILE_EXTENSION}`;
19
+ }
20
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAC3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,kBAAkB,GAAG,CAAC;AAC5D,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC;AAO9C,MAAM,UAAU,oBAAoB,CACnC,cAAiC,OAAO,CAAC,GAAG;IAE5C,MAAM,WAAW,GAAG,WAAW,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC;IACtD,MAAM,YAAY,GACjB,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QACpC,CAAC,CAAC,WAAW;QACb,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvC,MAAM,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAExD,OAAO;QACN,YAAY,EAAE,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC;QACjD,oBAAoB,EAAE,IAAI,CAAC,gBAAgB,EAAE,eAAe,CAAC;KAC7D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,WAAmB;IACrD,OAAO,GAAG,mBAAmB,GAAG,WAAW,GAAG,sBAAsB,EAAE,CAAC;AACxE,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function parseProfileName(input: string): string;
@@ -0,0 +1,12 @@
1
+ const PROFILE_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/;
2
+ export function parseProfileName(input) {
3
+ const profileName = input.trim();
4
+ if (profileName.length === 0) {
5
+ throw new Error("Profile name is required");
6
+ }
7
+ if (!PROFILE_NAME_PATTERN.test(profileName)) {
8
+ throw new Error("Use only letters, numbers, underscores, or hyphens");
9
+ }
10
+ return profileName;
11
+ }
12
+ //# sourceMappingURL=profile-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-name.js","sourceRoot":"","sources":["../src/profile-name.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEhD,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC7C,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAEjC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,WAAW,CAAC;AACpB,CAAC"}
@@ -0,0 +1 @@
1
+ export { OpenAIAccountSwitcherPlugin as default, OpenAIAccountSwitcherPlugin, } from "./index.js";
package/dist/server.js ADDED
@@ -0,0 +1,2 @@
1
+ export { OpenAIAccountSwitcherPlugin as default, OpenAIAccountSwitcherPlugin, } from "./index.js";
2
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,2BAA2B,IAAI,OAAO,EACtC,2BAA2B,GAC3B,MAAM,YAAY,CAAC"}
package/dist/tui.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type { TuiPluginModule } from "@opencode-ai/plugin/tui";
2
+ declare const plugin: TuiPluginModule & {
3
+ id: string;
4
+ };
5
+ export default plugin;
package/dist/tui.js ADDED
@@ -0,0 +1,7 @@
1
+ import { id, tui } from "./index.js";
2
+ const plugin = {
3
+ id,
4
+ tui,
5
+ };
6
+ export default plugin;
7
+ //# sourceMappingURL=tui.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tui.js","sourceRoot":"","sources":["../src/tui.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,MAAM,GAAqC;IAChD,EAAE;IACF,GAAG;CACH,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "opencode-openai-profiles",
3
+ "version": "0.1.0",
4
+ "description": "OpenCode TUI plugin for switching saved OpenAI ChatGPT OAuth profiles.",
5
+ "type": "module",
6
+ "main": "dist/server.js",
7
+ "types": "dist/server.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/server.d.ts",
11
+ "import": "./dist/server.js"
12
+ },
13
+ "./server": {
14
+ "types": "./dist/server.d.ts",
15
+ "import": "./dist/server.js"
16
+ },
17
+ "./tui": {
18
+ "types": "./dist/tui.d.ts",
19
+ "import": "./dist/tui.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsc -p tsconfig.json",
28
+ "check": "biome check .",
29
+ "check:write": "biome check --write .",
30
+ "test": "vitest run",
31
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit"
32
+ },
33
+ "keywords": [
34
+ "opencode",
35
+ "plugin",
36
+ "openai",
37
+ "chatgpt"
38
+ ],
39
+ "peerDependencies": {
40
+ "@opencode-ai/plugin": ">=1.14.33"
41
+ },
42
+ "devDependencies": {
43
+ "@biomejs/biome": "^2.4.15",
44
+ "@opencode-ai/plugin": "^1.15.0",
45
+ "@types/node": "^24.10.1",
46
+ "typescript": "^5.9.3",
47
+ "vitest": "^4.0.15"
48
+ },
49
+ "dependencies": {
50
+ "@opencode-ai/sdk": "^1.15.0"
51
+ }
52
+ }