carrick 0.3.148 → 0.3.149
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/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/sidecar/dist/src/capture/index.d.ts +1 -1
- package/sidecar/dist/src/capture/index.js +1 -1
- package/sidecar/dist/src/capture/project-references.d.ts +6 -0
- package/sidecar/dist/src/capture/project-references.js +11 -1
- package/sidecar/dist/src/capture/service-config.d.ts +40 -10
- package/sidecar/dist/src/capture/service-config.js +83 -33
- package/sidecar/dist/src/library-claims.js +4 -2
- package/sidecar/dist/src/position-rows.d.ts +12 -2
- package/sidecar/dist/src/position-rows.js +46 -1
- package/sidecar/dist/src/project-loader.d.ts +12 -24
- package/sidecar/dist/src/project-loader.js +19 -46
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carrick",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.149",
|
|
4
4
|
"carrickCache": {
|
|
5
5
|
"cache_version": 22,
|
|
6
6
|
"intent_cache_version": 2
|
|
@@ -115,11 +115,11 @@
|
|
|
115
115
|
"zod": "^3.23.0"
|
|
116
116
|
},
|
|
117
117
|
"optionalDependencies": {
|
|
118
|
-
"@carrick-tools/cli-darwin-arm64": "0.3.
|
|
119
|
-
"@carrick-tools/cli-darwin-x64": "0.3.
|
|
120
|
-
"@carrick-tools/cli-linux-arm64": "0.3.
|
|
121
|
-
"@carrick-tools/cli-linux-x64": "0.3.
|
|
122
|
-
"@carrick-tools/cli-win32-x64": "0.3.
|
|
118
|
+
"@carrick-tools/cli-darwin-arm64": "0.3.149",
|
|
119
|
+
"@carrick-tools/cli-darwin-x64": "0.3.149",
|
|
120
|
+
"@carrick-tools/cli-linux-arm64": "0.3.149",
|
|
121
|
+
"@carrick-tools/cli-linux-x64": "0.3.149",
|
|
122
|
+
"@carrick-tools/cli-win32-x64": "0.3.149"
|
|
123
123
|
},
|
|
124
124
|
"devDependencies": {
|
|
125
125
|
"@types/node": "^24.13.3"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carrick",
|
|
3
3
|
"description": "Claude Code plugin for Carrick, which indexes TypeScript codebases across service and repository boundaries. After each edit it adds the file's routes, calls, and cross-service type mismatches to the session, and it registers Carrick's language server. It pairs with the Carrick MCP server, which lets agents search functions by intent rather than name.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.149",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Carrick",
|
|
7
7
|
"email": "hello@carrick.tools"
|
|
@@ -35,7 +35,7 @@ export { sidecarCompilerOptions } from './compiler-options.js';
|
|
|
35
35
|
export { isInsideCheckout, untrustedReadBound, UNTRUSTED_TREE_ENV, type ReadBound } from './checkout.js';
|
|
36
36
|
export { serviceConfigPath } from './project-references.js';
|
|
37
37
|
export { referenceRedirectOf } from './reference-redirect.js';
|
|
38
|
-
export { findServiceTsconfig,
|
|
38
|
+
export { findServiceTsconfig, GoverningConfigs } from './service-config.js';
|
|
39
39
|
export { WriteGuard } from './guarded-fs.js';
|
|
40
40
|
export { installedPackageDirectory } from './installed-package-directory.js';
|
|
41
41
|
export { isDeclarationFileName, packageNameOf } from './specifiers.js';
|
|
@@ -54,7 +54,7 @@ export { sidecarCompilerOptions } from './compiler-options.js';
|
|
|
54
54
|
export { isInsideCheckout, untrustedReadBound, UNTRUSTED_TREE_ENV } from './checkout.js';
|
|
55
55
|
export { serviceConfigPath } from './project-references.js';
|
|
56
56
|
export { referenceRedirectOf } from './reference-redirect.js';
|
|
57
|
-
export { findServiceTsconfig,
|
|
57
|
+
export { findServiceTsconfig, GoverningConfigs } from './service-config.js';
|
|
58
58
|
// carrick#2405: the per-position rows write through the guard, and name an
|
|
59
59
|
// installed declaring file the way the capture's resolution walk does.
|
|
60
60
|
export { WriteGuard } from './guarded-fs.js';
|
|
@@ -51,6 +51,12 @@ export declare class ProjectGraph {
|
|
|
51
51
|
* reference closure lists it. The named config when none does.
|
|
52
52
|
*/
|
|
53
53
|
ownerOf(file: string): ServiceProject;
|
|
54
|
+
/**
|
|
55
|
+
* `ownerOf` when some project in the graph lists `file`, the named config
|
|
56
|
+
* included; undefined when none does (carrick#3497: a config that lists a
|
|
57
|
+
* file nowhere is passed over for one further up).
|
|
58
|
+
*/
|
|
59
|
+
listingOwnerOf(file: string): ServiceProject | undefined;
|
|
54
60
|
/**
|
|
55
61
|
* Every project `project` reaches through its references, transitively,
|
|
56
62
|
* depth-first in declared order, without itself. Only projects this graph
|
|
@@ -68,9 +68,19 @@ export class ProjectGraph {
|
|
|
68
68
|
ownerOf(file) {
|
|
69
69
|
if (!this.hasReferences)
|
|
70
70
|
return this.named;
|
|
71
|
+
return this.listingOwnerOf(file) ?? this.named;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* `ownerOf` when some project in the graph lists `file`, the named config
|
|
75
|
+
* included; undefined when none does (carrick#3497: a config that lists a
|
|
76
|
+
* file nowhere is passed over for one further up).
|
|
77
|
+
*/
|
|
78
|
+
listingOwnerOf(file) {
|
|
71
79
|
const key = fileKey(file);
|
|
80
|
+
if (!this.hasReferences)
|
|
81
|
+
return this.namedFiles.has(key) ? this.named : undefined;
|
|
72
82
|
const owner = this.projects().find((entry) => entry.files.has(key) && !this.closure(entry.project).some((reached) => reached.files.has(key)));
|
|
73
|
-
return owner?.project
|
|
83
|
+
return owner?.project;
|
|
74
84
|
}
|
|
75
85
|
/**
|
|
76
86
|
* Every project `project` reaches through its references, transitively,
|
|
@@ -14,25 +14,55 @@
|
|
|
14
14
|
* A service-root `jsconfig.json` ranks after those names and before an
|
|
15
15
|
* ancestor `tsconfig.json` (carrick#3497): tsserver types a JavaScript file
|
|
16
16
|
* under the jsconfig beside it, not under a config above. Where no ancestor
|
|
17
|
-
* config exists the answer stays undefined, as before:
|
|
18
|
-
* typed
|
|
17
|
+
* config exists the answer stays undefined, as before: each file is then
|
|
18
|
+
* typed by `GoverningConfigs` alone, which reads the same jsconfig.
|
|
19
19
|
*
|
|
20
20
|
* The walk stops at the scan root, inclusive: a config outside the scanned
|
|
21
21
|
* tree is never read. With no scan root, or a service outside it, only the
|
|
22
22
|
* service root is searched.
|
|
23
|
+
*
|
|
24
|
+
* The service config is the fallback of the per-file rule
|
|
25
|
+
* (`GoverningConfigs`, carrick#3497): a file a config inside the service
|
|
26
|
+
* lists is typed under that config.
|
|
23
27
|
*/
|
|
24
28
|
/** Absolute path of the config that types the service, or undefined for none. */
|
|
25
29
|
export declare function findServiceTsconfig(serviceRoot: string, scanRoot?: string): string | undefined;
|
|
26
30
|
/** The path with every symlink resolved; the path as given when it does not exist. */
|
|
27
31
|
export declare function realPath(p: string): string;
|
|
28
32
|
/**
|
|
29
|
-
* The config
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
33
|
+
* The config each file of one service is typed under (carrick#1604,
|
|
34
|
+
* carrick#3497 ruling R-N1): the one the TypeScript language service picks.
|
|
35
|
+
* From the file's directory up to the service root, inclusive, each directory's
|
|
36
|
+
* `tsconfig.json`, else `jsconfig.json`, is asked whether its program, or a
|
|
37
|
+
* project it references, lists the file; the first that does types it (a
|
|
38
|
+
* solution config hands the file to the reference that lists it). A config
|
|
39
|
+
* that lists the file nowhere is passed over. The climb stops after a
|
|
40
|
+
* directory named `node_modules`, as tsserver's does. A file no config inside
|
|
41
|
+
* the service lists falls back to the service config (`findServiceTsconfig`
|
|
42
|
+
* or the named one) and the project of its references that lists the file,
|
|
43
|
+
* else to that config itself; with no service config, to none.
|
|
34
44
|
*
|
|
35
|
-
* `
|
|
36
|
-
*
|
|
45
|
+
* The scanner's `module_aliases::Governing` is the same rule, and
|
|
46
|
+
* `tests/module_resolution_parity_test.rs` holds both to the compiler's own
|
|
47
|
+
* answer.
|
|
37
48
|
*/
|
|
38
|
-
export declare
|
|
49
|
+
export declare class GoverningConfigs {
|
|
50
|
+
private readonly serviceConfig;
|
|
51
|
+
private readonly report;
|
|
52
|
+
private readonly root;
|
|
53
|
+
/** Directory -> the config in it, for every directory a climb visited. */
|
|
54
|
+
private readonly dirConfigs;
|
|
55
|
+
/** Config -> its projects; undefined for one that cannot be read. */
|
|
56
|
+
private readonly graphs;
|
|
57
|
+
/**
|
|
58
|
+
* @param serviceRoot the service directory
|
|
59
|
+
* @param serviceConfig the fallback config, absolute, or undefined for none
|
|
60
|
+
* @param report where a config or reference that cannot be read is named
|
|
61
|
+
*/
|
|
62
|
+
constructor(serviceRoot: string, serviceConfig: string | undefined, report?: (diagnostic: string) => void);
|
|
63
|
+
/** Absolute path of the config that types `file`, or undefined for none. */
|
|
64
|
+
configFor(file: string): string | undefined;
|
|
65
|
+
private configIn;
|
|
66
|
+
/** The project reached from `config` that lists `file`, absolute. */
|
|
67
|
+
private listingOwner;
|
|
68
|
+
}
|
|
@@ -14,15 +14,20 @@
|
|
|
14
14
|
* A service-root `jsconfig.json` ranks after those names and before an
|
|
15
15
|
* ancestor `tsconfig.json` (carrick#3497): tsserver types a JavaScript file
|
|
16
16
|
* under the jsconfig beside it, not under a config above. Where no ancestor
|
|
17
|
-
* config exists the answer stays undefined, as before:
|
|
18
|
-
* typed
|
|
17
|
+
* config exists the answer stays undefined, as before: each file is then
|
|
18
|
+
* typed by `GoverningConfigs` alone, which reads the same jsconfig.
|
|
19
19
|
*
|
|
20
20
|
* The walk stops at the scan root, inclusive: a config outside the scanned
|
|
21
21
|
* tree is never read. With no scan root, or a service outside it, only the
|
|
22
22
|
* service root is searched.
|
|
23
|
+
*
|
|
24
|
+
* The service config is the fallback of the per-file rule
|
|
25
|
+
* (`GoverningConfigs`, carrick#3497): a file a config inside the service
|
|
26
|
+
* lists is typed under that config.
|
|
23
27
|
*/
|
|
24
28
|
import * as fs from 'node:fs';
|
|
25
29
|
import * as path from 'node:path';
|
|
30
|
+
import { ProjectGraph } from './project-references.js';
|
|
26
31
|
/** The names a service root is searched for, in order. */
|
|
27
32
|
const SERVICE_ROOT_NAMES = ['tsconfig.json', 'tsconfig.build.json', 'tsconfig.app.json'];
|
|
28
33
|
/** The root config tsserver types a JavaScript service under, after the names above. */
|
|
@@ -68,40 +73,85 @@ export function realPath(p) {
|
|
|
68
73
|
/** The names an editor looks for in a file's directory, in order. */
|
|
69
74
|
const FILE_CONFIG_NAMES = ['tsconfig.json', 'jsconfig.json'];
|
|
70
75
|
/**
|
|
71
|
-
* The config
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
+
* The config each file of one service is typed under (carrick#1604,
|
|
77
|
+
* carrick#3497 ruling R-N1): the one the TypeScript language service picks.
|
|
78
|
+
* From the file's directory up to the service root, inclusive, each directory's
|
|
79
|
+
* `tsconfig.json`, else `jsconfig.json`, is asked whether its program, or a
|
|
80
|
+
* project it references, lists the file; the first that does types it (a
|
|
81
|
+
* solution config hands the file to the reference that lists it). A config
|
|
82
|
+
* that lists the file nowhere is passed over. The climb stops after a
|
|
83
|
+
* directory named `node_modules`, as tsserver's does. A file no config inside
|
|
84
|
+
* the service lists falls back to the service config (`findServiceTsconfig`
|
|
85
|
+
* or the named one) and the project of its references that lists the file,
|
|
86
|
+
* else to that config itself; with no service config, to none.
|
|
76
87
|
*
|
|
77
|
-
* `
|
|
78
|
-
*
|
|
88
|
+
* The scanner's `module_aliases::Governing` is the same rule, and
|
|
89
|
+
* `tests/module_resolution_parity_test.rs` holds both to the compiler's own
|
|
90
|
+
* answer.
|
|
79
91
|
*/
|
|
80
|
-
export
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
export class GoverningConfigs {
|
|
93
|
+
serviceConfig;
|
|
94
|
+
report;
|
|
95
|
+
root;
|
|
96
|
+
/** Directory -> the config in it, for every directory a climb visited. */
|
|
97
|
+
dirConfigs = new Map();
|
|
98
|
+
/** Config -> its projects; undefined for one that cannot be read. */
|
|
99
|
+
graphs = new Map();
|
|
100
|
+
/**
|
|
101
|
+
* @param serviceRoot the service directory
|
|
102
|
+
* @param serviceConfig the fallback config, absolute, or undefined for none
|
|
103
|
+
* @param report where a config or reference that cannot be read is named
|
|
104
|
+
*/
|
|
105
|
+
constructor(serviceRoot, serviceConfig, report = () => { }) {
|
|
106
|
+
this.serviceConfig = serviceConfig;
|
|
107
|
+
this.report = report;
|
|
108
|
+
this.root = path.resolve(serviceRoot);
|
|
109
|
+
}
|
|
110
|
+
/** Absolute path of the config that types `file`, or undefined for none. */
|
|
111
|
+
configFor(file) {
|
|
112
|
+
const absolute = path.resolve(file);
|
|
113
|
+
let dir = path.dirname(absolute);
|
|
114
|
+
for (;;) {
|
|
115
|
+
const from = path.relative(this.root, dir);
|
|
116
|
+
if (from.startsWith('..') || path.isAbsolute(from))
|
|
117
|
+
break;
|
|
118
|
+
const config = this.configIn(dir);
|
|
119
|
+
const owner = config === undefined ? undefined : this.listingOwner(config, absolute);
|
|
120
|
+
if (owner !== undefined)
|
|
121
|
+
return owner;
|
|
122
|
+
// tsserver looks in a `node_modules` directory itself, then stops.
|
|
123
|
+
if (dir === this.root || path.basename(dir) === 'node_modules')
|
|
124
|
+
break;
|
|
125
|
+
dir = path.dirname(dir);
|
|
92
126
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
127
|
+
if (this.serviceConfig === undefined)
|
|
128
|
+
return undefined;
|
|
129
|
+
return this.listingOwner(this.serviceConfig, absolute) ?? this.serviceConfig;
|
|
130
|
+
}
|
|
131
|
+
configIn(dir) {
|
|
132
|
+
if (!this.dirConfigs.has(dir)) {
|
|
133
|
+
const name = FILE_CONFIG_NAMES.find((n) => fs.existsSync(path.join(dir, n)));
|
|
134
|
+
this.dirConfigs.set(dir, name === undefined ? undefined : path.join(dir, name));
|
|
98
135
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
136
|
+
return this.dirConfigs.get(dir);
|
|
137
|
+
}
|
|
138
|
+
/** The project reached from `config` that lists `file`, absolute. */
|
|
139
|
+
listingOwner(config, file) {
|
|
140
|
+
if (!this.graphs.has(config)) {
|
|
141
|
+
try {
|
|
142
|
+
this.graphs.set(config, { graph: new ProjectGraph(config), reported: 0 });
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
this.report(`tsconfig ${config} could not be read and was skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
146
|
+
this.graphs.set(config, undefined);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const entry = this.graphs.get(config);
|
|
150
|
+
if (entry === undefined)
|
|
151
|
+
return undefined;
|
|
152
|
+
const owner = entry.graph.listingOwnerOf(file);
|
|
153
|
+
entry.graph.diagnostics.slice(entry.reported).forEach(this.report);
|
|
154
|
+
entry.reported = entry.graph.diagnostics.length;
|
|
155
|
+
return owner?.configPath;
|
|
103
156
|
}
|
|
104
|
-
for (const d of climbed)
|
|
105
|
-
known.set(d, found);
|
|
106
|
-
return found;
|
|
107
157
|
}
|
|
@@ -2487,10 +2487,12 @@ class DeclarationReader {
|
|
|
2487
2487
|
*/
|
|
2488
2488
|
judgeOp(receiver, claim, rules) {
|
|
2489
2489
|
// Amendment 7, part 3 (carrick#3047): the form says how the service
|
|
2490
|
-
// writes the op, and the op kinds a form belongs to.
|
|
2490
|
+
// writes the op, and the op kinds a form belongs to. A `new` receive
|
|
2491
|
+
// subscribes when the export is constructed (carrick-cloud#3139).
|
|
2491
2492
|
const form = claim.form ?? 'call';
|
|
2492
|
-
if (form === 'new' && claim.op !== 'send' && claim.op !== 'request')
|
|
2493
|
+
if (form === 'new' && claim.op !== 'send' && claim.op !== 'request' && claim.op !== 'receive') {
|
|
2493
2494
|
return unchecked('claim_invalid');
|
|
2495
|
+
}
|
|
2494
2496
|
if (form === 'decorate' && claim.op !== 'receive')
|
|
2495
2497
|
return unchecked('claim_invalid');
|
|
2496
2498
|
// `returns` judges the handler a receive op registers.
|
|
@@ -51,7 +51,7 @@ import { ts } from 'ts-morph';
|
|
|
51
51
|
import type { ProjectLoader } from './project-loader.js';
|
|
52
52
|
import type { PositionRowsCounts } from './types.js';
|
|
53
53
|
/** The format's version, written in the header. */
|
|
54
|
-
export declare const POSITION_ROWS_VERSION =
|
|
54
|
+
export declare const POSITION_ROWS_VERSION = 5;
|
|
55
55
|
/** The type is `any`, declared or inferred. Never set with the error type. */
|
|
56
56
|
export declare const FLAG_ANY = 1;
|
|
57
57
|
/** The type is the compiler's error type: something did not resolve. */
|
|
@@ -86,7 +86,7 @@ export declare const FLAG_RUNS_HANDED = 128;
|
|
|
86
86
|
export declare const DECL_CAP = 16;
|
|
87
87
|
/** The kinds {@link kindOf} gives a node; `decl` and `jsx` rows are written beside them. */
|
|
88
88
|
export type NodeKind = 'call' | 'member' | 'compare' | 'ident';
|
|
89
|
-
export type PositionKind = NodeKind | 'decl' | 'jsx';
|
|
89
|
+
export type PositionKind = NodeKind | 'decl' | 'jsx' | 'typed_decl';
|
|
90
90
|
/** `[kind, start, end, symbol, decl_file, decl_line, decl_package, type_text, flags]` */
|
|
91
91
|
export type PositionRow = [
|
|
92
92
|
PositionKind,
|
|
@@ -247,6 +247,16 @@ export declare class PositionWalker {
|
|
|
247
247
|
* A throw writes one row flagged {@link FLAG_CHECKER_THREW}.
|
|
248
248
|
*/
|
|
249
249
|
private declRows;
|
|
250
|
+
/**
|
|
251
|
+
* The `typed_decl` row of a call (carrick#2448): the callee is a value
|
|
252
|
+
* (a parameter, a property, a local) whose type is a named function's own
|
|
253
|
+
* (`send: typeof fetch`), so the compiler gives the type a symbol whose
|
|
254
|
+
* declaration is that function's. Written only when the callee symbol is
|
|
255
|
+
* not already that declaration and the type's symbol is named (an
|
|
256
|
+
* anonymous function or type literal is `__function` / `__type`), so a
|
|
257
|
+
* direct call or a method call writes none.
|
|
258
|
+
*/
|
|
259
|
+
private typedDeclRow;
|
|
250
260
|
/** The row's symbol, following aliases to a target that has a declaration. */
|
|
251
261
|
symbolOf(kind: PositionKind, node: ts.Node): ts.Symbol | undefined;
|
|
252
262
|
/**
|
|
@@ -56,7 +56,7 @@ import { WriteGuard, installedPackageDirectory, isDeclarationFileName, moduleExp
|
|
|
56
56
|
import { attributedDeclaration, installedPackageOf, typeDeclaration } from './declaration-attribution.js';
|
|
57
57
|
import { typeToStringAsDeclared } from './print-type.js';
|
|
58
58
|
/** The format's version, written in the header. */
|
|
59
|
-
export const POSITION_ROWS_VERSION =
|
|
59
|
+
export const POSITION_ROWS_VERSION = 5;
|
|
60
60
|
/** The type is `any`, declared or inferred. Never set with the error type. */
|
|
61
61
|
export const FLAG_ANY = 1;
|
|
62
62
|
/** The type is the compiler's error type: something did not resolve. */
|
|
@@ -426,6 +426,11 @@ export class PositionWalker {
|
|
|
426
426
|
for (const decl of this.declRows(kind, node))
|
|
427
427
|
rows.push(['decl', row[1], row[2], ...tail(decl)]);
|
|
428
428
|
}
|
|
429
|
+
if (kind === 'call' && !(row[8] & FLAG_CHECKER_THREW)) {
|
|
430
|
+
const typed = this.typedDeclRow(node, row[1], row[2]);
|
|
431
|
+
if (typed)
|
|
432
|
+
rows.push(typed);
|
|
433
|
+
}
|
|
429
434
|
}
|
|
430
435
|
if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {
|
|
431
436
|
rows.push(this.row('jsx', node.tagName, sourceFile));
|
|
@@ -743,6 +748,45 @@ export class PositionWalker {
|
|
|
743
748
|
rows.sort((a, b) => compareNames(a.row[4], b.row[4]) || a.start - b.start);
|
|
744
749
|
return rows.map(({ row }) => row);
|
|
745
750
|
}
|
|
751
|
+
/**
|
|
752
|
+
* The `typed_decl` row of a call (carrick#2448): the callee is a value
|
|
753
|
+
* (a parameter, a property, a local) whose type is a named function's own
|
|
754
|
+
* (`send: typeof fetch`), so the compiler gives the type a symbol whose
|
|
755
|
+
* declaration is that function's. Written only when the callee symbol is
|
|
756
|
+
* not already that declaration and the type's symbol is named (an
|
|
757
|
+
* anonymous function or type literal is `__function` / `__type`), so a
|
|
758
|
+
* direct call or a method call writes none.
|
|
759
|
+
*/
|
|
760
|
+
typedDeclRow(node, start, end) {
|
|
761
|
+
if (!ts.isCallExpression(node))
|
|
762
|
+
return undefined;
|
|
763
|
+
try {
|
|
764
|
+
const symbol = this.symbolOf('call', node);
|
|
765
|
+
if (!symbol)
|
|
766
|
+
return undefined;
|
|
767
|
+
const type = this.checker.getNonNullableType(this.checker.getTypeAtLocation(node.expression));
|
|
768
|
+
const typeSymbol = type.symbol;
|
|
769
|
+
if (!typeSymbol || typeSymbol.name.startsWith('__'))
|
|
770
|
+
return undefined;
|
|
771
|
+
if (type.getCallSignatures().length === 0)
|
|
772
|
+
return undefined;
|
|
773
|
+
const declaration = this.typeDeclaration(type);
|
|
774
|
+
if (!declaration)
|
|
775
|
+
return undefined;
|
|
776
|
+
const own = symbol.declarations ?? [];
|
|
777
|
+
if (own.some((d) => (typeSymbol.declarations ?? []).includes(d)))
|
|
778
|
+
return undefined;
|
|
779
|
+
const file = declaration.getSourceFile();
|
|
780
|
+
const { declFile, declLine, declPackage } = this.located(file, declaration.getStart(file));
|
|
781
|
+
let flags = this.publication(typeSymbol, declaration);
|
|
782
|
+
if (declFile === null)
|
|
783
|
+
flags |= FLAG_DECLARATION_UNNAMED;
|
|
784
|
+
return ['typed_decl', start, end, ts.symbolName(typeSymbol), declFile, declLine, declPackage, null, flags];
|
|
785
|
+
}
|
|
786
|
+
catch {
|
|
787
|
+
return undefined;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
746
790
|
/** The row's symbol, following aliases to a target that has a declaration. */
|
|
747
791
|
symbolOf(kind, node) {
|
|
748
792
|
let symbol;
|
|
@@ -929,6 +973,7 @@ function nameNodeOf(kind, node) {
|
|
|
929
973
|
case 'ident':
|
|
930
974
|
return node;
|
|
931
975
|
case 'decl':
|
|
976
|
+
case 'typed_decl':
|
|
932
977
|
return undefined;
|
|
933
978
|
case 'jsx':
|
|
934
979
|
// The tag: `<Badge>`, `<ui.Button>`, `<this.Panel>`; a namespaced
|
|
@@ -81,17 +81,12 @@ export declare class ProjectLoader {
|
|
|
81
81
|
/** The tsconfig the service names, when the project is built from one. */
|
|
82
82
|
private namedTsconfigPath;
|
|
83
83
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
84
|
+
* The config each file is typed under (carrick#1604, carrick#3497): set for
|
|
85
|
+
* a service built from a tsconfig, with it as the fallback, and for one
|
|
86
|
+
* with no config at or above its root, with none. Unset (a snapshot or a
|
|
87
|
+
* Deno project), every file is the default project's.
|
|
87
88
|
*/
|
|
88
|
-
private
|
|
89
|
-
/** The per-directory answers of `fileConfigPath` for this service. */
|
|
90
|
-
private readonly fileConfigs;
|
|
91
|
-
/** The reference owner rule of each config a file was found under. */
|
|
92
|
-
private readonly ownerRules;
|
|
93
|
-
/** Each file's owning config (carrick#1604), resolved on first use. */
|
|
94
|
-
private configPathFor;
|
|
89
|
+
private governing;
|
|
95
90
|
/** Programs built for owning projects other than the named tsconfig. */
|
|
96
91
|
private readonly ownerProjects;
|
|
97
92
|
private readonly repoRoot;
|
|
@@ -128,22 +123,15 @@ export declare class ProjectLoader {
|
|
|
128
123
|
*/
|
|
129
124
|
private projectFromConfig;
|
|
130
125
|
/**
|
|
131
|
-
* Which project types `file` (carrick#1604): the key of its
|
|
132
|
-
* project's program, or `''` for the default one.
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* as before.
|
|
126
|
+
* Which project types `file` (carrick#1604, carrick#3497): the key of its
|
|
127
|
+
* owning project's program, or `''` for the default one. The owner is the
|
|
128
|
+
* config `GoverningConfigs` picks: the nearest config inside the service
|
|
129
|
+
* whose program, or a project it references (carrick#2418's search order),
|
|
130
|
+
* lists the file, else the service's tsconfig. The service's own tsconfig,
|
|
131
|
+
* every request that names no file, and a file no config governs use the
|
|
132
|
+
* default project.
|
|
139
133
|
*/
|
|
140
134
|
projectKeyFor(file?: string): string;
|
|
141
|
-
/**
|
|
142
|
-
* `projectKeyFor` for a service with no config at its root: the owner of the
|
|
143
|
-
* nearest config on the file's way up to the service root, or `''` (the
|
|
144
|
-
* default project, under the inferred options) for a file with none.
|
|
145
|
-
*/
|
|
146
|
-
private inferredKeyFor;
|
|
147
135
|
/**
|
|
148
136
|
* The project behind a key from `projectKeyFor`, built on first use and
|
|
149
137
|
* kept: a service whose files all belong to one project builds one.
|
|
@@ -13,7 +13,7 @@ import { Project, getCompilerOptionsFromTsConfig } from 'ts-morph';
|
|
|
13
13
|
import * as path from 'node:path';
|
|
14
14
|
import ts from 'typescript';
|
|
15
15
|
import * as fs from 'node:fs';
|
|
16
|
-
import { DenoProject, findDenoConfig,
|
|
16
|
+
import { DenoProject, findDenoConfig, findServiceTsconfig, GoverningConfigs, referenceRedirectOf, sidecarCompilerOptions, untrustedReadBound, } from './capture/index.js';
|
|
17
17
|
import { moduleFormatResolutionHost } from './module-format.js';
|
|
18
18
|
import { ExternalImports, registerExternalImports } from './origin.js';
|
|
19
19
|
import { pinProgramRoots } from './program-files.js';
|
|
@@ -141,17 +141,12 @@ export class ProjectLoader {
|
|
|
141
141
|
/** The tsconfig the service names, when the project is built from one. */
|
|
142
142
|
namedTsconfigPath;
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
144
|
+
* The config each file is typed under (carrick#1604, carrick#3497): set for
|
|
145
|
+
* a service built from a tsconfig, with it as the fallback, and for one
|
|
146
|
+
* with no config at or above its root, with none. Unset (a snapshot or a
|
|
147
|
+
* Deno project), every file is the default project's.
|
|
147
148
|
*/
|
|
148
|
-
|
|
149
|
-
/** The per-directory answers of `fileConfigPath` for this service. */
|
|
150
|
-
fileConfigs = new Map();
|
|
151
|
-
/** The reference owner rule of each config a file was found under. */
|
|
152
|
-
ownerRules = new Map();
|
|
153
|
-
/** Each file's owning config (carrick#1604), resolved on first use. */
|
|
154
|
-
configPathFor;
|
|
149
|
+
governing;
|
|
155
150
|
/** Programs built for owning projects other than the named tsconfig. */
|
|
156
151
|
ownerProjects = new Map();
|
|
157
152
|
repoRoot;
|
|
@@ -253,11 +248,12 @@ export class ProjectLoader {
|
|
|
253
248
|
else if (tsconfigPath) {
|
|
254
249
|
this.log(`Project will load with tsconfig: ${tsconfigPath}`);
|
|
255
250
|
this.namedTsconfigPath = tsconfigPath;
|
|
251
|
+
this.governing = new GoverningConfigs(this.repoRoot, tsconfigPath, (d) => this.logError(d));
|
|
256
252
|
this.buildProject = (kind) => this.projectFromConfig(tsconfigPath, kind);
|
|
257
253
|
}
|
|
258
254
|
else {
|
|
259
255
|
this.log('No tsconfig.json found, using default compiler options');
|
|
260
|
-
this.
|
|
256
|
+
this.governing = new GoverningConfigs(this.repoRoot, undefined, (d) => this.logError(d));
|
|
261
257
|
this.buildProject = (kind) => {
|
|
262
258
|
const project = new Project({
|
|
263
259
|
...this.fileSystemOption(),
|
|
@@ -379,7 +375,7 @@ export class ProjectLoader {
|
|
|
379
375
|
// TypeScript reads a `jsconfig.json` with an implicit depth of 2, which
|
|
380
376
|
// loads the JavaScript sources of installed packages; every other program
|
|
381
377
|
// here reads 0. A depth the config states is kept (carrick#1604).
|
|
382
|
-
if (this.
|
|
378
|
+
if (configPath !== this.namedTsconfigPath && path.basename(configPath) === 'jsconfig.json' && !statesJsDepth(configPath)) {
|
|
383
379
|
options.maxNodeModuleJsDepth = 0;
|
|
384
380
|
}
|
|
385
381
|
const project = new Project({
|
|
@@ -403,42 +399,19 @@ export class ProjectLoader {
|
|
|
403
399
|
return project;
|
|
404
400
|
}
|
|
405
401
|
/**
|
|
406
|
-
* Which project types `file` (carrick#1604): the key of its
|
|
407
|
-
* project's program, or `''` for the default one.
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
* as before.
|
|
402
|
+
* Which project types `file` (carrick#1604, carrick#3497): the key of its
|
|
403
|
+
* owning project's program, or `''` for the default one. The owner is the
|
|
404
|
+
* config `GoverningConfigs` picks: the nearest config inside the service
|
|
405
|
+
* whose program, or a project it references (carrick#2418's search order),
|
|
406
|
+
* lists the file, else the service's tsconfig. The service's own tsconfig,
|
|
407
|
+
* every request that names no file, and a file no config governs use the
|
|
408
|
+
* default project.
|
|
414
409
|
*/
|
|
415
410
|
projectKeyFor(file) {
|
|
416
|
-
if (this.
|
|
417
|
-
return this.inferredKeyFor(file);
|
|
418
|
-
if (!this.namedTsconfigPath || file === undefined)
|
|
411
|
+
if (file === undefined || this.governing === undefined)
|
|
419
412
|
return '';
|
|
420
|
-
this.
|
|
421
|
-
|
|
422
|
-
return config === this.namedTsconfigPath ? '' : config;
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* `projectKeyFor` for a service with no config at its root: the owner of the
|
|
426
|
-
* nearest config on the file's way up to the service root, or `''` (the
|
|
427
|
-
* default project, under the inferred options) for a file with none.
|
|
428
|
-
*/
|
|
429
|
-
inferredKeyFor(file) {
|
|
430
|
-
if (file === undefined)
|
|
431
|
-
return '';
|
|
432
|
-
const absolute = path.resolve(this.repoRoot, file);
|
|
433
|
-
const config = fileConfigPath(absolute, this.repoRoot, this.fileConfigs);
|
|
434
|
-
if (config === undefined)
|
|
435
|
-
return '';
|
|
436
|
-
let owner = this.ownerRules.get(config);
|
|
437
|
-
if (!owner) {
|
|
438
|
-
owner = serviceConfigPath(config, (d) => this.logError(d));
|
|
439
|
-
this.ownerRules.set(config, owner);
|
|
440
|
-
}
|
|
441
|
-
return owner(absolute);
|
|
413
|
+
const config = this.governing.configFor(path.resolve(this.repoRoot, file));
|
|
414
|
+
return config === undefined || config === this.namedTsconfigPath ? '' : config;
|
|
442
415
|
}
|
|
443
416
|
/**
|
|
444
417
|
* The project behind a key from `projectKeyFor`, built on first use and
|