# Make an AIC plugin

This guide is for an AI to read and follow as written. It tells you how to make an AIC (aicommunicator) plugin for the person, install it on this computer and show the person that it works. It also tells you how to publish it to this site, but only when the person asks.

A plugin adds one screen to AIC. The person sees and edits that screen in the browser, and you read and change the same content with the MCP tools of `aic`. AIC runs only on the person's computer. If you do not know what AIC is, read https://aic.aiakiv.net/about.md first.

To follow this guide, you must be able to run terminal commands and edit files. If you are in a chat that cannot run commands, point the person to "Do it yourself" at https://aic.aiakiv.net/create and stop.

## Rules

1. Check the result of each step before you go to the next one.
2. Make only what the person asked for. Do not add features they did not ask for.
3. Do not publish the plugin to the site until the person tells you to. Using it on this computer does not need the site.
4. Stop and tell the person when admin rights, a password or a login is needed. Never type a password, a login code or a key for the person.
5. Do not delete or change anything that this guide does not mention. Work inside the plugin folder you create.
6. Write every text inside the plugin in English, because this site is run in English. Talk with the person in the person's language.

## Step 0: AIC

1. Run `aic --help`. If the command is missing, install AIC first by following https://aic.aiakiv.net/install.md, then come back to this guide.
2. If Windows PowerShell blocks running scripts, call `aic.cmd` instead of `aic`.
3. Messages from `aic` and from its checks may be in Korean. Read them and explain them to the person in the person's language.

## Step 1: Decide what to make

1. Read what the person wants. If it is unclear, ask only short questions: what the screen shows, and what the person and you should be able to change on it.
2. Check whether a similar plugin already exists. Search the site with `aic plugin search <search text>`, and see the plugins that come with AIC with `aic plugin list`.
3. If an existing plugin already does what the person wants, tell the person and ask whether to use it instead.

## Step 2: Read the plugin guide

1. Run `aic plugin guide` and read all of it before you write any code. If it comes out in Korean, your aic is an older version. You can update it with `npm i -g aicommunicator@latest`, or read the Korean text as it is.
2. That guide is the source for every detailed rule: the contract between the logic and AIC, the manifest fields, how the logic and the screen are split, and the limits of the isolated runner and of the screen frame. This page only gives the order of the work. If this page and that guide differ, follow that guide.

## Step 3: Make the starter folder

1. Pick the id. It has the form `<account name>.<plugin name>`. Each part uses lowercase English letters, digits and `-`, and is 2 to 40 characters long. Example: `jane.reading-list`.
2. The first part is the person's account name on this site. Use it even if the person does not plan to publish now, because the site only takes ids that start with the account name of the person who publishes. The account name is chosen the first time the person signs in to the site with GitHub. The site suggests the GitHub login name in lowercase, and the name cannot be changed later. If you do not know the name, ask the person. Never start an id with `aic.`, because only the site operator can publish those.
3. Run `aic plugin new <id> [folder] --title "<name people see>"`. If you leave out the folder, it is `./plugin-<plugin name>`. The folder must not exist yet, or must be empty. If you leave out `--title`, the name is the plugin name part of the id.
4. The starter is a "list" plugin that already works. It has `manifest.json`, `logic.js`, `ui/index.html`, `docs/manual.md`, `LICENSE` and `README.md`. Change it into what the person asked for.

## Step 4: Build it

Follow `aic plugin guide`. The points below are only a reminder.

1. Write all text inside the plugin in English, even when the person asked in another language: `title`, `about` and `examples` in `manifest.json`, the manual, the names and descriptions of samples, `aiGuide` and the operation descriptions in `describe()`, the text on the screen, and `README.md`. If the starter from an older aic has text in Korean, replace all of it with English. Keep talking with the person in the person's language. English is the base text. The screen alone may also show another language when `capabilities().language` asks for it; `aic plugin guide` section 4.4 tells how.
2. The logic file runs in an isolated runner. It cannot use files, the network, the time (`Date`), random numbers (`Math.random`), timers or `import`. A new context is made for every call, so keep all state in records, and give the same result for the same input.
3. The screen is `ui/index.html`. It runs in a frame that cannot connect outside. Put all scripts and styles inside that one file, and put pictures and fonts in as `data:` addresses. The screen talks to AIC only with messages.
4. Write `title`, `about` and `examples` in `manifest.json` in plain words that a person would use. Write `aiGuide` and the operations in `describe()` so that another AI can use the screen without reading the code.
5. Write the manual in `docs/manual.md`. It tells the person and the AI what each part of the screen does.
6. The icon is one SVG file right under `ui/` (for example `ui/icon.svg`), named by `icon` in `manifest.json`. It cannot contain scripts, styles, animation or outside addresses. The icon is optional. Your aic version may not have this yet; update with `npm i -g aicommunicator@latest`. If `aic plugin guide` still does not mention the icon after that, leave the icon out.

