smart-commit-copilot-cli 0.1.0 → 0.1.2

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 (42) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +145 -220
  3. package/docs/configuration.md +7 -1
  4. package/docs/getting-started.md +2 -0
  5. package/docs/publish.md +35 -32
  6. package/docs/release-checklist.md +9 -5
  7. package/docs/releases/0.1.1-draft.md +56 -0
  8. package/docs/releases/0.1.2-draft.md +73 -0
  9. package/docs/verification.md +50 -0
  10. package/examples/config/smart-commit.json +1 -1
  11. package/out/commands/bridge.js +12 -4
  12. package/out/commands/bridge.js.map +1 -1
  13. package/out/commitMessage/index.js +1 -0
  14. package/out/commitMessage/index.js.map +1 -1
  15. package/out/commitMessage/openaiProvider.js +4 -2
  16. package/out/commitMessage/openaiProvider.js.map +1 -1
  17. package/out/commitMessage/prompt.js +36 -0
  18. package/out/commitMessage/prompt.js.map +1 -1
  19. package/out/config/schema.js +1 -1
  20. package/out/contracts.js +17 -1
  21. package/out/contracts.js.map +1 -1
  22. package/out/passHistory/index.js +14 -14
  23. package/out/passHistory/index.js.map +1 -1
  24. package/out/passHistory/store.js +14 -14
  25. package/out/passHistory/store.js.map +1 -1
  26. package/out/promptContext.js +68 -2
  27. package/out/promptContext.js.map +1 -1
  28. package/out/renderOutput.js +24 -0
  29. package/out/renderOutput.js.map +1 -1
  30. package/out/review/mockProvider.js +13 -0
  31. package/out/review/mockProvider.js.map +1 -1
  32. package/out/review/parser.js +4 -4
  33. package/out/review/parser.js.map +1 -1
  34. package/out/review/prompt.js +4 -0
  35. package/out/review/prompt.js.map +1 -1
  36. package/package.json +12 -5
  37. package/src/git-commit-message-skills/conventional/SKILL.md +156 -0
  38. package/src/git-commit-message-skills/conventional/references/examples.md +57 -0
  39. package/src/git-commit-message-skills/gitmoji/SKILL.md +157 -0
  40. package/src/git-commit-message-skills/gitmoji/references/examples.md +71 -0
  41. package/src/git-commit-message-skills/semantic/SKILL.md +158 -0
  42. package/src/git-commit-message-skills/semantic/references/examples.md +71 -0
package/CHANGELOG.md CHANGED
@@ -6,6 +6,48 @@ The format is based on Keep a Changelog, and this project follows Semantic Versi
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.1.2] - 2026-04-14
10
+
11
+ ### Added
12
+
13
+ - `bridge` output now includes structured `reviewDetails` in both JSON and text render paths
14
+ - bundled commit-message skill context is now injected for built-in `conventional`, `semantic`, and `gitmoji` profiles
15
+ - focused regression coverage for config resolution, OpenAI-compatible request handling, Git utilities, output rendering, reporting, and CLI report command branches
16
+ - dedicated Git utility tests for repository root resolution, detached HEAD fallback, upstream detection, working-tree state, and staged deleted-file snapshots
17
+
18
+ ### Changed
19
+
20
+ - default `passHistory.maxEntries` is now `3000`
21
+ - pass-history record field ordering now follows the legacy Smart Commit compatibility shape more closely
22
+ - built-in commit-message prompt builders now carry explicit protocol rules into generation and repair prompts
23
+ - conventional commit generation guidance now aligns more closely with the VS Code plugin behavior
24
+
25
+ ### Fixed
26
+
27
+ - review gating continues to follow the numeric-score-first rule consistently across bridge execution and smoke verification
28
+ - report command coverage now includes missing `--repo`, omitted `--period`, non-Git paths, file-path misuse, missing pass-history, and missing AI connection config scenarios
29
+ - release docs are now aligned with the current `0.1.2` publish target instead of older draft references
30
+
31
+ ## [0.1.1] - 2026-04-14
32
+
33
+ ### Added
34
+
35
+ - repeatable `npm run smoke:test` command for real CLI command-path regression checks
36
+ - `docs/verification.md` to document the command-level verification flow
37
+ - AI report fallback coverage in the smoke regression path
38
+
39
+ ### Changed
40
+
41
+ - GitHub Actions CI now runs `npm run smoke:test` on Node 20 in addition to `npm test`
42
+ - release checklist now points to the repeatable verification flow instead of relying only on manual spot-checks
43
+ - publish guidance is now easier to reuse for follow-up releases after `0.1.0`
44
+
45
+ ### Fixed
46
+
47
+ - command-level release verification now explicitly covers relative and absolute `--config` paths
48
+ - command-level release verification now explicitly checks that `--no-commit --no-push` leaves `HEAD` unchanged
49
+ - review gating now aligns with the VS Code plugin: when a numeric score exists, score vs threshold is the final pass or block standard
50
+
9
51
  ## [0.1.0] - 2026-04-13
