Skip to content

Pin jscpd version in setup-duplicates-analysis and analyze-duplicates - #45

Merged
CodyCBakerPhD merged 5 commits into
masterfrom
enh-pin-jscpd
Nov 13, 2026
Merged

CodyCBakerPhD merged 5 commits into
masterfrom
enh-pin-jscpd

Conversation

@yarikoptic

@yarikoptic yarikoptic commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Replace jscpd@latest with a version resolved once per run in setup-duplicates-analysis and analyze-duplicates. With @latest, a new jscpd release can change parsing or config, or fail on its own, so an unchanged commit can start failing CI later. Copilot flagged exactly that in the tools/check-duplication.sh this skill generated for con/duct#450.

  • setup-duplicates-analysis uses one <PINNED_VERSION> for the baseline, the report, the mitigation re-checks, and the pre-commit hook rev or wrapper script it commits into the target project. That version is the one the project already pins, if any (Step 0.1 now searches for it, CI workflows included), otherwise npm view jscpd version. An existing setup that still runs jscpd@latest, or whose runners pin different versions, counts as partially wired, so the skill pins it instead of stopping at "already clean".
  • analyze-duplicates fixes one version for the whole run and gets a new --jscpd-version flag, so setup's report uses the same version that the project's check is pinned to. Without the flag it uses the installed jscpd's version, else the current release.
  • PINNED_VERSION is a text placeholder the agent fills in, like the skills' other values, not a shell variable: unset, jscpd@ resolves to latest and would silently undo the pin.

This was left out of #15: it was committed locally but not pushed before #15 merged.

Test plan

  • tox -e validate,security-static
  • Dry run of the version-related steps of both skills on throwaway projects (no flag, --jscpd-version 5.4.2, fresh setup with the wrapper script, existing wrapper and hook pins)

🤖 Generated with Claude Code

https://claude.ai/code/session_01PvaGRYu7bNGqsozPje18f8

`jscpd@latest` is non-reproducible: a future release can change
parsing/config or fail independently of any repository change,
turning an unchanged commit into a failing CI job later.

setup-duplicates-analysis resolves a version once per session and uses
it everywhere: baseline, the wrapper script committed into the target
project, the report, and the mitigation loop's re-checks.
analyze-duplicates likewise fixes one version per run and accepts
--jscpd-version so setup's report matches the pin its CI enforces.

Prompted by Copilot flagging `jscpd@latest` in con/duct#450's
generated tools/check-duplication.sh.  Originally a3f3cba, which was
not pushed before #15 merged.

Co-Authored-By: Claude Code 2.1.322 / Claude Opus 5.5 <noreply@anthropic.com>

@yarikoptic-gitmate yarikoptic-gitmate left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head 060078d. Pinning is the right change, and CI is green. Two things should be fixed before merge, because each one lets a run fall back to an unpinned jscpd without anyone noticing. The rest is recommended tidying that makes the files shorter, not longer. All points have inline suggestions except the last one, whose lines are outside the diff.

Should fix

  1. analyze-duplicates Step 1 gives no version when jscpd is installed. command -v jscpd prints a path, so there is no number to pin. Suggestion inline (lines 65-76), plus a one-word follow-on at line 43.
  2. ${PINNED_VERSION} is a shell variable nothing assigns. Unset, it becomes jscpd@, which npx resolves to latest with exit 0 (checked here: it printed jscpd 5.4.3). The files' existing placeholder forms avoid that: PINNED_VERSION in analyze-duplicates (lines 91, 149) and <PINNED_VERSION> in setup-duplicates-analysis (lines 309, 629, 667). The wrapper script's own ${JSCPD_VERSION} (lines 400, 411) is assigned inside the script and is correct as is.

Recommended

  1. Prerequisites bullet in setup-duplicates-analysis (lines 44-53): reuse the pin the project already has before resolving a new one, drop "(or globally installed)", and shrink it from ten lines to four. Suggestion inline.
  2. Step 4.0 uses a second placeholder for the same value. On the pre-commit path the pin CI enforces is the hook rev, written v<VERSION>, and nothing ties it to <PINNED_VERSION>, which the baseline, report and re-checks use. Upstream tags are v plus the npm version (the hook at v5.4.3 pins jscpd==5.4.3), so one placeholder is right for both:
    • line 352: rev: v<PINNED_VERSION> # pre-commit autoupdate bumps it
    • line 369: additional_dependencies: ["jscpd@<PINNED_VERSION>"]

Not for this PR

review-repo-code-quality and review-org-code-quality could later pass --jscpd-version to analyze-duplicates. That changes what their runs do, so it would be a separate PR with a MINOR bump of both.

Neither touched skill declares version:, so the skill-version rule asks for nothing here.


Generated by Claude Code

Comment thread skills/analyze-duplicates/SKILL.md Resolved
Comment thread skills/analyze-duplicates/SKILL.md Resolved
Comment thread skills/analyze-duplicates/SKILL.md Resolved
Comment thread skills/analyze-duplicates/SKILL.md Resolved
CodyCBakerPhD and others added 2 commits November 12, 2026 13:39
PINNED_VERSION was written as a shell variable that nothing assigns;
unset, `jscpd@` resolves to latest and silently undoes the pin. It is
now a text placeholder like the skills' other values.

