claude-soul-server 0.1.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 (97) hide show
  1. package/dist/engine/context-assembler.d.ts +3 -0
  2. package/dist/engine/context-assembler.js +161 -0
  3. package/dist/engine/context-assembler.js.map +1 -0
  4. package/dist/engine/exemplar-selector.d.ts +6 -0
  5. package/dist/engine/exemplar-selector.js +21 -0
  6. package/dist/engine/exemplar-selector.js.map +1 -0
  7. package/dist/engine/framework-engine.d.ts +61 -0
  8. package/dist/engine/framework-engine.js +351 -0
  9. package/dist/engine/framework-engine.js.map +1 -0
  10. package/dist/engine/framework-renderer.d.ts +17 -0
  11. package/dist/engine/framework-renderer.js +161 -0
  12. package/dist/engine/framework-renderer.js.map +1 -0
  13. package/dist/engine/framework-seeds.d.ts +2 -0
  14. package/dist/engine/framework-seeds.js +265 -0
  15. package/dist/engine/framework-seeds.js.map +1 -0
  16. package/dist/engine/lesson-store.d.ts +8 -0
  17. package/dist/engine/lesson-store.js +40 -0
  18. package/dist/engine/lesson-store.js.map +1 -0
  19. package/dist/engine/meta-optimizer.d.ts +37 -0
  20. package/dist/engine/meta-optimizer.js +140 -0
  21. package/dist/engine/meta-optimizer.js.map +1 -0
  22. package/dist/engine/prompt-builder.d.ts +31 -0
  23. package/dist/engine/prompt-builder.js +385 -0
  24. package/dist/engine/prompt-builder.js.map +1 -0
  25. package/dist/engine/reflection-runner.d.ts +18 -0
  26. package/dist/engine/reflection-runner.js +313 -0
  27. package/dist/engine/reflection-runner.js.map +1 -0
  28. package/dist/engine/shadow-transform.d.ts +1 -0
  29. package/dist/engine/shadow-transform.js +41 -0
  30. package/dist/engine/shadow-transform.js.map +1 -0
  31. package/dist/engine/signal-extractor.d.ts +14 -0
  32. package/dist/engine/signal-extractor.js +204 -0
  33. package/dist/engine/signal-extractor.js.map +1 -0
  34. package/dist/engine/signal-store.d.ts +5 -0
  35. package/dist/engine/signal-store.js +56 -0
  36. package/dist/engine/signal-store.js.map +1 -0
  37. package/dist/engine/snapshot-manager.d.ts +3 -0
  38. package/dist/engine/snapshot-manager.js +52 -0
  39. package/dist/engine/snapshot-manager.js.map +1 -0
  40. package/dist/engine/state-engine.d.ts +34 -0
  41. package/dist/engine/state-engine.js +127 -0
  42. package/dist/engine/state-engine.js.map +1 -0
  43. package/dist/engine/tension-detector.d.ts +10 -0
  44. package/dist/engine/tension-detector.js +77 -0
  45. package/dist/engine/tension-detector.js.map +1 -0
  46. package/dist/engine/token-budget.d.ts +12 -0
  47. package/dist/engine/token-budget.js +44 -0
  48. package/dist/engine/token-budget.js.map +1 -0
  49. package/dist/hooks/on-stop.d.ts +11 -0
  50. package/dist/hooks/on-stop.js +153 -0
  51. package/dist/hooks/on-stop.js.map +1 -0
  52. package/dist/index.d.ts +2 -0
  53. package/dist/index.js +171 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/tools/soul-activate.d.ts +1 -0
  56. package/dist/tools/soul-activate.js +149 -0
  57. package/dist/tools/soul-activate.js.map +1 -0
  58. package/dist/tools/soul-context.d.ts +1 -0
  59. package/dist/tools/soul-context.js +31 -0
  60. package/dist/tools/soul-context.js.map +1 -0
  61. package/dist/tools/soul-evaluate.d.ts +8 -0
  62. package/dist/tools/soul-evaluate.js +97 -0
  63. package/dist/tools/soul-evaluate.js.map +1 -0
  64. package/dist/tools/soul-framework.d.ts +1 -0
  65. package/dist/tools/soul-framework.js +66 -0
  66. package/dist/tools/soul-framework.js.map +1 -0
  67. package/dist/tools/soul-read.d.ts +1 -0
  68. package/dist/tools/soul-read.js +24 -0
  69. package/dist/tools/soul-read.js.map +1 -0
  70. package/dist/tools/soul-reflect.d.ts +1 -0
  71. package/dist/tools/soul-reflect.js +82 -0
  72. package/dist/tools/soul-reflect.js.map +1 -0
  73. package/dist/tools/soul-signal.d.ts +8 -0
  74. package/dist/tools/soul-signal.js +119 -0
  75. package/dist/tools/soul-signal.js.map +1 -0
  76. package/dist/tools/soul-status.d.ts +1 -0
  77. package/dist/tools/soul-status.js +130 -0
  78. package/dist/tools/soul-status.js.map +1 -0
  79. package/dist/tools/soul-write.d.ts +1 -0
  80. package/dist/tools/soul-write.js +26 -0
  81. package/dist/tools/soul-write.js.map +1 -0
  82. package/dist/types/config-types.d.ts +45 -0
  83. package/dist/types/config-types.js +21 -0
  84. package/dist/types/config-types.js.map +1 -0
  85. package/dist/types/learning-types.d.ts +166 -0
  86. package/dist/types/learning-types.js +2 -0
  87. package/dist/types/learning-types.js.map +1 -0
  88. package/dist/util/files.d.ts +20 -0
  89. package/dist/util/files.js +54 -0
  90. package/dist/util/files.js.map +1 -0
  91. package/dist/util/llm.d.ts +6 -0
  92. package/dist/util/llm.js +76 -0
  93. package/dist/util/llm.js.map +1 -0
  94. package/dist/util/tokens.d.ts +1 -0
  95. package/dist/util/tokens.js +4 -0
  96. package/dist/util/tokens.js.map +1 -0
  97. package/package.json +44 -0
