devorch 0.3.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. devorch-0.4.0/DEVORCH.md +48 -0
  2. {devorch-0.3.0 → devorch-0.4.0}/PKG-INFO +63 -34
  3. {devorch-0.3.0 → devorch-0.4.0}/README.md +61 -32
  4. {devorch-0.3.0 → devorch-0.4.0}/cli/commands/_shared.py +76 -8
  5. {devorch-0.3.0 → devorch-0.4.0}/cli/commands/ask.py +4 -1
  6. {devorch-0.3.0 → devorch-0.4.0}/cli/commands/run.py +4 -1
  7. {devorch-0.3.0 → devorch-0.4.0}/cli/constants.py +32 -27
  8. {devorch-0.3.0 → devorch-0.4.0}/cli/main.py +663 -59
  9. {devorch-0.3.0 → devorch-0.4.0}/core/agent.py +80 -6
  10. devorch-0.4.0/core/context.py +233 -0
  11. devorch-0.4.0/core/loop_detector.py +185 -0
  12. devorch-0.4.0/core/project_context.py +193 -0
  13. devorch-0.4.0/core/project_memory.py +317 -0
  14. {devorch-0.3.0 → devorch-0.4.0}/providers/anthropic.py +14 -1
  15. devorch-0.4.0/providers/base.py +141 -0
  16. {devorch-0.3.0 → devorch-0.4.0}/providers/custom.py +23 -24
  17. {devorch-0.3.0 → devorch-0.4.0}/providers/deepseek.py +21 -24
  18. {devorch-0.3.0 → devorch-0.4.0}/providers/gemini.py +17 -1
  19. {devorch-0.3.0 → devorch-0.4.0}/providers/github_copilot.py +21 -24
  20. {devorch-0.3.0 → devorch-0.4.0}/providers/groq.py +2 -1
  21. {devorch-0.3.0 → devorch-0.4.0}/providers/kimi.py +21 -24
  22. {devorch-0.3.0 → devorch-0.4.0}/providers/lmstudio.py +2 -1
  23. {devorch-0.3.0 → devorch-0.4.0}/providers/local.py +2 -1
  24. {devorch-0.3.0 → devorch-0.4.0}/providers/mistral.py +2 -1
  25. {devorch-0.3.0 → devorch-0.4.0}/providers/openai.py +15 -1
  26. {devorch-0.3.0 → devorch-0.4.0}/providers/openrouter.py +2 -1
  27. {devorch-0.3.0 → devorch-0.4.0}/providers/together.py +2 -1
  28. {devorch-0.3.0 → devorch-0.4.0}/pyproject.toml +1 -1
  29. {devorch-0.3.0 → devorch-0.4.0}/schemas/message.py +9 -0
  30. devorch-0.4.0/tests/test_context.py +72 -0
  31. {devorch-0.3.0 → devorch-0.4.0}/tests/test_core.py +17 -0
  32. devorch-0.4.0/tests/test_loop_detector.py +62 -0
  33. devorch-0.4.0/tests/test_project_context.py +65 -0
  34. devorch-0.4.0/tests/test_project_memory.py +134 -0
  35. {devorch-0.3.0 → devorch-0.4.0}/tests/test_tools.py +48 -0
  36. {devorch-0.3.0 → devorch-0.4.0}/tools/edit.py +30 -1
  37. {devorch-0.3.0 → devorch-0.4.0}/tools/grep.py +10 -5
  38. devorch-0.4.0/tools/shell.py +111 -0
  39. {devorch-0.3.0 → devorch-0.4.0}/tools/terminal_session.py +1 -1
  40. devorch-0.3.0/core/context.py +0 -0
  41. devorch-0.3.0/providers/base.py +0 -51
  42. devorch-0.3.0/tools/shell.py +0 -55
  43. {devorch-0.3.0 → devorch-0.4.0}/.github/workflows/ci.yml +0 -0
  44. {devorch-0.3.0 → devorch-0.4.0}/.github/workflows/publish.yml +0 -0
  45. {devorch-0.3.0 → devorch-0.4.0}/.gitignore +0 -0
  46. {devorch-0.3.0 → devorch-0.4.0}/LICENSE +0 -0
  47. {devorch-0.3.0 → devorch-0.4.0}/assets/chat.png +0 -0
  48. {devorch-0.3.0 → devorch-0.4.0}/assets/models.png +0 -0
  49. {devorch-0.3.0 → devorch-0.4.0}/assets/providers.png +0 -0
  50. {devorch-0.3.0 → devorch-0.4.0}/assets/startup.png +0 -0
  51. {devorch-0.3.0 → devorch-0.4.0}/assets/terminal.png +0 -0
  52. {devorch-0.3.0 → devorch-0.4.0}/assets/tools.png +0 -0
  53. {devorch-0.3.0 → devorch-0.4.0}/cli/commands/edit.py +0 -0
  54. {devorch-0.3.0 → devorch-0.4.0}/config/permissions.py +0 -0
  55. {devorch-0.3.0 → devorch-0.4.0}/config/profiles.py +0 -0
  56. {devorch-0.3.0 → devorch-0.4.0}/config/settings.py +0 -0
  57. {devorch-0.3.0 → devorch-0.4.0}/core/executor.py +0 -0
  58. {devorch-0.3.0 → devorch-0.4.0}/core/mcp.py +0 -0
  59. {devorch-0.3.0 → devorch-0.4.0}/core/memory.py +0 -0
  60. {devorch-0.3.0 → devorch-0.4.0}/core/modes.py +0 -0
  61. {devorch-0.3.0 → devorch-0.4.0}/core/planner.py +0 -0
  62. {devorch-0.3.0 → devorch-0.4.0}/core/sessions.py +0 -0
  63. {devorch-0.3.0 → devorch-0.4.0}/core/skills.py +0 -0
  64. {devorch-0.3.0 → devorch-0.4.0}/core/tasks.py +0 -0
  65. {devorch-0.3.0 → devorch-0.4.0}/providers/__init__.py +0 -0
  66. {devorch-0.3.0 → devorch-0.4.0}/schemas/task.py +0 -0
  67. {devorch-0.3.0 → devorch-0.4.0}/schemas/tool.py +0 -0
  68. {devorch-0.3.0 → devorch-0.4.0}/tests/__init__.py +0 -0
  69. {devorch-0.3.0 → devorch-0.4.0}/tests/test_integration.py +0 -0
  70. {devorch-0.3.0 → devorch-0.4.0}/tests/test_permissions.py +0 -0
  71. {devorch-0.3.0 → devorch-0.4.0}/tests/test_schemas.py +0 -0
  72. {devorch-0.3.0 → devorch-0.4.0}/tools/__init__.py +0 -0
  73. {devorch-0.3.0 → devorch-0.4.0}/tools/agent.py +0 -0
  74. {devorch-0.3.0 → devorch-0.4.0}/tools/base.py +0 -0
  75. {devorch-0.3.0 → devorch-0.4.0}/tools/filesystem.py +0 -0
  76. {devorch-0.3.0 → devorch-0.4.0}/tools/git.py +0 -0
  77. {devorch-0.3.0 → devorch-0.4.0}/tools/search.py +0 -0
  78. {devorch-0.3.0 → devorch-0.4.0}/tools/task.py +0 -0
  79. {devorch-0.3.0 → devorch-0.4.0}/tools/tests.py +0 -0
  80. {devorch-0.3.0 → devorch-0.4.0}/tools/websearch.py +0 -0
  81. {devorch-0.3.0 → devorch-0.4.0}/utils/logger.py +0 -0
