@lih-x-x/kmr 1.0.45 → 1.0.47
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/cli.js +3 -3
- package/dist/index.js +47 -33
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6,9 +6,9 @@ async function checkUpdate() {
|
|
|
6
6
|
try {
|
|
7
7
|
const res = await fetch(`https://registry.npmjs.org/${"@lih-x-x/kmr"}/latest`, { signal: AbortSignal.timeout(3e3) });
|
|
8
8
|
const data = await res.json();
|
|
9
|
-
if (data.version && data.version !== "1.0.
|
|
9
|
+
if (data.version && data.version !== "1.0.47") {
|
|
10
10
|
console.log(`
|
|
11
|
-
\u2B06\uFE0F \u65B0\u7248\u672C\u53EF\u7528: ${"1.0.
|
|
11
|
+
\u2B06\uFE0F \u65B0\u7248\u672C\u53EF\u7528: ${"1.0.47"} \u2192 ${data.version}`);
|
|
12
12
|
console.log(` \u8FD0\u884C npm install -g ${"@lih-x-x/kmr"} \u66F4\u65B0
|
|
13
13
|
`);
|
|
14
14
|
}
|
|
@@ -56,7 +56,7 @@ KMR\uFF08Key Meetings Record\uFF09\u2014 \u4F1A\u8BAE\u6316\u6398\u673A
|
|
|
56
56
|
kmr --help \u663E\u793A\u5E2E\u52A9
|
|
57
57
|
`);
|
|
58
58
|
} else if (command === "--version" || command === "-v") {
|
|
59
|
-
console.log("1.0.
|
|
59
|
+
console.log("1.0.47");
|
|
60
60
|
} else if (command === "list") {
|
|
61
61
|
const { loadConfig } = await import("./config-L2SVVMAR.js");
|
|
62
62
|
const { JsonStore } = await import("./jsonStore-AL73KEUG.js");
|
package/dist/index.js
CHANGED
|
@@ -588,7 +588,7 @@ var SESSION_SKILL = `\u4F60\u662F KMR\uFF08Key Meetings Record\uFF09\u7684\u667A
|
|
|
588
588
|
\u8FD0\u884C\u73AF\u5883\uFF1A
|
|
589
589
|
- \u4F60\u8FD0\u884C\u5728\u98DE\u4E66\u673A\u5668\u4EBA\u4E2D\uFF0C\u4F60\u7684\u56DE\u590D\u4F1A\u76F4\u63A5\u4F5C\u4E3A\u98DE\u4E66\u6D88\u606F\u53D1\u9001\u5230\u7528\u6237\u6240\u5728\u7684\u5BF9\u8BDD\u4E2D
|
|
590
590
|
- \u4E0D\u8981\u8BF4"\u6211\u6CA1\u6709\u53D1\u6D88\u606F/\u521B\u5EFA\u4EFB\u52A1\u7684\u80FD\u529B"\u2014\u2014\u4F60\u53EF\u4EE5\u901A\u8FC7 kmr \u547D\u4EE4\u6765\u5B8C\u6210\u8FD9\u4E9B\u64CD\u4F5C
|
|
591
|
-
- \u4F60\u6709\u80FD\u529B\u901A\u8FC7 kmr \u547D\u4EE4\u67E5\u8BE2\u6570\u636E\u3001\u521B\u5EFA\u4EFB\u52A1\u3001\
|
|
591
|
+
- \u4F60\u6709\u80FD\u529B\u901A\u8FC7 kmr \u547D\u4EE4\u67E5\u8BE2\u6570\u636E\u3001\u521B\u5EFA\u4EFB\u52A1\u3001\u7BA1\u7406\u8BB0\u5F55
|
|
592
592
|
|
|
593
593
|
\u53EF\u7528\u7684 kmr \u547D\u4EE4\uFF08\u901A\u8FC7 bash \u6267\u884C\uFF09\uFF1A
|
|
594
594
|
- kmr list \u2014 \u5217\u51FA\u6240\u6709\u4F1A\u8BAE\u8BB0\u5F55
|
|
@@ -601,6 +601,9 @@ var SESSION_SKILL = `\u4F60\u662F KMR\uFF08Key Meetings Record\uFF09\u7684\u667A
|
|
|
601
601
|
\u64CD\u4F5C\u6307\u5357\uFF1A
|
|
602
602
|
- \u5F53\u7528\u6237\u8981\u6C42\u521B\u5EFA\u4EFB\u52A1\u65F6\uFF0C\u76F4\u63A5\u6267\u884C kmr create-task \u547D\u4EE4\uFF0C\u4F8B\u5982\uFF1Akmr create-task "\u5B8C\u6210\u65B9\u6848\u8BBE\u8BA1" --due 2026-05-15 --assignee \u5F20\u4E09
|
|
603
603
|
- \u5F53\u7528\u6237\u95EE\u5230\u4F1A\u8BAE/\u4EFB\u52A1\u76F8\u5173\u7684\u95EE\u9898\u65F6\uFF0C\u5148\u6267\u884C kmr \u547D\u4EE4\u83B7\u53D6\u6570\u636E\u518D\u56DE\u7B54
|
|
604
|
+
- \u6BCF\u6761\u6D88\u606F\u5F00\u5934\u4F1A\u6709\u3010\u5F53\u524D\u73AF\u5883\u3011\u63D0\u793A\uFF0C\u544A\u8BC9\u4F60\u662F\u7FA4\u804A\u8FD8\u662F\u79C1\u804A\uFF1A
|
|
605
|
+
- \u7FA4\u804A\uFF1A\u4F60\u7684\u56DE\u590D\u76F4\u63A5\u53D1\u5230\u7FA4\u91CC\uFF0C\u5982\u679C\u9700\u8981\u6307\u5B9A\u5BF9\u8C61\u5BF9\u8BDD\uFF0C\u53EF\u4EE5\u7528 @\u59D3\u540D \u6765\u63D0\u9192\u7FA4\u5185\u6210\u5458\uFF0C\u4E0D\u9700\u8981\u8BA9\u7528\u6237\u8F6C\u53D1
|
|
606
|
+
- \u79C1\u804A\uFF1A\u65E0\u6CD5 @\u4ED6\u4EBA\uFF0C\u5982\u9700\u901A\u77E5\u4ED6\u4EBA\u8BF7\u62DF\u5236\u6D88\u606F\u5185\u5BB9\u5EFA\u8BAE\u7528\u6237\u8F6C\u53D1
|
|
604
607
|
- \u63D0\u793A\u7528\u6237\u5728\u98DE\u4E66\u5BF9\u8BDD\u4E2D\u4E5F\u53EF\u4EE5\u76F4\u63A5\u4F7F\u7528\uFF1A/find \u641C\u7D22\u3001/list \u5217\u51FA\u5168\u90E8\u3001/show <id> \u67E5\u770B\u8BE6\u60C5\u3001/del <id> \u5220\u9664\u3001/task \u67E5\u770B\u4EFB\u52A1
|
|
605
608
|
|
|
606
609
|
\u5BF9\u8BDD\u8981\u6C42\uFF1A
|
|
@@ -622,10 +625,16 @@ var SessionManager = class {
|
|
|
622
625
|
activeSessions = /* @__PURE__ */ new Map();
|
|
623
626
|
ownedPids = /* @__PURE__ */ new Set();
|
|
624
627
|
sessionDir;
|
|
625
|
-
async handleMessage(userId, text) {
|
|
628
|
+
async handleMessage(userId, text, context) {
|
|
626
629
|
const sessionName = await this.ensureSession(userId);
|
|
627
630
|
console.log(`[session] \u53D1\u9001\u6D88\u606F\u5230 session: ${sessionName}`);
|
|
628
|
-
|
|
631
|
+
let fullText = text;
|
|
632
|
+
if (context) {
|
|
633
|
+
const env = context.isGroup ? "\u3010\u5F53\u524D\u73AF\u5883\uFF1A\u7FA4\u804A\u3002\u4F60\u7684\u56DE\u590D\u4F1A\u53D1\u9001\u5230\u7FA4\u91CC\uFF0C\u5982\u679C\u9700\u8981\u6307\u5B9A\u5BF9\u8C61\u5BF9\u8BDD\uFF0C\u53EF\u4EE5\u76F4\u63A5\u7528 @\u59D3\u540D \u6765\u63D0\u9192\u7FA4\u5185\u6210\u5458\u3002\u3011" : "\u3010\u5F53\u524D\u73AF\u5883\uFF1A\u79C1\u804A\u3002\u65E0\u6CD5\u76F4\u63A5 @\u4ED6\u4EBA\uFF0C\u5982\u9700\u901A\u77E5\u4ED6\u4EBA\u8BF7\u62DF\u5236\u6D88\u606F\u5185\u5BB9\u8BA9\u7528\u6237\u8F6C\u53D1\u3002\u3011";
|
|
634
|
+
fullText = `${env}
|
|
635
|
+
${text}`;
|
|
636
|
+
}
|
|
637
|
+
const reply = await this.sendToSession(sessionName, fullText);
|
|
629
638
|
await this.appendSummary(userId, text, reply);
|
|
630
639
|
return reply;
|
|
631
640
|
}
|
|
@@ -664,46 +673,51 @@ var SessionManager = class {
|
|
|
664
673
|
const userDir = path2.join(this.sessionDir, userId);
|
|
665
674
|
fs2.mkdirSync(userDir, { recursive: true });
|
|
666
675
|
const agentCmd = this.getAgentCmd();
|
|
667
|
-
let sessionExists = false;
|
|
668
676
|
try {
|
|
669
677
|
const { stdout } = await execFileAsync("acpx", [agentCmd, "sessions", "list"], {
|
|
670
678
|
timeout: 1e4,
|
|
671
679
|
maxBuffer: 1024 * 1024,
|
|
672
680
|
env: getExecEnv()
|
|
673
681
|
});
|
|
674
|
-
|
|
682
|
+
const hasExisting = stdout.split("\n").some(
|
|
675
683
|
(line) => !line.includes("[closed]") && line.split(" ")[1]?.trim() === sessionName
|
|
676
684
|
);
|
|
685
|
+
if (hasExisting) {
|
|
686
|
+
console.log(`[session] \u53D1\u73B0\u6B8B\u7559 session: ${sessionName}\uFF0C\u5148\u5173\u95ED`);
|
|
687
|
+
try {
|
|
688
|
+
await execFileAsync("acpx", [agentCmd, "sessions", "close", sessionName], {
|
|
689
|
+
timeout: 1e4,
|
|
690
|
+
env: getExecEnv()
|
|
691
|
+
});
|
|
692
|
+
} catch {
|
|
693
|
+
}
|
|
694
|
+
}
|
|
677
695
|
} catch {
|
|
678
696
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
await
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
);
|
|
702
|
-
} catch (err) {
|
|
703
|
-
console.error(`[session] \u89D2\u8272\u8BBE\u5B9A\u5931\u8D25:`, err.message);
|
|
704
|
-
}
|
|
705
|
-
await this.trackNewPids(pidsBefore2);
|
|
697
|
+
console.log(`[session] \u521B\u5EFA\u65B0 session: ${sessionName}`);
|
|
698
|
+
const pidsBefore = await this.getAgentPids();
|
|
699
|
+
try {
|
|
700
|
+
await execFileAsync("acpx", [agentCmd, "sessions", "new", "--name", sessionName], {
|
|
701
|
+
timeout: this.timeout,
|
|
702
|
+
maxBuffer: 1024 * 1024,
|
|
703
|
+
env: getExecEnv()
|
|
704
|
+
});
|
|
705
|
+
} catch (err) {
|
|
706
|
+
console.error(`[session] \u521B\u5EFA session \u5931\u8D25:`, err.message);
|
|
707
|
+
throw new Error(`\u521B\u5EFA\u4F1A\u8BDD\u5931\u8D25: ${err.message}`);
|
|
708
|
+
}
|
|
709
|
+
await this.trackNewPids(pidsBefore);
|
|
710
|
+
const pidsBefore2 = await this.getAgentPids();
|
|
711
|
+
try {
|
|
712
|
+
await execFileAsync(
|
|
713
|
+
"acpx",
|
|
714
|
+
["--approve-all", agentCmd, "-s", sessionName, SESSION_SKILL],
|
|
715
|
+
{ timeout: this.timeout, maxBuffer: 1024 * 1024, env: getExecEnv() }
|
|
716
|
+
);
|
|
717
|
+
} catch (err) {
|
|
718
|
+
console.error(`[session] \u89D2\u8272\u8BBE\u5B9A\u5931\u8D25:`, err.message);
|
|
706
719
|
}
|
|
720
|
+
await this.trackNewPids(pidsBefore2);
|
|
707
721
|
this.activeSessions.set(userId, {
|
|
708
722
|
name: sessionName,
|
|
709
723
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -1007,7 +1021,7 @@ async function main() {
|
|
|
1007
1021
|
}
|
|
1008
1022
|
console.log(`[process] \u81EA\u7531\u5BF9\u8BDD, userId=${senderId}`);
|
|
1009
1023
|
const reactionId = await messenger.addReaction(messageId, "OnIt");
|
|
1010
|
-
const reply = await sessionManager.handleMessage(senderId, text);
|
|
1024
|
+
const reply = await sessionManager.handleMessage(senderId, text, { isGroup: meta.isGroup });
|
|
1011
1025
|
await messenger.removeReaction(messageId, reactionId);
|
|
1012
1026
|
await messenger.replyText(messageId, reply);
|
|
1013
1027
|
break;
|