@renseiai/agentfactory-cli 0.8.10 → 0.8.11

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/agent.js CHANGED
@@ -19,7 +19,7 @@
19
19
  import path from 'path';
20
20
  import { config } from 'dotenv';
21
21
  // Load environment variables from .env.local in CWD
22
- config({ path: path.resolve(process.cwd(), '.env.local') });
22
+ config({ path: path.resolve(process.cwd(), '.env.local'), quiet: true });
23
23
  import { runAgent, C } from './lib/agent-runner.js';
24
24
  // ---------------------------------------------------------------------------
25
25
  // Usage
@@ -25,7 +25,7 @@
25
25
  import path from 'path';
26
26
  import { config } from 'dotenv';
27
27
  // Load environment variables from .env.local in CWD
28
- config({ path: path.resolve(process.cwd(), '.env.local') });
28
+ config({ path: path.resolve(process.cwd(), '.env.local'), quiet: true });
29
29
  import { runLogAnalyzer, printSummary } from './lib/analyze-logs-runner.js';
30
30
  import { getVersion, checkForUpdate, printUpdateNotification } from './lib/version.js';
31
31
  const DEFAULT_POLL_INTERVAL = 5000;
@@ -25,7 +25,7 @@
25
25
  import path from 'path';
26
26
  import { config } from 'dotenv';
27
27
  // Load environment variables from .env.local
28
- config({ path: path.resolve(process.cwd(), '.env.local') });
28
+ config({ path: path.resolve(process.cwd(), '.env.local'), quiet: true });
29
29
  import { parseGovernorArgs, runGovernor, } from './lib/governor-runner.js';
30
30
  import { createRealDependencies } from './lib/governor-dependencies.js';
31
31
  import { printStartupBanner, printScanSummary, printCircuitBreakerWarning, } from './lib/governor-logger.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,QAAA,MAAM,OAAO,QAAkB,CAAA;AAE/B,iBAAS,SAAS,IAAI,IAAI,CAyBzB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,QAAA,MAAM,OAAO,QAAkB,CAAA;AAE/B,iBAAS,SAAS,IAAI,IAAI,CA0BzB"}
package/dist/src/index.js CHANGED
@@ -25,6 +25,7 @@ Commands:
25
25
  analyze-logs Analyze agent session logs for errors
26
26
  linear Linear issue tracker operations
27
27
  sync-routes Generate missing route and page files from manifest
28
+ setup Configure development tools (mergiraf, etc.)
28
29
  status Show fleet status (inline one-line summary)
29
30
  help Show this help message
30
31
 
