mirror of
https://github.com/JuliusBrussee/caveman.git
synced 2026-08-11 13:21:09 +02:00
Installer fixes: #414 (rename PS1 $Args->$InstallerArgs), #437 (detect Copilot via extension dirs, fixes #336), #395 (--skill '*' instead of --all so -a <agent> is honored, fixes #389), #472 (prune orphaned managed hooks from settings.json, fixes #471), #393 (don't double-wire hooks when the plugin manifest already does, fixes #392), #380 (MCP-shrink off by default, requires an upstream, fixes #474), #376 install-side (opencode uses ~/.config/opencode, drop %APPDATA%), #443 (strip tools: from cavecrew agent copies for opencode, #386), #434 (existsSync guard on command copy), #396 (doc: discover profile slugs via --list). Security hardening: #261 (pin remote fetch to release tag PINNED_REF=v1.8.2, not moving main) and #262 (SHA-256-verify downloaded hook files against src/hooks/checksums.sha256 before they execute; abort on mismatch). #260 (inspect-before-run note). NOTE: enforcement activates fully once a release tag shipping checksums.sha256 is published and PINNED_REF is bumped; v1.8.2 predates the manifest so downloads there warn-and-proceed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
// Strip the `tools:` field from a Claude-Code-style subagent frontmatter so
|
|
// the file is valid for opencode, whose schema rejects the YAML array form
|
|
// (`tools: [Read, Grep, Bash]`) with:
|
|
//
|
|
// Configuration is invalid at .../agents/cavecrew-reviewer.md
|
|
// ↳ Expected object | undefined, got ["Read","Grep","Bash"] tools
|
|
//
|
|
// opencode allows `tools` to be a map (`{read: true, grep: true}`) or
|
|
// omitted entirely. Omitting falls back to opencode's default tool set,
|
|
// which is what the cavecrew subagent prompts already self-restrict against
|
|
// in their body ("Read-only locator", "No `Bash` available", etc.), so
|
|
// dropping the array form is safe.
|
|
|
|
const TOOLS_FIELD_RE = /^tools[ \t]*:/;
|
|
const CONTINUATION_RE = /^[ \t]/;
|
|
const FRONTMATTER_FENCE = '---\n';
|
|
|
|
function stripOpencodeAgentTools(content) {
|
|
if (typeof content !== 'string' || !content.startsWith(FRONTMATTER_FENCE)) return content;
|
|
const fmEnd = content.indexOf('\n---', FRONTMATTER_FENCE.length);
|
|
if (fmEnd < 0) return content;
|
|
|
|
const fm = content.slice(FRONTMATTER_FENCE.length, fmEnd);
|
|
const rest = content.slice(fmEnd);
|
|
|
|
const out = [];
|
|
let dropping = false;
|
|
for (const line of fm.split('\n')) {
|
|
if (dropping) {
|
|
if (CONTINUATION_RE.test(line)) continue;
|
|
dropping = false;
|
|
}
|
|
if (TOOLS_FIELD_RE.test(line)) { dropping = true; continue; }
|
|
out.push(line);
|
|
}
|
|
|
|
return FRONTMATTER_FENCE + out.join('\n') + rest;
|
|
}
|
|
|
|
module.exports = { stripOpencodeAgentTools };
|