Skip to content

📖 《把 AI 当助手——经济实证研究的诚信、方法与工具》双语网页版:每章中文部在前,English Edition 在后,内容与最新合订 PDF 一致。

附录 A · 环境配置速查(macOS / Windows) ​


A.1 macOS 主线配置(教师机实测) ​

A.1.1 基础工具 ​

表 A.1 基础工具。

L4|L4|L4|L4

软件 & 版本要求 & 安装方式 & 验证命令
Homebrew & latest & &
Python & ≥ 3.12 & brew install python@3.12 & python3 --version
Node.js & ≥ 20 LTS & brew install node & node --version
Git & ≥ 2.40 & brew install git & git --version
Stata & 18 MP/SE & 学校正版安装包 + 命令行链接 & stata-mp --version
Zotero & 10 & 官网下载(zotero.org) & 启动验证
Qoder / Trae & latest & 官网下载 & 启动验证
MacTeX & 2024+ & brew install --cask mactex-no-gui & xelatex --version\

A.1.2 学术工具链 ​

表 A.2 学术工具链。

L5|L5|L5|L5|L5

工具 & 用途 & 安装 & 验证 & 对应章节
officecli & Word/Excel/PPT 全能操作 & pip install officecli & officecli --version & 第 1/8/11 章
cli-anything-zotero & Zotero CLI Bridge & + 插件安装 & & 第 3 章
edge-tts & 语音合成(公众号/视频) & pip install edge-tts & edge-tts --list-voices & 课外
pandoc & 文档格式互转 & brew install pandoc & pandoc --version & 第 11 章
quarto & .ipynb → PDF/HTML/Word & brew install --cask quarto & quarto --version & 课外发布
uv & Python 包管理器(快) & brew install uv & uv --version & 第 1 章
gh & GitHub CLI & brew install gh & gh --version & 第 1 章\

A.1.3 macOS 一键自检脚本 ​

#!/bin/bash
# check_ai_stata_env.sh —— 第 1 章 macOS 自检 cell 配套
echo "=== AI 研究环境检查(macOS) ==="
for cmd in python3 node git stata-mp pandoc xelatex quarto uv gh \
           officecli cli-anything-zotero edge-tts; do
  if command -v $cmd &>/dev/null; then
    echo "[v] $cmd: $(command -v $cmd)"
  else
    echo "[x] $cmd: 未找到——请参照第 1 章安装指南"
  fi
done

echo ""
echo "=== 版本检查 ==="
python3 --version 2>/dev/null || echo "[!] python3 版本未知"
node --version 2>/dev/null || echo "[!] node 版本未知"

echo ""
echo "=== Stata 检查 ==="
if command -v stata-mp &>/dev/null; then
  echo "[v] Stata: $(stata-mp /e version 2>/dev/null || echo '已安装(版本未知)')"
else
  echo "[x] Stata 未找到——请确认已安装并加入 PATH"
fi

echo ""
echo "=== LaTeX 检查 ==="
if command -v xelatex &>/dev/null; then
  echo "[v] XeLaTeX: $(xelatex --version | head -1)"
else
  echo "[x] XeLaTeX 未找到——请安装 MacTeX 或 BasicTeX"
fi

echo ""
echo "=== Qoder MCP 配置 ==="
if [ -d "$HOME/.qoder/mcp" ]; then
  echo "[v] MCP 配置目录: $HOME/.qoder/mcp"
else
  echo "[!] Qoder MCP 配置目录不存在(首次启动 Qoder 后自动创建)"
fi

A.2 Windows 学生机配置(源 14 讲义口径) ​

A.2.1 基础工具 ​

表 A.3 基础工具。

L4|L4|L4|L4

软件 & 版本要求 & 安装方式 & 验证命令(PowerShell 7)
PowerShell 7 & latest & Microsoft Store 搜「PowerShell」 &
Python & 3.12 & python.org 下载,务必勾选 Add to PATH & python --version
Node.js & LTS(△  勿选 Current) & nodejs.org 下载 .msi & node --version
Git & ≥ 2.40 & git-scm.com 下载 & git --version
Stata & 18 MP/SE & 学校正版安装包;安装后手动加 PATH & stata-mp /e version
Zotero & 10 & zotero.org 下载 & 启动验证
Qoder & latest & 官网下载 Qoder-Setup.exe & 启动验证
MiKTeX & latest(Basic Installer 约 230 MB) & miktex.org 下载,无需管理员权限 & xelatex --version\

