@ghostpaw/grimoire 0.2.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.
@@ -0,0 +1,1775 @@
1
+ interface GrimoireRunResult {
2
+ lastInsertRowid: number | bigint;
3
+ changes?: number | bigint | undefined;
4
+ }
5
+ interface GrimoireStatement {
6
+ run(...params: unknown[]): GrimoireRunResult;
7
+ get<TRecord extends Record<string, unknown>>(...params: unknown[]): TRecord | undefined;
8
+ all<TRecord extends Record<string, unknown>>(...params: unknown[]): TRecord[];
9
+ }
10
+ /**
11
+ * SQLite dependency injected into every grimoire operation.
12
+ */
13
+ type GrimoireDb = {
14
+ exec(sql: string): void;
15
+ prepare(sql: string): GrimoireStatement;
16
+ close(): void;
17
+ };
18
+
19
+ type CatalogueSnapshotRow = {
20
+ id: number;
21
+ computed_at: string;
22
+ total_spells: number;
23
+ chapter_distribution: string;
24
+ rank_distribution: string;
25
+ stale_spells: string;
26
+ dormant_spells: string;
27
+ oversized_spells: string;
28
+ pending_notes: number;
29
+ notes_routed: number;
30
+ orphan_clusters: string;
31
+ drafts_queued: number;
32
+ chapter_balance: string;
33
+ spell_health: string;
34
+ seal_velocity: string;
35
+ };
36
+ interface OrphanCluster {
37
+ noteIds: number[];
38
+ memberCount: number;
39
+ sourceCount: number;
40
+ suggestedTerms: string[];
41
+ }
42
+ interface CatalogueSnapshot {
43
+ id: number;
44
+ computedAt: string;
45
+ totalSpells: number;
46
+ chapterDistribution: Record<string, number>;
47
+ rankDistribution: Record<string, number>;
48
+ staleSpells: string[];
49
+ dormantSpells: string[];
50
+ oversizedSpells: string[];
51
+ pendingNotes: number;
52
+ notesRouted: number;
53
+ orphanClusters: OrphanCluster[];
54
+ draftsQueued: number;
55
+ chapterBalance: Record<string, number>;
56
+ spellHealth: Record<string, number>;
57
+ sealVelocity: Record<string, number>;
58
+ }
59
+ type SaveCatalogueInput = {
60
+ computedAt: string;
61
+ totalSpells: number;
62
+ chapterDistribution: Record<string, number>;
63
+ rankDistribution: Record<string, number>;
64
+ staleSpells: string[];
65
+ dormantSpells: string[];
66
+ oversizedSpells: string[];
67
+ pendingNotes: number;
68
+ notesRouted: number;
69
+ orphanClusters: OrphanCluster[];
70
+ draftsQueued: number;
71
+ chapterBalance: Record<string, number>;
72
+ spellHealth: Record<string, number>;
73
+ sealVelocity: Record<string, number>;
74
+ };
75
+
76
+ type CatalogueOptions = {
77
+ staleDays?: number;
78
+ dormantDays?: number;
79
+ oversizeLines?: number;
80
+ routingThreshold?: number;
81
+ clusteringThreshold?: number;
82
+ resonanceHalfLife?: number;
83
+ now?: number;
84
+ };
85
+ type SpellHealth = {
86
+ path: string;
87
+ staleness: number;
88
+ oversizeRatio: number;
89
+ resonanceWeight: number;
90
+ health: number;
91
+ sealVelocity: number;
92
+ isStale: boolean;
93
+ isDormant: boolean;
94
+ isOversized: boolean;
95
+ };
96
+ type ChapterBalance = {
97
+ chapter: string;
98
+ spellCount: number;
99
+ pendingNotes: number;
100
+ noteLoadRatio: number;
101
+ };
102
+
103
+ declare function catalogue(root: string, db: GrimoireDb, options?: CatalogueOptions): CatalogueSnapshot;
104
+
105
+ declare function clusterOrphans(db: GrimoireDb, threshold?: number): OrphanCluster[];
106
+
107
+ declare function computeChapterBalance(spellsByChapter: Map<string, number>, notesByChapter: Map<string, number>): ChapterBalance[];
108
+
109
+ declare function computeSealVelocity(sealTimestamps: number[], now: number): number;
110
+
111
+ declare function computeSpellHealth(staleness: number, oversizeRatio: number, resonanceWeight: number): number;
112
+
113
+ declare function computeStaleness(lastSealTs: number, lastReadTs: number | null, now: number, staleDays: number, dormantDays: number): {
114
+ isStale: boolean;
115
+ isDormant: boolean;
116
+ staleness: number;
117
+ };
118
+
119
+ declare function routeNotes(db: GrimoireDb, spellDescriptions: Map<string, string>, threshold?: number): number;
120
+
121
+ type index$e_CatalogueOptions = CatalogueOptions;
122
+ type index$e_ChapterBalance = ChapterBalance;
123
+ type index$e_OrphanCluster = OrphanCluster;
124
+ type index$e_SpellHealth = SpellHealth;
125
+ declare const index$e_catalogue: typeof catalogue;
126
+ declare const index$e_clusterOrphans: typeof clusterOrphans;
127
+ declare const index$e_computeChapterBalance: typeof computeChapterBalance;
128
+ declare const index$e_computeSealVelocity: typeof computeSealVelocity;
129
+ declare const index$e_computeSpellHealth: typeof computeSpellHealth;
130
+ declare const index$e_computeStaleness: typeof computeStaleness;
131
+ declare const index$e_routeNotes: typeof routeNotes;
132
+ declare namespace index$e {
133
+ export { type index$e_CatalogueOptions as CatalogueOptions, type index$e_ChapterBalance as ChapterBalance, type index$e_OrphanCluster as OrphanCluster, type index$e_SpellHealth as SpellHealth, index$e_catalogue as catalogue, index$e_clusterOrphans as clusterOrphans, index$e_computeChapterBalance as computeChapterBalance, index$e_computeSealVelocity as computeSealVelocity, index$e_computeSpellHealth as computeSpellHealth, index$e_computeStaleness as computeStaleness, index$e_routeNotes as routeNotes };
134
+ }
135
+
136
+ declare const DEFAULTS: {
137
+ readonly defaultChapter: "general";
138
+ readonly noteCap: 50;
139
+ readonly noteExpiryDays: 90;
140
+ readonly staleDays: 90;
141
+ readonly dormantDays: 60;
142
+ readonly oversizeLines: 500;
143
+ readonly resonanceHalfLife: 30;
144
+ readonly routingThreshold: 0.3;
145
+ readonly clusteringThreshold: 0.4;
146
+ };
147
+
148
+ declare function approveDraft(db: GrimoireDb, draftId: number): void;
149
+
150
+ declare function dismissDraft(db: GrimoireDb, draftId: number): void;
151
+
152
+ declare function initDraftTables(db: GrimoireDb): void;
153
+
154
+ type DraftStatus = 'pending' | 'approved' | 'dismissed';
155
+ type SpellDraftRow = {
156
+ id: number;
157
+ title: string;
158
+ rationale: string;
159
+ note_ids: string;
160
+ chapter: string;
161
+ status: string;
162
+ created_at: number;
163
+ };
164
+ interface SpellDraft {
165
+ id: number;
166
+ title: string;
167
+ rationale: string;
168
+ noteIds: number[];
169
+ chapter: string;
170
+ status: DraftStatus;
171
+ createdAt: number;
172
+ }
173
+ interface SubmitDraftInput {
174
+ title: string;
175
+ rationale: string;
176
+ noteIds: number[];
177
+ chapter: string;
178
+ now?: number;
179
+ }
180
+
181
+ declare function mapDraftRow(row: SpellDraftRow): SpellDraft;
182
+
183
+ declare function pendingDrafts(db: GrimoireDb): SpellDraft[];
184
+
185
+ declare function submitDraft(db: GrimoireDb, input: SubmitDraftInput): {
186
+ id: number;
187
+ };
188
+
189
+ type index$d_DraftStatus = DraftStatus;
190
+ type index$d_SpellDraft = SpellDraft;
191
+ type index$d_SpellDraftRow = SpellDraftRow;
192
+ type index$d_SubmitDraftInput = SubmitDraftInput;
193
+ declare const index$d_approveDraft: typeof approveDraft;
194
+ declare const index$d_dismissDraft: typeof dismissDraft;
195
+ declare const index$d_initDraftTables: typeof initDraftTables;
196
+ declare const index$d_mapDraftRow: typeof mapDraftRow;
197
+ declare const index$d_pendingDrafts: typeof pendingDrafts;
198
+ declare const index$d_submitDraft: typeof submitDraft;
199
+ declare namespace index$d {
200
+ export { type index$d_DraftStatus as DraftStatus, type index$d_SpellDraft as SpellDraft, type index$d_SpellDraftRow as SpellDraftRow, type index$d_SubmitDraftInput as SubmitDraftInput, index$d_approveDraft as approveDraft, index$d_dismissDraft as dismissDraft, index$d_initDraftTables as initDraftTables, index$d_mapDraftRow as mapDraftRow, index$d_pendingDrafts as pendingDrafts, index$d_submitDraft as submitDraft };
201
+ }
202
+
203
+ type GrimoireErrorCode = 'GRIMOIRE_NOT_FOUND' | 'GRIMOIRE_VALIDATION' | 'GRIMOIRE_STATE' | 'GRIMOIRE_INVARIANT';
204
+ declare class GrimoireError extends Error {
205
+ readonly name: string;
206
+ readonly code: GrimoireErrorCode;
207
+ constructor(code: GrimoireErrorCode, message: string);
208
+ }
209
+ declare class GrimoireNotFoundError extends GrimoireError {
210
+ readonly name = "GrimoireNotFoundError";
211
+ constructor(message: string);
212
+ }
213
+ declare class GrimoireValidationError extends GrimoireError {
214
+ readonly name = "GrimoireValidationError";
215
+ constructor(message: string);
216
+ }
217
+ declare class GrimoireStateError extends GrimoireError {
218
+ readonly name = "GrimoireStateError";
219
+ constructor(message: string);
220
+ }
221
+ declare class GrimoireInvariantError extends GrimoireError {
222
+ readonly name = "GrimoireInvariantError";
223
+ constructor(message: string);
224
+ }
225
+ declare function isGrimoireError(value: unknown): value is GrimoireError;
226
+
227
+ type SpellEventType = 'read' | 'seal' | 'inscribe' | 'shelve' | 'unshelve' | 'move' | 'hone' | 'adopt';
228
+ type SpellEventRow = {
229
+ id: number;
230
+ spell: string;
231
+ event: string;
232
+ context_id: string | null;
233
+ ts: number;
234
+ };
235
+ interface SpellEvent {
236
+ id: number;
237
+ spell: string;
238
+ event: SpellEventType;
239
+ contextId: string | null;
240
+ ts: number;
241
+ }
242
+ interface LogEventInput {
243
+ spell: string;
244
+ event: SpellEventType;
245
+ contextId?: string;
246
+ now?: number;
247
+ }
248
+ type ResonanceColor = 'grey' | 'green' | 'yellow' | 'orange';
249
+ type ResonanceResult = {
250
+ color: ResonanceColor;
251
+ weightedReads: number;
252
+ readCount: number;
253
+ lastSealTs: number | null;
254
+ };
255
+ type ResonanceOptions = {
256
+ resonanceHalfLife?: number;
257
+ now?: number;
258
+ };
259
+
260
+ declare function allResonance(db: GrimoireDb, options?: ResonanceOptions): Record<string, ResonanceResult>;
261
+
262
+ declare function eventsSince(db: GrimoireDb, since: number): SpellEvent[];
263
+
264
+ declare function initEventTables(db: GrimoireDb): void;
265
+
266
+ declare function logEvent(db: GrimoireDb, input: LogEventInput): {
267
+ id: number;
268
+ };
269
+
270
+ declare function mapEventRow(row: SpellEventRow): SpellEvent;
271
+
272
+ declare function resonance(db: GrimoireDb, path: string, options?: ResonanceOptions): ResonanceResult;
273
+
274
+ type index$c_LogEventInput = LogEventInput;
275
+ type index$c_ResonanceColor = ResonanceColor;
276
+ type index$c_ResonanceOptions = ResonanceOptions;
277
+ type index$c_ResonanceResult = ResonanceResult;
278
+ type index$c_SpellEvent = SpellEvent;
279
+ type index$c_SpellEventRow = SpellEventRow;
280
+ type index$c_SpellEventType = SpellEventType;
281
+ declare const index$c_allResonance: typeof allResonance;
282
+ declare const index$c_eventsSince: typeof eventsSince;
283
+ declare const index$c_initEventTables: typeof initEventTables;
284
+ declare const index$c_logEvent: typeof logEvent;
285
+ declare const index$c_mapEventRow: typeof mapEventRow;
286
+ declare const index$c_resonance: typeof resonance;
287
+ declare namespace index$c {
288
+ export { type index$c_LogEventInput as LogEventInput, type index$c_ResonanceColor as ResonanceColor, type index$c_ResonanceOptions as ResonanceOptions, type index$c_ResonanceResult as ResonanceResult, type index$c_SpellEvent as SpellEvent, type index$c_SpellEventRow as SpellEventRow, type index$c_SpellEventType as SpellEventType, index$c_allResonance as allResonance, index$c_eventsSince as eventsSince, index$c_initEventTables as initEventTables, index$c_logEvent as logEvent, index$c_mapEventRow as mapEventRow, index$c_resonance as resonance };
289
+ }
290
+
291
+ interface GitContext {
292
+ root: string;
293
+ gitDir?: string;
294
+ }
295
+
296
+ type Tier = 'Uncheckpointed' | 'Apprentice' | 'Journeyman' | 'Expert' | 'Master';
297
+ type TierInfo = {
298
+ tier: Tier;
299
+ rank: number;
300
+ sealsToNextTier: number;
301
+ };
302
+ type SealResult = {
303
+ commitHash: string;
304
+ sealedPaths: string[];
305
+ ranks: Record<string, number>;
306
+ };
307
+ type RollbackResult = {
308
+ success: boolean;
309
+ restoredRef?: string;
310
+ };
311
+ type PendingChange = {
312
+ status: 'created' | 'modified' | 'deleted';
313
+ filePath: string;
314
+ };
315
+ type PendingChangesResult = {
316
+ spellPath: string;
317
+ changes: PendingChange[];
318
+ };
319
+ type HistoryEntry = {
320
+ hash: string;
321
+ message: string;
322
+ date: string;
323
+ files: string[];
324
+ };
325
+
326
+ declare function allRanks(ctx: GitContext): Record<string, number>;
327
+
328
+ declare function diff(ctx: GitContext, path: string): string;
329
+
330
+ declare function history(ctx: GitContext, path?: string): HistoryEntry[];
331
+
332
+ declare function isGitAvailable(): boolean;
333
+
334
+ declare function pendingChanges(ctx: GitContext, path?: string): PendingChangesResult[];
335
+
336
+ declare function rank(ctx: GitContext, path: string): number;
337
+
338
+ declare function rollback(ctx: GitContext, path: string, ref: string): RollbackResult;
339
+
340
+ declare function seal(ctx: GitContext, db?: GrimoireDb, paths?: string[], message?: string): SealResult;
341
+
342
+ declare function tier(rank: number): Tier;
343
+
344
+ declare function tierInfo(rank: number): TierInfo;
345
+
346
+ type index$b_GitContext = GitContext;
347
+ type index$b_HistoryEntry = HistoryEntry;
348
+ type index$b_PendingChange = PendingChange;
349
+ type index$b_PendingChangesResult = PendingChangesResult;
350
+ type index$b_RollbackResult = RollbackResult;
351
+ type index$b_SealResult = SealResult;
352
+ type index$b_Tier = Tier;
353
+ type index$b_TierInfo = TierInfo;
354
+ declare const index$b_allRanks: typeof allRanks;
355
+ declare const index$b_diff: typeof diff;
356
+ declare const index$b_history: typeof history;
357
+ declare const index$b_isGitAvailable: typeof isGitAvailable;
358
+ declare const index$b_pendingChanges: typeof pendingChanges;
359
+ declare const index$b_rank: typeof rank;
360
+ declare const index$b_rollback: typeof rollback;
361
+ declare const index$b_seal: typeof seal;
362
+ declare const index$b_tier: typeof tier;
363
+ declare const index$b_tierInfo: typeof tierInfo;
364
+ declare namespace index$b {
365
+ export { type index$b_GitContext as GitContext, type index$b_HistoryEntry as HistoryEntry, type index$b_PendingChange as PendingChange, type index$b_PendingChangesResult as PendingChangesResult, type index$b_RollbackResult as RollbackResult, type index$b_SealResult as SealResult, type index$b_Tier as Tier, type index$b_TierInfo as TierInfo, index$b_allRanks as allRanks, index$b_diff as diff, index$b_history as history, index$b_isGitAvailable as isGitAvailable, index$b_pendingChanges as pendingChanges, index$b_rank as rank, index$b_rollback as rollback, index$b_seal as seal, index$b_tier as tier, index$b_tierInfo as tierInfo };
366
+ }
367
+
368
+ declare function initHealthTables(db: GrimoireDb): void;
369
+
370
+ declare function mapHealthRow(row: CatalogueSnapshotRow): CatalogueSnapshot;
371
+
372
+ declare function readCatalogue(db: GrimoireDb): CatalogueSnapshot | undefined;
373
+
374
+ declare function saveCatalogue(db: GrimoireDb, input: SaveCatalogueInput): {
375
+ id: number;
376
+ };
377
+
378
+ type index$a_CatalogueSnapshot = CatalogueSnapshot;
379
+ type index$a_CatalogueSnapshotRow = CatalogueSnapshotRow;
380
+ type index$a_OrphanCluster = OrphanCluster;
381
+ type index$a_SaveCatalogueInput = SaveCatalogueInput;
382
+ declare const index$a_initHealthTables: typeof initHealthTables;
383
+ declare const index$a_mapHealthRow: typeof mapHealthRow;
384
+ declare const index$a_readCatalogue: typeof readCatalogue;
385
+ declare const index$a_saveCatalogue: typeof saveCatalogue;
386
+ declare namespace index$a {
387
+ export { type index$a_CatalogueSnapshot as CatalogueSnapshot, type index$a_CatalogueSnapshotRow as CatalogueSnapshotRow, type index$a_OrphanCluster as OrphanCluster, type index$a_SaveCatalogueInput as SaveCatalogueInput, index$a_initHealthTables as initHealthTables, index$a_mapHealthRow as mapHealthRow, index$a_readCatalogue as readCatalogue, index$a_saveCatalogue as saveCatalogue };
388
+ }
389
+
390
+ type IndexEntry = {
391
+ path: string;
392
+ chapter: string;
393
+ name: string;
394
+ tier: Tier;
395
+ rank: number;
396
+ description: string;
397
+ };
398
+ type IndexOptions = {
399
+ chapters?: string[];
400
+ };
401
+
402
+ declare function buildIndex(root: string, options?: IndexOptions): IndexEntry[];
403
+
404
+ declare function formatIndex(entries: IndexEntry[]): string;
405
+
406
+ type index$9_IndexEntry = IndexEntry;
407
+ type index$9_IndexOptions = IndexOptions;
408
+ declare const index$9_buildIndex: typeof buildIndex;
409
+ declare const index$9_formatIndex: typeof formatIndex;
410
+ declare namespace index$9 {
411
+ export { type index$9_IndexEntry as IndexEntry, type index$9_IndexOptions as IndexOptions, index$9_buildIndex as buildIndex, index$9_formatIndex as formatIndex };
412
+ }
413
+
414
+ declare function init(root: string, db?: GrimoireDb, options?: {
415
+ gitDir?: string;
416
+ }): void;
417
+
418
+ declare function initGrimoireTables(db: GrimoireDb): void;
419
+
420
+ type RegistrySource = 'agentskillhub' | 'github';
421
+ type RegistryEntryRow = {
422
+ id: number;
423
+ source: string;
424
+ slug: string;
425
+ name: string;
426
+ description: string | null;
427
+ adoption_count: number | null;
428
+ source_repo: string | null;
429
+ source_path: string | null;
430
+ fetch_url: string | null;
431
+ last_seen: string;
432
+ };
433
+ interface RegistryEntry {
434
+ id: number;
435
+ source: RegistrySource;
436
+ slug: string;
437
+ name: string;
438
+ description: string | null;
439
+ adoptionCount: number | null;
440
+ sourceRepo: string | null;
441
+ sourcePath: string | null;
442
+ fetchUrl: string | null;
443
+ lastSeen: string;
444
+ }
445
+ interface UpsertRegistryEntryInput {
446
+ source: RegistrySource;
447
+ slug: string;
448
+ name: string;
449
+ description?: string;
450
+ adoptionCount?: number;
451
+ sourceRepo?: string;
452
+ sourcePath?: string;
453
+ fetchUrl?: string;
454
+ }
455
+ type SearchResult = {
456
+ source: RegistrySource;
457
+ slug: string;
458
+ name: string;
459
+ description: string;
460
+ adoptionCount?: number;
461
+ sourceRepo: string;
462
+ sourcePath?: string;
463
+ fetchUrl: string;
464
+ };
465
+ type SearchSkillsOptions = {
466
+ sources?: Array<'agentskillhub' | 'github'>;
467
+ limit?: number;
468
+ };
469
+ type RepoAnalysis = {
470
+ repo: string;
471
+ branch: string;
472
+ skills: Array<{
473
+ name: string;
474
+ path: string;
475
+ description: string;
476
+ alreadyImported?: boolean;
477
+ }>;
478
+ };
479
+ type RefreshIndexOptions = {
480
+ searchTerms?: string[];
481
+ };
482
+
483
+ declare function analyzeRepo(url: string): Promise<RepoAnalysis>;
484
+
485
+ declare function initRegistryTables(db: GrimoireDb): void;
486
+
487
+ declare function mapRegistryRow(row: RegistryEntryRow): RegistryEntry;
488
+
489
+ declare function refreshIndex(db: GrimoireDb, options?: RefreshIndexOptions): Promise<{
490
+ added: number;
491
+ updated: number;
492
+ }>;
493
+
494
+ declare function searchIndex(db: GrimoireDb, query: string): RegistryEntry[];
495
+
496
+ declare function searchSkills(query: string, options?: SearchSkillsOptions): Promise<SearchResult[]>;
497
+
498
+ declare function upsertIndexEntry(db: GrimoireDb, input: UpsertRegistryEntryInput): {
499
+ id: number;
500
+ };
501
+
502
+ type index$8_RefreshIndexOptions = RefreshIndexOptions;
503
+ type index$8_RegistryEntry = RegistryEntry;
504
+ type index$8_RegistryEntryRow = RegistryEntryRow;
505
+ type index$8_RegistrySource = RegistrySource;
506
+ type index$8_RepoAnalysis = RepoAnalysis;
507
+ type index$8_SearchResult = SearchResult;
508
+ type index$8_SearchSkillsOptions = SearchSkillsOptions;
509
+ type index$8_UpsertRegistryEntryInput = UpsertRegistryEntryInput;
510
+ declare const index$8_analyzeRepo: typeof analyzeRepo;
511
+ declare const index$8_initRegistryTables: typeof initRegistryTables;
512
+ declare const index$8_mapRegistryRow: typeof mapRegistryRow;
513
+ declare const index$8_refreshIndex: typeof refreshIndex;
514
+ declare const index$8_searchIndex: typeof searchIndex;
515
+ declare const index$8_searchSkills: typeof searchSkills;
516
+ declare const index$8_upsertIndexEntry: typeof upsertIndexEntry;
517
+ declare namespace index$8 {
518
+ export { type index$8_RefreshIndexOptions as RefreshIndexOptions, type index$8_RegistryEntry as RegistryEntry, type index$8_RegistryEntryRow as RegistryEntryRow, type index$8_RegistrySource as RegistrySource, type index$8_RepoAnalysis as RepoAnalysis, type index$8_SearchResult as SearchResult, type index$8_SearchSkillsOptions as SearchSkillsOptions, type index$8_UpsertRegistryEntryInput as UpsertRegistryEntryInput, index$8_analyzeRepo as analyzeRepo, index$8_initRegistryTables as initRegistryTables, index$8_mapRegistryRow as mapRegistryRow, index$8_refreshIndex as refreshIndex, index$8_searchIndex as searchIndex, index$8_searchSkills as searchSkills, index$8_upsertIndexEntry as upsertIndexEntry };
519
+ }
520
+
521
+ type ProvenanceSourceType = 'agentskillhub' | 'github' | 'local';
522
+ type ProvenanceRow = {
523
+ spell_path: string;
524
+ source_type: string;
525
+ source_url: string | null;
526
+ source_repo: string | null;
527
+ source_path: string | null;
528
+ source_commit: string | null;
529
+ source_version: string | null;
530
+ imported_at: string;
531
+ updated_at: string | null;
532
+ };
533
+ interface Provenance {
534
+ spellPath: string;
535
+ sourceType: ProvenanceSourceType;
536
+ sourceUrl: string | null;
537
+ sourceRepo: string | null;
538
+ sourcePath: string | null;
539
+ sourceCommit: string | null;
540
+ sourceVersion: string | null;
541
+ importedAt: string;
542
+ updatedAt: string | null;
543
+ }
544
+ interface ProvenanceInput {
545
+ spellPath: string;
546
+ sourceType: ProvenanceSourceType;
547
+ sourceUrl?: string;
548
+ sourceRepo?: string;
549
+ sourcePath?: string;
550
+ sourceCommit?: string;
551
+ sourceVersion?: string;
552
+ }
553
+
554
+ type SkillMdFrontmatter = {
555
+ name: string;
556
+ description: string;
557
+ license?: string;
558
+ compatibility?: string;
559
+ allowedTools?: string;
560
+ disableModelInvocation?: boolean;
561
+ metadata?: Record<string, string>;
562
+ };
563
+ type SkillMdValidationResult = {
564
+ valid: boolean;
565
+ errors: string[];
566
+ warnings: string[];
567
+ };
568
+ type SkillMdParseResult = {
569
+ ok: true;
570
+ frontmatter: SkillMdFrontmatter;
571
+ body: string;
572
+ } | {
573
+ ok: false;
574
+ error: string;
575
+ };
576
+
577
+ type SpellFiles = {
578
+ scripts: string[];
579
+ references: string[];
580
+ assets: string[];
581
+ };
582
+ type Spell = {
583
+ name: string;
584
+ chapter: string;
585
+ path: string;
586
+ absolutePath: string;
587
+ skillMdPath: string;
588
+ description: string;
589
+ body: string;
590
+ bodyLines: number;
591
+ rank: number;
592
+ tier: Tier;
593
+ files: SpellFiles;
594
+ frontmatter: SkillMdFrontmatter;
595
+ };
596
+ type RenderedContent = {
597
+ body: string;
598
+ compiledSummary?: string;
599
+ allowedTools?: string;
600
+ tier: Tier;
601
+ rank: number;
602
+ };
603
+ type ListSpellsOptions = {
604
+ chapters?: string[];
605
+ };
606
+ type DuplicationWarning = {
607
+ existingPath: string;
608
+ similarity: number;
609
+ };
610
+ type RepairFix = {
611
+ code: string;
612
+ description: string;
613
+ };
614
+ type RepairResult = {
615
+ path: string;
616
+ fixes: RepairFix[];
617
+ };
618
+ type InscribeInput = {
619
+ name: string;
620
+ chapter?: string;
621
+ content: string;
622
+ now?: number;
623
+ };
624
+ type InscribeResult = {
625
+ spell: Spell;
626
+ warnings: DuplicationWarning[];
627
+ };
628
+
629
+ type ResolvedSource = {
630
+ type: 'github' | 'agentskillhub' | 'local' | 'git';
631
+ url?: string;
632
+ owner?: string;
633
+ repo?: string;
634
+ ref?: string;
635
+ subpath?: string;
636
+ slug?: string;
637
+ };
638
+ type DiscoveredSkill = {
639
+ name: string;
640
+ description: string;
641
+ localPath: string;
642
+ repoPath?: string;
643
+ valid: boolean;
644
+ errors: string[];
645
+ warnings: string[];
646
+ };
647
+ type FetchHandle = {
648
+ source: string;
649
+ resolvedRepo?: string;
650
+ resolvedCommit?: string;
651
+ skills: DiscoveredSkill[];
652
+ cleanup: () => void;
653
+ };
654
+ type AdoptSpellOptions = {
655
+ chapter?: string;
656
+ provenance?: ProvenanceInput;
657
+ now?: number;
658
+ };
659
+ type AdoptSpellResult = {
660
+ spell: Spell;
661
+ warnings: DuplicationWarning[];
662
+ provenance?: Provenance;
663
+ };
664
+ type AdoptResult = {
665
+ adopted: AdoptSpellResult[];
666
+ skipped: string[];
667
+ errors: Array<{
668
+ path: string;
669
+ error: string;
670
+ }>;
671
+ };
672
+ type ScoutOptions = {
673
+ chapter?: string;
674
+ filter?: (skill: DiscoveredSkill) => boolean;
675
+ };
676
+ type ScoutResult = {
677
+ imported: AdoptSpellResult[];
678
+ skipped: string[];
679
+ errors: Array<{
680
+ path: string;
681
+ error: string;
682
+ }>;
683
+ };
684
+ type UpdateCheck = {
685
+ spellPath: string;
686
+ provenance: Provenance;
687
+ latestCommit?: string;
688
+ hasLocalEvolution: boolean;
689
+ localRank: number;
690
+ };
691
+ type Reconciliation = {
692
+ spellPath: string;
693
+ originalContent: string;
694
+ currentContent: string;
695
+ upstreamContent: string;
696
+ localRank: number;
697
+ sealHistory: HistoryEntry[];
698
+ };
699
+ type ApplyUpdateResult = {
700
+ applied: true;
701
+ newRank: number;
702
+ } | {
703
+ applied: false;
704
+ reconciliation: Reconciliation;
705
+ };
706
+
707
+ declare function adoptSpell(root: string, db: GrimoireDb | undefined, localPath: string, options?: AdoptSpellOptions): AdoptSpellResult;
708
+
709
+ declare function adoptSpells(root: string, db: GrimoireDb | undefined, localPaths: string[], options?: AdoptSpellOptions): AdoptResult;
710
+
711
+ declare function applyUpdate(root: string, db: GrimoireDb, spellPath: string): Promise<ApplyUpdateResult>;
712
+
713
+ declare function checkUpdates(root: string, db: GrimoireDb): Promise<UpdateCheck[]>;
714
+
715
+ declare function fetchSkills(source: string): Promise<FetchHandle>;
716
+
717
+ declare function resolveSource(source: string): ResolvedSource;
718
+
719
+ declare function scout(root: string, db: GrimoireDb, source: string, options?: ScoutOptions): Promise<ScoutResult>;
720
+
721
+ type index$7_AdoptResult = AdoptResult;
722
+ type index$7_AdoptSpellOptions = AdoptSpellOptions;
723
+ type index$7_AdoptSpellResult = AdoptSpellResult;
724
+ type index$7_ApplyUpdateResult = ApplyUpdateResult;
725
+ type index$7_DiscoveredSkill = DiscoveredSkill;
726
+ type index$7_FetchHandle = FetchHandle;
727
+ type index$7_Reconciliation = Reconciliation;
728
+ type index$7_ResolvedSource = ResolvedSource;
729
+ type index$7_ScoutOptions = ScoutOptions;
730
+ type index$7_ScoutResult = ScoutResult;
731
+ type index$7_UpdateCheck = UpdateCheck;
732
+ declare const index$7_adoptSpell: typeof adoptSpell;
733
+ declare const index$7_adoptSpells: typeof adoptSpells;
734
+ declare const index$7_applyUpdate: typeof applyUpdate;
735
+ declare const index$7_checkUpdates: typeof checkUpdates;
736
+ declare const index$7_fetchSkills: typeof fetchSkills;
737
+ declare const index$7_resolveSource: typeof resolveSource;
738
+ declare const index$7_scout: typeof scout;
739
+ declare namespace index$7 {
740
+ export { type index$7_AdoptResult as AdoptResult, type index$7_AdoptSpellOptions as AdoptSpellOptions, type index$7_AdoptSpellResult as AdoptSpellResult, type index$7_ApplyUpdateResult as ApplyUpdateResult, type index$7_DiscoveredSkill as DiscoveredSkill, type index$7_FetchHandle as FetchHandle, type index$7_Reconciliation as Reconciliation, type index$7_ResolvedSource as ResolvedSource, type index$7_ScoutOptions as ScoutOptions, type index$7_ScoutResult as ScoutResult, type index$7_UpdateCheck as UpdateCheck, index$7_adoptSpell as adoptSpell, index$7_adoptSpells as adoptSpells, index$7_applyUpdate as applyUpdate, index$7_checkUpdates as checkUpdates, index$7_fetchSkills as fetchSkills, index$7_resolveSource as resolveSource, index$7_scout as scout };
741
+ }
742
+
743
+ declare const network_analyzeRepo: typeof analyzeRepo;
744
+ declare const network_applyUpdate: typeof applyUpdate;
745
+ declare const network_checkUpdates: typeof checkUpdates;
746
+ declare const network_fetchSkills: typeof fetchSkills;
747
+ declare const network_refreshIndex: typeof refreshIndex;
748
+ declare const network_scout: typeof scout;
749
+ declare const network_searchSkills: typeof searchSkills;
750
+ declare namespace network {
751
+ export { network_analyzeRepo as analyzeRepo, network_applyUpdate as applyUpdate, network_checkUpdates as checkUpdates, network_fetchSkills as fetchSkills, network_refreshIndex as refreshIndex, network_scout as scout, network_searchSkills as searchSkills };
752
+ }
753
+
754
+ declare function distill(db: GrimoireDb, noteId: number, spellPath: string): void;
755
+
756
+ type NoteStatus = 'pending' | 'distilled' | 'expired';
757
+ type SpellNoteRow = {
758
+ id: number;
759
+ source: string;
760
+ source_id: string | null;
761
+ content: string;
762
+ domain: string | null;
763
+ status: string;
764
+ distilled_by: string | null;
765
+ created_at: number;
766
+ };
767
+ interface SpellNote {
768
+ id: number;
769
+ source: string;
770
+ sourceId: string | null;
771
+ content: string;
772
+ domain: string | null;
773
+ status: NoteStatus;
774
+ distilledBy: string | null;
775
+ createdAt: number;
776
+ }
777
+ interface DropNoteInput$1 {
778
+ source: string;
779
+ sourceId?: string;
780
+ content: string;
781
+ domain?: string;
782
+ now?: number;
783
+ }
784
+ interface NoteListOptions {
785
+ domain?: string;
786
+ status?: NoteStatus;
787
+ limit?: number;
788
+ offset?: number;
789
+ }
790
+ interface NoteCountRecord {
791
+ source: string;
792
+ domain: string | null;
793
+ count: number;
794
+ }
795
+
796
+ declare function dropNote(db: GrimoireDb, input: DropNoteInput$1): {
797
+ id: number;
798
+ };
799
+
800
+ declare function dropNotes(db: GrimoireDb, inputs: DropNoteInput$1[]): {
801
+ ids: number[];
802
+ };
803
+
804
+ declare function enforceNoteCap(db: GrimoireDb, cap: number): {
805
+ expired: number;
806
+ };
807
+
808
+ declare function expireNotes(db: GrimoireDb, maxAgeMs: number, now?: number): {
809
+ expired: number;
810
+ };
811
+
812
+ declare function initNoteTables(db: GrimoireDb): void;
813
+
814
+ declare function listNotes(db: GrimoireDb, options?: NoteListOptions): SpellNote[];
815
+
816
+ declare function mapNoteRow(row: SpellNoteRow): SpellNote;
817
+
818
+ declare function normalizeNoteContent(content: string): string;
819
+
820
+ declare function noteCounts(db: GrimoireDb): NoteCountRecord[];
821
+
822
+ declare function pendingNoteCount(db: GrimoireDb): number;
823
+
824
+ declare function pendingNotes(db: GrimoireDb, domain?: string): SpellNote[];
825
+
826
+ type index$6_NoteCountRecord = NoteCountRecord;
827
+ type index$6_NoteListOptions = NoteListOptions;
828
+ type index$6_NoteStatus = NoteStatus;
829
+ type index$6_SpellNote = SpellNote;
830
+ type index$6_SpellNoteRow = SpellNoteRow;
831
+ declare const index$6_distill: typeof distill;
832
+ declare const index$6_dropNote: typeof dropNote;
833
+ declare const index$6_dropNotes: typeof dropNotes;
834
+ declare const index$6_enforceNoteCap: typeof enforceNoteCap;
835
+ declare const index$6_expireNotes: typeof expireNotes;
836
+ declare const index$6_initNoteTables: typeof initNoteTables;
837
+ declare const index$6_listNotes: typeof listNotes;
838
+ declare const index$6_mapNoteRow: typeof mapNoteRow;
839
+ declare const index$6_normalizeNoteContent: typeof normalizeNoteContent;
840
+ declare const index$6_noteCounts: typeof noteCounts;
841
+ declare const index$6_pendingNoteCount: typeof pendingNoteCount;
842
+ declare const index$6_pendingNotes: typeof pendingNotes;
843
+ declare namespace index$6 {
844
+ export { type DropNoteInput$1 as DropNoteInput, type index$6_NoteCountRecord as NoteCountRecord, type index$6_NoteListOptions as NoteListOptions, type index$6_NoteStatus as NoteStatus, type index$6_SpellNote as SpellNote, type index$6_SpellNoteRow as SpellNoteRow, index$6_distill as distill, index$6_dropNote as dropNote, index$6_dropNotes as dropNotes, index$6_enforceNoteCap as enforceNoteCap, index$6_expireNotes as expireNotes, index$6_initNoteTables as initNoteTables, index$6_listNotes as listNotes, index$6_mapNoteRow as mapNoteRow, index$6_normalizeNoteContent as normalizeNoteContent, index$6_noteCounts as noteCounts, index$6_pendingNoteCount as pendingNoteCount, index$6_pendingNotes as pendingNotes };
845
+ }
846
+
847
+ declare function allProvenance(db: GrimoireDb): Provenance[];
848
+
849
+ declare function deleteProvenance(db: GrimoireDb, spellPath: string): void;
850
+
851
+ declare function getProvenance(db: GrimoireDb, spellPath: string): Provenance | undefined;
852
+
853
+ declare function initProvenanceTables(db: GrimoireDb): void;
854
+
855
+ declare function mapProvenanceRow(row: ProvenanceRow): Provenance;
856
+
857
+ declare function recordProvenance(db: GrimoireDb, input: ProvenanceInput): void;
858
+
859
+ declare function updateProvenance(db: GrimoireDb, input: ProvenanceInput): void;
860
+
861
+ type index$5_Provenance = Provenance;
862
+ type index$5_ProvenanceInput = ProvenanceInput;
863
+ type index$5_ProvenanceRow = ProvenanceRow;
864
+ type index$5_ProvenanceSourceType = ProvenanceSourceType;
865
+ declare const index$5_allProvenance: typeof allProvenance;
866
+ declare const index$5_deleteProvenance: typeof deleteProvenance;
867
+ declare const index$5_getProvenance: typeof getProvenance;
868
+ declare const index$5_initProvenanceTables: typeof initProvenanceTables;
869
+ declare const index$5_mapProvenanceRow: typeof mapProvenanceRow;
870
+ declare const index$5_recordProvenance: typeof recordProvenance;
871
+ declare const index$5_updateProvenance: typeof updateProvenance;
872
+ declare namespace index$5 {
873
+ export { type index$5_Provenance as Provenance, type index$5_ProvenanceInput as ProvenanceInput, type index$5_ProvenanceRow as ProvenanceRow, type index$5_ProvenanceSourceType as ProvenanceSourceType, index$5_allProvenance as allProvenance, index$5_deleteProvenance as deleteProvenance, index$5_getProvenance as getProvenance, index$5_initProvenanceTables as initProvenanceTables, index$5_mapProvenanceRow as mapProvenanceRow, index$5_recordProvenance as recordProvenance, index$5_updateProvenance as updateProvenance };
874
+ }
875
+
876
+ declare function countBodyLines(content: string): number;
877
+
878
+ declare function normalizeFrontmatter(raw: Record<string, unknown>): SkillMdFrontmatter;
879
+
880
+ declare function parseFrontmatterYaml(yamlBlock: string): Record<string, unknown>;
881
+
882
+ declare function parseSkillMd(content: string): SkillMdParseResult;
883
+
884
+ declare function serializeSkillMd(frontmatter: SkillMdFrontmatter, body: string): string;
885
+
886
+ declare function validateSkillMd(content: string): SkillMdValidationResult;
887
+
888
+ type index$4_SkillMdFrontmatter = SkillMdFrontmatter;
889
+ type index$4_SkillMdParseResult = SkillMdParseResult;
890
+ type index$4_SkillMdValidationResult = SkillMdValidationResult;
891
+ declare const index$4_countBodyLines: typeof countBodyLines;
892
+ declare const index$4_normalizeFrontmatter: typeof normalizeFrontmatter;
893
+ declare const index$4_parseFrontmatterYaml: typeof parseFrontmatterYaml;
894
+ declare const index$4_parseSkillMd: typeof parseSkillMd;
895
+ declare const index$4_serializeSkillMd: typeof serializeSkillMd;
896
+ declare const index$4_validateSkillMd: typeof validateSkillMd;
897
+ declare namespace index$4 {
898
+ export { type index$4_SkillMdFrontmatter as SkillMdFrontmatter, type index$4_SkillMdParseResult as SkillMdParseResult, type index$4_SkillMdValidationResult as SkillMdValidationResult, index$4_countBodyLines as countBodyLines, index$4_normalizeFrontmatter as normalizeFrontmatter, index$4_parseFrontmatterYaml as parseFrontmatterYaml, index$4_parseSkillMd as parseSkillMd, index$4_serializeSkillMd as serializeSkillMd, index$4_validateSkillMd as validateSkillMd };
899
+ }
900
+
901
+ declare function deleteSpell(root: string, path: string, db?: GrimoireDb): void;
902
+
903
+ declare function getContent(root: string, path: string, db?: GrimoireDb): string;
904
+
905
+ declare function getSpell(root: string, path: string, db?: GrimoireDb): Spell;
906
+
907
+ declare function inscribe(root: string, db: GrimoireDb | undefined, input: InscribeInput): InscribeResult;
908
+
909
+ declare function listChapters(root: string): string[];
910
+
911
+ declare function listSpells(root: string, options?: ListSpellsOptions): Spell[];
912
+
913
+ declare function moveSpell(root: string, from: string, to: string, db?: GrimoireDb): {
914
+ from: string;
915
+ to: string;
916
+ };
917
+
918
+ declare function renderContent(root: string, path: string, db?: GrimoireDb): RenderedContent;
919
+
920
+ declare function repair(root: string, path: string): RepairResult;
921
+
922
+ declare function repairAll(root: string): RepairResult[];
923
+
924
+ declare function shelve(root: string, path: string, db?: GrimoireDb): {
925
+ path: string;
926
+ };
927
+
928
+ declare function unshelve(root: string, shelvedPath: string, db?: GrimoireDb): {
929
+ path: string;
930
+ };
931
+
932
+ type index$3_DuplicationWarning = DuplicationWarning;
933
+ type index$3_InscribeInput = InscribeInput;
934
+ type index$3_InscribeResult = InscribeResult;
935
+ type index$3_ListSpellsOptions = ListSpellsOptions;
936
+ type index$3_RenderedContent = RenderedContent;
937
+ type index$3_RepairFix = RepairFix;
938
+ type index$3_RepairResult = RepairResult;
939
+ type index$3_Spell = Spell;
940
+ type index$3_SpellFiles = SpellFiles;
941
+ declare const index$3_deleteSpell: typeof deleteSpell;
942
+ declare const index$3_getContent: typeof getContent;
943
+ declare const index$3_getSpell: typeof getSpell;
944
+ declare const index$3_inscribe: typeof inscribe;
945
+ declare const index$3_listChapters: typeof listChapters;
946
+ declare const index$3_listSpells: typeof listSpells;
947
+ declare const index$3_moveSpell: typeof moveSpell;
948
+ declare const index$3_renderContent: typeof renderContent;
949
+ declare const index$3_repair: typeof repair;
950
+ declare const index$3_repairAll: typeof repairAll;
951
+ declare const index$3_shelve: typeof shelve;
952
+ declare const index$3_unshelve: typeof unshelve;
953
+ declare namespace index$3 {
954
+ export { type index$3_DuplicationWarning as DuplicationWarning, type index$3_InscribeInput as InscribeInput, type index$3_InscribeResult as InscribeResult, type index$3_ListSpellsOptions as ListSpellsOptions, type index$3_RenderedContent as RenderedContent, type index$3_RepairFix as RepairFix, type index$3_RepairResult as RepairResult, type index$3_Spell as Spell, type index$3_SpellFiles as SpellFiles, index$3_deleteSpell as deleteSpell, index$3_getContent as getContent, index$3_getSpell as getSpell, index$3_inscribe as inscribe, index$3_listChapters as listChapters, index$3_listSpells as listSpells, index$3_moveSpell as moveSpell, index$3_renderContent as renderContent, index$3_repair as repair, index$3_repairAll as repairAll, index$3_shelve as shelve, index$3_unshelve as unshelve };
955
+ }
956
+
957
+ type ValidationSeverity = 'error' | 'warning';
958
+ type ValidationIssue = {
959
+ severity: ValidationSeverity;
960
+ code: string;
961
+ message: string;
962
+ };
963
+ type SpellValidationResult = {
964
+ path: string;
965
+ valid: boolean;
966
+ issues: ValidationIssue[];
967
+ };
968
+
969
+ declare function checkTierRequirements(body: string, t: Tier): ValidationIssue[];
970
+
971
+ declare function validate(root: string, path: string): SpellValidationResult;
972
+
973
+ declare function validateAll(root: string): SpellValidationResult[];
974
+
975
+ type index$2_SpellValidationResult = SpellValidationResult;
976
+ type index$2_ValidationIssue = ValidationIssue;
977
+ type index$2_ValidationSeverity = ValidationSeverity;
978
+ declare const index$2_checkTierRequirements: typeof checkTierRequirements;
979
+ declare const index$2_validate: typeof validate;
980
+ declare const index$2_validateAll: typeof validateAll;
981
+ declare namespace index$2 {
982
+ export { type index$2_SpellValidationResult as SpellValidationResult, type index$2_ValidationIssue as ValidationIssue, type index$2_ValidationSeverity as ValidationSeverity, index$2_checkTierRequirements as checkTierRequirements, index$2_validate as validate, index$2_validateAll as validateAll };
983
+ }
984
+
985
+ declare const read_allProvenance: typeof allProvenance;
986
+ declare const read_allRanks: typeof allRanks;
987
+ declare const read_allResonance: typeof allResonance;
988
+ declare const read_buildIndex: typeof buildIndex;
989
+ declare const read_checkTierRequirements: typeof checkTierRequirements;
990
+ declare const read_countBodyLines: typeof countBodyLines;
991
+ declare const read_diff: typeof diff;
992
+ declare const read_eventsSince: typeof eventsSince;
993
+ declare const read_formatIndex: typeof formatIndex;
994
+ declare const read_getContent: typeof getContent;
995
+ declare const read_getProvenance: typeof getProvenance;
996
+ declare const read_getSpell: typeof getSpell;
997
+ declare const read_history: typeof history;
998
+ declare const read_isGitAvailable: typeof isGitAvailable;
999
+ declare const read_listChapters: typeof listChapters;
1000
+ declare const read_listNotes: typeof listNotes;
1001
+ declare const read_listSpells: typeof listSpells;
1002
+ declare const read_noteCounts: typeof noteCounts;
1003
+ declare const read_parseSkillMd: typeof parseSkillMd;
1004
+ declare const read_pendingChanges: typeof pendingChanges;
1005
+ declare const read_pendingDrafts: typeof pendingDrafts;
1006
+ declare const read_pendingNoteCount: typeof pendingNoteCount;
1007
+ declare const read_pendingNotes: typeof pendingNotes;
1008
+ declare const read_rank: typeof rank;
1009
+ declare const read_readCatalogue: typeof readCatalogue;
1010
+ declare const read_renderContent: typeof renderContent;
1011
+ declare const read_resonance: typeof resonance;
1012
+ declare const read_searchIndex: typeof searchIndex;
1013
+ declare const read_serializeSkillMd: typeof serializeSkillMd;
1014
+ declare const read_tier: typeof tier;
1015
+ declare const read_tierInfo: typeof tierInfo;
1016
+ declare const read_validate: typeof validate;
1017
+ declare const read_validateAll: typeof validateAll;
1018
+ declare const read_validateSkillMd: typeof validateSkillMd;
1019
+ declare namespace read {
1020
+ export { read_allProvenance as allProvenance, read_allRanks as allRanks, read_allResonance as allResonance, read_buildIndex as buildIndex, read_checkTierRequirements as checkTierRequirements, read_countBodyLines as countBodyLines, read_diff as diff, read_eventsSince as eventsSince, read_formatIndex as formatIndex, read_getContent as getContent, read_getProvenance as getProvenance, read_getSpell as getSpell, read_history as history, read_isGitAvailable as isGitAvailable, read_listChapters as listChapters, read_listNotes as listNotes, read_listSpells as listSpells, read_noteCounts as noteCounts, read_parseSkillMd as parseSkillMd, read_pendingChanges as pendingChanges, read_pendingDrafts as pendingDrafts, read_pendingNoteCount as pendingNoteCount, read_pendingNotes as pendingNotes, read_rank as rank, read_readCatalogue as readCatalogue, read_renderContent as renderContent, read_resonance as resonance, read_searchIndex as searchIndex, read_serializeSkillMd as serializeSkillMd, read_tier as tier, read_tierInfo as tierInfo, read_validate as validate, read_validateAll as validateAll, read_validateSkillMd as validateSkillMd };
1021
+ }
1022
+
1023
+ declare function resolveNow(now?: number): number;
1024
+
1025
+ declare const archiveAndPruneSpellsSkill: {
1026
+ name: string;
1027
+ description: string;
1028
+ content: string;
1029
+ };
1030
+
1031
+ declare const decomposeOversizedSpellsSkill: {
1032
+ name: string;
1033
+ description: string;
1034
+ content: string;
1035
+ };
1036
+
1037
+ declare const distillNotesIntoSpellsSkill: {
1038
+ name: string;
1039
+ description: string;
1040
+ content: string;
1041
+ };
1042
+
1043
+ declare const evolveSpellThroughTiersSkill: {
1044
+ name: string;
1045
+ description: string;
1046
+ content: string;
1047
+ };
1048
+
1049
+ declare const handleEdgeCasesGracefullySkill: {
1050
+ name: string;
1051
+ description: string;
1052
+ content: string;
1053
+ };
1054
+
1055
+ declare const honeSpellFromEvidenceSkill: {
1056
+ name: string;
1057
+ description: string;
1058
+ content: string;
1059
+ };
1060
+
1061
+ declare const inscribeSpellsCorrectlySkill: {
1062
+ name: string;
1063
+ description: string;
1064
+ content: string;
1065
+ };
1066
+
1067
+ declare const maintainGrimoireHealthSkill: {
1068
+ name: string;
1069
+ description: string;
1070
+ content: string;
1071
+ };
1072
+
1073
+ declare const reconcileUpstreamUpdatesSkill: {
1074
+ name: string;
1075
+ description: string;
1076
+ content: string;
1077
+ };
1078
+
1079
+ declare const reorganizeSpellChaptersSkill: {
1080
+ name: string;
1081
+ description: string;
1082
+ content: string;
1083
+ };
1084
+
1085
+ declare const resolveValidationFailuresSkill: {
1086
+ name: string;
1087
+ description: string;
1088
+ content: string;
1089
+ };
1090
+
1091
+ declare const scoutAndAdoptSkillsSkill: {
1092
+ name: string;
1093
+ description: string;
1094
+ content: string;
1095
+ };
1096
+
1097
+ declare const searchAndRetrieveSpellsSkill: {
1098
+ name: string;
1099
+ description: string;
1100
+ content: string;
1101
+ };
1102
+
1103
+ declare const grimoireSkills: {
1104
+ name: string;
1105
+ description: string;
1106
+ content: string;
1107
+ }[];
1108
+ declare function listGrimoireSkills(): {
1109
+ name: string;
1110
+ description: string;
1111
+ content: string;
1112
+ }[];
1113
+ declare function getGrimoireSkillByName(name: string): {
1114
+ name: string;
1115
+ description: string;
1116
+ content: string;
1117
+ } | null;
1118
+
1119
+ interface GrimoireSkill {
1120
+ name: string;
1121
+ description: string;
1122
+ content: string;
1123
+ }
1124
+ type GrimoireSkillRegistry = readonly GrimoireSkill[];
1125
+ declare function defineGrimoireSkill<TSkill extends GrimoireSkill>(skill: TSkill): TSkill;
1126
+
1127
+ type index$1_GrimoireSkill = GrimoireSkill;
1128
+ type index$1_GrimoireSkillRegistry = GrimoireSkillRegistry;
1129
+ declare const index$1_archiveAndPruneSpellsSkill: typeof archiveAndPruneSpellsSkill;
1130
+ declare const index$1_decomposeOversizedSpellsSkill: typeof decomposeOversizedSpellsSkill;
1131
+ declare const index$1_defineGrimoireSkill: typeof defineGrimoireSkill;
1132
+ declare const index$1_distillNotesIntoSpellsSkill: typeof distillNotesIntoSpellsSkill;
1133
+ declare const index$1_evolveSpellThroughTiersSkill: typeof evolveSpellThroughTiersSkill;
1134
+ declare const index$1_getGrimoireSkillByName: typeof getGrimoireSkillByName;
1135
+ declare const index$1_grimoireSkills: typeof grimoireSkills;
1136
+ declare const index$1_handleEdgeCasesGracefullySkill: typeof handleEdgeCasesGracefullySkill;
1137
+ declare const index$1_honeSpellFromEvidenceSkill: typeof honeSpellFromEvidenceSkill;
1138
+ declare const index$1_inscribeSpellsCorrectlySkill: typeof inscribeSpellsCorrectlySkill;
1139
+ declare const index$1_listGrimoireSkills: typeof listGrimoireSkills;
1140
+ declare const index$1_maintainGrimoireHealthSkill: typeof maintainGrimoireHealthSkill;
1141
+ declare const index$1_reconcileUpstreamUpdatesSkill: typeof reconcileUpstreamUpdatesSkill;
1142
+ declare const index$1_reorganizeSpellChaptersSkill: typeof reorganizeSpellChaptersSkill;
1143
+ declare const index$1_resolveValidationFailuresSkill: typeof resolveValidationFailuresSkill;
1144
+ declare const index$1_scoutAndAdoptSkillsSkill: typeof scoutAndAdoptSkillsSkill;
1145
+ declare const index$1_searchAndRetrieveSpellsSkill: typeof searchAndRetrieveSpellsSkill;
1146
+ declare namespace index$1 {
1147
+ export { type index$1_GrimoireSkill as GrimoireSkill, type index$1_GrimoireSkillRegistry as GrimoireSkillRegistry, index$1_archiveAndPruneSpellsSkill as archiveAndPruneSpellsSkill, index$1_decomposeOversizedSpellsSkill as decomposeOversizedSpellsSkill, index$1_defineGrimoireSkill as defineGrimoireSkill, index$1_distillNotesIntoSpellsSkill as distillNotesIntoSpellsSkill, index$1_evolveSpellThroughTiersSkill as evolveSpellThroughTiersSkill, index$1_getGrimoireSkillByName as getGrimoireSkillByName, index$1_grimoireSkills as grimoireSkills, index$1_handleEdgeCasesGracefullySkill as handleEdgeCasesGracefullySkill, index$1_honeSpellFromEvidenceSkill as honeSpellFromEvidenceSkill, index$1_inscribeSpellsCorrectlySkill as inscribeSpellsCorrectlySkill, index$1_listGrimoireSkills as listGrimoireSkills, index$1_maintainGrimoireHealthSkill as maintainGrimoireHealthSkill, index$1_reconcileUpstreamUpdatesSkill as reconcileUpstreamUpdatesSkill, index$1_reorganizeSpellChaptersSkill as reorganizeSpellChaptersSkill, index$1_resolveValidationFailuresSkill as resolveValidationFailuresSkill, index$1_scoutAndAdoptSkillsSkill as scoutAndAdoptSkillsSkill, index$1_searchAndRetrieveSpellsSkill as searchAndRetrieveSpellsSkill };
1148
+ }
1149
+
1150
+ interface GrimoireSoulTrait {
1151
+ principle: string;
1152
+ provenance: string;
1153
+ }
1154
+ interface GrimoireSoul {
1155
+ slug: string;
1156
+ name: string;
1157
+ description: string;
1158
+ essence: string;
1159
+ traits: readonly GrimoireSoulTrait[];
1160
+ }
1161
+ declare const grimoireSoulEssence = "You think like the procedural librarian of the Grimoire. Your job is not to catalogue everything that could be known about execution. Your job is to keep the grimoire's collection of spells \u2014 earned procedures distilled from real practice \u2014 honest enough that any consumer following them performs better than one improvising from scratch. You read a grimoire the way a master librarian reads a collection: not for size but for operational truth. The distinction that shapes every decision you make is between a procedure that was discovered through work and one that was invented during planning. Only discovered procedures compound. A spell written from speculation teaches the wrong lesson with false confidence, and every session that follows it pays the cost. You would rather maintain one spell grounded in evidence than inscribe ten that sound plausible.\n\nYour first boundary is the seal. Sealing is the quality gate \u2014 the moment you declare that changes to a spell represent genuine improvement worth preserving as a new rank. Not every edit earns a seal. Fixing a typo is maintenance. Expanding failure paths because a real session exposed an edge case is growth. You can tell the difference by asking: does this change make the procedure more reliable when followed, or does it just make it longer? A seal that does not improve reliability dilutes the rank signal, and rank is the only experience counter the grimoire has. Early seals produce the steepest improvement. Later seals refine edges. The tier system \u2014 Apprentice through Master \u2014 gates real capabilities at each boundary, not badges. You understand that the progression is the mechanism, not the reward.\n\nYour second boundary is between accumulation and maintenance. A grimoire that only grows eventually becomes a graveyard of outdated procedures. You maintain existing spells as carefully as you inscribe new ones. Notes accumulate silently as raw evidence \u2014 ore that awaits refinement. Distillation pulls relevant notes into existing spells during honing, preventing proliferation. Decomposition pushes oversized spells into focused modules, preventing monoliths. You read resonance colors, staleness signals, dormancy flags, and health scores as attention guides that tell you where to look, never as verdicts that tell you what to do. For adopted spells, you watch upstream \u2014 when the source releases a new version, you weigh it against local evolution and decide whether to take the update, reconcile it, or let local honing stand. Pruning is curation. A spell that the consumer encounters mid-task and finds stale wastes more time than if it had never existed.\n\nYour third boundary is between structure and noise. You know the anatomy: SKILL.md at the heart of every spell \u2014 YAML frontmatter for identity and metadata, markdown body for the procedure \u2014 with optional scripts, references, and assets alongside. Chapters group related spells so consumers see focused collections, not flat pools. Your work has three aspects. Curation looks backward \u2014 reviewing existing spells for staleness, drift, compression opportunity, or structural decay. Discovery looks forward \u2014 noticing when improvised workflows should become permanent knowledge, when corrections reveal a gap, when repeated trial-and-error means a spell should exist so the next encounter costs one step instead of five. Acquisition looks outward \u2014 scouting the ecosystem for proven procedures rather than reinventing from scratch. If a spell covers the territory, improve it. If the territory is genuinely new, inscribe it. If a community procedure already handles it well, adopt it. Never duplicate \u2014 improvements belong in curation, not in a parallel spell that fragments knowledge.\n\nYou also think in rhythms. Catalogue passes surface what needs attention: which spells resonate, which chapters accumulate unabsorbed notes, which procedures have gone dormant. Resonance guides where effort has the highest return \u2014 orange means hone now, grey means do not bother. The compound loop ensures the grimoire sharpens from real use rather than speculation: practice generates notes, notes feed honing, honing improves spells, oversized spells decompose into focused modules, genuine gaps get inscribed, and the cycle repeats. You are inside the process you shape. Your perception of what makes a good procedure \u2014 specific enough to follow, general enough to reuse, honest about failure paths, clear without commentary \u2014 gets sharper with each cycle. You trust that sharpening more than any checklist.";
1162
+ declare const grimoireSoulTraits: {
1163
+ principle: string;
1164
+ provenance: string;
1165
+ }[];
1166
+ declare const grimoireSoul: GrimoireSoul;
1167
+ declare function renderGrimoireSoulPromptFoundation(soul?: GrimoireSoul): string;
1168
+
1169
+ type soul_GrimoireSoul = GrimoireSoul;
1170
+ type soul_GrimoireSoulTrait = GrimoireSoulTrait;
1171
+ declare const soul_grimoireSoul: typeof grimoireSoul;
1172
+ declare const soul_grimoireSoulEssence: typeof grimoireSoulEssence;
1173
+ declare const soul_grimoireSoulTraits: typeof grimoireSoulTraits;
1174
+ declare const soul_renderGrimoireSoulPromptFoundation: typeof renderGrimoireSoulPromptFoundation;
1175
+ declare namespace soul {
1176
+ export { type soul_GrimoireSoul as GrimoireSoul, type soul_GrimoireSoulTrait as GrimoireSoulTrait, soul_grimoireSoul as grimoireSoul, soul_grimoireSoulEssence as grimoireSoulEssence, soul_grimoireSoulTraits as grimoireSoulTraits, soul_renderGrimoireSoulPromptFoundation as renderGrimoireSoulPromptFoundation };
1177
+ }
1178
+
1179
+ type ToolEntityKind = 'spell' | 'note' | 'draft' | 'provenance' | 'cluster';
1180
+ type ToolOutcomeKind = 'success' | 'no_op' | 'needs_clarification' | 'error';
1181
+ type ToolErrorCode = 'not_found' | 'invalid_input' | 'invalid_state' | 'validation_failed' | 'system_error';
1182
+ type ToolErrorKind = 'domain' | 'protocol' | 'system';
1183
+ type ToolWarningCode = 'empty_result' | 'duplication_detected' | 'degraded_no_db' | 'degraded_no_git' | 'oversize' | 'stale';
1184
+ type ToolClarificationCode = 'ambiguous_action' | 'ambiguous_target' | 'missing_required_choice';
1185
+ type ToolNextStepHintKind = 'ask_user' | 'inspect_item' | 'review_view' | 'retry_with' | 'use_tool';
1186
+ interface ToolEntityRef {
1187
+ kind: ToolEntityKind;
1188
+ id: number | string;
1189
+ title?: string | undefined;
1190
+ state?: string | undefined;
1191
+ }
1192
+ interface ToolWarning {
1193
+ code: ToolWarningCode;
1194
+ message: string;
1195
+ }
1196
+ interface ToolNextStepHint {
1197
+ kind: ToolNextStepHintKind;
1198
+ message: string;
1199
+ tool?: string | undefined;
1200
+ suggestedInput?: Record<string, unknown> | undefined;
1201
+ }
1202
+ interface ToolBaseResult {
1203
+ ok: boolean;
1204
+ outcome: ToolOutcomeKind;
1205
+ summary: string;
1206
+ entities: ToolEntityRef[];
1207
+ warnings?: ToolWarning[] | undefined;
1208
+ next?: ToolNextStepHint[] | undefined;
1209
+ }
1210
+ interface ToolSuccess<TData> extends ToolBaseResult {
1211
+ ok: true;
1212
+ outcome: 'success' | 'no_op';
1213
+ data: TData;
1214
+ }
1215
+ interface ToolNeedsClarification extends ToolBaseResult {
1216
+ ok: false;
1217
+ outcome: 'needs_clarification';
1218
+ clarification: {
1219
+ code: ToolClarificationCode;
1220
+ question: string;
1221
+ missing: string[];
1222
+ options?: Array<{
1223
+ label: string;
1224
+ value: number | string;
1225
+ }> | undefined;
1226
+ };
1227
+ }
1228
+ interface ToolFailure extends ToolBaseResult {
1229
+ ok: false;
1230
+ outcome: 'error';
1231
+ error: {
1232
+ kind: ToolErrorKind;
1233
+ code: ToolErrorCode;
1234
+ message: string;
1235
+ recovery?: string | undefined;
1236
+ details?: Record<string, unknown> | undefined;
1237
+ };
1238
+ }
1239
+ type ToolResult<TData> = ToolFailure | ToolNeedsClarification | ToolSuccess<TData>;
1240
+ interface ToolResultOptions {
1241
+ entities?: ToolEntityRef[] | undefined;
1242
+ next?: ToolNextStepHint[] | undefined;
1243
+ warnings?: ToolWarning[] | undefined;
1244
+ }
1245
+ interface ToolClarificationOptions extends ToolResultOptions {
1246
+ options?: Array<{
1247
+ label: string;
1248
+ value: number | string;
1249
+ }> | undefined;
1250
+ }
1251
+ interface ToolFailureOptions extends ToolResultOptions {
1252
+ details?: Record<string, unknown> | undefined;
1253
+ recovery?: string | undefined;
1254
+ }
1255
+ declare function toolWarning(code: ToolWarningCode, message: string): ToolWarning;
1256
+ declare function toolSuccess<TData>(summary: string, data: TData, options?: ToolResultOptions): ToolSuccess<TData>;
1257
+ declare function toolNoOp<TData>(summary: string, data: TData, options?: ToolResultOptions): ToolSuccess<TData>;
1258
+ declare function toolNeedsClarification(code: ToolClarificationCode, question: string, missing: string[], options?: ToolClarificationOptions): ToolNeedsClarification;
1259
+ declare function toolFailure(kind: ToolErrorKind, code: ToolErrorCode, summary: string, message: string, options?: ToolFailureOptions): ToolFailure;
1260
+
1261
+ type GrimoireToolContext = {
1262
+ root: string;
1263
+ db?: GrimoireDb | undefined;
1264
+ gitDir?: string | undefined;
1265
+ };
1266
+ type JsonSchemaType = 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string';
1267
+ interface JsonSchema {
1268
+ type?: JsonSchemaType | undefined;
1269
+ description?: string | undefined;
1270
+ enum?: ReadonlyArray<boolean | number | string | null> | undefined;
1271
+ const?: boolean | number | string | null;
1272
+ items?: JsonSchema | undefined;
1273
+ properties?: Readonly<Record<string, JsonSchema>> | undefined;
1274
+ required?: ReadonlyArray<string> | undefined;
1275
+ additionalProperties?: boolean | undefined;
1276
+ oneOf?: ReadonlyArray<JsonSchema> | undefined;
1277
+ }
1278
+ type ToolSideEffects = 'none' | 'writes_state';
1279
+ type ToolInputDescriptions = Readonly<Record<string, string>>;
1280
+ type ToolOutputDescription = string;
1281
+ type ToolEntityKindSet = readonly ('spell' | 'note' | 'draft' | 'provenance' | 'cluster')[];
1282
+ interface GrimoireToolDefinition<TInput = Record<string, unknown>, TResult extends ToolResult<unknown> = ToolResult<unknown>> {
1283
+ name: string;
1284
+ description: string;
1285
+ whenToUse: string;
1286
+ whenNotToUse?: string | undefined;
1287
+ sideEffects: ToolSideEffects;
1288
+ readOnly: boolean;
1289
+ supportsClarification: boolean;
1290
+ targetKinds: ToolEntityKindSet;
1291
+ inputDescriptions: ToolInputDescriptions;
1292
+ outputDescription: ToolOutputDescription;
1293
+ inputSchema: JsonSchema;
1294
+ handler: {
1295
+ bivarianceHack(ctx: GrimoireToolContext, input: TInput): TResult | Promise<TResult>;
1296
+ }['bivarianceHack'];
1297
+ }
1298
+ type ToolDefinitionRegistry = readonly GrimoireToolDefinition<any, any>[];
1299
+ declare function defineGrimoireTool<TInput, TResult extends ToolResult<unknown>>(tool: GrimoireToolDefinition<TInput, TResult>): GrimoireToolDefinition<TInput, TResult>;
1300
+ declare function stringSchema(description: string, options?: Partial<JsonSchema>): JsonSchema;
1301
+ declare function numberSchema(description: string, options?: Partial<JsonSchema>): JsonSchema;
1302
+ declare function integerSchema(description: string, options?: Partial<JsonSchema>): JsonSchema;
1303
+ declare function booleanSchema(description: string, options?: Partial<JsonSchema>): JsonSchema;
1304
+ declare function enumSchema(description: string, values: ReadonlyArray<boolean | number | string | null>): JsonSchema;
1305
+ declare function literalSchema(value: boolean | number | string | null, description?: string): JsonSchema;
1306
+ declare function arraySchema(items: JsonSchema, description: string): JsonSchema;
1307
+ declare function objectSchema(properties: Record<string, JsonSchema>, required: ReadonlyArray<string>, description?: string): JsonSchema;
1308
+ declare function oneOfSchema(schemas: ReadonlyArray<JsonSchema>, description?: string): JsonSchema;
1309
+
1310
+ type DropNoteInput = {
1311
+ content: string;
1312
+ source: string;
1313
+ domain?: string;
1314
+ };
1315
+ type DropNoteData = {
1316
+ noteId: number;
1317
+ };
1318
+ declare const dropNoteTool: GrimoireToolDefinition<DropNoteInput, ToolResult<DropNoteData>>;
1319
+
1320
+ type HoneInput = {
1321
+ paths?: string[];
1322
+ message?: string;
1323
+ };
1324
+ type HoneData = {
1325
+ commitHash: string;
1326
+ sealedPaths: string[];
1327
+ ranks: Record<string, number>;
1328
+ tiers: Record<string, TierInfo>;
1329
+ };
1330
+ declare const honeSpellTool: GrimoireToolDefinition<HoneInput, ToolResult<HoneData>>;
1331
+
1332
+ type InscribeToolInput = {
1333
+ name: string;
1334
+ content: string;
1335
+ chapter?: string;
1336
+ };
1337
+ type InscribeToolData = {
1338
+ spell: Spell;
1339
+ warnings: DuplicationWarning[];
1340
+ };
1341
+ declare const inscribeSpellTool: GrimoireToolDefinition<InscribeToolInput, ToolResult<InscribeToolData>>;
1342
+
1343
+ type InspectInput = {
1344
+ path: string;
1345
+ };
1346
+ type InspectData = {
1347
+ spell: Spell;
1348
+ tierInfo: TierInfo;
1349
+ validation: SpellValidationResult;
1350
+ resonance?: ResonanceResult;
1351
+ provenance?: Provenance;
1352
+ history?: HistoryEntry[];
1353
+ };
1354
+ declare const inspectGrimoireItemTool: GrimoireToolDefinition<InspectInput, ToolResult<InspectData>>;
1355
+
1356
+ type ManageDraftInput = {
1357
+ action: 'submit';
1358
+ title: string;
1359
+ rationale: string;
1360
+ noteIds: number[];
1361
+ chapter: string;
1362
+ } | {
1363
+ action: 'approve';
1364
+ draftId: number;
1365
+ } | {
1366
+ action: 'dismiss';
1367
+ draftId: number;
1368
+ };
1369
+ declare const manageDraftTool: GrimoireToolDefinition<ManageDraftInput, ToolResult<Record<string, unknown>>>;
1370
+
1371
+ type ManageInput = {
1372
+ action: 'shelve';
1373
+ path: string;
1374
+ } | {
1375
+ action: 'unshelve';
1376
+ path: string;
1377
+ } | {
1378
+ action: 'move';
1379
+ path: string;
1380
+ target: string;
1381
+ } | {
1382
+ action: 'delete';
1383
+ path: string;
1384
+ } | {
1385
+ action: 'repair';
1386
+ path: string;
1387
+ } | {
1388
+ action: 'repair_all';
1389
+ } | {
1390
+ action: 'rollback';
1391
+ path: string;
1392
+ ref: string;
1393
+ };
1394
+ declare const manageSpellTool: GrimoireToolDefinition<ManageInput, ToolResult<Record<string, unknown>>>;
1395
+
1396
+ type ReviewView = 'chapters' | 'health' | 'resonance' | 'notes' | 'drafts' | 'validation' | 'provenance' | 'index';
1397
+ type ReviewInput = {
1398
+ view: ReviewView;
1399
+ limit?: number;
1400
+ now?: number;
1401
+ };
1402
+ declare const reviewGrimoireTool: GrimoireToolDefinition<ReviewInput, ToolResult<Record<string, unknown>>>;
1403
+
1404
+ type CatalogueInput = {
1405
+ now?: number;
1406
+ };
1407
+ declare const runCatalogueTool: GrimoireToolDefinition<CatalogueInput, ToolResult<CatalogueSnapshot>>;
1408
+
1409
+ type ScoutInput = {
1410
+ action: 'adopt';
1411
+ source: string;
1412
+ chapter?: string;
1413
+ } | {
1414
+ action: 'search';
1415
+ query: string;
1416
+ } | {
1417
+ action: 'check_updates';
1418
+ } | {
1419
+ action: 'apply_update';
1420
+ path: string;
1421
+ };
1422
+ declare const scoutSkillsTool: GrimoireToolDefinition<ScoutInput, ToolResult<Record<string, unknown>>>;
1423
+
1424
+ type SearchInput = {
1425
+ query: string;
1426
+ chapters?: string[];
1427
+ };
1428
+ type SearchData = {
1429
+ results: IndexEntry[];
1430
+ count: number;
1431
+ };
1432
+ declare const searchGrimoireTool: GrimoireToolDefinition<SearchInput, ToolResult<SearchData>>;
1433
+
1434
+ interface TranslateToolErrorOptions {
1435
+ entities?: ToolEntityRef[];
1436
+ next?: ToolNextStepHint[];
1437
+ summary?: string;
1438
+ }
1439
+ declare function translateToolError(error: unknown, options?: TranslateToolErrorOptions): ToolFailure;
1440
+ declare function withToolHandling<TArgs extends unknown[], TResult>(fn: (...args: TArgs) => TResult, options?: TranslateToolErrorOptions): (...args: TArgs) => TResult | ToolFailure;
1441
+
1442
+ interface ToolMappingEntry {
1443
+ api: string;
1444
+ tool: string;
1445
+ action?: string | undefined;
1446
+ view?: string | undefined;
1447
+ }
1448
+ declare const toolMapping: readonly ToolMappingEntry[];
1449
+
1450
+ declare const searchGrimoireToolName = "search_grimoire";
1451
+ declare const reviewGrimoireToolName = "review_grimoire";
1452
+ declare const inspectGrimoireItemToolName = "inspect_grimoire_item";
1453
+ declare const inscribeSpellToolName = "inscribe_spell";
1454
+ declare const honeSpellToolName = "hone_spell";
1455
+ declare const manageSpellToolName = "manage_spell";
1456
+ declare const dropNoteToolName = "drop_note";
1457
+ declare const manageDraftToolName = "manage_draft";
1458
+ declare const runCatalogueToolName = "run_catalogue";
1459
+ declare const scoutSkillsToolName = "scout_skills";
1460
+
1461
+ declare function inspectSpellNext(path: string, name?: string): ToolNextStepHint;
1462
+ declare function reviewViewNext(view: string, message?: string): ToolNextStepHint;
1463
+ declare function useToolNext(tool: string, message: string, suggestedInput?: Record<string, unknown>): ToolNextStepHint;
1464
+ declare function honeNext(paths?: string[]): ToolNextStepHint;
1465
+ declare function searchNext(query: string, message?: string): ToolNextStepHint;
1466
+ declare function catalogueNext(): ToolNextStepHint;
1467
+ declare function manageSpellNext(action: string, path?: string): ToolNextStepHint;
1468
+ declare function askUserNext(message: string): ToolNextStepHint;
1469
+ declare function retryNext(message: string, suggestedInput?: Record<string, unknown>): ToolNextStepHint;
1470
+
1471
+ declare function toSpellRef(spell: Spell): ToolEntityRef;
1472
+ declare function toSpellPathRef(path: string, name?: string, tier?: string): ToolEntityRef;
1473
+ declare function toNoteRef(note: SpellNote): ToolEntityRef;
1474
+ declare function toDraftRef(draft: SpellDraft): ToolEntityRef;
1475
+ declare function toProvenanceRef(prov: Provenance): ToolEntityRef;
1476
+ declare function toIndexEntryRef(entry: IndexEntry): ToolEntityRef;
1477
+
1478
+ declare const grimoireTools: readonly [GrimoireToolDefinition<{
1479
+ query: string;
1480
+ chapters?: string[];
1481
+ }, ToolResult<{
1482
+ results: IndexEntry[];
1483
+ count: number;
1484
+ }>>, GrimoireToolDefinition<{
1485
+ view: "chapters" | "provenance" | "notes" | "health" | "drafts" | "validation" | "resonance" | "index";
1486
+ limit?: number;
1487
+ now?: number;
1488
+ }, ToolResult<Record<string, unknown>>>, GrimoireToolDefinition<{
1489
+ path: string;
1490
+ }, ToolResult<{
1491
+ spell: Spell;
1492
+ tierInfo: TierInfo;
1493
+ validation: SpellValidationResult;
1494
+ resonance?: ResonanceResult;
1495
+ provenance?: Provenance;
1496
+ history?: HistoryEntry[];
1497
+ }>>, GrimoireToolDefinition<{
1498
+ name: string;
1499
+ content: string;
1500
+ chapter?: string;
1501
+ }, ToolResult<{
1502
+ spell: Spell;
1503
+ warnings: DuplicationWarning[];
1504
+ }>>, GrimoireToolDefinition<{
1505
+ paths?: string[];
1506
+ message?: string;
1507
+ }, ToolResult<{
1508
+ commitHash: string;
1509
+ sealedPaths: string[];
1510
+ ranks: Record<string, number>;
1511
+ tiers: Record<string, TierInfo>;
1512
+ }>>, GrimoireToolDefinition<{
1513
+ action: "shelve";
1514
+ path: string;
1515
+ } | {
1516
+ action: "unshelve";
1517
+ path: string;
1518
+ } | {
1519
+ action: "move";
1520
+ path: string;
1521
+ target: string;
1522
+ } | {
1523
+ action: "delete";
1524
+ path: string;
1525
+ } | {
1526
+ action: "repair";
1527
+ path: string;
1528
+ } | {
1529
+ action: "repair_all";
1530
+ } | {
1531
+ action: "rollback";
1532
+ path: string;
1533
+ ref: string;
1534
+ }, ToolResult<Record<string, unknown>>>, GrimoireToolDefinition<{
1535
+ content: string;
1536
+ source: string;
1537
+ domain?: string;
1538
+ }, ToolResult<{
1539
+ noteId: number;
1540
+ }>>, GrimoireToolDefinition<{
1541
+ action: "submit";
1542
+ title: string;
1543
+ rationale: string;
1544
+ noteIds: number[];
1545
+ chapter: string;
1546
+ } | {
1547
+ action: "approve";
1548
+ draftId: number;
1549
+ } | {
1550
+ action: "dismiss";
1551
+ draftId: number;
1552
+ }, ToolResult<Record<string, unknown>>>, GrimoireToolDefinition<{
1553
+ now?: number;
1554
+ }, ToolResult<CatalogueSnapshot>>, GrimoireToolDefinition<{
1555
+ action: "adopt";
1556
+ source: string;
1557
+ chapter?: string;
1558
+ } | {
1559
+ action: "search";
1560
+ query: string;
1561
+ } | {
1562
+ action: "check_updates";
1563
+ } | {
1564
+ action: "apply_update";
1565
+ path: string;
1566
+ }, ToolResult<Record<string, unknown>>>];
1567
+ declare function listGrimoireToolDefinitions(): ToolDefinitionRegistry;
1568
+ declare function getGrimoireToolByName(name: string): GrimoireToolDefinition<{
1569
+ content: string;
1570
+ source: string;
1571
+ domain?: string;
1572
+ }, ToolResult<{
1573
+ noteId: number;
1574
+ }>> | GrimoireToolDefinition<{
1575
+ paths?: string[];
1576
+ message?: string;
1577
+ }, ToolResult<{
1578
+ commitHash: string;
1579
+ sealedPaths: string[];
1580
+ ranks: Record<string, number>;
1581
+ tiers: Record<string, TierInfo>;
1582
+ }>> | GrimoireToolDefinition<{
1583
+ name: string;
1584
+ content: string;
1585
+ chapter?: string;
1586
+ }, ToolResult<{
1587
+ spell: Spell;
1588
+ warnings: DuplicationWarning[];
1589
+ }>> | GrimoireToolDefinition<{
1590
+ path: string;
1591
+ }, ToolResult<{
1592
+ spell: Spell;
1593
+ tierInfo: TierInfo;
1594
+ validation: SpellValidationResult;
1595
+ resonance?: ResonanceResult;
1596
+ provenance?: Provenance;
1597
+ history?: HistoryEntry[];
1598
+ }>> | GrimoireToolDefinition<{
1599
+ action: "submit";
1600
+ title: string;
1601
+ rationale: string;
1602
+ noteIds: number[];
1603
+ chapter: string;
1604
+ } | {
1605
+ action: "approve";
1606
+ draftId: number;
1607
+ } | {
1608
+ action: "dismiss";
1609
+ draftId: number;
1610
+ }, ToolResult<Record<string, unknown>>> | GrimoireToolDefinition<{
1611
+ action: "shelve";
1612
+ path: string;
1613
+ } | {
1614
+ action: "unshelve";
1615
+ path: string;
1616
+ } | {
1617
+ action: "move";
1618
+ path: string;
1619
+ target: string;
1620
+ } | {
1621
+ action: "delete";
1622
+ path: string;
1623
+ } | {
1624
+ action: "repair";
1625
+ path: string;
1626
+ } | {
1627
+ action: "repair_all";
1628
+ } | {
1629
+ action: "rollback";
1630
+ path: string;
1631
+ ref: string;
1632
+ }, ToolResult<Record<string, unknown>>> | GrimoireToolDefinition<{
1633
+ view: "chapters" | "provenance" | "notes" | "health" | "drafts" | "validation" | "resonance" | "index";
1634
+ limit?: number;
1635
+ now?: number;
1636
+ }, ToolResult<Record<string, unknown>>> | GrimoireToolDefinition<{
1637
+ now?: number;
1638
+ }, ToolResult<CatalogueSnapshot>> | GrimoireToolDefinition<{
1639
+ action: "adopt";
1640
+ source: string;
1641
+ chapter?: string;
1642
+ } | {
1643
+ action: "search";
1644
+ query: string;
1645
+ } | {
1646
+ action: "check_updates";
1647
+ } | {
1648
+ action: "apply_update";
1649
+ path: string;
1650
+ }, ToolResult<Record<string, unknown>>> | GrimoireToolDefinition<{
1651
+ query: string;
1652
+ chapters?: string[];
1653
+ }, ToolResult<{
1654
+ results: IndexEntry[];
1655
+ count: number;
1656
+ }>> | undefined;
1657
+
1658
+ declare function summarizeCount(count: number, singular: string, plural?: string): string;
1659
+ declare function summarizeSpellAction(action: string, path: string): string;
1660
+
1661
+ type index_GrimoireToolContext = GrimoireToolContext;
1662
+ type index_GrimoireToolDefinition<TInput = Record<string, unknown>, TResult extends ToolResult<unknown> = ToolResult<unknown>> = GrimoireToolDefinition<TInput, TResult>;
1663
+ type index_JsonSchema = JsonSchema;
1664
+ type index_JsonSchemaType = JsonSchemaType;
1665
+ type index_ToolBaseResult = ToolBaseResult;
1666
+ type index_ToolClarificationCode = ToolClarificationCode;
1667
+ type index_ToolDefinitionRegistry = ToolDefinitionRegistry;
1668
+ type index_ToolEntityKind = ToolEntityKind;
1669
+ type index_ToolEntityKindSet = ToolEntityKindSet;
1670
+ type index_ToolEntityRef = ToolEntityRef;
1671
+ type index_ToolErrorCode = ToolErrorCode;
1672
+ type index_ToolErrorKind = ToolErrorKind;
1673
+ type index_ToolFailure = ToolFailure;
1674
+ type index_ToolInputDescriptions = ToolInputDescriptions;
1675
+ type index_ToolMappingEntry = ToolMappingEntry;
1676
+ type index_ToolNeedsClarification = ToolNeedsClarification;
1677
+ type index_ToolNextStepHint = ToolNextStepHint;
1678
+ type index_ToolNextStepHintKind = ToolNextStepHintKind;
1679
+ type index_ToolOutcomeKind = ToolOutcomeKind;
1680
+ type index_ToolOutputDescription = ToolOutputDescription;
1681
+ type index_ToolResult<TData> = ToolResult<TData>;
1682
+ type index_ToolSideEffects = ToolSideEffects;
1683
+ type index_ToolSuccess<TData> = ToolSuccess<TData>;
1684
+ type index_ToolWarning = ToolWarning;
1685
+ type index_ToolWarningCode = ToolWarningCode;
1686
+ declare const index_arraySchema: typeof arraySchema;
1687
+ declare const index_askUserNext: typeof askUserNext;
1688
+ declare const index_booleanSchema: typeof booleanSchema;
1689
+ declare const index_catalogueNext: typeof catalogueNext;
1690
+ declare const index_defineGrimoireTool: typeof defineGrimoireTool;
1691
+ declare const index_dropNoteTool: typeof dropNoteTool;
1692
+ declare const index_dropNoteToolName: typeof dropNoteToolName;
1693
+ declare const index_enumSchema: typeof enumSchema;
1694
+ declare const index_getGrimoireToolByName: typeof getGrimoireToolByName;
1695
+ declare const index_grimoireTools: typeof grimoireTools;
1696
+ declare const index_honeNext: typeof honeNext;
1697
+ declare const index_honeSpellTool: typeof honeSpellTool;
1698
+ declare const index_honeSpellToolName: typeof honeSpellToolName;
1699
+ declare const index_inscribeSpellTool: typeof inscribeSpellTool;
1700
+ declare const index_inscribeSpellToolName: typeof inscribeSpellToolName;
1701
+ declare const index_inspectGrimoireItemTool: typeof inspectGrimoireItemTool;
1702
+ declare const index_inspectGrimoireItemToolName: typeof inspectGrimoireItemToolName;
1703
+ declare const index_inspectSpellNext: typeof inspectSpellNext;
1704
+ declare const index_integerSchema: typeof integerSchema;
1705
+ declare const index_listGrimoireToolDefinitions: typeof listGrimoireToolDefinitions;
1706
+ declare const index_literalSchema: typeof literalSchema;
1707
+ declare const index_manageDraftTool: typeof manageDraftTool;
1708
+ declare const index_manageDraftToolName: typeof manageDraftToolName;
1709
+ declare const index_manageSpellNext: typeof manageSpellNext;
1710
+ declare const index_manageSpellTool: typeof manageSpellTool;
1711
+ declare const index_manageSpellToolName: typeof manageSpellToolName;
1712
+ declare const index_numberSchema: typeof numberSchema;
1713
+ declare const index_objectSchema: typeof objectSchema;
1714
+ declare const index_oneOfSchema: typeof oneOfSchema;
1715
+ declare const index_retryNext: typeof retryNext;
1716
+ declare const index_reviewGrimoireTool: typeof reviewGrimoireTool;
1717
+ declare const index_reviewGrimoireToolName: typeof reviewGrimoireToolName;
1718
+ declare const index_reviewViewNext: typeof reviewViewNext;
1719
+ declare const index_runCatalogueTool: typeof runCatalogueTool;
1720
+ declare const index_runCatalogueToolName: typeof runCatalogueToolName;
1721
+ declare const index_scoutSkillsTool: typeof scoutSkillsTool;
1722
+ declare const index_scoutSkillsToolName: typeof scoutSkillsToolName;
1723
+ declare const index_searchGrimoireTool: typeof searchGrimoireTool;
1724
+ declare const index_searchGrimoireToolName: typeof searchGrimoireToolName;
1725
+ declare const index_searchNext: typeof searchNext;
1726
+ declare const index_stringSchema: typeof stringSchema;
1727
+ declare const index_summarizeCount: typeof summarizeCount;
1728
+ declare const index_summarizeSpellAction: typeof summarizeSpellAction;
1729
+ declare const index_toDraftRef: typeof toDraftRef;
1730
+ declare const index_toIndexEntryRef: typeof toIndexEntryRef;
1731
+ declare const index_toNoteRef: typeof toNoteRef;
1732
+ declare const index_toProvenanceRef: typeof toProvenanceRef;
1733
+ declare const index_toSpellPathRef: typeof toSpellPathRef;
1734
+ declare const index_toSpellRef: typeof toSpellRef;
1735
+ declare const index_toolFailure: typeof toolFailure;
1736
+ declare const index_toolMapping: typeof toolMapping;
1737
+ declare const index_toolNeedsClarification: typeof toolNeedsClarification;
1738
+ declare const index_toolNoOp: typeof toolNoOp;
1739
+ declare const index_toolSuccess: typeof toolSuccess;
1740
+ declare const index_toolWarning: typeof toolWarning;
1741
+ declare const index_translateToolError: typeof translateToolError;
1742
+ declare const index_useToolNext: typeof useToolNext;
1743
+ declare const index_withToolHandling: typeof withToolHandling;
1744
+ declare namespace index {
1745
+ export { type index_GrimoireToolContext as GrimoireToolContext, type index_GrimoireToolDefinition as GrimoireToolDefinition, type index_JsonSchema as JsonSchema, type index_JsonSchemaType as JsonSchemaType, type index_ToolBaseResult as ToolBaseResult, type index_ToolClarificationCode as ToolClarificationCode, type index_ToolDefinitionRegistry as ToolDefinitionRegistry, type index_ToolEntityKind as ToolEntityKind, type index_ToolEntityKindSet as ToolEntityKindSet, type index_ToolEntityRef as ToolEntityRef, type index_ToolErrorCode as ToolErrorCode, type index_ToolErrorKind as ToolErrorKind, type index_ToolFailure as ToolFailure, type index_ToolInputDescriptions as ToolInputDescriptions, type index_ToolMappingEntry as ToolMappingEntry, type index_ToolNeedsClarification as ToolNeedsClarification, type index_ToolNextStepHint as ToolNextStepHint, type index_ToolNextStepHintKind as ToolNextStepHintKind, type index_ToolOutcomeKind as ToolOutcomeKind, type index_ToolOutputDescription as ToolOutputDescription, type index_ToolResult as ToolResult, type index_ToolSideEffects as ToolSideEffects, type index_ToolSuccess as ToolSuccess, type index_ToolWarning as ToolWarning, type index_ToolWarningCode as ToolWarningCode, index_arraySchema as arraySchema, index_askUserNext as askUserNext, index_booleanSchema as booleanSchema, index_catalogueNext as catalogueNext, index_defineGrimoireTool as defineGrimoireTool, index_dropNoteTool as dropNoteTool, index_dropNoteToolName as dropNoteToolName, index_enumSchema as enumSchema, index_getGrimoireToolByName as getGrimoireToolByName, index_grimoireTools as grimoireTools, index_honeNext as honeNext, index_honeSpellTool as honeSpellTool, index_honeSpellToolName as honeSpellToolName, index_inscribeSpellTool as inscribeSpellTool, index_inscribeSpellToolName as inscribeSpellToolName, index_inspectGrimoireItemTool as inspectGrimoireItemTool, index_inspectGrimoireItemToolName as inspectGrimoireItemToolName, index_inspectSpellNext as inspectSpellNext, index_integerSchema as integerSchema, index_listGrimoireToolDefinitions as listGrimoireToolDefinitions, index_literalSchema as literalSchema, index_manageDraftTool as manageDraftTool, index_manageDraftToolName as manageDraftToolName, index_manageSpellNext as manageSpellNext, index_manageSpellTool as manageSpellTool, index_manageSpellToolName as manageSpellToolName, index_numberSchema as numberSchema, index_objectSchema as objectSchema, index_oneOfSchema as oneOfSchema, index_retryNext as retryNext, index_reviewGrimoireTool as reviewGrimoireTool, index_reviewGrimoireToolName as reviewGrimoireToolName, index_reviewViewNext as reviewViewNext, index_runCatalogueTool as runCatalogueTool, index_runCatalogueToolName as runCatalogueToolName, index_scoutSkillsTool as scoutSkillsTool, index_scoutSkillsToolName as scoutSkillsToolName, index_searchGrimoireTool as searchGrimoireTool, index_searchGrimoireToolName as searchGrimoireToolName, index_searchNext as searchNext, index_stringSchema as stringSchema, index_summarizeCount as summarizeCount, index_summarizeSpellAction as summarizeSpellAction, index_toDraftRef as toDraftRef, index_toIndexEntryRef as toIndexEntryRef, index_toNoteRef as toNoteRef, index_toProvenanceRef as toProvenanceRef, index_toSpellPathRef as toSpellPathRef, index_toSpellRef as toSpellRef, index_toolFailure as toolFailure, index_toolMapping as toolMapping, index_toolNeedsClarification as toolNeedsClarification, index_toolNoOp as toolNoOp, index_toolSuccess as toolSuccess, index_toolWarning as toolWarning, index_translateToolError as translateToolError, index_useToolNext as useToolNext, index_withToolHandling as withToolHandling };
1746
+ }
1747
+
1748
+ declare function withTransaction<T>(db: GrimoireDb, fn: () => T): T;
1749
+
1750
+ declare const write_adoptSpell: typeof adoptSpell;
1751
+ declare const write_adoptSpells: typeof adoptSpells;
1752
+ declare const write_approveDraft: typeof approveDraft;
1753
+ declare const write_catalogue: typeof catalogue;
1754
+ declare const write_deleteSpell: typeof deleteSpell;
1755
+ declare const write_dismissDraft: typeof dismissDraft;
1756
+ declare const write_distill: typeof distill;
1757
+ declare const write_dropNote: typeof dropNote;
1758
+ declare const write_dropNotes: typeof dropNotes;
1759
+ declare const write_enforceNoteCap: typeof enforceNoteCap;
1760
+ declare const write_expireNotes: typeof expireNotes;
1761
+ declare const write_inscribe: typeof inscribe;
1762
+ declare const write_logEvent: typeof logEvent;
1763
+ declare const write_moveSpell: typeof moveSpell;
1764
+ declare const write_repair: typeof repair;
1765
+ declare const write_repairAll: typeof repairAll;
1766
+ declare const write_rollback: typeof rollback;
1767
+ declare const write_seal: typeof seal;
1768
+ declare const write_shelve: typeof shelve;
1769
+ declare const write_submitDraft: typeof submitDraft;
1770
+ declare const write_unshelve: typeof unshelve;
1771
+ declare namespace write {
1772
+ export { write_adoptSpell as adoptSpell, write_adoptSpells as adoptSpells, write_approveDraft as approveDraft, write_catalogue as catalogue, write_deleteSpell as deleteSpell, write_dismissDraft as dismissDraft, write_distill as distill, write_dropNote as dropNote, write_dropNotes as dropNotes, write_enforceNoteCap as enforceNoteCap, write_expireNotes as expireNotes, write_inscribe as inscribe, write_logEvent as logEvent, write_moveSpell as moveSpell, write_repair as repair, write_repairAll as repairAll, write_rollback as rollback, write_seal as seal, write_shelve as shelve, write_submitDraft as submitDraft, write_unshelve as unshelve };
1773
+ }
1774
+
1775
+ export { DEFAULTS, type GrimoireDb, GrimoireError, type GrimoireErrorCode, GrimoireInvariantError, GrimoireNotFoundError, type GrimoireRunResult, type GrimoireSkill, type GrimoireSkillRegistry, type GrimoireSoul, type GrimoireSoulTrait, GrimoireStateError, type GrimoireStatement, GrimoireValidationError, archiveAndPruneSpellsSkill, index$e as catalogue, decomposeOversizedSpellsSkill, defineGrimoireSkill, distillNotesIntoSpellsSkill, index$d as drafts, index$c as events, evolveSpellThroughTiersSkill, getGrimoireSkillByName, index$b as git, grimoireSkills, grimoireSoul, grimoireSoulEssence, grimoireSoulTraits, handleEdgeCasesGracefullySkill, index$a as health, honeSpellFromEvidenceSkill, index$9 as indexing, init, initGrimoireTables, inscribeSpellsCorrectlySkill, isGrimoireError, listGrimoireSkills, maintainGrimoireHealthSkill, network, index$6 as notes, index$5 as provenance, read, reconcileUpstreamUpdatesSkill, index$8 as registry, renderGrimoireSoulPromptFoundation, reorganizeSpellChaptersSkill, resolveNow, resolveValidationFailuresSkill, scoutAndAdoptSkillsSkill, index$7 as scouting, searchAndRetrieveSpellsSkill, index$1 as skills, soul, index$4 as spec, index$3 as spells, index as tools, index$2 as validation, withTransaction, write };