@minniexcode/codex-switch 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +35 -97
  2. package/dist/app/add-provider.js +10 -4
  3. package/dist/app/edit-provider.js +9 -9
  4. package/dist/app/export-providers.js +2 -2
  5. package/dist/app/get-current-profile.js +1 -1
  6. package/dist/app/get-status.js +2 -2
  7. package/dist/app/import-providers.js +15 -7
  8. package/dist/app/list-backups.js +1 -1
  9. package/dist/app/list-config-profiles.js +3 -2
  10. package/dist/app/list-providers.js +1 -1
  11. package/dist/app/remove-provider.js +2 -2
  12. package/dist/app/rollback-backup.js +1 -1
  13. package/dist/app/rollback-latest.js +1 -1
  14. package/dist/app/run-doctor.js +23 -6
  15. package/dist/app/run-mutation.js +2 -2
  16. package/dist/app/setup-codex.js +6 -6
  17. package/dist/app/show-config.js +2 -2
  18. package/dist/app/show-provider.js +1 -1
  19. package/dist/app/switch-provider.js +3 -3
  20. package/dist/cli/add-interactive.js +7 -106
  21. package/dist/cli/args.js +5 -137
  22. package/dist/cli/help.js +5 -313
  23. package/dist/cli/interactive.js +16 -227
  24. package/dist/cli/output.js +2 -2
  25. package/dist/cli/prompt.js +3 -108
  26. package/dist/cli.js +10 -404
  27. package/dist/commands/args.js +132 -0
  28. package/dist/commands/dispatch.js +16 -0
  29. package/dist/commands/handlers.js +391 -0
  30. package/dist/commands/help.js +119 -0
  31. package/dist/commands/registry.js +291 -0
  32. package/dist/commands/types.js +2 -0
  33. package/dist/domain/config.js +100 -23
  34. package/dist/infra/backup-repo.js +8 -208
  35. package/dist/infra/codex-cli.js +8 -128
  36. package/dist/infra/codex-paths.js +5 -69
  37. package/dist/infra/config-repo.js +59 -0
  38. package/dist/infra/fs-utils.js +7 -95
  39. package/dist/infra/lock-repo.js +3 -97
  40. package/dist/infra/providers-repo.js +7 -96
  41. package/dist/interaction/add-interactive.js +108 -0
  42. package/dist/interaction/interactive.js +216 -0
  43. package/dist/interaction/prompt.js +110 -0
  44. package/dist/runtime/codex-cli.js +130 -0
  45. package/dist/runtime/codex-probe.js +50 -0
  46. package/dist/runtime/types.js +2 -0
  47. package/dist/storage/backup-repo.js +210 -0
  48. package/dist/storage/codex-paths.js +71 -0
  49. package/dist/storage/config-repo.js +208 -0
  50. package/dist/storage/fs-utils.js +97 -0
  51. package/dist/storage/lock-repo.js +99 -0
  52. package/dist/storage/providers-repo.js +98 -0
  53. package/docs/Design/codex-switch-v0.0.5-design.md +32 -22
  54. package/docs/Design/codex-switch-v0.0.6-design.md +708 -0
  55. package/docs/PRD/codex-switch-prd-v0.0.5-to-v0.1.0.md +125 -93
  56. package/docs/PRD/codex-switch-prd-v0.1.0.md +200 -226
  57. package/docs/PRD/codex-switch-prd.md +1 -1
  58. package/docs/cli-usage.md +2 -1
  59. package/docs/codex-switch-technical-architecture.md +73 -4
  60. package/docs/test-report-0.0.5.md +163 -0
  61. package/docs/testing.md +131 -0
  62. package/package.json +1 -1
