Items Generator Module
The Items Generator module handles individual item operations within a work -- submitting new items, removing existing items, and updating item metadata. It operates directly on the data Git repository using branch-based workflows with optional pull request creation.
Sources:
packages/agent/src/items-generator/items-generator.module.tspackages/agent/src/items-generator/item-submission.service.tspackages/agent/src/items-generator/dto/packages/agent/src/items-generator/schemas/item-extraction.schemas.ts
Module Structure
items-generator/
dto/
create-items-generator.dto.ts # Generation trigger DTOs
submit-item.dto.ts # Single item submission
submit-item-response.dto.ts # Submission response
remove-item.dto.ts # Item removal request
remove-item-response.dto.ts # Removal response
update-item.dto.ts # Metadata update
extract-item-details.dto.ts # Detail extraction request
extract-item-details-response.dto.ts
items-generator-response.dto.ts # Generation response
delete-items-generator.dto.ts # Work deletion
index.ts # Barrel export
schemas/
item-extraction.schemas.ts # Zod schemas for AI extraction
item-submission.service.ts # Core submission logic
items-generator.module.ts # NestJS module definition
index.ts # Public API
NestJS Module
@Module({
imports: [DatabaseModule, FacadesModule, PipelineModule],
providers: [ItemSubmissionService],
exports: [ItemSubmissionService]
})
export class ItemsGeneratorModule {}
The module is intentionally lightweight. Bulk generation is handled by the PipelineOrchestratorService; this module focuses on single-item operations.
ItemSubmissionService
Submit Item
The submitItem method adds a new item to a work's data repository:
const result = await submissionService.submitItem(work, user, {
name: 'VS Code',
description: 'A popular code editor by Microsoft',
source_url: 'https://code.visualstudio.com',
category: 'Editors',
tags: ['ide', 'microsoft', 'open-source']
});
Workflow
- Clone/pull the data repository using the work owner's credentials.
- Read config to check autoapproval settings.
- Determine commit strategy:
| Condition | Strategy |
|---|---|
create_pull_request === true | Always create a PR (forced) |
pay_and_publish_now === true | Direct commit to main |
config.autoapproval === true | Direct commit to main |
| Default | Create a PR |
-
Branch management:
- For PRs: Create a new branch named
item-{slugified-name}-{timestamp}. - For direct commits: Switch to the main branch.
- For PRs: Create a new branch named
-
Prepare item data with the
MutableItemDatastructure. -
Capture screenshot if the item has a
source_urland the screenshot service is available. -
Write files to the data repository: item JSON and item markdown.
-
Commit and push using the current user as the committer (for Git attribution).
-
Create PR (if applicable) with a descriptive title and body including badge information.
Response Types
// Direct commit response
{
status: 'success',
slug: 'my-work',
item_name: 'VS Code',
item_slug: 'vs-code',
direct_commit: true,
item: { /* full item data */ },
}
// PR creation response
{
status: 'success',
slug: 'my-work',
item_name: 'VS Code',
item_slug: 'vs-code',
pr_number: 42,
pr_url: 'https://github.com/...',
pr_branch_name: 'item-vs-code-1234567890',
auto_merged: false,
item: { /* full item data */ },
}
Remove Item
The removeItem method removes an item from the data repository:
const result = await submissionService.removeItem(work, user, {
item_slug: 'vs-code',
reason: 'No longer maintained',
create_pull_request: true
});
Workflow
- Clone/pull the data repository.
- Verify the item exists via
data.itemExists(). - Read item details for the response.
- Create a branch (if PR requested) or switch to main.
- Remove the item work via
data.removeItem(). - Commit with an optional reason in the message.
- Push and optionally create a PR.
Update Item Metadata
The updateItem method modifies metadata fields on an existing item:
const result = await submissionService.updateItem(work, user, {
item_slug: 'vs-code',
featured: true,
order: 1,
create_pull_request: false
});
Supports updating featured status and order position. Uses the same branch/PR strategy as other operations.
DTOs
SubmitItemDto
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Item display name |
description | string | Yes | Item description |
source_url | string | Yes | Canonical URL (must be HTTP/HTTPS) |
category | string | Conditional | Single category (required if categories is empty) |
categories | string[] | Conditional | Category array (required if category is empty) |
tags | string[] | No | Keywords and labels |
featured | boolean | No | Featured flag (default: false) |
order | number | No | Sort order (min: 0) |
slug | string | No | URL-friendly identifier (auto-generated from name) |
brand | string | No | Brand/manufacturer name |
brand_logo_url | string | No | Brand logo URL |
images | string[] | No | Image URLs |
pay_and_publish_now | boolean | No | Skip PR, commit directly |
create_pull_request | boolean | No | Force PR creation |
RemoveItemDto
| Field | Type | Required | Description |
|---|---|---|---|
item_slug | string | Yes | Slug of the item to remove |
reason | string | No | Reason for removal (included in commit message) |
create_pull_request | boolean | No | Whether to create a PR |