klyd 0.2.0__tar.gz → 0.2.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: klyd
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: A CLI tool that wraps coding agents via git hooks to inject architectural memory.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -14,14 +14,16 @@ Dynamic: license-file
14
14
 
15
15
  <p align="center">
16
16
 
17
+ ```
17
18
  888 / 888 Y88b / 888~-_
18
19
  888 / 888 Y88b / 888 \
19
20
  888/\ 888 Y88b/ 888 |
20
21
  888 \ 888 Y8Y 888 |
21
22
  888 \ 888 Y 888 /
22
23
  888 \ 888____ / 888_-~
24
+ ```
23
25
 
24
- *An open-source project, not affiliated with the Klyd SaaS*
26
+ #### *An open-source project, not affiliated with the Klyd SaaS*
25
27
 
26
28
  </p>
27
29
 
@@ -1,401 +1,403 @@
1
- # klyd
2
-
3
- <p align="center">
4
-
5
- 888 / 888 Y88b / 888~-_
6
- 888 / 888 Y88b / 888 \
7
- 888/\ 888 Y88b/ 888 |
8
- 888 \ 888 Y8Y 888 |
9
- 888 \ 888 Y 888 /
10
- 888 \ 888____ / 888_-~
11
-
12
- *An open-source project, not affiliated with the Klyd SaaS*
13
-
14
- </p>
15
-
16
- ---
17
-
18
- ## What is klyd?
19
-
20
- klyd is a **decision memory harness** for terminal coding agents (aider, opencode, claude code). It wraps your agent workflow to inject persistent architectural memory into every session.
21
-
22
- ### The Problem
23
-
24
- Agentic coding tools fail in a specific, reproducible way:
25
-
26
- 1. Agent writes a file
27
- 2. Something breaks (test, CI)
28
- 3. Agent patches the nearest thing to make the signal go green
29
- 4. It doesn't fix the root — it satisfies the metric
30
- 5. Next session: agent reads the patched code as ground truth, builds on top of it
31
- 6. After ~20 turns: **slop fortress** — a codebase that compiles but nobody understands
32
-
33
- This is not a model quality problem. It's a **memory and context architecture problem**.
34
-
35
- ### The Solution
36
-
37
- klyd extracts architectural decisions from every commit and injects them into your agent's context at the exact moment of file write — when architectural damage happens.
38
-
39
- - **Two LLM calls per commit cycle maximum**
40
- - **All state lives in `.klyd/`** (local to your repo)
41
- - **BYOK** — bring your own API key
42
- - **Zero infrastructure** — no cloud, no servers
43
-
44
- ---
45
-
46
- ## Installation
47
-
48
- ```bash
49
- # From PyPI (recommended)
50
- pip install klyd
51
-
52
- # Or from source
53
- pip install .
54
- ```
55
-
56
- After installation, verify:
57
- ```bash
58
- kl --help
59
- ```
60
-
61
- ---
62
-
63
- ## Quickstart
64
-
65
- ```bash
66
- # 1. Initialize in your project repository
67
- cd your-project
68
- kl init
69
-
70
- # 2. Configure your API key
71
- kl config --api-key sk-ant-...
72
-
73
- # 3. Make commits with architectural decisions
74
- # (e.g., adding auth, changing DB, adopting a new library)
75
-
76
- # 4. Check extracted decisions
77
- kl status
78
-
79
- # 5. Run your agent with injected memory
80
- kl run aider
81
- ```
82
-
83
- ---
84
-
85
- ## Configuration
86
-
87
- klyd supports multiple LLM providers via BYOK (Bring Your Own Key).
88
-
89
- ### Anthropic (Default)
90
-
91
- ```bash
92
- kl config --api-key sk-ant-... --model claude-sonnet-4-6
93
- ```
94
-
95
- ### OpenAI
96
-
97
- ```bash
98
- kl config --openai-key sk-proj-... --model gpt-4o
99
- ```
100
-
101
- ### OpenRouter
102
-
103
- ```bash
104
- kl config --openrouter-key sk-or-... --model openrouter/free
105
- ```
106
-
107
- ### Google Gemini
108
-
109
- ```bash
110
- kl config --gemini-key AIza... --model gemini-1.5-pro
111
- ```
112
-
113
- ### Groq
114
-
115
- ```bash
116
- kl config --groq-key gsk_... --model llama3-8b-8192
117
- ```
118
-
119
- ### View Current Configuration
120
-
121
- ```bash
122
- kl config --show
123
- ```
124
-
125
- ---
126
-
127
- ## Commands
128
-
129
- ### `kl init`
130
-
131
- Initialize klyd in the current git repository.
132
-
133
- ```bash
134
- kl init
135
- ```
136
-
137
- This:
138
- - Creates `.klyd/` directory
139
- - Initializes SQLite database at `.klyd/memory.db`
140
- - Installs git hooks (post-commit, pre-commit)
141
- - Creates default config at `.klyd/config.json`
142
-
143
- ### `kl config`
144
-
145
- Configure klyd settings.
146
-
147
- ```bash
148
- # Set API key
149
- kl config --api-key sk-ant-...
150
-
151
- # Set model
152
- kl config --model claude-sonnet-4-6
153
-
154
- # Show current config
155
- kl config --show
156
- ```
157
-
158
- ### `kl status`
159
-
160
- View the current decision memory store.
161
-
162
- ```bash
163
- kl status
164
- ```
165
-
166
- Shows:
167
- - Active decisions (sorted by reinforcement count)
168
- - Confidence levels (HIGH/MEDIUM/LOW)
169
- - Event types (NEW/REINFORCE/CONTRADICT)
170
- - Flagged conflicts requiring review
171
-
172
- ### `kl run <agent>`
173
-
174
- Run a coding agent with injected architectural memory.
175
-
176
- ```bash
177
- kl run aider --message "Add user authentication"
178
- kl run opencode
179
- ```
180
-
181
- Options:
182
- - `--no-inject` - Skip generating injection file
183
-
184
- The agent receives your stored architectural decisions as context, preventing contradiction of established patterns.
185
-
186
- ### `kl review`
187
-
188
- Review flagged conflicting decisions.
189
-
190
- ```bash
191
- kl review
192
- ```
193
-
194
- When klyd detects a CONTRADICT (a new decision that conflicts with existing memory), it flags it for human review. This interactive command lets you:
195
-
196
- - **Accept** new decision (archive old)
197
- - **Reject** new decision (keep old)
198
- - **Edit** decision manually
199
- - **Skip** for now
200
-
201
- ### `kl extract-commit`
202
-
203
- Manually trigger decision extraction for the last commit.
204
-
205
- ```bash
206
- kl extract-commit
207
- ```
208
-
209
- Usually called automatically by the post-commit hook.
210
-
211
- ### `kl prepare-injection`
212
-
213
- Generate the injection file for agent sessions.
214
-
215
- ```bash
216
- kl prepare-injection
217
- ```
218
-
219
- Usually called automatically by the pre-commit hook. Outputs to `.klyd/injection.txt`.
220
-
221
- ---
222
-
223
- ## How It Works
224
-
225
- ### Git Hooks
226
-
227
- klyd installs two git hooks:
228
-
229
- **post-commit** (`hooks/post-commit.sh`):
230
- ```bash
231
- #!/bin/sh
232
- kl extract-commit >> .klyd/errors.log 2>&1 || true
233
- ```
234
-
235
- After every commit, extracts architectural decisions via LLM and stores them in SQLite.
236
-
237
- **pre-commit** (`hooks/pre-commit.sh`):
238
- ```bash
239
- #!/bin/sh
240
- kl prepare-injection >> .klyd/errors.log 2>&1 || true
241
- ```
242
-
243
- Before files are committed, queries relevant decisions and writes injection file.
244
-
245
- ### Extraction Flow
246
-
247
- 1. Get diff: `git diff HEAD~1 HEAD`
248
- 2. Get commit message: `git log -1 --format=%B`
249
- 3. Get touched files
250
- 4. Query existing decisions for those files
251
- 5. Call LLM with prompt
252
- 6. Store results:
253
- - **NEW** → `store_decision()`
254
- - **REINFORCE** → `reinforce_decision()` on matching existing
255
- - **CONTRADICT** → `store_decision()` with `flagged=True`
256
-
257
- ### Injection Flow
258
-
259
- 1. Get staged files: `git diff --cached --name-only`
260
- 2. Query top-k decisions for those files (excludes flagged, archived)
261
- 3. Format as injection message
262
- 4. Write to `.klyd/injection.txt`
263
-
264
- ### Decision Schema
265
-
266
- ```sql
267
- CREATE TABLE decisions (
268
- id INTEGER PRIMARY KEY AUTOINCREMENT,
269
- decision TEXT NOT NULL,
270
- module TEXT NOT NULL,
271
- file_patterns TEXT NOT NULL,
272
- confidence TEXT NOT NULL, -- LOW | MEDIUM | HIGH
273
- event_type TEXT NOT NULL, -- NEW | REINFORCE | CONTRADICT
274
- reinforcement_count INTEGER DEFAULT 1,
275
- last_seen_commit TEXT,
276
- created_at TEXT DEFAULT (datetime('now')),
277
- flagged INTEGER DEFAULT 0, -- 1 = needs human review
278
- archived INTEGER DEFAULT 0 -- 1 = soft-deleted
279
- );
280
- ```
281
-
282
- ---
283
-
284
- ## Examples
285
-
286
- ### Example 1: First-Time Setup
287
-
288
- ```bash
289
- $ cd my-project
290
- $ kl init
291
-
292
- # Configure with your API key
293
- $ kl config --api-key sk-ant-...
294
-
295
- # Make your first architectural commit
296
- $ echo "import sqlite3" > db.py
297
- $ git add db.py && git commit -m "feat: add sqlite for data storage"
298
-
299
- # Check extracted decisions
300
- $ kl status
301
- ```
302
-
303
- ### Example 2: Resolving Conflicts
304
-
305
- ```bash
306
- # Make a commit that contradicts existing decision
307
- $ echo "import mongoengine" > nosql.py
308
- $ git add nosql.py && git commit -m "feat: switch to mongodb"
309
-
310
- # LLM detects contradiction, flags for review
311
- $ kl status
312
- # Shows flagged decision in NEEDS REVIEW section
313
-
314
- $ kl review
315
- # Interactive resolution
316
- ```
317
-
318
- ### Example 3: Running Agent with Memory
319
-
320
- ```bash
321
- # Inject memory and run aider
322
- $ kl run aider --message "Add user login to the app"
323
-
324
- # Agent receives your architectural decisions as context
325
- # Won't contradict established patterns (e.g., "use SQLite, not sessions")
326
- ```
327
-
328
- ---
329
-
330
- ## File Structure
331
-
332
- ```
333
- your-project/
334
- ├── .klyd/ # klyd's working directory
335
- │ ├── memory.db # SQLite decision store
336
- │ ├── config.json # Your API keys & settings
337
- │ ├── injection.txt # Generated for agent sessions
338
- │ └── errors.log # Error logs
339
- ├── .git/hooks/
340
- │ ├── post-commit # Installed by kl init
341
- │ └── pre-commit # Installed by kl init
342
- └── [your project files]
343
- ```
344
-
345
- ---
346
-
347
- ## Troubleshooting
348
-
349
- ### "klyd is not initialized. Run `kl init`."
350
-
351
- ```bash
352
- kl init
353
- ```
354
-
355
- ### API Key Errors
356
-
357
- Check your config:
358
- ```bash
359
- kl config --show
360
- ```
361
-
362
- Ensure the key is correct. Errors are logged to `.klyd/errors.log`.
363
-
364
- ### No Decisions Extracted
365
-
366
- - Make commits with clear architectural changes (not just style fixes)
367
- - Ensure API key has credits/quota
368
- - Check `.klyd/errors.log` for details
369
-
370
- ### Hook Not Firing
371
-
372
- Verify hooks are installed:
373
- ```bash
374
- ls -la .git/hooks/post-commit
375
- ls -la .git/hooks/pre-commit
376
- ```
377
-
378
- If missing, re-run:
379
- ```bash
380
- kl init
381
- ```
382
-
383
- ---
384
-
385
- ## Requirements
386
-
387
- - Python 3.11+
388
- - click
389
- - anthropic
390
- - Git repository
391
-
392
- ## License
393
-
394
- MIT License - see LICENSE file.
395
-
396
- ---
397
-
398
- ## Links
399
-
400
- - PyPI: https://pypi.org/project/klyd/
401
- - GitHub: https://github.com/getKlyd/klyd
1
+ # klyd
2
+
3
+ <p align="center">
4
+
5
+ ```
6
+ 888 / 888 Y88b / 888~-_
7
+ 888 / 888 Y88b / 888 \
8
+ 888/\ 888 Y88b/ 888 |
9
+ 888 \ 888 Y8Y 888 |
10
+ 888 \ 888 Y 888 /
11
+ 888 \ 888____ / 888_-~
12
+ ```
13
+
14
+ #### *An open-source project, not affiliated with the Klyd SaaS*
15
+
16
+ </p>
17
+
18
+ ---
19
+
20
+ ## What is klyd?
21
+
22
+ klyd is a **decision memory harness** for terminal coding agents (aider, opencode, claude code). It wraps your agent workflow to inject persistent architectural memory into every session.
23
+
24
+ ### The Problem
25
+
26
+ Agentic coding tools fail in a specific, reproducible way:
27
+
28
+ 1. Agent writes a file
29
+ 2. Something breaks (test, CI)
30
+ 3. Agent patches the nearest thing to make the signal go green
31
+ 4. It doesn't fix the root — it satisfies the metric
32
+ 5. Next session: agent reads the patched code as ground truth, builds on top of it
33
+ 6. After ~20 turns: **slop fortress** — a codebase that compiles but nobody understands
34
+
35
+ This is not a model quality problem. It's a **memory and context architecture problem**.
36
+
37
+ ### The Solution
38
+
39
+ klyd extracts architectural decisions from every commit and injects them into your agent's context at the exact moment of file write — when architectural damage happens.
40
+
41
+ - **Two LLM calls per commit cycle maximum**
42
+ - **All state lives in `.klyd/`** (local to your repo)
43
+ - **BYOK** — bring your own API key
44
+ - **Zero infrastructure** — no cloud, no servers
45
+
46
+ ---
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ # From PyPI (recommended)
52
+ pip install klyd
53
+
54
+ # Or from source
55
+ pip install .
56
+ ```
57
+
58
+ After installation, verify:
59
+ ```bash
60
+ kl --help
61
+ ```
62
+
63
+ ---
64
+
65
+ ## Quickstart
66
+
67
+ ```bash
68
+ # 1. Initialize in your project repository
69
+ cd your-project
70
+ kl init
71
+
72
+ # 2. Configure your API key
73
+ kl config --api-key sk-ant-...
74
+
75
+ # 3. Make commits with architectural decisions
76
+ # (e.g., adding auth, changing DB, adopting a new library)
77
+
78
+ # 4. Check extracted decisions
79
+ kl status
80
+
81
+ # 5. Run your agent with injected memory
82
+ kl run aider
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Configuration
88
+
89
+ klyd supports multiple LLM providers via BYOK (Bring Your Own Key).
90
+
91
+ ### Anthropic (Default)
92
+
93
+ ```bash
94
+ kl config --api-key sk-ant-... --model claude-sonnet-4-6
95
+ ```
96
+
97
+ ### OpenAI
98
+
99
+ ```bash
100
+ kl config --openai-key sk-proj-... --model gpt-4o
101
+ ```
102
+
103
+ ### OpenRouter
104
+
105
+ ```bash
106
+ kl config --openrouter-key sk-or-... --model openrouter/free
107
+ ```
108
+
109
+ ### Google Gemini
110
+
111
+ ```bash
112
+ kl config --gemini-key AIza... --model gemini-1.5-pro
113
+ ```
114
+
115
+ ### Groq
116
+
117
+ ```bash
118
+ kl config --groq-key gsk_... --model llama3-8b-8192
119
+ ```
120
+
121
+ ### View Current Configuration
122
+
123
+ ```bash
124
+ kl config --show
125
+ ```
126
+
127
+ ---
128
+
129
+ ## Commands
130
+
131
+ ### `kl init`
132
+
133
+ Initialize klyd in the current git repository.
134
+
135
+ ```bash
136
+ kl init
137
+ ```
138
+
139
+ This:
140
+ - Creates `.klyd/` directory
141
+ - Initializes SQLite database at `.klyd/memory.db`
142
+ - Installs git hooks (post-commit, pre-commit)
143
+ - Creates default config at `.klyd/config.json`
144
+
145
+ ### `kl config`
146
+
147
+ Configure klyd settings.
148
+
149
+ ```bash
150
+ # Set API key
151
+ kl config --api-key sk-ant-...
152
+
153
+ # Set model
154
+ kl config --model claude-sonnet-4-6
155
+
156
+ # Show current config
157
+ kl config --show
158
+ ```
159
+
160
+ ### `kl status`
161
+
162
+ View the current decision memory store.
163
+
164
+ ```bash
165
+ kl status
166
+ ```
167
+
168
+ Shows:
169
+ - Active decisions (sorted by reinforcement count)
170
+ - Confidence levels (HIGH/MEDIUM/LOW)
171
+ - Event types (NEW/REINFORCE/CONTRADICT)
172
+ - Flagged conflicts requiring review
173
+
174
+ ### `kl run <agent>`
175
+
176
+ Run a coding agent with injected architectural memory.
177
+
178
+ ```bash
179
+ kl run aider --message "Add user authentication"
180
+ kl run opencode
181
+ ```
182
+
183
+ Options:
184
+ - `--no-inject` - Skip generating injection file
185
+
186
+ The agent receives your stored architectural decisions as context, preventing contradiction of established patterns.
187
+
188
+ ### `kl review`
189
+
190
+ Review flagged conflicting decisions.
191
+
192
+ ```bash
193
+ kl review
194
+ ```
195
+
196
+ When klyd detects a CONTRADICT (a new decision that conflicts with existing memory), it flags it for human review. This interactive command lets you:
197
+
198
+ - **Accept** new decision (archive old)
199
+ - **Reject** new decision (keep old)
200
+ - **Edit** decision manually
201
+ - **Skip** for now
202
+
203
+ ### `kl extract-commit`
204
+
205
+ Manually trigger decision extraction for the last commit.
206
+
207
+ ```bash
208
+ kl extract-commit
209
+ ```
210
+
211
+ Usually called automatically by the post-commit hook.
212
+
213
+ ### `kl prepare-injection`
214
+
215
+ Generate the injection file for agent sessions.
216
+
217
+ ```bash
218
+ kl prepare-injection
219
+ ```
220
+
221
+ Usually called automatically by the pre-commit hook. Outputs to `.klyd/injection.txt`.
222
+
223
+ ---
224
+
225
+ ## How It Works
226
+
227
+ ### Git Hooks
228
+
229
+ klyd installs two git hooks:
230
+
231
+ **post-commit** (`hooks/post-commit.sh`):
232
+ ```bash
233
+ #!/bin/sh
234
+ kl extract-commit >> .klyd/errors.log 2>&1 || true
235
+ ```
236
+
237
+ After every commit, extracts architectural decisions via LLM and stores them in SQLite.
238
+
239
+ **pre-commit** (`hooks/pre-commit.sh`):
240
+ ```bash
241
+ #!/bin/sh
242
+ kl prepare-injection >> .klyd/errors.log 2>&1 || true
243
+ ```
244
+
245
+ Before files are committed, queries relevant decisions and writes injection file.
246
+
247
+ ### Extraction Flow
248
+
249
+ 1. Get diff: `git diff HEAD~1 HEAD`
250
+ 2. Get commit message: `git log -1 --format=%B`
251
+ 3. Get touched files
252
+ 4. Query existing decisions for those files
253
+ 5. Call LLM with prompt
254
+ 6. Store results:
255
+ - **NEW** → `store_decision()`
256
+ - **REINFORCE** → `reinforce_decision()` on matching existing
257
+ - **CONTRADICT** → `store_decision()` with `flagged=True`
258
+
259
+ ### Injection Flow
260
+
261
+ 1. Get staged files: `git diff --cached --name-only`
262
+ 2. Query top-k decisions for those files (excludes flagged, archived)
263
+ 3. Format as injection message
264
+ 4. Write to `.klyd/injection.txt`
265
+
266
+ ### Decision Schema
267
+
268
+ ```sql
269
+ CREATE TABLE decisions (
270
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
271
+ decision TEXT NOT NULL,
272
+ module TEXT NOT NULL,
273
+ file_patterns TEXT NOT NULL,
274
+ confidence TEXT NOT NULL, -- LOW | MEDIUM | HIGH
275
+ event_type TEXT NOT NULL, -- NEW | REINFORCE | CONTRADICT
276
+ reinforcement_count INTEGER DEFAULT 1,
277
+ last_seen_commit TEXT,
278
+ created_at TEXT DEFAULT (datetime('now')),
279
+ flagged INTEGER DEFAULT 0, -- 1 = needs human review
280
+ archived INTEGER DEFAULT 0 -- 1 = soft-deleted
281
+ );
282
+ ```
283
+
284
+ ---
285
+
286
+ ## Examples
287
+
288
+ ### Example 1: First-Time Setup
289
+
290
+ ```bash
291
+ $ cd my-project
292
+ $ kl init
293
+
294
+ # Configure with your API key
295
+ $ kl config --api-key sk-ant-...
296
+
297
+ # Make your first architectural commit
298
+ $ echo "import sqlite3" > db.py
299
+ $ git add db.py && git commit -m "feat: add sqlite for data storage"
300
+
301
+ # Check extracted decisions
302
+ $ kl status
303
+ ```
304
+
305
+ ### Example 2: Resolving Conflicts
306
+
307
+ ```bash
308
+ # Make a commit that contradicts existing decision
309
+ $ echo "import mongoengine" > nosql.py
310
+ $ git add nosql.py && git commit -m "feat: switch to mongodb"
311
+
312
+ # LLM detects contradiction, flags for review
313
+ $ kl status
314
+ # Shows flagged decision in NEEDS REVIEW section
315
+
316
+ $ kl review
317
+ # Interactive resolution
318
+ ```
319
+
320
+ ### Example 3: Running Agent with Memory
321
+
322
+ ```bash
323
+ # Inject memory and run aider
324
+ $ kl run aider --message "Add user login to the app"
325
+
326
+ # Agent receives your architectural decisions as context
327
+ # Won't contradict established patterns (e.g., "use SQLite, not sessions")
328
+ ```
329
+
330
+ ---
331
+
332
+ ## File Structure
333
+
334
+ ```
335
+ your-project/
336
+ ├── .klyd/ # klyd's working directory
337
+ │ ├── memory.db # SQLite decision store
338
+ │ ├── config.json # Your API keys & settings
339
+ │ ├── injection.txt # Generated for agent sessions
340
+ │ └── errors.log # Error logs
341
+ ├── .git/hooks/
342
+ │ ├── post-commit # Installed by kl init
343
+ │ └── pre-commit # Installed by kl init
344
+ └── [your project files]
345
+ ```
346
+
347
+ ---
348
+
349
+ ## Troubleshooting
350
+
351
+ ### "klyd is not initialized. Run `kl init`."
352
+
353
+ ```bash
354
+ kl init
355
+ ```
356
+
357
+ ### API Key Errors
358
+
359
+ Check your config:
360
+ ```bash
361
+ kl config --show
362
+ ```
363
+
364
+ Ensure the key is correct. Errors are logged to `.klyd/errors.log`.
365
+
366
+ ### No Decisions Extracted
367
+
368
+ - Make commits with clear architectural changes (not just style fixes)
369
+ - Ensure API key has credits/quota
370
+ - Check `.klyd/errors.log` for details
371
+
372
+ ### Hook Not Firing
373
+
374
+ Verify hooks are installed:
375
+ ```bash
376
+ ls -la .git/hooks/post-commit
377
+ ls -la .git/hooks/pre-commit
378
+ ```
379
+
380
+ If missing, re-run:
381
+ ```bash
382
+ kl init
383
+ ```
384
+
385
+ ---
386
+
387
+ ## Requirements
388
+
389
+ - Python 3.11+
390
+ - click
391
+ - anthropic
392
+ - Git repository
393
+
394
+ ## License
395
+
396
+ MIT License - see LICENSE file.
397
+
398
+ ---
399
+
400
+ ## Links
401
+
402
+ - PyPI: https://pypi.org/project/klyd/
403
+ - GitHub: https://github.com/getKlyd/klyd
@@ -159,24 +159,20 @@ def extract_commit():
159
159
  klyd_dir = Path('.klyd')
