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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/coding-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Coding agent CLI with read, bash, edit, write, update_plan tools and session management",
"type": "module",
"imports": {
"#evolution": "./dist/vendor/evolution/index.js",
"#harness-trace": "./dist/vendor/harness-trace/index.js"
},
"diffexConfig": {
Expand Down Expand Up @@ -38,8 +39,8 @@
"scripts": {
"clean": "shx rm -rf dist",
"build": "tsgo -p tsconfig.build.json && shx chmod +x dist/cli.js dist/rpc-entry.js && npm run copy-assets",
"build:binary": "npm --prefix ../harness-state run build && npm --prefix ../tui run build && npm --prefix ../telemetry run build && npm --prefix ../harness-trace run build && npm --prefix ../ai run build && npm --prefix ../agent run build && npm --prefix ../protocol run build && npm --prefix ../client run build && npm run build && bun build --compile --no-compile-autoload-bunfig ./dist/bun/cli.js ./src/utils/image-resize-worker.ts --outfile dist/pi && npm run copy-binary-assets",
"copy-assets": "shx mkdir -p dist/modes/interactive/theme && shx cp src/modes/interactive/theme/*.json dist/modes/interactive/theme/ && shx mkdir -p dist/modes/interactive/assets && shx cp src/modes/interactive/assets/*.png dist/modes/interactive/assets/ && shx mkdir -p dist/core/export-html/vendor && shx cp src/core/export-html/template.html src/core/export-html/template.css src/core/export-html/template.js dist/core/export-html/ && shx cp src/core/export-html/vendor/*.js dist/core/export-html/vendor/ && shx mkdir -p dist/vendor && shx cp -r ../harness-trace/dist dist/vendor/harness-trace",
"build:binary": "npm --prefix ../harness-state run build && npm --prefix ../tui run build && npm --prefix ../telemetry run build && npm --prefix ../harness-trace run build && npm --prefix ../evolution run build && npm --prefix ../ai run build && npm --prefix ../agent run build && npm --prefix ../protocol run build && npm --prefix ../client run build && npm run build && bun build --compile --no-compile-autoload-bunfig ./dist/bun/cli.js ./src/utils/image-resize-worker.ts --outfile dist/pi && npm run copy-binary-assets",
"copy-assets": "shx mkdir -p dist/modes/interactive/theme && shx cp src/modes/interactive/theme/*.json dist/modes/interactive/theme/ && shx mkdir -p dist/modes/interactive/assets && shx cp src/modes/interactive/assets/*.png dist/modes/interactive/assets/ && shx mkdir -p dist/core/export-html/vendor && shx cp src/core/export-html/template.html src/core/export-html/template.css src/core/export-html/template.js dist/core/export-html/ && shx cp src/core/export-html/vendor/*.js dist/core/export-html/vendor/ && shx mkdir -p dist/vendor && shx cp -r ../harness-trace/dist dist/vendor/harness-trace && shx cp -r ../evolution/dist dist/vendor/evolution",
"copy-binary-assets": "shx cp package.json dist/ && shx cp README.md dist/ && shx cp CHANGELOG.md dist/ && shx mkdir -p dist/theme && shx cp src/modes/interactive/theme/*.json dist/theme/ && shx mkdir -p dist/assets && shx cp src/modes/interactive/assets/*.png dist/assets/ && shx mkdir -p dist/export-html/vendor && shx cp src/core/export-html/template.html dist/export-html/ && shx cp src/core/export-html/vendor/*.js dist/export-html/vendor/ && shx cp -r docs dist/ && shx cp -r examples dist/ && shx cp ../../node_modules/@silvia-odwyer/photon-node/photon_rs_bg.wasm dist/",
"test": "vitest --run",
"shrinkwrap": "node ../../scripts/generate-coding-agent-shrinkwrap.mjs",
Expand Down
27 changes: 21 additions & 6 deletions packages/coding-agent/src/core/agent-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1196,18 +1196,31 @@ export class AgentSession {
);
}

await this._subagentController?.reset();
const selected = await this._harnessStateStore.selectVersion(version);
this._harnessVersionBundle = selected;
this._baseSystemPrompt = this._rebuildSystemPrompt(this.getActiveToolNames());
this._systemPromptOverride = undefined;
this.agent.state.systemPrompt = this._baseSystemPrompt;
await this._notifyHarnessActivated(version);
await this._activateHarnessBundle(selected);
} finally {
this._harnessSwitchInProgress = false;
}
}

private async _activateHarnessBundle(bundle: HarnessVersionBundle): Promise<void> {
await this._subagentController?.reset();
this._harnessVersionBundle = bundle;
this._baseSystemPrompt = this._rebuildSystemPrompt(this.getActiveToolNames());
this._systemPromptOverride = undefined;
this.agent.state.systemPrompt = this._baseSystemPrompt;
await this._notifyHarnessActivated(bundle.manifest.version);
}

private async _refreshSelectedHarnessAtPromptBoundary(): Promise<void> {
if (!this._harnessStateStore) return;

const selected = await this._harnessStateStore.loadCurrent();
if (selected.manifest.version === this.activeHarnessVersion) return;

await this._activateHarnessBundle(selected);
}

/**
* Set active tools by name.
* Only tools in the registry can be enabled. Unknown tool names are ignored.
Expand Down Expand Up @@ -1646,6 +1659,8 @@ export class AgentSession {
return;
}

await this._refreshSelectedHarnessAtPromptBoundary();

// Flush any pending bash messages before the new prompt
this._flushPendingBashMessages();

Expand Down
Loading