claudecode-omc 5.6.8 → 5.11.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.
- package/.local/settings/settings.json +8 -0
- package/.local/skills/prompt-optimizer/SKILL.md +262 -19
- package/.omc-curation/ecc-selection.json +80 -0
- package/.omc-curation/governance.json +116 -0
- package/.omc-curation/sources.lock.json +30 -0
- package/README.md +78 -4
- package/bundled/manifest.json +6 -5
- package/bundled/upstream/anthropic-skills/.omc-source/bundle.json +18 -0
- package/bundled/upstream/anthropic-skills/.omc-source/provenance.json +399 -0
- package/bundled/upstream/anthropic-skills/skills/claude-api/SKILL.md +18 -17
- package/bundled/upstream/anthropic-skills/skills/claude-api/curl/examples.md +9 -9
- package/bundled/upstream/anthropic-skills/skills/claude-api/curl/managed-agents.md +4 -4
- package/bundled/upstream/anthropic-skills/skills/claude-api/go/managed-agents/README.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/java/claude-api.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/java/managed-agents/README.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/php/claude-api.md +10 -10
- package/bundled/upstream/anthropic-skills/skills/claude-api/php/managed-agents/README.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/README.md +16 -16
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/batches.md +3 -3
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/files-api.md +3 -3
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/streaming.md +7 -7
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/tool-use.md +19 -19
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/managed-agents/README.md +3 -3
- package/bundled/upstream/anthropic-skills/skills/claude-api/ruby/claude-api.md +4 -4
- package/bundled/upstream/anthropic-skills/skills/claude-api/ruby/managed-agents/README.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/error-codes.md +5 -5
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/live-sources.md +3 -1
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-api-reference.md +10 -4
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-core.md +19 -1
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-environments.md +6 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-multiagent.md +1 -1
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-onboarding.md +3 -3
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-overview.md +3 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-self-hosted-sandboxes.md +173 -0
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-tools.md +10 -4
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/model-migration.md +113 -13
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/models.md +14 -11
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/prompt-caching.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/tool-use-concepts.md +4 -4
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/README.md +15 -15
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/batches.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/files-api.md +1 -1
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/streaming.md +5 -5
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/tool-use.md +15 -15
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/managed-agents/README.md +3 -3
- package/bundled/upstream/ecc/.omc-source/bundle.json +2 -1
- package/bundled/upstream/ecc/.omc-source/last-plan-apply.json +108 -24
- package/bundled/upstream/ecc/.omc-source/manifests/.claude-plugin/marketplace.json +3 -3
- package/bundled/upstream/ecc/.omc-source/provenance.json +563 -0
- package/bundled/upstream/ecc/agents/marketing-agent.md +159 -0
- package/bundled/upstream/ecc/agents/react-build-resolver.md +215 -0
- package/bundled/upstream/ecc/agents/react-reviewer.md +167 -0
- package/bundled/upstream/ecc/agents/typescript-reviewer.md +3 -0
- package/bundled/upstream/ecc/commands/harness-audit.md +17 -10
- package/bundled/upstream/ecc/commands/marketing-campaign.md +129 -0
- package/bundled/upstream/ecc/commands/react-build.md +187 -0
- package/bundled/upstream/ecc/commands/react-review.md +170 -0
- package/bundled/upstream/ecc/commands/react-test.md +265 -0
- package/bundled/upstream/ecc/skills/benchmark-optimization-loop/SKILL.md +69 -0
- package/bundled/upstream/ecc/skills/blender-motion-state-inspection/SKILL.md +164 -0
- package/bundled/upstream/ecc/skills/canary-watch/SKILL.md +9 -1
- package/bundled/upstream/ecc/skills/continuous-learning-v2/hooks/observe.sh +31 -9
- package/bundled/upstream/ecc/skills/continuous-learning-v2/scripts/detect-project.sh +38 -4
- package/bundled/upstream/ecc/skills/continuous-learning-v2/scripts/instinct-cli.py +319 -12
- package/bundled/upstream/ecc/skills/data-throughput-accelerator/SKILL.md +72 -0
- package/bundled/upstream/ecc/skills/dynamic-workflow-mode/SKILL.md +123 -0
- package/bundled/upstream/ecc/skills/frontend-a11y/SKILL.md +446 -0
- package/bundled/upstream/ecc/skills/ito-basket-compare/SKILL.md +63 -0
- package/bundled/upstream/ecc/skills/ito-data-atlas-agent/SKILL.md +63 -0
- package/bundled/upstream/ecc/skills/ito-market-intelligence/SKILL.md +60 -0
- package/bundled/upstream/ecc/skills/ito-trade-planner/SKILL.md +67 -0
- package/bundled/upstream/ecc/skills/latency-critical-systems/SKILL.md +73 -0
- package/bundled/upstream/ecc/skills/marketing-campaign/SKILL.md +113 -0
- package/bundled/upstream/ecc/skills/nextjs-turbopack/SKILL.md +13 -0
- package/bundled/upstream/ecc/skills/parallel-execution-optimizer/SKILL.md +72 -0
- package/bundled/upstream/ecc/skills/prediction-market-oracle-research/SKILL.md +63 -0
- package/bundled/upstream/ecc/skills/prediction-market-risk-review/SKILL.md +60 -0
- package/bundled/upstream/ecc/skills/react-patterns/SKILL.md +341 -0
- package/bundled/upstream/ecc/skills/react-performance/SKILL.md +574 -0
- package/bundled/upstream/ecc/skills/react-testing/SKILL.md +423 -0
- package/bundled/upstream/ecc/skills/recsys-pipeline-architect/SKILL.md +114 -0
- package/bundled/upstream/ecc/skills/recursive-decision-ledger/SKILL.md +79 -0
- package/bundled/upstream/ecc/skills/social-publisher/SKILL.md +115 -0
- package/bundled/upstream/ecc/skills/team-agent-orchestration/SKILL.md +110 -0
- package/bundled/upstream/ecc/skills/uncloud/SKILL.md +343 -0
- package/bundled/upstream/ecc/skills/windows-desktop-e2e/SKILL.md +99 -0
- package/bundled/upstream/impeccable/.omc-source/bundle.json +20 -0
- package/bundled/upstream/impeccable/.omc-source/provenance.json +105 -0
- package/bundled/upstream/impeccable/agents/impeccable-manual-edit-applier.md +97 -0
- package/bundled/upstream/impeccable/skills/impeccable/SKILL.md +168 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/adapt.md +311 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/animate.md +201 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/audit.md +133 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/bolder.md +113 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/brand.md +108 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/clarify.md +288 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/codex.md +105 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/colorize.md +257 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/craft.md +123 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/critique.md +767 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/delight.md +302 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/distill.md +111 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/document.md +429 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/extract.md +69 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/harden.md +347 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/hooks.md +88 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/init.md +172 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/interaction-design.md +189 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/layout.md +161 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/live.md +718 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/onboard.md +234 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/optimize.md +258 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/overdrive.md +130 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/polish.md +241 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/product.md +60 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/quieter.md +99 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/shape.md +165 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/typeset.md +279 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/command-metadata.json +94 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/context-signals.mjs +225 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/context.mjs +280 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/critique-storage.mjs +242 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detect-csp.mjs +198 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detect.mjs +21 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/browser/injected/index.mjs +1735 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/cli/main.mjs +244 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +4907 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/detect-antipatterns.mjs +43 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +252 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +552 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +1013 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +208 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +189 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/findings.mjs +12 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/node/file-system.mjs +198 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/profile/profiler.mjs +166 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/registry/antipatterns.mjs +419 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/rules/checks.mjs +2671 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/shared/color.mjs +124 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/shared/constants.mjs +101 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/shared/page.mjs +7 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/hook-admin.mjs +574 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/hook-before-edit.mjs +473 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/hook-lib.mjs +1286 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/hook.mjs +61 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/lib/design-parser.mjs +835 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/lib/impeccable-paths.mjs +126 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/lib/is-generated.mjs +69 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/browser-script-parts.mjs +49 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/completion.mjs +19 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/event-validation.mjs +137 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/insert-ui.mjs +458 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/manual-apply.mjs +939 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/manual-edit-routes.mjs +357 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/manual-edits-buffer.mjs +152 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/session-store.mjs +289 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/svelte-component.mjs +826 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/sveltekit-adapter.mjs +274 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/ui-core.mjs +180 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/vocabulary.mjs +36 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-accept.mjs +812 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-browser-dom.js +146 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-browser-session.js +123 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-browser.js +11086 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-commit-manual-edits.mjs +1241 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-complete.mjs +75 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-copy-edit-agent.mjs +683 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-discard-manual-edits.mjs +51 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-inject.mjs +583 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-insert.mjs +272 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-manual-edit-evidence.mjs +363 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-poll.mjs +379 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-resume.mjs +94 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-server.mjs +1134 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-status.mjs +61 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-wrap.mjs +894 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live.mjs +246 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/palette.mjs +633 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/pin.mjs +214 -0
- package/bundled/upstream/oh-my-claudecode/.omc-source/bundle.json +2 -1
- package/bundled/upstream/oh-my-claudecode/.omc-source/provenance.json +116 -0
- package/bundled/upstream/oh-my-claudecode/skills/autopilot/SKILL.md +7 -0
- package/bundled/upstream/oh-my-claudecode/skills/cancel/SKILL.md +1 -0
- package/bundled/upstream/oh-my-claudecode/skills/deep-interview/SKILL.md +39 -5
- package/bundled/upstream/oh-my-claudecode/skills/hud/SKILL.md +1 -0
- package/bundled/upstream/oh-my-claudecode/skills/local-build-reminder/SKILL.md +78 -0
- package/bundled/upstream/oh-my-claudecode/skills/omc-doctor/SKILL.md +1 -1
- package/bundled/upstream/oh-my-claudecode/skills/omc-setup/SKILL.md +26 -10
- package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/01-install-claude-md.md +3 -3
- package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/02-configure.md +6 -4
- package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/03-integrations.md +1 -1
- package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/04-welcome.md +2 -2
- package/bundled/upstream/oh-my-claudecode/skills/omc-teams/SKILL.md +6 -6
- package/bundled/upstream/oh-my-claudecode/skills/plan/SKILL.md +44 -32
- package/bundled/upstream/oh-my-claudecode/skills/ralph/SKILL.md +45 -21
- package/bundled/upstream/oh-my-claudecode/skills/ralplan/SKILL.md +1 -1
- package/bundled/upstream/oh-my-claudecode/skills/self-improve/SKILL.md +7 -0
- package/bundled/upstream/oh-my-claudecode/skills/self-improve/scripts/resolve-paths.mjs +39 -15
- package/bundled/upstream/oh-my-claudecode/skills/team/SKILL.md +132 -90
- package/bundled/upstream/oh-my-claudecode/skills/ultragoal/SKILL.md +93 -0
- package/bundled/upstream/oh-my-claudecode/skills/ultraqa/SKILL.md +28 -13
- package/bundled/upstream/oh-my-claudecode/skills/ultrawork/SKILL.md +7 -0
- package/bundled/upstream/superpowers/.omc-source/bundle.json +2 -1
- package/bundled/upstream/superpowers/.omc-source/provenance.json +63 -0
- package/package.json +2 -1
- package/src/catalog/source-catalog.js +10 -4
- package/src/cli/index.js +4 -0
- package/src/cli/plan.js +14 -2
- package/src/cli/setup.js +52 -13
- package/src/cli/skill.js +1 -1
- package/src/cli/source.js +271 -14
- package/src/config/sources.js +82 -1
- package/src/merge/content-patch.js +88 -0
- package/templates/merge-config.json +1 -8
- package/bundled/upstream/ecc/skills/strategic-compact/suggest-compact.sh +0 -54
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scan a project tree for Content-Security-Policy signals and classify the
|
|
3
|
+
* shape so the agent knows which patch template to propose.
|
|
4
|
+
*
|
|
5
|
+
* Used at first-time `live.mjs` setup. Mechanical (grep-based) — no network,
|
|
6
|
+
* no dev server, no JS evaluation. The classification drives a user-facing
|
|
7
|
+
* consent prompt; the agent does the actual patch writing.
|
|
8
|
+
*
|
|
9
|
+
* Shapes are named by patch mechanism, not framework origin:
|
|
10
|
+
* - "append-arrays": CSP defined as structured directive arrays. Patch
|
|
11
|
+
* appends a dev-only localhost entry. Covers:
|
|
12
|
+
* - Monorepo helpers with additional*Src options
|
|
13
|
+
* (e.g. createBaseNextConfig for Next)
|
|
14
|
+
* - SvelteKit kit.csp.directives
|
|
15
|
+
* - nuxt-security module's contentSecurityPolicy
|
|
16
|
+
* - "append-string": CSP built as a literal value string. Patch splices
|
|
17
|
+
* a dev-only token into script-src and connect-src.
|
|
18
|
+
* Covers:
|
|
19
|
+
* - Inline Next.js headers() with CSP string
|
|
20
|
+
* - Nuxt routeRules / nitro.routeRules CSP headers
|
|
21
|
+
* - "middleware": CSP set dynamically in middleware.{ts,js}.
|
|
22
|
+
* Detected but not auto-patched in v1.
|
|
23
|
+
* - "meta-tag": <meta http-equiv="Content-Security-Policy"> in
|
|
24
|
+
* layout files. Detected but not auto-patched in v1.
|
|
25
|
+
* - null: no CSP signals found; no patch needed.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import fs from 'node:fs';
|
|
29
|
+
import path from 'node:path';
|
|
30
|
+
|
|
31
|
+
const SKIP_DIRS = new Set([
|
|
32
|
+
'node_modules',
|
|
33
|
+
'.git',
|
|
34
|
+
'.next',
|
|
35
|
+
'.turbo',
|
|
36
|
+
'.svelte-kit',
|
|
37
|
+
'.nuxt',
|
|
38
|
+
'.astro',
|
|
39
|
+
'dist',
|
|
40
|
+
'build',
|
|
41
|
+
'out',
|
|
42
|
+
'.vercel',
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
const SCAN_EXTS = new Set(['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts', '.tsx', '.jsx']);
|
|
46
|
+
const LAYOUT_EXTS = new Set(['.tsx', '.jsx', '.astro', '.vue', '.svelte', '.html']);
|
|
47
|
+
const MAX_DEPTH = 6;
|
|
48
|
+
const MAX_READ_BYTES = 64 * 1024;
|
|
49
|
+
|
|
50
|
+
// append-arrays signals: CSP expressed as structured directive arrays
|
|
51
|
+
const MONOREPO_HELPER_SIGNALS = [
|
|
52
|
+
/\bbuildCSPConfig\b/,
|
|
53
|
+
/\bbuildSecurityHeaders\b/,
|
|
54
|
+
/\badditionalScriptSrc\b/,
|
|
55
|
+
/\badditionalConnectSrc\b/,
|
|
56
|
+
/\bcreateBaseNextConfig\b/,
|
|
57
|
+
];
|
|
58
|
+
const SVELTEKIT_CSP_SIGNALS = [
|
|
59
|
+
/\bkit\s*:/,
|
|
60
|
+
/\bcsp\s*:/,
|
|
61
|
+
/\bdirectives\s*:/,
|
|
62
|
+
];
|
|
63
|
+
const NUXT_SECURITY_SIGNALS = [
|
|
64
|
+
/['"]nuxt-security['"]/,
|
|
65
|
+
/\bcontentSecurityPolicy\b/,
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
// append-string signals: CSP written as a literal value string
|
|
69
|
+
const INLINE_HEADER_SIGNALS = [
|
|
70
|
+
/["']Content-Security-Policy["']/i,
|
|
71
|
+
/\bscript-src\b/,
|
|
72
|
+
/\bconnect-src\b/,
|
|
73
|
+
];
|
|
74
|
+
const NUXT_ROUTE_RULES_SIGNALS = [
|
|
75
|
+
/\brouteRules\b/,
|
|
76
|
+
/Content-Security-Policy/i,
|
|
77
|
+
/\bscript-src\b/,
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
const MIDDLEWARE_HINT = /headers\.set\(\s*["']Content-Security-Policy["']/i;
|
|
81
|
+
const META_TAG_HINT = /http-equiv\s*=\s*["']Content-Security-Policy["']/i;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param {string} cwd Project root.
|
|
85
|
+
* @returns {{ shape: string|null, signals: string[] }}
|
|
86
|
+
*/
|
|
87
|
+
export function detectCsp(cwd = process.cwd()) {
|
|
88
|
+
const hits = { appendArrays: [], appendString: [], middleware: [], metaTag: [] };
|
|
89
|
+
|
|
90
|
+
walk(cwd, cwd, 0, (absPath, relPath, body) => {
|
|
91
|
+
const ext = path.extname(absPath);
|
|
92
|
+
const base = path.basename(absPath).toLowerCase();
|
|
93
|
+
const isConfig = (name) =>
|
|
94
|
+
new RegExp('(^|/)' + name + '\\.config\\.').test(relPath);
|
|
95
|
+
|
|
96
|
+
// === append-arrays candidates ===
|
|
97
|
+
|
|
98
|
+
// Monorepo CSP helper: packages/*/src/.../(config|security)/*
|
|
99
|
+
if (SCAN_EXTS.has(ext) &&
|
|
100
|
+
/packages\/[^/]+\/src\/.*(config|next-config|security)/.test(relPath) &&
|
|
101
|
+
MONOREPO_HELPER_SIGNALS.some((re) => re.test(body))) {
|
|
102
|
+
hits.appendArrays.push(relPath);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// SvelteKit kit.csp.directives
|
|
107
|
+
if (SCAN_EXTS.has(ext) && isConfig('svelte') &&
|
|
108
|
+
SVELTEKIT_CSP_SIGNALS.every((re) => re.test(body))) {
|
|
109
|
+
hits.appendArrays.push(relPath);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Nuxt nuxt-security module
|
|
114
|
+
if (SCAN_EXTS.has(ext) && isConfig('nuxt') &&
|
|
115
|
+
NUXT_SECURITY_SIGNALS.every((re) => re.test(body))) {
|
|
116
|
+
hits.appendArrays.push(relPath);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// === append-string candidates ===
|
|
121
|
+
|
|
122
|
+
// Inline headers in Next/Nuxt/SvelteKit/Astro/Vite config
|
|
123
|
+
if (SCAN_EXTS.has(ext) &&
|
|
124
|
+
/(^|\/)(next|nuxt|vite|astro|svelte)\.config\./.test(relPath) &&
|
|
125
|
+
INLINE_HEADER_SIGNALS.every((re) => re.test(body))) {
|
|
126
|
+
// Nuxt routeRules is a sub-shape of append-string; we already covered
|
|
127
|
+
// nuxt-security above via return, so any remaining Nuxt CSP match here
|
|
128
|
+
// is a route-rules / inline-headers case. Either way, same patch
|
|
129
|
+
// mechanism.
|
|
130
|
+
hits.appendString.push(relPath);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// === detect-only shapes ===
|
|
135
|
+
|
|
136
|
+
if ((base === 'middleware.ts' || base === 'middleware.js' || base === 'middleware.mjs') &&
|
|
137
|
+
MIDDLEWARE_HINT.test(body)) {
|
|
138
|
+
hits.middleware.push(relPath);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (LAYOUT_EXTS.has(ext) && META_TAG_HINT.test(body)) {
|
|
142
|
+
hits.metaTag.push(relPath);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Priority: append-arrays > append-string > middleware > meta-tag.
|
|
147
|
+
// Structured patches are safer than string splices; runtime and HTML
|
|
148
|
+
// injection patches are less reliable and v1 doesn't auto-apply them.
|
|
149
|
+
if (hits.appendArrays.length > 0) {
|
|
150
|
+
return { shape: 'append-arrays', signals: hits.appendArrays };
|
|
151
|
+
}
|
|
152
|
+
if (hits.appendString.length > 0) {
|
|
153
|
+
return { shape: 'append-string', signals: hits.appendString };
|
|
154
|
+
}
|
|
155
|
+
if (hits.middleware.length > 0) {
|
|
156
|
+
return { shape: 'middleware', signals: hits.middleware };
|
|
157
|
+
}
|
|
158
|
+
if (hits.metaTag.length > 0) {
|
|
159
|
+
return { shape: 'meta-tag', signals: hits.metaTag };
|
|
160
|
+
}
|
|
161
|
+
return { shape: null, signals: [] };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function walk(root, dir, depth, visit) {
|
|
165
|
+
if (depth > MAX_DEPTH) return;
|
|
166
|
+
let entries;
|
|
167
|
+
try { entries = fs.readdirSync(dir, { withFileTypes: true }); }
|
|
168
|
+
catch { return; }
|
|
169
|
+
|
|
170
|
+
for (const entry of entries) {
|
|
171
|
+
const abs = path.join(dir, entry.name);
|
|
172
|
+
if (entry.isDirectory()) {
|
|
173
|
+
if (SKIP_DIRS.has(entry.name)) continue;
|
|
174
|
+
walk(root, abs, depth + 1, visit);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (!entry.isFile()) continue;
|
|
178
|
+
const ext = path.extname(entry.name);
|
|
179
|
+
if (!SCAN_EXTS.has(ext) && !LAYOUT_EXTS.has(ext)) continue;
|
|
180
|
+
let body;
|
|
181
|
+
try {
|
|
182
|
+
const fd = fs.openSync(abs, 'r');
|
|
183
|
+
try {
|
|
184
|
+
const buf = Buffer.alloc(MAX_READ_BYTES);
|
|
185
|
+
const n = fs.readSync(fd, buf, 0, MAX_READ_BYTES, 0);
|
|
186
|
+
body = buf.slice(0, n).toString('utf-8');
|
|
187
|
+
} finally { fs.closeSync(fd); }
|
|
188
|
+
} catch { continue; }
|
|
189
|
+
visit(abs, path.relative(root, abs), body);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// CLI mode
|
|
194
|
+
const _running = process.argv[1];
|
|
195
|
+
if (_running?.endsWith('detect-csp.mjs') || _running?.endsWith('detect-csp.mjs/')) {
|
|
196
|
+
const result = detectCsp(process.cwd());
|
|
197
|
+
console.log(JSON.stringify(result, null, 2));
|
|
198
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const candidates = [
|
|
9
|
+
path.join(__dirname, 'detector', 'detect-antipatterns.mjs'),
|
|
10
|
+
path.join(__dirname, '..', '..', 'cli', 'engine', 'detect-antipatterns.mjs'),
|
|
11
|
+
];
|
|
12
|
+
const detectorPath = candidates.find(p => fs.existsSync(p));
|
|
13
|
+
|
|
14
|
+
if (!detectorPath) {
|
|
15
|
+
process.stderr.write('Error: bundled detector not found.\n');
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const { detectCli } = await import(pathToFileURL(detectorPath));
|
|
20
|
+
|
|
21
|
+
await detectCli();
|