@oh-my-pi/pi-utils 14.7.0 → 14.7.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/dirs.ts +25 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-utils",
4
- "version": "14.7.0",
4
+ "version": "14.7.2",
5
5
  "description": "Shared utilities for pi packages",
6
6
  "homepage": "https://github.com/can1357/oh-my-pi",
7
7
  "author": "Can Boluk",
@@ -37,8 +37,8 @@
37
37
  "winston-daily-rotate-file": "^5.0.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@types/bun": "^1.3",
41
- "@oh-my-pi/pi-natives": "14.7.0"
40
+ "@types/bun": "^1.3.13",
41
+ "@oh-my-pi/pi-natives": "14.7.2"
42
42
  },
43
43
  "engines": {
44
44
  "bun": ">=1.3.7"
package/src/dirs.ts CHANGED
@@ -192,6 +192,12 @@ class DirResolver {
192
192
 
193
193
  let dirs = new DirResolver(process.env.PI_CODING_AGENT_DIR);
194
194
 
195
+ // Anchor home for the resolver. Captured at module load to stay stable across
196
+ // test mocks of `os.homedir()`. `getPluginsDir(home)` compares against this so
197
+ // production callers (`home === RESOLVER_HOME`) hit the XDG-aware resolver while
198
+ // tests passing a temp HOME short-circuit to a deterministic path.
199
+ const RESOLVER_HOME = os.homedir();
200
+
195
201
  // =============================================================================
196
202
  // Root directories
197
203
  // =============================================================================
@@ -236,8 +242,20 @@ export function getLogPath(date = new Date()): string {
236
242
  return path.join(getLogsDir(), `${APP_NAME}.${date.toISOString().slice(0, 10)}.log`);
237
243
  }
238
244
 
239
- /** Get the plugins directory (~/.omp/plugins). */
240
- export function getPluginsDir(): string {
245
+ /**
246
+ * Get the plugins directory (~/.omp/plugins or its XDG equivalent).
247
+ *
248
+ * No-arg form (production callers) goes through the XDG-aware DirResolver so
249
+ * reads and writes always agree. The optional `home` parameter is for test
250
+ * isolation: when it differs from `os.homedir()` it short-circuits the resolver
251
+ * and returns `<home>/<configDir>/plugins` so tests with a temp HOME get a
252
+ * deterministic path. Passing `os.homedir()` explicitly is identical to the
253
+ * no-arg form — XDG semantics are preserved.
254
+ */
255
+ export function getPluginsDir(home?: string): string {
256
+ if (home !== undefined && home !== RESOLVER_HOME) {
257
+ return path.join(home, getConfigDirName(), "plugins");
258
+ }
241
259
  return dirs.rootSubdir("plugins", "data");
242
260
  }
243
261
 
@@ -281,6 +299,11 @@ export function getPythonEnvDir(): string {
281
299
  return dirs.rootSubdir("python-env", "data");
282
300
  }
283
301
 
302
+ /** Get the shared Python gateway state directory (~/.omp/agent/python-gateway; XDG default: $XDG_STATE_HOME/omp/python-gateway). */
303
+ export function getPythonGatewayDir(): string {
304
+ return dirs.agentSubdir(undefined, "python-gateway", "state");
305
+ }
306
+
284
307
  /** Get the puppeteer sandbox directory (~/.omp/puppeteer). */
285
308
  export function getPuppeteerDir(): string {
286
309
  return dirs.rootSubdir("puppeteer", "cache");