@signetai/core 0.154.6 → 0.154.7
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.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +497 -363
- package/dist/workspace.d.ts +66 -0
- package/dist/workspace.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12523,6 +12523,133 @@ function resolveSignetDaemonUrl(opts = {}) {
|
|
|
12523
12523
|
const port = normalizePort(readEnv(env, "SIGNET_PORT"), fallbackPort);
|
|
12524
12524
|
return normalizeDaemonUrl(`http://${bracketIpv6Host(host)}:${port}`, "SIGNET_HOST/SIGNET_PORT");
|
|
12525
12525
|
}
|
|
12526
|
+
// src/workspace.ts
|
|
12527
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync, statSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
12528
|
+
import { homedir as homedir3 } from "node:os";
|
|
12529
|
+
import { dirname as dirname2, join as join5, resolve } from "node:path";
|
|
12530
|
+
var WORKSPACE_ENV_KEYS = ["SIGNET_PATH", "SIGNET_WORKSPACE"];
|
|
12531
|
+
var DEFAULT_AGENTS_DIRNAME = ".agents";
|
|
12532
|
+
function normalizeWorkspacePath(pathValue, home = homedir3()) {
|
|
12533
|
+
return resolve(expandHome(pathValue.trim(), home));
|
|
12534
|
+
}
|
|
12535
|
+
function readTrimmedEnv(env, name) {
|
|
12536
|
+
const value = env[name];
|
|
12537
|
+
if (typeof value !== "string")
|
|
12538
|
+
return;
|
|
12539
|
+
const trimmed = value.trim();
|
|
12540
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
12541
|
+
}
|
|
12542
|
+
function readConfigHome(env, home) {
|
|
12543
|
+
const raw = env.XDG_CONFIG_HOME;
|
|
12544
|
+
if (typeof raw !== "string")
|
|
12545
|
+
return join5(home, ".config");
|
|
12546
|
+
const trimmed = raw.trim();
|
|
12547
|
+
return trimmed.length > 0 ? normalizeWorkspacePath(trimmed, home) : join5(home, ".config");
|
|
12548
|
+
}
|
|
12549
|
+
function isExistingDirectory(path) {
|
|
12550
|
+
try {
|
|
12551
|
+
return statSync(path).isDirectory();
|
|
12552
|
+
} catch {
|
|
12553
|
+
return false;
|
|
12554
|
+
}
|
|
12555
|
+
}
|
|
12556
|
+
function isRecord4(value) {
|
|
12557
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12558
|
+
}
|
|
12559
|
+
function getWorkspaceConfigPath(env = process.env, home = homedir3()) {
|
|
12560
|
+
return join5(readConfigHome(env, home), "signet", "workspace.json");
|
|
12561
|
+
}
|
|
12562
|
+
function readConfiguredWorkspacePath(env = process.env, home = homedir3(), options = {}) {
|
|
12563
|
+
const strict = options.strict ?? false;
|
|
12564
|
+
const configPath = getWorkspaceConfigPath(env, home);
|
|
12565
|
+
if (!existsSync4(configPath))
|
|
12566
|
+
return null;
|
|
12567
|
+
let raw;
|
|
12568
|
+
try {
|
|
12569
|
+
raw = JSON.parse(readFileSync3(configPath, "utf-8"));
|
|
12570
|
+
} catch (err) {
|
|
12571
|
+
if (strict) {
|
|
12572
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
12573
|
+
throw new Error(`Invalid Signet workspace config at ${configPath}: ${detail}`);
|
|
12574
|
+
}
|
|
12575
|
+
return null;
|
|
12576
|
+
}
|
|
12577
|
+
if (!isRecord4(raw) || !("workspace" in raw)) {
|
|
12578
|
+
if (strict)
|
|
12579
|
+
throw new Error(`Invalid Signet workspace config at ${configPath}: missing workspace`);
|
|
12580
|
+
return null;
|
|
12581
|
+
}
|
|
12582
|
+
const workspace = raw.workspace;
|
|
12583
|
+
if (typeof workspace !== "string" || workspace.trim().length === 0) {
|
|
12584
|
+
if (strict)
|
|
12585
|
+
throw new Error(`Invalid Signet workspace config at ${configPath}: workspace must be a non-empty string`);
|
|
12586
|
+
return null;
|
|
12587
|
+
}
|
|
12588
|
+
return normalizeWorkspacePath(workspace, home);
|
|
12589
|
+
}
|
|
12590
|
+
function writeConfiguredWorkspacePath(pathValue, env = process.env, home = homedir3()) {
|
|
12591
|
+
const path = normalizeWorkspacePath(pathValue, home);
|
|
12592
|
+
const configPath = getWorkspaceConfigPath(env, home);
|
|
12593
|
+
const configDir = dirname2(configPath);
|
|
12594
|
+
mkdirSync2(configDir, { recursive: true });
|
|
12595
|
+
const payload = {
|
|
12596
|
+
version: 1,
|
|
12597
|
+
workspace: path,
|
|
12598
|
+
updatedAt: new Date().toISOString()
|
|
12599
|
+
};
|
|
12600
|
+
writeFileSync2(configPath, `${JSON.stringify(payload, null, 2)}
|
|
12601
|
+
`);
|
|
12602
|
+
return configPath;
|
|
12603
|
+
}
|
|
12604
|
+
function clearConfiguredWorkspacePath(env = process.env) {
|
|
12605
|
+
const configPath = getWorkspaceConfigPath(env);
|
|
12606
|
+
if (!existsSync4(configPath))
|
|
12607
|
+
return;
|
|
12608
|
+
rmSync(configPath, { force: true });
|
|
12609
|
+
}
|
|
12610
|
+
function resolveWorkspacePath(options = {}) {
|
|
12611
|
+
const env = options.env ?? process.env;
|
|
12612
|
+
const home = options.home ?? homedir3();
|
|
12613
|
+
const strict = options.strict ?? false;
|
|
12614
|
+
const requireExistingEnvPath = options.requireExistingEnvPath ?? false;
|
|
12615
|
+
const configPath = getWorkspaceConfigPath(env, home);
|
|
12616
|
+
const envPath = resolveEnvWorkspace(env, home, requireExistingEnvPath);
|
|
12617
|
+
const configValue = readConfiguredWorkspacePath(env, home, { strict: envPath ? false : strict });
|
|
12618
|
+
if (envPath) {
|
|
12619
|
+
return {
|
|
12620
|
+
path: envPath,
|
|
12621
|
+
source: "env",
|
|
12622
|
+
configPath,
|
|
12623
|
+
configuredPath: configValue
|
|
12624
|
+
};
|
|
12625
|
+
}
|
|
12626
|
+
if (configValue) {
|
|
12627
|
+
return {
|
|
12628
|
+
path: configValue,
|
|
12629
|
+
source: "config",
|
|
12630
|
+
configPath,
|
|
12631
|
+
configuredPath: configValue
|
|
12632
|
+
};
|
|
12633
|
+
}
|
|
12634
|
+
return {
|
|
12635
|
+
path: join5(home, DEFAULT_AGENTS_DIRNAME),
|
|
12636
|
+
source: "default",
|
|
12637
|
+
configPath,
|
|
12638
|
+
configuredPath: configValue
|
|
12639
|
+
};
|
|
12640
|
+
}
|
|
12641
|
+
function resolveEnvWorkspace(env, home, requireExisting) {
|
|
12642
|
+
for (const key of WORKSPACE_ENV_KEYS) {
|
|
12643
|
+
const raw = readTrimmedEnv(env, key);
|
|
12644
|
+
if (!raw)
|
|
12645
|
+
continue;
|
|
12646
|
+
const normalized = normalizeWorkspacePath(raw, home);
|
|
12647
|
+
if (!requireExisting || isExistingDirectory(normalized))
|
|
12648
|
+
return normalized;
|
|
12649
|
+
console.warn(`[signet] ${key}="${raw}" does not point to an existing workspace directory; using the default workspace resolution instead.`);
|
|
12650
|
+
}
|
|
12651
|
+
return null;
|
|
12652
|
+
}
|
|
12526
12653
|
// src/search.ts
|
|
12527
12654
|
import { createRequire as createRequire2 } from "node:module";
|
|
12528
12655
|
var native = null;
|
|
@@ -13176,14 +13303,14 @@ var SIGNET_PLUGIN_REGISTRY_DIR = ".daemon/plugins";
|
|
|
13176
13303
|
var SIGNET_PLUGIN_REGISTRY_FILE = "registry-v1.json";
|
|
13177
13304
|
var SIGNET_PLUGIN_REGISTRY_VERSION = 1;
|
|
13178
13305
|
// src/graphiq.ts
|
|
13179
|
-
import { existsSync as
|
|
13180
|
-
import { dirname as
|
|
13306
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
13307
|
+
import { dirname as dirname3, join as join6, resolve as resolve2 } from "node:path";
|
|
13181
13308
|
var SIGNET_GRAPHIQ_STATE_FILE = ".daemon/graphiq/state.json";
|
|
13182
13309
|
function getGraphiqStatePath(basePath) {
|
|
13183
|
-
return
|
|
13310
|
+
return join6(basePath, SIGNET_GRAPHIQ_STATE_FILE);
|
|
13184
13311
|
}
|
|
13185
13312
|
function getGraphiqProjectDbPath(projectPath) {
|
|
13186
|
-
return
|
|
13313
|
+
return join6(resolve2(projectPath), ".graphiq", "graphiq.db");
|
|
13187
13314
|
}
|
|
13188
13315
|
function emptyGraphiqState(now = new Date) {
|
|
13189
13316
|
return {
|
|
@@ -13196,10 +13323,10 @@ function emptyGraphiqState(now = new Date) {
|
|
|
13196
13323
|
}
|
|
13197
13324
|
function readGraphiqState(basePath) {
|
|
13198
13325
|
const path = getGraphiqStatePath(basePath);
|
|
13199
|
-
if (!
|
|
13326
|
+
if (!existsSync5(path))
|
|
13200
13327
|
return emptyGraphiqState();
|
|
13201
13328
|
try {
|
|
13202
|
-
const parsed = JSON.parse(
|
|
13329
|
+
const parsed = JSON.parse(readFileSync4(path, "utf-8"));
|
|
13203
13330
|
return parseGraphiqState(parsed);
|
|
13204
13331
|
} catch {
|
|
13205
13332
|
return emptyGraphiqState();
|
|
@@ -13207,8 +13334,8 @@ function readGraphiqState(basePath) {
|
|
|
13207
13334
|
}
|
|
13208
13335
|
function writeGraphiqState(basePath, state) {
|
|
13209
13336
|
const path = getGraphiqStatePath(basePath);
|
|
13210
|
-
|
|
13211
|
-
|
|
13337
|
+
mkdirSync3(dirname3(path), { recursive: true });
|
|
13338
|
+
writeFileSync3(path, `${JSON.stringify(state, null, 2)}
|
|
13212
13339
|
`, { mode: 384 });
|
|
13213
13340
|
}
|
|
13214
13341
|
function setGraphiqActiveProject(basePath, activeProject) {
|
|
@@ -13219,7 +13346,7 @@ function setGraphiqActiveProject(basePath, activeProject) {
|
|
|
13219
13346
|
let locked = false;
|
|
13220
13347
|
for (let attempt = 0;attempt < maxAttempts; attempt++) {
|
|
13221
13348
|
try {
|
|
13222
|
-
|
|
13349
|
+
mkdirSync3(lockDir, { recursive: false });
|
|
13223
13350
|
locked = true;
|
|
13224
13351
|
break;
|
|
13225
13352
|
} catch (err) {
|
|
@@ -13240,20 +13367,20 @@ function setGraphiqActiveProject(basePath, activeProject) {
|
|
|
13240
13367
|
const fresh = readGraphiqState(basePath);
|
|
13241
13368
|
const tmpPath = `${statePath}.tmp`;
|
|
13242
13369
|
const next = { ...fresh, activeProject };
|
|
13243
|
-
|
|
13244
|
-
|
|
13370
|
+
mkdirSync3(dirname3(statePath), { recursive: true });
|
|
13371
|
+
writeFileSync3(tmpPath, `${JSON.stringify(next, null, 2)}
|
|
13245
13372
|
`, { mode: 384 });
|
|
13246
13373
|
renameSync(tmpPath, statePath);
|
|
13247
13374
|
} finally {
|
|
13248
13375
|
try {
|
|
13249
|
-
|
|
13376
|
+
rmSync2(lockDir, { recursive: false, force: true });
|
|
13250
13377
|
} catch {}
|
|
13251
13378
|
}
|
|
13252
13379
|
}
|
|
13253
13380
|
function updateGraphiqActiveProject(basePath, input) {
|
|
13254
13381
|
const current = readGraphiqState(basePath);
|
|
13255
13382
|
const indexedAt = input.indexedAt ?? new Date;
|
|
13256
|
-
const projectPath =
|
|
13383
|
+
const projectPath = resolve2(input.projectPath);
|
|
13257
13384
|
const project = {
|
|
13258
13385
|
path: projectPath,
|
|
13259
13386
|
dbPath: getGraphiqProjectDbPath(projectPath),
|
|
@@ -13303,7 +13430,7 @@ function disableGraphiqState(basePath, now = new Date) {
|
|
|
13303
13430
|
return next;
|
|
13304
13431
|
}
|
|
13305
13432
|
function parseGraphiqState(value) {
|
|
13306
|
-
if (!
|
|
13433
|
+
if (!isRecord5(value))
|
|
13307
13434
|
return emptyGraphiqState();
|
|
13308
13435
|
const indexedProjects = Array.isArray(value.indexedProjects) ? value.indexedProjects.map(parseIndexedProject).filter((entry) => entry !== null) : [];
|
|
13309
13436
|
const activeProject = typeof value.activeProject === "string" ? value.activeProject : undefined;
|
|
@@ -13319,7 +13446,7 @@ function parseGraphiqState(value) {
|
|
|
13319
13446
|
};
|
|
13320
13447
|
}
|
|
13321
13448
|
function parseIndexedProject(value) {
|
|
13322
|
-
if (!
|
|
13449
|
+
if (!isRecord5(value))
|
|
13323
13450
|
return null;
|
|
13324
13451
|
if (typeof value.path !== "string" || typeof value.dbPath !== "string" || typeof value.lastIndexedAt !== "string") {
|
|
13325
13452
|
return null;
|
|
@@ -13336,13 +13463,13 @@ function parseIndexedProject(value) {
|
|
|
13336
13463
|
function parseInstallSource(value) {
|
|
13337
13464
|
return value === "script" || value === "homebrew" || value === "source" || value === "existing" ? value : undefined;
|
|
13338
13465
|
}
|
|
13339
|
-
function
|
|
13466
|
+
function isRecord5(value) {
|
|
13340
13467
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13341
13468
|
}
|
|
13342
13469
|
// src/workspace-source-repo.ts
|
|
13343
13470
|
import { spawn, spawnSync } from "node:child_process";
|
|
13344
|
-
import { closeSync, existsSync as
|
|
13345
|
-
import { join as
|
|
13471
|
+
import { closeSync, existsSync as existsSync6, mkdirSync as mkdirSync4, openSync, readdirSync as readdirSync2, rmSync as rmSync3, statSync as statSync2, writeFileSync as writeFileSync4 } from "node:fs";
|
|
13472
|
+
import { join as join7, resolve as resolve3 } from "node:path";
|
|
13346
13473
|
var SIGNET_SOURCE_CHECKOUT_DIRNAME = "signetai";
|
|
13347
13474
|
var SIGNET_SOURCE_REMOTE_URL = "https://github.com/Signet-AI/signetai.git";
|
|
13348
13475
|
var DEFAULT_GIT_TIMEOUT_MS = 60000;
|
|
@@ -13350,7 +13477,7 @@ var SOURCE_REPO_SYNC_LOCK_FILENAME = "source-repo-sync.lock";
|
|
|
13350
13477
|
var SOURCE_REPO_SYNC_LOCK_STALE_MS = 5 * 60000;
|
|
13351
13478
|
var SOURCE_REPO_SYNC_LOCK_WAIT_MS = 15000;
|
|
13352
13479
|
function resolveWorkspaceSourceRepoPath(workspaceDir, repoDirName = SIGNET_SOURCE_CHECKOUT_DIRNAME) {
|
|
13353
|
-
return
|
|
13480
|
+
return join7(resolve3(workspaceDir), repoDirName);
|
|
13354
13481
|
}
|
|
13355
13482
|
function syncWorkspaceSourceRepo(workspaceDir, options = {}) {
|
|
13356
13483
|
const timeoutMs = options.gitTimeoutMs ?? DEFAULT_GIT_TIMEOUT_MS;
|
|
@@ -13399,7 +13526,7 @@ async function syncWorkspaceSourceRepoAsync(workspaceDir, options = {}) {
|
|
|
13399
13526
|
}
|
|
13400
13527
|
}
|
|
13401
13528
|
function syncWorkspaceSourceRepoLocked(run, workspaceDir, repoPath, remoteUrl, timeoutMs) {
|
|
13402
|
-
if (!
|
|
13529
|
+
if (!existsSync6(repoPath) || isEmptyDirectory(repoPath)) {
|
|
13403
13530
|
const workspaceReady = ensureWorkspaceDir(workspaceDir);
|
|
13404
13531
|
if (workspaceReady.ok === false) {
|
|
13405
13532
|
return errorResult(repoPath, workspaceReady.message);
|
|
@@ -13494,7 +13621,7 @@ function runGit(args, cwd, timeoutMs) {
|
|
|
13494
13621
|
};
|
|
13495
13622
|
}
|
|
13496
13623
|
async function runGitAsync(args, cwd, timeoutMs) {
|
|
13497
|
-
return await new Promise((
|
|
13624
|
+
return await new Promise((resolve4) => {
|
|
13498
13625
|
const proc = spawn("git", args, {
|
|
13499
13626
|
cwd,
|
|
13500
13627
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -13515,7 +13642,7 @@ async function runGitAsync(args, cwd, timeoutMs) {
|
|
|
13515
13642
|
clearTimeout(killTimer);
|
|
13516
13643
|
if (fallbackTimer)
|
|
13517
13644
|
clearTimeout(fallbackTimer);
|
|
13518
|
-
|
|
13645
|
+
resolve4(result);
|
|
13519
13646
|
};
|
|
13520
13647
|
const timer = setTimeout(() => {
|
|
13521
13648
|
stderr += `
|
|
@@ -13563,10 +13690,10 @@ function killGitProcessTree(proc, signal) {
|
|
|
13563
13690
|
} catch {}
|
|
13564
13691
|
}
|
|
13565
13692
|
function hasGitMetadata(path) {
|
|
13566
|
-
return
|
|
13693
|
+
return existsSync6(join7(path, ".git"));
|
|
13567
13694
|
}
|
|
13568
13695
|
function isEmptyDirectory(path) {
|
|
13569
|
-
if (!
|
|
13696
|
+
if (!existsSync6(path)) {
|
|
13570
13697
|
return true;
|
|
13571
13698
|
}
|
|
13572
13699
|
try {
|
|
@@ -13645,13 +13772,13 @@ function readErrorCode(err) {
|
|
|
13645
13772
|
return typeof maybeErrno.code === "string" ? maybeErrno.code : null;
|
|
13646
13773
|
}
|
|
13647
13774
|
function sourceRepoSyncLockPath(workspaceDir) {
|
|
13648
|
-
return
|
|
13775
|
+
return join7(resolve3(workspaceDir), ".daemon", SOURCE_REPO_SYNC_LOCK_FILENAME);
|
|
13649
13776
|
}
|
|
13650
13777
|
function clearStaleSourceRepoSyncLock(path) {
|
|
13651
13778
|
try {
|
|
13652
|
-
const age = Date.now() -
|
|
13779
|
+
const age = Date.now() - statSync2(path).mtimeMs;
|
|
13653
13780
|
if (age > SOURCE_REPO_SYNC_LOCK_STALE_MS) {
|
|
13654
|
-
|
|
13781
|
+
rmSync3(path, { force: true });
|
|
13655
13782
|
return true;
|
|
13656
13783
|
}
|
|
13657
13784
|
} catch {
|
|
@@ -13687,7 +13814,7 @@ async function acquireSourceRepoSyncLockAsync(workspaceDir) {
|
|
|
13687
13814
|
while (Date.now() < end) {
|
|
13688
13815
|
try {
|
|
13689
13816
|
const fd = openSync(path, "wx");
|
|
13690
|
-
|
|
13817
|
+
writeFileSync4(fd, `${process.pid}
|
|
13691
13818
|
${Date.now()}
|
|
13692
13819
|
`);
|
|
13693
13820
|
return { status: "acquired", lock: { fd, path } };
|
|
@@ -13708,10 +13835,10 @@ function releaseSourceRepoSyncLock(lock) {
|
|
|
13708
13835
|
try {
|
|
13709
13836
|
closeSync(lock.fd);
|
|
13710
13837
|
} catch {}
|
|
13711
|
-
|
|
13838
|
+
rmSync3(lock.path, { force: true });
|
|
13712
13839
|
}
|
|
13713
13840
|
async function sleep(ms) {
|
|
13714
|
-
await new Promise((
|
|
13841
|
+
await new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
13715
13842
|
}
|
|
13716
13843
|
function unsafeRemoteResult(repoPath) {
|
|
13717
13844
|
return {
|
|
@@ -13750,9 +13877,9 @@ function sourceRepoSyncLockErrorResult(repoPath, detail) {
|
|
|
13750
13877
|
};
|
|
13751
13878
|
}
|
|
13752
13879
|
function ensureDaemonDir(workspaceDir) {
|
|
13753
|
-
const daemonDir =
|
|
13880
|
+
const daemonDir = join7(resolve3(workspaceDir), ".daemon");
|
|
13754
13881
|
try {
|
|
13755
|
-
|
|
13882
|
+
mkdirSync4(daemonDir, { recursive: true });
|
|
13756
13883
|
return { ok: true };
|
|
13757
13884
|
} catch (err) {
|
|
13758
13885
|
return {
|
|
@@ -13763,7 +13890,7 @@ function ensureDaemonDir(workspaceDir) {
|
|
|
13763
13890
|
}
|
|
13764
13891
|
function ensureWorkspaceDir(workspaceDir) {
|
|
13765
13892
|
try {
|
|
13766
|
-
|
|
13893
|
+
mkdirSync4(workspaceDir, { recursive: true });
|
|
13767
13894
|
return { ok: true };
|
|
13768
13895
|
} catch (err) {
|
|
13769
13896
|
return {
|
|
@@ -13933,7 +14060,7 @@ function readTrimmedValue(result) {
|
|
|
13933
14060
|
function tryAcquireSourceRepoSyncLock(path) {
|
|
13934
14061
|
try {
|
|
13935
14062
|
const fd = openSync(path, "wx");
|
|
13936
|
-
|
|
14063
|
+
writeFileSync4(fd, `${process.pid}
|
|
13937
14064
|
${Date.now()}
|
|
13938
14065
|
`);
|
|
13939
14066
|
return { status: "acquired", lock: { fd, path } };
|
|
@@ -14077,9 +14204,9 @@ function escapeRegExp(value) {
|
|
|
14077
14204
|
}
|
|
14078
14205
|
// src/sources-config.ts
|
|
14079
14206
|
import { createHash, randomUUID } from "node:crypto";
|
|
14080
|
-
import { existsSync as
|
|
14081
|
-
import { homedir as
|
|
14082
|
-
import { basename, dirname as
|
|
14207
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync5, renameSync as renameSync2, rmSync as rmSync4, statSync as statSync3, writeFileSync as writeFileSync5 } from "node:fs";
|
|
14208
|
+
import { homedir as homedir4, platform as platform2 } from "node:os";
|
|
14209
|
+
import { basename, dirname as dirname4, resolve as resolve4 } from "node:path";
|
|
14083
14210
|
var DEFAULT_OBSIDIAN_EXCLUDE_GLOBS = [
|
|
14084
14211
|
"**/.obsidian/**",
|
|
14085
14212
|
"**/.trash/**",
|
|
@@ -14100,18 +14227,18 @@ var DEFAULT_GITHUB_MAX_ITEMS_PER_REPO = 500;
|
|
|
14100
14227
|
var MAX_GITHUB_MAX_ITEMS_PER_REPO = 1e4;
|
|
14101
14228
|
var VALID_GITHUB_RESOURCE_TYPES = new Set(DEFAULT_GITHUB_RESOURCE_TYPES);
|
|
14102
14229
|
function getAgentsDir() {
|
|
14103
|
-
return process.env.SIGNET_PATH || `${
|
|
14230
|
+
return process.env.SIGNET_PATH || `${homedir4()}/.agents`;
|
|
14104
14231
|
}
|
|
14105
14232
|
function getSourcesConfigPath(agentsDir = getAgentsDir()) {
|
|
14106
14233
|
return `${agentsDir.replace(/\/$/, "")}/sources.json`;
|
|
14107
14234
|
}
|
|
14108
14235
|
function loadSourcesConfig(agentsDir = getAgentsDir()) {
|
|
14109
14236
|
const path = getSourcesConfigPath(agentsDir);
|
|
14110
|
-
if (!
|
|
14237
|
+
if (!existsSync7(path))
|
|
14111
14238
|
return emptyConfig();
|
|
14112
14239
|
try {
|
|
14113
|
-
const parsed = JSON.parse(
|
|
14114
|
-
if (!
|
|
14240
|
+
const parsed = JSON.parse(readFileSync5(path, "utf8"));
|
|
14241
|
+
if (!isRecord6(parsed) || parsed.version !== SOURCES_CONFIG_VERSION || !Array.isArray(parsed.sources)) {
|
|
14115
14242
|
return emptyConfig();
|
|
14116
14243
|
}
|
|
14117
14244
|
return {
|
|
@@ -14124,24 +14251,24 @@ function loadSourcesConfig(agentsDir = getAgentsDir()) {
|
|
|
14124
14251
|
}
|
|
14125
14252
|
function saveSourcesConfig(config, agentsDir = getAgentsDir()) {
|
|
14126
14253
|
const path = getSourcesConfigPath(agentsDir);
|
|
14127
|
-
|
|
14254
|
+
mkdirSync5(dirname4(path), { recursive: true });
|
|
14128
14255
|
const tmp = `${path}.tmp-${process.pid}-${randomUUID()}`;
|
|
14129
|
-
|
|
14256
|
+
writeFileSync5(tmp, `${JSON.stringify(config, null, 2)}
|
|
14130
14257
|
`, "utf8");
|
|
14131
14258
|
renameSync2(tmp, path);
|
|
14132
14259
|
}
|
|
14133
14260
|
function loadSourcesConfigForWrite(agentsDir = getAgentsDir()) {
|
|
14134
14261
|
const path = getSourcesConfigPath(agentsDir);
|
|
14135
|
-
if (!
|
|
14262
|
+
if (!existsSync7(path))
|
|
14136
14263
|
return emptyConfig();
|
|
14137
14264
|
let parsed;
|
|
14138
14265
|
try {
|
|
14139
|
-
parsed = JSON.parse(
|
|
14266
|
+
parsed = JSON.parse(readFileSync5(path, "utf8"));
|
|
14140
14267
|
} catch (err) {
|
|
14141
14268
|
const detail = err instanceof Error ? err.message : String(err);
|
|
14142
14269
|
throw new Error(`Sources config is not readable JSON; refusing to overwrite ${path}: ${detail}`);
|
|
14143
14270
|
}
|
|
14144
|
-
if (!
|
|
14271
|
+
if (!isRecord6(parsed) || parsed.version !== SOURCES_CONFIG_VERSION || !Array.isArray(parsed.sources)) {
|
|
14145
14272
|
throw new Error(`Sources config is invalid; refusing to overwrite ${path}`);
|
|
14146
14273
|
}
|
|
14147
14274
|
if (!parsed.sources.every(isSourceEntry)) {
|
|
@@ -14467,11 +14594,11 @@ function addObsidianSourceChecked(input, agentsDir = getAgentsDir()) {
|
|
|
14467
14594
|
const trimmedRoot = input.root.trim();
|
|
14468
14595
|
if (!trimmedRoot)
|
|
14469
14596
|
return { ok: false, error: "Obsidian vault path is required" };
|
|
14470
|
-
const root =
|
|
14471
|
-
if (!
|
|
14597
|
+
const root = resolve4(trimmedRoot);
|
|
14598
|
+
if (!existsSync7(root))
|
|
14472
14599
|
return { ok: false, error: `Obsidian vault path does not exist: ${root}` };
|
|
14473
14600
|
try {
|
|
14474
|
-
if (!
|
|
14601
|
+
if (!statSync3(root).isDirectory())
|
|
14475
14602
|
return { ok: false, error: `Obsidian vault path must be a directory: ${root}` };
|
|
14476
14603
|
} catch {
|
|
14477
14604
|
return { ok: false, error: `Obsidian vault path is not accessible: ${root}` };
|
|
@@ -14547,12 +14674,12 @@ function emptyConfig() {
|
|
|
14547
14674
|
}
|
|
14548
14675
|
function withSourcesConfigLock(agentsDir, fn) {
|
|
14549
14676
|
const configPath = getSourcesConfigPath(agentsDir);
|
|
14550
|
-
|
|
14677
|
+
mkdirSync5(dirname4(configPath), { recursive: true });
|
|
14551
14678
|
const lockDir = `${configPath}.lock`;
|
|
14552
14679
|
let locked = false;
|
|
14553
14680
|
for (let attempt = 0;attempt < 500; attempt++) {
|
|
14554
14681
|
try {
|
|
14555
|
-
|
|
14682
|
+
mkdirSync5(lockDir);
|
|
14556
14683
|
locked = true;
|
|
14557
14684
|
break;
|
|
14558
14685
|
} catch (err) {
|
|
@@ -14566,7 +14693,7 @@ function withSourcesConfigLock(agentsDir, fn) {
|
|
|
14566
14693
|
try {
|
|
14567
14694
|
return fn();
|
|
14568
14695
|
} finally {
|
|
14569
|
-
|
|
14696
|
+
rmSync4(lockDir, { recursive: true, force: true });
|
|
14570
14697
|
}
|
|
14571
14698
|
}
|
|
14572
14699
|
function isFileExistsError(err) {
|
|
@@ -14590,7 +14717,7 @@ function cleanDiscordChannelFilter(values) {
|
|
|
14590
14717
|
}
|
|
14591
14718
|
function cleanLocalPath(value) {
|
|
14592
14719
|
const trimmed = value?.trim();
|
|
14593
|
-
return trimmed ?
|
|
14720
|
+
return trimmed ? resolve4(trimmed.replace(/^~(?=$|\/|\\)/, homedir4())) : undefined;
|
|
14594
14721
|
}
|
|
14595
14722
|
function cleanGitHubRepos(values) {
|
|
14596
14723
|
return Array.from(new Set(values.filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean)));
|
|
@@ -14638,11 +14765,11 @@ function isDiscordSyncMode(value) {
|
|
|
14638
14765
|
function defaultDiscordDesktopCachePath() {
|
|
14639
14766
|
switch (platform2()) {
|
|
14640
14767
|
case "darwin":
|
|
14641
|
-
return
|
|
14768
|
+
return resolve4(homedir4(), "Library", "Application Support", "discord");
|
|
14642
14769
|
case "win32":
|
|
14643
|
-
return
|
|
14770
|
+
return resolve4(process.env.APPDATA || resolve4(homedir4(), "AppData", "Roaming"), "discord");
|
|
14644
14771
|
default:
|
|
14645
|
-
return
|
|
14772
|
+
return resolve4(process.env.XDG_CONFIG_HOME || resolve4(homedir4(), ".config"), "discord");
|
|
14646
14773
|
}
|
|
14647
14774
|
}
|
|
14648
14775
|
function looksLikeDiscordDesktopCacheRoot(value) {
|
|
@@ -14675,14 +14802,14 @@ function isSafeGitHubDocPath(value) {
|
|
|
14675
14802
|
function mergeDefaultObsidianExcludeGlobs(values) {
|
|
14676
14803
|
return [...DEFAULT_OBSIDIAN_EXCLUDE_GLOBS, ...cleanExcludeGlobs(values) ?? []].filter((value, index, all) => all.indexOf(value) === index);
|
|
14677
14804
|
}
|
|
14678
|
-
function
|
|
14805
|
+
function isRecord6(value) {
|
|
14679
14806
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14680
14807
|
}
|
|
14681
14808
|
function isSourceEntry(value) {
|
|
14682
|
-
return
|
|
14809
|
+
return isRecord6(value) && typeof value.kind === "string" && value.kind.trim().length > 0 && typeof value.id === "string" && typeof value.name === "string" && typeof value.root === "string" && typeof value.enabled === "boolean" && value.mode === "read-only" && typeof value.createdAt === "string" && typeof value.updatedAt === "string" && (value.lastIndexedAt === undefined || typeof value.lastIndexedAt === "string") && (value.excludeGlobs === undefined || Array.isArray(value.excludeGlobs) && value.excludeGlobs.every((entry) => typeof entry === "string")) && (value.providerSettings === undefined || isJsonRecord(value.providerSettings));
|
|
14683
14810
|
}
|
|
14684
14811
|
function isJsonRecord(value) {
|
|
14685
|
-
if (!
|
|
14812
|
+
if (!isRecord6(value))
|
|
14686
14813
|
return false;
|
|
14687
14814
|
return Object.values(value).every(isJsonValue);
|
|
14688
14815
|
}
|
|
@@ -14701,8 +14828,8 @@ function isJsonValue(value) {
|
|
|
14701
14828
|
var SOURCE_CHUNK_SOURCE_TYPE = "source_chunk";
|
|
14702
14829
|
var LEGACY_OBSIDIAN_CHUNK_SOURCE_TYPE = "source_obsidian_chunk";
|
|
14703
14830
|
// src/export.ts
|
|
14704
|
-
import { existsSync as
|
|
14705
|
-
import { join as
|
|
14831
|
+
import { existsSync as existsSync8, readFileSync as readFileSync6, readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
|
|
14832
|
+
import { join as join8 } from "node:path";
|
|
14706
14833
|
var IDENTITY_FILE_NAMES = [
|
|
14707
14834
|
"AGENTS.md",
|
|
14708
14835
|
"SOUL.md",
|
|
@@ -14714,15 +14841,15 @@ var IDENTITY_FILE_NAMES = [
|
|
|
14714
14841
|
];
|
|
14715
14842
|
function collectExportData(agentsDir, db, options = {}) {
|
|
14716
14843
|
let agentYaml = null;
|
|
14717
|
-
const yamlPath =
|
|
14718
|
-
if (
|
|
14719
|
-
agentYaml =
|
|
14844
|
+
const yamlPath = join8(agentsDir, "agent.yaml");
|
|
14845
|
+
if (existsSync8(yamlPath)) {
|
|
14846
|
+
agentYaml = readFileSync6(yamlPath, "utf-8");
|
|
14720
14847
|
}
|
|
14721
14848
|
const identityFiles = [];
|
|
14722
14849
|
for (const name of IDENTITY_FILE_NAMES) {
|
|
14723
|
-
const path =
|
|
14724
|
-
if (
|
|
14725
|
-
identityFiles.push({ name, content:
|
|
14850
|
+
const path = join8(agentsDir, name);
|
|
14851
|
+
if (existsSync8(path)) {
|
|
14852
|
+
identityFiles.push({ name, content: readFileSync6(path, "utf-8") });
|
|
14726
14853
|
}
|
|
14727
14854
|
}
|
|
14728
14855
|
const memories = db.prepare(`SELECT id, content, type, category, confidence, source_type,
|
|
@@ -14740,14 +14867,14 @@ function collectExportData(agentsDir, db, options = {}) {
|
|
|
14740
14867
|
ORDER BY created_at ASC`).all();
|
|
14741
14868
|
const skills = [];
|
|
14742
14869
|
if (options.includeSkills !== false) {
|
|
14743
|
-
const skillsDir =
|
|
14744
|
-
if (
|
|
14870
|
+
const skillsDir = join8(agentsDir, "skills");
|
|
14871
|
+
if (existsSync8(skillsDir)) {
|
|
14745
14872
|
try {
|
|
14746
14873
|
const entries = readdirSync3(skillsDir, { withFileTypes: true });
|
|
14747
14874
|
for (const entry of entries) {
|
|
14748
14875
|
if (!entry.isDirectory())
|
|
14749
14876
|
continue;
|
|
14750
|
-
const skillDir =
|
|
14877
|
+
const skillDir = join8(skillsDir, entry.name);
|
|
14751
14878
|
const skillFiles = [];
|
|
14752
14879
|
collectSkillFiles(skillDir, "", skillFiles);
|
|
14753
14880
|
skills.push({ name: entry.name, files: skillFiles });
|
|
@@ -14778,16 +14905,16 @@ function collectSkillFiles(dir, prefix, out) {
|
|
|
14778
14905
|
try {
|
|
14779
14906
|
const entries = readdirSync3(dir, { withFileTypes: true });
|
|
14780
14907
|
for (const entry of entries) {
|
|
14781
|
-
const fullPath =
|
|
14908
|
+
const fullPath = join8(dir, entry.name);
|
|
14782
14909
|
const relPath = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
14783
14910
|
if (entry.isDirectory()) {
|
|
14784
14911
|
collectSkillFiles(fullPath, relPath, out);
|
|
14785
14912
|
} else {
|
|
14786
|
-
const stat =
|
|
14913
|
+
const stat = statSync4(fullPath);
|
|
14787
14914
|
if (stat.size > 1e6)
|
|
14788
14915
|
continue;
|
|
14789
14916
|
try {
|
|
14790
|
-
out.push({ path: relPath, content:
|
|
14917
|
+
out.push({ path: relPath, content: readFileSync6(fullPath, "utf-8") });
|
|
14791
14918
|
} catch {}
|
|
14792
14919
|
}
|
|
14793
14920
|
}
|
|
@@ -14919,14 +15046,14 @@ function importRelations(db, relationsJsonl) {
|
|
|
14919
15046
|
}
|
|
14920
15047
|
// src/identity.ts
|
|
14921
15048
|
import { execFileSync } from "node:child_process";
|
|
14922
|
-
import { existsSync as
|
|
14923
|
-
import { homedir as
|
|
14924
|
-
import { dirname as
|
|
15049
|
+
import { existsSync as existsSync11, readFileSync as readFileSync9, readdirSync as readdirSync4, realpathSync, statSync as statSync5 } from "node:fs";
|
|
15050
|
+
import { homedir as homedir7 } from "node:os";
|
|
15051
|
+
import { dirname as dirname7, join as join11 } from "node:path";
|
|
14925
15052
|
|
|
14926
15053
|
// src/oh-my-pi.ts
|
|
14927
|
-
import { existsSync as
|
|
14928
|
-
import { homedir as
|
|
14929
|
-
import { dirname as
|
|
15054
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync6, readFileSync as readFileSync7, rmSync as rmSync5, writeFileSync as writeFileSync6 } from "node:fs";
|
|
15055
|
+
import { homedir as homedir5 } from "node:os";
|
|
15056
|
+
import { dirname as dirname5, join as join9, resolve as resolve5 } from "node:path";
|
|
14930
15057
|
function readTrimmed(env, name) {
|
|
14931
15058
|
const raw = env[name];
|
|
14932
15059
|
if (typeof raw !== "string")
|
|
@@ -14935,21 +15062,21 @@ function readTrimmed(env, name) {
|
|
|
14935
15062
|
return trimmed.length > 0 ? trimmed : null;
|
|
14936
15063
|
}
|
|
14937
15064
|
function normalizePath(pathValue) {
|
|
14938
|
-
return
|
|
15065
|
+
return resolve5(expandHome(pathValue.trim()));
|
|
14939
15066
|
}
|
|
14940
|
-
function
|
|
15067
|
+
function readConfigHome2(env) {
|
|
14941
15068
|
const configured = readTrimmed(env, "XDG_CONFIG_HOME");
|
|
14942
|
-
return configured ? normalizePath(configured) :
|
|
15069
|
+
return configured ? normalizePath(configured) : join9(homedir5(), ".config");
|
|
14943
15070
|
}
|
|
14944
15071
|
function getOhMyPiConfigPath(env = process.env) {
|
|
14945
|
-
return
|
|
15072
|
+
return join9(readConfigHome2(env), "signet", "oh-my-pi.json");
|
|
14946
15073
|
}
|
|
14947
15074
|
function readConfiguredOhMyPiAgentDir(env = process.env) {
|
|
14948
15075
|
const configPath = getOhMyPiConfigPath(env);
|
|
14949
|
-
if (!
|
|
15076
|
+
if (!existsSync9(configPath))
|
|
14950
15077
|
return null;
|
|
14951
15078
|
try {
|
|
14952
|
-
const raw = JSON.parse(
|
|
15079
|
+
const raw = JSON.parse(readFileSync7(configPath, "utf-8"));
|
|
14953
15080
|
if (typeof raw !== "object" || raw === null)
|
|
14954
15081
|
return null;
|
|
14955
15082
|
const agentDir = Reflect.get(raw, "agentDir");
|
|
@@ -14962,10 +15089,10 @@ function resolveOhMyPiAgentDir(env = process.env) {
|
|
|
14962
15089
|
const configured = readTrimmed(env, "PI_CODING_AGENT_DIR");
|
|
14963
15090
|
if (configured)
|
|
14964
15091
|
return normalizePath(configured);
|
|
14965
|
-
return readConfiguredOhMyPiAgentDir(env) ??
|
|
15092
|
+
return readConfiguredOhMyPiAgentDir(env) ?? join9(homedir5(), ".omp", "agent");
|
|
14966
15093
|
}
|
|
14967
15094
|
function resolveOhMyPiExtensionsDir(env = process.env) {
|
|
14968
|
-
return
|
|
15095
|
+
return join9(resolveOhMyPiAgentDir(env), "extensions");
|
|
14969
15096
|
}
|
|
14970
15097
|
function listOhMyPiAgentDirCandidates(env = process.env) {
|
|
14971
15098
|
const candidates = new Set;
|
|
@@ -14975,38 +15102,38 @@ function listOhMyPiAgentDirCandidates(env = process.env) {
|
|
|
14975
15102
|
const persisted = readConfiguredOhMyPiAgentDir(env);
|
|
14976
15103
|
if (persisted)
|
|
14977
15104
|
candidates.add(persisted);
|
|
14978
|
-
candidates.add(
|
|
15105
|
+
candidates.add(join9(homedir5(), ".omp", "agent"));
|
|
14979
15106
|
return Array.from(candidates);
|
|
14980
15107
|
}
|
|
14981
15108
|
function writeConfiguredOhMyPiAgentDir(pathValue, env = process.env) {
|
|
14982
15109
|
const agentDir = normalizePath(pathValue);
|
|
14983
15110
|
const configPath = getOhMyPiConfigPath(env);
|
|
14984
|
-
if (readConfiguredOhMyPiAgentDir(env) === agentDir &&
|
|
15111
|
+
if (readConfiguredOhMyPiAgentDir(env) === agentDir && existsSync9(configPath)) {
|
|
14985
15112
|
return configPath;
|
|
14986
15113
|
}
|
|
14987
|
-
|
|
15114
|
+
mkdirSync6(dirname5(configPath), { recursive: true });
|
|
14988
15115
|
const payload = {
|
|
14989
15116
|
version: 1,
|
|
14990
15117
|
agentDir,
|
|
14991
15118
|
updatedAt: new Date().toISOString()
|
|
14992
15119
|
};
|
|
14993
|
-
|
|
15120
|
+
writeFileSync6(configPath, `${JSON.stringify(payload, null, 2)}
|
|
14994
15121
|
`);
|
|
14995
15122
|
return configPath;
|
|
14996
15123
|
}
|
|
14997
15124
|
function clearConfiguredOhMyPiAgentDir(env = process.env) {
|
|
14998
15125
|
const configPath = getOhMyPiConfigPath(env);
|
|
14999
|
-
if (!
|
|
15126
|
+
if (!existsSync9(configPath))
|
|
15000
15127
|
return;
|
|
15001
15128
|
try {
|
|
15002
|
-
|
|
15129
|
+
rmSync5(configPath, { force: true });
|
|
15003
15130
|
} catch {}
|
|
15004
15131
|
}
|
|
15005
15132
|
|
|
15006
15133
|
// src/pi.ts
|
|
15007
|
-
import { existsSync as
|
|
15008
|
-
import { homedir as
|
|
15009
|
-
import { dirname as
|
|
15134
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync8, rmSync as rmSync6, writeFileSync as writeFileSync7 } from "node:fs";
|
|
15135
|
+
import { homedir as homedir6 } from "node:os";
|
|
15136
|
+
import { dirname as dirname6, join as join10, resolve as resolve6 } from "node:path";
|
|
15010
15137
|
function readTrimmed2(env, name) {
|
|
15011
15138
|
const raw = env[name];
|
|
15012
15139
|
if (typeof raw !== "string")
|
|
@@ -15017,29 +15144,29 @@ function readTrimmed2(env, name) {
|
|
|
15017
15144
|
function expandUserPath(pathValue) {
|
|
15018
15145
|
const trimmed = pathValue.trim();
|
|
15019
15146
|
if (trimmed === "~")
|
|
15020
|
-
return
|
|
15147
|
+
return homedir6();
|
|
15021
15148
|
if (trimmed.startsWith("~/"))
|
|
15022
|
-
return
|
|
15149
|
+
return join10(homedir6(), trimmed.slice(2));
|
|
15023
15150
|
if (trimmed.startsWith("~"))
|
|
15024
|
-
return
|
|
15151
|
+
return join10(homedir6(), trimmed.slice(1));
|
|
15025
15152
|
return trimmed;
|
|
15026
15153
|
}
|
|
15027
15154
|
function normalizePath2(pathValue) {
|
|
15028
|
-
return
|
|
15155
|
+
return resolve6(expandUserPath(pathValue));
|
|
15029
15156
|
}
|
|
15030
|
-
function
|
|
15157
|
+
function readConfigHome3(env) {
|
|
15031
15158
|
const configured = readTrimmed2(env, "XDG_CONFIG_HOME");
|
|
15032
|
-
return configured ? normalizePath2(configured) :
|
|
15159
|
+
return configured ? normalizePath2(configured) : join10(homedir6(), ".config");
|
|
15033
15160
|
}
|
|
15034
15161
|
function getPiConfigPath(env = process.env) {
|
|
15035
|
-
return
|
|
15162
|
+
return join10(readConfigHome3(env), "signet", "pi.json");
|
|
15036
15163
|
}
|
|
15037
15164
|
function readConfiguredPiAgentDir(env = process.env) {
|
|
15038
15165
|
const configPath = getPiConfigPath(env);
|
|
15039
|
-
if (!
|
|
15166
|
+
if (!existsSync10(configPath))
|
|
15040
15167
|
return null;
|
|
15041
15168
|
try {
|
|
15042
|
-
const raw = JSON.parse(
|
|
15169
|
+
const raw = JSON.parse(readFileSync8(configPath, "utf-8"));
|
|
15043
15170
|
if (typeof raw !== "object" || raw === null)
|
|
15044
15171
|
return null;
|
|
15045
15172
|
const agentDir = Reflect.get(raw, "agentDir");
|
|
@@ -15052,10 +15179,10 @@ function resolvePiAgentDir(env = process.env) {
|
|
|
15052
15179
|
const configured = readTrimmed2(env, "PI_CODING_AGENT_DIR");
|
|
15053
15180
|
if (configured)
|
|
15054
15181
|
return normalizePath2(configured);
|
|
15055
|
-
return readConfiguredPiAgentDir(env) ??
|
|
15182
|
+
return readConfiguredPiAgentDir(env) ?? join10(homedir6(), ".pi", "agent");
|
|
15056
15183
|
}
|
|
15057
15184
|
function resolvePiExtensionsDir(env = process.env) {
|
|
15058
|
-
return
|
|
15185
|
+
return join10(resolvePiAgentDir(env), "extensions");
|
|
15059
15186
|
}
|
|
15060
15187
|
function listPiAgentDirCandidates(env = process.env) {
|
|
15061
15188
|
const candidates = new Set;
|
|
@@ -15065,31 +15192,31 @@ function listPiAgentDirCandidates(env = process.env) {
|
|
|
15065
15192
|
const persisted = readConfiguredPiAgentDir(env);
|
|
15066
15193
|
if (persisted)
|
|
15067
15194
|
candidates.add(persisted);
|
|
15068
|
-
candidates.add(
|
|
15195
|
+
candidates.add(join10(homedir6(), ".pi", "agent"));
|
|
15069
15196
|
return Array.from(candidates);
|
|
15070
15197
|
}
|
|
15071
15198
|
function writeConfiguredPiAgentDir(pathValue, env = process.env) {
|
|
15072
15199
|
const agentDir = normalizePath2(pathValue);
|
|
15073
15200
|
const configPath = getPiConfigPath(env);
|
|
15074
|
-
if (readConfiguredPiAgentDir(env) === agentDir &&
|
|
15201
|
+
if (readConfiguredPiAgentDir(env) === agentDir && existsSync10(configPath)) {
|
|
15075
15202
|
return configPath;
|
|
15076
15203
|
}
|
|
15077
|
-
|
|
15204
|
+
mkdirSync7(dirname6(configPath), { recursive: true });
|
|
15078
15205
|
const payload = {
|
|
15079
15206
|
version: 1,
|
|
15080
15207
|
agentDir,
|
|
15081
15208
|
updatedAt: new Date().toISOString()
|
|
15082
15209
|
};
|
|
15083
|
-
|
|
15210
|
+
writeFileSync7(configPath, `${JSON.stringify(payload, null, 2)}
|
|
15084
15211
|
`);
|
|
15085
15212
|
return configPath;
|
|
15086
15213
|
}
|
|
15087
15214
|
function clearConfiguredPiAgentDir(env = process.env) {
|
|
15088
15215
|
const configPath = getPiConfigPath(env);
|
|
15089
|
-
if (!
|
|
15216
|
+
if (!existsSync10(configPath))
|
|
15090
15217
|
return;
|
|
15091
15218
|
try {
|
|
15092
|
-
|
|
15219
|
+
rmSync6(configPath, { force: true });
|
|
15093
15220
|
} catch {}
|
|
15094
15221
|
}
|
|
15095
15222
|
|
|
@@ -15103,7 +15230,7 @@ var PI_MANAGED_MARKER = "SIGNET_MANAGED_PI_EXTENSION";
|
|
|
15103
15230
|
function resolveAgentBasePath(agentName, workspaceDir) {
|
|
15104
15231
|
if (agentName === "default")
|
|
15105
15232
|
return workspaceDir;
|
|
15106
|
-
return
|
|
15233
|
+
return join11(workspaceDir, "agents", agentName);
|
|
15107
15234
|
}
|
|
15108
15235
|
var IDENTITY_MODES = ["managed", "passthrough", "off"];
|
|
15109
15236
|
var IDENTITY_FILES = {
|
|
@@ -15202,13 +15329,13 @@ var REQUIRED_IDENTITY_KEYS = Object.entries(IDENTITY_FILES).filter(([, spec]) =>
|
|
|
15202
15329
|
var OPTIONAL_IDENTITY_KEYS = Object.entries(IDENTITY_FILES).filter(([, spec]) => spec.optional).map(([key]) => key);
|
|
15203
15330
|
function isSignetManagedOhMyPiInstall() {
|
|
15204
15331
|
for (const agentDir of listOhMyPiAgentDirCandidates()) {
|
|
15205
|
-
const extensionsDir =
|
|
15332
|
+
const extensionsDir = join11(agentDir, "extensions");
|
|
15206
15333
|
for (const filename of [OH_MY_PI_MANAGED_EXTENSION_FILENAME, OH_MY_PI_LEGACY_MANAGED_EXTENSION_FILENAME]) {
|
|
15207
|
-
const extensionPath =
|
|
15208
|
-
if (!
|
|
15334
|
+
const extensionPath = join11(extensionsDir, filename);
|
|
15335
|
+
if (!existsSync11(extensionPath))
|
|
15209
15336
|
continue;
|
|
15210
15337
|
try {
|
|
15211
|
-
const content =
|
|
15338
|
+
const content = readFileSync9(extensionPath, "utf8");
|
|
15212
15339
|
if (content.includes(OH_MY_PI_MANAGED_MARKER))
|
|
15213
15340
|
return true;
|
|
15214
15341
|
} catch {}
|
|
@@ -15218,13 +15345,13 @@ function isSignetManagedOhMyPiInstall() {
|
|
|
15218
15345
|
}
|
|
15219
15346
|
function isSignetManagedPiInstall() {
|
|
15220
15347
|
for (const agentDir of listPiAgentDirCandidates()) {
|
|
15221
|
-
const extensionsDir =
|
|
15348
|
+
const extensionsDir = join11(agentDir, "extensions");
|
|
15222
15349
|
for (const filename of [PI_MANAGED_EXTENSION_FILENAME, PI_LEGACY_MANAGED_EXTENSION_FILENAME]) {
|
|
15223
|
-
const extensionPath =
|
|
15224
|
-
if (!
|
|
15350
|
+
const extensionPath = join11(extensionsDir, filename);
|
|
15351
|
+
if (!existsSync11(extensionPath))
|
|
15225
15352
|
continue;
|
|
15226
15353
|
try {
|
|
15227
|
-
const content =
|
|
15354
|
+
const content = readFileSync9(extensionPath, "utf8");
|
|
15228
15355
|
if (content.includes(PI_MANAGED_MARKER))
|
|
15229
15356
|
return true;
|
|
15230
15357
|
} catch {}
|
|
@@ -15233,31 +15360,31 @@ function isSignetManagedPiInstall() {
|
|
|
15233
15360
|
return false;
|
|
15234
15361
|
}
|
|
15235
15362
|
function userHome() {
|
|
15236
|
-
return process.env.HOME?.trim() ||
|
|
15363
|
+
return process.env.HOME?.trim() || homedir7();
|
|
15237
15364
|
}
|
|
15238
15365
|
function resolveHermesHomePath() {
|
|
15239
15366
|
const hermesHome = process.env.HERMES_HOME?.trim();
|
|
15240
|
-
return hermesHome ||
|
|
15367
|
+
return hermesHome || join11(userHome(), ".hermes");
|
|
15241
15368
|
}
|
|
15242
15369
|
function hermesAgentCandidateDirs() {
|
|
15243
15370
|
const home = userHome();
|
|
15244
15371
|
const hermesHome = resolveHermesHomePath();
|
|
15245
15372
|
return [
|
|
15246
15373
|
hermesHome,
|
|
15247
|
-
|
|
15248
|
-
|
|
15249
|
-
|
|
15250
|
-
|
|
15374
|
+
join11(hermesHome, "hermes-agent"),
|
|
15375
|
+
join11(home, "hermes-agent"),
|
|
15376
|
+
join11(home, ".local", "share", "hermes-agent"),
|
|
15377
|
+
join11(home, "src", "hermes-agent"),
|
|
15251
15378
|
"/opt/hermes-agent"
|
|
15252
15379
|
];
|
|
15253
15380
|
}
|
|
15254
15381
|
function resolveHermesRepoPath() {
|
|
15255
15382
|
const hermesRepo = process.env.HERMES_REPO?.trim();
|
|
15256
|
-
if (hermesRepo &&
|
|
15383
|
+
if (hermesRepo && existsSync11(join11(hermesRepo, "plugins", "memory"))) {
|
|
15257
15384
|
return hermesRepo;
|
|
15258
15385
|
}
|
|
15259
15386
|
for (const base of hermesAgentCandidateDirs()) {
|
|
15260
|
-
if (
|
|
15387
|
+
if (existsSync11(join11(base, "plugins", "memory")))
|
|
15261
15388
|
return base;
|
|
15262
15389
|
}
|
|
15263
15390
|
try {
|
|
@@ -15267,19 +15394,19 @@ function resolveHermesRepoPath() {
|
|
|
15267
15394
|
timeout: 3000
|
|
15268
15395
|
}).trim();
|
|
15269
15396
|
if (hermesPath) {
|
|
15270
|
-
const repoDir =
|
|
15271
|
-
if (
|
|
15397
|
+
const repoDir = dirname7(realpathSync(hermesPath));
|
|
15398
|
+
if (existsSync11(join11(repoDir, "plugins", "memory")))
|
|
15272
15399
|
return repoDir;
|
|
15273
15400
|
}
|
|
15274
15401
|
} catch {}
|
|
15275
15402
|
return null;
|
|
15276
15403
|
}
|
|
15277
15404
|
function resolveHermesRepoPluginPath() {
|
|
15278
|
-
const pluginFile =
|
|
15405
|
+
const pluginFile = join11("plugins", "memory", "signet", "__init__.py");
|
|
15279
15406
|
const hermesRepo = resolveHermesRepoPath();
|
|
15280
15407
|
if (hermesRepo !== null) {
|
|
15281
|
-
const candidate =
|
|
15282
|
-
if (
|
|
15408
|
+
const candidate = join11(hermesRepo, pluginFile);
|
|
15409
|
+
if (existsSync11(candidate))
|
|
15283
15410
|
return candidate;
|
|
15284
15411
|
}
|
|
15285
15412
|
return null;
|
|
@@ -15288,52 +15415,52 @@ function detectExistingSetup(basePath) {
|
|
|
15288
15415
|
const identityFileNames = Object.values(IDENTITY_FILES).map((spec) => spec.path);
|
|
15289
15416
|
const foundFiles = [];
|
|
15290
15417
|
for (const fileName of identityFileNames) {
|
|
15291
|
-
if (
|
|
15418
|
+
if (existsSync11(join11(basePath, fileName))) {
|
|
15292
15419
|
foundFiles.push(fileName);
|
|
15293
15420
|
}
|
|
15294
15421
|
}
|
|
15295
|
-
const memoryDir =
|
|
15422
|
+
const memoryDir = join11(basePath, "memory");
|
|
15296
15423
|
let memoryLogCount = 0;
|
|
15297
|
-
if (
|
|
15424
|
+
if (existsSync11(memoryDir)) {
|
|
15298
15425
|
try {
|
|
15299
15426
|
const files = readdirSync4(memoryDir);
|
|
15300
15427
|
memoryLogCount = files.filter((f) => f.endsWith(".md") && !f.startsWith("TEMPLATE")).length;
|
|
15301
15428
|
} catch {}
|
|
15302
15429
|
}
|
|
15303
|
-
const home =
|
|
15430
|
+
const home = homedir7();
|
|
15304
15431
|
return {
|
|
15305
15432
|
basePath,
|
|
15306
|
-
agentsDir:
|
|
15307
|
-
agentYaml:
|
|
15308
|
-
agentsMd:
|
|
15309
|
-
configYaml:
|
|
15310
|
-
memoryDb:
|
|
15433
|
+
agentsDir: existsSync11(basePath),
|
|
15434
|
+
agentYaml: existsSync11(join11(basePath, "agent.yaml")),
|
|
15435
|
+
agentsMd: existsSync11(join11(basePath, "AGENTS.md")),
|
|
15436
|
+
configYaml: existsSync11(join11(basePath, "config.yaml")),
|
|
15437
|
+
memoryDb: existsSync11(join11(basePath, "memory", "memories.db")),
|
|
15311
15438
|
identityFiles: foundFiles,
|
|
15312
|
-
hasMemoryDir:
|
|
15439
|
+
hasMemoryDir: existsSync11(memoryDir),
|
|
15313
15440
|
memoryLogCount,
|
|
15314
|
-
hasClawdhub:
|
|
15315
|
-
hasClaudeSkills:
|
|
15441
|
+
hasClawdhub: existsSync11(join11(basePath, ".clawdhub", "lock.json")),
|
|
15442
|
+
hasClaudeSkills: existsSync11(join11(home, ".claude", "skills")),
|
|
15316
15443
|
harnesses: {
|
|
15317
|
-
claudeCode:
|
|
15318
|
-
openclaw:
|
|
15319
|
-
opencode:
|
|
15320
|
-
forge:
|
|
15321
|
-
codex:
|
|
15322
|
-
ohMyPi: isSignetManagedOhMyPiInstall() ||
|
|
15323
|
-
pi: isSignetManagedPiInstall() ||
|
|
15444
|
+
claudeCode: existsSync11(join11(home, ".claude", "settings.json")),
|
|
15445
|
+
openclaw: existsSync11(join11(home, ".openclaw", "openclaw.json")) || existsSync11(join11(home, ".clawdbot", "clawdbot.json")),
|
|
15446
|
+
opencode: existsSync11(join11(home, ".config", "opencode", "config.json")),
|
|
15447
|
+
forge: existsSync11(join11(home, ".forge", ".mcp.json")) || existsSync11(join11(home, "forge", ".mcp.json")) || existsSync11(join11(home, ".forge", ".forge.toml")) || existsSync11(join11(home, "forge", ".forge.toml")),
|
|
15448
|
+
codex: existsSync11(join11(home, ".codex", "config.toml")) || existsSync11(join11(home, ".config", "signet", "bin", "codex")),
|
|
15449
|
+
ohMyPi: isSignetManagedOhMyPiInstall() || existsSync11(resolveOhMyPiAgentDir()),
|
|
15450
|
+
pi: isSignetManagedPiInstall() || existsSync11(resolvePiAgentDir()),
|
|
15324
15451
|
hermesAgent: resolveHermesRepoPath() !== null,
|
|
15325
|
-
gemini:
|
|
15452
|
+
gemini: existsSync11(join11(home, ".gemini", "settings.json"))
|
|
15326
15453
|
}
|
|
15327
15454
|
};
|
|
15328
15455
|
}
|
|
15329
15456
|
async function loadIdentityFiles(basePath) {
|
|
15330
15457
|
const result = {};
|
|
15331
15458
|
for (const [key, spec] of Object.entries(IDENTITY_FILES)) {
|
|
15332
|
-
const filePath =
|
|
15333
|
-
if (
|
|
15459
|
+
const filePath = join11(basePath, spec.path);
|
|
15460
|
+
if (existsSync11(filePath)) {
|
|
15334
15461
|
try {
|
|
15335
|
-
const content =
|
|
15336
|
-
const stats =
|
|
15462
|
+
const content = readFileSync9(filePath, "utf-8");
|
|
15463
|
+
const stats = statSync5(filePath);
|
|
15337
15464
|
result[key] = {
|
|
15338
15465
|
path: spec.path,
|
|
15339
15466
|
content,
|
|
@@ -15354,11 +15481,11 @@ async function loadIdentityFiles(basePath) {
|
|
|
15354
15481
|
function loadIdentityFilesSync(basePath) {
|
|
15355
15482
|
const result = {};
|
|
15356
15483
|
for (const [key, spec] of Object.entries(IDENTITY_FILES)) {
|
|
15357
|
-
const filePath =
|
|
15358
|
-
if (
|
|
15484
|
+
const filePath = join11(basePath, spec.path);
|
|
15485
|
+
if (existsSync11(filePath)) {
|
|
15359
15486
|
try {
|
|
15360
|
-
const content =
|
|
15361
|
-
const stats =
|
|
15487
|
+
const content = readFileSync9(filePath, "utf-8");
|
|
15488
|
+
const stats = statSync5(filePath);
|
|
15362
15489
|
result[key] = {
|
|
15363
15490
|
path: spec.path,
|
|
15364
15491
|
content,
|
|
@@ -15382,7 +15509,7 @@ function hasValidIdentity(basePath) {
|
|
|
15382
15509
|
return true;
|
|
15383
15510
|
for (const key of REQUIRED_IDENTITY_KEYS) {
|
|
15384
15511
|
const spec = IDENTITY_FILES[key];
|
|
15385
|
-
if (!
|
|
15512
|
+
if (!existsSync11(join11(basePath, spec.path))) {
|
|
15386
15513
|
return false;
|
|
15387
15514
|
}
|
|
15388
15515
|
}
|
|
@@ -15395,7 +15522,7 @@ function getMissingIdentityFiles(basePath) {
|
|
|
15395
15522
|
const missing = [];
|
|
15396
15523
|
for (const key of REQUIRED_IDENTITY_KEYS) {
|
|
15397
15524
|
const spec = IDENTITY_FILES[key];
|
|
15398
|
-
if (!
|
|
15525
|
+
if (!existsSync11(join11(basePath, spec.path))) {
|
|
15399
15526
|
missing.push(spec.path);
|
|
15400
15527
|
}
|
|
15401
15528
|
}
|
|
@@ -15443,11 +15570,11 @@ function resolveIdentityModeFromConfig(config) {
|
|
|
15443
15570
|
return "managed";
|
|
15444
15571
|
}
|
|
15445
15572
|
function loadIdentityMode(agentsDir) {
|
|
15446
|
-
const agentYaml =
|
|
15447
|
-
if (!
|
|
15573
|
+
const agentYaml = join11(agentsDir, "agent.yaml");
|
|
15574
|
+
if (!existsSync11(agentYaml))
|
|
15448
15575
|
return "managed";
|
|
15449
15576
|
try {
|
|
15450
|
-
return resolveIdentityModeFromConfig(parseSimpleYaml(
|
|
15577
|
+
return resolveIdentityModeFromConfig(parseSimpleYaml(readFileSync9(agentYaml, "utf-8")));
|
|
15451
15578
|
} catch {
|
|
15452
15579
|
return "managed";
|
|
15453
15580
|
}
|
|
@@ -15498,11 +15625,11 @@ function identityHeaderFor(path, role) {
|
|
|
15498
15625
|
return STATIC_HEADER_BY_FILE[filename] ?? role ?? filename.replace(/\.md$/i, "");
|
|
15499
15626
|
}
|
|
15500
15627
|
function resolveStartupIdentityFiles(agentsDir) {
|
|
15501
|
-
const agentYaml =
|
|
15502
|
-
if (!
|
|
15628
|
+
const agentYaml = join11(agentsDir, "agent.yaml");
|
|
15629
|
+
if (!existsSync11(agentYaml))
|
|
15503
15630
|
return STATIC_BUDGETS.map(({ file, budget }) => ({ path: file, budget }));
|
|
15504
15631
|
try {
|
|
15505
|
-
const config = parseSimpleYaml(
|
|
15632
|
+
const config = parseSimpleYaml(readFileSync9(agentYaml, "utf-8"));
|
|
15506
15633
|
if (!identityModeReadsFiles(resolveIdentityModeFromConfig(config)))
|
|
15507
15634
|
return [];
|
|
15508
15635
|
const identity = readRecord(config.identity);
|
|
@@ -15518,12 +15645,12 @@ function resolveStartupIdentityFiles(agentsDir) {
|
|
|
15518
15645
|
return STATIC_BUDGETS.map(({ file, budget }) => ({ path: file, budget }));
|
|
15519
15646
|
}
|
|
15520
15647
|
function resolveSpecialIdentityFiles(agentsDir, kind) {
|
|
15521
|
-
const agentYaml =
|
|
15522
|
-
if (!
|
|
15648
|
+
const agentYaml = join11(agentsDir, "agent.yaml");
|
|
15649
|
+
if (!existsSync11(agentYaml)) {
|
|
15523
15650
|
return IDENTITY_PRESETS.minimal.special.filter((entry) => entry.kind === kind);
|
|
15524
15651
|
}
|
|
15525
15652
|
try {
|
|
15526
|
-
const config = parseSimpleYaml(
|
|
15653
|
+
const config = parseSimpleYaml(readFileSync9(agentYaml, "utf-8"));
|
|
15527
15654
|
if (!identityModeReadsFiles(resolveIdentityModeFromConfig(config)))
|
|
15528
15655
|
return [];
|
|
15529
15656
|
const identity = readRecord(config.identity);
|
|
@@ -15560,17 +15687,17 @@ function resolvePromptSubmitTimeoutMs(raw) {
|
|
|
15560
15687
|
return ms;
|
|
15561
15688
|
}
|
|
15562
15689
|
function readStaticIdentity(agentsDir, status = STATIC_IDENTITY_OFFLINE_STATUS) {
|
|
15563
|
-
if (!
|
|
15690
|
+
if (!existsSync11(agentsDir))
|
|
15564
15691
|
return null;
|
|
15565
15692
|
if (!identityModeReadsFiles(loadIdentityMode(agentsDir)))
|
|
15566
15693
|
return null;
|
|
15567
15694
|
const parts = [];
|
|
15568
15695
|
for (const entry of resolveStartupIdentityFiles(agentsDir)) {
|
|
15569
|
-
const path =
|
|
15570
|
-
if (!
|
|
15696
|
+
const path = join11(agentsDir, entry.path);
|
|
15697
|
+
if (!existsSync11(path))
|
|
15571
15698
|
continue;
|
|
15572
15699
|
try {
|
|
15573
|
-
const raw =
|
|
15700
|
+
const raw = readFileSync9(path, "utf-8").trim();
|
|
15574
15701
|
if (!raw)
|
|
15575
15702
|
continue;
|
|
15576
15703
|
const budget = entry.budget ?? STATIC_BUDGETS.find((candidate) => candidate.file === entry.path)?.budget ?? 4000;
|
|
@@ -15605,8 +15732,8 @@ function summarizeIdentity(identity) {
|
|
|
15605
15732
|
`);
|
|
15606
15733
|
}
|
|
15607
15734
|
// src/agents.ts
|
|
15608
|
-
import { existsSync as
|
|
15609
|
-
import { join as
|
|
15735
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync8, readdirSync as readdirSync5, writeFileSync as writeFileSync8 } from "node:fs";
|
|
15736
|
+
import { join as join12 } from "node:path";
|
|
15610
15737
|
var IDENTITY_FILES2 = [
|
|
15611
15738
|
"AGENTS.md",
|
|
15612
15739
|
"SOUL.md",
|
|
@@ -15618,37 +15745,37 @@ var IDENTITY_FILES2 = [
|
|
|
15618
15745
|
"BOOTSTRAP.md"
|
|
15619
15746
|
];
|
|
15620
15747
|
function discoverAgents(agentsDir) {
|
|
15621
|
-
const root =
|
|
15622
|
-
if (!
|
|
15748
|
+
const root = join12(agentsDir, "agents");
|
|
15749
|
+
if (!existsSync12(root))
|
|
15623
15750
|
return [];
|
|
15624
15751
|
return readdirSync5(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => ({ name: d.name }));
|
|
15625
15752
|
}
|
|
15626
15753
|
function scaffoldAgent(name, agentsDir) {
|
|
15627
|
-
const dir =
|
|
15628
|
-
if (!
|
|
15629
|
-
|
|
15630
|
-
const soul =
|
|
15631
|
-
if (!
|
|
15632
|
-
|
|
15754
|
+
const dir = join12(agentsDir, "agents", name);
|
|
15755
|
+
if (!existsSync12(dir))
|
|
15756
|
+
mkdirSync8(dir, { recursive: true });
|
|
15757
|
+
const soul = join12(dir, "SOUL.md");
|
|
15758
|
+
if (!existsSync12(soul))
|
|
15759
|
+
writeFileSync8(soul, `# Soul
|
|
15633
15760
|
|
|
15634
15761
|
Add ${name}'s personality here.
|
|
15635
15762
|
`);
|
|
15636
|
-
const identity =
|
|
15637
|
-
if (!
|
|
15638
|
-
|
|
15763
|
+
const identity = join12(dir, "IDENTITY.md");
|
|
15764
|
+
if (!existsSync12(identity))
|
|
15765
|
+
writeFileSync8(identity, `# Identity
|
|
15639
15766
|
|
|
15640
15767
|
name: ${name}
|
|
15641
15768
|
`);
|
|
15642
15769
|
}
|
|
15643
15770
|
function getAgentIdentityFiles(name, agentsDir) {
|
|
15644
15771
|
const result = {};
|
|
15645
|
-
const agentDir =
|
|
15772
|
+
const agentDir = join12(agentsDir, "agents", name);
|
|
15646
15773
|
for (const file of IDENTITY_FILES2) {
|
|
15647
|
-
const specific =
|
|
15648
|
-
const fallback =
|
|
15649
|
-
if (
|
|
15774
|
+
const specific = join12(agentDir, file);
|
|
15775
|
+
const fallback = join12(agentsDir, file);
|
|
15776
|
+
if (existsSync12(specific))
|
|
15650
15777
|
result[file] = specific;
|
|
15651
|
-
else if (
|
|
15778
|
+
else if (existsSync12(fallback))
|
|
15652
15779
|
result[file] = fallback;
|
|
15653
15780
|
}
|
|
15654
15781
|
return result;
|
|
@@ -15696,13 +15823,13 @@ function resolveAgentSkills(agentDef, allSkills) {
|
|
|
15696
15823
|
return allSkills.filter((s) => allowed.has(s));
|
|
15697
15824
|
}
|
|
15698
15825
|
// src/skills.ts
|
|
15699
|
-
import { existsSync as
|
|
15700
|
-
import { join as
|
|
15701
|
-
import { homedir as
|
|
15826
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync10, readFileSync as readFileSync10, readdirSync as readdirSync7, statSync as statSync6, writeFileSync as writeFileSync9 } from "node:fs";
|
|
15827
|
+
import { join as join14 } from "node:path";
|
|
15828
|
+
import { homedir as homedir8 } from "node:os";
|
|
15702
15829
|
|
|
15703
15830
|
// src/symlinks.ts
|
|
15704
|
-
import { existsSync as
|
|
15705
|
-
import { join as
|
|
15831
|
+
import { existsSync as existsSync13, lstatSync, mkdirSync as mkdirSync9, readdirSync as readdirSync6, symlinkSync, unlinkSync } from "node:fs";
|
|
15832
|
+
import { join as join13 } from "node:path";
|
|
15706
15833
|
function linkDirSync(target, path) {
|
|
15707
15834
|
const type = process.platform === "win32" ? "junction" : "dir";
|
|
15708
15835
|
symlinkSync(target, path, type);
|
|
@@ -15713,15 +15840,15 @@ function symlinkSkills(sourceDir, targetDir, options = {}) {
|
|
|
15713
15840
|
skipped: [],
|
|
15714
15841
|
errors: []
|
|
15715
15842
|
};
|
|
15716
|
-
if (!
|
|
15843
|
+
if (!existsSync13(sourceDir)) {
|
|
15717
15844
|
return result;
|
|
15718
15845
|
}
|
|
15719
|
-
const targetParent =
|
|
15720
|
-
if (!
|
|
15721
|
-
|
|
15846
|
+
const targetParent = join13(targetDir, "..");
|
|
15847
|
+
if (!existsSync13(targetParent)) {
|
|
15848
|
+
mkdirSync9(targetParent, { recursive: true });
|
|
15722
15849
|
}
|
|
15723
|
-
if (!
|
|
15724
|
-
|
|
15850
|
+
if (!existsSync13(targetDir)) {
|
|
15851
|
+
mkdirSync9(targetDir, { recursive: true });
|
|
15725
15852
|
}
|
|
15726
15853
|
let entries;
|
|
15727
15854
|
try {
|
|
@@ -15734,8 +15861,8 @@ function symlinkSkills(sourceDir, targetDir, options = {}) {
|
|
|
15734
15861
|
return result;
|
|
15735
15862
|
}
|
|
15736
15863
|
for (const entry of entries) {
|
|
15737
|
-
const srcPath =
|
|
15738
|
-
const destPath =
|
|
15864
|
+
const srcPath = join13(sourceDir, entry);
|
|
15865
|
+
const destPath = join13(targetDir, entry);
|
|
15739
15866
|
try {
|
|
15740
15867
|
const src = lstatSync(srcPath);
|
|
15741
15868
|
if (src.isSymbolicLink() || !src.isDirectory()) {
|
|
@@ -15777,10 +15904,10 @@ function symlinkSkills(sourceDir, targetDir, options = {}) {
|
|
|
15777
15904
|
return result;
|
|
15778
15905
|
}
|
|
15779
15906
|
function symlinkDir(src, dest, options = {}) {
|
|
15780
|
-
if (!
|
|
15907
|
+
if (!existsSync13(src)) {
|
|
15781
15908
|
return false;
|
|
15782
15909
|
}
|
|
15783
|
-
if (
|
|
15910
|
+
if (existsSync13(dest)) {
|
|
15784
15911
|
try {
|
|
15785
15912
|
const stat = lstatSync(dest);
|
|
15786
15913
|
if (stat.isSymbolicLink()) {
|
|
@@ -15806,36 +15933,36 @@ function symlinkDir(src, dest, options = {}) {
|
|
|
15806
15933
|
}
|
|
15807
15934
|
|
|
15808
15935
|
// src/skills.ts
|
|
15809
|
-
var home =
|
|
15936
|
+
var home = homedir8();
|
|
15810
15937
|
function loadClawdhubLock(basePath) {
|
|
15811
|
-
const lockPath =
|
|
15812
|
-
if (!
|
|
15938
|
+
const lockPath = join14(basePath, ".clawdhub", "lock.json");
|
|
15939
|
+
if (!existsSync14(lockPath)) {
|
|
15813
15940
|
return null;
|
|
15814
15941
|
}
|
|
15815
15942
|
try {
|
|
15816
|
-
const content =
|
|
15943
|
+
const content = readFileSync10(lockPath, "utf-8");
|
|
15817
15944
|
return JSON.parse(content);
|
|
15818
15945
|
} catch {
|
|
15819
15946
|
return null;
|
|
15820
15947
|
}
|
|
15821
15948
|
}
|
|
15822
15949
|
function symlinkClaudeSkills(basePath) {
|
|
15823
|
-
const claudeSkillsDir =
|
|
15824
|
-
const targetSkillsDir =
|
|
15825
|
-
if (!
|
|
15950
|
+
const claudeSkillsDir = join14(home, ".claude", "skills");
|
|
15951
|
+
const targetSkillsDir = join14(basePath, "skills");
|
|
15952
|
+
if (!existsSync14(claudeSkillsDir)) {
|
|
15826
15953
|
return { symlinked: 0, skills: [] };
|
|
15827
15954
|
}
|
|
15828
|
-
if (!
|
|
15829
|
-
|
|
15955
|
+
if (!existsSync14(targetSkillsDir)) {
|
|
15956
|
+
mkdirSync10(targetSkillsDir, { recursive: true });
|
|
15830
15957
|
}
|
|
15831
15958
|
const symlinkedSkills = [];
|
|
15832
15959
|
try {
|
|
15833
15960
|
const skills = readdirSync7(claudeSkillsDir);
|
|
15834
15961
|
for (const skill of skills) {
|
|
15835
|
-
const src =
|
|
15836
|
-
const dest =
|
|
15962
|
+
const src = join14(claudeSkillsDir, skill);
|
|
15963
|
+
const dest = join14(targetSkillsDir, skill);
|
|
15837
15964
|
try {
|
|
15838
|
-
if (!
|
|
15965
|
+
if (!statSync6(src).isDirectory())
|
|
15839
15966
|
continue;
|
|
15840
15967
|
} catch {
|
|
15841
15968
|
continue;
|
|
@@ -15848,12 +15975,12 @@ function symlinkClaudeSkills(basePath) {
|
|
|
15848
15975
|
return { symlinked: symlinkedSkills.length, skills: symlinkedSkills };
|
|
15849
15976
|
}
|
|
15850
15977
|
function writeRegistry(basePath, registry) {
|
|
15851
|
-
const skillsDir =
|
|
15852
|
-
const registryPath =
|
|
15853
|
-
if (!
|
|
15854
|
-
|
|
15978
|
+
const skillsDir = join14(basePath, "skills");
|
|
15979
|
+
const registryPath = join14(skillsDir, "registry.json");
|
|
15980
|
+
if (!existsSync14(skillsDir)) {
|
|
15981
|
+
mkdirSync10(skillsDir, { recursive: true });
|
|
15855
15982
|
}
|
|
15856
|
-
|
|
15983
|
+
writeFileSync9(registryPath, JSON.stringify(registry, null, 2), "utf-8");
|
|
15857
15984
|
}
|
|
15858
15985
|
async function unifySkills(basePath, config = {}) {
|
|
15859
15986
|
const registry = {
|
|
@@ -15867,7 +15994,7 @@ async function unifySkills(basePath, config = {}) {
|
|
|
15867
15994
|
if (clawdhubLock) {
|
|
15868
15995
|
registry.sources.push({
|
|
15869
15996
|
type: "openclaw",
|
|
15870
|
-
path:
|
|
15997
|
+
path: join14(basePath, ".clawdhub")
|
|
15871
15998
|
});
|
|
15872
15999
|
const skillsData = clawdhubLock.skills || clawdhubLock;
|
|
15873
16000
|
for (const [name, data] of Object.entries(skillsData)) {
|
|
@@ -15889,10 +16016,10 @@ async function unifySkills(basePath, config = {}) {
|
|
|
15889
16016
|
}
|
|
15890
16017
|
}
|
|
15891
16018
|
const claudeResult = symlinkClaudeSkills(basePath);
|
|
15892
|
-
if (claudeResult.symlinked > 0 ||
|
|
16019
|
+
if (claudeResult.symlinked > 0 || existsSync14(join14(home, ".claude", "skills"))) {
|
|
15893
16020
|
registry.sources.push({
|
|
15894
16021
|
type: "claude-code",
|
|
15895
|
-
path:
|
|
16022
|
+
path: join14(home, ".claude", "skills")
|
|
15896
16023
|
});
|
|
15897
16024
|
for (const skillName of claudeResult.skills) {
|
|
15898
16025
|
if (!registry.skills[skillName]) {
|
|
@@ -15900,7 +16027,7 @@ async function unifySkills(basePath, config = {}) {
|
|
|
15900
16027
|
name: skillName,
|
|
15901
16028
|
source: "claude-code",
|
|
15902
16029
|
symlinked: true,
|
|
15903
|
-
path:
|
|
16030
|
+
path: join14(basePath, "skills", skillName)
|
|
15904
16031
|
};
|
|
15905
16032
|
symlinked++;
|
|
15906
16033
|
} else {
|
|
@@ -15910,7 +16037,7 @@ async function unifySkills(basePath, config = {}) {
|
|
|
15910
16037
|
}
|
|
15911
16038
|
if (config.registries) {
|
|
15912
16039
|
for (const reg of config.registries) {
|
|
15913
|
-
if (!
|
|
16040
|
+
if (!existsSync14(reg.path)) {
|
|
15914
16041
|
continue;
|
|
15915
16042
|
}
|
|
15916
16043
|
registry.sources.push({
|
|
@@ -15920,9 +16047,9 @@ async function unifySkills(basePath, config = {}) {
|
|
|
15920
16047
|
try {
|
|
15921
16048
|
const entries = readdirSync7(reg.path);
|
|
15922
16049
|
for (const entry of entries) {
|
|
15923
|
-
const entryPath =
|
|
16050
|
+
const entryPath = join14(reg.path, entry);
|
|
15924
16051
|
try {
|
|
15925
|
-
if (!
|
|
16052
|
+
if (!statSync6(entryPath).isDirectory())
|
|
15926
16053
|
continue;
|
|
15927
16054
|
} catch {
|
|
15928
16055
|
continue;
|
|
@@ -15932,9 +16059,9 @@ async function unifySkills(basePath, config = {}) {
|
|
|
15932
16059
|
continue;
|
|
15933
16060
|
}
|
|
15934
16061
|
if (reg.symlink) {
|
|
15935
|
-
const targetPath =
|
|
15936
|
-
if (!
|
|
15937
|
-
|
|
16062
|
+
const targetPath = join14(basePath, "skills", entry);
|
|
16063
|
+
if (!existsSync14(join14(basePath, "skills"))) {
|
|
16064
|
+
mkdirSync10(join14(basePath, "skills"), { recursive: true });
|
|
15938
16065
|
}
|
|
15939
16066
|
if (symlinkDir(entryPath, targetPath)) {
|
|
15940
16067
|
registry.skills[entry] = {
|
|
@@ -15969,7 +16096,7 @@ async function unifySkills(basePath, config = {}) {
|
|
|
15969
16096
|
};
|
|
15970
16097
|
}
|
|
15971
16098
|
// src/skill-transcript.ts
|
|
15972
|
-
function
|
|
16099
|
+
function isRecord7(value) {
|
|
15973
16100
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15974
16101
|
}
|
|
15975
16102
|
function toMs(ts) {
|
|
@@ -15994,20 +16121,20 @@ function parseTranscriptSkills(content) {
|
|
|
15994
16121
|
} catch {
|
|
15995
16122
|
continue;
|
|
15996
16123
|
}
|
|
15997
|
-
if (!
|
|
16124
|
+
if (!isRecord7(row))
|
|
15998
16125
|
continue;
|
|
15999
16126
|
const message = row.message;
|
|
16000
|
-
if (!
|
|
16127
|
+
if (!isRecord7(message))
|
|
16001
16128
|
continue;
|
|
16002
16129
|
const contentBlocks = message.content;
|
|
16003
16130
|
if (!Array.isArray(contentBlocks))
|
|
16004
16131
|
continue;
|
|
16005
16132
|
const at = toMs(row.timestamp);
|
|
16006
16133
|
for (const part of contentBlocks) {
|
|
16007
|
-
if (!
|
|
16134
|
+
if (!isRecord7(part))
|
|
16008
16135
|
continue;
|
|
16009
16136
|
if (part.type === "tool_use" && part.name === "Skill") {
|
|
16010
|
-
const input =
|
|
16137
|
+
const input = isRecord7(part.input) ? part.input : {};
|
|
16011
16138
|
const skillName = toStr(input.skill) || toStr(input.name) || toStr(input.skill_name);
|
|
16012
16139
|
if (!skillName)
|
|
16013
16140
|
continue;
|
|
@@ -16050,8 +16177,8 @@ function parseTranscriptSkills(content) {
|
|
|
16050
16177
|
return { records, skipped };
|
|
16051
16178
|
}
|
|
16052
16179
|
// src/import.ts
|
|
16053
|
-
import { existsSync as
|
|
16054
|
-
import { join as
|
|
16180
|
+
import { existsSync as existsSync15, readFileSync as readFileSync11, readdirSync as readdirSync8 } from "node:fs";
|
|
16181
|
+
import { join as join15 } from "node:path";
|
|
16055
16182
|
var DATE_FILENAME_PATTERN = /^(\d{4}-\d{2}-\d{2})\.md$/;
|
|
16056
16183
|
function estimateTokens(text) {
|
|
16057
16184
|
return Math.ceil(text.length / 4);
|
|
@@ -16258,8 +16385,8 @@ function importMemoryLogs(basePath, db) {
|
|
|
16258
16385
|
skipped: 0,
|
|
16259
16386
|
errors: []
|
|
16260
16387
|
};
|
|
16261
|
-
const memoryDir =
|
|
16262
|
-
if (!
|
|
16388
|
+
const memoryDir = join15(basePath, "memory");
|
|
16389
|
+
if (!existsSync15(memoryDir)) {
|
|
16263
16390
|
result.errors.push(`Memory directory not found: ${memoryDir}`);
|
|
16264
16391
|
return result;
|
|
16265
16392
|
}
|
|
@@ -16272,7 +16399,7 @@ function importMemoryLogs(basePath, db) {
|
|
|
16272
16399
|
return result;
|
|
16273
16400
|
}
|
|
16274
16401
|
for (const file of files) {
|
|
16275
|
-
const filePath =
|
|
16402
|
+
const filePath = join15(memoryDir, file);
|
|
16276
16403
|
const date = extractDateFromFilename(file);
|
|
16277
16404
|
if (!date) {
|
|
16278
16405
|
result.skipped++;
|
|
@@ -16281,7 +16408,7 @@ function importMemoryLogs(basePath, db) {
|
|
|
16281
16408
|
}
|
|
16282
16409
|
let content;
|
|
16283
16410
|
try {
|
|
16284
|
-
content =
|
|
16411
|
+
content = readFileSync11(filePath, "utf-8");
|
|
16285
16412
|
} catch (err) {
|
|
16286
16413
|
const message = err instanceof Error ? err.message : String(err);
|
|
16287
16414
|
result.errors.push(`Failed to read file ${file}: ${message}`);
|
|
@@ -16482,7 +16609,7 @@ function ok(value) {
|
|
|
16482
16609
|
function err(code, message, details) {
|
|
16483
16610
|
return { ok: false, error: { code, message, ...details ? { details } : {} } };
|
|
16484
16611
|
}
|
|
16485
|
-
function
|
|
16612
|
+
function isRecord8(value) {
|
|
16486
16613
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16487
16614
|
}
|
|
16488
16615
|
function asString(value) {
|
|
@@ -16512,7 +16639,7 @@ function asNonNegativeInt(value) {
|
|
|
16512
16639
|
return Math.floor(value);
|
|
16513
16640
|
}
|
|
16514
16641
|
function asRecordOfStrings(value) {
|
|
16515
|
-
if (!
|
|
16642
|
+
if (!isRecord8(value))
|
|
16516
16643
|
return {};
|
|
16517
16644
|
const next = {};
|
|
16518
16645
|
for (const [key, raw] of Object.entries(value)) {
|
|
@@ -16523,7 +16650,7 @@ function asRecordOfStrings(value) {
|
|
|
16523
16650
|
return next;
|
|
16524
16651
|
}
|
|
16525
16652
|
function asRecordOfStringArrays(value) {
|
|
16526
|
-
if (!
|
|
16653
|
+
if (!isRecord8(value))
|
|
16527
16654
|
return {};
|
|
16528
16655
|
const next = {};
|
|
16529
16656
|
for (const [key, raw] of Object.entries(value)) {
|
|
@@ -16661,7 +16788,7 @@ function parseRoutingTargetRef(value) {
|
|
|
16661
16788
|
});
|
|
16662
16789
|
}
|
|
16663
16790
|
function parseAccountConfig(raw) {
|
|
16664
|
-
if (!
|
|
16791
|
+
if (!isRecord8(raw))
|
|
16665
16792
|
return null;
|
|
16666
16793
|
const kind = asString(raw.kind);
|
|
16667
16794
|
if (!kind || !ROUTING_ACCOUNT_KINDS.includes(kind))
|
|
@@ -16679,7 +16806,7 @@ function parseAccountConfig(raw) {
|
|
|
16679
16806
|
};
|
|
16680
16807
|
}
|
|
16681
16808
|
function parseModelConfig(raw) {
|
|
16682
|
-
if (!
|
|
16809
|
+
if (!isRecord8(raw))
|
|
16683
16810
|
return null;
|
|
16684
16811
|
const model = asString(raw.model);
|
|
16685
16812
|
if (!model)
|
|
@@ -16697,7 +16824,7 @@ function parseModelConfig(raw) {
|
|
|
16697
16824
|
};
|
|
16698
16825
|
}
|
|
16699
16826
|
function parseCommandConfig(raw) {
|
|
16700
|
-
if (!
|
|
16827
|
+
if (!isRecord8(raw))
|
|
16701
16828
|
return;
|
|
16702
16829
|
const bin = asString(raw.bin ?? raw.command);
|
|
16703
16830
|
if (!bin)
|
|
@@ -16735,9 +16862,9 @@ function asAcpxModelSelection(value) {
|
|
|
16735
16862
|
return typeof value === "string" && ["acp", "agent"].includes(value) ? value : undefined;
|
|
16736
16863
|
}
|
|
16737
16864
|
function parseAcpxConfig(raw) {
|
|
16738
|
-
if (!
|
|
16865
|
+
if (!isRecord8(raw))
|
|
16739
16866
|
return;
|
|
16740
|
-
const nested =
|
|
16867
|
+
const nested = isRecord8(raw.acpx) ? raw.acpx : raw;
|
|
16741
16868
|
const agent = asString(nested.agent ?? nested.harness);
|
|
16742
16869
|
if (!agent)
|
|
16743
16870
|
return;
|
|
@@ -16765,10 +16892,10 @@ function parseAcpxConfig(raw) {
|
|
|
16765
16892
|
};
|
|
16766
16893
|
}
|
|
16767
16894
|
function parseOpenRouterConfig(raw) {
|
|
16768
|
-
if (!
|
|
16895
|
+
if (!isRecord8(raw))
|
|
16769
16896
|
return;
|
|
16770
|
-
const nested =
|
|
16771
|
-
const reasoningRaw =
|
|
16897
|
+
const nested = isRecord8(raw.openrouter) ? raw.openrouter : raw;
|
|
16898
|
+
const reasoningRaw = isRecord8(nested.reasoning) ? nested.reasoning : undefined;
|
|
16772
16899
|
if (!reasoningRaw)
|
|
16773
16900
|
return;
|
|
16774
16901
|
const enabled = asBool(reasoningRaw.enabled);
|
|
@@ -16780,12 +16907,12 @@ function parseOpenRouterConfig(raw) {
|
|
|
16780
16907
|
return Object.keys(reasoning).length > 0 ? { reasoning } : undefined;
|
|
16781
16908
|
}
|
|
16782
16909
|
function parseTargetConfig(raw) {
|
|
16783
|
-
if (!
|
|
16910
|
+
if (!isRecord8(raw))
|
|
16784
16911
|
return null;
|
|
16785
16912
|
const executor = asString(raw.executor);
|
|
16786
16913
|
if (!executor || !ROUTING_EXECUTOR_PATTERN.test(executor))
|
|
16787
16914
|
return null;
|
|
16788
|
-
const modelsRaw =
|
|
16915
|
+
const modelsRaw = isRecord8(raw.models) ? raw.models : null;
|
|
16789
16916
|
if (!modelsRaw)
|
|
16790
16917
|
return null;
|
|
16791
16918
|
const models = {};
|
|
@@ -16820,7 +16947,7 @@ function parseTargetConfig(raw) {
|
|
|
16820
16947
|
};
|
|
16821
16948
|
}
|
|
16822
16949
|
function parsePolicyConfig(raw) {
|
|
16823
|
-
if (!
|
|
16950
|
+
if (!isRecord8(raw))
|
|
16824
16951
|
return null;
|
|
16825
16952
|
return {
|
|
16826
16953
|
mode: asRoutingMode(raw.mode, "automatic"),
|
|
@@ -16834,7 +16961,7 @@ function parsePolicyConfig(raw) {
|
|
|
16834
16961
|
};
|
|
16835
16962
|
}
|
|
16836
16963
|
function parseTaskClassConfig(raw) {
|
|
16837
|
-
if (!
|
|
16964
|
+
if (!isRecord8(raw))
|
|
16838
16965
|
return null;
|
|
16839
16966
|
return {
|
|
16840
16967
|
reasoning: asRoutingReasoningDepth(raw.reasoning, "medium"),
|
|
@@ -16851,7 +16978,7 @@ function parseTaskClassConfig(raw) {
|
|
|
16851
16978
|
};
|
|
16852
16979
|
}
|
|
16853
16980
|
function parseAgentRoutingConfig(raw) {
|
|
16854
|
-
if (!
|
|
16981
|
+
if (!isRecord8(raw))
|
|
16855
16982
|
return null;
|
|
16856
16983
|
return {
|
|
16857
16984
|
defaultPolicy: asString(raw.defaultPolicy ?? raw.default_policy),
|
|
@@ -16861,7 +16988,7 @@ function parseAgentRoutingConfig(raw) {
|
|
|
16861
16988
|
};
|
|
16862
16989
|
}
|
|
16863
16990
|
function parseWorkloadBinding(raw) {
|
|
16864
|
-
if (!
|
|
16991
|
+
if (!isRecord8(raw))
|
|
16865
16992
|
return;
|
|
16866
16993
|
const policy = asString(raw.policy);
|
|
16867
16994
|
const taskClass = asString(raw.taskClass ?? raw.task_class);
|
|
@@ -17122,17 +17249,17 @@ function validateRoutingReferences(config) {
|
|
|
17122
17249
|
}
|
|
17123
17250
|
function parseRoutingConfig(raw, legacyConfig) {
|
|
17124
17251
|
const base = legacyConfig ?? emptyRoutingConfig("explicit");
|
|
17125
|
-
if (!
|
|
17252
|
+
if (!isRecord8(raw)) {
|
|
17126
17253
|
return ok(base);
|
|
17127
17254
|
}
|
|
17128
|
-
const embeddedInference =
|
|
17255
|
+
const embeddedInference = isRecord8(raw.inference) ? raw.inference : null;
|
|
17129
17256
|
const standaloneInference = embeddedInference ? null : hasStandaloneRoutingShape(raw) ? raw : null;
|
|
17130
17257
|
const routingRaw = embeddedInference ?? standaloneInference;
|
|
17131
17258
|
if (!routingRaw) {
|
|
17132
17259
|
return ok(base);
|
|
17133
17260
|
}
|
|
17134
17261
|
const accounts = { ...base.accounts };
|
|
17135
|
-
if (
|
|
17262
|
+
if (isRecord8(routingRaw.accounts)) {
|
|
17136
17263
|
for (const [accountId, accountRaw] of Object.entries(routingRaw.accounts)) {
|
|
17137
17264
|
const parsed = parseAccountConfig(accountRaw);
|
|
17138
17265
|
if (parsed)
|
|
@@ -17140,7 +17267,7 @@ function parseRoutingConfig(raw, legacyConfig) {
|
|
|
17140
17267
|
}
|
|
17141
17268
|
}
|
|
17142
17269
|
const targets = { ...base.targets };
|
|
17143
|
-
const targetsRaw =
|
|
17270
|
+
const targetsRaw = isRecord8(routingRaw.targets) ? routingRaw.targets : isRecord8(routingRaw.providers) ? routingRaw.providers : null;
|
|
17144
17271
|
if (targetsRaw) {
|
|
17145
17272
|
for (const [targetId, targetRaw] of Object.entries(targetsRaw)) {
|
|
17146
17273
|
const parsed = parseTargetConfig(targetRaw);
|
|
@@ -17149,7 +17276,7 @@ function parseRoutingConfig(raw, legacyConfig) {
|
|
|
17149
17276
|
}
|
|
17150
17277
|
}
|
|
17151
17278
|
const policies = { ...base.policies };
|
|
17152
|
-
if (
|
|
17279
|
+
if (isRecord8(routingRaw.policies)) {
|
|
17153
17280
|
for (const [policyId, policyRaw] of Object.entries(routingRaw.policies)) {
|
|
17154
17281
|
const parsed = parsePolicyConfig(policyRaw);
|
|
17155
17282
|
if (parsed)
|
|
@@ -17157,8 +17284,8 @@ function parseRoutingConfig(raw, legacyConfig) {
|
|
|
17157
17284
|
}
|
|
17158
17285
|
}
|
|
17159
17286
|
const taskClasses = { ...base.taskClasses };
|
|
17160
|
-
if (
|
|
17161
|
-
const taskClassRaw =
|
|
17287
|
+
if (isRecord8(routingRaw.taskClasses ?? routingRaw.task_classes)) {
|
|
17288
|
+
const taskClassRaw = isRecord8(routingRaw.taskClasses) ? routingRaw.taskClasses : routingRaw.task_classes;
|
|
17162
17289
|
for (const [taskId, taskRaw] of Object.entries(taskClassRaw)) {
|
|
17163
17290
|
const parsed = parseTaskClassConfig(taskRaw);
|
|
17164
17291
|
if (parsed)
|
|
@@ -17166,7 +17293,7 @@ function parseRoutingConfig(raw, legacyConfig) {
|
|
|
17166
17293
|
}
|
|
17167
17294
|
}
|
|
17168
17295
|
const agents = { ...base.agents };
|
|
17169
|
-
if (
|
|
17296
|
+
if (isRecord8(routingRaw.agents)) {
|
|
17170
17297
|
for (const [agentId, agentRaw] of Object.entries(routingRaw.agents)) {
|
|
17171
17298
|
const parsed = parseAgentRoutingConfig(agentRaw);
|
|
17172
17299
|
if (parsed)
|
|
@@ -17176,7 +17303,7 @@ function parseRoutingConfig(raw, legacyConfig) {
|
|
|
17176
17303
|
const workloads = {
|
|
17177
17304
|
...base.workloads ?? {}
|
|
17178
17305
|
};
|
|
17179
|
-
if (
|
|
17306
|
+
if (isRecord8(routingRaw.workloads)) {
|
|
17180
17307
|
const defaultBinding = parseWorkloadBinding(routingRaw.workloads.default);
|
|
17181
17308
|
const interactive = parseWorkloadBinding(routingRaw.workloads.interactive);
|
|
17182
17309
|
const memoryExtraction = parseWorkloadBinding(routingRaw.workloads.memoryExtraction ?? routingRaw.workloads.memory_extraction);
|
|
@@ -17564,16 +17691,16 @@ function resolveRoutingDecision(config, request, runtimeSnapshot) {
|
|
|
17564
17691
|
});
|
|
17565
17692
|
}
|
|
17566
17693
|
// src/pipeline-pause.ts
|
|
17567
|
-
import { existsSync as
|
|
17568
|
-
import { join as
|
|
17694
|
+
import { existsSync as existsSync16, readFileSync as readFileSync12, writeFileSync as writeFileSync10 } from "node:fs";
|
|
17695
|
+
import { join as join16 } from "node:path";
|
|
17569
17696
|
var PIPELINE_CONFIG_FILES = ["agent.yaml", "AGENT.yaml", "config.yaml"];
|
|
17570
|
-
function
|
|
17697
|
+
function isRecord9(value) {
|
|
17571
17698
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17572
17699
|
}
|
|
17573
17700
|
function findPipelineConfigFile(dir) {
|
|
17574
17701
|
for (const name of PIPELINE_CONFIG_FILES) {
|
|
17575
|
-
const file =
|
|
17576
|
-
if (
|
|
17702
|
+
const file = join16(dir, name);
|
|
17703
|
+
if (existsSync16(file)) {
|
|
17577
17704
|
return file;
|
|
17578
17705
|
}
|
|
17579
17706
|
}
|
|
@@ -17584,15 +17711,15 @@ function readCfg(dir) {
|
|
|
17584
17711
|
if (file === null) {
|
|
17585
17712
|
return { file: null, cfg: null };
|
|
17586
17713
|
}
|
|
17587
|
-
const parsed = parseSimpleYaml(
|
|
17588
|
-
return { file, cfg:
|
|
17714
|
+
const parsed = parseSimpleYaml(readFileSync12(file, "utf-8"));
|
|
17715
|
+
return { file, cfg: isRecord9(parsed) ? parsed : {} };
|
|
17589
17716
|
}
|
|
17590
17717
|
function readMem(cfg) {
|
|
17591
|
-
return
|
|
17718
|
+
return isRecord9(cfg.memory) ? cfg.memory : null;
|
|
17592
17719
|
}
|
|
17593
17720
|
function readPipeline(cfg) {
|
|
17594
17721
|
const mem = readMem(cfg);
|
|
17595
|
-
return mem &&
|
|
17722
|
+
return mem && isRecord9(mem.pipelineV2) ? mem.pipelineV2 : null;
|
|
17596
17723
|
}
|
|
17597
17724
|
function readPipelineConfigData(dir) {
|
|
17598
17725
|
const { cfg: root, file } = readCfg(dir);
|
|
@@ -17627,7 +17754,7 @@ function setPipelinePaused(dir, paused) {
|
|
|
17627
17754
|
const nextP2 = { ...pipeline ?? {}, paused };
|
|
17628
17755
|
const nextMem = { ...memory ?? {}, pipelineV2: nextP2 };
|
|
17629
17756
|
const next = { ...root, memory: nextMem };
|
|
17630
|
-
|
|
17757
|
+
writeFileSync10(file, formatYaml(next));
|
|
17631
17758
|
return {
|
|
17632
17759
|
file,
|
|
17633
17760
|
exists: true,
|
|
@@ -17637,12 +17764,12 @@ function setPipelinePaused(dir, paused) {
|
|
|
17637
17764
|
}
|
|
17638
17765
|
// src/package-manager.ts
|
|
17639
17766
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
17640
|
-
import { existsSync as
|
|
17641
|
-
import { homedir as
|
|
17642
|
-
import { join as
|
|
17767
|
+
import { existsSync as existsSync17, readFileSync as readFileSync13 } from "node:fs";
|
|
17768
|
+
import { homedir as homedir10 } from "node:os";
|
|
17769
|
+
import { join as join17 } from "node:path";
|
|
17643
17770
|
|
|
17644
17771
|
// src/package-manager-path.ts
|
|
17645
|
-
import { homedir as
|
|
17772
|
+
import { homedir as homedir9 } from "node:os";
|
|
17646
17773
|
import { posix, win32 } from "node:path";
|
|
17647
17774
|
function normalizeExecutablePath(path, platform3) {
|
|
17648
17775
|
const normalized = (platform3 === "win32" ? win32 : posix).resolve(path).replaceAll("\\", "/");
|
|
@@ -17657,7 +17784,7 @@ function inferPackageManagerFromExecutable(executablePath, options = {}) {
|
|
|
17657
17784
|
if (!executablePath)
|
|
17658
17785
|
return null;
|
|
17659
17786
|
const env = options.env ?? process.env;
|
|
17660
|
-
const home2 = options.home ??
|
|
17787
|
+
const home2 = options.home ?? homedir9();
|
|
17661
17788
|
const platform3 = options.platform ?? process.platform;
|
|
17662
17789
|
const pathApi = platform3 === "win32" ? win32 : posix;
|
|
17663
17790
|
const candidate = normalizeExecutablePath(executablePath, platform3);
|
|
@@ -17738,12 +17865,12 @@ function pickFirstAvailable(available, order) {
|
|
|
17738
17865
|
function readConfiguredPackageManager(agentsDir) {
|
|
17739
17866
|
if (!agentsDir)
|
|
17740
17867
|
return null;
|
|
17741
|
-
const configPaths = [
|
|
17868
|
+
const configPaths = [join17(agentsDir, "agent.yaml"), join17(agentsDir, "AGENT.yaml"), join17(agentsDir, "config.yaml")];
|
|
17742
17869
|
for (const path of configPaths) {
|
|
17743
|
-
if (!
|
|
17870
|
+
if (!existsSync17(path))
|
|
17744
17871
|
continue;
|
|
17745
17872
|
try {
|
|
17746
|
-
const yaml = parseSimpleYaml(
|
|
17873
|
+
const yaml = parseSimpleYaml(readFileSync13(path, "utf-8"));
|
|
17747
17874
|
const install = yaml.install;
|
|
17748
17875
|
const source = install?.source;
|
|
17749
17876
|
if (source === "fallback")
|
|
@@ -17855,8 +17982,8 @@ function resolveGlobalPackagePath(family, packageName) {
|
|
|
17855
17982
|
try {
|
|
17856
17983
|
switch (family) {
|
|
17857
17984
|
case "bun": {
|
|
17858
|
-
const bunGlobal =
|
|
17859
|
-
if (
|
|
17985
|
+
const bunGlobal = join17(process.env.BUN_INSTALL ?? join17(homedir10(), ".bun"), "install", "global", "node_modules", packageName);
|
|
17986
|
+
if (existsSync17(bunGlobal))
|
|
17860
17987
|
return bunGlobal;
|
|
17861
17988
|
return;
|
|
17862
17989
|
}
|
|
@@ -17867,8 +17994,8 @@ function resolveGlobalPackagePath(family, packageName) {
|
|
|
17867
17994
|
windowsHide: true
|
|
17868
17995
|
});
|
|
17869
17996
|
if (result.status === 0 && result.stdout.trim()) {
|
|
17870
|
-
const candidate =
|
|
17871
|
-
if (
|
|
17997
|
+
const candidate = join17(result.stdout.trim(), packageName);
|
|
17998
|
+
if (existsSync17(candidate))
|
|
17872
17999
|
return candidate;
|
|
17873
18000
|
}
|
|
17874
18001
|
return;
|
|
@@ -17880,8 +18007,8 @@ function resolveGlobalPackagePath(family, packageName) {
|
|
|
17880
18007
|
windowsHide: true
|
|
17881
18008
|
});
|
|
17882
18009
|
if (result.status === 0 && result.stdout.trim()) {
|
|
17883
|
-
const candidate =
|
|
17884
|
-
if (
|
|
18010
|
+
const candidate = join17(result.stdout.trim(), packageName);
|
|
18011
|
+
if (existsSync17(candidate))
|
|
17885
18012
|
return candidate;
|
|
17886
18013
|
}
|
|
17887
18014
|
return;
|
|
@@ -17900,13 +18027,13 @@ function resolveGlobalPackagePath(family, packageName) {
|
|
|
17900
18027
|
windowsHide: true
|
|
17901
18028
|
});
|
|
17902
18029
|
if (result.status === 0 && result.stdout.trim()) {
|
|
17903
|
-
const candidate =
|
|
17904
|
-
if (
|
|
18030
|
+
const candidate = join17(result.stdout.trim(), "node_modules", packageName);
|
|
18031
|
+
if (existsSync17(candidate))
|
|
17905
18032
|
return candidate;
|
|
17906
18033
|
}
|
|
17907
18034
|
} else {
|
|
17908
|
-
const berryGlobal =
|
|
17909
|
-
if (
|
|
18035
|
+
const berryGlobal = join17(process.env.YARN_GLOBAL_FOLDER ?? join17(homedir10(), ".yarn", "berry", "global"), "node_modules", packageName);
|
|
18036
|
+
if (existsSync17(berryGlobal))
|
|
17910
18037
|
return berryGlobal;
|
|
17911
18038
|
}
|
|
17912
18039
|
return;
|
|
@@ -17929,8 +18056,8 @@ function getGlobalInstallCommand(family, packageName) {
|
|
|
17929
18056
|
}
|
|
17930
18057
|
}
|
|
17931
18058
|
// src/signet-installation.ts
|
|
17932
|
-
import { existsSync as
|
|
17933
|
-
import { homedir as
|
|
18059
|
+
import { existsSync as existsSync18, realpathSync as realpathSync2 } from "node:fs";
|
|
18060
|
+
import { homedir as homedir11 } from "node:os";
|
|
17934
18061
|
import { posix as posix2, win32 as win322 } from "node:path";
|
|
17935
18062
|
var PACKAGE_MANAGERS = ["npm", "pnpm", "bun", "yarn"];
|
|
17936
18063
|
function safeRealpath(path, platform3, realpath) {
|
|
@@ -17976,10 +18103,10 @@ function packageManagerRemovalCommand(family) {
|
|
|
17976
18103
|
}
|
|
17977
18104
|
function detectSignetInstallations(options = {}) {
|
|
17978
18105
|
const env = options.env ?? process.env;
|
|
17979
|
-
const home2 = options.home ??
|
|
18106
|
+
const home2 = options.home ?? homedir11();
|
|
17980
18107
|
const platform3 = options.platform ?? process.platform;
|
|
17981
18108
|
const activeExecutablePath = options.execPath ?? process.execPath;
|
|
17982
|
-
const pathExists = options.exists ??
|
|
18109
|
+
const pathExists = options.exists ?? existsSync18;
|
|
17983
18110
|
const realpath = options.realpath ?? realpathSync2;
|
|
17984
18111
|
const activeRealPath = safeRealpath(activeExecutablePath, platform3, realpath);
|
|
17985
18112
|
const signetDir = env.SIGNET_DIR?.trim();
|
|
@@ -18040,15 +18167,15 @@ function inactivePackageManagerInstallations(report) {
|
|
|
18040
18167
|
return report.inactive.filter((installation) => PACKAGE_MANAGERS.includes(installation.method) && installation.removalCommand);
|
|
18041
18168
|
}
|
|
18042
18169
|
// src/ingest/index.ts
|
|
18043
|
-
import { existsSync as
|
|
18044
|
-
import { join as
|
|
18045
|
-
import { readFileSync as
|
|
18170
|
+
import { existsSync as existsSync24, statSync as statSync11, readdirSync as readdirSync12 } from "fs";
|
|
18171
|
+
import { join as join22, extname as extname3, resolve as resolve7, basename as basename8 } from "path";
|
|
18172
|
+
import { readFileSync as readFileSync20 } from "fs";
|
|
18046
18173
|
|
|
18047
18174
|
// src/ingest/markdown-parser.ts
|
|
18048
|
-
import { readFileSync as
|
|
18175
|
+
import { readFileSync as readFileSync14 } from "fs";
|
|
18049
18176
|
import { basename as basename3 } from "path";
|
|
18050
18177
|
function parseMarkdown(filePath) {
|
|
18051
|
-
const raw =
|
|
18178
|
+
const raw = readFileSync14(filePath, "utf-8");
|
|
18052
18179
|
return parseMarkdownContent(raw, basename3(filePath));
|
|
18053
18180
|
}
|
|
18054
18181
|
function parseMarkdownContent(content, title = null) {
|
|
@@ -18172,7 +18299,7 @@ function parseMarkdownContent(content, title = null) {
|
|
|
18172
18299
|
};
|
|
18173
18300
|
}
|
|
18174
18301
|
function parseTxt(filePath) {
|
|
18175
|
-
const raw =
|
|
18302
|
+
const raw = readFileSync14(filePath, "utf-8");
|
|
18176
18303
|
const paragraphs = raw.split(/\n\n+/).filter((p) => p.trim().length > 0);
|
|
18177
18304
|
const sections = paragraphs.map((para) => ({
|
|
18178
18305
|
heading: null,
|
|
@@ -18191,7 +18318,7 @@ function parseTxt(filePath) {
|
|
|
18191
18318
|
};
|
|
18192
18319
|
}
|
|
18193
18320
|
function parseCode(filePath) {
|
|
18194
|
-
const raw =
|
|
18321
|
+
const raw = readFileSync14(filePath, "utf-8");
|
|
18195
18322
|
const ext = filePath.split(".").pop() || "";
|
|
18196
18323
|
const langMap = {
|
|
18197
18324
|
ts: "typescript",
|
|
@@ -18242,7 +18369,7 @@ function parseCode(filePath) {
|
|
|
18242
18369
|
}
|
|
18243
18370
|
|
|
18244
18371
|
// src/ingest/pdf-parser.ts
|
|
18245
|
-
import { readFileSync as
|
|
18372
|
+
import { readFileSync as readFileSync15 } from "fs";
|
|
18246
18373
|
import { basename as basename4 } from "path";
|
|
18247
18374
|
async function parsePdf(filePath) {
|
|
18248
18375
|
let text;
|
|
@@ -18252,7 +18379,7 @@ async function parsePdf(filePath) {
|
|
|
18252
18379
|
const pdfParseModule = "pdf-parse";
|
|
18253
18380
|
const mod = await import(pdfParseModule);
|
|
18254
18381
|
const { PDFParse } = mod;
|
|
18255
|
-
const buffer =
|
|
18382
|
+
const buffer = readFileSync15(filePath);
|
|
18256
18383
|
const parser = new PDFParse({ data: new Uint8Array(buffer) });
|
|
18257
18384
|
try {
|
|
18258
18385
|
const textResult = await parser.getText();
|
|
@@ -18382,8 +18509,8 @@ function isLikelyHeading(line) {
|
|
|
18382
18509
|
}
|
|
18383
18510
|
|
|
18384
18511
|
// src/ingest/slack-parser.ts
|
|
18385
|
-
import { existsSync as
|
|
18386
|
-
import { join as
|
|
18512
|
+
import { existsSync as existsSync19, readFileSync as readFileSync16, readdirSync as readdirSync9 } from "fs";
|
|
18513
|
+
import { join as join18, basename as basename5 } from "path";
|
|
18387
18514
|
|
|
18388
18515
|
// src/ingest/chat-utils.ts
|
|
18389
18516
|
var TIME_GAP_MS = 30 * 60 * 1000;
|
|
@@ -18477,11 +18604,11 @@ function parseSlackExport(dirPath, options) {
|
|
|
18477
18604
|
}
|
|
18478
18605
|
function loadUsers(dirPath) {
|
|
18479
18606
|
const usersMap = new Map;
|
|
18480
|
-
const usersPath =
|
|
18481
|
-
if (!
|
|
18607
|
+
const usersPath = join18(dirPath, "users.json");
|
|
18608
|
+
if (!existsSync19(usersPath))
|
|
18482
18609
|
return usersMap;
|
|
18483
18610
|
try {
|
|
18484
|
-
const raw = JSON.parse(
|
|
18611
|
+
const raw = JSON.parse(readFileSync16(usersPath, "utf-8"));
|
|
18485
18612
|
if (!Array.isArray(raw))
|
|
18486
18613
|
return usersMap;
|
|
18487
18614
|
const users_arr = raw.filter((u) => typeof u === "object" && u !== null && ("id" in u) && ("name" in u));
|
|
@@ -18494,11 +18621,11 @@ function loadUsers(dirPath) {
|
|
|
18494
18621
|
}
|
|
18495
18622
|
function loadChannels(dirPath) {
|
|
18496
18623
|
const channelsMap = new Map;
|
|
18497
|
-
const channelsPath =
|
|
18498
|
-
if (!
|
|
18624
|
+
const channelsPath = join18(dirPath, "channels.json");
|
|
18625
|
+
if (!existsSync19(channelsPath))
|
|
18499
18626
|
return channelsMap;
|
|
18500
18627
|
try {
|
|
18501
|
-
const raw = JSON.parse(
|
|
18628
|
+
const raw = JSON.parse(readFileSync16(channelsPath, "utf-8"));
|
|
18502
18629
|
if (!Array.isArray(raw))
|
|
18503
18630
|
return channelsMap;
|
|
18504
18631
|
const channels_arr = raw.filter((c) => typeof c === "object" && c !== null && ("id" in c) && ("name" in c));
|
|
@@ -18516,7 +18643,7 @@ function findChannelDirs(dirPath) {
|
|
|
18516
18643
|
continue;
|
|
18517
18644
|
if (entry.name.startsWith("."))
|
|
18518
18645
|
continue;
|
|
18519
|
-
const fullPath =
|
|
18646
|
+
const fullPath = join18(dirPath, entry.name);
|
|
18520
18647
|
const files = readdirSync9(fullPath);
|
|
18521
18648
|
if (files.some((f) => f.endsWith(".json"))) {
|
|
18522
18649
|
dirs.push(fullPath);
|
|
@@ -18529,7 +18656,7 @@ function loadChannelMessages(channelDir) {
|
|
|
18529
18656
|
const messages = [];
|
|
18530
18657
|
for (const file of files) {
|
|
18531
18658
|
try {
|
|
18532
|
-
const raw = JSON.parse(
|
|
18659
|
+
const raw = JSON.parse(readFileSync16(join18(channelDir, file), "utf-8"));
|
|
18533
18660
|
if (Array.isArray(raw)) {
|
|
18534
18661
|
messages.push(...raw);
|
|
18535
18662
|
}
|
|
@@ -18653,8 +18780,8 @@ function resolveUserMentions(text, users) {
|
|
|
18653
18780
|
}
|
|
18654
18781
|
|
|
18655
18782
|
// src/ingest/discord-parser.ts
|
|
18656
|
-
import { readFileSync as
|
|
18657
|
-
import { join as
|
|
18783
|
+
import { readFileSync as readFileSync17, readdirSync as readdirSync10, statSync as statSync8 } from "fs";
|
|
18784
|
+
import { join as join19, extname } from "path";
|
|
18658
18785
|
var SKIP_TYPES = new Set([
|
|
18659
18786
|
"RecipientAdd",
|
|
18660
18787
|
"RecipientRemove",
|
|
@@ -18675,7 +18802,7 @@ var SKIP_TYPES = new Set([
|
|
|
18675
18802
|
"ApplicationCommand"
|
|
18676
18803
|
]);
|
|
18677
18804
|
function parseDiscordExport(path, options) {
|
|
18678
|
-
const stat =
|
|
18805
|
+
const stat = statSync8(path);
|
|
18679
18806
|
const exports = [];
|
|
18680
18807
|
if (stat.isFile() && extname(path).toLowerCase() === ".json") {
|
|
18681
18808
|
const parsed = loadExportFile(path);
|
|
@@ -18684,7 +18811,7 @@ function parseDiscordExport(path, options) {
|
|
|
18684
18811
|
} else if (stat.isDirectory()) {
|
|
18685
18812
|
const files = readdirSync10(path).filter((f) => f.endsWith(".json")).sort();
|
|
18686
18813
|
for (const file of files) {
|
|
18687
|
-
const parsed = loadExportFile(
|
|
18814
|
+
const parsed = loadExportFile(join19(path, file));
|
|
18688
18815
|
if (parsed)
|
|
18689
18816
|
exports.push(parsed);
|
|
18690
18817
|
}
|
|
@@ -18744,7 +18871,7 @@ function isDiscordMessageShape(m) {
|
|
|
18744
18871
|
}
|
|
18745
18872
|
function loadExportFile(filePath) {
|
|
18746
18873
|
try {
|
|
18747
|
-
const raw = JSON.parse(
|
|
18874
|
+
const raw = JSON.parse(readFileSync17(filePath, "utf-8"));
|
|
18748
18875
|
if (raw && Array.isArray(raw.messages) && (raw.messages.length === 0 || isDiscordMessageShape(raw.messages[0]))) {
|
|
18749
18876
|
return raw;
|
|
18750
18877
|
}
|
|
@@ -18879,19 +19006,19 @@ function threadToSection2(thread, channelName) {
|
|
|
18879
19006
|
}
|
|
18880
19007
|
|
|
18881
19008
|
// src/ingest/code-parser.ts
|
|
18882
|
-
import { existsSync as
|
|
18883
|
-
import { join as
|
|
19009
|
+
import { existsSync as existsSync22, readFileSync as readFileSync18, readdirSync as readdirSync11, statSync as statSync9 } from "fs";
|
|
19010
|
+
import { join as join20, basename as basename7, extname as extname2, relative } from "path";
|
|
18884
19011
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
18885
19012
|
|
|
18886
19013
|
// src/ingest/git-utils.ts
|
|
18887
|
-
import { existsSync as
|
|
19014
|
+
import { existsSync as existsSync21 } from "fs";
|
|
18888
19015
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
18889
19016
|
function findGit() {
|
|
18890
19017
|
const isWindows = process.platform === "win32";
|
|
18891
19018
|
if (!isWindows) {
|
|
18892
19019
|
const candidates = ["/usr/bin/git", "/usr/local/bin/git", "/opt/homebrew/bin/git"];
|
|
18893
19020
|
for (const candidate of candidates) {
|
|
18894
|
-
if (
|
|
19021
|
+
if (existsSync21(candidate))
|
|
18895
19022
|
return candidate;
|
|
18896
19023
|
}
|
|
18897
19024
|
}
|
|
@@ -18903,7 +19030,7 @@ function findGit() {
|
|
|
18903
19030
|
windowsHide: true
|
|
18904
19031
|
});
|
|
18905
19032
|
const path = result.trim().split(/\r?\n/)[0];
|
|
18906
|
-
if (path &&
|
|
19033
|
+
if (path && existsSync21(path))
|
|
18907
19034
|
return path;
|
|
18908
19035
|
} catch {}
|
|
18909
19036
|
return null;
|
|
@@ -19012,7 +19139,7 @@ function parseCodeRepository(repoPath, options) {
|
|
|
19012
19139
|
sections.push(section);
|
|
19013
19140
|
totalChars += section.content.length;
|
|
19014
19141
|
}
|
|
19015
|
-
if (includeGitLog &&
|
|
19142
|
+
if (includeGitLog && existsSync22(join20(repoPath, ".git"))) {
|
|
19016
19143
|
const gitSections = parseGitLog(repoPath, gitLogDepth);
|
|
19017
19144
|
for (const section of gitSections) {
|
|
19018
19145
|
sections.push(section);
|
|
@@ -19070,9 +19197,9 @@ function countExtensions(dirPath, counts, depth) {
|
|
|
19070
19197
|
continue;
|
|
19071
19198
|
if (SKIP_DIRS.has(name))
|
|
19072
19199
|
continue;
|
|
19073
|
-
const fullPath =
|
|
19200
|
+
const fullPath = join20(dirPath, name);
|
|
19074
19201
|
try {
|
|
19075
|
-
const stat =
|
|
19202
|
+
const stat = statSync9(fullPath);
|
|
19076
19203
|
if (stat.isDirectory()) {
|
|
19077
19204
|
countExtensions(fullPath, counts, depth + 1);
|
|
19078
19205
|
} else if (stat.isFile()) {
|
|
@@ -19101,16 +19228,16 @@ function buildLanguageSection(languages) {
|
|
|
19101
19228
|
function parseImportantFiles(repoPath) {
|
|
19102
19229
|
const sections = [];
|
|
19103
19230
|
for (const fileName of IMPORTANT_FILES) {
|
|
19104
|
-
const filePath =
|
|
19105
|
-
if (!
|
|
19231
|
+
const filePath = join20(repoPath, fileName);
|
|
19232
|
+
if (!existsSync22(filePath))
|
|
19106
19233
|
continue;
|
|
19107
19234
|
try {
|
|
19108
|
-
const stat =
|
|
19235
|
+
const stat = statSync9(filePath);
|
|
19109
19236
|
if (!stat.isFile())
|
|
19110
19237
|
continue;
|
|
19111
19238
|
if (stat.size > MAX_FILE_CHARS)
|
|
19112
19239
|
continue;
|
|
19113
|
-
const content =
|
|
19240
|
+
const content = readFileSync18(filePath, "utf-8").slice(0, MAX_FILE_CHARS);
|
|
19114
19241
|
const lowerName = fileName.toLowerCase();
|
|
19115
19242
|
if (lowerName.endsWith(".json")) {
|
|
19116
19243
|
const section = parseJsonConfig(fileName, content);
|
|
@@ -19367,9 +19494,9 @@ function scanDefinitions(dirPath, extensions, depth) {
|
|
|
19367
19494
|
continue;
|
|
19368
19495
|
if (SKIP_DIRS.has(name))
|
|
19369
19496
|
continue;
|
|
19370
|
-
const fullPath =
|
|
19497
|
+
const fullPath = join20(dirPath, name);
|
|
19371
19498
|
try {
|
|
19372
|
-
const stat =
|
|
19499
|
+
const stat = statSync9(fullPath);
|
|
19373
19500
|
if (stat.isDirectory()) {
|
|
19374
19501
|
definitions.push(...scanDefinitions(fullPath, extensions, depth + 1));
|
|
19375
19502
|
} else if (stat.isFile()) {
|
|
@@ -19378,7 +19505,7 @@ function scanDefinitions(dirPath, extensions, depth) {
|
|
|
19378
19505
|
continue;
|
|
19379
19506
|
if (stat.size > MAX_FILE_CHARS)
|
|
19380
19507
|
continue;
|
|
19381
|
-
const content =
|
|
19508
|
+
const content = readFileSync18(fullPath, "utf-8");
|
|
19382
19509
|
const fileDefs = extractDefinitions(fullPath, content, ext);
|
|
19383
19510
|
definitions.push(...fileDefs);
|
|
19384
19511
|
}
|
|
@@ -19515,13 +19642,13 @@ function groupDefinitionsByFile(definitions, repoPath) {
|
|
|
19515
19642
|
}
|
|
19516
19643
|
|
|
19517
19644
|
// src/ingest/entire-parser.ts
|
|
19518
|
-
import { existsSync as
|
|
19519
|
-
import { join as
|
|
19645
|
+
import { existsSync as existsSync23 } from "fs";
|
|
19646
|
+
import { join as join21 } from "path";
|
|
19520
19647
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
19521
19648
|
var ENTIRE_BRANCH = "entire/checkpoints/v1";
|
|
19522
19649
|
var MAX_TRANSCRIPT_CHARS = 200000;
|
|
19523
19650
|
function hasEntireBranch(repoPath) {
|
|
19524
|
-
if (!
|
|
19651
|
+
if (!existsSync23(join21(repoPath, ".git"))) {
|
|
19525
19652
|
return false;
|
|
19526
19653
|
}
|
|
19527
19654
|
try {
|
|
@@ -20496,10 +20623,10 @@ function parseExtractionResponse2(raw, minConfidence) {
|
|
|
20496
20623
|
|
|
20497
20624
|
// src/ingest/provenance.ts
|
|
20498
20625
|
import { createHash as createHash2 } from "crypto";
|
|
20499
|
-
import { readFileSync as
|
|
20626
|
+
import { readFileSync as readFileSync19, statSync as statSync10 } from "fs";
|
|
20500
20627
|
function computeFileHash(filePath) {
|
|
20501
20628
|
try {
|
|
20502
|
-
const content =
|
|
20629
|
+
const content = readFileSync19(filePath);
|
|
20503
20630
|
return createHash2("sha256").update(content).digest("hex");
|
|
20504
20631
|
} catch {
|
|
20505
20632
|
return createHash2("sha256").update(filePath).digest("hex");
|
|
@@ -20623,9 +20750,9 @@ function isSlackExport(dirPath) {
|
|
|
20623
20750
|
return false;
|
|
20624
20751
|
}
|
|
20625
20752
|
for (const entry of entries) {
|
|
20626
|
-
const fullPath =
|
|
20753
|
+
const fullPath = join22(dirPath, entry);
|
|
20627
20754
|
try {
|
|
20628
|
-
if (
|
|
20755
|
+
if (statSync11(fullPath).isDirectory() && !entry.startsWith(".")) {
|
|
20629
20756
|
const subFiles = readdirSync12(fullPath);
|
|
20630
20757
|
if (subFiles.some((f) => f.endsWith(".json")))
|
|
20631
20758
|
return true;
|
|
@@ -20639,20 +20766,20 @@ function isSlackExport(dirPath) {
|
|
|
20639
20766
|
}
|
|
20640
20767
|
function isDiscordExport(filePath) {
|
|
20641
20768
|
try {
|
|
20642
|
-
const stat =
|
|
20769
|
+
const stat = statSync11(filePath);
|
|
20643
20770
|
if (stat.isFile() && extname3(filePath).toLowerCase() === ".json") {
|
|
20644
|
-
const raw =
|
|
20771
|
+
const raw = readFileSync20(filePath, "utf-8").slice(0, 4096);
|
|
20645
20772
|
return (raw.includes('"guild"') || raw.includes('"channel"')) && raw.includes('"messages"');
|
|
20646
20773
|
}
|
|
20647
20774
|
if (stat.isDirectory()) {
|
|
20648
20775
|
const entries = readdirSync12(filePath);
|
|
20649
20776
|
if (entries.includes("index.json")) {
|
|
20650
|
-
const indexContent =
|
|
20777
|
+
const indexContent = readFileSync20(join22(filePath, "index.json"), "utf-8").slice(0, 2048);
|
|
20651
20778
|
return indexContent.includes('"guild"') || indexContent.includes('"channel"');
|
|
20652
20779
|
}
|
|
20653
20780
|
const jsonFile = entries.find((f) => f.endsWith(".json"));
|
|
20654
20781
|
if (jsonFile) {
|
|
20655
|
-
const content =
|
|
20782
|
+
const content = readFileSync20(join22(filePath, jsonFile), "utf-8").slice(0, 4096);
|
|
20656
20783
|
return (content.includes('"guild"') || content.includes('"channel"')) && content.includes('"messages"');
|
|
20657
20784
|
}
|
|
20658
20785
|
}
|
|
@@ -20662,14 +20789,14 @@ function isDiscordExport(filePath) {
|
|
|
20662
20789
|
}
|
|
20663
20790
|
}
|
|
20664
20791
|
function isGitRepo(dirPath) {
|
|
20665
|
-
return
|
|
20792
|
+
return existsSync24(join22(dirPath, ".git"));
|
|
20666
20793
|
}
|
|
20667
20794
|
function collectFiles(inputPath, forcedType) {
|
|
20668
|
-
const absPath =
|
|
20669
|
-
if (!
|
|
20795
|
+
const absPath = resolve7(inputPath);
|
|
20796
|
+
if (!existsSync24(absPath)) {
|
|
20670
20797
|
throw new Error(`Path does not exist: ${absPath}`);
|
|
20671
20798
|
}
|
|
20672
|
-
const stat =
|
|
20799
|
+
const stat = statSync11(absPath);
|
|
20673
20800
|
if (forcedType === "slack" || forcedType === "discord" || forcedType === "repo" || forcedType === "entire") {
|
|
20674
20801
|
return [{ path: absPath, type: forcedType }];
|
|
20675
20802
|
}
|
|
@@ -20703,7 +20830,7 @@ function collectDirectory(dirPath, forcedType) {
|
|
|
20703
20830
|
const files = [];
|
|
20704
20831
|
const entries = readdirSync12(dirPath, { withFileTypes: true });
|
|
20705
20832
|
for (const entry of entries) {
|
|
20706
|
-
const fullPath =
|
|
20833
|
+
const fullPath = join22(dirPath, entry.name);
|
|
20707
20834
|
if (entry.name.startsWith(".") || SKIP_FILES.has(entry.name))
|
|
20708
20835
|
continue;
|
|
20709
20836
|
if (entry.isDirectory()) {
|
|
@@ -20853,7 +20980,7 @@ async function ingestPath(inputPath, options = {}, provider, onProgress) {
|
|
|
20853
20980
|
var MAX_INGEST_FILE_BYTES = 50 * 1024 * 1024;
|
|
20854
20981
|
async function ingestSingleFile(filePath, fileType, provider, extractionOpts, options, onProgress) {
|
|
20855
20982
|
try {
|
|
20856
|
-
const fileStat =
|
|
20983
|
+
const fileStat = statSync11(filePath);
|
|
20857
20984
|
if (fileStat.isFile() && fileStat.size > MAX_INGEST_FILE_BYTES) {
|
|
20858
20985
|
const sizeMB = Math.round(fileStat.size / (1024 * 1024));
|
|
20859
20986
|
console.warn(`[ingest] Skipping ${filePath}: file size ${sizeMB} MB exceeds ${MAX_INGEST_FILE_BYTES / (1024 * 1024)} MB limit`);
|
|
@@ -20983,6 +21110,7 @@ var DEFAULT_APP_SIZE = { w: 4, h: 3 };
|
|
|
20983
21110
|
export {
|
|
20984
21111
|
writeRegistry,
|
|
20985
21112
|
writeGraphiqState,
|
|
21113
|
+
writeConfiguredWorkspacePath,
|
|
20986
21114
|
writeConfiguredPiAgentDir,
|
|
20987
21115
|
writeConfiguredOhMyPiAgentDir,
|
|
20988
21116
|
withHookRecallCompat,
|
|
@@ -21006,6 +21134,7 @@ export {
|
|
|
21006
21134
|
saveSourcesConfig,
|
|
21007
21135
|
runMigrations,
|
|
21008
21136
|
resolveWorkspaceSourceRepoPath,
|
|
21137
|
+
resolveWorkspacePath,
|
|
21009
21138
|
resolveStartupIdentityFiles,
|
|
21010
21139
|
resolveSpecialIdentityFiles,
|
|
21011
21140
|
resolveSignetDaemonUrl,
|
|
@@ -21035,6 +21164,7 @@ export {
|
|
|
21035
21164
|
readNetworkMode,
|
|
21036
21165
|
readMemoriesFtsSql,
|
|
21037
21166
|
readGraphiqState,
|
|
21167
|
+
readConfiguredWorkspacePath,
|
|
21038
21168
|
readConfiguredPiAgentDir,
|
|
21039
21169
|
readConfiguredOhMyPiAgentDir,
|
|
21040
21170
|
partitionRecallRows,
|
|
@@ -21053,6 +21183,7 @@ export {
|
|
|
21053
21183
|
parseGitHubSettings,
|
|
21054
21184
|
parseDiscordSettings,
|
|
21055
21185
|
packageManagerRemovalCommand,
|
|
21186
|
+
normalizeWorkspacePath,
|
|
21056
21187
|
normalizeStructuredMemoryPayload,
|
|
21057
21188
|
normalizeNetworkMode,
|
|
21058
21189
|
normalizeAgentRosterEntry,
|
|
@@ -21092,6 +21223,7 @@ export {
|
|
|
21092
21223
|
hasValidIdentity,
|
|
21093
21224
|
hasSignetBlock,
|
|
21094
21225
|
hasPendingMigrations,
|
|
21226
|
+
getWorkspaceConfigPath,
|
|
21095
21227
|
getSourcesConfigPath,
|
|
21096
21228
|
getSkillsRunnerCommand,
|
|
21097
21229
|
getPiConfigPath,
|
|
@@ -21127,6 +21259,7 @@ export {
|
|
|
21127
21259
|
cosineSimilarity,
|
|
21128
21260
|
compileLegacyRoutingConfig,
|
|
21129
21261
|
collectExportData,
|
|
21262
|
+
clearConfiguredWorkspacePath,
|
|
21130
21263
|
clearConfiguredPiAgentDir,
|
|
21131
21264
|
clearConfiguredOhMyPiAgentDir,
|
|
21132
21265
|
chunkMarkdownHierarchically,
|
|
@@ -21142,6 +21275,7 @@ export {
|
|
|
21142
21275
|
addObsidianSource,
|
|
21143
21276
|
addGitHubSource,
|
|
21144
21277
|
addDiscordSource,
|
|
21278
|
+
WORKSPACE_ENV_KEYS,
|
|
21145
21279
|
UNIFIED_SCHEMA,
|
|
21146
21280
|
TASK_STATUSES,
|
|
21147
21281
|
TASK_HARNESSES,
|