Skip to content
Open
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
35 changes: 35 additions & 0 deletions .env_example_gitcommit
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Git Commit Script Configuration

# Debug mode: true or false
DEBUG_MODE=false

# # MiniMax
# BASE_URL=https://api.minimaxi.com/v1
# API_KEY=your_api_key_here
# LLM_MODEL=MiniMax-M2.5

# # Zhipu AI
# BASE_URL=https://open.bigmodel.cn/api/paas/v4
# API_KEY=your_api_key_here
# LLM_MODEL=GLM-4.7-Flash


# siliconflow
# BASE_URL=https://api.siliconflow.cn/v1
# API_KEY=your_api_key_here
# LLM_MODEL=Qwen/Qwen2.5-Coder-32B-Instruct
# LLM_MODEL=Qwen/Qwen3-Coder-30B-A3B-Instruct
# LLM_MODEL=Qwen/Qwen3-30B-A3B-Instruct-2507

## openrouter
BASE_URL=https://openrouter.ai/api/v1
API_KEY=your_api_key_here
LLM_MODEL=minimax/minimax-m2.5:free
# LLM_MODEL=nvidia/nemotron-3-super-120b-a12b:free
# LLM_MODEL=arcee-ai/trinity-large-preview:free
# LLM_MODEL=z-ai/glm-4.5-air:free
# LLM_MODEL=nvidia/nemotron-3-nano-30b-a3b:free
# LLM_MODEL=minimax/minimax-m2.5:free
# LLM_MODEL=openai/gpt-oss-120b:free
# LLM_MODEL=openai/gpt-oss-20b:free
# LLM_MODEL=google/gemma-4-31b-it:free
66 changes: 66 additions & 0 deletions ___git_commit_push_llm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

# Cross-platform Git Commit and Push Script Router
# Auto-detects OS and delegates to the platform-specific implementation

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# ======================================= [全局 .env 文件支持]
# Load root-level .env first so platform scripts inherit via environment
ENV_FILE="$SCRIPT_DIR/.env"
if [ -f "$ENV_FILE" ]; then
while IFS= read -r line || [[ -n "$line" ]]; do
[[ "$line" =~ ^[[:space:]]*# ]] && continue
[[ -z "${line// /}" ]] && continue
if [[ "$line" =~ ^([A-Za-z_][A-Za-z0-9_]*)=(.*)$ ]]; then
key="${BASH_REMATCH[1]}"
value="${BASH_REMATCH[2]}"
value="${value%$'\r'}"
value="${value#\"}"; value="${value%\"}"
value="${value#\'}"; value="${value%\'}"
if ! eval "[ -n \"\${$key+x}\" ]"; then
export "$key=$value"
fi
fi
done < "$ENV_FILE"
fi

# ======================================= [平台检测与路由]
detect_os() {
case "$(uname -s)" in
Linux*|Darwin*) echo "linux" ;;
CYGWIN*|MINGW*|MSYS*) echo "windows" ;;
*) echo "unknown" ;;
esac
}

OS=$(detect_os)

if [ "$OS" = "linux" ]; then
TARGET="$SCRIPT_DIR/zbak_script/linux/commit/___git_commit_push_llm.sh"
if [ ! -f "$TARGET" ]; then
echo "Error: Linux script not found: $TARGET" >&2
exit 1
fi
exec bash "$TARGET"

elif [ "$OS" = "windows" ]; then
TARGET="$SCRIPT_DIR/zbak_script/win/commit/___git_commit_push_llm.ps1"
if [ ! -f "$TARGET" ]; then
echo "Error: Windows script not found: $TARGET" >&2
exit 1
fi
# Prefer pwsh (PowerShell 7+), fallback to powershell (Windows PowerShell)
if command -v pwsh &>/dev/null; then
exec pwsh -ExecutionPolicy Bypass -File "$TARGET"
elif command -v powershell &>/dev/null; then
exec powershell -ExecutionPolicy Bypass -File "$TARGET"
else
echo "Error: PowerShell (pwsh or powershell) not found." >&2
exit 1
fi

else
echo "Error: Unsupported OS '$(uname -s)'. Expected Linux, macOS, or Windows (Git Bash/MSYS)." >&2
exit 1
fi
141 changes: 141 additions & 0 deletions __cc-haha-op.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#!/usr/bin/env bash

REPO_ROOT="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd -P)"
cd "$REPO_ROOT"

# ── Configurable remotes ─────────────────────────────────────────────────────
UPSTREAM_REMOTE="${UPSTREAM_REMOTE:-upstream}"
ORIGIN_REMOTE="${ORIGIN_REMOTE:-origin}"

BUILD_SCRIPT="$REPO_ROOT/desktop/scripts/build-windows-x64.ps1"

# ── Colors ───────────────────────────────────────────────────────────────────
red() { echo -e "\033[31m$*\033[0m"; }
green() { echo -e "\033[32m$*\033[0m"; }
yellow() { echo -e "\033[33m$*\033[0m"; }
cyan() { echo -e "\033[36m$*\033[0m"; }