@@ -0,0 +1,48 @@
1
+ # DevOrch - AI Coding Assistant CLI
2
+
3
+ ## Overview
4
+ DevOrch is an enterprise-ready, multi-provider AI coding assistant CLI with support for 13+ LLM providers, interactive REPL, persistent sessions, tool execution, MCP servers, and background terminal processes.
5
+
6
+ ## Tech Stack
7
+ - **Language**: Python 3.10+ (tested on Python 3.10-3.13)
8
+ - **CLI Framework**: Typer, Questionary, Prompt Toolkit, Rich
9
+ - **AI / SDKs**: OpenAI, Anthropic, Google GenAI SDK, HTTPX
10
+ - **Data Validation**: Pydantic v2
11
+ - **Testing & Quality**: Pytest, Pytest-asyncio, Ruff, Mypy
12
+
13
+ ## Architecture & Project Structure
14
+ - `cli/`: CLI entrypoints, Typer commands (`ask`, `edit`, `run`, `init`), slash command handlers, banners, and REPL.
15
+ - `core/`: Agent orchestration engine:
16
+ - `agent.py`: Main agentic loop, tool calling, execution loop, plan mode approval.
17
+ - `context.py`: Token estimation, context compaction, tool output pruning, token usage tracking.
18
+ - `loop_detector.py`: Duplicate call detection, oscillation detection, error thrashing prevention, turn advisories.
19
+ - `project_context.py`: Auto-discovers and loads repository instructions (`DEVORCH.md`, `CLAUDE.md`, `AGENTS.md`).
20
+ - `executor.py`: Tool permission enforcement and invocation.
21
+ - `planner.py`: Message preparation and system prompt injection.
22
+ - `sessions.py`: Session persistence, continuation, and summarization.
23
+ - `modes.py`: Agent execution modes (`ASK`, `AUTO`, `PLAN`).
24
+ - `memory.py` & `skills.py`: Persistent memory and skill definitions.
25
+ - `tools/`: Built-in tools:
26
+ - `filesystem.py`: File reading with pagination, writing, directory listing.
27
+ - `edit.py`: Surgical find/replace, line-based editing, diff generation.
28
+ - `grep.py`: Fast regex pattern search across text files.
29
+ - `search.py`: Glob-based file and directory search.
30
+ - `shell.py` & `terminal_session.py`: Shell execution and persistent terminal sessions.
31
+ - `providers/`: Unified LLM provider adapters (`openai`, `anthropic`, `gemini`, `groq`, `deepseek`, etc.).
32
+ - `schemas/`: Dataclasses for `Message`, `ToolCall`, `LLMResponse`, `TokenUsage`.
33
+
34
+ ## Common Commands
35
+ - **Run Tests**: `pytest` or `python -m pytest`
36
+ - **Run Single Test**: `pytest tests/test_context.py`
37
+ - **Lint**: `ruff check .`
38
+ - **Format**: `ruff format .`
39
+ - **Type Check**: `mypy .`
40
+ - **Run DevOrch Locally**: `devorch` or `python -m cli.main`
41
+
42
+ ## Coding Standards & Minimal Token Guidelines
43
+ 1. **Find Before Reading**: Always use `search` (to find file paths) or `grep` (to find symbols/definitions) before reading file contents.
44
+ 2. **Inspect Surgically**: Use `filesystem` with `action="read_lines"` or specific line ranges rather than dumping huge files.
45
+ 3. **Edit Surgically**: Use `edit` with `action="replace"` or `action="replace_lines"` to generate clean unified diffs. Avoid full file rewrites whenever possible.
46
+ 4. **Prevent Loops**: Never repeat identical tool calls with the same arguments. If a tool fails or finds nothing, alter the query or check file paths.
47
+ 5. **Verify Changes**: After modifying code, always run the relevant pytest test suite to verify correctness before reporting completion.
48
+ 6. **Preserve Compatibility**: Keep type hints compatible with Python 3.10+ (use `|` for unions or `Optional`/`Union`).
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: devorch
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Multi-provider AI coding assistant CLI with 13+ providers
5
5
  Project-URL: Homepage, https://github.com/Amanbig/DevOrch
