Skip to content
Open
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
8 changes: 4 additions & 4 deletions .github/scripts/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ def main():
return run_parallel(shards, command)
if sys.argv[1:] == ['chrome']:
binary = prepare_chrome(os.environ['CHROME_BINARY'], os.environ['RUNNER_OS'], os.environ['RUNNER_TEMP'])
with open(os.environ['GITHUB_ENV'], 'a') as output:
with open(os.environ['GITHUB_ENV'], 'a', encoding='utf-8') as output:
output.write(f'FREEHAND_CHROME={binary}\n')
print(f'Test browser: {binary}')
return 0
if sys.argv[1:] == ['scope']:
event = json.loads(Path(os.environ['GITHUB_EVENT_PATH']).read_text())
event = json.loads(Path(os.environ['GITHUB_EVENT_PATH']).read_text(encoding='utf-8'))
full = full_checks(os.environ['GITHUB_EVENT_NAME'], os.environ['GITHUB_REF'], os.environ['GITHUB_WORKFLOW'],
event, changed_files)
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
with open(os.environ['GITHUB_OUTPUT'], 'a', encoding='utf-8') as output:
output.write(f'full={str(full).lower()}\n')
print('Full checks required' if full else 'Documentation-only: quick checks are sufficient')
return 0
Expand All @@ -143,7 +143,7 @@ def main():
summary = '\n'.join(rows) + '\n'
print(summary)
if os.environ.get('GITHUB_STEP_SUMMARY'):
with open(os.environ['GITHUB_STEP_SUMMARY'], 'a') as output:
with open(os.environ['GITHUB_STEP_SUMMARY'], 'a', encoding='utf-8') as output:
output.write(summary)
return int(bool(errors))
raise SystemExit('Usage: ci.py scope|result|chrome|parallel')
Expand Down
7 changes: 5 additions & 2 deletions .github/scripts/npm_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import datetime
import json
from pathlib import Path
import shutil
import subprocess
import sys

Expand Down Expand Up @@ -60,12 +61,14 @@ def problems(report, lock, today, level='moderate'):


def main(cwd='.'):
run = subprocess.run(['npm', 'audit', '--json'], cwd=cwd, capture_output=True, text=True)
npm = shutil.which('npm') or 'npm'
run = subprocess.run([npm, 'audit', '--json'], cwd=cwd, capture_output=True, text=True,
encoding='utf-8', errors='replace')
try:
report = json.loads(run.stdout)
except ValueError:
report = {'error': run.stderr.strip() or run.stdout.strip()}
lock = json.loads((Path(cwd) / 'package-lock.json').read_text())
lock = json.loads((Path(cwd) / 'package-lock.json').read_text(encoding='utf-8'))
found = problems(report, lock, datetime.date.today())
for line in found:
print('npm audit: ' + line, file=sys.stderr)
Expand Down
22 changes: 17 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.10", "3.14"]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
shard: [1, 2, 3]
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
Expand Down Expand Up @@ -152,12 +152,24 @@ jobs:
install-script:
needs: [scope, quality]
if: needs.scope.outputs.full == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
- run: FREEHAND_INSTALL_SPEC="$PWD" sh install.sh
- run: ~/.local/bin/freehand --version
- if: runner.os != 'Windows'
run: FREEHAND_INSTALL_SPEC="$PWD" sh install.sh
- if: runner.os != 'Windows'
run: ~/.local/bin/freehand --version
- if: runner.os == 'Windows'
shell: pwsh
run: |
$env:FREEHAND_INSTALL_SPEC = (Get-Location).Path
.\install.ps1
& "$HOME\.local\bin\freehand.exe" --version

