o15ika's profile picture
o15ika

terminal

Public

Forked from bakit/terminal

13 Downloads

README

šŸš€ LM Studio Terminal Plugin

A powerful terminal plugin for LM Studio with enhanced security, comprehensive system tools, and a unified toolset.


šŸ“¦ Available Tools

ToolDescription
shell_execExecute a shell command with sanitisation, retry, and configurable timeout
run_processSpawn a process with arguments (no shell interpreter)
file_writeWrite content to a file (creates directories automatically)
read_fileRead file contents
file_diffCompare two files (unified diff format, pure JS LCS/Myers algorithm)
file_checksumCalculate SHA256 or MD5 checksum
file_statsGet file metadata (size, modified, permissions, type)
list_directoryList directory contents with metadata
create_directoryCreate directories (recursive by default)
delete_fileDelete a file or directory (auto-detects type)
delete_directoryDelete a directory and contents
system_infoComprehensive system diagnostics (CPU, memory, uptime, load avg)
list_processesList running processes with PID, CPU%, memory, status
kill_processTerminate a process by PID (validated, no shell injection)
check_networkDNS + TCP connectivity check with latency reporting
get_network_infoGet network interface information
get_disk_infoGet disk/volume information
zip_createCreate a .zip archive (pure JS, no external deps)
zip_extractExtract a .zip archive (pure JS)
zip_listList contents of a .zip archive (pure JS)
replace_textFind and replace text within a file (regex support)
count_textCount occurrences of text or regex patterns in a file
insert_textInsert text at a specific line in a file
delete_linesDelete a range of lines from a file

šŸš€ Quick Start

Installation

cd "C:\LM Studio DATABASE\terminal"
npm install
npm run build

Load in LM Studio

  • Open LM Studio → Plugins section
  • Add the terminal plugin directory
  • Configure settings as needed (shell path, windows shell, etc.)
  • Start using terminal commands!

šŸ”’ Security

  • Command sanitisation: Blocks dangerous patterns (rm -rf, del, format, shutdown, reboot, eval, source) — checks both original and lowercased input
  • Path sanitisation: Prevents writing to system directories, blocks .. traversal and null bytes
  • Rate limiting: Configurable command rate limiting
  • Audit logging: Tracks command history via Pino
  • Input validation: All parameters are validated via Zod schemas before execution
  • PID injection prevention: kill_process validates PID is a positive integer and uses runProcess with array args (no shell)
  • Host injection prevention: check_network escapes single quotes in hostnames

āš™ļø Configuration

SettingDescriptionDefault
defaultShellDefault shellpowershell
defaultTimeoutMsDefault command timeout30,000 ms
maxOutputBytesMaximum output size10 MB
maxConcurrentExecutionsMax concurrent executions4
logLevelLogging levelinfo
maxRetriesRetry attempts on transient errors2
retryDelayMsDelay between retries500 ms

Config is stored at ~/.lmstudio-terminal/config.json.


šŸ— Project Structure

terminal/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ index.ts              # Plugin entry point
│   ā”œā”€ā”€ toolsProvider.ts      # All tool definitions (24 tools)
│   ā”œā”€ā”€ executor.ts           # execCommand, runProcess, retry logic
│   ā”œā”€ā”€ fileUtilities.ts      # File read/write/diff/checksum/stats + pure JS zip
│   ā”œā”€ā”€ systemUtilities.ts    # System info, processes, network, disks
│   ā”œā”€ā”€ securityEnhanced.ts   # Sanitisation, validation, rate limiting
│   ā”œā”€ā”€ config.ts             # LM Studio config schematics
│   ā”œā”€ā”€ constants.ts          # Thresholds and limits
│   ā”œā”€ā”€ errors.ts             # Custom error classes
│   ā”œā”€ā”€ logger.ts             # Pino-based logging
│   ā”œā”€ā”€ types.ts              # Shared TypeScript types
│   ā”œā”€ā”€ runtimeResolver.ts    # Runtime detection & resolution
│   ā”œā”€ā”€ cache.ts              # Command result cache (TTL-based)
│   ā”œā”€ā”€ progressIndicator.ts  # Progress tracking
│   ā”œā”€ā”€ pluginTypes.ts        # Additional shared type definitions
│   ā”œā”€ā”€ enhancedUtils.ts      # Re-export barrel
│   └── tools/
│       ā”œā”€ā”€ shell_tools.ts    # shell_exec, run_process
│       ā”œā”€ā”€ file_tools.ts     # file_write, read_file, diff, checksum, stats, list, create/delete dir
│       ā”œā”€ā”€ system_tools.ts   # system_info, list_processes, kill_process, check_network, get_network_info, get_disk_info
│       ā”œā”€ā”€ archive_tools.ts  # zip_create, zip_extract, zip_list
│       └── text_tools.ts     # replace_text, count_text, insert_text, delete_lines
ā”œā”€ā”€ package.json
ā”œā”€ā”€ tsconfig.json
ā”œā”€ā”€ manifest.json
ā”œā”€ā”€ .eslintrc.json
ā”œā”€ā”€ .prettierrc
└── .gitignore

šŸ“„ License

Apache 2.0