Skip to content

Commit 509ecd6

Browse files
NiallJoeMaherclaude
andcommitted
workshop: add Chapter 3 preview stubs (multi-agent)
- Add lib/ai/agents/quiz-master.ts with TODO placeholder - Add lib/ai/agents/planner.ts with TODO placeholder - Add lib/ai/agents/analyst.ts with TODO placeholder - Update index.ts with commented exports for Chapter 3 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6b85452 commit 509ecd6

4 files changed

Lines changed: 198 additions & 0 deletions

File tree

lib/ai/agents/analyst.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { tool } from "ai";
2+
import { z } from "zod";
3+
4+
import type { AgentResult, CreateAgentProps } from "./types";
5+
6+
// TODO CHAPTER 3: Implement the Analyst Agent
7+
//
8+
// The Analyst analyzes content and extracts key insights.
9+
// It should:
10+
// 1. Accept content and analysis type (summary, key-points, deep-analysis, study-notes)
11+
// 2. Use generateText to analyze the content
12+
// 3. Return structured analysis or summary
13+
//
14+
// Triggers: "analyze", "summarize", "key points", "what's important"
15+
//
16+
// See CHAPTER-3.md for the complete implementation.
17+
18+
/**
19+
* Analyst Agent - Analyzes content and extracts insights
20+
*
21+
* @param _props - Agent props (session, dataStream)
22+
* @returns AI SDK tool that analyzes and summarizes content
23+
*/
24+
export const createAnalystAgent = (_props: CreateAgentProps) =>
25+
tool({
26+
description:
27+
"Analyze content, extract key insights, and create summaries. " +
28+
"Use when the user wants to understand, summarize, or extract key points. " +
29+
"Triggers: analyze, summarize, key points, main ideas, extract insights.",
30+
inputSchema: z.object({
31+
content: z.string().describe("The text or content to analyze"),
32+
analysisType: z
33+
.enum(["summary", "key-points", "deep-analysis", "study-notes"])
34+
.default("summary")
35+
.describe("Type of analysis to perform"),
36+
focusOn: z
37+
.string()
38+
.optional()
39+
.describe("Specific aspect to focus the analysis on"),
40+
outputLength: z
41+
.enum(["brief", "moderate", "detailed"])
42+
.default("moderate")
43+
.describe("Desired length of the analysis output"),
44+
}),
45+
execute: async ({ analysisType }): Promise<AgentResult> => {
46+
// TODO: Implement in Chapter 3
47+
// 1. Build prompt based on analysis type
48+
// 2. Use generateText to analyze content
49+
// 3. Return structured analysis result
50+
51+
console.log(`[Analyst] TODO: Perform ${analysisType} analysis`);
52+
53+
// Placeholder await to satisfy linter (remove when implementing)
54+
await Promise.resolve();
55+
56+
return {
57+
agentName: "analyst",
58+
success: false,
59+
summary: `TODO: Implement analyst in Chapter 3 to perform ${analysisType} analysis`,
60+
};
61+
},
62+
});

lib/ai/agents/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22

33
// Specialized agents
44
export { createTutorAgent } from "./tutor";
5+
6+
// TODO CHAPTER 3: Uncomment these exports when implementing multi-agent system
7+
// export { createQuizMasterAgent } from "./quiz-master";
8+
// export { createPlannerAgent } from "./planner";
9+
// export { createAnalystAgent } from "./analyst";
10+
511
export type { AgentContext, AgentResult, CreateAgentProps } from "./types";

