pi-jscpd 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/CONTRIBUTING.md +144 -0
  3. package/LICENSE +21 -0
  4. package/README.md +231 -0
  5. package/SECURITY.md +93 -0
  6. package/docs/automatic-checkpoint.md +235 -0
  7. package/docs/compatibility.md +119 -0
  8. package/docs/effect-architecture.md +128 -0
  9. package/docs/fallow-coexistence.md +120 -0
  10. package/docs/overlay-interaction.md +347 -0
  11. package/docs/release.md +115 -0
  12. package/package.json +86 -0
  13. package/scripts/check-compatibility.mjs +103 -0
  14. package/skills/jscpd/SKILL.md +90 -0
  15. package/src/acknowledgements.ts +268 -0
  16. package/src/automatic.ts +396 -0
  17. package/src/baseline.ts +400 -0
  18. package/src/capability.ts +569 -0
  19. package/src/changed-files.ts +372 -0
  20. package/src/changed.ts +548 -0
  21. package/src/clone-identity.ts +373 -0
  22. package/src/config.ts +414 -0
  23. package/src/contract.ts +39 -0
  24. package/src/dispatch.ts +90 -0
  25. package/src/effect/clock.ts +10 -0
  26. package/src/effect/errors.ts +311 -0
  27. package/src/effect/filesystem.ts +240 -0
  28. package/src/effect/runtime-boundary.ts +25 -0
  29. package/src/effect/runtime-contract.ts +18 -0
  30. package/src/effect/services.ts +131 -0
  31. package/src/extension.ts +708 -0
  32. package/src/fallow.ts +479 -0
  33. package/src/finding-presentation.ts +73 -0
  34. package/src/index.ts +8 -0
  35. package/src/jscpd-report.ts +819 -0
  36. package/src/jscpd.ts +748 -0
  37. package/src/overlay.ts +1166 -0
  38. package/src/parser.ts +189 -0
  39. package/src/path-utils.ts +44 -0
  40. package/src/presentation.ts +232 -0
  41. package/src/process.ts +425 -0
  42. package/src/registry.ts +102 -0
  43. package/src/scan.ts +441 -0
  44. package/src/scheduler.ts +434 -0
  45. package/src/session-state.ts +229 -0
  46. package/src/status.ts +534 -0
  47. package/src/types.ts +334 -0
  48. package/src/value-utils.ts +14 -0
  49. package/src/verification.ts +220 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,99 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
