devbrain-cli 0.1.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 (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +26 -0
  3. package/dist/bin.d.ts +2 -0
  4. package/dist/bin.js +48 -0
  5. package/dist/commands/context.command.d.ts +16 -0
  6. package/dist/commands/context.command.js +36 -0
  7. package/dist/commands/init.command.d.ts +16 -0
  8. package/dist/commands/init.command.js +57 -0
  9. package/dist/commands/learn.command.d.ts +17 -0
  10. package/dist/commands/learn.command.js +72 -0
  11. package/dist/pipeline/command.pipeline.d.ts +28 -0
  12. package/dist/pipeline/command.pipeline.js +65 -0
  13. package/dist/ui/logger.d.ts +13 -0
  14. package/dist/ui/logger.js +31 -0
  15. package/node_modules/@devbrain/core/dist/analysis/analyzer.interface.d.ts +10 -0
  16. package/node_modules/@devbrain/core/dist/analysis/analyzer.interface.js +2 -0
  17. package/node_modules/@devbrain/core/dist/analysis/analyzer.registry.d.ts +20 -0
  18. package/node_modules/@devbrain/core/dist/analysis/analyzer.registry.js +67 -0
  19. package/node_modules/@devbrain/core/dist/analysis/analyzers/build-gradle.analyzer.d.ts +14 -0
  20. package/node_modules/@devbrain/core/dist/analysis/analyzers/build-gradle.analyzer.js +53 -0
  21. package/node_modules/@devbrain/core/dist/analysis/analyzers/docker.analyzer.d.ts +14 -0
  22. package/node_modules/@devbrain/core/dist/analysis/analyzers/docker.analyzer.js +38 -0
  23. package/node_modules/@devbrain/core/dist/analysis/analyzers/git.analyzer.d.ts +14 -0
  24. package/node_modules/@devbrain/core/dist/analysis/analyzers/git.analyzer.js +54 -0
  25. package/node_modules/@devbrain/core/dist/analysis/analyzers/package-json.analyzer.d.ts +14 -0
  26. package/node_modules/@devbrain/core/dist/analysis/analyzers/package-json.analyzer.js +72 -0
  27. package/node_modules/@devbrain/core/dist/analysis/analyzers/pom-xml.analyzer.d.ts +14 -0
  28. package/node_modules/@devbrain/core/dist/analysis/analyzers/pom-xml.analyzer.js +70 -0
  29. package/node_modules/@devbrain/core/dist/analysis/analyzers/readme.analyzer.d.ts +17 -0
  30. package/node_modules/@devbrain/core/dist/analysis/analyzers/readme.analyzer.js +65 -0
  31. package/node_modules/@devbrain/core/dist/analysis/analyzers/requirements-txt.analyzer.d.ts +14 -0
  32. package/node_modules/@devbrain/core/dist/analysis/analyzers/requirements-txt.analyzer.js +62 -0
  33. package/node_modules/@devbrain/core/dist/analysis/analyzers/tsconfig.analyzer.d.ts +14 -0
  34. package/node_modules/@devbrain/core/dist/analysis/analyzers/tsconfig.analyzer.js +47 -0
  35. package/node_modules/@devbrain/core/dist/analysis/scanner.d.ts +21 -0
  36. package/node_modules/@devbrain/core/dist/analysis/scanner.js +81 -0
  37. package/node_modules/@devbrain/core/dist/context/context.service.d.ts +17 -0
  38. package/node_modules/@devbrain/core/dist/context/context.service.js +72 -0
  39. package/node_modules/@devbrain/core/dist/filesystem/filesystem.service.d.ts +29 -0
  40. package/node_modules/@devbrain/core/dist/filesystem/filesystem.service.js +87 -0
  41. package/node_modules/@devbrain/core/dist/index.d.ts +14 -0
  42. package/node_modules/@devbrain/core/dist/index.js +16 -0
  43. package/node_modules/@devbrain/core/dist/memory/memory.service.d.ts +19 -0
  44. package/node_modules/@devbrain/core/dist/memory/memory.service.js +158 -0
  45. package/node_modules/@devbrain/core/package.json +22 -0
  46. package/node_modules/@devbrain/shared/dist/constants.d.ts +6 -0
  47. package/node_modules/@devbrain/shared/dist/constants.js +15 -0
  48. package/node_modules/@devbrain/shared/dist/errors.d.ts +38 -0
  49. package/node_modules/@devbrain/shared/dist/errors.js +64 -0
  50. package/node_modules/@devbrain/shared/dist/index.d.ts +3 -0
  51. package/node_modules/@devbrain/shared/dist/index.js +4 -0
  52. package/node_modules/@devbrain/shared/dist/types.d.ts +52 -0
  53. package/node_modules/@devbrain/shared/dist/types.js +2 -0
  54. package/node_modules/@devbrain/shared/package.json +14 -0
  55. package/package.json +65 -0
@@ -0,0 +1,72 @@
1
+ import { join } from 'node:path';
2
+ import { FilesystemService } from '../filesystem/filesystem.service.js';
3
+ import { ValidationError } from '@devbrain/shared';
4
+ /**
5
+ * Service responsible for reading generated project memory and consolidating it into an optimized AI prompt context.
6
+ */
7
+ export class ContextService {
8
+ fsService;
9
+ constructor(fsService = new FilesystemService()) {
10
+ this.fsService = fsService;
11
+ }
12
+ /**
13
+ * Reads memory markdown files, validates existence, and compiles them into a single token-efficient string.
14
+ */
15
+ async buildContext(memoryDir) {
16
+ const files = [
17
+ 'summary.md',
18
+ 'stack.md',
19
+ 'architecture.md',
20
+ 'features.md',
21
+ 'rules.md',
22
+ 'timeline.md',
23
+ ];
24
+ const parts = [];
25
+ // Ensure memory folder exists
26
+ if (!(await this.fsService.exists(memoryDir))) {
27
+ throw new ValidationError('Project memory directory not found.', `The directory ${memoryDir} does not exist.`, 'Run "devbrain learn" to scan the repository and populate the memory files first.');
28
+ }
29
+ parts.push('<!-- START OF DEVBRAIN AI ASSISTANT CONTEXT SCHEMA -->');
30
+ parts.push('# DEVBRAIN PROJECT CONTEXT INDEX');
31
+ parts.push('');
32
+ for (const file of files) {
33
+ const filePath = join(memoryDir, file);
34
+ if (!(await this.fsService.exists(filePath))) {
35
+ continue; // Skip missing files gracefully or use a warning comment
36
+ }
37
+ const content = await this.fsService.read(filePath);
38
+ const formatted = this.normalizeHeadings(file, content);
39
+ parts.push(formatted);
40
+ parts.push('');
41
+ }
42
+ parts.push('<!-- END OF DEVBRAIN AI ASSISTANT CONTEXT SCHEMA -->');
43
+ return parts.join('\n');
44
+ }
45
+ /**
46
+ * Formats and converts absolute top-level headers (#) to sub-headers (##)
47
+ * to maintain a single root h1 structure and optimizes whitespaces.
48
+ */
49
+ normalizeHeadings(fileName, content) {
50
+ const sectionName = fileName.replace('.md', '').toUpperCase();
51
+ const lines = content.split('\n');
52
+ const processedLines = [`## SECTION: ${sectionName}`, ''];
53
+ for (let line of lines) {
54
+ line = line.trimEnd();
55
+ // Translate root header # to second-level ##
56
+ if (line.startsWith('# ')) {
57
+ processedLines.push(`### ${line.substring(2)}`);
58
+ }
59
+ else if (line.startsWith('## ')) {
60
+ processedLines.push(`#### ${line.substring(3)}`);
61
+ }
62
+ else if (line.startsWith('### ')) {
63
+ processedLines.push(`##### ${line.substring(4)}`);
64
+ }
65
+ else {
66
+ processedLines.push(line);
67
+ }
68
+ }
69
+ return processedLines.join('\n').trim();
70
+ }
71
+ }
72
+ //# sourceMappingURL=context.service.js.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Service for safe filesystem operations.
3
+ */
4
+ export declare class FilesystemService {
5
+ /**
6
+ * Check if a path exists.
7
+ */
8
+ exists(path: string): Promise<boolean>;
9
+ /**
10
+ * Reads contents of a file as a string.
11
+ */
12
+ read(path: string): Promise<string>;
13
+ /**
14
+ * Writes content to a file, creating directories recursively.
15
+ */
16
+ write(path: string, content: string): Promise<void>;
17
+ /**
18
+ * Atomically writes file content by writing to a temporary file then renaming.
19
+ */
20
+ writeAtomic(path: string, content: string): Promise<void>;
21
+ /**
22
+ * Reads and parses a JSON file.
23
+ */
24
+ readJson<T>(path: string): Promise<T>;
25
+ /**
26
+ * Writes JSON data to a file (optionally atomically).
27
+ */
28
+ writeJson(path: string, data: any, indent?: number): Promise<void>;
29
+ }
@@ -0,0 +1,87 @@
1
+ import { mkdir, readFile, writeFile, rename, stat } from 'node:fs/promises';
2
+ import { dirname } from 'node:path';
3
+ import { FilesystemError } from '@devbrain/shared';
4
+ /**
5
+ * Service for safe filesystem operations.
6
+ */
7
+ export class FilesystemService {
8
+ /**
9
+ * Check if a path exists.
10
+ */
11
+ async exists(path) {
12
+ try {
13
+ await stat(path);
14
+ return true;
15
+ }
16
+ catch {
17
+ return false;
18
+ }
19
+ }
20
+ /**
21
+ * Reads contents of a file as a string.
22
+ */
23
+ async read(path) {
24
+ try {
25
+ return await readFile(path, 'utf8');
26
+ }
27
+ catch (error) {
28
+ throw new FilesystemError(`Failed to read file at ${path}`, error.message || 'File might not exist or is not readable', 'Verify the path is correct and has appropriate read permissions.');
29
+ }
30
+ }
31
+ /**
32
+ * Writes content to a file, creating directories recursively.
33
+ */
34
+ async write(path, content) {
35
+ try {
36
+ const dir = dirname(path);
37
+ await mkdir(dir, { recursive: true });
38
+ await writeFile(path, content, 'utf8');
39
+ }
40
+ catch (error) {
41
+ throw new FilesystemError(`Failed to write file to ${path}`, error.message || 'Directory could not be created or file is locked', 'Check disk space, directory write permissions, and that target file is not locked.');
42
+ }
43
+ }
44
+ /**
45
+ * Atomically writes file content by writing to a temporary file then renaming.
46
+ */
47
+ async writeAtomic(path, content) {
48
+ const tempPath = `${path}.tmp-${Date.now()}-${Math.random().toString(36).substring(2, 8)}`;
49
+ try {
50
+ await this.write(tempPath, content);
51
+ await rename(tempPath, path);
52
+ }
53
+ catch (error) {
54
+ // Clean up temp path if it exists
55
+ try {
56
+ if (await this.exists(tempPath)) {
57
+ const { unlink } = await import('node:fs/promises');
58
+ await unlink(tempPath);
59
+ }
60
+ }
61
+ catch {
62
+ // Ignore cleanup error
63
+ }
64
+ throw new FilesystemError(`Failed to atomically write file to ${path}`, error.message || 'Atomic rename failed', 'Ensure the destination folder is writable and in the same filesystem drive.');
65
+ }
66
+ }
67
+ /**
68
+ * Reads and parses a JSON file.
69
+ */
70
+ async readJson(path) {
71
+ const raw = await this.read(path);
72
+ try {
73
+ return JSON.parse(raw);
74
+ }
75
+ catch (error) {
76
+ throw new FilesystemError(`Failed to parse JSON file at ${path}`, error.message || 'Invalid JSON format', 'Correct the JSON syntax or reconstruct the file configuration.');
77
+ }
78
+ }
79
+ /**
80
+ * Writes JSON data to a file (optionally atomically).
81
+ */
82
+ async writeJson(path, data, indent = 2) {
83
+ const content = JSON.stringify(data, null, indent) + '\n';
84
+ await this.writeAtomic(path, content);
85
+ }
86
+ }
87
+ //# sourceMappingURL=filesystem.service.js.map
@@ -0,0 +1,14 @@
1
+ export { FilesystemService } from './filesystem/filesystem.service.js';
2
+ export { RepositoryScanner, ScanOptions } from './analysis/scanner.js';
3
+ export { Analyzer } from './analysis/analyzer.interface.js';
4
+ export { AnalyzerRegistry } from './analysis/analyzer.registry.js';
5
+ export { MemoryService } from './memory/memory.service.js';
6
+ export { ContextService } from './context/context.service.js';
7
+ export { ReadmeAnalyzer } from './analysis/analyzers/readme.analyzer.js';
8
+ export { PackageJsonAnalyzer } from './analysis/analyzers/package-json.analyzer.js';
9
+ export { TsconfigAnalyzer } from './analysis/analyzers/tsconfig.analyzer.js';
10
+ export { GitAnalyzer } from './analysis/analyzers/git.analyzer.js';
11
+ export { DockerfileAnalyzer } from './analysis/analyzers/docker.analyzer.js';
12
+ export { RequirementsTxtAnalyzer } from './analysis/analyzers/requirements-txt.analyzer.js';
13
+ export { PomXmlAnalyzer } from './analysis/analyzers/pom-xml.analyzer.js';
14
+ export { BuildGradleAnalyzer } from './analysis/analyzers/build-gradle.analyzer.js';
@@ -0,0 +1,16 @@
1
+ // Public API exports for @devbrain/core
2
+ export { FilesystemService } from './filesystem/filesystem.service.js';
3
+ export { RepositoryScanner } from './analysis/scanner.js';
4
+ export { AnalyzerRegistry } from './analysis/analyzer.registry.js';
5
+ export { MemoryService } from './memory/memory.service.js';
6
+ export { ContextService } from './context/context.service.js';
7
+ // Concrete Analyzer exports
8
+ export { ReadmeAnalyzer } from './analysis/analyzers/readme.analyzer.js';
9
+ export { PackageJsonAnalyzer } from './analysis/analyzers/package-json.analyzer.js';
10
+ export { TsconfigAnalyzer } from './analysis/analyzers/tsconfig.analyzer.js';
11
+ export { GitAnalyzer } from './analysis/analyzers/git.analyzer.js';
12
+ export { DockerfileAnalyzer } from './analysis/analyzers/docker.analyzer.js';
13
+ export { RequirementsTxtAnalyzer } from './analysis/analyzers/requirements-txt.analyzer.js';
14
+ export { PomXmlAnalyzer } from './analysis/analyzers/pom-xml.analyzer.js';
15
+ export { BuildGradleAnalyzer } from './analysis/analyzers/build-gradle.analyzer.js';
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,19 @@
1
+ import { AggregatedAnalysis } from '@devbrain/shared';
2
+ import { FilesystemService } from '../filesystem/filesystem.service.js';
3
+ /**
4
+ * Service responsible for generating deterministic, human-readable markdown project documentation.
5
+ */
6
+ export declare class MemoryService {
7
+ private readonly fsService;
8
+ constructor(fsService?: FilesystemService);
9
+ /**
10
+ * Generates memory markdown files and writes them to the specified directory.
11
+ */
12
+ generateMemory(analysis: AggregatedAnalysis, memoryDir: string): Promise<void>;
13
+ private buildSummary;
14
+ private buildStack;
15
+ private buildArchitecture;
16
+ private buildFeatures;
17
+ private buildRules;
18
+ private buildTimeline;
19
+ }
@@ -0,0 +1,158 @@
1
+ import { join } from 'node:path';
2
+ import { FilesystemService } from '../filesystem/filesystem.service.js';
3
+ /**
4
+ * Service responsible for generating deterministic, human-readable markdown project documentation.
5
+ */
6
+ export class MemoryService {
7
+ fsService;
8
+ constructor(fsService = new FilesystemService()) {
9
+ this.fsService = fsService;
10
+ }
11
+ /**
12
+ * Generates memory markdown files and writes them to the specified directory.
13
+ */
14
+ async generateMemory(analysis, memoryDir) {
15
+ const summary = this.buildSummary(analysis);
16
+ const stack = this.buildStack(analysis);
17
+ const architecture = this.buildArchitecture(analysis);
18
+ const features = this.buildFeatures(analysis);
19
+ const rules = this.buildRules(analysis);
20
+ const timeline = this.buildTimeline(analysis);
21
+ await this.fsService.write(join(memoryDir, 'summary.md'), summary);
22
+ await this.fsService.write(join(memoryDir, 'stack.md'), stack);
23
+ await this.fsService.write(join(memoryDir, 'architecture.md'), architecture);
24
+ await this.fsService.write(join(memoryDir, 'features.md'), features);
25
+ await this.fsService.write(join(memoryDir, 'rules.md'), rules);
26
+ await this.fsService.write(join(memoryDir, 'timeline.md'), timeline);
27
+ }
28
+ buildSummary(analysis) {
29
+ const readmeData = analysis.analyzers.readme || {};
30
+ const packageJsonData = analysis.analyzers['package-json'] || {};
31
+ const overview = readmeData.description || 'No project description available.';
32
+ const projectName = analysis.projectName || packageJsonData.name || 'unnamed-project';
33
+ const fileList = [...analysis.files].sort();
34
+ const treeLines = fileList.map((f) => `- ${f}`).join('\n');
35
+ return [
36
+ `# Project Summary: ${projectName}`,
37
+ '',
38
+ '## Overview',
39
+ overview,
40
+ '',
41
+ '## Repository Structure',
42
+ `Total Files Tracked: ${analysis.files.length}`,
43
+ '',
44
+ treeLines,
45
+ '',
46
+ ].join('\n');
47
+ }
48
+ buildStack(analysis) {
49
+ const techList = [...analysis.technologies]
50
+ .sort()
51
+ .map((t) => `- **${t}**`)
52
+ .join('\n') || '- None detected';
53
+ const fwList = [...analysis.frameworks]
54
+ .sort()
55
+ .map((f) => `- **${f}**`)
56
+ .join('\n') || '- None detected';
57
+ return [
58
+ '# Technology Stack',
59
+ '',
60
+ '## Core Languages & Runtimes',
61
+ techList,
62
+ '',
63
+ '## Frameworks & Libraries',
64
+ fwList,
65
+ '',
66
+ ].join('\n');
67
+ }
68
+ buildArchitecture(analysis) {
69
+ const packageJsonData = analysis.analyzers['package-json'] || {};
70
+ const dockerfileData = analysis.analyzers.dockerfile || {};
71
+ const backendTech = analysis.technologies.includes('Node.js') ? 'Node.js' : 'unknown';
72
+ const buildTool = packageJsonData.dependencies ? 'npm' : 'unknown';
73
+ const dockerBase = dockerfileData.baseImage
74
+ ? `Docker (Base image: ${dockerfileData.baseImage})`
75
+ : 'None detected';
76
+ return [
77
+ '# Project Architecture',
78
+ '',
79
+ '## Layers & Runtimes',
80
+ `- **Backend Runtime**: ${backendTech}`,
81
+ `- **Build / Package Manager**: ${buildTool}`,
82
+ `- **Containerization / Deployment**: ${dockerBase}`,
83
+ '',
84
+ '## Module System & Standards',
85
+ `- **Primary Language**: ${analysis.metadata.projectLanguage || 'unknown'}`,
86
+ `- **Default Framework**: ${analysis.metadata.projectFramework || 'None'}`,
87
+ '',
88
+ ].join('\n');
89
+ }
90
+ buildFeatures(analysis) {
91
+ const packageJsonData = analysis.analyzers['package-json'] || {};
92
+ const scripts = packageJsonData.scripts || [];
93
+ // Scan file paths to infer feature areas
94
+ const features = [];
95
+ const files = analysis.files;
96
+ if (files.some((f) => f.includes('controller')))
97
+ features.push('Controller layer (business routing)');
98
+ if (files.some((f) => f.includes('route')))
99
+ features.push('API routing definition');
100
+ if (files.some((f) => f.includes('component') || f.includes('view')))
101
+ features.push('UI components / presentation layer');
102
+ if (files.some((f) => f.includes('service') || f.includes('provider')))
103
+ features.push('Service integrations / business logic');
104
+ if (files.some((f) => f.includes('model') || f.includes('entity')))
105
+ features.push('Data models / entity schemas');
106
+ if (files.some((f) => f.includes('tests/') || f.endsWith('.test.ts') || f.endsWith('.spec.ts')))
107
+ features.push('Unit/Integration Testing suite');
108
+ const featureList = features.map((f) => `- ${f}`).join('\n') || '- Basic codebase files structure';
109
+ const scriptsList = scripts.map((s) => `- \`npm run ${s}\``).join('\n') || '- None declared';
110
+ return [
111
+ '# Product Features',
112
+ '',
113
+ '## Codebase Feature Capabilities',
114
+ featureList,
115
+ '',
116
+ '## Runnable Project Commands',
117
+ scriptsList,
118
+ '',
119
+ ].join('\n');
120
+ }
121
+ buildRules(analysis) {
122
+ const tsconfigData = analysis.analyzers.tsconfig || {};
123
+ const rules = [
124
+ '# Project Coding Rules & Conventions',
125
+ '',
126
+ '## Compiler Options & Code Style Standards',
127
+ ];
128
+ if (tsconfigData.target) {
129
+ rules.push(`- **TypeScript Target**: ${tsconfigData.target}`);
130
+ rules.push(`- **Module System**: ${tsconfigData.module}`);
131
+ rules.push(`- **Strict Type Checking**: ${tsconfigData.strict ? 'Enabled' : 'Disabled'}`);
132
+ rules.push(`- **JSX Engine**: ${tsconfigData.jsx}`);
133
+ }
134
+ else {
135
+ rules.push('- No TypeScript rules detected. Applying default ES rules.');
136
+ }
137
+ rules.push('', '## General Architecture Rules', '- Enforce clean boundaries: CLI layer -> Core layer -> Shared utility layer.', '- Modular composition preferred over inheritance patterns.', '');
138
+ return rules.join('\n');
139
+ }
140
+ buildTimeline(analysis) {
141
+ const gitData = analysis.analyzers.git || {};
142
+ const commits = gitData.recentCommits || [];
143
+ const commitLines = commits.map((c) => `- **${c.hash}** - ${c.message} (${c.author})`).join('\n') ||
144
+ '- No commits found or git history unavailable';
145
+ const branch = gitData.branch || 'unknown';
146
+ return [
147
+ '# Project Timeline & History',
148
+ '',
149
+ '## Git Metrics',
150
+ `- **Current Branch**: ${branch}`,
151
+ '',
152
+ '## Recent Commit Log',
153
+ commitLines,
154
+ '',
155
+ ].join('\n');
156
+ }
157
+ }
158
+ //# sourceMappingURL=memory.service.js.map
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@devbrain/core",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "type": "module",
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "scripts": {
12
+ "build": "tsc --build"
13
+ },
14
+ "dependencies": {
15
+ "@devbrain/shared": "^0.1.0"
16
+ },
17
+ "devDependencies": {
18
+ "fast-glob": "^3.3.2",
19
+ "fast-xml-parser": "^5.9.3",
20
+ "simple-git": "^3.23.0"
21
+ }
22
+ }
@@ -0,0 +1,6 @@
1
+ export declare const DEVBRAIN_VERSION = "0.1.0";
2
+ export declare const DEFAULT_IGNORE_PATTERNS: string[];
3
+ export declare const CONFIG_FILE_NAME = "config.json";
4
+ export declare const MEMORY_DIR_NAME = "memory";
5
+ export declare const DEVBRAIN_DIR_NAME = ".devbrain";
6
+ export declare const DEFAULT_MEMORY_DIR = ".devbrain/memory";
@@ -0,0 +1,15 @@
1
+ export const DEVBRAIN_VERSION = '0.1.0';
2
+ export const DEFAULT_IGNORE_PATTERNS = [
3
+ '**/node_modules/**',
4
+ '**/.git/**',
5
+ '**/dist/**',
6
+ '**/coverage/**',
7
+ '**/target/**',
8
+ '**/build/**',
9
+ '**/.cache/**',
10
+ ];
11
+ export const CONFIG_FILE_NAME = 'config.json';
12
+ export const MEMORY_DIR_NAME = 'memory';
13
+ export const DEVBRAIN_DIR_NAME = '.devbrain';
14
+ export const DEFAULT_MEMORY_DIR = `${DEVBRAIN_DIR_NAME}/${MEMORY_DIR_NAME}`;
15
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Base error class for all DevBrain errors.
3
+ * Provides structured details: what happened, why, and how to fix it.
4
+ */
5
+ export declare class DevBrainError extends Error {
6
+ readonly code: string;
7
+ readonly explanation: string;
8
+ readonly remediation: string;
9
+ constructor(code: string, message: string, explanation: string, remediation: string);
10
+ /**
11
+ * Formats the error into a detailed, user-friendly CLI report.
12
+ */
13
+ formatReport(): string;
14
+ }
15
+ /**
16
+ * Thrown when config validation fails.
17
+ */
18
+ export declare class ValidationError extends DevBrainError {
19
+ constructor(message: string, explanation: string, remediation: string);
20
+ }
21
+ /**
22
+ * Thrown when a filesystem operation fails.
23
+ */
24
+ export declare class FilesystemError extends DevBrainError {
25
+ constructor(message: string, explanation: string, remediation: string);
26
+ }
27
+ /**
28
+ * Thrown when an analyzer plugin execution fails.
29
+ */
30
+ export declare class AnalyzerError extends DevBrainError {
31
+ constructor(message: string, explanation: string, remediation: string);
32
+ }
33
+ /**
34
+ * Thrown when command pipeline lifecycle encounters an execution error.
35
+ */
36
+ export declare class CommandError extends DevBrainError {
37
+ constructor(message: string, explanation: string, remediation: string);
38
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Base error class for all DevBrain errors.
3
+ * Provides structured details: what happened, why, and how to fix it.
4
+ */
5
+ export class DevBrainError extends Error {
6
+ code;
7
+ explanation;
8
+ remediation;
9
+ constructor(code, message, explanation, remediation) {
10
+ super(message);
11
+ this.code = code;
12
+ this.explanation = explanation;
13
+ this.remediation = remediation;
14
+ this.name = 'DevBrainError';
15
+ Object.setPrototypeOf(this, new.target.prototype);
16
+ }
17
+ /**
18
+ * Formats the error into a detailed, user-friendly CLI report.
19
+ */
20
+ formatReport() {
21
+ return [
22
+ `Error [${this.code}]: ${this.message}`,
23
+ `Why: ${this.explanation}`,
24
+ `Fix: ${this.remediation}`,
25
+ ].join('\n');
26
+ }
27
+ }
28
+ /**
29
+ * Thrown when config validation fails.
30
+ */
31
+ export class ValidationError extends DevBrainError {
32
+ constructor(message, explanation, remediation) {
33
+ super('VALIDATION_ERROR', message, explanation, remediation);
34
+ this.name = 'ValidationError';
35
+ }
36
+ }
37
+ /**
38
+ * Thrown when a filesystem operation fails.
39
+ */
40
+ export class FilesystemError extends DevBrainError {
41
+ constructor(message, explanation, remediation) {
42
+ super('FILESYSTEM_ERROR', message, explanation, remediation);
43
+ this.name = 'FilesystemError';
44
+ }
45
+ }
46
+ /**
47
+ * Thrown when an analyzer plugin execution fails.
48
+ */
49
+ export class AnalyzerError extends DevBrainError {
50
+ constructor(message, explanation, remediation) {
51
+ super('ANALYZER_ERROR', message, explanation, remediation);
52
+ this.name = 'AnalyzerError';
53
+ }
54
+ }
55
+ /**
56
+ * Thrown when command pipeline lifecycle encounters an execution error.
57
+ */
58
+ export class CommandError extends DevBrainError {
59
+ constructor(message, explanation, remediation) {
60
+ super('COMMAND_ERROR', message, explanation, remediation);
61
+ this.name = 'CommandError';
62
+ }
63
+ }
64
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1,3 @@
1
+ export * from './types.js';
2
+ export * from './errors.js';
3
+ export * from './constants.js';
@@ -0,0 +1,4 @@
1
+ export * from './types.js';
2
+ export * from './errors.js';
3
+ export * from './constants.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Configuration schema for DevBrain.
3
+ */
4
+ export interface DevBrainConfig {
5
+ version: string;
6
+ project: {
7
+ name: string;
8
+ language?: string;
9
+ framework?: string;
10
+ };
11
+ scanner: {
12
+ ignore: string[];
13
+ followSymlinks: boolean;
14
+ respectGitignore: boolean;
15
+ };
16
+ memory: {
17
+ format: 'markdown';
18
+ directory: string;
19
+ };
20
+ }
21
+ /**
22
+ * Context that is passed through the command lifecycle pipeline.
23
+ */
24
+ export interface CommandContext {
25
+ cwd: string;
26
+ config?: DevBrainConfig;
27
+ debug: boolean;
28
+ }
29
+ /**
30
+ * Result of individual file analysis.
31
+ */
32
+ export interface AnalysisResult {
33
+ analyzerId: string;
34
+ analyzerName: string;
35
+ data: Record<string, any>;
36
+ }
37
+ /**
38
+ * Aggregated repository metadata and technology details.
39
+ */
40
+ export interface AggregatedAnalysis {
41
+ projectName: string;
42
+ technologies: string[];
43
+ frameworks: string[];
44
+ metadata: Record<string, any>;
45
+ files: string[];
46
+ analyzers: Record<string, any>;
47
+ }
48
+ export interface ProjectContext {
49
+ cwd: string;
50
+ files: string[];
51
+ config: DevBrainConfig;
52
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@devbrain/shared",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "type": "module",
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "scripts": {
12
+ "build": "tsc --build"
13
+ }
14
+ }