@yangdw2024/hpc-web-copilot 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +97 -2
  3. package/SKILL.md +111 -0
  4. package/bin/cli.mjs +135 -0
  5. package/cordis.patch.yml +3 -0
  6. package/docs/DETAIL.md +21 -0
  7. package/icon.svg +22 -0
  8. package/index.js +71 -0
  9. package/locale/en.json +7 -0
  10. package/locale/zh.json +7 -0
  11. package/package.json +67 -4
  12. package/profiles/example.profile.env +71 -0
  13. package/references/00_/350/275/257/344/273/266/351/200/211/345/236/213/346/200/273/347/233/256/345/275/225.md +54 -0
  14. package/references/01_Gaussian16_/345/205/245/351/227/250/344/270/216/345/256/236/346/210/230.md +24 -0
  15. package/references/02_Multiwfn/344/270/216VMD_/345/220/216/345/244/204/347/220/206/346/214/207/345/215/227.md +27 -0
  16. package/references/03_ORCA_/345/205/245/351/227/250/344/270/216/345/256/236/346/210/230.md +24 -0
  17. package/references/04_GROMACS_/345/205/245/351/227/250/344/270/216/345/256/236/346/210/230.md +41 -0
  18. package/references/05_VASP/344/270/216vaspkit_/345/205/245/351/227/250/344/270/216/345/256/236/346/210/230.md +25 -0
  19. package/references/06_CP2K/344/270/216LAMMPS_/345/205/245/351/227/250/346/214/207/345/215/227.md +18 -0
  20. package/references/07_Conda/344/270/216/347/274/226/350/257/221/347/216/257/345/242/203/346/214/207/345/215/227.md +16 -0
  21. package/references/portal-cdp-xterm-guide.md +71 -0
  22. package/scripts/chk2fchk.sh +72 -0
  23. package/scripts/cp2k_sub.sh +97 -0
  24. package/scripts/g16_batch.sh +40 -0
  25. package/scripts/g16_sub.sh +139 -0
  26. package/scripts/gmx_sub.sh +80 -0
  27. package/scripts/hpc_common.sh +144 -0
  28. package/scripts/install.ps1 +48 -0
  29. package/scripts/install.sh +39 -0
  30. package/scripts/lammps_sub.sh +74 -0
  31. package/scripts/launch_cdp_browser.ps1 +115 -0
  32. package/scripts/multiwfn_esp_pack.ps1 +99 -0
  33. package/scripts/node_check.sh +60 -0
  34. package/scripts/orca_sub.sh +108 -0
  35. package/scripts/probe_cluster.sh +95 -0
  36. package/scripts/vasp_sub.sh +87 -0
  37. package/scripts/watch_job.sh +65 -0
