diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..23067d2 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,11 @@ +# Agent Instructions + +## Selfimprove + +This repository uses the global `selfimprovemeta` MCP. While working here, +record concrete tool friction with `record_friction` as it happens. Include +`caller_agent`, `project_slug = "gptqueue"`, and a queue/session id when one is +available. + +If the MCP is unavailable, append the same record shape to +`~/.selfimprovemeta/friction.md`. diff --git a/README.md b/README.md index eb07f8f..57f8469 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,9 @@ Or set `GPTQ_AGENT_NAME` in the environment. | `REDIS_URL` | `redis://127.0.0.1:6379` | Redis connection URL (MCP server and PTY wrapper) | | `GPTQ_AGENT_NAME` | _(none)_ | Pre-register with this agent name on startup | | `GPTQ_QUEUE_BOUND` | `10` | Max messages per agent inbox | +| `AGENT_ATTRIBUTION_CALLER` | `gptqueue-pty` | Attribution for PTY-wrapped child CLI processes | +| `AGENT_ATTRIBUTION_PROJECT` | Current directory name | Project attribution for PTY-wrapped child CLI processes | +| `AGENT_ATTRIBUTION_SESSION` | Agent name | Session attribution for PTY-wrapped child CLI processes | | `REDIS_HOST` | `127.0.0.1` | Redis host (hook script only) | | `REDIS_PORT` | `6379` | Redis port (hook script only) | diff --git a/src/pty-wrapper/index.ts b/src/pty-wrapper/index.ts index 94e286f..fac7d2d 100644 --- a/src/pty-wrapper/index.ts +++ b/src/pty-wrapper/index.ts @@ -1,5 +1,6 @@ #!/usr/bin/env node +import * as path from "node:path"; import * as pty from "node-pty"; import { IdleDetector } from "./idle-detector.js"; import { RedisWatcher } from "./redis-watcher.js"; @@ -31,6 +32,16 @@ const { agent, cmd, args } = parseArgs(process.argv); console.log(`[gptqueue-pty] Starting agent "${agent}" with command: ${cmd} ${args.join(" ")}`); +function agentAttributionEnv(agentName: string): Record { + return { + AGENT_ATTRIBUTION_CALLER: + process.env.AGENT_ATTRIBUTION_CALLER || "gptqueue-pty", + AGENT_ATTRIBUTION_PROJECT: + process.env.AGENT_ATTRIBUTION_PROJECT || path.basename(process.cwd()), + AGENT_ATTRIBUTION_SESSION: process.env.AGENT_ATTRIBUTION_SESSION || agentName, + }; +} + // Spawn the wrapped CLI in a PTY const ptyProcess = pty.spawn(cmd, args, { name: "xterm-color", @@ -40,6 +51,7 @@ const ptyProcess = pty.spawn(cmd, args, { env: { ...process.env, GPTQ_AGENT_NAME: agent, + ...agentAttributionEnv(agent), } as Record, });