agents-reverse-engineer 0.1.1
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/LICENSE +21 -0
- package/README.md +238 -0
- package/dist/change-detection/detector.d.ts +24 -0
- package/dist/change-detection/detector.d.ts.map +1 -0
- package/dist/change-detection/detector.js +114 -0
- package/dist/change-detection/detector.js.map +1 -0
- package/dist/change-detection/index.d.ts +9 -0
- package/dist/change-detection/index.d.ts.map +1 -0
- package/dist/change-detection/index.js +8 -0
- package/dist/change-detection/index.js.map +1 -0
- package/dist/change-detection/types.d.ts +39 -0
- package/dist/change-detection/types.d.ts.map +1 -0
- package/dist/change-detection/types.js +5 -0
- package/dist/change-detection/types.js.map +1 -0
- package/dist/cli/discover.d.ts +52 -0
- package/dist/cli/discover.d.ts.map +1 -0
- package/dist/cli/discover.js +125 -0
- package/dist/cli/discover.js.map +1 -0
- package/dist/cli/generate.d.ts +41 -0
- package/dist/cli/generate.d.ts.map +1 -0
- package/dist/cli/generate.js +179 -0
- package/dist/cli/generate.js.map +1 -0
- package/dist/cli/index.d.ts +12 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +182 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init.d.ts +38 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +94 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/update.d.ts +28 -0
- package/dist/cli/update.d.ts.map +1 -0
- package/dist/cli/update.js +296 -0
- package/dist/cli/update.js.map +1 -0
- package/dist/config/defaults.d.ts +38 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +89 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/loader.d.ts +66 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +158 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +235 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +80 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/discovery/filters/binary.d.ts +46 -0
- package/dist/discovery/filters/binary.d.ts.map +1 -0
- package/dist/discovery/filters/binary.js +157 -0
- package/dist/discovery/filters/binary.js.map +1 -0
- package/dist/discovery/filters/custom.d.ts +26 -0
- package/dist/discovery/filters/custom.d.ts.map +1 -0
- package/dist/discovery/filters/custom.js +50 -0
- package/dist/discovery/filters/custom.js.map +1 -0
- package/dist/discovery/filters/gitignore.d.ts +24 -0
- package/dist/discovery/filters/gitignore.d.ts.map +1 -0
- package/dist/discovery/filters/gitignore.js +53 -0
- package/dist/discovery/filters/gitignore.js.map +1 -0
- package/dist/discovery/filters/index.d.ts +85 -0
- package/dist/discovery/filters/index.d.ts.map +1 -0
- package/dist/discovery/filters/index.js +98 -0
- package/dist/discovery/filters/index.js.map +1 -0
- package/dist/discovery/filters/vendor.d.ts +30 -0
- package/dist/discovery/filters/vendor.d.ts.map +1 -0
- package/dist/discovery/filters/vendor.js +57 -0
- package/dist/discovery/filters/vendor.js.map +1 -0
- package/dist/discovery/types.d.ts +66 -0
- package/dist/discovery/types.d.ts.map +1 -0
- package/dist/discovery/types.js +8 -0
- package/dist/discovery/types.js.map +1 -0
- package/dist/discovery/walker.d.ts +24 -0
- package/dist/discovery/walker.d.ts.map +1 -0
- package/dist/discovery/walker.js +35 -0
- package/dist/discovery/walker.js.map +1 -0
- package/dist/generation/budget/chunker.d.ts +38 -0
- package/dist/generation/budget/chunker.d.ts.map +1 -0
- package/dist/generation/budget/chunker.js +73 -0
- package/dist/generation/budget/chunker.js.map +1 -0
- package/dist/generation/budget/counter.d.ts +26 -0
- package/dist/generation/budget/counter.d.ts.map +1 -0
- package/dist/generation/budget/counter.js +45 -0
- package/dist/generation/budget/counter.js.map +1 -0
- package/dist/generation/budget/index.d.ts +4 -0
- package/dist/generation/budget/index.d.ts.map +1 -0
- package/dist/generation/budget/index.js +4 -0
- package/dist/generation/budget/index.js.map +1 -0
- package/dist/generation/budget/tracker.d.ts +63 -0
- package/dist/generation/budget/tracker.d.ts.map +1 -0
- package/dist/generation/budget/tracker.js +96 -0
- package/dist/generation/budget/tracker.js.map +1 -0
- package/dist/generation/complexity.d.ts +43 -0
- package/dist/generation/complexity.d.ts.map +1 -0
- package/dist/generation/complexity.js +156 -0
- package/dist/generation/complexity.js.map +1 -0
- package/dist/generation/detection/detector.d.ts +23 -0
- package/dist/generation/detection/detector.d.ts.map +1 -0
- package/dist/generation/detection/detector.js +62 -0
- package/dist/generation/detection/detector.js.map +1 -0
- package/dist/generation/detection/patterns.d.ts +21 -0
- package/dist/generation/detection/patterns.d.ts.map +1 -0
- package/dist/generation/detection/patterns.js +115 -0
- package/dist/generation/detection/patterns.js.map +1 -0
- package/dist/generation/executor.d.ts +95 -0
- package/dist/generation/executor.d.ts.map +1 -0
- package/dist/generation/executor.js +352 -0
- package/dist/generation/executor.js.map +1 -0
- package/dist/generation/orchestrator.d.ts +126 -0
- package/dist/generation/orchestrator.d.ts.map +1 -0
- package/dist/generation/orchestrator.js +222 -0
- package/dist/generation/orchestrator.js.map +1 -0
- package/dist/generation/prompts/builder.d.ts +31 -0
- package/dist/generation/prompts/builder.d.ts.map +1 -0
- package/dist/generation/prompts/builder.js +136 -0
- package/dist/generation/prompts/builder.js.map +1 -0
- package/dist/generation/prompts/index.d.ts +5 -0
- package/dist/generation/prompts/index.d.ts.map +1 -0
- package/dist/generation/prompts/index.js +4 -0
- package/dist/generation/prompts/index.js.map +1 -0
- package/dist/generation/prompts/templates.d.ts +11 -0
- package/dist/generation/prompts/templates.d.ts.map +1 -0
- package/dist/generation/prompts/templates.js +247 -0
- package/dist/generation/prompts/templates.js.map +1 -0
- package/dist/generation/prompts/types.d.ts +71 -0
- package/dist/generation/prompts/types.d.ts.map +1 -0
- package/dist/generation/prompts/types.js +23 -0
- package/dist/generation/prompts/types.js.map +1 -0
- package/dist/generation/types.d.ts +72 -0
- package/dist/generation/types.d.ts.map +1 -0
- package/dist/generation/types.js +5 -0
- package/dist/generation/types.js.map +1 -0
- package/dist/generation/writers/agents-md.d.ts +63 -0
- package/dist/generation/writers/agents-md.d.ts.map +1 -0
- package/dist/generation/writers/agents-md.js +235 -0
- package/dist/generation/writers/agents-md.js.map +1 -0
- package/dist/generation/writers/claude-md.d.ts +13 -0
- package/dist/generation/writers/claude-md.d.ts.map +1 -0
- package/dist/generation/writers/claude-md.js +33 -0
- package/dist/generation/writers/claude-md.js.map +1 -0
- package/dist/generation/writers/index.d.ts +5 -0
- package/dist/generation/writers/index.d.ts.map +1 -0
- package/dist/generation/writers/index.js +5 -0
- package/dist/generation/writers/index.js.map +1 -0
- package/dist/generation/writers/sum.d.ts +37 -0
- package/dist/generation/writers/sum.d.ts.map +1 -0
- package/dist/generation/writers/sum.js +98 -0
- package/dist/generation/writers/sum.js.map +1 -0
- package/dist/generation/writers/supplementary.d.ts +53 -0
- package/dist/generation/writers/supplementary.d.ts.map +1 -0
- package/dist/generation/writers/supplementary.js +195 -0
- package/dist/generation/writers/supplementary.js.map +1 -0
- package/dist/integration/detect.d.ts +28 -0
- package/dist/integration/detect.d.ts.map +1 -0
- package/dist/integration/detect.js +64 -0
- package/dist/integration/detect.js.map +1 -0
- package/dist/integration/generate.d.ts +36 -0
- package/dist/integration/generate.d.ts.map +1 -0
- package/dist/integration/generate.js +107 -0
- package/dist/integration/generate.js.map +1 -0
- package/dist/integration/templates.d.ts +42 -0
- package/dist/integration/templates.d.ts.map +1 -0
- package/dist/integration/templates.js +203 -0
- package/dist/integration/templates.js.map +1 -0
- package/dist/integration/types.d.ts +44 -0
- package/dist/integration/types.d.ts.map +1 -0
- package/dist/integration/types.js +8 -0
- package/dist/integration/types.js.map +1 -0
- package/dist/output/logger.d.ts +86 -0
- package/dist/output/logger.d.ts.map +1 -0
- package/dist/output/logger.js +107 -0
- package/dist/output/logger.js.map +1 -0
- package/dist/state/database.d.ts +9 -0
- package/dist/state/database.d.ts.map +1 -0
- package/dist/state/database.js +66 -0
- package/dist/state/database.js.map +1 -0
- package/dist/state/index.d.ts +8 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +7 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/migrations.d.ts +12 -0
- package/dist/state/migrations.d.ts.map +1 -0
- package/dist/state/migrations.js +39 -0
- package/dist/state/migrations.js.map +1 -0
- package/dist/state/types.d.ts +54 -0
- package/dist/state/types.d.ts.map +1 -0
- package/dist/state/types.js +2 -0
- package/dist/state/types.js.map +1 -0
- package/dist/types/index.d.ts +39 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/update/index.d.ts +10 -0
- package/dist/update/index.d.ts.map +1 -0
- package/dist/update/index.js +9 -0
- package/dist/update/index.js.map +1 -0
- package/dist/update/orchestrator.d.ts +91 -0
- package/dist/update/orchestrator.d.ts.map +1 -0
- package/dist/update/orchestrator.js +204 -0
- package/dist/update/orchestrator.js.map +1 -0
- package/dist/update/orphan-cleaner.d.ts +30 -0
- package/dist/update/orphan-cleaner.d.ts.map +1 -0
- package/dist/update/orphan-cleaner.js +151 -0
- package/dist/update/orphan-cleaner.js.map +1 -0
- package/dist/update/types.d.ts +59 -0
- package/dist/update/types.d.ts.map +1 -0
- package/dist/update/types.js +2 -0
- package/dist/update/types.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { writeFile, readFile, mkdir } from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Build ARCHITECTURE.md content from complexity metrics.
|
|
5
|
+
*
|
|
6
|
+
* This generates a template that the host LLM will expand with actual
|
|
7
|
+
* architectural analysis.
|
|
8
|
+
*/
|
|
9
|
+
export function buildArchitectureMd(metrics, projectName) {
|
|
10
|
+
const sections = [];
|
|
11
|
+
// Header
|
|
12
|
+
sections.push(`# Architecture: ${projectName}\n`);
|
|
13
|
+
sections.push(`> Auto-generated architecture overview. ${metrics.fileCount} files analyzed.\n`);
|
|
14
|
+
// Detected patterns
|
|
15
|
+
if (metrics.architecturalPatterns.length > 0) {
|
|
16
|
+
sections.push('## Architectural Patterns\n');
|
|
17
|
+
for (const pattern of metrics.architecturalPatterns) {
|
|
18
|
+
sections.push(`- **${formatPatternName(pattern)}**`);
|
|
19
|
+
}
|
|
20
|
+
sections.push('');
|
|
21
|
+
}
|
|
22
|
+
// Directory structure (high-level)
|
|
23
|
+
sections.push('## Directory Structure\n');
|
|
24
|
+
sections.push('```');
|
|
25
|
+
const topLevelDirs = getTopLevelDirectories(metrics.directories);
|
|
26
|
+
for (const dir of topLevelDirs.sort()) {
|
|
27
|
+
sections.push(`${dir}/`);
|
|
28
|
+
}
|
|
29
|
+
sections.push('```\n');
|
|
30
|
+
// Layers section (placeholder for LLM expansion)
|
|
31
|
+
sections.push('## Layers\n');
|
|
32
|
+
sections.push('<!-- This section describes the architectural layers -->\n');
|
|
33
|
+
// Data flow section (placeholder)
|
|
34
|
+
sections.push('## Data Flow\n');
|
|
35
|
+
sections.push('<!-- This section describes how data flows through the system -->\n');
|
|
36
|
+
// Key abstractions (placeholder)
|
|
37
|
+
sections.push('## Key Abstractions\n');
|
|
38
|
+
sections.push('<!-- This section describes important interfaces and patterns -->\n');
|
|
39
|
+
return sections.join('\n');
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Format pattern name for display.
|
|
43
|
+
*/
|
|
44
|
+
function formatPatternName(pattern) {
|
|
45
|
+
return pattern
|
|
46
|
+
.split('-')
|
|
47
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
48
|
+
.join(' ');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get top-level directories from all directories.
|
|
52
|
+
*/
|
|
53
|
+
function getTopLevelDirectories(directories) {
|
|
54
|
+
const topLevel = [];
|
|
55
|
+
for (const dir of directories) {
|
|
56
|
+
const parts = dir.split(path.sep);
|
|
57
|
+
if (parts.length === 1 || (parts.length === 2 && parts[0] === '.')) {
|
|
58
|
+
topLevel.push(parts[parts.length - 1]);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return [...new Set(topLevel)];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Build STACK.md content from package.json analysis.
|
|
65
|
+
*/
|
|
66
|
+
export function buildStackMd(stackInfo, projectName) {
|
|
67
|
+
const sections = [];
|
|
68
|
+
// Header
|
|
69
|
+
sections.push(`# Technology Stack: ${projectName}\n`);
|
|
70
|
+
// Runtime
|
|
71
|
+
sections.push('## Runtime\n');
|
|
72
|
+
sections.push(`- **Environment**: ${stackInfo.runtime}`);
|
|
73
|
+
if (stackInfo.framework) {
|
|
74
|
+
sections.push(`- **Framework**: ${stackInfo.framework}`);
|
|
75
|
+
}
|
|
76
|
+
sections.push('');
|
|
77
|
+
// Dependencies by category
|
|
78
|
+
for (const [category, deps] of Object.entries(stackInfo.dependencies)) {
|
|
79
|
+
if (deps.length === 0)
|
|
80
|
+
continue;
|
|
81
|
+
sections.push(`## ${category}\n`);
|
|
82
|
+
for (const dep of deps) {
|
|
83
|
+
const purpose = dep.purpose ? ` - ${dep.purpose}` : '';
|
|
84
|
+
sections.push(`- **${dep.name}** (${dep.version})${purpose}`);
|
|
85
|
+
}
|
|
86
|
+
sections.push('');
|
|
87
|
+
}
|
|
88
|
+
// Dev tools
|
|
89
|
+
if (stackInfo.devTools.length > 0) {
|
|
90
|
+
sections.push('## Development Tools\n');
|
|
91
|
+
for (const tool of stackInfo.devTools) {
|
|
92
|
+
sections.push(`- ${tool}`);
|
|
93
|
+
}
|
|
94
|
+
sections.push('');
|
|
95
|
+
}
|
|
96
|
+
return sections.join('\n');
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Parse package.json to extract stack information.
|
|
100
|
+
*/
|
|
101
|
+
export async function analyzePackageJson(packageJsonPath) {
|
|
102
|
+
try {
|
|
103
|
+
const content = await readFile(packageJsonPath, 'utf-8');
|
|
104
|
+
const pkg = JSON.parse(content);
|
|
105
|
+
const stackInfo = {
|
|
106
|
+
runtime: 'Node.js',
|
|
107
|
+
dependencies: {
|
|
108
|
+
'Core': [],
|
|
109
|
+
'Framework': [],
|
|
110
|
+
'Database': [],
|
|
111
|
+
'Testing': [],
|
|
112
|
+
'Build Tools': [],
|
|
113
|
+
'Other': [],
|
|
114
|
+
},
|
|
115
|
+
devTools: [],
|
|
116
|
+
};
|
|
117
|
+
// Detect framework
|
|
118
|
+
const frameworkDeps = ['next', 'react', 'vue', 'angular', 'svelte', 'express', 'fastify', 'nestjs'];
|
|
119
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
120
|
+
for (const fw of frameworkDeps) {
|
|
121
|
+
if (deps[fw]) {
|
|
122
|
+
stackInfo.framework = fw.charAt(0).toUpperCase() + fw.slice(1);
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Categorize dependencies
|
|
127
|
+
const categoryRules = [
|
|
128
|
+
{ category: 'Framework', patterns: ['react', 'vue', 'angular', 'svelte', 'next', 'nuxt', 'express', 'fastify', 'nestjs'] },
|
|
129
|
+
{ category: 'Database', patterns: ['prisma', 'mongoose', 'typeorm', 'sequelize', 'pg', 'mysql', 'redis', 'drizzle'] },
|
|
130
|
+
{ category: 'Testing', patterns: ['jest', 'vitest', 'mocha', 'chai', 'cypress', 'playwright', '@testing-library'] },
|
|
131
|
+
{ category: 'Build Tools', patterns: ['typescript', 'esbuild', 'vite', 'webpack', 'rollup', 'parcel', 'tsup'] },
|
|
132
|
+
];
|
|
133
|
+
for (const [name, version] of Object.entries(pkg.dependencies ?? {})) {
|
|
134
|
+
let categorized = false;
|
|
135
|
+
for (const rule of categoryRules) {
|
|
136
|
+
if (rule.patterns.some(p => name.toLowerCase().includes(p))) {
|
|
137
|
+
stackInfo.dependencies[rule.category].push({ name, version: version });
|
|
138
|
+
categorized = true;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (!categorized) {
|
|
143
|
+
stackInfo.dependencies['Other'].push({ name, version: version });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Dev tools
|
|
147
|
+
const devToolPatterns = ['eslint', 'prettier', 'husky', 'lint-staged'];
|
|
148
|
+
for (const [name] of Object.entries(pkg.devDependencies ?? {})) {
|
|
149
|
+
if (devToolPatterns.some(p => name.includes(p))) {
|
|
150
|
+
stackInfo.devTools.push(name);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return stackInfo;
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Write ARCHITECTURE.md to the configured location.
|
|
161
|
+
*/
|
|
162
|
+
export async function writeArchitectureMd(projectRoot, metrics, config) {
|
|
163
|
+
if (!config.generateArchitecture)
|
|
164
|
+
return null;
|
|
165
|
+
const outputDir = config.outputDir
|
|
166
|
+
? path.join(projectRoot, config.outputDir)
|
|
167
|
+
: projectRoot;
|
|
168
|
+
await mkdir(outputDir, { recursive: true });
|
|
169
|
+
const projectName = path.basename(projectRoot);
|
|
170
|
+
const content = buildArchitectureMd(metrics, projectName);
|
|
171
|
+
const filePath = path.join(outputDir, 'ARCHITECTURE.md');
|
|
172
|
+
await writeFile(filePath, content, 'utf-8');
|
|
173
|
+
return filePath;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Write STACK.md to the configured location.
|
|
177
|
+
*/
|
|
178
|
+
export async function writeStackMd(projectRoot, config) {
|
|
179
|
+
if (!config.generateStack)
|
|
180
|
+
return null;
|
|
181
|
+
const packageJsonPath = path.join(projectRoot, 'package.json');
|
|
182
|
+
const stackInfo = await analyzePackageJson(packageJsonPath);
|
|
183
|
+
if (!stackInfo)
|
|
184
|
+
return null;
|
|
185
|
+
const outputDir = config.outputDir
|
|
186
|
+
? path.join(projectRoot, config.outputDir)
|
|
187
|
+
: projectRoot;
|
|
188
|
+
await mkdir(outputDir, { recursive: true });
|
|
189
|
+
const projectName = path.basename(projectRoot);
|
|
190
|
+
const content = buildStackMd(stackInfo, projectName);
|
|
191
|
+
const filePath = path.join(outputDir, 'STACK.md');
|
|
192
|
+
await writeFile(filePath, content, 'utf-8');
|
|
193
|
+
return filePath;
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=supplementary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supplementary.js","sourceRoot":"","sources":["../../../src/generation/writers/supplementary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AA6BlC;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAA0B,EAC1B,WAAmB;IAEnB,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,SAAS;IACT,QAAQ,CAAC,IAAI,CAAC,mBAAmB,WAAW,IAAI,CAAC,CAAC;IAClD,QAAQ,CAAC,IAAI,CAAC,2CAA2C,OAAO,CAAC,SAAS,oBAAoB,CAAC,CAAC;IAEhG,oBAAoB;IACpB,IAAI,OAAO,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7C,QAAQ,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;QAC7C,KAAK,MAAM,OAAO,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;YACpD,QAAQ,CAAC,IAAI,CAAC,OAAO,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACvD,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpB,CAAC;IAED,mCAAmC;IACnC,QAAQ,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAC1C,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,MAAM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IAElD,MAAM,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment detection for AI coding assistants
|
|
3
|
+
*
|
|
4
|
+
* Detects which AI coding assistant environments are present in a project
|
|
5
|
+
* by checking for their configuration directories and files.
|
|
6
|
+
*/
|
|
7
|
+
import type { DetectedEnvironment, EnvironmentType } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Detect all AI coding assistant environments present in a project
|
|
10
|
+
*
|
|
11
|
+
* Checks for:
|
|
12
|
+
* - Claude Code: .claude/ directory OR CLAUDE.md file
|
|
13
|
+
* - OpenCode: .opencode/ directory
|
|
14
|
+
* - Aider: .aider.conf.yml file OR .aider/ directory
|
|
15
|
+
*
|
|
16
|
+
* @param projectRoot - Root directory to check for environments
|
|
17
|
+
* @returns Array of detected environments (may include multiple)
|
|
18
|
+
*/
|
|
19
|
+
export declare function detectEnvironments(projectRoot: string): DetectedEnvironment[];
|
|
20
|
+
/**
|
|
21
|
+
* Check if a specific AI coding assistant environment is present
|
|
22
|
+
*
|
|
23
|
+
* @param projectRoot - Root directory to check
|
|
24
|
+
* @param type - Environment type to check for
|
|
25
|
+
* @returns true if the environment is detected
|
|
26
|
+
*/
|
|
27
|
+
export declare function hasEnvironment(projectRoot: string, type: EnvironmentType): boolean;
|
|
28
|
+
//# sourceMappingURL=detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../src/integration/detect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEvE;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAoC7E;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,eAAe,GACpB,OAAO,CAGT"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment detection for AI coding assistants
|
|
3
|
+
*
|
|
4
|
+
* Detects which AI coding assistant environments are present in a project
|
|
5
|
+
* by checking for their configuration directories and files.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
import * as path from 'node:path';
|
|
9
|
+
/**
|
|
10
|
+
* Detect all AI coding assistant environments present in a project
|
|
11
|
+
*
|
|
12
|
+
* Checks for:
|
|
13
|
+
* - Claude Code: .claude/ directory OR CLAUDE.md file
|
|
14
|
+
* - OpenCode: .opencode/ directory
|
|
15
|
+
* - Aider: .aider.conf.yml file OR .aider/ directory
|
|
16
|
+
*
|
|
17
|
+
* @param projectRoot - Root directory to check for environments
|
|
18
|
+
* @returns Array of detected environments (may include multiple)
|
|
19
|
+
*/
|
|
20
|
+
export function detectEnvironments(projectRoot) {
|
|
21
|
+
const environments = [];
|
|
22
|
+
// Check for Claude Code
|
|
23
|
+
const claudeDir = path.join(projectRoot, '.claude');
|
|
24
|
+
const claudeMd = path.join(projectRoot, 'CLAUDE.md');
|
|
25
|
+
if (existsSync(claudeDir) || existsSync(claudeMd)) {
|
|
26
|
+
environments.push({
|
|
27
|
+
type: 'claude',
|
|
28
|
+
configDir: '.claude',
|
|
29
|
+
detected: true,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
// Check for OpenCode
|
|
33
|
+
const openCodeDir = path.join(projectRoot, '.opencode');
|
|
34
|
+
if (existsSync(openCodeDir)) {
|
|
35
|
+
environments.push({
|
|
36
|
+
type: 'opencode',
|
|
37
|
+
configDir: '.opencode',
|
|
38
|
+
detected: true,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
// Check for Aider
|
|
42
|
+
const aiderConfig = path.join(projectRoot, '.aider.conf.yml');
|
|
43
|
+
const aiderDir = path.join(projectRoot, '.aider');
|
|
44
|
+
if (existsSync(aiderConfig) || existsSync(aiderDir)) {
|
|
45
|
+
environments.push({
|
|
46
|
+
type: 'aider',
|
|
47
|
+
configDir: '.aider',
|
|
48
|
+
detected: true,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return environments;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Check if a specific AI coding assistant environment is present
|
|
55
|
+
*
|
|
56
|
+
* @param projectRoot - Root directory to check
|
|
57
|
+
* @param type - Environment type to check for
|
|
58
|
+
* @returns true if the environment is detected
|
|
59
|
+
*/
|
|
60
|
+
export function hasEnvironment(projectRoot, type) {
|
|
61
|
+
const environments = detectEnvironments(projectRoot);
|
|
62
|
+
return environments.some((env) => env.type === type);
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=detect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../../src/integration/detect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAmB;IACpD,MAAM,YAAY,GAA0B,EAAE,CAAC;IAE/C,wBAAwB;IACxB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACrD,IAAI,UAAU,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClD,YAAY,CAAC,IAAI,CAAC;YAChB,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,SAAS;YACpB,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;IACL,CAAC;IAED,qBAAqB;IACrB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACxD,IAAI,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC5B,YAAY,CAAC,IAAI,CAAC;YAChB,IAAI,EAAE,UAAU;YAChB,SAAS,EAAE,WAAW;YACtB,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;IACL,CAAC;IAED,kBAAkB;IAClB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;IAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAClD,IAAI,UAAU,CAAC,WAAW,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpD,YAAY,CAAC,IAAI,CAAC;YAChB,IAAI,EAAE,OAAO;YACb,SAAS,EAAE,QAAQ;YACnB,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;IACL,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,WAAmB,EACnB,IAAqB;IAErB,MAAM,YAAY,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACrD,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration file generation for AI coding assistants
|
|
3
|
+
*
|
|
4
|
+
* Generates command files and hooks for detected AI assistant environments.
|
|
5
|
+
* Handles file creation with directory creation and skip-if-exists behavior.
|
|
6
|
+
*/
|
|
7
|
+
import type { IntegrationResult } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Options for generating integration files
|
|
10
|
+
*/
|
|
11
|
+
export interface GenerateOptions {
|
|
12
|
+
/** If true, don't actually write files - just report what would be done */
|
|
13
|
+
dryRun?: boolean;
|
|
14
|
+
/** If true, overwrite existing files instead of skipping them */
|
|
15
|
+
force?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generate integration files for all detected AI assistant environments
|
|
19
|
+
*
|
|
20
|
+
* For each detected environment:
|
|
21
|
+
* - Gets appropriate templates (command files)
|
|
22
|
+
* - Creates files if they don't exist (or if force=true)
|
|
23
|
+
* - For Claude: also creates the session-end hook
|
|
24
|
+
*
|
|
25
|
+
* @param projectRoot - Root directory of the project
|
|
26
|
+
* @param options - Generation options
|
|
27
|
+
* @returns Array of results, one per environment
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const results = await generateIntegrationFiles('/path/to/project');
|
|
32
|
+
* // [{ environment: 'claude', filesCreated: ['...'], filesSkipped: [] }]
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function generateIntegrationFiles(projectRoot: string, options?: GenerateOptions): Promise<IntegrationResult[]>;
|
|
36
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/integration/generate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAmB,MAAM,YAAY,CAAC;AAQrE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iEAAiE;IACjE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAcD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAsD9B"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration file generation for AI coding assistants
|
|
3
|
+
*
|
|
4
|
+
* Generates command files and hooks for detected AI assistant environments.
|
|
5
|
+
* Handles file creation with directory creation and skip-if-exists behavior.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
8
|
+
import * as path from 'node:path';
|
|
9
|
+
import { detectEnvironments } from './detect.js';
|
|
10
|
+
import { getClaudeTemplates, getOpenCodeTemplates, getHookTemplate, } from './templates.js';
|
|
11
|
+
/**
|
|
12
|
+
* Ensure parent directories exist for a file path
|
|
13
|
+
*
|
|
14
|
+
* @param filePath - Full path to the file
|
|
15
|
+
*/
|
|
16
|
+
function ensureDir(filePath) {
|
|
17
|
+
const dir = path.dirname(filePath);
|
|
18
|
+
if (!existsSync(dir)) {
|
|
19
|
+
mkdirSync(dir, { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Generate integration files for all detected AI assistant environments
|
|
24
|
+
*
|
|
25
|
+
* For each detected environment:
|
|
26
|
+
* - Gets appropriate templates (command files)
|
|
27
|
+
* - Creates files if they don't exist (or if force=true)
|
|
28
|
+
* - For Claude: also creates the session-end hook
|
|
29
|
+
*
|
|
30
|
+
* @param projectRoot - Root directory of the project
|
|
31
|
+
* @param options - Generation options
|
|
32
|
+
* @returns Array of results, one per environment
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const results = await generateIntegrationFiles('/path/to/project');
|
|
37
|
+
* // [{ environment: 'claude', filesCreated: ['...'], filesSkipped: [] }]
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export async function generateIntegrationFiles(projectRoot, options = {}) {
|
|
41
|
+
const { dryRun = false, force = false } = options;
|
|
42
|
+
const results = [];
|
|
43
|
+
// Detect which environments are present
|
|
44
|
+
const environments = detectEnvironments(projectRoot);
|
|
45
|
+
for (const env of environments) {
|
|
46
|
+
const result = {
|
|
47
|
+
environment: env.type,
|
|
48
|
+
filesCreated: [],
|
|
49
|
+
filesSkipped: [],
|
|
50
|
+
};
|
|
51
|
+
// Get templates for this environment
|
|
52
|
+
const templates = getTemplatesForEnvironment(env.type);
|
|
53
|
+
// Process each template
|
|
54
|
+
for (const template of templates) {
|
|
55
|
+
const fullPath = path.join(projectRoot, template.path);
|
|
56
|
+
if (existsSync(fullPath) && !force) {
|
|
57
|
+
// File exists and force is not set - skip it
|
|
58
|
+
result.filesSkipped.push(template.path);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// Create the file
|
|
62
|
+
if (!dryRun) {
|
|
63
|
+
ensureDir(fullPath);
|
|
64
|
+
writeFileSync(fullPath, template.content, 'utf-8');
|
|
65
|
+
}
|
|
66
|
+
result.filesCreated.push(template.path);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// For Claude, also generate the hook file
|
|
70
|
+
if (env.type === 'claude') {
|
|
71
|
+
const hookPath = '.claude/hooks/ar-session-end.js';
|
|
72
|
+
const fullHookPath = path.join(projectRoot, hookPath);
|
|
73
|
+
if (existsSync(fullHookPath) && !force) {
|
|
74
|
+
result.filesSkipped.push(hookPath);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
if (!dryRun) {
|
|
78
|
+
ensureDir(fullHookPath);
|
|
79
|
+
writeFileSync(fullHookPath, getHookTemplate(), 'utf-8');
|
|
80
|
+
}
|
|
81
|
+
result.filesCreated.push(hookPath);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
results.push(result);
|
|
85
|
+
}
|
|
86
|
+
return results;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get templates for a specific environment type
|
|
90
|
+
*
|
|
91
|
+
* @param type - Environment type
|
|
92
|
+
* @returns Array of templates for that environment
|
|
93
|
+
*/
|
|
94
|
+
function getTemplatesForEnvironment(type) {
|
|
95
|
+
switch (type) {
|
|
96
|
+
case 'claude':
|
|
97
|
+
return getClaudeTemplates();
|
|
98
|
+
case 'opencode':
|
|
99
|
+
return getOpenCodeTemplates();
|
|
100
|
+
case 'aider':
|
|
101
|
+
// Aider doesn't have command files yet - return empty
|
|
102
|
+
return [];
|
|
103
|
+
default:
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/integration/generate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAYxB;;;;GAIG;AACH,SAAS,SAAS,CAAC,QAAgB;IACjC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtC,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,WAAmB,EACnB,UAA2B,EAAE;IAE7B,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAClD,MAAM,OAAO,GAAwB,EAAE,CAAC;IAExC,wCAAwC;IACxC,MAAM,YAAY,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAErD,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAC/B,MAAM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;oBACxB,aAAa,CAAC,YAAY,EAAE,eAAe,EAAE,EAAE,OAAO,CAAC,CAAC;gBAC1D,CAAC;gBACD,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,SAAS,0BAA0B,CACjC,IAAqB;IAErB,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,kBAAkB,EAAE,CAAC;QAC9B,KAAK,UAAU;YACb,OAAO,oBAAoB,EAAE,CAAC;QAChC,KAAK,OAAO;YACV,sDAAsD;YACtD,OAAO,EAAE,CAAC;QACZ;YACE,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template generators for AI coding assistant integration files
|
|
3
|
+
*
|
|
4
|
+
* Generates command file templates for Claude Code, OpenCode, and session hooks.
|
|
5
|
+
*/
|
|
6
|
+
import type { IntegrationTemplate } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Get Claude Code command file templates
|
|
9
|
+
*
|
|
10
|
+
* Returns templates for:
|
|
11
|
+
* - generate.md: Full documentation generation command
|
|
12
|
+
* - update.md: Incremental documentation update command
|
|
13
|
+
* - init.md: Initialize agents-reverse-engineer in a project
|
|
14
|
+
*
|
|
15
|
+
* @returns Array of Claude Code command templates
|
|
16
|
+
*/
|
|
17
|
+
export declare function getClaudeTemplates(): IntegrationTemplate[];
|
|
18
|
+
/**
|
|
19
|
+
* Get OpenCode command file templates
|
|
20
|
+
*
|
|
21
|
+
* Returns templates for:
|
|
22
|
+
* - are-generate.md: Full documentation generation command
|
|
23
|
+
* - are-update.md: Incremental documentation update command
|
|
24
|
+
*
|
|
25
|
+
* @returns Array of OpenCode command templates
|
|
26
|
+
*/
|
|
27
|
+
export declare function getOpenCodeTemplates(): IntegrationTemplate[];
|
|
28
|
+
/**
|
|
29
|
+
* Get session-end hook template for automatic documentation updates
|
|
30
|
+
*
|
|
31
|
+
* The hook:
|
|
32
|
+
* - Checks ARE_DISABLE_HOOK env var for temporary disable
|
|
33
|
+
* - Checks config file for permanent disable (hook_enabled: false)
|
|
34
|
+
* - Checks git status and exits silently if no changes
|
|
35
|
+
* - Spawns are update --quiet in background (detached, unref'd)
|
|
36
|
+
*
|
|
37
|
+
* Uses CommonJS (require) since hooks run via node directly.
|
|
38
|
+
*
|
|
39
|
+
* @returns JavaScript hook code as a string
|
|
40
|
+
*/
|
|
41
|
+
export declare function getHookTemplate(): string;
|
|
42
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/integration/templates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,IAAI,mBAAmB,EAAE,CAkF1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,mBAAmB,EAAE,CAuC5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAyCxC"}
|