thumbgate 1.40.10 → 1.40.12

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 (46) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.well-known/mcp/server-card.json +1 -1
  3. package/README.md +46 -40
  4. package/adapters/claude/.mcp.json +3 -3
  5. package/adapters/forge/forge.yaml +3 -3
  6. package/adapters/future-agi/.mcp.json +1 -1
  7. package/adapters/future-agi/config.toml +1 -1
  8. package/adapters/future-agi/opencode.json +1 -1
  9. package/adapters/herdr/herdr-plugin.toml +2 -2
  10. package/adapters/mcp/server-stdio.js +1 -1
  11. package/adapters/opencode/opencode.json +1 -1
  12. package/bin/cli.js +9 -8
  13. package/bin/postinstall.js +2 -2
  14. package/package.json +9 -5
  15. package/public/admin.html +229 -29
  16. package/public/agent-manager.html +2 -2
  17. package/public/agents-cost-savings.html +1 -1
  18. package/public/codex-enterprise.html +2 -2
  19. package/public/compare.html +3 -3
  20. package/public/dashboard.html +28 -9
  21. package/public/diagnostic.html +1 -1
  22. package/public/founders.html +1 -1
  23. package/public/guide.html +4 -4
  24. package/public/index.html +80 -116
  25. package/public/install.html +19 -19
  26. package/public/js/connect-panel.js +21 -7
  27. package/public/lessons.html +1 -1
  28. package/public/numbers.html +2 -2
  29. package/public/pricing.html +12 -9
  30. package/public/pro.html +96 -137
  31. package/public/project-switcher.js +42 -18
  32. package/scripts/auto-wire-hooks.js +36 -2
  33. package/scripts/billing.js +3 -1
  34. package/scripts/cli-schema.js +2 -3
  35. package/scripts/commercial-offer.js +1 -1
  36. package/scripts/gates-engine.js +26 -8
  37. package/scripts/hook-runtime.js +18 -1
  38. package/scripts/owner-admin.js +212 -13
  39. package/scripts/owner-alerts.js +79 -0
  40. package/scripts/owner-telemetry.js +93 -3
  41. package/scripts/project-catalog.js +3 -1
  42. package/scripts/project-identity.js +4 -1
  43. package/scripts/seo-gsd.js +1 -1
  44. package/scripts/telemetry-analytics.js +7 -1
  45. package/server.json +2 -2
  46. package/src/api/server.js +51 -3
