Skip to content

feat(cli): ci + anonymize + diff commands#102

Merged
sepehr-safari merged 1 commit into
mainfrom
feat/cli-ci-anonymize-diff
Jul 9, 2026
Merged

feat(cli): ci + anonymize + diff commands#102
sepehr-safari merged 1 commit into
mainfrom
feat/cli-ci-anonymize-diff

Conversation

@sepehr-safari

Copy link
Copy Markdown
Member

Summary

Adds three new CLI commands for v0.3.0:

1. ocpp-debugkit ci [dir]

Run all built-in scenarios (and optional external scenario files from [dir]), exit 0 if all pass, 1 if any fail. Supports --format json for CI tooling.

ocpp-debugkit ci                    # Run all built-in scenarios
ocpp-debugkit ci ./scenarios        # Also run external scenarios from directory
ocpp-debugkit ci --format json      # JSON output for CI integration

2. ocpp-debugkit anonymize <file>

Strip sensitive fields from a trace file. Anonymizes: idTag, chargePointSerialNumber, stationId, transactionId, email/phone/IP patterns.

ocpp-debugkit anonymize trace.json              # Output to stdout
ocpp-debugkit anonymize trace.json -o anon.json  # Write to file

3. ocpp-debugkit diff <a> <b>

Compare two trace files and output differences. Uses diffTraces() from Issue #85.

ocpp-debugkit diff trace-a.json trace-b.json
ocpp-debugkit diff trace-a.json trace-b.json --format json

Additional Fixes

  • evaluateScenario() now deduplicates failure codes before comparing with expectedFailures — fixes false negatives when a rule fires multiple times for the same code
  • Fixed unexpected-start scenario — extended session duration to >60s to avoid false SUSPICIOUS_SESSION_DURATION trigger
  • Fixed slow-csms-response scenario — changed timing assertion from maxGapMs to minGapMs (the gap should be large, not small)

Files Changed

  • packages/toolkit/src/cli/commands/ci.ts — new
  • packages/toolkit/src/cli/commands/anonymize.ts — new
  • packages/toolkit/src/cli/commands/diff.ts — new
  • packages/toolkit/src/cli/index.ts — register new commands
  • packages/toolkit/src/cli/cli.test.ts — 6 new integration tests
  • packages/toolkit/src/core/assertions.ts — deduplicate failure codes
  • packages/toolkit/src/scenarios/__scenarios__/slow-csms-response.ts — fix assertion
  • packages/toolkit/src/scenarios/__scenarios__/unexpected-start.ts — extend session duration
  • .changeset/v03-cli-commands.md — minor bump changeset
  • CURRENT_STATE.md — updated with v0.3.0 progress

Closes #88

Checklist

  • ocpp-debugkit ci runs all scenarios, exits 0/1, supports --format json and [dir] arg
  • ocpp-debugkit anonymize <file> strips sensitive fields, supports -o output
  • ocpp-debugkit diff <a> <b> shows trace differences, supports --format json
  • All commands have input validation (file paths, size limits, safe parsing)
  • Error messages are non-sensitive
  • Integration tests (execa-based) for each command
  • Help text for each command
  • Changeset added
  • CURRENT_STATE.md updated
  • Lint, typecheck, test, format all pass (371 tests)

@sepehr-safari sepehr-safari merged commit 1b8cb39 into main Jul 9, 2026
2 checks passed
@sepehr-safari sepehr-safari deleted the feat/cli-ci-anonymize-diff branch July 9, 2026 07:11
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.

feat(cli): ci + anonymize + diff commands

1 participant