@renseiai/agentfactory-cli 0.8.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 (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +123 -0
  3. package/dist/src/agent.d.ts +20 -0
  4. package/dist/src/agent.d.ts.map +1 -0
  5. package/dist/src/agent.js +109 -0
  6. package/dist/src/analyze-logs.d.ts +26 -0
  7. package/dist/src/analyze-logs.d.ts.map +1 -0
  8. package/dist/src/analyze-logs.js +152 -0
  9. package/dist/src/cleanup.d.ts +17 -0
  10. package/dist/src/cleanup.d.ts.map +1 -0
  11. package/dist/src/cleanup.js +111 -0
  12. package/dist/src/governor.d.ts +26 -0
  13. package/dist/src/governor.d.ts.map +1 -0
  14. package/dist/src/governor.js +305 -0
  15. package/dist/src/index.d.ts +10 -0
  16. package/dist/src/index.d.ts.map +1 -0
  17. package/dist/src/index.js +76 -0
  18. package/dist/src/lib/agent-runner.d.ts +28 -0
  19. package/dist/src/lib/agent-runner.d.ts.map +1 -0
  20. package/dist/src/lib/agent-runner.js +272 -0
  21. package/dist/src/lib/analyze-logs-runner.d.ts +47 -0
  22. package/dist/src/lib/analyze-logs-runner.d.ts.map +1 -0
  23. package/dist/src/lib/analyze-logs-runner.js +216 -0
  24. package/dist/src/lib/auto-updater.d.ts +40 -0
  25. package/dist/src/lib/auto-updater.d.ts.map +1 -0
  26. package/dist/src/lib/auto-updater.js +109 -0
  27. package/dist/src/lib/cleanup-runner.d.ts +29 -0
  28. package/dist/src/lib/cleanup-runner.d.ts.map +1 -0
  29. package/dist/src/lib/cleanup-runner.js +295 -0
  30. package/dist/src/lib/governor-dependencies.d.ts +23 -0
  31. package/dist/src/lib/governor-dependencies.d.ts.map +1 -0
  32. package/dist/src/lib/governor-dependencies.js +361 -0
  33. package/dist/src/lib/governor-logger.d.ts +30 -0
  34. package/dist/src/lib/governor-logger.d.ts.map +1 -0
  35. package/dist/src/lib/governor-logger.js +210 -0
  36. package/dist/src/lib/governor-runner.d.ts +103 -0
  37. package/dist/src/lib/governor-runner.d.ts.map +1 -0
  38. package/dist/src/lib/governor-runner.js +210 -0
  39. package/dist/src/lib/linear-runner.d.ts +8 -0
  40. package/dist/src/lib/linear-runner.d.ts.map +1 -0
  41. package/dist/src/lib/linear-runner.js +7 -0
  42. package/dist/src/lib/orchestrator-runner.d.ts +51 -0
  43. package/dist/src/lib/orchestrator-runner.d.ts.map +1 -0
  44. package/dist/src/lib/orchestrator-runner.js +151 -0
  45. package/dist/src/lib/queue-admin-runner.d.ts +30 -0
  46. package/dist/src/lib/queue-admin-runner.d.ts.map +1 -0
  47. package/dist/src/lib/queue-admin-runner.js +378 -0
  48. package/dist/src/lib/sync-routes-runner.d.ts +28 -0
  49. package/dist/src/lib/sync-routes-runner.d.ts.map +1 -0
  50. package/dist/src/lib/sync-routes-runner.js +110 -0
  51. package/dist/src/lib/version.d.ts +35 -0
  52. package/dist/src/lib/version.d.ts.map +1 -0
  53. package/dist/src/lib/version.js +168 -0
  54. package/dist/src/lib/worker-fleet-runner.d.ts +32 -0
  55. package/dist/src/lib/worker-fleet-runner.d.ts.map +1 -0
  56. package/dist/src/lib/worker-fleet-runner.js +256 -0
  57. package/dist/src/lib/worker-runner.d.ts +33 -0
  58. package/dist/src/lib/worker-runner.d.ts.map +1 -0
  59. package/dist/src/lib/worker-runner.js +781 -0
  60. package/dist/src/linear.d.ts +37 -0
  61. package/dist/src/linear.d.ts.map +1 -0
  62. package/dist/src/linear.js +118 -0
  63. package/dist/src/orchestrator.d.ts +21 -0
  64. package/dist/src/orchestrator.d.ts.map +1 -0
  65. package/dist/src/orchestrator.js +190 -0
  66. package/dist/src/queue-admin.d.ts +25 -0
  67. package/dist/src/queue-admin.d.ts.map +1 -0
  68. package/dist/src/queue-admin.js +96 -0
  69. package/dist/src/sync-routes.d.ts +17 -0
  70. package/dist/src/sync-routes.d.ts.map +1 -0
  71. package/dist/src/sync-routes.js +100 -0
  72. package/dist/src/worker-fleet.d.ts +25 -0
  73. package/dist/src/worker-fleet.d.ts.map +1 -0
  74. package/dist/src/worker-fleet.js +140 -0
  75. package/dist/src/worker.d.ts +26 -0
  76. package/dist/src/worker.d.ts.map +1 -0
  77. package/dist/src/worker.js +135 -0
  78. package/package.json +175 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Rensei AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # @renseiai/agentfactory-cli
2
+
3
+ CLI tools for [AgentFactory](https://github.com/renseiai/agentfactory). Run a local orchestrator, remote workers, worker fleets, and queue management.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Global (CLI commands)
9
+ npm install -g @renseiai/agentfactory-cli
10
+
11
+ # Local (programmatic runner functions)
12
+ npm install @renseiai/agentfactory-cli
13
+ ```
14
+
15
+ ## CLI Commands
16
+
17
+ ```bash
18
+ # Spawn agents on backlog issues
19
+ af-orchestrator --project MyProject --max 3
20
+
21
+ # Process a single issue
22
+ af-orchestrator --single PROJ-123
23
+
24
+ # Dry run — preview what would be processed
25
+ af-orchestrator --project MyProject --dry-run
26
+
27
+ # Start the Workflow Governor (event-driven + poll sweep)
28
+ af-governor --project MyProject --project OtherProject
29
+
30
+ # Governor: single scan and exit (for cron jobs)
31
+ af-governor --project MyProject --once
32
+
33
+ # Governor: poll-only mode (no event bus)
34
+ af-governor --project MyProject --mode poll-only
35
+
36
+ # Start a remote worker
37
+ af-worker --api-url https://your-app.vercel.app --api-key your-key
38
+
39
+ # Start a worker fleet (auto-detects CPU cores)
40
+ af-worker-fleet --api-url https://your-app.vercel.app --api-key your-key
41
+
42
+ # Clean up orphaned git worktrees
43
+ af-cleanup
44
+
45
+ # Queue management
46
+ af-queue-admin list
47
+ af-queue-admin drain
48
+
49
+ # Analyze agent session logs
50
+ af-analyze-logs --follow
51
+ ```
52
+
53
+ ### Governor
54
+
55
+ The Workflow Governor scans projects and decides what work to dispatch based on issue status, active sessions, cooldowns, and human overrides.
56
+
57
+ **Modes:**
58
+ - `event-driven` (default) — Listens to a GovernorEventBus for real-time webhook events, with a periodic poll sweep as safety net
59
+ - `poll-only` — Periodic scan loop only
60
+
61
+ **Options:**
62
+ ```
63
+ --project <name> Project to scan (repeatable)
64
+ --scan-interval <ms> Poll interval (default: 60000 for poll-only, 300000 for event-driven)
65
+ --max-dispatches <n> Max concurrent dispatches per scan (default: 3)
66
+ --mode <mode> poll-only or event-driven (default: event-driven)
67
+ --once Single scan pass and exit
68
+ --no-auto-research Disable Icebox → research
69
+ --no-auto-backlog-creation Disable Icebox → backlog-creation
70
+ --no-auto-development Disable Backlog → development
71
+ --no-auto-qa Disable Finished → QA
72
+ --no-auto-acceptance Disable Delivered → acceptance
73
+ ```
74
+
75
+ When `LINEAR_API_KEY` and `REDIS_URL` are set, the governor uses real dependencies (Linear SDK + Redis). Without them, it falls back to stub dependencies for testing.
76
+
77
+ ## Programmatic Usage
78
+
79
+ All CLI tools are available as importable functions via subpath exports:
80
+
81
+ ```typescript
82
+ import { runOrchestrator } from '@renseiai/agentfactory-cli/orchestrator'
83
+
84
+ await runOrchestrator({
85
+ project: 'MyProject',
86
+ max: 3,
87
+ dryRun: false,
88
+ })
89
+ ```
90
+
91
+ ### Available Runner Functions
92
+
93
+ ```typescript
94
+ import { runOrchestrator } from '@renseiai/agentfactory-cli/orchestrator'
95
+ import { runWorker } from '@renseiai/agentfactory-cli/worker'
96
+ import { runWorkerFleet } from '@renseiai/agentfactory-cli/worker-fleet'
97
+ import { runCleanup } from '@renseiai/agentfactory-cli/cleanup'
98
+ import { runQueueAdmin } from '@renseiai/agentfactory-cli/queue-admin'
99
+ import { runLogAnalyzer } from '@renseiai/agentfactory-cli/analyze-logs'
100
+ ```
101
+
102
+ Each function accepts a config object and returns a Promise — use them to build thin wrappers with your own env loading and argument parsing.
103
+
104
+ ## Environment Variables
105
+
106
+ | Variable | Used By | Description |
107
+ |----------|---------|-------------|
108
+ | `LINEAR_API_KEY` | orchestrator, governor | Linear API key |
109
+ | `REDIS_URL` | governor, queue-admin | Redis connection URL |
110
+ | `WORKER_API_URL` | worker, fleet | Webhook server URL |
111
+ | `WORKER_API_KEY` | worker, fleet | API key for authentication |
112
+
113
+ ## Related Packages
114
+
115
+ | Package | Description |
116
+ |---------|-------------|
117
+ | [@renseiai/agentfactory](https://www.npmjs.com/package/@renseiai/agentfactory) | Core orchestrator |
118
+ | [@renseiai/agentfactory-server](https://www.npmjs.com/package/@renseiai/agentfactory-server) | Redis work queue |
119
+ | [@renseiai/agentfactory-nextjs](https://www.npmjs.com/package/@renseiai/agentfactory-nextjs) | Next.js webhook server |
120
+
121
+ ## License
122
+
123
+ MIT
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AgentFactory Agent CLI
4
+ *
5
+ * Manage running agent sessions: list, stop, send messages, check status,
6
+ * or reconnect a disconnected Linear session.
7
+ *
8
+ * Usage:
9
+ * af-agent list [--all] List active sessions
10
+ * af-agent stop <issue-id> Stop a running agent
11
+ * af-agent chat <issue-id> <message> Send a message to a running agent
12
+ * af-agent status <issue-id> Show session details
13
+ * af-agent reconnect <issue-id> Re-establish Linear agent session
14
+ *
15
+ * Environment (loaded from .env.local in CWD):
16
+ * REDIS_URL Required for all commands
17
+ * LINEAR_API_KEY Required for reconnect
18
+ */
19
+ export {};
20
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;GAgBG"}
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AgentFactory Agent CLI
4
+ *
5
+ * Manage running agent sessions: list, stop, send messages, check status,
6
+ * or reconnect a disconnected Linear session.
7
+ *
8
+ * Usage:
9
+ * af-agent list [--all] List active sessions
10
+ * af-agent stop <issue-id> Stop a running agent
11
+ * af-agent chat <issue-id> <message> Send a message to a running agent
12
+ * af-agent status <issue-id> Show session details
13
+ * af-agent reconnect <issue-id> Re-establish Linear agent session
14
+ *
15
+ * Environment (loaded from .env.local in CWD):
16
+ * REDIS_URL Required for all commands
17
+ * LINEAR_API_KEY Required for reconnect
18
+ */
19
+ import path from 'path';
20
+ import { config } from 'dotenv';
21
+ // Load environment variables from .env.local in CWD
22
+ config({ path: path.resolve(process.cwd(), '.env.local') });
23
+ import { runAgent, C } from './lib/agent-runner.js';
24
+ // ---------------------------------------------------------------------------
25
+ // Usage
26
+ // ---------------------------------------------------------------------------
27
+ function printUsage() {
28
+ console.log(`
29
+ ${C.cyan}AgentFactory Agent${C.reset} - Manage running agent sessions
30
+
31
+ ${C.yellow}Usage:${C.reset}
32
+ af-agent <command> [issue-id] [args]
33
+
34
+ ${C.yellow}Commands:${C.reset}
35
+ list [--all] List active sessions (--all includes completed/failed)
36
+ ls [--all] Alias for list
37
+ stop <issue-id> Stop a running agent (worker aborts within ~5s)
38
+ chat <issue-id> <message> Send a message to a running agent session
39
+ status <issue-id> Show detailed session information
40
+ reconnect <issue-id> Create new Linear session and re-associate
41
+
42
+ ${C.yellow}Arguments:${C.reset}
43
+ <issue-id> Issue identifier (e.g., SUP-674) or partial session ID
44
+
45
+ ${C.yellow}Examples:${C.reset}
46
+ af-agent ls
47
+ af-agent list --all
48
+ af-agent stop SUP-674
49
+ af-agent chat SUP-674 "use the existing test fixtures instead"
50
+ af-agent status SUP-674
51
+ af-agent reconnect SUP-674
52
+
53
+ ${C.yellow}Environment:${C.reset}
54
+ REDIS_URL Required for all commands
55
+ LINEAR_API_KEY Required for reconnect
56
+ `);
57
+ }
58
+ // ---------------------------------------------------------------------------
59
+ // Valid commands
60
+ // ---------------------------------------------------------------------------
61
+ const VALID_COMMANDS = new Set(['stop', 'chat', 'status', 'reconnect', 'list']);
62
+ const COMMAND_ALIASES = { ls: 'list' };
63
+ // ---------------------------------------------------------------------------
64
+ // Main
65
+ // ---------------------------------------------------------------------------
66
+ async function main() {
67
+ let command = process.argv[2];
68
+ if (!command || command === 'help' || command === '--help' || command === '-h') {
69
+ printUsage();
70
+ return;
71
+ }
72
+ // Resolve aliases
73
+ command = COMMAND_ALIASES[command] ?? command;
74
+ if (!VALID_COMMANDS.has(command)) {
75
+ console.error(`Unknown command: ${command}`);
76
+ printUsage();
77
+ process.exit(1);
78
+ }
79
+ // list/ls doesn't require an issue ID
80
+ if (command === 'list') {
81
+ const showAll = process.argv.includes('--all') || process.argv.includes('-a');
82
+ await runAgent({ command: 'list', all: showAll });
83
+ return;
84
+ }
85
+ const issueId = process.argv[3];
86
+ if (!issueId) {
87
+ console.error(`Usage: af-agent ${command} <issue-id>`);
88
+ process.exit(1);
89
+ }
90
+ // For chat, join remaining args as the message
91
+ let message;
92
+ if (command === 'chat') {
93
+ const messageArgs = process.argv.slice(4);
94
+ if (messageArgs.length === 0) {
95
+ console.error('Usage: af-agent chat <issue-id> <message>');
96
+ process.exit(1);
97
+ }
98
+ message = messageArgs.join(' ');
99
+ }
100
+ await runAgent({
101
+ command: command,
102
+ issueId,
103
+ message,
104
+ });
105
+ }
106
+ main().catch((error) => {
107
+ console.error('Error:', error instanceof Error ? error.message : error);
108
+ process.exit(1);
109
+ });
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AgentFactory Log Analyzer CLI
4
+ *
5
+ * Thin wrapper around the analyze-logs runner. Handles dotenv, arg parsing,
6
+ * SIGINT, and process.exit so the runner stays process-agnostic.
7
+ *
8
+ * Usage:
9
+ * af-analyze-logs [options]
10
+ *
11
+ * Options:
12
+ * --session <id> Analyze a specific session
13
+ * --follow, -f Watch for new sessions and analyze as they complete
14
+ * --interval <ms> Poll interval in milliseconds (default: 5000)
15
+ * --dry-run Show what would be created without creating issues
16
+ * --cleanup Cleanup old logs based on retention policy
17
+ * --verbose Show detailed analysis output
18
+ * --help, -h Show this help message
19
+ *
20
+ * Environment (loaded from .env.local in CWD):
21
+ * LINEAR_API_KEY Required for issue creation
22
+ * AGENT_LOG_RETENTION_DAYS Days before cleanup (default: 7)
23
+ * AGENT_LOGS_DIR Base directory for logs (default: .agent-logs)
24
+ */
25
+ export {};
26
+ //# sourceMappingURL=analyze-logs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyze-logs.d.ts","sourceRoot":"","sources":["../../src/analyze-logs.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;GAsBG"}
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AgentFactory Log Analyzer CLI
4
+ *
5
+ * Thin wrapper around the analyze-logs runner. Handles dotenv, arg parsing,
6
+ * SIGINT, and process.exit so the runner stays process-agnostic.
7
+ *
8
+ * Usage:
9
+ * af-analyze-logs [options]
10
+ *
11
+ * Options:
12
+ * --session <id> Analyze a specific session
13
+ * --follow, -f Watch for new sessions and analyze as they complete
14
+ * --interval <ms> Poll interval in milliseconds (default: 5000)
15
+ * --dry-run Show what would be created without creating issues
16
+ * --cleanup Cleanup old logs based on retention policy
17
+ * --verbose Show detailed analysis output
18
+ * --help, -h Show this help message
19
+ *
20
+ * Environment (loaded from .env.local in CWD):
21
+ * LINEAR_API_KEY Required for issue creation
22
+ * AGENT_LOG_RETENTION_DAYS Days before cleanup (default: 7)
23
+ * AGENT_LOGS_DIR Base directory for logs (default: .agent-logs)
24
+ */
25
+ import path from 'path';
26
+ import { config } from 'dotenv';
27
+ // Load environment variables from .env.local in CWD
28
+ config({ path: path.resolve(process.cwd(), '.env.local') });
29
+ import { runLogAnalyzer, printSummary } from './lib/analyze-logs-runner.js';
30
+ import { getVersion, checkForUpdate, printUpdateNotification } from './lib/version.js';
31
+ const DEFAULT_POLL_INTERVAL = 5000;
32
+ function parseArgs() {
33
+ const args = process.argv.slice(2);
34
+ const result = {
35
+ follow: false,
36
+ interval: DEFAULT_POLL_INTERVAL,
37
+ dryRun: false,
38
+ cleanup: false,
39
+ verbose: false,
40
+ showHelp: false,
41
+ };
42
+ for (let i = 0; i < args.length; i++) {
43
+ const arg = args[i];
44
+ switch (arg) {
45
+ case '--session':
46
+ result.sessionId = args[++i];
47
+ break;
48
+ case '--follow':
49
+ case '-f':
50
+ result.follow = true;
51
+ break;
52
+ case '--interval':
53
+ result.interval = parseInt(args[++i], 10) || DEFAULT_POLL_INTERVAL;
54
+ break;
55
+ case '--dry-run':
56
+ result.dryRun = true;
57
+ break;
58
+ case '--cleanup':
59
+ result.cleanup = true;
60
+ break;
61
+ case '--verbose':
62
+ result.verbose = true;
63
+ break;
64
+ case '--help':
65
+ case '-h':
66
+ result.showHelp = true;
67
+ break;
68
+ }
69
+ }
70
+ return result;
71
+ }
72
+ function printHelp() {
73
+ console.log(`
74
+ AgentFactory Log Analyzer - Analyze agent session logs for errors and improvements
75
+
76
+ Usage:
77
+ af-analyze-logs [options]
78
+
79
+ Options:
80
+ --session <id> Analyze a specific session
81
+ --follow, -f Watch for new sessions and analyze as they complete
82
+ --interval <ms> Poll interval in milliseconds (default: 5000)
83
+ --dry-run Show what would be created without creating issues
84
+ --cleanup Cleanup old logs based on retention policy
85
+ --verbose Show detailed analysis output
86
+ --help, -h Show this help message
87
+
88
+ Environment Variables:
89
+ LINEAR_API_KEY Required for creating Linear issues
90
+ AGENT_LOG_RETENTION_DAYS Days before log cleanup (default: 7)
91
+ AGENT_LOGS_DIR Base directory for logs (default: .agent-logs)
92
+
93
+ Examples:
94
+ # Analyze all unprocessed sessions
95
+ af-analyze-logs
96
+
97
+ # Analyze a specific session
98
+ af-analyze-logs --session abc123
99
+
100
+ # Watch for new sessions and analyze continuously
101
+ af-analyze-logs --follow
102
+
103
+ # Watch with custom poll interval (10 seconds)
104
+ af-analyze-logs -f --interval 10000
105
+
106
+ # Preview what issues would be created (no actual changes)
107
+ af-analyze-logs --dry-run
108
+
109
+ # Clean up logs older than retention period
110
+ af-analyze-logs --cleanup
111
+
112
+ # Show detailed output during analysis
113
+ af-analyze-logs --verbose
114
+ `);
115
+ }
116
+ // ---------------------------------------------------------------------------
117
+ // Main
118
+ // ---------------------------------------------------------------------------
119
+ async function main() {
120
+ const options = parseArgs();
121
+ if (options.showHelp) {
122
+ printHelp();
123
+ process.exit(0);
124
+ }
125
+ const version = getVersion();
126
+ console.log(`AgentFactory Log Analyzer \x1b[2mv${version}\x1b[0m\n`);
127
+ // Update check (non-blocking)
128
+ const updateCheck = await checkForUpdate();
129
+ printUpdateNotification(updateCheck);
130
+ // Create AbortController for SIGINT handling in follow mode
131
+ const controller = new AbortController();
132
+ if (options.follow) {
133
+ const shutdown = () => {
134
+ controller.abort();
135
+ };
136
+ process.on('SIGINT', shutdown);
137
+ process.on('SIGTERM', shutdown);
138
+ }
139
+ const result = await runLogAnalyzer({
140
+ sessionId: options.sessionId,
141
+ follow: options.follow,
142
+ interval: options.interval,
143
+ dryRun: options.dryRun,
144
+ cleanup: options.cleanup,
145
+ verbose: options.verbose,
146
+ }, controller.signal);
147
+ printSummary(result, options.dryRun);
148
+ }
149
+ main().catch((error) => {
150
+ console.error('Error:', error instanceof Error ? error.message : error);
151
+ process.exit(1);
152
+ });
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AgentFactory Worktree Cleanup CLI
4
+ *
5
+ * Thin wrapper around the cleanup runner.
6
+ *
7
+ * Usage:
8
+ * af-cleanup [options]
9
+ *
10
+ * Options:
11
+ * --dry-run Show what would be cleaned up without removing anything
12
+ * --force Force removal even if worktree appears active
13
+ * --path <dir> Custom worktrees directory (default: .worktrees)
14
+ * --help, -h Show this help message
15
+ */
16
+ export {};
17
+ //# sourceMappingURL=cleanup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../src/cleanup.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;GAaG"}
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AgentFactory Worktree Cleanup CLI
4
+ *
5
+ * Thin wrapper around the cleanup runner.
6
+ *
7
+ * Usage:
8
+ * af-cleanup [options]
9
+ *
10
+ * Options:
11
+ * --dry-run Show what would be cleaned up without removing anything
12
+ * --force Force removal even if worktree appears active
13
+ * --path <dir> Custom worktrees directory (default: .worktrees)
14
+ * --help, -h Show this help message
15
+ */
16
+ import { basename } from 'path';
17
+ import { runCleanup, getGitRoot } from './lib/cleanup-runner.js';
18
+ function parseArgs() {
19
+ const args = process.argv.slice(2);
20
+ const result = {
21
+ dryRun: false,
22
+ force: false,
23
+ worktreePath: undefined,
24
+ };
25
+ for (let i = 0; i < args.length; i++) {
26
+ const arg = args[i];
27
+ switch (arg) {
28
+ case '--dry-run':
29
+ result.dryRun = true;
30
+ break;
31
+ case '--force':
32
+ result.force = true;
33
+ break;
34
+ case '--path':
35
+ result.worktreePath = args[++i];
36
+ break;
37
+ case '--help':
38
+ case '-h':
39
+ printHelp();
40
+ process.exit(0);
41
+ }
42
+ }
43
+ return result;
44
+ }
45
+ function printHelp() {
46
+ console.log(`
47
+ AgentFactory Worktree Cleanup - Remove orphaned git worktrees
48
+
49
+ Usage:
50
+ af-cleanup [options]
51
+
52
+ Options:
53
+ --dry-run Show what would be cleaned up without removing
54
+ --force Force removal even if worktree appears active
55
+ --path <dir> Custom worktrees directory (default: .worktrees)
56
+ --help, -h Show this help message
57
+
58
+ Orphaned worktrees are identified by:
59
+ - Branch no longer exists (merged/deleted)
60
+ - Not listed in 'git worktree list' (stale directory)
61
+ - Lock file exists but is stale
62
+
63
+ Examples:
64
+ # Preview what would be cleaned up
65
+ af-cleanup --dry-run
66
+
67
+ # Clean up orphaned worktrees
68
+ af-cleanup
69
+
70
+ # Force cleanup all worktrees (use with caution)
71
+ af-cleanup --force
72
+ `);
73
+ }
74
+ function printSummary(result) {
75
+ console.log('=== Summary ===\n');
76
+ console.log(` Scanned: ${result.scanned} worktree(s)`);
77
+ console.log(` Orphaned: ${result.orphaned}`);
78
+ console.log(` Cleaned: ${result.cleaned}`);
79
+ if (result.skipped > 0) {
80
+ console.log(` Skipped: ${result.skipped} (IDE/process still open — use --force)`);
81
+ }
82
+ if (result.errors.length > 0) {
83
+ console.log(` Errors: ${result.errors.length}`);
84
+ for (const err of result.errors) {
85
+ console.log(` - ${basename(err.path)}: ${err.error}`);
86
+ }
87
+ }
88
+ console.log('');
89
+ }
90
+ // Main execution
91
+ function main() {
92
+ const args = parseArgs();
93
+ console.log('\n=== AgentFactory Worktree Cleanup ===\n');
94
+ if (args.dryRun) {
95
+ console.log('[DRY RUN MODE - No changes will be made]\n');
96
+ }
97
+ if (args.force) {
98
+ console.log('[FORCE MODE - All worktrees will be removed]\n');
99
+ }
100
+ const result = runCleanup({
101
+ dryRun: args.dryRun,
102
+ force: args.force,
103
+ worktreePath: args.worktreePath,
104
+ gitRoot: getGitRoot(),
105
+ });
106
+ printSummary(result);
107
+ if (result.errors.length > 0) {
108
+ process.exit(1);
109
+ }
110
+ }
111
+ main();
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AgentFactory Governor CLI
4
+ *
5
+ * Thin wrapper around the governor runner.
6
+ *
7
+ * Usage:
8
+ * af-governor [options]
9
+ *
10
+ * Options:
11
+ * --project <name> Project to scan (can be repeated)
12
+ * --scan-interval <ms> Scan interval in milliseconds (default: 60000)
13
+ * --max-dispatches <n> Maximum concurrent dispatches per scan (default: 3)
14
+ * --no-auto-research Disable auto-research from Icebox
15
+ * --no-auto-backlog-creation Disable auto-backlog-creation from Icebox
16
+ * --no-auto-development Disable auto-development from Backlog
17
+ * --no-auto-qa Disable auto-QA from Finished
18
+ * --no-auto-acceptance Disable auto-acceptance from Delivered
19
+ * --once Run a single scan pass and exit
20
+ *
21
+ * Environment:
22
+ * LINEAR_API_KEY Required API key for Linear authentication
23
+ * GOVERNOR_PROJECTS Comma-separated project names (fallback for --project)
24
+ */
25
+ export {};
26
+ //# sourceMappingURL=governor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"governor.d.ts","sourceRoot":"","sources":["../../src/governor.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;GAsBG"}