@@ -1,6 +1,7 @@
1
1
  (function () {
2
2
  'use strict';
3
3
  var selected = new URL(window.location.href).searchParams.get('project');
4
+ var explicit = selected !== null;
4
5
  if (selected === 'all') selected = null;
5
6
  var selectedDir = selected ? new URL(window.location.href).searchParams.get('projectDir') : null;
6
7
  var loading = null;
@@ -16,20 +17,34 @@
16
17
  var container = document.createElement('section');
17
18
  container.id = 'projectOverview';
18
19
  container.className = 'container';
19
- container.style.cssText = 'padding:16px 20px;max-width:1200px;margin:auto';
20
+ container.style.cssText = 'padding:12px 20px;max-width:1200px;margin:auto';
21
+ var bar = document.createElement('div'); bar.style.cssText = 'display:flex;align-items:center;gap:12px;flex-wrap:wrap';
20
22
  var label = document.createElement('label');
21
- label.htmlFor = 'projectSwitcher'; label.textContent = 'Project';
23
+ label.htmlFor = 'projectSwitcher'; label.textContent = 'Project'; label.style.cssText = 'font-weight:600';
22
24
  var select = document.createElement('select');
23
- select.id = 'projectSwitcher'; select.style.cssText = 'margin:0 12px;padding:8px;max-width:100%;background:var(--bg-raised,#18181b);color:var(--text,#fafafa);border:1px solid var(--border,#444);border-radius:6px';
25
+ select.id = 'projectSwitcher'; select.style.cssText = 'padding:8px;min-width:260px;max-width:100%;background:var(--bg-raised,#18181b);color:var(--text,#fafafa);border:1px solid var(--border,#444);border-radius:6px';
24
26
  var all = document.createElement('option'); all.value = ''; all.textContent = 'All projects (account-wide, not one project)'; select.appendChild(all);
25
- if (selected) { var pending = document.createElement('option'); pending.value = selected; pending.textContent = 'Selected project'; select.appendChild(pending); select.value = selected; }
26
- select.addEventListener('change', function () { var next = new URL(window.location.href); next.searchParams.delete('projectDir'); if (select.value) next.searchParams.set('project', select.value); else next.searchParams.delete('project'); window.location.assign(next.href); });
27
- var status = document.createElement('span'); status.id = 'projectStatus'; status.setAttribute('role', 'status');
28
- var cards = document.createElement('div'); cards.id = 'projectCards'; cards.style.cssText = 'display:flex;gap:12px;flex-wrap:wrap;margin-top:12px';
29
- var sharedGates = document.createElement('p'); sharedGates.id = 'projectGlobalGates';
30
- container.append(label, select, status, sharedGates, cards);
31
- var header = document.querySelector('header');
32
- if (header) header.after(container); else document.body.prepend(container);
27
+ if (selected) { var pending = document.createElement('option'); pending.value = selected; pending.textContent = selectedDir ? selectedDir.split('/').filter(Boolean).pop() : 'Loading project…'; select.appendChild(pending); select.value = selected; }
28
+ select.addEventListener('change', function () { var next = new URL(window.location.href); next.searchParams.delete('projectDir'); next.searchParams.set('project', select.value || 'all'); window.location.assign(next.href); });
29
+ var status = document.createElement('span'); status.id = 'projectStatus'; status.setAttribute('role', 'status'); status.style.cssText = 'color:var(--text-muted,#a1a1aa)';
30
+ var cards = document.createElement('div'); cards.id = 'projectCards'; cards.style.cssText = 'display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:12px;margin-top:12px';
31
+ var sharedGates = document.createElement('p'); sharedGates.id = 'projectGlobalGates'; sharedGates.style.cssText = 'margin:8px 0 0;color:var(--text-muted,#a1a1aa);font-size:13px';
32
+ bar.append(label, select, status);
33
+ container.append(bar, sharedGates, cards);
34
+ // The dashboard's top bar is a <nav class="app-top-nav">, not a <header>: anchor under it so the switcher never lands above the site nav.
35
+ var anchor = document.querySelector('.app-top-nav') || document.querySelector('header');
36
+ if (anchor) anchor.after(container); else document.body.prepend(container);
37
+ }
38
+ function hasActivity(project) {
39
+ if (project.empty === true) return false;
40
+ var c = project.counts || {};
41
+ return Boolean(c.feedback || c.lessons || c.gates || c.blocks || c.warns || c.toolCalls || c.agents);
42
+ }
43
+ // A real project is one identified by its git remote (repo_ key). Legacy, local and unassigned identities are leftovers.
44
+ function isRealProject(project) { return /^repo_/.test(project.projectKey || ''); }
45
+ function displayName(project) {
46
+ if (project.projectKey === selected && selectedDir) return selectedDir.split('/').filter(Boolean).pop();
47
+ return String(project.projectName || '').split('/').pop();
33
48
  }
34
49
  function refresh(headers) {
35
50
  mount();
@@ -38,18 +53,27 @@
38
53
  var select = document.getElementById('projectSwitcher');
39
54
  while (select.options.length > 1) select.remove(1);
40
55
  var projects = Array.isArray(data.projects) ? data.projects : [];
41
- if (selected && !projects.some(function (project) { return project.projectKey === selected; })) projects.push({ projectKey: selected, projectName: 'Project with no recorded activity', counts: {} });
42
- projects.forEach(function (project) { var option = document.createElement('option'); option.value = project.projectKey; option.textContent = project.projectName; select.appendChild(option); });
56
+ if (selected && !projects.some(function (project) { return project.projectKey === selected; })) projects.push({ projectKey: selected, projectName: selectedDir ? selectedDir.split('/').filter(Boolean).pop() : 'Project with no recorded activity', counts: {} });
57
+ // Leftover identities with nothing recorded are not worth a pick: hide them and say how many.
58
+ // A bare dashboard URL opens on a project; "All projects" is an explicit pick (project=all).
59
+ if (!explicit) {
60
+ var recent = projects.filter(function (project) { return isRealProject(project) && project.lastActivity; }).sort(function (a, b) { return new Date(b.lastActivity) - new Date(a.lastActivity); })[0];
61
+ if (recent) { var next = new URL(window.location.href); next.searchParams.set('project', recent.projectKey); if (data.projectDir) next.searchParams.set('projectDir', data.projectDir); window.location.replace(next.href); return; }
62
+ }
63
+ // Only the selected project and other real projects with feedback are offered; legacy, local and unassigned identities are not.
64
+ var shown = projects.filter(function (project) { return project.projectKey === selected || isRealProject(project); });
65
+ shown.forEach(function (project) { var option = document.createElement('option'); option.value = project.projectKey; option.textContent = displayName(project); select.appendChild(option); });
43
66
  select.value = selected || '';
44
67
  var current = projects.find(function (project) { return project.projectKey === selected; });
45
- document.getElementById('projectStatus').textContent = current ? current.projectName : 'Account-wide view: mixes every project and store. Pick a project for its own numbers.';
68
+ var where = selectedDir ? selectedDir.replace(/^\/Users\/[^/]+/, '~') : '';
69
+ document.getElementById('projectStatus').textContent = current ? displayName(current) + (where ? ' · ' + where : '') : 'All projects: account-wide, mixes every project. Pick a project for its own numbers.';
46
70
  document.getElementById('projectGlobalGates').textContent = (data.globalGateCount || 0) + ' global gates shared across projects';
47
71
  var cards = document.getElementById('projectCards'); cards.replaceChildren();
48
- if (!selected) projects.forEach(function (project) {
49
- var card = document.createElement('a'); card.href = '?project=' + encodeURIComponent(project.projectKey); card.style.cssText = 'display:block;border:1px solid var(--border,#444);border-radius:8px;padding:12px;color:inherit;min-width:180px;text-decoration:none';
72
+ if (!selected) shown.forEach(function (project) {
73
+ var card = document.createElement('a'); card.href = '?project=' + encodeURIComponent(project.projectKey); card.style.cssText = 'display:flex;flex-direction:column;gap:4px;border:1px solid var(--border,#444);border-radius:8px;padding:12px;color:inherit;min-width:0;text-decoration:none';
50
74
  var title = document.createElement('strong'); title.textContent = project.projectName;
51
- var counts = document.createElement('div'); var c = project.counts || {}; counts.textContent = (c.feedback || 0) + ' feedback · ' + (c.lessons || 0) + ' lessons · ' + (c.gates || 0) + ' active gates · ' + (c.blocks || 0) + ' blocks · ' + (c.warns || 0) + ' warnings · ' + (c.toolCalls || 0) + ' tool calls · ' + (c.agents || 0) + ' agents';
52
- var activity = document.createElement('small'); activity.textContent = project.lastActivity ? 'Last activity ' + new Date(project.lastActivity).toLocaleString() : 'No recorded activity';
75
+ var counts = document.createElement('div'); var c = project.counts || {}; counts.style.cssText = 'font-size:13px'; counts.textContent = (c.feedback || 0) + ' feedback · ' + (c.lessons || 0) + ' lessons · ' + (c.gates || 0) + ' active gates · ' + (c.blocks || 0) + ' blocks · ' + (c.warns || 0) + ' warnings · ' + (c.toolCalls || 0) + ' tool calls · ' + (c.agents || 0) + ' agents';
76
+ var activity = document.createElement('small'); activity.style.cssText = 'color:var(--text-muted,#a1a1aa)'; activity.textContent = project.lastActivity ? 'Last activity ' + new Date(project.lastActivity).toLocaleString() : 'No recorded activity';
53
77
  card.append(title, counts, activity); cards.appendChild(card);
54
78
  });
55
79
  }).catch(function () { document.getElementById('projectStatus').textContent = 'Project list unavailable'; }).finally(function () { loading = null; });
@@ -30,6 +30,7 @@ const {
30
30
  statuslineCommand,
31
31
  userPromptHookCommand,
32
32
  cursorShellGateHookCommand,
33
+ isDisposableCheckout,
33
34
  } = require('./hook-runtime');
34
35
  const { installShim } = require('./install-shim');
35
36
 
@@ -337,11 +338,30 @@ function expandShellToken(token, resolveBase) {
337
338
  // missing script file, else null. Anything that doesn't look like a file
338
339
  // reference, or contains unresolved $VAR after expansion, returns null —
339
340
  // caller treats null as "keep the hook" (err on the side of NOT pruning).
341
+ const SCRIPT_INTERPRETERS = new Set(['node', 'nodejs', 'sh', 'bash', 'zsh', 'python', 'python3']);
342
+
340
343
  function staleHookPath(command, resolveBase) {
341
344
  if (!command) return null;
342
- const rawFirstToken = command.split(/\s+/)[0];
345
+ const tokens = command.trim().split(/\s+/);
346
+ let rawFirstToken = tokens[0];
347
+ let runsScript = false;
348
+ // `node /gone/script.js`: the interpreter is never a path, so check the script it runs.
349
+ // Without this a hook that points at a deleted worktree survives every cleanup and breaks
350
+ // each tool call (23 Nov 2026, ThumbGate-main-live).
351
+ if (SCRIPT_INTERPRETERS.has(path.basename(rawFirstToken))) {
352
+ // -c / -e / -p / --eval / --print run inline code, not a script file.
353
+ let script = null;
354
+ for (const token of tokens.slice(1)) {
355
+ if (/^(-[cep]|--eval|--print)$/.test(token)) return null;
356
+ if (!token.startsWith('-')) { script = token; break; }
357
+ }
358
+ if (!script) return null;
359
+ rawFirstToken = script;
360
+ runsScript = true;
361
+ }
343
362
  const firstToken = expandShellToken(rawFirstToken, resolveBase);
344
363
  const looksLikePath =
364
+ runsScript ||
345
365
  firstToken.includes('/') ||
346
366
  firstToken.includes('\\') ||
347
367
  firstToken.endsWith('.sh');
@@ -469,7 +489,9 @@ function wireClaudeHooks(options) {
469
489
  // The shim at ~/.thumbgate/bin/thumbgate-hook always resolves @latest,
470
490
  // so hooks never go stale across version bumps (Volta-style pattern).
471
491
  // Skip in source-checkout mode — developers use direct node commands.
472
- if (!dryRun && !require('./mcp-config').isSourceCheckout(path.join(__dirname, '..'))) {
492
+ // Worktree checkouts get hooks that call the stable launcher, so it must exist.
493
+ const sourceRoot = path.join(__dirname, '..');
494
+ if (!dryRun && (!require('./mcp-config').isSourceCheckout(sourceRoot) || isDisposableCheckout(sourceRoot))) {
473
495
  try {
474
496
  installShim();
475
497
  } catch {
@@ -866,6 +888,7 @@ function parseFlags(argv) {
866
888
  const flags = {};
867
889
  for (const arg of argv) {
868
890
  if (arg === '--dry-run') flags.dryRun = true;
891
+ if (arg === '--help' || arg === '-h') flags.help = true;
869
892
  if (arg === '--wire-hooks') flags.wireHooks = true;
870
893
  if (arg.startsWith('--agent=')) flags.agent = arg.slice('--agent='.length);
871
894
  if (arg.startsWith('--agent') && !arg.includes('=')) {
@@ -900,6 +923,7 @@ module.exports = {
900
923
  syncClaudeStatusLine,
901
924
  forgeConfigPath,
902
925
  pruneStaleFileHooks,
926
+ staleHookPath,
903
927
  pruneStaleHooksInFile,
904
928
  CLAUDE_HOOKS,
905
929
  preToolHookCommand,
@@ -908,8 +932,18 @@ module.exports = {
908
932
  sessionStartHookCommand,
909
933
  };
910
934
 
935
+ const USAGE = `Usage: node scripts/auto-wire-hooks.js [--agent=<claude-code|codex|gemini|forge|cursor>] [--dry-run] [--help]
936
+
937
+ --dry-run print the entries that would be written; write nothing
938
+ --help, -h print this text; write nothing
939
+ `;
940
+
911
941
  if (require.main === module) {
912
942
  const flags = parseFlags(process.argv.slice(2));
943
+ if (flags.help) {
944
+ console.log(USAGE);
945
+ process.exit(0);
946
+ }
913
947
  const result = wireHooks(flags);
914
948
 
915
949
  if (result.error) {
@@ -2422,7 +2422,9 @@ async function listStripeReconciledRevenueEvents({ signal, deadline = Infinity }
2422
2422
  // qualified checkout start.
2423
2423
  function classifyCheckoutSessionDepth(session) {
2424
2424
  if (!session || typeof session !== 'object') return 'raw';
2425
- if (session.payment_status === 'paid' || session.status === 'complete') return 'paid';
2425
+ // Session completion can precede asynchronous payment settlement.
2426
+ // Only the payment status supports the paid bucket.
2427
+ if (session.payment_status === 'paid') return 'paid';
2426
2428
  if (normalizeText(session.payment_intent) || normalizeText(session.setup_intent)) return 'payment_attempt';
2427
2429
  const email = normalizeText(session.customer_details?.email) || normalizeText(session.customer_email);
2428
2430
  if (email && !isSyntheticOrOwnerCheckoutEmail(email)) return 'identified';
@@ -814,7 +814,6 @@ const CLI_COMMANDS = [
814
814
  flags: [],
815
815
  },
816
816
  {
817
- <<<<<<< HEAD
818
817
  name: 'cuda-gate',
819
818
  aliases: ['cuda-gate-batch'],
820
819
  description: 'CUDA-inspired parallel PreToolUse gate evaluation (SIMT + shared-memory hot cache)',
@@ -837,12 +836,12 @@ const CLI_COMMANDS = [
837
836
  { name: 'json', type: 'boolean', description: 'Output as JSON' },
838
837
  { name: 'memory-dir', type: 'string', description: 'Custom memory directory path' },
839
838
  ],
840
- =======
839
+ },
840
+ {
841
841
  name: 'cursor-shell-gate',
842
842
  description: 'Cursor beforeShellExecution hook: map command JSON to gate pipeline and emit permission allow/deny',
843
843
  group: 'gates',
844
844
  flags: [],
845
- >>>>>>> c47af0f9f (feat(cursor): add beforeShellExecution adapter for gate-check)
846
845
  },
847
846
  {
848
847
  name: 'force-gate',
@@ -78,7 +78,7 @@ function buildCaptureReceipt({ signal, feedbackId, memoryId, actionType } = {})
78
78
  ' Next proof : npx thumbgate stats',
79
79
  ' Cost proof : npx thumbgate cost',
80
80
  '',
81
- ` Solo Pro : ${PRO_PRICE_LABEL} for recall, dashboard, adapters, and exports`,
81
+ ` Solo Pro : ${PRO_PRICE_LABEL} for every learned rule, unlimited thumbs, recall, lesson search, and exports`,
82
82
  ` Upgrade : ${trackedProUrl('cli_capture_receipt', actionType || normalizedSignal.toLowerCase())}`,
83
83
  ` Enterprise : ${ENTERPRISE_PRICE_LABEL}; start with one repeated workflow failure`,
84
84
  ` ${ENTERPRISE_ENTRY_URL}`,
@@ -80,6 +80,7 @@ const {
80
80
  redactText,
81
81
  isSafeSecretStorageWrite,
82
82
  SAFE_SECRET_STORAGE_DIRS,
83
+ SECRET_FILE_PATTERNS,
83
84
  } = require('./secret-scanner');
84
85
  const {
85
86
  evaluateSecurityScan,
@@ -4250,12 +4251,24 @@ function evaluateGatesInner(toolName, toolInput, configPath, options = {}) {
4250
4251
  // Turn a secret-exfiltration block into actionable guidance that names the
4251
4252
  // safe path, instead of a dead-end that drives agents toward brittle
4252
4253
  // workarounds (e.g. writing secrets to /tmp). The vault dirs referenced here
4253
- // are the SAME constant the scanner whitelists, so the hint can never drift
4254
- // from enforcement.
4255
- function buildSecretRemediation(toolName = '', toolInput = {}) {
4256
- const vaultDirs = (SAFE_SECRET_STORAGE_DIRS || []).map((dir) => `~/${dir}`);
4257
- const primaryVault = vaultDirs[0] || '~/.resume_secrets';
4258
- const vaultList = vaultDirs.join(', ') || primaryVault;
4254
+ // come from the SAME constant the scanner whitelists, so the hint can never
4255
+ // drift from enforcement. `.resume_secrets` stays whitelisted for existing
4256
+ // installs but is a legacy, operator-specific name, so it is not advertised.
4257
+ const LEGACY_SECRET_STORAGE_DIRS = new Set(['.resume_secrets']);
4258
+ const SECRET_FILE_FINDING_IDS = new Set((SECRET_FILE_PATTERNS || []).map((pattern) => pattern.id));
4259
+
4260
+ function listAdvertisedVaultDirs() {
4261
+ const dirs = (SAFE_SECRET_STORAGE_DIRS || []).filter((dir) => !LEGACY_SECRET_STORAGE_DIRS.has(dir));
4262
+ return (dirs.length ? dirs : ['.thumbgate/secrets']).map((dir) => `~/${dir}`);
4263
+ }
4264
+
4265
+ function isSecretFileReadOnly(findings = []) {
4266
+ return findings.length > 0 && findings.every((finding) => SECRET_FILE_FINDING_IDS.has(finding.id));
4267
+ }
4268
+
4269
+ function buildSecretRemediation(toolName = '', toolInput = {}, findings = []) {
4270
+ const vaultDirs = listAdvertisedVaultDirs();
4271
+ const vaultList = vaultDirs.join(', ');
4259
4272
 
4260
4273
  if (EDIT_LIKE_TOOLS && EDIT_LIKE_TOOLS.has(toolName)) {
4261
4274
  const target = toolInput.file_path || toolInput.path || toolInput.filePath || toolInput.target_path;
@@ -4265,6 +4278,11 @@ function buildSecretRemediation(toolName = '', toolInput = {}) {
4265
4278
  + `Do not route around this by writing to /tmp or another path — that leaves the secret in a world-readable location and does not make it safe.`;
4266
4279
  }
4267
4280
 
4281
+ if (toolName === 'Bash' && isSecretFileReadOnly(findings)) {
4282
+ return `Do not print or send a credentials file — its contents would land in the session transcript and logs. `
4283
+ + `Let the code load those values at runtime (for example from environment variables), or ask the user which specific setting you need.`;
4284
+ }
4285
+
4268
4286
  if (toolName === 'Bash') {
4269
4287
  return `Do not inline a live secret literal into a shell command — it leaks into shell history and process args. `
4270
4288
  + `Instead, store the value with the Write tool to a file under ${vaultList}, then reference it via an environment variable or by reading that file at runtime.`;
@@ -4274,7 +4292,7 @@ function buildSecretRemediation(toolName = '', toolInput = {}) {
4274
4292
  }
4275
4293
 
4276
4294
  function buildSecretGuardResult(scanResult, context = {}) {
4277
- const remediation = buildSecretRemediation(context.toolName, context.toolInput || {});
4295
+ const remediation = buildSecretRemediation(context.toolName, context.toolInput || {}, scanResult.findings || []);
4278
4296
  const summary = buildSafeSummary(
4279
4297
  scanResult.findings,
4280
4298
  'Blocked because the action appears to expose secret material'
@@ -5078,7 +5096,7 @@ function buildBlockActionProCta() {
5078
5096
  return '\n\n💡 Pro: keep this rule searchable, exportable, and visible → thumbgate.ai/go/pro';
5079
5097
  }
5080
5098
  if (totalBlocks < 100) {
5081
- return `\n\n💡 ${totalBlocks} actions blocked. Pro adds recall, dashboard proof, and exports → thumbgate.ai/go/pro ($19/mo)`;
5099
+ return `\n\n💡 ${totalBlocks} actions blocked. Pro keeps every learned rule active and adds recall and exports → thumbgate.ai/go/pro ($19/mo)`;
5082
5100
  }
5083
5101
  return `\n\n💡 ${totalBlocks} mistakes caught. Your team could use Enterprise shared hosted enforcement → thumbgate.ai/go/pro`;
5084
5102
  } catch (_) {
@@ -34,9 +34,25 @@ function publishedHookCommandsAvailable(version) {
34
34
  return available;
35
35
  }
36
36
 
37
+ // A linked git worktree (or anything under .thumbgate-worktrees) is deleted after merge.
38
+ // A hook that points inside one breaks every tool call once it is gone (23 Nov 2026).
39
+ function isDisposableCheckout(root) {
40
+ const normalized = String(root).split(path.sep).join('/');
41
+ if (normalized.includes('/.thumbgate-worktrees/') || normalized.includes('/worktrees/')) return true;
42
+ try {
43
+ return fs.statSync(path.join(root, '.git')).isFile();
44
+ } catch {
45
+ return false;
46
+ }
47
+ }
48
+
37
49
  function resolveCliCommand(subcommand) {
38
- // Source checkout: always use direct node command for development
50
+ // Source checkout: direct node command for development, but never from a disposable
51
+ // worktree. Those get the stable launcher at ~/.thumbgate/bin/thumbgate-hook.
39
52
  if (isSourceCheckout(PKG_ROOT)) {
53
+ if (isDisposableCheckout(PKG_ROOT)) {
54
+ return `${shellQuote(shimPath())} ${subcommand}`;
55
+ }
40
56
  return `node ${shellQuote(path.join(PKG_ROOT, 'bin', 'cli.js'))} ${subcommand}`;
41
57
  }
42
58
  // Prefer stable shim — always resolves @latest, survives version bumps
@@ -153,4 +169,5 @@ module.exports = {
153
169
  statuslineCommand,
154
170
  userPromptHookCommand,
155
171
  cursorShellGateHookCommand,
172
+ isDisposableCheckout,
156
173
  };