opencode-supabase 0.0.4 → 0.0.5

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": "opencode-supabase",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Supabase integration with server and TUI components",
6
6
  "license": "Apache-2.0",
@@ -23,6 +23,8 @@
23
23
  "tui"
24
24
  ],
25
25
  "scripts": {
26
+ "lint": "biome check .",
27
+ "verify:pack": "npm pack --dry-run",
26
28
  "typecheck": "bunx tsc --noEmit",
27
29
  "test": "bun test"
28
30
  },
@@ -33,6 +35,7 @@
33
35
  "zod": "latest"
34
36
  },
35
37
  "devDependencies": {
38
+ "@biomejs/biome": "^1.9.4",
36
39
  "@opentui/core": "0.1.95",
37
40
  "@opentui/solid": "0.1.95",
38
41
  "@types/bun": "latest",
@@ -1,10 +1,10 @@
1
- import type { PluginInput, PluginOptions } from "@opencode-ai/plugin";
2
1
  import { createConnection } from "node:net";
2
+ import type { PluginInput, PluginOptions } from "@opencode-ai/plugin";
3
3
 
4
4
  import {
5
5
  BrokerClientError,
6
- exchangeCodeThroughBroker,
7
6
  type BrokerConfig,
7
+ exchangeCodeThroughBroker,
8
8
  } from "../shared/broker.ts";
9
9
  import { readSupabaseConfig } from "../shared/cfg.ts";
10
10
  import type { SupabaseLogger } from "../shared/log.ts";
@@ -1,6 +1,6 @@
1
- import type { PluginInput } from "@opencode-ai/plugin";
2
1
  import { mkdir } from "node:fs/promises";
3
- import { dirname, join } from "node:path";
2
+ import { dirname, join, relative, resolve, sep } from "node:path";
3
+ import type { PluginInput } from "@opencode-ai/plugin";
4
4
 
5
5
  type StoreInput = Pick<PluginInput, "directory" | "worktree">;
6
6
 
@@ -17,8 +17,32 @@ export type SavedState = {
17
17
 
18
18
  const STORE_FILE = "supabase-auth.json";
19
19
 
20
+ // Use worktree only when it is non-root and directory is equal to or inside it;
21
+ // otherwise fall back to the session directory.
22
+ function resolveStoreRoot(input: StoreInput): string {
23
+ const directory = resolve(input.directory);
24
+ if (!input.worktree) {
25
+ return directory;
26
+ }
27
+
28
+ const worktree = resolve(input.worktree);
29
+ if (worktree === dirname(worktree)) {
30
+ return directory;
31
+ }
32
+
33
+ const pathFromWorktree = relative(worktree, directory);
34
+ if (
35
+ pathFromWorktree === "" ||
36
+ (!pathFromWorktree.startsWith("..") && !pathFromWorktree.startsWith(`..${sep}`))
37
+ ) {
38
+ return worktree;
39
+ }
40
+
41
+ return directory;
42
+ }
43
+
20
44
  export function file(input: StoreInput): string {
21
- const root = input.worktree || input.directory;
45
+ const root = resolveStoreRoot(input);
22
46
  return join(root, ".opencode", STORE_FILE);
23
47
  }
24
48
 
@@ -1,16 +1,16 @@
1
1
  import type { PluginOptions } from "@opencode-ai/plugin";
2
- import type { ToolContext } from "@opencode-ai/plugin/tool";
3
2
  import { tool } from "@opencode-ai/plugin";
3
+ import type { ToolContext } from "@opencode-ai/plugin/tool";
4
4
 
5
+ import { supabaseManagementApiFetch } from "../shared/api.ts";
5
6
  import {
6
7
  BrokerClientError,
7
8
  refreshTokenThroughBroker,
8
9
  } from "../shared/broker.ts";
9
- import { supabaseManagementApiFetch } from "../shared/api.ts";
10
10
  import { readSupabaseConfig } from "../shared/cfg.ts";
11
11
  import type { SupabaseLogger } from "../shared/log.ts";
12
12
  import type { FetchLike } from "../shared/types.ts";
13
- import { clearSavedAuth, readSavedAuth, writeSavedAuth, type SavedAuth } from "./store.ts";
13
+ import { type SavedAuth, clearSavedAuth, readSavedAuth, writeSavedAuth } from "./store.ts";
14
14
 
15
15
  type ToolDeps = {
16
16
  fetch?: FetchLike;
@@ -1,5 +1,5 @@
1
- import type { FetchLike, SupabaseTokenResponse } from "./types.ts";
2
1
  import type { SupabaseLogger } from "./log.ts";
2
+ import type { FetchLike, SupabaseTokenResponse } from "./types.ts";
3
3
 
4
4
  export type BrokerConfig = {
5
5
  baseUrl: string;