Rewrite README install section as a 6-step walkthrough

Replace the terse install summary with a click-by-click guide that
covers the full setup in both README.md and README.zh-CN.md:
clone+pip, GCP service account, moving the key out of the repo,
creating the sheet with header row, writing config.json, and a
sanity check. Flag the zh-CN tab-name gotcha (工作表1 vs Sheet1)
that causes HTTP 400 Unable to parse range.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Knowit
2026-04-20 15:33:36 +08:00
parent db3d96999e
commit a7ba4f313f
2 changed files with 132 additions and 12 deletions

View File

@@ -16,18 +16,78 @@ Intended to be invoked manually inside Claude Code today, and wired up to a What
## Install ## Install
Clone into your Claude Code skills directory: Follow the 6 steps below. Takes ~10 minutes.
### Step 1 — Clone the skill and install Python deps
```bash ```bash
git clone https://git.deepknow.site/Knowit/AutoACCT.git ~/.claude/skills/bookkeeping git clone https://git.deepknow.site/Knowit/AutoACCT.git ~/.claude/skills/bookkeeping
pip install google-api-python-client google-auth
``` ```
Then follow [`scripts/setup.md`](scripts/setup.md) for the one-time setup: ### Step 2 — Create a Google Cloud service account
- Python deps: `pip install google-api-python-client google-auth` 1. Open https://console.cloud.google.com/ and create a new project (e.g. `autoacct`).
- Create a GCP service account + download its JSON key 2. In the top search bar, search **Google Sheets API** → click the result → **Enable**.
- Create a Google Sheet, add 14 header columns, share with the service account email 3. Left menu: **IAM & Admin → Service Accounts → + Create Service Account**
- `cp config.example.json config.json` and fill in `sheet_id` + `service_account_path` - Name: `bookkeeping` (any name works)
- Click **Create and Continue → Done** (skip the optional role step).
4. Click the new service account → **Keys** tab → **Add Key → Create new key → JSON → Create**.
A `.json` key file will download to your browser's Downloads folder.
5. **Copy the service account's email** (looks like `bookkeeping@<project>.iam.gserviceaccount.com`) — you'll paste it in Step 4.
### Step 3 — Move the key file out of the repo
Never leave a service-account key inside the repo directory. Move it to `~/.config/gcp/`:
```bash
mkdir -p ~/.config/gcp
mv ~/Downloads/<your-downloaded-file>.json ~/.config/gcp/bookkeeping-sa.json
chmod 600 ~/.config/gcp/bookkeeping-sa.json
```
### Step 4 — Create the Google Sheet
1. Open https://sheets.new (creates a fresh blank sheet).
2. Give it a title (e.g. `AutoACCT Expenses`).
3. **Note the tab name** at the bottom-left — default is `Sheet1` (English UI) or `工作表1` (Chinese UI). Write it down, you'll need the exact string in Step 5.
4. Click cell **A1**, then paste this one line (the tabs split the headers across AN automatically):
```
Date Merchant Category Amount Currency Amount (HKD) FX Rate FX Date Payment Method Line Items Raw OCR Note Receipt Logged At
```
5. Click **Share** (top right) → paste the service-account email from Step 2 → role **Editor** → **Send** (you can uncheck "Notify people").
6. Copy the **Sheet ID** from the URL — it's the long string between `/d/` and `/edit`:
`https://docs.google.com/spreadsheets/d/`**`1abc...xyz`**`/edit`
### Step 5 — Write config.json
```bash
cd ~/.claude/skills/bookkeeping
cp config.example.json config.json
```
Open `config.json` in your editor and fill in **sheet_id** and **worksheet** with the values from Step 4:
```json
{
"sheet_id": "1abc...xyz",
"worksheet": "Sheet1",
"service_account_path": "~/.config/gcp/bookkeeping-sa.json",
"hkd_fx_provider": "frankfurter"
}
```
> ⚠️ **Common pitfall**: if your Google Sheets UI is in Chinese, the default tab is named `工作表1` (not `Sheet1`). Put `"worksheet": "工作表1"` exactly. A mismatched tab name throws `HTTP 400: Unable to parse range`.
### Step 6 — Sanity check
```bash
echo '{"date":"2026-04-20","merchant":"TEST","category":"Other","amount":1,"currency":"HKD","amount_hkd":1,"fx_rate":1,"fx_date":"2026-04-20"}' | python3 ~/.claude/skills/bookkeeping/scripts/append_row.py
```
Success looks like: `OK 'Sheet1'!A2:N2` and a new row appears in the sheet. Delete the TEST row when you're done.
If you hit an error, see [`scripts/setup.md`](scripts/setup.md) for the longer reference.
## Use ## Use

