oh-my-opencode 0.2.0 → 0.3.1

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.
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Claude Code Hooks Type Definitions
3
+ * Maps Claude Code hook concepts to OpenCode plugin events
4
+ */
5
+ export type ClaudeHookEvent = "PreToolUse" | "PostToolUse" | "UserPromptSubmit" | "Stop";
6
+ export interface HookMatcher {
7
+ matcher: string;
8
+ hooks: HookCommand[];
9
+ }
10
+ export interface HookCommand {
11
+ type: "command";
12
+ command: string;
13
+ }
14
+ export interface ClaudeHooksConfig {
15
+ PreToolUse?: HookMatcher[];
16
+ PostToolUse?: HookMatcher[];
17
+ UserPromptSubmit?: HookMatcher[];
18
+ Stop?: HookMatcher[];
19
+ }
20
+ export interface PreToolUseInput {
21
+ session_id: string;
22
+ transcript_path?: string;
23
+ cwd: string;
24
+ permission_mode?: PermissionMode;
25
+ hook_event_name: "PreToolUse";
26
+ tool_name: string;
27
+ tool_input: Record<string, unknown>;
28
+ tool_use_id?: string;
29
+ hook_source?: HookSource;
30
+ }
31
+ export interface PostToolUseInput {
32
+ session_id: string;
33
+ transcript_path?: string;
34
+ cwd: string;
35
+ permission_mode?: PermissionMode;
36
+ hook_event_name: "PostToolUse";
37
+ tool_name: string;
38
+ tool_input: Record<string, unknown>;
39
+ tool_response: {
40
+ title?: string;
41
+ output?: string;
42
+ [key: string]: unknown;
43
+ };
44
+ tool_use_id?: string;
45
+ hook_source?: HookSource;
46
+ }
47
+ export interface UserPromptSubmitInput {
48
+ session_id: string;
49
+ cwd: string;
50
+ permission_mode?: PermissionMode;
51
+ hook_event_name: "UserPromptSubmit";
52
+ prompt: string;
53
+ session?: {
54
+ id: string;
55
+ };
56
+ hook_source?: HookSource;
57
+ }
58
+ export type PermissionMode = "default" | "plan" | "acceptEdits" | "bypassPermissions";
59
+ export type HookSource = "opencode-plugin";
60
+ export interface StopInput {
61
+ session_id: string;
62
+ transcript_path?: string;
63
+ cwd: string;
64
+ permission_mode?: PermissionMode;
65
+ hook_event_name: "Stop";
66
+ stop_hook_active: boolean;
67
+ todo_path?: string;
68
+ hook_source?: HookSource;
69
+ }
70
+ export type PermissionDecision = "allow" | "deny" | "ask";
71
+ /**
72
+ * Common JSON fields for all hook outputs (Claude Code spec)
73
+ */
74
+ export interface HookCommonOutput {
75
+ /** If false, Claude stops entirely */
76
+ continue?: boolean;
77
+ /** Message shown to user when continue=false */
78
+ stopReason?: string;
79
+ /** Suppress output from transcript */
80
+ suppressOutput?: boolean;
81
+ /** Warning/message displayed to user */
82
+ systemMessage?: string;
83
+ }
84
+ export interface PreToolUseOutput extends HookCommonOutput {
85
+ /** Deprecated: use hookSpecificOutput.permissionDecision instead */
86
+ decision?: "allow" | "deny" | "approve" | "block" | "ask";
87
+ /** Deprecated: use hookSpecificOutput.permissionDecisionReason instead */
88
+ reason?: string;
89
+ hookSpecificOutput?: {
90
+ hookEventName: "PreToolUse";
91
+ permissionDecision: PermissionDecision;
92
+ permissionDecisionReason?: string;
93
+ updatedInput?: Record<string, unknown>;
94
+ };
95
+ }
96
+ export interface PostToolUseOutput extends HookCommonOutput {
97
+ decision?: "block";
98
+ reason?: string;
99
+ hookSpecificOutput?: {
100
+ hookEventName: "PostToolUse";
101
+ /** Additional context to provide to Claude */
102
+ additionalContext?: string;
103
+ };
104
+ }
105
+ export interface HookResult {
106
+ exitCode: number;
107
+ stdout?: string;
108
+ stderr?: string;
109
+ }
110
+ export interface TranscriptEntry {
111
+ type: "tool_use" | "tool_result" | "user" | "assistant";
112
+ timestamp: string;
113
+ tool_name?: string;
114
+ tool_input?: Record<string, unknown>;
115
+ tool_output?: Record<string, unknown>;
116
+ content?: string;
117
+ }
118
+ export interface TodoItem {
119
+ id: string;
120
+ content: string;
121
+ status: "pending" | "in_progress" | "completed" | "cancelled";
122
+ priority?: "low" | "medium" | "high";
123
+ created_at: string;
124
+ updated_at?: string;
125
+ }
126
+ export interface ClaudeCodeTodoItem {
127
+ content: string;
128
+ status: string;
129
+ activeForm: string;
130
+ }
131
+ export interface TodoFile {
132
+ session_id: string;
133
+ items: TodoItem[];
134
+ created_at: string;
135
+ updated_at: string;
136
+ }
137
+ export interface StopOutput {
138
+ decision?: "block" | "continue";
139
+ reason?: string;
140
+ stop_hook_active?: boolean;
141
+ permission_mode?: PermissionMode;
142
+ inject_prompt?: string;
143
+ }
144
+ export type ClaudeCodeContent = {
145
+ type: "text";
146
+ text: string;
147
+ } | {
148
+ type: "tool_use";
149
+ id: string;
150
+ name: string;
151
+ input: Record<string, unknown>;
152
+ } | {
153
+ type: "tool_result";
154
+ tool_use_id: string;
155
+ content: string;
156
+ };
157
+ export interface ClaudeCodeMessage {
158
+ type: "user" | "assistant";
159
+ message: {
160
+ role: "user" | "assistant";
161
+ content: ClaudeCodeContent[];
162
+ };
163
+ }
164
+ export interface PluginConfig {
165
+ disabledHooks?: boolean | ClaudeHookEvent[];
166
+ }
@@ -0,0 +1,22 @@
1
+ import type { ClaudeHooksConfig } from "./types";
2
+ import { type PluginExtendedConfig } from "./config-loader";
3
+ export interface MessagePart {
4
+ type: "text" | "tool_use" | "tool_result";
5
+ text?: string;
6
+ [key: string]: unknown;
7
+ }
8
+ export interface UserPromptSubmitContext {
9
+ sessionId: string;
10
+ parentSessionId?: string;
11
+ prompt: string;
12
+ parts: MessagePart[];
13
+ cwd: string;
14
+ permissionMode?: "default" | "acceptEdits" | "bypassPermissions";
15
+ }
16
+ export interface UserPromptSubmitResult {
17
+ block: boolean;
18
+ reason?: string;
19
+ modifiedParts: MessagePart[];
20
+ messages: string[];
21
+ }
22
+ export declare function executeUserPromptSubmitHooks(ctx: UserPromptSubmitContext, config: ClaudeHooksConfig | null, extendedConfig?: PluginExtendedConfig | null): Promise<UserPromptSubmitResult>;
@@ -8,3 +8,4 @@ export { createDirectoryAgentsInjectorHook } from "./directory-agents-injector";
8
8
  export { createEmptyTaskResponseDetectorHook } from "./empty-task-response-detector";
9
9
  export { createAnthropicAutoCompactHook } from "./anthropic-auto-compact";
10
10
  export { createThinkModeHook } from "./think-mode";
11
+ export { createClaudeCodeHooksHook } from "./claude-code-hooks";
@@ -7,6 +7,7 @@ export declare function hasContent(part: StoredPart): boolean;
7
7
  export declare function messageHasContent(messageID: string): boolean;
8
8
  export declare function injectTextPart(sessionID: string, messageID: string, text: string): boolean;
9
9
  export declare function findEmptyMessages(sessionID: string): string[];
10
+ export declare function findEmptyMessageByIndex(sessionID: string, targetIndex: number): string | null;
10
11
  export declare function findFirstEmptyMessage(sessionID: string): string | null;
11
12
  export declare function findMessagesWithThinkingBlocks(sessionID: string): string[];
12
13
  export declare function findMessagesWithOrphanThinking(sessionID: string): string[];