periderm-cli 0.1.35 → 0.1.37

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/index.js CHANGED
@@ -31,7 +31,7 @@ const program = new Command();
31
31
  program
32
32
  .name("periderm")
33
33
  .description("A pre-launch checklist.")
34
- .version("0.1.32");
34
+ .version("0.1.37");
35
35
  // Easter egg: `periderm bless` — hidden, undocumented
36
36
  program
37
37
  .command("bless", { hidden: true })
@@ -40,6 +40,13 @@ export function renderMarkdown(r) {
40
40
  lines.push("No findings. Ship it.");
41
41
  return lines.join("\n");
42
42
  }
43
+ const isMobile = r.meta?.projectProfile === "mobile-app" || r.meta?.stacks?.some(s => ["react-native", "expo", "flutter", "swift-ios"].includes(s));
44
+ if (isMobile) {
45
+ lines.push("## Mobile Launch Advice");
46
+ lines.push("");
47
+ lines.push("> **Note on Legal & SEO:** We've skipped web SEO and on-page Legal & Compliance checks because this is a mobile project. However, mobile apps typically link to external web pages for their Terms and Privacy Policies. Make sure your externally hosted legal pages are complete, up to date, and correctly state your data collection practices (especially for app store review).");
48
+ lines.push("");
49
+ }
43
50
  lines.push("## How to use this report");
44
51
  lines.push("");
45
52
  lines.push("Each finding below has a **Why it matters**, an **Exact fix**, and an **AI prompt** you can paste directly into your coding assistant. Fix the criticals first, then the highs, then re-run `periderm scan`.");
@@ -9,8 +9,8 @@ Given a project summary, decide:
9
9
  - notes: one sentence explaining your reasoning
10
10
 
11
11
  Rules:
12
- - If both marketing/landing routes AND admin/dashboard routes exist → monorepo. Do NOT skip legal/SEO globally; only internal_globs for admin paths.
13
- - Pure admin dashboards with no public marketing → admin-only, skip Legal & Compliance and SEO & Discoverability globally.
12
+ - A project is an 'admin-only' internal tool EVEN IF it has public auth/login pages. Only classify as 'monorepo' if it contains a full public-facing marketing site or consumer product alongside the dashboard.
13
+ - If 'admin-only' or 'internal-tool', skip Legal & Compliance, SEO & Discoverability, and Accessibility globally.
14
14
  - Mobile-only (Flutter/RN/Swift, no web marketing) → mobile-app, skip SEO.
15
15
  - Never skip Security, Runtime Stability, or Runaway Cloud Costs unless library with no runtime.`;
16
16
  const TRIAGE_PROMPT = `You triage scan findings for false positives. Return ONLY valid JSON:
@@ -19,7 +19,29 @@ const TRIAGE_PROMPT = `You triage scan findings for false positives. Return ONLY
19
19
  Remove findings that clearly do not apply given project context (e.g. favicon missing when nonstandard icon exists, legal pages not needed on admin-only internal tools, accessibility on internal admin panels).
20
20
 
21
21
  Keep real security and cost issues. Be conservative — when unsure, keep the finding.`;