A.2.2 与 macOS 的关键差异 ​

表 A.4 与 macOS 的关键差异。

L3|L3|L3

维度 & macOS & Windows
路径分隔符 & / & \(PowerShell 中可用 /)
终端 & Terminal / iTerm2 + zsh & PowerShell 7 / Windows Terminal
包管理器 & Homebrew(brew install) & winget / choco(winget install)
Stata 路径 & &
Qoder MCP 配置 & ~/Library/``Application Support/Qoder/``SharedClientCache/``projects/<项目>/mcps & %APPDATA%\Qoder\``SharedClientCache\``extension\local\``mcp.json
LaTeX 发行版 & MacTeX(约 4 GB,全) & MiKTeX(Basic 约 230 MB,按需下载宏包)
中文字体 & 系统自带(PingFang/STHeiti) & SimSun / SimHei / KaiTi / FangSong / 微软雅黑(五件套)\

A.2.3 PowerShell 7 常用命令对照 ​

表 A.5 PowerShell 7 常用命令对照。

L3|L3|L3

任务 & macOS(zsh) & Windows(PowerShell 7)
列目录 & ls -la & Get-ChildItem -Force 或 ls(PowerShell 别名)
进目录 & cd path & cd path(同)
查命令路径 & which cmd & Get-Command cmd
设环境变量 & export VAR=val & $env:VAR = "val"
永久环境变量 & 写入 ~/.zshrc & [Environment]::``SetEnvironmentVariable``("VAR","val","User")
包安装 & brew install pkg & winget install pkg
Python 包 & pip install pkg & pip install pkg(同;建议先 python -m pip install -U pip)
查端口占用 & lsof -i :PORT & Get-NetTCPConnection -LocalPort PORT\

A.2.4 MiKTeX 中文 LaTeX 配置要点 ​

  1. 安装时选「Install missing packages on-the-fly」= Always(避免编译卡住)

  2. 编译中文文档必须用 XeLaTeX(不是 pdfLaTeX),导言区加:

   \usepackage[UTF8]{ctex}   % 或 \usepackage{xeCJK}
   \setCJKmainfont{SimSun}
   \setCJKsansfont{SimHei}
   \setCJKmonofont{KaiTi}
  1. 第一次编译会下载宏包,不要中断——等 MiKTeX Console 自动装完

  2. 推荐编辑器:VS Code + LaTeX Workshop 扩展,或 TeXstudio

A.2.5 Windows 一键自检脚本(PowerShell 7) ​

# check_ai_stata_env.ps1 —— 第 1 章 Windows 自检 cell 配套
Write-Host "=== AI 研究环境检查(Windows) ===" -ForegroundColor Cyan
$cmds = @("python","node","git","stata-mp","pandoc","xelatex","quarto","uv","gh",
          "officecli","cli-anything-zotero","edge-tts")
foreach ($c in $cmds) {
  $cmd = Get-Command $c -ErrorAction SilentlyContinue
  if ($cmd) { Write-Host "[v] $c : $($cmd.Source)" -ForegroundColor Green }
  else      { Write-Host "[x] $c : 未安装" -ForegroundColor Red }
}
# Qoder MCP 配置文件检查
$mcp = "$env:APPDATA\Qoder\SharedClientCache\extension\local\mcp.json"
if (Test-Path $mcp) { Write-Host "[v] Qoder mcp.json: $mcp" -ForegroundColor Green }
else                { Write-Host "[!] Qoder mcp.json 不存在(首次启动 Qoder 后自动创建)" }

A.2.6 Windows 排错速查(源 14 第十二部分精选 8 条) ​

表 A.6 Windows 排错速查(源 14 第十二部分精选 8 条)。

L3|L3|L3

