Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
211 lines (204 loc) · 7.47 KB
/
Copy pathvite.config.ts
File metadata and controls
211 lines (204 loc) · 7.47 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
import { recommended } from "@effect/tsgo/oxlint-presets";
import { fileURLToPath } from "node:url";
import { defineConfig } from "vite-plus";
import type { DummyRuleMap } from "vite-plus/lint";
import { configDefaults } from "vite-plus/test/config";
const ignoredPaths = [
"dist/**",
"**/dist/**",
"node_modules/**",
"**/node_modules/**",
".pnpm-store/**",
".zed/**",
".vercel/**",
"**/.vercel/**",
// Generated by @tanstack/router-plugin; regenerated on dev/build.
"**/routeTree.gen.ts",
// Paused: kept in the tree, outside the workspace.
"packages/tui/**",
];
const aliases = [
// `@codeworksh/plugin` is the published plugin SDK; in this repo it resolves to source,
// so a change to the contract is visible to the harness and the example plugins at once.
{
find: /^@codeworksh\/plugin$/,
replacement: fileURLToPath(new URL("./packages/plugin/src/index.ts", import.meta.url)),
},
{
find: /^@codeworksh\/plugin\/(.*)$/,
replacement: fileURLToPath(new URL("./packages/plugin/src/$1.ts", import.meta.url)),
},
{
find: "@codeworksh/harness/effect",
replacement: fileURLToPath(new URL("./packages/harness/src/effect.ts", import.meta.url)),
},
{
find: "@codeworksh/harness/sandbox",
replacement: fileURLToPath(new URL("./packages/harness/src/sandbox.ts", import.meta.url)),
},
{
find: "@codeworksh/aikit/failure",
replacement: fileURLToPath(new URL("./packages/aikit/src/llm/failure.ts", import.meta.url)),
},
{
find: "@codeworksh/aikit/modelgen",
replacement: fileURLToPath(new URL("./packages/aikit/src/modelgen.ts", import.meta.url)),
},
{
find: /^@codeworksh\/aikit\/(oauth\/.+)$/,
replacement: fileURLToPath(new URL("./packages/aikit/src/$1.ts", import.meta.url)),
},
{ find: "@codeworksh/aikit", replacement: fileURLToPath(new URL("./packages/aikit/src/index.ts", import.meta.url)) },
{
find: "@codeworksh/harness",
replacement: fileURLToPath(new URL("./packages/harness/src/index.ts", import.meta.url)),
},
];
// Packages written against Effect. Kept as a list so lint overrides and the
// Effect rule set stay in one place as more Effect packages land.
const effectPackages = ["packages/harness/src/**/*.ts", "packages/plugin/src/**/*.ts", "packages/codework/src/**/*.ts"];
const effectRules = {
...recommended.rules,
// These packages have explicit Node host/provider boundaries; their Effect
// language-service policy permits these imports for the same reason.
"effecttsgo/node-builtin-import": "off",
// These APIs intentionally return fresh streams/layers or perform setup when
// called. Treating every zero-argument constructor as redundant is incorrect.
"effecttsgo/lazy-effect": "off",
} as const;
const reactCompilerRules: DummyRuleMap = {
"react/globals": "error",
"react/hooks": "error",
"react/immutability": "error",
"react/memo-dependencies": "error",
"react/preserve-manual-memoization": "error",
"react/purity": "error",
"react/refs": "error",
"react/set-state-in-render": "error",
"react/static-components": "error",
"react/unsupported-syntax": "error",
// Not compiler bailouts; effects stay as they are until they are reviewed on their own.
"react/set-state-in-effect": "off",
"react-hooks/exhaustive-deps": "off",
};
// Tailwind rules for the web app, from @shadcn/lint and eslint-plugin-better-tailwindcss. shadcn's
// components/ui stays as the generator wrote it. The checked rules are clean and gate `vp check`;
// `vp run lint:tailwind` adds the rest until each is clean enough to join them.
const tailwindChecked: DummyRuleMap = {
"shadcn/no-unknown-classes": "error",
"shadcn/no-raw-colors": "error",
};
const tailwindOptional: DummyRuleMap = {
"shadcn/require-static-classes": "error",
"shadcn/no-arbitrary-values": [
"error",
{
allow: [
"layout",
"transition",
// One-off effects with no place on a scale: frame and menu shadows, the drop target's glow,
// the queue strip's fade, a monogram's tint, and inline code sized to its text.
"shadow-[0_12px_32px_-12px_var(--cw-shadow-far)]",
"shadow-[0_16px_40px_-18px_rgb(0_0_0/0.55)]",
"bg-[radial-gradient(ellipse_at_center,var(--cw-drop-shadow),transparent_70%)]",
"mask-[linear-gradient(to_bottom,transparent,black_6px,black_calc(100%-10px),transparent)]",
"bg-[color-mix(in_oklab,currentColor_14%,transparent)]",
"text-[0.9em]",
],
},
],
"shadcn/no-restyle": ["error", { allow: ["layout"] }],
// One class at a time, as the editor's Tailwind hints are.
"better-tailwindcss/enforce-canonical-classes": ["error", { collapse: false, logical: false }],
};
export default defineConfig({
resolve: {
alias: aliases,
},
run: {
tasks: {
// Uncached tasks see the whole environment, which these need (npm OIDC in CI, git signing).
bump: { command: "node scripts/bump.mjs", cache: false },
release: { command: "node scripts/release.mjs", cache: false },
// CI's check gate. Type-aware lint, like each package's typecheck, resolves aikit through
// its generated declarations, so they are built first.
// Dead files and dependencies everywhere, dead exports in the workspaces kept clean so far.
// Both read the same files and write nothing, so they run side by side.
"knip:check:all": {
command: 'node -e ""',
dependsOn: ["knip:check:files", "knip:check:exports"],
cache: false,
},
"lint:tailwind": { command: "CODEWORK_LINT_TAILWIND=1 vp lint apps/web/src", cache: false },
verify: {
command: [
"vp check packages scripts .github infra",
"vp run --filter './packages/*' --concurrency-limit 2 typecheck",
"vp run knip:check",
],
dependsOn: ["@codeworksh/aikit#build"],
cache: false,
},
},
},
test: {
include: ["packages/**/*.test.ts"],
exclude:
process.env.CODEWORK_SANDBOX_E2E_REQUIRED === "1"
? configDefaults.exclude
: [...configDefaults.exclude, "packages/**/*.e2e.test.ts"],
},
lint: {
// Effect rules from @effect/tsgo, scoped to the Effect codebases here -- aikit
// is plain TypeScript and would drown in false positives. Overrides cannot
// `extends`, so the preset's plugins/rules are spread in directly. These need Oxlint's
// type-aware mode, which the patched oxlint-tsgolint binary provides (`prepare`).
jsPlugins: ["@shadcn/lint", { name: "better-tailwindcss", specifier: "eslint-plugin-better-tailwindcss" }],
settings: {
"better-tailwindcss": { entryPoint: "src/style.css", cwd: "apps/web" },
},
overrides: [
{
files: effectPackages,
...(recommended.plugins && { plugins: recommended.plugins }),
rules: effectRules,
},
{
// The React Compiler memoizes apps/web; these are the rules its bailouts map to.
files: ["apps/web/src/**/*.{ts,tsx}"],
excludeFiles: ["apps/web/src/components/ui/**"],
plugins: ["react"],
rules: reactCompilerRules,
},
{
files: ["apps/web/src/**/*.tsx"],
excludeFiles: ["apps/web/src/components/ui/**"],
rules: {
...tailwindChecked,
...(process.env.CODEWORK_LINT_TAILWIND === "1" ? tailwindOptional : {}),
},
},
],
ignorePatterns: ignoredPaths,
options: {
typeAware: true,
typeCheck: true,
},
},
fmt: {
// A file snapshot is the exact bytes a test wrote, and the bundled model catalog the exact
// bytes `aikit modelgen --baseline` wrote; reformatting either would make it drift. Agent
// skills and tool config stay as installed.
ignorePatterns: [
...ignoredPaths,
"**/__artifacts__/**",
"packages/aikit/src/model/baseline.json",
".agents/**",
".claude/**",
],
printWidth: 120,
useTabs: true,
tabWidth: 3,
sortPackageJson: true,
},
});