Skip to content

Commit a3699ba

Browse files
elkinjosetmclaude
andauthored
Log runner environment at session start (#109)
* Add logEnvironment to Runner interface for session diagnostics Runners now log environment-specific config at session start, making it easy to verify which account or config directory is active. This helps debug multi-account setups where the wrong credentials could be used. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Update bun.lock Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Bump version to 1.0.1 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2ca9e17 commit a3699ba

File tree

7 files changed

+22
-4
lines changed

7 files changed

+22
-4
lines changed

bun.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stonecut",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "CLI that drives PRD-driven development with agentic coding CLIs",
55
"license": "MIT",
66
"repository": {

src/runner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export async function runAfkLoop<T extends { number: number }>(
120120
const { logger, git, runner, runnerName } = session;
121121

122122
logger.log(`Session started — runner: ${runnerName}, iterations: ${iterations}`);
123+
runner.logEnvironment(logger);
123124
logger.log("");
124125
const results: IterationResult[] = [];
125126
const sessionStart = performance.now();

src/runners/claude.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@
66
* human-readable messages.
77
*/
88

9-
import type { Runner, RunResult } from "../types.js";
9+
import type { LogWriter, Runner, RunResult } from "../types.js";
1010

1111
const ERROR_MESSAGES: Record<string, string> = {
1212
error_max_turns: "max turns exceeded",
1313
error_max_budget_usd: "max budget exceeded",
1414
};
1515

1616
export class ClaudeRunner implements Runner {
17+
logEnvironment(logger: LogWriter): void {
18+
const configDir = process.env.CLAUDE_CONFIG_DIR || "~/.claude (default)";
19+
logger.log(`Claude config: ${configDir}`);
20+
}
21+
1722
async run(prompt: string): Promise<RunResult> {
1823
const start = performance.now();
1924

src/runners/codex.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* output on failure.
77
*/
88

9-
import type { Runner, RunResult } from "../types.js";
9+
import type { LogWriter, Runner, RunResult } from "../types.js";
1010

1111
function extractError(stdout: string): string {
1212
for (const raw of stdout.split("\n")) {
@@ -43,6 +43,10 @@ function extractError(stdout: string): string {
4343
}
4444

4545
export class CodexRunner implements Runner {
46+
logEnvironment(_logger: LogWriter): void {
47+
// No environment-specific config to log for Codex.
48+
}
49+
4650
async run(prompt: string): Promise<RunResult> {
4751
const start = performance.now();
4852

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface IterationResult {
2323
/** Protocol that all runner adapters must satisfy. */
2424
export interface Runner {
2525
run(prompt: string): Promise<RunResult>;
26+
logEnvironment(logger: LogWriter): void;
2627
}
2728

2829
/** Snapshot of the working tree state before a runner session. */

tests/commit-flow.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class FakeRunner implements Runner {
2727
this._success = success;
2828
}
2929

30+
logEnvironment(): void {}
31+
3032
async run(prompt: string): Promise<RunResult> {
3133
this.calls.push(prompt);
3234
return { success: this._success, exitCode: 0, durationSeconds: 0.1 };
@@ -293,6 +295,7 @@ describe("runAfkLoop", () => {
293295
test("runner failure does not complete issue", async () => {
294296
const source = new FakeSource([{ number: 1, title: "Task 1" }]);
295297
const failRunner: Runner = {
298+
logEnvironment() {},
296299
async run() {
297300
return {
298301
success: false,
@@ -462,6 +465,7 @@ describe("runAfkLoop", () => {
462465
{ number: 2, title: "Task 2" },
463466
]);
464467
const failRunner: Runner = {
468+
logEnvironment() {},
465469
async run() {
466470
return {
467471
success: false,
@@ -499,6 +503,7 @@ describe("runAfkLoop", () => {
499503
]);
500504
let callCount = 0;
501505
const runner: Runner = {
506+
logEnvironment() {},
502507
async run() {
503508
callCount++;
504509
// First call fails (issue 1 attempt 1), rest succeed
@@ -535,6 +540,7 @@ describe("runAfkLoop", () => {
535540
{ number: 2, title: "Task 2" },
536541
]);
537542
const failRunner: Runner = {
543+
logEnvironment() {},
538544
async run() {
539545
return {
540546
success: false,
@@ -593,6 +599,7 @@ describe("runAfkLoop", () => {
593599
const source = new FakeSource([{ number: 1, title: "Task 1" }]);
594600
let callCount = 0;
595601
const runner: Runner = {
602+
logEnvironment() {},
596603
async run() {
597604
callCount++;
598605
return {

0 commit comments

Comments
 (0)