projscan 3.4.0 → 3.5.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 (44) hide show
  1. package/README.md +25 -23
  2. package/dist/cli/commands/plugin.js +134 -2
  3. package/dist/cli/commands/plugin.js.map +1 -1
  4. package/dist/cli/commands/workplan.js +1 -1
  5. package/dist/cli/commands/workplan.js.map +1 -1
  6. package/dist/cli/commands/workspace.js +3 -2
  7. package/dist/cli/commands/workspace.js.map +1 -1
  8. package/dist/core/pluginDx.d.ts +1 -0
  9. package/dist/core/pluginDx.js +77 -18
  10. package/dist/core/pluginDx.js.map +1 -1
  11. package/dist/core/pluginTrust.d.ts +56 -0
  12. package/dist/core/pluginTrust.js +138 -0
  13. package/dist/core/pluginTrust.js.map +1 -0
  14. package/dist/core/plugins.d.ts +1 -1
  15. package/dist/core/plugins.js +33 -0
  16. package/dist/core/plugins.js.map +1 -1
  17. package/dist/core/preflight.js +4 -16
  18. package/dist/core/preflight.js.map +1 -1
  19. package/dist/core/privacy.js +8 -2
  20. package/dist/core/privacy.js.map +1 -1
  21. package/dist/core/workspace.d.ts +4 -2
  22. package/dist/core/workspace.js +63 -4
  23. package/dist/core/workspace.js.map +1 -1
  24. package/dist/fixes/eslintFix.js +6 -2
  25. package/dist/fixes/eslintFix.js.map +1 -1
  26. package/dist/fixes/prettierFix.js +5 -2
  27. package/dist/fixes/prettierFix.js.map +1 -1
  28. package/dist/fixes/testFix.js +8 -2
  29. package/dist/fixes/testFix.js.map +1 -1
  30. package/dist/mcp/tools/plugin.js +72 -20
  31. package/dist/mcp/tools/plugin.js.map +1 -1
  32. package/dist/mcp/tools/workplan.js +3 -2
  33. package/dist/mcp/tools/workplan.js.map +1 -1
  34. package/dist/mcp/tools/workspaceGraph.js +31 -0
  35. package/dist/mcp/tools/workspaceGraph.js.map +1 -1
  36. package/dist/projscan-sbom.cdx.json +87 -185
  37. package/dist/tool-manifest.json +5 -5
  38. package/dist/types.d.ts +7 -0
  39. package/dist/utils/formatSupport.d.ts +2 -0
  40. package/dist/utils/formatSupport.js +2 -0
  41. package/dist/utils/formatSupport.js.map +1 -1
  42. package/docs/PLUGIN-AUTHORING.md +41 -13
  43. package/docs/PLUGIN-GALLERY.md +2 -1
  44. package/package.json +2 -2
@@ -1,12 +1,24 @@
1
1
  # Plugin Authoring
2
2
 
3
3
  projscan 2.0 stabilizes the local analyzer and reporter plugin contract.
4
- Plugin execution is opt-in via `PROJSCAN_PLUGINS_PREVIEW=1` so repositories
5
- must explicitly trust local plugin code before it runs.
4
+ Plugin execution is gated by two independent controls:
6
5
 
7
- Plugins are local code. Enabling the opt-in flag means you trust the plugin code in
8
- the repository, the same way you trust project scripts in `package.json`.
9
- projscan does not fetch remote plugin code.
6
+ 1. **Opt-in flag** set `PROJSCAN_PLUGINS_PREVIEW=1` to enable the plugin system at all.
7
+ 2. **Trust-on-first-use** — even with the flag on, each plugin **module** must be
8
+ explicitly approved with `projscan plugin trust <name>` before projscan will
9
+ execute it. Approval pins the module's SHA-256; if the file later changes, it
10
+ reverts to untrusted and must be re-approved. Untrusted plugins are discovered
11
+ and listed but never run.
12
+
13
+ This means setting the flag globally (e.g. in your shell profile) can't silently
14
+ execute attacker-authored code from a repository you happen to scan — you still
15
+ have to approve each module once. The trust store lives in your user config
16
+ directory (`$XDG_CONFIG_HOME/projscan` or `~/.config/projscan`,
17
+ overridable with `PROJSCAN_PLUGIN_TRUST_HOME`), never inside the scanned repo.
18
+
19
+ Plugins are local code. Approving one means you trust that code in the repository,
20
+ the same way you trust project scripts in `package.json`. projscan does not fetch
21
+ remote plugin code.
10
22
 
