opencode-prompt-recorder 1.7.0 → 1.7.1
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 +5 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{mkdir as y,appendFile as
|
|
2
|
-
`;try{let
|
|
3
|
-
`)[0].trim().replace(/<[^>]*>/g,"").replace(/\s+/g," ").trim().replace(j,"").substring(0,40).trim()||"untitled"}function A(t){return
|
|
1
|
+
import{mkdir as y,appendFile as M,writeFile as O,readFile as x}from"fs/promises";import{join as o,dirname as T}from"path";import{fileURLToPath as _}from"url";var b=T(_(import.meta.url));async function h(t,a){if(process.env.PROMPT_RECORDER_DEBUG!=="1"&&process.env.PROMPT_RECORDER_DEBUG!=="true")return;let g=`[${new Date().toISOString()}] ${a}
|
|
2
|
+
`;try{let s=o(t,".agent","prompts-log");await y(s,{recursive:!0}),await M(o(s,"log.txt"),g)}catch(s){console.error("debugLog failed:",s)}}async function C(){try{return JSON.parse(await x(o(b,"package.json"),"utf-8")).version}catch{return"unknown"}}var j=/[<>:"/\\|?*\x00-\x1f]/g;function v(t){return t.split(`
|
|
3
|
+
`)[0].trim().replace(/<[^>]*>/g,"").replace(/\s+/g," ").trim().replace(j,"").substring(0,40).trim()||"untitled"}function A(t){let a=t.trimStart();return a.startsWith("<system-reminder>")||a.startsWith("<system>")}function B(t){let a=t.getFullYear().toString(),p=String(t.getMonth()+1).padStart(2,"0"),g=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),m=String(t.getMinutes()).padStart(2,"0");return{yyyy:a,MM:p,dd:g,HH:s,mm:m}}function G(t){return`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}var J=async({directory:t,client:a})=>{let p=!1,g=new Map,s=new Set,m=null;return{event:async({event:c})=>{if(c.type==="message.updated"){let e=c.properties.info,n=e?.role||e?.message?.role;e?.id&&n&&g.set(e.id,n)}if(c.type==="message.part.updated"){let e=c.properties.part;if(e?.type==="text"&&e?.text){if(e.synthetic)return;let n=e.sessionID,l=e.messageID,r=e.text,i=g.get(l);if(i||(i=e.message?.role),i||(i=c.properties.info?.role),i||(i=c.properties.info?.message?.role),i==="user"&&r&&n){if(A(r)){await h(t,`[prompt-recorder] filtered system-injected: sessionID=${n}`);return}let S=`${l}:${r}`;if(s.has(S))return;s.add(S),await h(t,`[prompt-recorder] event=${c.type}, role=${i}, sessionID=${n}, textLength=${r.length}, textPreview=${r.substring(0,50)}`),m||(m=n);let $=new Date,{yyyy:u,MM:d,dd:f,HH:R,mm:k}=B($),D=o(t,".agent","prompts"),w=n!==m&&m!==null?o(D,"task",u,d,f):o(D,u,d,f);await y(w,{recursive:!0});let I=G($),L=u.slice(-2),P=`${`============ ${I} ============`}
|
|
4
4
|
|
|
5
|
-
${
|
|
5
|
+
${r}`,E=v(r),H=`${L}${d}${f}${R}${k}-${E}.md`,F=o(w,H);await M(F,P)}}}if(c.type==="session.updated"&&!p)try{let e=await C(),n=o(t,".agent"),l=o(n,"opencode-prompt-recorder-readme.txt"),r=`# OpenCode Prompt Recorder
|
|
6
6
|
|
|
7
7
|
\u81EA\u52A8\u8BB0\u5F55\u7528\u6237\u63D0\u793A\u8BCD\u5230 .agent/prompts \u76EE\u5F55\u7684\u63D2\u4EF6\u3002
|
|
8
8
|
|
|
9
9
|
\u7248\u672C\uFF1A${e}
|
|
10
10
|
\u4F5C\u8005\uFF1Aanarckk
|
|
11
|
-
\u9879\u76EE\u5730\u5740\uFF1Ahttps://github.com/anarckk/opencode-prompt-recorder`;try{if(await
|
|
11
|
+
\u9879\u76EE\u5730\u5740\uFF1Ahttps://github.com/anarckk/opencode-prompt-recorder`;try{if(await x(l,"utf-8")===r){p=!0;return}}catch{}await y(n,{recursive:!0}),await O(l,r),p=!0}catch{}}}},V=J;export{J as OpenCodePromptRecorder,V as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-prompt-recorder",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.1",
|
|
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",
|