@trim21/personal-pi-extensions 0.0.383 → 0.0.385

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trim21/personal-pi-extensions",
3
- "version": "0.0.383",
3
+ "version": "0.0.385",
4
4
  "type": "module",
5
5
  "description": "Custom pi coding-agent extensions: bwrap sandbox, workspace guard, opencode edit, and more",
6
6
  "keywords": [
@@ -99,6 +99,6 @@
99
99
  "web-tree-sitter": "^0.26.12"
100
100
  },
101
101
  "optionalDependencies": {
102
- "@cortexkit/aft-linux-x64": "0.52.0"
102
+ "@cortexkit/aft-linux-x64": "0.52.1"
103
103
  }
104
104
  }
package/src/aft/tools.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  import { readFileSync } from "node:fs";
9
9
  import { stat } from "node:fs/promises";
10
10
  import { homedir } from "node:os";
11
- import { basename, isAbsolute, join, relative, resolve } from "node:path";
11
+ import { basename, isAbsolute, join, resolve } from "node:path";
12
12
  import { fileURLToPath } from "node:url";
13
13
 
14
14
  import {
@@ -23,6 +23,7 @@ import {
23
23
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
24
24
  import { Type } from "typebox";
25
25
 
26
+ import { formatDisplayPath } from "../lib/path.js";
26
27
  import { type ToolPendant } from "../lib/pendant.js";
27
28
  import { callAftTool, SEMANTIC_INDEX_WAIT_TIMEOUT_MS } from "./bridge.js";
28
29
 
@@ -50,19 +51,6 @@ export function resolvePathArg(cwd: string, input: string): string {
50
51
  return isAbsolute(input) ? input : resolve(cwd, input);
51
52
  }
52
53
 
53
- /** 人类可读的显示路径:cwd 内用 `./…`,home 内用 `~/…`,否则原样绝对路径。 */
54
- export function formatDisplayPath(cwd: string, filePath: string): string {
55
- const relToCwd = relative(cwd, filePath);
56
- if (relToCwd !== "" && !relToCwd.startsWith("..") && !isAbsolute(relToCwd)) {
57
- return `./${relToCwd}`;
58
- }
59
- const relToHome = relative(homedir(), filePath);
60
- if (relToHome !== "" && !relToHome.startsWith("..") && !isAbsolute(relToHome)) {
61
- return `~/${relToHome}`;
62
- }
63
- return filePath;
64
- }
65
-
66
54
  /** subtitle 中路径的最大显示长度,超过时退化为仅文件名。 */
67
55
  export const MAX_SUBTITLE_PATH_LENGTH = 20;
68
56
 
@@ -16,6 +16,7 @@ import {
16
16
  import { type TObject, Type } from "typebox";
17
17
 
18
18
  import { type CommandSpec, parseCommand } from "../lib/cli.js";
19
+ import { formatDisplayPath } from "../lib/path.js";
19
20
  import {
20
21
  type CheckboxAction,
21
22
  type SelectAction,
@@ -533,9 +534,10 @@ export class BwrapRuntime {
533
534
  );
534
535
  }
535
536
  lines.push(fenceCodeBlock(command));
536
- // 执行目录与工作区不同时,提示实际执行目录(execCwd 是解析后的绝对路径)
537
+ // 执行目录与工作区不同时,提示实际执行目录(execCwd 是解析后的绝对路径,
538
+ // 显示用 pretty path 风格:home 内 `~/…`,否则绝对路径)
537
539
  if (execCwd !== ctx.cwd) {
538
- lines.push(`Workdir: ${escapeHtml(execCwd)}`);
540
+ lines.push(`Workdir: ${escapeHtml(formatDisplayPath(ctx.cwd, execCwd))}`);
539
541
  }
540
542
  const description = lines.join("\n");
541
543
 
package/src/lib/path.ts CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { stat } from "node:fs/promises";
6
6
  import { homedir } from "node:os";
7
- import { isAbsolute, join, resolve } from "node:path";
7
+ import { isAbsolute, join, relative, resolve } from "node:path";
8
8
 
9
9
  /**
10
10
  * Expand a leading `~` to the user's home directory.
@@ -46,3 +46,16 @@ export async function resolveWorkdir(workdir: string, baseDir: string): Promise<
46
46
  }
47
47
  return target;
48
48
  }
49
+
50
+ /** 人类可读的显示路径:cwd 内用 `./…`,home 内用 `~/…`,否则原样绝对路径。 */
51
+ export function formatDisplayPath(cwd: string, filePath: string): string {
52
+ const relToCwd = relative(cwd, filePath);
53
+ if (relToCwd !== "" && !relToCwd.startsWith("..") && !isAbsolute(relToCwd)) {
54
+ return `./${relToCwd}`;
55
+ }
56
+ const relToHome = relative(homedir(), filePath);
57
+ if (relToHome !== "" && !relToHome.startsWith("..") && !isAbsolute(relToHome)) {
58
+ return `~/${relToHome}`;
59
+ }
60
+ return filePath;
61
+ }