Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"name": "pstack",
"source": "./plugins/pstack",
"description": "Cursor pstack for T3 Code: poteto-mode, principles, and the verified agent workflows, adapted to T3 orchestration for Claude and Codex.",
"version": "0.17.4",
"version": "0.17.5",
"author": {
"name": "Lauren Tan (pstack), pmwoz (T3 Code port)"
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "t3-pstack",
"version": "0.17.4",
"version": "0.17.5",
"private": true,
"type": "module",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion pins.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
},
"t3": {
"repo": "pingdotgg/t3code",
"commit": "c9e9e7d36a91044bdcd9c7e1163c97de297f5bde",
"commit": "2808e878de91aacc7fb82887f18414976be7ae34",
"paths": [
"apps/server/src/mcp/McpToolExposure.ts",
"apps/server/src/mcp/toolkits/attachment/tools.ts",
"apps/server/src/mcp/toolkits/device/tools.ts",
"apps/server/src/mcp/toolkits/environment/tools.ts",
"apps/server/src/mcp/toolkits/feedback/tools.ts",
"apps/server/src/mcp/toolkits/html/tools.ts",
"apps/server/src/mcp/toolkits/issues/tools.ts",
"apps/server/src/mcp/toolkits/message/tools.ts",
Expand All @@ -40,6 +41,7 @@
"apps/server/src/mcp/toolkits/theme/tools.ts",
"apps/server/src/mcp/toolkits/thread/tools.ts",
"apps/server/src/mcp/toolkits/toolSearch/tools.ts",
"apps/server/src/mcp/toolkits/workflow/tools.ts",
"apps/server/src/mcp/toolkits/worktree/tools.ts",
"apps/server/src/provider/Drivers/ClaudeSkillDispatch.ts",
"apps/server/src/provider/Drivers/ClaudeSkills.ts",
Expand Down
2 changes: 1 addition & 1 deletion plugins/pstack/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pstack",
"displayName": "pstack",
"version": "0.17.4",
"version": "0.17.5",
"description": "Cursor pstack for T3 Code: poteto-mode, principles, and the verified agent workflows, adapted to T3 orchestration for Claude and Codex.",
"author": {
"name": "Lauren Tan (pstack), pmwoz (T3 Code port)"
Expand Down
2 changes: 1 addition & 1 deletion plugins/pstack/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pstack",
"version": "0.17.4",
"version": "0.17.5",
"description": "Cursor pstack for T3 Code: poteto-mode, principles, and the verified agent workflows, adapted to T3 orchestration for Claude and Codex.",
"author": {
"name": "Lauren Tan (pstack), pmwoz (T3 Code port)"
Expand Down
2 changes: 1 addition & 1 deletion plugins/pstack/skills/poteto-mode/references/t3-adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ T3 has no cloud agents. Every lane is a `delegate_task` child on this machine or
- **Review guides.** When the root hands PRs to the user for review or merge, it reads each with `read_pull_request_guide`. Then it calls `write_pull_request_guides` once for every PR whose guide is missing or `stale`. A run takes minutes, so do not wait for it. The user reads the guide in the PR's Guide tab. Pass each PR as `repository` and `number`, because the `url` form can fail to find the project's checkout. A PR whose outcome is `failed`, for example because guides are off in T3's Source Control settings, gets no guide. Give its `detail` in the reply and go on.
- **A PR owner (autopilot, multi-phase plans)** is a role, not a long-lived agent. Each owner round (build, fix, merge) is a fresh `delegate_task` in that PR's worktree. The round does its work, reports the PR URL, head SHA, and state, and returns. The root decides and delegates the next round.
- **Babysit inside a child.** A child told to babysit does one `check` pass, fixes what it can, and returns the PR state. It never arms a watch.
- **`/loop` around a PR.** This covers babysit's `drive` mode, shipping, and autonomous-run events. The root calls `watch_pull_request` and ends the turn. T3 wakes it on checks, reviews, and conflicts. On each wake, take the verdict from `<pstack-root>/skills/poteto-mode/scripts/watch-pr/watch-pr --status-only --pr <number>`, run in the PR's checkout (or `pull_request_read`, else the playbook's `origin` or `gh pr view` read), act, and keep the watch armed across push waves. Call `unwatch_pull_request` before handing back to the user. `scripts/watch-pr` stays the verdict oracle.
- **`/loop` around a PR.** This covers babysit's `drive` mode, shipping, and autonomous-run events. The root calls `watch_pull_request` and ends the turn. T3 wakes it on checks, reviews, and conflicts. Checks that already pass when the watch starts never wake it, so when the result's `checksState` is `passing`, do a wake's steps in the same turn instead of ending it. On each wake, take the verdict from `<pstack-root>/skills/poteto-mode/scripts/watch-pr/watch-pr --status-only --pr <number>`, run in the PR's checkout (or `pull_request_read`, else the playbook's `origin` or `gh pr view` read), act, and keep the watch armed across push waves. Call `unwatch_pull_request` before handing back to the user. `scripts/watch-pr` stays the verdict oracle.
- **`/loop` on a fixed cadence** (`/loop 1h`, audit ticks, heartbeats). The root calls `schedule_task` with `{type: "interval", everyMs: 3600000}` bound to its own thread, reports `nextRunAt`, and calls `delete_scheduled_task` when the run closes. To read that schedule again, such as on session pickup, call `list_scheduled_tasks` with its `scheduledTaskId`. Schedule from the root, because a child's schedule posts into the child's thread.
- **`/loop until X`** with no outside event: keep iterating within the run. Add a schedule only when the work must survive turn ends.
- **Events a PR watch cannot see.** T3 refuses to watch a PR that is already merged or whose host it cannot read, such as when `gh` is missing or signed out, and it cannot watch a ref, a branch without a PR, or a post-merge CI run. On Claude, wait on an event that a command can wait for, such as a post-merge CI run (`gh run watch <run-id> --exit-status`) or a deploy (its CLI's wait command), by running that command as a long shell command (Claude item below). For an event no command waits on (an autonomous run waiting on a ref), on Codex, and for a heartbeat fallback, the root calls `schedule_task` with an interval bound to its own thread. When the event has a known time, such as a release window or a deploy ETA, use `{type: "once", runAt}` with an ISO time and offset instead, so the root wakes once at that time. The prompt states the check and the exit condition. Call `delete_scheduled_task` once the condition holds.
Expand Down
34 changes: 34 additions & 0 deletions t3/contract/apps/server/src/mcp/toolkits/feedback/tools.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { OrchestratorMcpFailure } from "@t3tools/contracts";
import * as Schema from "effect/Schema";
import { McpSchema, Tool, Toolkit } from "effect/ai";

import {
FeedbackAwaitingApproval,
FeedbackInput,
FeedbackSubmitResult,
} from "../../../feedback/FeedbackReport.ts";
import * as Feedback from "../../../feedback/FeedbackService.ts";
import * as ThreadManagementService from "../../../orchestration-v2/ThreadManagementService.ts";
import * as McpInvocationContext from "../../McpInvocationContext.ts";

const shared = {
failure: OrchestratorMcpFailure,
failureMode: "return" as const,
dependencies: [
Feedback.FeedbackService,
McpInvocationContext.McpInvocationContext,
ThreadManagementService.ThreadManagementService,
],
};

export const FeedbackToolkit = Toolkit.make(
Tool.make("t3_feedback", {
...shared,
description:
"Send feedback to the T3 team: a T3 tool or `t3` command that misbehaved, a confusing instruction, a missing capability, or anything about T3 Code the user asks you to send. Not the user's own code. Use your own words; never quote the user's messages, code, files, or names. A report the user asks for opens a card where they approve it and choose whether to include the conversation of the `turns` you set, so call this when asked without asking first, and never paste the conversation into it.",
parameters: FeedbackInput,
success: Schema.Union([FeedbackSubmitResult, FeedbackAwaitingApproval]),
})
.annotate(Tool.Destructive, false)
.annotate(McpSchema.EnabledWhen, McpInvocationContext.hiddenWhileFeedbackOff),
);
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ const EnvironmentLinkTool = Tool.make("t3_environment_link", {

const EnvironmentUnlinkTool = Tool.make("t3_environment_unlink", {
description:
"Forget a linked environment. That machine's Connections list its session until revoked there.",
"Forget a linked environment. Its session on that machine ends too when the machine answers.",
parameters: OrchestratorMcpEnvironmentUnlinkInput,
success: OrchestratorMcpEnvironmentUnlinkResult,
failure: OrchestratorMcpFailure,
Expand Down
3 changes: 3 additions & 0 deletions t3/contract/apps/server/src/mcp/toolkits/project/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ThreadId,
RunId,
OrchestrationV2DelegatedFrom,
OrchestrationV2WorkflowOrigin,
OrchestrationV2RunStatus,
OrchestrationV2ThreadLaunchWorkspaceStrategy,
RuntimeMode,
Expand Down Expand Up @@ -165,6 +166,8 @@ const ThreadLaunchTool = Tool.make("t3_thread_launch", {
clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
/** Set by a linked environment launching its agent's delegated task here; ignored otherwise. */
delegatedFrom: Schema.optional(OrchestrationV2DelegatedFrom),
/** Set by a linked environment whose workflow run this thread is a step of; ignored otherwise. */
workflowRun: Schema.optional(OrchestrationV2WorkflowOrigin),
}),
success: Schema.Struct({
threadId: ThreadId,
Expand Down
12 changes: 12 additions & 0 deletions t3/contract/apps/server/src/mcp/toolkits/pullRequests/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
PullRequestReviewGuideRun,
PullRequestState,
PullRequestUnavailableError,
PullRequestVisibility,
PullRequestWatchUntil,
ThreadPullRequestLinkSource,
TrimmedNonEmptyString,
Expand Down Expand Up @@ -262,13 +263,17 @@ export const WatchPullRequestResult = Schema.Struct({
description: "The PR already ended, so nothing was watched.",
}),
),
checksState: Schema.optional(PullRequestChecksState),
next: Schema.optional(Schema.String),
});
export type WatchPullRequestResult = typeof WatchPullRequestResult.Type;

export const alreadyEndedWatchNext = (state: "merged" | "closed") =>
`This PR is already ${state}, so there is nothing to watch. Report that and end your turn.`;

export const CHECKS_ALREADY_PASSED_WATCH_NEXT =
"Checks already pass on this head, so no wake will come for them. Act on that now; the watch still wakes you on later changes.";

export const ThreadPullRequestEntry = Schema.Struct({
...PullRequestIdentity,
source: ThreadPullRequestLinkSource,
Expand Down Expand Up @@ -517,6 +522,9 @@ export const ReadPullRequestResult = Schema.Struct({
title: Schema.String,
state: PullRequestState,
isDraft: Schema.Boolean,
visibility: Schema.optional(PullRequestVisibility).annotate({
description: "Only on a host with private PRs.",
}),
author: Schema.NullOr(Schema.String),
headBranch: Schema.String,
baseBranch: Schema.String,
Expand Down Expand Up @@ -675,6 +683,10 @@ const CreatePullRequestTool = Tool.make("pull_request_create", {
body: Schema.String,
base: Schema.optional(TrimmedNonEmptyString),
draft: Schema.optional(Schema.Boolean),
private: Schema.optional(Schema.Boolean).annotate({
description:
"Visible to writers only; the branch never reaches origin. Fails on a host without private PRs.",
}),
}),
success: CreatePullRequestResult,
failure: PullRequestToolError,
Expand Down
69 changes: 69 additions & 0 deletions t3/contract/apps/server/src/mcp/toolkits/workflow/tools.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { OrchestratorMcpFailure, TrimmedNonEmptyString, WorkflowHook } from "@t3tools/contracts";
import * as Schema from "effect/Schema";
import * as SecureRandom from "effect/crypto/SecureRandom";
import { McpSchema, Tool, Toolkit } from "effect/ai";

import * as ThreadManagementService from "../../../orchestration-v2/ThreadManagementService.ts";
import * as Workflows from "../../../workflows/Workflows.ts";
import { WorkflowRun, WorkflowRunStatus, WorkflowStep } from "../../../workflows/WorkflowStore.ts";
import * as McpInvocationContext from "../../McpInvocationContext.ts";

export const WORKFLOW_READ_ACTIONS = ["list", "read", "questions", "store"] as const;

const WorkflowTool = Tool.make("t3_workflow", {
description:
"Durable workflow runs on this server. start: `workflow`, `input`, `idempotencyKey` (same key, same run). list: runs, by `status`. read: one run and its steps. questions: what runs ask a person. hooks: the URL paths that start runs. store: what workflows keep, under keys starting with `key`; store_set a `key` to `value`; store_delete. signal: wake a wait with `value`, addressed by `runId` and `wait`, or by `workflow` and `channel`; answers a question as `{choice, reason?}`. resume: run a paused run's failed step again. cancel.",
parameters: Schema.Struct({
action: Schema.Literals([
...WORKFLOW_READ_ACTIONS,
"hooks",
"start",
"signal",
"resume",
"cancel",
"store_set",
"store_delete",
]),
workflow: Schema.optional(TrimmedNonEmptyString),
input: Schema.optional(Schema.Json),
idempotencyKey: Schema.optional(TrimmedNonEmptyString),
runId: Schema.optional(TrimmedNonEmptyString),
status: Schema.optional(WorkflowRunStatus),
wait: Schema.optional(TrimmedNonEmptyString),
key: Schema.optional(TrimmedNonEmptyString),
channel: Schema.optional(TrimmedNonEmptyString),
value: Schema.optional(Schema.Json),
signalId: Schema.optional(
TrimmedNonEmptyString.annotate({
description: "Reuse it to retry the same signal. A new signal gets a new id.",
}),
),
reason: Schema.optional(Schema.String),
}),
success: Schema.Struct({
run: Schema.optional(WorkflowRun),
steps: Schema.optional(Schema.Array(WorkflowStep)),
runs: Schema.optional(Schema.Array(WorkflowRun)),
questions: Schema.optional(Schema.Array(Workflows.WorkflowQuestion)),
hooks: Schema.optional(Schema.Array(WorkflowHook)),
entries: Schema.optional(
Schema.Array(Schema.Struct({ key: Schema.String, value: Schema.Json })),
),
delivery: Schema.optional(Schema.Literals(["delivered", "buffered"])),
}),
failure: OrchestratorMcpFailure,
failureMode: "return" as const,
dependencies: [
McpInvocationContext.McpInvocationContext,
Workflows.Workflows,
ThreadManagementService.ThreadManagementService,
SecureRandom.SecureRandom,
],
})
.annotate(Tool.Title, "Workflow runs")
.annotate(Tool.Destructive, true)
// Outside clients and the CLI drive workflows. An agent in a thread reaches them through the
// CLI, so the tool costs no thread any context.
.annotate(McpSchema.EnabledWhen, McpInvocationContext.hiddenFromThreads);

export const WorkflowToolkit = Toolkit.make(WorkflowTool);
3 changes: 2 additions & 1 deletion t3/contract/packages/contracts/src/orchestratorMcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const OrchestratorMcpTarget = Schema.Struct({
options: Schema.optional(
OrchestratorMcpTargetOptions.annotate({
description:
"Options from `orchestrator_capabilities`, such as {effort:'max'}. Given values override inherited. [] or {} clears.",
"Ids vary by provider; see `orchestrator_capabilities`. Given values override inherited. [] or {} clears.",
}),
),
environmentId: Schema.optional(
Expand Down Expand Up @@ -965,6 +965,7 @@ export type OrchestratorMcpEnvironmentUnlinkInput =
export const OrchestratorMcpEnvironmentUnlinkResult = Schema.Struct({
environmentId: EnvironmentId,
removed: Schema.Boolean,
endedThere: Schema.Boolean,
});
export type OrchestratorMcpEnvironmentUnlinkResult =
typeof OrchestratorMcpEnvironmentUnlinkResult.Type;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import type { AgentFeedbackMode } from "@t3tools/contracts";

import type { ProviderAdapterV2RuntimePolicy } from "./ProviderAdapter.ts";

/** None while agent feedback is off, so users who never opt in pay no context for it. */
export const AGENT_FEEDBACK_INSTRUCTIONS = {
off: "",
"on-request": "Use `t3_feedback` only when the user asks you to send T3 feedback.",
auto: "`t3_feedback` reports are wanted and cheap. Send one, then continue, when a T3 tool or `t3` command fails or gives a wrong result, the user corrects how you use T3 Code, or a T3 capability you looked for is missing. Once per problem; also when the user asks. Only about T3 Code, never the user's code or other tools.",
} satisfies Record<AgentFeedbackMode, string>;

/** Session-invariant; harnesses with a native system-prompt append can carry it once per session. */
export const PULL_REQUEST_LINKING_INSTRUCTIONS = `<pull_request_linking>
Link each PR you create, take over, or push to: link_pull_request, or link_pull_requests for several, full URL, every stack layer, as your next call. Host tools don't link for you. If linking fails, say so. Skip PRs you only read or review and PRs named only as background. Call watch_pull_request when asked to monitor or babysit, or when work you were asked to do, such as a merge, still waits on checks or reviews, even after an earlier unwatch. Finish any needed branch update and push first, then watch and end your turn. Otherwise act now or hand back. Delegated children never watch, even if the brief says babysit. After PR work, a child's last line is: PR <full URL>, head <SHA>, checks and reviews <state>. Links and watches persist across pushes. For PR waits, no sleep, loops, gh --watch, Monitor or ScheduleWakeup. Before handback, call unwatch_pull_request on any PR you watch. When pull_request_* tools are listed, use them, not gh or cafe, to read, list, open, edit, review, reply on, close, or merge PRs, and ci_logs and ci_rerun for their checks. pull_request_create links for you.
Expand All @@ -9,6 +18,7 @@ If available, call link_issue for each issue you take on or file, even via CLI;
/** Omit model and effort when the harness manages them dynamically. */
export function buildRuntimeInstructions(runtime: {
readonly harness: string;
readonly agentFeedback?: AgentFeedbackMode;
readonly model?: string | undefined;
readonly modelName?: string | undefined;
readonly reasoningEffort?: string | undefined;
Expand All @@ -26,13 +36,15 @@ export function buildRuntimeInstructions(runtime: {
const modelInfo = model && model !== "auto" && model !== "default" ? `, as ${modelLabel}` : "";
const effortInfo = effort ? ` with ${effort} reasoning effort` : "";
const runtimeInfo = `<runtime_info>In case you're asked: you are running in T3 Code through the ${harness} harness${modelInfo}${effortInfo}. No need to mention this otherwise. You can embed images, video, and audio using Markdown image syntax with absolute file paths. Link every other file you cite or produce by its absolute path, as in [http.ts:42](/abs/path/http.ts:42), so the user can open it in T3 Code's files viewer.</runtime_info>`;
const feedbackLine = AGENT_FEEDBACK_INSTRUCTIONS[runtime.agentFeedback ?? "off"];
const feedback = feedbackLine ? `\n${feedbackLine}` : "";
const workspace =
runtime.runtimePolicy === undefined ? "" : buildWorkspaceInstructions(runtime.runtimePolicy);
return [
runtimeInfo,
...(runtime.pullRequestLinking === false ? [] : [PULL_REQUEST_LINKING_INSTRUCTIONS]),
...(workspace === "" ? [] : [workspace]),
].join("\n\n");
const linked =
runtime.pullRequestLinking === false
? runtimeInfo
: `${runtimeInfo}\n\n${PULL_REQUEST_LINKING_INSTRUCTIONS}`;
return [linked + feedback, ...(workspace === "" ? [] : [workspace])].join("\n\n");
}

function toSingleLine(value: string): string {
Expand Down
Loading