bacluc-opencode-completion-check-command 0.1.0 → 0.3.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bacluc-opencode-completion-check-command",
|
|
3
|
-
"version": "v0.
|
|
3
|
+
"version": "v0.3.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|
|
@@ -40,8 +40,9 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/bun": "1.3.14",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
43
|
+
"@types/node": "25.9.2",
|
|
44
|
+
"prettier": "3.8.3",
|
|
45
|
+
"typescript": "6.0.3",
|
|
45
46
|
"vitest": "4.1.7"
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Hooks, Plugin, PluginInput } from '@opencode-ai/plugin'
|
|
2
2
|
import type { Event } from '@opencode-ai/sdk'
|
|
3
|
+
import { promises as fs } from 'fs'
|
|
3
4
|
|
|
4
5
|
export const DEFAULT_MAX_RETRIES = 10
|
|
5
6
|
|
|
@@ -108,6 +109,19 @@ export function buildFailureMessage(result: CommandResult): string {
|
|
|
108
109
|
return message
|
|
109
110
|
}
|
|
110
111
|
|
|
112
|
+
export async function readDefaultCommandFromAgentsMd(directory: string): Promise<string | null> {
|
|
113
|
+
try {
|
|
114
|
+
const content = await fs.readFile(`${directory}/AGENTS.md`, 'utf-8')
|
|
115
|
+
const commandIndex = content.indexOf('/completion-check-command')
|
|
116
|
+
if (commandIndex === -1) {
|
|
117
|
+
return null
|
|
118
|
+
}
|
|
119
|
+
return parseCodeBlock(content.slice(commandIndex))
|
|
120
|
+
} catch {
|
|
121
|
+
return null
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
111
125
|
export const CompletionCheckCommandPlugin: Plugin = async (input, options) => {
|
|
112
126
|
const { client, $ } = input
|
|
113
127
|
const maxRetries = typeof options?.maxRetries === 'number' ? options.maxRetries : DEFAULT_MAX_RETRIES
|
|
@@ -137,13 +151,64 @@ export const CompletionCheckCommandPlugin: Plugin = async (input, options) => {
|
|
|
137
151
|
|
|
138
152
|
const command = parseCodeBlock(input.arguments)
|
|
139
153
|
if (!command) {
|
|
154
|
+
try {
|
|
155
|
+
await client.tui.showToast({
|
|
156
|
+
body: {
|
|
157
|
+
title: 'Completion Check',
|
|
158
|
+
message:
|
|
159
|
+
"I couldn't find a code block in your message. Please include a markdown code block with the shell command to run. For example:\n\n```bash\n./check.sh\n```",
|
|
160
|
+
variant: 'warning',
|
|
161
|
+
duration: 10000,
|
|
162
|
+
},
|
|
163
|
+
})
|
|
164
|
+
} catch {
|
|
165
|
+
// Ignore feedback errors
|
|
166
|
+
}
|
|
140
167
|
return
|
|
141
168
|
}
|
|
142
169
|
|
|
143
170
|
store.set(input.sessionID, command)
|
|
171
|
+
|
|
172
|
+
try {
|
|
173
|
+
await client.tui.showToast({
|
|
174
|
+
body: {
|
|
175
|
+
title: 'Completion Check',
|
|
176
|
+
message: `Registered! When the agent finishes, this command will be run to verify completion:\n\n\`\`\`bash\n${command}\n\`\`\``,
|
|
177
|
+
variant: 'success',
|
|
178
|
+
duration: 10000,
|
|
179
|
+
},
|
|
180
|
+
})
|
|
181
|
+
} catch {
|
|
182
|
+
// Ignore feedback errors
|
|
183
|
+
}
|
|
144
184
|
},
|
|
145
185
|
|
|
146
186
|
event: async ({ event }) => {
|
|
187
|
+
if (event.type === 'session.created') {
|
|
188
|
+
const sessionID = (event as Extract<Event, { type: 'session.created' }>).properties.info.id
|
|
189
|
+
const directory = (event as Extract<Event, { type: 'session.created' }>).properties.info.directory
|
|
190
|
+
const defaultCommand = await readDefaultCommandFromAgentsMd(directory)
|
|
191
|
+
|
|
192
|
+
if (defaultCommand) {
|
|
193
|
+
store.set(sessionID, defaultCommand)
|
|
194
|
+
|
|
195
|
+
try {
|
|
196
|
+
await client.tui.showToast({
|
|
197
|
+
body: {
|
|
198
|
+
title: 'Completion Check',
|
|
199
|
+
message: `Found default completion check command in AGENTS.md. It will be run automatically when the agent finishes:\n\n\`\`\`bash\n${defaultCommand}\n\`\`\``,
|
|
200
|
+
variant: 'info',
|
|
201
|
+
duration: 10000,
|
|
202
|
+
},
|
|
203
|
+
})
|
|
204
|
+
} catch {
|
|
205
|
+
// Ignore feedback errors
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
|
|
147
212
|
if (event.type !== 'session.idle') {
|
|
148
213
|
return
|
|
149
214
|
}
|