@blockspool/core 0.3.1 → 0.3.3

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 (93) hide show
  1. package/dist/db/adapter.d.ts +191 -0
  2. package/dist/db/adapter.d.ts.map +1 -0
  3. package/dist/db/adapter.js +40 -0
  4. package/dist/db/adapter.js.map +1 -0
  5. package/dist/db/contract.d.ts +47 -0
  6. package/dist/db/contract.d.ts.map +1 -0
  7. package/dist/db/contract.js +258 -0
  8. package/dist/db/contract.js.map +1 -0
  9. package/dist/db/index.d.ts +6 -0
  10. package/dist/db/index.d.ts.map +1 -0
  11. package/dist/db/index.js +7 -0
  12. package/dist/db/index.js.map +1 -0
  13. package/dist/exec/index.d.ts +5 -0
  14. package/dist/exec/index.d.ts.map +1 -0
  15. package/dist/exec/index.js +5 -0
  16. package/dist/exec/index.js.map +1 -0
  17. package/dist/exec/types.d.ts +64 -0
  18. package/dist/exec/types.d.ts.map +1 -0
  19. package/dist/exec/types.js +8 -0
  20. package/dist/exec/types.js.map +1 -0
  21. package/dist/index.d.ts +23 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +27 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/repos/index.d.ts +15 -0
  26. package/dist/repos/index.d.ts.map +1 -0
  27. package/dist/repos/index.js +11 -0
  28. package/dist/repos/index.js.map +1 -0
  29. package/dist/repos/projects.d.ts +41 -0
  30. package/dist/repos/projects.d.ts.map +1 -0
  31. package/dist/repos/projects.js +74 -0
  32. package/dist/repos/projects.js.map +1 -0
  33. package/dist/repos/run_steps.d.ts +152 -0
  34. package/dist/repos/run_steps.d.ts.map +1 -0
  35. package/dist/repos/run_steps.js +321 -0
  36. package/dist/repos/run_steps.js.map +1 -0
  37. package/dist/repos/runs.d.ts +92 -0
  38. package/dist/repos/runs.d.ts.map +1 -0
  39. package/dist/repos/runs.js +177 -0
  40. package/dist/repos/runs.js.map +1 -0
  41. package/dist/repos/tickets.d.ts +71 -0
  42. package/dist/repos/tickets.d.ts.map +1 -0
  43. package/dist/repos/tickets.js +128 -0
  44. package/dist/repos/tickets.js.map +1 -0
  45. package/dist/scout/index.d.ts +15 -0
  46. package/dist/scout/index.d.ts.map +1 -0
  47. package/dist/scout/index.js +383 -0
  48. package/dist/scout/index.js.map +1 -0
  49. package/dist/scout/prompt.d.ts +32 -0
  50. package/dist/scout/prompt.d.ts.map +1 -0
  51. package/dist/scout/prompt.js +104 -0
  52. package/dist/scout/prompt.js.map +1 -0
  53. package/dist/scout/runner.d.ts +68 -0
  54. package/dist/scout/runner.d.ts.map +1 -0
  55. package/dist/scout/runner.js +270 -0
  56. package/dist/scout/runner.js.map +1 -0
  57. package/dist/scout/scanner.d.ts +35 -0
  58. package/dist/scout/scanner.d.ts.map +1 -0
  59. package/dist/scout/scanner.js +164 -0
  60. package/dist/scout/scanner.js.map +1 -0
  61. package/dist/scout/types.d.ts +179 -0
  62. package/dist/scout/types.d.ts.map +1 -0
  63. package/dist/scout/types.js +44 -0
  64. package/dist/scout/types.js.map +1 -0
  65. package/dist/services/index.d.ts +10 -0
  66. package/dist/services/index.d.ts.map +1 -0
  67. package/dist/services/index.js +9 -0
  68. package/dist/services/index.js.map +1 -0
  69. package/dist/services/qa.d.ts +76 -0
  70. package/dist/services/qa.d.ts.map +1 -0
  71. package/dist/services/qa.js +239 -0
  72. package/dist/services/qa.js.map +1 -0
  73. package/dist/services/scout.d.ts +120 -0
  74. package/dist/services/scout.d.ts.map +1 -0
  75. package/dist/services/scout.js +205 -0
  76. package/dist/services/scout.js.map +1 -0
  77. package/dist/utils/id.d.ts +12 -0
  78. package/dist/utils/id.d.ts.map +1 -0
  79. package/dist/utils/id.js +24 -0
  80. package/dist/utils/id.js.map +1 -0
  81. package/dist/utils/id.test.d.ts +5 -0
  82. package/dist/utils/id.test.d.ts.map +1 -0
  83. package/dist/utils/id.test.js +173 -0
  84. package/dist/utils/id.test.js.map +1 -0
  85. package/dist/utils/index.d.ts +6 -0
  86. package/dist/utils/index.d.ts.map +1 -0
  87. package/dist/utils/index.js +6 -0
  88. package/dist/utils/index.js.map +1 -0
  89. package/dist/utils/json.d.ts +9 -0
  90. package/dist/utils/json.d.ts.map +1 -0
  91. package/dist/utils/json.js +19 -0
  92. package/dist/utils/json.js.map +1 -0
  93. package/package.json +1 -1
