thumbgate 1.4.3 → 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 (266) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.well-known/mcp/server-card.json +1 -1
  4. package/adapters/README.md +1 -1
  5. package/adapters/claude/.mcp.json +2 -2
  6. package/adapters/codex/config.toml +2 -2
  7. package/adapters/mcp/server-stdio.js +1 -1
  8. package/adapters/opencode/opencode.json +1 -1
  9. package/package.json +157 -9
  10. package/scripts/statusline.sh +1 -0
  11. package/src/api/server.js +113 -16
  12. package/src/index.js +3 -0
  13. package/.claude-plugin/bundle/icon.png +0 -0
  14. package/.claude-plugin/bundle/icon.svg +0 -18
  15. package/.claude-plugin/bundle/server/index.js +0 -24
  16. package/adapters/chatgpt/INSTALL.md +0 -158
  17. package/adapters/perplexity/.mcp.json +0 -36
  18. package/adapters/perplexity/config.toml +0 -16
  19. package/adapters/perplexity/opencode.json +0 -29
  20. package/bin/memory.sh +0 -64
  21. package/bin/obsidian-sync.sh +0 -20
  22. package/plugins/amp-skill/INSTALL.md +0 -52
  23. package/plugins/amp-skill/SKILL.md +0 -64
  24. package/plugins/claude-codex-bridge/.claude-plugin/plugin.json +0 -22
  25. package/plugins/claude-codex-bridge/.mcp.json +0 -14
  26. package/plugins/claude-codex-bridge/INSTALL.md +0 -43
  27. package/plugins/claude-codex-bridge/README.md +0 -46
  28. package/plugins/claude-codex-bridge/scripts/codex-bridge.js +0 -286
  29. package/plugins/claude-codex-bridge/skills/adversarial-review/SKILL.md +0 -24
  30. package/plugins/claude-codex-bridge/skills/result/SKILL.md +0 -22
  31. package/plugins/claude-codex-bridge/skills/review/SKILL.md +0 -28
  32. package/plugins/claude-codex-bridge/skills/second-pass/SKILL.md +0 -27
  33. package/plugins/claude-codex-bridge/skills/setup/SKILL.md +0 -21
  34. package/plugins/claude-codex-bridge/skills/status/SKILL.md +0 -19
  35. package/plugins/claude-skill/INSTALL.md +0 -55
  36. package/plugins/claude-skill/SKILL.md +0 -46
  37. package/plugins/codex-profile/.codex-plugin/plugin.json +0 -43
  38. package/plugins/codex-profile/.mcp.json +0 -14
  39. package/plugins/codex-profile/AGENTS.md +0 -20
  40. package/plugins/codex-profile/INSTALL.md +0 -89
  41. package/plugins/codex-profile/README.md +0 -61
  42. package/plugins/cursor-marketplace/.cursor-plugin/plugin.json +0 -23
  43. package/plugins/cursor-marketplace/CHANGELOG.md +0 -30
  44. package/plugins/cursor-marketplace/LICENSE +0 -21
  45. package/plugins/cursor-marketplace/README.md +0 -124
  46. package/plugins/cursor-marketplace/agents/reliability-reviewer.md +0 -31
  47. package/plugins/cursor-marketplace/assets/logo-400x400.png +0 -0
  48. package/plugins/cursor-marketplace/commands/capture-feedback.md +0 -33
  49. package/plugins/cursor-marketplace/commands/check-gates.md +0 -25
  50. package/plugins/cursor-marketplace/commands/show-lessons.md +0 -27
  51. package/plugins/cursor-marketplace/hooks/hooks.json +0 -10
  52. package/plugins/cursor-marketplace/mcp.json +0 -14
  53. package/plugins/cursor-marketplace/rules/feedback-capture.mdc +0 -34
  54. package/plugins/cursor-marketplace/rules/pre-action-gates.mdc +0 -30
  55. package/plugins/cursor-marketplace/rules/session-continuity.mdc +0 -28
  56. package/plugins/cursor-marketplace/scripts/gate-check.sh +0 -21
  57. package/plugins/cursor-marketplace/skills/capture-feedback/SKILL.md +0 -48
  58. package/plugins/cursor-marketplace/skills/prevention-rules/SKILL.md +0 -31
  59. package/plugins/cursor-marketplace/skills/recall-context/SKILL.md +0 -30
  60. package/plugins/cursor-marketplace/skills/search-lessons/SKILL.md +0 -33
  61. package/plugins/gemini-extension/INSTALL.md +0 -92
  62. package/plugins/gemini-extension/gemini_prompt.txt +0 -14
  63. package/plugins/gemini-extension/tool_contract.json +0 -45
  64. package/plugins/opencode-profile/INSTALL.md +0 -57
  65. package/public/assets/instagram-card.png +0 -0
  66. package/public/assets/tiktok-agent-memory.mp4 +0 -0
  67. package/public/blog.html +0 -474
  68. package/public/compare/mem0.html +0 -189
  69. package/public/compare/speclock.html +0 -180
  70. package/public/compare.html +0 -310
  71. package/public/dashboard.html +0 -1100
  72. package/public/guide.html +0 -317
  73. package/public/guides/claude-code-prevent-repeated-mistakes.html +0 -161
  74. package/public/guides/codex-cli-guardrails.html +0 -158
  75. package/public/guides/cursor-prevent-repeated-mistakes.html +0 -161
  76. package/public/guides/pre-action-gates.html +0 -162
  77. package/public/guides/stop-repeated-ai-agent-mistakes.html +0 -159
  78. package/public/index.html +0 -1225
  79. package/public/js/buyer-intent.js +0 -252
  80. package/public/learn/agent-harness-pattern.html +0 -180
  81. package/public/learn/ai-agent-persistent-memory.html +0 -203
  82. package/public/learn/learn.css +0 -45
  83. package/public/learn/mcp-pre-action-gates-explained.html +0 -172
  84. package/public/learn/stop-ai-agent-force-push.html +0 -134
  85. package/public/learn/vibe-coding-safety-net.html +0 -142
  86. package/public/learn.html +0 -274
  87. package/public/lessons.html +0 -967
  88. package/public/llm-context.md +0 -156
  89. package/public/pro.html +0 -1087
  90. package/public/vercel.json +0 -8
  91. package/scripts/a2ui-engine.js +0 -73
  92. package/scripts/adk-consolidator.js +0 -274
  93. package/scripts/agent-security-hardening.js +0 -225
  94. package/scripts/ai-search-visibility.js +0 -116
  95. package/scripts/autonomous-sales-agent.js +0 -39
  96. package/scripts/autoresearch-runner.js +0 -216
  97. package/scripts/background-agent-governance.js +0 -229
  98. package/scripts/behavioral-extraction.js +0 -93
  99. package/scripts/budget-enforcer.js +0 -173
  100. package/scripts/budget-guard.js +0 -173
  101. package/scripts/build-claude-mcpb.js +0 -255
  102. package/scripts/build-codex-plugin.js +0 -152
  103. package/scripts/capture-railway-diagnostics.sh +0 -97
  104. package/scripts/changeset-check.js +0 -372
  105. package/scripts/check-congruence.js +0 -443
  106. package/scripts/computer-use-firewall.js +0 -280
  107. package/scripts/content-engine/linkedin-content-generator.js +0 -154
  108. package/scripts/content-engine/output/linkedin-memento-validation.md +0 -17
  109. package/scripts/content-engine/output/linkedin-posts-2026-04-09.md +0 -175
  110. package/scripts/content-engine/reddit-thread-finder.js +0 -154
  111. package/scripts/context-engine.js +0 -710
  112. package/scripts/daily-digest.js +0 -11
  113. package/scripts/data-governance.js +0 -173
  114. package/scripts/deploy-gcp.sh +0 -44
  115. package/scripts/deploy-policy.js +0 -249
  116. package/scripts/disagreement-mining.js +0 -315
  117. package/scripts/dpo-optimizer.js +0 -206
  118. package/scripts/ensure-repo-bootstrap.js +0 -130
  119. package/scripts/ephemeral-agent-store.js +0 -212
  120. package/scripts/eval-harness.js +0 -56
  121. package/scripts/export-kto-pairs.js +0 -309
  122. package/scripts/export-training.js +0 -446
  123. package/scripts/feedback-fallback.js +0 -111
  124. package/scripts/feedback-inbox-read.js +0 -162
  125. package/scripts/feedback-root-consolidator.js +0 -233
  126. package/scripts/feedback-to-memory.js +0 -185
  127. package/scripts/gate-satisfy.js +0 -42
  128. package/scripts/generate-paperbanana-diagrams.sh +0 -99
  129. package/scripts/generate-pretool-hook.sh +0 -40
  130. package/scripts/github-about.js +0 -430
  131. package/scripts/github-outreach.js +0 -65
  132. package/scripts/gtm-revenue-loop.js +0 -535
  133. package/scripts/hallucination-detector.js +0 -226
  134. package/scripts/hf-papers.js +0 -317
  135. package/scripts/hook-auto-capture.sh +0 -100
  136. package/scripts/hook-stop-pr-thread-check.sh +0 -68
  137. package/scripts/hook-stop-self-score.sh +0 -51
  138. package/scripts/hook-stop-verify-deploy.sh +0 -31
  139. package/scripts/hook-verify-before-done.sh +0 -20
  140. package/scripts/managed-dpo-export.js +0 -91
  141. package/scripts/markdown-escape.js +0 -12
  142. package/scripts/marketing-experiment.js +0 -657
  143. package/scripts/memalign-recall.js +0 -111
  144. package/scripts/memory-migration.js +0 -296
  145. package/scripts/meta-policy.js +0 -190
  146. package/scripts/metered-billing.js +0 -16
  147. package/scripts/model-tier-router.js +0 -310
  148. package/scripts/money-watcher.js +0 -218
  149. package/scripts/multi-hop-recall.js +0 -240
  150. package/scripts/per-step-scoring.js +0 -163
  151. package/scripts/perplexity-command-center.js +0 -644
  152. package/scripts/perplexity-marketing.js +0 -454
  153. package/scripts/pii-scanner.js +0 -153
  154. package/scripts/plan-gate.js +0 -154
  155. package/scripts/post-everywhere.js +0 -341
  156. package/scripts/post-to-x-retry.sh +0 -22
  157. package/scripts/post-to-x.js +0 -369
  158. package/scripts/pr-manager.js +0 -421
  159. package/scripts/principle-extractor.js +0 -162
  160. package/scripts/pro-features.js +0 -41
  161. package/scripts/prompt-dlp.js +0 -222
  162. package/scripts/prove-adapters.js +0 -860
  163. package/scripts/prove-attribution.js +0 -361
  164. package/scripts/prove-automation.js +0 -651
  165. package/scripts/prove-autoresearch.js +0 -304
  166. package/scripts/prove-claim-verification.js +0 -277
  167. package/scripts/prove-cloudflare-sandbox.js +0 -161
  168. package/scripts/prove-data-pipeline.js +0 -408
  169. package/scripts/prove-data-quality.js +0 -227
  170. package/scripts/prove-evolution.js +0 -352
  171. package/scripts/prove-harnesses.js +0 -287
  172. package/scripts/prove-intelligence.js +0 -257
  173. package/scripts/prove-lancedb.js +0 -425
  174. package/scripts/prove-local-intelligence.js +0 -340
  175. package/scripts/prove-loop-closure.js +0 -263
  176. package/scripts/prove-packaged-runtime.js +0 -327
  177. package/scripts/prove-predictive-insights.js +0 -355
  178. package/scripts/prove-runtime.js +0 -363
  179. package/scripts/prove-seo-gsd.js +0 -234
  180. package/scripts/prove-settings.js +0 -279
  181. package/scripts/prove-subway-upgrades.js +0 -277
  182. package/scripts/prove-tessl.js +0 -229
  183. package/scripts/prove-training-export.js +0 -325
  184. package/scripts/prove-workflow-contract.js +0 -112
  185. package/scripts/prove-xmemory.js +0 -332
  186. package/scripts/publish-decision.js +0 -159
  187. package/scripts/ralph-loop.js +0 -376
  188. package/scripts/ralph-mode-ci.js +0 -434
  189. package/scripts/reddit-dm-outreach.js +0 -192
  190. package/scripts/reddit-monitor-cron.sh +0 -26
  191. package/scripts/reminder-engine.js +0 -132
  192. package/scripts/revenue-status.js +0 -472
  193. package/scripts/rotate-stripe-webhook-secret.js +0 -314
  194. package/scripts/schedule-manager.js +0 -249
  195. package/scripts/self-healing-check.js +0 -193
  196. package/scripts/session-analyzer.js +0 -533
  197. package/scripts/shieldcortex-memory-firewall-runner.mjs +0 -53
  198. package/scripts/skill-exporter.js +0 -260
  199. package/scripts/skill-materializer.js +0 -134
  200. package/scripts/skill-packs.js +0 -136
  201. package/scripts/skill-proposer.js +0 -99
  202. package/scripts/skill-quality-tracker.js +0 -282
  203. package/scripts/slow-loop.js +0 -72
  204. package/scripts/social-analytics/db/marketing-db.js +0 -179
  205. package/scripts/social-analytics/db/schema.sql +0 -55
  206. package/scripts/social-analytics/digest.js +0 -256
  207. package/scripts/social-analytics/engagement-audit.js +0 -185
  208. package/scripts/social-analytics/generate-instagram-card.js +0 -123
  209. package/scripts/social-analytics/generate-slides.js +0 -268
  210. package/scripts/social-analytics/instagram-thumbgate-post.js +0 -111
  211. package/scripts/social-analytics/install-growth-automation.js +0 -114
  212. package/scripts/social-analytics/load-env.js +0 -77
  213. package/scripts/social-analytics/mcp-server.js +0 -289
  214. package/scripts/social-analytics/normalizer.js +0 -580
  215. package/scripts/social-analytics/notify.js +0 -162
  216. package/scripts/social-analytics/poll-all.js +0 -107
  217. package/scripts/social-analytics/pollers/github.js +0 -195
  218. package/scripts/social-analytics/pollers/instagram.js +0 -253
  219. package/scripts/social-analytics/pollers/linkedin.js +0 -340
  220. package/scripts/social-analytics/pollers/plausible.js +0 -245
  221. package/scripts/social-analytics/pollers/reddit.js +0 -306
  222. package/scripts/social-analytics/pollers/threads.js +0 -233
  223. package/scripts/social-analytics/pollers/tiktok.js +0 -203
  224. package/scripts/social-analytics/pollers/x.js +0 -227
  225. package/scripts/social-analytics/pollers/youtube.js +0 -304
  226. package/scripts/social-analytics/pollers/zernio.js +0 -183
  227. package/scripts/social-analytics/post-video.js +0 -316
  228. package/scripts/social-analytics/publish-instagram-thumbgate.js +0 -104
  229. package/scripts/social-analytics/publish-thumbgate-launch.js +0 -322
  230. package/scripts/social-analytics/publishers/devto.js +0 -122
  231. package/scripts/social-analytics/publishers/instagram.js +0 -317
  232. package/scripts/social-analytics/publishers/linkedin.js +0 -294
  233. package/scripts/social-analytics/publishers/reddit.js +0 -385
  234. package/scripts/social-analytics/publishers/threads.js +0 -275
  235. package/scripts/social-analytics/publishers/tiktok.js +0 -217
  236. package/scripts/social-analytics/publishers/x.js +0 -259
  237. package/scripts/social-analytics/publishers/youtube.js +0 -223
  238. package/scripts/social-analytics/publishers/zernio.js +0 -568
  239. package/scripts/social-analytics/reconcile-thumbgate-campaign.js +0 -165
  240. package/scripts/social-analytics/run-digest.js +0 -34
  241. package/scripts/social-analytics/schedule-thumbgate-campaign.js +0 -275
  242. package/scripts/social-analytics/store.js +0 -455
  243. package/scripts/social-analytics/sync-launch-assets.js +0 -185
  244. package/scripts/social-analytics/utm.js +0 -143
  245. package/scripts/social-pipeline.js +0 -2626
  246. package/scripts/social-post-hourly.js +0 -228
  247. package/scripts/social-quality-gate.js +0 -134
  248. package/scripts/social-reply-monitor.js +0 -592
  249. package/scripts/status-dashboard.js +0 -155
  250. package/scripts/stripe-live-status.js +0 -115
  251. package/scripts/subagent-profiles.js +0 -79
  252. package/scripts/sync-branch-protection.js +0 -340
  253. package/scripts/sync-gh-secrets-from-env.sh +0 -70
  254. package/scripts/sync-github-about.js +0 -55
  255. package/scripts/sync-version.js +0 -479
  256. package/scripts/synthetic-dpo.js +0 -234
  257. package/scripts/tessl-export.js +0 -369
  258. package/scripts/test-coverage.js +0 -128
  259. package/scripts/thumbgate-bench.js +0 -494
  260. package/scripts/thumbgate_session_start.sh +0 -32
  261. package/scripts/train_from_feedback.py +0 -929
  262. package/scripts/validate-feedback.js +0 -581
  263. package/scripts/verify-obsidian-setup.sh +0 -269
  264. package/scripts/verify-run.js +0 -269
  265. package/scripts/weekly-auto-post.js +0 -124
  266. package/scripts/x-autonomous-marketing.js +0 -139
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * autonomous-sales-agent.js
4
- *
5
- * Wrapper for the truth-aware GSD revenue loop:
6
- * 1. read the current commercial snapshot
7
- * 2. pick the correct motion (Pro vs Workflow Hardening Sprint)
8
- * 3. generate operator-ready outreach artifacts
9
- * Canonical app origin remains https://thumbgate-production.up.railway.app.
10
- */
11
-
12
- 'use strict';
13
-
14
- const { parseArgs, runRevenueLoop } = require('./gtm-revenue-loop');
15
-
16
- async function main(argv = process.argv.slice(2)) {
17
- const options = parseArgs(argv);
18
- const { report, written } = await runRevenueLoop(options);
19
-
20
- console.log('\n✅ GTM automation complete.');
21
- if (written.docsPath) {
22
- console.log(`Open ${written.docsPath} to review the operator report.`);
23
- }
24
- if (written.reportDir) {
25
- console.log(`Artifacts written to ${written.reportDir}.`);
26
- }
27
- console.log(`State: ${report.directive.state} | Targets: ${report.targets.length}`);
28
- }
29
-
30
- if (require.main === module) {
31
- main().catch((err) => {
32
- console.error(err && err.message ? err.message : err);
33
- process.exit(1);
34
- });
35
- }
36
-
37
- module.exports = {
38
- main,
39
- };
@@ -1,216 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- /**
4
- * Autoresearch Runner (AUTORESEARCH-02)
5
- *
6
- * Karpathy-inspired self-optimizing loop for the ThumbGate feedback studio.
7
- * Each iteration: mutate local evolution state → run primary + holdout checks
8
- * → measure score → keep/discard with rollback snapshots.
9
- *
10
- * The runner never rewrites tracked source files. It mutates the local
11
- * evolution-state overlay, evaluates in place, and only persists accepted
12
- * settings plus rollback snapshots.
13
- *
14
- * Mutation targets (in priority order):
15
- * 1. Thompson Sampling priors (HALF_LIFE_DAYS, DECAY_FLOOR)
16
- * 2. Prevention rule thresholds (minOccurrences)
17
- * 3. Verification loop retries (MAX_RETRIES)
18
- * 4. DPO temperature (DPO_BETA)
19
- *
20
- * Score function: command pass rate × approval weighting, with holdout gating.
21
- *
22
- * Zero external dependencies.
23
- *
24
- * Exports: runIteration, runLoop, scoreSuite, MUTATION_TARGETS
25
- */
26
-
27
- const {
28
- getProgress,
29
- } = require('./experiment-tracker');
30
- const { buildResearchBrief } = require('./hf-papers');
31
- const {
32
- EVOLUTION_TARGETS,
33
- parseCommandScore,
34
- runWorkspaceEvolution,
35
- } = require('./workspace-evolver');
36
-
37
- // ---------------------------------------------------------------------------
38
- // Mutation Targets
39
- // ---------------------------------------------------------------------------
40
-
41
- const MUTATION_TARGETS = EVOLUTION_TARGETS;
42
-
43
- // ---------------------------------------------------------------------------
44
- // Score Function
45
- // ---------------------------------------------------------------------------
46
-
47
- /**
48
- * Score a test suite run. Returns a number in [0, 1].
49
- *
50
- * @param {object} params
51
- * @param {string} params.testOutput - stdout from test run
52
- * @param {number} [params.approvalRate] - Current approval rate from feedback
53
- * @returns {{ score: number, testPassRate: number, details: object }}
54
- */
55
- function scoreSuite(params) {
56
- return parseCommandScore(params.testOutput || '', 0, typeof params.approvalRate === 'number' ? params.approvalRate : 0.5);
57
- }
58
-
59
- // ---------------------------------------------------------------------------
60
- // Single Iteration
61
- // ---------------------------------------------------------------------------
62
-
63
- /**
64
- * Run one autoresearch iteration.
65
- *
66
- * 1. Pick a random mutation target
67
- * 2. Read current value, compute a random neighbor
68
- * 3. Run the test suite in a tmp env with the mutation
69
- * 4. Score and keep/discard via experiment tracker
70
- *
71
- * @param {object} [opts]
72
- * @param {string} [opts.targetName] - Force a specific mutation target
73
- * @param {number} [opts.nextValue] - Force the candidate value instead of a random neighbor
74
- * @param {string} [opts.testCommand] - Override test command (default: npm test)
75
- * @param {string[]} [opts.holdoutCommands] - Optional holdout commands required for acceptance
76
- * @param {number} [opts.timeoutMs] - Test timeout in ms (default: 120000)
77
- * @param {string} [opts.researchQuery] - Optional external research query
78
- * @param {number} [opts.paperLimit] - Max papers to ingest for research context
79
- * @param {Function} [opts.fetchImpl] - Optional fetch implementation override
80
- * @param {Function} [opts.searchPapersImpl] - Optional paper search override
81
- * @returns {Promise<object>} experiment result
82
- */
83
- async function runIteration(opts = {}) {
84
- const options = opts || {};
85
- const timeoutMs = options.timeoutMs || 120000;
86
- const testCommand = options.testCommand || 'npm test';
87
- const research = options.researchQuery
88
- ? await buildResearchBrief({
89
- query: options.researchQuery,
90
- limit: options.paperLimit,
91
- fetchImpl: options.fetchImpl,
92
- searchPapersImpl: options.searchPapersImpl,
93
- template: 'autoresearch-brief',
94
- })
95
- : null;
96
-
97
- const result = runWorkspaceEvolution({
98
- targetName: options.targetName,
99
- nextValue: options.nextValue,
100
- primaryCommands: [testCommand],
101
- holdoutCommands: options.holdoutCommands || [],
102
- timeoutMs,
103
- hypothesisSuffix: research ? `Research query: ${research.query}` : null,
104
- additionalMetrics: {
105
- researchQuery: research ? research.query : null,
106
- researchPackId: research ? research.packId : null,
107
- researchPaperIds: research ? research.citations.map((citation) => citation.paperId).filter(Boolean) : [],
108
- },
109
- });
110
-
111
- return result;
112
- }
113
-
114
- // ---------------------------------------------------------------------------
115
- // Multi-Iteration Loop
116
- // ---------------------------------------------------------------------------
117
-
118
- /**
119
- * Run N autoresearch iterations.
120
- *
121
- * @param {object} params
122
- * @param {number} params.iterations - Number of experiments to run
123
- * @param {string} [params.testCommand] - Override test command
124
- * @param {number} [params.timeoutMs] - Per-iteration timeout
125
- * @param {string} [params.researchQuery] - Optional external research query
126
- * @param {number} [params.paperLimit] - Max papers to ingest for research context
127
- * @param {Function} [params.fetchImpl] - Optional fetch implementation override
128
- * @param {Function} [params.searchPapersImpl] - Optional paper search override
129
- * @returns {Promise<object>} { results, progress }
130
- */
131
- async function runLoop(params) {
132
- const iterations = params.iterations || 1;
133
- const results = [];
134
-
135
- for (let i = 0; i < iterations; i++) {
136
- console.log(`\n[autoresearch] Iteration ${i + 1}/${iterations}`);
137
- try {
138
- const result = await runIteration({
139
- testCommand: params.testCommand,
140
- holdoutCommands: params.holdoutCommands,
141
- timeoutMs: params.timeoutMs,
142
- researchQuery: params.researchQuery,
143
- paperLimit: params.paperLimit,
144
- fetchImpl: params.fetchImpl,
145
- searchPapersImpl: params.searchPapersImpl,
146
- });
147
- results.push(result);
148
- if (result.kept) {
149
- console.log(` ✓ KEPT: ${result.name} (delta: +${(result.delta || 0).toFixed(4)})`);
150
- } else if (result.skipped) {
151
- console.log(` ⊘ SKIPPED: ${result.reason}`);
152
- } else {
153
- console.log(` ✗ DISCARDED: ${result.reason}`);
154
- }
155
- } catch (err) {
156
- console.error(` ✗ ERROR: ${err.message}`);
157
- results.push({ error: err.message });
158
- }
159
- }
160
-
161
- const progress = getProgress();
162
- console.log(`\n[autoresearch] Progress: ${progress.completed} experiments, ${progress.kept} kept (${progress.keepRate}%)`);
163
- return { results, progress };
164
- }
165
-
166
- // ---------------------------------------------------------------------------
167
- // CLI
168
- // ---------------------------------------------------------------------------
169
-
170
- if (require.main === module) {
171
- const args = {};
172
- process.argv.slice(2).forEach((arg) => {
173
- if (!arg.startsWith('--')) return;
174
- const [key, ...rest] = arg.slice(2).split('=');
175
- args[key] = rest.length > 0 ? rest.join('=') : true;
176
- });
177
-
178
- if (args.run) {
179
- const iterations = Number(args.iterations || 1);
180
- const testCommand = args['test-command'] || 'npm test';
181
- const timeoutMs = Number(args.timeout || 120000);
182
- const paperLimit = Number(args['paper-limit'] || 5);
183
- const holdoutCommands = args.holdout ? [args.holdout] : [];
184
- runLoop({
185
- iterations,
186
- testCommand,
187
- holdoutCommands,
188
- timeoutMs,
189
- researchQuery: args['research-query'] || null,
190
- paperLimit,
191
- }).catch((error) => {
192
- console.error(error.message);
193
- process.exit(1);
194
- });
195
- } else if (args.targets) {
196
- console.log('Mutation targets:');
197
- MUTATION_TARGETS.forEach((t) => {
198
- console.log(` ${t.name} (${t.type}): range [${t.range.join(', ')}], step ${t.step}`);
199
- });
200
- } else {
201
- console.log(`Usage:
202
- node scripts/autoresearch-runner.js --run [--iterations=5] [--test-command="npm test"] [--holdout="npm run self-heal:check"] [--timeout=120000] [--research-query="rank fusion"] [--paper-limit=5]
203
- node scripts/autoresearch-runner.js --targets`);
204
- }
205
- }
206
-
207
- // ---------------------------------------------------------------------------
208
- // Exports
209
- // ---------------------------------------------------------------------------
210
-
211
- module.exports = {
212
- runIteration,
213
- runLoop,
214
- scoreSuite,
215
- MUTATION_TARGETS,
216
- };
@@ -1,229 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- /**
5
- * Background Agent Governance — the missing layer for Ramp/Ona-style agent stacks.
6
- *
7
- * Background agents run unattended (writing 57% of PRs at Ramp). They need:
8
- * 1. Run tracking — what did each agent run do?
9
- * 2. Governance gate — should this PR/action be allowed based on past failures?
10
- * 3. Post-run audit — auto-capture feedback from CI results
11
- * 4. Governance report — "X runs, Y blocked, Z lessons learned"
12
- *
13
- * Integrates with: MCP server, gates engine, org dashboard, lesson inference.
14
- */
15
-
16
- const fs = require('fs');
17
- const path = require('path');
18
- const { resolveFeedbackDir } = require('./feedback-paths');
19
- const { ensureParentDir, readJsonl } = require('./fs-utils');
20
-
21
- const RUNS_FILE = 'agent-runs.jsonl';
22
-
23
- function getFeedbackDir() { return resolveFeedbackDir(); }
24
- function getRunsPath() { return path.join(getFeedbackDir(), RUNS_FILE); }
25
-
26
- // ---------------------------------------------------------------------------
27
- // 1. Run Tracking
28
- // ---------------------------------------------------------------------------
29
-
30
- /**
31
- * Record a background agent run.
32
- * Called when a background agent starts or completes a task.
33
- */
34
- function recordAgentRun({ agentId, runType, source, branch, prNumber, status, gatesChecked, gatesBlocked, filesChanged, ciPassed, duration, metadata } = {}) {
35
- const runsPath = getRunsPath();
36
- ensureParentDir(runsPath);
37
- const run = {
38
- id: `run_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
39
- timestamp: new Date().toISOString(),
40
- agentId: agentId || 'unknown',
41
- runType: runType || 'unknown', // 'pr', 'fix', 'refactor', 'ci-repair', 'migration'
42
- source: source || 'background', // 'background', 'triggered', 'scheduled', 'manual'
43
- branch: branch || null,
44
- prNumber: prNumber || null,
45
- status: status || 'started', // 'started', 'completed', 'blocked', 'failed'
46
- gatesChecked: gatesChecked || 0,
47
- gatesBlocked: gatesBlocked || 0,
48
- filesChanged: filesChanged || 0,
49
- ciPassed: ciPassed === undefined ? null : ciPassed,
50
- durationMs: duration || null,
51
- metadata: metadata || {},
52
- };
53
- fs.appendFileSync(runsPath, JSON.stringify(run) + '\n');
54
- return run;
55
- }
56
-
57
- // ---------------------------------------------------------------------------
58
- // 2. Governance Gate — pre-run check
59
- // ---------------------------------------------------------------------------
60
-
61
- /**
62
- * Check if a background agent run should proceed based on governance rules.
63
- * Returns { allowed, blockers, warnings, governanceScore }.
64
- */
65
- function checkRunGovernance({ agentId, runType, branch, filesChanged } = {}) {
66
- const runs = readJsonl(getRunsPath());
67
- const blockers = [];
68
- const warnings = [];
69
-
70
- // Rule 1: Block if this agent has > 50% failure rate in last 10 runs
71
- const agentRuns = runs.filter((r) => r.agentId === agentId).slice(-10);
72
- const failedRuns = agentRuns.filter((r) => r.status === 'failed' || r.status === 'blocked');
73
- if (agentRuns.length >= 5 && failedRuns.length / agentRuns.length > 0.5) {
74
- blockers.push({ rule: 'high_failure_rate', message: `Agent ${agentId} has ${failedRuns.length}/${agentRuns.length} failed runs (>50%)`, severity: 'critical' });
75
- }
76
-
77
- // Rule 2: Warn if agent has been blocked by gates in recent runs
78
- const recentBlocked = agentRuns.filter((r) => r.gatesBlocked > 0);
79
- if (recentBlocked.length >= 3) {
80
- warnings.push({ rule: 'repeated_gate_blocks', message: `Agent ${agentId} has been gate-blocked in ${recentBlocked.length} recent runs`, severity: 'warning' });
81
- }
82
-
83
- // Rule 3: Block if targeting protected branch without CI passing
84
- if (branch && /^(main|master|develop)$/.test(branch)) {
85
- warnings.push({ rule: 'protected_branch', message: `Run targets protected branch "${branch}" — CI must pass before merge`, severity: 'warning' });
86
- }
87
-
88
- // Rule 4: Warn if too many files changed (large blast radius)
89
- if (filesChanged > 20) {
90
- warnings.push({ rule: 'large_blast_radius', message: `${filesChanged} files changed — consider splitting into smaller PRs`, severity: 'warning' });
91
- }
92
-
93
- const governanceScore = Math.max(0, 100 - blockers.length * 40 - warnings.length * 10);
94
-
95
- return {
96
- allowed: blockers.length === 0,
97
- blockers,
98
- warnings,
99
- governanceScore,
100
- checkedAt: new Date().toISOString(),
101
- };
102
- }
103
-
104
- // ---------------------------------------------------------------------------
105
- // 3. Post-Run Audit — auto-capture feedback from CI
106
- // ---------------------------------------------------------------------------
107
-
108
- /**
109
- * Auto-capture feedback from a completed background agent run.
110
- * Converts CI pass/fail into structured feedback for the learning loop.
111
- */
112
- function auditCompletedRun({ runId, agentId, ciPassed, ciOutput, prNumber, branch, filesChanged } = {}) {
113
- const signal = ciPassed ? 'positive' : 'negative';
114
- const context = ciPassed
115
- ? `Background agent run ${runId || 'unknown'} completed successfully. PR #${prNumber || '?'} on ${branch || '?'}. ${filesChanged || 0} files changed. CI passed.`
116
- : `Background agent run ${runId || 'unknown'} failed. PR #${prNumber || '?'} on ${branch || '?'}. ${filesChanged || 0} files changed. CI failed.`;
117
-
118
- const whatWentWrong = !ciPassed && ciOutput ? ciOutput.slice(0, 500) : null;
119
-
120
- // Record the completed run
121
- const run = recordAgentRun({
122
- agentId,
123
- runType: 'pr',
124
- source: 'background',
125
- branch,
126
- prNumber,
127
- status: ciPassed ? 'completed' : 'failed',
128
- filesChanged,
129
- ciPassed,
130
- });
131
-
132
- // Auto-capture feedback
133
- let feedbackResult = null;
134
- try {
135
- const { captureFeedback } = require('./feedback-loop');
136
- feedbackResult = captureFeedback({
137
- signal: ciPassed ? 'up' : 'down',
138
- context,
139
- whatWentWrong,
140
- whatWorked: ciPassed ? `Agent successfully completed PR #${prNumber || '?'}` : undefined,
141
- tags: ['background-agent', ciPassed ? 'ci-pass' : 'ci-fail', `agent:${agentId || 'unknown'}`],
142
- });
143
- } catch { /* feedback capture is non-critical */ }
144
-
145
- return { run, feedbackResult, signal, context };
146
- }
147
-
148
- // ---------------------------------------------------------------------------
149
- // 4. Governance Report
150
- // ---------------------------------------------------------------------------
151
-
152
- /**
153
- * Generate a governance report for background agent runs.
154
- * Shows: total runs, blocked, pass rate, top failing agents, lessons learned.
155
- */
156
- function generateGovernanceReport({ periodHours = 24 } = {}) {
157
- const runs = readJsonl(getRunsPath());
158
- const cutoff = Date.now() - periodHours * 60 * 60 * 1000;
159
- const recent = runs.filter((r) => new Date(r.timestamp).getTime() > cutoff);
160
-
161
- const total = recent.length;
162
- const completed = recent.filter((r) => r.status === 'completed').length;
163
- const failed = recent.filter((r) => r.status === 'failed').length;
164
- const blocked = recent.filter((r) => r.status === 'blocked').length;
165
- const started = recent.filter((r) => r.status === 'started').length;
166
-
167
- const passRate = (completed + failed) > 0 ? Math.round((completed / (completed + failed)) * 1000) / 10 : 0;
168
- const totalGatesChecked = recent.reduce((s, r) => s + (r.gatesChecked || 0), 0);
169
- const totalGatesBlocked = recent.reduce((s, r) => s + (r.gatesBlocked || 0), 0);
170
-
171
- // Per-agent breakdown
172
- const byAgent = {};
173
- for (const r of recent) {
174
- if (!byAgent[r.agentId]) byAgent[r.agentId] = { completed: 0, failed: 0, blocked: 0, total: 0 };
175
- byAgent[r.agentId].total++;
176
- if (r.status === 'completed') byAgent[r.agentId].completed++;
177
- if (r.status === 'failed') byAgent[r.agentId].failed++;
178
- if (r.status === 'blocked') byAgent[r.agentId].blocked++;
179
- }
180
-
181
- const agentSummaries = Object.entries(byAgent).map(([id, counts]) => ({
182
- agentId: id,
183
- ...counts,
184
- passRate: (counts.completed + counts.failed) > 0 ? Math.round((counts.completed / (counts.completed + counts.failed)) * 1000) / 10 : 0,
185
- })).sort((a, b) => a.passRate - b.passRate);
186
-
187
- // By run type
188
- const byType = {};
189
- for (const r of recent) {
190
- if (!byType[r.runType]) byType[r.runType] = 0;
191
- byType[r.runType]++;
192
- }
193
-
194
- return {
195
- periodHours,
196
- total, completed, failed, blocked, started,
197
- passRate,
198
- gatesChecked: totalGatesChecked,
199
- gatesBlocked: totalGatesBlocked,
200
- agents: agentSummaries,
201
- topFailingAgent: agentSummaries.length > 0 && agentSummaries[0].passRate < 80 ? agentSummaries[0] : null,
202
- byType,
203
- generatedAt: new Date().toISOString(),
204
- };
205
- }
206
-
207
- /**
208
- * Format governance report as a human-readable string.
209
- */
210
- function formatGovernanceReport(report) {
211
- const lines = [
212
- `Background Agent Governance Report (${report.periodHours}h)`,
213
- `Total runs: ${report.total} | Completed: ${report.completed} | Failed: ${report.failed} | Blocked: ${report.blocked}`,
214
- `Pass rate: ${report.passRate}%`,
215
- `Gates checked: ${report.gatesChecked} | Gates blocked: ${report.gatesBlocked}`,
216
- ];
217
- if (report.topFailingAgent) {
218
- lines.push(`Top failing agent: ${report.topFailingAgent.agentId} (${report.topFailingAgent.passRate}% pass rate)`);
219
- }
220
- if (Object.keys(report.byType).length > 0) {
221
- lines.push(`Run types: ${Object.entries(report.byType).map(([t, c]) => `${t}:${c}`).join(', ')}`);
222
- }
223
- return lines.join('\n');
224
- }
225
-
226
- module.exports = {
227
- recordAgentRun, checkRunGovernance, auditCompletedRun,
228
- generateGovernanceReport, formatGovernanceReport, getRunsPath,
229
- };
@@ -1,93 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * behavioral-extraction.js
4
- *
5
- * Layer 4: Behavioral Learning
6
- * Extracts user preference patterns from feedback logs to adjust agent approach.
7
- */
8
-
9
- const fs = require('fs');
10
- const path = require('path');
11
- const { resolveFeedbackDir } = require('./feedback-paths');
12
-
13
- const baseDir = resolveFeedbackDir();
14
- const FEEDBACK_LOG_PATH = path.join(baseDir, 'feedback-log.jsonl');
15
- const TRAITS_PATH = path.join(baseDir, 'behavioral-traits.json');
16
-
17
- const TRAIT_DEFINITIONS = [
18
- {
19
- id: 'surgical-over-rewrite',
20
- patterns: [/surgical/i, /targeted/i, /don't rewrite/i, /minimal change/i],
21
- threshold: 2,
22
- description: 'User prefers surgical edits over full file rewrites.'
23
- },
24
- {
25
- id: 'concise-over-verbose',
26
- patterns: [/concise/i, /short/i, /less talk/i, /too much chat/i],
27
- threshold: 2,
28
- description: 'User prefers concise, direct communication.'
29
- },
30
- {
31
- id: 'test-driven',
32
- patterns: [/test first/i, /where is the test/i, /run tests/i, /tdd/i],
33
- threshold: 2,
34
- description: 'User prioritizes test coverage and verification.'
35
- }
36
- ];
37
-
38
- function extractTraits() {
39
- if (!fs.existsSync(FEEDBACK_LOG_PATH)) {
40
- console.log('No feedback log found at', FEEDBACK_LOG_PATH);
41
- return [];
42
- }
43
-
44
- const logLines = fs.readFileSync(FEEDBACK_LOG_PATH, 'utf-8').split('\n').filter(Boolean);
45
- const evidenceCount = {};
46
-
47
- logLines.forEach(line => {
48
- try {
49
- const entry = JSON.parse(line);
50
- const text = `${entry.context || ''} ${entry.whatWorked || ''} ${entry.whatWentWrong || ''} ${entry.whatToChange || ''}`;
51
-
52
- TRAIT_DEFINITIONS.forEach(trait => {
53
- if (trait.patterns.some(p => p.test(text))) {
54
- evidenceCount[trait.id] = (evidenceCount[trait.id] || 0) + 1;
55
- }
56
- });
57
- } catch (e) {
58
- // skip malformed lines
59
- }
60
- });
61
-
62
- const activeTraits = TRAIT_DEFINITIONS
63
- .filter(trait => (evidenceCount[trait.id] || 0) >= trait.threshold)
64
- .map(trait => ({
65
- id: trait.id,
66
- description: trait.description,
67
- evidenceCount: evidenceCount[trait.id]
68
- }));
69
-
70
- return activeTraits;
71
- }
72
-
73
- function run() {
74
- console.log('🤖 [Layer 4] Extracting behavioral patterns...');
75
- const traits = extractTraits();
76
-
77
- if (traits.length > 0) {
78
- fs.writeFileSync(TRAITS_PATH, JSON.stringify({
79
- generatedAt: new Date().toISOString(),
80
- traits
81
- }, null, 2));
82
- console.log(`✅ Extracted ${traits.length} behavioral traits.`);
83
- traits.forEach(t => console.log(` - ${t.id} (${t.evidenceCount} evidences)`));
84
- } else {
85
- console.log('No strong behavioral patterns identified yet.');
86
- }
87
- }
88
-
89
- if (require.main === module) {
90
- run();
91
- }
92
-
93
- module.exports = { extractTraits };