@cognium/mcp-server 0.8.0 → 0.9.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 +231 -0
- package/README.md +169 -12
- package/dist/bin.js +32 -3
- package/dist/bin.js.map +1 -1
- package/dist/deps/resolve.d.ts +70 -0
- package/dist/deps/resolve.d.ts.map +1 -0
- package/dist/deps/resolve.js +256 -0
- package/dist/deps/resolve.js.map +1 -0
- package/dist/deps/snapshot.d.ts +42 -0
- package/dist/deps/snapshot.d.ts.map +1 -0
- package/dist/deps/snapshot.js +104 -0
- package/dist/deps/snapshot.js.map +1 -0
- package/dist/deps/tycho-target.d.ts +31 -0
- package/dist/deps/tycho-target.d.ts.map +1 -0
- package/dist/deps/tycho-target.js +62 -0
- package/dist/deps/tycho-target.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/modules.d.ts +14 -2
- package/dist/modules.d.ts.map +1 -1
- package/dist/modules.js +11 -3
- package/dist/modules.js.map +1 -1
- package/dist/roots.d.ts +146 -0
- package/dist/roots.d.ts.map +1 -0
- package/dist/roots.js +354 -0
- package/dist/roots.js.map +1 -0
- package/dist/server.d.ts +38 -4
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +131 -7
- package/dist/server.js.map +1 -1
- package/dist/startup.d.ts.map +1 -1
- package/dist/startup.js +3 -4
- package/dist/startup.js.map +1 -1
- package/dist/status.d.ts +43 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +54 -0
- package/dist/status.js.map +1 -0
- package/dist/tools/analyze-dependencies.d.ts +377 -0
- package/dist/tools/analyze-dependencies.d.ts.map +1 -0
- package/dist/tools/analyze-dependencies.js +387 -0
- package/dist/tools/analyze-dependencies.js.map +1 -0
- package/dist/tools/attack-surface-summary.d.ts +11 -0
- package/dist/tools/attack-surface-summary.d.ts.map +1 -1
- package/dist/tools/attack-surface-summary.js +2 -0
- package/dist/tools/attack-surface-summary.js.map +1 -1
- package/dist/tools/check-sanitizer.d.ts +10 -0
- package/dist/tools/check-sanitizer.d.ts.map +1 -1
- package/dist/tools/check-sanitizer.js +2 -0
- package/dist/tools/check-sanitizer.js.map +1 -1
- package/dist/tools/dependency-calls.d.ts +4 -4
- package/dist/tools/dependency-calls.d.ts.map +1 -1
- package/dist/tools/dependency-calls.js +6 -6
- package/dist/tools/dependency-calls.js.map +1 -1
- package/dist/tools/describe-sink.d.ts +14 -0
- package/dist/tools/describe-sink.d.ts.map +1 -1
- package/dist/tools/describe-sink.js +2 -0
- package/dist/tools/describe-sink.js.map +1 -1
- package/dist/tools/describe-source.d.ts +8 -0
- package/dist/tools/describe-source.d.ts.map +1 -1
- package/dist/tools/describe-source.js +2 -0
- package/dist/tools/describe-source.js.map +1 -1
- package/dist/tools/explain-finding.d.ts +5 -0
- package/dist/tools/explain-finding.d.ts.map +1 -1
- package/dist/tools/explain-finding.js +2 -0
- package/dist/tools/explain-finding.js.map +1 -1
- package/dist/tools/find-similar.d.ts +10 -0
- package/dist/tools/find-similar.d.ts.map +1 -1
- package/dist/tools/find-similar.js +2 -0
- package/dist/tools/find-similar.js.map +1 -1
- package/dist/tools/graph-facts.d.ts +829 -0
- package/dist/tools/graph-facts.d.ts.map +1 -0
- package/dist/tools/graph-facts.js +735 -0
- package/dist/tools/graph-facts.js.map +1 -0
- package/dist/tools/list-entry-points.d.ts +11 -0
- package/dist/tools/list-entry-points.d.ts.map +1 -1
- package/dist/tools/list-entry-points.js +2 -0
- package/dist/tools/list-entry-points.js.map +1 -1
- package/dist/tools/list-reachable-sinks.d.ts +11 -0
- package/dist/tools/list-reachable-sinks.d.ts.map +1 -1
- package/dist/tools/list-reachable-sinks.js +2 -0
- package/dist/tools/list-reachable-sinks.js.map +1 -1
- package/dist/tools/navigation.d.ts +22 -0
- package/dist/tools/navigation.d.ts.map +1 -1
- package/dist/tools/navigation.js +3 -0
- package/dist/tools/navigation.js.map +1 -1
- package/dist/tools/output-shapes.d.ts +159 -0
- package/dist/tools/output-shapes.d.ts.map +1 -0
- package/dist/tools/output-shapes.js +153 -0
- package/dist/tools/output-shapes.js.map +1 -0
- package/dist/tools/refresh.d.ts +7 -0
- package/dist/tools/refresh.d.ts.map +1 -1
- package/dist/tools/refresh.js +2 -0
- package/dist/tools/refresh.js.map +1 -1
- package/dist/tools/scan.d.ts +18 -0
- package/dist/tools/scan.d.ts.map +1 -1
- package/dist/tools/scan.js +2 -0
- package/dist/tools/scan.js.map +1 -1
- package/dist/tools/taint-paths.d.ts +10 -0
- package/dist/tools/taint-paths.d.ts.map +1 -1
- package/dist/tools/taint-paths.js +2 -0
- package/dist/tools/taint-paths.js.map +1 -1
- package/dist/tools/types.d.ts +17 -5
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +9 -0
- package/dist/tools/types.js.map +1 -1
- package/package.json +7 -10
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,237 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.9.0] - 2026-11-08
|
|
10
|
+
|
|
11
|
+
Tested against `circle-ir` **4.20.0** (was 4.18.1; 4.19.0 is skipped). The
|
|
12
|
+
optional module to pair it with is `circle-ir-ai` **4.31.0**, built on 4.20.0
|
|
13
|
+
(the release train: `npm run check:train`). A minor: three new tools
|
|
14
|
+
(`analyze_dependencies`, `find_dead_code`, `removal_reach`), an `outputSchema`
|
|
15
|
+
and `structuredContent` on every tool, and path confinement by default (a
|
|
16
|
+
changed default, see Security). 4.20.0 still carries the advisory matcher,
|
|
17
|
+
Maven version order and declared-version reader that `analyze_dependencies`
|
|
18
|
+
uses.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- **`circle-ir` pin 4.18.1 → 4.20.0** (exact). The engine's public API change is
|
|
23
|
+
additive. Answers change with it: circle-ir 4.19.0 and 4.20.0 clear many
|
|
24
|
+
false-positive classes and add true positives (circle-ir CHANGELOG), Java
|
|
25
|
+
dead code is narrower (cognium-dev #1092, #1093), and `fileTimeoutMs` is now
|
|
26
|
+
checked after each extraction phase (#1007), so a file that used to finish
|
|
27
|
+
can time out. `@cognium/code-facts` 0.1.0 needs `circle-ir` `>=4.18.0`, so a
|
|
28
|
+
single `circle-ir` is still installed. circle-ir 4.20.0 also declares an
|
|
29
|
+
optional dependency, `apache-arrow` 21.1.0, so a default install now pulls it
|
|
30
|
+
and its dependencies too; `npm install --omit=optional` leaves it out.
|
|
31
|
+
- **Optional peer `circle-ir-ai` `>=4.30.0` → `>=4.31.0`.** A module built on
|
|
32
|
+
another `circle-ir` minor is refused at load, so circle-ir-ai 4.30.0 (on
|
|
33
|
+
4.18.1) would silently drop the module's tools. **Upgrade circle-ir-ai to
|
|
34
|
+
4.31.0 together with the server.**
|
|
35
|
+
|
|
36
|
+
### Security
|
|
37
|
+
|
|
38
|
+
- **Every path argument is confined to allowed roots, by default** (#37).
|
|
39
|
+
Before, every path-taking tool read any absolute directory on the host and
|
|
40
|
+
followed a symlink out of a project; mounted over HTTP with
|
|
41
|
+
`createHandler()`, a token holder could read text from any directory on the
|
|
42
|
+
server's host. Now every path argument of every tool, floor and module, is
|
|
43
|
+
checked before the tool runs: a `..` segment is refused, a Windows-style path
|
|
44
|
+
on a POSIX host (a UNC path on Windows) is refused, and everything else is
|
|
45
|
+
resolved with `realpath` and refused outside the roots, so a symlink cannot
|
|
46
|
+
escape. The roots are the client's MCP roots and `allowedRoots` (on
|
|
47
|
+
`buildServer`, `createServer`, `createHandler`), else
|
|
48
|
+
`COGNIUM_MCP_ALLOWED_ROOTS` — never the working directory (next entry).
|
|
49
|
+
`'*'` as either is the explicit opt-out. `ToolContext.allowedRoots` carries
|
|
50
|
+
the real roots to modules.
|
|
51
|
+
|
|
52
|
+
**This changes a default.** A call that used to read a directory outside the
|
|
53
|
+
allowed roots is now refused with `isError` and one line naming
|
|
54
|
+
`COGNIUM_MCP_ALLOWED_ROOTS`. `buildServer()` with no options is confined
|
|
55
|
+
too; it used to be unconfined. `dependency_calls` no longer reads
|
|
56
|
+
`~/.m2/repository` unless that is inside a root (its `note` says so). Clients
|
|
57
|
+
that send no MCP roots, such as those that start servers in `/` (Claude
|
|
58
|
+
Desktop on macOS), must set `COGNIUM_MCP_ALLOWED_ROOTS`.
|
|
59
|
+
|
|
60
|
+
- **Every file read is confined, there is no implicit root, and the client's
|
|
61
|
+
MCP roots are honoured** (S5). The confinement above had gaps before it
|
|
62
|
+
shipped. `analyze_dependencies`' `resolved[].applies_to` was not checked, so
|
|
63
|
+
the tool read build files (`pom.xml`, `effective-pom.xml`, Gradle lockfiles,
|
|
64
|
+
`dependency-*.txt`) in any directory on the host. Files the tool finds on its
|
|
65
|
+
own inside a tree (those, advisory records and the default `advisory_db`)
|
|
66
|
+
were read through symlinks that led out of it. With no root configured, the
|
|
67
|
+
server fell back to the working directory, which some clients set to `/` or
|
|
68
|
+
`$HOME`, so it confined nothing. And the client's MCP `roots` were ignored.
|
|
69
|
+
Now:
|
|
70
|
+
|
|
71
|
+
- **Every file read stays inside the roots.** `applies_to` is checked like
|
|
72
|
+
every other path argument and must lie inside its own tree. A nested
|
|
73
|
+
relative path is checked against every tree of the call, so a
|
|
74
|
+
baseline-side `resolved[].path` is checked against `baseline_root` too. A
|
|
75
|
+
file a tool finds inside a tree is read only when its real path is still
|
|
76
|
+
inside that tree; one that is a symlink out reads as no file.
|
|
77
|
+
- **The allowed roots are the client's MCP roots** when it declares the
|
|
78
|
+
`roots` capability. They are asked for on every call: `roots/list` on a
|
|
79
|
+
2025-era connection; on the 2026-07-28 revision, an `input_required`
|
|
80
|
+
result whose `inputRequests["cognium/roots"]` is a `roots/list` request.
|
|
81
|
+
Where roots are also configured (`allowedRoots`, else
|
|
82
|
+
`COGNIUM_MCP_ALLOWED_ROOTS`), the client's roots only narrow them, to the
|
|
83
|
+
part inside both. Client roots never widen configured roots. Over HTTP
|
|
84
|
+
(`createHandler()`) they never stand in for them, because a remote
|
|
85
|
+
client's roots name its own machine's directories.
|
|
86
|
+
- **No implicit root.** With no configured root and no client roots, every
|
|
87
|
+
path-taking tool refuses with one line naming `COGNIUM_MCP_ALLOWED_ROOTS`,
|
|
88
|
+
whatever directory the server was started in. A client that declares
|
|
89
|
+
`roots` but fails `roots/list` gets the configured roots, or that refusal.
|
|
90
|
+
- New option `clientRoots: 'narrow' | 'establish'` on `buildServer`,
|
|
91
|
+
`createServer` and `createHandler`. The default is `'narrow'`; the stdio
|
|
92
|
+
binary uses `'establish'`, where the client's roots are the roots by
|
|
93
|
+
themselves. `ToolContext.allowedRoots` is the roots of the call in
|
|
94
|
+
progress, and is `undefined` only when that call is unconfined.
|
|
95
|
+
`resolveAllowedRoots()` takes no working directory and returns
|
|
96
|
+
`undefined` when nothing is configured. `rootPathsFromList()` and
|
|
97
|
+
`effectiveGuard()` are exported.
|
|
98
|
+
|
|
99
|
+
**Consumer Impact.**
|
|
100
|
+
- A client that sends no MCP roots, run without
|
|
101
|
+
`COGNIUM_MCP_ALLOWED_ROOTS`, now gets `isError` from every path-taking
|
|
102
|
+
tool. Before this change, those tools read the working directory. Set
|
|
103
|
+
the variable in the client's `env`.
|
|
104
|
+
- On a tree where a build file, lockfile, `dependency-*.txt`,
|
|
105
|
+
`effective-pom.xml` or advisory record is a symlink that leads out of the
|
|
106
|
+
tree, `analyze_dependencies` answers as if that file were absent. Before
|
|
107
|
+
this change, it read the file. The answer has fewer `dependencies[]` and
|
|
108
|
+
`matches[]`, and a `resolution[]` row comes from the next input in order.
|
|
109
|
+
An `applies_to` outside its tree, or a default `advisory_db` that is a
|
|
110
|
+
symlink out of the tree, is now an error.
|
|
111
|
+
- A module that reads `ctx.allowedRoots` while registering gets the
|
|
112
|
+
configured roots, not those of a call. Read it at call time.
|
|
113
|
+
|
|
114
|
+
### Added
|
|
115
|
+
|
|
116
|
+
- **`analyze_dependencies` reads Eclipse/Tycho target platforms** (`*.target`).
|
|
117
|
+
On a Tycho build the third-party versions are `<location type="Maven">`
|
|
118
|
+
entries of a target definition, not pom `<dependency>` rows, so a tree such
|
|
119
|
+
as iDempiere's `org.idempiere.p2.targetplatform` resolved to no third-party
|
|
120
|
+
coordinate and matched no advisory. Every `*.target` file with a Maven
|
|
121
|
+
location is now a manifest of its own in `resolution[]` (`kind: "declared"`,
|
|
122
|
+
`transitive: false`); its coordinates (flat and `<dependencies>` forms) carry
|
|
123
|
+
`declared.origin: "target-location"` with the target file as `file`. Comments
|
|
124
|
+
and CDATA are ignored, other location types are skipped, and a `${…}`
|
|
125
|
+
version is `unknown` (counted in `unresolved`, never matched). The rules are
|
|
126
|
+
circle-ir's `parseTychoTargetDependencies` (cognium-dev #1077), read here
|
|
127
|
+
until a released `circle-ir` exports it.
|
|
128
|
+
|
|
129
|
+
**Consumer Impact.** On a tree with `*.target` files, `resolution[]` gains
|
|
130
|
+
one row per target file, `dependencies[]` and `matches[]` gain the target's
|
|
131
|
+
coordinates, and `declared.origin` takes the new value `"target-location"`.
|
|
132
|
+
A consumer that lists the known `origin` values should add it. Trees without
|
|
133
|
+
a `*.target` file answer as before, byte for byte.
|
|
134
|
+
|
|
135
|
+
- **`analyze_dependencies`**, a new built-in tool (deterministic, offline,
|
|
136
|
+
read-only, closed-world, with an `outputSchema`). Resolves a Java project's
|
|
137
|
+
manifests (Maven, Gradle) to their dependency sets — from a Gradle lockfile
|
|
138
|
+
or Maven `dependency:tree` / `dependency:list` output when present, else the
|
|
139
|
+
build file — and matches them against an OSV advisory snapshot the caller
|
|
140
|
+
supplies (default `<project_root>/.cognium/advisory/osv-maven`). With
|
|
141
|
+
`baseline_root`, adds the advisories a change removed, added and left, and
|
|
142
|
+
the dependency drift. The snapshot is indexed once per content (digest) per
|
|
143
|
+
process. Its path arguments (`project_root`, `baseline_root`, `advisory_db`,
|
|
144
|
+
`resolved[].path`, `resolved[].applies_to`) are confined to the allowed roots
|
|
145
|
+
like every other tool's, and so is every file it finds in a tree (S5).
|
|
146
|
+
Fifteen built-in tools.
|
|
147
|
+
|
|
148
|
+
- **Every tool declares an `outputSchema` and returns `structuredContent`**
|
|
149
|
+
(#38). `dependency_calls`, `analyze_dependencies`, `find_dead_code` and
|
|
150
|
+
`removal_reach` already did; the other thirteen now do too (`src/tools/output-shapes.ts`). `textResult` builds
|
|
151
|
+
`structuredContent` by parsing the JSON text it just wrote, so the two are
|
|
152
|
+
the same object and a field left `undefined` is absent from both. The schemas pin each tool's
|
|
153
|
+
top-level envelope and leave nested engine objects open. Error results are
|
|
154
|
+
unchanged: text only, `isError: true`.
|
|
155
|
+
|
|
156
|
+
**A minor, not a major.** No tool's `inputSchema` changed and the text
|
|
157
|
+
result is byte-identical; a client that ignores `outputSchema` sees only the
|
|
158
|
+
new `structuredContent` field. The install check counts a first
|
|
159
|
+
`outputSchema` on a tool that had none as an addition (#47). The install
|
|
160
|
+
check also reads `tools/list` across several stdout chunks now: with every
|
|
161
|
+
schema declared the reply is past the 64 KiB pipe buffer. From here on
|
|
162
|
+
these envelopes are API: removing or changing one is a major.
|
|
163
|
+
|
|
164
|
+
- **A refused optional module is visible to the MCP client** (#26), not only on
|
|
165
|
+
stderr. `capabilities.experimental["cognium/modules"]` lists the installed
|
|
166
|
+
`circle-ir`, the modules that loaded and the modules that were refused, each
|
|
167
|
+
refusal with its reason and, for a version-skew refusal, the `circle-ir` the
|
|
168
|
+
module was built against (`builtAgainst`) next to the one the server pins
|
|
169
|
+
(`installed`). When anything was refused, `instructions` says so in one
|
|
170
|
+
paragraph. Both are in the `initialize` result and in `server/discover`. A
|
|
171
|
+
module that throws while registering is reported the same way.
|
|
172
|
+
`buildServer()` takes `refusals`; `createServer()`, `createHandler()` and the
|
|
173
|
+
stdio binary pass the loader's. No tool or schema changed.
|
|
174
|
+
|
|
175
|
+
- **`find_dead_code`** — per declaration, the engine's `dead-code@0.1` fact:
|
|
176
|
+
`live`, `may-be-live` (with reasons) or `dead`, the shortest strong and weak
|
|
177
|
+
paths from an entry, unresolved sites, `partialFiles`, and `reachedByTest`.
|
|
178
|
+
Inputs `project_root`, `language`, `root_kinds[]`, `verdicts[]`, `limit`.
|
|
179
|
+
- **`removal_reach`** — for two checked-out trees (`project_root` = head,
|
|
180
|
+
`baseline_root` = base), every removed declaration with what reached it at
|
|
181
|
+
the base (`removal-reach@0.1`); moves and renames listed apart in `moved[]`;
|
|
182
|
+
`partial[]` and `partialFiles` for files that did not parse at either pin.
|
|
183
|
+
- Both build the engine's graph for **TypeScript / JavaScript, Java, Python or
|
|
184
|
+
Go** (`buildTsCallGraph`, `buildJavaGraph`, `buildPythonGraph`,
|
|
185
|
+
`buildGoGraph`), in one output shape. `language` picks the graph; by default
|
|
186
|
+
the only family present is used, and a tree holding more than one is asked
|
|
187
|
+
to say which (C4 0.4.0).
|
|
188
|
+
- Both apply **the rule `no-inferred-edge-decides@0.1`**. Each fact gets a
|
|
189
|
+
`decision`, and an inferred edge neither proves code live nor proves it
|
|
190
|
+
dead:
|
|
191
|
+
- `reachable` on a strong path;
|
|
192
|
+
- `unreachable` only with no path of any kind from a non-empty root set,
|
|
193
|
+
nothing unresolved and no unparsed file that could reach it;
|
|
194
|
+
- `undecided` otherwise.
|
|
195
|
+
|
|
196
|
+
`because` lists the facts the outcome rests on. `removal_reach` also leaves
|
|
197
|
+
a removal `undecided` when its file did not parse at the head, and sums the
|
|
198
|
+
change up in `decisions.allUnreachable`: `true`, `false` or `null`.
|
|
199
|
+
- Both return the evidence the decisions are read against. `entrySet` holds
|
|
200
|
+
the roots used: kinds, certainty, places and a digest. `scope` holds the
|
|
201
|
+
files read and the directories skipped.
|
|
202
|
+
- Both validate their input and answer with one line and `isError` for:
|
|
203
|
+
- an empty `root_kinds` or `verdicts`;
|
|
204
|
+
- a language with no files under a root;
|
|
205
|
+
- overlapping or identical roots (`removal_reach`);
|
|
206
|
+
- a tree of 50,000 files or more.
|
|
207
|
+
- Both carry `engine: { package: "circle-ir", version }`, because the engine's
|
|
208
|
+
schemes do not name the version that computed them. Every field the engine
|
|
209
|
+
returns is passed through unchanged; the envelope, `decision`, `entrySet`,
|
|
210
|
+
`scope`, `decisions` and truncation are the server's. Both declare an
|
|
211
|
+
`outputSchema` and return `structuredContent`; both are read-only and local.
|
|
212
|
+
The `META-INF/services` walk does not follow symlinks.
|
|
213
|
+
|
|
214
|
+
## [0.8.1] - 2026-11-01
|
|
215
|
+
|
|
216
|
+
Tested against `circle-ir` **4.18.1** (was 4.16.1). The optional module to pair
|
|
217
|
+
it with is `circle-ir-ai` **4.30.0**, built on `4.18.1` (the release train:
|
|
218
|
+
`npm run check:train`). A patch: no tool added, removed or renamed, and no
|
|
219
|
+
schema changed.
|
|
220
|
+
|
|
221
|
+
### Changed
|
|
222
|
+
|
|
223
|
+
- **`circle-ir` pin 4.16.1 → 4.18.1** (exact). 4.18.1 carries
|
|
224
|
+
`dependencyCalls`, the engine `dependency_calls` reads, and the OWASP
|
|
225
|
+
Benchmark gains of cognium-dev #1041.
|
|
226
|
+
- **`@cognium/code-facts` 0.1.0 is an exact dependency**, no longer an optional
|
|
227
|
+
peer. It needs `circle-ir` `>=4.18.0`, which the new pin meets, so a single
|
|
228
|
+
`circle-ir` is installed. `dependency_calls` now works out of the box.
|
|
229
|
+
- **Optional peer `circle-ir-ai` `>=4.17.0` → `>=4.30.0`.** A module built on
|
|
230
|
+
another `circle-ir` minor is refused at load, so circle-ir-ai before 4.30.0
|
|
231
|
+
(on 4.16.1 or older) would silently drop the module's tools. **Upgrade
|
|
232
|
+
circle-ir-ai to 4.30.0 together with the server**: npm upgrades a caret-ranged
|
|
233
|
+
circle-ir-ai to 4.30.0, and refuses an exact older pin with `ERESOLVE`.
|
|
234
|
+
|
|
235
|
+
### Fixed
|
|
236
|
+
|
|
237
|
+
- `dependency_calls`' refusal no longer says code-facts is unpublished, and the
|
|
238
|
+
README's tool count says fourteen built-in tools, not eleven.
|
|
239
|
+
|
|
9
240
|
## [0.8.0] - 2026-10-31
|
|
10
241
|
|
|
11
242
|
Tested against `circle-ir` **4.16.1** (unchanged). The optional module to pair
|
package/README.md
CHANGED
|
@@ -78,9 +78,39 @@ The same stdio config is bundled in the [Cognium SAST plugin](../../plugins/cogn
|
|
|
78
78
|
| `find_similar` | Given a finding id, return other findings sharing the same `rule_id` and/or `sink_type`. |
|
|
79
79
|
| `find_callers` | Who calls a method, with a resolution tier on every answer and a reason on every site it could not resolve. Java. |
|
|
80
80
|
| `find_callees` | What a method calls, with the same tiers and reasons. Java. |
|
|
81
|
-
| `dependency_calls` | For a Maven dependency bump: every call into the artifact, the tests that reach each one, and the sites that cannot be ruled in or out. Java.
|
|
81
|
+
| `dependency_calls` | For a Maven dependency bump: every call into the artifact, the tests that reach each one, and the sites that cannot be ruled in or out. Java. Computed by `@cognium/code-facts` 0.1.0, installed with the server. |
|
|
82
|
+
| `find_dead_code` | Per declaration, the engine's `dead-code@0.1` fact (`live`, `may-be-live` with reasons, or `dead`, with the paths from an entry and the first test that reaches it), and a `decision` under the rule "no inferred edge decides", against the roots listed in `entrySet`. TypeScript, JavaScript, Java, Python, Go. |
|
|
83
|
+
| `removal_reach` | For two checked-out trees, every removed declaration with what reached it at the base (`removal-reach@0.1`; moves and renames listed apart), each with the same `decision`, and `allUnreachable` over the change. TypeScript, JavaScript, Java, Python, Go. |
|
|
84
|
+
| `analyze_dependencies` | Known advisories in a Java project's resolved dependencies (Maven, Gradle), matched against an OSV advisory snapshot you supply; with `baseline_root`, what a change removed and added. See below. |
|
|
82
85
|
| `refresh` | Manually invalidate the cache for one project or every project. |
|
|
83
86
|
|
|
87
|
+
### `analyze_dependencies`
|
|
88
|
+
|
|
89
|
+
Resolves each manifest directory to its dependency set from the best input
|
|
90
|
+
present, and says which: a caller-named file (`resolved`), `gradle.lockfile`,
|
|
91
|
+
the `dependency-tree.txt` / `dependency-list.txt` a build writes
|
|
92
|
+
(`mvn dependency:tree -DoutputFile=dependency-tree.txt`), or else the build
|
|
93
|
+
file itself (`kind: "declared"`, direct dependencies only). It then matches
|
|
94
|
+
every coordinate against the advisory snapshot at `advisory_db` — a directory
|
|
95
|
+
of OSV records, as `unzip Maven/all.zip` from OSV.dev leaves it; default
|
|
96
|
+
`<project_root>/.cognium/advisory/osv-maven`.
|
|
97
|
+
|
|
98
|
+
It never downloads a snapshot and never runs a build: the answer depends only
|
|
99
|
+
on the tree, the snapshot and this version, and carries the snapshot's
|
|
100
|
+
`digest` and `snapshotDate` (the newest record in it) so the caller can pin
|
|
101
|
+
both. Each match gives the advisory id and aliases (CVE), the affected ranges,
|
|
102
|
+
the later fixed versions, the record's own severity fields (copied, never
|
|
103
|
+
ranked), the dependency's path from a direct dependency, and the version the
|
|
104
|
+
POMs declare for it with where that comes from (`direct`, `property`,
|
|
105
|
+
`dependencyManagement`, a parent's, a BOM, an external parent). Withdrawn
|
|
106
|
+
records are listed by id and never matched. Test-only dependencies are left
|
|
107
|
+
out unless `include_dev` is true.
|
|
108
|
+
|
|
109
|
+
With `baseline_root` (the same project at an earlier commit), the answer adds
|
|
110
|
+
`delta` — advisories `removed`, `added` and `persisting`, each with the
|
|
111
|
+
versions seen on both sides, and the dependency drift — and the baseline's
|
|
112
|
+
`resolution`, both under the one snapshot.
|
|
113
|
+
|
|
84
114
|
## Resources
|
|
85
115
|
|
|
86
116
|
| URI | Content |
|
|
@@ -127,13 +157,50 @@ tests reaching each (covered when `tests[0].class` is `strong`), `covered`,
|
|
|
127
157
|
`uncovered`, `unattributedSites[]` and `partial[]`, plus `engine`, `facts`,
|
|
128
158
|
`counts` and truncation. The contract is C4 0.5.0 §11c.
|
|
129
159
|
|
|
130
|
-
It is computed by `@cognium/code-facts
|
|
131
|
-
`circle-ir`
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
160
|
+
It is computed by `@cognium/code-facts` 0.1.0, an exact dependency of the
|
|
161
|
+
server since 0.8.1, on the same `circle-ir` (4.20.0) the server pins, so one
|
|
162
|
+
`circle-ir` is installed. If the package cannot be loaded, the tool answers
|
|
163
|
+
with one line saying so, and every other tool keeps serving.
|
|
164
|
+
|
|
165
|
+
## Dead code and removals
|
|
166
|
+
|
|
167
|
+
`find_dead_code` takes `project_root`; `removal_reach` takes `project_root`
|
|
168
|
+
(the head) and `baseline_root` (the base), two separate checkouts. Both take
|
|
169
|
+
`language` (`typescript` · `javascript` · `java` · `python` · `go`; by default
|
|
170
|
+
the one family present), `root_kinds` (default every entry kind except `test`)
|
|
171
|
+
and `limit`. The engine's answer is passed through unchanged; the contract is
|
|
172
|
+
C4 0.3.0 §11, with `language` from 0.4.0.
|
|
173
|
+
|
|
174
|
+
Each declaration also carries a `decision` under one rule,
|
|
175
|
+
`no-inferred-edge-decides@0.1`. An inferred edge neither proves code live nor
|
|
176
|
+
proves it dead:
|
|
177
|
+
|
|
178
|
+
| `decision.outcome` | When | `because` |
|
|
179
|
+
| ---- | ---- | ---- |
|
|
180
|
+
| `reachable` | a strong path: from a `declared` or `conventional` entry over `exact` or `polymorphic` calls | `strong-path` |
|
|
181
|
+
| `unreachable` | no path of any kind from any root, no unresolved site that could bind to it, no unparsed file that could reach it | all four of `no-strong-path`, `no-weak-path`, `no-unresolved-site`, `no-partial-file` |
|
|
182
|
+
| `undecided` | anything else: a person decides | any of `inferred-entry`, `inferred-call`, `reference`, `unresolved-site`, `partial-file`, `partial-at-head` (its file did not parse at the head, so it may not be removed at all), `no-entries` |
|
|
183
|
+
|
|
184
|
+
Read a decision against the evidence next to it:
|
|
185
|
+
|
|
186
|
+
- `entrySet` lists the roots the walk started from: their kinds, their
|
|
187
|
+
certainty, where they are, and a digest.
|
|
188
|
+
- `scope` gives how many files were read, and which directories were skipped.
|
|
189
|
+
|
|
190
|
+
With no roots, nothing is `unreachable`. `removal_reach` sums the change up in
|
|
191
|
+
`decisions.allUnreachable`:
|
|
192
|
+
|
|
193
|
+
- `true` when something was removed and every removal is `unreachable`;
|
|
194
|
+
- `false` when any removal is `reachable`;
|
|
195
|
+
- `null` otherwise.
|
|
196
|
+
|
|
197
|
+
The tools refuse these with one line:
|
|
198
|
+
|
|
199
|
+
- an empty `root_kinds`;
|
|
200
|
+
- a language with no files under a root;
|
|
201
|
+
- two roots that are the same directory or overlap;
|
|
202
|
+
- a tree of 50,000 files or more, since an answer over part of a tree could
|
|
203
|
+
call live code dead.
|
|
137
204
|
|
|
138
205
|
## Reading a navigation answer
|
|
139
206
|
|
|
@@ -234,9 +301,74 @@ await server.connect(myTransport); // serves the 2025-era protocol only
|
|
|
234
301
|
`buildServer(options)` is the synchronous form: it registers exactly what you
|
|
235
302
|
pass and resolves nothing.
|
|
236
303
|
|
|
304
|
+
## Which directories a tool may read
|
|
305
|
+
|
|
306
|
+
Every path argument of every tool — `scan.path`, every `project_root`,
|
|
307
|
+
`dependency_calls`' `jar_path` and `maven_repo_dir`, nested paths such as
|
|
308
|
+
`site.file` and `analyze_dependencies`' `resolved[].path` and
|
|
309
|
+
`resolved[].applies_to`, and the path arguments of an optional module's tools
|
|
310
|
+
— is **confined to the allowed roots** before the tool runs (0.9.0, #37, S5):
|
|
311
|
+
|
|
312
|
+
- a path with a `..` segment is refused, wherever it would land;
|
|
313
|
+
- on a POSIX host a Windows-style path (backslashes, `C:`) is refused; on
|
|
314
|
+
Windows a UNC path (`\\server\share`) is;
|
|
315
|
+
- everything else is resolved with `realpath`, so a symlink is judged by where
|
|
316
|
+
it points, and refused unless that lies inside a root. A tree argument inside
|
|
317
|
+
a root reaches the tool as its real path; a nested relative path is checked
|
|
318
|
+
against every tree of the call.
|
|
319
|
+
|
|
320
|
+
The files a tool then finds on its own inside a tree — a build file, a
|
|
321
|
+
lockfile, `dependency-tree.txt`, `effective-pom.xml`, an advisory record — are
|
|
322
|
+
read only when their real path is still inside that tree, so a symlink planted
|
|
323
|
+
in a project cannot lead a read out of it either.
|
|
324
|
+
|
|
325
|
+
**The allowed roots** are:
|
|
326
|
+
|
|
327
|
+
- **the client's MCP roots**, when the client declares the `roots` capability
|
|
328
|
+
(asked for on every call, so a folder the user opens counts from the next
|
|
329
|
+
call). On the stdio binary they are the roots by themselves; wherever roots
|
|
330
|
+
are also configured, they only narrow them — a tool may read the part of the
|
|
331
|
+
client's roots that lies inside a configured root;
|
|
332
|
+
- **the configured roots**: `allowedRoots` passed to `buildServer()`,
|
|
333
|
+
`createServer()` or `createHandler()`, else `COGNIUM_MCP_ALLOWED_ROOTS`
|
|
334
|
+
(directories separated by `:`, or `;` on Windows);
|
|
335
|
+
- **nothing else.** With no configured root and no client roots, every path is
|
|
336
|
+
refused, with one line naming `COGNIUM_MCP_ALLOWED_ROOTS`. The working
|
|
337
|
+
directory is never a root: clients start servers in `/` (Claude Desktop on
|
|
338
|
+
macOS) or in `$HOME`.
|
|
339
|
+
|
|
340
|
+
The opt-out is explicit: `allowedRoots: '*'` or `COGNIUM_MCP_ALLOWED_ROOTS=*`
|
|
341
|
+
(the client's roots, if it sends any, still narrow it). The stdio binary says
|
|
342
|
+
on stderr which applies.
|
|
343
|
+
|
|
344
|
+
A client that sends no MCP roots — or declares the capability and does not
|
|
345
|
+
answer `roots/list` — needs `COGNIUM_MCP_ALLOWED_ROOTS` in its `env`:
|
|
346
|
+
|
|
347
|
+
```json
|
|
348
|
+
"cognium": {
|
|
349
|
+
"command": "npx",
|
|
350
|
+
"args": ["-y", "@cognium/mcp-server"],
|
|
351
|
+
"env": { "COGNIUM_MCP_ALLOWED_ROOTS": "/Users/me/src" }
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
Over HTTP, a client's MCP roots name directories on the client's machine, so
|
|
356
|
+
on `createHandler()` they can only narrow the roots the host configures, never
|
|
357
|
+
stand in for them: a host that names no roots serves no path. A host that
|
|
358
|
+
connects `buildServer()` to a transport of its own gets the same rule unless it
|
|
359
|
+
passes `clientRoots: 'establish'`. On the 2026-07-28 revision, where a server
|
|
360
|
+
cannot send a request to the client, a client that declares `roots` is asked
|
|
361
|
+
for them with an `input_required` result (`inputRequests["cognium/roots"]`, a
|
|
362
|
+
`roots/list` request) and the call goes on when it retries with the answer.
|
|
363
|
+
|
|
364
|
+
`dependency_calls` reads the local Maven repository (`~/.m2/repository`) only
|
|
365
|
+
when it lies inside a root; otherwise the artifact's packages come from the
|
|
366
|
+
built-in table and the answer's `note` says so. Add the repository to
|
|
367
|
+
`COGNIUM_MCP_ALLOWED_ROOTS`, or pass `jar_path`, to have the jar read.
|
|
368
|
+
|
|
237
369
|
## Optional tool modules
|
|
238
370
|
|
|
239
|
-
The
|
|
371
|
+
The seventeen tools above are always present. A separate package may add more by
|
|
240
372
|
exporting a `ToolModule`:
|
|
241
373
|
|
|
242
374
|
```ts
|
|
@@ -249,6 +381,11 @@ export default {
|
|
|
249
381
|
// ctx.cache — the server's analysis cache, shared with every tool
|
|
250
382
|
// ctx.enablement — what this install may offer; the module decides what
|
|
251
383
|
// to register, and checks again at call time
|
|
384
|
+
// ctx.allowedRoots — the real paths tools may read in the call in
|
|
385
|
+
// progress (read it at call time: it follows the
|
|
386
|
+
// client's MCP roots). The server has already checked
|
|
387
|
+
// the tool's path arguments; hold any further path the
|
|
388
|
+
// module reads to the same roots
|
|
252
389
|
},
|
|
253
390
|
};
|
|
254
391
|
```
|
|
@@ -258,11 +395,25 @@ what is looked for, or to `none` to look for nothing.
|
|
|
258
395
|
|
|
259
396
|
**The server comes up either way.** A module that is absent, broken, wrongly
|
|
260
397
|
shaped or built against a different `circle-ir` minor is refused on one line of
|
|
261
|
-
stderr, and the
|
|
398
|
+
stderr, and the seventeen built-in tools serve as normal.
|
|
399
|
+
|
|
400
|
+
A refusal is also visible to the MCP client, on both protocol eras (the
|
|
401
|
+
`initialize` result and `server/discover`):
|
|
402
|
+
|
|
403
|
+
- `capabilities.experimental["cognium/modules"]` is always present:
|
|
404
|
+
`{ circleIr, loaded: [{ id, version, licence, circleIrRange }], refused:
|
|
405
|
+
[{ specifier, reason, id?, version?, builtAgainst?, installed? }] }`. On a
|
|
406
|
+
version-skew refusal, `builtAgainst` is the `circle-ir` the module declares
|
|
407
|
+
and `installed` the one this server pins.
|
|
408
|
+
- `instructions` carries the same facts as one paragraph when, and only when,
|
|
409
|
+
something was refused.
|
|
410
|
+
|
|
411
|
+
A module that throws while registering is reported the same way.
|
|
262
412
|
|
|
263
413
|
| Variable | Effect |
|
|
264
414
|
|---|---|
|
|
265
415
|
| `COGNIUM_MCP_MODULES` | Which module specifiers to look for. `none` disables. |
|
|
416
|
+
| `COGNIUM_MCP_ALLOWED_ROOTS` | The directories tools may read, `:`-separated (`;` on Windows), narrowed to the client's MCP roots when it sends them. Unset: only the client's MCP roots, and with none every path is refused (never the working directory). `*` turns confinement off. |
|
|
266
417
|
| `COGNIUM_ENDPOINT` | An opaque endpoint passed through to modules. The server never parses or connects to it. |
|
|
267
418
|
| `COGNIUM_LICENSE` | A licence token, verified offline. Also read from `$COGNIUM_CONFIG_DIR/license`, default `~/.cognium/license`. |
|
|
268
419
|
| `COGNIUM_LICENSE_PUBKEY` | Extra verification keys as `kid=key[,kid=key]`, base64url raw Ed25519, merged over the published ones. A bare key with no `kid=` matches any token, which is a development convenience and not for production. |
|
|
@@ -285,9 +436,15 @@ decides what is *listed*, and the terms carry the grant.
|
|
|
285
436
|
## What a response and a tool tell you
|
|
286
437
|
|
|
287
438
|
- **`provenance`** is the last field of every successful response:
|
|
288
|
-
`"deterministic"` for all
|
|
439
|
+
`"deterministic"` for all seventeen built-in tools. A tool from an optional module
|
|
289
440
|
that used a model says `llm: <model>`.
|
|
290
|
-
-
|
|
441
|
+
- **`outputSchema` and `structuredContent`.** Every built-in tool declares an
|
|
442
|
+
`outputSchema` in `tools/list`, and every successful response carries
|
|
443
|
+
`structuredContent`: the same object as the JSON in `content[0].text`. The
|
|
444
|
+
schema pins the top-level envelope; nested engine objects are open, so the
|
|
445
|
+
engine may add a field inside them in a minor. An `isError` result carries
|
|
446
|
+
text only.
|
|
447
|
+
- **Annotations** are declared on every tool in `tools/list`. Thirteen are
|
|
291
448
|
`readOnlyHint: true`; none reaches the network (`openWorldHint: false`) or
|
|
292
449
|
deletes anything (`destructiveHint: false`). `refresh` is not read-only: it
|
|
293
450
|
writes no file, but it clears the server's in-memory cache.
|
package/dist/bin.js
CHANGED
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
* cost.
|
|
16
16
|
*/
|
|
17
17
|
import { serveStdio } from '@modelcontextprotocol/server/stdio';
|
|
18
|
-
import { buildServer, discoverModules } from './server.js';
|
|
18
|
+
import { buildServer, discoverModules, SERVER_NAME } from './server.js';
|
|
19
|
+
import { parse, resolve } from 'node:path';
|
|
20
|
+
import { resolveAllowedRoots, ENV_ALLOWED_ROOTS, UNCONFINED } from './roots.js';
|
|
19
21
|
import { startupLines } from './startup.js';
|
|
20
22
|
async function main() {
|
|
21
23
|
// Modules and the licence state are resolved once, before anything is
|
|
@@ -24,12 +26,39 @@ async function main() {
|
|
|
24
26
|
for (const line of startupLines(discovery)) {
|
|
25
27
|
process.stderr.write(`${line}\n`);
|
|
26
28
|
}
|
|
29
|
+
// Tools read only under the allowed roots (issue #37, S5): the client's
|
|
30
|
+
// MCP roots, narrowed to COGNIUM_MCP_ALLOWED_ROOTS when that is set. The
|
|
31
|
+
// working directory is never a root: clients start servers in `/` or in
|
|
32
|
+
// `$HOME`. Opting out is allowed, and said out loud.
|
|
33
|
+
const roots = resolveAllowedRoots(undefined);
|
|
34
|
+
if (roots === UNCONFINED) {
|
|
35
|
+
process.stderr.write(`[${SERVER_NAME}] paths unconfined (${ENV_ALLOWED_ROOTS}=*): tools may read any directory on this host, ` +
|
|
36
|
+
"or only the client's MCP roots when it sends them\n");
|
|
37
|
+
}
|
|
38
|
+
else if (roots === undefined) {
|
|
39
|
+
process.stderr.write(`[${SERVER_NAME}] paths confined to the client's MCP roots; none are configured, ` +
|
|
40
|
+
`so a client that sends none is refused every path (set ${ENV_ALLOWED_ROOTS})\n`);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const whole = roots.some((r) => resolve(r) === parse(resolve(r)).root);
|
|
44
|
+
process.stderr.write(`[${SERVER_NAME}] paths confined to ${roots.length} allowed root${roots.length === 1 ? '' : 's'} (${ENV_ALLOWED_ROOTS})` +
|
|
45
|
+
", narrowed to the client's MCP roots when it sends them" +
|
|
46
|
+
(whole ? '; one is the filesystem root, so a client that sends no roots may read the whole disk' : '') +
|
|
47
|
+
'\n');
|
|
48
|
+
}
|
|
27
49
|
// `serveStdio` owns the transport and decides, from the client's opening
|
|
28
50
|
// message, which protocol era the connection speaks. A client that opens
|
|
29
51
|
// with `initialize` is served exactly as before; one that speaks the
|
|
30
52
|
// 2026-07-28 revision is served that. Either way it gets one server,
|
|
31
|
-
// built here, for the life of the connection.
|
|
32
|
-
|
|
53
|
+
// built here, for the life of the connection. The client on the other
|
|
54
|
+
// end of stdio is the user's own, so its MCP roots may stand in for
|
|
55
|
+
// configured ones.
|
|
56
|
+
serveStdio(() => buildServer({
|
|
57
|
+
modules: discovery.modules,
|
|
58
|
+
refusals: discovery.refusals,
|
|
59
|
+
enablement: discovery.enablement,
|
|
60
|
+
clientRoots: 'establish',
|
|
61
|
+
}));
|
|
33
62
|
}
|
|
34
63
|
main().catch((err) => {
|
|
35
64
|
// stderr is safe for stdio-transport servers (stdout is reserved for MCP
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,KAAK,UAAU,IAAI;IACjB,sEAAsE;IACtE,2DAA2D;IAC3D,MAAM,SAAS,GAAG,MAAM,eAAe,EAAE,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;IACpC,CAAC;IACD,wEAAwE;IACxE,yEAAyE;IACzE,wEAAwE;IACxE,qDAAqD;IACrD,MAAM,KAAK,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC7C,IAAI,KAAK,KAAK,UAAU,EAAE,CAAC;QACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,IAAI,WAAW,uBAAuB,iBAAiB,kDAAkD;YACvG,qDAAqD,CACxD,CAAC;IACJ,CAAC;SAAM,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,IAAI,WAAW,mEAAmE;YAChF,0DAA0D,iBAAiB,KAAK,CACnF,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,IAAI,WAAW,uBAAuB,KAAK,CAAC,MAAM,gBAAgB,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,iBAAiB,GAAG;YACtH,yDAAyD;YACzD,CAAC,KAAK,CAAC,CAAC,CAAC,uFAAuF,CAAC,CAAC,CAAC,EAAE,CAAC;YACtG,IAAI,CACP,CAAC;IACJ,CAAC;IACD,yEAAyE;IACzE,yEAAyE;IACzE,qEAAqE;IACrE,qEAAqE;IACrE,sEAAsE;IACtE,oEAAoE;IACpE,mBAAmB;IACnB,UAAU,CAAC,GAAG,EAAE,CACd,WAAW,CAAC;QACV,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,UAAU,EAAE,SAAS,CAAC,UAAU;QAChC,WAAW,EAAE,WAAW;KACzB,CAAC,CACH,CAAC;AACJ,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,yEAAyE;IACzE,aAAa;IACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAiC,GAAa,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC,CAAC;IACtF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve one source tree to its Maven-coordinate dependency set.
|
|
3
|
+
*
|
|
4
|
+
* Per directory holding a build file, the best input wins, and the answer
|
|
5
|
+
* says which one it was:
|
|
6
|
+
*
|
|
7
|
+
* 1. an explicit `resolved` input for that directory (caller-named file);
|
|
8
|
+
* 2. `gradle.lockfile`, or `gradle/dependency-locks/*.lockfile` → `lockfile`;
|
|
9
|
+
* 3. `dependency-tree.txt`, then `dependency-list.txt` written by a build
|
|
10
|
+
* run (`mvn dependency:tree|list -DoutputFile=…`) → `resolved`;
|
|
11
|
+
* 4. the build file itself (`pom.xml`, `build.gradle[.kts]`) → `declared`.
|
|
12
|
+
*
|
|
13
|
+
* Besides, every Eclipse PDE / Tycho target definition (`*.target`) with a
|
|
14
|
+
* `<location type="Maven">` is a manifest of its own, `declared`: on a Tycho
|
|
15
|
+
* build the third-party versions live there, not in pom rows (cognium-dev
|
|
16
|
+
* #1077). Its entries carry `declared.origin: "target-location"`.
|
|
17
|
+
*
|
|
18
|
+
* Nothing here runs a build or opens a connection: every input is a file
|
|
19
|
+
* already in the tree (or named by the caller). A file found in the tree is
|
|
20
|
+
* read only when its real path is still in the tree (S5): a symlinked
|
|
21
|
+
* `pom.xml`, lockfile or `effective-pom.xml` that leads out of it reads as
|
|
22
|
+
* no file, and a caller-named `applies_to` directory outside it is skipped
|
|
23
|
+
* (the tool refuses one before it gets here).
|
|
24
|
+
*/
|
|
25
|
+
import { type DeclaredVersion, type Dependency } from 'circle-ir';
|
|
26
|
+
export type ResolvedKind = 'maven-dependency-tree' | 'maven-dependency-list' | 'gradle-lockfile' | 'cyclonedx-json';
|
|
27
|
+
export interface ResolvedInput {
|
|
28
|
+
path: string;
|
|
29
|
+
kind: ResolvedKind;
|
|
30
|
+
/** The manifest directory it applies to, relative to the tree root (default: the root). */
|
|
31
|
+
applies_to?: string;
|
|
32
|
+
side?: 'head' | 'baseline';
|
|
33
|
+
}
|
|
34
|
+
export interface ResolutionEntry {
|
|
35
|
+
manifest: string;
|
|
36
|
+
kind: 'resolved' | 'lockfile' | 'declared';
|
|
37
|
+
input: string;
|
|
38
|
+
dependencies: number;
|
|
39
|
+
unresolved: number;
|
|
40
|
+
excludedDev: number;
|
|
41
|
+
transitive: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** `declared` as the tool reports it; Gradle literals are added beside the Maven origins. */
|
|
44
|
+
export type Declared = (Omit<DeclaredVersion, 'origin'> & {
|
|
45
|
+
origin: DeclaredVersion['origin'] | 'gradle-literal' | 'target-location';
|
|
46
|
+
}) | null;
|
|
47
|
+
/** One coordinate as found in one manifest. */
|
|
48
|
+
export interface ManifestDep {
|
|
49
|
+
dep: Dependency;
|
|
50
|
+
manifest: string;
|
|
51
|
+
declared: Declared;
|
|
52
|
+
}
|
|
53
|
+
export interface TreeResolution {
|
|
54
|
+
root: string;
|
|
55
|
+
resolution: ResolutionEntry[];
|
|
56
|
+
deps: ManifestDep[];
|
|
57
|
+
coverage: {
|
|
58
|
+
ecosystemsSeen: string[];
|
|
59
|
+
ecosystemsCovered: string[];
|
|
60
|
+
notCovered: string[];
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export interface ResolveOptions {
|
|
64
|
+
includeDev: boolean;
|
|
65
|
+
side: 'head' | 'baseline';
|
|
66
|
+
resolved?: ResolvedInput[];
|
|
67
|
+
}
|
|
68
|
+
/** Resolve the tree at `root`. Paths in the answer are relative to it. */
|
|
69
|
+
export declare function resolveTree(rootIn: string, opts: ResolveOptions): TreeResolution;
|
|
70
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/deps/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,EAOL,KAAK,eAAe,EACpB,KAAK,UAAU,EAEhB,MAAM,WAAW,CAAC;AAKnB,MAAM,MAAM,YAAY,GAAG,uBAAuB,GAAG,uBAAuB,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAEpH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,CAAC;IACnB,2FAA2F;IAC3F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,6FAA6F;AAC7F,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,GAAG;IAAE,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG,gBAAgB,GAAG,iBAAiB,CAAA;CAAE,CAAC,GAAG,IAAI,CAAC;AAE/I,+CAA+C;AAC/C,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,UAAU,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,IAAI,EAAE,WAAW,EAAE,CAAC;IACpB,QAAQ,EAAE;QAAE,cAAc,EAAE,MAAM,EAAE,CAAC;QAAC,iBAAiB,EAAE,MAAM,EAAE,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAC3F;AAqGD,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAC1B,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5B;AAED,0EAA0E;AAC1E,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,cAAc,CAiHhF"}
|