Skip to main content

repl-interaction

Patterns for controlling REPL sessions (Python, IPython, Node.js, Ruby, etc.) via terminalcp

Quellinformationen

Repository
code-yeongyu/sisyphus-private
Letzte Quellaktivität
2. November 2025 um 08:33
Erkannte Sprache von SKILL.md
Englisch
Sterne
19
Forks
2

Installationsoptionen

Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.

Quelldateien prüfen

Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.

SKILL.md wird angezeigt

SKILL.md
Quellanweisungen · Schreibgeschützte Vorschau
name
repl-interaction
description
Patterns for controlling REPL sessions (Python, IPython, Node.js, Ruby, etc.) via terminalcp
# REPL Interaction with terminalcp This skill provides comprehensive patterns for managing and automating REPL (Read-Eval-Print Loop) sessions using terminalcp MCP. It enables AI agents to execute code interactively, explore APIs, and prototype solutions in real-time. ## Overview terminalcp enables: - Interactive code execution in multiple languages - Real-time output capture and parsing - Persistent REPL sessions for stateful exploration - Parallel REPL management for multi-language projects - History and context preservation The MCP server runs via `npx @mariozechner/terminalcp@latest --mcp` and provides full terminal emulation for REPL interaction. ## Python REPL ### Starting Python REPL ```json { "action": "start", "command": "python3 -i", "name": "python-repl" } ``` ### Starting IPython (Enhanced REPL) ```json { "action": "start", "command": "ipython", "name": "ipython-repl" } ``` ### Basic Code Execution ```json // Simple expression { "action": "stdin", "id": "python-repl", "data": "2 + 2\r" } // Variable assignment { "action": "stdin", "id": "python-repl", "data": "x = 42\r" } // Import module { "action": "stdin", "id": "python-repl", "data": "import math\r" } // Use imported module { "action": "stdin", "id": "python-repl", "data": "math.sqrt(16)\r" } ``` ### Multi-Line Code Execution ```json // Start multi-line code { "action": "stdin", "id": "python-repl", "data": "def greet(name):\r" } { "action": "stdin", "id": "python-repl", "data": " return f'Hello, {name}!'\r" } // Empty line to finish { "action": "stdin", "id": "python-repl", "data": "\r" } // Call the function { "action": "stdin", "id": "python-repl", "data": "greet('Alice')\r" } ``` ### Capturing REPL Output ```json { "action": "stdout", "id": "python-repl" } ``` Returns the current terminal state including all executed code and output. ### Stream Mode for Real-Time Monitoring ```json { "action": "stream", "id": "python-repl", "since_last": true } ``` Returns only new output since last check, useful for monitoring long-running computations. ## IPython Advanced Features ### Magic Commands ```json // Time execution { "action": "stdin", "id": "ipython-repl", "data": "%timeit sum(range(1000))\r" } // Run external script { "action": "stdin", "id": "ipython-repl", "data": "%run script.py\r" } // Show history { "action": "stdin", "id": "ipython-repl", "data": "%history\r" } // List variables { "action": "stdin", "id": "ipython-repl", "data": "%whos\r" } // Edit code in external editor { "action": "stdin", "id": "ipython-repl", "data": "%edit myfunction\r" } ``` ### Object Introspection ```json // Get help { "action": "stdin", "id": "ipython-repl", "data": "str.split?\r" } // Detailed help { "action": "stdin", "id": "ipython-repl", "data": "str.split??\r" } // List methods { "action": "stdin", "id": "ipython-repl", "data": "dir(str)\r" } // Type inspection { "action": "stdin", "id": "ipython-repl", "data": "type(my_variable)\r" } ``` ### Shell Commands in IPython ```json // Run shell command { "action": "stdin", "id": "ipython-repl", "data": "!ls -la\r" } // Capture shell output { "action": "stdin", "id": "ipython-repl", "data": "files = !ls *.py\r" } // Use Python variables in shell { "action": "stdin", "id": "ipython-repl", "data": "!echo {my_var}\r" } ``` ## Node.js REPL ### Starting Node REPL ```json { "action": "start", "command": "node", "name": "node-repl" } ``` ### Basic JavaScript Execution ```json // Simple expression { "action": "stdin", "id": "node-repl", "data": "2 + 2\r" } // Variable declaration { "action": "stdin", "id": "node-repl", "data": "const x = 42\r" } // Array methods { "action": "stdin", "id": "node-repl", "data": "[1, 2, 3].map(n => n * 2)\r" } // Require module { "action": "stdin", "id": "node-repl", "data": "const fs = require('fs')\r" } ``` ### Multi-Line Code ```json // Start function definition { "action": "stdin", "id": "node-repl", "data": "function greet(name) {\r" } { "action": "stdin", "id": "node-repl", "data": " return `Hello, ${name}!`\r" } { "action": "stdin", "id": "node-repl", "data": "}\r" } // Call function { "action": "stdin", "id": "node-repl", "data": "greet('Bob')\r" } ``` ### Async/Await in REPL ```json // Define async function { "action": "stdin", "id": "node-repl", "data": "async function fetchData() { return 'data' }\r" } // Call with await (Node 16+) { "action": "stdin", "id": "node-repl", "data": "await fetchData()\r" } ``` ### Node REPL Commands ```json // Show help { "action": "stdin", "id": "node-repl", "data": ".help\r" } // Load file { "action": "stdin", "id": "node-repl", "data": ".load script.js\r" } // Save session to file { "action": "stdin", "id": "node-repl", "data": ".save session.js\r" } // Exit REPL { "action": "stdin", "id": "node-repl", "data": ".exit\r" } ``` ## Ruby REPL (irb) ### Starting Ruby REPL ```json { "action": "start", "command": "irb", "name": "ruby-repl" } ``` ### Ruby Code Execution ```json // Simple expression { "action": "stdin", "id": "ruby-repl", "data": "2 + 2\r" } // String manipulation { "action": "stdin", "id": "ruby-repl", "data": "'hello'.upcase\r" } // Array operations { "action": "stdin", "id": "ruby-repl", "data": "[1, 2, 3].map { |n| n * 2 }\r" } // Define method { "action": "stdin", "id": "ruby-repl", "data": "def greet(name); \"Hello, #{name}!\"; end\r" } // Call method { "action": "stdin", "id": "ruby-repl", "data": "greet('Charlie')\r" } ``` ## Lua REPL ### Starting Lua REPL ```json { "action": "start", "command": "lua", "name": "lua-repl" } ``` ### Lua Code Execution ```json // Simple expression { "action": "stdin", "id": "lua-repl", "data": "print(2 + 2)\r" } // Table manipulation { "action": "stdin", "id": "lua-repl", "data": "t = {1, 2, 3}\r" } { "action": "stdin", "id": "lua-repl", "data": "print(t[1])\r" } ``` ## Advanced Patterns ### API Exploration Workflow ```json // 1. Start IPython session { "action": "start", "command": "ipython", "name": "api-explore" } // 2. Import library { "action": "stdin", "id": "api-explore", "data": "import requests\r" } // 3. Inspect module { "action": "stdin", "id": "api-explore", "data": "dir(requests)\r" } // 4. Get help on specific function { "action": "stdin",
Auf GitHub ansehen
Diese SKILL.md ist sehr gross, daher zeigt SkillsMP hier nur den ersten Abschnitt. Auf GitHub ansehen