@icoderyy/yy-prd-core
v0.1.8
Published
PRD Agent Runtime core SDK.
Readme
@icoderyy/yy-prd-core
PRD Agent Runtime core SDK. It turns rough PRD text into structured analysis, clarification questions, AI-development PRDs, validation reports, and Markdown artifacts for upper-layer apps.
Install
npm install @icoderyy/yy-prd-coreMinimal Usage
import { createAISDKProvider, createPRDCore } from '@icoderyy/yy-prd-core'
const prd = createPRDCore({
provider: createAISDKProvider({ modelId: 'deepseek:deepseek-chat' }),
})
const session = await prd.createSession({
source: {
type: 'markdown',
title: 'CRM 修改主账号功能优化',
content: rawMarkdown,
},
})
await prd.analyze(session.id)
await prd.generateClarificationQuestions(session.id)
const devPRD = await prd.generateDevPRD(session.id, { mode: 'auto' })
const report = await prd.validate(session.id)
const markdown = await prd.export(session.id)Runtime Boundary
This package is only the core SDK. Web, CLI, server jobs, Feishu plugins, and IDE plugins should import this package instead of duplicating PRD prompts or workflow logic.
Provider use is optional. Without a provider, built-in deterministic PRD tools still run. With a provider, analysis, clarification question generation, and final PRD generation use LLM output validated by zod schemas, then fall back to deterministic tools if the provider fails.
Artifact Contract
Core methods return values that upper-layer apps can use directly, with an attached artifact on structured steps:
const analysis = await prd.analyze(session.id)
await appDb.saveArtifact(session.id, analysis.artifact)
const questions = await prd.generateClarificationQuestions(session.id)
await appDb.saveArtifact(session.id, questions.artifact)
const exportArtifact = await prd.exportArtifact(session.id)
await appDb.saveArtifact(session.id, exportArtifact)The SDK keeps an in-memory runtime state only. Product persistence, users, projects, history, rollback, and database writes belong to the application layer.
Grill Runtime
Use runPrdAgentTurn() when the app wants a grill-me style loop. Core decides the next action; the app renders it and persists whatever it needs.
let turn = await prd.runPrdAgentTurn({
source: {
type: 'markdown',
content: rawMarkdown,
},
})
if (turn.nextAction.type === 'ask_user') {
renderQuestion(turn.nextAction.question, turn.nextAction.recommendedAnswer)
}
turn = await prd.runPrdAgentTurn({
sessionId: turn.session.id,
answer: {
questionId: turn.nextAction.type === 'ask_user' ? turn.nextAction.question.id : '',
value: userAnswer,
},
})grill mode asks one unresolved P0/P1 implementation question at a time. auto skips grilling and generates with available context. strict only asks P0 blockers.
Core Layout
agent: PRD agent loop and workflow boundary.providers: AI SDK model adapter and provider registry.config: model aliases, provider env mapping, and default model resolution.tools: deterministic PRD tools such as markdown parsing, missing-item detection, scoring, rendering, and validation.skills: PRD workflow skills built on top of tools.mcp: MCP server config types for upper-layer integrations.plugins: extension boundary for extra tools, skills, providers, and MCP servers.schemas: zod schemas for structured PRD runtime outputs.