6
6
  Project-URL: Repository, https://github.com/Amanbig/DevOrch
@@ -76,7 +76,9 @@ DevOrch gives you a coding assistant in your terminal that can execute shell com
76
76
 
77
77
  - **Provider freedom** — Switch between OpenAI, Anthropic, Gemini, Mistral, Groq, and 8 more providers (including local models) with a single command. No vendor lock-in.
78
78
  - **Actually does things** — Runs shell commands, edits files, manages background processes, searches the web. Not just a chatbot.
79
- - **Remembers you** — Persistent memory system stores your preferences, project context, and feedback across conversations.
79
+ - **Cross-session project memory** — Per-project persistent memory system automatically recalls architecture decisions, coding preferences, and recent session milestones across sessions.
80
+ - **Loop & thrashing safeguards** — Advanced safety layer detects duplicate calls, tool oscillation, and error loops, preventing runaway token drain.
81
+ - **Full token & speed transparency** — Real-time prompt/completion token tracking, context compaction metrics, and generation speed (`tok/s`) across 13 providers.
80
82
  - **Extensible** — Add custom skills as YAML files, connect MCP servers for additional tools, configure permissions per-tool.
81
83
 
82
84
  ## Quick Start
@@ -142,18 +144,27 @@ DevOrch can act on your system, not just talk about it:
142
144
  | `memory` | Persistent memory across conversations |
143
145
  | `websearch` / `webfetch` | Search the web, fetch URLs |
144
146
 
145
- ### Memory System
146
-
147
- DevOrch remembers context across conversations:
148
-
149
- ```
150
- /remember I prefer TypeScript over JavaScript
151
- /remember This project uses PostgreSQL, not MySQL
152
- /memory # View all saved memories
153
- /forget # Delete a memory interactively
147
+ ### Memory & Project Context
148
+
149
+ DevOrch maintains persistent memory so you never have to repeat context:
150
+
151
+ **1. Per-Project Memory (Cross-Session Recall)**
152
+ Stored automatically per repository in `~/.devorch/projects/<project_id>/`:
153
+ ```bash
154
+ /memory # View active architectural decisions & session history
155
+ /memory add Use uv for package management # Record an architectural decision
156
+ /memory pref Prefer clean async/await # Record a coding style preference
157
+ /memory clear # Clear project memory for this repository
154
158
  ```
159
+ *Accomplishments are automatically extracted and summarized on session exit with zero raw command leakage.*
155
160
 
156
- Memory types: **user** (preferences), **feedback** (corrections), **project** (context), **reference** (external links).
161
+ **2. Global Memory (Across All Projects)**
162
+ Stored in `~/.devorch/memory/`:
163
+ ```bash
164
+ /remember I prefer tabs over spaces
165
+ /remember Use ruff for Python linting
166
+ /forget # Interactively choose a memory to remove
167
+ ```
157
168
 
158
169
  ### Skills
159
170
 
@@ -285,6 +296,19 @@ devorch edit app/models.py "add created_at field" --mcp sqlite
285
296
 
286
297
  # List available skills
287
298
  devorch skills
299
+
300
+ # Browse providers and models directly from terminal
301
+ devorch providers # View all 13 providers & configuration status
302
+ devorch models # View models for active provider
303
+ devorch models anthropic # View models for a specific provider
304
+
305
+ # Inspect or manage project memory
306
+ devorch memory # View project decisions and recent accomplishments
307
+ devorch memory add "Use pytest" # Record a decision from the terminal
308
+ devorch memory clear # Clear project memory
309
+
310
+ # Repository initialization
311
+ devorch init # Generate or update DEVORCH.md repository instructions
288
312
  ```
