Skip to content

Commit b1c528c

Browse files
Gen-AI module -> Fixes
Gen-AI module Major fixes/repairs attending project requirements and given feedback.
2 parents eeb542a + 1532cb2 commit b1c528c

File tree

76 files changed

+6111
-21153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+6111
-21153
lines changed
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
name: PR AI Summary
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
summarize:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Get PR diff
19+
id: diff
20+
run: |
21+
BASE="${{ github.event.pull_request.base.sha }}"
22+
HEAD="${{ github.event.pull_request.head.sha }}"
23+
# Trae exactamente esos commits (evita problemas de merge-base y shallow clones)
24+
git fetch --no-tags --prune --depth=1 origin $BASE $HEAD
25+
git diff $BASE $HEAD > pr.diff
26+
echo "path=pr.diff" >> $GITHUB_OUTPUT
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.11'
32+
33+
- name: Install deps
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install openai==1.* # SDK oficial
37+
38+
- name: Generate AI summary (OpenAI)
39+
id: ai
40+
continue-on-error: true
41+
env:
42+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
43+
MODEL: gpt-4o-mini
44+
run: |
45+
python - << 'PY'
46+
import os
47+
from openai import OpenAI
48+
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
49+
50+
with open("pr.diff","r",encoding="utf-8") as f:
51+
diff = f.read()[:200000] # tope por costos/ruido
52+
53+
prompt = (
54+
"You are a code reviewer. Summarize this PR in 2-20 bullets. "
55+
"Include WHAT changed, WHY it matters, RISKS, TESTS to add, and any BREAKING CHANGES. "
56+
"Highlight key features or changes. Consider markdown as the default output format."
57+
"Keep in mind the following points:"
58+
"1) If DIFF shows only documentation files (e.g., .md/.mdx/.txt/README), state 'Docs-only change', "
59+
" make clear that the change is included only in documentation files, if that is the case, "
60+
" otherwise explain normally, considering the DIFF changes like normal. "
61+
"2) Include a short list of changed file paths as extracted from DIFF. "
62+
"Keep it concise and actionable.\n\nDIFF:\n" + diff
63+
)
64+
65+
resp = client.chat.completions.create(
66+
model=os.getenv("MODEL","gpt-4o-mini"),
67+
temperature=0.2,
68+
messages=[{"role":"user","content":prompt}],
69+
)
70+
text = resp.choices[0].message.content.strip()
71+
with open("summary.txt","w",encoding="utf-8") as f:
72+
f.write(text)
73+
PY
74+
75+
- name: Heuristic fallback if AI failed
76+
if: ${{ steps.ai.outcome == 'failure' }}
77+
run: |
78+
python - << 'PY'
79+
import re, pathlib
80+
diff = pathlib.Path("pr.diff").read_text(encoding="utf-8")
81+
82+
added = len(re.findall(r"^\\+[^+].*$", diff, flags=re.M))
83+
removed = len(re.findall(r"^\\-[^-].*$", diff, flags=re.M))
84+
files = re.findall(r"^\\+\\+\\+ b/(.+)$", diff, flags=re.M)
85+
86+
lower_paths = [f.lower() for f in files]
87+
DOC_EXT = (".md", ".mdx", ".txt", ".rst", ".adoc")
88+
is_doc = lambda p: p.endswith(DOC_EXT) or "/docs/" in p or "/doc/" in p
89+
docs_only = len(files) > 0 and all(is_doc(p) for p in lower_paths)
90+
91+
# ---------- Doc-only summary ----------
92+
if docs_only:
93+
bullets_changed = []
94+
for f in files[:20]: # evita listas enormes
95+
bullets_changed.append(f"- `{f}`")
96+
doc_summary = [
97+
"## PR Summary",
98+
"",
99+
"### WHAT Changed",
100+
"- **Docs-only change** detected from DIFF.",
101+
f"- Files changed ({len(files)}):",
102+
*bullets_changed,
103+
"",
104+
"### WHY It Matters",
105+
"- Improves documentation/README clarity and onboarding experience.",
106+
"",
107+
"### RISKS",
108+
"- None to runtime behavior (documentation only).",
109+
"",
110+
"### TESTS to Add",
111+
"- N/A (no code changes).",
112+
"",
113+
"### BREAKING CHANGES",
114+
"- None.",
115+
]
116+
pathlib.Path("summary.txt").write_text("\n".join(doc_summary), encoding="utf-8")
117+
raise SystemExit(0)
118+
119+
scopes = set()
120+
for f in files:
121+
fl = f.lower()
122+
if "/controller" in fl: scopes.add("controller")
123+
elif "/service" in fl: scopes.add("service")
124+
elif "/repository" in fl or "jparepository" in diff.lower(): scopes.add("repository")
125+
elif "/entity" in fl or "/model" in fl: scopes.add("entity")
126+
elif "application" in fl and (fl.endswith(".yml") or fl.endswith(".yaml") or fl.endswith(".properties")):
127+
scopes.add("config")
128+
elif fl.endswith("test.java"): scopes.add("test")
129+
130+
scope = ",".join(sorted(scopes)) if scopes else "core"
131+
kind = "refactor"
132+
if added and not removed: kind = "feat"
133+
if removed and not added: kind = "chore"
134+
if re.search(r"@Test", diff): kind = "test"
135+
if re.search(r"fix|bug|exception|stacktrace", diff, re.I): kind = "fix"
136+
137+
subject = f"[Fallback] {kind}({scope}): {len(files)} file(s), +{added}/-{removed}"
138+
139+
bullets = []
140+
bullets.append(f"- Files changed: {len(files)}")
141+
bullets.append(f"- Lines: +{added} / -{removed}")
142+
if scopes:
143+
bullets.append(f"- Layers: {', '.join(sorted(scopes))}")
144+
if re.search(r"@Transactional", diff): bullets.append("- Touches transactional boundaries")
145+
if re.search(r"@RestController|@Controller", diff): bullets.append("- Controller changes present")
146+
if re.search(r"@Service", diff): bullets.append("- Service-layer changes present")
147+
if re.search(r"@Repository|JpaRepository", diff): bullets.append("- Repository-layer changes present")
148+
if re.search(r"todo|fixme", diff, re.I): bullets.append("- Contains TODO/FIXME markers")
149+
150+
text = subject + "\\n\\n" + "\\n".join(bullets)
151+
pathlib.Path("summary.txt").write_text(text, encoding="utf-8")
152+
PY
153+
154+
- name: Comment on PR
155+
uses: marocchino/sticky-pull-request-comment@v2
156+
with:
157+
header: ai-pr-summary
158+
recreate: true
159+
path: summary.txt

