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 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 binName = path.basename(process.argv[1]).replace(/\.(js|ts|mjs)$/, '');
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: ${binName} "<task description or task-id>"`));
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);
@@ -1,4 +1,5 @@
1
1
  import { AgentConfig } from '../types.js';
2
+ export declare const PKG_NAME: string;
2
3
  export declare const AGENT_HOME: string;
3
4
  export declare const AUTH_FILE: string;
4
5
  export declare const CONFIG_FILE: string;
@@ -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
- export const AGENT_HOME = path.join(os.homedir(), '.agent-cli');
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() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-rev",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Reviewer agent — validates and reviews implementation against the plan",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",