@dyyz1993/pi-coding-agent 0.74.14 → 0.74.16

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.
@@ -12,6 +12,7 @@ import { spawn, spawnSync } from "child_process";
12
12
  import { APP_NAME, APP_TITLE, getAgentDir, getAuthPath, getDebugLogPath, getDocsPath, getShareViewerUrl, VERSION, } from "../../config.js";
13
13
  import { parseSkillBlock } from "../../core/agent-session.js";
14
14
  import { SessionImportFileNotFoundError } from "../../core/agent-session-runtime.js";
15
+ import { resolveProjectIdentity, getSessionDataDir, getProjectDataDir, getCwdDataDir, getGlobalDataDir } from "../../core/storage.js";
15
16
  import { FooterDataProvider } from "../../core/footer-data-provider.js";
16
17
  import { KeybindingsManager } from "../../core/keybindings.js";
17
18
  import { createCompactionSummaryMessage } from "../../core/messages.js";
@@ -1225,51 +1226,52 @@ export class InteractiveMode {
1225
1226
  if (shortcuts.size === 0)
1226
1227
  return;
1227
1228
  // Create a context for shortcut handlers
1228
- const createContext = () => ({
1229
- ui: this.createExtensionUIContext(),
1230
- hasUI: true,
1231
- cwd: this.sessionManager.getCwd(),
1232
- sessionManager: this.sessionManager,
1233
- modelRegistry: this.session.modelRegistry,
1234
- model: this.session.model,
1235
- isIdle: () => !this.session.isStreaming,
1236
- signal: this.session.agent.signal,
1237
- abort: () => this.session.abort(),
1238
- hasPendingMessages: () => this.session.pendingMessageCount > 0,
1239
- shutdown: () => {
1240
- this.shutdownRequested = true;
1241
- },
1242
- getContextUsage: () => this.session.getContextUsage(),
1243
- compact: (options) => {
1244
- void (async () => {
1245
- try {
1246
- const result = await this.session.compact(options?.customInstructions);
1247
- options?.onComplete?.(result);
1248
- }
1249
- catch (error) {
1250
- const err = error instanceof Error ? error : new Error(String(error));
1251
- options?.onError?.(err);
1252
- }
1253
- })();
1254
- },
1255
- getSystemPrompt: () => this.session.systemPrompt,
1256
- extensionName: "",
1257
- projectRoot: this.sessionManager.getCwd(),
1258
- sessionDataDir: "",
1259
- projectDataDir: "",
1260
- cwdDataDir: "",
1261
- globalDataDir: "",
1262
- sessionSignal: AbortSignal.abort(),
1263
- respondUI: () => { },
1264
- fileSnapshotManager: this.session.fileSnapshotManager,
1265
- });
1229
+ const createContext = (extName) => {
1230
+ const projectRoot = resolveProjectIdentity(this.sessionManager.getCwd());
1231
+ return {
1232
+ ui: this.createExtensionUIContext(),
1233
+ hasUI: true,
1234
+ cwd: this.sessionManager.getCwd(),
1235
+ sessionManager: this.sessionManager,
1236
+ modelRegistry: this.session.modelRegistry,
1237
+ model: this.session.model,
1238
+ isIdle: () => !this.session.isStreaming,
1239
+ signal: this.session.agent.signal,
1240
+ abort: () => this.session.abort(),
1241
+ hasPendingMessages: () => this.session.pendingMessageCount > 0,
1242
+ shutdown: () => {
1243
+ this.shutdownRequested = true;
1244
+ },
1245
+ getContextUsage: () => this.session.getContextUsage(),
1246
+ compact: (options) => {
1247
+ void (async () => {
1248
+ try {
1249
+ const result = await this.session.compact(options?.customInstructions);
1250
+ options?.onComplete?.(result);
1251
+ }
1252
+ catch (error) {
1253
+ const err = error instanceof Error ? error : new Error(String(error));
1254
+ options?.onError?.(err);
1255
+ }
1256
+ })();
1257
+ },
1258
+ getSystemPrompt: () => this.session.systemPrompt,
1259
+ extensionName: extName,
1260
+ projectRoot,
1261
+ sessionDataDir: getSessionDataDir(this.sessionManager.getSessionDir(), this.sessionManager.getSessionId(), extName),
1262
+ projectDataDir: getProjectDataDir(projectRoot, extName),
1263
+ cwdDataDir: getCwdDataDir(this.sessionManager.getCwd(), extName),
1264
+ globalDataDir: getGlobalDataDir(extName),
1265
+ sessionSignal: AbortSignal.abort(),
1266
+ respondUI: () => { },
1267
+ fileSnapshotManager: this.session.fileSnapshotManager,
1268
+ };
1269
+ };
1266
1270
  // Set up the extension shortcut handler on the default editor
1267
1271
  this.defaultEditor.onExtensionShortcut = (data) => {
1268
1272
  for (const [shortcutStr, shortcut] of shortcuts) {
1269
- // Cast to KeyId - extension shortcuts use the same format
1270
1273
  if (matchesKey(data, shortcutStr)) {
1271
- // Run handler async, don't block input
1272
- Promise.resolve(shortcut.handler(createContext())).catch((err) => {
1274
+ Promise.resolve(shortcut.handler(createContext(shortcut.extensionName))).catch((err) => {
1273
1275
  this.showError(`Shortcut handler error: ${err instanceof Error ? err.message : String(err)}`);
1274
1276
  });
1275
1277
  return true;