289
313
 
290
314
  All non-interactive commands support `--provider`, `--model`, `--mode`, `--mcp`, and `--no-mcp`.
@@ -293,33 +317,38 @@ All non-interactive commands support `--provider`, `--model`, `--mode`, `--mcp`,
293
317
 
294
318
  | Command | Description |
295
319
  |---------|-------------|
296
- | `/help` | Show all commands |
297
- | `/models` | Browse and switch models (interactive) |
298
- | `/model <name>` | Switch model (partial match supported) |
299
- | `/providers` | Browse and switch providers (interactive) |
300
- | `/provider <name>` | Switch provider directly |
301
- | `/mode` | Switch mode (Plan/Auto/Ask) |
302
- | `/status` | Show current config |
303
- | `/auth [provider]` | Set/update API key |
304
- | `/memory` | Show saved memories |
305
- | `/remember <text>` | Save to memory |
306
- | `/forget` | Delete a memory |
320
+ | `/help` | Show categorized commands and shortcuts |
321
+ | `/mode [plan\|auto\|ask]` | Show or switch execution mode |
322
+ | `/plan` `/auto` `/ask` | Quick switch execution mode |
323
+ | `/models` | Search and browse models with 15/page pagination |
324
+ | `/model <name>` | Switch model directly or launch search |
325
+ | `/providers` | Search and browse providers with interactive pagination |
326
+ | `/provider <name>` | Switch provider directly or launch search |
327
+ | `/tokens` | Show session token usage, prompt/completion split, and costs |
328
+ | `/copy` | Copy last assistant response directly to clipboard |
329
+ | `/paste` | Enter multi-line paste mode for large text or code (`Alt+Enter` also inserts newlines) |
330
+ | `/status` | Show current provider, model, execution mode, and loaded context |
331
+ | `/auth [provider]` | Set or update API key for any provider |
332
+ | `/memory` | Show project memory (`/memory add <dec>`, `/memory pref <p>`, `/memory clear`) |
333
+ | `/remember <text>` | Save a note or convention to global memory |
334
+ | `/forget` | Delete a global memory interactively or by query |
335
+ | `/init` | Generate or update a `DEVORCH.md` project context file |
307
336
  | `/skills` | List available skills |
308
- | `/skill <name>` | Run a skill |
337
+ | `/skill <name>` | Run a skill directly |
309
338
  | `/commit` `/review` `/test` `/fix` `/explain` `/simplify` | Skill shortcuts |
310
- | `/session` | Session info |
311
- | `/history` | Conversation history |
312
- | `/clear` | Clear history |
313
- | `/compact` | Summarize history |
314
- | `/save` | Save to file |
315
- | `/undo` | Undo last message |
339
+ | `/session` | Current session ID, model, and message count |
340
+ | `/history` | Full conversation history in this session |
341
+ | `/clear` | Clear history (saves accomplishments to project memory) |
342
+ | `/compact` | Summarize and compact conversation history to save tokens |
343
+ | `/save` | Save conversation history to a file |
344
+ | `/undo` | Undo last message and agent turn |
316
345
  | `/mcp` | Show MCP server status |
317
346
  | `/mcp add <name> <cmd> [args]` | Connect a new MCP server mid-session |
318
347
  | `/mcp start <name>` | Reconnect a server from config |
319
348
  | `/mcp stop <name>` | Disconnect a server and remove its tools |
320
- | `/config` | Show configuration |
321
- | `/permissions` | Show permissions |
322
- | `/tasks` | Show task list |
349
+ | `/config` | Show configuration settings |
350
+ | `/permissions` | Show and manage tool permission settings |
351
+ | `/tasks` | Show multi-step task list and execution progress |
323
352
 
324
353
  ## Configuration
325
354
 
@@ -34,7 +34,9 @@ DevOrch gives you a coding assistant in your terminal that can execute shell com
34
34
 
35
35
  - **Provider freedom** — Switch between OpenAI, Anthropic, Gemini, Mistral, Groq, and 8 more providers (including local models) with a single command. No vendor lock-in.
36
36
  - **Actually does things** — Runs shell commands, edits files, manages background processes, searches the web. Not just a chatbot.
37
- - **Remembers you** — Persistent memory system stores your preferences, project context, and feedback across conversations.
37
+ - **Cross-session project memory** — Per-project persistent memory system automatically recalls architecture decisions, coding preferences, and recent session milestones across sessions.
38
+ - **Loop & thrashing safeguards** — Advanced safety layer detects duplicate calls, tool oscillation, and error loops, preventing runaway token drain.
39
+ - **Full token & speed transparency** — Real-time prompt/completion token tracking, context compaction metrics, and generation speed (`tok/s`) across 13 providers.
38
40
  - **Extensible** — Add custom skills as YAML files, connect MCP servers for additional tools, configure permissions per-tool.
39
41
 
40
42
  ## Quick Start
