@renseiai/agentfactory-cli 0.8.29 → 0.8.31
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/add-dep.d.ts +17 -0
- package/dist/src/add-dep.d.ts.map +1 -0
- package/dist/src/add-dep.js +74 -0
- package/dist/src/index.js +3 -0
- package/dist/src/lib/add-dep-runner.d.ts +15 -0
- package/dist/src/lib/add-dep-runner.d.ts.map +1 -0
- package/dist/src/lib/add-dep-runner.js +155 -0
- package/package.json +6 -5
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* AgentFactory Add-Dep CLI
|
|
4
|
+
*
|
|
5
|
+
* Safely adds dependencies in agent worktrees by cleaning symlinked
|
|
6
|
+
* node_modules and running the correct package manager add command
|
|
7
|
+
* with the preinstall guard bypass.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* af-add-dep <package> [<package>...] [--filter <workspace>]
|
|
11
|
+
*
|
|
12
|
+
* Options:
|
|
13
|
+
* --filter <workspace> Target a specific workspace (monorepo)
|
|
14
|
+
* --help, -h Show this help message
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=add-dep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-dep.d.ts","sourceRoot":"","sources":["../../src/add-dep.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;GAaG"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* AgentFactory Add-Dep CLI
|
|
4
|
+
*
|
|
5
|
+
* Safely adds dependencies in agent worktrees by cleaning symlinked
|
|
6
|
+
* node_modules and running the correct package manager add command
|
|
7
|
+
* with the preinstall guard bypass.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* af-add-dep <package> [<package>...] [--filter <workspace>]
|
|
11
|
+
*
|
|
12
|
+
* Options:
|
|
13
|
+
* --filter <workspace> Target a specific workspace (monorepo)
|
|
14
|
+
* --help, -h Show this help message
|
|
15
|
+
*/
|
|
16
|
+
import { runAddDep } from './lib/add-dep-runner.js';
|
|
17
|
+
function parseArgs() {
|
|
18
|
+
const args = process.argv.slice(2);
|
|
19
|
+
const packages = [];
|
|
20
|
+
let filter;
|
|
21
|
+
for (let i = 0; i < args.length; i++) {
|
|
22
|
+
const arg = args[i];
|
|
23
|
+
switch (arg) {
|
|
24
|
+
case '--filter':
|
|
25
|
+
filter = args[++i];
|
|
26
|
+
break;
|
|
27
|
+
case '--help':
|
|
28
|
+
case '-h':
|
|
29
|
+
printHelp();
|
|
30
|
+
process.exit(0);
|
|
31
|
+
break;
|
|
32
|
+
default:
|
|
33
|
+
if (!arg.startsWith('-')) {
|
|
34
|
+
packages.push(arg);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return { packages, filter };
|
|
39
|
+
}
|
|
40
|
+
function printHelp() {
|
|
41
|
+
console.log(`
|
|
42
|
+
AgentFactory Add-Dep - Safely add dependencies in worktrees
|
|
43
|
+
|
|
44
|
+
Usage:
|
|
45
|
+
af-add-dep <package> [<package>...] [options]
|
|
46
|
+
|
|
47
|
+
Options:
|
|
48
|
+
--filter <workspace> Target a specific workspace (monorepo)
|
|
49
|
+
--help, -h Show this help message
|
|
50
|
+
|
|
51
|
+
The package manager is auto-detected from .agentfactory/config.yaml.
|
|
52
|
+
|
|
53
|
+
In worktrees, symlinked node_modules are cleaned before running the
|
|
54
|
+
add command. The ORCHESTRATOR_INSTALL=1 env var is set to bypass
|
|
55
|
+
preinstall guard scripts.
|
|
56
|
+
|
|
57
|
+
Examples:
|
|
58
|
+
af-add-dep lodash
|
|
59
|
+
af-add-dep zod vitest --filter @myorg/api
|
|
60
|
+
`);
|
|
61
|
+
}
|
|
62
|
+
function main() {
|
|
63
|
+
const { packages, filter } = parseArgs();
|
|
64
|
+
if (packages.length === 0) {
|
|
65
|
+
printHelp();
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
runAddDep({
|
|
69
|
+
packages,
|
|
70
|
+
filter,
|
|
71
|
+
cwd: process.cwd(),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
main();
|
package/dist/src/index.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add-dep runner — safely adds dependencies in agent worktrees.
|
|
3
|
+
*
|
|
4
|
+
* Detects worktree vs main repo, resolves the package manager from
|
|
5
|
+
* .agentfactory/config.yaml, cleans symlinked node_modules, and runs
|
|
6
|
+
* the correct add command with ORCHESTRATOR_INSTALL=1 to bypass
|
|
7
|
+
* preinstall guards.
|
|
8
|
+
*/
|
|
9
|
+
export interface AddDepOptions {
|
|
10
|
+
packages: string[];
|
|
11
|
+
filter?: string;
|
|
12
|
+
cwd: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function runAddDep(options: AddDepOptions): void;
|
|
15
|
+
//# sourceMappingURL=add-dep-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-dep-runner.d.ts","sourceRoot":"","sources":["../../../src/lib/add-dep-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;CACZ;AAmFD,wBAAgB,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAqEtD"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add-dep runner — safely adds dependencies in agent worktrees.
|
|
3
|
+
*
|
|
4
|
+
* Detects worktree vs main repo, resolves the package manager from
|
|
5
|
+
* .agentfactory/config.yaml, cleans symlinked node_modules, and runs
|
|
6
|
+
* the correct add command with ORCHESTRATOR_INSTALL=1 to bypass
|
|
7
|
+
* preinstall guards.
|
|
8
|
+
*/
|
|
9
|
+
import { execSync } from 'node:child_process';
|
|
10
|
+
import { existsSync, readFileSync, readdirSync, rmSync, statSync } from 'node:fs';
|
|
11
|
+
import { resolve } from 'node:path';
|
|
12
|
+
import { getAddCommand, } from '@renseiai/agentfactory';
|
|
13
|
+
import { loadRepositoryConfig } from '@renseiai/agentfactory';
|
|
14
|
+
/** Detect if we're inside a git worktree (not the main repo). */
|
|
15
|
+
function isWorktree(cwd) {
|
|
16
|
+
const gitPath = resolve(cwd, '.git');
|
|
17
|
+
if (!existsSync(gitPath))
|
|
18
|
+
return false;
|
|
19
|
+
try {
|
|
20
|
+
const stat = statSync(gitPath);
|
|
21
|
+
// Worktrees have a .git *file* pointing to the main repo's .git/worktrees/<name>
|
|
22
|
+
return stat.isFile();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Resolve the git root (works for both worktrees and main repos). */
|
|
29
|
+
function findGitRoot(cwd) {
|
|
30
|
+
try {
|
|
31
|
+
return execSync('git rev-parse --show-toplevel', {
|
|
32
|
+
cwd,
|
|
33
|
+
encoding: 'utf-8',
|
|
34
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
35
|
+
}).trim();
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return cwd;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Resolve the main repo root from a worktree .git file. */
|
|
42
|
+
function resolveMainRepo(cwd) {
|
|
43
|
+
const gitPath = resolve(cwd, '.git');
|
|
44
|
+
try {
|
|
45
|
+
const content = readFileSync(gitPath, 'utf-8').trim();
|
|
46
|
+
// Format: "gitdir: /path/to/main/.git/worktrees/<name>"
|
|
47
|
+
const match = content.match(/^gitdir:\s*(.+)$/);
|
|
48
|
+
if (!match)
|
|
49
|
+
return null;
|
|
50
|
+
const gitdir = match[1];
|
|
51
|
+
// Walk up from .git/worktrees/<name> to .git, then to repo root
|
|
52
|
+
const mainGitDir = resolve(gitdir, '..', '..');
|
|
53
|
+
return resolve(mainGitDir, '..');
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** Remove symlinked node_modules from the worktree. */
|
|
60
|
+
function cleanNodeModules(worktreePath) {
|
|
61
|
+
// Root node_modules
|
|
62
|
+
const rootNm = resolve(worktreePath, 'node_modules');
|
|
63
|
+
if (existsSync(rootNm)) {
|
|
64
|
+
rmSync(rootNm, { recursive: true, force: true });
|
|
65
|
+
}
|
|
66
|
+
// Per-workspace node_modules
|
|
67
|
+
for (const subdir of ['apps', 'packages']) {
|
|
68
|
+
const dir = resolve(worktreePath, subdir);
|
|
69
|
+
if (!existsSync(dir))
|
|
70
|
+
continue;
|
|
71
|
+
try {
|
|
72
|
+
for (const entry of readdirSync(dir)) {
|
|
73
|
+
const nm = resolve(dir, entry, 'node_modules');
|
|
74
|
+
if (existsSync(nm)) {
|
|
75
|
+
rmSync(nm, { recursive: true, force: true });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// Skip unreadable directories
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** Resolve the package manager from repo config or default to 'pnpm'. */
|
|
85
|
+
function resolvePackageManager(repoRoot) {
|
|
86
|
+
try {
|
|
87
|
+
const config = loadRepositoryConfig(repoRoot);
|
|
88
|
+
if (config?.packageManager) {
|
|
89
|
+
return config.packageManager;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// Config not found or invalid — fall through to default
|
|
94
|
+
}
|
|
95
|
+
return 'pnpm';
|
|
96
|
+
}
|
|
97
|
+
export function runAddDep(options) {
|
|
98
|
+
const { packages, filter, cwd } = options;
|
|
99
|
+
if (packages.length === 0) {
|
|
100
|
+
console.error('Error: No packages specified');
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
const gitRoot = findGitRoot(cwd);
|
|
104
|
+
const inWorktree = isWorktree(cwd);
|
|
105
|
+
// Resolve package manager from the main repo's config
|
|
106
|
+
const configRoot = inWorktree ? (resolveMainRepo(cwd) ?? gitRoot) : gitRoot;
|
|
107
|
+
const pm = resolvePackageManager(configRoot);
|
|
108
|
+
if (pm === 'none') {
|
|
109
|
+
console.error('Error: packageManager is "none" — cannot add dependencies');
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
const addCmd = getAddCommand(pm);
|
|
113
|
+
if (!addCmd) {
|
|
114
|
+
console.error(`Error: No add command for package manager "${pm}"`);
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
// Build the full command
|
|
118
|
+
let cmd = `${addCmd} ${packages.join(' ')}`;
|
|
119
|
+
if (filter) {
|
|
120
|
+
// Package manager specific workspace filter
|
|
121
|
+
switch (pm) {
|
|
122
|
+
case 'pnpm':
|
|
123
|
+
cmd += ` --filter ${filter}`;
|
|
124
|
+
break;
|
|
125
|
+
case 'yarn':
|
|
126
|
+
cmd += ` --workspace ${filter}`;
|
|
127
|
+
break;
|
|
128
|
+
case 'npm':
|
|
129
|
+
cmd += ` --workspace=${filter}`;
|
|
130
|
+
break;
|
|
131
|
+
case 'bun':
|
|
132
|
+
cmd += ` --filter ${filter}`;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// If in a worktree, clean symlinked node_modules first
|
|
137
|
+
if (inWorktree) {
|
|
138
|
+
console.log('Detected worktree — cleaning symlinked node_modules...');
|
|
139
|
+
cleanNodeModules(cwd);
|
|
140
|
+
}
|
|
141
|
+
console.log(`Running: ${cmd}`);
|
|
142
|
+
try {
|
|
143
|
+
execSync(cmd, {
|
|
144
|
+
cwd,
|
|
145
|
+
stdio: 'inherit',
|
|
146
|
+
timeout: 120_000,
|
|
147
|
+
env: { ...process.env, ORCHESTRATOR_INSTALL: '1' },
|
|
148
|
+
});
|
|
149
|
+
console.log('Dependencies added successfully');
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
console.error('Failed to add dependencies:', error instanceof Error ? error.message : String(error));
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
155
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@renseiai/agentfactory-cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.31",
|
|
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)",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"af-worker": "dist/src/worker.js",
|
|
34
34
|
"af-worker-fleet": "dist/src/worker-fleet.js",
|
|
35
35
|
"af-cleanup": "dist/src/cleanup.js",
|
|
36
|
+
"af-add-dep": "dist/src/add-dep.js",
|
|
36
37
|
"af-queue-admin": "dist/src/queue-admin.js",
|
|
37
38
|
"af-analyze-logs": "dist/src/analyze-logs.js",
|
|
38
39
|
"af-linear": "dist/src/linear.js",
|
|
@@ -126,12 +127,12 @@
|
|
|
126
127
|
],
|
|
127
128
|
"dependencies": {
|
|
128
129
|
"dotenv": "^17.2.3",
|
|
129
|
-
"@renseiai/agentfactory": "0.8.
|
|
130
|
-
"@renseiai/plugin-linear": "0.8.
|
|
131
|
-
"@renseiai/agentfactory-server": "0.8.
|
|
130
|
+
"@renseiai/agentfactory": "0.8.31",
|
|
131
|
+
"@renseiai/plugin-linear": "0.8.31",
|
|
132
|
+
"@renseiai/agentfactory-server": "0.8.31"
|
|
132
133
|
},
|
|
133
134
|
"optionalDependencies": {
|
|
134
|
-
"@renseiai/agentfactory-code-intelligence": "0.8.
|
|
135
|
+
"@renseiai/agentfactory-code-intelligence": "0.8.31"
|
|
135
136
|
},
|
|
136
137
|
"devDependencies": {
|
|
137
138
|
"@types/node": "^22.5.4",
|