CLI Gadgets
Write gadgets (tools) for use with llmist agent.
Quick Start
Section titled “Quick Start”Create a file with a gadget class:
import { Gadget, z } from 'llmist';
export class FloppyDisk extends Gadget({ description: 'Calculate how many 1.44MB floppy disks are needed', schema: z.object({ filename: z.string(), megabytes: z.number().positive(), }),}) { execute(params: this['params']): string { const { filename, megabytes } = params; const disks = Math.ceil(megabytes / 1.44); return `${filename} requires ${disks} floppy disk(s). Label them 1/${disks}, 2/${disks}...`; }}Use it:
bunx @llmist/cli agent "How many floppies for DOOM.ZIP at 50MB?" --gadget ./floppy.tsnpx @llmist/cli agent "How many floppies for DOOM.ZIP at 50MB?" --gadget ./floppy.tsFile Requirements
Section titled “File Requirements”Gadget files must:
- Export one or more gadget classes
- Use TypeScript or JavaScript
- Be a valid ES module
// Multiple exports workexport class FloppyDisk extends Gadget({ ... }) { ... }export class DialUpModem extends Gadget({ ... }) { ... }
// Default exports work tooexport default class ArcadeHighScore extends Gadget({ ... }) { ... }Loading Multiple Gadgets
Section titled “Loading Multiple Gadgets”# Multiple filesbunx @llmist/cli agent "Calculate floppies and connect to BBS" \ --gadget ./floppy.ts \ --gadget ./dialup.ts
# Single file with multiple exportsbunx @llmist/cli agent "Calculate floppies and dial up" --gadget ./retro-tools.ts# Multiple filesnpx @llmist/cli agent "Calculate floppies and connect to BBS" \ --gadget ./floppy.ts \ --gadget ./dialup.ts
# Single file with multiple exportsnpx @llmist/cli agent "Calculate floppies and dial up" --gadget ./retro-tools.tsLoading Specific Gadgets
Section titled “Loading Specific Gadgets”Load a specific gadget from a file or package using the appropriate suffix:
# Load only FloppyDisk from a file with multiple exports (colon separator)bunx @llmist/cli agent "Calculate floppies" --gadget ./retro-tools.ts:FloppyDisk
# Load BrowseWeb subagent from npm package (slash separator)bunx @llmist/cli agent "Browse apple.com" -g dhalsim/BrowseWeb
# Load from scoped npm packagebunx @llmist/cli agent "task" -g @myorg/my-gadgets/MyGadget
# Load from git URL (slash separator)bunx @llmist/cli agent "task" -g git+https://github.com/user/repo#main/MyGadget# Load only FloppyDisk from a file with multiple exports (colon separator)npx @llmist/cli agent "Calculate floppies" --gadget ./retro-tools.ts:FloppyDisk
# Load BrowseWeb subagent from npm package (slash separator)npx @llmist/cli agent "Browse apple.com" -g dhalsim/BrowseWeb
# Load from scoped npm packagenpx @llmist/cli agent "task" -g @myorg/my-gadgets/MyGadget
# Load from git URL (slash separator)npx @llmist/cli agent "task" -g git+https://github.com/user/repo#main/MyGadgetExternal Gadgets
Section titled “External Gadgets”Load gadgets from npm packages or git repositories:
# npm package (Dhalsim browser automation)bunx @llmist/cli agent "Navigate to apple.com" -g dhalsim
# Use a presetbunx @llmist/cli agent "Browse the web" -g dhalsim:minimal
# Load specific gadget from packagebunx @llmist/cli agent "Browse the web" -g dhalsim/BrowseWeb
# git URLbunx @llmist/cli agent "task" -g git+https://github.com/user/repo.git
# git URL with specific gadgetbunx @llmist/cli agent "task" -g git+https://github.com/user/repo.git#main/MyGadget
# Combine sourcesbunx @llmist/cli agent "Complex task" \ -g ./local-gadget.ts \ -g dhalsim/BrowseWeb \ -g builtin:ReadFile# npm package (Dhalsim browser automation)npx @llmist/cli agent "Navigate to apple.com" -g dhalsim
# Use a presetnpx @llmist/cli agent "Browse the web" -g dhalsim:minimal
# Load specific gadget from packagenpx @llmist/cli agent "Browse the web" -g dhalsim/BrowseWeb
# git URLnpx @llmist/cli agent "task" -g git+https://github.com/user/repo.git
# git URL with specific gadgetnpx @llmist/cli agent "task" -g git+https://github.com/user/repo.git#main/MyGadget
# Combine sourcesnpx @llmist/cli agent "Complex task" \ -g ./local-gadget.ts \ -g dhalsim/BrowseWeb \ -g builtin:ReadFileSee Gadget Ecosystem for detailed documentation on Dhalsim, presets, and creating your own packages.
Testing Gadgets
Section titled “Testing Gadgets”Use the gadget command to test in isolation:
# Run interactivelybunx @llmist/cli gadget run ./floppy.ts
# View gadget infobunx @llmist/cli gadget info ./floppy.ts
# Validate structurebunx @llmist/cli gadget validate ./floppy.ts
# Pipe JSON inputecho '{"filename": "DOOM.ZIP", "megabytes": 50}' | bunx @llmist/cli gadget run ./floppy.ts# Run interactivelynpx @llmist/cli gadget run ./floppy.ts
# View gadget infonpx @llmist/cli gadget info ./floppy.ts
# Validate structurenpx @llmist/cli gadget validate ./floppy.ts
# Pipe JSON inputecho '{"filename": "DOOM.ZIP", "megabytes": 50}' | npx @llmist/cli gadget run ./floppy.tsCreating External Packages
Section titled “Creating External Packages”Add an llmist field to package.json:
{ "name": "my-gadgets", "llmist": { "gadgets": "./dist/index.js", "presets": { "all": "*", "minimal": ["GadgetA", "GadgetB"] } }}See Also
Section titled “See Also”- Creating Gadgets - Comprehensive gadget development guide
- Gadget Examples - Common gadget patterns
- Gadget Ecosystem - Third-party gadgets and packages
- CLI Configuration - Gadget approval settings
- Testing Gadgets - Unit testing gadgets