-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
71 lines (60 loc) · 1.79 KB
/
tsdown.config.ts
File metadata and controls
71 lines (60 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import Fs from "node:fs/promises";
import Path from "node:path";
import { defineConfig, type UserConfig } from "tsdown";
import { applyPatch } from "./src/patch.ts";
async function applyCommandPatches(): Promise<void> {
const commandsDir = Path.resolve(import.meta.dirname, "dist/commands");
const patchesDir = Path.resolve(import.meta.dirname, "src/command-patches");
let commandFiles: string[];
try {
commandFiles = await Fs.readdir(commandsDir);
} catch {
// dist/commands does not exist yet — nothing to patch
return;
}
for (const file of commandFiles) {
if (!file.endsWith(".md")) continue;
const patchPath = Path.join(patchesDir, file);
let patchContent: string;
try {
patchContent = await Fs.readFile(patchPath, "utf-8");
} catch {
// No patch for this command — leave it unchanged
continue;
}
const upstreamPath = Path.join(commandsDir, file);
const upstream = await Fs.readFile(upstreamPath, "utf-8");
let merged: string;
try {
merged = applyPatch(upstream, patchContent);
} catch (err) {
throw new Error(
`Failed to apply patch for ${file}: ${err instanceof Error ? err.message : String(err)}`,
);
}
await Fs.writeFile(upstreamPath, merged, "utf-8");
console.log(`[patch] Applied patch: dist/commands/${file}`);
}
}
const config: UserConfig = defineConfig({
root: "./src",
entry: ["./src/main.ts"],
copy: [
"./agent-skills/.claude/commands",
"./agent-skills/agents",
"./agent-skills/references",
"./agent-skills/skills",
"./src/prompt-patch.md",
],
dts: true,
deps: {
onlyBundle: ["yaml"],
alwaysBundle: ["yaml"],
},
publint: true,
attw: {
profile: "esm-only",
},
onSuccess: applyCommandPatches,
});
export default config;