@polymorphism-tech/morph-spec 3.1.0 → 3.2.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 (51) hide show
  1. package/CLAUDE.md +534 -0
  2. package/README.md +78 -4
  3. package/bin/morph-spec.js +50 -1
  4. package/bin/render-template.js +56 -10
  5. package/bin/task-manager.cjs +101 -7
  6. package/docs/cli-auto-detection.md +219 -0
  7. package/docs/llm-interaction-config.md +735 -0
  8. package/docs/troubleshooting.md +269 -0
  9. package/package.json +5 -1
  10. package/src/commands/advance-phase.js +93 -2
  11. package/src/commands/approve.js +221 -0
  12. package/src/commands/capture-pattern.js +121 -0
  13. package/src/commands/generate.js +128 -1
  14. package/src/commands/init.js +37 -0
  15. package/src/commands/migrate-state.js +158 -0
  16. package/src/commands/search-patterns.js +126 -0
  17. package/src/commands/spawn-team.js +172 -0
  18. package/src/commands/task.js +2 -2
  19. package/src/commands/update.js +36 -0
  20. package/src/commands/upgrade.js +346 -0
  21. package/src/generator/.gitkeep +0 -0
  22. package/src/generator/config-generator.js +206 -0
  23. package/src/generator/templates/config.json.template +40 -0
  24. package/src/generator/templates/project.md.template +67 -0
  25. package/src/lib/checkpoint-hooks.js +258 -0
  26. package/src/lib/metadata-extractor.js +380 -0
  27. package/src/lib/phase-state-machine.js +214 -0
  28. package/src/lib/state-manager.js +120 -0
  29. package/src/lib/template-data-sources.js +325 -0
  30. package/src/lib/validators/content-validator.js +351 -0
  31. package/src/llm/.gitkeep +0 -0
  32. package/src/llm/analyzer.js +215 -0
  33. package/src/llm/environment-detector.js +43 -0
  34. package/src/llm/few-shot-examples.js +216 -0
  35. package/src/llm/project-config-schema.json +188 -0
  36. package/src/llm/prompt-builder.js +96 -0
  37. package/src/llm/schema-validator.js +121 -0
  38. package/src/orchestrator.js +206 -0
  39. package/src/sanitizer/.gitkeep +0 -0
  40. package/src/sanitizer/context-sanitizer.js +221 -0
  41. package/src/sanitizer/patterns.js +163 -0
  42. package/src/scanner/.gitkeep +0 -0
  43. package/src/scanner/project-scanner.js +242 -0
  44. package/src/types/index.js +477 -0
  45. package/src/ui/.gitkeep +0 -0
  46. package/src/ui/diff-display.js +91 -0
  47. package/src/ui/interactive-wizard.js +96 -0
  48. package/src/ui/user-review.js +211 -0
  49. package/src/ui/wizard-questions.js +190 -0
  50. package/src/writer/.gitkeep +0 -0
  51. package/src/writer/file-writer.js +86 -0
