Install an AI coding agent lab: npm, a config file and a model
This lab is the coding agent lab with nothing installed. Each student installs opencode, an open-source AI coding agent, from npm, reads an example config file and copies it into place, and then uses the agent on the same small tuck shop program.
The copy has no way out to the internet except two: the npm registry, through a proxy that lets nothing else through, and the platform’s model. The agent works for the same people as in the first lab, on the same allowance.
What students learn
That a program is installed as a package and pinned to a release, that a config file tells a program where its services are, and that a key never goes in a file they hand in. It suits a first lesson on installing and configuring tools.
Run it in your browser
The lab starts one service, agent, with the project in /home/node/project and an example config at /home/node/opencode.example.json.
- Open the Container page. Open Build on the bar and choose Run a container. Anybody may open it, and the Git lab and the SQL lab start with no account. Every other lab needs a free account: create one, sign in, then press Start.
- Find the lab. The Sample labs card lists every sample. Find the install-it-yourself coding agent.
- Press Start. Start runs it as it is, in one press. Edit the file first opens the compose file so you can change it before you start.
- Open it. On the lab’s page, press Open terminal. docker exec agent npm install -g [email protected] installs the agent, docker exec agent opencode --version prints its release, and the lesson copies the example config into place.
What to ask students to hand in
Their opencode.json, the tests before and after the fix, and a sentence on what each line of the config does.
A basic lesson on this lab
AI Coding Agent Basics 2 is a small lesson worked in this lab, after AI Coding Agent Basics. In it a student installs the agent, reads and copies its config, asks it one question and then fixes the bug with it.
Free personal accounts have it in the Basics module, which is on Home, every college can copy it from the Library’s Basics folder, and a new college opens with it in a module called DevOps Labs (Sample). Copy it into a module of your own to change it.
The code on GitHub
The compose file has no Dockerfile: it runs the official node image, pinned to a version, as an unprivileged user. opencode is MIT licensed and is installed by the student, not distributed by us. The project and the config are kept in a named volume; the agent is not, so it is installed again after a restart.
Set it as work
Say in the task what to hand in.
- Make the lab. In your module add a task and choose the Container lab card, then In a GitHub repository. Give https://github.com/mitsurutech/lab-ai-agent-install with the branch main. The compose file is the default, compose.yaml. Fork the repository first if you want to change it.
- Publish and try it. Publish pins the commit you were shown, so a later change in the repository does not alter a lab you have already set. Start your own copy first.
- Hand it out. Assign it like any task, with a due date if you want one, and say in the task what to do and what to hand in.
- Mark what is handed in. Open a student’s copy and the work they handed in, mark it, and send it back with a reason if it needs more.
Questions people ask
- Where does npm get the agent from, if the lab has no way out?
- From the npm registry, through a proxy beside the copy that lets the registry through and refuses every other address.
- Why is the key in the config just the word lab?
- The lab adds the real one on the way out, so it is never in a file a student can see or hand in. Anything typed there is replaced.
- Why must the agent be installed again after a restart?
- It is about 140 MB, more than a copy may keep. The project and the config are kept, so the install is the only step to do again.