oy-cli 0.2.1__tar.gz → 0.3.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.
oy_cli-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,242 @@
1
+ Metadata-Version: 2.4
2
+ Name: oy-cli
3
+ Version: 0.3.0
4
+ Summary: Tiny local coding CLI with a small tool surface
5
+ Author: oy-cli contributors
6
+ License-Expression: Apache-2.0
7
+ Requires-Python: >=3.14
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: defopt>=7.0.0
11
+ Requires-Dist: httpx>=0.28.1
12
+ Requires-Dist: httpx-aws-auth>=4.1.1
13
+ Requires-Dist: markdownify>=1.2.0
14
+ Requires-Dist: openai>=1.68.0
15
+ Requires-Dist: rich>=14.3.0
16
+ Requires-Dist: tiktoken>=0.7.0
17
+ Requires-Dist: tenacity>=9.0.0
18
+ Requires-Dist: msgspec>=0.20.0
19
+ Dynamic: license-file
20
+
21
+ # oy-cli
22
+
23
+ **Tiny AI coding assistant for your shell.** Reads files, runs commands, makes precise edits, and stays intentionally small.
24
+
25
+ ```bash
26
+ uv tool install oy-cli
27
+ oy "add docstrings to public functions"
28
+ ```
29
+
30
+ ## Examples
31
+
32
+ ```bash
33
+ # Basic usage
34
+ oy "read the main module and suggest improvements"
35
+
36
+ # Work in a specific directory
37
+ OY_ROOT=./my-project oy "fix the failing tests"
38
+
39
+ # Non-interactive mode (CI/pipelines)
40
+ echo "update the changelog" | OY_NON_INTERACTIVE=1 oy
41
+
42
+ # Security audit
43
+ oy audit
44
+ oy audit "focus on authentication"
45
+ ```
46
+
47
+ ## Commands
48
+
49
+ ```bash
50
+ oy "prompt" # Run with a prompt (default)
51
+ oy audit # Security audit against OWASP ASVS/MSVS
52
+ oy model # Show current default model
53
+ oy model <filter> # Pick/save a model
54
+ oy model --token # Print Bedrock OpenAI env exports
55
+ oy --help # Show all commands
56
+ ```
57
+
58
+ ## Why This Exists
59
+
60
+ Most AI coding tools are large, complex, or lock you into a single provider. `oy` is deliberately small, easy to audit, and built around a narrow tool surface.
61
+
62
+ **Design goals:** small auditable codebase, minimal tool surface, OpenAI-completions-focused CLI loop, multiple backends behind shims, fresh session each run, and explicit checkpoints when needed.
63
+
64
+ **Built-in guidance:**
65
+ - complexity: grugbrain.dev style simplicity over abstraction
66
+ - security: OWASP-minded defaults and review
67
+ - performance: performance-aware programming; measure first, avoid obvious waste
68
+
69
+ ## Tools
70
+
71
+ | Tool | Purpose | Best Use |
72
+ |------|---------|----------|
73
+ | `list` | List directory contents | First pass on unfamiliar trees |
74
+ | `read` | Read files or directories | Primary inspection tool; always before editing |
75
+ | `apply` | Modify files | Exact replacements, writes, moves, deletes |
76
+ | `grep` | Search file contents | Find code by text or regex |
77
+ | `glob` | Find files by pattern | Find paths when you know the filename shape |
78
+ | `bash` | Run shell commands | Tests, builds, git, scripts |
79
+ | `httpx` | Fetch web/API content | Docs, standards, and API responses |
80
+ | `ask` | Ask the user questions | Interactive approvals and checkpoints |
81
+
82
+ **Behavioral rules:**
83
+ - Inspect before changing.
84
+ - Prefer `list`/`read`/`grep`/`glob` over shelling out for inspection.
85
+ - Use `apply` for all file edits.
86
+ - Keep edits targeted and batch related operations.
87
+ - If output is clipped, narrow the query instead of guessing.
88
+
89
+ ## Agent Behavior
90
+
91
+ **Core workflow:** inspect first, use the narrowest useful tool, make precise edits, and keep going until done or genuinely blocked.
92
+
93
+ **Prompt style:** the embedded system prompts are intentionally short. Tool semantics live with the tool definitions, while the system prompt focuses on operating rules and judgment.
94
+
95
+ **Reasoning defaults:**
96
+ - prefer grugbrain.dev style simplicity to reduce complexity
97
+ - use OWASP framing for security-sensitive work
98
+ - apply performance-aware programming judgment from Computer Enhance: measure before tuning, but avoid obvious waste
99
+
100
+ **Interactive mode:** use checkpoints for plans, ambiguous choices, and risky changes.
101
+
102
+ **Non-interactive mode:** do not pause for approval; recover from failures when possible and stop only with a concise blocked status.
103
+
104
+ **Output truncation:** tool output is clipped to preserve context; `bash` keeps both head and tail. When that happens, narrow the next query.
105
+
106
+ ## Audit Command
107
+
108
+ Fetches current OWASP ASVS/MASVS standards, explores the repository, identifies security issues, complexity problems, and major obvious performance issues, then writes findings to `ISSUES.md`.
109
+
110
+ ```bash
111
+ oy audit # Full audit
112
+ oy audit "focus on auth" # With focus area
113
+ OY_ROOT=./src oy audit # Audit specific directory
114
+ ```
115
+
116
+ ## Configuration
117
+
118
+ **Environment variables:**
119
+
120
+ | Variable | Purpose |
121
+ |----------|---------|
122
+ | `OY_MODEL` | Override model for this session (bare name or `shim:model`) |
123
+ | `OY_SHIM` | Force a specific shim: `openai`, `codex`, `gemini`, `claude`, `bedrock`, or `bedrock-mantle` |
124
+ | `OY_NON_INTERACTIVE` | Set to `1` to disable checkpoints |
125
+ | `OY_ROOT` | Run against different workspace |
126
+ | `OY_SYSTEM_FILE` | Append extra system instructions |
127
+ | `OY_CONFIG` | Override config path (default: `~/.config/oy/config.json`) |
128
+
129
+ **Tuning variables** (rarely needed):
130
+
131
+ | Variable | Default | Purpose |
132
+ |----------|---------|---------|
133
+ | `OY_MAX_TOOL_OUTPUT_TOKENS` | `4096` | Max tokens kept from tool output |
134
+ | `OY_MAX_TOOL_TAIL_TOKENS` | `1024` | Tail tokens preserved when output is clipped |
135
+ | `OY_MAX_CONTEXT_TOKENS` | `131072` | Context window budget |
136
+ | `OY_MAX_MESSAGE_TOKENS` | `4096` | Per-message truncation limit |
137
+ | `OY_DEFAULT_MAX_STEPS` | `512` | Max LLM turns per run |
138
+ | `OY_DEFAULT_MAX_TOOL_CALLS` | `512` | Max tool invocations per run |
139
+ | `OY_DEFAULT_LINE_LIMIT` | `500` | Default line limit for `read`/`list`/`glob` |
140
+ | `OY_BEDROCK_READ_TIMEOUT` | `120` | HTTP read timeout for Bedrock (seconds) |
141
+ | `OY_BEDROCK_MAX_OUTPUT_TOKENS` | `4096` | Max output tokens for Bedrock Converse |
142
+
143
+ **Config file** (`~/.config/oy/config.json`):
144
+ ```json
145
+ {"shim": "gemini", "model": "gemini-2.5-pro"}
146
+ ```
147
+
148
+ The `shim` field pins which backend to use regardless of what else is signed in. Use `oy model <filter>` to pick interactively; it merges models from available signed-in shims into a single list using `shim:model` prefixes.
149
+
150
+ On first run, if no model is configured, `oy` prompts you to pick one from the available backends. Set `OY_MODEL`, `OY_SHIM`, or save a config with `oy model` to pin behavior.
151
+
152
+ **Recommended model:** From testing, `glm-5` (via Bedrock) offers the best balance of intelligence, cost, and tool-use ability. `kimi-k2.5` is another strong option.
153
+
154
+ ## Requirements
155
+
156
+ - Python 3.14+
157
+ - `bash`
158
+ - (Optional) `rg` (ripgrep) for faster search
159
+ - OpenAI API key or Codex local auth **OR** Gemini CLI OAuth credentials (`~/.gemini/oauth_creds.json`) **OR** Claude Code local auth **OR** AWS CLI configured for Bedrock
160
+
161
+ ## Installation
162
+
163
+ ```bash
164
+ uv tool install oy-cli # Preferred
165
+ pip install oy-cli # Alternative
166
+ ```
167
+
168
+ ## Authentication
169
+
170
+ **OpenAI:**
171
+ ```bash
172
+ export OPENAI_API_KEY=sk-...
173
+ ```
174
+
175
+ For OpenAI-compatible endpoints:
176
+ ```bash
177
+ export OPENAI_BASE_URL=https://your-endpoint.example/v1
178
+ export OPENAI_API_KEY=...
179
+ ```
180
+
181
+ **Codex CLI (automatic):** If you have already logged in with `codex`, `oy` will reuse the credentials in `~/.codex/auth.json`. If that file contains a generated API key, `oy` uses the public OpenAI Responses API. If it contains a ChatGPT account session instead, `oy` uses the ChatGPT-backed Codex responses endpoint.
182
+
183
+ **Gemini CLI (automatic):** If you have the [Gemini CLI](https://github.com/google-gemini/gemini-cli) installed and have run `gemini` at least once to authenticate, `oy` will pick up the OAuth credentials automatically from `~/.gemini/oauth_creds.json`. No extra setup needed.
184
+
185
+ ```bash
186
+ # Install and authenticate the Gemini CLI once
187
+ npm install -g @google/gemini-cli
188
+ gemini # follow the login prompt
189
+
190
+ # Then just use oy — it auto-detects Gemini credentials
191
+ oy "refactor this function"
192
+ ```
193
+
194
+ Default model when using Gemini: `gemini-2.5-pro`. Use `oy model <filter>` or `OY_MODEL` to switch.
195
+
196
+ **Claude Code (automatic):** If you have already signed in with Claude Code, `oy` can use that local session directly through the `claude` shim. No Anthropic API key is required.
197
+
198
+ ```bash
199
+ claude auth login
200
+ oy --model claude:sonnet "refactor this function"
201
+ ```
202
+
203
+ **AWS Bedrock (automatic):** Uses your default AWS profile/region. Supports auto-refresh of stale SSO sessions.
204
+ ```bash
205
+ export AWS_PROFILE=my-profile
206
+ export AWS_REGION=us-west-2
207
+ ```
208
+
209
+ ## Troubleshooting
210
+
211
+ **"Missing API credentials"** -> Set `OPENAI_API_KEY`, sign in with `codex`, install and authenticate the Gemini CLI, sign in with `claude auth login`, or configure AWS CLI (`aws configure`). For Bedrock: ensure your profile has `bedrock:InvokeModel` permission.
212
+
213
+ **"stdin is not a TTY"** -> Piping input disables `ask`. Set `OY_NON_INTERACTIVE=1` to make explicit.
214
+
215
+ **"AWS SSO session is stale"** -> Run `aws sso login --use-device-code --no-browser` or run `oy` in a TTY for auto-prompt.
216
+
217
+ **"command timed out"** -> `bash` default timeout is 120s. Agent can increase `timeout_seconds` parameter.
218
+
219
+ **"replace target not found"** -> `apply` requires exact string match. Read file first, check whitespace.
220
+
221
+ **Output truncated** -> Tools clip at 4096 tokens by default. Agent auto-narrows queries, or guide explicitly: "read lines 100-200".
222
+
223
+ ## Security
224
+
225
+ `oy` can run shell commands and modify files with your permissions. Treat it like any other local automation tool.
226
+
227
+ Recommended:
228
+ - run in a repo or workspace you trust
229
+ - mount only needed directories in containers
230
+ - avoid exposing long-lived secrets in the environment
231
+ - review generated changes before shipping
232
+
233
+ **Automatic protections:** workspace-bound file access, structured edits through `apply`, sensitive header redaction in `httpx`, and secure Bedrock token generation.
234
+
235
+ ## Links
236
+
237
+ - [Issues](ISSUES.md) - Known issues and audit findings
238
+ - [Contributing](CONTRIBUTING.md) - Development and release notes
239
+
240
+ ## License
241
+
242
+ Apache License 2.0
oy_cli-0.3.0/README.md ADDED
@@ -0,0 +1,222 @@
1
+ # oy-cli
2
+
3
+ **Tiny AI coding assistant for your shell.** Reads files, runs commands, makes precise edits, and stays intentionally small.
4
+
5
+ ```bash
6
+ uv tool install oy-cli
7
+ oy "add docstrings to public functions"
8
+ ```
9
+
10
+ ## Examples
11
+
12
+ ```bash
13
+ # Basic usage
14
+ oy "read the main module and suggest improvements"
15
+
16
+ # Work in a specific directory
17
+ OY_ROOT=./my-project oy "fix the failing tests"
18
+
19
+ # Non-interactive mode (CI/pipelines)
20
+ echo "update the changelog" | OY_NON_INTERACTIVE=1 oy
21
+
22
+ # Security audit
23
+ oy audit
24
+ oy audit "focus on authentication"
25
+ ```
26
+
27
+ ## Commands
28
+
29
+ ```bash
30
+ oy "prompt" # Run with a prompt (default)
31
+ oy audit # Security audit against OWASP ASVS/MSVS
32
+ oy model # Show current default model
33
+ oy model <filter> # Pick/save a model
34
+ oy model --token # Print Bedrock OpenAI env exports
35
+ oy --help # Show all commands
36
+ ```
37
+
38
+ ## Why This Exists
39
+
40
+ Most AI coding tools are large, complex, or lock you into a single provider. `oy` is deliberately small, easy to audit, and built around a narrow tool surface.
41
+
42
+ **Design goals:** small auditable codebase, minimal tool surface, OpenAI-completions-focused CLI loop, multiple backends behind shims, fresh session each run, and explicit checkpoints when needed.
43
+
44
+ **Built-in guidance:**
45
+ - complexity: grugbrain.dev style simplicity over abstraction
46
+ - security: OWASP-minded defaults and review
47
+ - performance: performance-aware programming; measure first, avoid obvious waste
48
+
49
+ ## Tools
50
+
51
+ | Tool | Purpose | Best Use |
52
+ |------|---------|----------|
53
+ | `list` | List directory contents | First pass on unfamiliar trees |
54
+ | `read` | Read files or directories | Primary inspection tool; always before editing |
55
+ | `apply` | Modify files | Exact replacements, writes, moves, deletes |
56
+ | `grep` | Search file contents | Find code by text or regex |
57
+ | `glob` | Find files by pattern | Find paths when you know the filename shape |
58
+ | `bash` | Run shell commands | Tests, builds, git, scripts |
59
+ | `httpx` | Fetch web/API content | Docs, standards, and API responses |
60
+ | `ask` | Ask the user questions | Interactive approvals and checkpoints |
61
+
62
+ **Behavioral rules:**
63
+ - Inspect before changing.
64
+ - Prefer `list`/`read`/`grep`/`glob` over shelling out for inspection.
65
+ - Use `apply` for all file edits.
66
+ - Keep edits targeted and batch related operations.
67
+ - If output is clipped, narrow the query instead of guessing.
68
+
69
+ ## Agent Behavior
70
+
71
+ **Core workflow:** inspect first, use the narrowest useful tool, make precise edits, and keep going until done or genuinely blocked.
72
+
73
+ **Prompt style:** the embedded system prompts are intentionally short. Tool semantics live with the tool definitions, while the system prompt focuses on operating rules and judgment.
74
+
75
+ **Reasoning defaults:**
76
+ - prefer grugbrain.dev style simplicity to reduce complexity
77
+ - use OWASP framing for security-sensitive work
78
+ - apply performance-aware programming judgment from Computer Enhance: measure before tuning, but avoid obvious waste
79
+
80
+ **Interactive mode:** use checkpoints for plans, ambiguous choices, and risky changes.
81
+
82
+ **Non-interactive mode:** do not pause for approval; recover from failures when possible and stop only with a concise blocked status.
83
+
84
+ **Output truncation:** tool output is clipped to preserve context; `bash` keeps both head and tail. When that happens, narrow the next query.
85
+
86
+ ## Audit Command
87
+
88
+ Fetches current OWASP ASVS/MASVS standards, explores the repository, identifies security issues, complexity problems, and major obvious performance issues, then writes findings to `ISSUES.md`.
89
+
90
+ ```bash
91
+ oy audit # Full audit
92
+ oy audit "focus on auth" # With focus area
93
+ OY_ROOT=./src oy audit # Audit specific directory
94
+ ```
95
+
96
+ ## Configuration
97
+
98
+ **Environment variables:**
99
+
100
+ | Variable | Purpose |
101
+ |----------|---------|
102
+ | `OY_MODEL` | Override model for this session (bare name or `shim:model`) |
103
+ | `OY_SHIM` | Force a specific shim: `openai`, `codex`, `gemini`, `claude`, `bedrock`, or `bedrock-mantle` |
104
+ | `OY_NON_INTERACTIVE` | Set to `1` to disable checkpoints |
105
+ | `OY_ROOT` | Run against different workspace |
106
+ | `OY_SYSTEM_FILE` | Append extra system instructions |
107
+ | `OY_CONFIG` | Override config path (default: `~/.config/oy/config.json`) |
108
+
109
+ **Tuning variables** (rarely needed):
110
+
111
+ | Variable | Default | Purpose |
112
+ |----------|---------|---------|
113
+ | `OY_MAX_TOOL_OUTPUT_TOKENS` | `4096` | Max tokens kept from tool output |
114
+ | `OY_MAX_TOOL_TAIL_TOKENS` | `1024` | Tail tokens preserved when output is clipped |
115
+ | `OY_MAX_CONTEXT_TOKENS` | `131072` | Context window budget |
116
+ | `OY_MAX_MESSAGE_TOKENS` | `4096` | Per-message truncation limit |
117
+ | `OY_DEFAULT_MAX_STEPS` | `512` | Max LLM turns per run |
118
+ | `OY_DEFAULT_MAX_TOOL_CALLS` | `512` | Max tool invocations per run |
119
+ | `OY_DEFAULT_LINE_LIMIT` | `500` | Default line limit for `read`/`list`/`glob` |
120
+ | `OY_BEDROCK_READ_TIMEOUT` | `120` | HTTP read timeout for Bedrock (seconds) |
121
+ | `OY_BEDROCK_MAX_OUTPUT_TOKENS` | `4096` | Max output tokens for Bedrock Converse |
122
+
123
+ **Config file** (`~/.config/oy/config.json`):
124
+ ```json
125
+ {"shim": "gemini", "model": "gemini-2.5-pro"}
126
+ ```
127
+
128
+ The `shim` field pins which backend to use regardless of what else is signed in. Use `oy model <filter>` to pick interactively; it merges models from available signed-in shims into a single list using `shim:model` prefixes.
129
+
130
+ On first run, if no model is configured, `oy` prompts you to pick one from the available backends. Set `OY_MODEL`, `OY_SHIM`, or save a config with `oy model` to pin behavior.
131
+
132
+ **Recommended model:** From testing, `glm-5` (via Bedrock) offers the best balance of intelligence, cost, and tool-use ability. `kimi-k2.5` is another strong option.
133
+
134
+ ## Requirements
135
+
136
+ - Python 3.14+
137
+ - `bash`
138
+ - (Optional) `rg` (ripgrep) for faster search
139
+ - OpenAI API key or Codex local auth **OR** Gemini CLI OAuth credentials (`~/.gemini/oauth_creds.json`) **OR** Claude Code local auth **OR** AWS CLI configured for Bedrock
140
+
141
+ ## Installation
142
+
143
+ ```bash
144
+ uv tool install oy-cli # Preferred
145
+ pip install oy-cli # Alternative
146
+ ```
147
+
148
+ ## Authentication
149
+
150
+ **OpenAI:**
151
+ ```bash
152
+ export OPENAI_API_KEY=sk-...
153
+ ```
154
+
155
+ For OpenAI-compatible endpoints:
156
+ ```bash
157
+ export OPENAI_BASE_URL=https://your-endpoint.example/v1
158
+ export OPENAI_API_KEY=...
159
+ ```
160
+
161
+ **Codex CLI (automatic):** If you have already logged in with `codex`, `oy` will reuse the credentials in `~/.codex/auth.json`. If that file contains a generated API key, `oy` uses the public OpenAI Responses API. If it contains a ChatGPT account session instead, `oy` uses the ChatGPT-backed Codex responses endpoint.
162
+
163
+ **Gemini CLI (automatic):** If you have the [Gemini CLI](https://github.com/google-gemini/gemini-cli) installed and have run `gemini` at least once to authenticate, `oy` will pick up the OAuth credentials automatically from `~/.gemini/oauth_creds.json`. No extra setup needed.
164
+
165
+ ```bash
166
+ # Install and authenticate the Gemini CLI once
167
+ npm install -g @google/gemini-cli
168
+ gemini # follow the login prompt
169
+
170
+ # Then just use oy — it auto-detects Gemini credentials
171
+ oy "refactor this function"
172
+ ```
173
+
174
+ Default model when using Gemini: `gemini-2.5-pro`. Use `oy model <filter>` or `OY_MODEL` to switch.
175
+
176
+ **Claude Code (automatic):** If you have already signed in with Claude Code, `oy` can use that local session directly through the `claude` shim. No Anthropic API key is required.
177
+
178
+ ```bash
179
+ claude auth login
180
+ oy --model claude:sonnet "refactor this function"
181
+ ```
182
+
183
+ **AWS Bedrock (automatic):** Uses your default AWS profile/region. Supports auto-refresh of stale SSO sessions.
184
+ ```bash
185
+ export AWS_PROFILE=my-profile
186
+ export AWS_REGION=us-west-2
187
+ ```
188
+
189
+ ## Troubleshooting
190
+
191
+ **"Missing API credentials"** -> Set `OPENAI_API_KEY`, sign in with `codex`, install and authenticate the Gemini CLI, sign in with `claude auth login`, or configure AWS CLI (`aws configure`). For Bedrock: ensure your profile has `bedrock:InvokeModel` permission.
192
+
193
+ **"stdin is not a TTY"** -> Piping input disables `ask`. Set `OY_NON_INTERACTIVE=1` to make explicit.
194
+
195
+ **"AWS SSO session is stale"** -> Run `aws sso login --use-device-code --no-browser` or run `oy` in a TTY for auto-prompt.
196
+
197
+ **"command timed out"** -> `bash` default timeout is 120s. Agent can increase `timeout_seconds` parameter.
198
+
199
+ **"replace target not found"** -> `apply` requires exact string match. Read file first, check whitespace.
200
+
201
+ **Output truncated** -> Tools clip at 4096 tokens by default. Agent auto-narrows queries, or guide explicitly: "read lines 100-200".
202
+
203
+ ## Security
204
+
205
+ `oy` can run shell commands and modify files with your permissions. Treat it like any other local automation tool.
206
+
207
+ Recommended:
208
+ - run in a repo or workspace you trust
209
+ - mount only needed directories in containers
210
+ - avoid exposing long-lived secrets in the environment
211
+ - review generated changes before shipping
212
+
213
+ **Automatic protections:** workspace-bound file access, structured edits through `apply`, sensitive header redaction in `httpx`, and secure Bedrock token generation.
214
+
215
+ ## Links
216
+
217
+ - [Issues](ISSUES.md) - Known issues and audit findings
218
+ - [Contributing](CONTRIBUTING.md) - Development and release notes
219
+
220
+ ## License
221
+
222
+ Apache License 2.0