@leing2021/super-pi 0.25.2 → 0.25.3

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/README.md CHANGED
@@ -18,7 +18,7 @@ Install, describe what you want to build, then keep saying "continue." Super Pi
18
18
  pi install npm:@leing2021/super-pi
19
19
  ```
20
20
 
21
- ---
21
+ > **Project trust (pi ≥ 0.79):** Pi asks before loading project-local settings, resources, and packages. On first use, approve the project trust prompt so Super Pi can read `.pi/settings.json` and load its skills/extensions. Use `pi --approve` for non-interactive runs.
22
22
 
23
23
  ## Highlights
24
24
 
@@ -1,6 +1,7 @@
1
1
  import { readFile } from "node:fs/promises"
2
2
  import path from "node:path"
3
3
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent"
4
+ import { CONFIG_DIR_NAME } from "@earendil-works/pi-coding-agent"
4
5
  import { Type } from "typebox"
5
6
  import { createArtifactHelperTool, type ArtifactType } from "./tools/artifact-helper"
6
7
  import { createAskUserQuestionTool, CUSTOM_SENTINEL } from "./tools/ask-user-question"
@@ -97,15 +98,17 @@ interface StrategySettings {
97
98
  }
98
99
 
99
100
  /**
100
- * Read settings from two locations:
101
- * 1. Project-level: {cwd}/.pi/settings.json (highest priority)
102
- * 2. Global-level: ~/.pi/agent/settings.json (fallback)
101
+ * Read settings from two locations (config dir honors pi's `CONFIG_DIR_NAME`,
102
+ * which defaults to `.pi` but is user-configurable since pi 0.79.7):
103
+ * 1. Project-level: {cwd}/{CONFIG_DIR_NAME}/settings.json (highest priority)
104
+ * 2. Global-level: ~/{CONFIG_DIR_NAME}/agent/settings.json (fallback)
103
105
  *
104
106
  * Project-level takes precedence; global-level is used as fallback.
105
107
  */
106
108
  async function readSettings(cwd: string): Promise<StrategySettings | null> {
109
+ const agentHome = process.env.HOME || "~"
107
110
  // Try project-level first
108
- const projectPath = path.join(cwd, ".pi", "settings.json")
111
+ const projectPath = path.join(cwd, CONFIG_DIR_NAME, "settings.json")
109
112
  try {
110
113
  const content = await readFile(projectPath, "utf8")
111
114
  const projectSettings = JSON.parse(content) as StrategySettings
@@ -118,7 +121,7 @@ async function readSettings(cwd: string): Promise<StrategySettings | null> {
118
121
  }
119
122
 
120
123
  // Fallback to global-level
121
- const globalPath = path.join(process.env.HOME || "~", ".pi", "agent", "settings.json")
124
+ const globalPath = path.join(agentHome, CONFIG_DIR_NAME, "agent", "settings.json")
122
125
  try {
123
126
  const content = await readFile(globalPath, "utf8")
124
127
  return JSON.parse(content) as StrategySettings
@@ -126,8 +129,8 @@ async function readSettings(cwd: string): Promise<StrategySettings | null> {
126
129
  // Global settings not found either
127
130
  }
128
131
 
129
- // Try ~/.pi/settings.json as another fallback
130
- const altGlobalPath = path.join(process.env.HOME || "~", ".pi", "settings.json")
132
+ // Try ~/{CONFIG_DIR_NAME}/settings.json as another fallback
133
+ const altGlobalPath = path.join(agentHome, CONFIG_DIR_NAME, "settings.json")
131
134
  try {
132
135
  const content = await readFile(altGlobalPath, "utf8")
133
136
  return JSON.parse(content) as StrategySettings
@@ -805,7 +808,19 @@ export default function ceCoreExtension(pi: ExtensionAPI) {
805
808
  }
806
809
  })
807
810
 
808
- // Tree summary prompt optimizer — keeps branch summaries focused
811
+ // Branch summary prompt optimizer — appends focus instructions to `/tree`
812
+ // navigation summaries. `SessionBeforeTreeResult.customInstructions` is
813
+ // consumed by pi (agent-session.js navigateTree), so this return shape is
814
+ // effective for branch summaries.
815
+ //
816
+ // NOTE on regular context compaction (manual `/compact`, threshold,
817
+ // overflow): pi's `session_before_compact` result only accepts `cancel` or
818
+ // a full `compaction` replacement — there is NO prompt-only injection
819
+ // field (`customInstructions` is an event *input*, not a return value).
820
+ // So we cannot append focus instructions to regular compaction summaries
821
+ // without replacing pi's entire summarizer. We deliberately do not hook
822
+ // `session_before_compact` to avoid dead handlers and needless emit()
823
+ // overhead on every compaction.
809
824
  pi.on("session_before_tree", async (_event, _ctx) => {
810
825
  return {
811
826
  customInstructions: COMPACTION_FOCUS_INSTRUCTIONS,
@@ -2,11 +2,23 @@
2
2
  // Compaction Prompt Optimizer
3
3
  // ============================================================================
4
4
  //
5
- // Hooks into `session_before_compact` to inject custom instructions that make
6
- // compaction summaries more focused and useful for coding agent context.
5
+ // Focus instructions injected into pi's branch-summary prompts so summaries
6
+ // stay useful for coding-agent continuation.
7
7
  //
8
- // This is a "prompt-only" optimization it doesn't replace pi's compaction
9
- // flow, just adds focus instructions to the summarization prompt.
8
+ // Consumed by the `session_before_tree` hook in `index.ts`, which returns
9
+ // `{ customInstructions, replaceInstructions }`. This return shape IS
10
+ // supported by pi (consumed in `agent-session.js` navigateTree →
11
+ // SessionBeforeTreeResult) and appends focus instructions to summaries
12
+ // generated on `/tree` navigation.
13
+ //
14
+ // Regular context compaction (manual `/compact`, threshold, overflow) is
15
+ // NOT covered: pi's `SessionBeforeCompactResult` only accepts `cancel` or a
16
+ // full `compaction` replacement — there is no prompt-only injection field
17
+ // (`customInstructions` is an event *input*, not a return value). Appending
18
+ // focus instructions there would require replacing pi's entire summarizer,
19
+ // so we deliberately do not hook it.
20
+ //
21
+ // This is a "prompt-only" optimization; it does not replace pi's flows.
10
22
 
11
23
  /**
12
24
  * Custom instructions appended to compaction summarization prompts.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leing2021/super-pi",
3
- "version": "0.25.2",
3
+ "version": "0.25.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Pi-native Compound Engineering package for iterative development workflows",
@@ -35,13 +35,13 @@
35
35
  "test": "bun test"
36
36
  },
37
37
  "peerDependencies": {
38
- "@earendil-works/pi-coding-agent": ">=0.74.0",
39
- "@earendil-works/pi-tui": ">=0.74.0",
38
+ "@earendil-works/pi-coding-agent": ">=0.79.10",
39
+ "@earendil-works/pi-tui": ">=0.79.10",
40
40
  "typebox": ">=1.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@earendil-works/pi-coding-agent": "^0.76.0",
44
- "@earendil-works/pi-tui": "^0.76.0",
43
+ "@earendil-works/pi-coding-agent": "^0.80.0",
44
+ "@earendil-works/pi-tui": "^0.80.0",
45
45
  "bun-types": "^1.3.12"
46
46
  },
47
47
  "pi": {