opencode-prompt-recorder 1.3.0 → 1.3.2
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 +28 -12
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -51,31 +51,47 @@ async function findExistingFile(directory, sessionId) {
|
|
|
51
51
|
} catch {}
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
|
-
var OpenCodePromptRecorder = async ({ directory, client }) => {
|
|
54
|
+
var OpenCodePromptRecorder = async ({ directory, client: _client }) => {
|
|
55
55
|
let lastUserMessage = "";
|
|
56
|
+
let versionFileWritten = false;
|
|
56
57
|
return {
|
|
57
58
|
"chat.message": async (input, output) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
if (!versionFileWritten) {
|
|
60
|
+
try {
|
|
61
|
+
const version = await getVersion();
|
|
62
|
+
const versionDir = join(process.env.HOME || "", ".config", "opencode");
|
|
63
|
+
const versionFile = join(versionDir, "opencode-prompt-recorder-version.txt");
|
|
64
|
+
const content = `opencode-prompt-recorder:${version}
|
|
65
|
+
|
|
66
|
+
说明:本文件是插件自动写入。`;
|
|
67
|
+
try {
|
|
68
|
+
const existing = await readFile(versionFile, "utf-8");
|
|
69
|
+
if (existing === content) {
|
|
70
|
+
versionFileWritten = true;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
} catch {}
|
|
74
|
+
await mkdir(versionDir, { recursive: true });
|
|
75
|
+
await writeFile(versionFile, content);
|
|
76
|
+
versionFileWritten = true;
|
|
77
|
+
} catch (e) {}
|
|
78
|
+
}
|
|
64
79
|
if (output.message.role === "user") {
|
|
80
|
+
const now = new Date;
|
|
65
81
|
const text = output.parts.map((p) => p.type === "text" ? p.text : "").join("");
|
|
66
82
|
const sessionId = input.sessionID;
|
|
67
83
|
if (!sessionId) {
|
|
68
84
|
return;
|
|
69
85
|
}
|
|
70
86
|
if (text && text !== lastUserMessage) {
|
|
71
|
-
const { yyyy, MM, dd, HH, mm } = formatDate(
|
|
87
|
+
const { yyyy, MM, dd, HH, mm } = formatDate(now);
|
|
72
88
|
const topic = sanitizeFilename(text);
|
|
73
89
|
const promptDir = join(directory, ".agent", "prompts", yyyy, MM, dd);
|
|
74
90
|
await mkdir(promptDir, { recursive: true });
|
|
75
91
|
const existingFile = await findExistingFile(directory, sessionId);
|
|
76
|
-
const time = formatTime(
|
|
92
|
+
const time = formatTime(now);
|
|
77
93
|
const timeTitle = `============ ${time} ============`;
|
|
78
|
-
const
|
|
94
|
+
const fileContent = existingFile ? `
|
|
79
95
|
|
|
80
96
|
${timeTitle}
|
|
81
97
|
|
|
@@ -83,11 +99,11 @@ ${text}` : `${timeTitle}
|
|
|
83
99
|
|
|
84
100
|
${text}`;
|
|
85
101
|
if (existingFile) {
|
|
86
|
-
await appendFile(existingFile,
|
|
102
|
+
await appendFile(existingFile, fileContent);
|
|
87
103
|
} else {
|
|
88
104
|
const filename = `${HH}${mm}-${sessionId}-${topic}.md`;
|
|
89
105
|
const filepath = join(promptDir, filename);
|
|
90
|
-
await appendFile(filepath,
|
|
106
|
+
await appendFile(filepath, fileContent);
|
|
91
107
|
}
|
|
92
108
|
lastUserMessage = text;
|
|
93
109
|
}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-prompt-recorder",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "OpenCode plugin for recording user prompts. Automatically saves user messages to a local file system with organized directory structure.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-prompt-recorder",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "OpenCode plugin for recording user prompts. Automatically saves user messages to a local file system with organized directory structure.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|