mirror of
https://github.com/vectorize-io/hindsight.git
synced 2026-09-14 19:31:49 +08:00
729b1120c4
grok-build install only stripped the marker-delimited block, so an unmarked [mcp_servers.hindsight] + hook tables from an earlier config survived and the fresh block redefined them. TOML rejects duplicate tables, Grok could not parse the file, and every MCP server was silently disabled. - detect leftover Hindsight entries from the parsed document (smol-toml), with a textual fallback when the file is already broken - strip unmarked [mcp_servers.hindsight] and our [[hooks.*]] entries textually, keeping the user's comments and formatting - validate the composed config parses before writing; refuse otherwise - strip every marked block, not just the first - smol-toml is inlined into the bundle like jsonc-parser
91 lines
4.6 KiB
TypeScript
91 lines
4.6 KiB
TypeScript
import { defineConfig } from "tsup";
|
|
|
|
export default defineConfig({
|
|
entry: {
|
|
index: "src/index.ts",
|
|
// opencode v2 (`opencode2`) loads this via the package's root index.js, which re-exports it.
|
|
// Its plugin contract shares nothing with v1's, so it is a separate entry — see src/opencode2.ts.
|
|
opencode2: "src/opencode2.ts",
|
|
// Kilo CLI (an opencode fork) loads this as its persistent plugin — see src/kilo.ts.
|
|
kilo: "src/kilo.ts",
|
|
deepen: "src/deepen.ts",
|
|
installer: "src/installer.ts",
|
|
status: "src/status.ts",
|
|
"claude-hook": "src/claude-hook.ts",
|
|
"claude-stop-hook": "src/claude-stop-hook.ts",
|
|
"claude-sessionstart-hook": "src/claude-sessionstart-hook.ts",
|
|
"cursor-hook": "src/cursor-hook.ts",
|
|
"cursor-sessionstart-hook": "src/cursor-sessionstart-hook.ts",
|
|
"cursor-stop-hook": "src/cursor-stop-hook.ts",
|
|
"copilot-hook": "src/copilot-hook.ts",
|
|
"copilot-sessionstart-hook": "src/copilot-sessionstart-hook.ts",
|
|
"copilot-stop-hook": "src/copilot-stop-hook.ts",
|
|
// Cline CLI loads this module through `cline plugin install`; file hooks cannot mutate
|
|
// model requests, so the native beforeModel hook is the reliable injection path.
|
|
cline: "src/cline.ts",
|
|
// DeepSeek Harness loads this as a native Cordis plugin — see src/dsh.ts.
|
|
dsh: "src/dsh.ts",
|
|
// pi and its fork Prime Agent each load their own module as an extension (default export) by
|
|
// absolute path from their settings.json `extensions` array, so both must be self-contained
|
|
// like the hook bins. They share src/harness/pi-extension.ts, which `splitting: false` inlines
|
|
// into each bundle rather than a shared chunk.
|
|
pi: "src/pi.ts",
|
|
"prime-agent": "src/prime-agent.ts",
|
|
"qwen-hook": "src/qwen-hook.ts",
|
|
"qwen-sessionstart-hook": "src/qwen-sessionstart-hook.ts",
|
|
"qwen-stop-hook": "src/qwen-stop-hook.ts",
|
|
"grok-hook": "src/grok-hook.ts",
|
|
"grok-sessionstart-hook": "src/grok-sessionstart-hook.ts",
|
|
"grok-stop-hook": "src/grok-stop-hook.ts",
|
|
"codex-hook": "src/codex-hook.ts",
|
|
"codex-sessionstart-hook": "src/codex-sessionstart-hook.ts",
|
|
"codex-stop-hook": "src/codex-stop-hook.ts",
|
|
"dcode-hook": "src/dcode-hook.ts",
|
|
"dcode-sessionstart-hook": "src/dcode-sessionstart-hook.ts",
|
|
"dcode-stop-hook": "src/dcode-stop-hook.ts",
|
|
"antigravity-hook": "src/antigravity-hook.ts",
|
|
"antigravity-stop-hook": "src/antigravity-stop-hook.ts",
|
|
"antigravity-statusline": "src/antigravity-statusline.ts",
|
|
"devin-hook": "src/devin-hook.ts",
|
|
"devin-sessionstart-hook": "src/devin-sessionstart-hook.ts",
|
|
"devin-stop-hook": "src/devin-stop-hook.ts",
|
|
"zcode-hook": "src/zcode-hook.ts",
|
|
"zcode-sessionstart-hook": "src/zcode-sessionstart-hook.ts",
|
|
"zcode-stop-hook": "src/zcode-stop-hook.ts",
|
|
"droid-hook": "src/droid-hook.ts",
|
|
"droid-sessionstart-hook": "src/droid-sessionstart-hook.ts",
|
|
"droid-stop-hook": "src/droid-stop-hook.ts",
|
|
// Spawned DETACHED to start the local daemon — a cold start outlives every hook timeout.
|
|
"daemon-start": "src/daemon-start.ts",
|
|
"mcp-server": "src/mcp-server.ts",
|
|
"hindsight-seed": "src/hindsight-seed.ts",
|
|
},
|
|
format: ["esm"],
|
|
target: "node18",
|
|
clean: true,
|
|
dts: { entry: "src/index.ts" },
|
|
shims: false,
|
|
// Each bin entry (claude-hook.js, cursor-hook.js, codex-hook.js, deepen.js, status.js, mcp-server.js,
|
|
// hindsight-seed.js) must be a single self-contained file: hosts wire a hook by absolute path to
|
|
// ONE dist file and never load the rest of the package, so shared code can't live in a separate
|
|
// chunk-*.js.
|
|
splitting: false,
|
|
// mcp-server.js additionally needs its npm deps (the MCP SDK + zod) inlined, since the wrapper
|
|
// only copies the single bundle file, not node_modules. The regexes catch subpath imports too
|
|
// (e.g. "@modelcontextprotocol/sdk/server/mcp.js", "zod/v4/...").
|
|
// hindsight-all (the local-daemon lifecycle manager) is inlined for the same reason: hooks are
|
|
// wired by absolute path to ONE dist file and never load the package's node_modules. It has zero
|
|
// dependencies of its own, so inlining costs almost nothing.
|
|
// jsonc-parser likewise: installer.js is staged to ~/.hindsight/coding-agents as dist + skill +
|
|
// package.json — never node_modules — so an external import there is unresolvable, and re-running
|
|
// `install` from the staged copy (the upgrade path) dies with ERR_MODULE_NOT_FOUND.
|
|
noExternal: [
|
|
/^@modelcontextprotocol\/sdk/,
|
|
/^zod/,
|
|
/^@vectorize-io\/hindsight-all/,
|
|
/^jsonc-parser/,
|
|
// smol-toml likewise: installer.js parses ~/.grok/config.toml with it.
|
|
/^smol-toml/,
|
|
],
|
|
});
|