ownkey 1.0.1 → 1.1.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/README.md +293 -46
- package/dist/ai/anthropic.d.ts.map +1 -1
- package/dist/ai/anthropic.js +15 -18
- package/dist/ai/anthropic.js.map +1 -1
- package/dist/ai/factory.d.ts.map +1 -1
- package/dist/ai/factory.js +7 -6
- package/dist/ai/factory.js.map +1 -1
- package/dist/ai/gemini.d.ts.map +1 -1
- package/dist/ai/gemini.js +13 -7
- package/dist/ai/gemini.js.map +1 -1
- package/dist/ai/ollama.d.ts.map +1 -1
- package/dist/ai/ollama.js +2 -1
- package/dist/ai/ollama.js.map +1 -1
- package/dist/ai/openai.d.ts +2 -0
- package/dist/ai/openai.d.ts.map +1 -1
- package/dist/ai/openai.js +44 -33
- package/dist/ai/openai.js.map +1 -1
- package/dist/ai/provider.d.ts +2 -0
- package/dist/ai/provider.d.ts.map +1 -1
- package/dist/ai/provider.js +11 -0
- package/dist/ai/provider.js.map +1 -1
- package/dist/commands/apply.d.ts.map +1 -1
- package/dist/commands/apply.js +41 -2
- package/dist/commands/apply.js.map +1 -1
- package/dist/commands/review.d.ts +3 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +161 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/suggest.d.ts.map +1 -1
- package/dist/commands/suggest.js +3 -37
- package/dist/commands/suggest.js.map +1 -1
- package/dist/commands/undo.d.ts.map +1 -1
- package/dist/commands/undo.js +12 -28
- package/dist/commands/undo.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +5 -4
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/keychain.d.ts +5 -0
- package/dist/config/keychain.d.ts.map +1 -1
- package/dist/config/keychain.js +44 -11
- package/dist/config/keychain.js.map +1 -1
- package/dist/config/models.d.ts +12 -0
- package/dist/config/models.d.ts.map +1 -0
- package/dist/config/models.js +19 -0
- package/dist/config/models.js.map +1 -0
- package/dist/core/backup/index.d.ts +1 -0
- package/dist/core/backup/index.d.ts.map +1 -1
- package/dist/core/backup/index.js +1 -0
- package/dist/core/backup/index.js.map +1 -1
- package/dist/core/backup/rollback.d.ts +6 -0
- package/dist/core/backup/rollback.d.ts.map +1 -0
- package/dist/core/backup/rollback.js +15 -0
- package/dist/core/backup/rollback.js.map +1 -0
- package/dist/core/persist.d.ts +8 -0
- package/dist/core/persist.d.ts.map +1 -0
- package/dist/core/persist.js +56 -0
- package/dist/core/persist.js.map +1 -0
- package/dist/core/review/git.d.ts +33 -0
- package/dist/core/review/git.d.ts.map +1 -0
- package/dist/core/review/git.js +89 -0
- package/dist/core/review/git.js.map +1 -0
- package/dist/core/review/report.d.ts +16 -0
- package/dist/core/review/report.d.ts.map +1 -0
- package/dist/core/review/report.js +110 -0
- package/dist/core/review/report.js.map +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +12 -7
- package/dist/utils/logger.js.map +1 -1
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -1,86 +1,333 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/ArpitK24/OwnKey/main/assets/logo.png" alt="OwnKey" width="420">
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
>
|
|
5
|
+
<h3 align="center">The local-first AI code reviewer that runs on your own keys.</h3>
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
Review your changes before you commit, gate pull requests in CI, and apply fixes as verified, reversible diffs.<br>
|
|
9
|
+
OpenAI, Anthropic, Google Gemini, or fully offline with Ollama. No account, no telemetry, no required database.
|
|
10
|
+
</p>
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/ownkey"><img src="https://img.shields.io/npm/v/ownkey.svg" alt="npm version"></a>
|
|
14
|
+
<img src="https://img.shields.io/node/v/ownkey.svg" alt="node version">
|
|
15
|
+
<a href="https://github.com/ArpitK24/OwnKey/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="license"></a>
|
|
16
|
+
</p>
|
|
9
17
|
|
|
10
|
-
|
|
18
|
+
<p align="center">
|
|
19
|
+
<a href="https://ownkey.qzz.io/docs">Documentation</a> ·
|
|
20
|
+
<a href="https://ownkey.qzz.io/docs/getting-started">Quick start</a> ·
|
|
21
|
+
<a href="https://ownkey.qzz.io/docs/commands">CLI reference</a> ·
|
|
22
|
+
<a href="https://github.com/ArpitK24/OwnKey/blob/main/CHANGELOG.md">Changelog</a>
|
|
23
|
+
</p>
|
|
11
24
|
|
|
12
|
-
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Overview
|
|
28
|
+
|
|
29
|
+
OwnKey is a command-line code reviewer for developers who want AI review without handing their workflow to a hosted service. It reads your repository locally, sends only the code under review to the model provider you choose, and returns structured findings: bugs, security issues, performance problems, refactors, and more, each with a severity, a rationale, and a patch you can inspect before anything touches disk.
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
review -> apply --verify -> undo
|
|
33
|
+
diff patch + test restore
|
|
34
|
+
```
|
|
13
35
|
|
|
14
|
-
|
|
15
|
-
- 🔒 **Privacy-First** - Works completely offline with local-only mode
|
|
16
|
-
- 💾 **Optional Database** - Supabase integration for persistent history (optional)
|
|
17
|
-
- 🚀 **Auto-Model Detection** - Instantly supports new AI models without CLI updates
|
|
18
|
-
- 🎯 **Smart Suggestions** - Identifies bugs, security issues, performance problems, and more
|
|
19
|
-
- ⚡ **Apply & Undo** - Safely apply suggestions with automatic backups
|
|
36
|
+
Use `ownkey review` on what you just changed, in a pre-commit hook, or as a GitHub Action on every pull request. Use `ownkey suggest` for a full audit of any folder.
|
|
20
37
|
|
|
21
|
-
|
|
38
|
+
| | |
|
|
39
|
+
|---|---|
|
|
40
|
+
| **Bring your own key** | Use your existing OpenAI, Anthropic, or Gemini account, or any OpenAI-compatible endpoint. You pay your provider directly; OwnKey adds nothing in between. |
|
|
41
|
+
| **Fully offline option** | Point OwnKey at a local Ollama server and no code leaves your machine. |
|
|
42
|
+
| **Reviews what changed** | `review` looks at staged changes, uncommitted work, or a branch against its base, and reports only on those lines. |
|
|
43
|
+
| **Built for CI** | SARIF for GitHub code scanning, Markdown for PR comments, JSON for tooling, and `--fail-on` exit codes for gating. |
|
|
44
|
+
| **Verified fixes** | `apply --verify "npm test"` runs your checks after each fix and reverts it automatically if they fail. |
|
|
45
|
+
| **Safe by default** | Each apply creates a backup first. `undo` restores modified files and removes files the apply created. |
|
|
46
|
+
| **Standalone** | Suggestions and backups live in `~/.ownkey`. A Postgres or Supabase database is optional, for teams that want shared history. |
|
|
22
47
|
|
|
23
|
-
|
|
48
|
+
## Requirements
|
|
49
|
+
|
|
50
|
+
- Node.js 18 or later
|
|
51
|
+
- An API key for OpenAI, Anthropic, or Google Gemini, **or** a running [Ollama](https://ollama.com) server
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
24
54
|
|
|
25
55
|
```bash
|
|
26
56
|
npm install -g ownkey
|
|
57
|
+
ownkey --version
|
|
27
58
|
```
|
|
28
59
|
|
|
29
|
-
|
|
60
|
+
## Quick start
|
|
61
|
+
|
|
62
|
+
**1. Configure a provider**
|
|
30
63
|
|
|
31
64
|
```bash
|
|
32
|
-
#
|
|
33
|
-
ownkey config --provider
|
|
65
|
+
# Hosted providers
|
|
66
|
+
ownkey config --provider openai --api-key sk-...
|
|
67
|
+
ownkey config --provider anthropic --api-key sk-ant-...
|
|
68
|
+
ownkey config --provider gemini --api-key AIza...
|
|
69
|
+
|
|
70
|
+
# Fully local, no key required
|
|
71
|
+
ownkey config --provider ollama --model qwen2.5-coder:latest
|
|
72
|
+
```
|
|
34
73
|
|
|
35
|
-
|
|
36
|
-
ownkey suggest .
|
|
74
|
+
Any model your key can access works. Set it with `--model`; OwnKey does not maintain a model allowlist.
|
|
37
75
|
|
|
38
|
-
|
|
39
|
-
ownkey apply
|
|
40
|
-
ownkey apply local-123456789-0 --dry-run
|
|
41
|
-
ownkey apply local-123456789-0
|
|
76
|
+
**2. Review your changes**
|
|
42
77
|
|
|
43
|
-
|
|
44
|
-
|
|
78
|
+
```bash
|
|
79
|
+
cd my-repo
|
|
80
|
+
ownkey review # staged changes, or uncommitted work if nothing is staged
|
|
81
|
+
ownkey review --base origin/main # everything on this branch
|
|
45
82
|
```
|
|
46
83
|
|
|
47
|
-
|
|
84
|
+
**3. Apply fixes, verified**
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
ownkey apply # list pending suggestions
|
|
88
|
+
ownkey apply <id> --dry-run # preview the diff, write nothing
|
|
89
|
+
ownkey apply <id> --verify "npm test" # apply, run tests, revert automatically on failure
|
|
90
|
+
ownkey apply --all --severity high # apply everything rated high or critical
|
|
91
|
+
```
|
|
48
92
|
|
|
49
|
-
|
|
93
|
+
**4. Undo if needed**
|
|
50
94
|
|
|
51
95
|
```bash
|
|
52
|
-
ownkey
|
|
96
|
+
ownkey undo --last # restore the most recent apply
|
|
97
|
+
ownkey undo --list # recent applies
|
|
53
98
|
```
|
|
54
99
|
|
|
55
|
-
|
|
100
|
+
For a whole-project audit of any folder, git or not, use `ownkey suggest .`
|
|
101
|
+
|
|
102
|
+
## Commands
|
|
103
|
+
|
|
104
|
+
| Command | Purpose |
|
|
105
|
+
|---|---|
|
|
106
|
+
| `ownkey config` | Set the AI provider, model, endpoint, and optional database. Run with no flags for an interactive wizard. |
|
|
107
|
+
| `ownkey review [path]` | Review git changes: staged, uncommitted, or a branch against its base. |
|
|
108
|
+
| `ownkey suggest [path]` | Audit a whole folder and store suggestions. |
|
|
109
|
+
| `ownkey scan [path]` | List the files OwnKey would analyze, honoring `.gitignore` and `.ownkeyignore`. |
|
|
110
|
+
| `ownkey apply [id]` | Apply one suggestion, or all pending ones with `--all`, optionally verified. |
|
|
111
|
+
| `ownkey undo [backup-id]` | Restore files from a backup created by `apply`. |
|
|
112
|
+
|
|
113
|
+
<details>
|
|
114
|
+
<summary><strong>Full option reference</strong></summary>
|
|
115
|
+
|
|
116
|
+
#### `ownkey config`
|
|
117
|
+
|
|
118
|
+
| Option | Description |
|
|
119
|
+
|---|---|
|
|
120
|
+
| `--show` | Print the current configuration (keys are masked). |
|
|
121
|
+
| `--provider <name>` | `openai`, `anthropic`, `gemini`, or `ollama`. |
|
|
122
|
+
| `--api-key <key>` | Provider API key. Not needed for Ollama. |
|
|
123
|
+
| `--model <model>` | Any model available to your key or Ollama server. |
|
|
124
|
+
| `--endpoint <url>` | Ollama server URL, or an OpenAI-compatible base URL with `--provider openai`. |
|
|
125
|
+
| `--database-url <url>` | Optional Postgres connection string for shared history. |
|
|
126
|
+
| `--no-database` | Remove the database and use local storage only. |
|
|
127
|
+
| `--reset` | Reset configuration to defaults. |
|
|
128
|
+
| `-y, --yes` | Skip confirmation prompts. |
|
|
129
|
+
|
|
130
|
+
#### `ownkey review [path]`
|
|
131
|
+
|
|
132
|
+
| Option | Description |
|
|
133
|
+
|---|---|
|
|
134
|
+
| `--staged` | Review only staged changes. Default: staged if any, otherwise uncommitted changes. |
|
|
135
|
+
| `--base <ref>` | Review everything since the merge base with this ref, such as `origin/main`. |
|
|
136
|
+
| `--severity <level>` | Minimum severity to report. |
|
|
137
|
+
| `--type <type>` | Only report this type. |
|
|
138
|
+
| `--format <format>` | `text` (default), `markdown`, `json`, or `sarif`. |
|
|
139
|
+
| `--output <file>` | Write the report to a file instead of stdout. |
|
|
140
|
+
| `--sarif-output <file>` | Also write a SARIF report. |
|
|
141
|
+
| `--markdown-output <file>` | Also write a Markdown report. |
|
|
142
|
+
| `--fail-on <level>` | Exit with code 1 when any finding is at or above this severity. |
|
|
143
|
+
| `--max-files <n>` | Maximum changed files to review. Default `25`. |
|
|
144
|
+
|
|
145
|
+
Exit codes: `0` success, `1` the `--fail-on` gate tripped, `2` the review could not run.
|
|
146
|
+
|
|
147
|
+
#### `ownkey scan [path]`
|
|
148
|
+
|
|
149
|
+
| Option | Description |
|
|
150
|
+
|---|---|
|
|
151
|
+
| `--max-file-size <size>` | Skip files larger than this. Default `500kb`. |
|
|
152
|
+
| `--ignore <patterns...>` | Additional ignore patterns. |
|
|
153
|
+
|
|
154
|
+
#### `ownkey suggest [path]`
|
|
155
|
+
|
|
156
|
+
| Option | Description |
|
|
157
|
+
|---|---|
|
|
158
|
+
| `--type <type>` | `bug`, `security`, `performance`, `refactor`, `style`, `architecture`, `test`, or `documentation`. |
|
|
159
|
+
| `--severity <level>` | Minimum severity: `critical`, `high`, `medium`, `low`, `info`. |
|
|
160
|
+
| `--max-files <n>` | Maximum files to analyze. Default `10`. |
|
|
161
|
+
|
|
162
|
+
#### `ownkey apply [id]`
|
|
163
|
+
|
|
164
|
+
| Option | Description |
|
|
165
|
+
|---|---|
|
|
166
|
+
| `--dry-run` | Show the diff without writing. |
|
|
167
|
+
| `--auto` | Apply without the confirmation prompt (for scripts and CI). |
|
|
168
|
+
| `--all` | Apply every pending suggestion for the project. |
|
|
169
|
+
| `--severity <level>` | With `--all`, only apply at or above this severity. |
|
|
170
|
+
| `--verify <command>` | Run this command after each apply; revert automatically if it fails. |
|
|
171
|
+
| `--project <path>` | Project the suggestions belong to. Default `.`. |
|
|
172
|
+
| `--force` | Apply matching hunks even if others do not match. |
|
|
173
|
+
| `--no-backup` | Skip the backup. Not recommended. |
|
|
174
|
+
|
|
175
|
+
#### `ownkey undo [backup-id]`
|
|
176
|
+
|
|
177
|
+
| Option | Description |
|
|
178
|
+
|---|---|
|
|
179
|
+
| `--last` | Undo the most recent apply. |
|
|
180
|
+
| `--list` | List recent applies. |
|
|
181
|
+
| `--all` | Undo all applies from today. |
|
|
182
|
+
| `-y, --yes` | Skip the confirmation prompt. |
|
|
183
|
+
|
|
184
|
+
#### Global options
|
|
185
|
+
|
|
186
|
+
`--local-only`, `--verbose`, `--debug`, `--quiet`
|
|
187
|
+
|
|
188
|
+
</details>
|
|
189
|
+
|
|
190
|
+
## Providers
|
|
191
|
+
|
|
192
|
+
| Provider | Setup | Default model |
|
|
193
|
+
|---|---|---|
|
|
194
|
+
| OpenAI | `--provider openai --api-key <key>` | `gpt-6.1-sol` |
|
|
195
|
+
| Anthropic | `--provider anthropic --api-key <key>` | `claude-sonnet-5-5` |
|
|
196
|
+
| Google Gemini | `--provider gemini --api-key <key>` | `gemini-3.8-flash` |
|
|
197
|
+
| Ollama | `--provider ollama [--endpoint http://host:11434]` | `qwen2.5-coder:latest` |
|
|
198
|
+
| OpenAI-compatible | `--provider openai --endpoint <base-url> --api-key <key>` | Set with `--model` |
|
|
56
199
|
|
|
57
|
-
|
|
58
|
-
**connection string** from Supabase → Connect → Session pooler; tables are created automatically:
|
|
200
|
+
Defaults are mid-tier models chosen for review quality per dollar. Override with `--model`, for example `gpt-6-astra` or `claude-opus-5-5` for the deepest review. OwnKey sends each model the request shape it expects, including reasoning-era OpenAI models and Claude's adaptive thinking.
|
|
59
201
|
|
|
60
202
|
```bash
|
|
203
|
+
# Example: OpenRouter through the OpenAI-compatible endpoint
|
|
204
|
+
ownkey config --provider openai \
|
|
205
|
+
--endpoint https://openrouter.ai/api/v1 \
|
|
206
|
+
--api-key sk-or-... \
|
|
207
|
+
--model anthropic/claude-sonnet-4.5
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## GitHub Action
|
|
211
|
+
|
|
212
|
+
Review every pull request, post a summary comment, and surface findings in the Security tab.
|
|
213
|
+
|
|
214
|
+
```yaml
|
|
215
|
+
# .github/workflows/ownkey.yml
|
|
216
|
+
name: OwnKey review
|
|
217
|
+
on: pull_request
|
|
218
|
+
|
|
219
|
+
permissions:
|
|
220
|
+
contents: read
|
|
221
|
+
pull-requests: write
|
|
222
|
+
security-events: write
|
|
223
|
+
|
|
224
|
+
jobs:
|
|
225
|
+
review:
|
|
226
|
+
runs-on: ubuntu-latest
|
|
227
|
+
steps:
|
|
228
|
+
- uses: actions/checkout@v4
|
|
229
|
+
with:
|
|
230
|
+
fetch-depth: 0
|
|
231
|
+
- uses: ArpitK24/OwnKey@v1
|
|
232
|
+
with:
|
|
233
|
+
provider: anthropic
|
|
234
|
+
api-key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
235
|
+
fail-on: high
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
| Input | Default | Description |
|
|
239
|
+
|---|---|---|
|
|
240
|
+
| `provider` | required | `openai`, `anthropic`, `gemini`, or `ollama`. |
|
|
241
|
+
| `api-key` | | Provider key, from a repository secret. |
|
|
242
|
+
| `model` | provider default | Any model your key can access. |
|
|
243
|
+
| `endpoint` | | Ollama URL or OpenAI-compatible base URL. |
|
|
244
|
+
| `base` | PR base branch | Ref to review against. |
|
|
245
|
+
| `severity` | `low` | Minimum severity to report. |
|
|
246
|
+
| `fail-on` | | Fail the job at or above this severity. |
|
|
247
|
+
| `comment` | `true` | Post or update one summary comment on the PR. |
|
|
248
|
+
| `upload-sarif` | `true` | Upload findings to GitHub code scanning. |
|
|
249
|
+
| `version` | `latest` | OwnKey version from npm. |
|
|
250
|
+
|
|
251
|
+
### Pre-commit hook
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# .git/hooks/pre-commit
|
|
255
|
+
#!/bin/sh
|
|
256
|
+
exec ownkey review --staged --fail-on high
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## How apply works
|
|
260
|
+
|
|
261
|
+
1. The suggestion's unified diff is parsed and matched against the current file. Small line-number drift is tolerated; hunks whose context does not match are rejected rather than guessed.
|
|
262
|
+
2. The diff is shown and you confirm (skipped with `--auto`, not available without a terminal unless `--auto` is set).
|
|
263
|
+
3. A backup of every affected file is written to `~/.ownkey/backups`.
|
|
264
|
+
4. Changes are written, preserving the file's line endings. New files proposed by the model are created.
|
|
265
|
+
5. With `--verify`, your command runs in the project. If it exits non-zero, the backup is restored immediately.
|
|
266
|
+
6. The suggestion is marked applied, so it cannot be applied twice by accident.
|
|
267
|
+
|
|
268
|
+
`ownkey undo` reverses step 4 exactly, including removing files that the apply created.
|
|
269
|
+
|
|
270
|
+
## Data and privacy
|
|
271
|
+
|
|
272
|
+
| Location | Contents |
|
|
273
|
+
|---|---|
|
|
274
|
+
| `~/.ownkey/config.json` | Provider, model, endpoint, and database settings. |
|
|
275
|
+
| OS keychain | API keys, by default. |
|
|
276
|
+
| `~/.ownkey/keys.enc` | AES-256-GCM encrypted key file, used when no keychain is available or `OWNKEY_NO_KEYCHAIN=1` is set. Encrypted with a random per-install secret in `~/.ownkey/master.key`; both files are readable only by you. |
|
|
277
|
+
| `~/.ownkey/storage/` | Suggestions, kept for 7 days and capped at 100 per project. |
|
|
278
|
+
| `~/.ownkey/backups/` | File backups created by `apply`. |
|
|
279
|
+
|
|
280
|
+
OwnKey has no telemetry and no OwnKey-operated servers. The only network traffic is to the model provider you configured and, if you enabled it, your own database. With Ollama, analysis is fully local.
|
|
281
|
+
|
|
282
|
+
Exclude files from analysis with a `.ownkeyignore` file in the project root (same syntax as `.gitignore`). Common build output, dependencies, lockfiles, binaries, and `.env` are excluded by default.
|
|
283
|
+
|
|
284
|
+
## Optional database
|
|
285
|
+
|
|
286
|
+
For shared history across machines or a team, connect any Postgres database. Tables are created and migrated automatically on first use.
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# Supabase: Project -> Connect -> Session pooler connection string
|
|
61
290
|
ownkey config --database-url "postgresql://postgres.<ref>:<password>@aws-0-<region>.pooler.supabase.com:5432/postgres"
|
|
62
|
-
|
|
291
|
+
|
|
292
|
+
# Return to local-only at any time
|
|
293
|
+
ownkey config --no-database
|
|
63
294
|
```
|
|
64
295
|
|
|
65
|
-
`--supabase-url`
|
|
296
|
+
If the database is unreachable, OwnKey falls back to local storage and keeps working. `--supabase-url` is accepted as an alias for `--database-url`.
|
|
66
297
|
|
|
67
|
-
##
|
|
298
|
+
## Using OwnKey in scripts and CI
|
|
68
299
|
|
|
69
|
-
|
|
300
|
+
Every interactive step has a flag, and OwnKey never blocks waiting for input when there is no terminal.
|
|
70
301
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
-
|
|
74
|
-
|
|
302
|
+
```bash
|
|
303
|
+
export OWNKEY_NO_KEYCHAIN=1
|
|
304
|
+
ownkey config --provider openai --api-key "$OPENAI_API_KEY" --yes
|
|
305
|
+
ownkey review --base origin/main --format sarif --output ownkey.sarif --fail-on high
|
|
306
|
+
ownkey apply --all --severity high --auto --verify "npm test"
|
|
307
|
+
```
|
|
75
308
|
|
|
76
|
-
##
|
|
309
|
+
## Development
|
|
77
310
|
|
|
78
|
-
|
|
311
|
+
```bash
|
|
312
|
+
git clone https://github.com/ArpitK24/OwnKey.git
|
|
313
|
+
cd OwnKey
|
|
314
|
+
npm install
|
|
315
|
+
npm run build
|
|
316
|
+
npm test
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
The test suite runs every command end to end against a mock Ollama server, including `review` against real git repositories, plus unit tests for the diff engine, report formats, response parsing, and provider request shapes. Database tests are opt-in:
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
OWNKEY_TEST_DATABASE_URL=postgresql://user:pass@localhost:5432/postgres npm test
|
|
323
|
+
```
|
|
79
324
|
|
|
80
|
-
##
|
|
325
|
+
## Contributing
|
|
81
326
|
|
|
82
|
-
|
|
327
|
+
Issues and pull requests are welcome. For a change in behavior, please open an issue first to discuss it. Before submitting, run `npm run build` and `npm test`.
|
|
83
328
|
|
|
84
|
-
|
|
329
|
+
Report bugs at [github.com/ArpitK24/OwnKey/issues](https://github.com/ArpitK24/OwnKey/issues).
|
|
330
|
+
|
|
331
|
+
## License
|
|
85
332
|
|
|
86
|
-
|
|
333
|
+
[MIT](LICENSE) © 2026 OwnKey
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/ai/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/ai/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIjE;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,UAAU;IAC7C,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,UAAU,CAAgB;gBAEtB,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAI3C,eAAe,IAAI,MAAM;IAInB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAkCjC,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC,UAAU,CAAC;IAwDhE;;;;OAIG;WACU,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAUtE"}
|
package/dist/ai/anthropic.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AIProvider } from './provider.js';
|
|
2
2
|
import { logger } from '../utils/logger.js';
|
|
3
|
+
import { DEFAULT_MODELS } from '../config/models.js';
|
|
3
4
|
/**
|
|
4
5
|
* Anthropic Claude AI Provider
|
|
5
6
|
* Supports all Claude models: Opus, Sonnet, and Haiku variants
|
|
@@ -12,7 +13,7 @@ export class AnthropicProvider extends AIProvider {
|
|
|
12
13
|
super(apiKey, model);
|
|
13
14
|
}
|
|
14
15
|
getDefaultModel() {
|
|
15
|
-
return
|
|
16
|
+
return DEFAULT_MODELS.anthropic;
|
|
16
17
|
}
|
|
17
18
|
async testConnection() {
|
|
18
19
|
try {
|
|
@@ -59,8 +60,9 @@ export class AnthropicProvider extends AIProvider {
|
|
|
59
60
|
},
|
|
60
61
|
body: JSON.stringify({
|
|
61
62
|
model: this.model,
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
// No temperature: Claude 5.x models reject sampling parameters.
|
|
64
|
+
// Adaptive thinking shares this budget, so leave headroom.
|
|
65
|
+
max_tokens: 32000,
|
|
64
66
|
system: this.getSystemPrompt(),
|
|
65
67
|
messages: [
|
|
66
68
|
{
|
|
@@ -76,7 +78,11 @@ export class AnthropicProvider extends AIProvider {
|
|
|
76
78
|
throw new Error(`Anthropic API error: ${errorData.error?.message || response.statusText}`);
|
|
77
79
|
}
|
|
78
80
|
const data = await response.json();
|
|
79
|
-
|
|
81
|
+
// Adaptive thinking can put thinking blocks before the text; read text blocks only.
|
|
82
|
+
const content = (data.content || [])
|
|
83
|
+
.filter((b) => b?.type === 'text' && typeof b.text === 'string')
|
|
84
|
+
.map((b) => b.text)
|
|
85
|
+
.join('\n');
|
|
80
86
|
if (!content) {
|
|
81
87
|
throw new Error('No content in Anthropic response');
|
|
82
88
|
}
|
|
@@ -97,22 +103,13 @@ export class AnthropicProvider extends AIProvider {
|
|
|
97
103
|
* Returns known models - users can specify any model name in config
|
|
98
104
|
*/
|
|
99
105
|
static async getAvailableModels(_apiKey) {
|
|
100
|
-
//
|
|
106
|
+
// Known models as of Oct 2026
|
|
101
107
|
// Users can use ANY model name - this list is just for convenience
|
|
102
108
|
return [
|
|
103
|
-
|
|
104
|
-
'claude-opus-
|
|
105
|
-
'claude-
|
|
106
|
-
'claude-
|
|
107
|
-
// Claude 3.5 (Legacy)
|
|
108
|
-
'claude-3-5-sonnet-20241022', // Sonnet 3.5
|
|
109
|
-
'claude-3-5-sonnet-20240620', // Sonnet 3.5 (Older)
|
|
110
|
-
// Claude 3 (Legacy)
|
|
111
|
-
'claude-3-opus-20240229', // Opus 3
|
|
112
|
-
'claude-3-sonnet-20240229', // Sonnet 3
|
|
113
|
-
'claude-3-haiku-20240307', // Haiku 3
|
|
114
|
-
// Future models (5.x, 6.x, etc.) will work automatically
|
|
115
|
-
// Users just need to specify the model name in config
|
|
109
|
+
'claude-sonnet-5-5', // balanced default
|
|
110
|
+
'claude-opus-5-5', // deepest review
|
|
111
|
+
'claude-haiku-5-5', // fastest, cheapest
|
|
112
|
+
'claude-fable-5-1',
|
|
116
113
|
];
|
|
117
114
|
}
|
|
118
115
|
}
|
package/dist/ai/anthropic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/ai/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/ai/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IACrC,OAAO,GAAG,8BAA8B,CAAC;IACzC,UAAU,GAAG,YAAY,CAAC;IAElC,YAAY,MAAe,EAAE,KAAc;QACvC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,eAAe;QACX,OAAO,cAAc,CAAC,SAAS,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,cAAc;QAChB,IAAI,CAAC;YACD,8EAA8E;YAC9E,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,WAAW,EAAE;gBACrD,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACL,cAAc,EAAE,kBAAkB;oBAClC,WAA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M,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,OAAe;QAC3C,8BAA8B;QAC9B,mEAAmE;QACnE,OAAO;YACH,mBAAmB,EAAE,mBAAmB;YACxC,iBAAiB,EAAE,iBAAiB;YACpC,kBAAkB,EAAE,oBAAoB;YACxC,kBAAkB;SACrB,CAAC;IACN,CAAC;CACJ"}
|
package/dist/ai/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/ai/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/ai/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAU3C;;GAEG;AACH,qBAAa,iBAAiB;IAC1B;;OAEG;WACU,cAAc,IAAI,OAAO,CAAC,UAAU,CAAC;IA6ClD;;OAEG;WACU,YAAY,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBjE;;OAEG;IACH,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAepD;;OAEG;WACU,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAmBvF"}
|
package/dist/ai/factory.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_MODELS } from '../config/models.js';
|
|
1
2
|
import { GeminiProvider } from './gemini.js';
|
|
2
3
|
import { OpenAIProvider } from './openai.js';
|
|
3
4
|
import { AnthropicProvider } from './anthropic.js';
|
|
@@ -31,17 +32,17 @@ export class AIProviderFactory {
|
|
|
31
32
|
if (!apiKey) {
|
|
32
33
|
throw new ConfigError('OpenAI API key not found. Run: ownkey config');
|
|
33
34
|
}
|
|
34
|
-
const openaiModel = config.providers.openai?.model ||
|
|
35
|
+
const openaiModel = config.providers.openai?.model || DEFAULT_MODELS.openai;
|
|
35
36
|
return new OpenAIProvider(apiKey, openaiModel, config.providers.openai?.endpoint);
|
|
36
37
|
case 'anthropic':
|
|
37
38
|
if (!apiKey) {
|
|
38
39
|
throw new ConfigError('Anthropic API key not found. Run: ownkey config');
|
|
39
40
|
}
|
|
40
|
-
const anthropicModel = config.providers.anthropic?.model ||
|
|
41
|
+
const anthropicModel = config.providers.anthropic?.model || DEFAULT_MODELS.anthropic;
|
|
41
42
|
return new AnthropicProvider(apiKey, anthropicModel);
|
|
42
43
|
case 'ollama':
|
|
43
44
|
// Ollama doesn't require API key - runs locally
|
|
44
|
-
const ollamaModel = config.providers.ollama?.model ||
|
|
45
|
+
const ollamaModel = config.providers.ollama?.model || DEFAULT_MODELS.ollama;
|
|
45
46
|
const ollamaBaseUrl = config.providers.ollama?.endpoint || 'http://localhost:11434';
|
|
46
47
|
return new OllamaProvider(undefined, ollamaModel, ollamaBaseUrl);
|
|
47
48
|
default:
|
|
@@ -76,11 +77,11 @@ export class AIProviderFactory {
|
|
|
76
77
|
case 'gemini':
|
|
77
78
|
return GeminiProvider.getRecommendedModel();
|
|
78
79
|
case 'openai':
|
|
79
|
-
return
|
|
80
|
+
return DEFAULT_MODELS.openai;
|
|
80
81
|
case 'anthropic':
|
|
81
|
-
return
|
|
82
|
+
return DEFAULT_MODELS.anthropic;
|
|
82
83
|
case 'ollama':
|
|
83
|
-
return
|
|
84
|
+
return DEFAULT_MODELS.ollama;
|
|
84
85
|
default:
|
|
85
86
|
return '';
|
|
86
87
|
}
|
package/dist/ai/factory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/ai/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAA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CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,8BAA8B,QAAQ,GAAG,EAAE,KAAc,CAAC,CAAC;YACxE,OAAO,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC7D,CAAC;IACL,CAAC;CACJ"}
|
package/dist/ai/gemini.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../src/ai/gemini.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAmB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../src/ai/gemini.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAmB,MAAM,mBAAmB,CAAC;AA2B7F;;;GAGG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC1C,OAAO,CAAC,OAAO,CAAkD;IAEjE,eAAe,IAAI,MAAM;IAInB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAejC,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,cAAc,CAAC,UAAU,CAAC;IA2E1F;;OAEG;WACU,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAgClE;;OAEG;IACH,MAAM,CAAC,mBAAmB,IAAI,MAAM;CAGvC"}
|
package/dist/ai/gemini.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AIProvider } from './provider.js';
|
|
2
2
|
import { AIProviderError } from '../types/index.js';
|
|
3
3
|
import { logger } from '../utils/logger.js';
|
|
4
|
+
import { DEFAULT_MODELS } from '../config/models.js';
|
|
4
5
|
/**
|
|
5
6
|
* Google Gemini AI Provider
|
|
6
7
|
* Supports: gemini-1.5-pro, gemini-1.5-flash, gemini-pro
|
|
@@ -8,7 +9,7 @@ import { logger } from '../utils/logger.js';
|
|
|
8
9
|
export class GeminiProvider extends AIProvider {
|
|
9
10
|
baseUrl = 'https://generativelanguage.googleapis.com/v1';
|
|
10
11
|
getDefaultModel() {
|
|
11
|
-
return
|
|
12
|
+
return DEFAULT_MODELS.gemini;
|
|
12
13
|
}
|
|
13
14
|
async testConnection() {
|
|
14
15
|
try {
|
|
@@ -41,8 +42,10 @@ export class GeminiProvider extends AIProvider {
|
|
|
41
42
|
},
|
|
42
43
|
],
|
|
43
44
|
generationConfig: {
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
// Gemini 3.x is tuned for its default temperature; thinking shares the output budget.
|
|
46
|
+
...(options?.temperature !== undefined ? { temperature: options.temperature } : {}),
|
|
47
|
+
maxOutputTokens: options?.maxTokens || 32768,
|
|
48
|
+
responseMimeType: 'application/json',
|
|
46
49
|
},
|
|
47
50
|
};
|
|
48
51
|
const response = await fetch(`${this.baseUrl}/models/${this.model}:generateContent`, {
|
|
@@ -63,7 +66,10 @@ export class GeminiProvider extends AIProvider {
|
|
|
63
66
|
throw new AIProviderError('No response from Gemini');
|
|
64
67
|
}
|
|
65
68
|
const candidate = data.candidates[0];
|
|
66
|
-
const responseText = candidate.content
|
|
69
|
+
const responseText = (candidate.content?.parts || [])
|
|
70
|
+
.filter((p) => !p.thought && typeof p.text === 'string')
|
|
71
|
+
.map((p) => p.text)
|
|
72
|
+
.join('');
|
|
67
73
|
logger.verbose('Received response from Gemini');
|
|
68
74
|
logger.debug('Response:', responseText.substring(0, 200) + '...');
|
|
69
75
|
// Parse suggestions from response
|
|
@@ -100,18 +106,18 @@ export class GeminiProvider extends AIProvider {
|
|
|
100
106
|
.filter((m) => m.supportedGenerationMethods?.includes('generateContent') &&
|
|
101
107
|
m.name.includes('gemini'))
|
|
102
108
|
.map((m) => m.name.replace('models/', ''));
|
|
103
|
-
return models.length > 0 ? models : [
|
|
109
|
+
return models.length > 0 ? models : [DEFAULT_MODELS.gemini];
|
|
104
110
|
}
|
|
105
111
|
catch (error) {
|
|
106
112
|
logger.error('Failed to fetch Gemini models:', error);
|
|
107
|
-
return [
|
|
113
|
+
return [DEFAULT_MODELS.gemini, 'gemini-3.6-flash', 'gemini-3.5-flash-lite'];
|
|
108
114
|
}
|
|
109
115
|
}
|
|
110
116
|
/**
|
|
111
117
|
* Get recommended model for code analysis
|
|
112
118
|
*/
|
|
113
119
|
static getRecommendedModel() {
|
|
114
|
-
return
|
|
120
|
+
return DEFAULT_MODELS.gemini;
|
|
115
121
|
}
|
|
116
122
|
}
|
|
117
123
|
//# sourceMappingURL=gemini.js.map
|
package/dist/ai/gemini.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../src/ai/gemini.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAA2C,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../src/ai/gemini.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAA2C,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAyBrD;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IAClC,OAAO,GAAG,8CAA8C,CAAC;IAEjE,eAAe;QACX,OAAO,cAAc,CAAC,MAAM,CAAC;IAC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CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAC5B;iBACA,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;YAEpD,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAChE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAc,CAAC,CAAC;YAC/D,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,kBAAkB,EAAE,uBAAuB,CAAC,CAAC;QAChF,CAAC;IACL,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,mBAAmB;QACtB,OAAO,cAAc,CAAC,MAAM,CAAC;IACjC,CAAC;CACJ"}
|
package/dist/ai/ollama.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ollama.d.ts","sourceRoot":"","sources":["../../src/ai/ollama.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ollama.d.ts","sourceRoot":"","sources":["../../src/ai/ollama.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIjE;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC1C,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAK7D,eAAe,IAAI,MAAM;IAInB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAYjC,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC,UAAU,CAAC;IAwChE;;;OAGG;WACU,kBAAkB,CAAC,OAAO,GAAE,MAAiC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAe9F;;OAEG;WACU,eAAe,CAAC,OAAO,GAAE,MAAiC,GAAG,OAAO,CAAC,OAAO,CAAC;IAS1F;;OAEG;WACU,gBAAgB,CACzB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,MAAiC,GAC3C,OAAO,CAAC,OAAO,CAAC;CAItB"}
|