pi-knowledge 0.13.0 → 0.15.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.
@@ -1,4 +1,5 @@
1
1
  import { type DiagnosticResult } from "./diagnostics/health.ts";
2
+ import type { EmbeddingCompatibility } from "./embedding/provider.ts";
2
3
  import { createSkippedScanStats } from "./indexer/chunker.ts";
3
4
  import { type RankingDiagnostics } from "./search/ranking.ts";
4
5
  import { type SearchProfile, type SearchTuningSummary } from "./search/tuning.ts";
@@ -37,6 +38,40 @@ export interface SearchResult {
37
38
  };
38
39
  }
39
40
  export { CURRENT_EMBEDDING_MODEL } from "./embedding/provider.ts";
41
+ export type SearchMissReason = "no_knowledge_bases" | "knowledge_base_not_found" | "no_searchable_knowledge_bases" | "no_indexed_chunks" | "embedding_incompatible" | "no_retrieval_candidates" | "threshold_filtered" | "evidence_filtered" | "metadata_filtered" | "reranker_empty" | "page_out_of_range" | "no_match";
42
+ export type SearchMissAction = "add_knowledge_base" | "fix_kb_id" | "wait_for_indexing" | "fix_knowledge_base" | "fix_embedding" | "try_semantic" | "try_semantic_hybrid" | "relax_filter" | "reset_offset" | "rephrase";
43
+ export interface SearchKnowledgeBaseSummary {
44
+ id: string;
45
+ name: string;
46
+ status: KnowledgeBase["status"];
47
+ chunk_count: number;
48
+ }
49
+ export interface SearchAttemptSummary {
50
+ mode: SearchMode;
51
+ reason?: SearchMissReason;
52
+ retrieved_candidates: number;
53
+ threshold_candidates: number;
54
+ eligible_candidates: number;
55
+ filtered_candidates: number;
56
+ result_count: number;
57
+ }
58
+ export interface SearchMiss {
59
+ reason: SearchMissReason;
60
+ action: SearchMissAction;
61
+ requested_kb_id?: string;
62
+ file_type?: string;
63
+ path_pattern?: string;
64
+ min_hybrid_score?: number;
65
+ searched_kbs: SearchKnowledgeBaseSummary[];
66
+ skipped_kbs: SearchKnowledgeBaseSummary[];
67
+ retrieved_candidates: number;
68
+ threshold_candidates: number;
69
+ eligible_candidates: number;
70
+ filtered_candidates: number;
71
+ ranked_candidates: number;
72
+ total_results: number;
73
+ attempts?: SearchAttemptSummary[];
74
+ }
40
75
  export interface SearchResponse {
41
76
  results: SearchResult[];
42
77
  total_count: number;
@@ -44,8 +79,8 @@ export interface SearchResponse {
44
79
  warnings?: string[];
45
80
  mode_used?: SearchMode;
46
81
  retry_modes?: SearchMode[];
47
- suggestions?: string[];
48
82
  tuning?: SearchTuningSummary;
83
+ miss?: SearchMiss;
49
84
  }
50
85
  export type ProgressCallback = (msg: string) => void;
51
86
  export interface AddOptions {
@@ -58,7 +93,7 @@ export interface DoctorIssue {
58
93
  kb_name?: string;
59
94
  message: string;
60
95
  action: string;
61
- action_code?: "run_update" | "rebuild_kb" | "wait_for_indexing" | "review_skipped_scope" | "rebuild_vectors" | "reindex_for_embedding_budget" | "check_source" | "none";
96
+ action_code?: "run_update" | "rebuild_kb" | "wait_for_indexing" | "review_skipped_scope" | "fix_embedding_config" | "rebuild_vectors" | "reindex_for_embedding_budget" | "check_source" | "none";
62
97
  }
63
98
  export interface DoctorReport {
64
99
  health_score: number;
@@ -72,6 +107,21 @@ export interface DoctorReport {
72
107
  description: string;
73
108
  }>;
74
109
  }
110
+ export interface KnowledgeBaseEmbeddingStatus {
111
+ kb_id: string;
112
+ kb_name: string;
113
+ indexed_model: string | null;
114
+ active_model: string;
115
+ active_decoration: string;
116
+ compatibility: EmbeddingCompatibility;
117
+ detail: string;
118
+ }
119
+ export interface KnowledgeStatusSnapshot {
120
+ knowledge_bases: KnowledgeBase[];
121
+ diagnostics: DiagnosticResult[];
122
+ embeddings: KnowledgeBaseEmbeddingStatus[];
123
+ embedding_error?: string;
124
+ }
75
125
  export interface SymbolSearchOptions {
76
126
  kb_id?: string;
77
127
  kind?: KnowledgeSymbol["kind"];
@@ -80,6 +130,20 @@ export interface SymbolSearchOptions {
80
130
  offset?: number;
81
131
  exact?: boolean;
82
132
  }
133
+ export type SymbolSearchMissReason = "no_knowledge_bases" | "knowledge_base_not_found" | "no_searchable_knowledge_bases" | "symbol_index_empty" | "exact_name_not_found" | "metadata_filtered" | "page_out_of_range" | "no_match";
134
+ export type SymbolSearchMissAction = "add_knowledge_base" | "fix_kb_id" | "wait_for_indexing" | "fix_knowledge_base" | "rebuild_symbol_index" | "broaden_symbol_search" | "relax_filter" | "reset_offset" | "use_text_search";
135
+ export interface SymbolSearchMiss {
136
+ reason: SymbolSearchMissReason;
137
+ action: SymbolSearchMissAction;
138
+ requested_kb_id?: string;
139
+ kind?: KnowledgeSymbol["kind"];
140
+ file_pattern?: string;
141
+ exact: boolean;
142
+ searched_kbs: SearchKnowledgeBaseSummary[];
143
+ skipped_kbs: SearchKnowledgeBaseSummary[];
144
+ indexed_symbols: number;
145
+ unfiltered_matches: number;
146
+ }
83
147
  export interface SymbolSearchResponse {
84
148
  results: Array<{
85
149
  name: string;
@@ -96,6 +160,7 @@ export interface SymbolSearchResponse {
96
160
  }>;
97
161
  total_count: number;
98
162
  has_more: boolean;
163
+ miss?: SymbolSearchMiss;
99
164
  }
100
165
  export declare const CURRENT_URL_STRUCTURE_POLICY = 1;
101
166
  export declare const CURRENT_EMBEDDING_INPUT_POLICY = 2;
@@ -133,6 +198,7 @@ export declare class KnowledgeEngine {
133
198
  list(signal?: AbortSignal): KnowledgeBase[];
134
199
  clear(): void;
135
200
  diagnose(signal?: AbortSignal): DiagnosticResult[];
201
+ statusSnapshot(signal?: AbortSignal): KnowledgeStatusSnapshot;
136
202
  symbolSearch(query: string, options?: SymbolSearchOptions, signal?: AbortSignal): SymbolSearchResponse;
137
203
  doctor(signal?: AbortSignal): DoctorReport;
138
204
  exportKB(nameOrId: string, outputPath: string, signal?: AbortSignal, onProgress?: ProgressCallback): Promise<number>;