@oss-autopilot/core 3.22.2 → 3.22.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.
- package/dist/cli.bundle.cjs +58 -59
- package/dist/commands/local-repos.js +48 -18
- package/dist/commands/overnight.js +9 -0
- package/package.json +4 -4
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Scans configurable directories for local git clones and caches results
|
|
4
4
|
*/
|
|
5
5
|
import * as fs from 'node:fs';
|
|
6
|
-
import
|
|
6
|
+
import path from 'node:path';
|
|
7
7
|
import * as os from 'node:os';
|
|
8
8
|
import { execFileSync } from 'node:child_process';
|
|
9
9
|
import { getStateManager, debug } from '../core/index.js';
|
|
@@ -17,6 +17,49 @@ const DEFAULT_SCAN_PATHS = [
|
|
|
17
17
|
path.join(os.homedir(), 'code'),
|
|
18
18
|
path.join(os.homedir(), 'repos'),
|
|
19
19
|
];
|
|
20
|
+
// Maximum depth for `.git` directories, matching the previous `find -maxdepth 4` behavior.
|
|
21
|
+
const MAX_GIT_DIR_DEPTH = 4;
|
|
22
|
+
// Wall-clock bound per scan root, matching the previous `execFileSync` timeout. A scan root like
|
|
23
|
+
// `~` can hold millions of entries within four levels; a partial result beats a hung process.
|
|
24
|
+
const SCAN_TIMEOUT_MS = 30_000;
|
|
25
|
+
function collectGitDirectoryEntries(entries, directory, depth, pending, gitDirectories) {
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
if (!entry.isDirectory())
|
|
28
|
+
continue;
|
|
29
|
+
const childPath = path.join(directory, entry.name);
|
|
30
|
+
const childDepth = depth + 1;
|
|
31
|
+
if (entry.name === '.git') {
|
|
32
|
+
gitDirectories.push(childPath);
|
|
33
|
+
}
|
|
34
|
+
else if (childDepth < MAX_GIT_DIR_DEPTH) {
|
|
35
|
+
pending.push({ directory: childPath, depth: childDepth });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Find `.git` directories without platform-specific shell tools. Directory symlinks are not
|
|
40
|
+
// followed, matching GNU find's default behavior.
|
|
41
|
+
function findGitDirectories(scanPath) {
|
|
42
|
+
const gitDirectories = [];
|
|
43
|
+
const pending = [{ directory: scanPath, depth: 0 }];
|
|
44
|
+
const deadline = Date.now() + SCAN_TIMEOUT_MS;
|
|
45
|
+
while (pending.length > 0) {
|
|
46
|
+
if (Date.now() > deadline) {
|
|
47
|
+
debug('local-repos', `Scan of ${scanPath} exceeded ${SCAN_TIMEOUT_MS}ms; returning partial results`);
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
const { directory, depth } = pending.pop();
|
|
51
|
+
let entries;
|
|
52
|
+
try {
|
|
53
|
+
entries = fs.readdirSync(directory, { withFileTypes: true });
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
debug('local-repos', `Failed to read directory ${directory}`, error);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
collectGitDirectoryEntries(entries, directory, depth, pending, gitDirectories);
|
|
60
|
+
}
|
|
61
|
+
return gitDirectories;
|
|
62
|
+
}
|
|
20
63
|
/** Extract the GitHub "owner/repo" remote from a git directory */
|
|
21
64
|
function getGitHubRemote(repoPath) {
|
|
22
65
|
try {
|
|
@@ -62,23 +105,10 @@ export function scanForRepos(scanPaths) {
|
|
|
62
105
|
for (const scanPath of scanPaths) {
|
|
63
106
|
if (!fs.existsSync(scanPath))
|
|
64
107
|
continue;
|
|
65
|
-
// Find git repos up to 3 levels deep
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
encoding: 'utf8',
|
|
70
|
-
timeout: 30_000,
|
|
71
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
72
|
-
}).trim();
|
|
73
|
-
gitDirs = output ? output.split('\n').filter(Boolean) : [];
|
|
74
|
-
}
|
|
75
|
-
catch (err) {
|
|
76
|
-
// find command failed for this scan path (permission denied, path gone, etc.) — skip it
|
|
77
|
-
debug('local-repos', `find failed for scan path ${scanPath}`, err);
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
for (const gitDir of gitDirs) {
|
|
81
|
-
const repoPath = path.dirname(gitDir);
|
|
108
|
+
// Find `.git` directories up to 4 levels beneath the scan root (repos up to 3 levels deep).
|
|
109
|
+
const gitDirectories = findGitDirectories(scanPath);
|
|
110
|
+
for (const gitDirectory of gitDirectories) {
|
|
111
|
+
const repoPath = path.dirname(gitDirectory);
|
|
82
112
|
const remote = getGitHubRemote(repoPath);
|
|
83
113
|
if (!remote)
|
|
84
114
|
continue;
|
|
@@ -258,6 +258,15 @@ export const OVERNIGHT_DISALLOWED_TOOLS = [
|
|
|
258
258
|
'Bash(gh issue close *)',
|
|
259
259
|
'Bash(gh run rerun *)',
|
|
260
260
|
'Bash(gh api *)',
|
|
261
|
+
// `npm`/`pnpm` are allowed for builds and tests, but a token in ~/.npmrc
|
|
262
|
+
// would let their registry writes ship a release unattended — exactly the
|
|
263
|
+
// credential-bearing writes the gate exists to keep out.
|
|
264
|
+
'Bash(npm publish)',
|
|
265
|
+
'Bash(npm publish *)',
|
|
266
|
+
'Bash(npm unpublish *)',
|
|
267
|
+
'Bash(npm deprecate *)',
|
|
268
|
+
'Bash(pnpm publish)',
|
|
269
|
+
'Bash(pnpm publish *)',
|
|
261
270
|
'AskUserQuestion',
|
|
262
271
|
].join(',');
|
|
263
272
|
export const OVERNIGHT_ALLOWED_TOOLS = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oss-autopilot/core",
|
|
3
|
-
"version": "3.22.
|
|
3
|
+
"version": "3.22.3",
|
|
4
4
|
"description": "CLI and core library for managing open source contributions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -60,13 +60,13 @@
|
|
|
60
60
|
"zod": "^4.5.4"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@types/node": "^26.4.
|
|
64
|
-
"@vitest/coverage-v8": "^
|
|
63
|
+
"@types/node": "^26.4.1",
|
|
64
|
+
"@vitest/coverage-v8": "^5.0.0",
|
|
65
65
|
"esbuild": "^0.28.2",
|
|
66
66
|
"tsx": "^4.23.13",
|
|
67
67
|
"typedoc": "^0.28.20",
|
|
68
68
|
"typescript": "^6.0.3",
|
|
69
|
-
"vitest": "^
|
|
69
|
+
"vitest": "^5.0.0"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build": "tsc",
|