@@ -0,0 +1,139 @@
1
+ #!/bin/bash
2
+ # ==============================================================================
3
+ # g16_sub.sh - 通用 Profile 驱动 Gaussian 16 安全提交脚本
4
+ # 用法:
5
+ # bash g16_sub.sh <input.gjf> [核数] [内存G] [auto|节点名] [--dry-run]
6
+ # ==============================================================================
7
+
8
+ set -euo pipefail
9
+
10
+ if [[ $# -lt 1 || "$1" == "-h" || "$1" == "--help" ]]; then
11
+ grep '^# ' "$0" | sed 's/^# //'
12
+ exit 0
13
+ fi
14
+
15
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16
+ source "${SCRIPT_DIR}/hpc_common.sh"
17
+ hpc_load_profile "$SCRIPT_DIR"
18
+ hpc_check_workdir
19
+
20
+ GJF_FILE="$1"
21
+ NCORES="${2:-$G16_DEFAULT_CORES}"
22
+ MEM_GB="${3:-$G16_DEFAULT_MEM_GB}"
23
+ TARGET_NODE="${4:-auto}"
24
+ DRY_RUN="${5:-}"
25
+
26
+ if [[ ! -f "$GJF_FILE" ]]; then
27
+ echo "[ERROR] 找不到输入文件: $GJF_FILE" >&2
28
+ exit 1
29
+ fi
30
+ if [[ "$GJF_FILE" != *.gjf && "$GJF_FILE" != *.com ]]; then
31
+ echo "[ERROR] 输入文件扩展名应为 .gjf 或 .com: $GJF_FILE" >&2
32
+ exit 1
33
+ fi
34
+
35
+ hpc_check_limits "$NCORES" "$MEM_GB"
36
+ NODE_DIRECTIVES="$(hpc_build_node_directives "$TARGET_NODE")"
37
+
38
+ # 自动清理 Windows \r 并补齐末尾空行
39
+ sed -i 's/\r$//' "$GJF_FILE"
40
+ if [[ -n "$(tail -n 1 "$GJF_FILE")" ]]; then
41
+ printf '\n\n' >> "$GJF_FILE"
42
+ echo "[INFO] 已自动为 $GJF_FILE 补齐末尾空行。"
43
+ fi
44
+
45
+ # 校对 .gjf 内部 %nprocshared 与 %mem
46
+ gjf_nproc=$(grep -iE '^%nprocshared=' "$GJF_FILE" | head -n1 | cut -d= -f2 | tr -d '[:space:]' || true)
47
+ gjf_mem=$(grep -iE '^%mem=' "$GJF_FILE" | head -n1 | cut -d= -f2 | tr -d '[:space:]' || true)
48
+ if [[ -n "$gjf_nproc" && "$gjf_nproc" != "$NCORES" ]]; then
49
+ echo "[WARN] $GJF_FILE 中 %nprocshared=$gjf_nproc 与申请核数 $NCORES 不一致!"
50
+ fi
51
+ if [[ -n "$gjf_mem" ]]; then
52
+ echo "[INFO] 输入文件设置: %nprocshared=${gjf_nproc:-未指定}, %mem=$gjf_mem (Slurm --mem=${MEM_GB}G,建议 %mem 约为 --mem 的 80%)"
53
+ fi
54
+
55
+ JOB_BASE="${GJF_FILE%.*}"
56
+ SLURM_FILE="${JOB_BASE}.slurm"
57
+ JOB_NAME="${JOB_PREFIX}_${JOB_BASE}"
58
+
59
+ {
60
+ cat << EOF
61
+ #!/bin/bash
62
+ #SBATCH -J "${JOB_NAME}"
63
+ #SBATCH -p ${DEFAULT_PARTITION}
64
+ #SBATCH --nodes=1
65
+ #SBATCH --ntasks-per-node=${NCORES}
66
+ #SBATCH --cpus-per-task=1
67
+ #SBATCH --mem=${MEM_GB}G
68
+ #SBATCH --time=${DEFAULT_WALLTIME}
69
+ EOF
70
+ [[ -n "$NODE_DIRECTIVES" ]] && printf '%s\n' "$NODE_DIRECTIVES"
71
+ cat << EOF
72
+ #SBATCH -o %j.out
73
+ #SBATCH -e %j.err
74
+
75
+ INPUT_GJF="${GJF_FILE}"
76
+ JOB_BASE="${JOB_BASE}"
77
+
78
+ ulimit -d unlimited
79
+ ulimit -s unlimited
80
+ ulimit -t unlimited
81
+ ulimit -v unlimited
82
+
83
+ export SLURM_EXPORT_ENV=ALL
84
+ export OMP_NUM_THREADS=\${SLURM_CPUS_PER_TASK:-1}
85
+ ${G16_ENV_CMD}
86
+
87
+ cd "\$SLURM_SUBMIT_DIR" || exit 1
88
+ EOF
89
+
90
+ if [[ "$SCRATCH_MODE" == "tmp" ]]; then
91
+ cat << EOF
92
+ APP_RUNDIR="${SCRATCH_ROOT}/\$(whoami).\${SLURM_JOB_ID}"
93
+ mkdir -p "\$APP_RUNDIR"
94
+ export GAUSS_SCRDIR="\$APP_RUNDIR"
95
+
96
+ cleanup() {
97
+ cp -f "\$APP_RUNDIR/\${JOB_BASE}.log" "\$SLURM_SUBMIT_DIR/" 2>/dev/null || true
98
+ cp -f "\$APP_RUNDIR"/*.chk "\$SLURM_SUBMIT_DIR/" 2>/dev/null || true
99
+ cp -f "\$APP_RUNDIR"/*.fchk "\$SLURM_SUBMIT_DIR/" 2>/dev/null || true
100
+ cp -f "\$APP_RUNDIR/\${SLURM_JOB_ID}.log" "\$SLURM_SUBMIT_DIR/" 2>/dev/null || true
101
+ rm -rf "\$APP_RUNDIR"
102
+ }
103
+ trap cleanup EXIT
104
+
105
+ cp -f "\$SLURM_SUBMIT_DIR/\$INPUT_GJF" "\$APP_RUNDIR/"
106
+ cp -f "\$SLURM_SUBMIT_DIR"/*.chk "\$APP_RUNDIR/" 2>/dev/null || true
107
+ cd "\$APP_RUNDIR" || exit 1
108
+ EOF
109
+ else
110
+ cat << EOF
111
+ export GAUSS_SCRDIR="${SCRATCH_ROOT}/\$(whoami).\${SLURM_JOB_ID}"
112
+ mkdir -p "\$GAUSS_SCRDIR"
113
+ trap 'rm -rf "\$GAUSS_SCRDIR"' EXIT
114
+ EOF
115
+ fi
116
+
117
+ cat << EOF
118
+
119
+ echo "Starting ${G16_CMD} at \$(hostname) on: \$(date)" >> "\${SLURM_JOB_ID}.log"
120
+ ${G16_CMD} < "\$INPUT_GJF" > "\${JOB_BASE}.log" 2>&1
121
+ G16_EXIT=\$?
122
+
123
+ if [ \$G16_EXIT -eq 0 ] && [ -f "\${JOB_BASE}.chk" ] && command -v formchk >/dev/null 2>&1; then
124
+ formchk ${G16_FORMCHK_FLAGS} "\${JOB_BASE}.chk" "\${JOB_BASE}.fchk"
125
+ fi
126
+
127
+ echo "Finished ${G16_CMD} (exit=\$G16_EXIT) at \$(hostname) on: \$(date)" >> "\${SLURM_JOB_ID}.log"
128
+ exit \$G16_EXIT
129
+ EOF
130
+ } > "$SLURM_FILE"
131
+
132
+ chmod +x "$SLURM_FILE"
133
+
134
+ if [[ "$DRY_RUN" == "--dry-run" ]]; then
135
+ echo "[DRY-RUN] 已生成 $SLURM_FILE (Cluster=${CLUSTER_NAME}, Part=${DEFAULT_PARTITION}, ${NCORES}C/${MEM_GB}G, node=${TARGET_NODE})"
136
+ else
137
+ echo "[SUBMIT] 提交 $SLURM_FILE (Job=${JOB_NAME}, Part=${DEFAULT_PARTITION}, ${NCORES}C/${MEM_GB}G, node=${TARGET_NODE})"
138
+ sbatch "$SLURM_FILE"
139
+ fi
@@ -0,0 +1,80 @@
1
+ #!/bin/bash
2
+ # ==============================================================================
3
+ # gmx_sub.sh - 通用 Profile 驱动 GROMACS 提交脚本(自动断点续算 -cpi)
4
+ # 用法: bash gmx_sub.sh <deffnm前缀(不含.tpr)> [核数] [内存G] [auto|节点名] [--dry-run]
5
+ # ==============================================================================
6
+
7
+ set -euo pipefail
8
+
9
+ if [[ $# -lt 1 || "$1" == "-h" || "$1" == "--help" ]]; then
10
+ grep '^# ' "$0" | sed 's/^# //'
11
+ exit 0
12
+ fi
13
+
14
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15
+ source "${SCRIPT_DIR}/hpc_common.sh"
16
+ hpc_load_profile "$SCRIPT_DIR"
17
+ hpc_check_workdir
18
+
19
+ DEFFNM="${1%.tpr}"
20
+ NCORES="${2:-$GMX_DEFAULT_CORES}"
21
+ MEM_GB="${3:-$GMX_DEFAULT_MEM_GB}"
22
+ TARGET_NODE="${4:-auto}"
23
+ DRY_RUN="${5:-}"
24
+
25
+ [[ ! -f "${DEFFNM}.tpr" ]] && { echo "[ERROR] 找不到 ${DEFFNM}.tpr,请先用 grompp 生成。" >&2; exit 1; }
26
+
27
+ hpc_check_limits "$NCORES" "$MEM_GB"
28
+ NODE_DIRECTIVES="$(hpc_build_node_directives "$TARGET_NODE")"
29
+
30
+ SLURM_FILE="${DEFFNM}_gmx.slurm"
31
+ JOB_NAME="${JOB_PREFIX}_gmx_${DEFFNM}"
32
+
33
+ {
34
+ cat << EOF
35
+ #!/bin/bash
36
+ #SBATCH -J "${JOB_NAME}"
37
+ #SBATCH -p ${DEFAULT_PARTITION}
38
+ #SBATCH --nodes=1
39
+ #SBATCH --ntasks-per-node=${NCORES}
40
+ #SBATCH --cpus-per-task=1
41
+ #SBATCH --mem=${MEM_GB}G
42
+ #SBATCH --time=${DEFAULT_WALLTIME}
43
+ EOF
44
+ [[ -n "$NODE_DIRECTIVES" ]] && printf '%s\n' "$NODE_DIRECTIVES"
45
+ cat << EOF
46
+ #SBATCH -o %j.out
47
+ #SBATCH -e %j.err
48
+
49
+ ulimit -d unlimited
50
+ ulimit -s unlimited
51
+ ulimit -t unlimited
52
+ ulimit -v unlimited
53
+
54
+ export SLURM_EXPORT_ENV=ALL
55
+ export OMP_NUM_THREADS=\${SLURM_CPUS_PER_TASK:-1}
56
+ ${GMX_ENV_CMD}
57
+
58
+ cd "\$SLURM_SUBMIT_DIR" || exit 1
59
+ DEFFNM="${DEFFNM}"
60
+
61
+ echo "Starting GROMACS on \$(hostname) at \$(date)" >> "\${SLURM_JOB_ID}.log"
62
+ if [ -f "\${DEFFNM}.cpt" ]; then
63
+ echo "[INFO] 检测到 \${DEFFNM}.cpt,执行断点续算 (-cpi)..." >> "\${SLURM_JOB_ID}.log"
64
+ ${GMX_MPI_LAUNCHER} ${GMX_BIN} mdrun -v -deffnm "\${DEFFNM}" -cpi "\${DEFFNM}.cpt"
65
+ else
66
+ ${GMX_MPI_LAUNCHER} ${GMX_BIN} mdrun -v -deffnm "\${DEFFNM}"
67
+ fi
68
+ GMX_EXIT=\$?
69
+ echo "Finished GROMACS (exit=\$GMX_EXIT) on \$(hostname) at \$(date)" >> "\${SLURM_JOB_ID}.log"
70
+ exit \$GMX_EXIT
71
+ EOF
72
+ } > "$SLURM_FILE"
73
+
74
+ chmod +x "$SLURM_FILE"
75
+ if [[ "$DRY_RUN" == "--dry-run" ]]; then
76
+ echo "[DRY-RUN] 已生成 GROMACS 脚本 $SLURM_FILE(未提交)。"
77
+ else
78
+ echo "[SUBMIT] 提交 GROMACS: $SLURM_FILE (${NCORES}C/${MEM_GB}G, node=${TARGET_NODE})"
79
+ sbatch "$SLURM_FILE"
80
+ fi
@@ -0,0 +1,144 @@
1
+ #!/bin/bash
2
+ # ==============================================================================
3
+ # hpc_common.sh - 通用 Profile 加载器与安全护栏公共库(由各 *_sub.sh source)
4
+ # ==============================================================================
5
+
6
+ hpc_load_profile() {
7
+ local caller_dir="$1"
8
+ local prof=""
9
+ if [[ -n "${HPC_PROFILE:-}" && -f "${HPC_PROFILE}" ]]; then
10
+ prof="${HPC_PROFILE}"
11
+ elif [[ -f "${caller_dir}/hpc_profile.env" ]]; then
12
+ prof="${caller_dir}/hpc_profile.env"
13
+ elif [[ -f "${HOME}/.hpc_profile.env" ]]; then
14
+ prof="${HOME}/.hpc_profile.env"
15
+ fi
16
+
17
+ if [[ -n "$prof" ]]; then
18
+ # shellcheck disable=SC1090
19
+ source "$prof"
20
+ HPC_PROFILE_LOADED="$prof"
21
+ else
22
+ echo "[WARN] 未找到 hpc_profile.env(可放脚本同目录、~/.hpc_profile.env 或通过 HPC_PROFILE 指定),将使用通用默认值。" >&2
23
+ HPC_PROFILE_LOADED="(builtin-defaults)"
24
+ fi
25
+
26
+ # 通用兜底默认值(零特定学校硬编码)
27
+ CLUSTER_NAME="${CLUSTER_NAME:-generic_slurm_hpc}"
28
+ JOB_PREFIX="${JOB_PREFIX:-$(whoami)}"
29
+ ALLOWED_WORKDIR="${ALLOWED_WORKDIR:-}"
30
+ DEFAULT_PARTITION="${DEFAULT_PARTITION:-normal}"
31
+ ALLOWED_NODES="${ALLOWED_NODES:-}"
32
+ EXCLUDE_NODES="${EXCLUDE_NODES:-}"
33
+ DEFAULT_WALLTIME="${DEFAULT_WALLTIME:-720:00:00}"
34
+ MAX_CPUS_SAFE="${MAX_CPUS_SAFE:-64}"
35
+ MAX_MEM_GB_SAFE="${MAX_MEM_GB_SAFE:-240}"
36
+ EXTRA_SBATCH_OPTS="${EXTRA_SBATCH_OPTS:-}"
37
+ SCRATCH_MODE="${SCRATCH_MODE:-tmp}"
38
+ SCRATCH_ROOT="${SCRATCH_ROOT:-/tmp}"
39
+
40
+ G16_ENV_CMD="${G16_ENV_CMD:-}"
41
+ G16_CMD="${G16_CMD:-g16}"
42
+ G16_FORMCHK_FLAGS="${G16_FORMCHK_FLAGS:--MS}"
43
+ G16_DEFAULT_CORES="${G16_DEFAULT_CORES:-32}"
44
+ G16_DEFAULT_MEM_GB="${G16_DEFAULT_MEM_GB:-120}"
45
+ CHK_DEFAULT_CORES="${CHK_DEFAULT_CORES:-2}"
46
+ CHK_DEFAULT_MEM_GB="${CHK_DEFAULT_MEM_GB:-60}"
47
+
48
+ ORCA_ENV_CMD="${ORCA_ENV_CMD:-}"
49
+ ORCA_EXE="${ORCA_EXE:-orca}"
50
+ ORCA_2MKL_EXE="${ORCA_2MKL_EXE:-orca_2mkl}"
51
+ ORCA_DEFAULT_CORES="${ORCA_DEFAULT_CORES:-24}"
52
+ ORCA_DEFAULT_MEM_GB="${ORCA_DEFAULT_MEM_GB:-96}"
53
+
54
+ GMX_ENV_CMD="${GMX_ENV_CMD:-}"
55
+ GMX_BIN="${GMX_BIN:-gmx_mpi}"
56
+ GMX_MPI_LAUNCHER="${GMX_MPI_LAUNCHER:-srun --mpi=pmi2}"
57
+ GMX_DEFAULT_CORES="${GMX_DEFAULT_CORES:-32}"
58
+ GMX_DEFAULT_MEM_GB="${GMX_DEFAULT_MEM_GB:-64}"
59
+
60
+ VASP_APPS_ROOT="${VASP_APPS_ROOT:-}"
61
+ VASP_DEFAULT_VER="${VASP_DEFAULT_VER:-vasp}"
62
+ VASP_ENV_CMD="${VASP_ENV_CMD:-}"
63
+ VASP_MPI_LAUNCHER="${VASP_MPI_LAUNCHER:-srun --mpi=pmi2}"
64
+ VASP_DEFAULT_CORES="${VASP_DEFAULT_CORES:-48}"
65
+ VASP_DEFAULT_MEM_GB="${VASP_DEFAULT_MEM_GB:-180}"
66
+
67
+ CP2K_ENV_CMD="${CP2K_ENV_CMD:-}"
68
+ CP2K_RUNNER="${CP2K_RUNNER:-srun --mpi=pmi2 cp2k.psmp}"
69
+ CP2K_DEFAULT_CORES="${CP2K_DEFAULT_CORES:-48}"
70
+ CP2K_DEFAULT_MEM_GB="${CP2K_DEFAULT_MEM_GB:-180}"
71
+
72
+ LAMMPS_ENV_CMD="${LAMMPS_ENV_CMD:-}"
73
+ LAMMPS_BIN="${LAMMPS_BIN:-lmp}"
74
+ LAMMPS_MPI_LAUNCHER="${LAMMPS_MPI_LAUNCHER:-srun --mpi=pmi2}"
75
+ LAMMPS_DEFAULT_CORES="${LAMMPS_DEFAULT_CORES:-32}"
76
+ LAMMPS_DEFAULT_MEM_GB="${LAMMPS_DEFAULT_MEM_GB:-64}"
77
+ }
78
+
79
+ # 安全边界检查:若配置了 ALLOWED_WORKDIR,拒绝在越界目录(如公用账号根目录)提交
80
+ hpc_check_workdir() {
81
+ if [[ -n "${ALLOWED_WORKDIR:-}" ]]; then
82
+ local cur_dir
83
+ cur_dir="$(pwd -P)"
84
+ local allow_norm="${ALLOWED_WORKDIR%/}"
85
+ if [[ "$cur_dir" != "$allow_norm" && "$cur_dir" != "$allow_norm/"* ]]; then
86
+ echo "[SAFETY BLOCK] 当前目录 ($cur_dir) 不在允许的工作根目录 ($allow_norm) 内!" >&2
87
+ echo " 为防止污染公用账号根目录,已拒绝提交。请先 cd 到允许目录的子文件夹。" >&2
88
+ exit 1
89
+ fi
90
+ if [[ "$cur_dir" == "$allow_norm" ]]; then
91
+ echo "[WARN] 建议在 ${allow_norm}/<具体任务子文件夹> 中提交,避免多任务文件互相覆盖。" >&2
92
+ fi
93
+ fi
94
+ }
95
+
96
+ # 资源限额检查
97
+ hpc_check_limits() {
98
+ local cores="$1"
99
+ local mem_gb="$2"
100
+ if (( cores > MAX_CPUS_SAFE )); then
101
+ echo "[WARN] 申请核数 (${cores}) 超过 Profile 建议上限 (${MAX_CPUS_SAFE} 核),请注意共享节点排队风险!" >&2
102
+ fi
103
+ if (( mem_gb > MAX_MEM_GB_SAFE )); then
104
+ echo "[WARN] 申请内存 (${mem_gb}G) 超过 Profile 建议上限 (${MAX_MEM_GB_SAFE}G),请注意共享节点排队风险!" >&2
105
+ fi
106
+ }
107
+
108
+ # 构造节点白名单/黑名单 SBATCH 指令(硬性禁止目标落入 EXCLUDE_NODES)
109
+ hpc_build_node_directives() {
110
+ local target="${1:-auto}"
111
+ local lines=""
112
+
113
+ if [[ "$target" != "auto" && -n "$target" ]]; then
114
+ # 检查目标节点是否在黑名单中
115
+ if [[ -n "$EXCLUDE_NODES" ]]; then
116
+ local IFS=','
117
+ for ex in $EXCLUDE_NODES; do
118
+ if [[ "$target" == "$ex" ]]; then
119
+ echo "[SAFETY BLOCK] 目标节点 '$target' 位于 EXCLUDE_NODES ($EXCLUDE_NODES) 中,严禁提交!" >&2
120
+ exit 1
121
+ fi
122
+ done
123
+ fi
124
+ lines="#SBATCH --nodelist=${target}"
125
+ fi
126
+
127
+ if [[ -n "$EXCLUDE_NODES" ]]; then
128
+ if [[ -n "$lines" ]]; then
129
+ lines="${lines}"$'\n'"#SBATCH --exclude=${EXCLUDE_NODES}"
130
+ else
131
+ lines="#SBATCH --exclude=${EXCLUDE_NODES}"
132
+ fi
133
+ fi
134
+
135
+ if [[ -n "$EXTRA_SBATCH_OPTS" ]]; then
136
+ if [[ -n "$lines" ]]; then
137
+ lines="${lines}"$'\n'"#SBATCH ${EXTRA_SBATCH_OPTS}"
138
+ else
139
+ lines="#SBATCH ${EXTRA_SBATCH_OPTS}"
140
+ fi
141
+ fi
142
+
143
+ printf '%s' "$lines"
144
+ }
@@ -0,0 +1,48 @@
1
+ # One-line Windows installer for hpc-web-copilot (no Node.js required)
2
+ # Usage: irm https://raw.githubusercontent.com/yangdw2024/hpc-web-copilot/main/scripts/install.ps1 | iex
3
+ $ErrorActionPreference = 'Stop'
4
+
5
+ $repo = 'yangdw2024/hpc-web-copilot'
6
+ $skillName = 'hpc-web-copilot'
7
+ $zipUrl = "https://github.com/$repo/archive/refs/heads/main.zip"
8
+ $tmp = Join-Path $env:TEMP ("install-" + $skillName + "-" + [guid]::NewGuid().ToString('N'))
9
+ $zipPath = Join-Path $tmp 'repo.zip'
10
+
11
+ try {
12
+ New-Item -ItemType Directory -Path $tmp -Force | Out-Null
13
+ Write-Host "Downloading $repo..." -ForegroundColor Cyan
14
+ Invoke-WebRequest -Uri $zipUrl -OutFile $zipPath -UseBasicParsing
15
+ Expand-Archive -Path $zipPath -DestinationPath $tmp -Force
16
+ $srcRoot = (Get-ChildItem -Path $tmp -Directory | Select-Object -First 1).FullName
17
+ $skillSrc = $srcRoot
18
+
19
+ $candidates = @(
20
+ @{ Root = (Join-Path $env:USERPROFILE '.dsh'); Dest = (Join-Path $env:USERPROFILE ".dsh\skills\$skillName") },
21
+ @{ Root = (Join-Path $env:USERPROFILE '.claude'); Dest = (Join-Path $env:USERPROFILE ".claude\skills\$skillName") },
22
+ @{ Root = (Join-Path $env:USERPROFILE '.codex'); Dest = (Join-Path $env:USERPROFILE ".codex\skills\$skillName") },
23
+ @{ Root = (Join-Path $env:USERPROFILE '.cursor'); Dest = (Join-Path $env:USERPROFILE ".cursor\skills\$skillName") },
24
+ @{ Root = (Join-Path $env:USERPROFILE '.agents'); Dest = (Join-Path $env:USERPROFILE ".agents\skills\$skillName") },
25
+ @{ Root = (Join-Path $env:USERPROFILE '.gemini\antigravity'); Dest = (Join-Path $env:USERPROFILE ".gemini\antigravity\skills\$skillName") }
26
+ )
27
+
28
+ $targets = @($candidates | Where-Object { Test-Path $_.Root })
29
+ if ($targets.Count -eq 0) {
30
+ $targets = @($candidates[0], $candidates[4])
31
+ }
32
+
33
+ $items = @('SKILL.md', 'profiles', 'references', 'scripts', 'LICENSE')
34
+ foreach ($t in $targets) {
35
+ if (Test-Path $t.Dest) { Remove-Item -Recurse -Force $t.Dest }
36
+ New-Item -ItemType Directory -Path $t.Dest -Force | Out-Null
37
+ foreach ($item in $items) {
38
+ $from = Join-Path $skillSrc $item
39
+ if (Test-Path $from) {
40
+ Copy-Item -Path $from -Destination (Join-Path $t.Dest $item) -Recurse -Force
41
+ }
42
+ }
43
+ Write-Host "[ok] Installed $skillName -> $($t.Dest)" -ForegroundColor Green
44
+ }
45
+ Write-Host "`nDone! Open a new session in DSH / Claude Code / Codex / Cursor / Antigravity to use /$skillName." -ForegroundColor Cyan
46
+ } finally {
47
+ if (Test-Path $tmp) { Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue }
48
+ }
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env bash
2
+ # One-line macOS/Linux installer for hpc-web-copilot (no Node.js required)
3
+ # Usage: curl -fsSL https://raw.githubusercontent.com/yangdw2024/hpc-web-copilot/main/scripts/install.sh | bash
4
+ set -euo pipefail
5
+
6
+ REPO="yangdw2024/hpc-web-copilot"
7
+ SKILL_NAME="hpc-web-copilot"
8
+ TMP_DIR="$(mktemp -d)"
9
+ trap 'rm -rf "$TMP_DIR"' EXIT
10
+
11
+ echo "Downloading $REPO..."
12
+ curl -fsSL "https://github.com/$REPO/archive/refs/heads/main.tar.gz" | tar -xz -C "$TMP_DIR"
13
+ SRC_ROOT="$(find "$TMP_DIR" -mindepth 1 -maxdepth 1 -type d | head -n 1)"
14
+ SKILL_SRC="$SRC_ROOT"
15
+
16
+ TARGETS=()
17
+ for root in "$HOME/.dsh" "$HOME/.claude" "$HOME/.codex" "$HOME/.cursor" "$HOME/.agents" "$HOME/.gemini/antigravity"; do
18
+ if [ -d "$root" ]; then
19
+ TARGETS+=("$root/skills/$SKILL_NAME")
20
+ fi
21
+ done
22
+ if [ "${#TARGETS[@]}" -eq 0 ]; then
23
+ TARGETS=("$HOME/.dsh/skills/$SKILL_NAME" "$HOME/.agents/skills/$SKILL_NAME")
24
+ fi
25
+
26
+ ITEMS=("SKILL.md" "profiles" "references" "scripts" "LICENSE")
27
+ for dest in "${TARGETS[@]}"; do
28
+ rm -rf "$dest"
29
+ mkdir -p "$dest"
30
+ for item in "${ITEMS[@]}"; do
31
+ if [ -e "$SKILL_SRC/$item" ]; then
32
+ cp -R "$SKILL_SRC/$item" "$dest/$item"
33
+ fi
34
+ done
35
+ echo "[ok] Installed $SKILL_NAME -> $dest"
36
+ done
37
+
38
+ echo ""
39
+ echo "Done! Open a new session in DSH / Claude Code / Codex / Cursor / Antigravity to use /$SKILL_NAME."
@@ -0,0 +1,74 @@
1
+ #!/bin/bash
2
+ # ==============================================================================
3
+ # lammps_sub.sh - 通用 Profile 驱动 LAMMPS 提交脚本
4
+ # 用法: bash lammps_sub.sh <in.xxx> [核数] [内存G] [auto|节点名] [--dry-run]
5
+ # ==============================================================================
6
+
7
+ set -euo pipefail
8
+
9
+ if [[ $# -lt 1 || "$1" == "-h" || "$1" == "--help" ]]; then
10
+ grep '^# ' "$0" | sed 's/^# //'
11
+ exit 0
12
+ fi
13
+
14
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15
+ source "${SCRIPT_DIR}/hpc_common.sh"
16
+ hpc_load_profile "$SCRIPT_DIR"
17
+ hpc_check_workdir
18
+
19
+ IN_FILE="$1"
20
+ NCORES="${2:-$LAMMPS_DEFAULT_CORES}"
21
+ MEM_GB="${3:-$LAMMPS_DEFAULT_MEM_GB}"
22
+ TARGET_NODE="${4:-auto}"
23
+ DRY_RUN="${5:-}"
24
+
25
+ [[ ! -f "$IN_FILE" ]] && { echo "[ERROR] 找不到 LAMMPS 输入文件: $IN_FILE" >&2; exit 1; }
26
+ sed -i 's/\r$//' "$IN_FILE"
27
+
28
+ hpc_check_limits "$NCORES" "$MEM_GB"
29
+ NODE_DIRECTIVES="$(hpc_build_node_directives "$TARGET_NODE")"
30
+
31
+ TAG="${IN_FILE//./_}"
32
+ SLURM_FILE="${TAG}_lmp.slurm"
33
+ JOB_NAME="${JOB_PREFIX}_lmp_${TAG}"
34
+
35
+ {
36
+ cat << EOF
37
+ #!/bin/bash
38
+ #SBATCH -J "${JOB_NAME}"
39
+ #SBATCH -p ${DEFAULT_PARTITION}
40
+ #SBATCH --nodes=1
41
+ #SBATCH --ntasks-per-node=${NCORES}
42
+ #SBATCH --cpus-per-task=1
43
+ #SBATCH --mem=${MEM_GB}G
44
+ #SBATCH --time=${DEFAULT_WALLTIME}
45
+ EOF
46
+ [[ -n "$NODE_DIRECTIVES" ]] && printf '%s\n' "$NODE_DIRECTIVES"
47
+ cat << EOF
48
+ #SBATCH -o %j.out
49
+ #SBATCH -e %j.err
50
+
51
+ ulimit -d unlimited
52
+ ulimit -s unlimited
53
+ ulimit -t unlimited
54
+ ulimit -v unlimited
55
+
56
+ ${LAMMPS_ENV_CMD}
57
+ export OMP_NUM_THREADS=\${SLURM_CPUS_PER_TASK:-1}
58
+
59
+ cd "\$SLURM_SUBMIT_DIR" || exit 1
60
+ echo "Starting LAMMPS on \$(hostname) at \$(date)" >> "\${SLURM_JOB_ID}.log"
61
+ ${LAMMPS_MPI_LAUNCHER} ${LAMMPS_BIN} < "${IN_FILE}" >lmp.out 2>lmp.err
62
+ LMP_EXIT=\$?
63
+ echo "Finished LAMMPS (exit=\$LMP_EXIT) on \$(hostname) at \$(date)" >> "\${SLURM_JOB_ID}.log"
64
+ exit \$LMP_EXIT
65
+ EOF
66
+ } > "$SLURM_FILE"
67
+
68
+ chmod +x "$SLURM_FILE"
69
+ if [[ "$DRY_RUN" == "--dry-run" ]]; then
70
+ echo "[DRY-RUN] 已生成 LAMMPS 脚本 $SLURM_FILE(未提交)。"
71
+ else
72
+ echo "[SUBMIT] 提交 LAMMPS: $SLURM_FILE (${NCORES}C/${MEM_GB}G, node=${TARGET_NODE})"
73
+ sbatch "$SLURM_FILE"
74
+ fi
@@ -0,0 +1,115 @@
1
+ <#
2
+ .SYNOPSIS
3
+ 通用 Windows CDP 持久化浏览器启动脚本(支持 Edge / Chrome,零硬编码路径)。
4
+ .DESCRIPTION
5
+ 绕过 Chromium/Edge 136+ 禁止在默认用户数据目录开启 --remote-debugging-port 的限制,
6
+ 自动创建独立的持久化配置目录 (%USERPROFILE%\.dsh\cdp-<channel>-profile),不影响日常浏览器。
7
+ .EXAMPLE
8
+ pwsh -NoProfile -ExecutionPolicy Bypass -File .\launch_cdp_browser.ps1 -Channel edge -StartUrl "https://hpc.example.edu.cn"
9
+ .EXAMPLE
10
+ pwsh -NoProfile -ExecutionPolicy Bypass -File .\launch_cdp_browser.ps1 -Channel edge -StartUrl "https://hpc.example.edu.cn" -CreateShortcut -ShortcutName "AI协同 Edge"
11
+ #>
12
+ param(
13
+ [ValidateSet("edge", "chrome")]
14
+ [string]$Channel = "edge",
15
+
16
+ [int]$Port = 9222,
17
+
18
+ [string]$ProfileDir = "",
19
+
20
+ [string]$StartUrl = "about:blank",
21
+
22
+ [switch]$ForceSwitch,
23
+
24
+ [switch]$CreateShortcut,
25
+
26
+ [string]$ShortcutName = ""
27
+ )
28
+
29
+ $ErrorActionPreference = "Stop"
30
+
31
+ # 自动探测已安装浏览器路径(零硬编码用户名)
32
+ function Find-BrowserExe([string]$ch) {
33
+ $candidates = if ($ch -eq "edge") {
34
+ @(
35
+ "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe",
36
+ "$env:ProgramFiles\Microsoft\Edge\Application\msedge.exe",
37
+ "$env:LOCALAPPDATA\Microsoft\Edge\Application\msedge.exe"
38
+ )
39
+ } else {
40
+ @(
41
+ "$env:ProgramFiles\Google\Chrome\Application\chrome.exe",
42
+ "${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe",
43
+ "$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe"
44
+ )
45
+ }
46
+ foreach ($p in $candidates) {
47
+ if ($p -and (Test-Path $p)) { return $p }
48
+ }
49
+ throw "未在本机找到 $ch 浏览器,请确认已安装。"
50
+ }
51
+
52
+ $browserExe = Find-BrowserExe $Channel
53
+ if ([string]::IsNullOrWhiteSpace($ProfileDir)) {
54
+ $ProfileDir = Join-Path $env:USERPROFILE ".dsh\cdp-$Channel-profile"
55
+ }
56
+ if (-not (Test-Path $ProfileDir)) {
57
+ New-Item -ItemType Directory -Path $ProfileDir -Force | Out-Null
58
+ }
59
+
60
+ $argsStr = "--remote-debugging-port=$Port --user-data-dir=`"$ProfileDir`" --no-first-run `"$StartUrl`""
61
+
62
+ if ($CreateShortcut) {
63
+ $desktop = [Environment]::GetFolderPath("Desktop")
64
+ if ([string]::IsNullOrWhiteSpace($ShortcutName)) {
65
+ $ShortcutName = if ($Channel -eq "edge") { "AI协同 Edge" } else { "AI协同 Chrome" }
66
+ }
67
+ $lnkPath = Join-Path $desktop "$ShortcutName.lnk"
68
+ $shell = New-Object -ComObject WScript.Shell
69
+ $sc = $shell.CreateShortcut($lnkPath)
70
+ $sc.TargetPath = $browserExe
71
+ $sc.Arguments = $argsStr
72
+ $sc.WorkingDirectory = Split-Path $browserExe
73
+ $sc.IconLocation = "$browserExe,0"
74
+ $sc.Description = "启动带 CDP $Port 调试端口的 AI 协同专用 $Channel(独立持久化配置目录)"
75
+ $sc.Save()
76
+ Write-Output "[OK] 已创建桌面快捷方式: $lnkPath"
77
+ }
78
+
79
+ $expectedPattern = if ($Channel -eq "edge") { "^Edg/" } else { "^Chrome/" }
80
+
81
+ try {
82
+ $ver = Invoke-RestMethod -Uri "http://127.0.0.1:$Port/json/version" -TimeoutSec 2
83
+ if ($ver.Browser -match $expectedPattern) {
84
+ Write-Output "[OK] CDP 浏览器已在线: $($ver.Browser) on 127.0.0.1:$Port"
85
+ exit 0
86
+ } elseif ($ForceSwitch) {
87
+ Write-Output "[INFO] 端口 $Port 当前被 $($ver.Browser) 占用,正在释放并切换为 $Channel..."
88
+ $line = netstat -ano | Select-String "127\.0\.0\.1:$Port\s+.*LISTENING" | Select-Object -First 1
89
+ if ($line) {
90
+ $ownerPid = ($line.ToString().Trim() -split '\s+')[-1]
91
+ if ($ownerPid -match '^\d+$') {
92
+ Stop-Process -Id ([int]$ownerPid) -Force -ErrorAction SilentlyContinue
93
+ Start-Sleep -Milliseconds 800
94
+ }
95
+ }
96
+ } else {
97
+ Write-Output "[WARN] 端口 $Port 当前被 $($ver.Browser) 占用。如需强制切换,请追加 -ForceSwitch。"
98
+ exit 1
99
+ }
100
+ } catch {
101
+ # 端口空闲,继续启动
102
+ }
103
+
104
+ Start-Process -FilePath $browserExe -ArgumentList $argsStr
105
+
106
+ for ($i = 0; $i -lt 16; $i++) {
107
+ Start-Sleep -Milliseconds 500
108
+ try {
109
+ $ver = Invoke-RestMethod -Uri "http://127.0.0.1:$Port/json/version" -TimeoutSec 2
110
+ Write-Output "[OK] CDP 浏览器启动成功: $($ver.Browser) on 127.0.0.1:$Port"
111
+ exit 0
112
+ } catch {}
113
+ }
114
+
115
+ throw "等待 8 秒后 127.0.0.1:$Port 仍未响应,请检查浏览器启动状态。"