Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ on:
branches: [main]
jobs:
build:
runs-on: ubuntu-24.04
strategy:
matrix:
os: [ubuntu-24.04, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- uses: oven-sh/setup-bun@v2
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.llm/reference
node_modules
.build
/mutagen.yml
/mutagen.yml.lock
7 changes: 6 additions & 1 deletion src/core/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from "fs";
import os from "os";
import path from "path";
import { z } from "zod";

Expand All @@ -7,7 +8,11 @@ const LOCAL_FILE = path.join(LOCAL_DIR, "dotllm.json");
const REF_DIR = path.join(LOCAL_DIR, "reference");

function home(): string {
return path.join(process.env.HOME ?? "", ".local", "share", "dotllm");
if (process.platform === "win32") {
const appData = process.env.LOCALAPPDATA ?? path.join(os.homedir(), "AppData", "Local");
return path.join(appData, "dotllm");
}
return path.join(process.env.HOME ?? os.homedir(), ".local", "share", "dotllm");
}

const RepoEntry = z.object({
Expand Down
10 changes: 8 additions & 2 deletions test/core/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ import { Config, type RepoEntry } from "@spader/dotllm/core/config"
const foo: RepoEntry = { kind: "file", name: "foo", uri: "/mock/foo", description: "foo lib" }
const bar: RepoEntry = { kind: "url", name: "bar", uri: "https://example.com/bar", description: "" }

function globalDir(root: string): string {
return process.platform === "win32"
? path.join(root, "dotllm")
: path.join(root, ".local", "share", "dotllm")
}

function seedGlobal(root: string, content: string): void {
const dir = path.join(root, ".local", "share", "dotllm")
const dir = globalDir(root)
fs.mkdirSync(dir, { recursive: true })
fs.writeFileSync(path.join(dir, "dotllm.json"), content)
}
Expand Down Expand Up @@ -130,7 +136,7 @@ test("local read returns default on schema-invalid JSON", async () => {

test("storeDir returns path under HOME", async () => {
await using env = await fixture()
expect(Config.storeDir()).toBe(path.join(env.path, ".local", "share", "dotllm", "store"))
expect(Config.storeDir()).toBe(path.join(globalDir(env.path), "store"))
})

test("refDir returns .llm/reference", () => {
Expand Down
11 changes: 9 additions & 2 deletions test/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ type Env = {

export async function fixture(state: State = {}): Promise<Env> {
const root = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), "dotllm-")))
const prev = process.env.HOME
const prevHome = process.env.HOME
const prevAppData = process.env.LOCALAPPDATA
const cwd = process.cwd()
process.env.HOME = root
if (process.platform === "win32") {
process.env.LOCALAPPDATA = root
}
process.chdir(root)

const git = { stdout: "pipe" as const, stderr: "pipe" as const }
Expand Down Expand Up @@ -81,7 +85,10 @@ export async function fixture(state: State = {}): Promise<Env> {
path: root,
dir(name: string) { return path.join(root, name) },
async [Symbol.asyncDispose]() {
process.env.HOME = prev
process.env.HOME = prevHome
if (process.platform === "win32") {
process.env.LOCALAPPDATA = prevAppData
}
process.chdir(cwd)
fs.rmSync(root, { recursive: true, force: true })
},
Expand Down
11 changes: 5 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
"esModuleInterop": true,
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"baseUrl": ".",
"paths": {
"@spader/dotllm/cli": ["src/cli/index.ts"],
"@spader/dotllm/cli/*": ["src/cli/*"],
"@spader/dotllm/core": ["src/core/index.ts"],
"@spader/dotllm/core/*": ["src/core/*"],
"#tools/*": ["tools/*"]
"@spader/dotllm/cli": ["./src/cli/index.ts"],
"@spader/dotllm/cli/*": ["./src/cli/*"],
"@spader/dotllm/core": ["./src/core/index.ts"],
"@spader/dotllm/core/*": ["./src/core/*"],
"#tools/*": ["./tools/*"]
}
},
"include": ["src/**/*.ts", "test/**/*.ts"]
Expand Down