lib/ai/agents/planner.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { tool } from "ai";
2+
import { z } from "zod";
3+
4+
import type { AgentResult, CreateAgentProps } from "./types";
5+
6+
// TODO CHAPTER 3: Implement the Planner Agent
7+
//
8+
// The Planner creates personalized study plans and learning roadmaps.
9+
// It should:
10+
// 1. Accept a topic, timeframe, hours/day, and current level
11+
// 2. Use generateObject to create structured study plan data
12+
// 3. Return weekly breakdown with goals, tasks, and resources
13+
//
14+
// In Chapter 4, this will create a study-plan artifact with checkboxes.
15+
//
16+
// Triggers: "study plan", "learning roadmap", "how should I learn"
17+
//
18+
// See CHAPTER-3.md for the complete implementation.
19+
20+
/**
21+
* Planner Agent - Creates study plans and learning roadmaps
22+
*
23+
* @param _props - Agent props (session, dataStream)
24+
* @returns AI SDK tool that generates study plans
25+
*/
26+
export const createPlannerAgent = (_props: CreateAgentProps) =>
27+
tool({
28+
description:
29+
"Create a personalized study plan or learning roadmap for a topic. " +
30+
"Use when the user wants to plan their learning, create a study schedule, or get a structured approach. " +
31+
"Triggers: study plan, learning roadmap, how to learn, schedule, curriculum.",
32+
inputSchema: z.object({
33+
topic: z
34+
.string()
35+
.describe("The topic or skill to create a study plan for"),
36+
timeframe: z
37+
.string()
38+
.default("2 weeks")
39+
.describe("How long the user has to learn (e.g., '1 week', '30 days')"),
40+
hoursPerDay: z
41+
.number()
42+
.min(0.5)
43+
.max(8)
44+
.default(1)
45+
.describe("Hours available for study per day"),
46+
currentLevel: z
47+
.enum(["complete beginner", "some basics", "intermediate", "advanced"])
48+
.default("complete beginner")
49+
.describe("User's current knowledge level"),
50+
}),
51+
execute: async ({ topic }): Promise<AgentResult> => {
52+
// TODO: Implement in Chapter 3
53+
// 1. Use generateObject with a study plan schema
54+
// 2. Create weekly breakdown with goals and tasks
55+
// 3. Format as markdown or create artifact in Chapter 4
56+
57+
console.log(`[Planner] TODO: Create study plan for "${topic}"`);
58+
59+
// Placeholder await to satisfy linter (remove when implementing)
60+
await Promise.resolve();
61+
62+
return {
63+
agentName: "planner",
64+
success: false,
65+
summary: `TODO: Implement planner in Chapter 3 to create study plan for "${topic}"`,
66+
};
67+
},
68+
});

lib/ai/agents/quiz-master.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { tool } from "ai";
2+
import { z } from "zod";
3+
4+
import type { AgentResult, CreateAgentProps } from "./types";
5+
6+
// TODO CHAPTER 3: Implement the Quiz Master Agent
7+
//
8+
// The Quiz Master creates interactive quizzes to test knowledge.
9+
// It should:
10+
// 1. Accept a topic, number of questions, and difficulty level
11+
// 2. Use generateObject to create structured quiz data
12+
// 3. Return quiz questions with multiple choice options
13+
//
14+
// In Chapter 4, this will create a flashcard artifact instead of text.
15+
//
16+
// Triggers: "quiz me", "test my knowledge", "practice questions"
17+
//
18+
// See CHAPTER-3.md for the complete implementation.
19+
20+
/**
21+
* Quiz Master Agent - Creates quizzes to test knowledge
22+
*
23+
* @param _props - Agent props (session, dataStream)
24+
* @returns AI SDK tool that generates quiz questions
25+
*/
26+
export const createQuizMasterAgent = (_props: CreateAgentProps) =>
27+
tool({
28+
description:
29+
"Create a quiz to test knowledge on a topic. " +
30+
"Use when the user wants to be quizzed, test their knowledge, or practice. " +
31+
"Triggers: quiz me, test me, practice questions, assessment, flashcards.",
32+
inputSchema: z.object({
33+
topic: z.string().describe("The topic to create quiz questions about"),
34+
numberOfQuestions: z
35+
.number()
36+
.min(1)
37+
.max(10)
38+
.default(5)
39+
.describe("Number of questions to generate"),
40+
difficulty: z
41+
.enum(["easy", "medium", "hard", "mixed"])
42+
.default("medium")
43+
.describe("Difficulty level of the questions"),
44+
}),
45+
execute: async ({ topic }): Promise<AgentResult> => {
46+
// TODO: Implement in Chapter 3
47+
// 1. Use generateObject with a quiz schema
48+
// 2. Generate questions with options and explanations
49+
// 3. Format as markdown or create artifact in Chapter 4
50+
51+
console.log(`[QuizMaster] TODO: Create quiz about "${topic}"`);
52+
53+
// Placeholder await to satisfy linter (remove when implementing)
54+
await Promise.resolve();
55+
56+
return {
57+
agentName: "quiz-master",
58+
success: false,
59+
summary: `TODO: Implement quiz master in Chapter 3 to create quiz about "${topic}"`,
60+
};
61+
},
62+
});

0 commit comments

Comments
 (0)