Skip to content

Instantly share code, notes, and snippets.

View shibuiwilliam's full-sized avatar

shibuiwilliam shibuiwilliam

View GitHub Profile
@shibuiwilliam
shibuiwilliam / opencode.md
Created February 22, 2026 07:54
Dissecting OpenCode — 10 Design Elements Every Coding Agent Developer Should Know

Dissecting OpenCode — 10 Design Elements Every Coding Agent Developer Should Know

A deep dive into the architecture, agent loop, tool system, and more behind the 100k-star open-source AI coding agent

As AI coding agents rapidly evolve, open-source projects that let you study their internals are invaluable. OpenCode is an open-source AI coding agent with over 100,000 GitHub stars. It supports multiple client surfaces — terminal (TUI), web browser, desktop app, and IDE extensions — and works with 75+ LLM providers out of the box.

In this article, we take a deep dive into OpenCode's documentation and source code to identify 10 critical technical elements that engineers building their own coding agents should understand. Rather than a feature overview, we focus on the "why" behind each design decision and how you can apply these patterns to your own agent.

By the end of this article, you will understand:

import json
import operator
import uuid
from datetime import datetime
from pathlib import Path
from typing import Annotated, Any, Dict, List, Optional, TypedDict
from dotenv import load_dotenv
from langchain_core.messages import BaseMessage, HumanMessage, SystemMessage
from langchain_openai import AzureChatOpenAI
// SpawnManager.cs
// https://github.com/shibuiwilliam/ARWithWord/blob/main/ARWithWord/Assets/Scripts/SpawnManager.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
private fun initDistanceTable(){
for (i in 0 until Constants.maxNumMultiplePoints+1){
val tableRow = TableRow(this)
multipleDistanceTableLayout.addView(tableRow,
multipleDistanceTableLayout.width,
Constants.multipleDistanceTableHeight / (Constants.maxNumMultiplePoints + 1))
for (j in 0 until Constants.maxNumMultiplePoints+1){
val textView = TextView(this)
textView.setTextColor(Color.WHITE)
if (i==0){
private fun tapDistanceOfMultiplePoints(hitResult: HitResult){
if (placedAnchorNodes.size >= Constants.maxNumMultiplePoints){
clearAllAnchors()
}
ViewRenderable
.builder()
.setView(this, R.layout.point_text_layout)
.build()
.thenAccept{
it.isShadowReceiver = false
private fun tapDistanceOf2Points(hitResult: HitResult){
if (placedAnchorNodes.size == 0){
placeAnchor(hitResult, cubeRenderable!!)
}
else if (placedAnchorNodes.size == 1){
placeAnchor(hitResult, cubeRenderable!!)
val midPosition = floatArrayOf(
(placedAnchorNodes[0].worldPosition.x + placedAnchorNodes[1].worldPosition.x) / 2,
(placedAnchorNodes[0].worldPosition.y + placedAnchorNodes[1].worldPosition.y) / 2,
private fun measureDistanceFromCamera(){
val frame = arFragment!!.arSceneView.arFrame
if (placedAnchorNodes.size >= 1) {
val distanceMeter = calculateDistance(
placedAnchorNodes[0].worldPosition,
frame!!.camera.pose)
measureDistanceOf2Points(distanceMeter)
}
}
private fun placeAnchor(hitResult: HitResult,
renderable: Renderable){
val anchor = hitResult.createAnchor()
placedAnchors.add(anchor)
val anchorNode = AnchorNode(anchor).apply {
isSmoothed = true
setParent(arFragment!!.arSceneView.scene)
}
placedAnchorNodes.add(anchorNode)
@shibuiwilliam
shibuiwilliam / TensorflowOnSparkOnDocker
Last active October 21, 2021 09:01
TensorFlowOnSpark on Dockerfile
FROM ubuntu
MAINTAINER cvusk
# insert hostname on environmental variable
ENV HOSTNAME tensorflow.spark
# install prerequisites
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get -y install apt-utils
@shibuiwilliam
shibuiwilliam / keras_fizzbuzz
Created February 11, 2017 12:44
fizzbuzz in Keras
import numpy as np
from keras.models import Sequential
from keras.layers import Dense
from keras.utils import np_utils
from keras.layers import Dense
from keras.models import Model
# create training data
def binary_encode(i, num_digits):