Repository navigation
Expand file tree
/
Copy pathknip.jsonc
More file actions
227 lines (227 loc) · 11 KB
/
Copy pathknip.jsonc
File metadata and controls
227 lines (227 loc) · 11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
// Knip config — unused files / exports / dependencies across the workspace.
// Run AFTER `pnpm build`: workspace packages resolve each other through their exports
// maps into the gitignored dist/, so a cold tree reports a wall of unresolved imports.
//
// The `ignore` / `ignoreDependencies` entries below are the remaining ACCEPTED BASELINE,
// kept explicit so a follow-up can triage them (delete the dead code / drop the dep and
// shrink the list) — they are NOT an invitation to add more. New findings fail CI.
// `exports`/`types`/`duplicates` are reported as non-failing warnings: the bulk (~130
// unused exports/types) has been triaged away (dead code deleted, needless `export`s
// dropped); the residual handful are DELIBERATE re-export barrels (the neutral VcsClient
// port types in `ports/vcs-client.ts`, the Worker `config/index.ts` config-type barrel,
// the `providerEndpoints` base-URL group) plus a couple of types that must stay exported
// for declaration emit even though nothing imports them by name — all intentional, hence
// warn, not error.
{
"$schema": "https://unpkg.com/knip@6/schema.json",
"rules": {
"files": "error",
"dependencies": "error",
"devDependencies": "error",
"unlisted": "error",
"binaries": "error",
"exports": "warn",
"types": "warn",
"duplicates": "warn",
},
"workspaces": {
".": {
"entry": ["scripts/*.mjs"],
"project": ["scripts/**/*.mjs"],
},
"backend/packages/*": {
"entry": ["src/**/*.test.ts"],
"project": ["src/**/*.ts"],
},
"backend/packages/contracts": {
"entry": ["src/**/*.test.ts"],
"project": ["src/**/*.ts"],
// Baseline: not imported from src/ — triage separately.
"ignoreDependencies": ["@toad-contracts/core"],
},
"backend/packages/consensus": {
"entry": ["src/**/*.test.ts"],
"project": ["src/**/*.ts"],
"ignoreDependencies": ["@cat-factory/contracts"],
},
"backend/packages/provider-bedrock": {
"entry": ["src/**/*.test.ts"],
"project": ["src/**/*.ts"],
"ignoreDependencies": ["@cat-factory/kernel", "ai"],
},
"backend/packages/provider-cloudflare": {
"entry": ["src/**/*.test.ts"],
"project": ["src/**/*.ts"],
"ignoreDependencies": ["@cat-factory/kernel"],
},
"backend/packages/server": {
"entry": ["src/**/*.test.ts"],
"project": ["src/**/*.ts"],
"ignoreDependencies": ["@toad-contracts/valibot"],
},
"backend/runtimes/*": {
"entry": ["src/main.ts", "src/link-repo.ts", "src/**/*.test.ts", "test/**/*.ts"],
"project": ["src/**/*.ts"],
},
"backend/runtimes/cloudflare": {
"entry": ["test/**/*.ts"],
"project": ["src/**/*.ts"],
// The workers-pool vitest config reads ./migrations relative to cwd, which breaks
// when knip loads it from the repo root — and its test entries are covered by the
// explicit test/ glob above anyway.
"vitest": false,
// `cloudflare` is knip misreading the `cloudflare:workers` module specifier scheme
// as an npm package. The rest is the accepted unused-dep baseline (plausible
// leftovers of the @cat-factory/server extraction) — triage separately.
"ignoreDependencies": [
"cloudflare",
"@ai-sdk/openai-compatible",
"@hono/valibot-validator",
"pino",
],
},
"backend/runtimes/node": {
"entry": ["src/main.ts", "test/**/*.ts"],
"project": ["src/**/*.ts"],
// `layered-loader` is loaded via the OPAQUE dynamic import in
// cacheNotifications.ts (`import('layered-loader' as string)`, gated on
// REDIS_URL — the cast deliberately hides its Redis modules from the TS
// build graph), so knip sees no static import.
"ignoreDependencies": ["layered-loader"],
},
"backend/runtimes/local": {
"entry": ["src/main.ts", "src/link-repo.ts", "src/**/*.test.ts", "test/**/*.ts"],
"project": ["src/**/*.ts"],
// `@cat-factory/executor-harness` is resolved dynamically at runtime via
// createRequire(import.meta.url).resolve('@cat-factory/executor-harness') in
// LocalProcessRunnerTransport (native mode spawns its bundled dist/harness-server.js), so knip
// sees no static import.
"ignoreDependencies": ["@cat-factory/executor-harness"],
},
// The public-API SDK client. The smoketest program is an entry point in its own right (the
// cross-SDK harness runs it), not something `src/index.ts` reaches. The generated modules need
// no `ignore`: `src/index.ts` re-exports them and is an entry, so their exports are not
// reported.
"sdk/typescript": {
"entry": ["src/index.ts", "test/**/*.test.ts", "smoketest/main.ts"],
"project": ["src/**/*.ts", "test/**/*.ts", "smoketest/**/*.ts"],
},
// The MCP facade over that same surface. `src/bin.ts` has to be named explicitly: it is the
// package's `bin`, but the manifest points at the BUILT `dist/bin.js`, so knip cannot map it
// back to a source file and the stdio executable would read as an unused file. Same reason
// the client above lists its smoketest entry by hand.
"sdk/mcp": {
"entry": ["src/index.ts", "src/bin.ts", "test/**/*.test.ts"],
"project": ["src/**/*.ts", "test/**/*.ts"],
},
// The gatekeeper bindings over that same surface: a generated policy table plus hand-written
// ladder helpers, re-exported from the entry like the client's generated modules are.
"sdk/gatekeeper": {
"entry": ["src/index.ts", "test/**/*.test.ts"],
"project": ["src/**/*.ts", "test/**/*.ts"],
},
"backend/internal/*": {
"entry": ["src/**/*.ts", "tests/**/*.ts", "test/**/*.ts"],
"project": ["src/**/*.ts"],
},
"backend/internal/sdk-smoketest": {
"entry": ["src/**/*.ts", "test/**/*.ts"],
"project": ["src/**/*.ts"],
// The harness SPAWNS the e2e test server rather than importing it — it resolves
// `@cat-factory/e2e/package.json` to locate `testServer.ts` and runs it as a child process,
// which is the whole point (the SDKs must be smoketested against a real HTTP deployment, not
// an in-process app). Knip cannot see a `require.resolve` of a package manifest, so the
// dependency has to be declared here or it reads as unused.
"ignoreDependencies": ["@cat-factory/e2e"],
},
"backend/internal/benchmark-harness": {
"entry": ["src/**/*.ts"],
"project": ["src/**/*.ts"],
"ignoreDependencies": ["@cat-factory/contracts"],
},
"backend/internal/smoketest-harness": {
"entry": ["src/**/*.ts"],
"project": ["src/**/*.ts"],
"ignoreDependencies": ["@cat-factory/kernel"],
},
"backend/internal/executor-harness": {
"entry": ["src/**/*.ts"],
"project": ["src/**/*.ts"],
// Binaries invoked inside the runner container image, not on the dev machine.
"ignoreBinaries": ["java", "serve", "pi"],
},
"frontend/app": {
"entry": ["app/**/*.{vue,ts}", "i18n/**/*.ts", "scripts/*.mjs"],
"project": ["app/**/*.{vue,ts}", "i18n/**/*.ts"],
// @vue-flow/*: referenced as CSS paths in nuxt.config.ts, which knip double-reports
// as unlisted-in-config + unused-in-app. vue-tsc backs `nuxt typecheck`; msw and
// @toad-contracts/testing are test-setup deps outside the project globs.
"ignoreDependencies": [
"@vue-flow/core",
"@vue-flow/node-resizer",
"@toad-contracts/valibot",
"@toad-contracts/testing",
"msw",
"vue-tsc",
],
},
"deploy/backend": { "entry": ["src/**/*.ts"] },
"deploy/node": { "entry": ["src/**/*.ts"] },
"deploy/local": {
"entry": ["src/**/*.ts"],
// `pnpm dev` spawns the CLI as `node ../../backend/packages/cli/dist/bin.js`, by path
// rather than by its `cat-factory` bin name, because that shim cannot exist on a fresh
// checkout (check-workspace-bin-scripts.mjs holds the rule). Knip reads a path into a
// gitignored `dist/` as a file reference, not as a use of the package that owns it, so
// the dependency has to be declared here or it reads as unused.
"ignoreDependencies": ["@cat-factory/cli"],
},
// The Gatekeeper template: the Worker entry, the policy it wires, and the policy's own test.
// `src/index.ts` is knip's own default entry and the vitest plugin finds the suite, so the
// only thing worth stating is that `src/**` is the project (the default would sweep in
// `vitest.config.ts`, which is configuration rather than source this analysis can speak to).
"deploy/gatekeeper": {
"project": ["src/**/*.ts", "test/**/*.ts"],
},
// The Gatekeeper machinery. `src/index.ts` is the published entry and the specs are the
// second, which is also why `project` is stated: the default (`**/*`) would sweep in
// `vitest.config.ts` and the fake origin, and neither is source this analysis has anything to
// say about. `src/policy/index.ts` is the second published entry (`./policy`), which nothing
// inside the package has to import for it to be part of the surface.
"sdk/gatekeeper-worker": {
"entry": ["src/index.ts", "src/policy/index.ts", "test/**/*.ts"],
"project": ["src/**/*.ts", "test/**/*.ts"],
// The vitest config reads `./test/fake-cat-factory.mjs` relative to cwd, which fails when
// knip loads it from the repo root, and its test entries are covered by the explicit
// `test/` glob above anyway. Same reason the Worker runtime's config is skipped.
"vitest": false,
// `cloudflare` is knip misreading the `cloudflare:workers` / `cloudflare:test` module
// specifier scheme as an npm package, exactly as it does in `backend/runtimes/cloudflare`.
//
// `@gadgets/integration-tests` is Cloudflare OS's own test toolkit, which the OS leg imports
// BY NAME and `vitest.os.config.ts` aliases at run time into the partner checkout
// `GATEKEEPER_OS_DIR` points at. It is deliberately not a dependency (the initiative's CI rule
// refuses putting a partner's release cadence in front of this package's build) and it is not
// on a registry, so declaring it to silence this would be the lie. Ignored here, and the
// nightly leg is what proves the import still resolves.
"ignoreDependencies": ["cloudflare", "@gadgets/integration-tests"],
},
"deploy/frontend": {
// Backs `nuxt typecheck` in the deploy consumer.
"ignoreDependencies": ["vue-tsc"],
},
"frontend/storybook": {
// The story test config has its own name so no ordinary vitest lane picks it up, so it is
// named here as an entry, with the setup file it names. `nuxt.config.ts` gives every page
// `EmptyPage.vue` by path, not by import.
"entry": [
"vitest.stories.config.ts",
".storybook/collectGarbage.ts",
".storybook/EmptyPage.vue",
],
// msw's generated service worker: Storybook serves it from `.storybook/public` and the
// preview registers it by URL, so no module imports it.
"ignore": [".storybook/public/mockServiceWorker.js"],
},
},
}