@comfanion/workflow 4.9.0 → 4.10.0

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/bin/cli.js CHANGED
@@ -235,13 +235,41 @@ program
235
235
  const spinner = ora('Initializing OpenCode Workflow...').start();
236
236
 
237
237
  try {
238
- // If updating, create backup and remove old directory
238
+ // If updating, preserve vectorizer and indexes
239
+ const vectorizerDir = path.join(targetDir, 'vectorizer');
240
+ const vectorsDir = path.join(targetDir, 'vectors');
241
+ const vectorizerNodeModules = path.join(vectorizerDir, 'node_modules');
242
+ const tempNodeModules = path.join(process.cwd(), '.vectorizer-node_modules-temp');
243
+ const tempVectors = path.join(process.cwd(), '.vectors-temp');
244
+
245
+ let hadVectorizer = false;
246
+ let hadVectors = false;
247
+
239
248
  if (await fs.pathExists(targetDir)) {
240
249
  const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
241
250
  const backupDir = path.join(process.cwd(), `.opencode.backup-${timestamp}`);
242
251
 
252
+ // Check what we need to preserve
253
+ hadVectorizer = await fs.pathExists(vectorizerNodeModules);
254
+ hadVectors = await fs.pathExists(vectorsDir);
255
+
256
+ // Preserve vectorizer node_modules (100MB+, don't backup)
257
+ if (hadVectorizer) {
258
+ spinner.text = 'Preserving vectorizer dependencies...';
259
+ await fs.move(vectorizerNodeModules, tempNodeModules, { overwrite: true });
260
+ }
261
+
262
+ // Preserve vector indexes
263
+ if (hadVectors) {
264
+ spinner.text = 'Preserving vector indexes...';
265
+ await fs.move(vectorsDir, tempVectors, { overwrite: true });
266
+ }
267
+
268
+ // Create backup (without node_modules and vectors)
243
269
  spinner.text = 'Creating backup...';
244
- await fs.copy(targetDir, backupDir);
270
+ await fs.copy(targetDir, backupDir, {
271
+ filter: (src) => !src.includes('node_modules') && !src.includes('vectors')
272
+ });
245
273
 
246
274
  spinner.text = 'Removing old .opencode/...';
247
275
  await fs.remove(targetDir);
@@ -254,6 +282,27 @@ program
254
282
  // Copy .opencode structure (fresh, no old files)
255
283
  await fs.copy(OPENCODE_SRC, targetDir);
256
284
 
285
+ // Copy updated vectorizer source files
286
+ if (await fs.pathExists(VECTORIZER_SRC)) {
287
+ spinner.text = 'Updating vectorizer...';
288
+ const newVectorizerDir = path.join(targetDir, 'vectorizer');
289
+ await fs.ensureDir(newVectorizerDir);
290
+ await fs.copy(path.join(VECTORIZER_SRC, 'index.js'), path.join(newVectorizerDir, 'index.js'));
291
+ await fs.copy(path.join(VECTORIZER_SRC, 'package.json'), path.join(newVectorizerDir, 'package.json'));
292
+ }
293
+
294
+ // Restore vectorizer node_modules
295
+ if (hadVectorizer) {
296
+ spinner.text = 'Restoring vectorizer dependencies...';
297
+ await fs.move(tempNodeModules, path.join(targetDir, 'vectorizer', 'node_modules'), { overwrite: true });
298
+ }
299
+
300
+ // Restore vector indexes
301
+ if (hadVectors) {
302
+ spinner.text = 'Restoring vector indexes...';
303
+ await fs.move(tempVectors, path.join(targetDir, 'vectors'), { overwrite: true });
304
+ }
305
+
257
306
  // Update config.yaml with user values
258
307
  spinner.text = 'Configuring...';
259
308
  const configPath = path.join(targetDir, 'config.yaml');
@@ -332,8 +381,16 @@ program
332
381
 
333
382
  spinner.succeed(chalk.green('OpenCode Workflow initialized!'));
334
383
 
335
- // Install vectorizer if requested
336
- if (config.install_vectorizer) {
384
+ // Show what was preserved
385
+ if (hadVectorizer) {
386
+ console.log(chalk.green('✅ Vectorizer updated (dependencies preserved)'));
387
+ }
388
+ if (hadVectors) {
389
+ console.log(chalk.green('✅ Vector indexes preserved'));
390
+ }
391
+
392
+ // Install vectorizer if requested (and not already installed)
393
+ if (config.install_vectorizer && !hadVectorizer) {
337
394
  await installVectorizer(targetDir);
338
395
  }
339
396
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comfanion/workflow",
3
- "version": "4.9.0",
3
+ "version": "4.10.0",
4
4
  "description": "Initialize OpenCode Workflow system for AI-assisted development with semantic code search",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": "3.0.0",
3
- "buildDate": "2026-01-24T09:33:58.989Z",
3
+ "buildDate": "2026-01-24T09:51:33.276Z",
4
4
  "files": [
5
5
  "config.yaml",
6
6
  "FLOW.yaml",
@@ -119,8 +119,14 @@ permission:
119
119
  </prefer-lsp-when>
120
120
  </lsp-exploration>
121
121
 
122
- <codesearch-exploration hint="Semantic search with MULTI-INDEX support">
123
- <check>codeindex({ action: "list" }) → See all indexes. If none, suggest: npx opencode-workflow index --index code</check>
122
+ <codesearch-exploration hint="ALWAYS TRY SEMANTIC SEARCH FIRST">
123
+ <critical>
124
+ BEFORE using grep/glob, ALWAYS check: codeindex({ action: "list" })
125
+ If indexes exist → USE codesearch instead of grep!
126
+ codesearch returns 5-10 relevant files vs 100+ grep matches
127
+ </critical>
128
+
129
+ <first-step>codeindex({ action: "list" }) → Check if indexes exist</first-step>
124
130
 
125
131
  <indexes hint="Different indexes for different content types">
126
132
  <index name="code">Source code (*.go, *.ts, *.py) - functions, classes, logic</index>
@@ -175,14 +181,22 @@ permission:
175
181
  - Regex pattern matching needed
176
182
  </use-grep-when>
177
183
 
178
- <exploration-strategy>
179
- 1. codeindex({ action: "list" }) → Check what indexes exist
180
- 2. codesearch({ query: "high-level concept", index: "code" }) → Find relevant code areas
181
- 3. codesearch({ query: "explanation", index: "docs" }) → Find related documentation
182
- 4. Read top results to understand structure
183
- 5. lsp documentSymbol on key files → Get detailed structure
184
- 6. grep for specific patterns if needed
184
+ <exploration-strategy priority="MANDATORY">
185
+ 1. FIRST: codeindex({ action: "list" }) → Check what indexes exist
186
+ 2. IF indexes exist:
187
+ - codesearch({ query: "concept", index: "code" }) → 5-10 relevant files (NOT 100+ grep matches!)
188
+ - Read top 3-5 results
189
+ - Done! Much faster than grep
190
+ 3. IF no indexes:
191
+ - Suggest: "Index not found. Create with: codeindex({ action: 'reindex', index: 'code' })"
192
+ - Fall back to grep/glob
193
+ 4. Use grep ONLY for exact string matches (function names, imports)
185
194
  </exploration-strategy>
195
+
196
+ <efficiency-comparison>
197
+ BAD: grep "category.*mapping" → 100 matches → read 20 files → slow!
198
+ GOOD: codesearch({ query: "category mapping logic" }) → 5 files → fast!
199
+ </efficiency-comparison>
186
200
  </codesearch-exploration>
187
201
 
188
202
  </agent>