codeecho 1.0.0__tar.gz → 1.1.0__tar.gz

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.
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ ## 1.1.0 - 2026-08-15
4
+
5
+ ### Added
6
+
7
+ - Gosu (`.gs`, `.gsx`) is now parsed with a dedicated [tree-sitter-gosu](https://github.com/rcw3bb/tree-sitter-gosu)
8
+ grammar instead of the Java fallback, enabling accurate fragment extraction using Gosu-native node types
9
+ (`compilation_unit`, `function_declaration`, `constructor_declaration`, `class_declaration`).
10
+
11
+ ## 1.0.1 - 2026-07-10
12
+
13
+ ### Fixed
14
+
15
+ - Type-3 clone detection no longer flags fragments as clones when one is nested inside the other
16
+ within the same file (e.g. a `function` inside its enclosing `class`).
17
+ - Type-3 clone groups now drop outer/container fragments (e.g. a whole-`file` fragment) when a
18
+ more specific nested fragment from the same file is already a member of that group, preventing
19
+ false positives caused by union-find transitivity.
20
+
21
+ ## 1.0.0 - 2026-07-10
22
+
23
+ ### Added
24
+
25
+ - Initial release of codeecho.
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Ron Webb
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ron Webb
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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codeecho
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: A developer tool that scans your codebase to detect and highlight ECHOES of duplicated or near-duplicated code so you can refactor toward cleaner, more maintainable designs.
5
5
  License: MIT License
6
6
 
@@ -37,18 +37,19 @@ Requires-Dist: logenrich (>=1.0.1,<2.0.0)
37
37
  Requires-Dist: rich (>=15.0.0,<16.0.0)
38
38
  Requires-Dist: tree-sitter (>=0.26.0,<0.27.0)
39
39
  Requires-Dist: tree-sitter-go (>=0.25.0,<0.26.0)
40
+ Requires-Dist: tree-sitter-gosu (>=0.2.0,<0.3.0)
40
41
  Requires-Dist: tree-sitter-java (>=0.23.5,<0.24.0)
41
42
  Requires-Dist: tree-sitter-javascript (>=0.25.0,<0.26.0)
42
43
  Requires-Dist: tree-sitter-python (>=0.25.0,<0.26.0)
43
44
  Requires-Dist: tree-sitter-typescript (>=0.23.2,<0.24.0)
44
45
  Description-Content-Type: text/markdown
45
46
 
46
- # codeecho 1.0.0
47
+ # codeecho 1.1.0
47
48
 
48
49
  > A developer tool that scans your codebase to detect and highlight **echoes** of duplicated or near-duplicated code, so you can refactor toward cleaner, more maintainable designs.
49
50
 
50
51
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
51
- [![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)](CHANGELOG.md)
52
+ [![Version](https://img.shields.io/badge/version-1.1.0-blue.svg)](CHANGELOG.md)
52
53
 
53
54
  ## Prerequisites
54
55
 
@@ -76,14 +77,14 @@ python -m codeecho <path> [options]
76
77
 
77
78
  ### Supported languages
78
79
 
79
- | Language | Extensions |
80
- |----------|-----------|
81
- | Python | `.py` |
82
- | JavaScript | `.js`, `.mjs`, `.cjs` |
83
- | TypeScript | `.ts`, `.tsx` |
84
- | Java | `.java` |
85
- | Go | `.go` |
86
- | Gosu | `.gs`, `.gsx` |
80
+ | Language | Extensions | Grammar |
81
+ |----------|-----------|--------|
82
+ | Python | `.py` | [tree-sitter-python](https://github.com/tree-sitter/tree-sitter-python) |
83
+ | JavaScript | `.js`, `.mjs`, `.cjs` | [tree-sitter-javascript](https://github.com/tree-sitter/tree-sitter-javascript) |
84
+ | TypeScript | `.ts`, `.tsx` | [tree-sitter-typescript](https://github.com/tree-sitter/tree-sitter-typescript) |
85
+ | Java | `.java` | [tree-sitter-java](https://github.com/tree-sitter/tree-sitter-java) |
86
+ | Go | `.go` | [tree-sitter-go](https://github.com/tree-sitter/tree-sitter-go) |
87
+ | Gosu | `.gs`, `.gsx` | [tree-sitter-gosu](https://github.com/rcw3bb/tree-sitter-gosu) |
87
88
 
88
89
  ### Arguments
89
90
 
@@ -1,162 +1,162 @@
1
- # codeecho 1.0.0
2
-
3
- > A developer tool that scans your codebase to detect and highlight **echoes** of duplicated or near-duplicated code, so you can refactor toward cleaner, more maintainable designs.
4
-
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
- [![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)](CHANGELOG.md)
7
-
8
- ## Prerequisites
9
-
10
- - Python `>=3.14`
11
-
12
- ## Installation
13
-
14
- ```powershell
15
- pip install codeecho
16
- ```
17
-
18
- ## Usage
19
-
20
- ```powershell
21
- python -m codeecho <path> [options]
22
- ```
23
-
24
- ### Clone detection levels
25
-
26
- | Type | Detection strategy | Example |
27
- |------|--------------------|---------|
28
- | **Type-1** | Exact copy-paste — identical token sequences | Two functions with the same code copied verbatim |
29
- | **Type-2** | Structural clone — same structure, renamed identifiers / literals | Same logic with different variable names |
30
- | **Type-3** | Near-duplicate — high Jaccard similarity on token sets | Nearly identical functions with a few extra lines |
31
-
32
- ### Supported languages
33
-
34
- | Language | Extensions |
35
- |----------|-----------|
36
- | Python | `.py` |
37
- | JavaScript | `.js`, `.mjs`, `.cjs` |
38
- | TypeScript | `.ts`, `.tsx` |
39
- | Java | `.java` |
40
- | Go | `.go` |
41
- | Gosu | `.gs`, `.gsx` |
42
-
43
- ### Arguments
44
-
45
- | Argument | Description |
46
- |----------|-------------|
47
- | `path` | Root directory to scan. |
48
-
49
- ### Options
50
-
51
- | Option | Default | Description |
52
- |--------|---------|-------------|
53
- | `--types <types>` | `all` | Clone types to detect: comma-separated (`1`, `2`, `3`) or `all`. |
54
- | `--threshold <float>` | `0.8` | Jaccard similarity threshold for Type-3 detection (`0.0`–`1.0`). |
55
- | `--output <name>` | `codeecho-output` | Base name (without extension) for output file(s). |
56
- | `--output-dir <dir>` | `<cwd>/reports` | Directory where output file(s) will be written. |
57
- | `--db-dir <dir>` | `~/.codeecho` | Directory for the SQLite scratch database (`codeecho.db`). Session records are removed after the report is written. |
58
- | `--format <fmt>` | `both` | Output format: `json`, `html`, or `both`. |
59
- | `--min-tokens <n>` | `10` | Minimum token count for a code fragment to be included. |
60
- | `--exclude <pattern>` | _(none)_ | Glob pattern(s) to exclude from scanning (repeatable). |
61
- | `--version` | | Print the version and exit. |
62
- | `-h, --help` | | Show help and exit. |
63
-
64
- ### Examples
65
-
66
- Scan the current directory and write both JSON and HTML reports:
67
-
68
- ```powershell
69
- python -m codeecho .
70
- ```
71
-
72
- Detect only Type-1 and Type-2 clones in a `src/` tree:
73
-
74
- ```powershell
75
- python -m codeecho src --types 1,2
76
- ```
77
-
78
- Scan with a custom output name and directory:
79
-
80
- ```powershell
81
- python -m codeecho . --output my-scan --output-dir audit/reports
82
- ```
83
-
84
- Lower the Type-3 threshold to catch more near-duplicates:
85
-
86
- ```powershell
87
- python -m codeecho . --threshold 0.6
88
- ```
89
-
90
- Exclude test and vendor directories:
91
-
92
- ```powershell
93
- python -m codeecho . --exclude "*/tests/*" --exclude "*/vendor/*"
94
- ```
95
-
96
- ## Configuration
97
-
98
- | Environment variable | Description |
99
- |----------------------|-------------|
100
- | `CODEECHO_CONFIG_DIR` | Directory where `logging.ini` and `.ignore` are seeded on first run. When unset, the bundled copies inside the package are used directly. |
101
-
102
- ### `.ignore` file
103
-
104
- On first run, a `.ignore` file is seeded into `CODEECHO_CONFIG_DIR` (or the package directory when unset). It follows gitignore syntax and is applied during file scanning to exclude paths in addition to any `--exclude` patterns passed on the command line. Edit this file to permanently suppress paths you never want scanned.
105
-
106
- ## Development
107
-
108
- ### Prerequisites
109
-
110
- - Poetry `2.2+`
111
-
112
- ### Setup
113
-
114
- ```powershell
115
- poetry install
116
- ```
117
-
118
- ### Run
119
-
120
- ```powershell
121
- poetry run python -m codeecho <path> [options]
122
- ```
123
-
124
- ### Architecture
125
-
126
- ```mermaid
127
- flowchart TD
128
- CLI["__main__.py\n(Click CLI)"] --> ScannerM["scanner.py\nFile discovery"]
129
- ScannerM --> Parser["parser.py\nTree-sitter parsing"]
130
- Parser --> Extractor["extractor.py\nFragment extraction\n(functions · classes · files)"]
131
- Extractor --> Normalizer["normalizer.py\nRegex tokeniser\nType-2 normalisation"]
132
- Normalizer --> Fingerprint["fingerprint.py\nSHA-256 hashing"]
133
- Fingerprint --> DB["db.py\nSQLite session store"]
134
- DB --> Detector["detector.py\nType-1 / 2 hash grouping\nType-3 Jaccard similarity"]
135
- Detector --> DB
136
- DB --> JSON["reporter/json_reporter.py\nJSON report"]
137
- DB --> HTML["reporter/html_reporter.py\nHTML report"]
138
- DB -->|delete session| Cleanup["Session cleanup"]
139
- ```
140
-
141
- ### Format and Lint
142
-
143
- ```powershell
144
- poetry run black codeecho
145
- poetry run pylint codeecho
146
- ```
147
-
148
- ### Run Tests with Coverage
149
-
150
- ```powershell
151
- poetry run pytest --cov=codeecho tests --cov-report html
152
- ```
153
-
154
- ## [Changelog](CHANGELOG.md)
155
-
156
- ## License
157
-
158
- This project is licensed under the [MIT License](LICENSE).
159
-
160
- ## Author
161
-
162
- Ron Webb
1
+ # codeecho 1.1.0
2
+
3
+ > A developer tool that scans your codebase to detect and highlight **echoes** of duplicated or near-duplicated code, so you can refactor toward cleaner, more maintainable designs.
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
+ [![Version](https://img.shields.io/badge/version-1.1.0-blue.svg)](CHANGELOG.md)
7
+
8
+ ## Prerequisites
9
+
10
+ - Python `>=3.14`
11
+
12
+ ## Installation
13
+
14
+ ```powershell
15
+ pip install codeecho
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```powershell
21
+ python -m codeecho <path> [options]
22
+ ```
23
+
24
+ ### Clone detection levels
25
+
26
+ | Type | Detection strategy | Example |
27
+ |------|--------------------|---------|
28
+ | **Type-1** | Exact copy-paste — identical token sequences | Two functions with the same code copied verbatim |
29
+ | **Type-2** | Structural clone — same structure, renamed identifiers / literals | Same logic with different variable names |
30
+ | **Type-3** | Near-duplicate — high Jaccard similarity on token sets | Nearly identical functions with a few extra lines |
31
+
32
+ ### Supported languages
33
+
34
+ | Language | Extensions | Grammar |
35
+ |----------|-----------|--------|
36
+ | Python | `.py` | [tree-sitter-python](https://github.com/tree-sitter/tree-sitter-python) |
37
+ | JavaScript | `.js`, `.mjs`, `.cjs` | [tree-sitter-javascript](https://github.com/tree-sitter/tree-sitter-javascript) |
38
+ | TypeScript | `.ts`, `.tsx` | [tree-sitter-typescript](https://github.com/tree-sitter/tree-sitter-typescript) |
39
+ | Java | `.java` | [tree-sitter-java](https://github.com/tree-sitter/tree-sitter-java) |
40
+ | Go | `.go` | [tree-sitter-go](https://github.com/tree-sitter/tree-sitter-go) |
41
+ | Gosu | `.gs`, `.gsx` | [tree-sitter-gosu](https://github.com/rcw3bb/tree-sitter-gosu) |
42
+
43
+ ### Arguments
44
+
45
+ | Argument | Description |
46
+ |----------|-------------|
47
+ | `path` | Root directory to scan. |
48
+
49
+ ### Options
50
+
51
+ | Option | Default | Description |
52
+ |--------|---------|-------------|
53
+ | `--types <types>` | `all` | Clone types to detect: comma-separated (`1`, `2`, `3`) or `all`. |
54
+ | `--threshold <float>` | `0.8` | Jaccard similarity threshold for Type-3 detection (`0.0`–`1.0`). |
55
+ | `--output <name>` | `codeecho-output` | Base name (without extension) for output file(s). |
56
+ | `--output-dir <dir>` | `<cwd>/reports` | Directory where output file(s) will be written. |
57
+ | `--db-dir <dir>` | `~/.codeecho` | Directory for the SQLite scratch database (`codeecho.db`). Session records are removed after the report is written. |
58
+ | `--format <fmt>` | `both` | Output format: `json`, `html`, or `both`. |
59
+ | `--min-tokens <n>` | `10` | Minimum token count for a code fragment to be included. |
60
+ | `--exclude <pattern>` | _(none)_ | Glob pattern(s) to exclude from scanning (repeatable). |
61
+ | `--version` | | Print the version and exit. |
62
+ | `-h, --help` | | Show help and exit. |
63
+
64
+ ### Examples
65
+
66
+ Scan the current directory and write both JSON and HTML reports:
67
+
68
+ ```powershell
69
+ python -m codeecho .
70
+ ```
71
+
72
+ Detect only Type-1 and Type-2 clones in a `src/` tree:
73
+
74
+ ```powershell
75
+ python -m codeecho src --types 1,2
76
+ ```
77
+
78
+ Scan with a custom output name and directory:
79
+
80
+ ```powershell
81
+ python -m codeecho . --output my-scan --output-dir audit/reports
82
+ ```
83
+
84
+ Lower the Type-3 threshold to catch more near-duplicates:
85
+
86
+ ```powershell
87
+ python -m codeecho . --threshold 0.6
88
+ ```
89
+
90
+ Exclude test and vendor directories:
91
+
92
+ ```powershell
93
+ python -m codeecho . --exclude "*/tests/*" --exclude "*/vendor/*"
94
+ ```
95
+
96
+ ## Configuration
97
+
98
+ | Environment variable | Description |
99
+ |----------------------|-------------|
100
+ | `CODEECHO_CONFIG_DIR` | Directory where `logging.ini` and `.ignore` are seeded on first run. When unset, the bundled copies inside the package are used directly. |
101
+
102
+ ### `.ignore` file
103
+
104
+ On first run, a `.ignore` file is seeded into `CODEECHO_CONFIG_DIR` (or the package directory when unset). It follows gitignore syntax and is applied during file scanning to exclude paths in addition to any `--exclude` patterns passed on the command line. Edit this file to permanently suppress paths you never want scanned.
105
+
106
+ ## Development
107
+
108
+ ### Prerequisites
109
+
110
+ - Poetry `2.2+`
111
+
112
+ ### Setup
113
+
114
+ ```powershell
115
+ poetry install
116
+ ```
117
+
118
+ ### Run
119
+
120
+ ```powershell
121
+ poetry run python -m codeecho <path> [options]
122
+ ```
123
+
124
+ ### Architecture
125
+
126
+ ```mermaid
127
+ flowchart TD
128
+ CLI["__main__.py\n(Click CLI)"] --> ScannerM["scanner.py\nFile discovery"]
129
+ ScannerM --> Parser["parser.py\nTree-sitter parsing"]
130
+ Parser --> Extractor["extractor.py\nFragment extraction\n(functions · classes · files)"]
131
+ Extractor --> Normalizer["normalizer.py\nRegex tokeniser\nType-2 normalisation"]
132
+ Normalizer --> Fingerprint["fingerprint.py\nSHA-256 hashing"]
133
+ Fingerprint --> DB["db.py\nSQLite session store"]
134
+ DB --> Detector["detector.py\nType-1 / 2 hash grouping\nType-3 Jaccard similarity"]
135
+ Detector --> DB
136
+ DB --> JSON["reporter/json_reporter.py\nJSON report"]
137
+ DB --> HTML["reporter/html_reporter.py\nHTML report"]
138
+ DB -->|delete session| Cleanup["Session cleanup"]
139
+ ```
140
+
141
+ ### Format and Lint
142
+
143
+ ```powershell
144
+ poetry run black codeecho
145
+ poetry run pylint codeecho
146
+ ```
147
+
148
+ ### Run Tests with Coverage
149
+
150
+ ```powershell
151
+ poetry run pytest --cov=codeecho tests --cov-report html
152
+ ```
153
+
154
+ ## [Changelog](CHANGELOG.md)
155
+
156
+ ## License
157
+
158
+ This project is licensed under the [MIT License](LICENSE).
159
+
160
+ ## Author
161
+
162
+ Ron Webb
@@ -1,22 +1,22 @@
1
- """
2
- codeecho - A developer tool that scans your codebase to detect and highlight ECHOES
3
- of duplicated or near-duplicated code so you can refactor toward cleaner, more
4
- maintainable designs.
5
- """
6
-
7
- from env_dir_bootstrap import EnvDirBootstrap
8
- from logenrich import setup_logger
9
-
10
- __version__ = "1.0.0"
11
-
12
- _bootstrapper = EnvDirBootstrap(
13
- env_var="CODEECHO_CONFIG_DIR",
14
- resources=["logging.ini", ".ignore"],
15
- package="codeecho",
16
- )
17
-
18
- _bootstrapper.setup()
19
-
20
- CONF_DIR = str(_bootstrapper.get_dir())
21
-
22
- setup_logger("codeecho", conf_dir=CONF_DIR)
1
+ """
2
+ codeecho - A developer tool that scans your codebase to detect and highlight ECHOES
3
+ of duplicated or near-duplicated code so you can refactor toward cleaner, more
4
+ maintainable designs.
5
+ """
6
+
7
+ from env_dir_bootstrap import EnvDirBootstrap
8
+ from logenrich import setup_logger
9
+
10
+ __version__ = "1.1.0"
11
+
12
+ _bootstrapper = EnvDirBootstrap(
13
+ env_var="CODEECHO_CONFIG_DIR",
14
+ resources=["logging.ini", ".ignore"],
15
+ package="codeecho",
16
+ )
17
+
18
+ _bootstrapper.setup()
19
+
20
+ CONF_DIR = str(_bootstrapper.get_dir())
21
+
22
+ setup_logger("codeecho", conf_dir=CONF_DIR)