22
+ import { readConfig } from "../config.js";
22
23
  async function groqJson(apiKey, system, user) {
24
+ const cfg = readConfig();
25
+ if (cfg.token && cfg.apiUrl) {
26
+ try {
27
+ const res = await fetch(`${cfg.apiUrl}/api/public/deep-review`, {
28
+ method: "POST",
29
+ headers: { "Content-Type": "application/json", "x-periderm-token": cfg.token },
30
+ body: JSON.stringify({ system, user }),
31
+ });
32
+ if (res.ok) {
33
+ const data = (await res.json());
34
+ if (data.valid && data.content) {
35
+ return JSON.parse(data.content);
36
+ }
37
+ }
38
+ }
39
+ catch {
40
+ // Fallback to direct Groq API if backend fails or network error
41
+ }
42
+ }
43
+ if (!apiKey)
44
+ return null;
23
45
  try {
24
46
  const res = await fetch("https://api.groq.com/openai/v1/chat/completions", {
25
47
  method: "POST",
@@ -29,7 +29,7 @@ export async function scan(root, options = {}) {
29
29
  onProgress?.({ type: "phase", label: "Analyzing project context…" });
30
30
  let ctx = await detectProjectContext(root, files);
31
31
  const groqKey = resolveGroqApiKey(options.groqApiKey);
32
- const useAi = enableAiContext !== false && !!groqKey;
32
+ const useAi = enableAiContext !== false;
33
33
  if (useAi) {
34
34
  ctx = await enhanceContextWithGroq(ctx, buildContextSummary(ctx, root, relFiles), groqKey);
35
35
  }
@@ -84,8 +84,8 @@ export async function scan(root, options = {}) {
84
84
  onProgress?.({ type: "phase", label: "Applying project context filters…" });
85
85
  let findings = rawFindings.filter((f) => !shouldSkipFinding(f, ctx));
86
86
  const contextFilteredCount = rawFindings.length - findings.length;
87
- if (useAi && findings.length > 0) {
88
- onProgress?.({ type: "phase", label: "AI triage (removing false positives)…" });
87
+ if (useAi) {
88
+ onProgress?.({ type: "phase", label: "Triaging findings with AI…" });
89
89
  findings = await triageFindingsWithGroq(findings, ctx, groqKey);
90
90
  }
91
91
  onProgress?.({ type: "phase", label: "Computing launch verdict…" });
@@ -19,15 +19,17 @@ const INTERNAL_PATH_RE = [
19
19
  /(?:^|[/\\])middleware\.(?:ts|js)/,
20
20
  ];
21
21
  const CONSUMER_PATH_RE = [
22
- /(?:^|[/\\])routes[/\\]index\.(tsx|jsx)$/,
23
- /(?:^|[/\\])routes[/\\]__root\.(tsx|jsx)$/,
24
- /(?:^|[/\\])pages[/\\]index\.(tsx|jsx)$/,
25
- /(?:^|[/\\])app[/\\]page\.(tsx|jsx)$/,
22
+ /(?:^|[/\\])routes[/\\](?:index|__root|\+page)\.(tsx|jsx|svelte|vue)$/i,
23
+ /(?:^|[/\\])pages[/\\]index\.(tsx|jsx|vue|astro)$/i,
24
+ /(?:^|[/\\])app[/\\](?:page|layout|app\.component)\.(tsx|jsx|ts|js)$/i,
25
+ /(?:^|[/\\])(?:App|app)\.(svelte|vue)$/i,
26
+ /(?:^|[/\\])lib[/\\](?:main|screens[/\\]home)\.dart$/i,
27
+ /(?:^|[/\\])(?:ContentView|ViewController)\.swift$/i,
26
28
  /(?:^|[/\\])landing/i,
27
29
  /(?:^|[/\\])marketing/i,
28
- /(?:^|[/\\])routes[/\\]docs\.(tsx|jsx)$/,
29
- /(?:^|[/\\])routes[/\\]privacy\.(tsx|jsx)$/,
30
- /(?:^|[/\\])routes[/\\]terms\.(tsx|jsx)$/,
30
+ /(?:^|[/\\])(?:routes|pages|app)[/\\]docs\./i,
31
+ /(?:^|[/\\])(?:routes|pages|app)[/\\]privacy\./i,
32
+ /(?:^|[/\\])(?:routes|pages|app)[/\\]terms\./i,
31
33
  ];
32
34
  const INTERNAL_ONLY_SKIP = new Set([
33
35
  "Legal & Compliance",
@@ -40,6 +42,7 @@ const ADMIN_ONLY_SKIP = new Set([
40
42
  "SEO & Discoverability",
41
43
  ]);
42
44
  const MOBILE_SKIP = new Set([
45
+ "Legal & Compliance",
43
46
  "SEO & Discoverability",
44
47
  "Polish & Embarrassment Risks",
45
48
  ]);
@@ -131,7 +134,7 @@ export async function detectProjectContext(root, files) {
131
134
  stacks.push("swift-ios");
132
135
  reasoning.push("Detected Swift/iOS.");
133
136
  }
134
- if (pkgRaw && /react|vite|next|tanstack|svelte|vue/.test(pkgRaw)) {
137
+ if (pkgRaw && /react|vite|next|tanstack|svelte|vue|angular|astro|nuxt|remix|gatsby/i.test(pkgRaw)) {
135
138
  stacks.push("web-js");
136
139
  reasoning.push("Detected web JavaScript/TypeScript stack.");
137
140
  }
@@ -101,7 +101,21 @@ export async function runRepoChecks(root, _files, ctx) {
101
101
  });
102
102
  }
103
103
  }
104
- if (!skipLegalGlobally) {
104
+ }
105
+ if (!skipLegalGlobally) {
106
+ if (ctx?.profile === "mobile-app") {
107
+ out.push({
108
+ id: "mobile-legal-reminder",
109
+ category: "Legal & Compliance",
110
+ severity: "medium",
111
+ file: "App Stores", line: 1,
112
+ message: "Verify Privacy Policy URL is configured in App Store / Google Play.",
113
+ why: "Mobile apps must link to external legal policies in the app stores. Code scanners cannot verify external links.",
114
+ fix: "Ensure your App Store Connect and Google Play Console entries have valid, accessible URLs to your privacy policy and terms.",
115
+ aiPrompt: "Remind me to update my App Store / Google Play developer console with the Privacy Policy link.",
116
+ });
117
+ }
118
+ else {
105
119
  const legalFilePaths = _files.filter(f => {
106
120
  const rel = path.relative(root, f);
107
121
  return /terms|privacy|cookie|policy|legal|compliance|eula|tos/i.test(rel);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "periderm-cli",
3
- "version": "0.1.35",
3
+ "version": "0.1.37",
4
4
  "description": "Pre-launch scanner for web and mobile codebases. Context-aware checks for JS, TS, Flutter, React Native, and Swift.",
5
5
  "type": "module",
6
6
  "bin": {