feat: initialize AI agent harness
This commit is contained in:
5
scripts/agent-harness.cmd
Normal file
5
scripts/agent-harness.cmd
Normal file
@@ -0,0 +1,5 @@
|
||||
@echo off
|
||||
setlocal
|
||||
set "SCRIPT_DIR=%~dp0"
|
||||
powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%agent-harness.ps1" %*
|
||||
exit /b %ERRORLEVEL%
|
||||
33
scripts/agent-harness.ps1
Normal file
33
scripts/agent-harness.ps1
Normal file
@@ -0,0 +1,33 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(ValueFromRemainingArguments = $true)]
|
||||
[string[]] $HarnessArguments
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$scriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$harnessRoot = Split-Path -Parent $scriptRoot
|
||||
$entryPoint = Join-Path $harnessRoot 'dist\cli.cjs'
|
||||
|
||||
if (-not (Test-Path -LiteralPath $entryPoint -PathType Leaf)) {
|
||||
throw "Harness entry point not found: $entryPoint"
|
||||
}
|
||||
|
||||
$nodeCommand = Get-Command node -ErrorAction SilentlyContinue
|
||||
if ($null -eq $nodeCommand) {
|
||||
throw 'Node.js 20 or newer is required.'
|
||||
}
|
||||
|
||||
$nodeVersionText = (& $nodeCommand.Source --version).TrimStart('v')
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
|
||||
$nodeVersion = [Version] $nodeVersionText
|
||||
if ($nodeVersion.Major -lt 20) {
|
||||
throw "Node.js 20 or newer is required. Found: $nodeVersionText"
|
||||
}
|
||||
|
||||
& $nodeCommand.Source $entryPoint @HarnessArguments
|
||||
exit $LASTEXITCODE
|
||||
33
scripts/build.mjs
Normal file
33
scripts/build.mjs
Normal file
@@ -0,0 +1,33 @@
|
||||
import { chmod, rm } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { build } from "esbuild";
|
||||
|
||||
const harnessRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
await rm(path.join(harnessRoot, "dist"), { recursive: true, force: true });
|
||||
|
||||
const common = {
|
||||
absWorkingDir: harnessRoot,
|
||||
bundle: true,
|
||||
platform: "node",
|
||||
target: "node20",
|
||||
format: "cjs",
|
||||
legalComments: "eof",
|
||||
sourcemap: false,
|
||||
};
|
||||
|
||||
await Promise.all([
|
||||
build({
|
||||
...common,
|
||||
entryPoints: [path.join(harnessRoot, "src", "cli.ts")],
|
||||
outfile: path.join(harnessRoot, "dist", "cli.cjs"),
|
||||
banner: { js: "#!/usr/bin/env node" },
|
||||
}),
|
||||
build({
|
||||
...common,
|
||||
entryPoints: [path.join(harnessRoot, "src", "index.ts")],
|
||||
outfile: path.join(harnessRoot, "dist", "index.cjs"),
|
||||
}),
|
||||
]);
|
||||
|
||||
await chmod(path.join(harnessRoot, "dist", "cli.cjs"), 0o755);
|
||||
Reference in New Issue
Block a user