@@ -9,7 +9,7 @@ import { parseSkill, isValidSkillDirectory } from "../Skills/parser";
99import { formatSkillItems } from "../Skills/formatSkillItems" ;
1010import { Skill } from "../Skills/types" ;
1111import { InsightAction } from "./Extractor/IInsightExtractor" ;
12- import { UsageTracker } from "../Utils/UsageTracker" ;
12+ import { UsageTracker , UsageState } from "../Utils/UsageTracker" ;
1313import { HybridSearcher } from "../Retrieval" ;
1414import { IInsightExtractor } from "./Extractor/IInsightExtractor" ;
1515
@@ -41,7 +41,6 @@ export class InsightService implements IInsightService {
4141
4242 @init ( )
4343 async initialize ( ) : Promise < void > {
44- this . logger ?. debug ( `initialize: insightDir=${ this . insightDir } , limit=${ this . insightLimit } , staleDays=${ this . staleDays } , archiveDays=${ this . archiveDays } , hasEmbeddings=${ ! ! this . embeddings } ` ) ;
4544 this . curate ( ) ;
4645 }
4746
@@ -52,13 +51,10 @@ export class InsightService implements IInsightService {
5251 }
5352
5453 async extractFromConversation ( userMessage : string , assistantMessages ?: string [ ] ) : Promise < void > {
55- this . logger ?. debug ( `extractFromConversation: userMessage length=${ userMessage . length } , assistantMessages=${ assistantMessages ?. length ?? 0 } ` ) ;
5654 try {
5755 const insights = this . getAllInsights ( ) ;
5856 const existingNames = insights . map ( s => s . name ) ;
59- this . logger ?. debug ( `extractFromConversation: existing insights=[${ existingNames . join ( ', ' ) } ]` ) ;
6057 const extracted = await this . extractor . extract ( userMessage , assistantMessages ?? [ ] , existingNames ) ;
61- this . logger ?. debug ( `extractFromConversation: extractor returned ${ extracted . length } items` ) ;
6258
6359 for ( const item of extracted ) {
6460 if ( item . action === InsightAction . Delete ) {
@@ -111,7 +107,6 @@ ${item.content}`;
111107 async getRelevantInsights ( query : string , limit ?: number ) : Promise < Skill [ ] > {
112108 const max = limit ?? this . insightLimit ! ;
113109 const insights = this . getAllInsights ( ) ;
114- this . logger ?. debug ( `getRelevantInsights: query="${ query . slice ( 0 , 80 ) } ", total=${ insights . length } , max=${ max } ` ) ;
115110 if ( insights . length === 0 ) return [ ] ;
116111
117112 let selected : Skill [ ] ;
@@ -120,15 +115,13 @@ ${item.content}`;
120115 } else {
121116 selected = ( await this . searcher . search ( query , insights , toSearchable , max ) ) . map ( r => r . item ) ;
122117 }
123- this . logger ?. debug ( `getRelevantInsights: selected ${ selected . length } insights: [${ selected . map ( s => s . name ) . join ( ', ' ) } ]` ) ;
124118 return selected ;
125119 }
126120
127121 // ── Curator ──
128122
129123 private curate ( ) : void {
130124 const insights = this . getAllInsights ( ) ;
131- this . logger ?. debug ( `curate: checking ${ insights . length } insights for staleness/archival` ) ;
132125 for ( const insight of insights ) {
133126 const tracker = new UsageTracker ( insight . path ) ;
134127 const usage = tracker . get ( ) ;
@@ -138,8 +131,8 @@ ${item.content}`;
138131
139132 if ( daysSince >= this . archiveDays ! ) {
140133 this . archiveInsight ( insight , usage ) ;
141- } else if ( daysSince >= this . staleDays ! && usage . state === 'active' ) {
142- usage . state = 'stale' ;
134+ } else if ( daysSince >= this . staleDays ! && usage . state === UsageState . Active ) {
135+ usage . state = UsageState . Stale ;
143136 tracker . save ( usage ) ;
144137 this . logger ?. info ( `Insight marked stale: ${ insight . name } (${ Math . round ( daysSince ) } d inactive)` ) ;
145138 }
@@ -154,7 +147,7 @@ ${item.content}`;
154147 const archiveDest = path . join ( archiveBase , `${ insight . name } _${ timestamp } ` ) ;
155148 fs . renameSync ( insight . path , archiveDest ) ;
156149 if ( usage ) {
157- usage . state = 'archived' ;
150+ usage . state = UsageState . Archived ;
158151 fs . writeFileSync ( path . join ( archiveDest , '.usage.json' ) , JSON . stringify ( usage , null , 2 ) , 'utf-8' ) ;
159152 }
160153 this . logger ?. info ( `Insight auto-archived: ${ insight . name } → ${ archiveDest } ` ) ;
@@ -176,7 +169,7 @@ ${item.content}`;
176169 const insight = parseSkill ( dir ) ;
177170 if ( ! insight ) continue ;
178171 const usage = new UsageTracker ( dir ) . get ( ) ;
179- if ( usage ?. state === 'archived' ) continue ;
172+ if ( usage ?. state === UsageState . Archived ) continue ;
180173 insights . push ( insight ) ;
181174 }
182175 } catch ( e : any ) {
0 commit comments