codesift-mcp 0.8.18 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/cli/commands.d.ts +36 -0
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +177 -1
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/help.d.ts +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +29 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/hooks.js +5 -5
- package/dist/cli/hooks.js.map +1 -1
- package/dist/cli/setup.d.ts +14 -1
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +75 -58
- package/dist/cli/setup.js.map +1 -1
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/server.d.ts +27 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +166 -6
- package/dist/server.js.map +1 -1
- package/dist/storage/embedding-store.d.ts.map +1 -1
- package/dist/storage/embedding-store.js +28 -12
- package/dist/storage/embedding-store.js.map +1 -1
- package/dist/tools/conversation-tools.d.ts +4 -5
- package/dist/tools/conversation-tools.d.ts.map +1 -1
- package/dist/tools/conversation-tools.js +6 -45
- package/dist/tools/conversation-tools.js.map +1 -1
- package/dist/tools/index-tools.d.ts +7 -1
- package/dist/tools/index-tools.d.ts.map +1 -1
- package/dist/tools/index-tools.js +102 -12
- package/dist/tools/index-tools.js.map +1 -1
- package/dist/tools/outline-tools.d.ts.map +1 -1
- package/dist/tools/outline-tools.js +23 -0
- package/dist/tools/outline-tools.js.map +1 -1
- package/dist/tools/pattern-tools.js +1 -1
- package/dist/tools/pattern-tools.js.map +1 -1
- package/package.json +2 -2
- package/rules/codesift.md +1 -1
- package/rules/codesift.mdc +1 -1
- package/rules/codex.md +1 -1
- package/rules/gemini.md +1 -1
- package/dist/tools/hono-conditional-middleware.d.ts +0 -27
- package/dist/tools/hono-conditional-middleware.d.ts.map +0 -1
- package/dist/tools/hono-conditional-middleware.js +0 -62
- package/dist/tools/hono-conditional-middleware.js.map +0 -1
- package/dist/tools/hono-env-regression.d.ts +0 -29
- package/dist/tools/hono-env-regression.d.ts.map +0 -1
- package/dist/tools/hono-env-regression.js +0 -157
- package/dist/tools/hono-env-regression.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codesift-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "MCP server for code intelligence — 146 tools for symbol search, call graph, semantic search, route tracing, community detection, LSP bridge, secret detection, conversation search, and Hono framework intelligence",
|
|
5
5
|
"license": "BSL-1.1",
|
|
6
6
|
"author": "Greg Laskowski",
|
|
@@ -78,6 +78,6 @@
|
|
|
78
78
|
],
|
|
79
79
|
"repository": {
|
|
80
80
|
"type": "git",
|
|
81
|
-
"url": "https://github.com/
|
|
81
|
+
"url": "git+https://github.com/greglas75/codesift.git"
|
|
82
82
|
}
|
|
83
83
|
}
|
package/rules/codesift.md
CHANGED
|
@@ -251,7 +251,7 @@ The server appends hint codes to responses to guide tool usage. Act on them imme
|
|
|
251
251
|
- Call `list_repos` in single-repo sessions — repo auto-resolves from CWD
|
|
252
252
|
- Use manual Edit on multiple files for rename — use `rename_symbol`
|
|
253
253
|
- Read entire file just to get a return type — use `get_type_info`
|
|
254
|
-
- Index
|
|
254
|
+
- Index a worktree only when it is the reviewed/edited target and `index_status(path=<worktree>)` shows the branch tip is missing; otherwise use `index_file(path=...)` for edited files
|
|
255
255
|
- Call `get_knowledge_map` without `focus=` parameter
|
|
256
256
|
|
|
257
257
|
## Response Cascade
|
package/rules/codesift.mdc
CHANGED
|
@@ -234,7 +234,7 @@ The server appends hint codes to responses to guide tool usage. Act on them imme
|
|
|
234
234
|
- Call `list_repos` in single-repo sessions — repo auto-resolves from CWD
|
|
235
235
|
- Use manual Edit on multiple files for rename — use `rename_symbol`
|
|
236
236
|
- Read entire file just to get a return type — use `get_type_info`
|
|
237
|
-
- Index
|
|
237
|
+
- Index a worktree only when it is the reviewed/edited target and `index_status(path=<worktree>)` shows the branch tip is missing; otherwise use `index_file(path=...)` for edited files
|
|
238
238
|
- Call `get_knowledge_map` without `focus=` parameter
|
|
239
239
|
|
|
240
240
|
## Response Cascade
|
package/rules/codex.md
CHANGED
|
@@ -229,7 +229,7 @@ The server appends hint codes to responses to guide tool usage. Act on them imme
|
|
|
229
229
|
- Call `list_repos` in single-repo sessions — repo auto-resolves from CWD
|
|
230
230
|
- Use manual Edit on multiple files for rename — use `rename_symbol`
|
|
231
231
|
- Read entire file just to get a return type — use `get_type_info`
|
|
232
|
-
- Index
|
|
232
|
+
- Index a worktree only when it is the reviewed/edited target and `index_status(path=<worktree>)` shows the branch tip is missing; otherwise use `index_file(path=...)` for edited files
|
|
233
233
|
- Call `get_knowledge_map` without `focus=` parameter
|
|
234
234
|
|
|
235
235
|
## Response Cascade
|
package/rules/gemini.md
CHANGED
|
@@ -230,7 +230,7 @@ The server appends hint codes to responses to guide tool usage. Act on them imme
|
|
|
230
230
|
- Call `list_repos` in single-repo sessions — repo auto-resolves from CWD
|
|
231
231
|
- Use manual Edit on multiple files for rename — use `rename_symbol`
|
|
232
232
|
- Read entire file just to get a return type — use `get_type_info`
|
|
233
|
-
- Index
|
|
233
|
+
- Index a worktree only when it is the reviewed/edited target and `index_status(path=<worktree>)` shows the branch tip is missing; otherwise use `index_file(path=...)` for edited files
|
|
234
234
|
- Call `get_knowledge_map` without `focus=` parameter
|
|
235
235
|
|
|
236
236
|
## Response Cascade
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* trace_conditional_middleware — lists middleware that is applied under a
|
|
3
|
-
* runtime condition (e.g., basicAuth only for non-GET methods). Consumes
|
|
4
|
-
* the applied_when data populated by HonoExtractor Phase 2 T4.
|
|
5
|
-
*
|
|
6
|
-
* Use case: audit_hono_security was producing false positives on conditional
|
|
7
|
-
* auth wrappers in inline middleware arrows. This tool surfaces the gated
|
|
8
|
-
* middleware so operators can verify the gating is correct.
|
|
9
|
-
*
|
|
10
|
-
* Spec: docs/specs/2026-04-11-hono-phase-2-plan.md (T7)
|
|
11
|
-
*/
|
|
12
|
-
import type { ConditionalApplication } from "../parser/extractors/hono-model.js";
|
|
13
|
-
export interface ConditionalMiddlewareEntry {
|
|
14
|
-
scope: string;
|
|
15
|
-
middleware_name: string;
|
|
16
|
-
condition_type: ConditionalApplication["condition_type"];
|
|
17
|
-
condition_text: string;
|
|
18
|
-
file: string;
|
|
19
|
-
line: number;
|
|
20
|
-
}
|
|
21
|
-
export interface ConditionalMiddlewareResult {
|
|
22
|
-
entries?: ConditionalMiddlewareEntry[];
|
|
23
|
-
total?: number;
|
|
24
|
-
error?: string;
|
|
25
|
-
}
|
|
26
|
-
export declare function traceConditionalMiddleware(repo: string, scopeFilter?: string): Promise<ConditionalMiddlewareResult>;
|
|
27
|
-
//# sourceMappingURL=hono-conditional-middleware.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hono-conditional-middleware.d.ts","sourceRoot":"","sources":["../../src/tools/hono-conditional-middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAEjF,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;IACzD,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,CAAC,EAAE,0BAA0B,EAAE,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,2BAA2B,CAAC,CAmCtC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* trace_conditional_middleware — lists middleware that is applied under a
|
|
3
|
-
* runtime condition (e.g., basicAuth only for non-GET methods). Consumes
|
|
4
|
-
* the applied_when data populated by HonoExtractor Phase 2 T4.
|
|
5
|
-
*
|
|
6
|
-
* Use case: audit_hono_security was producing false positives on conditional
|
|
7
|
-
* auth wrappers in inline middleware arrows. This tool surfaces the gated
|
|
8
|
-
* middleware so operators can verify the gating is correct.
|
|
9
|
-
*
|
|
10
|
-
* Spec: docs/specs/2026-04-11-hono-phase-2-plan.md (T7)
|
|
11
|
-
*/
|
|
12
|
-
import { getCodeIndex } from "./index-tools.js";
|
|
13
|
-
import { honoCache } from "../cache/hono-cache.js";
|
|
14
|
-
import { HonoExtractor } from "../parser/extractors/hono.js";
|
|
15
|
-
import { detectFrameworks } from "../utils/framework-detect.js";
|
|
16
|
-
import { join } from "node:path";
|
|
17
|
-
export async function traceConditionalMiddleware(repo, scopeFilter) {
|
|
18
|
-
const index = await getCodeIndex(repo);
|
|
19
|
-
if (!index)
|
|
20
|
-
return { error: `Repository "${repo}" not found` };
|
|
21
|
-
const frameworks = detectFrameworks(index);
|
|
22
|
-
if (!frameworks.has("hono"))
|
|
23
|
-
return { error: "No Hono app detected" };
|
|
24
|
-
const entryFile = resolveHonoEntryFile(index);
|
|
25
|
-
if (!entryFile)
|
|
26
|
-
return { error: "No Hono app entry file found" };
|
|
27
|
-
let model;
|
|
28
|
-
try {
|
|
29
|
-
model = await honoCache.get(repo, entryFile, new HonoExtractor());
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
33
|
-
return { error: `Failed to parse: ${msg}` };
|
|
34
|
-
}
|
|
35
|
-
const entries = [];
|
|
36
|
-
for (const chain of model.middleware_chains) {
|
|
37
|
-
if (scopeFilter && chain.scope !== scopeFilter)
|
|
38
|
-
continue;
|
|
39
|
-
for (const entry of chain.entries) {
|
|
40
|
-
if (!entry.applied_when)
|
|
41
|
-
continue;
|
|
42
|
-
entries.push({
|
|
43
|
-
scope: chain.scope,
|
|
44
|
-
middleware_name: entry.name,
|
|
45
|
-
condition_type: entry.applied_when.condition_type,
|
|
46
|
-
condition_text: entry.applied_when.condition_text,
|
|
47
|
-
file: entry.file,
|
|
48
|
-
line: entry.line,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return { entries, total: entries.length };
|
|
53
|
-
}
|
|
54
|
-
function resolveHonoEntryFile(index) {
|
|
55
|
-
for (const sym of index.symbols) {
|
|
56
|
-
if (sym.source && /new\s+(?:Hono|OpenAPIHono)\s*(?:<[^>]*>)?\s*\(/.test(sym.source)) {
|
|
57
|
-
return join(index.root, sym.file);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=hono-conditional-middleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hono-conditional-middleware.js","sourceRoot":"","sources":["../../src/tools/hono-conditional-middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAkBjC,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,IAAY,EACZ,WAAoB;IAEpB,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,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AAC,YAAY,CAAC,cAAc;gBACjD,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,IAAI,EAAE,KAAK,CAAC,IAAI;aACjB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;AAC5C,CAAC;AAED,SAAS,oBAAoB,CAAC,KAG7B;IACC,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAChC,IAAI,GAAG,CAAC,MAAM,IAAI,gDAAgD,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACpF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* detect_middleware_env_regression — static check for the Issue #3587 pattern:
|
|
3
|
-
* in a chain of 3+ middleware, intermediate entries declared with plain
|
|
4
|
-
* `createMiddleware(...)` (no Env generic) reset the accumulated Env type
|
|
5
|
-
* back to BlankEnv. Downstream middleware then can't see the custom bindings.
|
|
6
|
-
*
|
|
7
|
-
* Best-effort heuristic — regex over middleware declaration files, not a
|
|
8
|
-
* real type checker. Flags candidates for manual review rather than hard
|
|
9
|
-
* assertions, and documents this in the result `note` field.
|
|
10
|
-
*
|
|
11
|
-
* Spec: docs/specs/2026-04-11-hono-phase-2-plan.md (T10)
|
|
12
|
-
*/
|
|
13
|
-
export interface EnvRegressionFinding {
|
|
14
|
-
chain_scope: string;
|
|
15
|
-
chain_length: number;
|
|
16
|
-
middleware_name: string;
|
|
17
|
-
file: string;
|
|
18
|
-
/** First line in the file where the plain createMiddleware( call occurs. */
|
|
19
|
-
line: number;
|
|
20
|
-
reason: "plain_createMiddleware_no_generic";
|
|
21
|
-
}
|
|
22
|
-
export interface EnvRegressionResult {
|
|
23
|
-
findings?: EnvRegressionFinding[];
|
|
24
|
-
total?: number;
|
|
25
|
-
note?: string;
|
|
26
|
-
error?: string;
|
|
27
|
-
}
|
|
28
|
-
export declare function detectMiddlewareEnvRegression(repo: string): Promise<EnvRegressionResult>;
|
|
29
|
-
//# sourceMappingURL=hono-env-regression.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hono-env-regression.d.ts","sourceRoot":"","sources":["../../src/tools/hono-env-regression.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,mCAAmC,CAAC;CAC7C;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAkBD,wBAAsB,6BAA6B,CACjD,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,mBAAmB,CAAC,CA6D9B"}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* detect_middleware_env_regression — static check for the Issue #3587 pattern:
|
|
3
|
-
* in a chain of 3+ middleware, intermediate entries declared with plain
|
|
4
|
-
* `createMiddleware(...)` (no Env generic) reset the accumulated Env type
|
|
5
|
-
* back to BlankEnv. Downstream middleware then can't see the custom bindings.
|
|
6
|
-
*
|
|
7
|
-
* Best-effort heuristic — regex over middleware declaration files, not a
|
|
8
|
-
* real type checker. Flags candidates for manual review rather than hard
|
|
9
|
-
* assertions, and documents this in the result `note` field.
|
|
10
|
-
*
|
|
11
|
-
* Spec: docs/specs/2026-04-11-hono-phase-2-plan.md (T10)
|
|
12
|
-
*/
|
|
13
|
-
import { getCodeIndex } from "./index-tools.js";
|
|
14
|
-
import { honoCache } from "../cache/hono-cache.js";
|
|
15
|
-
import { HonoExtractor } from "../parser/extractors/hono.js";
|
|
16
|
-
import { detectFrameworks } from "../utils/framework-detect.js";
|
|
17
|
-
import { join, dirname, resolve as pathResolve } from "node:path";
|
|
18
|
-
import { readFile } from "node:fs/promises";
|
|
19
|
-
import { existsSync } from "node:fs";
|
|
20
|
-
const HEURISTIC_NOTE = "Heuristic regex scan; false positives possible when middleware factories wrap createMiddleware or re-export it under a different name. Review each finding before typing changes.";
|
|
21
|
-
/**
|
|
22
|
-
* Regex explanation:
|
|
23
|
-
* \bcreateMiddleware → word-boundary before the token
|
|
24
|
-
* (?!\s*<) → negative lookahead — NOT followed by `<` (generic arg)
|
|
25
|
-
* \s*\( → open paren of the call
|
|
26
|
-
*
|
|
27
|
-
* Matches: createMiddleware(async (c, next) => ...)
|
|
28
|
-
* createMiddleware (async (c, next) => ...)
|
|
29
|
-
* Does not match: createMiddleware<AppEnv>(...)
|
|
30
|
-
* createMiddleware< { Bindings: ... } >(...)
|
|
31
|
-
*/
|
|
32
|
-
const PLAIN_CREATE_MIDDLEWARE = /\bcreateMiddleware(?!\s*<)\s*\(/g;
|
|
33
|
-
export async function detectMiddlewareEnvRegression(repo) {
|
|
34
|
-
const index = await getCodeIndex(repo);
|
|
35
|
-
if (!index)
|
|
36
|
-
return { error: `Repository "${repo}" not found` };
|
|
37
|
-
const frameworks = detectFrameworks(index);
|
|
38
|
-
if (!frameworks.has("hono"))
|
|
39
|
-
return { error: "No Hono app detected" };
|
|
40
|
-
const entryFile = resolveHonoEntryFile(index);
|
|
41
|
-
if (!entryFile)
|
|
42
|
-
return { error: "No Hono app entry file found" };
|
|
43
|
-
let model;
|
|
44
|
-
try {
|
|
45
|
-
model = await honoCache.get(repo, entryFile, new HonoExtractor());
|
|
46
|
-
}
|
|
47
|
-
catch (err) {
|
|
48
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
49
|
-
return { error: `Failed to parse: ${msg}` };
|
|
50
|
-
}
|
|
51
|
-
const findings = [];
|
|
52
|
-
// Cache file scans so a middleware file shared across chains is only read once.
|
|
53
|
-
const fileScanCache = new Map();
|
|
54
|
-
for (const chain of model.middleware_chains) {
|
|
55
|
-
if (chain.entries.length < 3)
|
|
56
|
-
continue;
|
|
57
|
-
// Intermediate entries: exclude first + last (those are endpoints of the chain).
|
|
58
|
-
// We only suspect regression on entries that sit between custom-typed middleware.
|
|
59
|
-
const intermediates = chain.entries.slice(1, -1);
|
|
60
|
-
for (const entry of intermediates) {
|
|
61
|
-
if (entry.is_third_party)
|
|
62
|
-
continue;
|
|
63
|
-
if (entry.inline)
|
|
64
|
-
continue;
|
|
65
|
-
// Resolve the DEFINITION file — entry.file is the caller (app.use site).
|
|
66
|
-
// If the entry was imported from a relative path, resolve it; otherwise
|
|
67
|
-
// fall back to scanning the caller file (local definitions).
|
|
68
|
-
const definitionFile = resolveDefinitionFile(entry.file, entry.imported_from);
|
|
69
|
-
if (!definitionFile)
|
|
70
|
-
continue;
|
|
71
|
-
let hits = fileScanCache.get(definitionFile);
|
|
72
|
-
if (!hits) {
|
|
73
|
-
hits = await scanFileForPlainCreateMiddleware(definitionFile);
|
|
74
|
-
fileScanCache.set(definitionFile, hits);
|
|
75
|
-
}
|
|
76
|
-
if (hits.length === 0)
|
|
77
|
-
continue;
|
|
78
|
-
// Report the first hit — a file may contain many, but the chain-level
|
|
79
|
-
// signal is "this middleware file has at least one regression candidate".
|
|
80
|
-
const first = hits[0];
|
|
81
|
-
if (!first)
|
|
82
|
-
continue;
|
|
83
|
-
findings.push({
|
|
84
|
-
chain_scope: chain.scope,
|
|
85
|
-
chain_length: chain.entries.length,
|
|
86
|
-
middleware_name: entry.name,
|
|
87
|
-
file: definitionFile,
|
|
88
|
-
line: first.line,
|
|
89
|
-
reason: "plain_createMiddleware_no_generic",
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return {
|
|
94
|
-
findings,
|
|
95
|
-
total: findings.length,
|
|
96
|
-
note: HEURISTIC_NOTE,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Resolve the file that defines a middleware based on the caller file and
|
|
101
|
-
* the optional import specifier. Returns the absolute path, or null if the
|
|
102
|
-
* import specifier is third-party (bare module) or can't be resolved on disk.
|
|
103
|
-
*/
|
|
104
|
-
function resolveDefinitionFile(callerFile, importSpec) {
|
|
105
|
-
if (!importSpec) {
|
|
106
|
-
// No import record — middleware is defined in the same file as the caller.
|
|
107
|
-
return existsSync(callerFile) ? callerFile : null;
|
|
108
|
-
}
|
|
109
|
-
if (!importSpec.startsWith(".")) {
|
|
110
|
-
// Bare module specifier — third-party, nothing to scan.
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
const base = pathResolve(dirname(callerFile), importSpec);
|
|
114
|
-
const candidates = [
|
|
115
|
-
base,
|
|
116
|
-
`${base}.ts`,
|
|
117
|
-
`${base}.tsx`,
|
|
118
|
-
`${base}.js`,
|
|
119
|
-
`${base}.jsx`,
|
|
120
|
-
join(base, "index.ts"),
|
|
121
|
-
join(base, "index.tsx"),
|
|
122
|
-
join(base, "index.js"),
|
|
123
|
-
join(base, "index.jsx"),
|
|
124
|
-
];
|
|
125
|
-
for (const candidate of candidates) {
|
|
126
|
-
if (existsSync(candidate))
|
|
127
|
-
return candidate;
|
|
128
|
-
}
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
async function scanFileForPlainCreateMiddleware(file) {
|
|
132
|
-
let source;
|
|
133
|
-
try {
|
|
134
|
-
source = await readFile(file, "utf-8");
|
|
135
|
-
}
|
|
136
|
-
catch {
|
|
137
|
-
return [];
|
|
138
|
-
}
|
|
139
|
-
const hits = [];
|
|
140
|
-
// Reset regex state per scan (global flag retains lastIndex).
|
|
141
|
-
PLAIN_CREATE_MIDDLEWARE.lastIndex = 0;
|
|
142
|
-
let m;
|
|
143
|
-
while ((m = PLAIN_CREATE_MIDDLEWARE.exec(source)) !== null) {
|
|
144
|
-
const line = source.slice(0, m.index).split("\n").length;
|
|
145
|
-
hits.push({ line });
|
|
146
|
-
}
|
|
147
|
-
return hits;
|
|
148
|
-
}
|
|
149
|
-
function resolveHonoEntryFile(index) {
|
|
150
|
-
for (const sym of index.symbols) {
|
|
151
|
-
if (sym.source && /new\s+(?:Hono|OpenAPIHono)\s*(?:<[^>]*>)?\s*\(/.test(sym.source)) {
|
|
152
|
-
return join(index.root, sym.file);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
//# sourceMappingURL=hono-env-regression.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hono-env-regression.js","sourceRoot":"","sources":["../../src/tools/hono-env-regression.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAmBrC,MAAM,cAAc,GAClB,mLAAmL,CAAC;AAEtL;;;;;;;;;;GAUG;AACH,MAAM,uBAAuB,GAAG,kCAAkC,CAAC;AAEnE,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,IAAY;IAEZ,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,IAAI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