@rubytech/taskmaster 1.0.38 → 1.0.40

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.
@@ -1,4 +1,5 @@
1
1
  import { randomUUID } from "node:crypto";
2
+ import fsSync from "node:fs";
2
3
  import fs from "node:fs/promises";
3
4
  import path from "node:path";
4
5
  import chokidar from "chokidar";
@@ -323,7 +324,25 @@ export class MemoryIndexManager {
323
324
  maxEntries: params.settings.cache.maxEntries,
324
325
  };
325
326
  this.fts = { enabled: params.settings.query.hybrid.enabled, available: false };
326
- this.ensureSchema();
327
+ try {
328
+ this.ensureSchema();
329
+ }
330
+ catch (err) {
331
+ // Database is corrupted (e.g. orphaned FTS5 metadata blocking writes).
332
+ // Delete and rebuild from scratch.
333
+ const msg = err instanceof Error ? err.message : String(err);
334
+ log.warn(`schema init failed, rebuilding database: ${msg}`);
335
+ try {
336
+ this.db.close();
337
+ }
338
+ catch {
339
+ /* ignore */
340
+ }
341
+ const dbPath = resolveUserPath(this.settings.store.path);
342
+ this.removeIndexFilesSync(dbPath);
343
+ this.db = this.openDatabase();
344
+ this.ensureSchema();
345
+ }
327
346
  this.vector = {
328
347
  enabled: params.settings.store.vector.enabled,
329
348
  available: null,
@@ -848,6 +867,17 @@ export class MemoryIndexManager {
848
867
  const suffixes = ["", "-wal", "-shm"];
849
868
  await Promise.all(suffixes.map((suffix) => fs.rm(`${basePath}${suffix}`, { force: true })));
850
869
  }
870
+ removeIndexFilesSync(basePath) {
871
+ const suffixes = ["", "-wal", "-shm"];
872
+ for (const suffix of suffixes) {
873
+ try {
874
+ fsSync.rmSync(`${basePath}${suffix}`, { force: true });
875
+ }
876
+ catch {
877
+ /* ignore */
878
+ }
879
+ }
880
+ }
851
881
  ensureSchema() {
852
882
  const result = ensureMemoryIndexSchema({
853
883
  db: this.db,
@@ -1337,8 +1367,12 @@ export class MemoryIndexManager {
1337
1367
  const shouldSyncMemory = this.sources.has("memory") && (params?.force || needsFullReindex || this.dirty);
1338
1368
  const shouldSyncSessions = this.shouldSyncSessions(params, needsFullReindex);
1339
1369
  if (shouldSyncMemory) {
1340
- await this.syncMemoryFiles({ needsFullReindex, progress: progress ?? undefined });
1341
- this.dirty = false;
1370
+ try {
1371
+ await this.syncMemoryFiles({ needsFullReindex, progress: progress ?? undefined });
1372
+ }
1373
+ finally {
1374
+ this.dirty = false;
1375
+ }
1342
1376
  }
1343
1377
  if (shouldSyncSessions) {
1344
1378
  await this.syncSessionFiles({ needsFullReindex, progress: progress ?? undefined });
@@ -64,6 +64,9 @@ export function ensureMemoryIndexSchema(params) {
64
64
  // Leaving them in the DB can cause "no such module: fts5" errors on
65
65
  // unrelated operations if SQLite touches the virtual table machinery.
66
66
  dropOrphanedFtsTables(params.db, params.ftsTable);
67
+ // Verify the database is still writable after cleanup. FTS5 virtual table
68
+ // metadata left in sqlite_master can corrupt the database for all writes.
69
+ verifyWritable(params.db);
67
70
  }
68
71
  }
69
72
  ensureColumn(params.db, "files", "source", "TEXT NOT NULL DEFAULT 'memory'");
@@ -72,6 +75,21 @@ export function ensureMemoryIndexSchema(params) {
72
75
  params.db.exec(`CREATE INDEX IF NOT EXISTS idx_chunks_source ON chunks(source);`);
73
76
  return { ftsAvailable, ...(ftsError ? { ftsError } : {}) };
74
77
  }
78
+ /**
79
+ * Verify the database is writable by performing a test write.
80
+ * If FTS5 cleanup left orphaned virtual table metadata in sqlite_master,
81
+ * SQLite may refuse all writes. Throws so the caller can delete and rebuild.
82
+ */
83
+ function verifyWritable(db) {
84
+ try {
85
+ db.prepare(`INSERT INTO meta (key, value) VALUES ('_write_check', '1') ON CONFLICT(key) DO UPDATE SET value = '1'`).run();
86
+ db.prepare(`DELETE FROM meta WHERE key = '_write_check'`).run();
87
+ }
88
+ catch (err) {
89
+ const msg = err instanceof Error ? err.message : String(err);
90
+ throw new Error(`database not writable after FTS cleanup (needs rebuild): ${msg}`);
91
+ }
92
+ }
75
93
  /**
76
94
  * When fts5 module is unavailable but the virtual table and its shadow tables
77
95
  * exist from a previous run, drop them to prevent "no such module" errors.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubytech/taskmaster",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "description": "AI-powered business assistant for small businesses",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -495,6 +495,18 @@ When you add or change a file, your assistant picks it up automatically — no r
495
495
 
496
496
  When your assistant writes to **public/** or **shared/**, a shield icon appears in the navigation bar so you can review what was written (see [Data Safety Alert](#data-safety-alert) above).
497
497
 
498
+ ### Searching Memory
499
+
500
+ The Files page includes a **memory search bar** that lets you test what your assistant finds when it searches its knowledge base.
501
+
502
+ 1. Type a query in the **Search memory** box and press Enter (or click **Search**)
503
+ 2. Results show the file path, relevance score (as a percentage), matching line numbers, and a snippet of the matched text
504
+ 3. Click any result to open the file preview
505
+ 4. Use the **agent selector** dropdown next to the search bar to switch between agents (e.g., public vs admin) — this lets you verify what each assistant can see
506
+ 5. Click **Clear** to return to the normal file tree view
507
+
508
+ This is useful for diagnosing search issues — if your assistant can't find something in conversation, test the same query here to see what comes back. All results are shown regardless of score threshold, so you can see everything the search engine found.
509
+
498
510
  ---
499
511
 
500
512
  ## Status Dashboard
@@ -952,19 +964,50 @@ Only the business owner can change the activation mode.
952
964
 
953
965
  ## Updating Taskmaster
954
966
 
955
- When a new version of Taskmaster is available, the **Software** row on the Status Dashboard turns yellow and shows the new version number (e.g., "v1.2.3 → v1.3.0").
967
+ ### Checking for Updates
968
+
969
+ Taskmaster checks for updates automatically when you open the Setup page. The **Software** row in the Status Dashboard shows your current version and whether an update is available:
956
970
 
957
- To update:
971
+ - **Green** — You're running the latest version
972
+ - **Yellow** — An update is available (shows the new version number, e.g., "v1.0.38 → v1.0.39")
973
+ - **Grey** — Not yet checked
974
+
975
+ If the row shows "Unknown", tap the **refresh** button (circular arrow) to check manually. Tap the **(i)** button to see version details (current version, latest version, and status).
976
+
977
+ ### Installing an Update
958
978
 
959
979
  1. Open the **Setup** page
960
- 2. Look for the **Software** row in the dashboard
961
- 3. If an update is available, tap the **download** button (down-arrow icon)
962
- 4. Wait for the update to complete the page will reload automatically
963
- 5. After reload, the Software row should show "Up to date" in green
980
+ 2. Look for the **Software** row if it's yellow, an update is available
981
+ 3. Tap the **download** button (down-arrow icon)
982
+ 4. A progress overlay appears showing each step of the update (fetching, building, running checks, etc.)
983
+ 5. When the update completes, the gateway restarts automatically
984
+ 6. The page reconnects on its own — you'll see a result banner showing the version change (e.g., "Updated: v1.0.38 → v1.0.39")
985
+ 7. The Software row should now show green
986
+
987
+ You don't need to refresh the page — the overlay stays visible during the update and the page reconnects automatically after the gateway restarts.
988
+
989
+ ### Alternative: Re-run the Installer
990
+
991
+ You can also update by re-running the install command in Terminal:
992
+
993
+ ```bash
994
+ curl -fsSL https://taskmaster.bot/install.sh | bash
995
+ ```
996
+
997
+ This detects your existing installation and upgrades it in place.
998
+
999
+ ### If an Update Fails
1000
+
1001
+ If something goes wrong during the update:
1002
+
1003
+ - The progress overlay shows which step failed (marked with an X)
1004
+ - A result banner appears with the failure reason
1005
+ - Your previous version remains running — a failed update does not leave your system broken
1006
+ - Tap **Dismiss** to close the result banner
964
1007
 
965
- If the Software row shows "Unknown", tap the **refresh** button (circular arrow) to check for updates. Tap the **(i)** button to see version details.
1008
+ If the page loses connection during the update and doesn't reconnect within two minutes, refresh the page manually. If the gateway doesn't come back, try power-cycling your device (unplug and replug).
966
1009
 
967
- > **Note:** Updates require an internet connection. The update process takes about 30 seconds. Your assistant will be briefly unavailable during the restart.
1010
+ > **Note:** Updates require an internet connection. The update process typically takes 30–60 seconds. Your assistant will be briefly unavailable during the restart.
968
1011
 
969
1012
  ---
970
1013