@@ -0,0 +1,140 @@
1
+ import { META_PATH } from "../util/files.js";
2
+ import { readJsonSafe, writeJsonAtomic } from "../util/files.js";
3
+ const DEFAULT_META = {
4
+ phase: "apprentice",
5
+ frameworkSurvivalRate: 1.0,
6
+ reflectionCount: 0,
7
+ totalDiscovered: 0,
8
+ totalRetired: 0,
9
+ oscillationFlags: [],
10
+ lastPhaseTransition: Date.now(),
11
+ phaseHistory: [{ phase: "apprentice", enteredAt: Date.now(), reason: "initial" }],
12
+ };
13
+ export async function loadMeta() {
14
+ return readJsonSafe(META_PATH, { ...DEFAULT_META });
15
+ }
16
+ export async function saveMeta(meta) {
17
+ await writeJsonAtomic(META_PATH, meta);
18
+ }
19
+ /**
20
+ * Update meta-optimization state after a reflection.
21
+ */
22
+ export async function updateMetaAfterReflection(store) {
23
+ const meta = await loadMeta();
24
+ meta.reflectionCount = store.meta.reflectionCount;
25
+ meta.totalDiscovered = store.meta.totalDiscovered;
26
+ meta.totalRetired = store.meta.totalRetired;
27
+ // Calculate framework survival rate
28
+ if (meta.totalDiscovered > 0) {
29
+ meta.frameworkSurvivalRate = 1 - (meta.totalRetired / meta.totalDiscovered);
30
+ }
31
+ // Detect phase transitions based on framework stability
32
+ const activeCount = store.frameworks.filter((f) => f.status === "active" || f.status === "questioning").length;
33
+ const avgConfidence = store.frameworks
34
+ .filter((f) => f.status === "active")
35
+ .reduce((sum, f) => sum + f.confidence, 0) /
36
+ Math.max(1, store.frameworks.filter((f) => f.status === "active").length);
37
+ const prevPhase = meta.phase;
38
+ if (meta.phase === "apprentice") {
39
+ // Transition to creative: 5+ active frameworks with avg confidence > 0.5
40
+ const activeHighConf = store.frameworks.filter((f) => f.status === "active" && f.confidence > 0.5).length;
41
+ if (activeHighConf >= 5 && meta.reflectionCount >= 5) {
42
+ meta.phase = "creative";
43
+ meta.lastPhaseTransition = Date.now();
44
+ meta.phaseHistory.push({
45
+ phase: "creative",
46
+ enteredAt: Date.now(),
47
+ reason: `${activeHighConf} high-confidence frameworks, ${meta.reflectionCount} reflections`,
48
+ });
49
+ }
50
+ }
51
+ else if (meta.phase === "creative") {
52
+ // Transition to mastery: 10+ active frameworks with avg confidence > 0.7, low churn
53
+ const activeHighConf = store.frameworks.filter((f) => f.status === "active" && f.confidence > 0.7).length;
54
+ const churnRate = meta.totalRetired / Math.max(1, meta.reflectionCount);
55
+ if (activeHighConf >= 10 && churnRate < 0.3 && meta.reflectionCount >= 20) {
56
+ meta.phase = "mastery";
57
+ meta.lastPhaseTransition = Date.now();
58
+ meta.phaseHistory.push({
59
+ phase: "mastery",
60
+ enteredAt: Date.now(),
61
+ reason: `${activeHighConf} high-confidence frameworks, churn rate ${churnRate.toFixed(2)}`,
62
+ });
63
+ }
64
+ }
65
+ // Detect oscillation: framework discovered then retired then re-discovered
66
+ const retiredNames = new Set(store.frameworks.filter((f) => f.status === "retired").map((f) => f.name.toLowerCase()));
67
+ const activeNames = store.frameworks
68
+ .filter((f) => f.status === "active" || f.status === "questioning")
69
+ .map((f) => f.name.toLowerCase());
70
+ for (const name of activeNames) {
71
+ if (retiredNames.has(name) && !meta.oscillationFlags.includes(name)) {
72
+ meta.oscillationFlags.push(name);
73
+ }
74
+ }
75
+ // Keep oscillation flags manageable
76
+ meta.oscillationFlags = meta.oscillationFlags.slice(-10);
77
+ await saveMeta(meta);
78
+ return meta;
79
+ }
80
+ /**
81
+ * Get phase-adaptive reflection thresholds.
82
+ * Apprentice phase needs tight loops for fast learning.
83
+ * Mastery phase can afford slower, more deliberate reflection.
84
+ */
85
+ export function getReflectionThresholds(meta) {
86
+ switch (meta.phase) {
87
+ case "apprentice":
88
+ return {
89
+ quickSignals: 5,
90
+ deepSignals: 25,
91
+ quickTimeMs: 2 * 60 * 60 * 1000, // 2 hours
92
+ deepTimeMs: 12 * 60 * 60 * 1000, // 12 hours
93
+ minSignals: 3,
94
+ };
95
+ case "creative":
96
+ return {
97
+ quickSignals: 12,
98
+ deepSignals: 60,
99
+ quickTimeMs: 4 * 60 * 60 * 1000, // 4 hours
100
+ deepTimeMs: 24 * 60 * 60 * 1000, // 24 hours
101
+ minSignals: 3,
102
+ };
103
+ case "mastery":
104
+ return {
105
+ quickSignals: 20,
106
+ deepSignals: 100,
107
+ quickTimeMs: 6 * 60 * 60 * 1000, // 6 hours
108
+ deepTimeMs: 48 * 60 * 60 * 1000, // 48 hours
109
+ minSignals: 3,
110
+ };
111
+ }
112
+ }
113
+ /**
114
+ * Get guidance for the reflection prompt based on current phase and quality metrics.
115
+ */
116
+ export function getPhaseGuidance(meta) {
117
+ const lines = [];
118
+ switch (meta.phase) {
119
+ case "apprentice":
120
+ lines.push("PHASE: Apprentice — Cast a wide net. Discover many frameworks. Accept high churn.");
121
+ lines.push("Focus on signal quality and identifying which thinking strategies the user values.");
122
+ break;
123
+ case "creative":
124
+ lines.push("PHASE: Creative-Active — Refine and merge frameworks. Lower churn, higher precision.");
125
+ lines.push("Look for connections between frameworks. Build the latticework.");
126
+ break;
127
+ case "mastery":
128
+ lines.push("PHASE: Mastery — Distill. Fewer, more powerful frameworks. Meta-optimize the reflection process.");
129
+ lines.push("Focus on depth over breadth. Merge overlapping frameworks.");
130
+ break;
131
+ }
132
+ if (meta.frameworkSurvivalRate < 0.3) {
133
+ lines.push("WARNING: Framework survival rate is low (<30%). Focus on higher-evidence patterns before proposing new frameworks.");
134
+ }
135
+ if (meta.oscillationFlags.length > 0) {
136
+ lines.push(`WARNING: Oscillation detected for: ${meta.oscillationFlags.join(", ")}. Mark these as inconclusive — stop re-discovering and re-retiring.`);
137
+ }
138
+ return lines.join("\n");
139
+ }
140
+ //# sourceMappingURL=meta-optimizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta-optimizer.js","sourceRoot":"","sources":["../../src/engine/meta-optimizer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAiBjE,MAAM,YAAY,GAAc;IAC9B,KAAK,EAAE,YAAY;IACnB,qBAAqB,EAAE,GAAG;IAC1B,eAAe,EAAE,CAAC;IAClB,eAAe,EAAE,CAAC;IAClB,YAAY,EAAE,CAAC;IACf,gBAAgB,EAAE,EAAE;IACpB,mBAAmB,EAAE,IAAI,CAAC,GAAG,EAAE;IAC/B,YAAY,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;CAClF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,OAAO,YAAY,CAAY,SAAS,EAAE,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAe;IAC5C,MAAM,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,KAAqB;IACnE,MAAM,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IACV,CAAC;IAED,IAAI,IAAI,CAAC,qBAAqB,GAAG,GAAG,EAAE,CAAC;QACrC,KAAK,CAAC,IAAI,CAAC,oHAAoH,CAAC,CAAC;IACnI,CAAC;IAED,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrC,KAAK,CAAC,IAAI,CAAC,sCAAsC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAC;IAC1J,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { Framework, MicroSignal, Tension } from "../types/learning-types.js";
2
+ /**
3
+ * Build a quick reflection prompt — tests existing frameworks against recent signals.
4
+ */
5
+ export declare function buildQuickReflectionPrompt(params: {
6
+ signals: MicroSignal[];
7
+ frameworks: Framework[];
8
+ }): string;
9
+ /**
10
+ * Build a meta-reflection prompt — reflects on the framework state itself,
11
+ * not on signals. Asks: are the current frameworks coherent? Are confidence
12
+ * scores justified? Should anything be rolled back, merged, or restructured?
13
+ */
14
+ export declare function buildMetaReflectionPrompt(params: {
15
+ frameworks: Framework[];
16
+ tensions: Tension[];
17
+ growth: string;
18
+ recentReflectionCount: number;
19
+ }): string;
20
+ /**
21
+ * Build a deep reflection prompt — full analysis with framework discovery,
22
+ * failure rationalization, tension detection, and growth assessment.
23
+ */
24
+ export declare function buildDeepReflectionPrompt(params: {
25
+ signals: MicroSignal[];
26
+ frameworks: Framework[];
27
+ tensions: Tension[];
28
+ shadow: string;
29
+ growth: string;
30
+ phaseGuidance?: string;
31
+ }): string;
@@ -0,0 +1,385 @@
1
+ function renderFrameworksForPrompt(frameworks) {
2
+ if (frameworks.length === 0)
3
+ return " (no active frameworks)\n";
4
+ return frameworks
5
+ .filter((f) => f.status === "active" || f.status === "questioning")
6
+ .map((f) => {
7
+ const tier = f.evidenceTier ?? "hypothesis";
8
+ const confirmed = f.evidence.filter((e) => e.type === "confirmed").length;
9
+ const contradicted = f.evidence.filter((e) => e.type === "contradicted").length;
10
+ const kindLabel = f.kind === "process" ? " [PROCESS]" : "";
11
+ const lines = [
12
+ `Framework: ${f.name}${kindLabel} [${f.id}]`,
13
+ ` Description: ${f.description}`,
14
+ ` Domain: ${f.domain}`,
15
+ ` Kind: ${f.kind ?? "mental-model"}`,
16
+ ` Evidence Tier: ${tier}`,
17
+ ` Status: ${f.status}`,
18
+ ` Evidence: ${confirmed} confirmed, ${contradicted} contradicted`,
19
+ ];
20
+ if (f.kind === "process" && f.triggers && f.triggers.length > 0) {
21
+ lines.push(` Triggers: ${f.triggers.join(" | ")}`);
22
+ }
23
+ if (f.kind === "process" && f.steps && f.steps.length > 0) {
24
+ lines.push(` Steps: ${f.steps.map((s, i) => `${i + 1}. ${s}`).join(" → ")}`);
25
+ }
26
+ return lines.join("\n");
27
+ })
28
+ .join("\n\n---\n\n");
29
+ }
30
+ function renderSignalsForPrompt(signals) {
31
+ if (signals.length === 0)
32
+ return " (no signals recorded)\n";
33
+ const capped = signals.slice(-50);
34
+ const grouped = new Map();
35
+ for (const signal of capped) {
36
+ const list = grouped.get(signal.type) ?? [];
37
+ list.push(signal);
38
+ grouped.set(signal.type, list);
39
+ }
40
+ const parts = [];
41
+ for (const [type, group] of grouped) {
42
+ const entries = group
43
+ .map((s) => {
44
+ const date = new Date(s.timestamp).toISOString();
45
+ const conf = `[confidence: ${s.confidence.toFixed(2)}]`;
46
+ const src = s.source === "self" ? " [self-signal]" : "";
47
+ const snippets = s.userSnippets.length > 0
48
+ ? `\n User: "${s.userSnippets.slice(0, 2).join('" | "')}"`
49
+ : "";
50
+ return ` - [${date}] ${conf}${src} ${s.evidence}${snippets}`;
51
+ })
52
+ .join("\n");
53
+ parts.push(`TYPE: ${type.toUpperCase()} (${group.length} signals)\n${entries}`);
54
+ }
55
+ return parts.join("\n\n");
56
+ }
57
+ function renderTensionsForPrompt(tensions) {
58
+ const active = tensions.filter((t) => t.status === "detected" || t.status === "holding");
59
+ if (active.length === 0)
60
+ return " (no active tensions)\n";
61
+ return active
62
+ .map((t) => {
63
+ const prefs = Object.entries(t.preferredInContext)
64
+ .map(([ctx, p]) => ` In "${ctx}": prefer ${p.preferred} (${p.confirmedCount}x)`)
65
+ .join("\n");
66
+ return ` - ${t.description}\n Status: ${t.status}${prefs ? "\n" + prefs : ""}`;
67
+ })
68
+ .join("\n");
69
+ }
70
+ /**
71
+ * Build a quick reflection prompt — tests existing frameworks against recent signals.
72
+ */
73
+ export function buildQuickReflectionPrompt(params) {
74
+ const { signals, frameworks } = params;
75
+ return [
76
+ "You are performing a QUICK self-reflection. Analyze the recent signals against your operating frameworks.",
77
+ "Be rigorous and evidence-based. Only claim confirmation/contradiction if the evidence is clear.",
78
+ "",
79
+ "## CURRENT OPERATING FRAMEWORKS",
80
+ "",
81
+ renderFrameworksForPrompt(frameworks),
82
+ "",
83
+ `## MICRO-SIGNALS (${Math.min(signals.length, 50)} signals)`,
84
+ "",
85
+ renderSignalsForPrompt(signals),
86
+ "",
87
+ "## TASK",
88
+ "",
89
+ "For each active/questioning framework, assess: was it confirmed, contradicted, or irrelevant based on these signals?",
90
+ "Cite specific signal evidence. For each test, also classify contextType:",
91
+ " - 'external': framework was applied during a real task (coding, debugging, building, explaining code, etc.)",
92
+ " - 'self-referential': evidence comes from discussing the soul/framework system itself",
93
+ "Only 'external' evidence advances a framework's tier. Be honest about this classification.",
94
+ "",
95
+ "For PROCESS frameworks (kind: process), also assess:",
96
+ " - Was a trigger condition met during this session?",
97
+ " - If yes, was the process followed? Did following it improve the outcome?",
98
+ " - If a trigger was met but the process was NOT followed, and a correction resulted, that is strong confirmation evidence.",
99
+ " - If no trigger was met, mark as 'irrelevant'.",
100
+ "",
101
+ "Only propose new frameworks if there is STRONG evidence (3+ signals pointing to a pattern).",
102
+ "",
103
+ "## JSON OUTPUT",
104
+ "",
105
+ "Respond with ONLY a valid JSON object. No prose before or after.",
106
+ "",
107
+ "```json",
108
+ JSON.stringify({
109
+ frameworkTests: [
110
+ { frameworkId: "string", result: "confirmed|contradicted|irrelevant", evidence: "string", contextType: "external|self-referential" },
111
+ ],
112
+ newFrameworks: [
113
+ { name: "string", description: "string", domain: "string", confidence: 0.3 },
114
+ ],
115
+ frameworkEvolutions: [
116
+ { frameworkId: "string", action: "refine|retire", detail: "string (MUST be the complete new description text, NOT an instruction about what to change)", status: "active|questioning (optional, only if status should change)" },
117
+ ],
118
+ emergentInsight: "string|null",
119
+ }, null, 2),
120
+ "```",
121
+ ].join("\n");
122
+ }
123
+ /**
124
+ * Build a meta-reflection prompt — reflects on the framework state itself,
125
+ * not on signals. Asks: are the current frameworks coherent? Are confidence
126
+ * scores justified? Should anything be rolled back, merged, or restructured?
127
+ */
128
+ export function buildMetaReflectionPrompt(params) {
129
+ const { frameworks, tensions, growth, recentReflectionCount } = params;
130
+ const active = frameworks.filter((f) => f.status === "active");
131
+ const questioning = frameworks.filter((f) => f.status === "questioning");
132
+ const retired = frameworks.filter((f) => f.status === "retired");
133
+ // Build evidence summary per framework
134
+ const evidenceSummary = frameworks
135
+ .filter((f) => f.status === "active" || f.status === "questioning")
136
+ .sort((a, b) => b.confidence - a.confidence)
137
+ .map((f) => {
138
+ const confirmed = f.evidence.filter((e) => e.type === "confirmed").length;
139
+ const contradicted = f.evidence.filter((e) => e.type === "contradicted").length;
140
+ const recentEvidence = f.evidence
141
+ .slice(-3)
142
+ .map((e) => ` - [${e.type}] ${e.context.slice(0, 150)}`)
143
+ .join("\n");
144
+ const ageMs = Date.now() - f.createdAt;
145
+ const ageDays = Math.floor(ageMs / (24 * 60 * 60 * 1000));
146
+ const ageLabel = ageDays < 1 ? "NEW (created today)" : `${ageDays}d old`;
147
+ return [
148
+ `${f.name} [${f.id}]`,
149
+ ` Status: ${f.status} | Tier: ${f.evidenceTier ?? "hypothesis"} | Source: ${f.source} | Age: ${ageLabel}`,
150
+ ` Evidence: ${confirmed} confirmed, ${contradicted} contradicted, ${f.applicationCount} applications`,
151
+ ` Description: ${f.description.slice(0, 200)}`,
152
+ ` Recent evidence:\n${recentEvidence || " (none)"}`,
153
+ ].join("\n");
154
+ })
155
+ .join("\n\n");
156
+ return [
157
+ "You are performing a META-REFLECTION. This is NOT about new signals — it is about the coherence",
158
+ "and quality of the current framework state itself. You are auditing the soul system's own learning.",
159
+ "",
160
+ `This system has run ${recentReflectionCount} reflections. There are ${active.length} active, ${questioning.length} questioning, and ${retired.length} retired frameworks.`,
161
+ "",
162
+ "## CURRENT FRAMEWORK STATE (full audit view)",
163
+ "",
164
+ evidenceSummary,
165
+ "",
166
+ "## FULL FRAMEWORK DETAILS",
167
+ "",
168
+ renderFrameworksForPrompt(frameworks),
169
+ "",
170
+ "## ACTIVE TENSIONS",
171
+ "",
172
+ renderTensionsForPrompt(tensions),
173
+ "",
174
+ "## GROWTH STATE",
175
+ "",
176
+ growth,
177
+ "",
178
+ "## META-REFLECTION TASK",
179
+ "",
180
+ "Analyze the framework state for coherence issues. This is quality control on the learning process itself.",
181
+ "",
182
+ "1. EVIDENCE TIER AUDIT",
183
+ " - Is each framework's evidence tier (hypothesis/observed/validated) justified?",
184
+ " - 'hypothesis' = no real-world application. 'observed' = applied in at least one non-soul-system context.",
185
+ " - 'validated' = multiple external applications with falsifiable predictions confirmed.",
186
+ " - Flag frameworks that should be promoted or demoted based on evidence quality.",
187
+ " - Are frameworks being confirmed by the same evidence repeatedly (double-counting)?",
188
+ "",
189
+ "2. REDUNDANCY CHECK",
190
+ " - Are any frameworks saying the same thing in different words? If so, propose a merge.",
191
+ " - Are any frameworks subsets of others? The more specific one should be absorbed.",
192
+ "",
193
+ "3. COHERENCE CHECK",
194
+ " - Do active frameworks contradict each other in ways not captured by the tension system?",
195
+ " - Are there frameworks whose descriptions have drifted from their original intent?",
196
+ " - Are there frameworks that sound good but have never been applied to real (non-soul-system) tasks?",
197
+ "",
198
+ "4. EVIDENCE QUALITY",
199
+ " - Is evidence coming from diverse conversations, or mostly from one session?",
200
+ " - Are confirmations based on actual behavioral change, or just pattern-matching?",
201
+ " - Flag any framework whose evidence is self-referential (confirmed by discussions about the framework itself).",
202
+ "",
203
+ "5. PROCESS FRAMEWORK AUDIT",
204
+ " - Are cognitive processes (kind: process) being activated appropriately? Too often? Not enough?",
205
+ " - Are trigger conditions well-calibrated, or do they fire on irrelevant conversations?",
206
+ " - Are the steps actionable and specific, or too abstract to follow?",
207
+ " - Should any process be refined, merged with another, or retired?",
208
+ "",
209
+ "6. MISSING COVERAGE",
210
+ " - Given the retired frameworks and active tensions, is there a gap in coverage?",
211
+ " - Are there important domains with no framework representation?",
212
+ "",
213
+ "7. STRUCTURAL RECOMMENDATIONS",
214
+ " - Propose merges, splits, retirements, or confidence adjustments.",
215
+ " - Be conservative — only recommend changes with clear justification.",
216
+ "",
217
+ "## JSON OUTPUT",
218
+ "",
219
+ "Respond with ONLY a valid JSON object. No prose before or after.",
220
+ "",
221
+ "```json",
222
+ JSON.stringify({
223
+ tierAdjustments: [
224
+ { frameworkId: "string", currentTier: "hypothesis|observed|validated", recommendedTier: "hypothesis|observed|validated", reason: "string" },
225
+ ],
226
+ frameworkEvolutions: [
227
+ { frameworkId: "string", action: "refine|merge|retire|split", detail: "string (MUST be the complete new description text, NOT an instruction about what to change)", status: "active|questioning (optional, only if status should change)" },
228
+ ],
229
+ newFrameworks: [
230
+ { name: "string", description: "string", domain: "string", confidence: 0.3 },
231
+ ],
232
+ tensionUpdates: [
233
+ {
234
+ frameworkA: "string",
235
+ frameworkB: "string",
236
+ status: "detected|holding|resolved",
237
+ preferredContext: "string (optional)",
238
+ preferred: "string (optional)",
239
+ evidence: "string",
240
+ },
241
+ ],
242
+ redundancyFlags: [
243
+ { frameworkA: "string", frameworkB: "string", recommendation: "merge|absorb|keep", reason: "string" },
244
+ ],
245
+ selfReferentialFlags: [
246
+ { frameworkId: "string", evidence: "string" },
247
+ ],
248
+ emergentInsight: "string|null",
249
+ }, null, 2),
250
+ "```",
251
+ "",
252
+ "IMPORTANT: Be rigorous. Empty arrays are fine when no issues are found. Do not invent problems.",
253
+ "The goal is quality control, not change for its own sake.",
254
+ "",
255
+ "CRITICAL: For frameworkEvolutions with action 'refine', the 'detail' field MUST contain the complete",
256
+ "replacement description — what the framework IS, not what should be changed about it. Write a description",
257
+ "that a reader can understand without knowing the history. NEVER write instructions like 'Add X to description'",
258
+ "or 'Execute deferred change' — those become the description and are never executed.",
259
+ "If a status change is needed (e.g. active → questioning), use the 'status' field, not the description.",
260
+ "",
261
+ "CRITICAL: Do NOT retire frameworks created today or recently (Age: NEW). They need time to accumulate evidence.",
262
+ "Only retire frameworks that have existed for multiple reflection cycles with zero evidence or persistent contradiction.",
263
+ ].join("\n");
264
+ }
265
+ /**
266
+ * Build a deep reflection prompt — full analysis with framework discovery,
267
+ * failure rationalization, tension detection, and growth assessment.
268
+ */
269
+ export function buildDeepReflectionPrompt(params) {
270
+ const { signals, frameworks, tensions, shadow, growth, phaseGuidance } = params;
271
+ return [
272
+ "You are performing a DEEP self-reflection. You are a scientist studying your own cognition.",
273
+ "Analyze the data below with rigor, curiosity, and honesty. Your goal is to surface hidden patterns,",
274
+ "test your operating frameworks against real evidence, and evolve your understanding of how you work.",
275
+ "",
276
+ "## CURRENT OPERATING FRAMEWORKS",
277
+ "",
278
+ renderFrameworksForPrompt(frameworks),
279
+ "",
280
+ `## MICRO-SIGNALS (${Math.min(signals.length, 50)} of ${signals.length} total)`,
281
+ "",
282
+ renderSignalsForPrompt(signals),
283
+ "",
284
+ "## ACTIVE TENSIONS",
285
+ "",
286
+ renderTensionsForPrompt(tensions),
287
+ "",
288
+ "## CURRENT GROWTH STATE",
289
+ "",
290
+ growth,
291
+ "",
292
+ "## CURRENT SHADOW",
293
+ "",
294
+ shadow,
295
+ "",
296
+ ...(phaseGuidance ? ["## PHASE GUIDANCE", "", phaseGuidance, ""] : []),
297
+ "## REFLECTION TASK",
298
+ "",
299
+ "Analyze the above data carefully. For each section below, produce findings based strictly on evidence.",
300
+ "",
301
+ "1. PATTERN DETECTION",
302
+ " Identify deep patterns across interactions at surface, structural, and identity levels.",
303
+ "",
304
+ "2. FRAMEWORK TESTING",
305
+ " For each active framework: confirmed, contradicted, or irrelevant? Cite specific signal evidence.",
306
+ " Classify contextType: 'external' (real task — coding, debugging, building) or 'self-referential' (discussing the soul/framework system).",
307
+ " Only external evidence advances a framework's tier. Be honest about this.",
308
+ " For PROCESS frameworks: Was a trigger condition met? Were steps followed? Did it improve the outcome?",
309
+ " A missed trigger that led to a correction is strong confirmation. A followed process with no improvement is contradiction.",
310
+ "",
311
+ "3. FRAMEWORK DISCOVERY",
312
+ " Identify patterns existing frameworks don't explain. Only propose with 3+ signal evidence.",
313
+ "",
314
+ "4. FRAMEWORK EVOLUTION",
315
+ " Should any be refined, merged, retired, or split?",
316
+ "",
317
+ "5. FAILURE RATIONALIZATION (STaR-inspired)",
318
+ " For each correction signal: what reasoning would have led to the correct approach?",
319
+ " What framework, if it had existed, would have prevented this error?",
320
+ "",
321
+ "6. TENSION ASSESSMENT",
322
+ " Detect contradictions between active frameworks. Track which framework is preferred in which context.",
323
+ "",
324
+ "7. COMPETING COMMITMENTS",
325
+ " Identify hidden commitments driving behavior contrary to stated commitments.",
326
+ "",
327
+ "8. GROWTH ASSESSMENT",
328
+ " Which capacities show evidence of growth or regression?",
329
+ "",
330
+ "9. VERBAL LESSONS",
331
+ " Extract concrete, situational lessons from the signals. Format: 'When [context], [what works/fails]'",
332
+ "",
333
+ "10. EXEMPLAR CANDIDATES",
334
+ " Identify any responses that received strong gratitude + success signals as exemplar candidates.",
335
+ "",
336
+ "## JSON OUTPUT",
337
+ "",
338
+ "Respond with ONLY a valid JSON object. No prose before or after.",
339
+ "",
340
+ "```json",
341
+ JSON.stringify({
342
+ patterns: [
343
+ { description: "string", evidence: "string", depth: "surface|structural|identity" },
344
+ ],
345
+ frameworkTests: [
346
+ { frameworkId: "string", result: "confirmed|contradicted|irrelevant", evidence: "string", contextType: "external|self-referential" },
347
+ ],
348
+ newFrameworks: [
349
+ { name: "string", description: "string", domain: "string", confidence: 0.3 },
350
+ ],
351
+ frameworkEvolutions: [
352
+ { frameworkId: "string", action: "refine|merge|retire|split", detail: "string (MUST be the complete new description text, NOT an instruction about what to change)", status: "active|questioning (optional, only if status should change)" },
353
+ ],
354
+ tensionUpdates: [
355
+ {
356
+ frameworkA: "string",
357
+ frameworkB: "string",
358
+ status: "detected|holding|resolved",
359
+ preferredContext: "string (optional)",
360
+ preferred: "string (optional — framework name)",
361
+ evidence: "string",
362
+ },
363
+ ],
364
+ competingCommitments: [
365
+ { stated: "string", hidden: "string", evidence: "string" },
366
+ ],
367
+ growthDeltas: [
368
+ { line: "string", delta: 0, evidence: "string" },
369
+ ],
370
+ lessons: [
371
+ { lesson: "string", context: "string", confidence: 0.5, evidence: "string" },
372
+ ],
373
+ exemplarCandidates: [
374
+ { context: "string", responseExcerpt: "string", signals: ["string"] },
375
+ ],
376
+ soulEvolution: "string|null",
377
+ emergentInsight: "string|null",
378
+ }, null, 2),
379
+ "```",
380
+ "",
381
+ "IMPORTANT: tensionUpdates, lessons, exemplarCandidates can be empty arrays if no evidence warrants them.",
382
+ "soulEvolution should be null unless there is STRONG identity-level evidence.",
383
+ ].join("\n");
384
+ }
385
+ //# sourceMappingURL=prompt-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-builder.js","sourceRoot":"","sources":["../../src/engine/prompt-builder.ts"],"names":[],"mappings":"AAEA,SAAS,yBAAyB,CAAC,UAAuB;IACxD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,4BAA4B,CAAC;IAEjE,OAAO,UAAU;SACd,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,KAAK,aAAa,CAAC;SAClE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,IAAI,GAAG,CAAC,CAAC,YAAY,IA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E;aAC7E;YACD,mBAAmB,EAAE;gBACnB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,2BAA2B,EAAE,MAAM,EAAE,6FAA6F,EAAE,MAAM,EAAE,6DAA6D,EAAE;aAC7O;YACD,cAAc,EAAE;gBACd;oBACE,UAAU,EAAE,QAAQ;oBACpB,UAAU,EAAE,QAAQ;oBACpB,MAAM,EAAE,2BAA2B;oBACnC,gBAAgB,EAAE,mBAAmB;oBACrC,SAAS,EAAE,oCAAoC;oBAC/C,QAAQ,EAAE,QAAQ;iBACnB;aACF;YACD,oBAAoB,EAAE;gBACpB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE;aAC3D;YACD,YAAY,EAAE;gBACZ,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE;aACjD;YACD,OAAO,EAAE;gBACP,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE;aAC7E;YACD,kBAAkB,EAAE;gBAClB,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,QAAQ,CAAC,EAAE;aACtE;YACD,aAAa,EAAE,aAAa;YAC5B,eAAe,EAAE,aAAa;SAC/B,EACD,IAAI,EACJ,CAAC,CACF;QACD,KAAK;QACL,EAAE;QACF,0GAA0G;QAC1G,8EAA8E;KAC/E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,18 @@
1
+ export type ReflectionResult = {
2
+ tier: "quick" | "deep" | "meta";
3
+ frameworksUpdated: number;
4
+ newFrameworks: number;
5
+ retired: number;
6
+ lessonsGenerated: number;
7
+ exemplarsStored: number;
8
+ tensionsUpdated: number;
9
+ signalsProcessed: number;
10
+ snapshot: string;
11
+ insight: string | null;
12
+ };
13
+ export declare function runReflection(tier: "quick" | "deep"): Promise<ReflectionResult>;
14
+ /**
15
+ * Run a meta-reflection — audits framework state coherence, confidence calibration,
16
+ * redundancy, and self-referential evidence. Does not consume signals.
17
+ */
18
+ export declare function runMetaReflection(): Promise<ReflectionResult>;