Forked from cseliot/shell-command-runner
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
No test runner configured. No build script — lms dev handles compilation.
LM Studio plugin. Entry: src/index.ts → registers config schema + tools provider.
Three files, three concerns:
src/config.ts — defines all plugin settings via createConfigSchematics(). Each .field() call maps to a UI control in LM Studio. Config keys: operatingSystem, homeDirectory (sandbox root), executionPolicy, allowedCommands, forbiddenCommands, additionalSearchPaths, defaultTimeout, allowAutoExecution, testMode.
src/toolsProvider.ts — exports toolsProvider(ctl) which reads config once at startup (for shell/sandbox setup) and returns three tools:
run_shell_command — main tool; re-reads config on every invocation for live config changesget_whitelist / get_blacklist — read-only inspection toolssrc/index.ts — thin glue; calls context.withConfigSchematics() and context.withToolsProvider()
allowAutoExecution master kill switchcd {sandboxRoot} exception — cd target validated; any chained part (&& cmd) still runs through blacklist/whitelist before executioncheckBlacklist()) — catches command at start, middle, and end of chained commandscheckWhitelist()) — if policy === allow_only.. traversal and absolute paths (drive letters after ;, |, &&)exec() call → result formatted by formatResult()Number(exitCode) !== 1 — handles both numeric and string codes like 'ENOENT')TIMEOUT: prefix immediately (checked before error handling in formatResult)cmd.exe for Windows, /bin/bash for Linux/macOScd commands only allowed to exact sandbox root (not subdirectories); chained commands after && are still security-checkedC:\/D:/ after start-of-command, ;, |, or && — does NOT match colons in sed patternsformatResult(result) — single place for all output formatting; handles timeout, errors, stderr, stdout truncationcheckBlacklist(commandLower, forbiddenStr) — reused for both main commands and chained parts of cd exceptionscheckWhitelist(commandLower, allowedStr) — same reuse patternnpm run dev # start plugin in dev/watch mode via lms CLI
npm run push # push plugin to LM Studio