现象 & 原因 & 解法
xelatex 中文报错「cannot find font」 & 未装中文字体或未用 \setCJKmainfont & 用 Windows 自带 SimSun/SimHei;导言区显式指定字体
MiKTeX 首次编译卡住 & 在按需下载宏包 & 等 MiKTeX Console 自动完成;勿强制结束
警告「headheight too small」 & 模板默认值偏小 & 导言区加
npm install -g 权限失败 & PowerShell 执行策略限制 & Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
pip install 慢/超时 & 默认源在国外 & pip config set``global.index-url``https://pypi.tuna.``tsinghua.edu.cn/simple
python 命令找不到 & 安装时未勾选 Add to PATH & 重装并勾选;或手动加 C:\Users\<你>``\AppData\Local\``Programs\Python\Python312 到 PATH
OpenCLI 扩展未连接 & Chrome 扩展未启用 & 运行 opencli setup 重新配对,再 opencli doctor 自检
失败 & Node 版本太老 / 镜像问题 & 升 Node LTS;\

A.3 标准研究文件夹结构(第 1.5/2.6 节配套) ​

my_research_project/
+-- README.md                  # 一页项目说明
+-- data/
|   +-- raw/                   # 原始数据(只读,永不修改)
|   +-- clean/                 # 清洗后数据(do 文件生成)
|   +-- derived/               # 中间产物(合并表/子样本)
+-- do/                        # Stata do 文件(按章节命名)
|   +-- 01_clean.do
|   +-- 02_explore.do
|   +-- 03_regress.do
|   +-- 04_diag.do
|   +-- 05_export.do
+-- output/
|   +-- tables/                # 回归表格(.tex / .rtf)
|   +-- figures/               # 图表(.png / .pdf)
|   +-- logs/                  # Stata log(带时间戳)
+-- docs/                      # 研究设计、问卷、笔记
+-- manuscript/                # 论文正文(.tex / .docx)
+-- references/
    +-- rural_finance_30papers.bib
    +-- pdfs/

黄金原则:data/raw/ 只读 + do/ 完整可复现 + output/logs/ 带时间戳——三件套齐备才能通过 S8.1 / S9.3 诚信检查。


A.4 MCP / Skill / CLI 三层范式速查(第 1.3c 节配套) ​

A.4.1 三范式五维对比 ​

表 A.7 三范式五维对比。

L4|L4|L4|L4

维度 & MCP(连接层) & Skill(知识层) & CLI(执行层)
本质 & 连接协议 & 领域知识文件 & Shell 命令
类比 & USB-C 接口 & 操作手册 & 万能遥控器
形态 & JSON-RPC Server & Markdown 文件(SKILL.md) & Shell 命令
开发成本 & 高(需写 Server) & 低(写 Markdown) & 零(直接用)
适合场景 & 企业 SaaS / 数据库 / 远程执行 & 知识复用 / SOP 沉淀 & 本地自动化 / 文件批处理\

[提示] 黄金组合:CLI(执行层)+ Skill(知识层)+ MCP(连接层)= 完整的 AI 工具链。

例:跑回归 = stata-mcp(MCP 连 Stata)+ stata Skill(回归 SOP)+ officecli(CLI 输出 Word)。

A.4.2 Qoder mcp.json 配置双平台路径 ​

表 A.8 Qoder mcp.json 配置双平台路径。

L2|L2

平台 & 配置文件路径
Windows & %APPDATA%\Qoder\``SharedClientCache\``extension\local\``mcp.json
macOS & ~/Library/Application Support/Qoder/SharedClientCache/projects/<项目>/mcps/\

△  新增 MCP 服务器后必须重启 Qoder 客户端才能加载(实测陷阱)。

A.4.3 mcp.json 三种启动方式 ​

{
  "mcpServers": {
    // 方式 1:npx(Node 包)
    "stata-mcp": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/stata-mcp"]
    },
    // 方式 2:uvx(Python 包,需先 pip install uv)
    "faostat-mcp-server": {
      "command": "uvx",
      "args": ["faostat-mcp-server"]
    },
    // 方式 3:本地 exe / 脚本
    "officecli-mcp": {
      "command": "/Users/yourname/.local/bin/officecli",
      "args": ["mcp"]
    }
  }
}

