obsidian-dev-skills 1.0.6 → 1.0.8

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 +50 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "obsidian-dev-skills",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Agent skills for Obsidian plugin and theme development",
5
5
  "keywords": [
6
6
  "obsidian",
package/scripts/init.mjs CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import fs from 'fs';
4
4
  import path from 'path';
5
+ import readline from 'readline';
5
6
  import { fileURLToPath } from 'url';
6
7
 
7
8
  const __filename = fileURLToPath(import.meta.url);
@@ -109,6 +110,47 @@ function detectProjectType(root) {
109
110
  return isPlugin ? 'plugin' : 'theme';
110
111
  }
111
112
 
113
+ /**
114
+ * Asks the user to select a project type if it's ambiguous.
115
+ * @returns {Promise<'plugin' | 'theme' | 'both'>}
116
+ */
117
+ function askProjectType() {
118
+ return new Promise((resolve) => {
119
+ if (!process.stdin.isTTY) {
120
+ resolve('both');
121
+ return;
122
+ }
123
+
124
+ const rl = readline.createInterface({
125
+ input: process.stdin,
126
+ output: process.stdout
127
+ });
128
+
129
+ console.log('\nā“ The project type is not immediately clear.');
130
+ console.log('Is this an Obsidian plugin project, a theme project, or both?');
131
+ console.log('Choices: [p]lugin, [t]heme, [b]oth (default)');
132
+
133
+ const handleAnswer = (answer) => {
134
+ const cleanAnswer = answer.trim().toLowerCase();
135
+ if (cleanAnswer === 'p' || cleanAnswer === 'plugin') {
136
+ rl.close();
137
+ resolve('plugin');
138
+ } else if (cleanAnswer === 't' || cleanAnswer === 'theme') {
139
+ rl.close();
140
+ resolve('theme');
141
+ } else if (cleanAnswer === 'b' || cleanAnswer === 'both' || cleanAnswer === '') {
142
+ rl.close();
143
+ resolve('both');
144
+ } else {
145
+ console.log('Invalid choice. Please enter p, t, or b.');
146
+ rl.question('> ', handleAnswer);
147
+ }
148
+ };
149
+
150
+ rl.question('> ', handleAnswer);
151
+ });
152
+ }
153
+
112
154
  /**
113
155
  * Updates AGENTS.md in the project root to include the installed skills in the openskills format.
114
156
  */
@@ -261,9 +303,7 @@ Example:
261
303
 
262
304
  async function init() {
263
305
  // Determine if we are running in the package's own directory (development)
264
- const isDevelopment = projectRoot === packageRoot ||
265
- (fs.existsSync(path.join(packageRoot, 'obsidian-dev')) &&
266
- !fs.existsSync(path.join(projectRoot, 'node_modules', 'obsidian-dev-skills')));
306
+ const isDevelopment = projectRoot === packageRoot;
267
307
 
268
308
  if (isDevelopment && !process.env.FORCE_INIT) {
269
309
  console.log('šŸ› ļø Development mode detected (or forced skip), skipping initialization.');
@@ -272,8 +312,13 @@ async function init() {
272
312
 
273
313
  console.log(`šŸš€ Initializing Obsidian Dev Skills in: ${projectRoot}`);
274
314
  try {
275
- const projectType = detectProjectType(projectRoot);
276
- console.log(`šŸ” Detected project type: ${projectType}`);
315
+ let projectType = detectProjectType(projectRoot);
316
+
317
+ if (projectType === 'both' && process.stdin.isTTY) {
318
+ projectType = await askProjectType();
319
+ }
320
+
321
+ console.log(`šŸ” Using project type: ${projectType}`);
277
322
 
278
323
  // Create .agent/skills directory if it doesn't exist
279
324
  if (!fs.existsSync(skillsDir)) {