opencode-supabase 0.0.4-alpha.0 → 0.0.4
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 +8 -3
- package/package.json +1 -1
- package/src/server/index.ts +2 -2
- package/src/shared/log.ts +16 -3
- package/src/tui/index.tsx +2 -2
package/README.md
CHANGED
|
@@ -22,13 +22,18 @@ Connect your account and ask your agent about Supabase capabilities.
|
|
|
22
22
|
|
|
23
23
|
## Debug Logging
|
|
24
24
|
|
|
25
|
-
If you hit auth or tool errors and need logs for an issue,
|
|
25
|
+
If you hit auth or tool errors and need logs for an issue, collect the newest OpenCode session log from its default log directory:
|
|
26
|
+
|
|
27
|
+
- macOS/Linux: `~/.local/share/opencode/log/`
|
|
28
|
+
- Windows: `%USERPROFILE%\.local\share\opencode\log`
|
|
29
|
+
|
|
30
|
+
Run OpenCode with debug logging enabled while reproducing the problem:
|
|
26
31
|
|
|
27
32
|
```bash
|
|
28
|
-
opencode --log-level DEBUG --print-logs
|
|
33
|
+
opencode --log-level DEBUG --print-logs
|
|
29
34
|
```
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
Then share that newest session log file in the issue. In our testing, the session log file is more reliable than redirecting `stderr` with `2>` for capturing plugin activity.
|
|
32
37
|
|
|
33
38
|
## Available today
|
|
34
39
|
|
package/package.json
CHANGED
package/src/server/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Plugin } from "@opencode-ai/plugin";
|
|
2
2
|
|
|
3
|
-
import { createSupabaseLogger } from "../shared/log.ts";
|
|
3
|
+
import { createServerLogWriter, createSupabaseLogger } from "../shared/log.ts";
|
|
4
4
|
import { createSupabaseAuth } from "./auth.ts";
|
|
5
5
|
import { createSupabaseTools } from "./tools.ts";
|
|
6
6
|
|
|
7
7
|
const server: Plugin = async (input, options) => {
|
|
8
8
|
const logger = createSupabaseLogger({
|
|
9
|
-
write: (
|
|
9
|
+
write: createServerLogWriter(input.client),
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
return {
|
package/src/shared/log.ts
CHANGED
|
@@ -2,7 +2,7 @@ export type SupabaseLogLevel = "debug" | "info" | "warn" | "error";
|
|
|
2
2
|
|
|
3
3
|
export type SupabaseLogger = ReturnType<typeof createSupabaseLogger>;
|
|
4
4
|
|
|
5
|
-
type LogEntry = {
|
|
5
|
+
export type LogEntry = {
|
|
6
6
|
service: string;
|
|
7
7
|
level: SupabaseLogLevel;
|
|
8
8
|
message: string;
|
|
@@ -18,13 +18,18 @@ export function createSupabaseLogger(input: { write: LogWriter }) {
|
|
|
18
18
|
extra?: Record<string, unknown>,
|
|
19
19
|
) {
|
|
20
20
|
try {
|
|
21
|
-
await input.write({
|
|
21
|
+
const result = await input.write({
|
|
22
22
|
service: "opencode-supabase",
|
|
23
23
|
level,
|
|
24
24
|
message,
|
|
25
25
|
extra,
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
if (result && typeof result === "object" && "error" in result) {
|
|
28
|
+
console.error("[opencode-supabase] host log rejected:", (result as { error: unknown }).error);
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error("[opencode-supabase] host log failed:", error instanceof Error ? error.message : error);
|
|
32
|
+
}
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
return {
|
|
@@ -42,3 +47,11 @@ export function createSupabaseLogger(input: { write: LogWriter }) {
|
|
|
42
47
|
},
|
|
43
48
|
};
|
|
44
49
|
}
|
|
50
|
+
|
|
51
|
+
export function createServerLogWriter(client: { app: { log: (input: { body: LogEntry }) => Promise<unknown> } }) {
|
|
52
|
+
return (entry: LogEntry) => client.app.log({ body: entry });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function createTuiLogWriter(client: { app: { log: (input: LogEntry, options?: { throwOnError?: boolean }) => Promise<unknown> } }) {
|
|
56
|
+
return (entry: LogEntry) => client.app.log(entry, { throwOnError: true });
|
|
57
|
+
}
|
package/src/tui/index.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { TuiPlugin } from "@opencode-ai/plugin/tui";
|
|
2
2
|
|
|
3
|
-
import { createSupabaseLogger } from "../shared/log.ts";
|
|
3
|
+
import { createSupabaseLogger, createTuiLogWriter } from "../shared/log.ts";
|
|
4
4
|
import { createSupabaseCommand } from "./commands";
|
|
5
5
|
import { SupabaseDialog } from "./dialog";
|
|
6
6
|
|
|
7
7
|
const tui: TuiPlugin = async (api) => {
|
|
8
8
|
const logger = createSupabaseLogger({
|
|
9
|
-
write: (
|
|
9
|
+
write: createTuiLogWriter(api.client),
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
api.command.register(() => [
|