Compare commits

...

2 Commits

Author SHA1 Message Date
Colin McDonnell 07a2ec3ab2 0.0.119 2025-12-02 20:32:10 -08:00
Colin McDonnell b14bab5ed2 Improve cursor logging 2025-12-02 20:18:18 -08:00
7 changed files with 120 additions and 106 deletions
+25 -18
View File
@@ -83,6 +83,22 @@ type CursorEvent =
| CursorToolCallEvent | CursorToolCallEvent
| CursorResultEvent; | CursorResultEvent;
export const cursor = agent({
name: "cursor",
install: async () => {
return await installFromCurl({
installUrl: "https://cursor.com/install",
executableName: "cursor-agent",
});
},
run: async ({ payload, apiKey, cliPath, mcpServers }) => {
configureCursorMcpServers({ mcpServers, cliPath });
// track logged messages to avoid duplicates
const loggedAssistantMessages = new Set<string>();
// moved into `run` because it is stateful
// it tracks logged assistant messages to avoid duplicates
const messageHandlers = { const messageHandlers = {
system: (_event: CursorSystemEvent) => { system: (_event: CursorSystemEvent) => {
// system init events - no logging needed // system init events - no logging needed
@@ -94,13 +110,10 @@ const messageHandlers = {
// thinking events are internal - no logging needed // thinking events are internal - no logging needed
}, },
assistant: (event: CursorAssistantEvent) => { assistant: (event: CursorAssistantEvent) => {
// only log finalized messages (ones with model_call_id) const text = event.message?.content?.[0]?.text?.trim();
// cursor emits each message twice: once without model_call_id, then again with it if (text && !loggedAssistantMessages.has(text)) {
if (event.model_call_id) { loggedAssistantMessages.add(text);
const text = event.message?.content?.[0]?.text; log.box(text, { title: "Cursor" });
if (text?.trim()) {
log.box(text.trim(), { title: "Cursor" });
}
} }
}, },
tool_call: (event: CursorToolCallEvent) => { tool_call: (event: CursorToolCallEvent) => {
@@ -135,17 +148,6 @@ const messageHandlers = {
}, },
}; };
export const cursor = agent({
name: "cursor",
install: async () => {
return await installFromCurl({
installUrl: "https://cursor.com/install",
executableName: "cursor-agent",
});
},
run: async ({ payload, apiKey, cliPath, mcpServers }) => {
configureCursorMcpServers({ mcpServers, cliPath });
try { try {
const fullPrompt = addInstructions(payload); const fullPrompt = addInstructions(payload);
@@ -188,6 +190,11 @@ export const cursor = agent({
try { try {
const event = JSON.parse(text) as CursorEvent; const event = JSON.parse(text) as CursorEvent;
// skip debug logging for empty thinking deltas
if (event.type === "thinking" && event.subtype === "delta" && !event.text) {
return;
}
// route to appropriate handler // route to appropriate handler
const handler = messageHandlers[event.type as keyof typeof messageHandlers]; const handler = messageHandlers[event.type as keyof typeof messageHandlers];
if (handler) { if (handler) {
+1 -1
View File
@@ -70,7 +70,7 @@ Before starting any work, you must first determine which mode to use by examinin
Available modes: Available modes:
${[...modes, ...payload.modes].map((w) => ` - "${w.name}": ${w.description}`).join("\n")} ${(payload.modes.length > 0 ? payload.modes : modes).map((w) => ` - "${w.name}": ${w.description}`).join("\n")}
**IMPORTANT**: The first thing you must do is: **IMPORTANT**: The first thing you must do is:
1. Examine the user's request/prompt carefully 1. Examine the user's request/prompt carefully
+25 -22
View File
@@ -83859,7 +83859,7 @@ function query({
// package.json // package.json
var package_default = { var package_default = {
name: "@pullfrog/action", name: "@pullfrog/action",
version: "0.0.118", version: "0.0.119",
type: "module", type: "module",
files: [ files: [
"index.js", "index.js",
@@ -92367,7 +92367,7 @@ Before starting any work, you must first determine which mode to use by examinin
Available modes: Available modes:
${[...modes, ...payload.modes].map((w) => ` - "${w.name}": ${w.description}`).join("\n")} ${(payload.modes.length > 0 ? payload.modes : modes).map((w) => ` - "${w.name}": ${w.description}`).join("\n")}
**IMPORTANT**: The first thing you must do is: **IMPORTANT**: The first thing you must do is:
1. Examine the user's request/prompt carefully 1. Examine the user's request/prompt carefully
@@ -93390,7 +93390,18 @@ import { spawn as spawn3 } from "node:child_process";
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync2 } from "node:fs"; import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync2 } from "node:fs";
import { homedir as homedir2 } from "node:os"; import { homedir as homedir2 } from "node:os";
import { join as join6 } from "node:path"; import { join as join6 } from "node:path";
var messageHandlers3 = { var cursor = agent({
name: "cursor",
install: async () => {
return await installFromCurl({
installUrl: "https://cursor.com/install",
executableName: "cursor-agent"
});
},
run: async ({ payload, apiKey, cliPath, mcpServers }) => {
configureCursorMcpServers({ mcpServers, cliPath });
const loggedAssistantMessages = /* @__PURE__ */ new Set();
const messageHandlers4 = {
system: (_event) => { system: (_event) => {
}, },
user: (_event) => { user: (_event) => {
@@ -93398,11 +93409,10 @@ var messageHandlers3 = {
thinking: (_event) => { thinking: (_event) => {
}, },
assistant: (event) => { assistant: (event) => {
if (event.model_call_id) { const text = event.message?.content?.[0]?.text?.trim();
const text = event.message?.content?.[0]?.text; if (text && !loggedAssistantMessages.has(text)) {
if (text?.trim()) { loggedAssistantMessages.add(text);
log.box(text.trim(), { title: "Cursor" }); log.box(text, { title: "Cursor" });
}
} }
}, },
tool_call: (event) => { tool_call: (event) => {
@@ -93434,16 +93444,6 @@ var messageHandlers3 = {
} }
} }
}; };
var cursor = agent({
name: "cursor",
install: async () => {
return await installFromCurl({
installUrl: "https://cursor.com/install",
executableName: "cursor-agent"
});
},
run: async ({ payload, apiKey, cliPath, mcpServers }) => {
configureCursorMcpServers({ mcpServers, cliPath });
try { try {
const fullPrompt = addInstructions(payload); const fullPrompt = addInstructions(payload);
log.info("Running Cursor CLI..."); log.info("Running Cursor CLI...");
@@ -93479,7 +93479,10 @@ var cursor = agent({
stdout += text; stdout += text;
try { try {
const event = JSON.parse(text); const event = JSON.parse(text);
const handler2 = messageHandlers3[event.type]; if (event.type === "thinking" && event.subtype === "delta" && !event.text) {
return;
}
const handler2 = messageHandlers4[event.type];
if (handler2) { if (handler2) {
await handler2(event); await handler2(event);
} }
@@ -93640,7 +93643,7 @@ async function spawn4(options) {
// agents/gemini.ts // agents/gemini.ts
var assistantMessageBuffer = ""; var assistantMessageBuffer = "";
var messageHandlers4 = { var messageHandlers3 = {
init: (_event) => { init: (_event) => {
assistantMessageBuffer = ""; assistantMessageBuffer = "";
}, },
@@ -93740,7 +93743,7 @@ var gemini = agent({
log.debug(`[gemini stdout] ${trimmed}`); log.debug(`[gemini stdout] ${trimmed}`);
try { try {
const event = JSON.parse(trimmed); const event = JSON.parse(trimmed);
const handler2 = messageHandlers4[event.type]; const handler2 = messageHandlers3[event.type];
if (handler2) { if (handler2) {
await handler2(event); await handler2(event);
} }
@@ -122737,7 +122740,7 @@ function parsePayload(inputs) {
agent: null, agent: null,
prompt: inputs.prompt, prompt: inputs.prompt,
event: { event: {
trigger: "workflow_dispatch" trigger: "unknown"
}, },
modes modes
}; };
+4
View File
@@ -135,6 +135,10 @@ export type PayloadEvent =
| { | {
trigger: "workflow_dispatch"; trigger: "workflow_dispatch";
[key: string]: any; [key: string]: any;
}
| {
trigger: "unknown";
[key: string]: any;
}; };
// payload type for agent execution // payload type for agent execution
+1 -1
View File
@@ -1 +1 @@
summarize https://github.com/pullfrogai/scratch/issues/56, its status, and pertinent discussion on the issue Tell me a joke
+1 -1
View File
@@ -263,7 +263,7 @@ function parsePayload(inputs: Inputs): Payload {
agent: null, agent: null,
prompt: inputs.prompt, prompt: inputs.prompt,
event: { event: {
trigger: "workflow_dispatch", trigger: "unknown",
}, },
modes, modes,
}; };
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@pullfrog/action", "name": "@pullfrog/action",
"version": "0.0.118", "version": "0.0.119",
"type": "module", "type": "module",
"files": [ "files": [
"index.js", "index.js",