claude-cognitive 0.3.2 → 0.4.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.
- package/README.md +57 -35
- package/dist/agents/context.d.ts.map +1 -1
- package/dist/agents/context.js +7 -7
- package/dist/agents/context.js.map +1 -1
- package/dist/cli/commands/feedback-stats.d.ts +10 -0
- package/dist/cli/commands/feedback-stats.d.ts.map +1 -0
- package/dist/cli/commands/feedback-stats.js +70 -0
- package/dist/cli/commands/feedback-stats.js.map +1 -0
- package/dist/cli/commands/feedback-sync.d.ts +10 -0
- package/dist/cli/commands/feedback-sync.d.ts.map +1 -0
- package/dist/cli/commands/feedback-sync.js +117 -0
- package/dist/cli/commands/feedback-sync.js.map +1 -0
- package/dist/cli/commands/index.d.ts +2 -0
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +2 -0
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/install.d.ts.map +1 -1
- package/dist/cli/commands/install.js +130 -4
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/semantic.d.ts +4 -2
- package/dist/cli/commands/semantic.d.ts.map +1 -1
- package/dist/cli/commands/semantic.js +8 -57
- package/dist/cli/commands/semantic.js.map +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +0 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/sync.d.ts +4 -2
- package/dist/cli/commands/sync.d.ts.map +1 -1
- package/dist/cli/commands/sync.js +9 -250
- package/dist/cli/commands/sync.js.map +1 -1
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/commands/update.js +106 -1
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/index.js +3 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils/output.d.ts +0 -2
- package/dist/cli/utils/output.d.ts.map +1 -1
- package/dist/cli/utils/output.js +0 -2
- package/dist/cli/utils/output.js.map +1 -1
- package/dist/client.d.ts +121 -22
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +209 -36
- package/dist/client.js.map +1 -1
- package/dist/events.d.ts +30 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/feedback/constants.d.ts +72 -0
- package/dist/feedback/constants.d.ts.map +1 -0
- package/dist/feedback/constants.js +145 -0
- package/dist/feedback/constants.js.map +1 -0
- package/dist/feedback/detector.d.ts +75 -0
- package/dist/feedback/detector.d.ts.map +1 -0
- package/dist/feedback/detector.js +393 -0
- package/dist/feedback/detector.js.map +1 -0
- package/dist/feedback/index.d.ts +85 -0
- package/dist/feedback/index.d.ts.map +1 -0
- package/dist/feedback/index.js +194 -0
- package/dist/feedback/index.js.map +1 -0
- package/dist/feedback/offline-queue.d.ts +110 -0
- package/dist/feedback/offline-queue.d.ts.map +1 -0
- package/dist/feedback/offline-queue.js +188 -0
- package/dist/feedback/offline-queue.js.map +1 -0
- package/dist/feedback/scorer.d.ts +81 -0
- package/dist/feedback/scorer.d.ts.map +1 -0
- package/dist/feedback/scorer.js +194 -0
- package/dist/feedback/scorer.js.map +1 -0
- package/dist/feedback/similarity.d.ts +19 -0
- package/dist/feedback/similarity.d.ts.map +1 -0
- package/dist/feedback/similarity.js +49 -0
- package/dist/feedback/similarity.js.map +1 -0
- package/dist/feedback/tracker.d.ts +104 -0
- package/dist/feedback/tracker.d.ts.map +1 -0
- package/dist/feedback/tracker.js +324 -0
- package/dist/feedback/tracker.js.map +1 -0
- package/dist/hooks/process-session.d.ts.map +1 -1
- package/dist/hooks/process-session.js +17 -8
- package/dist/hooks/process-session.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/learn/index.d.ts.map +1 -1
- package/dist/learn/index.js +6 -2
- package/dist/learn/index.js.map +1 -1
- package/dist/mcp/handlers.d.ts +9 -1
- package/dist/mcp/handlers.d.ts.map +1 -1
- package/dist/mcp/handlers.js +66 -0
- package/dist/mcp/handlers.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +42 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.d.ts +77 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +30 -0
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/types.d.ts +16 -0
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mind.d.ts +47 -28
- package/dist/mind.d.ts.map +1 -1
- package/dist/mind.js +351 -104
- package/dist/mind.js.map +1 -1
- package/dist/offline.d.ts +111 -0
- package/dist/offline.d.ts.map +1 -0
- package/dist/offline.js +198 -0
- package/dist/offline.js.map +1 -0
- package/dist/types.d.ts +171 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feedback Loop Constants
|
|
3
|
+
*
|
|
4
|
+
* Centralized configuration for detection thresholds, trigger patterns,
|
|
5
|
+
* and default values for the memory feedback loop system.
|
|
6
|
+
*
|
|
7
|
+
* @module feedback/constants
|
|
8
|
+
*/
|
|
9
|
+
import type { FeedbackConfig } from "../types.js";
|
|
10
|
+
/** Confidence score for explicit reference detection (highest confidence) */
|
|
11
|
+
export declare const EXPLICIT_CONFIDENCE = 0.95;
|
|
12
|
+
/**
|
|
13
|
+
* Similarity threshold for semantic matching (Jaccard similarity)
|
|
14
|
+
* Lower than dedup threshold (0.85) to catch paraphrased content
|
|
15
|
+
*/
|
|
16
|
+
export declare const SEMANTIC_THRESHOLD = 0.5;
|
|
17
|
+
/** Maximum confidence for semantic matches (scaled down from explicit) */
|
|
18
|
+
export declare const SEMANTIC_MAX_CONFIDENCE = 0.85;
|
|
19
|
+
/** Base confidence for behavioral signals (file access, task correlation) */
|
|
20
|
+
export declare const BEHAVIORAL_CONFIDENCE_BASE = 0.4;
|
|
21
|
+
/** Confidence multiplier for file access correlation */
|
|
22
|
+
export declare const FILE_ACCESS_CONFIDENCE = 0.5;
|
|
23
|
+
/** Confidence multiplier for task topic correlation */
|
|
24
|
+
export declare const TASK_TOPIC_CONFIDENCE = 0.4;
|
|
25
|
+
/** Net score threshold above which a fact is considered "used" */
|
|
26
|
+
export declare const USED_THRESHOLD = 0.2;
|
|
27
|
+
/** Net score threshold below which a fact is considered "ignored" */
|
|
28
|
+
export declare const IGNORED_THRESHOLD = -0.2;
|
|
29
|
+
/** Weight applied to negative signals (lower than positive) */
|
|
30
|
+
export declare const NEGATIVE_SIGNAL_WEIGHT = 0.5;
|
|
31
|
+
/** Weight for facts at low positions (position > 15) */
|
|
32
|
+
export declare const LOW_POSITION_WEIGHT = 0.3;
|
|
33
|
+
/** Position threshold for low position signal */
|
|
34
|
+
export declare const LOW_POSITION_THRESHOLD = 15;
|
|
35
|
+
/** Weight for topic mismatch signal */
|
|
36
|
+
export declare const TOPIC_MISMATCH_WEIGHT = 0.5;
|
|
37
|
+
/** Minimum topic overlap to avoid mismatch signal */
|
|
38
|
+
export declare const TOPIC_MISMATCH_THRESHOLD = 0.1;
|
|
39
|
+
/** Weight for files not accessed signal */
|
|
40
|
+
export declare const FILES_NOT_ACCESSED_WEIGHT = 0.3;
|
|
41
|
+
/** Maximum ignore confidence (cap) */
|
|
42
|
+
export declare const MAX_IGNORE_CONFIDENCE = 0.9;
|
|
43
|
+
/**
|
|
44
|
+
* Regex patterns that indicate Claude explicitly referenced context.
|
|
45
|
+
* These are high-confidence signals that a fact was used.
|
|
46
|
+
*/
|
|
47
|
+
export declare const EXPLICIT_TRIGGERS: RegExp[];
|
|
48
|
+
/**
|
|
49
|
+
* Factory function to create fresh regex patterns for file reference extraction.
|
|
50
|
+
* Creates new RegExp instances on each call to avoid shared mutable state issues
|
|
51
|
+
* with the global flag, and includes length limits for ReDoS protection.
|
|
52
|
+
*
|
|
53
|
+
* @returns Fresh array of regex patterns (safe to use with exec/matchAll)
|
|
54
|
+
*/
|
|
55
|
+
export declare function createFileReferencePatterns(): RegExp[];
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated Use createFileReferencePatterns() instead to avoid shared state issues.
|
|
58
|
+
* Kept for backward compatibility but will be removed in next major version.
|
|
59
|
+
*/
|
|
60
|
+
export declare const FILE_REFERENCE_PATTERNS: RegExp[];
|
|
61
|
+
/** Maximum words per chunk when splitting response for comparison */
|
|
62
|
+
export declare const CHUNK_MAX_WORDS = 50;
|
|
63
|
+
/** Word overlap between chunks */
|
|
64
|
+
export declare const CHUNK_OVERLAP_WORDS = 10;
|
|
65
|
+
/** Days to retain recall session data */
|
|
66
|
+
export declare const SESSION_DATA_RETENTION_DAYS = 7;
|
|
67
|
+
/**
|
|
68
|
+
* Default configuration for the feedback loop.
|
|
69
|
+
* Merged with user config from .claudemindrc
|
|
70
|
+
*/
|
|
71
|
+
export declare const DEFAULT_FEEDBACK_CONFIG: FeedbackConfig;
|
|
72
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/feedback/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAMlD,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,0EAA0E;AAC1E,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C,6EAA6E;AAC7E,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,wDAAwD;AACxD,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,uDAAuD;AACvD,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAMzC,kEAAkE;AAClE,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,qEAAqE;AACrE,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAEtC,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAM1C,wDAAwD;AACxD,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,iDAAiD;AACjD,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,uCAAuC;AACvC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,qDAAqD;AACrD,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,2CAA2C;AAC3C,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C,sCAAsC;AACtC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAMzC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,EA8BrC,CAAC;AAMF;;;;;;GAMG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,EAAE,CAStD;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,EAAkC,CAAC;AAM/E,qEAAqE;AACrE,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,kCAAkC;AAClC,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAMtC,yCAAyC;AACzC,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAM7C;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAcrC,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feedback Loop Constants
|
|
3
|
+
*
|
|
4
|
+
* Centralized configuration for detection thresholds, trigger patterns,
|
|
5
|
+
* and default values for the memory feedback loop system.
|
|
6
|
+
*
|
|
7
|
+
* @module feedback/constants
|
|
8
|
+
*/
|
|
9
|
+
// =============================================================================
|
|
10
|
+
// Detection Confidence Thresholds
|
|
11
|
+
// =============================================================================
|
|
12
|
+
/** Confidence score for explicit reference detection (highest confidence) */
|
|
13
|
+
export const EXPLICIT_CONFIDENCE = 0.95;
|
|
14
|
+
/**
|
|
15
|
+
* Similarity threshold for semantic matching (Jaccard similarity)
|
|
16
|
+
* Lower than dedup threshold (0.85) to catch paraphrased content
|
|
17
|
+
*/
|
|
18
|
+
export const SEMANTIC_THRESHOLD = 0.5;
|
|
19
|
+
/** Maximum confidence for semantic matches (scaled down from explicit) */
|
|
20
|
+
export const SEMANTIC_MAX_CONFIDENCE = 0.85;
|
|
21
|
+
/** Base confidence for behavioral signals (file access, task correlation) */
|
|
22
|
+
export const BEHAVIORAL_CONFIDENCE_BASE = 0.4;
|
|
23
|
+
/** Confidence multiplier for file access correlation */
|
|
24
|
+
export const FILE_ACCESS_CONFIDENCE = 0.5;
|
|
25
|
+
/** Confidence multiplier for task topic correlation */
|
|
26
|
+
export const TASK_TOPIC_CONFIDENCE = 0.4;
|
|
27
|
+
// =============================================================================
|
|
28
|
+
// Verdict Thresholds
|
|
29
|
+
// =============================================================================
|
|
30
|
+
/** Net score threshold above which a fact is considered "used" */
|
|
31
|
+
export const USED_THRESHOLD = 0.2;
|
|
32
|
+
/** Net score threshold below which a fact is considered "ignored" */
|
|
33
|
+
export const IGNORED_THRESHOLD = -0.2;
|
|
34
|
+
/** Weight applied to negative signals (lower than positive) */
|
|
35
|
+
export const NEGATIVE_SIGNAL_WEIGHT = 0.5;
|
|
36
|
+
// =============================================================================
|
|
37
|
+
// Negative Signal Weights
|
|
38
|
+
// =============================================================================
|
|
39
|
+
/** Weight for facts at low positions (position > 15) */
|
|
40
|
+
export const LOW_POSITION_WEIGHT = 0.3;
|
|
41
|
+
/** Position threshold for low position signal */
|
|
42
|
+
export const LOW_POSITION_THRESHOLD = 15;
|
|
43
|
+
/** Weight for topic mismatch signal */
|
|
44
|
+
export const TOPIC_MISMATCH_WEIGHT = 0.5;
|
|
45
|
+
/** Minimum topic overlap to avoid mismatch signal */
|
|
46
|
+
export const TOPIC_MISMATCH_THRESHOLD = 0.1;
|
|
47
|
+
/** Weight for files not accessed signal */
|
|
48
|
+
export const FILES_NOT_ACCESSED_WEIGHT = 0.3;
|
|
49
|
+
/** Maximum ignore confidence (cap) */
|
|
50
|
+
export const MAX_IGNORE_CONFIDENCE = 0.9;
|
|
51
|
+
// =============================================================================
|
|
52
|
+
// Explicit Reference Trigger Patterns
|
|
53
|
+
// =============================================================================
|
|
54
|
+
/**
|
|
55
|
+
* Regex patterns that indicate Claude explicitly referenced context.
|
|
56
|
+
* These are high-confidence signals that a fact was used.
|
|
57
|
+
*/
|
|
58
|
+
export const EXPLICIT_TRIGGERS = [
|
|
59
|
+
// Direct context references
|
|
60
|
+
/based on the (recalled |session |)context/i,
|
|
61
|
+
/according to (the |my )?(recalled )?memory/i,
|
|
62
|
+
/from the session context/i,
|
|
63
|
+
/from the (recalled |)context/i,
|
|
64
|
+
/as (mentioned|noted|stated|indicated) (in|from) (the )?(recalled )?context/i,
|
|
65
|
+
/the (recalled |session )?(fact|memory|context) (shows|indicates|mentions|states)/i,
|
|
66
|
+
/referring to the (recalled |session )?context/i,
|
|
67
|
+
// Bracketed references (common in structured responses)
|
|
68
|
+
/\[from context\]/i,
|
|
69
|
+
/\[context\]/i,
|
|
70
|
+
/\[recalled\]/i,
|
|
71
|
+
/\[memory\]/i,
|
|
72
|
+
/\(from context\)/i,
|
|
73
|
+
/\(from memory\)/i,
|
|
74
|
+
// Header-style references
|
|
75
|
+
/context reference:/i,
|
|
76
|
+
/recalled context:/i,
|
|
77
|
+
/from previous sessions?:/i,
|
|
78
|
+
// Knowledge acknowledgment
|
|
79
|
+
/I recall that/i,
|
|
80
|
+
/I remember that/i,
|
|
81
|
+
/from what I've learned/i,
|
|
82
|
+
/based on prior knowledge/i,
|
|
83
|
+
/drawing from (the |)context/i,
|
|
84
|
+
/the context (tells|shows|indicates|mentions) (me |us |)/i,
|
|
85
|
+
];
|
|
86
|
+
// =============================================================================
|
|
87
|
+
// File Reference Patterns
|
|
88
|
+
// =============================================================================
|
|
89
|
+
/**
|
|
90
|
+
* Factory function to create fresh regex patterns for file reference extraction.
|
|
91
|
+
* Creates new RegExp instances on each call to avoid shared mutable state issues
|
|
92
|
+
* with the global flag, and includes length limits for ReDoS protection.
|
|
93
|
+
*
|
|
94
|
+
* @returns Fresh array of regex patterns (safe to use with exec/matchAll)
|
|
95
|
+
*/
|
|
96
|
+
export function createFileReferencePatterns() {
|
|
97
|
+
return [
|
|
98
|
+
// Explicit file paths (limited to 100 chars for ReDoS protection)
|
|
99
|
+
/(?:^|[\s(,])([a-zA-Z0-9_-]{1,100}\.[a-zA-Z]{2,4})(?:[\s),]|$)/g,
|
|
100
|
+
// Path-like references (limited to 200 chars for ReDoS protection)
|
|
101
|
+
/(?:in |at |from |to |file |path )['"]?([a-zA-Z0-9_/-]{1,200}\.[a-zA-Z]{2,4})['"]?/gi,
|
|
102
|
+
// src/ or lib/ paths (limited to 200 chars for ReDoS protection)
|
|
103
|
+
/(?:src|lib|app|components|pages|utils|hooks|services|api)\/[a-zA-Z0-9_/-]{1,200}\.[a-zA-Z]{2,4}/gi,
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated Use createFileReferencePatterns() instead to avoid shared state issues.
|
|
108
|
+
* Kept for backward compatibility but will be removed in next major version.
|
|
109
|
+
*/
|
|
110
|
+
export const FILE_REFERENCE_PATTERNS = createFileReferencePatterns();
|
|
111
|
+
// =============================================================================
|
|
112
|
+
// Chunking Parameters (for semantic detection)
|
|
113
|
+
// =============================================================================
|
|
114
|
+
/** Maximum words per chunk when splitting response for comparison */
|
|
115
|
+
export const CHUNK_MAX_WORDS = 50;
|
|
116
|
+
/** Word overlap between chunks */
|
|
117
|
+
export const CHUNK_OVERLAP_WORDS = 10;
|
|
118
|
+
// =============================================================================
|
|
119
|
+
// Data Retention
|
|
120
|
+
// =============================================================================
|
|
121
|
+
/** Days to retain recall session data */
|
|
122
|
+
export const SESSION_DATA_RETENTION_DAYS = 7;
|
|
123
|
+
// =============================================================================
|
|
124
|
+
// Default Feedback Configuration
|
|
125
|
+
// =============================================================================
|
|
126
|
+
/**
|
|
127
|
+
* Default configuration for the feedback loop.
|
|
128
|
+
* Merged with user config from .claudemindrc
|
|
129
|
+
*/
|
|
130
|
+
export const DEFAULT_FEEDBACK_CONFIG = {
|
|
131
|
+
enabled: false,
|
|
132
|
+
detection: {
|
|
133
|
+
explicit: true,
|
|
134
|
+
semantic: true,
|
|
135
|
+
behavioral: true,
|
|
136
|
+
semanticThreshold: SEMANTIC_THRESHOLD,
|
|
137
|
+
},
|
|
138
|
+
hindsight: {
|
|
139
|
+
sendFeedback: true,
|
|
140
|
+
boostByUsefulness: true,
|
|
141
|
+
boostWeight: 0.3,
|
|
142
|
+
},
|
|
143
|
+
debug: false,
|
|
144
|
+
};
|
|
145
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/feedback/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,gFAAgF;AAChF,kCAAkC;AAClC,gFAAgF;AAEhF,6EAA6E;AAC7E,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAEtC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C,6EAA6E;AAC7E,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAE9C,wDAAwD;AACxD,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C,uDAAuD;AACvD,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAEzC,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF;AAEhF,kEAAkE;AAClE,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAElC,qEAAqE;AACrE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,CAAC;AAEtC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C,gFAAgF;A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/C,gFAAgF;AAEhF,qEAAqE;AACrE,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC,kCAAkC;AAClC,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEhF,yCAAyC;AACzC,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAE7C,gFAAgF;AAChF,iCAAiC;AACjC,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAmB;IACrD,OAAO,EAAE,KAAK;IACd,SAAS,EAAE;QACT,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,IAAI;QAChB,iBAAiB,EAAE,kBAAkB;KACtC;IACD,SAAS,EAAE;QACT,YAAY,EAAE,IAAI;QAClB,iBAAiB,EAAE,IAAI;QACvB,WAAW,EAAE,GAAG;KACjB;IACD,KAAK,EAAE,KAAK;CACb,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Usage Detection Strategies
|
|
3
|
+
*
|
|
4
|
+
* Implements 4 detection strategies to identify which recalled facts
|
|
5
|
+
* Claude actually used during a session:
|
|
6
|
+
*
|
|
7
|
+
* 1. Explicit Reference Detection (High Confidence)
|
|
8
|
+
* 2. Semantic Similarity Detection (Medium Confidence)
|
|
9
|
+
* 3. Behavioral Signal Detection (Low Confidence)
|
|
10
|
+
* 4. Negative Signal Detection
|
|
11
|
+
*
|
|
12
|
+
* @module feedback/detector
|
|
13
|
+
*/
|
|
14
|
+
import type { RecalledFact } from "./tracker.js";
|
|
15
|
+
import type { FeedbackDetectionConfig } from "../types.js";
|
|
16
|
+
export interface Detection {
|
|
17
|
+
factId: string;
|
|
18
|
+
detectionType: "explicit_reference" | "semantic_match" | "file_access_correlation" | "task_topic_correlation";
|
|
19
|
+
confidence: number;
|
|
20
|
+
evidence: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
export interface NegativeSignalDetail {
|
|
23
|
+
type: "low_position" | "topic_mismatch" | "files_not_accessed";
|
|
24
|
+
weight: number;
|
|
25
|
+
detail: string;
|
|
26
|
+
}
|
|
27
|
+
export interface NegativeSignal {
|
|
28
|
+
factId: string;
|
|
29
|
+
signals: NegativeSignalDetail[];
|
|
30
|
+
ignoreConfidence: number;
|
|
31
|
+
}
|
|
32
|
+
export interface DetectionResults {
|
|
33
|
+
explicit: Detection[];
|
|
34
|
+
semantic: Detection[];
|
|
35
|
+
behavioral: Detection[];
|
|
36
|
+
negative: NegativeSignal[];
|
|
37
|
+
}
|
|
38
|
+
export interface SessionActivity {
|
|
39
|
+
filesAccessed?: string[];
|
|
40
|
+
tasksCompleted?: Array<{
|
|
41
|
+
description?: string;
|
|
42
|
+
title?: string;
|
|
43
|
+
}>;
|
|
44
|
+
summary?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Detect explicit references to context in Claude's response
|
|
48
|
+
*/
|
|
49
|
+
export declare function detectExplicitReferences(response: string, recalledFacts: RecalledFact[]): Detection[];
|
|
50
|
+
/**
|
|
51
|
+
* Detect semantic matches between response and facts
|
|
52
|
+
* Uses Jaccard similarity (word overlap) for comparison
|
|
53
|
+
*/
|
|
54
|
+
export declare function detectSemanticMatches(response: string, recalledFacts: RecalledFact[], threshold?: number): Detection[];
|
|
55
|
+
/**
|
|
56
|
+
* Detect behavioral signals that indicate fact usage
|
|
57
|
+
*/
|
|
58
|
+
export declare function detectBehavioralSignals(sessionActivity: SessionActivity, recalledFacts: RecalledFact[]): Detection[];
|
|
59
|
+
/**
|
|
60
|
+
* Extract file references from text
|
|
61
|
+
*/
|
|
62
|
+
export declare function extractFileReferences(text: string): string[];
|
|
63
|
+
/**
|
|
64
|
+
* Extract topic keywords from text
|
|
65
|
+
*/
|
|
66
|
+
export declare function extractTopics(text: string): Set<string>;
|
|
67
|
+
/**
|
|
68
|
+
* Detect negative signals for facts that were likely NOT used
|
|
69
|
+
*/
|
|
70
|
+
export declare function detectNegativeSignals(sessionActivity: SessionActivity | null, recalledFacts: RecalledFact[], usedFactIds: Set<string>): NegativeSignal[];
|
|
71
|
+
/**
|
|
72
|
+
* Run the full detection pipeline
|
|
73
|
+
*/
|
|
74
|
+
export declare function runDetectionPipeline(conversationText: string | null, sessionActivity: SessionActivity | null, recalledFacts: RecalledFact[], config?: FeedbackDetectionConfig): DetectionResults;
|
|
75
|
+
//# sourceMappingURL=detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../src/feedback/detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAoBH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAM3D,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,oBAAoB,GAAG,gBAAgB,GAAG,yBAAyB,GAAG,wBAAwB,CAAC;IAC9G,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,cAAc,GAAG,gBAAgB,GAAG,oBAAoB,CAAC;IAC/D,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,QAAQ,EAAE,cAAc,E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