@renseiai/agentfactory-cli 0.8.5 → 0.8.7
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/src/cleanup.d.ts +8 -6
- package/dist/src/cleanup.d.ts.map +1 -1
- package/dist/src/cleanup.js +74 -30
- package/dist/src/governor.js +1 -1
- package/dist/src/lib/agent-runner.js +1 -1
- package/dist/src/lib/cleanup-runner.d.ts +16 -1
- package/dist/src/lib/cleanup-runner.d.ts.map +1 -1
- package/dist/src/lib/cleanup-runner.js +151 -1
- package/dist/src/lib/governor-dependencies.d.ts +1 -1
- package/dist/src/lib/governor-dependencies.d.ts.map +1 -1
- package/dist/src/lib/governor-dependencies.js +2 -0
- package/dist/src/lib/governor-logger.d.ts +1 -1
- package/dist/src/lib/governor-logger.d.ts.map +1 -1
- package/dist/src/lib/linear-runner.d.ts +3 -3
- package/dist/src/lib/linear-runner.d.ts.map +1 -1
- package/dist/src/lib/linear-runner.js +3 -3
- package/dist/src/lib/orchestrator-runner.d.ts.map +1 -1
- package/dist/src/lib/orchestrator-runner.js +7 -0
- package/dist/src/lib/worker-runner.d.ts.map +1 -1
- package/dist/src/lib/worker-runner.js +7 -0
- package/dist/src/linear.d.ts +1 -0
- package/dist/src/linear.d.ts.map +1 -1
- package/dist/src/linear.js +2 -0
- package/package.json +5 -4
package/dist/src/cleanup.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* AgentFactory
|
|
3
|
+
* AgentFactory Cleanup CLI
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Cleans up orphaned git worktrees and stale local branches.
|
|
6
6
|
*
|
|
7
7
|
* Usage:
|
|
8
8
|
* af-cleanup [options]
|
|
9
9
|
*
|
|
10
10
|
* Options:
|
|
11
|
-
* --dry-run
|
|
12
|
-
* --force
|
|
13
|
-
* --path <dir>
|
|
14
|
-
* --
|
|
11
|
+
* --dry-run Show what would be cleaned up without removing anything
|
|
12
|
+
* --force Force removal / include branches with gone remotes
|
|
13
|
+
* --path <dir> Custom worktrees directory (default: .worktrees)
|
|
14
|
+
* --skip-worktrees Skip worktree cleanup
|
|
15
|
+
* --skip-branches Skip branch cleanup
|
|
16
|
+
* --help, -h Show this help message
|
|
15
17
|
*/
|
|
16
18
|
export {};
|
|
17
19
|
//# sourceMappingURL=cleanup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../src/cleanup.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../src/cleanup.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;GAeG"}
|
package/dist/src/cleanup.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* AgentFactory
|
|
3
|
+
* AgentFactory Cleanup CLI
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Cleans up orphaned git worktrees and stale local branches.
|
|
6
6
|
*
|
|
7
7
|
* Usage:
|
|
8
8
|
* af-cleanup [options]
|
|
9
9
|
*
|
|
10
10
|
* Options:
|
|
11
|
-
* --dry-run
|
|
12
|
-
* --force
|
|
13
|
-
* --path <dir>
|
|
14
|
-
* --
|
|
11
|
+
* --dry-run Show what would be cleaned up without removing anything
|
|
12
|
+
* --force Force removal / include branches with gone remotes
|
|
13
|
+
* --path <dir> Custom worktrees directory (default: .worktrees)
|
|
14
|
+
* --skip-worktrees Skip worktree cleanup
|
|
15
|
+
* --skip-branches Skip branch cleanup
|
|
16
|
+
* --help, -h Show this help message
|
|
15
17
|
*/
|
|
16
18
|
import { basename } from 'path';
|
|
17
19
|
import { runCleanup, getGitRoot } from './lib/cleanup-runner.js';
|
|
@@ -21,6 +23,8 @@ function parseArgs() {
|
|
|
21
23
|
dryRun: false,
|
|
22
24
|
force: false,
|
|
23
25
|
worktreePath: undefined,
|
|
26
|
+
skipWorktrees: false,
|
|
27
|
+
skipBranches: false,
|
|
24
28
|
};
|
|
25
29
|
for (let i = 0; i < args.length; i++) {
|
|
26
30
|
const arg = args[i];
|
|
@@ -34,6 +38,12 @@ function parseArgs() {
|
|
|
34
38
|
case '--path':
|
|
35
39
|
result.worktreePath = args[++i];
|
|
36
40
|
break;
|
|
41
|
+
case '--skip-worktrees':
|
|
42
|
+
result.skipWorktrees = true;
|
|
43
|
+
break;
|
|
44
|
+
case '--skip-branches':
|
|
45
|
+
result.skipBranches = true;
|
|
46
|
+
break;
|
|
37
47
|
case '--help':
|
|
38
48
|
case '-h':
|
|
39
49
|
printHelp();
|
|
@@ -44,67 +54,101 @@ function parseArgs() {
|
|
|
44
54
|
}
|
|
45
55
|
function printHelp() {
|
|
46
56
|
console.log(`
|
|
47
|
-
AgentFactory
|
|
57
|
+
AgentFactory Cleanup - Remove orphaned worktrees and stale branches
|
|
48
58
|
|
|
49
59
|
Usage:
|
|
50
60
|
af-cleanup [options]
|
|
51
61
|
|
|
52
62
|
Options:
|
|
53
|
-
--dry-run
|
|
54
|
-
--force
|
|
55
|
-
--path <dir>
|
|
56
|
-
--
|
|
63
|
+
--dry-run Show what would be cleaned up without removing
|
|
64
|
+
--force Force worktree removal + delete branches with gone remotes
|
|
65
|
+
--path <dir> Custom worktrees directory (default: .worktrees)
|
|
66
|
+
--skip-worktrees Skip worktree cleanup
|
|
67
|
+
--skip-branches Skip branch cleanup
|
|
68
|
+
--help, -h Show this help message
|
|
57
69
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
Worktree cleanup:
|
|
71
|
+
Orphaned worktrees are identified by:
|
|
72
|
+
- Branch no longer exists (merged/deleted)
|
|
73
|
+
- Not listed in 'git worktree list' (stale directory)
|
|
74
|
+
|
|
75
|
+
Branch cleanup:
|
|
76
|
+
By default, deletes local branches already merged into main.
|
|
77
|
+
With --force, also deletes branches whose remote tracking branch is gone.
|
|
62
78
|
|
|
63
79
|
Examples:
|
|
64
80
|
# Preview what would be cleaned up
|
|
65
81
|
af-cleanup --dry-run
|
|
66
82
|
|
|
67
|
-
# Clean up orphaned worktrees
|
|
83
|
+
# Clean up everything (merged branches + orphaned worktrees)
|
|
68
84
|
af-cleanup
|
|
69
85
|
|
|
70
|
-
#
|
|
86
|
+
# Aggressive cleanup (includes branches with gone remotes)
|
|
71
87
|
af-cleanup --force
|
|
88
|
+
|
|
89
|
+
# Only clean up branches
|
|
90
|
+
af-cleanup --skip-worktrees
|
|
91
|
+
|
|
92
|
+
# Only clean up worktrees
|
|
93
|
+
af-cleanup --skip-branches
|
|
72
94
|
`);
|
|
73
95
|
}
|
|
74
96
|
function printSummary(result) {
|
|
75
97
|
console.log('=== Summary ===\n');
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
console.log(`
|
|
98
|
+
if (result.scanned > 0 || result.orphaned > 0) {
|
|
99
|
+
console.log(' Worktrees:');
|
|
100
|
+
console.log(` Scanned: ${result.scanned}`);
|
|
101
|
+
console.log(` Orphaned: ${result.orphaned}`);
|
|
102
|
+
console.log(` Cleaned: ${result.cleaned}`);
|
|
103
|
+
if (result.skipped > 0) {
|
|
104
|
+
console.log(` Skipped: ${result.skipped} (IDE/process still open — use --force)`);
|
|
105
|
+
}
|
|
106
|
+
if (result.errors.length > 0) {
|
|
107
|
+
console.log(` Errors: ${result.errors.length}`);
|
|
108
|
+
for (const err of result.errors) {
|
|
109
|
+
console.log(` - ${basename(err.path)}: ${err.error}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
console.log('');
|
|
81
113
|
}
|
|
82
|
-
if (result.
|
|
83
|
-
console.log(
|
|
84
|
-
|
|
85
|
-
|
|
114
|
+
if (result.branches.scanned > 0 || result.branches.deleted > 0) {
|
|
115
|
+
console.log(' Branches:');
|
|
116
|
+
console.log(` Scanned: ${result.branches.scanned}`);
|
|
117
|
+
console.log(` Deleted: ${result.branches.deleted}`);
|
|
118
|
+
if (result.branches.errors.length > 0) {
|
|
119
|
+
console.log(` Errors: ${result.branches.errors.length}`);
|
|
120
|
+
for (const err of result.branches.errors) {
|
|
121
|
+
console.log(` - ${err.branch}: ${err.error}`);
|
|
122
|
+
}
|
|
86
123
|
}
|
|
124
|
+
console.log('');
|
|
125
|
+
}
|
|
126
|
+
const totalErrors = result.errors.length + result.branches.errors.length;
|
|
127
|
+
if (totalErrors === 0 && result.cleaned === 0 && result.branches.deleted === 0) {
|
|
128
|
+
console.log(' Nothing to clean up.\n');
|
|
87
129
|
}
|
|
88
|
-
console.log('');
|
|
89
130
|
}
|
|
90
131
|
// Main execution
|
|
91
132
|
function main() {
|
|
92
133
|
const args = parseArgs();
|
|
93
|
-
console.log('\n=== AgentFactory
|
|
134
|
+
console.log('\n=== AgentFactory Cleanup ===\n');
|
|
94
135
|
if (args.dryRun) {
|
|
95
136
|
console.log('[DRY RUN MODE - No changes will be made]\n');
|
|
96
137
|
}
|
|
97
138
|
if (args.force) {
|
|
98
|
-
console.log('[FORCE MODE -
|
|
139
|
+
console.log('[FORCE MODE - Aggressive cleanup enabled]\n');
|
|
99
140
|
}
|
|
100
141
|
const result = runCleanup({
|
|
101
142
|
dryRun: args.dryRun,
|
|
102
143
|
force: args.force,
|
|
103
144
|
worktreePath: args.worktreePath,
|
|
104
145
|
gitRoot: getGitRoot(),
|
|
146
|
+
skipWorktrees: args.skipWorktrees,
|
|
147
|
+
skipBranches: args.skipBranches,
|
|
105
148
|
});
|
|
106
149
|
printSummary(result);
|
|
107
|
-
|
|
150
|
+
const totalErrors = result.errors.length + result.branches.errors.length;
|
|
151
|
+
if (totalErrors > 0) {
|
|
108
152
|
process.exit(1);
|
|
109
153
|
}
|
|
110
154
|
}
|
package/dist/src/governor.js
CHANGED
|
@@ -31,7 +31,7 @@ import { createRealDependencies } from './lib/governor-dependencies.js';
|
|
|
31
31
|
import { printStartupBanner, printScanSummary, printCircuitBreakerWarning, } from './lib/governor-logger.js';
|
|
32
32
|
import { getVersion, checkForUpdate, printUpdateNotification } from './lib/version.js';
|
|
33
33
|
import { maybeAutoUpdate } from './lib/auto-updater.js';
|
|
34
|
-
import { createLinearAgentClient } from '@renseiai/
|
|
34
|
+
import { createLinearAgentClient } from '@renseiai/plugin-linear';
|
|
35
35
|
import { createLogger, initTouchpointStorage } from '@renseiai/agentfactory';
|
|
36
36
|
import { RedisOverrideStorage, listStoredWorkspaces, getAccessToken, createRedisTokenBucket, createRedisCircuitBreaker, } from '@renseiai/agentfactory-server';
|
|
37
37
|
// ---------------------------------------------------------------------------
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* status changes and pending prompts every 5 seconds.
|
|
7
7
|
*/
|
|
8
8
|
import { getRedisClient, getAllSessions, updateSessionStatus, storeSessionState, storePendingPrompt, disconnectRedis, } from '@renseiai/agentfactory-server';
|
|
9
|
-
import { createLinearAgentClient } from '@renseiai/
|
|
9
|
+
import { createLinearAgentClient } from '@renseiai/plugin-linear';
|
|
10
10
|
// ---------------------------------------------------------------------------
|
|
11
11
|
// ANSI colors
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
@@ -13,8 +13,12 @@ export interface CleanupRunnerConfig {
|
|
|
13
13
|
worktreePath?: string;
|
|
14
14
|
/** Git root for default worktree path (default: auto-detect) */
|
|
15
15
|
gitRoot?: string;
|
|
16
|
+
/** Skip worktree cleanup (default: false) */
|
|
17
|
+
skipWorktrees?: boolean;
|
|
18
|
+
/** Skip branch cleanup (default: false) */
|
|
19
|
+
skipBranches?: boolean;
|
|
16
20
|
}
|
|
17
|
-
export interface
|
|
21
|
+
export interface WorktreeCleanupResult {
|
|
18
22
|
scanned: number;
|
|
19
23
|
orphaned: number;
|
|
20
24
|
cleaned: number;
|
|
@@ -24,6 +28,17 @@ export interface CleanupResult {
|
|
|
24
28
|
error: string;
|
|
25
29
|
}>;
|
|
26
30
|
}
|
|
31
|
+
export interface CleanupResult extends WorktreeCleanupResult {
|
|
32
|
+
branches: BranchCleanupResult;
|
|
33
|
+
}
|
|
34
|
+
export interface BranchCleanupResult {
|
|
35
|
+
scanned: number;
|
|
36
|
+
deleted: number;
|
|
37
|
+
errors: Array<{
|
|
38
|
+
branch: string;
|
|
39
|
+
error: string;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
27
42
|
export declare function getGitRoot(): string;
|
|
28
43
|
export declare function runCleanup(config?: CleanupRunnerConfig): CleanupResult;
|
|
29
44
|
//# sourceMappingURL=cleanup-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanup-runner.d.ts","sourceRoot":"","sources":["../../../src/lib/cleanup-runner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,MAAM,WAAW,mBAAmB;IAClC,sEAAsE;IACtE,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,qEAAqE;IACrE,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"cleanup-runner.d.ts","sourceRoot":"","sources":["../../../src/lib/cleanup-runner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,MAAM,WAAW,mBAAmB;IAClC,sEAAsE;IACtE,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,qEAAqE;IACrE,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6CAA6C;IAC7C,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC/C;AAED,MAAM,WAAW,aAAc,SAAQ,qBAAqB;IAC1D,QAAQ,EAAE,mBAAmB,CAAA;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACjD;AAuBD,wBAAgB,UAAU,IAAI,MAAM,CASnC;AA8bD,wBAAgB,UAAU,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,aAAa,CAkBtE"}
|
|
@@ -282,6 +282,150 @@ function cleanup(options) {
|
|
|
282
282
|
return result;
|
|
283
283
|
}
|
|
284
284
|
// ---------------------------------------------------------------------------
|
|
285
|
+
// Branch cleanup
|
|
286
|
+
// ---------------------------------------------------------------------------
|
|
287
|
+
/**
|
|
288
|
+
* Get the current branch name (to avoid deleting it).
|
|
289
|
+
*/
|
|
290
|
+
function getCurrentBranch() {
|
|
291
|
+
try {
|
|
292
|
+
return execSync('git rev-parse --abbrev-ref HEAD', {
|
|
293
|
+
encoding: 'utf-8',
|
|
294
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
295
|
+
}).trim();
|
|
296
|
+
}
|
|
297
|
+
catch {
|
|
298
|
+
return '';
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Get branches that have been merged into the given base branch.
|
|
303
|
+
*/
|
|
304
|
+
function getMergedBranches(baseBranch) {
|
|
305
|
+
try {
|
|
306
|
+
const output = execSync(`git branch --merged ${baseBranch}`, {
|
|
307
|
+
encoding: 'utf-8',
|
|
308
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
309
|
+
});
|
|
310
|
+
return output
|
|
311
|
+
.split('\n')
|
|
312
|
+
.map((line) => line.replace(/^[*+]?\s+/, '').trim())
|
|
313
|
+
.filter((b) => b && b !== baseBranch);
|
|
314
|
+
}
|
|
315
|
+
catch {
|
|
316
|
+
return [];
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Get local branches whose remote tracking branch is gone.
|
|
321
|
+
*/
|
|
322
|
+
function getGoneBranches() {
|
|
323
|
+
try {
|
|
324
|
+
// Fetch prune first so we have up-to-date remote state
|
|
325
|
+
execSync('git fetch --prune 2>/dev/null || true', {
|
|
326
|
+
encoding: 'utf-8',
|
|
327
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
328
|
+
timeout: 15000,
|
|
329
|
+
});
|
|
330
|
+
const output = execSync('git branch -vv', {
|
|
331
|
+
encoding: 'utf-8',
|
|
332
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
333
|
+
});
|
|
334
|
+
const gone = [];
|
|
335
|
+
for (const line of output.split('\n')) {
|
|
336
|
+
// Match lines like " SUP-123 abc1234 [origin/SUP-123: gone] commit msg"
|
|
337
|
+
if (/\[.*: gone\]/.test(line)) {
|
|
338
|
+
const branch = line.replace(/^\*?\s+/, '').split(/\s+/)[0];
|
|
339
|
+
if (branch)
|
|
340
|
+
gone.push(branch);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return gone;
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
return [];
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Clean up stale local branches.
|
|
351
|
+
*
|
|
352
|
+
* Default: deletes branches merged into main.
|
|
353
|
+
* With force: also deletes branches whose remote tracking branch is gone.
|
|
354
|
+
*/
|
|
355
|
+
function cleanupBranches(options) {
|
|
356
|
+
const result = {
|
|
357
|
+
scanned: 0,
|
|
358
|
+
deleted: 0,
|
|
359
|
+
errors: [],
|
|
360
|
+
};
|
|
361
|
+
// Prune stale worktree metadata first so that branches from prunable
|
|
362
|
+
// worktrees (e.g. research agents) are no longer locked.
|
|
363
|
+
try {
|
|
364
|
+
execSync('git worktree prune', {
|
|
365
|
+
encoding: 'utf-8',
|
|
366
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
catch {
|
|
370
|
+
// Ignore prune errors
|
|
371
|
+
}
|
|
372
|
+
console.log('Scanning local branches...\n');
|
|
373
|
+
const currentBranch = getCurrentBranch();
|
|
374
|
+
// Determine the base branch (main or master)
|
|
375
|
+
const baseBranch = branchExists('main') ? 'main' : branchExists('master') ? 'master' : '';
|
|
376
|
+
if (!baseBranch) {
|
|
377
|
+
console.log('Could not determine base branch (main/master). Skipping branch cleanup.\n');
|
|
378
|
+
return result;
|
|
379
|
+
}
|
|
380
|
+
// Collect branches to delete
|
|
381
|
+
const toDelete = new Set();
|
|
382
|
+
const mergedBranches = getMergedBranches(baseBranch);
|
|
383
|
+
for (const b of mergedBranches) {
|
|
384
|
+
toDelete.add(b);
|
|
385
|
+
}
|
|
386
|
+
if (options.force) {
|
|
387
|
+
const goneBranches = getGoneBranches();
|
|
388
|
+
for (const b of goneBranches) {
|
|
389
|
+
toDelete.add(b);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
// Never delete base branch or current branch
|
|
393
|
+
toDelete.delete(baseBranch);
|
|
394
|
+
toDelete.delete(currentBranch);
|
|
395
|
+
result.scanned = toDelete.size;
|
|
396
|
+
if (toDelete.size === 0) {
|
|
397
|
+
console.log('No stale branches found.\n');
|
|
398
|
+
return result;
|
|
399
|
+
}
|
|
400
|
+
const merged = new Set(mergedBranches);
|
|
401
|
+
const sorted = [...toDelete].sort();
|
|
402
|
+
for (const branch of sorted) {
|
|
403
|
+
const isMerged = merged.has(branch);
|
|
404
|
+
const reason = isMerged ? 'merged' : 'remote gone';
|
|
405
|
+
if (options.dryRun) {
|
|
406
|
+
console.log(` Would delete: ${branch} (${reason})`);
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
// Use -d for merged, -D for gone (unmerged)
|
|
410
|
+
const flag = isMerged ? '-d' : '-D';
|
|
411
|
+
try {
|
|
412
|
+
execSync(`git branch ${flag} "${branch}"`, {
|
|
413
|
+
encoding: 'utf-8',
|
|
414
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
415
|
+
});
|
|
416
|
+
console.log(` deleted: ${branch} (${reason})`);
|
|
417
|
+
result.deleted++;
|
|
418
|
+
}
|
|
419
|
+
catch (err) {
|
|
420
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
421
|
+
console.log(` FAILED: ${branch} — ${msg}`);
|
|
422
|
+
result.errors.push({ branch, error: msg });
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
console.log('');
|
|
426
|
+
return result;
|
|
427
|
+
}
|
|
428
|
+
// ---------------------------------------------------------------------------
|
|
285
429
|
// Runner
|
|
286
430
|
// ---------------------------------------------------------------------------
|
|
287
431
|
export function runCleanup(config) {
|
|
@@ -291,5 +435,11 @@ export function runCleanup(config) {
|
|
|
291
435
|
force: config?.force ?? false,
|
|
292
436
|
worktreePath: config?.worktreePath ?? resolve(gitRoot, '.worktrees'),
|
|
293
437
|
};
|
|
294
|
-
|
|
438
|
+
const worktreeResult = config?.skipWorktrees
|
|
439
|
+
? { scanned: 0, orphaned: 0, cleaned: 0, skipped: 0, errors: [] }
|
|
440
|
+
: cleanup(options);
|
|
441
|
+
const branchResult = config?.skipBranches
|
|
442
|
+
? { scanned: 0, deleted: 0, errors: [] }
|
|
443
|
+
: cleanupBranches(options);
|
|
444
|
+
return { ...worktreeResult, branches: branchResult };
|
|
295
445
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* using the Linear SDK (via LinearAgentClient) and Redis storage
|
|
6
6
|
* (from @renseiai/agentfactory-server).
|
|
7
7
|
*/
|
|
8
|
-
import type { LinearAgentClient, WorkflowContext } from '@renseiai/
|
|
8
|
+
import type { LinearAgentClient, WorkflowContext } from '@renseiai/plugin-linear';
|
|
9
9
|
import type { GovernorDependencies } from '@renseiai/agentfactory';
|
|
10
10
|
export interface RealDependenciesConfig {
|
|
11
11
|
linearClient: LinearAgentClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"governor-dependencies.d.ts","sourceRoot":"","sources":["../../../src/lib/governor-dependencies.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"governor-dependencies.d.ts","sourceRoot":"","sources":["../../../src/lib/governor-dependencies.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACjF,OAAO,KAAK,EACV,oBAAoB,EAGrB,MAAM,wBAAwB,CAAA;AAiC/B,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,iBAAiB,CAAA;IAC/B,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAA;IACjE,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,eAAe,KAAK,MAAM,CAAA;CAC9H;AA6BD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,sBAAsB,GAC7B,oBAAoB,CA8TtB"}
|
|
@@ -252,6 +252,8 @@ export function createRealDependencies(config) {
|
|
|
252
252
|
if (parentIssueIds.has(issueId)) {
|
|
253
253
|
if (workType === 'development')
|
|
254
254
|
workType = 'coordination';
|
|
255
|
+
else if (workType === 'inflight')
|
|
256
|
+
workType = 'inflight-coordination';
|
|
255
257
|
else if (workType === 'qa')
|
|
256
258
|
workType = 'qa-coordination';
|
|
257
259
|
else if (workType === 'acceptance')
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* to avoid external dependencies like chalk.
|
|
6
6
|
*/
|
|
7
7
|
import type { ScanResult } from '@renseiai/agentfactory';
|
|
8
|
-
import type { LinearApiQuota } from '@renseiai/
|
|
8
|
+
import type { LinearApiQuota } from '@renseiai/plugin-linear';
|
|
9
9
|
export interface StartupBannerConfig {
|
|
10
10
|
version: string;
|
|
11
11
|
projects: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"governor-logger.d.ts","sourceRoot":"","sources":["../../../src/lib/governor-logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"governor-logger.d.ts","sourceRoot":"","sources":["../../../src/lib/governor-logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAkC7D,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,cAAc,EAAE,MAAM,CAAA;IACtB,uBAAuB,EAAE,MAAM,CAAA;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAA;IACb,QAAQ,EAAE;QACR,YAAY,EAAE,OAAO,CAAA;QACrB,mBAAmB,EAAE,OAAO,CAAA;QAC5B,eAAe,EAAE,OAAO,CAAA;QACxB,MAAM,EAAE,OAAO,CAAA;QACf,cAAc,EAAE,OAAO,CAAA;KACxB,CAAA;IACD,cAAc,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAA;CACvB;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAqFpE;AAMD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,UAAU,EAAE,EACrB,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,cAAc,EACtB,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CA6CN;AAMD,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAuC5E;AAMD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAa/D"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Linear CLI Runner — re-exports from @renseiai/
|
|
2
|
+
* Linear CLI Runner — re-exports from @renseiai/plugin-linear.
|
|
3
3
|
*
|
|
4
|
-
* The canonical implementation lives in packages/
|
|
4
|
+
* The canonical implementation lives in packages/linear/src/tools/linear-runner.ts
|
|
5
5
|
* so both the CLI and the in-process tool plugin share a single source of truth.
|
|
6
6
|
*/
|
|
7
|
-
export { runLinear, parseLinearArgs, type LinearRunnerConfig, type LinearRunnerResult, } from '@renseiai/
|
|
7
|
+
export { runLinear, parseLinearArgs, type LinearRunnerConfig, type LinearRunnerResult, } from '@renseiai/plugin-linear';
|
|
8
8
|
//# sourceMappingURL=linear-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linear-runner.d.ts","sourceRoot":"","sources":["../../../src/lib/linear-runner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,SAAS,EACT,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,
|
|
1
|
+
{"version":3,"file":"linear-runner.d.ts","sourceRoot":"","sources":["../../../src/lib/linear-runner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,SAAS,EACT,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,yBAAyB,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Linear CLI Runner — re-exports from @renseiai/
|
|
2
|
+
* Linear CLI Runner — re-exports from @renseiai/plugin-linear.
|
|
3
3
|
*
|
|
4
|
-
* The canonical implementation lives in packages/
|
|
4
|
+
* The canonical implementation lives in packages/linear/src/tools/linear-runner.ts
|
|
5
5
|
* so both the CLI and the in-process tool plugin share a single source of truth.
|
|
6
6
|
*/
|
|
7
|
-
export { runLinear, parseLinearArgs, } from '@renseiai/
|
|
7
|
+
export { runLinear, parseLinearArgs, } from '@renseiai/plugin-linear';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator-runner.d.ts","sourceRoot":"","sources":["../../../src/lib/orchestrator-runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAEL,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"orchestrator-runner.d.ts","sourceRoot":"","sources":["../../../src/lib/orchestrator-runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAA;AAY/B,MAAM,WAAW,wBAAwB;IACvC,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAA;IACpB,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6CAA6C;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kDAAkD;IAClD,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,iEAAiE;IACjE,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,qBAAqB,CAAA;IACjC,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAA;IACpD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAA;IAC5C,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAA;IAC/C,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAC1D,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAA;CAClD;AAED,MAAM,WAAW,wBAAwB;IACvC,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC,CAAA;IAChD,SAAS,EAAE,YAAY,EAAE,CAAA;CAC1B;AAMD,wBAAgB,UAAU,IAAI,MAAM,CASnC;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAYjD;AA0CD,wBAAsB,eAAe,CACnC,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,wBAAwB,CAAC,CAmGnC"}
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import { execSync } from 'child_process';
|
|
10
10
|
import { createOrchestrator, } from '@renseiai/agentfactory';
|
|
11
|
+
import { LinearIssueTrackerClient, createLinearStatusMappings, linearPlugin, } from '@renseiai/plugin-linear';
|
|
12
|
+
import { codeIntelligencePlugin } from '@renseiai/agentfactory-code-intelligence';
|
|
11
13
|
// ---------------------------------------------------------------------------
|
|
12
14
|
// Helpers
|
|
13
15
|
// ---------------------------------------------------------------------------
|
|
@@ -77,11 +79,16 @@ export async function runOrchestrator(config) {
|
|
|
77
79
|
const dryRun = config.dryRun ?? false;
|
|
78
80
|
const gitRoot = config.gitRoot ?? getGitRoot();
|
|
79
81
|
const cb = config.callbacks ?? defaultCallbacks();
|
|
82
|
+
const issueTrackerClient = new LinearIssueTrackerClient({ apiKey: config.linearApiKey });
|
|
83
|
+
const statusMappings = createLinearStatusMappings();
|
|
80
84
|
const orchestratorConfig = {
|
|
81
85
|
project: config.project,
|
|
82
86
|
maxConcurrent,
|
|
83
87
|
worktreePath: path.resolve(gitRoot, '.worktrees'),
|
|
84
88
|
linearApiKey: config.linearApiKey,
|
|
89
|
+
issueTrackerClient,
|
|
90
|
+
statusMappings,
|
|
91
|
+
toolPlugins: [linearPlugin, codeIntelligencePlugin],
|
|
85
92
|
};
|
|
86
93
|
if (config.templateDir) {
|
|
87
94
|
orchestratorConfig.templateDir = config.templateDir;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-runner.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"worker-runner.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyBH,MAAM,WAAW,kBAAkB;IACjC,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,mDAAmD;IACnD,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,gFAAgF;IAChF,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB;AAwED;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,kBAAkB,EAC1B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAy7Bf"}
|
|
@@ -9,6 +9,8 @@ import path from 'path';
|
|
|
9
9
|
import { execSync } from 'child_process';
|
|
10
10
|
import os from 'os';
|
|
11
11
|
import { createOrchestrator, createLogger, } from '@renseiai/agentfactory';
|
|
12
|
+
import { LinearIssueTrackerClient, createLinearStatusMappings, linearPlugin, } from '@renseiai/plugin-linear';
|
|
13
|
+
import { codeIntelligencePlugin } from '@renseiai/agentfactory-code-intelligence';
|
|
12
14
|
// ---------------------------------------------------------------------------
|
|
13
15
|
// Helpers (stateless)
|
|
14
16
|
// ---------------------------------------------------------------------------
|
|
@@ -405,9 +407,14 @@ export async function runWorker(config, signal) {
|
|
|
405
407
|
? `Resuming work on ${work.issueIdentifier}`
|
|
406
408
|
: `Worker claimed ${work.issueIdentifier}. Setting up environment...`);
|
|
407
409
|
// Create orchestrator with API activity proxy
|
|
410
|
+
const issueTrackerClient = new LinearIssueTrackerClient({ apiKey: linearApiKey });
|
|
411
|
+
const statusMappings = createLinearStatusMappings();
|
|
408
412
|
const orchestrator = createOrchestrator({
|
|
409
413
|
maxConcurrent: 1,
|
|
410
414
|
worktreePath: path.resolve(gitRoot, '.worktrees'),
|
|
415
|
+
issueTrackerClient,
|
|
416
|
+
statusMappings,
|
|
417
|
+
toolPlugins: [linearPlugin, codeIntelligencePlugin],
|
|
411
418
|
apiActivityConfig: {
|
|
412
419
|
baseUrl: workerConfig.apiUrl,
|
|
413
420
|
apiKey: workerConfig.apiKey,
|
package/dist/src/linear.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* update-issue <id> Update an existing issue
|
|
14
14
|
* list-comments <issueId> List comments on an issue
|
|
15
15
|
* create-comment <issueId> Create a comment on an issue
|
|
16
|
+
* list-issues List issues with flexible filters
|
|
16
17
|
* list-backlog-issues List backlog issues for a project
|
|
17
18
|
* list-unblocked-backlog List unblocked backlog issues
|
|
18
19
|
* check-blocked <id> Check if an issue is blocked
|
package/dist/src/linear.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linear.d.ts","sourceRoot":"","sources":["../../src/linear.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"linear.d.ts","sourceRoot":"","sources":["../../src/linear.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG"}
|
package/dist/src/linear.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* update-issue <id> Update an existing issue
|
|
14
14
|
* list-comments <issueId> List comments on an issue
|
|
15
15
|
* create-comment <issueId> Create a comment on an issue
|
|
16
|
+
* list-issues List issues with flexible filters
|
|
16
17
|
* list-backlog-issues List backlog issues for a project
|
|
17
18
|
* list-unblocked-backlog List unblocked backlog issues
|
|
18
19
|
* check-blocked <id> Check if an issue is blocked
|
|
@@ -51,6 +52,7 @@ Commands:
|
|
|
51
52
|
update-issue <id> Update an existing issue
|
|
52
53
|
list-comments <issueId> List comments on an issue
|
|
53
54
|
create-comment <issueId> Create a comment on an issue
|
|
55
|
+
list-issues List issues with flexible filters
|
|
54
56
|
list-backlog-issues List backlog issues for a project
|
|
55
57
|
list-unblocked-backlog List unblocked backlog issues
|
|
56
58
|
check-blocked <id> Check if an issue is blocked
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@renseiai/agentfactory-cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI tools for AgentFactory — local orchestrator, remote worker, queue admin",
|
|
6
6
|
"author": "Rensei AI (https://rensei.ai)",
|
|
@@ -101,9 +101,10 @@
|
|
|
101
101
|
],
|
|
102
102
|
"dependencies": {
|
|
103
103
|
"dotenv": "^17.2.3",
|
|
104
|
-
"@renseiai/agentfactory": "0.8.
|
|
105
|
-
"@renseiai/
|
|
106
|
-
"@renseiai/agentfactory-
|
|
104
|
+
"@renseiai/agentfactory": "0.8.7",
|
|
105
|
+
"@renseiai/plugin-linear": "0.8.7",
|
|
106
|
+
"@renseiai/agentfactory-code-intelligence": "0.8.7",
|
|
107
|
+
"@renseiai/agentfactory-server": "0.8.7"
|
|
107
108
|
},
|
|
108
109
|
"devDependencies": {
|
|
109
110
|
"@types/node": "^22.5.4",
|