Skip to content
Merged
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
22 changes: 0 additions & 22 deletions .claude/commands/commit.md

This file was deleted.

94 changes: 0 additions & 94 deletions .claude/commands/linux-native-binding-repair.md

This file was deleted.

40 changes: 40 additions & 0 deletions .claude/skills/commit/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: commit
description: '根据当前仓库改动生成并执行规范化 Git 提交。Use when committing current changes, generating a conventional commit message, or preparing a repo commit after validation.'
argument-hint: '可选填写 subject,skill 会继续自动推断 type 和 scope'
user-invocable: true
---

# Commit Skill

## 适用场景

- 需要为当前仓库执行一次规范化 Git 提交
- 需要根据暂存区差异自动生成 commit message
- 用户只给出 subject,希望自动补全 type 和 scope

## 执行步骤

1. 顺序执行 `npm run build -- --force`、`npm run lint`、`npm run test`。
2. 如果任意命令失败,停止提交,说明失败点,并给出修复建议。
3. 阅读仓库规范文件 [docs/git-commit-message-standard.md](../../../docs/git-commit-message-standard.md)。
4. 检查当前 staged 变更。
5. 如果没有 staged 变更,先将当前工作区改动加入暂存区。
6. 如果 staged 或当前工作区改动中包含 `package.json` 或 `package-lock.json`,需要检查变更内容:
- 如果 `package-lock.json` 有修改 **或者** `package.json` 的 `dependencies` 或 `devDependencies` 部分有修改,必须先执行 `/linux-native-binding-repair`,确认不存在 Linux native binding、optionalDependencies 或 lockfile 跨平台漂移问题。
- 如果只有 `package.json` 的其他部分(如 scripts、workspaces 等)修改,且 `package-lock.json` 没有修改,则不需要执行 `/linux-native-binding-repair`。
7. 基于暂存区差异生成 commit message,格式必须是 `<type>(<scope>): <subject>`。
8. 如果用户传入参数,将其作为 subject,仍需自动补全 type 和 scope。
9. 执行 git 提交。
10. 返回以下结果:

- 最终 commit message
- 提交 hash
- 变更文件列表

## 约束

- `type` 仅可使用 `feat`、`fix`、`refactor`、`docs`、`style`、`test`、`chore`
- `scope` 优先根据 `src` 目录映射规则推断
- `subject` 使用英文,简洁明确,不加句号
- 不要跳过验证步骤,除非用户显式要求
86 changes: 86 additions & 0 deletions .claude/skills/linux-native-binding-repair/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
name: linux-native-binding-repair
description: '排查并修复 Linux 环境下缺失 native binding、optionalDependencies 或 package-lock 跨平台漂移问题。Use when CI fails on Ubuntu/Linux, act fails on Linux containers, or errors mention missing native bindings.'
argument-hint: '可选填写失败包名、平台、错误信息、失败步骤或 CI 上下文'
user-invocable: true
---

# Linux Native Binding Repair

## 适用场景

- GitHub Actions 在 Ubuntu 上失败,但本地 macOS 正常
- `act` 失败,但本地 `npm run lint`、`npm run test` 或 `npm run build -- --force` 正常
- 错误信息包含 `Cannot find native binding`
- 错误信息包含 `npm has a bug related to optional dependencies`
- 缺少 `@oxlint/binding-linux-x64-gnu`、`@oxfmt/binding-linux-x64-gnu`、`@rolldown/binding-linux-x64-gnu` 或同类平台包
- `package-lock.json` 在 macOS 上生成,Linux CI 无法加载原生二进制

## 执行步骤

1. 先确认失败的包、运行环境和失败步骤。
2. 记录缺失模块名,以及失败发生在 `npm ci`、`lint`、`test` 还是 `build`。
3. 区分 `linux/amd64` 与 `linux/arm64`。
4. 确认 CI 实际平台:
- GitHub Actions 的 `ubuntu-latest` 默认通常是 `linux/amd64`
- Apple Silicon 上的 `act` 可能默认是 `linux/arm64`,除非显式使用 `--container-architecture linux/amd64`
5. 检查根 `package-lock.json`,不要只检查子包 lockfile。
6. 在根 lockfile 中搜索缺失 binding,并确认 `packages` 区域存在真实节点,例如 `node_modules/@scope/binding-linux-x64-gnu`,而不只是 `optionalDependencies` 引用。
7. 运行前先检查本机是否安装 `docker` 与 `act`:
- `command -v docker`
- `command -v act`
8. 如果缺少 Docker,明确说明无法做容器级 Linux 复现,应优先安装 Docker;缺少 `act` 时,可退化为 Docker 验证。
9. 优先使用与 CI 架构一致的 Docker 环境复现。
10. 若要与 GitHub Actions x64 Linux 对齐,优先执行:

```bash
docker run --rm --platform linux/amd64 -v "$PWD":/src:ro node:24.12.0-bookworm bash -lc 'cp -a /src /work && cd /work && npm ci --workspaces --include-workspace-root && npm run lint && npm run test'
```

11. 如果 binding 缺失,继续检查包元数据:
- 查看失败包在 `package-lock.json` 中的 `optionalDependencies`
- 从 npm registry 查询缺失 binding 包元数据:

```bash
npm view @scope/binding-linux-x64-gnu@<version> dist.tarball dist.integrity cpu os engines --json
```

