prsmith 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - name: Use Node.js
15
+ uses: actions/setup-node@v4
16
+ with:
17
+ node-version: '20.x'
18
+ cache: 'npm'
19
+ - run: npm ci
20
+ - run: npm run lint
21
+ - run: npm run test
@@ -0,0 +1,2 @@
1
+ npm run lint
2
+ npm test
package/.prettierrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "semi": true,
3
+ "singleQuote": true,
4
+ "tabWidth": 2,
5
+ "trailingComma": "es5"
6
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [1.0.0] - 2026-05-31
6
+
7
+ ### Added
8
+ - Interactive CLI prompts to generate PR review comments.
9
+ - Formatter to generate markdown based on severity, title, issue, and fix.
10
+ - Initial setup for linting, testing, and CI.
package/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ MIT License
2
+
3
+ Copyright Tarunya Kesharwani (tarunyak) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
package/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # PRSmith
2
+
3
+ [![npm version](https://img.shields.io/npm/v/prsmith.svg?style=flat-square)](https://www.npmjs.com/package/prsmith)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://opensource.org/licenses/MIT)
5
+ [![CI](https://img.shields.io/github/actions/workflow/status/TarunyaProgrammer/PRSmith_NPMPackage/ci.yml?branch=main&style=flat-square)](https://github.com/TarunyaProgrammer/PRSmith_NPMPackage/actions)
6
+
7
+ Forge professional pull request review comments directly from the terminal.
8
+
9
+ PRSmith streamlines the process of writing code reviews by providing an interactive prompt that generates consistently formatted, polite, and actionable Markdown comments.
10
+
11
+ ---
12
+
13
+ ## Architecture Flow
14
+
15
+ The tool operates via a straightforward interactive flow, generating structured markdown from your inputs.
16
+
17
+ ```mermaid
18
+ graph TD
19
+ A[User runs 'prsmith'] --> B{Interactive Prompts}
20
+ B -->|Severity| C[Select Critical, Major, Minor, Suggestion]
21
+ B -->|Title| D[Enter Title]
22
+ B -->|Issue| E[Describe Problem]
23
+ B -->|Fix| F[Suggest Fix]
24
+ C & D & E & F --> G[Markdown Generator]
25
+ G --> H[Print Formatted PR Comment]
26
+ ```
27
+
28
+ ---
29
+
30
+ ## Installation
31
+
32
+ Install globally to use it anywhere on your machine.
33
+
34
+ ```bash
35
+ npm install -g prsmith
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ Simply run the command in your terminal:
41
+
42
+ ```bash
43
+ prsmith
44
+ ```
45
+
46
+ ## Example Interaction
47
+
48
+ **Input:**
49
+ - Severity: `Critical`
50
+ - Title: `Scope Issue`
51
+ - Issue: `Utility functions are nested incorrectly.`
52
+ - Suggested Fix: `Move them to module scope.`
53
+
54
+ **Output:**
55
+
56
+ ```md
57
+ ### Critical: Scope Issue
58
+
59
+ The current implementation introduces a critical issue.
60
+
61
+ **Problem**
62
+
63
+ Utility functions are nested incorrectly.
64
+
65
+ **Suggested Fix**
66
+
67
+ Move them to module scope.
68
+ ```
69
+
70
+ ## Development & Contribution
71
+
72
+ To set up the project locally:
73
+
74
+ ```bash
75
+ # Install dependencies
76
+ npm install
77
+
78
+ # Run the CLI locally
79
+ npm start
80
+
81
+ # Run unit tests
82
+ npm test
83
+
84
+ # Lint the codebase
85
+ npm run lint
86
+
87
+ # Format the code
88
+ npm run format
89
+ ```
90
+
91
+ ## License
92
+
93
+ This project is licensed under the MIT License.
package/bin/cli.js ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+
3
+ import chalk from "chalk";
4
+ import { getReviewData } from "../src/prompts.js";
5
+ import { generateMarkdown } from "../src/formatter.js";
6
+
7
+ async function main() {
8
+ try {
9
+ console.log(
10
+ chalk.cyan("\nPRSmith - Professional PR Review Comment Generator\n")
11
+ );
12
+
13
+ const data = await getReviewData();
14
+
15
+ const markdown = generateMarkdown(data);
16
+
17
+ console.log(chalk.green("\nGenerated Comment:\n"));
18
+ console.log(markdown);
19
+ } catch (error) {
20
+ if (error.name === "ExitPromptError") {
21
+ console.log(chalk.yellow("\nYou have quit in b/w :) \n"));
22
+ process.exit(0);
23
+ }
24
+ console.error(chalk.red("\nSomething went wrong.\n"));
25
+ console.error(error);
26
+ process.exit(1);
27
+ }
28
+ }
29
+
30
+ main();
@@ -0,0 +1,18 @@
1
+ import js from "@eslint/js";
2
+
3
+ export default [
4
+ js.configs.recommended,
5
+ {
6
+ languageOptions: {
7
+ ecmaVersion: "latest",
8
+ sourceType: "module",
9
+ globals: {
10
+ process: "readonly",
11
+ console: "readonly",
12
+ },
13
+ },
14
+ rules: {
15
+ "no-unused-vars": "warn",
16
+ },
17
+ },
18
+ ];
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "prsmith",
3
+ "version": "1.0.0",
4
+ "description": "Forge professional pull request review comments from simple prompts.",
5
+ "keywords": [
6
+ "pull-request",
7
+ "code-review",
8
+ "github",
9
+ "cli",
10
+ "developer-tools"
11
+ ],
12
+ "license": "MIT",
13
+ "author": "tarunyak",
14
+ "type": "module",
15
+ "main": "index.js",
16
+ "bin": {
17
+ "prsmith": "bin/cli.js"
18
+ },
19
+ "scripts": {
20
+ "start": "node bin/cli.js",
21
+ "test": "vitest run",
22
+ "lint": "eslint .",
23
+ "format": "prettier --write .",
24
+ "prepare": "husky"
25
+ },
26
+ "dependencies": {
27
+ "chalk": "^5.6.2",
28
+ "commander": "^15.0.0",
29
+ "inquirer": "^14.0.1"
30
+ },
31
+ "devDependencies": {
32
+ "@eslint/js": "^10.0.1",
33
+ "eslint": "^10.4.1",
34
+ "husky": "^9.1.7",
35
+ "prettier": "^3.8.3",
36
+ "vitest": "^4.1.7"
37
+ }
38
+ }
@@ -0,0 +1,20 @@
1
+ import { templates } from "./templates.js";
2
+
3
+ export function generateMarkdown(data) {
4
+ const intro =
5
+ templates[data.severity] ||
6
+ "The current implementation requires attention.";
7
+
8
+ return `### ${data.severity}: ${data.title}
9
+
10
+ ${intro}
11
+
12
+ **Problem**
13
+
14
+ ${data.issue}
15
+
16
+ **Suggested Fix**
17
+
18
+ ${data.fix}
19
+ `;
20
+ }
@@ -0,0 +1 @@
1
+ // generator.js
package/src/prompts.js ADDED
@@ -0,0 +1,27 @@
1
+ import inquirer from "inquirer";
2
+
3
+ export async function getReviewData() {
4
+ return inquirer.prompt([
5
+ {
6
+ type: "select",
7
+ name: "severity",
8
+ message: "Select severity:",
9
+ choices: ["Critical", "Major", "Minor", "Suggestion"],
10
+ },
11
+ {
12
+ type: "input",
13
+ name: "title",
14
+ message: "Review title:",
15
+ },
16
+ {
17
+ type: "input",
18
+ name: "issue",
19
+ message: "Describe the issue:",
20
+ },
21
+ {
22
+ type: "input",
23
+ name: "fix",
24
+ message: "Suggested fix:",
25
+ },
26
+ ]);
27
+ }
@@ -0,0 +1,13 @@
1
+ export const templates = {
2
+ Critical:
3
+ "The current implementation introduces a critical issue.",
4
+
5
+ Major:
6
+ "The current implementation introduces a significant issue.",
7
+
8
+ Minor:
9
+ "The current implementation could be improved.",
10
+
11
+ Suggestion:
12
+ "The implementation works, but there may be a cleaner approach."
13
+ };
@@ -0,0 +1,32 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { generateMarkdown } from "../src/formatter.js";
3
+
4
+ describe("formatter.js", () => {
5
+ it("should generate proper markdown for Critical severity", () => {
6
+ const data = {
7
+ severity: "Critical",
8
+ title: "Memory Leak",
9
+ issue: "The connection is never closed.",
10
+ fix: "Add a finally block to close the connection."
11
+ };
12
+
13
+ const markdown = generateMarkdown(data);
14
+
15
+ expect(markdown).toContain("### Critical: Memory Leak");
16
+ expect(markdown).toContain("The current implementation introduces a critical issue.");
17
+ expect(markdown).toContain("The connection is never closed.");
18
+ expect(markdown).toContain("Add a finally block to close the connection.");
19
+ });
20
+
21
+ it("should fallback to a default intro if severity is unknown", () => {
22
+ const data = {
23
+ severity: "Unknown",
24
+ title: "Something",
25
+ issue: "Bad code.",
26
+ fix: "Fix code."
27
+ };
28
+
29
+ const markdown = generateMarkdown(data);
30
+ expect(markdown).toContain("The current implementation requires attention.");
31
+ });
32
+ });