@@ -64,6 +65,9 @@ switch (command) {
64
65
  case 'sync-routes':
65
66
  import('./sync-routes');
66
67
  break;
68
+ case 'setup':
69
+ import('./setup');
70
+ break;
67
71
  case 'status':
68
72
  import('./status');
69
73
  break;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Setup Mergiraf Runner — Programmatic API for configuring mergiraf as git merge driver.
3
+ *
4
+ * Exports `setupMergiraf()` so mergiraf configuration can be invoked from code
5
+ * without going through process.argv / process.env / process.exit.
6
+ */
7
+ export interface SetupMergirafConfig {
8
+ /** Show what would be done without making changes (default: false) */
9
+ dryRun?: boolean;
10
+ /** Only configure for agent worktrees, not the whole repo (default: false) */
11
+ worktreeOnly?: boolean;
12
+ /** Skip mergiraf binary check (default: false) */
13
+ skipCheck?: boolean;
14
+ /** Git root directory (default: auto-detect) */
15
+ gitRoot?: string;
16
+ /** Worktree path for per-worktree configuration (used with worktreeOnly) */
17
+ worktreePath?: string;
18
+ }
19
+ export interface SetupMergirafResult {
20
+ mergirafFound: boolean;
21
+ mergirafVersion: string;
22
+ configuredFileTypes: string[];
23
+ gitattributesWritten: boolean;
24
+ mergeDriverConfigured: boolean;
25
+ worktreeMode: boolean;
26
+ repoConfigUpdated: boolean;
27
+ errors: string[];
28
+ /** Process exit code: 0 = success, 1 = error, 2 = mergiraf not found */
29
+ exitCode: number;
30
+ }
31
+ export declare function getGitRoot(): string;
32
+ /**
33
+ * Detect mergiraf binary and return version info.
34
+ * Uses `which` to find the binary and `mergiraf --version` for the version string.
35
+ */
36
+ export declare function detectMergiraf(): {
37
+ found: boolean;
38
+ version: string;
39
+ };
40
+ /**
41
+ * Configure .gitattributes with mergiraf merge driver entries.
42
+ * Idempotent — skips entries that already exist.
43
+ */
44
+ export declare function configureGitattributes(gitRoot: string, config: SetupMergirafConfig): {
45
+ written: boolean;
46
+ fileTypes: string[];
47
+ };
48
+ /**
49
+ * Configure git merge driver for mergiraf via `git config`.
50
+ * In worktree-only mode, uses `--worktree` flag for worktree-local config.
51
+ */
52
+ export declare function configureMergeDriver(targetPath: string, config: SetupMergirafConfig): boolean;
53
+ /**
54
+ * Update .agentfactory/config.yaml with mergeDriver: mergiraf.
55
+ */
56
+ export declare function updateRepoConfig(gitRoot: string, config: SetupMergirafConfig): boolean;
57
+ export declare function setupMergiraf(config?: SetupMergirafConfig): SetupMergirafResult;
58
+ //# sourceMappingURL=setup-mergiraf-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-mergiraf-runner.d.ts","sourceRoot":"","sources":["../../../src/lib/setup-mergiraf-runner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,MAAM,WAAW,mBAAmB;IAClC,sEAAsE;IACtE,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,8EAA8E;IAC9E,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,kDAAkD;IAClD,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,OAAO,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,mBAAmB,EAAE,MAAM,EAAE,CAAA;IAC7B,oBAAoB,EAAE,OAAO,CAAA;IAC7B,qBAAqB,EAAE,OAAO,CAAA;IAC9B,YAAY,EAAE,OAAO,CAAA;IACrB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,wEAAwE;IACxE,QAAQ,EAAE,MAAM,CAAA;CACjB;AAMD,wBAAgB,UAAU,IAAI,MAAM,CASnC;AAMD;;;GAGG;AACH,wBAAgB,cAAc,IAAI;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAuBpE;AAgBD;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,mBAAmB,GAC1B;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CAkD3C;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAoCT;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAsCT;AAMD,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,mBAAmB,CA0D/E"}
@@ -0,0 +1,239 @@
1
+ /**
2
+ * Setup Mergiraf Runner — Programmatic API for configuring mergiraf as git merge driver.
3
+ *
4
+ * Exports `setupMergiraf()` so mergiraf configuration can be invoked from code
5
+ * without going through process.argv / process.env / process.exit.
6
+ */
7
+ import { execSync } from 'child_process';
8
+ import { existsSync, readFileSync, writeFileSync } from 'fs';
9
+ import { resolve } from 'path';
10
+ // ---------------------------------------------------------------------------
11
+ // Helpers
12
+ // ---------------------------------------------------------------------------
13
+ export function getGitRoot() {
14
+ try {
15
+ return execSync('git rev-parse --show-toplevel', {
16
+ encoding: 'utf-8',
17
+ stdio: ['pipe', 'pipe', 'pipe'],
18
+ }).trim();
19
+ }
20
+ catch {
21
+ return process.cwd();
22
+ }
23
+ }
24
+ // ---------------------------------------------------------------------------
25
+ // Step functions
26
+ // ---------------------------------------------------------------------------
27
+ /**
28
+ * Detect mergiraf binary and return version info.
29
+ * Uses `which` to find the binary and `mergiraf --version` for the version string.
30
+ */
31
+ export function detectMergiraf() {
32
+ try {
33
+ execSync('which mergiraf', { stdio: 'pipe', encoding: 'utf-8' });
34
+ }
35
+ catch {
36
+ console.log('mergiraf binary not found on PATH.\n');
37
+ console.log('Install mergiraf:');
38
+ console.log(' macOS: brew install mergiraf');
39
+ console.log(' Linux: cargo install mergiraf (or download from Codeberg releases)');
40
+ console.log(' Any: cargo install mergiraf (requires Rust toolchain)\n');
41
+ return { found: false, version: '' };
42
+ }
43
+ let version = '';
44
+ try {
45
+ version = execSync('mergiraf --version', {
46
+ encoding: 'utf-8',
47
+ stdio: ['pipe', 'pipe', 'pipe'],
48
+ }).trim();
49
+ }
50
+ catch {
51
+ version = '(unknown)';
52
+ }
53
+ return { found: true, version };
54
+ }
55
+ /** File types that mergiraf supports for AST-aware merging. */
56
+ const MERGIRAF_FILE_TYPES = [
57
+ '*.ts', '*.tsx', '*.js', '*.jsx', '*.mjs', '*.json',
58
+ '*.yaml', '*.yml', '*.py', '*.go', '*.rs',
59
+ '*.java', '*.css', '*.html',
60
+ ];
61
+ /** Lock files that should use merge=ours strategy. */
62
+ const LOCK_FILE_ENTRIES = [
63
+ 'pnpm-lock.yaml merge=ours',
64
+ 'package-lock.json merge=ours',
65
+ 'yarn.lock merge=ours',
66
+ ];
67
+ /**
68
+ * Configure .gitattributes with mergiraf merge driver entries.
69
+ * Idempotent — skips entries that already exist.
70
+ */
71
+ export function configureGitattributes(gitRoot, config) {
72
+ const gitattributesPath = resolve(gitRoot, '.gitattributes');
73
+ let existing = '';
74
+ if (existsSync(gitattributesPath)) {
75
+ existing = readFileSync(gitattributesPath, 'utf-8');
76
+ }
77
+ const lines = [];
78
+ const addedTypes = [];
79
+ // Add mergiraf merge driver entries
80
+ for (const ft of MERGIRAF_FILE_TYPES) {
81
+ const entry = `${ft} merge=mergiraf`;
82
+ if (!existing.includes(entry)) {
83
+ lines.push(entry);
84
+ addedTypes.push(ft);
85
+ }
86
+ }
87
+ // Add lock file entries
88
+ for (const entry of LOCK_FILE_ENTRIES) {
89
+ if (!existing.includes(entry)) {
90
+ lines.push(entry);
91
+ }
92
+ }
93
+ if (lines.length === 0) {
94
+ console.log(' .gitattributes already configured — no changes needed');
95
+ return { written: true, fileTypes: MERGIRAF_FILE_TYPES };
96
+ }
97
+ if (config.dryRun) {
98
+ console.log('[DRY RUN] Would add to .gitattributes:');
99
+ for (const line of lines) {
100
+ console.log(` ${line}`);
101
+ }
102
+ return { written: false, fileTypes: MERGIRAF_FILE_TYPES };
103
+ }
104
+ // Append new entries with a header comment
105
+ const newContent = existing.trimEnd() +
106
+ (existing.length > 0 ? '\n\n' : '') +
107
+ '# AST-aware merge driver (mergiraf)\n' +
108
+ lines.join('\n') + '\n';
109
+ writeFileSync(gitattributesPath, newContent, 'utf-8');
110
+ console.log(` .gitattributes updated: ${addedTypes.length} file type(s) added`);
111
+ return { written: true, fileTypes: MERGIRAF_FILE_TYPES };
112
+ }
113
+ /**
114
+ * Configure git merge driver for mergiraf via `git config`.
115
+ * In worktree-only mode, uses `--worktree` flag for worktree-local config.
116
+ */
117
+ export function configureMergeDriver(targetPath, config) {
118
+ const scope = config.worktreeOnly ? ' --worktree' : '';
119
+ const label = config.worktreeOnly ? 'worktree-local config' : '.git/config';
120
+ if (config.dryRun) {
121
+ console.log('[DRY RUN] Would configure git merge driver:');
122
+ console.log(` git config${scope} merge.mergiraf.name "mergiraf"`);
123
+ console.log(` git config${scope} merge.mergiraf.driver "mergiraf merge --git %O %A %B -s %S -x %X -y %Y -p %P"`);
124
+ return false;
125
+ }
126
+ try {
127
+ // Enable worktree config extension if using worktree-only mode
128
+ if (config.worktreeOnly) {
129
+ execSync('git config extensions.worktreeConfig true', {
130
+ stdio: 'pipe',
131
+ encoding: 'utf-8',
132
+ cwd: targetPath,
133
+ });
134
+ }
135
+ execSync(`git config${scope} merge.mergiraf.name "mergiraf"`, {
136
+ stdio: 'pipe',
137
+ encoding: 'utf-8',
138
+ cwd: targetPath,
139
+ });
140
+ execSync(`git config${scope} merge.mergiraf.driver "mergiraf merge --git %O %A %B -s %S -x %X -y %Y -p %P"`, { stdio: 'pipe', encoding: 'utf-8', cwd: targetPath });
141
+ console.log(` Merge driver configured in ${label}`);
142
+ return true;
143
+ }
144
+ catch (error) {
145
+ console.error(` Failed to configure merge driver: ${error instanceof Error ? error.message : String(error)}`);
146
+ return false;
147
+ }
148
+ }
149
+ /**
150
+ * Update .agentfactory/config.yaml with mergeDriver: mergiraf.
151
+ */
152
+ export function updateRepoConfig(gitRoot, config) {
153
+ const configDir = resolve(gitRoot, '.agentfactory');
154
+ const configPath = resolve(configDir, 'config.yaml');
155
+ if (config.dryRun) {
156
+ console.log('[DRY RUN] Would set mergeDriver: mergiraf in .agentfactory/config.yaml');
157
+ return false;
158
+ }
159
+ if (!existsSync(configPath)) {
160
+ // Config file doesn't exist — skip (don't create one from scratch)
161
+ console.log(' .agentfactory/config.yaml not found — skipping repo config update');
162
+ return false;
163
+ }
164
+ try {
165
+ let content = readFileSync(configPath, 'utf-8');
166
+ if (content.includes('mergeDriver: mergiraf')) {
167
+ console.log(' .agentfactory/config.yaml already has mergeDriver: mergiraf');
168
+ return true;
169
+ }
170
+ if (content.includes('mergeDriver:')) {
171
+ // Replace existing mergeDriver value
172
+ content = content.replace(/mergeDriver:\s*\S+/, 'mergeDriver: mergiraf');
173
+ }
174
+ else {
175
+ // Append mergeDriver setting
176
+ content = content.trimEnd() + '\nmergeDriver: mergiraf\n';
177
+ }
178
+ writeFileSync(configPath, content, 'utf-8');
179
+ console.log(' .agentfactory/config.yaml updated: mergeDriver: mergiraf');
180
+ return true;
181
+ }
182
+ catch (error) {
183
+ console.error(` Failed to update repo config: ${error instanceof Error ? error.message : String(error)}`);
184
+ return false;
185
+ }
186
+ }
187
+ // ---------------------------------------------------------------------------
188
+ // Runner
189
+ // ---------------------------------------------------------------------------
190
+ export function setupMergiraf(config) {
191
+ const gitRoot = config?.gitRoot ?? getGitRoot();
192
+ const isWorktreeMode = config?.worktreeOnly ?? false;
193
+ // In worktree-only mode, use the worktree path for .gitattributes and git config
194
+ const targetPath = isWorktreeMode && config?.worktreePath
195
+ ? config.worktreePath
196
+ : gitRoot;
197
+ const result = {
198
+ mergirafFound: false,
199
+ mergirafVersion: '',
200
+ configuredFileTypes: [],
201
+ gitattributesWritten: false,
202
+ mergeDriverConfigured: false,
203
+ worktreeMode: isWorktreeMode,
204
+ repoConfigUpdated: false,
205
+ errors: [],
206
+ exitCode: 0,
207
+ };
208
+ // Step 1: Detect mergiraf binary
209
+ if (!config?.skipCheck) {
210
+ const detection = detectMergiraf();
211
+ result.mergirafFound = detection.found;
212
+ result.mergirafVersion = detection.version;
213
+ if (!detection.found) {
214
+ result.errors.push('mergiraf binary not found on PATH. Install with: brew install mergiraf (macOS) or cargo install mergiraf');
215
+ result.exitCode = 2;
216
+ return result;
217
+ }
218
+ }
219
+ else {
220
+ result.mergirafFound = true;
221
+ result.mergirafVersion = '(check skipped)';
222
+ }
223
+ if (config?.dryRun) {
224
+ console.log('[DRY RUN] Would configure mergiraf in:', targetPath);
225
+ console.log('[DRY RUN] Worktree-only mode:', isWorktreeMode);
226
+ return result;
227
+ }
228
+ // Step 2: Configure .gitattributes (in worktree root or repo root)
229
+ const gitattributes = configureGitattributes(targetPath, config ?? {});
230
+ result.gitattributesWritten = gitattributes.written;
231
+ result.configuredFileTypes = gitattributes.fileTypes;
232
+ // Step 3: Configure git merge driver (worktree-local or repo-wide)
233
+ result.mergeDriverConfigured = configureMergeDriver(targetPath, config ?? {});
234
+ // Step 4: Update repo config (always in git root, not worktree)
235
+ if (!isWorktreeMode) {
236
+ result.repoConfigUpdated = updateRepoConfig(gitRoot, config ?? {});
237
+ }
238
+ return result;
239
+ }
@@ -37,7 +37,7 @@
37
37
  import path from 'path';
38
38
  import { config } from 'dotenv';
39
39
  // Load environment variables from .env.local
40
- config({ path: path.resolve(process.cwd(), '.env.local') });
40
+ config({ path: path.resolve(process.cwd(), '.env.local'), quiet: true });
41
41
  import { runLinear, parseLinearArgs } from './lib/linear-runner.js';
42
42
  function printHelp() {
43
43
  console.log(`
@@ -20,7 +20,7 @@
20
20
  import path from 'path';
21
21
  import { config } from 'dotenv';
22
22
  // Load environment variables from .env.local
23
- config({ path: path.resolve(process.cwd(), '.env.local') });
23
+ config({ path: path.resolve(process.cwd(), '.env.local'), quiet: true });
24
24
  import { runOrchestrator } from './lib/orchestrator-runner.js';
25
25
  import { getVersion, checkForUpdate, printUpdateNotification } from './lib/version.js';
26
26
  function parseArgs() {
@@ -24,7 +24,7 @@
24
24
  import path from 'path';
25
25
  import { config } from 'dotenv';
26
26
  // Load environment variables from .env.local in CWD
27
- config({ path: path.resolve(process.cwd(), '.env.local') });
27
+ config({ path: path.resolve(process.cwd(), '.env.local'), quiet: true });
28
28
  import { runQueueAdmin, C } from './lib/queue-admin-runner.js';
29
29
  // ---------------------------------------------------------------------------
30
30
  // Usage
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AgentFactory Setup CLI
4
+ *
5
+ * Configure development tools for agent workflows.
6
+ *
7
+ * Usage:
8
+ * af-setup <tool> [options]
9
+ * agentfactory setup <tool> [options]
10
+ *
11
+ * Tools:
12
+ * mergiraf Configure mergiraf AST-aware merge driver
13
+ *
14
+ * Options:
15
+ * --dry-run Show what would be done without making changes
16
+ * --worktree-only Only configure for agent worktrees
17
+ * --skip-check Skip mergiraf binary availability check
18
+ * --help, -h Show this help message
19
+ */
20
+ export {};
21
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/setup.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;GAiBG"}
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AgentFactory Setup CLI
4
+ *
5
+ * Configure development tools for agent workflows.
6
+ *
7
+ * Usage:
8
+ * af-setup <tool> [options]
9
+ * agentfactory setup <tool> [options]
10
+ *
11
+ * Tools:
12
+ * mergiraf Configure mergiraf AST-aware merge driver
13
+ *
14
+ * Options:
15
+ * --dry-run Show what would be done without making changes
16
+ * --worktree-only Only configure for agent worktrees
17
+ * --skip-check Skip mergiraf binary availability check
18
+ * --help, -h Show this help message
19
+ */
20
+ import { setupMergiraf, getGitRoot } from './lib/setup-mergiraf-runner.js';
21
+ function parseArgs() {
22
+ const args = process.argv.slice(2);
23
+ const result = {
24
+ subcommand: undefined,
25
+ dryRun: false,
26
+ worktreeOnly: false,
27
+ skipCheck: false,
28
+ };
29
+ for (let i = 0; i < args.length; i++) {
30
+ const arg = args[i];
31
+ switch (arg) {
32
+ case '--dry-run':
33
+ result.dryRun = true;
34
+ break;
35
+ case '--worktree-only':
36
+ result.worktreeOnly = true;
37
+ break;
38
+ case '--skip-check':
39
+ result.skipCheck = true;
40
+ break;
41
+ case '--help':
42
+ case '-h':
43
+ printHelp();
44
+ process.exit(0);
45
+ break;
46
+ default:
47
+ // First non-flag argument is the subcommand (skip 'setup' if present)
48
+ if (!arg.startsWith('-') && arg !== 'setup') {
49
+ result.subcommand = arg;
50
+ }
51
+ break;
52
+ }
53
+ }
54
+ return result;
55
+ }
56
+ function printHelp() {
57
+ console.log(`
58
+ AgentFactory Setup - Configure development tools for agent workflows
59
+
60
+ Usage:
61
+ af-setup <tool> [options]
62
+ agentfactory setup <tool> [options]
63
+
64
+ Tools:
65
+ mergiraf Configure mergiraf AST-aware merge driver
66
+
67
+ Options:
68
+ --dry-run Show what would be done without making changes
69
+ --worktree-only Only configure for agent worktrees (not whole repo)
70
+ --skip-check Skip mergiraf binary availability check
71
+ --help, -h Show this help message
72
+
73
+ Examples:
74
+ # Configure mergiraf for the entire repository
75
+ af-setup mergiraf
76
+
77
+ # Configure only for agent worktrees (recommended)
78
+ af-setup mergiraf --worktree-only
79
+
80
+ # Preview changes without modifying anything
81
+ af-setup mergiraf --dry-run
82
+ `);
83
+ }
84
+ function printSummary(result) {
85
+ console.log('=== Summary ===\n');
86
+ if (result.mergirafFound) {
87
+ console.log(` Mergiraf: found (${result.mergirafVersion})`);
88
+ }
89
+ else {
90
+ console.log(' Mergiraf: NOT FOUND');
91
+ }
92
+ if (result.configuredFileTypes.length > 0) {
93
+ console.log(` File types: ${result.configuredFileTypes.join(', ')}`);
94
+ }
95
+ console.log(` .gitattributes: ${result.gitattributesWritten ? 'configured' : 'not configured'}`);
96
+ console.log(` Merge driver: ${result.mergeDriverConfigured ? 'configured' : 'not configured'}`);
97
+ console.log(` Worktree mode: ${result.worktreeMode ? 'yes' : 'no (repo-wide)'}`);
98
+ console.log(` Repo config: ${result.repoConfigUpdated ? 'updated' : 'not updated'}`);
99
+ if (result.errors.length > 0) {
100
+ console.log('\n Errors:');
101
+ for (const err of result.errors) {
102
+ console.log(` - ${err}`);
103
+ }
104
+ }
105
+ if (result.gitattributesWritten && result.mergeDriverConfigured) {
106
+ console.log('\n See: https://github.com/RenseiAI/agentfactory/blob/main/docs/guides/mergiraf-setup.md');
107
+ }
108
+ console.log('');
109
+ }
110
+ // Main execution
111
+ function main() {
112
+ const args = parseArgs();
113
+ if (!args.subcommand) {
114
+ console.error('Error: No tool specified.\n');
115
+ printHelp();
116
+ process.exit(1);
117
+ }
118
+ switch (args.subcommand) {
119
+ case 'mergiraf': {
120
+ console.log('\n=== AgentFactory Setup: Mergiraf ===\n');
121
+ if (args.dryRun) {
122
+ console.log('[DRY RUN MODE - No changes will be made]\n');
123
+ }
124
+ const result = setupMergiraf({
125
+ dryRun: args.dryRun,
126
+ worktreeOnly: args.worktreeOnly,
127
+ skipCheck: args.skipCheck,
128
+ gitRoot: getGitRoot(),
129
+ });
130
+ printSummary(result);
131
+ if (result.errors.length > 0) {
132
+ process.exit(result.exitCode || 1);
133
+ }
134
+ break;
135
+ }
136
+ default:
137
+ console.error(`Unknown tool: ${args.subcommand}\n`);
138
+ printHelp();
139
+ process.exit(1);
140
+ }
141
+ }
142
+ main();
@@ -17,7 +17,7 @@
17
17
  import path from 'path';
18
18
  import { config } from 'dotenv';
19
19
  // Load environment variables from .env.local in CWD
20
- config({ path: path.resolve(process.cwd(), '.env.local') });
20
+ config({ path: path.resolve(process.cwd(), '.env.local'), quiet: true });
21
21
  import { runStatus, C } from './lib/status-runner.js';
22
22
  // ---------------------------------------------------------------------------
23
23
  // Usage
@@ -25,7 +25,7 @@ import path from 'path';
25
25
  import os from 'os';
26
26
  import { config as loadEnv } from 'dotenv';
27
27
  // Load environment variables from .env.local in CWD
28
- loadEnv({ path: path.resolve(process.cwd(), '.env.local') });
28
+ loadEnv({ path: path.resolve(process.cwd(), '.env.local'), quiet: true });
29
29
  import { runWorkerFleet } from './lib/worker-fleet-runner.js';
30
30
  // ANSI colors (kept for help output)
31
31
  const colors = {
@@ -25,7 +25,7 @@
25
25
  import path from 'path';
26
26
  import { config } from 'dotenv';
27
27
  // Load environment variables from .env.local in CWD
28
- config({ path: path.resolve(process.cwd(), '.env.local') });
28
+ config({ path: path.resolve(process.cwd(), '.env.local'), quiet: true });
29
29
  import os from 'os';
30
30
  import { runWorker } from './lib/worker-runner.js';
31
31
  function parseArgs() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@renseiai/agentfactory-cli",
3
- "version": "0.8.10",
3
+ "version": "0.8.11",
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)",
@@ -38,6 +38,7 @@
38
38
  "af-linear": "dist/src/linear.js",
39
39
  "af-governor": "dist/src/governor.js",
40
40
  "af-sync-routes": "dist/src/sync-routes.js",
41
+ "af-setup": "dist/src/setup.js",
41
42
  "af-status": "dist/src/status.js",
42
43
  "af-migrate-worktrees": "dist/src/migrate-worktrees.js"
43
44
  },
@@ -95,6 +96,11 @@
95
96
  "import": "./dist/src/lib/sync-routes-runner.js",
96
97
  "default": "./dist/src/lib/sync-routes-runner.js"
97
98
  },
99
+ "./setup": {
100
+ "types": "./dist/src/lib/setup-mergiraf-runner.d.ts",
101
+ "import": "./dist/src/lib/setup-mergiraf-runner.js",
102
+ "default": "./dist/src/lib/setup-mergiraf-runner.js"
103
+ },
98
104
  "./status": {
99
105
  "types": "./dist/src/lib/status-runner.d.ts",
100
106
  "import": "./dist/src/lib/status-runner.js",
@@ -108,10 +114,10 @@
108
114
  ],
109
115
  "dependencies": {
110
116
  "dotenv": "^17.2.3",
111
- "@renseiai/agentfactory": "0.8.10",
112
- "@renseiai/agentfactory-code-intelligence": "0.8.10",
113
- "@renseiai/plugin-linear": "0.8.10",
114
- "@renseiai/agentfactory-server": "0.8.10"
117
+ "@renseiai/agentfactory-server": "0.8.11",
118
+ "@renseiai/agentfactory-code-intelligence": "0.8.11",
119
+ "@renseiai/plugin-linear": "0.8.11",
120
+ "@renseiai/agentfactory": "0.8.11"
115
121
  },
116
122
  "devDependencies": {
117
123
  "@types/node": "^22.5.4",