Imported from Eveheeero/fireman (
AGENTS.md). Install upstream withnpx skills add Eveheeero/fireman. Copyright stays with the author.
Fireman AI Agent Guide
Default
- Using
cargo bandcargo thelps to void lag when didn't touchfirebatdirectory. - Formatting uses
cargo +nightly fmt - To avoid context overflow from voluminous logs, use regular expressions to filter and retrieve only the necessary segments for analysis.
.fb Pattern Policy
- COMMENT ONLY ANALYZATION NOT ALLOWED. INLINE FUNCTION ONLY OR FLAG ONLY TOO.
- Centralize predefined
.fbpattern and script registration infireball/src/abstract_syntax_tree/optimize/pattern_matching.rs. - Instead, rewrite IR or AST to human readable structure.
- Wrtie
.fbfile withDSLinpattern_matchingand.rsatfireball::abstract_syntax_tree::optimize::pattern_matching::embeddedboth. - You can use
rhaiscript and can modify.fbDSL to make general methods. - If a rewrite cannot be expressed with the existing general pattern engine, keep it in Rust until a general-purpose pattern feature exists.
- Always keep
patterns/examples/all_syntax.fbup to date when adding or changing.fbDSL syntax. This file is the canonical reference for all supported directives. - Every new or changed DSL directive MUST have a test at each
fireball::abstract_syntax_tree::optimize::pattern_matching::embedded.
Code Style Guidelines
General Conventions
- Persona: Adhere to the ODIN (Outline Driven INtelligence) persona defined in
AGENTS.md.- Execute with precision and surgical accuracy.
- No emojis in code, comments, or commit messages.
- Reason deeply before acting using diagrams.
- File Organization:
- Use
camel_casefor directory and file names (e.g.,outline_driven_development,agent_heuristics.md). - Temporal Files: ALL temporal artifacts for outline-driven development MUST use
.outline/directory. Use/tmpfor scratch work.
- Use
- Indentation & Formatting:
- Markdown: Use ATX headers (
#,##). Max line length 100 characters where feasible.
- Markdown: Use ATX headers (
Operational Rules
Diagram-First Reasoning
MANDATORY: Before complex implementation, reason through:
- Architecture: Components, interfaces, contracts.
- Data Flow: Sources, transformations, sinks.
- Concurrency: Threads, sync, race prevention.
- Memory: Ownership, lifetimes, safety.
- Optimization: Bottlenecks, complexity targets.
- Tidiness: Naming, structure, minimal complexity.
Tool Selection Strategy
- Search/Discovery: Use
fd(Primary) andripgrep(rg). - Code Edit: Use
ast-grep(Structure) andsrgn(Grammar-Regex). - Context: Use
repomixto pack/analyze codebases. - Banned Tools:
ls→ USEezafind→ USEfdgrep→ USErgorast-grepcat→ USEbatsed→ USEsrgnorast-grep
Git Protocol (Branchless)
- Strategy: Git = Source of Truth. Work in detached HEAD for anonymous commits.
- Atomic Commits: One logical change per commit. Tests pass in isolation.
Verification & Refinement
Three-Stage Protocol:
- Pre-Action: Verify file locations, patterns, and scope.
- Mid-Action: Verify state consistency and ability to rollback.
- Post-Action: Verify changes applied correctly, tests pass, no regressions.
Risk Scoring:
- Low: Standard verification.
- Medium: Progressive refinement (MVC → 10% → 100%).
- High: Plan first, extensive testing.
Post-Transform Check:
- Run
ast-grep -Uto apply changes. - Use
difft --display inlineto verify diffs.
UI/UX Design Guidelines
- Design Tokens: MUST use design system tokens, not hardcoded values.
- Density: Target 2-3x denser layouts. Use spacing scales (4/8/12/16/24px).
- Paradigms: Post-minimalism, Neo-brutalism, Glassmorphism. Avoid boring minimalism.
- Forbidden:
- Purple-blue/purple-pink colors.
transition: all.font-family: system-ui.- Gradients on buttons/titles (unless requested).
- Quality Gate: Design excellence ≥ 95% (compliance, accessibility, performance).
Good Coding Paradigms
- Contract-first Development: Define preconditions, postconditions, and invariants explicitly.
- Immutable-first Data: Default to immutable data structures. Mutations explicit and localized.
- Zero-allocation/Zero-copy: Prefer zero-allocation hot paths. Use arena allocators, object pools.
- Fail-Fast: Detect errors early, fail immediately with context. Typed error domains.
- Principle of Least Surprise: Code should behave as readers expect. Explicit over implicit.
Structure Paths (fireball)
Major Structs (quick reference)
Address-fireball/src/core/address.rsInstruction-fireball/src/core/instruction.rsSection/Sections-fireball/src/core/section.rs,fireball/src/core/sections.rsBlock/Blocks-fireball/src/core/block.rs,fireball/src/core/blocks.rsRelation/Relations-fireball/src/core/relation.rs,fireball/src/core/relations.rsPreDefinedOffset/PreDefinedOffsets-fireball/src/core/pre_defined_offset.rs,fireball/src/core/pre_defined_offsets.rsPe-fireball/src/pe/mod.rsVirtualMachine,IrBlock,Ir-fireball/src/ir/mod.rsRegister-fireball/src/ir/register.rsIrDataAccess-fireball/src/ir/data.rsIrStatementDescriptor/IrStatementDescriptorMap<T>-fireball/src/ir/utils.rsIrVariable,BlockGrouper,BlockGroup,KnownDataType,IrFunction,IrFunctionVariable-fireball/src/ir/analyze/...Ast,AstFunction,AstVariable,AstParameter-fireball/src/abstract_syntax_tree/objects/...AstPrintConfig,AstOptimizationConfig-fireball/src/abstract_syntax_tree/objects/...WrappedAstStatement,Wrapped<T>,AstDescriptor-fireball/src/abstract_syntax_tree/objects/wrapper.rsAstPattern,AstPatternRule,AstPatternIrReplacement,AstPatternAsmData,AstPatternAstData,AstPatternIrData,AstPatternScript,AstPatternRange-fireball/src/abstract_syntax_tree/optimize/pattern_matching.rsVersionMap<..>-fireball/src/utils/version_map.rsAstFunction-fireball/src/abstract_syntax_tree/objects/function.rs
Entry points
Fireball(enum) -fireball/src/lib.rs- Common imports -
fireball/src/prelude.rs
Core (fireball/src/core)
- Module exports -
fireball/src/core/mod.rs Fire(trait) -fireball/src/core/fire.rsFireRaw(trait) -fireball/src/core/fire_raw.rsAddress-fireball/src/core/address.rsInstruction-fireball/src/core/instruction.rsSection-fireball/src/core/section.rsSections-fireball/src/core/sections.rsBlock-fireball/src/core/block.rsBlocks-fireball/src/core/blocks.rsRelation-fireball/src/core/relation.rsRelations-fireball/src/core/relations.rsDestinationType(enum) -fireball/src/core/relation.rsRelationType(enum) -fireball/src/core/relation.rsPreDefinedOffset-fireball/src/core/pre_defined_offset.rsPreDefinedOffsets-fireball/src/core/pre_defined_offsets.rs
PE (fireball/src/pe)
Pe-fireball/src/pe/mod.rs
Arch -> IR (fireball/src/arch)
- asm to
IrStatementconversion -fireball/src/arch/x86_64/instruction_analyze.rs - statement/data shortcuts -
fireball/src/arch/x86_64/instruction_analyze_shortcuts/...
IR (fireball/src/ir)
- Module exports -
fireball/src/ir/mod.rs VirtualMachine-fireball/src/ir/mod.rsIrBlock-fireball/src/ir/mod.rsIr-fireball/src/ir/mod.rsArchitecture(enum) -fireball/src/ir/mod.rsRegister-fireball/src/ir/register.rsIrStatement(enum) -fireball/src/ir/statements.rsIrStatementSpecial(enum) -fireball/src/ir/statements.rsIrUnaryOperator(enum) -fireball/src/ir/operator.rsIrBinaryOperator(enum) -fireball/src/ir/operator.rsIrStatementDescriptor-fireball/src/ir/utils.rsIrStatementDescriptorMap<T>-fireball/src/ir/utils.rsIrData(enum) -fireball/src/ir/data.rsIrDataAccess-fireball/src/ir/data.rsIrIntrinsic(enum) -fireball/src/ir/data.rsNumCondition(enum) -fireball/src/ir/data.rsIrDataAccessType(enum) -fireball/src/ir/data.rsIrDataOperation(enum) -fireball/src/ir/data.rsIrAccessSize(enum) -fireball/src/ir/data.rsIrDataContainable(trait) -fireball/src/ir/data.rsARM(trait) -fireball/src/ir/arm/mod.rsX64(trait) -fireball/src/ir/x86_64/mod.rsX64Mut(trait) -fireball/src/ir/x86_64/mod.rs
IR analysis (fireball/src/ir/analyze)
IrVariable-fireball/src/ir/analyze/variables.rsBlockGrouper-fireball/src/ir/analyze/block_grouper.rsBlockGroup-fireball/src/ir/analyze/block_grouper.rsKnownDataType-fireball/src/ir/analyze/datatype.rsDataType(enum) -fireball/src/ir/analyze/datatype.rs
AST (fireball/src/abstract_syntax_tree)
- Module exports -
fireball/src/abstract_syntax_tree/mod.rs Ast-fireball/src/abstract_syntax_tree/objects/ast.rsAstFunction-fireball/src/abstract_syntax_tree/objects/function.rsAstStatement(enum) -fireball/src/abstract_syntax_tree/objects/statement.rsAstExpression(enum) -fireball/src/abstract_syntax_tree/objects/expression.rsAstValueType(enum) -fireball/src/abstract_syntax_tree/objects/value.rsAstValue(enum) -fireball/src/abstract_syntax_tree/objects/value.rsAstLiteral(enum) -fireball/src/abstract_syntax_tree/objects/value.rsAstVariable-fireball/src/abstract_syntax_tree/objects/variable.rsAstVariableId-fireball/src/abstract_syntax_tree/objects/tags.rsAstFunctionId-fireball/src/abstract_syntax_tree/objects/tags.rsAstFunctionVersion-fireball/src/abstract_syntax_tree/objects/tags.rsAstParameter-fireball/src/abstract_syntax_tree/objects/parameter.rsAstParameterLocation(enum) -fireball/src/abstract_syntax_tree/objects/parameter.rsAstUnaryOperator(enum) -fireball/src/abstract_syntax_tree/objects/operator.rsAstBinaryOperator(enum) -fireball/src/abstract_syntax_tree/objects/operator.rsAstJumpTarget(enum) -fireball/src/abstract_syntax_tree/objects/etc.rsAstCall(enum) -fireball/src/abstract_syntax_tree/objects/etc.rsAstBuiltinFunctionArgument(enum) -fireball/src/abstract_syntax_tree/objects/etc.rsAstBuiltinFunction(enum) -fireball/src/abstract_syntax_tree/objects/etc.rsArcAstFunctionMap(type) -fireball/src/abstract_syntax_tree/objects/etc.rsArcAstVariableMap(type) -fireball/src/abstract_syntax_tree/objects/etc.rsAstPrintConfig-fireball/src/abstract_syntax_tree/objects/print_config.rsAstOptimizationConfig-fireball/src/abstract_syntax_tree/objects/optimization.rsAstOptimizationKind(enum) -fireball/src/abstract_syntax_tree/objects/optimization.rsWrappedAstStatement-fireball/src/abstract_syntax_tree/objects/wrapper.rsWrapped<T>-fireball/src/abstract_syntax_tree/objects/wrapper.rsAstDescriptor-fireball/src/abstract_syntax_tree/objects/wrapper.rsAstStatementOrigin(enum) -fireball/src/abstract_syntax_tree/objects/wrapper.rsAstValueOrigin(enum) -fireball/src/abstract_syntax_tree/objects/wrapper.rsPrintWithConfig(trait) -fireball/src/abstract_syntax_tree/traits.rsGetRelatedVariables(trait) -fireball/src/abstract_syntax_tree/traits.rsAstVariableAccessType(enum) -fireball/src/abstract_syntax_tree/traits.rs
AST Analyzation (AST Optimization) (fireball/src/abstract_syntax_tree/optimize)
AstPattern-fireball/src/abstract_syntax_tree/optimize/pattern_matching.rsAstPatternOrigin(enum) -fireball/src/abstract_syntax_tree/optimize/pattern_matching.rsAstPatternArgType(enum) -fireball/src/abstract_syntax_tree/optimize/pattern_matching.rs
Pattern Matching Engine (fireball/src/abstract_syntax_tree/optimize/pattern_matching/)
mod.rs— Core types:AstPatternRule,AstPatternClauseGroup,AstPatternInBlock(enum),AstPatternOutAction(enum),AstPatternScript(stores pre-compiledrhai::AST, no source text),AstPatternAsmData,AstPatternAstData,AstPatternIrData,AstPatternRange,IgnoreCommentFilter(enum),ClearIgnoreTarget(enum)apply.rs— Execution engine:AstPatternScriptContext(holds&[WrappedAstStatement],&[IrStatement],&[AstPatternNormalizedAsmLine]),AstPatternLoadedRule, Rhai engine/scope setup, if/do script evaluation, ignore filter application, asm/ast/ir matchingfb_parser.rs—.fbDSL parser:parse_pattern_file(),parse_rhai_script(), allif:/do:directive parsingrhai_types.rs— Rhai wrapper types.stmt_pattern/— PatTree matching:parser.rs(PatTree parser),matcher.rs(statement/expression matching),construct.rs(emit construction from PatTree),predicate.rs(where predicates)ir_parser.rs— IR/asm text parsing for pattern conditions
Utils / errors (fireball/src/utils)
VersionMap<..>-fireball/src/utils/version_map.rsAos<T>(enum) -fireball/src/utils/arc_or_static.rsFireballError(enum) -fireball/src/utils/error.rsDecompileError(enum) -fireball/src/utils/error/decompile_error.rsDisassembleError(enum) -fireball/src/utils/error/disassemble_error.rsIoError(enum) -fireball/src/utils/error/io_error.rsIrAnalyzeAssertionFailure(enum) -fireball/src/utils/error/ir_analyze_assertion_error.rs
If you want to find another struct/enum/trait/type, search by regex (e.g. rg "^\\s*pub\\s+(struct|enum|trait|type)\\s+Name").
Testing
Never add tests for firebat or the Fireman TUI. This is a hard rule.
Due to the difficulty of setting up AST and IR environments, agents must refrain from writing internal tests for them and instead conduct testing using reversing results from tests/resources/hello_world.exe.
To verify and compare disassembly and decompiled outputs during testing, use the radare (r2) CLI.
After tests succeed, analyze log files to confirm the decompilation results are normal and match the expected output.