thumbgate 1.39.1 → 1.40.2

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 (199) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.well-known/llms.txt +2 -2
  3. package/.well-known/mcp/server-card.json +1 -1
  4. package/README.md +5 -4
  5. package/adapters/claude/.mcp.json +6 -2
  6. package/adapters/codex/config.toml +5 -0
  7. package/adapters/forge/forge.yaml +4 -4
  8. package/adapters/future-agi/.mcp.json +1 -1
  9. package/adapters/future-agi/config.toml +1 -1
  10. package/adapters/future-agi/opencode.json +1 -1
  11. package/adapters/herdr/herdr-plugin.toml +2 -2
  12. package/adapters/mcp/server-stdio.js +82 -7
  13. package/adapters/opencode/opencode.json +1 -1
  14. package/bin/cli.js +128 -15
  15. package/config/brand-standards.json +131 -0
  16. package/config/gates/default.json +18 -1
  17. package/config/github-about.json +1 -1
  18. package/config/mcp-allowlists.json +16 -3
  19. package/config/merge-quality-checks.json +1 -0
  20. package/config/post-deploy-marketing-pages.json +3 -3
  21. package/config/schemas/task-outcome-receipt.schema.json +9 -0
  22. package/openapi/openapi.yaml +7 -3
  23. package/package.json +98 -31
  24. package/public/about.html +2 -2
  25. package/public/admin.html +771 -0
  26. package/public/agent-manager.html +3 -3
  27. package/public/agents-cost-savings.html +1 -1
  28. package/public/ai-malpractice-prevention.html +12 -12
  29. package/public/architecture.html +0 -1
  30. package/public/assets/diagrams/decision.svg +3 -3
  31. package/public/blog/2026-10-05-why-3-days-of-triage-wont-save-ai-speed-code.html +1 -1
  32. package/public/blog/2026-10-09-your-code-got-a-third-author-governance.html +1 -1
  33. package/public/blog/git-at-agent-scale.html +2 -2
  34. package/public/blog/inside-your-boundary.html +1 -1
  35. package/public/blog/process-over-outcome-gates.html +1 -1
  36. package/public/case-studies.html +1 -2
  37. package/public/codex-enterprise.html +1 -1
  38. package/public/codex-plugin.html +1 -1
  39. package/public/dashboard.html +773 -481
  40. package/public/diagnostic.html +8 -3
  41. package/public/enterprise-governance.html +26 -174
  42. package/public/eval-scorecard.html +3 -4
  43. package/public/eval-scorecard.json +2 -2
  44. package/public/evaluations.html +0 -1
  45. package/public/founders.html +3 -3
  46. package/public/gaming-playbook.html +4 -4
  47. package/public/guide.html +3 -5
  48. package/public/index.html +181 -205
  49. package/public/install.html +12 -11
  50. package/public/js/buyer-intent.js +49 -8
  51. package/public/lessons.html +103 -46
  52. package/public/numbers.html +32 -33
  53. package/public/operator-framework.html +44 -72
  54. package/public/peter.html +3 -3
  55. package/public/platform-partners.html +1 -1
  56. package/public/pricing.html +61 -327
  57. package/public/pro.html +3 -1
  58. package/public/project-switcher.js +76 -0
  59. package/public/whitepaper.html +1 -2
  60. package/scripts/activation-quickstart.js +15 -3
  61. package/scripts/activation-tracker.js +280 -3
  62. package/scripts/agent-action-inventory.js +235 -143
  63. package/scripts/agent-operations-planner.js +1 -1
  64. package/scripts/agent-readiness.js +36 -6
  65. package/scripts/agentic-prompt-pipelines.js +901 -0
  66. package/scripts/analytics-report.js +363 -0
  67. package/scripts/analytics-window.js +7 -1
  68. package/scripts/async-job-runner.js +66 -11
  69. package/scripts/audit-trail.js +37 -24
  70. package/scripts/auto-context-packs.js +249 -0
  71. package/scripts/auto-promote-gates.js +37 -27
  72. package/scripts/backfill-lesson-scopes.js +122 -0
  73. package/scripts/billing-setup.js +137 -0
  74. package/scripts/billing.js +889 -132
  75. package/scripts/bot-detection.js +112 -0
  76. package/scripts/brand-standards-gate.js +571 -0
  77. package/scripts/chatgpt-ads-readiness-pack.js +1 -1
  78. package/scripts/check-update.js +236 -0
  79. package/scripts/cli-schema.js +1 -1
  80. package/scripts/commercial-offer.js +2 -2
  81. package/scripts/contextfs.js +9 -3
  82. package/scripts/conversion-rate-stats.js +442 -0
  83. package/scripts/cost-cli.js +147 -0
  84. package/scripts/creator-campaigns.js +239 -0
  85. package/scripts/cross-encoder-reranker.js +4 -0
  86. package/scripts/cuda-gate-batch.js +560 -0
  87. package/scripts/daemon-manager.js +108 -0
  88. package/scripts/dashboard-chat.js +11 -0
  89. package/scripts/dashboard.js +576 -169
  90. package/scripts/decision-journal.js +7 -4
  91. package/scripts/delegation-runtime.js +1036 -0
  92. package/scripts/dispatch-brief.js +159 -0
  93. package/scripts/distribution-surfaces.js +110 -0
  94. package/scripts/docker-sandbox-planner.js +3 -3
  95. package/scripts/egm-goldfish-packet.js +95 -0
  96. package/scripts/embeddinggemma-adapter.js +407 -0
  97. package/scripts/export-dpo-pairs.js +12 -7
  98. package/scripts/feedback-aggregate.js +4 -0
  99. package/scripts/feedback-attribution.js +6 -4
  100. package/scripts/feedback-history-distiller.js +18 -6
  101. package/scripts/feedback-loop.js +255 -89
  102. package/scripts/feedback-paths.js +8 -1
  103. package/scripts/feedback-sanitizer.js +5 -0
  104. package/scripts/feedback-scope.js +106 -0
  105. package/scripts/feedback-session.js +8 -2
  106. package/scripts/filesystem-search.js +13 -8
  107. package/scripts/financial-control-plane.js +707 -45
  108. package/scripts/funnel-analytics.js +35 -0
  109. package/scripts/gate-semantic-layer.js +292 -0
  110. package/scripts/gate-stats.js +8 -2
  111. package/scripts/gates-engine.js +694 -230
  112. package/scripts/generate-eval-scorecard.js +0 -1
  113. package/scripts/harness-tool-names.js +31 -5
  114. package/scripts/hybrid-feedback-context.js +5 -2
  115. package/scripts/implementation-notes.js +241 -0
  116. package/scripts/intent-router.js +518 -0
  117. package/scripts/intervention-policy.js +2 -1
  118. package/scripts/latency-budget.js +164 -0
  119. package/scripts/lesson-canonical.js +2 -2
  120. package/scripts/lesson-db.js +55 -14
  121. package/scripts/lesson-graph.js +2 -1
  122. package/scripts/lesson-retrieval.js +95 -9
  123. package/scripts/lesson-search.js +86 -22
  124. package/scripts/lesson-synthesis.js +21 -5
  125. package/scripts/mailer/index.js +17 -1
  126. package/scripts/mailer/resend-mailer.js +213 -179
  127. package/scripts/mcp-writeguard.js +158 -0
  128. package/scripts/migrate-project-scope.js +209 -0
  129. package/scripts/model-candidates.js +414 -0
  130. package/scripts/openrouter-armor-partnership-diode.js +2419 -0
  131. package/scripts/operational-dashboard.js +172 -0
  132. package/scripts/operational-integrity.js +436 -3
  133. package/scripts/operational-summary.js +190 -0
  134. package/scripts/operator-artifacts.js +622 -0
  135. package/scripts/optimize-context.js +17 -0
  136. package/scripts/override-audit.js +2 -0
  137. package/scripts/owner-admin.js +338 -0
  138. package/scripts/pr-manager.js +194 -1
  139. package/scripts/predictive-insights.js +449 -0
  140. package/scripts/profound-aeo-citation-engine.js +583 -0
  141. package/scripts/progressive-signoff.js +260 -0
  142. package/scripts/project-catalog.js +243 -0
  143. package/scripts/project-dashboard.js +61 -0
  144. package/scripts/project-evidence.js +172 -0
  145. package/scripts/project-identity.js +182 -0
  146. package/scripts/project-scope.js +381 -0
  147. package/scripts/prompt-guard.js +446 -52
  148. package/scripts/proof-report.js +232 -0
  149. package/scripts/provider-action-normalizer.js +14 -6
  150. package/scripts/pulse.js +80 -0
  151. package/scripts/rate-limiter.js +41 -0
  152. package/scripts/rrsi-doctor.js +2698 -0
  153. package/scripts/secret-redaction.js +171 -25
  154. package/scripts/secret-scanner.js +101 -42
  155. package/scripts/self-protection.js +2 -2
  156. package/scripts/seo-gsd.js +14 -14
  157. package/scripts/session-context-dedupe.js +66 -0
  158. package/scripts/session-report.js +120 -0
  159. package/scripts/settings-hierarchy.js +4 -2
  160. package/scripts/statusline-meta.js +34 -23
  161. package/scripts/subagent-profiles.js +79 -0
  162. package/scripts/task-outcomes.js +29 -2
  163. package/scripts/telemetry-analytics.js +238 -13
  164. package/scripts/third-author-cli.js +118 -0
  165. package/scripts/third-author-governance.js +437 -0
  166. package/scripts/thumbgate-dream.js +878 -0
  167. package/scripts/thumbgate-search.js +23 -9
  168. package/scripts/tool-kpi-tracker.js +5 -2
  169. package/scripts/tool-registry.js +42 -1
  170. package/scripts/triage-savings-calculator.js +1 -1
  171. package/scripts/vector-store.js +4 -1
  172. package/scripts/verified-lessons.js +270 -0
  173. package/scripts/verify-marketing-pages-deployed.js +2 -2
  174. package/scripts/workflow-sentinel.js +29 -10
  175. package/server.json +2 -2
  176. package/skills/thumbgate-daily-discoveries/SKILL.md +25 -41
  177. package/src/api/server.js +2371 -451
  178. package/src/feedback.js +21 -0
  179. package/src/hermes-sync-plane.js +2 -1
  180. package/src/index.js +2 -0
  181. package/src/lesson-search.js +9 -0
  182. package/src/mckinsey-top-company-ai-coding.js +493 -0
  183. package/src/mcp/server.js +3 -0
  184. package/src/mcp-writeguard.js +772 -11
  185. package/src/openshell-lovable-engine.js +1475 -0
  186. package/src/task-outcome.js +3 -0
  187. package/config/evals/agent-safety-eval.json +0 -447
  188. package/config/evals/retrieval-ranking-golden.json +0 -522
  189. package/config/progressive/01-wire-only.json +0 -11
  190. package/config/progressive/02-dashboard-empty-ok.json +0 -10
  191. package/config/progressive/03-one-lesson.json +0 -10
  192. package/config/progressive/04-warn-fires.json +0 -11
  193. package/config/progressive/05-strict-optional.json +0 -11
  194. package/config/progressive/README.md +0 -15
  195. package/public/assets/diagrams/agent-integration.png +0 -0
  196. package/public/assets/diagrams/thumbgate-architecture.png +0 -0
  197. package/scripts/install-thumbgate-daily-publish-launchd.sh +0 -83
  198. package/scripts/thumbgate-daily-discoveries-publish.js +0 -461
  199. package/scripts/thumbgate-daily-discoveries-publish.sh +0 -18
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /**
5
+ * backfill-lesson-scopes.js — Backfill project-level scopes and demote transport blobs
6
+ * in memory logs.
7
+ *
8
+ * Implements Item 1 of the Dual-Model MoA & Agentic GraphRAG Playbook brief:
9
+ * "Give each lesson a fixed-schema scope at capture time (project/repo from cwd and git remote,
10
+ * plus tool and failure class), and backfill existing lessons from their text where the project is clear."
11
+ */
12
+
13
+ const fs = require('node:fs');
14
+ const path = require('node:path');
15
+ const { getFeedbackPaths, readJSONL } = require('./feedback-loop');
16
+ const { inferProjectFromLesson, isTranscriptShaped } = require('./project-scope');
17
+
18
+ function backfillMemoryLog(filePath, options = {}) {
19
+ const targetPath = filePath || getFeedbackPaths().MEMORY_LOG_PATH;
20
+ if (!fs.existsSync(targetPath)) {
21
+ return { ok: false, reason: `File not found: ${targetPath}` };
22
+ }
23
+
24
+ const records = readJSONL(targetPath, { maxLines: 0 });
25
+ let modifiedCount = 0;
26
+ let demotedTranscripts = 0;
27
+ const projectCounts = {};
28
+
29
+ const updatedRecords = records.map((record) => {
30
+ if (!record || typeof record !== 'object') return record;
31
+
32
+ let modified = false;
33
+ let demoted = record.demoted;
34
+ let demoteReason = record.demoteReason;
35
+
36
+ // 1. Demote transcript-shaped blobs
37
+ if (isTranscriptShaped(record) && !demoted) {
38
+ demoted = true;
39
+ demoteReason = 'transcript_shaped_transport_blob';
40
+ demotedTranscripts += 1;
41
+ modified = true;
42
+ }
43
+
44
+ // 2. Infer project if missing or generic; unknown remains null (unscoped)
45
+ const existingProject = record.scope?.projectId || record.metadata?.project;
46
+ const inferredProject = inferProjectFromLesson(record);
47
+ const resolvedProject = existingProject && existingProject !== 'default' && existingProject !== 'agent'
48
+ ? existingProject
49
+ : (inferredProject || null);
50
+
51
+ const countKey = resolvedProject || 'unscoped';
52
+ projectCounts[countKey] = (projectCounts[countKey] || 0) + 1;
53
+
54
+ const existingScope = record.scope || {};
55
+ const scopeModified = existingScope.projectId !== resolvedProject;
56
+ if (scopeModified) {
57
+ modified = true;
58
+ }
59
+
60
+ const updatedScope = {
61
+ ...(existingScope.entityId ? { entityId: existingScope.entityId } : {}),
62
+ projectId: resolvedProject,
63
+ processId: existingScope.processId || 'agent',
64
+ sessionId: existingScope.sessionId || `session_${record.timestamp ? new Date(record.timestamp).getTime() : Date.now()}`,
65
+ };
66
+
67
+ const existingMetadata = record.metadata || {};
68
+ const updatedMetadata = {
69
+ ...existingMetadata,
70
+ ...(resolvedProject ? { project: resolvedProject, repo: resolvedProject } : {}),
71
+ tool: existingMetadata.tool || record.structuredRule?.metadata?.toolsUsed?.[0] || 'unknown',
72
+ failureClass: existingMetadata.failureClass || (record.category === 'error' ? 'execution' : 'success'),
73
+ };
74
+
75
+ if (modified) {
76
+ modifiedCount += 1;
77
+ }
78
+
79
+ return {
80
+ ...record,
81
+ demoted,
82
+ ...(demoteReason ? { demoteReason } : {}),
83
+ scope: updatedScope,
84
+ metadata: updatedMetadata,
85
+ };
86
+ });
87
+
88
+ if (!options.dryRun && modifiedCount > 0) {
89
+ const tmpPath = `${targetPath}.tmp.${Date.now()}`;
90
+ const serialized = updatedRecords.map((r) => JSON.stringify(r)).join('\n') + (updatedRecords.length ? '\n' : '');
91
+ fs.writeFileSync(tmpPath, serialized, 'utf8');
92
+ fs.renameSync(tmpPath, targetPath);
93
+ }
94
+
95
+ return {
96
+ ok: true,
97
+ totalRecords: records.length,
98
+ modifiedCount,
99
+ demotedTranscripts,
100
+ projectCounts,
101
+ dryRun: Boolean(options.dryRun),
102
+ targetPath,
103
+ };
104
+ }
105
+
106
+ function main() {
107
+ const args = process.argv.slice(2);
108
+ const dryRun = args.includes('--dry-run');
109
+ const fileArgIdx = args.indexOf('--file');
110
+ const targetFile = fileArgIdx !== -1 ? args[fileArgIdx + 1] : null;
111
+
112
+ const result = backfillMemoryLog(targetFile, { dryRun });
113
+ process.stdout.write(JSON.stringify(result, null, 2) + '\n');
114
+ }
115
+
116
+ if (process.argv[1] && path.resolve(process.argv[1]) === path.resolve(__filename)) {
117
+ main();
118
+ }
119
+
120
+ module.exports = {
121
+ backfillMemoryLog,
122
+ };
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /**
5
+ * billing-setup.js — Wire up hosted billing for the CFO dashboard
6
+ *
7
+ * Generates a THUMBGATE_OPERATOR_KEY and stores it locally so that
8
+ * `node bin/cli.js cfo --today` pulls live revenue from the production server.
9
+ *
10
+ * Usage:
11
+ * node scripts/billing-setup.js
12
+ *
13
+ * After running, set the saved key on Railway from a private terminal:
14
+ * THUMBGATE_PRINT_OPERATOR_KEY=1 node scripts/billing-setup.js
15
+ * Then redeploy (or let Railway auto-deploy).
16
+ */
17
+
18
+ const crypto = require('node:crypto');
19
+ const fs = require('node:fs');
20
+ const path = require('node:path');
21
+ const os = require('node:os');
22
+
23
+ const LOCAL_CONFIG_PATH = path.join(os.homedir(), '.config', 'thumbgate', 'operator.json');
24
+ const PROD_URL = 'https://thumbgate-production.up.railway.app';
25
+
26
+ function shouldRevealOperatorKey() {
27
+ return process.env.THUMBGATE_PRINT_OPERATOR_KEY === '1';
28
+ }
29
+
30
+ function generateOperatorKey() {
31
+ return `tg_op_${crypto.randomBytes(20).toString('hex')}`;
32
+ }
33
+
34
+ function redactOperatorKey(key) {
35
+ const raw = String(key || '');
36
+ if (!raw) return '<missing>';
37
+ if (shouldRevealOperatorKey()) return raw;
38
+ return `${raw.slice(0, 8)}...${raw.slice(-4)} (redacted)`;
39
+ }
40
+
41
+ function railwaySetCommand(key) {
42
+ const value = shouldRevealOperatorKey() ? key : '<value-from-operator.json>';
43
+ return `railway variables set THUMBGATE_OPERATOR_KEY=${value}`;
44
+ }
45
+
46
+ function printRevealHint() {
47
+ if (shouldRevealOperatorKey()) return;
48
+ console.log('\nTo reveal the key in a private terminal only:');
49
+ console.log(' THUMBGATE_PRINT_OPERATOR_KEY=1 node bin/cli.js billing:setup');
50
+ console.log('\nDo not paste the operator key into chat, shell history shared with agents, or git.');
51
+ }
52
+
53
+ function loadExistingConfig() {
54
+ try {
55
+ const raw = fs.readFileSync(LOCAL_CONFIG_PATH, 'utf8');
56
+ return JSON.parse(raw);
57
+ } catch {
58
+ return null;
59
+ }
60
+ }
61
+
62
+ function saveConfig(config) {
63
+ const dir = path.dirname(LOCAL_CONFIG_PATH);
64
+ fs.mkdirSync(dir, { recursive: true });
65
+ fs.writeFileSync(LOCAL_CONFIG_PATH, JSON.stringify(config, null, 2) + '\n', { mode: 0o600 });
66
+ }
67
+
68
+ async function verifyEndpoint(baseUrl, key) {
69
+ try {
70
+ const url = new URL('/v1/billing/summary?window=today', baseUrl);
71
+ const res = await fetch(url, {
72
+ method: 'GET',
73
+ headers: { authorization: `Bearer ${key}`, accept: 'application/json' },
74
+ });
75
+ return { status: res.status, ok: res.ok };
76
+ } catch (err) {
77
+ return { status: null, ok: false, error: err.message };
78
+ }
79
+ }
80
+
81
+ async function main() {
82
+ const existing = loadExistingConfig();
83
+
84
+ if (existing && existing.operatorKey && existing.baseUrl) {
85
+ console.log('\n✓ Operator config already exists at', LOCAL_CONFIG_PATH);
86
+ console.log(' Base URL :', existing.baseUrl);
87
+ console.log(' Operator key:', redactOperatorKey(existing.operatorKey));
88
+ console.log('\nTo regenerate, delete the file and re-run this script.');
89
+
90
+ // Set env for this process so the verify check works
91
+ process.env.THUMBGATE_OPERATOR_KEY = existing.operatorKey;
92
+ process.env.THUMBGATE_BILLING_API_BASE_URL = existing.baseUrl;
93
+
94
+ const check = await verifyEndpoint(existing.baseUrl, existing.operatorKey);
95
+ if (check.ok) {
96
+ console.log('\n✓ Production endpoint responds OK — hosted billing is active.');
97
+ } else if (check.status === 403) {
98
+ console.log('\n⚠ Production endpoint returned 403 — the operator key is not yet set on Railway.');
99
+ console.log('\nSet it now:\n');
100
+ console.log(` ${railwaySetCommand(existing.operatorKey)}`);
101
+ printRevealHint();
102
+ console.log('\nThen redeploy (Railway will pick it up automatically).');
103
+ } else {
104
+ console.log(`\n⚠ Endpoint check returned status ${check.status || 'error'}: ${check.error || ''}`);
105
+ console.log('\nIf this is an auth/config mismatch, verify Railway has the same operator key:\n');
106
+ console.log(` ${railwaySetCommand(existing.operatorKey)}`);
107
+ printRevealHint();
108
+ }
109
+ return;
110
+ }
111
+
112
+ const key = generateOperatorKey();
113
+ const config = {
114
+ operatorKey: key,
115
+ baseUrl: process.env.THUMBGATE_BILLING_API_BASE_URL || PROD_URL,
116
+ createdAt: new Date().toISOString(),
117
+ };
118
+
119
+ saveConfig(config);
120
+
121
+ console.log('\n✓ Operator key generated and saved to', LOCAL_CONFIG_PATH);
122
+ console.log('\n──────────────────────────────────────────────────────');
123
+ console.log(' THUMBGATE_OPERATOR_KEY =', redactOperatorKey(key));
124
+ console.log('──────────────────────────────────────────────────────');
125
+ console.log('\nSet this key on Railway (one-time):');
126
+ console.log('\n ' + railwaySetCommand(key));
127
+ printRevealHint();
128
+ console.log('\nOr paste it into the Railway dashboard under Variables.');
129
+ console.log('\nAfter Railway redeploys, run:\n');
130
+ console.log(' node bin/cli.js cfo --today\n');
131
+ console.log('The CFO dashboard will use live production billing data.');
132
+ }
133
+
134
+ main().catch((err) => {
135
+ console.error('billing-setup error:', err.message);
136
+ process.exit(1);
137
+ });