@@ -0,0 +1,163 @@
1
+ # Test Report: 0.0.5
2
+
3
+ Date: 2026-05-13
4
+
5
+ ## Environment
6
+
7
+ - Platform: Windows (`win32`)
8
+ - Node.js: `v24.11.1`
9
+ - npm: `11.13.0`
10
+ - Workspace: `C:\Users\A200477427\Developers\Github\codex-switch`
11
+
12
+ ## Commands Run
13
+
14
+ ```bash
15
+ npm run build
16
+ npm test
17
+ ```
18
+
19
+ ## Overall Result
20
+
21
+ - Build: PASS
22
+ - Test suites: 5/5 PASS
23
+
24
+ Suite results:
25
+
26
+ - `domain`: PASS
27
+ - `app`: PASS
28
+ - `cli`: PASS
29
+ - `dev-sandbox`: PASS
30
+ - `e2e`: PASS
31
+
32
+ ## Coverage Added In This Pass
33
+
34
+ New test assets:
35
+
36
+ - `tests/dev-sandbox.spec.js`
37
+ - `tests/e2e.spec.js`
38
+ - `docs/testing.md`
39
+
40
+ Updated wiring:
41
+
42
+ - `tests/helpers.js`
43
+ - `tests/run-tests.js`
44
+
45
+ ## Detailed Results
46
+
47
+ ### 1. Domain Suite
48
+
49
+ Status: PASS
50
+
51
+ Focus:
52
+
53
+ - config patch planning
54
+ - managed profile view generation
55
+ - provider normalization and masking
56
+ - runtime drift helpers
57
+ - backup list helpers
58
+
59
+ ### 2. App Suite
60
+
61
+ Status: PASS
62
+
63
+ Focus:
64
+
65
+ - list/current/status
66
+ - add/edit/show/remove
67
+ - import/export
68
+ - switch/login/rollback
69
+ - setup
70
+ - doctor
71
+ - lock conflict and rollback behavior
72
+
73
+ ### 3. CLI Suite
74
+
75
+ Status: PASS
76
+
77
+ Focus:
78
+
79
+ - arg parsing
80
+ - help rendering
81
+ - JSON success/failure envelopes
82
+ - interactive add/edit/remove/import/export/rollback/setup flows
83
+ - config commands
84
+
85
+ ### 4. Dev Sandbox Suite
86
+
87
+ Status: PASS
88
+
89
+ Fixture:
90
+
91
+ - `dev-codex/local-sandbox`
92
+
93
+ Validated with the built CLI command dispatcher against the real development fixture:
94
+
95
+ - `list --json`
96
+ - `current --json`
97
+ - `status --json`
98
+ - `config show --json`
99
+ - `backups list --json`
100
+ - `doctor --json`
101
+
102
+ Observed state during test:
103
+
104
+ - active profile: `packycode`
105
+ - managed providers: `freemodel`, `packycode`
106
+ - status issues: `0`
107
+ - backups found: `>= 1`
108
+
109
+ ### 5. End-to-End Suite
110
+
111
+ Status: PASS
112
+
113
+ Fixture strategy:
114
+
115
+ - copy `dev-codex/local-sandbox` into a temp directory
116
+ - run write commands against the temp copy
117
+ - keep the repository fixture unchanged
118
+
119
+ Validated flows:
120
+
121
+ - `switch freemodel` updates active profile and refreshes `auth.json`
122
+ - `rollback` restores `config.toml` and `auth.json`
123
+ - `add` creates a provider in `providers.json`
124
+ - `edit` updates note and tags
125
+ - `remove --force` deletes a non-active provider
126
+ - `add --create-profile` creates a managed profile section in `config.toml` when a same-named `[model_providers.*]` runtime section already exists
127
+ - destructive removal of the active provider fails with `PROFILE_IN_USE`
128
+ - `import --merge` replaces overlapping providers and keeps merged state valid
129
+ - `export` writes a valid providers file
130
+ - `backups list` skips corrupt backup folders with warnings
131
+ - `rollback missing-backup` fails with `BACKUP_NOT_FOUND`
132
+ - corrupt `backups/latest.json` fails with `ROLLBACK_FAILED`
133
+ - `setup` adopt flow works through CLI dispatch with mocked Codex CLI availability
134
+
135
+ Validated mixed workflows:
136
+
137
+ - `add -> switch -> edit -> show -> config show -> export -> rollback`
138
+ - `import --merge -> switch --no-login -> remove -> doctor -> backups list -> rollback <backup-id>`
139
+
140
+ ## Release Confidence
141
+
142
+ Current confidence for `0.0.5`: medium-high.
143
+
144
+ Why:
145
+
146
+ - core read and write workflows now have automated coverage
147
+ - the development fixture is exercised directly by the built CLI
148
+ - backup/rollback behavior is covered by both existing and new tests
149
+
150
+ ## Residual Risks
151
+
152
+ - `setup` is not yet covered as a true subprocess end-to-end command because it depends on interactive adopt input and external `codex` availability
153
+ - `rollback-latest` still has no direct dedicated test case even though `rollback` coverage is strong
154
+ - `README.md` still shows version `0.0.4` in the documentation text and should be updated separately
155
+
156
+ ## Recommended Pre-Release Checklist
157
+
158
+ Before the next publish:
159
+
160
+ - run `npm test`
161
+ - run a manual smoke check of `node dist/cli.js --help`
162
+ - run one real local `switch --no-login` against a temp `--codex-dir`
163
+ - update user-facing docs if the package version changes
@@ -0,0 +1,131 @@
1
+ # Testing Guide
2
+
3
+ `codex-switch` now has four test layers:
4
+
5
+ - `tests/domain.spec.js`: pure domain/unit coverage
6
+ - `tests/app.spec.js`: file-backed application integration coverage
7
+ - `tests/cli.spec.js`: CLI dispatch and prompt simulation coverage
8
+ - `tests/dev-sandbox.spec.js`: real `node dist/cli.js` read-only smoke tests against `dev-codex/local-sandbox`
9
+ - `tests/e2e.spec.js`: write-command regression tests against temporary copies of `dev-codex/local-sandbox`
10
+
11
+ ## Commands
12
+
13
+ Build the CLI:
14
+
15
+ ```bash
16
+ npm run build
17
+ ```
18
+
19
+ Run the full suite:
20
+
21
+ ```bash
22
+ npm test
23
+ ```
24
+
25
+ Run a single suite manually:
26
+
27
+ ```bash
28
+ node -e "require('./tests/dev-sandbox.spec').run()"
29
+ node -e "require('./tests/e2e.spec').run()"
30
+ ```
31
+
32
+ ## Development Fixture
33
+
34
+ The repository fixture lives at:
35
+
36
+ ```text
37
+ dev-codex/local-sandbox/
38
+ ```
39
+
40
+ It is used in two different ways:
41
+
42
+ - read-only dispatcher tests point at it directly
43
+ - mutation tests copy it into a temporary directory before running writes
44
+
45
+ Do not point destructive automation directly at `dev-codex/local-sandbox` unless you intentionally want to update the fixture.
46
+
47
+ ## Read-Only Smoke Tests
48
+
49
+ `tests/dev-sandbox.spec.js` verifies the built CLI against the real development fixture.
50
+
51
+ Covered commands:
52
+
53
+ - `list --json`
54
+ - `current --json`
55
+ - `status --json`
56
+ - `config show --json`
57
+ - `backups list --json`
58
+ - `doctor --json`
59
+
60
+ These tests check two execution styles:
61
+
62
+ - development default resolution with `NODE_ENV=development`
63
+ - explicit `--codex-dir dev-codex/local-sandbox`
64
+
65
+ This is the fastest way to validate that `0.0.x` builds still read the repo sandbox correctly.
66
+
67
+ ## Mutation Regression Tests
68
+
69
+ `tests/e2e.spec.js` uses `fs.cpSync()` to clone `dev-codex/local-sandbox` into a temp directory, then exercises the real CLI command dispatcher against the copy.
70
+
71
+ Covered write scenarios:
72
+
73
+ - `switch` with login and backup creation
74
+ - `rollback` restoring `config.toml` and `auth.json`
75
+ - `add`, `edit`, `remove`
76
+ - `add --create-profile`
77
+ - blocking destructive remove of the active profile provider
78
+ - `import --merge`
79
+ - `export`
80
+ - `backups list` with corrupt backup entries
81
+ - `rollback <missing-id>`
82
+ - corrupt `backups/latest.json`
83
+
84
+ It also includes mixed workflow scenarios where multiple commands operate on the same sandbox copy end-to-end, for example:
85
+
86
+ - `add -> switch -> edit -> show -> config show -> export -> rollback`
87
+ - `import --merge -> switch --no-login -> remove -> doctor -> backups list -> rollback <backup-id>`
88
+
89
+ The setup flow is covered with `executeCommand()` plus mocked Codex CLI checks because `setup` currently depends on external `codex --version` availability and interactive adopt input.
90
+
91
+ ## Fixture Rules
92
+
93
+ - Prefer `--codex-dir <temp-copy>` for all write tests.
94
+ - Prefer `--json` when assertions need stable output.
95
+ - Treat `show --json` output as sensitive because it includes unmasked API keys.
96
+ - If a test needs `codex login` or `codex --version`, prefer mocking the spawn layer.
97
+ - Keep fixture assertions focused on stable data such as provider names, active profile, backup count, and typed error codes.
98
+
99
+ ## Reporting Template
100
+
101
+ Use this template for release checks:
102
+
103
+ ```text
104
+ Version under test: 0.0.x
105
+ Build: PASS/FAIL
106
+ Suite results:
107
+ - domain: PASS/FAIL
108
+ - app: PASS/FAIL
109
+ - cli: PASS/FAIL
110
+ - dev-sandbox: PASS/FAIL
111
+ - e2e: PASS/FAIL
112
+
113
+ Read-only smoke checks:
114
+ - list/current/status/config/backups/doctor
115
+
116
+ Mutation checks:
117
+ - switch/rollback/add/edit/remove/import/export/setup
118
+
119
+ Open risks:
120
+ - <risk 1>
121
+ - <risk 2>
122
+ ```
123
+
124
+ ## Current Gaps
125
+
126
+ Known areas that still deserve more coverage:
127
+
128
+ - true subprocess coverage for `setup`
129
+ - explicit tests for `rollback-latest`
130
+ - more backup corruption cases inside historical manifests
131
+ - README and release docs should stay in sync with the package version
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minniexcode/codex-switch",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Local-first CLI for managing and switching Codex provider/profile configuration.",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",