VS Code + OpenCode + Muse Spark 1.3 Contribut...
  1. A few things outside what you named that are still worth knowing (not extra tools to install as products):
  2.  
  3. - You will need **system packages** for GTK4 and the C toolchain (libgtk-4-dev, CMake, Ninja). The agent can install them, but you should approve those commands.
  4. - Put the project in its **own empty folder** and git init it. /undo helps; git is the real safety net.
  5. - **Contributor** means Meta may train on prompts and code you send. Fine for this exercise; do not point it at private work later without switching model IDs.
  6. - OpenCode **Plan** vs **Build** (Tab) is the habit that matters more than the toolkit.
  7. - Drop the calculator screenshot into the session so the agent can match layout.
  8.  
  9. ---
  10.  
  11. # VS Code + OpenCode + Muse Spark 1.3 Contributor
  12.  
  13. ## GTK4 calculator in C (Ubuntu 26.04 / MATE)
  14.  
  15. Goal: learn the **tools**, not GTK. Treat GTK as “the library the agent uses.”
  16.  
  17. ---
  18.  
  19. ## 0. One-time Ubuntu packages
  20.  
  21. In a normal terminal (not required to be VS Code yet):
  22.  
  23. Bash
  24.  
  25. ```
  26. sudo apt update
  27. sudo apt install -y build-essential cmake ninja-build pkg-config git \
  28. libgtk-4-dev
  29. ```
  30.  
  31. Check:
  32.  
  33. Bash
  34.  
  35. ```
  36. gcc --version
  37. cmake --version
  38. pkg-config --modversion gtk4
  39. code --version
  40. ```
  41.  
  42. If code is missing: in VS Code, Command Palette → **Shell Command: Install 'code' command in PATH**.
  43.  
  44. Optional but useful: Node.js 18+ only if you install OpenCode via npm instead of the curl script.
  45.  
  46. ---
  47.  
  48. ## 1. Create a Meta Model API key
  49.  
  50. 1. Open [ai.developer.meta.com](ai.developer.meta.com (or the Model API dashboard linked from Meta’s Muse Spark docs).
  51. 2. Sign in with a Meta account.
  52. 3. Create an **API key**. Keys often look like LLM|…|….
  53. 4. Copy it once. Store it in a password manager. **Do not** put it in the project repo.
  54.  
  55. New accounts sometimes have a small credit; Contributor is cheap (muse-spark-1.3-contributor: about $0.10 / $0.20 per million tokens) and Meta may use prompts/completions for training. Rate limit is lower than the paid standard tier (~100 RPM). Plenty for this project.
  56.  
  57. ---
  58.  
  59. ## 2. Install OpenCode CLI
  60.  
  61. Bash
  62.  
  63. ```
  64. curl -fsSL opencode.ai | bash
  65. ```
  66.  
  67. Close and reopen the terminal (or source ~/.bashrc) so opencode is on PATH.
  68.  
  69. Bash
  70.  
  71. ```
  72. opencode --version
  73. ```
  74.  
  75. Alternative: npm install -g opencode-ai.
  76.  
  77.  
  78. ---
  79.  
  80. ## 3. Open VS Code the official way
  81.  
  82. Bash
  83.  
  84. ```
  85. mkdir -p ~/src/gtk-calc-lab
  86. cd ~/src/gtk-calc-lab
  87. git init
  88. code .
  89. ```
  90.  
  91. In VS Code’s **integrated terminal** (Ctrl+`):
  92.  
  93. Bash
  94.  
  95. ```
  96. opencode
  97. ```
  98.  
  99. First run should offer to install the official VS Code integration. Accept it.
  100.  
  101. Useful keys (Linux):
  102.  
  103. | Action | Shortcut |
  104. | ----------------------------------------- | -------------- |
  105. | Open / focus OpenCode in a split terminal | Ctrl+Esc |
  106. | New OpenCode session | Ctrl+Shift+Esc |
  107. | Insert file reference | Alt+Ctrl+K |
  108.  
  109. You stay in the terminal agent. That is intentional.
  110.  
  111. ---
  112.  
  113. ## 4. Connect Meta and pick Contributor
  114.  
  115. Inside the OpenCode TUI:
  116.  
  117. text
  118.  
  119. ```
  120. /connect
  121. ```
  122.  
  123. - If **Meta** appears in the list, select it and paste the API key.
  124. - If not, pick **Other**, provider id meta, paste the key, then add config (next).
  125.  
  126. Create or edit **global** config (not in the git repo):
  127.  
  128. ~/.config/opencode/opencode.json
  129.  
  130. JSON
  131.  
  132. ```
  133. {
  134. "$schema": "opencode.ai
  135. "provider": {
  136. "meta": {
  137. "name": "Meta Model API",
  138. "npm": "@ai-sdk/openai",
  139. "options": {
  140. "baseURL": "api.meta.ai
  141. },
  142. "models": {
  143. "muse-spark-1.3-contributor": {
  144. "name": "Muse Spark 1.3 Contributor",
  145. "reasoning": true,
  146. "limit": {
  147. "context": 1048576,
  148. "output": 131072
  149. },
  150. "modalities": {
  151. "input": ["text", "image", "pdf", "video"],
  152. "output": ["text"]
  153. },
  154. "options": {
  155. "reasoningEffort": "medium",
  156. "reasoningSummary": "auto",
  157. "include": ["reasoning.encrypted_content"]
  158. }
  159. }
  160. }
  161. }
  162. }
  163. }
  164. ```
  165.  
  166. Notes:
  167.  
  168. - Use @ai-sdk/openai and api.meta.ai so Muse Spark uses the **Responses** API (what Meta documents for OpenCode).
  169. - Restart OpenCode after saving.
  170. - /models and select muse-spark-1.3-contributor.
  171. - Status line should show something like **Muse Spark 1.3 Contributor · Meta**.
  172.  
  173. For learning, keep reasoning at **medium**. Raise to high only if the agent flails.
  174.  
  175. ### Permissions (ask before writes and shell)
  176.  
  177. In the same opencode.json (or project opencode.json later), prefer the safer default: **do not** turn on auto-approve. When a tool call appears (write file, apt, cmake, run binary), read the diff/command and approve or reject.
  178.  
  179. If the UI has an “Open” / auto-approve switch, leave it off for this project.
  180.  
  181. ---
  182.  
  183. ## 5. Hello-world test (prove the loop)
  184.  
  185. Still in ~/src/gtk-calc-lab, in OpenCode:
  186.  
  187. text
  188.  
  189. ```
  190. /init
  191. ```
  192.  
  193. That writes AGENTS.md (project hints for the agent). Fine to keep.
  194.  
  195. Then paste:
  196.  
  197. text
  198.  
  199. ```
  200. Do not create a GUI yet.
  201.  
  202. Create a tiny CMake + Ninja C project in this folder:
  203. - src/hello.c that prints "hello from opencode" and exits 0
  204. - CMakeLists.txt that builds an executable named hello
  205. - A one-line README with the exact build commands
  206.  
  207. Use out-of-source build in build/.
  208. After writing files, show me the commands. Wait for my approval before running cmake or the binary.
  209. ```
  210.  
  211. You should:
  212.  
  213. 1. See a plan or file diffs.
  214. 2. Approve writes.
  215. 3. Approve:
  216.  
  217. Bash
  218.  
  219. ```
  220. cmake -S . -B build -G Ninja
  221. cmake --build build
  222. ./build/hello
  223. ```
  224.  
  225. 4. See hello from opencode.
  226.  
  227. If that works, VS Code + OpenCode + Meta + CMake are wired.
  228.  
  229. If it fails:
  230.  
  231. - Model not selected → /models
  232. - 401 → /connect again, check key
  233. - Empty reply / truncated reasoning → output limit or wrong adapter; confirm npm is @ai-sdk/openai and model id is exactly muse-spark-1.3-contributor
  234. - Extension missing → run opencode from the **VS Code** terminal, not an external one
  235.  
  236. Optional VS Code check: Command Palette → **CMake: Configure** on the same folder. Not required if you build from the terminal.
  237.  
  238. ---
  239.  
  240. ## 6. Other options (know they exist; skip for now)
  241.  
  242. | Option | When to consider |
  243. | ------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
  244. | OpenCode Zen | Bundled models; there has been a free Contributor-style Muse SKU through Zen. Extra account. |
  245. | Standard muse-spark-1.3 | Same model, no training-on-your-data, ~12–21× more expensive |
  246. | Ollama local model | Offline; weaker agent than Spark 1.3 |
  247. | Third-party VS Code sidebars (OpenCode Panel, Varro, OpenCode GUI) | Chat panel instead of split terminal. Add later if you want diffs in a sidebar. |
  248. | Cline / Continue-style extensions | Different agent. Ignore for this exercise. |
  249. | Qt6 | Fine later; more packages, not needed to learn OpenCode |
  250. | Meson | Native for some GNOME apps; you asked for CMake |
  251.  
  252. Stay on official CLI + Contributor + ask-before-apply.
  253.  
  254. ---
  255.  
  256. ## 7. Calculator project — how to prompt
  257.  
  258. Keep using the **same folder** or start clean:
  259.  
  260. Bash
  261.  
  262. ```
  263. cd ~/src/gtk-calc-lab
  264. # optional: git checkout a new branch
  265. git checkout -b calculator
  266. ```
  267.  
  268. Attach the screenshot (drag into the OpenCode terminal). Muse Spark accepts images.
  269.  
  270. ### Step A — Plan only
  271.  
  272. Press **Tab** until you are in **Plan** mode.
  273.  
  274. text
  275.  
  276. ```
  277. I am an experienced embedded C developer learning VS Code + OpenCode.
  278. I do not want a GTK tutorial. You own the GTK4 details.
  279.  
  280. Build a simple Linux desktop calculator in C + GTK4 + CMake + Ninja
  281. that looks like the attached screenshot.
  282.  
  283. Requirements:
  284. - Single window titled "Calculator"
  285. - Menu bar: Calculator, Mode, View, Help (Calculator can be File-style: Quit is enough; other menus can be stubs or simple About)
  286. - Large read-only expression/result entry at the top
  287. - Button grid matching the screenshot as closely as practical:
  288. 7 8 9 ÷ Undo Clear (Clear is red)
  289. 4 5 6 × ( )
  290. 1 2 3 − x² √
  291. 0 . % + = (Equals is wide and blue, spans remaining cells)
  292. - Keyboard support for digits and + - * / Enter Backspace Escape
  293. - Correct operator precedence, parentheses, percent, square, square root
  294. - No crash on divide-by-zero; show an error in the display
  295. - No network, no extra frameworks
  296. - C11, GTK4 only
  297. - CMake + Ninja, target name calculator
  298. - Keep C files small and readable (main UI vs evaluation)
  299. - README with Ubuntu package list and build/run commands
  300.  
  301. First produce a short plan: files you will create, how you will evaluate expressions,
  302. and how you will match the layout. Do not write code until I say so.
  303. ```
  304.  
  305. Read the plan. Push back in plain language (“put eval in its own .c”, “Clear must not be the same color as Undo”).
  306.  
  307. ### Step B — Build
  308.  
  309. Tab back to **Build** mode:
  310.  
  311. text
  312.  
  313. ```
  314. The plan is approved. Implement it in this folder.
  315. Replace the hello-world files if they conflict.
  316. Show diffs. Do not run cmake until I approve.
  317. ```
  318.  
  319. Approve file writes. Then approve build:
  320.  
  321. Bash
  322.  
  323. ```
  324. cmake -S . -B build -G Ninja
  325. cmake --build build
  326. ./build/calculator
  327. ```
  328.  
  329. On MATE this should be a normal X11/Wayland window.
  330.  
  331. ---
  332.  
  333. ## 8. How to ask for changes
  334.  
  335. Be specific. Name the widget or behavior. One change per prompt until you trust it.
  336.  
  337. Examples:
  338.  
  339. text
  340.  
  341. ```
  342. Clear must be solid red and Equals solid blue, similar to the screenshot.
  343. Use GTK CSS on those two buttons only. Do not restyle the whole app.
  344. ```
  345.  
  346. text
  347.  
  348. ```
  349. Undo should remove the last character from the expression, not clear everything.
  350. Clear still wipes the display.
  351. ```
  352.  
  353. text
  354.  
  355. ```
  356. The window is too wide. Match a compact calculator: smaller padding,
  357. square-ish number keys, Equals still wider than the others.
  358. ```
  359.  
  360. text
  361.  
  362. ```
  363. % should mean “percent of the current value” as in a four-function
  364. calculator, not modulo.
  365. ```
  366.  
  367. text
  368.  
  369. ```
  370. Add a Mode menu item "Degrees" vs "Radians" but do not add sin/cos yet.
  371. Just store the flag and print it in a comment or status if easy.
  372. ```
  373.  
  374. text
  375.  
  376. ```
  377. Explain @src/eval.c in five bullet points. Do not change code.
  378. ```
  379.  
  380. Useful OpenCode commands:
  381.  
  382. - /undo — revert last agent turn
  383. - /redo
  384. - @path/to/file — pin a file in the prompt
  385. - Tab — Plan vs Build
  386.  
  387. After each accepted change:
  388.  
  389. Bash
  390.  
  391. ```
  392. git add -A && git commit -m "calculator: describe the change"
  393. ```
  394.  
  395. ---
  396.  
  397. ## 9. Suggested workflow while you learn
  398.  
  399. 1. **You** decide the outcome in one sentence.
  400. 2. **Plan mode** for anything more than a one-file tweak.
  401. 3. **You** approve diffs and shell.
  402. 4. **You** run the binary and click through.
  403. 5. **You** write the next prompt from what you saw, not from theory.
  404. 6. Commit.
  405.  
  406. If the agent starts teaching GTK, steer it:
  407.  
  408. text
  409.  
  410. ```
  411. Stop explaining GTK. Change the code. I will review the diff.
  412. ```
  413.  
  414. If it installs random libraries:
  415.  
  416. text
  417.  
  418. ```
  419. GTK4 and CMake only. Do not add extra dependencies.
  420. ```
  421.  
  422. ---
  423.  
  424. ## 10. What “done” looks like
  425.  
  426. - OpenCode in VS Code terminal, model = Muse Spark 1.3 Contributor
  427. - Hello program built with CMake/Ninja
  428. - ./build/calculator looks in the same family as your screenshot
  429. - You have used Plan, Build, approve-write, approve-shell, and a follow-up UI prompt
  430.  
  431. When you have walked through it, say what you want tightened and I will turn this into a short markdown file.
  432.  
Pasted 2026-09-17 13:58:39

Short link: