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 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
- ## Features
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
- pnpm add -g openspec-stat
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
- ## Usage
45
-
46
- ### Basic Usage
22
+ ## Quick start
47
23
 
48
- Run in a Git repository directory:
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
- ```bash
61
- # Initialize multi-repo configuration (interactive wizard)
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
- # Run multi-repo analysis
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
- **Perfect for team managers who:**
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
- **Note**: By default, multi-repo mode only shows aggregated statistics to avoid information overload. Use `--show-contributors` to see detailed statistics for each contributor.
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
- See [Multi-Repository Guide](./MULTI_REPO_GUIDE.md) for detailed documentation.
46
+ ## Common flags (full list: `openspec-stat --help`)
82
47
 
83
- ### Command Line Options
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
- ```bash
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
- ### Examples
59
+ Analyze multiple local/remote repositories in one run.
105
60
 
106
61
  ```bash
107
- # Track default time range
108
- openspec-stat
109
-
110
- # Track specific time range
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
- # Use Chinese output
132
- openspec-stat --lang zh-CN
67
+ See [Multi-Repository Guide](./MULTI_REPO_GUIDE.md) for full details.
133
68
 
134
- # Combine with other options
135
- openspec-stat --lang zh-CN --verbose
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 File
73
+ ## Configuration (short)
139
74
 
140
- Create `.openspec-stats.json` or `openspec-stats.config.json` in the project root:
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
- ### Configuration Options
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
- 1. **Proposal Summary**: Aggregates statistics by proposal, showing total code changes per proposal and all contributors. This avoids statistical bias from merge commits.
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 Statistics Report
209
- Time Range: 2024-01-01 00:00:00 ~ 2024-01-31 23:59:59
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: 15
212
-
213
- 📋 Proposal Summary (by proposal)
214
- ┌──────────────┬─────────┬──────────────────┬────────────┬───────────┬───────────┬─────────────┐
215
- │ Proposal │ Commits │ ContributorsCode Files │ Additions │ Deletions │ Net Changes
216
- ├──────────────┼─────────┼──────────────────┼────────────┼───────────┼───────────┼─────────────┤
217
- │ feature-123 │ 5 │ John Doe, Jane S.│ 30 │ +890 -234 │ +656 │
218
- │ feature-456 │ 3 │ John Doe │ 15 │ +344 │ -100 │ +244 │
219
- └──────────────┴─────────┴──────────────────┴────────────┴───────────┴───────────┴─────────────┘
220
- 📊 Total: 2 proposals | 8 commits | 45 files | +1234/-334 lines (net: +900)
221
-
222
- 👥 Author Summary (by contributor)
223
- ┌──────────┬─────────┬──────────────────┬────────────┬───────────┬───────────┬─────────────┐
224
- Author │ CommitsOpenSpec ProposalsCode Files Additions Deletions │ Net Changes │
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
- ## Language Support
114
+ Use `--markdown`, `--json`, or `--csv` for other formats.
250
115
 
251
- The tool supports both English and Chinese output. You can specify the language using the `--lang` option:
116
+ ## Language
252
117
 
253
- ```bash
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, branching, and pull-request expectations.
284
- - See [RELEASE.md](./RELEASE.md) for the Changesets-driven versioning and publishing workflow.
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
- ## LICENSE
134
+ ## License
287
135
 
288
136
  MIT