10
52
 
11
53
  ### Added
package/README.md CHANGED
@@ -1,101 +1,131 @@
1
1
  # smart-commit CLI
2
2
 
3
- Standalone CLI-first automation runtime for shell, Husky, Cursor hook, and external agent workflows.
3
+ `smart-commit CLI` is a shell-first tool for automated commit review, commit-message generation, and report workflows.
4
4
 
5
- This project is intentionally separate from the VS Code extension runtime. Its goal is simple: expose a stable CLI that can be embedded into real engineering workflows.
5
+ Use it when you want the same workflow to run from a terminal, script, hook, or agent.
6
6
 
7
- ## What It Does
7
+ It can:
8
8
 
9
- `smart-commit CLI` helps you automate four common steps around code changes:
9
+ - inspect staged changes
10
+ - generate or validate commit messages
11
+ - run AI-assisted review gating
12
+ - optionally commit and push
13
+ - persist pass history
14
+ - generate work reports
10
15
 
11
- 1. Inspect staged changes
12
- 2. Generate or validate commit messages
13
- 3. Run AI-assisted review gating
14
- 4. Persist pass history and generate work reports
16
+ Install package:
15
17
 
16
- The current product surface includes:
17
-
18
- - `config resolve`
19
- - `bridge`
20
- - `report generate`
21
- - `schema print`
22
-
23
- ## Who It Is For
18
+ ```bash
19
+ npm install -g smart-commit-copilot-cli
20
+ ```
24
21
 
25
- This CLI is useful when you want `smart-commit` to run outside the editor:
22
+ Run command:
26
23
 
27
- - shell scripts
28
- - Husky hooks
29
- - Cursor hooks
30
- - external agents
31
- - CI or local automation
24
+ ```bash
25
+ smart-commit --help
26
+ ```
32
27
 
33
- ## Before You Start
28
+ Or use `npx` directly:
34
29
 
35
- Current repository state:
30
+ ```bash
31
+ npx smart-commit-copilot-cli --help
32
+ ```
36
33
 
37
- - the package is now configured for npm publication
38
- - the easiest way to try it is from a local checkout
39
- - command examples below use `smart-commit`
34
+ ## Quick Start
40
35
 
41
- If you have not linked the binary yet, replace `smart-commit` with:
36
+ ### 1. Prepare your API key
42
37
 
43
38
  ```bash
44
- node out/cli.js
39
+ export SMART_COMMIT_API_KEY="your-api-key"
45
40
  ```
46
41
 
47
- ## 5-Minute Quick Start
42
+ ### 2. Create a config file
48
43
 
49
- ### 1. Prepare the CLI
44
+ Create `smart-commit.json` in your repository:
50
45
 
