@5ive-tech/cli 1.0.10 → 1.0.12

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.
@@ -9,7 +9,7 @@ import { FiveFileManager } from '../utils/FiveFileManager.js';
9
9
  import { loadBuildManifest, loadProjectConfig } from '../project/ProjectLoader.js';
10
10
  import { section, success as uiSuccess, error as uiError } from '../utils/cli-ui.js';
11
11
  /**
12
- * Five test command implementation
12
+ * 5IVE test command implementation
13
13
  */
14
14
  export const testCommand = {
15
15
  name: 'test',
@@ -122,27 +122,27 @@ export const testCommand = {
122
122
  ],
123
123
  examples: [
124
124
  {
125
- command: 'five test',
125
+ command: '5ive test',
126
126
  description: 'Run all tests in ./tests directory'
127
127
  },
128
128
  {
129
- command: 'five test --filter "token*" --verbose',
129
+ command: '5ive test --filter "token*" --verbose',
130
130
  description: 'Run token tests with verbose output'
131
131
  },
132
132
  {
133
- command: 'five test ./my-tests --benchmark --format json',
133
+ command: '5ive test ./my-tests --benchmark --format json',
134
134
  description: 'Run benchmarks with JSON output'
135
135
  },
136
136
  {
137
- command: 'five test --watch --parallel 4',
137
+ command: '5ive test --watch --parallel 4',
138
138
  description: 'Watch mode with 4 parallel workers'
139
139
  },
140
140
  {
141
- command: 'five test test-scripts/ --on-chain --target devnet',
141
+ command: '5ive test test-scripts/ --on-chain --target devnet',
142
142
  description: 'Run on-chain tests on devnet'
143
143
  },
144
144
  {
145
- command: 'five test test-scripts/ --on-chain --batch --analyze-costs',
145
+ command: '5ive test test-scripts/ --on-chain --batch --analyze-costs',
146
146
  description: 'Batch test all .bin files with cost analysis'
147
147
  }
148
148
  ],
@@ -183,10 +183,10 @@ export const testCommand = {
183
183
  }
184
184
  // Legacy approach with SDK integration
185
185
  // Initialize SDK for testing
186
- const spinner = ora('Initializing Five SDK for testing...').start();
186
+ const spinner = ora('Initializing 5IVE SDK for testing...').start();
187
187
  // No initialization needed for SDK - it's stateless
188
188
  const sdk = FiveSDK.create({ debug: options.verbose });
189
- spinner.succeed('Five SDK initialized');
189
+ spinner.succeed('5IVE SDK initialized');
190
190
  // Discover test files
191
191
  const testSuites = await discoverTestSuites(testPath, options, logger);
192
192
  if (testSuites.length === 0) {
@@ -367,7 +367,7 @@ async function runSingleTest(testCase, sdk, options, context) {
367
367
  parameters = [inputData];
368
368
  }
369
369
  }
370
- // Execute with timeout using Five SDK
370
+ // Execute with timeout using 5IVE SDK
371
371
  const executionPromise = FiveSDK.executeLocally(bytecode, 0, // Default to first function
372
372
  parameters, {
373
373
  debug: options.verbose,
@@ -562,7 +562,7 @@ async function runOnChainTests(testPath, options, context) {
562
562
  */
563
563
  async function runWithSdkRunner(testPath, options, context) {
564
564
  const { logger } = context;
565
- logger.info('Using Five SDK test runner');
565
+ logger.info('Using 5IVE SDK test runner');
566
566
  // Create test runner with options
567
567
  const runner = new FiveTestRunner({
568
568
  timeout: options.timeout,
@@ -1,6 +1,6 @@
1
1
  import { CommandDefinition } from '../types.js';
2
2
  /**
3
- * Five version command implementation
3
+ * 5IVE version command implementation
4
4
  */
5
5
  export declare const versionCommand: CommandDefinition;
6
6
  //# sourceMappingURL=version.d.ts.map
@@ -10,7 +10,7 @@ const __dirname = dirname(__filename);
10
10
  import { FiveCompilerWasm } from '../wasm/compiler.js';
11
11
  import { FiveVM } from '../wasm/vm.js';
12
12
  /**
13
- * Five version command implementation
13
+ * 5IVE version command implementation
14
14
  */
15
15
  export const versionCommand = {
16
16
  name: 'version',
@@ -37,15 +37,15 @@ export const versionCommand = {
37
37
  arguments: [],
38
38
  examples: [
39
39
  {
40
- command: 'five version',
40
+ command: '5ive version',
41
41
  description: 'Show basic version information'
42
42
  },
43
43
  {
44
- command: 'five version --detailed --format json',
44
+ command: '5ive version --detailed --format json',
45
45
  description: 'Show detailed version info in JSON format'
46
46
  },
47
47
  {
48
- command: 'five version --check-updates',
48
+ command: '5ive version --check-updates',
49
49
  description: 'Check for CLI updates'
50
50
  }
51
51
  ],
@@ -80,7 +80,7 @@ async function gatherVersionInfo(context, detailed) {
80
80
  cli: {
81
81
  name: packageInfo.name || 'five-cli',
82
82
  version: packageInfo.version || '1.0.0',
83
- description: packageInfo.description || 'Five VM CLI'
83
+ description: packageInfo.description || '5IVE VM CLI'
84
84
  },
85
85
  wasm: {},
86
86
  dependencies: {},
@@ -125,7 +125,7 @@ async function getPackageInfo(rootDir) {
125
125
  continue;
126
126
  }
127
127
  }
128
- return { name: 'five-cli', version: '1.0.0', description: 'Five VM CLI' };
128
+ return { name: 'five-cli', version: '1.0.0', description: '5IVE VM CLI' };
129
129
  }
130
130
  /**
131
131
  * Get WASM module version information
@@ -317,7 +317,7 @@ function displayVersionTable(versionInfo) {
317
317
  rows.push(['WASM VM', versionInfo.wasm.vm.version]);
318
318
  }
319
319
  // Simple table formatting
320
- console.log(chalk.bold('Five CLI Version Information:'));
320
+ console.log(chalk.bold('5IVE CLI Version Information:'));
321
321
  console.log();
322
322
  const maxKeyLength = Math.max(...rows.map(([key]) => key.length));
323
323
  for (const [key, value] of rows) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5ive-tech/cli",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "High-performance CLI for Five VM development with WebAssembly integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -37,6 +37,7 @@
37
37
  },
38
38
  "files": [
39
39
  "dist/",
40
+ "templates/AGENTS.md",
40
41
  "assets/",
41
42
  "README.md",
42
43
  "LICENSE"
@@ -0,0 +1,402 @@
1
+ # AGENTS.md - Complete 5IVE DSL Agent Bootstrap
2
+
3
+ This file is written for agents with zero prior 5IVE knowledge.
4
+ It is intentionally self-contained and should be treated as the baseline technical specification for authoring, testing, deploying, and integrating 5IVE programs.
5
+
6
+ ## 1) What 5IVE Is
7
+
8
+ 5IVE is a DSL and toolchain for compiling compact bytecode programs for Solana execution paths.
9
+
10
+ Core surfaces:
11
+ 1. Source language: `.v`
12
+ 2. Canonical artifact: `.five` (bytecode + ABI)
13
+ 3. CLI: `@5ive-tech/cli` (`5ive` canonical command; `five` alias supported)
14
+ 4. SDK: `@5ive-tech/sdk` (`FiveSDK`, `FiveProgram`)
15
+
16
+ ## 2) Source of Truth Policy
17
+
18
+ When docs conflict, resolve in this order:
19
+ 1. Compiler/CLI/SDK source code
20
+ 2. Package manifests + command definitions
21
+ 3. READMEs/examples/docs
22
+
23
+ Never rely on stale docs when behavior is high-stakes (deploy/execute/CPI encoding).
24
+
25
+ ## 3) Non-Negotiable Workflow
26
+
27
+ 1. Inspect `five.toml` before code changes.
28
+ 2. Compile to `.five`.
29
+ 3. Run local/runtime tests.
30
+ 4. Deploy with explicit target + program ID resolution path.
31
+ 5. Execute and verify confirmed tx metadata (`meta.err == null`).
32
+ 6. Record signatures + compute units.
33
+
34
+ ## 4) DSL Feature Inventory (Deep)
35
+
36
+ This section enumerates language features discovered from parser/compiler code and repo examples.
37
+
38
+ ### 4.1 Top-level declarations
39
+ Observed and/or parsed:
40
+ 1. `account Name { ... }`
41
+ 2. Global fields/variables (including `mut`)
42
+ 3. `init { ... }` block
43
+ 4. `constraints { ... }` block
44
+ 5. Function/instruction definitions (`pub`, `fn`, optional `instruction` keyword)
45
+ 6. `event Name { ... }` definitions
46
+ 7. `interface Name ... { ... }` definitions
47
+ 8. `use` / `import` statements
48
+ 9. Legacy `script Name { ... }` wrapper (parser-supported)
49
+
50
+ ### 4.2 Function definition forms
51
+ Parser accepts flexible forms:
52
+ 1. `pub add(...) -> ... { ... }`
53
+ 2. `fn add(...) { ... }`
54
+ 3. `instruction add(...) { ... }`
55
+ 4. `pub fn add(...) { ... }`
56
+
57
+ ### 4.3 Parameter system
58
+ Each parameter supports:
59
+ 1. Name + type: `x: u64`
60
+ 2. Optional marker: `x?: u64`
61
+ 3. Default value: `x: u64 = 10`
62
+ 4. Attributes before or after type
63
+
64
+ Common attributes:
65
+ 1. `@signer`
66
+ 2. `@mut`
67
+ 3. `@init`
68
+ 4. Generic form: `@attribute(args...)`
69
+ 5. Template-observed relation constraints: `@has(field)`
70
+
71
+ ### 4.4 `@init` config support
72
+ `@init` can include config arguments:
73
+ 1. `payer=...`
74
+ 2. `space=...`
75
+ 3. `seeds=[...]`
76
+ 4. `bump=...`
77
+
78
+ Examples also show legacy bracket seed forms after `@init`.
79
+
80
+ ### 4.5 Types
81
+ Supported/parsed type families:
82
+ 1. Primitive numeric/bool/pubkey/string types (`u8..u128`, `i8..i64`, `bool`, `pubkey`, `string`)
83
+ 2. `Account` type and account-typed params
84
+ 3. Sized strings: `string<32>`
85
+ 4. Arrays:
86
+ - Rust style: `[T; N]`
87
+ - TypeScript-style sized: `T[N]`
88
+ - TypeScript-style dynamic: `T[]`
89
+ 5. Tuples: `(T1, T2, ...)`
90
+ 6. Inline struct types: `{ field: Type, ... }`
91
+ 7. Generic types:
92
+ - `Option<T>`
93
+ - `Result<T, E>`
94
+ - nested generics (`Option<Option<u64>>` etc.)
95
+ 8. Namespaced/custom types: `module::Type`
96
+ 9. Optional account fields in structs/accounts: `field?: Type`
97
+
98
+ ### 4.6 Statements
99
+ Observed and parser-supported:
100
+ 1. `let` declarations (with `mut` and optional type annotation)
101
+ 2. Assignment:
102
+ - direct: `x = y`
103
+ - compound: `+=`, `-=`, `*=`, `/=`, `<<=`, `>>=`, `&=`, `|=`, `^=`
104
+ 3. Field assignment: `obj.field = value`
105
+ 4. Return statements (`return`, `return value`)
106
+ 5. Guard/assertion: `require(condition)`
107
+ 6. Conditionals:
108
+ - `if (...) {}`
109
+ - `else if (...) {}`
110
+ - `else {}`
111
+ 7. Pattern matching: `match expr { ... }`, with optional arm guards (`if ...`)
112
+ 8. Loops:
113
+ - `while (...) { ... }`
114
+ - `for (init; cond; update) { ... }`
115
+ - `for (item in iterable) { ... }`
116
+ - `do { ... } while (...);`
117
+ 9. Tuple destructuring:
118
+ - declaration style: `let (a, b) = expr`
119
+ - assignment style for tuple targets
120
+ 10. Event emission: `emit EventName { field: value, ... }`
121
+ 11. Expression statements (function/method calls, constructors like `Some(...)`)
122
+
123
+ ### 4.7 Expressions and operators
124
+ Parser handles:
125
+ 1. Arithmetic: `+`, `-`, `*`, `/`, `%`
126
+ 2. Checked-arithmetic tokens in grammar: `+?`, `-?`, `*?`
127
+ - Some repo tests indicate these were replaced/legacy in current examples.
128
+ 3. Comparison: `==`, `!=`, `<`, `<=`, `>`, `>=`
129
+ 4. Boolean: `&&`, `||`, `!`
130
+ 5. Bitwise: `&`, `|`, `^`, `~`
131
+ 6. Shifts/bit ops: `<<`, `>>`, `>>>`, `<<<`
132
+ 7. Range operator: `..`
133
+ 8. Unary `+`/`-`
134
+ 9. Cast syntax: `expr as Type`
135
+ 10. Error propagation postfix: `expr?`
136
+ 11. Field access: `obj.field`
137
+ 12. Tuple access: `obj.0`
138
+ 13. Array indexing: `arr[idx]`
139
+ 14. Function calls
140
+ 15. Method calls: `obj.method(args...)`
141
+ 16. Namespaced calls: `module::function(...)`
142
+ 17. Struct literals: `{ field: expr, ... }`
143
+ 18. Array literals: `[a, b, c]`
144
+ 19. Tuple literals: `(a, b)`
145
+ 20. Option/Result constructors and patterns:
146
+ - `Some(...)`, `None`
147
+ - `Ok(...)`, `Err(...)`
148
+
149
+ ### 4.8 Imports and modules
150
+ `use`/`import` system supports:
151
+ 1. External module specifier via quoted literal
152
+ 2. Local module specifier via identifier path
153
+ 3. Nested local module paths using `::`
154
+ 4. Scoped namespace forms with symbols: `!`, `@`, `#`, `$`, `%`
155
+ 5. Member imports:
156
+ - single: `::name`
157
+ - list: `::{a, b}`
158
+ - typed list entries: `method foo`, `interface Bar`
159
+
160
+ ### 4.9 Interfaces and CPI features
161
+ Interface parser supports:
162
+ 1. `interface Name ... { methods... }`
163
+ 2. Program binding:
164
+ - `program("...")`
165
+ - `@program("...")`
166
+ 3. Serializer hints:
167
+ - `serializer(...)`
168
+ - `@serializer(...)`
169
+ 4. Anchor marker:
170
+ - `@anchor interface ...`
171
+ 5. Method discriminators:
172
+ - `@discriminator(u8)`
173
+ - `@discriminator([byte,...])`
174
+ - `discriminator_bytes(...)` forms in parser/compiler AST
175
+ 6. Optional interface method return types
176
+
177
+ CPI hard rule for agents:
178
+ 1. Always set `@program(...)`
179
+ 2. Always set `@serializer(...)` explicitly
180
+ 3. Always set discriminator explicitly
181
+
182
+ ### 4.10 Events and error/enums
183
+ Parser/AST include:
184
+ 1. Event definitions + `emit` statements
185
+ 2. Enum/error-style definitions (`enum` path in parser)
186
+
187
+ Production note:
188
+ Treat event/error enum features as available in syntax, but verify runtime/compiler behavior in your exact toolchain version before relying on them for critical flows.
189
+
190
+ ### 4.11 Testing-oriented language features
191
+ From tokenizer/parser support:
192
+ 1. `#[...]` test attributes
193
+ 2. `test` function parse path
194
+ 3. Test attribute names/tokens include:
195
+ - `ignore`
196
+ - `should_fail`
197
+ - `timeout`
198
+ 4. Assertion tokens:
199
+ - `assert_eq`
200
+ - `assert_true`
201
+ - `assert_false`
202
+ - `assert_fails`
203
+ - `assert_approx_eq`
204
+
205
+ Repository tests also use comment-based param conventions (`// @test-params ...`) in many scripts.
206
+
207
+ ### 4.12 Blockchain-oriented built-ins seen in examples
208
+ Observed in scripts/templates:
209
+ 1. `derive_pda(...)` (including bump-return and bump-specified variants)
210
+ 2. `get_clock()`
211
+ 3. `get_key(...)`
212
+ 4. account key access: `authority.key`
213
+
214
+ Treat built-ins as compiler/runtime coupled features; verify signatures in current examples before use.
215
+
216
+ ## 5) Feature Maturity Matrix (Agent Safety)
217
+
218
+ ### 5.1 Generally production-oriented (widely used in templates)
219
+ 1. Accounts, `@mut`, `@signer`, `@init`
220
+ 2. `require`
221
+ 3. Basic control flow (`if`, `while`)
222
+ 4. Arithmetic/comparison/boolean expressions
223
+ 5. `.five` compile/deploy/execute path
224
+ 6. `interface` + explicit discriminator + explicit serializer CPI patterns
225
+
226
+ ### 5.2 Available but validate per-version before critical use
227
+ 1. Match expressions with `Option`/`Result`
228
+ 2. Tuple destructuring and tuple returns
229
+ 3. Advanced loop forms (`for`, `do-while`)
230
+ 4. Event definition/emit workflows
231
+ 5. Namespaced imports and scoped namespace symbols
232
+ 6. Bitwise/shift operator-heavy code
233
+
234
+ ### 5.3 Parser tokens exist; treat as reserved/experimental unless proven in your path
235
+ 1. `query`, `when`, `realloc`, `pda` keywords
236
+ 2. Some assertion/test keyword paths in non-test production code
237
+ 3. Legacy checked-arithmetic operators (`+?`, `-?`, `*?`) where examples indicate migration
238
+
239
+ ## 6) CLI Canonical Usage
240
+
241
+ ### 6.1 Install and identity
242
+ ```bash
243
+ npm install -g @5ive-tech/cli
244
+ 5ive --version
245
+ ```
246
+
247
+ ### 6.2 Initialize
248
+ ```bash
249
+ 5ive init my-program
250
+ cd my-program
251
+ ```
252
+
253
+ ### 6.3 Compile
254
+ ```bash
255
+ 5ive compile src/main.v -o build/main.five
256
+ # or project-aware
257
+ 5ive build
258
+ ```
259
+
260
+ ### 6.4 Local execute
261
+ ```bash
262
+ 5ive execute build/main.five --local -f 0
263
+ ```
264
+
265
+ ### 6.5 Configure devnet
266
+ ```bash
267
+ 5ive config init
268
+ 5ive config set --target devnet
269
+ 5ive config set --keypair ~/.config/solana/id.json
270
+ 5ive config set --program-id <FIVE_VM_PROGRAM_ID> --target devnet
271
+ ```
272
+
273
+ ### 6.6 Deploy + execute on-chain
274
+ ```bash
275
+ 5ive deploy build/main.five --target devnet
276
+ 5ive execute build/main.five --target devnet -f 0
277
+ ```
278
+
279
+ ### 6.7 Advanced deploy modes
280
+ ```bash
281
+ 5ive deploy build/main.five --target devnet --optimized --progress
282
+ 5ive deploy build/main.five --target devnet --force-chunked --chunk-size 900
283
+ 5ive deploy build/main.five --target devnet --dry-run --format json
284
+ ```
285
+
286
+ ### 6.8 Test modes
287
+ ```bash
288
+ 5ive test --sdk-runner
289
+ 5ive test tests/ --on-chain --target devnet
290
+ 5ive test --sdk-runner --format json
291
+ ```
292
+
293
+ ## 7) Program ID and Target Resolution
294
+
295
+ On-chain command precedence (`deploy`, `execute`, `namespace`):
296
+ 1. `--program-id`
297
+ 2. `five.toml [deploy].program_id`
298
+ 3. `5ive config` value for current target
299
+ 4. `FIVE_PROGRAM_ID`
300
+
301
+ Never run on-chain commands with ambiguous target/program-id context.
302
+
303
+ ## 8) SDK Canonical Usage
304
+
305
+ ### 8.1 Load artifact
306
+ ```ts
307
+ import fs from "fs";
308
+ import { FiveSDK } from "@5ive-tech/sdk";
309
+
310
+ const fiveFileText = fs.readFileSync("build/main.five", "utf8");
311
+ const { abi } = await FiveSDK.loadFiveFile(fiveFileText);
312
+ ```
313
+
314
+ ### 8.2 Program client
315
+ ```ts
316
+ import { FiveProgram } from "@5ive-tech/sdk";
317
+
318
+ const program = FiveProgram.fromABI("<SCRIPT_ACCOUNT>", abi, {
319
+ fiveVMProgramId: "<FIVE_VM_PROGRAM_ID>",
320
+ vmStateAccount: "<VM_STATE_ACCOUNT>",
321
+ feeReceiverAccount: "<FEE_RECEIVER_ACCOUNT>",
322
+ });
323
+ ```
324
+
325
+ ### 8.3 Execution verification pattern
326
+ 1. Build instruction via `program.function(...).accounts(...).args(...).instruction()`
327
+ 2. Submit with preflight enabled
328
+ 3. Fetch confirmed tx
329
+ 4. Assert `meta.err == null`
330
+ 5. Record `meta.computeUnitsConsumed`
331
+
332
+ ### 8.4 SDK program ID resolution precedence
333
+ 1. Explicit `fiveVMProgramId`
334
+ 2. `FiveSDK.setDefaultProgramId(...)`
335
+ 3. `FIVE_PROGRAM_ID`
336
+ 4. release-baked default (if present)
337
+
338
+ ## 9) Frontend Integration Baseline
339
+
340
+ 1. Build execute instructions via SDK (`FiveProgram`), not custom serializers.
341
+ 2. Keep network selection explicit (`localnet`, `devnet`, `mainnet`).
342
+ 3. Surface signatures, CU metrics, and rich error states.
343
+ 4. Use LSP-backed editing where available to reduce DSL mistakes.
344
+
345
+ ## 10) Pattern Mapping for Complex Contracts
346
+
347
+ 1. Vault:
348
+ - authority-gated custody, withdraw invariants
349
+ 2. Escrow:
350
+ - lifecycle transitions, dual-party authorization
351
+ 3. Token/mint authority:
352
+ - supply accounting, freeze/delegate controls
353
+ 4. AMM/orderbook:
354
+ - conservation math, deterministic settlement
355
+ 5. Lending/perps/stablecoin:
356
+ - collateral/liquidation thresholds, risk checks
357
+
358
+ ## 11) Mainnet Safety Policy
359
+
360
+ Required preflight gates:
361
+ 1. Freeze artifact hash
362
+ 2. Lock target/program-id/RPC/key source
363
+ 3. Validate key custody
364
+ 4. Run simulation/dry-run path
365
+ 5. Predefine rollback/containment actions
366
+
367
+ Post-deploy:
368
+ 1. smoke execute
369
+ 2. confirmed tx validation
370
+ 3. CU baseline capture
371
+ 4. incident process if anomalies appear
372
+
373
+ ## 12) Common Failure Signatures
374
+
375
+ 1. `No program ID resolved for Five VM`:
376
+ - set explicit program-id source
377
+ 2. `Function '<name>' not found in ABI`:
378
+ - use exact ABI name (including namespace)
379
+ 3. `Missing required account/argument`:
380
+ - satisfy `.accounts(...)` and `.args(...)`
381
+ 4. owner/program mismatch:
382
+ - verify target program ownership assumptions
383
+ 5. CPI mismatch:
384
+ - verify explicit serializer/discriminator/account order
385
+
386
+ ## 13) Definition of Done
387
+
388
+ Complete means:
389
+ 1. `.five` artifact produced
390
+ 2. tests passed with evidence
391
+ 3. deployment confirmed (if in scope)
392
+ 4. execution confirmed with `meta.err == null` (if in scope)
393
+ 5. signatures + CU metrics recorded
394
+ 6. integration snippet delivered (SDK/frontend when requested)
395
+
396
+ ## 14) Agent Behavior Rules
397
+
398
+ 1. Prefer deterministic, minimal command paths.
399
+ 2. Verify tx outcomes; do not assume send success == execution success.
400
+ 3. Avoid hidden defaults for deploy/CPI critical parameters.
401
+ 4. Keep changes auditable and reproducible.
402
+ 5. If uncertain, inspect compiler/CLI source directly.