View File

@@ -16,18 +16,78 @@
## 安装 ## 安装
把仓库 clone 到 Claude Code 的 skills 目录: 按下面 6 步操作,整个过程约 10 分钟。
### Step 1 — Clone 仓库 + 装 Python 依赖
```bash ```bash
git clone https://git.deepknow.site/Knowit/AutoACCT.git ~/.claude/skills/bookkeeping git clone https://git.deepknow.site/Knowit/AutoACCT.git ~/.claude/skills/bookkeeping
pip install google-api-python-client google-auth
``` ```
然后按 [`scripts/setup.md`](scripts/setup.md) 完成一次性配置: ### Step 2 — 建 Google Cloud 服务账号
- 安装 Python 依赖:`pip install google-api-python-client google-auth` 1. 打开 https://console.cloud.google.com/,左上角下拉 → **New Project** → 随便起名(如 `autoacct`)→ Create
- 在 GCP 建服务账号并下载 JSON key 2. 顶部搜索框搜 **Google Sheets API** → 点进去 → **Enable**
- 新建 Google Sheet填好 14 列表头,把 sheet 分享给服务账号的 email 3. 左侧菜单 **IAM & Admin → Service Accounts → + Create Service Account**
- `cp config.example.json config.json`,填入 `sheet_id``service_account_path` - Name 填 `bookkeeping`(随意)
-**Create and Continue → Done**(中间可选的 role 步骤跳过)
4. 点进刚建好的服务账号 → 顶部 **Keys** 标签 → **Add Key → Create new key → 选 JSON → Create**
浏览器会自动下载一个 `.json` 文件到你的 Downloads
5. **复制服务账号的 email**(形如 `bookkeeping@<项目名>.iam.gserviceaccount.com`Step 4 要用
### Step 3 — 把 key 文件挪出 repo
**千万不要**把 key 留在 repo 目录里。挪到 `~/.config/gcp/`
```bash
mkdir -p ~/.config/gcp
mv ~/Downloads/<你下载的文件名>.json ~/.config/gcp/bookkeeping-sa.json
chmod 600 ~/.config/gcp/bookkeeping-sa.json
```
### Step 4 — 建 Google Sheet
1. 打开 https://sheets.new直接创建空白 sheet
2. 给 sheet 起个标题(如 `AutoACCT Expenses`
3. **记住左下角 tab 的名字** — 英文界面默认 `Sheet1`,中文界面默认 `工作表1`。Step 5 要用这个**精确字符串**
4. 点进 **A1** 单元格,粘贴下面这一整行(中间是 Tab 分隔,粘进去会自动拆到 A1N1
```
Date Merchant Category Amount Currency Amount (HKD) FX Rate FX Date Payment Method Line Items Raw OCR Note Receipt Logged At
```
5. 右上角 **Share** → 粘贴 Step 2 复制的服务账号 email → 权限选 **Editor** → **Send**"Notify people" 可以不勾)
6. 从 URL 里复制 **Sheet ID** —— `/d/` 和 `/edit` 之间那一长串:
`https://docs.google.com/spreadsheets/d/`**`1abc...xyz`**`/edit`
### Step 5 — 写 config.json
```bash
cd ~/.claude/skills/bookkeeping
cp config.example.json config.json
```
用编辑器打开 `config.json`,把 Step 4 拿到的 **sheet_id** 和 **worksheet**tab 名)填进去:
```json
{
"sheet_id": "1abc...xyz",
"worksheet": "Sheet1",
"service_account_path": "~/.config/gcp/bookkeeping-sa.json",
"hkd_fx_provider": "frankfurter"
}
```
> ⚠️ **常见坑**:如果你的 Google Sheets 界面是中文,默认 tab 名是 `工作表1`**不是** `Sheet1`。必须写成 `"worksheet": "工作表1"`。tab 名不对会报 `HTTP 400: Unable to parse range`。
### Step 6 — 冒烟测试
```bash
echo '{"date":"2026-04-20","merchant":"TEST","category":"Other","amount":1,"currency":"HKD","amount_hkd":1,"fx_rate":1,"fx_date":"2026-04-20"}' | python3 ~/.claude/skills/bookkeeping/scripts/append_row.py
```
看到 `OK 'Sheet1'!A2:N2`(或中文 tab 名)并且 sheet 第 2 行出现 TEST就全通了。完事记得把这行测试数据删掉。
遇到报错可以参考 [`scripts/setup.md`](scripts/setup.md) 的详细版。
## 使用 ## 使用