12. 修复根 `package-lock.json`:
- 优先在目标平台上重新生成 lockfile
- 如果 npm 仍未生成所需 `packages` 节点,可手动补齐缺失 Linux binding 节点,至少包含:`version`、`resolved`、`integrity`、`cpu`、`os`、`engines`、`optional: true`
- 如果父包是开发依赖,补 `dev: true`
13. 在目标平台重新验证:
- 重新执行 `npm ci`
- 重新执行此前失败的精确命令
- 必要时单独验证对应 `act` job
14. 区分真实依赖问题与 `act` 兼容性限制:
- 若 `act` 报 `runs.using key ... got node24`,这是 `act` 的运行时兼容性限制,不是 binding 缺失

## 仓库特定说明

- 此仓库已经出现过 `oxfmt`、`oxlint`、`rolldown` 的 Linux binding 缺失问题
- 修复应落在根 `package-lock.json`
- 主 CI 工作流是 `.github/workflows/push.yml`
- 相关复用工作流包括:
- `.github/workflows/monkey_push.yml`
- `.github/workflows/qinglong_push.yml`

## 快速检查清单

- 已确认缺失的包名
- 已确认 CI 架构
- 已检查根 lockfile
- 已确认本机存在 `docker`
- 已确认本机是否存在 `act`
- 已用 Docker 在目标平台复现
- 已从 npm 获取缺失 binding 的元数据
- 已修复或重建根 lockfile
- 已在目标平台重新验证 `npm ci`
- 已区分 `act` 限制与真实依赖故障

## 常见需要检查的包

- `@oxlint/binding-linux-x64-gnu`
- `@oxfmt/binding-linux-x64-gnu`
- `@rolldown/binding-linux-x64-gnu`
- 以及根据 runner 架构变化的其他包,例如 `binding-linux-arm64-gnu`、`binding-linux-x64-musl` 等
15 changes: 11 additions & 4 deletions .github/workflows/caddyfile_sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
- turbo.json

jobs:
caddyfile-sdk-check:
caddyfile-sdk:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -27,15 +27,22 @@ jobs:
with:
node-version: 24.12.0
cache: npm
cache-dependency-path: package-lock.json

- name: Install dependencies
run: npm ci -ws --include-workspace-root

- name: Lint
run: npm run lint -w @arylo/caddyfile-sdk
run: npm run lint
env:
TURBO_FILTER: ./apps/caddyfile-sdk

- name: Test
run: npm run test -w @arylo/caddyfile-sdk
run: npm run test
env:
TURBO_FILTER: ./apps/caddyfile-sdk

- name: Build
run: npm run build -w @arylo/caddyfile-sdk
run: npm run build --ignore-scripts
env:
TURBO_FILTER: ./apps/caddyfile-sdk
6 changes: 6 additions & 0 deletions .github/workflows/monkey_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24.12.0
cache: npm
cache-dependency-path: package-lock.json
- name: Install dependencies
run: npm ci --workspaces --include-workspace-root
- name: Build Scripts
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
with:
node-version: 24.12.0
cache: npm
cache-dependency-path: package-lock.json
- name: Install dependencies
run: npm ci --workspaces --include-workspace-root
- name: Lint
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/qinglong_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24.12.0
cache: npm
cache-dependency-path: package-lock.json
- name: Install dependencies
run: npm ci --workspaces --include-workspace-root
- name: Build Scripts
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ dist/
logs/
.turbo
.DS_Store

.wrangler/
wrangler.*.jsonc
9 changes: 6 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"cSpell.words": [
"arylo"
]
"cSpell.words": [
"arylo"
],
"files.associations": {
"wrangler.json": "jsonc"
}
}
4 changes: 3 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# CLAUDE.md

## Custom Commands
## Claude Skills

- `/commit`:根据当前改动生成并执行规范化 Git 提交
- `/linux-native-binding-repair`:排查并修复 Linux 环境下缺失的 native binding、optionalDependencies 和 package-lock 跨平台漂移问题

以上能力已迁移到 `.claude/skills/`,按 Claude skill 方式维护与发现。
3 changes: 2 additions & 1 deletion apps/caddyfile-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@
"lint:formatter": "oxfmt --check",
"lint:oxlint": "oxlint",
"test": "vitest run src",
"fix": "concurrently -m 1 --timings npm:fix:*",
"fix:formatter": "oxfmt"
},
"devDependencies": {
"concurrently": "^8.2.2",
"oxfmt": "^0.35.0",
"oxlint": "^1.24.0",
"rimraf": "^6.0.1",
"typescript": "^5.4.5",
"typescript": "~5.9.3",
"vitest": "^4.1.0"
}
}
3 changes: 3 additions & 0 deletions apps/cf-worker/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CLAUDE.md

本文件夹下储存运行在Cloudflare worker 下的项目, 每个文件夹都为一个独立的项目.
3 changes: 2 additions & 1 deletion apps/monkey/copymanga-enhance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"concurrently": "^8.2.2",
"oxfmt": "^0.35.0",
"oxlint": "^1.24.0",
"rimraf": "^6.0.1"
"rimraf": "^6.0.1",
"vitest": "^4.1.0"
}
}
1 change: 1 addition & 0 deletions docs/git-commit-message-standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ If there are changes in directories under `apps/`, add the folder name to the sc
- `apps/qinglong/` → `qinglong`
- `apps/monkey/` → `monkey`
- `apps/raspberry_pi/` → `pi`
- `apps/caddyfile-sdk` → `caddyfile`

### Examples

Expand Down
Loading
Loading