evergreen-deprecation 0.0.0-stage → 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/LICENSE +189 -0
- package/README.md +122 -2
- package/dist/src/action.d.ts +2 -0
- package/dist/src/action.js +62 -0
- package/dist/src/action.js.map +1 -0
- package/dist/src/agent-tools.d.ts +45 -0
- package/dist/src/agent-tools.js +94 -0
- package/dist/src/agent-tools.js.map +1 -0
- package/dist/src/baseline.d.ts +16 -0
- package/dist/src/baseline.js +50 -0
- package/dist/src/baseline.js.map +1 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +97 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/detectors/github-actions.d.ts +7 -0
- package/dist/src/detectors/github-actions.js +96 -0
- package/dist/src/detectors/github-actions.js.map +1 -0
- package/dist/src/detectors/index.d.ts +2 -0
- package/dist/src/detectors/index.js +9 -0
- package/dist/src/detectors/index.js.map +1 -0
- package/dist/src/detectors/npm.d.ts +7 -0
- package/dist/src/detectors/npm.js +253 -0
- package/dist/src/detectors/npm.js.map +1 -0
- package/dist/src/detectors/python.d.ts +7 -0
- package/dist/src/detectors/python.js +329 -0
- package/dist/src/detectors/python.js.map +1 -0
- package/dist/src/domain.d.ts +101 -0
- package/dist/src/domain.js +11 -0
- package/dist/src/domain.js.map +1 -0
- package/dist/src/engine.d.ts +3 -0
- package/dist/src/engine.js +22 -0
- package/dist/src/engine.js.map +1 -0
- package/dist/src/github-action.d.ts +23 -0
- package/dist/src/github-action.js +56 -0
- package/dist/src/github-action.js.map +1 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.js +8 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mcp-cli.d.ts +2 -0
- package/dist/src/mcp-cli.js +9 -0
- package/dist/src/mcp-cli.js.map +1 -0
- package/dist/src/mcp.d.ts +4 -0
- package/dist/src/mcp.js +118 -0
- package/dist/src/mcp.js.map +1 -0
- package/dist/src/migration-packet.d.ts +22 -0
- package/dist/src/migration-packet.js +236 -0
- package/dist/src/migration-packet.js.map +1 -0
- package/dist/src/package-files.d.ts +1 -0
- package/dist/src/package-files.js +22 -0
- package/dist/src/package-files.js.map +1 -0
- package/dist/src/reporters.d.ts +6 -0
- package/dist/src/reporters.js +86 -0
- package/dist/src/reporters.js.map +1 -0
- package/dist/src/sdk.d.ts +34 -0
- package/dist/src/sdk.js +129 -0
- package/dist/src/sdk.js.map +1 -0
- package/dist/src/source-usage.d.ts +3 -0
- package/dist/src/source-usage.js +358 -0
- package/dist/src/source-usage.js.map +1 -0
- package/dist/src/version.d.ts +1 -0
- package/dist/src/version.js +2 -0
- package/dist/src/version.js.map +1 -0
- package/examples/demo/.github/workflows/ci.yml +10 -0
- package/examples/demo/package.json +10 -0
- package/examples/demo/src/client.js +5 -0
- package/examples/detectors/todo-comments.ts +40 -0
- package/package.json +78 -4
- package/registry/github-actions.json +160 -0
- package/registry/nodejs.json +89 -0
- package/registry/npm.json +105 -0
- package/registry/python.json +139 -0
- package/schemas/baseline.v1.schema.json +25 -0
- package/schemas/context.v1.schema.json +66 -0
- package/schemas/deprecations.v1.schema.json +31 -0
- package/schemas/scan.v1.schema.json +130 -0
- package/schemas/verification.v1.schema.json +34 -0
- package/skills/evergreen-deprecation/SKILL.md +37 -0
- package/skills/evergreen-deprecation/evals/cases.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
https://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work.
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean any work of authorship, including
|
|
48
|
+
the original version of the Work and any modifications or additions
|
|
49
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
50
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
51
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
52
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
53
|
+
means any form of electronic, verbal, or written communication sent
|
|
54
|
+
to the Licensor or its representatives, including but not limited to
|
|
55
|
+
communication on electronic mailing lists, source code control systems,
|
|
56
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
57
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
58
|
+
excluding communication that is conspicuously marked or otherwise
|
|
59
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
60
|
+
|
|
61
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
62
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
63
|
+
subsequently incorporated within the Work.
|
|
64
|
+
|
|
65
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
66
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
67
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
68
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
69
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
70
|
+
Work and such Derivative Works in Source or Object form.
|
|
71
|
+
|
|
72
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
73
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
74
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
75
|
+
(except as stated in this section) patent license to make, have made,
|
|
76
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
77
|
+
where such license applies only to those patent claims licensable
|
|
78
|
+
by such Contributor that are necessarily infringed by their
|
|
79
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
80
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
81
|
+
institute patent litigation against any entity (including a
|
|
82
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
83
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
84
|
+
or contributory patent infringement, then any patent licenses
|
|
85
|
+
granted to You under this License for that Work shall terminate
|
|
86
|
+
as of the date such litigation is filed.
|
|
87
|
+
|
|
88
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
89
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
90
|
+
modifications, and in Source or Object form, provided that You
|
|
91
|
+
meet the following conditions:
|
|
92
|
+
|
|
93
|
+
(a) You must give any other recipients of the Work or
|
|
94
|
+
Derivative Works a copy of this License; and
|
|
95
|
+
|
|
96
|
+
(b) You must cause any modified files to carry prominent notices
|
|
97
|
+
stating that You changed the files; and
|
|
98
|
+
|
|
99
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
100
|
+
that You distribute, all copyright, patent, trademark, and
|
|
101
|
+
attribution notices from the Source form of the Work,
|
|
102
|
+
excluding those notices that do not pertain to any part of
|
|
103
|
+
the Derivative Works; and
|
|
104
|
+
|
|
105
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
106
|
+
distribution, then any Derivative Works that You distribute must
|
|
107
|
+
include a readable copy of the attribution notices contained
|
|
108
|
+
within such NOTICE file, excluding those notices that do not
|
|
109
|
+
pertain to any part of the Derivative Works, in at least one
|
|
110
|
+
of the following places: within a NOTICE text file distributed
|
|
111
|
+
as part of the Derivative Works; within the Source form or
|
|
112
|
+
documentation, if provided along with the Derivative Works; or,
|
|
113
|
+
within a display generated by the Derivative Works, if and
|
|
114
|
+
wherever such third-party notices normally appear. The contents
|
|
115
|
+
of the NOTICE file are for informational purposes only and
|
|
116
|
+
do not modify the License. You may add Your own attribution
|
|
117
|
+
notices within Derivative Works that You distribute, alongside
|
|
118
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
119
|
+
that such additional attribution notices cannot be construed
|
|
120
|
+
as modifying the License.
|
|
121
|
+
|
|
122
|
+
You may add Your own copyright statement to Your modifications and
|
|
123
|
+
may provide additional or different license terms and conditions
|
|
124
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
125
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
126
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
127
|
+
the conditions stated in this License.
|
|
128
|
+
|
|
129
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
130
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
131
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
132
|
+
this License, without any additional terms or conditions.
|
|
133
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
134
|
+
the terms of any separate license agreement you may have executed
|
|
135
|
+
with Licensor regarding such Contributions.
|
|
136
|
+
|
|
137
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
138
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
139
|
+
except as required for reasonable and customary use in describing the
|
|
140
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
141
|
+
|
|
142
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
143
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
144
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
145
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
146
|
+
implied, including, without limitation, any warranties or conditions
|
|
147
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
148
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
149
|
+
appropriateness of using or redistributing the Work and assume any
|
|
150
|
+
risks associated with Your exercise of permissions under this License.
|
|
151
|
+
|
|
152
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
153
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
154
|
+
unless required by applicable law (such as deliberate and grossly
|
|
155
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
156
|
+
liable to You for damages, including any direct, indirect, special,
|
|
157
|
+
incidental, or consequential damages of any character arising as a
|
|
158
|
+
result of this License or out of the use or inability to use the
|
|
159
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
160
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
161
|
+
other commercial damages or losses), even if such Contributor
|
|
162
|
+
has been advised of the possibility of such damages.
|
|
163
|
+
|
|
164
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
165
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
166
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
167
|
+
or other liability obligations and/or rights consistent with this
|
|
168
|
+
License. However, in accepting such obligations, You may act only
|
|
169
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
170
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
171
|
+
defend, and hold each Contributor harmless for any liability
|
|
172
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
173
|
+
of your accepting any such warranty or additional liability.
|
|
174
|
+
|
|
175
|
+
END OF TERMS AND CONDITIONS
|
|
176
|
+
|
|
177
|
+
Copyright 2026 Armin Azimi
|
|
178
|
+
|
|
179
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
180
|
+
you may not use this file except in compliance with the License.
|
|
181
|
+
You may obtain a copy of the License at
|
|
182
|
+
|
|
183
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
184
|
+
|
|
185
|
+
Unless required by applicable law or agreed to in writing, software
|
|
186
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
187
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
188
|
+
See the License for the specific language governing permissions and
|
|
189
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,123 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Evergreen
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/arminazimi/evergreen/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/evergreen-deprecation)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
Evergreen is a local-first deprecation intelligence engine for software repositories. It connects upcoming ecosystem changes to the exact files they affect and produces evidence-backed migration context for humans and AI coding agents.
|
|
8
|
+
|
|
9
|
+
Version 0.1 includes GitHub Actions, Node.js, npm, and Python lifecycle detectors. Read the [public documentation](https://arminazimi.github.io/evergreen/), run the [90-second demo](docs/DEMO.md), or inspect the [v0.1 validation report](docs/VALIDATION.md).
|
|
10
|
+
|
|
11
|
+
## Product principles
|
|
12
|
+
|
|
13
|
+
- Local-first: source code stays on the user's machine or CI runner.
|
|
14
|
+
- Deterministic core: findings do not require an LLM.
|
|
15
|
+
- Evidence-backed: every deprecation claim links to an authoritative source.
|
|
16
|
+
- Agent-ready: every human-readable report has a machine-readable equivalent.
|
|
17
|
+
- Extensible: ecosystems are added through detectors rather than core rewrites.
|
|
18
|
+
|
|
19
|
+
## Quickstart
|
|
20
|
+
|
|
21
|
+
Requirements: Node.js 22 or newer.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx evergreen-deprecation scan .
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Create a baseline for accepted existing findings, then report only new lifecycle regressions:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx evergreen-deprecation baseline .
|
|
31
|
+
npx evergreen-deprecation scan . --baseline .evergreen-baseline.json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Inspect the evidence and migration direction for one result:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npx evergreen-deprecation explain '<finding-id>' .
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Generate portable migration context for a human or coding agent:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npx evergreen-deprecation context '<finding-id>' . --json
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Migration packets contain rule-specific constraints and steps, exact affected files and usages, authoritative sources, and suggested verification commands. Evergreen never executes those commands automatically. See the [migration packet guide](docs/MIGRATION_PACKETS.md).
|
|
47
|
+
|
|
48
|
+
Connect a coding agent through the local MCP server:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npx --yes --package evergreen-deprecation evergreen-mcp
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The stdio server exposes `scan_repository`, `list_deprecations`, `explain_deprecation`, `create_migration_context`, and `verify_migration`. See the [local MCP guide](docs/MCP.md) for host configuration, the intended workflow, and privacy guarantees.
|
|
55
|
+
|
|
56
|
+
## Agent Skill
|
|
57
|
+
|
|
58
|
+
The package includes a thin, vendor-neutral Agent Skill at [`skills/evergreen-deprecation`](skills/evergreen-deprecation/SKILL.md). Install that folder in any host implementing the open Agent Skills format. It teaches discovery, explanation, migration, and verification while leaving detection and migration logic inside Evergreen. See the [Agent Skill guide](docs/AGENT_SKILLS.md) for installation, evaluation, limits, and security assumptions.
|
|
59
|
+
|
|
60
|
+
Evergreen runs locally and does not upload repository contents.
|
|
61
|
+
|
|
62
|
+
## Development
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm install
|
|
66
|
+
npm run check
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The initial detector reports unsupported major versions of five first-party actions with exact file and line locations:
|
|
70
|
+
|
|
71
|
+
- `actions/checkout`
|
|
72
|
+
- `actions/setup-node`
|
|
73
|
+
- `actions/cache`
|
|
74
|
+
- `actions/upload-artifact`
|
|
75
|
+
- `actions/download-artifact`
|
|
76
|
+
|
|
77
|
+
Pinned commit SHAs and dynamic expressions are intentionally left unclassified until Evergreen can resolve them without guessing.
|
|
78
|
+
|
|
79
|
+
The npm detector also reads `package.json`, npm/pnpm/Yarn lockfiles, Node.js runtime declarations, and a small evidence-backed registry of deprecated direct dependencies. Use `evergreen explain <finding-id>` to inspect a finding and its sources.
|
|
80
|
+
|
|
81
|
+
The Python detector reads PEP 621 and Poetry metadata from `pyproject.toml`, `requirements*.txt`, common runtime-version files, and uv/Poetry/PDM/Pipenv lockfiles. It reports unsupported Python declarations and lifecycle risks in direct dependencies while ignoring transitive-only lockfile entries.
|
|
82
|
+
|
|
83
|
+
## Source usage analysis
|
|
84
|
+
|
|
85
|
+
Package lifecycle findings now include the concrete imports, calls, and configuration keys that make a migration necessary. Matching is language-aware and alias-aware for JavaScript, TypeScript, and Python, with configuration-key support for JSON, YAML, TOML, INI, and Python settings. Each match includes its exact file, line, column, and source excerpt, plus a migration-impact estimate based on affected usages and files.
|
|
86
|
+
|
|
87
|
+
The analyzer scans the repository once for a batch of detector contracts and ignores generated, dependency, build, and environment directories. Run the repeatable accuracy and scan-time benchmark with:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm run benchmark:usage
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
See [the benchmark notes](docs/BENCHMARKS.md) for the corpus and interpretation.
|
|
94
|
+
|
|
95
|
+
## GitHub Action
|
|
96
|
+
|
|
97
|
+
Evergreen can annotate pull requests, suppress accepted findings with a baseline, fail on a chosen severity, and upload the complete JSON report:
|
|
98
|
+
|
|
99
|
+
```yaml
|
|
100
|
+
permissions:
|
|
101
|
+
contents: read
|
|
102
|
+
|
|
103
|
+
steps:
|
|
104
|
+
- uses: actions/checkout@v7
|
|
105
|
+
- uses: arminazimi/evergreen@v0.1.0
|
|
106
|
+
with:
|
|
107
|
+
baseline: .evergreen-baseline.json
|
|
108
|
+
fail-on-severity: high
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Pin a full commit SHA instead of a version tag when your threat model requires immutable third-party action references. See the [GitHub Action guide](docs/GITHUB_ACTION.md) for setup, inputs, permissions, artifacts, and privacy boundaries.
|
|
112
|
+
|
|
113
|
+
## Detector SDK
|
|
114
|
+
|
|
115
|
+
External detectors can use the versioned interface exported by `evergreen-deprecation/sdk`. The scan engine composes compatible detectors without importing any built-in implementation.
|
|
116
|
+
|
|
117
|
+
See the [detector authoring guide](docs/DETECTORS.md) and the [minimal detector example](examples/detectors/todo-comments.ts).
|
|
118
|
+
|
|
119
|
+
## Initial product shape
|
|
120
|
+
|
|
121
|
+
The CLI is the product. Detectors extend it, GitHub Actions automate it, and the local MCP server exposes it to agents. A hosted backend is intentionally outside the first three-month roadmap.
|
|
122
|
+
|
|
123
|
+
See [the roadmap](docs/ROADMAP.md), [architecture](docs/ARCHITECTURE.md), and [contribution guide](CONTRIBUTING.md).
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { appendFile } from "node:fs/promises";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
import { runGitHubAction } from "./github-action.js";
|
|
6
|
+
function commandValue(value) {
|
|
7
|
+
return value.replaceAll("%", "%25").replaceAll("\r", "%0D").replaceAll("\n", "%0A");
|
|
8
|
+
}
|
|
9
|
+
function commandProperty(value) {
|
|
10
|
+
return commandValue(value).replaceAll(":", "%3A").replaceAll(",", "%2C");
|
|
11
|
+
}
|
|
12
|
+
function annotationCommand(annotation) {
|
|
13
|
+
const properties = [
|
|
14
|
+
`file=${commandProperty(annotation.location.path)}`,
|
|
15
|
+
annotation.location.line ? `line=${annotation.location.line}` : undefined,
|
|
16
|
+
annotation.location.column ? `col=${annotation.location.column}` : undefined,
|
|
17
|
+
`title=${commandProperty(annotation.title)}`,
|
|
18
|
+
].filter((value) => value !== undefined);
|
|
19
|
+
return `::${annotation.level} ${properties.join(",")}::${commandValue(annotation.message)}`;
|
|
20
|
+
}
|
|
21
|
+
async function setOutput(name, value) {
|
|
22
|
+
const output = process.env.GITHUB_OUTPUT;
|
|
23
|
+
if (output)
|
|
24
|
+
await appendFile(output, `${name}=${value}\n`, "utf8");
|
|
25
|
+
}
|
|
26
|
+
async function writeSummary(findings, failed, gate) {
|
|
27
|
+
const summary = process.env.GITHUB_STEP_SUMMARY;
|
|
28
|
+
if (!summary)
|
|
29
|
+
return;
|
|
30
|
+
const status = failed ? `failed the **${gate}** severity gate` : "passed the severity gate";
|
|
31
|
+
await appendFile(summary, `## Evergreen\n\nFound **${findings}** new lifecycle finding${findings === 1 ? "" : "s"}; ${status}.\n`, "utf8");
|
|
32
|
+
}
|
|
33
|
+
async function main() {
|
|
34
|
+
try {
|
|
35
|
+
const workspace = process.env.GITHUB_WORKSPACE ?? process.cwd();
|
|
36
|
+
const root = process.env.INPUT_PATH || workspace;
|
|
37
|
+
const reportPath = resolve(process.env.RUNNER_TEMP ?? workspace, "evergreen-report.json");
|
|
38
|
+
const outcome = await runGitHubAction({
|
|
39
|
+
root,
|
|
40
|
+
reportPath,
|
|
41
|
+
...(process.env.INPUT_BASELINE ? { baselinePath: process.env.INPUT_BASELINE } : {}),
|
|
42
|
+
failOnSeverity: (process.env["INPUT_FAIL-ON-SEVERITY"] || "high"),
|
|
43
|
+
});
|
|
44
|
+
for (const annotation of outcome.annotations)
|
|
45
|
+
console.log(annotationCommand(annotation));
|
|
46
|
+
await setOutput("report-path", outcome.reportPath);
|
|
47
|
+
await setOutput("finding-count", String(outcome.result.findings.length));
|
|
48
|
+
await writeSummary(outcome.result.findings.length, outcome.failed, outcome.gate);
|
|
49
|
+
console.log(`Evergreen found ${outcome.result.findings.length} new lifecycle finding${outcome.result.findings.length === 1 ? "" : "s"}.`);
|
|
50
|
+
if (outcome.failed) {
|
|
51
|
+
console.log(`::error title=Evergreen severity gate failed::A finding met the ${outcome.gate} threshold.`);
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
57
|
+
console.log(`::error title=Evergreen failed::${commandValue(message)}`);
|
|
58
|
+
process.exitCode = 1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
void main();
|
|
62
|
+
//# sourceMappingURL=action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/action.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK,CAAC,UAAU,CAAC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EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QACzE,MAAM,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACjF,OAAO,CAAC,GAAG,CACT,mBAAmB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,yBAAyB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAC7H,CAAC;QACF,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,mEAAmE,OAAO,CAAC,IAAI,aAAa,CAAC,CAAC;YAC1G,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,OAAO,CAAC,GAAG,CAAC,mCAAmC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACxE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,KAAK,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Finding, ScanResult, Severity, SourceLocation, VerificationCommand } from "./domain.js";
|
|
2
|
+
import type { MigrationPacket } from "./migration-packet.js";
|
|
3
|
+
export interface DeprecationSummary {
|
|
4
|
+
id: string;
|
|
5
|
+
ruleId: string;
|
|
6
|
+
title: string;
|
|
7
|
+
severity: Severity;
|
|
8
|
+
location: SourceLocation;
|
|
9
|
+
usageCount: number;
|
|
10
|
+
affectedFiles: number;
|
|
11
|
+
}
|
|
12
|
+
export interface DeprecationList {
|
|
13
|
+
schemaVersion: "evergreen.deprecations.v1";
|
|
14
|
+
repositoryRoot: string;
|
|
15
|
+
scannedAt: string;
|
|
16
|
+
count: number;
|
|
17
|
+
deprecations: DeprecationSummary[];
|
|
18
|
+
}
|
|
19
|
+
export interface MigrationVerification {
|
|
20
|
+
schemaVersion: "evergreen.verification.v1";
|
|
21
|
+
repositoryRoot: string;
|
|
22
|
+
findingId: string;
|
|
23
|
+
verifiedAt: string;
|
|
24
|
+
verified: boolean;
|
|
25
|
+
commandsExecuted: false;
|
|
26
|
+
summary: string;
|
|
27
|
+
remainingFindings: Finding[];
|
|
28
|
+
suggestedCommands: VerificationCommand[];
|
|
29
|
+
}
|
|
30
|
+
export declare class FindingNotObservedError extends Error {
|
|
31
|
+
constructor(findingId: string);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Owns Evergreen's agent workflow behind a local, transport-independent interface.
|
|
35
|
+
* Transport adapters should translate inputs and outputs only.
|
|
36
|
+
*/
|
|
37
|
+
export declare class EvergreenAgentTools {
|
|
38
|
+
private readonly observed;
|
|
39
|
+
scan(repositoryPath?: string): Promise<ScanResult>;
|
|
40
|
+
list(repositoryPath?: string): Promise<DeprecationList>;
|
|
41
|
+
explain(findingId: string, repositoryPath?: string): Promise<Finding>;
|
|
42
|
+
context(findingId: string, repositoryPath?: string): Promise<MigrationPacket>;
|
|
43
|
+
verify(findingId: string, repositoryPath?: string): Promise<MigrationVerification>;
|
|
44
|
+
private remember;
|
|
45
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { findingFingerprint } from "./baseline.js";
|
|
3
|
+
import { builtInDetectors } from "./detectors/index.js";
|
|
4
|
+
import { scanRepository } from "./engine.js";
|
|
5
|
+
import { createMigrationPacket } from "./migration-packet.js";
|
|
6
|
+
export class FindingNotObservedError extends Error {
|
|
7
|
+
constructor(findingId) {
|
|
8
|
+
super(`Finding was not observed in this MCP session: ${findingId}. Call scan_repository, explain_deprecation, or create_migration_context before editing the repository.`);
|
|
9
|
+
this.name = "FindingNotObservedError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Owns Evergreen's agent workflow behind a local, transport-independent interface.
|
|
14
|
+
* Transport adapters should translate inputs and outputs only.
|
|
15
|
+
*/
|
|
16
|
+
export class EvergreenAgentTools {
|
|
17
|
+
observed = new Map();
|
|
18
|
+
async scan(repositoryPath = ".") {
|
|
19
|
+
const result = await scanRepository(repositoryPath, builtInDetectors);
|
|
20
|
+
this.remember(result);
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
async list(repositoryPath = ".") {
|
|
24
|
+
const result = await this.scan(repositoryPath);
|
|
25
|
+
return {
|
|
26
|
+
schemaVersion: "evergreen.deprecations.v1",
|
|
27
|
+
repositoryRoot: result.root,
|
|
28
|
+
scannedAt: result.scannedAt,
|
|
29
|
+
count: result.findings.length,
|
|
30
|
+
deprecations: result.findings.map((finding) => ({
|
|
31
|
+
id: finding.id,
|
|
32
|
+
ruleId: finding.ruleId,
|
|
33
|
+
title: finding.title,
|
|
34
|
+
severity: finding.severity,
|
|
35
|
+
location: finding.location,
|
|
36
|
+
usageCount: finding.impact?.usageCount ?? finding.usages?.length ?? 0,
|
|
37
|
+
affectedFiles: finding.impact?.affectedFiles ??
|
|
38
|
+
new Set((finding.usages ?? []).map((usage) => usage.location.path)).size,
|
|
39
|
+
})),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async explain(findingId, repositoryPath = ".") {
|
|
43
|
+
const result = await this.scan(repositoryPath);
|
|
44
|
+
const finding = result.findings.find((candidate) => candidate.id === findingId);
|
|
45
|
+
if (!finding)
|
|
46
|
+
throw new Error(`Finding not found: ${findingId}`);
|
|
47
|
+
return finding;
|
|
48
|
+
}
|
|
49
|
+
async context(findingId, repositoryPath = ".") {
|
|
50
|
+
const result = await this.scan(repositoryPath);
|
|
51
|
+
return createMigrationPacket(result, findingId);
|
|
52
|
+
}
|
|
53
|
+
async verify(findingId, repositoryPath = ".") {
|
|
54
|
+
const root = resolve(repositoryPath);
|
|
55
|
+
const observed = this.observed.get(root)?.get(findingId);
|
|
56
|
+
if (!observed)
|
|
57
|
+
throw new FindingNotObservedError(findingId);
|
|
58
|
+
const result = await scanRepository(root, builtInDetectors);
|
|
59
|
+
const remainingFindings = result.findings.filter((finding) => finding.ruleId === observed.ruleId && finding.location.path === observed.location.path);
|
|
60
|
+
this.remember(result);
|
|
61
|
+
const verified = remainingFindings.length === 0;
|
|
62
|
+
const suggestedCommands = [
|
|
63
|
+
...(observed.migration?.verification ?? []),
|
|
64
|
+
{
|
|
65
|
+
command: "evergreen scan . --json",
|
|
66
|
+
purpose: "Confirm the lifecycle finding no longer appears.",
|
|
67
|
+
},
|
|
68
|
+
].filter((command, index, commands) => commands.findIndex((candidate) => candidate.command === command.command) === index);
|
|
69
|
+
return {
|
|
70
|
+
schemaVersion: "evergreen.verification.v1",
|
|
71
|
+
repositoryRoot: result.root,
|
|
72
|
+
findingId,
|
|
73
|
+
verifiedAt: result.scannedAt,
|
|
74
|
+
verified,
|
|
75
|
+
commandsExecuted: false,
|
|
76
|
+
summary: verified
|
|
77
|
+
? "The previously observed deprecation is absent from a fresh local scan."
|
|
78
|
+
: `A fresh local scan still reports ${remainingFindings.length} matching deprecation${remainingFindings.length === 1 ? "" : "s"}.`,
|
|
79
|
+
remainingFindings,
|
|
80
|
+
suggestedCommands,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
remember(result) {
|
|
84
|
+
const findings = this.observed.get(result.root) ?? new Map();
|
|
85
|
+
for (const finding of result.findings) {
|
|
86
|
+
const previous = findings.get(finding.id);
|
|
87
|
+
if (!previous || findingFingerprint(previous) !== findingFingerprint(finding)) {
|
|
88
|
+
findings.set(finding.id, finding);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
this.observed.set(result.root, findings);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=agent-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tools.js","sourceRoot":"","sources":["../../src/agent-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAiC9D,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,SAAiB;QAC3B,KAAK,CACH,iDAAiD,SAAS,yGAAyG,CACpK,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IACb,QAAQ,GAAG,IAAI,GAAG,EAAgC,CAAC;IAEpE,KAAK,CAAC,IAAI,CAAC,cAAc,GAAG,GAAG;QAC7B,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;QACtE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,cAAc,GAAG,GAAG;QAC7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC/C,OAAO;YACL,aAAa,EAAE,2BAA2B;YAC1C,cAAc,EAAE,MAAM,CAAC,IAAI;YAC3B,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;YAC7B,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,G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gBACf,CAAC,CAAC,wEAAwE;gBAC1E,CAAC,CAAC,oCAAoC,iBAAiB,CAAC,MAAM,wBAAwB,iBAAiB,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG;YACpI,iBAAiB;YACjB,iBAAiB;SAClB,CAAC;IACJ,CAAC;IAEO,QAAQ,CAAC,MAAkB;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,EAAmB,CAAC;QAC9E,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACtC,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAC1C,IAAI,CAAC,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,CAAC,KAAK,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC9E,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Finding, ScanResult } from "./domain.js";
|
|
2
|
+
export interface BaselineEntry {
|
|
3
|
+
fingerprint: string;
|
|
4
|
+
ruleId: string;
|
|
5
|
+
path: string;
|
|
6
|
+
}
|
|
7
|
+
export interface Baseline {
|
|
8
|
+
schemaVersion: "evergreen.baseline.v1";
|
|
9
|
+
createdAt: string;
|
|
10
|
+
findings: BaselineEntry[];
|
|
11
|
+
}
|
|
12
|
+
export declare function findingFingerprint(finding: Finding): string;
|
|
13
|
+
export declare function createBaseline(result: ScanResult): Baseline;
|
|
14
|
+
export declare function writeBaseline(path: string, baseline: Baseline): Promise<void>;
|
|
15
|
+
export declare function readBaseline(path: string): Promise<Baseline>;
|
|
16
|
+
export declare function applyBaseline(result: ScanResult, baseline: Baseline): ScanResult;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
export function findingFingerprint(finding) {
|
|
4
|
+
const usages = finding.usages
|
|
5
|
+
?.map((usage) => [usage.kind, usage.location.path, usage.symbol])
|
|
6
|
+
.sort((left, right) => JSON.stringify(left).localeCompare(JSON.stringify(right)));
|
|
7
|
+
return createHash("sha256")
|
|
8
|
+
.update(JSON.stringify([
|
|
9
|
+
finding.ruleId,
|
|
10
|
+
finding.location.path,
|
|
11
|
+
finding.summary,
|
|
12
|
+
...(usages && usages.length > 0 ? [usages] : []),
|
|
13
|
+
]))
|
|
14
|
+
.digest("hex");
|
|
15
|
+
}
|
|
16
|
+
export function createBaseline(result) {
|
|
17
|
+
return {
|
|
18
|
+
schemaVersion: "evergreen.baseline.v1",
|
|
19
|
+
createdAt: new Date().toISOString(),
|
|
20
|
+
findings: result.findings.map((finding) => ({
|
|
21
|
+
fingerprint: findingFingerprint(finding),
|
|
22
|
+
ruleId: finding.ruleId,
|
|
23
|
+
path: finding.location.path,
|
|
24
|
+
})),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export async function writeBaseline(path, baseline) {
|
|
28
|
+
await writeFile(path, `${JSON.stringify(baseline, null, 2)}\n`, "utf8");
|
|
29
|
+
}
|
|
30
|
+
export async function readBaseline(path) {
|
|
31
|
+
const baseline = JSON.parse(await readFile(path, "utf8"));
|
|
32
|
+
if (baseline.schemaVersion !== "evergreen.baseline.v1" || !Array.isArray(baseline.findings)) {
|
|
33
|
+
throw new Error(`Unsupported Evergreen baseline: ${path}`);
|
|
34
|
+
}
|
|
35
|
+
return baseline;
|
|
36
|
+
}
|
|
37
|
+
export function applyBaseline(result, baseline) {
|
|
38
|
+
const suppressed = new Set(baseline.findings.map((entry) => entry.fingerprint));
|
|
39
|
+
const findings = result.findings.filter((finding) => !suppressed.has(findingFingerprint(finding)));
|
|
40
|
+
const suppressedCount = result.findings.length - findings.length;
|
|
41
|
+
return {
|
|
42
|
+
...result,
|
|
43
|
+
findings,
|
|
44
|
+
diagnostics: [
|
|
45
|
+
...result.diagnostics,
|
|
46
|
+
`Suppressed ${suppressedCount} finding${suppressedCount === 1 ? "" : "s"} from the baseline.`,
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=baseline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseline.js","sourceRoot":"","sources":["../../src/baseline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAgBvD,MAAM,UAAU,kBAAkB,CAAC,OAAgB;IACjD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM;QAC3B,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;SAChE,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACpF,OAAO,UAAU,CAAC,QAAQ,CAAC;SACxB,MAAM,CACL,IAAI,CAAC,SAAS,CAAC;QACb,OAAO,CAAC,MAAM;QACd,OAAO,CAAC,QAAQ,CAAC,IAAI;QACrB,OAAO,CAAC,OAAO;QACf,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM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