@bolloon/bolloon-agent 0.3.30 → 0.3.32
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/agents/pi-sdk-tools.js +128 -0
- package/dist/cli/ink-app.js +345 -2
- package/dist/cli/mention-data.js +238 -0
- package/dist/constraint-runtime/_archive_helper.d.ts +1 -0
- package/dist/constraint-runtime/_archive_helper.js +9 -0
- package/dist/constraint-runtime/agent/coordinator.d.ts +19 -0
- package/dist/constraint-runtime/agent/coordinator.js +48 -0
- package/dist/constraint-runtime/agent/index.d.ts +1 -0
- package/dist/constraint-runtime/agent/index.js +1 -0
- package/dist/constraint-runtime/assistant/index.d.ts +11 -0
- package/dist/constraint-runtime/assistant/index.js +12 -0
- package/dist/constraint-runtime/bootstrap/index.d.ts +11 -0
- package/dist/constraint-runtime/bootstrap/index.js +12 -0
- package/dist/constraint-runtime/bootstrap_graph.d.ts +4 -0
- package/dist/constraint-runtime/bootstrap_graph.js +13 -0
- package/dist/constraint-runtime/bridge/index.d.ts +11 -0
- package/dist/constraint-runtime/bridge/index.js +12 -0
- package/dist/constraint-runtime/buddy/index.d.ts +11 -0
- package/dist/constraint-runtime/buddy/index.js +12 -0
- package/dist/constraint-runtime/cli/index.d.ts +11 -0
- package/dist/constraint-runtime/cli/index.js +12 -0
- package/dist/constraint-runtime/command_graph.d.ts +7 -0
- package/dist/constraint-runtime/command_graph.js +10 -0
- package/dist/constraint-runtime/commands.d.ts +15 -0
- package/dist/constraint-runtime/commands.js +60 -0
- package/dist/constraint-runtime/components/index.d.ts +11 -0
- package/dist/constraint-runtime/components/index.js +12 -0
- package/dist/constraint-runtime/constants/index.d.ts +11 -0
- package/dist/constraint-runtime/constants/index.js +12 -0
- package/dist/constraint-runtime/constraint/budget.d.ts +11 -0
- package/dist/constraint-runtime/constraint/budget.js +22 -0
- package/dist/constraint-runtime/constraint/index.d.ts +3 -0
- package/dist/constraint-runtime/constraint/index.js +2 -0
- package/dist/constraint-runtime/constraint/permission.d.ts +9 -0
- package/dist/constraint-runtime/constraint/permission.js +20 -0
- package/dist/constraint-runtime/context.d.ts +12 -0
- package/dist/constraint-runtime/context.js +30 -0
- package/dist/constraint-runtime/coordinator/index.d.ts +11 -0
- package/dist/constraint-runtime/coordinator/index.js +12 -0
- package/dist/constraint-runtime/cost_hook.d.ts +2 -0
- package/dist/constraint-runtime/cost_hook.js +4 -0
- package/dist/constraint-runtime/cost_tracker.d.ts +5 -0
- package/dist/constraint-runtime/cost_tracker.js +8 -0
- package/dist/constraint-runtime/deferred_init.d.ts +8 -0
- package/dist/constraint-runtime/deferred_init.js +10 -0
- package/dist/constraint-runtime/direct_modes.d.ts +7 -0
- package/dist/constraint-runtime/direct_modes.js +6 -0
- package/dist/constraint-runtime/dynamic-tool-loader.d.ts +13 -0
- package/dist/constraint-runtime/dynamic-tool-loader.js +85 -0
- package/dist/constraint-runtime/entrypoints/index.d.ts +11 -0
- package/dist/constraint-runtime/entrypoints/index.js +12 -0
- package/dist/constraint-runtime/execution_registry.d.ts +20 -0
- package/dist/constraint-runtime/execution_registry.js +44 -0
- package/dist/constraint-runtime/history.d.ts +9 -0
- package/dist/constraint-runtime/history.js +9 -0
- package/dist/constraint-runtime/hooks/index.d.ts +11 -0
- package/dist/constraint-runtime/hooks/index.js +12 -0
- package/dist/constraint-runtime/index.d.ts +26 -0
- package/dist/constraint-runtime/index.js +26 -0
- package/dist/constraint-runtime/ink.d.ts +1 -0
- package/dist/constraint-runtime/ink.js +4 -0
- package/dist/constraint-runtime/keybindings/index.d.ts +11 -0
- package/dist/constraint-runtime/keybindings/index.js +12 -0
- package/dist/constraint-runtime/memdir/index.d.ts +11 -0
- package/dist/constraint-runtime/memdir/index.js +12 -0
- package/dist/constraint-runtime/migrations/index.d.ts +11 -0
- package/dist/constraint-runtime/migrations/index.js +12 -0
- package/dist/constraint-runtime/models.d.ts +42 -0
- package/dist/constraint-runtime/models.js +1 -0
- package/dist/constraint-runtime/moreright/index.d.ts +11 -0
- package/dist/constraint-runtime/moreright/index.js +12 -0
- package/dist/constraint-runtime/native_ts/index.d.ts +11 -0
- package/dist/constraint-runtime/native_ts/index.js +12 -0
- package/dist/constraint-runtime/output_styles/index.d.ts +11 -0
- package/dist/constraint-runtime/output_styles/index.js +12 -0
- package/dist/constraint-runtime/parity_audit.d.ts +11 -0
- package/dist/constraint-runtime/parity_audit.js +12 -0
- package/dist/constraint-runtime/plugins/index.d.ts +11 -0
- package/dist/constraint-runtime/plugins/index.js +12 -0
- package/dist/constraint-runtime/port_manifest.d.ts +7 -0
- package/dist/constraint-runtime/port_manifest.js +11 -0
- package/dist/constraint-runtime/prefetch.d.ts +8 -0
- package/dist/constraint-runtime/prefetch.js +9 -0
- package/dist/constraint-runtime/query.d.ts +6 -0
- package/dist/constraint-runtime/query.js +1 -0
- package/dist/constraint-runtime/reference_data/archive_surface_snapshot.json +63 -0
- package/dist/constraint-runtime/reference_data/commands_snapshot.json +1037 -0
- package/dist/constraint-runtime/reference_data/subsystems/assistant.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/bootstrap.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/bridge.json +32 -0
- package/dist/constraint-runtime/reference_data/subsystems/buddy.json +13 -0
- package/dist/constraint-runtime/reference_data/subsystems/cli.json +26 -0
- package/dist/constraint-runtime/reference_data/subsystems/components.json +32 -0
- package/dist/constraint-runtime/reference_data/subsystems/constants.json +28 -0
- package/dist/constraint-runtime/reference_data/subsystems/coordinator.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/entrypoints.json +15 -0
- package/dist/constraint-runtime/reference_data/subsystems/hooks.json +32 -0
- package/dist/constraint-runtime/reference_data/subsystems/keybindings.json +21 -0
- package/dist/constraint-runtime/reference_data/subsystems/memdir.json +15 -0
- package/dist/constraint-runtime/reference_data/subsystems/migrations.json +18 -0
- package/dist/constraint-runtime/reference_data/subsystems/moreright.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/native_ts.json +11 -0
- package/dist/constraint-runtime/reference_data/subsystems/outputStyles.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/plugins.json +9 -0
- package/dist/constraint-runtime/reference_data/subsystems/remote.json +11 -0
- package/dist/constraint-runtime/reference_data/subsystems/schemas.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/screens.json +10 -0
- package/dist/constraint-runtime/reference_data/subsystems/server.json +10 -0
- package/dist/constraint-runtime/reference_data/subsystems/services.json +32 -0
- package/dist/constraint-runtime/reference_data/subsystems/skills.json +27 -0
- package/dist/constraint-runtime/reference_data/subsystems/state.json +13 -0
- package/dist/constraint-runtime/reference_data/subsystems/types.json +18 -0
- package/dist/constraint-runtime/reference_data/subsystems/upstreamproxy.json +9 -0
- package/dist/constraint-runtime/reference_data/subsystems/utils.json +32 -0
- package/dist/constraint-runtime/reference_data/subsystems/vim.json +12 -0
- package/dist/constraint-runtime/reference_data/subsystems/voice.json +8 -0
- package/dist/constraint-runtime/reference_data/tools_snapshot.json +922 -0
- package/dist/constraint-runtime/remote/index.d.ts +11 -0
- package/dist/constraint-runtime/remote/index.js +12 -0
- package/dist/constraint-runtime/remote_runtime.d.ts +8 -0
- package/dist/constraint-runtime/remote_runtime.js +9 -0
- package/dist/constraint-runtime/runtime/index.d.ts +1 -0
- package/dist/constraint-runtime/runtime/index.js +1 -0
- package/dist/constraint-runtime/runtime/session.d.ts +22 -0
- package/dist/constraint-runtime/runtime/session.js +35 -0
- package/dist/constraint-runtime/schemas/index.d.ts +11 -0
- package/dist/constraint-runtime/schemas/index.js +12 -0
- package/dist/constraint-runtime/screens/index.d.ts +11 -0
- package/dist/constraint-runtime/screens/index.js +12 -0
- package/dist/constraint-runtime/server/index.d.ts +11 -0
- package/dist/constraint-runtime/server/index.js +12 -0
- package/dist/constraint-runtime/services/index.d.ts +11 -0
- package/dist/constraint-runtime/services/index.js +12 -0
- package/dist/constraint-runtime/session_store.d.ts +8 -0
- package/dist/constraint-runtime/session_store.js +22 -0
- package/dist/constraint-runtime/setup.d.ts +19 -0
- package/dist/constraint-runtime/setup.js +30 -0
- package/dist/constraint-runtime/skills/index.d.ts +1 -0
- package/dist/constraint-runtime/skills/index.js +1 -0
- package/dist/constraint-runtime/skills/skill-registry.d.ts +14 -0
- package/dist/constraint-runtime/skills/skill-registry.js +28 -0
- package/dist/constraint-runtime/state/index.d.ts +11 -0
- package/dist/constraint-runtime/state/index.js +12 -0
- package/dist/constraint-runtime/system_init.d.ts +1 -0
- package/dist/constraint-runtime/system_init.js +20 -0
- package/dist/constraint-runtime/thinking/engine.d.ts +20 -0
- package/dist/constraint-runtime/thinking/engine.js +42 -0
- package/dist/constraint-runtime/thinking/index.d.ts +1 -0
- package/dist/constraint-runtime/thinking/index.js +1 -0
- package/dist/constraint-runtime/tool_pool.d.ts +8 -0
- package/dist/constraint-runtime/tool_pool.js +8 -0
- package/dist/constraint-runtime/tools/OpenCLI/execAdapter.d.ts +9 -0
- package/dist/constraint-runtime/tools/OpenCLI/execAdapter.js +7 -0
- package/dist/constraint-runtime/tools/OpenCLI/listAdapters.d.ts +5 -0
- package/dist/constraint-runtime/tools/OpenCLI/listAdapters.js +7 -0
- package/dist/constraint-runtime/tools/OpenCLI/runCommand.d.ts +10 -0
- package/dist/constraint-runtime/tools/OpenCLI/runCommand.js +7 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/cancelOrder.d.ts +17 -0
- package/dist/constraint-runtime/{src/tools → tools}/PolymarketSDK/cancelOrder.js +4 -7
- package/dist/constraint-runtime/tools/PolymarketSDK/clobShared.d.ts +50 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/clobShared.js +78 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/createOrder.d.ts +31 -0
- package/dist/constraint-runtime/{src/tools → tools}/PolymarketSDK/createOrder.js +9 -12
- package/dist/constraint-runtime/tools/PolymarketSDK/getMarket.d.ts +10 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/getMarket.js +16 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/getOrders.d.ts +16 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/getOrders.js +25 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/listMarkets.d.ts +23 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/listMarkets.js +24 -0
- package/dist/constraint-runtime/tools/SafeSDK/confirmTransaction.d.ts +10 -0
- package/dist/constraint-runtime/tools/SafeSDK/confirmTransaction.js +6 -0
- package/dist/constraint-runtime/tools/SafeSDK/createTransaction.d.ts +14 -0
- package/dist/constraint-runtime/tools/SafeSDK/createTransaction.js +8 -0
- package/dist/constraint-runtime/tools/SafeSDK/deploySafe.d.ts +10 -0
- package/dist/constraint-runtime/tools/SafeSDK/executeTransaction.d.ts +9 -0
- package/dist/constraint-runtime/tools/SafeSDK/executeTransaction.js +6 -0
- package/dist/constraint-runtime/tools/SafeSDK/getBalance.d.ts +7 -0
- package/dist/constraint-runtime/tools/SafeSDK/getBalance.js +6 -0
- package/dist/constraint-runtime/tools/SafeSDK/getPendingTransactions.d.ts +7 -0
- package/dist/constraint-runtime/tools/SafeSDK/getPendingTransactions.js +6 -0
- package/dist/constraint-runtime/tools/SafeSDK/proposeTransaction.d.ts +11 -0
- package/dist/constraint-runtime/tools/SafeSDK/proposeTransaction.js +6 -0
- package/dist/constraint-runtime/tools/WalletTools/autoPay.d.ts +26 -0
- package/dist/constraint-runtime/tools/WalletTools/createWallet.d.ts +7 -0
- package/dist/constraint-runtime/tools/WalletTools/getBalance.d.ts +11 -0
- package/dist/constraint-runtime/tools/WalletTools/importWallet.d.ts +10 -0
- package/dist/constraint-runtime/tools/WalletTools/sendTransaction.d.ts +20 -0
- package/dist/constraint-runtime/tools/WalletTools/signMessage.d.ts +10 -0
- package/dist/constraint-runtime/tools/WalletTools/transferToken.d.ts +17 -0
- package/dist/constraint-runtime/tools.d.ts +14 -0
- package/dist/constraint-runtime/tools.js +80 -0
- package/dist/constraint-runtime/transcript.d.ts +8 -0
- package/dist/constraint-runtime/transcript.js +19 -0
- package/dist/constraint-runtime/types/index.d.ts +11 -0
- package/dist/constraint-runtime/types/index.js +12 -0
- package/dist/constraint-runtime/upstream_proxy/index.d.ts +11 -0
- package/dist/constraint-runtime/upstream_proxy/index.js +12 -0
- package/dist/constraint-runtime/utils/index.d.ts +11 -0
- package/dist/constraint-runtime/utils/index.js +12 -0
- package/dist/constraint-runtime/vim/index.d.ts +11 -0
- package/dist/constraint-runtime/vim/index.js +12 -0
- package/dist/constraint-runtime/voice/index.d.ts +11 -0
- package/dist/constraint-runtime/voice/index.js +12 -0
- package/dist/index.js +7 -4
- package/dist/llm/config-store.js +39 -28
- package/dist/llm/pi-ai.js +64 -36
- package/dist/security/tool-gate.js +2 -0
- package/package.json +3 -2
- package/dist/constraint-runtime/src/tools/PolymarketSDK/clobShared.js +0 -104
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getMarket.js +0 -5
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getOrders.js +0 -19
- package/dist/constraint-runtime/src/tools/PolymarketSDK/listMarkets.js +0 -4
- /package/dist/constraint-runtime/{src/tools → tools}/SafeSDK/deploySafe.js +0 -0
- /package/dist/constraint-runtime/{src/tools → tools}/WalletTools/autoPay.js +0 -0
- /package/dist/constraint-runtime/{src/tools → tools}/WalletTools/createWallet.js +0 -0
- /package/dist/constraint-runtime/{src/tools → tools}/WalletTools/getBalance.js +0 -0
- /package/dist/constraint-runtime/{src/tools → tools}/WalletTools/importWallet.js +0 -0
- /package/dist/constraint-runtime/{src/tools → tools}/WalletTools/sendTransaction.js +0 -0
- /package/dist/constraint-runtime/{src/tools → tools}/WalletTools/signMessage.js +0 -0
- /package/dist/constraint-runtime/{src/tools → tools}/WalletTools/transferToken.js +0 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mention-data.ts — CLI @ / # 弹出窗数据源 (2026-08-05)
|
|
3
|
+
*
|
|
4
|
+
* 弹出窗三路命中:
|
|
5
|
+
* @ → 智能体 (本地 channels + 远端 channel 缓存)
|
|
6
|
+
* / → 命令 (CLI 内置 + Web 斜杠命令) + 技能 (3 个 skill 目录) + 插件 (MCP servers)
|
|
7
|
+
* # → 文件 (cwd 有限深度遍历)
|
|
8
|
+
*
|
|
9
|
+
* 全部走本地文件读取, 不依赖 web server 是否在跑 (CLI 模式 server 不启动).
|
|
10
|
+
*/
|
|
11
|
+
import * as fs from 'fs/promises';
|
|
12
|
+
import * as path from 'path';
|
|
13
|
+
import * as os from 'os';
|
|
14
|
+
const HOME = () => process.env.HOME || os.homedir() || '/tmp';
|
|
15
|
+
// ─── 命令 (CLI 内置) ─────────────────────────────────────────────────────────
|
|
16
|
+
const CLI_COMMANDS = [
|
|
17
|
+
{ kind: 'command', label: 'queue', hint: '切换队列模式', insert: 'queue' },
|
|
18
|
+
{ kind: 'command', label: 'dequeue', hint: '出队一条', insert: 'dequeue' },
|
|
19
|
+
{ kind: 'command', label: 'help', hint: '显示帮助', insert: 'help' },
|
|
20
|
+
{ kind: 'command', label: 'exit', hint: '退出', insert: 'exit' },
|
|
21
|
+
{ kind: 'command', label: 'peers', hint: '查看 P2P 节点', insert: 'peers' },
|
|
22
|
+
{ kind: 'command', label: 'iroh', hint: '查看 iroh 状态', insert: 'iroh' },
|
|
23
|
+
{ kind: 'command', label: 'add_friend', hint: '添加好友 <64位hex公钥>', insert: 'add_friend' },
|
|
24
|
+
];
|
|
25
|
+
/** Web 端斜杠命令 (server /message 路由 → LLM 工具) */
|
|
26
|
+
const WEB_COMMANDS = [
|
|
27
|
+
{ kind: 'command', label: 'plan', hint: '创建计划', insert: 'plan' },
|
|
28
|
+
{ kind: 'command', label: 'todo', hint: '勾选步骤', insert: 'todo' },
|
|
29
|
+
{ kind: 'command', label: 'review', hint: '审查计划', insert: 'review' },
|
|
30
|
+
{ kind: 'command', label: 'task', hint: '创建任务', insert: 'task' },
|
|
31
|
+
{ kind: 'command', label: 'goal', hint: '暂停目标', insert: 'goal' },
|
|
32
|
+
{ kind: 'command', label: 'skill', hint: '沉淀技能', insert: 'skill' },
|
|
33
|
+
{ kind: 'command', label: 'add-friend', hint: '添加好友 (智能体工具)', insert: 'add-friend' },
|
|
34
|
+
];
|
|
35
|
+
export function loadCommands() {
|
|
36
|
+
return [...CLI_COMMANDS, ...WEB_COMMANDS];
|
|
37
|
+
}
|
|
38
|
+
// ─── 智能体 (@) ──────────────────────────────────────────────────────────────
|
|
39
|
+
/** 本地 channels.json (server-types.ts CHANNELS_PATH) + 远端 channel 缓存 */
|
|
40
|
+
export async function loadAgents() {
|
|
41
|
+
const out = [];
|
|
42
|
+
// 本地 channels: 优先 ~/.bolloon/sessions/channels.json, 兜底 ~/.bolloon/channels.json
|
|
43
|
+
const channelsPaths = [
|
|
44
|
+
path.join(HOME(), '.bolloon', 'sessions', 'channels.json'),
|
|
45
|
+
path.join(HOME(), '.bolloon', 'channels.json'),
|
|
46
|
+
];
|
|
47
|
+
for (const p of channelsPaths) {
|
|
48
|
+
try {
|
|
49
|
+
const chs = JSON.parse(await fs.readFile(p, 'utf-8'));
|
|
50
|
+
if (Array.isArray(chs)) {
|
|
51
|
+
for (const c of chs) {
|
|
52
|
+
const name = c?.name;
|
|
53
|
+
if (typeof name === 'string' && name.trim()) {
|
|
54
|
+
out.push({ kind: 'agent', label: name.trim(), hint: '本地智能体', insert: name.trim() });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch { /* 尝试下一个路径 */ }
|
|
61
|
+
}
|
|
62
|
+
// 远端 channel 缓存: { peerPublicKey: Channel[] }
|
|
63
|
+
try {
|
|
64
|
+
const remote = JSON.parse(await fs.readFile(path.join(HOME(), '.bolloon', 'remote-channels-cache.json'), 'utf-8'));
|
|
65
|
+
if (remote && typeof remote === 'object') {
|
|
66
|
+
for (const [peerPk, channels] of Object.entries(remote)) {
|
|
67
|
+
if (!Array.isArray(channels))
|
|
68
|
+
continue;
|
|
69
|
+
for (const c of channels) {
|
|
70
|
+
const name = c?.name;
|
|
71
|
+
if (typeof name === 'string' && name.trim()) {
|
|
72
|
+
out.push({ kind: 'agent', label: name.trim(), hint: `远端 · ${peerPk.slice(0, 8)}…`, insert: name.trim() });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch { /* 无远端缓存 */ }
|
|
79
|
+
// 去重 (本地优先)
|
|
80
|
+
const seen = new Set();
|
|
81
|
+
return out.filter(i => {
|
|
82
|
+
if (seen.has(i.label))
|
|
83
|
+
return false;
|
|
84
|
+
seen.add(i.label);
|
|
85
|
+
return true;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
// ─── 技能 (/ 弹窗的一部分) ───────────────────────────────────────────────────
|
|
89
|
+
/** 3 个 skill 目录 (与 skill-loader.defaultSkillPaths 一致) */
|
|
90
|
+
export async function loadSkills() {
|
|
91
|
+
const out = [];
|
|
92
|
+
const dirs = [
|
|
93
|
+
path.join(HOME(), '.bolloon', 'skills'),
|
|
94
|
+
path.join(process.cwd(), '.bolloon', 'skills'),
|
|
95
|
+
path.join(HOME(), '.boll', 'skills'),
|
|
96
|
+
];
|
|
97
|
+
for (const d of dirs) {
|
|
98
|
+
let entries;
|
|
99
|
+
try {
|
|
100
|
+
entries = await fs.readdir(d, { withFileTypes: true });
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
for (const e of entries) {
|
|
106
|
+
if (!e.isDirectory() || e.name.startsWith('.'))
|
|
107
|
+
continue;
|
|
108
|
+
// 读 frontmatter description 作为提示 (轻量, 不引 skill-loader 依赖)
|
|
109
|
+
let desc = '';
|
|
110
|
+
try {
|
|
111
|
+
const raw = (await fs.readFile(path.join(d, e.name, 'SKILL.md'), 'utf-8')).slice(0, 800);
|
|
112
|
+
const m = raw.match(/^---\r?\n[\s\S]*?^description:\s*(.+)$/m);
|
|
113
|
+
if (m)
|
|
114
|
+
desc = m[1].trim().replace(/^["']|["']$/g, '').slice(0, 50);
|
|
115
|
+
}
|
|
116
|
+
catch { /* 无 SKILL.md → 仅目录名 */ }
|
|
117
|
+
out.push({ kind: 'skill', label: e.name, hint: desc || '技能', insert: e.name });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const seen = new Set();
|
|
121
|
+
return out.filter(i => {
|
|
122
|
+
if (seen.has(i.label))
|
|
123
|
+
return false;
|
|
124
|
+
seen.add(i.label);
|
|
125
|
+
return true;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
// ─── 插件 (/ 弹窗的一部分) — MCP servers ─────────────────────────────────────
|
|
129
|
+
/** ~/.mcp.json / cwd/.mcp.json 的 mcpServers 键名 */
|
|
130
|
+
export async function loadPlugins() {
|
|
131
|
+
const out = [];
|
|
132
|
+
const paths = [path.join(HOME(), '.mcp.json'), path.join(process.cwd(), '.mcp.json')];
|
|
133
|
+
for (const p of paths) {
|
|
134
|
+
try {
|
|
135
|
+
const data = JSON.parse(await fs.readFile(p, 'utf-8'));
|
|
136
|
+
const servers = data?.mcpServers;
|
|
137
|
+
if (servers && typeof servers === 'object') {
|
|
138
|
+
for (const name of Object.keys(servers)) {
|
|
139
|
+
out.push({ kind: 'plugin', label: name, hint: 'MCP 插件', insert: name });
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch { /* 下一个路径 */ }
|
|
145
|
+
}
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
// ─── 文件 (#) ────────────────────────────────────────────────────────────────
|
|
149
|
+
const SKIP_DIRS = new Set([
|
|
150
|
+
'node_modules', '.git', 'dist', 'build', 'out', 'target', '.cache', '.hermes',
|
|
151
|
+
'coverage', '.next', '.nuxt', '.venv', 'venv', '__pycache__', 'tmp', 'release',
|
|
152
|
+
'.bolloon', '.boll', '.turbo', '.idea', '.vscode', 'bin', 'lib', 'assets',
|
|
153
|
+
]);
|
|
154
|
+
/** cwd 有限深度 BFS, 只收文件, 上限 cap 个, 排序稳定 */
|
|
155
|
+
export async function loadFiles(_query, base = process.cwd(), maxDepth = 3, cap = 400) {
|
|
156
|
+
const out = [];
|
|
157
|
+
const stack = [{ dir: base, depth: 0 }];
|
|
158
|
+
while (stack.length > 0 && out.length < cap) {
|
|
159
|
+
const { dir, depth } = stack.pop();
|
|
160
|
+
let entries;
|
|
161
|
+
try {
|
|
162
|
+
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
// 目录优先入栈, 文件直接收集; 同层排序保证稳定
|
|
168
|
+
const dirs = [];
|
|
169
|
+
for (const e of entries) {
|
|
170
|
+
if (out.length >= cap)
|
|
171
|
+
break;
|
|
172
|
+
if (e.name.startsWith('.'))
|
|
173
|
+
continue;
|
|
174
|
+
const full = path.join(dir, e.name);
|
|
175
|
+
if (e.isDirectory()) {
|
|
176
|
+
if (depth < maxDepth && !SKIP_DIRS.has(e.name))
|
|
177
|
+
dirs.push({ dir: full, depth: depth + 1 });
|
|
178
|
+
}
|
|
179
|
+
else if (e.isFile()) {
|
|
180
|
+
const rel = path.relative(base, full);
|
|
181
|
+
out.push({ kind: 'file', label: rel, hint: '', insert: rel });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
dirs.reverse(); // 保证 pop 顺序按字母序
|
|
185
|
+
for (const d of dirs)
|
|
186
|
+
stack.push(d);
|
|
187
|
+
}
|
|
188
|
+
out.sort((a, b) => a.label.localeCompare(b.label));
|
|
189
|
+
return out;
|
|
190
|
+
}
|
|
191
|
+
/** 文件匹配评分: basename 前缀 > 全路径前缀 > basename 包含 > 全路径包含 */
|
|
192
|
+
export function matchFileScore(label, q) {
|
|
193
|
+
const base = label.split('/').pop() || label;
|
|
194
|
+
if (base.startsWith(q))
|
|
195
|
+
return 0;
|
|
196
|
+
if (label.startsWith(q))
|
|
197
|
+
return 1;
|
|
198
|
+
if (base.includes(q))
|
|
199
|
+
return 2;
|
|
200
|
+
if (label.includes(q))
|
|
201
|
+
return 3;
|
|
202
|
+
return -1;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* 从输入里检测当前 mention token (最后一个以 @ / # 开头的 token).
|
|
206
|
+
* 返回 { kind, query, start, trigger } — start 是触发符在 input 里的下标.
|
|
207
|
+
*
|
|
208
|
+
* 规则:
|
|
209
|
+
* @ → agent: token 里最后一个 @, 且 @ 前一个字符不是 ascii 字母数字 (防 email a@b.com)
|
|
210
|
+
* # → file: token 里最后一个 #, 允许路径含 / (如 #src/cli/), 前字符非 ascii 字母数字
|
|
211
|
+
* / → command: 必须是 token 第一个字符 (防 "看看 src/" 误触发), 如 /queue
|
|
212
|
+
*/
|
|
213
|
+
export function getMention(input) {
|
|
214
|
+
// 最后一个 token 的起始下标 (最后一个空白之后)
|
|
215
|
+
let tokenStart = input.length;
|
|
216
|
+
while (tokenStart > 0 && !/\s/.test(input[tokenStart - 1]))
|
|
217
|
+
tokenStart--;
|
|
218
|
+
const token = input.slice(tokenStart);
|
|
219
|
+
// 从后往前找触发符
|
|
220
|
+
for (let i = token.length - 1; i >= 0; i--) {
|
|
221
|
+
const ch = token[i];
|
|
222
|
+
if (ch !== '@' && ch !== '/' && ch !== '#')
|
|
223
|
+
continue;
|
|
224
|
+
if (ch === '/') {
|
|
225
|
+
// 命令: 只认 token 第一个字符
|
|
226
|
+
if (i !== 0)
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
// @ / #: 前一个字符是 ascii 字母数字 → email/url 场景, 跳过
|
|
231
|
+
if (i > 0 && /[A-Za-z0-9]/.test(token[i - 1]))
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
const kind = ch === '@' ? 'agent' : ch === '#' ? 'file' : 'command';
|
|
235
|
+
return { kind, query: token.slice(i + 1), start: tokenStart + i, trigger: ch };
|
|
236
|
+
}
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadArchiveMetadata(packageName: string): Record<string, unknown>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = path.dirname(__filename);
|
|
6
|
+
export function loadArchiveMetadata(packageName) {
|
|
7
|
+
const snapshotPath = path.join(__dirname, 'reference_data', 'subsystems', `${packageName}.json`);
|
|
8
|
+
return JSON.parse(fs.readFileSync(snapshotPath, 'utf-8'));
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface SubTask {
|
|
2
|
+
id: string;
|
|
3
|
+
description: string;
|
|
4
|
+
priority: number;
|
|
5
|
+
}
|
|
6
|
+
export interface AgentResult {
|
|
7
|
+
taskId: string;
|
|
8
|
+
output: string;
|
|
9
|
+
success: boolean;
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export declare class AgentCoordinator {
|
|
13
|
+
private engine;
|
|
14
|
+
constructor(maxDepth?: number);
|
|
15
|
+
dispatch(prompt: string, parallelCount?: number): Promise<AgentResult[]>;
|
|
16
|
+
private splitTask;
|
|
17
|
+
private executeTask;
|
|
18
|
+
private aggregate;
|
|
19
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { DeepThinkingEngine } from '../thinking/engine.js';
|
|
2
|
+
export class AgentCoordinator {
|
|
3
|
+
engine;
|
|
4
|
+
constructor(maxDepth = 3) {
|
|
5
|
+
this.engine = new DeepThinkingEngine(maxDepth);
|
|
6
|
+
}
|
|
7
|
+
async dispatch(prompt, parallelCount = 3) {
|
|
8
|
+
const tasks = this.splitTask(prompt, parallelCount);
|
|
9
|
+
const results = await Promise.all(tasks.map(task => this.executeTask(task)));
|
|
10
|
+
return this.aggregate(results);
|
|
11
|
+
}
|
|
12
|
+
splitTask(prompt, count) {
|
|
13
|
+
const words = prompt.split(/\s+/);
|
|
14
|
+
const chunkSize = Math.ceil(words.length / count);
|
|
15
|
+
const chunks = [];
|
|
16
|
+
for (let i = 0; i < count; i++) {
|
|
17
|
+
const chunk = words.slice(i * chunkSize, (i + 1) * chunkSize).join(' ');
|
|
18
|
+
if (chunk) {
|
|
19
|
+
chunks.push({
|
|
20
|
+
id: `task-${i}`,
|
|
21
|
+
description: chunk,
|
|
22
|
+
priority: i
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return chunks;
|
|
27
|
+
}
|
|
28
|
+
async executeTask(task) {
|
|
29
|
+
try {
|
|
30
|
+
const thinkResult = await this.engine.think(task.description);
|
|
31
|
+
return {
|
|
32
|
+
taskId: task.id,
|
|
33
|
+
output: thinkResult.finalOutput,
|
|
34
|
+
success: true
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return {
|
|
39
|
+
taskId: task.id,
|
|
40
|
+
output: String(error),
|
|
41
|
+
success: false
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
aggregate(results) {
|
|
46
|
+
return results.sort((a, b) => a.taskId.localeCompare(b.taskId));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AgentCoordinator, type SubTask, type AgentResult } from './coordinator.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AgentCoordinator } from './coordinator.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const ARCHIVE_NAME: string;
|
|
2
|
+
export declare const MODULE_COUNT: number;
|
|
3
|
+
export declare const SAMPLE_FILES: string[];
|
|
4
|
+
export declare const PORTING_NOTE: string;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
ARCHIVE_NAME: string;
|
|
7
|
+
MODULE_COUNT: number;
|
|
8
|
+
PORTING_NOTE: string;
|
|
9
|
+
SAMPLE_FILES: string[];
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { loadArchiveMetadata } from '../_archive_helper.js';
|
|
2
|
+
const SNAPSHOT = loadArchiveMetadata('assistant');
|
|
3
|
+
export const ARCHIVE_NAME = SNAPSHOT['archive_name'];
|
|
4
|
+
export const MODULE_COUNT = SNAPSHOT['module_count'];
|
|
5
|
+
export const SAMPLE_FILES = SNAPSHOT['sample_files'];
|
|
6
|
+
export const PORTING_NOTE = `Python placeholder package for '${ARCHIVE_NAME}' with ${MODULE_COUNT} archived module references.`;
|
|
7
|
+
export default {
|
|
8
|
+
ARCHIVE_NAME,
|
|
9
|
+
MODULE_COUNT,
|
|
10
|
+
PORTING_NOTE,
|
|
11
|
+
SAMPLE_FILES,
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const ARCHIVE_NAME: string;
|
|
2
|
+
export declare const MODULE_COUNT: number;
|
|
3
|
+
export declare const SAMPLE_FILES: string[];
|
|
4
|
+
export declare const PORTING_NOTE: string;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
ARCHIVE_NAME: string;
|
|
7
|
+
MODULE_COUNT: number;
|
|
8
|
+
PORTING_NOTE: string;
|
|
9
|
+
SAMPLE_FILES: string[];
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { loadArchiveMetadata } from '../_archive_helper.js';
|
|
2
|
+
const SNAPSHOT = loadArchiveMetadata('bootstrap');
|
|
3
|
+
export const ARCHIVE_NAME = SNAPSHOT['archive_name'];
|
|
4
|
+
export const MODULE_COUNT = SNAPSHOT['module_count'];
|
|
5
|
+
export const SAMPLE_FILES = SNAPSHOT['sample_files'];
|
|
6
|
+
export const PORTING_NOTE = `Python placeholder package for '${ARCHIVE_NAME}' with ${MODULE_COUNT} archived module references.`;
|
|
7
|
+
export default {
|
|
8
|
+
ARCHIVE_NAME,
|
|
9
|
+
MODULE_COUNT,
|
|
10
|
+
PORTING_NOTE,
|
|
11
|
+
SAMPLE_FILES,
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function buildBootstrapGraph() {
|
|
2
|
+
return {
|
|
3
|
+
stages: [
|
|
4
|
+
'top-level prefetch side effects',
|
|
5
|
+
'warning handler and environment guards',
|
|
6
|
+
'CLI parser and pre-action trust gate',
|
|
7
|
+
'setup() + commands/agents parallel load',
|
|
8
|
+
'deferred init after trust',
|
|
9
|
+
'mode routing: local / remote / ssh / teleport / direct-connect / deep-link',
|
|
10
|
+
'query engine submit loop',
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const ARCHIVE_NAME: string;
|
|
2
|
+
export declare const MODULE_COUNT: number;
|
|
3
|
+
export declare const SAMPLE_FILES: string[];
|
|
4
|
+
export declare const PORTING_NOTE: string;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
ARCHIVE_NAME: string;
|
|
7
|
+
MODULE_COUNT: number;
|
|
8
|
+
PORTING_NOTE: string;
|
|
9
|
+
SAMPLE_FILES: string[];
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { loadArchiveMetadata } from '../_archive_helper.js';
|
|
2
|
+
const SNAPSHOT = loadArchiveMetadata('bridge');
|
|
3
|
+
export const ARCHIVE_NAME = SNAPSHOT['archive_name'];
|
|
4
|
+
export const MODULE_COUNT = SNAPSHOT['module_count'];
|
|
5
|
+
export const SAMPLE_FILES = SNAPSHOT['sample_files'];
|
|
6
|
+
export const PORTING_NOTE = `Python placeholder package for '${ARCHIVE_NAME}' with ${MODULE_COUNT} archived module references.`;
|
|
7
|
+
export default {
|
|
8
|
+
ARCHIVE_NAME,
|
|
9
|
+
MODULE_COUNT,
|
|
10
|
+
PORTING_NOTE,
|
|
11
|
+
SAMPLE_FILES,
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const ARCHIVE_NAME: string;
|
|
2
|
+
export declare const MODULE_COUNT: number;
|
|
3
|
+
export declare const SAMPLE_FILES: string[];
|
|
4
|
+
export declare const PORTING_NOTE: string;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
ARCHIVE_NAME: string;
|
|
7
|
+
MODULE_COUNT: number;
|
|
8
|
+
PORTING_NOTE: string;
|
|
9
|
+
SAMPLE_FILES: string[];
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { loadArchiveMetadata } from '../_archive_helper.js';
|
|
2
|
+
const SNAPSHOT = loadArchiveMetadata('buddy');
|
|
3
|
+
export const ARCHIVE_NAME = SNAPSHOT['archive_name'];
|
|
4
|
+
export const MODULE_COUNT = SNAPSHOT['module_count'];
|
|
5
|
+
export const SAMPLE_FILES = SNAPSHOT['sample_files'];
|
|
6
|
+
export const PORTING_NOTE = `Python placeholder package for '${ARCHIVE_NAME}' with ${MODULE_COUNT} archived module references.`;
|
|
7
|
+
export default {
|
|
8
|
+
ARCHIVE_NAME,
|
|
9
|
+
MODULE_COUNT,
|
|
10
|
+
PORTING_NOTE,
|
|
11
|
+
SAMPLE_FILES,
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const ARCHIVE_NAME: string;
|
|
2
|
+
export declare const MODULE_COUNT: number;
|
|
3
|
+
export declare const SAMPLE_FILES: string[];
|
|
4
|
+
export declare const PORTING_NOTE: string;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
ARCHIVE_NAME: string;
|
|
7
|
+
MODULE_COUNT: number;
|
|
8
|
+
PORTING_NOTE: string;
|
|
9
|
+
SAMPLE_FILES: string[];
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { loadArchiveMetadata } from '../_archive_helper.js';
|
|
2
|
+
const SNAPSHOT = loadArchiveMetadata('cli');
|
|
3
|
+
export const ARCHIVE_NAME = SNAPSHOT['archive_name'];
|
|
4
|
+
export const MODULE_COUNT = SNAPSHOT['module_count'];
|
|
5
|
+
export const SAMPLE_FILES = SNAPSHOT['sample_files'];
|
|
6
|
+
export const PORTING_NOTE = `Python placeholder package for '${ARCHIVE_NAME}' with ${MODULE_COUNT} archived module references.`;
|
|
7
|
+
export default {
|
|
8
|
+
ARCHIVE_NAME,
|
|
9
|
+
MODULE_COUNT,
|
|
10
|
+
PORTING_NOTE,
|
|
11
|
+
SAMPLE_FILES,
|
|
12
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getCommands } from './commands.js';
|
|
2
|
+
export function buildCommandGraph() {
|
|
3
|
+
const commands = getCommands();
|
|
4
|
+
return {
|
|
5
|
+
builtins: commands.filter(m => !m.sourceHint.toLowerCase().includes('plugin') &&
|
|
6
|
+
!m.sourceHint.toLowerCase().includes('skills')),
|
|
7
|
+
pluginLike: commands.filter(m => m.sourceHint.toLowerCase().includes('plugin')),
|
|
8
|
+
skillLike: commands.filter(m => m.sourceHint.toLowerCase().includes('skills')),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PortingModule } from './models.js';
|
|
2
|
+
export interface CommandExecution {
|
|
3
|
+
name: string;
|
|
4
|
+
sourceHint: string;
|
|
5
|
+
prompt: string;
|
|
6
|
+
handled: boolean;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const PORTED_COMMANDS: PortingModule[];
|
|
10
|
+
export { PortingModule };
|
|
11
|
+
export declare function builtInCommandNames(): Set<string>;
|
|
12
|
+
export declare function getCommand(name: string): PortingModule | undefined;
|
|
13
|
+
export declare function getCommands(includePluginCommands?: boolean, includeSkillCommands?: boolean): PortingModule[];
|
|
14
|
+
export declare function findCommands(query: string, limit?: number): PortingModule[];
|
|
15
|
+
export declare function executeCommand(name: string, prompt?: string): CommandExecution;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = path.dirname(__filename);
|
|
6
|
+
const SNAPSHOT_PATH = path.join(__dirname, 'reference_data', 'commands_snapshot.json');
|
|
7
|
+
function loadCommandSnapshot() {
|
|
8
|
+
try {
|
|
9
|
+
if (!fs.existsSync(SNAPSHOT_PATH)) {
|
|
10
|
+
console.warn(`[commands] Snapshot not found: ${SNAPSHOT_PATH}, using empty list`);
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
const raw = JSON.parse(fs.readFileSync(SNAPSHOT_PATH, 'utf-8'));
|
|
14
|
+
return raw.map((e) => ({
|
|
15
|
+
name: e.name,
|
|
16
|
+
responsibility: e.responsibility,
|
|
17
|
+
sourceHint: e.source_hint,
|
|
18
|
+
status: 'mirrored',
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.warn(`[commands] Failed to load snapshot: ${error}, using empty list`);
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export const PORTED_COMMANDS = loadCommandSnapshot();
|
|
27
|
+
export function builtInCommandNames() {
|
|
28
|
+
return new Set(PORTED_COMMANDS.map(m => m.name));
|
|
29
|
+
}
|
|
30
|
+
export function getCommand(name) {
|
|
31
|
+
const needle = name.toLowerCase();
|
|
32
|
+
return PORTED_COMMANDS.find(m => m.name.toLowerCase() === needle);
|
|
33
|
+
}
|
|
34
|
+
export function getCommands(includePluginCommands = true, includeSkillCommands = true) {
|
|
35
|
+
let commands = [...PORTED_COMMANDS];
|
|
36
|
+
if (!includePluginCommands) {
|
|
37
|
+
commands = commands.filter(m => !m.sourceHint.toLowerCase().includes('plugin'));
|
|
38
|
+
}
|
|
39
|
+
if (!includeSkillCommands) {
|
|
40
|
+
commands = commands.filter(m => !m.sourceHint.toLowerCase().includes('skills'));
|
|
41
|
+
}
|
|
42
|
+
return commands;
|
|
43
|
+
}
|
|
44
|
+
export function findCommands(query, limit = 20) {
|
|
45
|
+
const needle = query.toLowerCase();
|
|
46
|
+
return PORTED_COMMANDS.filter(m => m.name.toLowerCase().includes(needle) || m.sourceHint.toLowerCase().includes(needle)).slice(0, limit);
|
|
47
|
+
}
|
|
48
|
+
export function executeCommand(name, prompt = '') {
|
|
49
|
+
const module = getCommand(name);
|
|
50
|
+
if (!module) {
|
|
51
|
+
return { name, sourceHint: '', prompt, handled: false, message: `Unknown mirrored command: ${name}` };
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
name: module.name,
|
|
55
|
+
sourceHint: module.sourceHint,
|
|
56
|
+
prompt,
|
|
57
|
+
handled: true,
|
|
58
|
+
message: `Mirrored command '${module.name}' from ${module.sourceHint} would handle prompt.`,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const ARCHIVE_NAME: string;
|
|
2
|
+
export declare const MODULE_COUNT: number;
|
|
3
|
+
export declare const SAMPLE_FILES: string[];
|
|
4
|
+
export declare const PORTING_NOTE: string;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
ARCHIVE_NAME: string;
|
|
7
|
+
MODULE_COUNT: number;
|
|
8
|
+
PORTING_NOTE: string;
|
|
9
|
+
SAMPLE_FILES: string[];
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { loadArchiveMetadata } from '../_archive_helper.js';
|
|
2
|
+
const SNAPSHOT = loadArchiveMetadata('components');
|
|
3
|
+
export const ARCHIVE_NAME = SNAPSHOT['archive_name'];
|
|
4
|
+
export const MODULE_COUNT = SNAPSHOT['module_count'];
|
|
5
|
+
export const SAMPLE_FILES = SNAPSHOT['sample_files'];
|
|
6
|
+
export const PORTING_NOTE = `Python placeholder package for '${ARCHIVE_NAME}' with ${MODULE_COUNT} archived module references.`;
|
|
7
|
+
export default {
|
|
8
|
+
ARCHIVE_NAME,
|
|
9
|
+
MODULE_COUNT,
|
|
10
|
+
PORTING_NOTE,
|
|
11
|
+
SAMPLE_FILES,
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const ARCHIVE_NAME: string;
|
|
2
|
+
export declare const MODULE_COUNT: number;
|
|
3
|
+
export declare const SAMPLE_FILES: string[];
|
|
4
|
+
export declare const PORTING_NOTE: string;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
ARCHIVE_NAME: string;
|
|
7
|
+
MODULE_COUNT: number;
|
|
8
|
+
PORTING_NOTE: string;
|
|
9
|
+
SAMPLE_FILES: string[];
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { loadArchiveMetadata } from '../_archive_helper.js';
|
|
2
|
+
const SNAPSHOT = loadArchiveMetadata('constants');
|
|
3
|
+
export const ARCHIVE_NAME = SNAPSHOT['archive_name'];
|
|
4
|
+
export const MODULE_COUNT = SNAPSHOT['module_count'];
|
|
5
|
+
export const SAMPLE_FILES = SNAPSHOT['sample_files'];
|
|
6
|
+
export const PORTING_NOTE = `Python placeholder package for '${ARCHIVE_NAME}' with ${MODULE_COUNT} archived module references.`;
|
|
7
|
+
export default {
|
|
8
|
+
ARCHIVE_NAME,
|
|
9
|
+
MODULE_COUNT,
|
|
10
|
+
PORTING_NOTE,
|
|
11
|
+
SAMPLE_FILES,
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UsageSummary } from '../models.js';
|
|
2
|
+
export declare class BudgetTracker {
|
|
3
|
+
maxBudgetTokens: number;
|
|
4
|
+
maxTurns: number;
|
|
5
|
+
compactAfterTurns: number;
|
|
6
|
+
constructor(maxBudgetTokens?: number, maxTurns?: number, compactAfterTurns?: number);
|
|
7
|
+
addTurn(inputTokens: number, outputTokens: number): UsageSummary;
|
|
8
|
+
isBudgetExceeded(usage: UsageSummary): boolean;
|
|
9
|
+
isTurnLimitExceeded(currentTurns: number): boolean;
|
|
10
|
+
shouldCompact(turnCount: number): boolean;
|
|
11
|
+
}
|