@@ -100,18 +102,27 @@ DevOrch can act on your system, not just talk about it:
100
102
  | `memory` | Persistent memory across conversations |
101
103
  | `websearch` / `webfetch` | Search the web, fetch URLs |
102
104
 
103
- ### Memory System
104
-
105
- DevOrch remembers context across conversations:
106
-
107
- ```
108
- /remember I prefer TypeScript over JavaScript
109
- /remember This project uses PostgreSQL, not MySQL
110
- /memory # View all saved memories
111
- /forget # Delete a memory interactively
105
+ ### Memory & Project Context
106
+
107
+ DevOrch maintains persistent memory so you never have to repeat context:
108
+
109
+ **1. Per-Project Memory (Cross-Session Recall)**
110
+ Stored automatically per repository in `~/.devorch/projects/<project_id>/`:
111
+ ```bash
112
+ /memory # View active architectural decisions & session history
113
+ /memory add Use uv for package management # Record an architectural decision
114
+ /memory pref Prefer clean async/await # Record a coding style preference
115
+ /memory clear # Clear project memory for this repository
112
116
  ```
117
+ *Accomplishments are automatically extracted and summarized on session exit with zero raw command leakage.*
113
118
 
114
- Memory types: **user** (preferences), **feedback** (corrections), **project** (context), **reference** (external links).
119
+ **2. Global Memory (Across All Projects)**
120
+ Stored in `~/.devorch/memory/`:
121
+ ```bash
122
+ /remember I prefer tabs over spaces
123
+ /remember Use ruff for Python linting
124
+ /forget # Interactively choose a memory to remove
125
+ ```
115
126
 
116
127
  ### Skills
117
128
 
@@ -243,6 +254,19 @@ devorch edit app/models.py "add created_at field" --mcp sqlite
243
254
 
244
255
  # List available skills
245
256
  devorch skills
257
+
258
+ # Browse providers and models directly from terminal
259
+ devorch providers # View all 13 providers & configuration status
260
+ devorch models # View models for active provider
261
+ devorch models anthropic # View models for a specific provider
262
+
263
+ # Inspect or manage project memory
264
+ devorch memory # View project decisions and recent accomplishments
265
+ devorch memory add "Use pytest" # Record a decision from the terminal
266
+ devorch memory clear # Clear project memory
267
+
268
+ # Repository initialization
269
+ devorch init # Generate or update DEVORCH.md repository instructions
246
270
  ```
247
271
 
248
272
  All non-interactive commands support `--provider`, `--model`, `--mode`, `--mcp`, and `--no-mcp`.
@@ -251,33 +275,38 @@ All non-interactive commands support `--provider`, `--model`, `--mode`, `--mcp`,
251
275
 
252
276
  | Command | Description |
253
277
  |---------|-------------|
254
- | `/help` | Show all commands |
255
- | `/models` | Browse and switch models (interactive) |
256
- | `/model <name>` | Switch model (partial match supported) |
257
- | `/providers` | Browse and switch providers (interactive) |
258
- | `/provider <name>` | Switch provider directly |
259
- | `/mode` | Switch mode (Plan/Auto/Ask) |
260
- | `/status` | Show current config |
261
- | `/auth [provider]` | Set/update API key |
262
- | `/memory` | Show saved memories |
263
- | `/remember <text>` | Save to memory |
264
- | `/forget` | Delete a memory |
278
+ | `/help` | Show categorized commands and shortcuts |
279
+ | `/mode [plan\|auto\|ask]` | Show or switch execution mode |
280
+ | `/plan` `/auto` `/ask` | Quick switch execution mode |
281
+ | `/models` | Search and browse models with 15/page pagination |
282
+ | `/model <name>` | Switch model directly or launch search |
283
+ | `/providers` | Search and browse providers with interactive pagination |
284
+ | `/provider <name>` | Switch provider directly or launch search |
285
+ | `/tokens` | Show session token usage, prompt/completion split, and costs |
286
+ | `/copy` | Copy last assistant response directly to clipboard |
287
+ | `/paste` | Enter multi-line paste mode for large text or code (`Alt+Enter` also inserts newlines) |
288
+ | `/status` | Show current provider, model, execution mode, and loaded context |
289
+ | `/auth [provider]` | Set or update API key for any provider |
290
+ | `/memory` | Show project memory (`/memory add <dec>`, `/memory pref <p>`, `/memory clear`) |
291
+ | `/remember <text>` | Save a note or convention to global memory |
292
+ | `/forget` | Delete a global memory interactively or by query |
293
+ | `/init` | Generate or update a `DEVORCH.md` project context file |
265
294
  | `/skills` | List available skills |
266
- | `/skill <name>` | Run a skill |
295
+ | `/skill <name>` | Run a skill directly |
267
296
  | `/commit` `/review` `/test` `/fix` `/explain` `/simplify` | Skill shortcuts |
