Files
miti99/scripts/newsletter/fetch-via-defuddle.js
T
tiennm99 8699294561 feat(tooling): run blog from Claude Code, OpenCode & Codex on shared engine
Extract newsletter scripts to a neutral scripts/newsletter/ engine and add
side-by-side support for all three AI coding tools off one source of truth.

- Move 9 scripts + substack config from .claude/skills/**/scripts to
  scripts/newsletter/ (history preserved); fix PROJECT_ROOT depth and
  cross-require/config paths; repoint all SKILL.md invocations
- Add canonical AGENTS.md; reduce CLAUDE.md to an @AGENTS.md import
- Add opencode.json (permissions, no MCP); skills auto-discovered in place
- Add codex/prompts/*.md (6 prompts) + copy installers (install.sh/.ps1)
- Add docs/multi-tool-usage.md (setup, per-tool invocation, teardown) + README pointer
2026-06-02 14:07:22 +07:00

38 lines
1.0 KiB
JavaScript

#!/usr/bin/env node
// mt-webfetch fallback fetcher via defuddle.md
// Usage: node fetch.js <target_url>
// Exit codes: 0 = content returned, 1 = empty/failed, 2 = bad args
const url = process.argv[2];
if (!url) {
console.error("Usage: node fetch.js <target_url>");
process.exit(2);
}
const defuddleUrl = `https://defuddle.md/${url}`;
async function main() {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 30000);
try {
const res = await fetch(defuddleUrl, {
redirect: "follow",
signal: controller.signal,
headers: { "User-Agent": "mt-webfetch/1.0" },
});
clearTimeout(timeout);
const body = await res.text();
if (!res.ok || !body || body.trim().length === 0) {
console.error(`mt-webfetch: defuddle returned ${res.status} / empty body for ${url}`);
process.exit(1);
}
process.stdout.write(body);
} catch (err) {
clearTimeout(timeout);
console.error(`mt-webfetch: fetch failed for ${url}: ${err.message}`);
process.exit(1);
}
}
main();