agent-bober 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +9 -0
- package/LICENSE +21 -0
- package/README.md +495 -0
- package/agents/bober-evaluator.md +323 -0
- package/agents/bober-generator.md +245 -0
- package/agents/bober-planner.md +248 -0
- package/dist/cli/commands/eval.d.ts +6 -0
- package/dist/cli/commands/eval.d.ts.map +1 -0
- package/dist/cli/commands/eval.js +129 -0
- package/dist/cli/commands/eval.js.map +1 -0
- package/dist/cli/commands/init.d.ts +5 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +547 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/plan.d.ts +5 -0
- package/dist/cli/commands/plan.d.ts.map +1 -0
- package/dist/cli/commands/plan.js +87 -0
- package/dist/cli/commands/plan.js.map +1 -0
- package/dist/cli/commands/run.d.ts +5 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +120 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/sprint.d.ts +6 -0
- package/dist/cli/commands/sprint.d.ts.map +1 -0
- package/dist/cli/commands/sprint.js +206 -0
- package/dist/cli/commands/sprint.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +124 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/defaults.d.ts +15 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +226 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +8 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +18 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +189 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +904 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +181 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/contracts/eval-result.d.ts +205 -0
- package/dist/contracts/eval-result.d.ts.map +1 -0
- package/dist/contracts/eval-result.js +87 -0
- package/dist/contracts/eval-result.js.map +1 -0
- package/dist/contracts/index.d.ts +4 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +16 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/spec.d.ts +101 -0
- package/dist/contracts/spec.d.ts.map +1 -0
- package/dist/contracts/spec.js +51 -0
- package/dist/contracts/spec.js.map +1 -0
- package/dist/contracts/sprint-contract.d.ts +141 -0
- package/dist/contracts/sprint-contract.d.ts.map +1 -0
- package/dist/contracts/sprint-contract.js +80 -0
- package/dist/contracts/sprint-contract.js.map +1 -0
- package/dist/evaluators/builtin/api-check.d.ts +13 -0
- package/dist/evaluators/builtin/api-check.d.ts.map +1 -0
- package/dist/evaluators/builtin/api-check.js +152 -0
- package/dist/evaluators/builtin/api-check.js.map +1 -0
- package/dist/evaluators/builtin/build-check.d.ts +17 -0
- package/dist/evaluators/builtin/build-check.d.ts.map +1 -0
- package/dist/evaluators/builtin/build-check.js +155 -0
- package/dist/evaluators/builtin/build-check.js.map +1 -0
- package/dist/evaluators/builtin/command-runner.d.ts +26 -0
- package/dist/evaluators/builtin/command-runner.d.ts.map +1 -0
- package/dist/evaluators/builtin/command-runner.js +114 -0
- package/dist/evaluators/builtin/command-runner.js.map +1 -0
- package/dist/evaluators/builtin/lint.d.ts +17 -0
- package/dist/evaluators/builtin/lint.d.ts.map +1 -0
- package/dist/evaluators/builtin/lint.js +264 -0
- package/dist/evaluators/builtin/lint.js.map +1 -0
- package/dist/evaluators/builtin/playwright.d.ts +16 -0
- package/dist/evaluators/builtin/playwright.d.ts.map +1 -0
- package/dist/evaluators/builtin/playwright.js +238 -0
- package/dist/evaluators/builtin/playwright.js.map +1 -0
- package/dist/evaluators/builtin/typescript-check.d.ts +12 -0
- package/dist/evaluators/builtin/typescript-check.d.ts.map +1 -0
- package/dist/evaluators/builtin/typescript-check.js +155 -0
- package/dist/evaluators/builtin/typescript-check.js.map +1 -0
- package/dist/evaluators/builtin/unit-test.d.ts +18 -0
- package/dist/evaluators/builtin/unit-test.d.ts.map +1 -0
- package/dist/evaluators/builtin/unit-test.js +279 -0
- package/dist/evaluators/builtin/unit-test.js.map +1 -0
- package/dist/evaluators/index.d.ts +11 -0
- package/dist/evaluators/index.d.ts.map +1 -0
- package/dist/evaluators/index.js +13 -0
- package/dist/evaluators/index.js.map +1 -0
- package/dist/evaluators/plugin-interface.d.ts +50 -0
- package/dist/evaluators/plugin-interface.d.ts.map +1 -0
- package/dist/evaluators/plugin-interface.js +2 -0
- package/dist/evaluators/plugin-interface.js.map +1 -0
- package/dist/evaluators/plugin-loader.d.ts +18 -0
- package/dist/evaluators/plugin-loader.d.ts.map +1 -0
- package/dist/evaluators/plugin-loader.js +107 -0
- package/dist/evaluators/plugin-loader.js.map +1 -0
- package/dist/evaluators/registry.d.ts +78 -0
- package/dist/evaluators/registry.d.ts.map +1 -0
- package/dist/evaluators/registry.js +238 -0
- package/dist/evaluators/registry.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestrator/context-handoff.d.ts +543 -0
- package/dist/orchestrator/context-handoff.d.ts.map +1 -0
- package/dist/orchestrator/context-handoff.js +133 -0
- package/dist/orchestrator/context-handoff.js.map +1 -0
- package/dist/orchestrator/evaluator-agent.d.ts +15 -0
- package/dist/orchestrator/evaluator-agent.d.ts.map +1 -0
- package/dist/orchestrator/evaluator-agent.js +233 -0
- package/dist/orchestrator/evaluator-agent.js.map +1 -0
- package/dist/orchestrator/generator-agent.d.ts +16 -0
- package/dist/orchestrator/generator-agent.d.ts.map +1 -0
- package/dist/orchestrator/generator-agent.js +147 -0
- package/dist/orchestrator/generator-agent.js.map +1 -0
- package/dist/orchestrator/pipeline.d.ts +24 -0
- package/dist/orchestrator/pipeline.d.ts.map +1 -0
- package/dist/orchestrator/pipeline.js +290 -0
- package/dist/orchestrator/pipeline.js.map +1 -0
- package/dist/orchestrator/planner-agent.d.ts +10 -0
- package/dist/orchestrator/planner-agent.d.ts.map +1 -0
- package/dist/orchestrator/planner-agent.js +187 -0
- package/dist/orchestrator/planner-agent.js.map +1 -0
- package/dist/state/helpers.d.ts +5 -0
- package/dist/state/helpers.d.ts.map +1 -0
- package/dist/state/helpers.js +8 -0
- package/dist/state/helpers.js.map +1 -0
- package/dist/state/history.d.ts +39 -0
- package/dist/state/history.d.ts.map +1 -0
- package/dist/state/history.js +162 -0
- package/dist/state/history.js.map +1 -0
- package/dist/state/index.d.ts +8 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +22 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/plan-state.d.ts +21 -0
- package/dist/state/plan-state.d.ts.map +1 -0
- package/dist/state/plan-state.js +108 -0
- package/dist/state/plan-state.js.map +1 -0
- package/dist/state/sprint-state.d.ts +20 -0
- package/dist/state/sprint-state.d.ts.map +1 -0
- package/dist/state/sprint-state.js +98 -0
- package/dist/state/sprint-state.js.map +1 -0
- package/dist/utils/fs.d.ts +31 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +67 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/git.d.ts +35 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +84 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +45 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +73 -0
- package/dist/utils/logger.js.map +1 -0
- package/hooks/hooks.json +10 -0
- package/package.json +67 -0
- package/scripts/detect-stack.sh +287 -0
- package/scripts/init-project.sh +206 -0
- package/scripts/run-eval.sh +175 -0
- package/skills/bober.anchor/SKILL.md +365 -0
- package/skills/bober.anchor/references/anchor-guide.md +567 -0
- package/skills/bober.brownfield/SKILL.md +422 -0
- package/skills/bober.brownfield/references/codebase-analysis.md +304 -0
- package/skills/bober.eval/SKILL.md +235 -0
- package/skills/bober.eval/references/eval-strategies.md +407 -0
- package/skills/bober.eval/references/feedback-format.md +182 -0
- package/skills/bober.plan/SKILL.md +244 -0
- package/skills/bober.plan/references/clarification-guide.md +124 -0
- package/skills/bober.plan/references/spec-schema.md +253 -0
- package/skills/bober.react/SKILL.md +330 -0
- package/skills/bober.react/references/react-scaffold.md +344 -0
- package/skills/bober.run/SKILL.md +303 -0
- package/skills/bober.solidity/SKILL.md +416 -0
- package/skills/bober.solidity/references/solidity-guide.md +487 -0
- package/skills/bober.sprint/SKILL.md +280 -0
- package/skills/bober.sprint/references/contract-schema.md +251 -0
- package/templates/base/CLAUDE.md +20 -0
- package/templates/base/bober.config.json +35 -0
- package/templates/brownfield/CLAUDE.md +34 -0
- package/templates/brownfield/bober.config.json +37 -0
- package/templates/presets/anchor/CLAUDE.md +163 -0
- package/templates/presets/anchor/bober.config.json +9 -0
- package/templates/presets/api-node/CLAUDE.md +153 -0
- package/templates/presets/api-node/bober.config.json +10 -0
- package/templates/presets/nextjs/CLAUDE.md +82 -0
- package/templates/presets/nextjs/bober.config.json +14 -0
- package/templates/presets/python-api/CLAUDE.md +202 -0
- package/templates/presets/python-api/bober.config.json +9 -0
- package/templates/presets/react-vite/CLAUDE.md +71 -0
- package/templates/presets/react-vite/bober.config.json +53 -0
- package/templates/presets/react-vite/scaffold/package.json +45 -0
- package/templates/presets/react-vite/scaffold/server/index.ts +38 -0
- package/templates/presets/react-vite/scaffold/server/tsconfig.json +24 -0
- package/templates/presets/react-vite/scaffold/src/App.tsx +37 -0
- package/templates/presets/react-vite/scaffold/src/index.html +12 -0
- package/templates/presets/react-vite/scaffold/src/main.tsx +12 -0
- package/templates/presets/react-vite/scaffold/tsconfig.json +27 -0
- package/templates/presets/react-vite/scaffold/vite.config.ts +34 -0
- package/templates/presets/solidity/CLAUDE.md +106 -0
- package/templates/presets/solidity/bober.config.json +9 -0
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bober.solidity
|
|
3
|
+
description: "EVM smart contract development workflow. Scaffolds Hardhat or Foundry projects, plans contract architecture, implements with security best practices, and evaluates with compilation, linting, and test coverage. Use when building Solidity smart contracts, DeFi protocols, NFT projects, or DAOs."
|
|
4
|
+
argument-hint: <contract-description>
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# bober.solidity — EVM Smart Contract Workflow
|
|
8
|
+
|
|
9
|
+
You are running the **bober.solidity** skill. This is a specialized workflow for building Solidity smart contracts targeting the Ethereum Virtual Machine (EVM). It covers project scaffolding, contract architecture planning, implementation with security best practices, and evaluation using compilation, linting, testing, and gas analysis.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
Use `bober.solidity` when:
|
|
14
|
+
- Building new EVM smart contracts from scratch (greenfield)
|
|
15
|
+
- Adding contracts or features to an existing Hardhat/Foundry project
|
|
16
|
+
- The project involves: Solidity contracts, DeFi protocols, NFT collections, DAOs, token launches, or any EVM-compatible chain deployment
|
|
17
|
+
|
|
18
|
+
For non-Solidity blockchain work (e.g., Solana/Anchor), use `bober.anchor`. For general projects, use `bober.run`.
|
|
19
|
+
|
|
20
|
+
## Stack Assumptions
|
|
21
|
+
|
|
22
|
+
This skill is optimized for:
|
|
23
|
+
- **Language:** Solidity 0.8.x+
|
|
24
|
+
- **Frameworks:** Hardhat (TypeScript) or Foundry (Rust tooling)
|
|
25
|
+
- **Libraries:** OpenZeppelin Contracts, Solmate, or custom implementations
|
|
26
|
+
- **Testing:** Hardhat tests (Mocha/Chai + ethers.js) or Foundry tests (Solidity-based with forge)
|
|
27
|
+
- **Linting:** solhint
|
|
28
|
+
- **Deployment:** Hardhat Ignition, Foundry scripts, or custom deploy scripts
|
|
29
|
+
- **Verification:** Etherscan/Sourcify verification
|
|
30
|
+
|
|
31
|
+
If the user's stack differs, adapt accordingly. These are defaults, not requirements.
|
|
32
|
+
|
|
33
|
+
## Step 1: Project Assessment
|
|
34
|
+
|
|
35
|
+
### Greenfield (New Project)
|
|
36
|
+
|
|
37
|
+
If there is no `hardhat.config.ts`, `hardhat.config.js`, or `foundry.toml` in the project:
|
|
38
|
+
|
|
39
|
+
1. Ask the user to describe their contract/protocol
|
|
40
|
+
2. Ask clarifying questions specific to Solidity projects:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
**Q1: Development Framework**
|
|
44
|
+
A) Hardhat (TypeScript, most popular, large plugin ecosystem)
|
|
45
|
+
B) Foundry (Rust tooling, Solidity-native tests, faster compilation)
|
|
46
|
+
C) Both (Hardhat for deployment/scripts, Foundry for testing)
|
|
47
|
+
|
|
48
|
+
**Q2: Contract Type**
|
|
49
|
+
A) Token (ERC-20, ERC-721, ERC-1155)
|
|
50
|
+
B) DeFi protocol (AMM, lending, staking, vault)
|
|
51
|
+
C) Governance (Governor, Timelock, multisig)
|
|
52
|
+
D) Custom application logic
|
|
53
|
+
E) Upgradeable contracts (proxy pattern)
|
|
54
|
+
|
|
55
|
+
**Q3: Security Libraries**
|
|
56
|
+
A) OpenZeppelin Contracts (battle-tested, most audited)
|
|
57
|
+
B) Solmate (gas-optimized, minimal)
|
|
58
|
+
C) Custom implementations (for advanced use cases)
|
|
59
|
+
D) Mix of the above
|
|
60
|
+
|
|
61
|
+
**Q4: Target Chain**
|
|
62
|
+
A) Ethereum mainnet
|
|
63
|
+
B) L2 (Optimism, Arbitrum, Base, zkSync)
|
|
64
|
+
C) EVM-compatible L1 (Polygon, Avalanche, BSC)
|
|
65
|
+
D) Multi-chain deployment
|
|
66
|
+
E) Testnet only for now
|
|
67
|
+
|
|
68
|
+
**Q5: Upgradeability**
|
|
69
|
+
A) Immutable contracts (simpler, more trustless)
|
|
70
|
+
B) Transparent Proxy (OpenZeppelin)
|
|
71
|
+
C) UUPS Proxy (OpenZeppelin)
|
|
72
|
+
D) Diamond/EIP-2535 (multi-facet proxy)
|
|
73
|
+
E) Not sure yet
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
3. After answers, scaffold the project using the appropriate framework
|
|
77
|
+
|
|
78
|
+
### Brownfield (Existing Solidity Project)
|
|
79
|
+
|
|
80
|
+
If `hardhat.config.ts`, `hardhat.config.js`, or `foundry.toml` exists:
|
|
81
|
+
|
|
82
|
+
1. Analyze the existing setup:
|
|
83
|
+
- Read the framework config file
|
|
84
|
+
- Check `package.json` (Hardhat) or `foundry.toml` (Foundry) for dependencies
|
|
85
|
+
- Read `contracts/` or `src/` directory for existing contracts
|
|
86
|
+
- Check for OpenZeppelin imports, Solmate imports, or custom base contracts
|
|
87
|
+
- Check for existing tests in `test/` or `test/` directories
|
|
88
|
+
- Check for deployment scripts in `scripts/`, `deploy/`, or `script/`
|
|
89
|
+
- Read any existing `.sol` interfaces for contract architecture
|
|
90
|
+
|
|
91
|
+
2. Survey the contract architecture:
|
|
92
|
+
- Map contract inheritance hierarchies
|
|
93
|
+
- Identify access control patterns (Ownable, AccessControl, custom)
|
|
94
|
+
- Check for proxy/upgrade patterns
|
|
95
|
+
- List external contract integrations (oracles, DEXs, lending protocols)
|
|
96
|
+
|
|
97
|
+
3. Skip scaffolding -- proceed directly to planning
|
|
98
|
+
|
|
99
|
+
## Step 2: Initialize Configuration
|
|
100
|
+
|
|
101
|
+
Create or update `bober.config.json` with Solidity-optimized defaults:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"project": {
|
|
106
|
+
"name": "<project-name>",
|
|
107
|
+
"mode": "greenfield",
|
|
108
|
+
"preset": "solidity",
|
|
109
|
+
"description": "<user's contract description>"
|
|
110
|
+
},
|
|
111
|
+
"planner": {
|
|
112
|
+
"maxClarifications": 5,
|
|
113
|
+
"model": "opus",
|
|
114
|
+
"contextFiles": [
|
|
115
|
+
"hardhat.config.ts",
|
|
116
|
+
"foundry.toml",
|
|
117
|
+
"contracts/",
|
|
118
|
+
"src/"
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
"generator": {
|
|
122
|
+
"model": "sonnet",
|
|
123
|
+
"maxTurnsPerSprint": 50,
|
|
124
|
+
"autoCommit": true,
|
|
125
|
+
"branchPattern": "bober/{feature-name}"
|
|
126
|
+
},
|
|
127
|
+
"evaluator": {
|
|
128
|
+
"model": "sonnet",
|
|
129
|
+
"strategies": [
|
|
130
|
+
{ "type": "build", "required": true },
|
|
131
|
+
{ "type": "lint", "required": true },
|
|
132
|
+
{ "type": "unit-test", "required": true }
|
|
133
|
+
],
|
|
134
|
+
"maxIterations": 3
|
|
135
|
+
},
|
|
136
|
+
"sprint": {
|
|
137
|
+
"maxSprints": 10,
|
|
138
|
+
"requireContracts": true,
|
|
139
|
+
"sprintSize": "medium"
|
|
140
|
+
},
|
|
141
|
+
"pipeline": {
|
|
142
|
+
"maxIterations": 20,
|
|
143
|
+
"requireApproval": false,
|
|
144
|
+
"contextReset": "always"
|
|
145
|
+
},
|
|
146
|
+
"commands": {
|
|
147
|
+
"install": "npm install",
|
|
148
|
+
"build": "npx hardhat compile",
|
|
149
|
+
"test": "npx hardhat test",
|
|
150
|
+
"lint": "npx solhint 'contracts/**/*.sol'",
|
|
151
|
+
"dev": ""
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
For Foundry projects, adjust commands:
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"commands": {
|
|
160
|
+
"install": "forge install",
|
|
161
|
+
"build": "forge build",
|
|
162
|
+
"test": "forge test -vvv",
|
|
163
|
+
"lint": "npx solhint 'src/**/*.sol'",
|
|
164
|
+
"dev": ""
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Adjust based on what actually exists in the project.
|
|
170
|
+
|
|
171
|
+
## Step 3: Scaffold (Greenfield Only)
|
|
172
|
+
|
|
173
|
+
For new projects, create the initial project structure.
|
|
174
|
+
|
|
175
|
+
### Hardhat Scaffolding
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
npx hardhat init # Select TypeScript project
|
|
179
|
+
npm install --save-dev @openzeppelin/contracts solhint
|
|
180
|
+
npm install --save-dev @nomicfoundation/hardhat-toolbox
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Create project structure:
|
|
184
|
+
```
|
|
185
|
+
contracts/
|
|
186
|
+
interfaces/
|
|
187
|
+
libraries/
|
|
188
|
+
mocks/
|
|
189
|
+
test/
|
|
190
|
+
unit/
|
|
191
|
+
integration/
|
|
192
|
+
scripts/
|
|
193
|
+
deploy/
|
|
194
|
+
.solhint.json
|
|
195
|
+
hardhat.config.ts
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Create `.solhint.json`:
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"extends": "solhint:recommended",
|
|
202
|
+
"rules": {
|
|
203
|
+
"compiler-version": ["error", "^0.8.20"],
|
|
204
|
+
"func-visibility": ["warn", { "ignoreConstructors": true }],
|
|
205
|
+
"not-rely-on-time": "warn",
|
|
206
|
+
"reason-string": ["warn", { "maxLength": 64 }]
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Foundry Scaffolding
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
forge init . --no-commit
|
|
215
|
+
forge install OpenZeppelin/openzeppelin-contracts
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Create project structure:
|
|
219
|
+
```
|
|
220
|
+
src/
|
|
221
|
+
interfaces/
|
|
222
|
+
libraries/
|
|
223
|
+
test/
|
|
224
|
+
unit/
|
|
225
|
+
integration/
|
|
226
|
+
mocks/
|
|
227
|
+
script/
|
|
228
|
+
foundry.toml
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Common Setup
|
|
232
|
+
|
|
233
|
+
1. Configure Solidity compiler version in the framework config
|
|
234
|
+
2. Set up remappings for imports (Foundry: `remappings.txt`, Hardhat: paths in config)
|
|
235
|
+
3. Create an initial `.gitignore` with `node_modules/`, `artifacts/`, `cache/`, `out/`, `lib/` (as appropriate)
|
|
236
|
+
4. Create initial git commit:
|
|
237
|
+
```bash
|
|
238
|
+
git init
|
|
239
|
+
git add -A
|
|
240
|
+
git commit -m "chore: initial scaffold from bober.solidity"
|
|
241
|
+
```
|
|
242
|
+
5. Verify the scaffold compiles:
|
|
243
|
+
```bash
|
|
244
|
+
npx hardhat compile # or: forge build
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Step 4: Plan the Feature
|
|
248
|
+
|
|
249
|
+
Run the full planning workflow with Solidity-specific enhancements:
|
|
250
|
+
|
|
251
|
+
### Contract Architecture Planning
|
|
252
|
+
|
|
253
|
+
When planning a smart contract feature, consider:
|
|
254
|
+
|
|
255
|
+
1. **State variables:** What data does the contract store? What are the types? Storage layout matters for upgradeable contracts.
|
|
256
|
+
2. **Functions:** What are the external/public functions? What are the access control requirements for each?
|
|
257
|
+
3. **Events:** What events should be emitted for off-chain indexing?
|
|
258
|
+
4. **Errors:** Custom errors (gas-efficient) vs require strings?
|
|
259
|
+
5. **Modifiers:** What reusable checks are needed?
|
|
260
|
+
6. **Inheritance:** What base contracts to inherit from (OpenZeppelin, custom)?
|
|
261
|
+
7. **Interfaces:** Define interfaces first for clean architecture and testing.
|
|
262
|
+
8. **Upgrade patterns:** If upgradeable, plan storage layout carefully (no storage collisions).
|
|
263
|
+
|
|
264
|
+
### Solidity-Specific Sprint Ordering
|
|
265
|
+
|
|
266
|
+
For a typical smart contract feature:
|
|
267
|
+
|
|
268
|
+
1. **Interface and type definitions first:** Define the contract interface (`.sol` interface file), custom errors, events, and structs. This establishes the contract's API before implementation.
|
|
269
|
+
2. **Core contract logic:** Implement the main contract with state variables, constructor, and core functions. Inherit from base contracts (OpenZeppelin).
|
|
270
|
+
3. **Access control and modifiers:** Implement role-based access, pausability, and custom modifiers.
|
|
271
|
+
4. **Integration points:** Cross-contract calls (CPI), oracle integrations, DEX interactions.
|
|
272
|
+
5. **Testing:** Unit tests for every function, edge case tests, access control tests, gas benchmarks.
|
|
273
|
+
6. **Deployment and verification:** Deploy scripts, constructor argument encoding, Etherscan verification.
|
|
274
|
+
|
|
275
|
+
### Solidity-Specific Success Criteria
|
|
276
|
+
|
|
277
|
+
Include these for every contract sprint:
|
|
278
|
+
|
|
279
|
+
- "The contract compiles without errors or warnings using solc"
|
|
280
|
+
- "All functions have correct visibility modifiers (no unintended public functions)"
|
|
281
|
+
- "All state-changing functions emit appropriate events"
|
|
282
|
+
- "Access control is enforced: only authorized roles can call restricted functions"
|
|
283
|
+
- "Custom errors are used instead of require strings for gas efficiency"
|
|
284
|
+
- "All external/public functions have NatSpec documentation (@dev, @param, @return)"
|
|
285
|
+
- "Tests achieve 100% line coverage for new contract code"
|
|
286
|
+
- "No reentrancy vulnerabilities: state changes happen before external calls, or ReentrancyGuard is used"
|
|
287
|
+
|
|
288
|
+
### Solidity-Specific Evaluator Notes
|
|
289
|
+
|
|
290
|
+
- For compilation criteria, run the configured build command and check for zero errors and zero warnings
|
|
291
|
+
- For linting criteria, run solhint and check for zero errors
|
|
292
|
+
- For test criteria, run the test suite and verify all tests pass with expected coverage
|
|
293
|
+
- For security criteria, check for common vulnerability patterns (see Security Checklist below)
|
|
294
|
+
- For gas criteria, check that gas usage for key functions is within reasonable bounds
|
|
295
|
+
|
|
296
|
+
## Step 5: Execute the Pipeline
|
|
297
|
+
|
|
298
|
+
Run the full sprint execution loop with Solidity-specific evaluation:
|
|
299
|
+
|
|
300
|
+
### Solidity-Specific Evaluation Enhancements
|
|
301
|
+
|
|
302
|
+
When evaluating Solidity sprints, the evaluator should additionally check:
|
|
303
|
+
|
|
304
|
+
1. **Compilation:**
|
|
305
|
+
- Zero compiler errors
|
|
306
|
+
- Zero compiler warnings (treat warnings as errors)
|
|
307
|
+
- Correct Solidity version pragma
|
|
308
|
+
|
|
309
|
+
2. **Security patterns:**
|
|
310
|
+
- **Reentrancy:** State changes before external calls, or `ReentrancyGuard` used on functions that make external calls
|
|
311
|
+
- **Access control:** No unprotected admin functions, proper role checks
|
|
312
|
+
- **Integer safety:** Solidity 0.8+ has built-in overflow protection, but check for unchecked blocks
|
|
313
|
+
- **Front-running:** Identify functions vulnerable to front-running (approve/transferFrom, DEX swaps)
|
|
314
|
+
- **Oracle manipulation:** If using oracles, check for TWAP vs spot price, staleness checks
|
|
315
|
+
- **Denial of service:** No unbounded loops over user-controlled arrays
|
|
316
|
+
- **Flash loan attacks:** If DeFi, check for single-transaction price manipulation vectors
|
|
317
|
+
- **Signature replay:** If using signatures, check for nonce/deadline/chainId protection
|
|
318
|
+
|
|
319
|
+
3. **Gas optimization:**
|
|
320
|
+
- Use `uint256` instead of smaller types when storage packing is not achieved
|
|
321
|
+
- Use `calldata` instead of `memory` for read-only function parameters
|
|
322
|
+
- Pack storage variables (variables less than 32 bytes adjacent in storage)
|
|
323
|
+
- Use custom errors instead of require strings
|
|
324
|
+
- Mark functions as `view`/`pure` where applicable
|
|
325
|
+
- Avoid redundant SLOAD operations (cache storage reads in memory)
|
|
326
|
+
|
|
327
|
+
4. **Code quality:**
|
|
328
|
+
- NatSpec documentation on all external/public functions
|
|
329
|
+
- Consistent naming: `_internalFunctions`, `CONSTANTS`, `storageVariables`
|
|
330
|
+
- Events emitted for all state changes
|
|
331
|
+
- Interface defined for cross-contract interactions
|
|
332
|
+
- Proper use of `immutable` and `constant` keywords
|
|
333
|
+
|
|
334
|
+
5. **Test quality:**
|
|
335
|
+
- Unit tests for every external/public function
|
|
336
|
+
- Tests for access control (verify unauthorized calls revert)
|
|
337
|
+
- Tests for edge cases (zero values, max values, empty arrays)
|
|
338
|
+
- Tests for event emissions
|
|
339
|
+
- Fuzz tests for arithmetic-heavy functions (Foundry)
|
|
340
|
+
|
|
341
|
+
## Step 6: Post-Pipeline Verification
|
|
342
|
+
|
|
343
|
+
After all sprints pass, run a final comprehensive check:
|
|
344
|
+
|
|
345
|
+
1. **Full compilation:**
|
|
346
|
+
```bash
|
|
347
|
+
npx hardhat compile # or: forge build
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
2. **Full test suite with coverage:**
|
|
351
|
+
```bash
|
|
352
|
+
npx hardhat coverage # or: forge coverage
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
3. **Linting:**
|
|
356
|
+
```bash
|
|
357
|
+
npx solhint 'contracts/**/*.sol' # or: npx solhint 'src/**/*.sol'
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
4. **Gas report:**
|
|
361
|
+
```bash
|
|
362
|
+
REPORT_GAS=true npx hardhat test # or: forge test --gas-report
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
5. **Report to user:**
|
|
366
|
+
```
|
|
367
|
+
## Smart Contracts Complete
|
|
368
|
+
|
|
369
|
+
Your contracts are ready for review.
|
|
370
|
+
|
|
371
|
+
### How to Build & Test
|
|
372
|
+
npx hardhat compile # Compile contracts
|
|
373
|
+
npx hardhat test # Run tests
|
|
374
|
+
npx hardhat coverage # Coverage report
|
|
375
|
+
|
|
376
|
+
### What Was Built
|
|
377
|
+
<Summary of contracts implemented>
|
|
378
|
+
|
|
379
|
+
### Contract Architecture
|
|
380
|
+
<Inheritance diagram, key contracts and their roles>
|
|
381
|
+
|
|
382
|
+
### Security Notes
|
|
383
|
+
<Key security decisions made, patterns applied>
|
|
384
|
+
|
|
385
|
+
### Deployment
|
|
386
|
+
<Instructions for deploying to testnet/mainnet>
|
|
387
|
+
|
|
388
|
+
### Next Steps
|
|
389
|
+
- Review the contracts on branch: bober/<feature-slug>
|
|
390
|
+
- Run a professional audit before mainnet deployment
|
|
391
|
+
- Deploy to testnet first: npx hardhat run scripts/deploy.ts --network sepolia
|
|
392
|
+
- Verify on Etherscan after deployment
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
## Security Checklist
|
|
396
|
+
|
|
397
|
+
The evaluator MUST check for these common vulnerability patterns:
|
|
398
|
+
|
|
399
|
+
1. **Reentrancy:** External calls made before state updates. Mitigate with checks-effects-interactions pattern or `ReentrancyGuard`.
|
|
400
|
+
2. **Front-running:** Transactions that can be profitably front-run (approve, swaps). Mitigate with commit-reveal, deadlines, or slippage protection.
|
|
401
|
+
3. **Oracle manipulation:** Single-block price reads. Mitigate with TWAP, multiple oracle sources, or circuit breakers.
|
|
402
|
+
4. **Integer overflow/underflow:** Unchecked arithmetic blocks. Mitigate by avoiding `unchecked` unless gas-critical and mathematically proven safe.
|
|
403
|
+
5. **Access control:** Missing or incorrect role checks. Mitigate with OpenZeppelin AccessControl or Ownable.
|
|
404
|
+
6. **Denial of service:** Unbounded loops, block gas limit issues. Mitigate with pagination, pull-over-push patterns.
|
|
405
|
+
7. **Signature replay:** Missing nonce, deadline, or chain ID in signed messages. Mitigate with EIP-712 typed data.
|
|
406
|
+
8. **Centralization risks:** Single admin key controlling critical functions. Mitigate with multisig, timelock, or governance.
|
|
407
|
+
9. **Storage collisions:** In upgradeable contracts, storage layout changes between versions. Mitigate with storage gaps, ERC-7201 namespaced storage.
|
|
408
|
+
10. **Unchecked return values:** Not checking return values of `transfer`, `approve`, or low-level calls. Mitigate with SafeERC20 or explicit checks.
|
|
409
|
+
|
|
410
|
+
## Error Handling
|
|
411
|
+
|
|
412
|
+
- **Compilation failures:** Read the compiler output carefully. Common issues: import path errors, version mismatches, missing dependencies. Run `forge install` or `npm install` first.
|
|
413
|
+
- **Test failures in Hardhat:** Check that the local Hardhat node is not already running on the same port. Check that test fixtures deploy contracts correctly.
|
|
414
|
+
- **Test failures in Foundry:** Check that `setUp()` deploys all required contracts. Check that fork tests have the correct RPC URL configured.
|
|
415
|
+
- **Solhint errors:** If solhint is not installed, install it as a dev dependency. If rules are too strict, adjust `.solhint.json` but document the reason.
|
|
416
|
+
- **Gas report issues:** If gas reports show unexpectedly high usage, flag specific functions for optimization in a follow-up sprint.
|