@knip/mcp 0.0.2 → 0.0.3
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/docs/blog/for-editors-and-agents.md +50 -35
- package/docs/docs/blog/brief-history.md +30 -0
- package/docs/docs/blog/for-editors-and-agents.md +124 -0
- package/docs/docs/blog/knip-v3.mdx +88 -0
- package/docs/docs/blog/knip-v4.mdx +149 -0
- package/docs/docs/blog/knip-v5.mdx +190 -0
- package/docs/docs/blog/migration-to-v1.md +65 -0
- package/docs/docs/blog/release-notes-v2.md +46 -0
- package/docs/docs/blog/slim-down-to-speed-up.md +269 -0
- package/docs/docs/blog/state-of-knip.md +191 -0
- package/docs/docs/blog/two-years.mdx +107 -0
- package/docs/docs/explanations/comparison-and-migration.md +129 -0
- package/docs/docs/explanations/entry-files.md +70 -0
- package/docs/docs/explanations/plugins.md +318 -0
- package/docs/docs/explanations/why-use-knip.md +128 -0
- package/docs/docs/features/auto-fix.mdx +333 -0
- package/docs/docs/features/compilers.md +172 -0
- package/docs/docs/features/integrated-monorepos.md +52 -0
- package/docs/docs/features/monorepos-and-workspaces.md +134 -0
- package/docs/docs/features/production-mode.md +95 -0
- package/docs/docs/features/reporters.md +302 -0
- package/docs/docs/features/rules-and-filters.md +102 -0
- package/docs/docs/features/script-parser.md +156 -0
- package/docs/docs/features/source-mapping.md +100 -0
- package/docs/docs/guides/configuring-project-files.md +205 -0
- package/docs/docs/guides/contributing.md +24 -0
- package/docs/docs/guides/handling-issues.mdx +646 -0
- package/docs/docs/guides/issue-reproduction.md +94 -0
- package/docs/docs/guides/namespace-imports.md +125 -0
- package/docs/docs/guides/performance.md +97 -0
- package/docs/docs/guides/troubleshooting.md +127 -0
- package/docs/docs/guides/using-knip-in-ci.md +54 -0
- package/docs/docs/guides/working-with-commonjs.md +72 -0
- package/docs/docs/index.mdx +160 -0
- package/docs/docs/overview/configuration.md +104 -0
- package/docs/docs/overview/features.md +66 -0
- package/docs/docs/overview/getting-started.mdx +195 -0
- package/docs/docs/overview/screenshots-videos.md +42 -0
- package/docs/docs/playground.mdx +38 -0
- package/docs/docs/reference/cli.md +481 -0
- package/docs/docs/reference/configuration.md +413 -0
- package/docs/docs/reference/dynamic-configuration.mdx +72 -0
- package/docs/docs/reference/faq.md +441 -0
- package/docs/docs/reference/issue-types.md +43 -0
- package/docs/docs/reference/jsdoc-tsdoc-tags.md +122 -0
- package/docs/docs/reference/known-issues.md +64 -0
- package/docs/docs/reference/plugins/.gitkeep +0 -0
- package/docs/docs/reference/plugins.md +238 -0
- package/docs/docs/reference/related-tooling.md +46 -0
- package/docs/docs/sponsors.mdx +65 -0
- package/docs/docs/typescript/unused-dependencies.md +86 -0
- package/docs/docs/typescript/unused-exports.md +87 -0
- package/docs/docs/writing-a-plugin/argument-parsing.md +202 -0
- package/docs/docs/writing-a-plugin/index.md +376 -0
- package/docs/docs/writing-a-plugin/inputs.md +162 -0
- package/package.json +8 -6
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Inputs
|
|
3
|
+
sidebar:
|
|
4
|
+
order: 2
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You may have noticed functions like `toDeferResolve` and `toEntry`. They're a
|
|
8
|
+
way for plugins to tell what they've found and how Knip should handle those. The
|
|
9
|
+
more precise a plugin can be, the better it is for results and performance.
|
|
10
|
+
Here's an overview of all input type functions:
|
|
11
|
+
|
|
12
|
+
- [toEntry][1]
|
|
13
|
+
- [toProductionEntry][2]
|
|
14
|
+
- [toProject][3]
|
|
15
|
+
- [toDependency][4]
|
|
16
|
+
- [toProductionDependency][5]
|
|
17
|
+
- [toDeferResolve][6]
|
|
18
|
+
- [toDeferResolveEntry][7]
|
|
19
|
+
- [toConfig][8]
|
|
20
|
+
- [toBinary][9]
|
|
21
|
+
- [toAlias][10]
|
|
22
|
+
- [Options][11]
|
|
23
|
+
|
|
24
|
+
## toEntry
|
|
25
|
+
|
|
26
|
+
An `entry` input is just like an `entry` in the configuration. It should either
|
|
27
|
+
be an absolute or relative path, and glob patterns are allowed.
|
|
28
|
+
|
|
29
|
+
## toProductionEntry
|
|
30
|
+
|
|
31
|
+
A production `entry` input is just like an `production` in the configuration. It
|
|
32
|
+
should either be an absolute or relative path, and it can have glob patterns.
|
|
33
|
+
|
|
34
|
+
## toProject
|
|
35
|
+
|
|
36
|
+
A `project` input is the equivalent of `project` patterns in the configuration.
|
|
37
|
+
It should either be an absolute or relative path, and (negated) glob patterns
|
|
38
|
+
are allowed.
|
|
39
|
+
|
|
40
|
+
## toDependency
|
|
41
|
+
|
|
42
|
+
The `dependency` indicates the entry is a dependency, belonging in either the
|
|
43
|
+
`"dependencies"` or `"devDependencies"` section of `package.json`.
|
|
44
|
+
|
|
45
|
+
## toProductionDependency
|
|
46
|
+
|
|
47
|
+
The production `dependency` indicates the entry is a production dependency,
|
|
48
|
+
expected to be listed in `"dependencies"`.
|
|
49
|
+
|
|
50
|
+
## toDeferResolve
|
|
51
|
+
|
|
52
|
+
The `deferResolve` input type is used to defer the resolution of a specifier.
|
|
53
|
+
This could be resolved to a dependency or an entry file. For instance, the
|
|
54
|
+
specifier `"input"` could be resolved to `"input.js"`, `"input.tsx"`,
|
|
55
|
+
`"input/index.js"` or the `"input"` package name. Local files are added as entry
|
|
56
|
+
files, package names are external dependencies.
|
|
57
|
+
|
|
58
|
+
If this does not lead to a resolution, the specifier will be reported under
|
|
59
|
+
"unresolved imports".
|
|
60
|
+
|
|
61
|
+
## toDeferResolveEntry
|
|
62
|
+
|
|
63
|
+
The `deferResolveEntry` input type is similar to `deferResolve`, but it's used
|
|
64
|
+
for entry files only (not dependencies) and unresolved inputs are ignored. It's
|
|
65
|
+
different from `toEntry` as glob patterns are not supported.
|
|
66
|
+
|
|
67
|
+
## toConfig
|
|
68
|
+
|
|
69
|
+
The `config` input type is a way for plugins to reference a configuration file
|
|
70
|
+
that should be handled by a different plugin. For instance, Angular
|
|
71
|
+
configurations might contain references to `tsConfig` and `karmaConfig` files,
|
|
72
|
+
so these `config` files can then be handled by the TypeScript and Karma plugins,
|
|
73
|
+
respectively.
|
|
74
|
+
|
|
75
|
+
Example:
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
toConfig('typescript', './path/to/tsconfig.json');
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
For instance, the Angular plugin uses this to tell Knip about its `tsConfig`
|
|
82
|
+
value in `angular.json` projects.
|
|
83
|
+
|
|
84
|
+
## toBinary
|
|
85
|
+
|
|
86
|
+
The `binary` input type isn't used by plugins directly, but by the shell script
|
|
87
|
+
parser (through the `getInputsFromScripts` helper). Think of GitHub Actions
|
|
88
|
+
workflow YAML files or husky scripts. Using this input type, a binary is
|
|
89
|
+
"assigned" to the dependency that has it as a `"bin"` in their `package.json`.
|
|
90
|
+
|
|
91
|
+
## toAlias
|
|
92
|
+
|
|
93
|
+
The `alias` input type adds path aliases to the core module resolver. They're
|
|
94
|
+
added to `compilerOptions.paths` so the syntax is identical.
|
|
95
|
+
|
|
96
|
+
## Options
|
|
97
|
+
|
|
98
|
+
When creating inputs from specifiers, an extra `options` object as the second
|
|
99
|
+
argument can be provided.
|
|
100
|
+
|
|
101
|
+
### dir
|
|
102
|
+
|
|
103
|
+
The optional `dir` option assigns the input to a different workspace. For
|
|
104
|
+
instance, GitHub Action workflows are always stored in the root workspace, and
|
|
105
|
+
support `working-directory` in job steps. For example:
|
|
106
|
+
|
|
107
|
+
```yaml
|
|
108
|
+
jobs:
|
|
109
|
+
stylelint:
|
|
110
|
+
runs-on: ubuntu-latest
|
|
111
|
+
steps:
|
|
112
|
+
- run: npx esbuild
|
|
113
|
+
working-directory: packages/app
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The GitHub Action plugin understands `working-directory` and adds this `dir` to
|
|
117
|
+
the input:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
toDependency('esbuild', { dir: 'packages/app' });
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Knip now understands `esbuild` is a dependency of the workspace in the
|
|
124
|
+
`packages/app` directory.
|
|
125
|
+
|
|
126
|
+
### optional
|
|
127
|
+
|
|
128
|
+
Use the `optional` flag to indicate the dependency is optional. Then, a
|
|
129
|
+
dependency won't be flagged as unlisted if it isn't.
|
|
130
|
+
|
|
131
|
+
### allowIncludeExports
|
|
132
|
+
|
|
133
|
+
By default, exports of entry files such as `src/index.ts` or the files in
|
|
134
|
+
`package.json#exports` are not reported as unused. When using the
|
|
135
|
+
`--include-entry-exports` flag or `isIncludeExports: true` option, unused
|
|
136
|
+
exports on such entry files are also reported.
|
|
137
|
+
|
|
138
|
+
Exports of entry files coming from plugins are not included in the analysis,
|
|
139
|
+
even with the option enabled. This is because certain tools and frameworks
|
|
140
|
+
consume named exports from entry files, causing false positives.
|
|
141
|
+
|
|
142
|
+
The `allowIncludeExports` option allows the exports of entry files to be
|
|
143
|
+
reported as unused when using `--include-entry-exports`. This option is
|
|
144
|
+
typically used with the [toProductionEntry][2] input type.
|
|
145
|
+
|
|
146
|
+
Example:
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
toProductionEntry('./entry.ts', { allowIncludeExports: true });
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
[1]: #toentry
|
|
153
|
+
[2]: #toproductionentry
|
|
154
|
+
[3]: #toproject
|
|
155
|
+
[4]: #todependency
|
|
156
|
+
[5]: #toproductiondependency
|
|
157
|
+
[6]: #todeferresolve
|
|
158
|
+
[7]: #todeferresolveentry
|
|
159
|
+
[8]: #toconfig
|
|
160
|
+
[9]: #tobinary
|
|
161
|
+
[10]: #toalias
|
|
162
|
+
[11]: #options
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knip/mcp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Knip MCP Server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
"src",
|
|
15
15
|
"docs"
|
|
16
16
|
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"prepack": "cp -r ../docs/src/content/docs ./docs"
|
|
19
|
+
},
|
|
17
20
|
"keywords": [
|
|
18
21
|
"knip",
|
|
19
22
|
"mcp",
|
|
@@ -28,11 +31,10 @@
|
|
|
28
31
|
"license": "ISC",
|
|
29
32
|
"dependencies": {
|
|
30
33
|
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
34
|
+
"knip": "^5.75.2",
|
|
35
|
+
"zod": "^4.1.11"
|
|
33
36
|
},
|
|
34
37
|
"engines": {
|
|
35
38
|
"node": ">=18.18.0"
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
+
}
|
|
40
|
+
}
|