projscan 0.1.13 → 0.3.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/README.md +164 -19
- package/dist/analyzers/architectureCheck.js +1 -0
- package/dist/analyzers/architectureCheck.js.map +1 -1
- package/dist/analyzers/securityCheck.js +16 -1
- package/dist/analyzers/securityCheck.js.map +1 -1
- package/dist/cli/index.js +209 -164
- package/dist/cli/index.js.map +1 -1
- package/dist/core/fileInspector.d.ts +13 -0
- package/dist/core/fileInspector.js +205 -0
- package/dist/core/fileInspector.js.map +1 -0
- package/dist/core/hotspotAnalyzer.d.ts +16 -0
- package/dist/core/hotspotAnalyzer.js +342 -0
- package/dist/core/hotspotAnalyzer.js.map +1 -0
- package/dist/core/repositoryScanner.d.ts +4 -1
- package/dist/core/repositoryScanner.js +6 -3
- package/dist/core/repositoryScanner.js.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/prompts.d.ts +14 -0
- package/dist/mcp/prompts.js +126 -0
- package/dist/mcp/prompts.js.map +1 -0
- package/dist/mcp/resources.d.ts +8 -0
- package/dist/mcp/resources.js +57 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/server.d.ts +5 -0
- package/dist/mcp/server.js +205 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +9 -0
- package/dist/mcp/tools.js +176 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/reporters/consoleReporter.d.ts +3 -1
- package/dist/reporters/consoleReporter.js +127 -0
- package/dist/reporters/consoleReporter.js.map +1 -1
- package/dist/reporters/jsonReporter.d.ts +3 -1
- package/dist/reporters/jsonReporter.js +6 -0
- package/dist/reporters/jsonReporter.js.map +1 -1
- package/dist/reporters/markdownReporter.d.ts +3 -1
- package/dist/reporters/markdownReporter.js +99 -0
- package/dist/reporters/markdownReporter.js.map +1 -1
- package/dist/reporters/sarifReporter.d.ts +61 -0
- package/dist/reporters/sarifReporter.js +102 -0
- package/dist/reporters/sarifReporter.js.map +1 -0
- package/dist/types.d.ts +112 -1
- package/dist/utils/baseline.d.ts +4 -4
- package/dist/utils/baseline.js +71 -5
- package/dist/utils/baseline.js.map +1 -1
- package/dist/utils/changedFiles.d.ts +14 -0
- package/dist/utils/changedFiles.js +113 -0
- package/dist/utils/changedFiles.js.map +1 -0
- package/dist/utils/config.d.ts +8 -0
- package/dist/utils/config.js +117 -0
- package/dist/utils/config.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
**Instant codebase insights — doctor, x-ray, and architecture map for any repository.**
|
|
10
10
|
|
|
11
|
-
[Install](#install) · [Quick Start](#quick-start) · [Commands](#commands) · [Full Guide](docs/GUIDE.md)
|
|
11
|
+
[Install](#install) · [Quick Start](#quick-start) · [Commands](#commands) · [Full Guide](docs/GUIDE.md) · [Roadmap](docs/ROADMAP.md)
|
|
12
12
|
|
|
13
13
|
<img src="docs/hero.png" alt="projscan banner" width="600">
|
|
14
14
|
|
|
@@ -60,13 +60,16 @@ npx projscan
|
|
|
60
60
|
Run inside any repository:
|
|
61
61
|
|
|
62
62
|
```bash
|
|
63
|
-
projscan
|
|
64
|
-
projscan doctor
|
|
65
|
-
projscan
|
|
66
|
-
projscan
|
|
67
|
-
projscan
|
|
68
|
-
projscan
|
|
69
|
-
projscan
|
|
63
|
+
projscan # Full project analysis
|
|
64
|
+
projscan doctor # Health check
|
|
65
|
+
projscan hotspots # Rank files by risk (churn × complexity × issues × ownership)
|
|
66
|
+
projscan file <path> # Drill into a file — purpose, risk, ownership, issues
|
|
67
|
+
projscan fix # Auto-fix detected issues
|
|
68
|
+
projscan ci # CI health gate (exits 1 on low score)
|
|
69
|
+
projscan diff # Compare health + hotspot trends against a baseline
|
|
70
|
+
projscan diagram # Architecture visualization
|
|
71
|
+
projscan structure # Directory tree
|
|
72
|
+
projscan mcp # Run as an MCP server for AI coding agents
|
|
70
73
|
```
|
|
71
74
|
|
|
72
75
|
<img src="docs/npx%20projscan%20--help.png" alt="npx projscan --help" width="700">
|
|
@@ -79,14 +82,17 @@ For a comprehensive walkthrough, see the **[Full Guide](docs/GUIDE.md)**.
|
|
|
79
82
|
|---------|-------------|
|
|
80
83
|
| `projscan analyze` | Full analysis — languages, frameworks, dependencies, issues |
|
|
81
84
|
| `projscan doctor` | Health check — missing tooling, architecture smells, security risks |
|
|
85
|
+
| `projscan hotspots` | Rank files by risk — churn × complexity × issues × ownership |
|
|
86
|
+
| `projscan file <path>` | Drill into a file — purpose, risk, ownership, related issues |
|
|
82
87
|
| `projscan fix` | Auto-fix issues (ESLint, Prettier, Vitest, .editorconfig) |
|
|
83
|
-
| `projscan ci` | CI
|
|
84
|
-
| `projscan diff` | Compare current health against a
|
|
88
|
+
| `projscan ci` | CI health gate — SARIF output, `--changed-only` PR-diff mode, exits 1 if score below threshold |
|
|
89
|
+
| `projscan diff` | Compare current health **and hotspot trends** against a baseline |
|
|
85
90
|
| `projscan explain <file>` | Explain a file's purpose, imports, exports, and issues |
|
|
86
91
|
| `projscan diagram` | ASCII architecture diagram of your project |
|
|
87
92
|
| `projscan structure` | Directory tree with file counts |
|
|
88
93
|
| `projscan dependencies` | Dependency analysis — counts, risks, recommendations |
|
|
89
94
|
| `projscan badge` | Generate a health score badge for your README |
|
|
95
|
+
| `projscan mcp` | Run as an MCP server for AI coding agents (Claude Code, Cursor, …) |
|
|
90
96
|
|
|
91
97
|
To see all commands and options, run:
|
|
92
98
|
|
|
@@ -133,15 +139,19 @@ All commands support `--format` for different output targets:
|
|
|
133
139
|
```bash
|
|
134
140
|
projscan analyze --format json # Machine-readable JSON
|
|
135
141
|
projscan doctor --format markdown # Markdown for docs/PRs
|
|
142
|
+
projscan ci --format sarif # SARIF 2.1.0 for GitHub Code Scanning
|
|
136
143
|
```
|
|
137
144
|
|
|
138
|
-
Formats: `console` (default), `json`, `markdown`
|
|
145
|
+
Formats: `console` (default), `json`, `markdown`, `sarif`
|
|
139
146
|
|
|
140
147
|
### Options
|
|
141
148
|
|
|
142
149
|
| Flag | Description |
|
|
143
150
|
|------|-------------|
|
|
144
|
-
| `--format <type>` | Output format: console, json, markdown |
|
|
151
|
+
| `--format <type>` | Output format: console, json, markdown, sarif |
|
|
152
|
+
| `--config <path>` | Path to a `.projscanrc` config file |
|
|
153
|
+
| `--changed-only` | Scope to files changed vs base ref (ci/analyze/doctor) |
|
|
154
|
+
| `--base-ref <ref>` | Git base ref for `--changed-only` (default: origin/main) |
|
|
145
155
|
| `--verbose` | Enable debug output |
|
|
146
156
|
| `--quiet` | Suppress non-essential output |
|
|
147
157
|
| `-V, --version` | Show version |
|
|
@@ -198,21 +208,79 @@ This outputs a [shields.io](https://shields.io) badge URL and markdown snippet y
|
|
|
198
208
|
Use `projscan ci` to gate your pipelines:
|
|
199
209
|
|
|
200
210
|
```bash
|
|
201
|
-
projscan ci --min-score 70
|
|
202
|
-
projscan ci --min-score 80 --format json
|
|
211
|
+
projscan ci --min-score 70 # Exits 1 if score < 70
|
|
212
|
+
projscan ci --min-score 80 --format json # JSON output for parsing
|
|
213
|
+
projscan ci --changed-only # Gate only on this PR's diff
|
|
214
|
+
projscan ci --format sarif > projscan.sarif # SARIF for Code Scanning
|
|
203
215
|
```
|
|
204
216
|
|
|
205
217
|
<img src="docs/npx%20projscan%20ci%20--min-score%2070.png" alt="npx projscan ci --min-score 70" width="700">
|
|
206
218
|
|
|
207
|
-
### GitHub
|
|
219
|
+
### GitHub Action (recommended)
|
|
220
|
+
|
|
221
|
+
projscan ships a first-party GitHub Action that installs, runs, and uploads SARIF to **GitHub Code Scanning** in one step:
|
|
222
|
+
|
|
223
|
+
```yaml
|
|
224
|
+
# .github/workflows/projscan.yml
|
|
225
|
+
name: ProjScan
|
|
226
|
+
on:
|
|
227
|
+
push: { branches: [main] }
|
|
228
|
+
pull_request: { branches: [main] }
|
|
229
|
+
|
|
230
|
+
permissions:
|
|
231
|
+
contents: read
|
|
232
|
+
security-events: write # required for SARIF upload
|
|
233
|
+
|
|
234
|
+
jobs:
|
|
235
|
+
scan:
|
|
236
|
+
runs-on: ubuntu-latest
|
|
237
|
+
steps:
|
|
238
|
+
- uses: actions/checkout@v4
|
|
239
|
+
with: { fetch-depth: 0 } # needed for --changed-only
|
|
240
|
+
- uses: actions/setup-node@v4
|
|
241
|
+
with: { node-version: 20 }
|
|
242
|
+
- uses: abhiyoheswaran1/projscan@v0.3.0
|
|
243
|
+
with:
|
|
244
|
+
min-score: '70'
|
|
245
|
+
changed-only: 'true'
|
|
246
|
+
```
|
|
208
247
|
|
|
209
|
-
|
|
248
|
+
Inputs: `min-score`, `changed-only`, `base-ref`, `config`, `sarif-file`, `upload-sarif`, `working-directory`, `version`. Outputs: `score`, `grade`.
|
|
210
249
|
|
|
211
|
-
|
|
212
|
-
|
|
250
|
+
Findings appear in the **Security → Code scanning** tab, annotated on files and lines. PRs get inline annotations on changed lines.
|
|
251
|
+
|
|
252
|
+
### Plain workflow (no SARIF upload)
|
|
253
|
+
|
|
254
|
+
If you'd rather not upload SARIF, [`.github/projscan-ci.yml`](.github/projscan-ci.yml) is a drop-in workflow that runs projscan and posts a markdown health report as a PR comment.
|
|
255
|
+
|
|
256
|
+
## Configuration (`.projscanrc`)
|
|
257
|
+
|
|
258
|
+
Drop a `.projscanrc.json` at your repo root to set defaults — CLI flags always win over config. A `"projscan"` key in `package.json` and plain `.projscanrc` are also supported.
|
|
259
|
+
|
|
260
|
+
```json
|
|
261
|
+
{
|
|
262
|
+
"minScore": 80,
|
|
263
|
+
"baseRef": "origin/main",
|
|
264
|
+
"ignore": ["**/fixtures/**", "**/generated/**"],
|
|
265
|
+
"disableRules": ["missing-editorconfig", "large-*"],
|
|
266
|
+
"severityOverrides": {
|
|
267
|
+
"missing-prettier": "info"
|
|
268
|
+
},
|
|
269
|
+
"hotspots": {
|
|
270
|
+
"limit": 20,
|
|
271
|
+
"since": "6 months ago"
|
|
272
|
+
}
|
|
273
|
+
}
|
|
213
274
|
```
|
|
214
275
|
|
|
215
|
-
|
|
276
|
+
Fields:
|
|
277
|
+
|
|
278
|
+
- `minScore` — default `ci` threshold (0–100)
|
|
279
|
+
- `baseRef` — default base ref for `--changed-only`
|
|
280
|
+
- `ignore` — extra glob patterns added to the built-in ignore list
|
|
281
|
+
- `disableRules` — silence rules by id; supports wildcard `prefix-*`
|
|
282
|
+
- `severityOverrides` — remap a rule's severity (`info` / `warning` / `error`)
|
|
283
|
+
- `hotspots.limit` / `hotspots.since` — defaults for the `hotspots` command
|
|
216
284
|
|
|
217
285
|
## Tracking Health Over Time
|
|
218
286
|
|
|
@@ -227,10 +295,87 @@ projscan diff --format markdown # Markdown diff for PRs
|
|
|
227
295
|
|
|
228
296
|
<img src="docs/npx%20projscan%20diff%20--save-baseline.png" alt="npx projscan diff --save-baseline" width="700">
|
|
229
297
|
|
|
298
|
+
## Hotspots — Where to Fix First
|
|
299
|
+
|
|
300
|
+
A flat health score doesn't tell you what to do. **`projscan hotspots`** combines `git log` churn, file complexity, open issues, recency, and **ownership** into a single risk score per file — so you know where refactoring or review will actually pay off.
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
projscan hotspots # Top 10 hotspots
|
|
304
|
+
projscan hotspots --limit 20
|
|
305
|
+
projscan hotspots --since "6 months ago"
|
|
306
|
+
projscan hotspots --format json # Machine-readable for dashboards
|
|
307
|
+
projscan hotspots --format markdown # Drop into a PR or tech-debt ticket
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Hotspot ranking follows the classic Feathers "churn × complexity" heuristic with boosts for files that fail `projscan doctor`, changed recently, or show **bus factor 1** (single-author + high churn). Falls back gracefully outside a git repo.
|
|
311
|
+
|
|
312
|
+
### Drill Into a Hotspot
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
projscan file src/cli/index.ts
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Combines the file's purpose, imports, exports, hotspot risk, ownership, and every open issue that references it — the natural follow-up to `projscan hotspots`.
|
|
319
|
+
|
|
320
|
+
### Track Trends Over Time
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
projscan diff --save-baseline # Snapshots health + hotspots
|
|
324
|
+
# ...time passes, commits happen...
|
|
325
|
+
projscan diff # Shows which hotspots rose / fell
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
The baseline file now captures top hotspots too, so `diff` surfaces files that are **getting worse** (not just new issues).
|
|
329
|
+
|
|
330
|
+
## AI Agent Integration (MCP)
|
|
331
|
+
|
|
332
|
+
**`projscan mcp`** starts an [MCP](https://modelcontextprotocol.io) server over stdio so AI coding agents can query projscan during a session.
|
|
333
|
+
|
|
334
|
+
**Tools** (7):
|
|
335
|
+
- `projscan_analyze` — full project report
|
|
336
|
+
- `projscan_doctor` — health score + issues
|
|
337
|
+
- `projscan_hotspots` — risk-ranked files (with `limit`, `since` args)
|
|
338
|
+
- `projscan_file` — per-file risk + ownership + related issues
|
|
339
|
+
- `projscan_explain` — per-file purpose, imports, exports, smells
|
|
340
|
+
- `projscan_structure` — directory tree
|
|
341
|
+
- `projscan_dependencies` — package audit
|
|
342
|
+
|
|
343
|
+
**Prompts** (2, parameterized with live project data):
|
|
344
|
+
- `prioritize_refactoring` — ranked plan grounded in current hotspots
|
|
345
|
+
- `investigate_file` — senior-engineer brief for a specific file
|
|
346
|
+
|
|
347
|
+
**Resources** (3, readable on demand):
|
|
348
|
+
- `projscan://health` · `projscan://hotspots` · `projscan://structure`
|
|
349
|
+
|
|
350
|
+
### Claude Code
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
claude mcp add projscan -- npx projscan mcp
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Cursor / Windsurf / any MCP client
|
|
357
|
+
|
|
358
|
+
Add to your MCP config:
|
|
359
|
+
|
|
360
|
+
```json
|
|
361
|
+
{
|
|
362
|
+
"mcpServers": {
|
|
363
|
+
"projscan": {
|
|
364
|
+
"command": "npx",
|
|
365
|
+
"args": ["projscan", "mcp"]
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
Now your agent can ask *"what are the riskiest files in this repo?"* and get a grounded answer, or run `projscan_doctor` before proposing an edit.
|
|
372
|
+
|
|
230
373
|
## Use Cases
|
|
231
374
|
|
|
232
375
|
- **Onboarding**: Understand any codebase in seconds, not hours
|
|
233
376
|
- **Code reviews**: Run `projscan doctor --format markdown` and paste into PRs
|
|
377
|
+
- **Tech-debt prioritization**: Use `projscan hotspots` to decide what deserves refactoring time
|
|
378
|
+
- **AI-assisted development**: Mount `projscan mcp` in your agent of choice for grounded edits
|
|
234
379
|
- **CI/CD**: Use `projscan ci` to enforce health standards in your pipeline
|
|
235
380
|
- **Security**: Catch committed secrets and `.env` files before they reach production
|
|
236
381
|
- **Consulting**: Quickly assess client projects before diving in
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"architectureCheck.js","sourceRoot":"","sources":["../../src/analyzers/architectureCheck.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AAE3D,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,QAAgB,EAAE,KAAkB;IAC9D,MAAM,MAAM,GAAY,EAAE,CAAC;IAE3B,sCAAsC;IACtC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;IAChD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,YAAY,CAAC,QAAQ,CAA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ACxB,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,kBAAkB;SAC1B,CAAC,CAAC;IACL,CAAC;IAED,oCAAoC;IACpC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;QACzD,OAAO,CACL,CAAC,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,YAAY,CAAC;YACpE,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS,KAAK,GAAG,CAAC,CACtC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,CAAC,IAAI,CAAC;YACV,EAAE,EAAE,gBAAgB;YACpB,KAAK,EAAE,gBAAgB;YACvB,WAAW,EACT,uFAAuF;YACzF,QAAQ,EAAE,SAAS;YACnB,QAAQ,EAAE,cAAc;YACxB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,UAAU,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC;YACV,EAAE,EAAE,cAAc;YAClB,KAAK,EAAE,wBAAwB;YAC/B,WAAW,EACT,4HAA4H;YAC9H,QAAQ,EAAE,MAAM;YAChB,QAAQ,EAAE,cAAc;YACxB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -38,6 +38,7 @@ export async function check(rootPath, files) {
|
|
|
38
38
|
severity: 'warning',
|
|
39
39
|
category: 'security',
|
|
40
40
|
fixAvailable: false,
|
|
41
|
+
locations: [{ file: file.relativePath, line: 1 }],
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
}
|
|
@@ -55,6 +56,7 @@ export async function check(rootPath, files) {
|
|
|
55
56
|
severity: 'error',
|
|
56
57
|
category: 'security',
|
|
57
58
|
fixAvailable: false,
|
|
59
|
+
locations: [{ file: file.relativePath, line: 1 }],
|
|
58
60
|
});
|
|
59
61
|
}
|
|
60
62
|
}
|
|
@@ -101,7 +103,9 @@ async function scanFileForSecrets(file) {
|
|
|
101
103
|
try {
|
|
102
104
|
const content = await fs.readFile(file.absolutePath, 'utf-8');
|
|
103
105
|
for (const { name, pattern } of SECRET_PATTERNS) {
|
|
104
|
-
|
|
106
|
+
const match = pattern.exec(content);
|
|
107
|
+
if (match) {
|
|
108
|
+
const line = lineNumberFor(content, match.index);
|
|
105
109
|
return {
|
|
106
110
|
id: 'hardcoded-secret',
|
|
107
111
|
title: `Potential ${name} detected in ${file.relativePath}`,
|
|
@@ -109,6 +113,7 @@ async function scanFileForSecrets(file) {
|
|
|
109
113
|
severity: 'error',
|
|
110
114
|
category: 'security',
|
|
111
115
|
fixAvailable: false,
|
|
116
|
+
locations: [{ file: file.relativePath, line }],
|
|
112
117
|
};
|
|
113
118
|
}
|
|
114
119
|
}
|
|
@@ -118,4 +123,14 @@ async function scanFileForSecrets(file) {
|
|
|
118
123
|
}
|
|
119
124
|
return null;
|
|
120
125
|
}
|
|
126
|
+
function lineNumberFor(content, index) {
|
|
127
|
+
if (index <= 0)
|
|
128
|
+
return 1;
|
|
129
|
+
let line = 1;
|
|
130
|
+
for (let i = 0; i < index && i < content.length; i++) {
|
|
131
|
+
if (content.charCodeAt(i) === 10)
|
|
132
|
+
line++;
|
|
133
|
+
}
|
|
134
|
+
return line;
|
|
135
|
+
}
|
|
121
136
|
//# sourceMappingURL=securityCheck.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"securityCheck.js","sourceRoot":"","sources":["../../src/analyzers/securityCheck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;A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