160
160
  if not (klyd_dir / 'memory.db').exists():
161
161
  return
162
-
162
+
163
163
  try:
164
- try:
165
- diff = subprocess.check_output(['git', 'diff', 'HEAD~1', 'HEAD'], text=True)
166
- msg = subprocess.check_output(['git', 'log', '-1', '--format=%B'], text=True)
167
- files_out = subprocess.check_output(['git', 'diff', '--name-only', 'HEAD~1', 'HEAD'], text=True)
168
- files = [f for f in files_out.strip().split('\n') if f]
169
- commit_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip()
170
- except subprocess.CalledProcessError:
171
- diff = subprocess.check_output(['git', 'show', 'HEAD'], text=True)
172
- msg = subprocess.check_output(['git', 'log', '-1', '--format=%B'], text=True)
173
- files_out = subprocess.check_output(['git', 'show', '--name-only', '--format=', 'HEAD'], text=True)
174
- files = [f for f in files_out.strip().split('\n') if f]
175
- commit_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip()
164
+ diff = subprocess.check_output(['git', 'show', 'HEAD'], text=True)
165
+ files_out = subprocess.check_output(['git', 'show', '--name-only', '--format=', 'HEAD'], text=True)
166
+ msg = subprocess.check_output(['git', 'log', '-1', '--format=%B'], text=True)
167
+ files = [f for f in files_out.strip().split('\n') if f]
168
+ commit_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip()
169
+ except subprocess.CalledProcessError:
170
+ return
176
171
 
