Remove extractor logic from CLI package and use the extractor from @dittowords/text-extract library - #151
Merged
Merged
Conversation
…ittowords/text-extract package
This was referenced Aug 17, 2026
laurakoye
approved these changes
Aug 17, 2026
laurakoye
left a comment
Contributor
There was a problem hiding this comment.
All the testing steps were good except there is no summary.ndjson specifically, but I did see: [ditto-cli scan][extract] framework: react output in stderr
laurakoye
approved these changes
Aug 17, 2026
laurakoye
left a comment
Contributor
There was a problem hiding this comment.
All the testing steps were good except there is no summary.ndjson specifically, but I did see: [ditto-cli scan][extract] framework: react output in stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR removes the extractor code from the CLI. The CLI now calls the
@dittowords/text-extractpackage instead.Changes:
@dittowords/text-extract@^0.2.0as a dependency.lib/src/scan/extract.ts,walk.ts,rules.tsandtypes.ts.lib/src/scan/lang/directory containing all the extractors.runExtract,DittoScanCandidateandDittoScanExtractSummaryfromthe package.
lib/ditto.ts.lib/src/scan/extract.test.ts. This test confirms that the CLI resolvesthe package.
Removed dependencies
@ast-grep/napi@ast-grep/lang-kotlin@ast-grep/lang-swiftglobbyyaml@google/genaimaster.Logging change
Previously,
runExtractwrote each failure to stderr at the moment of the failure.The package returns
summary.filesFailedandsummary.failuresinstead, andlogExtractSummarynow prints them.Two limits apply to the new report:
filesFailedcount stays exact.logExtractSummaryruns at the end of the command. On the remote path it runs only afterinitiateClassifysucceeds. A classify failure hides the report.This is the only behavior change. The candidate output does not change.
Context
The extractor code was originally in the CLI repo, but we ported it to a standalone package so that the Ditto app can more easily reuse it for work on local flows. A future GitHub scan originating from the main app's UI can re-use the same code.
Testing
I scanned the
v0-demorepository twice, first against currentmasterand then again on this branch.v0-democovers a good basis of extractor functionality (at least as far as TS goes). I also ran the same check against a couple other smaller test repos.The two scans resulted in the exact same 182 candidatese.
detection_kindlanguagelocale_keylocation.file--list-directoriesbreakdownScreenshots
Test Plan
Setup
yarn install. Confirm that yarn installs@dittowords/text-extract.Unit tests
yarn buildand confirm build passes.yarn test. Confirm all unit tests pass.Scan a repository
yarn scan <path-to-a-frontend-repo> --local --out-dir /tmp/scan-app./tmp/scan-appand open summary.ndjson. Confirm that the summary reports the correct framework tokens, for examplereact, next.candidates.ndjson) and reports no failed files.Compare same repo against
mastermaster. Runyarn installandyarn scan <path-to-a-frontend-repo> --local --out-dir /tmp/scan-master.sort /tmp/scan-master/candidates.ndjson > /tmp/a.sort /tmp/scan-v0/candidates.ndjson > /tmp/b. (need to do these sorts because the globby package's file traversal is non-deterministic due to parallelization)diff /tmp/a /tmp/b. Confirm that the command reports no difference.