51
- ```bash
52
- npm install
53
- npm run build
46
+ ```json
47
+ {
48
+ "smartCommitCli": {
49
+ "connection": {
50
+ "baseUrl": "https://api.openai.com/v1",
51
+ "apiKey": "env:SMART_COMMIT_API_KEY",
52
+ "model": "gpt-5"
53
+ },
54
+ "review": {
55
+ "threshold": 6,
56
+ "language": "zh"
57
+ },
58
+ "commitMessage": {
59
+ "language": "zh",
60
+ "autoGenerate": true,
61
+ "hybridGenerate": false,
62
+ "validation": {
63
+ "protocol": "none",
64
+ "pattern": "",
65
+ "extractTicketIdFromBranch": true,
66
+ "requireTicketIdInMessage": false
67
+ }
68
+ },
69
+ "git": {
70
+ "autoStageWhenNothingStaged": true,
71
+ "autoCommit": false,
72
+ "autoPush": false
73
+ },
74
+ "passHistory": {
75
+ "enabled": true,
76
+ "dirPath": ".smart-commit-cli",
77
+ "maxEntries": 3000
78
+ },
79
+ "reporting": {
80
+ "language": "zh",
81
+ "weekStartsOn": "monday",
82
+ "outputDirPath": ".smart-commit-cli/reports",
83
+ "prompt": "",
84
+ "ai": {
85
+ "enabled": false
86
+ }
87
+ },
88
+ "output": {
89
+ "format": "json",
90
+ "logLevel": "info"
91
+ }
92
+ }
93
+ }
54
94
  ```
55
95
 
56
- Optional, if you want the `smart-commit` command in your shell:
96
+ ### 3. Validate the config
57
97
 
58
98
  ```bash
59
- npm link
99
+ smart-commit config resolve --config ./smart-commit.json
60
100
  ```
61
101
 
62
- ### 2. Prepare your API key
102
+ This is the recommended first command because it shows:
63
103
 
64
- ```bash
65
- export SMART_COMMIT_API_KEY="your-api-key"
66
- ```
104
+ - merged config after CLI args, env vars, file config, and defaults
105
+ - secret redaction
106
+ - validation errors before real execution
67
107
 
68
- ### 3. Copy the example config
108
+ For human-readable output:
69
109
 
70
110
  ```bash
71
- cp examples/config/smart-commit.json ./smart-commit.json
111
+ smart-commit config resolve --config ./smart-commit.json --output text
72
112
  ```
73
113
 
74
- The example config already demonstrates the recommended canonical format:
114
+ ### 4. Run a safe preflight
75
115
 
76
- - `smartCommitCli`
77
- - `apiKey: "env:SMART_COMMIT_API_KEY"`
78
- - JSON output by default
79
-
80
- ### 4. Validate the merged config
116
+ Stage some changes first:
81
117
 
82
118
  ```bash
83
- smart-commit config resolve --config ./smart-commit.json
119
+ git add -A
84
120
  ```
85
121
 
86
- What this gives you:
87
-
88
- - final merged config after CLI args, env vars, file config, and defaults
89
- - secret redaction in output
90
- - early validation before real automation wiring
91
-
92
- ### 5. Run a safe preflight on your repo
122
+ Then run:
93
123
 
94
124
  ```bash
95
125
  smart-commit bridge --repo . --config ./smart-commit.json --dry-run
96
126
  ```
97
127
 
98
- This is the recommended first real command. It checks:
128
+ This checks:
99
129
 
100
130
  - repository path is valid
101
131
  - current directory is inside Git
@@ -103,90 +133,65 @@ This is the recommended first real command. It checks:
103
133
  - commit message can be resolved
104
134
  - bridge input is ready for execution
105
135
 
106
- ### 6. Run review-only mode
136
+ ### 5. Run review-only mode
137
+
138
+ This is the safest way to start using the tool in a real workflow:
107
139
 
108
140
  ```bash
109
141
  smart-commit bridge --repo . --config ./smart-commit.json --no-commit --no-push