177
- if not files:
178
- return
172
+ if not files:
173
+ return
179
174
 
175
+ try:
180
176
  with console.status("[bold cyan]Extracting architectural decisions via LLM...[/bold cyan]", spinner="dots12"):
181
177
  db_path = str(klyd_dir / 'memory.db')
182
178
  existing = get_decisions_for_files(db_path, files, top_k=20)
@@ -44,7 +44,8 @@ Rules:
44
44
  - Only record if the diff explicitly introduces, changes, or contradicts a decision
45
45
  - Do not guess. Do not infer. Only record what is clearly shown in the diff.
46
46
  - If the commit is a style fix, test update, or minor refactor with no architectural significance: return []
47
- - For each decision, classify as NEW (not seen before), REINFORCE (confirms an existing decision), or CONTRADICT (conflicts with an existing decision)
47
+ - IMPORTANT: A NEW decision should be recorded when the commit introduces a different architectural choice than previously recorded, even if both are in the same project. For example: first commit uses Click, second commit adds SQLite - these are NEW decisions about different architectural choices (CLI framework, database). Only classify as REINFORCE if the commit explicitly confirms or repeats the SAME decision (e.g., adding another Click-based command).
48
+ - For each decision, classify as NEW (new architectural choice), REINFORCE (confirms SAME existing decision), or CONTRADICT (conflicts with an existing decision)
48
49
  - Assign confidence: HIGH (unmistakable from diff), MEDIUM (clear but could have context), LOW (possible but uncertain)
