Skip to content

feat(cli): add debug logging via CHKIT_DEBUG env variable#105

Merged
KeKs0r merged 1 commit intomainfrom
marc/cli-debug-logging
Mar 29, 2026
Merged

feat(cli): add debug logging via CHKIT_DEBUG env variable#105
KeKs0r merged 1 commit intomainfrom
marc/cli-debug-logging

Conversation

@KeKs0r
Copy link
Copy Markdown
Contributor

@KeKs0r KeKs0r commented Mar 29, 2026

Summary

  • Adds a CHKIT_DEBUG=1 environment variable that enables detailed stderr logging across the CLI
  • New debug.ts module with timestamped, categorized output (cli, config, clickhouse, plugin, hook, journal, schema, migrate, generate, status, drift, check, dispatch, context, command)
  • Instruments 12 files: config loading (path, resolved summary), command dispatch routing, all 10 plugin lifecycle hooks with input/output details, ClickHouse executor wrapper (SQL preview, timing, row counts, errors), journal store (bootstrap, read, write, retry), schema file loading, and key steps in all 5 core commands
  • Zero overhead when disabled — the debug() function returns immediately when CHKIT_DEBUG is unset

Test plan

  • bun run build and bun run typecheck pass
  • CHKIT_DEBUG=1 chkit --version shows debug line on stderr, stdout unaffected
  • CHKIT_DEBUG=1 chkit status shows config resolution, fatal error with stack trace
  • Without CHKIT_DEBUG, output is unchanged (no debug lines)
  • Verify with live ClickHouse: CHKIT_DEBUG=1 chkit migrate --apply shows query timing, journal writes

🤖 Generated with Claude Code

Adds a lightweight stderr debug logger gated by CHKIT_DEBUG=1.
Instruments config loading, command dispatch, all plugin lifecycle
hooks, ClickHouse executor (queries, timing, errors), journal
operations, schema loading, and per-command details (migrate,
generate, status, drift, check).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@KeKs0r KeKs0r merged commit 2f1767f into main Mar 29, 2026
2 checks passed
@KeKs0r KeKs0r deleted the marc/cli-debug-logging branch March 29, 2026 20:25
KeKs0r added a commit that referenced this pull request Mar 29, 2026
* refactor(plugin-obsessiondb): replace hand-rolled API client with ORPC

Replace the manual fetch-based api-client.ts with a typed ORPC client
backed by contracts copied from the platform repo. Narrows remote
commands to status/cancel/list and adds --job-id/--service-id flags.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(plugin-obsessiondb): add grant_type to device token poll request

RFC 8628 requires the grant_type field in the device authorization
token request, which better-auth's device plugin enforces.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(plugin-obsessiondb): handle 400 responses in device token polling

RFC 8628 device flow returns authorization_pending and slow_down as 400
responses. The !res.ok guard was throwing before the body could be parsed,
preventing the existing switch/case from handling these expected states.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Commit currnet Progress

* refactor(plugin-obsessiondb): migrate remote executor and services to oRPC

Replace REST API calls with oRPC client for all remote operations.
The remote executor now routes SQL through workbench.query.execute
instead of the removed /api/v1/ endpoints. Extract shared introspection
helpers (buildIntrospectedTables, normalize functions) from @chkit/clickhouse
so both local and remote executors reuse the same logic.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(cli): add debug logging via CHKIT_DEBUG env variable (#105)

Adds a lightweight stderr debug logger gated by CHKIT_DEBUG=1.
Instruments config loading, command dispatch, all plugin lifecycle
hooks, ClickHouse executor (queries, timing, errors), journal
operations, schema loading, and per-command details (migrate,
generate, status, drift, check).

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

* refactor(plugin-obsessiondb): replace hand-rolled API client with ORPC

Replace the manual fetch-based api-client.ts with a typed ORPC client
backed by contracts copied from the platform repo. Narrows remote
commands to status/cancel/list and adds --job-id/--service-id flags.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(plugin-obsessiondb): add grant_type to device token poll request

RFC 8628 requires the grant_type field in the device authorization
token request, which better-auth's device plugin enforces.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(plugin-obsessiondb): handle 400 responses in device token polling

RFC 8628 device flow returns authorization_pending and slow_down as 400
responses. The !res.ok guard was throwing before the body could be parsed,
preventing the existing switch/case from handling these expected states.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Commit currnet Progress

* refactor(plugin-obsessiondb): migrate remote executor and services to oRPC

Replace REST API calls with oRPC client for all remote operations.
The remote executor now routes SQL through workbench.query.execute
instead of the removed /api/v1/ endpoints. Extract shared introspection
helpers (buildIntrospectedTables, normalize functions) from @chkit/clickhouse
so both local and remote executors reuse the same logic.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 🐛 Throw error on remote query failure

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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