110
142
  ```
111
143
 
112
- This is the safest production onboarding mode:
144
+ It will:
113
145
 
114
- - review runs
115
- - commit message logic runs
116
- - no Git side effects happen
146
+ - run review
147
+ - run commit-message logic
148
+ - return structured output
149
+ - avoid Git side effects
117
150
 
118
- ## Fastest Path To Value
151
+ When the review returns a numeric score, the final pass or block result is determined by comparing that score with `review.threshold`.
119
152
 
120
- If you only want the shortest route to practical usage, use this sequence:
153
+ If you only want the shortest path:
121
154
 
122
- 1. `smart-commit config resolve --config ./smart-commit.json`
123
- 2. `smart-commit bridge --repo . --config ./smart-commit.json --dry-run`
124
- 3. `smart-commit bridge --repo . --config ./smart-commit.json --no-commit --no-push`
125
- 4. wire the same command into Husky or Cursor hook
126
- 5. enable `passHistory`
127
- 6. add `report generate`
155
+ 1. install `smart-commit-copilot-cli`
156
+ 2. export `SMART_COMMIT_API_KEY`
157
+ 3. create `smart-commit.json`
158
+ 4. run `smart-commit config resolve`
159
+ 5. run `smart-commit bridge --dry-run`
160
+ 6. run `smart-commit bridge --no-commit --no-push`
128
161
 
129
162
  ## Core Commands
130
163
 
131
- ### `config resolve`
132
-
133
- Use this to inspect the final config after all sources are merged.
164
+ ### Resolve config
134
165
 
135
166
  ```bash
136
167
  smart-commit config resolve --config ./smart-commit.json
137
168
  ```
138
169
 
139
- Useful when:
140
-
141
- - you are debugging precedence issues
142
- - you want to verify `env:VAR_NAME` resolution
143
- - you want to confirm defaults before automation rollout
144
-
145
- ### `bridge`
146
-
147
- This is the main automation entrypoint.
148
-
149
- ```bash
150
- smart-commit bridge --repo . --config ./smart-commit.json
151
- ```
152
-
153
- Typical modes:
154
-
155
- - preflight only:
170
+ ### Bridge preflight
156
171
 
157
172
  ```bash
158
173
  smart-commit bridge --repo . --config ./smart-commit.json --dry-run
159
174
  ```
160
175
 
161
- - review only:
176
+ ### Review-only bridge
162
177
 
163
178
  ```bash
164
179
  smart-commit bridge --repo . --config ./smart-commit.json --no-commit --no-push
165
180
  ```
166
181
 
167
- - full execution:
182
+ ### Full bridge execution
168
183
 
169
184
  ```bash
170
185
  smart-commit bridge --repo . --config ./smart-commit.json
171
186
  ```
172
187
 
173
- ### `report generate`
174
-
175
- Generate a Markdown report from pass history.
188
+ ### Generate a report
176
189
 
177
190
  ```bash
178
191
  smart-commit report generate --repo . --config ./smart-commit.json --period weekly
179
192
  ```
180
193
 
181
- Useful when:
182
-
183
- - you want a local work report
184
- - you want scheduled summaries
185
- - you want agent-readable reporting output
186
-
187
- ### `schema print`
188
-
189
- Print machine-facing JSON Schema for integration contracts.
194
+ ### Print machine-readable schema
190
195
 
191
196
  ```bash
192
197
  smart-commit schema print --target bridge
@@ -194,29 +199,24 @@ smart-commit schema print --target bridge
194
199
 
195
200
  ## Output Modes
196
201
 
197
- Default machine-facing mode:
202
+ Default mode is machine-facing JSON:
198
203
 
199
204
  ```bash
200
205
  smart-commit bridge --repo . --config ./smart-commit.json
201
206
  ```
202
207
 
203
- Human-readable mode:
208
+ For a terminal-friendly summary:
204
209
 
205
210
  ```bash
206
211
  smart-commit bridge --repo . --config ./smart-commit.json --output text
207
212
  ```
208
213
 
209
- Use JSON when:
214
+ Recommended usage:
210
215
 
211
- - integrating with hooks or agents
212
- - branching on `status` and `error.code`
216
+ - use JSON for hooks, agents, and automation
217
+ - use text for manual debugging
213
218
 