49
50
  - If this commit contradicts any of the listed invariants, set event_type to 'CONTRADICT' and add a note in the 'decision' field describing the violation. Otherwise, proceed with NEW or REINFORCE as before.
50
51
 
@@ -64,19 +65,26 @@ DIFF:
64
65
 
65
66
  Existing architectural invariants (do not violate unless explicitly instructed):
66
67
  {invariants_text}
67
- """
68
+ """
68
69
  try:
69
70
  # Determine provider
70
- if model.startswith('claude-') or 'api_key' in config_data and not any(k in config_data for k in ['openai_key', 'openrouter_key', 'gemini_key', 'groq_key']):
71
- if 'api_key' not in config_data:
72
- raise ValueError("Anthropic API key is required.")
71
+ is_anthropic_model = model.startswith('claude-') or model.startswith('anthropic/')
72
+
73
+ # Direct Anthropic API if we have api_key and no other keys
74
+ if is_anthropic_model and 'api_key' in config_data and not any(k in config_data for k in ['openai_key', 'openrouter_key', 'gemini_key', 'groq_key']):
73
75
  client = Anthropic(api_key=config_data['api_key'])
76
+ # Strip anthropic/ prefix if present
77
+ actual_model = model.replace('anthropic/', '')
74
78
  response = client.messages.create(
75
- model=model,
79
+ model=actual_model,
76
80
  max_tokens=1024,
77
81
  messages=[{"role": "user", "content": prompt}]
78
82
  )
