diff --git a/.changeset/ci-audit-coverage.md b/.changeset/ci-audit-coverage.md index e258f2c..43877f6 100644 --- a/.changeset/ci-audit-coverage.md +++ b/.changeset/ci-audit-coverage.md @@ -1,5 +1,5 @@ --- -'@link-foundation/example-package-name': patch +'@link-foundation/code-evolution': patch --- Syntax-check every tracked JavaScript file and scan shipped examples with CodeQL. Record pinned npm and Deno install-script decisions, install native fixture dependencies in every runtime test leg, and remove the artifact, desktop and Pages dependency deprecations with tested compatibility adapters instead of warning suppressions. diff --git a/.changeset/ci-infrastructure-resilience.md b/.changeset/ci-infrastructure-resilience.md index eaa31eb..ee12955 100644 --- a/.changeset/ci-infrastructure-resilience.md +++ b/.changeset/ci-infrastructure-resilience.md @@ -1,5 +1,5 @@ --- -'@link-foundation/example-package-name': patch +'@link-foundation/code-evolution': patch --- Make CI survive GitHub infrastructure failures: diff --git a/.changeset/extract-code-evolution.md b/.changeset/extract-code-evolution.md new file mode 100644 index 0000000..7ee0c23 --- /dev/null +++ b/.changeset/extract-code-evolution.md @@ -0,0 +1,7 @@ +--- +'@link-foundation/code-evolution': minor +--- + +Extract the bounded Git evolution engine from Code Quality with its existing +JSON contract, a standalone CLI, typed library exports, reproducible consumer +checks, and a browser report explorer. diff --git a/.changeset/fix-repository-audits-and-test-coverage.md b/.changeset/fix-repository-audits-and-test-coverage.md index e75c907..3d6cfa2 100644 --- a/.changeset/fix-repository-audits-and-test-coverage.md +++ b/.changeset/fix-repository-audits-and-test-coverage.md @@ -1,5 +1,5 @@ --- -'@link-foundation/example-package-name': patch +'@link-foundation/code-evolution': patch --- Run repository-wide workflow audits on all relevant inputs, report unavailable tests with explicit reasons, and exercise fixture coverage under parallel Deno testing. Give npm propagation a 25.5-minute verification window, keep runtime-owned lockfiles quiet, validate lock/config/install-script policies, and avoid duplicate publish output. diff --git a/.changeset/javascript-first-rust-integration.md b/.changeset/javascript-first-rust-integration.md index 49b87c2..eb3b994 100644 --- a/.changeset/javascript-first-rust-integration.md +++ b/.changeset/javascript-first-rust-integration.md @@ -1,5 +1,5 @@ --- -'@link-foundation/example-package-name': major +'@link-foundation/code-evolution': major --- Require the reusable JavaScript-first gate's boolean `rust-template-applied` diff --git a/.changeset/quiet-safe-release-gates.md b/.changeset/quiet-safe-release-gates.md index a0e4227..ed1065b 100644 --- a/.changeset/quiet-safe-release-gates.md +++ b/.changeset/quiet-safe-release-gates.md @@ -1,5 +1,5 @@ --- -'@link-foundation/example-package-name': patch +'@link-foundation/code-evolution': patch --- Harden CI evidence scanning, syntax triggers, tool verification and cache writes. Reject oversized npm tarballs before publishing and stop retrying permanent E413 refusals. diff --git a/.changeset/release-and-ci-integrity.md b/.changeset/release-and-ci-integrity.md index 1bc9449..978b34a 100644 --- a/.changeset/release-and-ci-integrity.md +++ b/.changeset/release-and-ci-integrity.md @@ -1,5 +1,5 @@ --- -'@link-foundation/example-package-name': patch +'@link-foundation/code-evolution': patch --- Retry transient release push failures without changing validated code; attest release metadata and publication recovery, repair preview container tooling, update vulnerable transitive dependencies, and reject incomplete audit, link, and CodeQL evidence. diff --git a/.changeset/release-formatter-exact-moves.md b/.changeset/release-formatter-exact-moves.md index 63b3ac4..de01baa 100644 --- a/.changeset/release-formatter-exact-moves.md +++ b/.changeset/release-formatter-exact-moves.md @@ -1,5 +1,5 @@ --- -'@link-foundation/example-package-name': patch +'@link-foundation/code-evolution': patch --- Pin Changesets release formatting to Prettier and validate versioning on pull requests without publishing credentials. Reject unchanged moves of pending changesets while accepting new replacement fragments, and check both paths of code moves. diff --git a/.changeset/reliable-template-ci-helpers.md b/.changeset/reliable-template-ci-helpers.md index c9bfbcf..6db88fb 100644 --- a/.changeset/reliable-template-ci-helpers.md +++ b/.changeset/reliable-template-ci-helpers.md @@ -1,5 +1,5 @@ --- -'@link-foundation/example-package-name': patch +'@link-foundation/code-evolution': patch --- Fix secrets-scan ordering, optional workflow directories, reproducible release dependency loading, Windows Git hook installation and shell line endings, and transient Web Archive lookup handling. diff --git a/.changeset/reliable-template-pipelines.md b/.changeset/reliable-template-pipelines.md index d07da02..fdec4d3 100644 --- a/.changeset/reliable-template-pipelines.md +++ b/.changeset/reliable-template-pipelines.md @@ -1,5 +1,5 @@ --- -'@link-foundation/example-package-name': patch +'@link-foundation/code-evolution': patch --- Make release, preview, security and workflow checks report failures accurately; diff --git a/.changeset/repair-release-security-evidence.md b/.changeset/repair-release-security-evidence.md index 6663103..970bae7 100644 --- a/.changeset/repair-release-security-evidence.md +++ b/.changeset/repair-release-security-evidence.md @@ -1,5 +1,5 @@ --- -'@link-foundation/example-package-name': patch +'@link-foundation/code-evolution': patch --- Require complete release and security evidence, retry transient artifact transport failures, preserve lockfile dependency graphs during versioning, and keep archived examples outside maintained checks and release metadata. diff --git a/.changeset/repository-pipeline-repairs.md b/.changeset/repository-pipeline-repairs.md index 59a1a07..fd69556 100644 --- a/.changeset/repository-pipeline-repairs.md +++ b/.changeset/repository-pipeline-repairs.md @@ -1,5 +1,5 @@ --- -'@link-foundation/example-package-name': patch +'@link-foundation/code-evolution': patch --- Make version and changeset validation fail on unavailable Git comparisons, verify npm trusted publishing with a package-specific OIDC exchange, repair release badge detection and commit quoting, and recover missing GitHub releases without another version bump. Correct process survivor reporting, remove a busy-looping test fixture, pin CI scanners and hosted runner images, and exclude experimental and example code from CodeQL. diff --git a/.changeset/tidy-checks-hooks-links.md b/.changeset/tidy-checks-hooks-links.md index 8c53a24..9f31ea2 100644 --- a/.changeset/tidy-checks-hooks-links.md +++ b/.changeset/tidy-checks-hooks-links.md @@ -1,5 +1,5 @@ --- -'@link-foundation/example-package-name': patch +'@link-foundation/code-evolution': patch --- Cancel superseded read-only checks on main while preserving serialized writers, reject Husky installation errors with stale hook configuration, and retry checksum-verified lychee downloads without weakening broken-link checks. diff --git a/.changeset/transient-links-bun-pin.md b/.changeset/transient-links-bun-pin.md index abd6991..0979ce2 100644 --- a/.changeset/transient-links-bun-pin.md +++ b/.changeset/transient-links-bun-pin.md @@ -1,5 +1,5 @@ --- -'@link-foundation/example-package-name': patch +'@link-foundation/code-evolution': patch --- Retry transient HTTP link failures with bounded backoff and authenticated GitHub contents fallback, and pin the Bun CI runtime to the supported 1.x line. Refresh vulnerable development dependencies so pipeline security checks can pass. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2baad6e..6dc38b9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -286,6 +286,20 @@ jobs: - name: Check code duplication run: npm run check:duplication + - name: Check out the pinned Code Quality consumer + uses: actions/checkout@v7 + with: + repository: link-foundation/code-quality + ref: e0e2e03d8e78fee2119e6d272ebee4aef2505682 + path: .code-quality-contract + sparse-checkout: | + bin + src + persist-credentials: false + + - name: Verify packed evolution engine in Code Quality + run: node examples/code-quality-consumer/verify.mjs .code-quality-contract + # Test matrix: 3 runtimes (Node.js, Bun, Deno) x 3 OS (Ubuntu, macOS, Windows) # IMPORTANT: Tests must validate the ACTUAL merge result, not a stale merge preview. # See docs/case-studies/issue-23 for why this is critical. diff --git a/README.md b/README.md index 0a2c0c0..94f529e 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,17 @@ -# js-ai-driven-development-pipeline-template +# Code Evolution -A comprehensive template for AI-driven JavaScript/TypeScript development with full CI/CD pipeline support. +Analyze Git history at the file, function and class level. Code Evolution tracks identity changes, counts repeated structural edits and links findings to their commits and source paths. -This repository publishes the real test package -`@link-foundation/example-package-name` so the template release pipeline is -validated end to end with npm trusted publishing. +```bash +npm ci +node bin/code-evolution.js /path/to/repository --max-commits 25 --output report.json +``` + +The typed library entry point is `@link-foundation/code-evolution/evolution`. The report viewer includes a reproducible five-commit example and accepts local JSON reports. [Library, CLI and demo guide](docs/evolution.md), [demo screenshot](docs/screenshots/code-evolution.png), [extraction case study](docs/case-studies/issue-1/README.md) + +## Development infrastructure + +This project inherits the JavaScript AI-driven development template and its CI/CD tooling. The template's calculator examples remain available for pipeline verification. ## Features @@ -294,7 +301,7 @@ Add regex patterns to `.lycheeignore` to exclude URLs from checks (e.g., local d After creating a repository from this template, update the package name in: -1. `package.json`: replace `"@link-foundation/example-package-name"` with your package name +1. `package.json`: replace `"@link-foundation/code-evolution"` with your package name 2. `.changeset/config.json`: Package references Release scripts derive the package name from `package.json` at runtime, so no diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md new file mode 100644 index 0000000..5bc5d53 --- /dev/null +++ b/THIRD-PARTY-NOTICES.md @@ -0,0 +1,363 @@ +# Third-party notices + +Original Code Evolution and Code Quality source and tests are dedicated to the public domain under +the repository's Unlicense. The licenses below apply to the grammar artifacts and dependencies. + +`web-tree-sitter` 0.20.8 is MIT, copyright 2018–2021 Max Brunsfeld. Its complete +notice is supplied by the installed package at `web-tree-sitter/LICENSE`: + +The MIT License (MIT) + +Copyright (c) 2018-2021 Max Brunsfeld + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +`tree-sitter-wasms` 0.1.13, Gregor and Menci, declares Unlicense for its build +packaging. Its grammar builder is pinned at +`3e88dc9e36b4e8bf752ce53bea61e4b67282a2bb`. The grammar versions used by this +engine come from that revision's pnpm lock; their original notices follow. +These separately licensed grammars are not public domain. npm lockfiles pin the +prebuilt archive's integrity. Exact reproducible rebuilding of its binary outputs +has not been established by this project. + +`web-tree-sitter-bash-runtime` is an exact npm alias of MIT-licensed +`web-tree-sitter` 0.24.7, copyright 2018–2021 Max Brunsfeld. Its installed LICENSE +contains the complete MIT notice above. Only Bash uses this compatible runtime. + +The shipped `src/evolution/grammars/tree-sitter-bash.wasm` is the unchanged official +Tree-sitter Bash 0.23.3 release artifact at commit +`487734f87fd87118028a65a4599352fa99c9cde8`, SHA-256 +`d1844429a58620f306b6f42aebe92298243ca8120cd833a3ab5d87c7a2e7b9fd`. +Its complete MIT license is retained in `src/evolution/grammars/BASH-LICENSE`. +The earlier bundled Bash notice remains below because the grammar bundle is +still distributed as a dependency; that older Bash artifact is no longer loaded. + +## tree-sitter-bash 0.20.5 + +Registry license: MIT. + +The MIT License (MIT) + +Copyright (c) 2017 Max Brunsfeld + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +## tree-sitter-c 0.20.8 + +Registry license: MIT. + +The MIT License (MIT) + +Copyright (c) 2014 Max Brunsfeld + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +## tree-sitter-c-sharp 0.20.0 + +Registry license: MIT. + +The MIT License (MIT) + +Copyright (c) 2014 Max Brunsfeld + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +## tree-sitter-cpp 0.20.5 + +Registry license: MIT. + +The MIT License (MIT) + +Copyright (c) 2014 Max Brunsfeld + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +## tree-sitter-go 0.20.0 + +Registry license: MIT. + +The MIT License (MIT) + +Copyright (c) 2014 Max Brunsfeld + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +## tree-sitter-java 0.20.2 + +Registry license: MIT. + +MIT License + +Copyright (c) 2017 Ayman Nadeem + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +## tree-sitter-javascript 0.20.4 + +Registry license: MIT. + +The MIT License (MIT) + +Copyright (c) 2014 Max Brunsfeld + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +## tree-sitter-php 0.22.8 + +Registry license: MIT. + +The MIT License (MIT) + +Copyright (c) 2017 Josh Vera, GitHub +Copyright (c) 2019 Max Brunsfeld, Amaan Qureshi, Christian Frøystad, Caleb White + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +## tree-sitter-python 0.21.0 + +Registry license: MIT. + +The MIT License (MIT) + +Copyright (c) 2016 Max Brunsfeld + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +## tree-sitter-rust 0.20.4 + +Registry license: MIT. + +The MIT License (MIT) + +Copyright (c) 2017 Maxim Sokolov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +## tree-sitter-typescript 0.20.5 + +Registry license: MIT. + +The MIT License (MIT) + +Copyright (c) 2017 GitHub + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +## Development glob dependency + +`@ryotsu/picomatch` 4.0.7-a is an exact development-tooling override of picomatch. +Its pinned patched revision is recorded in the issue 1 case study. Its published license follows. + +The MIT License (MIT) + +Copyright (c) 2017-present, Jon Schlinkert. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/bin/code-evolution.js b/bin/code-evolution.js new file mode 100755 index 0000000..9ef424e --- /dev/null +++ b/bin/code-evolution.js @@ -0,0 +1,96 @@ +#!/usr/bin/env node + +import { readFileSync } from 'node:fs'; +import { writeFile } from 'node:fs/promises'; +import { URL } from 'node:url'; +import { makeConfig } from 'lino-arguments'; +import { extractEvolution } from '../src/evolution/index.js'; + +const usage = `Usage: code-evolution [repository] [options] + + --from Start at this first-parent commit, inclusive + --to End at this commit (default: HEAD) + --max-commits Limit the number of snapshots (default: 100) + --max-files Limit tracked source files per snapshot + --max-file-bytes Limit bytes per source file + --max-total-bytes Limit source bytes per snapshot + --output Write JSON to this path (default: stdout) + -c, --configuration Read options from a .lenv file + -h, --help Show usage + -v, --version Show the package version +`; + +async function main() { + const { + positionals: [root = '.', extra], + help, + version, + output, + from, + to, + maxCommits, + maxFiles, + maxFileBytes, + maxTotalBytes, + } = makeConfig({ + includePositionals: true, + lenv: { quiet: true }, + yargs: ({ yargs, getenv }) => + yargs + .exitProcess(false) + .help(false) + .version(false) + .parserConfiguration({ 'parse-positional-numbers': false }) + .strictOptions() + .option('help', { type: 'boolean', alias: 'h' }) + .option('version', { type: 'boolean', alias: 'v' }) + .option('from', { + type: 'string', + default: getenv('FROM') || undefined, + }) + .option('to', { type: 'string', default: getenv('TO') || undefined }) + .option('output', { type: 'string' }) + .option('max-commits', { type: 'number' }) + .option('max-files', { type: 'number' }) + .option('max-file-bytes', { type: 'number' }) + .option('max-total-bytes', { type: 'number' }) + .fail((message, error) => { + throw error || new Error(message); + }), + }); + if (extra !== undefined) { + throw new Error('Expected at most one repository path'); + } + if (help) { + process.stdout.write(usage); + return; + } + if (version) { + const metadata = new URL('../package.json', import.meta.url); + process.stdout.write( + `${JSON.parse(readFileSync(metadata, 'utf8')).version}\n` + ); + return; + } + const report = await extractEvolution(root, { + from, + to, + maxCommits, + maxFiles, + maxFileBytes, + maxTotalBytes, + }); + const json = `${JSON.stringify(report, null, 2)}\n`; + if (output) { + await writeFile(output, json); + } else { + process.stdout.write(json); + } +} + +try { + await main(); +} catch (error) { + console.error(`code-evolution: ${error.message}`); + process.exitCode = 2; +} diff --git a/deno.lock b/deno.lock index fb61ec0..1b95ae1 100644 --- a/deno.lock +++ b/deno.lock @@ -13,6 +13,9 @@ "npm:lint-staged@^16.4.0": "16.4.0", "npm:prettier@^3.6.2": "3.8.4", "npm:test-anywhere@~0.8.48": "0.8.50", + "npm:tree-sitter-wasms@0.1.13": "0.1.13", + "npm:web-tree-sitter@0.20.8": "0.20.8", + "npm:web-tree-sitter@0.24.7": "0.24.7", "npm:yaml@2.9.1": "2.9.1" }, "npm": { @@ -95,7 +98,7 @@ "@changesets/should-skip-package", "@changesets/types", "@manypkg/get-packages", - "picomatch" + "picomatch@npm:@ryotsu/picomatch@4.0.7-a" ] }, "@changesets/errors@1.0.0": { @@ -121,7 +124,7 @@ "@changesets/errors", "@changesets/types", "@manypkg/get-packages", - "picomatch", + "picomatch@npm:@ryotsu/picomatch@4.0.7-a", "tinyexec" ] }, @@ -368,6 +371,9 @@ "@resvg/resvg-js-win32-x64-msvc" ] }, + "@ryotsu/picomatch@4.0.7-a": { + "integrity": "sha512-JroBFEmaejC7szGSfqOhF1QZHLKvX2wTA1+fWyfkpy3BjzdQKNPLKa2FtgeKVUDy5/UPUNkXEeCHJ5ZRBMLTVA==" + }, "@sec-ant/readable-stream@0.4.1": { "integrity": "sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==" }, @@ -653,13 +659,13 @@ "fast-string-width" ] }, - "fdir@6.5.0_picomatch@4.0.7": { + "fdir@6.5.0_@ryotsu+picomatch@4.0.7-a": { "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", "dependencies": [ - "picomatch" + "picomatch@npm:@ryotsu/picomatch@4.0.7-a" ], "optionalPeers": [ - "picomatch" + "picomatch@npm:@ryotsu/picomatch@4.0.7-a" ] }, "figures@6.1.0": { @@ -888,7 +894,7 @@ "dependencies": [ "commander", "listr2", - "picomatch", + "picomatch@npm:@ryotsu/picomatch@4.0.7-a", "string-argv", "tinyexec", "yaml" @@ -1001,9 +1007,6 @@ "picocolors@1.1.1": { "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==" }, - "picomatch@4.0.7": { - "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==" - }, "prelude-ls@1.2.1": { "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==" }, @@ -1121,9 +1124,12 @@ "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", "dependencies": [ "fdir", - "picomatch" + "picomatch@npm:@ryotsu/picomatch@4.0.7-a" ] }, + "tree-sitter-wasms@0.1.13": { + "integrity": "sha512-wT+cR6DwaIz80/vho3AvSF0N4txuNx/5bcRKoXouOfClpxh/qqrF4URNLQXbbt8MaAxeksZcZd1j8gcGjc+QxQ==" + }, "type-check@0.4.0": { "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dependencies": [ @@ -1139,6 +1145,12 @@ "punycode" ] }, + "web-tree-sitter@0.20.8": { + "integrity": "sha512-weOVgZ3aAARgdnb220GqYuh7+rZU0Ka9k9yfKtGAzEYMa6GgiCzW9JjQRJyCJakvibQW+dfjJdihjInKuuCAUQ==" + }, + "web-tree-sitter@0.24.7": { + "integrity": "sha512-CdC/TqVFbXqR+C51v38hv6wOPatKEUGxa39scAeFSm98wIhZxAYonhRQPSMmfZ2w7JDI0zQDdzdmgtNk06/krQ==" + }, "which-command@0.1.0": { "integrity": "sha512-XZyoF5/5hZtXitIwzrU4NKK+Wtbb9aB9CezUEw2Q0wlYK8NUYQxC1rRXgNueYLtBAJwXIb+/tFVk4dozciNJMA==", "bin": true @@ -1204,11 +1216,15 @@ "npm:lint-staged@^16.4.0", "npm:prettier@^3.6.2", "npm:test-anywhere@~0.8.48", + "npm:tree-sitter-wasms@0.1.13", + "npm:web-tree-sitter@0.20.8", + "npm:web-tree-sitter@0.24.7", "npm:yaml@2.9.1" ], "overrides": { "minimatch@>=7 <11": "^11.0.4", - "glob@>=9 <=14.0.1": "^14.0.2" + "glob@>=9 <=14.0.1": "^14.0.2", + "picomatch": "npm:@ryotsu/picomatch@4.0.7-a" } } } diff --git a/docs/case-studies/issue-1/README.md b/docs/case-studies/issue-1/README.md new file mode 100644 index 0000000..5054f3e --- /dev/null +++ b/docs/case-studies/issue-1/README.md @@ -0,0 +1,58 @@ +# Issue 1 case study + +Code Quality built an inline analyzer to track source identities through Git history. This extraction makes that analyzer installable and gives reviewers a browser view of its evidence. It preserves the first-parent v1 report at the existing Code Quality library, CLI and HTTP boundaries. [Extraction issue](https://github.com/link-foundation/code-evolution/issues/1), [Code Quality issue](https://github.com/link-foundation/code-quality/issues/1), [original implementation](https://github.com/link-foundation/code-quality/pull/2) + +## Evidence collected + +The [data directory](data/) records GitHub issue and pull request metadata observed on November 18, 2026. It includes the extraction issue, its comment and sub-issue lists, the associated Code Quality issue and implementing PR, the open Meta Language PR inventory and the associative stack guide. The extraction issue had no comments or sub-issues, and the Code Evolution PR had no conversation comments, inline comments or submitted reviews when reviewed. The original Code Quality PR retains its inline engine, as requested by the extraction issue. + +The source snapshot is Code Quality commit `e0e2e03d8e78fee2119e6d272ebee4aef2505682`. The [source inventory](data/source-files.tsv) records original paths and SHA-256 digests. The migrated modules retain the Unlicense. The upstream Git fixtures are repository-authored, and external projects informed this study through public documentation and research. The existing Bash grammar retains its upstream license. [Pinned Code Quality tree](https://github.com/link-foundation/code-quality/tree/e0e2e03d8e78fee2119e6d272ebee4aef2505682), [third-party notices](../../../THIRD-PARTY-NOTICES.md) + +## How existing approaches address the requirements + +| Approach | What it measures or provides | Consequences for this extraction | +| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Git history and diffs | Git enumerates a commit's first parents, reads exact blob objects and can infer similar file renames from a file diff. | Git provides auditable changeset boundaries and exact contents. File similarity is a distinct heuristic from matching declarations and cannot supply stable function or class identities on its own. Using it for file renames would also change existing v1 results. [Git rev-list](https://git-scm.com/docs/git-rev-list), [Git diff](https://git-scm.com/docs/git-diff) | +| CodeScene hotspots | Public documentation combines change frequency, Code Health and other factors to prioritize where refactoring could have impact. | A hotspot backed only by v1 file events answers where activity occurred. Ranking file paths by count keeps the result reproducible from raw events and leaves priority decisions to the reviewer. [CodeScene hotspots](https://codescene.io/docs/guides/technical/hotspots.html) | +| CodeScene change coupling | Public documentation distinguishes commit co-change from ticket-based associations and discusses filtering and thresholds. | Commit pairs can be counted from the input repository alone, with an explicit omission for large commits. Ticket and time-window grouping would change the unit of observation. A frequently changing test or configuration file may couple for good reasons. [CodeScene change coupling](https://docs.enterprise.codescene.io/latest/guides/technical/change-coupling.html) | +| RefactoringMiner | Its public documentation describes a Java API for detecting named refactorings and displaying AST diffs, including code moved between files. | Typed refactoring detectors can provide richer explanations. They would add a separate runtime and their semantics would differ from the existing multi-language hash-and-evidence API. The extracted report uses original v1 normalization and records the source of each observed change. [RefactoringMiner documentation](https://github.com/tsantalis/RefactoringMiner) | +| Refactoring graphs | Brito, Hora and Valente studied 1,150 nontrivial refactoring graphs across 10 Java projects, including chains of changes spanning commits. | Multiple commits can express one larger refactoring. V1 groups equal transitions and points back to evidence, so its occurrence count answers a narrower question. The paper's counts describe a different population from the five-commit example. [Refactoring Graphs](https://arxiv.org/abs/2003.04666) | + +Keeping the analyzer in Code Quality would minimize package overhead but tie the CLI, demo and further reuse to that repository. A file-only engine based on Git would omit the abstraction-level acceptance criteria. A full parser and identity rewrite would need a new evidence corpus and contract. The chosen plan extracts the existing read-only Git traversal and syntax projection as a package, validates it with the original tests, and uses the packed candidate to exercise the consumer cutover. + +## Associative stack and Meta Language + +The stack baseline is Formal AI commit `015a683197c89e8f74375b097e8dd06a57dcea8f`. The executable uses `lino-arguments` for argv and Links Notation settings. The browser uses `link-foundation/ui` through `@link-foundation/ui-dom` for action controls declared in a `.lino` document and `lino-i18n` for its English catalog. Git remains the authoritative object store. The report is an on-demand JSON projection, and the browser keeps imported JSON in memory. This read-only feature requires no transaction, persistent link-store, reasoning or calculator boundary. [Pinned associative stack guide](https://github.com/link-assistant/formal-ai/blob/015a683197c89e8f74375b097e8dd06a57dcea8f/docs/associative-tech-stack.md), [Links UI](https://github.com/link-foundation/ui) + +The existing pipeline uses `command-stream`. Its exact-argv runner and streaming API were considered for Git. The extracted Git adapter retains the original combined stdout/stderr byte limit before decode, 30-second deadline, process-group cancellation and matching error behavior. The wider `command-stream` API would still need a custom adapter to enforce this policy. Public search and capture belong to the research process. The engine reads only local Git objects. [Command Stream API](https://github.com/link-foundation/command-stream) + +The open PR inventory covered dependency refresh #229, CST/source-preserving translation #228, and Rust layout #218. PR #228 at `3b77cb71a42c091c89d952f24acfe652ee95a1a1` is the relevant development snapshot. Its registry and syntax projection provide a CST boundary. The projection uses UTF-8 span coordinates and has its own grammar and source-preservation contracts. The existing engine needs JavaScript source offsets and stable declaration names and hashes across thirteen modes, including an original limited CMake adapter. Some CMake expansions must explicitly refuse analysis. A wholesale adoption would need fixture evidence of equivalence for these contracts. [Meta Language PR #228](https://github.com/link-foundation/meta-language/pull/228) + +The extracted analyzer copies the small Meta Language grammar-kind helper from that exact revision and uses it in structural metrics. The helper bridges Tree-sitter versions that expose symbol categories differently. The existing pinned parser runtimes and CMake projection supply the rest of the contract. The grammar fixtures check valid and invalid syntax in all thirteen modes, and the Code Quality verifier compares the complete report. [Helper at pinned revision](https://github.com/link-foundation/meta-language/blob/3b77cb71a42c091c89d952f24acfe652ee95a1a1/js/src/tree-sitter-node-kind.js), [original and adapted code inventory](data/source-files.tsv) + +## Requirement plan and verification + +| Requirement | Options and chosen implementation | Evidence | +| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Extract the engine and original Git-fixture tests | Preserve inline development in its original PR. Move the smallest dependency closure and its Git acceptance assertions into this library. | [Extraction fixtures](../../../tests/evolution.test.js), [CMake fixtures](../../../tests/cmake-evolution.test.js), [grammar fixtures](../../../tests/evolution-languages.test.js) | +| Expose bounded, read-only Git analysis and a JavaScript JSON API | Use Git object reads and first-parent snapshots. Select stable defaults and refuse out-of-window start refs, invalid revisions or excessive inputs. | [Library, CLI and limits](../../evolution.md), [typed report](../../../src/evolution/index.d.ts), fixture assertions for windowing, invalid ranges, HEAD and worktree state | +| Track file, function and class identities and four event types | Use path and qualified name, then exact content, then unique abstraction structure. Ambiguity retains separate lifetimes. Preserve content and normalized structural hashes. | [Identity rules](../../evolution.md#identity-and-report-interpretation), four-action and duplicate-declaration tests, grammar hash assertions | +| Count repeated transformations, hotspots and coupling | Reuse v1 structural transitions and path/commit counts. Inspect the initial snapshot effect and count each occurrence independently of commit count. | [Sample report](../../../examples/universal-app/evolution/sample-report.json), automated fixture assertions, observations below | +| Give evidence-linked improvement suggestions | Treat matching edits as observations and reference the specific commit, path and identity. Use those references in the demo. | Fixture asserts observational confidence and evidence references. In the browser, each sample evidence link focuses its own changed function. | +| Keep Code Quality API-compatible via a pin and verify CLI, library and server | Use the original consumer revision as a baseline. Install a candidate tarball by exact file reference with SHA-512 integrity, switch only the evolution import, and compare all three outputs and refusals. | [Consumer verification commands](../../../examples/code-quality-consumer/README.md) and the PR's consumer check | +| Preserve public-domain and clean-room provenance | Carry repository-authored implementation and fixtures from the pinned source. Compare external ideas using primary public documentation. | [Unlicense](../../../LICENSE), [third-party notices](../../../THIRD-PARTY-NOTICES.md), [source inventory](data/source-files.tsv) | +| Provide a useful website using Links UI | Use the existing Vite site to build a static report viewer with an original sample, timeline filter, local JSON import and evidence navigation. | [Browser sample regeneration test](../../../tests/evolution-languages.test.js), [browser render](../../screenshots/code-evolution.png) | +| Use the associative stack and check current Meta Language development | Use the stack at the configuration and presentation boundaries. Reuse the small CST helper with the existing source projection where contract differences remain. | [CLI](../../../bin/code-evolution.js), [Links UI actions](../../../examples/universal-app/evolution/actions.lino), [Meta Language inventory](data/meta-language-open-pulls.json) | +| Collect data and compare solutions in this PR | Preserve initial repository evidence and compare public approaches with concrete measurement and compatibility trade-offs. | [Snapshots and source inventory](data/), this analysis and reproducible fixture | + +## Observations from the generated history + +The fixture starts at `57583c74ae4ff44af9c298079fbaeece1bae59e6` and ends at `f5cbf88018970626328fd80ba03eced9047a996f`. Five snapshots give 27 events and five hotspot paths. The two busiest paths, `src/metrics.py` and `src/normalize.js`, have three file events each. Three file pairs each share two commits. All three pairs share the initial baseline, illustrating how the selected window affects a coupling count. The rename preserves the formatter file ID but the hotspot count is split between the old and new paths. + +The two JavaScript default-value transformations land in commit `3cbc8894b04fb1b5405b5e3113c1f276a95fb2b3` and produce a single repeated pattern. Its two evidence entries point to distinct function identities in the same path. The aggregate complexity delta is zero under the structural counter. This fixture demonstrates evidence frequency while leaving behavioral impact and maintainability to review. + +Run `node examples/evolution-report/generate.mjs` to regenerate the sample from a temporary Git repository. The automated fixtures compare the complete parsed report. The browser smoke test loads the sample, filters for classes, follows the evidence to a function, opens a local JSON file, rejects an invalid report, resets the sample and checks the layout at 390 pixels. See the [checked-in browser capture](../../screenshots/code-evolution.png). + +## Dependency audit + +The prepared branch's Security run failed in both npm audit jobs with the same high-severity Picomatch advisory. Both lockfiles now resolve the patched `@ryotsu/picomatch@4.0.7-a` fork already pinned by Code Quality. The npm archive identifies source commit `3ab5a7627d480259e3d9ca67fbc14c125d374f0e` and the lockfiles verify its integrity. That revision changes handling of complex repeated glob patterns, so the audit override is restricted to development and demo tooling. npm lockfile audits for both workspaces reported zero advisories after the change. [Prepared Security run](https://github.com/link-foundation/code-evolution/actions/runs/44250715969), [advisory](https://github.com/advisories/GHSA-fc5q-39xc-vjpf), [patched source commit](https://github.com/ryotsu-kankichi/secured-picomatch/commit/3ab5a7627d480259e3d9ca67fbc14c125d374f0e) diff --git a/docs/case-studies/issue-1/data/associative-tech-stack.md b/docs/case-studies/issue-1/data/associative-tech-stack.md new file mode 100644 index 0000000..8c600c2 --- /dev/null +++ b/docs/case-studies/issue-1/data/associative-tech-stack.md @@ -0,0 +1,286 @@ +# Associative technology stack + +Formal AI stores inspectable knowledge as a links network with Links Notation as its portable text representation. + +This guide names the upstream associative components, explains what each one +provides, and states exactly where Formal AI uses it. + +“Associative” here means that knowledge is represented as addressable links +between other links or values. It does not mean that every repository in the +same ecosystem is compiled into Formal AI. The sections below distinguish: + +- a **direct dependency** declared in `Cargo.toml` or `package.json`; +- a protocol, compatibility target, or in-repository implementation informed + by another project; and +- a development-time tool that operates Formal AI without becoming part of the + shipped runtime. + +## How data moves through the stack + +```mermaid +flowchart LR + Clients["CLI / HTTP / browser"] --> Config["lino-arguments"] + Config --> Syntax["Links Notation + object codec"] + Syntax --> Store["link-cli transactional store
or browser IndexedDB"] + Store --> Reason["Formal AI reasoning,
query and substitution"] + Syntax --> Meta["meta-language CST / AST"] + Reason --> Calc["link-calculator"] + Reason --> Output["Links Notation / API / localized web UI"] + Agent["Agent CLI / Hive Mind
(development-time)"] -.-> Clients +``` + +1. `lino-arguments` turns command-line, environment, and `.lenv` settings into + Formal AI configuration. +2. `links-notation` and `lino-objects-codec` parse human-readable `.lino` + documents and serialize portable memories, datasets, traces, and packages. +3. A native default build mirrors those records through the `link-cli` library, + whose transactional layer wraps a file-mapped `doublets-rs` store. Browser + builds keep the same reducible link shape in IndexedDB and advertise + `doublets-web` only when that runtime is present. +4. Formal AI's in-repository reasoning, query, and substitution engines operate + on the links. `meta-language` supplies CST and AST networks for program and + document structure, while `link-calculator` handles supported calculations. +5. Results return through the CLI or API, can be serialized back to Links + Notation, and are localized in the web UI through `lino-i18n`. + +## Direct runtime components + +These components are current direct dependencies. The manifest and source-path +references are the source of truth for how each is integrated. + +### `link-cli` + +Repository: [link-foundation/link-cli](https://github.com/link-foundation/link-cli) + +Formal AI's default `doublets-native` Cargo feature selects `link-cli` as its +native link-store library. `rust/src/link_store.rs` uses link-cli's file-mapped +`DoubletsStorage` and `GenericTransactionsDecorator` directly: server writes +are committed with an fsynced recovery log, explicit rollback restores both +the native graph and its in-memory projection, and an interrupted projection is +repaired from the atomic `.lino` source on reopen. This replaces Formal AI's +former local composition of `doublets` and `platform-mem`. + +### `doublets-rs` storage inside link-cli + +Repository: [linksplatform/doublets-rs](https://github.com/linksplatform/doublets-rs) + +`doublets-rs` supplies link-cli's physical doublet network: each link has a +source and target and can point to other links. It is now a transitive +implementation detail of the link-cli library rather than a separately wired +Formal AI dependency. `rust/src/link_store.rs` reduces memory events to stable +`Type → SubType → Value` graphs while Links Notation remains the reviewable +import/export projection. Its +[`platform-mem`](https://github.com/linksplatform/mem-rs) allocator is likewise +transitive storage infrastructure, not a separately integrated semantic or +reasoning layer. + +### `links-notation` + +Repository: [link-foundation/links-notation](https://github.com/link-foundation/links-notation) + +Links Notation is the portable, human-readable syntax for nested links +networks. Formal AI uses the parser crate when reading `.lino` input and keeps +the notation as the durable interchange format for seeds, memory, datasets, +packages, and reasoning traces. This is why stored knowledge remains +inspectable independently of the native or browser backend. + +### `lino-objects-codec` + +Repository: +[link-foundation/lino-objects-codec](https://github.com/link-foundation/lino-objects-codec) + +This codec parses and formats object-shaped data expressed in Links Notation. +Formal AI uses it at strict import boundaries and for canonical structured +serialization, including associative packages and memory/substitution data. +For example, `rust/src/link_store.rs` and `rust/src/associative_package.rs` use the +codec's indented-format parser before accepting input. + +### `meta-language` + +Repository: [link-foundation/meta-language](https://github.com/link-foundation/meta-language) + +`meta-language` represents source text and documents as a mutable links +network. In `rust/src/coding/cst.rs`, Formal AI uses its real grammars to parse +generated programs, inspect the concrete syntax tree (CST), project AST-like +structure, verify a full match, and confirm lossless text reconstruction. +`rust/src/document_formats.rs` uses the same network for supported markup and +document conversions. It is an optional Cargo feature but is enabled by +default. + +### `link-calculator` + +Repository: [link-assistant/calculator](https://github.com/link-assistant/calculator) + +This component evaluates calculator-shaped expressions and returns the value, +steps, and a Links Notation trace. `rust/src/calculation.rs` delegates supported +calculation input to `link-calculator` first, then uses Formal AI's local +fallback for syntax or word-problem normalization the component does not +support. + +### `lino-arguments` + +Repository: +[link-foundation/lino-arguments](https://github.com/link-foundation/lino-arguments) + +`lino-arguments` is the configuration boundary for the executable. `rust/src/main.rs` +initializes it before parsing commands, allowing Formal AI's CLI options to be +populated consistently from command-line arguments, environment variables, and +`.lenv` files. It configures the system; it does not perform reasoning. + +### `lino-i18n` + +Repository: [link-foundation/lino-i18n](https://github.com/link-foundation/lino-i18n) + +This JavaScript package parses Links Notation translation catalogs and resolves +localized messages. It is declared in `package.json`, bundled for browser use, +and loaded by `js/i18n.js`. Its boundary is web internationalization; it is +not part of the Rust solver. + +### `command-stream` + +Repository: [link-foundation/command-stream](https://github.com/link-foundation/command-stream) + +`rust/Cargo.toml` declares the native command execution dependency. In +`rust/src/orchestration/runner.rs`, `execute` passes an exact program/argument +vector, working directory and environment to `StreamingRunner::from_argv`. +`collect_command_stream` consumes stdout, stderr and exit events, with a bounded +execution timeout and process cancellation. This is the execution boundary for +external agent commands; it does not itself provide reasoning or link storage. +The manifest declaration is unconditional, while this orchestration is a native +host facility, not a browser subprocess API. + +### `web-capture` + +Repository: [link-assistant/web-capture](https://github.com/link-assistant/web-capture) + +`rust/Cargo.toml` selects `default-features = false` and the `search` feature under +`cfg(not(target_arch = "wasm32"))`. The native acquisition path in +`rust/src/web_search_core.rs` calls `web_capture::search::build_search_url` and +`parse_search_results`, recording blocked, empty and unavailable observations. +This supplies search acquisition/parsing rather than a knowledge-store backend; +failed acquisition is evidence of a failure, not an answer. + +The browser component in `js/web-search-component-entry.js` uses an HTTP capture +adapter: it first requests `/fetch?url=…` from the configured capture base +(default `http://localhost:3000`) with a deadline. A transport failure can fall +back to a direct CORS fetch. The adapter preserves the target status and bytes, +including target HTTP errors; a target error must not be misrepresented as a +successful discovery. This browser HTTP boundary is distinct from compiling the +native Cargo dependency into WASM. + +### `web-search` + +Repository: [link-assistant/web-search](https://github.com/link-assistant/web-search) + +There are two direct package integrations, with versions governed by their +respective manifests: + +- Native: `rust/Cargo.toml` declares `web-search` without default features and with + `merge`, under `cfg(not(target_arch = "wasm32"))`. + `rust/src/web_search_core.rs` converts provider rankings to `SearchResult`, + configures `MergeOptions` with the shared reciprocal-rank-fusion constant and + calls `web_search::merger::merge_results`. +- JavaScript: `package.json` declares `@link-assistant/web-search`. + `js/web-search-component-entry.js` imports and actually calls + `getDefaultProviderIds` and `mergeResults`. Its merge uses reciprocal rank + fusion and duplicate removal; its HTTP adapter supplies captured pages. + +Search discovers candidate evidence; capture obtains it; ranking merges the +candidates. Formal AI still owns the reasoning and verification needed to turn +those observations into supported statements. Neither package substitutes for +that reasoning, proves the content true, or provides a link-store dependency. + +## Architecture and protocol components + +These repositories explain protocol lineage, compatibility, or design context. +Unless a component is explicitly described as a direct dependency above, it is +not linked into the Formal AI runtime. + +### Browser storage: `doublets-web` + +Repository: [linksplatform/doublets-web](https://github.com/linksplatform/doublets-web) + +`doublets-web` is the browser-side Links Platform store and a compatibility +target, not a bundled JavaScript dependency. `js/memory.js` uses an +IndexedDB implementation with the same event-to-doublets projection and reports +the `doublets-web` backend when a compatible global runtime is available. This +keeps browser data portable without claiming that the upstream package is +always loaded. + +### Query dialect supplied by `link-cli` + +Repository: [link-foundation/link-cli](https://github.com/link-foundation/link-cli) + +Besides the native storage APIs used directly above, `link-cli` defines the +link query and substitution command conventions. Formal AI adapts those +conventions in `rust/src/links_query.rs` and `rust/src/links_substitution_query/`; it +links the Rust library in-process and does not launch an external CLI binary. + +### Reasoning model: `relative-meta-logic` + +Repository: +[link-foundation/relative-meta-logic](https://github.com/link-foundation/relative-meta-logic) + +Relative Meta Logic models claims relative to contexts instead of forcing one +global truth value. Formal AI has an in-repository implementation in +`rust/src/relative_meta_logic.rs`, integrated with `rust/src/world_model.rs` for +context-relative facts, contradictions, and queries. The upstream repository +is the architectural reference, not a linked crate. + +### Conceptual model: `meta-theory` + +Repository: [link-foundation/meta-theory](https://github.com/link-foundation/meta-theory) + +Meta Theory is a conceptual foundation for describing languages and theories as +data. It informs Formal AI's data-first approach to rules, syntax, and +reasoning, but there is no `meta-theory` runtime dependency in the manifests. + +### Transformation model: `transformer` + +Repository: [link-foundation/transformer](https://github.com/link-foundation/transformer) + +Transformer is a related model for graph transformations. Formal AI's current +substitution engine is an in-repository implementation in +`rust/src/substitution.rs`, where `.lino` rules match and rewrite link patterns on +CRUD events. The repository is useful for comparison and vocabulary, but its +code is not linked into the Formal AI runtime. + +## Development and orchestration components + +These tools exercise or coordinate the system during development. They are not +end-user runtime libraries. + +### Agent CLI + +Repository: [link-assistant/agent](https://github.com/link-assistant/agent) + +The Agent CLI is an external development-time client for OpenAI-compatible +model endpoints. Contributors use it against a running Formal AI server to +prove that the symbolic agent loop can inspect a worktree, call tools, edit +files, and verify its result through the same public protocol used by other +clients. + +### Hive Mind + +Repository: [link-assistant/hive-mind](https://github.com/link-assistant/hive-mind) + +Hive Mind is development-time orchestration around issue-solving agents and +pull requests. It supplies tasks and coordinates repository work; Formal AI is +the system being driven. Hive Mind does not participate in knowledge storage, +parsing, reasoning, or responses in a shipped Formal AI process. + +## Keeping this map accurate + +When an integration changes, update this guide from executable evidence: + +- `Cargo.toml` and its feature table define Rust runtime dependencies; +- `package.json` defines the web bundle's direct packages; +- `rust/src/link_store.rs`, `rust/src/coding/cst.rs`, `rust/src/document_formats.rs`, + `rust/src/calculation.rs`, `rust/src/main.rs`, and `js/i18n.js` show the integration + boundaries; and +- compatibility or conceptual repositories must remain in the architecture + section until their code becomes an actual manifest dependency. + +The project catalog in `data/seed/projects.lino` records a wider ecosystem for +discovery. Catalog membership alone is not evidence that a component executes +inside Formal AI. diff --git a/docs/case-studies/issue-1/data/code-quality-issue.json b/docs/case-studies/issue-1/data/code-quality-issue.json new file mode 100644 index 0000000..5d20e86 --- /dev/null +++ b/docs/case-studies/issue-1/data/code-quality-issue.json @@ -0,0 +1 @@ +{"body":"It should support all programming languages we have in https://github.com/link-assistant/hive-mind/blob/main/docs/CI-CD-BEST-PRACTICES.md\n\nSo we later will be able to integrate it to all of these languages.\n\nAlso we need to collect list of all competitors and beat them all in their features, by making sure we have all similar tests (or even better), and if there are closed source tools we should make sure we handle all the cases they document.\n\nSo we use clean room development, to make public domain implementation of code quality tool that should be available as CLI, API (server + docker), and library, which is extensible and so on.\n\nWe also should include our own code evolution extraction tool, which takes repository code, tracks each function/class/file and other abstractions evolution, so we can discover repeated (most frequent patterns from any codebase), and use that as guideline for making suggestions on how to improve common code patterns.\n\nWe start by implementing it inline in this repository with creating issue at https://github.com/link-foundation/code-evolution, so the code evolution logic will be moved to https://github.com/link-foundation/code-evolution repository.\n\nWe must document our vision detailed comparison of all features of all competitors and do as much as we can in a single pull request, so we produce the best possible tool, that will beat all the competitors.\n\nWe should also beat github.com/ever-guild/quality-bash fully.\n\nWe need to collect data related about the issue to this repository, make sure we compile that data to `./docs/case-studies/issue-{id}` folder, and use it to do deep case study analysis (also make sure to search online for additional facts and data), list of each and all requirements from the issue, and propose possible solutions and solution plans for each requirement (we should also check known existing components/libraries, that solve similar problem or can help in solutions).\n\nPlease plan and execute everything in this single pull request, you have unlimited time and context, as context auto-compacts and you can continue indefinitely, until each and every requirement fully addressed, and everything is totally done.\n\n","comments":[],"state":"OPEN","title":"We need to make best code quality tool on the planet","url":"https://github.com/link-foundation/code-quality/issues/1"} diff --git a/docs/case-studies/issue-1/data/code-quality-pull-request.json b/docs/case-studies/issue-1/data/code-quality-pull-request.json new file mode 100644 index 0000000..767e754 --- /dev/null +++ b/docs/case-studies/issue-1/data/code-quality-pull-request.json @@ -0,0 +1 @@ +{"body":"Issue #1 starts from a pipeline template with arithmetic examples. This change adds a public-domain JavaScript quality engine and inline Git evolution analysis through a CLI, the typed `/quality` library entry point, and a bounded HTTP API with a non-root Docker image.\n\n**Implementation remains in progress. Exhaustive competitor/documented-case parity and full quality-bash parity are unfinished acceptance criteria. The strict readiness command rejects them; current functionality and passing tests do not establish universal superiority. Keep this PR unmerged.**\n\n- Parse and extract abstractions for every language named in the pinned Hive Mind guidance, plus Bash and TSX. Apply original structural, duplication, whitespace and heuristic security rules. Measure literal CMake formal arity and structural decisions with an original adapter. Refuse unresolved headers and unsupported custom tree rules; record remaining evaluation limitations.\n- Add deterministic JSON/text/SARIF, versioned plugins, declarative AST rules, explicit trusted analyzer adapters, and monotonic finding/coverage/mutation baselines. Locked atomic writes and `--baseline-ref` enforce working and committed target-revision floors. Fresh report bundles preserve failed/incomplete evidence and raw coverage outputs.\n- Track files/functions/classes and other grammar abstractions through bounded, read-only Git history. Preserve identities with unique evidence, rank repeated edits, and attach source evidence to observational suggestions.\n- Add shell syntax/ShellCheck/Bats/kcov/mutation orchestration, independent stages, repeatable file selection, bounded workers, audited baseline migrations and source-preserving upstream-schema import through fresh independent QA. Reject missing Bash prerequisites, tool changes during measurement, duplicate JSON fields and malformed Bats TAP.\n- Download checksum-pinned Bats 1.14, ShellCheck 0.11 and Debian kcov 43 for Linux x64/arm64 into exclusively owned output. Download a separately pinned private Debian library closure without sudo or maintainer scripts; retain notices, check loader resolution and fingerprint the entire managed tree before and after measurement. Host Bash >=5.2, glibc >=2.36, Python and system configuration remain explicit dependencies/limits.\n- Add a consumer GitHub Action with literal arguments, automatic PR-base baseline enforcement, fresh installation-failure evidence and owned temporary cleanup.\n- Provide command-specific usage/options without project configuration or external tools. Correct Windows drive-prefix and macOS canonical-root validation while preserving all refusal assertions.\n- Add original arithmetic mutations and exact count arithmetic with default floor or explicit fingerprinted half-up rounding. Require reviewed migration for earlier shell methods. Record actual released-CLI QA, cache-freshness refusals and floor-preserving baseline import on two original fixtures with identical external tools.\n- Verify every bounded workspace input, including helper data, unselected helpers and permissions, across shell stages. Refuse additions/deletions/changes, share copy exclusions and record tree evidence with a versioned method. A real passing Bats control reproduces the helper change and corrected refusal.\n- Add optional token-block clones with explicit identifier/literal normalization, minimum lengths, maximal nonoverlapping pairs, exact ranges and SARIF related locations in all thirteen language modes. Native CMake command/parenthesis/argument tokens preserve raw kinds, dynamic references and generator markers. Include normalized-token signatures in baseline identities; refuse incomplete metrics and exhausted work budgets. Version the CMake token policy and require reviewed baseline migration. A finite independent oracle checks 300 token-index cases.\n- Add opt-in `CPD-OFF`/`CPD-ON` comment regions across all thirteen modes, strict malformed-marker refusals, segment boundaries and audited UTF-16 ranges. Syntax validation and structural rules remain active; suppressed tokens still consume work budgets. Explicit false retains default behavior and methods.\n- Collect verified token-pair locations into deterministic `cloneGroups` in JSON, text and SARIF without changing pair findings, gates, signatures or method fingerprints. Deduplicate locations by language, token count and normalized signature; preserve overlapping groups and separate signatures.\n- Add opt-in Java/C# annotation and C# using-directive clone filters while preserving syntax checks, other rules, comment markers and shared token budgets. Keep annotation declarations, using statements/declarations and other languages visible. Correct six Java numeric literal families; version enabled filters/normalization and require reviewed baseline migrations.\n- Add optional native structural tree rules with exact grammar node/text/field/operator constraints, ordered named children, captures, repeated structural equality and one anchored sequence wildcard. Ignore comments/formatting for capture equality while preserving operators, literal spelling and tree shape. Validate pattern size and share finite candidate/capture work; applicable CMake rules still refuse incomplete analysis.\n- Compose native rules with candidate-local `all`/`any`/`not` filters. Each clause inherits an isolated copy of parent captures and discards temporary bindings; Boolean truth values do not depend on sibling order. Bound clause visits and copied entries. Preserve legacy/no-filter methods and findings, version enabled rules/filters, and require reviewed baseline migrations. This is an independently designed object API; Semgrep syntax/range/binding semantics and complete rule parity remain missing.\n- Correct valid Bash literal/pattern/case/heredoc parsing using the pinned official Bash 0.23.3 WASM release and compatible isolated runtime. Verify artifact integrity before parsing, retain its MIT license, handle both runtime node APIs and anonymous comparison fields, preserve non-Bash method identities, and require reviewed Bash baseline migration. Record a finite released/native operator audit without claiming full parity.\n- Restrict shell mutations to actual operator fields and command-list operators, preserving quoted logical text and comparison operands. Add opt-in expanded arithmetic ordering and a second multiplication fault model through the library, CLI and Action; fingerprint policies and refuse partial inventories. Correct npm alias normalization in the strict Deno dependency guard while retaining all inventory and resolution assertions.\n- Add opt-in native JS/TS/TSX straight-line taint models with exact sources/sanitizer returns, conservative simple parameter sources, assignments, eager expressions and selected sink arguments. Preserve ordered source-to-sink paths in JSON/text/SARIF and baseline identities. Reject shadowed/escaped bindings, unsupported control flow and exhausted budgets as incomplete; preserve default behavior and methods. Local calls, closures, heap, framework and full compiler/interfile semantics remain unfinished.\n- Preserve the existing browser-compatible arithmetic entry point, example CLI and pipeline features. Add one minor Changeset, preserve earlier release notes/bump types, and retain third-party notices.\n- Collect source snapshots, clean-room provenance, competitor comparisons, requirement mapping, alternatives and explicit gaps under [the case study](https://github.com/link-foundation/code-quality/tree/issue-1-f401f7eb3981/docs/case-studies/issue-1).\n\nThe requested later extraction is tracked at https://github.com/link-foundation/code-evolution/issues/1; the implementation remains inline here. Competitor implementation and test-suite files were not opened or copied. Public report-format documentation contains illustrative source excerpts; none were copied or used as fixtures. The research ledger records this distinction.\n\nReproduce the new behavior:\n\n```sh\nnpm ci\nnode bin/code-quality.js check ./src --format json\nnode bin/code-quality.js evolution . --max-commits 10\nnode bin/code-quality.js serve .\nnode bin/code-quality.js check examples/code-quality/taint --config examples/code-quality/taint/quality.json --format sarif\n```\n\nThe taint example exits 1 with one unsanitized flow; the sanitized file stays clean. Its inputs are analyzed without execution. The original escaped-binding regression fails before the draft correction and passes afterward; unsupported cases refuse complete baselines.\n\nValidation at `58e3221e54d7fdf53be2252398e83f0ffed39dff`:\n\n- All 319 selected Node checks and 312 Bun/frozen-Deno cases pass without skips, including existing dependency and JavaScript-first guards. Twenty new flow/consumer tests cover exact calls, overwrite/copy behavior, nested sinks, selected arguments, multiple origins, Unicode locations, type assertions, independent scopes, early returns, malformed models, bounded work and CLI/HTTP/text/SARIF. Existing acceptance assertions remain intact.\n- `npm run check` passes without lint/format warnings (6.30% duplicated lines). Types, Changeset validation, all 449 tracked-file line guards, installed-tarball smoke and isolated release versioning pass. Release fragments produce `0.11.31` to `1.0.0`, preserving the prior major fragment. All twenty research snapshot hashes match. Seven source-hashed flow observations reproduce within a 128 MiB Node heap and bounded stack.\n- All six preceding `8dc4a7d` workflows pass on attempt one, including all nine runtime legs, both native shell architectures, distribution/container and desktop packaging. [Checks and release](https://github.com/link-foundation/code-quality/actions/runs/44205208691) confirms the dependency-guard correction. New same-revision CI is pending; full real-shell and container checks remain covered there.\n- The preceding actual shell observations retain 75% coverage and the original 100%/66.66% mutation fixtures, 3/5 arithmetic coverage and 2/3 detection, default 66.66 or explicit half-up 66.67, baseline import, migration, consumer Action, failed evidence and helper-change refusal. The expanded example records standard 0/1 versus expanded 5/6 mutants killed (83.33%); different denominators do not establish an accuracy ranking.\n- Every incremental change was reviewed, including the whole final candidate diff, which matches the reviewed draft byte-for-byte. GitHub's combined PR diff exceeds its 20,000-line service limit; paginated PR file blobs are checked against reviewed local Git. All 217 preceding file blob identities match. The shipped Bash grammar is pinned to the observed official HTTPS release binary; no independent build reproducibility claim is made.\n- Reviewed dependency pins, bounded security regressions, frozen graphs and audit thresholds remain intact. `npm run quality:readiness` deliberately returns seven explicit refusals for unfinished compiler/project semantics, partial CMake/taint adapters, exhaustive competitor/proprietary cases and full quality-bash parity. No production Rust jobs are introduced.\n\nFixes #1\n","headRefOid":"e0e2e03d8e78fee2119e6d272ebee4aef2505682","isDraft":false,"state":"OPEN","title":"feat: add native quality analysis and inline code evolution","url":"https://github.com/link-foundation/code-quality/pull/2"} diff --git a/docs/case-studies/issue-1/data/issue-comments.json b/docs/case-studies/issue-1/data/issue-comments.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/docs/case-studies/issue-1/data/issue-comments.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/docs/case-studies/issue-1/data/issue.json b/docs/case-studies/issue-1/data/issue.json new file mode 100644 index 0000000..3285944 --- /dev/null +++ b/docs/case-studies/issue-1/data/issue.json @@ -0,0 +1 @@ +{"url":"https://api.github.com/repos/link-foundation/code-evolution/issues/1","repository_url":"https://api.github.com/repos/link-foundation/code-evolution","labels_url":"https://api.github.com/repos/link-foundation/code-evolution/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/link-foundation/code-evolution/issues/1/comments","events_url":"https://api.github.com/repos/link-foundation/code-evolution/issues/1/events","html_url":"https://github.com/link-foundation/code-evolution/issues/1","id":6448279986,"node_id":"I_kwDOVxxzOc8AAAABgFjxsg","number":1,"title":"Extract the inline Git evolution engine from code-quality","user":{"login":"konard","id":1431904,"node_id":"MDQ6VXNlcjE0MzE5MDQ=","avatar_url":"https://avatars.githubusercontent.com/u/1431904?v=4","gravatar_id":"","url":"https://api.github.com/users/konard","html_url":"https://github.com/konard","followers_url":"https://api.github.com/users/konard/followers","following_url":"https://api.github.com/users/konard/following{/other_user}","gists_url":"https://api.github.com/users/konard/gists{/gist_id}","starred_url":"https://api.github.com/users/konard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/konard/subscriptions","organizations_url":"https://api.github.com/users/konard/orgs","repos_url":"https://api.github.com/users/konard/repos","events_url":"https://api.github.com/users/konard/events{/privacy}","received_events_url":"https://api.github.com/users/konard/received_events","type":"User","user_view_type":"public","site_admin":false},"labels":[{"id":13117286257,"node_id":"LA_kwDOVxxzOc8AAAADDdnncQ","url":"https://api.github.com/repos/link-foundation/code-evolution/labels/documentation","name":"documentation","color":"0075ca","default":true,"description":"Improvements or additions to documentation","archived_at":null,"archived_by":null},{"id":13117286306,"node_id":"LA_kwDOVxxzOc8AAAADDdnnog","url":"https://api.github.com/repos/link-foundation/code-evolution/labels/enhancement","name":"enhancement","color":"a2eeef","default":true,"description":"New feature or request","archived_at":null,"archived_by":null}],"state":"open","locked":false,"assignees":[],"milestone":null,"comments":0,"created_at":"2026-11-17T15:43:06Z","updated_at":"2026-11-18T06:19:42Z","closed_at":null,"assignee":null,"author_association":"MEMBER","issue_field_values":[],"type":{"id":22969357,"node_id":"IT_kwDOCoAzvc4BXnwN","name":"Feature","description":"A request, idea, or new functionality","color":"blue","created_at":"2024-07-20T19:06:39Z","updated_at":"2024-10-08T23:47:30Z","is_enabled":true},"active_lock_reason":null,"sub_issues_summary":{"total":0,"completed":0,"percent_completed":0},"issue_dependencies_summary":{"blocked_by":0,"total_blocked_by":0,"blocking":0,"total_blocking":0},"body":"The code-quality engine is being developed inline in https://github.com/link-foundation/code-quality/pull/2 for https://github.com/link-foundation/code-quality/issues/1.\n\nTrack its later extraction into this repository. The inline module will expose a JavaScript library API and JSON report for bounded Git history analysis: file/function/class identities, additions/modifications/deletions/renames, content and normalized structural hashes, repeated transformation frequencies, hotspots and change coupling, plus evidence-linked improvement suggestions. Use original clean-room tests and public documentation only; preserve the public-domain license and avoid copying competitor implementations or tests.\n\nExtraction acceptance: migrate the implementation and its reproducible Git-fixture tests, retain API compatibility in code-quality via a pinned dependency, document ambiguous identity matching and history limits, and verify CLI/library/server consumers. This issue requests the future repository move; implementation remains inline in the current PR as requested.\n\nWe also should have a good demo website using https://github.com/link-foundation/ui\n\nWe also must use by default https://github.com/link-assistant/formal-ai/blob/main/docs/associative-tech-stack.md in all places where applicable.\n\nhttps://github.com/link-foundation/meta-language use can be directly beneficial, yet if it is not fully ready yet for required programming languages, we should make a copy of the code and do just enough changes, so it will work for our use case (check latest open pull requests of meta language, to use latest development).\n\nWe need to collect data related about the issue to this repository, make sure we compile that data to `./docs/case-studies/issue-{id}` folder, and use it to do deep case study analysis (also make sure to search online for additional facts and data), list of each and all requirements from the issue, and propose possible solutions and solution plans for each requirement (we should also check known existing components/libraries, that solve similar problem or can help in solutions).\n\nPlease plan and execute everything in this single pull request, you have unlimited time and context, as context auto-compacts and you can continue indefinitely, until each and every requirement fully addressed, and everything is totally done.","closed_by":null,"reactions":{"url":"https://api.github.com/repos/link-foundation/code-evolution/issues/1/reactions","total_count":0,"+1":0,"-1":0,"laugh":0,"hooray":0,"confused":0,"heart":0,"rocket":0,"eyes":0},"timeline_url":"https://api.github.com/repos/link-foundation/code-evolution/issues/1/timeline","performed_via_github_app":{"id":1144995,"client_id":"Iv23liVemv8A9if9v0F2","slug":"chatgpt-codex-connector","node_id":"A_kwHOAOQ6Gs4AEXij","owner":{"login":"openai","id":14957082,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0OTU3MDgy","avatar_url":"https://avatars.githubusercontent.com/u/14957082?v=4","gravatar_id":"","url":"https://api.github.com/users/openai","html_url":"https://github.com/openai","followers_url":"https://api.github.com/users/openai/followers","following_url":"https://api.github.com/users/openai/following{/other_user}","gists_url":"https://api.github.com/users/openai/gists{/gist_id}","starred_url":"https://api.github.com/users/openai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openai/subscriptions","organizations_url":"https://api.github.com/users/openai/orgs","repos_url":"https://api.github.com/users/openai/repos","events_url":"https://api.github.com/users/openai/events{/privacy}","received_events_url":"https://api.github.com/users/openai/received_events","type":"Organization","user_view_type":"public","site_admin":false},"name":"ChatGPT Codex Connector","description":"Bring ChatGPT and Codex to your GitHub repositories.","external_url":"https://www.chatgpt.com","html_url":"https://github.com/apps/chatgpt-codex-connector","created_at":"2025-02-14T01:37:05Z","updated_at":"2026-09-23T18:52:59Z","permissions":{"actions":"write","checks":"read","contents":"write","emails":"read","issues":"write","metadata":"read","pull_requests":"write","statuses":"read","workflows":"write"},"events":["check_run","check_suite","commit_comment","issues","issue_comment","pull_request","pull_request_review","pull_request_review_comment","pull_request_review_thread","repository","status","sub_issues"]},"state_reason":null,"pinned_comment":null} \ No newline at end of file diff --git a/docs/case-studies/issue-1/data/meta-language-open-pulls.json b/docs/case-studies/issue-1/data/meta-language-open-pulls.json new file mode 100644 index 0000000..c671760 --- /dev/null +++ b/docs/case-studies/issue-1/data/meta-language-open-pulls.json @@ -0,0 +1 @@ +[{"headRefOid":"dc0a17bd1f9d0accbb0a5d91ebb83e04ebb3d855","number":229,"title":"chore(deps): scheduled dependency refresh","url":"https://github.com/link-foundation/meta-language/pull/229"},{"headRefOid":"3b77cb71a42c091c89d952f24acfe652ee95a1a1","number":228,"title":"Expand source-preserving JavaScript/Rust translation and repair CI histories","url":"https://github.com/link-foundation/meta-language/pull/228"},{"headRefOid":"896905cec33db402d9fe3f1a315340e714ea9c51","number":218,"title":"Lay out emitted Rust that does not fit 100 columns (#217)","url":"https://github.com/link-foundation/meta-language/pull/218"}] diff --git a/docs/case-studies/issue-1/data/meta-language-pull-228.json b/docs/case-studies/issue-1/data/meta-language-pull-228.json new file mode 100644 index 0000000..a8de1fa --- /dev/null +++ b/docs/case-studies/issue-1/data/meta-language-pull-228.json @@ -0,0 +1 @@ +{"body":"Own-codebase translation needs checked module owners, shared array identity and complete source restoration. This PR translates JavaScript functions beside literal containers, empty Map/Set allocations and pure Number arithmetic constants, and adds standard Rust shared-array profiles including `std::rc::Rc::clone(&value)`. Whole Rust libraries retain visibility and exact original bytes for reverse translation.\n\nA complete parser-owned CST proves each numeric constant's actual lexical name and pure initializer. Once that initializer independently checks and emits, its actual scalar static signature can bind sibling functions and recursive components. Existing arithmetic and lazy-static emitters retain rounding, NaN and signed zero. Calls, coercion, BigInt, unknown/eager owners and unsupported operators keep explicit obligations. TypeScript ownership scanning now uses the same real erasure path already used by the native binder.\n\nShared JavaScript decisions generate native rules and checked Links programs automatically. Both source-free codecs preserve aliases, distinct allocations, signed zero and Unicode. The original nine scalar, three associated-clone, ten refusal and six empty-allocation fixtures remain. Six numeric scope cases and six executable arithmetic predicates cover actual source restoration, ownership and Number behavior; one shared TypeScript case covers erasure and full-result parity. Native tests compare complete results/signatures and execute original JavaScript/emitted Rust only in CI.\n\nCompiler repairs expose the existing constructor, fix private imports and independent Node observations, and retain the byte-wise sha2 0.11 formatter. Forty-four prior Clippy diagnostics have generator/decorator corrections for eight families. Complete original diagnostics and certified native sources remain Links fixtures. Current Rust tokens are source-owned after caller-entry validation, retaining all forgery refusals.\n\nThe last completed run, [39960718444](https://github.com/link-foundation/meta-language/actions/runs/39960718444), finished all 97 jobs: 74 successful, three failed, two cancelled and 18 skipped. All sixteen reports and the three previously failing crate-history shards passed. The remaining independent causes were a raw-source timeout, a tooling timeout after all 173 tests passed, and an obsolete refusal for the unchanged `const LIMIT = 1 + 2` fixture. The aggregates reflect those prerequisites; native stages were skipped.\n\nThe repair starts all available complete archive workers on stored source candidates alongside fresh compiler preparation. Every candidate must equal the entire fresh generated source. All original compiler/profile/codec checks, three full CST text/binary replays and successful worker exits still precede publication or matrix allocation. Naming preflight checks every selected whole source before expensive extraction; every original per-view assertion and extractor remains. Job counts, gates, heap bounds and deadlines remain unchanged.\n\nThe arithmetic fixture retains its exact original input and round trip, expects the implemented Number-static translation, and adds independent JavaScript/generated-Rust execution of the result three. Version-sensitive checks bound active Node and Rust versions explicitly. Two incomplete operation-definition fields now recover their complete SAME original declarations from independently Git-certified modules and original registration/codec receipts. An exact inverse preserves old fragments, identities and contexts; unknown edits refuse.\n\nSixteen physical reports preserve all eight logical source unions and original deadlines. Package checks run alongside JavaScript tests; native jobs still depend on every JavaScript prerequisite. The catalogs contain 16,754 concepts and 8,046 source bindings, with 67 appended operations and all codec epochs through sixteen preserved. Naming retains 374 certified source epochs, 263 views and 2,113 names in five bounded Links documents. Source preservation does not establish semantic equivalence.\n\nDraft validation before the latest commit: all 33 targeted declaration, archive scheduling, capacity, preflight and driver groups pass, plus the two changed binding controls. All twelve history authors, paired catalogs, snapshots, complete naming author/reader/serializer and eighteen ordered read-only verification commands pass. Source reconciliation preserves 60 requirement sources, 14 status reports, 831 dependency entries and all 469 requirements/490 fixture identities. The broader local binding invocation exhausted its fixed heap and one naming author timed out under observed CPU contention; both failed logs remain, targeted binding controls and an identical bounded naming retry pass. No Rust compilation, full raw workload, full naming policy or complete acceptance ran locally.\n\nCommit `1d25066a857b16e58ed954b0cfd3a4b63c3ef902` is pushed. [CI 39971598320](https://github.com/link-foundation/meta-language/actions/runs/39971598320) is queued for exact-commit native compilation/execution, parity, complete suites, full raw timing, naming policy, workloads and acceptance. Local invocation receipts are not requirement observations.\n\nFull class/regex/initializer semantics and complete own-codebase translation remain unfinished; 77 ledger rows still lack complete implementation entry points. The [task handoff](https://github.com/link-foundation/meta-language/blob/1d25066a857b16e58ed954b0cfd3a4b63c3ef902/docs/handoffs/issue-199-after-pr-201-2026-10-19.md) retains the failures, repairs and receipts. Remaining scope stays in [issue #227](https://github.com/link-foundation/meta-language/issues/227), with grammar inference in [issue #224](https://github.com/link-foundation/meta-language/issues/224). No full-completion or closing claim.","headRefOid":"3b77cb71a42c091c89d952f24acfe652ee95a1a1","state":"OPEN","title":"Expand source-preserving JavaScript/Rust translation and repair CI histories","url":"https://github.com/link-foundation/meta-language/pull/228"} diff --git a/docs/case-studies/issue-1/data/pull-conversation.json b/docs/case-studies/issue-1/data/pull-conversation.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/docs/case-studies/issue-1/data/pull-conversation.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/docs/case-studies/issue-1/data/pull-inline-comments.json b/docs/case-studies/issue-1/data/pull-inline-comments.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/docs/case-studies/issue-1/data/pull-inline-comments.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/docs/case-studies/issue-1/data/pull-reviews.json b/docs/case-studies/issue-1/data/pull-reviews.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/docs/case-studies/issue-1/data/pull-reviews.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/docs/case-studies/issue-1/data/source-files.tsv b/docs/case-studies/issue-1/data/source-files.tsv new file mode 100644 index 0000000..5e0df0e --- /dev/null +++ b/docs/case-studies/issue-1/data/source-files.tsv @@ -0,0 +1,16 @@ +repository revision path sha256 +link-foundation/code-quality e0e2e03d8e78fee2119e6d272ebee4aef2505682 src/quality/bash-syntax.js 0e74a03daf38231931a4d815366b9b42c0ab35c7be23204a9ae3f547502d8fb2 +link-foundation/code-quality e0e2e03d8e78fee2119e6d272ebee4aef2505682 src/quality/cmake.js eb7c00a0c9f33db5bef0019b4aa477ef0d67fd1f698874fc05602ea09c21f5c7 +link-foundation/code-quality e0e2e03d8e78fee2119e6d272ebee4aef2505682 src/quality/config.js f51423ed50801a145a013136d126616cb25c6fbbf9ae2db34dca13dd0092cbc3 +link-foundation/code-quality e0e2e03d8e78fee2119e6d272ebee4aef2505682 src/quality/evolution.js 8168f63ecaaa2279ef8f44c9ea55f09adbb39e462848c7d967249be42889b74d +link-foundation/code-quality e0e2e03d8e78fee2119e6d272ebee4aef2505682 src/quality/git.js d83ec7da0b4a65956de1f0cc638203896d37106a1510dfbcea9061ef9f6d55f0 +link-foundation/code-quality e0e2e03d8e78fee2119e6d272ebee4aef2505682 src/quality/grammars/BASH-LICENSE 49bf33cf78ef5897e4e161ce1517df7de1ae5042a65b6bcfd44401e0fc606559 +link-foundation/code-quality e0e2e03d8e78fee2119e6d272ebee4aef2505682 src/quality/grammars/tree-sitter-bash.wasm d1844429a58620f306b6f42aebe92298243ca8120cd833a3ab5d87c7a2e7b9fd +link-foundation/code-quality e0e2e03d8e78fee2119e6d272ebee4aef2505682 src/quality/languages.js 0c18d85af078cf490f872a9145af89f1d70cef32081143f787b92b0a7dfd1ea0 +link-foundation/code-quality e0e2e03d8e78fee2119e6d272ebee4aef2505682 src/quality/lines.js 96f6fef6b56eefd962a294e529768e499373b00d973a452aa05b6d823d5d53a4 +link-foundation/code-quality e0e2e03d8e78fee2119e6d272ebee4aef2505682 src/quality/process.js 5f2482d7d3ee4f54cc50242ec426e32dfa2ced431f9333150c838f3c2f06fcdf +link-foundation/code-quality e0e2e03d8e78fee2119e6d272ebee4aef2505682 src/quality/syntax.js 84decda152eefacde30c11935f1f71e7c89335e4210908faa178137d06779a7c +link-foundation/code-quality e0e2e03d8e78fee2119e6d272ebee4aef2505682 tests/quality-evolution.test.js cad9c435209952996d0afa8c92c066cc3d4f2022210b4f00af05f477f638566b +link-foundation/code-quality e0e2e03d8e78fee2119e6d272ebee4aef2505682 tests/quality-cmake-evolution.test.js 32c50c104db0508d9ba63a6fffa567de9eef7c6cb75beece4de1e66e90f6304d +link-foundation/code-quality e0e2e03d8e78fee2119e6d272ebee4aef2505682 tests/fixtures/quality-languages.js e9ab85db0fb08be2b50467611239f35f8cc5e8d2c2739c171600c1ccab304a65 +link-foundation/meta-language 3b77cb71a42c091c89d952f24acfe652ee95a1a1 js/src/tree-sitter-node-kind.js b2ccb1af4a58312ec5923bfd10d139a02d05c3c9a97b75509bf9fa2c9832c433 diff --git a/docs/case-studies/issue-1/data/sub-issues.json b/docs/case-studies/issue-1/data/sub-issues.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/docs/case-studies/issue-1/data/sub-issues.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/docs/evolution.md b/docs/evolution.md new file mode 100644 index 0000000..a9a21cd --- /dev/null +++ b/docs/evolution.md @@ -0,0 +1,55 @@ +# Git history analysis + +The `@link-foundation/code-evolution/evolution` entry point reads a local Git repository and returns a JSON-compatible report. The `code-evolution` executable writes the same report. Both require Git on `PATH`. The package supports Node.js 20 and later. The Git fixtures also run under Bun and Deno. + +```bash +node bin/code-evolution.js /path/to/repository --max-commits 25 --output report.json +``` + +```js +import { extractEvolution } from '@link-foundation/code-evolution/evolution'; + +const report = await extractEvolution('/path/to/repository', { + to: 'HEAD', + maxCommits: 25, +}); +``` + +The CLI uses `lino-arguments` and accepts a Links Notation configuration file via `--configuration`. Run `node bin/code-evolution.js --help` for all options. A refusal exits with status 2 and writes its reason to stderr. + +## History selection + +The engine resolves commit refs, follows the first parent of each commit, then reports the selected snapshots from oldest to newest. `to` defaults to `HEAD`. `from` is inclusive and must be within the selected first-parent window of `to`. When `from` is omitted, `truncated` reports whether the local history reaches beyond the commit limit. A shallow clone can hide older history. Merge results are visible in first-parent snapshots. Side-branch commits, index changes and uncommitted files are outside the analysis window. + +The first selected snapshot contributes additions for every tracked identity in that snapshot. Its file events count toward hotspot and coupling totals. Identity IDs and aggregated counts can therefore change when you change the starting commit. + +The source projection recognizes JavaScript, TypeScript, TSX, Rust, Python, Go, C#, Java, C, C++, PHP, Bash and CMake. It excludes known dependency and build directories (`node_modules`, `vendor`, `target`, `dist` and `.venv`). The analyzer refuses recognized source entries that are symlinks or other non-regular Git entries, binary sources, syntax errors, and definitions requiring unsupported CMake expansion. + +| Option | Default | Maximum | +| ---------------------------- | ------: | ------: | +| `maxCommits` | 100 | 1,000 | +| `maxFiles` per snapshot | 1,000 | 1,000 | +| `maxFileBytes` | 1 MiB | 1 MiB | +| `maxTotalBytes` per snapshot | 16 MiB | 16 MiB | + +Git subprocesses have individual 30-second and output limits. Parsing has independent traversal, complexity and metadata budgets. The engine refuses histories with more than 50,000 events or more than 100,000 distinct candidate file pairs. Commits with more than 100 file events contribute to hotspots and are excluded from coupling. Source blobs must be present locally when Git honors `GIT_NO_LAZY_FETCH`. + +## Identity and report interpretation + +- Earlier and later entries must have the same kind and language. Matching tries unique path plus qualified name, then unique exact content, then unique normalized structure for functions and classes. Each earlier entry can be matched once. A candidate duplicated on either side cannot match by that criterion. +- Identity continues across a matched rename. An exact-content file rename is eligible for continuity. A move with edits can appear as a file deletion and addition. Same-shaped declarations may be unrelated, and true continuations can become ambiguous. If every criterion fails, the engine records additions and deletions with independent identities. +- A file content hash is its Git blob ID. An abstraction content hash is SHA-256 over its source span. Structural hashes use normalized syntax, so identifiers and selected literals can vary across the same shape. A file shape summarizes its abstraction shapes. Additional edit hashes capture transformations such as operator changes that the structural projection may normalize. +- Hotspots count file events by reported path. A coupling entry counts commits where both paths had a file event and appears after two such commits. Batches, the initial snapshot and renames can affect both rankings. Use the timeline to inspect the underlying commits. +- A repeated transformation groups matching before/after edit hashes by language and abstraction kind. Suggestions link each occurrence by commit, path and identity ID. A single commit can contribute several occurrences. The report labels suggestions observational because structural changes do not establish behavioral equivalence or maintenance benefit. + +The `schemaVersion: 1` contract includes resolved refs, ordered commits, the identity events, current identities, summaries and limitations. See the [Code Quality compatibility check](../examples/code-quality-consumer/README.md) and the [extraction case study](case-studies/issue-1/README.md). + +## Demo + +```bash +npm ci --prefix examples/universal-app +npm run example:web:build +npm run example:web:preview +``` + +Open `/evolution/` on the printed local address. Explore the built-in history or choose **Open JSON** to inspect a report. The demo reads files up to 8 MiB in the browser. To recreate the built-in report byte for byte, run `node examples/evolution-report/generate.mjs` from the repository root. The sample generator writes dates in canonical UTC form so Git versions that spell the same offset differently produce identical sample JSON. diff --git a/docs/screenshots/code-evolution.png b/docs/screenshots/code-evolution.png new file mode 100644 index 0000000..511ac88 Binary files /dev/null and b/docs/screenshots/code-evolution.png differ diff --git a/eslint.config.js b/eslint.config.js index 195debf..ca64225 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -95,7 +95,10 @@ export default [ }, }, { - files: ['examples/universal-app/src/**/*.js'], + files: [ + 'examples/universal-app/src/**/*.js', + 'examples/universal-app/evolution/**/*.js', + ], languageOptions: { globals: { document: 'readonly', diff --git a/examples/code-quality-consumer/README.md b/examples/code-quality-consumer/README.md new file mode 100644 index 0000000..174ea60 --- /dev/null +++ b/examples/code-quality-consumer/README.md @@ -0,0 +1,18 @@ +# Code Quality dependency compatibility + +The verifier runs the original Code Quality CLI, library API and localhost HTTP endpoint from the exact upstream commit in `code-quality-source.txt`. It installs a packed Code Evolution candidate into a temporary copy of the same consumer, changes its evolution module to a re-export, and runs the unchanged entry points again. The comparison covers the complete v1 report, a truncated window and an invalid revision. It also checks the packed Code Evolution executable against the same report. + +```bash +git clone --filter=blob:none --no-checkout https://github.com/link-foundation/code-quality.git code-quality-source +git -C code-quality-source sparse-checkout set bin src +git -C code-quality-source checkout "$(cat examples/code-quality-consumer/code-quality-source.txt)" +node examples/code-quality-consumer/verify.mjs code-quality-source +``` + +The verifier installs the exact tarball path, checks the package lock's SHA-512 integrity against the bytes from `npm pack`, and verifies reproducibility with `npm ci`. The PR workflow repeats this check against its own candidate. The re-export uses the following public entry point. + +```js +export { extractEvolution } from '@link-foundation/code-evolution/evolution'; +``` + +Code Quality's open implementation PR keeps the inline engine as specified in the extraction issue. Its consumer cutover is demonstrated in the temporary checkout. A later consumer revision can use the exact published Code Evolution version, with the corresponding integrity checked into its lockfile, once the package is published. [Code Quality PR #2](https://github.com/link-foundation/code-quality/pull/2), [extraction issue](https://github.com/link-foundation/code-evolution/issues/1) diff --git a/examples/code-quality-consumer/code-quality-source.txt b/examples/code-quality-consumer/code-quality-source.txt new file mode 100644 index 0000000..91cfa5e --- /dev/null +++ b/examples/code-quality-consumer/code-quality-source.txt @@ -0,0 +1 @@ +e0e2e03d8e78fee2119e6d272ebee4aef2505682 diff --git a/examples/code-quality-consumer/observe.mjs b/examples/code-quality-consumer/observe.mjs new file mode 100644 index 0000000..ccf7e8f --- /dev/null +++ b/examples/code-quality-consumer/observe.mjs @@ -0,0 +1,48 @@ +import assert from 'node:assert/strict'; +import { execFileSync } from 'node:child_process'; +import { once } from 'node:events'; + +const { extractEvolution, createQualityServer } = + await import('@link-foundation/code-quality/quality'); + +const root = process.argv[2]; +const report = await extractEvolution(root); +assert.equal(report.commits.length, 5); +assert.ok(report.repeatedPatterns.length > 0); +assert.ok(report.coupling.length > 0); +const cli = JSON.parse( + execFileSync(process.execPath, ['bin/code-quality.js', 'evolution', root], { + encoding: 'utf8', + maxBuffer: 1_048_576, + timeout: 30_000, + }) +); +assert.deepEqual(cli, report); +const limited = await extractEvolution(root, { maxCommits: 2 }); +assert.equal(limited.truncated, true); + +const server = createQualityServer({ root }); +const listening = once(server, 'listening'); +server.listen(0, '127.0.0.1'); +await listening; +try { + const url = `http://127.0.0.1:${server.address().port}/v1/evolution`; + const request = (body) => + fetch(url, { + method: 'POST', + headers: { 'content-type': 'application/json' }, + body: JSON.stringify(body), + signal: AbortSignal.timeout(15_000), + }); + const result = await request({ maxCommits: 2 }); + assert.equal(result.status, 200); + assert.deepEqual(await result.json(), limited); + const invalid = await request({ to: '--all' }); + assert.equal(invalid.status, 400); + const refusal = await invalid.json(); + assert.match(refusal.error, /Invalid Git revision/); + console.log(JSON.stringify({ report, limited, refusal })); +} finally { + server.closeAllConnections(); + await new Promise((done) => server.close(done)); +} diff --git a/examples/code-quality-consumer/verify.mjs b/examples/code-quality-consumer/verify.mjs new file mode 100644 index 0000000..ec5a0be --- /dev/null +++ b/examples/code-quality-consumer/verify.mjs @@ -0,0 +1,118 @@ +import assert from 'node:assert/strict'; +import { execFileSync } from 'node:child_process'; +import { createHash } from 'node:crypto'; +import { cp, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import { join, resolve } from 'node:path'; +import { URL } from 'node:url'; +import { withExampleHistory } from '../evolution-report/generate.mjs'; + +const packageName = '@link-foundation/code-evolution'; +const sourceRepository = resolve(process.argv[2] || ''); +const project = new URL('../../', import.meta.url); +const [pinnedSource] = ( + await readFile(new URL('./code-quality-source.txt', import.meta.url), 'utf8') +) + .trim() + .split(/\s+/); + +function run(command, args, cwd) { + return execFileSync(command, args, { + cwd, + encoding: 'utf8', + maxBuffer: 2_097_152, + timeout: 120_000, + }); +} + +async function prepareConsumer(directory) { + assert.equal( + run('git', ['rev-parse', 'HEAD'], sourceRepository).trim(), + pinnedSource + ); + for (const path of ['package.json', 'package-lock.json', 'bin', 'src']) { + await cp(join(sourceRepository, path), join(directory, path), { + recursive: true, + }); + } + const [pkg] = JSON.parse( + run('npm', ['pack', '--json', '--pack-destination', directory], project) + ); + run( + 'npm', + ['ci', '--omit=dev', '--ignore-scripts', '--no-audit', '--no-fund'], + directory + ); + await cp( + new URL('./observe.mjs', import.meta.url), + join(directory, 'observe.mjs') + ); + return pkg; +} + +async function installDependency(directory, pkg) { + const archive = join(directory, pkg.filename); + const sha = createHash('sha512') + .update(await readFile(archive)) + .digest('base64'); + assert.equal(pkg.integrity, `sha512-${sha}`); + run( + 'npm', + [ + 'install', + '--omit=dev', + '--ignore-scripts', + '--no-audit', + '--no-fund', + '--save-exact', + `./${pkg.filename}`, + ], + directory + ); + const lock = JSON.parse( + await readFile(join(directory, 'package-lock.json'), 'utf8') + ); + assert.equal( + lock.packages[''].dependencies[packageName], + `file:${pkg.filename}` + ); + assert.equal( + lock.packages[`node_modules/${packageName}`].integrity, + pkg.integrity + ); + await writeFile( + join(directory, 'src/quality/evolution.js'), + `export { extractEvolution } from '${packageName}/evolution';\n` + ); + run( + 'npm', + ['ci', '--omit=dev', '--ignore-scripts', '--no-audit', '--no-fund'], + directory + ); +} + +assert.ok(process.argv[2], 'Provide the pinned Code Quality checkout'); +const directory = await mkdtemp(join(tmpdir(), 'code-quality-consumer-')); +try { + const pkg = await prepareConsumer(directory); + await withExampleHistory(async (repository) => { + const observe = () => + JSON.parse(run(process.execPath, ['observe.mjs', repository], directory)); + const before = observe(); + await installDependency(directory, pkg); + assert.deepEqual(observe(), before); + const executable = join( + directory, + 'node_modules', + packageName, + 'bin/code-evolution.js' + ); + const report = run(process.execPath, [executable, repository], directory); + assert.deepEqual(JSON.parse(report), before.report); + }); + console.log( + `Code Quality library, CLI and HTTP parity verified with ${pkg.name}@${pkg.version} (${pkg.integrity})` + ); +} finally { + await rm(directory, { recursive: true, force: true }); +} diff --git a/examples/evolution-report/generate.mjs b/examples/evolution-report/generate.mjs new file mode 100644 index 0000000..b8bb074 --- /dev/null +++ b/examples/evolution-report/generate.mjs @@ -0,0 +1,130 @@ +import { spawnSync } from 'node:child_process'; +import { mkdtemp, mkdir, rename, rm, writeFile } from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { fileURLToPath, pathToFileURL, URL } from 'node:url'; +import { extractEvolution } from '../../src/evolution/index.js'; + +const initial = { + 'src/cache.js': 'export function cached(value) { return value; }\n', + 'src/normalize.js': + 'export function label(value) { if (value) { return value; } return "none"; }\n' + + 'export function title(name) { if (name) { return name; } return "none"; }\n', + 'src/format.js': + 'export class Formatter { format(value) { return String(value); } }\n', + 'src/metrics.py': 'def count(values):\n return len(values)\n', +}; + +export async function withExampleHistory(callback) { + const root = await mkdtemp(join(tmpdir(), 'evolution-example-')); + let date; + const git = (...args) => { + const result = spawnSync( + 'git', + [ + '-C', + root, + '-c', + 'core.autocrlf=false', + '-c', + 'core.hooksPath=.', + '-c', + 'commit.gpgsign=false', + ...args, + ], + { + encoding: 'utf8', + maxBuffer: 65_536, + env: { + ...process.env, + GIT_CONFIG_GLOBAL: join(root, 'no-global-config'), + GIT_CONFIG_NOSYSTEM: '1', + GIT_AUTHOR_NAME: 'Evolution Fixture', + GIT_AUTHOR_EMAIL: 'fixture@example.invalid', + GIT_COMMITTER_NAME: 'Evolution Fixture', + GIT_COMMITTER_EMAIL: 'fixture@example.invalid', + GIT_AUTHOR_DATE: date, + GIT_COMMITTER_DATE: date, + }, + } + ); + if (result.status !== 0) { + throw result.error || new Error(result.stderr.trim()); + } + }; + const write = (path, value) => writeFile(join(root, path), value); + const commit = (day, subject) => { + date = `2026-06-${day}T12:00:00Z`; + git('add', '--all'); + git('commit', '--quiet', '-m', subject); + }; + try { + git('init', '--quiet', '--initial-branch=main', '--object-format=sha1'); + await mkdir(join(root, 'src')); + for (const [path, source] of Object.entries(initial)) { + await write(path, source); + } + commit('02', 'Introduce text formatting and metrics'); + await write( + 'src/normalize.js', + 'export function label(value) { return value || "none"; }\n' + + 'export function title(name) { return name || "none"; }\n' + ); + await write( + 'src/metrics.py', + 'def count(values):\n return sum(1 for value in values)\n' + ); + commit('05', 'Simplify repeated default-value branches'); + await write( + 'src/format.js', + 'export class Formatter { format(value) { return String(value).trim(); } }\n' + ); + await write( + 'src/normalize.js', + 'export function label(value) { return value || "none"; }\n' + + 'export function title(name) { return name || "none"; }\n' + + 'export function slug(value) { return label(value).trim(); }\n' + ); + commit('08', 'Add a slug and trim formatted output'); + await rename(join(root, 'src/format.js'), join(root, 'src/formatter.js')); + commit('12', 'Move the formatter to a dedicated file'); + await rm(join(root, 'src/cache.js')); + await write( + 'src/metrics.py', + 'def count(values):\n return len(set(values))\n' + ); + commit('17', 'Remove the unused cache and count unique values'); + return await callback(root); + } finally { + await rm(root, { recursive: true, force: true }); + } +} + +export async function generateSampleReport() { + const report = await withExampleHistory(extractEvolution); + return { + ...report, + commits: report.commits.map((commit) => ({ + ...commit, + date: new Date(commit.date).toISOString(), + })), + }; +} + +if ( + process.argv[1] && + import.meta.url === pathToFileURL(process.argv[1]).href +) { + const report = await generateSampleReport(); + const destination = new URL( + '../universal-app/evolution/sample-report.json', + import.meta.url + ); + const { format, resolveConfig } = await import('prettier'); + const filepath = fileURLToPath(destination); + const options = await resolveConfig(filepath); + await writeFile( + destination, + await format(JSON.stringify(report, null, 2), { ...options, filepath }) + ); +} diff --git a/examples/universal-app/evolution/actions.lino b/examples/universal-app/evolution/actions.lino new file mode 100644 index 0000000..d2e0db7 --- /dev/null +++ b/examples/universal-app/evolution/actions.lino @@ -0,0 +1,12 @@ +report: document + actions: stack + direction horizontal + upload: button + label 'Open JSON' + variant filled + on press + navigate upload + sample: button + label 'Reset sample' + on press + navigate sample diff --git a/examples/universal-app/evolution/en.lino b/examples/universal-app/evolution/en.lino new file mode 100644 index 0000000..b211ee9 --- /dev/null +++ b/examples/universal-app/evolution/en.lino @@ -0,0 +1,12 @@ +en + commits "Commits" + changes "Changes" + hotspots "File hotspots" + patterns "Repeated patterns" + none "No matches in this report." + added "Added" + deleted "Deleted" + modified "Modified" + renamed "Renamed" + invalid "Open a valid Code Evolution JSON report under 8 MiB." + truncated "This report covers only the most recent part of the available history." diff --git a/examples/universal-app/evolution/index.html b/examples/universal-app/evolution/index.html new file mode 100644 index 0000000..a53c69e --- /dev/null +++ b/examples/universal-app/evolution/index.html @@ -0,0 +1,104 @@ + + + + + + + + Code Evolution + + +
+ +
+
+
+

