@auxiora/personality 1.0.0 → 1.3.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.
Files changed (162) hide show
  1. package/dist/__tests__/architect-awareness-collector.test.d.ts +2 -0
  2. package/dist/__tests__/architect-awareness-collector.test.d.ts.map +1 -0
  3. package/dist/__tests__/architect-awareness-collector.test.js +57 -0
  4. package/dist/__tests__/architect-awareness-collector.test.js.map +1 -0
  5. package/dist/__tests__/architect-bridge.test.d.ts +2 -0
  6. package/dist/__tests__/architect-bridge.test.d.ts.map +1 -0
  7. package/dist/__tests__/architect-bridge.test.js +59 -0
  8. package/dist/__tests__/architect-bridge.test.js.map +1 -0
  9. package/dist/__tests__/soul-bias-parser.test.d.ts +2 -0
  10. package/dist/__tests__/soul-bias-parser.test.d.ts.map +1 -0
  11. package/dist/__tests__/soul-bias-parser.test.js +47 -0
  12. package/dist/__tests__/soul-bias-parser.test.js.map +1 -0
  13. package/dist/architect-awareness-collector.d.ts +20 -0
  14. package/dist/architect-awareness-collector.d.ts.map +1 -0
  15. package/dist/architect-awareness-collector.js +41 -0
  16. package/dist/architect-awareness-collector.js.map +1 -0
  17. package/dist/architect-bridge.d.ts +35 -0
  18. package/dist/architect-bridge.d.ts.map +1 -0
  19. package/dist/architect-bridge.js +70 -0
  20. package/dist/architect-bridge.js.map +1 -0
  21. package/dist/index.d.ts +5 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +6 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/marketplace/schema.d.ts +6 -6
  26. package/dist/soul-bias-parser.d.ts +10 -0
  27. package/dist/soul-bias-parser.d.ts.map +1 -0
  28. package/dist/soul-bias-parser.js +48 -0
  29. package/dist/soul-bias-parser.js.map +1 -0
  30. package/lib/context-detector.d.ts +23 -0
  31. package/lib/context-detector.js +275 -0
  32. package/lib/context-profiles.d.ts +3 -0
  33. package/lib/context-profiles.js +550 -0
  34. package/lib/conversation-context.d.ts +70 -0
  35. package/lib/conversation-context.js +144 -0
  36. package/lib/conversation-export.d.ts +77 -0
  37. package/lib/conversation-export.js +254 -0
  38. package/lib/correction-store.d.ts +53 -0
  39. package/lib/correction-store.js +185 -0
  40. package/lib/custom-weights.d.ts +43 -0
  41. package/lib/custom-weights.js +164 -0
  42. package/lib/emotional-overrides.d.ts +14 -0
  43. package/lib/emotional-overrides.js +86 -0
  44. package/lib/emotional-tracker.d.ts +41 -0
  45. package/lib/emotional-tracker.js +210 -0
  46. package/lib/index.d.ts +161 -0
  47. package/lib/index.d.ts.map +1 -0
  48. package/lib/index.js +486 -0
  49. package/lib/index.js.map +1 -0
  50. package/lib/persistence-adapter.d.ts +55 -0
  51. package/lib/persistence-adapter.js +50 -0
  52. package/lib/persistence.d.ts +49 -0
  53. package/lib/persistence.js +116 -0
  54. package/lib/prompt-assembler.d.ts +16 -0
  55. package/lib/prompt-assembler.js +66 -0
  56. package/lib/recommender.d.ts +25 -0
  57. package/lib/recommender.js +125 -0
  58. package/lib/schema.d.ts +173 -0
  59. package/lib/schema.d.ts.map +1 -0
  60. package/lib/schema.js +2 -0
  61. package/lib/schema.js.map +1 -0
  62. package/lib/source-map.d.ts +9 -0
  63. package/lib/source-map.js +223 -0
  64. package/lib/system-prompt.d.ts +2 -0
  65. package/lib/system-prompt.js +102 -0
  66. package/lib/the-architect/context-detector.d.ts +23 -0
  67. package/lib/the-architect/context-detector.d.ts.map +1 -0
  68. package/lib/the-architect/context-detector.js +275 -0
  69. package/lib/the-architect/context-detector.js.map +1 -0
  70. package/lib/the-architect/context-profiles.d.ts +3 -0
  71. package/lib/the-architect/context-profiles.d.ts.map +1 -0
  72. package/lib/the-architect/context-profiles.js +550 -0
  73. package/lib/the-architect/context-profiles.js.map +1 -0
  74. package/lib/the-architect/conversation-context.d.ts +70 -0
  75. package/lib/the-architect/conversation-context.js +144 -0
  76. package/lib/the-architect/conversation-context.js.map +1 -0
  77. package/lib/the-architect/conversation-export.d.ts +77 -0
  78. package/lib/the-architect/conversation-export.js +254 -0
  79. package/lib/the-architect/correction-store.d.ts +53 -0
  80. package/lib/the-architect/correction-store.d.ts.map +1 -0
  81. package/lib/the-architect/correction-store.js +185 -0
  82. package/lib/the-architect/correction-store.js.map +1 -0
  83. package/lib/the-architect/custom-weights.d.ts +43 -0
  84. package/lib/the-architect/custom-weights.js +164 -0
  85. package/lib/the-architect/emotional-overrides.d.ts +14 -0
  86. package/lib/the-architect/emotional-overrides.d.ts.map +1 -0
  87. package/lib/the-architect/emotional-overrides.js +86 -0
  88. package/lib/the-architect/emotional-overrides.js.map +1 -0
  89. package/lib/the-architect/emotional-tracker.d.ts +41 -0
  90. package/lib/the-architect/emotional-tracker.js +210 -0
  91. package/lib/the-architect/index.d.ts +161 -0
  92. package/lib/the-architect/index.d.ts.map +1 -0
  93. package/lib/the-architect/index.js +486 -0
  94. package/lib/the-architect/index.js.map +1 -0
  95. package/lib/the-architect/persistence-adapter.d.ts +55 -0
  96. package/lib/the-architect/persistence-adapter.js +50 -0
  97. package/lib/the-architect/persistence.d.ts +49 -0
  98. package/lib/the-architect/persistence.js +116 -0
  99. package/lib/the-architect/prompt-assembler.d.ts +16 -0
  100. package/lib/the-architect/prompt-assembler.d.ts.map +1 -0
  101. package/lib/the-architect/prompt-assembler.js +66 -0
  102. package/lib/the-architect/prompt-assembler.js.map +1 -0
  103. package/lib/the-architect/recommender.d.ts +25 -0
  104. package/lib/the-architect/recommender.js +125 -0
  105. package/lib/the-architect/source-map.d.ts +9 -0
  106. package/lib/the-architect/source-map.d.ts.map +1 -0
  107. package/lib/the-architect/source-map.js +223 -0
  108. package/lib/the-architect/source-map.js.map +1 -0
  109. package/lib/the-architect/system-prompt.d.ts +2 -0
  110. package/lib/the-architect/system-prompt.d.ts.map +1 -0
  111. package/lib/the-architect/system-prompt.js +102 -0
  112. package/lib/the-architect/system-prompt.js.map +1 -0
  113. package/lib/the-architect/trait-to-instruction.d.ts +12 -0
  114. package/lib/the-architect/trait-to-instruction.d.ts.map +1 -0
  115. package/lib/the-architect/trait-to-instruction.js +330 -0
  116. package/lib/the-architect/trait-to-instruction.js.map +1 -0
  117. package/lib/trait-to-instruction.d.ts +12 -0
  118. package/lib/trait-to-instruction.js +330 -0
  119. package/package.json +15 -3
  120. package/modes/advisor.md +0 -24
  121. package/modes/analyst.md +0 -25
  122. package/modes/companion.md +0 -24
  123. package/modes/legal.md +0 -1188
  124. package/modes/operator.md +0 -24
  125. package/modes/roast.md +0 -24
  126. package/modes/socratic.md +0 -24
  127. package/modes/writer.md +0 -23
  128. package/src/__tests__/builder.test.ts +0 -78
  129. package/src/__tests__/conversation-builder.test.ts +0 -386
  130. package/src/__tests__/escalation.test.ts +0 -172
  131. package/src/__tests__/manager.test.ts +0 -141
  132. package/src/__tests__/parser.test.ts +0 -101
  133. package/src/__tests__/security-floor.test.ts +0 -212
  134. package/src/builder.ts +0 -75
  135. package/src/conversation-builder.ts +0 -279
  136. package/src/escalation.ts +0 -162
  137. package/src/index.ts +0 -55
  138. package/src/manager.ts +0 -119
  139. package/src/marketplace/__tests__/scanner.test.ts +0 -159
  140. package/src/marketplace/__tests__/schema.test.ts +0 -269
  141. package/src/marketplace/scanner.ts +0 -85
  142. package/src/marketplace/schema.ts +0 -141
  143. package/src/modes/__tests__/mode-detector.test.ts +0 -149
  144. package/src/modes/__tests__/mode-loader.test.ts +0 -143
  145. package/src/modes/__tests__/prompt-assembler.test.ts +0 -291
  146. package/src/modes/mode-detector.ts +0 -84
  147. package/src/modes/mode-loader.ts +0 -105
  148. package/src/modes/prompt-assembler.ts +0 -278
  149. package/src/modes/types.ts +0 -67
  150. package/src/parser.ts +0 -132
  151. package/src/security-floor.ts +0 -147
  152. package/src/types.ts +0 -27
  153. package/src/voice-profiles.ts +0 -88
  154. package/templates/chill.md +0 -30
  155. package/templates/creative.md +0 -29
  156. package/templates/friendly.md +0 -28
  157. package/templates/mentor.md +0 -31
  158. package/templates/minimal.md +0 -24
  159. package/templates/professional.md +0 -28
  160. package/templates/technical.md +0 -30
  161. package/tsconfig.json +0 -12
  162. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,116 @@
