agent-lyceum 0.40.0 → 0.41.0
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/config.js +6 -6
- package/dist/paths.d.ts +4 -0
- package/dist/paths.js +14 -0
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import YAML from "yaml";
|
|
4
|
-
import {
|
|
4
|
+
import { canonicalPath, escapesParent, expandHome, configPath, homePaths, projectPaths, } from "./paths.js";
|
|
5
5
|
import { availableTiers } from "./tiers.js";
|
|
6
6
|
import { DISPATCHER_DEFAULTS, GlobalConfig, REMOVED_AGENT_KEYS, REMOVED_DISPATCHER_KEYS, ProjectConfig, VERIFY_DEFAULTS, inferRuntime, RUNTIMES, } from "./schema.js";
|
|
7
7
|
export class ConfigError extends Error {
|
|
@@ -41,13 +41,13 @@ function resolveLayer(p, base) {
|
|
|
41
41
|
return {};
|
|
42
42
|
const out = { ...p };
|
|
43
43
|
if (p.agent_md)
|
|
44
|
-
out.agent_md =
|
|
44
|
+
out.agent_md = configPath(p.agent_md, base);
|
|
45
45
|
if (p.memory) {
|
|
46
46
|
out.memory = {};
|
|
47
47
|
if (p.memory.global)
|
|
48
|
-
out.memory.global =
|
|
48
|
+
out.memory.global = configPath(p.memory.global, base);
|
|
49
49
|
if (p.memory.project)
|
|
50
|
-
out.memory.project =
|
|
50
|
+
out.memory.project = configPath(p.memory.project, base);
|
|
51
51
|
}
|
|
52
52
|
return out;
|
|
53
53
|
}
|
|
@@ -201,7 +201,7 @@ export function resolveProjectFrom(home, name, g, p) {
|
|
|
201
201
|
return {
|
|
202
202
|
home,
|
|
203
203
|
name,
|
|
204
|
-
dir:
|
|
204
|
+
dir: configPath(p.dir, paths.root),
|
|
205
205
|
lead,
|
|
206
206
|
dispatcher,
|
|
207
207
|
agents,
|
|
@@ -263,7 +263,7 @@ export function listProjects(home) {
|
|
|
263
263
|
continue;
|
|
264
264
|
try {
|
|
265
265
|
const raw = loadProjectRaw(home, entry.name);
|
|
266
|
-
out.push({ name: entry.name, dir:
|
|
266
|
+
out.push({ name: entry.name, dir: configPath(raw.dir, projectPaths(home, entry.name).root) });
|
|
267
267
|
}
|
|
268
268
|
catch {
|
|
269
269
|
/* ignore broken project */
|
package/dist/paths.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ export declare const NAME_RE: RegExp;
|
|
|
2
2
|
export declare function expandHome(p: string): string;
|
|
3
3
|
/** Resolve a path from a config file: expand `~`, then resolve relative to `base`. */
|
|
4
4
|
export declare function absPath(p: string, base: string): string;
|
|
5
|
+
/** Expand `$VAR` / `${VAR}` from the environment. An unset variable is an error, never an empty string (that would turn `$ROOT/x` into `/x`). */
|
|
6
|
+
export declare function expandEnv(p: string, env?: NodeJS.ProcessEnv): string;
|
|
7
|
+
/** Like absPath, for paths written in config files: `$VAR` / `${VAR}` and `~` are expanded, so one synced config works on machines with different layouts. */
|
|
8
|
+
export declare function configPath(p: string, base: string, env?: NodeJS.ProcessEnv): string;
|
|
5
9
|
export declare function resolveHome(opt?: string): string;
|
|
6
10
|
export declare function assertName(kind: string, name: string): void;
|
|
7
11
|
export interface HomePaths {
|
package/dist/paths.js
CHANGED
|
@@ -13,6 +13,20 @@ export function expandHome(p) {
|
|
|
13
13
|
export function absPath(p, base) {
|
|
14
14
|
return path.resolve(base, expandHome(p));
|
|
15
15
|
}
|
|
16
|
+
/** Expand `$VAR` / `${VAR}` from the environment. An unset variable is an error, never an empty string (that would turn `$ROOT/x` into `/x`). */
|
|
17
|
+
export function expandEnv(p, env = process.env) {
|
|
18
|
+
return p.replace(/\$(?:\{([A-Za-z_][A-Za-z0-9_]*)\}|([A-Za-z_][A-Za-z0-9_]*))/g, (_m, a, b) => {
|
|
19
|
+
const name = (a ?? b);
|
|
20
|
+
const v = env[name];
|
|
21
|
+
if (v === undefined || v === "")
|
|
22
|
+
throw new Error(`Environment variable ${name} is not set (used in path "${p}").`);
|
|
23
|
+
return v;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** Like absPath, for paths written in config files: `$VAR` / `${VAR}` and `~` are expanded, so one synced config works on machines with different layouts. */
|
|
27
|
+
export function configPath(p, base, env = process.env) {
|
|
28
|
+
return absPath(expandEnv(p, env), base);
|
|
29
|
+
}
|
|
16
30
|
export function resolveHome(opt) {
|
|
17
31
|
const raw = opt ?? process.env.AGENT_LYCEUM_HOME ?? path.join(os.homedir(), "agent-lyceum-config");
|
|
18
32
|
return path.resolve(expandHome(raw));
|