@codechart/core 0.3.0 → 0.7.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/README.md CHANGED
@@ -8,8 +8,12 @@ It is the part both products must agree on:
8
8
  - **Truth checks** — anchor reading, mention checks and the checks that compare a claim with the code and the git diff; map layout (elkjs).
9
9
  - **Git rules** — changed files, log, preview and diff, and which diagram a change should produce.
10
10
  - **Review notes** — the note format, parser, merge, carry-over and storage, plus shared page and review file naming.
11
- - **Config** — the `.codechart.yaml` schema, loader and repo-root lookup.
12
- - **Code layer** — reads a repo's files and their symbols (classes, functions, methods, types) with tree-sitter, for TypeScript and JavaScript so far. `parseRepo` reads a whole repo, `parseCode` one file; a file with a syntax error keeps its last good symbols. Imports resolve to repo files (relative paths, tsconfig `paths`, package `exports` and `imports`, npm, yarn and pnpm workspaces mapped to their source) and imported names are followed through barrel files to where they're defined; an import nothing proves is `unknown`, a package outside the repo `external`. `createResolver` and `linkImports` re-resolve without re-parsing.
11
+ - **Config** — the `.codechart.yaml` schema, loader and repo-root lookup, and `writePinned`, which writes the `map.pinned` names sorted by id and leaves the rest of the file as it was.
12
+ - **Code layer** — reads a repo's files, their symbols (classes, functions, methods, types) and their calls with tree-sitter, for TypeScript, JavaScript and Python. `parseRepo` reads a whole repo, `parseCode` one file, and `openCodeIndex` keeps one repo current: a save re-parses only the files whose content hash changed, then re-matches only the code another file's change can reach (reverse indexes for imports and names); a file with a syntax error keeps its last good symbols, and the last good imports and export names its text still names. Imports resolve to repo files (relative paths, tsconfig `paths`, package `exports` and `imports`, npm, yarn and pnpm workspaces mapped to their source) and imported names are followed through barrel files to where they're defined; an import nothing proves is `unknown`, a package outside the repo `external`. A call is `resolved` only when a resolved import or a same-file definition reaches its function; otherwise it is `name-only`. Python imports resolve following CPython's path finder over the project's source roots (`src/` for files under it; `src/` and the project root for the rest); a module found nowhere in the repo is `external`, and in a file that edits `sys.path`, absolute imports of non-stdlib modules are `unknown`. Files without imports get entities and references instead:
13
+ - Entities: SQL `CREATE TABLE`s, the jobs and steps of `.github/workflows` files, docker-compose services, `package.json` scripts, and Bash functions (as symbols).
14
+ - References: the files workflow `run` steps and npm scripts run, Bash `source` and `.`, HTML `<script src>` and `<link href>`, and CSS `@import`.
15
+ - A reference is `resolved` only to a file of the code layer, and only where its folder is fixed: the page or stylesheet's folder, the package folder for npm scripts, the step's working directory after an `actions/checkout` of the repo, or the script's own folder written with `dirname "$0"` or `BASH_SOURCE`. A URL is `external`, and anything else is `unknown`.
16
+ - `createResolver`, `linkImports` and `linkCode` re-resolve without re-parsing.
13
17
  - **Agent presets** — the agents codechart knows, their skill folders, and commander-free helpers to install and remove the skill.
14
18
 
15
19
  The CLI owns everything that talks to a user or an agent: commands, terminal and HTML renderers, PR maps, the update check and the OpenCode plugin.
@@ -21,7 +25,7 @@ Version `0.x`: the API may change between minor versions. The app pins a version
21
25
  ## Usage
22
26
 
23
27
  ```ts
24
- import { validateSpec, checkMapNodes, layoutSpec, loadConfig, parseRepo } from '@codechart/core';
28
+ import { validateSpec, checkMapNodes, layoutSpec, loadConfig, parseRepo, openCodeIndex } from '@codechart/core';
25
29
  ```