CNKI 边界提醒(手册 v1.4 锁定):本手册不展开 cnki-mcp 配置;中文文献请用知网网页自行检索,配合 Zotero jasminum 插件抓取元数据(见第 3 章 §3.5)。


English Edition ​

Appendix A · Environment Setup Quick Reference (macOS / Windows) ​


A.1 macOS main configuration (verified on the teacher’s machine) ​

A.1.1 Basic tools ​

Table A.1 Basic tools.

L4|L4|L4|L4

Software & Version required & Installation & Verification command
Homebrew & latest & &
Python & ≥ 3.12 & brew install python@3.12 & python3 --version
Node.js & ≥ 20 LTS & brew install node & node --version
Git & ≥ 2.40 & brew install git & git --version
Stata & 18 MP/SE & University licensed installer + command-line link & stata-mp --version
Zotero & 10 & Download from zotero.org & Launch check
Qoder / Trae & latest & Download from the official site & Launch check
MacTeX & 2024+ & brew install --cask mactex-no-gui & xelatex --version\

A.1.2 Academic toolchain ​

Table A.2 Academic toolchain.

L5|L5|L5|L5|L5

Tool & Purpose & Installation & Verification & Related chapter
officecli & All-round Word/Excel/PPT operations & pip install officecli & officecli --version & Ch. 1/8/11
cli-anything-zotero & Zotero CLI bridge & + plugin install & & Ch. 3
edge-tts & Speech synthesis (WeChat articles/video) & pip install edge-tts & edge-tts --list-voices & Extracurricular
pandoc & Document format conversion & brew install pandoc & pandoc --version & Ch. 11
quarto & .ipynb → PDF/HTML/Word & brew install --cask quarto & quarto --version & Extracurricular publishing
uv & Python package manager (fast) & brew install uv & uv --version & Ch. 1
gh & GitHub CLI & brew install gh & gh --version & Ch. 1\

A.1.3 macOS one-shot self-check script ​

#!/bin/bash
# check_ai_stata_env.sh -- companion to the Chapter 1 macOS self-check cell
echo "=== AI research environment check (macOS) ==="
for cmd in python3 node git stata-mp pandoc xelatex quarto uv gh \
           officecli cli-anything-zotero edge-tts; do
  if command -v $cmd &>/dev/null; then
    echo "[v] $cmd: $(command -v $cmd)"
  else
    echo "[x] $cmd: not found -- see the Chapter 1 installation guide"
  fi
done

echo ""
echo "=== Version checks ==="
python3 --version 2>/dev/null || echo "[!] python3 version unknown"
node --version 2>/dev/null || echo "[!] node version unknown"

echo ""
echo "=== Stata check ==="
if command -v stata-mp &>/dev/null; then
  echo "[v] Stata: $(stata-mp /e version 2>/dev/null || echo 'installed (version unknown)')"
else
  echo "[x] Stata not found -- confirm it is installed and on PATH"
fi

echo ""
echo "=== LaTeX check ==="
if command -v xelatex &>/dev/null; then
  echo "[v] XeLaTeX: $(xelatex --version | head -1)"
else
  echo "[x] XeLaTeX not found -- install MacTeX or BasicTeX"
fi

echo ""
echo "=== Qoder MCP configuration ==="
if [ -d "$HOME/.qoder/mcp" ]; then
  echo "[v] MCP configuration directory: $HOME/.qoder/mcp"
else
  echo "[!] Qoder MCP configuration directory missing (created on first launch)"
fi

A.2 Windows student-machine configuration (per source handout 14) ​

A.2.1 Basic tools ​

Table A.3 Basic tools.

L4|L4|L4|L4

Software & Version required & Installation & Verification command (PowerShell 7)
PowerShell 7 & latest & Search “PowerShell” in the Microsoft Store &
Python & 3.12 & Download from python.org; be sure to tick Add to PATH & python --version
Node.js & LTS (△  not Current) & Download the .msi from nodejs.org & node --version
Git & ≥ 2.40 & Download from git-scm.com & git --version
Stata & 18 MP/SE & University licensed installer; add to PATH manually & stata-mp /e version
Zotero & 10 & Download from zotero.org & Launch check
Qoder & latest & Download Qoder-Setup.exe from the official site & Launch check
MiKTeX & latest (Basic Installer about 230 MB) & Download from miktex.org; no administrator rights needed & xelatex --version\

