pi-doc-injector 0.8.0 → 0.9.0

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.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/index.ts +13 -0
  3. package/package.json +3 -1
package/README.md CHANGED
@@ -19,6 +19,8 @@ If switching from npm, run `pi remove npm:pi-doc-injector` first to avoid loadin
19
19
 
20
20
  Requires Pi 1.5.2 or newer within the 1.x series.
21
21
 
22
+ The Pi transcript shows injected documents collapsed by default. Press Pi’s **Expand tools** shortcut (`Ctrl+O` by default) to show or hide their contents along with other expandable transcript items. This changes only what you see. The model still receives the complete documents.
23
+
22
24
  ## Simple mode (default)
23
25
 
24
26
  Create `docs/auth.md`. When **auth** appears as a complete word in a user message, assistant text, or assistant thinking, the extension selects that file. Matching ignores case. A user match injects the doc before the assistant responds. An assistant match injects it at Pi's completed `turn_end` boundary, after the assistant response and any tool results are saved. Pi persists a `custom_message` entry and continues the **same** run with the document available to the next provider request.
package/index.ts CHANGED
@@ -12,6 +12,7 @@ import type {
12
12
  ExtensionAPI,
13
13
  ExtensionContext,
14
14
  } from "@earendil-works/pi-coding-agent";
15
+ import { Box, Text } from "@earendil-works/pi-tui";
15
16
  import { Type } from "typebox";
16
17
  import { resolve } from "node:path";
17
18
  import { loadCache, mergeAndSaveCache } from "./cache";
@@ -36,6 +37,18 @@ import {
36
37
  import { registerCommands } from "./commands";
37
38
 
38
39
  export default async function docInjectorExtension(pi: ExtensionAPI) {
40
+ pi.registerMessageRenderer("doc-injector", (_message, options, theme) => {
41
+ // Let Pi render the original Markdown when transcript output is expanded.
42
+ if (options.expanded) return undefined;
43
+ const label = theme.fg("customMessageLabel", "Injected documents");
44
+ const hint = options.keyHint("app.tools.expand", "to expand");
45
+ const box = new Box(options.outputPad, 1, (line) =>
46
+ theme.bg("customMessageBg", line),
47
+ );
48
+ box.addChild(new Text(`${label} (${hint})`, 0, 0));
49
+ return box;
50
+ });
51
+
39
52
  // ---- State ----
40
53
  // The notifier buffers warnings emitted during startup (loadConfig,
41
54
  // loadCache, initRegistry) and flushes them via ctx.ui.notify() in
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-doc-injector",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Inject project docs into Pi context when their filename appears in the conversation",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
@@ -44,10 +44,12 @@
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@earendil-works/pi-coding-agent": "*",
47
+ "@earendil-works/pi-tui": "*",
47
48
  "typebox": "*"
48
49
  },
49
50
  "devDependencies": {
50
51
  "@earendil-works/pi-coding-agent": "^1.5.2",
52
+ "@earendil-works/pi-tui": "1.5.2",
51
53
  "@types/node": "^22.0.0",
52
54
  "husky": "^9.1.7",
53
55
  "prettier": "^3.8.4",