@claudetools/tools 0.8.10 → 0.9.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.
Files changed (76) hide show
  1. package/dist/codedna/generators/astro.d.ts +18 -0
  2. package/dist/codedna/generators/astro.js +91 -0
  3. package/dist/codedna/generators/authjs.d.ts +18 -0
  4. package/dist/codedna/generators/authjs.js +68 -0
  5. package/dist/codedna/generators/better-auth.d.ts +18 -0
  6. package/dist/codedna/generators/better-auth.js +62 -0
  7. package/dist/codedna/generators/drizzle-orm.d.ts +18 -0
  8. package/dist/codedna/generators/drizzle-orm.js +65 -0
  9. package/dist/codedna/generators/elysia-api.d.ts +12 -0
  10. package/dist/codedna/generators/elysia-api.js +64 -0
  11. package/dist/codedna/generators/hono-api.d.ts +12 -0
  12. package/dist/codedna/generators/hono-api.js +64 -0
  13. package/dist/codedna/generators/lucia-auth.d.ts +18 -0
  14. package/dist/codedna/generators/lucia-auth.js +69 -0
  15. package/dist/codedna/generators/prisma.d.ts +18 -0
  16. package/dist/codedna/generators/prisma.js +64 -0
  17. package/dist/codedna/generators/react-router-v7.d.ts +18 -0
  18. package/dist/codedna/generators/react-router-v7.js +77 -0
  19. package/dist/codedna/generators/react19-shadcn.d.ts +21 -0
  20. package/dist/codedna/generators/react19-shadcn.js +367 -0
  21. package/dist/codedna/generators/sveltekit.d.ts +18 -0
  22. package/dist/codedna/generators/sveltekit.js +73 -0
  23. package/dist/codedna/generators/tanstack-start-drizzle.d.ts +92 -0
  24. package/dist/codedna/generators/tanstack-start-drizzle.js +824 -0
  25. package/dist/codedna/generators/trpc-api.d.ts +12 -0
  26. package/dist/codedna/generators/trpc-api.js +64 -0
  27. package/dist/codedna/index.d.ts +31 -0
  28. package/dist/codedna/index.js +39 -0
  29. package/dist/codedna/kappa-api-generator.d.ts +89 -0
  30. package/dist/codedna/kappa-api-generator.js +493 -0
  31. package/dist/codedna/kappa-ast.d.ts +552 -0
  32. package/dist/codedna/kappa-ast.js +141 -0
  33. package/dist/codedna/kappa-cli.d.ts +2 -0
  34. package/dist/codedna/kappa-cli.js +302 -0
  35. package/dist/codedna/kappa-component-generator.d.ts +47 -0
  36. package/dist/codedna/kappa-component-generator.js +295 -0
  37. package/dist/codedna/kappa-design-generator.d.ts +52 -0
  38. package/dist/codedna/kappa-design-generator.js +365 -0
  39. package/dist/codedna/kappa-drizzle-generator.d.ts +45 -0
  40. package/dist/codedna/kappa-drizzle-generator.js +355 -0
  41. package/dist/codedna/kappa-form-generator.d.ts +51 -0
  42. package/dist/codedna/kappa-form-generator.js +319 -0
  43. package/dist/codedna/kappa-lexer.d.ts +268 -0
  44. package/dist/codedna/kappa-lexer.js +757 -0
  45. package/dist/codedna/kappa-page-generator.d.ts +57 -0
  46. package/dist/codedna/kappa-page-generator.js +338 -0
  47. package/dist/codedna/kappa-parser.d.ts +261 -0
  48. package/dist/codedna/kappa-parser.js +2547 -0
  49. package/dist/codedna/kappa-provenance.d.ts +101 -0
  50. package/dist/codedna/kappa-provenance.js +199 -0
  51. package/dist/codedna/kappa-types-generator.d.ts +37 -0
  52. package/dist/codedna/kappa-types-generator.js +159 -0
  53. package/dist/codedna/kappa-validator.d.ts +86 -0
  54. package/dist/codedna/kappa-validator.js +638 -0
  55. package/dist/codedna/kappa-zod-generator.d.ts +32 -0
  56. package/dist/codedna/kappa-zod-generator.js +216 -0
  57. package/dist/handlers/codedna-handlers.d.ts +1 -1
  58. package/dist/handlers/kappa-handlers.d.ts +116 -0
  59. package/dist/handlers/kappa-handlers.js +465 -0
  60. package/dist/handlers/tool-handlers.js +121 -0
  61. package/dist/templates/claude-md.d.ts +1 -1
  62. package/dist/templates/claude-md.js +166 -9
  63. package/dist/tools.js +199 -0
  64. package/docs/research/2026-01-02-codedna-il-specification.md +639 -0
  65. package/docs/research/2026-01-02-codedna-v2-research.md +943 -0
  66. package/docs/research/2026-01-02-computation-foundations.md +564 -0
  67. package/docs/research/2026-01-02-hardware-description.md +814 -0
  68. package/docs/research/2026-01-02-kappa-specification.md +697 -0
  69. package/docs/research/2026-01-02-kappa-tanstack-example.md +527 -0
  70. package/docs/research/2026-01-02-kappa-v2-synthesis.md +406 -0
  71. package/docs/research/2026-01-02-kappa-v2.5-specification.md +1218 -0
  72. package/docs/research/2026-01-02-kappa-v3-specification.md +1864 -0
  73. package/docs/research/2026-01-02-kappa-whitepaper.md +662 -0
  74. package/docs/research/2026-01-02-logic-constraint.md +731 -0
  75. package/docs/research/2026-01-02-quantum-computation.md +635 -0
  76. package/package.json +4 -2
