@dugleelabs/copair 1.0.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Duglee Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,203 @@
1
+ <p align="center">
2
+ <img src="https://assets.dugleelabs.com/Copair_Logo_cc1a297c94.png" width="160" alt="Copair Logo" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/package/copair"><img src="https://img.shields.io/npm/v/copair" alt="npm version"></a>
7
+ <a href="https://github.com/dugleelabs/copair/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/copair" alt="license"></a>
8
+ <a href="https://github.com/dugleelabs/copair/actions"><img src="https://img.shields.io/github/actions/workflow/status/dugleelabs/copair/pull_request.yaml?branch=main&label=CI" alt="CI"></a>
9
+ <a href="https://nodejs.org"><img src="https://img.shields.io/node/v/copair" alt="node version"></a>
10
+ </p>
11
+
12
+ A model-agnostic AI coding agent for the terminal. Works like Claude Code but supports any LLM provider — commercial APIs, open source models, or self-hosted instances.
13
+
14
+ ```
15
+ npm install -g copair
16
+ copair
17
+ ```
18
+
19
+ ## Providers
20
+
21
+ | Provider | Type |
22
+ |----------|------|
23
+ | Anthropic (Claude) | Native |
24
+ | OpenAI (GPT-4o, o1, etc.) | Native |
25
+ | Google Gemini (incl. 2.0/3.0 thought signatures) | Native |
26
+ | Ollama, vLLM, LM Studio, etc. | OpenAI-compatible |
27
+
28
+ Switch models mid-session with `/model <name>`. Context is summarized automatically before switching.
29
+
30
+ ## Quick Setup
31
+
32
+ Create `~/.copair/config.yaml`:
33
+
34
+ ```yaml
35
+ version: 1
36
+ default_model: claude-sonnet
37
+
38
+ providers:
39
+ anthropic:
40
+ api_key: ${ANTHROPIC_API_KEY}
41
+ models:
42
+ claude-sonnet:
43
+ id: claude-sonnet-4-20250514
44
+
45
+ openai:
46
+ api_key: ${OPENAI_API_KEY}
47
+ models:
48
+ gpt-4o:
49
+ id: gpt-4o
50
+
51
+ ollama:
52
+ type: openai-compatible
53
+ base_url: http://localhost:11434/v1
54
+ models:
55
+ llama3:
56
+ id: llama3.1:8b
57
+ supports_tool_calling: false
58
+ ```
59
+
60
+ ```
61
+ copair # start with default model
62
+ copair --model gpt-4o # start with a specific model
63
+ copair --resume # resume most recent session
64
+ copair --resume latest # same as above
65
+ copair --resume auth-fix # resume session by identifier
66
+ copair --verbose # show INFO/WARN logs
67
+ copair --debug # show all logs including DEBUG
68
+ ```
69
+
70
+ → [Full configuration reference](docs/configuration.md)
71
+ → [Local models setup (Qwen 3.5, etc.)](docs/local-models.md)
72
+
73
+ ## Built-in Tools
74
+
75
+ The agent has direct access to your codebase:
76
+
77
+ | Tool | Description |
78
+ |------|-------------|
79
+ | `Read` | Read file contents with line offset/limit |
80
+ | `Write` | Write file contents, creates parent dirs |
81
+ | `Edit` | Exact string replacement (errors on non-unique match) |
82
+ | `Grep` | Regex search across files |
83
+ | `Glob` | File pattern matching |
84
+ | `Bash` | Execute shell commands with timeout |
85
+ | `Git` | git status, diff, log, commit |
86
+ | `WebSearch` | Search via Tavily, Serper, or SearXNG |
87
+ | `UpdateKnowledge` | Add entries to project knowledge base |
88
+
89
+ For models without native tool calling, Copair falls back to prompt-based tool extraction.
90
+
91
+ ## Permissions
92
+
93
+ ```yaml
94
+ permissions:
95
+ mode: ask # ask | auto-approve | deny
96
+ allow_commands: # bash commands that skip the prompt
97
+ - git status
98
+ - git diff
99
+ - npm test
100
+ ```
101
+
102
+ In `ask` mode you can approve once or always-allow for the session. Shell operators (`;`, `&&`, `|`, etc.) are never auto-approved even if the base command matches.
103
+
104
+ → [Permission docs](docs/configuration.md#permission-modes)
105
+
106
+ ## Token Tracking
107
+
108
+ After each response:
109
+ ```
110
+ [tokens: 1,234 in / 567 out | session: 5,678 in / 2,345 out | ~$0.12]
111
+ ```
112
+
113
+ On exit, a per-model cost breakdown is shown. Supports all OpenAI, Anthropic, and Google pricing. Falls back to tiktoken estimation when the API doesn't report usage.
114
+
115
+ ## Slash Commands
116
+
117
+ | Command | Description |
118
+ |---------|-------------|
119
+ | `/help` | List all available commands |
120
+ | `/model <name>` | Switch model mid-session |
121
+ | `/clear` | Clear conversation history |
122
+ | `/cost` | Show session token usage and cost |
123
+ | `/workflow <name>` | Run a workflow |
124
+ | `/commands` | List custom commands |
125
+ | `/session list` | List all sessions for current project |
126
+ | `/session resume <id>` | Resume a previous session |
127
+ | `/session rename <name>` | Rename current session |
128
+ | `/session delete <id>` | Delete a stored session |
129
+ | `/session save` | Force save current session |
130
+ | `/session info` | Show current session metadata |
131
+
132
+ Custom commands are markdown files with frontmatter — drop them in `~/.copair/commands/` or `.copair/commands/`. Commands support nesting, positional arguments, and `$VAR` / `{{var}}` interpolation. They return their expanded markdown directly to the agent. → [Custom commands](docs/commands.md)
133
+
134
+ ## Sessions
135
+
136
+ Sessions persist across exits. On startup, Copair checks for previous sessions in `.copair/sessions/` and offers to resume or start fresh. Sessions are auto-named from your git branch, first message, and files touched.
137
+
138
+ ```
139
+ Previous sessions:
140
+ 1. auth-middleware-refactor-a3f2 (2h ago, 42 msgs, claude-sonnet)
141
+ 2. fix-login-bug-b7c1 (1d ago, 18 msgs, gemini-pro)
142
+ 3. Start fresh
143
+
144
+ Select [1-3]:
145
+ ```
146
+
147
+ On exit, sessions are summarized using a local model (via Ollama if available) or the active model. Resumed sessions inject the summary as context instead of replaying full message history.
148
+
149
+ Session files are stored in `.copair/sessions/` (gitignored automatically). Each session has a UUID directory containing `session.json`, `messages.jsonl`, and optionally `summary.md`.
150
+
151
+ ```yaml
152
+ # Optional session config in ~/.copair/config.yaml
153
+ context:
154
+ summarization_model: qwen-7b # model alias for summaries
155
+ max_sessions: 20 # max sessions per project
156
+ knowledge_max_size: 8192 # max bytes for knowledge base
157
+ ```
158
+
159
+ ## Knowledge Base
160
+
161
+ Copair maintains a project-level knowledge base at `COPAIR_KNOWLEDGE.md` in your project root. The agent adds entries when it learns project-specific facts (conventions, patterns, architecture decisions). This file is committed to git and shared with your team.
162
+
163
+ The knowledge base is automatically included in the system prompt for all sessions in that project. Entries are timestamped and pruned when the file exceeds the configured max size.
164
+
165
+ ## Workflows
166
+
167
+ Multi-step YAML workflows that combine agent prompts, shell commands, and branching logic.
168
+
169
+ ```
170
+ /workflow test-fix
171
+ /workflow test-fix test_command=pytest
172
+ ```
173
+
174
+ Workflows support: `prompt`, `shell`, `command`, `condition`, and `output` step types. Ctrl+C cancels at any step. → [Workflow docs](docs/workflows.md)
175
+
176
+ ## MCP Servers
177
+
178
+ Extend the agent with any [Model Context Protocol](https://modelcontextprotocol.io) server. MCP tools are discovered at startup and namespaced as `server-name:tool-name`.
179
+
180
+ ```yaml
181
+ mcp_servers:
182
+ - name: filesystem
183
+ command: npx
184
+ args: ["-y", "@modelcontextprotocol/server-filesystem", "/path"]
185
+ ```
186
+
187
+ → [MCP docs](docs/mcp.md)
188
+
189
+ ## Web Search
190
+
191
+ Supports Tavily, Serper, and self-hosted SearXNG. Anthropic models use native built-in search automatically.
192
+
193
+ ```yaml
194
+ web_search:
195
+ provider: tavily
196
+ api_key: ${TAVILY_API_KEY}
197
+ ```
198
+
199
+ → [Web search docs](docs/web-search.md)
200
+
201
+ ## License
202
+
203
+ MIT