Skip to content

Commit 4f4cbae

Browse files
committed
more streamlined
1 parent aef576a commit 4f4cbae

2 files changed

Lines changed: 6 additions & 59 deletions

File tree

scripts/suggest-optimize.sh

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -111,53 +111,8 @@ if [ -f "$SEEN_MARKER" ] && grep -qF "$COMMIT_HASH" "$SEEN_MARKER" 2>/dev/null;
111111
fi
112112
echo "$COMMIT_HASH" >> "$SEEN_MARKER"
113113

114-
# Walk from $PWD upward to $REPO_ROOT looking for project config.
115-
# Sets: PROJECT_TYPE, PROJECT_DIR, PROJECT_CONFIG_PATH, PROJECT_CONFIGURED
116-
detect_project() {
117-
PROJECT_TYPE=""
118-
PROJECT_DIR=""
119-
PROJECT_CONFIG_PATH=""
120-
PROJECT_CONFIGURED="false"
121-
local search_dir="$PWD"
122-
while true; do
123-
if [ -f "$search_dir/pyproject.toml" ]; then
124-
PROJECT_TYPE="python"
125-
PROJECT_DIR="$search_dir"
126-
PROJECT_CONFIG_PATH="$search_dir/pyproject.toml"
127-
if grep -q '\[tool\.codeflash\]' "$search_dir/pyproject.toml" 2>/dev/null; then
128-
PROJECT_CONFIGURED="true"
129-
fi
130-
break
131-
fi
132-
if [ -f "$search_dir/package.json" ]; then
133-
PROJECT_TYPE="js"
134-
PROJECT_DIR="$search_dir"
135-
PROJECT_CONFIG_PATH="$search_dir/package.json"
136-
if jq -e '.codeflash' "$search_dir/package.json" >/dev/null 2>&1; then
137-
PROJECT_CONFIGURED="true"
138-
fi
139-
break
140-
fi
141-
if [ "$search_dir" = "$REPO_ROOT" ]; then
142-
break
143-
fi
144-
local parent
145-
parent="$(dirname "$search_dir")"
146-
if [ "$parent" = "$search_dir" ]; then
147-
break
148-
fi
149-
case "$parent" in
150-
"$REPO_ROOT"|"$REPO_ROOT"/*) search_dir="$parent" ;;
151-
*) break ;;
152-
esac
153-
done
154-
}
155-
156-
# Discover project config
157-
detect_project
158-
159114
# --- JS/TS project path ---------------------------------------------------
160-
if [ "$PROJECT_TYPE" = "js" ] && [ "$HAS_JS_CHANGES" = "true" ]; then
115+
if [ "$HAS_JS_CHANGES" = "true" ]; then
161116
MESSAGE="JS/TS files were changed in a recent commit. Use the codeflash:optimize skill WITHOUT ANY ARGUMENTS to to optimize the JavaScript/TypeScript code for performance. Use npx to execute codeflash"
162117
jq -nc --arg reason "$MESSAGE" '{"decision": "block", "reason": $reason, "systemMessage": $reason}'
163118
exit 0

skills/setup/SKILL.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ npx codeflash --version
2828
If this fails, codeflash is not installed. Detect the project's package manager and install accordingly:
2929

3030
- If a `uv.lock` file exists or `pyproject.toml` uses `[tool.uv]`: run `uv add --dev codeflash`
31-
- Otherwise: run `pip install codeflash`
31+
- Otherwise: run `pip install codeflash` or `uv pip install codeflash` if there is a uv.lock file present in the directory.
3232
- For js/ts code, run `npm install --dev codeflash`
3333

3434
**Never** use `uv tool install` to install codeflash.
@@ -48,14 +48,10 @@ If this fails, the user is not authenticated. Run `codeflash auth login` for pyt
4848

4949
### Check 3a: Project Configuration (Python)
5050

51-
```bash
52-
grep -rq '\[tool\.codeflash\]' $(git rev-parse --show-toplevel)/pyproject.toml 2>/dev/null
53-
```
54-
55-
If this fails, the project configuration is missing. Walk upward from the current working directory to the git repository root, looking for a `pyproject.toml`.
51+
Find the `pyproject.toml` file closest to the file/files of concern (the file passed to codeflash --file or the files which changed in the diff). Confirm that a `[tool.codeflash]` section exists in the pyproject file found.
5652

57-
- If a `pyproject.toml` exists but lacks `[tool.codeflash]`, run **Configuration Discovery (Python)** below and append the section.
58-
- If no `pyproject.toml` exists, run **Configuration Discovery (Python)** and create one at the git repository root.
53+
- If the `pyproject.toml` file exists but lacks `[tool.codeflash]`, run **Configuration Discovery (Python)** below and append the section.
54+
- If no `pyproject.toml` exists, run **Configuration Discovery (Python)** below and create one.
5955

6056
#### Configuration Discovery (Python)
6157

@@ -86,11 +82,7 @@ After writing, confirm the configuration with the user before proceeding.
8682

8783
### Check 3b: Project Configuration (Javascript/Typescript)
8884

89-
```bash
90-
grep -rq 'codeflash' $(git rev-parse --show-toplevel)/package.json 2>/dev/null
91-
```
92-
93-
If this fails, the project configuration is missing. Walk upward from the current working directory to the git repository root, looking for a `package.json`.
85+
Find the `package.json` file closest to the file/files of concern (the file passed to codeflash --file or the files which changed in the diff). Confirm that a `codeflash` key exists in the package.json file found.
9486

9587
- If a `package.json` exists but lacks the `codeflash` key, run **Configuration Discovery (Javascript/Typescript)** below and append the section.
9688
- If no `package.json` exists, run **Configuration Discovery (Javascript/Typescript)** and create one at the git repository root.

0 commit comments

Comments
 (0)