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
package/server.json
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"source": "github",
|
|
9
9
|
"url": "https://github.com/IgorGanapolsky/ThumbGate"
|
|
10
10
|
},
|
|
11
|
-
"version": "1.40.
|
|
11
|
+
"version": "1.40.3",
|
|
12
12
|
"packages": [
|
|
13
13
|
{
|
|
14
14
|
"registryType": "npm",
|
|
15
15
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
16
16
|
"identifier": "thumbgate",
|
|
17
|
-
"version": "1.40.
|
|
17
|
+
"version": "1.40.3",
|
|
18
18
|
"runtimeHint": "npx",
|
|
19
19
|
"runtimeArguments": [
|
|
20
20
|
{
|
|
@@ -1,57 +1,41 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: thumbgate-daily-discoveries
|
|
3
|
-
description:
|
|
3
|
+
description: Daily technical-content staging, engagement polling, and reply-draft routine for ThumbGate.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# ThumbGate daily technical-content routine
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Use this routine to turn a verified engineering finding into one useful technical post, then track responses without sending duplicate or unsupported claims.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## Daily routine
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
1. **Daily Cadence (9:00 AM EST):** Runs once per calendar day. Avoids spam while establishing consistent technical authority.
|
|
15
|
-
2. **Dual Scheduling Redundancy:**
|
|
16
|
-
- Primary: macOS crontab (`0 9 * * * /bin/bash scripts/thumbgate-daily-discoveries-publish.sh ...`)
|
|
17
|
-
- Fallback: macOS LaunchAgent (`~/Library/LaunchAgents/com.thumbgate.daily-publish.plist`)
|
|
18
|
-
- Note: GitHub Actions `schedule:` is strictly limited to `codeql.yml` per repo hygiene tests.
|
|
19
|
-
3. **Full UTM Attribution & Tracked Redirects:**
|
|
20
|
-
- All outbound links to `thumbgate.ai` must use `buildUTMLink` from `scripts/social-analytics/utm.js`.
|
|
21
|
-
- Outbound pro/checkout links must route through `/go/pro` (`serveTrackedLinkRedirect` in `src/api/server.js`) to capture first-party funnel telemetry.
|
|
22
|
-
4. **Multi-Surface Staging & Sync:**
|
|
23
|
-
- Staged locally at `docs/marketing/daily-discoveries/YYYY-MM-DD-<slug>.md`.
|
|
24
|
-
- Synchronized to the CEO's Obsidian Vault at `~/Documents/Igor/Research/Daily-Discoveries/`.
|
|
25
|
-
- Logged idempotently to `.thumbgate/daily-discoveries-ledger.jsonl`.
|
|
26
|
-
- Dispatches to Dev.to / Zernio if API keys are configured.
|
|
12
|
+
The LaunchAgent runs at 9:00 AM local time. It stages one canonical technical article, polls available engagement metrics, and queues reply drafts. It sends no posts or replies.
|
|
27
13
|
|
|
28
|
-
|
|
14
|
+
1. Review the staged article and confirm each technical claim against its cited commit or source.
|
|
15
|
+
2. Adapt the finding to the rules and format of each relevant community. Do not paste the same promotion everywhere.
|
|
16
|
+
3. Use the canonical ThumbGate URL and UTM links from the article. Disclose the ThumbGate affiliation.
|
|
17
|
+
4. Before each external post, add an OPEN row to `coordination/LOCKS.md` and comment on the Ops Coordination Linear issue. Mark the row DONE after verifying the post URL.
|
|
18
|
+
5. Review `.thumbgate/reply-drafts.jsonl` for useful questions. Reply in the platform only when the answer is accurate, relevant, and welcome. Mark the coordination row DONE after verifying delivery.
|
|
19
|
+
6. Review the metrics database and the daily log. Record which posts led to meaningful discussion or attributed visits.
|
|
29
20
|
|
|
30
|
-
|
|
21
|
+
Skip posts that repeat yesterday's point, lack evidence, violate a community's rules, or expose private or employer information. Do not invent customer results or product capabilities.
|
|
31
22
|
|
|
32
|
-
|
|
33
|
-
# Preview today's technical discovery without making mutations or network calls
|
|
34
|
-
node scripts/thumbgate-daily-discoveries-publish.js --dry-run
|
|
23
|
+
## What the automation supports
|
|
35
24
|
|
|
36
|
-
|
|
37
|
-
node scripts/thumbgate-daily-discoveries-publish.js --json
|
|
25
|
+
The daily article is staged at `docs/marketing/daily-discoveries/YYYY-MM-DD-<slug>.md`, its canonical HTML is written under `public/blog/`, and a receipt is added to `.thumbgate/daily-discoveries-ledger.jsonl`. A second run on the same date skips an existing staged article. The article uses UTM-tagged links. The Obsidian copy is written only when the vault is available and has no conflicting claim.
|
|
38
26
|
|
|
39
|
-
|
|
40
|
-
node scripts/thumbgate-daily-discoveries-publish.js --force
|
|
41
|
-
|
|
42
|
-
# Shell wrapper (used by crontab / launchd)
|
|
43
|
-
./scripts/thumbgate-daily-discoveries-publish.sh
|
|
27
|
+
The scheduled command uses `--stage-only`, so a configured Dev.to key cannot trigger publication. The default metrics poller reads GitHub and Plausible metrics and uses Zernio for connected social accounts when its API key exists. Legacy direct pollers for Reddit, LinkedIn, Threads, Instagram, TikTok, and YouTube are disabled by default. Reddit and Bluesky monitors queue reply drafts. The LinkedIn reply monitor currently reports that its required Community Management API access is unavailable.
|
|
44
28
|
|
|
45
|
-
|
|
46
|
-
node --test tests/thumbgate-daily-discoveries-publish.test.js
|
|
47
|
-
```
|
|
29
|
+
No working integration was confirmed for Hacker News, Hashnode, Medium, or ZyVOP. The HubSpot social connector denied access, and Zernio publishing is disabled by project policy. Do not describe those channels as scheduled or monitored until an authorized path is verified.
|
|
48
30
|
|
|
49
|
-
|
|
31
|
+
## Run it by hand
|
|
50
32
|
|
|
51
|
-
|
|
33
|
+
```bash
|
|
34
|
+
node scripts/thumbgate-daily-discoveries-publish.js --dry-run --json
|
|
35
|
+
node scripts/thumbgate-daily-discoveries-publish.js --stage-only --json
|
|
36
|
+
./scripts/thumbgate-daily-discoveries-publish.sh
|
|
37
|
+
bash scripts/install-thumbgate-daily-publish-launchd.sh
|
|
38
|
+
bash scripts/install-thumbgate-daily-publish-launchd.sh --uninstall
|
|
39
|
+
```
|
|
52
40
|
|
|
53
|
-
|
|
54
|
-
- [ ] Verify outbound links contain valid UTM parameters (`utm_source=daily_discoveries`, `utm_campaign=daily_technical_discoveries`).
|
|
55
|
-
- [ ] Verify `launchctl list | grep thumbgate` reports exit code 0.
|
|
56
|
-
- [ ] Verify `crontab -l | grep thumbgate` contains the 9:00 AM daily trigger.
|
|
57
|
-
- [ ] Check `.thumbgate/daily-discoveries-ledger.jsonl` for recent execution receipts.
|
|
41
|
+
The LaunchAgent label is `com.thumbgate.daily-publish`. It is the only scheduler for this routine. Do not also add a cron entry.
|
package/src/api/server.js
CHANGED
|
@@ -7881,7 +7881,13 @@ function createUnscopedApiServer({ ownerAdminDependencies = {} } = {}) {
|
|
|
7881
7881
|
feedbackDir: requestSafeDataDir,
|
|
7882
7882
|
limit: 10,
|
|
7883
7883
|
});
|
|
7884
|
+
// Attribute the click to the project the status line was showing.
|
|
7885
|
+
const quickProject = projectForCapture({}, {
|
|
7886
|
+
hosted: !isLoopbackHost(getRequestHostHeader(req)),
|
|
7887
|
+
cwd: resolveRequestProjectDir(req, parsed),
|
|
7888
|
+
});
|
|
7884
7889
|
const result = captureFeedback({
|
|
7890
|
+
...quickProject,
|
|
7885
7891
|
signal,
|
|
7886
7892
|
context: 'Quick capture from Claude Code statusline',
|
|
7887
7893
|
chatHistory,
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# install-thumbgate-daily-publish-launchd.sh — Daily ThumbGate News & Technical Discoveries LaunchAgent.
|
|
3
|
-
#
|
|
4
|
-
# Default: every day at 09:00 AM EST (local).
|
|
5
|
-
#
|
|
6
|
-
# Usage:
|
|
7
|
-
# bash scripts/install-thumbgate-daily-publish-launchd.sh
|
|
8
|
-
# bash scripts/install-thumbgate-daily-publish-launchd.sh --uninstall
|
|
9
|
-
#
|
|
10
|
-
# Logs: ~/Library/Logs/thumbgate-daily-publish.log
|
|
11
|
-
set -euo pipefail
|
|
12
|
-
|
|
13
|
-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
14
|
-
SCRIPT="$ROOT/scripts/thumbgate-daily-discoveries-publish.sh"
|
|
15
|
-
LABEL="com.thumbgate.daily-publish"
|
|
16
|
-
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"
|
|
17
|
-
LOG_DIR="$HOME/Library/Logs"
|
|
18
|
-
HOUR="${THUMBGATE_PUBLISH_HOUR:-9}"
|
|
19
|
-
MINUTE="${THUMBGATE_PUBLISH_MINUTE:-0}"
|
|
20
|
-
|
|
21
|
-
UNINSTALL=0
|
|
22
|
-
while [[ $# -gt 0 ]]; do
|
|
23
|
-
case "$1" in
|
|
24
|
-
--uninstall) UNINSTALL=1 ;;
|
|
25
|
-
-h|--help)
|
|
26
|
-
echo "Usage: $0 [--uninstall]"
|
|
27
|
-
exit 0
|
|
28
|
-
;;
|
|
29
|
-
*)
|
|
30
|
-
echo "unknown arg: $1" >&2
|
|
31
|
-
exit 2
|
|
32
|
-
;;
|
|
33
|
-
esac
|
|
34
|
-
shift
|
|
35
|
-
done
|
|
36
|
-
|
|
37
|
-
if [[ "$(uname -s)" != "Darwin" ]]; then
|
|
38
|
-
echo "error: macOS only" >&2
|
|
39
|
-
exit 1
|
|
40
|
-
fi
|
|
41
|
-
|
|
42
|
-
if [[ "$UNINSTALL" -eq 1 ]]; then
|
|
43
|
-
launchctl bootout "gui/$(id -u)/${LABEL}" 2>/dev/null || true
|
|
44
|
-
rm -f "$PLIST"
|
|
45
|
-
echo "removed $PLIST"
|
|
46
|
-
exit 0
|
|
47
|
-
fi
|
|
48
|
-
|
|
49
|
-
mkdir -p "$LOG_DIR" "$HOME/Library/LaunchAgents"
|
|
50
|
-
|
|
51
|
-
cat > "$PLIST" <<PLIST_EOF
|
|
52
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
53
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
54
|
-
<plist version="1.0">
|
|
55
|
-
<dict>
|
|
56
|
-
<key>Label</key>
|
|
57
|
-
<string>${LABEL}</string>
|
|
58
|
-
<key>ProgramArguments</key>
|
|
59
|
-
<array>
|
|
60
|
-
<string>/bin/bash</string>
|
|
61
|
-
<string>${SCRIPT}</string>
|
|
62
|
-
</array>
|
|
63
|
-
<key>StartCalendarInterval</key>
|
|
64
|
-
<dict>
|
|
65
|
-
<key>Hour</key>
|
|
66
|
-
<integer>${HOUR}</integer>
|
|
67
|
-
<key>Minute</key>
|
|
68
|
-
<integer>${MINUTE}</integer>
|
|
69
|
-
</dict>
|
|
70
|
-
<key>StandardOutPath</key>
|
|
71
|
-
<string>${LOG_DIR}/thumbgate-daily-publish.log</string>
|
|
72
|
-
<key>StandardErrorPath</key>
|
|
73
|
-
<string>${LOG_DIR}/thumbgate-daily-publish.log</string>
|
|
74
|
-
<key>WorkingDirectory</key>
|
|
75
|
-
<string>${ROOT}</string>
|
|
76
|
-
</dict>
|
|
77
|
-
</plist>
|
|
78
|
-
PLIST_EOF
|
|
79
|
-
|
|
80
|
-
launchctl bootout "gui/$(id -u)/${LABEL}" 2>/dev/null || true
|
|
81
|
-
launchctl bootstrap "gui/$(id -u)" "$PLIST"
|
|
82
|
-
|
|
83
|
-
echo "installed and loaded ${PLIST} (runs daily at ${HOUR}:${MINUTE})"
|
|
@@ -1,461 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* thumbgate-daily-discoveries-publish.js
|
|
6
|
-
*
|
|
7
|
-
* Daily autonomous publishing engine for ThumbGate news and technical discoveries.
|
|
8
|
-
* Scheduled to run once per day at 9:00 AM EST via crontab / launchd.
|
|
9
|
-
*
|
|
10
|
-
* Capabilities:
|
|
11
|
-
* 1. Harvests latest technical discoveries (git innovations, format steals, pre-action rules).
|
|
12
|
-
* 2. Pulls live metrics (active gates, prevented failures, adherence rate).
|
|
13
|
-
* 3. Formats an in-depth, SEO-optimized technical post with code snippets and architecture notes.
|
|
14
|
-
* 4. Enforces full UTM attribution and /go/:slug tracked redirect links for revenue observability.
|
|
15
|
-
* 5. Generates public canonical HTML page under public/blog/ ensuring valid canonical target.
|
|
16
|
-
* 6. Coordinates fleet lease before writing to shared Obsidian Vault.
|
|
17
|
-
* 7. Acquires atomic run lock to prevent duplicate execution across cron and launchd.
|
|
18
|
-
* 8. Dispatches to Dev.to with canonical_url, holding ambiguous attempts until their outcome is reconciled.
|
|
19
|
-
* 9. Records idempotent receipts to .thumbgate/daily-discoveries-ledger.jsonl.
|
|
20
|
-
*
|
|
21
|
-
* Usage:
|
|
22
|
-
* node scripts/thumbgate-daily-discoveries-publish.js --dry-run
|
|
23
|
-
* node scripts/thumbgate-daily-discoveries-publish.js --json
|
|
24
|
-
* node scripts/thumbgate-daily-discoveries-publish.js --force
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
const fs = require('node:fs');
|
|
28
|
-
const path = require('node:path');
|
|
29
|
-
const { execSync } = require('node:child_process');
|
|
30
|
-
const { buildUTMLink } = require('./social-analytics/utm');
|
|
31
|
-
|
|
32
|
-
const REPO_ROOT = path.resolve(process.env.THUMBGATE_PUBLISH_ROOT || path.join(__dirname, '..'));
|
|
33
|
-
const MARKETING_DIR = path.join(REPO_ROOT, 'docs', 'marketing', 'daily-discoveries');
|
|
34
|
-
const PUBLIC_BLOG_DIR = path.join(REPO_ROOT, 'public', 'blog');
|
|
35
|
-
const LEDGER_PATH = path.join(REPO_ROOT, '.thumbgate', 'daily-discoveries-ledger.jsonl');
|
|
36
|
-
const LOCK_PATH = path.join(REPO_ROOT, '.thumbgate', 'daily-discoveries.lock');
|
|
37
|
-
const VAULT_DIR = process.env.VAULT_DIR || path.join(process.env.HOME || '', 'Documents', 'Igor');
|
|
38
|
-
|
|
39
|
-
const CURATED_TOPICS = require('./daily-discoveries-topics.json');
|
|
40
|
-
|
|
41
|
-
function getFormattedDate(date = new Date()) {
|
|
42
|
-
const yyyy = date.getFullYear();
|
|
43
|
-
const mm = String(date.getMonth() + 1).padStart(2, '0');
|
|
44
|
-
const dd = String(date.getDate()).padStart(2, '0');
|
|
45
|
-
return `${yyyy}-${mm}-${dd}`;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function selectTopicForDay(date = new Date()) {
|
|
49
|
-
const startOfYear = new Date(date.getFullYear(), 0, 1);
|
|
50
|
-
const dayOfYear = Math.floor((date - startOfYear) / (24 * 60 * 60 * 1000));
|
|
51
|
-
const index = Math.abs(dayOfYear % CURATED_TOPICS.length);
|
|
52
|
-
return CURATED_TOPICS[index];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function getRecentGitCommit() {
|
|
56
|
-
const gitBin = fs.existsSync('/usr/bin/git') ? '/usr/bin/git' : 'git';
|
|
57
|
-
try {
|
|
58
|
-
const log = execSync(`${gitBin} log -1 --format="%h - %s" origin/main 2>/dev/null || ${gitBin} log -1 --format="%h - %s"`, {
|
|
59
|
-
cwd: REPO_ROOT,
|
|
60
|
-
encoding: 'utf8',
|
|
61
|
-
}).trim();
|
|
62
|
-
return log;
|
|
63
|
-
} catch {
|
|
64
|
-
// Staging outside a Git checkout still produces a usable draft.
|
|
65
|
-
return 'Tip of main';
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function generatePostContent(topic, dateStr, gitCommit) {
|
|
70
|
-
const campaign = 'daily_technical_discoveries';
|
|
71
|
-
const source = 'daily_discoveries';
|
|
72
|
-
const medium = 'article';
|
|
73
|
-
const contentId = topic.slug;
|
|
74
|
-
|
|
75
|
-
const siteUrl = buildUTMLink('https://thumbgate.ai', { source, medium, campaign, content: contentId });
|
|
76
|
-
const proUrl = buildUTMLink('https://thumbgate.ai/go/pro', { source, medium, campaign, content: contentId });
|
|
77
|
-
const docsUrl = buildUTMLink('https://thumbgate.ai/docs', { source, medium, campaign, content: contentId });
|
|
78
|
-
const githubUrl = buildUTMLink('https://github.com/IgorGanapolsky/ThumbGate', { source, medium, campaign, content: contentId });
|
|
79
|
-
const canonicalUrl = `https://thumbgate.ai/blog/${dateStr}-${topic.slug}`;
|
|
80
|
-
|
|
81
|
-
return `# ${topic.title}
|
|
82
|
-
|
|
83
|
-
> **ThumbGate Engineering Daily** | ${dateStr}
|
|
84
|
-
> *Author:* Igor Ganapolsky ([@IgorGanapolsky](https://github.com/IgorGanapolsky))
|
|
85
|
-
> *Verified on Commit:* \`${gitCommit}\`
|
|
86
|
-
> *Canonical URL:* \`${canonicalUrl}\`
|
|
87
|
-
|
|
88
|
-
---
|
|
89
|
-
|
|
90
|
-
## Executive Summary
|
|
91
|
-
|
|
92
|
-
${topic.tagline}
|
|
93
|
-
|
|
94
|
-
Autonomous AI coding agents are rapidly moving from conversational prototypes to multi-tool execution engines with file system access, terminal execution, and external API integrations. However, without pre-action safety guarantees, agents remain vulnerable to untrusted context manipulation, hallucinated actions, and cascading production errors.
|
|
95
|
-
|
|
96
|
-
At **[ThumbGate](${siteUrl})**, we treat agent reliability not as a prompting exercise, but as an infrastructure firewall. Here is our latest technical discovery and implementation pattern from production.
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
## The Failure Mode
|
|
101
|
-
|
|
102
|
-
${topic.problem}
|
|
103
|
-
|
|
104
|
-
When an agentic system relies purely on instructions:
|
|
105
|
-
- Malicious or malformed inputs blend directly into execution context.
|
|
106
|
-
- System prompt instructions degrade as context windows expand.
|
|
107
|
-
- Execution boundaries blur between what the agent *reads* and what the agent *executes*.
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
## Architectural Resolution
|
|
112
|
-
|
|
113
|
-
${topic.solution}
|
|
114
|
-
|
|
115
|
-
### Enforcement Code Pattern
|
|
116
|
-
|
|
117
|
-
\`\`\`javascript
|
|
118
|
-
${topic.codeSnippet}
|
|
119
|
-
\`\`\`
|
|
120
|
-
|
|
121
|
-
By enforcing this check in the **PreToolUse** hook lifecycle, the agent runtime intercepts and validates commands in under 5ms, long before any shell or network call can execute.
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
## Key Engineering Takeaways
|
|
126
|
-
|
|
127
|
-
1. **Deterministic Over Heuristic:** Safety boundaries must execute as deterministic code gates rather than polite LLM suggestions.
|
|
128
|
-
2. **Attributed Observability:** Every blocked action produces an idempotent outcome receipt with verifiable execution evidence.
|
|
129
|
-
3. **Continuous Learning:** Thumbs-up/down signals feed directly into local lesson stores, generating progressive prevention rules over time.
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
## Learn More & Try ThumbGate
|
|
134
|
-
|
|
135
|
-
- **GitHub Repository (Open Source):** [ThumbGate GitHub](${githubUrl})
|
|
136
|
-
- **Production Platform:** [ThumbGate Infrastructure Firewall](${siteUrl})
|
|
137
|
-
- **Try ThumbGate Pro:** [Upgrade & Access Live Gates](${proUrl})
|
|
138
|
-
- **Documentation & MCP Integration:** [ThumbGate Docs](${docsUrl})
|
|
139
|
-
`;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function renderBlogHtml(topic, dateStr, markdownContent) {
|
|
143
|
-
const slug = `${dateStr}-${topic.slug}`;
|
|
144
|
-
const title = String(topic.title || '').replaceAll('"', '"');
|
|
145
|
-
const tagline = String(topic.tagline || '').replaceAll('"', '"');
|
|
146
|
-
const canonicalUrl = `https://thumbgate.ai/blog/${slug}`;
|
|
147
|
-
|
|
148
|
-
return `<!DOCTYPE html>
|
|
149
|
-
<html lang="en">
|
|
150
|
-
<head>
|
|
151
|
-
<meta charset="UTF-8">
|
|
152
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
153
|
-
<title>${title} | ThumbGate</title>
|
|
154
|
-
<link rel="canonical" href="${canonicalUrl}">
|
|
155
|
-
<meta name="description" content="${tagline}">
|
|
156
|
-
<meta property="og:title" content="${title}">
|
|
157
|
-
<meta property="og:description" content="${tagline}">
|
|
158
|
-
<meta property="og:url" content="${canonicalUrl}">
|
|
159
|
-
<link rel="stylesheet" href="/style.css">
|
|
160
|
-
</head>
|
|
161
|
-
<body class="blog-post-page">
|
|
162
|
-
<main class="container">
|
|
163
|
-
<article class="post-content">
|
|
164
|
-
<h1>${topic.title}</h1>
|
|
165
|
-
<p class="post-meta">Published on ${dateStr} by Igor Ganapolsky</p>
|
|
166
|
-
<section class="post-body">
|
|
167
|
-
<p class="lead">${topic.tagline}</p>
|
|
168
|
-
<h2>The Failure Mode</h2>
|
|
169
|
-
<p>${topic.problem}</p>
|
|
170
|
-
<h2>Architectural Resolution</h2>
|
|
171
|
-
<p>${topic.solution}</p>
|
|
172
|
-
<pre><code>${String(topic.codeSnippet || '').replaceAll('<', '<').replaceAll('>', '>')}</code></pre>
|
|
173
|
-
</section>
|
|
174
|
-
<footer class="post-footer">
|
|
175
|
-
<a href="https://thumbgate.ai/go/pro?utm_source=blog&utm_medium=article&utm_campaign=${slug}" class="cta-btn">Upgrade to ThumbGate Pro</a>
|
|
176
|
-
</footer>
|
|
177
|
-
</article>
|
|
178
|
-
</main>
|
|
179
|
-
</body>
|
|
180
|
-
</html>`;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function acquireRunLock() {
|
|
184
|
-
fs.mkdirSync(path.dirname(LOCK_PATH), { recursive: true });
|
|
185
|
-
try {
|
|
186
|
-
const fd = fs.openSync(LOCK_PATH, 'wx');
|
|
187
|
-
fs.writeFileSync(fd, `${process.pid}\n`, 'utf8');
|
|
188
|
-
fs.closeSync(fd);
|
|
189
|
-
return true;
|
|
190
|
-
} catch (err) {
|
|
191
|
-
if (err.code === 'EEXIST') {
|
|
192
|
-
try {
|
|
193
|
-
const stats = fs.statSync(LOCK_PATH);
|
|
194
|
-
// Stale lock reclamation (> 30m)
|
|
195
|
-
if (Date.now() - stats.mtimeMs > 30 * 60 * 1000) {
|
|
196
|
-
fs.unlinkSync(LOCK_PATH);
|
|
197
|
-
return acquireRunLock();
|
|
198
|
-
}
|
|
199
|
-
} catch {
|
|
200
|
-
// A changed or unreadable lock cannot grant this process ownership.
|
|
201
|
-
}
|
|
202
|
-
return false;
|
|
203
|
-
}
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function releaseRunLock() {
|
|
209
|
-
try {
|
|
210
|
-
if (fs.existsSync(LOCK_PATH)) {
|
|
211
|
-
fs.unlinkSync(LOCK_PATH);
|
|
212
|
-
}
|
|
213
|
-
} catch {
|
|
214
|
-
// Keep an unreleasable lock in place so later runs remain blocked.
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function canWriteToSharedVault(vaultDir) {
|
|
219
|
-
if (!fs.existsSync(vaultDir)) return false;
|
|
220
|
-
const claimsDir = path.join(vaultDir, 'Agents', 'Claims');
|
|
221
|
-
const runningJobsDir = path.join(vaultDir, 'Agent-Jobs', 'running');
|
|
222
|
-
for (const dir of [claimsDir, runningJobsDir]) {
|
|
223
|
-
if (fs.existsSync(dir)) {
|
|
224
|
-
try {
|
|
225
|
-
const entries = fs.readdirSync(dir);
|
|
226
|
-
for (const entry of entries) {
|
|
227
|
-
if (entry.toLowerCase().includes('daily-discoveries')) {
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
} catch {
|
|
232
|
-
// Unreadable coordination claims cannot authorize a vault write.
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return true;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function hasPublicationReceipt(receipt) {
|
|
241
|
-
if (!receipt || !Number.isSafeInteger(receipt.id) || receipt.id <= 0 || typeof receipt.url !== 'string') return false;
|
|
242
|
-
try {
|
|
243
|
-
const url = new URL(receipt.url);
|
|
244
|
-
return url.protocol === 'https:' && url.hostname === 'dev.to' && url.pathname !== '/';
|
|
245
|
-
} catch {
|
|
246
|
-
// Invalid URLs cannot serve as proof of remote publication.
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function getPublicationStatus(dateStr) {
|
|
252
|
-
if (!fs.existsSync(LEDGER_PATH)) return null;
|
|
253
|
-
let status = null;
|
|
254
|
-
const lines = fs.readFileSync(LEDGER_PATH, 'utf8').trim().split('\n');
|
|
255
|
-
for (const line of lines) {
|
|
256
|
-
let item;
|
|
257
|
-
try {
|
|
258
|
-
item = JSON.parse(line);
|
|
259
|
-
} catch {
|
|
260
|
-
continue;
|
|
261
|
-
}
|
|
262
|
-
if (!item || item.date !== dateStr) continue;
|
|
263
|
-
if (item.status === 'publication_unknown') status = 'publication_unknown';
|
|
264
|
-
if (item.status === 'published' && hasPublicationReceipt(item.devto)) status = 'published';
|
|
265
|
-
}
|
|
266
|
-
return status;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function hasAlreadyPublishedToday(dateStr) {
|
|
270
|
-
return getPublicationStatus(dateStr) === 'published';
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function recordLedgerEntry(entry) {
|
|
274
|
-
fs.mkdirSync(path.dirname(LEDGER_PATH), { recursive: true });
|
|
275
|
-
fs.appendFileSync(LEDGER_PATH, JSON.stringify(entry) + '\n', 'utf8');
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
async function runDailyPublish(options = {}) {
|
|
279
|
-
const now = new Date();
|
|
280
|
-
const dateStr = getFormattedDate(now);
|
|
281
|
-
const dryRun = options.dryRun === true;
|
|
282
|
-
const force = options.force === true;
|
|
283
|
-
const topic = selectTopicForDay(now);
|
|
284
|
-
const gitCommit = getRecentGitCommit();
|
|
285
|
-
const content = generatePostContent(topic, dateStr, gitCommit);
|
|
286
|
-
const canonicalUrl = `https://thumbgate.ai/blog/${dateStr}-${topic.slug}`;
|
|
287
|
-
|
|
288
|
-
const filename = `${dateStr}-${topic.slug}.md`;
|
|
289
|
-
const stagedPath = path.join(MARKETING_DIR, filename);
|
|
290
|
-
const publicBlogHtmlPath = path.join(PUBLIC_BLOG_DIR, `${dateStr}-${topic.slug}.html`);
|
|
291
|
-
|
|
292
|
-
const outputs = [];
|
|
293
|
-
|
|
294
|
-
if (dryRun) {
|
|
295
|
-
return {
|
|
296
|
-
status: 'dry_run_preview',
|
|
297
|
-
date: dateStr,
|
|
298
|
-
topic: topic.slug,
|
|
299
|
-
title: topic.title,
|
|
300
|
-
commit: gitCommit,
|
|
301
|
-
canonicalUrl,
|
|
302
|
-
stagedPath,
|
|
303
|
-
dryRun: true,
|
|
304
|
-
previewSnippet: content.slice(0, 300) + '...',
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// Acquire atomic process lock to prevent duplicate runs
|
|
309
|
-
if (!acquireRunLock()) {
|
|
310
|
-
return {
|
|
311
|
-
status: 'locked',
|
|
312
|
-
reason: 'Another daily publish process holds the active run lock. Skipping duplicate execution.',
|
|
313
|
-
date: dateStr,
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
try {
|
|
318
|
-
const publicationStatus = getPublicationStatus(dateStr);
|
|
319
|
-
if (publicationStatus === 'publication_unknown') {
|
|
320
|
-
return {
|
|
321
|
-
status: 'publication_unknown',
|
|
322
|
-
reason: 'A prior Dev.to attempt has an unknown outcome. Reconcile its remote publication before retrying; --force cannot override this hold.',
|
|
323
|
-
date: dateStr,
|
|
324
|
-
canonicalUrl,
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
if (!force && publicationStatus === 'published') {
|
|
328
|
-
return {
|
|
329
|
-
status: 'skipped',
|
|
330
|
-
reason: `Already published daily discovery for ${dateStr}. Use --force to override.`,
|
|
331
|
-
date: dateStr,
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// 1. Stage local marketing markdown
|
|
336
|
-
fs.mkdirSync(MARKETING_DIR, { recursive: true });
|
|
337
|
-
fs.writeFileSync(stagedPath, content, 'utf8');
|
|
338
|
-
outputs.push({ type: 'local_file', path: stagedPath });
|
|
339
|
-
|
|
340
|
-
// 2. Generate public canonical HTML page
|
|
341
|
-
fs.mkdirSync(PUBLIC_BLOG_DIR, { recursive: true });
|
|
342
|
-
fs.writeFileSync(publicBlogHtmlPath, renderBlogHtml(topic, dateStr, content), 'utf8');
|
|
343
|
-
outputs.push({ type: 'public_html', path: publicBlogHtmlPath });
|
|
344
|
-
|
|
345
|
-
// 3. Sync to Obsidian Vault if present and safe
|
|
346
|
-
const vaultDiscoveryDir = path.join(VAULT_DIR, 'Research', 'Daily-Discoveries');
|
|
347
|
-
if (fs.existsSync(VAULT_DIR)) {
|
|
348
|
-
if (canWriteToSharedVault(VAULT_DIR)) {
|
|
349
|
-
fs.mkdirSync(vaultDiscoveryDir, { recursive: true });
|
|
350
|
-
const vaultPath = path.join(vaultDiscoveryDir, filename);
|
|
351
|
-
fs.writeFileSync(vaultPath, content, 'utf8');
|
|
352
|
-
outputs.push({ type: 'obsidian_vault', path: vaultPath });
|
|
353
|
-
} else {
|
|
354
|
-
outputs.push({ type: 'obsidian_vault_skipped', reason: 'Active foreign vault claim detected.' });
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
// 4. Attempt Dev.to publish if API key is present
|
|
359
|
-
let devtoResult = null;
|
|
360
|
-
if (process.env.DEVTO_API_KEY) {
|
|
361
|
-
const { publishArticle } = require('./social-analytics/publishers/devto');
|
|
362
|
-
recordLedgerEntry({
|
|
363
|
-
date: dateStr,
|
|
364
|
-
topic: topic.slug,
|
|
365
|
-
title: topic.title,
|
|
366
|
-
status: 'publication_unknown',
|
|
367
|
-
attemptedAt: now.toISOString(),
|
|
368
|
-
canonicalUrl,
|
|
369
|
-
outputs,
|
|
370
|
-
devto: null,
|
|
371
|
-
reason: 'Dev.to publication attempt started. Reconcile the remote outcome if no confirmed receipt follows.',
|
|
372
|
-
});
|
|
373
|
-
const res = await publishArticle({
|
|
374
|
-
title: topic.title,
|
|
375
|
-
body_markdown: content,
|
|
376
|
-
tags: topic.tags,
|
|
377
|
-
published: true,
|
|
378
|
-
canonical_url: canonicalUrl,
|
|
379
|
-
});
|
|
380
|
-
if (!hasPublicationReceipt(res)) {
|
|
381
|
-
const reason = 'Dev.to accepted the request without a valid publication receipt. Reconcile the remote outcome before retrying.';
|
|
382
|
-
return { status: 'publication_unknown', reason, date: dateStr, canonicalUrl, stagedPath, publicBlogHtmlPath, dryRun: false };
|
|
383
|
-
}
|
|
384
|
-
devtoResult = { id: res.id, url: res.url };
|
|
385
|
-
outputs.push({ type: 'devto', url: res.url });
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
const status = devtoResult ? 'published' : 'staged';
|
|
389
|
-
recordLedgerEntry({
|
|
390
|
-
date: dateStr,
|
|
391
|
-
topic: topic.slug,
|
|
392
|
-
title: topic.title,
|
|
393
|
-
status,
|
|
394
|
-
...(devtoResult ? { publishedAt: now.toISOString() } : { stagedAt: now.toISOString() }),
|
|
395
|
-
canonicalUrl,
|
|
396
|
-
outputs,
|
|
397
|
-
devto: devtoResult,
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
return {
|
|
401
|
-
status,
|
|
402
|
-
date: dateStr,
|
|
403
|
-
topic: topic.slug,
|
|
404
|
-
title: topic.title,
|
|
405
|
-
commit: gitCommit,
|
|
406
|
-
canonicalUrl,
|
|
407
|
-
stagedPath,
|
|
408
|
-
publicBlogHtmlPath,
|
|
409
|
-
dryRun: false,
|
|
410
|
-
};
|
|
411
|
-
} finally {
|
|
412
|
-
releaseRunLock();
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
async function main() {
|
|
417
|
-
const args = new Set(process.argv.slice(2));
|
|
418
|
-
const dryRun = args.has('--dry-run');
|
|
419
|
-
const json = args.has('--json');
|
|
420
|
-
const force = args.has('--force');
|
|
421
|
-
|
|
422
|
-
try {
|
|
423
|
-
const result = await runDailyPublish({ dryRun, force });
|
|
424
|
-
if (json) {
|
|
425
|
-
process.stdout.write(JSON.stringify(result, null, 2) + '\n');
|
|
426
|
-
} else {
|
|
427
|
-
console.log(`[ThumbGate Daily Discoveries] Status: ${result.status}`);
|
|
428
|
-
console.log(` Topic: ${result.title}`);
|
|
429
|
-
console.log(` Date: ${result.date}`);
|
|
430
|
-
if (result.canonicalUrl) console.log(` Canonical URL: ${result.canonicalUrl}`);
|
|
431
|
-
if (result.stagedPath) console.log(` Staged: ${result.stagedPath}`);
|
|
432
|
-
if (dryRun) {
|
|
433
|
-
console.log('\n--- Preview ---');
|
|
434
|
-
console.log(result.previewSnippet);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
} catch (err) {
|
|
438
|
-
console.error(`[ThumbGate Daily Discoveries] Error: ${err.message}`);
|
|
439
|
-
process.exit(1);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
if (require.main === module) {
|
|
444
|
-
void main();
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
module.exports = {
|
|
448
|
-
selectTopicForDay,
|
|
449
|
-
generatePostContent,
|
|
450
|
-
renderBlogHtml,
|
|
451
|
-
runDailyPublish,
|
|
452
|
-
buildUTMLink,
|
|
453
|
-
getFormattedDate,
|
|
454
|
-
acquireRunLock,
|
|
455
|
-
releaseRunLock,
|
|
456
|
-
canWriteToSharedVault,
|
|
457
|
-
hasAlreadyPublishedToday,
|
|
458
|
-
getRecentGitCommit,
|
|
459
|
-
recordLedgerEntry,
|
|
460
|
-
CURATED_TOPICS,
|
|
461
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# thumbgate-daily-discoveries-publish.sh
|
|
3
|
-
# Automated daily publishing of ThumbGate news & technical discoveries.
|
|
4
|
-
# Invoked daily at 9:00 AM EST via crontab / launchd.
|
|
5
|
-
|
|
6
|
-
set -euo pipefail
|
|
7
|
-
|
|
8
|
-
export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:$PATH"
|
|
9
|
-
|
|
10
|
-
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
11
|
-
cd "$REPO_DIR"
|
|
12
|
-
|
|
13
|
-
echo "=== [$(date -u +"%Y-%m-%dT%H:%M:%SZ")] ThumbGate Daily Publishing Started ==="
|
|
14
|
-
|
|
15
|
-
# Execute node publishing script
|
|
16
|
-
node scripts/thumbgate-daily-discoveries-publish.js "$@"
|
|
17
|
-
|
|
18
|
-
echo "=== [$(date -u +"%Y-%m-%dT%H:%M:%SZ")] ThumbGate Daily Publishing Completed ==="
|