79
83
  content = response.content[0].text.strip()
84
+ # Use OpenRouter for Anthropic models if we have openrouter_key
85
+ elif is_anthropic_model and 'openrouter_key' in config_data:
86
+ url, key = "https://openrouter.ai/api/v1/chat/completions", config_data['openrouter_key']
87
+ content = _call_openai_compatible(url, key, model, prompt)
80
88
  else:
81
89
  # OpenAI compatible providers
82
90
  if model.startswith('gpt-') or model.startswith('o1') or model.startswith('o3'):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: klyd
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: A CLI tool that wraps coding agents via git hooks to inject architectural memory.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -14,14 +14,16 @@ Dynamic: license-file
14
14
 
15
15
  <p align="center">
16
16
 
17
+ ```
17
18
  888 / 888 Y88b / 888~-_
18
19
  888 / 888 Y88b / 888 \
19
20
  888/\ 888 Y88b/ 888 |
20
21
  888 \ 888 Y8Y 888 |
21
22
  888 \ 888 Y 888 /
22
23
  888 \ 888____ / 888_-~
24
+ ```
23
25
 
24
- *An open-source project, not affiliated with the Klyd SaaS*
26
+ #### *An open-source project, not affiliated with the Klyd SaaS*
25
27
 
26
28
  </p>
27
29
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "klyd"
7
- version = "0.2.0"
7
+ version = "0.2.2"
8
8
  description = "A CLI tool that wraps coding agents via git hooks to inject architectural memory."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes