@henryqw/pi-open-in 1.0.0 → 1.0.2
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 +11 -3
- package/extensions/open.ts +7 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# `@henryqw/pi-open-in`
|
|
2
2
|
|
|
3
|
-
Open the current working directory
|
|
3
|
+
Open the current Pi working directory in your editor with one command. The default editor is VS Code.
|
|
4
4
|
|
|
5
5
|
## Why
|
|
6
6
|
|
|
7
|
-
- **Created for**:
|
|
8
|
-
- **Advantage**: `/open` works while the agent is busy and supports any simple editor command
|
|
7
|
+
- **Created for**: Pi users who move between terminal work and an editor.
|
|
8
|
+
- **Advantage**: `/open` works while the agent is busy and supports any simple editor command.
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
@@ -15,6 +15,10 @@ pi install npm:@henryqw/pi-open-in
|
|
|
15
15
|
|
|
16
16
|
## Use
|
|
17
17
|
|
|
18
|
+
Run `/open`. With default settings, VS Code opens the current working directory.
|
|
19
|
+
|
|
20
|
+
Run `/set-open-in` when you want another command.
|
|
21
|
+
|
|
18
22
|
| Surface | Type | Purpose |
|
|
19
23
|
| --- | --- | --- |
|
|
20
24
|
| `/open` | command | Run `<command> <current-working-directory>`. Works while the agent is busy. |
|
|
@@ -51,4 +55,8 @@ const { source, value } = loadOpenInConfig();
|
|
|
51
55
|
`source` is `"missing"` or `"file"`. `value.command` is validated.
|
|
52
56
|
Pass an agent directory to `loadOpenInConfig(agentDir)` when needed.
|
|
53
57
|
|
|
58
|
+
`configuredOpenUri(path)` returns a VS Code URI when the executable is `code`.
|
|
59
|
+
For `code -n` and `code --new-window`, it adds `windowId=_blank` so the link opens a new window.
|
|
60
|
+
It returns `undefined` for other commands or invalid config.
|
|
61
|
+
|
|
54
62
|
This extension owns command validation. `@henryqw/pi-config-store` owns the config home and storage.
|
package/extensions/open.ts
CHANGED
|
@@ -31,19 +31,23 @@ export function loadOpenInConfig(agentDir?: string): { source: "file" | "missing
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export function configuredOpenUri(path: string): string | undefined {
|
|
34
|
+
let args: string[];
|
|
34
35
|
try {
|
|
35
|
-
|
|
36
|
+
const [executable, ...commandArgs] = loadOpenInConfig().value.command.split(/\s+/);
|
|
37
|
+
if (executable !== "code") return undefined;
|
|
38
|
+
args = commandArgs;
|
|
36
39
|
} catch {
|
|
37
40
|
// Invalid config must not break footer render; just omit the URI.
|
|
38
41
|
return undefined;
|
|
39
42
|
}
|
|
43
|
+
const query = args.includes("-n") || args.includes("--new-window") ? "?windowId=_blank" : "";
|
|
40
44
|
if (path.startsWith("\\\\")) {
|
|
41
45
|
const [host, ...parts] = path.slice(2).split("\\");
|
|
42
46
|
const uri = new URL(`file://${host}`);
|
|
43
47
|
uri.pathname = `/${parts.join("/")}`;
|
|
44
|
-
return `vscode://file//${uri.host}${uri.pathname}`;
|
|
48
|
+
return `vscode://file//${uri.host}${uri.pathname}${query}`;
|
|
45
49
|
}
|
|
46
|
-
return `vscode://file${pathToFileURL(path).pathname}`;
|
|
50
|
+
return `vscode://file${pathToFileURL(path).pathname}${query}`;
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
export default function openInExtension(pi: ExtensionAPI): void {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@henryqw/pi-open-in",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Open the current Pi working directory with a configurable command.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
},
|
|
33
33
|
"repository": {
|
|
34
34
|
"type": "git",
|
|
35
|
-
"url": "git+https://github.com/HenryQW/pi-
|
|
36
|
-
"directory": "
|
|
35
|
+
"url": "git+https://github.com/HenryQW/pi-harness.git",
|
|
36
|
+
"directory": "extensions/pi-open-in"
|
|
37
37
|
},
|
|
38
38
|
"bugs": {
|
|
39
|
-
"url": "https://github.com/HenryQW/pi-
|
|
39
|
+
"url": "https://github.com/HenryQW/pi-harness/issues"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|