@tduyng/pi-timbre 0.0.1 → 0.0.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/package.json +1 -1
- package/src/index.ts +9 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tduyng/pi-timbre",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Constrain the agent prose and code before it is written: inject the rules, block the undeniable tells, measure the reply, and rewrite what is already on disk.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi",
|
package/src/index.ts
CHANGED
|
@@ -101,10 +101,10 @@ export default function timbre(pi: ExtensionAPI): void {
|
|
|
101
101
|
let turnPrevented = config.prevent
|
|
102
102
|
const preventedNow = (): boolean => turnPrevented
|
|
103
103
|
|
|
104
|
-
let pendingWarning: string | undefined
|
|
105
104
|
const touchedCode = new Set<string>()
|
|
106
105
|
const reportedCode = new Map<string, string>()
|
|
107
106
|
let noticesHeld = 0
|
|
107
|
+
const reportedNotes = new Set<string>()
|
|
108
108
|
let block: { path: string; text: string } | undefined
|
|
109
109
|
|
|
110
110
|
let cached: { path: string; memory: Memory; mtimeMs: number; size: number } | undefined
|
|
@@ -157,7 +157,9 @@ export default function timbre(pi: ExtensionAPI): void {
|
|
|
157
157
|
} catch {}
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
pi.on('
|
|
160
|
+
pi.on('session_compact', () => {
|
|
161
|
+
reportedNotes.clear()
|
|
162
|
+
})
|
|
161
163
|
|
|
162
164
|
pi.on(
|
|
163
165
|
'before_agent_start',
|
|
@@ -287,7 +289,7 @@ export default function timbre(pi: ExtensionAPI): void {
|
|
|
287
289
|
const found = inspectProse(event, ctx.cwd)
|
|
288
290
|
if (found === null) return undefined
|
|
289
291
|
|
|
290
|
-
const { hits, chars, note: scannedNote, domain } = found
|
|
292
|
+
const { path, hits, chars, note: scannedNote, domain } = found
|
|
291
293
|
|
|
292
294
|
commit(
|
|
293
295
|
ctx.cwd,
|
|
@@ -298,10 +300,12 @@ export default function timbre(pi: ExtensionAPI): void {
|
|
|
298
300
|
)
|
|
299
301
|
)
|
|
300
302
|
|
|
301
|
-
const
|
|
303
|
+
const reportKey = `${ctx.sessionManager.getSessionId()}\n${path}\n${scannedNote}`
|
|
304
|
+
const repeat = scannedNote !== '' && reportedNotes.has(reportKey)
|
|
305
|
+
if (scannedNote !== '') reportedNotes.add(reportKey)
|
|
306
|
+
const parts = [scannedNote === '' || repeat ? undefined : scannedNote].filter(
|
|
302
307
|
(part): part is string => part !== undefined
|
|
303
308
|
)
|
|
304
|
-
pendingWarning = undefined
|
|
305
309
|
if (parts.length === 0) return undefined
|
|
306
310
|
return { content: [...event.content, { type: 'text' as const, text: parts.join('\n\n') }] }
|
|
307
311
|
} catch {
|