README.md

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
The system allows creating, updating, filtering, and sorting products,
55
as well as tracking key metrics like total stock, inventory value, and average price.
66

7-
The project was built with a focus on usability, clear data visualization,
8-
responsiveness and its supposed to be bug free. It supports pagination,
9-
search filters, product availability toggling, and sorting by multiple columns.
7+
The project was built with a focus of usability, clear data visualization and
8+
responsiveness, for an easy convenience store inventory management (and It's supposed to be bug free).
9+
It supports pagination, search filters, product availability toggling, and sorting by multiple columns.
1010

1111
## Tech Stack
1212

@@ -16,21 +16,7 @@ search filters, product availability toggling, and sorting by multiple columns.
1616
- **Backend:** REST API with CRUD and stock control endpoints
1717
[InventoryManagerBS](https://github.com/technologic-technologic/InventoryManagerBS.git)
1818

19-
## Features
20-
21-
- **Product CRUD**
22-
23-
- **Filtering & Searching**
24-
25-
- **Sorting**
26-
27-
- **Stock Management**
28-
29-
- **Inventory Metrics**
30-
31-
- **Pagination**
32-
33-
## Backend API (Expected)
19+
## Backend API (Expected communications)
3420

3521
Business service git URL: https://github.com/technologic-technologic/InventoryManagerBS.git
3622

@@ -49,16 +35,20 @@ The frontend expects the following API endpoints:
4935

5036
To run the frontend locally:
5137

38+
```bash
39+
# go to directory from repo location
40+
cd inventory-manager
41+
```
5242
```bash
5343
# Install dependencies
5444
npm install
5545
```
5646
```bash
5747
# Run the app on port 8080
58-
npm start
48+
npm run dev
5949
```
6050

6151
```bash
62-
# Run all tests
63-
npm test
52+
# Run tests manually
53+
npm run test
6454
```

documentation/documentation.docx

-43.8 KB
Binary file not shown.

inventory-manager/.gitignore

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2-
3-
# dependencies
4-
/node_modules
5-
/.pnp
6-
.pnp.js
7-
8-
# testing
9-
/coverage
10-
11-
# production
12-
/build
13-
14-
# misc
15-
.DS_Store
16-
.env.local
17-
.env.development.local
18-
.env.test.local
19-
.env.production.local
20-
1+
# Logs
2+
logs
3+
*.log
214
npm-debug.log*
225
yarn-debug.log*
236
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
package-lock.json
15+
16+
# Editor directories and files
17+
.vscode/*
18+
!.vscode/extensions.json
19+
.idea
20+
.idea/
21+
.DS_Store
22+
*.suo
23+
*.ntvs*
24+
*.njsproj
25+
*.sln
26+
*.sw?

inventory-manager/README.md

Lines changed: 73 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,73 @@
1-
# Getting Started with Create React App
2-
3-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4-
5-
## Available Scripts
6-
7-
In the project directory, you can run:
8-
9-
### `npm start`
10-
11-
Runs the app in the development mode.\
12-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13-
14-
The page will reload if you make edits.\
15-
You will also see any lint errors in the console.
16-
17-
### `npm test`
18-
19-
Launches the test runner in the interactive watch mode.\
20-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21-
22-
### `npm run build`
23-
24-
Builds the app for production to the `build` folder.\
25-
It correctly bundles React in production mode and optimizes the build for the best performance.
26-
27-
The build is minified and the filenames include the hashes.\
28-
Your app is ready to be deployed!
29-
30-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31-
32-
### `npm run eject`
33-
34-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35-
36-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37-
38-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39-
40-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41-
42-
## Learn More
43-
44-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45-
46-
To learn React, check out the [React documentation](https://reactjs.org/).
1+
# React + TypeScript + Vite
2+
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4+
5+
Currently, two official plugins are available:
6+
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9+
10+
## React Compiler
11+
12+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13+
14+
## Expanding the ESLint configuration
15+
16+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
17+
18+
```js
19+
export default defineConfig([
20+
globalIgnores(['dist']),
21+
{
22+
files: ['**/*.{ts,tsx}'],
23+
extends: [
24+
// Other configs...
25+
26+
// Remove tseslint.configs.recommended and replace with this
27+
tseslint.configs.recommendedTypeChecked,
28+
// Alternatively, use this for stricter rules
29+
tseslint.configs.strictTypeChecked,
30+
// Optionally, add this for stylistic rules
31+
tseslint.configs.stylisticTypeChecked,
32+
33+
// Other configs...
34+
],
35+
languageOptions: {
36+
parserOptions: {
37+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
38+
tsconfigRootDir: import.meta.dirname,
39+
},
40+
// other options...
41+
},
42+
},
43+
])
44+
```
45+
46+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47+
48+
```js
49+
// eslint.config.js
50+
import reactX from 'eslint-plugin-react-x'
51+
import reactDom from 'eslint-plugin-react-dom'
52+
53+
export default defineConfig([
54+
globalIgnores(['dist']),
55+
{
56+
files: ['**/*.{ts,tsx}'],
57+
extends: [
58+
// Other configs...
59+
// Enable lint rules for React
60+
reactX.configs['recommended-typescript'],
61+
// Enable lint rules for React DOM
62+
reactDom.configs.recommended,
63+
],
64+
languageOptions: {
65+
parserOptions: {
66+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
67+
tsconfigRootDir: import.meta.dirname,
68+
},
69+
// other options...
70+
},
71+
},
72+
])
73+
```

0 commit comments

Comments
 (0)