Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions backend/src/build-system/node/ux_sitemap_document/prompt/prompt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Define and export the system prompts object
export const prompts = {
generateUxsmdrompt: (
projectName: string,
prdDocument: string,
platform: string,
): string => {
return `You are an expert frontend develper and ux designer. Your job is to analyze and expand upon the details provided, generating a Full UX Sitemap Document based on the following inputs:
- Project name: ${projectName}
- product requirements document: ${prdDocument}
- Platform: ${platform}

Follow these rules as a guide to ensure clarity and completeness in your UX Sitemap Document.
1, Write you result in markdown
2, Your reply should start with : "\`\`\`UXSitemap" and end with "\`\`\`", Use proper markdown syntax for headings, subheadings, and hierarchical lists.
3. **Comprehensive Analysis**: Thoroughly parse the PRD to identify all core features, functionalities, and user stories.
- Focus on creating a hierarchical sitemap that covers each major section, with relevant sub-sections, pages, and key interactions.
- Ensure all primary and secondary user journeys identified in the PRD are clearly reflected.

4. **Page and Navigation Structure**: Break down the sitemap into main sections, secondary sections, and individual screens.
- **Main Sections**: Identify primary sections (e.g., Home, User Account, Product Catalog) based on project requirements.
- **Secondary Sections**: Include sub-sections under each main section (e.g., "Profile" and "Order History" under "User Account").
- **Screens and Interactions**: List specific screens and interactions that users encounter within each flow.

5. **Detailed User Journeys**:
- For every user story described in the PRD, map out the step-by-step navigation path.
- Highlight sequences (e.g., 1. Home > 1.1. Explore > 1.1.1. Product Details).

6. **Thorough Coverage**:
- Ensure the sitemap is fully comprehensive. If any feature from the PRD is not covered or any user journey is missing, add it to the sitemap.
- Consider the target audience and validate that all expected navigation flows and screens meet user needs.

7. Ask Your self:
- Am I cover all the product requirement document?
- Am I Cover all the gloabal UI?
- Am I Cover all unique UI?
- Am I cover all the view that expect by user?
- what is all the details about UI?
- Am I cover all the cases? Is the final result 100% complete?

Remeber your result will be directly be use in the deveolpment. Make sure is 100% complete.
`;
Comment on lines +8 to +42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Clean up prompt template content for clarity and professionalism

The prompt template contains several issues that should be addressed:

  1. Typos and grammatical errors:

    • Line 8: "develper" → "developer"
    • Line 34-39: Multiple spelling/grammar issues ("gloabal", "Am I cover", etc.)
    • Line 41: "Remeber", "deveolpment"
  2. Inconsistent formatting:

    • Line 14: Numbering uses comma instead of period "1,"
    • Line 15: Inconsistent quote marks and spacing
    • Lines 34-39: Inconsistent capitalization

Apply this diff to improve the content:

-    return `You are an expert frontend develper and ux designer. Your job is to analyze and expand upon the details provided, generating a Full UX Sitemap Document based on the following inputs:  
+    return `You are an expert frontend developer and UX designer. Your job is to analyze and expand upon the details provided, generating a Full UX Sitemap Document based on the following inputs:
-       - Project name: ${projectName}
-       - product requirements document: ${prdDocument}
-       - Platform: ${platform}
+    - Project Name: ${projectName}
+    - Product Requirements Document: ${prdDocument}
+    - Platform: ${platform}

     Follow these rules as a guide to ensure clarity and completeness in your UX Sitemap Document.
-    1, Write you result in markdown
-    2, Your reply should start with : "\`\`\`UXSitemap" and end with "\`\`\`", Use proper markdown syntax for headings, subheadings, and hierarchical lists.
+    1. Write your result in markdown
+    2. Your reply should start with "\`\`\`UXSitemap" and end with "\`\`\`". Use proper markdown syntax for headings, subheadings, and hierarchical lists.

-7. Ask Your self:
-    - Am I cover all the product requirement document?
-    - Am I Cover all the gloabal UI?
-    - Am I Cover all unique UI?
-    - Am I cover all the view that expect by user?
-    - what is all the details about UI?
-    - Am I cover all the cases? Is the final result 100% complete?
+    7. Verification Checklist:
+    - Have I covered all requirements from the PRD?
+    - Have I included all global UI elements?
+    - Have I documented all unique UI components?
+    - Have I addressed all expected user views?
+    - Have I detailed all UI specifications?
+    - Have I covered all edge cases and scenarios?
 
-Remeber your result will be directly be use in the deveolpment. Make sure is 100% complete.
+    Remember: Your output will be used directly in development. Ensure it is complete and accurate.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return `You are an expert frontend develper and ux designer. Your job is to analyze and expand upon the details provided, generating a Full UX Sitemap Document based on the following inputs:
- Project name: ${projectName}
- product requirements document: ${prdDocument}
- Platform: ${platform}
Follow these rules as a guide to ensure clarity and completeness in your UX Sitemap Document.
1, Write you result in markdown
2, Your reply should start with : "\`\`\`UXSitemap" and end with "\`\`\`", Use proper markdown syntax for headings, subheadings, and hierarchical lists.
3. **Comprehensive Analysis**: Thoroughly parse the PRD to identify all core features, functionalities, and user stories.
- Focus on creating a hierarchical sitemap that covers each major section, with relevant sub-sections, pages, and key interactions.
- Ensure all primary and secondary user journeys identified in the PRD are clearly reflected.
4. **Page and Navigation Structure**: Break down the sitemap into main sections, secondary sections, and individual screens.
- **Main Sections**: Identify primary sections (e.g., Home, User Account, Product Catalog) based on project requirements.
- **Secondary Sections**: Include sub-sections under each main section (e.g., "Profile" and "Order History" under "User Account").
- **Screens and Interactions**: List specific screens and interactions that users encounter within each flow.
5. **Detailed User Journeys**:
- For every user story described in the PRD, map out the step-by-step navigation path.
- Highlight sequences (e.g., 1. Home > 1.1. Explore > 1.1.1. Product Details).
6. **Thorough Coverage**:
- Ensure the sitemap is fully comprehensive. If any feature from the PRD is not covered or any user journey is missing, add it to the sitemap.
- Consider the target audience and validate that all expected navigation flows and screens meet user needs.
7. Ask Your self:
- Am I cover all the product requirement document?
- Am I Cover all the gloabal UI?
- Am I Cover all unique UI?
- Am I cover all the view that expect by user?
- what is all the details about UI?
- Am I cover all the cases? Is the final result 100% complete?
Remeber your result will be directly be use in the deveolpment. Make sure is 100% complete.
`;
return `You are an expert frontend developer and UX designer. Your job is to analyze and expand upon the details provided, generating a Full UX Sitemap Document based on the following inputs:
- Project Name: ${projectName}
- Product Requirements Document: ${prdDocument}
- Platform: ${platform}
Follow these rules as a guide to ensure clarity and completeness in your UX Sitemap Document.
1. Write your result in markdown
2. Your reply should start with "\`\`\`UXSitemap" and end with "\`\`\`". Use proper markdown syntax for headings, subheadings, and hierarchical lists.
3. **Comprehensive Analysis**: Thoroughly parse the PRD to identify all core features, functionalities, and user stories.
- Focus on creating a hierarchical sitemap that covers each major section, with relevant sub-sections, pages, and key interactions.
- Ensure all primary and secondary user journeys identified in the PRD are clearly reflected.
4. **Page and Navigation Structure**: Break down the sitemap into main sections, secondary sections, and individual screens.
- **Main Sections**: Identify primary sections (e.g., Home, User Account, Product Catalog) based on project requirements.
- **Secondary Sections**: Include sub-sections under each main section (e.g., "Profile" and "Order History" under "User Account").
- **Screens and Interactions**: List specific screens and interactions that users encounter within each flow.
5. **Detailed User Journeys**:
- For every user story described in the PRD, map out the step-by-step navigation path.
- Highlight sequences (e.g., 1. Home > 1.1. Explore > 1.1.1. Product Details).
6. **Thorough Coverage**:
- Ensure the sitemap is fully comprehensive. If any feature from the PRD is not covered or any user journey is missing, add it to the sitemap.
- Consider the target audience and validate that all expected navigation flows and screens meet user needs.
7. Verification Checklist:
- Have I covered all requirements from the PRD?
- Have I included all global UI elements?
- Have I documented all unique UI components?
- Have I addressed all expected user views?
- Have I detailed all UI specifications?
- Have I covered all edge cases and scenarios?
Remember: Your output will be used directly in development. Ensure it is complete and accurate.
`;

},
};
53 changes: 53 additions & 0 deletions backend/src/build-system/node/ux_sitemap_document/uxsmd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { BuildHandler, BuildResult } from 'src/build-system/types';
import { BuilderContext } from 'src/build-system/context';
import { prompts } from './prompt/prompt';
import { ModelProvider } from 'src/common/model-provider';
import { Logger } from '@nestjs/common';