@@ -0,0 +1,164 @@
1
+ /**
2
+ * File scanner - Discovers and reads files for analysis
3
+ */
4
+ import * as fs from 'node:fs';
5
+ import * as path from 'node:path';
6
+ /**
7
+ * Default exclusion patterns
8
+ */
9
+ const DEFAULT_EXCLUDES = [
10
+ 'node_modules',
11
+ '.git',
12
+ 'dist',
13
+ 'build',
14
+ 'coverage',
15
+ '.next',
16
+ '.cache',
17
+ '*.min.js',
18
+ '*.map',
19
+ '*.lock',
20
+ 'package-lock.json',
21
+ 'yarn.lock',
22
+ 'pnpm-lock.yaml',
23
+ ];
24
+ /**
25
+ * Check if a path matches a simple glob pattern
26
+ *
27
+ * Supports:
28
+ * - ** for recursive matching
29
+ * - * for single segment matching
30
+ * - Direct path matching
31
+ */
32
+ function matchesPattern(filePath, pattern) {
33
+ // Normalize paths
34
+ const normalizedPath = filePath.replace(/\\/g, '/');
35
+ const normalizedPattern = pattern.replace(/\\/g, '/');
36
+ // Direct match
37
+ if (normalizedPath === normalizedPattern) {
38
+ return true;
39
+ }
40
+ // Check if pattern is a directory prefix (without glob)
41
+ if (!normalizedPattern.includes('*') && normalizedPath.startsWith(normalizedPattern + '/')) {
42
+ return true;
43
+ }
44
+ // Simple glob matching
45
+ if (normalizedPattern.includes('*')) {
46
+ // Escape regex special chars except *
47
+ const escaped = normalizedPattern
48
+ .replace(/[.+^${}()|[\]\\]/g, '\\$&');
49
+ // Convert glob patterns to regex
50
+ // Note: **/ should be optional to match files directly in the directory
51
+ // e.g., src/services/**/*.ts should match both src/services/auditor.ts
52
+ // and src/services/sub/file.ts
53
+ const regexPattern = escaped
54
+ .replace(/\*\*\//g, '<<<DOUBLESTARSLASH>>>')
55
+ .replace(/\*\*/g, '<<<DOUBLESTAR>>>')
56
+ .replace(/\*/g, '[^/]*')
57
+ .replace(/<<<DOUBLESTARSLASH>>>/g, '(.*\\/)?')
58
+ .replace(/<<<DOUBLESTAR>>>/g, '.*');
59
+ const regex = new RegExp(`^${regexPattern}$`);
60
+ return regex.test(normalizedPath);
61
+ }
62
+ return false;
63
+ }
64
+ /**
65
+ * Check if a path should be excluded
66
+ */
67
+ function shouldExclude(filePath, excludePatterns) {
68
+ const allExcludes = [...DEFAULT_EXCLUDES, ...excludePatterns];
69
+ for (const pattern of allExcludes) {
70
+ if (matchesPattern(filePath, pattern)) {
71
+ return true;
72
+ }
73
+ // Also check if any path segment matches (for things like node_modules)
74
+ const segments = filePath.split('/');
75
+ if (segments.some(seg => matchesPattern(seg, pattern))) {
76
+ return true;
77
+ }
78
+ }
79
+ return false;
80
+ }
81
+ /**
82
+ * Check if a file matches any include pattern
83
+ */
84
+ function shouldInclude(filePath, includePatterns) {
85
+ // If no patterns specified, include source-like files
86
+ if (includePatterns.length === 0) {
87
+ const ext = path.extname(filePath).toLowerCase();
88
+ return ['.ts', '.tsx', '.js', '.jsx', '.py', '.go', '.rs', '.java', '.rb', '.md'].includes(ext);
89
+ }
90
+ return includePatterns.some(pattern => matchesPattern(filePath, pattern));
91
+ }
92
+ /**
93
+ * Recursively scan directory for files
94
+ */
95
+ function walkDir(dir, baseDir, options, files) {
96
+ const maxFileSize = options.maxFileSize ?? 100 * 1024; // 100KB
97
+ const maxFiles = options.maxFiles ?? 500;
98
+ if (files.length >= maxFiles) {
99
+ return;
100
+ }
101
+ let entries;
102
+ try {
103
+ entries = fs.readdirSync(dir, { withFileTypes: true });
104
+ }
105
+ catch {
106
+ return; // Skip unreadable directories
107
+ }
108
+ for (const entry of entries) {
109
+ if (files.length >= maxFiles) {
110
+ break;
111
+ }
112
+ const fullPath = path.join(dir, entry.name);
113
+ const relativePath = path.relative(baseDir, fullPath);
114
+ // Check exclusions first
115
+ if (shouldExclude(relativePath, options.exclude ?? [])) {
116
+ continue;
117
+ }
118
+ if (entry.isDirectory()) {
119
+ walkDir(fullPath, baseDir, options, files);
120
+ }
121
+ else if (entry.isFile()) {
122
+ // Check inclusion
123
+ if (!shouldInclude(relativePath, options.include)) {
124
+ continue;
125
+ }
126
+ // Check file size
127
+ try {
128
+ const stat = fs.statSync(fullPath);
129
+ if (stat.size > maxFileSize) {
130
+ continue;
131
+ }
132
+ // Read content
133
+ const content = fs.readFileSync(fullPath, 'utf-8');
134
+ files.push({
135
+ path: relativePath,
136
+ content,
137
+ size: stat.size,
138
+ });
139
+ }
140
+ catch {
141
+ // Skip unreadable files
142
+ }
143
+ }
144
+ }
145
+ }
146
+ /**
147
+ * Scan a directory for files matching the given patterns
148
+ */
149
+ export function scanFiles(options) {
150
+ const files = [];
151
+ walkDir(options.cwd, options.cwd, options, files);
152
+ return files;
153
+ }
154
+ /**
155
+ * Group files into batches for processing
156
+ */
157
+ export function batchFiles(files, batchSize = 3) {
158
+ const batches = [];
159
+ for (let i = 0; i < files.length; i += batchSize) {
160
+ batches.push(files.slice(i, i + batchSize));
161
+ }
162
+ return batches;
163
+ }
164
+ //# sourceMappingURL=scanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../src/scout/scanner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AA2BlC;;GAEG;AACH,MAAM,gBAAgB,GAAG;IACvB,cAAc;IACd,MAAM;IACN,MAAM;IACN,OAAO;IACP,UAAU;IACV,OAAO;IACP,QAAQ;IACR,UAAU;IACV,OAAO;IACP,QAAQ;IACR,mBAAmB;IACnB,WAAW;IACX,gBAAgB;CACjB,CAAC;AAEF;;;;;;;GAOG;AACH,SAAS,cAAc,CAAC,QAAgB,EAAE,OAAe;IACvD,kBAAkB;IAClB,MAAM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T,IAAI,EAAE,YAAY;oBAClB,OAAO;oBACP,IAAI,EAAE,IAAI,CAAC,IAAI;iBAChB,CAAC,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACP,wBAAwB;YAC1B,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,OAAoB;IAC5C,MAAM,KAAK,GAAkB,EAAE,CAAC;IAChC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAClD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAoB,EAAE,YAAoB,CAAC;IACpE,MAAM,OAAO,GAAoB,EAAE,CAAC;IAEpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC;QACjD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Scout types - Shared type definitions for codebase scanning
3
+ */
4
+ /**
5
+ * Proposal categories
6
+ */
7
+ export type ProposalCategory = 'refactor' | 'docs' | 'test' | 'perf' | 'security';
8
+ /**
9
+ * Complexity levels
10
+ */
11
+ export type ComplexityLevel = 'trivial' | 'simple' | 'moderate' | 'complex';
12
+ /**
13
+ * A ticket proposal generated by the scout
14
+ */
15
+ export interface TicketProposal {
16
+ /** Unique ID (scout-{timestamp}-{random}) */
17
+ id: string;
18
+ /** Category of improvement */
19
+ category: ProposalCategory;
20
+ /** Short, actionable title */
21
+ title: string;
22
+ /** What needs to be done and why */
23
+ description: string;
24
+ /** Verifiable acceptance criteria */
25
+ acceptance_criteria: string[];
26
+ /** Commands to verify the fix */
27
+ verification_commands: string[];
28
+ /** Files that can be modified */
29
+ allowed_paths: string[];
30
+ /** Specific files identified for change */
31
+ files: string[];
32
+ /** Confidence score (0-100) */
33
+ confidence: number;
34
+ /** Impact score (1-10, optional) — how much this matters */
35
+ impact_score?: number;
36
+ /** Why this improvement matters */
37
+ rationale: string;
38
+ /** Estimated complexity */
39
+ estimated_complexity: ComplexityLevel;
40
+ }
41
+ /**
42
+ * Scout configuration options
43
+ */
44
+ export interface ScoutOptions {
45
+ /** Glob pattern for files to scan (e.g., "src/**") */
46
+ scope: string;
47
+ /** Filter to specific categories */
48
+ types?: ProposalCategory[];
49
+ /** Categories to exclude */
50
+ excludeTypes?: ProposalCategory[];
51
+ /** Glob patterns to exclude */
52
+ exclude?: string[];
53
+ /** Maximum proposals to generate (default: 10) */
54
+ maxProposals?: number;
55
+ /** Minimum confidence threshold (default: 50) */
56
+ minConfidence?: number;
57
+ /** Working directory (default: cwd) */
58
+ projectPath?: string;
59
+ /** Timeout per batch in ms (default: 120000) */
60
+ timeoutMs?: number;
61
+ /** Cancellation signal */
62
+ signal?: AbortSignal;
63
+ /** Progress callback */
64
+ onProgress?: (progress: ScoutProgress) => void;
65
+ /** Recently completed ticket titles to avoid duplicates */
66
+ recentlyCompletedTitles?: string[];
67
+ /** Model to use (default: opus) */
68
+ model?: 'haiku' | 'sonnet' | 'opus';
69
+ /** Custom prompt from formula — tells the AI what to focus on */
70
+ customPrompt?: string;
71
+ /** Scout backend to use (default: ClaudeScoutBackend) */
72
+ backend?: import('./runner.js').ScoutBackend;
73
+ /** Files the scout can read but must NOT propose changes to */
74
+ protectedFiles?: string[];
75
+ }
76
+ /**
77
+ * Progress update during scanning
78
+ */
79
+ export interface ScoutProgress {
80
+ /** Current phase */
81
+ phase: 'discovering' | 'analyzing' | 'generating' | 'complete';
82
+ /** Files scanned so far */
83
+ filesScanned: number;
84
+ /** Total files to scan */
85
+ totalFiles: number;
86
+ /** Proposals found so far */
87
+ proposalsFound: number;
88
+ /** Current batch number */
89
+ currentBatch: number;
90
+ /** Total batches */
91
+ totalBatches: number;
92
+ /** Current file being processed */
93
+ currentFile?: string;
94
+ }
95
+ /**
96
+ * Scout result
97
+ */
98
+ export interface ScoutResult {
99
+ /** Whether the scan completed successfully */
100
+ success: boolean;
101
+ /** Generated proposals */
102
+ proposals: TicketProposal[];
103
+ /** Any errors encountered */
104
+ errors: string[];
105
+ /** Total files scanned */
106
+ scannedFiles: number;
107
+ /** Total scan duration in ms */
108
+ scanDurationMs: number;
109
+ }
110
+ /**
111
+ * Schema for validating LLM output
112
+ */
113
+ export declare const PROPOSAL_SCHEMA: {
114
+ readonly type: "object";
115
+ readonly properties: {
116
+ readonly proposals: {
117
+ readonly type: "array";
118
+ readonly items: {
119
+ readonly type: "object";
120
+ readonly required: readonly ["category", "title", "description", "acceptance_criteria", "verification_commands", "allowed_paths", "files", "confidence", "rationale", "estimated_complexity"];
121
+ readonly properties: {
122
+ readonly category: {
123
+ readonly type: "string";
124
+ readonly enum: readonly ["refactor", "docs", "test", "perf", "security"];
125
+ };
126
+ readonly title: {
127
+ readonly type: "string";
128
+ };
129
+ readonly description: {
130
+ readonly type: "string";
131
+ };
132
+ readonly acceptance_criteria: {
133
+ readonly type: "array";
134
+ readonly items: {
135
+ readonly type: "string";
136
+ };
137
+ };
138
+ readonly verification_commands: {
139
+ readonly type: "array";
140
+ readonly items: {
141
+ readonly type: "string";
142
+ };
143
+ };
144
+ readonly allowed_paths: {
145
+ readonly type: "array";
146
+ readonly items: {
147
+ readonly type: "string";
148
+ };
149
+ };
150
+ readonly files: {
151
+ readonly type: "array";
152
+ readonly items: {
153
+ readonly type: "string";
154
+ };
155
+ };
156
+ readonly confidence: {
157
+ readonly type: "number";
158
+ readonly minimum: 0;
159
+ readonly maximum: 100;
160
+ };
161
+ readonly impact_score: {
162
+ readonly type: "number";
163
+ readonly minimum: 1;
164
+ readonly maximum: 10;
165
+ };
166
+ readonly rationale: {
167
+ readonly type: "string";
168
+ };
169
+ readonly estimated_complexity: {
170
+ readonly type: "string";
171
+ readonly enum: readonly ["trivial", "simple", "moderate", "complex"];
172
+ };
173
+ };
174
+ };
175
+ };
176
+ };
177
+ readonly required: readonly ["proposals"];
178
+ };
179
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/scout/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;AAElF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAC;IACX,8BAA8B;IAC9B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,iCAAiC;IACjC,qBAAqB,EAAE,MAAM,EAAE,CAAC;IAChC,iCAAiC;IACjC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,2BAA2B;IAC3B,oBAAoB,EAAE,eAAe,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,KAAK,CAAC,EAAE,gBAAg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1B,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,0BAA0B;IAC1B,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,6BAA6B;IAC7B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,0BAA0B;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,gCAAgC;IAChC,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoClB,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Scout types - Shared type definitions for codebase scanning
3
+ */
4
+ /**
5
+ * Schema for validating LLM output
6
+ */
7
+ export const PROPOSAL_SCHEMA = {
8
+ type: 'object',
9
+ properties: {
10
+ proposals: {
11
+ type: 'array',
12
+ items: {
13
+ type: 'object',
14
+ required: [
15
+ 'category',
16
+ 'title',
17
+ 'description',
18
+ 'acceptance_criteria',
19
+ 'verification_commands',
20
+ 'allowed_paths',
21
+ 'files',
22
+ 'confidence',
23
+ 'rationale',
24
+ 'estimated_complexity',
25
+ ],
26
+ properties: {
27
+ category: { type: 'string', enum: ['refactor', 'docs', 'test', 'perf', 'security'] },
28
+ title: { type: 'string' },
29
+ description: { type: 'string' },
30
+ acceptance_criteria: { type: 'array', items: { type: 'string' } },
31
+ verification_commands: { type: 'array', items: { type: 'string' } },
32
+ allowed_paths: { type: 'array', items: { type: 'string' } },
33
+ files: { type: 'array', items: { type: 'string' } },
34
+ confidence: { type: 'number', minimum: 0, maximum: 100 },
35
+ impact_score: { type: 'number', minimum: 1, maximum: 10 },
36
+ rationale: { type: 'string' },
37
+ estimated_complexity: { type: 'string', enum: ['trivial', 'simple', 'moderate', 'complex'] },
38
+ },
39
+ },
40
+ },
41
+ },
42
+ required: ['proposals'],
43
+ };
44
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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AE,EAAE,EAAE;oBACzD,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBAC7B,oBAAoB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE;iBAC7F;aACF;SACF;KACF;IACD,QAAQ,EAAE,CAAC,WAAW,CAAC;CACf,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Service exports
3
+ *
4
+ * Services provide business logic orchestration.
5
+ * They use repositories for data access and are dependency-injected for testability.
6
+ */
7
+ export { scoutRepo, approveProposals, type ScoutDeps, type ScoutRepoOptions, type ScoutRepoResult, type ScoutProgress, type GitService, type Logger, } from './scout.js';
8
+ export type { ScoutBackend } from '../scout/index.js';
9
+ export { runQa, getQaRunDetails, type QaDeps, type QaLogger, type QaCommand, type QaConfig, type QaArtifactsConfig, type QaRetryConfig, type QaRunOptions, type QaRunResult, } from './qa.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,MAAM,GACZ,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EACL,KAAK,EACL,eAAe,EACf,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,GACjB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Service exports
3
+ *
4
+ * Services provide business logic orchestration.
5
+ * They use repositories for data access and are dependency-injected for testability.
6
+ */
7
+ export { scoutRepo, approveProposals, } from './scout.js';
8
+ export { runQa, getQaRunDetails, } from './qa.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,SAAS,EACT,gBAAgB,GAOjB,MAAM,YAAY,CAAC;AAIpB,OAAO,EACL,KAAK,EACL,eAAe,GAShB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * QA Service - Run local QA commands and record results
3
+ *
4
+ * This is pure orchestration: no FS writes, no raw SQL.
5
+ * Uses repos + ExecRunner for all operations.
6
+ */
7
+ import type { DatabaseAdapter } from '../db/adapter.js';
8
+ import type { ExecRunner } from '../exec/types.js';
9
+ import * as runs from '../repos/runs.js';
10
+ import * as runSteps from '../repos/run_steps.js';
11
+ export interface QaLogger {
12
+ info: (msg: string) => void;
13
+ warn?: (msg: string) => void;
14
+ error: (msg: string) => void;
15
+ debug?: (msg: string) => void;
16
+ }
17
+ export interface QaCommand {
18
+ name: string;
19
+ cmd: string;
20
+ cwd?: string;
21
+ env?: Record<string, string | undefined>;
22
+ timeoutMs?: number;
23
+ }
24
+ export interface QaArtifactsConfig {
25
+ dir: string;
26
+ maxLogBytes: number;
27
+ tailBytes: number;
28
+ }
29
+ export interface QaRetryConfig {
30
+ enabled: boolean;
31
+ maxAttempts: number;
32
+ }
33
+ export interface QaConfig {
34
+ commands: QaCommand[];
35
+ artifacts: QaArtifactsConfig;
36
+ retry: QaRetryConfig;
37
+ }
38
+ export interface QaDeps {
39
+ db: DatabaseAdapter;
40
+ exec: ExecRunner;
41
+ logger: QaLogger;
42
+ }
43
+ export interface QaRunOptions {
44
+ projectId: string;
45
+ repoRoot: string;
46
+ config: QaConfig;
47
+ maxAttemptsOverride?: number;
48
+ signal?: AbortSignal;
49
+ }
50
+ export interface QaRunResult {
51
+ runId: string;
52
+ projectId: string;
53
+ status: 'success' | 'failed' | 'canceled';
54
+ attempts: number;
55
+ latestAttempt: number;
56
+ failedAt?: {
57
+ attempt: number;
58
+ stepName: string;
59
+ };
60
+ startedAtMs: number;
61
+ endedAtMs: number;
62
+ durationMs: number;
63
+ }
64
+ /**
65
+ * Run QA commands and record results
66
+ */
67
+ export declare function runQa(deps: QaDeps, opts: QaRunOptions): Promise<QaRunResult>;
68
+ /**
69
+ * Get QA run details with step information
70
+ */
71
+ export declare function getQaRunDetails(db: DatabaseAdapter, runId: string): Promise<{
72
+ run: runs.Run | null;
73
+ steps: runSteps.RunStep[];
74
+ summary: runSteps.StepSummary;
75
+ } | null>;
76
+ //# sourceMappingURL=qa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qa.d.ts","sourceRoot":"","sources":["../../src/services/qa.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAA0B,MAAM,kBAAkB,CAAC;AAE3E,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAElD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CA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