thumbgate 0.9.9
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.
- package/.claude-plugin/README.md +134 -0
- package/.claude-plugin/bundle/icon.png +0 -0
- package/.claude-plugin/bundle/icon.svg +18 -0
- package/.claude-plugin/bundle/server/index.js +24 -0
- package/.claude-plugin/marketplace.json +36 -0
- package/.claude-plugin/plugin.json +21 -0
- package/.well-known/mcp/server-card.json +231 -0
- package/LICENSE +21 -0
- package/README.md +375 -0
- package/adapters/README.md +9 -0
- package/adapters/amp/skills/rlhf-feedback/SKILL.md +22 -0
- package/adapters/chatgpt/INSTALL.md +83 -0
- package/adapters/chatgpt/openapi.yaml +1281 -0
- package/adapters/claude/.mcp.json +14 -0
- package/adapters/codex/config.toml +9 -0
- package/adapters/gemini/function-declarations.json +224 -0
- package/adapters/mcp/server-stdio.js +788 -0
- package/adapters/opencode/opencode.json +15 -0
- package/bin/cli.js +1483 -0
- package/bin/memory.sh +64 -0
- package/bin/obsidian-sync.sh +20 -0
- package/bin/postinstall.js +37 -0
- package/config/build-metadata.json +4 -0
- package/config/e2e-critical-flows.json +45 -0
- package/config/gate-templates.json +77 -0
- package/config/gates/claim-verification.json +29 -0
- package/config/gates/computer-use.json +39 -0
- package/config/gates/default.json +117 -0
- package/config/github-about.json +25 -0
- package/config/mcp-allowlists.json +135 -0
- package/config/model-tiers.json +33 -0
- package/config/partner-routing.json +132 -0
- package/config/policy-bundles/constrained-v1.json +64 -0
- package/config/policy-bundles/default-v1.json +91 -0
- package/config/rubrics/default-v1.json +52 -0
- package/config/skill-packs/react-testing.json +23 -0
- package/config/skill-packs/stripe-integration/references/api-spec.json +1 -0
- package/config/skill-packs/stripe-integration/references/webhook-guide.md +3 -0
- package/config/skill-specs/pr-reviewer.json +9 -0
- package/config/skill-specs/release-status.json +9 -0
- package/config/skill-specs/ticket-triage.json +9 -0
- package/config/subagent-profiles.json +32 -0
- package/config/tessl-tiles.json +29 -0
- package/config/thumbgate-settings.managed.json +12 -0
- package/openapi/openapi.yaml +1281 -0
- package/package.json +286 -0
- package/plugins/amp-skill/INSTALL.md +52 -0
- package/plugins/amp-skill/SKILL.md +64 -0
- package/plugins/claude-codex-bridge/.claude-plugin/plugin.json +22 -0
- package/plugins/claude-codex-bridge/.mcp.json +12 -0
- package/plugins/claude-codex-bridge/INSTALL.md +43 -0
- package/plugins/claude-codex-bridge/README.md +46 -0
- package/plugins/claude-codex-bridge/scripts/codex-bridge.js +288 -0
- package/plugins/claude-codex-bridge/skills/adversarial-review/SKILL.md +24 -0
- package/plugins/claude-codex-bridge/skills/result/SKILL.md +22 -0
- package/plugins/claude-codex-bridge/skills/review/SKILL.md +28 -0
- package/plugins/claude-codex-bridge/skills/second-pass/SKILL.md +27 -0
- package/plugins/claude-codex-bridge/skills/setup/SKILL.md +21 -0
- package/plugins/claude-codex-bridge/skills/status/SKILL.md +19 -0
- package/plugins/claude-skill/INSTALL.md +55 -0
- package/plugins/claude-skill/SKILL.md +46 -0
- package/plugins/codex-profile/.codex-plugin/plugin.json +43 -0
- package/plugins/codex-profile/.mcp.json +12 -0
- package/plugins/codex-profile/AGENTS.md +20 -0
- package/plugins/codex-profile/INSTALL.md +66 -0
- package/plugins/codex-profile/README.md +37 -0
- package/plugins/cursor-marketplace/.cursor-plugin/plugin.json +23 -0
- package/plugins/cursor-marketplace/CHANGELOG.md +30 -0
- package/plugins/cursor-marketplace/LICENSE +21 -0
- package/plugins/cursor-marketplace/README.md +124 -0
- package/plugins/cursor-marketplace/agents/reliability-reviewer.md +31 -0
- package/plugins/cursor-marketplace/assets/logo-400x400.png +0 -0
- package/plugins/cursor-marketplace/commands/capture-feedback.md +33 -0
- package/plugins/cursor-marketplace/commands/check-gates.md +25 -0
- package/plugins/cursor-marketplace/commands/show-lessons.md +27 -0
- package/plugins/cursor-marketplace/hooks/hooks.json +10 -0
- package/plugins/cursor-marketplace/mcp.json +12 -0
- package/plugins/cursor-marketplace/rules/feedback-capture.mdc +34 -0
- package/plugins/cursor-marketplace/rules/pre-action-gates.mdc +30 -0
- package/plugins/cursor-marketplace/rules/session-continuity.mdc +28 -0
- package/plugins/cursor-marketplace/scripts/gate-check.sh +11 -0
- package/plugins/cursor-marketplace/skills/capture-feedback/SKILL.md +47 -0
- package/plugins/cursor-marketplace/skills/prevention-rules/SKILL.md +31 -0
- package/plugins/cursor-marketplace/skills/recall-context/SKILL.md +30 -0
- package/plugins/cursor-marketplace/skills/search-lessons/SKILL.md +33 -0
- package/plugins/gemini-extension/INSTALL.md +92 -0
- package/plugins/gemini-extension/gemini_prompt.txt +14 -0
- package/plugins/gemini-extension/tool_contract.json +45 -0
- package/plugins/opencode-profile/INSTALL.md +57 -0
- package/public/assets/instagram-card.png +0 -0
- package/public/assets/tiktok-agent-memory.mp4 +0 -0
- package/public/blog.html +400 -0
- package/public/dashboard.html +1093 -0
- package/public/guide.html +317 -0
- package/public/index.html +1195 -0
- package/public/learn/agent-harness-pattern.html +180 -0
- package/public/learn/ai-agent-persistent-memory.html +202 -0
- package/public/learn/learn.css +45 -0
- package/public/learn/mcp-pre-action-gates-explained.html +172 -0
- package/public/learn/stop-ai-agent-force-push.html +134 -0
- package/public/learn/vibe-coding-safety-net.html +142 -0
- package/public/learn.html +213 -0
- package/public/lessons.html +650 -0
- package/public/vercel.json +8 -0
- package/scripts/__pycache__/train_from_feedback.cpython-314.pyc +0 -0
- package/scripts/a2ui-engine.js +73 -0
- package/scripts/access-anomaly-detector.js +12 -0
- package/scripts/adk-consolidator.js +266 -0
- package/scripts/agent-readiness.js +220 -0
- package/scripts/agent-security-hardening.js +227 -0
- package/scripts/agentic-data-pipeline.js +847 -0
- package/scripts/analytics-report.js +328 -0
- package/scripts/analytics-window.js +158 -0
- package/scripts/async-job-runner.js +1001 -0
- package/scripts/audit-trail.js +398 -0
- package/scripts/auto-promote-gates.js +293 -0
- package/scripts/auto-wire-hooks.js +316 -0
- package/scripts/autonomous-sales-agent.js +39 -0
- package/scripts/autoresearch-runner.js +216 -0
- package/scripts/background-agent-governance.js +237 -0
- package/scripts/behavioral-extraction.js +93 -0
- package/scripts/belief-update.js +84 -0
- package/scripts/billing.js +2438 -0
- package/scripts/bot-detector.js +50 -0
- package/scripts/budget-guard.js +173 -0
- package/scripts/build-claude-mcpb.js +189 -0
- package/scripts/build-metadata.js +97 -0
- package/scripts/check-congruence.js +322 -0
- package/scripts/cli-feedback.js +135 -0
- package/scripts/cli-telemetry.js +87 -0
- package/scripts/cloudflare-dynamic-sandbox.js +315 -0
- package/scripts/code-reasoning.js +350 -0
- package/scripts/codegraph-context.js +466 -0
- package/scripts/commercial-offer.js +56 -0
- package/scripts/computer-use-firewall.js +250 -0
- package/scripts/context-engine.js +694 -0
- package/scripts/contextfs.js +1287 -0
- package/scripts/conversation-context.js +119 -0
- package/scripts/creator-campaigns.js +239 -0
- package/scripts/daemon-manager.js +108 -0
- package/scripts/daily-digest.js +11 -0
- package/scripts/dashboard-render-spec.js +395 -0
- package/scripts/dashboard.js +1058 -0
- package/scripts/data-governance.js +173 -0
- package/scripts/delegation-runtime.js +900 -0
- package/scripts/deploy-gcp.sh +44 -0
- package/scripts/deploy-policy.js +231 -0
- package/scripts/disagreement-mining.js +315 -0
- package/scripts/dispatch-brief.js +159 -0
- package/scripts/distribution-surfaces.js +44 -0
- package/scripts/dpo-optimizer.js +206 -0
- package/scripts/ensure-repo-bootstrap.js +129 -0
- package/scripts/ephemeral-agent-store.js +219 -0
- package/scripts/eval-harness.js +56 -0
- package/scripts/evolution-state.js +241 -0
- package/scripts/experiment-tracker.js +267 -0
- package/scripts/export-databricks-bundle.js +242 -0
- package/scripts/export-dpo-pairs.js +344 -0
- package/scripts/export-kto-pairs.js +309 -0
- package/scripts/export-training.js +450 -0
- package/scripts/failure-diagnostics.js +558 -0
- package/scripts/feedback-attribution.js +313 -0
- package/scripts/feedback-fallback.js +110 -0
- package/scripts/feedback-history-distiller.js +391 -0
- package/scripts/feedback-inbox-read.js +162 -0
- package/scripts/feedback-loop.js +1887 -0
- package/scripts/feedback-paths.js +145 -0
- package/scripts/feedback-quality.js +139 -0
- package/scripts/feedback-root-consolidator.js +238 -0
- package/scripts/feedback-schema.js +426 -0
- package/scripts/feedback-session.js +286 -0
- package/scripts/feedback-to-memory.js +185 -0
- package/scripts/feedback-to-rules.js +164 -0
- package/scripts/filesystem-search.js +405 -0
- package/scripts/funnel-analytics.js +35 -0
- package/scripts/gate-satisfy.js +42 -0
- package/scripts/gate-stats.js +116 -0
- package/scripts/gate-templates.js +70 -0
- package/scripts/gates-engine.js +816 -0
- package/scripts/generate-paperbanana-diagrams.sh +99 -0
- package/scripts/generate-pretool-hook.sh +40 -0
- package/scripts/github-about.js +350 -0
- package/scripts/github-outreach.js +65 -0
- package/scripts/gtm-revenue-loop.js +520 -0
- package/scripts/hallucination-detector.js +226 -0
- package/scripts/hf-papers.js +317 -0
- package/scripts/history-distiller.js +200 -0
- package/scripts/hook-auto-capture.sh +100 -0
- package/scripts/hook-stop-pr-thread-check.sh +68 -0
- package/scripts/hook-stop-self-score.sh +51 -0
- package/scripts/hook-stop-verify-deploy.sh +31 -0
- package/scripts/hook-thumbgate-cache-updater.js +48 -0
- package/scripts/hook-verify-before-done.sh +20 -0
- package/scripts/hosted-config.js +156 -0
- package/scripts/hybrid-feedback-context.js +675 -0
- package/scripts/install-mcp.js +159 -0
- package/scripts/intent-router.js +392 -0
- package/scripts/internal-agent-bootstrap.js +490 -0
- package/scripts/jsonl-watcher.js +155 -0
- package/scripts/lesson-db.js +613 -0
- package/scripts/lesson-inference.js +310 -0
- package/scripts/lesson-retrieval.js +95 -0
- package/scripts/lesson-rotation.js +137 -0
- package/scripts/lesson-search.js +644 -0
- package/scripts/lesson-synthesis.js +196 -0
- package/scripts/license.js +50 -0
- package/scripts/local-model-profile.js +384 -0
- package/scripts/markdown-escape.js +12 -0
- package/scripts/marketing-experiment.js +671 -0
- package/scripts/mcp-config.js +149 -0
- package/scripts/mcp-policy.js +99 -0
- package/scripts/memalign-recall.js +111 -0
- package/scripts/memory-firewall.js +222 -0
- package/scripts/memory-migration.js +296 -0
- package/scripts/meta-policy.js +190 -0
- package/scripts/metered-billing.js +16 -0
- package/scripts/model-tier-router.js +301 -0
- package/scripts/money-watcher.js +71 -0
- package/scripts/multi-hop-recall.js +240 -0
- package/scripts/natural-language-harness.js +330 -0
- package/scripts/obsidian-export.js +713 -0
- package/scripts/operational-dashboard.js +103 -0
- package/scripts/operational-summary.js +93 -0
- package/scripts/optimize-context.js +17 -0
- package/scripts/org-dashboard.js +201 -0
- package/scripts/partner-orchestration.js +146 -0
- package/scripts/per-step-scoring.js +165 -0
- package/scripts/perplexity-marketing.js +466 -0
- package/scripts/pii-scanner.js +153 -0
- package/scripts/plan-gate.js +154 -0
- package/scripts/post-everywhere.js +308 -0
- package/scripts/post-to-x-retry.sh +22 -0
- package/scripts/post-to-x.js +369 -0
- package/scripts/pr-manager.js +236 -0
- package/scripts/predictive-insights.js +356 -0
- package/scripts/principle-extractor.js +162 -0
- package/scripts/pro-features.js +40 -0
- package/scripts/pro-local-dashboard.js +174 -0
- package/scripts/problem-detail.js +53 -0
- package/scripts/product-feedback.js +134 -0
- package/scripts/profile-router.js +245 -0
- package/scripts/prompt-dlp.js +221 -0
- package/scripts/prompt-guard.js +83 -0
- package/scripts/prove-adapters.js +863 -0
- package/scripts/prove-attribution.js +365 -0
- package/scripts/prove-automation.js +653 -0
- package/scripts/prove-autoresearch.js +304 -0
- package/scripts/prove-claim-verification.js +277 -0
- package/scripts/prove-cloudflare-sandbox.js +163 -0
- package/scripts/prove-data-pipeline.js +410 -0
- package/scripts/prove-data-quality.js +227 -0
- package/scripts/prove-evolution.js +352 -0
- package/scripts/prove-harnesses.js +287 -0
- package/scripts/prove-intelligence.js +259 -0
- package/scripts/prove-lancedb.js +371 -0
- package/scripts/prove-local-intelligence.js +342 -0
- package/scripts/prove-loop-closure.js +263 -0
- package/scripts/prove-predictive-insights.js +357 -0
- package/scripts/prove-runtime.js +350 -0
- package/scripts/prove-seo-gsd.js +234 -0
- package/scripts/prove-settings.js +279 -0
- package/scripts/prove-subway-upgrades.js +277 -0
- package/scripts/prove-tessl.js +229 -0
- package/scripts/prove-training-export.js +327 -0
- package/scripts/prove-workflow-contract.js +116 -0
- package/scripts/prove-xmemory.js +332 -0
- package/scripts/publish-decision.js +133 -0
- package/scripts/pulse.js +80 -0
- package/scripts/rate-limiter.js +125 -0
- package/scripts/reddit-dm-outreach.js +182 -0
- package/scripts/reddit-monitor-cron.sh +26 -0
- package/scripts/reflector-agent.js +221 -0
- package/scripts/reminder-engine.js +132 -0
- package/scripts/revenue-status.js +472 -0
- package/scripts/risk-scorer.js +459 -0
- package/scripts/rlaif-self-audit.js +129 -0
- package/scripts/rlhf_session_start.sh +32 -0
- package/scripts/rubric-engine.js +230 -0
- package/scripts/schedule-manager.js +251 -0
- package/scripts/secret-scanner.js +414 -0
- package/scripts/self-heal.js +147 -0
- package/scripts/self-healing-check.js +188 -0
- package/scripts/semantic-layer.js +98 -0
- package/scripts/seo-gsd.js +1153 -0
- package/scripts/settings-hierarchy.js +214 -0
- package/scripts/shieldcortex-memory-firewall-runner.mjs +53 -0
- package/scripts/skill-exporter.js +262 -0
- package/scripts/skill-generator.js +446 -0
- package/scripts/skill-materializer.js +134 -0
- package/scripts/skill-packs.js +136 -0
- package/scripts/skill-proposer.js +99 -0
- package/scripts/skill-quality-tracker.js +282 -0
- package/scripts/slo-alert-engine.js +14 -0
- package/scripts/slow-loop.js +72 -0
- package/scripts/social-analytics/db/schema.sql +32 -0
- package/scripts/social-analytics/db/social-analytics.db +0 -0
- package/scripts/social-analytics/digest.js +256 -0
- package/scripts/social-analytics/generate-instagram-card.js +97 -0
- package/scripts/social-analytics/instagram-thumbgate-post.js +107 -0
- package/scripts/social-analytics/load-env.js +46 -0
- package/scripts/social-analytics/mcp-server.js +289 -0
- package/scripts/social-analytics/normalizer.js +580 -0
- package/scripts/social-analytics/notify.js +162 -0
- package/scripts/social-analytics/poll-all.js +92 -0
- package/scripts/social-analytics/pollers/github.js +195 -0
- package/scripts/social-analytics/pollers/instagram.js +253 -0
- package/scripts/social-analytics/pollers/linkedin.js +330 -0
- package/scripts/social-analytics/pollers/plausible.js +247 -0
- package/scripts/social-analytics/pollers/reddit.js +306 -0
- package/scripts/social-analytics/pollers/threads.js +233 -0
- package/scripts/social-analytics/pollers/tiktok.js +203 -0
- package/scripts/social-analytics/pollers/x.js +227 -0
- package/scripts/social-analytics/pollers/youtube.js +304 -0
- package/scripts/social-analytics/pollers/zernio.js +183 -0
- package/scripts/social-analytics/publish-instagram-thumbgate.js +98 -0
- package/scripts/social-analytics/publish-thumbgate-launch.js +316 -0
- package/scripts/social-analytics/publishers/devto.js +122 -0
- package/scripts/social-analytics/publishers/instagram.js +317 -0
- package/scripts/social-analytics/publishers/linkedin.js +294 -0
- package/scripts/social-analytics/publishers/reddit.js +390 -0
- package/scripts/social-analytics/publishers/threads.js +275 -0
- package/scripts/social-analytics/publishers/tiktok.js +217 -0
- package/scripts/social-analytics/publishers/x.js +259 -0
- package/scripts/social-analytics/publishers/youtube.js +223 -0
- package/scripts/social-analytics/publishers/zernio.js +378 -0
- package/scripts/social-analytics/run-digest.js +34 -0
- package/scripts/social-analytics/store.js +257 -0
- package/scripts/social-analytics/utm.js +143 -0
- package/scripts/social-pipeline.js +2628 -0
- package/scripts/social-quality-gate.js +18 -0
- package/scripts/social-reply-monitor.js +445 -0
- package/scripts/status-dashboard.js +155 -0
- package/scripts/statusline-lesson.js +16 -0
- package/scripts/statusline-tower.js +8 -0
- package/scripts/statusline.sh +116 -0
- package/scripts/stripe-live-status.js +115 -0
- package/scripts/subagent-profiles.js +79 -0
- package/scripts/sync-gh-secrets-from-env.sh +70 -0
- package/scripts/sync-github-about.js +52 -0
- package/scripts/sync-version.js +447 -0
- package/scripts/synthetic-dpo.js +234 -0
- package/scripts/telemetry-analytics.js +821 -0
- package/scripts/tessl-export.js +371 -0
- package/scripts/test-coverage.js +120 -0
- package/scripts/thompson-sampling.js +417 -0
- package/scripts/thumbgate-search.js +189 -0
- package/scripts/tool-kpi-tracker.js +12 -0
- package/scripts/tool-registry.js +811 -0
- package/scripts/train_from_feedback.py +933 -0
- package/scripts/user-profile.js +78 -0
- package/scripts/validate-feedback.js +581 -0
- package/scripts/validate-workflow-contract.js +287 -0
- package/scripts/vector-store.js +197 -0
- package/scripts/verification-loop.js +291 -0
- package/scripts/verify-obsidian-setup.sh +269 -0
- package/scripts/verify-run.js +269 -0
- package/scripts/webhook-delivery.js +62 -0
- package/scripts/weekly-auto-post.js +124 -0
- package/scripts/workflow-runs.js +154 -0
- package/scripts/workflow-sprint-intake.js +475 -0
- package/scripts/workspace-evolver.js +374 -0
- package/scripts/x-autonomous-marketing.js +139 -0
- package/scripts/xmemory-lite.js +405 -0
- package/skills/agent-memory/SKILL.md +97 -0
- package/skills/rlhf-feedback/SKILL.md +49 -0
- package/skills/solve-architecture-autonomy/SKILL.md +17 -0
- package/skills/solve-architecture-autonomy/tool.js +33 -0
- package/skills/thumbgate/SKILL.md +114 -0
- package/src/api/server.js +4206 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const fs = require('node:fs');
|
|
5
|
+
const os = require('node:os');
|
|
6
|
+
const path = require('node:path');
|
|
7
|
+
const { spawnSync } = require('node:child_process');
|
|
8
|
+
|
|
9
|
+
const { appendWorkflowRun } = require('./workflow-runs');
|
|
10
|
+
|
|
11
|
+
function npmCommand() {
|
|
12
|
+
return process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function buildVerifyPlan(mode = 'quick') {
|
|
16
|
+
if (mode === 'quick') {
|
|
17
|
+
return [
|
|
18
|
+
{ command: 'node', args: ['--test', 'tests/verify-run.test.js'] },
|
|
19
|
+
{ command: npmCommand(), args: ['run', 'test:cli'] },
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (mode === 'full') {
|
|
24
|
+
return [
|
|
25
|
+
{ command: npmCommand(), args: ['test'] },
|
|
26
|
+
{ command: npmCommand(), args: ['run', 'test:coverage'] },
|
|
27
|
+
{ command: npmCommand(), args: ['run', 'prove:adapters'] },
|
|
28
|
+
{ command: npmCommand(), args: ['run', 'prove:automation'] },
|
|
29
|
+
{ command: npmCommand(), args: ['run', 'prove:claim-verification'] },
|
|
30
|
+
{ command: npmCommand(), args: ['run', 'prove:cloudflare-sandbox'] },
|
|
31
|
+
{ command: npmCommand(), args: ['run', 'prove:data-pipeline'] },
|
|
32
|
+
{ command: npmCommand(), args: ['run', 'prove:evolution'] },
|
|
33
|
+
{ command: npmCommand(), args: ['run', 'prove:harnesses'] },
|
|
34
|
+
{ command: npmCommand(), args: ['run', 'prove:local-intelligence'] },
|
|
35
|
+
{ command: npmCommand(), args: ['run', 'prove:predictive-insights'] },
|
|
36
|
+
{ command: npmCommand(), args: ['run', 'prove:runtime'] },
|
|
37
|
+
{ command: npmCommand(), args: ['run', 'prove:settings'] },
|
|
38
|
+
{ command: npmCommand(), args: ['run', 'prove:seo-gsd'] },
|
|
39
|
+
{ command: npmCommand(), args: ['run', 'prove:tessl'] },
|
|
40
|
+
{ command: npmCommand(), args: ['run', 'prove:xmemory'] },
|
|
41
|
+
{ command: npmCommand(), args: ['run', 'self-heal:check'] },
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
throw new Error(`Unsupported verify mode: ${mode}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function runPlan(plan, env = process.env, cwd = process.cwd()) {
|
|
49
|
+
for (const step of plan) {
|
|
50
|
+
console.log(`$ ${step.command} ${step.args.join(' ')}`.trim());
|
|
51
|
+
const result = spawnSync(step.command, step.args, {
|
|
52
|
+
cwd,
|
|
53
|
+
env,
|
|
54
|
+
stdio: 'inherit',
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (result.status !== 0) {
|
|
58
|
+
const joined = [step.command, ...step.args].join(' ');
|
|
59
|
+
throw new Error(`Verification failed: ${joined}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function copyArtifactIfPresent(sourcePath, targetPath) {
|
|
65
|
+
if (!fs.existsSync(sourcePath)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
70
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function materializeProofArtifacts(tempRoot, cwd = process.cwd()) {
|
|
75
|
+
const artifacts = [
|
|
76
|
+
{
|
|
77
|
+
source: path.join(tempRoot, 'proof-adapters', 'report.json'),
|
|
78
|
+
target: path.join(cwd, 'proof', 'compatibility', 'report.json'),
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
source: path.join(tempRoot, 'proof-adapters', 'report.md'),
|
|
82
|
+
target: path.join(cwd, 'proof', 'compatibility', 'report.md'),
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
source: path.join(tempRoot, 'proof-automation', 'report.json'),
|
|
86
|
+
target: path.join(cwd, 'proof', 'automation', 'report.json'),
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
source: path.join(tempRoot, 'proof-automation', 'report.md'),
|
|
90
|
+
target: path.join(cwd, 'proof', 'automation', 'report.md'),
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
source: path.join(tempRoot, 'proof-adapters', 'cloudflare-sandbox-report.json'),
|
|
94
|
+
target: path.join(cwd, 'proof', 'cloudflare-sandbox-report.json'),
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
source: path.join(tempRoot, 'proof-adapters', 'cloudflare-sandbox-report.md'),
|
|
98
|
+
target: path.join(cwd, 'proof', 'cloudflare-sandbox-report.md'),
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
source: path.join(tempRoot, 'proof-adapters', 'claim-verification-report.json'),
|
|
102
|
+
target: path.join(cwd, 'proof', 'claim-verification-report.json'),
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
source: path.join(tempRoot, 'proof-adapters', 'claim-verification-report.md'),
|
|
106
|
+
target: path.join(cwd, 'proof', 'claim-verification-report.md'),
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
source: path.join(tempRoot, 'proof-adapters', 'data-pipeline-report.json'),
|
|
110
|
+
target: path.join(cwd, 'proof', 'data-pipeline-report.json'),
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
source: path.join(tempRoot, 'proof-adapters', 'data-pipeline-report.md'),
|
|
114
|
+
target: path.join(cwd, 'proof', 'data-pipeline-report.md'),
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
source: path.join(tempRoot, 'proof-adapters', 'evolution-report.json'),
|
|
118
|
+
target: path.join(cwd, 'proof', 'evolution-report.json'),
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
source: path.join(tempRoot, 'proof-adapters', 'evolution-report.md'),
|
|
122
|
+
target: path.join(cwd, 'proof', 'evolution-report.md'),
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
source: path.join(tempRoot, 'proof-harnesses', 'harnesses-report.json'),
|
|
126
|
+
target: path.join(cwd, 'proof', 'harnesses-report.json'),
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
source: path.join(tempRoot, 'proof-harnesses', 'harnesses-report.md'),
|
|
130
|
+
target: path.join(cwd, 'proof', 'harnesses-report.md'),
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
source: path.join(tempRoot, 'proof-adapters', 'local-intelligence-report.json'),
|
|
134
|
+
target: path.join(cwd, 'proof', 'local-intelligence-report.json'),
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
source: path.join(tempRoot, 'proof-adapters', 'local-intelligence-report.md'),
|
|
138
|
+
target: path.join(cwd, 'proof', 'local-intelligence-report.md'),
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
source: path.join(tempRoot, 'proof-adapters', 'predictive-insights-report.json'),
|
|
142
|
+
target: path.join(cwd, 'proof', 'predictive-insights-report.json'),
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
source: path.join(tempRoot, 'proof-adapters', 'predictive-insights-report.md'),
|
|
146
|
+
target: path.join(cwd, 'proof', 'predictive-insights-report.md'),
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
source: path.join(tempRoot, 'proof-runtime', 'runtime-report.json'),
|
|
150
|
+
target: path.join(cwd, 'proof', 'runtime-report.json'),
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
source: path.join(tempRoot, 'proof-runtime', 'runtime-report.md'),
|
|
154
|
+
target: path.join(cwd, 'proof', 'runtime-report.md'),
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
source: path.join(tempRoot, 'proof-settings', 'settings-report.json'),
|
|
158
|
+
target: path.join(cwd, 'proof', 'settings-report.json'),
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
source: path.join(tempRoot, 'proof-settings', 'settings-report.md'),
|
|
162
|
+
target: path.join(cwd, 'proof', 'settings-report.md'),
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
source: path.join(tempRoot, 'proof-adapters', 'seo-gsd-report.json'),
|
|
166
|
+
target: path.join(cwd, 'proof', 'seo-gsd-report.json'),
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
source: path.join(tempRoot, 'proof-adapters', 'seo-gsd-report.md'),
|
|
170
|
+
target: path.join(cwd, 'proof', 'seo-gsd-report.md'),
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
source: path.join(tempRoot, 'proof-adapters', 'tessl-report.json'),
|
|
174
|
+
target: path.join(cwd, 'proof', 'tessl-report.json'),
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
source: path.join(tempRoot, 'proof-adapters', 'tessl-report.md'),
|
|
178
|
+
target: path.join(cwd, 'proof', 'tessl-report.md'),
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
source: path.join(tempRoot, 'proof-adapters', 'xmemory-report.json'),
|
|
182
|
+
target: path.join(cwd, 'proof', 'xmemory-report.json'),
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
source: path.join(tempRoot, 'proof-adapters', 'xmemory-report.md'),
|
|
186
|
+
target: path.join(cwd, 'proof', 'xmemory-report.md'),
|
|
187
|
+
},
|
|
188
|
+
];
|
|
189
|
+
|
|
190
|
+
return artifacts
|
|
191
|
+
.filter(({ source, target }) => copyArtifactIfPresent(source, target))
|
|
192
|
+
.map(({ target }) => target);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function recordVerifyWorkflowRun(mode = 'quick', cwd = process.cwd(), feedbackDir = undefined) {
|
|
196
|
+
if (mode !== 'full') return null;
|
|
197
|
+
return appendWorkflowRun({
|
|
198
|
+
workflowId: 'repo_self_dogfood_full_verify',
|
|
199
|
+
workflowName: 'Repo self dogfood full verification',
|
|
200
|
+
owner: 'cto',
|
|
201
|
+
runtime: 'node',
|
|
202
|
+
status: 'passed',
|
|
203
|
+
customerType: 'internal_dogfood',
|
|
204
|
+
teamId: 'internal_repo',
|
|
205
|
+
reviewed: true,
|
|
206
|
+
reviewedBy: 'automation',
|
|
207
|
+
proofBacked: true,
|
|
208
|
+
source: 'verify:full',
|
|
209
|
+
proofArtifacts: [
|
|
210
|
+
path.join(cwd, 'docs', 'VERIFICATION_EVIDENCE.md'),
|
|
211
|
+
path.join(cwd, 'proof', 'compatibility', 'report.json'),
|
|
212
|
+
path.join(cwd, 'proof', 'automation', 'report.json'),
|
|
213
|
+
path.join(cwd, 'proof', 'cloudflare-sandbox-report.json'),
|
|
214
|
+
path.join(cwd, 'proof', 'claim-verification-report.json'),
|
|
215
|
+
path.join(cwd, 'proof', 'data-pipeline-report.json'),
|
|
216
|
+
path.join(cwd, 'proof', 'evolution-report.json'),
|
|
217
|
+
path.join(cwd, 'proof', 'harnesses-report.json'),
|
|
218
|
+
path.join(cwd, 'proof', 'local-intelligence-report.json'),
|
|
219
|
+
path.join(cwd, 'proof', 'predictive-insights-report.json'),
|
|
220
|
+
path.join(cwd, 'proof', 'runtime-report.json'),
|
|
221
|
+
path.join(cwd, 'proof', 'settings-report.json'),
|
|
222
|
+
path.join(cwd, 'proof', 'seo-gsd-report.json'),
|
|
223
|
+
path.join(cwd, 'proof', 'tessl-report.json'),
|
|
224
|
+
path.join(cwd, 'proof', 'xmemory-report.json'),
|
|
225
|
+
],
|
|
226
|
+
metadata: {
|
|
227
|
+
suite: 'repo_verify_full',
|
|
228
|
+
},
|
|
229
|
+
}, feedbackDir);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function runVerify(mode = 'quick', baseEnv = process.env, cwd = process.cwd()) {
|
|
233
|
+
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'rlhf-verify-'));
|
|
234
|
+
const env = {
|
|
235
|
+
...baseEnv,
|
|
236
|
+
THUMBGATE_PROOF_DIR: path.join(tempRoot, 'proof-adapters'),
|
|
237
|
+
THUMBGATE_AUTOMATION_PROOF_DIR: path.join(tempRoot, 'proof-automation'),
|
|
238
|
+
THUMBGATE_HARNESSES_PROOF_DIR: path.join(tempRoot, 'proof-harnesses'),
|
|
239
|
+
THUMBGATE_RUNTIME_PROOF_DIR: path.join(tempRoot, 'proof-runtime'),
|
|
240
|
+
THUMBGATE_SETTINGS_PROOF_DIR: path.join(tempRoot, 'proof-settings'),
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
runPlan(buildVerifyPlan(mode), env, cwd);
|
|
244
|
+
materializeProofArtifacts(tempRoot, cwd);
|
|
245
|
+
const workflowRun = recordVerifyWorkflowRun(mode, cwd);
|
|
246
|
+
|
|
247
|
+
return {
|
|
248
|
+
mode,
|
|
249
|
+
tempRoot,
|
|
250
|
+
workflowRun,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (require.main === module) {
|
|
255
|
+
try {
|
|
256
|
+
runVerify(process.argv[2] || 'quick');
|
|
257
|
+
} catch (error) {
|
|
258
|
+
console.error(error.message);
|
|
259
|
+
process.exit(1);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
module.exports = {
|
|
264
|
+
buildVerifyPlan,
|
|
265
|
+
materializeProofArtifacts,
|
|
266
|
+
recordVerifyWorkflowRun,
|
|
267
|
+
runPlan,
|
|
268
|
+
runVerify,
|
|
269
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const https = require('https');
|
|
5
|
+
const http = require('http');
|
|
6
|
+
|
|
7
|
+
function sendWebhook(webhookUrl, payload) {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const url = new URL(webhookUrl);
|
|
10
|
+
const mod = url.protocol === 'https:' ? https : http;
|
|
11
|
+
const body = JSON.stringify(payload);
|
|
12
|
+
|
|
13
|
+
const req = mod.request(url, {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) },
|
|
16
|
+
timeout: 10000,
|
|
17
|
+
}, (res) => {
|
|
18
|
+
let data = '';
|
|
19
|
+
res.on('data', (c) => { data += c; });
|
|
20
|
+
res.on('end', () => resolve({ status: res.statusCode, body: data }));
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
req.on('error', reject);
|
|
24
|
+
req.on('timeout', () => { req.destroy(); reject(new Error('Webhook timeout')); });
|
|
25
|
+
req.write(body);
|
|
26
|
+
req.end();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function deliverToTeams(webhookUrl, title, message) {
|
|
31
|
+
return sendWebhook(webhookUrl, {
|
|
32
|
+
'@type': 'MessageCard',
|
|
33
|
+
'@context': 'http://schema.org/extensions',
|
|
34
|
+
summary: title,
|
|
35
|
+
themeColor: '0076D7',
|
|
36
|
+
title,
|
|
37
|
+
text: message,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function deliverToSlack(webhookUrl, title, message) {
|
|
42
|
+
return sendWebhook(webhookUrl, {
|
|
43
|
+
text: `*${title}*\n${message}`,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function deliverToDiscord(webhookUrl, title, message) {
|
|
48
|
+
return sendWebhook(webhookUrl, {
|
|
49
|
+
embeds: [{ title, description: message.substring(0, 4096), color: 0x0076D7 }],
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function deliver(platform, webhookUrl, title, message) {
|
|
54
|
+
switch (platform) {
|
|
55
|
+
case 'teams': return deliverToTeams(webhookUrl, title, message);
|
|
56
|
+
case 'slack': return deliverToSlack(webhookUrl, title, message);
|
|
57
|
+
case 'discord': return deliverToDiscord(webhookUrl, title, message);
|
|
58
|
+
default: return sendWebhook(webhookUrl, { title, message });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = { deliver, deliverToTeams, deliverToSlack, deliverToDiscord, sendWebhook };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Weekly Auto-Post — build-in-public experiment loop.
|
|
6
|
+
*
|
|
7
|
+
* Every week, auto-generates a social post from ThumbGate stats
|
|
8
|
+
* ("X mistakes blocked, Y hours saved") and posts to configured platforms.
|
|
9
|
+
* Closes the deploy → measure → share → compound loop.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const os = require('os');
|
|
15
|
+
const { generateWeeklyStatsPost } = require('./daily-digest');
|
|
16
|
+
const { createSchedule } = require('./schedule-manager');
|
|
17
|
+
|
|
18
|
+
const POSTS_DIR = path.join(os.homedir(), '.rlhf', 'weekly-posts');
|
|
19
|
+
|
|
20
|
+
function ensureDir(p) { if (!fs.existsSync(p)) fs.mkdirSync(p, { recursive: true }); }
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Generate a weekly stats post file in post-everywhere format.
|
|
24
|
+
* Returns the file path.
|
|
25
|
+
*/
|
|
26
|
+
function generateWeeklyPostFile({ periodDays = 7 } = {}) {
|
|
27
|
+
const { post, stats } = generateWeeklyStatsPost({ periodDays });
|
|
28
|
+
|
|
29
|
+
const date = new Date().toISOString().slice(0, 10);
|
|
30
|
+
const filename = `weekly-stats-${date}.md`;
|
|
31
|
+
|
|
32
|
+
// Build post-everywhere compatible frontmatter
|
|
33
|
+
const content = [
|
|
34
|
+
'---',
|
|
35
|
+
`title: ThumbGate Weekly Stats — ${date}`,
|
|
36
|
+
'platform: x',
|
|
37
|
+
`tags: thumbgate, ai-agents, build-in-public`,
|
|
38
|
+
'---',
|
|
39
|
+
'',
|
|
40
|
+
post,
|
|
41
|
+
'',
|
|
42
|
+
'#ThumbGate #AIAgents #BuildInPublic',
|
|
43
|
+
].join('\n');
|
|
44
|
+
|
|
45
|
+
ensureDir(POSTS_DIR);
|
|
46
|
+
const filePath = path.join(POSTS_DIR, filename);
|
|
47
|
+
fs.writeFileSync(filePath, content);
|
|
48
|
+
|
|
49
|
+
return { filePath, filename, post, stats, date };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Generate and post weekly stats. Full pipeline.
|
|
54
|
+
* If dryRun is true, generates the file but doesn't post.
|
|
55
|
+
*/
|
|
56
|
+
async function runWeeklyPost({ periodDays = 7, platforms, dryRun = false } = {}) {
|
|
57
|
+
const generated = generateWeeklyPostFile({ periodDays });
|
|
58
|
+
|
|
59
|
+
let postResult = null;
|
|
60
|
+
let zernioResult = null;
|
|
61
|
+
|
|
62
|
+
if (!dryRun) {
|
|
63
|
+
// Primary: Zernio API (posts to all connected platforms — X, LinkedIn, Instagram, TikTok)
|
|
64
|
+
try {
|
|
65
|
+
const { publishToAllPlatforms } = require('./social-analytics/publishers/zernio');
|
|
66
|
+
zernioResult = await publishToAllPlatforms(generated.post);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
zernioResult = { error: err.message };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Fallback: post-everywhere (if Zernio fails or specific platforms needed)
|
|
72
|
+
if (zernioResult && zernioResult.error && platforms) {
|
|
73
|
+
try {
|
|
74
|
+
const { postEverywhere } = require('./post-everywhere');
|
|
75
|
+
postResult = await postEverywhere(generated.filePath, { platforms, dryRun });
|
|
76
|
+
} catch (err) {
|
|
77
|
+
postResult = { error: err.message };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
generated,
|
|
84
|
+
posted: !dryRun,
|
|
85
|
+
zernioResult,
|
|
86
|
+
postResult,
|
|
87
|
+
dryRun,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Create a weekly schedule for auto-posting.
|
|
93
|
+
* Default: every Monday at 10:00 AM.
|
|
94
|
+
*/
|
|
95
|
+
function createWeeklyPostSchedule({ day = 'monday', time = '10:00', dryRun = false } = {}) {
|
|
96
|
+
const command = [
|
|
97
|
+
`const wp = require(${JSON.stringify(__filename)});`,
|
|
98
|
+
`wp.runWeeklyPost(${JSON.stringify({ dryRun })})`,
|
|
99
|
+
'.then(r => { process.stdout.write(JSON.stringify(r, null, 2) + "\\n"); })',
|
|
100
|
+
'.catch(e => { process.stderr.write(e.message + "\\n"); process.exit(1); });',
|
|
101
|
+
].join(' ');
|
|
102
|
+
|
|
103
|
+
return createSchedule({
|
|
104
|
+
id: 'thumbgate-weekly-post',
|
|
105
|
+
name: 'ThumbGate Weekly Build-in-Public Post',
|
|
106
|
+
description: `Weekly stats post every ${day} at ${time}`,
|
|
107
|
+
schedule: `weekly ${day} ${time}`,
|
|
108
|
+
command,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* List all generated weekly post files.
|
|
114
|
+
*/
|
|
115
|
+
function listWeeklyPosts() {
|
|
116
|
+
ensureDir(POSTS_DIR);
|
|
117
|
+
return fs.readdirSync(POSTS_DIR)
|
|
118
|
+
.filter((f) => f.endsWith('.md'))
|
|
119
|
+
.sort()
|
|
120
|
+
.reverse()
|
|
121
|
+
.map((f) => ({ filename: f, path: path.join(POSTS_DIR, f), date: f.match(/\d{4}-\d{2}-\d{2}/)?.[0] || null }));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
module.exports = { generateWeeklyPostFile, runWeeklyPost, createWeeklyPostSchedule, listWeeklyPosts, POSTS_DIR };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const { getFeedbackPaths } = require('./feedback-loop');
|
|
7
|
+
|
|
8
|
+
const WORKFLOW_RUNS_FILE_NAME = 'workflow-runs.jsonl';
|
|
9
|
+
const WEEK_IN_MS = 7 * 24 * 60 * 60 * 1000;
|
|
10
|
+
|
|
11
|
+
function getWorkflowRunsPath(feedbackDir = getFeedbackPaths().FEEDBACK_DIR) {
|
|
12
|
+
return path.join(feedbackDir, WORKFLOW_RUNS_FILE_NAME);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function normalizeText(value) {
|
|
16
|
+
if (value === undefined || value === null) return null;
|
|
17
|
+
const text = String(value).trim();
|
|
18
|
+
return text || null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function normalizeTimestamp(value) {
|
|
22
|
+
const text = normalizeText(value);
|
|
23
|
+
if (!text) return new Date().toISOString();
|
|
24
|
+
const parsed = Date.parse(text);
|
|
25
|
+
return Number.isNaN(parsed) ? new Date().toISOString() : new Date(parsed).toISOString();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function normalizeProofArtifacts(value) {
|
|
29
|
+
if (!Array.isArray(value)) return [];
|
|
30
|
+
return value
|
|
31
|
+
.map((entry) => normalizeText(entry))
|
|
32
|
+
.filter(Boolean);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function sanitizeWorkflowRun(entry = {}) {
|
|
36
|
+
const proofArtifacts = normalizeProofArtifacts(entry.proofArtifacts);
|
|
37
|
+
const proofBacked = Boolean(entry.proofBacked);
|
|
38
|
+
const reviewed = typeof entry.reviewed === 'boolean'
|
|
39
|
+
? entry.reviewed
|
|
40
|
+
: Boolean(entry.reviewedBy || proofArtifacts.length > 0);
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
timestamp: normalizeTimestamp(entry.timestamp),
|
|
44
|
+
workflowId: normalizeText(entry.workflowId) || 'unknown_workflow',
|
|
45
|
+
workflowName: normalizeText(entry.workflowName) || 'Unknown workflow',
|
|
46
|
+
owner: normalizeText(entry.owner) || 'unknown_owner',
|
|
47
|
+
runtime: normalizeText(entry.runtime) || 'unknown_runtime',
|
|
48
|
+
status: normalizeText(entry.status) || 'passed',
|
|
49
|
+
customerType: normalizeText(entry.customerType) || 'internal_dogfood',
|
|
50
|
+
teamId: normalizeText(entry.teamId),
|
|
51
|
+
reviewed,
|
|
52
|
+
reviewedBy: normalizeText(entry.reviewedBy),
|
|
53
|
+
proofBacked,
|
|
54
|
+
proofArtifacts,
|
|
55
|
+
source: normalizeText(entry.source),
|
|
56
|
+
metadata: entry.metadata && typeof entry.metadata === 'object' ? entry.metadata : {},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function resolveBusinessKey(entry = {}) {
|
|
61
|
+
const metadata = entry.metadata && typeof entry.metadata === 'object' ? entry.metadata : {};
|
|
62
|
+
return normalizeText(
|
|
63
|
+
metadata.leadId ||
|
|
64
|
+
metadata.pipelineLeadId ||
|
|
65
|
+
entry.teamId ||
|
|
66
|
+
entry.workflowId ||
|
|
67
|
+
entry.workflowName
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function countUniqueBusinessStates(entries = [], predicate) {
|
|
72
|
+
const keys = new Set();
|
|
73
|
+
let fallbackCount = 0;
|
|
74
|
+
for (const entry of entries) {
|
|
75
|
+
if (!predicate(entry)) continue;
|
|
76
|
+
const businessKey = resolveBusinessKey(entry);
|
|
77
|
+
if (businessKey) {
|
|
78
|
+
keys.add(businessKey);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
fallbackCount += 1;
|
|
82
|
+
}
|
|
83
|
+
return keys.size + fallbackCount;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function appendWorkflowRun(entry = {}, feedbackDir = getFeedbackPaths().FEEDBACK_DIR) {
|
|
87
|
+
const target = getWorkflowRunsPath(feedbackDir);
|
|
88
|
+
const sanitized = sanitizeWorkflowRun(entry);
|
|
89
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
90
|
+
fs.appendFileSync(target, `${JSON.stringify(sanitized)}\n`, 'utf-8');
|
|
91
|
+
return sanitized;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function loadWorkflowRuns(feedbackDir = getFeedbackPaths().FEEDBACK_DIR) {
|
|
95
|
+
const target = getWorkflowRunsPath(feedbackDir);
|
|
96
|
+
if (!fs.existsSync(target)) return [];
|
|
97
|
+
const raw = fs.readFileSync(target, 'utf-8').trim();
|
|
98
|
+
if (!raw) return [];
|
|
99
|
+
return raw
|
|
100
|
+
.split('\n')
|
|
101
|
+
.map((line) => {
|
|
102
|
+
try {
|
|
103
|
+
return sanitizeWorkflowRun(JSON.parse(line));
|
|
104
|
+
} catch {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
.filter(Boolean)
|
|
109
|
+
.sort((a, b) => String(a.timestamp).localeCompare(String(b.timestamp)));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function summarizeWorkflowRuns(feedbackDir = getFeedbackPaths().FEEDBACK_DIR, now = new Date()) {
|
|
113
|
+
const entries = loadWorkflowRuns(feedbackDir);
|
|
114
|
+
const windowStart = new Date(now.getTime() - WEEK_IN_MS).toISOString();
|
|
115
|
+
const proofBackedEntries = entries.filter((entry) => entry.proofBacked);
|
|
116
|
+
const recentProofBackedEntries = proofBackedEntries.filter((entry) => String(entry.timestamp) >= windowStart);
|
|
117
|
+
const weeklyWorkflowIds = new Set(recentProofBackedEntries.map((entry) => entry.workflowId).filter(Boolean));
|
|
118
|
+
const weeklyTeamKeys = new Set(
|
|
119
|
+
recentProofBackedEntries
|
|
120
|
+
.map((entry) => entry.teamId || `${entry.customerType}:${entry.workflowId}`)
|
|
121
|
+
.filter(Boolean)
|
|
122
|
+
);
|
|
123
|
+
const namedPilotAgreements = countUniqueBusinessStates(
|
|
124
|
+
entries,
|
|
125
|
+
(entry) => entry.customerType === 'named_pilot'
|
|
126
|
+
);
|
|
127
|
+
const paidTeamRuns = countUniqueBusinessStates(
|
|
128
|
+
entries,
|
|
129
|
+
(entry) => entry.customerType === 'paid_team'
|
|
130
|
+
);
|
|
131
|
+
const latestRun = entries.length ? entries[entries.length - 1] : null;
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
totalRuns: entries.length,
|
|
135
|
+
proofBackedRuns: proofBackedEntries.length,
|
|
136
|
+
reviewedRuns: entries.filter((entry) => entry.reviewed).length,
|
|
137
|
+
weeklyActiveProofBackedWorkflowRuns: weeklyWorkflowIds.size,
|
|
138
|
+
weeklyTeamsRunningProofBackedWorkflows: weeklyTeamKeys.size,
|
|
139
|
+
namedPilotAgreements,
|
|
140
|
+
paidTeamRuns,
|
|
141
|
+
northStarReached: weeklyWorkflowIds.size > 0,
|
|
142
|
+
customerProofReached: namedPilotAgreements > 0 || paidTeamRuns > 0,
|
|
143
|
+
latestRun,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
module.exports = {
|
|
148
|
+
WORKFLOW_RUNS_FILE_NAME,
|
|
149
|
+
appendWorkflowRun,
|
|
150
|
+
getWorkflowRunsPath,
|
|
151
|
+
loadWorkflowRuns,
|
|
152
|
+
sanitizeWorkflowRun,
|
|
153
|
+
summarizeWorkflowRuns,
|
|
154
|
+
};
|