-
Notifications
You must be signed in to change notification settings - Fork 0
Merge pull request #59 from HuynhThuong0711/codex/github-mention-scaffold-add-web-next.js-app,-api-fastify-m-ixlftb Merge pull request #43 from HuynhThuong0711/codex/giai-thich-ma-goc-cho-nguoi-moi-7lss8n Merge pull request #39 from HuynhThuong0711/codex/github-mention-scaffold-add-web-next.js-app,-api-fastify-m Merge pull request #30 from HuynhThuong0711/codex/github-mention-scaffold-add-web-next.js-app,-api-fastify-m-ixlftb Merge pull request #16 from HuynhThuong0711/codex/github-mention-scaffold-add-web-next.js-app,-api-fastify-m-ixlftb (#20) Merge pull request #13 from HuynhThuong0711/codex/github-mention-scaffold-add-web-next.js-app,-api-fastify-m Merge pull request #12 from HuynhThuong0711/codex/giai-thich-ma-goc-cho-nguoi-moi-7lss8n Merge pull request #4 from HuynhThuong0711/codex/github-mention-scaffold-add-web-next.js-app,-api-fastify-m-ixlftb fix: add @codexpr/shared workspace and adjust config for scaffold validation (#17) #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HuynhThuong0711
wants to merge
25
commits into
feat/integrated-system
Choose a base branch
from
codex/giai-thich-ma-goc-cho-nguoi-moi-7lss8n
base: feat/integrated-system
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
9e7a2ff
Scaffold Next frontend and Fastify backend
HuynhThuong0711 5882661
Expand Next pages and Vercel deployment setup
HuynhThuong0711 20a8453
Fix shared workspace scaffold
HuynhThuong0711 6f0502e
Fix shared workspace scaffold
HuynhThuong0711 a96a1c8
Merge pull request #3 from HuynhThuong0711/codex/github-mention-scaff…
HuynhThuong0711 5d738c4
Merge pull request #4 from HuynhThuong0711/codex/github-mention-scaff…
HuynhThuong0711 cf1369a
Merge pull request #12 from HuynhThuong0711/codex/giai-thich-ma-goc-c…
HuynhThuong0711 cc994e0
Merge pull request #13 from HuynhThuong0711/codex/github-mention-scaf…
HuynhThuong0711 c4a4849
Merge pull request #15 from HuynhThuong0711/codex/github-mention-scaf…
HuynhThuong0711 5b18e5c
Merge pull request #16 from HuynhThuong0711/codex/github-mention-scaf…
HuynhThuong0711 62b68a8
Merge pull request #16 from HuynhThuong0711/codex/github-mention-scaf…
HuynhThuong0711 06a3bba
Merge pull request #16 from HuynhThuong0711/codex/github-mention-scaf…
HuynhThuong0711 fc9b349
Merge pull request #21 from HuynhThuong0711/codex/giai-thich-ma-goc-c…
HuynhThuong0711 ff8b22c
Merge pull request #30 from HuynhThuong0711/codex/github-mention-scaf…
HuynhThuong0711 b19015b
Merge pull request #39 from HuynhThuong0711/codex/github-mention-scaf…
HuynhThuong0711 1fbe45c
Merge pull request #43 from HuynhThuong0711/codex/giai-thich-ma-goc-c…
HuynhThuong0711 d7b436c
Merge pull request #59 from HuynhThuong0711/codex/github-mention-scaf…
HuynhThuong0711 cff16d7
Update packages/shared/src/index.ts
HuynhThuong0711 c323bf2
Update apps/api/src/server.ts
HuynhThuong0711 f2af404
Update apps/api/tsconfig.json
HuynhThuong0711 d625a50
Update apps/api/src/server.ts
HuynhThuong0711 4f97c2c
Update packages/shared/src/index.ts
HuynhThuong0711 a630651
Update apps/api/src/server.ts
HuynhThuong0711 f982e94
Update apps/api/src/server.ts
HuynhThuong0711 1a7519c
Update apps/api/src/server.ts
HuynhThuong0711 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "name": "@codexpr/api", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "dev": "tsx src/server.ts", | ||
| "build": "tsc -p tsconfig.json" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import type { AgentTask, ChatMessage, PullRequestDraft, RepositorySummary } from '@codexpr/shared'; | ||
|
|
||
| export class AgentService { | ||
| private readonly repositories: RepositorySummary[] = [ | ||
| { id: 'repo-1', name: 'nova-commerce', provider: 'github', defaultBranch: 'main', activeBranch: 'agent/checkout-flow', status: 'ready' }, | ||
| ]; | ||
|
|
||
| async listRepositories() { | ||
| return this.repositories; | ||
| } | ||
|
|
||
| async createChatTurn(content: string): Promise<ChatMessage> { | ||
| return { | ||
| id: `agent-${Date.now()}`, | ||
| role: 'agent', | ||
| content: `Đã nhận yêu cầu: "${content}". Gợi ý: chọn scope, xác nhận branch, chạy sandbox build.`, | ||
| createdAt: new Date().toISOString(), | ||
| suggestions: ['Xác nhận scope', 'Tạo branch', 'Chạy build', 'Mở PR'], | ||
| }; | ||
| } | ||
|
|
||
| async queueBuildTask(repositoryId: string): Promise<AgentTask> { | ||
| return { | ||
| id: `task-${Date.now()}`, | ||
| title: `Build ${repositoryId}`, | ||
| status: 'queued', | ||
| progress: 0, | ||
| logs: ['Task queued for BullMQ worker', 'Waiting for sandbox capacity'], | ||
| }; | ||
| } | ||
|
|
||
| async draftPullRequest(): Promise<PullRequestDraft> { | ||
| return { | ||
| repository: 'nova-commerce', | ||
| branch: 'agent/checkout-flow', | ||
| title: 'AI Agent build: checkout flow', | ||
| checks: ['build', 'lint', 'test', 'self-review'], | ||
| }; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| export class AnalyticsService { | ||
| summary() { | ||
| return { | ||
| tasks: 128, | ||
| pullRequests: 24, | ||
| successRate: 0.94, | ||
| estimatedCostUsd: 8.42, | ||
| updatedAt: new Date().toISOString(), | ||
| }; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| export class AuthorizationService { | ||
| private readonly requests = [ | ||
| { id: 'auth-1', app: 'Google Drive', url: 'https://drive.google.com', scope: 'Read docs', state: 'pending' }, | ||
| { id: 'auth-2', app: 'GitHub', url: 'https://github.com/rkix/nova-commerce', scope: 'Create branch + PR', state: 'approved' }, | ||
| ]; | ||
|
|
||
| listRequests() { | ||
| return this.requests; | ||
| } | ||
|
|
||
| approve(id: string) { | ||
| return { id, state: 'approved', approvedAt: new Date().toISOString() }; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export const config = { | ||
| port: Number(process.env.PORT ?? 4000), | ||
| databaseUrl: process.env.DATABASE_URL ?? 'postgres://localhost:5432/codexpr', | ||
| redisUrl: process.env.REDIS_URL ?? 'redis://localhost:6379', | ||
| githubAppId: process.env.GITHUB_APP_ID ?? 'local-dev', | ||
| sandboxDriver: process.env.SANDBOX_DRIVER ?? 'docker', | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import type { DeployTarget } from '@codexpr/shared'; | ||
|
|
||
| export class DeploymentService { | ||
| private readonly targets: DeployTarget[] = [ | ||
| { environment: 'production', status: 'processing', url: 'https://nova-commerce.vercel.app' }, | ||
| { environment: 'staging', status: 'complete', url: 'https://nova-commerce-staging.vercel.app' }, | ||
| ]; | ||
|
|
||
| listTargets() { | ||
| return this.targets; | ||
| } | ||
|
|
||
| startSetup(environment: DeployTarget['environment']) { | ||
| return { | ||
| environment, | ||
| status: 'processing' as const, | ||
| progress: 12, | ||
| logs: ['Validate Vercel project', 'Sync encrypted environment variables', 'Prepare build command'], | ||
| }; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import Fastify from 'fastify'; | ||
| import cors from '@fastify/cors'; | ||
| import websocket from '@fastify/websocket'; | ||
| import { z } from 'zod'; | ||
| import { AgentService } from './agent-service.js'; | ||
| import { AnalyticsService } from './analytics-service.js'; | ||
| import { AuthorizationService } from './auth-service.js'; | ||
| import { config } from './config.js'; | ||
| import { DeploymentService } from './deployment-service.js'; | ||
|
|
||
| const server = Fastify({ logger: true }); | ||
| const agentService = new AgentService(); | ||
| const deploymentService = new DeploymentService(); | ||
| const authorizationService = new AuthorizationService(); | ||
| const analyticsService = new AnalyticsService(); | ||
|
|
||
| await server.register(cors, { origin: true }); | ||
|
HuynhThuong0711 marked this conversation as resolved.
HuynhThuong0711 marked this conversation as resolved.
HuynhThuong0711 marked this conversation as resolved.
HuynhThuong0711 marked this conversation as resolved.
|
||
| await server.register(websocket); | ||
|
|
||
| server.get('/health', async () => ({ status: 'ok', service: 'codexpr-api' })); | ||
|
|
||
| server.get('/repositories', async () => agentService.listRepositories()); | ||
|
|
||
| server.post('/chat', async (request) => { | ||
| const body = z.object({ content: z.string().min(1) }).parse(request.body); | ||
| return agentService.createChatTurn(body.content); | ||
| }); | ||
|
HuynhThuong0711 marked this conversation as resolved.
HuynhThuong0711 marked this conversation as resolved.
|
||
|
|
||
| server.post('/tasks/build', async (request) => { | ||
| const body = z.object({ repositoryId: z.string().min(1) }).parse(request.body); | ||
| return agentService.queueBuildTask(body.repositoryId); | ||
| }); | ||
|
|
||
| server.post('/pull-requests/draft', async () => agentService.draftPullRequest()); | ||
|
|
||
| server.get('/deploy/targets', async () => deploymentService.listTargets()); | ||
|
|
||
| server.post('/deploy/setup', async (request) => { | ||
| const body = z.object({ environment: z.enum(['production', 'staging']) }).parse(request.body); | ||
| return deploymentService.startSetup(body.environment); | ||
| }); | ||
|
|
||
| server.get('/auth/requests', async () => authorizationService.listRequests()); | ||
|
|
||
| server.post('/auth/requests/:id/approve', async (request) => { | ||
| const params = z.object({ id: z.string().min(1) }).parse(request.params); | ||
| return authorizationService.approve(params.id); | ||
|
HuynhThuong0711 marked this conversation as resolved.
HuynhThuong0711 marked this conversation as resolved.
|
||
| }); | ||
|
HuynhThuong0711 marked this conversation as resolved.
HuynhThuong0711 marked this conversation as resolved.
|
||
|
|
||
| server.get('/analytics/summary', async () => analyticsService.summary()); | ||
|
|
||
| server.get('/logs/stream', { websocket: true }, (socket) => { | ||
| const events = ['Clone Repository', 'Install', 'Edit code', 'Run tests', 'Commit', 'Push branch', 'Create Pull Request']; | ||
| let index = 0; | ||
| const timer = setInterval(() => { | ||
| if (socket.readyState !== 1) { clearInterval(timer); return; } | ||
| socket.send(JSON.stringify({ event: events[index], at: new Date().toISOString() })); | ||
| index += 1; | ||
| if (index >= events.length) clearInterval(timer); | ||
| }, 1000); | ||
| socket.on('close', () => clearInterval(timer)); | ||
| }); | ||
|
HuynhThuong0711 marked this conversation as resolved.
|
||
|
|
||
| await server.listen({ port: config.port, host: '0.0.0.0' }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "extends": "../../tsconfig.json", | ||
| "compilerOptions": { | ||
| "outDir": "dist", | ||
| "rootDir": "src", | ||
| "noEmit": false, | ||
| "module": "NodeNext", | ||
| "moduleResolution": "NodeNext", | ||
| "types": ["node"] | ||
| }, | ||
| "include": ["src/**/*.ts"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { AppShell, PageHero } from '../../components/app-shell'; | ||
| import { AnalyticsDashboard } from '../../components/operations'; | ||
|
|
||
| export default function AnalyticsPage() { | ||
| return <AppShell><PageHero eyebrow="Analytics" title="Dashboard phân tích realtime" description="Tổng hợp task, Pull Request, tỉ lệ thành công, token cost và trạng thái workflow từ toàn bộ hệ thống." /><AnalyticsDashboard /></AppShell>; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.