Skip to content

Latest commit

 

History

History
79 lines (68 loc) · 3.61 KB

File metadata and controls

79 lines (68 loc) · 3.61 KB

AGENTS.md

Development Commands

  • moon check - Lint and type-check (runs in pre-commit hook)
  • moon test - Run all tests
  • moon test -p <package> -f <file> - Run specific tests
  • moon fmt - Format code
  • moon info - Update .mbti interface files
  • moon info && moon fmt - Standard workflow before committing

MoonBit Notes

  • Use suberror for error types, raise to throw, try! func() |> ignore to ignore errors
  • Use func() |> ignore not let _ = func()
  • When using inspect(value, content=expected_string), don't declare a separate let expected = ... variable - it causes unused variable warnings. Put the expected string directly in the content= parameter
  • Use !condition not not(condition)
  • Use f(value) not f!(value) (deprecated)
  • Use for i in 0..<n not C-style for i = 0; i < n; i = i + 1
  • Use if opt is Pattern(v) { ... } for single-branch matching, not match opt {}
  • Use arr.clear() not while arr.length() > 0 { arr.pop() }
  • Use s.code_unit_at(i) or for c in s not s[i] (deprecated)
  • Struct/enum visibility: priv (hidden) < (none)/abstract (type only) < pub (readonly) < pub(all) (full)
  • Default to abstract (no modifier) for internal types; use pub struct when external code reads fields
  • Use pub(all) enum for enums that external code pattern-matches on
  • Use let mut only for reassignment, not for mutable containers like Array
  • Use reinterpret_as_uint() for unsigned ops, to_int() for numeric conversion
  • Use Array::length() not Array::size()
  • In moon.pkg.json, use "import", "test-import" and "wbtest-import" to manage package importing for ".mbt", "_test.mbt" and "_wbtest.mbt"
  • Use Option::unwrap_or not Option::or
  • Use const CAPITAL_NAME : Type = expr to define constants, not let or lower_case_name
  • Use Ref::new not @ref.new
  • Use pub(open) trait to export a trait
  • Use try! s[start:end] to forcely get a slice (StringView)

License Header

  • Add the following header to new source files (unless the file already has an existing license header):
    // Copyright 2025 International Digital Economy Academy
    //
    // Licensed under the Apache License, Version 2.0 (the "License");
    // you may not use this file except in compliance with the License.
    // You may obtain a copy of the License at
    //
    //     http://www.apache.org/licenses/LICENSE-2.0
    //
    // Unless required by applicable law or agreed to in writing, software
    // distributed under the License is distributed on an "AS IS" BASIS,
    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    // See the License for the specific language governing permissions and
    // limitations under the License.
    

Landing the Plane (Session Completion)

When ending a work session, you MUST complete ALL steps below. Work is NOT complete until git push succeeds.

MANDATORY WORKFLOW:

  1. File issues for remaining work - Create issues for anything that needs follow-up
  2. Run quality gates (if code changed) - Tests, linters, builds
  3. Update issue status - Close finished work, update in-progress items
  4. PUSH TO REMOTE - This is MANDATORY:
    git pull --rebase
    git push
    git status  # MUST show "up to date with origin"
  5. Clean up - Clear stashes, prune remote branches
  6. Verify - All changes committed AND pushed
  7. Hand off - Provide context for next session

CRITICAL RULES:

  • Work is NOT complete until git push succeeds
  • NEVER stop before pushing - that leaves work stranded locally
  • NEVER say "ready to push when you are" - YOU must push
  • If push fails, resolve and retry until it succeeds