268
- | `/session` | Session info |
269
- | `/history` | Conversation history |
270
- | `/clear` | Clear history |
271
- | `/compact` | Summarize history |
272
- | `/save` | Save to file |
273
- | `/undo` | Undo last message |
297
+ | `/session` | Current session ID, model, and message count |
298
+ | `/history` | Full conversation history in this session |
299
+ | `/clear` | Clear history (saves accomplishments to project memory) |
300
+ | `/compact` | Summarize and compact conversation history to save tokens |
301
+ | `/save` | Save conversation history to a file |
302
+ | `/undo` | Undo last message and agent turn |
274
303
  | `/mcp` | Show MCP server status |
275
304
  | `/mcp add <name> <cmd> [args]` | Connect a new MCP server mid-session |
276
305
  | `/mcp start <name>` | Reconnect a server from config |
277
306
  | `/mcp stop <name>` | Disconnect a server and remove its tools |
278
- | `/config` | Show configuration |
279
- | `/permissions` | Show permissions |
280
- | `/tasks` | Show task list |
307
+ | `/config` | Show configuration settings |
308
+ | `/permissions` | Show and manage tool permission settings |
309
+ | `/tasks` | Show multi-step task list and execution progress |
281
310
 
282
311
  ## Configuration
283
312
 
@@ -4,6 +4,9 @@ Shared utilities for DevOrch CLI commands.
4
4
  Exports: console, SYSTEM_PROMPT, SimplePlanner, create_provider, build_tools, resolve_mode
5
5
  """
6
6
 
7
+ import os
8
+ import platform
9
+
7
10
  import typer
8
11
 
9
12
  from config.settings import Settings
@@ -32,10 +35,10 @@ SYSTEM_PROMPT = """You are DevOrch, an AI coding assistant with access to tools
32
35
 
33
36
  IMPORTANT: You have the following tools available and MUST use them to help the user:
34
37
 
35
- 1. **shell** - Execute shell commands (bash/powershell). Use this to:
36
- - Run commands like `npm install`, `git clone`, `git status`, etc.
37
- - Navigate directories, create files, run scripts
38
- - Any short-lived terminal command that returns output
38
+ 1. **shell** - Execute shell commands (builds, tests, git, package managers). Use this to:
39
+ - Run CLI tools: `npm`, `pip`, `uv`, `pytest`, `cargo`, `git`
40
+ - Run project test suites, linters, and compilation scripts
41
+ - Do NOT use shell to inspect directory contents or read files — use `filesystem` instead!
39
42
 
40
43
  2. **terminal_session** — The PRIMARY tool for all terminal/process needs:
41
44
  - `start` — launch a command in a managed session. Defaults to 'bash' if no command.
@@ -112,12 +115,27 @@ RULES:
112
115
  - When the user corrects you or gives feedback, save it to memory for future conversations
113
116
  - When you learn about the user's role, preferences, or project context, save it to memory
114
117
 
115
- When executing shell commands, use the shell tool with the command to run."""
118
+ - When executing shell commands, use the shell tool with the command to run.
119
+
120
+ EFFICIENCY & SURGICAL WORKFLOW (MINIMIZE TOKENS):
121
+ - **Find before reading**: Use `search` (to locate files) or `grep` (to find specific functions/classes/patterns) instead of listing directory trees or reading arbitrary files.
122
+ - **Inspect surgically**: Use `filesystem` with `action="read_lines"` or bounded `max_lines` to inspect specific sections. Do NOT dump entire huge files into context when only a small section is needed.
123
+ - **Edit surgically**: Use `edit` with `action="replace"` or `action="replace_lines"` to make precise changes.
124
+ - **Verify without waste**: After making an edit, do NOT re-read the entire file if the diff confirmed the change. Verify with test or lint commands when applicable.
125
+ - **Avoid loops**: Never call the exact same tool with the exact same arguments repeatedly. If an edit or search fails, re-examine the target lines or change the query before retrying."""
116
126
 
117
127
 
118
128
  class SimplePlanner(Planner):
119
- def __init__(self, memory_context: str = "", tools: list | None = None):
129
+ def __init__(
130
+ self,
131
+ memory_context: str = "",
132
+ project_context: str = "",
133
+ project_memory_context: str = "",
134
+ tools: list | None = None,
135
+ ):
120
136
  self.memory_context = memory_context
137
+ self.project_context = project_context
138
+ self.project_memory_context = project_memory_context
121
139
  self._tools = tools or []
122
140
 
123
141
  def update_tools(self, tools: list) -> None:
@@ -127,6 +145,44 @@ class SimplePlanner(Planner):
127
145
  def plan(self, history: list[Message]) -> list[Message]:
128
146
  prompt = SYSTEM_PROMPT
129
147
 