11
23
  ## Layout
12
24
 
@@ -184,19 +196,18 @@ Use `plugin test` after editing a plugin:
184
196
  ```sh
185
197
  projscan plugin test .projscan-plugins/policy.projscan-plugin.json
186
198
  projscan plugin test .projscan-plugins/policy.projscan-plugin.json --format json
187
- projscan plugin test .projscan-plugins/policy.projscan-plugin.json --fixture ./test-fixture
199
+ PROJSCAN_PLUGINS_PREVIEW=1 projscan plugin test .projscan-plugins/policy.projscan-plugin.json --execute
200
+ PROJSCAN_PLUGINS_PREVIEW=1 projscan plugin test .projscan-plugins/policy.projscan-plugin.json --execute --fixture ./test-fixture
188
201
  ```
189
202
 
190
- For analyzer plugins, the test runner loads the module, scans the fixture root,
191
- runs `check(rootPath, files)`, and verifies every returned issue has the required
192
- shape. For reporter plugins, it renders sample `doctor`, `analyze`, and `ci`
193
- payloads for the commands listed in the manifest and verifies each render returns
194
- a string.
203
+ By default, `plugin test` validates the manifest, checks that the module file is readable, and reports guidance without importing or running plugin code. Add `--execute` only when you intentionally want to run local plugin code, and set `PROJSCAN_PLUGINS_PREVIEW=1` in the process environment.
204
+
205
+ In execute mode, analyzer plugins scan the fixture root, run `check(rootPath, files)`, and verify every returned issue has the required shape. Reporter plugins render sample `doctor`, `analyze`, and `ci` payloads for the commands listed in the manifest and verify each render returns a string.
195
206
 
196
207
  The JSON result also includes three guidance blocks:
197
208
 
198
209
  - `trust`: reminds callers that local plugins execute repository code, stay local-only, and require `PROJSCAN_PLUGINS_PREVIEW=1` before execution.
199
- - `commands`: gives copyable `validate`, `test`, and preview-enabled `enable` commands for the same manifest.
210
+ - `commands`: gives copyable `validate`, static `test`, preview-enabled `execute`, and `enable` commands for the same manifest.
200
211
  - `context`: reports whether the plugin requested graph/dataflow context and lists detected capabilities such as `semanticGraph` and `dataflow`.
201
212
 
202
213
  Graph-aware analyzers should keep context access lazy. Only call `context.getSemanticGraph()` or `context.getDataflow()` when the plugin needs that evidence for its issues.
@@ -209,11 +220,28 @@ projscan plugin list --format json
209
220
  ```
210
221
 
211
222
  The list command discovers manifests whether or not execution is enabled. It
212
- shows `enabled:false` until the opt-in flag is set.
223
+ shows `enabled:false` until the opt-in flag is set, and a per-plugin `trust`
224
+ status (`trusted` / `untrusted` / `changed`) so you can see what would actually run.
225
+
226
+ ## Trust
227
+
228
+ Approve a plugin's current module bytes before it can execute:
229
+
230
+ ```sh
231
+ projscan plugin trust policy # approve one plugin by name
232
+ projscan plugin trust --all # approve every valid discovered plugin
233
+ projscan plugin untrust policy # revoke approval
234
+ ```
235
+
236
+ Trust is intentionally a human CLI action — it is not exposed over the MCP server,
237
+ so an agent can't approve a plugin on your behalf.
213
238
 
214
239
  ## Enable
215
240
 
241
+ Enabling requires both the opt-in flag and a trusted module:
242
+
216
243
  ```sh
