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
33 changes: 33 additions & 0 deletions .github/workflows/coverage-badge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Coverage Badge

on:
push:
branches:
- main
- master
workflow_dispatch:

permissions:
contents: write

jobs:
coverage-badge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- run: bun install
- run: bun run test:coverage:ci
- run: bun run coverage:badge
- run: touch badge/.nojekyll

- name: Deploy coverage badge to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./badge
publish_branch: gh-pages
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
bun-version: latest

- run: bun install

- run: bun run test:unit
- run: bun run test:coverage:ci
- run: bun run build:openclaw:check

publish:
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ permissions:
jobs:
unit-test:
runs-on: ubuntu-latest
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- uses: actions/checkout@v4

Expand All @@ -21,13 +23,17 @@ jobs:
bun-version: latest

- run: bun install

- run: bun run test:unit:coverage:gate
env:
CORE_COVERAGE_THRESHOLD: '80'
- run: bun run test:coverage:ci
- run: bun run build:openclaw:check

- name: Upload coverage to Codecov
if: ${{ env.CODECOV_TOKEN != '' }}
uses: codecov/codecov-action@v5
with:
token: ${{ env.CODECOV_TOKEN }}
files: ./coverage/lcov.info
fail_ci_if_error: false
fail_ci_if_error: true

- name: Skip Codecov upload (missing token)
if: ${{ env.CODECOV_TOKEN == '' }}
run: echo "CODECOV_TOKEN is not set; skipping Codecov upload."
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

[English](./README.md) | [中文](./README.zh-CN.md)

[![Unit Tests](https://github.com/AElfProject/aelf-node-skill/actions/workflows/test.yml/badge.svg)](https://github.com/AElfProject/aelf-node-skill/actions/workflows/test.yml)
[![Coverage](https://img.shields.io/endpoint?url=https://AElfProject.github.io/aelf-node-skill/coverage.json)](https://AElfProject.github.io/aelf-node-skill/coverage.json)

AElf Node Skill provides MCP, CLI, and SDK interfaces for AElf public nodes with `REST for reads, SDK for contract execution, and selective fallback for fee estimate`.

## Features
Expand All @@ -23,6 +26,27 @@ AElf Node Skill provides MCP, CLI, and SDK interfaces for AElf public nodes with
bun install
```

## Usage

### MCP

```bash
bun run mcp
```

### CLI

```bash
bun run cli get-chain-status --chain-id AELF
```

### OpenClaw

```bash
bun run build:openclaw
bun run build:openclaw:check
```

## Quick Start

```bash
Expand Down Expand Up @@ -118,3 +142,19 @@ MCP tool names:
- `src/mcp/server.ts`: MCP adapter
- `aelf_node_skill.ts`: CLI adapter
- `index.ts`: SDK exports

## Testing

```bash
bun run test
bun run test:coverage:ci
```

## Security

- Never put `AELF_PRIVATE_KEY` in prompts or channel outputs.
- Use environment variables for all secrets.

## License

MIT
40 changes: 40 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

[中文](./README.zh-CN.md) | [English](./README.md)

[![Unit Tests](https://github.com/AElfProject/aelf-node-skill/actions/workflows/test.yml/badge.svg)](https://github.com/AElfProject/aelf-node-skill/actions/workflows/test.yml)
[![Coverage](https://img.shields.io/endpoint?url=https://AElfProject.github.io/aelf-node-skill/coverage.json)](https://AElfProject.github.io/aelf-node-skill/coverage.json)

AElf Node Skill 提供 MCP、CLI、SDK 三种接口,采用“读走 REST、合约执行走 SDK、手续费估算选择性 fallback”的架构访问 AElf 公共节点。

## 功能
Expand All @@ -23,6 +26,27 @@ AElf Node Skill 提供 MCP、CLI、SDK 三种接口,采用“读走 REST、合
bun install
```

## 使用方式

### MCP

```bash
bun run mcp
```

### CLI

```bash
bun run cli get-chain-status --chain-id AELF
```

### OpenClaw

```bash
bun run build:openclaw
bun run build:openclaw:check
```

## 快速开始

```bash
Expand Down Expand Up @@ -118,3 +142,19 @@ MCP tool 名称:
- `src/mcp/server.ts`:MCP 入口
- `aelf_node_skill.ts`:CLI 入口
- `index.ts`:SDK 导出

## 测试

```bash
bun run test
bun run test:coverage:ci
```

## 安全

- 不要在对话输出中暴露 `AELF_PRIVATE_KEY`。
- 所有密钥均通过环境变量管理。

## License

MIT
32 changes: 32 additions & 0 deletions SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: "aelf-node-skill"
description: "AElf node querying and contract execution skill for agents."
---

# AElf Node Skill

## When to use
- Use this skill when you need AElf chain query, contract view/send, and fee estimation tasks.

## Capabilities
- Chain reads: status, block, transaction result, metadata
- Contract operations: view call and transaction sending
- Node registry import/list with REST-first and SDK fallback strategy
- Supports SDK, CLI, MCP, and OpenClaw integration from one codebase.

## Safe usage rules
- Never print private keys, mnemonics, or tokens in channel outputs.
- For write operations, require explicit user confirmation and validate parameters before sending transactions.
- Prefer `simulate` or read-only queries first when available.

## Command recipes
- Start MCP server: `bun run mcp`
- Run CLI entry: `bun run cli`
- Generate OpenClaw config: `bun run build:openclaw`
- Verify OpenClaw config: `bun run build:openclaw:check`
- Run CI coverage gate: `bun run test:coverage:ci`

## Limits / Non-goals
- This skill focuses on domain operations and adapters; it is not a full wallet custody system.
- Do not hardcode environment secrets in source code or docs.
- Avoid bypassing validation for external service calls.
44 changes: 44 additions & 0 deletions bin/generate-coverage-badge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bun
import * as fs from 'node:fs';
import * as path from 'node:path';

const root = path.resolve(import.meta.dir, '..');
const lcovPath = path.join(root, 'coverage', 'lcov.info');
const outputDir = path.join(root, 'badge');
const outputPath = path.join(outputDir, 'coverage.json');

if (!fs.existsSync(lcovPath)) {
process.stderr.write(`[ERROR] lcov not found: ${lcovPath}\n`);
process.exit(1);
}

const lcov = fs.readFileSync(lcovPath, 'utf-8');
let linesFound = 0;
let linesHit = 0;

for (const line of lcov.split('\n')) {
if (line.startsWith('LF:')) linesFound += Number(line.slice(3)) || 0;
if (line.startsWith('LH:')) linesHit += Number(line.slice(3)) || 0;
}

const coverage = linesFound > 0 ? (linesHit / linesFound) * 100 : 0;
const rounded = Math.round(coverage * 100) / 100;

let color = 'red';
if (rounded >= 90) color = 'brightgreen';
else if (rounded >= 80) color = 'green';
else if (rounded >= 70) color = 'yellowgreen';
else if (rounded >= 60) color = 'yellow';
else if (rounded >= 50) color = 'orange';

const badge = {
schemaVersion: 1,
label: 'coverage',
message: `${rounded}%`,
color,
generatedAt: new Date().toISOString(),
};

fs.mkdirSync(outputDir, { recursive: true });
fs.writeFileSync(outputPath, `${JSON.stringify(badge, null, 2)}\n`, 'utf-8');
process.stdout.write(`[OK] Coverage badge generated: ${outputPath} (${badge.message})\n`);
Loading