@intentweave/python-parser 0.4.0
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/LICENSE +202 -0
- package/dist/extractor.d.ts +29 -0
- package/dist/extractor.d.ts.map +1 -0
- package/dist/extractor.js +567 -0
- package/dist/extractor.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +86 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2025 - 2026 Benjamin Becker
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PythonFileResult, PythonExtractionOptions, PythonBatchResult } from "./types.js";
|
|
2
|
+
export declare class PythonExtractor {
|
|
3
|
+
private parser;
|
|
4
|
+
private workspaceRoot;
|
|
5
|
+
private defaultOptions;
|
|
6
|
+
constructor(workspaceRoot: string, options?: Partial<PythonExtractionOptions>);
|
|
7
|
+
/**
|
|
8
|
+
* Extract symbols from a single Python file.
|
|
9
|
+
*/
|
|
10
|
+
extractFile(filePath: string, options?: Partial<PythonExtractionOptions>): Promise<PythonFileResult>;
|
|
11
|
+
/**
|
|
12
|
+
* Extract symbols from a Python source string (for testing / in-memory).
|
|
13
|
+
*/
|
|
14
|
+
extractFromString(content: string, filePath: string, options?: Partial<PythonExtractionOptions>): PythonFileResult;
|
|
15
|
+
/**
|
|
16
|
+
* Extract symbols from multiple Python files.
|
|
17
|
+
*/
|
|
18
|
+
extractBatch(filePaths: string[], options?: Partial<PythonExtractionOptions>): Promise<PythonBatchResult>;
|
|
19
|
+
private walkNode;
|
|
20
|
+
private extractFunction;
|
|
21
|
+
private extractClass;
|
|
22
|
+
/** Handle `import X`, `import X as Y`, `import X, Y` */
|
|
23
|
+
private extractImportStatement;
|
|
24
|
+
/** Handle `from X import Y`, `from . import Z`, `from ..pkg import W` */
|
|
25
|
+
private extractImportFromStatement;
|
|
26
|
+
private extractAssignment;
|
|
27
|
+
}
|
|
28
|
+
export declare function createPythonExtractor(workspaceRoot: string, options?: Partial<PythonExtractionOptions>): PythonExtractor;
|
|
29
|
+
//# sourceMappingURL=extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../src/extractor.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAGV,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EAGlB,MAAM,YAAY,CAAC;AAkMpB,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,cAAc,CAAoC;gBAGxD,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC;IAe5C;;OAEG;IACG,WAAW,CACf,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GACzC,OAAO,CAAC,gBAAgB,CAAC;IAuB5B;;OAEG;IACH,iBAAiB,CACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GACzC,gBAAgB;IAoCnB;;OAEG;IACG,YAAY,CAChB,SAAS,EAAE,MAAM,EAAE,EACnB,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GACzC,OAAO,CAAC,iBAAiB,CAAC;IA+B7B,OAAO,CAAC,QAAQ;IA6FhB,OAAO,CAAC,eAAe;IAsEvB,OAAO,CAAC,YAAY;IA2DpB,wDAAwD;IACxD,OAAO,CAAC,sBAAsB;IA2C9B,yEAAyE;IACzE,OAAO,CAAC,0BAA0B;IAqElC,OAAO,CAAC,iBAAiB;CAuD1B;AAID,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GACzC,eAAe,CAEjB"}
|
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
// Copyright 2025-2026 Benjamin Becker
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* @file Python AST Extractor
|
|
5
|
+
*
|
|
6
|
+
* Tree-sitter based Python AST extractor.
|
|
7
|
+
* Extracts functions, classes, methods, decorators, imports,
|
|
8
|
+
* module-level variables, and type hints from .py files.
|
|
9
|
+
*/
|
|
10
|
+
import Parser from "tree-sitter";
|
|
11
|
+
import Python from "tree-sitter-python";
|
|
12
|
+
import * as fs from "fs";
|
|
13
|
+
import * as path from "path";
|
|
14
|
+
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
15
|
+
function toRange(node) {
|
|
16
|
+
return {
|
|
17
|
+
startLine: node.startPosition.row + 1,
|
|
18
|
+
startColumn: node.startPosition.column,
|
|
19
|
+
endLine: node.endPosition.row + 1,
|
|
20
|
+
endColumn: node.endPosition.column,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Python visibility is convention-based:
|
|
25
|
+
* `__name` → private (name-mangled)
|
|
26
|
+
* `_name` → protected (convention)
|
|
27
|
+
* `name` → public
|
|
28
|
+
*/
|
|
29
|
+
function getVisibility(name) {
|
|
30
|
+
if (name.startsWith("__") && !name.endsWith("__"))
|
|
31
|
+
return "private";
|
|
32
|
+
if (name.startsWith("_"))
|
|
33
|
+
return "protected";
|
|
34
|
+
return "public";
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Determine if a module-level symbol is "exported".
|
|
38
|
+
* - Names starting with `_` are internal by convention
|
|
39
|
+
* - If `__all__` is defined, only listed names are exported
|
|
40
|
+
*/
|
|
41
|
+
function isExportedName(name, allNames) {
|
|
42
|
+
if (allNames)
|
|
43
|
+
return allNames.has(name);
|
|
44
|
+
return !name.startsWith("_");
|
|
45
|
+
}
|
|
46
|
+
/** Extract decorator names from a decorated_definition wrapper. */
|
|
47
|
+
function extractDecorators(node) {
|
|
48
|
+
const decorators = [];
|
|
49
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
50
|
+
const child = node.child(i);
|
|
51
|
+
if (child.type === "decorator") {
|
|
52
|
+
// decorator → "@" expression
|
|
53
|
+
// The expression is typically an identifier or dotted name or call
|
|
54
|
+
const expr = child.childCount > 1 ? child.child(1) : null;
|
|
55
|
+
if (expr) {
|
|
56
|
+
// For `@staticmethod` → "staticmethod"
|
|
57
|
+
// For `@app.route("/")` → "app.route"
|
|
58
|
+
if (expr.type === "identifier") {
|
|
59
|
+
decorators.push(expr.text);
|
|
60
|
+
}
|
|
61
|
+
else if (expr.type === "attribute") {
|
|
62
|
+
decorators.push(expr.text);
|
|
63
|
+
}
|
|
64
|
+
else if (expr.type === "call") {
|
|
65
|
+
// @decorator(args) → extract decorator name
|
|
66
|
+
const fn = expr.childForFieldName("function");
|
|
67
|
+
if (fn)
|
|
68
|
+
decorators.push(fn.text);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return decorators;
|
|
74
|
+
}
|
|
75
|
+
/** Extract base classes from a class argument_list. */
|
|
76
|
+
function extractBases(node) {
|
|
77
|
+
const bases = [];
|
|
78
|
+
const argList = node.childForFieldName("superclasses");
|
|
79
|
+
if (!argList)
|
|
80
|
+
return bases;
|
|
81
|
+
for (let i = 0; i < argList.childCount; i++) {
|
|
82
|
+
const child = argList.child(i);
|
|
83
|
+
if (child.type === "identifier" || child.type === "attribute") {
|
|
84
|
+
bases.push(child.text);
|
|
85
|
+
}
|
|
86
|
+
else if (child.type === "keyword_argument") {
|
|
87
|
+
// e.g., metaclass=ABCMeta — skip
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return bases;
|
|
91
|
+
}
|
|
92
|
+
/** Extract parameter names from a `parameters` node. */
|
|
93
|
+
function extractParameters(node) {
|
|
94
|
+
const params = [];
|
|
95
|
+
const paramList = node.childForFieldName("parameters");
|
|
96
|
+
if (!paramList)
|
|
97
|
+
return params;
|
|
98
|
+
for (let i = 0; i < paramList.childCount; i++) {
|
|
99
|
+
const child = paramList.child(i);
|
|
100
|
+
switch (child.type) {
|
|
101
|
+
case "identifier":
|
|
102
|
+
params.push(child.text);
|
|
103
|
+
break;
|
|
104
|
+
case "typed_parameter":
|
|
105
|
+
case "default_parameter":
|
|
106
|
+
case "typed_default_parameter": {
|
|
107
|
+
// Try field name first, then fall back to first identifier child
|
|
108
|
+
const nameNode = child.childForFieldName("name") ??
|
|
109
|
+
(() => {
|
|
110
|
+
for (let j = 0; j < child.childCount; j++) {
|
|
111
|
+
if (child.child(j).type === "identifier")
|
|
112
|
+
return child.child(j);
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
})();
|
|
116
|
+
if (nameNode)
|
|
117
|
+
params.push(nameNode.text);
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
case "list_splat_pattern":
|
|
121
|
+
case "dictionary_splat_pattern": {
|
|
122
|
+
// *args, **kwargs
|
|
123
|
+
const inner = child.childCount > 0 ? child.child(child.childCount - 1) : null;
|
|
124
|
+
if (inner?.type === "identifier") {
|
|
125
|
+
const prefix = child.type === "list_splat_pattern" ? "*" : "**";
|
|
126
|
+
params.push(prefix + inner.text);
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return params;
|
|
133
|
+
}
|
|
134
|
+
/** Extract the first line of a docstring from the function/class body. */
|
|
135
|
+
function extractDocstring(node) {
|
|
136
|
+
const body = node.childForFieldName("body");
|
|
137
|
+
if (!body || body.childCount === 0)
|
|
138
|
+
return undefined;
|
|
139
|
+
const first = body.child(0);
|
|
140
|
+
// expression_statement → string
|
|
141
|
+
if (first.type === "expression_statement") {
|
|
142
|
+
const expr = first.child(0);
|
|
143
|
+
if (expr &&
|
|
144
|
+
(expr.type === "string" || expr.type === "concatenated_string")) {
|
|
145
|
+
const text = expr.text;
|
|
146
|
+
// Strip triple quotes
|
|
147
|
+
const stripped = text
|
|
148
|
+
.replace(/^("""|''')\s*/, "")
|
|
149
|
+
.replace(/\s*("""|''')$/, "")
|
|
150
|
+
.trim();
|
|
151
|
+
// Return first line only
|
|
152
|
+
const firstLine = stripped.split("\n")[0].trim();
|
|
153
|
+
return firstLine || undefined;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
/** Build a displayable signature. */
|
|
159
|
+
function buildSignature(node, kind) {
|
|
160
|
+
const lines = node.text.split("\n");
|
|
161
|
+
const firstLine = lines[0].trim();
|
|
162
|
+
// Trim body (after colon)
|
|
163
|
+
const colonIdx = firstLine.indexOf(":");
|
|
164
|
+
if (colonIdx > 0)
|
|
165
|
+
return firstLine.substring(0, colonIdx).trim();
|
|
166
|
+
return firstLine.length > 120 ? firstLine.substring(0, 120) + "…" : firstLine;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Scan the module for `__all__ = [...]` and return the listed names.
|
|
170
|
+
* Returns null if no __all__ is defined.
|
|
171
|
+
*/
|
|
172
|
+
function extractAllNames(root) {
|
|
173
|
+
for (let i = 0; i < root.childCount; i++) {
|
|
174
|
+
const child = root.child(i);
|
|
175
|
+
if (child.type !== "expression_statement")
|
|
176
|
+
continue;
|
|
177
|
+
const assignment = child.child(0);
|
|
178
|
+
if (!assignment || assignment.type !== "assignment")
|
|
179
|
+
continue;
|
|
180
|
+
const left = assignment.childForFieldName("left");
|
|
181
|
+
const right = assignment.childForFieldName("right");
|
|
182
|
+
if (!left || left.text !== "__all__")
|
|
183
|
+
continue;
|
|
184
|
+
if (!right || right.type !== "list")
|
|
185
|
+
continue;
|
|
186
|
+
const names = new Set();
|
|
187
|
+
for (let j = 0; j < right.childCount; j++) {
|
|
188
|
+
const elem = right.child(j);
|
|
189
|
+
if (elem.type === "string") {
|
|
190
|
+
// Strip quotes
|
|
191
|
+
const stripped = elem.text.replace(/^["']|["']$/g, "");
|
|
192
|
+
if (stripped)
|
|
193
|
+
names.add(stripped);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return names;
|
|
197
|
+
}
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
// ── Extractor ────────────────────────────────────────────────────────────────
|
|
201
|
+
export class PythonExtractor {
|
|
202
|
+
parser;
|
|
203
|
+
workspaceRoot;
|
|
204
|
+
defaultOptions;
|
|
205
|
+
constructor(workspaceRoot, options) {
|
|
206
|
+
this.workspaceRoot = workspaceRoot;
|
|
207
|
+
this.parser = new Parser();
|
|
208
|
+
this.parser.setLanguage(Python);
|
|
209
|
+
this.defaultOptions = {
|
|
210
|
+
includePrivate: options?.includePrivate ?? false,
|
|
211
|
+
includeDocSummary: options?.includeDocSummary ?? true,
|
|
212
|
+
includeParameters: options?.includeParameters ?? true,
|
|
213
|
+
includeMembers: options?.includeMembers ?? true,
|
|
214
|
+
maxDepth: options?.maxDepth ?? 2,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Extract symbols from a single Python file.
|
|
219
|
+
*/
|
|
220
|
+
async extractFile(filePath, options) {
|
|
221
|
+
const opts = { ...this.defaultOptions, ...options };
|
|
222
|
+
const absolutePath = path.isAbsolute(filePath)
|
|
223
|
+
? filePath
|
|
224
|
+
: path.join(this.workspaceRoot, filePath);
|
|
225
|
+
const relativePath = path.relative(this.workspaceRoot, absolutePath);
|
|
226
|
+
try {
|
|
227
|
+
const content = await fs.promises.readFile(absolutePath, "utf-8");
|
|
228
|
+
return this.extractFromString(content, relativePath, opts);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
return {
|
|
232
|
+
filePath: relativePath,
|
|
233
|
+
language: "python",
|
|
234
|
+
symbols: [],
|
|
235
|
+
imports: [],
|
|
236
|
+
extractedAt: Date.now(),
|
|
237
|
+
errors: [error.message],
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Extract symbols from a Python source string (for testing / in-memory).
|
|
243
|
+
*/
|
|
244
|
+
extractFromString(content, filePath, options) {
|
|
245
|
+
const opts = { ...this.defaultOptions, ...options };
|
|
246
|
+
const tree = this.parser.parse(content);
|
|
247
|
+
const symbols = [];
|
|
248
|
+
const imports = [];
|
|
249
|
+
const errors = [];
|
|
250
|
+
// Pre-scan for __all__
|
|
251
|
+
const allNames = extractAllNames(tree.rootNode);
|
|
252
|
+
this.walkNode(tree.rootNode, filePath, symbols, imports, opts, undefined, 0, allNames);
|
|
253
|
+
if (tree.rootNode.hasError) {
|
|
254
|
+
errors.push("Parse errors detected in file");
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
filePath,
|
|
258
|
+
language: "python",
|
|
259
|
+
symbols,
|
|
260
|
+
imports,
|
|
261
|
+
extractedAt: Date.now(),
|
|
262
|
+
errors: errors.length > 0 ? errors : undefined,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Extract symbols from multiple Python files.
|
|
267
|
+
*/
|
|
268
|
+
async extractBatch(filePaths, options) {
|
|
269
|
+
const startTime = Date.now();
|
|
270
|
+
const files = new Map();
|
|
271
|
+
const failures = [];
|
|
272
|
+
let totalSymbols = 0;
|
|
273
|
+
for (const filePath of filePaths) {
|
|
274
|
+
try {
|
|
275
|
+
const result = await this.extractFile(filePath, options);
|
|
276
|
+
files.set(result.filePath, result);
|
|
277
|
+
totalSymbols += result.symbols.length;
|
|
278
|
+
if (result.errors?.length) {
|
|
279
|
+
failures.push({ filePath: result.filePath, error: result.errors[0] });
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
failures.push({ filePath, error: error.message });
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
files,
|
|
288
|
+
totalSymbols,
|
|
289
|
+
totalFiles: filePaths.length,
|
|
290
|
+
failures,
|
|
291
|
+
durationMs: Date.now() - startTime,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
// ── Tree walker ──────────────────────────────────────────────────────
|
|
295
|
+
walkNode(node, filePath, symbols, imports, options, parentName, depth, allNames) {
|
|
296
|
+
if (depth > options.maxDepth)
|
|
297
|
+
return;
|
|
298
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
299
|
+
const child = node.child(i);
|
|
300
|
+
switch (child.type) {
|
|
301
|
+
case "function_definition":
|
|
302
|
+
this.extractFunction(child, filePath, symbols, options, parentName, depth, allNames, []);
|
|
303
|
+
break;
|
|
304
|
+
case "class_definition":
|
|
305
|
+
this.extractClass(child, filePath, symbols, imports, options, depth, allNames, []);
|
|
306
|
+
break;
|
|
307
|
+
case "decorated_definition": {
|
|
308
|
+
const decorators = extractDecorators(child);
|
|
309
|
+
const definition = child.childForFieldName("definition");
|
|
310
|
+
if (definition) {
|
|
311
|
+
if (definition.type === "function_definition") {
|
|
312
|
+
this.extractFunction(definition, filePath, symbols, options, parentName, depth, allNames, decorators);
|
|
313
|
+
}
|
|
314
|
+
else if (definition.type === "class_definition") {
|
|
315
|
+
this.extractClass(definition, filePath, symbols, imports, options, depth, allNames, decorators);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
case "import_statement":
|
|
321
|
+
this.extractImportStatement(child, imports);
|
|
322
|
+
break;
|
|
323
|
+
case "import_from_statement":
|
|
324
|
+
this.extractImportFromStatement(child, imports);
|
|
325
|
+
break;
|
|
326
|
+
case "expression_statement":
|
|
327
|
+
// Module-level variable assignments
|
|
328
|
+
if (depth === 0) {
|
|
329
|
+
this.extractAssignment(child, filePath, symbols, allNames);
|
|
330
|
+
}
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
// ── Function extraction ──────────────────────────────────────────────
|
|
336
|
+
extractFunction(node, filePath, symbols, options, parentName, depth, allNames, decorators) {
|
|
337
|
+
const nameNode = node.childForFieldName("name");
|
|
338
|
+
if (!nameNode)
|
|
339
|
+
return;
|
|
340
|
+
const name = nameNode.text;
|
|
341
|
+
const visibility = getVisibility(name);
|
|
342
|
+
// Skip private if not requested
|
|
343
|
+
if (!options.includePrivate && visibility !== "public" && !parentName)
|
|
344
|
+
return;
|
|
345
|
+
const isAsync = node.previousSibling?.type === "async" ||
|
|
346
|
+
node.parent?.type === "async_function_definition" ||
|
|
347
|
+
// Check for 'async' keyword within the node
|
|
348
|
+
(node.childCount > 0 && node.child(0)?.type === "async");
|
|
349
|
+
// Determine kind: function or method
|
|
350
|
+
const kind = parentName ? "method" : "function";
|
|
351
|
+
// Check for @property → treat as property
|
|
352
|
+
const isProperty = decorators.includes("property");
|
|
353
|
+
const actualKind = isProperty ? "property" : kind;
|
|
354
|
+
const isStatic = decorators.includes("staticmethod") || decorators.includes("classmethod");
|
|
355
|
+
const exported = parentName != null
|
|
356
|
+
? visibility === "public" // class members: exported if public
|
|
357
|
+
: isExportedName(name, allNames);
|
|
358
|
+
const sym = {
|
|
359
|
+
name,
|
|
360
|
+
kind: actualKind,
|
|
361
|
+
filePath,
|
|
362
|
+
range: toRange(node),
|
|
363
|
+
isExported: exported,
|
|
364
|
+
visibility,
|
|
365
|
+
decorators: decorators.length > 0 ? decorators : undefined,
|
|
366
|
+
};
|
|
367
|
+
if (parentName)
|
|
368
|
+
sym.parent = parentName;
|
|
369
|
+
if (isAsync)
|
|
370
|
+
sym.isAsync = true;
|
|
371
|
+
if (isStatic)
|
|
372
|
+
sym.isStatic = true;
|
|
373
|
+
if (options.includeParameters) {
|
|
374
|
+
sym.parameters = extractParameters(node);
|
|
375
|
+
}
|
|
376
|
+
if (options.includeDocSummary) {
|
|
377
|
+
sym.docSummary = extractDocstring(node);
|
|
378
|
+
}
|
|
379
|
+
sym.signature = buildSignature(node, actualKind);
|
|
380
|
+
symbols.push(sym);
|
|
381
|
+
}
|
|
382
|
+
// ── Class extraction ─────────────────────────────────────────────────
|
|
383
|
+
extractClass(node, filePath, symbols, imports, options, depth, allNames, decorators) {
|
|
384
|
+
const nameNode = node.childForFieldName("name");
|
|
385
|
+
if (!nameNode)
|
|
386
|
+
return;
|
|
387
|
+
const name = nameNode.text;
|
|
388
|
+
const visibility = getVisibility(name);
|
|
389
|
+
if (!options.includePrivate && visibility !== "public")
|
|
390
|
+
return;
|
|
391
|
+
const bases = extractBases(node);
|
|
392
|
+
const sym = {
|
|
393
|
+
name,
|
|
394
|
+
kind: "class",
|
|
395
|
+
filePath,
|
|
396
|
+
range: toRange(node),
|
|
397
|
+
isExported: isExportedName(name, allNames),
|
|
398
|
+
visibility,
|
|
399
|
+
decorators: decorators.length > 0 ? decorators : undefined,
|
|
400
|
+
bases: bases.length > 0 ? bases : undefined,
|
|
401
|
+
};
|
|
402
|
+
if (options.includeDocSummary) {
|
|
403
|
+
sym.docSummary = extractDocstring(node);
|
|
404
|
+
}
|
|
405
|
+
sym.signature = buildSignature(node, "class");
|
|
406
|
+
symbols.push(sym);
|
|
407
|
+
// Extract class body members
|
|
408
|
+
if (options.includeMembers) {
|
|
409
|
+
const body = node.childForFieldName("body");
|
|
410
|
+
if (body) {
|
|
411
|
+
this.walkNode(body, filePath, symbols, imports, options, name, depth + 1, allNames);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
// ── Import extraction ────────────────────────────────────────────────
|
|
416
|
+
/** Handle `import X`, `import X as Y`, `import X, Y` */
|
|
417
|
+
extractImportStatement(node, imports) {
|
|
418
|
+
// import_statement children: "import" dotted_name ("as" identifier)?
|
|
419
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
420
|
+
const child = node.child(i);
|
|
421
|
+
if (child.type === "dotted_name") {
|
|
422
|
+
const moduleName = child.text;
|
|
423
|
+
let alias;
|
|
424
|
+
// Check for "as" alias
|
|
425
|
+
const next = node.child(i + 1);
|
|
426
|
+
const nextNext = node.child(i + 2);
|
|
427
|
+
if (next?.type === "as" && nextNext?.type === "identifier") {
|
|
428
|
+
alias = nextNext.text;
|
|
429
|
+
}
|
|
430
|
+
imports.push({
|
|
431
|
+
moduleName,
|
|
432
|
+
isRelative: false,
|
|
433
|
+
importedNames: [],
|
|
434
|
+
isWholeModule: true,
|
|
435
|
+
alias,
|
|
436
|
+
range: toRange(node),
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
else if (child.type === "aliased_import") {
|
|
440
|
+
const nameNode = child.childForFieldName("name");
|
|
441
|
+
const aliasNode = child.childForFieldName("alias");
|
|
442
|
+
if (nameNode) {
|
|
443
|
+
imports.push({
|
|
444
|
+
moduleName: nameNode.text,
|
|
445
|
+
isRelative: false,
|
|
446
|
+
importedNames: [],
|
|
447
|
+
isWholeModule: true,
|
|
448
|
+
alias: aliasNode?.text,
|
|
449
|
+
range: toRange(node),
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
/** Handle `from X import Y`, `from . import Z`, `from ..pkg import W` */
|
|
456
|
+
extractImportFromStatement(node, imports) {
|
|
457
|
+
const moduleNode = node.childForFieldName("module_name");
|
|
458
|
+
let moduleName = "";
|
|
459
|
+
let isRelative = false;
|
|
460
|
+
// Check for relative import prefix (dots before module name)
|
|
461
|
+
let dotsPrefix = "";
|
|
462
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
463
|
+
const child = node.child(i);
|
|
464
|
+
if (child.type === "relative_import") {
|
|
465
|
+
// relative_import contains dot(s) and optionally a dotted_name
|
|
466
|
+
for (let j = 0; j < child.childCount; j++) {
|
|
467
|
+
const rc = child.child(j);
|
|
468
|
+
if (rc.type === "import_prefix") {
|
|
469
|
+
dotsPrefix = rc.text;
|
|
470
|
+
}
|
|
471
|
+
else if (rc.type === "dotted_name") {
|
|
472
|
+
moduleName = rc.text;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
isRelative = true;
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (!isRelative && moduleNode) {
|
|
480
|
+
moduleName = moduleNode.text;
|
|
481
|
+
isRelative = moduleName.startsWith(".");
|
|
482
|
+
}
|
|
483
|
+
if (isRelative && dotsPrefix) {
|
|
484
|
+
moduleName = dotsPrefix + moduleName;
|
|
485
|
+
}
|
|
486
|
+
// Extract imported names
|
|
487
|
+
const importedNames = [];
|
|
488
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
489
|
+
const child = node.child(i);
|
|
490
|
+
if (child.type === "dotted_name" && child !== moduleNode) {
|
|
491
|
+
importedNames.push({ name: child.text });
|
|
492
|
+
}
|
|
493
|
+
else if (child.type === "aliased_import") {
|
|
494
|
+
const nameNode = child.childForFieldName("name");
|
|
495
|
+
const aliasNode = child.childForFieldName("alias");
|
|
496
|
+
if (nameNode) {
|
|
497
|
+
importedNames.push({
|
|
498
|
+
name: nameNode.text,
|
|
499
|
+
alias: aliasNode?.text,
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
else if (child.type === "wildcard_import") {
|
|
504
|
+
importedNames.push({ name: "*" });
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
imports.push({
|
|
508
|
+
moduleName: moduleName || ".",
|
|
509
|
+
isRelative,
|
|
510
|
+
importedNames,
|
|
511
|
+
isWholeModule: false,
|
|
512
|
+
range: toRange(node),
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
// ── Module-level assignment extraction ───────────────────────────────
|
|
516
|
+
extractAssignment(node, filePath, symbols, allNames) {
|
|
517
|
+
const child = node.child(0);
|
|
518
|
+
if (!child)
|
|
519
|
+
return;
|
|
520
|
+
// assignment: left = right
|
|
521
|
+
if (child.type === "assignment") {
|
|
522
|
+
const left = child.childForFieldName("left");
|
|
523
|
+
if (!left)
|
|
524
|
+
return;
|
|
525
|
+
// Skip __all__, __name__, etc. — these are metadata, not user-visible symbols
|
|
526
|
+
if (left.type === "identifier") {
|
|
527
|
+
const name = left.text;
|
|
528
|
+
if (name === "__all__" || name === "__name__" || name === "__file__")
|
|
529
|
+
return;
|
|
530
|
+
const visibility = getVisibility(name);
|
|
531
|
+
const exported = isExportedName(name, allNames);
|
|
532
|
+
// Determine if it looks like a constant (UPPER_SNAKE_CASE)
|
|
533
|
+
const isConst = /^[A-Z][A-Z0-9_]*$/.test(name);
|
|
534
|
+
symbols.push({
|
|
535
|
+
name,
|
|
536
|
+
kind: "variable",
|
|
537
|
+
filePath,
|
|
538
|
+
range: toRange(node),
|
|
539
|
+
isExported: exported,
|
|
540
|
+
visibility,
|
|
541
|
+
signature: isConst ? `${name} = ...` : undefined,
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
// Type-annotated assignment: x: int = 5
|
|
546
|
+
if (child.type === "type_alias_statement") {
|
|
547
|
+
// `type X = ...` (Python 3.12+)
|
|
548
|
+
const nameNode = child.childForFieldName("name");
|
|
549
|
+
if (nameNode) {
|
|
550
|
+
const name = nameNode.text;
|
|
551
|
+
symbols.push({
|
|
552
|
+
name,
|
|
553
|
+
kind: "variable",
|
|
554
|
+
filePath,
|
|
555
|
+
range: toRange(node),
|
|
556
|
+
isExported: isExportedName(name, allNames),
|
|
557
|
+
visibility: getVisibility(name),
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
// ── Factory ──────────────────────────────────────────────────────────────────
|
|
564
|
+
export function createPythonExtractor(workspaceRoot, options) {
|
|
565
|
+
return new PythonExtractor(workspaceRoot, options);
|
|
566
|
+
}
|
|
567
|
+
//# sourceMappingURL=extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractor.js","sourceRoot":"","sources":["../src/extractor.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,sCAAsC;AAEtC;;;;;;GAMG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAW7B,gFAAgF;AAEhF,SAAS,OAAO,CAAC,IAAuB;IACtC,OAAO;QACL,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC;QACrC,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM;QACtC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC;QACjC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM;KACnC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAC,IAAY;IACjC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IACpE,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,WAAW,CAAC;IAC7C,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CAAC,IAAY,EAAE,QAA4B;IAChE,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC;AAED,mEAAmE;AACn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AG,IAAI,QAAQ,CAAC,CAAC,CAAC,SAAS;iBACjD,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,wCAAwC;QACxC,IAAI,KAAK,CAAC,IAAI,KAAK,sBAAsB,EAAE,CAAC;YAC1C,gCAAgC;YAChC,MAAM,QAAQ,GAAG,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;YACjD,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;gBAC3B,OAAO,CAAC,IAAI,CAAC;oBACX,IAAI;oBACJ,IAAI,EAAE,UAAU;oBAChB,QAAQ;oBACR,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC;oBACpB,UAAU,EAAE,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC;oBAC1C,UAAU,EAAE,aAAa,CAAC,IAAI,CAAC;iBAChC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,gFAAgF;AAEhF,MAAM,UAAU,qBAAqB,CACnC,aAAqB,EACrB,OAA0C;IAE1C,OAAO,IAAI,eAAe,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Python Parser - Public API
|
|
3
|
+
*
|
|
4
|
+
* Tree-sitter based AST extractor for Python source files.
|
|
5
|
+
* Extracts functions, classes, methods, decorators, imports,
|
|
6
|
+
* module-level variables, and type hints from .py files.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createPythonExtractor } from '@intentweave/python-parser';
|
|
11
|
+
*
|
|
12
|
+
* const extractor = createPythonExtractor('/path/to/python-project');
|
|
13
|
+
* const result = await extractor.extractFile('src/app.py');
|
|
14
|
+
*
|
|
15
|
+
* console.log(`Found ${result.symbols.length} symbols`);
|
|
16
|
+
* for (const sym of result.symbols) {
|
|
17
|
+
* console.log(` ${sym.kind} ${sym.name} (${sym.visibility ?? 'public'})`);
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export type { PythonSymbolKind, SourceRange, PythonSymbol, PythonImport, PythonFileResult, PythonExtractionOptions, PythonBatchResult, } from "./types.js";
|
|
22
|
+
export { PythonExtractor, createPythonExtractor } from "./extractor.js";
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,sCAAsC;AAkCtC,sBAAsB;AACtB,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Python Parser Types
|
|
3
|
+
*
|
|
4
|
+
* Types for extracted Python code symbols.
|
|
5
|
+
* Compatible with the @intentweave/ast-extractor type shapes so AX stage
|
|
6
|
+
* can consume TypeScript, Swift, and Python extraction results uniformly.
|
|
7
|
+
*/
|
|
8
|
+
export type PythonSymbolKind = "function" | "class" | "method" | "property" | "variable" | "module";
|
|
9
|
+
export interface SourceRange {
|
|
10
|
+
startLine: number;
|
|
11
|
+
startColumn: number;
|
|
12
|
+
endLine: number;
|
|
13
|
+
endColumn: number;
|
|
14
|
+
}
|
|
15
|
+
export interface PythonSymbol {
|
|
16
|
+
name: string;
|
|
17
|
+
kind: PythonSymbolKind;
|
|
18
|
+
filePath: string;
|
|
19
|
+
range: SourceRange;
|
|
20
|
+
/** Parent class name for methods/properties */
|
|
21
|
+
parent?: string;
|
|
22
|
+
/**
|
|
23
|
+
* In Python there's no `export` keyword. We treat module-level symbols
|
|
24
|
+
* (not prefixed with `_`) as "exported" and `_`-prefixed as "internal".
|
|
25
|
+
* Symbols listed in `__all__` are always exported.
|
|
26
|
+
*/
|
|
27
|
+
isExported: boolean;
|
|
28
|
+
/** async def? */
|
|
29
|
+
isAsync?: boolean;
|
|
30
|
+
/** @staticmethod or @classmethod? */
|
|
31
|
+
isStatic?: boolean;
|
|
32
|
+
/** Name starts with `_` (convention-private) or `__` (name-mangled) */
|
|
33
|
+
visibility?: "public" | "private" | "protected";
|
|
34
|
+
/** First line of docstring (triple-quoted string after def/class) */
|
|
35
|
+
docSummary?: string;
|
|
36
|
+
/** Parameter names for functions/methods */
|
|
37
|
+
parameters?: string[];
|
|
38
|
+
/** Raw signature: `def foo(x: int, y: str) -> bool` */
|
|
39
|
+
signature?: string;
|
|
40
|
+
/** Decorator names (e.g., ["staticmethod", "property"]) */
|
|
41
|
+
decorators?: string[];
|
|
42
|
+
/** Base classes for class declarations */
|
|
43
|
+
bases?: string[];
|
|
44
|
+
}
|
|
45
|
+
export interface PythonImport {
|
|
46
|
+
/** Module path, e.g. "os.path" or ".utils" */
|
|
47
|
+
moduleName: string;
|
|
48
|
+
/** Is relative import? (starts with `.`) */
|
|
49
|
+
isRelative: boolean;
|
|
50
|
+
/** Individual names imported (`from X import a, b`) — empty for `import X` */
|
|
51
|
+
importedNames: Array<{
|
|
52
|
+
name: string;
|
|
53
|
+
alias?: string;
|
|
54
|
+
}>;
|
|
55
|
+
/** The whole module is imported (import X / import X as Y) */
|
|
56
|
+
isWholeModule: boolean;
|
|
57
|
+
/** Alias for module-level import (`import X as Y`) */
|
|
58
|
+
alias?: string;
|
|
59
|
+
range: SourceRange;
|
|
60
|
+
}
|
|
61
|
+
export interface PythonFileResult {
|
|
62
|
+
filePath: string;
|
|
63
|
+
language: "python";
|
|
64
|
+
symbols: PythonSymbol[];
|
|
65
|
+
imports: PythonImport[];
|
|
66
|
+
extractedAt: number;
|
|
67
|
+
errors?: string[];
|
|
68
|
+
}
|
|
69
|
+
export interface PythonExtractionOptions {
|
|
70
|
+
includePrivate?: boolean;
|
|
71
|
+
includeDocSummary?: boolean;
|
|
72
|
+
includeParameters?: boolean;
|
|
73
|
+
includeMembers?: boolean;
|
|
74
|
+
maxDepth?: number;
|
|
75
|
+
}
|
|
76
|
+
export interface PythonBatchResult {
|
|
77
|
+
files: Map<string, PythonFileResult>;
|
|
78
|
+
totalSymbols: number;
|
|
79
|
+
totalFiles: number;
|
|
80
|
+
failures: Array<{
|
|
81
|
+
filePath: string;
|
|
82
|
+
error: string;
|
|
83
|
+
}>;
|
|
84
|
+
durationMs: number;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AAEH,MAAM,MAAM,gBAAgB,GACxB,UAAU,GACV,OAAO,GACP,QAAQ,GACR,UAAU,GACV,UAAU,GACV,QAAQ,CAAC;AAEb,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,WAAW,CAAC;IAEnB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,M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OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,sCAAsC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@intentweave/python-parser",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Tree-sitter based AST extractor for Python source files",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"tree-sitter": "^0.21.1",
|
|
22
|
+
"tree-sitter-python": "^0.21.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"typescript": "^5.6.0",
|
|
26
|
+
"vitest": "^2.1.0"
|
|
27
|
+
},
|
|
28
|
+
"intentweave": {
|
|
29
|
+
"tier": "oss",
|
|
30
|
+
"description": "Python AST extraction engine — open-source, enables code linking for Python projects"
|
|
31
|
+
},
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/intentweave/intentweave.git",
|
|
36
|
+
"directory": "packages/python-parser"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=20.0.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:unit": "vitest run",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"lint": "echo 'TODO: eslint'",
|
|
47
|
+
"clean": "rm -rf dist *.tsbuildinfo"
|
|
48
|
+
}
|
|
49
|
+
}
|