@goodandready/dsh-clinebot 0.6.29 → 0.6.31

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.
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { readFileSync, writeFileSync, renameSync, mkdirSync, existsSync, copyFileSync, readdirSync, unlinkSync } from 'node:fs'
9
- import { homedir } from 'node:os'
9
+ import { resolveDataPath, isSafeDataPath } from './path-safety.js'
10
10
  import path from 'node:path'
11
11
  import {
12
12
  latencyBucketIndex,
@@ -85,33 +85,8 @@ function localDateKey(date) {
85
85
  return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
86
86
  }
87
87
 
88
- /** Get active .dsh directory, respecting DSH_HOME and HOME. */
89
- function getDshHome() {
90
- if (process.env.DSH_HOME) return process.env.DSH_HOME
91
- const home = process.env.HOME || homedir()
92
- return path.join(home, '.dsh')
93
- }
94
-
95
88
  export function resolvePath(targetPath) {
96
- let unwrapGuard = 0
97
- while (unwrapGuard < 5 && targetPath) {
98
- if (typeof targetPath === 'function') {
99
- try { targetPath = targetPath() } catch { targetPath = ''; break }
100
- unwrapGuard += 1
101
- } else if (typeof targetPath === 'object' && typeof targetPath.get === 'function') {
102
- try { targetPath = targetPath.get() } catch { targetPath = ''; break }
103
- unwrapGuard += 1
104
- } else {
105
- break
106
- }
107
- }
108
- if (typeof targetPath !== 'string') targetPath = ''
109
- if (!targetPath) return path.join(getDshHome(), 'clinebot-stats.json')
110
- if (targetPath.startsWith('~/') || targetPath === '~') {
111
- const home = process.env.HOME || homedir()
112
- return path.join(home, targetPath.slice(1))
113
- }
114
- return path.resolve(targetPath)
89
+ return resolveDataPath(targetPath, 'clinebot-stats.json')
115
90
  }
116
91
 
117
92
  /**