fix(cli): triage review findings from bugbot and coderabbit
The seed prompt now always lives in prompt.md and the agent launches with a one-line pointer at it: Windows .cmd shims go through cmd.exe, which cannot carry the multiline playbook as argv. T3CODE_HOME is now honored as the --base-dir equivalent, matching t3 pair. The playbook opens prefilled issue URLs only after the user approves. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
04b472742f
commit
c4e925d22c
4 files changed
+46
-10
No files matched your search
@@ -109,7 +109,8 @@ of `main` for that work, never the tag-pinned diagnosis clone.
|
||||
- Note at the end of the issue which model and agent produced it.
|
||||
- If `gh` is not authenticated, offer `gh auth login`, or build a prefilled
|
||||
https://github.com/pingdotgg/t3code/issues/new URL with title and body query
|
||||
parameters and open it in their browser.
|
||||
parameters; print the URL, and open it in their browser only after they
|
||||
approve.
|
||||
- If the user pasted screenshots, remind them to drag the images into the issue
|
||||
after it is created; they cannot be attached from here.
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import * as NodeReadlinePromises from "node:readline/promises";
|
||||
|
||||
import { HostProcessArchitecture, HostProcessPlatform } from "@t3tools/shared/hostProcess";
|
||||
import { isCommandAvailable, resolveSpawnCommand } from "@t3tools/shared/shell";
|
||||
import * as Config from "effect/Config";
|
||||
import * as Console from "effect/Console";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Effect from "effect/Effect";
|
||||
@@ -31,7 +32,11 @@ import { resolveBaseDir } from "../os-jank.ts";
|
||||
import { readPersistedServerRuntimeState } from "../serverRuntimeState.ts";
|
||||
import { baseDirFlag } from "./config.ts";
|
||||
import { resolveCliCommand } from "./invocation.ts";
|
||||
import { buildTriageContext, buildTriageSeedPrompt } from "./triagePrompt.ts";
|
||||
import {
|
||||
buildTriageContext,
|
||||
buildTriageLaunchPrompt,
|
||||
buildTriageSeedPrompt,
|
||||
} from "./triagePrompt.ts";
|
||||
|
||||
interface TriageAgent {
|
||||
readonly id: "claude" | "codex";
|
||||
@@ -172,7 +177,11 @@ export const triageCommand = Command.make("triage", {
|
||||
const path = yield* Path.Path;
|
||||
|
||||
// Triage is a user-facing feature: always the userdata state, never dev.
|
||||
const baseDir = yield* resolveBaseDir(Option.getOrUndefined(flags.baseDir));
|
||||
// --base-dir wins; T3CODE_HOME is its documented env equivalent (same
|
||||
// precedence as `t3 pair`).
|
||||
const explicitBaseDir = Option.getOrUndefined(flags.baseDir);
|
||||
const envHome = yield* Config.string("T3CODE_HOME").pipe(Config.option);
|
||||
const baseDir = yield* resolveBaseDir(explicitBaseDir ?? Option.getOrUndefined(envHome));
|
||||
const paths = yield* ServerConfig.deriveServerPaths(baseDir, undefined, {});
|
||||
|
||||
const now = yield* DateTime.now;
|
||||
@@ -237,11 +246,14 @@ export const triageCommand = Command.make("triage", {
|
||||
selected = yield* pickAgent(installed);
|
||||
}
|
||||
|
||||
const seedPrompt = buildTriageSeedPrompt(contextFilePath);
|
||||
// The full seed prompt always goes to disk. The agent is launched with a
|
||||
// one-line pointer at it: Windows `.cmd` shims run through cmd.exe,
|
||||
// which cannot carry the multiline playbook as an argv string, and with
|
||||
// no agent installed the same file is the paste-anywhere fallback.
|
||||
const promptFilePath = path.join(scratchDir, "prompt.md");
|
||||
yield* fs.writeFileString(promptFilePath, buildTriageSeedPrompt(contextFilePath));
|
||||
|
||||
if (selected === undefined) {
|
||||
const promptFilePath = path.join(scratchDir, "prompt.md");
|
||||
yield* fs.writeFileString(promptFilePath, seedPrompt);
|
||||
yield* Console.log(
|
||||
[
|
||||
"No supported agent CLI (claude, codex) was found on this machine.",
|
||||
@@ -259,7 +271,7 @@ export const triageCommand = Command.make("triage", {
|
||||
const model = Option.getOrUndefined(flags.model);
|
||||
const spawnSpec = yield* resolveSpawnCommand(selected.command, [
|
||||
...(model === undefined ? [] : ["--model", model]),
|
||||
seedPrompt,
|
||||
buildTriageLaunchPrompt(promptFilePath),
|
||||
]);
|
||||
yield* Console.log(`Starting ${selected.label}. It will ask what went wrong.\n`);
|
||||
const exitCode = yield* runInteractiveSession({ ...spawnSpec, cwd: scratchDir });
|
||||
|
||||
@@ -4,7 +4,12 @@ import * as NodePath from "node:path";
|
||||
|
||||
import { assert, it } from "@effect/vitest";
|
||||
|
||||
import { buildTriageContext, buildTriageSeedPrompt, TRIAGE_PLAYBOOK } from "./triagePrompt.ts";
|
||||
import {
|
||||
buildTriageContext,
|
||||
buildTriageLaunchPrompt,
|
||||
buildTriageSeedPrompt,
|
||||
TRIAGE_PLAYBOOK,
|
||||
} from "./triagePrompt.ts";
|
||||
|
||||
it("stays byte-identical to .github/triage/PLAYBOOK.md", () => {
|
||||
// Old releases fetch the repo copy from `main` and follow it when it differs
|
||||
@@ -24,6 +29,15 @@ it("seed prompt names the context file and embeds the playbook", () => {
|
||||
assert.include(prompt, TRIAGE_PLAYBOOK);
|
||||
});
|
||||
|
||||
it("launch prompt stays a single argv-safe line naming the prompt file", () => {
|
||||
// The launch argument goes through cmd.exe on Windows (.cmd shims), which
|
||||
// cannot carry newlines; the playbook itself must stay on disk.
|
||||
const launch = buildTriageLaunchPrompt(String.raw`C:\Users\a b\.t3\userdata\triage\x\prompt.md`);
|
||||
assert.notInclude(launch, "\n");
|
||||
assert.include(launch, String.raw`C:\Users\a b\.t3\userdata\triage\x\prompt.md`);
|
||||
assert.isBelow(launch.length, 1_000);
|
||||
});
|
||||
|
||||
it("context file carries every path the playbook depends on", () => {
|
||||
const context = buildTriageContext({
|
||||
generatedAt: "2026-08-13T00:00:00.000Z",
|
||||
|
||||
@@ -121,7 +121,8 @@ of \`main\` for that work, never the tag-pinned diagnosis clone.
|
||||
- Note at the end of the issue which model and agent produced it.
|
||||
- If \`gh\` is not authenticated, offer \`gh auth login\`, or build a prefilled
|
||||
https://github.com/pingdotgg/t3code/issues/new URL with title and body query
|
||||
parameters and open it in their browser.
|
||||
parameters; print the URL, and open it in their browser only after they
|
||||
approve.
|
||||
- If the user pasted screenshots, remind them to drag the images into the issue
|
||||
after it is created; they cannot be attached from here.
|
||||
|
||||
@@ -138,7 +139,15 @@ user's environment and evidence instead of filing a new issue. A confirmed
|
||||
duplicate with fresh evidence is more useful than a second thread.
|
||||
`;
|
||||
|
||||
/** The prompt the interactive agent session is launched with. */
|
||||
/**
|
||||
* The one-line argument the agent session is launched with. The real
|
||||
* instructions live in `prompt.md` on disk: Windows `.cmd` shims run through
|
||||
* cmd.exe, which cannot carry a multiline, multi-kilobyte argv string.
|
||||
*/
|
||||
export const buildTriageLaunchPrompt = (promptFilePath: string) =>
|
||||
`Read the file "${promptFilePath}" and follow its instructions exactly: it is your T3 Code triage playbook, and it starts with asking the user what went wrong.`;
|
||||
|
||||
/** The full seed prompt, written to `prompt.md` in the triage scratch dir. */
|
||||
export const buildTriageSeedPrompt = (contextFilePath: string) => `A T3 Code user is \
|
||||
having a problem with their install and started this session with \`t3 triage\`.
|
||||
|
||||
|
||||
Reference in new issue
Block a user