thumbgate 1.4.2 → 1.4.4

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 (279) hide show
  1. package/.claude-plugin/README.md +45 -34
  2. package/.claude-plugin/marketplace.json +3 -3
  3. package/.claude-plugin/plugin.json +3 -3
  4. package/.well-known/llms.txt +1 -1
  5. package/.well-known/mcp/server-card.json +1 -1
  6. package/README.md +26 -2
  7. package/adapters/README.md +4 -1
  8. package/adapters/claude/.mcp.json +2 -2
  9. package/adapters/codex/config.toml +2 -2
  10. package/adapters/mcp/server-stdio.js +10 -4
  11. package/adapters/opencode/opencode.json +1 -1
  12. package/bin/cli.js +246 -90
  13. package/config/mcp-allowlists.json +11 -3
  14. package/package.json +184 -21
  15. package/scripts/audit-trail.js +25 -15
  16. package/scripts/auto-wire-hooks.js +127 -0
  17. package/scripts/cli-demo.js +102 -0
  18. package/scripts/cli-schema.js +285 -0
  19. package/scripts/cli-status.js +166 -0
  20. package/scripts/cross-encoder-reranker.js +235 -0
  21. package/scripts/explore-subcommands.js +277 -0
  22. package/scripts/explore.js +569 -0
  23. package/scripts/feedback-loop.js +20 -6
  24. package/scripts/lesson-inference.js +7 -1
  25. package/scripts/lesson-reranker.js +263 -0
  26. package/scripts/lesson-retrieval.js +34 -17
  27. package/scripts/lesson-search.js +69 -0
  28. package/scripts/perplexity-client.js +210 -0
  29. package/scripts/reflector-agent.js +2 -2
  30. package/scripts/statusline-local-stats.js +3 -1
  31. package/scripts/statusline.sh +12 -11
  32. package/src/api/server.js +178 -17
  33. package/src/index.js +3 -0
  34. package/.claude-plugin/bundle/icon.png +0 -0
  35. package/.claude-plugin/bundle/icon.svg +0 -18
  36. package/.claude-plugin/bundle/server/index.js +0 -24
  37. package/adapters/chatgpt/INSTALL.md +0 -138
  38. package/bin/memory.sh +0 -64
  39. package/bin/obsidian-sync.sh +0 -20
  40. package/plugins/amp-skill/INSTALL.md +0 -52
  41. package/plugins/amp-skill/SKILL.md +0 -64
  42. package/plugins/claude-codex-bridge/.claude-plugin/plugin.json +0 -22
  43. package/plugins/claude-codex-bridge/.mcp.json +0 -14
  44. package/plugins/claude-codex-bridge/INSTALL.md +0 -43
  45. package/plugins/claude-codex-bridge/README.md +0 -46
  46. package/plugins/claude-codex-bridge/scripts/codex-bridge.js +0 -286
  47. package/plugins/claude-codex-bridge/skills/adversarial-review/SKILL.md +0 -24
  48. package/plugins/claude-codex-bridge/skills/result/SKILL.md +0 -22
  49. package/plugins/claude-codex-bridge/skills/review/SKILL.md +0 -28
  50. package/plugins/claude-codex-bridge/skills/second-pass/SKILL.md +0 -27
  51. package/plugins/claude-codex-bridge/skills/setup/SKILL.md +0 -21
  52. package/plugins/claude-codex-bridge/skills/status/SKILL.md +0 -19
  53. package/plugins/claude-skill/INSTALL.md +0 -55
  54. package/plugins/claude-skill/SKILL.md +0 -46
  55. package/plugins/codex-profile/.codex-plugin/plugin.json +0 -43
  56. package/plugins/codex-profile/.mcp.json +0 -14
  57. package/plugins/codex-profile/AGENTS.md +0 -20
  58. package/plugins/codex-profile/INSTALL.md +0 -89
  59. package/plugins/codex-profile/README.md +0 -61
  60. package/plugins/cursor-marketplace/.cursor-plugin/plugin.json +0 -23
  61. package/plugins/cursor-marketplace/CHANGELOG.md +0 -30
  62. package/plugins/cursor-marketplace/LICENSE +0 -21
  63. package/plugins/cursor-marketplace/README.md +0 -124
  64. package/plugins/cursor-marketplace/agents/reliability-reviewer.md +0 -31
  65. package/plugins/cursor-marketplace/assets/logo-400x400.png +0 -0
  66. package/plugins/cursor-marketplace/commands/capture-feedback.md +0 -33
  67. package/plugins/cursor-marketplace/commands/check-gates.md +0 -25
  68. package/plugins/cursor-marketplace/commands/show-lessons.md +0 -27
  69. package/plugins/cursor-marketplace/hooks/hooks.json +0 -10
  70. package/plugins/cursor-marketplace/mcp.json +0 -14
  71. package/plugins/cursor-marketplace/rules/feedback-capture.mdc +0 -34
  72. package/plugins/cursor-marketplace/rules/pre-action-gates.mdc +0 -30
  73. package/plugins/cursor-marketplace/rules/session-continuity.mdc +0 -28
  74. package/plugins/cursor-marketplace/scripts/gate-check.sh +0 -21
  75. package/plugins/cursor-marketplace/skills/capture-feedback/SKILL.md +0 -48
  76. package/plugins/cursor-marketplace/skills/prevention-rules/SKILL.md +0 -31
  77. package/plugins/cursor-marketplace/skills/recall-context/SKILL.md +0 -30
  78. package/plugins/cursor-marketplace/skills/search-lessons/SKILL.md +0 -33
  79. package/plugins/gemini-extension/INSTALL.md +0 -92
  80. package/plugins/gemini-extension/gemini_prompt.txt +0 -14
  81. package/plugins/gemini-extension/tool_contract.json +0 -45
  82. package/plugins/opencode-profile/INSTALL.md +0 -57
  83. package/public/assets/instagram-card.png +0 -0
  84. package/public/assets/tiktok-agent-memory.mp4 +0 -0
  85. package/public/blog.html +0 -474
  86. package/public/compare/mem0.html +0 -189
  87. package/public/compare/speclock.html +0 -180
  88. package/public/compare.html +0 -310
  89. package/public/dashboard.html +0 -1100
  90. package/public/guide.html +0 -317
  91. package/public/guides/claude-code-prevent-repeated-mistakes.html +0 -161
  92. package/public/guides/codex-cli-guardrails.html +0 -158
  93. package/public/guides/cursor-prevent-repeated-mistakes.html +0 -161
  94. package/public/guides/pre-action-gates.html +0 -162
  95. package/public/guides/stop-repeated-ai-agent-mistakes.html +0 -159
  96. package/public/index.html +0 -1128
  97. package/public/js/buyer-intent.js +0 -252
  98. package/public/learn/agent-harness-pattern.html +0 -180
  99. package/public/learn/ai-agent-persistent-memory.html +0 -203
  100. package/public/learn/learn.css +0 -45
  101. package/public/learn/mcp-pre-action-gates-explained.html +0 -172
  102. package/public/learn/stop-ai-agent-force-push.html +0 -134
  103. package/public/learn/vibe-coding-safety-net.html +0 -142
  104. package/public/learn.html +0 -274
  105. package/public/lessons.html +0 -967
  106. package/public/llm-context.md +0 -140
  107. package/public/pro.html +0 -1087
  108. package/public/vercel.json +0 -8
  109. package/scripts/a2ui-engine.js +0 -73
  110. package/scripts/adk-consolidator.js +0 -274
  111. package/scripts/agent-security-hardening.js +0 -225
  112. package/scripts/ai-search-visibility.js +0 -142
  113. package/scripts/autonomous-sales-agent.js +0 -39
  114. package/scripts/autoresearch-runner.js +0 -216
  115. package/scripts/background-agent-governance.js +0 -229
  116. package/scripts/behavioral-extraction.js +0 -93
  117. package/scripts/budget-enforcer.js +0 -173
  118. package/scripts/budget-guard.js +0 -173
  119. package/scripts/build-claude-mcpb.js +0 -255
  120. package/scripts/build-codex-plugin.js +0 -152
  121. package/scripts/capture-railway-diagnostics.sh +0 -97
  122. package/scripts/changeset-check.js +0 -372
  123. package/scripts/check-congruence.js +0 -443
  124. package/scripts/computer-use-firewall.js +0 -280
  125. package/scripts/content-engine/linkedin-content-generator.js +0 -154
  126. package/scripts/content-engine/output/linkedin-memento-validation.md +0 -17
  127. package/scripts/content-engine/output/linkedin-posts-2026-04-09.md +0 -175
  128. package/scripts/content-engine/reddit-thread-finder.js +0 -154
  129. package/scripts/context-engine.js +0 -710
  130. package/scripts/daily-digest.js +0 -11
  131. package/scripts/data-governance.js +0 -173
  132. package/scripts/deploy-gcp.sh +0 -44
  133. package/scripts/deploy-policy.js +0 -249
  134. package/scripts/disagreement-mining.js +0 -315
  135. package/scripts/dpo-optimizer.js +0 -206
  136. package/scripts/ensure-repo-bootstrap.js +0 -130
  137. package/scripts/ephemeral-agent-store.js +0 -212
  138. package/scripts/eval-harness.js +0 -56
  139. package/scripts/export-kto-pairs.js +0 -309
  140. package/scripts/export-training.js +0 -446
  141. package/scripts/feedback-fallback.js +0 -111
  142. package/scripts/feedback-inbox-read.js +0 -162
  143. package/scripts/feedback-root-consolidator.js +0 -233
  144. package/scripts/feedback-to-memory.js +0 -185
  145. package/scripts/gate-satisfy.js +0 -42
  146. package/scripts/generate-paperbanana-diagrams.sh +0 -99
  147. package/scripts/generate-pretool-hook.sh +0 -40
  148. package/scripts/github-about.js +0 -430
  149. package/scripts/github-outreach.js +0 -65
  150. package/scripts/gtm-revenue-loop.js +0 -535
  151. package/scripts/hallucination-detector.js +0 -226
  152. package/scripts/hf-papers.js +0 -317
  153. package/scripts/hook-auto-capture.sh +0 -100
  154. package/scripts/hook-stop-pr-thread-check.sh +0 -68
  155. package/scripts/hook-stop-self-score.sh +0 -51
  156. package/scripts/hook-stop-verify-deploy.sh +0 -31
  157. package/scripts/hook-verify-before-done.sh +0 -20
  158. package/scripts/managed-dpo-export.js +0 -91
  159. package/scripts/markdown-escape.js +0 -12
  160. package/scripts/marketing-experiment.js +0 -657
  161. package/scripts/memalign-recall.js +0 -111
  162. package/scripts/memory-migration.js +0 -296
  163. package/scripts/meta-policy.js +0 -190
  164. package/scripts/metered-billing.js +0 -16
  165. package/scripts/model-tier-router.js +0 -310
  166. package/scripts/money-watcher.js +0 -218
  167. package/scripts/multi-hop-recall.js +0 -240
  168. package/scripts/per-step-scoring.js +0 -163
  169. package/scripts/perplexity-marketing.js +0 -466
  170. package/scripts/pii-scanner.js +0 -153
  171. package/scripts/plan-gate.js +0 -154
  172. package/scripts/post-everywhere.js +0 -341
  173. package/scripts/post-to-x-retry.sh +0 -22
  174. package/scripts/post-to-x.js +0 -369
  175. package/scripts/pr-manager.js +0 -421
  176. package/scripts/principle-extractor.js +0 -162
  177. package/scripts/pro-features.js +0 -41
  178. package/scripts/prompt-dlp.js +0 -222
  179. package/scripts/prove-adapters.js +0 -860
  180. package/scripts/prove-attribution.js +0 -361
  181. package/scripts/prove-automation.js +0 -651
  182. package/scripts/prove-autoresearch.js +0 -304
  183. package/scripts/prove-claim-verification.js +0 -277
  184. package/scripts/prove-cloudflare-sandbox.js +0 -161
  185. package/scripts/prove-data-pipeline.js +0 -408
  186. package/scripts/prove-data-quality.js +0 -227
  187. package/scripts/prove-evolution.js +0 -352
  188. package/scripts/prove-harnesses.js +0 -287
  189. package/scripts/prove-intelligence.js +0 -257
  190. package/scripts/prove-lancedb.js +0 -425
  191. package/scripts/prove-local-intelligence.js +0 -340
  192. package/scripts/prove-loop-closure.js +0 -263
  193. package/scripts/prove-packaged-runtime.js +0 -326
  194. package/scripts/prove-predictive-insights.js +0 -355
  195. package/scripts/prove-runtime.js +0 -363
  196. package/scripts/prove-seo-gsd.js +0 -234
  197. package/scripts/prove-settings.js +0 -279
  198. package/scripts/prove-subway-upgrades.js +0 -277
  199. package/scripts/prove-tessl.js +0 -229
  200. package/scripts/prove-training-export.js +0 -325
  201. package/scripts/prove-workflow-contract.js +0 -112
  202. package/scripts/prove-xmemory.js +0 -332
  203. package/scripts/publish-decision.js +0 -159
  204. package/scripts/ralph-loop.js +0 -376
  205. package/scripts/ralph-mode-ci.js +0 -331
  206. package/scripts/reddit-dm-outreach.js +0 -192
  207. package/scripts/reddit-monitor-cron.sh +0 -26
  208. package/scripts/reminder-engine.js +0 -132
  209. package/scripts/revenue-status.js +0 -472
  210. package/scripts/rotate-stripe-webhook-secret.js +0 -314
  211. package/scripts/schedule-manager.js +0 -249
  212. package/scripts/self-healing-check.js +0 -193
  213. package/scripts/shieldcortex-memory-firewall-runner.mjs +0 -53
  214. package/scripts/skill-exporter.js +0 -260
  215. package/scripts/skill-materializer.js +0 -134
  216. package/scripts/skill-packs.js +0 -136
  217. package/scripts/skill-proposer.js +0 -99
  218. package/scripts/skill-quality-tracker.js +0 -282
  219. package/scripts/slow-loop.js +0 -72
  220. package/scripts/social-analytics/db/analytics.sqlite +0 -0
  221. package/scripts/social-analytics/db/schema.sql +0 -32
  222. package/scripts/social-analytics/digest.js +0 -256
  223. package/scripts/social-analytics/engagement-audit.js +0 -185
  224. package/scripts/social-analytics/generate-instagram-card.js +0 -97
  225. package/scripts/social-analytics/instagram-thumbgate-post.js +0 -111
  226. package/scripts/social-analytics/install-growth-automation.js +0 -114
  227. package/scripts/social-analytics/load-env.js +0 -77
  228. package/scripts/social-analytics/mcp-server.js +0 -289
  229. package/scripts/social-analytics/normalizer.js +0 -580
  230. package/scripts/social-analytics/notify.js +0 -162
  231. package/scripts/social-analytics/poll-all.js +0 -107
  232. package/scripts/social-analytics/pollers/github.js +0 -195
  233. package/scripts/social-analytics/pollers/instagram.js +0 -253
  234. package/scripts/social-analytics/pollers/linkedin.js +0 -340
  235. package/scripts/social-analytics/pollers/plausible.js +0 -245
  236. package/scripts/social-analytics/pollers/reddit.js +0 -306
  237. package/scripts/social-analytics/pollers/threads.js +0 -233
  238. package/scripts/social-analytics/pollers/tiktok.js +0 -203
  239. package/scripts/social-analytics/pollers/x.js +0 -227
  240. package/scripts/social-analytics/pollers/youtube.js +0 -304
  241. package/scripts/social-analytics/pollers/zernio.js +0 -183
  242. package/scripts/social-analytics/publish-instagram-thumbgate.js +0 -104
  243. package/scripts/social-analytics/publish-thumbgate-launch.js +0 -322
  244. package/scripts/social-analytics/publishers/devto.js +0 -122
  245. package/scripts/social-analytics/publishers/instagram.js +0 -317
  246. package/scripts/social-analytics/publishers/linkedin.js +0 -294
  247. package/scripts/social-analytics/publishers/reddit.js +0 -385
  248. package/scripts/social-analytics/publishers/threads.js +0 -275
  249. package/scripts/social-analytics/publishers/tiktok.js +0 -217
  250. package/scripts/social-analytics/publishers/x.js +0 -259
  251. package/scripts/social-analytics/publishers/youtube.js +0 -223
  252. package/scripts/social-analytics/publishers/zernio.js +0 -539
  253. package/scripts/social-analytics/reconcile-thumbgate-campaign.js +0 -165
  254. package/scripts/social-analytics/run-digest.js +0 -34
  255. package/scripts/social-analytics/schedule-thumbgate-campaign.js +0 -275
  256. package/scripts/social-analytics/store.js +0 -455
  257. package/scripts/social-analytics/sync-launch-assets.js +0 -185
  258. package/scripts/social-analytics/utm.js +0 -143
  259. package/scripts/social-pipeline.js +0 -2626
  260. package/scripts/social-post-hourly.js +0 -228
  261. package/scripts/social-quality-gate.js +0 -134
  262. package/scripts/social-reply-monitor.js +0 -592
  263. package/scripts/status-dashboard.js +0 -155
  264. package/scripts/stripe-live-status.js +0 -115
  265. package/scripts/subagent-profiles.js +0 -79
  266. package/scripts/sync-branch-protection.js +0 -340
  267. package/scripts/sync-gh-secrets-from-env.sh +0 -70
  268. package/scripts/sync-github-about.js +0 -55
  269. package/scripts/sync-version.js +0 -479
  270. package/scripts/synthetic-dpo.js +0 -234
  271. package/scripts/tessl-export.js +0 -369
  272. package/scripts/test-coverage.js +0 -128
  273. package/scripts/thumbgate_session_start.sh +0 -32
  274. package/scripts/train_from_feedback.py +0 -929
  275. package/scripts/validate-feedback.js +0 -581
  276. package/scripts/verify-obsidian-setup.sh +0 -269
  277. package/scripts/verify-run.js +0 -269
  278. package/scripts/weekly-auto-post.js +0 -124
  279. package/scripts/x-autonomous-marketing.js +0 -139