244
+ projscan plugin trust --all
217
245
  PROJSCAN_PLUGINS_PREVIEW=1 projscan doctor
218
246
  PROJSCAN_PLUGINS_PREVIEW=1 projscan ci
219
247
  PROJSCAN_PLUGINS_PREVIEW=1 projscan analyze
@@ -6,10 +6,11 @@ the manifest and module into `.projscan-plugins/`, then run:
6
6
  ```bash
7
7
  projscan plugin validate .projscan-plugins/<name>.projscan-plugin.json
8
8
  projscan plugin test .projscan-plugins/<name>.projscan-plugin.json
9
+ PROJSCAN_PLUGINS_PREVIEW=1 projscan plugin test .projscan-plugins/<name>.projscan-plugin.json --execute
9
10
  PROJSCAN_PLUGINS_PREVIEW=1 projscan doctor
10
11
  ```
11
12
 
12
- Local plugins are code execution. Only enable plugins you trust. `projscan plugin test --format json` returns `trust`, `commands`, and `context` guidance so agents can validate a plugin, see the preview flag, and detect graph/dataflow context needs before execution.
13
+ Local plugins are code execution. Only enable plugins you trust. `projscan plugin test --format json` is static by default and returns `trust`, `commands`, `execution`, and `context` guidance so agents can validate a plugin, see the preview flag, and detect graph/dataflow context needs before execution.
13
14
 
14
15
  ## Analyzer Plugins
15
16
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "projscan",
3
3
  "mcpName": "io.github.abhiyoheswaran1/projscan",
4
- "version": "3.4.0",
4
+ "version": "3.5.0",
5
5
  "description": "Agent-first code intelligence. MCP server (2025-03-26) with AST parsing for JavaScript, TypeScript, Python, Go, Java, Ruby, Rust, PHP, C#, Kotlin, Swift, and C++; repo understanding maps (projscan_understand), stable v3 semantic graph (projscan_semantic_graph), dataflow risk engine with bridge-helper detection (projscan_dataflow), code graph, file + per-function AST cyclomatic complexity, per-function fan-in + fan-out, coupling + cycle detection, structural PR diff with HTML reporter, coverage report with HTML reporter, intent-grounded one-call PR review (projscan_review with optional `intent` arg, new taint flows, contract changes, and newDataflowRisks) and long-running PR-watch mode with structured per-bucket deltas (projscan_review_watch), first-60-seconds workflow orientation (projscan_start), agent workplans (projscan_workplan), bug-hunt queues (projscan_bug_hunt), product-line planning (projscan_release_train), evidence packs (projscan_evidence_pack), regression planning (projscan_regression_plan), agent briefs (projscan_agent_brief), quality scorecards (projscan_quality_scorecard), and preflight with supply-chain IOC evidence, rule-driven fix suggestions + mechanical apply layer with rollback (projscan_apply_fix, projscan_fix_suggest, projscan_explain_issue), source-to-sink taint analysis (projscan_taint) with truncation reporting, transitive blast-radius analysis with cross-repo mode (projscan_impact for files and symbols), cross-repo workspace registration + intelligence (projscan_workspace_graph), per-function semantic search chunks (sub-file embeddings), per-rule confidence + severity drift + cost-summary analytics with live streaming (projscan_cost_summary), stable local analyzer + reporter plugin API (projscan_plugin, CLI --reporter, opt-in via PROJSCAN_PLUGINS_PREVIEW=1), monorepo workspace awareness with cross-package import policy + per-package dependencies / outdated / audit, BM25 + optional semantic search, cursor pagination, progress notifications, context-budgeted output, and a stable-surface CI guard. CLI on the side.",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -112,7 +112,7 @@
112
112
  "typescript": "^5.6.0",
113
113
  "typescript-eslint": "^8.57.0",
114
114
  "vite": "^6.4.2",
115
- "vitest": "^3.2.4"
115
+ "vitest": "^4.1.8"
116
116
  },
117
117
  "overrides": {
118
118
  "protobufjs": "^7.5.9",