pi-anycopy 0.2.6 → 0.3.0
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.
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
* Esc - close
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import type { ExtensionAPI, ExtensionCommandContext, SessionEntry } from "@
|
|
17
|
+
import type { ExtensionAPI, ExtensionCommandContext, SessionEntry } from "@earendil-works/pi-coding-agent";
|
|
18
18
|
import {
|
|
19
19
|
copyToClipboard,
|
|
20
20
|
getLanguageFromPath,
|
|
21
21
|
getMarkdownTheme,
|
|
22
22
|
highlightCode,
|
|
23
23
|
TreeSelectorComponent,
|
|
24
|
-
} from "@
|
|
24
|
+
} from "@earendil-works/pi-coding-agent";
|
|
25
25
|
|
|
26
|
-
import { getKeybindings, Markdown, matchesKey, truncateToWidth } from "@
|
|
27
|
-
import type { Focusable } from "@
|
|
26
|
+
import { getKeybindings, Markdown, matchesKey, truncateToWidth } from "@earendil-works/pi-tui";
|
|
27
|
+
import type { Focusable } from "@earendil-works/pi-tui";
|
|
28
28
|
|
|
29
29
|
import { existsSync, readFileSync } from "fs";
|
|
30
30
|
import { homedir } from "os";
|
|
@@ -113,12 +113,7 @@ const getAgentDir = (): string => process.env.PI_CODING_AGENT_DIR || join(homedi
|
|
|
113
113
|
|
|
114
114
|
const readJsonFile = <T>(path: string): T | undefined => {
|
|
115
115
|
if (!existsSync(path)) return undefined;
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
return JSON.parse(readFileSync(path, "utf8")) as T;
|
|
119
|
-
} catch {
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
116
|
+
return JSON.parse(readFileSync(path, "utf8")) as T;
|
|
122
117
|
};
|
|
123
118
|
|
|
124
119
|
const loadBranchSummarySkipPrompt = (cwd: string): boolean => {
|
|
@@ -133,7 +128,8 @@ const loadBranchSummarySkipPrompt = (cwd: string): boolean => {
|
|
|
133
128
|
|
|
134
129
|
const loadConfig = (): anycopyRuntimeConfig => {
|
|
135
130
|
const configPath = join(getExtensionDir(), "config.json");
|
|
136
|
-
|
|
131
|
+
const parsed = readJsonFile<anycopyConfig>(configPath);
|
|
132
|
+
if (!parsed) {
|
|
137
133
|
return {
|
|
138
134
|
keys: { ...DEFAULT_KEYS },
|
|
139
135
|
treeFilterMode: DEFAULT_TREE_FILTER_MODE,
|
|
@@ -141,43 +137,23 @@ const loadConfig = (): anycopyRuntimeConfig => {
|
|
|
141
137
|
};
|
|
142
138
|
}
|
|
143
139
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const treeFilterMode =
|
|
151
|
-
typeof treeFilterModeRaw === "string" && validTreeFilterModes.includes(treeFilterModeRaw as TreeFilterMode)
|
|
152
|
-
? (treeFilterModeRaw as TreeFilterMode)
|
|
153
|
-
: DEFAULT_TREE_FILTER_MODE;
|
|
154
|
-
const persistFoldState =
|
|
155
|
-
typeof parsed.persistFoldState === "boolean" ? parsed.persistFoldState : DEFAULT_PERSIST_FOLD_STATE;
|
|
156
|
-
|
|
157
|
-
return {
|
|
158
|
-
keys: {
|
|
159
|
-
toggleSelect: typeof keys.toggleSelect === "string" ? keys.toggleSelect : DEFAULT_KEYS.toggleSelect,
|
|
160
|
-
copy: typeof keys.copy === "string" ? keys.copy : DEFAULT_KEYS.copy,
|
|
161
|
-
clear: typeof keys.clear === "string" ? keys.clear : DEFAULT_KEYS.clear,
|
|
162
|
-
toggleLabelTimestamps:
|
|
163
|
-
typeof keys.toggleLabelTimestamps === "string"
|
|
164
|
-
? keys.toggleLabelTimestamps
|
|
165
|
-
: DEFAULT_KEYS.toggleLabelTimestamps,
|
|
166
|
-
scrollDown: typeof keys.scrollDown === "string" ? keys.scrollDown : DEFAULT_KEYS.scrollDown,
|
|
167
|
-
scrollUp: typeof keys.scrollUp === "string" ? keys.scrollUp : DEFAULT_KEYS.scrollUp,
|
|
168
|
-
pageDown: typeof keys.pageDown === "string" ? keys.pageDown : DEFAULT_KEYS.pageDown,
|
|
169
|
-
pageUp: typeof keys.pageUp === "string" ? keys.pageUp : DEFAULT_KEYS.pageUp,
|
|
170
|
-
},
|
|
171
|
-
treeFilterMode,
|
|
172
|
-
persistFoldState,
|
|
173
|
-
};
|
|
174
|
-
} catch {
|
|
175
|
-
return {
|
|
176
|
-
keys: { ...DEFAULT_KEYS },
|
|
177
|
-
treeFilterMode: DEFAULT_TREE_FILTER_MODE,
|
|
178
|
-
persistFoldState: DEFAULT_PERSIST_FOLD_STATE,
|
|
179
|
-
};
|
|
140
|
+
const keys: anycopyKeyConfig = { ...DEFAULT_KEYS };
|
|
141
|
+
if (parsed.keys) {
|
|
142
|
+
for (const key of Object.keys(DEFAULT_KEYS) as Array<keyof anycopyKeyConfig>) {
|
|
143
|
+
const value = parsed.keys[key];
|
|
144
|
+
if (typeof value === "string") keys[key] = value;
|
|
145
|
+
}
|
|
180
146
|
}
|
|
147
|
+
|
|
148
|
+
const validTreeFilterModes: TreeFilterMode[] = ["default", "no-tools", "user-only", "labeled-only", "all"];
|
|
149
|
+
const treeFilterMode =
|
|
150
|
+
typeof parsed.treeFilterMode === "string" && validTreeFilterModes.includes(parsed.treeFilterMode as TreeFilterMode)
|
|
151
|
+
? (parsed.treeFilterMode as TreeFilterMode)
|
|
152
|
+
: DEFAULT_TREE_FILTER_MODE;
|
|
153
|
+
const persistFoldState =
|
|
154
|
+
typeof parsed.persistFoldState === "boolean" ? parsed.persistFoldState : DEFAULT_PERSIST_FOLD_STATE;
|
|
155
|
+
|
|
156
|
+
return { keys, treeFilterMode, persistFoldState };
|
|
181
157
|
};
|
|
182
158
|
|
|
183
159
|
const formatKeyHint = (key: string): string => {
|
|
@@ -459,12 +435,8 @@ class anycopyOverlay implements Focusable {
|
|
|
459
435
|
this.selector.focused = value;
|
|
460
436
|
}
|
|
461
437
|
|
|
462
|
-
getTreeList(): anycopyTreeList {
|
|
463
|
-
return this.selector.getTreeList();
|
|
464
|
-
}
|
|
465
|
-
|
|
466
438
|
private getTreeListInternals(): anycopyTreeListInternals {
|
|
467
|
-
return getTreeListInternals(this.getTreeList());
|
|
439
|
+
return getTreeListInternals(this.selector.getTreeList());
|
|
468
440
|
}
|
|
469
441
|
|
|
470
442
|
handleInput(data: string): void {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-anycopy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Pi's /tree with a live syntax-highlighted preview, ability to copy any node(s) to the clipboard, and persistence of folded branches",
|
|
5
5
|
"keywords": ["pi-package", "pi", "pi-coding-agent"],
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"image": "https://raw.githubusercontent.com/w-winter/dot314/main/assets/anycopy-demo.gif"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
21
|
+
"@earendil-works/pi-coding-agent": "^0.74.0",
|
|
22
|
+
"@earendil-works/pi-tui": "*"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"prepack": "node ../../scripts/pi-package-prepack.mjs"
|