214
- Use text when:
215
-
216
- - debugging manually
217
- - checking behavior in a terminal
218
-
219
- ## How Configuration Works
219
+ ## Configuration Rules
220
220
 
221
221
  Config precedence from high to low:
222
222
 
@@ -228,99 +228,52 @@ Config precedence from high to low:
228
228
 
229
229
  Special rule:
230
230
 
231
- - string values like `env:SMART_COMMIT_API_KEY` are resolved from the current process environment after merge and before validation
232
-
233
- Recommended format:
234
-
235
- ```json
236
- {
237
- "smartCommitCli": {
238
- "connection": {
239
- "baseUrl": "https://api.openai.com/v1",
240
- "apiKey": "env:SMART_COMMIT_API_KEY",
241
- "model": "gpt-5"
242
- },
243
- "review": {
244
- "threshold": 6,
245
- "language": "zh"
246
- },
247
- "git": {
248
- "autoCommit": true,
249
- "autoPush": true
250
- }
251
- }
252
- }
253
- ```
254
-
255
- The CLI still supports legacy `smartCommit.*` keys for migration, but `smartCommitCli` is the long-term recommended format.
256
-
257
- ## Common Rollout Patterns
258
-
259
- ### Local Manual Testing
260
-
261
- Use:
262
-
263
- ```bash
264
- smart-commit bridge --repo . --config ./smart-commit.json --dry-run --output text
265
- ```
266
-
267
- ### Husky Pre-Commit
268
-
269
- Use review-only mode:
270
-
271
- ```bash
272
- smart-commit bridge --repo . --config ./smart-commit.json --no-commit --no-push
273
- ```
274
-
275
- Reference files:
276
-
277
- - [`examples/hooks/smart-commit-bridge.sh`](./examples/hooks/smart-commit-bridge.sh)
278
- - [`examples/hooks/husky-pre-commit.sh`](./examples/hooks/husky-pre-commit.sh)
279
-
280
- ### Cursor Hook
281
-
282
- Use the same review-only bridge command behind a shell wrapper.
231
+ - values like `env:SMART_COMMIT_API_KEY` are resolved from the current process environment after merge and before validation
283
232
 
284
- Reference file:
233
+ Canonical format:
285
234
 
286
- - [`examples/hooks/cursor-bridge-wrapper.sh`](./examples/hooks/cursor-bridge-wrapper.sh)
235
+ - `smartCommitCli` is the recommended long-term format
236
+ - legacy `smartCommit.*` is supported for migration
287
237
 
288
- ### External Agent
238
+ ## Automation-Friendly Capabilities
289
239
 
290
- Consume stdout as JSON and branch on:
240
+ This package is designed to work well in shell-driven automation scenarios.
291
241
 
292
- - `schemaVersion`
293
- - `status`
294
- - `error.code`
242
+ Typical examples include:
295
243
 
296
- Reference files:
244
+ - Git hook style workflows
245
+ - editor or IDE hook workflows
246
+ - external agent workflows
247
+ - local automation scripts
248
+ - CI or scheduled reporting flows
297
249
 
298
- - [`examples/agent/bridge-agent.mjs`](./examples/agent/bridge-agent.mjs)
299
- - [`examples/agent/report-agent.mjs`](./examples/agent/report-agent.mjs)
250
+ For machine integrations, the recommended pattern is:
300
251
 
301
- ## Pass History And Reporting
252
+ - call `smart-commit bridge` or `smart-commit report generate`
253
+ - consume stdout as JSON
254
+ - branch on `schemaVersion`, `status`, and `error.code`
302
255
 
303
- When `passHistory.enabled=true`, successful bridge runs are written to `pass-history.jsonl`.
256
+ ## Reporting
304
257
 
305
- Then you can generate reports:
258
+ If `passHistory.enabled=true`, successful runs are written to local history and can be summarized later:
306
259
 
307
260
  ```bash
308
261
  smart-commit report generate --repo . --config ./smart-commit.json --period weekly
309
262
  ```
310
263
 
311
- AI-enhanced reporting is optional:
264
+ Optional AI-enhanced reporting:
312
265
 
