Skip to content

Commit 31dd694

Browse files
committed
docs(tutorials): add AI agent, website preview and Python tutorials
1 parent bf999c5 commit 31dd694

5 files changed

Lines changed: 350 additions & 0 deletions

File tree

‎.vitepress/config.mts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,18 @@ export default defineConfig({
476476
text: "How to run java",
477477
link: "/tutorials/how-to-run-java",
478478
},
479+
{
480+
text: "Use the AI Agent",
481+
link: "/tutorials/ai-agent",
482+
},
483+
{
484+
text: "Build and preview a website",
485+
link: "/tutorials/preview-website",
486+
},
487+
{
488+
text: "Python autocomplete",
489+
link: "/tutorials/python-language-server",
490+
},
479491
],
480492
},
481493
},

‎tutorials/ai-agent.md‎

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
description: Set up the official Acode AI Agent plugin, connect a model provider, and let an AI agent read, edit and run your project.
3+
---
4+
5+
# Use the Acode AI Agent
6+
7+
[Acode AI Agent](https://acode.app/plugin/acode.ai.agent) is the official coding agent for Acode, made by the Acode Foundation. It opens as an editor tab, reads and edits files in your project, searches the web, and runs commands on terminal folders. You bring your own model provider, such as OpenRouter, OpenAI, Anthropic, Gemini, GitHub Copilot or a local server. There is no Acode backend in between.
8+
9+
This tutorial installs it, connects a provider, and walks through a first task safely.
10+
11+
## What You Need
12+
13+
- Acode version code `1002` or newer.
14+
- A project folder open in Acode (local, terminal, SAF, FTP or SFTP).
15+
- An API key or subscription for a model provider. If you aren't sure, an [OpenRouter](https://openrouter.ai) key gives access to many models with one key.
16+
17+
## Step 1: Install the Plugin
18+
19+
1. Open the sidebar and tap the **Plugins** icon, or go to **Settings** > **Plugins**.
20+
2. Search for **Acode AI Agent** (by Acode Foundation) and install it.
21+
22+
A new **AI Agent** icon appears in the sidebar.
23+
24+
## Step 2: Open a Project
25+
26+
The agent only works inside an open folder. Open your project in the sidebar's file tree first.
27+
28+
For the best results, use a folder in the [built-in terminal](/user-guide/terminal) (**Terminal Public**, `~` in the terminal). There the agent can also run commands like `npm test` or `python3 main.py`. In SAF, FTP and SFTP folders it can still read, edit, move and delete files, but it can't run commands.
29+
30+
::: tip Just trying it out?
31+
In the **AI Agent** sidebar, **Spin up new session** creates a starter project in your home folder and opens a chat in it.
32+
:::
33+
34+
## Step 3: Open the Agent and Connect a Provider
35+
36+
1. Tap the **AI Agent** icon in the sidebar and start a session with **+**, or run **AI Agent: Open** from the [Command Palette](/user-guide/command-palette).
37+
2. In the agent tab, tap **⋯** in the top-right corner and add a provider under **Provider access**:
38+
- **API key**: paste a key for OpenRouter, OpenAI, Anthropic, Gemini, xAI, Groq, DeepSeek and others.
39+
- **Subscription sign-in**: OpenRouter, ChatGPT Plus / Pro, Codex, GitHub Copilot, xAI and Kimi Code sign in through the browser or a device code.
40+
- **Local endpoint**: any OpenAI-compatible server, such as Ollama, LM Studio, llama.cpp or vLLM, at a URL like `http://192.168.1.10:8080/v1`.
41+
42+
Keys are kept in Acode's secure plugin storage, not in settings or chat history.
43+
44+
## Step 4: Choose a Mode and Model
45+
46+
The chip in the composer, for example `Ask · Med · <model>`, sets three things for the chat:
47+
48+
| Setting | What to pick |
49+
| :------ | :----------- |
50+
| **Permission mode** | Start with **Ask**: you approve every edit, delete and command. **Allow edits** lets it write files freely but still asks before deleting or running commands. **Full access** never asks. |
51+
| **Thinking level** | **Med** is a good default. Higher levels think longer and cost more. |
52+
| **Model** | Any model from your provider. You can also paste a model id that isn't in the list. |
53+
54+
::: warning
55+
In **Full access** mode the agent can delete files and, in terminal folders, run any command without asking. Use it only in projects you can restore.
56+
:::
57+
58+
## Step 5: Give It a First Task
59+
60+
An empty chat offers starter prompts such as **Map the project** and **Review the open file**. Try one, or write your own:
61+
62+
```text
63+
Map this project and explain how the main pieces fit together. Don't edit anything.
64+
```
65+
66+
Then ask for a small change:
67+
68+
```text
69+
In @index.html, disable the Save button while the form is submitting.
70+
```
71+
72+
Tips for good results:
73+
74+
- **Mention files with `@`** so the agent doesn't have to search for them.
75+
- **Say how you'll know it's done** ("the button is disabled while saving").
76+
- **For bigger changes, ask for a plan first** ("plan this, don't edit yet"), then tell it to go ahead.
77+
- **Keep one task per chat.** Tap **+** when you switch topics.
78+
79+
## Step 6: Review and Undo Changes
80+
81+
- In **Ask** mode, each edit shows the removed (`−`) and added (`+`) lines before you approve it.
82+
- Edits to files that are open in Acode stay **unsaved**, so you can read them and use the editor's undo before saving.
83+
- After a turn, a card lists the changed files. **Undo** puts them back the way they were before that turn and deletes files it created. Moves, deletes and commands are not undone.
84+
85+
While a run is going, the work log shows each step. **Stop** ends the run, and sending a message steers it. If Android stops the app mid-run, the chat offers **Resume** from the last saved step.
86+
87+
## Step 7: Teach It About Your Project
88+
89+
Add an `AGENTS.md` file (or `CLAUDE.md`) to the root of your project with anything the agent should always know:
90+
91+
```md
92+
# Project notes
93+
94+
- This is a plain HTML/CSS/JS site. No build step.
95+
- Run `npx serve .` to preview it.
96+
- Use tabs for indentation.
97+
```
98+
99+
The agent reads it at the start of every chat. For repeatable jobs, add skills in `.agents/skills/<name>/SKILL.md`, or prompt templates in `.agents/prompts/` that become `/` commands.
100+
101+
## Useful Commands
102+
103+
Type `/` in the composer to see them all.
104+
105+
| Command | What it does |
106+
| :------ | :----------- |
107+
| `/model` | Change the model for this chat. |
108+
| `/new` | Start a new chat. |
109+
| `/compact` | Summarize older messages when the context ring fills up. |
110+
| `/session` | Show this chat's token usage and cost. |
111+
| `/tree` | Go back to an earlier point and branch from there. |
112+
| `/resume` | List previous chats. |
113+
114+
The **AI Agent** sidebar lists chats per project, with search, so you can pick up where you left off.
115+
116+
## Troubleshooting
117+
118+
::: details "Open a folder first"
119+
Open a project folder in the sidebar's file tree, then start a new chat.
120+
:::
121+
122+
::: details The agent can't run commands
123+
Commands only run in terminal folders. Move the project under **Terminal Public**, or let the agent edit files and run commands yourself in the [terminal](/user-guide/terminal).
124+
:::
125+
126+
::: details Empty or failed replies
127+
Try another model or a lower thinking level, and check that your provider key has credit.
128+
:::
129+
130+
::: tip For plugin developers
131+
Other plugins can add tools, providers and context to the agent through `acode.require("acode.ai.agent.runtime")`. See the plugin's [README](https://github.com/Acode-Foundation/acode-ai-agent) for the extension API.
132+
:::

‎tutorials/index.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ Welcome to the **Acode** tutorial and documentation section! This section is des
77
In this section, you'll find a variety of small tutorials, how-to guides, and documentation related to Acode and plugin development. Whether you're new to Acode or looking to extend its functionality with your own plugins, this is the place to learn and get started!
88
But for Plugin related APIs, check out this section 👉 [Plugin Api Guide](../docs/index)
99

10+
## Tutorials
11+
12+
- [Use the Acode AI Agent](./ai-agent): set up the official AI coding agent and let it edit and run your project.
13+
- [Build and preview a website](./preview-website): write HTML, CSS and JavaScript and preview it with the built-in server.
14+
- [Command Palette](./command-palette): find and run any command quickly.
15+
- [How to run Java](./how-to-run-java): compile and run Java code.
16+
- [Python autocomplete and error checking](./python-language-server): set up a language server for Python with the built-in terminal.
17+
1018
:::tip
1119
Stay tuned as we regularly update this section with new tutorials, guides, and tips!
1220
:::

‎tutorials/preview-website.md‎

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
description: Build a small HTML, CSS and JavaScript site in Acode and preview it on your phone with the built-in server, console and live reload.
3+
---
4+
5+
# Build and Preview a Website
6+
7+
Acode has a built-in web server and preview, so you can write a site and see it on your phone without any other app. This tutorial creates a small HTML, CSS and JavaScript page and previews it.
8+
9+
## Step 1: Create a Project Folder
10+
11+
1. Open the menu (⋮) and tap **Files**, or open the sidebar's file tree.
12+
2. Pick a location, such as **Terminal Public** or a folder in your storage, and create a folder named `my-site`.
13+
3. Open the folder so it shows in the sidebar.
14+
15+
## Step 2: Add the Files
16+
17+
Create three files in `my-site`.
18+
19+
`index.html`:
20+
21+
```html
22+
<!doctype html>
23+
<html lang="en">
24+
<head>
25+
<meta charset="utf-8" />
26+
<meta name="viewport" content="width=device-width, initial-scale=1" />
27+
<title>My Site</title>
28+
<link rel="stylesheet" href="style.css" />
29+
</head>
30+
<body>
31+
<h1>Hello from Acode</h1>
32+
<button id="count">Clicked 0 times</button>
33+
<script src="script.js"></script>
34+
</body>
35+
</html>
36+
```
37+
38+
`style.css`:
39+
40+
```css
41+
body {
42+
font-family: system-ui, sans-serif;
43+
display: grid;
44+
place-items: center;
45+
min-height: 100vh;
46+
margin: 0;
47+
background: #12141a;
48+
color: #f1f2f4;
49+
}
50+
51+
button {
52+
padding: 12px 20px;
53+
border: 0;
54+
border-radius: 10px;
55+
font-size: 1rem;
56+
}
57+
```
58+
59+
`script.js`:
60+
61+
```js
62+
const button = document.getElementById("count");
63+
let clicks = 0;
64+
65+
button.addEventListener("click", () => {
66+
clicks += 1;
67+
button.textContent = `Clicked ${clicks} times`;
68+
console.log("clicks:", clicks);
69+
});
70+
```
71+
72+
## Step 3: Run the Preview
73+
74+
With any file of the project open, tap the **Run** (▶) button in the header or press **`F5`**.
75+
76+
Acode starts a local server for the folder and opens `index.html`. It serves the whole folder, so links, images, CSS and scripts load like on a real web server, including clean URLs such as `/about` for `about.html`.
77+
78+
You can also run a single HTML, Markdown, SVG or JavaScript file. Turn on **Use Current File** in [Preview Settings](/user-guide/settings/preview-settings) to preview the open file instead of `index.html`.
79+
80+
## Step 4: Debug with the Console
81+
82+
Turn on **Show Console Toggler** in **Settings** > **Preview Settings**. The preview then has a button that opens a JavaScript console where `console.log` output and errors appear. Tap the button in the page and you'll see `clicks: 1`.
83+
84+
For a fuller console with DOM and network tabs, set **Console** to **Eruda** in [App Settings](/user-guide/settings/app-settings).
85+
86+
## Step 5: In-App or Browser
87+
88+
**Preview Mode** in Preview Settings chooses where the page opens:
89+
90+
- **In-App** opens it inside Acode, next to your code.
91+
- **Browser** opens it in your phone's browser, which is useful for testing how the page behaves there.
92+
93+
## Using a Dev Server Instead
94+
95+
For projects with a build tool such as Vite, run its dev server in the [terminal](/user-guide/terminal), for example `npm run dev`. Then in **Preview Settings**, set **Preview Port** to the dev server's port (such as `5173`). When **Preview Port** differs from **Server Port**, Acode doesn't start its own server and opens your dev server instead.
96+
97+
## Next Steps
98+
99+
- Get autocomplete and error checking for HTML, CSS and JavaScript from the built-in [language servers](/user-guide/language-servers). They work out of the box.
100+
- Ask the [Acode AI Agent](./ai-agent) to build features for you.
101+
- Publish the site from the terminal with `git`, or upload it over [FTP/SFTP](/user-guide/remote-access).
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
description: Set up Python autocomplete, error checking and go to definition in Acode with the built-in terminal and a language server.
3+
---
4+
5+
# Python Autocomplete and Error Checking
6+
7+
This tutorial sets up a Python project in Acode with full code intelligence: suggestions as you type, errors underlined in the editor, hover docs and go to definition. It uses Acode's built-in terminal and the **Python (ty)** [language server](/user-guide/language-servers). You don't need any other app.
8+
9+
It takes about five minutes, most of it waiting for downloads.
10+
11+
## What You Need
12+
13+
- Acode with the [built-in terminal](/user-guide/terminal) available.
14+
- An internet connection for the first setup.
15+
16+
## Step 1: Install the Terminal
17+
18+
1. Open the menu (⋮) in the top-right corner and tap **Terminal**.
19+
2. If the terminal isn't installed yet, Acode installs it. Wait until you see a shell prompt.
20+
21+
## Step 2: Create a Project in the Terminal's Folder
22+
23+
Language servers run inside the terminal, so keep the project in a folder the terminal can see. Your terminal home folder (`~`) is the easiest; it shows up as **Terminal Public** in Acode's file browser.
24+
25+
In the terminal, run:
26+
27+
```bash
28+
mkdir -p ~/hello-python
29+
cd ~/hello-python
30+
acode .
31+
```
32+
33+
`acode .` opens the folder in Acode's sidebar.
34+
35+
::: warning
36+
Folders added with the Android file picker (SAF), other external storage and FTP/SFTP folders are skipped by language servers by default, so autocomplete won't work there. See [Folders outside the terminal](/user-guide/language-servers#folders-outside-the-terminal).
37+
:::
38+
39+
## Step 3: Create a Python File
40+
41+
In the sidebar, create a new file named `main.py` in `hello-python` and add:
42+
43+
```python
44+
def greet(name: str) -> str:
45+
return f"Hello, {name}!"
46+
47+
print(greet("Acode"))
48+
```
49+
50+
## Step 4: Install the Language Server
51+
52+
**Python (ty)** is enabled by default, so opening a `.py` file is enough to start it. The first time, it isn't installed yet:
53+
54+
1. A notification appears: **"Python (ty) language server is not installed. Tap to install."** If you miss it, open the sidebar and tap the bell icon.
55+
2. Tap the notification. Acode runs the install in the terminal: it adds Python and pip with `apk`, then installs `ty` with pip.
56+
3. Wait for the **Installing Python (ty)…** notification to finish.
57+
58+
You can also install it from **Settings** > **Language Servers** > **Python (ty)** > **Install / repair**. The same page shows **Installed** once it's ready.
59+
60+
## Step 5: Try It Out
61+
62+
Back in `main.py`:
63+
64+
- Type `greet(` on a new line: signature help shows the `name: str` parameter.
65+
- Type `"text".` and suggestions for string methods appear.
66+
- Change `return f"Hello, {name}!"` to `return 42`. The line is underlined, and the error is listed in **Problems** (`Ctrl` + `Shift` + `M`).
67+
- Select `greet` in the last line and pick **LSP Actions** > **Go to Definition** from the selection menu.
68+
69+
To check what is running for the file, open the pencil menu in the header and tap **LSP Info**.
70+
71+
## Step 6: Run the Script
72+
73+
In the terminal:
74+
75+
```bash
76+
cd ~/hello-python
77+
python3 main.py
78+
```
79+
80+
You should see `Hello, Acode!`.
81+
82+
## Troubleshooting
83+
84+
::: details No suggestions or errors appear
85+
- Check that the folder is under **Terminal Public** (`~` in the terminal), not a SAF or remote folder.
86+
- Open **Settings** > **Language Servers** > **Python (ty)** and check that **Enabled** is on and the status says **Installed**.
87+
- Open **LSP Info** from the pencil menu to see whether the server started and read its log.
88+
:::
89+
90+
::: details The install fails
91+
- Make sure you're online, then run `apk update` in the terminal.
92+
- Try again with **Install / repair** on the server's settings page.
93+
:::
94+
95+
::: details I prefer pylsp
96+
Turn off **Python (ty)** and turn on **Python (pylsp)** in **Settings** > **Language Servers**. Only keep one Python server enabled at a time.
97+
:::

0 commit comments

Comments
 (0)