UNPKG

@brianlovin/notion-skills

Version:

Sync agent skills from a Notion database to Claude Code, Codex, OpenCode, Cursor, Gemini CLI.

87 lines 3.16 kB
import { execSync } from "node:child_process"; export const GEN_AGENTS = [ { // claude --print --output-format text --allowedTools=Write,Read,WebFetch "<prompt>" // --print: run once, print response, exit. // --output-format text: stream text output to stdout so the user // sees progress live. // --allowedTools=Write,…: pre-approve exactly the tools the agent // needs to write a SKILL.md. Without this, // Write of a new file falls through the // default permission gate and the agent // prints "(pending your approval)" then // exits without writing. // We use the `=` syntax (vs. space-separated) because // `--allowedTools` is variadic and would otherwise eat the prompt. // `--permission-mode acceptEdits` doesn't help here — it covers // editing existing files but not creating new ones. key: "claude", label: "Claude", bin: "claude", passPromptVia: "-p", extraArgs: [ "--output-format", "text", "--allowedTools=Write,Read,WebFetch", ], }, { // codex exec --full-auto "<prompt>" // exec: non-interactive run-and-exit mode. // --full-auto: low-friction sandboxed automatic execution // (auto-approve everything codex will do, sandboxed // to the working dir). key: "codex", label: "Codex", bin: "codex", passPromptVia: "positional", extraArgs: ["exec", "--full-auto"], }, { // opencode run "<prompt>" — non-interactive run. key: "opencode", label: "OpenCode", bin: "opencode", passPromptVia: "positional", extraArgs: ["run"], }, { // gemini --prompt "<prompt>" — non-interactive print mode. key: "gemini", label: "Gemini", bin: "gemini", passPromptVia: "-p", extraArgs: [], }, ]; export function findGenAgent(key) { return GEN_AGENTS.find((a) => a.key === key); } export function isAgentInstalled(agent) { try { execSync(`command -v ${agent.bin}`, { stdio: "ignore" }); return true; } catch { return false; } } export function detectAvailableAgents() { return GEN_AGENTS.filter(isAgentInstalled); } /** * Build the argv (and stdin payload, if applicable) for handing `prompt` * to `agent`. Pure function — no spawning, no FS access — so the contract * is unit-testable for every supported agent. */ export function buildAgentSpawnArgs(agent, prompt) { const args = [...agent.extraArgs]; if (agent.passPromptVia === "stdin") { return { args, stdin: prompt }; } if (agent.passPromptVia === "-p") { return { args: [...args, "-p", prompt] }; } return { args: [...args, prompt] }; } //# sourceMappingURL=gen-agents.js.map