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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/init.mjs +35 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "obsidian-dev-skills",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Agent skills for Obsidian plugin and theme development",
5
5
  "keywords": [
6
6
  "obsidian",
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
- // The project root is where the user is running the command (usually their Obsidian project)
14
- const projectRoot = process.cwd();
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
- // Skip if we're running inside the obsidian-dev-skills repo itself (development)
48
- const pkgJsonPath = path.join(projectRoot, 'package.json');
49
- if (fs.existsSync(pkgJsonPath)) {
50
- try {
51
- const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
52
- if (pkg.name === 'obsidian-dev-skills' && projectRoot === packageRoot) {
53
- console.log('🛠️ Development mode detected, skipping initialization.');
54
- return;
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('🚀 Initializing Obsidian Dev Skills...');
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)) {