6
+ published releases use [Semantic Versioning](https://semver.org/).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2026-09-05
11
+
12
+ ### Added
13
+
14
+ - Pi-native `jscpd_run` tool and namespaced `/jscpd` command surface.
15
+ - Pinned jscpd `5.1.2` runtime dependency with project-local, `PATH`, and bundled
16
+ resolution, plus bounded shell-free process ownership and no runtime download.
17
+ - Exact Effect `3.22.1` runtime foundation with declarative process, filesystem,
18
+ clock, and Pi service tags, stable typed expected failures, bounded public
19
+ mapping intent, deterministic test layers, and an AST runtime-boundary gate.
20
+ - Effect-owned bounded child processes, process-tree escalation, serialized jscpd
21
+ execution, temporary report workspaces, capability probing/caching, and scoped
22
+ service layers.
23
+ - A shared live bounded-filesystem layer for trusted configuration, canonical
24
+ path validation, report normalization, exact clone-source ranges, and supported
25
+ Fallow signal reads, with typed failures and deterministic test layers.
26
+ - Effect-owned baseline generations, changed-file attribution, acknowledgement
27
+ transactions, verification checkpoints, and typed branch-snapshot persistence,
28
+ with immutable values and lifecycle-scoped state owners.
29
+ - Scoped Effect scheduling for dirty-generation coalescing, automatic changed
30
+ checks, interruption-safe cancellation, and acknowledgement-after-delivery Pi
31
+ transactions without unmanaged background promises or timers.
32
+ - Effect-composed scan, changed, status/session-control, Fallow coexistence,
33
+ report-decoding, and verification workflows with unchanged bounded public
34
+ results.
35
+ - One managed Effect runtime and production process/filesystem/clock layer graph
36
+ per extension instance, with native Pi cancellation, effectful dispatch,
37
+ idempotent finalizer-aware shutdown, and no nested command/overlay runtimes.
38
+ - Strict normalized jscpd JSON report validation and scope-safe explicit scans.
39
+ - Trusted extension configuration, session controls, branch-local state, and
40
+ changed-file attribution.
41
+ - Ephemeral session baselines, content-aware clone identity, changed-only
42
+ findings, acknowledgements, and quiet automatic settled checks.
43
+ - Responsive `/jscpd` overview, shared actionable finding presentation, and
44
+ ephemeral refactor verification.
45
+ - TUI root-subcommand autocomplete for `/jscpd ` with labeled scan, changed,
46
+ status, session-control, and help suggestions.
47
+ - Packaged on-demand `jscpd` skill with polyglot scan routing, result
48
+ interpretation, verification, configuration, Fallow-coexistence, and advisory
49
+ safety guidance.
50
+ - Conservative Pi Fallow coexistence policy with explicit on-demand and allow
51
+ choices.
52
+ - Confirmed `pi-jscpd` package identity and a tested Node/Pi/TypeBox
53
+ compatibility policy.
54
+ - Public CI, dependency-update policy, contribution guidance, security policy,
55
+ issue forms, pull-request guidance, and release ownership.
56
+ - Exact packed-artifact certification with isolated Pi RPC/tool/TUI-compatible,
57
+ JSON, print, process-tree shutdown, and temporary-report cleanup checks.
58
+ - Non-publishing release-readiness workflow, provenance/access intent,
59
+ documentation-link validation, repository-hygiene guards, and release,
60
+ rollback, and post-release policy.
61
+ - A tag-triggered npm trusted-publishing and GitHub Release workflow based on
62
+ `pi-fallow`, protected by release metadata and maintainer-approval guards. Its
63
+ first-publication bootstrap credential is isolated to the lifecycle-disabled
64
+ publish step and removed after `0.1.0`.
65
+
66
+ ### Changed
67
+
68
+ - Reworked the `/jscpd` overlay into a Pi Fallow-style findings navigator with
69
+ framed status/count hierarchy, responsive two-location rows, inline detail,
70
+ search, scrolling, multi-selection, and bounded editor prompt handoff. The
71
+ overlay now retains up to 100 findings in memory, initially reveals 10, and
72
+ loads subsequent 10-item pages manually or when navigation crosses the shown
73
+ boundary without enlarging configured model/tool output or persisted state.
74
+ - Accepted valid jscpd v5 reports whose token-equivalent second occurrence spans
75
+ fewer physical lines than the reporter's first-occurrence line count.
76
+ - Added repository jscpd ignore policy for dependency/build artifacts, caches,
77
+ generated source maps/snapshots, archives, and common polyglot lockfiles.
78
+ - Kept packed-artifact cleanup verification bounded while allowing slower Node 22
79
+ CI runners enough time to observe completed temporary-directory finalization.
80
+ - Removed superseded process, capability, analyzer, configuration,
81
+ Fallow-coexistence, baseline, changed-file, command/status, and
82
+ scheduler/automatic Promise facades; removed the parallel Promise report
83
+ consumer, direct analyzer filesystem workflow, production test runtime, and
84
+ filesystem-backed clone/report test facades. Service workflows now expose only
85
+ their Effect-native production paths; Promise orchestration remains confined to
86
+ reviewed Pi/TUI and filesystem-infrastructure boundaries.
87
+ - Locked existing command/tool, lifecycle, persistence, cancellation, and bounded
88
+ presentation behavior before production Effect workflow migration.
89
+ - Completed the ordered Effect runtime migration, legacy-removal audit,
90
+ documentation pass, supported-Node validation, security checks, and
91
+ exact-tarball recertification required for the first public release.
92
+
93
+ ### Security
94
+
95
+ - Project paths, child output, reports, temporary directories, cancellation,
96
+ configuration trust, and lifecycle cleanup are bounded and fail open.
97
+
98
+ [Unreleased]: https://github.com/revazi/pi-jscpd/compare/v0.1.0...HEAD
99
+ [0.1.0]: https://github.com/revazi/pi-jscpd/releases/tag/v0.1.0
@@ -0,0 +1,144 @@
1
+ # Contributing to pi-jscpd
2
+
3
+ Thanks for helping improve `pi-jscpd`. Changes should preserve the extension's
4
+ quiet, advisory, read-only, bounded, and fail-open behavior. jscpd remains the
5
+ authority for tokenization, clone detection, supported formats, and duplication
6
+ statistics. The Effect runtime architecture is documented in
7
+ [Effect architecture and conformance](docs/effect-architecture.md). Changes must
8
+ preserve those product contracts and the completed runtime boundaries.
9
+
10
+ ## Before opening a change
11
+
12
+ 1. Search the [issue tracker](https://github.com/revazi/pi-jscpd/issues).
13
+ 2. Open or select a focused issue before substantial implementation work.
14
+ 3. Discuss changes to public commands/tools, configuration, persisted session
15
+ state, process ownership, or product invariants before coding.
16
+ 4. For changes to Effect-owned workflows or runtime boundaries, open a focused
17
+ issue and preserve the architecture documented in this repository.
18
+ 5. Report suspected vulnerabilities privately according to
19
+ [SECURITY.md](SECURITY.md), not in a public issue.
20
+
21
+ Feature requests should explain why normal jscpd configuration or Pi's ordinary
22
+ agent flow is insufficient. Do not propose an independent clone detector,
23
+ automatic source edits, surprise binary installation, or mandatory
24
+ JavaScript-only parsing in the core workflow.
25
+
26
+ ## Development setup
27
+
28
+ Use a host from the [compatibility matrix](docs/compatibility.md). Install the
29
+ locked dependencies without changing global Pi configuration:
30
+
31
+ ```text
32
+ npm ci --ignore-scripts
33
+ npm run docs:check
34
+ npm run repo:hygiene
35
+ npm run check
36
+ npm run pack:certify
37
+ npm run pack:dry-run
38
+ ```
39
+
40
+ `npm run check` validates the active Node/Pi/Effect fixtures, enforces the
41
+ approved Effect runtime boundary, type checks strict ESM TypeScript, runs
42
+ Biome's formatting/lint checks, and executes the network-free test suite. The
43
+ documentation and hygiene checks validate public local links, release metadata,
44
+ ignored/private path policy, package metadata, and the non-publishing readiness
45
+ workflow. `pack:certify` installs and exercises the exact tarball.
46
+ CI repeats those checks on Node 22.19.0 and 24.12.0.
47
+
48
+ Tests must not require network access, read or modify global Pi configuration,
49
+ write reports into a source tree, or depend on a separately installed jscpd
50
+ binary. Use deterministic fake executables for controlled reports and process
51
+ lifecycle cases. Capability and packed-artifact checks also probe the exact
52
+ jscpd runtime dependency declared by the package. The repository's Fallow
53
+ configuration records that indirect CLI use and disables Fallow clone detection
54
+ so jscpd remains this project's single duplication authority.
55
+
56
+ ## Effect migration rules
57
+
58
+ - Use Effect for fallible async work, resources, cancellation, concurrency, and
59
+ shared service state—not to decorate pure functions.
60
+ - Declare capabilities with services/layers and keep the single production
61
+ runtime in the Pi composition boundary. Process and filesystem services provide
62
+ live layers but create no independent runtime.
63
+ - Keep `Effect.run*` out of infrastructure, domain, and application modules.
64
+ Only `src/effect/runtime-boundary.ts` may execute production Effect programs;
65
+ do not add another runtime bridge.
66
+ - Add characterization tests before converting a boundary, deterministic test
67
+ layers with the conversion, and interruption/finalizer tests for resources.
68
+ Filesystem changes must preserve trust gating, canonical containment,
69
+ no-follow opens, exact byte bounds, atomic decode rejection, and body-free
70
+ diagnostics. Stateful domain changes must use one owner per layer/facade,
71
+ preserve immutable snapshots and generation/revision checks, and test stale
72
+ completion plus competing updates. Scheduler and automatic-check changes must
73
+ use scoped fibers, preserve explicit-work priority and retry eligibility, and
74
+ commit acknowledgements only after successful quiet Pi delivery. Application
75
+ workflows must compose existing service effects, keep public result mapping at
76
+ one boundary, and leave deterministic comparison/presentation code pure. Only
77
+ `src/effect/runtime-boundary.ts` may execute Effect; production work must use
78
+ the single runtime passed from extension composition.
79
+ - Do not add Promise service facades. Promise workflow orchestration is limited
80
+ to reviewed Pi/TUI host adapters and the filesystem infrastructure boundary;
81
+ characterization adapters belong under `test/support/`.
82
+ - Do not combine a migration slice with unrelated public behavior changes.
83
+
84
+ ## Pull requests
85
+
86
+ Keep one concern per pull request and include:
87
+
88
+ - the problem and user-visible behavior;
89
+ - the issue it closes;
90
+ - tests for success, no-findings, and relevant failure/cancellation paths;
91
+ - documentation for behavior or compatibility changes;
92
+ - for Effect slices, the prerequisite issue, removed legacy path, typed failures,
93
+ layer graph, interruption/finalizer evidence, and approved runtime boundary;
94
+ and
95
+ - exact validation performed.
96
+
97
+ Before requesting review, run:
98
+
99
+ ```text
100
+ npm run format
101
+ npm run docs:check
102
+ npm run repo:hygiene
103
+ npm run check
104
+ npm run pack:certify
105
+ npm run pack:dry-run
106
+ ```
107
+
108
+ The protected `main` branch requires the branch to be current and both
109
+ `Validate (Node 22.19.0)` and `Validate (Node 24.12.0)` to pass. The rule applies
110
+ to administrators, requires resolved review conversations, and blocks force
111
+ pushes and branch deletion. Reviews and CI are evidence, not authorization to
112
+ publish.
113
+
114
+ Keep credentials, proprietary source, source fragments from jscpd reports,
115
+ private paths, generated reports, local overrides, `.agents/`, and `AGENTS.md`
116
+ out of commits. Contributors remain responsible for reviewing and understanding
117
+ all submitted changes, including AI-assisted changes.
118
+
119
+ ## Dependency updates
120
+
121
+ Repository vulnerability alerts and Dependabot security updates are enabled.
122
+ Dependabot also checks direct npm dependencies and GitHub Actions monthly. Pi
123
+ 0.84 patches and compatible development-tooling updates are grouped. Major
124
+ updates to development tools and Pi minor/major updates are ignored because they
125
+ need deliberate recertification. The minimum TypeBox fixture is excluded from
126
+ scheduled version updates and changes only through a focused compatibility
127
+ review; vulnerability alerts and security updates remain enabled. The Effect
128
+ runtime must be exact-pinned and updated only through a focused architecture and
129
+ compatibility review. GitHub Actions are SHA-pinned and updates must retain
130
+ least-privilege permissions.
131
+
132
+ A dependency PR must pass both Node jobs. Pi, TypeBox-major, Node-range, and
133
+ workflow changes also require the manual compatibility evidence described in
134
+ [`docs/compatibility.md`](docs/compatibility.md).
135
+
136
+ ## Release ownership
137
+
138
+ Only [Revaz Zakalashvili](https://github.com/revazi), as package maintainer and
139
+ repository owner, may approve a version, create a tag, configure registry
140
+ publishing, or publish. The manual readiness workflow has no registry credentials
141
+ or write permission and cannot release anything; tagged releases use the
142
+ protected npm workflow. Follow [the release policy](docs/release.md). A
143
+ contributor, reviewer, CODEOWNERS approval, or passing CI does not grant
144
+ publication authority.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Revaz Zakalashvili
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,231 @@
1
+ # pi-jscpd
2
+
3
+ [![CI](https://github.com/revazi/pi-jscpd/actions/workflows/ci.yml/badge.svg)](https://github.com/revazi/pi-jscpd/actions/workflows/ci.yml)
4
+ [![npm](https://img.shields.io/npm/v/pi-jscpd.svg)](https://www.npmjs.com/package/pi-jscpd)
5
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
6
+ [![GitHub issues](https://img.shields.io/github/issues/revazi/pi-jscpd.svg)](https://github.com/revazi/pi-jscpd/issues)
7
+
8
+ A quiet, read-only duplication guardrail for the [Pi coding agent](https://github.com/earendil-works/pi), powered by [jscpd](https://github.com/kucherenko/jscpd).
9
+
10
+ `pi-jscpd` detects duplicate blocks introduced during a Pi session, shows both
11
+ locations, and helps you inspect, refactor, test, and verify the result. jscpd
12
+ remains the source of truth for tokenization, clone detection, supported
13
+ languages, and statistics.
14
+
15
+ ## Install
16
+
17
+ ```sh
18
+ pi install npm:pi-jscpd
19
+ ```
20
+
21
+ The package includes pinned jscpd `5.1.2` and Effect `3.22.1` runtime
22
+ dependencies plus an on-demand `jscpd` agent skill—there is no separate analyzer
23
+ installation and no runtime download.
24
+ Effect owns bounded process execution, analyzer probing, temporary report
25
+ workspaces, adapter serialization, trusted configuration and signal reads,
26
+ canonical source-path validation, baseline generations, changed-file attribution,
27
+ acknowledgement transactions, verification checkpoints, scoped scheduling,
28
+ automatic finding delivery, scan/changed/status/Fallow application workflows,
29
+ and one managed runtime/layer graph per extension instance. Legacy Promise/service
30
+ paths are removed from those layers, and host-launched baseline work is settled at
31
+ lifecycle boundaries. If your project already installs
32
+ a compatible jscpd locally, or `jscpd`/`cpd` is available on `PATH`, the
33
+ extension uses that installation first and keeps the bundled version as a
34
+ fallback.
35
+
36
+ Start Pi in your project and verify the setup:
37
+
38
+ ```text
39
+ /jscpd status
40
+ ```
41
+
42
+ If no compatible binary is available, the extension stays dormant and Pi
43
+ continues normally.
44
+
45
+ ## Usage
46
+
47
+ Run `/jscpd` to open the interactive overview. Opening it shows status only; it
48
+ never starts an implicit scan.
49
+
50
+ | Command | Purpose |
51
+ | --- | --- |
52
+ | `/jscpd` | Open the responsive overview |
53
+ | `/jscpd changed` | Show unacknowledged duplication introduced this session |
54
+ | `/jscpd scan` | Scan the whole project |
55
+ | `/jscpd scan src tests` | Scan specific in-project files or directories |
56
+ | `/jscpd status` | Show binary, configuration, mode, and last-check status |
57
+ | `/jscpd off` | Disable scans for the current session |
58
+ | `/jscpd on` | Re-enable scans for the current session |
59
+ | `/jscpd help` | Show command help |
60
+
61
+ Pi can use the same operations through the `jscpd_run` tool:
62
+
63
+ ```json
64
+ {
65
+ "command": "scan",
66
+ "args": ["src"]
67
+ }
68
+ ```
69
+
70
+ Supported tool commands are `scan`, `changed`, `status`, `off`, `on`, and
71
+ `help`. In TUI mode, `/jscpd ` provides subcommand autocomplete with labels and
72
+ descriptions; selecting `scan` leaves the editor ready for an optional target.
73
+
74
+ The package also exposes `/skill:jscpd`. Pi advertises only the skill's concise
75
+ description at startup and loads its full workflow guidance on demand when a
76
+ duplication task matches or the user invokes the skill command. The extension
77
+ and `jscpd_run` tool remain usable when skills are disabled.
78
+
79
+ ## How session checks work
80
+
81
+ At session start, the extension captures one bounded, in-memory project baseline.
82
+ It then tracks successful writes and edits made through Pi's built-in `write`
83
+ and `edit` tools.
84
+
85
+ After Pi settles, one coalesced background check compares the current project
86
+ with the baseline:
87
+
88
+ - clean checks stay out of model context;
89
+ - failures remain advisory and available through `/jscpd status`;
90
+ - new duplicate blocks are reported with both locations;
91
+ - existing repository duplication is omitted from changed-only results; and
92
+ - actionable automatic findings never trigger a surprise model turn.
93
+
94
+ Displayed findings are acknowledged for the active conversation branch so the
95
+ same unchanged block is not repeatedly reported. Baselines, source bytes,
96
+ verification checkpoints, and reports are never persisted.
97
+
98
+ Manual edits, shell commands, custom mutation tools, deletes, and renames are not
99
+ attributed because Pi does not provide a stable structured file list for them.
100
+ Use `/jscpd scan` when changes happened outside built-in `write` or `edit`.
101
+
102
+ ## Interactive overview
103
+
104
+ Bare `/jscpd` opens a status-first, Fallow-style bounded TUI with:
105
+
106
+ - a framed overview of mode, binary, configuration, last check, and explicit
107
+ changed/project scan actions;
108
+ - a searchable, scrollable findings navigator that retains up to 100 findings,
109
+ initially shows 10, and reveals the next 10 with `L` or by navigating past the
110
+ last shown row—without rescanning or changing configuration;
111
+ - both duplicate locations, size, format, session relationship, inline detail,
112
+ verification, and omission/ambiguity context;
113
+ - `j`/`k`, arrows, Home/End, paging, expand/collapse, search, and multi-selection
114
+ controls consistent with Pi Fallow's navigator; and
115
+ - a bounded `e`/`a` handoff that closes the overlay and loads selected findings
116
+ into Pi's editor for user review.
117
+
118
+ The extra overlay cache is in-memory and TUI-only. `maxFindings` still caps
119
+ model/tool and explicit-command output, and cached findings are not added to
120
+ persisted session state or acknowledgement records. The editor handoff never
121
+ submits a prompt. The overview never edits source, writes jscpd configuration,
122
+ runs project tests, or refactors automatically. In RPC, JSON, and print modes,
123
+ explicit subcommands remain available and the bare command uses a bounded
124
+ non-interactive fallback.
125
+
126
+ ## Configuration
127
+
128
+ Project configuration is optional:
129
+
130
+ ```text
131
+ .pi/jscpd-guardrail.json
132
+ ```
133
+
134
+ Use `.pi/jscpd-guardrail.local.json` for an ignored local override. Configuration
135
+ is read only after Pi trusts the project.
136
+
137
+ ```json
138
+ {
139
+ "enabled": true,
140
+ "timeoutMs": 30000,
141
+ "maxFindings": 10,
142
+ "fallowCoexistence": "auto"
143
+ }
144
+ ```
145
+
146
+ | Setting | Default | Allowed values |
147
+ | --- | ---: | --- |
148
+ | `enabled` | `true` | Boolean |
149
+ | `timeoutMs` | `30000` | Integer from `100` to `300000` |
150
+ | `maxFindings` | `10` | Integer from `1` to `100` |
151
+ | `fallowCoexistence` | `auto` | `auto`, `on-demand`, or `allow` |
152
+
153
+ Clone thresholds, formats, ignore rules, and other detection policy belong in
154
+ jscpd's normal configuration, such as `.jscpd.json` or package-level jscpd
155
+ settings. The extension does not maintain a parallel clone policy.
156
+
157
+ ## Fallow coexistence
158
+
159
+ Pi Fallow can also detect duplication. With the default `auto` policy,
160
+ `pi-jscpd` conservatively detects supported signs of active Fallow duplication
161
+ analysis and moves automatic jscpd checks to on-demand mode to avoid duplicate
162
+ warnings.
163
+
164
+ Explicit `/jscpd changed`, project scans, and scoped scans remain available. Set
165
+ `fallowCoexistence` to `allow` when both automatic analyzers are intentional, or
166
+ `on-demand` to disable automatic jscpd checks explicitly.
167
+
168
+ See [Fallow coexistence](docs/fallow-coexistence.md) for the supported signals
169
+ and limitations.
170
+
171
+ ## Safety and privacy
172
+
173
+ - Advisory and read-only by default.
174
+ - Never downloads packages at runtime or mutates source.
175
+ - Invokes binaries with argument arrays, never a shell command string.
176
+ - Keeps reports in restrictive temporary directories and removes them after
177
+ success, failure, timeout, cancellation, or shutdown.
178
+ - Bounds process time, output, report size, findings, paths, and persisted state.
179
+ - Omits source fragments, raw child output, temporary paths, and internal
180
+ fingerprints from results.
181
+ - Reads extension configuration only for trusted projects.
182
+ - Fails open so analyzer problems do not break the Pi session.
183
+
184
+ ## Requirements
185
+
186
+ | Component | Supported |
187
+ | --- | --- |
188
+ | Node.js | `>=22.19.0 <23` or `>=24 <25` |
189
+ | Pi packages | `>=0.84.4 <0.85.0` |
190
+ | TypeBox | `>=1.3.7 <2` |
191
+ | Effect | Exact reviewed `3.22.1` runtime foundation |
192
+ | jscpd | Bundled `5.1.2`; compatible project-local or `PATH` v5 installations are preferred |
193
+
194
+ See the [compatibility policy](docs/compatibility.md) for the exact tested
195
+ fixtures and certification matrix.
196
+
197
+ ## Development
198
+
199
+ ```sh
200
+ npm ci --ignore-scripts
201
+ npm run format
202
+ npm run docs:check
203
+ npm run repo:hygiene
204
+ npm run check
205
+ npm run pack:certify
206
+ ```
207
+
208
+ `npm run check` includes the Effect runtime-boundary architecture gate.
209
+ `npm run release:check` runs the complete documentation, hygiene, compatibility,
210
+ architecture, test, and packed-artifact release gate. Tests are network-free and
211
+ use deterministic fake jscpd executables and Effect layers.
212
+ The repository-owned `.jscpd.json` excludes dependency/build
213
+ artifacts, caches, source maps, snapshots, archives, and common package-manager
214
+ lockfiles while continuing to analyze `src`, `test`, scripts, documentation, and
215
+ workflow files.
216
+
217
+ Useful documentation:
218
+
219
+ - [Effect architecture and conformance](docs/effect-architecture.md)
220
+ - [Automatic checkpoint lifecycle](docs/automatic-checkpoint.md)
221
+ - [`/jscpd` overlay contract](docs/overlay-interaction.md)
222
+ - [Fallow coexistence](docs/fallow-coexistence.md)
223
+ - [Compatibility and packed-artifact certification](docs/compatibility.md)
224
+ - [Release preparation and publication policy](docs/release.md)
225
+ - [Contributing](CONTRIBUTING.md)
226
+ - [Security policy](SECURITY.md)
227
+ - [Changelog](CHANGELOG.md)
228
+
229
+ ## License
230
+
231
+ [MIT](./LICENSE) © 2026 Revaz Zakalashvili
package/SECURITY.md ADDED
@@ -0,0 +1,93 @@
1
+ # Security policy
2
+
3
+ ## Supported versions
4
+
5
+ Security fixes target the latest `0.1.x` release and the `main` branch. Older
6
+ minor lines are unsupported unless this table explicitly says otherwise. The
7
+ manual release-readiness workflow cannot publish or create a release; the
8
+ [release policy](docs/release.md) defines approval, rollback, and post-release
9
+ checks.
10
+
11
+ | Version | Supported |
12
+ | --- | --- |
13
+ | `0.1.x` | Yes |
14
+ | `< 0.1.0` | No |
15
+
16
+ The host-version contract is documented in
17
+ [`docs/compatibility.md`](docs/compatibility.md). Forced installations outside
18
+ that contract are unsupported, but reports of issues that affect a supported
19
+ configuration are welcome.
20
+
21
+ ## Reporting a vulnerability
22
+
23
+ Do **not** open a public issue for a suspected vulnerability. Use GitHub's
24
+ [private vulnerability reporting](https://github.com/revazi/pi-jscpd/security/advisories/new)
25
+ to contact the maintainer. If GitHub does not offer the form, contact the
26
+ repository owner privately through their GitHub profile and ask for a secure
27
+ reporting channel without including vulnerability details in the first message.
28
+
29
+ Include only what is needed to reproduce and assess the problem:
30
+
31
+ - affected commit or version;
32
+ - supported Node and Pi versions;
33
+ - operating system;
34
+ - bounded reproduction steps using synthetic source where possible;
35
+ - expected and observed security impact; and
36
+ - whether disclosure is already public or time-sensitive.
37
+
38
+ Do not send credentials, tokens, proprietary source, full environment dumps,
39
+ raw jscpd fragments, or unrelated filesystem paths. Replace them with minimal
40
+ fixtures and redacted diagnostics.
41
+
42
+ The maintainer aims to acknowledge a complete report within five business days,
43
+ will coordinate validation and remediation privately, and will discuss a safe
44
+ disclosure timeline with the reporter. This is a best-effort open-source target,
45
+ not a guaranteed service-level agreement. Please allow a reasonable remediation
46
+ window before public disclosure.
47
+
48
+ ## Security boundaries
49
+
50
+ Security-sensitive behavior includes:
51
+
52
+ - shell-free executable invocation and cancellation of owned child processes;
53
+ - containment and validation of user-controlled paths;
54
+ - restrictive temporary report ownership and cleanup;
55
+ - bounded child output and strict jscpd report parsing;
56
+ - trusted-only project configuration reads;
57
+ - omission of source fragments and private process output from findings; and
58
+ - exclusion of local overrides, credentials, and private coding-agent context
59
+ from Git history and npm packages.
60
+
61
+ The extension is advisory and installs jscpd only as an explicit package
62
+ dependency; it never downloads packages during a Pi session, rewrites project
63
+ configuration, edits source automatically, or treats scan success as permission
64
+ to publish data. Security fixes must preserve those boundaries.
65
+
66
+ The completed [Effect architecture](docs/effect-architecture.md) preserves and
67
+ strengthens resource ownership. Child-process, temporary-report, and bounded
68
+ filesystem resources now use typed Effect services and scoped file/process
69
+ ownership. Baseline, changed-file, acknowledgement, verification, and session
70
+ snapshot state now use generation/revision-checked Effect owners with bounded
71
+ values. Automatic scheduling uses scoped fibers, interruption-linked abort
72
+ signals, and acknowledgement commit only after successful quiet delivery.
73
+ Scan, changed, status, and Fallow application workflows compose these typed
74
+ services without nested Promise error handling; bounded public failures remain
75
+ the only operational output. Trusted configuration, report paths, clone source
76
+ ranges, and Fallow signals retain no-follow, containment, and byte-limit checks.
77
+ The Pi host owns one managed runtime; cancellation interrupts native command
78
+ fibers and shutdown awaits tracked baseline plus bounded scheduler, process, and
79
+ workspace finalizers before closing its layer scope. The source conformance audit
80
+ restricts Promise workflows to reviewed Pi/TUI and filesystem infrastructure
81
+ boundaries and found no unmanaged service runtimes. Final supported-host,
82
+ dependency/security, and packed-artifact recertification gates protect the
83
+ release branch. Migration must not turn defects or sensitive exception details
84
+ into user-facing output.
85
+
86
+ ## Release authority
87
+
88
+ Only [Revaz Zakalashvili](https://github.com/revazi) may authorize an npm
89
+ publication or security release. A pull request, automated dependency update,
90
+ CI result, readiness run, Effect migration completion, or third-party review
91
+ does not itself authorize a release. If a vulnerability affects a published
92
+ version, coordinate any deprecation, corrected release, advisory, and bounded post-release verification
93
+ privately before disclosure; npm versions must never be overwritten.