浏览器与自动化
1.
2.
3.
4. System prompt in
add-tool
Add a new function calling tool (vault operation) for the Gemini chat. Use when adding new tools like read_note, create_note, etc.
takeshy · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add takeshy/obsidian-llm-hub --skill add-tool技能说明
name: add-tool description: Add a new function calling tool (vault operation) for the Gemini chat. Use when adding new tools like read_note, create_note, etc. argument-hint: "[tool-name]" disable-model-invocation: true allowed-tools: Read, Edit, Write, Grep, Glob, Bash
Add New Function Calling Tool
Add a new function calling tool called $ARGUMENTS to the Gemini chat integration.
Required File Changes
1. src/core/tools.ts
- Add
ToolDefinitionto the appropriate tools array (read/write/delete) - Define
name,description, andparametersschema - Property types:
STRING,BOOLEAN,INTEGER,ARRAY,OBJECT - Add to
getEnabledTools()logic if it needs conditional enabling
2. src/vault/toolExecutor.ts
- Add
caseinexecuteToolCall()switch for the new tool name - Implement the execution logic (typically calling methods from
notes.tsorsearch.ts)
3. src/vault/notes.ts or src/vault/search.ts (if needed)
- Add the underlying vault operation method if it doesn't exist yet
- Use
app.vaultfor file operations,app.workspacefor UI operations
4. System prompt in src/ui/components/Chat.tsx
- Update the system prompt to mention the new tool's capabilities
- This helps the model know when to use the tool
Tool Design Guidelines
- Safe editing: Use
propose_editpattern (apply changes, backup original, user confirms) - Read-only tools: Always enabled; add to read tools array
- Write tools: Gated by
allowWriteoption - Delete tools: Gated by
allowDeleteoption (opt-in) - Naming: Use
snake_case(e.g.,read_note,create_folder) - Results: Return structured objects; large results will be truncated to 500 chars in tracing
Verification
- Run
npm run lint - Run
npm run build - Verify the tool appears in enabled tools based on its category