ownkey 1.0.0 → 1.0.2
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 +21 -21
- package/README.md +256 -81
- package/dist/ai/factory.js +2 -2
- package/dist/ai/factory.js.map +1 -1
- package/dist/ai/gemini.d.ts.map +1 -1
- package/dist/ai/gemini.js +13 -3
- package/dist/ai/gemini.js.map +1 -1
- package/dist/ai/ollama.d.ts +0 -2
- package/dist/ai/ollama.d.ts.map +1 -1
- package/dist/ai/ollama.js +20 -93
- package/dist/ai/ollama.js.map +1 -1
- package/dist/ai/openai.d.ts +4 -1
- package/dist/ai/openai.d.ts.map +1 -1
- package/dist/ai/openai.js +7 -3
- package/dist/ai/openai.js.map +1 -1
- package/dist/ai/provider.d.ts +4 -0
- package/dist/ai/provider.d.ts.map +1 -1
- package/dist/ai/provider.js +80 -47
- package/dist/ai/provider.js.map +1 -1
- package/dist/commands/apply.d.ts.map +1 -1
- package/dist/commands/apply.js +82 -47
- package/dist/commands/apply.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +249 -101
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/suggest.d.ts.map +1 -1
- package/dist/commands/suggest.js +44 -34
- package/dist/commands/suggest.js.map +1 -1
- package/dist/commands/undo.d.ts.map +1 -1
- package/dist/commands/undo.js +35 -25
- package/dist/commands/undo.js.map +1 -1
- package/dist/config/keychain.d.ts.map +1 -1
- package/dist/config/keychain.js +5 -1
- package/dist/config/keychain.js.map +1 -1
- package/dist/config/manager.d.ts +15 -2
- package/dist/config/manager.d.ts.map +1 -1
- package/dist/config/manager.js +42 -13
- package/dist/config/manager.js.map +1 -1
- package/dist/core/apply/engine.d.ts +19 -12
- package/dist/core/apply/engine.d.ts.map +1 -1
- package/dist/core/apply/engine.js +160 -149
- package/dist/core/apply/engine.js.map +1 -1
- package/dist/core/apply/index.d.ts +4 -2
- package/dist/core/apply/index.d.ts.map +1 -1
- package/dist/core/apply/index.js.map +1 -1
- package/dist/core/apply/interactive.d.ts +1 -1
- package/dist/core/apply/interactive.d.ts.map +1 -1
- package/dist/core/apply/interactive.js.map +1 -1
- package/dist/core/backup/index.d.ts +2 -1
- package/dist/core/backup/index.d.ts.map +1 -1
- package/dist/core/backup/index.js.map +1 -1
- package/dist/core/backup/manager.d.ts +6 -1
- package/dist/core/backup/manager.d.ts.map +1 -1
- package/dist/core/backup/manager.js +26 -18
- package/dist/core/backup/manager.js.map +1 -1
- package/dist/core/diff/applier.d.ts +23 -8
- package/dist/core/diff/applier.d.ts.map +1 -1
- package/dist/core/diff/applier.js +85 -80
- package/dist/core/diff/applier.js.map +1 -1
- package/dist/core/diff/index.d.ts +6 -3
- package/dist/core/diff/index.d.ts.map +1 -1
- package/dist/core/diff/index.js.map +1 -1
- package/dist/core/diff/parser.d.ts +2 -0
- package/dist/core/diff/parser.d.ts.map +1 -1
- package/dist/core/diff/parser.js +15 -5
- package/dist/core/diff/parser.js.map +1 -1
- package/dist/core/diff/validator.d.ts +3 -8
- package/dist/core/diff/validator.d.ts.map +1 -1
- package/dist/core/diff/validator.js +13 -71
- package/dist/core/diff/validator.js.map +1 -1
- package/dist/db/client.d.ts +9 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +64 -86
- package/dist/db/client.js.map +1 -1
- package/dist/db/migrations/001_init.sql +80 -80
- package/dist/db/migrations/002_applies.sql +33 -32
- package/dist/index.js +13 -20
- package/dist/index.js.map +1 -1
- package/dist/storage/local.d.ts +12 -0
- package/dist/storage/local.d.ts.map +1 -1
- package/dist/storage/local.js +28 -0
- package/dist/storage/local.js.map +1 -1
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/severity.d.ts +6 -0
- package/dist/utils/severity.d.ts.map +1 -0
- package/dist/utils/severity.js +19 -0
- package/dist/utils/severity.js.map +1 -0
- package/package.json +72 -72
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 OwnKey
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OwnKey
|
|
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
CHANGED
|
@@ -1,81 +1,256 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
**
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/ArpitK24/OwnKey/main/assets/logo.png" alt="OwnKey" width="420">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h3 align="center">The local-first AI coding agent that runs on your own keys.</h3>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
Scan a codebase, get reviewable suggestions as unified diffs, apply them with automatic backups, and undo in one command.<br>
|
|
9
|
+
OpenAI, Anthropic, Google Gemini, or fully offline with Ollama. No account, no telemetry, no required database.
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/ownkey"><img src="https://img.shields.io/npm/v/ownkey?style=flat-square&color=111111&label=npm" alt="npm version"></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/ownkey"><img src="https://img.shields.io/npm/dm/ownkey?style=flat-square&color=111111" alt="npm downloads"></a>
|
|
15
|
+
<img src="https://img.shields.io/node/v/ownkey?style=flat-square&color=111111" alt="node version">
|
|
16
|
+
<a href="https://github.com/ArpitK24/OwnKey/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/ownkey?style=flat-square&color=111111" alt="license"></a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<a href="https://ownkey.qzz.io/docs">Documentation</a> ·
|
|
21
|
+
<a href="https://ownkey.qzz.io/docs/getting-started">Quick start</a> ·
|
|
22
|
+
<a href="https://ownkey.qzz.io/docs/commands">CLI reference</a> ·
|
|
23
|
+
<a href="https://github.com/ArpitK24/OwnKey/blob/main/CHANGELOG.md">Changelog</a>
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Overview
|
|
29
|
+
|
|
30
|
+
OwnKey is a command-line coding agent for developers who want AI code review without handing their workflow to a hosted service. It reads your project locally, sends only the files under analysis to the model provider you choose, and returns structured suggestions: bugs, security issues, performance problems, refactors, and more, each with a severity, a rationale, and a patch you can inspect before anything touches disk.
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
scan -> suggest -> apply -> undo
|
|
34
|
+
map review patch restore
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
| | |
|
|
38
|
+
|---|---|
|
|
39
|
+
| **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. |
|
|
40
|
+
| **Fully offline option** | Point OwnKey at a local Ollama server and no code leaves your machine. |
|
|
41
|
+
| **Review before write** | Every suggestion carries a unified diff. `apply` previews it and asks for confirmation; `--dry-run` never writes. |
|
|
42
|
+
| **Safe by default** | Each apply creates a backup first. `undo` restores modified files and removes files the apply created. |
|
|
43
|
+
| **Standalone** | Suggestions and backups live in `~/.ownkey`. A Postgres or Supabase database is optional, for teams that want shared history. |
|
|
44
|
+
|
|
45
|
+
## Requirements
|
|
46
|
+
|
|
47
|
+
- Node.js 18 or later
|
|
48
|
+
- An API key for OpenAI, Anthropic, or Google Gemini, **or** a running [Ollama](https://ollama.com) server
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install -g ownkey
|
|
54
|
+
ownkey --version
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Quick start
|
|
58
|
+
|
|
59
|
+
**1. Configure a provider**
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Hosted providers
|
|
63
|
+
ownkey config --provider openai --api-key sk-...
|
|
64
|
+
ownkey config --provider anthropic --api-key sk-ant-...
|
|
65
|
+
ownkey config --provider gemini --api-key AIza...
|
|
66
|
+
|
|
67
|
+
# Fully local, no key required
|
|
68
|
+
ownkey config --provider ollama --model qwen2.5-coder:latest
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Any model your key can access works. Set it with `--model`; OwnKey does not maintain a model allowlist.
|
|
72
|
+
|
|
73
|
+
**2. Analyze a project**
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
cd my-project
|
|
77
|
+
ownkey scan . # see what will be analyzed
|
|
78
|
+
ownkey suggest . # generate suggestions
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**3. Review and apply**
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
ownkey apply # list pending suggestions
|
|
85
|
+
ownkey apply <id> --dry-run # preview the diff, write nothing
|
|
86
|
+
ownkey apply <id> # preview, confirm, apply with backup
|
|
87
|
+
ownkey apply --all --severity high # apply everything rated high or critical
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**4. Undo if needed**
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
ownkey undo --list # recent applies
|
|
94
|
+
ownkey undo <backup-id> # restore that apply
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Commands
|
|
98
|
+
|
|
99
|
+
| Command | Purpose |
|
|
100
|
+
|---|---|
|
|
101
|
+
| `ownkey config` | Set the AI provider, model, endpoint, and optional database. Run with no flags for an interactive wizard. |
|
|
102
|
+
| `ownkey scan [path]` | List the files OwnKey would analyze, honoring `.gitignore` and `.ownkeyignore`. |
|
|
103
|
+
| `ownkey suggest [path]` | Analyze files and store suggestions for review. |
|
|
104
|
+
| `ownkey apply [id]` | Apply one suggestion, or all pending ones with `--all`. |
|
|
105
|
+
| `ownkey undo [backup-id]` | Restore files from a backup created by `apply`. |
|
|
106
|
+
|
|
107
|
+
<details>
|
|
108
|
+
<summary><strong>Full option reference</strong></summary>
|
|
109
|
+
|
|
110
|
+
#### `ownkey config`
|
|
111
|
+
|
|
112
|
+
| Option | Description |
|
|
113
|
+
|---|---|
|
|
114
|
+
| `--show` | Print the current configuration (keys are masked). |
|
|
115
|
+
| `--provider <name>` | `openai`, `anthropic`, `gemini`, or `ollama`. |
|
|
116
|
+
| `--api-key <key>` | Provider API key. Not needed for Ollama. |
|
|
117
|
+
| `--model <model>` | Any model available to your key or Ollama server. |
|
|
118
|
+
| `--endpoint <url>` | Ollama server URL, or an OpenAI-compatible base URL with `--provider openai`. |
|
|
119
|
+
| `--database-url <url>` | Optional Postgres connection string for shared history. |
|
|
120
|
+
| `--no-database` | Remove the database and use local storage only. |
|
|
121
|
+
| `--reset` | Reset configuration to defaults. |
|
|
122
|
+
| `-y, --yes` | Skip confirmation prompts. |
|
|
123
|
+
|
|
124
|
+
#### `ownkey scan [path]`
|
|
125
|
+
|
|
126
|
+
| Option | Description |
|
|
127
|
+
|---|---|
|
|
128
|
+
| `--max-file-size <size>` | Skip files larger than this. Default `500kb`. |
|
|
129
|
+
| `--ignore <patterns...>` | Additional ignore patterns. |
|
|
130
|
+
|
|
131
|
+
#### `ownkey suggest [path]`
|
|
132
|
+
|
|
133
|
+
| Option | Description |
|
|
134
|
+
|---|---|
|
|
135
|
+
| `--type <type>` | `bug`, `security`, `performance`, `refactor`, `style`, `architecture`, `test`, or `documentation`. |
|
|
136
|
+
| `--severity <level>` | Minimum severity: `critical`, `high`, `medium`, `low`, `info`. |
|
|
137
|
+
| `--max-files <n>` | Maximum files to analyze. Default `10`. |
|
|
138
|
+
|
|
139
|
+
#### `ownkey apply [id]`
|
|
140
|
+
|
|
141
|
+
| Option | Description |
|
|
142
|
+
|---|---|
|
|
143
|
+
| `--dry-run` | Show the diff without writing. |
|
|
144
|
+
| `--auto` | Apply without the confirmation prompt (for scripts and CI). |
|
|
145
|
+
| `--all` | Apply every pending suggestion for the project. |
|
|
146
|
+
| `--severity <level>` | With `--all`, only apply at or above this severity. |
|
|
147
|
+
| `--project <path>` | Project the suggestions belong to. Default `.`. |
|
|
148
|
+
| `--force` | Apply matching hunks even if others do not match. |
|
|
149
|
+
| `--no-backup` | Skip the backup. Not recommended. |
|
|
150
|
+
|
|
151
|
+
#### `ownkey undo [backup-id]`
|
|
152
|
+
|
|
153
|
+
| Option | Description |
|
|
154
|
+
|---|---|
|
|
155
|
+
| `--list` | List recent applies. |
|
|
156
|
+
| `--all` | Undo all applies from today. |
|
|
157
|
+
| `-y, --yes` | Skip the confirmation prompt. |
|
|
158
|
+
|
|
159
|
+
#### Global options
|
|
160
|
+
|
|
161
|
+
`--local-only`, `--verbose`, `--debug`, `--quiet`
|
|
162
|
+
|
|
163
|
+
</details>
|
|
164
|
+
|
|
165
|
+
## Providers
|
|
166
|
+
|
|
167
|
+
| Provider | Setup | Notes |
|
|
168
|
+
|---|---|---|
|
|
169
|
+
| OpenAI | `--provider openai --api-key <key>` | Any chat model on your account. |
|
|
170
|
+
| Anthropic | `--provider anthropic --api-key <key>` | Any Claude model on your account. |
|
|
171
|
+
| Google Gemini | `--provider gemini --api-key <key>` | Keys from Google AI Studio. |
|
|
172
|
+
| Ollama | `--provider ollama [--endpoint http://host:11434]` | Runs entirely on your hardware. No key. |
|
|
173
|
+
| OpenAI-compatible | `--provider openai --endpoint <base-url> --api-key <key>` | OpenRouter, Groq, LM Studio, vLLM, and similar. |
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Example: OpenRouter through the OpenAI-compatible endpoint
|
|
177
|
+
ownkey config --provider openai \
|
|
178
|
+
--endpoint https://openrouter.ai/api/v1 \
|
|
179
|
+
--api-key sk-or-... \
|
|
180
|
+
--model anthropic/claude-sonnet-4.5
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## How apply works
|
|
184
|
+
|
|
185
|
+
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.
|
|
186
|
+
2. The diff is shown and you confirm (skipped with `--auto`, not available without a terminal unless `--auto` is set).
|
|
187
|
+
3. A backup of every affected file is written to `~/.ownkey/backups`.
|
|
188
|
+
4. Changes are written, preserving the file's line endings. New files proposed by the model are created.
|
|
189
|
+
5. The suggestion is marked applied, so it cannot be applied twice by accident.
|
|
190
|
+
|
|
191
|
+
`ownkey undo` reverses step 4 exactly, including removing files that the apply created.
|
|
192
|
+
|
|
193
|
+
## Data and privacy
|
|
194
|
+
|
|
195
|
+
| Location | Contents |
|
|
196
|
+
|---|---|
|
|
197
|
+
| `~/.ownkey/config.json` | Provider, model, endpoint, and database settings. |
|
|
198
|
+
| OS keychain | API keys, by default. |
|
|
199
|
+
| `~/.ownkey/keys.enc` | Encrypted key file, used when no keychain is available or `OWNKEY_NO_KEYCHAIN=1` is set. |
|
|
200
|
+
| `~/.ownkey/storage/` | Suggestions, kept for 7 days and capped at 100 per project. |
|
|
201
|
+
| `~/.ownkey/backups/` | File backups created by `apply`. |
|
|
202
|
+
|
|
203
|
+
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.
|
|
204
|
+
|
|
205
|
+
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.
|
|
206
|
+
|
|
207
|
+
## Optional database
|
|
208
|
+
|
|
209
|
+
For shared history across machines or a team, connect any Postgres database. Tables are created and migrated automatically on first use.
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# Supabase: Project -> Connect -> Session pooler connection string
|
|
213
|
+
ownkey config --database-url "postgresql://postgres.<ref>:<password>@aws-0-<region>.pooler.supabase.com:5432/postgres"
|
|
214
|
+
|
|
215
|
+
# Return to local-only at any time
|
|
216
|
+
ownkey config --no-database
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
If the database is unreachable, OwnKey falls back to local storage and keeps working. `--supabase-url` is accepted as an alias for `--database-url`.
|
|
220
|
+
|
|
221
|
+
## Using OwnKey in scripts and CI
|
|
222
|
+
|
|
223
|
+
Every interactive step has a flag, and OwnKey never blocks waiting for input when there is no terminal.
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
export OWNKEY_NO_KEYCHAIN=1
|
|
227
|
+
ownkey config --provider openai --api-key "$OPENAI_API_KEY" --yes
|
|
228
|
+
ownkey suggest . --severity high
|
|
229
|
+
ownkey apply --all --severity high --auto
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Development
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
git clone https://github.com/ArpitK24/OwnKey.git
|
|
236
|
+
cd OwnKey
|
|
237
|
+
npm install
|
|
238
|
+
npm run build
|
|
239
|
+
npm test
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
The test suite runs every command end to end against a mock Ollama server, plus unit tests for the diff engine and response parsing. Database tests are opt-in:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
OWNKEY_TEST_DATABASE_URL=postgresql://user:pass@localhost:5432/postgres npm test
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Contributing
|
|
249
|
+
|
|
250
|
+
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`.
|
|
251
|
+
|
|
252
|
+
Report bugs at [github.com/ArpitK24/OwnKey/issues](https://github.com/ArpitK24/OwnKey/issues).
|
|
253
|
+
|
|
254
|
+
## License
|
|
255
|
+
|
|
256
|
+
[MIT](LICENSE) © 2026 OwnKey
|
package/dist/ai/factory.js
CHANGED
|
@@ -32,7 +32,7 @@ export class AIProviderFactory {
|
|
|
32
32
|
throw new ConfigError('OpenAI API key not found. Run: ownkey config');
|
|
33
33
|
}
|
|
34
34
|
const openaiModel = config.providers.openai?.model || 'gpt-4-turbo';
|
|
35
|
-
return new OpenAIProvider(apiKey, openaiModel);
|
|
35
|
+
return new OpenAIProvider(apiKey, openaiModel, config.providers.openai?.endpoint);
|
|
36
36
|
case 'anthropic':
|
|
37
37
|
if (!apiKey) {
|
|
38
38
|
throw new ConfigError('Anthropic API key not found. Run: ownkey config');
|
|
@@ -98,7 +98,7 @@ export class AIProviderFactory {
|
|
|
98
98
|
case 'anthropic':
|
|
99
99
|
return await AnthropicProvider.getAvailableModels(apiKey);
|
|
100
100
|
case 'ollama':
|
|
101
|
-
return
|
|
101
|
+
return await OllamaProvider.getAvailableModels(apiKey || undefined);
|
|
102
102
|
default:
|
|
103
103
|
return [];
|
|
104
104
|
}
|
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,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAC1B;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,cAAc;QACvB,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,CAAC;QAE1C,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YACzB,MAAM,IAAI,WAAW,CAAC,sDAAsD,CAAC,CAAC;QAClF,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC;QACvC,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAEvD,MAAM,CAAC,OA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AC,kBAAkB,CAAC,QAAgB,EAAE,MAAc;QAC5D,IAAI,CAAC;YACD,QAAQ,QAAQ,EAAE,CAAC;gBACf,KAAK,QAAQ;oBACT,OAAO,MAAM,cAAc,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;gBAC3D,KAAK,QAAQ;oBACT,OAAO,MAAM,cAAc,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;gBAC3D,KAAK,WAAW;oBACZ,OAAO,MAAM,iBAAiB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;gBAC9D,KAAK,QAAQ;oBACT,OAAO,MAAM,cAAc,CAAC,kBAAkB,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC;gBACxE;oBACI,OAAO,EAAE,CAAC;YAClB,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;AAyB7F;;;GAGG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC1C,OAAO,CAAC,OAAO,CAAkD;IAEjE,eAAe,IAAI,MAAM;IAInB,cAAc,IAAI,OAAO,CAAC,OAAO,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;AAyB7F;;;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;IAsE1F;;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
|
@@ -11,9 +11,19 @@ export class GeminiProvider extends AIProvider {
|
|
|
11
11
|
return 'gemini-2.5-pro';
|
|
12
12
|
}
|
|
13
13
|
async testConnection() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
try {
|
|
15
|
+
const response = await fetch(`${this.baseUrl}/models?pageSize=1`, {
|
|
16
|
+
headers: { 'x-goog-api-key': this.apiKey || '' },
|
|
17
|
+
});
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
logger.debug(`Gemini connection test failed: ${response.status}`);
|
|
20
|
+
}
|
|
21
|
+
return response.ok;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
logger.debug(`Gemini connection test error: ${error.message}`);
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
17
27
|
}
|
|
18
28
|
async *analyze(context, options) {
|
|
19
29
|
try {
|
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,EA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E,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,2BAA2B,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;YACtE,CAAC;YAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAS,CAAC;YAE1C,iDAAiD;YACjD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM;iBACrB,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CACf,CAAC,CAAC,0BAA0B,EAAE,QAAQ,CAAC,iBAAiB,CAAC;gBACzD,CAAC,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,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;QAC/E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAc,CAAC,CAAC;YAC/D,OAAO,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,uBAAuB,CAAC,CAAC;QAC3E,CAAC;IACL,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,mBAAmB;QACtB,OAAO,gBAAgB,CAAC;IAC5B,CAAC;CACJ"}
|
package/dist/ai/ollama.d.ts
CHANGED
|
@@ -11,8 +11,6 @@ export declare class OllamaProvider extends AIProvider {
|
|
|
11
11
|
getDefaultModel(): string;
|
|
12
12
|
testConnection(): Promise<boolean>;
|
|
13
13
|
analyze(context: CodeContext): AsyncGenerator<Suggestion>;
|
|
14
|
-
private buildPrompt;
|
|
15
|
-
private parseResponse;
|
|
16
14
|
/**
|
|
17
15
|
* Get available Ollama models
|
|
18
16
|
* Lists models installed on the local Ollama instance
|
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;AAGjE;;;;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;
|
|
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;AAGjE;;;;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"}
|
package/dist/ai/ollama.js
CHANGED
|
@@ -27,111 +27,38 @@ export class OllamaProvider extends AIProvider {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
async *analyze(context) {
|
|
30
|
-
|
|
30
|
+
let response;
|
|
31
31
|
try {
|
|
32
|
-
|
|
32
|
+
// Same prompt and JSON contract as every other provider, so suggestions carry diffs.
|
|
33
|
+
response = await fetch(`${this.baseUrl}/api/generate`, {
|
|
33
34
|
method: 'POST',
|
|
34
|
-
headers: {
|
|
35
|
-
'Content-Type': 'application/json',
|
|
36
|
-
},
|
|
35
|
+
headers: { 'Content-Type': 'application/json' },
|
|
37
36
|
body: JSON.stringify({
|
|
38
37
|
model: this.model,
|
|
39
|
-
|
|
38
|
+
system: this.getSystemPrompt(),
|
|
39
|
+
prompt: this.buildUserPrompt(context),
|
|
40
40
|
stream: false,
|
|
41
|
+
options: { temperature: 0.2 },
|
|
41
42
|
}),
|
|
42
43
|
});
|
|
43
|
-
if (!response.ok) {
|
|
44
|
-
throw new Error(`Ollama API error: ${response.status} ${response.statusText}`);
|
|
45
|
-
}
|
|
46
|
-
const data = await response.json();
|
|
47
|
-
const suggestions = this.parseResponse(data.response, context);
|
|
48
|
-
for (const suggestion of suggestions) {
|
|
49
|
-
yield suggestion;
|
|
50
|
-
}
|
|
51
44
|
}
|
|
52
45
|
catch (error) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
' Or check if Ollama is installed: https://ollama.ai');
|
|
57
|
-
}
|
|
58
|
-
throw error;
|
|
46
|
+
throw new Error(`Cannot reach Ollama at ${this.baseUrl} (${error.message}).\n` +
|
|
47
|
+
' Start it with: ollama serve\n' +
|
|
48
|
+
' Or set another endpoint: ownkey config --provider ollama --endpoint <url>');
|
|
59
49
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
.join('\n\n');
|
|
65
|
-
return `You are a code analysis expert. Analyze the following code and identify issues.
|
|
66
|
-
|
|
67
|
-
Project: ${context.projectInfo.name}
|
|
68
|
-
Files to analyze: ${context.projectInfo.fileCount}
|
|
69
|
-
|
|
70
|
-
${fileContents}
|
|
71
|
-
|
|
72
|
-
Please analyze this code and provide suggestions for:
|
|
73
|
-
- Bugs and potential errors
|
|
74
|
-
- Security vulnerabilities
|
|
75
|
-
- Performance issues
|
|
76
|
-
- Code quality improvements
|
|
77
|
-
- Missing tests
|
|
78
|
-
- Documentation gaps
|
|
79
|
-
|
|
80
|
-
For each issue found, provide:
|
|
81
|
-
1. Type (bug, security, performance, test, documentation, style)
|
|
82
|
-
2. Severity (critical, high, medium, low, info)
|
|
83
|
-
3. File path
|
|
84
|
-
4. Description of the issue
|
|
85
|
-
5. Suggested fix
|
|
86
|
-
|
|
87
|
-
Format your response as a JSON array of suggestions:
|
|
88
|
-
[
|
|
89
|
-
{
|
|
90
|
-
"type": "bug",
|
|
91
|
-
"severity": "high",
|
|
92
|
-
"filePath": "path/to/file.js",
|
|
93
|
-
"content": "Description of the issue and suggested fix"
|
|
94
|
-
}
|
|
95
|
-
]`;
|
|
96
|
-
}
|
|
97
|
-
parseResponse(response, context) {
|
|
98
|
-
try {
|
|
99
|
-
// Try to extract JSON from response
|
|
100
|
-
const jsonMatch = response.match(/\[[\s\S]*\]/);
|
|
101
|
-
if (!jsonMatch) {
|
|
102
|
-
// Fallback: create generic suggestion
|
|
103
|
-
return [
|
|
104
|
-
{
|
|
105
|
-
type: 'style',
|
|
106
|
-
severity: 'info',
|
|
107
|
-
filePath: context.files[0]?.path || 'unknown',
|
|
108
|
-
content: response.substring(0, 200),
|
|
109
|
-
diff: '',
|
|
110
|
-
rationale: 'AI response could not be parsed',
|
|
111
|
-
},
|
|
112
|
-
];
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
const body = await response.text().catch(() => '');
|
|
52
|
+
if (response.status === 404 && /model/i.test(body)) {
|
|
53
|
+
throw new Error(`Model "${this.model}" is not installed. Run: ollama pull ${this.model}`);
|
|
113
54
|
}
|
|
114
|
-
|
|
115
|
-
return suggestions.map((s) => ({
|
|
116
|
-
type: s.type || 'info',
|
|
117
|
-
severity: s.severity || 'info',
|
|
118
|
-
filePath: s.filePath || context.files[0]?.path || 'unknown',
|
|
119
|
-
content: s.content || s.description || 'No description provided',
|
|
120
|
-
}));
|
|
55
|
+
throw new Error(`Ollama API error: ${response.status} ${response.statusText} ${body}`.trim());
|
|
121
56
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
type: 'style',
|
|
128
|
-
severity: 'info',
|
|
129
|
-
filePath: context.files[0]?.path || 'unknown',
|
|
130
|
-
content: response.substring(0, 200),
|
|
131
|
-
diff: '',
|
|
132
|
-
rationale: 'AI response parsing failed',
|
|
133
|
-
},
|
|
134
|
-
];
|
|
57
|
+
const data = (await response.json());
|
|
58
|
+
const text = data.response ?? '';
|
|
59
|
+
logger.debug(`Ollama raw response (${text.length} chars): ${text.slice(0, 500)}`);
|
|
60
|
+
for (const suggestion of this.parseSuggestions(text)) {
|
|
61
|
+
yield suggestion;
|
|
135
62
|
}
|
|
136
63
|
}
|
|
137
64
|
/**
|
package/dist/ai/ollama.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ollama.js","sourceRoot":"","sources":["../../src/ai/ollama.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IAClC,OAAO,CAAS;IAExB,YAAY,MAAe,EAAE,KAAc,EAAE,OAAgB;QACzD,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACrB,IAAI,CAAC,O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