Skip to content

100x is a skill by a former Cursor engineer that turns prompts into formally verified, production-ready code

Run 100x natively on Windows: junctions and launchers for links, taskkill for stop, Git sh for judge commands

Glitch1a832759110b
diff --git a/docs/install.md b/docs/install.md
index 5555543..387e7f4 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -33,6 +33,16 @@ npm install -g github:DeadInternetStudios/100x-engineer-skill
The first line puts the tool on your PATH, with the skills inside the package. The second does what the installer above does, from there. `npm update -g` replaces the package, so run `100x install` again after it.
+### On Windows
+
+The same ways work in PowerShell, cmd and Git Bash. Three things differ.
+
+- **A POSIX shell.** The commands you set for a judge or a prototype, such as `review.command`, are written for `sh` with `$VARIABLES`. 100x runs them with the `sh.exe` that Git for Windows installs. It looks on PATH and in the usual Git folders, and `X100_SH` names another one. Claude Code needs Git for Windows too, so you probably have it already.
+- **Links.** Windows lets only an administrator, or a machine in Developer Mode, make a symlink. The installer tries one and, when Windows refuses, makes a junction for each skill folder, which the agent apps read the same way. The `100x` program is two small launchers that run `node` on this checkout, `100x.cmd` for cmd and PowerShell and `100x` for Git Bash. The installer says which kind it made. `100x doctor` counts all three as installed, and `--uninstall` removes them. `X100_NO_SYMLINK=1` asks for the junction and launcher path even where symlinks work.
+- **Folders.** The launchers go to `%USERPROFILE%\.local\bin`, which is not on PATH until you add it in Windows Settings (search for "environment variables"). `npm install -g` puts `100x` on PATH by itself. Playwright keeps its browsers in `%LOCALAPPDATA%\ms-playwright`.
+
+A `git pull` in this repo updates the install, because the junctions and launchers point at this checkout.
+
### With skills.sh
[skills.sh](https://skills.sh) is a directory of skills and a command line tool, `skills`, that copies them into the apps you use. There is nothing to submit: a repo is listed once people install it with that tool.
diff --git a/lib/build-stamp.mjs b/lib/build-stamp.mjs
index 8387286..c9eaa6e 100644
--- a/lib/build-stamp.mjs
+++ b/lib/build-stamp.mjs
@@ -1,7 +1,7 @@
import crypto from 'node:crypto';
import fs from 'node:fs';
import path from 'node:path';
-import { REPO_ROOT } from './paths.mjs';
+import { posix, REPO_ROOT } from './paths.mjs';
const files = (dir) => fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
const full = path.join(dir, entry.name);
@@ -13,6 +13,6 @@ const files = (dir) => fs.readdirSync(dir, { withFileTypes: true }).flatMap((ent
// is serving an old page. A stamp from the files, not the git head, because an unmerged edit changes the page too.
export function buildStamp(root = REPO_ROOT) {
const hash = crypto.createHash('sha1');
- for (const file of [...files(path.join(root, 'lib')), path.join(root, 'package.json')]) hash.update(path.relative(root, file)).update(fs.readFileSync(file));
+ for (const file of [...files(path.join(root, 'lib')), path.join(root, 'package.json')]) hash.update(posix(path.relative(root, file))).update(fs.readFileSync(file));
return hash.digest('hex').slice(0, 10);
}
diff --git a/lib/clock.mjs b/lib/clock.mjs
index 55da775..7256251 100644
--- a/lib/clock.mjs
+++ b/lib/clock.mjs
@@ -1,6 +1,7 @@
import fs from 'node:fs';
import path from 'node:path';
import { CliError } from './errors.mjs';
+import { posix } from './paths.mjs';
import { stateFile } from './project.mjs';
import { writeJson } from './write-json.mjs';
@@ -84,7 +85,7 @@ function readRecord(root) {
return record;
}
-const damaged = (root, why) => `The clock file ${path.relative(root, clockFile(root)) || 'clock.json'} cannot be read (${why}). It holds the deadline. Set the clock again with \`100x clock set <time>\`, add --fill for a fill clock, or delete it on purpose with \`100x clock clear\`.`;
+const damaged = (root, why) => `The clock file ${posix(path.relative(root, clockFile(root))) || 'clock.json'} cannot be read (${why}). It holds the deadline. Set the clock again with \`100x clock set <time>\`, add --fill for a fill clock, or delete it on purpose with \`100x clock clear\`.`;
// When the clock was set and how long it was set for, or null when there is none.
export function clockSpan(root) {
diff --git a/lib/commands/browsers.mjs b/lib/commands/browsers.mjs
index 05d5fa7..c8afd2f 100644
--- a/lib/commands/browsers.mjs
+++ b/lib/commands/browsers.mjs
@@ -1,9 +1,9 @@
-import { spawnSync } from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import { parseArgs } from 'node:util';
import { CliError } from '../errors.mjs';
import { globalDir } from '../paths.mjs';
+import { runProgram } from '../proc.mjs';
import { chromiumBuilds, resolvePlaywright } from '../playwright.mjs';
const usage = `
@@ -17,7 +17,7 @@ The installers' progress lines are kept and shown only when one of them fails.
// The installers print a progress line for every 10 percent, which buries the answer for an agent. Keep the output, show it on failure.
export function install(label, command, args) {
- const result = spawnSync(command, args, { encoding: 'utf8' });
+ const result = runProgram(command, args, { encoding: 'utf8' });
if (result.status === 0) return;
const output = `${result.stdout ?? ''}${result.stderr ?? ''}`.trim().split('\n').slice(-15).join('\n');
throw new CliError(`${label} failed${result.status === null ? ` (${result.error?.message ?? 'did not start'})` : ` with exit code ${result.status}`}.\n${output}`);
@@ -43,7 +43,7 @@ export default {
console.log(`Installing Playwright into ${globalDir()}. This takes a minute or two, and the output is kept unless it fails.`);
install('Installing Playwright', 'npm', ['install', '--prefix', globalDir(), '--no-audit', '--no-fund', 'playwright']);
console.log('Installing Chromium. The download is large.');
- install('Installing Chromium', path.join(globalDir(), 'node_modules', '.bin', 'playwright'), ['install', 'chromium']);
+ install('Installing Chromium', path.join(globalDir(), 'node_modules', '.bin', process.platform === 'win32' ? 'playwright.cmd' : 'playwright'), ['install', 'chromium']);
console.log('installed Playwright and Chromium into', globalDir());
return undefined;
},
diff --git a/lib/commands/eval.mjs b/lib/commands/eval.mjs
index 6759a2c..653ccc2 100644
--- a/lib/commands/eval.mjs
+++ b/lib/commands/eval.mjs
@@ -9,6 +9,7 @@ import { buildPictures } from '../eval/pictures.mjs';
import { bakeoffScreen } from '../eval/screen.mjs';
import { bakeoffReport, scoreBakeoff } from '../eval/tally.mjs';
import { planText, reachOf } from '../eval/plan.mjs';
+import { posix } from '../paths.mjs';
import { INSTALL_HINT } from '../playwright.mjs';
import { duration, plural, shellPath, wrap } from '../eval/words.mjs';
@@ -81,7 +82,7 @@ function status(dir) {
const order = config.order ?? runKeys(config);
const built = Object.fromEntries(config.briefs.flatMap((b) => config.arms.map((a) => {
const folder = armFolder(dir, config.arms, b.id, a);
- return [`${b.id}/${a}`, { folder: path.relative(dir, folder), ready: fs.existsSync(path.join(folder, 'index.html')), run: runs[`${b.id}/${a}`] }];
+ return [`${b.id}/${a}`, { folder: posix(path.relative(dir, folder)), ready: fs.existsSync(path.join(folder, 'index.html')), run: runs[`${b.id}/${a}`] }];
})));
const lines = [`Bake-off in ${dir}. Arms ${config.arms.join(' and ')}, ${plural(config.briefs.length, 'brief')}, seed ${config.seed}. The runs are listed in the order to run them.`];
for (const key of order) {
diff --git a/lib/commands/install.mjs b/lib/commands/install.mjs
index 57bf792..26914cd 100644
--- a/lib/commands/install.mjs
+++ b/lib/commands/install.mjs
@@ -1,6 +1,7 @@
import { parseArgs } from 'node:util';
import { formatCheck, repoSkills, runDoctor } from '../doctor.mjs';
import { APP_NAMES, appsHere, install, uninstall } from '../install.mjs';
+import { LINK_NOTES } from '../links.mjs';
const usage = `
100x install [--uninstall] [--force] [--dry-run] [--no-unslop] [--no-bin] [--json] [--also claude,codex,opencode,cursor]
@@ -25,6 +26,7 @@ to your own copy of unslop-text is kept, unless you pass --force.
function print(result, json) {
if (json) return console.log(JSON.stringify(result, null, 2));
for (const e of result.events) console.log(`${e.kind.padEnd(5)} ${e.status.padEnd(13)} ${e.path}${e.detail ? ` ${e.detail}` : ''}`);
+ for (const how of new Set(result.events.map((e) => e.how).filter(Boolean))) console.log(`\n${LINK_NOTES[how]}`);
return undefined;
}
diff --git a/lib/commands/morning.mjs b/lib/commands/morning.mjs
index c12cb86..f76f1ef 100644
--- a/lib/commands/morning.mjs
+++ b/lib/commands/morning.mjs
@@ -11,6 +11,7 @@ import { inProgress, inProgressLines } from '../in-progress.mjs';
import { decision, heldBack, trustLine } from '../look-first.mjs';
import { mustNotBreakLine } from '../must-not-break.mjs';
import { galleryFile, globalDir, REPO_ROOT } from '../paths.mjs';
+import { openTarget } from '../proc.mjs';
import { countLeftOut, parseWindow, select } from '../registry.mjs';
import { refreshReports } from '../report-refresh.mjs';
import { modern } from '../runfile.mjs';
@@ -32,10 +33,7 @@ A run nobody touched inside the window is counted, and --all lists it. --json pr
const dir = () => path.join(globalDir(), 'morning');
-function opener(target) {
- const tool = process.platform === 'darwin' ? 'open' : 'xdg-open';
- spawn(tool, [target], { detached: true, stdio: 'ignore' }).unref();
-}
+const opener = openTarget;
// The best few get four lines each. Past that, one line each, so fifteen runs are not sixty lines. The gallery has the rest. The judge's
// reasons are what the owner asked for, so a run the judge refused gets one more line down there: its first reason and how many more its card has.
@@ -118,7 +116,7 @@ export default {
fs.mkdirSync(dir(), { recursive: true });
const fd = fs.openSync(path.join(dir(), 'server.log'), 'a');
const args = ['morning', '--serve', ...(values.since ? ['--since', values.since] : []), ...(values.all ? ['--all'] : []), ...(values.port ? ['--port', values.port] : [])];
- spawn(process.execPath, [path.join(REPO_ROOT, 'bin', '100x.mjs'), ...args], { detached: true, stdio: ['ignore', fd, fd], env: process.env }).unref();
+ spawn(process.execPath, [path.join(REPO_ROOT, 'bin', '100x.mjs'), ...args], { detached: true, stdio: ['ignore', fd, fd], env: process.env, windowsHide: true }).unref();
for (let i = 0; i < 40; i += 1) {
await new Promise((resolve) => setTimeout(resolve, 150));
const started = readInfo();
diff --git a/lib/commands/upstream.mjs b/lib/commands/upstream.mjs
index d702245..3e17407 100644
--- a/lib/commands/upstream.mjs
+++ b/lib/commands/upstream.mjs
@@ -1,7 +1,7 @@
-import { execFileSync } from 'node:child_process';
import { parseArgs } from 'node:util';
import UPSTREAM from '../upstream.json' with { type: 'json' };
import { CliError } from '../errors.mjs';
+import { runProgram } from '../proc.mjs';
import { plural } from '../text.mjs';
const usage = `
@@ -27,12 +27,9 @@ export default {
usage,
async run(argv) {
const { values } = parseArgs({ args: argv, options: { json: { type: 'boolean' } } });
- let tsv;
- try {
- tsv = execFileSync(process.env.X100_GH ?? 'gh', ['api', `repos/${UPSTREAM.repo}/commits?path=${UPSTREAM.path}&per_page=40`, '--jq', '.[] | [.sha[0:7], .commit.committer.date, (.commit.message | split("\\n")[0])] | @tsv'], { encoding: 'utf8', timeout: 20000, stdio: ['ignore', 'pipe', 'pipe'] });
- } catch (error) {
- throw new CliError(`Could not read ${UPSTREAM.repo} on GitHub. ${(error.stderr || error.message).toString().trim().slice(0, 200)}`);
- }
+ const reply = runProgram(process.env.X100_GH ?? 'gh', ['api', `repos/${UPSTREAM.repo}/commits?path=${UPSTREAM.path}&per_page=40`, '--jq', '.[] | [.sha[0:7], .commit.committer.date, (.commit.message | split("\\n")[0])] | @tsv'], { encoding: 'utf8', timeout: 20000, stdio: ['ignore', 'pipe', 'pipe'] });
+ if (reply.error || reply.status !== 0) throw new CliError(`Could not read ${UPSTREAM.repo} on GitHub. ${(reply.stderr || reply.error?.message || '').toString().trim().slice(0, 200)}`);
+ const tsv = reply.stdout;
const { found, newer } = newerCommits(tsv, UPSTREAM.pinned);
if (values.json) return console.log(JSON.stringify({ pinned: UPSTREAM.pinned, found, newer }, null, 2));
if (!found) console.log(`The pinned commit ${UPSTREAM.pinned.slice(0, 7)} is not among the latest 40 commits. Everything below may be newer.`);
diff --git a/lib/companions.mjs b/lib/companions.mjs
index bbd56a2..33682c0 100644
--- a/lib/companions.mjs
+++ b/lib/companions.mjs
@@ -106,7 +106,7 @@ export function inOurWords(name, text) {
return text
.replace(new RegExp(`(?<![\\w./-])${spec.name}(?= (?:${commands})(?![\\w-]))`, 'g'), spec.as)
.replace(new RegExp(`(?<![\\w./-])${spec.name}(?= --help(?![\\w-]))`, 'g'), spec.as)
- .replace(new RegExp(`node \\S*/${spec.script.replace('.', '\\.')}(?= (?:${commands})(?![\\w-]))`, 'g'), spec.as)
+ .replace(new RegExp(`node (?:'[^'\\n]*[\\\\/]${spec.script.replace('.', '\\.')}'|"[^"\\n]*[\\\\/]${spec.script.replace('.', '\\.')}"|\\S*[\\\\/]${spec.script.replace('.', '\\.')})(?= (?:${commands})(?![\\w-]))`, 'g'), spec.as)
.replace(new RegExp(`^${spec.name}(?=: )`, 'gm'), spec.as)
.replace(new RegExp(`^${spec.name}(?= [a-z])`), spec.as);
}
diff --git a/lib/doctor.mjs b/lib/doctor.mjs
index be840e1..4196226 100644
--- a/lib/doctor.mjs
+++ b/lib/doctor.mjs
@@ -1,4 +1,5 @@
import fs from 'node:fs';
+import os from 'node:os';
import path from 'node:path';
import { buildStamp } from './build-stamp.mjs';
import { checkVendored, treeHash, vendorDir } from './companions.mjs';
@@ -8,16 +9,23 @@ import { readInfo } from './morning-server.mjs';
import { chromiumBuilds, INSTALL_HINT, resolvePlaywright } from './playwright.mjs';
import { globalDir, REPO_ROOT, skillsDir } from './paths.mjs';
import { recentHelpers, tally } from './provenance.mjs';
+import { launcherState, usesLauncher } from './links.mjs';
+import { isWindows } from './proc.mjs';
import { skillHash } from './skill-hash.mjs';
import { readManifest, staleLinks } from './install-record.mjs';
import { versionLine } from './version.mjs';
import { commandModels, hardCodesMax, isWindowName, lockedCommand, lockSelection, maxWindow, mayBeCursor, namesCursor, optionsSelection, outsideLock, parseOnly, sameId } from './helper-lock.mjs';
-const INSTALL = 'Run `100x install`. From a clone that is not on your PATH yet, run scripts/install.sh in it.';
+const INSTALL = `Run \`100x install\`. From a clone that is not on your PATH yet, run ${isWindows ? '`node bin/100x.mjs install`' : 'scripts/install.sh'} in it.`;
const isSkillCopy = (dir) => fs.lstatSync(dir).isDirectory() && fs.existsSync(path.join(dir, 'SKILL.md'));
function linkState(target, expected) {
+ // On Windows the 100x program is a launcher file (100x.cmd, and 100x for Git Bash) that runs node on the CLI entry.
+ if (usesLauncher(expected)) {
+ const { state } = launcherState(isWindows && !/\.cmd$/i.test(target) ? `${target}.cmd` : target, expected);
+ return state === 'ok' ? 'ok' : state === 'missing' ? 'missing' : 'conflict';
+ }
let stat;
try {
stat = fs.lstatSync(target);
@@ -70,7 +78,19 @@ export function presentChecks(checks) {
return { first, rows, tally: `${count('fail')} fail, ${count('warn')} warn, ${count('ok')} ok.` };
}
-const onPathAs = (name) => (process.env.PATH ?? '').split(path.delimiter).some((entry) => entry && fs.existsSync(path.join(entry, name)));
+// On Windows a program is found by its name plus one of the extensions in PATHEXT.
+const EXTENSIONS = isWindows ? ['', ...(process.env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD').split(';').filter(Boolean)] : [''];
+// `npm install -g` writes its own 100x.cmd that runs the bin of the package, which is this checkout when it was installed from here.
+const npmShimRuns = (file) => {
+ if (!isWindows) return false;
+ try {
+ return /bin[\\/]100x\.mjs/.test(fs.readFileSync(file, 'utf8')) && fs.realpathSync(path.join(path.dirname(file), 'node_modules', JSON.parse(fs.readFileSync(path.join(REPO_ROOT, 'package.json'), 'utf8')).name)) === fs.realpathSync(REPO_ROOT);
+ } catch {
+ return false;
+ }
+};
+
+const onPathAs = (name) => (process.env.PATH ?? '').split(path.delimiter).some((entry) => entry && EXTENSIONS.some((ext) => fs.existsSync(path.join(entry, name + ext))));
// Who judges the finished work. Nothing vendor specific is built in, so an unset judge is a warning with the way out.
// A judge that is the model that builds shares its blind spots, so that is a warning too.
@@ -83,7 +103,7 @@ export function judgeCheck(review, builderModel, only = null) {
if (review.command) {
const word = /^\s*(?:"([^"]+)"|'([^']+)'|(\S+))/.exec(review.command);
const program = word?.[1] ?? word?.[2] ?? word?.[3] ?? '';
- const found = !program || program.includes('$') || (program.includes('/') ? fs.existsSync(program) : onPathAs(program));
+ const found = !program || program.includes('$') || (/[\\/]/.test(program) ? fs.existsSync(program) : onPathAs(program));
if (!found) return ['judge', 'warn', `${program} is not on PATH`, 'Install that tool, or call 100x-setup and change the judge.'];
return ['judge', self ? 'warn' : 'ok', `a command, ${program}${review.model ? `, model ${review.model}` : ''}${self ? `.${SELF_REVIEW}` : ''}`, self ? SELF_REVIEW_FIX : ''];
}
@@ -187,8 +207,8 @@ export async function runDoctor({ deep = false } = {}) {
add('home', 'ok', home);
const bin = linkState(path.join(home, 'bin', '100x'), path.join(REPO_ROOT, 'bin', '100x.mjs'));
add('cli link', bin === 'ok' ? 'ok' : bin === 'missing' ? 'warn' : 'fail', `${home}/bin/100x is ${bin}`, bin === 'ok' ? '' : INSTALL);
- const onPath = (process.env.PATH ?? '').split(path.delimiter).some((entry) => entry && linkState(path.join(entry, '100x'), path.join(REPO_ROOT, 'bin', '100x.mjs')) === 'ok');
- add('on PATH', onPath ? 'ok' : 'warn', onPath ? '`100x` resolves in this shell' : '`100x` is not on PATH in this shell', onPath ? '' : `Call ${path.join(home, 'bin', '100x')}, or put ~/.local/bin on PATH.`);
+ const onPath = (process.env.PATH ?? '').split(path.delimiter).some((entry) => entry && (linkState(path.join(entry, '100x'), path.join(REPO_ROOT, 'bin', '100x.mjs')) === 'ok' || npmShimRuns(path.join(entry, '100x.cmd'))));
+ add('on PATH', onPath ? 'ok' : 'warn', onPath ? '`100x` resolves in this shell' : '`100x` is not on PATH in this shell', onPath ? '' : `Call ${path.join(home, 'bin', isWindows ? '100x.cmd' : '100x')}, or put ${isWindows ? path.join(os.homedir(), '.local', 'bin') : '~/.local/bin'} on PATH.`);
add('profile', fs.existsSync(path.join(home, 'profile.md')) ? 'ok' : 'warn', path.join(home, 'profile.md'), 'Run `100x install`. It writes a default profile.');
// An older install may have linked a skill that this repo has since dropped. The link is dead and the agent reads the folder it sits in.
const record = path.join(home, 'install.json');
diff --git a/lib/eval/blind.mjs b/lib/eval/blind.mjs
index c8d444b..5a6cdba 100644
--- a/lib/eval/blind.mjs
+++ b/lib/eval/blind.mjs
@@ -3,7 +3,8 @@ import fs from 'node:fs';
import path from 'node:path';
import { spawnSync } from 'node:child_process';
import { CliError } from '../errors.mjs';
-import { REPO_ROOT } from '../paths.mjs';
+import { posix, REPO_ROOT, slashes } from '../paths.mjs';
+import { isWindows } from '../proc.mjs';
import { chromiumBuilds, INSTALL_HINT, resolvePlaywright } from '../playwright.mjs';
import { readReceipt, receiptParams } from '../receipt.mjs';
import { sign, signingKey } from '../seal.mjs';
@@ -116,12 +117,14 @@ export function pinSkill(dir) {
fs.mkdirSync(path.join(folder, 'home'), { recursive: true });
for (const item of PIN_ITEMS) if (fs.existsSync(path.join(REPO_ROOT, item))) fs.cpSync(path.join(REPO_ROOT, item), path.join(folder, item), { recursive: true });
const playwright = resolvePlaywright()?.base;
- const command = path.join(folder, '100x');
- fs.writeFileSync(command, `#!/bin/sh\nX100_HOME=${shell(path.join(folder, 'home'))}${playwright ? ` X100_PLAYWRIGHT_FROM=${shell(playwright)}` : ''} exec node ${shell(path.join(folder, 'bin', '100x.mjs'))} "$@"\n`, { mode: 0o755 });
+ const command = slashes(path.join(folder, '100x'));
+ fs.writeFileSync(path.join(folder, '100x'), `#!/bin/sh\nX100_HOME=${shell(slashes(path.join(folder, 'home')))}${playwright ? ` X100_PLAYWRIGHT_FROM=${shell(slashes(playwright))}` : ''} exec node ${shell(slashes(path.join(folder, 'bin', '100x.mjs')))} "$@"\n`, { mode: 0o755 });
+ // Windows also gets the launcher cmd and PowerShell run, 100x.cmd, which sets the same two variables for its own process only.
+ if (isWindows) fs.writeFileSync(path.join(folder, '100x.cmd'), `@echo off\r\nsetlocal\r\nset "X100_HOME=${path.join(folder, 'home')}"\r\n${playwright ? `set "X100_PLAYWRIGHT_FROM=${playwright}"\r\n` : ''}node "${path.join(folder, 'bin', '100x.mjs')}" %*\r\n`);
return { folder, command, snapshot: gitState() };
}
-const METHOD = (pin) => `Follow the skill in ${path.join(pin.folder, 'skills', '100x-mockup', 'SKILL.md')}. Its 100x command is ${pin.command}, so run that wherever the skill says to run 100x. Read no other SKILL.md file and use no other skill.`;
+const METHOD = (pin) => `Follow the skill in ${slashes(path.join(pin.folder, 'skills', '100x-mockup', 'SKILL.md'))}. Its 100x command is ${pin.command}, so run that wherever the skill says to run 100x. Read no other SKILL.md file and use no other skill.`;
export const runKeys = (config) => config.briefs.flatMap((b) => config.arms.map((a) => `${b.id}/${a}`));
@@ -247,7 +250,7 @@ export function scanForLeaks(folder, patterns, { product = false } = {}) {
for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
if (product && notProduct(entry.name, entry.isDirectory())) continue;
const file = path.join(current, entry.name);
- const relative = path.relative(folder, file);
+ const relative = posix(path.relative(folder, file));
for (const { word, pattern } of patterns) if (pattern.test(relative)) hits.push({ file: relative, line: 0, text: `the file name holds "${word}"` });
if (entry.isDirectory()) {
walk(file);
@@ -402,7 +405,7 @@ export function buildPairs(dir, { capture: shoot = true, allow = [], blank = fal
if (!fs.existsSync(path.join(folder, 'index.html'))) fs.writeFileSync(path.join(folder, 'index.html'), BLANK_PAGE);
if (label === 'blurred') blurCopy(folder);
const rank = [label === 'blurred' ? 1 : 0, config.briefs.findIndex((b) => b.id === item.brief), config.arms.indexOf(arm)];
- sources.set(id, { id, folder, screens: [], copies: 0, rank, name: `${item.brief}/${arm}`, control: label === 'blurred', origin: path.relative(dir, armFolder(dir, config.arms, item.brief, arm)) });
+ sources.set(id, { id, folder, screens: [], copies: 0, rank, name: `${item.brief}/${arm}`, control: label === 'blurred', origin: posix(path.relative(dir, armFolder(dir, config.arms, item.brief, arm))) });
}
return sources.get(id);
};
@@ -412,8 +415,8 @@ export function buildPairs(dir, { capture: shoot = true, allow = [], blank = fal
const early = { hits: [], unscanned: [] };
for (const made of sources.values()) {
const result = scanForLeaks(made.folder, patterns);
- early.hits.push(...result.hits.map((hit) => ({ ...hit, file: path.join(made.origin, hit.file), copies: made.copies })));
- early.unscanned.push(...result.unscanned.map((item) => ({ ...item, file: path.join(made.origin, item.file), copies: made.copies })));
+ early.hits.push(...result.hits.map((hit) => ({ ...hit, file: path.posix.join(made.origin, hit.file), copies: made.copies })));
+ early.unscanned.push(...result.unscanned.map((item) => ({ ...item, file: path.posix.join(made.origin, item.file), copies: made.copies })));
}
refuse(early.hits, early.unscanned);
@@ -428,7 +431,7 @@ export function buildPairs(dir, { capture: shoot = true, allow = [], blank = fal
made.screens = taken.screens;
// What the page showed once it ran is scanned for the same names as its files, and a name found there is refused at once, in brief order.
const shown = taken.rendered.filter((text) => patterns.some(({ pattern }) => pattern.test(text)));
- refuse(shown.map((text) => ({ file: path.join(made.origin, 'index.html (as it rendered)'), line: 0, text: text.slice(0, 100), copies: made.copies })), []);
+ refuse(shown.map((text) => ({ file: path.posix.join(made.origin, 'index.html (as it rendered)'), line: 0, text: text.slice(0, 100), copies: made.copies })), []);
progress(` page ${index + 1} of ${ordered.length}: ${made.control ? `the blurred control, from ${made.name}` : made.name}, ${Math.round((Date.now() - started) / 1000)} s so far`);
});
}
@@ -457,8 +460,8 @@ export function buildPairs(dir, { capture: shoot = true, allow = [], blank = fal
const result = scanForLeaks(path.join(work, 'judge', pack), patterns);
scanned += result.scanned;
binary += result.binary;
- hits.push(...result.hits.map((hit) => ({ ...hit, file: path.join(pack, hit.file) })));
- unscanned.push(...result.unscanned.map((item) => ({ ...item, file: path.join(pack, item.file) })));
+ hits.push(...result.hits.map((hit) => ({ ...hit, file: path.posix.join(posix(pack), hit.file) })));
+ unscanned.push(...result.unscanned.map((item) => ({ ...item, file: path.posix.join(posix(pack), item.file) })));
}
refuse(hits, unscanned);
fs.renameSync(path.join(work, 'judge'), where.judge);
diff --git a/lib/eval/pictures.mjs b/lib/eval/pictures.mjs
index ad2aa05..84b73a7 100644
--- a/lib/eval/pictures.mjs
+++ b/lib/eval/pictures.mjs
@@ -86,7 +86,7 @@ export async function buildPictures(dir, out, { progress = () => {} } = {}) {
const item = real.find((entry) => entry.brief === brief);
// The originals are copied beside the report. Linking into the judge folders breaks as soon as the report is not inside the bake-off folder, and that is where it is usually put.
const originals = key.arms.flatMap((arm) => ['phone', 'desktop'].map((size) => {
- const copy = path.join('screens', brief, `${arm}-${size}.png`);
+ const copy = path.posix.join('screens', brief, `${arm}-${size}.png`);
fs.mkdirSync(path.dirname(path.join(out, copy)), { recursive: true });
fs.copyFileSync(screen(item, arm, `${size}.png`), path.join(out, copy));
return [`${arm} ${size}`, copy];
diff --git a/lib/eval/words.mjs b/lib/eval/words.mjs
index fd5b9e3..6853254 100644
--- a/lib/eval/words.mjs
+++ b/lib/eval/words.mjs
@@ -30,4 +30,8 @@ export function wrap(text, { width = 100, indent = '' } = {}) {
}
// A path as a shell would need it written, so a command printed here can be pasted as it stands.
-export const shellPath = (text) => (/^[\w@%+=:,./-]+$/.test(text) ? text : `'${text.replaceAll("'", "'\\''")}'`);
+// On Windows the path is written with forward slashes, which cmd, PowerShell and sh all take and which need no quoting.
+export const shellPath = (path) => {
+ const text = process.platform === 'win32' ? path.replaceAll('\\', '/') : path;
+ return /^[\w@%+=:,./-]+$/.test(text) ? text : `'${text.replaceAll("'", "'\\''")}'`;
+};
diff --git a/lib/init.mjs b/lib/init.mjs
index d676904..220880b 100644
--- a/lib/init.mjs
+++ b/lib/init.mjs
@@ -5,7 +5,7 @@ import path from 'node:path';
import { COLUMNS, isRunStart, readRows } from './decisions.mjs';
import { CliError } from './errors.mjs';
import { archiveStageTags } from './git.mjs';
-import { globalDir } from './paths.mjs';
+import { globalDir, posix } from './paths.mjs';
import { PROMPT_MARKER, PROMPT_MARKER_TEXT, projectTemplate } from './prompt.mjs';
const FRAMEWORKS = {
@@ -137,7 +137,7 @@ function archiveEarlierRun(root, now = new Date()) {
for (let n = 2; fs.existsSync(target); n += 1) target = path.join(state, 'archive', `${stamp}-${n}`);
fs.mkdirSync(target, { recursive: true });
for (const name of names) fs.renameSync(path.join(state, name), path.join(target, name));
- return { dir: path.relative(root, target), tags: archiveStageTags(root, path.basename(target)) };
+ return { dir: posix(path.relative(root, target)), tags: archiveStageTags(root, path.basename(target)) };
}
export function initProject({ dir = process.cwd(), git: useGit = true, track = false, fresh = false } = {}) {
diff --git a/lib/install.mjs b/lib/install.mjs
index 8e5d841..23c869c 100644
--- a/lib/install.mjs
+++ b/lib/install.mjs
@@ -5,7 +5,9 @@ import path from 'node:path';
import { vendorDir } from './companions.mjs';
import { repoSkills } from './doctor.mjs';
import { CliError } from './errors.mjs';
+import { launcherState, makeLink, usesLauncher, writeLauncher } from './links.mjs';
import { globalDir, REPO_ROOT, skillsDir } from './paths.mjs';
+import { isWindows } from './proc.mjs';
import { skillHash } from './skill-hash.mjs';
import { MANIFEST, readManifest, staleLinks } from './install-record.mjs';
@@ -17,6 +19,9 @@ export const APP_NAMES = { claude: 'Claude Code', codex: 'Codex', opencode: 'Ope
// The apps whose folder is already on this machine. They read their own skills folder, so a default install does not reach them.
export const appsHere = (home = os.homedir()) => Object.entries(APP_SKILL_DIRS).filter(([, parts]) => fs.existsSync(path.join(home, ...parts.slice(0, -1)))).map(([app]) => app);
+// Windows paths differ by case and by a closing backslash that a junction keeps, and both name the same folder.
+const sameFolderPath = (a, b) => (isWindows ? path.resolve(a).toLowerCase() === path.resolve(b).toLowerCase() : path.resolve(a) === path.resolve(b));
+
const sha256 = (text) => crypto.createHash('sha256').update(text).digest('hex');
const canonical = (p) => (fs.existsSync(p) ? fs.realpathSync.native(p) : path.resolve(p));
const lstat = (p) => {
@@ -28,6 +33,8 @@ const lstat = (p) => {
};
export function linkStatus(linkPath, target) {
+ // On Windows the 100x program is a launcher file, not a link, because only an .exe, .cmd or script is run by its name.
+ if (usesLauncher(target)) return launcherState(linkPath, target);
const stat = lstat(linkPath);
if (!stat) return { state: 'missing' };
if (!stat.isSymbolicLink()) {
@@ -37,7 +44,7 @@ export function linkStatus(linkPath, target) {
}
const current = fs.readlinkSync(linkPath);
const resolved = path.resolve(path.dirname(linkPath), current);
- const same = canonical(linkPath) === canonical(target) || resolved === path.resolve(target);
+ const same = canonical(linkPath) === canonical(target) || sameFolderPath(resolved, target);
return { state: same ? 'ok' : 'elsewhere', current: resolved };
}
@@ -75,7 +82,7 @@ export function install(options = {}) {
const events = [];
let ok = true;
- const note = (kind, status, target, detail = '') => events.push({ kind, status, path: target, detail });
+ const note = (kind, status, target, detail = '', how = 'symlink') => events.push({ kind, status, path: target, detail, ...(how === 'symlink' ? {} : { how }) });
function ensureDir(dir) {
if (fs.existsSync(dir)) return;
@@ -100,14 +107,26 @@ export function install(options = {}) {
if (core) ok = false;
return note('link', 'conflict', linkPath, `already points to ${status.current}. Run again with --force to replace it`);
}
- const replaced = status.state === 'elsewhere' ? status.current : undefined;
+ const launcher = usesLauncher(target);
+ // A launcher that ran another 100x is overwritten, and there is no earlier link to give back on uninstall.
+ const replaced = status.state === 'elsewhere' && !launcher ? status.current : undefined;
+ let how = launcher ? 'launcher' : 'symlink';
if (!o.dryRun) {
fs.mkdirSync(path.dirname(linkPath), { recursive: true });
- if (replaced) fs.unlinkSync(linkPath);
- fs.symlinkSync(target, linkPath);
+ if (status.state === 'elsewhere' && !launcher) fs.unlinkSync(linkPath);
+ if (launcher) writeLauncher(linkPath, target);
+ else how = makeLink(target, linkPath);
}
manifest.links.push({ path: linkPath, target, ...(replaced ? { replaced } : {}) });
- note('link', o.dryRun ? 'would link' : replaced ? 'replaced' : 'created', linkPath, target);
+ note('link', o.dryRun ? 'would link' : status.state === 'elsewhere' ? 'replaced' : 'created', linkPath, how === 'symlink' ? target : `${target} (${how})`, how);
+ }
+
+ // The 100x program. On Windows that is two launchers, 100x.cmd for cmd and PowerShell and 100x for Git Bash, each running node on the CLI entry.
+ function program(linkPath, unixTarget, opts) {
+ if (!isWindows) return link(linkPath, unixTarget, opts);
+ const entry = path.join(o.repo, 'bin', '100x.mjs');
+ link(linkPath, entry, opts);
+ return link(`${linkPath}.cmd`, entry, opts);
}
function file(filePath, content, { overwrite }) {
@@ -136,11 +155,11 @@ export function install(options = {}) {
const skillDirs = [...new Set([o.skills, ...o.also])];
for (const dir of skillDirs) ensureDir(dir);
- link(path.join(o.home, 'bin', '100x'), path.join(o.repo, 'bin', '100x.mjs'));
+ program(path.join(o.home, 'bin', '100x'), path.join(o.repo, 'bin', '100x.mjs'));
if (o.binDir) {
ensureDir(o.binDir);
- link(path.join(o.binDir, '100x'), path.join(o.home, 'bin', '100x'), { core: false });
- if (!onPath(o.binDir)) note('path', 'hint', o.binDir, `is not on PATH. Add it, or call ${path.join(o.home, 'bin', '100x')}`);
+ program(path.join(o.binDir, '100x'), path.join(o.home, 'bin', '100x'), { core: false });
+ if (!onPath(o.binDir)) note('path', 'hint', o.binDir, isWindows ? `is not on PATH. Add it in Windows Settings (search for "environment variables"), or call ${path.join(o.home, 'bin', '100x.cmd')}` : `is not on PATH. Add it, or call ${path.join(o.home, 'bin', '100x')}`);
}
file(path.join(o.home, 'repo'), `${o.repo}\n`, { overwrite: true });
@@ -181,7 +200,7 @@ export function install(options = {}) {
const restore = old.replaced && fs.existsSync(old.replaced) ? old.replaced : null;
if (!o.dryRun) {
fs.unlinkSync(old.path);
- if (restore) fs.symlinkSync(restore, old.path);
+ if (restore) makeLink(restore, old.path);
}
note('link', o.dryRun ? 'would remove' : 'removed', old.path, `the skill it pointed at, ${target}, is no longer in this repo${restore ? `. Restored the link you had made, to ${restore}` : ''}`);
}
@@ -210,7 +229,7 @@ export function uninstall(options = {}) {
} else {
if (!o.dryRun) {
fs.unlinkSync(record.path);
- if (record.replaced) fs.symlinkSync(record.replaced, record.path);
+ if (record.replaced) makeLink(record.replaced, record.path);
}
if (!record.replaced) removed.add(record.path);
note('link', o.dryRun ? 'would remove' : 'removed', record.path, record.replaced ? `restored the link to ${record.replaced}` : '');
diff --git a/lib/links.mjs b/lib/links.mjs
index 89f144d..84af9dd 100644
--- a/lib/links.mjs
+++ b/lib/links.mjs
@@ -16,21 +16,29 @@ const isFolder = (target) => {
// Makes linkPath point at target and says what it made: 'symlink' or 'junction'. Throws when neither can be made.
export function makeLink(target, linkPath) {
- const folder = isFolder(target);
+ // A relative target is read from the folder that holds the link, as a symlink reads it. A junction needs the whole path.
+ const absolute = path.resolve(path.dirname(linkPath), target);
+ const folder = isFolder(absolute);
+ // A link to a folder that is gone is made the same way, because the links this makes are to skill folders.
+ const junctionable = isWindows && (folder || !fs.existsSync(absolute));
if (!process.env.X100_NO_SYMLINK) {
try {
fs.symlinkSync(target, linkPath, folder ? 'dir' : 'file');
return 'symlink';
} catch (error) {
- if (!refused(error) || !folder) throw error;
+ if (!refused(error) || !junctionable) throw error;
}
}
- if (!folder || !isWindows) throw Object.assign(new Error(`could not link ${linkPath} to ${target}`), { code: 'EPERM' });
- fs.symlinkSync(target, linkPath, 'junction');
+ if (!junctionable) throw Object.assign(new Error(`could not link ${linkPath} to ${target}`), { code: 'EPERM' });
+ fs.symlinkSync(absolute, linkPath, 'junction');
return 'junction';
}
-export const LINK_WORDS = { symlink: 'a symlink', junction: 'a junction, because this account cannot make symlinks (they need Developer Mode or an administrator)', launcher: 'a launcher file, because Windows runs a program by its file name and not by a link' };
+// What each kind of link is, said once after a listing of links, so the listing itself stays short.
+export const LINK_NOTES = {
+ junction: 'junction: a folder link that Windows lets any account make. A symlink needs Developer Mode or an administrator, and this account has neither. A junction works the same for the agent apps.',
+ launcher: 'launcher: a small file that runs 100x, because Windows starts a program by its file name and not through a link. 100x.cmd is for cmd and PowerShell, and 100x is for Git Bash.',
+};
// On Windows the 100x program is a pair of launchers, 100x.cmd for cmd and PowerShell and a script named 100x for Git Bash, each running node on the CLI entry.
export const usesLauncher = (target) => isWindows && path.extname(target) === '.mjs';
diff --git a/lib/matrix.mjs b/lib/matrix.mjs
index 48e1d24..41cd78c 100644
--- a/lib/matrix.mjs
+++ b/lib/matrix.mjs
@@ -470,21 +470,25 @@ export async function runMatrix(options) {
if (!found) throw new CliError(`Playwright is not installed anywhere 100x can see. ${INSTALL_HINT}`);
fs.mkdirSync(options.outDir, { recursive: true });
const started = Date.now();
- const browser = await found.playwright.chromium.launch({
+ const launch = () => found.playwright.chromium.launch({
headless: true,
args: ['--mute-audio', '--ignore-gpu-blocklist', '--enable-unsafe-swiftshader', '--use-angle=swiftshader'].filter((arg) => options.sound !== true || arg !== '--mute-audio'),
});
+ let browser = await launch();
const result = { tool: '100x shots', target: options.url, matrix: options.matrixName, startedAt: new Date(started).toISOString(), viewports: [] };
// Every string the page showed in any viewport or state, once, so the copy can be linted with `100x text lint`.
const texts = new Set();
const withTexts = { ...options, texts };
try {
for (const viewport of options.viewports) {
+ // A picture too large for the machine can take the whole browser down with it (Chromium on Windows does), and the sizes after it still need one.
+ if (!browser.isConnected()) browser = await launch();
const handle = {};
const work = runViewport(browser, viewport, withTexts, handle);
result.viewports.push(await withDeadline(work, options.viewportTimeoutMs ?? (Number(process.env.X100_VIEWPORT_TIMEOUT_MS) || VIEWPORT_CAP_MS), handle, `the ${viewport.name} size`).catch((error) => failedViewport(viewport, error)));
}
fs.writeFileSync(path.join(options.outDir, 'contact-sheet.html'), contactSheet(result));
+ if (!browser.isConnected()) browser = await launch();
await renderSheetPng(browser, options.outDir).catch(() => {});
} finally {
await browser.close();
diff --git a/lib/morning-server.mjs b/lib/morning-server.mjs
index ed07f69..73aa8a3 100644
--- a/lib/morning-server.mjs
+++ b/lib/morning-server.mjs
@@ -1,4 +1,3 @@
-import { spawn, spawnSync } from 'node:child_process';
import crypto from 'node:crypto';
import fs from 'node:fs';
import http from 'node:http';
@@ -10,6 +9,7 @@ import { esc, renderGallery, startableAddress, THEME, windowWords } from './gall
import { inProgress } from './in-progress.mjs';
import { galleryFile, globalDir } from './paths.mjs';
import { countLeftOut, readRegistry, select } from './registry.mjs';
+import { killTree, openLog, processCommand, spawnShell } from './proc.mjs';
import { refreshReports } from './report-refresh.mjs';
import { runDir } from './run-dir.mjs';
@@ -75,11 +75,11 @@ function alive(pid) {
// A pid in server.json can outlive the server and be handed to some other program. Signal it only when its command
// line says it is this gallery server, started as `100x morning --serve` or `100x.mjs morning --serve`.
-const SERVER_COMMAND = /(?:^|[\s/])100x(?:\.mjs)?\s+morning\s.*--serve/;
+const SERVER_COMMAND = /(?:^|[\s/\\])100x(?:\.mjs)?"?\s+morning\s.*--serve/;
function isGalleryServer(pid) {
- const result = spawnSync('ps', ['-p', String(pid), '-o', 'command='], { encoding: 'utf8' });
- return result.status === 0 && SERVER_COMMAND.test(result.stdout);
+ const command = processCommand(pid);
+ return command !== null && SERVER_COMMAND.test(command);
}
export function readInfo() {
@@ -92,7 +92,9 @@ export function readInfo() {
}
export async function stopServer(info) {
- process.kill(info.pid, 'SIGTERM');
+ // Windows ends a process the moment it is signalled, so the server never gets to stop its prototypes. Ending the tree stops them too.
+ if (process.platform === 'win32') killTree(info.pid);
+ else process.kill(info.pid, 'SIGTERM');
fs.rmSync(infoFile(), { force: true });
for (let waited = 0; waited < 3000 && alive(info.pid); waited += 100) await delay(100);
}
@@ -146,8 +148,8 @@ export function createController() {
// The card links the log through the served files, when this run's folder is the one that holds it.
const log = runDir(entry) === path.dirname(logFile) ? `file/${id}/dev.log` : undefined;
fs.mkdirSync(path.dirname(logFile), { recursive: true });
- const fd = fs.openSync(logFile, 'a');
- const child = spawn('sh', ['-c', command], {
+ const fd = openLog(logFile);
+ const child = spawnShell(command, {
cwd: entry.path,
detached: true,
stdio: ['ignore', fd, fd],
@@ -170,9 +172,7 @@ export function createController() {
function stop(id) {
const held = children.get(id);
if (!held) return false;
- try {
- process.kill(-held.child.pid, 'SIGTERM');
- } catch {
+ if (!killTree(held.child.pid)) {
try {
held.child.kill('SIGTERM');
} catch {
diff --git a/lib/paths.mjs b/lib/paths.mjs
index 01edcf7..0ae336c 100644
--- a/lib/paths.mjs
+++ b/lib/paths.mjs
@@ -1,7 +1,16 @@
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
-import { fileURLToPath } from 'node:url';
+import { fileURLToPath, pathToFileURL } from 'node:url';
+
+// A relative path as people write it in text and docs, with / on every system.
+export const posix = (p) => p.split(path.sep).join('/');
+
+// pathToFileURL, except that a Windows path with a root and no drive letter, as the README's sample paths are, is kept as written.
+export const fileUrl = (p) => (process.platform === 'win32' && /^[\\/](?![\\/])/.test(p) ? `file://${p.replaceAll('\\', '/')}` : pathToFileURL(p).href);
+
+// A path written with / on Windows too, for text an agent reads and a command that is pasted into a shell.
+export const slashes = (p) => (process.platform === 'win32' ? p.replaceAll('\\', '/') : p);
export const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
diff --git a/lib/playwright.mjs b/lib/playwright.mjs
index afd9ae7..2922821 100644
--- a/lib/playwright.mjs
+++ b/lib/playwright.mjs
@@ -30,6 +30,7 @@ export function resolvePlaywright(cwd = process.cwd()) {
export function browserCacheDir() {
if (process.env.PLAYWRIGHT_BROWSERS_PATH && process.env.PLAYWRIGHT_BROWSERS_PATH !== '0') return process.env.PLAYWRIGHT_BROWSERS_PATH;
+ if (process.platform === 'win32') return path.join(process.env.LOCALAPPDATA ?? path.join(os.homedir(), 'AppData', 'Local'), 'ms-playwright');
return process.platform === 'darwin' ? path.join(os.homedir(), 'Library', 'Caches', 'ms-playwright') : path.join(os.homedir(), '.cache', 'ms-playwright');
}
diff --git a/lib/proc.mjs b/lib/proc.mjs
index 8116bb5..639054d 100644
--- a/lib/proc.mjs
+++ b/lib/proc.mjs
@@ -32,20 +32,12 @@ export function findSh() {
if (process.env.X100_SH && fs.existsSync(process.env.X100_SH)) foundSh = process.env.X100_SH;
else if (!isWindows) foundSh = 'sh';
else {
- const roots = new Set();
- for (const dir of (process.env.PATH ?? '').split(path.delimiter)) {
- if (!dir) continue;
- // C:\Program Files\Git\cmd and C:\Program Files\Git\bin both sit one folder under the Git root.
- if (fs.existsSync(path.join(dir, 'git.exe'))) roots.add(path.dirname(dir));
- for (const name of ['sh.exe']) if (fs.existsSync(path.join(dir, name)) && !/system32/i.test(dir)) foundSh = foundSh ?? path.join(dir, name);
- }
+ // An sh.exe on PATH wins. Otherwise the Git for Windows folders are tried, from git.exe on PATH (C:\Program Files\Git\cmd is one folder under the Git root) and from the usual places.
+ const dirs = (process.env.PATH ?? '').split(path.delimiter).filter(Boolean);
+ const roots = new Set(dirs.filter((dir) => fs.existsSync(path.join(dir, 'git.exe'))).map((dir) => path.dirname(dir)));
for (const base of [process.env.ProgramFiles, process.env['ProgramFiles(x86)'], process.env.ProgramW6432, process.env.LOCALAPPDATA && path.join(process.env.LOCALAPPDATA, 'Programs')]) if (base) roots.add(path.join(base, 'Git'));
- for (const root of roots) {
- for (const rel of [['usr', 'bin', 'sh.exe'], ['bin', 'sh.exe']]) {
- const candidate = path.join(root, ...rel);
- if (!foundSh && fs.existsSync(candidate)) foundSh = candidate;
- }
- }
+ const candidates = [...dirs.map((dir) => path.join(dir, 'sh.exe')), ...[...roots].flatMap((root) => [path.join(root, 'usr', 'bin', 'sh.exe'), path.join(root, 'bin', 'sh.exe')])];
+ foundSh = candidates.find((candidate) => fs.existsSync(candidate)) ?? null;
}
return foundSh;
}
@@ -62,7 +54,33 @@ export function shellInvocation(script, { requireSh = false } = {}) {
export function spawnShell(script, options = {}, { requireSh = false } = {}) {
const { file, args, options: extra } = shellInvocation(script, { requireSh });
- return spawn(file, args, { windowsHide: true, ...extra, ...options });
+ return spawn(file, args, { windowsHide: true, ...extra, ...options, ...(isWindows && file !== (process.env.ComSpec || 'cmd.exe') ? { env: withToolsOnPath(options.env ?? process.env, path.dirname(file)) } : {}) });
+}
+
+// sh.exe started from outside Git Bash does not put Git's own tools (sleep, cat, mkdir) on the PATH of the commands it runs. Its folder goes first.
+function withToolsOnPath(env, dir) {
+ const key = Object.keys(env).find((name) => name.toUpperCase() === 'PATH') ?? 'PATH';
+ const current = env[key] ?? '';
+ if (current.split(path.delimiter).some((entry) => entry.toLowerCase() === dir.toLowerCase())) return env;
+ return { ...env, [key]: `${dir}${path.delimiter}${current}` };
+}
+
+// A log file a child writes to for as long as it runs. A handle opened for append on Windows lets only native programs write, and a child
+// started by sh (an MSYS program) loses its output, so there the file is opened for writing and moved to its end, which is the same place.
+export function openLog(file) {
+ if (!isWindows) return fs.openSync(file, 'a');
+ let size = 0;
+ try {
+ size = fs.statSync(file).size;
+ } catch {
+ return fs.openSync(file, 'w');
+ }
+ // A log from an earlier run that grew past a megabyte is started over instead of read through.
+ if (size > 1 << 20) return fs.openSync(file, 'w');
+ const fd = fs.openSync(file, 'r+');
+ const chunk = Buffer.alloc(65536);
+ while (fs.readSync(fd, chunk, 0, chunk.length, null) > 0);
+ return fd;
}
// Windows has no process groups to signal. taskkill /T ends a process and everything it started.
diff --git a/lib/project.mjs b/lib/project.mjs
index 1073ef9..31b17a5 100644
--- a/lib/project.mjs
+++ b/lib/project.mjs
@@ -190,7 +190,14 @@ export function targetIsOurs(root, target, run = {}) {
} catch {
return false;
}
- if (url.protocol === 'file:') return insideRoot(root, fileURLToPath(url));
+ if (url.protocol === 'file:') {
+ try {
+ return insideRoot(root, fileURLToPath(url));
+ } catch {
+ // A path that names no place on this system, such as one with no drive on Windows, is not in the project.
+ return false;
+ }
+ }
if (url.protocol !== 'http:' && url.protocol !== 'https:') return false;
const host = url.hostname.replace(/^\[|\]$/g, '');
if (LOCAL_HOSTS.has(host) || host.endsWith('.localhost') || onThisNetwork(host)) return true;
diff --git a/lib/provenance.mjs b/lib/provenance.mjs
index ccffec8..878ad97 100644
--- a/lib/provenance.mjs
+++ b/lib/provenance.mjs
@@ -15,6 +15,7 @@ const HOOK_LOG = /^cursor\.hooks\..*\.log$/;
export function cursorLogsDir() {
if (process.env.X100_CURSOR_LOGS !== undefined) return process.env.X100_CURSOR_LOGS;
const home = os.homedir();
+ if (process.platform === 'win32') return path.join(process.env.APPDATA ?? path.join(home, 'AppData', 'Roaming'), 'Cursor', 'logs');
return process.platform === 'darwin' ? path.join(home, 'Library', 'Application Support', 'Cursor', 'logs') : path.join(home, '.config', 'Cursor', 'logs');
}
diff --git a/lib/report.mjs b/lib/report.mjs
index 0b28a6a..403e41c 100644
--- a/lib/report.mjs
+++ b/lib/report.mjs
@@ -6,7 +6,7 @@ import { stageTags } from './git.mjs';
import { lookFirst, lookTone, worstReason } from './look-first.mjs';
import { reasonsFor, reasonText, SHORT, shownReasons } from './why-not.mjs';
import { checkWords, mustNotBreakList } from './must-not-break.mjs';
-import { galleryFile } from './paths.mjs';
+import { fileUrl, galleryFile } from './paths.mjs';
import { finalMatrix, readAsks, runRows, stateFile } from './project.mjs';
import { renderReportHtml } from './report-html.mjs';
import { modern } from './runfile.mjs';
@@ -175,7 +175,7 @@ export function chatSummary(entry) {
...(roundsLine(entry.review) ? [roundsLine(entry.review)] : []),
m ? `Screen sizes: ${m.totals.broken} broken, ${m.totals.weak} weak, ${plural(m.viewports, 'size')} and ${plural(m.examined, 'element')} checked` : `Screen sizes: ${entry.matrixSkipped ? `skipped, ${bare(entry.matrixSkipped)}` : 'not run'}`,
...(entry.asks.total ? [`Asks: ${entry.asks.closed} of ${entry.asks.total} closed`] : []),
- `Report: ${pathToFileURL(path.join(entry.path, '.100x', 'REPORT.html')).href}`,
+ `Report: ${fileUrl(path.join(entry.path, '.100x', 'REPORT.html'))}`,
];
if (workLine(entry.work)) lines.splice(-1, 0, workLine(entry.work));
if (entry.nextAsks?.length) lines.push(`Next likely asks: ${entry.nextAsks.slice(0, 3).join('; ')}${entry.nextAsks.length > 3 ? `; and ${entry.nextAsks.length - 3} more in the report` : ''}`);
diff --git a/lib/review-run.mjs b/lib/review-run.mjs
index 9602725..0dd9440 100644
--- a/lib/review-run.mjs
+++ b/lib/review-run.mjs
@@ -1,9 +1,9 @@
-import { execFileSync, spawn } from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import { checkCommand, helperTarget } from './delegate.mjs';
import { CliError } from './errors.mjs';
import { briefFile, findingsFile, loopAskFile, loopFindingsFile, loopTask, reviewDir, reviewTask, checkLoopName } from './review.mjs';
+import { killTree, openLog, processStart as startOf, spawnShell } from './proc.mjs';
import { plannedRounds, roundStatus } from './rounds.mjs';
const file = (root, name) => path.join(reviewDir(root), name);
@@ -36,16 +36,9 @@ export function reviewEnv(root, config, { fallback = false, loop = null } = {})
};
}
-// When a process started, as ps prints it. A pid alone is reused after a reboot or a kill, so the record keeps this beside it.
-// null when ps cannot say, and then only the pid is checked.
-export const processStart = (pid) => {
- try {
- const text = execFileSync('ps', ['-o', 'lstart=', '-p', String(pid)], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
- return text || null;
- } catch {
- return null;
- }
-};
+// When a process started, as ps prints it (the start time that PowerShell reports on Windows). A pid alone is reused after a reboot or a kill,
+// so the record keeps this beside it. null when the system cannot say, and then only the pid is checked.
+export const processStart = startOf;
// The judge is started by this user, so a process this user cannot signal is not the judge (EPERM). A live pid whose start time differs from the record's is another process that reused the number.
const alive = (record) => {
@@ -85,9 +78,9 @@ export function startReview(root, config, { fallback = false, loop = null } = {}
checkCommand(command, config.review.provider, fallback ? 'fallback judge' : 'judge', { only: config.helper?.only ?? null });
fs.mkdirSync(reviewDir(root), { recursive: true });
fs.rmSync(file(root, 'run.exit'), { force: true });
- const log = fs.openSync(file(root, 'run.log'), 'a');
+ const log = openLog(file(root, 'run.log'));
const script = `${command}\nstatus=$?\nprintf '%s' "$status" > "$X100_EXIT_FILE"\nexit $status`;
- const child = spawn('sh', ['-c', script], { cwd: root, env: { ...process.env, ...env }, detached: true, stdio: ['ignore', log, log] });
+ const child = spawnShell(script, { cwd: root, env: { ...process.env, ...env }, detached: true, stdio: ['ignore', log, log] }, { requireSh: true });
child.on('error', () => {});
child.unref();
fs.closeSync(log);
@@ -101,11 +94,7 @@ export function stopReview(root) {
if (!record) return { state: 'none' };
// Only a judge that is still the process this record names is signalled. A pid that was reused, or a judge that already exited, is left alone.
if (!record.stopped && !fs.existsSync(file(root, 'run.exit')) && alive(record)) {
- try {
- process.kill(-record.pid, 'SIGTERM');
- } catch {
- // already gone
- }
+ killTree(record.pid);
}
fs.writeFileSync(file(root, 'run.json'), `${JSON.stringify({ ...record, stopped: true }, null, 2)}\n`);
return { ...reviewStatus(root), state: 'stopped' };
diff --git a/lib/validate.mjs b/lib/validate.mjs
index 3431504..6476b89 100644
--- a/lib/validate.mjs
+++ b/lib/validate.mjs
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
+import { posix } from './paths.mjs';
import { readStamp, stampProblems } from './skill-meta.mjs';
import { parseFrontmatter, parseSkillFrontmatter, specFindings } from './skill-spec.mjs';
@@ -53,7 +54,7 @@ const usageFlags = (usage) => new Set([...(usage ?? '').matchAll(/--[a-z][a-z0-9
export function validateRepo(root, { commands = [], usages = {} } = {}) {
const findings = [];
- const add = (level, file, rule, message) => findings.push({ level, file: path.relative(root, file) || '.', rule, message });
+ const add = (level, file, rule, message) => findings.push({ level, file: posix(path.relative(root, file)) || '.', rule, message });
const known = new Set([...commands, 'help', 'version']);
const skillsRoot = path.join(root, 'skills');
const names = fs.existsSync(skillsRoot) ? fs.readdirSync(skillsRoot, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort() : [];
diff --git a/package.json b/package.json
index 62f17ab..6604053 100644
--- a/package.json
+++ b/package.json
@@ -15,7 +15,7 @@
"test": "node --test \"test/*.test.mjs\"",
"test:fast": "node scripts/test-fast.mjs",
"validate": "node bin/100x.mjs validate",
- "validate:spec": "for d in skills/*/; do npx -y skills-ref validate \"$d\" || exit 1; done",
+ "validate:spec": "node scripts/validate-spec.mjs",
"stamp": "node scripts/stamp-skills.mjs"
},
"repository": {
diff --git a/scripts/readme-stamp.mjs b/scripts/readme-stamp.mjs
index d84fe5d..9a9dd27 100644
--- a/scripts/readme-stamp.mjs
+++ b/scripts/readme-stamp.mjs
@@ -62,7 +62,9 @@ export function pageStamp() {
.replace(/<span>Finished [^<]*<\/span>/g, '')
.replace(/<p class="meta">Built [^<]*<\/p>/, '')
.split(pathToFileURL(dir).href).join('FIXTURE')
- .split(dir).join('FIXTURE'));
+ .split(dir).join('FIXTURE')
+ // On Windows the folder is written with backslashes below that point, and the stamp was made where they are slashes.
+ .replace(/FIXTURE[^\s"'<>&]*/g, (path) => path.replaceAll('\\', '/')));
}
export const pictureStamp = () => sha(fs.readFileSync(PICTURE));
diff --git a/scripts/validate-spec.mjs b/scripts/validate-spec.mjs
new file mode 100644
index 0000000..4442436
--- /dev/null
+++ b/scripts/validate-spec.mjs
@@ -0,0 +1,11 @@
+// The same check as `for d in skills/*/; do npx -y skills-ref validate "$d"; done`, written in node so it also runs where npm uses cmd.exe.
+import fs from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { runProgram } from '../lib/proc.mjs';
+
+const skills = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'skills');
+for (const entry of fs.readdirSync(skills, { withFileTypes: true }).filter((e) => e.isDirectory())) {
+ const result = runProgram('npx', ['-y', 'skills-ref', 'validate', path.join(skills, entry.name)], { stdio: 'inherit' });
+ if (result.status !== 0) process.exit(result.status ?? 1);
+}
diff --git a/test/apps.test.mjs b/test/apps.test.mjs
index aacf914..8bd2894 100644
--- a/test/apps.test.mjs
+++ b/test/apps.test.mjs
@@ -3,7 +3,7 @@ import { spawnSync } from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
-import { cli, ROOT, sandbox, write } from './helpers.mjs';
+import { cli, ROOT, sandbox, SH, write } from './helpers.mjs';
import { makeProject } from './projects.mjs';
const DOC = fs.readFileSync(path.join(ROOT, 'skills', '100x', 'references', 'apps.md'), 'utf8');
@@ -23,7 +23,7 @@ function stubApps(box) {
return { bin, args: () => fs.readFileSync(record, 'utf8').split('\0').slice(0, -1) };
}
-const run = (command, env, bin) => spawnSync('sh', ['-c', command], { env: { ...process.env, PATH: `${bin}${path.delimiter}${process.env.PATH}`, ...env }, encoding: 'utf8' });
+const run = (command, env, bin) => spawnSync(SH, ['-c', command], { env: { ...process.env, PATH: `${bin}${path.delimiter}${process.env.PATH}`, ...env }, encoding: 'utf8' });
test('the documented apps are the ones the test knows about', () => {
assert.deepEqual(Object.keys(TEMPLATES).sort(), ['claude', 'codex', 'cursor', 'gemini', 'opencode']);
diff --git a/test/browsers.test.mjs b/test/browsers.test.mjs
index cf1eac8..db1f858 100644
--- a/test/browsers.test.mjs
+++ b/test/browsers.test.mjs
@@ -4,6 +4,7 @@ import path from 'node:path';
import test from 'node:test';
import { chromiumBuilds, resolvePlaywright } from '../lib/playwright.mjs';
import { cli, sandbox } from './helpers.mjs';
+import { fakeBin } from './helpers.mjs';
test('browsers --check reports missing when nothing provides Playwright', () => {
const box = sandbox();
@@ -24,21 +25,22 @@ test('browsers --check reports available when Playwright resolves', { skip: reso
// A stand-in npm that writes a stand-in playwright, which prints a progress line for each 5 percent like the real one does.
function fakeInstallers(box, { exit = 0 } = {}) {
const bin = path.join(box.dir, 'fake-bin');
- fs.mkdirSync(bin, { recursive: true });
- fs.writeFileSync(path.join(bin, 'npm'), `#!/bin/sh
-prefix=""
-while [ $# -gt 0 ]; do if [ "$1" = "--prefix" ]; then prefix="$2"; fi; shift; done
-mkdir -p "$prefix/node_modules/.bin"
-cat > "$prefix/node_modules/.bin/playwright" <<'INNER'
-#!/bin/sh
-i=0
-while [ $i -lt 20 ]; do echo "|progress| $((i * 5))% of 160 MiB"; i=$((i + 1)); done
-echo "disk is full" >&2
-exit ${exit}
-INNER
-chmod +x "$prefix/node_modules/.bin/playwright"
+ // The stand-in npm writes the stand-in playwright, with a launcher for each shell, as the real one writes .bin entries.
+ const playwright = `let i = 0;
+while (i < 20) { console.log(\`|progress| \${i * 5}% of 160 MiB\`); i += 1; }
+console.error('disk is full');
+process.exit(${exit});
+`;
+ fakeBin(bin, 'npm', `import fs from 'node:fs';
+import path from 'node:path';
+const args = process.argv.slice(2);
+const prefix = args[args.indexOf('--prefix') + 1];
+const dir = path.join(prefix, 'node_modules', '.bin');
+fs.mkdirSync(dir, { recursive: true });
+fs.writeFileSync(path.join(dir, 'playwright.mjs'), ${JSON.stringify(playwright)});
+fs.writeFileSync(path.join(dir, 'playwright'), '#!/bin/sh\\nexec ' + JSON.stringify(process.execPath) + ' "$(dirname "$0")/playwright.mjs" "$@"\\n', { mode: 0o755 });
+fs.writeFileSync(path.join(dir, 'playwright.cmd'), '@echo off\\r\\n"' + process.execPath + '" "%~dp0playwright.mjs" %*\\r\\n');
`);
- fs.chmodSync(path.join(bin, 'npm'), 0o755);
return { ...box.env, X100_PLAYWRIGHT_FROM: '', PATH: `${bin}${path.delimiter}${process.env.PATH}` };
}
diff --git a/test/doctor.test.mjs b/test/doctor.test.mjs
index a10e82e..79b6fba 100644
--- a/test/doctor.test.mjs
+++ b/test/doctor.test.mjs
@@ -3,7 +3,7 @@ import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
import { helperCheck, judgeCheck, windowCheck, windowChecks } from '../lib/doctor.mjs';
-import { cli, ROOT, sandbox, write } from './helpers.mjs';
+import { cli, ROOT, sandbox, symlink, write } from './helpers.mjs';
test('doctor on an empty machine fails on the missing home and says how to fix it', () => {
const box = sandbox();
@@ -55,7 +55,7 @@ test('doctor warns when the linked companion skill is a different build than the
fs.mkdirSync(skills, { recursive: true });
const checkout = path.join(box.dir, 'checkout', 'unslop-text');
fs.cpSync(path.join(ROOT, 'vendor', 'unslop-text'), checkout, { recursive: true });
- fs.symlinkSync(checkout, path.join(skills, 'unslop-text'));
+ symlink(checkout, path.join(skills, 'unslop-text'));
const check = () => JSON.parse(cli(['doctor', '--json'], { cwd: box.project, env: box.env }).out).find((c) => c.name === 'skill unslop-text');
const same = check();
assert.equal(same.status, 'ok');
@@ -76,10 +76,10 @@ test('doctor warns about a link an older install made to a skill this repo dropp
const manifest = JSON.parse(fs.readFileSync(manifestFile, 'utf8'));
const gone = path.join(ROOT, 'vendor', 'dropped-companion');
const link = path.join(skills, 'dropped-companion');
- fs.symlinkSync(gone, link);
+ symlink(gone, link);
// Not stale: the owner's own link, to a folder outside this repo that is missing. It is not 100x's to judge.
const theirs = path.join(skills, 'my-own-skill');
- fs.symlinkSync(path.join(box.dir, 'nowhere'), theirs);
+ symlink(path.join(box.dir, 'nowhere'), theirs);
manifest.links.push({ path: link, target: gone }, { path: theirs, target: path.join(box.dir, 'nowhere') });
fs.writeFileSync(manifestFile, JSON.stringify(manifest));
const check = () => JSON.parse(cli(['doctor', '--json'], { cwd: box.project, env: box.env }).out).find((c) => c.name === 'old links');
diff --git a/test/eval-bakeoff-guards.test.mjs b/test/eval-bakeoff-guards.test.mjs
index 449d371..f64d42c 100644
--- a/test/eval-bakeoff-guards.test.mjs
+++ b/test/eval-bakeoff-guards.test.mjs
@@ -6,7 +6,7 @@ import test from 'node:test';
import { buildPairs, causeOf, leakPatterns, markRun, scanForLeaks } from '../lib/eval/blind.mjs';
import { ARMS, bakeoff, folder, judge, keyOf, makeReceipt, ON, OFF, ORDERS, recordModels, sealedOf, sees, split } from './bakeoff-helpers.mjs';
import { sign, signingKey } from '../lib/seal.mjs';
-import { cli, sandbox, write } from './helpers.mjs';
+import { cli, noFileLinks, sandbox, symlink, write } from './helpers.mjs';
const run = (box, ...args) => cli(['eval', 'bakeoff', ...args], { cwd: box.project, env: box.env });
// The exit code is part of what every score here returns: 2 when the verdict was withheld, 0 when one was printed.
@@ -79,12 +79,14 @@ test('the leak scan reads what a file holds, so a name in a file with no extensi
assert.deepEqual(scan('shot.png', Buffer.concat([Buffer.from([0x89, 0x50, 0x4e, 0x47, 0]), Buffer.from('skill-on')])), ['the binary file holds "skill-on"'], 'a longer name is still found in a picture');
fs.rmSync(probe, { recursive: true, force: true });
- fs.symlinkSync(path.join(box.dir, 'briefs.json'), path.join(arm, 'link'));
- const linked = attempt();
- assert.equal(linked.code, 1);
- assert.match(linked.err, /The scan could not read 1 file a judge would be given:\n arms\/\S+\/arm-\d\/link +it is a symbolic link.*\(in 2 judge folders\)/, 'one link in the arm folder, copied into both judge folders of its pair');
- assert.match(linked.err, /link {2}it is a symbolic link/);
- fs.rmSync(path.join(arm, 'link'));
+ if (!noFileLinks) {
+ symlink(path.join(box.dir, 'briefs.json'), path.join(arm, 'link'));
+ const linked = attempt();
+ assert.equal(linked.code, 1);
+ assert.match(linked.err, /The scan could not read 1 file a judge would be given:\n arms\/\S+\/arm-\d\/link +it is a symbolic link.*\(in 2 judge folders\)/, 'one link in the arm folder, copied into both judge folders of its pair');
+ assert.match(linked.err, /link {2}it is a symbolic link/);
+ fs.rmSync(path.join(arm, 'link'));
+ }
assert.ok(!fs.existsSync(path.join(dir, 'key.json')), 'no refusal seals anything');
const clean = attempt();
diff --git a/test/eval-bakeoff.test.mjs b/test/eval-bakeoff.test.mjs
index 29605f3..8ab3626 100644
--- a/test/eval-bakeoff.test.mjs
+++ b/test/eval-bakeoff.test.mjs
@@ -5,10 +5,15 @@ import os from 'node:os';
import { spawnSync } from 'node:child_process';
import path from 'node:path';
import test from 'node:test';
+import { fileURLToPath } from 'node:url';
import { markRun } from '../lib/eval/blind.mjs';
+import { runProgram } from '../lib/proc.mjs';
import { ARMS, bakeoff, folder, judge, keyOf, makeReceipt, ON, OFF, ORDERS, page, recordModels, sees, split } from './bakeoff-helpers.mjs';
import { browserSkip, cli, ROOT, sandbox, write } from './helpers.mjs';
+// A path as the commands and the agent text write it, with / on every system.
+const fwd = (p) => p.replaceAll('\\', '/');
+
const score = (box, dir) => cli(['eval', 'bakeoff', 'score', dir, '--json'], { cwd: box.project, env: box.env });
// Every score in this file also checks the exit code: 2 when the verdict was withheld, 0 when one was printed, whatever it said.
const scored = (box, dir) => {
@@ -34,9 +39,9 @@ test('init makes a task per brief and arm that differ only in the method note, a
assert.doesNotMatch(off, /## Method/, 'the control arm has no method paragraph, and its folder is called arm-1');
assert.match(off, /Use no skill from your list of installed skills, and open no SKILL\.md file except one that a Method section below names\./);
assert.match(on, /Use no skill from your list of installed skills, and open no SKILL\.md file except one that a Method section below names\./, 'both arms are told the same thing about skills');
- assert.match(off, /\/arms\/a\/arm-1\./);
- assert.match(on, /\/arms\/a\/arm-2\./);
- const strip = (text) => text.replace(/\n## Method[\s\S]*$/, '').replace(/\/arms\/a\/arm-[12]\./, '/arms/a/ARM.');
+ assert.match(fwd(off), /\/arms\/a\/arm-1\./);
+ assert.match(fwd(on), /\/arms\/a\/arm-2\./);
+ const strip = (text) => fwd(text).replace(/\n## Method[\s\S]*$/, '').replace(/\/arms\/a\/arm-[12]\./, '/arms/a/ARM.');
assert.equal(strip(on), strip(off), 'the same brief, the same minutes, the same deliverable');
assert.match(off, /You have 20 minutes/);
assert.ok(fs.existsSync(folder(dir, 'b', ON)));
@@ -152,7 +157,7 @@ test('pairs refuses while an arm folder has no index.html and names it', () => {
fs.rmSync(path.join(folder(dir, briefs[1].id, ON), 'index.html'));
const refused = cli(['eval', 'bakeoff', 'pairs', dir, '--no-capture'], { cwd: box.project, env: box.env });
assert.equal(refused.code, 1);
- assert.match(refused.err, /have no index\.html yet:\n.*brief-2\/arm-2\/index\.html/);
+ assert.match(fwd(refused.err), /have no index\.html yet:\n.*brief-2\/arm-2\/index\.html/);
box.cleanup();
});
@@ -408,7 +413,7 @@ test('status says what is built, what is judged and the next step', () => {
fs.rmSync(path.join(folder(dir, briefs[0].id, OFF), 'index.html'));
const status = () => cli(['eval', 'bakeoff', 'status', dir], { cwd: box.project, env: box.env }).out;
assert.match(status(), new RegExp(`brief-1/${OFF} +no index\\.html in arms/brief-1/arm-1`));
- const d = dir.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+ const d = fwd(dir).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
assert.match(status(), new RegExp(`Next: start brief-1/${OFF}\\. Run these in order\\. \`100x helper models\` lists the model id, level and size to fill in\\.\\n {2}100x eval bakeoff mark ${d} brief-1/${OFF} start\\n {2}100x helper run --model <model id> --effort <level> --context <size> --task-file ${d}/tasks/brief-1--${OFF}\\.md --cwd ${d}/arms/brief-1/arm-1 --minutes 20 --receipt ${d}/helper-receipts/brief-1--${OFF}\\.json --json\\n {2}100x eval bakeoff mark ${d} brief-1/${OFF} stop --receipt ${d}/helper-receipts/brief-1--${OFF}\\.json\\n`), 'the next step is three commands that run as they stand, with only the model left to fill in');
cli(['eval', 'bakeoff', 'mark', dir, `brief-1/${OFF}`, 'start', '--model', 'm'], { cwd: box.project, env: box.env });
assert.match(status(), new RegExp(`brief-1/${OFF} +no index\\.html in arms/brief-1/arm-1, running`));
@@ -430,7 +435,7 @@ test('a run that left no page stays in the count: pairs refuses until --blank-mi
const pairs = (...flags) => cli(['eval', 'bakeoff', 'pairs', dir, '--no-capture', ...flags], { cwd: box.project, env: box.env });
const refused = pairs();
assert.equal(refused.code, 1);
- assert.match(refused.err, /have no index\.html yet:\n.*brief-1\/arm-1\/index\.html/);
+ assert.match(fwd(refused.err), /have no index\.html yet:\n.*brief-1\/arm-1\/index\.html/);
assert.match(refused.err, /a run that is over and left no page failed, and it stays in the count/i);
assert.match(refused.err, /--blank-missing/);
assert.ok(!fs.existsSync(path.join(dir, 'key.json')), 'a refusal seals nothing');
@@ -493,7 +498,7 @@ test('status says which finished runs left no page and what to do about them', (
}
const out = cli(['eval', 'bakeoff', 'status', dir], { cwd: box.project, env: box.env }).out;
assert.match(out, /brief-1\/skill-off ended with no index\.html\. That is a failed run and it stays in the count\./);
- assert.match(out, new RegExp(`Next: 100x eval bakeoff pairs ${dir.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')} --blank-missing\\.`));
+ assert.match(out, new RegExp(`Next: 100x eval bakeoff pairs ${fwd(dir).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')} --blank-missing\\.`));
box.cleanup();
});
@@ -673,16 +678,17 @@ test('--pin copies the skill into the bake-off folder with a clean home and a co
const pinned = path.join(dir, 'pinned');
assert.ok(fs.existsSync(path.join(pinned, 'skills', '100x-mockup', 'SKILL.md')));
assert.deepEqual(fs.readdirSync(path.join(pinned, 'home')), [], 'a clean home');
- const ran = spawnSync(path.join(pinned, '100x'), ['doctor'], { encoding: 'utf8', env: { ...process.env, HOME: box.env.HOME, X100_HOME: '/nonexistent-home' }, cwd: box.project });
- const quoted = pinned.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
- assert.match(ran.stdout, new RegExp(`home +${quoted}/home`), 'the command uses the clean home whatever the caller has set');
+ const ran = runProgram(path.join(pinned, process.platform === 'win32' ? '100x.cmd' : '100x'), ['doctor'], { encoding: 'utf8', env: { ...process.env, HOME: box.env.HOME, X100_HOME: '/nonexistent-home' }, cwd: box.project });
+ const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+ const quoted = escape(fwd(pinned));
+ assert.match(ran.stdout, new RegExp(`home +${escape(path.join(pinned, 'home'))}`), 'the command uses the clean home whatever the caller has set');
const on = fs.readFileSync(path.join(dir, 'tasks', `lighthouse-idle--${ON}.md`), 'utf8');
const off = fs.readFileSync(path.join(dir, 'tasks', `lighthouse-idle--${OFF}.md`), 'utf8');
assert.match(on, new RegExp(`## Method\\nFollow the skill in ${quoted}/skills/100x-mockup/SKILL\\.md\\. Its 100x command is ${quoted}/100x`));
assert.doesNotMatch(off, /pinned|100x-mockup|## Method/);
assert.match(made.out, /The skill is pinned in .*pinned/);
if (config.pinned.snapshot) assert.match(made.out, /from commit [0-9a-f]{12}/);
- assert.match(made.out, /Protocol: .*evals\/PROTOCOL\.md\. Read it before the first arm starts\./);
+ assert.match(made.out, /Protocol: .*evals[\\/]PROTOCOL\.md\. Read it before the first arm starts\./);
box.cleanup();
});
@@ -702,7 +708,7 @@ test('the run order is a seeded shuffle of every brief and arm, the same for the
assert.deepEqual(a.config.order, b.config.order, 'the same seed, the same order');
assert.notDeepEqual(a.config.order, c.config.order);
assert.match(a.result.out, /Run the arms one at a time in this order: /);
- const protocolText = fs.readFileSync(path.join(path.dirname(new URL(import.meta.url).pathname), '..', 'evals', 'PROTOCOL.md'));
+ const protocolText = fs.readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'evals', 'PROTOCOL.md'));
assert.equal(a.config.protocol, crypto.createHash('sha256').update(protocolText).digest('hex'), 'init records the hash of the protocol text it ran under');
assert.match(make('d', '--first', '0').result.err, /--first takes a whole number from 1 to 20\. Got "0"\./);
assert.match(make('e', '--first', '99').result.err, /from 1 to 20\. Got "99"\./);
@@ -711,7 +717,7 @@ test('the run order is a seeded shuffle of every brief and arm, the same for the
});
test('evals/briefs.json holds 20 briefs with the three pilot briefs first, and none names a skill', () => {
- const file = JSON.parse(fs.readFileSync(path.join(path.dirname(new URL(import.meta.url).pathname), '..', 'evals', 'briefs.json'), 'utf8'));
+ const file = JSON.parse(fs.readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'evals', 'briefs.json'), 'utf8'));
assert.equal(file.briefs.length, 20);
assert.deepEqual(file.briefs.slice(0, 3).map((b) => b.id), ['lighthouse-idle', 'coffee-dashboard', 'dog-walking-lisbon']);
assert.equal(new Set(file.briefs.map((b) => b.id)).size, 20);
diff --git a/test/eval-screens.test.mjs b/test/eval-screens.test.mjs
index f61001b..a1ed714 100644
--- a/test/eval-screens.test.mjs
+++ b/test/eval-screens.test.mjs
@@ -11,6 +11,9 @@ import { duration, plural, wrap } from '../lib/eval/words.mjs';
import { bakeoff, folder, judge, ON, ORDERS, OFF, recordModels, sees } from './bakeoff-helpers.mjs';
import { cli, ROOT, sandbox } from './helpers.mjs';
+// A path as the commands write it, with / on every system.
+const fwd = (p) => p.replaceAll('\\', '/');
+
// What a person sees in the terminal and in the help. The numbers are tested elsewhere. These tests read the words.
const ev = (box, ...args) => cli(['eval', ...args], { cwd: box.project, env: box.env });
// A path is as long as the folder it names, so the lines that carry one are left out.
@@ -27,7 +30,7 @@ test('score prints a screen for a person, not the report file: counts, a verdict
assert.match(ahead.out, /\nVerdict: skill-on is ahead\. 6 decisive pairs, exact two-sided sign test p = 0\.03125\.\n/);
assert.match(ahead.out, /\nControls: the judge passed both\.\n/);
assert.match(ahead.out, /\nMedian time: skill-off 10 min, skill-on 10 min\.\n/);
- assert.match(ahead.out, new RegExp(`\\nThe whole report, with the interval, the models and the limits: ${path.join(dir, 'report.md').replaceAll('.', '\\.')}\\n`));
+ assert.match(ahead.out, new RegExp(`\\nThe whole report, with the interval, the models and the limits: ${path.join(dir, 'report.md').replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\n`));
assert.doesNotMatch(ahead.out, /^\||^#|\*\*/m, 'no markdown source on a terminal');
assert.ok(widest(ahead.out, dir) <= 110, `no line wider than a terminal can show, got ${widest(ahead.out, dir)}`);
assert.match(fs.readFileSync(path.join(dir, 'report.md'), 'utf8'), /\| pair \| brief \| result \|/, 'the file keeps the table');
@@ -234,7 +237,7 @@ test('status prints the next step as commands that run as they stand, lists ever
const block = waiting.slice(waiting.indexOf('Waiting:'), waiting.indexOf('For pair-'));
for (let n = 1; n <= 4; n += 1) for (const order of ORDERS) assert.equal(block.split(`pair-0${n}-${order}`).length, 2, `pair-0${n}-${order} is listed once`);
assert.ok(!/ and \d+ more/.test(block), 'a list that says "and 12 more" cannot be copied');
- assert.match(waiting, new RegExp(`\\nFor pair-0\\d-o\\d, then for each of the others:\\n {2}100x helper run --model <model id> --effort <level> --context <size> --cwd ${built.dir.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}/judge/pair-0\\d-o\\d --minutes 30 --receipt \\S+/helper-receipts/pair-0\\d-o\\d\\.json --json --task "Open this folder and follow ask\\.md in it\\."\\n {2}100x eval bakeoff mark \\S+ judge/pair-0\\d-o\\d stop --receipt \\S+\\.json\\n?$`), 'the judge command is whole');
+ assert.match(waiting, new RegExp(`\\nFor pair-0\\d-o\\d, then for each of the others:\\n {2}100x helper run --model <model id> --effort <level> --context <size> --cwd ${fwd(built.dir).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}/judge/pair-0\\d-o\\d --minutes 30 --receipt \\S+/helper-receipts/pair-0\\d-o\\d\\.json --json --task "Open this folder and follow ask\\.md in it\\."\\n {2}100x eval bakeoff mark \\S+ judge/pair-0\\d-o\\d stop --receipt \\S+\\.json\\n?$`), 'the judge command is whole');
const spaced = path.join(box.dir, 'with space');
const odd = bakeoff(box, { n: 1, pairs: false, where: spaced });
diff --git a/test/finish.test.mjs b/test/finish.test.mjs
index e3c19cb..f688135 100644
--- a/test/finish.test.mjs
+++ b/test/finish.test.mjs
@@ -52,7 +52,7 @@ test('registry list reads like the gallery, the date and the verdict first, and
assert.equal(finish(box).code, 0);
const [entry] = JSON.parse(cli(['registry', 'list', '--json'], { env: box.env }).out);
const line = cli(['registry', 'list'], { env: box.env }).out.trim();
- assert.match(line, /^[A-Z][a-z]{2} \d{1,2}, \d{1,2}:\d{2} [AP]M +ship +Glow +\//, line);
+ assert.match(line, /^[A-Z][a-z]{2} \d{1,2}, \d{1,2}:\d{2} [AP]M +ship +Glow +(?:\/|[A-Za-z]:\\)/, line);
assert.ok(line.endsWith(` ${entry.id}`), 'the id is the last column');
assert.doesNotMatch(line, /\d{4}-\d{2}-\d{2}T/, 'no ISO timestamp');
assert.equal(cli(['registry', 'remove', line.split(/\s+/).at(-1)], { env: box.env }).out.trim(), 'removed 1 run');
diff --git a/test/helper.test.mjs b/test/helper.test.mjs
index 5c58142..4c8625b 100644
--- a/test/helper.test.mjs
+++ b/test/helper.test.mjs
@@ -6,7 +6,7 @@ import test from 'node:test';
import { spawnSync } from 'node:child_process';
import { readReceipt, receiptBacks, receiptParams, receiptState } from '../lib/receipt.mjs';
import { sealFile, sealState } from '../lib/seal.mjs';
-import { BIN, cli, ROOT, sandbox, write } from './helpers.mjs';
+import { BIN, cli, ROOT, sandbox, SH, write } from './helpers.mjs';
// A stand-in for @cursor/sdk. It keeps a catalog like the account's own, can be logged out, can report another model than the one
// asked for, can fail, and can hang until it is cancelled. Every call it gets is written to a file the test reads back.
@@ -369,7 +369,7 @@ test('the command line in apps.md runs as written with the variables 100x review
const bin = path.join(box.dir, 'bin');
write(path.join(bin, '100x'), `#!/bin/sh\nexec ${JSON.stringify(process.execPath)} ${JSON.stringify(BIN)} "$@"\n`);
fs.chmodSync(path.join(bin, '100x'), 0o755);
- const run = (extra) => spawnSync('sh', ['-c', line], { cwd: box.project, encoding: 'utf8', env: { ...process.env, ...env, PATH: `${bin}${path.delimiter}${process.env.PATH}`, X100_TASK: 'Judge it. Write findings.md.', ...extra } });
+ const run = (extra) => spawnSync(SH, ['-c', line], { cwd: box.project, encoding: 'utf8', env: { ...process.env, ...env, PATH: `${bin}${path.delimiter}${process.env.PATH}`, X100_TASK: 'Judge it. Write findings.md.', ...extra } });
const result = run({ X100_MODEL: 'muse-wonder-1.0', X100_EFFORT: 'max', X100_OPT_CONTEXTWINDOW: '300k' });
assert.equal(result.status, 0, result.stderr + result.stdout);
assert.match(result.stdout, /^working\nhelper finished\./);
diff --git a/test/helpers.mjs b/test/helpers.mjs
index 09f3e30..315770d 100644
--- a/test/helpers.mjs
+++ b/test/helpers.mjs
@@ -3,6 +3,8 @@ import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
+import { makeLink } from '../lib/links.mjs';
+import { findSh } from '../lib/proc.mjs';
import { browserCacheDir, resolvePlaywright } from '../lib/playwright.mjs';
const REAL_BROWSER_CACHE = browserCacheDir();
@@ -41,6 +43,43 @@ export function cli(args, { cwd = ROOT, env = {} } = {}) {
return { code: result.status, out: result.stdout, err: result.stderr };
}
+// A link to a folder, or to a folder that is gone. Where symlinks are not allowed (Windows without Developer Mode) it is a junction.
+export const symlink = (target, linkPath) => makeLink(target, linkPath);
+
+// A link to a file has no such fallback, so a test that needs one carries this as its skip reason.
+export const noFileLinks = (() => {
+ if (process.env.X100_NO_SYMLINK) return 'X100_NO_SYMLINK is set, so no symlink is made';
+ const dir = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), '100x-link-'));
+ try {
+ fs.writeFileSync(path.join(dir, 'a'), '');
+ fs.symlinkSync(path.join(dir, 'a'), path.join(dir, 'b'), 'file');
+ return false;
+ } catch (error) {
+ return error.code === 'EPERM' ? 'a link to a file needs Developer Mode or an administrator on Windows' : false;
+ } finally {
+ fs.rmSync(dir, { recursive: true, force: true });
+ }
+})();
+
+// The POSIX shell the commands in the docs are written for. Windows has one when Git for Windows is installed.
+export const SH = findSh();
+// bash.exe sits beside sh.exe in Git for Windows. A bare "bash" on Windows can be the one that starts WSL.
+export const BASH = process.platform === 'win32' ? (SH ? path.join(path.dirname(SH), 'bash.exe') : 'bash') : 'bash';
+
+// A stand-in program that runs by its name from a PATH folder: a node script, and the launchers that start it. Returns the path that starts it
+// on this system, a .cmd on Windows (where the same folder also gets a script for sh, which looks a program up without an extension).
+export function fakeBin(dir, name, source) {
+ fs.mkdirSync(dir, { recursive: true });
+ const script = path.join(dir, `${name}.mjs`);
+ fs.writeFileSync(script, source);
+ const sh = path.join(dir, name);
+ fs.writeFileSync(sh, `#!/bin/sh\nexec ${JSON.stringify(process.execPath)} ${JSON.stringify(script)} "$@"\n`, { mode: 0o755 });
+ if (process.platform !== 'win32') return sh;
+ const cmd = path.join(dir, `${name}.cmd`);
+ fs.writeFileSync(cmd, `@echo off\r\n"${process.execPath}" "${script}" %*\r\n`);
+ return cmd;
+}
+
export function write(file, text) {
fs.mkdirSync(path.dirname(file), { recursive: true });
fs.writeFileSync(file, text);
diff --git a/test/init.test.mjs b/test/init.test.mjs
index 1f6b78d..49fda9e 100644
--- a/test/init.test.mjs
+++ b/test/init.test.mjs
@@ -4,7 +4,7 @@ import { createHash } from 'node:crypto';
import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
-import { cli, sandbox, write } from './helpers.mjs';
+import { cli, sandbox, symlink, write } from './helpers.mjs';
test('init scaffolds, creates a repository, hides .100x from git and detects the stack', () => {
const box = sandbox();
@@ -35,7 +35,7 @@ test('the project file has a place for the pre-flight the skill says to save', (
test('the global folder is never taken for a project, even when the home folder is reached through a symlink', () => {
const box = sandbox();
const link = path.join(box.dir, 'home-link');
- fs.symlinkSync(box.home, link);
+ symlink(box.home, link);
fs.mkdirSync(path.join(box.home, '.100x'), { recursive: true });
const env = { ...box.env, HOME: link, X100_HOME: path.join(link, '.100x') };
for (const [args, refusal] of [[['log', 'start', 'x', 'y'], /No \.100x folder found here/], [['status'], /No run in this folder/]]) {
diff --git a/test/install.test.mjs b/test/install.test.mjs
index b51e160..59b8575 100644
--- a/test/install.test.mjs
+++ b/test/install.test.mjs
@@ -3,7 +3,10 @@ import { spawnSync } from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
-import { cli, ROOT, sandbox, write } from './helpers.mjs';
+import { runProgram } from '../lib/proc.mjs';
+import { BASH, cli, noFileLinks, ROOT, sandbox, symlink, write } from './helpers.mjs';
+
+const WINDOWS = process.platform === 'win32';
// Every skill folder of this repository: 100x and each of its modes. The install has to link all of them, or a mode is not there to call.
const SKILLS = fs.readdirSync(path.join(ROOT, 'skills'), { withFileTypes: true }).filter((d) => d.isDirectory() && fs.existsSync(path.join(ROOT, 'skills', d.name, 'SKILL.md'))).map((d) => d.name).sort();
@@ -62,11 +65,17 @@ test('a fresh install links every skill, the CLI and the PATH entry, and the lin
const result = install(box);
assert.equal(result.code, 0, result.out + result.err);
for (const name of SKILLS) assert.equal(fs.realpathSync(path.join(where.skills, name)), fs.realpathSync(path.join(ROOT, 'skills', name)));
- assert.equal(fs.realpathSync(path.join(where.bin, '100x')), fs.realpathSync(path.join(ROOT, 'bin', '100x.mjs')));
+ // Windows runs a program by its file name, so the CLI is a pair of launchers there, 100x.cmd and a script named 100x for Git Bash.
+ if (WINDOWS) {
+ for (const dir of [where.bin, path.join(where.global, 'bin')]) {
+ assert.match(fs.readFileSync(path.join(dir, '100x.cmd'), 'utf8'), /^@echo off\r\nnode ".*bin\\100x\.mjs" %\*\r\n$/);
+ assert.match(fs.readFileSync(path.join(dir, '100x'), 'utf8'), /^#!\/bin\/sh\nexec node ".*\/bin\/100x\.mjs" "\$@"\n$/);
+ }
+ } else assert.equal(fs.realpathSync(path.join(where.bin, '100x')), fs.realpathSync(path.join(ROOT, 'bin', '100x.mjs')));
assert.equal(fs.readFileSync(path.join(where.global, 'repo'), 'utf8').trim(), fs.realpathSync.native(ROOT));
assert.equal(fs.readFileSync(path.join(where.global, 'config.json'), 'utf8').trim(), '{}');
assert.match(fs.readFileSync(path.join(where.global, 'profile.md'), 'utf8'), /Stage 0 reads it/);
- const version = spawnSync(path.join(where.bin, '100x'), ['version'], { encoding: 'utf8', env: { ...process.env, ...box.env } });
+ const version = runProgram(path.join(where.bin, WINDOWS ? '100x.cmd' : '100x'), ['version'], { encoding: 'utf8', env: { ...process.env, ...box.env } });
assert.equal(version.status, 0, version.stderr);
assert.ok(version.stdout.trim().startsWith(JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8')).version), 'the linked CLI prints the package number first, then the commit it is at');
box.cleanup();
@@ -125,7 +134,8 @@ test('a real folder in the way is never replaced, even with --force, and the res
assert.equal(result.code, 1);
assert.match(result.out, /blocked/);
assert.equal(fs.readFileSync(path.join(where.skills, '100x', 'notes.txt'), 'utf8'), 'mine');
- assert.ok(fs.lstatSync(path.join(where.global, 'bin', '100x')).isSymbolicLink());
+ if (WINDOWS) assert.ok(fs.existsSync(path.join(where.global, 'bin', '100x.cmd')));
+ else assert.ok(fs.lstatSync(path.join(where.global, 'bin', '100x')).isSymbolicLink());
box.cleanup();
});
@@ -135,7 +145,7 @@ test('a link that points elsewhere is a conflict until --force, and uninstall re
const other = path.join(box.dir, 'other-setup');
write(path.join(other, 'SKILL.md'), 'other');
fs.mkdirSync(where.skills, { recursive: true });
- fs.symlinkSync(other, path.join(where.skills, '100x'));
+ symlink(other, path.join(where.skills, '100x'));
const refused = install(box);
assert.equal(refused.code, 1);
@@ -225,7 +235,7 @@ test('a link to your own copy of unslop-text is kept, never recorded, and --forc
const where = layout(box);
const mine = fakeCheckout(box, 'unslop-text');
fs.mkdirSync(where.skills, { recursive: true });
- fs.symlinkSync(path.join(mine, 'skills', 'unslop-text'), path.join(where.skills, 'unslop-text'));
+ symlink(path.join(mine, 'skills', 'unslop-text'), path.join(where.skills, 'unslop-text'));
const kept = cli(['install'], { env: box.env });
assert.equal(kept.code, 0, kept.out + kept.err);
assert.match(kept.out, /kept\s+.*unslop-text\s+points to .* a copy of unslop-text you chose/);
@@ -247,7 +257,7 @@ test('an install from before unslop-design left 100x loses the link to the remov
// What an older 100x left behind: a link to vendor/unslop-design, which replaced the one the owner had made, recorded in install.json.
const gone = path.join(ROOT, 'vendor', 'unslop-design');
const link = path.join(where.skills, 'unslop-design');
- fs.symlinkSync(gone, link);
+ symlink(gone, link);
const manifestFile = path.join(where.global, 'install.json');
const manifest = JSON.parse(fs.readFileSync(manifestFile, 'utf8'));
manifest.links.push({ path: link, target: gone, replaced: own });
@@ -268,7 +278,7 @@ test('an old install record that lists the removed link twice is cleaned up once
assert.equal(cli(['install'], { env: box.env }).code, 0);
const gone = path.join(ROOT, 'vendor', 'unslop-design');
const link = path.join(where.skills, 'unslop-design');
- fs.symlinkSync(gone, link);
+ symlink(gone, link);
const manifestFile = path.join(where.global, 'install.json');
const manifest = JSON.parse(fs.readFileSync(manifestFile, 'utf8'));
manifest.links.push({ path: link, target: gone }, { path: link, target: gone });
@@ -288,7 +298,7 @@ test('an old install record that lists the removed link twice gives the owner li
assert.equal(cli(['install'], { env: box.env }).code, 0);
const gone = path.join(ROOT, 'vendor', 'unslop-design');
const link = path.join(where.skills, 'unslop-design');
- fs.symlinkSync(gone, link);
+ symlink(gone, link);
const manifestFile = path.join(where.global, 'install.json');
const manifest = JSON.parse(fs.readFileSync(manifestFile, 'utf8'));
const plain = { path: link, target: gone };
@@ -315,23 +325,23 @@ test('--no-bin skips the PATH entry and prints a hint when the folder is not on
test('scripts/install.sh forwards to the CLI, including --help and --dry-run', () => {
const box = sandbox();
const script = path.join(ROOT, 'scripts', 'install.sh');
- const help = spawnSync('bash', [script, '--help'], { encoding: 'utf8', env: { ...process.env, ...box.env } });
+ const help = spawnSync(BASH, [script.replaceAll('\\', '/'), '--help'], { encoding: 'utf8', env: { ...process.env, ...box.env } });
assert.equal(help.status, 0, help.stderr);
assert.match(help.stdout, /--uninstall/);
- const dry = spawnSync('bash', [script, '--no-unslop', '--dry-run'], { encoding: 'utf8', env: { ...process.env, ...box.env } });
+ const dry = spawnSync(BASH, [script.replaceAll('\\', '/'), '--no-unslop', '--dry-run'], { encoding: 'utf8', env: { ...process.env, ...box.env } });
assert.equal(dry.status, 0, dry.stderr);
assert.match(dry.stdout, /Dry run/);
assert.deepEqual(entries(box.home), []);
box.cleanup();
});
-test('a symlink planted where install writes a small file is left alone, and so is what it points at', () => {
+test('a symlink planted where install writes a small file is left alone, and so is what it points at', { skip: noFileLinks }, () => {
const box = sandbox();
const where = layout(box);
const precious = path.join(box.dir, 'precious.txt');
fs.writeFileSync(precious, 'PRECIOUS DO NOT OVERWRITE\n');
fs.mkdirSync(where.global, { recursive: true });
- fs.symlinkSync(precious, path.join(where.global, 'repo'));
+ symlink(precious, path.join(where.global, 'repo'));
const result = cli(['install', '--no-unslop', '--json'], { env: box.env });
assert.equal(result.code, 0, result.out + result.err);
assert.equal(fs.readFileSync(precious, 'utf8'), 'PRECIOUS DO NOT OVERWRITE\n');
@@ -342,13 +352,13 @@ test('a symlink planted where install writes a small file is left alone, and so
box.cleanup();
});
-test('an install record that is a symlink stops the install before anything changes', () => {
+test('an install record that is a symlink stops the install before anything changes', { skip: noFileLinks }, () => {
const box = sandbox();
const where = layout(box);
const precious = path.join(box.dir, 'precious.json');
fs.writeFileSync(precious, '{"mine":true}\n');
fs.mkdirSync(where.global, { recursive: true });
- fs.symlinkSync(precious, path.join(where.global, 'install.json'));
+ symlink(precious, path.join(where.global, 'install.json'));
const result = cli(['install', '--no-unslop'], { env: box.env });
assert.equal(result.code, 1);
assert.match(result.out + result.err, /install\.json.*is a symlink/);
@@ -381,9 +391,9 @@ test('install takes out a link whose skill was renamed away, and leaves other li
install(box);
const stale = path.join(where.skills, '100x-old-name');
const gone = path.join(ROOT, 'skills', '100x-old-name');
- fs.symlinkSync(gone, stale);
+ symlink(gone, stale);
const kept = path.join(where.skills, 'kept-link');
- fs.symlinkSync(path.join(ROOT, 'skills', '100x'), kept);
+ symlink(path.join(ROOT, 'skills', '100x'), kept);
const manifestFile = path.join(where.global, 'install.json');
const manifest = JSON.parse(fs.readFileSync(manifestFile, 'utf8'));
manifest.links.push({ path: stale, target: gone }, { path: kept, target: path.join(ROOT, 'skills', '100x') });
@@ -402,9 +412,9 @@ test('install takes out a link whose skill was renamed away, and leaves other li
install(box);
const stale = path.join(where.skills, '100x-old-name');
const gone = path.join(ROOT, 'skills', '100x-old-name');
- fs.symlinkSync(gone, stale);
+ symlink(gone, stale);
const kept = path.join(where.skills, 'kept-link');
- fs.symlinkSync(path.join(ROOT, 'skills', '100x'), kept);
+ symlink(path.join(ROOT, 'skills', '100x'), kept);
const manifestFile = path.join(where.global, 'install.json');
const manifest = JSON.parse(fs.readFileSync(manifestFile, 'utf8'));
manifest.links.push({ path: stale, target: gone }, { path: kept, target: path.join(ROOT, 'skills', '100x') });
diff --git a/test/morning-stop.test.mjs b/test/morning-stop.test.mjs
index 778e419..a374411 100644
--- a/test/morning-stop.test.mjs
+++ b/test/morning-stop.test.mjs
@@ -25,7 +25,7 @@ const until = async (check, ms = 4000) => {
test('--stop never signals a process that only happens to own the pid in server.json', async () => {
const box = sandbox();
- const bystander = spawn('sleep', ['60'], { stdio: 'ignore' });
+ const bystander = spawn(process.execPath, ['-e', 'setTimeout(() => {}, 60000)'], { stdio: 'ignore' });
try {
const dir = path.join(box.env.X100_HOME, 'morning');
fs.mkdirSync(dir, { recursive: true });
diff --git a/test/morning.test.mjs b/test/morning.test.mjs
index d26d164..841ffa3 100644
--- a/test/morning.test.mjs
+++ b/test/morning.test.mjs
@@ -6,7 +6,7 @@ import test from 'node:test';
import { pathToFileURL } from 'node:url';
import { freePort, listening, startServer } from '../lib/morning-server.mjs';
import { resolvePlaywright } from '../lib/playwright.mjs';
-import { browserSkip as skip, cli, sandbox } from './helpers.mjs';
+import { browserSkip as skip, cli, noFileLinks, sandbox, symlink } from './helpers.mjs';
import { gradientPng } from './png.mjs';
import { FINDINGS, makeProject, PNG, runJson } from './projects.mjs';
@@ -834,8 +834,10 @@ test('the gallery server checks token, host and header, and serves only the run
assert.deepEqual(hero.body, PNG);
fs.writeFileSync(path.join(root, 'secret.txt'), 'nope');
assert.ok([403, 404].includes((await request(base, `file/${id}/..%2Fsecret.txt`)).status), 'no path traversal out of .100x');
- fs.symlinkSync(path.join(root, 'secret.txt'), path.join(root, '.100x', 'link.txt'));
- assert.equal((await request(base, `file/${id}/link.txt`)).status, 403, 'no symlink escape');
+ if (!noFileLinks) {
+ symlink(path.join(root, 'secret.txt'), path.join(root, '.100x', 'link.txt'));
+ assert.equal((await request(base, `file/${id}/link.txt`)).status, 403, 'no symlink escape');
+ }
} finally {
await gallery.close();
process.env.X100_HOME = previous ?? '';
diff --git a/test/prompt.test.mjs b/test/prompt.test.mjs
index 5621853..f87c947 100644
--- a/test/prompt.test.mjs
+++ b/test/prompt.test.mjs
@@ -417,8 +417,10 @@ test('show leaves the asks as they were written, except for the box and the clos
test('show says where the other chat works, adds the owner\'s words on request, and writes a file', () => {
const box = promptBox(examples[1]);
+ // The folder is written as the system writes it: /work/dead-exports on macOS and Linux, C:\work\dead-exports on Windows.
+ const folder = path.resolve('/work/dead-exports');
const where = run(box, 'prompt', 'show', '--where', '/work/dead-exports', '--with-brief');
- assert.match(where.out, /\nWHERE\nWork in \/work\/dead-exports\. Commit locally and often\./, 'nothing about this folder or its git state');
+ assert.ok(where.out.includes(`\nWHERE\nWork in ${folder}. Commit locally and often.`), 'nothing about this folder or its git state');
assert.match(where.out, /\nTHE OWNER'S WORDS\na cli that finds dead exports/);
const file = path.join(box.dir, 'out', 'prompt.txt');
const wrote = run(box, 'prompt', 'show', '--out', file);
@@ -488,7 +490,7 @@ test('show lists the number phrases that would change a run after the skill name
test('show lists a number phrase in the WHERE line it wrote, and no mode word', () => {
const box = promptBox(FULL);
const { out, err } = run(box, 'prompt', 'show', '--where', '/work/mockup-overnight-3 versions');
- const line = out.split('\n').findIndex((one) => one.startsWith('Work in /work/mockup-overnight-3 versions')) + 1;
+ const line = out.split('\n').findIndex((one) => one.startsWith(`Work in ${path.resolve('/work/mockup-overnight-3 versions')}`)) + 1;
assert.match(err, new RegExp(`Line ${line} has "3 versions"\\.`));
assert.doesNotMatch(err, /has "(mockup|overnight)"/);
box.cleanup();
diff --git a/test/proof.test.mjs b/test/proof.test.mjs
index a08bfe0..0e67685 100644
--- a/test/proof.test.mjs
+++ b/test/proof.test.mjs
@@ -3,12 +3,14 @@ import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import test from 'node:test';
-import { pathToFileURL } from 'node:url';
+import { fileURLToPath, pathToFileURL } from 'node:url';
import { targetIsOurs } from '../lib/project.mjs';
-import { cli, sandbox } from './helpers.mjs';
+import { cli, noFileLinks, sandbox, symlink } from './helpers.mjs';
import { blankPng, encodePng } from './png.mjs';
import { CHECK_OUTPUT, makeProject, matrixJson, PROJECT_MD, runJson, seal } from './projects.mjs';
+// A file that exists and is not in any project, as /etc/hosts is on Linux and macOS.
+const OUTSIDE = fileURLToPath(import.meta.url);
const finish = (box, ...args) => cli(['finish', ...args], { cwd: box.project, env: box.env });
const check = (kind, status, summary) => ({ kind, status, summary });
@@ -32,7 +34,7 @@ function refused(name, setup, pattern) {
}
refused('a hero that is not an image', { hero: Buffer.from('not a png at all\n'.repeat(4)) }, /hero .* is not a PNG, JPEG, WebP or GIF image/);
-refused('a hero outside the project folder', { run: runJson({ hero: '/etc/hosts' }) }, /hero \/etc\/hosts is outside the project folder/);
+refused('a hero outside the project folder', { run: runJson({ hero: OUTSIDE }) }, new RegExp(`hero ${OUTSIDE.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')} is outside the project folder`));
refused('a blank hero, the sign the page was not up', { hero: blankPng() }, /looks blank/);
refused('a hero that is only a few pixels', { hero: encodePng(8, 8, () => [0, 0, 0, 255]) }, /is only 8 by 8 pixels/);
refused('a project with no resolution matrix and no reason', { matrix: false }, /no resolution matrix\. Run `100x shots/);
@@ -47,7 +49,7 @@ test('screens of a page on this machine or this network count as the project\'s
fs.rmSync(root, { recursive: true, force: true });
});
-refused('a screen run of a file outside the project', { matrix: { target: 'file:///etc/hosts' } }, /the final matrix looked at file:\/\/\/etc\/hosts, which is not this project/);
+refused('a screen run of a file outside the project', { matrix: { target: pathToFileURL(OUTSIDE).href } }, new RegExp(`the final matrix looked at ${pathToFileURL(OUTSIDE).href.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}, which is not this project`));
refused('a ship with broken findings in the final matrix', { matrix: { broken: 3 } }, /verdict is ship but the final matrix has 3 broken findings/);
refused('a closed ask whose evidence points at nothing', { projectMd: PROJECT_MD.replace('(evidence: shots/final)', '(evidence: wherever)') }, /ask "a thing that glows \(evidence: wherever\)" has evidence that points at nothing a reader can check\. Name a commit, a file, a command in backticks or a number/);
refused('a closed ask with no evidence', { projectMd: PROJECT_MD.replace(' (evidence: shots/final)', '') }, /ask "a thing that glows" is closed without evidence/);
@@ -110,10 +112,10 @@ refused('three checks, because an app has one or two', {
refused('the same check listed twice', { run: runJson({ mustNotBreak: [check('numbers', 'pass', '12 of 12 cases'), check('numbers', 'pass', '12 of 12 cases')] }), checkFiles: { numbers: CHECK_OUTPUT } }, /The must-not-break check "numbers" is listed twice/);
refused('a must-not-break check kind that is not one word', { run: runJson({ mustNotBreak: check('Money Math!', 'pass', '12 of 12 cases') }) }, /kind must be one lowercase word/);
-test('a hero that is a link out of the project is followed and refused', () => {
+test('a hero that is a link out of the project is followed and refused', { skip: noFileLinks }, () => {
const box = sandbox();
makeProject(box, { run: runJson({ hero: '.100x/shots/final/link.png' }) });
- fs.symlinkSync('/etc/hosts', path.join(box.project, '.100x', 'shots', 'final', 'link.png'));
+ symlink(OUTSIDE, path.join(box.project, '.100x', 'shots', 'final', 'link.png'));
const result = finish(box);
assert.equal(result.code, 1);
assert.match(result.err, /is outside the project folder/);
diff --git a/test/review-run.test.mjs b/test/review-run.test.mjs
index a06e137..8dbe3cf 100644
--- a/test/review-run.test.mjs
+++ b/test/review-run.test.mjs
@@ -3,6 +3,7 @@ import fs from 'node:fs';
import path from 'node:path';
import { spawn } from 'node:child_process';
import test from 'node:test';
+import { killTree } from '../lib/proc.mjs';
import { cli, sandbox, write } from './helpers.mjs';
import { makeProject } from './projects.mjs';
@@ -103,7 +104,7 @@ test('a pid that another process reused is not the judge, is not reported as run
makeProject(box);
withCommand(box, 'sleep 60');
// An unrelated process in a group of its own stands for whatever took the pid after a reboot.
- const other = spawn('sleep', ['60'], { detached: true, stdio: 'ignore' });
+ const other = spawn(process.execPath, ['-e', 'setTimeout(() => {}, 60000)'], { detached: true, stdio: 'ignore' });
other.unref();
try {
const dir = path.join(box.project, '.100x', 'review');
@@ -114,11 +115,7 @@ test('a pid that another process reused is not the judge, is not reported as run
json(box, ['review-run', '--stop', '--json']);
process.kill(other.pid, 0);
} finally {
- try {
- process.kill(-other.pid, 'SIGTERM');
- } catch {
- // gone
- }
+ killTree(other.pid);
box.cleanup();
}
});
@@ -156,7 +153,7 @@ test('a loop judge by command writes into the loop folder, not the stage 6 findi
fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(path.join(dir, 'ask.md'), 'Pass 2. Craft.\n');
const started = json(box, ['review-run', '--loop', 'pass-2', '--json']);
- assert.match(started.findings, /loops\/pass-2\/judge\.md$/);
+ assert.match(started.findings, /loops[\\/]pass-2[\\/]judge\.md$/);
const text = await until(() => (fs.existsSync(started.findings) ? fs.readFileSync(started.findings, 'utf8') : null), 'the loop judge findings', 99000);
assert.match(text, /judge-x/);
assert.equal(fs.existsSync(path.join(box.project, '.100x', 'review', 'findings.md')), true, 'makeProject stage 6 fixture is untouched in content');
diff --git a/test/review.test.mjs b/test/review.test.mjs
index 17222e5..70d76cd 100644
--- a/test/review.test.mjs
+++ b/test/review.test.mjs
@@ -264,13 +264,13 @@ test('a loop judge gets its own brutal task and findings file, and refuses witho
const parsed = JSON.parse(call.out);
assert.equal(parsed.via, 'harness');
assert.equal(parsed.deadlineMinutes, 20);
- assert.match(parsed.findings, /loops\/pass-1\/judge\.md$/);
+ assert.match(parsed.findings, /loops[\\/]pass-1[\\/]judge\.md$/);
assert.match(parsed.delegateTask.task, /Be brutal/);
assert.match(parsed.delegateTask.task, /Drifting: yes/);
assert.match(parsed.delegateTask.task, /Judged by: looking/);
assert.match(parsed.delegateTask.task, /Never judge a screen from its code/);
assert.match(parsed.delegateTask.task, /single full-size screenshots/);
- assert.match(parsed.delegateTask.task, /loops\/pass-1\/ask\.md/);
+ assert.match(parsed.delegateTask.task, /loops[\\/]pass-1[\\/]ask\.md/);
box.cleanup();
});
diff --git a/test/routing-runner.test.mjs b/test/routing-runner.test.mjs
index 5d4a567..b9ca705 100644
--- a/test/routing-runner.test.mjs
+++ b/test/routing-runner.test.mjs
@@ -57,7 +57,7 @@ test('each message goes to the helper once with the model, effort and context as
for (const [id, skill] of Object.entries(answers)) assert.equal(skill, firstListed(dir, id), `${id} got the answer to its own message`);
const calls = fs.readFileSync(path.join(home, 'calls.log'), 'utf8').trim().split('\n');
assert.equal(calls.length, 3);
- for (const call of calls) assert.match(call, / some-model high 200k \/.*route-empty-/, 'the helper ran in a folder that holds nothing');
+ for (const call of calls) assert.match(call, / some-model high 200k (?:\/|[A-Za-z]:\\).*route-empty-/, 'the helper ran in a folder that holds nothing');
const meta = JSON.parse(fs.readFileSync(path.join(dir, 'answers-meta.json'), 'utf8'));
assert.equal(meta.model, 'some-model');
assert.equal(meta.tokens, 300);
diff --git a/test/skill-spec.test.mjs b/test/skill-spec.test.mjs
index 9389f42..d0b1a89 100644
--- a/test/skill-spec.test.mjs
+++ b/test/skill-spec.test.mjs
@@ -8,7 +8,7 @@ import { COMPATIBILITY, readStamp, stampProblems, stampText } from '../lib/skill
import { skillHash } from '../lib/skill-hash.mjs';
import { parseSkillFrontmatter, specFindings } from '../lib/skill-spec.mjs';
import { validateRepo } from '../lib/validate.mjs';
-import { cli, ROOT, sandbox, write } from './helpers.mjs';
+import { cli, ROOT, sandbox, symlink, write } from './helpers.mjs';
const skill = (front, body = '# Demo\n\nRun `100x doctor`.\n') => `---\nname: 100x-demo\ndescription: "Use when testing the spec rules."\n${front}---\n${body}`;
const rulesOf = (text, extra = {}) => {
@@ -149,7 +149,7 @@ test('a symlink that loops back to a folder above it is left out of the hash ins
const skill = path.join(box.dir, 'looping');
write(path.join(skill, 'SKILL.md'), '---\nname: looping\ndescription: Use for a loop. Do it.\n---\nBody.\n');
const plain = skillHash(skill);
- fs.symlinkSync('.', path.join(skill, 'self'));
+ symlink('.', path.join(skill, 'self'));
assert.equal(skillHash(skill), plain, 'the loop adds no file');
const tabbed = parseSkillFrontmatter('---\nname: a\ndescription: Use it.\nmetadata:\n\tauthor: "me"\n---\n');
assert.ok(tabbed.problems.some((problem) => /tab characters must not be used in indentation/.test(problem)), tabbed.problems.join('; '));
diff --git a/test/upstream.test.mjs b/test/upstream.test.mjs
index 8b48c4d..b3afd74 100644
--- a/test/upstream.test.mjs
+++ b/test/upstream.test.mjs
@@ -3,7 +3,7 @@ import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
import { newerCommits } from '../lib/commands/upstream.mjs';
-import { cli, sandbox } from './helpers.mjs';
+import { cli, fakeBin, sandbox } from './helpers.mjs';
const PINNED = 'bf0c7cd80abdbf7fe47b634978a7d1b4071f71a7';
@@ -21,8 +21,7 @@ test('when the pinned commit is not in the list everything is reported as maybe
});
function fakeGh(box, body, code = 0) {
- const file = path.join(box.dir, 'fake-gh');
- fs.writeFileSync(file, `#!/bin/sh\n${code ? `echo "gh: network down" >&2\nexit ${code}` : `printf '%s' '${body}'`}\n`, { mode: 0o755 });
+ const file = fakeBin(path.join(box.dir, 'fake-gh-bin'), 'fake-gh', code ? `process.stderr.write('gh: network down\\n'); process.exit(${code});` : `process.stdout.write(${JSON.stringify(body)});`);
return { ...box.env, X100_GH: file };
}