opencode-session-renamer 1.0.0 → 1.0.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.d.ts.map +1 -1
- package/dist/index.js +27 -0
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAiSlD,QAAA,MAAM,MAAM,EAAE,MA6Fb,CAAC;AAGF,eAAO,MAAM,cAAc,QAAS,CAAC;AAGrC,eAAe,MAAM,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -49,7 +49,9 @@ Examples:
|
|
|
49
49
|
- User: "I want to refactor the database module" -> "Refactor database module"
|
|
50
50
|
- User: "Please optimize this React component's performance" -> "Optimize React component performance"`;
|
|
51
51
|
var renamedSessions = new Set;
|
|
52
|
+
var lockedSessions = new Set;
|
|
52
53
|
var tempSessions = new Set;
|
|
54
|
+
var DEFAULT_TITLE_PREFIXES = ["New session - ", "Child session - "];
|
|
53
55
|
var providersConfigPromise = null;
|
|
54
56
|
function formatDate(format) {
|
|
55
57
|
const now = new Date;
|
|
@@ -61,6 +63,13 @@ function formatDate(format) {
|
|
|
61
63
|
const minutes = pad(now.getMinutes());
|
|
62
64
|
return format.replace("YYYY", year.toString()).replace("YY", year.toString().slice(-2)).replace("MM", month).replace("DD", day).replace("HH", hours).replace("mm", minutes);
|
|
63
65
|
}
|
|
66
|
+
function isDefaultTitle(title) {
|
|
67
|
+
if (!title || !title.trim()) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
const trimmed = title.trim();
|
|
71
|
+
return DEFAULT_TITLE_PREFIXES.some((prefix) => trimmed.startsWith(prefix));
|
|
72
|
+
}
|
|
64
73
|
function parseModelString(modelStr) {
|
|
65
74
|
const parts = modelStr.split("/");
|
|
66
75
|
if (parts.length >= 2) {
|
|
@@ -254,6 +263,24 @@ var plugin = async (ctx) => {
|
|
|
254
263
|
log(config, "Session already renamed, skipping:", sessionID);
|
|
255
264
|
return;
|
|
256
265
|
}
|
|
266
|
+
if (lockedSessions.has(sessionID)) {
|
|
267
|
+
log(config, "Session title locked, skipping:", sessionID);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
const sessionClient = ctx.client.session;
|
|
271
|
+
if (sessionClient.get) {
|
|
272
|
+
try {
|
|
273
|
+
const sessionInfo = await sessionClient.get({ path: { id: sessionID } });
|
|
274
|
+
const existingTitle = sessionInfo?.data?.title;
|
|
275
|
+
if (!isDefaultTitle(existingTitle)) {
|
|
276
|
+
lockedSessions.add(sessionID);
|
|
277
|
+
log(config, "Session already titled, skipping:", sessionID);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
} catch (error) {
|
|
281
|
+
log(config, "Failed to read session title:", error);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
257
284
|
let userMessage = null;
|
|
258
285
|
if (message.summary?.title) {
|
|
259
286
|
userMessage = message.summary.title;
|