Getting Started with ASTRA
This section gets you from nothing to a running ASTRA agent in a few minutes. Use Check your setup if Java, Maven or your editor needs configuring. Once you have a working project, Programming with ASTRA explains the concepts behind it.
What you’ll need
ASTRA requires no direct installation. ASTRA code is compiled and run using Apache Maven, and the entire ASTRA codebase is available through Maven Central. You will need:
A Java Development Kit (JDK 17 or later)
Apache Maven (3.3 or later)
A text editor or IDE
The source code for ASTRA is available through gitlab.com.
Create your first project
The quickest way to create an ASTRA project is to use the ASTRA Maven archetype. In a folder of your choice, type:
mvn archetype:generate \
-DarchetypeGroupId=com.astralanguage \
-DarchetypeArtifactId=astra-archetype \
-DarchetypeVersion=2.6.1 \
-DgroupId=examples \
-DartifactId=hello \
-Dversion=0.1.0
You should change the groupId and artifactId to reflect your own project. This creates a hello folder containing a Maven build file (pom.xml) and a single agent program, src/main/astra/Main.astra:
agent Main {
module Console console;
rule +!main(list args) {
console.println("Hello World, ASTRA");
}
}
Run it
From inside the hello folder, type:
mvn
This compiles the agent program and starts it. While there will be a lot of output, at the end you should see:
[INFO] --- astra:2.6.1:run (default-cli) @ hello ---
[main] Hello World, ASTRA
The text in square brackets is the name of the agent that generated the output (main by default). The ASTRA platform keeps running after the agent has finished, so press Ctrl+C to stop it. To make an agent end the program itself, see the Hello World example.
The Building and Deploying ASTRA Programs guide explains what is going on in more detail, including how to create a project without the archetype and how to choose which agent program is run.
ASTRA and IDE Integration
While ASTRA can be used with any IDE that supports Maven, we have chosen to provide support for syntax highlighting for the Visual Studio Code platform. This support is delivered through a custom extension. To install the extension, simply click on the extensions tab and type astra.
Open the generated project folder in your editor. IntelliJ users can follow its maintained Maven project guide. For ASTRA syntax highlighting, community extensions are available:
Intellij Syntax Highlighting: contributed by Maximilian Scholl
Neovim Syntax Highlighting: contributed by Niall Mahon
Make your first change
Stop the running program, change the message in src/main/astra/Main.astra, save it and run mvn again. Check that the new message appears. This edit–compile–run cycle is how you work through the examples in this guide.
The agent class name must match its filename: keep agent Main in Main.astra for this first project. The rule +!main(list args) handles the startup goal; console.println prints the message. plan is an equivalent spelling of rule.
Where next?
Programming with ASTRA develops an application from language fundamentals through design, Java modules, cooperation, testing and deployment.
Hello World example contains complete ASTRA programs; more are on GitLab.
Observing and Acting explains how to use and write Java modules.
Environments covers CArtAgO and EIS; LLM Integration and MAMS have their own sections.
Reference provides syntax, types, APIs, protocols and Maven options.
The YouTube video below provides a basic introduction to programming with ASTRA.