opencomputer 0.1.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 (93) hide show
  1. opencomputer-0.1.0/.gitignore +65 -0
  2. opencomputer-0.1.0/AGENTS.md +86 -0
  3. opencomputer-0.1.0/CHANGELOG.md +42 -0
  4. opencomputer-0.1.0/CLAUDE.md +341 -0
  5. opencomputer-0.1.0/PKG-INFO +190 -0
  6. opencomputer-0.1.0/README.md +157 -0
  7. opencomputer-0.1.0/RELEASE.md +115 -0
  8. opencomputer-0.1.0/docs/refs/claude-code/.gitkeep +0 -0
  9. opencomputer-0.1.0/docs/refs/hermes-agent/.gitkeep +0 -0
  10. opencomputer-0.1.0/docs/refs/kimi-cli/.gitkeep +0 -0
  11. opencomputer-0.1.0/docs/refs/openclaw/.gitkeep +0 -0
  12. opencomputer-0.1.0/extensions/anthropic-provider/plugin.json +10 -0
  13. opencomputer-0.1.0/extensions/anthropic-provider/plugin.py +22 -0
  14. opencomputer-0.1.0/extensions/anthropic-provider/provider.py +217 -0
  15. opencomputer-0.1.0/extensions/coding-harness/background.py +220 -0
  16. opencomputer-0.1.0/extensions/coding-harness/edit.py +124 -0
  17. opencomputer-0.1.0/extensions/coding-harness/multi_edit.py +140 -0
  18. opencomputer-0.1.0/extensions/coding-harness/plan_mode.py +79 -0
  19. opencomputer-0.1.0/extensions/coding-harness/plugin.json +10 -0
  20. opencomputer-0.1.0/extensions/coding-harness/plugin.py +50 -0
  21. opencomputer-0.1.0/extensions/coding-harness/skills/code-reviewer/SKILL.md +59 -0
  22. opencomputer-0.1.0/extensions/coding-harness/todo_write.py +182 -0
  23. opencomputer-0.1.0/extensions/discord/adapter.py +160 -0
  24. opencomputer-0.1.0/extensions/discord/plugin.json +10 -0
  25. opencomputer-0.1.0/extensions/discord/plugin.py +20 -0
  26. opencomputer-0.1.0/extensions/openai-provider/plugin.json +10 -0
  27. opencomputer-0.1.0/extensions/openai-provider/plugin.py +17 -0
  28. opencomputer-0.1.0/extensions/openai-provider/provider.py +247 -0
  29. opencomputer-0.1.0/extensions/telegram/adapter.py +191 -0
  30. opencomputer-0.1.0/extensions/telegram/plugin.json +10 -0
  31. opencomputer-0.1.0/extensions/telegram/plugin.py +29 -0
  32. opencomputer-0.1.0/opencomputer/__init__.py +3 -0
  33. opencomputer-0.1.0/opencomputer/agent/__init__.py +1 -0
  34. opencomputer-0.1.0/opencomputer/agent/compaction.py +245 -0
  35. opencomputer-0.1.0/opencomputer/agent/config.py +108 -0
  36. opencomputer-0.1.0/opencomputer/agent/config_store.py +210 -0
  37. opencomputer-0.1.0/opencomputer/agent/injection.py +60 -0
  38. opencomputer-0.1.0/opencomputer/agent/loop.py +326 -0
  39. opencomputer-0.1.0/opencomputer/agent/memory.py +132 -0
  40. opencomputer-0.1.0/opencomputer/agent/prompt_builder.py +66 -0
  41. opencomputer-0.1.0/opencomputer/agent/prompts/base.j2 +23 -0
  42. opencomputer-0.1.0/opencomputer/agent/state.py +251 -0
  43. opencomputer-0.1.0/opencomputer/agent/step.py +31 -0
  44. opencomputer-0.1.0/opencomputer/cli.py +483 -0
  45. opencomputer-0.1.0/opencomputer/doctor.py +216 -0
  46. opencomputer-0.1.0/opencomputer/gateway/__init__.py +1 -0
  47. opencomputer-0.1.0/opencomputer/gateway/dispatch.py +89 -0
  48. opencomputer-0.1.0/opencomputer/gateway/protocol.py +84 -0
  49. opencomputer-0.1.0/opencomputer/gateway/server.py +77 -0
  50. opencomputer-0.1.0/opencomputer/gateway/wire_server.py +256 -0
  51. opencomputer-0.1.0/opencomputer/hooks/__init__.py +1 -0
  52. opencomputer-0.1.0/opencomputer/hooks/engine.py +79 -0
  53. opencomputer-0.1.0/opencomputer/hooks/runner.py +42 -0
  54. opencomputer-0.1.0/opencomputer/mcp/__init__.py +1 -0
  55. opencomputer-0.1.0/opencomputer/mcp/client.py +208 -0
  56. opencomputer-0.1.0/opencomputer/plugins/__init__.py +1 -0
  57. opencomputer-0.1.0/opencomputer/plugins/discovery.py +107 -0
  58. opencomputer-0.1.0/opencomputer/plugins/loader.py +155 -0
  59. opencomputer-0.1.0/opencomputer/plugins/registry.py +56 -0
  60. opencomputer-0.1.0/opencomputer/setup_wizard.py +235 -0
  61. opencomputer-0.1.0/opencomputer/skills/debug-python-import-error/SKILL.md +58 -0
  62. opencomputer-0.1.0/opencomputer/tools/__init__.py +1 -0
  63. opencomputer-0.1.0/opencomputer/tools/bash.py +78 -0
  64. opencomputer-0.1.0/opencomputer/tools/delegate.py +98 -0
  65. opencomputer-0.1.0/opencomputer/tools/glob.py +70 -0
  66. opencomputer-0.1.0/opencomputer/tools/grep.py +117 -0
  67. opencomputer-0.1.0/opencomputer/tools/read.py +81 -0
  68. opencomputer-0.1.0/opencomputer/tools/registry.py +69 -0
  69. opencomputer-0.1.0/opencomputer/tools/skill_manage.py +265 -0
  70. opencomputer-0.1.0/opencomputer/tools/write.py +58 -0
  71. opencomputer-0.1.0/plugin_sdk/__init__.py +66 -0
  72. opencomputer-0.1.0/plugin_sdk/channel_contract.py +74 -0
  73. opencomputer-0.1.0/plugin_sdk/core.py +129 -0
  74. opencomputer-0.1.0/plugin_sdk/hooks.py +80 -0
  75. opencomputer-0.1.0/plugin_sdk/injection.py +60 -0
  76. opencomputer-0.1.0/plugin_sdk/provider_contract.py +95 -0
  77. opencomputer-0.1.0/plugin_sdk/runtime_context.py +39 -0
  78. opencomputer-0.1.0/plugin_sdk/tool_contract.py +67 -0
  79. opencomputer-0.1.0/pyproject.toml +81 -0
  80. opencomputer-0.1.0/tests/__init__.py +0 -0
  81. opencomputer-0.1.0/tests/test_phase1_5.py +183 -0
  82. opencomputer-0.1.0/tests/test_phase2.py +108 -0
  83. opencomputer-0.1.0/tests/test_phase3.py +141 -0
  84. opencomputer-0.1.0/tests/test_phase3_1.py +93 -0
  85. opencomputer-0.1.0/tests/test_phase4.py +189 -0
  86. opencomputer-0.1.0/tests/test_phase5.py +118 -0
  87. opencomputer-0.1.0/tests/test_phase6a.py +313 -0
  88. opencomputer-0.1.0/tests/test_phase6b.py +341 -0
  89. opencomputer-0.1.0/tests/test_phase7.py +238 -0
  90. opencomputer-0.1.0/tests/test_phase8.py +91 -0
  91. opencomputer-0.1.0/tests/test_phase9.py +265 -0
  92. opencomputer-0.1.0/tests/test_provider_auth.py +117 -0
  93. opencomputer-0.1.0/tests/test_smoke.py +109 -0
