@stupidloud/codegraph 0.7.20 → 0.8.1
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 +38 -48
- package/dist/bin/codegraph.js +25 -0
- package/dist/bin/codegraph.js.map +1 -1
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +63 -37
- package/dist/extraction/index.js.map +1 -1
- package/dist/installer/config-writer.d.ts.map +1 -1
- package/dist/installer/config-writer.js +3 -1
- package/dist/installer/config-writer.js.map +1 -1
- package/dist/installer/index.d.ts +12 -0
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +72 -4
- package/dist/installer/index.js.map +1 -1
- package/dist/installer/instructions-template.d.ts +2 -2
- package/dist/installer/instructions-template.d.ts.map +1 -1
- package/dist/installer/instructions-template.js +4 -2
- package/dist/installer/instructions-template.js.map +1 -1
- package/dist/installer/targets/claude.d.ts +10 -6
- package/dist/installer/targets/claude.d.ts.map +1 -1
- package/dist/installer/targets/claude.js +72 -10
- package/dist/installer/targets/claude.js.map +1 -1
- package/dist/mcp/index.d.ts +8 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +116 -18
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/server-instructions.d.ts +1 -1
- package/dist/mcp/server-instructions.d.ts.map +1 -1
- package/dist/mcp/server-instructions.js +15 -0
- package/dist/mcp/server-instructions.js.map +1 -1
- package/dist/mcp/tools.d.ts +14 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +90 -15
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/transport.d.ts +17 -0
- package/dist/mcp/transport.d.ts.map +1 -1
- package/dist/mcp/transport.js +63 -0
- package/dist/mcp/transport.js.map +1 -1
- package/dist/resolution/frameworks/index.d.ts +1 -0
- package/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/dist/resolution/frameworks/index.js +5 -1
- package/dist/resolution/frameworks/index.js.map +1 -1
- package/dist/resolution/frameworks/nestjs.d.ts +26 -0
- package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
- package/dist/resolution/frameworks/nestjs.js +374 -0
- package/dist/resolution/frameworks/nestjs.js.map +1 -0
- package/dist/sync/git-hooks.d.ts +45 -0
- package/dist/sync/git-hooks.d.ts.map +1 -0
- package/dist/sync/git-hooks.js +223 -0
- package/dist/sync/git-hooks.js.map +1 -0
- package/dist/sync/index.d.ts +4 -0
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +12 -1
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/watch-policy.d.ts +48 -0
- package/dist/sync/watch-policy.d.ts.map +1 -0
- package/dist/sync/watch-policy.js +124 -0
- package/dist/sync/watch-policy.js.map +1 -0
- package/dist/sync/watcher.d.ts.map +1 -1
- package/dist/sync/watcher.js +10 -0
- package/dist/sync/watcher.js.map +1 -1
- package/package.json +3 -3
- package/scripts/agent-eval/audit.sh +68 -0
- package/scripts/agent-eval/itrun.sh +1 -1
- package/scripts/agent-eval/run-all.sh +67 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Manages framework-specific resolvers.
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.vaporResolver = exports.uikitResolver = exports.swiftUIResolver = exports.aspnetResolver = exports.rustResolver = exports.goResolver = exports.springResolver = exports.railsResolver = exports.fastapiResolver = exports.flaskResolver = exports.djangoResolver = exports.vueResolver = exports.svelteResolver = exports.reactResolver = exports.expressResolver = exports.FACADE_MAPPINGS = exports.laravelResolver = void 0;
|
|
8
|
+
exports.vaporResolver = exports.uikitResolver = exports.swiftUIResolver = exports.aspnetResolver = exports.rustResolver = exports.goResolver = exports.springResolver = exports.railsResolver = exports.fastapiResolver = exports.flaskResolver = exports.djangoResolver = exports.vueResolver = exports.svelteResolver = exports.reactResolver = exports.nestjsResolver = exports.expressResolver = exports.FACADE_MAPPINGS = exports.laravelResolver = void 0;
|
|
9
9
|
exports.getAllFrameworkResolvers = getAllFrameworkResolvers;
|
|
10
10
|
exports.getFrameworkResolver = getFrameworkResolver;
|
|
11
11
|
exports.detectFrameworks = detectFrameworks;
|
|
@@ -13,6 +13,7 @@ exports.getApplicableFrameworks = getApplicableFrameworks;
|
|
|
13
13
|
exports.registerFrameworkResolver = registerFrameworkResolver;
|
|
14
14
|
const laravel_1 = require("./laravel");
|
|
15
15
|
const express_1 = require("./express");
|
|
16
|
+
const nestjs_1 = require("./nestjs");
|
|
16
17
|
const react_1 = require("./react");
|
|
17
18
|
const svelte_1 = require("./svelte");
|
|
18
19
|
const vue_1 = require("./vue");
|
|
@@ -31,6 +32,7 @@ const FRAMEWORK_RESOLVERS = [
|
|
|
31
32
|
laravel_1.laravelResolver,
|
|
32
33
|
// JavaScript/TypeScript
|
|
33
34
|
express_1.expressResolver,
|
|
35
|
+
nestjs_1.nestjsResolver,
|
|
34
36
|
react_1.reactResolver,
|
|
35
37
|
svelte_1.svelteResolver,
|
|
36
38
|
vue_1.vueResolver,
|
|
@@ -102,6 +104,8 @@ Object.defineProperty(exports, "laravelResolver", { enumerable: true, get: funct
|
|
|
102
104
|
Object.defineProperty(exports, "FACADE_MAPPINGS", { enumerable: true, get: function () { return laravel_2.FACADE_MAPPINGS; } });
|
|
103
105
|
var express_2 = require("./express");
|
|
104
106
|
Object.defineProperty(exports, "expressResolver", { enumerable: true, get: function () { return express_2.expressResolver; } });
|
|
107
|
+
var nestjs_2 = require("./nestjs");
|
|
108
|
+
Object.defineProperty(exports, "nestjsResolver", { enumerable: true, get: function () { return nestjs_2.nestjsResolver; } });
|
|
105
109
|
var react_2 = require("./react");
|
|
106
110
|
Object.defineProperty(exports, "reactResolver", { enumerable: true, get: function () { return react_2.reactResolver; } });
|
|
107
111
|
var svelte_2 = require("./svelte");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/resolution/frameworks/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/resolution/frameworks/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAqDH,4DAEC;AAKD,oDAEC;AAKD,4CAQC;AAMD,0DAOC;AAKD,8DAOC;AAhGD,uCAA4C;AAC5C,uCAA4C;AAC5C,qCAA0C;AAC1C,mCAAwC;AACxC,qCAA0C;AAC1C,+BAAoC;AACpC,qCAA0E;AAC1E,iCAAuC;AACvC,iCAAwC;AACxC,6BAAkC;AAClC,iCAAsC;AACtC,qCAA0C;AAC1C,mCAAwE;AAExE;;GAEG;AACH,MAAM,mBAAmB,GAAwB;IAC/C,MAAM;IACN,yBAAe;IACf,wBAAwB;IACxB,yBAAe;IACf,uBAAc;IACd,qBAAa;IACb,uBAAc;IACd,iBAAW;IACX,SAAS;IACT,uBAAc;IACd,sBAAa;IACb,wBAAe;IACf,OAAO;IACP,oBAAa;IACb,OAAO;IACP,qBAAc;IACd,KAAK;IACL,eAAU;IACV,OAAO;IACP,mBAAY;IACZ,KAAK;IACL,uBAAc;IACd,QAAQ;IACR,uBAAe;IACf,qBAAa;IACb,qBAAa;CACd,CAAC;AAEF;;GAEG;AACH,SAAgB,wBAAwB;IACtC,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAC1D,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,OAA0B;IACzD,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC7C,IAAI,CAAC;YACH,OAAO,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,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A,cAAc,OAAA;AACvB,iCAAwE;AAA/D,wGAAA,eAAe,OAAA;AAAE,sGAAA,aAAa,OAAA;AAAE,sGAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NestJS Framework Resolver
|
|
3
|
+
*
|
|
4
|
+
* Handles NestJS decorator-based routing across its transport layers:
|
|
5
|
+
* - HTTP: @Controller(prefix) + @Get/@Post/@Put/@Patch/@Delete/@Head/@Options/@All
|
|
6
|
+
* - GraphQL: @Resolver + @Query/@Mutation/@Subscription
|
|
7
|
+
* - Microservices: @MessagePattern / @EventPattern
|
|
8
|
+
* - WebSockets: @WebSocketGateway(namespace) + @SubscribeMessage(event)
|
|
9
|
+
*
|
|
10
|
+
* Like the other framework extractors this is regex-over-source (comment-
|
|
11
|
+
* stripped), not AST traversal. NestJS differs from Spring/ASP.NET in two ways
|
|
12
|
+
* that this resolver has to account for:
|
|
13
|
+
*
|
|
14
|
+
* 1. An HTTP route's path is split across TWO decorators — the class-level
|
|
15
|
+
* `@Controller` prefix and the method-level `@Get`/`@Post` path — and both
|
|
16
|
+
* are frequently empty (`@Controller()`, `@Get()`). We pair each method
|
|
17
|
+
* decorator with its enclosing class and join the two paths.
|
|
18
|
+
*
|
|
19
|
+
* 2. `@Query()` is overloaded: it's a GraphQL *method* decorator (from
|
|
20
|
+
* `@nestjs/graphql`) AND a REST *parameter* decorator (from
|
|
21
|
+
* `@nestjs/common`). We only treat it as GraphQL when it sits inside an
|
|
22
|
+
* `@Resolver` class, which is what disambiguates the two.
|
|
23
|
+
*/
|
|
24
|
+
import { FrameworkResolver } from '../types';
|
|
25
|
+
export declare const nestjsResolver: FrameworkResolver;
|
|
26
|
+
//# sourceMappingURL=nestjs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestjs.d.ts","sourceRoot":"","sources":["../../../src/resolution/frameworks/nestjs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EACL,iBAAiB,EAIlB,MAAM,UAAU,CAAC;AAQlB,eAAO,MAAM,cAAc,EAAE,iBAqJ5B,CAAC"}
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* NestJS Framework Resolver
|
|
4
|
+
*
|
|
5
|
+
* Handles NestJS decorator-based routing across its transport layers:
|
|
6
|
+
* - HTTP: @Controller(prefix) + @Get/@Post/@Put/@Patch/@Delete/@Head/@Options/@All
|
|
7
|
+
* - GraphQL: @Resolver + @Query/@Mutation/@Subscription
|
|
8
|
+
* - Microservices: @MessagePattern / @EventPattern
|
|
9
|
+
* - WebSockets: @WebSocketGateway(namespace) + @SubscribeMessage(event)
|
|
10
|
+
*
|
|
11
|
+
* Like the other framework extractors this is regex-over-source (comment-
|
|
12
|
+
* stripped), not AST traversal. NestJS differs from Spring/ASP.NET in two ways
|
|
13
|
+
* that this resolver has to account for:
|
|
14
|
+
*
|
|
15
|
+
* 1. An HTTP route's path is split across TWO decorators — the class-level
|
|
16
|
+
* `@Controller` prefix and the method-level `@Get`/`@Post` path — and both
|
|
17
|
+
* are frequently empty (`@Controller()`, `@Get()`). We pair each method
|
|
18
|
+
* decorator with its enclosing class and join the two paths.
|
|
19
|
+
*
|
|
20
|
+
* 2. `@Query()` is overloaded: it's a GraphQL *method* decorator (from
|
|
21
|
+
* `@nestjs/graphql`) AND a REST *parameter* decorator (from
|
|
22
|
+
* `@nestjs/common`). We only treat it as GraphQL when it sits inside an
|
|
23
|
+
* `@Resolver` class, which is what disambiguates the two.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.nestjsResolver = void 0;
|
|
27
|
+
const strip_comments_1 = require("../strip-comments");
|
|
28
|
+
const HTTP_METHODS = ['Get', 'Post', 'Put', 'Patch', 'Delete', 'Head', 'Options', 'All'];
|
|
29
|
+
const GQL_OPS = ['Query', 'Mutation', 'Subscription'];
|
|
30
|
+
exports.nestjsResolver = {
|
|
31
|
+
name: 'nestjs',
|
|
32
|
+
languages: ['typescript', 'javascript'],
|
|
33
|
+
detect(context) {
|
|
34
|
+
// Primary, fast path: any @nestjs/* dependency in package.json.
|
|
35
|
+
const packageJson = context.readFile('package.json');
|
|
36
|
+
if (packageJson) {
|
|
37
|
+
try {
|
|
38
|
+
const pkg = JSON.parse(packageJson);
|
|
39
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
40
|
+
if (Object.keys(deps).some((k) => k.startsWith('@nestjs/'))) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Invalid JSON — fall through to the source scan.
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Fallback: NestJS-specific decorators in conventionally named files.
|
|
49
|
+
const allFiles = context.getAllFiles();
|
|
50
|
+
for (const file of allFiles) {
|
|
51
|
+
if (file.endsWith('.controller.ts') ||
|
|
52
|
+
file.endsWith('.controller.js') ||
|
|
53
|
+
file.endsWith('.module.ts') ||
|
|
54
|
+
file.endsWith('.resolver.ts') ||
|
|
55
|
+
file.endsWith('.gateway.ts')) {
|
|
56
|
+
const content = context.readFile(file);
|
|
57
|
+
if (content &&
|
|
58
|
+
(content.includes('@nestjs/') ||
|
|
59
|
+
content.includes('@Controller') ||
|
|
60
|
+
content.includes('@Module(') ||
|
|
61
|
+
content.includes('@Resolver(') ||
|
|
62
|
+
content.includes('@WebSocketGateway('))) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
},
|
|
69
|
+
resolve(ref, context) {
|
|
70
|
+
// Resolve provider/controller references (e.g. constructor-injected
|
|
71
|
+
// `UsersService`) to their class, preferring the Nest file-name
|
|
72
|
+
// convention (`*.service.ts`, `*.controller.ts`, …).
|
|
73
|
+
for (const [suffix, convention] of PROVIDER_CONVENTIONS) {
|
|
74
|
+
if (!suffix.test(ref.referenceName))
|
|
75
|
+
continue;
|
|
76
|
+
const candidates = context
|
|
77
|
+
.getNodesByName(ref.referenceName)
|
|
78
|
+
.filter((n) => n.kind === 'class');
|
|
79
|
+
if (candidates.length === 0)
|
|
80
|
+
return null;
|
|
81
|
+
const preferred = candidates.find((n) => n.filePath.includes(convention));
|
|
82
|
+
const target = preferred ?? candidates[0];
|
|
83
|
+
return {
|
|
84
|
+
original: ref,
|
|
85
|
+
targetNodeId: target.id,
|
|
86
|
+
confidence: preferred ? 0.85 : 0.7,
|
|
87
|
+
resolvedBy: 'framework',
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
},
|
|
92
|
+
extract(filePath, content) {
|
|
93
|
+
if (!/\.(m?js|tsx?|cjs)$/.test(filePath))
|
|
94
|
+
return { nodes: [], references: [] };
|
|
95
|
+
const nodes = [];
|
|
96
|
+
const references = [];
|
|
97
|
+
const now = Date.now();
|
|
98
|
+
const lang = detectLanguage(filePath);
|
|
99
|
+
const safe = (0, strip_comments_1.stripCommentsForRegex)(content, lang);
|
|
100
|
+
const addRoute = (index, method, path, length, handler) => {
|
|
101
|
+
const line = lineAt(safe, index);
|
|
102
|
+
const node = {
|
|
103
|
+
id: `route:${filePath}:${line}:${method}:${path}`,
|
|
104
|
+
kind: 'route',
|
|
105
|
+
name: `${method} ${path}`,
|
|
106
|
+
qualifiedName: `${filePath}::${method}:${path}`,
|
|
107
|
+
filePath,
|
|
108
|
+
startLine: line,
|
|
109
|
+
endLine: line,
|
|
110
|
+
startColumn: 0,
|
|
111
|
+
endColumn: length,
|
|
112
|
+
language: lang,
|
|
113
|
+
updatedAt: now,
|
|
114
|
+
};
|
|
115
|
+
nodes.push(node);
|
|
116
|
+
if (handler) {
|
|
117
|
+
references.push({
|
|
118
|
+
fromNodeId: node.id,
|
|
119
|
+
referenceName: handler,
|
|
120
|
+
referenceKind: 'references',
|
|
121
|
+
line,
|
|
122
|
+
column: 0,
|
|
123
|
+
filePath,
|
|
124
|
+
language: lang,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const scopes = buildClassScopes(safe);
|
|
129
|
+
// HTTP routes: method decorator path joined onto the enclosing controller's prefix.
|
|
130
|
+
for (const hit of findDecorators(safe, HTTP_METHODS)) {
|
|
131
|
+
const scope = scopeFor(scopes, hit.index);
|
|
132
|
+
const prefix = scope && scope.kind === 'controller' ? scope.prefix : '';
|
|
133
|
+
const path = joinHttpPath(prefix, parseStringArg(hit.args));
|
|
134
|
+
addRoute(hit.index, hit.name.toUpperCase(), path, hit.length, methodNameAfter(safe, hit.end));
|
|
135
|
+
}
|
|
136
|
+
// GraphQL operations: only inside an @Resolver class (disambiguates the
|
|
137
|
+
// REST `@Query()` parameter decorator, which lives inside @Controller classes).
|
|
138
|
+
for (const hit of findDecorators(safe, GQL_OPS)) {
|
|
139
|
+
const scope = scopeFor(scopes, hit.index);
|
|
140
|
+
if (!scope || scope.kind !== 'resolver')
|
|
141
|
+
continue;
|
|
142
|
+
const handler = methodNameAfter(safe, hit.end);
|
|
143
|
+
const name = parseGraphqlName(hit.args, handler);
|
|
144
|
+
addRoute(hit.index, hit.name.toUpperCase(), name, hit.length, handler);
|
|
145
|
+
}
|
|
146
|
+
// Microservice message/event handlers.
|
|
147
|
+
for (const hit of findDecorators(safe, ['MessagePattern', 'EventPattern'])) {
|
|
148
|
+
const verb = hit.name === 'EventPattern' ? 'EVENT' : 'MESSAGE';
|
|
149
|
+
const handler = methodNameAfter(safe, hit.end);
|
|
150
|
+
addRoute(hit.index, verb, parseStringArg(hit.args) || handler || '', hit.length, handler);
|
|
151
|
+
}
|
|
152
|
+
// WebSocket message handlers, prefixed with the gateway namespace when present.
|
|
153
|
+
for (const hit of findDecorators(safe, ['SubscribeMessage'])) {
|
|
154
|
+
const scope = scopeFor(scopes, hit.index);
|
|
155
|
+
const namespace = scope && scope.kind === 'gateway' ? scope.prefix : '';
|
|
156
|
+
const handler = methodNameAfter(safe, hit.end);
|
|
157
|
+
const event = parseStringArg(hit.args) || handler || '';
|
|
158
|
+
addRoute(hit.index, 'WS', namespace ? `${namespace}:${event}` : event, hit.length, handler);
|
|
159
|
+
}
|
|
160
|
+
return { nodes, references };
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
// Provider resolution conventions
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
const PROVIDER_CONVENTIONS = [
|
|
167
|
+
[/Service$/, '.service.'],
|
|
168
|
+
[/Controller$/, '.controller.'],
|
|
169
|
+
[/Resolver$/, '.resolver.'],
|
|
170
|
+
[/Gateway$/, '.gateway.'],
|
|
171
|
+
[/Repository$/, '.repository.'],
|
|
172
|
+
[/Guard$/, '.guard.'],
|
|
173
|
+
[/Interceptor$/, '.interceptor.'],
|
|
174
|
+
[/Pipe$/, '.pipe.'],
|
|
175
|
+
[/Module$/, '.module.'],
|
|
176
|
+
];
|
|
177
|
+
/**
|
|
178
|
+
* Find every `@Name(...)` decorator whose name is in `names`. Uses a
|
|
179
|
+
* string-aware balanced-paren reader for the argument list so type thunks
|
|
180
|
+
* like `@Query(() => [User])` are captured whole rather than truncated at the
|
|
181
|
+
* inner `()`.
|
|
182
|
+
*/
|
|
183
|
+
function findDecorators(safe, names) {
|
|
184
|
+
const hits = [];
|
|
185
|
+
const re = new RegExp(`@(${names.join('|')})\\s*\\(`, 'g');
|
|
186
|
+
let m;
|
|
187
|
+
while ((m = re.exec(safe)) !== null) {
|
|
188
|
+
const openIndex = m.index + m[0].length - 1; // position of '('
|
|
189
|
+
const parsed = readArgs(safe, openIndex);
|
|
190
|
+
if (!parsed)
|
|
191
|
+
continue;
|
|
192
|
+
hits.push({
|
|
193
|
+
name: m[1],
|
|
194
|
+
args: parsed.args,
|
|
195
|
+
index: m.index,
|
|
196
|
+
end: parsed.end,
|
|
197
|
+
length: parsed.end - m.index,
|
|
198
|
+
});
|
|
199
|
+
re.lastIndex = parsed.end; // resume past the args so nested text isn't re-scanned
|
|
200
|
+
}
|
|
201
|
+
return hits;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Read a balanced `(...)` starting at `openIndex` (which must point at `(`).
|
|
205
|
+
* String-aware, so parens inside string literals don't unbalance the count.
|
|
206
|
+
* Returns the inner text and the index just past the closing `)`.
|
|
207
|
+
*/
|
|
208
|
+
function readArgs(s, openIndex) {
|
|
209
|
+
if (s[openIndex] !== '(')
|
|
210
|
+
return null;
|
|
211
|
+
let depth = 0;
|
|
212
|
+
let inStr = null;
|
|
213
|
+
for (let i = openIndex; i < s.length; i++) {
|
|
214
|
+
const ch = s[i];
|
|
215
|
+
if (inStr) {
|
|
216
|
+
if (ch === '\\') {
|
|
217
|
+
i++;
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
if (ch === inStr)
|
|
221
|
+
inStr = null;
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if (ch === '"' || ch === "'" || ch === '`') {
|
|
225
|
+
inStr = ch;
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (ch === '(')
|
|
229
|
+
depth++;
|
|
230
|
+
else if (ch === ')') {
|
|
231
|
+
depth--;
|
|
232
|
+
if (depth === 0)
|
|
233
|
+
return { args: s.slice(openIndex + 1, i), end: i + 1 };
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Starting just after a method decorator's `)`, return the name of the method
|
|
240
|
+
* it decorates. Skips any further stacked decorators (`@UseGuards(...)`,
|
|
241
|
+
* `@HttpCode(204)`, …) and access/async modifiers in between.
|
|
242
|
+
*/
|
|
243
|
+
function methodNameAfter(safe, start) {
|
|
244
|
+
let i = start;
|
|
245
|
+
const ws = /\s*/y;
|
|
246
|
+
const decoName = /@[\w.]+/y;
|
|
247
|
+
const modifier = /(?:public|private|protected|async|static)\b/y;
|
|
248
|
+
const ident = /([A-Za-z_$][\w$]*)\s*\(/y;
|
|
249
|
+
const eatWs = () => {
|
|
250
|
+
ws.lastIndex = i;
|
|
251
|
+
if (ws.exec(safe))
|
|
252
|
+
i = ws.lastIndex;
|
|
253
|
+
};
|
|
254
|
+
// Skip stacked decorators.
|
|
255
|
+
for (;;) {
|
|
256
|
+
eatWs();
|
|
257
|
+
if (safe[i] !== '@')
|
|
258
|
+
break;
|
|
259
|
+
decoName.lastIndex = i;
|
|
260
|
+
if (!decoName.exec(safe))
|
|
261
|
+
break;
|
|
262
|
+
i = decoName.lastIndex;
|
|
263
|
+
eatWs();
|
|
264
|
+
if (safe[i] === '(') {
|
|
265
|
+
const parsed = readArgs(safe, i);
|
|
266
|
+
if (!parsed)
|
|
267
|
+
return null;
|
|
268
|
+
i = parsed.end;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
// Skip access/async/static modifiers.
|
|
272
|
+
for (;;) {
|
|
273
|
+
eatWs();
|
|
274
|
+
modifier.lastIndex = i;
|
|
275
|
+
if (modifier.exec(safe) && modifier.lastIndex > i) {
|
|
276
|
+
i = modifier.lastIndex;
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
eatWs();
|
|
282
|
+
ident.lastIndex = i;
|
|
283
|
+
const m = ident.exec(safe);
|
|
284
|
+
return m ? m[1] : null;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Build the list of class-level decorator scopes, sorted by position. Each
|
|
288
|
+
* scope runs from its decorator up to the next class decorator (of any kind),
|
|
289
|
+
* which lets a method decorator find its enclosing class regardless of how
|
|
290
|
+
* many classes share a file.
|
|
291
|
+
*/
|
|
292
|
+
function buildClassScopes(safe) {
|
|
293
|
+
const defs = [
|
|
294
|
+
{ kind: 'controller', name: 'Controller', prefixOf: parseControllerPrefix },
|
|
295
|
+
{ kind: 'resolver', name: 'Resolver', prefixOf: () => '' },
|
|
296
|
+
{ kind: 'gateway', name: 'WebSocketGateway', prefixOf: parseGatewayNamespace },
|
|
297
|
+
{ kind: 'other', name: 'Injectable', prefixOf: () => '' },
|
|
298
|
+
{ kind: 'other', name: 'Module', prefixOf: () => '' },
|
|
299
|
+
{ kind: 'other', name: 'Catch', prefixOf: () => '' },
|
|
300
|
+
];
|
|
301
|
+
const raw = [];
|
|
302
|
+
for (const def of defs) {
|
|
303
|
+
for (const hit of findDecorators(safe, [def.name])) {
|
|
304
|
+
raw.push({ kind: def.kind, prefix: def.prefixOf(hit.args), index: hit.index });
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
raw.sort((a, b) => a.index - b.index);
|
|
308
|
+
return raw.map((r, i) => ({
|
|
309
|
+
kind: r.kind,
|
|
310
|
+
prefix: r.prefix,
|
|
311
|
+
start: r.index,
|
|
312
|
+
end: i + 1 < raw.length ? raw[i + 1].index : safe.length,
|
|
313
|
+
}));
|
|
314
|
+
}
|
|
315
|
+
function scopeFor(scopes, index) {
|
|
316
|
+
for (const s of scopes) {
|
|
317
|
+
if (index >= s.start && index < s.end)
|
|
318
|
+
return s;
|
|
319
|
+
}
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
// ---------------------------------------------------------------------------
|
|
323
|
+
// Argument parsing
|
|
324
|
+
// ---------------------------------------------------------------------------
|
|
325
|
+
/** First string literal anywhere in the args, or '' (covers `'x'`, `{ k: 'x' }`). */
|
|
326
|
+
function parseStringArg(args) {
|
|
327
|
+
const m = args.match(/['"`]([^'"`]*)['"`]/);
|
|
328
|
+
return m ? m[1] : '';
|
|
329
|
+
}
|
|
330
|
+
/** `@Controller('users')` | `@Controller({ path: 'users', host })` | `@Controller(['a','b'])` | `@Controller()`. */
|
|
331
|
+
function parseControllerPrefix(args) {
|
|
332
|
+
const obj = args.match(/path\s*:\s*['"`]([^'"`]*)['"`]/);
|
|
333
|
+
if (obj)
|
|
334
|
+
return obj[1];
|
|
335
|
+
return parseStringArg(args);
|
|
336
|
+
}
|
|
337
|
+
/** `@WebSocketGateway({ namespace: 'chat' })` | `@WebSocketGateway(81, { namespace: '/chat' })` | `@WebSocketGateway()`. */
|
|
338
|
+
function parseGatewayNamespace(args) {
|
|
339
|
+
const m = args.match(/namespace\s*:\s*['"`]([^'"`]*)['"`]/);
|
|
340
|
+
return m ? m[1] : '';
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* GraphQL operation name. Prefers an explicit `{ name: 'x' }` or a leading
|
|
344
|
+
* string literal (`@Query('users')`); otherwise the field name defaults to the
|
|
345
|
+
* handler method name. Avoids mistaking a `description` string for the name.
|
|
346
|
+
*/
|
|
347
|
+
function parseGraphqlName(args, handler) {
|
|
348
|
+
const named = args.match(/name\s*:\s*['"`]([^'"`]*)['"`]/);
|
|
349
|
+
if (named)
|
|
350
|
+
return named[1];
|
|
351
|
+
const lead = args.match(/^\s*['"`]([^'"`]*)['"`]/);
|
|
352
|
+
if (lead)
|
|
353
|
+
return lead[1];
|
|
354
|
+
return handler ?? '';
|
|
355
|
+
}
|
|
356
|
+
// ---------------------------------------------------------------------------
|
|
357
|
+
// Path helpers
|
|
358
|
+
// ---------------------------------------------------------------------------
|
|
359
|
+
/** Join a controller prefix and method path into a single normalised `/path`. */
|
|
360
|
+
function joinHttpPath(prefix, sub) {
|
|
361
|
+
const parts = [prefix, sub]
|
|
362
|
+
.map((p) => p.trim().replace(/^\/+|\/+$/g, ''))
|
|
363
|
+
.filter((p) => p.length > 0);
|
|
364
|
+
return '/' + parts.join('/');
|
|
365
|
+
}
|
|
366
|
+
function lineAt(safe, index) {
|
|
367
|
+
return safe.slice(0, index).split('\n').length;
|
|
368
|
+
}
|
|
369
|
+
function detectLanguage(filePath) {
|
|
370
|
+
if (filePath.endsWith('.ts') || filePath.endsWith('.tsx'))
|
|
371
|
+
return 'typescript';
|
|
372
|
+
return 'javascript';
|
|
373
|
+
}
|
|
374
|
+
//# sourceMappingURL=nestjs.js.map
|
|
@@ -0,0 +1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C,YAAY,EAAE,EAAE,CAAC,CAAC;SAC9C,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC/B,OAAO,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,MAAM,CAAC,IAAY,EAAE,KAAa;IACzC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;AACjD,CAAC;AAED,SAAS,cAAc,CAAC,QAAgB;IACtC,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,YAAY,CAAC;IAC/E,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Sync Hooks
|
|
3
|
+
*
|
|
4
|
+
* When the live file watcher is disabled (e.g. on WSL2 `/mnt/*` drives,
|
|
5
|
+
* see watch-policy.ts), the CodeGraph index would otherwise go stale until
|
|
6
|
+
* the user runs `codegraph sync` by hand. As an opt-in alternative, we can
|
|
7
|
+
* install git hooks that refresh the index after the operations that change
|
|
8
|
+
* files on disk: commit, merge (covers `git pull`), and checkout.
|
|
9
|
+
*
|
|
10
|
+
* The hooks run `codegraph sync` in the background so they never block git,
|
|
11
|
+
* and are guarded by `command -v codegraph` so they no-op cleanly when the
|
|
12
|
+
* CLI isn't on PATH. Our snippet is delimited by marker comments so install
|
|
13
|
+
* is idempotent and removal preserves any user-authored hook content.
|
|
14
|
+
*/
|
|
15
|
+
export type GitHookName = 'post-commit' | 'post-merge' | 'post-checkout';
|
|
16
|
+
/** Hooks installed by default: commit, merge (git pull), and checkout. */
|
|
17
|
+
export declare const DEFAULT_SYNC_HOOKS: GitHookName[];
|
|
18
|
+
export interface GitHookResult {
|
|
19
|
+
/** Hook names that were created or updated. */
|
|
20
|
+
installed: GitHookName[];
|
|
21
|
+
/** Resolved hooks directory, or null when not a git repo. */
|
|
22
|
+
hooksDir: string | null;
|
|
23
|
+
/** Reason nothing happened (e.g. not a git repository). */
|
|
24
|
+
skipped?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Whether `projectRoot` is inside a git working tree. Returns false if git
|
|
28
|
+
* isn't installed or the path isn't a repo.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isGitRepo(projectRoot: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Install (or update) the CodeGraph sync hooks in a git repository.
|
|
33
|
+
* Idempotent: re-running replaces our marker block rather than duplicating
|
|
34
|
+
* it, and any user-authored hook content is preserved.
|
|
35
|
+
*/
|
|
36
|
+
export declare function installGitSyncHook(projectRoot: string, hooks?: GitHookName[]): GitHookResult;
|
|
37
|
+
/**
|
|
38
|
+
* Remove the CodeGraph sync hooks. Strips only our marker block; deletes the
|
|
39
|
+
* hook file entirely when nothing but a shebang remains, otherwise rewrites
|
|
40
|
+
* the user's content untouched.
|
|
41
|
+
*/
|
|
42
|
+
export declare function removeGitSyncHook(projectRoot: string, hooks?: GitHookName[]): GitHookResult;
|
|
43
|
+
/** Whether any CodeGraph sync hook is currently installed. */
|
|
44
|
+
export declare function isSyncHookInstalled(projectRoot: string, hooks?: GitHookName[]): boolean;
|
|
45
|
+
//# sourceMappingURL=git-hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-hooks.d.ts","sourceRoot":"","sources":["../../src/sync/git-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AASH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,YAAY,GAAG,eAAe,CAAC;AAEzE,0EAA0E;AAC1E,eAAO,MAAM,kBAAkB,EAAE,WAAW,EAAmD,CAAC;AAEhG,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAWtD;AAgED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,EACnB,KAAK,GAAE,WAAW,EAAuB,GACxC,aAAa,CAmCf;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,KAAK,GAAE,WAAW,EAAuB,GACxC,aAAa,CA0Bf;AAED,8DAA8D;AAC9D,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,KAAK,GAAE,WAAW,EAAuB,GACxC,OAAO,CAOT"}
|