A.2.2 Key differences from macOS ​

Table A.4 Key differences from macOS.

L3|L3|L3

Dimension & macOS & Windows
Path separator & / & \ (/ also works in PowerShell)
Terminal & Terminal / iTerm2 + zsh & PowerShell 7 / Windows Terminal
Package manager & Homebrew (brew install) & winget / choco (winget install)
Stata path & &
Qoder MCP config & ~/Library/``Application Support/Qoder/``SharedClientCache/``projects/<project>/mcps & %APPDATA%\Qoder\``SharedClientCache\``extension\local\``mcp.json
LaTeX distribution & MacTeX (about 4 GB, complete) & MiKTeX (Basic about 230 MB, packages on demand)
Chinese fonts & Built in (PingFang/STHeiti) & SimSun / SimHei / KaiTi / FangSong / Microsoft YaHei (the five-piece set)\

A.2.3 Common PowerShell 7 command equivalents ​

Table A.5 Common PowerShell 7 command equivalents.

L3|L3|L3

Task & macOS (zsh) & Windows (PowerShell 7)
List a directory & ls -la & Get-ChildItem -Force or ls (PowerShell alias)
Change directory & cd path & cd path (same)
Locate a command & which cmd & Get-Command cmd
Set an environment variable & export VAR=val & $env:VAR = "val"
Persist an environment variable & Write into ~/.zshrc & [Environment]::``SetEnvironmentVariable``("VAR","val","User")
Install a package & brew install pkg & winget install pkg
Install a Python package & pip install pkg & pip install pkg (same; run python -m pip install -U pip first)
Check a port & lsof -i :PORT & Get-NetTCPConnection -LocalPort PORT\

A.2.4 Key points for Chinese LaTeX under MiKTeX ​

  1. During installation choose “Install missing packages on-the-fly” = Always (so compilation does not stall)

  2. Chinese documents must be compiled with XeLaTeX (not pdfLaTeX), with this in the preamble:

   \usepackage[UTF8]{ctex}   % or \usepackage{xeCJK}
   \setCJKmainfont{SimSun}
   \setCJKsansfont{SimHei}
   \setCJKmonofont{KaiTi}
  1. The first compilation downloads packages—do not interrupt; wait for MiKTeX Console to finish

  2. Recommended editors: VS Code with the LaTeX Workshop extension, or TeXstudio

A.2.5 Windows one-shot self-check script (PowerShell 7) ​

# check_ai_stata_env.ps1 -- companion to the Chapter 1 Windows self-check cell
Write-Host "=== AI research environment check (Windows) ===" -ForegroundColor Cyan
$cmds = @("python","node","git","stata-mp","pandoc","xelatex","quarto","uv","gh",
          "officecli","cli-anything-zotero","edge-tts")
foreach ($c in $cmds) {
  $cmd = Get-Command $c -ErrorAction SilentlyContinue
  if ($cmd) { Write-Host "[v] $c : $($cmd.Source)" -ForegroundColor Green }
  else      { Write-Host "[x] $c : not installed" -ForegroundColor Red }
}
# Check the Qoder MCP configuration file
$mcp = "$env:APPDATA\Qoder\SharedClientCache\extension\local\mcp.json"
if (Test-Path $mcp) { Write-Host "[v] Qoder mcp.json: $mcp" -ForegroundColor Green }
else                { Write-Host "[!] Qoder mcp.json missing (created on first launch)" }

A.2.6 Windows troubleshooting quick reference (eight from source 14, part 12) ​

Table A.6 Windows troubleshooting quick reference.

L3|L3|L3

