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
45 changes: 34 additions & 11 deletions skills/6verity/scripts/writing_check.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#!/usr/bin/env bash
set -u

# Windows (python.org installer / Git Bash) usually only provides `python`,
# while Linux/macOS provide `python3`. Pick whichever exists.
PYTHON_BIN="$(command -v python3 || command -v python || true)"
if [ -z "$PYTHON_BIN" ]; then
echo "ERROR: python3 (or python) not found in PATH" >&2
exit 2
fi

usage() {
cat <<'EOF'
Usage:
Expand All @@ -27,6 +35,11 @@ the actual files it wants checked.
EOF
}

die_missing_value() {
echo "ERROR: $1 requires a value" >&2
exit 2
}

PAPER_DIR="${PAPER_DIR:-}"
ROOT_DIR="${ROOT_DIR:-}"
MAIN_FILE="${MAIN_FILE:-}"
Expand All @@ -43,43 +56,53 @@ POSITIONAL=()
while [ "$#" -gt 0 ]; do
case "$1" in
--paper-dir)
PAPER_DIR="${2:-}"
[ "$#" -ge 2 ] || die_missing_value "$1"
PAPER_DIR="$2"
shift 2
;;
--root-dir)
ROOT_DIR="${2:-}"
[ "$#" -ge 2 ] || die_missing_value "$1"
ROOT_DIR="$2"
shift 2
;;
--main)
MAIN_FILE="${2:-}"
[ "$#" -ge 2 ] || die_missing_value "$1"
MAIN_FILE="$2"
shift 2
;;
--sections-dir)
SECTIONS_DIR="${2:-}"
[ "$#" -ge 2 ] || die_missing_value "$1"
SECTIONS_DIR="$2"
shift 2
;;
--references)
REFERENCES_FILE="${2:-}"
[ "$#" -ge 2 ] || die_missing_value "$1"
REFERENCES_FILE="$2"
shift 2
;;
--figures-dir)
FIGURES_DIR="${2:-}"
[ "$#" -ge 2 ] || die_missing_value "$1"
FIGURES_DIR="$2"
shift 2
;;
--results-file)
RESULTS_FILE="${2:-}"
[ "$#" -ge 2 ] || die_missing_value "$1"
RESULTS_FILE="$2"
shift 2
;;
--problem-analysis)
PROBLEM_ANALYSIS_FILE="${2:-}"
[ "$#" -ge 2 ] || die_missing_value "$1"
PROBLEM_ANALYSIS_FILE="$2"
shift 2
;;
--all-results)
ALL_RESULTS_FILE="${2:-}"
[ "$#" -ge 2 ] || die_missing_value "$1"
ALL_RESULTS_FILE="$2"
shift 2
;;
--internal-term)
EXTRA_INTERNAL_TERMS+=("${2:-}")
[ "$#" -ge 2 ] || die_missing_value "$1"
EXTRA_INTERNAL_TERMS+=("$2")
shift 2
;;
--no-internal-check)
Expand Down Expand Up @@ -185,7 +208,7 @@ else
fi
export EXTRA_INTERNAL_TERMS_STR

python3 - <<'PY'
"$PYTHON_BIN" - <<'PY'
import json
import os
import re
Expand Down
20 changes: 16 additions & 4 deletions skills/doctor/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ allowed-tools: Bash(*), Read, Write
| --- | --- | --- |
| `typst` | 论文编译(5writing、6verity,Typst 引擎) | `command -v typst` |
| `xelatex` | 论文编译(5writing、6verity,LaTeX 引擎,中文模板必需) | `command -v xelatex` |
| `python3` | 数值计算与图表(3coding-visual) | `command -v python3` |
| `python3` / `python` | 数值计算与图表(3coding-visual) | `command -v python3 \|\| command -v python` |
| `drawio` / `draw.io` | DrawIO 流程图导出 PDF(4drawio) | `command -v drawio \|\| command -v draw.io` |
| `pdftoppm` | PDF 转 PNG 视觉检查(6verity) | `command -v pdftoppm` |
| `mutool` | PDF 转 PNG 备用(6verity) | `command -v mutool` |
Expand Down Expand Up @@ -55,7 +55,7 @@ if [ -f /etc/os-release ]; then
. /etc/os-release
echo "DISTRO=$ID"
fi
# Windows 包管理器检测(在 Git Bash / PowerShell
# Windows 包管理器检测(在 Git Bash 中;PowerShell 请使用 Get-Command winget 等
command -v winget >/dev/null 2>&1 && echo "PKG=winget"
command -v scoop >/dev/null 2>&1 && echo "PKG=scoop"
command -v choco >/dev/null 2>&1 && echo "PKG=choco"
Expand All @@ -64,14 +64,22 @@ command -v choco >/dev/null 2>&1 && echo "PKG=choco"
### Step 2:检查所有工具

```bash
# Windows(python.org 安装包 / Git Bash)通常只有 `python`,Linux/macOS 为 `python3`。
# 注意:check_cmd 必须显式 return,否则函数以 echo 的退出码(恒为 0)结尾,
# `check_cmd a || check_cmd b` 的回退分支永远不会执行。
check_cmd() {
if command -v "$1" >/dev/null 2>&1; then
echo "OK $1 ($(command -v "$1"))"
return 0
else
echo "MISS $1"
return 1
fi
}

# 统一探测可用的 Python 解释器,供下方包检测使用
PYTHON_BIN="$(command -v python3 || command -v python || true)"

check_cmd typst
check_cmd xelatex
check_cmd python3 || check_cmd python # Windows 上可能是 python
Expand All @@ -81,7 +89,10 @@ check_cmd pdftoppm
check_cmd mutool
check_cmd magick

python3 - <<'PYEOF'
if [ -z "$PYTHON_BIN" ]; then
echo "MISS python3/python,跳过 Python 包检测"
else
"$PYTHON_BIN" - <<'PYEOF'
import importlib
pkgs = ["numpy", "scipy", "pandas", "matplotlib", "sklearn", "openpyxl"]
for p in pkgs:
Expand All @@ -96,6 +107,7 @@ for p in pkgs:
except ImportError:
print(f"MISS {p}")
PYEOF
fi
```

### Step 3:输出检查报告
Expand All @@ -112,7 +124,7 @@ PYEOF
...
```

**必须项:** typst 或 xelatex(至少一个论文编译器)、python3、numpy、pandas、matplotlib
**必须项:** typst 或 xelatex(至少一个论文编译器)、python3/python、numpy、pandas、matplotlib
**可选项:** drawio、pdftoppm/mutool/magick 三选一、scipy、scikit-learn、openpyxl

### Step 4:提供安装命令(按平台)
Expand Down