Skip to content

Instantly share code, notes, and snippets.

View jprochazk's full-sized avatar
💭
📦

Jan Procházka jprochazk

💭
📦
View GitHub Profile
import { spawn, spawnSync } from "node:child_process";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
type RevdiffResult = { status: "complete"; content: string } | { status: "failed"; exitCode: number | null };
function splitArgs(input: string): string[] {
const args: string[] = [];
@jprochazk
jprochazk / tl.ts
Created September 2, 2026 16:54
Translate latest message using another model
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import type { Api, Model, UserMessage } from "@earendil-works/pi-ai";
import type {
ExtensionAPI,
ExtensionCommandContext,
} from "@earendil-works/pi-coding-agent";
import { getAgentDir, getMarkdownTheme } from "@earendil-works/pi-coding-agent";
import { Container, Markdown, Text } from "@earendil-works/pi-tui";
{
"verbose": true,
"showThinkingSummaries": true,
"env": {
"CLAUDE_CODE_EXTRA_BODY": "{\"thinking\":{\"type\":\"adaptive\",\"display\":\"summarized\"}}"
}
}
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Session Export</title>
<style>
:root {
--accent: #8abeb7;
- uses: actions/checkout@v5
# selecting a toolchain either by action or manual `rustup` calls should happen
# before the plugin, as the cache uses the current rustc version as its cache key
- run: rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
with:
# The prefix cache key, this can be changed to start a new cache manually.
# default: "v0-rust"
impl<'s> ::logos::Logos<'s> for TokenKind {
type Error = ();
type Extras = ();
type Source = str;
fn lex(lex: &mut ::logos::Lexer<'s, Self>) {
use ::logos::internal::{CallbackResult, LexerInternal, SkipCallbackResult};
type Lexer<'s> = ::logos::Lexer<'s, TokenKind>;
fn _end<'s>(lex: &mut Lexer<'s>) {
lex.end()
}
@jprochazk
jprochazk / gc.md
Created April 20, 2025 22:50
GC API

GC API

The following GC API has one main goal, which is to provide safe access to garbage-collected objects.

The definition of "safe access" here specifically means that the garbage collector would consider the object to be reachable if a garbage collection cycle were to take place while the reference to it is still live. As a consequence, it should also

@jprochazk
jprochazk / text.md
Last active November 11, 2024 15:07
gc woes

The goal of a GC is to automatically manage memory. When something isn't being used anymore, it should be freed. But that implies it should never free anything that is still in use, because that could lead to a use-after-free. You don't typically think about this when using a language with garbage collection, because it has managed references which the compiler and GC know about and so it all just works and you as the user don't have to worry that something will be freed from under your nose.

But it's different when you're the one implementing the language and its runtime. Remember how Crafting Interpreters does it, with pushing temporary values onto the runtime stack so that the GC can find them there. Which is very error-prone. That's where what I'm trying to do comes in. There are already a few Rust GC implementations that are memory safe, in that there's no possible way to introduce a use-after-free without unsafe code, because the garbage collector is made aware of every reference for as long as you'r

use std::marker::PhantomData;
use std::ops::{Deref, DerefMut, Index, IndexMut};
pub struct EnumArray<const LEN: usize, E: Into<usize>, V: Copy> {
array: [V; LEN],
index: PhantomData<fn() -> E>,
}
impl<const LEN: usize, E: Into<usize>, V: Copy> EnumArray<LEN, E, V> {
pub fn new(v: V) -> Self {
@jprochazk
jprochazk / data.json
Created February 7, 2024 19:14
parse-rosetta-rs benchmark data
{
"timestamp": "2024-02-07",
"hostname": "DESKTOP-HLQEUO4",
"os": "Linux",
"os_ver": "5.15.133.1-microsoft-standard-WSL2",
"arch": "x86_64",
"cpus": 32,
"libs": {
"examples/chumsky-app/Cargo.toml": {
"name": "chumsky",