@core/comments 기반 상품 리뷰: 구매 인증, 사진, 출처 표시된 가져온 리뷰, 평점, 리뷰 요청 메일
설치
genpm add @core/reviews포함 내용
- src/lib/reviews/에 소스 코드, 파일 5개. (14kB)
- src/lib/reviews/AGENTS.md에 AI 규칙, 그리고 IDE 규칙 파일.
- .env.example에 추가되는 환경 변수: REVIEW_REQUEST_DELAY_DAYS.
- @core/auth, @core/catalog, @core/comments, @core/db, @core/email, @core/jobs, @core/orders을(를) 자동으로 해결합니다.
README
이 패키지에는 README가 없습니다.
이것이 AI가 src/lib/reviews에서 작업할 때 읽는 내용 그대로입니다. 그 외에는 컨텍스트에 아무것도 추가되지 않습니다.
@core/reviews — rules for AI agents
Purpose
Product reviews built on @core/comments (no duplicate comment system): a review is a comment on product/<id> with a
1–5 rating, plus review_meta (verified purchase, photos from @core/media, source) and review_stats per product.
"Verified" means the signed-in author has a paid and shipped order with that product (by user id or their account's
verified email); guest reviews are never verified, so the response never reveals whether an email bought. Imported reviews are always labeled with
their source and never verified. Asks customers for a review N days after delivery.
Map
index.ts— public API:postReview,listReviews,productRating,moderateReview,importReviews,verifiedOrder.reviews.ts— logic, stats and thereviews.requestjob (scheduled from the orderdeliveredevent on import).
Integration
- Requires @core/comments (moderation, anti-spam) and @core/orders. Env: optional
REVIEW_REQUEST_DELAY_DAYS(default 7,-1disables),SITE_URL,EMAIL_FROM. - Migrations as in
src/lib/db/AGENTS.md; import this module at startup. - Product page:
productRating(id)for stars and JSON-LD (jsonLd.product({ rating })from @core/seo),listReviews(id, { page, rating, sort })for the list; show a "Verified purchase" badge and, for imported ones, "Imported from <source>". - Review form →
postReview({ productId, rating, body, user | guest, photos }, { headers, fields })with @core/antispam fields. - Moderate in the comments admin (filter
entityType=product) and callmoderateReviewso stats update. - Verify: a buyer's review shows as verified after approval and the product rating changes.
Conventions
- Explain on the page how reviews are checked (EU Omnibus Directive): verified = confirmed order.
- Show all approved reviews, including negative ones; sort options must not hide them by default.
Don't
- Don't write, generate or buy fake reviews, and don't mark imported reviews as verified.
- Don't put
aggregateRatingin JSON-LD when there are no approved reviews. - Don't offer rewards conditioned on a positive review.
# @core/reviews — rules for AI agents
## Purpose
Product reviews built on @core/comments (no duplicate comment system): a review is a comment on `product/<id>` with a
1–5 rating, plus `review_meta` (verified purchase, photos from @core/media, source) and `review_stats` per product.
"Verified" means the signed-in author has a paid and shipped order with that product (by user id or their account's
verified email); guest reviews are never verified, so the response never reveals whether an email bought. Imported reviews are always labeled with
their source and never verified. Asks customers for a review N days after delivery.
## Map
- `index.ts` — public API: `postReview`, `listReviews`, `productRating`, `moderateReview`, `importReviews`, `verifiedOrder`.
- `reviews.ts` — logic, stats and the `reviews.request` job (scheduled from the order `delivered` event on import).
## Integration
1. Requires @core/comments (moderation, anti-spam) and @core/orders. Env: optional `REVIEW_REQUEST_DELAY_DAYS` (default 7, `-1` disables), `SITE_URL`, `EMAIL_FROM`.
2. Migrations as in `src/lib/db/AGENTS.md`; import this module at startup.
3. Product page: `productRating(id)` for stars and JSON-LD (`jsonLd.product({ rating })` from @core/seo), `listReviews(id, { page, rating, sort })`
for the list; show a "Verified purchase" badge and, for imported ones, "Imported from <source>".
4. Review form → `postReview({ productId, rating, body, user | guest, photos }, { headers, fields })` with @core/antispam fields.
5. Moderate in the comments admin (filter `entityType=product`) and call `moderateReview` so stats update.
6. Verify: a buyer's review shows as verified after approval and the product rating changes.
## Conventions
- Explain on the page how reviews are checked (EU Omnibus Directive): verified = confirmed order.
- Show all approved reviews, including negative ones; sort options must not hide them by default.
## Don't
- Don't write, generate or buy fake reviews, and don't mark imported reviews as verified.
- Don't put `aggregateRating` in JSON-LD when there are no approved reviews.
- Don't offer rewards conditioned on a positive review.
.genpmignore 적용 후 주입될 정확한 트리입니다. 고정 대상:
// Tablas de @core/reviews. Las reseñas son comentarios (@core/comments) con valoración; aquí solo sus datos extra.
import { boolean, integer, jsonb, pgTable, text } from 'drizzle-orm/pg-core';
import { comments } from '../comments/index.ts';
import { timestamps } from '../db/index.ts';
export const reviewMeta = pgTable('review_meta', {
commentId: text('comment_id')
.primaryKey()
.references(() => comments.id, { onDelete: 'cascade' }),
productId: text('product_id').notNull(),
/** Compra comprobada: el autor tiene un pedido pagado y enviado con este producto. */
verified: boolean('verified').notNull().default(false),
orderId: text('order_id'),
/** `site` o el origen de una reseña importada (`aliexpress`, `trustpilot`…), que se muestra siempre. */
source: text('source').notNull().default('site'),
photos: jsonb('photos').$type<string[]>().notNull().default([]),
...timestamps,
});
/** Agregado por producto (se recalcula al publicar o moderar). `average` × 100. */
export const reviewStats = pgTable('review_stats', {
productId: text('product_id').primaryKey(),
count: integer('count').notNull().default(0),
average: integer('average').notNull().default(0),
histogram: jsonb('histogram').$type<[number, number, number, number, number]>().notNull().default([0, 0, 0, 0, 0]),
...timestamps,
});
이 패키지는 MCP 서버를 선언하지 않습니다.
| 버전 | 커밋 | 게시일 | 검사 |
|---|---|---|---|
| 1.0.1 | 9c40b7a | 2시간 전 | 검사 통과 |
- genpm
- @core/auth ^1.1.0@core/catalog ^1.0.0@core/comments ^1.0.0@core/db ^1.0.0@core/email ^1.0.1@core/jobs ^1.0.0@core/orders ^1.0.0
- npm
- zod ^4.0.0
- 제안됨
- GenPM은 npm 명령을 제안하고, 동의한 경우에만 실행합니다.
- 사용하는 패키지 (1)
- @core/kit-store ^1.0.0
- 검사
- 검사 통과 · 문제 0건
- 커밋
- v1.0.1 → 9c40b7a86c884d5c4711aee662c9b7d674cdbab4 · 가져온 뒤 검증됨
- 스크립트
- 없음. GenPM은 패키지 코드를 절대 실행하지 않습니다.
- 라이선스
- MIT
- 품질
- 100/100
- 인정된 라이선스충족
- AGENTS.md에 목적 설명충족
- AGENTS.md에 통합 단계충족
- AGENTS.md에 규칙 또는 금지 사항충족
- 테스트 포함충족
- 보안 검사 통과충족
- 최근 6개월 내 게시충족
- 인증된 게시자충족
- 요약과 키워드충족
- 신고
- 문제가 있나요?