Skip to content

Commit df2914b

Browse files
authored
refactor: use PI_CODING_AGENT_DIR env var and remove unused subagent infrastructure (#52)
* refactor: use PI_CODING_AGENT_DIR env var for agent configuration paths * chore: remove closed ticket references and update brainstorm skill documentation * fixes * docs: update changelog
1 parent a691aeb commit df2914b

22 files changed

Lines changed: 73 additions & 2253 deletions

.tickets/as-0673.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

.tickets/as-5a68.md

Lines changed: 0 additions & 28 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ All notable changes to agent-stuff are documented here.
9090

9191

9292

93-
## fix/type-safety-and-race-conditions
93+
94+
95+
## refactor/use-agent-dir-env-var
96+
97+
This refactor centralizes agent and session data storage configuration through the `PI_CODING_AGENT_DIR` environment variable, replacing hard-coded `~/.pi` paths across multiple extensions (#52). The change improves portability and allows users to customize storage locations via environment variable, with automatic fallback to `$HOME/.pi/agent` when unset. Documentation and control socket paths in `control.ts`, `sandbox/index.ts`, `session-breakdown.ts`, and `stash.ts` have been updated to reference the new variable. Additionally, closed ticket references and subagent infrastructure (unused agent definitions and test suites) have been removed to reduce codebase complexity.
98+
99+
## [1.0.36](https://github.com/kostyay/agent-stuff/pull/51) - 2026-03-16
94100

95101
Improved type safety and race condition handling across subagent and ticket extensions (#51). The ticket system now retries ID generation on lock conflicts and uses per-ticket locks during garbage collection to prevent concurrent mutation races, while subagent tool calls include explicit type assertions for content blocks. Enhanced tmux session uniqueness by incorporating a directory hash into session names to avoid collisions in multi-workspace scenarios. Renamed the `/plan` command to `/agentic-plan` to clarify its role in the skill-injection planning workflow. Removed approximately 1,300 lines of test scaffolding that was no longer actively maintained.
96102

pi-extensions/control.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Enables inter-session communication via Unix domain sockets. When enabled with
55
* the `--session-control` flag, each pi session creates a control socket at
6-
* `~/.pi/session-control/<session-id>.sock` that accepts JSON-RPC commands.
6+
* `$PI_CODING_AGENT_DIR/../session-control/<session-id>.sock` that accepts JSON-RPC commands.
77
*
88
* Features:
99
* - Send messages to other running pi sessions (steer or follow-up mode)
@@ -59,7 +59,10 @@ const CONTROL_SEND_MESSAGE_FLAG = "send-session-message";
5959
const CONTROL_SEND_MODE_FLAG = "send-session-mode";
6060
const CONTROL_SEND_WAIT_FLAG = "send-session-wait";
6161
const CONTROL_SEND_INCLUDE_SENDER_FLAG = "send-session-include-sender-info";
62-
const CONTROL_DIR = path.join(os.homedir(), ".pi", "session-control");
62+
const CONTROL_DIR = path.join(
63+
path.dirname(process.env.PI_CODING_AGENT_DIR ?? path.join(os.homedir(), ".pi", "agent")),
64+
"session-control",
65+
);
6366
const SOCKET_SUFFIX = ".sock";
6467
const SESSION_MESSAGE_TYPE = "session-message";
6568
const SENDER_INFO_PATTERN = /<sender_info>[\s\S]*?<\/sender_info>/g;
@@ -983,7 +986,7 @@ function shouldRegisterControlTools(pi: ExtensionAPI): boolean {
983986

984987
export default function (pi: ExtensionAPI) {
985988
pi.registerFlag(CONTROL_FLAG, {
986-
description: "Enable per-session control socket under ~/.pi/session-control",
989+
description: "Enable per-session control socket under $PI_CODING_AGENT_DIR/../session-control",
987990
type: "boolean",
988991
});
989992
pi.registerFlag(CONTROL_TARGET_FLAG, {

pi-extensions/prompt-editor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* - Thinking-level border color derived from mode or model config
88
* - Prompt history loaded from current and previous sessions
99
*
10-
* Modes are stored globally (~/.pi/agent/modes.json) or per-project (.pi/modes.json).
10+
* Modes are stored globally ($PI_CODING_AGENT_DIR/modes.json) or per-project (.pi/modes.json).
1111
* Multiple running pi sessions use file-locking to avoid clobbering each other.
1212
*/
1313

pi-extensions/sandbox/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* bubblewrap on Linux).
77
*
88
* Config files (merged, project takes precedence):
9-
* - ~/.pi/agent/sandbox.json (global)
9+
* - $PI_CODING_AGENT_DIR/sandbox.json (global)
1010
* - <cwd>/.pi/sandbox.json (project-local)
1111
*
1212
* Array fields (allowedDomains, denyRead, etc.) are unioned across layers,
@@ -131,7 +131,7 @@ function mergeConfig(base: SandboxConfig, overrides: Partial<SandboxConfig>): Sa
131131
}
132132

133133
function loadConfig(cwd: string): SandboxConfig {
134-
const globalPath = join(homedir(), ".pi", "agent", "sandbox.json");
134+
const globalPath = join(getProfileDir(), "sandbox.json");
135135
const projectPath = join(cwd, ".pi", "sandbox.json");
136136

137137
let config = { ...DEFAULT_CONFIG };
@@ -155,7 +155,7 @@ function loadConfig(cwd: string): SandboxConfig {
155155

156156
/**
157157
* Resolve the profile directory from PI_CODING_AGENT_DIR env var.
158-
* Falls back to ~/.pi/agent when unset.
158+
* Falls back to $HOME/.pi/agent when unset.
159159
*/
160160
function getProfileDir(): string {
161161
return process.env.PI_CODING_AGENT_DIR ?? join(homedir(), ".pi", "agent");

pi-extensions/session-breakdown.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* /session-breakdown
33
*
4-
* Interactive TUI that analyzes ~/.pi/agent/sessions (recursively, *.jsonl) and shows
4+
* Interactive TUI that analyzes $PI_CODING_AGENT_DIR/sessions (recursively, *.jsonl) and shows
55
* last 7/30/90 days of:
66
* - sessions/day
77
* - messages/day
@@ -111,7 +111,7 @@ interface BreakdownData {
111111
};
112112
}
113113

114-
const SESSION_ROOT = path.join(os.homedir(), ".pi", "agent", "sessions");
114+
const SESSION_ROOT = path.join(process.env.PI_CODING_AGENT_DIR ?? path.join(os.homedir(), ".pi", "agent"), "sessions");
115115
const RANGE_DAYS = [7, 30, 90] as const;
116116

117117
type MeasurementMode = "sessions" | "messages" | "tokens";
@@ -1085,7 +1085,7 @@ class BreakdownComponent implements Component {
10851085

10861086
export default function sessionBreakdownExtension(pi: ExtensionAPI) {
10871087
pi.registerCommand("session-breakdown", {
1088-
description: "Interactive breakdown of last 7/30/90 days of ~/.pi session usage (sessions/messages/tokens + cost by model)",
1088+
description: "Interactive breakdown of last 7/30/90 days of pi session usage (sessions/messages/tokens + cost by model)",
10891089
handler: async (_args, ctx: ExtensionContext) => {
10901090
if (!ctx.hasUI) {
10911091
// Non-interactive fallback: just notify.

pi-extensions/stash.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
* Persistence:
1313
* - Stash survives session switches and restarts.
14-
* - Stored per-workspace in ~/.pi/stash/<encoded-cwd>.txt
14+
* - Stored per-workspace in $PI_CODING_AGENT_DIR/stash/<encoded-cwd>.txt
1515
*
1616
* Shows a widget above the editor with a truncated preview of the stashed text.
1717
*/
@@ -22,7 +22,7 @@ import { join } from "node:path";
2222

2323
const WIDGET_ID = "stash";
2424
const MAX_PREVIEW_LENGTH = 60;
25-
const STASH_DIR = join(process.env.PI_CODING_AGENT_DIR ?? join(process.env.HOME ?? "", ".pi"), "stash");
25+
const STASH_DIR = join(process.env.PI_CODING_AGENT_DIR ?? join(process.env.HOME ?? "", ".pi", "agent"), "stash");
2626

2727
/**
2828
* Build the file path for a workspace's stash file.

pi-extensions/subagent/agents/code.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

pi-extensions/subagent/agents/planner.md

Lines changed: 0 additions & 196 deletions
This file was deleted.

0 commit comments

Comments
 (0)