tenjin-cli 0.1.0-alpha.23 → 0.1.0-alpha.25
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/NOTICE.md +1 -1
- package/README.md +7 -8
- package/dist/{chunk-Y3LKUXZA.js → chunk-3ZYPVSIU.js} +145 -36
- package/dist/chunk-3ZYPVSIU.js.map +1 -0
- package/dist/chunk-7EKYXMUO.js +7536 -0
- package/dist/chunk-7EKYXMUO.js.map +1 -0
- package/dist/chunk-AKWGE6JQ.js +49 -0
- package/dist/chunk-AKWGE6JQ.js.map +1 -0
- package/dist/{chunk-3IOS6YG6.js → chunk-CEMXMUIU.js} +3 -3
- package/dist/{chunk-NYJCBQL5.js → chunk-CKDD554V.js} +2 -2
- package/dist/{hook-command-RDT754KQ.js → chunk-CP7O6M55.js} +209 -41
- package/dist/chunk-CP7O6M55.js.map +1 -0
- package/dist/{chunk-YT7A7DLY.js → chunk-DRXDTITB.js} +1821 -141
- package/dist/chunk-DRXDTITB.js.map +1 -0
- package/dist/{chunk-HTC4VJFT.js → chunk-EACMJEF3.js} +206 -16
- package/dist/chunk-EACMJEF3.js.map +1 -0
- package/dist/{chunk-DHCOGDJB.js → chunk-EG7P4SM6.js} +4 -4
- package/dist/{chunk-RGVOODF4.js → chunk-EL56RW2J.js} +164 -7463
- package/dist/chunk-EL56RW2J.js.map +1 -0
- package/dist/{chunk-2RMXTNLT.js → chunk-EOGJKIOG.js} +6 -8
- package/dist/{chunk-2RMXTNLT.js.map → chunk-EOGJKIOG.js.map} +1 -1
- package/dist/{chunk-WXFVJPZD.js → chunk-GT6W3VJM.js} +2 -2
- package/dist/{chunk-UHEMZEGW.js → chunk-HII5HOQV.js} +3 -5
- package/dist/chunk-HII5HOQV.js.map +1 -0
- package/dist/{chunk-GONDQ27X.js → chunk-IYLECN4D.js} +3 -3
- package/dist/{chunk-6O6DFYF3.js → chunk-KGTQRJGS.js} +17 -8
- package/dist/chunk-KGTQRJGS.js.map +1 -0
- package/dist/chunk-LFZJM56J.js +159 -0
- package/dist/chunk-LFZJM56J.js.map +1 -0
- package/dist/{chunk-HJYI52HM.js → chunk-NTYQHAIM.js} +2 -2
- package/dist/{chunk-K63HPLYT.js → chunk-NYPFOHSJ.js} +4 -4
- package/dist/{chunk-RA2J3TWG.js → chunk-ODH7UXIS.js} +17 -14
- package/dist/chunk-ODH7UXIS.js.map +1 -0
- package/dist/{chunk-XBYTP4SP.js → chunk-OZ3LWLCI.js} +3 -3
- package/dist/{chunk-2QYORQBF.js → chunk-P7LABKCW.js} +36 -1
- package/dist/{chunk-2QYORQBF.js.map → chunk-P7LABKCW.js.map} +1 -1
- package/dist/{chunk-N7A5EXJZ.js → chunk-SCAE6PW6.js} +4 -4
- package/dist/{chunk-UGLTSPXQ.js → chunk-UDWGT4FX.js} +2 -2
- package/dist/chunk-VYONGSMQ.js +119 -0
- package/dist/chunk-VYONGSMQ.js.map +1 -0
- package/dist/{chunk-SAN5PFTL.js → chunk-XICKN3CH.js} +49 -4
- package/dist/chunk-XICKN3CH.js.map +1 -0
- package/dist/chunk-YHKXNYTB.js +105 -0
- package/dist/chunk-YHKXNYTB.js.map +1 -0
- package/dist/{chunk-I2GBBIDI.js → chunk-YSW57KUT.js} +46 -32
- package/dist/chunk-YSW57KUT.js.map +1 -0
- package/dist/{chunk-F4IJQBGP.js → chunk-YTM7OURD.js} +2 -2
- package/dist/{cli-MUYFTWWB.js → cli-4WMGZPBP.js} +28 -29
- package/dist/{cli-MUYFTWWB.js.map → cli-4WMGZPBP.js.map} +1 -1
- package/dist/{config-IIRRO3XC.js → config-VU6U7QOU.js} +10 -9
- package/dist/{doctor-KGHM2CAC.js → doctor-26JS2SG3.js} +124 -32
- package/dist/doctor-26JS2SG3.js.map +1 -0
- package/dist/{fund-DOWIT3JT.js → fund-JJN3FRRF.js} +13 -14
- package/dist/fund-JJN3FRRF.js.map +1 -0
- package/dist/hook-command-S2V4UNB3.js +28 -0
- package/dist/index.js +3 -3
- package/dist/{install-BYQUMYBN.js → install-GXQ33J4G.js} +20 -17
- package/dist/{install-identity-KTQPYVAO.js → install-identity-HFQUXPSI.js} +6 -7
- package/dist/{install-wallet-T737X74E.js → install-wallet-27LTEHBI.js} +9 -10
- package/dist/{install-wallet-T737X74E.js.map → install-wallet-27LTEHBI.js.map} +1 -1
- package/dist/{mcp-ZKOTURQN.js → mcp-AHCZVD2U.js} +604 -93
- package/dist/mcp-AHCZVD2U.js.map +1 -0
- package/dist/{pay-LZPU2HUT.js → pay-3TCOPGCX.js} +14 -13
- package/dist/{payments-26NVMFR2.js → payments-H3LSBGSL.js} +6 -7
- package/dist/{payments-26NVMFR2.js.map → payments-H3LSBGSL.js.map} +1 -1
- package/dist/{send-4RUBQQKP.js → send-LKCLN5GA.js} +9 -11
- package/dist/{send-4RUBQQKP.js.map → send-LKCLN5GA.js.map} +1 -1
- package/dist/{status-CEHZKHBU.js → status-2FDGI4LQ.js} +7 -9
- package/dist/{status-CEHZKHBU.js.map → status-2FDGI4LQ.js.map} +1 -1
- package/dist/{status-line-QRAO3Y2E.js → status-line-QKDJYZGV.js} +4 -5
- package/dist/{status-line-QRAO3Y2E.js.map → status-line-QKDJYZGV.js.map} +1 -1
- package/dist/{status-line-wiring-7D2CSV3K.js → status-line-wiring-ZDBYHNYR.js} +6 -4
- package/dist/{uninstall-VR44B4KD.js → uninstall-ZXWABDHS.js} +34 -30
- package/dist/uninstall-ZXWABDHS.js.map +1 -0
- package/dist/{update-SOYQLDBF.js → update-HEIWVOP5.js} +17 -6
- package/dist/update-HEIWVOP5.js.map +1 -0
- package/dist/{wallet-IB2EFAUP.js → wallet-T7JYWI6O.js} +8 -9
- package/dist/wallet-T7JYWI6O.js.map +1 -0
- package/docs/agent-permissions.md +11 -8
- package/docs/safety-model.md +10 -23
- package/package.json +16 -13
- package/dist/chunk-6O6DFYF3.js.map +0 -1
- package/dist/chunk-A2XMQSWI.js +0 -140
- package/dist/chunk-A2XMQSWI.js.map +0 -1
- package/dist/chunk-HTC4VJFT.js.map +0 -1
- package/dist/chunk-I2GBBIDI.js.map +0 -1
- package/dist/chunk-O2JYBOUO.js +0 -47
- package/dist/chunk-O2JYBOUO.js.map +0 -1
- package/dist/chunk-RA2J3TWG.js.map +0 -1
- package/dist/chunk-RGVOODF4.js.map +0 -1
- package/dist/chunk-S2NRVRPF.js +0 -171
- package/dist/chunk-S2NRVRPF.js.map +0 -1
- package/dist/chunk-SAN5PFTL.js.map +0 -1
- package/dist/chunk-UHEMZEGW.js.map +0 -1
- package/dist/chunk-Y3LKUXZA.js.map +0 -1
- package/dist/chunk-YT7A7DLY.js.map +0 -1
- package/dist/doctor-KGHM2CAC.js.map +0 -1
- package/dist/fund-DOWIT3JT.js.map +0 -1
- package/dist/hook-command-RDT754KQ.js.map +0 -1
- package/dist/mcp-ZKOTURQN.js.map +0 -1
- package/dist/tenjin-daemon.mjs +0 -20601
- package/dist/tenjin-shim.mjs +0 -251
- package/dist/tenjin-vitest-reporter.mjs +0 -49
- package/dist/uninstall-VR44B4KD.js.map +0 -1
- package/dist/update-SOYQLDBF.js.map +0 -1
- /package/dist/{chunk-3IOS6YG6.js.map → chunk-CEMXMUIU.js.map} +0 -0
- /package/dist/{chunk-NYJCBQL5.js.map → chunk-CKDD554V.js.map} +0 -0
- /package/dist/{chunk-DHCOGDJB.js.map → chunk-EG7P4SM6.js.map} +0 -0
- /package/dist/{chunk-WXFVJPZD.js.map → chunk-GT6W3VJM.js.map} +0 -0
- /package/dist/{chunk-GONDQ27X.js.map → chunk-IYLECN4D.js.map} +0 -0
- /package/dist/{chunk-HJYI52HM.js.map → chunk-NTYQHAIM.js.map} +0 -0
- /package/dist/{chunk-K63HPLYT.js.map → chunk-NYPFOHSJ.js.map} +0 -0
- /package/dist/{chunk-XBYTP4SP.js.map → chunk-OZ3LWLCI.js.map} +0 -0
- /package/dist/{chunk-N7A5EXJZ.js.map → chunk-SCAE6PW6.js.map} +0 -0
- /package/dist/{chunk-UGLTSPXQ.js.map → chunk-UDWGT4FX.js.map} +0 -0
- /package/dist/{chunk-F4IJQBGP.js.map → chunk-YTM7OURD.js.map} +0 -0
- /package/dist/{config-IIRRO3XC.js.map → config-VU6U7QOU.js.map} +0 -0
- /package/dist/{install-BYQUMYBN.js.map → hook-command-S2V4UNB3.js.map} +0 -0
- /package/dist/{install-identity-KTQPYVAO.js.map → install-GXQ33J4G.js.map} +0 -0
- /package/dist/{pay-LZPU2HUT.js.map → install-identity-HFQUXPSI.js.map} +0 -0
- /package/dist/{status-line-wiring-7D2CSV3K.js.map → pay-3TCOPGCX.js.map} +0 -0
- /package/dist/{wallet-IB2EFAUP.js.map → status-line-wiring-ZDBYHNYR.js.map} +0 -0
package/dist/chunk-S2NRVRPF.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
MCP_SERVER_NAME,
|
|
4
|
-
REQUEST_TOOL
|
|
5
|
-
} from "./chunk-TGLKKLQG.js";
|
|
6
|
-
|
|
7
|
-
// src/router/agent-tools.ts
|
|
8
|
-
import { readdir, readFile } from "node:fs/promises";
|
|
9
|
-
import { dirname, join, resolve } from "node:path";
|
|
10
|
-
var MCP_INHERITING_BUILTINS = /* @__PURE__ */ new Set([
|
|
11
|
-
"general-purpose",
|
|
12
|
-
"Explore",
|
|
13
|
-
"Plan"
|
|
14
|
-
]);
|
|
15
|
-
var MAX_AGENT_FILE_BYTES = 256 * 1024;
|
|
16
|
-
var TYPE_RE = /^[A-Za-z0-9_.:-]{1,200}$/;
|
|
17
|
-
async function requestToolAccess(agentType, lookup) {
|
|
18
|
-
if (agentType === void 0 || !TYPE_RE.test(agentType)) return "unknown";
|
|
19
|
-
try {
|
|
20
|
-
const text = await findDefinition(agentType, lookup);
|
|
21
|
-
if (text !== null) return accessOf(text);
|
|
22
|
-
return MCP_INHERITING_BUILTINS.has(agentType) ? "allowed" : "unknown";
|
|
23
|
-
} catch {
|
|
24
|
-
return "unknown";
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function accessOf(definition) {
|
|
28
|
-
const frontmatter = frontmatterOf(definition);
|
|
29
|
-
if (frontmatter === null) return "unknown";
|
|
30
|
-
const disallowed = listField(frontmatter, "disallowedTools");
|
|
31
|
-
if (disallowed !== void 0 && disallowed.some(namesRequestTool)) return "excluded";
|
|
32
|
-
const tools = listField(frontmatter, "tools");
|
|
33
|
-
if (tools === void 0) return "allowed";
|
|
34
|
-
return tools.some(namesRequestTool) ? "allowed" : "excluded";
|
|
35
|
-
}
|
|
36
|
-
function namesRequestTool(tool) {
|
|
37
|
-
if (tool === REQUEST_TOOL || tool === `mcp__${MCP_SERVER_NAME}`) return true;
|
|
38
|
-
return tool.endsWith("*") && REQUEST_TOOL.startsWith(tool.slice(0, -1));
|
|
39
|
-
}
|
|
40
|
-
async function agentsWithoutRequestTool(lookup) {
|
|
41
|
-
const found = [];
|
|
42
|
-
const seen = /* @__PURE__ */ new Set();
|
|
43
|
-
for (const directory of agentDirs(lookup)) {
|
|
44
|
-
for (const { name, text } of await definitionsIn(directory)) {
|
|
45
|
-
const type = nameOf(text) ?? name;
|
|
46
|
-
if (seen.has(type)) continue;
|
|
47
|
-
seen.add(type);
|
|
48
|
-
if (accessOf(text) === "excluded") found.push(type);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return found.sort();
|
|
52
|
-
}
|
|
53
|
-
async function findDefinition(agentType, lookup) {
|
|
54
|
-
for (const directory of agentDirs(lookup)) {
|
|
55
|
-
const text = await definitionIn(directory, agentType);
|
|
56
|
-
if (text !== null) return text;
|
|
57
|
-
}
|
|
58
|
-
const colon = agentType.indexOf(":");
|
|
59
|
-
if (colon > 0) {
|
|
60
|
-
const plugin = agentType.slice(0, colon);
|
|
61
|
-
const agent = agentType.slice(colon + 1);
|
|
62
|
-
for (const root of await pluginRoots(plugin, lookup.homeDir)) {
|
|
63
|
-
const text = await definitionIn(join(root, "agents"), agent);
|
|
64
|
-
if (text !== null) return text;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
function agentDirs(lookup) {
|
|
70
|
-
const dirs = [];
|
|
71
|
-
if (lookup.cwd !== void 0 && lookup.cwd.length > 0) {
|
|
72
|
-
let current = resolve(lookup.cwd);
|
|
73
|
-
for (; ; ) {
|
|
74
|
-
dirs.push(join(current, ".claude", "agents"));
|
|
75
|
-
const parent = dirname(current);
|
|
76
|
-
if (parent === current) break;
|
|
77
|
-
current = parent;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
const user = join(resolve(lookup.homeDir), ".claude", "agents");
|
|
81
|
-
return [...dirs.filter((d) => d !== user), user];
|
|
82
|
-
}
|
|
83
|
-
async function definitionIn(directory, agentType) {
|
|
84
|
-
const direct = await readBounded(join(directory, `${agentType}.md`));
|
|
85
|
-
if (direct !== null && (nameOf(direct) ?? agentType) === agentType) return direct;
|
|
86
|
-
for (const { text } of await definitionsIn(directory)) {
|
|
87
|
-
if (nameOf(text) === agentType) return text;
|
|
88
|
-
}
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
async function definitionsIn(directory) {
|
|
92
|
-
let names;
|
|
93
|
-
try {
|
|
94
|
-
names = (await readdir(directory)).filter((n) => n.endsWith(".md")).slice(0, 200);
|
|
95
|
-
} catch {
|
|
96
|
-
return [];
|
|
97
|
-
}
|
|
98
|
-
const out = [];
|
|
99
|
-
for (const file of names) {
|
|
100
|
-
const text = await readBounded(join(directory, file));
|
|
101
|
-
if (text !== null) out.push({ name: file.slice(0, -3), text });
|
|
102
|
-
}
|
|
103
|
-
return out;
|
|
104
|
-
}
|
|
105
|
-
async function pluginRoots(plugin, homeDir) {
|
|
106
|
-
const raw = await readBounded(join(homeDir, ".claude", "plugins", "installed_plugins.json"));
|
|
107
|
-
if (raw === null) return [];
|
|
108
|
-
const parsed = JSON.parse(raw);
|
|
109
|
-
const roots = [];
|
|
110
|
-
for (const [key, entries] of Object.entries(parsed.plugins ?? {})) {
|
|
111
|
-
if (key.split("@")[0] !== plugin || !Array.isArray(entries)) continue;
|
|
112
|
-
for (const entry of entries) {
|
|
113
|
-
const path = entry.installPath;
|
|
114
|
-
if (typeof path === "string" && path.length > 0) roots.push(path);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return roots;
|
|
118
|
-
}
|
|
119
|
-
async function readBounded(path) {
|
|
120
|
-
try {
|
|
121
|
-
const text = await readFile(path, "utf8");
|
|
122
|
-
return text.length > MAX_AGENT_FILE_BYTES ? null : text;
|
|
123
|
-
} catch {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function frontmatterOf(text) {
|
|
128
|
-
const lines = text.replace(/^\uFEFF/, "").split(/\r?\n/);
|
|
129
|
-
const open = lines.findIndex((l) => l.trim().length > 0);
|
|
130
|
-
if (open === -1 || lines[open]?.trim() !== "---") return null;
|
|
131
|
-
const end = lines.findIndex((l, i) => i > open && l.trim() === "---");
|
|
132
|
-
return end === -1 ? null : lines.slice(open + 1, end);
|
|
133
|
-
}
|
|
134
|
-
function nameOf(text) {
|
|
135
|
-
const frontmatter = frontmatterOf(text);
|
|
136
|
-
if (frontmatter === null) return null;
|
|
137
|
-
const line = frontmatter.find((l) => /^name\s*:/.test(l));
|
|
138
|
-
const value = line === void 0 ? "" : unquote(line.slice(line.indexOf(":") + 1).trim());
|
|
139
|
-
return value.length > 0 ? value : null;
|
|
140
|
-
}
|
|
141
|
-
function listField(frontmatter, key) {
|
|
142
|
-
const index = frontmatter.findIndex((l) => new RegExp(`^${key}\\s*:`).test(l));
|
|
143
|
-
if (index === -1) return void 0;
|
|
144
|
-
const line = frontmatter[index];
|
|
145
|
-
const inline = line.slice(line.indexOf(":") + 1).trim();
|
|
146
|
-
if (inline.length > 0) {
|
|
147
|
-
const body = inline.startsWith("[") && inline.endsWith("]") ? inline.slice(1, -1) : inline;
|
|
148
|
-
return body.split(",").map((part) => unquote(part.trim())).filter((part) => part.length > 0);
|
|
149
|
-
}
|
|
150
|
-
const items = [];
|
|
151
|
-
for (const next of frontmatter.slice(index + 1)) {
|
|
152
|
-
const item = /^\s+-\s*(.*)$/.exec(next);
|
|
153
|
-
if (item === null) {
|
|
154
|
-
if (next.trim().length === 0) continue;
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
const value = unquote(item[1].trim());
|
|
158
|
-
if (value.length > 0) items.push(value);
|
|
159
|
-
}
|
|
160
|
-
return items;
|
|
161
|
-
}
|
|
162
|
-
function unquote(value) {
|
|
163
|
-
const quoted = /^(['"])(.*)\1$/.exec(value);
|
|
164
|
-
return quoted === null ? value : quoted[2];
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export {
|
|
168
|
-
requestToolAccess,
|
|
169
|
-
agentsWithoutRequestTool
|
|
170
|
-
};
|
|
171
|
-
//# sourceMappingURL=chunk-S2NRVRPF.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/router/agent-tools.ts"],"sourcesContent":["import { readdir, readFile } from 'node:fs/promises';\nimport { dirname, join, resolve } from 'node:path';\nimport { MCP_SERVER_NAME, REQUEST_TOOL } from './names';\n\n/**\n * CAN THIS SUBAGENT CALL `request` AT ALL? An offer to an agent whose definition\n * leaves the tool out is a line it cannot act on, and a router call spent to\n * write it. Claude Code defines a custom agent in a Markdown file whose\n * frontmatter may carry `tools:` (an allowlist) and `disallowedTools:`; this\n * reads that, and nothing else, and never writes to it.\n *\n * ONLY `allowed` IS ACTED ON. A subagent is redirected or offered a lookup\n * only when this KNOWS it can make the call: a definition whose tools cover\n * the request tool (or that has no `tools:` and so inherits everything), or a\n * built-in in {@link MCP_INHERITING_BUILTINS}. Every other built-in, and any\n * type with no definition this can find or read, is `unknown`, and `unknown`\n * gets no router call: `claude-code-guide` ships with Bash, Read, WebFetch and\n * WebSearch and no MCP tools, and denying its WebFetch would strand it exactly\n * as #377 reported.\n *\n * WHERE A DEFINITION LIVES, in the harness's own precedence: the project's\n * `.claude/agents` (from `cwd` up to the filesystem root, nearest first), then\n * `~/.claude/agents`, then an installed plugin's `agents/` for a `plugin:agent`\n * type. A file is found by its name first and by its frontmatter `name:`\n * second, because the type is the `name:` and the file name only usually\n * matches it.\n */\n\nexport type RequestToolAccess = 'allowed' | 'excluded' | 'unknown';\n\n/**\n * The built-in agent types that have no definition file and still inherit MCP\n * tools, so can call `mcp__x402__request`. From Claude Code's own Agent tool\n * listing (2.1.28x): `general-purpose` has every tool, and `Explore` and `Plan`\n * exclude only editing and agent tools, never MCP. Built-ins with a fixed tool\n * list, such as `claude-code-guide` (Bash, Read, WebFetch, WebSearch) and\n * `statusline-setup` (Read, Edit), are deliberately absent.\n */\nexport const MCP_INHERITING_BUILTINS: ReadonlySet<string> = new Set([\n 'general-purpose',\n 'Explore',\n 'Plan',\n]);\n\nexport interface AgentLookup {\n cwd?: string;\n homeDir: string;\n}\n\nconst MAX_AGENT_FILE_BYTES = 256 * 1024;\nconst TYPE_RE = /^[A-Za-z0-9_.:-]{1,200}$/;\n\nexport async function requestToolAccess(\n agentType: string | undefined,\n lookup: AgentLookup,\n): Promise<RequestToolAccess> {\n if (agentType === undefined || !TYPE_RE.test(agentType)) return 'unknown';\n try {\n const text = await findDefinition(agentType, lookup);\n if (text !== null) return accessOf(text);\n return MCP_INHERITING_BUILTINS.has(agentType) ? 'allowed' : 'unknown';\n } catch {\n return 'unknown';\n }\n}\n\n/** What one definition's frontmatter says about the request tool. */\nexport function accessOf(definition: string): RequestToolAccess {\n const frontmatter = frontmatterOf(definition);\n if (frontmatter === null) return 'unknown';\n const disallowed = listField(frontmatter, 'disallowedTools');\n if (disallowed !== undefined && disallowed.some(namesRequestTool)) return 'excluded';\n const tools = listField(frontmatter, 'tools');\n if (tools === undefined) return 'allowed';\n return tools.some(namesRequestTool) ? 'allowed' : 'excluded';\n}\n\n/**\n * Does one `tools:` or `disallowedTools:` entry cover the request tool? The\n * tool itself, the bare server, or any `*`-suffixed pattern the tool's name\n * starts with: `*`, `mcp__*`, `mcp__x402__*` and every prefix between.\n */\nfunction namesRequestTool(tool: string): boolean {\n if (tool === REQUEST_TOOL || tool === `mcp__${MCP_SERVER_NAME}`) return true;\n return tool.endsWith('*') && REQUEST_TOOL.startsWith(tool.slice(0, -1));\n}\n\n/**\n * Every custom agent this project and this user define whose tools leave the\n * request tool out, for `doctor` to name. Plugin agents are not listed: their\n * files are not the user's to edit.\n */\nexport async function agentsWithoutRequestTool(lookup: AgentLookup): Promise<string[]> {\n const found: string[] = [];\n const seen = new Set<string>();\n for (const directory of agentDirs(lookup)) {\n for (const { name, text } of await definitionsIn(directory)) {\n const type = nameOf(text) ?? name;\n if (seen.has(type)) continue;\n seen.add(type);\n if (accessOf(text) === 'excluded') found.push(type);\n }\n }\n return found.sort();\n}\n\nasync function findDefinition(agentType: string, lookup: AgentLookup): Promise<string | null> {\n for (const directory of agentDirs(lookup)) {\n const text = await definitionIn(directory, agentType);\n if (text !== null) return text;\n }\n const colon = agentType.indexOf(':');\n if (colon > 0) {\n const plugin = agentType.slice(0, colon);\n const agent = agentType.slice(colon + 1);\n for (const root of await pluginRoots(plugin, lookup.homeDir)) {\n const text = await definitionIn(join(root, 'agents'), agent);\n if (text !== null) return text;\n }\n }\n return null;\n}\n\nfunction agentDirs(lookup: AgentLookup): string[] {\n const dirs: string[] = [];\n if (lookup.cwd !== undefined && lookup.cwd.length > 0) {\n let current = resolve(lookup.cwd);\n for (;;) {\n dirs.push(join(current, '.claude', 'agents'));\n const parent = dirname(current);\n if (parent === current) break;\n current = parent;\n }\n }\n const user = join(resolve(lookup.homeDir), '.claude', 'agents');\n // The user's directory is also an ancestor of most projects; it counts once,\n // in its own place in the order.\n return [...dirs.filter((d) => d !== user), user];\n}\n\nasync function definitionIn(directory: string, agentType: string): Promise<string | null> {\n const direct = await readBounded(join(directory, `${agentType}.md`));\n if (direct !== null && (nameOf(direct) ?? agentType) === agentType) return direct;\n for (const { text } of await definitionsIn(directory)) {\n if (nameOf(text) === agentType) return text;\n }\n return null;\n}\n\nasync function definitionsIn(directory: string): Promise<{ name: string; text: string }[]> {\n let names: string[];\n try {\n names = (await readdir(directory)).filter((n) => n.endsWith('.md')).slice(0, 200);\n } catch {\n return [];\n }\n const out: { name: string; text: string }[] = [];\n for (const file of names) {\n const text = await readBounded(join(directory, file));\n if (text !== null) out.push({ name: file.slice(0, -3), text });\n }\n return out;\n}\n\n/** Install paths `installed_plugins.json` records for `<plugin>@<marketplace>`. */\nasync function pluginRoots(plugin: string, homeDir: string): Promise<string[]> {\n const raw = await readBounded(join(homeDir, '.claude', 'plugins', 'installed_plugins.json'));\n if (raw === null) return [];\n const parsed = JSON.parse(raw) as { plugins?: Record<string, unknown> };\n const roots: string[] = [];\n for (const [key, entries] of Object.entries(parsed.plugins ?? {})) {\n if (key.split('@')[0] !== plugin || !Array.isArray(entries)) continue;\n for (const entry of entries) {\n const path = (entry as { installPath?: unknown }).installPath;\n if (typeof path === 'string' && path.length > 0) roots.push(path);\n }\n }\n return roots;\n}\n\nasync function readBounded(path: string): Promise<string | null> {\n try {\n const text = await readFile(path, 'utf8');\n return text.length > MAX_AGENT_FILE_BYTES ? null : text;\n } catch {\n return null;\n }\n}\n\nfunction frontmatterOf(text: string): string[] | null {\n const lines = text.replace(/^\\uFEFF/, '').split(/\\r?\\n/);\n const open = lines.findIndex((l) => l.trim().length > 0);\n if (open === -1 || lines[open]?.trim() !== '---') return null;\n const end = lines.findIndex((l, i) => i > open && l.trim() === '---');\n return end === -1 ? null : lines.slice(open + 1, end);\n}\n\nfunction nameOf(text: string): string | null {\n const frontmatter = frontmatterOf(text);\n if (frontmatter === null) return null;\n const line = frontmatter.find((l) => /^name\\s*:/.test(l));\n const value = line === undefined ? '' : unquote(line.slice(line.indexOf(':') + 1).trim());\n return value.length > 0 ? value : null;\n}\n\n/**\n * A top-level list field in the three spellings agent files use: `a, b, c`,\n * `[a, b]`, or a block of `- a` lines. `undefined` when the key is absent.\n */\nfunction listField(frontmatter: string[], key: string): string[] | undefined {\n const index = frontmatter.findIndex((l) => new RegExp(`^${key}\\\\s*:`).test(l));\n if (index === -1) return undefined;\n const line = frontmatter[index]!;\n const inline = line.slice(line.indexOf(':') + 1).trim();\n if (inline.length > 0) {\n const body = inline.startsWith('[') && inline.endsWith(']') ? inline.slice(1, -1) : inline;\n return body\n .split(',')\n .map((part) => unquote(part.trim()))\n .filter((part) => part.length > 0);\n }\n const items: string[] = [];\n for (const next of frontmatter.slice(index + 1)) {\n const item = /^\\s+-\\s*(.*)$/.exec(next);\n if (item === null) {\n if (next.trim().length === 0) continue;\n break;\n }\n const value = unquote(item[1]!.trim());\n if (value.length > 0) items.push(value);\n }\n return items;\n}\n\nfunction unquote(value: string): string {\n const quoted = /^(['\"])(.*)\\1$/.exec(value);\n return quoted === null ? value : quoted[2]!;\n}\n"],"mappings":";;;;;;;AAAA,SAAS,SAAS,gBAAgB;AAClC,SAAS,SAAS,MAAM,eAAe;AAqChC,IAAM,0BAA+C,oBAAI,IAAI;AAAA,EAClE;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAOD,IAAM,uBAAuB,MAAM;AACnC,IAAM,UAAU;AAEhB,eAAsB,kBACpB,WACA,QAC4B;AAC5B,MAAI,cAAc,UAAa,CAAC,QAAQ,KAAK,SAAS,EAAG,QAAO;AAChE,MAAI;AACF,UAAM,OAAO,MAAM,eAAe,WAAW,MAAM;AACnD,QAAI,SAAS,KAAM,QAAO,SAAS,IAAI;AACvC,WAAO,wBAAwB,IAAI,SAAS,IAAI,YAAY;AAAA,EAC9D,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGO,SAAS,SAAS,YAAuC;AAC9D,QAAM,cAAc,cAAc,UAAU;AAC5C,MAAI,gBAAgB,KAAM,QAAO;AACjC,QAAM,aAAa,UAAU,aAAa,iBAAiB;AAC3D,MAAI,eAAe,UAAa,WAAW,KAAK,gBAAgB,EAAG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