Skip to content

feat: default-on decision-level logging with configurable logLevel - #332

Merged
ranxianglei merged 2 commits into
masterfrom
2026-08-21_default-on-logging
Aug 21, 2026
Merged

feat: default-on decision-level logging with configurable logLevel#332
ranxianglei merged 2 commits into
masterfrom
2026-08-21_default-on-logging

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Problem

Default configuration (debug: false) wrote only WARN/ERROR to ~/.config/opencode/logs/acp/daily/<date>.log. INFO/DEBUG required debug: true, so a default install left almost no decision trail for diagnosing nudge/compression/update behavior.

Fix

Default-on INFO: decision-level events now land in the daily log out of the box.

Logger core (lib/logger.ts)

  • LogLevel = "debug" | "info" | "warn" | "error" | "silent" + rank-gated writes (silent swallows everything).
  • constructor(enabled: boolean, level?: LogLevel); level ?? (enabled ? "debug" : "warn")boolean-only callers keep exact old semantics (~40 test files untouched).
  • get enabled() becomes a derived view (level === "debug"); saveContext snapshots remain debug-only (no per-request JSON dumps by default).

Config

  • New logLevel option (default "info"), validated against the 5-value enum, in dcp.schema.json + merged per-layer. debug: true overrides to full debug as before.

INFO audit trail on core paths

  • init (index.ts): version / workspace / resolved level / secure mode / auto-update.
  • per request (lib/hooks.ts): transform summary — model, message count, pre/post tokens, context usage %, nudged; mid-session model switch.
  • nudge decisions (lib/messages/inject/inject.ts): injection (trigger tier, usage %, growth vs floor, recommended ranges), emergency /compact notice, suppression reasons (all_protected / in_protected_zone / below_effective_floor), tier-trigger injection.
  • auto-update (lib/update.ts): optional Logger threaded through; full check lifecycle (start, every skip reason, new version found, applied, failed).

Tests & docs

  • 4 new level-semantics tests in tests/logger.test.ts (explicit info gates debug; silent swallows errors; error level; enabled getter). 8/8 logger tests, 1028/1028 full suite, tsc 0 errors.
  • CONFIGURATION×2 (logLevel section + rewritten debug section), README×2 config examples, devlog 2026-08-21_default-on-logging/.

Behavior matrix

Install config What lands in daily log
default INFO + WARN + ERROR (decision trail)
logLevel: "warn" old default behavior
logLevel: "debug" full debug + context snapshots
logLevel: "silent" nothing
debug: true full debug (overrides logLevel)

Checklist

  • tsc --noEmit — 0 errors
  • Full test suite — 1028 pass / 0 fail
  • Back-compat verified: existing new Logger(false) tests unchanged and passing
  • Docs updated (CONFIGURATION×2, README×2, dcp.schema.json)
  • devlog REQ/WORKLOG

- LogLevel (debug|info|warn|error|silent) with rank-gated file writes;
  constructor keeps boolean-only back-compat (false→warn, true→debug)
- new logLevel config (default "info") — decision events written by
  default; debug:true overrides to full debug + per-request snapshots
- INFO audit trail on core paths: plugin init, per-request transform
  summary, mid-session model switch, nudge inject/suppress decisions
  (tier triggers, usage %, growth floor, recommended ranges),
  auto-update check lifecycle
- 4 new logger level-semantics tests; docs/schema updated
@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown

📦 Built Plugin Artifact

Branch: 2026-08-21_default-on-logging (bada84f)

Option A — Install from npm PR tag (recommended)

opencode plugin opencode-acp@pr-332 --global

Each push to this PR publishes a new version under the pr-332 npm tag.

Option B — Install from GitHub

opencode plugin "github:ranxianglei/opencode-acp#2026-08-21_default-on-logging" --global

Option C — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf opencode-acp-pr332.tgz
cp -r package/dist ~/.cache/opencode/packages/opencode-acp@latest/node_modules/opencode-acp/dist
  1. Restart opencode to pick up changes.

This comment is automatically updated on each push.

- invalid explicit level (e.g. typo 'verbose') fell through to
  LEVEL_RANK[undefined], failing every gate and dropping even ERROR/WARN;
  config validation is warn-only so bad values do reach the constructor.
  Now clamps to the legacy boolean mapping (false→warn, true→debug).
- info()/debug() early-return before getCallerFile so warn/error/silent
  users no longer pay Error().stack capture for lines that get dropped.
- regression test: bad level + error() must still write 1 line.
@ranxianglei
ranxianglei merged commit b0eefdd into master Aug 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant