Switch to double quotes and reformat codebase with Biome
This commit is contained in:
@@ -7,11 +7,7 @@
|
||||
* to understand how command output is delivered.
|
||||
*/
|
||||
|
||||
import {
|
||||
query,
|
||||
type SDKUserMessage,
|
||||
type SDKMessage,
|
||||
} from "@anthropic-ai/claude-agent-sdk";
|
||||
import { query, type SDKUserMessage, type SDKMessage } from "@anthropic-ai/claude-agent-sdk";
|
||||
|
||||
class Pushable<T> implements AsyncIterable<T> {
|
||||
private queue: T[] = [];
|
||||
@@ -103,7 +99,9 @@ async function investigateCommand(commandName: string): Promise<void> {
|
||||
break;
|
||||
|
||||
case "user":
|
||||
process.stdout.write(`User message content: ${JSON.stringify(message.message?.content, null, 2)}\n`);
|
||||
process.stdout.write(
|
||||
`User message content: ${JSON.stringify(message.message?.content, null, 2)}\n`,
|
||||
);
|
||||
break;
|
||||
|
||||
case "assistant":
|
||||
@@ -142,7 +140,7 @@ async function investigateCommand(commandName: string): Promise<void> {
|
||||
process.stdout.write(`Errors: ${JSON.stringify(message.errors)}\n`);
|
||||
}
|
||||
// Check for any other properties
|
||||
const resultKeys = Object.keys(message).filter(k => !["type", "subtype"].includes(k));
|
||||
const resultKeys = Object.keys(message).filter((k) => !["type", "subtype"].includes(k));
|
||||
if (resultKeys.length > 0) {
|
||||
process.stdout.write(`Other result properties: ${resultKeys.join(", ")}\n`);
|
||||
for (const key of resultKeys) {
|
||||
@@ -161,7 +159,6 @@ async function investigateCommand(commandName: string): Promise<void> {
|
||||
}
|
||||
|
||||
process.stdout.write(`\nTotal messages received: ${messageCount}\n`);
|
||||
|
||||
} finally {
|
||||
input.end();
|
||||
await claudeQuery.return?.();
|
||||
|
||||
@@ -136,7 +136,9 @@ async function executeCommand(commandName: string): Promise<void> {
|
||||
// Iterate the query to process the command
|
||||
let gotSystemInit = false;
|
||||
for await (const message of claudeQuery) {
|
||||
process.stdout.write(` [${message.type}] ${message.type === "system" ? message.subtype : ""}\n`);
|
||||
process.stdout.write(
|
||||
` [${message.type}] ${message.type === "system" ? message.subtype : ""}\n`,
|
||||
);
|
||||
|
||||
if (message.type === "system" && message.subtype === "init") {
|
||||
gotSystemInit = true;
|
||||
@@ -149,7 +151,9 @@ async function executeCommand(commandName: string): Promise<void> {
|
||||
if (Array.isArray(content)) {
|
||||
for (const block of content) {
|
||||
if (block.type === "text") {
|
||||
process.stdout.write(` Response: ${block.text.slice(0, 200)}${block.text.length > 200 ? "..." : ""}\n`);
|
||||
process.stdout.write(
|
||||
` Response: ${block.text.slice(0, 200)}${block.text.length > 200 ? "..." : ""}\n`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,7 +203,6 @@ async function main() {
|
||||
// Actually execute a command to demonstrate it works:
|
||||
// Using "context" as it's fast and doesn't require arguments
|
||||
await executeCommand("context");
|
||||
|
||||
} catch (error) {
|
||||
process.stderr.write(`ERROR: ${error}\n`);
|
||||
process.exit(1);
|
||||
|
||||
Reference in New Issue
Block a user