openspec-stat 1.4.3 → 1.4.5
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/README.md +66 -218
- package/README.zh-CN.md +66 -216
- package/dist/esm/cli.js +2 -2
- package/dist/esm/commands/multi.js +193 -99
- package/dist/esm/i18n/locales/en.json +4 -0
- package/dist/esm/i18n/locales/zh-CN.json +4 -0
- package/dist/esm/multi/cache-path.js +12 -0
- package/dist/esm/multi/config-validator.js +5 -4
- package/dist/esm/multi/multi-repo-analyzer.js +131 -22
- package/package.json +1 -2
- package/dist/esm/branch-selector.d.ts +0 -7
- package/dist/esm/cli.d.ts +0 -2
- package/dist/esm/commands/init.d.ts +0 -7
- package/dist/esm/commands/multi.d.ts +0 -16
- package/dist/esm/commands/single.d.ts +0 -2
- package/dist/esm/config.d.ts +0 -3
- package/dist/esm/formatters.d.ts +0 -7
- package/dist/esm/git-analyzer.d.ts +0 -11
- package/dist/esm/i18n/index.d.ts +0 -7
- package/dist/esm/index.d.ts +0 -6
- package/dist/esm/multi/config-validator.d.ts +0 -3
- package/dist/esm/multi/config-wizard.d.ts +0 -50
- package/dist/esm/multi/multi-repo-analyzer.d.ts +0 -24
- package/dist/esm/stats-aggregator.d.ts +0 -7
- package/dist/esm/time-utils.d.ts +0 -6
- package/dist/esm/types.d.ts +0 -136
- package/dist/esm/ui/spinner.d.ts +0 -12
package/README.md
CHANGED
|
@@ -10,279 +10,127 @@ English | [简体中文](./README.zh-CN.md)
|
|
|
10
10
|
|
|
11
11
|
A CLI tool for tracking team members' OpenSpec proposals and code changes in Git repositories.
|
|
12
12
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
- ✅ Track Git commits within specified time ranges
|
|
16
|
-
- ✅ Identify commits containing both OpenSpec proposals and code changes
|
|
17
|
-
- ✅ **Proposal-based statistics summary** - Aggregate statistics by proposal to avoid merge commit bias
|
|
18
|
-
- ✅ Group statistics by author (commits, proposals, code changes)
|
|
19
|
-
- ✅ Support multiple branches and wildcard filtering
|
|
20
|
-
- ✅ Author name mapping (handle multiple Git accounts for the same person)
|
|
21
|
-
- ✅ Track only recently active members (default: 2 weeks)
|
|
22
|
-
- ✅ Multiple output formats: Table, JSON, CSV, Markdown
|
|
23
|
-
- ✅ Internationalization support: English and Chinese (简体中文)
|
|
24
|
-
- ✅ **🆕 Multi-repository mode (BETA)** - Analyze multiple local/remote repositories in one run
|
|
25
|
-
|
|
26
|
-
## Installation
|
|
27
|
-
|
|
28
|
-
### Global Installation
|
|
13
|
+
## Install
|
|
29
14
|
|
|
30
15
|
```bash
|
|
16
|
+
# global install
|
|
31
17
|
npm install -g openspec-stat
|
|
32
|
-
# or
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Local Project Installation
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
npm install openspec-stat --save-dev
|
|
40
|
-
# or
|
|
41
|
-
pnpm add -D openspec-stat
|
|
18
|
+
# or local (dev dependency)
|
|
19
|
+
npm install -D openspec-stat
|
|
42
20
|
```
|
|
43
21
|
|
|
44
|
-
##
|
|
45
|
-
|
|
46
|
-
### Basic Usage
|
|
22
|
+
## Quick start
|
|
47
23
|
|
|
48
|
-
|
|
24
|
+
Default window: yesterday 20:00 → today 20:00.
|
|
49
25
|
|
|
50
26
|
```bash
|
|
27
|
+
# basic run
|
|
51
28
|
openspec-stat
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
This will track commits in the default time range (yesterday 20:00 ~ today 20:00).
|
|
55
|
-
|
|
56
|
-
### Multi-Repository Mode (BETA)
|
|
57
|
-
|
|
58
|
-
⚠️ **Experimental Feature**: Multi-repository mode allows analyzing multiple repositories (local or remote) in a single run.
|
|
59
29
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
openspec-stat init --multi
|
|
30
|
+
# custom time range
|
|
31
|
+
openspec-stat --since "2024-01-01 00:00:00" --until "2024-01-31 23:59:59"
|
|
63
32
|
|
|
64
|
-
#
|
|
33
|
+
# multi-repo (uses config)
|
|
65
34
|
openspec-stat multi -c .openspec-stats.multi.json
|
|
66
|
-
|
|
67
|
-
# Run with detailed contributor statistics
|
|
68
|
-
openspec-stat multi -c .openspec-stats.multi.json --show-contributors
|
|
69
|
-
|
|
70
|
-
# Generate template
|
|
71
|
-
openspec-stat init --template multi -o config.json
|
|
72
35
|
```
|
|
73
36
|
|
|
74
|
-
|
|
75
|
-
- Have local access to backend repos but not frontend repos
|
|
76
|
-
- Need to track contributions across multiple repositories
|
|
77
|
-
- Want combined statistics without running multiple commands
|
|
37
|
+
## Key features
|
|
78
38
|
|
|
79
|
-
|
|
39
|
+
- Track Git commits in a time window and per-branch filters
|
|
40
|
+
- Detect commits containing both OpenSpec proposals and code changes
|
|
41
|
+
- Proposal-based aggregation to avoid merge-commit bias
|
|
42
|
+
- Author grouping with name mapping (multiple Git identities per person)
|
|
43
|
+
- Multi-branch wildcards and **multi-repository mode (BETA)**
|
|
44
|
+
- Outputs: table, JSON, CSV, Markdown; languages: en / zh-CN
|
|
80
45
|
|
|
81
|
-
|
|
46
|
+
## Common flags (full list: `openspec-stat --help`)
|
|
82
47
|
|
|
83
|
-
|
|
48
|
+
- `-r, --repo <path>`: repository path (default: current directory)
|
|
49
|
+
- `-b, --branches <list>`: comma-separated branches, supports wildcards
|
|
50
|
+
- `-s, --since <datetime>` / `-u, --until <datetime>`: time window
|
|
51
|
+
- `-a, --author <name>`: filter by author
|
|
52
|
+
- `-c, --config <path>`: config file
|
|
53
|
+
- `--json | --csv | --markdown`: output format
|
|
54
|
+
- `-l, --lang <language>`: `en` or `zh-CN`
|
|
55
|
+
- `-v, --verbose`: verbose output
|
|
84
56
|
|
|
85
|
-
|
|
86
|
-
openspec-stat [options]
|
|
87
|
-
|
|
88
|
-
Options:
|
|
89
|
-
-r, --repo <path> Repository path (default: current directory)
|
|
90
|
-
-b, --branches <branches> Branch list, comma-separated (e.g., origin/master,origin/release/v1.0)
|
|
91
|
-
-s, --since <datetime> Start time (default: yesterday 20:00)
|
|
92
|
-
-u, --until <datetime> End time (default: today 20:00)
|
|
93
|
-
-a, --author <name> Filter by specific author
|
|
94
|
-
--json Output in JSON format
|
|
95
|
-
--csv Output in CSV format
|
|
96
|
-
--markdown Output in Markdown format
|
|
97
|
-
-c, --config <path> Configuration file path
|
|
98
|
-
-v, --verbose Verbose output mode
|
|
99
|
-
-l, --lang <language> Language for output (en, zh-CN) (default: "en")
|
|
100
|
-
-V, --version Display version number
|
|
101
|
-
-h, --help Display help information
|
|
102
|
-
```
|
|
57
|
+
## Multi-repo mode (BETA)
|
|
103
58
|
|
|
104
|
-
|
|
59
|
+
Analyze multiple local/remote repositories in one run.
|
|
105
60
|
|
|
106
61
|
```bash
|
|
107
|
-
|
|
108
|
-
openspec-stat
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
openspec-stat --since "2024-01-01 00:00:00" --until "2024-01-31 23:59:59"
|
|
112
|
-
|
|
113
|
-
# Track specific branches
|
|
114
|
-
openspec-stat --branches "origin/master,origin/release/v1.0"
|
|
115
|
-
|
|
116
|
-
# Track specific author
|
|
117
|
-
openspec-stat --author "John Doe"
|
|
118
|
-
|
|
119
|
-
# Output JSON format
|
|
120
|
-
openspec-stat --json > stats.json
|
|
121
|
-
|
|
122
|
-
# Output Markdown report
|
|
123
|
-
openspec-stat --markdown > report.md
|
|
124
|
-
|
|
125
|
-
# Verbose output mode
|
|
126
|
-
openspec-stat --verbose
|
|
127
|
-
|
|
128
|
-
# Use custom configuration file
|
|
129
|
-
openspec-stat --config ./my-config.json
|
|
62
|
+
openspec-stat init --multi # interactive setup
|
|
63
|
+
openspec-stat multi -c .openspec-stats.multi.json # aggregated view
|
|
64
|
+
openspec-stat multi -c .openspec-stats.multi.json --show-contributors
|
|
65
|
+
```
|
|
130
66
|
|
|
131
|
-
|
|
132
|
-
openspec-stat --lang zh-CN
|
|
67
|
+
See [Multi-Repository Guide](./MULTI_REPO_GUIDE.md) for full details.
|
|
133
68
|
|
|
134
|
-
|
|
135
|
-
openspec-stat
|
|
136
|
-
|
|
69
|
+
**Remote cache**: remote repos are cloned once and reused under
|
|
70
|
+
`~/.openspec-stat/cached/repos/<repo-name>-<hash>`. Use `--cache-mode temporary`
|
|
71
|
+
to force one-off clones, or `--force-clone` to refresh a single run.
|
|
137
72
|
|
|
138
|
-
## Configuration
|
|
73
|
+
## Configuration (short)
|
|
139
74
|
|
|
140
|
-
Create `.openspec-stats.json` or `openspec-stats.config.json` in the
|
|
75
|
+
Create `.openspec-stats.json` or `openspec-stats.config.json` in the repo root.
|
|
141
76
|
|
|
142
77
|
```json
|
|
143
78
|
{
|
|
144
|
-
"defaultBranches": [
|
|
145
|
-
"origin/master",
|
|
146
|
-
"origin/main",
|
|
147
|
-
"origin/release/*"
|
|
148
|
-
],
|
|
79
|
+
"defaultBranches": ["origin/master", "origin/main", "origin/release/*"],
|
|
149
80
|
"defaultSinceHours": -30,
|
|
150
81
|
"defaultUntilHours": 18,
|
|
151
|
-
"authorMapping": {
|
|
152
|
-
"John Doe": "John Doe",
|
|
153
|
-
"john.doe@company.com": "John Doe",
|
|
154
|
-
"johnd": "John Doe"
|
|
155
|
-
},
|
|
82
|
+
"authorMapping": {"john.doe@company.com": "John Doe"},
|
|
156
83
|
"openspecDir": "openspec/",
|
|
157
|
-
"excludeExtensions": [
|
|
158
|
-
".md",
|
|
159
|
-
".txt",
|
|
160
|
-
".png",
|
|
161
|
-
".jpg",
|
|
162
|
-
".jpeg",
|
|
163
|
-
".gif",
|
|
164
|
-
".svg",
|
|
165
|
-
".ico",
|
|
166
|
-
".webp"
|
|
167
|
-
],
|
|
84
|
+
"excludeExtensions": [".md", ".txt", ".png", ".jpg", "..."],
|
|
168
85
|
"activeUserWeeks": 2
|
|
169
86
|
}
|
|
170
87
|
```
|
|
171
88
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
- **defaultBranches**: Default branches to track (supports wildcards)
|
|
175
|
-
- **defaultSinceHours**: Default start time offset (hours, negative means going back)
|
|
176
|
-
- **defaultUntilHours**: Default end time (hour of the day)
|
|
177
|
-
- **authorMapping**: Author name mapping to unify multiple Git accounts for the same person
|
|
178
|
-
- **openspecDir**: OpenSpec proposals directory (default: `openspec/`)
|
|
179
|
-
- **excludeExtensions**: File extensions to exclude (not counted as code changes)
|
|
180
|
-
- **activeUserWeeks**: Active user time window (weeks, default: 2)
|
|
181
|
-
|
|
182
|
-
## Statistics Logic
|
|
183
|
-
|
|
184
|
-
The tool identifies commits that meet both conditions:
|
|
185
|
-
|
|
186
|
-
1. Contains file changes in the `openspec/` directory (OpenSpec proposals)
|
|
187
|
-
2. Contains code file changes (excluding documentation files)
|
|
188
|
-
|
|
189
|
-
Statistics include:
|
|
190
|
-
|
|
191
|
-
- **Commits**: Total number of qualifying commits
|
|
192
|
-
- **OpenSpec Proposals**: Counted by `openspec/changes/{proposal-name}` directories
|
|
193
|
-
- **Code Files**: Number of modified code files
|
|
194
|
-
- **Additions**: Lines of code added
|
|
195
|
-
- **Deletions**: Lines of code deleted
|
|
196
|
-
- **Net Changes**: Additions - Deletions
|
|
197
|
-
|
|
198
|
-
The tool provides two perspectives:
|
|
89
|
+
Key fields: default branches/time window, author mapping (merge identities), OpenSpec directory, excluded extensions, active user window.
|
|
199
90
|
|
|
200
|
-
|
|
201
|
-
2. **Author Summary**: Groups statistics by contributor, showing individual author contributions.
|
|
202
|
-
|
|
203
|
-
## Output Formats
|
|
204
|
-
|
|
205
|
-
### Table Format (Default)
|
|
91
|
+
## Output
|
|
206
92
|
|
|
207
93
|
```
|
|
208
|
-
📊 OpenSpec
|
|
209
|
-
Time
|
|
94
|
+
📊 OpenSpec Report
|
|
95
|
+
Time: 2024-01-01 00:00:00 ~ 2024-01-31 23:59:59
|
|
210
96
|
Branches: origin/master
|
|
211
|
-
Total Commits:
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
│ Proposal │ Commits │
|
|
216
|
-
|
|
217
|
-
│ feature-123 │ 5 │
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
│
|
|
225
|
-
|
|
226
|
-
│ John Doe │ 8 │ 3 │ 45 │ +1234 │ -567 │ +667 │
|
|
227
|
-
│ Jane S. │ 7 │ 2 │ 32 │ +890 │ -234 │ +656 │
|
|
228
|
-
└──────────┴─────────┴──────────────────┴────────────┴───────────┴───────────┴─────────────┘
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
### JSON Format
|
|
232
|
-
|
|
233
|
-
```bash
|
|
234
|
-
openspec-stat --json
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
### CSV Format
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
openspec-stat --csv > stats.csv
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
### Markdown Format
|
|
244
|
-
|
|
245
|
-
```bash
|
|
246
|
-
openspec-stat --markdown > report.md
|
|
97
|
+
Total Commits: 8
|
|
98
|
+
|
|
99
|
+
Proposal Summary
|
|
100
|
+
┌──────────────┬─────────┬───────────┬───────────┐
|
|
101
|
+
│ Proposal │ Commits │ Files │ Net Δ │
|
|
102
|
+
├──────────────┼─────────┼───────────┼───────────┤
|
|
103
|
+
│ feature-123 │ 5 │ 30 │ +656 │
|
|
104
|
+
└──────────────┴─────────┴───────────┴───────────┘
|
|
105
|
+
|
|
106
|
+
Author Summary
|
|
107
|
+
┌─────────┬─────────┬───────────┬───────────┐
|
|
108
|
+
│ Author │ Commits │ Proposals │ Net Δ │
|
|
109
|
+
├─────────┼─────────┼───────────┼───────────┤
|
|
110
|
+
│ John D. │ 8 │ 3 │ +667 │
|
|
111
|
+
└─────────┴─────────┴───────────┴───────────┘
|
|
247
112
|
```
|
|
248
113
|
|
|
249
|
-
|
|
114
|
+
Use `--markdown`, `--json`, or `--csv` for other formats.
|
|
250
115
|
|
|
251
|
-
|
|
116
|
+
## Language
|
|
252
117
|
|
|
253
|
-
|
|
254
|
-
# English output (default)
|
|
255
|
-
openspec-stat --lang en
|
|
256
|
-
|
|
257
|
-
# Chinese output
|
|
258
|
-
openspec-stat --lang zh-CN
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
The tool will also automatically detect your system language. If your system locale is set to Chinese, the output will default to Chinese.
|
|
262
|
-
|
|
263
|
-
For a Chinese version of this README, see [README.zh-CN.md](./README.zh-CN.md).
|
|
118
|
+
`--lang en` (default) or `--lang zh-CN`. Locale-based auto-detection is also supported.
|
|
264
119
|
|
|
265
120
|
## Development
|
|
266
121
|
|
|
267
122
|
```bash
|
|
268
|
-
# Install dependencies
|
|
269
123
|
pnpm install
|
|
270
|
-
|
|
271
|
-
# Development mode
|
|
272
124
|
pnpm dev
|
|
273
|
-
|
|
274
|
-
# Build
|
|
275
125
|
pnpm build
|
|
276
|
-
|
|
277
|
-
# Local testing
|
|
278
126
|
node dist/cjs/cli.js
|
|
279
127
|
```
|
|
280
128
|
|
|
281
129
|
## Contributing & Release Process
|
|
282
130
|
|
|
283
|
-
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup
|
|
284
|
-
- See [RELEASE.md](./RELEASE.md) for the Changesets-driven
|
|
131
|
+
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup and PR expectations.
|
|
132
|
+
- See [RELEASE.md](./RELEASE.md) for the Changesets-driven publishing workflow.
|
|
285
133
|
|
|
286
|
-
##
|
|
134
|
+
## License
|
|
287
135
|
|
|
288
136
|
MIT
|