@askexenow/exe-os 0.8.49 → 0.8.51

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.
@@ -3346,8 +3346,18 @@ async function countNewPendingReviewsSince(sinceIso) {
3346
3346
  });
3347
3347
  return Number(result.rows[0]?.cnt) || 0;
3348
3348
  }
3349
- async function listPendingReviews(limit) {
3349
+ async function listPendingReviews(limit, sessionScope) {
3350
3350
  const client = getClient();
3351
+ if (sessionScope) {
3352
+ const result2 = await client.execute({
3353
+ sql: `SELECT title, assigned_to, project_name FROM tasks
3354
+ WHERE status = 'needs_review'
3355
+ AND (session_scope = ? OR session_scope IS NULL)
3356
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
3357
+ args: [sessionScope, limit]
3358
+ });
3359
+ return result2.rows;
3360
+ }
3351
3361
  const result = await client.execute({
3352
3362
  sql: `SELECT title, assigned_to, project_name FROM tasks
3353
3363
  WHERE status = 'needs_review'
@@ -5487,8 +5487,18 @@ async function countNewPendingReviewsSince(sinceIso) {
5487
5487
  });
5488
5488
  return Number(result.rows[0]?.cnt) || 0;
5489
5489
  }
5490
- async function listPendingReviews(limit) {
5490
+ async function listPendingReviews(limit, sessionScope) {
5491
5491
  const client = getClient();
5492
+ if (sessionScope) {
5493
+ const result2 = await client.execute({
5494
+ sql: `SELECT title, assigned_to, project_name FROM tasks
5495
+ WHERE status = 'needs_review'
5496
+ AND (session_scope = ? OR session_scope IS NULL)
5497
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
5498
+ args: [sessionScope, limit]
5499
+ });
5500
+ return result2.rows;
5501
+ }
5492
5502
  const result = await client.execute({
5493
5503
  sql: `SELECT title, assigned_to, project_name FROM tasks
5494
5504
  WHERE status = 'needs_review'
@@ -1657,8 +1657,18 @@ var init_tmux_routing = __esm({
1657
1657
  // src/lib/tasks-review.ts
1658
1658
  import path12 from "path";
1659
1659
  import { existsSync as existsSync10, readdirSync as readdirSync3, unlinkSync as unlinkSync2 } from "fs";
1660
- async function listPendingReviews(limit) {
1660
+ async function listPendingReviews(limit, sessionScope) {
1661
1661
  const client = getClient();
1662
+ if (sessionScope) {
1663
+ const result2 = await client.execute({
1664
+ sql: `SELECT title, assigned_to, project_name FROM tasks
1665
+ WHERE status = 'needs_review'
1666
+ AND (session_scope = ? OR session_scope IS NULL)
1667
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
1668
+ args: [sessionScope, limit]
1669
+ });
1670
+ return result2.rows;
1671
+ }
1662
1672
  const result = await client.execute({
1663
1673
  sql: `SELECT title, assigned_to, project_name FROM tasks
1664
1674
  WHERE status = 'needs_review'
@@ -1638,8 +1638,18 @@ var init_tmux_routing = __esm({
1638
1638
  // src/lib/tasks-review.ts
1639
1639
  import path12 from "path";
1640
1640
  import { existsSync as existsSync10, readdirSync as readdirSync3, unlinkSync as unlinkSync2 } from "fs";
1641
- async function listPendingReviews(limit) {
1641
+ async function listPendingReviews(limit, sessionScope) {
1642
1642
  const client = getClient();
1643
+ if (sessionScope) {
1644
+ const result2 = await client.execute({
1645
+ sql: `SELECT title, assigned_to, project_name FROM tasks
1646
+ WHERE status = 'needs_review'
1647
+ AND (session_scope = ? OR session_scope IS NULL)
1648
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
1649
+ args: [sessionScope, limit]
1650
+ });
1651
+ return result2.rows;
1652
+ }
1643
1653
  const result = await client.execute({
1644
1654
  sql: `SELECT title, assigned_to, project_name FROM tasks
1645
1655
  WHERE status = 'needs_review'
@@ -1837,7 +1847,8 @@ var PENDING_REVIEW_LIMIT = 10;
1837
1847
  async function main() {
1838
1848
  await initStore();
1839
1849
  await cleanupOrphanedReviews();
1840
- const rows = await listPendingReviews(PENDING_REVIEW_LIMIT);
1850
+ const sessionScope = process.env.EXE_SESSION?.replace(/^.*?(exe\d+)$/, "$1") || void 0;
1851
+ const rows = await listPendingReviews(PENDING_REVIEW_LIMIT, sessionScope);
1841
1852
  if (rows.length > 0) {
1842
1853
  console.log("[REVIEW NOTIFICATIONS]");
1843
1854
  for (const row of rows) {
@@ -4599,8 +4599,18 @@ async function countNewPendingReviewsSince(sinceIso) {
4599
4599
  });
4600
4600
  return Number(result.rows[0]?.cnt) || 0;
4601
4601
  }
4602
- async function listPendingReviews(limit) {
4602
+ async function listPendingReviews(limit, sessionScope) {
4603
4603
  const client = getClient();
4604
+ if (sessionScope) {
4605
+ const result2 = await client.execute({
4606
+ sql: `SELECT title, assigned_to, project_name FROM tasks
4607
+ WHERE status = 'needs_review'
4608
+ AND (session_scope = ? OR session_scope IS NULL)
4609
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
4610
+ args: [sessionScope, limit]
4611
+ });
4612
+ return result2.rows;
4613
+ }
4604
4614
  const result = await client.execute({
4605
4615
  sql: `SELECT title, assigned_to, project_name FROM tasks
4606
4616
  WHERE status = 'needs_review'
@@ -2583,8 +2583,18 @@ async function countNewPendingReviewsSince(sinceIso) {
2583
2583
  });
2584
2584
  return Number(result.rows[0]?.cnt) || 0;
2585
2585
  }
2586
- async function listPendingReviews(limit) {
2586
+ async function listPendingReviews(limit, sessionScope) {
2587
2587
  const client = getClient();
2588
+ if (sessionScope) {
2589
+ const result2 = await client.execute({
2590
+ sql: `SELECT title, assigned_to, project_name FROM tasks
2591
+ WHERE status = 'needs_review'
2592
+ AND (session_scope = ? OR session_scope IS NULL)
2593
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
2594
+ args: [sessionScope, limit]
2595
+ });
2596
+ return result2.rows;
2597
+ }
2588
2598
  const result = await client.execute({
2589
2599
  sql: `SELECT title, assigned_to, project_name FROM tasks
2590
2600
  WHERE status = 'needs_review'
@@ -3051,8 +3051,18 @@ async function countNewPendingReviewsSince(sinceIso) {
3051
3051
  });
3052
3052
  return Number(result.rows[0]?.cnt) || 0;
3053
3053
  }
3054
- async function listPendingReviews(limit) {
3054
+ async function listPendingReviews(limit, sessionScope) {
3055
3055
  const client = getClient();
3056
+ if (sessionScope) {
3057
+ const result2 = await client.execute({
3058
+ sql: `SELECT title, assigned_to, project_name FROM tasks
3059
+ WHERE status = 'needs_review'
3060
+ AND (session_scope = ? OR session_scope IS NULL)
3061
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
3062
+ args: [sessionScope, limit]
3063
+ });
3064
+ return result2.rows;
3065
+ }
3056
3066
  const result = await client.execute({
3057
3067
  sql: `SELECT title, assigned_to, project_name FROM tasks
3058
3068
  WHERE status = 'needs_review'
@@ -56,43 +56,101 @@ function checkForUpdate(packageRoot) {
56
56
  }
57
57
 
58
58
  // src/bin/update.ts
59
- if (isMainModule(import.meta.url)) {
59
+ async function runUpdate(cliArgs) {
60
+ const args = cliArgs ?? process.argv.slice(2);
61
+ const autoMode = args.includes("--auto") || args.includes("-y");
62
+ const checkOnly = args.includes("--check");
60
63
  const packageRoot = new URL("../..", import.meta.url).pathname;
61
64
  const result = checkForUpdate(packageRoot);
62
65
  if (result.error) {
63
- console.error(result.error);
66
+ console.error(`\u26A0\uFE0F ${result.error}`);
67
+ process.exit(0);
68
+ }
69
+ if (checkOnly) {
70
+ if (result.updateAvailable) {
71
+ console.log(`Update available: v${result.localVersion} \u2192 v${result.remoteVersion}`);
72
+ } else {
73
+ console.log(`\u2705 exe-os is up to date (v${result.localVersion})`);
74
+ }
64
75
  process.exit(0);
65
76
  }
66
77
  if (!result.updateAvailable) {
67
- console.log(`exe-os is up to date (v${result.localVersion})`);
78
+ console.log(`\u2705 exe-os is up to date (v${result.localVersion})`);
68
79
  process.exit(0);
69
80
  }
70
- console.log(
71
- `Update available: v${result.localVersion} -> v${result.remoteVersion}`
72
- );
73
- console.log("");
74
- const rl = createInterface({ input: process.stdin, output: process.stdout });
75
- const answer = await new Promise((resolve) => {
76
- rl.question("Install update? (y/N) ", resolve);
77
- });
78
- rl.close();
79
- if (answer.toLowerCase() === "y") {
80
- console.log("Updating...");
81
+ console.log(`
82
+ \u{1F4E6} Update available: v${result.localVersion} \u2192 v${result.remoteVersion}
83
+ `);
84
+ let proceed = autoMode;
85
+ if (!proceed) {
86
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
87
+ const answer = await new Promise((resolve) => {
88
+ rl.question("Install update? (Y/n) ", resolve);
89
+ });
90
+ rl.close();
91
+ proceed = answer.toLowerCase() !== "n";
92
+ }
93
+ if (!proceed) {
94
+ console.log("Update skipped.");
95
+ process.exit(0);
96
+ }
97
+ console.log("\n\u{1F9F9} Clearing npm cache...");
98
+ try {
99
+ execSync2("npm cache clean --force", { stdio: "pipe" });
100
+ console.log(" Done");
101
+ } catch {
102
+ console.log(" Skipped (non-critical)");
103
+ }
104
+ console.log("\u{1F4E5} Installing @askexenow/exe-os@latest...");
105
+ try {
106
+ execSync2("npm install -g @askexenow/exe-os@latest", {
107
+ stdio: ["pipe", "pipe", "pipe"],
108
+ timeout: 12e4
109
+ });
110
+ } catch (err) {
111
+ console.error("\n\u274C Update failed.");
112
+ console.error(" Try manually: npm install -g @askexenow/exe-os@latest");
113
+ if (err instanceof Error && err.message) {
114
+ console.error(` Error: ${err.message.split("\n")[0]}`);
115
+ }
116
+ process.exit(1);
117
+ }
118
+ let newVersion;
119
+ try {
120
+ newVersion = getLocalVersion(packageRoot);
121
+ } catch {
81
122
  try {
82
- execSync2("npm install -g @askexenow/exe-os@latest", { stdio: "inherit" });
83
- console.log("Update complete!");
123
+ const out = execSync2("npm list -g @askexenow/exe-os --depth=0 2>/dev/null", { encoding: "utf8" });
124
+ const match = out.match(/@askexenow\/exe-os@(\S+)/);
125
+ newVersion = match?.[1] ?? "unknown";
84
126
  } catch {
85
- console.error(
86
- "Update failed. Try running manually: npx exe-os --global"
87
- );
88
- process.exit(1);
127
+ newVersion = "unknown";
89
128
  }
129
+ }
130
+ const remoteVersion = result.remoteVersion;
131
+ if (newVersion === remoteVersion) {
132
+ console.log(`
133
+ \u2705 Updated to v${newVersion}`);
134
+ } else if (newVersion !== result.localVersion) {
135
+ console.log(`
136
+ \u2705 Updated to v${newVersion} (latest: v${remoteVersion})`);
90
137
  } else {
91
- console.log("Update skipped.");
138
+ console.log(`
139
+ \u26A0\uFE0F Version unchanged (v${newVersion}). npm cache may be stale.`);
140
+ console.log(" Try: npm cache clean --force && npm install -g @askexenow/exe-os@latest");
92
141
  }
142
+ console.log(" Hooks re-wired, daemon restarted automatically.");
143
+ console.log("\n\u{1F680} Ready. Start your COO session to use the new version.\n");
144
+ }
145
+ if (isMainModule(import.meta.url)) {
146
+ runUpdate().catch((err) => {
147
+ console.error(err instanceof Error ? err.message : String(err));
148
+ process.exit(1);
149
+ });
93
150
  }
94
151
  export {
95
152
  checkForUpdate,
96
153
  getLocalVersion,
97
- getRemoteVersion
154
+ getRemoteVersion,
155
+ runUpdate
98
156
  };
@@ -3905,8 +3905,18 @@ async function countNewPendingReviewsSince(sinceIso) {
3905
3905
  });
3906
3906
  return Number(result.rows[0]?.cnt) || 0;
3907
3907
  }
3908
- async function listPendingReviews(limit) {
3908
+ async function listPendingReviews(limit, sessionScope) {
3909
3909
  const client = getClient();
3910
+ if (sessionScope) {
3911
+ const result2 = await client.execute({
3912
+ sql: `SELECT title, assigned_to, project_name FROM tasks
3913
+ WHERE status = 'needs_review'
3914
+ AND (session_scope = ? OR session_scope IS NULL)
3915
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
3916
+ args: [sessionScope, limit]
3917
+ });
3918
+ return result2.rows;
3919
+ }
3910
3920
  const result = await client.execute({
3911
3921
  sql: `SELECT title, assigned_to, project_name FROM tasks
3912
3922
  WHERE status = 'needs_review'
@@ -3464,8 +3464,18 @@ async function countNewPendingReviewsSince(sinceIso) {
3464
3464
  });
3465
3465
  return Number(result.rows[0]?.cnt) || 0;
3466
3466
  }
3467
- async function listPendingReviews(limit) {
3467
+ async function listPendingReviews(limit, sessionScope) {
3468
3468
  const client = getClient();
3469
+ if (sessionScope) {
3470
+ const result2 = await client.execute({
3471
+ sql: `SELECT title, assigned_to, project_name FROM tasks
3472
+ WHERE status = 'needs_review'
3473
+ AND (session_scope = ? OR session_scope IS NULL)
3474
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
3475
+ args: [sessionScope, limit]
3476
+ });
3477
+ return result2.rows;
3478
+ }
3469
3479
  const result = await client.execute({
3470
3480
  sql: `SELECT title, assigned_to, project_name FROM tasks
3471
3481
  WHERE status = 'needs_review'
@@ -2582,8 +2582,18 @@ async function countNewPendingReviewsSince(sinceIso) {
2582
2582
  });
2583
2583
  return Number(result.rows[0]?.cnt) || 0;
2584
2584
  }
2585
- async function listPendingReviews(limit) {
2585
+ async function listPendingReviews(limit, sessionScope) {
2586
2586
  const client = getClient();
2587
+ if (sessionScope) {
2588
+ const result2 = await client.execute({
2589
+ sql: `SELECT title, assigned_to, project_name FROM tasks
2590
+ WHERE status = 'needs_review'
2591
+ AND (session_scope = ? OR session_scope IS NULL)
2592
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
2593
+ args: [sessionScope, limit]
2594
+ });
2595
+ return result2.rows;
2596
+ }
2587
2597
  const result = await client.execute({
2588
2598
  sql: `SELECT title, assigned_to, project_name FROM tasks
2589
2599
  WHERE status = 'needs_review'
@@ -4103,8 +4103,18 @@ async function countNewPendingReviewsSince(sinceIso) {
4103
4103
  });
4104
4104
  return Number(result.rows[0]?.cnt) || 0;
4105
4105
  }
4106
- async function listPendingReviews(limit) {
4106
+ async function listPendingReviews(limit, sessionScope) {
4107
4107
  const client = getClient();
4108
+ if (sessionScope) {
4109
+ const result2 = await client.execute({
4110
+ sql: `SELECT title, assigned_to, project_name FROM tasks
4111
+ WHERE status = 'needs_review'
4112
+ AND (session_scope = ? OR session_scope IS NULL)
4113
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
4114
+ args: [sessionScope, limit]
4115
+ });
4116
+ return result2.rows;
4117
+ }
4108
4118
  const result = await client.execute({
4109
4119
  sql: `SELECT title, assigned_to, project_name FROM tasks
4110
4120
  WHERE status = 'needs_review'
@@ -3928,8 +3928,18 @@ async function countNewPendingReviewsSince(sinceIso) {
3928
3928
  });
3929
3929
  return Number(result.rows[0]?.cnt) || 0;
3930
3930
  }
3931
- async function listPendingReviews(limit) {
3931
+ async function listPendingReviews(limit, sessionScope) {
3932
3932
  const client = getClient();
3933
+ if (sessionScope) {
3934
+ const result2 = await client.execute({
3935
+ sql: `SELECT title, assigned_to, project_name FROM tasks
3936
+ WHERE status = 'needs_review'
3937
+ AND (session_scope = ? OR session_scope IS NULL)
3938
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
3939
+ args: [sessionScope, limit]
3940
+ });
3941
+ return result2.rows;
3942
+ }
3933
3943
  const result = await client.execute({
3934
3944
  sql: `SELECT title, assigned_to, project_name FROM tasks
3935
3945
  WHERE status = 'needs_review'
@@ -4026,8 +4026,18 @@ async function countNewPendingReviewsSince(sinceIso) {
4026
4026
  });
4027
4027
  return Number(result.rows[0]?.cnt) || 0;
4028
4028
  }
4029
- async function listPendingReviews(limit) {
4029
+ async function listPendingReviews(limit, sessionScope) {
4030
4030
  const client = getClient();
4031
+ if (sessionScope) {
4032
+ const result2 = await client.execute({
4033
+ sql: `SELECT title, assigned_to, project_name FROM tasks
4034
+ WHERE status = 'needs_review'
4035
+ AND (session_scope = ? OR session_scope IS NULL)
4036
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
4037
+ args: [sessionScope, limit]
4038
+ });
4039
+ return result2.rows;
4040
+ }
4031
4041
  const result = await client.execute({
4032
4042
  sql: `SELECT title, assigned_to, project_name FROM tasks
4033
4043
  WHERE status = 'needs_review'
package/dist/index.js CHANGED
@@ -2247,8 +2247,18 @@ async function countNewPendingReviewsSince(sinceIso) {
2247
2247
  });
2248
2248
  return Number(result.rows[0]?.cnt) || 0;
2249
2249
  }
2250
- async function listPendingReviews(limit) {
2250
+ async function listPendingReviews(limit, sessionScope) {
2251
2251
  const client = getClient();
2252
+ if (sessionScope) {
2253
+ const result2 = await client.execute({
2254
+ sql: `SELECT title, assigned_to, project_name FROM tasks
2255
+ WHERE status = 'needs_review'
2256
+ AND (session_scope = ? OR session_scope IS NULL)
2257
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
2258
+ args: [sessionScope, limit]
2259
+ });
2260
+ return result2.rows;
2261
+ }
2252
2262
  const result = await client.execute({
2253
2263
  sql: `SELECT title, assigned_to, project_name FROM tasks
2254
2264
  WHERE status = 'needs_review'
@@ -3353,8 +3353,18 @@ async function countNewPendingReviewsSince(sinceIso) {
3353
3353
  });
3354
3354
  return Number(result.rows[0]?.cnt) || 0;
3355
3355
  }
3356
- async function listPendingReviews(limit) {
3356
+ async function listPendingReviews(limit, sessionScope) {
3357
3357
  const client = getClient();
3358
+ if (sessionScope) {
3359
+ const result2 = await client.execute({
3360
+ sql: `SELECT title, assigned_to, project_name FROM tasks
3361
+ WHERE status = 'needs_review'
3362
+ AND (session_scope = ? OR session_scope IS NULL)
3363
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
3364
+ args: [sessionScope, limit]
3365
+ });
3366
+ return result2.rows;
3367
+ }
3358
3368
  const result = await client.execute({
3359
3369
  sql: `SELECT title, assigned_to, project_name FROM tasks
3360
3370
  WHERE status = 'needs_review'
package/dist/lib/tasks.js CHANGED
@@ -2170,8 +2170,18 @@ async function countNewPendingReviewsSince(sinceIso) {
2170
2170
  });
2171
2171
  return Number(result.rows[0]?.cnt) || 0;
2172
2172
  }
2173
- async function listPendingReviews(limit) {
2173
+ async function listPendingReviews(limit, sessionScope) {
2174
2174
  const client = getClient();
2175
+ if (sessionScope) {
2176
+ const result2 = await client.execute({
2177
+ sql: `SELECT title, assigned_to, project_name FROM tasks
2178
+ WHERE status = 'needs_review'
2179
+ AND (session_scope = ? OR session_scope IS NULL)
2180
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
2181
+ args: [sessionScope, limit]
2182
+ });
2183
+ return result2.rows;
2184
+ }
2175
2185
  const result = await client.execute({
2176
2186
  sql: `SELECT title, assigned_to, project_name FROM tasks
2177
2187
  WHERE status = 'needs_review'
@@ -1241,8 +1241,18 @@ async function countNewPendingReviewsSince(sinceIso) {
1241
1241
  });
1242
1242
  return Number(result.rows[0]?.cnt) || 0;
1243
1243
  }
1244
- async function listPendingReviews(limit) {
1244
+ async function listPendingReviews(limit, sessionScope) {
1245
1245
  const client = getClient();
1246
+ if (sessionScope) {
1247
+ const result2 = await client.execute({
1248
+ sql: `SELECT title, assigned_to, project_name FROM tasks
1249
+ WHERE status = 'needs_review'
1250
+ AND (session_scope = ? OR session_scope IS NULL)
1251
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
1252
+ args: [sessionScope, limit]
1253
+ });
1254
+ return result2.rows;
1255
+ }
1246
1256
  const result = await client.execute({
1247
1257
  sql: `SELECT title, assigned_to, project_name FROM tasks
1248
1258
  WHERE status = 'needs_review'
@@ -747,6 +747,17 @@ var init_db_retry = __esm({
747
747
  });
748
748
 
749
749
  // src/lib/database.ts
750
+ var database_exports = {};
751
+ __export(database_exports, {
752
+ disposeDatabase: () => disposeDatabase,
753
+ disposeTurso: () => disposeTurso,
754
+ ensureSchema: () => ensureSchema,
755
+ getClient: () => getClient,
756
+ getRawClient: () => getRawClient,
757
+ initDatabase: () => initDatabase,
758
+ initTurso: () => initTurso,
759
+ isInitialized: () => isInitialized
760
+ });
750
761
  import { createClient } from "@libsql/client";
751
762
  async function initDatabase(config2) {
752
763
  if (_client) {
@@ -5490,8 +5501,18 @@ async function countNewPendingReviewsSince(sinceIso) {
5490
5501
  });
5491
5502
  return Number(result.rows[0]?.cnt) || 0;
5492
5503
  }
5493
- async function listPendingReviews(limit) {
5504
+ async function listPendingReviews(limit, sessionScope) {
5494
5505
  const client = getClient();
5506
+ if (sessionScope) {
5507
+ const result2 = await client.execute({
5508
+ sql: `SELECT title, assigned_to, project_name FROM tasks
5509
+ WHERE status = 'needs_review'
5510
+ AND (session_scope = ? OR session_scope IS NULL)
5511
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
5512
+ args: [sessionScope, limit]
5513
+ });
5514
+ return result2.rows;
5515
+ }
5495
5516
  const result = await client.execute({
5496
5517
  sql: `SELECT title, assigned_to, project_name FROM tasks
5497
5518
  WHERE status = 'needs_review'
@@ -8283,6 +8304,7 @@ All tasks complete. No more open tasks in your queue.`;
8283
8304
  // src/mcp/tools/close-task.ts
8284
8305
  init_tasks();
8285
8306
  init_active_agent();
8307
+ init_tmux_routing();
8286
8308
  import { z as z10 } from "zod";
8287
8309
  var CLOSE_TASK_ALLOWED_ROLES = /* @__PURE__ */ new Set(["COO", "CTO"]);
8288
8310
  function registerCloseTask(server2) {
@@ -8310,6 +8332,26 @@ function registerCloseTask(server2) {
8310
8332
  isError: true
8311
8333
  };
8312
8334
  }
8335
+ try {
8336
+ const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
8337
+ const client = getClient2();
8338
+ const taskRow = await client.execute({
8339
+ sql: "SELECT session_scope FROM tasks WHERE id = ? OR task_file LIKE ? OR title LIKE ? LIMIT 1",
8340
+ args: [task_id, `%${task_id}%`, `%${task_id}%`]
8341
+ });
8342
+ const taskScope = taskRow.rows[0]?.session_scope;
8343
+ const mySession = resolveExeSession();
8344
+ if (taskScope && mySession && taskScope !== mySession) {
8345
+ return {
8346
+ content: [{
8347
+ type: "text",
8348
+ text: `\u26A0\uFE0F Session scope mismatch: this task belongs to ${taskScope}, but you are ${mySession}. Reviews should be processed by the exe session that dispatched the task. Switch to ${taskScope} to review this task.`
8349
+ }],
8350
+ isError: true
8351
+ };
8352
+ }
8353
+ } catch {
8354
+ }
8313
8355
  const baseDir = process.cwd();
8314
8356
  const task = await updateTask({
8315
8357
  taskId: task_id,
@@ -2334,8 +2334,18 @@ async function countNewPendingReviewsSince(sinceIso) {
2334
2334
  });
2335
2335
  return Number(result.rows[0]?.cnt) || 0;
2336
2336
  }
2337
- async function listPendingReviews(limit) {
2337
+ async function listPendingReviews(limit, sessionScope) {
2338
2338
  const client = getClient();
2339
+ if (sessionScope) {
2340
+ const result2 = await client.execute({
2341
+ sql: `SELECT title, assigned_to, project_name FROM tasks
2342
+ WHERE status = 'needs_review'
2343
+ AND (session_scope = ? OR session_scope IS NULL)
2344
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
2345
+ args: [sessionScope, limit]
2346
+ });
2347
+ return result2.rows;
2348
+ }
2339
2349
  const result = await client.execute({
2340
2350
  sql: `SELECT title, assigned_to, project_name FROM tasks
2341
2351
  WHERE status = 'needs_review'
@@ -2170,8 +2170,18 @@ async function countNewPendingReviewsSince(sinceIso) {
2170
2170
  });
2171
2171
  return Number(result.rows[0]?.cnt) || 0;
2172
2172
  }
2173
- async function listPendingReviews(limit) {
2173
+ async function listPendingReviews(limit, sessionScope) {
2174
2174
  const client = getClient();
2175
+ if (sessionScope) {
2176
+ const result2 = await client.execute({
2177
+ sql: `SELECT title, assigned_to, project_name FROM tasks
2178
+ WHERE status = 'needs_review'
2179
+ AND (session_scope = ? OR session_scope IS NULL)
2180
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
2181
+ args: [sessionScope, limit]
2182
+ });
2183
+ return result2.rows;
2184
+ }
2175
2185
  const result = await client.execute({
2176
2186
  sql: `SELECT title, assigned_to, project_name FROM tasks
2177
2187
  WHERE status = 'needs_review'
@@ -2188,8 +2188,18 @@ async function countNewPendingReviewsSince(sinceIso) {
2188
2188
  });
2189
2189
  return Number(result.rows[0]?.cnt) || 0;
2190
2190
  }
2191
- async function listPendingReviews(limit) {
2191
+ async function listPendingReviews(limit, sessionScope) {
2192
2192
  const client = getClient();
2193
+ if (sessionScope) {
2194
+ const result2 = await client.execute({
2195
+ sql: `SELECT title, assigned_to, project_name FROM tasks
2196
+ WHERE status = 'needs_review'
2197
+ AND (session_scope = ? OR session_scope IS NULL)
2198
+ ORDER BY priority ASC, created_at DESC LIMIT ?`,
2199
+ args: [sessionScope, limit]
2200
+ });
2201
+ return result2.rows;
2202
+ }
2193
2203
  const result = await client.execute({
2194
2204
  sql: `SELECT title, assigned_to, project_name FROM tasks
2195
2205
  WHERE status = 'needs_review'