26
30
 
27
31
  Node 22.12 or later, ESM.
@@ -1,6 +1,6 @@
1
1
  # Third-party notices
2
2
 
3
- `dist/grammars/` holds files copied from these tree-sitter grammars: the compiled `.wasm` parsers and the `queries/tags.scm` definition queries.
3
+ `dist/grammars/` holds files copied from these tree-sitter grammars: the compiled `.wasm` parsers and, for JavaScript, TypeScript and Python, the `queries/tags.scm` definition queries. `@derekstride/tree-sitter-sql` ships no `.wasm`: `scripts/build-sql-grammar.sh` in the repository compiles it from the published package.
4
4
 
5
5
  ## tree-sitter-javascript 0.25.0
6
6
 
@@ -31,6 +31,35 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
31
  SOFTWARE.
32
32
  ```
33
33
 
34
+ ## tree-sitter-python 0.25.0
35
+
36
+ - Source: <https://github.com/tree-sitter/tree-sitter-python>
37
+ - License: MIT
38
+
39
+ ```text
40
+ The MIT License (MIT)
41
+
42
+ Copyright (c) 2016 Max Brunsfeld
43
+
44
+ Permission is hereby granted, free of charge, to any person obtaining a copy
45
+ of this software and associated documentation files (the "Software"), to deal
46
+ in the Software without restriction, including without limitation the rights
47
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
48
+ copies of the Software, and to permit persons to whom the Software is
49
+ furnished to do so, subject to the following conditions:
50
+
51
+ The above copyright notice and this permission notice shall be included in all
52
+ copies or substantial portions of the Software.
53
+
54
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
55
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
56
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
57
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
58
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
59
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
60
+ SOFTWARE.
61
+ ```
62
+
34
63
  ## tree-sitter-typescript 0.23.2
35
64
 
36
65
  - Source: <https://github.com/tree-sitter/tree-sitter-typescript>
@@ -59,3 +88,176 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
59
88
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
60
89
  SOFTWARE.
61
90
  ```