1
+ import { CorrectionStore } from './correction-store.js';
2
+ // ────────────────────────────────────────────────────────────────────────────
3
+ // Constants
4
+ // ────────────────────────────────────────────────────────────────────────────
5
+ const CURRENT_VERSION = 1;
6
+ const ALL_DOMAINS = [
7
+ 'security_review', 'code_engineering', 'architecture_design', 'debugging',
8
+ 'team_leadership', 'one_on_one', 'sales_pitch', 'negotiation',
9
+ 'marketing_content', 'strategic_planning', 'crisis_management',
10
+ 'creative_work', 'writing_content', 'decision_making',
11
+ 'learning_research', 'personal_development', 'general',
12
+ ];
13
+ function emptyUsageHistory() {
14
+ const history = {};
15
+ for (const domain of ALL_DOMAINS) {
16
+ history[domain] = 0;
17
+ }
18
+ return history;
19
+ }
20
+ function createDefaults() {
21
+ const now = Date.now();
22
+ return {
23
+ corrections: new CorrectionStore().serialize(),
24
+ showContextIndicator: true,
25
+ showSourcesButton: true,
26
+ autoDetectContext: true,
27
+ defaultContext: null,
28
+ contextUsageHistory: emptyUsageHistory(),
29
+ totalInteractions: 0,
30
+ firstUsed: now,
31
+ lastUsed: now,
32
+ version: CURRENT_VERSION,
33
+ };
34
+ }
35
+ // ────────────────────────────────────────────────────────────────────────────
36
+ // ArchitectPersistence
37
+ // ────────────────────────────────────────────────────────────────────────────
38
+ export class ArchitectPersistence {
39
+ storage;
40
+ static STORAGE_KEY = 'architect_preferences';
41
+ constructor(storage) {
42
+ this.storage = storage;
43
+ }
44
+ /** Load preferences from encrypted storage. Returns defaults if none exist. */
45
+ async load() {
46
+ const raw = await this.storage.get(ArchitectPersistence.STORAGE_KEY);
47
+ if (raw === null) {
48
+ return createDefaults();
49
+ }
50
+ const prefs = JSON.parse(raw);
51
+ return this.migrate(prefs);
52
+ }
53
+ /** Save preferences to encrypted storage. Updates lastUsed automatically. */
54
+ async save(prefs) {
55
+ prefs.lastUsed = Date.now();
56
+ await this.storage.set(ArchitectPersistence.STORAGE_KEY, JSON.stringify(prefs));
57
+ }
58
+ /** Increment usage count for a domain and total interactions. */
59
+ async recordUsage(domain) {
60
+ const prefs = await this.load();
61
+ prefs.contextUsageHistory[domain] = (prefs.contextUsageHistory[domain] ?? 0) + 1;
62
+ prefs.totalInteractions++;
63
+ await this.save(prefs);
64
+ }
65
+ /** Update the corrections field from a CorrectionStore instance. */
66
+ async saveCorrections(store) {
67
+ const prefs = await this.load();
68
+ prefs.corrections = store.serialize();
69
+ await this.save(prefs);
70
+ }
71
+ /** Get the top N most-used context domains, sorted by usage descending. */
72
+ async getMostUsedContexts(topN) {
73
+ const prefs = await this.load();
74
+ return Object.entries(prefs.contextUsageHistory)
75
+ .filter(([, count]) => count > 0)
76
+ .sort(([, a], [, b]) => b - a)
77
+ .slice(0, topN)
78
+ .map(([domain]) => domain);
79
+ }
80
+ /** Delete all stored Architect data (user privacy). */
81
+ async clearAll() {
82
+ await this.storage.delete(ArchitectPersistence.STORAGE_KEY);
83
+ }
84
+ /** Export all data as JSON string (user data portability). */
85
+ async exportAll() {
86
+ const prefs = await this.load();
87
+ return JSON.stringify(prefs, null, 2);
88
+ }
89
+ /** Handle version upgrades for stored preferences. */
90
+ async migrate(prefs) {
91
+ if (prefs.version === CURRENT_VERSION) {
92
+ return prefs;
93
+ }
94
+ // Version 0 → 1: add missing fields with defaults
95
+ if (prefs.version === 0 || prefs.version === undefined) {
96
+ const defaults = createDefaults();
97
+ prefs.showContextIndicator ??= defaults.showContextIndicator;
98
+ prefs.showSourcesButton ??= defaults.showSourcesButton;
99
+ prefs.autoDetectContext ??= defaults.autoDetectContext;
100
+ prefs.defaultContext ??= defaults.defaultContext;
101
+ prefs.contextUsageHistory ??= defaults.contextUsageHistory;
102
+ prefs.totalInteractions ??= defaults.totalInteractions;
103
+ prefs.firstUsed ??= defaults.firstUsed;
104
+ prefs.lastUsed ??= defaults.lastUsed;
105
+ prefs.corrections ??= defaults.corrections;
106
+ // Ensure all domains exist in usage history
107
+ for (const domain of ALL_DOMAINS) {
108
+ prefs.contextUsageHistory[domain] ??= 0;
109
+ }
110
+ prefs.version = CURRENT_VERSION;
111
+ await this.save(prefs);
112
+ }
113
+ return prefs;
114
+ }
115
+ }
116
+ //# sourceMappingURL=persistence.js.map
@@ -0,0 +1,16 @@
1
+ import type { TraitMix, TaskContext, TraitSource } from '../schema.js';
2
+ /**
3
+ * Assembles a context-specific prompt modifier from the current trait mix.
4
+ *
5
+ * Selects the top 10 weighted traits, generates a weight-scaled behavioral
6
+ * instruction for each, and composes them into a prompt block that sits
7
+ * between the base personality prompt and the user message.
8
+ */
9
+ export declare function assemblePromptModifier(mix: TraitMix, context: TaskContext): string;
10
+ /**
11
+ * Returns the SOURCE_MAP entries for the top N weighted traits in the mix.
12
+ * Useful for transparency — explaining *why* the personality is behaving
13
+ * a certain way and which historical minds are driving the response.
14
+ */
15
+ export declare function getActiveSources(mix: TraitMix, topN?: number): TraitSource[];
16
+ //# sourceMappingURL=prompt-assembler.d.ts.map
@@ -0,0 +1,66 @@
1
+ import { TRAIT_TO_INSTRUCTION } from './trait-to-instruction.js';
2
+ import { SOURCE_MAP } from './source-map.js';
3
+ // ────────────────────────────────────────────────────────────────────────────
4
+ // Prompt modifier assembly
5
+ // ────────────────────────────────────────────────────────────────────────────
6
+ /**
7
+ * Assembles a context-specific prompt modifier from the current trait mix.
8
+ *
9
+ * Selects the top 10 weighted traits, generates a weight-scaled behavioral
10
+ * instruction for each, and composes them into a prompt block that sits
11
+ * between the base personality prompt and the user message.
12
+ */
13
+ export function assemblePromptModifier(mix, context) {
14
+ const entries = Object.entries(mix);
15
+ // Sort by weight descending, take top 10
16
+ const top = entries
17
+ .sort((a, b) => b[1] - a[1])
18
+ .slice(0, 10);
19
+ const instructions = [];
20
+ for (const [key, value] of top) {
21
+ const fn = TRAIT_TO_INSTRUCTION[key];
22
+ if (fn) {
23
+ instructions.push(fn(value, context));
24
+ }
25
+ }
26
+ return [
27
+ '## Current Context Adaptation',
28
+ '',
29
+ `You are operating in a **${formatDomain(context.domain)}** context.`,
30
+ `The user's emotional state appears **${context.emotionalRegister}**.`,
31
+ `Stakes: **${context.stakes}**. Complexity: **${context.complexity}**.`,
32
+ '',
33
+ 'For this interaction, emphasize:',
34
+ '',
35
+ ...instructions.map((i) => `- ${i}`),
36
+ '',
37
+ `Tone: warmth=${mix.warmth.toFixed(1)}, urgency=${mix.urgency.toFixed(1)}, humor=${mix.humor.toFixed(1)}, depth=${mix.verbosity.toFixed(1)}`,
38
+ ].join('\n');
39
+ }
40
+ // ────────────────────────────────────────────────────────────────────────────
41
+ // Active source retrieval
42
+ // ────────────────────────────────────────────────────────────────────────────
43
+ /**
44
+ * Returns the SOURCE_MAP entries for the top N weighted traits in the mix.
45
+ * Useful for transparency — explaining *why* the personality is behaving
46
+ * a certain way and which historical minds are driving the response.
47
+ */
48
+ export function getActiveSources(mix, topN = 10) {
49
+ const entries = Object.entries(mix);
50
+ return entries
51
+ .sort((a, b) => b[1] - a[1])
52
+ .slice(0, topN)
53
+ .map(([key]) => SOURCE_MAP[key])
54
+ .filter(Boolean);
55
+ }
56
+ // ────────────────────────────────────────────────────────────────────────────
57
+ // Helpers
58
+ // ────────────────────────────────────────────────────────────────────────────
59
+ /** Converts a snake_case domain key to a human-readable label. */
60
+ function formatDomain(domain) {
61
+ return domain
62
+ .split('_')
63
+ .map((w) => w.charAt(0).toUpperCase() + w.slice(1))
64
+ .join(' ');
65
+ }
66
+ //# sourceMappingURL=prompt-assembler.js.map
@@ -0,0 +1,25 @@
1
+ import type { TaskContext, ContextDomain } from '../schema.js';
2
+ import type { CorrectionStore } from './correction-store.js';
3
+ export interface ContextRecommendation {
4
+ suggestedDomain: ContextDomain;
5
+ reason: string;
6
+ confidence: number;
7
+ source: 'correction_pattern' | 'low_confidence' | 'usage_pattern';
8
+ }
9
+ export declare class ContextRecommender {
10
+ /**
11
+ * Analyze the detected context and determine if a recommendation should
12
+ * be shown. Returns null if auto-detection seems right; otherwise returns
13
+ * a recommendation with a human-readable reason and confidence score.
14
+ *
15
+ * Priority order:
16
+ * 1. Correction-based (learned from user overrides)
17
+ * 2. Low-confidence (ambiguous detection, close runner-up)
18
+ * 3. Usage-pattern (general detected but history is concentrated)
19
+ */
20
+ shouldRecommend(detectedContext: TaskContext, correctionStore: CorrectionStore, usageHistory: Record<ContextDomain, number>, userMessage?: string): ContextRecommendation | null;
21
+ private correctionBased;
22
+ private lowConfidence;
23
+ private usagePattern;
24
+ }
25
+ //# sourceMappingURL=recommender.d.ts.map
@@ -0,0 +1,125 @@
1
+ import { scoreAllDomains } from './context-detector.js';
2
+ // ────────────────────────────────────────────────────────────────────────────
3
+ // Helpers
4
+ // ────────────────────────────────────────────────────────────────────────────
5
+ /** Clamp a value to [0, 1]. */
6
+ function clamp01(n) {
7
+ return Math.min(1, Math.max(0, n));
8
+ }
9
+ /** Human-readable label for a domain (e.g. "code_engineering" → "Code Engineering"). */
10
+ function domainLabel(domain) {
11
+ return domain
12
+ .split('_')
13
+ .map(w => w.charAt(0).toUpperCase() + w.slice(1))
14
+ .join(' ');
15
+ }
16
+ // ────────────────────────────────────────────────────────────────────────────
17
+ // ContextRecommender
18
+ // ────────────────────────────────────────────────────────────────────────────
19
+ export class ContextRecommender {
20
+ /**
21
+ * Analyze the detected context and determine if a recommendation should
22
+ * be shown. Returns null if auto-detection seems right; otherwise returns
23
+ * a recommendation with a human-readable reason and confidence score.
24
+ *
25
+ * Priority order:
26
+ * 1. Correction-based (learned from user overrides)
27
+ * 2. Low-confidence (ambiguous detection, close runner-up)
28
+ * 3. Usage-pattern (general detected but history is concentrated)
29
+ */
30
+ shouldRecommend(detectedContext, correctionStore, usageHistory, userMessage) {
31
+ // 1. Correction-based
32
+ if (userMessage) {
33
+ const correctionRec = this.correctionBased(detectedContext, correctionStore, userMessage);
34
+ if (correctionRec)
35
+ return correctionRec;
36
+ }
37
+ // 2. Low-confidence
38
+ if (userMessage) {
39
+ const lowConfRec = this.lowConfidence(detectedContext, userMessage);
40
+ if (lowConfRec)
41
+ return lowConfRec;
42
+ }
43
+ // 3. Usage-pattern
44
+ const usageRec = this.usagePattern(detectedContext, usageHistory);
45
+ if (usageRec)
46
+ return usageRec;
47
+ return null;
48
+ }
49
+ // ── Strategy 1: Correction-based ────────────────────────────────────────
50
+ correctionBased(detectedContext, correctionStore, userMessage) {
51
+ const suggested = correctionStore.suggestCorrection(userMessage, detectedContext.domain);
52
+ if (suggested === null)
53
+ return null;
54
+ // Get the matching pattern's confidence from the store
55
+ const patterns = correctionStore.getPatterns();
56
+ const match = patterns.find(p => p.fromDomain === detectedContext.domain && p.toDomain === suggested);
57
+ const confidence = match ? clamp01(match.confidence) : 0.7;
58
+ return {
59
+ suggestedDomain: suggested,
60
+ reason: `You've previously switched from ${domainLabel(detectedContext.domain)} to ${domainLabel(suggested)} in similar messages`,
61
+ confidence,
62
+ source: 'correction_pattern',
63
+ };
64
+ }
65
+ // ── Strategy 2: Low-confidence ──────────────────────────────────────────
66
+ lowConfidence(detectedContext, userMessage) {
67
+ const detectionConfidence = detectedContext.detectionConfidence ?? 1;
68
+ if (detectionConfidence >= 0.5)
69
+ return null;
70
+ if (detectedContext.domain === 'general')
71
+ return null;
72
+ const scores = scoreAllDomains(userMessage);
73
+ // Get the top 3 domains (excluding general) sorted by score descending
74
+ const ranked = Object.entries(scores)
75
+ .filter(([d]) => d !== 'general')
76
+ .sort(([, a], [, b]) => b - a)
77
+ .slice(0, 3);
78
+ if (ranked.length < 2)
79
+ return null;
80
+ const [first, second] = ranked;
81
+ const gap = first[1] - second[1];
82
+ // If the #2 domain is within 0.1 of #1, suggest it as an alternative
83
+ if (gap > 0.1)
84
+ return null;
85
+ // Confidence is inversely proportional to the gap (closer = more ambiguous)
86
+ const confidence = clamp01(1 - gap * 10);
87
+ return {
88
+ suggestedDomain: second[0],
89
+ reason: `This could be ${domainLabel(first[0])} or ${domainLabel(second[0])} — want to specify?`,
90
+ confidence,
91
+ source: 'low_confidence',
92
+ };
93
+ }
94
+ // ── Strategy 3: Usage-pattern ───────────────────────────────────────────
95
+ usagePattern(detectedContext, usageHistory) {
96
+ if (detectedContext.domain !== 'general')
97
+ return null;
98
+ const total = Object.values(usageHistory).reduce((sum, n) => sum + n, 0);
99
+ if (total === 0)
100
+ return null;
101
+ // Find the most-used non-general domain
102
+ let topDomain = null;
103
+ let topCount = 0;
104
+ for (const [domain, count] of Object.entries(usageHistory)) {
105
+ if (domain === 'general')
106
+ continue;
107
+ if (count > topCount) {
108
+ topCount = count;
109
+ topDomain = domain;
110
+ }
111
+ }
112
+ if (topDomain === null)
113
+ return null;
114
+ const percentage = topCount / total;
115
+ if (percentage <= 0.6)
116
+ return null;
117
+ return {
118
+ suggestedDomain: topDomain,
119
+ reason: `You usually work in ${domainLabel(topDomain)} context — is that what you're doing here?`,
120
+ confidence: clamp01(percentage),
121
+ source: 'usage_pattern',
122
+ };
123
+ }
124
+ }
125
+ //# sourceMappingURL=recommender.js.map
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Numeric trait value constrained to the range [0.0, 1.0].
3
+ * 0.0 means the trait is completely suppressed; 1.0 means it dominates.
4
+ */
5
+ export type TraitValue = number;
6
+ /**
7
+ * The operational domain that shapes which traits are amplified or suppressed.
8
+ */
9
+ export type ContextDomain = 'security_review' | 'code_engineering' | 'architecture_design' | 'debugging' | 'team_leadership' | 'one_on_one' | 'sales_pitch' | 'negotiation' | 'marketing_content' | 'strategic_planning' | 'crisis_management' | 'creative_work' | 'writing_content' | 'decision_making' | 'learning_research' | 'personal_development' | 'general';
10
+ /**
11
+ * The emotional register detected in the user's message, used to modulate
12
+ * tone and trait selection so the response meets the user where they are.
13
+ */
14
+ export type EmotionalRegister = 'neutral' | 'stressed' | 'excited' | 'frustrated' | 'uncertain' | 'celebratory';
15
+ /**
16
+ * The full trait vector that defines a personality at a given moment.
17
+ *
18
+ * Every value is a float in [0.0, 1.0]. A base personality sets defaults;
19
+ * context detection then dials individual traits up or down before the
20
+ * prompt is assembled. The trait names encode *how* to think, not *what*
21
+ * to think — each is grounded in a specific historical mind's documented
22
+ * methodology.
23
+ */
24
+ export interface TraitMix {
25
+ /** Charlie Munger — define failure first, then avoid it. Invert, always invert. */
26
+ inversion: TraitValue;
27
+ /** Elon Musk / Isaac Newton — decompose to irreducible fundamentals before reasoning up. */
28
+ firstPrinciples: TraitValue;
29
+ /** Nikola Tesla — build and run the full model in your head before touching reality. */
30
+ mentalSimulation: TraitValue;
31
+ /** Andy Grove / Sun Tzu — assume intelligent adversaries; think like the attacker. */
32
+ adversarialThinking: TraitValue;
33
+ /** Howard Marks — always ask "and then what?" to surface cascading consequences. */
34
+ secondOrder: TraitValue;
35
+ /** Buckminster Fuller / Claude Shannon — see the whole system, not just the parts. */
36
+ systemsView: TraitValue;
37
+ /** Steve Jobs / Claude Shannon — ruthless clarity; remove until only the essential remains. */
38
+ simplification: TraitValue;
39
+ /** Robert Cialdini — lead with narrative and analogy, not raw argument. */
40
+ storytelling: TraitValue;
41
+ /** Chris Voss — label emotions, mirror language, use calibrated questions. */
42
+ tacticalEmpathy: TraitValue;
43
+ /** Dale Carnegie — ask questions and genuinely care about the answers. */
44
+ genuineCuriosity: TraitValue;
45
+ /** Kim Scott — care personally while challenging directly. */
46
+ radicalCandor: TraitValue;
47
+ /** John Wooden / Bill Walsh — culture is built through behavioral standards, not slogans. */
48
+ standardSetting: TraitValue;
49
+ /** John Wooden — grow people through high expectations and specific, caring feedback. */
50
+ developmentalCoaching: TraitValue;
51
+ /** Adam Grant / Benjamin Franklin — give first; generosity is a long-term strategy. */
52
+ strategicGenerosity: TraitValue;
53
+ /** Marcus Aurelius — the obstacle is the way; respond, don't react. */
54
+ stoicCalm: TraitValue;
55
+ /** Andy Grove — only the paranoid survive; complacency kills. */
56
+ paranoidVigilance: TraitValue;
57
+ /** Alex Hormozi — maximize perceived value, minimize time/effort/sacrifice/risk. */
58
+ valueEquation: TraitValue;
59
+ /** John Boyd — observe-orient-decide-act; cycle faster than the competition. */
60
+ ooda: TraitValue;
61
+ /** Martin Fowler / Kent Beck — optimize for adaptability; embrace change, don't fight it. */
62
+ buildForChange: TraitValue;
63
+ /** Don Norman — design for the human; understand the user before the system. */
64
+ humanCenteredDesign: TraitValue;
65
+ /** Charles & Ray Eames — limitations are creative fuel, not obstacles. */
66
+ constraintCreativity: TraitValue;
67
+ /** Jeff Bezos — decide from your 80-year-old self looking back; minimize future regret. */
68
+ regretMinimization: TraitValue;
69
+ /** Jeff Bezos — classify as one-way (irreversible, go slow) or two-way (reversible, go fast). */
70
+ doorClassification: TraitValue;
71
+ /** Annie Duke — assign probabilities, update beliefs with new evidence, embrace uncertainty. */
72
+ probabilistic: TraitValue;
73
+ /** Peter Drucker — systematically stop what is no longer working; don't cling. */
74
+ plannedAbandonment: TraitValue;
75
+ /** 0 = pure analytical machine, 1 = deeply empathetic and warm. */
76
+ warmth: TraitValue;
77
+ /** 0 = patient and contemplative, 1 = act now, urgency in every sentence. */
78
+ urgency: TraitValue;
79
+ /** 0 = dead serious, 1 = wry humor woven throughout. */
80
+ humor: TraitValue;
81
+ /** 0 = terse and tactical, 1 = expansive and strategic. */
82
+ verbosity: TraitValue;
83
+ }
84
+ /**
85
+ * The detected task context that drives trait modulation.
86
+ *
87
+ * Context is inferred from the user's message, active tools, file types,
88
+ * and conversation history. The engine uses this to decide which traits
89
+ * to amplify and which to suppress.
90
+ */
91
+ export interface TaskContext {
92
+ /** The operational domain of the current task. */
93
+ domain: ContextDomain;
94
+ /** The emotional register detected in the user's message. */
95
+ emotionalRegister: EmotionalRegister;
96
+ /** How deep the response needs to go. */
97
+ complexity: 'quick_answer' | 'moderate' | 'deep_analysis' | 'crisis';
98
+ /** Who the work is for — shapes formality and collaboration style. */
99
+ mode: 'solo_work' | 'team_context' | 'external_facing' | 'personal';
100
+ /** How much rides on getting this right. */
101
+ stakes: 'low' | 'moderate' | 'high' | 'critical';
102
+ /** True if the correction store overrode the auto-detected domain. */
103
+ corrected?: boolean;
104
+ /** The auto-detected domain before correction (only set when corrected). */
105
+ originalDomain?: ContextDomain;
106
+ /** Confidence score of the winning domain from keyword/pattern matching. */
107
+ detectionConfidence?: number;
108
+ /** The sustained conversation theme (set after 3+ consistent detections). */
109
+ conversationTheme?: ContextDomain;
110
+ /** True if the effective domain differs from the raw per-message detection. */
111
+ themeOverridden?: boolean;
112
+ /** The raw detected domain before conversation theme adjustment. */
113
+ rawDetectedDomain?: ContextDomain;
114
+ }
115
+ /**
116
+ * Signals used by the context detector to infer a TaskContext from
117
+ * raw input. Each signal type contributes evidence toward a domain
118
+ * or emotional register classification.
119
+ */
120
+ export interface ContextSignal {
121
+ /** Words that strongly indicate this context (e.g., "vulnerability", "CVE"). */
122
+ keywords: string[];
123
+ /** Regex patterns matched against the full message. */
124
+ patterns: string[];
125
+ /** Active tool names that suggest this context (e.g., "bash", "web_browser"). */
126
+ toolContext?: string[];
127
+ /** File extensions being discussed (e.g., ".tf", ".yaml", ".tsx"). */
128
+ fileExtensions?: string[];
129
+ /** Phrases indicating emotional state (e.g., "I'm stuck", "this is broken"). */
130
+ emotionalSignals?: string[];
131
+ /** Minimum confidence (0.0–1.0) before this signal triggers a context switch. */
132
+ confidence_threshold: number;
133
+ }
134
+ /**
135
+ * Links a trait back to its intellectual source so the engine can explain
136
+ * *why* it's behaving a certain way and the prompt can include the right
137
+ * behavioral instruction.
138
+ */
139
+ export interface TraitSource {
140
+ /** The key in TraitMix (e.g., "inversion", "stoicCalm"). */
141
+ traitKey: string;
142
+ /** The historical mind this trait is modeled after (e.g., "Charlie Munger"). */
143
+ sourceName: string;
144
+ /** The primary work or principle (e.g., "Poor Charlie's Almanack"). */
145
+ sourceWork: string;
146
+ /** One-sentence summary of the evidence for this approach. */
147
+ evidenceSummary: string;
148
+ /** The concrete instruction injected into the prompt when this trait is active. */
149
+ behavioralInstruction: string;
150
+ }
151
+ /**
152
+ * The final output of the personality engine: a fully assembled prompt
153
+ * along with metadata about what traits are active and why.
154
+ */
155
+ export interface PromptOutput {
156
+ /** The base personality prompt before context modulation. */
157
+ basePrompt: string;
158
+ /** The context-specific modifier layered on top. */
159
+ contextModifier: string;
160
+ /** The complete prompt ready for the provider (basePrompt + contextModifier). */
161
+ fullPrompt: string;
162
+ /** The traits that are actively shaping this prompt, with provenance. */
163
+ activeTraits: TraitSource[];
164
+ /** The context that was detected and used for trait modulation. */
165
+ detectedContext: TaskContext;
166
+ /** Suggestion to switch contexts, if the recommender thinks detection may be off. */
167
+ recommendation?: import('./the-architect/recommender.js').ContextRecommendation;
168
+ /** Emotional trajectory across the conversation (stable, escalating, etc.). */
169
+ emotionalTrajectory?: import('./the-architect/emotional-tracker.js').EmotionalTrajectory;
170
+ /** True when sustained high-intensity frustration triggers a proactive check-in. */
171
+ escalationAlert?: boolean;
172
+ }
173
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAMhC;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,kBAAkB,GAClB,qBAAqB,GACrB,WAAW,GACX,iBAAiB,GACjB,YAAY,GACZ,aAAa,GACb,aAAa,GACb,mBAAmB,GACnB,oBAAoB,GACpB,mBAAmB,GACnB,eAAe,GACf,iBAAiB,GACjB,iBAAiB,GACjB,mBAAmB,GACnB,sBAAsB,GACtB,SAAS,CAAC;AAEd;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,UAAU,GACV,SAAS,GACT,YAAY,GACZ,WAAW,GACX,aAAa,CAAC;AAMlB;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ;IAGvB,mFAAmF;IACnF,SAAS,EAAE,UAAU,CAAC;IAEtB,4FAA4F;IAC5F,eAAe,EAAE,UAAU,CAAC;IAE5B,wFAAwF;IACxF,gBAAgB,EAAE,UAAU,CAAC;IAE7B,sFAAsF;IACt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A6D;IAC7D,UAAU,EAAE,MAAM,CAAC;IAEnB,oDAAoD;IACpD,eAAe,EAAE,MAAM,CAAC;IAExB,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAC;IAEnB,yEAAyE;IACzE,YAAY,EAAE,WAAW,EAAE,CAAC;IAE5B,mEAAmE;IACnE,eAAe,EAAE,WAAW,CAAC;CAC9B"}
package/lib/schema.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import type { TraitSource } from '../schema.js';
2
+ /**
3
+ * Maps every trait in TraitMix to its intellectual source, primary evidence,
4
+ * and the concrete behavioral instruction injected into the prompt when the
5
+ * trait is active. This is the personality engine's bibliography — nothing
6
+ * is invented, everything traces to documented behavior.
7
+ */
8
+ export declare const SOURCE_MAP: Record<string, TraitSource>;
9
+ //# sourceMappingURL=source-map.d.ts.map