Skip to content

Commit f4ea41b

Browse files
authored
refactor(ticket): simplify auto-run flow and reorganize imports (#69)
* refactor(ticket): simplify auto-run flow and reorganize imports * docs: update changelog
1 parent 20fa2d2 commit f4ea41b

3 files changed

Lines changed: 511 additions & 51 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,18 @@ All notable changes to agent-stuff are documented here.
100100

101101

102102

103+
104+
105+
106+
## refactor/auto-run-simplification
107+
108+
Simplified the `/ticket-run-all` auto-run flow to streamline ticket processing across epics (#69). The command now uses a single confirmation dialog instead of fork-strategy selection, automatically initiates context compaction via `ctx.compact()`, and removes the separate session creation logic—auto-run state is tracked in-memory for seamless continuation. Added comprehensive test coverage for cross-epic task dependencies, including `buildAutoRunPrompt()` and `buildEpicContextLine()` helpers that enable proper context switching when moving between epic scopes. The refactored flow maintains the core auto-run capability (context compaction between tasks, continuation via `agent_end`) while reducing cognitive overhead and improving agent readiness for multi-epic workflows.
103109

104110
## docs/expand-github-skill-docs
105111

106112
Expanded the GitHub skill documentation (#64) with comprehensive `gh` CLI examples and best practices, including detailed sections on pull requests, GitHub Actions workflows, search, and API usage. The guide now covers practical command patterns for PR management (create, review, merge), workflow automation (triggering, monitoring, managing secrets/variables), and advanced querying with JSON filtering and GraphQL. Added a reference table for global flags and bulk operation patterns to improve discoverability and help users leverage the full capabilities of the GitHub CLI.
107113

108-
## chore/update-pi-packages-0-63-1
114+
## [1.0.42](https://github.com/kostyay/agent-stuff/pull/62) - 2026-03-28
109115

110116
Updated mariozechner PI packages to version 0.63.1 (#62), introducing API changes across multiple extensions. The update requires strict version pinning (`^0.63.1`) for peer dependencies (@mariozechner/pi-ai, @mariozechner/pi-coding-agent, @mariozechner/pi-tui), and refactors model authentication to use a new `getApiKeyAndHeaders()` method that returns an authentication object instead of a simple API key string. Key technical changes include updates to type imports (ModelRegistry), property accessors for command source information (from `c.path` to `c.sourceInfo?.path`), and dependency upgrades for OpenAI (6.10.0 → 6.26.0) and Mistral (1.10.0 → 1.14.1). The minimum Node.js requirement for pi-coding-agent was bumped from 20.0.0 to 20.6.0, and koffi is now an optional dependency in pi-tui.
111117

pi-extensions/ticket/index.ts

Lines changed: 23 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* - `ticket` tool with 9 actions (create, show, update, delete, start, close, reopen, list, add-note)
1111
* - `/ticket` TUI browser with fuzzy search and action menu
1212
* - `/ticket-create` prompt injection for epic + task breakdown
13-
* - `/ticket-run-all` automated ticket processing with auto-run continuation across epics
13+
* - `/ticket-run-all` automated ticket processing with compaction between tasks, continues across epics
1414
* - `/ticket-run-stop` to halt the auto-run loop after the current ticket
1515
* - Auto-close of parent epics when all child tasks are closed
1616
* - Auto-continuation: after closing a task, compacts context and sends next task prompt
@@ -20,6 +20,7 @@
2020
* - Auto-nudge on agent_end when tickets remain in-progress
2121
*/
2222

23+
import { StringEnum } from "@mariozechner/pi-ai";
2324
import {
2425
DynamicBorder,
2526
copyToClipboard,
@@ -30,27 +31,27 @@ import {
3031
type Theme,
3132
type ThemeColor,
3233
} from "@mariozechner/pi-coding-agent";
33-
import { StringEnum } from "@mariozechner/pi-ai";
34-
import { Type } from "@sinclair/typebox";
35-
import { existsSync } from "node:fs";
36-
import fs from "node:fs/promises";
37-
import path from "node:path";
3834
import {
3935
Container,
40-
type Focusable,
41-
type SelectItem,
4236
Input,
4337
Key,
4438
Markdown,
4539
SelectList,
4640
Spacer,
47-
Text,
4841
TUI,
42+
Text,
4943
getKeybindings,
5044
matchesKey,
5145
truncateToWidth,
5246
visibleWidth,
47+
type Focusable,
48+
type SelectItem,
5349
} from "@mariozechner/pi-tui";
50+
import { Type } from "@sinclair/typebox";
51+
import { existsSync } from "node:fs";
52+
import fs from "node:fs/promises";
53+
import path from "node:path";
54+
5455
import {
5556
type LockInfo,
5657
type TicketFrontMatter,
@@ -646,7 +647,7 @@ export default function ticketExtension(pi: ExtensionAPI) {
646647

647648
pi.on("input", async () => {
648649
nudgedThisCycle = false;
649-
return { action: "continue" as const };
650+
return { action: "continue" };
650651
});
651652

652653
// ── UI refresh ─────────────────────────────────────────────────────
@@ -1310,7 +1311,7 @@ export default function ticketExtension(pi: ExtensionAPI) {
13101311
// ── /ticket-run-all command ─────────────────────────────────────────
13111312

13121313
pi.registerCommand("ticket-run-all", {
1313-
description: "Process all ready tickets, optionally in separate sessions",
1314+
description: "Auto-run all ready tickets with compaction between tasks",
13141315
handler: async (_args, ctx) => {
13151316
const dir = getTicketsDir(ctx.cwd);
13161317
const tickets = await listTickets(dir);
@@ -1323,35 +1324,16 @@ export default function ticketExtension(pi: ExtensionAPI) {
13231324

13241325
const ticketList = ready.map((t) => ` ${t.id} ${t.title} [${t.type}, p${t.priority}]`).join("\n");
13251326

1326-
if (!ctx.hasUI) {
1327-
console.log(`Ready tickets:\n${ticketList}`);
1328-
return;
1329-
}
1330-
1331-
// Ask user how to proceed
1332-
const forkOptions = [
1333-
"Auto-run: work through all, each task compacted",
1334-
"Work through all in this session",
1335-
"Cancel",
1336-
];
1337-
const forkChoice = await ctx.ui.select("ticket-run-all: Session strategy", forkOptions);
1338-
1339-
if (!forkChoice || forkChoice === "Cancel") return;
1340-
1341-
if (forkChoice === "Work through all in this session") {
1342-
await clearAutoRun(dir);
1343-
const prompt =
1344-
`Work through these tickets in order, one at a time. For each ticket:\n` +
1345-
`1. Use \`ticket start <id>\` to begin\n` +
1346-
`2. Implement the work\n` +
1347-
`3. Use \`ticket close <id>\` when done (with tests_confirmed=true if it has tests)\n` +
1348-
`4. Move to the next ticket\n\n` +
1349-
`Ready tickets:\n${ticketList}\n\nStart with the first one.`;
1350-
ctx.ui.setEditorText(prompt);
1351-
return;
1327+
if (ctx.hasUI) {
1328+
const ok = await ctx.ui.confirm(
1329+
`Auto-run ${ready.length} ticket(s)?`,
1330+
`Context is compacted between tasks. Use /ticket-run-stop to halt.\n\n${ticketList}`,
1331+
);
1332+
if (!ok) return;
13521333
}
13531334

1354-
// Auto-run mode: set marker, send first task, agent_end handles continuation
1335+
// Set auto-run marker, compact context, send first task.
1336+
// agent_end handles continuation for subsequent tasks.
13551337
await writeAutoRun(dir, { active: true });
13561338

13571339
const firstTask = ready[0];
@@ -1362,16 +1344,9 @@ export default function ticketExtension(pi: ExtensionAPI) {
13621344
buildAutoRunPrompt(firstTask, record, ready.length) +
13631345
". Next task will be sent automatically after closing.";
13641346

1365-
const result = await ctx.newSession({
1366-
parentSession: ctx.sessionManager.getSessionFile(),
1367-
});
1368-
1369-
if (result.cancelled) {
1370-
await clearAutoRun(dir);
1371-
ctx.ui.notify("Session creation cancelled", "info");
1372-
} else {
1373-
pi.sendUserMessage(prompt);
1374-
}
1347+
ctx.compact();
1348+
refreshUI(ctx);
1349+
pi.sendUserMessage(prompt);
13751350
},
13761351
});
13771352

0 commit comments

Comments
 (0)