Skip to content

feat(cli): add comprehensive CLI with 11 commands#1283

Open
fatihkutlar wants to merge 2 commits intothedotmack:mainfrom
fatihkutlar:main
Open

feat(cli): add comprehensive CLI with 11 commands#1283
fatihkutlar wants to merge 2 commits intothedotmack:mainfrom
fatihkutlar:main

Conversation

@fatihkutlar
Copy link

Add complete CLI tool for managing Claude-Mem from terminal:

Commands (11):

  • System: doctor, repair, config, shell
  • Worker: logs
  • Data: backup, stats, search, clean, export, import

Features:

  • doctor: 5 health checks with --fix for auto-repair
  • config: Settings validation (PORT, LOG_LEVEL, etc.)
  • logs: View/follow logs with filtering and cleanup
  • backup: Create/list backups (full, DB-only, settings-only)
  • stats: Database statistics with JSON output
  • search: Full-text memory search with filters
  • clean: Remove old data (sessions, observations, logs)
  • export/import: JSON/Markdown support
  • shell: Bash/Zsh/Fish completion

Technical:

  • Modular architecture (utils/services/commands)
  • Colorized output with helpful error messages
  • Cross-platform support (Windows, macOS, Linux)
  • 35 unit tests included

Documentation:

  • docs/CLI_GUIDE.md - Complete command reference
  • README.md - Updated with CLI quick reference
  • CHANGELOG.md - v10.6.0 release notes

Version: 10.6.0

Copy link

@xkonjin xkonjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick review pass:

  • Main risk area here is auth/session state and stale credential handling.
  • Good to see test coverage move with the code; I’d still make sure it exercises the unhappy path around auth/session state and stale credential handling rather than only the happy path.
  • Before merge, I’d smoke-test the behavior touched by CHANGELOG.md, CLAUDE.md, README.md (+39 more) with malformed input / retry / rollback cases, since that’s where this class of change usually breaks.
  • Cancellation paths are notoriously flaky; a deterministic test proving cleanup happens on abort/timeout would reduce regression risk.

@fatihkutlar
Copy link
Author

Thanks for the thorough review — these are exactly the right things to stress-test.

Auth/session state & stale credentials Added unhappy-path coverage for four cases: expired credentials, missing credentials, malformed token format, and server-side session revocation (401 mock). Each exits non-zero with a human-readable message rather than a raw stack trace.

Malformed input / retry / rollback Added smoke tests for all 11 CLI commands covering invalid/missing flag combinations. No-retry / fail-fast behavior on ECONNREFUSED is now explicitly tested. For multi-step operations with partial-state risk, atomicity tests verify either full apply or full rollback — gaps are flagged with TODO guards that point to the required production-side fix.

Cancellation paths Added deterministic tests (fake timers, no real sleeps) for operation timeout and AbortController abort — each verifies connections and temp files are cleaned up before exit. SIGINT cleanup is marked as a TODO guard pending a process-signal hook in production code.

File Scenarios covered Tests added
tests/cli/auth-session-unhappy.test.ts Expired, missing, malformed credential; revoked session (401 mock) 4
src/cli/tests/malformed-input.test.ts Invalid/missing flags for all 11 CLI commands 11
tests/cli/worker-connection-fail-fast.test.ts ECONNREFUSED fail-fast, no retry hang 1
src/cli/tests/interruption-atomicity.test.ts Partial-apply guards for config/backup/cleanup/session-init/worker restart 5
src/cli/tests/cancellation.test.ts Timeout cleanup, AbortController cleanup, SIGINT TODO guard 4
tests/server/server.test.ts Stabilized with ephemeral ports (no new scenarios) 0
tests/integration/worker-api-endpoints.test.ts Stabilized with ephemeral ports (no new scenarios) 0
tests/integration/hook-execution-e2e.test.ts Stabilized with ephemeral ports (no new scenarios) 0
Total   25

Let me know if you'd prefer any of these split into a separate follow-up PR.

fatihkutlar and others added 2 commits March 13, 2026 18:03
Add complete CLI tool for managing Claude-Mem from terminal:

Commands (11):
- System: doctor, repair, config, shell
- Worker: logs
- Data: backup, stats, search, clean, export, import

Features:
- doctor: 5 health checks with --fix for auto-repair
- config: Settings validation (PORT, LOG_LEVEL, etc.)
- logs: View/follow logs with filtering and cleanup
- backup: Create/list backups (full, DB-only, settings-only)
- stats: Database statistics with JSON output
- search: Full-text memory search with filters
- clean: Remove old data (sessions, observations, logs)
- export/import: JSON/Markdown support
- shell: Bash/Zsh/Fish completion

Technical:
- Modular architecture (utils/services/commands)
- Colorized output with helpful error messages
- Cross-platform support (Windows, macOS, Linux)
- 35 unit tests included

Documentation:
- docs/CLI_GUIDE.md - Complete command reference
- README.md - Updated with CLI quick reference
- CHANGELOG.md - v10.6.0 release notes

Version: 10.6.0
…r CLI

- auth-session-unhappy: expired, missing, malformed, revoked (401) credentials
- malformed-input: invalid flags/args for all 11 CLI commands
- worker-connection-fail-fast: ECONNREFUSED fail-fast behavior
- interruption-atomicity: partial-apply risk guards + rollback TODOs
- cancellation: timeout and AbortController cleanup (deterministic/fake timers)
- server + integration tests: stabilized with ephemeral ports
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.

2 participants