Files
modelstudioai__cli/vite.config.ts
T
故璃 e46053b93e fix(tooling): stop interpolating filenames into staged check
Passing staged filenames per-file puts repository paths into the argv of
the vp check node process. When an endpoint security agent matches process
argv by substring, the whole process is SIGKILLed and pre-commit can never
finish. Use the function form so the command runs without filenames: one
whole-repo check, wider coverage than per-file, and independent of any path.
2026-07-29 17:54:54 +08:00

96 lines
3.4 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { defineConfig } from "vite-plus";
const commandCapabilityRestrictions = [
{
property: "configStore",
message: "configStore is only available to commands/config/**.",
},
{
property: "authStore",
message: "authStore is only available to commands/auth/**.",
},
{
property: "commandPacks",
message: "commandPacks is only available to commands/plugin/**.",
},
{
property: "exportApiCredential",
message:
"exportApiCredential is only available to commands/managed-agent/_engine/** (embedded-SDK credential delegation).",
},
] as const;
type CommandCapabilityRestriction = (typeof commandCapabilityRestrictions)[number];
type CommandCapability = CommandCapabilityRestriction["property"];
function restrictCommandCapabilities(
allowed?: CommandCapability,
): ["error", ...CommandCapabilityRestriction[]] {
return ["error", ...commandCapabilityRestrictions.filter(({ property }) => property !== allowed)];
}
export default defineConfig({
test: {
globalSetup: "./packages/e2e/src/global-setup.ts",
testTimeout: 60_000,
hookTimeout: 60_000,
},
staged: {
// 用函数形式返回命令:不把匹配到的文件名插值进 argv改为跑一次全量检查。
// 逐文件传参会让 `vp check` 的 node 进程 argv 携带仓库内的文件名,
// 命中终端安全软件按 argv 子串匹配的进程管控规则时整个进程被 SIGKILL,
// 导致 pre-commit 无法完成。全量检查覆盖面更广,也不依赖文件名。
"*.{js,mjs,cjs,ts,mts,cts,jsx,tsx,json,yaml,yml,md}": () => "vp check --fix",
},
lint: {
options: { typeAware: true, typeCheck: true },
// 命令只许抛错;进程退出统一收口到 runtime 的 handleError。
rules: { "unicorn/no-process-exit": "error" },
overrides: [
{
// runtime 是统一出口层tools/ 与测试是独立脚本入口,可直接退出。
files: ["packages/runtime/src/**", "tools/**", "**/tests/**"],
rules: { "unicorn/no-process-exit": "off" },
},
{
// finetune watch 的退出码是公开探针契约0 成功/1 失败/2 超时/3 运行中/130 中断),
// 非错误语义,不走 handleError。
files: ["packages/commands/src/commands/finetune/watch.ts"],
rules: { "unicorn/no-process-exit": "off" },
},
{
// 普通业务命令只依赖 settings/flags/client持久化和管理能力按命令族开放。
files: ["packages/commands/src/commands/**/*.ts"],
rules: { "no-restricted-properties": restrictCommandCapabilities() },
},
{
files: ["packages/commands/src/commands/config/**/*.ts"],
rules: {
"no-restricted-properties": restrictCommandCapabilities("configStore"),
},
},
{
files: ["packages/commands/src/commands/auth/**/*.ts"],
rules: {
"no-restricted-properties": restrictCommandCapabilities("authStore"),
},
},
{
files: ["packages/commands/src/commands/plugin/**/*.ts"],
rules: {
"no-restricted-properties": restrictCommandCapabilities("commandPacks"),
},
},
{
files: ["packages/commands/src/commands/managed-agent/_engine/**/*.ts"],
rules: {
"no-restricted-properties": restrictCommandCapabilities("exportApiCredential"),
},
},
],
},
run: {
cache: true,
},
});