Skip to content

feat: add configuration system with JSONC support#1

Merged
kldzj merged 2 commits intomainfrom
feat/config-system
Mar 23, 2026
Merged

feat: add configuration system with JSONC support#1
kldzj merged 2 commits intomainfrom
feat/config-system

Conversation

@kldzj
Copy link
Copy Markdown
Owner

@kldzj kldzj commented Mar 23, 2026

Summary

  • Add a 2-layer configuration system (global ~/.config/opencode/btw.jsonc + project .opencode/btw.jsonc) allowing users to customize hint behavior without code changes
  • Include JSON Schema (btw.schema.json) for IDE auto-completion out of the box
  • Auto-creates global config with $schema reference on first run

Configuration Options

Option Default Description
defaultPinned false Default hint type (transient vs pinned)
autoClear.onIdle true Clear transient hints on session idle
autoClear.onQuestionTool true Clear transient hints on question tool
injection.target "both" Where hints are injected: "both", "system", "user"
injection.systemPromptPosition "prepend" System prompt placement: "prepend" or "append"
injection.systemInstructions (built-in) Custom system prompt framing text
injection.userMessagePrefix "BTW, " Custom user message prefix
debug false Default debug mode
toastDuration 3000 Default toast duration in ms

Changes

  • New: src/config.ts — config types, defaults, 2-layer JSONC loading, validation with advisory warnings
  • New: src/config.test.ts — comprehensive config tests
  • New: btw.schema.json — JSON Schema for IDE support
  • Modified: src/core.ts — functions accept optional config parameter
  • Modified: src/plugin.ts — loads config at init, all hooks respect config
  • Modified: src/core.test.ts — updated imports + config-aware tests
  • Modified: package.json — added jsonc-parser dependency
  • Modified: README.md — added Configuration section with examples
  • Modified: .github/workflows/test.yml — updated branch refs from master to main

Test Coverage

177 tests, 293 assertions across 3 test files — all passing.

kldzj added 2 commits March 23, 2026 11:49
Add a 2-layer configuration system (global + project) allowing users
to customize hint behavior, injection targets, auto-clear triggers,
and more via ~/.config/opencode/btw.jsonc or .opencode/btw.jsonc.

- New config module with types, defaults, JSONC parsing, validation
- JSON Schema (btw.schema.json) for IDE auto-completion
- All hardcoded values now respect user configuration
- Auto-creates global config with $schema reference on first run
- Comprehensive test coverage (177 tests, 293 assertions)
- Updated README with configuration documentation and examples
@kldzj kldzj merged commit 3a9c286 into main Mar 23, 2026
1 check passed
@kldzj kldzj deleted the feat/config-system branch March 27, 2026 09:57
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