mindkeeper-openclaw 0.2.29 → 0.2.31
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 +32 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -678,11 +678,13 @@ function generateTemplateMessage(changedFiles, options) {
|
|
|
678
678
|
}
|
|
679
679
|
|
|
680
680
|
// ../core/src/message/llm.ts
|
|
681
|
-
async function generateLlmMessage(diffs, provider) {
|
|
681
|
+
async function generateLlmMessage(diffs, provider, log) {
|
|
682
682
|
if (!provider) return null;
|
|
683
683
|
try {
|
|
684
684
|
return await provider.generateCommitMessage(diffs);
|
|
685
|
-
} catch {
|
|
685
|
+
} catch (err) {
|
|
686
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
687
|
+
log?.warn?.(`[mindkeeper] LLM commit message error: ${msg}`);
|
|
686
688
|
return null;
|
|
687
689
|
}
|
|
688
690
|
}
|
|
@@ -698,6 +700,7 @@ var Tracker = class {
|
|
|
698
700
|
workDir;
|
|
699
701
|
gitDir;
|
|
700
702
|
configOverrides;
|
|
703
|
+
log;
|
|
701
704
|
constructor(options) {
|
|
702
705
|
this.workDir = import_node_path3.default.resolve(options.workDir);
|
|
703
706
|
this.gitDir = options.gitDir ? import_node_path3.default.resolve(options.gitDir) : import_node_path3.default.join(this.workDir, GITDIR_NAME);
|
|
@@ -705,6 +708,7 @@ var Tracker = class {
|
|
|
705
708
|
this.configLoaded = options.config !== void 0;
|
|
706
709
|
this.configOverrides = options.configOverrides;
|
|
707
710
|
this.llmProvider = options.llmProvider;
|
|
711
|
+
this.log = options.log;
|
|
708
712
|
this.store = new IsomorphicGitStore({
|
|
709
713
|
workDir: this.workDir,
|
|
710
714
|
gitDir: this.gitDir
|
|
@@ -847,12 +851,35 @@ var Tracker = class {
|
|
|
847
851
|
}
|
|
848
852
|
}
|
|
849
853
|
let message = null;
|
|
854
|
+
let usedLlm = false;
|
|
855
|
+
let templateReason = null;
|
|
850
856
|
if (this.config.commitMessage.mode === "llm" && diffs.length > 0) {
|
|
851
|
-
|
|
857
|
+
if (this.llmProvider) {
|
|
858
|
+
message = await generateLlmMessage(diffs, this.llmProvider, this.log);
|
|
859
|
+
if (message) usedLlm = true;
|
|
860
|
+
else templateReason = "LLM API call failed (check logs above for error)";
|
|
861
|
+
} else {
|
|
862
|
+
templateReason = "LLM provider not configured (no default model or API key in OpenClaw)";
|
|
863
|
+
}
|
|
864
|
+
} else if (this.config.commitMessage.mode === "llm" && diffs.length === 0) {
|
|
865
|
+
templateReason = "first commit or no diff (no previous version to compare, diffs.length=0)";
|
|
866
|
+
} else {
|
|
867
|
+
templateReason = "config: commitMessage.mode is 'template'";
|
|
852
868
|
}
|
|
853
869
|
if (!message) {
|
|
854
870
|
message = generateTemplateMessage(filesToCommit);
|
|
855
871
|
}
|
|
872
|
+
if (this.log) {
|
|
873
|
+
if (usedLlm) {
|
|
874
|
+
this.log.info?.(
|
|
875
|
+
`[mindkeeper] Commit message: LLM-generated \u2014 "${message.slice(0, 50)}${message.length > 50 ? "\u2026" : ""}"`
|
|
876
|
+
);
|
|
877
|
+
} else {
|
|
878
|
+
this.log.warn?.(
|
|
879
|
+
`[mindkeeper] Commit message: template \u2014 reason: ${templateReason}`
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
856
883
|
const oid = await this.store.commit(message);
|
|
857
884
|
return {
|
|
858
885
|
oid,
|
|
@@ -1294,7 +1321,8 @@ function createWatcherService(api, trackerRef) {
|
|
|
1294
1321
|
const tracker = new Tracker({
|
|
1295
1322
|
workDir: workspaceDir,
|
|
1296
1323
|
llmProvider: llmProvider ?? void 0,
|
|
1297
|
-
configOverrides: api.pluginConfig
|
|
1324
|
+
configOverrides: api.pluginConfig,
|
|
1325
|
+
log
|
|
1298
1326
|
});
|
|
1299
1327
|
await tracker.init();
|
|
1300
1328
|
trackerRef.current = tracker;
|