Files

1 line
7.0 KiB
JSON

{"repo": "cheong43/mitosis-cli", "files": {"README.md": {"2fe12f11e69561cba065d7985812e2d4e7775d9b": {"t": 1785596183.1452823, "n": 6868, "h": "cbecf2d9c409443a", "c": "# Mempedia CodeCLI\n\nA React-based CLI agent that interacts with Mempedia for context and knowledge management.\n\n## Prerequisites\n\n- Node.js\n- Rust (to build Mempedia)\n- OpenAI API Key or another OpenAI-compatible API key\n\n## Setup\n\n1. Build Mempedia (if not already built):\n ```bash\n cd ..\n cargo build --release\n cd mitosis-cli\n ```\n\n2. Install dependencies:\n ```bash\n npm install\n ```\n\n3. Configure Environment:\n Create a `.env` file in `mitosis-cli`.\n \n For OpenAI or any OpenAI-compatible endpoint:\n ```\n OPENAI_API_KEY=your_key_here\n OPENAI_BASE_URL=https://api.openai.com/v1\n OPENAI_MODEL=gpt-4o\n ```\n\n For embeddings used by Mempedia hybrid search (optional):\n ```\n EMBEDDING_API_KEY=your_key_here\n EMBEDDING_BASE_URL=https://api.openai.com/v1\n EMBEDDING_MODEL=text-embedding-3-small\n ```\n\n For separate memory extraction/saving model (optional):\n ```\n MEMORY_API_KEY=your_memory_key_here\n MEMORY_BASE_URL=https://aigw-gzgy2.cucloud.cn:8443/v1\n MEMORY_MODEL=Qwen3.5-397B-A17B\n ```\n\n Coding Plan aliases are also supported:\n ```\n CODING_PLAN_BASE_URL=https://aigw-gzgy2.cucloud.cn:8443/v1\n CODING_PLAN_MODEL=Qwen3.5-397B-A17B\n ```\n\n Supported Coding Plan model names:\n - MiniMax-M2.5\n - glm-5\n - kimi-k2.5\n - Qwen3.5-397B-A17B\n - Qwen3-235B-A22B\n - DeepSeek V3.1\n\n Optional timeout controls for memory background tasks:\n ```\n MEMPEDIA_REQUEST_TIMEOUT_MS=0\n MEMORY_SAVE_ACTION_TIMEOUT_MS=0\n MEMORY_TASK_TIMEOUT_MS=0\n ```\n Set any timeout to a positive value only when you need forced fail-fast behavior.\n\n Optional GitHub token for online skill search:\n ```\n GITHUB_TOKEN=your_github_token_here\n ```\n This is not required, but it raises the GitHub API rate limit for `/skills search <query>`.\n\n Optional sandbox controls:\n ```\n MEMPEDIA_SHELL_TIMEOUT_MS=15000\n ```\n `bash` now executes inside `.mempedia/sandbox` with project-local `HOME`, `TMPDIR`, config, and cache directories.\n The sandbox blocks `git clone`, `git pull`, `git fetch`, `gh repo clone`, remote shell/file transfer, privilege escalation, and download-then-exec patterns.\n\n Branching ReAct loop controls:\n ```\n REACT_BRANCH_MAX_DEPTH=2\n REACT_BRANCH_MAX_WIDTH=3\n REACT_BRANCH_MAX_STEPS=8\n REACT_BRANCH_MAX_COMPLETED=4\n REACT_BRANCH_CONCURRENCY=3\n ```\n These tune how aggressively the agent forks child reasoning loops when one thought step has multiple viable next actions. Child branches get their own local step budget, while `REACT_BRANCH_CONCURRENCY` caps how many branches can run at the same time.\n\n## Running\n\n```bash\nnpm start\n```\n\nBy default, CodeCLI stores runtime state under `mitosis-cli/.mempedia`.\nSet `MEMPEDIA_PROJECT_ROOT` only if you intentionally want `.mempedia` written somewhere else.\n\n## Claude Code Skills Compatibility\n\n- `codecli` injects `./souls.md` into every agent run as global enterprise-KB routing guidance.\n- `codecli` loads local default skills from `./skills/*/SKILL.md` and `./.github/skills/*/SKILL.md` (Claude-style frontmatter + markdown body).\n- Mempedia-related local skills can declare `category`, `priority`, `tags`, and `always_include`; high-priority mempedia skills are preferred during automatic skill matching.\n- Mempedia Layer 4 skill records are treated as the project skills library. They are searchable immediately, but they become default codecli skills only after being downloaded into local `SKILL.md` files.\n- Agent-side Mempedia access is guided by SKILL.md documents and executed through `bash` by calling the `mempedia` CLI. CodeCLI no longer exposes planner-visible `mempedia_*` tool routes.\n- Runtime commands:\n - `/skills` list local skills\n - `/skills library [query]` list or search the mempedia skills library\n - `/skills download <skill_id>` download a mempedia library skill into local `skills/<skill_id>/SKILL.md`\n - `/skills search <query>` search public GitHub `SKILL.md` files and cache matches for activation\n - `/skills clear-remote` clear cached remote search results\n - `/skill <name>` activate a skill for subsequent turns\n - `/skill off` disable active skill\n - `/skill <name> <task>` run one task with a skill (one-shot)\n - `/ui start [port]` launch integrated mempedia-ui with CLI bridge\n - `/ui stop` stop integrated mempedia-ui server\n - `/ui status` show ui server status\n - `/help` show command list\n - `/clear` clear current screen history\n- When a skill is active, its description and body are injected into the request prompt so the agent follows that skill behavior.\n- When no skill is manually selected, `codecli` will try to auto-match relevant local skills from `SKILL.md` files and inject up to two matches.\n- Every reusable workflow should have a corresponding `SKILL.md` file rather than living only in ad hoc prompts.\n- The agent can also download a mempedia library skill into the local workspace when it decides that skill should become always-available guidance.\n- Remote skill search uses the GitHub code search API and treats matching `SKILL.md` files the same way as local skills once cached.\n- Shell execution is sandboxed. Use `bash` for local shell work inside the project, but repository sync and other sensitive shell patterns are blocked or require confirmation.\n- Integrated UI features:\n - Embedded CLI dialogue window inside `mempedia-ui`\n - Trace visualization for thought/action/observation flow\n - Memory snapshot endpoint so UI parses the same `.mempedia/memory` used by CLI\n\n## Architecture\n\n- **React/Ink**: UI rendering.\n- **Branching ReAct Agent**: The agent now treats ReAct as a functional loop. Each loop step can either:\n - continue linearly with one tool plan,\n - fork into multiple child branches when there are materially different strategies,\n - or finish with a final answer.\n- **Five Top-Level Tools**: The planner sees only `read`, `search`, `edit`, `bash`, and `web`. `read/search/edit` are workspace-only; all Mempedia memory, preference, and skill operations happen through `bash` calling the `mempedia` CLI under SKILL.md guidance.\n- **Independent Memory Classifier Agent**: After every completed turn, a dedicated `MemoryClassifierAgent` classifies the interaction against all four Mempedia layers and persists only the qualifying content asynchronously.\n- **Branch Synthesizer**: Completed branches are merged into one final user answer.\n- **Mempedia Client**: Communicates with `mempedia` binary via NDJSON over stdin/stdout.\n- **Governed Local Sandbox**: Shell and file operations execute through the runtime governance layer. Shell commands run with project-local sandbox directories and command-level safety checks.\n- **Memory Save Queue**: Completed-turn memory classification jobs are serialized in the background so knowledge extraction and raw conversation logging do not block the main loop.\n"}}}}