package/bin/cli.js CHANGED
@@ -726,6 +726,18 @@ function capture() {
726
726
  if (result.accepted) {
727
727
  const ev = result.feedbackEvent;
728
728
  const mem = result.memoryRecord;
729
+
730
+ if (args.json) {
731
+ console.log(JSON.stringify({
732
+ ok: true,
733
+ signal: normalized,
734
+ feedbackId: ev.id,
735
+ memoryId: mem.id,
736
+ actionType: ev.actionType,
737
+ }, null, 2));
738
+ return;
739
+ }
740
+
729
741
  console.log(`\nFeedback Captured [${normalized.toUpperCase()}]`);
730
742
  console.log('─'.repeat(50));
731
743
  console.log(` Feedback ID : ${ev.id}`);
@@ -742,6 +754,14 @@ function capture() {
742
754
  console.log('');
743
755
  proNudge();
744
756
  } else {
757
+ if (args.json) {
758
+ console.log(JSON.stringify({
759
+ ok: false,
760
+ signal: normalized,
761
+ reason: result.reason,
762
+ }, null, 2));
763
+ process.exit(2);
764
+ }
745
765
  console.log(`\nFeedback Recorded [${normalized.toUpperCase()}] — not promoted`);
746
766
  console.log('─'.repeat(50));
747
767
  console.log(` Reason : ${result.reason}\n`);
@@ -751,23 +771,37 @@ function capture() {
751
771
 
752
772
  function stats() {
753
773
  trackEvent('cli_stats', { command: 'stats' });
774
+ const args = parseArgs(process.argv.slice(3));
754
775
  const { analyzeFeedback } = require(path.join(PKG_ROOT, 'scripts', 'feedback-loop'));
755
776
  const data = analyzeFeedback();
756
-
777
+
778
+ const avgCostOfMistake = 2.50;
779
+ const payload = {
780
+ total: data.total,
781
+ positives: data.totalPositive,
782
+ negatives: data.totalNegative,
783
+ approvalRate: Math.round(data.approvalRate * 100),
784
+ recentTrend: Math.round(data.recentRate * 100),
785
+ revenueAtRisk: Number((data.totalNegative * avgCostOfMistake).toFixed(2)),
786
+ topTags: data.topTags || [],
787
+ recentActivity: data.recentActivity || [],
788
+ };
789
+
790
+ if (args.json) {
791
+ console.log(JSON.stringify(payload, null, 2));
792
+ return;
793
+ }
794
+
757
795
  console.log('\n📊 ThumbGate Performance Metrics');
758
796
  console.log('─'.repeat(50));
759
- console.log(` Total Signals : ${data.total}`);
760
- console.log(` Approval Rate : ${Math.round(data.approvalRate * 100)}%`);
761
- console.log(` Recent Trend : ${Math.round(data.recentRate * 100)}%`);
762
-
763
- // The Pitch: Revenue-at-Risk
764
- const avgCostOfMistake = 2.50; // $2.50 per agent turn/fix
765
- const revenueAtRisk = (data.totalNegative * avgCostOfMistake).toFixed(2);
766
-
767
- if (data.totalNegative > 0) {
797
+ console.log(` Total Signals : ${payload.total}`);
798
+ console.log(` Approval Rate : ${payload.approvalRate}%`);
799
+ console.log(` Recent Trend : ${payload.recentTrend}%`);
800
+
801
+ if (payload.negatives > 0) {
768
802
  console.log('\n⚠️ REVENUE-AT-RISK ANALYSIS');
769
- console.log(` Repeated Failures detected: ${data.totalNegative}`);
770
- console.log(` Estimated Operational Loss: $${revenueAtRisk}`);
803
+ console.log(` Repeated Failures detected: ${payload.negatives}`);
804
+ console.log(` Estimated Operational Loss: $${payload.revenueAtRisk}`);
771
805
  console.log(' Action Required: Run "npx thumbgate rules" to generate guardrails.');
772
806
  console.log(' Strategic Recommendation: if this is a shared workflow problem, start the Workflow Hardening Sprint.');
773
807
  console.log(' Team intake: https://thumbgate-production.up.railway.app/#workflow-sprint-intake');
@@ -779,9 +813,15 @@ function stats() {
779
813
  }
780
814
 
781
815
  function compact() {
816
+ const args = parseArgs(process.argv.slice(3));
782
817
  const { compactMemories } = require(path.join(PKG_ROOT, 'scripts', 'feedback-loop'));
783
818
  const result = compactMemories();
784
819
 
820
+ if (args.json) {
821
+ console.log(JSON.stringify({ before: result.before, after: result.after, removed: result.removed }, null, 2));
822
+ return;
823
+ }
824
+
785
825
  console.log('\n🧹 Memory Compaction Complete');
786
826
  console.log('─'.repeat(50));
787
827
  console.log(` Before : ${result.before} memories`);
@@ -980,24 +1020,66 @@ function pro() {
980
1020
 
981
1021
  function summary() {
982
1022
  const args = parseArgs(process.argv.slice(3));
983
- const { feedbackSummary } = require(path.join(PKG_ROOT, 'scripts', 'feedback-loop'));
1023
+ const { feedbackSummary, analyzeFeedback } = require(path.join(PKG_ROOT, 'scripts', 'feedback-loop'));
1024
+ if (args.json) {
1025
+ const data = analyzeFeedback();
1026
+ console.log(JSON.stringify({
1027
+ total: data.total,
1028
+ positives: data.totalPositive,
1029
+ negatives: data.totalNegative,
1030
+ approvalRate: Math.round(data.approvalRate * 100),
1031
+ recentTrend: Math.round(data.recentRate * 100),
1032
+ }, null, 2));
1033
+ return;
1034
+ }
984
1035
  console.log(feedbackSummary(Number(args.recent || 20)));
985
1036
  }
986
1037
 
987
1038
  function lessons() {
988
1039
  trackEvent('cli_recall', { command: 'lessons' });
989
1040
  const args = parseArgs(process.argv.slice(3));
1041
+ const tags = String(args.tags || '').split(',').map((t) => t.trim()).filter(Boolean);
1042
+ const query = args.query || process.argv.slice(3).find((a) => !a.startsWith('--')) || '';
1043
+ const limit = Number(args.limit || 10);
1044
+
1045
+ // --remote: fetch from hosted Railway instance
1046
+ if (args.remote) {
1047
+ const apiBase = process.env.THUMBGATE_API_URL || PRO_URL;
1048
+ const params = new URLSearchParams({ q: query, limit: String(limit) });
1049
+ if (args.category) params.set('category', args.category);
1050
+ if (tags.length) params.set('tags', tags.join(','));
1051
+ const url = `${apiBase}/v1/lessons/search?${params}`;
1052
+ const mod = url.startsWith('https') ? require('https') : require('http');
1053
+ let body = '';
1054
+ const req = mod.get(url, { timeout: 8000 }, (res) => {
1055
+ res.on('data', (chunk) => { body += chunk; });
1056
+ res.on('end', () => {
1057
+ try {
1058
+ const result = JSON.parse(body);
1059
+ if (args.json) {
1060
+ console.log(JSON.stringify(result, null, 2));
1061
+ } else {
1062
+ const { formatLessonSearchResults } = require(path.join(PKG_ROOT, 'scripts', 'lesson-search'));
1063
+ process.stdout.write(`[remote: ${apiBase}]\n`);
1064
+ process.stdout.write(formatLessonSearchResults(result));
1065
+ }
1066
+ } catch {
1067
+ process.stderr.write(`Error parsing remote response: ${body.slice(0, 200)}\n`);
1068
+ process.exit(1);
1069
+ }
1070
+ });
1071
+ });
1072
+ req.on('error', (err) => {
1073
+ process.stderr.write(`Remote fetch failed: ${err.message}\n`);
1074
+ process.exit(1);
1075
+ });
1076
+ req.on('timeout', () => { req.destroy(); process.stderr.write('Remote fetch timed out\n'); process.exit(1); });
1077
+ return;
1078
+ }
1079
+
1080
+ // --local (default)
990
1081
  const { searchLessons, formatLessonSearchResults } = require(path.join(PKG_ROOT, 'scripts', 'lesson-search'));
991
- const tags = String(args.tags || '')
992
- .split(',')
993
- .map((tag) => tag.trim())
994
- .filter(Boolean);
995
- const query = args.query || process.argv.slice(3).find((arg) => !arg.startsWith('--')) || '';
996
- const result = searchLessons(query, {
997
- limit: Number(args.limit || 10),
998
- category: args.category,
999
- tags,
1000
- });
1082
+ const result = searchLessons(query, { limit, category: args.category, tags });
1001
1083
 
1002
1084
  if (args.json) {
1003
1085
  console.log(JSON.stringify(result, null, 2));
@@ -1214,6 +1296,16 @@ function rules() {
1214
1296
  const { writePreventionRules } = require(path.join(PKG_ROOT, 'scripts', 'feedback-loop'));
1215
1297
  const outPath = args.output || path.join(CWD, '.thumbgate', 'prevention-rules.md');
1216
1298
  const result = writePreventionRules(outPath, Number(args.min || 2));
1299
+ if (args.json) {
1300
+ // Count rule sections (## headers) from the generated markdown
1301
+ const ruleHeaders = (result.markdown || '').match(/^## /gm);
1302
+ console.log(JSON.stringify({
1303
+ ok: true,
1304
+ path: result.path,
1305
+ rulesWritten: ruleHeaders ? ruleHeaders.length : 0,
1306
+ }, null, 2));
1307
+ return;
1308
+ }
1217
1309
  console.log(`Wrote prevention rules to ${result.path}`);
1218
1310
  }
1219
1311
 
@@ -1256,15 +1348,14 @@ function watchCmd() {
1256
1348
  }
1257
1349
 
1258
1350
  function status() {
1259
- const statusDashboard = require(path.join(PKG_ROOT, 'scripts', 'status-dashboard'));
1260
- const { getFeedbackPaths } = require(path.join(PKG_ROOT, 'scripts', 'feedback-loop'));
1261
- const { FEEDBACK_DIR } = getFeedbackPaths();
1262
- const data = statusDashboard.generateStatus(FEEDBACK_DIR);
1263
- // printDashboard writes directly to stdout when run as main;
1264
- // for CLI we call the same renderer
1265
- statusDashboard.printDashboard
1266
- ? statusDashboard.printDashboard(data)
1267
- : console.log(JSON.stringify(data, null, 2));
1351
+ const args = parseArgs(process.argv.slice(3));
1352
+ const { generateAgentStatus, formatStatus } = require(path.join(PKG_ROOT, 'scripts', 'cli-status'));
1353
+ const data = generateAgentStatus({ pkgRoot: PKG_ROOT, projectDir: CWD });
1354
+ if (args.json) {
1355
+ console.log(JSON.stringify(data, null, 2));
1356
+ return;
1357
+ }
1358
+ process.stdout.write(formatStatus(data));
1268
1359
  }
1269
1360
 
1270
1361
  function funnel() {
@@ -1473,8 +1564,14 @@ function dashboard() {
1473
1564
  }
1474
1565
 
1475
1566
  function gateStats() {
1567
+ const args = parseArgs(process.argv.slice(3));
1476
1568
  const { calculateStats, formatStats } = require(path.join(PKG_ROOT, 'scripts', 'gate-stats'));
1477
1569
  const stats = calculateStats();
1570
+ if (args.json) {
1571
+ const { gates, ...summary } = stats;
1572
+ console.log(JSON.stringify(args.verbose ? stats : summary, null, 2));
1573
+ return;
1574
+ }
1478
1575
  console.log('\n' + formatStats(stats) + '\n');
1479
1576
  }
1480
1577
 
@@ -1489,71 +1586,83 @@ function startApi() {
1489
1586
 
1490
1587
  function help() {
1491
1588
  const v = pkgVersion();
1492
- console.log(`thumbgate v${v}`);
1589
+ const { groupedCommands, commandHelpLine } = require(path.join(PKG_ROOT, 'scripts', 'cli-schema'));
1590
+ const groups = groupedCommands();
1591
+ const GROUP_LABELS = {
1592
+ capture: 'Feedback capture',
1593
+ discovery: 'Discovery & inspection',
1594
+ gates: 'Gates & rules',
1595
+ export: 'Export',
1596
+ ops: 'Operations',
1597
+ advanced: 'Advanced',
1598
+ };
1599
+
1600
+ console.log(`thumbgate v${v} — pre-action gates for AI coding agents`);
1601
+ console.log('');
1602
+
1603
+ for (const [groupKey, label] of Object.entries(GROUP_LABELS)) {
1604
+ const cmds = groups[groupKey];
1605
+ if (!cmds || cmds.length === 0) continue;
1606
+ console.log(`${label}:`);
1607
+ for (const cmd of cmds) {
1608
+ console.log(commandHelpLine(cmd));
1609
+ }
1610
+ console.log('');
1611
+ }
1612
+
1613
+ // Internal / hook commands (called by agent runtime, not operator-facing schema).
1614
+ console.log('Internal hooks (called by agent runtime):');
1615
+ console.log(' gate-check Evaluate PreToolUse payload from stdin -> ALLOW/BLOCK');
1616
+ console.log(' cache-update Refresh Claude statusline cache from stdin');
1617
+ console.log(' statusline-render Render ThumbGate Claude status line');
1618
+ console.log(' hook-auto-capture Process Claude UserPromptSubmit inline feedback');
1619
+ console.log(' session-start Refresh local ThumbGate session cache');
1493
1620
  console.log('');
1494
- console.log('Commands:');
1495
- console.log(' init Scaffold .thumbgate/ config + MCP server in current project');
1496
- console.log(' --agent=NAME Wire PreToolUse hooks for agent (claude-code|codex|gemini|forge)');
1497
- console.log(' --wire-hooks Wire hooks only (auto-detect agent, skip scaffolding)');
1498
- console.log(' --dry-run Preview hook changes without writing');
1499
- console.log(' install-mcp Install ThumbGate MCP server into Claude Code settings (--project for local)');
1500
- console.log(' serve Start MCP server (stdio) — for claude/codex/gemini/forge mcp add');
1501
- console.log(' gate-check Internal: evaluate a PreToolUse payload from stdin');
1502
- console.log(' cache-update Internal: refresh the Claude statusline cache from stdin');
1503
- console.log(' statusline-render Internal: render the ThumbGate Claude status line');
1504
- console.log(' hook-auto-capture Internal: process Claude UserPromptSubmit feedback');
1505
- console.log(' session-start Internal: refresh local ThumbGate session cache');
1506
- console.log(' capture [flags] Capture feedback (--feedback=up|down --context="..." --tags="...")');
1507
- console.log(' stats Show feedback analytics + Revenue-at-Risk');
1508
- console.log(' cfo Show hosted billing summary when configured, else local fallback JSON');
1621
+
1622
+ // Legacy and specialist commands kept visible until they graduate into the schema.
1623
+ console.log('Also available:');
1624
+ console.log(' install-mcp Install MCP server into Claude Code settings (--project for local)');
1625
+ console.log(' cfo Hosted billing summary (local fallback JSON)');
1509
1626
  console.log(' billing:setup Generate operator key + print Railway setup instructions');
1510
- console.log(' repair-github-marketplace Dry-run or apply legacy GitHub Marketplace amount repairs (--write)');
1627
+ console.log(' repair-github-marketplace Repair legacy GitHub Marketplace amount mappings');
1511
1628
  console.log(' north-star Show proof-backed workflow-run progress toward the North Star');
1512
- console.log(' summary Human-readable feedback summary');
1513
- console.log(' lessons [flags] Search promoted lessons and show linked corrective actions');
1514
- console.log(' model-fit Detect the current local embedding profile and write evidence report');
1515
- console.log(' risk [flags] Train or query the boosted local risk scorer');
1516
- console.log(' doctor Audit runtime isolation, bootstrap context, and permission tier');
1517
- console.log(' dispatch Print a Dispatch-safe remote ops brief for phone-driven review sessions');
1518
- console.log(' import-doc Import a local policy/runbook and propose reviewable gate candidates');
1519
- console.log(' export-dpo Export DPO training pairs (prompt/chosen/rejected JSONL)');
1520
- console.log(' export-databricks Export feedback logs + proof artifacts as a Databricks-ready analytics bundle');
1521
- console.log(' obsidian-export Export all feedback data as interlinked Obsidian markdown notes');
1522
- console.log(' --vault-path=PATH Obsidian vault path (or set THUMBGATE_OBSIDIAN_VAULT_PATH)');
1523
- console.log(' --output-dir=DIR Output subdirectory (default: AI-Memories/thumbgate)');
1524
- console.log(' rules Generate prevention rules from repeated failures');
1525
- console.log(' optimize [PRO] Prune CLAUDE.md and migrate manual rules to Pre-Action Gates');
1526
- console.log(' force-gate <PATTERN> Immediately create a blocking gate from a pattern');
1527
- console.log(' meta-agent Run meta-agent loop: generate + evaluate + promote prevention rules');
1528
- console.log(' --dry-run Preview rules without writing');
1529
- console.log(' --status Show last run summary');
1530
- console.log(' self-heal Run self-healing check and auto-fix');
1531
- console.log(' activate <KEY> Activate a Pro license key (from Stripe checkout)');
1532
- console.log(' pro Show Pro plan ($19/mo) + hosted pilot info');
1533
- console.log(' --upgrade Install Pro configs into .thumbgate/');
1534
- console.log(' prove [--target=X] Run proof harness (adapters|automation|attribution|lancedb|local-intelligence|...)');
1535
- console.log(' watch [flags] Watch .thumbgate/ for external signals and ingest through pipeline (--once, --source=X)');
1536
- console.log(' status Show feedback tracking dashboard — approval trend + failure domains');
1537
- console.log(' dashboard Full ThumbGate dashboard — approval rate, gate stats, prevention impact');
1538
- console.log(' funnel Show marketing & revenue conversion funnel analytics');
1539
- console.log(' pulse Show real-time GTM velocity and Mission Control summary');
1540
- console.log(' dispatch Dispatch-safe brief — metrics, gates, and read-only prompt templates');
1541
- console.log(' gate-check PreToolUse hook: reads tool JSON from stdin, outputs gate verdict');
1542
- console.log(' gate-stats Show gate statistics — active gates, blocks, warns, time saved');
1543
- console.log(' analytics Unified ThumbGate analytics snapshot (npm, GitHub, landing page)');
1629
+ console.log(' model-fit Detect local embedding profile and write evidence report');
1630
+ console.log(' risk Train or query the boosted local risk scorer');
1631
+ console.log(' optimize [PRO] Prune CLAUDE.md and migrate rules to Pre-Action Gates');
1632
+ console.log(' prove [--target=X] Run proof harness (adapters|automation|...)');
1633
+ console.log(' watch Watch .thumbgate/ for external signals');
1634
+ console.log(' status Approval trend + failure domain dashboard');
1635
+ console.log(' funnel Marketing and revenue conversion funnel analytics');
1636
+ console.log(' pulse Real-time GTM velocity and Mission Control summary');
1637
+ console.log(' dispatch Dispatch-safe brief for phone-driven review sessions');
1638
+ console.log(' analytics Unified analytics snapshot (npm, GitHub, landing)');
1544
1639
  console.log(' start-api Start the ThumbGate HTTPS API server');
1545
- console.log(' help Show this help message');
1546
1640
  console.log('');
1641
+
1642
+ console.log('Global flags (all commands):');
1643
+ console.log(' --json Output as machine-readable JSON');
1644
+ console.log(' --local Use local storage (default for most commands)');
1645
+ console.log(' --remote Fetch from hosted Railway instance');
1646
+ console.log('');
1647
+
1648
+ console.log('Explore subcommands (non-interactive):');
1649
+ console.log(' explore lessons [--json] [--limit=N] List lessons with confidence badges');
1650
+ console.log(' explore rules [--json] List prevention rules');
1651
+ console.log(' explore gates [--json] List gates with action badges');
1652
+ console.log(' explore firings [--json] [--limit=N] List recent gate firings');
1653
+ console.log('');
1654
+
1547
1655
  console.log('Examples:');
1548
1656
  console.log(' npx thumbgate init');
1549
- console.log(' npx thumbgate stats');
1550
- console.log(' npx thumbgate cfo');
1551
- console.log(' npx thumbgate import-doc docs/release-policy.md --json');
1552
- console.log(' npx thumbgate repair-github-marketplace --write');
1553
- console.log(' npx thumbgate lessons --query="verification" --limit=5');
1554
- console.log(' npx thumbgate model-fit');
1555
- console.log(' npx thumbgate risk');
1556
- console.log(' npx thumbgate pro');
1657
+ console.log(' npx thumbgate status --json');
1658
+ console.log(' npx thumbgate explore lessons --json');
1659
+ console.log(' npx thumbgate explore gates --json');
1660
+ console.log(' npx thumbgate demo');
1661
+ console.log(' npx thumbgate stats --json');
1662
+ console.log(' npx thumbgate lessons "force push" --json');
1663
+ console.log(' npx thumbgate lessons --query="deploy" --remote');
1664
+ console.log(' npx thumbgate gate-stats --json');
1665
+ console.log(' npx thumbgate capture --feedback=down --context="agent broke deploy" --json');
1557
1666
  proNudge();
1558
1667
  }
1559
1668
 
@@ -1822,6 +1931,53 @@ switch (COMMAND) {
1822
1931
  case 'gate-stats':
1823
1932
  gateStats();
1824
1933
  break;
1934
+ case 'explore': {
1935
+ const subCmd = process.argv[3];
1936
+ const exploreArgs = parseArgs(process.argv.slice(3));
1937
+ // If a known subcommand is given (or --json), use non-interactive mode
1938
+ const knownSubs = ['lessons', 'rules', 'gates', 'firings'];
1939
+ if (knownSubs.includes(subCmd) || exploreArgs.json) {
1940
+ const { exploreLessons, exploreRules, exploreGates, exploreGateFirings } = require(path.join(PKG_ROOT, 'scripts', 'explore-subcommands'));
1941
+ const { getFeedbackPaths } = require(path.join(PKG_ROOT, 'scripts', 'feedback-loop'));
1942
+ const { FEEDBACK_DIR } = getFeedbackPaths();
1943
+ const subOptions = {
1944
+ feedbackDir: FEEDBACK_DIR,
1945
+ pkgRoot: PKG_ROOT,
1946
+ limit: Number(exploreArgs.limit || 20),
1947
+ json: Boolean(exploreArgs.json),
1948
+ };
1949
+ const effectiveSub = knownSubs.includes(subCmd) ? subCmd : 'lessons';
1950
+ let output;
1951
+ switch (effectiveSub) {
1952
+ case 'lessons': output = exploreLessons(subOptions); break;
1953
+ case 'rules': output = exploreRules(subOptions); break;
1954
+ case 'gates': output = exploreGates(subOptions); break;
1955
+ case 'firings': output = exploreGateFirings(subOptions); break;
1956
+ default: output = exploreLessons(subOptions); break;
1957
+ }
1958
+ if (exploreArgs.json) {
1959
+ console.log(JSON.stringify(output, null, 2));
1960
+ } else {
1961
+ process.stdout.write(output);
1962
+ }
1963
+ } else {
1964
+ // No subcommand and no --json → launch interactive TUI
1965
+ const { run: runExplore } = require(path.join(PKG_ROOT, 'scripts', 'explore'));
1966
+ runExplore();
1967
+ }
1968
+ break;
1969
+ }
1970
+ case 'demo': {
1971
+ const demoArgs = parseArgs(process.argv.slice(3));
1972
+ const { runDemo } = require(path.join(PKG_ROOT, 'scripts', 'cli-demo'));
1973
+ const demoOutput = runDemo({ json: Boolean(demoArgs.json) });
1974
+ if (demoArgs.json) {
1975
+ console.log(JSON.stringify(demoOutput, null, 2));
1976
+ } else {
1977
+ process.stdout.write(demoOutput);
1978
+ }
1979
+ break;
1980
+ }
1825
1981
  case 'dashboard':
1826
1982
  dashboard();
1827
1983
  break;
@@ -51,7 +51,11 @@
51
51
  "capture_memory_feedback",
52
52
  "get_reliability_rules",
53
53
  "describe_reliability_entity",
54
- "report_product_issue"
54
+ "report_product_issue",
55
+ "perplexity_search",
56
+ "perplexity_ask",
57
+ "perplexity_research",
58
+ "perplexity_reason"
55
59
  ],
56
60
  "essential": [
57
61
  "capture_feedback",
@@ -124,7 +128,9 @@
124
128
  "get_business_metrics",
125
129
  "describe_semantic_entity",
126
130
  "get_reliability_rules",
127
- "describe_reliability_entity"
131
+ "describe_reliability_entity",
132
+ "perplexity_search",
133
+ "perplexity_ask"
128
134
  ],
129
135
  "dispatch": [
130
136
  "recall",
@@ -151,7 +157,9 @@
151
157
  "get_business_metrics",
152
158
  "describe_semantic_entity",
153
159
  "get_reliability_rules",
154
- "describe_reliability_entity"
160
+ "describe_reliability_entity",
161
+ "perplexity_search",
162
+ "perplexity_ask"
155
163
  ],
156
164
  "locked": [
157
165
  "feedback_summary",