happyskills 0.4.0 → 0.4.3

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/CHANGELOG.md CHANGED
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.4.3] - 2026-03-05
11
+
12
+ ### Fixed
13
+ - Fix `find_project_root()` still treating the home directory as a project root via `~/skills-lock.json`; the home directory is now fully excluded from all project root detection checks
14
+
15
+ ## [0.4.2] - 2026-03-05
16
+
17
+ ### Fixed
18
+ - Fix `list`, `install`, `uninstall`, `update`, `setup`, and `convert` incorrectly treating the home directory as a project root when `~/.claude/skills/` exists; `find_project_root()` now excludes the global skills directory from its upward search
19
+
20
+ ## [0.4.1] - 2026-03-05
21
+
22
+ ### Fixed
23
+ - Fix `setup` command still installing globally on npm-published v0.4.0 (re-release of the project-level default and `-g` flag)
24
+
10
25
  ## [0.4.0] - 2026-03-05
11
26
 
12
27
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "happyskills",
3
- "version": "0.4.0",
3
+ "version": "0.4.3",
4
4
  "description": "Package manager for AI agent skills",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Nicolas Dao <nic@cloudlesslabs.com> (https://cloudlesslabs.com)",
@@ -37,16 +37,21 @@ const skill_install_dir = (base_skills_dir, name) => path.join(base_skills_dir,
37
37
  const find_project_root = (start_dir = process.cwd()) => {
38
38
  let dir = path.resolve(start_dir)
39
39
  while (true) {
40
- const skills = path.join(dir, '.claude', 'skills')
41
- const lock = path.join(dir, 'skills-lock.json')
42
- try {
43
- fs.statSync(skills)
44
- return dir
45
- } catch {}
46
- try {
47
- fs.statSync(lock)
48
- return dir
49
- } catch {}
40
+ // Never treat the home directory as a project root —
41
+ // ~/.claude/skills is the global skills dir, not a project,
42
+ // and ~/skills-lock.json is an artifact of old buggy behaviour.
43
+ if (dir !== home_dir) {
44
+ const skills = path.join(dir, '.claude', 'skills')
45
+ const lock = path.join(dir, 'skills-lock.json')
46
+ try {
47
+ fs.statSync(skills)
48
+ return dir
49
+ } catch {}
50
+ try {
51
+ fs.statSync(lock)
52
+ return dir
53
+ } catch {}
54
+ }
50
55
  const parent = path.dirname(dir)
51
56
  if (parent === dir) break
52
57
  dir = parent
@@ -1,5 +1,6 @@
1
1
  const { describe, it, beforeEach, afterEach } = require('node:test')
2
2
  const assert = require('node:assert')
3
+ const fs = require('fs')
3
4
  const path = require('path')
4
5
  const os = require('os')
5
6
 
@@ -97,4 +98,79 @@ describe('paths', () => {
97
98
  assert.strictEqual(result, path.join('/base/skills', '.install.lock'))
98
99
  })
99
100
  })
101
+
102
+ describe('find_project_root', () => {
103
+ it('finds project root by .claude/skills dir', () => {
104
+ const tmp = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'hs-test-')))
105
+ try {
106
+ fs.mkdirSync(path.join(tmp, '.claude', 'skills'), { recursive: true })
107
+ assert.strictEqual(paths.find_project_root(tmp), tmp)
108
+ } finally {
109
+ fs.rmSync(tmp, { recursive: true })
110
+ }
111
+ })
112
+
113
+ it('finds project root by skills-lock.json', () => {
114
+ const tmp = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'hs-test-')))
115
+ try {
116
+ fs.writeFileSync(path.join(tmp, 'skills-lock.json'), '{}')
117
+ assert.strictEqual(paths.find_project_root(tmp), tmp)
118
+ } finally {
119
+ fs.rmSync(tmp, { recursive: true })
120
+ }
121
+ })
122
+
123
+ it('walks up to find project root from nested dir', () => {
124
+ const tmp = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'hs-test-')))
125
+ try {
126
+ fs.mkdirSync(path.join(tmp, '.claude', 'skills'), { recursive: true })
127
+ const sub = path.join(tmp, 'src', 'deep')
128
+ fs.mkdirSync(sub, { recursive: true })
129
+ assert.strictEqual(paths.find_project_root(sub), tmp)
130
+ } finally {
131
+ fs.rmSync(tmp, { recursive: true })
132
+ }
133
+ })
134
+
135
+ it('falls back to start_dir when no project markers found', () => {
136
+ const tmp = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'hs-test-')))
137
+ try {
138
+ const sub = path.join(tmp, 'sub')
139
+ fs.mkdirSync(sub, { recursive: true })
140
+ assert.strictEqual(paths.find_project_root(sub), sub)
141
+ } finally {
142
+ fs.rmSync(tmp, { recursive: true })
143
+ }
144
+ })
145
+
146
+ it('does not treat ~/.claude/skills as a project marker', () => {
147
+ const global_skills = path.join(os.homedir(), '.claude', 'skills')
148
+ let global_exists = false
149
+ try { fs.statSync(global_skills); global_exists = true } catch {}
150
+ if (!global_exists) return // skip if global dir not present on this machine
151
+
152
+ const tmp = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'hs-test-')))
153
+ try {
154
+ // tmp has no project markers — should fall back to tmp, not home dir
155
+ assert.strictEqual(paths.find_project_root(tmp), tmp)
156
+ } finally {
157
+ fs.rmSync(tmp, { recursive: true })
158
+ }
159
+ })
160
+
161
+ it('does not treat ~/skills-lock.json as a project marker', () => {
162
+ // The home directory itself must never be returned as project root,
163
+ // even if a stale skills-lock.json exists there from old buggy behaviour.
164
+ // We verify this by running from a temp dir that has no project markers
165
+ // of its own — the result must be the temp dir, not the home dir.
166
+ const tmp = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'hs-test-')))
167
+ try {
168
+ const result = paths.find_project_root(tmp)
169
+ assert.notStrictEqual(result, os.homedir())
170
+ assert.strictEqual(result, tmp)
171
+ } finally {
172
+ fs.rmSync(tmp, { recursive: true })
173
+ }
174
+ })
175
+ })
100
176
  })