91
+
92
+ ## tree-sitter-html 0.23.2
93
+
94
+ - Source: <https://github.com/tree-sitter/tree-sitter-html>
95
+ - License: MIT
96
+
97
+ ```text
98
+ The MIT License (MIT)
99
+
100
+ Copyright (c) 2014 Max Brunsfeld
101
+
102
+ Permission is hereby granted, free of charge, to any person obtaining a copy
103
+ of this software and associated documentation files (the "Software"), to deal
104
+ in the Software without restriction, including without limitation the rights
105
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
106
+ copies of the Software, and to permit persons to whom the Software is
107
+ furnished to do so, subject to the following conditions:
108
+
109
+ The above copyright notice and this permission notice shall be included in all
110
+ copies or substantial portions of the Software.
111
+
112
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
113
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
114
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
115
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
116
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
117
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
118
+ SOFTWARE.
119
+ ```
120
+
121
+ ## tree-sitter-css 0.25.0
122
+
123
+ - Source: <https://github.com/tree-sitter/tree-sitter-css>
124
+ - License: MIT
125
+
126
+ ```text
127
+ The MIT License (MIT)
128
+
129
+ Copyright (c) 2018 Max Brunsfeld
130
+
131
+ Permission is hereby granted, free of charge, to any person obtaining a copy
132
+ of this software and associated documentation files (the "Software"), to deal
133
+ in the Software without restriction, including without limitation the rights
134
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
135
+ copies of the Software, and to permit persons to whom the Software is
136
+ furnished to do so, subject to the following conditions:
137
+
138
+ The above copyright notice and this permission notice shall be included in all
139
+ copies or substantial portions of the Software.
140
+
141
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
142
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
143
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
144
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
145
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
146
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
147
+ SOFTWARE.
148
+ ```
149
+
150
+ ## tree-sitter-bash 0.25.1
151
+
152
+ - Source: <https://github.com/tree-sitter/tree-sitter-bash>
153
+ - License: MIT
154
+
155
+ ```text
156
+ The MIT License (MIT)
157
+
158
+ Copyright (c) 2017 Max Brunsfeld
159
+
160
+ Permission is hereby granted, free of charge, to any person obtaining a copy
161
+ of this software and associated documentation files (the "Software"), to deal
162
+ in the Software without restriction, including without limitation the rights
163
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
164
+ copies of the Software, and to permit persons to whom the Software is
165
+ furnished to do so, subject to the following conditions:
166
+
167
+ The above copyright notice and this permission notice shall be included in all
168
+ copies or substantial portions of the Software.
169
+
170
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
171
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
172
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
173
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
174
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
175
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
176
+ SOFTWARE.
177
+ ```
178
+
179
+ ## tree-sitter-json 0.24.8
180
+
181
+ - Source: <https://github.com/tree-sitter/tree-sitter-json>
182
+ - License: MIT
183
+
184
+ ```text
185
+ The MIT License (MIT)
186
+
187
+ Copyright (c) 2014 Max Brunsfeld
188
+
189
+ Permission is hereby granted, free of charge, to any person obtaining a copy
190
+ of this software and associated documentation files (the "Software"), to deal
191
+ in the Software without restriction, including without limitation the rights
192
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
193
+ copies of the Software, and to permit persons to whom the Software is
194
+ furnished to do so, subject to the following conditions:
195
+
196
+ The above copyright notice and this permission notice shall be included in all
197
+ copies or substantial portions of the Software.
198
+
199
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
200
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
201
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
202
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
203
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
204
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
205
+ SOFTWARE.
206
+ ```
207
+
208
+ ## @tree-sitter-grammars/tree-sitter-yaml 0.7.1
209
+
210
+ - Source: <https://github.com/tree-sitter-grammars/tree-sitter-yaml>
211
+ - License: MIT
212
+
213
+ ```text
214
+ Copyright (c) 2024 tree-sitter-grammars contributors
215
+ Copyright (c) 2019-2021 Ika
216
+
217
+ Permission is hereby granted, free of charge, to any person obtaining a copy
218
+ of this software and associated documentation files (the "Software"), to deal
219
+ in the Software without restriction, including without limitation the rights
220
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
221
+ copies of the Software, and to permit persons to whom the Software is
222
+ furnished to do so, subject to the following conditions:
223
+
224
+ The above copyright notice and this permission notice shall be included in all
225
+ copies or substantial portions of the Software.
226
+
227
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
228
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
229
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
230
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
231
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
232
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
233
+ SOFTWARE.
234
+ ```
235
+
236
+ ## @derekstride/tree-sitter-sql 0.3.13
237
+
238
+ - Source: <https://github.com/DerekStride/tree-sitter-sql>
239
+ - License: MIT
240
+
241
+ ```text
242
+ MIT License
243
+
244
+ Copyright (c) 2021 Derek Stride
245
+
246
+ Permission is hereby granted, free of charge, to any person obtaining a copy
247
+ of this software and associated documentation files (the "Software"), to deal
248
+ in the Software without restriction, including without limitation the rights
249
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
250
+ copies of the Software, and to permit persons to whom the Software is
251
+ furnished to do so, subject to the following conditions:
252
+
253
+ The above copyright notice and this permission notice shall be included in all
254
+ copies or substantial portions of the Software.
255
+
256
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
257
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
258
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
259
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
260
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
261
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
262
+ SOFTWARE.
263
+ ```
@@ -0,0 +1,14 @@
1
+ (module (expression_statement (assignment left: (identifier) @name) @definition.constant))
2
+
3
+ (class_definition
4
+ name: (identifier) @name) @definition.class
5
+
6
+ (function_definition
7
+ name: (identifier) @name) @definition.function
8
+
9
+ (call
10
+ function: [
11
+ (identifier) @name
12
+ (attribute
13
+ attribute: (identifier) @name)
14
+ ]) @reference.call