@cg3/equip 0.1.0 → 0.1.1

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/lib/rules.js +25 -7
  2. package/package.json +1 -1
package/lib/rules.js CHANGED
@@ -70,10 +70,20 @@ function installRules(platform, options) {
70
70
 
71
71
  if (!platform.rulesPath) return { action: "skipped" };
72
72
 
73
- // Determine actual file path — standalone file vs append
74
- const rulesPath = fileName
75
- ? path.join(platform.rulesPath, fileName)
76
- : platform.rulesPath;
73
+ // Determine actual file path — standalone file (directory-based) vs append (file-based)
74
+ // Only use fileName if rulesPath is a directory (or doesn't exist yet as a file)
75
+ let rulesPath;
76
+ if (fileName) {
77
+ try {
78
+ const stat = fs.statSync(platform.rulesPath);
79
+ rulesPath = stat.isDirectory() ? path.join(platform.rulesPath, fileName) : platform.rulesPath;
80
+ } catch {
81
+ // Path doesn't exist — check if it looks like a file (has extension) or directory
82
+ rulesPath = path.extname(platform.rulesPath) ? platform.rulesPath : path.join(platform.rulesPath, fileName);
83
+ }
84
+ } else {
85
+ rulesPath = platform.rulesPath;
86
+ }
77
87
 
78
88
  const { MARKER_RE, BLOCK_RE } = markerPatterns(marker);
79
89
 
@@ -120,9 +130,17 @@ function uninstallRules(platform, options) {
120
130
 
121
131
  if (!platform.rulesPath) return false;
122
132
 
123
- const rulesPath = fileName
124
- ? path.join(platform.rulesPath, fileName)
125
- : platform.rulesPath;
133
+ let rulesPath;
134
+ if (fileName) {
135
+ try {
136
+ const stat = fs.statSync(platform.rulesPath);
137
+ rulesPath = stat.isDirectory() ? path.join(platform.rulesPath, fileName) : platform.rulesPath;
138
+ } catch {
139
+ rulesPath = path.extname(platform.rulesPath) ? platform.rulesPath : path.join(platform.rulesPath, fileName);
140
+ }
141
+ } else {
142
+ rulesPath = platform.rulesPath;
143
+ }
126
144
 
127
145
  try {
128
146
  if (!fs.statSync(rulesPath).isFile()) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cg3/equip",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Universal MCP + behavioral rules installer for AI coding agents",
5
5
  "main": "index.js",
6
6
  "exports": {