@wirecat/cli-template 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +18 -0
- package/.github/workflows/release.yml +63 -0
- package/CHANGELOG.md +72 -1
- package/CLAUDE.md +1 -3
- package/bin/release +5 -3
- package/contracts/help.snap +2 -0
- package/dist/bin/clidev.js +34 -12
- package/dist/bundle/all-profiles-MJ6XSFOO.js +24 -0
- package/dist/bundle/anthropic-W5UKBZUB.js +70 -0
- package/dist/bundle/app-server-EZ46JAHB.js +217 -0
- package/dist/bundle/bun-HB6O2TTT.js +169 -0
- package/dist/bundle/bun-sqlite-KBXOW2ES.js +69 -0
- package/dist/bundle/chunk-2B5U4Z5H.js +100 -0
- package/dist/bundle/chunk-35KYY65W.js +122 -0
- package/dist/bundle/chunk-4LURWBVV.js +752 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-7IXL4UFK.js +158 -0
- package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
- package/dist/bundle/chunk-AK257OMS.js +8353 -0
- package/dist/bundle/chunk-CXQXVKUY.js +24 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-E42W72PQ.js +151 -0
- package/dist/bundle/chunk-EFHLQXG6.js +5104 -0
- package/dist/bundle/chunk-EGRB55FF.js +264 -0
- package/dist/bundle/chunk-ERGB4NJA.js +53 -0
- package/dist/bundle/chunk-ERKR3VJ5.js +1146 -0
- package/dist/bundle/chunk-FDBINRWA.js +884 -0
- package/dist/bundle/chunk-FZZIU4B7.js +34514 -0
- package/dist/bundle/chunk-GOO67PDU.js +2 -0
- package/dist/bundle/chunk-HDY5X3WQ.js +281 -0
- package/dist/bundle/chunk-HTQTIKWP.js +928 -0
- package/dist/bundle/chunk-IBBN7Z3A.js +630 -0
- package/dist/bundle/chunk-IDWW4TU2.js +18 -0
- package/dist/bundle/chunk-IGHEW777.js +164 -0
- package/dist/bundle/chunk-IN3FVRPK.js +76 -0
- package/dist/bundle/chunk-JAOGZMKQ.js +48 -0
- package/dist/bundle/chunk-JHO2LL2J.js +459 -0
- package/dist/bundle/chunk-JRK73FOW.js +78 -0
- package/dist/bundle/chunk-KAREKBUZ.js +24 -0
- package/dist/bundle/chunk-KJTNT4SW.js +82 -0
- package/dist/bundle/chunk-L5WWMP5M.js +1904 -0
- package/dist/bundle/chunk-MFS52LTZ.js +570 -0
- package/dist/bundle/chunk-MJRSEUKG.js +442 -0
- package/dist/bundle/chunk-MUSYGFCY.js +3556 -0
- package/dist/bundle/chunk-N2Z3MCOF.js +779 -0
- package/dist/bundle/chunk-NOVLCHDV.js +45 -0
- package/dist/bundle/chunk-O3UXNU3S.js +54 -0
- package/dist/bundle/chunk-O5EHUB2V.js +2 -0
- package/dist/bundle/chunk-OV6PHTAY.js +36226 -0
- package/dist/bundle/chunk-PBN4RBHS.js +2315 -0
- package/dist/bundle/chunk-PDGXMKJS.js +31 -0
- package/dist/bundle/chunk-PJOVK7PG.js +191 -0
- package/dist/bundle/chunk-QBP7OMN5.js +58 -0
- package/dist/bundle/chunk-QJ6XW4DM.js +7556 -0
- package/dist/bundle/chunk-QKWRL4OD.js +1028 -0
- package/dist/bundle/chunk-RUKDZEID.js +73 -0
- package/dist/bundle/chunk-SVDF6NJF.js +215 -0
- package/dist/bundle/chunk-TAYOKLGF.js +193 -0
- package/dist/bundle/chunk-TGB5F7NC.js +288 -0
- package/dist/bundle/chunk-V3ZTQ24B.js +161 -0
- package/dist/bundle/chunk-VLNKTMV7.js +3103 -0
- package/dist/bundle/chunk-VYSUKHKL.js +63 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YJNUDHJD.js +3390 -0
- package/dist/bundle/chunk-Z7MSIRSQ.js +6848 -0
- package/dist/bundle/chunk-ZLY6GUAS.js +82 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/clidev.js +22 -0
- package/dist/bundle/command-contract-75VJ36U4.js +29 -0
- package/dist/bundle/decode-AMXUVKNY.js +158 -0
- package/dist/bundle/dist-ESHIQU4M.js +7577 -0
- package/dist/bundle/echarts-GJDMQ2AQ.js +42501 -0
- package/dist/bundle/embed-L4CRZ2XQ.js +35 -0
- package/dist/bundle/embedder-IBGV4M2K.js +108 -0
- package/dist/bundle/first-run-VTKC2IBV.js +23 -0
- package/dist/bundle/first-screen-X5IJKBSU.js +27 -0
- package/dist/bundle/instructions-YJECS4KN.js +11 -0
- package/dist/bundle/mcp-G6XP2IRO.js +151 -0
- package/dist/bundle/mcp-OQBZXELQ.js +165 -0
- package/dist/bundle/mcp-RDZGYPSY.js +78 -0
- package/dist/bundle/node-NQG4EVZR.js +176 -0
- package/dist/bundle/node-P4E63KXA.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-BR7F3BLB.js +61 -0
- package/dist/bundle/oauth-J7UAWNIK.js +17 -0
- package/dist/bundle/open-BR47R5UE.js +19 -0
- package/dist/bundle/process-66I7RDPJ.js +91 -0
- package/dist/bundle/program-K6347XBZ.js +17279 -0
- package/dist/bundle/prompt-NE5JJ7UP.js +12 -0
- package/dist/bundle/recognize-GC3YFVIA.js +21 -0
- package/dist/bundle/remote-QELOMKQM.js +26 -0
- package/dist/bundle/rerank-BH6TZ2SP.js +49 -0
- package/dist/bundle/serve-WWLRNDT2.js +19 -0
- package/dist/bundle/server-DE6NLNUF.js +52 -0
- package/dist/bundle/server-ZPSQKOAH.js +39 -0
- package/dist/bundle/state-2BEGXAMO.js +33 -0
- package/dist/bundle/store-AH6WZMCF.js +120 -0
- package/dist/bundle/store-maintenance-command-PBXX3IEV.js +40 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/docs/commands.md +9 -13
- package/docs/dev/TESTING.md +10 -0
- package/docs/dev/reference-clis.md +7 -5
- package/docs/dev/skills/release/SKILL.md +15 -8
- package/docs/dev/skills/release/fresh-audit.md +4 -0
- package/docs/dev/test-matrix.md +1 -1
- package/kit/dist/new.js +1 -0
- package/package.json +8 -5
- package/scripts/audit.sh +14 -3
- package/scripts/smoke-bundle.ts +64 -0
- package/scripts/smoke.ts +18 -0
- package/scripts/test-matrix-untested.ts +1 -1
- package/scripts/version-level.test.ts +17 -1
- package/scripts/version-level.ts +35 -7
- package/skills/clidev-cli/SKILL.md +8 -0
- package/src/version.ts +1 -1
- package/lint/baseline/unknown-verb.json +0 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
botInstructions
|
|
5
|
+
} from "./chunk-CXQXVKUY.js";
|
|
6
|
+
import {
|
|
7
|
+
answered,
|
|
8
|
+
normal,
|
|
9
|
+
registerCommands,
|
|
10
|
+
runCommandForAgent,
|
|
11
|
+
toolsFromCommands
|
|
12
|
+
} from "./chunk-YJNUDHJD.js";
|
|
13
|
+
import {
|
|
14
|
+
agentJson,
|
|
15
|
+
skillResource
|
|
16
|
+
} from "./chunk-4LURWBVV.js";
|
|
17
|
+
import {
|
|
18
|
+
callerOf,
|
|
19
|
+
serveStdio
|
|
20
|
+
} from "./chunk-IBBN7Z3A.js";
|
|
21
|
+
import {
|
|
22
|
+
wholeList
|
|
23
|
+
} from "./chunk-FZZIU4B7.js";
|
|
24
|
+
import {
|
|
25
|
+
McpServer
|
|
26
|
+
} from "./chunk-5D4AEUVA.js";
|
|
27
|
+
import {
|
|
28
|
+
MESSENGER_CHANGE_REFUSAL,
|
|
29
|
+
changesMessenger,
|
|
30
|
+
flatten,
|
|
31
|
+
itemOf,
|
|
32
|
+
readOnlyLockOf,
|
|
33
|
+
readOnlyRefusal
|
|
34
|
+
} from "./chunk-QJ6XW4DM.js";
|
|
35
|
+
import {
|
|
36
|
+
mcpErrorResult,
|
|
37
|
+
object
|
|
38
|
+
} from "./chunk-EFHLQXG6.js";
|
|
39
|
+
import {
|
|
40
|
+
__name
|
|
41
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
42
|
+
|
|
43
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.495.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_24cca5e5c8b0984f2f26e7d1ba6b6d47/node_modules/@wirecat/cli-core/dist/mcp/bot/server.js
|
|
44
|
+
import { randomUUID } from "node:crypto";
|
|
45
|
+
var body = /* @__PURE__ */ __name((command, value) => Array.isArray(value) ? wholeList(`bot ${command}`, value) : value !== null && typeof value === "object" && ("item" in value || "items" in value) ? value : itemOf(value !== null && typeof value === "object" ? value : { value }), "body");
|
|
46
|
+
var createBotServer = /* @__PURE__ */ __name((options) => {
|
|
47
|
+
const { bot, program, settings, env } = options;
|
|
48
|
+
const command = bot.app.command;
|
|
49
|
+
const levels = options.levels ?? (() => settings.permissions);
|
|
50
|
+
const authority = /* @__PURE__ */ __name((path) => options.authority?.(path) === true || path[0] === "config" && (path[1] === "set" || path[1] === "unset"), "authority");
|
|
51
|
+
const catalogue = {
|
|
52
|
+
includeUnavailable: true,
|
|
53
|
+
levels: settings.permissions,
|
|
54
|
+
currentLevels: levels,
|
|
55
|
+
readOnly: readOnlyLockOf(bot.app, env) !== void 0,
|
|
56
|
+
...options.keyOf ? { keyOf: options.keyOf } : {},
|
|
57
|
+
authority,
|
|
58
|
+
...options.fetchOnly ? { fetchOnly: options.fetchOnly } : {},
|
|
59
|
+
offline: true,
|
|
60
|
+
// Another bot's copy is this bot's to read only where `read_other_bots` says so.
|
|
61
|
+
...settings.readOtherBots ? {} : { omit: ["all_bots", "bots"] }
|
|
62
|
+
};
|
|
63
|
+
const tools = [
|
|
64
|
+
...toolsFromCommands(program.commands, { ...catalogue, root: ["bot"] }),
|
|
65
|
+
...toolsFromCommands(program.commands.filter((one) => one.path[0] === "config"), {
|
|
66
|
+
...catalogue,
|
|
67
|
+
omit: ["bot", "personal", "defaults"]
|
|
68
|
+
})
|
|
69
|
+
];
|
|
70
|
+
const writes = tools.filter((tool) => tool.writes && tool.availability?.().available !== false).map((tool) => tool.command);
|
|
71
|
+
const skill = options.skill ? skillResource(bot.app, options.skill) : void 0;
|
|
72
|
+
let queue = Promise.resolve();
|
|
73
|
+
const invoke = /* @__PURE__ */ __name((path, input, caller) => {
|
|
74
|
+
const next = queue.then(() => runCommandForAgent(program, path, path[0] === "config" ? { ...input, bot: true } : input, {
|
|
75
|
+
profile: settings.profile,
|
|
76
|
+
readOnly: readOnlyLockOf(bot.app, env) !== void 0,
|
|
77
|
+
env,
|
|
78
|
+
levels,
|
|
79
|
+
...options.keyOf ? { keyOf: options.keyOf } : {},
|
|
80
|
+
authority,
|
|
81
|
+
...caller ? { caller } : {}
|
|
82
|
+
}));
|
|
83
|
+
queue = next.catch(() => void 0);
|
|
84
|
+
return next;
|
|
85
|
+
}, "invoke");
|
|
86
|
+
const build = /* @__PURE__ */ __name(() => {
|
|
87
|
+
const callers = { env, client: /* @__PURE__ */ __name(() => server.server.getClientVersion(), "client"), connectionId: randomUUID() };
|
|
88
|
+
const server = new McpServer({ name: `${command}-bot-${settings.profile}`, version: bot.app.version }, {
|
|
89
|
+
instructions: botInstructions({
|
|
90
|
+
command,
|
|
91
|
+
name: bot.name ?? command,
|
|
92
|
+
profile: settings.profile,
|
|
93
|
+
writes,
|
|
94
|
+
...skill ? { skill: skill.instruction } : {}
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
if (skill) {
|
|
98
|
+
const { uri, name, title, description, mimeType, read } = skill;
|
|
99
|
+
server.registerResource(name, uri, { title, description, mimeType }, read);
|
|
100
|
+
}
|
|
101
|
+
const commands = Object.fromEntries(tools.map((tool) => [
|
|
102
|
+
tool.command,
|
|
103
|
+
{
|
|
104
|
+
title: tool.title,
|
|
105
|
+
description: tool.description,
|
|
106
|
+
writes: tool.writes,
|
|
107
|
+
availability: tool.availability,
|
|
108
|
+
input: tool.input,
|
|
109
|
+
run: /* @__PURE__ */ __name(async (args, ctx) => {
|
|
110
|
+
const caller = callerOf(ctx, `${command}_${tool.command.replaceAll(" ", "_")}`, callers);
|
|
111
|
+
const answer = await invoke(tool.path, args, caller);
|
|
112
|
+
return "error" in answer ? mcpErrorResult(JSON.parse(agentJson(answer.error))) : answered(body(tool.command, answer.result));
|
|
113
|
+
}, "run")
|
|
114
|
+
}
|
|
115
|
+
]));
|
|
116
|
+
commands.status = {
|
|
117
|
+
title: "This server's bot and profile",
|
|
118
|
+
description: "Which profile this server speaks for, where its bot token comes from, which bot it is, and which writing commands are on. Sends nothing.",
|
|
119
|
+
writes: false,
|
|
120
|
+
input: object({}),
|
|
121
|
+
run: /* @__PURE__ */ __name(async () => {
|
|
122
|
+
const auth = await invoke(["bot", "auth", "show"], {});
|
|
123
|
+
const shown = "error" in auth ? auth.error : auth.result?.item ?? auth.result;
|
|
124
|
+
return answered(itemOf({
|
|
125
|
+
profile: settings.profile,
|
|
126
|
+
kind: "bot",
|
|
127
|
+
auth: shown,
|
|
128
|
+
writes: tools.filter((tool) => tool.writes && tool.availability?.().available !== false).map((tool) => tool.command),
|
|
129
|
+
permissions: levels()
|
|
130
|
+
}));
|
|
131
|
+
}, "run")
|
|
132
|
+
};
|
|
133
|
+
registerCommands(server, `${command}_bot`, commands, void 0, (asked) => {
|
|
134
|
+
const lock = readOnlyLockOf(bot.app, env);
|
|
135
|
+
const one = flatten(program.commands).find((info) => info.path[0] === "bot" && normal(info.path.slice(1).join(" ")) === asked);
|
|
136
|
+
if (lock && one && changesMessenger(one))
|
|
137
|
+
throw readOnlyRefusal(lock, MESSENGER_CHANGE_REFUSAL);
|
|
138
|
+
}, bot.app.messenger);
|
|
139
|
+
return server;
|
|
140
|
+
}, "build");
|
|
141
|
+
return { build, tools, offered: tools.map((tool) => tool.command) };
|
|
142
|
+
}, "createBotServer");
|
|
143
|
+
var serveBotOverStdio = /* @__PURE__ */ __name(async (options, note) => {
|
|
144
|
+
const { build } = createBotServer(options);
|
|
145
|
+
const handle = serveStdio(build, { onerror: /* @__PURE__ */ __name((error) => note(`mcp: ${error.message}`), "onerror") });
|
|
146
|
+
await new Promise((resolve) => {
|
|
147
|
+
process.stdin.once("end", resolve);
|
|
148
|
+
process.stdin.once("close", resolve);
|
|
149
|
+
process.once("SIGINT", resolve);
|
|
150
|
+
process.once("SIGTERM", resolve);
|
|
151
|
+
});
|
|
152
|
+
await handle.close();
|
|
153
|
+
}, "serveBotOverStdio");
|
|
154
|
+
|
|
155
|
+
export {
|
|
156
|
+
createBotServer,
|
|
157
|
+
serveBotOverStdio
|
|
158
|
+
};
|