Symptom & Cause & Fix
xelatex reports “cannot find font” for Chinese & Chinese fonts missing or no \setCJKmainfont & Use the built-in SimSun/SimHei; set the fonts explicitly in the preamble
MiKTeX stalls on first compilation & Downloading packages on demand & Wait for MiKTeX Console to finish; do not force-quit
warns “headheight too small” & Template default is too small & Add to the preamble
npm install -g fails on permissions & PowerShell execution policy & Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
pip install is slow or times out & Default index is overseas & pip config set``global.index-url``https://pypi.tuna.``tsinghua.edu.cn/simple
python is not recognised & Add to PATH was not ticked & Reinstall and tick it, or add C:\Users\<you>``\AppData\Local\``Programs\Python\Python312 to PATH
OpenCLI extension not connected & Chrome extension not enabled & Run opencli setup to re-pair, then opencli doctor to self-check
fails & Node too old / registry problem & Upgrade to Node LTS;\

A.3 Standard research folder structure (paired with §1.5/§2.6) ​

my_research_project/
+-- README.md                  # one-page project description
+-- data/
|   +-- raw/                   # raw data (read-only, never modified)
|   +-- clean/                 # cleaned data (produced by do-files)
|   +-- derived/               # intermediate products (merged tables/subsamples)
+-- do/                        # Stata do-files (named by chapter)
|   +-- 01_clean.do
|   +-- 02_explore.do
|   +-- 03_regress.do
|   +-- 04_diag.do
|   +-- 05_export.do
+-- output/
|   +-- tables/                # regression tables (.tex / .rtf)
|   +-- figures/               # figures (.png / .pdf)
|   +-- logs/                  # Stata logs (timestamped)
+-- docs/                      # research design, questionnaires, notes
+-- manuscript/                # thesis text (.tex / .docx)
+-- references/
    +-- rural_finance_30papers.bib
    +-- pdfs/

Golden rule: data/raw/ read-only + do/ fully reproducible + output/logs/ timestamped—only with all three in place do you pass the S8.1 / S9.3 integrity checks.


A.4 Quick reference to the MCP / Skill / CLI three-layer paradigm (paired with §1.3c) ​

A.4.1 Five-dimension comparison of the three paradigms ​

Table A.7 Five-dimension comparison of the three paradigms.

L4|L4|L4|L4

Dimension & MCP (connection layer) & Skill (knowledge layer) & CLI (execution layer)
Essence & A connection protocol & A domain-knowledge file & A shell command
Analogy & A USB-C port & An operations manual & A universal remote
Form & JSON-RPC server & Markdown file (SKILL.md) & Shell command
Development cost & High (a server must be written) & Low (write Markdown) & Zero (use directly)
Best for & Enterprise SaaS / databases / remote execution & Knowledge reuse / codifying SOPs & Local automation / batch file processing\

[Tip] Golden combination: CLI (execution) + Skill (knowledge) + MCP (connection) = a complete AI toolchain.

Example: running a regression = stata-mcp (MCP to Stata) + the stata Skill (regression SOP) + officecli (CLI to export Word).

A.4.2 Qoder mcp.json paths on both platforms ​

Table A.8 Qoder mcp.json paths on both platforms.

L2|L2

Platform & Configuration file path
Windows & %APPDATA%\Qoder\``SharedClientCache\``extension\local\``mcp.json
macOS & ~/Library/Application Support/Qoder/SharedClientCache/projects/<project>/mcps/\

△  After adding an MCP server you must restart the Qoder client for it to load (a pitfall verified in practice).

A.4.3 Three ways to launch an MCP server in mcp.json ​

{
  "mcpServers": {
    // Way 1: npx (Node package)
    "stata-mcp": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/stata-mcp"]
    },
    // Way 2: uvx (Python package; pip install uv first)
    "faostat-mcp-server": {
      "command": "uvx",
      "args": ["faostat-mcp-server"]
    },
    // Way 3: local executable / script
    "officecli-mcp": {
      "command": "/Users/yourname/.local/bin/officecli",
      "args": ["mcp"]
    }
  }
}

CNKI boundary reminder (locked in handbook v1.4): this handbook does not cover cnki-mcp configuration; search Chinese literature on the CNKI website yourself and capture metadata with the Zotero jasminum plugin (see Chapter 3, §3.5).

本站教学资源仅供四川农业大学选课学生学习使用,版权归原作者所有,未经授权不得转载、转发或用于商业用途