-
Notifications
You must be signed in to change notification settings - Fork 0
feat: File-based SDLC conventions (issue #102) #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
65595e3
feat: Add file-based SDLC conventions (issue #102)
kwakayama 3cb5d97
refactor: Change SDLC to flat issues/ folder structure
kwakayama 848d0cf
feat: Add 'issues' command for file-based workflow
kwakayama 889586d
refactor: Simplify to 4 essential CLI commands
kwakayama 4ba9740
feat: Ultra-clean minimalistic CLI output
kwakayama 388dd18
feat: Enhanced help for humans and AI agents
kwakayama 9029495
feat: Add spec-driven development workflow
kwakayama a42270f
refactor: Rename src/sdlc to src/issues for consistency
kwakayama 4f84856
docs: Add comprehensive one-pager with evidence
kwakayama b8ff0e2
docs: Update one-pager with Studio PR #161
kwakayama be5cecc
docs: Update onepager with local dev environment proof
kwakayama d424c2c
chore: wip
kwakayama File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # Environment variables | ||
| # Copy this file to .env and fill in your values | ||
|
|
||
| # OpenAI API key (https://platform.openai.com/api-keys) | ||
| OPENAI_API_KEY=sk-... | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { agent } from "veryfront/agent"; | ||
| import { promptRegistry } from "veryfront/prompt"; | ||
|
|
||
| function getSystemPrompt(): string { | ||
| const prompt = promptRegistry.get("assistant"); | ||
| if (prompt) { | ||
| const content = prompt.getContent(); | ||
| return typeof content === "string" ? content : ""; | ||
| } | ||
| return "You are a helpful AI assistant."; | ||
| } | ||
|
|
||
| export default agent({ | ||
| id: "assistant", | ||
| model: "openai/gpt-4o", | ||
| system: getSystemPrompt, | ||
|
|
||
| // Use all discovered tools from tools/ | ||
| // To select specific tools, change to: tools: { toolName: true, anotherTool: true } | ||
| tools: true, | ||
|
|
||
| maxSteps: 10, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| import { z } from "zod"; | ||
| import { getAgent } from "veryfront/agent"; | ||
|
|
||
| // AI SDK v5 UIMessage format with parts array | ||
| // Supports text, tool-call, tool-result, and dynamic tool-* parts | ||
| const textPartSchema = z.object({ | ||
| type: z.literal("text"), | ||
| text: z.string().max(10000), | ||
| state: z.string().optional(), | ||
| }); | ||
|
|
||
| const toolCallPartSchema = z.object({ | ||
| type: z.literal("tool-call"), | ||
| toolCallId: z.string(), | ||
| toolName: z.string(), | ||
| args: z.unknown(), | ||
| }); | ||
|
|
||
| const toolResultPartSchema = z.object({ | ||
| type: z.literal("tool-result"), | ||
| toolCallId: z.string(), | ||
| result: z.unknown(), | ||
| }); | ||
|
|
||
| // Dynamic tool part (e.g., tool-calculator, tool-search) | ||
| // These are UI-specific parts that include tool state | ||
| const dynamicToolPartSchema = z.object({ | ||
| type: z.string().startsWith("tool-"), | ||
| toolCallId: z.string(), | ||
| toolName: z.string(), | ||
| state: z.string().optional(), | ||
| input: z.unknown().optional(), | ||
| output: z.unknown().optional(), | ||
| }).passthrough(); | ||
|
|
||
| // Union of all supported part types | ||
| const partSchema = z.union([ | ||
| textPartSchema, | ||
| toolCallPartSchema, | ||
| toolResultPartSchema, | ||
| dynamicToolPartSchema, | ||
| ]); | ||
|
|
||
| const messageSchema = z.object({ | ||
| id: z.string().optional(), | ||
| role: z.enum(["user", "assistant", "system", "tool"]), | ||
| parts: z.array(partSchema).min(1), | ||
| }); | ||
|
|
||
| const chatRequestSchema = z.object({ | ||
| messages: z.array(messageSchema).min(1).max(100), | ||
| }); | ||
|
|
||
| type ParsedMessage = z.infer<typeof messageSchema>; | ||
|
|
||
| /** | ||
| * Transform UI messages to agent-compatible format. | ||
| * AI SDK v5 UI bundles tool results in assistant message parts (output field), | ||
| * but the agent runtime expects separate tool role messages. | ||
| */ | ||
| function transformUIMessages(messages: ParsedMessage[]): ParsedMessage[] { | ||
| const result: ParsedMessage[] = []; | ||
|
|
||
| for (const msg of messages) { | ||
| if (msg.role === "assistant") { | ||
| // Check for tool parts with output (completed tool calls) | ||
| const toolPartsWithOutput = msg.parts.filter( | ||
| (p): p is { type: string; toolCallId: string; toolName: string; output: unknown } => | ||
| typeof p === "object" && | ||
| p !== null && | ||
| "type" in p && | ||
| typeof p.type === "string" && | ||
| p.type.startsWith("tool-") && | ||
| p.type !== "tool-result" && | ||
| "output" in p && | ||
| p.output !== undefined | ||
| ); | ||
|
|
||
| if (toolPartsWithOutput.length > 0) { | ||
| // Add the assistant message (keep tool parts for args extraction) | ||
| result.push(msg); | ||
|
|
||
| // Add tool result messages for each completed tool call | ||
| for (const toolPart of toolPartsWithOutput) { | ||
| result.push({ | ||
| id: `tool_${toolPart.toolCallId}`, | ||
| role: "tool", | ||
| parts: [{ | ||
| type: "tool-result", | ||
| toolCallId: toolPart.toolCallId, | ||
| result: toolPart.output, | ||
| }], | ||
| }); | ||
| } | ||
| } else { | ||
| result.push(msg); | ||
| } | ||
| } else { | ||
| result.push(msg); | ||
| } | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| export async function POST(request: Request) { | ||
| try { | ||
| const body = await request.json(); | ||
| const { messages: rawMessages } = chatRequestSchema.parse(body); | ||
|
|
||
| // Transform UI format to agent-compatible format | ||
| // AI SDK v5 UI bundles tool results in assistant parts (output field), | ||
| // but the agent runtime expects separate tool role messages | ||
| const messages = transformUIMessages(rawMessages); | ||
|
|
||
| const agent = getAgent("assistant"); | ||
| if (!agent) { | ||
| return Response.json({ error: "Agent not found" }, { status: 404 }); | ||
| } | ||
|
|
||
| // Clear server-side memory before each request | ||
| // The client (useChat) manages full conversation history | ||
| await agent.clearMemory(); | ||
|
|
||
| // In production, extract userId from session/cookie | ||
| // For development, we use a default user | ||
| const userId = "current-user"; | ||
|
|
||
| // Pass transformed messages to the agent | ||
| const result = await agent.stream({ | ||
| messages, | ||
| context: { userId }, | ||
| }); | ||
| return result.toDataStreamResponse(); | ||
| } catch (error) { | ||
| if (error instanceof z.ZodError) { | ||
| return Response.json( | ||
| { error: "Invalid request", details: error.errors }, | ||
| { status: 400 } | ||
| ); | ||
| } | ||
| return Response.json( | ||
| { error: "Internal server error" }, | ||
| { status: 500 } | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| export default function RootLayout({ children }: { children: React.ReactNode }) { | ||
| return ( | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charSet="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>AI Chat</title> | ||
| </head> | ||
| <body>{children}</body> | ||
| </html> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| 'use client' | ||
|
|
||
| import { Chat } from 'veryfront/components/ai' | ||
| import { useChat } from 'veryfront/agent/react' | ||
|
|
||
| export default function ChatPage() { | ||
| const chat = useChat({ api: '/api/chat' }) | ||
|
|
||
| return ( | ||
| <div className="flex flex-col h-screen bg-white dark:bg-neutral-900"> | ||
| {/* Header - sticky at top, full width */} | ||
| <header className="sticky top-0 z-10 flex-shrink-0 border-b border-neutral-200 dark:border-neutral-800 bg-white dark:bg-neutral-900"> | ||
| <div className="px-4 py-3 flex items-center justify-between"> | ||
| <h1 className="font-medium text-neutral-900 dark:text-white">AI Assistant</h1> | ||
| </div> | ||
| </header> | ||
|
|
||
| {/* Chat - fills remaining space with scrollable content */} | ||
| <Chat {...chat} className="flex-1 min-h-0" placeholder="Message" /> | ||
| </div> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { tool } from "veryfront/tool"; | ||
| import { z } from "zod"; | ||
|
|
||
| export default tool({ | ||
| id: "calculator", | ||
| description: "Perform basic arithmetic operations", | ||
| parameters: z.object({ | ||
| operation: z.enum(["add", "subtract", "multiply", "divide"]), | ||
| a: z.number(), | ||
| b: z.number(), | ||
| }), | ||
| execute: async ({ operation, a, b }) => { | ||
| switch (operation) { | ||
| case "add": | ||
| return { result: a + b }; | ||
| case "subtract": | ||
| return { result: a - b }; | ||
| case "multiply": | ||
| return { result: a * b }; | ||
| case "divide": | ||
| if (b === 0) throw new Error("Cannot divide by zero"); | ||
| return { result: a / b }; | ||
| } | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES2022", | ||
| "module": "ESNext", | ||
| "moduleResolution": "bundler", | ||
| "strict": true, | ||
| "jsx": "react-jsx", | ||
| "skipLibCheck": true, | ||
| "esModuleInterop": true, | ||
| "paths": { | ||
| "@/*": ["./*"] | ||
| } | ||
| }, | ||
| "include": ["**/*.ts", "**/*.tsx"], | ||
| "exclude": ["node_modules"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { VeryfrontConfig } from "veryfront"; | ||
|
|
||
| const config: VeryfrontConfig = { | ||
| projectSlug: "demo-0jmi15-37z9kb", | ||
| router: "app", | ||
|
|
||
| // Development | ||
| dev: { | ||
| open: true, | ||
| }, | ||
| }; | ||
|
|
||
| export default config; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Zod schema uses
z.string().startsWith("tool-")which is not a valid Zod method. To validate that a string starts with a specific prefix, usez.string().refine((s) => s.startsWith("tool-"), { message: "Type must start with 'tool-'" })orz.string().regex(/^tool-/)instead.