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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.well-known/mcp/server-card.json +1 -1
- package/adapters/README.md +1 -1
- package/adapters/claude/.mcp.json +2 -2
- package/adapters/codex/config.toml +2 -2
- package/adapters/mcp/server-stdio.js +1 -1
- package/adapters/opencode/opencode.json +1 -1
- package/package.json +157 -9
- package/scripts/statusline.sh +1 -0
- package/src/api/server.js +113 -16
- package/src/index.js +3 -0
- package/.claude-plugin/bundle/icon.png +0 -0
- package/.claude-plugin/bundle/icon.svg +0 -18
- package/.claude-plugin/bundle/server/index.js +0 -24
- package/adapters/chatgpt/INSTALL.md +0 -158
- package/adapters/perplexity/.mcp.json +0 -36
- package/adapters/perplexity/config.toml +0 -16
- package/adapters/perplexity/opencode.json +0 -29
- package/bin/memory.sh +0 -64
- package/bin/obsidian-sync.sh +0 -20
- package/plugins/amp-skill/INSTALL.md +0 -52
- package/plugins/amp-skill/SKILL.md +0 -64
- package/plugins/claude-codex-bridge/.claude-plugin/plugin.json +0 -22
- package/plugins/claude-codex-bridge/.mcp.json +0 -14
- package/plugins/claude-codex-bridge/INSTALL.md +0 -43
- package/plugins/claude-codex-bridge/README.md +0 -46
- package/plugins/claude-codex-bridge/scripts/codex-bridge.js +0 -286
- package/plugins/claude-codex-bridge/skills/adversarial-review/SKILL.md +0 -24
- package/plugins/claude-codex-bridge/skills/result/SKILL.md +0 -22
- package/plugins/claude-codex-bridge/skills/review/SKILL.md +0 -28
- package/plugins/claude-codex-bridge/skills/second-pass/SKILL.md +0 -27
- package/plugins/claude-codex-bridge/skills/setup/SKILL.md +0 -21
- package/plugins/claude-codex-bridge/skills/status/SKILL.md +0 -19
- package/plugins/claude-skill/INSTALL.md +0 -55
- package/plugins/claude-skill/SKILL.md +0 -46
- package/plugins/codex-profile/.codex-plugin/plugin.json +0 -43
- package/plugins/codex-profile/.mcp.json +0 -14
- package/plugins/codex-profile/AGENTS.md +0 -20
- package/plugins/codex-profile/INSTALL.md +0 -89
- package/plugins/codex-profile/README.md +0 -61
- package/plugins/cursor-marketplace/.cursor-plugin/plugin.json +0 -23
- package/plugins/cursor-marketplace/CHANGELOG.md +0 -30
- package/plugins/cursor-marketplace/LICENSE +0 -21
- package/plugins/cursor-marketplace/README.md +0 -124
- package/plugins/cursor-marketplace/agents/reliability-reviewer.md +0 -31
- package/plugins/cursor-marketplace/assets/logo-400x400.png +0 -0
- package/plugins/cursor-marketplace/commands/capture-feedback.md +0 -33
- package/plugins/cursor-marketplace/commands/check-gates.md +0 -25
- package/plugins/cursor-marketplace/commands/show-lessons.md +0 -27
- package/plugins/cursor-marketplace/hooks/hooks.json +0 -10
- package/plugins/cursor-marketplace/mcp.json +0 -14
- package/plugins/cursor-marketplace/rules/feedback-capture.mdc +0 -34
- package/plugins/cursor-marketplace/rules/pre-action-gates.mdc +0 -30
- package/plugins/cursor-marketplace/rules/session-continuity.mdc +0 -28
- package/plugins/cursor-marketplace/scripts/gate-check.sh +0 -21
- package/plugins/cursor-marketplace/skills/capture-feedback/SKILL.md +0 -48
- package/plugins/cursor-marketplace/skills/prevention-rules/SKILL.md +0 -31
- package/plugins/cursor-marketplace/skills/recall-context/SKILL.md +0 -30
- package/plugins/cursor-marketplace/skills/search-lessons/SKILL.md +0 -33
- package/plugins/gemini-extension/INSTALL.md +0 -92
- package/plugins/gemini-extension/gemini_prompt.txt +0 -14
- package/plugins/gemini-extension/tool_contract.json +0 -45
- package/plugins/opencode-profile/INSTALL.md +0 -57
- package/public/assets/instagram-card.png +0 -0
- package/public/assets/tiktok-agent-memory.mp4 +0 -0
- package/public/blog.html +0 -474
- package/public/compare/mem0.html +0 -189
- package/public/compare/speclock.html +0 -180
- package/public/compare.html +0 -310
- package/public/dashboard.html +0 -1100
- package/public/guide.html +0 -317
- package/public/guides/claude-code-prevent-repeated-mistakes.html +0 -161
- package/public/guides/codex-cli-guardrails.html +0 -158
- package/public/guides/cursor-prevent-repeated-mistakes.html +0 -161
- package/public/guides/pre-action-gates.html +0 -162
- package/public/guides/stop-repeated-ai-agent-mistakes.html +0 -159
- package/public/index.html +0 -1225
- package/public/js/buyer-intent.js +0 -252
- package/public/learn/agent-harness-pattern.html +0 -180
- package/public/learn/ai-agent-persistent-memory.html +0 -203
- package/public/learn/learn.css +0 -45
- package/public/learn/mcp-pre-action-gates-explained.html +0 -172
- package/public/learn/stop-ai-agent-force-push.html +0 -134
- package/public/learn/vibe-coding-safety-net.html +0 -142
- package/public/learn.html +0 -274
- package/public/lessons.html +0 -967
- package/public/llm-context.md +0 -156
- package/public/pro.html +0 -1087
- package/public/vercel.json +0 -8
- package/scripts/a2ui-engine.js +0 -73
- package/scripts/adk-consolidator.js +0 -274
- package/scripts/agent-security-hardening.js +0 -225
- package/scripts/ai-search-visibility.js +0 -116
- package/scripts/autonomous-sales-agent.js +0 -39
- package/scripts/autoresearch-runner.js +0 -216
- package/scripts/background-agent-governance.js +0 -229
- package/scripts/behavioral-extraction.js +0 -93
- package/scripts/budget-enforcer.js +0 -173
- package/scripts/budget-guard.js +0 -173
- package/scripts/build-claude-mcpb.js +0 -255
- package/scripts/build-codex-plugin.js +0 -152
- package/scripts/capture-railway-diagnostics.sh +0 -97
- package/scripts/changeset-check.js +0 -372
- package/scripts/check-congruence.js +0 -443
- package/scripts/computer-use-firewall.js +0 -280
- package/scripts/content-engine/linkedin-content-generator.js +0 -154
- package/scripts/content-engine/output/linkedin-memento-validation.md +0 -17
- package/scripts/content-engine/output/linkedin-posts-2026-04-09.md +0 -175
- package/scripts/content-engine/reddit-thread-finder.js +0 -154
- package/scripts/context-engine.js +0 -710
- package/scripts/daily-digest.js +0 -11
- package/scripts/data-governance.js +0 -173
- package/scripts/deploy-gcp.sh +0 -44
- package/scripts/deploy-policy.js +0 -249
- package/scripts/disagreement-mining.js +0 -315
- package/scripts/dpo-optimizer.js +0 -206
- package/scripts/ensure-repo-bootstrap.js +0 -130
- package/scripts/ephemeral-agent-store.js +0 -212
- package/scripts/eval-harness.js +0 -56
- package/scripts/export-kto-pairs.js +0 -309
- package/scripts/export-training.js +0 -446
- package/scripts/feedback-fallback.js +0 -111
- package/scripts/feedback-inbox-read.js +0 -162
- package/scripts/feedback-root-consolidator.js +0 -233
- package/scripts/feedback-to-memory.js +0 -185
- package/scripts/gate-satisfy.js +0 -42
- package/scripts/generate-paperbanana-diagrams.sh +0 -99
- package/scripts/generate-pretool-hook.sh +0 -40
- package/scripts/github-about.js +0 -430
- package/scripts/github-outreach.js +0 -65
- package/scripts/gtm-revenue-loop.js +0 -535
- package/scripts/hallucination-detector.js +0 -226
- package/scripts/hf-papers.js +0 -317
- package/scripts/hook-auto-capture.sh +0 -100
- package/scripts/hook-stop-pr-thread-check.sh +0 -68
- package/scripts/hook-stop-self-score.sh +0 -51
- package/scripts/hook-stop-verify-deploy.sh +0 -31
- package/scripts/hook-verify-before-done.sh +0 -20
- package/scripts/managed-dpo-export.js +0 -91
- package/scripts/markdown-escape.js +0 -12
- package/scripts/marketing-experiment.js +0 -657
- package/scripts/memalign-recall.js +0 -111
- package/scripts/memory-migration.js +0 -296
- package/scripts/meta-policy.js +0 -190
- package/scripts/metered-billing.js +0 -16
- package/scripts/model-tier-router.js +0 -310
- package/scripts/money-watcher.js +0 -218
- package/scripts/multi-hop-recall.js +0 -240
- package/scripts/per-step-scoring.js +0 -163
- package/scripts/perplexity-command-center.js +0 -644
- package/scripts/perplexity-marketing.js +0 -454
- package/scripts/pii-scanner.js +0 -153
- package/scripts/plan-gate.js +0 -154
- package/scripts/post-everywhere.js +0 -341
- package/scripts/post-to-x-retry.sh +0 -22
- package/scripts/post-to-x.js +0 -369
- package/scripts/pr-manager.js +0 -421
- package/scripts/principle-extractor.js +0 -162
- package/scripts/pro-features.js +0 -41
- package/scripts/prompt-dlp.js +0 -222
- package/scripts/prove-adapters.js +0 -860
- package/scripts/prove-attribution.js +0 -361
- package/scripts/prove-automation.js +0 -651
- package/scripts/prove-autoresearch.js +0 -304
- package/scripts/prove-claim-verification.js +0 -277
- package/scripts/prove-cloudflare-sandbox.js +0 -161
- package/scripts/prove-data-pipeline.js +0 -408
- package/scripts/prove-data-quality.js +0 -227
- package/scripts/prove-evolution.js +0 -352
- package/scripts/prove-harnesses.js +0 -287
- package/scripts/prove-intelligence.js +0 -257
- package/scripts/prove-lancedb.js +0 -425
- package/scripts/prove-local-intelligence.js +0 -340
- package/scripts/prove-loop-closure.js +0 -263
- package/scripts/prove-packaged-runtime.js +0 -327
- package/scripts/prove-predictive-insights.js +0 -355
- package/scripts/prove-runtime.js +0 -363
- package/scripts/prove-seo-gsd.js +0 -234
- package/scripts/prove-settings.js +0 -279
- package/scripts/prove-subway-upgrades.js +0 -277
- package/scripts/prove-tessl.js +0 -229
- package/scripts/prove-training-export.js +0 -325
- package/scripts/prove-workflow-contract.js +0 -112
- package/scripts/prove-xmemory.js +0 -332
- package/scripts/publish-decision.js +0 -159
- package/scripts/ralph-loop.js +0 -376
- package/scripts/ralph-mode-ci.js +0 -434
- package/scripts/reddit-dm-outreach.js +0 -192
- package/scripts/reddit-monitor-cron.sh +0 -26
- package/scripts/reminder-engine.js +0 -132
- package/scripts/revenue-status.js +0 -472
- package/scripts/rotate-stripe-webhook-secret.js +0 -314
- package/scripts/schedule-manager.js +0 -249
- package/scripts/self-healing-check.js +0 -193
- package/scripts/session-analyzer.js +0 -533
- package/scripts/shieldcortex-memory-firewall-runner.mjs +0 -53
- package/scripts/skill-exporter.js +0 -260
- package/scripts/skill-materializer.js +0 -134
- package/scripts/skill-packs.js +0 -136
- package/scripts/skill-proposer.js +0 -99
- package/scripts/skill-quality-tracker.js +0 -282
- package/scripts/slow-loop.js +0 -72
- package/scripts/social-analytics/db/marketing-db.js +0 -179
- package/scripts/social-analytics/db/schema.sql +0 -55
- package/scripts/social-analytics/digest.js +0 -256
- package/scripts/social-analytics/engagement-audit.js +0 -185
- package/scripts/social-analytics/generate-instagram-card.js +0 -123
- package/scripts/social-analytics/generate-slides.js +0 -268
- package/scripts/social-analytics/instagram-thumbgate-post.js +0 -111
- package/scripts/social-analytics/install-growth-automation.js +0 -114
- package/scripts/social-analytics/load-env.js +0 -77
- package/scripts/social-analytics/mcp-server.js +0 -289
- package/scripts/social-analytics/normalizer.js +0 -580
- package/scripts/social-analytics/notify.js +0 -162
- package/scripts/social-analytics/poll-all.js +0 -107
- package/scripts/social-analytics/pollers/github.js +0 -195
- package/scripts/social-analytics/pollers/instagram.js +0 -253
- package/scripts/social-analytics/pollers/linkedin.js +0 -340
- package/scripts/social-analytics/pollers/plausible.js +0 -245
- package/scripts/social-analytics/pollers/reddit.js +0 -306
- package/scripts/social-analytics/pollers/threads.js +0 -233
- package/scripts/social-analytics/pollers/tiktok.js +0 -203
- package/scripts/social-analytics/pollers/x.js +0 -227
- package/scripts/social-analytics/pollers/youtube.js +0 -304
- package/scripts/social-analytics/pollers/zernio.js +0 -183
- package/scripts/social-analytics/post-video.js +0 -316
- package/scripts/social-analytics/publish-instagram-thumbgate.js +0 -104
- package/scripts/social-analytics/publish-thumbgate-launch.js +0 -322
- package/scripts/social-analytics/publishers/devto.js +0 -122
- package/scripts/social-analytics/publishers/instagram.js +0 -317
- package/scripts/social-analytics/publishers/linkedin.js +0 -294
- package/scripts/social-analytics/publishers/reddit.js +0 -385
- package/scripts/social-analytics/publishers/threads.js +0 -275
- package/scripts/social-analytics/publishers/tiktok.js +0 -217
- package/scripts/social-analytics/publishers/x.js +0 -259
- package/scripts/social-analytics/publishers/youtube.js +0 -223
- package/scripts/social-analytics/publishers/zernio.js +0 -568
- package/scripts/social-analytics/reconcile-thumbgate-campaign.js +0 -165
- package/scripts/social-analytics/run-digest.js +0 -34
- package/scripts/social-analytics/schedule-thumbgate-campaign.js +0 -275
- package/scripts/social-analytics/store.js +0 -455
- package/scripts/social-analytics/sync-launch-assets.js +0 -185
- package/scripts/social-analytics/utm.js +0 -143
- package/scripts/social-pipeline.js +0 -2626
- package/scripts/social-post-hourly.js +0 -228
- package/scripts/social-quality-gate.js +0 -134
- package/scripts/social-reply-monitor.js +0 -592
- package/scripts/status-dashboard.js +0 -155
- package/scripts/stripe-live-status.js +0 -115
- package/scripts/subagent-profiles.js +0 -79
- package/scripts/sync-branch-protection.js +0 -340
- package/scripts/sync-gh-secrets-from-env.sh +0 -70
- package/scripts/sync-github-about.js +0 -55
- package/scripts/sync-version.js +0 -479
- package/scripts/synthetic-dpo.js +0 -234
- package/scripts/tessl-export.js +0 -369
- package/scripts/test-coverage.js +0 -128
- package/scripts/thumbgate-bench.js +0 -494
- package/scripts/thumbgate_session_start.sh +0 -32
- package/scripts/train_from_feedback.py +0 -929
- package/scripts/validate-feedback.js +0 -581
- package/scripts/verify-obsidian-setup.sh +0 -269
- package/scripts/verify-run.js +0 -269
- package/scripts/weekly-auto-post.js +0 -124
- package/scripts/x-autonomous-marketing.js +0 -139
|
@@ -1,454 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Perplexity Max Marketing Engine
|
|
5
|
-
*
|
|
6
|
-
* Uses Perplexity Sonar APIs to:
|
|
7
|
-
* 1. Deep Research — find buyers, competitors, distribution channels
|
|
8
|
-
* 2. Search API — find live discussions where ThumbGate is relevant
|
|
9
|
-
* 3. Sonar Pro — generate SEO-optimized launch posts for HN, Reddit, dev.to, Twitter
|
|
10
|
-
* 4. Generate ready-to-post content with links to purchase channels
|
|
11
|
-
*
|
|
12
|
-
* Usage:
|
|
13
|
-
* PERPLEXITY_API_KEY=pplx-... node scripts/perplexity-marketing.js [command]
|
|
14
|
-
*
|
|
15
|
-
* Commands:
|
|
16
|
-
* research — Deep research on target market and competitors
|
|
17
|
-
* find-threads — Find live discussions to engage with
|
|
18
|
-
* generate — Generate launch posts for all platforms
|
|
19
|
-
* full — Run all three steps (default)
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const fs = require('fs');
|
|
23
|
-
const path = require('path');
|
|
24
|
-
const {
|
|
25
|
-
PerplexityClient,
|
|
26
|
-
extractChatText,
|
|
27
|
-
extractCitations,
|
|
28
|
-
} = require('./perplexity-client');
|
|
29
|
-
|
|
30
|
-
const OUTPUT_DIR = path.join(__dirname, '..', '.amp', 'in', 'artifacts', 'marketing');
|
|
31
|
-
const perplexity = new PerplexityClient();
|
|
32
|
-
|
|
33
|
-
const PRODUCT = {
|
|
34
|
-
name: 'ThumbGate',
|
|
35
|
-
npm: 'thumbgate',
|
|
36
|
-
repo: 'https://github.com/IgorGanapolsky/ThumbGate',
|
|
37
|
-
checkout: 'https://thumbgate-production.up.railway.app/checkout/pro',
|
|
38
|
-
sponsor: 'https://github.com/sponsors/IgorGanapolsky',
|
|
39
|
-
coffee: 'https://buymeacoffee.com/igorganapolsky',
|
|
40
|
-
tagline: 'Local-first memory and feedback pipeline for AI agents. Captures thumbs-up/down signals, promotes reusable memories, generates prevention rules from repeated failures, and exports KTO/DPO pairs for fine-tuning.',
|
|
41
|
-
keywords: ['MCP', 'ThumbGate', 'DPO', 'KTO', 'Thompson Sampling', 'AI agent memory', 'Claude Code', 'Amp', 'Gemini CLI', 'context engineering', 'prevention rules', 'Pre-Action Gates'],
|
|
42
|
-
proPrice: '$19/mo or $149/yr',
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
async function sonarRequest(model, messages, options = {}) {
|
|
46
|
-
if (!perplexity.hasApiKey()) {
|
|
47
|
-
throw new Error('PERPLEXITY_API_KEY not set. Get yours at https://www.perplexity.ai/settings/api');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return perplexity.chatCompletion({
|
|
51
|
-
model,
|
|
52
|
-
messages,
|
|
53
|
-
options,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function ensureOutputDir() {
|
|
58
|
-
fs.mkdirSync(OUTPUT_DIR, { recursive: true });
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function saveOutput(filename, content) {
|
|
62
|
-
ensureOutputDir();
|
|
63
|
-
const p = path.join(OUTPUT_DIR, filename);
|
|
64
|
-
fs.writeFileSync(p, content, 'utf-8');
|
|
65
|
-
console.log(` ✓ Saved: ${p}`);
|
|
66
|
-
return p;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// ─── STEP 1: Deep Research ────────────────────────────────────────────────────
|
|
70
|
-
|
|
71
|
-
async function deepResearch() {
|
|
72
|
-
console.log('\n🔬 STEP 1: Deep Research — Market Analysis');
|
|
73
|
-
console.log(' Using sonar-deep-research for exhaustive analysis...\n');
|
|
74
|
-
|
|
75
|
-
const result = await sonarRequest('sonar-deep-research', [
|
|
76
|
-
{
|
|
77
|
-
role: 'system',
|
|
78
|
-
content: 'You are a market research analyst specializing in developer tools and AI infrastructure. Provide actionable intelligence with specific URLs, communities, and buyer personas.',
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
role: 'user',
|
|
82
|
-
content: `Research the market for MCP (Model Context Protocol) memory and feedback tools for AI coding agents.
|
|
83
|
-
|
|
84
|
-
I built "${PRODUCT.name}" — ${PRODUCT.tagline}
|
|
85
|
-
|
|
86
|
-
Research and provide:
|
|
87
|
-
1. **Competitor Analysis**: What similar tools exist? (LangSmith, Weights & Biases, custom ThumbGate pipelines, etc.) What do they charge? What gaps does my tool fill?
|
|
88
|
-
2. **Target Buyer Personas**: Who would pay $19/mo or $149/yr for a Pro plan with curated ThumbGate configs? (AI engineers, dev tool builders, agent framework users)
|
|
89
|
-
3. **Distribution Channels**: Specific subreddits, Discord servers, Slack communities, newsletters, and forums where MCP and AI agent reliability tool buyers hang out. Include URLs.
|
|
90
|
-
4. **SEO/GEO Keywords**: High-intent search terms people use when looking for this type of tool
|
|
91
|
-
5. **Launch Strategy**: Specific steps to get first 10 paying customers this week
|
|
92
|
-
6. **Pricing Validation**: Is $19/mo or $149/yr right for a Pro plan? What would similar tools charge?
|
|
93
|
-
|
|
94
|
-
Be specific with URLs, community names, and actionable steps.`,
|
|
95
|
-
},
|
|
96
|
-
]);
|
|
97
|
-
|
|
98
|
-
const content = extractChatText(result);
|
|
99
|
-
const citations = extractCitations(result);
|
|
100
|
-
|
|
101
|
-
let output = `# Market Research Report — ThumbGate\n\nGenerated: ${new Date().toISOString()}\n\n`;
|
|
102
|
-
output += content;
|
|
103
|
-
if (citations.length) {
|
|
104
|
-
output += '\n\n## Sources\n\n';
|
|
105
|
-
citations.forEach((c, i) => { output += `${i + 1}. ${c}\n`; });
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
saveOutput('01-deep-research.md', output);
|
|
109
|
-
console.log(' ✓ Deep research complete\n');
|
|
110
|
-
return content;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// ─── STEP 2: Find Live Discussions ───────────────────────────────────────────
|
|
114
|
-
|
|
115
|
-
async function findThreads() {
|
|
116
|
-
console.log('\n🔍 STEP 2: Find Live Discussions to Engage');
|
|
117
|
-
console.log(' Using sonar-pro to find active conversations...\n');
|
|
118
|
-
|
|
119
|
-
const queries = [
|
|
120
|
-
'MCP Model Context Protocol memory tools discussion site:reddit.com OR site:news.ycombinator.com 2025 2026',
|
|
121
|
-
'feedback-to-enforcement pipeline AI agents local-first tools discussion',
|
|
122
|
-
'Claude Code Amp agent memory context engineering tips',
|
|
123
|
-
'AI coding agent prevention rules guardrails DPO training',
|
|
124
|
-
];
|
|
125
|
-
|
|
126
|
-
const results = [];
|
|
127
|
-
|
|
128
|
-
for (const q of queries) {
|
|
129
|
-
try {
|
|
130
|
-
const result = await sonarRequest('sonar-pro', [
|
|
131
|
-
{
|
|
132
|
-
role: 'system',
|
|
133
|
-
content: 'Find active online discussions, forum threads, and community posts. Return specific URLs where people are discussing these topics. Focus on posts from the last 30 days.',
|
|
134
|
-
},
|
|
135
|
-
{ role: 'user', content: q },
|
|
136
|
-
], {
|
|
137
|
-
web_search_options: { search_context_size: 'high' },
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
const content = extractChatText(result);
|
|
141
|
-
const citations = extractCitations(result);
|
|
142
|
-
results.push({ query: q, content, citations });
|
|
143
|
-
} catch (err) {
|
|
144
|
-
console.log(` ⚠ Query failed: ${q} — ${err.message}`);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
let output = `# Live Discussion Threads — Engagement Opportunities\n\nGenerated: ${new Date().toISOString()}\n\n`;
|
|
149
|
-
for (const r of results) {
|
|
150
|
-
output += `## Query: ${r.query}\n\n${r.content}\n\n`;
|
|
151
|
-
if (r.citations.length) {
|
|
152
|
-
output += '### Sources\n';
|
|
153
|
-
r.citations.forEach((c, i) => { output += `${i + 1}. ${c}\n`; });
|
|
154
|
-
output += '\n';
|
|
155
|
-
}
|
|
156
|
-
output += '---\n\n';
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
saveOutput('02-live-threads.md', output);
|
|
160
|
-
console.log(' ✓ Found engagement opportunities\n');
|
|
161
|
-
return results;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// ─── STEP 3: Generate Launch Posts ───────────────────────────────────────────
|
|
165
|
-
|
|
166
|
-
async function generatePosts() {
|
|
167
|
-
console.log('\n✍️ STEP 3: Generate Launch Posts');
|
|
168
|
-
console.log(' Using sonar-pro to craft platform-specific content...\n');
|
|
169
|
-
|
|
170
|
-
const platforms = [
|
|
171
|
-
{
|
|
172
|
-
name: 'hackernews',
|
|
173
|
-
file: '03-hackernews-post.md',
|
|
174
|
-
prompt: `Write a Hacker News "Show HN" post for ${PRODUCT.name}.
|
|
175
|
-
|
|
176
|
-
Product: ${PRODUCT.tagline}
|
|
177
|
-
npm: npx ${PRODUCT.npm} init
|
|
178
|
-
GitHub: ${PRODUCT.repo}
|
|
179
|
-
Pro Pack: ${PRODUCT.proPrice} via hosted checkout (${PRODUCT.checkout})
|
|
180
|
-
|
|
181
|
-
Requirements:
|
|
182
|
-
- Title must start with "Show HN:"
|
|
183
|
-
- Keep the post body under 300 words
|
|
184
|
-
- Focus on the technical innovation (Thompson Sampling for feedback routing, DPO/KTO export, prevention rules from repeated failures)
|
|
185
|
-
- Mention it works with Claude, Codex, Amp, Gemini
|
|
186
|
-
- No marketing fluff — HN readers want technical substance
|
|
187
|
-
- Include the npm install command
|
|
188
|
-
- End with a link to the repo
|
|
189
|
-
|
|
190
|
-
Also generate 3 alternative titles to A/B test.`,
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
name: 'reddit',
|
|
194
|
-
file: '03-reddit-post.md',
|
|
195
|
-
prompt: `Write Reddit posts for ${PRODUCT.name} for these subreddits:
|
|
196
|
-
1. r/MachineLearning — focus on ThumbGate/DPO pipeline, academic angle
|
|
197
|
-
2. r/LocalLLaMA — focus on local-first, no cloud dependency
|
|
198
|
-
3. r/ClaudeAI — focus on Claude Code integration, MCP tools
|
|
199
|
-
4. r/programming — focus on the engineering of the feedback loop
|
|
200
|
-
|
|
201
|
-
Product: ${PRODUCT.tagline}
|
|
202
|
-
npm: npx ${PRODUCT.npm} init
|
|
203
|
-
GitHub: ${PRODUCT.repo}
|
|
204
|
-
Pro Pack: ${PRODUCT.proPrice} via hosted checkout (${PRODUCT.checkout})
|
|
205
|
-
|
|
206
|
-
For each subreddit, write:
|
|
207
|
-
- A title
|
|
208
|
-
- Post body (respect each subreddit's culture and rules)
|
|
209
|
-
- Suggested flair
|
|
210
|
-
Keep each post under 250 words. Be genuine, not salesy.`,
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
name: 'devto',
|
|
214
|
-
file: '03-devto-article.md',
|
|
215
|
-
prompt: `Write a dev.to article for ${PRODUCT.name}.
|
|
216
|
-
|
|
217
|
-
Product: ${PRODUCT.tagline}
|
|
218
|
-
npm: npx ${PRODUCT.npm} init
|
|
219
|
-
GitHub: ${PRODUCT.repo}
|
|
220
|
-
|
|
221
|
-
Write a technical tutorial titled something like "How I Built a Self-Improving AI Agent Memory System or Teaching AI Agents to Learn from Their Mistakes with ThumbGate".
|
|
222
|
-
|
|
223
|
-
Requirements:
|
|
224
|
-
- dev.to frontmatter (title, published, description, tags, cover_image)
|
|
225
|
-
- 800-1200 words
|
|
226
|
-
- Include code snippets showing the MCP tool usage
|
|
227
|
-
- Explain the 5-phase pipeline: Capture → Validate → Remember → Prevent → Export
|
|
228
|
-
- Include the learning curve dashboard output
|
|
229
|
-
- End with links to GitHub, npm, and the Pro Pack
|
|
230
|
-
- Tags: ai, machinelearning, webdev, opensource`,
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
name: 'twitter',
|
|
234
|
-
file: '03-twitter-thread.md',
|
|
235
|
-
prompt: `Write a Twitter/X thread (8-12 tweets) launching ${PRODUCT.name}.
|
|
236
|
-
|
|
237
|
-
Product: ${PRODUCT.tagline}
|
|
238
|
-
npm: npx ${PRODUCT.npm} init
|
|
239
|
-
GitHub: ${PRODUCT.repo}
|
|
240
|
-
Pro Pack: ${PRODUCT.proPrice} at ${PRODUCT.checkout}
|
|
241
|
-
|
|
242
|
-
Requirements:
|
|
243
|
-
- First tweet must hook attention (problem statement)
|
|
244
|
-
- Use emojis sparingly but effectively
|
|
245
|
-
- Include a code snippet tweet showing the CLI
|
|
246
|
-
- Include the learning curve dashboard as a tweet
|
|
247
|
-
- One tweet about the Pro Pack value prop
|
|
248
|
-
- Last tweet: CTA to star the repo + link
|
|
249
|
-
- Each tweet under 280 chars
|
|
250
|
-
- Number each tweet (1/N format)`,
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
name: 'linkedin',
|
|
254
|
-
file: '03-linkedin-post.md',
|
|
255
|
-
prompt: `Write a LinkedIn post announcing ${PRODUCT.name}.
|
|
256
|
-
|
|
257
|
-
Product: ${PRODUCT.tagline}
|
|
258
|
-
GitHub: ${PRODUCT.repo}
|
|
259
|
-
|
|
260
|
-
Requirements:
|
|
261
|
-
- Professional tone, not corporate bland
|
|
262
|
-
- Focus on the problem: AI agents repeat the same mistakes
|
|
263
|
-
- Position as an engineering innovation
|
|
264
|
-
- Mention it's open source (MIT)
|
|
265
|
-
- 150-250 words
|
|
266
|
-
- Include relevant hashtags
|
|
267
|
-
- End with a soft CTA`,
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
name: 'producthunt',
|
|
271
|
-
file: '03-producthunt-listing.md',
|
|
272
|
-
prompt: `Write a Product Hunt listing for ${PRODUCT.name}.
|
|
273
|
-
|
|
274
|
-
Product: ${PRODUCT.tagline}
|
|
275
|
-
npm: npx ${PRODUCT.npm} init
|
|
276
|
-
GitHub: ${PRODUCT.repo}
|
|
277
|
-
Pro Pack: ${PRODUCT.proPrice} at ${PRODUCT.checkout}
|
|
278
|
-
|
|
279
|
-
Requirements:
|
|
280
|
-
- Tagline (under 60 chars)
|
|
281
|
-
- Description (under 260 chars)
|
|
282
|
-
- Detailed description (300-500 words)
|
|
283
|
-
- 5 key features as bullet points
|
|
284
|
-
- "First comment" from the maker (personal story, why you built it)
|
|
285
|
-
- Suggested categories: Developer Tools, AI, Productivity
|
|
286
|
-
- Pricing: Free (open source) + Pro ($19/mo or $149/yr)`,
|
|
287
|
-
},
|
|
288
|
-
];
|
|
289
|
-
|
|
290
|
-
const posts = [];
|
|
291
|
-
|
|
292
|
-
for (const platform of platforms) {
|
|
293
|
-
console.log(` Generating ${platform.name} post...`);
|
|
294
|
-
try {
|
|
295
|
-
const result = await sonarRequest('sonar-pro', [
|
|
296
|
-
{
|
|
297
|
-
role: 'system',
|
|
298
|
-
content: `You are an expert developer advocate and technical content creator. Write authentic, technically accurate content that resonates with developers. Never use generic marketing phrases. Be specific and genuine.`,
|
|
299
|
-
},
|
|
300
|
-
{ role: 'user', content: platform.prompt },
|
|
301
|
-
], {
|
|
302
|
-
web_search_options: { search_context_size: 'low' },
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
const content = extractChatText(result);
|
|
306
|
-
saveOutput(platform.file, `# ${platform.name.toUpperCase()} — Launch Post\n\nGenerated: ${new Date().toISOString()}\n\n${content}`);
|
|
307
|
-
posts.push({ platform: platform.name, content });
|
|
308
|
-
} catch (err) {
|
|
309
|
-
console.log(` ⚠ Failed: ${platform.name} — ${err.message}`);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
console.log(' ✓ All posts generated\n');
|
|
314
|
-
return posts;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// ─── STEP 4: Generate SEO Content ────────────────────────────────────────────
|
|
318
|
-
|
|
319
|
-
async function generateSEO() {
|
|
320
|
-
console.log('\n📈 STEP 4: SEO/GEO Optimization Content');
|
|
321
|
-
console.log(' Generating content for AI search visibility...\n');
|
|
322
|
-
|
|
323
|
-
const result = await sonarRequest('sonar-pro', [
|
|
324
|
-
{
|
|
325
|
-
role: 'system',
|
|
326
|
-
content: 'You are an SEO expert specializing in developer tools and AI products. Focus on GEO (Generative Engine Optimization) — making content that AI search engines (Perplexity, Claude, ChatGPT) will cite.',
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
role: 'user',
|
|
330
|
-
content: `Generate SEO/GEO optimization content for ${PRODUCT.name}:
|
|
331
|
-
|
|
332
|
-
Product: ${PRODUCT.tagline}
|
|
333
|
-
URL: ${PRODUCT.repo}
|
|
334
|
-
npm: ${PRODUCT.npm}
|
|
335
|
-
|
|
336
|
-
Generate:
|
|
337
|
-
1. **FAQ Page Content** — 10 Q&As that match high-intent developer searches (format as JSON-LD FAQPage schema)
|
|
338
|
-
2. **Meta Descriptions** — for GitHub README, npm page, landing page
|
|
339
|
-
3. **Long-tail Keyword Targets** — 20 specific phrases developers search for
|
|
340
|
-
4. **Comparison Content** — "ThumbGate vs LangSmith", "ThumbGate vs custom ThumbGate setup", "ThumbGate vs Weights & Biases"
|
|
341
|
-
5. **Structured Data** — JSON-LD SoftwareApplication schema for the product
|
|
342
|
-
|
|
343
|
-
Make all content factually accurate and technically specific.`,
|
|
344
|
-
},
|
|
345
|
-
], {
|
|
346
|
-
web_search_options: { search_context_size: 'medium' },
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
const content = extractChatText(result);
|
|
350
|
-
saveOutput('04-seo-geo-content.md', `# SEO/GEO Optimization Content\n\nGenerated: ${new Date().toISOString()}\n\n${content}`);
|
|
351
|
-
console.log(' ✓ SEO content generated\n');
|
|
352
|
-
return content;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// ─── STEP 5: Generate Outreach Messages ──────────────────────────────────────
|
|
356
|
-
|
|
357
|
-
async function generateOutreach() {
|
|
358
|
-
console.log('\n📧 STEP 5: Direct Outreach Templates');
|
|
359
|
-
|
|
360
|
-
const result = await sonarRequest('sonar', [
|
|
361
|
-
{
|
|
362
|
-
role: 'system',
|
|
363
|
-
content: 'You are a developer relations expert. Write concise, personalized outreach templates.',
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
role: 'user',
|
|
367
|
-
content: `Write outreach message templates for ${PRODUCT.name} (${PRODUCT.tagline}):
|
|
368
|
-
|
|
369
|
-
1. **Newsletter pitch** — for AI/ML newsletters (The Batch, TLDR AI, etc.)
|
|
370
|
-
2. **Podcast pitch** — for AI dev podcasts
|
|
371
|
-
3. **Influencer DM** — for AI Twitter/YouTube personalities
|
|
372
|
-
4. **Discord/Slack message** — for MCP/AI agent community channels
|
|
373
|
-
5. **Email to AI tool aggregator sites** — to get listed
|
|
374
|
-
|
|
375
|
-
Each should be under 150 words, personalized, and include ${PRODUCT.repo}
|
|
376
|
-
Include [PERSONALIZATION] placeholders.`,
|
|
377
|
-
},
|
|
378
|
-
]);
|
|
379
|
-
|
|
380
|
-
const content = extractChatText(result);
|
|
381
|
-
saveOutput('05-outreach-templates.md', `# Outreach Templates\n\nGenerated: ${new Date().toISOString()}\n\n${content}`);
|
|
382
|
-
console.log(' ✓ Outreach templates generated\n');
|
|
383
|
-
return content;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
// ─── Main ─────────────────────────────────────────────────────────────────────
|
|
387
|
-
|
|
388
|
-
async function main() {
|
|
389
|
-
const cmd = process.argv[2] || 'full';
|
|
390
|
-
|
|
391
|
-
console.log('╔══════════════════════════════════════════════════════╗');
|
|
392
|
-
console.log('║ Perplexity Max Marketing Engine ║');
|
|
393
|
-
console.log('║ ThumbGate — First Dollar Campaign ║');
|
|
394
|
-
console.log('╚══════════════════════════════════════════════════════╝');
|
|
395
|
-
|
|
396
|
-
if (!perplexity.hasApiKey()) {
|
|
397
|
-
console.error('\n❌ PERPLEXITY_API_KEY not set.');
|
|
398
|
-
console.error(' Add it to .env: PERPLEXITY_API_KEY=pplx-...');
|
|
399
|
-
console.error(' Get your key: https://www.perplexity.ai/settings/api\n');
|
|
400
|
-
process.exit(1);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
console.log('\nAPI key configured.');
|
|
404
|
-
console.log(`Command: ${cmd}\n`);
|
|
405
|
-
|
|
406
|
-
try {
|
|
407
|
-
switch (cmd) {
|
|
408
|
-
case 'research':
|
|
409
|
-
await deepResearch();
|
|
410
|
-
break;
|
|
411
|
-
case 'find-threads':
|
|
412
|
-
await findThreads();
|
|
413
|
-
break;
|
|
414
|
-
case 'generate':
|
|
415
|
-
await generatePosts();
|
|
416
|
-
break;
|
|
417
|
-
case 'seo':
|
|
418
|
-
await generateSEO();
|
|
419
|
-
break;
|
|
420
|
-
case 'outreach':
|
|
421
|
-
await generateOutreach();
|
|
422
|
-
break;
|
|
423
|
-
case 'full':
|
|
424
|
-
await deepResearch();
|
|
425
|
-
await findThreads();
|
|
426
|
-
await generatePosts();
|
|
427
|
-
await generateSEO();
|
|
428
|
-
await generateOutreach();
|
|
429
|
-
break;
|
|
430
|
-
default:
|
|
431
|
-
console.error(`Unknown command: ${cmd}`);
|
|
432
|
-
console.error('Commands: research, find-threads, generate, seo, outreach, full');
|
|
433
|
-
process.exit(1);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
console.log('╔══════════════════════════════════════════════════════╗');
|
|
437
|
-
console.log('║ ✅ Marketing content generated! ║');
|
|
438
|
-
console.log('╠══════════════════════════════════════════════════════╣');
|
|
439
|
-
console.log(`║ Output: ${OUTPUT_DIR}`);
|
|
440
|
-
console.log('║ ║');
|
|
441
|
-
console.log('║ Next steps: ║');
|
|
442
|
-
console.log('║ 1. Review generated content in artifacts/marketing ║');
|
|
443
|
-
console.log('║ 2. Post to platforms (HN, Reddit, dev.to, Twitter) ║');
|
|
444
|
-
console.log('║ 3. Send outreach messages ║');
|
|
445
|
-
console.log('║ 4. Update landing page with SEO content ║');
|
|
446
|
-
console.log('╚══════════════════════════════════════════════════════╝');
|
|
447
|
-
|
|
448
|
-
} catch (err) {
|
|
449
|
-
console.error(`\n❌ Error: ${err.message}`);
|
|
450
|
-
process.exit(1);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
main();
|
package/scripts/pii-scanner.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* PII Scanner — LogSentinel-inspired PII detection for ThumbGate.
|
|
6
|
-
*
|
|
7
|
-
* Scans feedback content, context packs, and DPO exports for PII patterns.
|
|
8
|
-
* Applies hierarchical sensitivity labels. Redacts or rejects as configured.
|
|
9
|
-
* Builds on secret-scanner.js patterns + adds PII-specific detectors.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const { SECRET_PATTERNS, redactText: redactSecrets } = require('./secret-scanner');
|
|
13
|
-
|
|
14
|
-
// PII patterns beyond secrets — emails, phone numbers, SSNs, card numbers, IP addresses
|
|
15
|
-
const PII_PATTERNS = [
|
|
16
|
-
{ id: 'email', label: 'Email address', regex: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g, sensitivity: 'sensitive' },
|
|
17
|
-
{ id: 'phone_us', label: 'US phone number', regex: /\b(?:\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\b/g, sensitivity: 'sensitive' },
|
|
18
|
-
{ id: 'ssn', label: 'Social Security Number', regex: /\b\d{3}[-.\s]?\d{2}[-.\s]?\d{4}\b/g, sensitivity: 'restricted' },
|
|
19
|
-
{ id: 'credit_card', label: 'Credit card number', regex: /\b(?:4\d{3}|5[1-5]\d{2}|3[47]\d{2}|6(?:011|5\d{2}))[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}\b/g, sensitivity: 'restricted' },
|
|
20
|
-
{ id: 'ip_address', label: 'IP address', regex: /\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b/g, sensitivity: 'internal' },
|
|
21
|
-
{ id: 'aws_account', label: 'AWS account ID', regex: /\b\d{12}\b/g, sensitivity: 'internal' },
|
|
22
|
-
];
|
|
23
|
-
|
|
24
|
-
const SENSITIVITY_LEVELS = ['public', 'internal', 'sensitive', 'restricted'];
|
|
25
|
-
|
|
26
|
-
function sensitivityRank(level) {
|
|
27
|
-
const idx = SENSITIVITY_LEVELS.indexOf(level);
|
|
28
|
-
return idx >= 0 ? idx : 0;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Scan text for PII and return findings with sensitivity labels.
|
|
33
|
-
*/
|
|
34
|
-
function scanForPii(text) {
|
|
35
|
-
if (!text) return { findings: [], highestSensitivity: 'public', hasPii: false };
|
|
36
|
-
const str = String(text);
|
|
37
|
-
const findings = [];
|
|
38
|
-
let highest = 'public';
|
|
39
|
-
|
|
40
|
-
for (const pattern of PII_PATTERNS) {
|
|
41
|
-
// Reset regex lastIndex for global patterns
|
|
42
|
-
pattern.regex.lastIndex = 0;
|
|
43
|
-
const matches = str.match(pattern.regex);
|
|
44
|
-
if (matches && matches.length > 0) {
|
|
45
|
-
findings.push({
|
|
46
|
-
id: pattern.id,
|
|
47
|
-
label: pattern.label,
|
|
48
|
-
sensitivity: pattern.sensitivity,
|
|
49
|
-
matchCount: matches.length,
|
|
50
|
-
sample: matches[0].slice(0, 4) + '***',
|
|
51
|
-
});
|
|
52
|
-
if (sensitivityRank(pattern.sensitivity) > sensitivityRank(highest)) {
|
|
53
|
-
highest = pattern.sensitivity;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return { findings, highestSensitivity: highest, hasPii: findings.length > 0 };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Redact PII from text. Returns redacted string.
|
|
63
|
-
*/
|
|
64
|
-
function redactPii(text) {
|
|
65
|
-
if (!text) return '';
|
|
66
|
-
let redacted = String(text);
|
|
67
|
-
// First redact secrets (API keys, tokens)
|
|
68
|
-
redacted = redactSecrets(redacted);
|
|
69
|
-
// Then redact PII
|
|
70
|
-
for (const pattern of PII_PATTERNS) {
|
|
71
|
-
pattern.regex.lastIndex = 0;
|
|
72
|
-
redacted = redacted.replace(pattern.regex, `[REDACTED:${pattern.id}]`);
|
|
73
|
-
}
|
|
74
|
-
return redacted;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Assign a sensitivity label to a feedback entry based on content scan.
|
|
79
|
-
* Returns: { sensitivity, findings, redactedContent }
|
|
80
|
-
*/
|
|
81
|
-
function classifyFeedback(feedbackEntry) {
|
|
82
|
-
const content = [
|
|
83
|
-
feedbackEntry.context || '',
|
|
84
|
-
feedbackEntry.whatWentWrong || '',
|
|
85
|
-
feedbackEntry.whatToChange || '',
|
|
86
|
-
feedbackEntry.whatWorked || '',
|
|
87
|
-
].join('\n');
|
|
88
|
-
|
|
89
|
-
const scan = scanForPii(content);
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
sensitivity: scan.highestSensitivity,
|
|
93
|
-
findings: scan.findings,
|
|
94
|
-
hasPii: scan.hasPii,
|
|
95
|
-
redactedContent: scan.hasPii ? redactPii(content) : content,
|
|
96
|
-
originalContentHash: require('crypto').createHash('sha256').update(content).digest('hex').slice(0, 16),
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Scan a DPO pair for PII. Returns scan result with pass/fail.
|
|
102
|
-
*/
|
|
103
|
-
function scanDpoPair(pair) {
|
|
104
|
-
const chosen = scanForPii(pair.chosen || '');
|
|
105
|
-
const rejected = scanForPii(pair.rejected || '');
|
|
106
|
-
const prompt = scanForPii(pair.prompt || '');
|
|
107
|
-
const allFindings = [...prompt.findings, ...chosen.findings, ...rejected.findings];
|
|
108
|
-
const highest = SENSITIVITY_LEVELS[Math.max(
|
|
109
|
-
sensitivityRank(prompt.highestSensitivity),
|
|
110
|
-
sensitivityRank(chosen.highestSensitivity),
|
|
111
|
-
sensitivityRank(rejected.highestSensitivity),
|
|
112
|
-
)];
|
|
113
|
-
|
|
114
|
-
return {
|
|
115
|
-
hasPii: allFindings.length > 0,
|
|
116
|
-
highestSensitivity: highest,
|
|
117
|
-
findings: allFindings,
|
|
118
|
-
safe: sensitivityRank(highest) < sensitivityRank('sensitive'),
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Gate a DPO export: filter out pairs containing PII above threshold.
|
|
124
|
-
* Returns { safePairs, blockedPairs, blockedCount, totalScanned }.
|
|
125
|
-
*/
|
|
126
|
-
function gateDpoExport(pairs, { maxSensitivity = 'internal' } = {}) {
|
|
127
|
-
const maxRank = sensitivityRank(maxSensitivity);
|
|
128
|
-
const safePairs = [];
|
|
129
|
-
const blockedPairs = [];
|
|
130
|
-
|
|
131
|
-
for (const pair of pairs) {
|
|
132
|
-
const scan = scanDpoPair(pair);
|
|
133
|
-
if (sensitivityRank(scan.highestSensitivity) <= maxRank) {
|
|
134
|
-
safePairs.push(pair);
|
|
135
|
-
} else {
|
|
136
|
-
blockedPairs.push({ pair, scan });
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return {
|
|
141
|
-
safePairs,
|
|
142
|
-
blockedPairs,
|
|
143
|
-
blockedCount: blockedPairs.length,
|
|
144
|
-
totalScanned: pairs.length,
|
|
145
|
-
passRate: pairs.length > 0 ? Math.round((safePairs.length / pairs.length) * 1000) / 10 : 100,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
module.exports = {
|
|
150
|
-
PII_PATTERNS, SENSITIVITY_LEVELS,
|
|
151
|
-
scanForPii, redactPii, classifyFeedback,
|
|
152
|
-
scanDpoPair, gateDpoExport, sensitivityRank,
|
|
153
|
-
};
|