mindkeeper-openclaw 0.2.31 → 0.2.32
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/dist/index.js +108 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -718,11 +718,66 @@ var Tracker = class {
|
|
|
718
718
|
await this.ensureConfigLoaded();
|
|
719
719
|
await this.store.init();
|
|
720
720
|
await this.ensureGitignore();
|
|
721
|
+
this.log?.info?.(
|
|
722
|
+
`[mindkeeper] init: commitMessage.mode=${this.config.commitMessage.mode}, llmProvider=${this.llmProvider ? "yes" : "no"}`
|
|
723
|
+
);
|
|
721
724
|
const changed = await this.getTrackedChangedFiles();
|
|
722
725
|
if (changed.length > 0) {
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
+
const filesToCommit = changed.map((e) => e.filepath);
|
|
727
|
+
await this.store.addFiles(filesToCommit);
|
|
728
|
+
let message = null;
|
|
729
|
+
if (this.config.commitMessage.mode === "llm" && this.llmProvider) {
|
|
730
|
+
let headOid = null;
|
|
731
|
+
try {
|
|
732
|
+
headOid = await this.resolveHead();
|
|
733
|
+
} catch {
|
|
734
|
+
}
|
|
735
|
+
if (headOid) {
|
|
736
|
+
const diffs = [];
|
|
737
|
+
for (const file of filesToCommit) {
|
|
738
|
+
try {
|
|
739
|
+
const oldContent = await this.store.readFile(file, headOid) ?? "";
|
|
740
|
+
let newContent;
|
|
741
|
+
try {
|
|
742
|
+
newContent = await import_promises3.default.readFile(
|
|
743
|
+
import_node_path3.default.join(this.workDir, file),
|
|
744
|
+
"utf-8"
|
|
745
|
+
);
|
|
746
|
+
} catch {
|
|
747
|
+
newContent = "";
|
|
748
|
+
}
|
|
749
|
+
const d = computeDiff({
|
|
750
|
+
file,
|
|
751
|
+
fromVersion: headOid.slice(0, 8),
|
|
752
|
+
toVersion: "(staged)",
|
|
753
|
+
oldContent,
|
|
754
|
+
newContent
|
|
755
|
+
});
|
|
756
|
+
if (d.additions > 0 || d.deletions > 0) diffs.push(d);
|
|
757
|
+
} catch {
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
if (diffs.length > 0) {
|
|
761
|
+
message = await generateLlmMessage(diffs, this.llmProvider, this.log);
|
|
762
|
+
if (message) {
|
|
763
|
+
this.log?.info?.(
|
|
764
|
+
`[mindkeeper] init: LLM-generated commit \u2014 "${message.slice(0, 50)}${message.length > 50 ? "\u2026" : ""}"`
|
|
765
|
+
);
|
|
766
|
+
}
|
|
767
|
+
} else {
|
|
768
|
+
this.log?.info?.("[mindkeeper] init: diffs empty (all files unchanged vs HEAD)");
|
|
769
|
+
}
|
|
770
|
+
} else {
|
|
771
|
+
this.log?.info?.("[mindkeeper] init: no HEAD yet (first commit), LLM skipped");
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
if (!message) {
|
|
775
|
+
message = generateTemplateMessage(filesToCommit);
|
|
776
|
+
this.log?.info?.(`[mindkeeper] init: using template \u2014 "${message}"`);
|
|
777
|
+
}
|
|
778
|
+
await this.store.commit(message);
|
|
779
|
+
} else {
|
|
780
|
+
this.log?.info?.("[mindkeeper] init: no changed files");
|
|
726
781
|
}
|
|
727
782
|
return { initialFiles: changed.map((e) => e.filepath) };
|
|
728
783
|
}
|
|
@@ -823,6 +878,9 @@ var Tracker = class {
|
|
|
823
878
|
headOid = await this.resolveHead();
|
|
824
879
|
} catch {
|
|
825
880
|
}
|
|
881
|
+
this.log?.info?.(
|
|
882
|
+
`[mindkeeper] autoSnapshot: files=${filesToCommit.length}, headOid=${headOid ? headOid.slice(0, 8) : "none"}, mode=${this.config.commitMessage.mode}, llmProvider=${this.llmProvider ? "yes" : "no"}`
|
|
883
|
+
);
|
|
826
884
|
if (headOid) {
|
|
827
885
|
for (const file of filesToCommit) {
|
|
828
886
|
try {
|
|
@@ -846,10 +904,14 @@ var Tracker = class {
|
|
|
846
904
|
if (d.additions > 0 || d.deletions > 0) {
|
|
847
905
|
diffs.push(d);
|
|
848
906
|
}
|
|
849
|
-
} catch {
|
|
907
|
+
} catch (err) {
|
|
908
|
+
this.log?.warn?.(
|
|
909
|
+
`[mindkeeper] autoSnapshot: diff failed for ${file}: ${err instanceof Error ? err.message : String(err)}`
|
|
910
|
+
);
|
|
850
911
|
}
|
|
851
912
|
}
|
|
852
913
|
}
|
|
914
|
+
this.log?.info?.(`[mindkeeper] autoSnapshot: computed ${diffs.length} non-empty diff(s)`);
|
|
853
915
|
let message = null;
|
|
854
916
|
let usedLlm = false;
|
|
855
917
|
let templateReason = null;
|
|
@@ -857,28 +919,26 @@ var Tracker = class {
|
|
|
857
919
|
if (this.llmProvider) {
|
|
858
920
|
message = await generateLlmMessage(diffs, this.llmProvider, this.log);
|
|
859
921
|
if (message) usedLlm = true;
|
|
860
|
-
else templateReason = "LLM API call failed (check logs above for error)";
|
|
922
|
+
else templateReason = "LLM API call failed (check logs above for error details)";
|
|
861
923
|
} else {
|
|
862
|
-
templateReason = "
|
|
924
|
+
templateReason = "llmProvider is null (createOpenClawLlmProvider returned null \u2014 check startup logs)";
|
|
863
925
|
}
|
|
864
926
|
} else if (this.config.commitMessage.mode === "llm" && diffs.length === 0) {
|
|
865
|
-
templateReason =
|
|
927
|
+
templateReason = headOid ? `diffs empty (${filesToCommit.length} file(s) changed but no textual diff vs HEAD)` : "no HEAD commit yet (first commit), cannot compute diff";
|
|
866
928
|
} else {
|
|
867
|
-
templateReason = "config
|
|
929
|
+
templateReason = `commitMessage.mode="${this.config.commitMessage.mode}" (not "llm")`;
|
|
868
930
|
}
|
|
869
931
|
if (!message) {
|
|
870
932
|
message = generateTemplateMessage(filesToCommit);
|
|
871
933
|
}
|
|
872
|
-
if (
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
);
|
|
881
|
-
}
|
|
934
|
+
if (usedLlm) {
|
|
935
|
+
this.log?.info?.(
|
|
936
|
+
`[mindkeeper] Commit message: LLM \u2713 \u2014 "${message.slice(0, 60)}${message.length > 60 ? "\u2026" : ""}"`
|
|
937
|
+
);
|
|
938
|
+
} else {
|
|
939
|
+
this.log?.warn?.(
|
|
940
|
+
`[mindkeeper] Commit message: TEMPLATE \u2014 reason: ${templateReason}`
|
|
941
|
+
);
|
|
882
942
|
}
|
|
883
943
|
const oid = await this.store.commit(message);
|
|
884
944
|
return {
|
|
@@ -1191,7 +1251,7 @@ function readEnvApiKey(provider) {
|
|
|
1191
1251
|
// src/llm-provider.ts
|
|
1192
1252
|
var MAX_DIFF_CHARS = 4e3;
|
|
1193
1253
|
async function createOpenClawLlmProvider(api) {
|
|
1194
|
-
const modelSpec = resolveModelFromConfig(api.config);
|
|
1254
|
+
const modelSpec = resolveModelFromConfig(api.config, api.log);
|
|
1195
1255
|
if (!modelSpec) {
|
|
1196
1256
|
api.log?.warn?.(
|
|
1197
1257
|
"[mindkeeper] No default model configured in OpenClaw \u2014 LLM commit messages disabled."
|
|
@@ -1207,25 +1267,32 @@ async function createOpenClawLlmProvider(api) {
|
|
|
1207
1267
|
const apiKey = await resolveApiKey(modelSpec.provider);
|
|
1208
1268
|
if (!apiKey) {
|
|
1209
1269
|
api.log?.warn?.(
|
|
1210
|
-
`[mindkeeper] No API key found for provider "${modelSpec.provider}" \u2014 LLM commit messages disabled.`
|
|
1270
|
+
`[mindkeeper] No API key found for provider "${modelSpec.provider}" \u2014 LLM commit messages disabled. Checked: auth-profiles.json + env vars.`
|
|
1211
1271
|
);
|
|
1212
1272
|
return null;
|
|
1213
1273
|
}
|
|
1214
1274
|
api.log?.info?.(
|
|
1215
|
-
`[mindkeeper] LLM commit messages enabled (${modelSpec.provider}/${modelSpec.model}).`
|
|
1275
|
+
`[mindkeeper] LLM commit messages enabled (${modelSpec.provider}/${modelSpec.model}${modelSpec.baseUrl ? `, baseUrl=${modelSpec.baseUrl}` : ""}).`
|
|
1216
1276
|
);
|
|
1217
1277
|
return {
|
|
1218
1278
|
async generateCommitMessage(diffs) {
|
|
1219
1279
|
const diffText = diffs.map((d) => `--- ${d.file} ---
|
|
1220
1280
|
${d.unified}`).join("\n").slice(0, MAX_DIFF_CHARS);
|
|
1281
|
+
api.log?.info?.(
|
|
1282
|
+
`[mindkeeper] Calling LLM for commit message (${diffs.length} diff(s), ${diffText.length} chars)\u2026`
|
|
1283
|
+
);
|
|
1221
1284
|
const { callLlm } = await import("./llm-client.cjs");
|
|
1222
|
-
|
|
1285
|
+
const result = await callLlm({
|
|
1223
1286
|
provider: modelSpec.provider,
|
|
1224
1287
|
model: modelSpec.model,
|
|
1225
1288
|
apiKey,
|
|
1226
1289
|
userPrompt: diffText,
|
|
1227
1290
|
baseUrl: modelSpec.baseUrl
|
|
1228
1291
|
});
|
|
1292
|
+
api.log?.info?.(
|
|
1293
|
+
`[mindkeeper] LLM returned: "${(result ?? "").slice(0, 60)}${(result ?? "").length > 60 ? "\u2026" : ""}"`
|
|
1294
|
+
);
|
|
1295
|
+
return result;
|
|
1229
1296
|
}
|
|
1230
1297
|
};
|
|
1231
1298
|
}
|
|
@@ -1233,10 +1300,13 @@ function isOAuthProvider(provider) {
|
|
|
1233
1300
|
const normalized = normalizeProvider(provider);
|
|
1234
1301
|
return normalized.includes("portal") || normalized.includes("oauth");
|
|
1235
1302
|
}
|
|
1236
|
-
function resolveModelFromConfig(config) {
|
|
1303
|
+
function resolveModelFromConfig(config, log) {
|
|
1237
1304
|
const agents = config?.agents;
|
|
1238
1305
|
const defaults = agents?.defaults;
|
|
1239
1306
|
const raw = defaults?.model;
|
|
1307
|
+
log?.info?.(
|
|
1308
|
+
`[mindkeeper] resolveModel: config.agents=${agents ? "present" : "missing"}, config.agents.defaults=${defaults ? "present" : "missing"}, config.agents.defaults.model=${raw === void 0 ? "undefined" : typeof raw === "string" ? `"${raw}"` : JSON.stringify(raw)}`
|
|
1309
|
+
);
|
|
1240
1310
|
let spec;
|
|
1241
1311
|
if (typeof raw === "string") {
|
|
1242
1312
|
spec = raw.trim();
|
|
@@ -1244,7 +1314,12 @@ function resolveModelFromConfig(config) {
|
|
|
1244
1314
|
const primary = raw.primary;
|
|
1245
1315
|
if (typeof primary === "string") spec = primary.trim();
|
|
1246
1316
|
}
|
|
1247
|
-
if (!spec?.includes("/"))
|
|
1317
|
+
if (!spec?.includes("/")) {
|
|
1318
|
+
log?.warn?.(
|
|
1319
|
+
`[mindkeeper] resolveModel: no valid "provider/model" spec found (got: ${spec === void 0 ? "undefined" : `"${spec}"`})`
|
|
1320
|
+
);
|
|
1321
|
+
return null;
|
|
1322
|
+
}
|
|
1248
1323
|
const slashIdx = spec.indexOf("/");
|
|
1249
1324
|
const provider = spec.slice(0, slashIdx);
|
|
1250
1325
|
const model = spec.slice(slashIdx + 1);
|
|
@@ -1314,10 +1389,16 @@ function createWatcherService(api, trackerRef) {
|
|
|
1314
1389
|
return;
|
|
1315
1390
|
}
|
|
1316
1391
|
ensureWorkspaceSkillMirror(workspaceDir, { log: api.log });
|
|
1392
|
+
log.info(
|
|
1393
|
+
`[mindkeeper] Service starting: ctx.config=${ctx.config ? "present" : "missing"}, pluginConfig=${api.pluginConfig ? JSON.stringify(api.pluginConfig) : "none"}`
|
|
1394
|
+
);
|
|
1317
1395
|
const llmProvider = await createOpenClawLlmProvider({
|
|
1318
1396
|
config: ctx.config,
|
|
1319
1397
|
log
|
|
1320
1398
|
});
|
|
1399
|
+
log.info(
|
|
1400
|
+
`[mindkeeper] LLM provider: ${llmProvider ? "created successfully" : "null (will use template)"}`
|
|
1401
|
+
);
|
|
1321
1402
|
const tracker = new Tracker({
|
|
1322
1403
|
workDir: workspaceDir,
|
|
1323
1404
|
llmProvider: llmProvider ?? void 0,
|
|
@@ -1326,6 +1407,9 @@ function createWatcherService(api, trackerRef) {
|
|
|
1326
1407
|
});
|
|
1327
1408
|
await tracker.init();
|
|
1328
1409
|
trackerRef.current = tracker;
|
|
1410
|
+
log.info(
|
|
1411
|
+
`[mindkeeper] Tracker config: commitMessage.mode=${tracker.getConfig().commitMessage.mode}`
|
|
1412
|
+
);
|
|
1329
1413
|
watcher = new Watcher({
|
|
1330
1414
|
tracker,
|
|
1331
1415
|
onSnapshot: (commit) => {
|