## Step 5: Install it on this computer and try it

1. Check the folder with `aic plugin pack <folder>`. It runs the same checks as the site and writes a `<id>-<version>.tgz` file in the current folder. Fix every error. A line that says to fix something before publishing does not block using the plugin here.
2. Install it with `aic plugin install <folder> --yes --restart`. This checks the folder again, installs the plugin into the AIC data folder and restarts AIC if it is running. You do not need to log in. Installing the same version again replaces it.
3. If AIC is not running, start it with `aic start --background`.
4. Run `aic status`. The plugin must be in the plugin list. If it is not there, run `aic stop`, then run `aic start` without `--background` and read the line that says the plugin was skipped. That line gives the reason, such as a manifest check, `protocol` or dependencies. `aic start` keeps running until it is stopped, so stop it after you read the line (`aic stop` from another shell), fix the problem, install again and start AIC with `aic start --background`.
5. Open the screen with `aic open`.
6. Try it yourself. If you have the `aic` MCP tools in this chat, create a work with `create_document` and `plugin: "<id>"`, change it with `apply_operation`, and read it back with `read_concept`. Check that you can do the work from `aiGuide` and the operation examples alone. If the tools stop answering after the restart, reconnect the MCP server `aic` in the chat, or ask the person to do it.
7. Ask the person to try the screen in the browser: add, change and remove things, and check that the screen updates.
8. After you change the code, run `aic plugin install <folder> --yes --restart` again.

Up to this step, the plugin exists only on this computer, and nothing was sent to the site. This is all the person needs to use it.

## Step 6: Show the person

1. Tell the person what you made, the plugin id, the version and the folder it is in.
2. Tell the person how to open it: run `aic open`, then ask you in the chat to create a new work with the plugin.
3. Tell the person what they can do on the screen and what they can ask you to do.
4. If the person wants to give it to someone without publishing, the `.tgz` file from `aic plugin pack` can be installed on another computer with `aic plugin install <file>.tgz`.
5. Tell the person the rules for later changes:
   - Raise `version` in `manifest.json` and `VERSION` at the top of `logic.js` together each time you release a change. While you are still working, installing the same version again is fine. AIC only notes that the code changed.
   - Never go back to a lower version. AIC does not install a lower version over a higher one, and works saved with a higher version cannot be changed with a lower one.
   - Do not change `dataVersion` unless the person agrees. Works made before the change no longer open.

## Step 7: Publish it (only when the person asks)

Do this step only when the person tells you to publish. Anyone can download a published plugin.

1. Check before you publish:
   - The id starts with the person's account name on this site. The site refuses ids that start with another account name.
   - The `version` is higher than every version already published. A published version can never be changed or deleted.
   - `manifest.json` has `title`, `license`, `about` and `protocol`, and the folder has a `LICENSE` file.
   - No other plugin on the site uses the same `title`. The site compares titles without case, spaces, `-` and `_`, so "Mind Map", "mindmap" and "Mind-Map" are the same title. Search with `aic plugin search <title>` to check.
   - All text in the plugin is in English: `title`, `about` and `examples` in `manifest.json`, the manual, sample names and descriptions, `aiGuide`, the screen text and `README.md`. The site does not check this, but it is the rule of this site.
   - `aic plugin pack <folder>` finishes without a line that says to fix something before publishing.
   - Nothing in the folder holds personal data, keys or passwords. If there are samples, read them, because a sample holds the text of a real work as it was.
   - The bundle file is at most 5 MB, the unpacked files add up to at most 5 MB, and there are at most 200 files.
2. Log in. The person does this. Ask the person to run `aic login` in their terminal. It shows a short code and the address https://aic.aiakiv.net/device. The person opens it, signs in with GitHub, chooses an account name the first time, and enters the code. Do not enter the code, a password or anything else for the person. The key is saved on this computer, so this is needed only once.
3. Publish with `aic plugin publish <folder>`. It runs the same checks as `aic plugin pack` and uploads the bundle. Each account can publish 30 times per hour.
4. Open https://aic.aiakiv.net/plugins/<id> to check the plugin page, and give the person that address. Other people install it with `aic plugin install <id>`.
5. To fix a published version, do not try to replace it. Raise the version and publish again. The person can mark a wrong version as "do not use" on the "My account" page of the site.

## If something goes wrong

1. Show the error text to the person as it is.
2. Do not repeat the same command more than three times.
3. If a check fails, read the reason, fix the files and run the command again. Check messages may be in Korean.
4. If the site refuses to publish, the error says why. Common reasons are an id that does not start with the account name, a version that already exists, and a bundle that is too large.
5. If the error is `title_taken`, another plugin already uses that title, and the error names that plugin. Ask the person for a different title, change `title` in `manifest.json` and publish again. You do not need to raise the version, because nothing was published.