@@ -0,0 +1,406 @@
1
+ # Kappa v2: Synthesis of Research Findings
2
+
3
+ **Date:** 2026-01-02
4
+ **Status:** Research Synthesis Complete
5
+
6
+ ## Research Summary
7
+
8
+ Four deep research investigations were completed:
9
+
10
+ | Domain | Key Finding | Kappa Implication |
11
+ |--------|-------------|-------------------|
12
+ | Computation Foundations | Lambda calculus remains optimal; linear types are the future | Add linear types |
13
+ | Hardware Description | Circuits = stream functions + state + arrows | Add stream types |
14
+ | Quantum Computation | Requires stratified types (linear quantum, Cartesian classical) | Add type stratification |
15
+ | Logic/Constraint | Relations more fundamental; 4 primitives needed | Add relation primitives |
16
+
17
+ ---
18
+
19
+ ## Kappa v2: Extended Primitives
20
+
21
+ ### Original 6 Primitives (Retained)
22
+
23
+ | Primitive | Symbol | Purpose |
24
+ |-----------|--------|---------|
25
+ | Binding | `=` | Associate name with value |
26
+ | Application | `()` | Apply function to arguments |
27
+ | Composition | `>>` | Combine functions |
28
+ | Abstraction | `=>` | Create function |
29
+ | Type | `:` | Type annotation |
30
+ | Effect | `-[E]->` | Effect annotation |
31
+
32
+ ### New Primitives (Added)
33
+
34
+ | Primitive | Symbol | Purpose | Source |
35
+ |-----------|--------|---------|--------|
36
+ | Linear Type | `!` | Use exactly once | Quantum, Hardware, Rust |
37
+ | Stream Type | `~>` | Continuous signal flow | Hardware, Real-time |
38
+ | Relation | `<=>` | Bidirectional computation | Logic programming |
39
+ | Unification | `?=` | Pattern match with logic vars | Prolog, miniKanren |
40
+
41
+ **Total: 10 primitives** (vs 6 before)
42
+
43
+ ---
44
+
45
+ ## 1. Linear Types (`!`)
46
+
47
+ ### Why Needed
48
+
49
+ From quantum research: "The no-cloning theorem IS the linearity of quantum logic."
50
+ From hardware research: "Chisel uses ownership types for register file management."
51
+ From computation research: "Rust's success proves resource-aware type systems work."
52
+
53
+ ### Syntax
54
+
55
+ ```
56
+ # Linear (use exactly once)
57
+ qubit: !Qubit
58
+
59
+ # Affine (use at most once)
60
+ connection: ?TcpConnection
61
+
62
+ # Unrestricted (default, can copy/delete)
63
+ count: int
64
+ ```
65
+
66
+ ### Type Modalities
67
+
68
+ ```
69
+ # Stratified type system
70
+ Classical<T> # Can copy, delete (Cartesian)
71
+ Linear<T> # Use exactly once (no-clone, no-drop)
72
+ Affine<T> # Use at most once (no-clone, can drop)
73
+
74
+ # Quantum types are implicitly Linear
75
+ Qubit = Linear<|0⟩ | |1⟩>
76
+
77
+ # Classical control, quantum data
78
+ measure: Linear<Qubit> -> Classical<Bit>
79
+ ```
80
+
81
+ ### Hardware Example
82
+
83
+ ```
84
+ # Register is linear - can only be written once per cycle
85
+ register: !Signal<8>
86
+
87
+ # Write consumes the linear token
88
+ write: (!Signal<N>, bits<N>) -> Signal<N>
89
+
90
+ # Ensures single-writer semantics at compile time
91
+ ```
92
+
93
+ ---
94
+
95
+ ## 2. Stream Types (`~>`)
96
+
97
+ ### Why Needed
98
+
99
+ From hardware research: "Circuits are causal stream functions."
100
+
101
+ Hardware doesn't compute values - it transforms continuous signal streams over time.
102
+
103
+ ### Syntax
104
+
105
+ ```
106
+ # Stream type
107
+ Signal<N> = Stream<bits<N>>
108
+
109
+ # Stream function (continuous transformation)
110
+ inverter: Signal<1> ~> Signal<1>
111
+
112
+ # vs point function (single computation)
113
+ not: bit -> bit
114
+ ```
115
+
116
+ ### Temporal Operators
117
+
118
+ ```
119
+ # Delay by one clock cycle
120
+ delay: Signal<N> ~> Signal<N>
121
+
122
+ # Register (delay with enable)
123
+ register: (Signal<N>, Signal<1>) ~> Signal<N>
124
+
125
+ # Feedback loop (arrow-style)
126
+ feedback: ((a, s) ~> (b, s)) -> (a ~> b)
127
+ ```
128
+
129
+ ### Hardware Example (Full Adder)
130
+
131
+ ```
132
+ fullAdder: (Signal<1>, Signal<1>, Signal<1>) ~> (Signal<1>, Signal<1>) =
133
+ (a, b, cin) => {
134
+ sum = a ^ b ^ cin
135
+ cout = (a & b) | (cin & (a ^ b))
136
+ (sum, cout)
137
+ }
138
+
139
+ # 4-bit ripple carry adder using composition
140
+ adder4: (Signal<4>, Signal<4>) ~> (Signal<4>, Signal<1>) =
141
+ (a, b) => chain([
142
+ fullAdder(a[0], b[0], 0),
143
+ fullAdder(a[1], b[1], _),
144
+ fullAdder(a[2], b[2], _),
145
+ fullAdder(a[3], b[3], _)
146
+ ])
147
+ ```
148
+
149
+ ---
150
+
151
+ ## 3. Relations (`<=>`) and Unification (`?=`)
152
+
153
+ ### Why Needed
154
+
155
+ From logic research: "Relations are more fundamental than functions. Every function is a relation, but not vice versa."
156
+
157
+ Functions only go one direction. Relations go both ways.
158
+
159
+ ### Syntax
160
+
161
+ ```
162
+ # Relation declaration
163
+ append: ([a], [a], [a]) <=> bool
164
+
165
+ # Relation definition
166
+ append([], ys, ys).
167
+ append([x|xs], ys, [x|zs]) <= append(xs, ys, zs).
168
+
169
+ # Use in any direction
170
+ append([1,2], [3,4], ?result) # Forward: result = [1,2,3,4]
171
+ append(?front, [3,4], [1,2,3,4]) # Backward: front = [1,2]
172
+ append(?a, ?b, [1,2,3]) # Generate: all splits
173
+ ```
174
+
175
+ ### Unification
176
+
177
+ ```
178
+ # Logic variable
179
+ ?x: int
180
+
181
+ # Unification constraint
182
+ ?x ?= 5 # x must equal 5
183
+ ?x ?= ?y + 1 # x must equal y + 1
184
+ ?x ?= [?head | ?tail] # x is a cons cell
185
+
186
+ # Fresh variable introduction
187
+ fresh(?x =>
188
+ ?x ?= 5
189
+ ?x
190
+ )
191
+ ```
192
+
193
+ ### Constraint Example
194
+
195
+ ```
196
+ # Sudoku solver as relations
197
+ sudoku: Grid<9,9> <=> bool =
198
+ grid => {
199
+ # Each row has 1-9
200
+ rows(grid).all(r => distinct(r) & all(r, in(1..9)))
201
+ # Each column has 1-9
202
+ cols(grid).all(c => distinct(c) & all(c, in(1..9)))
203
+ # Each 3x3 box has 1-9
204
+ boxes(grid).all(b => distinct(b) & all(b, in(1..9)))
205
+ }
206
+
207
+ # Solve (run relation backward)
208
+ solve: Grid<9,9> -> [Grid<9,9>] =
209
+ partial => sudoku(?complete) & matches(partial, ?complete)
210
+ ```
211
+
212
+ ---
213
+
214
+ ## 4. Unified Type System
215
+
216
+ ### Stratification
217
+
218
+ ```
219
+ # Type universes
220
+ Type₀ = Classical types (can copy/delete)
221
+ Type₁ = Linear types (use exactly once)
222
+ Type₂ = Affine types (use at most once)
223
+
224
+ # Subtyping
225
+ Linear <: Affine # Linear can be used where Affine expected
226
+ # (stricter is subtype of looser)
227
+
228
+ # Coercion
229
+ promote: Classical<T> -> Linear<T> # Always safe
230
+ demote: Linear<T> -[Consume]-> Classical<T> # Requires effect
231
+ ```
232
+
233
+ ### Effect Interaction
234
+
235
+ ```
236
+ # Effects can require linearity
237
+ GPU: Linear -> Linear # GPU resources are linear
238
+
239
+ # Measurement collapses quantum to classical
240
+ Measure: Linear<Qubit> -[Collapse]-> Classical<Bit>
241
+
242
+ # IO can consume linear resources
243
+ Close: Linear<File> -[IO]-> ()
244
+ ```
245
+
246
+ ---
247
+
248
+ ## Complete Kappa v2 Syntax
249
+
250
+ ```
251
+ # === TYPES ===
252
+
253
+ # Primitive types
254
+ int, f32, f64, str, bool, void
255
+
256
+ # Compound types
257
+ [T] # Array
258
+ {a: T, b: U} # Record
259
+ T | U # Union
260
+ T? # Optional
261
+ (A, B) -> C # Function
262
+ A ~> B # Stream function
263
+ (A, B, C) <=> D # Relation
264
+
265
+ # Modality types
266
+ Linear<T> # Use exactly once (alias: !T)
267
+ Affine<T> # Use at most once (alias: ?T)
268
+ Classical<T> # Unrestricted (default)
269
+
270
+ # Parameterised types
271
+ Tensor[B, S, D]
272
+ Signal<N>
273
+ Qubit
274
+
275
+ # === EXPRESSIONS ===
276
+
277
+ # Binding
278
+ x = 42
279
+ y: int = 42
280
+ z: !Resource = acquire()
281
+
282
+ # Application
283
+ f(x, y)
284
+ obj.method(arg)
285
+
286
+ # Composition
287
+ a >> b >> c
288
+ input ~> transform ~> output
289
+
290
+ # Abstraction
291
+ x => x * 2
292
+ (a, b) => a + b
293
+
294
+ # Relation
295
+ append(xs, ys, ?zs)
296
+
297
+ # Unification
298
+ ?x ?= pattern
299
+
300
+ # Fresh
301
+ fresh(?v => body)
302
+
303
+ # Match
304
+ x >> match {
305
+ Some(v) => use(v)
306
+ None => default
307
+ }
308
+
309
+ # === EFFECTS ===
310
+
311
+ # Function with effects
312
+ f: A -[E]-> B
313
+
314
+ # Common effects
315
+ Pure # No effects
316
+ IO # External I/O
317
+ State<S> # Mutable state
318
+ Error<E> # Can fail
319
+ Async # Can suspend
320
+ GPU # GPU compute
321
+ Param # Learned parameters
322
+ Consume # Consumes linear resource
323
+ Collapse # Quantum measurement
324
+ Search # Non-deterministic search
325
+
326
+ # Effect composition
327
+ f: A -[IO + Error<E>]-> B
328
+ ```
329
+
330
+ ---
331
+
332
+ ## Universality Assessment
333
+
334
+ ### What Kappa v2 Covers
335
+
336
+ | Domain | Mechanism | Confidence |
337
+ |--------|-----------|------------|
338
+ | Web/APIs | Functions + IO effect | ✅ High |
339
+ | Games/Engines | Functions + State + loops | ✅ High |
340
+ | ML/AI | Functions + Param effect + tensors | ✅ High |
341
+ | Systems (Rust) | Linear types + State | ✅ High |
342
+ | Hardware (HDL) | Stream functions + linear | ✅ High |
343
+ | Quantum | Linear types + stratification | ✅ High |
344
+ | Logic/Constraint | Relations + unification | ✅ High |
345
+ | Infrastructure | Functions + IO | ✅ High |
346
+ | Compilers | Functions + Error | ✅ High |
347
+
348
+ ### What Kappa v2 Might Not Cover Well
349
+
350
+ | Domain | Issue | Mitigation |
351
+ |--------|-------|------------|
352
+ | Vague aesthetics | "Make it pop" | Style data, not code |
353
+ | Analog computing | Continuous math | Differential types? |
354
+ | Self-modifying code | Homoiconicity | Quote/unquote? |
355
+
356
+ ---
357
+
358
+ ## Token Efficiency (Updated)
359
+
360
+ ```
361
+ # Python equivalent: ~60 tokens
362
+ def authenticate(email: str, password: str) -> Optional[User]:
363
+ user = db.find_user(email)
364
+ if user and bcrypt.verify(password, user.password_hash):
365
+ return user
366
+ return None
367
+
368
+ # Kappa v2: ~25 tokens
369
+ authenticate: (email: str, pass: str) -[DB, Error]-> User? =
370
+ db.find(email) >> verify(pass, _.hash) >> _
371
+ ```
372
+
373
+ **Savings: ~58%**
374
+
375
+ ---
376
+
377
+ ## Conclusion
378
+
379
+ Kappa v2 extends the original 6 primitives to 10:
380
+
381
+ | Original | Added |
382
+ |----------|-------|
383
+ | Binding (`=`) | Linear type (`!`) |
384
+ | Application (`()`) | Stream type (`~>`) |
385
+ | Composition (`>>`) | Relation (`<=>`) |
386
+ | Abstraction (`=>`) | Unification (`?=`) |
387
+ | Type (`:`) | |
388
+ | Effect (`-[E]->`) | |
389
+
390
+ This covers:
391
+ - **Classical computation** (lambda calculus)
392
+ - **Concurrent computation** (effects)
393
+ - **Resource-aware computation** (linear types)
394
+ - **Continuous computation** (streams)
395
+ - **Relational computation** (logic programming)
396
+ - **Quantum computation** (linear + stratified)
397
+ - **Hardware description** (streams + linear)
398
+
399
+ **10 primitives. Universal coverage. Research-backed.**
400
+
401
+ The only remaining gaps are:
402
+ 1. Vague aesthetic intent (arguably out of scope for formal language)
403
+ 2. Truly analog/continuous math (edge case, might need calculus primitives)
404
+ 3. Self-modifying code (could add homoiconicity if needed)
405
+
406
+ These are acceptable trade-offs. No language covers 100% of everything.