agent-rev 0.1.0 → 0.1.2
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/index.js +3 -4
- package/dist/utils/config.d.ts +1 -0
- package/dist/utils/config.js +25 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import * as os from 'os';
|
|
|
5
5
|
import * as fs from 'fs/promises';
|
|
6
6
|
import * as readline from 'readline';
|
|
7
7
|
import chalk from 'chalk';
|
|
8
|
-
import { AGENT_HOME } from './utils/config.js';
|
|
8
|
+
import { AGENT_HOME, PKG_NAME } from './utils/config.js';
|
|
9
9
|
import { runRepl, runRole } from './commands/repl.js';
|
|
10
10
|
import { setupCommand } from './commands/setup.js';
|
|
11
11
|
import { getLastSessionForDir, listSessions, loadSession } from './utils/sessions.js';
|
|
@@ -64,13 +64,12 @@ const ROLE_BINS = {
|
|
|
64
64
|
'agent-rev': 'reviewer',
|
|
65
65
|
'agent-explorer': 'explorer',
|
|
66
66
|
};
|
|
67
|
-
const
|
|
68
|
-
const nativeRole = ROLE_BINS[binName];
|
|
67
|
+
const nativeRole = ROLE_BINS[PKG_NAME];
|
|
69
68
|
if (nativeRole) {
|
|
70
69
|
// Role-specific CLI: accept task as positional arg or prompt for it
|
|
71
70
|
const taskArg = process.argv.slice(2).filter(a => !a.startsWith('-')).join(' ').trim();
|
|
72
71
|
if (!taskArg) {
|
|
73
|
-
console.error(chalk.red(` Usage: ${
|
|
72
|
+
console.error(chalk.red(` Usage: ${PKG_NAME} "<task description or task-id>"`));
|
|
74
73
|
process.exit(1);
|
|
75
74
|
}
|
|
76
75
|
await runRole(nativeRole, taskArg);
|
package/dist/utils/config.d.ts
CHANGED
package/dist/utils/config.js
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
import { promises as fs } from 'fs';
|
|
2
|
+
import * as fsSync from 'fs';
|
|
2
3
|
import * as path from 'path';
|
|
3
4
|
import * as os from 'os';
|
|
4
|
-
|
|
5
|
+
const KNOWN_PKGS = ['agent-mp', 'agent-orch', 'agent-impl', 'agent-rev', 'agent-explorer'];
|
|
6
|
+
function resolvePackageName() {
|
|
7
|
+
// 1. Read package.json (reliable for both global installs and dev mode)
|
|
8
|
+
const __filename = new URL(import.meta.url).pathname;
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
for (const p of [
|
|
11
|
+
path.join(__dirname, '..', '..', 'package.json'),
|
|
12
|
+
path.join(__dirname, '..', 'package.json'),
|
|
13
|
+
]) {
|
|
14
|
+
try {
|
|
15
|
+
const pkg = JSON.parse(fsSync.readFileSync(p, 'utf-8'));
|
|
16
|
+
if (pkg.name && KNOWN_PKGS.includes(pkg.name))
|
|
17
|
+
return pkg.name;
|
|
18
|
+
}
|
|
19
|
+
catch { }
|
|
20
|
+
}
|
|
21
|
+
// 2. Fallback: binary name (e.g. running from a symlink in PATH)
|
|
22
|
+
const bin = path.basename(process.argv[1]).replace(/\.(js|ts|mjs)$/, '');
|
|
23
|
+
if (KNOWN_PKGS.includes(bin))
|
|
24
|
+
return bin;
|
|
25
|
+
return 'agent-mp';
|
|
26
|
+
}
|
|
27
|
+
export const PKG_NAME = resolvePackageName();
|
|
28
|
+
export const AGENT_HOME = path.join(os.homedir(), `.${PKG_NAME}`);
|
|
5
29
|
export const AUTH_FILE = path.join(AGENT_HOME, 'auth.json');
|
|
6
30
|
export const CONFIG_FILE = path.join(AGENT_HOME, 'config.json');
|
|
7
31
|
export async function loadAuth() {
|