smart-commit-copilot-cli 0.1.0
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.
- package/CHANGELOG.md +31 -0
- package/LICENSE +21 -0
- package/README.md +392 -0
- package/docs/configuration.md +262 -0
- package/docs/contracts.md +134 -0
- package/docs/getting-started.md +177 -0
- package/docs/integrations.md +85 -0
- package/docs/publish.md +135 -0
- package/docs/release-checklist.md +39 -0
- package/docs/releases/0.1.0-draft.md +52 -0
- package/docs/roadmap.md +94 -0
- package/examples/agent/bridge-agent.mjs +51 -0
- package/examples/agent/report-agent.mjs +48 -0
- package/examples/config/smart-commit.json +60 -0
- package/examples/hooks/cursor-bridge-wrapper.sh +12 -0
- package/examples/hooks/husky-pre-commit.sh +6 -0
- package/examples/hooks/smart-commit-bridge.sh +11 -0
- package/out/cli.js +19 -0
- package/out/cli.js.map +1 -0
- package/out/cliApp.js +239 -0
- package/out/cliApp.js.map +1 -0
- package/out/commands/bridge.js +607 -0
- package/out/commands/bridge.js.map +1 -0
- package/out/commands/report.js +266 -0
- package/out/commands/report.js.map +1 -0
- package/out/commands/types.js +3 -0
- package/out/commands/types.js.map +1 -0
- package/out/commitMessage/index.js +110 -0
- package/out/commitMessage/index.js.map +1 -0
- package/out/commitMessage/mockProvider.js +27 -0
- package/out/commitMessage/mockProvider.js.map +1 -0
- package/out/commitMessage/openaiProvider.js +44 -0
- package/out/commitMessage/openaiProvider.js.map +1 -0
- package/out/commitMessage/prompt.js +65 -0
- package/out/commitMessage/prompt.js.map +1 -0
- package/out/commitMessage/protocol.js +126 -0
- package/out/commitMessage/protocol.js.map +1 -0
- package/out/commitMessage/provider.js +3 -0
- package/out/commitMessage/provider.js.map +1 -0
- package/out/config/cliArgs.js +249 -0
- package/out/config/cliArgs.js.map +1 -0
- package/out/config/constants.js +47 -0
- package/out/config/constants.js.map +1 -0
- package/out/config/env.js +183 -0
- package/out/config/env.js.map +1 -0
- package/out/config/file.js +245 -0
- package/out/config/file.js.map +1 -0
- package/out/config/index.js +46 -0
- package/out/config/index.js.map +1 -0
- package/out/config/legacySmartCommit.js +200 -0
- package/out/config/legacySmartCommit.js.map +1 -0
- package/out/config/merge.js +70 -0
- package/out/config/merge.js.map +1 -0
- package/out/config/runtime.js +36 -0
- package/out/config/runtime.js.map +1 -0
- package/out/config/schema.js +204 -0
- package/out/config/schema.js.map +1 -0
- package/out/contracts.js +311 -0
- package/out/contracts.js.map +1 -0
- package/out/git.js +119 -0
- package/out/git.js.map +1 -0
- package/out/logger.js +17 -0
- package/out/logger.js.map +1 -0
- package/out/openaiCompatible.js +67 -0
- package/out/openaiCompatible.js.map +1 -0
- package/out/output.js +23 -0
- package/out/output.js.map +1 -0
- package/out/passHistory/index.js +119 -0
- package/out/passHistory/index.js.map +1 -0
- package/out/passHistory/store.js +252 -0
- package/out/passHistory/store.js.map +1 -0
- package/out/passHistory/types.js +6 -0
- package/out/passHistory/types.js.map +1 -0
- package/out/promptContext.js +72 -0
- package/out/promptContext.js.map +1 -0
- package/out/renderOutput.js +89 -0
- package/out/renderOutput.js.map +1 -0
- package/out/reporting/aggregate.js +113 -0
- package/out/reporting/aggregate.js.map +1 -0
- package/out/reporting/index.js +72 -0
- package/out/reporting/index.js.map +1 -0
- package/out/reporting/mockProvider.js +25 -0
- package/out/reporting/mockProvider.js.map +1 -0
- package/out/reporting/openaiProvider.js +19 -0
- package/out/reporting/openaiProvider.js.map +1 -0
- package/out/reporting/prompt.js +28 -0
- package/out/reporting/prompt.js.map +1 -0
- package/out/reporting/provider.js +3 -0
- package/out/reporting/provider.js.map +1 -0
- package/out/reporting/render.js +151 -0
- package/out/reporting/render.js.map +1 -0
- package/out/reporting/timeWindow.js +79 -0
- package/out/reporting/timeWindow.js.map +1 -0
- package/out/reporting/types.js +11 -0
- package/out/reporting/types.js.map +1 -0
- package/out/review/index.js +64 -0
- package/out/review/index.js.map +1 -0
- package/out/review/mockProvider.js +57 -0
- package/out/review/mockProvider.js.map +1 -0
- package/out/review/openaiProvider.js +40 -0
- package/out/review/openaiProvider.js.map +1 -0
- package/out/review/parser.js +92 -0
- package/out/review/parser.js.map +1 -0
- package/out/review/prompt.js +61 -0
- package/out/review/prompt.js.map +1 -0
- package/out/review/provider.js +3 -0
- package/out/review/provider.js.map +1 -0
- package/out/review/types.js +3 -0
- package/out/review/types.js.map +1 -0
- package/package.json +44 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on Keep a Changelog, and this project follows Semantic Versioning once public releases begin.
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.0] - 2026-04-13
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- standalone `smart-commit CLI` repository structure and TypeScript build/test setup
|
|
14
|
+
- canonical `smartCommitCli` JSON configuration schema
|
|
15
|
+
- compatibility layer for legacy `smartCommit.*` config keys
|
|
16
|
+
- merged config resolution across CLI args, environment variables, config files, and defaults
|
|
17
|
+
- `config resolve` command for inspecting final merged config
|
|
18
|
+
- `bridge` command with repository validation, staged diff handling, auto-stage behavior, review execution, commit-message generation, local commit, and optional push
|
|
19
|
+
- `passHistory` persistence using `pass-history.jsonl`
|
|
20
|
+
- `report generate` command with local Markdown rendering
|
|
21
|
+
- optional AI-enhanced report generation with local fallback
|
|
22
|
+
- machine-facing JSON schemas via `schema print`
|
|
23
|
+
- integration examples for Husky, Cursor hook, and external agents
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- README now documents stable CLI contracts, integration examples, and automation usage patterns
|
|
28
|
+
|
|
29
|
+
### Tested
|
|
30
|
+
|
|
31
|
+
- focused unit and integration coverage for config, review, commit message, bridge, pass history, reporting, and CLI command dispatch
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nie Tao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
# smart-commit CLI
|
|
2
|
+
|
|
3
|
+
Standalone CLI-first automation runtime for shell, Husky, Cursor hook, and external agent workflows.
|
|
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.
|
|
6
|
+
|
|
7
|
+
## What It Does
|
|
8
|
+
|
|
9
|
+
`smart-commit CLI` helps you automate four common steps around code changes:
|
|
10
|
+
|
|
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
|
|
15
|
+
|
|
16
|
+
The current product surface includes:
|
|
17
|
+
|
|
18
|
+
- `config resolve`
|
|
19
|
+
- `bridge`
|
|
20
|
+
- `report generate`
|
|
21
|
+
- `schema print`
|
|
22
|
+
|
|
23
|
+
## Who It Is For
|
|
24
|
+
|
|
25
|
+
This CLI is useful when you want `smart-commit` to run outside the editor:
|
|
26
|
+
|
|
27
|
+
- shell scripts
|
|
28
|
+
- Husky hooks
|
|
29
|
+
- Cursor hooks
|
|
30
|
+
- external agents
|
|
31
|
+
- CI or local automation
|
|
32
|
+
|
|
33
|
+
## Before You Start
|
|
34
|
+
|
|
35
|
+
Current repository state:
|
|
36
|
+
|
|
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`
|
|
40
|
+
|
|
41
|
+
If you have not linked the binary yet, replace `smart-commit` with:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
node out/cli.js
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 5-Minute Quick Start
|
|
48
|
+
|
|
49
|
+
### 1. Prepare the CLI
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm install
|
|
53
|
+
npm run build
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Optional, if you want the `smart-commit` command in your shell:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm link
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 2. Prepare your API key
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
export SMART_COMMIT_API_KEY="your-api-key"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 3. Copy the example config
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
cp examples/config/smart-commit.json ./smart-commit.json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The example config already demonstrates the recommended canonical format:
|
|
75
|
+
|
|
76
|
+
- `smartCommitCli`
|
|
77
|
+
- `apiKey: "env:SMART_COMMIT_API_KEY"`
|
|
78
|
+
- JSON output by default
|
|
79
|
+
|
|
80
|
+
### 4. Validate the merged config
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
smart-commit config resolve --config ./smart-commit.json
|
|
84
|
+
```
|
|
85
|
+
|
|
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
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
smart-commit bridge --repo . --config ./smart-commit.json --dry-run
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
This is the recommended first real command. It checks:
|
|
99
|
+
|
|
100
|
+
- repository path is valid
|
|
101
|
+
- current directory is inside Git
|
|
102
|
+
- staged diff exists, or whether auto-stage would happen
|
|
103
|
+
- commit message can be resolved
|
|
104
|
+
- bridge input is ready for execution
|
|
105
|
+
|
|
106
|
+
### 6. Run review-only mode
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
smart-commit bridge --repo . --config ./smart-commit.json --no-commit --no-push
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
This is the safest production onboarding mode:
|
|
113
|
+
|
|
114
|
+
- review runs
|
|
115
|
+
- commit message logic runs
|
|
116
|
+
- no Git side effects happen
|
|
117
|
+
|
|
118
|
+
## Fastest Path To Value
|
|
119
|
+
|
|
120
|
+
If you only want the shortest route to practical usage, use this sequence:
|
|
121
|
+
|
|
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`
|
|
128
|
+
|
|
129
|
+
## Core Commands
|
|
130
|
+
|
|
131
|
+
### `config resolve`
|
|
132
|
+
|
|
133
|
+
Use this to inspect the final config after all sources are merged.
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
smart-commit config resolve --config ./smart-commit.json
|
|
137
|
+
```
|
|
138
|
+
|
|
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:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
smart-commit bridge --repo . --config ./smart-commit.json --dry-run
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
- review only:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
smart-commit bridge --repo . --config ./smart-commit.json --no-commit --no-push
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
- full execution:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
smart-commit bridge --repo . --config ./smart-commit.json
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### `report generate`
|
|
174
|
+
|
|
175
|
+
Generate a Markdown report from pass history.
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
smart-commit report generate --repo . --config ./smart-commit.json --period weekly
|
|
179
|
+
```
|
|
180
|
+
|
|
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.
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
smart-commit schema print --target bridge
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Output Modes
|
|
196
|
+
|
|
197
|
+
Default machine-facing mode:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
smart-commit bridge --repo . --config ./smart-commit.json
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Human-readable mode:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
smart-commit bridge --repo . --config ./smart-commit.json --output text
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Use JSON when:
|
|
210
|
+
|
|
211
|
+
- integrating with hooks or agents
|
|
212
|
+
- branching on `status` and `error.code`
|
|
213
|
+
|
|
214
|
+
Use text when:
|
|
215
|
+
|
|
216
|
+
- debugging manually
|
|
217
|
+
- checking behavior in a terminal
|
|
218
|
+
|
|
219
|
+
## How Configuration Works
|
|
220
|
+
|
|
221
|
+
Config precedence from high to low:
|
|
222
|
+
|
|
223
|
+
1. CLI arguments
|
|
224
|
+
2. environment variables
|
|
225
|
+
3. `smartCommitCli` in a JSON config file
|
|
226
|
+
4. legacy `smartCommit.*` keys
|
|
227
|
+
5. built-in defaults
|
|
228
|
+
|
|
229
|
+
Special rule:
|
|
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.
|
|
283
|
+
|
|
284
|
+
Reference file:
|
|
285
|
+
|
|
286
|
+
- [`examples/hooks/cursor-bridge-wrapper.sh`](./examples/hooks/cursor-bridge-wrapper.sh)
|
|
287
|
+
|
|
288
|
+
### External Agent
|
|
289
|
+
|
|
290
|
+
Consume stdout as JSON and branch on:
|
|
291
|
+
|
|
292
|
+
- `schemaVersion`
|
|
293
|
+
- `status`
|
|
294
|
+
- `error.code`
|
|
295
|
+
|
|
296
|
+
Reference files:
|
|
297
|
+
|
|
298
|
+
- [`examples/agent/bridge-agent.mjs`](./examples/agent/bridge-agent.mjs)
|
|
299
|
+
- [`examples/agent/report-agent.mjs`](./examples/agent/report-agent.mjs)
|
|
300
|
+
|
|
301
|
+
## Pass History And Reporting
|
|
302
|
+
|
|
303
|
+
When `passHistory.enabled=true`, successful bridge runs are written to `pass-history.jsonl`.
|
|
304
|
+
|
|
305
|
+
Then you can generate reports:
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
smart-commit report generate --repo . --config ./smart-commit.json --period weekly
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
AI-enhanced reporting is optional:
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
smart-commit report generate --repo . --config ./smart-commit.json --period weekly --report-ai
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
If AI generation fails, the CLI falls back to local Markdown rendering automatically.
|
|
318
|
+
|
|
319
|
+
## Troubleshooting
|
|
320
|
+
|
|
321
|
+
### `connection.apiKey references missing environment variable`
|
|
322
|
+
|
|
323
|
+
Your config contains something like:
|
|
324
|
+
|
|
325
|
+
```json
|
|
326
|
+
"apiKey": "env:SMART_COMMIT_API_KEY"
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
but the environment variable is not set.
|
|
330
|
+
|
|
331
|
+
Fix:
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
export SMART_COMMIT_API_KEY="your-api-key"
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### `--repo is required`
|
|
338
|
+
|
|
339
|
+
`bridge` and `report generate` both require a repository root or a path inside a Git repository.
|
|
340
|
+
|
|
341
|
+
### No staged diff found
|
|
342
|
+
|
|
343
|
+
Possible causes:
|
|
344
|
+
|
|
345
|
+
- nothing is staged
|
|
346
|
+
- working tree is clean
|
|
347
|
+
- auto-stage is disabled
|
|
348
|
+
|
|
349
|
+
Try:
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
git add -A
|
|
353
|
+
smart-commit bridge --repo . --config ./smart-commit.json --dry-run
|
|
354
|
+
```
|
|
355
|
+
|
|
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:
|
|
391
|
+
|
|
392
|
+
- [`.github/workflows/ci.yml`](./.github/workflows/ci.yml)
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# Configuration Guide
|
|
2
|
+
|
|
3
|
+
This document explains how `smart-commit CLI` resolves configuration and which settings matter most in practice.
|
|
4
|
+
|
|
5
|
+
## Recommended Format
|
|
6
|
+
|
|
7
|
+
Use the canonical JSON format:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"smartCommitCli": {
|
|
12
|
+
"connection": {
|
|
13
|
+
"baseUrl": "https://api.openai.com/v1",
|
|
14
|
+
"apiKey": "env:SMART_COMMIT_API_KEY",
|
|
15
|
+
"model": "gpt-5"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Legacy `smartCommit.*` keys are still accepted for migration, but they are compatibility input only.
|
|
22
|
+
|
|
23
|
+
## Precedence
|
|
24
|
+
|
|
25
|
+
Merged from high to low:
|
|
26
|
+
|
|
27
|
+
1. CLI arguments
|
|
28
|
+
2. environment variables
|
|
29
|
+
3. `smartCommitCli`
|
|
30
|
+
4. legacy `smartCommit.*`
|
|
31
|
+
5. built-in defaults
|
|
32
|
+
|
|
33
|
+
Example:
|
|
34
|
+
|
|
35
|
+
- config file sets `git.autoPush = true`
|
|
36
|
+
- environment variable sets `SMART_COMMIT_AUTO_PUSH=false`
|
|
37
|
+
- CLI passes `--auto-push`
|
|
38
|
+
|
|
39
|
+
Final result:
|
|
40
|
+
|
|
41
|
+
- `git.autoPush = true` from CLI
|
|
42
|
+
|
|
43
|
+
## `env:VAR_NAME` References
|
|
44
|
+
|
|
45
|
+
String values that begin with `env:` are resolved from the current process environment after merge and before validation.
|
|
46
|
+
|
|
47
|
+
Example:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"smartCommitCli": {
|
|
52
|
+
"connection": {
|
|
53
|
+
"apiKey": "env:SMART_COMMIT_API_KEY"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Required shell setup:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
export SMART_COMMIT_API_KEY="your-api-key"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## High-Value Settings
|
|
66
|
+
|
|
67
|
+
These are the fields most users usually need first.
|
|
68
|
+
|
|
69
|
+
### Connection
|
|
70
|
+
|
|
71
|
+
- `connection.baseUrl`
|
|
72
|
+
- `connection.apiKey`
|
|
73
|
+
- `connection.model`
|
|
74
|
+
- `connection.requestTimeoutMs`
|
|
75
|
+
- `connection.extraHeaders`
|
|
76
|
+
|
|
77
|
+
### Review
|
|
78
|
+
|
|
79
|
+
- `review.threshold`
|
|
80
|
+
- `review.language`
|
|
81
|
+
- `review.maxDiffChars`
|
|
82
|
+
- `review.skill.id`
|
|
83
|
+
- `review.skill.path`
|
|
84
|
+
- `review.skill.promptTuning`
|
|
85
|
+
|
|
86
|
+
### Commit Message
|
|
87
|
+
|
|
88
|
+
- `commitMessage.input`
|
|
89
|
+
- `commitMessage.language`
|
|
90
|
+
- `commitMessage.autoGenerate`
|
|
91
|
+
- `commitMessage.hybridGenerate`
|
|
92
|
+
- `commitMessage.validation.protocol`
|
|
93
|
+
- `commitMessage.validation.pattern`
|
|
94
|
+
- `commitMessage.validation.extractTicketIdFromBranch`
|
|
95
|
+
- `commitMessage.validation.requireTicketIdInMessage`
|
|
96
|
+
- `commitMessage.skill.id`
|
|
97
|
+
- `commitMessage.skill.path`
|
|
98
|
+
- `commitMessage.skill.promptTuning`
|
|
99
|
+
|
|
100
|
+
### Git
|
|
101
|
+
|
|
102
|
+
- `git.autoStageWhenNothingStaged`
|
|
103
|
+
- `git.autoCommit`
|
|
104
|
+
- `git.autoPush`
|
|
105
|
+
- `git.pushTimeoutMs`
|
|
106
|
+
|
|
107
|
+
### Pass History
|
|
108
|
+
|
|
109
|
+
- `passHistory.enabled`
|
|
110
|
+
- `passHistory.dirPath`
|
|
111
|
+
- `passHistory.maxEntries`
|
|
112
|
+
|
|
113
|
+
### Reporting
|
|
114
|
+
|
|
115
|
+
- `reporting.language`
|
|
116
|
+
- `reporting.weekStartsOn`
|
|
117
|
+
- `reporting.outputDirPath`
|
|
118
|
+
- `reporting.prompt`
|
|
119
|
+
- `reporting.ai.enabled`
|
|
120
|
+
|
|
121
|
+
### Output
|
|
122
|
+
|
|
123
|
+
- `output.format`
|
|
124
|
+
- `output.logLevel`
|
|
125
|
+
|
|
126
|
+
## Common CLI Flags
|
|
127
|
+
|
|
128
|
+
Most frequently used:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
--repo
|
|
132
|
+
--config
|
|
133
|
+
--output
|
|
134
|
+
--base-url
|
|
135
|
+
--api-key
|
|
136
|
+
--model
|
|
137
|
+
--threshold
|
|
138
|
+
--review-language
|
|
139
|
+
--commit-language
|
|
140
|
+
--commit-message
|
|
141
|
+
--no-commit
|
|
142
|
+
--no-push
|
|
143
|
+
--dry-run
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Common reporting flags:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
--period
|
|
150
|
+
--report-language
|
|
151
|
+
--report-output-dir
|
|
152
|
+
--report-ai
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Common Environment Variables
|
|
156
|
+
|
|
157
|
+
Most practical ones:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
SMART_COMMIT_API_KEY
|
|
161
|
+
SMART_COMMIT_BASE_URL
|
|
162
|
+
SMART_COMMIT_MODEL
|
|
163
|
+
SMART_COMMIT_THRESHOLD
|
|
164
|
+
SMART_COMMIT_REVIEW_LANGUAGE
|
|
165
|
+
SMART_COMMIT_COMMIT_LANGUAGE
|
|
166
|
+
SMART_COMMIT_AUTO_COMMIT
|
|
167
|
+
SMART_COMMIT_AUTO_PUSH
|
|
168
|
+
SMART_COMMIT_REPORT_LANGUAGE
|
|
169
|
+
SMART_COMMIT_REPORT_OUTPUT_DIR
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Minimal Practical Config
|
|
173
|
+
|
|
174
|
+
If you want the smallest useful starting point:
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"smartCommitCli": {
|
|
179
|
+
"connection": {
|
|
180
|
+
"baseUrl": "https://api.openai.com/v1",
|
|
181
|
+
"apiKey": "env:SMART_COMMIT_API_KEY",
|
|
182
|
+
"model": "gpt-5"
|
|
183
|
+
},
|
|
184
|
+
"git": {
|
|
185
|
+
"autoCommit": false,
|
|
186
|
+
"autoPush": false
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
This gives you a safe review-first starting point.
|
|
193
|
+
|
|
194
|
+
## Safer Team Rollout Config
|
|
195
|
+
|
|
196
|
+
Recommended early team setup:
|
|
197
|
+
|
|
198
|
+
```json
|
|
199
|
+
{
|
|
200
|
+
"smartCommitCli": {
|
|
201
|
+
"connection": {
|
|
202
|
+
"baseUrl": "https://api.openai.com/v1",
|
|
203
|
+
"apiKey": "env:SMART_COMMIT_API_KEY",
|
|
204
|
+
"model": "gpt-5"
|
|
205
|
+
},
|
|
206
|
+
"git": {
|
|
207
|
+
"autoStageWhenNothingStaged": true,
|
|
208
|
+
"autoCommit": false,
|
|
209
|
+
"autoPush": false
|
|
210
|
+
},
|
|
211
|
+
"passHistory": {
|
|
212
|
+
"enabled": true,
|
|
213
|
+
"dirPath": ".smart-commit-cli",
|
|
214
|
+
"maxEntries": 5000
|
|
215
|
+
},
|
|
216
|
+
"output": {
|
|
217
|
+
"format": "json",
|
|
218
|
+
"logLevel": "info"
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Notes On Skills
|
|
225
|
+
|
|
226
|
+
`review.skill.path` and `commitMessage.skill.path` let you point to custom instruction files.
|
|
227
|
+
|
|
228
|
+
Use them when:
|
|
229
|
+
|
|
230
|
+
- your team has custom review standards
|
|
231
|
+
- your team has custom commit-message style guidance
|
|
232
|
+
|
|
233
|
+
`promptTuning` is useful when you want small additive guidance without creating a separate skill file.
|
|
234
|
+
|
|
235
|
+
## Notes On Output
|
|
236
|
+
|
|
237
|
+
Use:
|
|
238
|
+
|
|
239
|
+
- `output.format = "json"` for hooks, agents, and automation
|
|
240
|
+
- `output.format = "text"` for humans in the terminal
|
|
241
|
+
|
|
242
|
+
Use:
|
|
243
|
+
|
|
244
|
+
- `output.logLevel = "debug"` when diagnosing behavior
|
|
245
|
+
- `output.logLevel = "info"` for normal use
|
|
246
|
+
- `output.logLevel = "warn"` when you only care about warnings and errors
|
|
247
|
+
|
|
248
|
+
## Validation Tips
|
|
249
|
+
|
|
250
|
+
Always validate the final config before integration:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
smart-commit config resolve --config ./smart-commit.json
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
This is the fastest way to catch:
|
|
257
|
+
|
|
258
|
+
- missing environment variables
|
|
259
|
+
- invalid booleans or numbers
|
|
260
|
+
- invalid protocol values
|
|
261
|
+
- invalid regex patterns
|
|
262
|
+
- unsupported skill ids
|