codeecho 1.0.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,7 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 - 2026-07-10
4
+
5
+ ### Added
6
+
7
+ - Initial release of codeecho.
codeecho-1.0.0/LICENSE ADDED
@@ -0,0 +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.
@@ -0,0 +1,208 @@
1
+ Metadata-Version: 2.4
2
+ Name: codeecho
3
+ Version: 1.0.0
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
+ License: MIT License
6
+
7
+ Copyright (c) 2026 Ron Webb
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+ License-File: LICENSE
27
+ Author: Ron Webb
28
+ Requires-Python: >=3.14
29
+ Classifier: License :: Other/Proprietary License
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: Programming Language :: Python :: 3.14
32
+ Requires-Dist: braincraft (>=1.2.0,<2.0.0)
33
+ Requires-Dist: click (>=8.4.2,<9.0.0)
34
+ Requires-Dist: env-dir-bootstrap (>=1.1.0,<2.0.0)
35
+ Requires-Dist: jinja2 (>=3.1)
36
+ Requires-Dist: logenrich (>=1.0.1,<2.0.0)
37
+ Requires-Dist: rich (>=15.0.0,<16.0.0)
38
+ Requires-Dist: tree-sitter (>=0.26.0,<0.27.0)
39
+ Requires-Dist: tree-sitter-go (>=0.25.0,<0.26.0)
40
+ Requires-Dist: tree-sitter-java (>=0.23.5,<0.24.0)
41
+ Requires-Dist: tree-sitter-javascript (>=0.25.0,<0.26.0)
42
+ Requires-Dist: tree-sitter-python (>=0.25.0,<0.26.0)
43
+ Requires-Dist: tree-sitter-typescript (>=0.23.2,<0.24.0)
44
+ Description-Content-Type: text/markdown
45
+
46
+ # codeecho 1.0.0
47
+
48
+ > 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
+ [![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
+
53
+ ## Prerequisites
54
+
55
+ - Python `>=3.14`
56
+
57
+ ## Installation
58
+
59
+ ```powershell
60
+ pip install codeecho
61
+ ```
62
+
63
+ ## Usage
64
+
65
+ ```powershell
66
+ python -m codeecho <path> [options]
67
+ ```
68
+
69
+ ### Clone detection levels
70
+
71
+ | Type | Detection strategy | Example |
72
+ |------|--------------------|---------|
73
+ | **Type-1** | Exact copy-paste — identical token sequences | Two functions with the same code copied verbatim |
74
+ | **Type-2** | Structural clone — same structure, renamed identifiers / literals | Same logic with different variable names |
75
+ | **Type-3** | Near-duplicate — high Jaccard similarity on token sets | Nearly identical functions with a few extra lines |
76
+
77
+ ### Supported languages
78
+
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` |
87
+
88
+ ### Arguments
89
+
90
+ | Argument | Description |
91
+ |----------|-------------|
92
+ | `path` | Root directory to scan. |
93
+
94
+ ### Options
95
+
96
+ | Option | Default | Description |
97
+ |--------|---------|-------------|
98
+ | `--types <types>` | `all` | Clone types to detect: comma-separated (`1`, `2`, `3`) or `all`. |
99
+ | `--threshold <float>` | `0.8` | Jaccard similarity threshold for Type-3 detection (`0.0`–`1.0`). |
100
+ | `--output <name>` | `codeecho-output` | Base name (without extension) for output file(s). |
101
+ | `--output-dir <dir>` | `<cwd>/reports` | Directory where output file(s) will be written. |
102
+ | `--db-dir <dir>` | `~/.codeecho` | Directory for the SQLite scratch database (`codeecho.db`). Session records are removed after the report is written. |
103
+ | `--format <fmt>` | `both` | Output format: `json`, `html`, or `both`. |
104
+ | `--min-tokens <n>` | `10` | Minimum token count for a code fragment to be included. |
105
+ | `--exclude <pattern>` | _(none)_ | Glob pattern(s) to exclude from scanning (repeatable). |
106
+ | `--version` | | Print the version and exit. |
107
+ | `-h, --help` | | Show help and exit. |
108
+
109
+ ### Examples
110
+
111
+ Scan the current directory and write both JSON and HTML reports:
112
+
113
+ ```powershell
114
+ python -m codeecho .
115
+ ```
116
+
117
+ Detect only Type-1 and Type-2 clones in a `src/` tree:
118
+
119
+ ```powershell
120
+ python -m codeecho src --types 1,2
121
+ ```
122
+
123
+ Scan with a custom output name and directory:
124
+
125
+ ```powershell
126
+ python -m codeecho . --output my-scan --output-dir audit/reports
127
+ ```
128
+
129
+ Lower the Type-3 threshold to catch more near-duplicates:
130
+
131
+ ```powershell
132
+ python -m codeecho . --threshold 0.6
133
+ ```
134
+
135
+ Exclude test and vendor directories:
136
+
137
+ ```powershell
138
+ python -m codeecho . --exclude "*/tests/*" --exclude "*/vendor/*"
139
+ ```
140
+
141
+ ## Configuration
142
+
143
+ | Environment variable | Description |
144
+ |----------------------|-------------|
145
+ | `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. |
146
+
147
+ ### `.ignore` file
148
+
149
+ 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.
150
+
151
+ ## Development
152
+
153
+ ### Prerequisites
154
+
155
+ - Poetry `2.2+`
156
+
157
+ ### Setup
158
+
159
+ ```powershell
160
+ poetry install
161
+ ```
162
+
163
+ ### Run
164
+
165
+ ```powershell
166
+ poetry run python -m codeecho <path> [options]
167
+ ```
168
+
169
+ ### Architecture
170
+
171
+ ```mermaid
172
+ flowchart TD
173
+ CLI["__main__.py\n(Click CLI)"] --> ScannerM["scanner.py\nFile discovery"]
174
+ ScannerM --> Parser["parser.py\nTree-sitter parsing"]
175
+ Parser --> Extractor["extractor.py\nFragment extraction\n(functions · classes · files)"]
176
+ Extractor --> Normalizer["normalizer.py\nRegex tokeniser\nType-2 normalisation"]
177
+ Normalizer --> Fingerprint["fingerprint.py\nSHA-256 hashing"]
178
+ Fingerprint --> DB["db.py\nSQLite session store"]
179
+ DB --> Detector["detector.py\nType-1 / 2 hash grouping\nType-3 Jaccard similarity"]
180
+ Detector --> DB
181
+ DB --> JSON["reporter/json_reporter.py\nJSON report"]
182
+ DB --> HTML["reporter/html_reporter.py\nHTML report"]
183
+ DB -->|delete session| Cleanup["Session cleanup"]
184
+ ```
185
+
186
+ ### Format and Lint
187
+
188
+ ```powershell
189
+ poetry run black codeecho
190
+ poetry run pylint codeecho
191
+ ```
192
+
193
+ ### Run Tests with Coverage
194
+
195
+ ```powershell
196
+ poetry run pytest --cov=codeecho tests --cov-report html
197
+ ```
198
+
199
+ ## [Changelog](CHANGELOG.md)
200
+
201
+ ## License
202
+
203
+ This project is licensed under the [MIT License](LICENSE).
204
+
205
+ ## Author
206
+
207
+ Ron Webb
208
+
@@ -0,0 +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
@@ -0,0 +1,41 @@
1
+ # .ignore — codeecho scan exclusions
2
+ #
3
+ # This file uses gitignore-style pattern matching. Patterns are matched
4
+ # relative to the scan root directory (the PATH argument passed to codeecho).
5
+ #
6
+ # Edit this file to exclude directories or files from clone detection.
7
+ # Uncomment or add entries below to activate them.
8
+ #
9
+ # --- Directory exclusion examples ---
10
+ #
11
+ # build/
12
+ # dist/
13
+ # target/
14
+ # out/
15
+ # generated/
16
+ #
17
+ # --- File extension exclusion examples ---
18
+ #
19
+ # *.min.js
20
+ # *.bundle.js
21
+ # *.generated.py
22
+ # *.pb.go
23
+ #
24
+ # --- Specific file exclusion (anchored to scan root) ---
25
+ #
26
+ # /config/generated_config.py
27
+ # /src/proto/generated.ts
28
+ #
29
+ # --- Name-based exclusion anywhere in the tree ---
30
+ #
31
+ # *_generated.java
32
+ # *Test.java
33
+ #
34
+ # --- Double-star (match across directory boundaries) ---
35
+ #
36
+ # **/fixtures/
37
+ # **/*.test.ts
38
+ #
39
+ # --- Negation (un-exclude even if a parent pattern matches) ---
40
+ #
41
+ # !important_dir/
@@ -0,0 +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)