@sudosandwich/limps-radix 0.1.1
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 -0
- package/README.md +255 -0
- package/dist/cache/index.d.ts +110 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +176 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/storage.d.ts +73 -0
- package/dist/cache/storage.d.ts.map +1 -0
- package/dist/cache/storage.js +176 -0
- package/dist/cache/storage.js.map +1 -0
- package/dist/cache/ttl.d.ts +62 -0
- package/dist/cache/ttl.d.ts.map +1 -0
- package/dist/cache/ttl.js +96 -0
- package/dist/cache/ttl.js.map +1 -0
- package/dist/extractor/classifier.d.ts +30 -0
- package/dist/extractor/classifier.d.ts.map +1 -0
- package/dist/extractor/classifier.js +150 -0
- package/dist/extractor/classifier.js.map +1 -0
- package/dist/extractor/forward-ref.d.ts +28 -0
- package/dist/extractor/forward-ref.d.ts.map +1 -0
- package/dist/extractor/forward-ref.js +134 -0
- package/dist/extractor/forward-ref.js.map +1 -0
- package/dist/extractor/index.d.ts +25 -0
- package/dist/extractor/index.d.ts.map +1 -0
- package/dist/extractor/index.js +43 -0
- package/dist/extractor/index.js.map +1 -0
- package/dist/extractor/interface.d.ts +40 -0
- package/dist/extractor/interface.d.ts.map +1 -0
- package/dist/extractor/interface.js +233 -0
- package/dist/extractor/interface.js.map +1 -0
- package/dist/extractor/jsdoc.d.ts +24 -0
- package/dist/extractor/jsdoc.d.ts.map +1 -0
- package/dist/extractor/jsdoc.js +74 -0
- package/dist/extractor/jsdoc.js.map +1 -0
- package/dist/extractor/project.d.ts +17 -0
- package/dist/extractor/project.d.ts.map +1 -0
- package/dist/extractor/project.js +33 -0
- package/dist/extractor/project.js.map +1 -0
- package/dist/extractor/props.d.ts +24 -0
- package/dist/extractor/props.d.ts.map +1 -0
- package/dist/extractor/props.js +78 -0
- package/dist/extractor/props.js.map +1 -0
- package/dist/extractor/type-resolver.d.ts +32 -0
- package/dist/extractor/type-resolver.d.ts.map +1 -0
- package/dist/extractor/type-resolver.js +129 -0
- package/dist/extractor/type-resolver.js.map +1 -0
- package/dist/fetcher/index.d.ts +7 -0
- package/dist/fetcher/index.d.ts.map +1 -0
- package/dist/fetcher/index.js +7 -0
- package/dist/fetcher/index.js.map +1 -0
- package/dist/fetcher/npm-registry.d.ts +45 -0
- package/dist/fetcher/npm-registry.d.ts.map +1 -0
- package/dist/fetcher/npm-registry.js +217 -0
- package/dist/fetcher/npm-registry.js.map +1 -0
- package/dist/fetcher/unified-package.d.ts +27 -0
- package/dist/fetcher/unified-package.d.ts.map +1 -0
- package/dist/fetcher/unified-package.js +99 -0
- package/dist/fetcher/unified-package.js.map +1 -0
- package/dist/fetcher/unpkg.d.ts +20 -0
- package/dist/fetcher/unpkg.d.ts.map +1 -0
- package/dist/fetcher/unpkg.js +57 -0
- package/dist/fetcher/unpkg.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/signatures/disambiguation.d.ts +30 -0
- package/dist/signatures/disambiguation.d.ts.map +1 -0
- package/dist/signatures/disambiguation.js +99 -0
- package/dist/signatures/disambiguation.js.map +1 -0
- package/dist/signatures/distinguishing.d.ts +29 -0
- package/dist/signatures/distinguishing.d.ts.map +1 -0
- package/dist/signatures/distinguishing.js +108 -0
- package/dist/signatures/distinguishing.js.map +1 -0
- package/dist/signatures/generator.d.ts +20 -0
- package/dist/signatures/generator.d.ts.map +1 -0
- package/dist/signatures/generator.js +147 -0
- package/dist/signatures/generator.js.map +1 -0
- package/dist/signatures/index.d.ts +10 -0
- package/dist/signatures/index.d.ts.map +1 -0
- package/dist/signatures/index.js +10 -0
- package/dist/signatures/index.js.map +1 -0
- package/dist/signatures/inference.d.ts +37 -0
- package/dist/signatures/inference.d.ts.map +1 -0
- package/dist/signatures/inference.js +132 -0
- package/dist/signatures/inference.js.map +1 -0
- package/dist/tools/extract-primitive.d.ts +49 -0
- package/dist/tools/extract-primitive.d.ts.map +1 -0
- package/dist/tools/extract-primitive.js +103 -0
- package/dist/tools/extract-primitive.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +6 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-primitives.d.ts +40 -0
- package/dist/tools/list-primitives.d.ts.map +1 -0
- package/dist/tools/list-primitives.js +53 -0
- package/dist/tools/list-primitives.js.map +1 -0
- package/dist/types/index.d.ts +83 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Paul Breuler
|
|
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
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# @sudosandwich/limps-radix
|
|
2
|
+
|
|
3
|
+
limps extension for Radix UI contract extraction, semantic analysis, and drift detection.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @sudosandwich/limps-radix
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**Peer Dependencies**: Requires `@sudosandwich/limps@^2.0.0`.
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
1. Add the extension to your limps config (see below).
|
|
16
|
+
2. Restart your limps MCP server.
|
|
17
|
+
3. Use the MCP tools from your client (Cursor, Claude Desktop, etc.).
|
|
18
|
+
|
|
19
|
+
Example `limps.config.json`:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"extensions": ["@sudosandwich/limps-radix"]
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## MCP Tools
|
|
28
|
+
|
|
29
|
+
### `radix_list_primitives`
|
|
30
|
+
|
|
31
|
+
List all available Radix UI primitives with package names and descriptions.
|
|
32
|
+
|
|
33
|
+
**Input**
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"version": "latest"
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Output**
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"version": "1.1.2",
|
|
46
|
+
"primitives": [
|
|
47
|
+
{
|
|
48
|
+
"name": "dialog",
|
|
49
|
+
"package": "@radix-ui/react-dialog",
|
|
50
|
+
"description": "A modal dialog overlay"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"name": "popover",
|
|
54
|
+
"package": "@radix-ui/react-popover",
|
|
55
|
+
"description": "A popup that appears from a trigger"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### `radix_extract_primitive`
|
|
62
|
+
|
|
63
|
+
Extract the behavioral contract for a single Radix primitive, including sub-components, prop metadata, and semantic classification.
|
|
64
|
+
|
|
65
|
+
**Input**
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"primitive": "dialog",
|
|
70
|
+
"version": "latest"
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Output**
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"primitive": "Dialog",
|
|
79
|
+
"package": "@radix-ui/react-dialog",
|
|
80
|
+
"version": "1.1.2",
|
|
81
|
+
"behavior": {
|
|
82
|
+
"statePattern": "binary",
|
|
83
|
+
"compositionPattern": "compound",
|
|
84
|
+
"renderingPattern": "portal-conditional"
|
|
85
|
+
},
|
|
86
|
+
"subComponents": [
|
|
87
|
+
{
|
|
88
|
+
"name": "Root",
|
|
89
|
+
"props": [
|
|
90
|
+
{
|
|
91
|
+
"name": "open",
|
|
92
|
+
"type": "boolean",
|
|
93
|
+
"required": false,
|
|
94
|
+
"category": "state"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "onOpenChange",
|
|
98
|
+
"type": "(open: boolean) => void",
|
|
99
|
+
"required": false,
|
|
100
|
+
"category": "event"
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "Trigger",
|
|
106
|
+
"props": [
|
|
107
|
+
{
|
|
108
|
+
"name": "asChild",
|
|
109
|
+
"type": "boolean",
|
|
110
|
+
"required": false,
|
|
111
|
+
"category": "composition"
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"similarTo": ["AlertDialog", "Popover"],
|
|
117
|
+
"disambiguationRule": "Dialog has modal=true by default; AlertDialog requires action confirmation"
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## API Reference
|
|
122
|
+
|
|
123
|
+
This package re-exports its core types, signatures, cache helpers, and tool definitions from `src/index.ts`.
|
|
124
|
+
|
|
125
|
+
### Types
|
|
126
|
+
|
|
127
|
+
- `ExtractedPrimitive` — Raw extraction from Radix `.d.ts` files.
|
|
128
|
+
- `BehaviorSignature` — Semantic behavioral contract used for comparisons.
|
|
129
|
+
- `PropDefinition` — Prop metadata with semantic classification flags.
|
|
130
|
+
- `SubComponentDefinition` — Sub-component structure and prop list.
|
|
131
|
+
- `RawProp` — Raw prop before classification.
|
|
132
|
+
- `PrimitiveInfo` — Info used by primitive listings.
|
|
133
|
+
- `PackageInfo` — npm registry package metadata.
|
|
134
|
+
- `StatePattern` / `CompositionPattern` / `RenderingPattern` — Behavioral pattern enums.
|
|
135
|
+
|
|
136
|
+
### Modules
|
|
137
|
+
|
|
138
|
+
- `cache` — File-based cache helpers for extracted data and signatures.
|
|
139
|
+
- `signatures` — Behavior signature generation utilities.
|
|
140
|
+
- `tools` — MCP tool definitions (`radix_list_primitives`, `radix_extract_primitive`).
|
|
141
|
+
|
|
142
|
+
## Configuration
|
|
143
|
+
|
|
144
|
+
limps supports extension-specific config via a top-level key in `limps.config.json`.
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"extensions": ["@sudosandwich/limps-radix"],
|
|
149
|
+
"radix": {
|
|
150
|
+
"cacheDir": "~/Library/Application Support/limps-radix"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Options**
|
|
156
|
+
|
|
157
|
+
- `cacheDir` (optional): Base directory for the Radix cache. Defaults to `~/.limps-radix/cache`.
|
|
158
|
+
|
|
159
|
+
## Examples
|
|
160
|
+
|
|
161
|
+
### List primitives for a specific version
|
|
162
|
+
|
|
163
|
+
**Input**
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"version": "1.1.2"
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Output**
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"version": "1.1.2",
|
|
176
|
+
"primitives": [
|
|
177
|
+
{
|
|
178
|
+
"name": "dialog",
|
|
179
|
+
"package": "@radix-ui/react-dialog",
|
|
180
|
+
"description": "A modal dialog overlay"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"name": "popover",
|
|
184
|
+
"package": "@radix-ui/react-popover",
|
|
185
|
+
"description": "A popup that appears from a trigger"
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Extract a primitive contract
|
|
192
|
+
|
|
193
|
+
**Input**
|
|
194
|
+
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"primitive": "dialog"
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**Output**
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"primitive": "Dialog",
|
|
206
|
+
"package": "@radix-ui/react-dialog",
|
|
207
|
+
"version": "1.1.2",
|
|
208
|
+
"behavior": {
|
|
209
|
+
"statePattern": "binary",
|
|
210
|
+
"compositionPattern": "compound",
|
|
211
|
+
"renderingPattern": "portal-conditional"
|
|
212
|
+
},
|
|
213
|
+
"subComponents": [
|
|
214
|
+
{
|
|
215
|
+
"name": "Root",
|
|
216
|
+
"props": [
|
|
217
|
+
{
|
|
218
|
+
"name": "open",
|
|
219
|
+
"type": "boolean",
|
|
220
|
+
"required": false,
|
|
221
|
+
"category": "state"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"name": "onOpenChange",
|
|
225
|
+
"type": "(open: boolean) => void",
|
|
226
|
+
"required": false,
|
|
227
|
+
"category": "event"
|
|
228
|
+
}
|
|
229
|
+
]
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"name": "Trigger",
|
|
233
|
+
"props": [
|
|
234
|
+
{
|
|
235
|
+
"name": "asChild",
|
|
236
|
+
"type": "boolean",
|
|
237
|
+
"required": false,
|
|
238
|
+
"category": "composition"
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
],
|
|
243
|
+
"similarTo": ["AlertDialog", "Popover"],
|
|
244
|
+
"disambiguationRule": "Dialog has modal=true by default; AlertDialog requires action confirmation"
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Notes
|
|
249
|
+
|
|
250
|
+
- If the unified `radix-ui` package is available for a version, the tools may return `radix-ui` as the package name instead of individual `@radix-ui/react-*` packages.
|
|
251
|
+
- Cache entries are stored by version and primitive name to speed up repeated tool calls.
|
|
252
|
+
|
|
253
|
+
## License
|
|
254
|
+
|
|
255
|
+
MIT
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache module for Radix primitive data.
|
|
3
|
+
*
|
|
4
|
+
* Provides version-aware caching with TTL for:
|
|
5
|
+
* - ExtractedPrimitive data
|
|
6
|
+
* - BehaviorSignature data
|
|
7
|
+
* - "Latest" version resolution
|
|
8
|
+
*/
|
|
9
|
+
import type { ExtractedPrimitive, BehaviorSignature } from '../types/index.js';
|
|
10
|
+
export * from './storage.js';
|
|
11
|
+
export * from './ttl.js';
|
|
12
|
+
/**
|
|
13
|
+
* Latest version resolution cache entry.
|
|
14
|
+
*/
|
|
15
|
+
export interface LatestResolution {
|
|
16
|
+
version: string;
|
|
17
|
+
resolvedAt: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Latest resolution cache file content.
|
|
21
|
+
*/
|
|
22
|
+
export interface LatestResolutionCache {
|
|
23
|
+
[primitive: string]: LatestResolution;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Cache options for get operations.
|
|
27
|
+
*/
|
|
28
|
+
export interface CacheGetOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Skip TTL check and return cached data even if expired.
|
|
31
|
+
*/
|
|
32
|
+
ignoreExpired?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Base directory for cache (for testing).
|
|
35
|
+
*/
|
|
36
|
+
baseDir?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Cache options for save operations.
|
|
40
|
+
*/
|
|
41
|
+
export interface CacheSaveOptions {
|
|
42
|
+
/**
|
|
43
|
+
* Base directory for cache (for testing).
|
|
44
|
+
*/
|
|
45
|
+
baseDir?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get cached ExtractedPrimitive data.
|
|
49
|
+
* @param primitive - Primitive name (e.g., "Dialog")
|
|
50
|
+
* @param version - Version string
|
|
51
|
+
* @param options - Cache options
|
|
52
|
+
* @returns Cached data or null if not found or expired
|
|
53
|
+
*/
|
|
54
|
+
export declare function getFromCache(primitive: string, version: string, options?: CacheGetOptions): Promise<ExtractedPrimitive | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Save ExtractedPrimitive data to cache.
|
|
57
|
+
* @param primitive - Primitive name (e.g., "Dialog")
|
|
58
|
+
* @param version - Version string
|
|
59
|
+
* @param data - Data to cache
|
|
60
|
+
* @param options - Cache options
|
|
61
|
+
*/
|
|
62
|
+
export declare function saveToCache(primitive: string, version: string, data: ExtractedPrimitive, options?: CacheSaveOptions): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Get cached BehaviorSignature data.
|
|
65
|
+
* @param primitive - Primitive name (e.g., "Dialog")
|
|
66
|
+
* @param version - Version string
|
|
67
|
+
* @param options - Cache options
|
|
68
|
+
* @returns Cached signature or null if not found or expired
|
|
69
|
+
*/
|
|
70
|
+
export declare function getSignatureFromCache(primitive: string, version: string, options?: CacheGetOptions): Promise<BehaviorSignature | null>;
|
|
71
|
+
/**
|
|
72
|
+
* Save BehaviorSignature data to cache.
|
|
73
|
+
* @param primitive - Primitive name (e.g., "Dialog")
|
|
74
|
+
* @param version - Version string
|
|
75
|
+
* @param signature - Signature to cache
|
|
76
|
+
* @param options - Cache options
|
|
77
|
+
*/
|
|
78
|
+
export declare function saveSignatureToCache(primitive: string, version: string, signature: BehaviorSignature, options?: CacheSaveOptions): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Get the "latest" version resolution for a primitive.
|
|
81
|
+
* @param primitive - Primitive name
|
|
82
|
+
* @param options - Cache options
|
|
83
|
+
* @returns Latest resolution or null if not found or expired
|
|
84
|
+
*/
|
|
85
|
+
export declare function getLatestResolution(primitive: string, options?: CacheGetOptions): Promise<LatestResolution | null>;
|
|
86
|
+
/**
|
|
87
|
+
* Save a "latest" version resolution.
|
|
88
|
+
* @param primitive - Primitive name
|
|
89
|
+
* @param version - Resolved version string
|
|
90
|
+
* @param options - Cache options
|
|
91
|
+
*/
|
|
92
|
+
export declare function saveLatestResolution(primitive: string, version: string, options?: CacheSaveOptions): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Clear cache for a specific primitive and version, or all cache.
|
|
95
|
+
* @param primitive - Optional primitive name (clears all if not provided)
|
|
96
|
+
* @param version - Optional version (clears all versions of primitive if not provided)
|
|
97
|
+
* @param options - Cache options
|
|
98
|
+
*/
|
|
99
|
+
export declare function clearCache(primitive?: string, version?: string, options?: CacheSaveOptions): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Get cache statistics.
|
|
102
|
+
* @param options - Cache options
|
|
103
|
+
* @returns Cache statistics
|
|
104
|
+
*/
|
|
105
|
+
export declare function getCacheStats(options?: CacheGetOptions): Promise<{
|
|
106
|
+
versions: string[];
|
|
107
|
+
primitiveCount: number;
|
|
108
|
+
signatureCount: number;
|
|
109
|
+
}>;
|
|
110
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0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B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,iBAAiB,EAC5B,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAGf;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAqBlC;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAiBf;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAsBf;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC;IAC1E,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC,CAyBD"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache module for Radix primitive data.
|
|
3
|
+
*
|
|
4
|
+
* Provides version-aware caching with TTL for:
|
|
5
|
+
* - ExtractedPrimitive data
|
|
6
|
+
* - BehaviorSignature data
|
|
7
|
+
* - "Latest" version resolution
|
|
8
|
+
*/
|
|
9
|
+
import { getCacheDir, getCachePath, readFromFile, writeToFile, deleteFile, deleteDir, listCachedVersions, listCachedPrimitives, } from './storage.js';
|
|
10
|
+
import { isVersionDataExpired, isSignatureExpired, TTL } from './ttl.js';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
// Re-export storage and TTL utilities
|
|
13
|
+
export * from './storage.js';
|
|
14
|
+
export * from './ttl.js';
|
|
15
|
+
/**
|
|
16
|
+
* Get cached ExtractedPrimitive data.
|
|
17
|
+
* @param primitive - Primitive name (e.g., "Dialog")
|
|
18
|
+
* @param version - Version string
|
|
19
|
+
* @param options - Cache options
|
|
20
|
+
* @returns Cached data or null if not found or expired
|
|
21
|
+
*/
|
|
22
|
+
export async function getFromCache(primitive, version, options = {}) {
|
|
23
|
+
const cachePath = getCachePath(primitive, version, 'data', options.baseDir);
|
|
24
|
+
const data = await readFromFile(cachePath);
|
|
25
|
+
if (!data) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
// Check expiration unless ignored
|
|
29
|
+
if (!options.ignoreExpired && isVersionDataExpired(data.extractedAt)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return data;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Save ExtractedPrimitive data to cache.
|
|
36
|
+
* @param primitive - Primitive name (e.g., "Dialog")
|
|
37
|
+
* @param version - Version string
|
|
38
|
+
* @param data - Data to cache
|
|
39
|
+
* @param options - Cache options
|
|
40
|
+
*/
|
|
41
|
+
export async function saveToCache(primitive, version, data, options = {}) {
|
|
42
|
+
const cachePath = getCachePath(primitive, version, 'data', options.baseDir);
|
|
43
|
+
await writeToFile(cachePath, data);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get cached BehaviorSignature data.
|
|
47
|
+
* @param primitive - Primitive name (e.g., "Dialog")
|
|
48
|
+
* @param version - Version string
|
|
49
|
+
* @param options - Cache options
|
|
50
|
+
* @returns Cached signature or null if not found or expired
|
|
51
|
+
*/
|
|
52
|
+
export async function getSignatureFromCache(primitive, version, options = {}) {
|
|
53
|
+
const cachePath = getCachePath(primitive, version, 'sig', options.baseDir);
|
|
54
|
+
// BehaviorSignature doesn't have a timestamp, so we check the ExtractedPrimitive
|
|
55
|
+
const extractedPath = getCachePath(primitive, version, 'data', options.baseDir);
|
|
56
|
+
const extracted = await readFromFile(extractedPath);
|
|
57
|
+
// If no extracted data exists, signature is orphaned
|
|
58
|
+
if (!extracted && !options.ignoreExpired) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
// Check expiration based on extracted data timestamp
|
|
62
|
+
if (extracted && !options.ignoreExpired && isSignatureExpired(extracted.extractedAt)) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return readFromFile(cachePath);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Save BehaviorSignature data to cache.
|
|
69
|
+
* @param primitive - Primitive name (e.g., "Dialog")
|
|
70
|
+
* @param version - Version string
|
|
71
|
+
* @param signature - Signature to cache
|
|
72
|
+
* @param options - Cache options
|
|
73
|
+
*/
|
|
74
|
+
export async function saveSignatureToCache(primitive, version, signature, options = {}) {
|
|
75
|
+
const cachePath = getCachePath(primitive, version, 'sig', options.baseDir);
|
|
76
|
+
await writeToFile(cachePath, signature);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get the "latest" version resolution for a primitive.
|
|
80
|
+
* @param primitive - Primitive name
|
|
81
|
+
* @param options - Cache options
|
|
82
|
+
* @returns Latest resolution or null if not found or expired
|
|
83
|
+
*/
|
|
84
|
+
export async function getLatestResolution(primitive, options = {}) {
|
|
85
|
+
const cacheDir = getCacheDir(options.baseDir);
|
|
86
|
+
const latestPath = path.join(cacheDir, 'latest-resolved.json');
|
|
87
|
+
const cache = await readFromFile(latestPath);
|
|
88
|
+
if (!cache || !cache[primitive]) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const resolution = cache[primitive];
|
|
92
|
+
// Check expiration
|
|
93
|
+
if (!options.ignoreExpired) {
|
|
94
|
+
const resolvedTime = new Date(resolution.resolvedAt).getTime();
|
|
95
|
+
const now = Date.now();
|
|
96
|
+
if (now - resolvedTime >= TTL.LATEST_RESOLUTION) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return resolution;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Save a "latest" version resolution.
|
|
104
|
+
* @param primitive - Primitive name
|
|
105
|
+
* @param version - Resolved version string
|
|
106
|
+
* @param options - Cache options
|
|
107
|
+
*/
|
|
108
|
+
export async function saveLatestResolution(primitive, version, options = {}) {
|
|
109
|
+
const cacheDir = getCacheDir(options.baseDir);
|
|
110
|
+
const latestPath = path.join(cacheDir, 'latest-resolved.json');
|
|
111
|
+
// Read existing cache
|
|
112
|
+
let cache = await readFromFile(latestPath);
|
|
113
|
+
if (!cache) {
|
|
114
|
+
cache = {};
|
|
115
|
+
}
|
|
116
|
+
// Update entry
|
|
117
|
+
cache[primitive] = {
|
|
118
|
+
version,
|
|
119
|
+
resolvedAt: new Date().toISOString(),
|
|
120
|
+
};
|
|
121
|
+
await writeToFile(latestPath, cache);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Clear cache for a specific primitive and version, or all cache.
|
|
125
|
+
* @param primitive - Optional primitive name (clears all if not provided)
|
|
126
|
+
* @param version - Optional version (clears all versions of primitive if not provided)
|
|
127
|
+
* @param options - Cache options
|
|
128
|
+
*/
|
|
129
|
+
export async function clearCache(primitive, version, options = {}) {
|
|
130
|
+
const cacheDir = getCacheDir(options.baseDir);
|
|
131
|
+
// Clear everything
|
|
132
|
+
if (!primitive) {
|
|
133
|
+
await deleteDir(cacheDir);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
// Clear specific primitive in specific version
|
|
137
|
+
if (version) {
|
|
138
|
+
await deleteFile(getCachePath(primitive, version, 'data', options.baseDir));
|
|
139
|
+
await deleteFile(getCachePath(primitive, version, 'sig', options.baseDir));
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
// Clear specific primitive in all versions
|
|
143
|
+
const versions = await listCachedVersions(options.baseDir);
|
|
144
|
+
for (const v of versions) {
|
|
145
|
+
await deleteFile(getCachePath(primitive, v, 'data', options.baseDir));
|
|
146
|
+
await deleteFile(getCachePath(primitive, v, 'sig', options.baseDir));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get cache statistics.
|
|
151
|
+
* @param options - Cache options
|
|
152
|
+
* @returns Cache statistics
|
|
153
|
+
*/
|
|
154
|
+
export async function getCacheStats(options = {}) {
|
|
155
|
+
const versions = await listCachedVersions(options.baseDir);
|
|
156
|
+
let primitiveCount = 0;
|
|
157
|
+
let signatureCount = 0;
|
|
158
|
+
for (const version of versions) {
|
|
159
|
+
const primitives = await listCachedPrimitives(version, options.baseDir);
|
|
160
|
+
primitiveCount += primitives.length;
|
|
161
|
+
// Count signatures (files ending in .sig.json)
|
|
162
|
+
for (const primitive of primitives) {
|
|
163
|
+
const sigPath = getCachePath(primitive, version, 'sig', options.baseDir);
|
|
164
|
+
const sig = await readFromFile(sigPath);
|
|
165
|
+
if (sig) {
|
|
166
|
+
signatureCount++;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
versions,
|
|
172
|
+
primitiveCount,
|
|
173
|
+
signatureCount,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,UAAU,EACV,SAAS,EACT,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,sCAAsC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AA0CzB;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,SAAiB,EACjB,OAA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|
+
*
|
|
4
|
+
* Cache structure:
|
|
5
|
+
* ~/.limps-radix/
|
|
6
|
+
* cache/
|
|
7
|
+
* 1.0.5/
|
|
8
|
+
* dialog.json # ExtractedPrimitive
|
|
9
|
+
* dialog.sig.json # BehaviorSignature
|
|
10
|
+
* 1.1.0/
|
|
11
|
+
* ...
|
|
12
|
+
* latest-resolved.json # { primitive: { version: "1.1.2", resolvedAt: "..." } }
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Get the cache directory path.
|
|
16
|
+
* @param baseDir - Optional base directory (defaults to home directory)
|
|
17
|
+
* @returns Absolute path to the cache directory
|
|
18
|
+
*/
|
|
19
|
+
export declare function getCacheDir(baseDir?: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Get the versioned cache directory path.
|
|
22
|
+
* @param version - The Radix version
|
|
23
|
+
* @param baseDir - Optional base directory
|
|
24
|
+
* @returns Absolute path to the versioned cache directory
|
|
25
|
+
*/
|
|
26
|
+
export declare function getVersionedCacheDir(version: string, baseDir?: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Get the path for a cached primitive file.
|
|
29
|
+
* @param primitive - Primitive name (e.g., "Dialog")
|
|
30
|
+
* @param version - Version string
|
|
31
|
+
* @param type - Type of cache ('data' for ExtractedPrimitive, 'sig' for BehaviorSignature)
|
|
32
|
+
* @param baseDir - Optional base directory
|
|
33
|
+
* @returns Absolute file path
|
|
34
|
+
*/
|
|
35
|
+
export declare function getCachePath(primitive: string, version: string, type: 'data' | 'sig', baseDir?: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Read data from a cache file.
|
|
38
|
+
* @param cachePath - Full path to the cache file
|
|
39
|
+
* @returns Parsed JSON data or null if file doesn't exist or is invalid
|
|
40
|
+
*/
|
|
41
|
+
export declare function readFromFile<T>(cachePath: string): Promise<T | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Write data to a cache file.
|
|
44
|
+
* @param cachePath - Full path to the cache file
|
|
45
|
+
* @param data - Data to write
|
|
46
|
+
*/
|
|
47
|
+
export declare function writeToFile<T>(cachePath: string, data: T): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Delete a cache file.
|
|
50
|
+
* @param cachePath - Full path to the cache file
|
|
51
|
+
* @returns True if file was deleted, false if it didn't exist
|
|
52
|
+
*/
|
|
53
|
+
export declare function deleteFile(cachePath: string): Promise<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* Delete a directory and all its contents.
|
|
56
|
+
* @param dirPath - Directory path to delete
|
|
57
|
+
* @returns True if directory was deleted, false if it didn't exist
|
|
58
|
+
*/
|
|
59
|
+
export declare function deleteDir(dirPath: string): Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* List all versioned cache directories.
|
|
62
|
+
* @param baseDir - Optional base directory
|
|
63
|
+
* @returns Array of version strings that have cached data
|
|
64
|
+
*/
|
|
65
|
+
export declare function listCachedVersions(baseDir?: string): Promise<string[]>;
|
|
66
|
+
/**
|
|
67
|
+
* List all cached primitives for a version.
|
|
68
|
+
* @param version - Version string
|
|
69
|
+
* @param baseDir - Optional base directory
|
|
70
|
+
* @returns Array of primitive names that have cached data
|
|
71
|
+
*/
|
|
72
|
+
export declare function listCachedPrimitives(version: string, baseDir?: string): Promise<string[]>;
|
|
73
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/cache/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAgBH;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GAAG,KAAK,EACpB,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAOR;AAUD;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAa1E;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAK9E;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAUpE;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAUjE;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAc5E;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBnB"}
|