Skip to content
Open
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
15 changes: 11 additions & 4 deletions plugin_repackaging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ repackage(){
echo "⚠ Warning: No pyproject.toml or requirements.txt found"
fi

update_requirements_for_offline() {
local REQFILE="$1"
[ -f "$REQFILE" ] || return 0
awk '
BEGIN { print "--no-index --find-links=./wheels/" }
$0 !~ /^--no-index[[:space:]]+--find-links=\.\/wheels\/?$/ { print }
' "$REQFILE" > "$REQFILE.tmp" && mv "$REQFILE.tmp" "$REQFILE"
Comment on lines +157 to +160
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Dedup logic misses common --find-links forms, so offline flags can accumulate.

The awk filter only removes one exact combined line. Existing lines like --find-links=./wheels, --find-links ./wheels, or separate --no-index remain, so repeated runs can keep stale/duplicate resolver flags.

Suggested fix
 	awk '
-		BEGIN { print "--no-index --find-links=./wheels/" }
-		$0 !~ /^--no-index[[:space:]]+--find-links=\.\/wheels\/?$/ { print }
+		BEGIN { print "--no-index --find-links=./wheels/" }
+		# Drop any existing no-index / find-links directives so output is canonical and idempotent.
+		$0 ~ /^[[:space:]]*--no-index([[:space:]]|$)/ { next }
+		$0 ~ /^[[:space:]]*--find-links([=[:space:]]|$)/ { next }
+		{ print }
 	' "$REQFILE" > "$REQFILE.tmp" && mv "$REQFILE.tmp" "$REQFILE"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugin_repackaging.sh` around lines 157 - 160, The current awk snippet in
plugin_repackaging.sh that rewrites "$REQFILE" only removes one exact combined
flag and misses other forms; update the filter to remove any lines that are
standalone "--no-index", any "--find-links" using "=" or space, with or without
"./" and trailing slashes (e.g. "--find-links=./wheels", "--find-links
./wheels", "--find-links=../wheels/"), and also remove the case where
"--no-index" and "--find-links" are on separate lines; then prepend the
canonical combined line "--no-index --find-links=./wheels/" at the top as before
and write back to "$REQFILE" (use patterns like /^--no-index($|[[:space:]])/ and
/^--find-links([=[:space:]]).*(\/?wheels\/?)$/ to identify and drop all
variants).

}

# Inject [tool.uv] config into pyproject.toml (runtime will use local wheels offline)
inject_uv_into_pyproject() {
local PYFILE="$1"
Expand Down Expand Up @@ -349,13 +358,11 @@ PY
# ============================================
echo ""
echo "Updating requirements.txt for offline installation..."
update_requirements_for_offline requirements.txt
[ -f ".difyignore" ] && IGNORE_PATH=.difyignore || IGNORE_PATH=.gitignore
if [[ "linux" == "$OS_TYPE" ]]; then
sed -i '1i\--no-index --find-links=./wheels/' requirements.txt
[ -f ".difyignore" ] && IGNORE_PATH=.difyignore || IGNORE_PATH=.gitignore
[ -f "$IGNORE_PATH" ] && sed -i '/^wheels\//d' "${IGNORE_PATH}"
elif [[ "darwin" == "$OS_TYPE" ]]; then
sed -i ".bak" '1i\--no-index --find-links=./wheels/' requirements.txt && rm -f requirements.txt.bak
[ -f ".difyignore" ] && IGNORE_PATH=.difyignore || IGNORE_PATH=.gitignore
[ -f "$IGNORE_PATH" ] && sed -i ".bak" '/^wheels\//d' "${IGNORE_PATH}" && rm -f "${IGNORE_PATH}.bak"
fi
echo "✓ requirements.txt updated for offline mode"
Expand Down