obsidian-dev-skills 1.0.1 → 1.0.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.
- package/package.json +1 -1
- package/scripts/init.mjs +35 -14
package/package.json
CHANGED
package/scripts/init.mjs
CHANGED
|
@@ -10,8 +10,32 @@ const __dirname = path.dirname(__filename);
|
|
|
10
10
|
// The package root is one level up from scripts/
|
|
11
11
|
const packageRoot = path.join(__dirname, '..');
|
|
12
12
|
|
|
13
|
-
//
|
|
14
|
-
|
|
13
|
+
// Find the real project root where the package is being installed
|
|
14
|
+
function getProjectRoot() {
|
|
15
|
+
// INIT_CWD is set by npm/pnpm/yarn to the directory where the command was run
|
|
16
|
+
if (process.env.INIT_CWD) {
|
|
17
|
+
return process.env.INIT_CWD;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Fallback: traverse up from process.cwd() to find the first package.json
|
|
21
|
+
// that isn't the one in this package
|
|
22
|
+
let current = process.cwd();
|
|
23
|
+
while (current !== path.parse(current).root) {
|
|
24
|
+
const pkgPath = path.join(current, 'package.json');
|
|
25
|
+
if (fs.existsSync(pkgPath)) {
|
|
26
|
+
try {
|
|
27
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
28
|
+
if (pkg.name !== 'obsidian-dev-skills') {
|
|
29
|
+
return current;
|
|
30
|
+
}
|
|
31
|
+
} catch (e) {}
|
|
32
|
+
}
|
|
33
|
+
current = path.dirname(current);
|
|
34
|
+
}
|
|
35
|
+
return process.cwd();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const projectRoot = getProjectRoot();
|
|
15
39
|
|
|
16
40
|
let agentDir = path.join(projectRoot, '.agent');
|
|
17
41
|
// If .agents exists but .agent doesn't, use .agents
|
|
@@ -44,20 +68,17 @@ function copyRecursiveSync(src, dest) {
|
|
|
44
68
|
}
|
|
45
69
|
|
|
46
70
|
async function init() {
|
|
47
|
-
//
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
} catch (e) {}
|
|
71
|
+
// Determine if we are running in the package's own directory (development)
|
|
72
|
+
const isDevelopment = projectRoot === packageRoot ||
|
|
73
|
+
(fs.existsSync(path.join(packageRoot, 'obsidian-dev-plugins')) &&
|
|
74
|
+
!fs.existsSync(path.join(projectRoot, 'node_modules', 'obsidian-dev-skills')));
|
|
75
|
+
|
|
76
|
+
if (isDevelopment && !process.env.FORCE_INIT) {
|
|
77
|
+
console.log('🛠️ Development mode detected (or forced skip), skipping initialization.');
|
|
78
|
+
return;
|
|
57
79
|
}
|
|
58
80
|
|
|
59
|
-
console.log(
|
|
60
|
-
|
|
81
|
+
console.log(`🚀 Initializing Obsidian Dev Skills in: ${projectRoot}`);
|
|
61
82
|
try {
|
|
62
83
|
// Create .agent/skills directory if it doesn't exist
|
|
63
84
|
if (!fs.existsSync(skillsDir)) {
|