@yukino.js/yukino 0.0.11 → 0.0.13-dev
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/README.md +111 -68
- package/dist/a2a-DG2JNM3U.js +14 -0
- package/dist/acp-DCZDS6FQ.js +14 -0
- package/dist/anthropic-5BTWVZVT.js +4 -0
- package/dist/chunk-4CLD7LEU.js +5 -0
- package/dist/{chunk-QMHSZVNF.js → chunk-5DK2M7VI.js} +1 -1
- package/dist/chunk-5URXBVET.js +4 -0
- package/dist/{chunk-3VTVI62N.js → chunk-AZQD75PX.js} +1 -1
- package/dist/{chunk-WH5FUZXY.js → chunk-BDLFNDC4.js} +3 -3
- package/dist/{chunk-TPEUG7AU.js → chunk-COHBT6M7.js} +161 -155
- package/dist/chunk-CW5XFH7H.js +59 -0
- package/dist/{chunk-YWTRNPNR.js → chunk-IWMCIYOG.js} +21 -21
- package/dist/chunk-OI2W6R6H.js +28 -0
- package/dist/chunk-SZXXASVH.js +4 -0
- package/dist/chunk-UGX62ZSO.js +4 -0
- package/dist/chunk-W4GMCNWF.js +65 -0
- package/dist/lib/{anthropic-7HQY42TP.js → anthropic-AVZIC22O.js} +5 -5
- package/dist/lib/bwrap-JS5GRKWY.js +7 -0
- package/dist/lib/{chunk-QQ2V5EX3.js → chunk-EGJKLA2W.js} +3 -3
- package/dist/lib/{chunk-AUU4RKMV.js → chunk-GVI5R2DA.js} +47 -29
- package/dist/lib/{chunk-XDGZMZ2B.js → chunk-LSI3T24Q.js} +2 -2
- package/dist/lib/{chunk-EATSQNOB.js → chunk-O2H6VKKR.js} +3 -3
- package/dist/lib/{chunk-55LKYMVV.js → chunk-OFDOP6I2.js} +2 -2
- package/dist/lib/{chunk-JXZ5KIUV.js → chunk-PCZ63WQL.js} +1 -1
- package/dist/lib/{chunk-Q6B6TAR3.js → chunk-QJ32WYQY.js} +120 -152
- package/dist/lib/{chunk-VXHBKGZW.js → chunk-TUNZLQLO.js} +12 -13
- package/dist/lib/{chunk-OCGX3ISG.js → chunk-XH7D5FLE.js} +4 -4
- package/dist/lib/{chunk-KC54MV5H.js → chunk-XLRV26YW.js} +1 -1
- package/dist/lib/index.d.ts +380 -351
- package/dist/lib/index.js +925 -638
- package/dist/lib/{openai-Z7PCXN2X.js → openai-54IQOU6Y.js} +4 -4
- package/dist/lib/{providers-GOU5DD3X.js → providers-MOCB6Y5L.js} +3 -3
- package/dist/lib/seatbelt-LDM6UB6N.js +7 -0
- package/dist/lib/{tool-filter-GVVYY5QO.js → tool-filter-5Z6UTRRR.js} +4 -4
- package/dist/main-IA22XMQR.js +494 -0
- package/dist/main.js +2 -487
- package/dist/{openai-WNPMC64P.js → openai-I2TTMBWK.js} +1 -1
- package/dist/providers-DXQRJUIY.js +4 -0
- package/dist/server-QS7CX37F.js +4 -0
- package/dist/tool-filter-KDQMXIDC.js +4 -0
- package/package.json +2 -2
- package/dist/a2a-WKGEGTP6.js +0 -14
- package/dist/acp-W2I7T2NT.js +0 -14
- package/dist/anthropic-CQUMQFUK.js +0 -4
- package/dist/chunk-CH7VZVG4.js +0 -4
- package/dist/chunk-F6WFTAOT.js +0 -59
- package/dist/chunk-R567WVDL.js +0 -90
- package/dist/chunk-ZPL2YHQU.js +0 -5
- package/dist/lib/bwrap-V6MFP7PT.js +0 -7
- package/dist/lib/seatbelt-2OE46ZE7.js +0 -7
- package/dist/providers-CMCKMYGG.js +0 -4
- package/dist/server-OQ5XVSZY.js +0 -4
- package/dist/tool-filter-BTQ7WTHR.js +0 -4
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
MCP_TOOL_PREFIX,
|
|
3
3
|
McpCallTool,
|
|
4
4
|
mcpCallPermissionContent
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-LSI3T24Q.js";
|
|
6
6
|
import {
|
|
7
7
|
asErrorString,
|
|
8
8
|
asRecord,
|
|
@@ -11,15 +11,19 @@ import {
|
|
|
11
11
|
intArg,
|
|
12
12
|
isObject,
|
|
13
13
|
isRecord,
|
|
14
|
+
projectKey,
|
|
15
|
+
projectPath,
|
|
14
16
|
sanitizeNameSegment,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
sessionPath,
|
|
18
|
+
strArg,
|
|
19
|
+
yukinoPath
|
|
20
|
+
} from "./chunk-GVI5R2DA.js";
|
|
17
21
|
import {
|
|
18
22
|
__export,
|
|
19
23
|
canonicalPath,
|
|
20
24
|
isPathWithin,
|
|
21
25
|
resolveToolPath
|
|
22
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-OFDOP6I2.js";
|
|
23
27
|
|
|
24
28
|
// src/subagent/tool-filter.ts
|
|
25
29
|
var tool_filter_exports = {};
|
|
@@ -47,7 +51,6 @@ __export(loader_exports, {
|
|
|
47
51
|
loadAgentDefinitions: () => loadAgentDefinitions
|
|
48
52
|
});
|
|
49
53
|
import { readdirSync, readFileSync, existsSync } from "fs";
|
|
50
|
-
import { homedir } from "os";
|
|
51
54
|
import { join } from "path";
|
|
52
55
|
import yaml from "js-yaml";
|
|
53
56
|
import z, { parse } from "zod";
|
|
@@ -78,16 +81,9 @@ var BUILTIN_AGENTS = [
|
|
|
78
81
|
|
|
79
82
|
// src/subagent/loader.ts
|
|
80
83
|
var log = createChildLogger({ module: "subagent" });
|
|
81
|
-
function loadAgentDefinitions(
|
|
84
|
+
function loadAgentDefinitions() {
|
|
82
85
|
const definitions = [...BUILTIN_AGENTS];
|
|
83
|
-
|
|
84
|
-
if (home) {
|
|
85
|
-
loadDir(join(home, ".yukino", "agents"), definitions);
|
|
86
|
-
}
|
|
87
|
-
const dirs = [join(workDir, ".yukino", "agents")];
|
|
88
|
-
for (const dir of dirs) {
|
|
89
|
-
loadDir(dir, definitions);
|
|
90
|
-
}
|
|
86
|
+
loadDir(yukinoPath("agents"), definitions);
|
|
91
87
|
return definitions;
|
|
92
88
|
}
|
|
93
89
|
function loadDir(dir, definitions) {
|
|
@@ -417,7 +413,7 @@ import {
|
|
|
417
413
|
rmSync,
|
|
418
414
|
statSync as statSync2
|
|
419
415
|
} from "fs";
|
|
420
|
-
import {
|
|
416
|
+
import { tmpdir } from "os";
|
|
421
417
|
import { join as join3, resolve as resolve2, dirname } from "path";
|
|
422
418
|
import yaml2 from "js-yaml";
|
|
423
419
|
import z3, { parse as parse2 } from "zod";
|
|
@@ -1032,9 +1028,9 @@ var RuleEngine = class {
|
|
|
1032
1028
|
userPath;
|
|
1033
1029
|
projectPath;
|
|
1034
1030
|
cache = /* @__PURE__ */ new Map();
|
|
1035
|
-
constructor(
|
|
1036
|
-
this.userPath =
|
|
1037
|
-
this.projectPath =
|
|
1031
|
+
constructor(cwd) {
|
|
1032
|
+
this.userPath = yukinoPath("permissions.yaml");
|
|
1033
|
+
this.projectPath = projectPath(cwd, "permissions.yaml");
|
|
1038
1034
|
}
|
|
1039
1035
|
// Read a single rules file; skips re-reading and parsing on cache hit.
|
|
1040
1036
|
rulesFor(path) {
|
|
@@ -1124,18 +1120,18 @@ function modeDecide(mode, category) {
|
|
|
1124
1120
|
}
|
|
1125
1121
|
}
|
|
1126
1122
|
var PermissionChecker = class _PermissionChecker {
|
|
1127
|
-
constructor(
|
|
1128
|
-
this.
|
|
1123
|
+
constructor(cwd, mode = "default", modeSource) {
|
|
1124
|
+
this.cwd = cwd;
|
|
1129
1125
|
this.modeState = {
|
|
1130
1126
|
value: mode,
|
|
1131
1127
|
delegatedValue: mode === "plan" ? "default" : mode,
|
|
1132
1128
|
source: modeSource,
|
|
1133
1129
|
listeners: /* @__PURE__ */ new Set()
|
|
1134
1130
|
};
|
|
1135
|
-
this.sandbox = new PathSandbox(
|
|
1136
|
-
this.ruleEngine = new RuleEngine(
|
|
1131
|
+
this.sandbox = new PathSandbox(cwd);
|
|
1132
|
+
this.ruleEngine = new RuleEngine(cwd);
|
|
1137
1133
|
}
|
|
1138
|
-
|
|
1134
|
+
cwd;
|
|
1139
1135
|
modeState;
|
|
1140
1136
|
delegated = false;
|
|
1141
1137
|
planModeLocked = false;
|
|
@@ -1175,8 +1171,8 @@ var PermissionChecker = class _PermissionChecker {
|
|
|
1175
1171
|
this.modeState.listeners.delete(listener);
|
|
1176
1172
|
};
|
|
1177
1173
|
}
|
|
1178
|
-
|
|
1179
|
-
const checker = new _PermissionChecker(
|
|
1174
|
+
forCwd(cwd) {
|
|
1175
|
+
const checker = new _PermissionChecker(cwd, this.mode);
|
|
1180
1176
|
checker.modeState = this.modeState;
|
|
1181
1177
|
checker.delegated = this.delegated;
|
|
1182
1178
|
checker.planModeLocked = this.planModeLocked;
|
|
@@ -1187,8 +1183,8 @@ var PermissionChecker = class _PermissionChecker {
|
|
|
1187
1183
|
checker.sandboxAutoAllow = this.sandboxAutoAllow;
|
|
1188
1184
|
return checker;
|
|
1189
1185
|
}
|
|
1190
|
-
forSubagent(
|
|
1191
|
-
const checker = this.
|
|
1186
|
+
forSubagent(cwd) {
|
|
1187
|
+
const checker = this.forCwd(cwd);
|
|
1192
1188
|
checker.delegated = true;
|
|
1193
1189
|
if (!this.teammate) {
|
|
1194
1190
|
checker.planFilePath = "";
|
|
@@ -1199,7 +1195,7 @@ var PermissionChecker = class _PermissionChecker {
|
|
|
1199
1195
|
const content = extractContent(toolName, args);
|
|
1200
1196
|
const coordination = this.teammate && TEAMMATE_COORDINATION_TOOLS.has(toolName);
|
|
1201
1197
|
const filePath = strArg(args, "file_path", strArg(args, "path", ""));
|
|
1202
|
-
const planFileWrite = this.mode === "plan" && (toolName === "WriteFile" || toolName === "EditFile") && !!this.planFilePath && canonicalPath(resolveToolPath(this.
|
|
1198
|
+
const planFileWrite = this.mode === "plan" && (toolName === "WriteFile" || toolName === "EditFile") && !!this.planFilePath && canonicalPath(resolveToolPath(this.cwd, filePath)) === canonicalPath(resolveToolPath(this.cwd, this.planFilePath));
|
|
1203
1199
|
if (this.planModeLocked && category !== "read" && !coordination && !planFileWrite && !(category === "command" && isSafeCommand(content))) {
|
|
1204
1200
|
return {
|
|
1205
1201
|
effect: "deny",
|
|
@@ -1293,7 +1289,7 @@ var PermissionChecker = class _PermissionChecker {
|
|
|
1293
1289
|
const isFilePath = toolName === "ReadFile" || toolName === "WriteFile" || toolName === "EditFile";
|
|
1294
1290
|
let pattern;
|
|
1295
1291
|
if (isFilePath && content) {
|
|
1296
|
-
const abs = resolveToolPath(this.
|
|
1292
|
+
const abs = resolveToolPath(this.cwd, content);
|
|
1297
1293
|
let isDir = false;
|
|
1298
1294
|
try {
|
|
1299
1295
|
isDir = statSync2(abs).isDirectory();
|
|
@@ -1438,7 +1434,7 @@ import {
|
|
|
1438
1434
|
rmSync as rmSync2,
|
|
1439
1435
|
writeFileSync as writeFileSync3
|
|
1440
1436
|
} from "fs";
|
|
1441
|
-
import {
|
|
1437
|
+
import { dirname as dirname2 } from "path";
|
|
1442
1438
|
import z4, { parse as parse3 } from "zod";
|
|
1443
1439
|
var log4 = createChildLogger({ module: "todo" });
|
|
1444
1440
|
var StoredTaskStatusSchema = z4.enum([
|
|
@@ -1466,12 +1462,11 @@ var TaskSnapshotSchema = z4.object({
|
|
|
1466
1462
|
});
|
|
1467
1463
|
var TaskStore = class {
|
|
1468
1464
|
filePath;
|
|
1469
|
-
|
|
1470
|
-
constructor(workDir, listId) {
|
|
1465
|
+
constructor(listId) {
|
|
1471
1466
|
if (!/^[A-Za-z0-9_-]+$/u.test(listId)) {
|
|
1472
1467
|
throw new Error("Invalid task list ID");
|
|
1473
1468
|
}
|
|
1474
|
-
this.filePath =
|
|
1469
|
+
this.filePath = sessionPath(listId, "tasks.json");
|
|
1475
1470
|
}
|
|
1476
1471
|
load() {
|
|
1477
1472
|
if (!existsSync2(this.filePath)) {
|
|
@@ -2011,7 +2006,7 @@ __export(team_file_exports, {
|
|
|
2011
2006
|
teamsBaseDir: () => teamsBaseDir,
|
|
2012
2007
|
writeTeamFile: () => writeTeamFile
|
|
2013
2008
|
});
|
|
2014
|
-
import {
|
|
2009
|
+
import { randomBytes as randomBytes3 } from "crypto";
|
|
2015
2010
|
import {
|
|
2016
2011
|
existsSync as existsSync3,
|
|
2017
2012
|
mkdirSync as mkdirSync4,
|
|
@@ -2021,8 +2016,7 @@ import {
|
|
|
2021
2016
|
rmSync as rmSync3,
|
|
2022
2017
|
writeFileSync as writeFileSync4
|
|
2023
2018
|
} from "fs";
|
|
2024
|
-
import {
|
|
2025
|
-
import { dirname as dirname3, join as join5 } from "path";
|
|
2019
|
+
import { dirname as dirname3, join as join4 } from "path";
|
|
2026
2020
|
import z6 from "zod";
|
|
2027
2021
|
var TeamMemberEntrySchema = z6.object({
|
|
2028
2022
|
agentId: z6.string(),
|
|
@@ -2052,9 +2046,8 @@ var TeamFileSchema = z6.object({
|
|
|
2052
2046
|
leaderPid: z6.number().optional(),
|
|
2053
2047
|
members: z6.array(TeamMemberEntrySchema)
|
|
2054
2048
|
});
|
|
2055
|
-
function teamsBaseDir(
|
|
2056
|
-
|
|
2057
|
-
return join5(homedir3(), ".yukino", "teams", namespace);
|
|
2049
|
+
function teamsBaseDir(cwd) {
|
|
2050
|
+
return yukinoPath("teams", projectKey(cwd));
|
|
2058
2051
|
}
|
|
2059
2052
|
function sanitizeTeamName(name) {
|
|
2060
2053
|
if (!name.trim()) {
|
|
@@ -2062,21 +2055,21 @@ function sanitizeTeamName(name) {
|
|
|
2062
2055
|
}
|
|
2063
2056
|
return name.replace(/[^a-zA-Z0-9]/g, "-").toLowerCase();
|
|
2064
2057
|
}
|
|
2065
|
-
function teamDir(
|
|
2066
|
-
return
|
|
2058
|
+
function teamDir(cwd, name) {
|
|
2059
|
+
return join4(teamsBaseDir(cwd), sanitizeTeamName(name));
|
|
2067
2060
|
}
|
|
2068
|
-
function listTeamNames(
|
|
2061
|
+
function listTeamNames(cwd) {
|
|
2069
2062
|
try {
|
|
2070
|
-
return readdirSync3(teamsBaseDir(
|
|
2063
|
+
return readdirSync3(teamsBaseDir(cwd), { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
2071
2064
|
} catch {
|
|
2072
2065
|
return [];
|
|
2073
2066
|
}
|
|
2074
2067
|
}
|
|
2075
|
-
function teamConfigPath(
|
|
2076
|
-
return
|
|
2068
|
+
function teamConfigPath(cwd, name) {
|
|
2069
|
+
return join4(teamDir(cwd, name), "config.json");
|
|
2077
2070
|
}
|
|
2078
|
-
function readTeamFile(
|
|
2079
|
-
return readTeamFileAtPath(teamConfigPath(
|
|
2071
|
+
function readTeamFile(cwd, name) {
|
|
2072
|
+
return readTeamFileAtPath(teamConfigPath(cwd, name));
|
|
2080
2073
|
}
|
|
2081
2074
|
function readTeamFileAtPath(path) {
|
|
2082
2075
|
if (!existsSync3(path)) {
|
|
@@ -2089,8 +2082,8 @@ function readTeamFileAtPath(path) {
|
|
|
2089
2082
|
return null;
|
|
2090
2083
|
}
|
|
2091
2084
|
}
|
|
2092
|
-
function writeTeamFile(
|
|
2093
|
-
const path = teamConfigPath(
|
|
2085
|
+
function writeTeamFile(cwd, name, file, removedMembers = []) {
|
|
2086
|
+
const path = teamConfigPath(cwd, name);
|
|
2094
2087
|
try {
|
|
2095
2088
|
mkdirSync4(dirname3(path), { recursive: true });
|
|
2096
2089
|
withFileSyncLock(path, () => {
|
|
@@ -2447,7 +2440,7 @@ import {
|
|
|
2447
2440
|
stat,
|
|
2448
2441
|
symlink
|
|
2449
2442
|
} from "fs/promises";
|
|
2450
|
-
import { dirname as dirname4, isAbsolute, join as
|
|
2443
|
+
import { dirname as dirname4, isAbsolute, join as join5 } from "path";
|
|
2451
2444
|
import { promisify } from "util";
|
|
2452
2445
|
var log6 = createChildLogger({ module: "worktree" });
|
|
2453
2446
|
var execFileAsync = promisify(execFile);
|
|
@@ -2478,7 +2471,7 @@ async function pathExists(path) {
|
|
|
2478
2471
|
}
|
|
2479
2472
|
}
|
|
2480
2473
|
async function resolveGitDir(root) {
|
|
2481
|
-
const gitPath =
|
|
2474
|
+
const gitPath = join5(root, ".git");
|
|
2482
2475
|
if (!await pathExists(gitPath)) {
|
|
2483
2476
|
return "";
|
|
2484
2477
|
}
|
|
@@ -2491,13 +2484,13 @@ async function resolveGitDir(root) {
|
|
|
2491
2484
|
return "";
|
|
2492
2485
|
}
|
|
2493
2486
|
const rel = raw.slice("gitdir:".length).trim();
|
|
2494
|
-
return isAbsolute(rel) ? rel :
|
|
2487
|
+
return isAbsolute(rel) ? rel : join5(root, rel);
|
|
2495
2488
|
}
|
|
2496
2489
|
async function getCommonDir(gitDir) {
|
|
2497
2490
|
try {
|
|
2498
|
-
const commonDir =
|
|
2491
|
+
const commonDir = join5(gitDir, "commondir");
|
|
2499
2492
|
const raw = (await readFile(commonDir, "utf-8")).trim();
|
|
2500
|
-
return isAbsolute(raw) ? raw :
|
|
2493
|
+
return isAbsolute(raw) ? raw : join5(gitDir, raw);
|
|
2501
2494
|
} catch (err) {
|
|
2502
2495
|
log6.debug({ err }, "worktree commondir probe failed");
|
|
2503
2496
|
return "";
|
|
@@ -2506,7 +2499,7 @@ async function getCommonDir(gitDir) {
|
|
|
2506
2499
|
async function readGitHead(gitDir) {
|
|
2507
2500
|
let raw;
|
|
2508
2501
|
try {
|
|
2509
|
-
raw = (await readFile(
|
|
2502
|
+
raw = (await readFile(join5(gitDir, "HEAD"), "utf-8")).trim();
|
|
2510
2503
|
} catch (err) {
|
|
2511
2504
|
log6.error({ err }, "worktree operation failed");
|
|
2512
2505
|
return null;
|
|
@@ -2538,7 +2531,7 @@ async function resolveRefInDir(dir, ref, seen) {
|
|
|
2538
2531
|
}
|
|
2539
2532
|
seen.add(key);
|
|
2540
2533
|
try {
|
|
2541
|
-
const content = (await readFile(
|
|
2534
|
+
const content = (await readFile(join5(dir, ref), "utf-8")).trim();
|
|
2542
2535
|
if (content.startsWith("ref:")) {
|
|
2543
2536
|
const target = content.slice("ref:".length).trim();
|
|
2544
2537
|
if (!isSafeRefName(target)) {
|
|
@@ -2554,7 +2547,7 @@ async function resolveRefInDir(dir, ref, seen) {
|
|
|
2554
2547
|
log6.debug({ err }, "loose ref probe failed");
|
|
2555
2548
|
}
|
|
2556
2549
|
try {
|
|
2557
|
-
const packed = await readFile(
|
|
2550
|
+
const packed = await readFile(join5(dir, "packed-refs"), "utf-8");
|
|
2558
2551
|
for (const line of packed.split("\n")) {
|
|
2559
2552
|
if (!line || line.startsWith("#") || line.startsWith("^")) {
|
|
2560
2553
|
continue;
|
|
@@ -2590,7 +2583,7 @@ async function resolveRef(gitDir, ref, seen = /* @__PURE__ */ new Set()) {
|
|
|
2590
2583
|
async function readWorktreeHeadSha(worktreePath) {
|
|
2591
2584
|
let raw;
|
|
2592
2585
|
try {
|
|
2593
|
-
raw = (await readFile(
|
|
2586
|
+
raw = (await readFile(join5(worktreePath, ".git"), "utf-8")).trim();
|
|
2594
2587
|
} catch (err) {
|
|
2595
2588
|
log6.debug({ err }, "worktree .git probe failed");
|
|
2596
2589
|
return "";
|
|
@@ -2599,7 +2592,7 @@ async function readWorktreeHeadSha(worktreePath) {
|
|
|
2599
2592
|
return "";
|
|
2600
2593
|
}
|
|
2601
2594
|
const rel = raw.slice("gitdir:".length).trim();
|
|
2602
|
-
const gitDir = isAbsolute(rel) ? rel :
|
|
2595
|
+
const gitDir = isAbsolute(rel) ? rel : join5(worktreePath, rel);
|
|
2603
2596
|
const head = await readGitHead(gitDir);
|
|
2604
2597
|
if (!head) {
|
|
2605
2598
|
return "";
|
|
@@ -2620,25 +2613,29 @@ async function getCurrentBranch(repoRoot) {
|
|
|
2620
2613
|
}
|
|
2621
2614
|
return head.branch ?? "";
|
|
2622
2615
|
}
|
|
2623
|
-
async function createAgentWorktree(slug, gitRoot,
|
|
2616
|
+
async function createAgentWorktree(slug, gitRoot, cwd = process.cwd()) {
|
|
2624
2617
|
if (!/^[a-zA-Z0-9_-]+$/.test(slug)) {
|
|
2625
2618
|
throw new Error(
|
|
2626
2619
|
"Invalid worktree slug: use only alphanumeric, hyphen, underscore"
|
|
2627
2620
|
);
|
|
2628
2621
|
}
|
|
2629
2622
|
const root = gitRoot ?? (await execFileAsync("git", ["rev-parse", "--show-toplevel"], {
|
|
2630
|
-
cwd
|
|
2623
|
+
cwd
|
|
2631
2624
|
})).stdout.trim();
|
|
2632
|
-
const worktreeDir =
|
|
2625
|
+
const worktreeDir = yukinoPath("worktrees", projectKey(root), slug);
|
|
2633
2626
|
const branch = `worktree-${slug}`;
|
|
2634
2627
|
if (await pathExists(worktreeDir)) {
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
["rev-parse", "--show-toplevel"],
|
|
2638
|
-
{
|
|
2628
|
+
let topLevel;
|
|
2629
|
+
try {
|
|
2630
|
+
topLevel = (await execFileAsync("git", ["rev-parse", "--show-toplevel"], {
|
|
2639
2631
|
cwd: worktreeDir
|
|
2640
|
-
}
|
|
2641
|
-
)
|
|
2632
|
+
})).stdout;
|
|
2633
|
+
} catch (cause) {
|
|
2634
|
+
throw new Error(
|
|
2635
|
+
`Existing directory is not a worktree root: ${worktreeDir}`,
|
|
2636
|
+
{ cause }
|
|
2637
|
+
);
|
|
2638
|
+
}
|
|
2642
2639
|
if (await realpath(topLevel.trim()) !== await realpath(worktreeDir)) {
|
|
2643
2640
|
throw new Error(
|
|
2644
2641
|
`Existing directory is not a worktree root: ${worktreeDir}`
|
|
@@ -2721,49 +2718,18 @@ The parent project is at: ${parentCwd}
|
|
|
2721
2718
|
Changes made here are isolated from the parent working tree.`;
|
|
2722
2719
|
}
|
|
2723
2720
|
async function performPostCreationSetup(repoRoot, wtPath) {
|
|
2724
|
-
await copyYukinoSettings(repoRoot, wtPath);
|
|
2725
2721
|
await copyAgentsSettings(repoRoot, wtPath);
|
|
2726
2722
|
await configureHooksPath(repoRoot, wtPath);
|
|
2727
2723
|
await symlinkNodeModules(repoRoot, wtPath);
|
|
2728
2724
|
await copyWorktreeIncludeFiles(repoRoot, wtPath);
|
|
2729
2725
|
}
|
|
2730
|
-
var SHARED_YUKINO_ENTRIES = [
|
|
2731
|
-
"permissions.yaml",
|
|
2732
|
-
"agents",
|
|
2733
|
-
"commands",
|
|
2734
|
-
"memory"
|
|
2735
|
-
];
|
|
2736
2726
|
var SHARED_AGENTS_ENTRIES = ["AGENTS.md", "skills"];
|
|
2737
|
-
async function copyYukinoSettings(repoRoot, wtPath) {
|
|
2738
|
-
const yukinoDir = join6(repoRoot, ".yukino");
|
|
2739
|
-
if (!await pathExists(yukinoDir)) {
|
|
2740
|
-
return;
|
|
2741
|
-
}
|
|
2742
|
-
const dstRoot = join6(wtPath, ".yukino");
|
|
2743
|
-
try {
|
|
2744
|
-
await mkdir(dstRoot, { recursive: true });
|
|
2745
|
-
} catch (err) {
|
|
2746
|
-
log6.error({ err }, "failed to create .yukino/ in worktree");
|
|
2747
|
-
return;
|
|
2748
|
-
}
|
|
2749
|
-
for (const entry of SHARED_YUKINO_ENTRIES) {
|
|
2750
|
-
const src = join6(yukinoDir, entry);
|
|
2751
|
-
if (!await pathExists(src)) {
|
|
2752
|
-
continue;
|
|
2753
|
-
}
|
|
2754
|
-
try {
|
|
2755
|
-
await cp(src, join6(dstRoot, entry), { recursive: true });
|
|
2756
|
-
} catch (err) {
|
|
2757
|
-
log6.error({ err, entry }, "failed to copy .yukino/ entry to worktree");
|
|
2758
|
-
}
|
|
2759
|
-
}
|
|
2760
|
-
}
|
|
2761
2727
|
async function copyAgentsSettings(repoRoot, wtPath) {
|
|
2762
|
-
const agentsDir =
|
|
2728
|
+
const agentsDir = join5(repoRoot, ".agents");
|
|
2763
2729
|
if (!await pathExists(agentsDir)) {
|
|
2764
2730
|
return;
|
|
2765
2731
|
}
|
|
2766
|
-
const dstRoot =
|
|
2732
|
+
const dstRoot = join5(wtPath, ".agents");
|
|
2767
2733
|
try {
|
|
2768
2734
|
await mkdir(dstRoot, { recursive: true });
|
|
2769
2735
|
} catch (err) {
|
|
@@ -2771,12 +2737,12 @@ async function copyAgentsSettings(repoRoot, wtPath) {
|
|
|
2771
2737
|
return;
|
|
2772
2738
|
}
|
|
2773
2739
|
for (const entry of SHARED_AGENTS_ENTRIES) {
|
|
2774
|
-
const src =
|
|
2740
|
+
const src = join5(agentsDir, entry);
|
|
2775
2741
|
if (!await pathExists(src)) {
|
|
2776
2742
|
continue;
|
|
2777
2743
|
}
|
|
2778
2744
|
try {
|
|
2779
|
-
await cp(src,
|
|
2745
|
+
await cp(src, join5(dstRoot, entry), { recursive: true });
|
|
2780
2746
|
} catch (err) {
|
|
2781
2747
|
log6.error({ err, entry }, "failed to copy .agents/ entry to worktree");
|
|
2782
2748
|
}
|
|
@@ -2792,7 +2758,7 @@ async function configureHooksPath(repoRoot, worktreePath) {
|
|
|
2792
2758
|
if (existing) {
|
|
2793
2759
|
return;
|
|
2794
2760
|
}
|
|
2795
|
-
const hooksPath =
|
|
2761
|
+
const hooksPath = join5(repoRoot, ".husky");
|
|
2796
2762
|
try {
|
|
2797
2763
|
const info = await stat(hooksPath);
|
|
2798
2764
|
if (!info.isDirectory()) {
|
|
@@ -2818,11 +2784,11 @@ async function configureHooksPath(repoRoot, worktreePath) {
|
|
|
2818
2784
|
}
|
|
2819
2785
|
async function symlinkNodeModules(repoRoot, worktreePath) {
|
|
2820
2786
|
try {
|
|
2821
|
-
const src =
|
|
2787
|
+
const src = join5(repoRoot, "node_modules");
|
|
2822
2788
|
if (!await pathExists(src)) {
|
|
2823
2789
|
return;
|
|
2824
2790
|
}
|
|
2825
|
-
const dst =
|
|
2791
|
+
const dst = join5(worktreePath, "node_modules");
|
|
2826
2792
|
if (await pathExists(dst)) {
|
|
2827
2793
|
return;
|
|
2828
2794
|
}
|
|
@@ -2833,7 +2799,7 @@ async function symlinkNodeModules(repoRoot, worktreePath) {
|
|
|
2833
2799
|
}
|
|
2834
2800
|
async function copyWorktreeIncludeFiles(repoRoot, worktreePath) {
|
|
2835
2801
|
try {
|
|
2836
|
-
const includeFile =
|
|
2802
|
+
const includeFile = join5(repoRoot, ".worktreeinclude");
|
|
2837
2803
|
if (!await pathExists(includeFile)) {
|
|
2838
2804
|
return;
|
|
2839
2805
|
}
|
|
@@ -2844,11 +2810,11 @@ async function copyWorktreeIncludeFiles(repoRoot, worktreePath) {
|
|
|
2844
2810
|
continue;
|
|
2845
2811
|
}
|
|
2846
2812
|
try {
|
|
2847
|
-
const src =
|
|
2813
|
+
const src = join5(repoRoot, relPath);
|
|
2848
2814
|
if (!await pathExists(src)) {
|
|
2849
2815
|
continue;
|
|
2850
2816
|
}
|
|
2851
|
-
const dst =
|
|
2817
|
+
const dst = join5(worktreePath, relPath);
|
|
2852
2818
|
await mkdir(dirname4(dst), { recursive: true });
|
|
2853
2819
|
const info = await stat(src);
|
|
2854
2820
|
if (info.isDirectory()) {
|
|
@@ -2892,7 +2858,7 @@ var AgentTool = class _AgentTool {
|
|
|
2892
2858
|
querySource = "";
|
|
2893
2859
|
/** Optional: Team manager, enables the team_name parameter. */
|
|
2894
2860
|
teamManager;
|
|
2895
|
-
|
|
2861
|
+
cwd;
|
|
2896
2862
|
/**
|
|
2897
2863
|
* When fork is disabled, omitting subagent_type no longer forks but falls back to the
|
|
2898
2864
|
* general-purpose agent. The "disabled" semantics (rather than "enabled") are used so
|
|
@@ -2909,9 +2875,9 @@ var AgentTool = class _AgentTool {
|
|
|
2909
2875
|
teamProviderIndex;
|
|
2910
2876
|
spawnHandler;
|
|
2911
2877
|
forkHandler;
|
|
2912
|
-
constructor(
|
|
2913
|
-
this.definitions = loadAgentDefinitions(
|
|
2914
|
-
this.
|
|
2878
|
+
constructor(cwd, registry, spawnHandler, conversation, forkHandler, taskManager = new TaskManager()) {
|
|
2879
|
+
this.definitions = loadAgentDefinitions();
|
|
2880
|
+
this.cwd = cwd;
|
|
2915
2881
|
this.registry = registry;
|
|
2916
2882
|
this.spawnHandler = spawnHandler;
|
|
2917
2883
|
this.conversation = conversation;
|
|
@@ -2929,7 +2895,7 @@ var AgentTool = class _AgentTool {
|
|
|
2929
2895
|
}
|
|
2930
2896
|
forFork(registry) {
|
|
2931
2897
|
const agent = new _AgentTool(
|
|
2932
|
-
this.
|
|
2898
|
+
this.cwd,
|
|
2933
2899
|
registry,
|
|
2934
2900
|
this.spawnHandler,
|
|
2935
2901
|
this.conversation,
|
|
@@ -3092,16 +3058,16 @@ Launch independent tasks together; avoid concurrent writes to the same files. Re
|
|
|
3092
3058
|
}
|
|
3093
3059
|
const runInBackground = backgroundArg.data ?? definition.background ?? false;
|
|
3094
3060
|
let effectivePrompt = prompt;
|
|
3095
|
-
let
|
|
3061
|
+
let cwdOverride;
|
|
3096
3062
|
if (isolation === "worktree" || definition.isolation === "worktree") {
|
|
3097
3063
|
try {
|
|
3098
3064
|
const wt = await createAgentWorktree(
|
|
3099
3065
|
newAgentSlug(),
|
|
3100
3066
|
void 0,
|
|
3101
|
-
ctx.
|
|
3067
|
+
ctx.cwd
|
|
3102
3068
|
);
|
|
3103
|
-
|
|
3104
|
-
effectivePrompt = `${buildWorktreeNotice(this.
|
|
3069
|
+
cwdOverride = wt.path;
|
|
3070
|
+
effectivePrompt = `${buildWorktreeNotice(this.cwd, wt.path)}
|
|
3105
3071
|
|
|
3106
3072
|
${prompt}`;
|
|
3107
3073
|
} catch (e) {
|
|
@@ -3118,19 +3084,19 @@ ${prompt}`;
|
|
|
3118
3084
|
effectivePrompt,
|
|
3119
3085
|
runInBackground,
|
|
3120
3086
|
modelOverride,
|
|
3121
|
-
|
|
3087
|
+
cwdOverride ?? (runContext.cwd !== this.cwd ? runContext.cwd : void 0),
|
|
3122
3088
|
runContext
|
|
3123
3089
|
);
|
|
3124
3090
|
return {
|
|
3125
|
-
output:
|
|
3091
|
+
output: cwdOverride ? `${output}
|
|
3126
3092
|
|
|
3127
|
-
Worktree retained at: ${
|
|
3093
|
+
Worktree retained at: ${cwdOverride}` : output,
|
|
3128
3094
|
isError: false
|
|
3129
3095
|
};
|
|
3130
3096
|
} catch (err) {
|
|
3131
3097
|
return {
|
|
3132
|
-
output: `Agent error: ${asErrorString(err)}${
|
|
3133
|
-
Worktree retained at: ${
|
|
3098
|
+
output: `Agent error: ${asErrorString(err)}${cwdOverride ? `
|
|
3099
|
+
Worktree retained at: ${cwdOverride}` : ""}`,
|
|
3134
3100
|
isError: true
|
|
3135
3101
|
};
|
|
3136
3102
|
}
|
|
@@ -3234,16 +3200,16 @@ Worktree retained at: ${workDirOverride}` : ""}`,
|
|
|
3234
3200
|
new TeamTaskUpdateTool(this.teamManager, teamName, memberName)
|
|
3235
3201
|
);
|
|
3236
3202
|
let teammatePrompt = prompt;
|
|
3237
|
-
let
|
|
3203
|
+
let memberCwd = ctx.cwd;
|
|
3238
3204
|
if (worktreeIsolation) {
|
|
3239
3205
|
try {
|
|
3240
3206
|
const wt = await createAgentWorktree(
|
|
3241
3207
|
newAgentSlug(),
|
|
3242
3208
|
void 0,
|
|
3243
|
-
ctx.
|
|
3209
|
+
ctx.cwd
|
|
3244
3210
|
);
|
|
3245
|
-
|
|
3246
|
-
teammatePrompt = `${buildWorktreeNotice(this.
|
|
3211
|
+
memberCwd = wt.path;
|
|
3212
|
+
teammatePrompt = `${buildWorktreeNotice(this.cwd, wt.path)}
|
|
3247
3213
|
|
|
3248
3214
|
${prompt}`;
|
|
3249
3215
|
} catch (e) {
|
|
@@ -3255,16 +3221,16 @@ ${prompt}`;
|
|
|
3255
3221
|
};
|
|
3256
3222
|
}
|
|
3257
3223
|
}
|
|
3258
|
-
const parentChecker = ctx.permissionChecker ?? new PermissionChecker(this.
|
|
3224
|
+
const parentChecker = ctx.permissionChecker ?? new PermissionChecker(this.cwd);
|
|
3259
3225
|
this.teamManager.setPermissionChecker(parentChecker);
|
|
3260
|
-
const checker = parentChecker.forSubagent(
|
|
3226
|
+
const checker = parentChecker.forSubagent(memberCwd);
|
|
3261
3227
|
checker.planModeLocked ||= planModeRequired || definition.permissionMode === "plan";
|
|
3262
3228
|
checker.teammate = true;
|
|
3263
3229
|
try {
|
|
3264
3230
|
const runAgent = this.teamRunAgentFactory?.(
|
|
3265
3231
|
teammateRegistry,
|
|
3266
3232
|
checker,
|
|
3267
|
-
|
|
3233
|
+
memberCwd,
|
|
3268
3234
|
{
|
|
3269
3235
|
definition,
|
|
3270
3236
|
modelOverride,
|
|
@@ -3279,7 +3245,7 @@ ${prompt}`;
|
|
|
3279
3245
|
checker,
|
|
3280
3246
|
this.teamProviderIndex,
|
|
3281
3247
|
ctx.toolCallId,
|
|
3282
|
-
|
|
3248
|
+
memberCwd,
|
|
3283
3249
|
{
|
|
3284
3250
|
agentType: definition.name,
|
|
3285
3251
|
model: modelOverride || definition.model,
|
|
@@ -3309,8 +3275,8 @@ ${prompt}`;
|
|
|
3309
3275
|
team.removeMember(memberName);
|
|
3310
3276
|
await teammateRegistry.dispose();
|
|
3311
3277
|
return {
|
|
3312
|
-
output: `Error spawning teammate: ${asErrorString(error)}${
|
|
3313
|
-
Worktree retained at: ${
|
|
3278
|
+
output: `Error spawning teammate: ${asErrorString(error)}${memberCwd !== this.cwd ? `
|
|
3279
|
+
Worktree retained at: ${memberCwd}` : ""}`,
|
|
3314
3280
|
isError: true
|
|
3315
3281
|
};
|
|
3316
3282
|
}
|
|
@@ -3349,19 +3315,19 @@ Worktree retained at: ${memberWorkDir}` : ""}`,
|
|
|
3349
3315
|
const worktree = await createAgentWorktree(
|
|
3350
3316
|
newAgentSlug(),
|
|
3351
3317
|
void 0,
|
|
3352
|
-
ctx.
|
|
3318
|
+
ctx.cwd
|
|
3353
3319
|
);
|
|
3354
3320
|
worktreePath = worktree.path;
|
|
3355
|
-
prompt = `${buildWorktreeNotice(ctx.
|
|
3321
|
+
prompt = `${buildWorktreeNotice(ctx.cwd, worktree.path)}
|
|
3356
3322
|
|
|
3357
3323
|
${prompt}`;
|
|
3358
3324
|
ctx = {
|
|
3359
3325
|
...ctx,
|
|
3360
|
-
|
|
3361
|
-
permissionChecker: ctx.permissionChecker?.
|
|
3326
|
+
cwd: worktree.path,
|
|
3327
|
+
permissionChecker: ctx.permissionChecker?.forCwd(worktree.path)
|
|
3362
3328
|
};
|
|
3363
3329
|
}
|
|
3364
|
-
const { cloneRegistryForFork: cloneRegistryForFork2 } = await import("./tool-filter-
|
|
3330
|
+
const { cloneRegistryForFork: cloneRegistryForFork2 } = await import("./tool-filter-5Z6UTRRR.js");
|
|
3365
3331
|
const clonedRegistry = cloneRegistryForFork2(this.registry);
|
|
3366
3332
|
forkedRegistry = isAsync ? filterToolsForAgent(clonedRegistry, void 0, void 0, true) : clonedRegistry;
|
|
3367
3333
|
const snapshot = conversationSnapshot ?? this.conversation.fork();
|
|
@@ -3423,17 +3389,17 @@ import {
|
|
|
3423
3389
|
statSync as statSync3,
|
|
3424
3390
|
realpathSync
|
|
3425
3391
|
} from "fs";
|
|
3426
|
-
import { homedir
|
|
3427
|
-
import { join as
|
|
3392
|
+
import { homedir } from "os";
|
|
3393
|
+
import { join as join6 } from "path";
|
|
3428
3394
|
import yaml3 from "js-yaml";
|
|
3429
3395
|
import { z as z8 } from "zod";
|
|
3430
3396
|
var log8 = createChildLogger({ module: "skills" });
|
|
3431
3397
|
var SkillCatalog = class {
|
|
3432
3398
|
entries = /* @__PURE__ */ new Map();
|
|
3433
|
-
|
|
3399
|
+
cwd = "";
|
|
3434
3400
|
dirModTimes = /* @__PURE__ */ new Map();
|
|
3435
|
-
load(
|
|
3436
|
-
this.
|
|
3401
|
+
load(cwd) {
|
|
3402
|
+
this.cwd = cwd;
|
|
3437
3403
|
this.entries.clear();
|
|
3438
3404
|
this.dirModTimes.clear();
|
|
3439
3405
|
for (const dir of this.skillDirPaths()) {
|
|
@@ -3465,7 +3431,7 @@ var SkillCatalog = class {
|
|
|
3465
3431
|
return false;
|
|
3466
3432
|
}
|
|
3467
3433
|
reload() {
|
|
3468
|
-
this.load(this.
|
|
3434
|
+
this.load(this.cwd);
|
|
3469
3435
|
}
|
|
3470
3436
|
snapshotDirModTimes() {
|
|
3471
3437
|
for (const dir of /* @__PURE__ */ new Set([
|
|
@@ -3480,9 +3446,11 @@ var SkillCatalog = class {
|
|
|
3480
3446
|
}
|
|
3481
3447
|
}
|
|
3482
3448
|
skillDirPaths() {
|
|
3483
|
-
return [
|
|
3484
|
-
(
|
|
3485
|
-
|
|
3449
|
+
return [
|
|
3450
|
+
join6(homedir(), ".agents", "skills"),
|
|
3451
|
+
yukinoPath("skills"),
|
|
3452
|
+
...this.cwd ? [join6(this.cwd, ".agents", "skills")] : []
|
|
3453
|
+
];
|
|
3486
3454
|
}
|
|
3487
3455
|
scanDirectory(dir, visited) {
|
|
3488
3456
|
let dirEntries;
|
|
@@ -3493,7 +3461,7 @@ var SkillCatalog = class {
|
|
|
3493
3461
|
}
|
|
3494
3462
|
visited.add(canonical);
|
|
3495
3463
|
this.dirModTimes.set(dir, statSync3(dir).mtimeMs);
|
|
3496
|
-
const skillFile =
|
|
3464
|
+
const skillFile = join6(dir, "SKILL.md");
|
|
3497
3465
|
if (existsSync4(skillFile)) {
|
|
3498
3466
|
this.loadSkill(skillFile, dir);
|
|
3499
3467
|
return;
|
|
@@ -3504,8 +3472,8 @@ var SkillCatalog = class {
|
|
|
3504
3472
|
return;
|
|
3505
3473
|
}
|
|
3506
3474
|
for (const entry of dirEntries) {
|
|
3507
|
-
const fullPath =
|
|
3508
|
-
if ((entry.startsWith(".") || entry === "node_modules") && !existsSync4(
|
|
3475
|
+
const fullPath = join6(dir, entry);
|
|
3476
|
+
if ((entry.startsWith(".") || entry === "node_modules") && !existsSync4(join6(fullPath, "SKILL.md"))) {
|
|
3509
3477
|
continue;
|
|
3510
3478
|
}
|
|
3511
3479
|
try {
|
|
@@ -3632,12 +3600,12 @@ function parseSkillFile(content) {
|
|
|
3632
3600
|
function escapeSkillXml(text) {
|
|
3633
3601
|
return text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
3634
3602
|
}
|
|
3635
|
-
function buildSkillSection(catalog
|
|
3603
|
+
function buildSkillSection(catalog) {
|
|
3636
3604
|
const metas = catalog.list();
|
|
3637
3605
|
if (metas.length === 0) {
|
|
3638
3606
|
return "";
|
|
3639
3607
|
}
|
|
3640
|
-
const skillsDir =
|
|
3608
|
+
const skillsDir = yukinoPath("skills");
|
|
3641
3609
|
const lines = [
|
|
3642
3610
|
"## Skills",
|
|
3643
3611
|
'Load relevant instructions with LoadSkill {name: "<skill-name>"}, or user command /<skill-name>. Mode inline activates in this conversation; fork runs in a subagent when available, otherwise inline. Load resources only as needed, relative to the skill directory. Tool access remains host-controlled.',
|