@vieko/pi-redact 0.1.1 → 0.1.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.
@@ -23,6 +23,10 @@
23
23
  *
24
24
  * The vault lives in memory. After /reload or a resume, old placeholders no
25
25
  * longer map to a value and reach tools as written.
26
+ *
27
+ * The footer shows `redact:N`: distinct values kept out of this session's
28
+ * transcript. It counts the `pi-redact` entries on the branch, so the
29
+ * number survives /reload and resume even though the vault does not.
26
30
  */
27
31
 
28
32
  import { existsSync, readFileSync } from "node:fs";
@@ -115,6 +119,16 @@ export function createRedactor(pi: ExtensionAPI, init: RedactOptions = {}): void
115
119
  const cfg = buildConfig(init.options ?? loadOptions(CONFIG_PATH));
116
120
  let enabled = true;
117
121
  let hiddenTotal = 0;
122
+ let kept = 0;
123
+ let ui: ExtensionContext | undefined;
124
+ const showStatus = (): void => {
125
+ if (!ui?.hasUI || kept <= 0) return;
126
+ try {
127
+ ui.ui.setStatus(NAME, ui.ui.theme.fg("dim", `redact:${kept}`));
128
+ } catch {
129
+ // The context went stale (session replaced); the next session_start resets it.
130
+ }
131
+ };
118
132
  const handedById = new Map<string, Set<string>>();
119
133
  const contextMemo = new WeakMap<object, AnyMessage>();
120
134
  const tracked = new Set<string>();
@@ -126,6 +140,8 @@ export function createRedactor(pi: ExtensionAPI, init: RedactOptions = {}): void
126
140
  const fresh = [...tags].filter((t) => !t.startsWith("[REDACTED-LITERAL-") && !tracked.has(t));
127
141
  if (fresh.length === 0) return;
128
142
  for (const t of fresh) tracked.add(t);
143
+ kept += fresh.length;
144
+ showStatus();
129
145
  const vendor = fresh.filter((t) => findVendorKeys(restore(t)).length > 0).length;
130
146
  try {
131
147
  pi.appendEntry(NAME, { source, values: fresh.length, vendor });
@@ -146,7 +162,6 @@ export function createRedactor(pi: ExtensionAPI, init: RedactOptions = {}): void
146
162
  if (n <= 0) return;
147
163
  hiddenTotal += n;
148
164
  if (!ctx?.hasUI) return;
149
- ctx.ui.setStatus(NAME, `redact ${hiddenTotal}`);
150
165
  if (cfg.notify && where) ctx.ui.notify(`${NAME}: hid ${n} value(s) from ${where}`, "info");
151
166
  };
152
167
 
@@ -161,6 +176,16 @@ export function createRedactor(pi: ExtensionAPI, init: RedactOptions = {}): void
161
176
  return out;
162
177
  };
163
178
 
179
+ pi.on("session_start", (_event, ctx) => {
180
+ ui = ctx;
181
+ kept = 0;
182
+ for (const e of ctx.sessionManager.getBranch() as { type: string; customType?: string; data?: { values?: number } }[]) {
183
+ if (e.type === "custom" && e.customType === NAME) kept += e.data?.values ?? 0;
184
+ }
185
+ if (ctx.hasUI) ctx.ui.setStatus(NAME, undefined);
186
+ showStatus();
187
+ });
188
+
164
189
  // 1. What the user types. `!cmd` is the user's own shell and runs as typed.
165
190
  pi.on("input", (event, ctx) => {
166
191
  if (!enabled || event.text.startsWith("!")) return { action: "continue" as const };
package/package.json CHANGED
@@ -1,25 +1,54 @@
1
1
  {
2
2
  "name": "@vieko/pi-redact",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Keeps secrets out of pi session transcripts: stable placeholders in, real values back for local tools.",
5
- "keywords": ["pi-package", "pi-extension", "secrets", "redaction", "privacy"],
5
+ "keywords": [
6
+ "pi-package",
7
+ "pi-extension",
8
+ "secrets",
9
+ "redaction",
10
+ "privacy"
11
+ ],
6
12
  "license": "MIT",
7
13
  "author": "Vieko Franetovic",
8
- "repository": { "type": "git", "url": "git+https://github.com/vieko/pi-redact.git" },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/vieko/pi-redact.git"
17
+ },
9
18
  "homepage": "https://github.com/vieko/pi-redact#readme",
10
- "bugs": { "url": "https://github.com/vieko/pi-redact/issues" },
11
- "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org" },
19
+ "bugs": {
20
+ "url": "https://github.com/vieko/pi-redact/issues"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public",
24
+ "registry": "https://registry.npmjs.org"
25
+ },
12
26
  "type": "module",
13
- "files": ["extensions", "src", "scripts", "README.md", "NOTICE", "LICENSE"],
27
+ "files": [
28
+ "extensions",
29
+ "src",
30
+ "scripts",
31
+ "README.md",
32
+ "NOTICE",
33
+ "LICENSE"
34
+ ],
14
35
  "scripts": {
15
36
  "typecheck": "tsc -p tsconfig.json",
16
37
  "test:vendor": "node test/detect.vendor.mts && node test/pii-options.vendor.mts && node test/random-tags.vendor.mts && node test/session-privacy.vendor.mts",
17
38
  "test": "node --test \"test/*.test.ts\" && npm run test:vendor",
18
39
  "check": "npm run typecheck && npm run test"
19
40
  },
20
- "engines": { "node": ">=22.18" },
21
- "pi": { "extensions": ["./extensions/pi-redact.ts"] },
22
- "peerDependencies": { "@earendil-works/pi-coding-agent": ">=0.1.0" },
41
+ "engines": {
42
+ "node": ">=22.18"
43
+ },
44
+ "pi": {
45
+ "extensions": [
46
+ "./extensions/pi-redact.ts"
47
+ ]
48
+ },
49
+ "peerDependencies": {
50
+ "@earendil-works/pi-coding-agent": ">=0.1.0"
51
+ },
23
52
  "devDependencies": {
24
53
  "@earendil-works/pi-coding-agent": "*",
25
54
  "@types/node": "^24.0.0",