forked from intel/AI-Playground
-
Notifications
You must be signed in to change notification settings - Fork 3
V3.1.2 beta.rc4 #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
leslielazzarino
wants to merge
8
commits into
dev
Choose a base branch
from
v3.1.2-beta.rc4
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
V3.1.2 beta.rc4 #253
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dfa842f
Add pre-commit hooks, to enforce formatting and linting
leslielazzarino 72dec86
Scale down input pictures also in home agent
leslielazzarino cdcdda1
Fix OpenVINO version display and change
leslielazzarino ae3b844
feat: ovms int4 kv cache
mschuettlerTNG 7d3a449
OpenVINO update, some minor fixes/tuning
leslielazzarino 900dd9c
Pre-commit hooks: do not fail when formatting
leslielazzarino 976dce2
Display reasoning as in progress when not finished
leslielazzarino 771c8b3
Make BE folders writable on Linux if failing removal when updating
leslielazzarino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Pre-commit hooks: formatter + linter for the TS frontend and Python backends. | ||
| # Install once with: pre-commit install | ||
| # Run on all files : pre-commit run --all-files | ||
| # | ||
| # Python (service/, home-agent/) is handled by Ruff (matches the Ruff CI check). | ||
| # WebUI is handled by ESLint + Prettier via the existing npm scripts (matches the | ||
| # "Lint TS" CI check). ESLint resolves its flat config from WebUI/, not the repo | ||
| # root, so the eslint hook runs against the whole WebUI workspace. | ||
| # | ||
| # Formatters (ruff-format, prettier) reformat in place and then `git add` what they | ||
| # changed, so they never abort the commit just because formatting was applied — the | ||
| # reformatted files are restaged and included in the same commit. The linters still | ||
| # fail on genuine, unfixable problems. | ||
| repos: | ||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.15.20 | ||
| hooks: | ||
| # Linter (auto-fix what it safely can) | ||
| - id: ruff | ||
| name: ruff lint (Python) | ||
| args: [--fix] | ||
| files: ^(service|home-agent)/.*\.py$ | ||
|
|
||
| - repo: local | ||
| hooks: | ||
| # Formatter (Ruff) — format in place, restage, never fail on reformat | ||
| - id: ruff-format | ||
| name: ruff format (Python) | ||
| language: system | ||
| entry: bash -c 'uvx ruff@0.15.20 format "$@" && git add -- "$@"' -- | ||
| files: ^(service|home-agent)/.*\.py$ | ||
| # Linter (ESLint with auto-fix) | ||
| - id: eslint | ||
| name: eslint (WebUI) | ||
| language: system | ||
| entry: bash -c 'cd WebUI && npm run lint:eslint' | ||
| files: ^WebUI/.*\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|vue)$ | ||
| pass_filenames: false | ||
| # Formatter (Prettier) — format in place, restage, never fail on reformat | ||
| - id: prettier | ||
| name: prettier (WebUI) | ||
| language: system | ||
| entry: bash -c 'cd WebUI && files=(); for f in "$@"; do files+=("${f#WebUI/}"); done && npx prettier --write "${files[@]}" && cd .. && git add -- "$@"' -- | ||
| files: ^WebUI/.*\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|vue|json|css|scss|html|md|ya?ml)$ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| #!/usr/bin/env node | ||
| /** | ||
| * ensure-precommit-hook.mjs | ||
| * | ||
| * Install the git pre-commit hook defined by <repo-root>/.pre-commit-config.yaml | ||
| * (Ruff for the Python backends, ESLint + Prettier for the WebUI). Run as part of | ||
| * `npm run setup` so a fresh clone is ready to commit without a manual step. | ||
| * | ||
| * Best effort and idempotent: | ||
| * - No-op if this is not a git checkout (e.g. a source tarball). | ||
| * - No-op if the hook is already installed. | ||
| * - Uses `pre-commit` from PATH, else falls back to `uvx pre-commit` | ||
| * (uv ships with this repo's toolchain). If neither is available it prints | ||
| * how to install it and exits 0 — never blocks setup. | ||
| */ | ||
| import { spawnSync } from 'node:child_process' | ||
| import { existsSync, readFileSync } from 'node:fs' | ||
| import path from 'node:path' | ||
| import { fileURLToPath } from 'node:url' | ||
|
|
||
| const webuiDir = path.resolve(fileURLToPath(new URL('../../', import.meta.url))) | ||
| const repoRoot = path.resolve(webuiDir, '..') | ||
|
|
||
| function log(msg) { | ||
| console.log(`[ensure-precommit-hook] ${msg}`) | ||
| } | ||
|
|
||
| // Resolve a path relative to the git dir (handles worktrees and `.git` files). | ||
| function gitPath(relative) { | ||
| const res = spawnSync('git', ['rev-parse', '--git-path', relative], { | ||
| cwd: repoRoot, | ||
| encoding: 'utf-8', | ||
| }) | ||
| if (res.status !== 0) return undefined | ||
| const out = res.stdout.trim() | ||
| return path.isAbsolute(out) ? out : path.join(repoRoot, out) | ||
| } | ||
|
|
||
| // Skip cleanly when this is not a git working tree. | ||
| if ( | ||
| spawnSync('git', ['rev-parse', '--is-inside-work-tree'], { cwd: repoRoot, stdio: 'ignore' }) | ||
| .status !== 0 | ||
| ) { | ||
| log('Not a git checkout — skipping pre-commit hook install.') | ||
| process.exit(0) | ||
| } | ||
|
|
||
| const configPath = path.join(repoRoot, '.pre-commit-config.yaml') | ||
| if (!existsSync(configPath)) { | ||
| log(`No .pre-commit-config.yaml at ${configPath} — skipping.`) | ||
| process.exit(0) | ||
| } | ||
|
|
||
| // Already installed? The shim pre-commit writes carries a recognizable marker. | ||
| const hookPath = gitPath('hooks/pre-commit') | ||
| if (hookPath && existsSync(hookPath)) { | ||
| try { | ||
| if (readFileSync(hookPath, 'utf-8').includes('File generated by pre-commit')) { | ||
| log('pre-commit hook already installed — nothing to do.') | ||
| process.exit(0) | ||
| } | ||
| } catch { | ||
| /* fall through and (re)install */ | ||
| } | ||
| } | ||
|
|
||
| function commandAvailable(cmd, args = ['--version']) { | ||
| return spawnSync(cmd, args, { stdio: 'ignore' }).status === 0 | ||
| } | ||
|
|
||
| // Prefer a `pre-commit` on PATH; otherwise run it through uv's `uvx`. | ||
| let runner | ||
| if (commandAvailable('pre-commit')) { | ||
| runner = ['pre-commit'] | ||
| } else if (commandAvailable('uvx')) { | ||
| runner = ['uvx', 'pre-commit'] | ||
| } else { | ||
| log('`pre-commit` is not installed and `uvx` is unavailable, so the hook was not installed.') | ||
| log('Install it once with either of:') | ||
| log(' uv tool install pre-commit') | ||
| log(' pipx install pre-commit') | ||
| log('then re-run `npm run setup` (or `pre-commit install`).') | ||
| process.exit(0) | ||
| } | ||
|
|
||
| log(`Installing git pre-commit hook with: ${runner.join(' ')} install`) | ||
| const res = spawnSync(runner[0], [...runner.slice(1), 'install'], { | ||
| cwd: repoRoot, | ||
| stdio: 'inherit', | ||
| }) | ||
| if (res.status !== 0) { | ||
| log('Could not install the pre-commit hook (continuing anyway).') | ||
| log('You can install it manually later with `pre-commit install`.') | ||
| process.exit(0) | ||
| } | ||
|
|
||
| log('pre-commit hook installed.') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: TNG/AI-Playground
Length of output: 214
🏁 Script executed:
Repository: TNG/AI-Playground
Length of output: 2216
🌐 Web query:
pre-commit modifying files hook failed restage git add official docs formatting hook abort commit💡 Result:
When a pre-commit hook modifies a file, the pre-commit framework intentionally fails the commit [1][2]. This design is deliberate to ensure that no changes are committed to your repository without being explicitly reviewed and staged by you [1][3]. If a hook modifies a file, it will cause the commit to abort [1][4]. To resolve this, you can follow these steps: 1. Inspect the changes made by the hook to ensure they are correct [1]. 2. Add the modified files to the staging area using git add or git add -u [1][3][4]. 3. Re-run your commit command [1][4]. Since the files are now in the index, the commit should proceed successfully [4][5]. The framework does not automatically stage these changes for you because it considers modifying the staging area an unsafe operation that could lead to unintended consequences, such as overwriting unstaged changes or committing broken code if a hook behaves unexpectedly [1][3][2]. If you find this workflow creates too much friction, you have a few options: - Manually stage the changes and re-run the commit [1][3]. - If you are confident in the hook, you can bypass the pre-commit checks using the --no-verify flag (e.g., git commit --no-verify -m "message"), though this is generally discouraged as it skips all configured hooks [4]. - If you prefer a different approach, you may consider other tools that integrate with git-commit differently, or accept that manual re-staging is the standard, safe behavior for the pre-commit framework [3][2].
Citations:
Formatter hooks still abort the first commit after rewriting files
Pre-commit still fails when
ruff-formatorprettierchanges tracked files;git addonly restages the output so the nextgit commitsucceeds. Update the comment to reflect that this is a re-run workflow, not a one-shot commit.🤖 Prompt for AI Agents