thumbgate 1.40.1 → 1.40.3
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/plugin.json +1 -1
- package/.well-known/mcp/server-card.json +1 -1
- package/adapters/claude/.mcp.json +3 -3
- package/adapters/forge/forge.yaml +3 -3
- package/adapters/future-agi/.mcp.json +1 -1
- package/adapters/future-agi/config.toml +1 -1
- package/adapters/future-agi/opencode.json +1 -1
- package/adapters/herdr/herdr-plugin.toml +2 -2
- package/adapters/mcp/server-stdio.js +4 -2
- package/adapters/opencode/opencode.json +1 -1
- package/config/github-about.json +1 -1
- package/package.json +41 -6
- package/public/index.html +38 -152
- package/public/install.html +8 -8
- package/public/numbers.html +2 -2
- package/public/pricing.html +54 -335
- package/scripts/analytics-report.js +363 -0
- package/scripts/auto-context-packs.js +249 -0
- package/scripts/billing-setup.js +137 -0
- package/scripts/check-update.js +236 -0
- package/scripts/conversion-rate-stats.js +442 -0
- package/scripts/cost-cli.js +147 -0
- package/scripts/creator-campaigns.js +239 -0
- package/scripts/cuda-gate-batch.js +560 -0
- package/scripts/daemon-manager.js +108 -0
- package/scripts/dashboard.js +2 -2
- package/scripts/delegation-runtime.js +1036 -0
- package/scripts/dispatch-brief.js +159 -0
- package/scripts/distribution-surfaces.js +110 -0
- package/scripts/egm-goldfish-packet.js +95 -0
- package/scripts/embeddinggemma-adapter.js +407 -0
- package/scripts/feedback-loop.js +4 -1
- package/scripts/funnel-analytics.js +35 -0
- package/scripts/gate-semantic-layer.js +292 -0
- package/scripts/human-feedback.js +23 -0
- package/scripts/implementation-notes.js +241 -0
- package/scripts/intent-router.js +518 -0
- package/scripts/latency-budget.js +164 -0
- package/scripts/mcp-writeguard.js +158 -0
- package/scripts/model-candidates.js +414 -0
- package/scripts/openrouter-armor-partnership-diode.js +2419 -0
- package/scripts/operational-dashboard.js +172 -0
- package/scripts/operational-summary.js +190 -0
- package/scripts/operator-artifacts.js +622 -0
- package/scripts/optimize-context.js +17 -0
- package/scripts/predictive-insights.js +449 -0
- package/scripts/profound-aeo-citation-engine.js +583 -0
- package/scripts/pulse.js +80 -0
- package/scripts/rrsi-doctor.js +2698 -0
- package/scripts/session-report.js +120 -0
- package/scripts/statusline-human-counts.js +69 -0
- package/scripts/statusline-links.js +13 -3
- package/scripts/statusline-local-stats.js +5 -3
- package/scripts/statusline.sh +17 -2
- package/scripts/subagent-profiles.js +79 -0
- package/scripts/third-author-cli.js +118 -0
- package/scripts/third-author-governance.js +437 -0
- package/scripts/thumbgate-dream.js +878 -0
- package/server.json +2 -2
- package/skills/thumbgate-daily-discoveries/SKILL.md +25 -41
- package/src/api/server.js +6 -0
- package/scripts/install-thumbgate-daily-publish-launchd.sh +0 -83
- package/scripts/thumbgate-daily-discoveries-publish.js +0 -461
- package/scripts/thumbgate-daily-discoveries-publish.sh +0 -18
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { summarizePermissionTier } = require('./agent-readiness');
|
|
5
|
+
const { getOperationalDashboard } = require('./operational-dashboard');
|
|
6
|
+
|
|
7
|
+
const DISPATCH_TASK_DESCRIPTIONS = {
|
|
8
|
+
recall: 'Recall prior mistakes and prevention rules before planning.',
|
|
9
|
+
feedback_summary: 'Summarize recent wins, failures, and operator notes.',
|
|
10
|
+
search_lessons: 'Search promoted lessons and inspect what corrective action the system linked to each one.',
|
|
11
|
+
retrieve_lessons: 'Retrieve top-K relevant lessons for a given tool/action context (per-action guidance).',
|
|
12
|
+
search_thumbgate: 'Search raw ThumbGate feedback, ContextFS memory, and prevention rules.',
|
|
13
|
+
feedback_stats: 'Inspect approval trends and failure domains.',
|
|
14
|
+
diagnose_failure: 'Explain why a run failed or was blocked.',
|
|
15
|
+
list_intents: 'List available workflow plans without executing them.',
|
|
16
|
+
plan_intent: 'Plan a workflow with checkpoints and no execution.',
|
|
17
|
+
context_provenance: 'Audit recent context and evidence decisions.',
|
|
18
|
+
gate_stats: 'Review blocked and warned gate trends.',
|
|
19
|
+
dashboard: 'Summarize health, proof, gates, and pipeline metrics.',
|
|
20
|
+
get_business_metrics: 'Read revenue, conversion, and customer metrics.',
|
|
21
|
+
describe_semantic_entity: 'Explain Customer, Revenue, or Funnel state.',
|
|
22
|
+
enforcement_matrix: 'Full pipeline state: feedback counts, promotion rate, active checks, rejection ledger.',
|
|
23
|
+
get_reliability_rules: 'Review active prevention rules and success patterns.',
|
|
24
|
+
describe_reliability_entity: 'Alias for semantic entity definitions.',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const DISPATCH_BLOCKED_TASKS = [
|
|
28
|
+
'Direct code edits or git writes from the primary checkout.',
|
|
29
|
+
'Starting or completing handoffs from the remote session.',
|
|
30
|
+
'Memory writes, context-pack writes, or gate satisfaction mutations.',
|
|
31
|
+
'Admin-only billing or workflow mutation endpoints.',
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const DISPATCH_PROMPTS = [
|
|
35
|
+
'Summarize revenue, funnel, gates, and proof-backed workflow health for the last 7d.',
|
|
36
|
+
'Explain the top blocked gate and the repeated mistake it is preventing.',
|
|
37
|
+
'Plan the next workflow-hardening sprint for this repo without executing any changes.',
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
function buildDispatchBrief(data, options = {}) {
|
|
41
|
+
const profileName = String(options.profile || 'dispatch').trim() || 'dispatch';
|
|
42
|
+
const permissions = summarizePermissionTier(profileName);
|
|
43
|
+
const analytics = data.analytics || {};
|
|
44
|
+
const revenue = analytics.revenue || {};
|
|
45
|
+
const funnel = analytics.funnel || {};
|
|
46
|
+
const northStar = analytics.northStar || {};
|
|
47
|
+
const gateStats = data.gateStats || {};
|
|
48
|
+
const readiness = data.readiness || {};
|
|
49
|
+
const operational = data.operational || {};
|
|
50
|
+
|
|
51
|
+
const allowedTasks = permissions.allowedTools
|
|
52
|
+
.map((toolName) => ({
|
|
53
|
+
tool: toolName,
|
|
54
|
+
description: DISPATCH_TASK_DESCRIPTIONS[toolName],
|
|
55
|
+
}))
|
|
56
|
+
.filter((entry) => entry.description);
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
generatedAt: new Date().toISOString(),
|
|
60
|
+
source: options.source || operational.source || 'local',
|
|
61
|
+
fallbackReason: options.fallbackReason || operational.fallbackReason || null,
|
|
62
|
+
profile: permissions.profile,
|
|
63
|
+
tier: permissions.tier,
|
|
64
|
+
writeCapable: permissions.writeCapable,
|
|
65
|
+
readiness: {
|
|
66
|
+
overallStatus: readiness.overallStatus || 'unknown',
|
|
67
|
+
runtimeMode: readiness.runtime && readiness.runtime.mode ? readiness.runtime.mode : 'unknown',
|
|
68
|
+
bootstrapReady: Boolean(readiness.bootstrap && readiness.bootstrap.ready),
|
|
69
|
+
},
|
|
70
|
+
metrics: {
|
|
71
|
+
bookedRevenueUsd: Number(((Number(revenue.bookedRevenueCents || 0)) / 100).toFixed(2)),
|
|
72
|
+
paidOrders: revenue.paidOrders || 0,
|
|
73
|
+
uniqueLeads: funnel.uniqueLeads || 0,
|
|
74
|
+
visitors: funnel.visitors || 0,
|
|
75
|
+
checkoutStarts: funnel.checkoutStarts || 0,
|
|
76
|
+
weeklyProofBackedWorkflowRuns: northStar.weeklyActiveProofBackedWorkflowRuns || 0,
|
|
77
|
+
weeklyTeamsRunningProofBackedWorkflows: northStar.weeklyTeamsRunningProofBackedWorkflows || 0,
|
|
78
|
+
activeGates: gateStats.totalGates || 0,
|
|
79
|
+
blockedActions: gateStats.blocked || 0,
|
|
80
|
+
warnedActions: gateStats.warned || 0,
|
|
81
|
+
topBlockedGate: gateStats.topBlocked
|
|
82
|
+
? {
|
|
83
|
+
id: gateStats.topBlocked,
|
|
84
|
+
count: gateStats.topBlockedCount || 0,
|
|
85
|
+
}
|
|
86
|
+
: null,
|
|
87
|
+
},
|
|
88
|
+
allowedTasks,
|
|
89
|
+
blockedTasks: DISPATCH_BLOCKED_TASKS,
|
|
90
|
+
promptTemplates: DISPATCH_PROMPTS,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function formatDispatchBrief(brief) {
|
|
95
|
+
const lines = [];
|
|
96
|
+
lines.push('Dispatch Ops Brief');
|
|
97
|
+
lines.push('─'.repeat(40));
|
|
98
|
+
lines.push(`Source : ${brief.source}${brief.fallbackReason ? ` (${brief.fallbackReason})` : ''}`);
|
|
99
|
+
lines.push(`Profile : ${brief.profile} (${brief.tier})`);
|
|
100
|
+
lines.push(`Readiness : ${brief.readiness.overallStatus}`);
|
|
101
|
+
lines.push(`Runtime : ${brief.readiness.runtimeMode}`);
|
|
102
|
+
lines.push(`Bootstrap : ${brief.readiness.bootstrapReady ? 'ready' : 'missing context'}`);
|
|
103
|
+
lines.push('');
|
|
104
|
+
lines.push('Key Metrics');
|
|
105
|
+
lines.push(` Booked revenue : $${brief.metrics.bookedRevenueUsd.toFixed(2)}`);
|
|
106
|
+
lines.push(` Paid orders : ${brief.metrics.paidOrders}`);
|
|
107
|
+
lines.push(` Unique leads : ${brief.metrics.uniqueLeads}`);
|
|
108
|
+
lines.push(` Visitors : ${brief.metrics.visitors}`);
|
|
109
|
+
lines.push(` Checkout starts : ${brief.metrics.checkoutStarts}`);
|
|
110
|
+
lines.push(` Weekly proof runs : ${brief.metrics.weeklyProofBackedWorkflowRuns}`);
|
|
111
|
+
lines.push(` Weekly teams : ${brief.metrics.weeklyTeamsRunningProofBackedWorkflows}`);
|
|
112
|
+
lines.push(` Active gates : ${brief.metrics.activeGates}`);
|
|
113
|
+
lines.push(` Blocked actions : ${brief.metrics.blockedActions}`);
|
|
114
|
+
lines.push(` Warned actions : ${brief.metrics.warnedActions}`);
|
|
115
|
+
if (brief.metrics.topBlockedGate) {
|
|
116
|
+
lines.push(` Top blocked gate : ${brief.metrics.topBlockedGate.id} (${brief.metrics.topBlockedGate.count}x)`);
|
|
117
|
+
}
|
|
118
|
+
lines.push('');
|
|
119
|
+
lines.push('Safe Remote Tasks');
|
|
120
|
+
brief.allowedTasks.forEach((entry) => {
|
|
121
|
+
lines.push(`- ${entry.tool}: ${entry.description}`);
|
|
122
|
+
});
|
|
123
|
+
lines.push('');
|
|
124
|
+
lines.push('Do Not Do From Dispatch');
|
|
125
|
+
brief.blockedTasks.forEach((task) => {
|
|
126
|
+
lines.push(`- ${task}`);
|
|
127
|
+
});
|
|
128
|
+
lines.push('');
|
|
129
|
+
lines.push('Prompt Templates');
|
|
130
|
+
brief.promptTemplates.forEach((prompt) => {
|
|
131
|
+
lines.push(`- ${prompt}`);
|
|
132
|
+
});
|
|
133
|
+
return `${lines.join('\n')}\n`;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async function getDispatchBrief(options = {}) {
|
|
137
|
+
const profile = String(options.profile || 'dispatch').trim() || 'dispatch';
|
|
138
|
+
const { source, data, fallbackReason } = await getOperationalDashboard(options);
|
|
139
|
+
return buildDispatchBrief(data, { profile, source, fallbackReason });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
module.exports = {
|
|
143
|
+
DISPATCH_BLOCKED_TASKS,
|
|
144
|
+
DISPATCH_PROMPTS,
|
|
145
|
+
buildDispatchBrief,
|
|
146
|
+
formatDispatchBrief,
|
|
147
|
+
getDispatchBrief,
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
if (require.main === module) {
|
|
151
|
+
getDispatchBrief()
|
|
152
|
+
.then((brief) => {
|
|
153
|
+
process.stdout.write(formatDispatchBrief(brief));
|
|
154
|
+
})
|
|
155
|
+
.catch((err) => {
|
|
156
|
+
console.error(err && err.message ? err.message : err);
|
|
157
|
+
process.exit(1);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
|
|
6
|
+
const ROOT = path.join(__dirname, '..');
|
|
7
|
+
const PRODUCTHUNT_URL = 'https://www.producthunt.com/products/thumbgate';
|
|
8
|
+
const CLAUDE_PLUGIN_LATEST_ASSET_NAME = 'thumbgate-claude-desktop.mcpb';
|
|
9
|
+
const CLAUDE_PLUGIN_NEXT_ASSET_NAME = 'thumbgate-claude-desktop-next.mcpb';
|
|
10
|
+
const CLAUDE_PLUGIN_REVIEW_LATEST_ASSET_NAME = 'thumbgate-claude-plugin-review.zip';
|
|
11
|
+
const CLAUDE_PLUGIN_REVIEW_NEXT_ASSET_NAME = 'thumbgate-claude-plugin-review-next.zip';
|
|
12
|
+
const CODEX_PLUGIN_LATEST_ASSET_NAME = 'thumbgate-codex-plugin.zip';
|
|
13
|
+
const CODEX_PLUGIN_NEXT_ASSET_NAME = 'thumbgate-codex-plugin-next.zip';
|
|
14
|
+
|
|
15
|
+
function readJson(root, relativePath) {
|
|
16
|
+
return JSON.parse(fs.readFileSync(path.join(root, relativePath), 'utf8'));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getPackageVersion(root = ROOT) {
|
|
20
|
+
return String(readJson(root, 'package.json').version || '').trim();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getRepositoryUrl(root = ROOT) {
|
|
24
|
+
return String(readJson(root, 'package.json').repository.url || '').replace(/\.git$/, '');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getClaudePluginVersionedAssetName(version = getPackageVersion(ROOT)) {
|
|
28
|
+
const normalized = String(version || '').replace(/^v/, '');
|
|
29
|
+
return `thumbgate-claude-desktop-v${normalized}.mcpb`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getClaudePluginReviewVersionedAssetName(version = getPackageVersion(ROOT)) {
|
|
33
|
+
const normalized = String(version || '').replace(/^v/, '');
|
|
34
|
+
return `thumbgate-claude-plugin-review-v${normalized}.zip`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function isPrereleaseVersion(version = getPackageVersion(ROOT)) {
|
|
38
|
+
return /^\d+\.\d+\.\d+-[0-9A-Za-z.-]+$/.test(String(version || '').trim());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function getClaudePluginChannelAssetName(version = getPackageVersion(ROOT)) {
|
|
42
|
+
return isPrereleaseVersion(version) ? CLAUDE_PLUGIN_NEXT_ASSET_NAME : CLAUDE_PLUGIN_LATEST_ASSET_NAME;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getClaudePluginReviewChannelAssetName(version = getPackageVersion(ROOT)) {
|
|
46
|
+
return isPrereleaseVersion(version)
|
|
47
|
+
? CLAUDE_PLUGIN_REVIEW_NEXT_ASSET_NAME
|
|
48
|
+
: CLAUDE_PLUGIN_REVIEW_LATEST_ASSET_NAME;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getClaudePluginLatestDownloadUrl(root = ROOT) {
|
|
52
|
+
return `${getRepositoryUrl(root)}/releases/latest/download/${CLAUDE_PLUGIN_LATEST_ASSET_NAME}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getClaudePluginVersionedDownloadUrl(root = ROOT, version = getPackageVersion(root)) {
|
|
56
|
+
const normalized = String(version || '').replace(/^v/, '');
|
|
57
|
+
return `${getRepositoryUrl(root)}/releases/download/v${normalized}/${getClaudePluginVersionedAssetName(normalized)}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function getClaudePluginReviewLatestDownloadUrl(root = ROOT) {
|
|
61
|
+
return `${getRepositoryUrl(root)}/releases/latest/download/${CLAUDE_PLUGIN_REVIEW_LATEST_ASSET_NAME}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getClaudePluginReviewVersionedDownloadUrl(root = ROOT, version = getPackageVersion(root)) {
|
|
65
|
+
const normalized = String(version || '').replace(/^v/, '');
|
|
66
|
+
return `${getRepositoryUrl(root)}/releases/download/v${normalized}/${getClaudePluginReviewVersionedAssetName(normalized)}`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getCodexPluginVersionedAssetName(version = getPackageVersion(ROOT)) {
|
|
70
|
+
const normalized = String(version || '').replace(/^v/, '');
|
|
71
|
+
return `thumbgate-codex-plugin-v${normalized}.zip`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getCodexPluginChannelAssetName(version = getPackageVersion(ROOT)) {
|
|
75
|
+
return isPrereleaseVersion(version) ? CODEX_PLUGIN_NEXT_ASSET_NAME : CODEX_PLUGIN_LATEST_ASSET_NAME;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function getCodexPluginLatestDownloadUrl(root = ROOT) {
|
|
79
|
+
return `${getRepositoryUrl(root)}/releases/latest/download/${CODEX_PLUGIN_LATEST_ASSET_NAME}`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function getCodexPluginVersionedDownloadUrl(root = ROOT, version = getPackageVersion(root)) {
|
|
83
|
+
const normalized = String(version || '').replace(/^v/, '');
|
|
84
|
+
return `${getRepositoryUrl(root)}/releases/download/v${normalized}/${getCodexPluginVersionedAssetName(normalized)}`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports = {
|
|
88
|
+
CLAUDE_PLUGIN_LATEST_ASSET_NAME,
|
|
89
|
+
CLAUDE_PLUGIN_NEXT_ASSET_NAME,
|
|
90
|
+
CLAUDE_PLUGIN_REVIEW_LATEST_ASSET_NAME,
|
|
91
|
+
CLAUDE_PLUGIN_REVIEW_NEXT_ASSET_NAME,
|
|
92
|
+
CODEX_PLUGIN_LATEST_ASSET_NAME,
|
|
93
|
+
CODEX_PLUGIN_NEXT_ASSET_NAME,
|
|
94
|
+
PRODUCTHUNT_URL,
|
|
95
|
+
getClaudePluginChannelAssetName,
|
|
96
|
+
getClaudePluginLatestDownloadUrl,
|
|
97
|
+
getClaudePluginReviewChannelAssetName,
|
|
98
|
+
getClaudePluginReviewLatestDownloadUrl,
|
|
99
|
+
getClaudePluginReviewVersionedAssetName,
|
|
100
|
+
getClaudePluginReviewVersionedDownloadUrl,
|
|
101
|
+
getClaudePluginVersionedAssetName,
|
|
102
|
+
getClaudePluginVersionedDownloadUrl,
|
|
103
|
+
getCodexPluginChannelAssetName,
|
|
104
|
+
getCodexPluginLatestDownloadUrl,
|
|
105
|
+
getCodexPluginVersionedAssetName,
|
|
106
|
+
getCodexPluginVersionedDownloadUrl,
|
|
107
|
+
getPackageVersion,
|
|
108
|
+
getRepositoryUrl,
|
|
109
|
+
isPrereleaseVersion,
|
|
110
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Google Elephant-Goldfish review contract, local and not a plugin clone.
|
|
4
|
+
// A Goldfish reads the target and linked repo files only. Host instructions,
|
|
5
|
+
// lesson logs, and the author session are not context. A same-session
|
|
6
|
+
// self-grade is not a review.
|
|
7
|
+
|
|
8
|
+
const STAGES = Object.freeze([
|
|
9
|
+
'zoom_out',
|
|
10
|
+
'comprehension',
|
|
11
|
+
'critic',
|
|
12
|
+
'intermediate_zoom_out',
|
|
13
|
+
'implementation_readiness',
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
const RANKS = Object.freeze(['blocker', 'major', 'nit']);
|
|
17
|
+
const MAX_REAUDITS = 1;
|
|
18
|
+
const READ_ONLY_TOOLS = Object.freeze(['read', 'grep', 'glob']);
|
|
19
|
+
const HOST_INSTRUCTION = /(?:^|\/)(?:AGENTS|CLAUDE|GEMINI)\.md$/i;
|
|
20
|
+
const LESSON_LOG = /(?:memory-log|feedback-log|prior-lessons)/i;
|
|
21
|
+
|
|
22
|
+
function buildGoldfishReviewPacket({
|
|
23
|
+
targetFile = '',
|
|
24
|
+
authorSessionId = '',
|
|
25
|
+
reviewerSessionId = '',
|
|
26
|
+
linkedFiles = [],
|
|
27
|
+
reauditCount = 0,
|
|
28
|
+
findings = [],
|
|
29
|
+
reviewerTools = null,
|
|
30
|
+
stages = null,
|
|
31
|
+
comprehensionFiles = null,
|
|
32
|
+
} = {}) {
|
|
33
|
+
const reasons = [];
|
|
34
|
+
const target = String(targetFile || '').trim();
|
|
35
|
+
const author = String(authorSessionId || '').trim();
|
|
36
|
+
const reviewer = String(reviewerSessionId || '').trim();
|
|
37
|
+
if (!target) reasons.push('missing_target_file');
|
|
38
|
+
if (!reviewer) reasons.push('missing_reviewer_session');
|
|
39
|
+
if (author && reviewer && author === reviewer) {
|
|
40
|
+
reasons.push('same_session_is_not_a_goldfish_review');
|
|
41
|
+
}
|
|
42
|
+
const files = [target, ...(Array.isArray(linkedFiles) ? linkedFiles : [])]
|
|
43
|
+
.map((file) => String(file || '').trim())
|
|
44
|
+
.filter(Boolean);
|
|
45
|
+
if (files.some((file) => HOST_INSTRUCTION.test(file) || LESSON_LOG.test(file))) {
|
|
46
|
+
reasons.push('host_instructions_or_lessons_leaked_into_goldfish_context');
|
|
47
|
+
}
|
|
48
|
+
const reaudits = Number(reauditCount);
|
|
49
|
+
if (!Number.isInteger(reaudits) || reaudits < 0 || reaudits > MAX_REAUDITS) {
|
|
50
|
+
reasons.push('reaudit_cap_exceeded');
|
|
51
|
+
}
|
|
52
|
+
if (!Array.isArray(findings) || findings.some((finding) => {
|
|
53
|
+
const rank = String(finding && finding.rank || '').trim().toLowerCase();
|
|
54
|
+
return !RANKS.includes(rank);
|
|
55
|
+
})) {
|
|
56
|
+
reasons.push('unranked_finding');
|
|
57
|
+
}
|
|
58
|
+
const declaredTools = reviewerTools == null
|
|
59
|
+
? READ_ONLY_TOOLS
|
|
60
|
+
: (Array.isArray(reviewerTools) ? reviewerTools : [reviewerTools]).map((tool) => String(tool || '').trim().toLowerCase());
|
|
61
|
+
if (declaredTools.length === 0 || declaredTools.some((tool) => !READ_ONLY_TOOLS.includes(tool))) {
|
|
62
|
+
reasons.push('reviewer_tools_not_read_only');
|
|
63
|
+
}
|
|
64
|
+
if (stages != null) {
|
|
65
|
+
const list = Array.isArray(stages) ? stages : [];
|
|
66
|
+
if (list.length !== STAGES.length || list.some((stage, index) => stage !== STAGES[index])) {
|
|
67
|
+
reasons.push('stages_out_of_order');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const comprehension = comprehensionFiles == null
|
|
71
|
+
? [target].filter(Boolean)
|
|
72
|
+
: (Array.isArray(comprehensionFiles) ? comprehensionFiles : []).map((file) => String(file || '').trim()).filter(Boolean);
|
|
73
|
+
if (!target || comprehension.length !== 1 || comprehension[0] !== target) {
|
|
74
|
+
reasons.push('comprehension_must_read_target_only');
|
|
75
|
+
}
|
|
76
|
+
const goldfish = reasons.length === 0;
|
|
77
|
+
return {
|
|
78
|
+
goldfish,
|
|
79
|
+
reasons,
|
|
80
|
+
stages: STAGES,
|
|
81
|
+
ranks: RANKS,
|
|
82
|
+
maxReaudits: MAX_REAUDITS,
|
|
83
|
+
contextFiles: goldfish ? files : [],
|
|
84
|
+
comprehensionFiles: goldfish ? [target] : [],
|
|
85
|
+
reviewerTools: goldfish ? READ_ONLY_TOOLS : [],
|
|
86
|
+
comprehensionReadsTargetOnly: goldfish,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
module.exports = {
|
|
91
|
+
STAGES,
|
|
92
|
+
RANKS,
|
|
93
|
+
MAX_REAUDITS,
|
|
94
|
+
buildGoldfishReviewPacket,
|
|
95
|
+
};
|