@eldrforge/kodrdriv 1.2.29 → 1.2.123
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/dist/application.js +16 -13
- package/dist/application.js.map +1 -1
- package/dist/arguments.js +5 -5
- package/dist/arguments.js.map +1 -1
- package/dist/commands/audio-review.js +2 -5
- package/dist/commands/audio-review.js.map +1 -1
- package/dist/commands/clean.js +2 -4
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/commit.js +3 -6
- package/dist/commands/commit.js.map +1 -1
- package/dist/commands/development.js +7 -7
- package/dist/commands/development.js.map +1 -1
- package/dist/commands/link.js +3 -7
- package/dist/commands/link.js.map +1 -1
- package/dist/commands/precommit.js +99 -0
- package/dist/commands/precommit.js.map +1 -0
- package/dist/commands/publish.js +47 -32
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/release.js +3 -7
- package/dist/commands/release.js.map +1 -1
- package/dist/commands/review.js +4 -6
- package/dist/commands/review.js.map +1 -1
- package/dist/commands/tree.js +213 -84
- package/dist/commands/tree.js.map +1 -1
- package/dist/commands/unlink.js +3 -7
- package/dist/commands/unlink.js.map +1 -1
- package/dist/commands/updates.js +2 -4
- package/dist/commands/updates.js.map +1 -1
- package/dist/commands/versions.js +3 -7
- package/dist/commands/versions.js.map +1 -1
- package/dist/constants.js +4 -2
- package/dist/constants.js.map +1 -1
- package/dist/content/files.js +2 -4
- package/dist/content/files.js.map +1 -1
- package/dist/execution/CommandValidator.js +33 -1
- package/dist/execution/CommandValidator.js.map +1 -1
- package/dist/execution/ResourceMonitor.js +26 -1
- package/dist/execution/ResourceMonitor.js.map +1 -1
- package/dist/execution/TreeExecutionAdapter.js +2 -2
- package/dist/execution/TreeExecutionAdapter.js.map +1 -1
- package/dist/util/checkpointManager.js +2 -4
- package/dist/util/checkpointManager.js.map +1 -1
- package/dist/util/dependencyGraph.js +2 -4
- package/dist/util/dependencyGraph.js.map +1 -1
- package/dist/util/general.js +7 -107
- package/dist/util/general.js.map +1 -1
- package/dist/util/gitMutex.js +63 -18
- package/dist/util/gitMutex.js.map +1 -1
- package/dist/util/precommitOptimizations.js +310 -0
- package/dist/util/precommitOptimizations.js.map +1 -0
- package/dist/util/storageAdapter.js +2 -6
- package/dist/util/storageAdapter.js.map +1 -1
- package/dist/utils/branchState.js +178 -45
- package/dist/utils/branchState.js.map +1 -1
- package/package.json +6 -5
- package/AI-FRIENDLY-LOGGING-GUIDE.md +0 -237
- package/AI-LOGGING-MIGRATION-COMPLETE.md +0 -371
- package/ALREADY-PUBLISHED-PACKAGES-FIX.md +0 -264
- package/AUDIT-BRANCHES-PROGRESS-FIX.md +0 -90
- package/AUDIT-EXAMPLE-OUTPUT.md +0 -113
- package/CHECKPOINT-RECOVERY-FIX.md +0 -450
- package/LOGGING-MIGRATION-STATUS.md +0 -186
- package/MONOREPO-PUBLISH-IMPROVEMENTS.md +0 -281
- package/PARALLEL-EXECUTION-FIXES.md +0 -132
- package/PARALLEL-PUBLISH-DEBUGGING-GUIDE.md +0 -441
- package/PARALLEL-PUBLISH-FIXES-IMPLEMENTED.md +0 -405
- package/PARALLEL-PUBLISH-IMPROVEMENTS-IMPLEMENTED.md +0 -439
- package/PARALLEL-PUBLISH-LOGGING-FIXES.md +0 -274
- package/PARALLEL-PUBLISH-QUICK-REFERENCE.md +0 -375
- package/PARALLEL_EXECUTION_FIX.md +0 -146
- package/PUBLISH_IMPROVEMENTS_IMPLEMENTED.md +0 -294
- package/RECOVERY-FIXES.md +0 -72
- package/SUBMODULE-LOCK-FIX.md +0 -132
- package/VERSION-AUDIT-FIX.md +0 -333
- package/WORKFLOW-PRECHECK-IMPLEMENTATION.md +0 -239
- package/WORKFLOW-SKIP-SUMMARY.md +0 -121
- package/dist/util/safety.js +0 -166
- package/dist/util/safety.js.map +0 -1
- package/dist/util/stdin.js +0 -133
- package/dist/util/stdin.js.map +0 -1
- package/dist/util/storage.js +0 -187
- package/dist/util/storage.js.map +0 -1
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import path__default from 'path';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import { getLogger } from '../logging.js';
|
|
4
|
+
import { runSecure } from '@eldrforge/git-tools';
|
|
5
|
+
import { createStorage } from '@eldrforge/shared';
|
|
6
|
+
|
|
7
|
+
const logger = getLogger();
|
|
8
|
+
// Cache file to store test run timestamps per package
|
|
9
|
+
const TEST_CACHE_FILE = '.kodrdriv-test-cache.json';
|
|
10
|
+
/**
|
|
11
|
+
* Load test cache from disk
|
|
12
|
+
*/ async function loadTestCache(packageDir) {
|
|
13
|
+
const cachePath = path__default.join(packageDir, TEST_CACHE_FILE);
|
|
14
|
+
try {
|
|
15
|
+
const content = await fs.readFile(cachePath, 'utf-8');
|
|
16
|
+
return JSON.parse(content);
|
|
17
|
+
} catch {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Save test cache to disk
|
|
23
|
+
*/ async function saveTestCache(packageDir, cache) {
|
|
24
|
+
const cachePath = path__default.join(packageDir, TEST_CACHE_FILE);
|
|
25
|
+
try {
|
|
26
|
+
await fs.writeFile(cachePath, JSON.stringify(cache, null, 2), 'utf-8');
|
|
27
|
+
} catch (error) {
|
|
28
|
+
logger.debug(`Failed to save test cache: ${error.message}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get the current git commit hash
|
|
33
|
+
*/ async function getCurrentCommitHash(packageDir) {
|
|
34
|
+
try {
|
|
35
|
+
const { stdout } = await runSecure('git', [
|
|
36
|
+
'rev-parse',
|
|
37
|
+
'HEAD'
|
|
38
|
+
], {
|
|
39
|
+
cwd: packageDir
|
|
40
|
+
});
|
|
41
|
+
return stdout.trim();
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check if source files have changed since the last test run
|
|
48
|
+
*/ async function hasSourceFilesChanged(packageDir, lastCommitHash) {
|
|
49
|
+
if (!lastCommitHash) {
|
|
50
|
+
return {
|
|
51
|
+
changed: true,
|
|
52
|
+
reason: 'No previous test run recorded'
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
// Get current commit hash
|
|
57
|
+
const currentCommitHash = await getCurrentCommitHash(packageDir);
|
|
58
|
+
if (!currentCommitHash) {
|
|
59
|
+
return {
|
|
60
|
+
changed: true,
|
|
61
|
+
reason: 'Not in a git repository'
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// If commit hash changed, files definitely changed
|
|
65
|
+
if (currentCommitHash !== lastCommitHash) {
|
|
66
|
+
return {
|
|
67
|
+
changed: true,
|
|
68
|
+
reason: `Commit hash changed: ${lastCommitHash.substring(0, 7)} -> ${currentCommitHash.substring(0, 7)}`
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// Check if there are any uncommitted changes to source files
|
|
72
|
+
const { stdout } = await runSecure('git', [
|
|
73
|
+
'status',
|
|
74
|
+
'--porcelain'
|
|
75
|
+
], {
|
|
76
|
+
cwd: packageDir
|
|
77
|
+
});
|
|
78
|
+
const changedFiles = stdout.split('\n').filter((line)=>line.trim()).map((line)=>line.substring(3).trim()).filter((file)=>{
|
|
79
|
+
// Only consider source files, not build artifacts or config files
|
|
80
|
+
const ext = path__default.extname(file);
|
|
81
|
+
return(// TypeScript/JavaScript source files
|
|
82
|
+
[
|
|
83
|
+
'.ts',
|
|
84
|
+
'.tsx',
|
|
85
|
+
'.js',
|
|
86
|
+
'.jsx'
|
|
87
|
+
].includes(ext) || // Test files
|
|
88
|
+
file.includes('.test.') || file.includes('.spec.') || // Config files that affect build/test
|
|
89
|
+
[
|
|
90
|
+
'tsconfig.json',
|
|
91
|
+
'vite.config.ts',
|
|
92
|
+
'vitest.config.ts',
|
|
93
|
+
'package.json'
|
|
94
|
+
].includes(path__default.basename(file)));
|
|
95
|
+
});
|
|
96
|
+
if (changedFiles.length > 0) {
|
|
97
|
+
return {
|
|
98
|
+
changed: true,
|
|
99
|
+
reason: `Uncommitted changes in: ${changedFiles.slice(0, 3).join(', ')}${changedFiles.length > 3 ? '...' : ''}`
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
changed: false,
|
|
104
|
+
reason: 'No source file changes detected'
|
|
105
|
+
};
|
|
106
|
+
} catch (error) {
|
|
107
|
+
logger.debug(`Error checking for source file changes: ${error.message}`);
|
|
108
|
+
// Conservative: assume changed if we can't verify
|
|
109
|
+
return {
|
|
110
|
+
changed: true,
|
|
111
|
+
reason: `Could not verify changes: ${error.message}`
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Check if dist directory needs to be cleaned (is outdated compared to source files)
|
|
117
|
+
*/ async function isCleanNeeded(packageDir) {
|
|
118
|
+
const storage = createStorage();
|
|
119
|
+
const distPath = path__default.join(packageDir, 'dist');
|
|
120
|
+
try {
|
|
121
|
+
// Check if dist directory exists
|
|
122
|
+
const distExists = await storage.exists('dist');
|
|
123
|
+
if (!distExists) {
|
|
124
|
+
return {
|
|
125
|
+
needed: false,
|
|
126
|
+
reason: 'dist directory does not exist'
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
// Get dist directory modification time
|
|
130
|
+
const distStats = await fs.stat(distPath);
|
|
131
|
+
const distMtime = distStats.mtimeMs;
|
|
132
|
+
// Use git to find source files that are newer than dist
|
|
133
|
+
try {
|
|
134
|
+
// Get all tracked source files
|
|
135
|
+
const { stdout: trackedFiles } = await runSecure('git', [
|
|
136
|
+
'ls-files'
|
|
137
|
+
], {
|
|
138
|
+
cwd: packageDir
|
|
139
|
+
});
|
|
140
|
+
const files = trackedFiles.split('\n').filter(Boolean);
|
|
141
|
+
// Check if any source files are newer than dist
|
|
142
|
+
for (const file of files){
|
|
143
|
+
const ext = path__default.extname(file);
|
|
144
|
+
if (![
|
|
145
|
+
'.ts',
|
|
146
|
+
'.tsx',
|
|
147
|
+
'.js',
|
|
148
|
+
'.jsx',
|
|
149
|
+
'.json'
|
|
150
|
+
].includes(ext)) {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
// Skip dist files
|
|
154
|
+
if (file.startsWith('dist/')) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
const filePath = path__default.join(packageDir, file);
|
|
159
|
+
const fileStats = await fs.stat(filePath);
|
|
160
|
+
if (fileStats.mtimeMs > distMtime) {
|
|
161
|
+
return {
|
|
162
|
+
needed: true,
|
|
163
|
+
reason: `${file} is newer than dist directory`
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
} catch {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
needed: false,
|
|
172
|
+
reason: 'dist directory is up to date with source files'
|
|
173
|
+
};
|
|
174
|
+
} catch (error) {
|
|
175
|
+
// If git check fails, fall back to checking common source directories
|
|
176
|
+
logger.debug(`Git-based check failed, using fallback: ${error.message}`);
|
|
177
|
+
const sourceDirs = [
|
|
178
|
+
'src',
|
|
179
|
+
'tests'
|
|
180
|
+
];
|
|
181
|
+
for (const dir of sourceDirs){
|
|
182
|
+
const dirPath = path__default.join(packageDir, dir);
|
|
183
|
+
try {
|
|
184
|
+
const dirStats = await fs.stat(dirPath);
|
|
185
|
+
if (dirStats.mtimeMs > distMtime) {
|
|
186
|
+
return {
|
|
187
|
+
needed: true,
|
|
188
|
+
reason: `${dir} directory is newer than dist`
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
} catch {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// Conservative: if we can't verify, assume clean is needed
|
|
196
|
+
return {
|
|
197
|
+
needed: true,
|
|
198
|
+
reason: 'Could not verify dist freshness, cleaning to be safe'
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
} catch (error) {
|
|
202
|
+
logger.debug(`Error checking if clean is needed: ${error.message}`);
|
|
203
|
+
// Conservative: assume clean is needed if we can't check
|
|
204
|
+
return {
|
|
205
|
+
needed: true,
|
|
206
|
+
reason: `Could not verify: ${error.message}`
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Check if tests need to be run (source files changed since last test run)
|
|
212
|
+
*/ async function isTestNeeded(packageDir) {
|
|
213
|
+
try {
|
|
214
|
+
// Load test cache
|
|
215
|
+
const cache = await loadTestCache(packageDir);
|
|
216
|
+
const cacheKey = packageDir;
|
|
217
|
+
// Check if we have a cached test run for this package
|
|
218
|
+
const cached = cache[cacheKey];
|
|
219
|
+
if (!cached) {
|
|
220
|
+
return {
|
|
221
|
+
needed: true,
|
|
222
|
+
reason: 'No previous test run recorded'
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
// Check if source files have changed since last test run
|
|
226
|
+
const changeCheck = await hasSourceFilesChanged(packageDir, cached.lastCommitHash);
|
|
227
|
+
if (changeCheck.changed) {
|
|
228
|
+
return {
|
|
229
|
+
needed: true,
|
|
230
|
+
reason: changeCheck.reason
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
needed: false,
|
|
235
|
+
reason: 'No source file changes since last test run'
|
|
236
|
+
};
|
|
237
|
+
} catch (error) {
|
|
238
|
+
logger.debug(`Error checking if test is needed: ${error.message}`);
|
|
239
|
+
// Conservative: assume test is needed if we can't check
|
|
240
|
+
return {
|
|
241
|
+
needed: true,
|
|
242
|
+
reason: `Could not verify: ${error.message}`
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Record that tests were run for this package
|
|
248
|
+
*/ async function recordTestRun(packageDir) {
|
|
249
|
+
try {
|
|
250
|
+
const cache = await loadTestCache(packageDir);
|
|
251
|
+
const cacheKey = packageDir;
|
|
252
|
+
const commitHash = await getCurrentCommitHash(packageDir);
|
|
253
|
+
cache[cacheKey] = {
|
|
254
|
+
lastTestRun: Date.now(),
|
|
255
|
+
lastCommitHash: commitHash || 'unknown'
|
|
256
|
+
};
|
|
257
|
+
await saveTestCache(packageDir, cache);
|
|
258
|
+
} catch (error) {
|
|
259
|
+
logger.debug(`Failed to record test run: ${error.message}`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Optimize a precommit command by skipping unnecessary steps
|
|
264
|
+
* Returns the optimized command and information about what was skipped
|
|
265
|
+
*/ async function optimizePrecommitCommand(packageDir, originalCommand, options = {}) {
|
|
266
|
+
const { skipClean = true, skipTest = true } = options;
|
|
267
|
+
// Parse the original command to extract individual scripts
|
|
268
|
+
// Common patterns: "npm run precommit", "npm run clean && npm run build && npm run lint && npm run test"
|
|
269
|
+
const isPrecommitScript = originalCommand.includes('precommit') || originalCommand.includes('pre-commit');
|
|
270
|
+
let optimizedCommand = originalCommand;
|
|
271
|
+
const skipped = {
|
|
272
|
+
clean: false,
|
|
273
|
+
test: false
|
|
274
|
+
};
|
|
275
|
+
const reasons = {};
|
|
276
|
+
// If it's a precommit script, we need to check what it actually runs
|
|
277
|
+
// For now, we'll optimize the common pattern: clean && build && lint && test
|
|
278
|
+
if (isPrecommitScript || originalCommand.includes('clean')) {
|
|
279
|
+
if (skipClean) {
|
|
280
|
+
const cleanCheck = await isCleanNeeded(packageDir);
|
|
281
|
+
if (!cleanCheck.needed) {
|
|
282
|
+
// Remove clean from the command
|
|
283
|
+
optimizedCommand = optimizedCommand.replace(/npm\s+run\s+clean\s+&&\s*/g, '').replace(/npm\s+run\s+clean\s+/g, '').replace(/\s*&&\s*npm\s+run\s+clean/g, '').trim();
|
|
284
|
+
skipped.clean = true;
|
|
285
|
+
reasons.clean = cleanCheck.reason;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (isPrecommitScript || originalCommand.includes('test')) {
|
|
290
|
+
if (skipTest) {
|
|
291
|
+
const testCheck = await isTestNeeded(packageDir);
|
|
292
|
+
if (!testCheck.needed) {
|
|
293
|
+
// Remove test from the command
|
|
294
|
+
optimizedCommand = optimizedCommand.replace(/\s*&&\s*npm\s+run\s+test\s*/g, '').replace(/\s*&&\s*npm\s+run\s+test$/g, '').replace(/npm\s+run\s+test\s+&&\s*/g, '').trim();
|
|
295
|
+
skipped.test = true;
|
|
296
|
+
reasons.test = testCheck.reason;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// Clean up any double && or trailing &&
|
|
301
|
+
optimizedCommand = optimizedCommand.replace(/\s*&&\s*&&/g, ' && ').replace(/&&\s*$/, '').trim();
|
|
302
|
+
return {
|
|
303
|
+
optimizedCommand,
|
|
304
|
+
skipped,
|
|
305
|
+
reasons
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export { isCleanNeeded, isTestNeeded, optimizePrecommitCommand, recordTestRun };
|
|
310
|
+
//# sourceMappingURL=precommitOptimizations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"precommitOptimizations.js","sources":["../../src/util/precommitOptimizations.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs/promises';\nimport { getLogger } from '../logging';\nimport { runSecure } from '@eldrforge/git-tools';\nimport { createStorage } from '@eldrforge/shared';\n\nconst logger = getLogger();\n\n// Cache file to store test run timestamps per package\nconst TEST_CACHE_FILE = '.kodrdriv-test-cache.json';\n\ninterface TestCache {\n [packagePath: string]: {\n lastTestRun: number; // timestamp\n lastCommitHash: string; // git commit hash when tests last ran\n };\n}\n\n/**\n * Load test cache from disk\n */\nasync function loadTestCache(packageDir: string): Promise<TestCache> {\n const cachePath = path.join(packageDir, TEST_CACHE_FILE);\n try {\n const content = await fs.readFile(cachePath, 'utf-8');\n return JSON.parse(content);\n } catch {\n return {};\n }\n}\n\n/**\n * Save test cache to disk\n */\nasync function saveTestCache(packageDir: string, cache: TestCache): Promise<void> {\n const cachePath = path.join(packageDir, TEST_CACHE_FILE);\n try {\n await fs.writeFile(cachePath, JSON.stringify(cache, null, 2), 'utf-8');\n } catch (error: any) {\n logger.debug(`Failed to save test cache: ${error.message}`);\n }\n}\n\n/**\n * Get the current git commit hash\n */\nasync function getCurrentCommitHash(packageDir: string): Promise<string | null> {\n try {\n const { stdout } = await runSecure('git', ['rev-parse', 'HEAD'], { cwd: packageDir });\n return stdout.trim();\n } catch {\n return null;\n }\n}\n\n/**\n * Check if source files have changed since the last test run\n */\nasync function hasSourceFilesChanged(\n packageDir: string,\n lastCommitHash: string | null\n): Promise<{ changed: boolean; reason: string }> {\n if (!lastCommitHash) {\n return { changed: true, reason: 'No previous test run recorded' };\n }\n\n try {\n // Get current commit hash\n const currentCommitHash = await getCurrentCommitHash(packageDir);\n if (!currentCommitHash) {\n return { changed: true, reason: 'Not in a git repository' };\n }\n\n // If commit hash changed, files definitely changed\n if (currentCommitHash !== lastCommitHash) {\n return { changed: true, reason: `Commit hash changed: ${lastCommitHash.substring(0, 7)} -> ${currentCommitHash.substring(0, 7)}` };\n }\n\n // Check if there are any uncommitted changes to source files\n const { stdout } = await runSecure('git', ['status', '--porcelain'], { cwd: packageDir });\n const changedFiles = stdout.split('\\n')\n .filter(line => line.trim())\n .map(line => line.substring(3).trim())\n .filter(file => {\n // Only consider source files, not build artifacts or config files\n const ext = path.extname(file);\n return (\n // TypeScript/JavaScript source files\n ['.ts', '.tsx', '.js', '.jsx'].includes(ext) ||\n // Test files\n file.includes('.test.') || file.includes('.spec.') ||\n // Config files that affect build/test\n ['tsconfig.json', 'vite.config.ts', 'vitest.config.ts', 'package.json'].includes(path.basename(file))\n );\n });\n\n if (changedFiles.length > 0) {\n return { changed: true, reason: `Uncommitted changes in: ${changedFiles.slice(0, 3).join(', ')}${changedFiles.length > 3 ? '...' : ''}` };\n }\n\n return { changed: false, reason: 'No source file changes detected' };\n } catch (error: any) {\n logger.debug(`Error checking for source file changes: ${error.message}`);\n // Conservative: assume changed if we can't verify\n return { changed: true, reason: `Could not verify changes: ${error.message}` };\n }\n}\n\n/**\n * Check if dist directory needs to be cleaned (is outdated compared to source files)\n */\nexport async function isCleanNeeded(packageDir: string): Promise<{ needed: boolean; reason: string }> {\n const storage = createStorage();\n const distPath = path.join(packageDir, 'dist');\n\n try {\n // Check if dist directory exists\n const distExists = await storage.exists('dist');\n if (!distExists) {\n return { needed: false, reason: 'dist directory does not exist' };\n }\n\n // Get dist directory modification time\n const distStats = await fs.stat(distPath);\n const distMtime = distStats.mtimeMs;\n\n // Use git to find source files that are newer than dist\n try {\n // Get all tracked source files\n const { stdout: trackedFiles } = await runSecure('git', ['ls-files'], { cwd: packageDir });\n const files = trackedFiles.split('\\n').filter(Boolean);\n\n // Check if any source files are newer than dist\n for (const file of files) {\n const ext = path.extname(file);\n if (!['.ts', '.tsx', '.js', '.jsx', '.json'].includes(ext)) {\n continue;\n }\n\n // Skip dist files\n if (file.startsWith('dist/')) {\n continue;\n }\n\n try {\n const filePath = path.join(packageDir, file);\n const fileStats = await fs.stat(filePath);\n if (fileStats.mtimeMs > distMtime) {\n return { needed: true, reason: `${file} is newer than dist directory` };\n }\n } catch {\n // File might not exist or be inaccessible, skip it\n continue;\n }\n }\n\n return { needed: false, reason: 'dist directory is up to date with source files' };\n } catch (error: any) {\n // If git check fails, fall back to checking common source directories\n logger.debug(`Git-based check failed, using fallback: ${error.message}`);\n\n const sourceDirs = ['src', 'tests'];\n for (const dir of sourceDirs) {\n const dirPath = path.join(packageDir, dir);\n try {\n const dirStats = await fs.stat(dirPath);\n if (dirStats.mtimeMs > distMtime) {\n return { needed: true, reason: `${dir} directory is newer than dist` };\n }\n } catch {\n // Directory doesn't exist, skip it\n continue;\n }\n }\n\n // Conservative: if we can't verify, assume clean is needed\n return { needed: true, reason: 'Could not verify dist freshness, cleaning to be safe' };\n }\n } catch (error: any) {\n logger.debug(`Error checking if clean is needed: ${error.message}`);\n // Conservative: assume clean is needed if we can't check\n return { needed: true, reason: `Could not verify: ${error.message}` };\n }\n}\n\n/**\n * Check if tests need to be run (source files changed since last test run)\n */\nexport async function isTestNeeded(packageDir: string): Promise<{ needed: boolean; reason: string }> {\n try {\n // Load test cache\n const cache = await loadTestCache(packageDir);\n const cacheKey = packageDir;\n\n // Check if we have a cached test run for this package\n const cached = cache[cacheKey];\n if (!cached) {\n return { needed: true, reason: 'No previous test run recorded' };\n }\n\n // Check if source files have changed since last test run\n const changeCheck = await hasSourceFilesChanged(packageDir, cached.lastCommitHash);\n if (changeCheck.changed) {\n return { needed: true, reason: changeCheck.reason };\n }\n\n return { needed: false, reason: 'No source file changes since last test run' };\n } catch (error: any) {\n logger.debug(`Error checking if test is needed: ${error.message}`);\n // Conservative: assume test is needed if we can't check\n return { needed: true, reason: `Could not verify: ${error.message}` };\n }\n}\n\n/**\n * Record that tests were run for this package\n */\nexport async function recordTestRun(packageDir: string): Promise<void> {\n try {\n const cache = await loadTestCache(packageDir);\n const cacheKey = packageDir;\n const commitHash = await getCurrentCommitHash(packageDir);\n\n cache[cacheKey] = {\n lastTestRun: Date.now(),\n lastCommitHash: commitHash || 'unknown'\n };\n\n await saveTestCache(packageDir, cache);\n } catch (error: any) {\n logger.debug(`Failed to record test run: ${error.message}`);\n }\n}\n\n/**\n * Optimize a precommit command by skipping unnecessary steps\n * Returns the optimized command and information about what was skipped\n */\nexport async function optimizePrecommitCommand(\n packageDir: string,\n originalCommand: string,\n options: { skipClean?: boolean; skipTest?: boolean } = {}\n): Promise<{\n optimizedCommand: string;\n skipped: {\n clean: boolean;\n test: boolean;\n };\n reasons: {\n clean?: string;\n test?: string;\n };\n}> {\n const { skipClean = true, skipTest = true } = options;\n\n // Parse the original command to extract individual scripts\n // Common patterns: \"npm run precommit\", \"npm run clean && npm run build && npm run lint && npm run test\"\n const isPrecommitScript = originalCommand.includes('precommit') || originalCommand.includes('pre-commit');\n\n let optimizedCommand = originalCommand;\n const skipped = { clean: false, test: false };\n const reasons: { clean?: string; test?: string } = {};\n\n // If it's a precommit script, we need to check what it actually runs\n // For now, we'll optimize the common pattern: clean && build && lint && test\n if (isPrecommitScript || originalCommand.includes('clean')) {\n if (skipClean) {\n const cleanCheck = await isCleanNeeded(packageDir);\n if (!cleanCheck.needed) {\n // Remove clean from the command\n optimizedCommand = optimizedCommand\n .replace(/npm\\s+run\\s+clean\\s+&&\\s*/g, '')\n .replace(/npm\\s+run\\s+clean\\s+/g, '')\n .replace(/\\s*&&\\s*npm\\s+run\\s+clean/g, '')\n .trim();\n skipped.clean = true;\n reasons.clean = cleanCheck.reason;\n }\n }\n }\n\n if (isPrecommitScript || originalCommand.includes('test')) {\n if (skipTest) {\n const testCheck = await isTestNeeded(packageDir);\n if (!testCheck.needed) {\n // Remove test from the command\n optimizedCommand = optimizedCommand\n .replace(/\\s*&&\\s*npm\\s+run\\s+test\\s*/g, '')\n .replace(/\\s*&&\\s*npm\\s+run\\s+test$/g, '')\n .replace(/npm\\s+run\\s+test\\s+&&\\s*/g, '')\n .trim();\n skipped.test = true;\n reasons.test = testCheck.reason;\n }\n }\n }\n\n // Clean up any double && or trailing &&\n optimizedCommand = optimizedCommand.replace(/\\s*&&\\s*&&/g, ' && ').replace(/&&\\s*$/, '').trim();\n\n return { optimizedCommand, skipped, reasons };\n}\n\n"],"names":["logger","getLogger","TEST_CACHE_FILE","loadTestCache","packageDir","cachePath","path","join","content","fs","readFile","JSON","parse","saveTestCache","cache","writeFile","stringify","error","debug","message","getCurrentCommitHash","stdout","runSecure","cwd","trim","hasSourceFilesChanged","lastCommitHash","changed","reason","currentCommitHash","substring","changedFiles","split","filter","line","map","file","ext","extname","includes","basename","length","slice","isCleanNeeded","storage","createStorage","distPath","distExists","exists","needed","distStats","stat","distMtime","mtimeMs","trackedFiles","files","Boolean","startsWith","filePath","fileStats","sourceDirs","dir","dirPath","dirStats","isTestNeeded","cacheKey","cached","changeCheck","recordTestRun","commitHash","lastTestRun","Date","now","optimizePrecommitCommand","originalCommand","options","skipClean","skipT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
|
|
2
|
-
import { getLogger } from '../logging.js';
|
|
1
|
+
import { createStorage } from '@eldrforge/shared';
|
|
3
2
|
|
|
4
|
-
const logger = getLogger();
|
|
5
3
|
/**
|
|
6
4
|
* Create a StorageAdapter implementation using kodrdriv Storage
|
|
7
5
|
*/ function createStorageAdapter() {
|
|
8
|
-
const storage =
|
|
9
|
-
log: logger.debug
|
|
10
|
-
});
|
|
6
|
+
const storage = createStorage();
|
|
11
7
|
return {
|
|
12
8
|
async writeOutput (fileName, content) {
|
|
13
9
|
await storage.writeFile(fileName, content, 'utf8');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storageAdapter.js","sources":["../../src/util/storageAdapter.ts"],"sourcesContent":["/**\n * Adapter for ai-service StorageAdapter using kodrdriv Storage\n */\n\nimport type { StorageAdapter } from '@eldrforge/ai-service';\nimport
|
|
1
|
+
{"version":3,"file":"storageAdapter.js","sources":["../../src/util/storageAdapter.ts"],"sourcesContent":["/**\n * Adapter for ai-service StorageAdapter using kodrdriv Storage\n */\n\nimport type { StorageAdapter } from '@eldrforge/ai-service';\nimport { createStorage } from '@eldrforge/shared';\n\n/**\n * Create a StorageAdapter implementation using kodrdriv Storage\n */\nexport function createStorageAdapter(): StorageAdapter {\n const storage = createStorage();\n\n return {\n async writeOutput(fileName: string, content: string): Promise<void> {\n await storage.writeFile(fileName, content, 'utf8');\n },\n\n async readTemp(fileName: string): Promise<string> {\n return await storage.readFile(fileName, 'utf8');\n },\n\n async writeTemp(fileName: string, content: string): Promise<void> {\n await storage.writeFile(fileName, content, 'utf8');\n },\n };\n}\n\n"],"names":["createStorageAdapter","storage","createStorage","writeOutput","fileName","content","writeFile","readTemp","readFile","writeTemp"],"mappings":";;AAOA;;AAEC,IACM,SAASA,oBAAAA,GAAAA;AACZ,IAAA,MAAMC,OAAAA,GAAUC,aAAAA,EAAAA;IAEhB,OAAO;QACH,MAAMC,WAAAA,CAAAA,CAAYC,QAAgB,EAAEC,OAAe,EAAA;AAC/C,YAAA,MAAMJ,OAAAA,CAAQK,SAAS,CAACF,QAAAA,EAAUC,OAAAA,EAAS,MAAA,CAAA;AAC/C,QAAA,CAAA;AAEA,QAAA,MAAME,UAASH,QAAgB,EAAA;AAC3B,YAAA,OAAO,MAAMH,OAAAA,CAAQO,QAAQ,CAACJ,QAAAA,EAAU,MAAA,CAAA;AAC5C,QAAA,CAAA;QAEA,MAAMK,SAAAA,CAAAA,CAAUL,QAAgB,EAAEC,OAAe,EAAA;AAC7C,YAAA,MAAMJ,OAAAA,CAAQK,SAAS,CAACF,QAAAA,EAAUC,OAAAA,EAAS,MAAA,CAAA;AAC/C,QAAA;AACJ,KAAA;AACJ;;;;"}
|