analyze-duplicates: take the default from `jscpd --version` so an
installed jscpd also yields a version.

setup-duplicates-analysis: use the version the project already pins
(Step 0.1 now looks for it, CI workflows included); a setup that still
runs jscpd@latest or mixes versions counts as partially wired; the
pre-commit hook rev uses the same version, with a fallback when
upstream has no such tag.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PvaGRYu7bNGqsozPje18f8

Copy link
Copy Markdown
Contributor

312419d addresses all eight review threads, mostly as suggested:

  • PINNED_VERSION is a text placeholder everywhere (jscpd@PINNED_VERSION in analyze-duplicates, jscpd@<PINNED_VERSION> in setup-duplicates-analysis), and both skills say so.
  • analyze-duplicates Step 1 uses jscpd --version 2>/dev/null || npx --yes jscpd@latest --version, with "If neither works" back next to the check. The check is skipped when --jscpd-version is given.
  • The setup-duplicates-analysis Prerequisites bullet is shortened: the project's existing pin first, else npm view jscpd version; no more "(or globally installed)".

Beyond the suggestions, in setup-duplicates-analysis:

  • Step 0.1 searches for an existing pin (wrapper, dependency, CI workflow, hook rev). A package.json range is not a pin; the lockfile's version is.
  • A setup that still runs jscpd@latest or mixes versions is "partially wired", so it gets pinned instead of stopping at "already clean".
  • The pre-commit hook uses rev: v<PINNED_VERSION>, with the repo: local hook as fallback when upstream has no such tag (e.g. there is no v4.0.5).

Not changed here, both older than this PR:

  • review-repo-code-quality and review-org-code-quality ask for consent only when command -v jscpd finds nothing, but every scan goes through npx --yes jscpd@<version>, which can fetch from npm even with jscpd installed.
  • analyze-duplicates names the HTML report html/index.html; jscpd 5.4.x wrote jscpd-report.html in one dry run.

Generated by Claude Code

@yarikoptic-gitmate yarikoptic-gitmate left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of head 312419d. All four points from the first review are resolved, and CI is green:

  • analyze-duplicates Step 1 yields a version with or without an installed jscpd.
  • PINNED_VERSION is a text placeholder everywhere; no ${PINNED_VERSION} is left in either skill.
  • The Prerequisites bullet is six lines, with the project's existing pin first.
  • The pre-commit hook rev and the repo: local fallback use <PINNED_VERSION>.

The Step 0.1 search for an existing pin and the "partially wired" rule for unpinned or mixed setups are consistent with the 0.3 table and Steps 4, 7 and 9 on every path I walked.

Two statements in the text this commit added are factually off and should be fixed; both have inline suggestions that keep the line count the same or lower:

  1. npm ls jscpd does not read the lockfile (line 127), and a bare npx jscpd is pinned once npm ci has run.
  2. The upstream-tag bullet (lines 383-385): tags go back to v1.0.0, and the hook only works from v5.2.1, so a version test replaces the ls-remote test.

Two optional nits are inline (a wider grep pattern, a shorter parenthetical). Nothing else to request.


Generated by Claude Code

Comment thread skills/analyze-duplicates/SKILL.md Resolved
Read a package.json range's version from the lockfile with
`npm ls jscpd --package-lock-only` (plain `npm ls` reads node_modules),
and do not count a bare `npx jscpd` that follows `npm ci` as unpinned.

The upstream pre-commit hook works from v5.2.1 (language: python), not
v5.3.0; below that use the repo: local hook, so the tag lookup goes.

The pin search also matches `JSCPD_VERSION: X` and `jscpd==X`, and the
version-output example no longer claims a format that 5.0.x contradicts.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PvaGRYu7bNGqsozPje18f8

@yarikoptic-gitmate yarikoptic-gitmate left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of head f10ce92 (12 lines changed since 312419d). All four points from the previous review are resolved, and I am resolving their threads:

  • The lockfile lookup is npm ls jscpd --package-lock-only.
  • The bare npx jscpd exception is narrower than I suggested (jscpd in package-lock.json and npm ci run first), which is the more accurate rule.
  • The hook bullet is a version test (below 5.2.1 use the repo: local hook), the ls-remote step is gone, and the earlier bullet now says "Since v5.2.1", so the two agree.
  • The wider grep pattern and the shorter version-output parenthetical are in. I re-ran the pattern on a small fixture: it matches the env: form, jscpd==, jscpd@ and the package.json range, and skips - id: jscpd and a bare npx jscpd ..

No further requests from me. CI on this head was still running when I looked (validate passed; apm, security-static and security-deps in progress).


Generated by Claude Code

@yarikoptic

Copy link
Copy Markdown
Member Author

Anyone else to review approve merge?

@CodyCBakerPhD
CodyCBakerPhD merged commit b510d9e into master Nov 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants