Skip to content

Instantly share code, notes, and snippets.

@mizchi
mizchi / rag.ts
Last active June 23, 2025 12:30
My Portable RAG
/**
* My Portable RAG
* $ pnpm add sqlite-vec @ai-sdk/google ai
* SQLite Vector Search + Google AI Embeddings
*
* Required environment variables:
* GOOGLE_GENERATIVE_AI_API_KEY=your-api-key
*
* Usage:
* # Index text content

MoonBit Knowledge Base for LLMs (Claude Code)

This document contains essential MoonBit knowledge that LLMs cannot know without external environment access. Last updated: December 2024.

Language Version and Status

Current Status: Beta (as of December 2024)

  • Version 1.0 planned for 2026
  • Core language features are now stable
  • Breaking changes will follow RFC process
import React, { useState } from "react";
import { render } from "ink-testing-library";
import { Text, Box, useInput, useApp } from "ink";
import { describe, it, expect, beforeAll } from "vitest";
// テスト環境設定
beforeAll(() => {
process.stdin.isTTY = true;
process.stdout.isTTY = true;
});
// node --test ask-claude.test.ts
import { test } from "node:test";
import { query, type Options } from "@anthropic-ai/claude-code";
async function assertAI(prompt: string, options: Options = {}): Promise<void> {
const MARKER = "**ASSERT_OK**";
const abortController = new AbortController();
const finalPrompt = `Assert user query. Return ${MARKER} if it is true. \n\n${prompt}`;
for await (const message of query({
prompt: finalPrompt,
// node --test ask-claude.test.ts
import { test } from "node:test";
import { query } from "@anthropic-ai/claude-code";
test("Ask", async () => {
const EXPECTED = "paris";
const abortController = new AbortController();
for await (const message of query({
prompt: "What is the capital of France?",
options: { maxTurns: 1, abortController },
// pnpm add vitepress -D
// add this on docs/.vitepress/config.ts
// "doc:dev": "pnpm vitepress dev docs --port=9999",
// "doc:build": "pnpm vitepress build"
import { defineConfig } from "vitepress";
// Hyrum's Law: With a sufficient number of users of an API,
// it does not matter what you promise in the contract:
// all observable behaviors of your system will be depended on by somebody.
-- リアルワールド例:カウンターボタンの実装と証明
-- カウンターの状態
structure Counter where
value : Nat
-- カウンターの初期状態
def Counter.init : Counter := ⟨0
-- インクリメント操作

Claude Orchestrator: A System for Efficiently Decomposing and Executing Complex Tasks

tl;dr

  • Created a Claude Code version of Roo Orchestrator
  • Unlike Roo which doesn't support parallel tasks, Claude Code's Task can execute in parallel

Introduction

I've been a regular user of Roo Orchestrator and wanted a Claude version of it.

Orchestrator

Split complex tasks into sequential steps, where each step can contain multiple parallel subtasks.

Process

  1. Initial Analysis
    • First, analyze the entire task to understand scope and requirements
    • Identify dependencies and execution order
  • Plan sequential steps based on dependencies
# ast-grep 使用例チートシート
# ==========================================
# 基本的なパターンマッチング
# ==========================================
# 1. 関数呼び出しの検索
# CLI: ast-grep -p 'console.log($MSG)' src/
id: find-console-log
language: JavaScript