---
url: /guide/advanced/ultikits-cli.md
---
# UltiKits CLI

`@ultikits/cli` is the official command-line tool for publishing UltiTools plugin modules to the [UltiCloud](https://panel.ultikits.com/) marketplace. Developers can use it to authenticate, initialize project metadata, upload JAR files, and manage published modules and versions.

This page covers `@ultikits/cli` 3.0.0. Versions 1.x do not work with UltiCloud; upgrade with `npm install -g @ultikits/cli@latest` and run `ultikits login` again.

::: info Module template (as of v7.0.0)
In CLI 3.0.0, `ultikits create` scaffolds a module for Paper 26.3 and JDK 25. It defaults to framework version `7.0.0` and rejects versions below `7.0.0`. Use CLI `2.0.1` if you still need the 6.x template.
:::

To create a 7.0 module by hand, follow Quick Start to write the [`pom.xml`](/guide/quick-start#maven-build) and [module descriptor](/guide/quick-start#module-descriptor), then continue with the module entry point.

The optional argument to `ultikits create [directory]` only selects the output directory; `create` always prompts and has no non-interactive options.

::: tip Recommended: local publishing
Official UltiTools modules are published locally by their maintainers: the accepted JAR is attached to a GitHub release and that same file is published to UltiCloud with the CLI. Third-party developers can use the same path.
[GitHub Actions](#ci-cd-with-github-actions) is an optional manual workflow, not the official modules' release path.
:::

## Installation

```bash
npm install -g @ultikits/cli
```

Verify the installation:

```bash
ultikits --version
```

::: info Requirements

* Node.js 18 or later
* npm or any Node package manager
* JDK 25 or later and Maven to build projects generated by the 7.0 template

:::

## Authentication

Before publishing, you need to authenticate with UltiCloud. The CLI supports two methods.

### Browser Login (Device Authorization)

```bash
ultikits login
```

The CLI prints a user code and a confirmation link and opens your browser. Confirm the code there; the CLI polls and finishes on its own.

The CLI credential is saved to `~/.ultikits/credentials.json`.

### Developer Key

If you prefer non-interactive login (e.g., on a remote server), use a developer key:

1. Go to [panel.ultikits.com/developer](https://panel.ultikits.com/developer)
2. Copy your developer key (`ucd_…`)
3. Run `ultikits login --token` and paste the key when prompted, or run `ultikits login --token ucd_…`
4. The CLI checks the key with UltiCloud before saving it

### Environment Variable

For CI/CD pipelines, set the `ULTIKITS_TOKEN` environment variable instead of running `ultikits login`:

```bash
export ULTIKITS_TOKEN=ucd_...
```

The value must be a developer key (`ucd_…`) or a CLI credential (`ucc_…`); an old access token is refused. When it is set, it is used instead of the saved credential. `--api-url` or `ULTIKITS_API_URL` selects another UltiCloud API (https only); the default is `https://api.ultikits.com`.

### Other Auth Commands

```bash
ultikits whoami     # Check current authentication status
ultikits logout     # Remove stored credentials
```

## Scaffolding a New Module

In CLI 3.0.0, `ultikits create` generates modules only for UltiTools-API 7.0.0 or later. The template targets Paper 26.3 and Java 25.

To upgrade an existing 6.x module, see [Upgrading from 6.x to 7.0](/guide/advanced/upgrading-to-7).

```bash
ultikits create
```

The project directory defaults to the module name. To specify another name, use `ultikits create my-plugin-dir`.

### Interactive Prompts

| Prompt | Default | Accepted input |
|--------|---------|----------------|
| `Module name (e.g., UltiHome):` | None | Two or more ASCII letters or digits, starting with an uppercase letter. `UltiToolsPlugin` and `UltiToolsModule` are not allowed. |
| `Java package name:` | Derived from the module name, e.g. `com.ultikits.plugins.home` for `UltiHome` | Dot-separated lowercase Java identifiers. Each segment must start with `a`–`z` or `_`, followed by zero or more lowercase letters, digits or underscores. Reserved words are not allowed. |
| `Short description:` | None | A short description. It must not be blank after trimming. |
| `Author:` | `git config user.name`, if available | An author name. It must not be blank after trimming. |
| `UltiTools-API version:` | `7.0.0` | Three numeric parts (`X.Y.Z`), optionally followed by one or more hyphen-separated ASCII alphanumeric suffixes, e.g. `7.0.0-SNAPSHOT`. The derived API level must fit in a signed 32-bit integer. Versions below `7.0.0` are rejected and the prompt is shown again. |

### Generated Project

For `UltiHome` with the default Java package, the command writes these files:

```text
UltiHome/
├── .gitignore
├── README.md
├── pom.xml
└── src/main/
    ├── java/com/ultikits/plugins/home/UltiHome.java
    └── resources/
        ├── plugin.yml
        └── messages/
            ├── en.yml
            └── zh.yml
```

The CLI also attempts to initialize a Git repository. It does not create an empty `src/test/java` directory.

The generated `pom.xml` sets the compiler option `--release 25` and includes test dependencies. Install JDK 25 or later and use it to run Maven. The POM adds the Maven Central snapshot repository only if the selected UltiTools-API version ends in `-SNAPSHOT`.

The module descriptor `plugin.yml` contains an unquoted integer `api-version`. The CLI joins the three numeric parts of the selected framework version, ignoring the suffix: `7.0.0-SNAPSHOT` yields `api-version: 700`, while `7.0.1` yields `api-version: 701`.

`messages/en.yml` and `messages/zh.yml` contain matching sample message keys with MiniMessage values. The descriptor sets `source-language: en`. See [Messages](/guide/essentials/messages) for how to use the catalogues.

The generated main class implements `registerSelf()` and supplies the `onUnregister()` and `onReload()` hooks. It does not override the final `unregisterSelf()` or `reloadSelf()` methods.

```java
package com.ultikits.plugins.home;

import com.ultikits.ultitools.abstracts.UltiToolsPlugin;
import com.ultikits.ultitools.annotations.UltiToolsModule;

@UltiToolsModule(scanBasePackages = "com.ultikits.plugins.home")
public class UltiHome extends UltiToolsPlugin {

    @Override
    public boolean registerSelf() {
        return true;
    }

    @Override
    protected void onUnregister() {
        // Release any module-owned resources here.
    }

    @Override
    protected void onReload() {
        // Refresh any module-owned state after configuration reload.
    }
}
```

### Build and Test

Follow the `Next steps:` printed by the command. For the default directory in this example, run these commands with JDK 25 or later:

```bash
cd UltiHome
mvn package
```

`mvn package` runs any tests you add under `src/test/java` and writes the module JAR to `target/`. To test the built module on a Paper 26.3 server running Java 25 and the matching UltiTools-API version, place the JAR in `plugins/UltiTools/plugins/` and restart the server.

### Module tests without a server {#serverless-module-tests}

Put JUnit Jupiter tests in `src/test/java`, in the same Java package as the code they exercise. The 7.0 scaffold includes Jupiter and Mockito as test dependencies; for a hand-written project, add them with test scope and use a Surefire version that runs Jupiter tests. Run `mvn test`. These examples use JUnit Jupiter 6.1.3 (`org.junit.jupiter.api`), as included in the 7.0 scaffold, and public UltiTools APIs. A mock records or supplies values; it does not run Paper.

#### Message catalogues

In both files, nest `named` under `greeting:`: put `named: "Hello, <name>!"` in `src/main/resources/messages/en.yml` and put `named: "你好，<name>！"` in `src/main/resources/messages/zh.yml`. Compare the keys of all scalar values in the two files, including numbers and booleans, and render each parameterized message in both locales with distinct test values. Use SnakeYAML, supplied by Paper API, to read scalar values as text, as the framework does when loading messages. A missing, misspelled or escaped `<name>` makes the expected text fail even if the key sets match. Add a rendering assertion for each parameterized key in your module. Read from the module's resources directory so a dependency JAR cannot supply a file with the same name. This does not check the server's locale selection, overrides or in-game delivery.

```java
package com.example.mymodule;

import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.LinkedHashMap;
import java.util.Map;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.junit.jupiter.api.Test;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.nodes.MappingNode;
import org.yaml.snakeyaml.nodes.ScalarNode;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

class MessageCatalogueTest {
    @Test
    void bothLocalesProvideTheSameKeysAndRenderTheName() throws Exception {
        var en = load("en");
        var zh = load("zh");
        assertEquals(en.keySet(), zh.keySet());
        assertEquals("Hello, test-name!", renderGreeting(en));
        assertEquals("你好，test-name！", renderGreeting(zh));
    }

    private static Map<String, String> load(String locale) throws Exception {
        var module = Path.of(System.getProperty("basedir", "."));
        var catalogue = module.resolve("src/main/resources/messages/" + locale + ".yml");
        try (var reader = Files.newBufferedReader(catalogue, StandardCharsets.UTF_8)) {
            var messages = new LinkedHashMap<String, String>();
            collectScalars(assertInstanceOf(MappingNode.class, new Yaml().compose(reader)), "", messages);
            return messages;
        }
    }

    private static void collectScalars(MappingNode mapping, String prefix, Map<String, String> messages) {
        for (var entry : mapping.getValue()) {
            var key = assertInstanceOf(ScalarNode.class, entry.getKeyNode()).getValue();
            var path = prefix + key;
            if (entry.getValueNode() instanceof MappingNode nested) {
                collectScalars(nested, path + ".", messages);
            } else {
                var scalar = assertInstanceOf(ScalarNode.class, entry.getValueNode(), path);
                assertNull(messages.putIfAbsent(path, scalar.getValue()), "Duplicate message key: " + path);
            }
        }
    }

    private static String renderGreeting(Map<String, String> messages) {
        String template = messages.get("greeting.named");
        assertNotNull(template);
        var rendered = MiniMessage.miniMessage().deserialize(template, Placeholder.unparsed("name", "test-name"));
        return PlainTextComponentSerializer.plainText().serialize(rendered);
    }
}
```

#### Form and chest callbacks

Use the classes from [UI: Intents and Sessions](./ui-service). For a form, build a `FormResponse` with the input handles from the captured form, not new handles with the same keys. For a chest, call the action from the captured grid with a mock click. The test executor runs inline so you can assert your callback's effects, not Paper's scheduling, dialog input, layout, or inventory event routing. Check those on Paper with a client.

```java
package com.example.mymodule.ui;

import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicReference;
import com.ultikits.ultitools.scheduling.Scheduler;
import com.ultikits.ultitools.scheduling.TaskContext;
import com.ultikits.ultitools.ui.Form;
import com.ultikits.ultitools.ui.FormResponse;
import com.ultikits.ultitools.ui.Grid;
import com.ultikits.ultitools.ui.GridClick;
import com.ultikits.ultitools.ui.GridSession;
import com.ultikits.ultitools.ui.GridSlot;
import com.ultikits.ultitools.ui.UiResult;
import com.ultikits.ultitools.ui.UiService;
import com.ultikits.ultitools.ui.UiSession;
import org.bukkit.entity.Player;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;

import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

class ModuleUiTest {
    @Test
    @SuppressWarnings("unchecked")
    void submittedValuesReachTheHomeCallback() {
        var ui = mock(UiService.class);
        var player = mock(Player.class);
        var scheduler = mock(Scheduler.class);
        var entity = mock(TaskContext.class);
        var createHome = mock(HomeFormExample.CreateHome.class);
        UiSession<FormResponse> session = mock(UiSession.class);
        var result = new CompletableFuture<UiResult<FormResponse>>();
        when(ui.show(eq(player), any(Form.class))).thenReturn(session);
        when(session.result()).thenReturn(result);
        when(scheduler.entity(player)).thenReturn(entity);
        doAnswer(call -> {
            call.getArgument(0, Runnable.class).run();
            return null;
        }).when(entity).execute(any(Runnable.class));

        var completion = HomeFormExample.show(ui, scheduler, player, createHome);
        var form = ArgumentCaptor.forClass(Form.class);
        verify(ui).show(eq(player), form.capture());
        var inputs = form.getValue().inputs();
        var response = FormResponse.of(form.getValue(), Map.of(
                inputs.get(0), "Cabin", inputs.get(1), true, inputs.get(2), 3.0));
        result.complete(new UiResult.Completed<>(response));
        completion.toCompletableFuture().join();

        verify(createHome).create(player, "Cabin", true, 3.0);
    }

    @Test
    void arenaIconPassesTheViewerAndClosesTheSession() {
        var ui = mock(UiService.class);
        var player = mock(Player.class);
        var joined = new AtomicReference<Player>();
        ArenaMenuExample.show(ui, player, joined::set);
        var grid = ArgumentCaptor.forClass(Grid.class);
        verify(ui).show(eq(player), grid.capture());
        var session = mock(GridSession.class);
        var click = mock(GridClick.class);
        when(click.viewer()).thenReturn(player);
        when(click.session()).thenReturn(session);

        grid.getValue().item(new GridSlot(0, 4)).orElseThrow().action().orElseThrow().onClick(click);

        assertSame(player, joined.get());
        verify(session).close();
    }
}
```

#### Config-bound scheduling

Use the two classes from [Config-Bound Timing](./scheduled-tasks#config-bound-timing). Check that the method points to the intended config class and YAML key; test the method's own work separately by calling it with test dependencies. Neither check exercises config registration, the first tick or repeat interval, or how `/ul reload` applies a new value. Check those on Paper.

```java
package com.example.mymodule.scheduling;

import com.ultikits.ultitools.annotations.ConfigEntry;
import com.ultikits.ultitools.annotations.Scheduled;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

class BoundScheduleTest {
    @Test
    void bothTimingsUseTheSameConfigKey() throws ReflectiveOperationException {
        var method = BoundScheduleService.class.getMethod("distributeInterest");
        var schedule = method.getAnnotation(Scheduled.class);
        assertEquals(BoundScheduleConfig.class, schedule.config());
        var field = BoundScheduleConfig.class.getDeclaredField("interestInterval");
        String key = field.getAnnotation(ConfigEntry.class).path();
        assertEquals("interest.interval", key);
        assertEquals(key, schedule.delayKey());
        assertEquals(key, schedule.periodKey());
    }
}
```

#### Config validation

Pass candidate values to `validateProposedProperties`; it checks the proposed state and restores the original fields even on failure. This example checks rejection of an empty value without reading or writing a YAML file. Validation tries to construct a temporary instance, so declare a nested test config class `public static` and give it an accessible `(String)` or no-argument constructor. Test the loading and reload path with an actual YAML file on Paper if you need to verify live behavior.

```java
package com.example.mymodule.config;

import com.google.gson.JsonObject;
import com.ultikits.ultitools.abstracts.AbstractConfigEntity;
import com.ultikits.ultitools.annotations.ConfigEntity;
import com.ultikits.ultitools.annotations.ConfigEntry;
import com.ultikits.ultitools.annotations.config.NotEmpty;
import com.ultikits.ultitools.exceptions.ConfigurationException;
import com.ultikits.ultitools.exceptions.ErrorCode;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class ConfigValidationTest {
    @ConfigEntity("config/profile.yml")
    public static class ProfileConfig extends AbstractConfigEntity {
        @ConfigEntry(path = "display-name")
        @NotEmpty
        private String name = "Explorer";

        public ProfileConfig(String path) {
            super(path);
        }
    }

    @Test
    void checksProposedValuesWithoutChangingTheLoadedValue() {
        var config = new ProfileConfig("config/profile.yml");
        var changes = new JsonObject();
        changes.addProperty("display-name", "");
        var failure = assertThrows(ConfigurationException.class,
                () -> config.validateProposedProperties(changes));
        assertEquals(ErrorCode.CONFIG_VALIDATION_FAILED, failure.getErrorCode());

        changes.addProperty("display-name", "Ranger");
        assertDoesNotThrow(() -> config.validateProposedProperties(changes));
        assertEquals("Explorer", config.name);
    }
}
```

#### Data entities

Use `PlayerNote` and `PlayerNoteStore` from [Data Storage](../essentials/data-storage). Check the entity mapping you declared and the store operations your code requests. The fake operator assigns an ID so the test can check that the calling code returns it. It does not check scope registration, ID generation or persistence. Verify registration on Paper and round trips with the storage backends you support.

```java
package com.example.mymodule.data;

import com.ultikits.ultitools.abstracts.UltiToolsPlugin;
import com.ultikits.ultitools.annotations.Table;
import com.ultikits.ultitools.interfaces.DataOperator;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

class PlayerNoteStoreTest {
    @Test
    @SuppressWarnings("unchecked")
    void addsTheNoteToTheExpectedEntityAndReturnsItsAssignedId() {
        var module = mock(UltiToolsPlugin.class);
        DataOperator<PlayerNote> operator = mock(DataOperator.class);
        when(module.getDataOperator(PlayerNote.class)).thenReturn(operator);
        doAnswer(call -> {
            call.getArgument(0, PlayerNote.class).setId("test-id");
            return null;
        }).when(operator).insert(any(PlayerNote.class));

        assertEquals("test-id", new PlayerNoteStore(module).addNote("Meet at spawn"));

        var inserted = ArgumentCaptor.forClass(PlayerNote.class);
        verify(operator).insert(inserted.capture());
        assertEquals("Meet at spawn", inserted.getValue().getText());
        assertEquals("my_module_player_notes", PlayerNote.class.getAnnotation(Table.class).value());
    }
}
```

#### Bootstrap content

Use `MyModuleBootstrap` from [Declaring custom content](./startup-phases#bootstrap-content). A mock bootstrap context lets you verify the declarations your hook submits without initializing a registry. To check whether Paper accepts them, run a full start with the packaged module and verify that the enchantment, tags and embedded pack are available.

```java
package com.example.mymodule;

import java.util.List;
import com.ultikits.ultitools.bootstrap.DatapackChannel;
import com.ultikits.ultitools.bootstrap.EnchantmentChannel;
import com.ultikits.ultitools.bootstrap.EnchantmentDefinition;
import com.ultikits.ultitools.bootstrap.ModuleBootstrapContext;
import com.ultikits.ultitools.bootstrap.TagChannel;
import io.papermc.paper.registry.RegistryKey;
import net.kyori.adventure.key.Key;
import org.junit.jupiter.api.Test;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

class MyModuleBootstrapTest {
    @Test
    void declaresTheEnchantmentTagsAndEmbeddedPack() {
        var context = mock(ModuleBootstrapContext.class);
        var enchantments = mock(EnchantmentChannel.class);
        var packs = mock(DatapackChannel.class);
        when(context.enchantments()).thenReturn(enchantments);
        var tags = mock(TagChannel.class);
        when(context.tags()).thenReturn(tags);
        when(context.datapacks()).thenReturn(packs);

        new MyModuleBootstrap().bootstrap(context);

        verify(enchantments).register(eq(Key.key("mymodule:frost_edge")), any(EnchantmentDefinition.class));
        verify(tags).addToTag(RegistryKey.ENCHANTMENT, Key.key("minecraft:in_enchanting_table"),
                List.of(Key.key("mymodule:frost_edge")));
        verify(tags).setTag(RegistryKey.ITEM, Key.key("mymodule:frost_weapons"),
                List.of(Key.key("minecraft:diamond_sword")));
        verify(packs).embedded("frost");
    }
}
```

## Project Setup

### Initialize Project Config

Run the following command in your module's root directory:

```bash
ultikits init
```

This creates an `ultikits.json` file with interactive prompts:

```json
{
  "identifyString": "myplugin",
  "name": "MyPlugin",
  "shortDescription": "A brief description of your plugin.",
  "categoryId": 1
}
```

| Field | Description |
|-------|-------------|
| `identifyString` | Unique module identifier. 3-64 characters, lowercase letters, digits, `.` and `_`. Must start with a letter. |
| `name` | Display name shown on the marketplace. |
| `shortDescription` | Brief description, max 200 characters. |
| `categoryId` | Module category (see table below). |

### Categories

| ID | Category |
|----|----------|
| 1 | Utilities |
| 2 | Economy |
| 3 | World Management |
| 4 | Social & Chat |
| 5 | Permissions & Security |
| 6 | Gameplay |

## Publishing

### Basic Usage

Build and test the module, then keep the JAR you intend to release. Attach that file to your GitHub release and publish the same bytes with the CLI, without rebuilding between the two uploads:

```bash
mvn clean verify
ultikits publish target/MyPlugin-1.2.0.jar \
  --module-version 1.2.0 \
  --changelog "The body of the 1.2.0 section in CHANGELOG.md"
```

If no JAR path is supplied, the CLI searches `./target/` (skipping `-sources.jar` and `-javadoc.jar`). With a selected JAR, it automatically:

1. Uses that file for the upload
2. Reads `plugin.yml` from the JAR for name and version
3. Reads `ultikits.json` for identifyString, description, and category
4. Creates the module on UltiCloud if it doesn't exist, which needs a manage credential (`ultikits login`, or a developer key rotated to the manage scope)
5. Creates a new version and uploads the JAR

### Publish with Options

Specify the JAR path explicitly and override metadata with flags. Pass the body of the released version’s `CHANGELOG.md` section as one `--changelog` argument, rather than the whole file or a generic placeholder. Replace the sample text below with that section:

```bash
ultikits publish target/MyPlugin-1.2.0.jar \
  --module-version 1.2.0 \
  --changelog "The body of the 1.2.0 section in CHANGELOG.md"
```

Available flags:

| Flag | Description |
|------|-------------|
| `--id <identifyString>` | Override module identifier |
| `--name <name>` | Display name, used only when the module has to be created |
| `--module-version <version>` | Override version string |
| `--changelog <text>` | Version changelog |
| `--short-description <text>` | Short description, used only when the module has to be created |
| `--api-url <url>` | UltiCloud API URL (default `ULTIKITS_API_URL`, the stored login, or `https://api.ultikits.com`) |
| `-y, --yes` | Skip all confirmation prompts |

### Non-Interactive Mode

For CI/CD, use `--yes` to skip prompts and `ULTIKITS_TOKEN` for auth:

```bash
ULTIKITS_TOKEN=ucd_... ultikits publish --yes \
  --module-version "1.2.0" \
  --changelog "The body of the 1.2.0 section in CHANGELOG.md"
```

### Metadata Resolution

The CLI resolves metadata from multiple sources in this priority order:

**CLI flags** > **ultikits.json** > **plugin.yml from JAR**

For example, if you pass `--module-version 1.2.0`, it overrides the version in `plugin.yml`.

### Failed uploads and retries

A version whose artifact upload never completed is not published: it is not listed publicly or selected as the latest version. After a failed or interrupted upload, run the same `ultikits publish` command again with the **same JAR**: the CLI requests a new upload ticket for the pending version and the old ticket stops working. The pending version keeps the size and SHA-256 declared first, so to upload different bytes, delete the pending version in the developer centre or publish a higher version. A new version must be greater than every version of the module, including one still waiting for its upload.

A published version cannot be overwritten. Use a new version for changed bytes. If a network failure leaves the outcome unknown, run [`ultikits versions list`](#list-versions) first: a version listed there is published and cannot be replaced by retrying.

### The module's API level

As of v6.3.0, UltiCloud reads `api-version` from the root `plugin.yml` of the JAR you publish and stores it with the version. No flag and no `ultikits.json` field sets it; UltiCloud reads it only from the JAR. Declare it as an integer:

```yaml
api-version: 700
```

From 6.3.0 through the rest of 6.x, servers request levels from 630 up to their own API level; older frameworks request only levels below 630. As of v7.0.0, server requests use `minApiLevel=700`, and `/upm install` and `/upm update` accept only integer declarations from 700 up to the framework's level.

The scaffold writes the integer for the UltiTools-API version you select: `7.0.0` and `7.0.0-SNAPSHOT` both yield `700`, while `7.0.1` yields `701`. The framework refuses to load the module if the framework's API level is below the module's declared level. Changing only `api-version` does not make a 6.x module run on 7.0; rebuild it against UltiTools-API 7.0. See [Module Versioning](/guide/advanced/module-versioning#version-selection-by-api-level).

A JAR whose root `plugin.yml` does not declare an integer `api-version` is refused when it is uploaded: the version is not published and stays pending with the declared file. See [Upload refused for the API level](#upload-refused-for-the-api-level).

## Managing Modules

### List Your Modules

```bash
ultikits modules list
```

Output:

```
  myplugin — MyPlugin (1.0.0)
  anotherplugin — AnotherPlugin (无已发布版本 / no versions)
共 2 个模块 / 2 module(s)
```

### Module Details

```bash
ultikits modules info myplugin
```

Output:

```
  名称 / Name:          MyPlugin
  标识符 / Identifier:  myplugin
  简介 / Summary:       A brief description
  分类 / Category:      Utilities (#1)
  最新版本 / Latest:    1.0.0
  下载 / Downloads:     42
  更新 / Updated:       2026-11-07T12:00:00.000Z
```

### Delete a Module

```bash
ultikits modules delete myplugin
```

::: danger The module disappears at once
It is removed from the catalogue and downloads immediately. Within 30 days `ultikits modules restore myplugin` restores it (the web panel has no restore); after that it is purged.
:::

The CLI asks you to type the identifier again. With `-y`, or without a terminal, pass `--confirm myplugin`.

### Other Module Commands

These commands need a manage credential (`ultikits login`, or a developer key rotated to the manage scope):

```bash
ultikits modules create --id myplugin --name MyPlugin   # defaults come from ultikits.json
ultikits modules update myplugin --short-description "New text"
ultikits modules restore myplugin
```

## Managing Versions

### List Versions

```bash
ultikits versions list myplugin
```

This lists every published and withdrawn version from the public catalogue, with its size and publish time; pending uploads are not shown and no credential is sent.

To verify the uploaded bytes, read the version's metadata and compare its `sha256` and `sizeBytes` with your retained JAR:

```bash
curl --fail-with-body 'https://api.ultikits.com/v1/catalogue/modules/myplugin/versions/1.2.0'
```

### Withdraw a Version

```bash
ultikits versions withdraw myplugin 1.2.0
```

This withdraws a published version and needs a manage credential. It cannot be undone: the version and lower ones can never be published again; copies already downloaded are unaffected. With `-y`, or without a terminal, pass `--confirm myplugin@1.2.0`. `versions delete` is an old name for the same command.

## CI/CD with GitHub Actions {#ci-cd-with-github-actions}

Local publishing is recommended. If your project needs CI publishing, this optional recipe runs only when a maintainer starts it manually. It does not publish on a push, merge or GitHub release event. Create `.github/workflows/publish.yml`:

```yaml
name: Publish to UltiCloud

on:
  workflow_dispatch:
    inputs:
      version:
        description: Module version, for example 1.2.0
        required: true
        type: string

permissions:
  contents: read

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false

      - name: Extract release notes
        env:
          MODULE_VERSION: ${{ inputs.version }}
        shell: bash
        run: |
          set -euo pipefail
          python3 - <<'PY'
          import os
          import re
          from pathlib import Path

          version = os.environ["MODULE_VERSION"]
          if not re.fullmatch(r"(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)", version):
              raise SystemExit("Expected a release version such as 1.2.0")
          lines = Path("CHANGELOG.md").read_text(encoding="utf-8").splitlines()
          heading = re.compile(r"^##[ \t]+(?:\[v?([^\]]+)\]|v?([0-9]+\.[0-9]+\.[0-9]+))(?=[ \t]|$)")
          sections = []
          start = None
          fence = None
          for index, line in enumerate(lines):
              marker = re.match(r"^ {0,3}(`{3,}|~{3,})", line)
              if fence:
                  if re.fullmatch(r" {0,3}" + re.escape(fence[0]) + "{" + str(len(fence)) + r",}[ \t]*", line):
                      fence = None
                  continue
              if marker:
                  fence = marker.group(1)
                  continue
              if re.match(r"^##(?:[ \t]|$)", line):
                  if start is not None:
                      sections.append(lines[start:index])
                      start = None
                  match = heading.match(line)
                  if match and (match.group(1) or match.group(2)) == version:
                      start = index + 1
          if start is not None:
              sections.append(lines[start:])
          if len(sections) != 1:
              raise SystemExit("Expected exactly one CHANGELOG section for " + version)
          body = "\n".join(sections[0]).strip()
          if not body:
              raise SystemExit("The CHANGELOG section is empty")
          Path("release-notes.md").write_text(body + "\n", encoding="utf-8")
          PY

      - name: Set up JDK 25
        uses: actions/setup-java@v4
        with:
          java-version: '25'
          distribution: 'temurin'
          cache: maven

      - name: Set project version and verify
        env:
          MODULE_VERSION: ${{ inputs.version }}
        shell: bash
        run: |
          set -euo pipefail
          [[ "$MODULE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
          mvn -B versions:set "-DnewVersion=$MODULE_VERSION" -DgenerateBackupPoms=false
          mvn -B clean verify

      - name: Retain the built JAR
        uses: actions/upload-artifact@v4
        with:
          name: module-${{ inputs.version }}
          path: target/MyPlugin-${{ inputs.version }}.jar
          if-no-files-found: error
          retention-days: 7

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install a pinned UltiKits CLI
        run: npm install -g @ultikits/cli@3.0.0 --ignore-scripts

      - name: Publish to UltiCloud
        env:
          ULTIKITS_TOKEN: ${{ secrets.ULTIKITS_TOKEN }}
          MODULE_VERSION: ${{ inputs.version }}
        shell: bash
        run: |
          set -euo pipefail
          ultikits publish "target/MyPlugin-${MODULE_VERSION}.jar" --yes \
            --module-version "$MODULE_VERSION" \
            --changelog "$(cat release-notes.md)"
```

The extractor accepts a single `## [1.2.0]`, `## [v1.2.0]` or `## 1.2.0` heading, optionally followed by a date. It keeps subheadings and fenced code through the next level-two heading or end of file, and refuses an invalid version, missing or duplicate section, or empty body before building or publishing. Review the selected ref: its changelog must describe the bytes you intend to build.

### Setup Steps

1. Add the workflow file and change `MyPlugin` in both exact JAR paths to your build's final artifact name. Do not use a wildcard that could upload a sources or unshaded JAR.
2. Set the repository's `ULTIKITS_TOKEN` secret with a developer key (`ucd_…`); never put it in the workflow text or a dispatch input. An upload-scoped key cannot create a missing module, so create the module first.
3. Keep the CLI version pinned. Review a version change before updating the pin.

::: warning Publishing on push
Do not add a `push` or merge trigger: merging a version bump would then release it automatically. Interpolating workflow inputs directly into `run:` can also create shell injection; pass them through environment variables and quote their expansions as above.
:::

### Publishing a New Version

1. Review the source and the version's `CHANGELOG.md` section.
2. Open **Actions > Publish to UltiCloud > Run workflow** and select the intended branch or tag.
3. Enter only the module version. The workflow reads its complete section body from the checked-out `CHANGELOG.md`; no multiline form input is used.
4. Start the workflow deliberately, then check the uploaded version and file. This optional recipe builds once and publishes to UltiCloud; it does not create a GitHub release. Download the `module-<version>` artifact from the workflow run, extract its JAR, and attach that file to GitHub if needed, without rebuilding.

## Troubleshooting

### "Not logged in" Error

```
未登录：请运行 ultikits login，或设置环境变量 ULTIKITS_TOKEN。
```

Either run `ultikits login` to authenticate interactively, or set the `ULTIKITS_TOKEN` environment variable. A credential file written by CLI 1.x gives `凭据文件是旧版格式，对新接口无效，请重新 ultikits login。`; run `ultikits login` again.

### "No JAR file specified and none found in ./target/"

The CLI looks for a `.jar` file in `./target/` by default. Make sure you've built the project first:

```bash
mvn clean package -DskipTests
```

### Missing Required Fields

```
Missing required fields:
  - identifyString (use --id or ultikits.json)
```

Create an `ultikits.json` with `ultikits init`, or pass the missing fields as CLI flags.

### Invalid Credential on Publish

`[invalid_credential]` means the credential is wrong or expired, and `[role_required]` means the account is not a developer yet. Verify that the `ULTIKITS_TOKEN` secret is set correctly on your repository:

```bash
gh secret list --repo YourOrg/YourPlugin
```

The secret must be a developer key (`ucd_…`). `[key_scope_insufficient]` means the module does not exist and the key's upload scope cannot create it.

### Upload refused for the API level

`ultikits publish` reports one of two codes:

```
JAR 里的 plugin.yml 需要整数 api-version：补上后重新构建再发布。 [upload_api_level_missing]
上传的文件不是有效的 ZIP/JAR：检查构建产物路径。 [upload_jar_invalid]
```

`upload_api_level_missing` covers a missing root `plugin.yml` or `api-version`, an empty value, a value declared twice, and a Bukkit-style value such as `'1.19'` that is not an integer; the message does not say which. `upload_jar_invalid` means the file is not a readable ZIP/JAR, such as a truncated JAR. Declare the level as shown in [The module's API level](#the-module-s-api-level) and rebuild. The refused version stays pending with the old file's checksum, so delete that pending version in the developer centre and publish again, or publish a higher version number.
