Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# Auto-format staged code with oxfmt before each commit, so the CI `format` job
# (`oxfmt --check .`) can never fail on a commit that originated here. Activated
# by `git config core.hooksPath .githooks`, which `bun run bootstrap` sets for
# every fresh checkout / agent worktree.
#
# Behaviour: formats the staged JS/TS/JSON files in place and re-stages them.
# oxfmt honours `.oxfmtrc.json` `ignorePatterns` even for explicitly-passed
# paths, so generated/vendored files (bun.lock, routeTree.gen.ts, ...) are
# skipped automatically.
#
# NUL-delimited end to end (handles spaces/newlines in paths) and compatible
# with the bash 3.2 that ships on macOS, so no `mapfile`. A shell variable
# cannot hold NUL bytes, so the staged list is read into an array directly.
#
# Caveat: a file that is only partially staged (staged hunk + a separate
# unstaged hunk in the same file) gets fully re-staged after formatting. Agent
# flows stage whole files (`git add -A`), so this is not a concern in practice.

set -euo pipefail

cd "$(git rev-parse --show-toplevel)"

oxfmt="node_modules/.bin/oxfmt"
if [[ ! -x "$oxfmt" ]]; then
echo "pre-commit: oxfmt not found ($oxfmt) - run 'bun run bootstrap'; skipping format." >&2
exit 0
fi

# Staged Added/Copied/Modified/Renamed files, restricted to extensions oxfmt
# formats. Read NUL records into an array (no NUL-in-variable bug).
files=()
while IFS= read -r -d '' f; do
case "$f" in
*.ts | *.tsx | *.mts | *.cts | *.js | *.jsx | *.mjs | *.cjs | *.json | *.jsonc)
files+=("$f")
;;
esac
done < <(git diff --cached --name-only --diff-filter=ACMR -z)

((${#files[@]})) || exit 0

# Format in place, then re-stage whatever oxfmt may have rewritten.
# --no-error-on-unmatched-pattern keeps the hook from failing when every staged
# file is ignored by .oxfmtrc.json.
"$oxfmt" --write --no-error-on-unmatched-pattern "${files[@]}"
git add -- "${files[@]}"
4 changes: 2 additions & 2 deletions packages/core/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
".": "./src/index.ts"
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
".": "./src/index.ts"
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/execution/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"./promise": "./src/promise.ts"
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
Expand All @@ -33,8 +34,7 @@
"default": "./dist/core.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/integrations-registry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
".": "./src/index.ts"
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"./public-origin": "./src/public-origin.ts"
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
Expand Down Expand Up @@ -83,8 +84,7 @@
"default": "./dist/public-origin.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/vite-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
}
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/kernel/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
".": "./src/index.ts"
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/kernel/runtime-quickjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
".": "./src/index.ts"
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/desktop-settings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"./client": "./src/client.tsx"
},
"publishConfig": {
"access": "public",
"exports": {
"./server": {
"import": {
Expand All @@ -33,8 +34,7 @@
"default": "./dist/client.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"./shared": "./src/shared.ts"
},
"publishConfig": {
"access": "public",
"exports": {
"./server": {
"import": {
Expand All @@ -40,8 +41,7 @@
"default": "./dist/shared.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/file-secrets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"./promise": "./src/promise.ts"
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
Expand All @@ -33,8 +34,7 @@
"default": "./dist/core.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/google/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"./client": "./src/react/plugin-client.tsx"
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
Expand All @@ -42,8 +43,7 @@
"default": "./dist/client.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"./testing": "./src/testing/index.ts"
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
Expand All @@ -50,8 +51,7 @@
"default": "./dist/testing.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/keychain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"./promise": "./src/promise.ts"
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
Expand All @@ -33,8 +34,7 @@
"default": "./dist/core.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/mcp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"./testing": "./src/testing/index.ts"
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
Expand All @@ -50,8 +51,7 @@
"default": "./dist/testing.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/microsoft/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"./client": "./src/react/plugin-client.tsx"
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
Expand All @@ -42,8 +43,7 @@
"default": "./dist/client.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/onepassword/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"./client": "./src/react/plugin-client.tsx"
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
Expand All @@ -42,8 +43,7 @@
"default": "./dist/client.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"./testing": "./src/testing/index.ts"
},
"publishConfig": {
"access": "public",
"exports": {
".": {
"import": {
Expand All @@ -50,8 +51,7 @@
"default": "./dist/testing.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/toolkits/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"./shared": "./src/shared.ts"
},
"publishConfig": {
"access": "public",
"exports": {
"./server": {
"import": {
Expand All @@ -40,8 +41,7 @@
"default": "./dist/shared.js"
}
}
},
"access": "public"
}
},
"scripts": {
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
Expand Down
Loading
Loading