Follow the changes.

+

+ See how files, functions, and classes evolve across a Git history. +

+
+
+
+

REPORT

+ Formatting utilities +
+
+
+ +
+
+ +
+
+
+
+
+

Commit timeline

+
+ +
+
+
+
+
+
+
+

File hotspots

+
+
+
+
+
+
+
+

Change coupling

+
+
+
+
+
+
+
+
+
+

Repeated transformations

+
+
+
+
+
+ Report scope and limitations +
    +
    +
    JSON reports open locally in your browser.
    +
    + + + diff --git a/examples/universal-app/evolution/main.js b/examples/universal-app/evolution/main.js new file mode 100644 index 0000000..3326375 --- /dev/null +++ b/examples/universal-app/evolution/main.js @@ -0,0 +1,304 @@ +import { mountDocument } from '@link-foundation/ui-dom'; +import { createI18n, parseLinoCatalogs } from 'lino-i18n/browser'; +import sample from './sample-report.json'; +import layout from './actions.lino?raw'; +import catalog from './en.lino?raw'; +import { eventsByCommit, isReport } from './report.js'; +import './styles.css'; + +const [en] = parseLinoCatalogs(catalog); +const i18n = createI18n({ + defaultLocale: 'en', + locales: { en: en.translations }, +}); +const t = (key) => i18n.t(key); +const byId = (id) => document.getElementById(id); +const filter = byId('change-kind'); +const fileInput = byId('report-file'); +const dateFormat = new Intl.DateTimeFormat('en', { + dateStyle: 'medium', + timeZone: 'UTC', +}); +let report; +let byCommit; +let selection = 0; + +function make(tag, className, text) { + const item = document.createElement(tag); + item.className = className; + if (text !== undefined) { + item.textContent = text; + } + return item; +} + +function changeLabel(event) { + const location = (entry) => + event.kind === 'file' + ? entry.path + : `${entry.path} · ${entry.qualifiedName}`; + if (event.action === 'renamed') { + return `${location(event.before)} → ${location(event.after)}`; + } + return location(event.after || event.before); +} + +function commitItem(commit, events, expanded, evidenceId) { + const item = make('details', 'commit'); + item.id = `commit-${commit.sha}`; + item.open = expanded; + const summary = make('summary', 'commit-summary'); + const copy = make('span', 'commit-copy'); + copy.append( + make('strong', '', commit.subject || 'Untitled commit'), + make( + 'small', + '', + `${commit.sha.slice(0, 8)} · ${dateFormat.format(new Date(commit.date))}` + ) + ); + summary.append(copy, make('span', 'count', String(events.length))); + const changes = make('ul', 'changes'); + const visible = events.slice(0, 100); + if (evidenceId && !visible.some(({ id }) => id === evidenceId)) { + const evidence = events.find(({ id }) => id === evidenceId); + if (evidence) { + visible.push(evidence); + } + } + for (const event of visible) { + const row = make('li', 'change'); + if (event.id === evidenceId) { + row.tabIndex = -1; + row.dataset.evidence = ''; + } + row.append( + make('span', `change-action ${event.action}`, t(event.action)), + make('span', 'change-path', changeLabel(event)) + ); + changes.append(row); + } + if (events.length > visible.length) { + changes.append( + make( + 'li', + 'empty', + `Showing ${visible.length} of ${events.length} changes.` + ) + ); + } + item.append(summary, changes); + return item; +} + +function renderTimeline(evidence) { + const commits = report.commits + .slice() + .reverse() + .map((commit) => ({ + commit, + events: (byCommit.get(commit.sha) || []).filter( + (event) => !filter.value || event.kind === filter.value + ), + })) + .filter(({ events }) => !filter.value || events.length); + const timeline = byId('timeline'); + const visible = commits.slice(0, 100); + if ( + evidence && + !visible.some(({ commit }) => commit.sha === evidence.commit) + ) { + const entry = commits.find(({ commit }) => commit.sha === evidence.commit); + if (entry) { + visible.push(entry); + } + } + timeline.replaceChildren( + ...visible.map(({ commit, events }, index) => + commitItem( + commit, + events, + index === 0, + commit.sha === evidence?.commit ? evidence.id : undefined + ) + ) + ); + if (!commits.length) { + timeline.append(make('p', 'empty', t('none'))); + } else if (commits.length > visible.length) { + timeline.append( + make( + 'p', + 'empty', + `Showing ${visible.length} of ${commits.length} commits.` + ) + ); + } +} + +function renderHotspots() { + const container = byId('hotspots'); + const rows = report.hotspots.slice(0, 6); + const max = Math.max(1, ...rows.map(({ changes }) => changes)); + container.replaceChildren(); + for (const { path, changes } of rows) { + const item = make('div', 'hotspot'); + const row = make('div', 'hotspot-row'); + row.append(make('code', '', path), make('span', '', String(changes))); + const bar = make('div', 'bar'); + bar.setAttribute('aria-hidden', 'true'); + const fill = make('span', ''); + fill.style.width = `${(changes / max) * 100}%`; + bar.append(fill); + item.append(row, bar); + container.append(item); + } + if (!rows.length) { + container.append(make('p', 'empty', t('none'))); + } +} + +function renderCoupling() { + const container = byId('coupling'); + const rows = report.coupling.slice(0, 5); + container.replaceChildren(); + for (const { files, commits } of rows) { + const item = make('div', 'coupling-row'); + const paths = make('span', 'pair'); + paths.append(make('code', '', files[0]), make('code', '', files[1])); + item.append(paths, make('span', 'count', String(commits))); + container.append(item); + } + if (!rows.length) { + container.append(make('p', 'empty', t('none'))); + } +} + +function evidenceButton(evidence) { + const event = byCommit + .get(evidence.commit) + ?.find(({ id }) => id === evidence.id); + const label = event ? changeLabel(event) : evidence.path; + const button = make( + 'button', + 'evidence-button', + `${evidence.commit.slice(0, 8)} · ${label}` + ); + button.type = 'button'; + button.addEventListener('click', () => { + filter.value = ''; + renderTimeline(evidence); + const target = byId(`commit-${evidence.commit}`); + if (target) { + target.open = true; + const row = + target.querySelector('[data-evidence]') || + target.querySelector('summary'); + row.focus(); + row.scrollIntoView({ block: 'center' }); + } + }); + return button; +} + +function renderPatterns() { + const container = byId('patterns'); + const rows = report.suggestions.slice(0, 10); + container.replaceChildren(); + for (const { patternId, evidence, message } of rows) { + const card = make('div', 'pattern'); + const count = + report.repeatedPatterns.find(({ id }) => id === patternId)?.count ?? + evidence.length; + const evidenceActions = make('div', 'evidence-actions'); + for (const entry of evidence.slice(0, 10)) { + evidenceActions.append(evidenceButton(entry)); + } + card.append( + make('strong', '', `${count} occurrences`), + make('p', '', message), + evidenceActions + ); + container.append(card); + } + if (!rows.length) { + container.append(make('p', 'empty', t('none'))); + } +} + +function notice(message) { + const status = byId('notice'); + status.textContent = message; + status.hidden = !message; +} + +function show(next, name) { + report = next; + byCommit = eventsByCommit(next.events); + filter.value = ''; + byId('report-name').textContent = name; + notice(report.truncated ? t('truncated') : ''); + const values = [ + ['commits', report.commits.length], + ['changes', report.events.length], + ['hotspots', report.hotspots.length], + ['patterns', report.repeatedPatterns.length], + ]; + byId('metrics').replaceChildren( + ...values.map(([key, value]) => { + const metric = make('div', 'metric'); + metric.append(make('dt', '', t(key)), make('dd', '', String(value))); + return metric; + }) + ); + byId('limits').replaceChildren( + ...report.limitations.slice(0, 10).map((limit) => make('li', '', limit)) + ); + renderTimeline(); + renderHotspots(); + renderCoupling(); + renderPatterns(); +} + +function showSample() { + show(sample, 'Formatting utilities'); +} + +async function openReport() { + const request = ++selection; + const [file] = fileInput.files; + fileInput.value = ''; + if (!file) { + return; + } + try { + if (file.size > 8_388_608) { + throw new Error('File too large'); + } + const candidate = JSON.parse(await file.text()); + if (!isReport(candidate)) { + throw new Error('Invalid report'); + } + if (request === selection) { + show(candidate, file.name); + } + } catch { + if (request === selection) { + notice(t('invalid')); + } + } +} + +mountDocument(byId('report-actions'), layout, { + onAction({ source }) { + if (source === 'upload') { + fileInput.click(); + } else if (source === 'sample') { + selection++; + showSample(); + } + }, +}); +filter.addEventListener('change', () => renderTimeline()); +fileInput.addEventListener('change', openReport); +showSample(); diff --git a/examples/universal-app/evolution/report.js b/examples/universal-app/evolution/report.js new file mode 100644 index 0000000..04c0a99 --- /dev/null +++ b/examples/universal-app/evolution/report.js @@ -0,0 +1,65 @@ +const actions = new Set(['added', 'deleted', 'modified', 'renamed']); +const isText = (value) => typeof value === 'string'; +const isCount = (value) => Number.isSafeInteger(value) && value > 0; +const isSha = (value) => + typeof value === 'string' && /^(?:[\da-f]{40}|[\da-f]{64})$/.test(value); +const records = (list, test) => + Array.isArray(list) && list.every((item) => item && test(item)); +const isIdentity = (entry) => + entry && isText(entry.path) && isText(entry.qualifiedName); +const isEvent = (entry) => + isSha(entry.commit) && + isSha(entry.id) && + isText(entry.kind) && + actions.has(entry.action) && + (entry.action === 'added' || isIdentity(entry.before)) && + (entry.action === 'deleted' || isIdentity(entry.after)); +const isCommit = (entry) => + isSha(entry.sha) && + isText(entry.subject) && + isText(entry.date) && + Number.isFinite(Date.parse(entry.date)); +const isPathPair = (entry) => + Array.isArray(entry.files) && + entry.files.length === 2 && + entry.files.every(isText) && + isCount(entry.commits); +const isSuggestion = (entry) => + isText(entry.message) && + isText(entry.patternId) && + records( + entry.evidence, + ({ commit, id, path }) => isSha(commit) && isSha(id) && isText(path) + ); + +export function isReport(report) { + return ( + report?.schemaVersion === 1 && + report.algorithm === 'first-parent-structural-v1' && + typeof report.truncated === 'boolean' && + records(report.commits, isCommit) && + records(report.events, isEvent) && + records( + report.hotspots, + ({ path, changes }) => isText(path) && isCount(changes) + ) && + records(report.coupling, isPathPair) && + records( + report.repeatedPatterns, + ({ id, count }) => isText(id) && isCount(count) + ) && + records(report.suggestions, isSuggestion) && + Array.isArray(report.limitations) && + report.limitations.every(isText) + ); +} + +export function eventsByCommit(events) { + const byCommit = new Map(); + for (const event of events) { + const entries = byCommit.get(event.commit) || []; + entries.push(event); + byCommit.set(event.commit, entries); + } + return byCommit; +} diff --git a/examples/universal-app/evolution/sample-report.json b/examples/universal-app/evolution/sample-report.json new file mode 100644 index 0000000..4ebd5b2 --- /dev/null +++ b/examples/universal-app/evolution/sample-report.json @@ -0,0 +1,1077 @@ +{ + "schemaVersion": 1, + "algorithm": "first-parent-structural-v1", + "from": "57583c74ae4ff44af9c298079fbaeece1bae59e6", + "to": "f5cbf88018970626328fd80ba03eced9047a996f", + "truncated": false, + "commits": [ + { + "sha": "57583c74ae4ff44af9c298079fbaeece1bae59e6", + "date": "2026-06-02T12:00:00.000Z", + "subject": "Introduce text formatting and metrics" + }, + { + "sha": "3cbc8894b04fb1b5405b5e3113c1f276a95fb2b3", + "date": "2026-06-05T12:00:00.000Z", + "subject": "Simplify repeated default-value branches" + }, + { + "sha": "3ef49e932e9c93a8fec52b4519802112685b919e", + "date": "2026-06-08T12:00:00.000Z", + "subject": "Add a slug and trim formatted output" + }, + { + "sha": "da1be2417d7c3dcd5bac5e065ee92ecee158d60d", + "date": "2026-06-12T12:00:00.000Z", + "subject": "Move the formatter to a dedicated file" + }, + { + "sha": "f5cbf88018970626328fd80ba03eced9047a996f", + "date": "2026-06-17T12:00:00.000Z", + "subject": "Remove the unused cache and count unique values" + } + ], + "events": [ + { + "commit": "57583c74ae4ff44af9c298079fbaeece1bae59e6", + "id": "64b8cb400722e86866233227fd7caed00096eebe50677ef738165016e26931ad", + "kind": "file", + "action": "added", + "after": { + "path": "src/cache.js", + "kind": "file", + "name": "src/cache.js", + "qualifiedName": "src/cache.js", + "hash": "71be0b7cbe802894b44c8ab946ba7fd7499028c2", + "shape": "a56ffeac7bec40690d10ef61edd5e45ad7ed7dc6cba75525e036d2689d8073fc", + "language": "javascript", + "startLine": 1, + "complexity": 1, + "id": "64b8cb400722e86866233227fd7caed00096eebe50677ef738165016e26931ad" + } + }, + { + "commit": "57583c74ae4ff44af9c298079fbaeece1bae59e6", + "id": "3b05e8b32029b75b73c1e5f0f0a90373b4d42ea473219ab228ddbb9d11405bc2", + "kind": "function", + "action": "added", + "after": { + "kind": "function", + "syntaxKind": "function_declaration", + "name": "cached", + "qualifiedName": "cached", + "start": 7, + "end": 47, + "startLine": 1, + "endLine": 1, + "hash": "f5ffba3a64ad97eb13865c33080a529ebe1d4fc08a60d9e7198e8f42709cc3a9", + "parameters": 1, + "complexity": 1, + "shape": "7e3ebe2644d49e4264c514bd660a6a43caebff8cde1a0a418ccdf99b1d60d8d4", + "editHash": "7e3ebe2644d49e4264c514bd660a6a43caebff8cde1a0a418ccdf99b1d60d8d4", + "path": "src/cache.js", + "language": "javascript", + "id": "3b05e8b32029b75b73c1e5f0f0a90373b4d42ea473219ab228ddbb9d11405bc2" + } + }, + { + "commit": "57583c74ae4ff44af9c298079fbaeece1bae59e6", + "id": "2e9673475d2473eeddd7f12ab30e140ee443ce5c5b02bfcfa771042a2dd82959", + "kind": "file", + "action": "added", + "after": { + "path": "src/format.js", + "kind": "file", + "name": "src/format.js", + "qualifiedName": "src/format.js", + "hash": "661d795c809f31b55de6a30d5f805a0dac0c4cbb", + "shape": "3ea017c62a718b4203745afe275dba9dcac7af115a0b975816bd5362f0cfd66b", + "language": "javascript", + "startLine": 1, + "complexity": 2, + "id": "2e9673475d2473eeddd7f12ab30e140ee443ce5c5b02bfcfa771042a2dd82959" + } + }, + { + "commit": "57583c74ae4ff44af9c298079fbaeece1bae59e6", + "id": "0858bc9404191cc57b613bb0b8aec44afb58e32d3c7325f9cb0fb49c2d0a5a83", + "kind": "class", + "action": "added", + "after": { + "kind": "class", + "syntaxKind": "class_declaration", + "name": "Formatter", + "qualifiedName": "Formatter", + "start": 7, + "end": 66, + "startLine": 1, + "endLine": 1, + "hash": "e833ee1cc71c9fe52dddbd8916d0d4ed6ba11f8da2d3a7d25b976ef2aebd105f", + "parameters": 0, + "complexity": 1, + "shape": "80f71a9a2594fb9d880ac6ca1d1a2e4137040c3515f2cd0385b2268562e6ef62", + "editHash": "80f71a9a2594fb9d880ac6ca1d1a2e4137040c3515f2cd0385b2268562e6ef62", + "path": "src/format.js", + "language": "javascript", + "id": "0858bc9404191cc57b613bb0b8aec44afb58e32d3c7325f9cb0fb49c2d0a5a83" + } + }, + { + "commit": "57583c74ae4ff44af9c298079fbaeece1bae59e6", + "id": "6552ed8ea0a89c5143d0aa9f18c1892fcf48daa405f456ff761880696a6f0366", + "kind": "function", + "action": "added", + "after": { + "kind": "function", + "syntaxKind": "method_definition", + "name": "format", + "qualifiedName": "Formatter.format", + "start": 25, + "end": 64, + "startLine": 1, + "endLine": 1, + "hash": "fddd2cdcd8a9b038ddddef4a6d8f85cd2fdde848431db66c5b0bdd992b7b1d28", + "parameters": 1, + "complexity": 1, + "shape": "fbc6fb5ad998926f3793c9f5a733f6d13eba5b9776036a7bf70d7a4186b4d871", + "editHash": "fbc6fb5ad998926f3793c9f5a733f6d13eba5b9776036a7bf70d7a4186b4d871", + "path": "src/format.js", + "language": "javascript", + "id": "6552ed8ea0a89c5143d0aa9f18c1892fcf48daa405f456ff761880696a6f0366" + } + }, + { + "commit": "57583c74ae4ff44af9c298079fbaeece1bae59e6", + "id": "2854958d762638eac243cf2445b6797b409320cf5af34a7c50a4048d781787e4", + "kind": "file", + "action": "added", + "after": { + "path": "src/metrics.py", + "kind": "file", + "name": "src/metrics.py", + "qualifiedName": "src/metrics.py", + "hash": "b658981e8ffdba26593bbfd5485fa27923f57cd8", + "shape": "5f84cd31f03d2ae858a29d914ef62cc9df33f3cecd29110a60bafa9c14bf60f0", + "language": "python", + "startLine": 1, + "complexity": 1, + "id": "2854958d762638eac243cf2445b6797b409320cf5af34a7c50a4048d781787e4" + } + }, + { + "commit": "57583c74ae4ff44af9c298079fbaeece1bae59e6", + "id": "7047446222010452739430d8642900b0c126dcfb2ab481d44863ddc7bcb5906d", + "kind": "function", + "action": "added", + "after": { + "kind": "function", + "syntaxKind": "function_definition", + "name": "count", + "qualifiedName": "count", + "start": 0, + "end": 41, + "startLine": 1, + "endLine": 2, + "hash": "5e0709f85ae6dff3294bae821f1b72d42e5d9529357ce6a0fc32c637633399fa", + "parameters": 1, + "complexity": 1, + "shape": "c729a58f667a9a2d6f88c8316899f331839015d7c5b1fa5ef83e2c2e8b21b578", + "editHash": "c729a58f667a9a2d6f88c8316899f331839015d7c5b1fa5ef83e2c2e8b21b578", + "path": "src/metrics.py", + "language": "python", + "id": "7047446222010452739430d8642900b0c126dcfb2ab481d44863ddc7bcb5906d" + } + }, + { + "commit": "57583c74ae4ff44af9c298079fbaeece1bae59e6", + "id": "4611d04926ab7eebb45d61deb7731ca9c6813065817cd49792cba6d2dd26d4fa", + "kind": "file", + "action": "added", + "after": { + "path": "src/normalize.js", + "kind": "file", + "name": "src/normalize.js", + "qualifiedName": "src/normalize.js", + "hash": "c2beed8bbc77315944e6764bef2293a6e67de344", + "shape": "71b8f62b0de7bfe183b458b6dd13f034d099fa4db6ab77a5b06abcdfe2eb9629", + "language": "javascript", + "startLine": 1, + "complexity": 4, + "id": "4611d04926ab7eebb45d61deb7731ca9c6813065817cd49792cba6d2dd26d4fa" + } + }, + { + "commit": "57583c74ae4ff44af9c298079fbaeece1bae59e6", + "id": "674e7544bd8749bb3f72d25ceb2cbd10744d00938afe10082d5a8dcef633a563", + "kind": "function", + "action": "added", + "after": { + "kind": "function", + "syntaxKind": "function_declaration", + "name": "label", + "qualifiedName": "label", + "start": 7, + "end": 76, + "startLine": 1, + "endLine": 1, + "hash": "4864a64d2653c9b4f7eab7f157be2e95a5059d84e11b40901f4768857433d755", + "parameters": 1, + "complexity": 2, + "shape": "9d59733e176ce5ef66bb428d714142a00f4fc487a87165b78cda37c39d28f08e", + "editHash": "a2824929d6bcaf03e70c541e0f18e2dad965eac5a649a2479fea9f70c046b3b4", + "path": "src/normalize.js", + "language": "javascript", + "id": "674e7544bd8749bb3f72d25ceb2cbd10744d00938afe10082d5a8dcef633a563" + } + }, + { + "commit": "57583c74ae4ff44af9c298079fbaeece1bae59e6", + "id": "810d4134c3ed6bd5452285186ecaba7c8ba0e5f3a9630e819ca5236608c28238", + "kind": "function", + "action": "added", + "after": { + "kind": "function", + "syntaxKind": "function_declaration", + "name": "title", + "qualifiedName": "title", + "start": 84, + "end": 150, + "startLine": 2, + "endLine": 2, + "hash": "1e882961b76a6367981b5d3f3b3a38ee928cdc6a1d874f1f3e0f0094fedfcc41", + "parameters": 1, + "complexity": 2, + "shape": "9d59733e176ce5ef66bb428d714142a00f4fc487a87165b78cda37c39d28f08e", + "editHash": "a2824929d6bcaf03e70c541e0f18e2dad965eac5a649a2479fea9f70c046b3b4", + "path": "src/normalize.js", + "language": "javascript", + "id": "810d4134c3ed6bd5452285186ecaba7c8ba0e5f3a9630e819ca5236608c28238" + } + }, + { + "commit": "3cbc8894b04fb1b5405b5e3113c1f276a95fb2b3", + "id": "2854958d762638eac243cf2445b6797b409320cf5af34a7c50a4048d781787e4", + "kind": "file", + "action": "modified", + "matchedBy": "qualified-name", + "before": { + "path": "src/metrics.py", + "kind": "file", + "name": "src/metrics.py", + "qualifiedName": "src/metrics.py", + "hash": "b658981e8ffdba26593bbfd5485fa27923f57cd8", + "shape": "5f84cd31f03d2ae858a29d914ef62cc9df33f3cecd29110a60bafa9c14bf60f0", + "language": "python", + "startLine": 1, + "complexity": 1, + "id": "2854958d762638eac243cf2445b6797b409320cf5af34a7c50a4048d781787e4" + }, + "after": { + "path": "src/metrics.py", + "kind": "file", + "name": "src/metrics.py", + "qualifiedName": "src/metrics.py", + "hash": "b4f062cae06f19f0e8a53d654e0fb0a942bc47a2", + "shape": "40a702ca77ccbab57deebb21116d177e9172835ef3a74b44a075f7fc8ddae95f", + "language": "python", + "startLine": 1, + "complexity": 1, + "id": "2854958d762638eac243cf2445b6797b409320cf5af34a7c50a4048d781787e4" + } + }, + { + "commit": "3cbc8894b04fb1b5405b5e3113c1f276a95fb2b3", + "id": "7047446222010452739430d8642900b0c126dcfb2ab481d44863ddc7bcb5906d", + "kind": "function", + "action": "modified", + "matchedBy": "qualified-name", + "before": { + "kind": "function", + "syntaxKind": "function_definition", + "name": "count", + "qualifiedName": "count", + "start": 0, + "end": 41, + "startLine": 1, + "endLine": 2, + "hash": "5e0709f85ae6dff3294bae821f1b72d42e5d9529357ce6a0fc32c637633399fa", + "parameters": 1, + "complexity": 1, + "shape": "c729a58f667a9a2d6f88c8316899f331839015d7c5b1fa5ef83e2c2e8b21b578", + "editHash": "c729a58f667a9a2d6f88c8316899f331839015d7c5b1fa5ef83e2c2e8b21b578", + "path": "src/metrics.py", + "language": "python", + "id": "7047446222010452739430d8642900b0c126dcfb2ab481d44863ddc7bcb5906d" + }, + "after": { + "kind": "function", + "syntaxKind": "function_definition", + "name": "count", + "qualifiedName": "count", + "start": 0, + "end": 56, + "startLine": 1, + "endLine": 2, + "hash": "b6a59f7167c3a1a4e8e59d7130bc4a4470371d38d2eca1b5ebf04e930583e570", + "parameters": 1, + "complexity": 1, + "shape": "51b00abdde6a212eb7e42daf538c6b815021f6603a3322a58b0d06c223c8c5eb", + "editHash": "b377a8793fffdc8c48b978742c9601b2cecb7ec189809fd10b7e73edb4594c36", + "path": "src/metrics.py", + "language": "python", + "id": "7047446222010452739430d8642900b0c126dcfb2ab481d44863ddc7bcb5906d" + } + }, + { + "commit": "3cbc8894b04fb1b5405b5e3113c1f276a95fb2b3", + "id": "4611d04926ab7eebb45d61deb7731ca9c6813065817cd49792cba6d2dd26d4fa", + "kind": "file", + "action": "modified", + "matchedBy": "qualified-name", + "before": { + "path": "src/normalize.js", + "kind": "file", + "name": "src/normalize.js", + "qualifiedName": "src/normalize.js", + "hash": "c2beed8bbc77315944e6764bef2293a6e67de344", + "shape": "71b8f62b0de7bfe183b458b6dd13f034d099fa4db6ab77a5b06abcdfe2eb9629", + "language": "javascript", + "startLine": 1, + "complexity": 4, + "id": "4611d04926ab7eebb45d61deb7731ca9c6813065817cd49792cba6d2dd26d4fa" + }, + "after": { + "path": "src/normalize.js", + "kind": "file", + "name": "src/normalize.js", + "qualifiedName": "src/normalize.js", + "hash": "f2cfbf52ab2198073a4102354476c3d08b251ad3", + "shape": "6708e3fef21bf308a576f413b3c3eb420ecb6710e298d1eddccd94f1ccc0d7cb", + "language": "javascript", + "startLine": 1, + "complexity": 4, + "id": "4611d04926ab7eebb45d61deb7731ca9c6813065817cd49792cba6d2dd26d4fa" + } + }, + { + "commit": "3cbc8894b04fb1b5405b5e3113c1f276a95fb2b3", + "id": "674e7544bd8749bb3f72d25ceb2cbd10744d00938afe10082d5a8dcef633a563", + "kind": "function", + "action": "modified", + "matchedBy": "qualified-name", + "before": { + "kind": "function", + "syntaxKind": "function_declaration", + "name": "label", + "qualifiedName": "label", + "start": 7, + "end": 76, + "startLine": 1, + "endLine": 1, + "hash": "4864a64d2653c9b4f7eab7f157be2e95a5059d84e11b40901f4768857433d755", + "parameters": 1, + "complexity": 2, + "shape": "9d59733e176ce5ef66bb428d714142a00f4fc487a87165b78cda37c39d28f08e", + "editHash": "a2824929d6bcaf03e70c541e0f18e2dad965eac5a649a2479fea9f70c046b3b4", + "path": "src/normalize.js", + "language": "javascript", + "id": "674e7544bd8749bb3f72d25ceb2cbd10744d00938afe10082d5a8dcef633a563" + }, + "after": { + "kind": "function", + "syntaxKind": "function_declaration", + "name": "label", + "qualifiedName": "label", + "start": 7, + "end": 56, + "startLine": 1, + "endLine": 1, + "hash": "fd4d8d802396881bafa37c362643bf59c24aa78ee85e256eda2e6d203a66d5cb", + "parameters": 1, + "complexity": 2, + "shape": "3c1ac328efa60bfe76d8af60967aff2e512c2a8bc72bab37fb62fef57ffce84c", + "editHash": "86c40b5842642ceb6c73d85c2da75aab5399c3356eb82b70bc2e39f30a2f0b7a", + "path": "src/normalize.js", + "language": "javascript", + "id": "674e7544bd8749bb3f72d25ceb2cbd10744d00938afe10082d5a8dcef633a563" + } + }, + { + "commit": "3cbc8894b04fb1b5405b5e3113c1f276a95fb2b3", + "id": "810d4134c3ed6bd5452285186ecaba7c8ba0e5f3a9630e819ca5236608c28238", + "kind": "function", + "action": "modified", + "matchedBy": "qualified-name", + "before": { + "kind": "function", + "syntaxKind": "function_declaration", + "name": "title", + "qualifiedName": "title", + "start": 84, + "end": 150, + "startLine": 2, + "endLine": 2, + "hash": "1e882961b76a6367981b5d3f3b3a38ee928cdc6a1d874f1f3e0f0094fedfcc41", + "parameters": 1, + "complexity": 2, + "shape": "9d59733e176ce5ef66bb428d714142a00f4fc487a87165b78cda37c39d28f08e", + "editHash": "a2824929d6bcaf03e70c541e0f18e2dad965eac5a649a2479fea9f70c046b3b4", + "path": "src/normalize.js", + "language": "javascript", + "id": "810d4134c3ed6bd5452285186ecaba7c8ba0e5f3a9630e819ca5236608c28238" + }, + "after": { + "kind": "function", + "syntaxKind": "function_declaration", + "name": "title", + "qualifiedName": "title", + "start": 64, + "end": 111, + "startLine": 2, + "endLine": 2, + "hash": "983c05af7c1561a405245a4ae8cbb5a46acefbd257b9acca5fdce08b3d44dfee", + "parameters": 1, + "complexity": 2, + "shape": "3c1ac328efa60bfe76d8af60967aff2e512c2a8bc72bab37fb62fef57ffce84c", + "editHash": "86c40b5842642ceb6c73d85c2da75aab5399c3356eb82b70bc2e39f30a2f0b7a", + "path": "src/normalize.js", + "language": "javascript", + "id": "810d4134c3ed6bd5452285186ecaba7c8ba0e5f3a9630e819ca5236608c28238" + } + }, + { + "commit": "3ef49e932e9c93a8fec52b4519802112685b919e", + "id": "2e9673475d2473eeddd7f12ab30e140ee443ce5c5b02bfcfa771042a2dd82959", + "kind": "file", + "action": "modified", + "matchedBy": "qualified-name", + "before": { + "path": "src/format.js", + "kind": "file", + "name": "src/format.js", + "qualifiedName": "src/format.js", + "hash": "661d795c809f31b55de6a30d5f805a0dac0c4cbb", + "shape": "3ea017c62a718b4203745afe275dba9dcac7af115a0b975816bd5362f0cfd66b", + "language": "javascript", + "startLine": 1, + "complexity": 2, + "id": "2e9673475d2473eeddd7f12ab30e140ee443ce5c5b02bfcfa771042a2dd82959" + }, + "after": { + "path": "src/format.js", + "kind": "file", + "name": "src/format.js", + "qualifiedName": "src/format.js", + "hash": "709a463fd016f5041655a6b36f0d8c3b6c6b22e8", + "shape": "b61a85823dfe8e2cdd0a8ff771768cfc0922a6c55efdf9580e5d597850e47cca", + "language": "javascript", + "startLine": 1, + "complexity": 2, + "id": "2e9673475d2473eeddd7f12ab30e140ee443ce5c5b02bfcfa771042a2dd82959" + } + }, + { + "commit": "3ef49e932e9c93a8fec52b4519802112685b919e", + "id": "0858bc9404191cc57b613bb0b8aec44afb58e32d3c7325f9cb0fb49c2d0a5a83", + "kind": "class", + "action": "modified", + "matchedBy": "qualified-name", + "before": { + "kind": "class", + "syntaxKind": "class_declaration", + "name": "Formatter", + "qualifiedName": "Formatter", + "start": 7, + "end": 66, + "startLine": 1, + "endLine": 1, + "hash": "e833ee1cc71c9fe52dddbd8916d0d4ed6ba11f8da2d3a7d25b976ef2aebd105f", + "parameters": 0, + "complexity": 1, + "shape": "80f71a9a2594fb9d880ac6ca1d1a2e4137040c3515f2cd0385b2268562e6ef62", + "editHash": "80f71a9a2594fb9d880ac6ca1d1a2e4137040c3515f2cd0385b2268562e6ef62", + "path": "src/format.js", + "language": "javascript", + "id": "0858bc9404191cc57b613bb0b8aec44afb58e32d3c7325f9cb0fb49c2d0a5a83" + }, + "after": { + "kind": "class", + "syntaxKind": "class_declaration", + "name": "Formatter", + "qualifiedName": "Formatter", + "start": 7, + "end": 73, + "startLine": 1, + "endLine": 1, + "hash": "18441f134c87788d5cbe27c3f2c8bd9889500596c06c1963590680f1e7eb13bc", + "parameters": 0, + "complexity": 1, + "shape": "c9b6fec5e6096a433f69b87526660b7291e9cbcee02307b8faaf6cd81e4ecbad", + "editHash": "c9b6fec5e6096a433f69b87526660b7291e9cbcee02307b8faaf6cd81e4ecbad", + "path": "src/format.js", + "language": "javascript", + "id": "0858bc9404191cc57b613bb0b8aec44afb58e32d3c7325f9cb0fb49c2d0a5a83" + } + }, + { + "commit": "3ef49e932e9c93a8fec52b4519802112685b919e", + "id": "6552ed8ea0a89c5143d0aa9f18c1892fcf48daa405f456ff761880696a6f0366", + "kind": "function", + "action": "modified", + "matchedBy": "qualified-name", + "before": { + "kind": "function", + "syntaxKind": "method_definition", + "name": "format", + "qualifiedName": "Formatter.format", + "start": 25, + "end": 64, + "startLine": 1, + "endLine": 1, + "hash": "fddd2cdcd8a9b038ddddef4a6d8f85cd2fdde848431db66c5b0bdd992b7b1d28", + "parameters": 1, + "complexity": 1, + "shape": "fbc6fb5ad998926f3793c9f5a733f6d13eba5b9776036a7bf70d7a4186b4d871", + "editHash": "fbc6fb5ad998926f3793c9f5a733f6d13eba5b9776036a7bf70d7a4186b4d871", + "path": "src/format.js", + "language": "javascript", + "id": "6552ed8ea0a89c5143d0aa9f18c1892fcf48daa405f456ff761880696a6f0366" + }, + "after": { + "kind": "function", + "syntaxKind": "method_definition", + "name": "format", + "qualifiedName": "Formatter.format", + "start": 25, + "end": 71, + "startLine": 1, + "endLine": 1, + "hash": "b4719355a82cd13eb401d9935b1396c917b24488828af31a121d699fbb0d513b", + "parameters": 1, + "complexity": 1, + "shape": "919686762fa61443a35c5d86ae3f7cf264fc6f5367dab1e5670ba8c0bb9a0277", + "editHash": "919686762fa61443a35c5d86ae3f7cf264fc6f5367dab1e5670ba8c0bb9a0277", + "path": "src/format.js", + "language": "javascript", + "id": "6552ed8ea0a89c5143d0aa9f18c1892fcf48daa405f456ff761880696a6f0366" + } + }, + { + "commit": "3ef49e932e9c93a8fec52b4519802112685b919e", + "id": "4611d04926ab7eebb45d61deb7731ca9c6813065817cd49792cba6d2dd26d4fa", + "kind": "file", + "action": "modified", + "matchedBy": "qualified-name", + "before": { + "path": "src/normalize.js", + "kind": "file", + "name": "src/normalize.js", + "qualifiedName": "src/normalize.js", + "hash": "f2cfbf52ab2198073a4102354476c3d08b251ad3", + "shape": "6708e3fef21bf308a576f413b3c3eb420ecb6710e298d1eddccd94f1ccc0d7cb", + "language": "javascript", + "startLine": 1, + "complexity": 4, + "id": "4611d04926ab7eebb45d61deb7731ca9c6813065817cd49792cba6d2dd26d4fa" + }, + "after": { + "path": "src/normalize.js", + "kind": "file", + "name": "src/normalize.js", + "qualifiedName": "src/normalize.js", + "hash": "04581b87aaf5e3ec3007443aeb91f1602f1ff16c", + "shape": "06c5a9094cc294c55da10f4879be5da04a87128427828059e57ff2c2188c6716", + "language": "javascript", + "startLine": 1, + "complexity": 5, + "id": "4611d04926ab7eebb45d61deb7731ca9c6813065817cd49792cba6d2dd26d4fa" + } + }, + { + "commit": "3ef49e932e9c93a8fec52b4519802112685b919e", + "id": "44fc61efb8c83a8eb128decdf43fbd431dfcb1a46b7dea9958d6ac1880f620c1", + "kind": "function", + "action": "added", + "after": { + "kind": "function", + "syntaxKind": "function_declaration", + "name": "slug", + "qualifiedName": "slug", + "start": 119, + "end": 171, + "startLine": 3, + "endLine": 3, + "hash": "25942520158e35de7f2482624d1113f624b49f909b5ef7c4ae1e8915efb5ccbf", + "parameters": 1, + "complexity": 1, + "shape": "f49c9c25d61049b2572de08af2c3aed8c7dacc1b57deb4b878a03f1423f90153", + "editHash": "f49c9c25d61049b2572de08af2c3aed8c7dacc1b57deb4b878a03f1423f90153", + "path": "src/normalize.js", + "language": "javascript", + "id": "44fc61efb8c83a8eb128decdf43fbd431dfcb1a46b7dea9958d6ac1880f620c1" + } + }, + { + "commit": "da1be2417d7c3dcd5bac5e065ee92ecee158d60d", + "id": "2e9673475d2473eeddd7f12ab30e140ee443ce5c5b02bfcfa771042a2dd82959", + "kind": "file", + "action": "renamed", + "matchedBy": "exact-content", + "before": { + "path": "src/format.js", + "kind": "file", + "name": "src/format.js", + "qualifiedName": "src/format.js", + "hash": "709a463fd016f5041655a6b36f0d8c3b6c6b22e8", + "shape": "b61a85823dfe8e2cdd0a8ff771768cfc0922a6c55efdf9580e5d597850e47cca", + "language": "javascript", + "startLine": 1, + "complexity": 2, + "id": "2e9673475d2473eeddd7f12ab30e140ee443ce5c5b02bfcfa771042a2dd82959" + }, + "after": { + "path": "src/formatter.js", + "kind": "file", + "name": "src/formatter.js", + "qualifiedName": "src/formatter.js", + "hash": "709a463fd016f5041655a6b36f0d8c3b6c6b22e8", + "shape": "b61a85823dfe8e2cdd0a8ff771768cfc0922a6c55efdf9580e5d597850e47cca", + "language": "javascript", + "startLine": 1, + "complexity": 2, + "id": "2e9673475d2473eeddd7f12ab30e140ee443ce5c5b02bfcfa771042a2dd82959" + } + }, + { + "commit": "da1be2417d7c3dcd5bac5e065ee92ecee158d60d", + "id": "0858bc9404191cc57b613bb0b8aec44afb58e32d3c7325f9cb0fb49c2d0a5a83", + "kind": "class", + "action": "renamed", + "matchedBy": "exact-content", + "before": { + "kind": "class", + "syntaxKind": "class_declaration", + "name": "Formatter", + "qualifiedName": "Formatter", + "start": 7, + "end": 73, + "startLine": 1, + "endLine": 1, + "hash": "18441f134c87788d5cbe27c3f2c8bd9889500596c06c1963590680f1e7eb13bc", + "parameters": 0, + "complexity": 1, + "shape": "c9b6fec5e6096a433f69b87526660b7291e9cbcee02307b8faaf6cd81e4ecbad", + "editHash": "c9b6fec5e6096a433f69b87526660b7291e9cbcee02307b8faaf6cd81e4ecbad", + "path": "src/format.js", + "language": "javascript", + "id": "0858bc9404191cc57b613bb0b8aec44afb58e32d3c7325f9cb0fb49c2d0a5a83" + }, + "after": { + "kind": "class", + "syntaxKind": "class_declaration", + "name": "Formatter", + "qualifiedName": "Formatter", + "start": 7, + "end": 73, + "startLine": 1, + "endLine": 1, + "hash": "18441f134c87788d5cbe27c3f2c8bd9889500596c06c1963590680f1e7eb13bc", + "parameters": 0, + "complexity": 1, + "shape": "c9b6fec5e6096a433f69b87526660b7291e9cbcee02307b8faaf6cd81e4ecbad", + "editHash": "c9b6fec5e6096a433f69b87526660b7291e9cbcee02307b8faaf6cd81e4ecbad", + "path": "src/formatter.js", + "language": "javascript", + "id": "0858bc9404191cc57b613bb0b8aec44afb58e32d3c7325f9cb0fb49c2d0a5a83" + } + }, + { + "commit": "da1be2417d7c3dcd5bac5e065ee92ecee158d60d", + "id": "6552ed8ea0a89c5143d0aa9f18c1892fcf48daa405f456ff761880696a6f0366", + "kind": "function", + "action": "renamed", + "matchedBy": "exact-content", + "before": { + "kind": "function", + "syntaxKind": "method_definition", + "name": "format", + "qualifiedName": "Formatter.format", + "start": 25, + "end": 71, + "startLine": 1, + "endLine": 1, + "hash": "b4719355a82cd13eb401d9935b1396c917b24488828af31a121d699fbb0d513b", + "parameters": 1, + "complexity": 1, + "shape": "919686762fa61443a35c5d86ae3f7cf264fc6f5367dab1e5670ba8c0bb9a0277", + "editHash": "919686762fa61443a35c5d86ae3f7cf264fc6f5367dab1e5670ba8c0bb9a0277", + "path": "src/format.js", + "language": "javascript", + "id": "6552ed8ea0a89c5143d0aa9f18c1892fcf48daa405f456ff761880696a6f0366" + }, + "after": { + "kind": "function", + "syntaxKind": "method_definition", + "name": "format", + "qualifiedName": "Formatter.format", + "start": 25, + "end": 71, + "startLine": 1, + "endLine": 1, + "hash": "b4719355a82cd13eb401d9935b1396c917b24488828af31a121d699fbb0d513b", + "parameters": 1, + "complexity": 1, + "shape": "919686762fa61443a35c5d86ae3f7cf264fc6f5367dab1e5670ba8c0bb9a0277", + "editHash": "919686762fa61443a35c5d86ae3f7cf264fc6f5367dab1e5670ba8c0bb9a0277", + "path": "src/formatter.js", + "language": "javascript", + "id": "6552ed8ea0a89c5143d0aa9f18c1892fcf48daa405f456ff761880696a6f0366" + } + }, + { + "commit": "f5cbf88018970626328fd80ba03eced9047a996f", + "id": "2854958d762638eac243cf2445b6797b409320cf5af34a7c50a4048d781787e4", + "kind": "file", + "action": "modified", + "matchedBy": "qualified-name", + "before": { + "path": "src/metrics.py", + "kind": "file", + "name": "src/metrics.py", + "qualifiedName": "src/metrics.py", + "hash": "b4f062cae06f19f0e8a53d654e0fb0a942bc47a2", + "shape": "40a702ca77ccbab57deebb21116d177e9172835ef3a74b44a075f7fc8ddae95f", + "language": "python", + "startLine": 1, + "complexity": 1, + "id": "2854958d762638eac243cf2445b6797b409320cf5af34a7c50a4048d781787e4" + }, + "after": { + "path": "src/metrics.py", + "kind": "file", + "name": "src/metrics.py", + "qualifiedName": "src/metrics.py", + "hash": "f30e64477774f110b27897339ded07208f657c78", + "shape": "accfceedfb7f30ddf161af1b28a8369ef3c0eb8c879f8849ed261ff83cf498f6", + "language": "python", + "startLine": 1, + "complexity": 1, + "id": "2854958d762638eac243cf2445b6797b409320cf5af34a7c50a4048d781787e4" + } + }, + { + "commit": "f5cbf88018970626328fd80ba03eced9047a996f", + "id": "7047446222010452739430d8642900b0c126dcfb2ab481d44863ddc7bcb5906d", + "kind": "function", + "action": "modified", + "matchedBy": "qualified-name", + "before": { + "kind": "function", + "syntaxKind": "function_definition", + "name": "count", + "qualifiedName": "count", + "start": 0, + "end": 56, + "startLine": 1, + "endLine": 2, + "hash": "b6a59f7167c3a1a4e8e59d7130bc4a4470371d38d2eca1b5ebf04e930583e570", + "parameters": 1, + "complexity": 1, + "shape": "51b00abdde6a212eb7e42daf538c6b815021f6603a3322a58b0d06c223c8c5eb", + "editHash": "b377a8793fffdc8c48b978742c9601b2cecb7ec189809fd10b7e73edb4594c36", + "path": "src/metrics.py", + "language": "python", + "id": "7047446222010452739430d8642900b0c126dcfb2ab481d44863ddc7bcb5906d" + }, + "after": { + "kind": "function", + "syntaxKind": "function_definition", + "name": "count", + "qualifiedName": "count", + "start": 0, + "end": 46, + "startLine": 1, + "endLine": 2, + "hash": "a8ff843e5af620bbc55119414f26c13437fcbf508b1c765652a12be54bb5987d", + "parameters": 1, + "complexity": 1, + "shape": "3fbb3563c2f884c2e23e00b8259374f9ef3ae5603579a0fb0d1cb8a5a6dbe10e", + "editHash": "3fbb3563c2f884c2e23e00b8259374f9ef3ae5603579a0fb0d1cb8a5a6dbe10e", + "path": "src/metrics.py", + "language": "python", + "id": "7047446222010452739430d8642900b0c126dcfb2ab481d44863ddc7bcb5906d" + } + }, + { + "commit": "f5cbf88018970626328fd80ba03eced9047a996f", + "id": "64b8cb400722e86866233227fd7caed00096eebe50677ef738165016e26931ad", + "kind": "file", + "action": "deleted", + "before": { + "path": "src/cache.js", + "kind": "file", + "name": "src/cache.js", + "qualifiedName": "src/cache.js", + "hash": "71be0b7cbe802894b44c8ab946ba7fd7499028c2", + "shape": "a56ffeac7bec40690d10ef61edd5e45ad7ed7dc6cba75525e036d2689d8073fc", + "language": "javascript", + "startLine": 1, + "complexity": 1, + "id": "64b8cb400722e86866233227fd7caed00096eebe50677ef738165016e26931ad" + } + }, + { + "commit": "f5cbf88018970626328fd80ba03eced9047a996f", + "id": "3b05e8b32029b75b73c1e5f0f0a90373b4d42ea473219ab228ddbb9d11405bc2", + "kind": "function", + "action": "deleted", + "before": { + "kind": "function", + "syntaxKind": "function_declaration", + "name": "cached", + "qualifiedName": "cached", + "start": 7, + "end": 47, + "startLine": 1, + "endLine": 1, + "hash": "f5ffba3a64ad97eb13865c33080a529ebe1d4fc08a60d9e7198e8f42709cc3a9", + "parameters": 1, + "complexity": 1, + "shape": "7e3ebe2644d49e4264c514bd660a6a43caebff8cde1a0a418ccdf99b1d60d8d4", + "editHash": "7e3ebe2644d49e4264c514bd660a6a43caebff8cde1a0a418ccdf99b1d60d8d4", + "path": "src/cache.js", + "language": "javascript", + "id": "3b05e8b32029b75b73c1e5f0f0a90373b4d42ea473219ab228ddbb9d11405bc2" + } + } + ], + "current": [ + { + "path": "src/formatter.js", + "kind": "file", + "name": "src/formatter.js", + "qualifiedName": "src/formatter.js", + "hash": "709a463fd016f5041655a6b36f0d8c3b6c6b22e8", + "shape": "b61a85823dfe8e2cdd0a8ff771768cfc0922a6c55efdf9580e5d597850e47cca", + "language": "javascript", + "startLine": 1, + "complexity": 2, + "id": "2e9673475d2473eeddd7f12ab30e140ee443ce5c5b02bfcfa771042a2dd82959" + }, + { + "kind": "class", + "syntaxKind": "class_declaration", + "name": "Formatter", + "qualifiedName": "Formatter", + "start": 7, + "end": 73, + "startLine": 1, + "endLine": 1, + "hash": "18441f134c87788d5cbe27c3f2c8bd9889500596c06c1963590680f1e7eb13bc", + "parameters": 0, + "complexity": 1, + "shape": "c9b6fec5e6096a433f69b87526660b7291e9cbcee02307b8faaf6cd81e4ecbad", + "editHash": "c9b6fec5e6096a433f69b87526660b7291e9cbcee02307b8faaf6cd81e4ecbad", + "path": "src/formatter.js", + "language": "javascript", + "id": "0858bc9404191cc57b613bb0b8aec44afb58e32d3c7325f9cb0fb49c2d0a5a83" + }, + { + "kind": "function", + "syntaxKind": "method_definition", + "name": "format", + "qualifiedName": "Formatter.format", + "start": 25, + "end": 71, + "startLine": 1, + "endLine": 1, + "hash": "b4719355a82cd13eb401d9935b1396c917b24488828af31a121d699fbb0d513b", + "parameters": 1, + "complexity": 1, + "shape": "919686762fa61443a35c5d86ae3f7cf264fc6f5367dab1e5670ba8c0bb9a0277", + "editHash": "919686762fa61443a35c5d86ae3f7cf264fc6f5367dab1e5670ba8c0bb9a0277", + "path": "src/formatter.js", + "language": "javascript", + "id": "6552ed8ea0a89c5143d0aa9f18c1892fcf48daa405f456ff761880696a6f0366" + }, + { + "path": "src/metrics.py", + "kind": "file", + "name": "src/metrics.py", + "qualifiedName": "src/metrics.py", + "hash": "f30e64477774f110b27897339ded07208f657c78", + "shape": "accfceedfb7f30ddf161af1b28a8369ef3c0eb8c879f8849ed261ff83cf498f6", + "language": "python", + "startLine": 1, + "complexity": 1, + "id": "2854958d762638eac243cf2445b6797b409320cf5af34a7c50a4048d781787e4" + }, + { + "kind": "function", + "syntaxKind": "function_definition", + "name": "count", + "qualifiedName": "count", + "start": 0, + "end": 46, + "startLine": 1, + "endLine": 2, + "hash": "a8ff843e5af620bbc55119414f26c13437fcbf508b1c765652a12be54bb5987d", + "parameters": 1, + "complexity": 1, + "shape": "3fbb3563c2f884c2e23e00b8259374f9ef3ae5603579a0fb0d1cb8a5a6dbe10e", + "editHash": "3fbb3563c2f884c2e23e00b8259374f9ef3ae5603579a0fb0d1cb8a5a6dbe10e", + "path": "src/metrics.py", + "language": "python", + "id": "7047446222010452739430d8642900b0c126dcfb2ab481d44863ddc7bcb5906d" + }, + { + "path": "src/normalize.js", + "kind": "file", + "name": "src/normalize.js", + "qualifiedName": "src/normalize.js", + "hash": "04581b87aaf5e3ec3007443aeb91f1602f1ff16c", + "shape": "06c5a9094cc294c55da10f4879be5da04a87128427828059e57ff2c2188c6716", + "language": "javascript", + "startLine": 1, + "complexity": 5, + "id": "4611d04926ab7eebb45d61deb7731ca9c6813065817cd49792cba6d2dd26d4fa" + }, + { + "kind": "function", + "syntaxKind": "function_declaration", + "name": "label", + "qualifiedName": "label", + "start": 7, + "end": 56, + "startLine": 1, + "endLine": 1, + "hash": "fd4d8d802396881bafa37c362643bf59c24aa78ee85e256eda2e6d203a66d5cb", + "parameters": 1, + "complexity": 2, + "shape": "3c1ac328efa60bfe76d8af60967aff2e512c2a8bc72bab37fb62fef57ffce84c", + "editHash": "86c40b5842642ceb6c73d85c2da75aab5399c3356eb82b70bc2e39f30a2f0b7a", + "path": "src/normalize.js", + "language": "javascript", + "id": "674e7544bd8749bb3f72d25ceb2cbd10744d00938afe10082d5a8dcef633a563" + }, + { + "kind": "function", + "syntaxKind": "function_declaration", + "name": "title", + "qualifiedName": "title", + "start": 64, + "end": 111, + "startLine": 2, + "endLine": 2, + "hash": "983c05af7c1561a405245a4ae8cbb5a46acefbd257b9acca5fdce08b3d44dfee", + "parameters": 1, + "complexity": 2, + "shape": "3c1ac328efa60bfe76d8af60967aff2e512c2a8bc72bab37fb62fef57ffce84c", + "editHash": "86c40b5842642ceb6c73d85c2da75aab5399c3356eb82b70bc2e39f30a2f0b7a", + "path": "src/normalize.js", + "language": "javascript", + "id": "810d4134c3ed6bd5452285186ecaba7c8ba0e5f3a9630e819ca5236608c28238" + }, + { + "kind": "function", + "syntaxKind": "function_declaration", + "name": "slug", + "qualifiedName": "slug", + "start": 119, + "end": 171, + "startLine": 3, + "endLine": 3, + "hash": "25942520158e35de7f2482624d1113f624b49f909b5ef7c4ae1e8915efb5ccbf", + "parameters": 1, + "complexity": 1, + "shape": "f49c9c25d61049b2572de08af2c3aed8c7dacc1b57deb4b878a03f1423f90153", + "editHash": "f49c9c25d61049b2572de08af2c3aed8c7dacc1b57deb4b878a03f1423f90153", + "path": "src/normalize.js", + "language": "javascript", + "id": "44fc61efb8c83a8eb128decdf43fbd431dfcb1a46b7dea9958d6ac1880f620c1" + } + ], + "hotspots": [ + { + "path": "src/metrics.py", + "changes": 3 + }, + { + "path": "src/normalize.js", + "changes": 3 + }, + { + "path": "src/cache.js", + "changes": 2 + }, + { + "path": "src/format.js", + "changes": 2 + }, + { + "path": "src/formatter.js", + "changes": 1 + } + ], + "coupling": [ + { + "files": ["src/cache.js", "src/metrics.py"], + "commits": 2 + }, + { + "files": ["src/format.js", "src/normalize.js"], + "commits": 2 + }, + { + "files": ["src/metrics.py", "src/normalize.js"], + "commits": 2 + } + ], + "repeatedPatterns": [ + { + "id": "3b27131909625840a94af71c787127b18aeada0df023e3227f08ba023b6f4340", + "kind": "function", + "beforeShape": "9d59733e176ce5ef66bb428d714142a00f4fc487a87165b78cda37c39d28f08e", + "afterShape": "3c1ac328efa60bfe76d8af60967aff2e512c2a8bc72bab37fb62fef57ffce84c", + "count": 2, + "evidence": [ + { + "commit": "3cbc8894b04fb1b5405b5e3113c1f276a95fb2b3", + "path": "src/normalize.js", + "id": "674e7544bd8749bb3f72d25ceb2cbd10744d00938afe10082d5a8dcef633a563" + }, + { + "commit": "3cbc8894b04fb1b5405b5e3113c1f276a95fb2b3", + "path": "src/normalize.js", + "id": "810d4134c3ed6bd5452285186ecaba7c8ba0e5f3a9630e819ca5236608c28238" + } + ], + "complexityDelta": 0 + } + ], + "suggestions": [ + { + "patternId": "3b27131909625840a94af71c787127b18aeada0df023e3227f08ba023b6f4340", + "confidence": "observational", + "message": "Repeated structural edits may indicate a shared abstraction; review the linked transformations before applying a guideline", + "evidence": [ + { + "commit": "3cbc8894b04fb1b5405b5e3113c1f276a95fb2b3", + "path": "src/normalize.js", + "id": "674e7544bd8749bb3f72d25ceb2cbd10744d00938afe10082d5a8dcef633a563" + }, + { + "commit": "3cbc8894b04fb1b5405b5e3113c1f276a95fb2b3", + "path": "src/normalize.js", + "id": "810d4134c3ed6bd5452285186ecaba7c8ba0e5f3a9630e819ca5236608c28238" + } + ] + } + ], + "limitations": [ + "First-parent history only; merge side branches are not traversed", + "Renames use unique names, content or structure; ambiguous matches become deletion/addition", + "Pattern frequency is evidence, not proof that a change improves behavior", + "Coupling omits commits changing more than 100 source files" + ] +} diff --git a/examples/universal-app/evolution/styles.css b/examples/universal-app/evolution/styles.css new file mode 100644 index 0000000..50200a4 --- /dev/null +++ b/examples/universal-app/evolution/styles.css @@ -0,0 +1,513 @@ +:root { + color-scheme: light; + --ink: #162a22; + --muted: #526760; + --accent: #24654d; + --paper: #f5f6f1; + --line: #dce3d9; + --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; + font-family: + 'Inter', + -apple-system, + BlinkMacSystemFont, + 'Segoe UI', + sans-serif; + background: var(--paper); + color: var(--ink); +} + +* { + box-sizing: border-box; +} + +body { + margin: 0; +} + +a { + color: var(--accent); +} + +a:focus-visible, +button:focus-visible, +select:focus-visible, +summary:focus-visible { + outline: 2px solid #226347; + outline-offset: 4px; +} + +.shell { + width: min(1180px, calc(100% - 72px)); + margin-inline: auto; +} + +.top { + background: #153127; + color: #f4fcf6; +} + +.top-inner { + display: flex; + align-items: center; + justify-content: space-between; + min-height: 65px; + gap: 1rem; +} + +.top a { + color: inherit; + text-decoration: none; +} + +.top a:hover { + text-decoration: underline; +} + +.top a:focus-visible { + outline-color: #a8dbc1; +} + +.brand { + display: inline-flex; + align-items: center; + gap: 0.65rem; + font-weight: 700; + letter-spacing: -0.02em; +} + +.brand-mark { + display: grid; + width: 2rem; + height: 2rem; + place-items: center; + border: 1px solid #54816c; + border-radius: 8px; + background: #244839; + color: #c8efda; + font: bold 1.2rem var(--mono); +} + +.source-link { + color: #e0eee4; + font-size: 0.86rem; +} + +.intro { + padding: 50px 0 32px; +} + +h1, +h2, +p { + margin: 0; +} + +h1 { + font-size: clamp(2.7rem, 6vw, 4.7rem); + line-height: 1; + letter-spacing: -0.075em; +} + +.intro p { + margin-top: 15px; + color: var(--muted); + line-height: 1.5; +} + +.eyebrow { + color: var(--accent); + font: 700 0.67rem/1.25 var(--mono); + letter-spacing: 0.09em; +} + +.report-toolbar, +.panel, +.metric { + border: 1px solid var(--line); + border-radius: 11px; + background: #fff; +} + +.report-toolbar { + display: flex; + align-items: center; + justify-content: space-between; + min-height: 71px; + margin-bottom: 12px; + padding: 12px 17px; + gap: 12px; +} + +.report-toolbar strong { + display: block; + margin-top: 5px; + overflow-wrap: anywhere; +} + +#report-actions ui-stack { + gap: 8px; + flex-wrap: wrap; +} + +#report-actions ui-button > button { + min-height: 36px; + border: 1px solid #c6d6ce; + border-radius: 6px; + padding: 6px 11px; + color: var(--ink); + background: #fff; + font-family: inherit; + font-size: 0.83rem; + font-weight: 600; + white-space: nowrap; + cursor: pointer; +} + +#report-actions ui-button[variant='filled'] > button { + color: white; + border-color: #235943; + background: #235943; +} + +#report-actions ui-button > button:hover { + border-color: #6b9380; + filter: brightness(0.95); +} + +.notice { + margin: 0 0 12px; + padding: 9px 14px; + border-radius: 6px; + background: #fff0d0; + color: #624719; +} + +.metrics { + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: 12px; + margin: 0 0 14px; +} + +.metric { + padding: 12px 16px; +} + +.metric dt { + font-size: 0.83rem; + color: var(--muted); +} + +.metric dd { + margin: 3px 0 0; + font-size: 1.92rem; + font-weight: 720; + letter-spacing: -0.055em; +} + +.columns { + display: grid; + grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); + gap: 14px; + align-items: start; +} + +.side { + display: grid; + gap: 14px; + min-width: 0; +} + +.panel { + padding: 16px 17px; +} + +.panel-heading { + display: flex; + justify-content: space-between; + align-items: center; + gap: 8px; + margin-bottom: 14px; +} + +.panel h2 { + margin-top: 3px; + font-size: 1.36rem; + letter-spacing: -0.045em; +} + +.filter { + display: flex; + align-items: center; + gap: 7px; + color: var(--muted); + font-size: 0.77rem; +} + +.filter select { + padding: 6px 8px; + border: 1px solid var(--line); + border-radius: 6px; + background: #fafbf9; + color: var(--ink); + font: inherit; +} + +.timeline { + padding-left: 12px; + border-left: 1px solid #d9e5db; +} + +.commit { + position: relative; + border-bottom: 1px solid #e7ece7; +} + +.commit:last-child { + border-bottom: 0; +} + +.commit-summary { + display: flex; + align-items: center; + gap: 9px; + min-height: 52px; + cursor: pointer; + list-style: none; +} + +.commit-summary::-webkit-details-marker { + display: none; +} + +.commit-summary::before { + position: absolute; + left: -17px; + width: 8px; + height: 8px; + border-radius: 50%; + border: 1px solid #70a38a; + background: #fff; + content: ''; +} + +.commit[open] .commit-summary::before { + background: #34775a; + border-color: #34775a; +} + +.commit-summary::after { + content: '+'; + width: 15px; + color: var(--accent); + text-align: center; +} + +.commit[open] .commit-summary::after { + content: '−'; +} + +.commit-copy { + display: grid; + flex: 1; + min-width: 0; + gap: 4px; +} + +.commit-copy strong { + font-size: 0.9rem; + overflow-wrap: anywhere; +} + +.commit-copy small { + color: var(--muted); + font: 0.71rem var(--mono); +} + +.count { + border-radius: 18px; + padding: 3px 7px; + background: #edf4ee; + color: #2a6248; + font: 700 0.75rem var(--mono); +} + +.changes { + display: grid; + gap: 4px; + margin: 0 0 9px; + padding: 7px 9px; + border-radius: 6px; + background: #f5f8f5; + list-style: none; +} + +.change { + display: flex; + align-items: baseline; + gap: 7px; + min-width: 0; + padding: 3px 0; +} + +.change-action { + min-width: 62px; + color: #2c634c; + font-size: 0.73rem; + font-weight: 660; +} + +.change-action.deleted { + color: #8b4736; +} + +.change-action.renamed { + color: #48568d; +} + +.change-path, +.hotspot code, +.pair code { + font: 0.74rem/1.35 var(--mono); + overflow-wrap: anywhere; +} + +.hotspot { + margin-bottom: 10px; +} + +.hotspot:last-child { + margin-bottom: 0; +} + +.hotspot-row, +.coupling-row { + display: flex; + align-items: center; + justify-content: space-between; + gap: 8px; +} + +.hotspot-row span { + color: var(--muted); + font: 0.75rem var(--mono); +} + +.bar { + height: 4px; + margin-top: 5px; + border-radius: 4px; + background: #edf2ed; +} + +.bar span { + display: block; + height: 100%; + border-radius: inherit; + background: #629d7f; +} + +.coupling-row { + min-height: 39px; + border-top: 1px solid #e7ece7; + padding: 4px 0; +} + +.pair { + display: flex; + align-items: baseline; + flex-wrap: wrap; + gap: 3px 5px; +} + +.pair code + code::before { + margin-right: 5px; + color: var(--accent); + content: '↔'; +} + +.patterns { + margin-top: 14px; +} + +.pattern { + border-top: 1px solid #e7ece7; + padding: 12px 0 5px; +} + +.pattern p, +.empty { + margin-top: 5px; + color: var(--muted); + font-size: 0.86rem; + line-height: 1.5; +} + +.evidence-actions { + display: flex; + flex-wrap: wrap; + gap: 6px; + margin-top: 9px; +} + +.evidence-button { + border: 1px solid var(--line); + border-radius: 5px; + padding: 4px 6px; + background: transparent; + color: var(--accent); + font: 0.74rem var(--mono); + overflow-wrap: anywhere; + text-align: left; + cursor: pointer; +} + +.evidence-button:hover { + text-decoration: underline; +} + +.limits, +footer { + margin-block: 18px; + color: var(--muted); + font-size: 0.84rem; + line-height: 1.55; +} + +.limits summary { + color: var(--ink); + cursor: pointer; +} + +@media (max-width: 760px) { + .shell { + width: calc(100% - 28px); + } + + .intro { + padding-top: 33px; + } + + .columns { + grid-template-columns: minmax(0, 1fr); + } + + .metrics { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } + + .filter span { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip-path: inset(50%); + } +} + +@media (max-width: 370px) { + .report-toolbar { + align-items: flex-start; + flex-direction: column; + } +} diff --git a/examples/universal-app/package-lock.json b/examples/universal-app/package-lock.json index 1db5b1b..5b7f090 100644 --- a/examples/universal-app/package-lock.json +++ b/examples/universal-app/package-lock.json @@ -16,9 +16,11 @@ }, "devDependencies": { "@capacitor/cli": "^7.4.4", + "@link-foundation/ui-dom": "0.0.0", "@vitejs/plugin-react": "^4.7.0", "electron": "^43.4.0", "electron-builder": "^26.15.3", + "lino-i18n": "0.5.0", "vite": "^6.4.1" } }, @@ -1135,6 +1137,30 @@ "node": ">=18" } }, + "node_modules/@formatjs/fast-memoize": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-3.1.7.tgz", + "integrity": "sha512-zXfhLpvA6T7+efdt9JLbBwZ00tT7NsBMDVnDu8rpHeNNv8KfRZAMo2gkG0k9lK/Nzc//3kJ9pImsfuJxk3KhUA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@formatjs/icu-messageformat-parser": { + "version": "3.5.23", + "resolved": "https://registry.npmjs.org/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-3.5.23.tgz", + "integrity": "sha512-iB1fYfhtSGd8uH9A8b1m01Ujcv6QtQnJasefP3jPApmz72L/zNipzf3BdoinTMd1xuviVChjUJWL60iTwjUQ+w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@formatjs/icu-skeleton-parser": "2.1.13" + } + }, + "node_modules/@formatjs/icu-skeleton-parser": { + "version": "2.1.13", + "resolved": "https://registry.npmjs.org/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-2.1.13.tgz", + "integrity": "sha512-IdAJ9NrHn7AF0zqncD9UpxQozTYyJtbwwrZnJMEKVxTcOOXtVkUb2XYTpNOGTAv58NCsk0rjRB9G+i2SvBmGAQ==", + "dev": true, + "license": "MIT" + }, "node_modules/@ionic/cli-framework-output": { "version": "2.2.8", "resolved": "https://registry.npmjs.org/@ionic/cli-framework-output/-/cli-framework-output-2.2.8.tgz", @@ -1354,9 +1380,9 @@ } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", - "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", "dev": true, "license": "MIT" }, @@ -1371,6 +1397,95 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@link-foundation/ui-core": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/@link-foundation/ui-core/-/ui-core-0.0.0.tgz", + "integrity": "sha512-ePkwDIdsnzsJYZbLNDSrXnXeYp1sFQa2sMZbt1SM8tCAnwueQ7oWy/xLjAA+0RB0I4Z7zqj5nPrdnXX+trp7YQ==", + "dev": true, + "license": "Unlicense", + "dependencies": { + "links-notation": "^0.27.1" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@link-foundation/ui-dom": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/@link-foundation/ui-dom/-/ui-dom-0.0.0.tgz", + "integrity": "sha512-jNkWP9+vG77+BlcynuWAd4VxJ3AKaAeKhvyvMoMvcUV09l5nYu71wMbr5+44skBuUiVYzA2LC7l9Bn/8tz5gaA==", + "dev": true, + "license": "Unlicense", + "dependencies": { + "@link-foundation/ui-core": "^0.0.0", + "@link-foundation/ui-store": "^0.0.0", + "@link-foundation/ui-style": "^0.0.0", + "@link-foundation/ui-tokens": "^0.0.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@link-foundation/ui-store": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/@link-foundation/ui-store/-/ui-store-0.0.0.tgz", + "integrity": "sha512-l2liPI6saFG0WbfCWu2KDXgNrw4Qgl+N0k7Xofb30Inra/FOoiUSnO+RKw4MhtsNnDO4Q7jtm/jUMFkXsEr6VQ==", + "dev": true, + "license": "Unlicense", + "dependencies": { + "@link-foundation/ui-core": "^0.0.0" + }, + "engines": { + "node": ">=20" + }, + "peerDependencies": { + "doublets-web": "^0.1.3" + }, + "peerDependenciesMeta": { + "doublets-web": { + "optional": true + } + } + }, + "node_modules/@link-foundation/ui-style": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/@link-foundation/ui-style/-/ui-style-0.0.0.tgz", + "integrity": "sha512-PzKs2qHKwn2m1fgJou0B49wUN+XE9TMKD3rkBlTKrboZ/6jjxNDCsDMj6dvAocX7z0XwKRpCXd/Hjy0uXGAvOw==", + "dev": true, + "license": "Unlicense", + "dependencies": { + "@link-foundation/ui-core": "^0.0.0", + "@link-foundation/ui-tokens": "^0.0.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@link-foundation/ui-tokens": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/@link-foundation/ui-tokens/-/ui-tokens-0.0.0.tgz", + "integrity": "sha512-yItwzIhNQiZLIxkzTYTMNdPh1KEsuHQf9Y4ZywoTmDE6glgKeF9Ff8MA4vGXQ3MP3jQRwIVmK+xWtumlv3TrXA==", + "dev": true, + "license": "Unlicense", + "dependencies": { + "@link-foundation/ui-core": "^0.0.0", + "@link-foundation/ui-style": "^0.0.0" + }, + "bin": { + "link-ui-tokens": "bin/cli.js" + }, + "engines": { + "node": ">=20" + }, + "peerDependencies": { + "style-dictionary": ">=4.0.0" + }, + "peerDependenciesMeta": { + "style-dictionary": { + "optional": true + } + } + }, "node_modules/@malept/cross-spawn-promise": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@malept/cross-spawn-promise/-/cross-spawn-promise-2.0.0.tgz", @@ -2008,6 +2123,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/jsesc": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@types/jsesc/-/jsesc-2.5.1.tgz", + "integrity": "sha512-9VN+6yxLOPLOav+7PwjZbxiID2bVaeq0ED4qSQmdQTdjnXJSaCVKTR58t15oqH1H5t8Ng2ZX1SabJVoN9Q34bw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/keyv": { "version": "3.1.4", "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz", @@ -3756,6 +3878,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/getenv": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/getenv/-/getenv-2.0.0.tgz", + "integrity": "sha512-VilgtJj/ALgGY77fiLam5iD336eSWi96Q15JSAG1zi8NRBysm3LXKdGnHb4m5cuyxvOLQQKWpBZAT6ni4FI2iQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/glob": { "version": "14.0.4", "resolved": "https://registry.npmjs.org/glob/-/glob-14.0.4.tgz", @@ -4027,6 +4159,17 @@ "dev": true, "license": "ISC" }, + "node_modules/intl-messageformat": { + "version": "12.2.0", + "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-12.2.0.tgz", + "integrity": "sha512-zFzW80iYSSJm4V185g3ItJQ96lBZ2RDO8O8qmRiPAAVKYXJeHfDQN2ITdtLlV+CjSi9Lo7zVW9xGt9CPCx7J6A==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@formatjs/fast-memoize": "3.1.7", + "@formatjs/icu-messageformat-parser": "3.5.23" + } + }, "node_modules/is-docker": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", @@ -4230,6 +4373,320 @@ "dev": true, "license": "MIT" }, + "node_modules/links-notation": { + "version": "0.27.1", + "resolved": "https://registry.npmjs.org/links-notation/-/links-notation-0.27.1.tgz", + "integrity": "sha512-fTmzw/t3AHRTYhR6Ry8hCHzf0eroYGEH/8JsC7FALyGtWxQE0cHdp4YuZnMXqKqmcpMWWiTWoQiIo1D5AvsbQA==", + "dev": true, + "license": "Unlicense" + }, + "node_modules/lino-arguments": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/lino-arguments/-/lino-arguments-0.3.0.tgz", + "integrity": "sha512-46RbNaq0kpDxjyzBqhiCjPypHy9tuL0ITC9LgEolFH65PKtwl0/kRxryleG+5HnqS1JLnUUypZ2GoHWhLWH/PQ==", + "dev": true, + "license": "Unlicense", + "dependencies": { + "getenv": "^2.0.0", + "links-notation": "^0.11.2", + "lino-env": "^0.2.6", + "yargs": "^17.7.2" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@dotenvx/dotenvx": "^1.0.0" + }, + "peerDependenciesMeta": { + "@dotenvx/dotenvx": { + "optional": true + } + } + }, + "node_modules/lino-arguments/node_modules/links-notation": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/links-notation/-/links-notation-0.11.2.tgz", + "integrity": "sha512-VPyELWBXpaCCiNPVeZhMbG7RuvOQR51nhqELK+s/rbSzKYhSs+tyiSOdQ7z8I7Kh3PLABF3bZETtWSFwx3vFfg==", + "dev": true, + "license": "Unlicense" + }, + "node_modules/lino-env": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/lino-env/-/lino-env-0.2.8.tgz", + "integrity": "sha512-j9JcPo8LWCSlWCO7B1SSL3OlpRc/bGaR/OYnH22DTiANaMaLWan7ebRIo2Pwaw/apcIzdV+UD5EXamdapbn6kA==", + "dev": true, + "license": "Unlicense", + "dependencies": { + "links-notation": "^0.11.2" + } + }, + "node_modules/lino-env/node_modules/links-notation": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/links-notation/-/links-notation-0.11.2.tgz", + "integrity": "sha512-VPyELWBXpaCCiNPVeZhMbG7RuvOQR51nhqELK+s/rbSzKYhSs+tyiSOdQ7z8I7Kh3PLABF3bZETtWSFwx3vFfg==", + "dev": true, + "license": "Unlicense" + }, + "node_modules/lino-i18n": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/lino-i18n/-/lino-i18n-0.5.0.tgz", + "integrity": "sha512-WNfTmvkaEvyZsR8Uoj6ur3+wm7MvI/cX6J0MIFfit3vm0SM4czbcR3qEMS4fXeSf040LBDG9IeGMArBzRLMsaQ==", + "dev": true, + "license": "Unlicense", + "dependencies": { + "@babel/generator": "^8.0.6", + "@babel/parser": "^8.0.7", + "@babel/traverse": "^8.0.7", + "@babel/types": "^8.0.6", + "@formatjs/icu-messageformat-parser": "^3.5.21", + "intl-messageformat": "^12.1.3", + "links-notation": "^0.23.0", + "lino-arguments": "^0.3.0", + "lino-objects-codec": "^0.9.0" + }, + "bin": { + "lino-i18n": "bin/lino-i18n.js" + }, + "engines": { + "node": ">=22.11.0" + }, + "peerDependencies": { + "@generaltranslation/supported-locales": ">=2.1.41 <3", + "@rrweb/record": ">=2.1 <3", + "@rrweb/replay": ">=2.1 <3", + "@rrweb/types": ">=2.1 <3", + "@tanstack/react-router": ">=1.170 <2", + "@tanstack/react-start": ">=1.168 <2", + "@vue/compiler-sfc": ">=3.5 <4", + "eslint": ">=9 <11", + "generaltranslation": ">=9.5.5 <10", + "gt-remark": ">=1.0.12 <2", + "gt-rrweb": ">=0.2 <0.3", + "next": ">=16 <17", + "react": ">=18.0.0", + "react-dom": ">=18", + "vue": ">=3.5 <4" + }, + "peerDependenciesMeta": { + "@generaltranslation/supported-locales": { + "optional": true + }, + "@rrweb/record": { + "optional": true + }, + "@rrweb/replay": { + "optional": true + }, + "@rrweb/types": { + "optional": true + }, + "@tanstack/react-router": { + "optional": true + }, + "@tanstack/react-start": { + "optional": true + }, + "@vue/compiler-sfc": { + "optional": true + }, + "eslint": { + "optional": true + }, + "generaltranslation": { + "optional": true + }, + "gt-remark": { + "optional": true + }, + "gt-rrweb": { + "optional": true + }, + "next": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + }, + "vue": { + "optional": true + } + } + }, + "node_modules/lino-i18n/node_modules/@babel/code-frame": { + "version": "8.0.6", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-8.0.6.tgz", + "integrity": "sha512-uMHhvmDmwFiLuiozaoRYTZHqMFuu3fem/X9JY78lohAuLoh8LSGGC8JqUzo2cVuBsBxkjMZNk56CE7ock8Xxkw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^8.0.6", + "js-tokens": "^10.0.0" + }, + "engines": { + "node": "^22.18.0 || >=24.11.0" + } + }, + "node_modules/lino-i18n/node_modules/@babel/generator": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-8.1.2.tgz", + "integrity": "sha512-tAjURz1NaCZGtdG3hB6gjaIeTVo4XFD4TnbqIEneADVJ1Jpt2NxhPBAjbhius8ulUG5b/P2b56ec1ClJZa2aBQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^8.1.2", + "@babel/types": "^8.1.2", + "@jridgewell/gen-mapping": "0.4.0-beta.0", + "@jridgewell/trace-mapping": "^0.3.31", + "@types/jsesc": "^2.5.0", + "jsesc": "^3.0.2" + }, + "engines": { + "node": "^22.18.0 || >=24.11.0" + } + }, + "node_modules/lino-i18n/node_modules/@babel/helper-globals": { + "version": "8.0.6", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-8.0.6.tgz", + "integrity": "sha512-OdnA/N52LhzFpeUuVz5YGuSWjc7TPHiFmVYZbPlSgExocO2GwbxVpSni9MVs5wwW+wZ4kPuwBEBN9pIPDYz1mA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^22.18.0 || >=24.11.0" + } + }, + "node_modules/lino-i18n/node_modules/@babel/helper-string-parser": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-8.1.2.tgz", + "integrity": "sha512-TRz5Z0MgfIfWqwEIq/pCpUpEXQxUt2Ig2ZbxG3SdmhSbHMAFFYGOix0kI4JLV371/TA+qWnQ4xWHPWjojkyRFA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^22.18.0 || >=24.11.0" + } + }, + "node_modules/lino-i18n/node_modules/@babel/helper-validator-identifier": { + "version": "8.0.6", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-8.0.6.tgz", + "integrity": "sha512-HYx0YmuchRxRSpnjvcNffnPS8DCauKNmnumIuHG3jnQAVewRA7kfJGwF13ayEpSZs7s4R/oBH4eppuXcAQd5JQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^22.18.0 || >=24.11.0" + } + }, + "node_modules/lino-i18n/node_modules/@babel/parser": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-8.1.2.tgz", + "integrity": "sha512-ZDKU7vaX0VORd2BhaO+3FKr/30TKjbUy3SMZcydiPngnAb+MesgUoh5SJcE5EwEyBj14M5J6fK56GuBqvYmOpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^8.1.2" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": "^22.18.0 || >=24.11.0" + } + }, + "node_modules/lino-i18n/node_modules/@babel/template": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-8.1.2.tgz", + "integrity": "sha512-9B3FA5HZWK7rTJ7nU2F03qAc/t80O/WB5YQ7NKYdvmMwpq7EUyN04APNQWpkqwSqWtOsuwR0jMSRYLFoAd1m9A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^8.0.6", + "@babel/parser": "^8.1.2", + "@babel/types": "^8.1.2" + }, + "engines": { + "node": "^22.18.0 || >=24.11.0" + } + }, + "node_modules/lino-i18n/node_modules/@babel/traverse": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-8.1.2.tgz", + "integrity": "sha512-J8OoydypQO6HGgRYiiHPMj0iBfz2XpSm5hkmd0+OEHWgQFzYL8TEvYq2y4Gu8vxRCa7g06BilFZ0Imiye5jzzg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^8.0.6", + "@babel/generator": "^8.1.2", + "@babel/helper-globals": "^8.0.6", + "@babel/parser": "^8.1.2", + "@babel/template": "^8.1.2", + "@babel/types": "^8.1.2", + "obug": "^3.0.0" + }, + "engines": { + "node": "^22.18.0 || >=24.11.0" + } + }, + "node_modules/lino-i18n/node_modules/@babel/types": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-8.1.2.tgz", + "integrity": "sha512-uXt6qt2f5G61jZwNIzK1RKu7l5Xjt1VXtPPOGuVveha9fxbx0QM94U1kM4pFZKTRLjWK+X8vmwjwbIemJjiQTA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^8.1.2", + "@babel/helper-validator-identifier": "^8.0.6" + }, + "engines": { + "node": "^22.18.0 || >=24.11.0" + } + }, + "node_modules/lino-i18n/node_modules/@jridgewell/gen-mapping": { + "version": "0.4.0-beta.0", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.4.0-beta.0.tgz", + "integrity": "sha512-JdGNkbE4GlNPYQhM0L95fBQr7ctLZJ276QXQLTad4t1oSdnnCI3fDq9DW3BqYAWv8Wc3+HS+4Gsii1oPMCfz1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.6.0-beta.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/lino-i18n/node_modules/js-tokens": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-10.0.0.tgz", + "integrity": "sha512-lM/UBzQmfJRo9ABXbPWemivdCW8V2G8FHaHdypQaIy523snUjog0W71ayWXTjiR+ixeMyVHN2XcpnTd/liPg/Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/lino-i18n/node_modules/links-notation": { + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/links-notation/-/links-notation-0.23.0.tgz", + "integrity": "sha512-g9S4nnJc9xjxbaHL8W1tG5KV+B2wioUzd7rXrJ1IOpY/G7F0fQxy3cVVakqKPp6D9h3vALl2LPFSekp7kbcONg==", + "dev": true, + "license": "Unlicense" + }, + "node_modules/lino-objects-codec": { + "version": "0.9.6", + "resolved": "https://registry.npmjs.org/lino-objects-codec/-/lino-objects-codec-0.9.6.tgz", + "integrity": "sha512-KyZX1jkGQlmyN/8lwuUBhmZFXW0c7SR43qJaAzTiMG+rMhxXBMq4fpr7nIlCe5HiuP1eKCZ+k+5ax19KbPzrAA==", + "dev": true, + "license": "Unlicense", + "dependencies": { + "links-notation": "^0.31.3" + }, + "engines": { + "node": ">=22.11.0" + } + }, + "node_modules/lino-objects-codec/node_modules/links-notation": { + "version": "0.31.6", + "resolved": "https://registry.npmjs.org/links-notation/-/links-notation-0.31.6.tgz", + "integrity": "sha512-2T+JRHelBU5GGGgKZsF2r9ZdVKQHa3cuKrCYISmT0wP7xn+WP25S8gOc/PLJJDYwyyn+/xktFwpr2vF4qSw2Tg==", + "dev": true, + "license": "Unlicense" + }, "node_modules/lodash": { "version": "4.18.1", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", @@ -4579,6 +5036,20 @@ "node": ">= 0.4" } }, + "node_modules/obug": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/obug/-/obug-3.0.0.tgz", + "integrity": "sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -4706,6 +5177,20 @@ "dev": true, "license": "ISC" }, + "node_modules/picomatch": { + "name": "@ryotsu/picomatch", + "version": "4.0.7-a", + "resolved": "https://registry.npmjs.org/@ryotsu/picomatch/-/picomatch-4.0.7-a.tgz", + "integrity": "sha512-JroBFEmaejC7szGSfqOhF1QZHLKvX2wTA1+fWyfkpy3BjzdQKNPLKa2FtgeKVUDy5/UPUNkXEeCHJ5ZRBMLTVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/pkijs": { "version": "3.4.1", "resolved": "https://registry.npmjs.org/pkijs/-/pkijs-3.4.1.tgz", @@ -5538,19 +6023,6 @@ } } }, - "node_modules/tinyglobby/node_modules/picomatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", - "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/tmp": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.7.tgz", @@ -5816,19 +6288,6 @@ } } }, - "node_modules/vite/node_modules/picomatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", - "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/webcrypto-core": { "version": "1.9.2", "resolved": "https://registry.npmjs.org/webcrypto-core/-/webcrypto-core-1.9.2.tgz", diff --git a/examples/universal-app/package.json b/examples/universal-app/package.json index 9e6443c..43aad26 100644 --- a/examples/universal-app/package.json +++ b/examples/universal-app/package.json @@ -37,9 +37,11 @@ }, "devDependencies": { "@capacitor/cli": "^7.4.4", + "@link-foundation/ui-dom": "0.0.0", "@vitejs/plugin-react": "^4.7.0", "electron": "^43.4.0", "electron-builder": "^26.15.3", + "lino-i18n": "0.5.0", "vite": "^6.4.1" }, "build": { @@ -76,6 +78,7 @@ "rimraf": "file:../../compat/temp-rimraf" }, "minimatch@>=7 <11": "^11.0.4", - "glob@>=9 <=14.0.1": "^14.0.2" + "glob@>=9 <=14.0.1": "^14.0.2", + "picomatch": "npm:@ryotsu/picomatch@4.0.7-a" } } diff --git a/examples/universal-app/vite.config.js b/examples/universal-app/vite.config.js index 6782d92..e291002 100644 --- a/examples/universal-app/vite.config.js +++ b/examples/universal-app/vite.config.js @@ -1,5 +1,6 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; +import { fileURLToPath, URL } from 'node:url'; function resolveBasePath() { if (process.env.GITHUB_PAGES !== 'true') { @@ -16,6 +17,14 @@ export default defineConfig({ build: { outDir: 'dist', emptyOutDir: true, + rollupOptions: { + input: { + app: fileURLToPath(new URL('./index.html', import.meta.url)), + evolution: fileURLToPath( + new URL('./evolution/index.html', import.meta.url) + ), + }, + }, }, server: { fs: { diff --git a/package-lock.json b/package-lock.json index 81c8b9f..ff8a9ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,21 @@ { - "name": "@link-foundation/example-package-name", + "name": "@link-foundation/code-evolution", "version": "0.11.31", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@link-foundation/example-package-name", + "name": "@link-foundation/code-evolution", "version": "0.11.31", "license": "Unlicense", + "dependencies": { + "lino-arguments": "0.4.0", + "tree-sitter-wasms": "0.1.13", + "web-tree-sitter": "0.20.8", + "web-tree-sitter-bash-runtime": "npm:web-tree-sitter@0.24.7" + }, "bin": { + "code-evolution": "bin/code-evolution.js", "example-package-name": "bin/example-package-name.js" }, "devDependencies": { @@ -20,7 +27,6 @@ "eslint-plugin-prettier": "^5.5.4", "husky": "^9.1.7", "jscpd": "^5.4.0", - "lino-arguments": "0.4.0", "lint-staged": "^16.4.0", "prettier": "^3.6.2", "test-anywhere": "^0.8.48", @@ -971,7 +977,6 @@ "version": "6.4.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz", "integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==", - "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -1064,7 +1069,6 @@ "version": "9.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz", "integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==", - "dev": true, "license": "ISC", "dependencies": { "string-width": "^7.2.0", @@ -1079,7 +1083,6 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "dev": true, "license": "MIT", "dependencies": { "emoji-regex": "^10.3.0", @@ -1179,7 +1182,6 @@ "version": "10.6.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", - "dev": true, "license": "MIT" }, "node_modules/environment": { @@ -1199,7 +1201,6 @@ "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", - "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -1641,7 +1642,6 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true, "license": "ISC", "engines": { "node": "6.* || 8.* || >= 10.*" @@ -1651,7 +1651,6 @@ "version": "1.7.0", "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz", "integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -1681,7 +1680,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/getenv/-/getenv-2.0.0.tgz", "integrity": "sha512-VilgtJj/ALgGY77fiLam5iD336eSWi96Q15JSAG1zi8NRBysm3LXKdGnHb4m5cuyxvOLQQKWpBZAT6ni4FI2iQ==", - "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -2096,14 +2094,12 @@ "version": "0.27.1", "resolved": "https://registry.npmjs.org/links-notation/-/links-notation-0.27.1.tgz", "integrity": "sha512-fTmzw/t3AHRTYhR6Ry8hCHzf0eroYGEH/8JsC7FALyGtWxQE0cHdp4YuZnMXqKqmcpMWWiTWoQiIo1D5AvsbQA==", - "dev": true, "license": "Unlicense" }, "node_modules/lino-arguments": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/lino-arguments/-/lino-arguments-0.4.0.tgz", "integrity": "sha512-pdsrPxmZYHu5Hy1w2JRoXnydrc5UGvjWe+NvPO9k0MvrMVXzeSiuqJsKToNqoCZ7pQy/fbkEBgbn1x4lWOEQxg==", - "dev": true, "license": "Unlicense", "dependencies": { "getenv": "^2.0.0", @@ -2127,7 +2123,6 @@ "version": "0.2.8", "resolved": "https://registry.npmjs.org/lino-env/-/lino-env-0.2.8.tgz", "integrity": "sha512-j9JcPo8LWCSlWCO7B1SSL3OlpRc/bGaR/OYnH22DTiANaMaLWan7ebRIo2Pwaw/apcIzdV+UD5EXamdapbn6kA==", - "dev": true, "license": "Unlicense", "dependencies": { "links-notation": "^0.11.2" @@ -2137,7 +2132,6 @@ "version": "0.11.2", "resolved": "https://registry.npmjs.org/links-notation/-/links-notation-0.11.2.tgz", "integrity": "sha512-VPyELWBXpaCCiNPVeZhMbG7RuvOQR51nhqELK+s/rbSzKYhSs+tyiSOdQ7z8I7Kh3PLABF3bZETtWSFwx3vFfg==", - "dev": true, "license": "Unlicense" }, "node_modules/lint-staged": { @@ -2378,9 +2372,10 @@ "license": "ISC" }, "node_modules/picomatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", - "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "name": "@ryotsu/picomatch", + "version": "4.0.7-a", + "resolved": "https://registry.npmjs.org/@ryotsu/picomatch/-/picomatch-4.0.7-a.tgz", + "integrity": "sha512-JroBFEmaejC7szGSfqOhF1QZHLKvX2wTA1+fWyfkpy3BjzdQKNPLKa2FtgeKVUDy5/UPUNkXEeCHJ5ZRBMLTVA==", "dev": true, "license": "MIT", "engines": { @@ -2629,7 +2624,6 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", - "dev": true, "license": "MIT", "dependencies": { "ansi-regex": "^6.2.2" @@ -2707,6 +2701,15 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, + "node_modules/tree-sitter-wasms": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/tree-sitter-wasms/-/tree-sitter-wasms-0.1.13.tgz", + "integrity": "sha512-wT+cR6DwaIz80/vho3AvSF0N4txuNx/5bcRKoXouOfClpxh/qqrF4URNLQXbbt8MaAxeksZcZd1j8gcGjc+QxQ==", + "license": "Unlicense", + "dependencies": { + "tree-sitter-wasms": "^0.1.11" + } + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -2743,6 +2746,19 @@ "punycode": "^2.1.0" } }, + "node_modules/web-tree-sitter": { + "version": "0.20.8", + "resolved": "https://registry.npmjs.org/web-tree-sitter/-/web-tree-sitter-0.20.8.tgz", + "integrity": "sha512-weOVgZ3aAARgdnb220GqYuh7+rZU0Ka9k9yfKtGAzEYMa6GgiCzW9JjQRJyCJakvibQW+dfjJdihjInKuuCAUQ==", + "license": "MIT" + }, + "node_modules/web-tree-sitter-bash-runtime": { + "name": "web-tree-sitter", + "version": "0.24.7", + "resolved": "https://registry.npmjs.org/web-tree-sitter/-/web-tree-sitter-0.24.7.tgz", + "integrity": "sha512-CdC/TqVFbXqR+C51v38hv6wOPatKEUGxa39scAeFSm98wIhZxAYonhRQPSMmfZ2w7JDI0zQDdzdmgtNk06/krQ==", + "license": "MIT" + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -2789,7 +2805,6 @@ "version": "9.0.2", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", - "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^6.2.1", @@ -2807,7 +2822,6 @@ "version": "6.2.3", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", - "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -2820,7 +2834,6 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "dev": true, "license": "MIT", "dependencies": { "emoji-regex": "^10.3.0", @@ -2838,7 +2851,6 @@ "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true, "license": "ISC", "engines": { "node": ">=10" @@ -2864,7 +2876,6 @@ "version": "18.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.2.0.tgz", "integrity": "sha512-9OpKOLeaoNFecEp7P6iYbzze/5CqWoH7N3SMs/6y1XF4nMvFMspEGZzJ6uFi9MmQwXhyzqYoSEKO3tvA3Z/o2w==", - "dev": true, "license": "MIT", "dependencies": { "cliui": "^9.0.1", @@ -2882,7 +2893,6 @@ "version": "22.0.0", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz", "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==", - "dev": true, "license": "ISC", "engines": { "node": "^20.19.0 || ^22.12.0 || >=23" @@ -2892,7 +2902,6 @@ "version": "8.3.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz", "integrity": "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==", - "dev": true, "license": "MIT", "dependencies": { "get-east-asian-width": "^1.5.0", diff --git a/package.json b/package.json index 2649bab..86210dc 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,30 @@ { - "name": "@link-foundation/example-package-name", + "name": "@link-foundation/code-evolution", "version": "0.11.31", - "description": "A JavaScript/TypeScript package template for AI-driven development", + "description": "Bounded Git history analysis for source code and its abstractions", "type": "module", "main": "src/index.js", "types": "src/index.d.ts", "bin": { - "example-package-name": "./bin/example-package-name.js" + "example-package-name": "./bin/example-package-name.js", + "code-evolution": "./bin/code-evolution.js" }, "files": [ "bin/", "src/", "CHANGELOG.md", "LICENSE", - "README.md" + "README.md", + "THIRD-PARTY-NOTICES.md" ], "exports": { ".": { "types": "./src/index.d.ts", "import": "./src/index.js" + }, + "./evolution": { + "types": "./src/evolution/index.d.ts", + "import": "./src/evolution/index.js" } }, "scripts": { @@ -44,10 +50,10 @@ "changeset:status": "changeset status --since=origin/main" }, "keywords": [ - "template", - "javascript", - "typescript", - "ai-driven" + "git", + "history", + "code-evolution", + "structural-analysis" ], "author": "", "license": "Unlicense", @@ -61,7 +67,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/link-foundation/js-ai-driven-development-pipeline-template.git" + "url": "git+https://github.com/link-foundation/code-evolution.git" }, "engines": { "node": ">=20.0.0" @@ -75,7 +81,6 @@ "eslint-plugin-prettier": "^5.5.4", "husky": "^9.1.7", "jscpd": "^5.4.0", - "lino-arguments": "0.4.0", "lint-staged": "^16.4.0", "prettier": "^3.6.2", "test-anywhere": "^0.8.48", @@ -103,6 +108,13 @@ }, "overrides": { "minimatch@>=7 <11": "^11.0.4", - "glob@>=9 <=14.0.1": "^14.0.2" + "glob@>=9 <=14.0.1": "^14.0.2", + "picomatch": "npm:@ryotsu/picomatch@4.0.7-a" + }, + "dependencies": { + "lino-arguments": "0.4.0", + "tree-sitter-wasms": "0.1.13", + "web-tree-sitter": "0.20.8", + "web-tree-sitter-bash-runtime": "npm:web-tree-sitter@0.24.7" } } diff --git a/src/evolution/bash-syntax.js b/src/evolution/bash-syntax.js new file mode 100644 index 0000000..3e9a488 --- /dev/null +++ b/src/evolution/bash-syntax.js @@ -0,0 +1,39 @@ +import Parser from 'web-tree-sitter-bash-runtime'; +import { readFile } from 'node:fs/promises'; +import { createHash } from 'node:crypto'; +import { URL } from 'node:url'; + +const grammarSha256 = + 'd1844429a58620f306b6f42aebe92298243ca8120cd833a3ab5d87c7a2e7b9fd'; +export const bashParserMethod = `web-tree-sitter@0.24.7/tree-sitter-bash@0.23.3/${grammarSha256}`; +let language; + +async function loadLanguage() { + await Parser.init(); + const bytes = await readFile( + new URL('./grammars/tree-sitter-bash.wasm', import.meta.url) + ); + if (createHash('sha256').update(bytes).digest('hex') !== grammarSha256) { + throw new Error('Bash grammar checksum mismatch'); + } + return await Parser.Language.load(bytes); +} + +export async function withBashSyntax(source, callback) { + language ||= loadLanguage(); + const grammar = await language; + const parser = new Parser(); + let tree; + try { + parser.setLanguage(grammar); + parser.setTimeoutMicros(2_000_000); + tree = parser.parse(source); + if (!tree) { + throw new Error('Parser budget exceeded'); + } + return await callback({ root: tree.rootNode, cmake: null }); + } finally { + tree?.delete(); + parser.delete(); + } +} diff --git a/src/evolution/cmake.js b/src/evolution/cmake.js new file mode 100644 index 0000000..31d36e4 --- /dev/null +++ b/src/evolution/cmake.js @@ -0,0 +1,459 @@ +// Original structural adapter for CMake's public language grammar (modern policies). +// It never executes commands, expands variables or evaluates project conditions. +class Reader { + constructor(source, { tokens = false, comments = false } = {}) { + this.source = source; + this.index = source.startsWith('\uFEFF') ? 1 : 0; + this.errors = []; + this.arguments = 0; + this.tokens = tokens ? [] : null; + this.comments = comments; + } + + token(kind, start, end, flags = {}) { + if (!this.tokens) { + return; + } + if (this.tokens.length >= 100_000) { + throw new Error('CMake token count budget exceeded'); + } + this.tokens.push({ kind, start, end, ...flags }); + } + + error(message, index = this.index) { + if (this.errors.length >= 1000) { + throw new Error('CMake diagnostic count budget exceeded'); + } + this.errors.push({ index, message }); + } + + bracket() { + const start = this.index; + if (this.source[start] !== '[') { + return null; + } + let open = start + 1; + while (this.source[open] === '=') { + open++; + } + if (this.source[open] !== '[') { + return null; + } + const close = `]${this.source.slice(start + 1, open)}]`; + const end = this.source.indexOf(close, open + 1); + if (end < 0) { + this.error('Unclosed bracket argument or comment', start); + this.index = this.source.length; + return ''; + } + this.index = end + close.length; + return this.source + .slice(open + 1, end) + .replace(/^\r?\n/, '') + .replace(/\r\n/g, '\n'); + } + + trivia() { + let newline = false; + let bracketBeforeCommand = false; + while (this.index < this.source.length) { + const value = this.source[this.index]; + if (/[ \t\r\n]/.test(value)) { + newline ||= value === '\n'; + if (value === '\n') { + bracketBeforeCommand = false; + } + this.index++; + } else if (value === '#') { + const start = this.index; + this.index++; + if (this.bracket() === null) { + const end = this.source.indexOf('\n', this.index); + this.index = end < 0 ? this.source.length : end; + } else { + bracketBeforeCommand = true; + } + if (this.comments) { + this.token('cmake_comment', start, this.index, { comment: true }); + } + } else { + break; + } + } + return { newline, bracketBeforeCommand }; + } + + escape(quoted) { + const start = this.index++; + const value = this.source[this.index++]; + if (value === undefined) { + this.error('Incomplete escape sequence', start); + return ''; + } + if (value === '\r' && this.source[this.index] === '\n') { + this.index++; + return quoted ? '' : '\n'; + } + if (value === '\n') { + return quoted ? '' : '\n'; + } + if (value === ';') { + return '\\;'; + } + if ('trn'.includes(value)) { + return { t: '\t', r: '\r', n: '\n' }[value]; + } + if (/[A-Za-z0-9]/.test(value)) { + this.error('Invalid escape sequence', start); + } + return value; + } + + argument() { + const bracket = this.bracket(); + if (bracket !== null) { + const next = this.source[this.index]; + if (next !== undefined && !/[ \t\r\n()#]/.test(next)) { + this.error('Expected separation after a bracket argument'); + } + return { value: bracket, kind: 'bracket', dynamic: false }; + } + return this.textArgument(); + } + + reference(quoted) { + const dynamic = ['${', '$ENV{', '$CACHE{'].some((prefix) => + this.source.startsWith(prefix, this.index) + ); + const makeReference = /\$\([A-Za-z_][A-Za-z0-9_]*\)/y; + makeReference.lastIndex = this.index; + const make = !quoted && makeReference.exec(this.source); + const value = make ? make[0] : '$'; + this.index += value.length; + return { value, dynamic }; + } + + textArgument() { + const start = this.index; + const quoted = this.source[this.index] === '"'; + if (quoted) { + this.index++; + } + let legacyQuote = false; + let closed = !quoted; + let value = ''; + let dynamic = false; + while (this.index < this.source.length) { + const char = this.source[this.index]; + if (char === '\\') { + value += this.escape(quoted); + continue; + } + if (char === '"') { + this.index++; + if (quoted) { + closed = true; + break; + } + legacyQuote = !legacyQuote; + value += char; + continue; + } + if (!quoted && !legacyQuote && /[ \t\r\n()#]/.test(char)) { + break; + } + if (char === '$') { + const reference = this.reference(quoted); + dynamic ||= reference.dynamic; + value += reference.value; + continue; + } + value += char; + this.index++; + } + if (!closed || legacyQuote) { + this.error('Unclosed quoted argument', start); + } + return { + value: value.replace(/\r\n/g, '\n'), + kind: quoted ? 'quoted' : 'unquoted', + dynamic, + }; + } + + commandArguments() { + const args = []; + let depth = 1; + this.token('cmake_parenthesis', this.index, this.index + 1); + this.index++; + while (this.index < this.source.length) { + this.trivia(); + const char = this.source[this.index]; + if (char !== undefined && ++this.arguments > 200_000) { + throw new Error('CMake argument count budget exceeded'); + } + if (char === '(') { + if (++depth > 512) { + throw new Error('CMake parenthesis depth budget exceeded'); + } + this.token('cmake_parenthesis', this.index, this.index + 1); + this.index++; + args.push({ value: char, kind: 'unquoted', dynamic: false }); + } else if (char === ')') { + this.token('cmake_parenthesis', this.index, this.index + 1); + this.index++; + if (--depth === 0) { + return args; + } + args.push({ value: char, kind: 'unquoted', dynamic: false }); + } else if (char !== undefined) { + const start = this.index; + const argument = this.argument(); + args.push(argument); + if (this.tokens) { + const text = this.source.slice(start, this.index); + const identifier = + argument.kind === 'unquoted' && + /^[A-Za-z_][A-Za-z0-9_]*$/.test(text); + this.token(`cmake_${argument.kind}`, start, this.index, { + identifier, + literal: !identifier && !argument.dynamic && !text.includes('$<'), + }); + } + } + } + this.error('Unclosed command invocation'); + return args; + } + + commands() { + const commands = []; + let needsNewline = false; + const identifier = /[A-Za-z_][A-Za-z0-9_]*/y; + while (this.index < this.source.length) { + const { newline, bracketBeforeCommand } = this.trivia(); + if (this.index === this.source.length) { + break; + } + if ((needsNewline && !newline) || bracketBeforeCommand) { + this.error('Expected a newline between command invocations'); + } + const start = this.index; + identifier.lastIndex = start; + const name = identifier.exec(this.source)?.[0]; + if (!name) { + this.error('Expected a command invocation'); + this.index++; + continue; + } + this.index = identifier.lastIndex; + while (/[ \t]/.test(this.source[this.index] || '\0')) { + this.index++; + } + if (this.source[this.index] !== '(') { + this.error( + 'Expected an opening parenthesis on the command name line', + start + ); + continue; + } + if (commands.length >= 50_000) { + throw new Error('CMake command count budget exceeded'); + } + this.token('cmake_command', start, start + name.length, { + identifier: true, + }); + const args = this.commandArguments(); + commands.push({ name: name.toLowerCase(), start, end: this.index, args }); + needsNewline = true; + } + return commands; + } +} + +function listElements(value) { + const result = []; + let brackets = 0; + let element = ''; + for (let index = 0; index < value.length; index++) { + const char = value[index]; + if (char === '\\' && value[index + 1] === ';') { + element += ';'; + index++; + } else if (char === ';' && brackets === 0) { + if (element) { + result.push(element); + } + element = ''; + } else { + if (char === '[') { + brackets++; + } + if (char === ']') { + brackets--; + } + element += char; + } + } + if (element) { + result.push(element); + } + return result; +} + +function definition(command, parent, limitations, errors) { + const unresolved = command.args.some( + (arg) => arg.kind === 'unquoted' && arg.dynamic + ); + const argumentsWithValues = command.args.flatMap((arg) => + (arg.kind === 'unquoted' ? listElements(arg.value) : [arg.value]).map( + (value) => ({ value, dynamic: arg.dynamic }) + ) + ); + const values = argumentsWithValues.map((arg) => arg.value); + if (!unresolved && !values.length) { + errors.push({ + index: command.start, + message: `${command.name} requires a name`, + }); + } + if (unresolved) { + limitations.push({ + index: command.start, + message: + 'CMake formal parameter arity requires variable expansion; it was not measured', + }); + } + const first = argumentsWithValues[0]; + if (first?.dynamic && !unresolved) { + limitations.push({ + index: command.start, + message: + 'CMake definition name requires variable expansion; its identity was not resolved', + }); + } + const name = first?.dynamic ? '' : (values[0] ?? ''); + const qualifiedName = parent ? `${parent.qualifiedName}.${name}` : name; + if (qualifiedName.length > 4096) { + throw new Error('CMake definition name length budget exceeded'); + } + return { + kind: command.name, + name, + qualifiedName, + start: command.start, + parameters: unresolved ? null : Math.max(0, values.length - 1), + complexity: 1, + }; +} + +function extractBlocks(commands, errors, limitations) { + const abstractions = []; + const stack = []; + const definitions = []; + const blocks = new Set([ + 'function', + 'macro', + 'if', + 'foreach', + 'while', + 'block', + ]); + const decisions = new Set(['if', 'elseif', 'foreach', 'while']); + let spanBytes = 0; + for (const command of commands) { + if (decisions.has(command.name) && definitions.length) { + definitions.at(-1).complexity++; + } + if (blocks.has(command.name)) { + if (stack.length >= 512) { + throw new Error('CMake block depth budget exceeded'); + } + const entry = { ...command }; + if (['function', 'macro'].includes(command.name)) { + entry.abstraction = definition( + command, + definitions.at(-1), + limitations, + errors + ); + definitions.push(entry.abstraction); + } + stack.push(entry); + } else if (['elseif', 'else'].includes(command.name)) { + checkBranch(command, stack, errors); + } else if ( + command.name.startsWith('end') && + blocks.has(command.name.slice(3)) + ) { + spanBytes += closeBlock( + command, + stack, + definitions, + abstractions, + errors + ); + if (spanBytes > 4_194_304) { + throw new Error('CMake abstraction metadata budget exceeded'); + } + } + if (errors.length + limitations.length > 1000) { + throw new Error('CMake diagnostic count budget exceeded'); + } + } + for (const command of stack) { + errors.push({ + index: command.start, + message: `Missing end${command.name}`, + }); + } + return abstractions; +} + +function checkBranch(command, stack, errors) { + const block = stack.at(-1); + if (block?.name !== 'if' || block.hasElse) { + errors.push({ + index: command.start, + message: `Unexpected ${command.name}`, + }); + } + if (block && command.name === 'else') { + block.hasElse = true; + } +} + +function closeBlock(command, stack, definitions, abstractions, errors) { + const block = stack.at(-1); + if (!block || command.name !== `end${block.name}`) { + errors.push({ + index: command.start, + message: `Mismatched ${command.name}`, + }); + return 0; + } + stack.pop(); + if (!block.abstraction) { + return 0; + } + definitions.pop(); + abstractions.push({ ...block.abstraction, end: command.end }); + return (command.end - block.start) * 2; +} + +export function parseCmake(source, options) { + if (source.length > 1_048_576) { + throw new Error('CMake source length budget exceeded'); + } + const reader = new Reader(source, options); + const commands = reader.commands(); + const limitations = []; + const abstractions = extractBlocks(commands, reader.errors, limitations); + return { + errors: reader.errors, + limitations, + commands, + abstractions, + ...(reader.tokens && { tokens: reader.tokens }), + }; +} diff --git a/src/evolution/config.js b/src/evolution/config.js new file mode 100644 index 0000000..4d020b8 --- /dev/null +++ b/src/evolution/config.js @@ -0,0 +1,27 @@ +export function positiveInteger(value, name, max = Number.MAX_SAFE_INTEGER) { + if (!Number.isSafeInteger(value) || value < 1 || value > max) { + throw new Error(`${name} must be an integer in [1, ${max}]`); + } + return value; +} + +export function safePath(path) { + if ( + typeof path !== 'string' || + !path || + path.includes('\0') || + path.includes('\\') || + path.startsWith('/') || + /^[a-z]:/i.test(path) + ) { + throw new Error( + `Expected a relative portable file path: ${JSON.stringify(path)}` + ); + } + if (path.split('/').some((part) => ['..', '.', ''].includes(part))) { + throw new Error( + `Expected a relative portable file path: ${JSON.stringify(path)}` + ); + } + return path; +} diff --git a/src/evolution/evolution.js b/src/evolution/evolution.js new file mode 100644 index 0000000..77ffcfd --- /dev/null +++ b/src/evolution/evolution.js @@ -0,0 +1,390 @@ +import { resolve } from 'node:path'; +import { gitOutput as git, resolveCommit as commitRef } from './git.js'; +import { detectLanguage } from './languages.js'; +import { safePath, positiveInteger } from './config.js'; +import { hash, withSyntax, extractSyntax } from './syntax.js'; + +function cacheSnapshot(cache, key, parsed) { + const metadataBytes = Buffer.byteLength(JSON.stringify(parsed)); + if ((cache.metadataBytes || 0) + metadataBytes > 33_554_432) { + cache.clear(); + cache.metadataBytes = 0; + } + cache.metadataBytes = (cache.metadataBytes || 0) + metadataBytes; + cache.set(key, parsed); +} + +async function snapshot(root, revision, cache, budgets) { + const entries = (await git(root, ['ls-tree', '-r', '-z', revision])) + .split('\0') + .filter(Boolean); + const files = []; + let bytes = 0; + for (const record of entries) { + const tab = record.indexOf('\t'); + const [mode, type, blob] = record.slice(0, tab).split(' '); + const path = record.slice(tab + 1); + const language = detectLanguage(path); + if ( + !language || + path + .split('/') + .some((part) => + ['node_modules', 'vendor', 'target', 'dist', '.venv'].includes(part) + ) + ) { + continue; + } + safePath(path); + if (type !== 'blob' || !['100644', '100755'].includes(mode)) { + throw new Error(`Unsupported Git entry: ${path}`); + } + if (files.length >= budgets.maxFiles) { + throw new Error('Evolution file count budget exceeded'); + } + const key = `${language}:${blob}`; + let parsed = cache.get(key); + if (!parsed) { + const size = Number((await git(root, ['cat-file', '-s', blob])).trim()); + if (size > budgets.maxFileBytes) { + throw new Error(`Evolution file byte budget exceeded: ${path}`); + } + const content = await git( + root, + ['cat-file', 'blob', blob], + budgets.maxFileBytes + ); + if (content.includes('\0')) { + throw new Error(`Binary source is unsupported: ${path}`); + } + parsed = await withSyntax(language, content, (syntax) => + extractSyntax(syntax, content) + ); + if (parsed.errors.length) { + throw new Error( + `${revision}:${path}: syntax errors prevent trustworthy abstraction tracking` + ); + } + if (parsed.limitations?.length) { + throw new Error( + `${revision}:${path}: unsupported CMake expansion prevents trustworthy abstraction tracking` + ); + } + parsed = { + ...parsed, + bytes: size, + }; + cacheSnapshot(cache, key, parsed); + } + bytes += parsed.bytes; + if (bytes > budgets.maxTotalBytes) { + throw new Error('Evolution snapshot byte budget exceeded'); + } + files.push({ + path, + language, + blob, + abstractions: parsed.abstractions, + }); + } + return files; +} + +function identityKeys(entry) { + const family = [entry.kind, entry.language]; + return { + name: JSON.stringify([...family, entry.path, entry.qualifiedName]), + content: JSON.stringify([...family, entry.hash]), + structure: JSON.stringify([...family, entry.shape]), + }; +} + +function identityIndex(entries) { + const index = { name: new Map(), content: new Map(), structure: new Map() }; + for (const entry of entries) { + for (const [criterion, key] of Object.entries(identityKeys(entry))) { + const group = index[criterion].get(key) || new Set(); + group.add(entry); + index[criterion].set(key, group); + } + } + return index; +} + +function indexedMatch(previous, current, keys, criterion) { + const key = keys[criterion]; + const group = previous[criterion].get(key); + if (group?.size !== 1 || current[criterion].get(key)?.size !== 1) { + return null; + } + return group.values().next().value; +} + +function removeIdentity(index, entry) { + for (const [criterion, key] of Object.entries(identityKeys(entry))) { + index[criterion].get(key).delete(entry); + } +} + +function identities(files) { + return files.flatMap((file) => [ + { + path: file.path, + kind: 'file', + name: file.path, + qualifiedName: file.path, + hash: file.blob, + shape: hash( + file.abstractions + .map((entry) => entry.shape) + .sort() + .join(':') + ), + language: file.language, + startLine: 1, + complexity: file.abstractions.reduce( + (sum, entry) => sum + entry.complexity, + 0 + ), + }, + ...file.abstractions.map((entry) => ({ + ...entry, + path: file.path, + language: file.language, + })), + ]); +} + +function matchIdentities(previous, current, commit) { + const unused = new Set(previous); + const previousIndex = identityIndex(previous); + const currentIndex = identityIndex(current); + const events = []; + for (const next of current) { + const keys = identityKeys(next); + let before = indexedMatch(previousIndex, currentIndex, keys, 'name'); + let matchedBy = 'qualified-name'; + if (!before) { + before = indexedMatch(previousIndex, currentIndex, keys, 'content'); + matchedBy = 'exact-content'; + } + if (!before && next.kind !== 'file') { + before = indexedMatch(previousIndex, currentIndex, keys, 'structure'); + matchedBy = 'unique-structure'; + } + if (before) { + unused.delete(before); + removeIdentity(previousIndex, before); + next.id = before.id; + const renamed = + before.path !== next.path || + before.qualifiedName !== next.qualifiedName; + if (before.hash !== next.hash || renamed) { + events.push({ + commit, + id: next.id, + kind: next.kind, + action: renamed ? 'renamed' : 'modified', + matchedBy, + before, + after: next, + }); + } + } else { + next.id = hash( + JSON.stringify([ + commit, + next.path, + next.kind, + next.qualifiedName, + next.startLine, + ]) + ); + events.push({ + commit, + id: next.id, + kind: next.kind, + action: 'added', + after: next, + }); + } + } + for (const before of unused) { + events.push({ + commit, + id: before.id, + kind: before.kind, + action: 'deleted', + before, + }); + } + return events; +} + +function couplingPairs(commitFiles) { + const pairs = new Map(); + for (const files of commitFiles.values()) { + const paths = [...files].sort(); + if (paths.length > 100) { + continue; + } + for (let i = 0; i < paths.length; i++) { + for (let j = i + 1; j < paths.length; j++) { + const key = JSON.stringify([paths[i], paths[j]]); + if (!pairs.has(key) && pairs.size >= 100_000) { + throw new Error('Evolution coupling budget exceeded'); + } + pairs.set(key, (pairs.get(key) || 0) + 1); + } + } + } + return pairs; +} + +function summarize(events) { + const changes = new Map(); + const patterns = new Map(); + const commitFiles = new Map(); + for (const event of events) { + const path = (event.after || event.before).path; + if (event.kind === 'file') { + changes.set(path, (changes.get(path) || 0) + 1); + const files = commitFiles.get(event.commit) || new Set(); + files.add(path); + commitFiles.set(event.commit, files); + } + if ( + event.before && + event.after && + event.kind !== 'file' && + event.before.editHash !== event.after.editHash + ) { + const key = `${event.after.language}:${event.kind}:${event.before.editHash}:${event.after.editHash}`; + const pattern = patterns.get(key) || { + id: hash(key), + kind: event.kind, + beforeShape: event.before.shape, + afterShape: event.after.shape, + count: 0, + evidence: [], + complexityDelta: 0, + }; + pattern.count++; + pattern.complexityDelta += + event.after.complexity - event.before.complexity; + pattern.evidence.push({ commit: event.commit, path, id: event.id }); + patterns.set(key, pattern); + } + } + const pairs = couplingPairs(commitFiles); + const repeatedPatterns = [...patterns.values()] + .filter((entry) => entry.count > 1) + .sort((a, b) => b.count - a.count || a.id.localeCompare(b.id)); + return { + hotspots: [...changes] + .map(([path, changes]) => ({ path, changes })) + .sort((a, b) => b.changes - a.changes || a.path.localeCompare(b.path)), + coupling: [...pairs] + .filter(([, count]) => count > 1) + .map(([key, count]) => ({ files: JSON.parse(key), commits: count })) + .sort( + (a, b) => + b.commits - a.commits || a.files.join().localeCompare(b.files.join()) + ), + repeatedPatterns, + suggestions: repeatedPatterns.map((pattern) => ({ + patternId: pattern.id, + confidence: 'observational', + message: + pattern.complexityDelta < 0 + ? 'Repeated edits reduced structural complexity; review the linked transformations for a reusable refactoring' + : 'Repeated structural edits may indicate a shared abstraction; review the linked transformations before applying a guideline', + evidence: pattern.evidence, + })), + }; +} + +export async function extractEvolution( + root, + { + from, + to = 'HEAD', + maxCommits = 100, + maxFiles = 1000, + maxFileBytes = 1_048_576, + maxTotalBytes = 16_777_216, + } = {} +) { + positiveInteger(maxCommits, 'maxCommits', 1000); + positiveInteger(maxFiles, 'maxFiles', 1000); + positiveInteger(maxFileBytes, 'maxFileBytes', 1_048_576); + positiveInteger(maxTotalBytes, 'maxTotalBytes', 16_777_216); + const absolute = resolve(root); + const end = await commitRef(absolute, to); + const start = from ? await commitRef(absolute, from) : null; + const history = ( + await git(absolute, [ + 'rev-list', + '--first-parent', + `--max-count=${maxCommits + 1}`, + end, + ]) + ) + .trim() + .split('\n') + .filter(Boolean); + const startIndex = start ? history.indexOf(start) : -1; + if (start && !history.slice(0, maxCommits).includes(start)) { + throw new Error( + 'from must occur on the bounded first-parent history of to' + ); + } + const selected = ( + start ? history.slice(0, startIndex + 1) : history.slice(0, maxCommits) + ).reverse(); + const truncated = !start && history.length > maxCommits; + const cache = new Map(); + const events = []; + const commits = []; + let previous = []; + for (const revision of selected) { + const info = await git(absolute, [ + 'show', + '-s', + '--format=%cI%x00%s', + revision, + ]); + const [date, subject] = info.trimEnd().split('\0'); + commits.push({ sha: revision, date, subject }); + const current = identities( + await snapshot(absolute, revision, cache, { + maxFiles, + maxFileBytes, + maxTotalBytes, + }) + ); + const diff = matchIdentities(previous, current, revision); + if (events.length + diff.length > 50_000) { + throw new Error('Evolution event budget exceeded'); + } + events.push(...diff); + previous = current; + } + return { + schemaVersion: 1, + algorithm: 'first-parent-structural-v1', + from: selected[0], + to: end, + truncated, + commits, + events, + current: previous, + ...summarize(events), + limitations: [ + 'First-parent history only; merge side branches are not traversed', + 'Renames use unique names, content or structure; ambiguous matches become deletion/addition', + 'Pattern frequency is evidence, not proof that a change improves behavior', + 'Coupling omits commits changing more than 100 source files', + ], + }; +} diff --git a/src/evolution/git.js b/src/evolution/git.js new file mode 100644 index 0000000..43000be --- /dev/null +++ b/src/evolution/git.js @@ -0,0 +1,40 @@ +import { runProcess } from './process.js'; + +export async function gitOutput(root, args, maxOutputBytes = 4_194_304) { + const result = await runProcess( + 'git', + ['--literal-pathspecs', '-C', root, ...args], + { + maxOutputBytes, + env: { + ...process.env, + GIT_NO_LAZY_FETCH: '1', + GIT_OPTIONAL_LOCKS: '0', + GIT_TERMINAL_PROMPT: '0', + }, + } + ); + if (result.code !== 0) { + throw new Error(`Git ${args[0]} failed: ${result.stderr.trim()}`); + } + return result.stdout; +} + +export async function resolveCommit(root, ref) { + if ( + typeof ref !== 'string' || + !ref || + ref.startsWith('-') || + ref.includes('\0') + ) { + throw new Error('Invalid Git revision'); + } + return ( + await gitOutput(root, [ + 'rev-parse', + '--verify', + '--end-of-options', + `${ref}^{commit}`, + ]) + ).trim(); +} diff --git a/src/evolution/grammars/BASH-LICENSE b/src/evolution/grammars/BASH-LICENSE new file mode 100644 index 0000000..aa9f858 --- /dev/null +++ b/src/evolution/grammars/BASH-LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 Max Brunsfeld + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/evolution/grammars/tree-sitter-bash.wasm b/src/evolution/grammars/tree-sitter-bash.wasm new file mode 100644 index 0000000..28e2869 Binary files /dev/null and b/src/evolution/grammars/tree-sitter-bash.wasm differ diff --git a/src/evolution/index.d.ts b/src/evolution/index.d.ts new file mode 100644 index 0000000..d10af94 --- /dev/null +++ b/src/evolution/index.d.ts @@ -0,0 +1,94 @@ +export type Language = + | 'javascript' + | 'typescript' + | 'tsx' + | 'rust' + | 'python' + | 'go' + | 'csharp' + | 'java' + | 'c' + | 'cpp' + | 'php' + | 'bash' + | 'cmake'; + +export interface Abstraction { + kind: 'function' | 'class' | 'macro'; + syntaxKind?: string; + name: string; + qualifiedName: string; + start: number; + end: number; + startLine: number; + endLine: number; + /** Null when CMake formal arity needs unevaluated variable expansion. */ + parameters: number | null; + complexity: number; + hash: string; + shape: string; + editHash?: string; +} + +export interface EvolutionIdentity extends Partial> { + id: string; + path: string; + kind: string; + qualifiedName: string; + hash: string; + shape: string; + editHash?: string; + language: Language; + startLine: number; + complexity: number; +} +export interface EvolutionEvent { + commit: string; + id: string; + kind: string; + action: 'added' | 'modified' | 'renamed' | 'deleted'; + matchedBy?: string; + before?: EvolutionIdentity; + after?: EvolutionIdentity; +} +export interface EvolutionPattern { + id: string; + kind: string; + beforeShape: string; + afterShape: string; + count: number; + complexityDelta: number; + evidence: { commit: string; path: string; id: string }[]; +} +export interface EvolutionReport { + schemaVersion: 1; + algorithm: string; + from: string; + to: string; + truncated: boolean; + commits: { sha: string; date: string; subject: string }[]; + events: EvolutionEvent[]; + current: EvolutionIdentity[]; + hotspots: { path: string; changes: number }[]; + coupling: { files: string[]; commits: number }[]; + repeatedPatterns: EvolutionPattern[]; + suggestions: { + patternId: string; + confidence: 'observational'; + message: string; + evidence: EvolutionPattern['evidence']; + }[]; + limitations: string[]; +} + +export function extractEvolution( + root: string, + options?: { + from?: string; + to?: string; + maxCommits?: number; + maxFiles?: number; + maxFileBytes?: number; + maxTotalBytes?: number; + } +): Promise; diff --git a/src/evolution/index.js b/src/evolution/index.js new file mode 100644 index 0000000..c2cfcc8 --- /dev/null +++ b/src/evolution/index.js @@ -0,0 +1 @@ +export { extractEvolution } from './evolution.js'; diff --git a/src/evolution/languages.js b/src/evolution/languages.js new file mode 100644 index 0000000..2a0c33f --- /dev/null +++ b/src/evolution/languages.js @@ -0,0 +1,52 @@ +import { extname, basename } from 'node:path'; + +export const languages = Object.freeze( + [ + { + id: 'javascript', + extensions: ['.js', '.mjs', '.cjs', '.jsx'], + grammar: 'javascript', + }, + { + id: 'typescript', + extensions: ['.ts', '.mts', '.cts'], + grammar: 'typescript', + }, + { id: 'tsx', extensions: ['.tsx'], grammar: 'tsx' }, + { id: 'rust', extensions: ['.rs'], grammar: 'rust' }, + { id: 'python', extensions: ['.py', '.pyi'], grammar: 'python' }, + { id: 'go', extensions: ['.go'], grammar: 'go' }, + { id: 'csharp', extensions: ['.cs'], grammar: 'c_sharp' }, + { id: 'java', extensions: ['.java'], grammar: 'java' }, + { id: 'c', extensions: ['.c', '.h'], grammar: 'c' }, + { + id: 'cpp', + extensions: ['.cc', '.cpp', '.cxx', '.hpp', '.hh', '.hxx'], + grammar: 'cpp', + }, + { id: 'php', extensions: ['.php', '.phtml'], grammar: 'php' }, + { id: 'bash', extensions: ['.sh', '.bash', '.bats'], grammar: 'bash' }, + { id: 'cmake', extensions: ['.cmake'], grammar: null }, + ].map((entry) => + Object.freeze({ ...entry, extensions: Object.freeze(entry.extensions) }) + ) +); + +export function detectLanguage(path, content = '') { + if (basename(path) === 'CMakeLists.txt') { + return 'cmake'; + } + return ( + languages.find((lang) => + lang.extensions.includes(extname(path).toLowerCase()) + )?.id || (/^#![^\n]*\b(?:ba)?sh\b/.test(content) ? 'bash' : null) + ); +} + +export function getLanguage(id) { + const language = languages.find((entry) => entry.id === id); + if (!language) { + throw new Error(`Unsupported language: ${id}`); + } + return language; +} diff --git a/src/evolution/lines.js b/src/evolution/lines.js new file mode 100644 index 0000000..a591118 --- /dev/null +++ b/src/evolution/lines.js @@ -0,0 +1,22 @@ +// Binary searches keep repeated source-offset lookups bounded on large inputs. +export function lineLocator(source) { + const starts = [0]; + for (let index = 0; index < source.length; index++) { + if (source[index] === '\n') { + starts.push(index + 1); + } + } + return (index) => { + let low = 0; + let high = starts.length; + while (low + 1 < high) { + const middle = Math.floor((low + high) / 2); + if (starts[middle] <= index) { + low = middle; + } else { + high = middle; + } + } + return { line: low + 1, column: index - starts[low] + 1 }; + }; +} diff --git a/src/evolution/meta-language/tree-sitter-node-kind.js b/src/evolution/meta-language/tree-sitter-node-kind.js new file mode 100644 index 0000000..f2919b4 --- /dev/null +++ b/src/evolution/meta-language/tree-sitter-node-kind.js @@ -0,0 +1,29 @@ +// The kind the native runtime reports for a tree-sitter node. +// +// Native `ts_node_type` (Rust `Node::kind`) names the node's alias or grammar +// symbol, while web-tree-sitter's `Node.type` names its public symbol. The two +// agree unless a generated parser maps a symbol to a public symbol with another +// name: tree-sitter-scala 0.26.2 maps the anonymous `(` of class parameters to +// the token its `arguments` alias renamed, so web-tree-sitter would print +// `"arguments"` where the native CLI prints `"("`. An unaliased node's public +// symbol is the one `idForNodeType` returns for its grammar symbol's name, and +// its native kind is that grammar symbol's name. +export function treeSitterNodeKind(node) { + const language = node.tree.language; + // Node.type uses `name || "ERROR"`, which turns a legitimate empty + // grammar symbol (a NUL sentinel) into an error name. The symbol API keeps + // the original name, as native Node::kind does. + const type = language.nodeTypeForId(node.typeId) ?? node.type; + const grammarType = + node.grammarType === undefined + ? undefined + : (language.nodeTypeForId(node.grammarId) ?? node.grammarType); + if (grammarType === undefined || type === grammarType) { + return type; + } + const unaliased = language.idForNodeType( + grammarType, + language.nodeTypeIsNamed(node.grammarId) + ); + return unaliased === node.typeId ? grammarType : type; +} diff --git a/src/evolution/process.js b/src/evolution/process.js new file mode 100644 index 0000000..bd32269 --- /dev/null +++ b/src/evolution/process.js @@ -0,0 +1,112 @@ +import { StringDecoder } from 'node:string_decoder'; +import { spawn } from 'node:child_process'; +import { positiveInteger } from './config.js'; + +// No shell interpolation. Callers explicitly choose trusted executables. +export function runProcess( + command, + args = [], + { + cwd, + timeoutMs = 30_000, + maxOutputBytes = 4_194_304, + env = process.env, + } = {} +) { + positiveInteger(timeoutMs, 'timeoutMs', 300_000); + positiveInteger(maxOutputBytes, 'maxOutputBytes', 16_777_216); + const debug = env.CODE_QUALITY_DEBUG === '1'; + const started = Date.now(); + if (debug) { + console.error( + JSON.stringify({ event: 'quality-process-start', command, args, cwd }) + ); + } + return new Promise((resolve, reject) => { + const child = spawn(command, args, { + cwd, + env, + shell: false, + windowsHide: true, + detached: process.platform !== 'win32', + stdio: ['ignore', 'pipe', 'pipe'], + }); + const decoders = { + stdout: new StringDecoder('utf8'), + stderr: new StringDecoder('utf8'), + }; + let stdout = ''; + let stderr = ''; + let bytes = 0; + let failure; + const stop = (message) => { + failure ||= new Error(message); + if (process.platform !== 'win32' && child.pid) { + try { + process.kill(-child.pid, 'SIGKILL'); + } catch { + child.kill('SIGKILL'); + } + } else { + child.kill('SIGKILL'); + } + }; + const timer = setTimeout( + () => stop(`${command}: execution timeout`), + timeoutMs + ); + const collect = (stream) => (chunk) => { + bytes += chunk.length; + if (bytes > maxOutputBytes) { + stop(`${command}: output budget exceeded`); + return; + } + if (stream === 'stdout') { + stdout += decoders.stdout.write(chunk); + } else { + stderr += decoders.stderr.write(chunk); + } + }; + child.stdout.on('data', collect('stdout')); + child.stderr.on('data', collect('stderr')); + child.on('error', (error) => { + clearTimeout(timer); + reject(error); + }); + child.on('close', (code, signal) => { + clearTimeout(timer); + stdout += decoders.stdout.end(); + stderr += decoders.stderr.end(); + if (debug) { + console.error( + JSON.stringify({ + event: 'quality-process-close', + command, + code, + signal, + elapsedMs: Date.now() - started, + stdout, + stderr, + }) + ); + } + if (failure) { + reject( + Object.assign(failure, { command, code, signal, stdout, stderr }) + ); + } else if (signal) { + reject( + Object.assign(new Error(`${command}: terminated by ${signal}`), { + command, + code, + signal, + stdout, + stderr, + }) + ); + } else { + resolve({ code, stdout, stderr }); + } + }); + }); +} diff --git a/src/evolution/syntax.js b/src/evolution/syntax.js new file mode 100644 index 0000000..0382372 --- /dev/null +++ b/src/evolution/syntax.js @@ -0,0 +1,311 @@ +import Parser from 'web-tree-sitter'; +import { createRequire } from 'node:module'; +import { createHash } from 'node:crypto'; +import { getLanguage } from './languages.js'; +import { parseCmake } from './cmake.js'; +import { lineLocator } from './lines.js'; +import { withBashSyntax } from './bash-syntax.js'; +import { treeSitterNodeKind } from './meta-language/tree-sitter-node-kind.js'; + +const require = createRequire(import.meta.url); +const grammars = new Map(); +let initialized; +const functionKinds = new Set([ + 'function_declaration', + 'function_definition', + 'function_item', + 'method_declaration', + 'method_definition', + 'arrow_function', + 'function_expression', + 'generator_function_declaration', + 'generator_function', + 'constructor_declaration', + 'local_function_statement', + 'anonymous_method_expression', + 'lambda_expression', + 'closure_expression', + 'lambda', +]); +const classKinds = new Set([ + 'class_declaration', + 'class_definition', + 'class_specifier', + 'class', + 'struct_item', + 'struct_specifier', + 'struct_declaration', + 'interface_declaration', + 'interface_type', + 'enum_item', + 'enum_declaration', + 'trait_item', + 'impl_item', + 'type_declaration', + 'namespace_definition', + 'namespace_declaration', + 'module', + 'mod_item', +]); +const decisionKinds = new Set([ + 'if_statement', + 'if_expression', + 'elif_clause', + 'for_statement', + 'for_expression', + 'while_statement', + 'while_expression', + 'do_statement', + 'case_statement', + 'switch_case', + 'catch_clause', + 'except_clause', + 'conditional_expression', + 'ternary_expression', + 'match_arm', + 'for_in_statement', + 'for_range_loop', + 'select_statement', +]); + +export const hash = (value) => createHash('sha256').update(value).digest('hex'); +export const isNamed = (node) => + typeof node.isNamed === 'function' ? node.isNamed() : node.isNamed; +export function* walk(root, budget = { remaining: 500_000 }) { + const cursor = root.walk(); + try { + let more = true; + while (more) { + if (--budget.remaining < 0) { + throw new Error('Syntax traversal budget exceeded'); + } + yield typeof cursor.currentNode === 'function' + ? cursor.currentNode() + : cursor.currentNode; + if (cursor.gotoFirstChild()) { + continue; + } + while (!cursor.gotoNextSibling()) { + if (!cursor.gotoParent()) { + more = false; + break; + } + } + } + } finally { + cursor.delete(); + } +} + +function nodeName(node) { + const direct = node.childForFieldName('name')?.text; + if (direct) { + return direct; + } + const declarator = node.childForFieldName('declarator'); + if (declarator) { + return [...walk(declarator)].find((child) => + ['identifier', 'field_identifier'].includes(child.type) + )?.text; + } + const parent = node.parent; + if ( + ![ + 'variable_declarator', + 'pair', + 'assignment', + 'assignment_expression', + ].includes(parent?.type) + ) { + return null; + } + return ( + parent.childForFieldName('name') || + parent.childForFieldName('left') || + parent.childForFieldName('key') + )?.text; +} + +function qualifiedName(node, name) { + const parents = []; + let depth = 0; + for (let parent = node.parent; parent; parent = parent.parent) { + if (++depth > 512) { + throw new Error('Syntax depth budget exceeded'); + } + if (functionKinds.has(parent.type) || classKinds.has(parent.type)) { + const parentName = parent.childForFieldName('name')?.text; + if (parentName) { + parents.unshift(parentName); + } + } + } + return [...parents, name].join('.'); +} + +function nodeMetrics(node, budget) { + const leaves = []; + const edits = []; + let complexity = 1; + for (const child of walk(node, budget)) { + const kind = treeSitterNodeKind(child); + if ( + decisionKinds.has(kind) || + ['&&', '||', 'and', 'or', '??'].includes(kind) + ) { + complexity++; + } + if (child.childCount !== 0 || /comment/.test(kind)) { + continue; + } + const identity = /identifier|name/.test(kind); + const literal = /string|number|integer|float|literal/.test(kind); + leaves.push(identity ? '$id' : literal ? `$${kind}` : kind); + edits.push(identity ? '$id' : child.text); + } + const params = node.childForFieldName('parameters'); + const parameters = params + ? params.namedChildren.filter((child) => !child.type.includes('comment')) + .length + : 0; + return { + parameters, + complexity, + shape: hash(leaves.join(' ')), + editHash: hash(edits.join(' ')), + }; +} + +function abstraction(node, source, budget) { + if ( + !isNamed(node) || + (node.type === 'module' && !node.childForFieldName('name')) + ) { + return null; + } + const kind = functionKinds.has(node.type) + ? 'function' + : classKinds.has(node.type) + ? 'class' + : null; + if (!kind) { + return null; + } + const name = nodeName(node) || ''; + const start = node.startIndex; + const end = node.endIndex; + return { + kind, + syntaxKind: node.type, + name, + qualifiedName: qualifiedName(node, name), + start, + end, + startLine: node.startPosition.row + 1, + endLine: node.endPosition.row + 1, + hash: hash(source.slice(start, end)), + ...nodeMetrics(node, budget), + }; +} + +export async function withSyntax(language, source, callback, options) { + const spec = getLanguage(language); + if (!spec.grammar) { + return callback({ cmake: parseCmake(source, options), root: null }); + } + if (spec.grammar === 'bash') { + return await withBashSyntax(source, callback); + } + initialized ||= Parser.init(); + await initialized; + if (!grammars.has(spec.grammar)) { + grammars.set( + spec.grammar, + Parser.Language.load( + require.resolve( + `tree-sitter-wasms/out/tree-sitter-${spec.grammar}.wasm` + ) + ) + ); + } + const parser = new Parser(); + let tree; + try { + parser.setLanguage(await grammars.get(spec.grammar)); + parser.setTimeoutMicros(2_000_000); + tree = parser.parse(source); + if (!tree) { + throw new Error('Parser budget exceeded'); + } + return await callback({ root: tree.rootNode, cmake: null }); + } finally { + tree?.delete(); + parser.delete(); + } +} + +export function extractSyntax(syntax, source) { + if (syntax.cmake) { + // A shared line index maps CMake source offsets to report positions without + // rescanning each declaration's prefix. + const location = lineLocator(source); + let descriptorBytes = 0; + return { + errors: syntax.cmake.errors.map((error) => ({ + ...location(error.index), + message: error.message, + })), + limitations: syntax.cmake.limitations.map((entry) => ({ + ...location(entry.index), + message: entry.message, + })), + abstractions: syntax.cmake.abstractions.map((entry) => { + const abstraction = { + ...entry, + kind: 'function', + syntaxKind: entry.kind, + editHash: hash( + source + .slice(entry.start, entry.end) + .replace(/\b[A-Za-z_]\w*\b/g, '$id') + ), + startLine: location(entry.start).line, + endLine: location(entry.end).line, + hash: hash(source.slice(entry.start, entry.end)), + shape: hash( + source.slice(entry.start, entry.end).replace(/\b\w+\b/g, '$id') + ), + }; + descriptorBytes += Buffer.byteLength(JSON.stringify(abstraction)); + if (descriptorBytes > 4_194_304) { + throw new Error('Abstraction metadata budget exceeded'); + } + return abstraction; + }), + }; + } + const errors = []; + const abstractions = []; + let descriptorBytes = 0; + const budget = { remaining: 500_000 }; + for (const node of walk(syntax.root, budget)) { + const missing = + typeof node.isMissing === 'function' ? node.isMissing() : node.isMissing; + if (node.type === 'ERROR' || missing) { + errors.push({ + line: node.startPosition.row + 1, + column: node.startPosition.column + 1, + message: `Invalid or incomplete ${node.type}`, + }); + } + const entry = abstraction(node, source, budget); + if (entry) { + descriptorBytes += Buffer.byteLength(JSON.stringify(entry)); + if (descriptorBytes > 4_194_304) { + throw new Error('Abstraction metadata budget exceeded'); + } + abstractions.push(entry); + } + } + return { errors, abstractions }; +} diff --git a/tests/cmake-evolution.test.js b/tests/cmake-evolution.test.js new file mode 100644 index 0000000..798fb32 --- /dev/null +++ b/tests/cmake-evolution.test.js @@ -0,0 +1,60 @@ +import { describe } from 'test-anywhere'; +import assert from 'node:assert/strict'; +import { mkdtemp, writeFile, rm } from 'node:fs/promises'; +import { join } from 'node:path'; +import { tmpdir } from 'node:os'; +import { extractEvolution } from '../src/evolution/index.js'; +import { runProcess } from '../src/evolution/process.js'; +import { itUnless, sandboxed } from './helpers/skip.js'; + +describe('CMake evolution metrics and refusals', () => { + itUnless(sandboxed)( + 'tracks literal metrics and refuses unresolved definition identities or arity', + async () => { + const root = await mkdtemp(join(tmpdir(), 'quality-cmake-history-')); + const git = async (...args) => { + const result = await runProcess('git', ['-C', root, ...args]); + assert.equal(result.code, 0, result.stderr); + }; + const commit = async () => { + await git('add', '.'); + await git('commit', '-m', 'Original CMake history fixture'); + }; + try { + await git('init', '-b', 'main'); + await git('config', 'user.name', 'Quality Fixture'); + await git('config', 'user.email', 'quality@example.invalid'); + await writeFile( + join(root, 'original.cmake'), + 'function(sample first second)\nif(first)\nendif()\nendfunction()\n' + ); + await commit(); + await writeFile( + join(root, 'original.cmake'), + 'function(sample first second)\nmessage("value")\nendfunction()\n' + ); + await commit(); + const history = await extractEvolution(root); + const event = history.events.find( + ({ kind, action }) => kind === 'function' && action === 'modified' + ); + assert.equal(event.before.parameters, 2); + assert.equal(event.before.complexity, 2); + assert.equal(event.after.complexity, 1); + for (const header of ['sample ${arguments}', '"${name}" first']) { + await writeFile( + join(root, 'original.cmake'), + `function(${header})\nendfunction()\n` + ); + await commit(); + await assert.rejects( + () => extractEvolution(root, { maxCommits: 1 }), + /unsupported.*abstraction tracking/ + ); + } + } finally { + await rm(root, { recursive: true, force: true }); + } + } + ); +}); diff --git a/tests/evolution-languages.test.js b/tests/evolution-languages.test.js new file mode 100644 index 0000000..c775bc7 --- /dev/null +++ b/tests/evolution-languages.test.js @@ -0,0 +1,49 @@ +import assert from 'node:assert/strict'; +import { readFile } from 'node:fs/promises'; +import { URL } from 'node:url'; +import { describe, it } from 'test-anywhere'; +import { detectLanguage } from '../src/evolution/languages.js'; +import { extractSyntax, withSyntax } from '../src/evolution/syntax.js'; +import { generateSampleReport } from '../examples/evolution-report/generate.mjs'; +import { isReport } from '../examples/universal-app/evolution/report.js'; +import { languageFixtures } from './fixtures/evolution-languages.js'; +import { itUnless, sandboxed } from './helpers/skip.js'; + +describe('evolution input and report formats', () => { + for (const [language, { path, content, invalid }] of Object.entries( + languageFixtures + )) { + it(`projects the pinned ${language} grammar`, async () => { + assert.equal(detectLanguage(path), language); + const project = (source) => + withSyntax(language, source, (syntax) => extractSyntax(syntax, source)); + const parsed = await project(content); + assert.deepEqual(parsed.errors, []); + assert.ok(parsed.abstractions.some(({ kind }) => kind === 'function')); + for (const { hash, shape, editHash } of parsed.abstractions) { + for (const digest of [hash, shape, editHash]) { + assert.match(digest, /^[a-f0-9]{64}$/); + } + } + assert.ok((await project(invalid)).errors.length); + }); + } + + itUnless(sandboxed)( + 'reproduces the report shipped with the viewer', + async () => { + const report = await generateSampleReport(); + const sample = await readFile( + new URL( + '../examples/universal-app/evolution/sample-report.json', + import.meta.url + ), + 'utf8' + ); + assert.deepEqual(report, JSON.parse(sample)); + assert.ok(isReport(report)); + assert.equal(isReport({ ...report, events: [null] }), false); + assert.equal(isReport({ ...report, schemaVersion: 2 }), false); + } + ); +}); diff --git a/tests/evolution.test.js b/tests/evolution.test.js new file mode 100644 index 0000000..84cdc29 --- /dev/null +++ b/tests/evolution.test.js @@ -0,0 +1,138 @@ +import { describe } from 'test-anywhere'; +import assert from 'node:assert/strict'; +import { mkdtemp, writeFile, rename, rm } from 'node:fs/promises'; +import { join } from 'node:path'; +import { tmpdir } from 'node:os'; +import { extractEvolution } from '../src/evolution/index.js'; +import { runProcess } from '../src/evolution/process.js'; +import { itUnless, sandboxed } from './helpers/skip.js'; + +describe('read-only code evolution extraction', () => { + itUnless(sandboxed)( + 'does not carry one identity into ambiguous duplicate declarations', + async () => { + const root = await mkdtemp(join(tmpdir(), 'quality-ambiguous-history-')); + const git = async (...args) => { + const result = await runProcess('git', ['-C', root, ...args]); + assert.equal(result.code, 0, result.stderr); + return result.stdout.trim(); + }; + try { + await git('init', '-b', 'main'); + await git('config', 'user.name', 'Quality Fixture'); + await git('config', 'user.email', 'quality@example.invalid'); + await writeFile(join(root, 'a.js'), 'function same() { return 1; }\n'); + await git('add', '.'); + await git('commit', '-m', 'One declaration'); + await writeFile( + join(root, 'a.js'), + 'function same() { return 2; }\nfunction same() { return 3; }\n' + ); + await git('add', '.'); + await git('commit', '-m', 'Ambiguous declarations'); + const report = await extractEvolution(root); + const events = report.events.filter( + (event) => event.commit === report.to && event.kind === 'function' + ); + assert.deepEqual(events.map((event) => event.action).sort(), [ + 'added', + 'added', + 'deleted', + ]); + } finally { + await rm(root, { recursive: true, force: true }); + } + } + ); + itUnless(sandboxed)( + 'tracks file/function/class additions, changes, renames, deletions and repeated improvements', + async () => { + const root = await mkdtemp(join(tmpdir(), 'quality-history-')); + const git = async (...args) => { + const result = await runProcess('git', ['-C', root, ...args]); + assert.equal(result.code, 0, result.stderr); + return result.stdout.trim(); + }; + const commit = async (subject) => { + await git('add', '.'); + await git('commit', '-m', subject); + return git('rev-parse', 'HEAD'); + }; + try { + await git('init', '-b', 'main'); + await git('config', 'user.name', 'Quality Fixture'); + await git('config', 'user.email', 'quality@example.invalid'); + const before = + 'export function first(x) { if (x) { return x; } return 0; }\nexport function second(y) { if (y) { return y; } return 0; }\nclass Sample { method() { return 1; } }\n'; + await writeFile(join(root, 'a.js'), before); + await writeFile( + join(root, 'b.py'), + 'def compute(x):\n return x + 1\n' + ); + const first = await commit('Add independent original functions'); + await writeFile( + join(root, 'a.js'), + before + .replace('if (x) { return x; } return 0;', 'return x || 0;') + .replace('if (y) { return y; } return 0;', 'return y || 0;') + ); + await writeFile( + join(root, 'b.py'), + 'def compute(x):\n return x + 2\n' + ); + await commit('Apply the same structural simplification twice'); + await rename(join(root, 'a.js'), join(root, 'renamed.js')); + await commit('Move a file without changing its source'); + await writeFile( + join(root, 'renamed.js'), + 'export function renamed(x) { return x || 0; }\n' + ); + const last = await commit('Rename a function and remove a class'); + const report = await extractEvolution(root, { from: first, to: last }); + assert.equal(report.truncated, false); + assert.equal(report.commits.length, 4); + for (const kind of ['file', 'function', 'class']) { + assert.ok( + report.events.some((entry) => entry.kind === kind), + kind + ); + } + for (const action of ['added', 'modified', 'renamed', 'deleted']) { + assert.ok( + report.events.some((entry) => entry.action === action), + action + ); + } + assert.equal(report.repeatedPatterns[0].count, 2); + assert.equal(report.suggestions[0].confidence, 'observational'); + assert.equal(report.suggestions[0].evidence.length, 2); + assert.ok( + report.coupling.some((entry) => entry.files.includes('b.py')) + ); + const moved = report.events.find( + (entry) => entry.kind === 'file' && entry.action === 'renamed' + ); + assert.equal(moved.before.path, 'a.js'); + assert.equal(moved.after.path, 'renamed.js'); + const short = await extractEvolution(root, { maxCommits: 2 }); + assert.equal(short.truncated, true); + await assert.rejects( + () => extractEvolution(root, { from: first, maxCommits: 1 }), + /bounded/ + ); + await assert.rejects( + () => extractEvolution(root, { to: '--all' }), + /Invalid/ + ); + await assert.rejects( + () => extractEvolution(root, { maxCommits: 0 }), + /integer/ + ); + assert.equal(await git('status', '--porcelain'), ''); + assert.equal(await git('rev-parse', 'HEAD'), last); + } finally { + await rm(root, { recursive: true, force: true }); + } + } + ); +}); diff --git a/tests/fixtures/evolution-languages.js b/tests/fixtures/evolution-languages.js new file mode 100644 index 0000000..5abee9f --- /dev/null +++ b/tests/fixtures/evolution-languages.js @@ -0,0 +1,67 @@ +export const languageFixtures = { + javascript: { + path: 'sample.js', + content: 'export function compute(x) { return x + 1; }\n', + invalid: 'function broken( {\n', + }, + typescript: { + path: 'sample.ts', + content: 'export function compute(x: number): number { return x + 1; }\n', + invalid: 'function broken(x: {\n', + }, + tsx: { + path: 'sample.tsx', + content: 'function Component() { return
    ; }\n', + invalid: 'function broken() { return
    \n', + }, + rust: { + path: 'sample.rs', + content: 'fn compute(x: i32) -> i32 { x + 1 }\n', + invalid: 'fn broken( {\n', + }, + python: { + path: 'sample.py', + content: 'def compute(x):\n return x + 1\n', + invalid: 'def broken(:\n', + }, + go: { + path: 'sample.go', + content: 'package main\nfunc compute(x int) int { return x + 1 }\n', + invalid: 'package main\nfunc broken( {\n', + }, + csharp: { + path: 'Sample.cs', + content: 'class Sample { int Compute(int x) { return x + 1; } }\n', + invalid: 'class Sample { int Broken( {\n', + }, + java: { + path: 'Sample.java', + content: 'class Sample { int compute(int x) { return x + 1; } }\n', + invalid: 'class Sample { int broken( {\n', + }, + c: { + path: 'sample.c', + content: 'int compute(int x) { return x + 1; }\n', + invalid: 'int broken( {\n', + }, + cpp: { + path: 'sample.cpp', + content: 'class Sample { public: int compute(int x) { return x + 1; } };\n', + invalid: 'class Sample { int broken( {\n', + }, + php: { + path: 'sample.php', + content: ' { ...pkg.dependencies, ...pkg.devDependencies, }) - .map( - ([name, range]) => - `npm:${name}@${range.replace(/^\^(0\.[1-9]\d*\.\d+)/, '~$1')}` - ) + .map(([name, range]) => { + if (range.startsWith('npm:')) { + return range; + } + return `npm:${name}@${range.replace(/^\^(0\.[1-9]\d*\.\d+)/, '~$1')}`; + }) .sort(); expect([...lock.workspace.packageJson.dependencies].sort()).toEqual( expected diff --git a/tests/issue-262-regressions.test.js b/tests/issue-262-regressions.test.js index 8fc6a19..f0b3d84 100644 --- a/tests/issue-262-regressions.test.js +++ b/tests/issue-262-regressions.test.js @@ -57,10 +57,12 @@ describe('issue 262 repository regressions', () => { const manifest = JSON.parse(readFileSync('package.json', 'utf8')); const lock = JSON.parse(readFileSync('package-lock.json', 'utf8')); for (const name of ['command-stream', 'lino-arguments']) { - assert.match(manifest.devDependencies[name], /^\d+\.\d+\.\d+$/); + const pinnedVersion = + manifest.dependencies?.[name] ?? manifest.devDependencies?.[name]; + assert.match(pinnedVersion, /^\d+\.\d+\.\d+$/); assert.equal( lock.packages[`node_modules/${name}`].version, - manifest.devDependencies[name] + pinnedVersion ); assert.match(lock.packages[`node_modules/${name}`].integrity, /^sha512-/); } diff --git a/tests/package-metadata.test.js b/tests/package-metadata.test.js index 74701ad..1d7e0d5 100644 --- a/tests/package-metadata.test.js +++ b/tests/package-metadata.test.js @@ -37,18 +37,17 @@ function windowsSymlinkSkipReason() { const symlinkSkipReason = windowsSymlinkSkipReason(); describe('publishable package metadata', () => { - it('uses the real link-foundation example package name', () => { - expect(packageJson.name).toBe('@link-foundation/example-package-name'); + it('uses the real link-foundation code evolution package name', () => { + expect(packageJson.name).toBe('@link-foundation/code-evolution'); expect(packageJson.publishConfig).toEqual({ access: 'public' }); - expect(lockJson.name).toBe('@link-foundation/example-package-name'); - expect(lockJson.packages[''].name).toBe( - '@link-foundation/example-package-name' - ); + expect(lockJson.name).toBe('@link-foundation/code-evolution'); + expect(lockJson.packages[''].name).toBe('@link-foundation/code-evolution'); }); it('defines a globally installable CLI command', () => { expect(packageJson.bin).toEqual({ 'example-package-name': './bin/example-package-name.js', + 'code-evolution': './bin/code-evolution.js', }); expect(existsSync('bin/example-package-name.js')).toBe(true); }); @@ -106,6 +105,7 @@ describe('publishable package metadata', () => { 'CHANGELOG.md', 'LICENSE', 'README.md', + 'THIRD-PARTY-NOTICES.md', ]); }); }); diff --git a/tests/release-preflight.test.js b/tests/release-preflight.test.js index 01ca12f..927d373 100644 --- a/tests/release-preflight.test.js +++ b/tests/release-preflight.test.js @@ -175,7 +175,7 @@ describe('release-preflight probe behaviour (offline, curl stub)', () => { 'audience=npm%3Aregistry.npmjs.org' ); expect(readFileSync(join(fixtures, 'requests'), 'utf8')).toContain( - '/exchange/package/%40link-foundation%2Fexample-package-name' + '/exchange/package/%40link-foundation%2Fcode-evolution' ); expect(stdout).not.toContain('private-fixture'); } @@ -422,16 +422,16 @@ describe('npm OIDC package exchange regression', () => { [ 404, [ - 'npm has no package @link-foundation/example-package-name yet', + 'npm has no package @link-foundation/code-evolution yet', 'Add an NPM_TOKEN repository secret', 'https://github.com/acme/widget/settings/secrets/actions', - 'add a trusted publisher for acme/widget, workflow release.yml, at https://www.npmjs.com/package/@link-foundation/example-package-name/access', + 'add a trusted publisher for acme/widget, workflow release.yml, at https://www.npmjs.com/package/@link-foundation/code-evolution/access', ], ], [ 200, [ - 'npm rejected the OIDC exchange for @link-foundation/example-package-name (404): add a trusted publisher for acme/widget', + 'npm rejected the OIDC exchange for @link-foundation/code-evolution (404): add a trusted publisher for acme/widget', ], ], ['000', ['the package lookup answered 000']], @@ -455,7 +455,7 @@ describe('npm OIDC package exchange regression', () => { } expect(stdout).toContain('::error::release-preflight: npm '); expect(readFileSync(join(fixtures, 'requests'), 'utf8')).toContain( - 'https://registry.npmjs.org/%40link-foundation%2Fexample-package-name' + 'https://registry.npmjs.org/%40link-foundation%2Fcode-evolution' ); } );