@riotprompt/riotprompt 0.0.8 → 0.0.10
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/.kodrdriv-test-cache.json +6 -0
- package/BUG-ANALYSIS.md +523 -0
- package/CODE-REVIEW-SUMMARY.md +330 -0
- package/FIXES-APPLIED.md +437 -0
- package/README.md +2 -2
- package/dist/builder.js +3 -0
- package/dist/builder.js.map +1 -1
- package/dist/chat.d.ts +1 -1
- package/dist/chat.js +2 -5
- package/dist/chat.js.map +1 -1
- package/dist/constants.js +1 -2
- package/dist/constants.js.map +1 -1
- package/dist/context-manager.d.ts +136 -0
- package/dist/context-manager.js +243 -0
- package/dist/context-manager.js.map +1 -0
- package/dist/conversation-logger.d.ts +285 -0
- package/dist/conversation-logger.js +491 -0
- package/dist/conversation-logger.js.map +1 -0
- package/dist/conversation.d.ts +277 -0
- package/dist/conversation.js +649 -0
- package/dist/conversation.js.map +1 -0
- package/dist/formatter.js.map +1 -1
- package/dist/items/section.js +3 -3
- package/dist/items/section.js.map +1 -1
- package/dist/iteration-strategy.d.ts +233 -0
- package/dist/iteration-strategy.js +520 -0
- package/dist/iteration-strategy.js.map +1 -0
- package/dist/loader.js +21 -3
- package/dist/loader.js.map +1 -1
- package/dist/message-builder.d.ts +156 -0
- package/dist/message-builder.js +256 -0
- package/dist/message-builder.js.map +1 -0
- package/dist/model-config.d.ts +115 -0
- package/dist/model-config.js +205 -0
- package/dist/model-config.js.map +1 -0
- package/dist/override.js +8 -1
- package/dist/override.js.map +1 -1
- package/dist/parser.js +3 -3
- package/dist/parser.js.map +1 -1
- package/dist/recipes.d.ts +42 -0
- package/dist/recipes.js +189 -4
- package/dist/recipes.js.map +1 -1
- package/dist/reflection.d.ts +250 -0
- package/dist/reflection.js +419 -0
- package/dist/reflection.js.map +1 -0
- package/dist/riotprompt.cjs +3854 -178
- package/dist/riotprompt.cjs.map +1 -1
- package/dist/riotprompt.d.ts +20 -2
- package/dist/riotprompt.js +10 -1
- package/dist/riotprompt.js.map +1 -1
- package/dist/token-budget.d.ts +177 -0
- package/dist/token-budget.js +401 -0
- package/dist/token-budget.js.map +1 -0
- package/dist/tools.d.ts +239 -0
- package/dist/tools.js +324 -0
- package/dist/tools.js.map +1 -0
- package/dist/util/general.js +1 -1
- package/dist/util/general.js.map +1 -1
- package/package.json +23 -20
package/FIXES-APPLIED.md
ADDED
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
# Code Review Fixes Applied
|
|
2
|
+
|
|
3
|
+
All issues identified in the comprehensive code review have been fixed.
|
|
4
|
+
|
|
5
|
+
## Summary
|
|
6
|
+
|
|
7
|
+
- **Total Issues Fixed:** 19
|
|
8
|
+
- **Critical Issues:** 4
|
|
9
|
+
- **High Priority Issues:** 6
|
|
10
|
+
- **Medium Priority Issues:** 9
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 🔴 Critical Issues Fixed
|
|
15
|
+
|
|
16
|
+
### 1. **Memory Leak in TokenBudgetManager** ✅
|
|
17
|
+
**File:** `src/token-budget.ts`
|
|
18
|
+
|
|
19
|
+
**Problem:** Creating temporary `TokenBudgetManager` instances without disposing encoders.
|
|
20
|
+
|
|
21
|
+
**Fix:** Modified `compressAdaptive()` to temporarily modify config instead of creating new instance.
|
|
22
|
+
|
|
23
|
+
**Before:**
|
|
24
|
+
```typescript
|
|
25
|
+
const tempManager = new TokenBudgetManager(modifiedConfig, 'gpt-4o', this.logger);
|
|
26
|
+
return tempManager.compressFIFO(messages, targetTokens);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**After:**
|
|
30
|
+
```typescript
|
|
31
|
+
const originalPreserveRecent = this.config.preserveRecent;
|
|
32
|
+
this.config.preserveRecent = 5;
|
|
33
|
+
const result = this.compressFIFO(messages, targetTokens);
|
|
34
|
+
this.config.preserveRecent = originalPreserveRecent;
|
|
35
|
+
return result;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### 2. **Context Injection Position Tracking Bug** ✅
|
|
41
|
+
**File:** `src/conversation.ts`
|
|
42
|
+
|
|
43
|
+
**Problem:** Multiple items injected at same position had incorrect tracking.
|
|
44
|
+
|
|
45
|
+
**Fix:** Track each item at `position + index` to maintain correct positions.
|
|
46
|
+
|
|
47
|
+
**Before:**
|
|
48
|
+
```typescript
|
|
49
|
+
this.state.messages.splice(position, 0, contextMessage);
|
|
50
|
+
this.state.contextManager.track(item, position);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**After:**
|
|
54
|
+
```typescript
|
|
55
|
+
const actualPosition = position + i;
|
|
56
|
+
this.state.messages.splice(actualPosition, 0, contextMessage);
|
|
57
|
+
this.state.contextManager.track(item, actualPosition);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### 3. **Shallow Copy Causing Shared State** ✅
|
|
63
|
+
**File:** `src/conversation.ts`
|
|
64
|
+
|
|
65
|
+
**Problem:** Cloning conversations with shallow copy causes `tool_calls` arrays to be shared.
|
|
66
|
+
|
|
67
|
+
**Fix:** Deep copy messages including nested `tool_calls` arrays.
|
|
68
|
+
|
|
69
|
+
**Before:**
|
|
70
|
+
```typescript
|
|
71
|
+
cloned.state.messages = this.state.messages.map(msg => ({ ...msg }));
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**After:**
|
|
75
|
+
```typescript
|
|
76
|
+
cloned.state.messages = this.state.messages.map(msg => ({
|
|
77
|
+
...msg,
|
|
78
|
+
tool_calls: msg.tool_calls ? msg.tool_calls.map(tc => ({
|
|
79
|
+
...tc,
|
|
80
|
+
function: { ...tc.function }
|
|
81
|
+
})) : undefined
|
|
82
|
+
}));
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
### 4. **Uncaught JSON Parse Error** ✅
|
|
88
|
+
**File:** `src/iteration-strategy.ts`
|
|
89
|
+
|
|
90
|
+
**Problem:** No error handling for `JSON.parse()` on tool arguments.
|
|
91
|
+
|
|
92
|
+
**Fix:** Wrapped JSON.parse in try-catch with descriptive error message.
|
|
93
|
+
|
|
94
|
+
**After:**
|
|
95
|
+
```typescript
|
|
96
|
+
let toolArgs: any;
|
|
97
|
+
try {
|
|
98
|
+
toolArgs = JSON.parse(toolCall.function.arguments);
|
|
99
|
+
} catch (parseError) {
|
|
100
|
+
throw new Error(`Invalid JSON in tool arguments: ${parseError.message}`);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 🟡 High Priority Issues Fixed
|
|
107
|
+
|
|
108
|
+
### 5. **Hardcoded Model in Recipe ExecuteWith** ✅
|
|
109
|
+
**File:** `src/recipes.ts`
|
|
110
|
+
|
|
111
|
+
**Problem:** `executeWith()` hardcoded `'gpt-4o'` model.
|
|
112
|
+
|
|
113
|
+
**Fix:** Added `model` parameter with default value.
|
|
114
|
+
|
|
115
|
+
**After:**
|
|
116
|
+
```typescript
|
|
117
|
+
executeWith: async (
|
|
118
|
+
llm: LLMClient,
|
|
119
|
+
strategy: IterationStrategy,
|
|
120
|
+
model: Model = 'gpt-4o',
|
|
121
|
+
tokenBudget?: TokenBudgetConfig
|
|
122
|
+
)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
### 6. **Section Array Append Missing Options** ✅
|
|
128
|
+
**File:** `src/items/section.ts`
|
|
129
|
+
|
|
130
|
+
**Problem:** Options not propagated when appending arrays.
|
|
131
|
+
|
|
132
|
+
**Fix:** Pass `options` parameter in recursive calls.
|
|
133
|
+
|
|
134
|
+
**After:**
|
|
135
|
+
```typescript
|
|
136
|
+
if (Array.isArray(item)) {
|
|
137
|
+
item.forEach((item) => {
|
|
138
|
+
append(item, options); // Now propagates options
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
### 7. **JSONL File Race Condition** ✅
|
|
146
|
+
**File:** `src/conversation-logger.ts`
|
|
147
|
+
|
|
148
|
+
**Problem:** Fire-and-forget async writes could corrupt JSONL files.
|
|
149
|
+
|
|
150
|
+
**Fix:** Added write queue and cached output path.
|
|
151
|
+
|
|
152
|
+
**After:**
|
|
153
|
+
```typescript
|
|
154
|
+
private cachedOutputPath?: string;
|
|
155
|
+
private writeQueue: Promise<void> = Promise.resolve();
|
|
156
|
+
|
|
157
|
+
// Queue writes
|
|
158
|
+
this.writeQueue = this.writeQueue
|
|
159
|
+
.then(() => this.appendToJSONL(loggedMessage))
|
|
160
|
+
.catch(this.config.onError);
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
### 8. **Hardcoded Model Detection System** ✅
|
|
166
|
+
**Files:** New `src/model-config.ts`, `src/chat.ts`, `src/message-builder.ts`, `src/token-budget.ts`
|
|
167
|
+
|
|
168
|
+
**Problem:** Model names hardcoded throughout codebase, inflexible for new models.
|
|
169
|
+
|
|
170
|
+
**Fix:** Created flexible `ModelRegistry` system with pattern-based configuration.
|
|
171
|
+
|
|
172
|
+
**Key Features:**
|
|
173
|
+
- Pattern-based model matching (regex)
|
|
174
|
+
- Configurable role mapping (system vs developer)
|
|
175
|
+
- Tokenizer encoding configuration
|
|
176
|
+
- User-extensible via `configureModel()`
|
|
177
|
+
|
|
178
|
+
**Example Usage:**
|
|
179
|
+
```typescript
|
|
180
|
+
import { configureModel } from 'riotprompt';
|
|
181
|
+
|
|
182
|
+
// Add support for new model family
|
|
183
|
+
configureModel({
|
|
184
|
+
pattern: /^gemini/i,
|
|
185
|
+
personaRole: 'system',
|
|
186
|
+
encoding: 'cl100k_base',
|
|
187
|
+
family: 'gemini'
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
### 9. **Conversation Replayer JSON Parse Error** ✅
|
|
194
|
+
**File:** `src/conversation-logger.ts`
|
|
195
|
+
|
|
196
|
+
**Problem:** No error handling when parsing tool call arguments from logs.
|
|
197
|
+
|
|
198
|
+
**Fix:** Added try-catch with fallback object containing raw arguments.
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
### 10. **Iteration Counter Misplaced** ✅
|
|
203
|
+
**File:** `src/iteration-strategy.ts`
|
|
204
|
+
|
|
205
|
+
**Problem:** Counter incremented per phase instead of per iteration.
|
|
206
|
+
|
|
207
|
+
**Fix:** Moved `incrementIteration()` inside the iteration loop.
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## 🟠 Medium Priority Issues Fixed
|
|
212
|
+
|
|
213
|
+
### 11. **FIFO Compression O(n*m) Complexity** ✅
|
|
214
|
+
**File:** `src/token-budget.ts`
|
|
215
|
+
|
|
216
|
+
**Problem:** Using `includes()` on array is O(n*m) for large conversations.
|
|
217
|
+
|
|
218
|
+
**Fix:** Use `Set` for O(1) lookups, reducing to O(n).
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
### 12. **Overly Aggressive Similar Content Detection** ✅
|
|
223
|
+
**File:** `src/context-manager.ts`
|
|
224
|
+
|
|
225
|
+
**Problem:** "Hello" and "Hello world" considered duplicates.
|
|
226
|
+
|
|
227
|
+
**Fix:** Added similarity threshold (default 90%) for substring matching.
|
|
228
|
+
|
|
229
|
+
**After:**
|
|
230
|
+
```typescript
|
|
231
|
+
hasSimilarContent(content: string, similarityThreshold: number = 0.9): boolean {
|
|
232
|
+
const lengthRatio = shorter.length / longer.length;
|
|
233
|
+
if (lengthRatio >= similarityThreshold) {
|
|
234
|
+
if (longer.includes(shorter)) {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
### 13. **Duplicate Context Without IDs** ✅
|
|
244
|
+
**File:** `src/context-manager.ts`
|
|
245
|
+
|
|
246
|
+
**Problem:** Same content tracked multiple times if no ID provided.
|
|
247
|
+
|
|
248
|
+
**Fix:** Check content hash before tracking items without IDs.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
### 14. **Tool Category Filter Edge Case** ✅
|
|
253
|
+
**File:** `src/recipes.ts`
|
|
254
|
+
|
|
255
|
+
**Problem:** Tools without category could match empty string in filter array.
|
|
256
|
+
|
|
257
|
+
**Fix:** Added explicit check for truthy `tool.category`.
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
### 15. **Circuit Breaker for Failing Tools** ✅
|
|
262
|
+
**File:** `src/iteration-strategy.ts`
|
|
263
|
+
|
|
264
|
+
**Problem:** No protection against repeatedly calling broken tools.
|
|
265
|
+
|
|
266
|
+
**Fix:** Added circuit breaker with configurable threshold (default: 3 consecutive failures).
|
|
267
|
+
|
|
268
|
+
**Features:**
|
|
269
|
+
- Tracks consecutive failures per tool
|
|
270
|
+
- Configurable via `maxConsecutiveToolFailures` in phase config
|
|
271
|
+
- Resets counter on successful execution
|
|
272
|
+
- Logs circuit breaker triggers
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
### 16. **Generic Parser Error Message** ✅
|
|
277
|
+
**File:** `src/parser.ts`
|
|
278
|
+
|
|
279
|
+
**Problem:** Error said "instructions" but parser is used for all content types.
|
|
280
|
+
|
|
281
|
+
**Fix:** Changed to generic "content" in error message.
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
### 17. **Override Array Mutation** ✅
|
|
286
|
+
**File:** `src/override.ts`
|
|
287
|
+
|
|
288
|
+
**Problem:** Mutating `appends` array with `.reverse()`.
|
|
289
|
+
|
|
290
|
+
**Fix:** Create copy before reversing: `[...appends].reverse()`.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
### 18. **Type Assertion Hack in Loader** ✅
|
|
295
|
+
**File:** `src/loader.ts`
|
|
296
|
+
|
|
297
|
+
**Problem:** Double cast `as unknown as T` circumventing type system.
|
|
298
|
+
|
|
299
|
+
**Fix:** Removed unnecessary cast - `Section.add()` correctly accepts `Section<T>`.
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
### 19. **Ignore Pattern Only Tests Filename** ✅
|
|
304
|
+
**File:** `src/loader.ts`
|
|
305
|
+
|
|
306
|
+
**Problem:** Regex patterns only tested against filename, not full path.
|
|
307
|
+
|
|
308
|
+
**Fix:** Test against both filename and full path for flexibility.
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## New Features Added
|
|
313
|
+
|
|
314
|
+
### Model Configuration System
|
|
315
|
+
|
|
316
|
+
Created a comprehensive, user-configurable model system:
|
|
317
|
+
|
|
318
|
+
**File:** `src/model-config.ts`
|
|
319
|
+
|
|
320
|
+
**Exports:**
|
|
321
|
+
- `ModelRegistry` - Main registry class
|
|
322
|
+
- `getModelRegistry()` - Get global instance
|
|
323
|
+
- `configureModel()` - Register custom models
|
|
324
|
+
- `getPersonaRole()` - Get role for model
|
|
325
|
+
- `getEncoding()` - Get tokenizer encoding
|
|
326
|
+
- `supportsToolCalls()` - Check tool support
|
|
327
|
+
- `getModelFamily()` - Get model family
|
|
328
|
+
|
|
329
|
+
**Default Configurations:**
|
|
330
|
+
- GPT-4 family (uses 'system' role)
|
|
331
|
+
- O-series models (uses 'developer' role)
|
|
332
|
+
- Claude family (uses 'system' role)
|
|
333
|
+
- Default fallback for unknown models
|
|
334
|
+
|
|
335
|
+
**Benefits:**
|
|
336
|
+
- No more hardcoded model names
|
|
337
|
+
- Easy to add new models without code changes
|
|
338
|
+
- Pattern-based matching (e.g., `/^o\d+/` matches o1, o2, o3, etc.)
|
|
339
|
+
- User-extensible at runtime
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## Testing Recommendations
|
|
344
|
+
|
|
345
|
+
1. **Memory Leak Test:** Run long conversation with many compressions, monitor memory
|
|
346
|
+
2. **Context Injection Test:** Inject multiple items, verify position tracking
|
|
347
|
+
3. **Clone Test:** Clone conversation, modify tool_calls, verify no cross-contamination
|
|
348
|
+
4. **Invalid JSON Test:** Send malformed tool arguments, verify graceful error handling
|
|
349
|
+
5. **Circuit Breaker Test:** Configure tool to fail repeatedly, verify circuit breaker triggers
|
|
350
|
+
6. **Model Registry Test:** Register custom model, verify correct role/encoding selection
|
|
351
|
+
7. **JSONL Race Test:** Add many messages rapidly, verify file integrity
|
|
352
|
+
8. **Performance Test:** Compress large conversations (1000+ messages), verify Set optimization
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## Breaking Changes
|
|
357
|
+
|
|
358
|
+
⚠️ **Minor Breaking Change in Recipe API:**
|
|
359
|
+
|
|
360
|
+
```typescript
|
|
361
|
+
// OLD
|
|
362
|
+
builder.executeWith(llm, strategy, tokenBudget)
|
|
363
|
+
|
|
364
|
+
// NEW
|
|
365
|
+
builder.executeWith(llm, strategy, model, tokenBudget)
|
|
366
|
+
// OR use default
|
|
367
|
+
builder.executeWith(llm, strategy) // defaults to 'gpt-4o'
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## Migration Guide
|
|
373
|
+
|
|
374
|
+
### For Custom Model Support
|
|
375
|
+
|
|
376
|
+
**Before:** Had to modify source code to add new models
|
|
377
|
+
|
|
378
|
+
**After:** Configure at runtime:
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
import { configureModel } from 'riotprompt';
|
|
382
|
+
|
|
383
|
+
// Add new model family
|
|
384
|
+
configureModel({
|
|
385
|
+
pattern: /^my-model/i,
|
|
386
|
+
personaRole: 'system',
|
|
387
|
+
encoding: 'gpt-4o',
|
|
388
|
+
supportsToolCalls: true,
|
|
389
|
+
family: 'my-family'
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
// Add specific override
|
|
393
|
+
configureModel({
|
|
394
|
+
exactMatch: 'my-model-v2-special',
|
|
395
|
+
personaRole: 'developer',
|
|
396
|
+
encoding: 'cl100k_base'
|
|
397
|
+
});
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## Files Modified
|
|
403
|
+
|
|
404
|
+
1. `src/model-config.ts` (NEW)
|
|
405
|
+
2. `src/chat.ts`
|
|
406
|
+
3. `src/conversation.ts`
|
|
407
|
+
4. `src/token-budget.ts`
|
|
408
|
+
5. `src/iteration-strategy.ts`
|
|
409
|
+
6. `src/recipes.ts`
|
|
410
|
+
7. `src/conversation-logger.ts`
|
|
411
|
+
8. `src/context-manager.ts`
|
|
412
|
+
9. `src/items/section.ts`
|
|
413
|
+
10. `src/parser.ts`
|
|
414
|
+
11. `src/loader.ts`
|
|
415
|
+
12. `src/override.ts`
|
|
416
|
+
13. `src/message-builder.ts`
|
|
417
|
+
14. `src/riotprompt.ts`
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
## Next Steps
|
|
422
|
+
|
|
423
|
+
1. ✅ All critical issues fixed
|
|
424
|
+
2. ✅ All high priority issues fixed
|
|
425
|
+
3. ✅ All medium priority issues fixed
|
|
426
|
+
4. ✅ No linting errors
|
|
427
|
+
5. ⏭️ Run test suite to verify fixes
|
|
428
|
+
6. ⏭️ Update documentation for model configuration system
|
|
429
|
+
7. ⏭️ Consider adding unit tests for circuit breaker
|
|
430
|
+
8. ⏭️ Performance test compression optimization
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
**Review completed:** December 27, 2025
|
|
435
|
+
**Total fixes applied:** 19
|
|
436
|
+
**Status:** ✅ All issues resolved
|
|
437
|
+
|
package/README.md
CHANGED
|
@@ -75,11 +75,11 @@ RiotPrompt is designed to be completely generic and unopinionated. Unlike other
|
|
|
75
75
|
|
|
76
76
|
## 🤝 Contributing
|
|
77
77
|
|
|
78
|
-
Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
78
|
+
Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
79
79
|
|
|
80
80
|
## 📄 License
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
Apache-2.0 License - see [LICENSE](LICENSE) for details.
|
|
83
83
|
|
|
84
84
|
---
|
|
85
85
|
|
package/dist/builder.js
CHANGED
|
@@ -10,6 +10,9 @@ import { create as create$1 } from './parser.js';
|
|
|
10
10
|
import { create as create$3 } from './loader.js';
|
|
11
11
|
import { create as create$2 } from './override.js';
|
|
12
12
|
import './recipes.js';
|
|
13
|
+
import './conversation.js';
|
|
14
|
+
import 'tiktoken';
|
|
15
|
+
import './tools.js';
|
|
13
16
|
|
|
14
17
|
const OptionSchema = z.object({
|
|
15
18
|
logger: z.any().optional().default(DEFAULT_LOGGER),
|
package/dist/builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sources":["../src/builder.ts"],"sourcesContent":["import path from \"path\";\nimport { z } from \"zod\";\nimport { ParametersSchema } from \"./items/parameters\";\nimport { SectionOptions, SectionOptionsSchema } from \"./items/section\";\nimport { DEFAULT_LOGGER, wrapLogger } from \"./logger\";\nimport { Content, Context, createPrompt, createSection, Instruction, Loader, Override, Parser, Prompt, Section, Weighted } from \"./riotprompt\";\n\nconst OptionSchema = z.object({\n logger: z.any().optional().default(DEFAULT_LOGGER),\n basePath: z.string(),\n overridePaths: z.array(z.string()).optional().default([\"./\"]),\n overrides: z.boolean().optional().default(false),\n parameters: ParametersSchema.optional().default({}),\n});\n\nexport type Options = z.infer<typeof OptionSchema>;\n\nexport type OptionsParam = Required<Pick<Options, 'basePath'>> & Partial<Omit<Options, 'basePath'>>;\n\nexport interface Instance {\n addPersonaPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContextPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addInstructionPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContentPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContent(content: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContext(context: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n loadContext(contextDirectories: string[], sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n loadContent(contentDirectories: string[], sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n build(): Promise<Prompt>;\n}\n\nexport const create = (builderOptions: OptionsParam): Instance => {\n const options: Required<Options> = OptionSchema.parse(builderOptions) as Required<Options>;\n\n const logger = wrapLogger(options.logger, 'Builder');\n const parser = Parser.create({ logger });\n const override = Override.create({\n logger, configDirs: options.overridePaths || [\"./\"],\n overrides: options.overrides || false\n });\n const loader = Loader.create({ logger });\n\n const personaSection: Section<Instruction> = createSection({ title: \"Persona\" });\n const contextSection: Section<Context> = createSection({ title: \"Context\" });\n const instructionSection: Section<Instruction> = createSection({ title: \"Instruction\" });\n const contentSection: Section<Content> = createSection({ title: \"Content\" });\n const parameters = options.parameters;\n\n\n const instance: Partial<Instance> = {}\n\n const loadOptions = (sectionOptions: Partial<SectionOptions> = {}): SectionOptions => {\n const currentOptions = SectionOptionsSchema.parse(sectionOptions);\n return {\n ...currentOptions,\n parameters: {\n ...parameters,\n ...currentOptions.parameters\n }\n }\n }\n\n const loadDirectories = async <T extends Weighted>(\n directories: string[],\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Section<T>[]> => {\n const currentOptions = loadOptions(sectionOptions);\n logger.debug(\"Loading directories\", directories);\n const sections: Section<T>[] = await loader.load<T>(directories, currentOptions);\n return sections;\n }\n\n const loadContext = async (\n contextDirectories: string[],\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n const currentOptions = loadOptions(sectionOptions);\n logger.debug('Loading context', contextDirectories);\n const context: Section<Context>[] = await loadDirectories<Context>(contextDirectories, currentOptions);\n contextSection.add(context);\n return instance as Instance;\n }\n instance.loadContext = loadContext;\n\n const loadContent = async (\n contentDirectories: string[],\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n const currentOptions = loadOptions(sectionOptions);\n const content: Section<Content>[] = await loadDirectories<Content>(contentDirectories, currentOptions);\n contentSection.add(content);\n return instance as Instance;\n }\n instance.loadContent = loadContent;\n\n const loadPath = async <T extends Weighted>(\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Section<T>> => {\n const currentOptions = loadOptions(sectionOptions);\n const defaultPath = path.join(options.basePath as string, contentPath);\n const section: Section<T> = await parser.parseFile<T>(defaultPath, currentOptions);\n const overrideSection = await override.customize<T>(contentPath, section, currentOptions);\n return overrideSection;\n }\n\n const addPersonaPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n const currentOptions = loadOptions(sectionOptions);\n const persona: Section<Instruction> = await loadPath<Instruction>(contentPath, currentOptions);\n personaSection.add(persona);\n return instance as Instance;\n }\n instance.addPersonaPath = addPersonaPath;\n\n const addContextPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding context path\", contentPath);\n const currentOptions = loadOptions(sectionOptions);\n const context: Section<Context> = await loadPath<Context>(contentPath, currentOptions);\n contextSection.add(context);\n return instance as Instance;\n }\n instance.addContextPath = addContextPath;\n\n const addInstructionPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding instruction path\", contentPath);\n const currentOptions = loadOptions(sectionOptions);\n const instruction: Section<Instruction> = await loadPath<Instruction>(contentPath, currentOptions);\n instructionSection.add(instruction);\n return instance as Instance;\n }\n instance.addInstructionPath = addInstructionPath;\n\n const addContentPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding content path\", contentPath);\n const currentOptions = loadOptions(sectionOptions);\n const content: Section<Content> = await loadPath<Content>(contentPath, currentOptions);\n contentSection.add(content);\n return instance as Instance;\n }\n instance.addContentPath = addContentPath;\n\n const addContent = async (\n content: string | Buffer,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding content\", typeof content);\n const currentOptions = loadOptions(sectionOptions);\n const parsedContentSection: Section<Content> = await parser.parse<Content>(content, currentOptions);\n contentSection.add(parsedContentSection);\n return instance as Instance;\n }\n instance.addContent = addContent;\n\n const addContext = async (\n context: string | Buffer,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding context\", typeof context);\n const currentOptions = loadOptions(sectionOptions);\n const parsedContextSection: Section<Context> = await parser.parse<Context>(context, currentOptions);\n contextSection.add(parsedContextSection);\n return instance as Instance;\n }\n instance.addContext = addContext;\n\n const build = async () => {\n logger.debug(\"Building prompt\", {});\n const prompt = createPrompt({ persona: personaSection, contexts: contextSection, instructions: instructionSection, contents: contentSection });\n return prompt;\n }\n instance.build = build;\n\n return instance as Instance;\n}\n"],"names":["OptionSchema","z","object","logger","any","optional","default","DEFAULT_LOGGER","basePath","string","overridePaths","array","overrides","boolean","parameters","ParametersSchema","create","builderOptions","options","parse","wrapLogger","parser","Parser","override","Override","configDirs","loader","Loader","personaSection","createSection","title","contextSection","instructionSection","contentSection","instance","loadOptions","sectionOptions","currentOptions","SectionOptionsSchema","loadDirectories","directories","debug","sections","load","loadContext","contextDirectories","context","add","loadContent","contentDirectories","content","loadPath","contentPath","defaultPath","path","join","section","parseFile","overrideSection","customize","addPersonaPath","persona","addContextPath","addInstructionPath","instruction","addContentPath","addContent","parsedContentSection","addContext","parsedContextSection","build","prompt","createPrompt","contexts","instructions","contents"],"mappings":";;;;;;;;;;;;;AAOA,MAAMA,YAAAA,GAAeC,CAAAA,CAAEC,MAAM,CAAC;AAC1BC,IAAAA,MAAAA,EAAQF,EAAEG,GAAG,EAAA,CAAGC,QAAQ,EAAA,CAAGC,OAAO,CAACC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AA;AACX,IAAA,CAAA;AACArC,IAAAA,QAAAA,CAASoC,KAAK,GAAGA,KAAAA;IAEjB,OAAOpC,QAAAA;AACX;;;;"}
|
|
1
|
+
{"version":3,"file":"builder.js","sources":["../src/builder.ts"],"sourcesContent":["import path from \"path\";\nimport { z } from \"zod\";\nimport { ParametersSchema } from \"./items/parameters\";\nimport { SectionOptions, SectionOptionsSchema } from \"./items/section\";\nimport { DEFAULT_LOGGER, wrapLogger } from \"./logger\";\nimport { Content, Context, createPrompt, createSection, Instruction, Loader, Override, Parser, Prompt, Section, Weighted } from \"./riotprompt\";\n\nconst OptionSchema = z.object({\n logger: z.any().optional().default(DEFAULT_LOGGER),\n basePath: z.string(),\n overridePaths: z.array(z.string()).optional().default([\"./\"]),\n overrides: z.boolean().optional().default(false),\n parameters: ParametersSchema.optional().default({}),\n});\n\nexport type Options = z.infer<typeof OptionSchema>;\n\nexport type OptionsParam = Required<Pick<Options, 'basePath'>> & Partial<Omit<Options, 'basePath'>>;\n\nexport interface Instance {\n addPersonaPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContextPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addInstructionPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContentPath(contentPath: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContent(content: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n addContext(context: string, sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n loadContext(contextDirectories: string[], sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n loadContent(contentDirectories: string[], sectionOptions?: Partial<SectionOptions>): Promise<Instance>;\n build(): Promise<Prompt>;\n}\n\nexport const create = (builderOptions: OptionsParam): Instance => {\n const options: Required<Options> = OptionSchema.parse(builderOptions) as Required<Options>;\n\n const logger = wrapLogger(options.logger, 'Builder');\n const parser = Parser.create({ logger });\n const override = Override.create({\n logger, configDirs: options.overridePaths || [\"./\"],\n overrides: options.overrides || false\n });\n const loader = Loader.create({ logger });\n\n const personaSection: Section<Instruction> = createSection({ title: \"Persona\" });\n const contextSection: Section<Context> = createSection({ title: \"Context\" });\n const instructionSection: Section<Instruction> = createSection({ title: \"Instruction\" });\n const contentSection: Section<Content> = createSection({ title: \"Content\" });\n const parameters = options.parameters;\n\n\n const instance: Partial<Instance> = {}\n\n const loadOptions = (sectionOptions: Partial<SectionOptions> = {}): SectionOptions => {\n const currentOptions = SectionOptionsSchema.parse(sectionOptions);\n return {\n ...currentOptions,\n parameters: {\n ...parameters,\n ...currentOptions.parameters\n }\n }\n }\n\n const loadDirectories = async <T extends Weighted>(\n directories: string[],\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Section<T>[]> => {\n const currentOptions = loadOptions(sectionOptions);\n logger.debug(\"Loading directories\", directories);\n const sections: Section<T>[] = await loader.load<T>(directories, currentOptions);\n return sections;\n }\n\n const loadContext = async (\n contextDirectories: string[],\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n const currentOptions = loadOptions(sectionOptions);\n logger.debug('Loading context', contextDirectories);\n const context: Section<Context>[] = await loadDirectories<Context>(contextDirectories, currentOptions);\n contextSection.add(context);\n return instance as Instance;\n }\n instance.loadContext = loadContext;\n\n const loadContent = async (\n contentDirectories: string[],\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n const currentOptions = loadOptions(sectionOptions);\n const content: Section<Content>[] = await loadDirectories<Content>(contentDirectories, currentOptions);\n contentSection.add(content);\n return instance as Instance;\n }\n instance.loadContent = loadContent;\n\n const loadPath = async <T extends Weighted>(\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Section<T>> => {\n const currentOptions = loadOptions(sectionOptions);\n const defaultPath = path.join(options.basePath as string, contentPath);\n const section: Section<T> = await parser.parseFile<T>(defaultPath, currentOptions);\n const overrideSection = await override.customize<T>(contentPath, section, currentOptions);\n return overrideSection;\n }\n\n const addPersonaPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n const currentOptions = loadOptions(sectionOptions);\n const persona: Section<Instruction> = await loadPath<Instruction>(contentPath, currentOptions);\n personaSection.add(persona);\n return instance as Instance;\n }\n instance.addPersonaPath = addPersonaPath;\n\n const addContextPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding context path\", contentPath);\n const currentOptions = loadOptions(sectionOptions);\n const context: Section<Context> = await loadPath<Context>(contentPath, currentOptions);\n contextSection.add(context);\n return instance as Instance;\n }\n instance.addContextPath = addContextPath;\n\n const addInstructionPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding instruction path\", contentPath);\n const currentOptions = loadOptions(sectionOptions);\n const instruction: Section<Instruction> = await loadPath<Instruction>(contentPath, currentOptions);\n instructionSection.add(instruction);\n return instance as Instance;\n }\n instance.addInstructionPath = addInstructionPath;\n\n const addContentPath = async (\n contentPath: string,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding content path\", contentPath);\n const currentOptions = loadOptions(sectionOptions);\n const content: Section<Content> = await loadPath<Content>(contentPath, currentOptions);\n contentSection.add(content);\n return instance as Instance;\n }\n instance.addContentPath = addContentPath;\n\n const addContent = async (\n content: string | Buffer,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding content\", typeof content);\n const currentOptions = loadOptions(sectionOptions);\n const parsedContentSection: Section<Content> = await parser.parse<Content>(content, currentOptions);\n contentSection.add(parsedContentSection);\n return instance as Instance;\n }\n instance.addContent = addContent;\n\n const addContext = async (\n context: string | Buffer,\n sectionOptions: Partial<SectionOptions> = {}\n ): Promise<Instance> => {\n logger.debug(\"Adding context\", typeof context);\n const currentOptions = loadOptions(sectionOptions);\n const parsedContextSection: Section<Context> = await parser.parse<Context>(context, currentOptions);\n contextSection.add(parsedContextSection);\n return instance as Instance;\n }\n instance.addContext = addContext;\n\n const build = async () => {\n logger.debug(\"Building prompt\", {});\n const prompt = createPrompt({ persona: personaSection, contexts: contextSection, instructions: instructionSection, contents: contentSection });\n return prompt;\n }\n instance.build = build;\n\n return instance as Instance;\n}\n"],"names":["OptionSchema","z","object","logger","any","optional","default","DEFAULT_LOGGER","basePath","string","overridePaths","array","overrides","boolean","parameters","ParametersSchema","create","builderOptions","options","parse","wrapLogger","parser","Parser","override","Override","configDirs","loader","Loader","personaSection","createSection","title","contextSection","instructionSection","contentSection","instance","loadOptions","sectionOptions","currentOptions","SectionOptionsSchema","loadDirectories","directories","debug","sections","load","loadContext","contextDirectories","context","add","loadContent","contentDirectories","content","loadPath","contentPath","defaultPath","path","join","section","parseFile","overrideSection","customize","addPersonaPath","persona","addContextPath","addInstructionPath","instruction","addContentPath","addContent","parsedContentSection","addContext","parsedContextSection","build","prompt","createPrompt","contexts","instructions","contents"],"mappings":";;;;;;;;;;;;;;;;AAOA,MAAMA,YAAAA,GAAeC,CAAAA,CAAEC,MAAM,CAAC;AAC1BC,IAAAA,MAAAA,EAAQF,EAAEG,GAAG,EAAA,CAAGC,QAAQ,EAAA,CAAGC,OAAO,CAACC,cAAAA,CAAAA;AACnCC,IAAAA,QAAAA,EAAUP,EAAEQ,MAAM,EAAA;IAClBC,aAAAA,EAAeT,CAAAA,CAAEU,KAAK,CAACV,CAAAA,CAAEQ,MAAM,EAAA,CAAA,CAAIJ,QAAQ,EAAA,CAAGC,OAAO,CAAC;AAAC,QAAA;AAAK,KAAA,CAAA;AAC5DM,IAAAA,SAAAA,EAAWX,EAAEY,OAAO,EAAA,CAAGR,QAAQ,EAAA,CAAGC,OAAO,CAAC,KAAA,CAAA;AAC1CQ,IAAAA,UAAAA,EAAYC,gBAAAA,CAAiBV,QAAQ,EAAA,CAAGC,OAAO,CAAC,EAAC;AACrD,CAAA,CAAA;AAkBO,MAAMU,SAAS,CAACC,cAAA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gC,UAAU,GAAGA,UAAAA;AAEtB,IAAA,MAAME,UAAAA,GAAa,OACftB,OAAAA,EACAV,cAAAA,GAA0C,EAAE,GAAA;QAE5CjC,MAAAA,CAAOsC,KAAK,CAAC,gBAAA,EAAkB,OAAOK,OAAAA,CAAAA;AACtC,QAAA,MAAMT,iBAAiBF,WAAAA,CAAYC,cAAAA,CAAAA;AACnC,QAAA,MAAMiC,oBAAAA,GAAyC,MAAMhD,QAAAA,CAAOF,KAAK,CAAU2B,OAAAA,EAAST,cAAAA,CAAAA;AACpFN,QAAAA,cAAAA,CAAegB,GAAG,CAACsB,oBAAAA,CAAAA;QACnB,OAAOnC,QAAAA;AACX,IAAA,CAAA;AACAA,IAAAA,QAAAA,CAASkC,UAAU,GAAGA,UAAAA;AAEtB,IAAA,MAAME,KAAAA,GAAQ,UAAA;QACVnE,MAAAA,CAAOsC,KAAK,CAAC,iBAAA,EAAmB,EAAC,CAAA;AACjC,QAAA,MAAM8B,SAASC,QAAAA,CAAa;YAAEX,OAAAA,EAASjC,cAAAA;YAAgB6C,QAAAA,EAAU1C,cAAAA;YAAgB2C,YAAAA,EAAc1C,kBAAAA;YAAoB2C,QAAAA,EAAU1C;AAAe,SAAA,CAAA;QAC5I,OAAOsC,MAAAA;AACX,IAAA,CAAA;AACArC,IAAAA,QAAAA,CAASoC,KAAK,GAAGA,KAAAA;IAEjB,OAAOpC,QAAAA;AACX;;;;"}
|
package/dist/chat.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type Role = "user" | "assistant" | "system" | "developer";
|
|
2
|
-
export type Model =
|
|
2
|
+
export type Model = string;
|
|
3
3
|
export interface Message {
|
|
4
4
|
role: Role;
|
|
5
5
|
content: string | string[];
|
package/dist/chat.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getPersonaRole as getPersonaRole$1 } from './model-config.js';
|
|
2
2
|
|
|
3
3
|
const getPersonaRole = (model)=>{
|
|
4
|
-
|
|
5
|
-
return "system";
|
|
6
|
-
}
|
|
7
|
-
return DEFAULT_PERSONA_ROLE;
|
|
4
|
+
return getPersonaRole$1(model);
|
|
8
5
|
};
|
|
9
6
|
const createRequest = (model)=>{
|
|
10
7
|
const messages = [];
|
package/dist/chat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.js","sources":["../src/chat.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"chat.js","sources":["../src/chat.ts"],"sourcesContent":["import { getPersonaRole as getPersonaRoleFromRegistry } from \"./model-config\";\n\nexport type Role = \"user\" | \"assistant\" | \"system\" | \"developer\";\n\n// Model is now a flexible string type\nexport type Model = string;\n\nexport interface Message {\n role: Role;\n content: string | string[];\n name?: string;\n}\n\nexport interface Request {\n messages: Message[];\n model: Model;\n\n addMessage(message: Message): void;\n}\n\nexport const getPersonaRole = (model: Model): Role => {\n return getPersonaRoleFromRegistry(model);\n}\n\nexport const createRequest = (model: Model): Request => {\n const messages: Message[] = [];\n\n return {\n model,\n messages,\n addMessage: (message: Message) => {\n messages.push(message);\n }\n }\n}\n"],"names":["getPersonaRole","model","getPersonaRoleFromRegistry","createRequest","messages","addMessage","message","push"],"mappings":";;AAoBO,MAAMA,iBAAiB,CAACC,KAAAA,GAAAA;AAC3B,IAAA,OAAOC,gBAAAA,CAA2BD,KAAAA,CAAAA;AACtC;AAEO,MAAME,gBAAgB,CAACF,KAAAA,GAAAA;AAC1B,IAAA,MAAMG,WAAsB,EAAE;IAE9B,OAAO;AACHH,QAAAA,KAAAA;AACAG,QAAAA,QAAAA;AACAC,QAAAA,UAAAA,EAAY,CAACC,OAAAA,GAAAA;AACTF,YAAAA,QAAAA,CAASG,IAAI,CAACD,OAAAA,CAAAA;AAClB,QAAA;AACJ,KAAA;AACJ;;;;"}
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const DEFAULT_CHARACTER_ENCODING = "utf8";
|
|
2
2
|
const LIBRARY_NAME = "riotprompt";
|
|
3
|
-
const DEFAULT_PERSONA_ROLE = "developer";
|
|
4
3
|
const DEFAULT_IGNORE_PATTERNS = [
|
|
5
4
|
"^\\..*",
|
|
6
5
|
"\\.(jpg|jpeg|png|gif|bmp|svg|webp|ico)$",
|
|
@@ -19,5 +18,5 @@ const DEFAULT_FORMAT_OPTIONS = {
|
|
|
19
18
|
sectionDepth: 0
|
|
20
19
|
};
|
|
21
20
|
|
|
22
|
-
export { DEFAULT_CHARACTER_ENCODING, DEFAULT_FORMAT_OPTIONS, DEFAULT_IGNORE_PATTERNS,
|
|
21
|
+
export { DEFAULT_CHARACTER_ENCODING, DEFAULT_FORMAT_OPTIONS, DEFAULT_IGNORE_PATTERNS, DEFAULT_SECTION_INDENTATION, DEFAULT_SECTION_SEPARATOR, DEFAULT_SECTION_TITLE_PROPERTY, LIBRARY_NAME };
|
|
23
22
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["import { SectionSeparator } from \"formatter\";\n\nimport { FormatOptions } from \"formatter\";\n\nexport const DEFAULT_CHARACTER_ENCODING = \"utf8\";\nexport const LIBRARY_NAME = \"riotprompt\";\n\nexport const DEFAULT_PERSONA_ROLE = \"developer\";\n\nexport const DEFAULT_INSTRUCTIONS_AREA_TITLE = \"Instructions\";\nexport const DEFAULT_CONTENTS_AREA_TITLE = \"Contents\";\nexport const DEFAULT_CONTEXT_AREA_TITLE = \"Context\";\n\nexport const DEFAULT_IGNORE_PATTERNS: string[] = [\n \"^\\\\..*\", // Hidden files (e.g., .git, .DS_Store)\n \"\\\\.(jpg|jpeg|png|gif|bmp|svg|webp|ico)$\", // Image files\n \"\\\\.(mp3|wav|ogg|aac|flac)$\", // Audio files\n \"\\\\.(mp4|mov|avi|mkv|webm)$\", // Video files\n \"\\\\.(pdf|doc|docx|xls|xlsx|ppt|pptx)$\", // Document files\n \"\\\\.(zip|tar|gz|rar|7z)$\" // Compressed files\n];\n\nexport const DEFAULT_SECTION_SEPARATOR: SectionSeparator = \"tag\";\nexport const DEFAULT_SECTION_INDENTATION = true;\nexport const DEFAULT_SECTION_TAG = \"section\";\nexport const DEFAULT_SECTION_TITLE_PROPERTY = \"title\";\n\nexport const DEFAULT_FORMAT_OPTIONS: FormatOptions = {\n sectionSeparator: DEFAULT_SECTION_SEPARATOR,\n sectionIndentation: DEFAULT_SECTION_INDENTATION,\n sectionTitleProperty: DEFAULT_SECTION_TITLE_PROPERTY,\n sectionDepth: 0,\n}\n"],"names":["DEFAULT_CHARACTER_ENCODING","LIBRARY_NAME","
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["import { SectionSeparator } from \"formatter\";\n\nimport { FormatOptions } from \"formatter\";\n\nexport const DEFAULT_CHARACTER_ENCODING = \"utf8\";\nexport const LIBRARY_NAME = \"riotprompt\";\n\nexport const DEFAULT_PERSONA_ROLE = \"developer\";\n\nexport const DEFAULT_INSTRUCTIONS_AREA_TITLE = \"Instructions\";\nexport const DEFAULT_CONTENTS_AREA_TITLE = \"Contents\";\nexport const DEFAULT_CONTEXT_AREA_TITLE = \"Context\";\n\nexport const DEFAULT_IGNORE_PATTERNS: string[] = [\n \"^\\\\..*\", // Hidden files (e.g., .git, .DS_Store)\n \"\\\\.(jpg|jpeg|png|gif|bmp|svg|webp|ico)$\", // Image files\n \"\\\\.(mp3|wav|ogg|aac|flac)$\", // Audio files\n \"\\\\.(mp4|mov|avi|mkv|webm)$\", // Video files\n \"\\\\.(pdf|doc|docx|xls|xlsx|ppt|pptx)$\", // Document files\n \"\\\\.(zip|tar|gz|rar|7z)$\" // Compressed files\n];\n\nexport const DEFAULT_SECTION_SEPARATOR: SectionSeparator = \"tag\";\nexport const DEFAULT_SECTION_INDENTATION = true;\nexport const DEFAULT_SECTION_TAG = \"section\";\nexport const DEFAULT_SECTION_TITLE_PROPERTY = \"title\";\n\nexport const DEFAULT_FORMAT_OPTIONS: FormatOptions = {\n sectionSeparator: DEFAULT_SECTION_SEPARATOR,\n sectionIndentation: DEFAULT_SECTION_INDENTATION,\n sectionTitleProperty: DEFAULT_SECTION_TITLE_PROPERTY,\n sectionDepth: 0,\n}\n"],"names":["DEFAULT_CHARACTER_ENCODING","LIBRARY_NAME","DEFAULT_IGNORE_PATTERNS","DEFAULT_SECTION_SEPARATOR","DEFAULT_SECTION_INDENTATION","DEFAULT_SECTION_TITLE_PROPERTY","DEFAULT_FORMAT_OPTIONS","sectionSeparator","sectionIndentation","sectionTitleProperty","sectionDepth"],"mappings":"AAIO,MAAMA,6BAA6B;AACnC,MAAMC,eAAe;MAQfC,uBAAAA,GAAoC;AAC7C,IAAA,QAAA;AACA,IAAA,yCAAA;AACA,IAAA,4BAAA;AACA,IAAA,4BAAA;AACA,IAAA,sCAAA;AACA,IAAA,yBAAA;;AAGG,MAAMC,4BAA8C;AACpD,MAAMC,8BAA8B;AAEpC,MAAMC,iCAAiC;MAEjCC,sBAAAA,GAAwC;IACjDC,gBAAAA,EAAkBJ,yBAAAA;IAClBK,kBAAAA,EAAoBJ,2BAAAA;IACpBK,oBAAAA,EAAsBJ,8BAAAA;IACtBK,YAAAA,EAAc;AAClB;;;;"}
|