pi-one-instruction 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.
Files changed (2) hide show
  1. package/index.ts +11 -14
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { join } from "node:path"
2
- import { appendFileSync, existsSync, readFileSync, writeFileSync } from "node:fs";
3
- import { getAgentDir, getMarkdownTheme, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
4
- import { Markdown, type AutocompleteItem } from "@earendil-works/pi-tui";
1
+ import { join } from "node:path";
2
+ import { existsSync, readFileSync } from "node:fs";
3
+ import { getAgentDir, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
4
+ import { type AutocompleteItem } from "@earendil-works/pi-tui";
5
5
 
6
6
  export default function (pi: ExtensionAPI) {
7
7
  const conf = join(getAgentDir(), "INSTRUCTION.md");
@@ -9,12 +9,6 @@ export default function (pi: ExtensionAPI) {
9
9
  const path = [local_conf, conf].find(existsSync);
10
10
  const instr = path ? readFileSync(path, "utf8") : null;
11
11
  let enabled = true;
12
- pi.registerEntryRenderer<{ content: string }>(
13
- "one-instruction-view",
14
- (entry, _options, _theme) => {
15
- return new Markdown(entry.data?.content ?? "", 1, 1, getMarkdownTheme());
16
- }
17
- );
18
12
  pi.registerCommand("one-instruction", {
19
13
  description: "Toggle one instruction",
20
14
  getArgumentCompletions: (prefix): AutocompleteItem[] => {
@@ -35,15 +29,18 @@ export default function (pi: ExtensionAPI) {
35
29
  ctx.ui.notify("INSTRUCTION.md not found in project or user configuration", "warning");
36
30
  return;
37
31
  }
38
- ctx.ui.notify("View INSTRUCTION.md", "info");
39
- pi.appendEntry("one-instruction-view", { content: instr });
32
+ const numbered = instr
33
+ .split("\n")
34
+ .map((line, n) => `${n + 1} ${line}`)
35
+ .join("\n");
36
+ ctx.ui.notify(`View: ${path}\n${numbered}`, "info");
40
37
  } else {
41
38
  ctx.ui.notify("Usage: /one-instruction on|off|view", "warning");
42
39
  }
43
40
  },
44
41
  });
45
- pi.on("before_provider_request", (event) => {
42
+ pi.on("before_agent_start", (event) => {
46
43
  if (instr == null || !enabled) return;
47
- (event.payload as Record<string, unknown>).instructions = instr;
44
+ event.systemPromptOptions.forceSystemPrompt = instr;
48
45
  });
49
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-one-instruction",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Overwrite Pi's instructions with a single INSTRUCTION.md",
5
5
  "license": "MIT",
6
6
  "repository": {