agent-rev 0.1.0 → 0.1.1
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/utils/config.js +25 -1
- package/package.json +1 -1
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
|
+
function getAgentHome() {
|
|
6
|
+
const known = ['agent-mp', 'agent-orch', 'agent-impl', 'agent-rev', 'agent-explorer'];
|
|
7
|
+
const binName = path.basename(process.argv[1]).replace(/\.(js|ts|mjs)$/, '');
|
|
8
|
+
if (known.includes(binName)) {
|
|
9
|
+
return path.join(os.homedir(), `.${binName}`);
|
|
10
|
+
}
|
|
11
|
+
// dev mode (tsx src/index.ts) — read name from package.json
|
|
12
|
+
const __filename = new URL(import.meta.url).pathname;
|
|
13
|
+
const __dirname = path.dirname(__filename);
|
|
14
|
+
for (const p of [
|
|
15
|
+
path.join(__dirname, '..', '..', 'package.json'),
|
|
16
|
+
path.join(__dirname, '..', 'package.json'),
|
|
17
|
+
]) {
|
|
18
|
+
try {
|
|
19
|
+
const pkg = JSON.parse(fsSync.readFileSync(p, 'utf-8'));
|
|
20
|
+
if (pkg.name && known.includes(pkg.name)) {
|
|
21
|
+
return path.join(os.homedir(), `.${pkg.name}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch { }
|
|
25
|
+
}
|
|
26
|
+
return path.join(os.homedir(), '.agent-mp');
|
|
27
|
+
}
|
|
28
|
+
export const AGENT_HOME = getAgentHome();
|
|
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() {
|