export class UXSMDHandler implements BuildHandler {
readonly id = 'op:UXSMD::STATE:GENERATE';
readonly logger: Logger = new Logger('UXSMDHandler');

async run(context: BuilderContext, args: unknown): Promise<BuildResult> {
this.logger.log('Generating UXSMD...');

// Extract project data from the context
const projectName =
context.getData('projectName') || 'Default Project Name';
const platform = context.getData('platform') || 'Default Platform';

// Generate the prompt dynamically
const prompt = prompts.generateUxsmdrompt(
projectName,
args as string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add type validation for args parameter

The direct type casting of args to string is unsafe and could lead to runtime errors if the input is not a string.

Apply this diff to add type validation:

-      args as string,
+      typeof args === 'string' ? args : String(args),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
args as string,
typeof args === 'string' ? args : String(args),

platform,
);

// Send the prompt to the LLM server and process the response
const uxsmdContent = await this.generateUXSMDFromLLM(prompt);

// Store the generated document in the context
context.setData('uxsmdDocument', uxsmdContent);

return {
success: true,
data: uxsmdContent,
};
}

private async generateUXSMDFromLLM(prompt: string): Promise<string> {
const modelProvider = ModelProvider.getInstance();

const model = 'gpt-3.5-turbo';

const prdContent = modelProvider.chatSync(
{
content: prompt,
},
model,
);

this.logger.log('Received full UXSMD content from LLM server.');
return prdContent;
Comment on lines +43 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use asynchronous method chat instead of chatSync and fix variable naming

Using the synchronous method chatSync inside an asynchronous function can block the event loop and degrade performance. Additionally, the variable prdContent is inconsistent with uxsmdContent used elsewhere. It's better to use the asynchronous chat method and maintain consistent variable names.

Apply this diff to use the asynchronous chat method and correct variable names:

-const prdContent = modelProvider.chatSync(
-  {
-    content: prompt,
-  },
-  model,
-);
+const uxsmdContent = await modelProvider.chat(
+  [
+    {
+      role: 'user',
+      content: prompt,
+    },
+  ],
+  model,
+);

Update the log message and return statement accordingly:

-this.logger.log('Received full UXSMD content from LLM server.');
-return prdContent;
+this.logger.log('Received UXSMD content from LLM server.');
+return uxsmdContent;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const prdContent = modelProvider.chatSync(
{
content: prompt,
},
model,
);
this.logger.log('Received full UXSMD content from LLM server.');
return prdContent;
const uxsmdContent = await modelProvider.chat(
[
{
role: 'user',
content: prompt,
},
],
model,
);
this.logger.log('Received UXSMD content from LLM server.');
return uxsmdContent;

}
}
Loading