pi-anycopy 0.2.7 → 0.3.1
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 +8 -3
- package/extensions/anycopy/index.ts +20 -48
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# anycopy for Pi (`pi-anycopy`)
|
|
2
2
|
|
|
3
|
-
This extension mirrors all the behaviors of Pi's native `/tree` while adding a live, syntax-highlighting preview of each node's content, the ability to copy any node(s) to the clipboard, and optional
|
|
3
|
+
This extension mirrors all the behaviors of Pi's native `/tree` while adding a live, syntax-highlighting preview of each node's content, the ability to copy any node(s) to the clipboard, and optional node creation timestamps.
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<img width="450" alt="anycopy demo" src="https://raw.githubusercontent.com/w-winter/dot314/main/assets/anycopy-demo.gif" />
|
|
@@ -52,6 +52,7 @@ Defaults (customizable in `config.json`):
|
|
|
52
52
|
| `Shift+X` | Clear selection |
|
|
53
53
|
| `Shift+L` | Label node (native tree behavior) |
|
|
54
54
|
| `Shift+T` | Toggle label timestamps for labeled nodes |
|
|
55
|
+
| `Shift+Ctrl+T` | Toggle node creation timestamps |
|
|
55
56
|
| `Shift+Up` / `Shift+Down` | Scroll node preview by line |
|
|
56
57
|
| `Shift+PageUp` / `Shift+PageDown` | Page through node preview |
|
|
57
58
|
| `Esc` | Close |
|
|
@@ -68,7 +69,10 @@ Notes:
|
|
|
68
69
|
- `Shift+A`/`Shift+C` multi-select copy behavior is unchanged by navigation support, while plain space remains available for search queries
|
|
69
70
|
- `Shift+T` is configurable via `keys.toggleLabelTimestamps` in `config.json`
|
|
70
71
|
- `Shift+T` shows timestamps for labeled nodes only, using the latest label-change time for each label
|
|
71
|
-
-
|
|
72
|
+
- `Shift+Ctrl+T` is configurable via `keys.toggleEntryTimestamps` in `config.json`
|
|
73
|
+
- `Shift+Ctrl+T` shows each node's creation time right-aligned at the far right of each visible tree row
|
|
74
|
+
- Nodes without a creation time show no timestamp
|
|
75
|
+
- Timestamps use a compact format: same-day `HH:MM`, same-year `M/D HH:MM`, cross-year `YY/M/D HH:MM`
|
|
72
76
|
- Label edits are persisted via `pi.setLabel(...)`
|
|
73
77
|
- [Folded](https://github.com/badlogic/pi-mono/blob/09e9de5749193beab234f30ed220a77f3d91cfad/packages/coding-agent/docs/tree.md#controls) branches are persisted by default in hidden `/anycopy` session entries, so closing/reopening `/anycopy`, switching to a sibling branch, or revisiting the session later restores the same folded view until you explicitly unfold it again
|
|
74
78
|
- Search and filter changes still reset the live overlay's fold state temporarily; reopening `/anycopy` restores the persisted folded branches
|
|
@@ -80,7 +84,7 @@ Edit `~/.pi/agent/extensions/anycopy/config.json`:
|
|
|
80
84
|
- `treeFilterMode`: initial tree filter mode when opening `/anycopy`; defaults to `default` to match `/tree`
|
|
81
85
|
- one of: `default` | `no-tools` | `user-only` | `labeled-only` | `all`
|
|
82
86
|
- `persistFoldState`: whether `/anycopy` persists folded branches across reopenings and later sessions; defaults to `true`; when disabled, `/anycopy` does not read or write hidden fold-state session entries
|
|
83
|
-
- `keys`: keybindings used inside the `/anycopy` overlay for copy/preview actions
|
|
87
|
+
- `keys`: keybindings used inside the `/anycopy` overlay for copy/preview actions and the creation timestamp toggle
|
|
84
88
|
|
|
85
89
|
```json
|
|
86
90
|
{
|
|
@@ -91,6 +95,7 @@ Edit `~/.pi/agent/extensions/anycopy/config.json`:
|
|
|
91
95
|
"copy": "shift+c",
|
|
92
96
|
"clear": "shift+x",
|
|
93
97
|
"toggleLabelTimestamps": "shift+t",
|
|
98
|
+
"toggleEntryTimestamps": "shift+ctrl+t",
|
|
94
99
|
"scrollUp": "shift+up",
|
|
95
100
|
"scrollDown": "shift+down",
|
|
96
101
|
"pageUp": "shift+pageup",
|
|
@@ -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.1",
|
|
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",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
{ "from": "../../extensions/anycopy/index.ts", "to": "extensions/anycopy/index.ts" },
|
|
31
31
|
{ "from": "../../extensions/anycopy/enter-navigation.ts", "to": "extensions/anycopy/enter-navigation.ts" },
|
|
32
32
|
{ "from": "../../extensions/anycopy/fold-state.ts", "to": "extensions/anycopy/fold-state.ts" },
|
|
33
|
+
{ "from": "../../extensions/anycopy/timestamps.ts", "to": "extensions/anycopy/timestamps.ts" },
|
|
33
34
|
{ "from": "../../extensions/anycopy/config.json", "to": "extensions/anycopy/config.json" },
|
|
34
35
|
{ "from": "../../LICENSE", "to": "LICENSE" }
|
|
35
36
|
],
|