fivocell 7.0.0 → 7.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.
- package/README.md +120 -237
- package/dist/walls/01-context/context/agents-md.d.ts +1 -1
- package/dist/walls/01-context/context/agents-md.d.ts.map +1 -1
- package/dist/walls/01-context/context/agents-md.js +33 -1
- package/dist/walls/01-context/context/agents-md.js.map +1 -1
- package/dist/walls/01-context/context/context-bridge.d.ts +39 -0
- package/dist/walls/01-context/context/context-bridge.d.ts.map +1 -0
- package/dist/walls/01-context/context/context-bridge.js +224 -0
- package/dist/walls/01-context/context/context-bridge.js.map +1 -0
- package/dist/walls/01-context/context/context-continuity.d.ts +54 -0
- package/dist/walls/01-context/context/context-continuity.d.ts.map +1 -0
- package/dist/walls/01-context/context/context-continuity.js +350 -0
- package/dist/walls/01-context/context/context-continuity.js.map +1 -0
- package/dist/walls/01-context/context/context-predictor.d.ts +24 -0
- package/dist/walls/01-context/context/context-predictor.d.ts.map +1 -0
- package/dist/walls/01-context/context/context-predictor.js +322 -0
- package/dist/walls/01-context/context/context-predictor.js.map +1 -0
- package/dist/walls/01-context/context/prompt-builder.d.ts.map +1 -1
- package/dist/walls/01-context/context/prompt-builder.js +53 -0
- package/dist/walls/01-context/context/prompt-builder.js.map +1 -1
- package/dist/walls/01-context/sessions/session-memory.d.ts.map +1 -1
- package/dist/walls/01-context/sessions/session-memory.js +47 -1
- package/dist/walls/01-context/sessions/session-memory.js.map +1 -1
- package/dist/walls/04-team/collab/team-supreme.d.ts +70 -0
- package/dist/walls/04-team/collab/team-supreme.d.ts.map +1 -0
- package/dist/walls/04-team/collab/team-supreme.js +357 -0
- package/dist/walls/04-team/collab/team-supreme.js.map +1 -0
- package/dist/walls/05-community/share/cloud-connector.d.ts +83 -0
- package/dist/walls/05-community/share/cloud-connector.d.ts.map +1 -0
- package/dist/walls/05-community/share/cloud-connector.js +385 -0
- package/dist/walls/05-community/share/cloud-connector.js.map +1 -0
- package/dist/walls/05-community/stats/community-supreme.d.ts +83 -0
- package/dist/walls/05-community/stats/community-supreme.d.ts.map +1 -0
- package/dist/walls/05-community/stats/community-supreme.js +221 -0
- package/dist/walls/05-community/stats/community-supreme.js.map +1 -0
- package/dist/walls/06-memory/vibe/vibe-confidence.js +6 -6
- package/dist/walls/06-memory/vibe/vibe-confidence.js.map +1 -1
- package/dist/walls/06-memory/vibe/vibe-engine.d.ts +7 -0
- package/dist/walls/06-memory/vibe/vibe-engine.d.ts.map +1 -1
- package/dist/walls/06-memory/vibe/vibe-engine.js +323 -240
- package/dist/walls/06-memory/vibe/vibe-engine.js.map +1 -1
- package/dist/walls/06-memory/vibe/vibe-intelligence.d.ts +19 -0
- package/dist/walls/06-memory/vibe/vibe-intelligence.d.ts.map +1 -0
- package/dist/walls/06-memory/vibe/vibe-intelligence.js +264 -0
- package/dist/walls/06-memory/vibe/vibe-intelligence.js.map +1 -0
- package/dist/walls/06-memory/vibe/vibe-signals.d.ts +3 -0
- package/dist/walls/06-memory/vibe/vibe-signals.d.ts.map +1 -1
- package/dist/walls/06-memory/vibe/vibe-signals.js +122 -9
- package/dist/walls/06-memory/vibe/vibe-signals.js.map +1 -1
- package/dist/walls/07-runtime/cli/cli.js +8 -0
- package/dist/walls/07-runtime/cli/cli.js.map +1 -1
- package/dist/walls/07-runtime/cli/commands/cloud.d.ts +3 -0
- package/dist/walls/07-runtime/cli/commands/cloud.d.ts.map +1 -0
- package/dist/walls/07-runtime/cli/commands/cloud.js +219 -0
- package/dist/walls/07-runtime/cli/commands/cloud.js.map +1 -0
- package/dist/walls/07-runtime/cli/commands/community.d.ts.map +1 -1
- package/dist/walls/07-runtime/cli/commands/community.js +6 -0
- package/dist/walls/07-runtime/cli/commands/community.js.map +1 -1
- package/dist/walls/07-runtime/cli/commands/help.d.ts.map +1 -1
- package/dist/walls/07-runtime/cli/commands/help.js +85 -75
- package/dist/walls/07-runtime/cli/commands/help.js.map +1 -1
- package/dist/walls/07-runtime/cli/utils.js +2 -2
- package/dist/walls/07-runtime/daemon/lifecycle.d.ts.map +1 -1
- package/dist/walls/07-runtime/daemon/lifecycle.js +13 -1
- package/dist/walls/07-runtime/daemon/lifecycle.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// context-bridge.ts — Supreme Session Bridge
|
|
3
|
+
// Rich session-end capture. Auto-injects at next session start.
|
|
4
|
+
// The bridge ensures AI never starts a session "blind" — always has previous context.
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.captureSessionBridge = captureSessionBridge;
|
|
40
|
+
exports.consumeSessionBridge = consumeSessionBridge;
|
|
41
|
+
exports.peekSessionBridge = peekSessionBridge;
|
|
42
|
+
exports.isBridgeStale = isBridgeStale;
|
|
43
|
+
exports.autoGenerateBridge = autoGenerateBridge;
|
|
44
|
+
exports.formatBridgeForContext = formatBridgeForContext;
|
|
45
|
+
const fs = __importStar(require("fs"));
|
|
46
|
+
const path = __importStar(require("path"));
|
|
47
|
+
const database_1 = require("../../06-memory/database/database");
|
|
48
|
+
function getBridgeDir(projectDir) {
|
|
49
|
+
const d = path.join(projectDir, '.cell', 'bridge');
|
|
50
|
+
if (!fs.existsSync(d))
|
|
51
|
+
fs.mkdirSync(d, { recursive: true });
|
|
52
|
+
return d;
|
|
53
|
+
}
|
|
54
|
+
function bridgeFilePath(projectDir) {
|
|
55
|
+
return path.join(getBridgeDir(projectDir), 'latest.json');
|
|
56
|
+
}
|
|
57
|
+
// CAPTURE: Called at session end — full snapshot of everything AI needs to remember
|
|
58
|
+
function captureSessionBridge(projectDir, params) {
|
|
59
|
+
const bridge = {
|
|
60
|
+
fromSessionId: params.sessionId,
|
|
61
|
+
capturedAt: new Date().toISOString(),
|
|
62
|
+
consumed: false,
|
|
63
|
+
project: params.project,
|
|
64
|
+
tool: params.tool,
|
|
65
|
+
summary: params.summary,
|
|
66
|
+
status: params.status,
|
|
67
|
+
filesTouched: params.filesTouched,
|
|
68
|
+
keyDecisions: params.keyDecisions,
|
|
69
|
+
openQuestions: params.openQuestions,
|
|
70
|
+
failedApproaches: params.failedApproaches,
|
|
71
|
+
workingApproaches: params.workingApproaches,
|
|
72
|
+
lastThought: params.lastThought,
|
|
73
|
+
vibeAtCapture: '',
|
|
74
|
+
predictedNextSteps: params.predictedNextSteps,
|
|
75
|
+
};
|
|
76
|
+
// Try to read vibes
|
|
77
|
+
try {
|
|
78
|
+
const vibePath = path.join(projectDir, '.cell', 'vibe', 'vibe-summary.json');
|
|
79
|
+
if (fs.existsSync(vibePath)) {
|
|
80
|
+
const v = JSON.parse(fs.readFileSync(vibePath, 'utf-8'));
|
|
81
|
+
bridge.vibeAtCapture = v.summary || '';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch { }
|
|
85
|
+
const dir = getBridgeDir(projectDir);
|
|
86
|
+
fs.writeFileSync(bridgeFilePath(projectDir), JSON.stringify(bridge, null, 2), 'utf-8');
|
|
87
|
+
// Also archive old bridges
|
|
88
|
+
const archiveFile = path.join(dir, `bridge-${params.sessionId}-${Date.now()}.json`);
|
|
89
|
+
fs.writeFileSync(archiveFile, JSON.stringify(bridge, null, 2), 'utf-8');
|
|
90
|
+
// Cleanup old archives — keep last 10
|
|
91
|
+
const archives = fs.readdirSync(dir)
|
|
92
|
+
.filter(f => f.startsWith('bridge-') && f.endsWith('.json'))
|
|
93
|
+
.sort()
|
|
94
|
+
.reverse();
|
|
95
|
+
for (const f of archives.slice(10)) {
|
|
96
|
+
fs.unlinkSync(path.join(dir, f));
|
|
97
|
+
}
|
|
98
|
+
return bridge;
|
|
99
|
+
}
|
|
100
|
+
// CONSUME: Called at session start — auto-inject previous bridge
|
|
101
|
+
function consumeSessionBridge(projectDir, currentSessionId) {
|
|
102
|
+
const bp = bridgeFilePath(projectDir);
|
|
103
|
+
if (!fs.existsSync(bp))
|
|
104
|
+
return null;
|
|
105
|
+
const bridge = JSON.parse(fs.readFileSync(bp, 'utf-8'));
|
|
106
|
+
if (bridge.consumed)
|
|
107
|
+
return null; // Already used
|
|
108
|
+
bridge.consumed = true;
|
|
109
|
+
bridge.consumedAt = new Date().toISOString();
|
|
110
|
+
bridge.toSessionId = currentSessionId;
|
|
111
|
+
fs.writeFileSync(bp, JSON.stringify(bridge, null, 2), 'utf-8');
|
|
112
|
+
return bridge;
|
|
113
|
+
}
|
|
114
|
+
// Get bridge without consuming (for display)
|
|
115
|
+
function peekSessionBridge(projectDir) {
|
|
116
|
+
const bp = bridgeFilePath(projectDir);
|
|
117
|
+
if (!fs.existsSync(bp))
|
|
118
|
+
return null;
|
|
119
|
+
return JSON.parse(fs.readFileSync(bp, 'utf-8'));
|
|
120
|
+
}
|
|
121
|
+
// Check staleness — warn if bridge is older than 24 hours
|
|
122
|
+
function isBridgeStale(projectDir) {
|
|
123
|
+
const bridge = peekSessionBridge(projectDir);
|
|
124
|
+
if (!bridge)
|
|
125
|
+
return false;
|
|
126
|
+
const age = Date.now() - new Date(bridge.capturedAt).getTime();
|
|
127
|
+
return age > 24 * 60 * 60 * 1000; // 24 hours
|
|
128
|
+
}
|
|
129
|
+
// Auto-generate bridge if one doesn't exist (from DB)
|
|
130
|
+
function autoGenerateBridge(projectDir, project) {
|
|
131
|
+
try {
|
|
132
|
+
const db = (0, database_1.getDb)();
|
|
133
|
+
const lastSession = db.prepare('SELECT id, tool_name, start_time, end_time, files_touched, key_decisions, context_snapshot FROM sessions WHERE project = ? ORDER BY id DESC LIMIT 1').get(project);
|
|
134
|
+
if (!lastSession)
|
|
135
|
+
return null;
|
|
136
|
+
const approaches = db.prepare('SELECT approach, status, reason FROM session_approaches WHERE session_id = ? ORDER BY id DESC LIMIT 20').all(lastSession.id);
|
|
137
|
+
const questions = db.prepare('SELECT question, resolved FROM session_questions WHERE session_id = ? ORDER BY id DESC LIMIT 10').all(lastSession.id);
|
|
138
|
+
const failed = approaches.filter((a) => a.status === 'failed' || a.status === 'rejected').map((a) => a.approach);
|
|
139
|
+
const worked = approaches.filter((a) => a.status === 'accepted' || a.status === 'worked').map((a) => a.approach);
|
|
140
|
+
let files = [];
|
|
141
|
+
try {
|
|
142
|
+
files = JSON.parse(lastSession.files_touched || '[]');
|
|
143
|
+
}
|
|
144
|
+
catch { }
|
|
145
|
+
let decisions = [];
|
|
146
|
+
try {
|
|
147
|
+
decisions = JSON.parse(lastSession.key_decisions || '[]');
|
|
148
|
+
}
|
|
149
|
+
catch { }
|
|
150
|
+
return captureSessionBridge(projectDir, {
|
|
151
|
+
sessionId: lastSession.id,
|
|
152
|
+
project,
|
|
153
|
+
tool: lastSession.tool_name || 'unknown',
|
|
154
|
+
summary: lastSession.context_snapshot || 'No summary captured.',
|
|
155
|
+
status: 'completed',
|
|
156
|
+
filesTouched: files,
|
|
157
|
+
keyDecisions: decisions,
|
|
158
|
+
openQuestions: questions.filter((q) => !q.resolved).map((q) => q.question),
|
|
159
|
+
failedApproaches: failed,
|
|
160
|
+
workingApproaches: worked,
|
|
161
|
+
lastThought: decisions.slice(-3).join('; ') || 'No explicit closing thought captured.',
|
|
162
|
+
predictedNextSteps: [],
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Format the bridge for injection into AI context
|
|
170
|
+
function formatBridgeForContext(bridge) {
|
|
171
|
+
const lines = [];
|
|
172
|
+
lines.push('🌉 LAST SESSION BRIDGE');
|
|
173
|
+
lines.push(` Completed: ${bridge.capturedAt.split('T')[0]} via ${bridge.tool}`);
|
|
174
|
+
lines.push(` Status: ${bridge.status}`);
|
|
175
|
+
if (bridge.summary && bridge.summary !== 'No summary captured.') {
|
|
176
|
+
lines.push('');
|
|
177
|
+
lines.push(` 📝 SUMMARY: ${bridge.summary}`);
|
|
178
|
+
}
|
|
179
|
+
if (bridge.keyDecisions.length > 0) {
|
|
180
|
+
lines.push('');
|
|
181
|
+
lines.push(' 🎯 KEY DECISIONS:');
|
|
182
|
+
for (const d of bridge.keyDecisions.slice(-5)) {
|
|
183
|
+
lines.push(` • ${d}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (bridge.keyDecisions.length > 0) {
|
|
187
|
+
lines.push('');
|
|
188
|
+
lines.push(` 💭 LAST THOUGHT: ${bridge.lastThought}`);
|
|
189
|
+
}
|
|
190
|
+
if (bridge.openQuestions.length > 0) {
|
|
191
|
+
lines.push('');
|
|
192
|
+
lines.push(' ❓ UNRESOLVED:');
|
|
193
|
+
for (const q of bridge.openQuestions.slice(0, 5)) {
|
|
194
|
+
lines.push(` ? ${q}`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (bridge.failedApproaches.length > 0) {
|
|
198
|
+
lines.push('');
|
|
199
|
+
lines.push(' 🚫 DON\'T RETRY:');
|
|
200
|
+
for (const a of bridge.failedApproaches.slice(0, 3)) {
|
|
201
|
+
lines.push(` ✗ ${a}`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (bridge.workingApproaches.length > 0) {
|
|
205
|
+
lines.push('');
|
|
206
|
+
lines.push(' ✅ APPROACHES THAT WORKED:');
|
|
207
|
+
for (const a of bridge.workingApproaches.slice(0, 3)) {
|
|
208
|
+
lines.push(` ✓ ${a}`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (bridge.filesTouched.length > 0) {
|
|
212
|
+
lines.push('');
|
|
213
|
+
lines.push(' 📁 FILES IN FOCUS:');
|
|
214
|
+
for (const f of bridge.filesTouched.slice(0, 8)) {
|
|
215
|
+
lines.push(` · ${f}`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (bridge.vibeAtCapture) {
|
|
219
|
+
lines.push('');
|
|
220
|
+
lines.push(` 🎭 VIBE: ${bridge.vibeAtCapture}`);
|
|
221
|
+
}
|
|
222
|
+
return lines.join('\n');
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=context-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-bridge.js","sourceRoot":"","sources":["../../../../src/walls/01-context/context/context-bridge.ts"],"names":[],"mappings":";AAAA,6CAA6C;AAC7C,gEAAgE;AAChE,sFAAsF;;;;;;;;;;;;;;;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;QACf,KAAK,CAAC,IAAI,CAAC,eAAe,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface ContinuityThread {
|
|
2
|
+
project: string;
|
|
3
|
+
threadId: string;
|
|
4
|
+
activeSince: string;
|
|
5
|
+
lastActiveAt: string;
|
|
6
|
+
sessionCount: number;
|
|
7
|
+
contextTags: string[];
|
|
8
|
+
openQuestions: string[];
|
|
9
|
+
pendingActions: string[];
|
|
10
|
+
keyLearnings: string[];
|
|
11
|
+
decisionLog: Array<{
|
|
12
|
+
what: string;
|
|
13
|
+
why: string;
|
|
14
|
+
when: string;
|
|
15
|
+
}>;
|
|
16
|
+
fileFocus: string[];
|
|
17
|
+
threadIntent: string;
|
|
18
|
+
bridgeHints: BridgeHint[];
|
|
19
|
+
}
|
|
20
|
+
export interface BridgeHint {
|
|
21
|
+
type: 'remember' | 'continue' | 'watch_out' | 'prediction' | 'decision';
|
|
22
|
+
text: string;
|
|
23
|
+
confidence: number;
|
|
24
|
+
fromSessionId: number;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ContinuityContext {
|
|
28
|
+
currentThread: ContinuityThread | null;
|
|
29
|
+
recentThreads: ContinuityThread[];
|
|
30
|
+
crossSessionWarnings: string[];
|
|
31
|
+
predictedNextSteps: string[];
|
|
32
|
+
memoryThread: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function getActiveThread(projectDir: string): ContinuityThread | null;
|
|
35
|
+
export declare function getAllThreads(projectDir: string): ContinuityThread[];
|
|
36
|
+
export declare function detectOrCreateThread(projectDir: string, project: string, recentDecisions: string[], touchedFiles: string[]): ContinuityThread;
|
|
37
|
+
export declare function closeThread(projectDir: string): void;
|
|
38
|
+
export declare function addBridgeHint(projectDir: string, hint: BridgeHint): void;
|
|
39
|
+
export declare function addOpenQuestion(projectDir: string, question: string): void;
|
|
40
|
+
export declare function resolveQuestion(projectDir: string, question: string): void;
|
|
41
|
+
export declare function addPendingAction(projectDir: string, action: string): void;
|
|
42
|
+
export declare function addKeyLearning(projectDir: string, learning: string): void;
|
|
43
|
+
export declare function addDecision(projectDir: string, what: string, why: string): void;
|
|
44
|
+
export declare function updateFileFocus(projectDir: string, files: string[]): void;
|
|
45
|
+
export declare function buildContinuityContext(projectDir: string, project: string): ContinuityContext;
|
|
46
|
+
export declare function captureSessionEnd(projectDir: string, project: string, decisions: string[], files: string[], approaches: Array<{
|
|
47
|
+
approach: string;
|
|
48
|
+
status: string;
|
|
49
|
+
}>, questions: Array<{
|
|
50
|
+
question: string;
|
|
51
|
+
resolved: boolean;
|
|
52
|
+
}>): void;
|
|
53
|
+
export declare function getContinuityBlock(context: ContinuityContext): string;
|
|
54
|
+
//# sourceMappingURL=context-continuity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-continuity.d.ts","sourceRoot":"","sources":["../../../../src/walls/01-context/context/context-continuity.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;IAC9D,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WA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,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CASzE;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAO/E;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAMzE;AAGD,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAwD7F;AAGD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAC,CAAC,GAAG,IAAI,CAkDjO;AAGD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAoCrE"}
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// context-continuity.ts — Supreme Context Thread Engine
|
|
3
|
+
// Maintains cross-session memory so AI never forgets context between sessions.
|
|
4
|
+
// Captures the "continuation mindset" — what was happening, what's next, why.
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getActiveThread = getActiveThread;
|
|
40
|
+
exports.getAllThreads = getAllThreads;
|
|
41
|
+
exports.detectOrCreateThread = detectOrCreateThread;
|
|
42
|
+
exports.closeThread = closeThread;
|
|
43
|
+
exports.addBridgeHint = addBridgeHint;
|
|
44
|
+
exports.addOpenQuestion = addOpenQuestion;
|
|
45
|
+
exports.resolveQuestion = resolveQuestion;
|
|
46
|
+
exports.addPendingAction = addPendingAction;
|
|
47
|
+
exports.addKeyLearning = addKeyLearning;
|
|
48
|
+
exports.addDecision = addDecision;
|
|
49
|
+
exports.updateFileFocus = updateFileFocus;
|
|
50
|
+
exports.buildContinuityContext = buildContinuityContext;
|
|
51
|
+
exports.captureSessionEnd = captureSessionEnd;
|
|
52
|
+
exports.getContinuityBlock = getContinuityBlock;
|
|
53
|
+
const fs = __importStar(require("fs"));
|
|
54
|
+
const path = __importStar(require("path"));
|
|
55
|
+
function getContinuityDir(projectDir) {
|
|
56
|
+
const d = path.join(projectDir, '.cell', 'continuity');
|
|
57
|
+
if (!fs.existsSync(d))
|
|
58
|
+
fs.mkdirSync(d, { recursive: true });
|
|
59
|
+
return d;
|
|
60
|
+
}
|
|
61
|
+
function threadPath(projectDir, threadId) {
|
|
62
|
+
return path.join(getContinuityDir(projectDir), `${threadId.replace(/[^a-z0-9_-]/gi, '_')}.json`);
|
|
63
|
+
}
|
|
64
|
+
function getActiveThread(projectDir) {
|
|
65
|
+
const dir = getContinuityDir(projectDir);
|
|
66
|
+
const activeFile = path.join(dir, '_active.json');
|
|
67
|
+
if (!fs.existsSync(activeFile))
|
|
68
|
+
return null;
|
|
69
|
+
return JSON.parse(fs.readFileSync(activeFile, 'utf-8'));
|
|
70
|
+
}
|
|
71
|
+
function getAllThreads(projectDir) {
|
|
72
|
+
const dir = getContinuityDir(projectDir);
|
|
73
|
+
if (!fs.existsSync(dir))
|
|
74
|
+
return [];
|
|
75
|
+
return fs.readdirSync(dir)
|
|
76
|
+
.filter(f => f.endsWith('.json') && !f.startsWith('_'))
|
|
77
|
+
.map(f => JSON.parse(fs.readFileSync(path.join(dir, f), 'utf-8')))
|
|
78
|
+
.sort((a, b) => new Date(b.lastActiveAt).getTime() - new Date(a.lastActiveAt).getTime());
|
|
79
|
+
}
|
|
80
|
+
function detectOrCreateThread(projectDir, project, recentDecisions, touchedFiles) {
|
|
81
|
+
const existing = getActiveThread(projectDir);
|
|
82
|
+
// Auto-detect thread intent from recent decisions and files
|
|
83
|
+
const intentStrings = [...recentDecisions, ...touchedFiles].join(' ').toLowerCase();
|
|
84
|
+
let intent = 'General development';
|
|
85
|
+
if (/bug|fix|error|crash|broken/.test(intentStrings))
|
|
86
|
+
intent = 'Bug fixing';
|
|
87
|
+
else if (/feature|add|implement|create|build|new/.test(intentStrings))
|
|
88
|
+
intent = 'Feature development';
|
|
89
|
+
else if (/refactor|clean|improve|optimize|restructure/.test(intentStrings))
|
|
90
|
+
intent = 'Refactoring';
|
|
91
|
+
else if (/test|spec|coverage|jest|vitest/.test(intentStrings))
|
|
92
|
+
intent = 'Testing';
|
|
93
|
+
else if (/docs|readme|document|wiki/.test(intentStrings))
|
|
94
|
+
intent = 'Documentation';
|
|
95
|
+
else if (/deploy|release|ship|launch|publish/.test(intentStrings))
|
|
96
|
+
intent = 'Release/Deploy';
|
|
97
|
+
if (existing) {
|
|
98
|
+
// Same thread — update it
|
|
99
|
+
existing.lastActiveAt = new Date().toISOString();
|
|
100
|
+
existing.sessionCount++;
|
|
101
|
+
existing.contextTags = [...new Set([...existing.contextTags, intent])];
|
|
102
|
+
if (intent !== existing.threadIntent && existing.sessionCount > 2) {
|
|
103
|
+
existing.threadIntent = existing.threadIntent + ' → ' + intent;
|
|
104
|
+
}
|
|
105
|
+
saveThread(projectDir, existing);
|
|
106
|
+
setActiveThread(projectDir, existing);
|
|
107
|
+
return existing;
|
|
108
|
+
}
|
|
109
|
+
// New thread
|
|
110
|
+
const threadId = `${project}-${intent.replace(/\s+/g, '-').toLowerCase()}-${Date.now()}`;
|
|
111
|
+
const thread = {
|
|
112
|
+
project,
|
|
113
|
+
threadId,
|
|
114
|
+
activeSince: new Date().toISOString(),
|
|
115
|
+
lastActiveAt: new Date().toISOString(),
|
|
116
|
+
sessionCount: 1,
|
|
117
|
+
contextTags: [intent],
|
|
118
|
+
openQuestions: [],
|
|
119
|
+
pendingActions: [],
|
|
120
|
+
keyLearnings: [],
|
|
121
|
+
decisionLog: [],
|
|
122
|
+
fileFocus: touchedFiles.slice(0, 10),
|
|
123
|
+
threadIntent: intent,
|
|
124
|
+
bridgeHints: [],
|
|
125
|
+
};
|
|
126
|
+
saveThread(projectDir, thread);
|
|
127
|
+
setActiveThread(projectDir, thread);
|
|
128
|
+
return thread;
|
|
129
|
+
}
|
|
130
|
+
function saveThread(projectDir, thread) {
|
|
131
|
+
fs.writeFileSync(threadPath(projectDir, thread.threadId), JSON.stringify(thread, null, 2), 'utf-8');
|
|
132
|
+
}
|
|
133
|
+
function setActiveThread(projectDir, thread) {
|
|
134
|
+
const dir = getContinuityDir(projectDir);
|
|
135
|
+
fs.writeFileSync(path.join(dir, '_active.json'), JSON.stringify(thread, null, 2), 'utf-8');
|
|
136
|
+
}
|
|
137
|
+
function closeThread(projectDir) {
|
|
138
|
+
const dir = getContinuityDir(projectDir);
|
|
139
|
+
const activeFile = path.join(dir, '_active.json');
|
|
140
|
+
if (fs.existsSync(activeFile)) {
|
|
141
|
+
const thread = JSON.parse(fs.readFileSync(activeFile, 'utf-8'));
|
|
142
|
+
thread.lastActiveAt = new Date().toISOString();
|
|
143
|
+
saveThread(projectDir, thread);
|
|
144
|
+
fs.unlinkSync(activeFile);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function addBridgeHint(projectDir, hint) {
|
|
148
|
+
const thread = getActiveThread(projectDir);
|
|
149
|
+
if (!thread)
|
|
150
|
+
return;
|
|
151
|
+
thread.bridgeHints.push(hint);
|
|
152
|
+
// Keep only last 20 hints
|
|
153
|
+
if (thread.bridgeHints.length > 20)
|
|
154
|
+
thread.bridgeHints = thread.bridgeHints.slice(-20);
|
|
155
|
+
saveThread(projectDir, thread);
|
|
156
|
+
setActiveThread(projectDir, thread);
|
|
157
|
+
}
|
|
158
|
+
function addOpenQuestion(projectDir, question) {
|
|
159
|
+
const thread = getActiveThread(projectDir);
|
|
160
|
+
if (!thread)
|
|
161
|
+
return;
|
|
162
|
+
if (!thread.openQuestions.includes(question)) {
|
|
163
|
+
thread.openQuestions.push(question);
|
|
164
|
+
}
|
|
165
|
+
saveThread(projectDir, thread);
|
|
166
|
+
setActiveThread(projectDir, thread);
|
|
167
|
+
}
|
|
168
|
+
function resolveQuestion(projectDir, question) {
|
|
169
|
+
const thread = getActiveThread(projectDir);
|
|
170
|
+
if (!thread)
|
|
171
|
+
return;
|
|
172
|
+
thread.openQuestions = thread.openQuestions.filter(q => q !== question);
|
|
173
|
+
saveThread(projectDir, thread);
|
|
174
|
+
setActiveThread(projectDir, thread);
|
|
175
|
+
}
|
|
176
|
+
function addPendingAction(projectDir, action) {
|
|
177
|
+
const thread = getActiveThread(projectDir);
|
|
178
|
+
if (!thread)
|
|
179
|
+
return;
|
|
180
|
+
if (!thread.pendingActions.includes(action)) {
|
|
181
|
+
thread.pendingActions.push(action);
|
|
182
|
+
}
|
|
183
|
+
saveThread(projectDir, thread);
|
|
184
|
+
setActiveThread(projectDir, thread);
|
|
185
|
+
}
|
|
186
|
+
function addKeyLearning(projectDir, learning) {
|
|
187
|
+
const thread = getActiveThread(projectDir);
|
|
188
|
+
if (!thread)
|
|
189
|
+
return;
|
|
190
|
+
if (!thread.keyLearnings.includes(learning)) {
|
|
191
|
+
thread.keyLearnings.push(learning);
|
|
192
|
+
if (thread.keyLearnings.length > 15)
|
|
193
|
+
thread.keyLearnings = thread.keyLearnings.slice(-15);
|
|
194
|
+
}
|
|
195
|
+
saveThread(projectDir, thread);
|
|
196
|
+
setActiveThread(projectDir, thread);
|
|
197
|
+
}
|
|
198
|
+
function addDecision(projectDir, what, why) {
|
|
199
|
+
const thread = getActiveThread(projectDir);
|
|
200
|
+
if (!thread)
|
|
201
|
+
return;
|
|
202
|
+
thread.decisionLog.push({ what, why, when: new Date().toISOString() });
|
|
203
|
+
if (thread.decisionLog.length > 15)
|
|
204
|
+
thread.decisionLog = thread.decisionLog.slice(-15);
|
|
205
|
+
saveThread(projectDir, thread);
|
|
206
|
+
setActiveThread(projectDir, thread);
|
|
207
|
+
}
|
|
208
|
+
function updateFileFocus(projectDir, files) {
|
|
209
|
+
const thread = getActiveThread(projectDir);
|
|
210
|
+
if (!thread)
|
|
211
|
+
return;
|
|
212
|
+
thread.fileFocus = [...new Set([...files, ...thread.fileFocus])].slice(0, 15);
|
|
213
|
+
saveThread(projectDir, thread);
|
|
214
|
+
setActiveThread(projectDir, thread);
|
|
215
|
+
}
|
|
216
|
+
// Build Supreme context from continuity data
|
|
217
|
+
function buildContinuityContext(projectDir, project) {
|
|
218
|
+
const activeThread = getActiveThread(projectDir);
|
|
219
|
+
const recentThreads = getAllThreads(projectDir).filter(t => t.threadId !== activeThread?.threadId).slice(0, 3);
|
|
220
|
+
const crossSessionWarnings = [];
|
|
221
|
+
const predictedNextSteps = [];
|
|
222
|
+
if (activeThread) {
|
|
223
|
+
// Warnings
|
|
224
|
+
if (activeThread.openQuestions.length > 0) {
|
|
225
|
+
crossSessionWarnings.push(`Has ${activeThread.openQuestions.length} unanswered questions from previous sessions`);
|
|
226
|
+
}
|
|
227
|
+
if (activeThread.pendingActions.length > 0) {
|
|
228
|
+
crossSessionWarnings.push(`${activeThread.pendingActions.length} planned actions remain uncompleted — may have been interrupted`);
|
|
229
|
+
}
|
|
230
|
+
if (activeThread.sessionCount >= 3 && activeThread.bridgeHints.length < 5) {
|
|
231
|
+
crossSessionWarnings.push('Multiple sessions but limited context continuity — might be working blind across sessions');
|
|
232
|
+
}
|
|
233
|
+
// Predictions
|
|
234
|
+
for (const hint of activeThread.bridgeHints.filter(h => h.type === 'prediction')) {
|
|
235
|
+
predictedNextSteps.push(hint.text);
|
|
236
|
+
}
|
|
237
|
+
for (const action of activeThread.pendingActions.slice(0, 3)) {
|
|
238
|
+
predictedNextSteps.push(action);
|
|
239
|
+
}
|
|
240
|
+
if (activeThread.openQuestions.length > 0) {
|
|
241
|
+
predictedNextSteps.push(`Answer open question: "${activeThread.openQuestions[0]}"`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// Memory thread — human-readable summary
|
|
245
|
+
let memoryThread = 'No prior context thread found. This appears to be a fresh session.';
|
|
246
|
+
if (activeThread && activeThread.sessionCount > 1) {
|
|
247
|
+
const parts = [];
|
|
248
|
+
parts.push(`Working on: ${activeThread.threadIntent}`);
|
|
249
|
+
parts.push(`Across ${activeThread.sessionCount} sessions since ${activeThread.activeSince.split('T')[0]}`);
|
|
250
|
+
if (activeThread.keyLearnings.length > 0) {
|
|
251
|
+
parts.push(`Key learnings: ${activeThread.keyLearnings.slice(-3).join('; ')}`);
|
|
252
|
+
}
|
|
253
|
+
if (activeThread.pendingActions.length > 0) {
|
|
254
|
+
parts.push(`⏭️ Pending: ${activeThread.pendingActions.slice(0, 3).join(', ')}`);
|
|
255
|
+
}
|
|
256
|
+
if (activeThread.fileFocus.length > 0) {
|
|
257
|
+
parts.push(`Focus files: ${activeThread.fileFocus.slice(0, 5).map(f => path.basename(f)).join(', ')}`);
|
|
258
|
+
}
|
|
259
|
+
memoryThread = parts.join('. ');
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
currentThread: activeThread,
|
|
263
|
+
recentThreads,
|
|
264
|
+
crossSessionWarnings,
|
|
265
|
+
predictedNextSteps,
|
|
266
|
+
memoryThread,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
// Auto-capture on session end — takes a full snapshot
|
|
270
|
+
function captureSessionEnd(projectDir, project, decisions, files, approaches, questions) {
|
|
271
|
+
const thread = getActiveThread(projectDir);
|
|
272
|
+
if (!thread)
|
|
273
|
+
return; // No active thread to capture into
|
|
274
|
+
// Record decisions
|
|
275
|
+
for (const d of decisions.slice(-5)) {
|
|
276
|
+
if (!thread.decisionLog.some(dl => dl.what === d)) {
|
|
277
|
+
thread.decisionLog.push({ what: d, why: '', when: new Date().toISOString() });
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// Unresolved questions
|
|
281
|
+
for (const q of questions.filter(q => !q.resolved)) {
|
|
282
|
+
if (!thread.openQuestions.includes(q.question)) {
|
|
283
|
+
thread.openQuestions.push(q.question);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
// Failed/tried approaches → bridge hints
|
|
287
|
+
for (const a of approaches.filter(a => a.status === 'failed' || a.status === 'tried')) {
|
|
288
|
+
const existing = thread.bridgeHints.find(h => h.text.includes(a.approach));
|
|
289
|
+
if (!existing) {
|
|
290
|
+
thread.bridgeHints.push({
|
|
291
|
+
type: 'watch_out',
|
|
292
|
+
text: `Previously tried: "${a.approach}" — ${a.status}. Don't retry.`,
|
|
293
|
+
confidence: 85,
|
|
294
|
+
fromSessionId: thread.sessionCount,
|
|
295
|
+
createdAt: new Date().toISOString(),
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
// Successful approaches → remember
|
|
300
|
+
for (const a of approaches.filter(a => a.status === 'accepted' || a.status === 'worked')) {
|
|
301
|
+
const existing = thread.bridgeHints.find(h => h.text.includes(a.approach));
|
|
302
|
+
if (!existing) {
|
|
303
|
+
thread.bridgeHints.push({
|
|
304
|
+
type: 'remember',
|
|
305
|
+
text: `Approach that worked: "${a.approach}" — reuse if similar problem.`,
|
|
306
|
+
confidence: 75,
|
|
307
|
+
fromSessionId: thread.sessionCount,
|
|
308
|
+
createdAt: new Date().toISOString(),
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
// File focus
|
|
313
|
+
updateFileFocus(projectDir, files);
|
|
314
|
+
saveThread(projectDir, thread);
|
|
315
|
+
}
|
|
316
|
+
// Get the supreme context block for insertion into prompt
|
|
317
|
+
function getContinuityBlock(context) {
|
|
318
|
+
const lines = [];
|
|
319
|
+
if (context.currentThread && context.currentThread.sessionCount > 0) {
|
|
320
|
+
lines.push('🧵 CONTINUITY THREAD');
|
|
321
|
+
lines.push(` ${context.memoryThread}`);
|
|
322
|
+
if (context.predictedNextSteps.length > 0) {
|
|
323
|
+
lines.push('');
|
|
324
|
+
lines.push(' 🔮 LIKELY NEXT:');
|
|
325
|
+
for (const step of context.predictedNextSteps.slice(0, 4)) {
|
|
326
|
+
lines.push(` → ${step}`);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
if (context.crossSessionWarnings.length > 0) {
|
|
330
|
+
lines.push('');
|
|
331
|
+
for (const w of context.crossSessionWarnings.slice(0, 3)) {
|
|
332
|
+
lines.push(` ⚠️ ${w}`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (context.currentThread.bridgeHints.length > 0) {
|
|
336
|
+
lines.push('');
|
|
337
|
+
lines.push(' 🧠 BRIDGE MEMORY:');
|
|
338
|
+
for (const h of context.currentThread.bridgeHints.slice(-5)) {
|
|
339
|
+
const icon = h.type === 'watch_out' ? '🚫' : h.type === 'remember' ? '✅' : '🔮';
|
|
340
|
+
lines.push(` ${icon} ${h.text}`);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
lines.push('🧵 CONTINUITY THREAD');
|
|
346
|
+
lines.push(' No prior context — fresh session.');
|
|
347
|
+
}
|
|
348
|
+
return lines.join('\n');
|
|
349
|
+
}
|
|
350
|
+
//# sourceMappingURL=context-continuity.js.map
|