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,365 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bober.anchor
|
|
3
|
+
description: "Solana program development workflow using Anchor. Plans program architecture, implements with proper account validation, and evaluates with build, test, and security checks. Use when building Solana programs, SPL tokens, or on-chain applications."
|
|
4
|
+
argument-hint: <program-description>
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# bober.anchor — Solana Program Workflow
|
|
8
|
+
|
|
9
|
+
You are running the **bober.anchor** skill. This is a specialized workflow for building Solana programs using the Anchor framework. It covers project scaffolding, program architecture planning, implementation with proper account validation, and evaluation using build, test, and security checks.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
Use `bober.anchor` when:
|
|
14
|
+
- Building new Solana programs from scratch (greenfield)
|
|
15
|
+
- Adding programs or instructions to an existing Anchor project
|
|
16
|
+
- The project involves: Solana programs, SPL tokens, on-chain applications, DeFi on Solana, NFT programs, or any Solana-native development
|
|
17
|
+
|
|
18
|
+
For EVM/Solidity work, use `bober.solidity`. For general projects, use `bober.run`.
|
|
19
|
+
|
|
20
|
+
## Stack Assumptions
|
|
21
|
+
|
|
22
|
+
This skill is optimized for:
|
|
23
|
+
- **Language:** Rust (with Anchor macros)
|
|
24
|
+
- **Framework:** Anchor 0.30+
|
|
25
|
+
- **Client SDK:** TypeScript with `@coral-xyz/anchor`
|
|
26
|
+
- **Testing:** Anchor integration tests (TypeScript), Bankrun for fast local testing, or `solana-test-validator`
|
|
27
|
+
- **Token standard:** SPL Token / Token-2022
|
|
28
|
+
- **Tooling:** Solana CLI, Anchor CLI, Rust/Cargo
|
|
29
|
+
|
|
30
|
+
If the user's stack differs (e.g., native Solana without Anchor, Seahorse/Python), adapt accordingly. These are defaults, not requirements.
|
|
31
|
+
|
|
32
|
+
## Step 1: Project Assessment
|
|
33
|
+
|
|
34
|
+
### Greenfield (New Project)
|
|
35
|
+
|
|
36
|
+
If there is no `Anchor.toml` in the project:
|
|
37
|
+
|
|
38
|
+
1. Ask the user to describe their program/application
|
|
39
|
+
2. Ask clarifying questions specific to Solana/Anchor projects:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
**Q1: Program Type**
|
|
43
|
+
A) Token program (SPL Token, Token-2022, custom mint/transfer logic)
|
|
44
|
+
B) DeFi protocol (AMM, lending, staking, vault)
|
|
45
|
+
C) NFT/Metaplex program (minting, marketplace, collections)
|
|
46
|
+
D) Governance / DAO
|
|
47
|
+
E) Custom application logic (gaming, social, data storage)
|
|
48
|
+
|
|
49
|
+
**Q2: Token Standard**
|
|
50
|
+
A) SPL Token (standard, most compatible)
|
|
51
|
+
B) Token-2022 (extensions: transfer fees, confidential transfers, etc.)
|
|
52
|
+
C) No tokens involved
|
|
53
|
+
D) Both SPL Token and Token-2022 support
|
|
54
|
+
|
|
55
|
+
**Q3: Account Architecture**
|
|
56
|
+
A) Simple (few account types, straightforward PDAs)
|
|
57
|
+
B) Moderate (multiple account types, several PDAs, some relationships)
|
|
58
|
+
C) Complex (many account types, nested PDAs, cross-program invocations)
|
|
59
|
+
|
|
60
|
+
**Q4: Testing Approach**
|
|
61
|
+
A) Bankrun (fast, in-process validator simulation -- recommended)
|
|
62
|
+
B) Local validator (solana-test-validator, slower but full fidelity)
|
|
63
|
+
C) Both (Bankrun for unit tests, local validator for integration)
|
|
64
|
+
|
|
65
|
+
**Q5: Client SDK**
|
|
66
|
+
A) TypeScript SDK (most common, works with Anchor IDL)
|
|
67
|
+
B) Rust client (for CLI tools or backend services)
|
|
68
|
+
C) Both TypeScript and Rust clients
|
|
69
|
+
D) No client SDK needed (program only)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
3. After answers, scaffold the project using Anchor
|
|
73
|
+
|
|
74
|
+
### Brownfield (Existing Anchor Project)
|
|
75
|
+
|
|
76
|
+
If `Anchor.toml` exists:
|
|
77
|
+
|
|
78
|
+
1. Analyze the existing setup:
|
|
79
|
+
- Read `Anchor.toml` for program IDs, cluster config, and workspace settings
|
|
80
|
+
- Read `Cargo.toml` for Rust dependencies
|
|
81
|
+
- Check `programs/` directory for existing programs
|
|
82
|
+
- Read existing program source files to understand account structures
|
|
83
|
+
- Check for existing tests in `tests/` directory
|
|
84
|
+
- Check for client SDK code in `app/` or `sdk/` directories
|
|
85
|
+
- Read IDL files in `target/idl/` if they exist
|
|
86
|
+
|
|
87
|
+
2. Survey the program architecture:
|
|
88
|
+
- Map all account structs and their constraints
|
|
89
|
+
- Identify all instructions and their required accounts
|
|
90
|
+
- List PDA derivation patterns
|
|
91
|
+
- Identify CPI targets (other programs called)
|
|
92
|
+
- Check for custom error definitions
|
|
93
|
+
|
|
94
|
+
3. Skip scaffolding -- proceed directly to planning
|
|
95
|
+
|
|
96
|
+
## Step 2: Initialize Configuration
|
|
97
|
+
|
|
98
|
+
Create or update `bober.config.json` with Anchor-optimized defaults:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"project": {
|
|
103
|
+
"name": "<project-name>",
|
|
104
|
+
"mode": "greenfield",
|
|
105
|
+
"preset": "anchor",
|
|
106
|
+
"description": "<user's program description>"
|
|
107
|
+
},
|
|
108
|
+
"planner": {
|
|
109
|
+
"maxClarifications": 5,
|
|
110
|
+
"model": "opus",
|
|
111
|
+
"contextFiles": [
|
|
112
|
+
"Anchor.toml",
|
|
113
|
+
"Cargo.toml",
|
|
114
|
+
"programs/"
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
"generator": {
|
|
118
|
+
"model": "sonnet",
|
|
119
|
+
"maxTurnsPerSprint": 50,
|
|
120
|
+
"autoCommit": true,
|
|
121
|
+
"branchPattern": "bober/{feature-name}"
|
|
122
|
+
},
|
|
123
|
+
"evaluator": {
|
|
124
|
+
"model": "sonnet",
|
|
125
|
+
"strategies": [
|
|
126
|
+
{ "type": "build", "required": true },
|
|
127
|
+
{ "type": "lint", "required": true },
|
|
128
|
+
{ "type": "unit-test", "required": true }
|
|
129
|
+
],
|
|
130
|
+
"maxIterations": 3
|
|
131
|
+
},
|
|
132
|
+
"sprint": {
|
|
133
|
+
"maxSprints": 10,
|
|
134
|
+
"requireContracts": true,
|
|
135
|
+
"sprintSize": "medium"
|
|
136
|
+
},
|
|
137
|
+
"pipeline": {
|
|
138
|
+
"maxIterations": 20,
|
|
139
|
+
"requireApproval": false,
|
|
140
|
+
"contextReset": "always"
|
|
141
|
+
},
|
|
142
|
+
"commands": {
|
|
143
|
+
"install": "npm install && anchor build",
|
|
144
|
+
"build": "anchor build",
|
|
145
|
+
"test": "anchor test",
|
|
146
|
+
"lint": "cargo clippy --all-targets -- -D warnings",
|
|
147
|
+
"dev": ""
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Adjust commands based on what actually exists in the project.
|
|
153
|
+
|
|
154
|
+
## Step 3: Scaffold (Greenfield Only)
|
|
155
|
+
|
|
156
|
+
For new projects, create the initial project structure.
|
|
157
|
+
|
|
158
|
+
### Anchor Scaffolding
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
anchor init <project-name>
|
|
162
|
+
cd <project-name>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Or if initializing in the current directory:
|
|
166
|
+
```bash
|
|
167
|
+
anchor init . --name <program-name>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Verify the initial setup:
|
|
171
|
+
```bash
|
|
172
|
+
anchor build
|
|
173
|
+
anchor test
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Post-Scaffold Setup
|
|
177
|
+
|
|
178
|
+
1. **Update Anchor.toml** with appropriate cluster and wallet configuration
|
|
179
|
+
2. **Update Cargo.toml** with additional dependencies if needed:
|
|
180
|
+
- `anchor-spl` for SPL Token interactions
|
|
181
|
+
- `mpl-token-metadata` for Metaplex NFT metadata
|
|
182
|
+
3. **Create program directory structure:**
|
|
183
|
+
```
|
|
184
|
+
programs/<program-name>/src/
|
|
185
|
+
lib.rs # Program entry point
|
|
186
|
+
instructions/ # Instruction handlers (one file per instruction)
|
|
187
|
+
mod.rs
|
|
188
|
+
state/ # Account structs and state definitions
|
|
189
|
+
mod.rs
|
|
190
|
+
errors.rs # Custom error definitions
|
|
191
|
+
constants.rs # Program constants and seeds
|
|
192
|
+
```
|
|
193
|
+
4. **Set up test structure:**
|
|
194
|
+
```
|
|
195
|
+
tests/
|
|
196
|
+
<program-name>.ts # Integration tests
|
|
197
|
+
helpers/
|
|
198
|
+
setup.ts # Test setup utilities
|
|
199
|
+
utils.ts # Test helper functions
|
|
200
|
+
```
|
|
201
|
+
5. **Create initial git commit:**
|
|
202
|
+
```bash
|
|
203
|
+
git init
|
|
204
|
+
git add -A
|
|
205
|
+
git commit -m "chore: initial scaffold from bober.anchor"
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Step 4: Plan the Feature
|
|
209
|
+
|
|
210
|
+
Run the full planning workflow with Anchor-specific enhancements:
|
|
211
|
+
|
|
212
|
+
### Program Architecture Planning
|
|
213
|
+
|
|
214
|
+
When planning a Solana program feature, consider:
|
|
215
|
+
|
|
216
|
+
1. **Account structures:** What accounts does the program need? What data do they store? What are the relationships between accounts?
|
|
217
|
+
2. **PDAs (Program Derived Addresses):** What PDAs are needed? What seeds derive each PDA? Are they unique per user, per token, per global state?
|
|
218
|
+
3. **Instructions:** What instructions does the program expose? What accounts does each instruction require? What are the signer requirements?
|
|
219
|
+
4. **Account validation:** What constraints apply to each account in each instruction? Size, ownership, initialization state, PDA derivation?
|
|
220
|
+
5. **CPIs (Cross-Program Invocations):** Does the program call other programs (System Program, Token Program, Associated Token Program, etc.)?
|
|
221
|
+
6. **Custom errors:** What error conditions exist? Define custom errors for each.
|
|
222
|
+
7. **Events:** What events should be emitted for off-chain indexing?
|
|
223
|
+
|
|
224
|
+
### Anchor-Specific Sprint Ordering
|
|
225
|
+
|
|
226
|
+
For a typical Solana program feature:
|
|
227
|
+
|
|
228
|
+
1. **Account definitions and state first:** Define all account structs, PDA seeds, and constants. This establishes the program's data model.
|
|
229
|
+
2. **Instruction handlers (core logic):** Implement the main instruction handlers one at a time, starting with initialization/creation instructions.
|
|
230
|
+
3. **State management and transitions:** Implement state transitions, validations, and business logic within instruction handlers.
|
|
231
|
+
4. **Client SDK:** Generate and extend the TypeScript client SDK from the Anchor IDL. Create helper functions for common operations.
|
|
232
|
+
5. **Integration tests:** Write comprehensive tests that exercise the full instruction flow, including error cases and edge cases.
|
|
233
|
+
|
|
234
|
+
### Anchor-Specific Success Criteria
|
|
235
|
+
|
|
236
|
+
Include these for every program sprint:
|
|
237
|
+
|
|
238
|
+
- "The program compiles successfully with `anchor build` and produces a valid BPF/SBF binary"
|
|
239
|
+
- "All account constraints are properly defined (signer checks, PDA derivation, ownership, space allocation)"
|
|
240
|
+
- "Custom errors are defined for all failure modes and used in constraint checks"
|
|
241
|
+
- "PDA derivation is correct: seeds match between creation and lookup"
|
|
242
|
+
- "All instruction handlers validate all required accounts"
|
|
243
|
+
- "Integration tests pass with `anchor test`"
|
|
244
|
+
- "No `cargo clippy` warnings in the program code"
|
|
245
|
+
|
|
246
|
+
### Anchor-Specific Evaluator Notes
|
|
247
|
+
|
|
248
|
+
- For build criteria, run `anchor build` and check for zero errors and zero warnings
|
|
249
|
+
- For lint criteria, run `cargo clippy` and check for zero warnings (with `-D warnings` flag)
|
|
250
|
+
- For test criteria, run `anchor test` and verify all tests pass
|
|
251
|
+
- For account validation criteria, review the Accounts structs for proper constraints
|
|
252
|
+
- For PDA criteria, verify seeds are consistent between instruction contexts and client code
|
|
253
|
+
|
|
254
|
+
## Step 5: Execute the Pipeline
|
|
255
|
+
|
|
256
|
+
Run the full sprint execution loop with Anchor-specific evaluation:
|
|
257
|
+
|
|
258
|
+
### Anchor-Specific Evaluation Enhancements
|
|
259
|
+
|
|
260
|
+
When evaluating Anchor sprints, the evaluator should additionally check:
|
|
261
|
+
|
|
262
|
+
1. **Program compilation:**
|
|
263
|
+
- `anchor build` succeeds with zero errors
|
|
264
|
+
- `cargo clippy` produces zero warnings
|
|
265
|
+
- IDL is generated correctly in `target/idl/`
|
|
266
|
+
|
|
267
|
+
2. **Account validation:**
|
|
268
|
+
- All accounts in instruction contexts have appropriate constraints:
|
|
269
|
+
- `#[account(mut)]` for accounts that are modified
|
|
270
|
+
- `#[account(signer)]` or marking as `Signer` type for accounts that must sign
|
|
271
|
+
- `#[account(init, payer = ..., space = ...)]` for new accounts with correct space calculation
|
|
272
|
+
- `#[account(seeds = [...], bump)]` for PDAs with correct seed derivation
|
|
273
|
+
- `#[account(has_one = ...)]` for relationship validation
|
|
274
|
+
- `#[account(constraint = ...)]` for custom validation logic
|
|
275
|
+
- Account space calculations include the 8-byte discriminator
|
|
276
|
+
- PDA bumps are stored and reused correctly
|
|
277
|
+
|
|
278
|
+
3. **PDA correctness:**
|
|
279
|
+
- Seeds used in account derivation match between creation and lookup
|
|
280
|
+
- PDA seeds are deterministic and unambiguous (no collisions)
|
|
281
|
+
- Bump seeds are stored in account data for efficient re-derivation
|
|
282
|
+
|
|
283
|
+
4. **Error handling:**
|
|
284
|
+
- Custom error enum defined with `#[error_code]`
|
|
285
|
+
- Meaningful error messages for each error variant
|
|
286
|
+
- Errors used in `require!()` and `constraint` checks
|
|
287
|
+
- No panics or unwrap calls in instruction logic
|
|
288
|
+
|
|
289
|
+
5. **CPI safety:**
|
|
290
|
+
- CPI calls use proper signer seeds for PDA-signed invocations
|
|
291
|
+
- Account ownership is verified before passing accounts to CPI targets
|
|
292
|
+
- Token program CPIs use the correct mint, authority, and token accounts
|
|
293
|
+
|
|
294
|
+
6. **Compute budget:**
|
|
295
|
+
- Instructions stay within Solana's compute unit limits (default 200,000 per instruction)
|
|
296
|
+
- Heavy computations are broken into multiple transactions if needed
|
|
297
|
+
- Logging is minimal in production code (`msg!` uses compute units)
|
|
298
|
+
|
|
299
|
+
7. **Test quality:**
|
|
300
|
+
- Tests cover the happy path for every instruction
|
|
301
|
+
- Tests verify error cases (unauthorized signers, invalid accounts, constraint violations)
|
|
302
|
+
- Tests verify PDA derivation matches expected addresses
|
|
303
|
+
- Tests use proper setup/teardown with account creation
|
|
304
|
+
|
|
305
|
+
## Step 6: Post-Pipeline Verification
|
|
306
|
+
|
|
307
|
+
After all sprints pass, run a final comprehensive check:
|
|
308
|
+
|
|
309
|
+
1. **Full build:**
|
|
310
|
+
```bash
|
|
311
|
+
anchor build
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
2. **Full test suite:**
|
|
315
|
+
```bash
|
|
316
|
+
anchor test
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
3. **Clippy:**
|
|
320
|
+
```bash
|
|
321
|
+
cargo clippy --all-targets -- -D warnings
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
4. **IDL verification:**
|
|
325
|
+
- Check that `target/idl/<program>.json` exists and matches the program interface
|
|
326
|
+
|
|
327
|
+
5. **Report to user:**
|
|
328
|
+
```
|
|
329
|
+
## Solana Program Complete
|
|
330
|
+
|
|
331
|
+
Your program is ready for review.
|
|
332
|
+
|
|
333
|
+
### How to Build & Test
|
|
334
|
+
anchor build # Compile the program
|
|
335
|
+
anchor test # Run integration tests
|
|
336
|
+
anchor deploy # Deploy to configured cluster
|
|
337
|
+
|
|
338
|
+
### What Was Built
|
|
339
|
+
<Summary of program instructions and accounts>
|
|
340
|
+
|
|
341
|
+
### Program Architecture
|
|
342
|
+
<Account diagram, PDA derivations, instruction flow>
|
|
343
|
+
|
|
344
|
+
### Security Notes
|
|
345
|
+
<Key validation decisions, access control patterns>
|
|
346
|
+
|
|
347
|
+
### Deployment
|
|
348
|
+
- Deploy to devnet first: anchor deploy --provider.cluster devnet
|
|
349
|
+
- Program ID: <program-id from Anchor.toml>
|
|
350
|
+
|
|
351
|
+
### Next Steps
|
|
352
|
+
- Review the program on branch: bober/<feature-slug>
|
|
353
|
+
- Get a security audit before mainnet deployment
|
|
354
|
+
- Deploy to devnet: anchor deploy --provider.cluster devnet
|
|
355
|
+
- Test with the client SDK
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
## Error Handling
|
|
359
|
+
|
|
360
|
+
- **Build failures:** Common issues include Rust version mismatches, missing dependencies in Cargo.toml, and Anchor version incompatibilities. Check `anchor --version` and `rustc --version`.
|
|
361
|
+
- **Test failures:** Check that the local validator is not already running. Check that program IDs in tests match Anchor.toml. Ensure accounts are properly initialized before use.
|
|
362
|
+
- **Account size errors:** If accounts cannot be created due to insufficient space, recalculate space requirements including the 8-byte discriminator and all fields.
|
|
363
|
+
- **Compute budget exceeded:** Break heavy logic into multiple instructions or request additional compute units with `ComputeBudgetProgram.setComputeUnitLimit()`.
|
|
364
|
+
- **Transaction size exceeded:** Solana transactions are limited to 1232 bytes. If a transaction is too large, split into multiple transactions or use lookup tables for accounts.
|
|
365
|
+
- **PDA derivation mismatches:** Verify that seeds are identical in the program (Rust) and client (TypeScript). Watch for encoding differences (string vs bytes, endianness of numbers).
|