@henryqw/pi-add-dir 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 CHANGED
@@ -1,14 +1,9 @@
1
1
  # `@henryqw/pi-add-dir`
2
2
 
3
- Give the current Pi session context, skills, and searchable files from directories outside the current workspace.
3
+ Give the current Pi session context, skills, and searchable files from directories outside the workspace. Reuse those resources in place without copying or linking their directories.
4
4
 
5
5
  ![Pi using added external directories by name](./example.png)
6
6
 
7
- ## Why
8
-
9
- - **Created for**: Pi users who keep reusable instructions or skills outside one repository.
10
- - **Advantage**: Use those resources in place, without copying or linking their directories.
11
-
12
7
  ## Install
13
8
 
14
9
  ```bash
@@ -35,8 +30,10 @@ Added directories give Pi these resources:
35
30
 
36
31
  `/dir-add` reloads when it finds skills. `add_directory` reports when a reload is needed.
37
32
 
38
- Search supports basename and relative-path globs. It skips `.git` and `node_modules`. It uses Node filesystem traversal and returns at most 1,000 results per call.
39
-
40
- ## State
33
+ ## State and storage
41
34
 
42
35
  Pi session entry `add-dir:state` stores added directories. It is package-managed; do not edit it. Tree navigation restores the active branch's directories and reloads resources when that set changes.
36
+
37
+ ## Limits and recovery
38
+
39
+ Search supports basename and relative-path globs. It skips `.git` and `node_modules`. It uses Node filesystem traversal and returns at most 1,000 results per call.
@@ -1,5 +1,5 @@
1
1
  import { readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
2
- import { glob } from "node:fs/promises";
2
+ import { readdir } from "node:fs/promises";
3
3
  import { homedir } from "node:os";
4
4
  import * as path from "node:path";
5
5
 
@@ -152,20 +152,35 @@ export async function findFiles(
152
152
  const matchPath = normalizedPattern.includes(path.sep);
153
153
  const results: string[] = [];
154
154
 
155
- signal?.throwIfAborted();
156
- for await (const entry of glob("**/@(*|.*)", {
157
- cwd: root,
158
- withFileTypes: true,
159
- exclude: (entry) => entry.isSymbolicLink() || (entry.isDirectory() && SKIPPED_SEARCH_DIRS.has(entry.name)),
160
- })) {
155
+ const directories = [root];
156
+ while (directories.length > 0) {
161
157
  signal?.throwIfAborted();
162
- if (!entry.isFile()) continue;
158
+ const dir = directories.pop()!;
159
+ let entries;
160
+ try {
161
+ entries = await readdir(dir, { withFileTypes: true });
162
+ } catch (error) {
163
+ signal?.throwIfAborted();
164
+ if (!isMissingPathError(error)) throw error;
165
+ continue;
166
+ }
167
+ signal?.throwIfAborted();
168
+ for (const entry of entries) {
169
+ signal?.throwIfAborted();
170
+ if (entry.isSymbolicLink()) continue;
171
+
172
+ const fullPath = path.join(dir, entry.name);
173
+ if (entry.isDirectory()) {
174
+ if (!SKIPPED_SEARCH_DIRS.has(entry.name)) directories.push(fullPath);
175
+ continue;
176
+ }
177
+ if (!entry.isFile()) continue;
163
178
 
164
- const fullPath = path.join(entry.parentPath, entry.name);
165
- const candidate = matchPath ? path.relative(root, fullPath) : entry.name;
166
- if (!path.matchesGlob(candidate, normalizedPattern)) continue;
167
- results.push(fullPath);
168
- if (results.length >= maxResults) return results;
179
+ const candidate = matchPath ? path.relative(root, fullPath) : entry.name;
180
+ if (!path.matchesGlob(candidate, normalizedPattern)) continue;
181
+ results.push(fullPath);
182
+ if (results.length >= maxResults) return results;
183
+ }
169
184
  }
170
185
 
171
186
  return results;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henryqw/pi-add-dir",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Add external directories to a Pi session with context, skills, and file search.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -25,8 +25,8 @@
25
25
  "pack:check": "npm pack --dry-run"
26
26
  },
27
27
  "peerDependencies": {
28
- "@earendil-works/pi-coding-agent": "^0.85.0",
29
- "@earendil-works/pi-tui": "^0.85.0",
28
+ "@earendil-works/pi-coding-agent": "^0.85.1",
29
+ "@earendil-works/pi-tui": "^0.85.1",
30
30
  "typebox": "^1.3.15"
31
31
  },
32
32
  "repository": {