@pi-unipi/core 2.0.9 → 2.0.10

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/utils.ts +16 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/core",
3
- "version": "2.0.9",
3
+ "version": "2.0.10",
4
4
  "description": "Shared utilities, event types, and constants for Unipi extension suite",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -23,11 +23,11 @@
23
23
  "access": "public"
24
24
  },
25
25
  "peerDependencies": {
26
- "@earendil-works/pi-coding-agent": "^0.75.5",
26
+ "@earendil-works/pi-coding-agent": "^0.78.0",
27
27
  "typebox": "^1.1.38"
28
28
  },
29
29
  "devDependencies": {
30
- "@earendil-works/pi-coding-agent": "^0.75.5",
30
+ "@earendil-works/pi-coding-agent": "^0.78.0",
31
31
  "typebox": "^1.1.38",
32
32
  "@types/node": "^22.0.0"
33
33
  }
package/utils.ts CHANGED
@@ -148,12 +148,28 @@ export function getPackageVersion(packageDir: string): string {
148
148
  */
149
149
  export function findPackageRoot(startDir: string, packageName: string, maxSteps = 10): string | null {
150
150
  let dir = path.resolve(startDir);
151
+ const visited = new Set<string>();
152
+
151
153
  for (let i = 0; i < maxSteps; i++) {
154
+ visited.add(dir);
152
155
  const pkgPath = path.join(dir, "package.json");
153
156
  const pkg = readJson<{ name?: string }>(pkgPath);
154
157
  if (pkg?.name === packageName) {
155
158
  return dir;
156
159
  }
160
+
161
+ const nodeModulesIndex = dir.lastIndexOf(`${path.sep}node_modules${path.sep}`);
162
+ if (nodeModulesIndex >= 0) {
163
+ const nodeModulesDir = dir.slice(0, nodeModulesIndex + `${path.sep}node_modules`.length);
164
+ const siblingPackageDir = path.join(nodeModulesDir, packageName);
165
+ if (!visited.has(siblingPackageDir)) {
166
+ const siblingPkg = readJson<{ name?: string }>(path.join(siblingPackageDir, "package.json"));
167
+ if (siblingPkg?.name === packageName) {
168
+ return siblingPackageDir;
169
+ }
170
+ }
171
+ }
172
+
157
173
  const parent = path.dirname(dir);
158
174
  if (parent === dir) break; // filesystem root
159
175
  dir = parent;