desktop-dependencies:
needs: [scope, quality]
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/desktop-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-15, macos-15-intel, ubuntu-24.04]
os: [macos-15, macos-15-intel, ubuntu-24.04, windows-latest]
runs-on: ${{ matrix.os }}
env:
CSC_LINK: ${{ secrets.MAC_CSC_LINK }}
Expand All @@ -55,18 +55,20 @@ jobs:
- run: uv sync --locked
- run: npm ci
working-directory: desktop
- run: python3 ../.github/scripts/npm_audit.py
- run: uv run --no-sync python ../.github/scripts/npm_audit.py
working-directory: desktop
- run: npm run test:build-deps
working-directory: desktop
- run: npm run test:updates
working-directory: desktop
- name: Validate release channel
shell: bash
working-directory: desktop
run: |
node -e 'require("./scripts/release-updates").settings(require("./package.json").version,
process.env.RELEASE_CHANNEL, process.env.MAC_SIGNED === "true")'
- name: Require matching release versions
shell: bash
run: |
uv run python -c "import json; from freehand import __version__; \
assert __version__ == json.load(open('desktop/package.json'))['version'], \
Expand All @@ -88,6 +90,7 @@ jobs:
(umask 077; printf '%s' "$APPLE_API_KEY_CONTENT" > "$key")
echo "APPLE_API_KEY=$key" >> "$GITHUB_ENV"
- name: Build self-contained CLI and installers
shell: bash
working-directory: desktop
run: |
npm run bundle:cli
Expand Down Expand Up @@ -122,6 +125,7 @@ jobs:
desktop/dist/*.AppImage
desktop/dist/*.deb
desktop/dist/*.rpm
desktop/dist/*.exe
desktop/dist/*.yml
desktop/dist/*.blockmap
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,21 @@ them well: with weaker models, traditional harnesses still do better ([Results](

## Install

Supported platforms: **macOS and Linux**. The CLI and web interface also run in Linux under WSL2.
**Native Windows: coming soon.** Desktop builds target macOS (Apple Silicon and Intel) and Linux (x64);
see [desktop/README.md](desktop/README.md) for build details.
Supported platforms: **macOS, Linux, and Windows**. Desktop builds target macOS (Apple Silicon and Intel),
Linux (x64), and Windows (x64); see [desktop/README.md](desktop/README.md) for build details.

On macOS or Linux:

```bash
curl -LsSf https://raw.githubusercontent.com/microsoft/FreeHand/main/install.sh | sh
```

On Windows (PowerShell):

```powershell
irm https://raw.githubusercontent.com/microsoft/FreeHand/main/install.ps1 | iex
```

Or install from [PyPI](https://pypi.org/project/freehand-ai/) (Python 3.10+):

```bash
Expand Down
9 changes: 7 additions & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ Freehand 得分最高、成本最低,平均耗时也最短。

## 安装

支持平台:**macOS 和 Linux**。命令行和 Web 界面也可在 WSL2 的 Linux 环境中运行。
**原生 Windows:coming soon(即将支持)。** 桌面构建面向 macOS(Apple Silicon 和 Intel)及 Linux(x64),
支持平台:**macOS、Linux 和 Windows**。桌面构建面向 macOS(Apple Silicon 和 Intel)、Linux(x64)及 Windows(x64),
构建说明见 [desktop/README.md](desktop/README.md)。

在 macOS 或 Linux 上安装:
Expand All @@ -61,6 +60,12 @@ Freehand 得分最高、成本最低,平均耗时也最短。
curl -LsSf https://raw.githubusercontent.com/microsoft/FreeHand/main/install.sh | sh
```

在 Windows(PowerShell)上安装:

```powershell
irm https://raw.githubusercontent.com/microsoft/FreeHand/main/install.ps1 | iex
```

也可以直接从 [PyPI](https://pypi.org/project/freehand-ai/) 安装(需 Python 3.10+):

```bash
Expand Down
10 changes: 5 additions & 5 deletions desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ These actions use the shared local server API, so they also work in `freehand we

## Supported platforms

Desktop builds target **macOS (Apple Silicon and Intel)** and **Linux x64**. The release workflow builds on native
macOS runners and Ubuntu 24.04; Linux packaging produces AppImage, deb and x86_64 RPM files.
Desktop builds target **macOS (Apple Silicon and Intel)**, **Linux x64**, and **Windows x64**. The release workflow
builds on native macOS runners, Ubuntu 24.04, and Windows; Linux packaging produces AppImage, deb and x86_64 RPM
files, and Windows packaging produces an NSIS installer (`.exe`).
RPM packages are intended for Fedora users; the build matrix does not test every Linux distribution.
Linux ARM64 desktop builds are not covered by the release matrix. **Native Windows: coming soon.**
The CLI and web interface support macOS and Linux, including Linux under WSL2; WSL2 desktop GUI builds are not a
release target. The published 0.1.1 macOS previews are ad-hoc signed, not Developer ID signed/notarized;
Linux ARM64 and Windows ARM64 desktop builds are not covered by the release matrix.
The CLI and web interface support macOS, Linux (including WSL2), and native Windows. The published 0.1.1 macOS previews are ad-hoc signed, not Developer ID signed/notarized;
install them manually. See the update and release requirements below.

## Install the RPM on Fedora
Expand Down
Binary file added desktop/build/icon.ico
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions desktop/build/icons.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"sha256": {
"src/freehand/web/favicon.svg": "d1dc05d0a29946bf085045cfd2bbff9a8d1a21503de9ae9b83263462e5611077",
"src/freehand/web/favicon.svg": "0b0c313413caec86c745bebdea3e692e4c74b9daae627f60c499f141825bd2f6",
"desktop/build/icon.png": "a816643aa537e270922de28685060d959a71d5aa43bb7f72e4e242ed746fc648",
"desktop/build/icon-mac.png": "2fbb1d8b3ef1f93c21486af0e635e9ad31182d646907098e5a5a80390f05928e"
"desktop/build/icon-mac.png": "2fbb1d8b3ef1f93c21486af0e635e9ad31182d646907098e5a5a80390f05928e",
"desktop/build/icon.ico": "1fbb9d32ebfe51b6fbc6a4ffa4845156b781b14a7933693ea432ccc33b50fc1a"
},
"size": 1024,
"mac_tile": 824
Expand Down
39 changes: 26 additions & 13 deletions desktop/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ const fs = require("node:fs");
const os = require("node:os");
const path = require("node:path");

const ICON = path.join(__dirname, "build", "icon.png");
const ICON = path.join(__dirname, "build", process.platform === "win32" ? "icon.ico" : "icon.png");
// macOS draws an icon as it is given, so the Dock's has the margin every Mac icon has; the full one would look large
const DOCK_ICON = path.join(__dirname, "build", "icon-mac.png");
const DEVELOPMENT = !app.isPackaged || Boolean(require("./package.json").freehandDevelopment);
const SMOKE = process.env.FREEHAND_DESKTOP_SMOKE === "1"; // load the page, report, quit: for checking a build
const recovery = require("./recovery");
const { createNotices } = require("./notice");
const INSTALL = "curl -LsSf https://raw.githubusercontent.com/microsoft/FreeHand/main/install.sh | sh";
const INSTALL = process.platform === "win32"
? "irm https://raw.githubusercontent.com/microsoft/FreeHand/main/install.ps1 | iex"
: "curl -LsSf https://raw.githubusercontent.com/microsoft/FreeHand/main/install.sh | sh";
if (process.platform === "win32" && typeof app.setAppUserModelId === "function") {
app.setAppUserModelId("com.microsoft.freehand");
}
let win = null;
let unseenTurns = 0;
let serviceBin = null, restarting = null, serviceStale = false;
Expand All @@ -28,25 +33,30 @@ let allowedOrigin = null; // updated whenever keepSe
// An app started from the Finder or a launcher does not get the shell's PATH, so the usual install locations are
// looked at too. FREEHAND_BIN names the command outright.
function findFreehand() {
const isWin = process.platform === "win32";
const exe = isWin ? "freehand.exe" : "freehand";
if (process.env.FREEHAND_BIN) return process.env.FREEHAND_BIN;
if (!app.isPackaged) {
const local = path.join(__dirname, "..", ".venv", process.platform === "win32" ? "Scripts" : "bin",
process.platform === "win32" ? "freehand.exe" : "freehand");
const local = path.join(__dirname, "..", ".venv", isWin ? "Scripts" : "bin", exe);
try { fs.accessSync(local, fs.constants.X_OK); return local; } catch { /* use the installed CLI */ }
}
const bundled = path.join(process.resourcesPath || __dirname, "freehand", "freehand");
const bundled = path.join(process.resourcesPath || __dirname, "freehand", exe);
try { fs.accessSync(bundled, fs.constants.X_OK); return bundled; } catch { /* development checkout */ }
const chosen = readState().cli;
if (chosen) { try { fs.accessSync(chosen, fs.constants.X_OK); return chosen; } catch { /* moved */ } }
const dirs = [...(process.env.PATH || "").split(path.delimiter), path.join(os.homedir(), ".local", "bin"),
"/opt/homebrew/bin", "/usr/local/bin"];
...(isWin ? [] : ["/opt/homebrew/bin", "/usr/local/bin"])];
const names = isWin ? ["freehand.exe", "freehand.cmd", "freehand"] : ["freehand"];
for (const dir of dirs) {
const candidate = path.join(dir, "freehand");
try {
fs.accessSync(candidate, fs.constants.X_OK);
return candidate;
} catch {
// not here
if (!dir) continue;
for (const name of names) {
const candidate = path.join(dir, name);
try {
fs.accessSync(candidate, fs.constants.X_OK);
return candidate;
} catch {
// not here
}
}
}
return null;
Expand Down Expand Up @@ -91,7 +101,10 @@ const rememberFolder = (folder) => { if (folder === null || isFolder(folder)) re
function startServer(bin) {
return new Promise((resolve, reject) => {
let out = "", err = "";
const run = spawn(bin, ["web", "--background"], { cwd: lastFolder(), stdio: ["ignore", "pipe", "pipe"] });
const run = spawn(bin, ["web", "--background"], {
cwd: lastFolder(), stdio: ["ignore", "pipe", "pipe"], windowsHide: true,
...(process.platform === "win32" && /\.(cmd|bat)$/i.test(bin) ? { shell: true } : {}),
});
Comment on lines +104 to +107
const timer = setTimeout(() => { run.kill();
reject(new Error("Local service startup timed out (45 seconds).")); }, 45000);
run.on("error", (error) => { clearTimeout(timer); reject(error); });
Expand Down
21 changes: 19 additions & 2 deletions desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"main": "main.js",
"scripts": {
"start": "electron .",
"smoke": "FREEHAND_DESKTOP_SMOKE=1 electron .",
"smoke": "node -e \"const {spawnSync}=require('node:child_process');process.exit(spawnSync(require('electron'),['.'],{stdio:'inherit',env:{...process.env,FREEHAND_DESKTOP_SMOKE:'1'}}).status??1)\"",
"app": "npm run bundle:cli && node scripts/dev-app.js",
"dist": "npm run bundle:cli && electron-builder",
"bundle:cli": "sh scripts/bundle-cli.sh",
"bundle:cli": "node scripts/bundle-cli.js",
"test:build-deps": "node ../tests/desktop_build_dependencies.js",
"test:updates": "node ../tests/desktop_updates.js && node ../tests/desktop_release_updates.js"
},
Expand All @@ -28,6 +28,7 @@
"preload.js",
"package.json",
"build/icon.png",
"build/icon.ico",
"recovery.js",
"notice.js",
"notice.html",
Expand Down Expand Up @@ -57,6 +58,22 @@
"rpm"
]
},
"win": {
"icon": "build/icon.ico",
"target": [
{
"target": "nsis",
"arch": [
"x64"
]
}
]
},
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true,
"artifactName": "Freehand-Setup-${version}.${ext}"
},
"extraResources": [
{
"from": "runtime/freehand",
Expand Down
25 changes: 25 additions & 0 deletions desktop/scripts/bundle-cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Build the self-contained CLI on each target OS/architecture without copying user settings or credentials.
const { execFileSync } = require("node:child_process");
const fs = require("node:fs");
const os = require("node:os");
const path = require("node:path");

const root = path.resolve(__dirname, "..", "..");
const uv = process.platform === "win32" ? "uv.exe" : "uv";
const args = [
"run", "--with", "pyinstaller", "pyinstaller", "--noconfirm", "--clean", "--onedir", "--name", "freehand",
"--distpath", "desktop/runtime", "--workpath", "desktop/.pyinstaller", "--specpath", "desktop/.pyinstaller",
"--collect-all", "freehand", "--collect-all", "anthropic", "--collect-all", "prompt_toolkit", "--collect-all", "rich",
"--hidden-import", "freehand.terminal_child", "--hidden-import", "freehand.winpty",
"--hidden-import", "freehand.__main__", "desktop/bundle_entry.py",
];
execFileSync(uv, args, { cwd: root, stdio: "inherit" });

const tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), "freehand-bundle-"));
try {
const binary = path.join(root, "desktop", "runtime", "freehand",
process.platform === "win32" ? "freehand.exe" : "freehand");
execFileSync(binary, ["--version"], { cwd: root, env: { ...process.env, FREEHAND_HOME: tmpHome }, stdio: "inherit" });
} finally {
fs.rmSync(tmpHome, { recursive: true, force: true });
}
Loading