@link-assistant/hive-mind 0.50.4 → 0.50.6
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/CHANGELOG.md +15 -0
- package/package.json +1 -1
- package/src/opencode.lib.mjs +87 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @link-assistant/hive-mind
|
|
2
2
|
|
|
3
|
+
## 0.50.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7733b32: Detect OpenCode permission prompts and recommend @link-assistant/agent for autonomous workflows
|
|
8
|
+
- Configure all OpenCode permissions to "allow" (edit, bash, webfetch, skill, doom_loop, external_directory)
|
|
9
|
+
- Detect interactive permission prompts that block automated execution
|
|
10
|
+
- Recommend @link-assistant/agent (100% unrestricted OpenCode fork) when prompts are detected
|
|
11
|
+
|
|
12
|
+
## 0.50.5
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Test patch release
|
|
17
|
+
|
|
3
18
|
## 0.50.4
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/package.json
CHANGED
package/src/opencode.lib.mjs
CHANGED
|
@@ -211,6 +211,34 @@ export const executeOpenCodeCommand = async params => {
|
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
// Create OpenCode configuration file with unrestricted permissions
|
|
215
|
+
// This allows OpenCode to access files outside the working directory without prompting
|
|
216
|
+
// Fixes issue #755: "Permission required to run: Access file outside working directory"
|
|
217
|
+
// Reference: https://opencode.ai/docs/config - see permissions documentation
|
|
218
|
+
const opencodeConfigPath = path.join(tempDir, 'opencode.json');
|
|
219
|
+
const opencodeConfig = {
|
|
220
|
+
$schema: 'https://opencode.ai/config.json',
|
|
221
|
+
permission: {
|
|
222
|
+
// All tool permissions set to 'allow' for unrestricted autonomous execution
|
|
223
|
+
// See: https://github.com/sst/opencode - permission options: "allow", "ask", "deny"
|
|
224
|
+
edit: 'allow', // File modification operations
|
|
225
|
+
bash: 'allow', // Command execution
|
|
226
|
+
webfetch: 'allow', // Web page retrieval
|
|
227
|
+
skill: 'allow', // Custom skills execution
|
|
228
|
+
doom_loop: 'allow', // Allow repeated identical tool calls (default: ask)
|
|
229
|
+
external_directory: 'allow', // File operations outside working directory (default: ask)
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
try {
|
|
233
|
+
await fs.writeFile(opencodeConfigPath, JSON.stringify(opencodeConfig, null, 2));
|
|
234
|
+
if (argv.verbose) {
|
|
235
|
+
await log(` Created OpenCode config: ${opencodeConfigPath}`, { verbose: true });
|
|
236
|
+
await log(' Permissions set: edit=allow, bash=allow, webfetch=allow, skill=allow, doom_loop=allow, external_directory=allow', { verbose: true });
|
|
237
|
+
}
|
|
238
|
+
} catch (configError) {
|
|
239
|
+
await log(`⚠️ Warning: Could not create OpenCode config file: ${configError.message}`, { level: 'warning' });
|
|
240
|
+
}
|
|
241
|
+
|
|
214
242
|
// Take resource snapshot before execution
|
|
215
243
|
const resourcesBefore = await getResourceSnapshot();
|
|
216
244
|
await log('📈 System resources before execution:', { verbose: true });
|
|
@@ -277,24 +305,76 @@ export const executeOpenCodeCommand = async params => {
|
|
|
277
305
|
let limitReached = false;
|
|
278
306
|
let limitResetTime = null;
|
|
279
307
|
let lastMessage = '';
|
|
308
|
+
let allOutput = ''; // Collect all output for error detection
|
|
280
309
|
|
|
281
310
|
for await (const chunk of execCommand.stream()) {
|
|
282
311
|
if (chunk.type === 'stdout') {
|
|
283
312
|
const output = chunk.data.toString();
|
|
284
313
|
await log(output);
|
|
285
314
|
lastMessage = output;
|
|
315
|
+
allOutput += output;
|
|
286
316
|
}
|
|
287
317
|
|
|
288
318
|
if (chunk.type === 'stderr') {
|
|
289
319
|
const errorOutput = chunk.data.toString();
|
|
290
320
|
if (errorOutput) {
|
|
291
321
|
await log(errorOutput, { stream: 'stderr' });
|
|
322
|
+
allOutput += errorOutput;
|
|
292
323
|
}
|
|
293
324
|
} else if (chunk.type === 'exit') {
|
|
294
325
|
exitCode = chunk.code;
|
|
295
326
|
}
|
|
296
327
|
}
|
|
297
328
|
|
|
329
|
+
// Clean up the opencode.json config file to avoid polluting the repository
|
|
330
|
+
try {
|
|
331
|
+
await fs.unlink(opencodeConfigPath);
|
|
332
|
+
if (argv.verbose) {
|
|
333
|
+
await log(` Cleaned up OpenCode config: ${opencodeConfigPath}`, { verbose: true });
|
|
334
|
+
}
|
|
335
|
+
} catch (cleanupError) {
|
|
336
|
+
// Ignore cleanup errors - file may already be deleted or not exist
|
|
337
|
+
if (argv.verbose) {
|
|
338
|
+
await log(` Note: Could not clean up OpenCode config: ${cleanupError.message}`, { verbose: true });
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Check for permission prompt errors (these can hang the process)
|
|
343
|
+
// Pattern: "Permission required to run:" or "Access file outside working directory"
|
|
344
|
+
const hasPermissionPrompt = allOutput.includes('Permission required to run:') || allOutput.includes('Access file outside working directory') || allOutput.includes('● Allow once') || allOutput.includes('○ Always allow') || allOutput.includes('○ Reject');
|
|
345
|
+
|
|
346
|
+
if (hasPermissionPrompt) {
|
|
347
|
+
await log('\n\n❌ OpenCode encountered a permission prompt', { level: 'error' });
|
|
348
|
+
await log('', { level: 'error' });
|
|
349
|
+
await log('OpenCode CLI does not support autonomous agents in its full potential.', { level: 'error' });
|
|
350
|
+
await log('Interactive permission prompts block automated execution, even with', { level: 'error' });
|
|
351
|
+
await log('all permissions set to "allow" in opencode.json configuration.', { level: 'error' });
|
|
352
|
+
await log('', { level: 'error' });
|
|
353
|
+
await log('💡 Recommendation: Use @link-assistant/agent instead', { level: 'error' });
|
|
354
|
+
await log('', { level: 'error' });
|
|
355
|
+
await log(' @link-assistant/agent is a 100% unrestricted fork of OpenCode', { level: 'error' });
|
|
356
|
+
await log(' specifically designed for autonomous agents in isolated environments.', { level: 'error' });
|
|
357
|
+
await log('', { level: 'error' });
|
|
358
|
+
await log(' Install: bun install -g @link-assistant/agent', { level: 'error' });
|
|
359
|
+
await log(' Run with: --tool agent', { level: 'error' });
|
|
360
|
+
await log('', { level: 'error' });
|
|
361
|
+
await log(' More info: https://github.com/link-assistant/agent', { level: 'error' });
|
|
362
|
+
await log('', { level: 'error' });
|
|
363
|
+
|
|
364
|
+
const resourcesAfter = await getResourceSnapshot();
|
|
365
|
+
await log('\n📈 System resources after execution:', { verbose: true });
|
|
366
|
+
await log(` Memory: ${resourcesAfter.memory.split('\n')[1]}`, { verbose: true });
|
|
367
|
+
await log(` Load: ${resourcesAfter.load}`, { verbose: true });
|
|
368
|
+
|
|
369
|
+
return {
|
|
370
|
+
success: false,
|
|
371
|
+
sessionId,
|
|
372
|
+
limitReached: false,
|
|
373
|
+
limitResetTime: null,
|
|
374
|
+
permissionPromptDetected: true,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
|
|
298
378
|
if (exitCode !== 0) {
|
|
299
379
|
// Check for usage limit errors first (more specific)
|
|
300
380
|
const limitInfo = detectUsageLimit(lastMessage);
|
|
@@ -339,6 +419,13 @@ export const executeOpenCodeCommand = async params => {
|
|
|
339
419
|
limitResetTime,
|
|
340
420
|
};
|
|
341
421
|
} catch (error) {
|
|
422
|
+
// Clean up the opencode.json config file even on error
|
|
423
|
+
try {
|
|
424
|
+
await fs.unlink(opencodeConfigPath);
|
|
425
|
+
} catch {
|
|
426
|
+
// Ignore cleanup errors
|
|
427
|
+
}
|
|
428
|
+
|
|
342
429
|
reportError(error, {
|
|
343
430
|
context: 'execute_opencode',
|
|
344
431
|
command: params.command,
|