# ── Sync upstream ────────────────────────────────────────────────────────────
sync_upstream() {
# 1. Check upstream remote exists, auto-add if missing
if ! git remote get-url "$UPSTREAM_REMOTE" > /dev/null 2>&1; then
yellow "Remote '$UPSTREAM_REMOTE' not found. Adding..."
git remote add "$UPSTREAM_REMOTE" git@github.com:NanmiCoder/cc-haha.git
fi

# 2. Check origin remote exists
if ! git remote get-url "$ORIGIN_REMOTE" > /dev/null 2>&1; then
red "Error: remote '$ORIGIN_REMOTE' not found."
return 1
fi

# 3. Stash if worktree is dirty
local stashed=false
if [ -n "$(git status --porcelain 2>/dev/null)" ]; then
yellow "Worktree is dirty. Stashing changes..."
git stash push -m "auto: stash before sync $(date '+%Y-%m-%d %H:%M:%S')"
stashed=true
fi

# 4. Determine original branch
local original_branch
local current_branch
current_branch="$(git rev-parse --abbrev-ref HEAD)"
local all_branches
all_branches=$(git branch --list --format='%(refname:short)')

# If only on main with no other local branches, create a new branch
if [ "$current_branch" = "main" ] && [ -z "$(echo "$all_branches" | grep -v '^main$')" ]; then
local new_branch="feature/sync-$(date '+%Y%m%d')"
yellow "Only main branch found. Creating new branch: $new_branch"
git checkout -b "$new_branch"
git add -A
git commit -m "chore: initial commit on $new_branch"
original_branch="$new_branch"
else
original_branch="$current_branch"
fi

# 5. Checkout main, fetch upstream, merge
echo "[1/4] Fetching $UPSTREAM_REMOTE..."
git fetch "$UPSTREAM_REMOTE"

echo "[2/4] Checking out main and merging $UPSTREAM_REMOTE/main..."
git checkout main
git merge "$UPSTREAM_REMOTE/main" --no-edit

# 6. Push to origin
echo "[3/4] Pushing to $ORIGIN_REMOTE..."
git push "$ORIGIN_REMOTE" main

# 7. Checkout original branch and rebase onto main
echo "[4/4] Rebasing $original_branch onto main..."
git checkout "$original_branch"
if ! git rebase main; then
red "Rebase failed. Resolve conflicts, then run:"
echo " git rebase --continue"
echo " git stash pop (if you had stashed changes)"
return 1
fi

# 8. Pop stash if we stashed
if [ "$stashed" = true ]; then
echo "Restoring stashed changes..."
git stash pop
fi

green "Sync complete."
}

# ── Build exe ────────────────────────────────────────────────────────────────
build_exe() {
echo "[build-exe] 执行 PowerShell 构建脚本..."
if command -v pwsh > /dev/null 2>&1; then
pwsh -ExecutionPolicy Bypass -File "$BUILD_SCRIPT"
elif command -v powershell > /dev/null 2>&1; then
powershell -ExecutionPolicy Bypass -File "$BUILD_SCRIPT"
else
red "错误:未找到 pwsh 或 powershell"
return 1
fi
}

# ── Menu ─────────────────────────────────────────────────────────────────────
show_menu() {
clear
echo "========== cc-haha menu =========="
echo "1. sync-upstream (fetch → merge → push → rebase)"
echo "2. build-exe"
echo "0. exit"
echo "=================================="
}
# ── Main ─────────────────────────────────────────────────────────────────────
main() {
case "${1:-}" in
sync|1)
sync_upstream
;;
build|2)
build_exe
;;
*)
while true; do
show_menu
read -r -p "请选择: " choice || { echo ""; exit 0; }
case "$choice" in
1) sync_upstream ;;
2) build_exe ;;
0) echo "Bye."; exit 0 ;;
*) red "无效选项,请重新输入。" ;;
esac

if [ "$choice" != "0" ]; then
echo ""
read -r -p "按 Enter 继续..."
fi
done
;;
esac
}

main "$@"
4 changes: 3 additions & 1 deletion adapters/feishu/extract-payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export function extractInboundPayload(content: string, msgType: string): Inbound
}

if (msgType === 'post') {
const nodes = (parsed.zh_cn?.content ?? parsed.en_us?.content ?? []) as any[]
// Post content can either be multi-locale ({zh_cn:{content:[...]}, en_us:...})
// or single-locale ({title:"", content:[[...],...]}). Try both.
const nodes = (parsed.zh_cn?.content ?? parsed.en_us?.content ?? parsed.content ?? []) as any[]
const flat = nodes.flat()
const textParts: string[] = []
const downloads: PendingDownload[] = []
Expand Down
1 change: 1 addition & 0 deletions adapters/feishu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,7 @@ function stripMentions(text: string): string {
// ---------- event handlers ----------

async function handleMessage(data: any): Promise<void> {

const event = data as {
sender?: { sender_id?: { open_id?: string } }
message?: {
Expand Down
Loading
Loading