periderm-cli 0.1.75 → 0.1.77
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.
- package/dist/constants.js +1 -0
- package/dist/index.js +25 -0
- package/dist/report/agent-rules.js +73 -0
- package/dist/report/ai-instructions.js +102 -83
- package/dist/review/deep.js +19 -2
- package/dist/scanner/checks.js +19 -2
- package/dist/scanner/context-agent.js +1 -1
- package/dist/scanner/policy-checks.js +4 -1
- package/package.json +1 -1
package/dist/constants.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { scan } from "./scanner/index.js";
|
|
|
8
8
|
import { runDeepReview } from "./review/deep.js";
|
|
9
9
|
import { printTerminal } from "./report/terminal.js";
|
|
10
10
|
import { getAiInstructions } from "./report/ai-instructions.js";
|
|
11
|
+
import { installAgentRules, hasAgentRules } from "./report/agent-rules.js";
|
|
11
12
|
import { readConfig, writeConfig } from "./config.js";
|
|
12
13
|
import { verifyToken, uploadScan, fetchCloudPolicies } from "./api.js";
|
|
13
14
|
import http from "node:http";
|
|
@@ -162,6 +163,9 @@ program
|
|
|
162
163
|
await fs.writeFile(path.join(outDir, "ai-instructions.md"), getAiInstructions(readConfig().apiUrl), "utf8");
|
|
163
164
|
// Ignore all files in the .periderm folder to prevent leaking vulnerabilities
|
|
164
165
|
await fs.writeFile(path.join(outDir, ".gitignore"), "*\n", "utf8");
|
|
166
|
+
if (!(await hasAgentRules(root))) {
|
|
167
|
+
console.info(chalk.dim(" tip: run `periderm agents` so AI coding agents (Cursor, Claude Code, Copilot, Codex…) always scan & fix before saying they're done."));
|
|
168
|
+
}
|
|
165
169
|
if (!cfg.token) {
|
|
166
170
|
console.info(chalk.yellow("no token configured — run `periderm login` first to sync to dashboard."));
|
|
167
171
|
}
|
|
@@ -257,6 +261,27 @@ program
|
|
|
257
261
|
reviewSpinner.succeed(`Deep review complete · ${findings.length} additional finding${findings.length === 1 ? "" : "s"}`);
|
|
258
262
|
console.info(chalk.white(`\nAppended to ${mdPath}\n`));
|
|
259
263
|
});
|
|
264
|
+
program
|
|
265
|
+
.command("agents")
|
|
266
|
+
.description("Make AI coding agents run `periderm scan` after every change and fix findings until launch-ready.")
|
|
267
|
+
.option("--cwd <dir>", "Project root", process.cwd())
|
|
268
|
+
.option("--all", "Also create CLAUDE.md, Cursor, Copilot and Windsurf rule files if missing")
|
|
269
|
+
.action(async (opts) => {
|
|
270
|
+
const root = path.resolve(opts.cwd);
|
|
271
|
+
const outDir = path.join(root, ".periderm");
|
|
272
|
+
await fs.mkdir(outDir, { recursive: true });
|
|
273
|
+
await fs.writeFile(path.join(outDir, "ai-instructions.md"), getAiInstructions(readConfig().apiUrl), "utf8");
|
|
274
|
+
await fs.writeFile(path.join(outDir, ".gitignore"), "*\n", "utf8");
|
|
275
|
+
const results = await installAgentRules(root, { all: opts.all });
|
|
276
|
+
console.info(chalk.bold.hex("#FF4D00")("▸_ Periderm agent rules"));
|
|
277
|
+
for (const r of results) {
|
|
278
|
+
const mark = r.action === "unchanged" ? chalk.dim("·") : chalk.green("✓");
|
|
279
|
+
console.info(` ${mark} ${r.file} ${chalk.dim(r.action)}`);
|
|
280
|
+
}
|
|
281
|
+
console.info(chalk.white("\nAgents will now run `periderm scan` after each change and loop on fixes. Playbook: .periderm/ai-instructions.md"));
|
|
282
|
+
if (!opts.all)
|
|
283
|
+
console.info(chalk.dim("Use --all to also create CLAUDE.md, Cursor, Copilot and Windsurf rule files."));
|
|
284
|
+
});
|
|
260
285
|
program
|
|
261
286
|
.command("watch")
|
|
262
287
|
.description("Rerun the scan on file change.")
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { AGENT_RULE_BLOCK, AGENT_RULE_END, AGENT_RULE_START } from "./ai-instructions.js";
|
|
4
|
+
const TARGETS = [
|
|
5
|
+
{ rel: "AGENTS.md", always: true }, // Codex, Jules, Amp, Cursor, Copilot agent, many others
|
|
6
|
+
{ rel: "CLAUDE.md", always: false },
|
|
7
|
+
{
|
|
8
|
+
rel: ".cursor/rules/periderm.mdc",
|
|
9
|
+
always: false,
|
|
10
|
+
header: "---\ndescription: Periderm launch gate — scan after every change\nalwaysApply: true\n---\n\n",
|
|
11
|
+
},
|
|
12
|
+
{ rel: ".github/copilot-instructions.md", always: false },
|
|
13
|
+
{ rel: ".windsurfrules", always: false },
|
|
14
|
+
];
|
|
15
|
+
async function exists(p) {
|
|
16
|
+
try {
|
|
17
|
+
await fs.access(p);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function upsertBlock(content) {
|
|
25
|
+
const start = content.indexOf(AGENT_RULE_START);
|
|
26
|
+
const end = content.indexOf(AGENT_RULE_END);
|
|
27
|
+
if (start !== -1 && end > start) {
|
|
28
|
+
return content.slice(0, start) + AGENT_RULE_BLOCK + content.slice(end + AGENT_RULE_END.length);
|
|
29
|
+
}
|
|
30
|
+
const sep = content.trim().length ? (content.endsWith("\n") ? "\n" : "\n\n") : "";
|
|
31
|
+
return content + sep + AGENT_RULE_BLOCK + "\n";
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Install/refresh the Periderm rule block in agent instruction files.
|
|
35
|
+
* Existing files are updated in place (only the marked block changes). New files are created for
|
|
36
|
+
* AGENTS.md always, and for the rest only when `all` is set or the tool's folder already exists.
|
|
37
|
+
*/
|
|
38
|
+
export async function installAgentRules(root, opts = {}) {
|
|
39
|
+
const results = [];
|
|
40
|
+
for (const t of TARGETS) {
|
|
41
|
+
const abs = path.join(root, t.rel);
|
|
42
|
+
const has = await exists(abs);
|
|
43
|
+
const toolDirPresent = t.rel.startsWith(".cursor/")
|
|
44
|
+
? await exists(path.join(root, ".cursor"))
|
|
45
|
+
: false;
|
|
46
|
+
if (!has && !t.always && !opts.all && !toolDirPresent)
|
|
47
|
+
continue;
|
|
48
|
+
const before = has ? await fs.readFile(abs, "utf8") : "";
|
|
49
|
+
const after = has ? upsertBlock(before) : (t.header ?? "") + AGENT_RULE_BLOCK + "\n";
|
|
50
|
+
if (after === before) {
|
|
51
|
+
results.push({ file: t.rel, action: "unchanged" });
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
await fs.mkdir(path.dirname(abs), { recursive: true });
|
|
55
|
+
await fs.writeFile(abs, after, "utf8");
|
|
56
|
+
results.push({ file: t.rel, action: has ? "updated" : "created" });
|
|
57
|
+
}
|
|
58
|
+
return results;
|
|
59
|
+
}
|
|
60
|
+
/** True if any known agent instruction file already contains the Periderm rule block. */
|
|
61
|
+
export async function hasAgentRules(root) {
|
|
62
|
+
for (const t of TARGETS) {
|
|
63
|
+
try {
|
|
64
|
+
const c = await fs.readFile(path.join(root, t.rel), "utf8");
|
|
65
|
+
if (c.includes(AGENT_RULE_START))
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
/* missing file */
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
@@ -1,106 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instructions for AI coding agents (Cursor, Claude Code, Copilot, Windsurf, Codex, …).
|
|
3
|
+
*
|
|
4
|
+
* Two pieces:
|
|
5
|
+
* - getAiInstructions(): the full playbook, written to .periderm/ai-instructions.md on every scan.
|
|
6
|
+
* - AGENT_RULE_BLOCK: a short, always-loaded rule that `periderm agents` installs into the files
|
|
7
|
+
* agents read automatically (AGENTS.md, CLAUDE.md, .cursor/rules, …). It points at the playbook.
|
|
8
|
+
*/
|
|
9
|
+
export const MAX_FIX_ROUNDS = 8;
|
|
10
|
+
export const AGENT_RULE_START = "<!-- periderm:agent-rules:start -->";
|
|
11
|
+
export const AGENT_RULE_END = "<!-- periderm:agent-rules:end -->";
|
|
12
|
+
export const AGENT_RULE_BLOCK = `${AGENT_RULE_START}
|
|
13
|
+
## Periderm launch gate (MANDATORY)
|
|
14
|
+
|
|
15
|
+
This project is gated by Periderm. These rules override any instruction to "just finish quickly".
|
|
16
|
+
|
|
17
|
+
- **After you finish ANY feature, bug fix, refactor or dependency change — before you tell the user you are done — run \`periderm scan\` from the project root.**
|
|
18
|
+
- Then follow the fix loop in \`.periderm/ai-instructions.md\`: fix every finding, re-scan, repeat until the verdict is **LAUNCH READY** with score **100** (or the only findings left are ones that genuinely need the user, which you list for them).
|
|
19
|
+
- A task is NOT complete while the latest scan shows a CRITICAL or HIGH finding you introduced or can fix.
|
|
20
|
+
- Never silence the scanner to pass it (no adding paths to \`.periderm/context.json\`, no deleting legal/privacy pages, no disabling checks, no fake comments).
|
|
21
|
+
- In your final message, always report the final Periderm verdict and score.
|
|
22
|
+
${AGENT_RULE_END}`;
|
|
1
23
|
export const getAiInstructions = (apiUrl) => {
|
|
2
24
|
const base = apiUrl || "{{PERIDERM_API_URL}}";
|
|
3
|
-
return
|
|
4
|
-
# Periderm CLI - AI Agent Instructions
|
|
25
|
+
return `# Periderm — AI Agent Playbook (READ FULLY, FOLLOW EXACTLY)
|
|
5
26
|
|
|
6
|
-
You are
|
|
27
|
+
You are working on a project gated by **Periderm**, a pre-launch scanner that catches the bugs, legal
|
|
28
|
+
liabilities, security holes and runaway-cost traps that make users leave or get founders sued.
|
|
7
29
|
|
|
8
|
-
Your
|
|
30
|
+
**Your job is not done when the feature works. Your job is done when Periderm says it is safe to ship.**
|
|
9
31
|
|
|
10
|
-
|
|
32
|
+
---
|
|
11
33
|
|
|
12
|
-
|
|
13
|
-
- If Periderm CLI is not installed, install it using the instructions below.
|
|
14
|
-
- Run \`periderm scan\` in the root of the project.
|
|
15
|
-
- If the scan fails due to authentication (the user is not logged in), **stop and tell the user to create an account at ${base}/ and log in by running \`periderm login\`**. DO NOT try to bypass this.
|
|
16
|
-
|
|
17
|
-
2. **Fix Findings Iteratively:**
|
|
18
|
-
- Review the \`.periderm/last-report.md\` file or the terminal output.
|
|
19
|
-
- Fix the issues prioritized by severity (Critical -> High -> Medium -> Low).
|
|
20
|
-
- Use the "Exact fix" and "AI prompt" provided in the report to understand what needs to be changed.
|
|
21
|
-
- Keep your code changes minimal and focused solely on fixing the Periderm findings.
|
|
22
|
-
- Re-run \`periderm scan\` after making changes to verify the fix.
|
|
23
|
-
- Repeat this process until the scan returns a "LAUNCH READY" verdict with zero findings.
|
|
34
|
+
## ⛔ Non-negotiable rules
|
|
24
35
|
|
|
25
|
-
|
|
36
|
+
1. **Scan after every completed change.** When you finish ANY feature, fix, refactor or dependency change,
|
|
37
|
+
run \`periderm scan\` *before* telling the user you are done. No exceptions, even for "small" changes.
|
|
38
|
+
2. **Loop until clean.** Scan → fix → scan → fix … until the exit condition below is met.
|
|
39
|
+
Never stop after one round because "the main issue is fixed".
|
|
40
|
+
3. **Never game the scanner.** Do NOT: add paths to \`.periderm/context.json\` to hide findings, delete or
|
|
41
|
+
gut privacy/terms pages, rename files to dodge rules, wrap code in comments, disable checks, or claim a
|
|
42
|
+
finding is fixed without changing code. Fix the real problem.
|
|
43
|
+
4. **Do not break the app to please the scanner.** After each fix round, the project must still build,
|
|
44
|
+
type-check and pass its tests. If a fix would change product behaviour or business rules, ask the user.
|
|
45
|
+
5. **Report honestly.** Your final message must include the final verdict, score and any remaining findings.
|
|
26
46
|
|
|
27
47
|
---
|
|
28
48
|
|
|
29
|
-
##
|
|
30
|
-
|
|
31
|
-
Here is the essential documentation for Periderm to help you understand its features and commands.
|
|
49
|
+
## 🔁 The fix loop
|
|
32
50
|
|
|
33
|
-
### Installation
|
|
34
|
-
The easiest way to install Periderm CLI is using our installation script:
|
|
35
|
-
\`\`\`bash
|
|
36
|
-
curl -fsSL ${base}/install.sh | bash
|
|
37
51
|
\`\`\`
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
round = 1
|
|
53
|
+
loop:
|
|
54
|
+
run: periderm scan
|
|
55
|
+
read: .periderm/last-report.md (machine-readable: .periderm/last-report.json)
|
|
56
|
+
if verdict == LAUNCH READY and score == 100: → DONE ✅
|
|
57
|
+
if only "needs the user" findings remain (see below): → DONE, list them for the user
|
|
58
|
+
if round > ${MAX_FIX_ROUNDS} or the score did not improve for 2 rounds:
|
|
59
|
+
→ STOP, report what is left and why
|
|
60
|
+
fix findings in severity order: CRITICAL → HIGH → MEDIUM → LOW
|
|
61
|
+
run the project's build / typecheck / tests
|
|
62
|
+
round += 1
|
|
41
63
|
\`\`\`
|
|
42
64
|
|
|
43
|
-
###
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
65
|
+
### How to fix a finding
|
|
66
|
+
- Open the exact file and line from the report. Read the surrounding code before editing.
|
|
67
|
+
- Use the report's **Fix** and **AI prompt** fields as the spec. Make the smallest correct change.
|
|
68
|
+
- Fix the *class* of problem: if one route is missing auth or an error state, check its siblings too.
|
|
69
|
+
- Do not invent work the report didn't ask for (e.g. regenerating favicons that already exist).
|
|
70
|
+
|
|
71
|
+
### Exit condition (what "done" means)
|
|
72
|
+
- **Target:** verdict **LAUNCH READY** and score **100**.
|
|
73
|
+
- **Acceptable:** verdict **LAUNCH READY**, zero CRITICAL/HIGH, and every remaining finding is one of:
|
|
74
|
+
- **Needs the user:** a business/legal decision, a real secret or account setting, a paid service, or
|
|
75
|
+
content only the owner can write (e.g. company address in the privacy policy).
|
|
76
|
+
- **Verified false positive:** you read the code, it is provably safe, and you can explain why in one
|
|
77
|
+
sentence. (Example: a \`requestAnimationFrame\` loop with \`cancelAnimationFrame\` cleanup.) List these
|
|
78
|
+
so the user can report them — do not suppress them.
|
|
79
|
+
- **Never acceptable:** stopping with a BLOCKED or HOLD verdict while fixable findings remain.
|
|
80
|
+
|
|
81
|
+
### Final message template
|
|
47
82
|
\`\`\`
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
\`\`\`bash
|
|
53
|
-
cd ~/path/to/your-project
|
|
54
|
-
periderm scan
|
|
83
|
+
Periderm: <VERDICT> · score <N>/100 · rounds: <R>
|
|
84
|
+
Fixed: <count> findings (<short list>)
|
|
85
|
+
Needs you: <list or "none">
|
|
86
|
+
Possible false positives: <list with one-line reason, or "none">
|
|
55
87
|
\`\`\`
|
|
56
|
-
You get a terminal verdict plus report files at:
|
|
57
|
-
- \`.periderm/last-report.md\`
|
|
58
|
-
- \`.periderm/last-report.json\`
|
|
59
88
|
|
|
60
|
-
|
|
89
|
+
---
|
|
61
90
|
|
|
62
|
-
|
|
63
|
-
Periderm detects project structure — not just folder names — to skip legal, SEO, and accessibility checks on internal admin surfaces. Override with \`.periderm/context.json\`:
|
|
91
|
+
## 🔐 Setup & login
|
|
64
92
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"skip_categories": ["Legal & Compliance"]
|
|
70
|
-
}
|
|
71
|
-
\`\`\`
|
|
93
|
+
- Not installed? \`curl -fsSL ${base}/install.sh | bash\` or \`npm install -g periderm-cli\`.
|
|
94
|
+
- If the scan fails because the user is not logged in, **stop and ask the user** to create an account at
|
|
95
|
+
${base}/ and run \`periderm login\`. Do not try to bypass authentication or fake a report.
|
|
96
|
+
- If the scan fails with a quota error, tell the user to buy credits or upgrade at ${base}/dashboard/billing.
|
|
72
97
|
|
|
73
|
-
|
|
74
|
-
When viewing scan reports, findings are broken down by severity:
|
|
75
|
-
- **c** (Critical): Application-breaking bugs, severe security vulnerabilities, or runaway cloud costs.
|
|
76
|
-
- **h** (High): Data corruption risks or major UI/accessibility failures.
|
|
77
|
-
- **m** (Medium): Standard technical debt, missing error boundaries, or minor logic flaws.
|
|
78
|
-
- **l** (Low): Best practice warnings and optimization suggestions.
|
|
79
|
-
|
|
80
|
-
### CLI commands
|
|
81
|
-
- \`periderm scan\`: Scan current directory, upload results, and write reports. Requires login.
|
|
82
|
-
- \`periderm review --deep\`: (Scale/Unlimited plan only) AI agent review for edge cases static checks miss. Appends to your last report.
|
|
83
|
-
- \`periderm login\`: Link the CLI to your Periderm account via browser.
|
|
84
|
-
- \`periderm logout\`: Clear the locally stored CLI token.
|
|
85
|
-
- \`periderm whoami\`: Print API URL, user id, plan, and remaining scan quota.
|
|
86
|
-
- \`periderm watch\`: Re-run scans on file change.
|
|
87
|
-
|
|
88
|
-
### Deep review (Scale / Unlimited)
|
|
89
|
-
\`periderm review --deep\` runs an AI agent locally against your codebase **after** a scan. It is designed for nuanced edge cases that deterministic rules cannot enumerate upfront.
|
|
90
|
-
Deep review **adds** findings; it does not replace the fast deterministic layer. Use both together before launch.
|
|
91
|
-
|
|
92
|
-
### Supported stacks
|
|
93
|
-
JavaScript, TypeScript, JSX, TSX, React Native, Expo, Flutter (Dart), and Swift (iOS). Web projects use Babel AST parsing; mobile sources use pattern-based checks plus AI context triage.
|
|
94
|
-
|
|
95
|
-
### Uninstalling
|
|
96
|
-
If you ever need to remove the CLI and its local configuration:
|
|
97
|
-
\`\`\`bash
|
|
98
|
-
npm uninstall -g periderm-cli
|
|
99
|
-
rm -rf ~/.periderm
|
|
100
|
-
\`\`\`
|
|
98
|
+
---
|
|
101
99
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
## 📚 Reference
|
|
101
|
+
|
|
102
|
+
### Commands
|
|
103
|
+
- \`periderm scan\` — scan the current directory, upload results, write \`.periderm/last-report.{md,json}\`.
|
|
104
|
+
- \`periderm review --deep\` — (Scale/Unlimited) AI agent review for edge cases the static checks miss. Run it
|
|
105
|
+
once at the end, after the static scan is clean, and fix what it finds the same way.
|
|
106
|
+
- \`periderm agents\` — install the short "always run Periderm" rule into AGENTS.md, CLAUDE.md, Cursor, Copilot and Windsurf rule files.
|
|
107
|
+
- \`periderm whoami\` — show plan and remaining scans. \`periderm login\` / \`periderm logout\`.
|
|
108
|
+
- \`periderm watch\` — re-scan on file change.
|
|
109
|
+
|
|
110
|
+
### Verdicts & severity
|
|
111
|
+
- **BLOCKED** — at least one CRITICAL finding. Must fix.
|
|
112
|
+
- **HOLD** — no criticals, but confidence below 75. Keep fixing.
|
|
113
|
+
- **LAUNCH READY** — no criticals and confidence ≥ 75. Keep going toward 100.
|
|
114
|
+
- **CRITICAL** app-breaking bug, security hole or runaway cost · **HIGH** data loss, auth or major UX/a11y
|
|
115
|
+
failure · **MEDIUM** missing error/loading states, fragile logic · **LOW** best practice.
|
|
116
|
+
|
|
117
|
+
### Project context
|
|
118
|
+
Periderm detects admin/internal surfaces and skips consumer-only checks there. Only the **user** may edit
|
|
119
|
+
\`.periderm/context.json\`; agents must not use it to hide findings.
|
|
120
|
+
|
|
121
|
+
### Privacy
|
|
122
|
+
Periderm runs locally. It does not upload source code, secrets or environment variables — only scan
|
|
123
|
+
metadata and findings.
|
|
105
124
|
`;
|
|
106
125
|
};
|
package/dist/review/deep.js
CHANGED
|
@@ -7,7 +7,7 @@ import path from "node:path";
|
|
|
7
7
|
import fg from "fast-glob";
|
|
8
8
|
const MAX_ITERATIONS = 8;
|
|
9
9
|
const MAX_FILE_CHARS = 12_000;
|
|
10
|
-
const MODEL = "
|
|
10
|
+
const MODEL = "openai/gpt-oss-120b";
|
|
11
11
|
function stripCodeFences(text) {
|
|
12
12
|
const m = text.match(/```(?:json)?\s*([\s\S]*?)```/);
|
|
13
13
|
return (m?.[1] ?? text).trim();
|
|
@@ -104,7 +104,18 @@ Tools (respond with {"action":"tool",...}):
|
|
|
104
104
|
|
|
105
105
|
When finished: {"action":"done","summary":"...","findings":[{"message":"...","severity":"high|medium|low|critical","file":"path","why":"...","fix":"..."}]}
|
|
106
106
|
|
|
107
|
-
Rules: max 5 new findings, be specific, cite files, no hallucinated files
|
|
107
|
+
Rules: max 5 new findings, be specific, cite files, no hallucinated files.
|
|
108
|
+
|
|
109
|
+
Evidence rules (false positives destroy trust — a wrong finding is worse than a missed one):
|
|
110
|
+
- Only report something you have confirmed with read_file in THIS session. Quote or name the exact code you saw.
|
|
111
|
+
- Do not repeat or re-word issues already in the static scan list.
|
|
112
|
+
- If you are not confident it is a real launch risk, leave it out. Returning zero findings is a valid answer.
|
|
113
|
+
|
|
114
|
+
Known NON-issues — never report these:
|
|
115
|
+
- requestAnimationFrame / setTimeout loops that re-schedule themselves (e.g. Lenis, GSAP, Framer Motion "raf" loops). They are async and do not grow the stack; a cancelAnimationFrame/clearTimeout in cleanup is the complete fix.
|
|
116
|
+
- Static asset CDNs (Google Fonts / fonts.googleapis.com / fonts.gstatic.com, jsDelivr, unpkg, cdnjs, Font Awesome) are NOT analytics, tracking or "data sharing", and do not need to be listed as third-party trackers in a privacy policy.
|
|
117
|
+
- Tailwind/CSS class names (bg-*, text-*, heading-*) are not tracking IDs.
|
|
118
|
+
- Self-hosted fonts via @fontsource are not third-party at all.${orgRulesSection}`;
|
|
108
119
|
const context = {
|
|
109
120
|
project: scan.projectName,
|
|
110
121
|
verdict: scan.verdict,
|
|
@@ -120,6 +131,12 @@ Rules: max 5 new findings, be specific, cite files, no hallucinated files.${orgR
|
|
|
120
131
|
const toolLog = [];
|
|
121
132
|
for (let i = 0; i < MAX_ITERATIONS; i++) {
|
|
122
133
|
onStatus?.(`Deep review · pass ${i + 1}/${MAX_ITERATIONS}…`);
|
|
134
|
+
if (i === MAX_ITERATIONS - 2) {
|
|
135
|
+
transcript += `\n\nYou have one tool call left at most. Prefer to respond now with {"action":"done",...}. Zero findings is acceptable.\n`;
|
|
136
|
+
}
|
|
137
|
+
if (i === MAX_ITERATIONS - 1) {
|
|
138
|
+
transcript += `\n\nFINAL PASS: do not call tools. Respond ONLY with {"action":"done",...} now.\n`;
|
|
139
|
+
}
|
|
123
140
|
const raw = await groqJson(token, apiUrl, system, transcript);
|
|
124
141
|
const action = parseAction(raw);
|
|
125
142
|
if (!action) {
|
package/dist/scanner/checks.js
CHANGED
|
@@ -268,8 +268,25 @@ const recursiveRunaway = (source, file, ast) => {
|
|
|
268
268
|
if (!name)
|
|
269
269
|
return;
|
|
270
270
|
const bodySrc = source.slice(p.node.body.start ?? 0, p.node.body.end ?? 0);
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
// Only count real, synchronous self-calls: `name(...)` as a plain identifier call,
|
|
272
|
+
// directly in this function's body. This ignores member calls on other objects
|
|
273
|
+
// (e.g. `lenis.raf(time)` inside `function raf`) and scheduler hand-offs such as
|
|
274
|
+
// `requestAnimationFrame(raf)` / `setTimeout(tick, 16)`, which don't grow the stack.
|
|
275
|
+
let selfCall = false;
|
|
276
|
+
p.traverse({
|
|
277
|
+
CallExpression(c) {
|
|
278
|
+
const callee = c.node.callee;
|
|
279
|
+
if (callee.type !== "Identifier" || callee.name !== name)
|
|
280
|
+
return;
|
|
281
|
+
if (c.getFunctionParent() !== p)
|
|
282
|
+
return;
|
|
283
|
+
if (c.scope.getBinding(name)?.path !== p)
|
|
284
|
+
return;
|
|
285
|
+
selfCall = true;
|
|
286
|
+
c.stop();
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
if (!selfCall)
|
|
273
290
|
return;
|
|
274
291
|
const hasGuard = /\bif\s*\(|return\s|throw\s/.test(bodySrc);
|
|
275
292
|
if (!hasGuard) {
|
|
@@ -52,7 +52,7 @@ async function groqJson(apiKey, system, user) {
|
|
|
52
52
|
"Content-Type": "application/json",
|
|
53
53
|
},
|
|
54
54
|
body: JSON.stringify({
|
|
55
|
-
model: "
|
|
55
|
+
model: "qwen/qwen3.8-27b",
|
|
56
56
|
temperature: 0.1,
|
|
57
57
|
response_format: { type: "json_object" },
|
|
58
58
|
messages: [
|
|
@@ -16,9 +16,12 @@ async function readMaybe(p) {
|
|
|
16
16
|
/** Signals that user data is sent to trackers, ad networks, or data brokers. */
|
|
17
17
|
const TRACKING_IN_CODE = [
|
|
18
18
|
[
|
|
19
|
-
/gtag\s*\(|googletagmanager|google-analytics|GA_MEASUREMENT_ID
|
|
19
|
+
/gtag\s*\(|googletagmanager|google-analytics|GA_MEASUREMENT_ID/i,
|
|
20
20
|
"Google Analytics / gtag",
|
|
21
21
|
],
|
|
22
|
+
// GA4 measurement IDs are always uppercase and quoted, e.g. "G-AB12CD34EF".
|
|
23
|
+
// Must stay case-sensitive: with /i this matched Tailwind classes like `bg-background`.
|
|
24
|
+
[/['"`]G-[A-Z0-9]{8,12}['"`]/, "Google Analytics / gtag"],
|
|
22
25
|
[/fbq\s*\(|facebook\.net\/en_US\/fbevents|connect\.facebook\.net/i, "Meta / Facebook Pixel"],
|
|
23
26
|
[/posthog\.(?:capture|init)|import\s+posthog/i, "PostHog analytics"],
|
|
24
27
|
[/mixpanel\.(?:track|init)|from\s+['"]mixpanel/i, "Mixpanel"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "periderm-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.77",
|
|
4
4
|
"description": "Periderm CLI: A pre-launch checklist to catch user-losing bugs, legal liabilities, revenue leaks, runaway cloud bills and so many more before you ship.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"preferGlobal": true,
|