pi-live-context 0.0.1 → 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/CHANGELOG.md CHANGED
@@ -1 +1,13 @@
1
1
  # pi-live-context
2
+
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2](https://github.com/bradennss/pi-live-context/pull/2) [`3fb6039`](https://github.com/bradennss/pi-live-context/commit/3fb603923eb97de2cba8f266f0245ef136f6b390) Thanks [@bradennss](https://github.com/bradennss)! - Support Pi's structured system prompt sections while preserving compatibility with Pi 0.85.
8
+
9
+ ## 1.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - [`6312b97`](https://github.com/bradennss/pi-live-context/commit/6312b978091ec144216a2b0ef2196fbb5234f3c0) Thanks [@bradennss](https://github.com/bradennss)! - First stable release. pi-live-context reloads AGENTS.md every turn and sends it as a user message instead of system prompt text.
package/README.md CHANGED
@@ -21,7 +21,7 @@ Pi discovers `AGENTS.md` and `CLAUDE.md` the same way it usually does, but sends
21
21
 
22
22
  ## Requirements
23
23
 
24
- - Node.js >= 20.
24
+ - Node.js >= 22.19, the version Pi itself requires.
25
25
  - Pi 0.85 or newer.
26
26
 
27
27
  ## Development
package/index.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  * before every request.
5
5
  */
6
6
  import {
7
+ type BuildSystemPromptOptions,
7
8
  type ExtensionAPI,
8
9
  type ExtensionContext,
9
10
  getAgentDir,
@@ -18,6 +19,12 @@ import { stripContextFiles } from "./src/system-prompt.ts";
18
19
  const LAYOUT_WARNING =
19
20
  "pi-live-context is off for this session: this version of Pi lays out context files in a way the extension cannot remove from the system prompt.";
20
21
 
22
+ function supportsStructuredSystemPrompt(
23
+ options: BuildSystemPromptOptions,
24
+ ): boolean {
25
+ return "sections" in options;
26
+ }
27
+
21
28
  export default function liveContext(pi: ExtensionAPI): void {
22
29
  let relocating = false;
23
30
  let warned = false;
@@ -31,10 +38,22 @@ export default function liveContext(pi: ExtensionAPI): void {
31
38
  }
32
39
 
33
40
  pi.on("before_agent_start", (event, ctx) => {
34
- const contextFiles = event.systemPromptOptions.contextFiles ?? [];
41
+ const options = event.systemPromptOptions;
42
+ const contextFiles = options.contextFiles;
43
+ if (contextFiles.length === 0) {
44
+ relocating = false;
45
+ return;
46
+ }
47
+
48
+ if (supportsStructuredSystemPrompt(options)) {
49
+ options.contextFiles = [];
50
+ relocating = true;
51
+ return;
52
+ }
53
+
35
54
  const systemPrompt = stripContextFiles(event.systemPrompt, contextFiles);
36
- relocating = contextFiles.length > 0 && systemPrompt !== event.systemPrompt;
37
- if (contextFiles.length > 0 && !relocating) {
55
+ relocating = systemPrompt !== event.systemPrompt;
56
+ if (!relocating) {
38
57
  warnOnce(ctx);
39
58
  }
40
59
  return relocating ? { systemPrompt } : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-live-context",
3
- "version": "0.0.1",
3
+ "version": "1.0.1",
4
4
  "description": "Pi extension that reloads AGENTS.md every turn and sends it as a user message instead of system prompt text.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  "CHANGELOG.md"
39
39
  ],
40
40
  "engines": {
41
- "node": ">=20"
41
+ "node": ">=22.19.0"
42
42
  },
43
43
  "pi": {
44
44
  "extensions": [
@@ -51,9 +51,9 @@
51
51
  "devDependencies": {
52
52
  "@changesets/changelog-github": "^1.0.0",
53
53
  "@changesets/cli": "^3.0.1",
54
- "@earendil-works/pi-coding-agent": "^0.85.1",
54
+ "@earendil-works/pi-coding-agent": "^0.86.1",
55
55
  "@eslint/js": "^10.0.1",
56
- "@types/node": "^22.0.0",
56
+ "@types/node": "^22.19.0",
57
57
  "eslint": "^10.8.1",
58
58
  "eslint-config-prettier": "^10.1.8",
59
59
  "husky": "^9.1.7",
@@ -1,6 +1,6 @@
1
1
  import type { ContextFile } from "./context-file.ts";
2
2
 
3
- /** Mirrors the `<project_context>` block `buildSystemPrompt` appends for context files. */
3
+ /** Renders the context block used by Pi 0.85 and earlier. */
4
4
  function renderSystemPromptBlock(contextFiles: ContextFile[]): string {
5
5
  let block = "\n\n<project_context>\n\n";
6
6
  block += "Project-specific instructions and guidelines:\n\n";