148
+ # Append runtime environment & host OS shell guidance
149
+ os_name = platform.system()
150
+ os_release = platform.release()
151
+ os_machine = platform.machine()
152
+ cwd = os.getcwd()
153
+
154
+ if os_name == "Windows":
155
+ shell_info = (
156
+ f"\n\nENVIRONMENT & SYSTEM CONTEXT:\n"
157
+ f"- Host OS: Windows ({os_release}, {os_machine})\n"
158
+ f"- Current Working Directory: {cwd}\n"
159
+ f"- Shell: Windows cmd.exe / PowerShell\n"
160
+ f"- IMPORTANT SHELL RULES FOR WINDOWS:\n"
161
+ f" * Do NOT use Unix shell commands like `pwd`, `ls`, `ls -la`, `cat`, `touch`, `rm -rf`, `grep`, or `export`.\n"
162
+ f" * To inspect directory contents: use the `filesystem` tool with `action='list'`, `path='.'`.\n"
163
+ f" * To read files: use the `filesystem` tool with `action='read'`.\n"
164
+ f" * To search files: use `search` (glob) or `grep` (content search).\n"
165
+ f" * For builds & CLI tools, use direct commands: `pip`, `uv`, `npm`, `git`, `python`, `pytest`.\n"
166
+ f" * For Windows file paths in shell commands, use backslashes `\\` or wrap paths in quotes."
167
+ )
168
+ else:
169
+ shell_info = (
170
+ f"\n\nENVIRONMENT & SYSTEM CONTEXT:\n"
171
+ f"- Host OS: {os_name} ({os_release}, {os_machine})\n"
172
+ f"- Current Working Directory: {cwd}\n"
173
+ f"- Shell: bash/sh\n"
174
+ f"- Prefer using `filesystem` tool for reading and listing files to minimize token usage."
175
+ )
176
+ prompt += shell_info
177
+
178
+ # Append project rules/guidelines (from DEVORCH.md or CLAUDE.md)
179
+ if self.project_context:
180
+ prompt += "\n\n" + self.project_context
181
+
182
+ # Append persistent per-project memory (cross-session decisions & learnings)
183
+ if self.project_memory_context:
184
+ prompt += "\n\n" + self.project_memory_context
185
+
130
186
  # Append a live tool summary so the LLM knows exactly what's loaded,
131
187
  # including any MCP tools added after startup.
132
188
  if self._tools:
@@ -242,7 +298,14 @@ def resolve_mode(mode_str: str | None, default: AgentMode = AgentMode.AUTO) -> A
242
298
  raise typer.Exit(1) from err
243
299
 
244
300
 
245
- def build_agent(llm, tools: list, memory_ctx: str, agent_mode: AgentMode) -> "Agent":
301
+ def build_agent(
302
+ llm,
303
+ tools: list,
304
+ memory_ctx: str,
305
+ agent_mode: AgentMode,
306
+ project_ctx: str = "",
307
+ project_memory_ctx: str = "",
308
+ ) -> "Agent":
246
309
  """Construct a configured Agent ready to run.
247
310
 
248
311
  AgentTool is injected after construction since it needs the provider reference.
@@ -251,7 +314,12 @@ def build_agent(llm, tools: list, memory_ctx: str, agent_mode: AgentMode) -> "Ag
251
314
  """
252
315
  mode_manager = ModeManager(default_mode=agent_mode)
253
316
  executor = ToolExecutor(tools=tools, mode_manager=mode_manager)
254
- planner = SimplePlanner(memory_context=memory_ctx, tools=tools)
317
+ planner = SimplePlanner(
318
+ memory_context=memory_ctx,
319
+ project_context=project_ctx,
320
+ project_memory_context=project_memory_ctx,
321
+ tools=tools,
322
+ )
255
323
 
256
324
  agent = Agent(
257
325
  provider=llm,
@@ -6,6 +6,7 @@ from cli.commands._shared import build_agent, build_tools, console, create_provi
6
6
  from config.settings import Settings
7
7
  from core.memory import MemoryManager
8
8
  from core.modes import AgentMode
9
+ from core.project_context import ProjectContextLoader
9
10
  from core.skills import SkillManager
10
11
  from utils.logger import print_error, print_panel
11
12
 
@@ -41,7 +42,9 @@ def ask(
41
42
  tools = build_tools(settings, no_mcp=no_mcp, mcp_only=mcp or None)
42
43
  agent_mode = resolve_mode(mode, default=AgentMode.AUTO)
43
44
  memory_ctx = MemoryManager().get_context_prompt()
44
- agent = build_agent(llm, tools, memory_ctx, agent_mode)
45
+ project_ctx = ProjectContextLoader().load()
46
+ project_prompt = project_ctx.to_system_prompt_block() if project_ctx else ""
47
+ agent = build_agent(llm, tools, memory_ctx, agent_mode, project_ctx=project_prompt)
45
48
 
46
49
  skill_manager = SkillManager()
47
50
  if skill:
@@ -5,6 +5,7 @@ import typer
5
5
  from cli.commands._shared import build_agent, build_tools, console, create_provider, resolve_mode
6
6
  from config.settings import Settings
7
7
  from core.memory import MemoryManager
8
+ from core.project_context import ProjectContextLoader
8
9
  from core.skills import SkillManager
9
10
  from utils.logger import print_error, print_panel
10
11
 
@@ -49,7 +50,9 @@ def run(
49
50
  tools = build_tools(settings, no_mcp=no_mcp, mcp_only=mcp or None)
50
51
  agent_mode = resolve_mode(mode)
51
52
  memory_ctx = MemoryManager().get_context_prompt()
52
- agent = build_agent(llm, tools, memory_ctx, agent_mode)
53
+ project_ctx = ProjectContextLoader().load()
54
+ project_prompt = project_ctx.to_system_prompt_block() if project_ctx else ""
55
+ agent = build_agent(llm, tools, memory_ctx, agent_mode, project_ctx=project_prompt)
53
56
 
54
57
  console.print(f"[dim]Skill: {skill_name} | {llm.name}/{llm.model}[/dim]")
55
58
  try:
@@ -17,7 +17,7 @@ console = get_console()
17
17
 
18
18
  # ── Version ──────────────────────────────────────────────────────────────────
19
19
 
20
- VERSION = "0.3.0"
20
+ VERSION = "0.4.0"
21
21
 
22
22
  # ── Banners ───────────────────────────────────────────────────────────────────
23
23
 
@@ -33,32 +33,36 @@ BANNER_SMALL = "[bold cyan]DevOrch[/bold cyan]"
33
33
  # automatically.
34
34
 
35
35
  SLASH_COMMANDS: dict[str, str] = {
36
- "/help": "Show available commands",
37
- "/mode": "Show or change mode (plan/auto/ask)",
38
- "/plan": "Switch to plan mode",
39
- "/auto": "Switch to auto mode",
40
- "/ask": "Switch to ask mode (default)",
41
- "/clear": "Clear conversation history",
42
- "/session": "Show current session info",
43
- "/config": "Show configuration settings",
44
- "/permissions": "Show permission settings",
45
- "/compact": "Summarize and compact history",
46
- "/models": "Browse and switch models (interactive)",
47
- "/model": "Switch model (/model <name> or interactive)",
48
- "/providers": "Browse and switch providers (interactive)",
49
- "/provider": "Switch provider (/provider <name> or interactive)",
50
- "/history": "Show conversation history",
51
- "/undo": "Undo last message",
52
- "/save": "Save conversation to file",
53
- "/status": "Show current provider, model, and mode",
54
- "/tasks": "Show current task list",
55
- "/memory": "Show saved memories",
56
- "/remember": "Save something to memory",
57
- "/forget": "Delete a memory",
58
- "/skills": "List available skills",
59
- "/skill": "Run a skill (e.g. /skill commit)",
60
- "/mcp": "Show MCP servers | add/stop/start servers inline",
61
- "/auth": "Set or update API key for current/specified provider",
36
+ "/help": "Show categorized help and command shortcuts",
37
+ "/mode": "Show or switch mode: /mode [plan|auto|ask]",
38
+ "/plan": "Switch to plan mode (requires approval before tool execution)",
39
+ "/auto": "Switch to auto mode (executes approved tools autonomously)",
40
+ "/ask": "Switch to ask mode (default: read and suggest only)",
41
+ "/clear": "Clear conversation history (saves accomplishments to project memory)",
42
+ "/session": "Show current session ID, model, and message count",
43
+ "/config": "Show configuration settings and provider status",
44
+ "/permissions": "Show and manage tool permission settings",
45
+ "/compact": "Summarize and compact conversation history to save tokens",
46
+ "/models": "Search, browse, and switch models (interactive 15/page pagination)",
47
+ "/model": "Switch model directly (/model <name>) or open interactive search",
48
+ "/providers": "Search, browse, and switch providers (interactive pagination)",
49
+ "/provider": "Switch provider directly (/provider <name>) or open interactive search",
50
+ "/history": "Show full conversation history in this session",
51
+ "/undo": "Undo last message and agent turn",
52
+ "/save": "Save conversation history to a file",
53
+ "/status": "Show active provider, model, execution mode, and loaded context",
54
+ "/tasks": "Show active multi-step task list and execution progress",
55
+ "/memory": "Show project memory (/memory add <dec>, /memory pref <p>, /memory clear)",
56
+ "/remember": "Save something to global memory (/remember <note>)",
57
+ "/forget": "Delete a memory (/forget or /forget <name>)",
58
+ "/skills": "List available built-in and custom skills",
59
+ "/skill": "Run a skill directly (/skill <name>)",
60
+ "/mcp": "Show MCP servers (/mcp add, /mcp stop, /mcp start)",
61
+ "/auth": "Set or update API key for current or specified provider",
62
+ "/tokens": "Show session token usage, prompt/completion split, and costs",
63
+ "/copy": "Copy the last assistant response to clipboard",
64
+ "/paste": "Enter multi-line paste mode to input large text or code",
65
+ "/init": "Generate or update a DEVORCH.md project context file",
62
66
  }
63
67
 
64
68
  # ── Questionary style (provider/model selection prompts) ─────────────────────
@@ -83,6 +87,7 @@ QUESTIONARY_STYLE = QStyle(
83
87
  PROMPT_STYLE = Style.from_dict(
84
88
  {
85
89
  "prompt": "#55cc55 bold",
90
+ "prompt-mode": "#55aaff bold",
86
91
  "prompt-arrow": "#55cc55 bold",
87
92
  "": "#ffffff bold",
88
93
  "command": "#66ccff bold",