@@ -0,0 +1,65 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual environments
24
+ .venv/
25
+ venv/
26
+ env/
27
+ ENV/
28
+
29
+ # uv
30
+ .uv-cache/
31
+
32
+ # Testing
33
+ .pytest_cache/
34
+ .coverage
35
+ htmlcov/
36
+ .tox/
37
+ .nox/
38
+ .hypothesis/
39
+
40
+ # Type checkers
41
+ .mypy_cache/
42
+ .ruff_cache/
43
+ .pyre/
44
+ .pytype/
45
+
46
+ # IDE
47
+ .vscode/
48
+ .idea/
49
+ *.swp
50
+ *.swo
51
+
52
+ # OS
53
+ .DS_Store
54
+ Thumbs.db
55
+
56
+ # OpenComputer state
57
+ ~/.opencomputer/
58
+ .opencomputer/
59
+ sessions/
60
+ *.log
61
+
62
+ # Secrets
63
+ .env
64
+ .env.local
65
+ credentials.json
@@ -0,0 +1,86 @@
1
+ # OpenComputer — Development Guide
2
+
3
+ Instructions for AI coding assistants and developers working on OpenComputer.
4
+
5
+ ## Project Structure
6
+
7
+ ```
8
+ OpenComputer/
9
+ ├── pyproject.toml # package metadata + deps (hatchling)
10
+ ├── README.md
11
+ ├── AGENTS.md # this file
12
+ ├── opencomputer/ # core package
13
+ │ ├── __init__.py
14
+ │ ├── cli.py # entry point — `opencomputer` command
15
+ │ ├── agent/
16
+ │ │ ├── loop.py # core while-loop — run_conversation
17
+ │ │ ├── step.py # StepOutcome dataclass
18
+ │ │ ├── injection.py # DynamicInjectionProvider (plan/yolo modes)
19
+ │ │ ├── memory.py # three-pillar memory manager
20
+ │ │ ├── state.py # SQLite + FTS5 session store
21
+ │ │ ├── prompt_builder.py # Jinja2 rendering + slot injection
22
+ │ │ ├── prompts/ # Jinja2 templates for system prompts
23
+ │ │ ├── middleware.py # surrogate sanitize, rate limit, retry
24
+ │ │ └── config.py # typed config (dataclasses)
25
+ │ ├── tools/ # built-in tool implementations
26
+ │ ├── gateway/ # WS daemon + platform dispatch
27
+ │ ├── hooks/ # lifecycle hook engine
28
+ │ ├── plugins/ # plugin discovery + loader
29
+ │ └── skills/ # bundled default skills
30
+ ├── plugin_sdk/ # PUBLIC plugin contract
31
+ ├── extensions/ # bundled plugins (Telegram, Anthropic, OpenAI, ...)
32
+ ├── tests/
33
+ └── docs/
34
+ ```
35
+
36
+ ## Core Concepts (plan vocab)
37
+
38
+ - **Agent loop** — single while loop, model call → tool dispatch → continue/break
39
+ - **StepOutcome** — dataclass capturing one loop iteration's result (stop reason + assistant message)
40
+ - **Three-pillar memory:**
41
+ - Declarative — `~/.opencomputer/MEMORY.md`, `USER.md`
42
+ - Procedural — `~/.opencomputer/skills/*/SKILL.md`
43
+ - Episodic — SQLite + FTS5 session search
44
+ - **Hooks** — lifecycle event intercepts (PreToolUse, PostToolUse, Stop, SessionStart, SessionEnd, UserPromptSubmit)
45
+ - **Subagents** — spawn fresh mini-agent in isolated context via `delegate` tool
46
+ - **Dynamic injection** — cross-cutting modes (plan, yolo) inject system reminders without scattering `if` checks
47
+ - **Plugin SDK** — public contract at `plugin_sdk/` — stable. `opencomputer/**` — internal, can refactor.
48
+
49
+ ## Development
50
+
51
+ ```bash
52
+ # Setup
53
+ uv venv
54
+ source .venv/bin/activate
55
+ uv pip install -e ".[dev]"
56
+
57
+ # Run
58
+ opencomputer
59
+
60
+ # Test
61
+ pytest
62
+
63
+ # Lint / format
64
+ ruff check .
65
+ black .
66
+ ```
67
+
68
+ ## Boundary Rules (strict)
69
+
70
+ - **Extensions must only import from `plugin_sdk/*`.** Never from `opencomputer/**`.
71
+ - **Core (`opencomputer/**`) must not import from extensions.** Extensions register via manifests + hooks.
72
+ - **Never break the SDK without a major version bump** — third-party plugins depend on it.
73
+ - **Hooks must be fire-and-forget for post-actions.** Never block the main loop.
74
+
75
+ ## Reference repos (in parent folder)
76
+
77
+ - `../claude-code/` — plugin primitives vocabulary
78
+ - `../hermes-agent/` — Python patterns, three-pillar memory
79
+ - `../openclaw/` — plugin-first architecture, manifest-first discovery
80
+ - `../kimi-cli/` — dynamic injection, fire-and-forget hooks, wire protocol
81
+
82
+ When in doubt, check these for proven patterns before inventing new ones.
83
+
84
+ ## Version
85
+
86
+ Current: 0.0.1 (pre-alpha — Phase 0 scaffolding)
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ All notable changes to OpenComputer are listed here. Follows [Keep a Changelog](https://keepachangelog.com/) conventions, [semver](https://semver.org/).
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [0.1.0] — 2026-04-21 (pre-alpha)
8
+
9
+ ### Added
10
+ - Initial public release.
11
+ - Core agent loop with tool dispatch (`opencomputer/agent/loop.py`).
12
+ - Three-pillar memory: declarative (MEMORY.md), procedural (skills/), episodic (SQLite + FTS5 full-text search).
13
+ - 7 built-in tools: Read, Write, Bash, Grep, Glob, skill_manage, delegate.
14
+ - Strict plugin SDK boundary (`plugin_sdk/`) with manifest-first two-phase discovery.
15
+ - Bundled plugins:
16
+ - `anthropic-provider` — Anthropic Claude models with Bearer-auth proxy support.
17
+ - `openai-provider` — OpenAI Chat Completions + any OpenAI-compatible endpoint.
18
+ - `telegram` — Telegram Bot API channel with typing indicators.
19
+ - `discord` — Discord channel via discord.py.
20
+ - `coding-harness` — Edit, MultiEdit, TodoWrite, background-process tools + plan mode.
21
+ - MCP integration — connects to Model Context Protocol servers (stdio), tools namespaced.
22
+ - Gateway for multi-channel daemons.
23
+ - Wire server — JSON over WebSocket RPC for TUI / IDE / web clients (`opencomputer wire`).
24
+ - Streaming responses (Anthropic + OpenAI) with per-turn typing indicators on Telegram.
25
+ - Dynamic injection engine — cross-cutting modes as providers (plan mode).
26
+ - Hardened context compaction — real token counts, tool-pair preservation, aux-fail fallback.
27
+ - Runtime context threading — plan_mode / yolo_mode / custom flags flow loop → hooks → delegate → subagents.
28
+ - CLI: `chat`, `gateway`, `wire`, `search`, `sessions`, `skills`, `plugins`, `setup`, `doctor`, `config`.
29
+ - Interactive setup wizard (`opencomputer setup`).
30
+ - Health check (`opencomputer doctor`).
31
+ - Typed YAML config with dotted-key get/set.
32
+ - GitHub Actions CI — pytest on Python 3.12 + 3.13, ruff lint.
33
+ - 114 tests.
34
+
35
+ ### Credits
36
+ Architectural ideas synthesized from [Claude Code](https://github.com/anthropics/claude-code),
37
+ [Hermes Agent](https://github.com/NousResearch/hermes-agent),
38
+ [OpenClaw](https://github.com/openclaw/openclaw),
39
+ [Kimi CLI](https://github.com/MoonshotAI/kimi-cli).
40
+
41
+ [Unreleased]: https://github.com/sakshamzip2-sys/opencomputer/compare/v0.1.0...HEAD
42
+ [0.1.0]: https://github.com/sakshamzip2-sys/opencomputer/releases/tag/v0.1.0
@@ -0,0 +1,341 @@
1
+ # OpenComputer — Session Context for Claude Code
2
+
3
+ This file is auto-loaded at session start. It is the **single comprehensive brief** a new Claude session needs to resume work on OpenComputer without re-explaining anything.
4
+
5
+ Last updated: 2026-04-21 (end of Phase 10b)
6
+
7
+ ---
8
+
9
+ ## 1. Project elevator pitch
10
+
11
+ **OpenComputer** is a personal AI agent framework, written in Python 3.12+, that synthesizes the best ideas from four reference projects into one cohesive system:
12
+
13
+ | Reference | What we took |
14
+ |---|---|
15
+ | [Claude Code](https://github.com/anthropics/claude-code) | Plugin primitives (commands/skills/agents/hooks/MCP), lifecycle events, tool shapes (Edit, MultiEdit, TodoWrite) |
16
+ | [Hermes Agent](https://github.com/NousResearch/hermes-agent) | Python core patterns, three-pillar memory (declarative + procedural + episodic), agent loop shape, channel adapter pattern |
17
+ | [OpenClaw](https://github.com/openclaw/openclaw) | Plugin-first architecture, strict SDK boundary, manifest-first two-phase discovery (scan cheap metadata, activate lazily), typed wire protocol |
18
+ | [Kimi CLI](https://github.com/MoonshotAI/kimi-cli) | Dynamic injection providers for cross-cutting modes, fire-and-forget hooks, deferred MCP loading, StepOutcome abstraction, Jinja2 prompts |
19
+
20
+ **Positioning:** "Same agent, same memory. Install the coding-harness plugin → it's a coding agent. Don't install → it's a chat agent. Your choice." Works from CLI, Telegram, Discord, and any WebSocket client (TUI, IDE).
21
+
22
+ Identity is user-configurable, not locked:
23
+ - You are **Saksham** (GitHub: `sakshamzip2-sys`).
24
+ - Repo: `https://github.com/sakshamzip2-sys/opencomputer` (PUBLIC).
25
+ - Authored on macOS (darwin), zsh.
26
+
27
+ ---
28
+
29
+ ## 2. Repository layout
30
+
31
+ The parent git repo is at `/Users/saksham/Vscode/claude/` and contains the OpenComputer project plus four reference repos consolidated under `sources/` (gitignored so they don't pollute our commits):
32
+
33
+ ```
34
+ /Users/saksham/Vscode/claude/
35
+ ├── .git/ ← parent repo — GitHub sakshamzip2-sys/opencomputer
36
+ ├── .gitignore ← ignores sources/ + build artifacts
37
+ ├── .github/workflows/
38
+ │ ├── test.yml ← pytest on Python 3.12 + 3.13 on every push/PR
39
+ │ ├── lint.yml ← ruff check
40
+ │ └── release.yml ← triggered on v* tags, publishes to PyPI (OIDC)
41
+ ├── OpenComputer/ ← THE PROJECT. cd here for anything code-related.
42
+ │ └── docs/refs/ ← reference-extraction notes by repo
43
+ │ ├── claude-code/
44
+ │ ├── hermes-agent/
45
+ │ ├── openclaw/
46
+ │ └── kimi-cli/
47
+ └── sources/ ← reference repos (gitignored — not in commits)
48
+ ├── claude-code/
49
+ ├── hermes-agent/
50
+ ├── openclaw/
51
+ └── kimi-cli/
52
+ ```
53
+
54
+ ### OpenComputer/ structure
55
+
56
+ ```
57
+ OpenComputer/
58
+ ├── pyproject.toml ← hatchling build, deps, ruff/pytest config
59
+ ├── README.md ← user-facing docs
60
+ ├── CLAUDE.md ← THIS FILE
61
+ ├── AGENTS.md ← dev guide for AI assistants
62
+ ├── RELEASE.md ← runbook for cutting a release
63
+ ├── CHANGELOG.md ← Keep-a-Changelog format
64
+ ├── .venv/ ← local development venv (gitignored)
65
+
66
+ ├── opencomputer/ ← CORE PACKAGE (can be refactored freely)
67
+ │ ├── __init__.py ← __version__ = "0.1.0"
68
+ │ ├── cli.py ← Typer CLI — 11 subcommands
69
+ │ ├── doctor.py ← opencomputer doctor — health checks
70
+ │ ├── setup_wizard.py ← opencomputer setup — onboarding
71
+ │ ├── agent/
72
+ │ │ ├── loop.py ← AgentLoop.run_conversation — THE while loop
73
+ │ │ ├── state.py ← SessionDB (SQLite + FTS5 full-text search)
74
+ │ │ ├── memory.py ← MemoryManager (declarative + procedural)
75
+ │ │ ├── config.py ← typed dataclasses: Model/Loop/Session/Memory/MCP
76
+ │ │ ├── config_store.py ← load/save ~/.opencomputer/config.yaml
77
+ │ │ ├── injection.py ← InjectionEngine — collects mode providers per turn
78
+ │ │ ├── compaction.py ← CompactionEngine (auto-summarize when context full)
79
+ │ │ ├── step.py ← StepOutcome dataclass
80
+ │ │ ├── prompt_builder.py ← Jinja2 prompt rendering
81
+ │ │ └── prompts/base.j2 ← default system prompt template
82
+ │ ├── tools/ ← built-in tools
83
+ │ │ ├── registry.py ← ToolRegistry singleton + dispatch
84
+ │ │ ├── read.py, write.py, bash.py, grep.py, glob.py
85
+ │ │ ├── skill_manage.py ← self-improvement: agent saves skills
86
+ │ │ └── delegate.py ← spawn subagent with isolated context
87
+ │ ├── gateway/ ← messaging gateway + wire server
88
+ │ │ ├── server.py ← Gateway daemon (Telegram/Discord etc.)
89
+ │ │ ├── dispatch.py ← MessageEvent → AgentLoop routing + typing heartbeat
90
+ │ │ ├── protocol.py ← WireRequest/Response/Event (pydantic)
91
+ │ │ └── wire_server.py ← WebSocket JSON-RPC for TUI/IDE clients
92
+ │ ├── hooks/
93
+ │ │ ├── engine.py ← Hook dispatcher (6 events)
94
+ │ │ └── runner.py ← fire-and-forget async runner (kimi pattern)
95
+ │ ├── plugins/ ← plugin system (not plugins themselves!)
96
+ │ │ ├── discovery.py ← scans manifests → PluginCandidates (cheap)
97
+ │ │ ├── loader.py ← imports entry module + runs register(api)
98
+ │ │ └── registry.py ← PluginRegistry singleton + PluginAPI
99
+ │ ├── mcp/
100
+ │ │ └── client.py ← MCPTool + MCPManager (deferred load)
101
+ │ └── skills/
102
+ │ └── debug-python-import-error/SKILL.md ← first bundled skill
103
+
104
+ ├── plugin_sdk/ ← PUBLIC CONTRACT. Plugins import from here ONLY.
105
+ │ │ NEVER imports from opencomputer/*.
106
+ │ │ Linter test enforces this.
107
+ │ ├── __init__.py ← ~30 public exports
108
+ │ ├── core.py ← Message, ToolCall, ToolResult, Platform, MessageEvent
109
+ │ ├── tool_contract.py ← BaseTool, ToolSchema
110
+ │ ├── provider_contract.py ← BaseProvider, ProviderResponse, StreamEvent, Usage
111
+ │ ├── channel_contract.py ← BaseChannelAdapter
112
+ │ ├── hooks.py ← HookSpec, HookContext, HookDecision (6 events)
113
+ │ ├── injection.py ← DynamicInjectionProvider ABC, InjectionContext
114
+ │ └── runtime_context.py ← RuntimeContext (plan_mode, yolo_mode, custom)
115
+
116
+ ├── extensions/ ← 5 bundled plugins
117
+ │ ├── telegram/ ← kind=channel. DISCORD_BOT_TOKEN via env
118
+ │ ├── discord/ ← kind=channel. DISCORD_BOT_TOKEN
119
+ │ ├── anthropic-provider/ ← kind=provider. x-api-key + Bearer-proxy support
120
+ │ ├── openai-provider/ ← kind=provider. OpenAI + OpenAI-compatible endpoints
121
+ │ └── coding-harness/ ← kind=mixed. Edit/MultiEdit/TodoWrite/bg/plan-mode
122
+
123
+ ├── tests/ ← 114 tests, all passing
124
+ │ ├── test_smoke.py ← package + CLI imports
125
+ │ ├── test_phase1_5.py ← skill_manage, Grep, Glob, hook engine, discovery
126
+ │ ├── test_phase2.py ← gateway protocol, dispatch, telegram
127
+ │ ├── test_phase3.py, test_phase3_1.py
128
+ │ ├── test_phase4.py ← MCP
129
+ │ ├── test_phase5.py ← doctor + setup wizard
130
+ │ ├── test_phase6a.py ← InjectionEngine + CompactionEngine + RuntimeContext
131
+ │ ├── test_phase6b.py ← coding-harness plugin
132
+ │ ├── test_phase7.py ← streaming + typing heartbeat
133
+ │ ├── test_phase8.py ← Discord
134
+ │ ├── test_phase9.py ← WebSocket wire server
135
+ │ └── test_provider_auth.py ← Anthropic auth modes (x-api-key vs Bearer)
136
+
137
+ └── docs/ ← (empty — Phase 10c will populate)
138
+ ```
139
+
140
+ ---
141
+
142
+ ## 3. Architecture in one diagram
143
+
144
+ ```
145
+ user
146
+
147
+ ┌──────────────────┼──────────────────────┐
148
+ │ │ │
149
+ ▼ ▼ ▼
150
+ opencomputer opencomputer opencomputer
151
+ chat gateway wire
152
+ (streaming (daemon with (WS server
153
+ CLI tokens) channel adapters) for TUI/IDE)
154
+ │ │ │
155
+ └──────────────────┼──────────────────────┘
156
+
157
+
158
+ ╔═══════════╗
159
+ ║ AgentLoop ║ ← run_conversation(user_msg, runtime)
160
+ ╠═══════════╣
161
+ ║ • inject (plan/yolo modes via InjectionEngine)
162
+ ║ • compact (auto-summarize old turns when full)
163
+ ║ • call provider.complete() or stream_complete()
164
+ ║ • dispatch tool calls in parallel (safety-checked)
165
+ ║ • fire PreToolUse hooks (can block)
166
+ ║ • loop until model stops calling tools
167
+ ╚═══════════╝
168
+
169
+
170
+ ┌───────────────────────────┐
171
+ │ plugin_sdk/ (PUBLIC) │ ← 30 exports
172
+ │ Stable contract. │
173
+ └───────────────────────────┘
174
+
175
+ │ (plugins import from here)
176
+
177
+ ┌───────────┼───────────┬─────────────┐
178
+ │ │ │ │
179
+ telegram discord anthropic coding-
180
+ openai harness
181
+ ```
182
+
183
+ **The rule:** plugins never import from `opencomputer/*`. Only from `plugin_sdk/*`. Enforced by a test that scans plugin_sdk/ for any `from opencomputer` imports.
184
+
185
+ ---
186
+
187
+ ## 4. What's been built (all phases to date)
188
+
189
+ All committed + pushed to `main`. 18 commits total.
190
+
191
+ | Phase | Commit | What |
192
+ |---|---|---|
193
+ | 0 | `0d512cb` | Project scaffold — folder structure, pyproject, smoke tests |
194
+ | 1 | `8d96aff` | Core: agent loop, SQLite+FTS5, 3 tools, Anthropic provider |
195
+ | 1.5 | `11209c9` | skill_manage, Grep, Glob, delegate, hook engine, plugin discovery |
196
+ | 2 | `4252f17` | Gateway + Telegram (first real plugin) |
197
+ | 2.1 | `c280dc6` | Bearer auth + x-api-key strip for Claude Router proxy |
198
+ | 3 | `eb22d46` | OpenAI provider plugin + plugin-registry provider resolution |
199
+ | 3.1 | `441690d`, `be42ff8` | Anthropic moved to plugin + config command + loader cache fix |
200
+ | 4 | `37642be` | MCP integration + bundled skills path |
201
+ | 5 | `684226a` | Generic-ify — setup wizard, doctor, clean README |
202
+ | 6a | `c739c4a` | Injection + compaction engines + RuntimeContext threading |
203
+ | 6b | `bfa1ada` | coding-harness plugin — Edit, MultiEdit, TodoWrite, bg processes, plan mode |
204
+ | 7 | `96b1b7d` | Real streaming in both providers + Telegram typing heartbeat |
205
+ | 8 | `e9240da` | Discord channel plugin |
206
+ | 9 | `d5802c8` | WebSocket wire server + RPC protocol dispatch |
207
+ | 10a | `01a8f9c` | CI/CD (GitHub Actions) + ruff configuration + codebase cleanup |
208
+ | 10b | `2858815` | PyPI release automation + v0.1.0 prep |
209
+
210
+ **Test count:** 114 passing across 14 test files.
211
+
212
+ ---
213
+
214
+ ## 5. What's NEXT (phases 10c–13 + pause gate)
215
+
216
+ Full roadmap lives in `~/.claude/plans/delightful-sauteeing-sutherland.md`. Short summary:
217
+
218
+ ### Remaining Phase 10 (ship-ready 1.0)
219
+
220
+ - **10c — Plugin scaffolding + SDK docs** (3-5 days). `opencomputer plugin new` CLI. `docs/plugin-authors.md`. `docs/sdk-reference.md`.
221
+ - **10d — Example third-party plugin repo** (2-3 days). `opencomputer-weather` or similar. On PyPI separately. Proves extensibility.
222
+ - **10e — WebFetch + WebSearch tools** (1-2 days).
223
+
224
+ ### 🛑 GATE after Phase 10: Use OpenComputer daily for 2 weeks
225
+
226
+ Before Phase 11, the roadmap requires 2 weeks of real use so feature priorities come from actual gaps, not guesses. This gate is load-bearing — don't skip.
227
+
228
+ ### Phase 11 (post-pause)
229
+
230
+ - **11a — TypeScript Ink TUI MVP** (2 weeks) connecting to `opencomputer wire`
231
+ - **11b — Slack channel** (1 day)
232
+ - **11c — Channel UX polish** — tool-call visibility, output truncation, Discord markdown
233
+
234
+ ### Phase 12 (optional)
235
+
236
+ - **12a — ACP adapter** for VS Code / Zed / JetBrains integration
237
+
238
+ ### Phase 13 (a la carte)
239
+
240
+ Independent sub-phases: more hook events, compaction strategy plugin API, Jupyter support, ExitPlanMode tool, security scanning, `opencomputer upgrade` command.
241
+
242
+ ### WON'T DO (explicitly parked)
243
+
244
+ Canvas rendering, native mobile apps, voice wake-word, Atropos RL, trajectory compression, Honcho memory, 6 remote terminal backends, skills marketplace, full i18n. Re-open only if a concrete use case appears.
245
+
246
+ ---
247
+
248
+ ## 6. How to run / develop / test
249
+
250
+ ### Local setup
251
+
252
+ ```bash
253
+ cd /Users/saksham/Vscode/claude/OpenComputer
254
+ source .venv/bin/activate # venv uses Python 3.13 (anaconda)
255
+ ```
256
+
257
+ ### Run the CLI
258
+
259
+ ```bash
260
+ # Prereqs — one of:
261
+ export ANTHROPIC_API_KEY=sk-ant-... # native Anthropic
262
+ # OR
263
+ export ANTHROPIC_BASE_URL=https://claude-router.vercel.app
264
+ export ANTHROPIC_AUTH_MODE=bearer
265
+ export ANTHROPIC_API_KEY=<router-proxy-key> # proxy mode
266
+ # OR
267
+ export OPENAI_API_KEY=sk-... # OpenAI
268
+
269
+ opencomputer # chat
270
+ opencomputer --plan # plan mode (Edit/Write/Bash refused)
271
+ opencomputer gateway # daemon for Telegram/Discord
272
+ opencomputer wire # WebSocket API at ws://127.0.0.1:18789
273
+ opencomputer plugins # list 5 installed plugins
274
+ opencomputer skills # list skills
275
+ opencomputer doctor # health check
276
+ opencomputer config show # dump config
277
+ ```
278
+
279
+ ### Test / lint
280
+
281
+ ```bash
282
+ pytest tests/ # all 114 tests
283
+ pytest tests/test_phase6b.py -v # one file
284
+ ruff check opencomputer/ plugin_sdk/ extensions/ tests/ # lint
285
+ ```
286
+
287
+ ### Cut a release (when ready)
288
+
289
+ See `RELEASE.md` — basically bump version in two places, tag `vX.Y.Z`, push. CI handles PyPI.
290
+
291
+ ---
292
+
293
+ ## 7. Non-obvious gotchas (burned-in lessons)
294
+
295
+ 1. **Plugin module-cache collisions.** When multiple plugins share sibling file names (`plugin.py`, `provider.py`), Python's `sys.modules` returns the first-loaded one for all imports. `plugins/loader.py` solves this: synthetic unique module names via `importlib.util.spec_from_file_location` + `_clear_plugin_local_cache()` between plugin loads. Tests use the same pattern (`importlib.util.spec_from_file_location` with unique names).
296
+
297
+ 2. **Claude Router proxy rejects x-api-key.** Some Anthropic proxies forward `x-api-key` unchanged to upstream Anthropic, which then rejects the proxy_key. `extensions/anthropic-provider/provider.py` supports `ANTHROPIC_AUTH_MODE=bearer` which uses `Authorization: Bearer` AND strips `x-api-key` via an httpx event hook before the request goes out.
298
+
299
+ 3. **Compaction MUST preserve `tool_use`/`tool_result` pairs atomically.** Splitting them causes Anthropic's API to 400. `CompactionEngine._safe_split_index` walks back from the naive split point until it lands outside of any `tool_use`/`tool_result` pair.
300
+
301
+ 4. **`DelegateTool._factory` needs `staticmethod` wrap.** Lambdas stored as class attributes get bound to `self` when accessed via instances. `set_factory` uses `cls._factory = staticmethod(factory)` to prevent this.
302
+
303
+ 5. **asyncio subprocesses can't cross event loops.** A process started in one `asyncio.run()` can't be awaited in another. Background-process tests must do spawn + check + kill in one `asyncio.run()` call.
304
+
305
+ 6. **The plugin SDK boundary is enforced by a test.** `tests/test_phase6a.py::test_plugin_sdk_does_not_import_opencomputer` scans `plugin_sdk/*.py` for `from opencomputer` imports and fails if any exist. Do not bypass this — it's how the contract stays honest.
306
+
307
+ 7. **HookContext.runtime is optional for backwards compat.** Hooks written before Phase 6a don't pass it. New hooks should use `ctx.runtime.plan_mode` etc.
308
+
309
+ ---
310
+
311
+ ## 8. User preferences (learned across this project)
312
+
313
+ - **Action over confirmation.** Saksham asks Claude to just do things. Don't ask "should I...?" — do what can be done, then report.
314
+ - **Per-phase workflow is a hard rule:** after each phase, review → `git push` → next phase. Never chain phases without the commit boundary.
315
+ - **Concise communication.** Short responses. Direct. Don't pad.
316
+ - **Stock market data must be live.** Not relevant to OpenComputer, but if stocks come up in a future session: use MCP servers (investor-agent, stockflow) + fresh web search. Never stale cached data.
317
+ - **Plugins + skills + MCPs should be checked before answering.** If a relevant tool exists, use it rather than guessing.
318
+
319
+ ---
320
+
321
+ ## 9. If you need to dig deeper
322
+
323
+ - **Full plan with rationale + critique:** `~/.claude/plans/delightful-sauteeing-sutherland.md`
324
+ - **Reference implementations cloned locally at `../sources/`:**
325
+ - `/Users/saksham/Vscode/claude/sources/claude-code/` (plugin shapes)
326
+ - `/Users/saksham/Vscode/claude/sources/hermes-agent/` (Python patterns, loop, channels)
327
+ - `/Users/saksham/Vscode/claude/sources/openclaw/` (plugin SDK boundary, discovery)
328
+ - `/Users/saksham/Vscode/claude/sources/kimi-cli/` (dynamic injection, compaction, wire)
329
+ - **Per-repo extraction notes:** `OpenComputer/docs/refs/<repo-name>/` — take notes
330
+ about each reference project here as you study it.
331
+ - **GitHub:** https://github.com/sakshamzip2-sys/opencomputer
332
+
333
+ ---
334
+
335
+ ## 10. One-line session restart prompt
336
+
337
+ If you're a fresh Claude Code session, the user typically opens with something like:
338
+
339
+ > "Continue OpenComputer from where we left off. Read CLAUDE.md first, then pick up Phase 10c (plugin scaffolding + SDK docs)."
340
+
341
+ That's enough context to start coding.