jasper-recall 0.5.5 → 0.5.6
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.
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { execSync } from 'child_process';
|
|
14
|
+
import { readFileSync, existsSync } from 'fs';
|
|
14
15
|
import * as path from 'path';
|
|
15
16
|
import * as os from 'os';
|
|
16
17
|
|
|
@@ -131,18 +132,33 @@ export default function register(api: PluginApi) {
|
|
|
131
132
|
try {
|
|
132
133
|
let prependParts: string[] = [];
|
|
133
134
|
|
|
134
|
-
// If fresh session,
|
|
135
|
+
// If fresh session, inject identity files directly into context
|
|
135
136
|
if (isFreshSession) {
|
|
136
|
-
api.logger.info('[jasper-recall] Fresh session detected -
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
137
|
+
api.logger.info('[jasper-recall] Fresh session detected - injecting identity context');
|
|
138
|
+
|
|
139
|
+
const workspace = path.join(os.homedir(), '.openclaw', 'workspace');
|
|
140
|
+
const identityFiles = ['IDENTITY.md', 'SOUL.md', 'USER.md'];
|
|
141
|
+
const identityParts: string[] = [];
|
|
142
|
+
|
|
143
|
+
for (const file of identityFiles) {
|
|
144
|
+
const filePath = path.join(workspace, file);
|
|
145
|
+
if (existsSync(filePath)) {
|
|
146
|
+
try {
|
|
147
|
+
const content = readFileSync(filePath, 'utf8');
|
|
148
|
+
identityParts.push(`### ${file}\n${content}`);
|
|
149
|
+
} catch (err: any) {
|
|
150
|
+
api.logger.warn(`[jasper-recall] Failed to read ${file}: ${err.message}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (identityParts.length > 0) {
|
|
156
|
+
prependParts.push(`<session-identity>
|
|
157
|
+
🔄 **Fresh session.** Your identity files:
|
|
158
|
+
|
|
159
|
+
${identityParts.join('\n\n---\n\n')}
|
|
160
|
+
</session-identity>`);
|
|
161
|
+
}
|
|
146
162
|
}
|
|
147
163
|
|
|
148
164
|
const results = runRecall(event.prompt, {
|
|
@@ -180,18 +196,33 @@ ${memoryContext}
|
|
|
180
196
|
} catch (err: any) {
|
|
181
197
|
api.logger.warn(`[jasper-recall] Auto-recall failed: ${err.message}`);
|
|
182
198
|
|
|
183
|
-
// Still inject identity
|
|
199
|
+
// Still inject identity context on fresh session even if recall fails
|
|
184
200
|
if (isFreshSession) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
201
|
+
const workspace = path.join(os.homedir(), '.openclaw', 'workspace');
|
|
202
|
+
const identityFiles = ['IDENTITY.md', 'SOUL.md', 'USER.md'];
|
|
203
|
+
const identityParts: string[] = [];
|
|
204
|
+
|
|
205
|
+
for (const file of identityFiles) {
|
|
206
|
+
const filePath = path.join(workspace, file);
|
|
207
|
+
if (existsSync(filePath)) {
|
|
208
|
+
try {
|
|
209
|
+
const content = readFileSync(filePath, 'utf8');
|
|
210
|
+
identityParts.push(`### ${file}\n${content}`);
|
|
211
|
+
} catch {
|
|
212
|
+
// Skip unreadable files
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (identityParts.length > 0) {
|
|
218
|
+
return {
|
|
219
|
+
prependContext: `<session-identity>
|
|
220
|
+
🔄 **Fresh session.** Your identity files:
|
|
221
|
+
|
|
222
|
+
${identityParts.join('\n\n---\n\n')}
|
|
223
|
+
</session-identity>`,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
195
226
|
}
|
|
196
227
|
}
|
|
197
228
|
});
|