313
266
  ```bash
314
267
  smart-commit report generate --repo . --config ./smart-commit.json --period weekly --report-ai
315
268
  ```
316
269
 
317
- If AI generation fails, the CLI falls back to local Markdown rendering automatically.
270
+ If AI generation fails, the CLI falls back to local Markdown automatically.
318
271
 
319
272
  ## Troubleshooting
320
273
 
321
274
  ### `connection.apiKey references missing environment variable`
322
275
 
323
- Your config contains something like:
276
+ Your config contains:
324
277
 
325
278
  ```json
326
279
  "apiKey": "env:SMART_COMMIT_API_KEY"
@@ -336,7 +289,7 @@ export SMART_COMMIT_API_KEY="your-api-key"
336
289
 
337
290
  ### `--repo is required`
338
291
 
339
- `bridge` and `report generate` both require a repository root or a path inside a Git repository.
292
+ `bridge` and `report generate` require a repository path or a path inside a Git repository.
340
293
 
341
294
  ### No staged diff found
342
295
 
@@ -353,40 +306,12 @@ git add -A
353
306
  smart-commit bridge --repo . --config ./smart-commit.json --dry-run
354
307
  ```
355
308
 
356
- ## Documentation Map
357
-
358
- Start here first:
359
-
360
- - [`docs/getting-started.md`](./docs/getting-started.md)
361
-
362
- Then use these based on task:
363
-
364
- - [`docs/configuration.md`](./docs/configuration.md)
365
- - [`docs/integrations.md`](./docs/integrations.md)
366
- - [`docs/contracts.md`](./docs/contracts.md)
367
- - [`examples/config/smart-commit.json`](./examples/config/smart-commit.json)
368
-
369
- Release and maintenance docs:
370
-
371
- - [`docs/release-checklist.md`](./docs/release-checklist.md)
372
- - [`docs/publish.md`](./docs/publish.md)
373
- - [`docs/releases/0.1.0-draft.md`](./docs/releases/0.1.0-draft.md)
374
- - [`docs/roadmap.md`](./docs/roadmap.md)
375
-
376
- ## Development
377
-
378
- Build:
379
-
380
- ```bash
381
- npm run build
382
- ```
383
-
384
- Test:
385
-
386
- ```bash
387
- npm test
388
- ```
389
-
390
- CI:
309
+ ## Recommended First Rollout
391
310
 
392
- - [`.github/workflows/ci.yml`](./.github/workflows/ci.yml)
311
+ 1. create `smart-commit.json`
312
+ 2. run `smart-commit config resolve`
313
+ 3. run `smart-commit bridge --dry-run`
314
+ 4. run `smart-commit bridge --no-commit --no-push`
315
+ 5. embed the same command into your automation flow
316
+ 6. enable pass history
317
+ 7. add reporting
@@ -83,6 +83,12 @@ These are the fields most users usually need first.
83
83
  - `review.skill.path`
84
84
  - `review.skill.promptTuning`
85
85
 
86
+ Numeric review scores are the final gating signal:
87
+
88
+ - `score <= review.threshold` blocks
89
+ - `score > review.threshold` passes
90
+ - if a review returns `score = null`, the model decision is used
91
+
86
92
  ### Commit Message
87
93
 
88
94
  - `commitMessage.input`
@@ -211,7 +217,7 @@ Recommended early team setup:
211
217
  "passHistory": {
212
218
  "enabled": true,
213
219
  "dirPath": ".smart-commit-cli",
214
- "maxEntries": 5000
220
+ "maxEntries": 3000
215
221
  },
216
222
  "output": {
217
223
  "format": "json",
@@ -133,6 +133,8 @@ This lets you verify:
133
133
 
134
134
  without creating a commit or pushing to remote.
135
135
 
136
+ When the review returns a numeric score, the final pass or block result is determined by comparing that score with the configured threshold.
137
+
136
138
  ## Step 8: Enable Pass History
137
139
 
138
140
  If you want reporting later, enable pass history: