Skip to content

Commit 92909a8

Browse files
authored
Merge pull request #1 from AElfProject/codex/align-skill-1-5
refactor
2 parents 3498ccf + fe62e6c commit 92909a8

33 files changed

Lines changed: 882 additions & 94 deletions

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ AELF_NODE_TIMEOUT_MS=10000
1313

1414
# Optional retries for REST calls
1515
AELF_NODE_RETRY=1
16+
17+
# Optional cache limits
18+
AELF_SDK_INSTANCE_CACHE_MAX=32
19+
AELF_SDK_CONTRACT_CACHE_MAX=256
20+
AELF_REST_CLIENT_CACHE_MAX=64

.github/workflows/publish.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
name: Publish to npm
22

33
on:
4-
pull_request:
54
push:
6-
branches:
7-
- main
8-
- master
95
tags:
106
- 'v*'
117

@@ -25,15 +21,7 @@ jobs:
2521

2622
- run: bun install
2723

28-
- run: bun run test:unit:coverage:gate
29-
env:
30-
CORE_COVERAGE_THRESHOLD: '70'
31-
32-
- name: Upload coverage to Codecov
33-
uses: codecov/codecov-action@v5
34-
with:
35-
files: ./coverage/lcov.info
36-
fail_ci_if_error: false
24+
- run: bun run test:unit
3725

3826
publish:
3927
if: startsWith(github.ref, 'refs/tags/v')

.github/workflows/test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Unit Test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- master
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
unit-test:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: oven-sh/setup-bun@v2
20+
with:
21+
bun-version: latest
22+
23+
- run: bun install
24+
25+
- run: bun run test:unit:coverage:gate
26+
env:
27+
CORE_COVERAGE_THRESHOLD: '80'
28+
29+
- name: Upload coverage to Codecov
30+
uses: codecov/codecov-action@v5
31+
with:
32+
files: ./coverage/lcov.info
33+
fail_ci_if_error: false

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
AElf Node Skill provides MCP, CLI, and SDK interfaces for AElf public nodes with a `SDK-first + REST fallback` architecture.
5+
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`.
66

77
## Features
88

@@ -85,9 +85,13 @@ cp .env.example .env
8585
```
8686

8787
- `AELF_PRIVATE_KEY`: required for write operations
88+
- `AELF_PRIVATE_KEY` is read from environment only in MCP mode (no private key tool input)
8889
- `AELF_NODE_AELF_RPC_URL`: optional override for AELF node
8990
- `AELF_NODE_TDVV_RPC_URL`: optional override for tDVV node
9091
- `AELF_NODE_REGISTRY_PATH`: optional custom registry path
92+
- `AELF_SDK_INSTANCE_CACHE_MAX`: optional max SDK instance cache size (default `32`)
93+
- `AELF_SDK_CONTRACT_CACHE_MAX`: optional max SDK contract cache size (default `256`)
94+
- `AELF_REST_CLIENT_CACHE_MAX`: optional max REST client cache size (default `64`)
9195

9296
## Tool List
9397

README.zh-CN.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

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

77
## 功能
88

@@ -85,9 +85,13 @@ cp .env.example .env
8585
```
8686

8787
- `AELF_PRIVATE_KEY`:写操作必填
88+
- MCP 模式仅从环境变量读取 `AELF_PRIVATE_KEY`(不接受 tool 入参传私钥)
8889
- `AELF_NODE_AELF_RPC_URL`:可选,覆盖 AELF 节点
8990
- `AELF_NODE_TDVV_RPC_URL`:可选,覆盖 tDVV 节点
9091
- `AELF_NODE_REGISTRY_PATH`:可选,自定义节点注册表路径
92+
- `AELF_SDK_INSTANCE_CACHE_MAX`:可选,SDK 实例缓存上限(默认 `32`
93+
- `AELF_SDK_CONTRACT_CACHE_MAX`:可选,SDK 合约缓存上限(默认 `256`
94+
- `AELF_REST_CLIENT_CACHE_MAX`:可选,REST 客户端缓存上限(默认 `64`
9195

9296
## Tool 列表
9397

bin/check-core-coverage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function parseCoreLineHits(lcovText: string): LineHits {
4646

4747
function main() {
4848
const lcovFile = process.env.CORE_COVERAGE_FILE || 'coverage/lcov.info';
49-
const threshold = Number(process.env.CORE_COVERAGE_THRESHOLD || '70');
49+
const threshold = Number(process.env.CORE_COVERAGE_THRESHOLD || '80');
5050
const lcovPath = resolve(process.cwd(), lcovFile);
5151

5252
if (!existsSync(lcovPath)) {

bin/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const program = new Command();
1919

2020
program
2121
.name('aelf-node-setup')
22-
.description('Configure @aelfproject/aelf-node-skill for Claude/Cursor/OpenClaw')
22+
.description('Configure @blockchain-forever/aelf-node-skill for Claude/Cursor/OpenClaw')
2323
.version('0.1.0');
2424

2525
const withCommonMcpOptions = (command: Command) =>

bun.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export { callContractView, sendContractTransaction } from './src/core/contract.j
1313
export { importNode, listNodes } from './src/core/node-registry.js';
1414

1515
export { resolveNode, listAvailableNodes } from './lib/node-router.js';
16-
export { clearSdkCaches } from './lib/sdk-client.js';
16+
export { clearSdkCaches, clearSdkCacheForRpc } from './lib/sdk-client.js';
1717
export type {
1818
SkillResponse,
1919
SkillError,

lib/aelf-sdk.d.ts

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,55 @@
11
declare module 'aelf-sdk' {
2-
const AElf: any;
2+
export interface AelfWallet {
3+
address: string;
4+
[key: string]: unknown;
5+
}
6+
7+
export interface AelfTxResult {
8+
Status?: string;
9+
[key: string]: unknown;
10+
}
11+
12+
export interface AelfContractMethod {
13+
(params?: Record<string, unknown>): Promise<unknown>;
14+
call?: (params?: Record<string, unknown>) => Promise<unknown>;
15+
getSignedTx?: (params?: Record<string, unknown>) => string;
16+
}
17+
18+
export interface AelfContract {
19+
[methodName: string]: AelfContractMethod | unknown;
20+
}
21+
22+
export interface AelfChainApi {
23+
contractAt(contractAddress: string, wallet: AelfWallet): Promise<AelfContract>;
24+
getTxResult(transactionId: string): Promise<AelfTxResult>;
25+
calculateTransactionFee(rawTransaction: string): Promise<unknown>;
26+
}
27+
28+
export interface AelfInstance {
29+
chain: AelfChainApi;
30+
}
31+
32+
export interface HttpProviderConstructor {
33+
new (rpcUrl: string, timeoutMs?: number): unknown;
34+
}
35+
36+
export interface AelfWalletApi {
37+
createNewWallet(): AelfWallet;
38+
getWalletByPrivateKey(privateKey: string): AelfWallet;
39+
}
40+
41+
export interface AelfStaticApi {
42+
providers: {
43+
HttpProvider: HttpProviderConstructor;
44+
};
45+
wallet: AelfWalletApi;
46+
}
47+
48+
export interface AelfConstructor {
49+
new (provider: unknown): AelfInstance;
50+
}
51+
52+
const AElf: AelfConstructor & AelfStaticApi;
53+
354
export default AElf;
455
}

0 commit comments

Comments
 (0)