Fix inaccurate syllable counting - #2
Conversation
Reviewer's GuideReplaces the extension’s naive syllable counter with the Sequence diagram for dynamic syllable import and fallbacksequenceDiagram
actor User
participant VSCodeExtension
participant syllableModule
VSCodeExtension->>syllableModule: import('syllable')
syllableModule-->>VSCodeExtension: syllable
User->>VSCodeExtension: countSyllables(text)
VSCodeExtension->>syllableModule: syllable(text)
alt [syllable(text) throws or import failed]
VSCodeExtension->>VSCodeExtension: [fallback vowel count]
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 10 security issues, 1 other issue, and left some high level feedback:
Security issues:
- SEE LICENSE IN LICENSE.txt: Open-source license could not be identified (link)
- SEE LICENSE IN LICENSE.txt: Open-source license could not be identified (link)
- SEE LICENSE IN LICENSE.txt: Open-source license could not be identified (link)
- SEE LICENSE IN LICENSE.txt: Open-source license could not be identified (link)
- SEE LICENSE IN LICENSE.txt: Open-source license could not be identified (link)
- SEE LICENSE IN LICENSE.txt: Open-source license could not be identified (link)
- SEE LICENSE IN LICENSE.txt: Open-source license could not be identified (link)
- SEE LICENSE IN LICENSE.txt: Open-source license could not be identified (link)
- SEE LICENSE IN LICENSE.txt: Open-source license could not be identified (link)
- SEE LICENSE IN LICENSE.txt: Open-source license could not be identified (link)
General comments:
- The async dynamic import of
syllableruns at module load time andcountSyllablesmay be invoked before it resolves, so if accuracy is important you may want to move the import intoactivateor expose a readiness check instead of silently falling back to the simple vowel counter. - You’ve committed
dist/extension.jsand its source map; consider excluding built artifacts via.gitignoreto avoid noisy diffs and potential merge conflicts in future changes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The async dynamic import of `syllable` runs at module load time and `countSyllables` may be invoked before it resolves, so if accuracy is important you may want to move the import into `activate` or expose a readiness check instead of silently falling back to the simple vowel counter.
- You’ve committed `dist/extension.js` and its source map; consider excluding built artifacts via `.gitignore` to avoid noisy diffs and potential merge conflicts in future changes.
## Individual Comments
### Comment 1
<location path="src/extension.ts" line_range="4" />
<code_context>
import * as vscode from 'vscode';
+// Fallback: simple vowel-count function
+let syllableFn: (text: string) => number = (text: string) => {
+ const m = text.match(/[aeiouy]/gi);
+ return m ? m.length : 0;
+};
</code_context>
<issue_to_address>
**issue:** Fallback syllable counting drops support for Cyrillic vowels that the previous implementation handled.
Previously, vowels were matched with `[аеёиоуыэюяaeiouy]`, but both the top-level fallback and this inner fallback now use only `[aeiouy]`, which removes Russian support. If Cyrillic handling is still required, restore the broader character class in both places.
</issue_to_address>
### Comment 2
<location path="package-lock.json" line_range="1291-1309" />
<code_context>
</code_context>
<issue_to_address>
**security (license/@vscode/vsce-sign):** SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the `SEE LICENSE IN LICENSE.txt` license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
*Source: trivy*
</issue_to_address>
### Comment 3
<location path="package-lock.json" line_range="1310-1323" />
<code_context>
</code_context>
<issue_to_address>
**security (license/@vscode/vsce-sign-alpine-arm64):** SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the `SEE LICENSE IN LICENSE.txt` license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
*Source: trivy*
</issue_to_address>
### Comment 4
<location path="package-lock.json" line_range="1324-1337" />
<code_context>
</code_context>
<issue_to_address>
**security (license/@vscode/vsce-sign-alpine-x64):** SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the `SEE LICENSE IN LICENSE.txt` license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
*Source: trivy*
</issue_to_address>
### Comment 5
<location path="package-lock.json" line_range="1338-1351" />
<code_context>
</code_context>
<issue_to_address>
**security (license/@vscode/vsce-sign-darwin-arm64):** SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the `SEE LICENSE IN LICENSE.txt` license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
*Source: trivy*
</issue_to_address>
### Comment 6
<location path="package-lock.json" line_range="1352-1365" />
<code_context>
</code_context>
<issue_to_address>
**security (license/@vscode/vsce-sign-darwin-x64):** SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the `SEE LICENSE IN LICENSE.txt` license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
*Source: trivy*
</issue_to_address>
### Comment 7
<location path="package-lock.json" line_range="1366-1379" />
<code_context>
</code_context>
<issue_to_address>
**security (license/@vscode/vsce-sign-linux-arm):** SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the `SEE LICENSE IN LICENSE.txt` license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
*Source: trivy*
</issue_to_address>
### Comment 8
<location path="package-lock.json" line_range="1380-1393" />
<code_context>
</code_context>
<issue_to_address>
**security (license/@vscode/vsce-sign-linux-arm64):** SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the `SEE LICENSE IN LICENSE.txt` license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
*Source: trivy*
</issue_to_address>
### Comment 9
<location path="package-lock.json" line_range="1394-1407" />
<code_context>
</code_context>
<issue_to_address>
**security (license/@vscode/vsce-sign-linux-x64):** SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the `SEE LICENSE IN LICENSE.txt` license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
*Source: trivy*
</issue_to_address>
### Comment 10
<location path="package-lock.json" line_range="1408-1421" />
<code_context>
</code_context>
<issue_to_address>
**security (license/@vscode/vsce-sign-win32-arm64):** SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the `SEE LICENSE IN LICENSE.txt` license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
*Source: trivy*
</issue_to_address>
### Comment 11
<location path="package-lock.json" line_range="1422-1435" />
<code_context>
</code_context>
<issue_to_address>
**security (license/@vscode/vsce-sign-win32-x64):** SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the `SEE LICENSE IN LICENSE.txt` license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
*Source: trivy*
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| import * as vscode from 'vscode'; | ||
| // Fallback: simple vowel-count function | ||
| let syllableFn: (text: string) => number = (text: string) => { | ||
| const m = text.match(/[aeiouy]/gi); |
There was a problem hiding this comment.
issue: Fallback syllable counting drops support for Cyrillic vowels that the previous implementation handled.
Previously, vowels were matched with [аеёиоуыэюяaeiouy], but both the top-level fallback and this inner fallback now use only [aeiouy], which removes Russian support. If Cyrillic handling is still required, restore the broader character class in both places.
| "node_modules/@vscode/vsce-sign": { | ||
| "version": "2.0.5", | ||
| "resolved": "https://registry.npmjs.org/@vscode/vsce-sign/-/vsce-sign-2.0.5.tgz", | ||
| "integrity": "sha512-GfYWrsT/vypTMDMgWDm75iDmAOMe7F71sZECJ+Ws6/xyIfmB3ELVnVN+LwMFAvmXY+e6eWhR2EzNGF/zAhWY3Q==", | ||
| "dev": true, | ||
| "hasInstallScript": true, | ||
| "license": "SEE LICENSE IN LICENSE.txt", | ||
| "optionalDependencies": { | ||
| "@vscode/vsce-sign-alpine-arm64": "2.0.2", | ||
| "@vscode/vsce-sign-alpine-x64": "2.0.2", | ||
| "@vscode/vsce-sign-darwin-arm64": "2.0.2", | ||
| "@vscode/vsce-sign-darwin-x64": "2.0.2", | ||
| "@vscode/vsce-sign-linux-arm": "2.0.2", | ||
| "@vscode/vsce-sign-linux-arm64": "2.0.2", | ||
| "@vscode/vsce-sign-linux-x64": "2.0.2", | ||
| "@vscode/vsce-sign-win32-arm64": "2.0.2", | ||
| "@vscode/vsce-sign-win32-x64": "2.0.2" | ||
| } | ||
| }, |
There was a problem hiding this comment.
security (license/@vscode/vsce-sign): SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the SEE LICENSE IN LICENSE.txt license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
Source: trivy
| "node_modules/@vscode/vsce-sign-alpine-arm64": { | ||
| "version": "2.0.2", | ||
| "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-alpine-arm64/-/vsce-sign-alpine-arm64-2.0.2.tgz", | ||
| "integrity": "sha512-E80YvqhtZCLUv3YAf9+tIbbqoinWLCO/B3j03yQPbjT3ZIHCliKZlsy1peNc4XNZ5uIb87Jn0HWx/ZbPXviuAQ==", | ||
| "cpu": [ | ||
| "arm64" | ||
| ], | ||
| "dev": true, | ||
| "license": "SEE LICENSE IN LICENSE.txt", | ||
| "optional": true, | ||
| "os": [ | ||
| "alpine" | ||
| ] | ||
| }, |
There was a problem hiding this comment.
security (license/@vscode/vsce-sign-alpine-arm64): SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the SEE LICENSE IN LICENSE.txt license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
Source: trivy
| "node_modules/@vscode/vsce-sign-alpine-x64": { | ||
| "version": "2.0.2", | ||
| "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-alpine-x64/-/vsce-sign-alpine-x64-2.0.2.tgz", | ||
| "integrity": "sha512-n1WC15MSMvTaeJ5KjWCzo0nzjydwxLyoHiMJHu1Ov0VWTZiddasmOQHekA47tFRycnt4FsQrlkSCTdgHppn6bw==", | ||
| "cpu": [ | ||
| "x64" | ||
| ], | ||
| "dev": true, | ||
| "license": "SEE LICENSE IN LICENSE.txt", | ||
| "optional": true, | ||
| "os": [ | ||
| "alpine" | ||
| ] | ||
| }, |
There was a problem hiding this comment.
security (license/@vscode/vsce-sign-alpine-x64): SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the SEE LICENSE IN LICENSE.txt license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
Source: trivy
| "node_modules/@vscode/vsce-sign-darwin-arm64": { | ||
| "version": "2.0.2", | ||
| "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-darwin-arm64/-/vsce-sign-darwin-arm64-2.0.2.tgz", | ||
| "integrity": "sha512-rz8F4pMcxPj8fjKAJIfkUT8ycG9CjIp888VY/6pq6cuI2qEzQ0+b5p3xb74CJnBbSC0p2eRVoe+WgNCAxCLtzQ==", | ||
| "cpu": [ | ||
| "arm64" | ||
| ], | ||
| "dev": true, | ||
| "license": "SEE LICENSE IN LICENSE.txt", | ||
| "optional": true, | ||
| "os": [ | ||
| "darwin" | ||
| ] | ||
| }, |
There was a problem hiding this comment.
security (license/@vscode/vsce-sign-darwin-arm64): SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the SEE LICENSE IN LICENSE.txt license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
Source: trivy
| "node_modules/@vscode/vsce-sign-linux-arm": { | ||
| "version": "2.0.2", | ||
| "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-linux-arm/-/vsce-sign-linux-arm-2.0.2.tgz", | ||
| "integrity": "sha512-Fkb5jpbfhZKVw3xwR6t7WYfwKZktVGNXdg1m08uEx1anO0oUPUkoQRsNm4QniL3hmfw0ijg00YA6TrxCRkPVOQ==", | ||
| "cpu": [ | ||
| "arm" | ||
| ], | ||
| "dev": true, | ||
| "license": "SEE LICENSE IN LICENSE.txt", | ||
| "optional": true, | ||
| "os": [ | ||
| "linux" | ||
| ] | ||
| }, |
There was a problem hiding this comment.
security (license/@vscode/vsce-sign-linux-arm): SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the SEE LICENSE IN LICENSE.txt license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
Source: trivy
| "node_modules/@vscode/vsce-sign-linux-arm64": { | ||
| "version": "2.0.2", | ||
| "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-linux-arm64/-/vsce-sign-linux-arm64-2.0.2.tgz", | ||
| "integrity": "sha512-Ybeu7cA6+/koxszsORXX0OJk9N0GgfHq70Wqi4vv2iJCZvBrOWwcIrxKjvFtwyDgdeQzgPheH5nhLVl5eQy7WA==", | ||
| "cpu": [ | ||
| "arm64" | ||
| ], | ||
| "dev": true, | ||
| "license": "SEE LICENSE IN LICENSE.txt", | ||
| "optional": true, | ||
| "os": [ | ||
| "linux" | ||
| ] | ||
| }, |
There was a problem hiding this comment.
security (license/@vscode/vsce-sign-linux-arm64): SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the SEE LICENSE IN LICENSE.txt license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
Source: trivy
| "node_modules/@vscode/vsce-sign-linux-x64": { | ||
| "version": "2.0.2", | ||
| "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-linux-x64/-/vsce-sign-linux-x64-2.0.2.tgz", | ||
| "integrity": "sha512-NsPPFVtLaTlVJKOiTnO8Cl78LZNWy0Q8iAg+LlBiCDEgC12Gt4WXOSs2pmcIjDYzj2kY4NwdeN1mBTaujYZaPg==", | ||
| "cpu": [ | ||
| "x64" | ||
| ], | ||
| "dev": true, | ||
| "license": "SEE LICENSE IN LICENSE.txt", | ||
| "optional": true, | ||
| "os": [ | ||
| "linux" | ||
| ] | ||
| }, |
There was a problem hiding this comment.
security (license/@vscode/vsce-sign-linux-x64): SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the SEE LICENSE IN LICENSE.txt license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
Source: trivy
| "node_modules/@vscode/vsce-sign-win32-arm64": { | ||
| "version": "2.0.2", | ||
| "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-win32-arm64/-/vsce-sign-win32-arm64-2.0.2.tgz", | ||
| "integrity": "sha512-wPs848ymZ3Ny+Y1Qlyi7mcT6VSigG89FWQnp2qRYCyMhdJxOpA4lDwxzlpL8fG6xC8GjQjGDkwbkWUcCobvksQ==", | ||
| "cpu": [ | ||
| "arm64" | ||
| ], | ||
| "dev": true, | ||
| "license": "SEE LICENSE IN LICENSE.txt", | ||
| "optional": true, | ||
| "os": [ | ||
| "win32" | ||
| ] | ||
| }, |
There was a problem hiding this comment.
security (license/@vscode/vsce-sign-win32-arm64): SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the SEE LICENSE IN LICENSE.txt license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
Source: trivy
| "node_modules/@vscode/vsce-sign-win32-x64": { | ||
| "version": "2.0.2", | ||
| "resolved": "https://registry.npmjs.org/@vscode/vsce-sign-win32-x64/-/vsce-sign-win32-x64-2.0.2.tgz", | ||
| "integrity": "sha512-pAiRN6qSAhDM5SVOIxgx+2xnoVUePHbRNC7OD2aOR3WltTKxxF25OfpK8h8UQ7A0BuRkSgREbB59DBlFk4iAeg==", | ||
| "cpu": [ | ||
| "x64" | ||
| ], | ||
| "dev": true, | ||
| "license": "SEE LICENSE IN LICENSE.txt", | ||
| "optional": true, | ||
| "os": [ | ||
| "win32" | ||
| ] | ||
| }, |
There was a problem hiding this comment.
security (license/@vscode/vsce-sign-win32-x64): SEE LICENSE IN LICENSE.txt: Open-source license could not be identified
The obligations of the SEE LICENSE IN LICENSE.txt license for this code could not be determined automatically. Unknown licenses may carry obligations or restrictions and should be reviewed manually to ensure compliance
Source: trivy
There was a problem hiding this comment.
🟡 Not ready to approve
The update introduces a Cyrillic syllable-count regression and an invalid self-referential file: dependency that will break installs/packaging.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR updates the VS Code extension’s syllable counting to use the external syllable library (with fallback behavior) and adjusts build/packaging configuration to support bundling and VSIX creation.
Changes:
- Replace naive syllable counting with a dynamically-loaded
syllablelibrary implementation plus fallback logic. - Update TypeScript config for interop and update npm tooling/scripts for VSIX packaging.
- Commit built extension artifacts to
dist/.
File summaries
| File | Description |
|---|---|
| tsconfig.json | Enables ESM/CJS interop options needed by the updated import/build flow. |
| src/extension.ts | Switches syllable counting to syllable with fallback logic. |
| package.json | Adds syllable dependency and VSIX packaging tooling/script. |
| package-lock.json | Locks new dependency/tooling additions. |
| dist/extension.js | Adds compiled/bundled extension output for distribution. |
| dist/extension.js.map | Adds source map for the compiled extension output. |
| .gitignore | Adds node_modules to ignored files. |
Review details
Suppressed comments (1)
src/extension.ts:33
syllableis an English syllable counter; for Cyrillic lines it will typically return 0 without throwing, so we never hit the fallback and end up hiding syllable counts for Russian text. Consider bypassing the library for Cyrillic input (and optionally falling back when the library returns 0 but vowels exist).
function countSyllables(text: string): number {
try {
return syllableFn(text);
} catch {
// Should never throw, but fallback to vowel count
- Files reviewed: 2/11 changed files
- Comments generated: 2
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| // Fallback: simple vowel-count function | ||
| let syllableFn: (text: string) => number = (text: string) => { | ||
| const m = text.match(/[aeiouy]/gi); | ||
| return m ? m.length : 0; | ||
| }; |
| "dependencies": { | ||
| "poetmeter": "file:" | ||
| "poetmeter": "file:", | ||
| "syllable": "^5.0.1" | ||
| } |
fixes a bug where syllables are counted inaccurately
Summary by Sourcery
Improve syllable counting accuracy in the VS Code extension by integrating an external syllable library with a safe fallback and adjust project configuration accordingly.
New Features:
syllablelibrary to provide more accurate syllable counts within the extension.Bug Fixes:
Enhancements:
dist/extension.jsbundle for distribution.Build:
@vscode/vsceas a dev dependency and introduce an npmvsixscript to package the extension.