@codechart/core 0.0.0-stage → 0.3.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MiscomLab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,31 @@
1
- # Temporary Holding Version
1
+ # @codechart/core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The engine shared by the [codechart CLI](https://www.npmjs.com/package/codechart) and the codechart desktop app.
4
+
5
+ It is the part both products must agree on:
6
+
7
+ - **Specs** — the map, flow, business, release and explain schemas, their zod validation and generated JSON schemas.
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
+ - **Git rules** — changed files, log, preview and diff, and which diagram a change should produce.
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.
13
+ - **Agent presets** — the agents codechart knows, their skill folders, and commander-free helpers to install and remove the skill.
14
+
15
+ 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.
16
+
17
+ ## Stability
18
+
19
+ Version `0.x`: the API may change between minor versions. The app pins a version (`"@codechart/core": "0.1.x"`) so it stays on a range it was built and tested against.
20
+
21
+ ## Usage
22
+
23
+ ```ts
24
+ import { validateSpec, checkMapNodes, layoutSpec, loadConfig, parseRepo } from '@codechart/core';
25
+ ```
26
+
27
+ Node 22.12 or later, ESM.
28
+
29
+ ## Licence
30
+
31
+ MIT. The map layout uses [elkjs](https://github.com/kieler/elkjs) at runtime, under the EPL-2.0 licence; see the notice in the [CLI package](https://github.com/MiscomLab/codechart/blob/main/packages/cli/THIRD_PARTY_NOTICES.md). The code layer runs [web-tree-sitter](https://github.com/tree-sitter/tree-sitter) and ships the MIT tree-sitter grammars listed in [THIRD_PARTY_NOTICES.md](https://github.com/MiscomLab/codechart/blob/main/packages/core/THIRD_PARTY_NOTICES.md).
@@ -0,0 +1,61 @@
1
+ # Third-party notices
2
+
3
+ `dist/grammars/` holds files copied from these tree-sitter grammars: the compiled `.wasm` parsers and the `queries/tags.scm` definition queries.
4
+
5
+ ## tree-sitter-javascript 0.25.0
6
+
7
+ - Source: <https://github.com/tree-sitter/tree-sitter-javascript>
8
+ - License: MIT
9
+
10
+ ```text
11
+ The MIT License (MIT)
12
+
13
+ Copyright (c) 2014 Max Brunsfeld
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ of this software and associated documentation files (the "Software"), to deal
17
+ in the Software without restriction, including without limitation the rights
18
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ copies of the Software, and to permit persons to whom the Software is
20
+ furnished to do so, subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in all
23
+ copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ SOFTWARE.
32
+ ```
33
+
34
+ ## tree-sitter-typescript 0.23.2
35
+
36
+ - Source: <https://github.com/tree-sitter/tree-sitter-typescript>
37
+ - License: MIT
38
+
39
+ ```text
40
+ The MIT License (MIT)
41
+
42
+ Copyright (c) 2017 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
+ ```
@@ -0,0 +1,99 @@
1
+ (
2
+ (comment)* @doc
3
+ .
4
+ (method_definition
5
+ name: (property_identifier) @name) @definition.method
6
+ (#not-eq? @name "constructor")
7
+ (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
8
+ (#select-adjacent! @doc @definition.method)
9
+ )
10
+
11
+ (
12
+ (comment)* @doc
13
+ .
14
+ [
15
+ (class
16
+ name: (_) @name)
17
+ (class_declaration
18
+ name: (_) @name)
19
+ ] @definition.class
20
+ (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
21
+ (#select-adjacent! @doc @definition.class)
22
+ )
23
+
24
+ (
25
+ (comment)* @doc
26
+ .
27
+ [
28
+ (function_expression
29
+ name: (identifier) @name)
30
+ (function_declaration
31
+ name: (identifier) @name)
32
+ (generator_function
33
+ name: (identifier) @name)
34
+ (generator_function_declaration
35
+ name: (identifier) @name)
36
+ ] @definition.function
37
+ (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
38
+ (#select-adjacent! @doc @definition.function)
39
+ )
40
+
41
+ (
42
+ (comment)* @doc
43
+ .
44
+ (lexical_declaration
45
+ (variable_declarator
46
+ name: (identifier) @name
47
+ value: [(arrow_function) (function_expression)]) @definition.function)
48
+ (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
49
+ (#select-adjacent! @doc @definition.function)
50
+ )
51
+
52
+ (
53
+ (comment)* @doc
54
+ .
55
+ (variable_declaration
56
+ (variable_declarator
57
+ name: (identifier) @name
58
+ value: [(arrow_function) (function_expression)]) @definition.function)
59
+ (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
60
+ (#select-adjacent! @doc @definition.function)
61
+ )
62
+
63
+ (assignment_expression
64
+ left: [
65
+ (identifier) @name
66
+ (member_expression
67
+ property: (property_identifier) @name)
68
+ ]
69
+ right: [(arrow_function) (function_expression)]
70
+ ) @definition.function
71
+
72
+ (pair
73
+ key: (property_identifier) @name
74
+ value: [(arrow_function) (function_expression)]) @definition.function
75
+
76
+ (
77
+ (call_expression
78
+ function: (identifier) @name) @reference.call
79
+ (#not-match? @name "^(require)$")
80
+ )
81
+
82
+ (call_expression
83
+ function: (member_expression
84
+ property: (property_identifier) @name)
85
+ arguments: (_) @reference.call)
86
+
87
+ (new_expression
88
+ constructor: (_) @name) @reference.class
89
+
90
+ (export_statement value: (assignment_expression left: (identifier) @name right: ([
91
+ (number)
92
+ (string)
93
+ (identifier)
94
+ (undefined)
95
+ (null)
96
+ (new_expression)
97
+ (binary_expression)
98
+ (call_expression)
99
+ ]))) @definition.constant
@@ -0,0 +1,23 @@
1
+ (function_signature
2
+ name: (identifier) @name) @definition.function
3
+
4
+ (method_signature
5
+ name: (property_identifier) @name) @definition.method
6
+
7
+ (abstract_method_signature
8
+ name: (property_identifier) @name) @definition.method
9
+
10
+ (abstract_class_declaration
11
+ name: (type_identifier) @name) @definition.class
12
+
13
+ (module
14
+ name: (identifier) @name) @definition.module
15
+
16
+ (interface_declaration
17
+ name: (type_identifier) @name) @definition.interface
18
+
19
+ (type_annotation
20
+ (type_identifier) @name) @reference.type
21
+
22
+ (new_expression
23
+ constructor: (identifier) @name) @reference.class