mirror of
https://github.com/wesammustafa/opencode-primer.git
synced 2026-11-18 18:04:22 +00:00
- Bump every version pin, pricing table, and model ID to the verified 2026-07-05 state (v1.17.13): Claude Fable 5 / Sonnet 5 on Zen, new free tier, deprecation sunset table, v1.17.x changelog section - Cover gaps: OpenCode Go vs Zen billing, Anthropic subscription-login removal (PR #18186), MCP resources, --mini mode, --auto flag, yolo mode - Fix correctness bugs: command-template !`cmd` syntax in docs and .opencode/commands, protect-secrets regex missing 'cat .env', dual plugin exports, quickstart PATH fix, Playwright MCP flags, ctrl+d keybind conflict, agent/command required-field claims - Fix links: cursor.com, windsurf.com, platform.claude.com, code.claude.com, opencode.ai/discord, Vercel Grep announcement - Rebrand: banner (Images/banner.svg), 1280x640 social preview asset, hero redesign with star CTA, ecosystem stats, private vulnerability reporting channel, CI-matching local checks, MD060 lint opt-out
34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
// .opencode/plugins/audit-log.js
|
|
//
|
|
// Append a JSONL record of every completed tool call to .opencode/audit.jsonl.
|
|
// Useful as an after-the-fact paper trail of what the agent did this session.
|
|
//
|
|
// Toggle off by deleting this file or by gating with an env var:
|
|
// if (process.env.OPENCODE_DISABLE_AUDIT_LOG) return {};
|
|
|
|
import { appendFile, mkdir } from "node:fs/promises";
|
|
import { dirname, join } from "node:path";
|
|
|
|
export const AuditLog = async ({ directory }) => {
|
|
const logPath = join(directory, ".opencode", "audit.jsonl");
|
|
// Make sure .opencode/ exists in case this plugin runs in a fresh project
|
|
await mkdir(dirname(logPath), { recursive: true });
|
|
|
|
return {
|
|
// `tool.execute.after` is a top-level hook with an (input, output) signature,
|
|
// fired once a tool call completes. `input.tool`/`input.args` describe the
|
|
// call; `output.title` is OpenCode's short summary of the result.
|
|
"tool.execute.after": async (input, output) => {
|
|
const record = {
|
|
ts: new Date().toISOString(),
|
|
tool: input.tool,
|
|
// Capture argument keys only — full args can be huge (file content, diffs)
|
|
arg_keys: input.args ? Object.keys(input.args) : [],
|
|
title: output?.title,
|
|
};
|
|
|
|
await appendFile(logPath, JSON.stringify(record) + "\n");
|
|
},
|
|
};
|
|
};
|