@@ -0,0 +1,206 @@
1
+ /**
2
+ * @fileoverview AutoContextOrchestrator - Main orchestrator for CLI auto-detection
3
+ * @module morph-spec/orchestrator
4
+ */
5
+
6
+ import chalk from 'chalk';
7
+ import { ProjectScanner } from './scanner/project-scanner.js';
8
+ import { ContextSanitizer } from './sanitizer/context-sanitizer.js';
9
+ import { LLMAnalyzer } from './llm/analyzer.js';
10
+ import { ConfigGenerator } from './generator/config-generator.js';
11
+ import { UserReview } from './ui/user-review.js';
12
+ import { InteractiveWizard } from './ui/interactive-wizard.js';
13
+ import { FileWriter } from './writer/file-writer.js';
14
+ import { readFile, access } from 'fs/promises';
15
+ import { join } from 'path';
16
+
17
+ /**
18
+ * @typedef {import('./types/index.js').GeneratedConfigs} GeneratedConfigs
19
+ */
20
+
21
+ /**
22
+ * AutoContextOrchestrator - Orchestrates the complete auto-detection flow
23
+ * @class
24
+ */
25
+ export class AutoContextOrchestrator {
26
+ constructor() {
27
+ this.scanner = new ProjectScanner();
28
+ this.sanitizer = new ContextSanitizer();
29
+ this.llmAnalyzer = new LLMAnalyzer();
30
+ this.configGenerator = new ConfigGenerator();
31
+ this.userReview = new UserReview();
32
+ this.wizard = new InteractiveWizard();
33
+ this.fileWriter = new FileWriter();
34
+
35
+ // Handle Ctrl+C gracefully
36
+ this.setupSignalHandlers();
37
+ }
38
+
39
+ /**
40
+ * Execute the complete auto-detection flow
41
+ * @param {string} cwd - Current working directory
42
+ * @param {Object} [options] - Orchestration options
43
+ * @param {boolean} [options.skipReview] - Skip user review (auto-approve)
44
+ * @param {boolean} [options.fallbackOnError] - Fallback to wizard on LLM error (default: true)
45
+ * @param {boolean} [options.wizardMode] - Force wizard mode (skip LLM)
46
+ * @returns {Promise<{success: boolean, configs: GeneratedConfigs|null}>}
47
+ */
48
+ async execute(cwd, options = {}) {
49
+ const {
50
+ skipReview = false,
51
+ fallbackOnError = true,
52
+ wizardMode = false
53
+ } = options;
54
+
55
+ try {
56
+ console.log(chalk.bold.cyan('\nšŸ” MORPH-SPEC Auto Context Detection\n'));
57
+
58
+ let projectConfig;
59
+
60
+ // Step 1: Decide between LLM or Wizard mode
61
+ if (wizardMode) {
62
+ console.log(chalk.yellow(' Using interactive wizard mode (--wizard flag)\n'));
63
+ projectConfig = await this.wizard.run();
64
+ } else {
65
+ try {
66
+ // Step 1a: Scan project
67
+ console.log(chalk.dim(' [1/6] Scanning project directory...'));
68
+ const projectContext = await this.scanner.scan(cwd);
69
+
70
+ // Step 1b: Sanitize context
71
+ console.log(chalk.dim(' [2/6] Sanitizing context (removing secrets)...'));
72
+ const sanitizedContext = this.sanitizer.sanitize(projectContext);
73
+
74
+ // Step 1c: Analyze with LLM
75
+ console.log(chalk.dim(' [3/6] Analyzing with Claude Code LLM...'));
76
+ projectConfig = await this.llmAnalyzer.analyze(sanitizedContext);
77
+
78
+ console.log(chalk.green(' āœ“ Auto-detection successful\n'));
79
+ } catch (error) {
80
+ // LLM failed
81
+ console.log(chalk.yellow(`\n āš ļø Auto-detection failed: ${error.message}\n`));
82
+
83
+ if (!fallbackOnError) {
84
+ throw error;
85
+ }
86
+
87
+ // Fallback to wizard
88
+ console.log(chalk.cyan(' Falling back to interactive wizard...\n'));
89
+ projectConfig = await this.wizard.run();
90
+ }
91
+ }
92
+
93
+ // Step 2: Generate configs
94
+ console.log(chalk.dim(' [4/6] Generating configuration files...'));
95
+ const configs = await this.configGenerator.generate(projectConfig);
96
+
97
+ // Step 3: User review (unless skipped)
98
+ let finalConfigs = configs;
99
+
100
+ if (!skipReview) {
101
+ console.log(chalk.dim(' [5/6] Requesting user approval...'));
102
+
103
+ // Check if updating existing configs
104
+ const existingConfigs = await this.readExistingConfigs(cwd);
105
+
106
+ const approvalResponse = await this.userReview.promptForApproval(
107
+ configs,
108
+ projectConfig,
109
+ existingConfigs
110
+ );
111
+
112
+ if (approvalResponse.action === 'cancel') {
113
+ console.log(chalk.yellow('\nāŒ Operation canceled by user\n'));
114
+ console.log(chalk.dim(` Reason: ${approvalResponse.cancelReason || 'User canceled'}\n`));
115
+ return { success: false, configs: null };
116
+ }
117
+
118
+ if (approvalResponse.editedConfigs) {
119
+ finalConfigs = approvalResponse.editedConfigs;
120
+ }
121
+ } else {
122
+ console.log(chalk.dim(' [5/6] Skipping user review (auto-approve)'));
123
+ }
124
+
125
+ // Step 4: Save configs
126
+ console.log(chalk.dim(' [6/6] Saving configuration files...'));
127
+
128
+ // Backup existing configs if they exist
129
+ await this.configGenerator.backupExisting(cwd);
130
+
131
+ // Write new configs
132
+ await this.fileWriter.save(cwd, finalConfigs);
133
+
134
+ console.log(chalk.bold.green('šŸŽ‰ Auto-detection complete!\n'));
135
+
136
+ return { success: true, configs: finalConfigs };
137
+ } catch (error) {
138
+ console.log(chalk.bold.red('\nāŒ Auto-detection failed\n'));
139
+ console.log(chalk.red(` Error: ${error.message}\n`));
140
+
141
+ if (error.stack && process.env.DEBUG) {
142
+ console.log(chalk.dim(error.stack));
143
+ }
144
+
145
+ return { success: false, configs: null };
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Read existing configs (if they exist)
151
+ * @param {string} cwd - Current working directory
152
+ * @returns {Promise<Object|null>} Existing configs or null
153
+ */
154
+ async readExistingConfigs(cwd) {
155
+ try {
156
+ const projectMdPath = join(cwd, '.morph', 'project.md');
157
+ const configJsonPath = join(cwd, '.morph', 'config', 'config.json');
158
+
159
+ const [projectMdExists, configJsonExists] = await Promise.all([
160
+ this.fileExists(projectMdPath),
161
+ this.fileExists(configJsonPath)
162
+ ]);
163
+
164
+ if (!projectMdExists && !configJsonExists) {
165
+ return null; // No existing configs
166
+ }
167
+
168
+ const [projectMd, configJson] = await Promise.all([
169
+ projectMdExists ? readFile(projectMdPath, 'utf-8') : null,
170
+ configJsonExists ? readFile(configJsonPath, 'utf-8') : null
171
+ ]);
172
+
173
+ return { projectMd, configJson };
174
+ } catch (error) {
175
+ return null; // Error reading configs, treat as non-existent
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Check if file exists
181
+ * @param {string} filepath - File path
182
+ * @returns {Promise<boolean>}
183
+ */
184
+ async fileExists(filepath) {
185
+ try {
186
+ await access(filepath);
187
+ return true;
188
+ } catch {
189
+ return false;
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Setup signal handlers for graceful shutdown
195
+ */
196
+ setupSignalHandlers() {
197
+ const handleExit = () => {
198
+ console.log(chalk.yellow('\n\nāš ļø Operation interrupted by user (Ctrl+C)\n'));
199
+ console.log(chalk.dim(' No files were modified\n'));
200
+ process.exit(0);
201
+ };
202
+
203
+ process.on('SIGINT', handleExit);
204
+ process.on('SIGTERM', handleExit);
205
+ }
206
+ }
File without changes
@@ -0,0 +1,221 @@
1
+ /**
2
+ * @fileoverview ContextSanitizer - Sanitizes project context before sending to LLM
3
+ * @module morph-spec/sanitizer/context-sanitizer
4
+ */
5
+
6
+ import { minimatch } from 'minimatch';
7
+ import {
8
+ WHITELIST_FILES,
9
+ BLACKLIST_DIRECTORIES,
10
+ BLACKLIST_FILES,
11
+ SECRET_PATTERNS,
12
+ MAX_FILE_SIZE,
13
+ MAX_SUMMARY_LENGTH
14
+ } from './patterns.js';
15
+
16
+ /**
17
+ * @typedef {import('../types/index.js').ProjectContext} ProjectContext
18
+ * @typedef {import('../types/index.js').SanitizedContext} SanitizedContext
19
+ */
20
+
21
+ /**
22
+ * ContextSanitizer - Removes secrets and sensitive data before LLM analysis
23
+ * Implements hybrid whitelist/blacklist approach per ADR-004
24
+ * @class
25
+ */
26
+ export class ContextSanitizer {
27
+ /**
28
+ * Sanitize project context (remove secrets, truncate files)
29
+ * @param {ProjectContext} context - Raw project context
30
+ * @returns {SanitizedContext}
31
+ */
32
+ sanitize(context) {
33
+ // Sanitize package.json (remove private fields, redact secrets)
34
+ const sanitizedPackageJson = this.sanitizePackageJson(context.packageJson);
35
+
36
+ // Extract only filenames from .csproj paths (not full content)
37
+ const csprojFilenames = context.csprojFiles.map(path => path.split('/').pop());
38
+
39
+ // Truncate README and CLAUDE.md to first 500 chars
40
+ const readmeSummary = context.readme
41
+ ? this.truncateText(context.readme, MAX_SUMMARY_LENGTH)
42
+ : null;
43
+
44
+ const claudeMdSummary = context.claudeMd
45
+ ? this.truncateText(context.claudeMd, MAX_SUMMARY_LENGTH)
46
+ : null;
47
+
48
+ // Sanitize infrastructure summary (remove secrets, just count files)
49
+ const infraSummary = {
50
+ dockerfilesCount: context.infraFiles.dockerfiles.length,
51
+ dockerComposeCount: context.infraFiles.dockerComposeFiles.length,
52
+ bicepFilesCount: context.infraFiles.bicepFiles.length,
53
+ pipelinesCount: context.infraFiles.pipelines.length,
54
+ hasAzure: context.infraFiles.hasAzure,
55
+ hasDocker: context.infraFiles.hasDocker,
56
+ hasDevOps: context.infraFiles.hasDevOps
57
+ };
58
+
59
+ // Extract git remote domain only (not full URL with credentials)
60
+ const gitRemoteDomain = context.gitRemote
61
+ ? this.extractDomain(context.gitRemote)
62
+ : null;
63
+
64
+ // Estimate total files (approximate)
65
+ const totalFiles = context.structure.topLevelDirs.length * 10; // rough estimate
66
+
67
+ return {
68
+ packageJson: sanitizedPackageJson,
69
+ csprojFilenames,
70
+ hasSolution: context.solutionFile !== null,
71
+ readmeSummary,
72
+ claudeMdSummary,
73
+ structure: context.structure,
74
+ infraSummary,
75
+ gitRemoteDomain,
76
+ totalFiles
77
+ };
78
+ }
79
+
80
+ /**
81
+ * Sanitize package.json - remove private fields and redact secrets
82
+ * @param {Object|null} packageJson - Raw package.json
83
+ * @returns {Object}
84
+ */
85
+ sanitizePackageJson(packageJson) {
86
+ if (!packageJson) {
87
+ return {};
88
+ }
89
+
90
+ // Keep only safe fields
91
+ const safe = {
92
+ name: packageJson.name || 'unknown',
93
+ version: packageJson.version,
94
+ description: packageJson.description,
95
+ type: packageJson.type,
96
+ engines: packageJson.engines
97
+ };
98
+
99
+ // Include dependencies (names only, no versions for simplicity)
100
+ if (packageJson.dependencies) {
101
+ safe.dependencies = Object.keys(packageJson.dependencies);
102
+ }
103
+
104
+ if (packageJson.devDependencies) {
105
+ safe.devDependencies = Object.keys(packageJson.devDependencies);
106
+ }
107
+
108
+ // Include scripts (but redact any that might contain secrets)
109
+ if (packageJson.scripts) {
110
+ safe.scripts = {};
111
+ for (const [key, value] of Object.entries(packageJson.scripts)) {
112
+ safe.scripts[key] = this.redactSecrets(value);
113
+ }
114
+ }
115
+
116
+ return safe;
117
+ }
118
+
119
+ /**
120
+ * Detect and redact secrets from text
121
+ * @param {string} text - Text to sanitize
122
+ * @returns {string} Sanitized text
123
+ */
124
+ redactSecrets(text) {
125
+ if (!text || typeof text !== 'string') {
126
+ return text;
127
+ }
128
+
129
+ let sanitized = text;
130
+
131
+ // Apply all secret patterns
132
+ for (const pattern of SECRET_PATTERNS) {
133
+ sanitized = sanitized.replace(pattern.regex, pattern.replacement);
134
+ }
135
+
136
+ return sanitized;
137
+ }
138
+
139
+ /**
140
+ * Check if file should be excluded from LLM analysis
141
+ * @param {string} filepath - File path (relative or absolute)
142
+ * @returns {boolean} True if file should be excluded
143
+ */
144
+ shouldExcludeFile(filepath) {
145
+ const normalizedPath = filepath.replace(/\\/g, '/');
146
+
147
+ // Check if path contains blacklisted directory
148
+ for (const blacklistDir of BLACKLIST_DIRECTORIES) {
149
+ if (normalizedPath.includes(`/${blacklistDir}/`) || normalizedPath.startsWith(`${blacklistDir}/`)) {
150
+ return true;
151
+ }
152
+ }
153
+
154
+ // Check if filename matches blacklist pattern
155
+ const filename = normalizedPath.split('/').pop();
156
+ for (const pattern of BLACKLIST_FILES) {
157
+ if (minimatch(filename, pattern, { nocase: true })) {
158
+ return true;
159
+ }
160
+ }
161
+
162
+ return false;
163
+ }
164
+
165
+ /**
166
+ * Check if file is whitelisted for reading
167
+ * @param {string} filepath - File path
168
+ * @returns {boolean} True if file is whitelisted
169
+ */
170
+ isWhitelisted(filepath) {
171
+ const normalizedPath = filepath.replace(/\\/g, '/');
172
+ const filename = normalizedPath.split('/').pop();
173
+
174
+ for (const pattern of WHITELIST_FILES) {
175
+ if (minimatch(filename, pattern, { nocase: true })) {
176
+ return true;
177
+ }
178
+ // Also check full path for patterns like ".github/workflows/*.yml"
179
+ if (minimatch(normalizedPath, pattern, { nocase: true })) {
180
+ return true;
181
+ }
182
+ }
183
+
184
+ return false;
185
+ }
186
+
187
+ /**
188
+ * Truncate text to maximum length
189
+ * @param {string} text - Text to truncate
190
+ * @param {number} maxLength - Maximum length
191
+ * @returns {string} Truncated text
192
+ */
193
+ truncateText(text, maxLength) {
194
+ if (!text || text.length <= maxLength) {
195
+ return text;
196
+ }
197
+
198
+ return text.substring(0, maxLength) + '... [truncated]';
199
+ }
200
+
201
+ /**
202
+ * Extract domain from git remote URL
203
+ * @param {string} url - Git remote URL
204
+ * @returns {string|null} Domain only (e.g., "github.com")
205
+ */
206
+ extractDomain(url) {
207
+ try {
208
+ // Handle SSH format: git@github.com:user/repo.git
209
+ if (url.startsWith('git@')) {
210
+ const match = url.match(/git@([^:]+):/);
211
+ return match ? match[1] : null;
212
+ }
213
+
214
+ // Handle HTTPS format: https://github.com/user/repo.git
215
+ const urlObj = new URL(url);
216
+ return urlObj.hostname;
217
+ } catch (error) {
218
+ return null;
219
+ }
220
+ }
221
+ }
@@ -0,0 +1,163 @@
1
+ /**
2
+ * @fileoverview Sanitization patterns - Whitelists, Blacklists, Secret patterns
3
+ * @module morph-spec/sanitizer/patterns
4
+ */
5
+
6
+ /**
7
+ * Whitelist: Files explicitly allowed to be read and sent to LLM
8
+ */
9
+ export const WHITELIST_FILES = [
10
+ 'package.json',
11
+ 'package-lock.json',
12
+ 'yarn.lock',
13
+ 'pnpm-lock.yaml',
14
+ '*.csproj',
15
+ '*.sln',
16
+ 'README.md',
17
+ 'CLAUDE.md',
18
+ 'Dockerfile',
19
+ 'docker-compose.yml',
20
+ 'docker-compose.*.yml',
21
+ '*.bicep',
22
+ 'azure-pipelines.yml',
23
+ '.github/workflows/*.yml',
24
+ '.gitlab-ci.yml',
25
+ 'tsconfig.json',
26
+ 'jsconfig.json',
27
+ '.eslintrc*',
28
+ '.prettierrc*',
29
+ 'vite.config.*',
30
+ 'next.config.*',
31
+ 'nuxt.config.*'
32
+ ];
33
+
34
+ /**
35
+ * Blacklist: Directories to NEVER scan or read
36
+ */
37
+ export const BLACKLIST_DIRECTORIES = [
38
+ 'node_modules',
39
+ '.git',
40
+ '.svn',
41
+ '.hg',
42
+ 'bin',
43
+ 'obj',
44
+ 'dist',
45
+ 'build',
46
+ 'out',
47
+ '.next',
48
+ '.nuxt',
49
+ 'coverage',
50
+ '__pycache__',
51
+ '.pytest_cache',
52
+ 'venv',
53
+ 'env',
54
+ '.venv',
55
+ '.env.*',
56
+ 'temp',
57
+ 'tmp',
58
+ '.cache'
59
+ ];
60
+
61
+ /**
62
+ * Blacklist: File patterns to NEVER read (even if matched by whitelist)
63
+ */
64
+ export const BLACKLIST_FILES = [
65
+ '.env',
66
+ '.env.local',
67
+ '.env.*.local',
68
+ '.env.production',
69
+ '*.key',
70
+ '*.pem',
71
+ '*.pfx',
72
+ '*.p12',
73
+ '*.cert',
74
+ '*.crt',
75
+ '*secret*',
76
+ '*password*',
77
+ '*credentials*',
78
+ '*token*',
79
+ 'secrets.json',
80
+ 'appsettings.Production.json',
81
+ 'appsettings.Staging.json',
82
+ '*.log',
83
+ '*.sqlite',
84
+ '*.db'
85
+ ];
86
+
87
+ /**
88
+ * Secret patterns to redact from file contents
89
+ * Each pattern has: regex, replacement text, description
90
+ */
91
+ export const SECRET_PATTERNS = [
92
+ {
93
+ name: 'api-key',
94
+ regex: /(?:api[_-]?key|apikey|api[_-]?secret)[\s:=]+["']?([a-zA-Z0-9_\-]{20,})["']?/gi,
95
+ replacement: 'API_KEY=***REDACTED***',
96
+ description: 'API keys'
97
+ },
98
+ {
99
+ name: 'bearer-token',
100
+ regex: /(?:bearer|authorization)[\s:=]+["']?([a-zA-Z0-9_\-\.]{20,})["']?/gi,
101
+ replacement: 'Bearer ***REDACTED***',
102
+ description: 'Bearer tokens'
103
+ },
104
+ {
105
+ name: 'connection-string',
106
+ regex: /(?:connection[_-]?string|connectionstring)[\s:=]+["']?([^"'\n]{30,})["']?/gi,
107
+ replacement: 'ConnectionString=***REDACTED***',
108
+ description: 'Connection strings'
109
+ },
110
+ {
111
+ name: 'sql-password',
112
+ regex: /(?:password|pwd)=([^;"\s]{6,})/gi,
113
+ replacement: 'Password=***REDACTED***',
114
+ description: 'SQL passwords in connection strings'
115
+ },
116
+ {
117
+ name: 'azure-key',
118
+ regex: /(?:account[_-]?key|accountkey)[\s:=]+["']?([a-zA-Z0-9+/=]{40,})["']?/gi,
119
+ replacement: 'AccountKey=***REDACTED***',
120
+ description: 'Azure Storage Account Keys'
121
+ },
122
+ {
123
+ name: 'jwt-secret',
124
+ regex: /(?:jwt[_-]?secret|jwtsecret)[\s:=]+["']?([a-zA-Z0-9_\-]{16,})["']?/gi,
125
+ replacement: 'JwtSecret=***REDACTED***',
126
+ description: 'JWT secrets'
127
+ },
128
+ {
129
+ name: 'private-key',
130
+ regex: /-----BEGIN (?:RSA |EC )?PRIVATE KEY-----[\s\S]+?-----END (?:RSA |EC )?PRIVATE KEY-----/gi,
131
+ replacement: '-----BEGIN PRIVATE KEY-----\n***REDACTED***\n-----END PRIVATE KEY-----',
132
+ description: 'Private keys (PEM format)'
133
+ },
134
+ {
135
+ name: 'github-token',
136
+ regex: /gh[pousr]_[a-zA-Z0-9]{36,}/gi,
137
+ replacement: 'ghp_***REDACTED***',
138
+ description: 'GitHub personal access tokens'
139
+ },
140
+ {
141
+ name: 'npm-token',
142
+ regex: /npm_[a-zA-Z0-9]{36,}/gi,
143
+ replacement: 'npm_***REDACTED***',
144
+ description: 'NPM tokens'
145
+ },
146
+ {
147
+ name: 'generic-secret',
148
+ regex: /(?:secret|password|pwd|pass|token)[\s:=]+["']([^"'\n]{8,})["']/gi,
149
+ replacement: 'secret=***REDACTED***',
150
+ description: 'Generic secrets'
151
+ }
152
+ ];
153
+
154
+ /**
155
+ * Maximum file size to include (50KB)
156
+ * Files larger than this are truncated with a summary
157
+ */
158
+ export const MAX_FILE_SIZE = 50 * 1024; // 50KB
159
+
160
+ /**
161
+ * Maximum content length for README/CLAUDE.md summaries
162
+ */
163
+ export const MAX_SUMMARY_LENGTH = 500; // 500 chars
File without changes