@sagmans/pi-prefix 0.1.5 → 0.1.6

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 +30 -5
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -23,6 +23,7 @@ const THIRD_PARTY_LIMIT_NOTE =
23
23
  const EXTENSION_COMMAND_SOURCE = "extension";
24
24
  const COMMAND_NAME_SEPARATOR = " ";
25
25
  const COMMAND_PREFIX = "/";
26
+ const DELIVER_WHILE_BUSY = "steer";
26
27
 
27
28
  type SessionState = {
28
29
  result: LoadConfigResult;
@@ -60,13 +61,28 @@ function bindingSummary(state: SessionState): string {
60
61
  .join(", ");
61
62
  }
62
63
 
63
- function statusMessage(state: SessionState | undefined, agentDir: string): string {
64
+ function statusMessage(
65
+ state: SessionState | undefined,
66
+ agentDir: string,
67
+ inactiveResult: LoadConfigResult | undefined,
68
+ ): string {
64
69
  if (state === undefined || state.result.config === undefined) {
65
- return [
70
+ const lines = [
66
71
  "pi-prefix: inactive",
67
72
  `global config: ${agentDir}/pi-prefix.json`,
68
73
  "No effective prefix and bindings. See the package README for configuration.",
69
- ].join(" | ");
74
+ ];
75
+ // WHY: startup notices scroll away; the status command is where users
76
+ // look later to learn why the extension is off.
77
+ if (inactiveResult !== undefined) {
78
+ for (const error of formatDiagnostics(inactiveResult, "error")) {
79
+ lines.push(`error: ${error}`);
80
+ }
81
+ for (const warning of formatDiagnostics(inactiveResult, "warning")) {
82
+ lines.push(`warning: ${warning}`);
83
+ }
84
+ }
85
+ return lines.join(" | ");
70
86
  }
71
87
  const { config } = state.result;
72
88
  const lines = [
@@ -96,11 +112,14 @@ export function setupPiPrefix(
96
112
  options: { agentDir: string },
97
113
  ): void {
98
114
  let state: SessionState | undefined;
115
+ // WHY: an inactive session has no SessionState, but its load diagnostics
116
+ // must stay reachable from the status command.
117
+ let inactiveResult: LoadConfigResult | undefined;
99
118
 
100
119
  pi.registerCommand(STATUS_COMMAND, {
101
120
  description: "Show pi-prefix status, loaded config layers, and conflicts",
102
121
  handler: async (_args: string, ctx: ExtensionContext) => {
103
- ctx.ui.notify(statusMessage(state, options.agentDir), "info");
122
+ ctx.ui.notify(statusMessage(state, options.agentDir, inactiveResult), "info");
104
123
  },
105
124
  });
106
125
 
@@ -120,8 +139,10 @@ export function setupPiPrefix(
120
139
  if (result.config === undefined) {
121
140
  // WHY: absence of a full map is ordinary; the extension stays inert
122
141
  // without touching the editor chain.
142
+ inactiveResult = result;
123
143
  return;
124
144
  }
145
+ inactiveResult = undefined;
125
146
  state = {
126
147
  result,
127
148
  projectTrusted: ctx.isProjectTrusted(),
@@ -151,7 +172,10 @@ export function setupPiPrefix(
151
172
  (available) => available.name === name && available.source === EXTENSION_COMMAND_SOURCE,
152
173
  );
153
174
  if (!isExtensionCommand) return false;
154
- pi.sendUserMessage(command, { expandPromptTemplates: true });
175
+ // WHY: newer Pi hosts treat a starting run as busy and reject
176
+ // sendUserMessage without deliverAs; steer matches what Enter does
177
+ // for typed input while the agent is working.
178
+ pi.sendUserMessage(command, { expandPromptTemplates: true, deliverAs: DELIVER_WHILE_BUSY });
155
179
  return true;
156
180
  },
157
181
  });
@@ -188,6 +212,7 @@ export function setupPiPrefix(
188
212
  pi.on("session_shutdown", (_event, ctx) => {
189
213
  state?.wrapper?.dispose();
190
214
  state = undefined;
215
+ inactiveResult = undefined;
191
216
  ctx.ui.setStatus(STATUS_KEY, undefined);
192
217
  });
193
218
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sagmans/pi-prefix",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "description": "Configurable prefix key that maps a second key to Pi app actions, slash commands, or extension events",
6
6
  "license": "MIT",