Skip to content

Commit 1541fc3

Browse files
aidandaly24claude
andcommitted
chore: make TUI harness build opt-in for dev only
The harness is dev-only tooling for AI agents and integration tests. It should not ship to end users who install the CLI. - Gate MCP harness esbuild behind BUILD_HARNESS=1 env var - Remove agent-tui-harness bin entry from package.json - Add !dist/mcp-harness to files array (npm publish exclusion) - Remove node-pty from optionalDependencies (stays in devDependencies) - Add build:harness script, update test:tui to use it - Update AGENTS.md to reference npm run build:harness Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cf56679 commit 1541fc3

3 files changed

Lines changed: 18 additions & 13 deletions

File tree

AGENTS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ The TUI harness provides MCP tools for programmatically driving the AgentCore CL
129129

130130
### Getting Started
131131

132-
1. Run `npm run build` to compile the project before using the harness tools.
132+
1. Run `npm run build:harness` to compile both the CLI and the MCP harness binary. The harness is dev-only tooling and
133+
is not included in the standard `npm run build`.
133134
2. Call `tui_launch` to start a TUI session. It returns a `sessionId` that all subsequent tool calls require.
134135
- `tui_launch({})` with no arguments defaults to `command="node"`, `args=["dist/cli/index.mjs"]` (the AgentCore CLI).
135136
- The `cwd` parameter determines what the TUI sees: if `cwd` is a directory with an `agentcore.config.json`, the TUI
@@ -357,6 +358,6 @@ When `tui_send_keys` doesn't change the screen:
357358

358359
When `tui_launch` returns an error:
359360

360-
1. Ensure `npm run build` was run recently -- the CLI binary at `dist/cli/index.mjs` must be up to date.
361+
1. Ensure `npm run build:harness` was run recently -- both the CLI binary and the MCP harness must be up to date.
361362
2. Check that `cwd` points to a valid directory.
362363
3. The error response includes the screen content at time of failure -- use it to diagnose.

esbuild.config.mjs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,17 @@ fs.chmodSync('./dist/cli/index.mjs', '755');
6161

6262
console.log('CLI build complete: dist/cli/index.mjs');
6363

64-
// MCP harness build — only run if the entry point source exists.
65-
// The source file is created separately; skip gracefully until then.
64+
// ---------------------------------------------------------------------------
65+
// MCP harness build — opt-in via BUILD_HARNESS=1
66+
//
67+
// The TUI harness is dev-only tooling for AI agents and integration tests.
68+
// It is NOT shipped to end users. Build it separately with:
69+
// BUILD_HARNESS=1 node esbuild.config.mjs
70+
// npm run build:harness
71+
// ---------------------------------------------------------------------------
6672
const mcpEntryPoint = './src/tui-harness/mcp/index.ts';
6773

68-
if (fs.existsSync(mcpEntryPoint)) {
74+
if (process.env.BUILD_HARNESS === '1' && fs.existsSync(mcpEntryPoint)) {
6975
await esbuild.build({
7076
entryPoints: [mcpEntryPoint],
7177
outfile: './dist/mcp-harness/index.mjs',
@@ -91,6 +97,6 @@ if (fs.existsSync(mcpEntryPoint)) {
9197
fs.chmodSync('./dist/mcp-harness/index.mjs', '755');
9298

9399
console.log('MCP harness build complete: dist/mcp-harness/index.mjs');
94-
} else {
100+
} else if (process.env.BUILD_HARNESS === '1') {
95101
console.log(`MCP harness build skipped: entry point ${mcpEntryPoint} does not exist yet`);
96102
}

package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
"main": "./dist/index.js",
3131
"types": "./dist/index.d.ts",
3232
"bin": {
33-
"agentcore": "dist/cli/index.mjs",
34-
"agent-tui-harness": "dist/mcp-harness/index.mjs"
33+
"agentcore": "dist/cli/index.mjs"
3534
},
3635
"exports": {
3736
".": {
@@ -41,14 +40,16 @@
4140
},
4241
"files": [
4342
"dist",
44-
"scripts"
43+
"scripts",
44+
"!dist/mcp-harness"
4545
],
4646
"scripts": {
4747
"preinstall": "node scripts/check-old-cli.mjs",
4848
"build": "npm run build:lib && npm run build:cli && npm run build:assets",
4949
"build:lib": "tsc -p tsconfig.build.json",
5050
"build:cli": "node esbuild.config.mjs",
5151
"build:assets": "node scripts/copy-assets.mjs",
52+
"build:harness": "BUILD_HARNESS=1 node esbuild.config.mjs",
5253
"cli": "npx tsx src/cli/index.ts",
5354
"typecheck": "tsc --noEmit",
5455
"lint": "eslint src/",
@@ -66,7 +67,7 @@
6667
"test:unit": "vitest run --project unit --coverage",
6768
"test:e2e": "vitest run --project e2e",
6869
"test:update-snapshots": "vitest run --project unit --update",
69-
"test:tui": "npm run build && vitest run --project tui"
70+
"test:tui": "npm run build:harness && vitest run --project tui"
7071
},
7172
"dependencies": {
7273
"@aws-cdk/toolkit-lib": "^1.16.0",
@@ -129,9 +130,6 @@
129130
"typescript-eslint": "^8.50.1",
130131
"vitest": "^4.0.18"
131132
},
132-
"optionalDependencies": {
133-
"node-pty": "^1.1.0"
134-
},
135133
"overridesComments": {
136134
"minimatch": "GHSA-7r86-cg39-jmmj, GHSA-23c5-xmqv-rm74: minimatch 10.0.0-10.2.2 has ReDoS vulnerabilities. Multiple transitive deps (eslint, typescript-eslint, eslint-plugin-import, eslint-plugin-react, prettier-plugin-sort-imports, aws-cdk-lib) pin older versions. Remove this override once upstream packages update their minimatch dependency to >=10.2.3.",
137135
"fast-xml-parser": "GHSA-fj3w-jwp8-x2g3: fast-xml-parser <5.3.8 has stack overflow in XMLBuilder. Transitive via @aws-sdk/xml-builder. Remove this override once @aws-sdk updates to fast-xml-parser >=5.3.8."

0 commit comments

Comments
 (0)