lunar-skills 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.
- package/.gemini/skills/anti-ai-ui-developer/SKILL.md +18 -0
- package/.gemini/skills/auto-idea-to-product/SKILL.md +29 -0
- package/.gemini/skills/master-app-builder/SKILL.md +26 -0
- package/.gemini/skills/master-orchestrator/SKILL.md +14 -0
- package/.gemini/skills/qa-circuit-breaker/SKILL.md +25 -0
- package/.gemini/skills/security-architect/SKILL.md +21 -0
- package/.gemini/skills/skills-manager/SKILL.md +8 -0
- package/.gemini/skills/system-architecture-diagrammer/SKILL.md +14 -0
- package/README.md +45 -0
- package/bin/cli.js +16 -0
- package/data/cards.json +91 -0
- package/data/milestones/MILESTONE-001.json +102 -0
- package/data/milestones/MILESTONE-002.json +91 -0
- package/data/milestones/MILESTONE-003.json +105 -0
- package/data/milestones/MILESTONE-004.json +112 -0
- package/data/milestones/MILESTONE-005.json +112 -0
- package/data/milestones/MILESTONE-006.json +112 -0
- package/data/milestones/MILESTONE-007.json +112 -0
- package/docs/adr/ADR-001.md +31 -0
- package/docs/adr/ADR-002.md +28 -0
- package/docs/api/api-architecture.md +70 -0
- package/docs/api/authentication-flow.md +31 -0
- package/docs/api/data-flow.md +21 -0
- package/docs/architecture/dependency-diagram.md +37 -0
- package/docs/architecture/feature-tree.md +35 -0
- package/docs/architecture/folder-structure.md +81 -0
- package/docs/architecture/module-diagram.md +43 -0
- package/docs/architecture/package-diagram.md +26 -0
- package/docs/architecture/system-architecture.md +42 -0
- package/docs/architecture.html +193 -0
- package/docs/database/database.md +67 -0
- package/docs/deployment/deployment.md +26 -0
- package/docs/infrastructure/cicd.md +26 -0
- package/docs/infrastructure/infrastructure.md +21 -0
- package/docs/infrastructure/logging.md +24 -0
- package/docs/infrastructure/monitoring.md +18 -0
- package/docs/security/security.md +35 -0
- package/docs/workflow/sequence-card-creation.md +26 -0
- package/docs/workflow/sequence-compaction.md +25 -0
- package/docs/workflow/sequence-scope-validation.md +20 -0
- package/index.html +540 -0
- package/package.json +38 -0
- package/scripts/card-manager.js +162 -0
- package/scripts/circuit-breaker.js +32 -0
- package/scripts/install-skills.js +60 -0
- package/scripts/mock-server.js +29 -0
- package/scripts/scope-enforcer.js +80 -0
- package/scripts/verify-system.js +88 -0
- package/src/index.js +102 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# 5. Feature Tree Documentation
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## 🌲 5.1 System Feature Tree Diagram
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
graph TD
|
|
9
|
+
Root["PROACTIVE AI SKILL SYSTEM"] --> F1["Card & Prompt Management"]
|
|
10
|
+
Root --> F2["Scope Boundary Guard"]
|
|
11
|
+
Root --> F3["Hierarchical Card Compaction"]
|
|
12
|
+
Root --> F4["Visual System Diagrammer"]
|
|
13
|
+
Root --> F5["Multi-Category Tool Advisor"]
|
|
14
|
+
|
|
15
|
+
F1 --> F1_1["Auto-Create Card from Prompt"]
|
|
16
|
+
F1 --> F1_2["Auto-State Transition (Active -> DONE)"]
|
|
17
|
+
F1 --> F1_3["Proactive Idle Scope Trigger (Cạn Scope Notification)"]
|
|
18
|
+
|
|
19
|
+
F2 --> F2_1["Scope Rule Matrix (SCOPE_DIAGRAM, SCOPE_CORE_ENGINE...)"]
|
|
20
|
+
F2 --> F2_2["File Path Boundary Validation"]
|
|
21
|
+
F2 --> F2_3["Scope Violation Blocker"]
|
|
22
|
+
|
|
23
|
+
F3 --> F3_1["Level 0: Active Cards (< 10 Cards in cards.json)"]
|
|
24
|
+
F3 --> F3_2["Level 1: Milestone Compaction (10-in-1 JSON File)"]
|
|
25
|
+
F3 --> F3_3["Level 2: Executive Macro Report (100-in-1 Markdown Report)"]
|
|
26
|
+
|
|
27
|
+
F4 --> F4_1["C4 Architecture Mermaid Graph"]
|
|
28
|
+
F4 --> F4_2["Compaction Flowchart Visualizer"]
|
|
29
|
+
F4 --> F4_3["Live Card Status Tracker Table"]
|
|
30
|
+
|
|
31
|
+
F5 --> F5_1["Static Web Advice (HTML5 + Cloudflare/Vercel)"]
|
|
32
|
+
F5 --> F5_2["Cloud Backend Advice (Supabase / Firebase)"]
|
|
33
|
+
F5 --> F5_3["Payment Advice (VietQR / PayOS / Stripe)"]
|
|
34
|
+
F5 --> F5_4["Notification Advice (Telegram / Zalo ZNS / Resend)"]
|
|
35
|
+
```
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# 1. Folder Structure Documentation
|
|
2
|
+
|
|
3
|
+
**Project Name:** Universal Proactive AI Skill System & Card Compaction Architecture
|
|
4
|
+
**Generated At:** 2026-07-27
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 🌳 1.1 Tree Structure (Source Code Fact)
|
|
9
|
+
|
|
10
|
+
```text
|
|
11
|
+
/Volumes/sdd anh/skill/
|
|
12
|
+
├── README.md # Open-source community installation & usage guide
|
|
13
|
+
├── package.json # Node.js manifest & npm scripts
|
|
14
|
+
├── index.html # Live Mermaid.js visual architecture dashboard
|
|
15
|
+
│
|
|
16
|
+
├── .gemini/
|
|
17
|
+
│ └── skills/ # Custom AI Skill Definitions
|
|
18
|
+
│ ├── auto-idea-to-product/
|
|
19
|
+
│ │ └── SKILL.md # Proactive Card Engine & Compaction Skill
|
|
20
|
+
│ └── system-architecture-diagrammer/
|
|
21
|
+
│ └── SKILL.md # Visual System Diagrammer Skill
|
|
22
|
+
│
|
|
23
|
+
├── data/ # Persistent Data Storage Layer
|
|
24
|
+
│ ├── cards.json # Level 0: Active task cards array (Max < 10)
|
|
25
|
+
│ ├── milestones/ # Level 1: Compacted 10-in-1 milestone JSON files
|
|
26
|
+
│ └── reports/ # Level 2: Compacted 100-in-1 executive markdown reports
|
|
27
|
+
│
|
|
28
|
+
├── scripts/ # Core Business Engine Scripts
|
|
29
|
+
│ ├── card-manager.js # Proactive Card Engine & 10-to-1 Compaction logic
|
|
30
|
+
│ └── scope-enforcer.js # Strict Scope Boundary Enforcer Guard
|
|
31
|
+
│
|
|
32
|
+
├── src/ # Runtime HTTP API Server
|
|
33
|
+
│ └── index.js # Native HTTP server serving /api/cards & static files
|
|
34
|
+
│
|
|
35
|
+
└── docs/ # Enterprise Architectural Documentation
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 📁 1.2 Thư mục & Vai trò Kỹ thuật
|
|
41
|
+
|
|
42
|
+
```mermaid
|
|
43
|
+
graph TD
|
|
44
|
+
Root["/ (Root Project)"] --> Gemini[".gemini/skills (AI Skills)"]
|
|
45
|
+
Root --> Data["data/ (JSON & Markdown Storage)"]
|
|
46
|
+
Root --> Scripts["scripts/ (Engine & Scope Guard)"]
|
|
47
|
+
Root --> Src["src/ (Native HTTP Server)"]
|
|
48
|
+
Root --> Docs["docs/ (Architectural Specs)"]
|
|
49
|
+
|
|
50
|
+
Data --> Cards["cards.json (Level 0 Active)"]
|
|
51
|
+
Data --> Milestones["milestones/ (Level 1 Milestone Files)"]
|
|
52
|
+
Data --> Reports["reports/ (Level 2 Macro Reports)"]
|
|
53
|
+
|
|
54
|
+
Scripts --> CardMgr["card-manager.js (Proactive Engine)"]
|
|
55
|
+
Scripts --> ScopeEnf["scope-enforcer.js (Boundary Guard)"]
|
|
56
|
+
|
|
57
|
+
Src --> IndexJS["index.js (HTTP Server Port 3000)"]
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 🔗 1.3 Dependency giữa các Package / Modules
|
|
63
|
+
|
|
64
|
+
```mermaid
|
|
65
|
+
graph LR
|
|
66
|
+
SrcIndex["src/index.js"] -->|require| CardMgr["scripts/card-manager.js"]
|
|
67
|
+
CardMgr -->|require| ScopeEnf["scripts/scope-enforcer.js"]
|
|
68
|
+
CardMgr -->|read/write| DataCards["data/cards.json"]
|
|
69
|
+
CardMgr -->|write| DataMilestones["data/milestones/"]
|
|
70
|
+
CardMgr -->|write| DataReports["data/reports/"]
|
|
71
|
+
SrcIndex -->|serves static| IndexHTML["index.html"]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 🏷 1.4 Quy Tắc Đặt Tên (Naming Conventions)
|
|
77
|
+
|
|
78
|
+
- **File JavaScript**: `kebab-case.js` (Ví dụ: `card-manager.js`, `scope-enforcer.js`).
|
|
79
|
+
- **File JSON Data**: `kebab-case.json` / `UPPERCASE.json` (Ví dụ: `cards.json`, `MILESTONE-001.json`).
|
|
80
|
+
- **File Skill**: `SKILL.md` đặt trong thư mục tên skill dạng `kebab-case` (Ví dụ: `.gemini/skills/auto-idea-to-product/SKILL.md`).
|
|
81
|
+
- **Scopes**: `UPPERCASE_SNAKE_CASE` (Ví dụ: `SCOPE_DIAGRAM`, `SCOPE_CORE_ENGINE`, `SCOPE_SECURITY`, `SCOPE_PAYMENT`).
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# 4. Module Diagram Documentation
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## 🧩 4.1 Module Relationship Diagram
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
graph TD
|
|
9
|
+
M1["Card Manager Module (scripts/card-manager.js)"]
|
|
10
|
+
M2["Scope Guard Module (scripts/scope-enforcer.js)"]
|
|
11
|
+
M3["API Server Module (src/index.js)"]
|
|
12
|
+
M4["Diagram Visualizer Module (index.html)"]
|
|
13
|
+
M5["Compaction Engine Module (scripts/card-manager.js)"]
|
|
14
|
+
|
|
15
|
+
M3 -->|Imports| M1
|
|
16
|
+
M1 -->|Imports| M2
|
|
17
|
+
M1 -->|Invokes| M5
|
|
18
|
+
M4 -->|Fetches Data / Embeds| M3
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 📋 4.2 Module Specification Table
|
|
24
|
+
|
|
25
|
+
### 1. Card Manager Module
|
|
26
|
+
- **Responsibility**: Khởi tạo thẻ mới từ prompt, chuyển thẻ cũ sang DONE, tư vấn bộ công cụ đa dạng và kiểm tra trạng thái Cạn Scope.
|
|
27
|
+
- **Dependency**: `scripts/scope-enforcer.js`, `data/cards.json`.
|
|
28
|
+
- **Public API**: `processUserPrompt()`, `checkIdleScopeState()`, `adviseToolsFromPrompt()`.
|
|
29
|
+
|
|
30
|
+
### 2. Scope Guard Module
|
|
31
|
+
- **Responsibility**: Định nghĩa bảng quy tắc ranh giới Scope (`SCOPE_DIAGRAM`, `SCOPE_CORE_ENGINE`, `SCOPE_SECURITY`, `SCOPE_PAYMENT`, `GLOBAL_SCOPE`) và kiểm tra tính hợp lệ khi sửa file.
|
|
32
|
+
- **Dependency**: Native Node.js `path` module.
|
|
33
|
+
- **Public API**: `ScopeEnforcer.validateAction(scopeName, targetFilePath)`.
|
|
34
|
+
|
|
35
|
+
### 3. Compaction Engine Module
|
|
36
|
+
- **Responsibility**: Tự động gom nén 10 Thẻ Lẻ hoàn thành thành 1 File Milestone (`MILESTONE-xxx.json`) và nén 10 Milestones thành 1 Báo cáo Macro (`MASTER_REPORT-xxx.md`).
|
|
37
|
+
- **Dependency**: Native Node.js `fs` & `path` modules.
|
|
38
|
+
- **Public API**: `compactCardsIfNeeded()`, `compactMilestonesIfNeeded()`.
|
|
39
|
+
|
|
40
|
+
### 4. API Server Module
|
|
41
|
+
- **Responsibility**: Phục vụ static file `index.html` và cung cấp các REST API Endpoints `/api/health`, `/api/skills`, `/api/cards`.
|
|
42
|
+
- **Dependency**: `http`, `fs`, `path`, `url`, `scripts/card-manager.js`.
|
|
43
|
+
- **Public API**: HTTP Server Port 3000.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# 2. Package Diagram Documentation
|
|
2
|
+
|
|
3
|
+
Dựa trên phân tích codebase hiện tại, hệ thống sử dụng cấu trúc **Native Lightweight Controller-Service-Storage Architecture** không dùng framework nặng.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 📦 2.1 Package Architecture Flow
|
|
8
|
+
|
|
9
|
+
```mermaid
|
|
10
|
+
graph TD
|
|
11
|
+
Client["Client / User / Terminal"] -->|HTTP REST / CLI| Controller["Controller (src/index.js)"]
|
|
12
|
+
Controller -->|Delegates Logic| Service["Service / Engine (scripts/card-manager.js)"]
|
|
13
|
+
Service -->|Validates Action| Guard["Guard / Enforcer (scripts/scope-enforcer.js)"]
|
|
14
|
+
Service -->|Persists Data| Storage["Storage Layer (data/cards.json & milestones/)"]
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 🔍 2.2 Chi Tiết Các Tầng (Layers)
|
|
20
|
+
|
|
21
|
+
| Tầng (Layer) | File đại diện | Vai trò kỹ thuật |
|
|
22
|
+
| :--- | :--- | :--- |
|
|
23
|
+
| **Controller Layer** | `src/index.js` | Tiếp nhận HTTP Request (`GET /api/cards`, `POST /api/cards`, `GET /api/health`), định tuyến MIME types và phản hồi JSON. |
|
|
24
|
+
| **Service Layer** | `scripts/card-manager.js` | Xử lý logic tạo thẻ từ prompt, nén thẻ phân cấp 10-in-1, tự động phát hiện Cạn Scope (IDLE) và tư vấn bộ công cụ đa dạng. |
|
|
25
|
+
| **Guard / Boundary Layer** | `scripts/scope-enforcer.js` | Kiểm tra ranh giới file path tương ứng với Scope được giao (`SCOPE_DIAGRAM`, `SCOPE_CORE_ENGINE`, etc.). |
|
|
26
|
+
| **Storage Layer** | `data/cards.json`<br>`data/milestones/`<br>`data/reports/` | Nơi lưu trữ bền vững phẳng dạng JSON & Markdown. |
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# 3. System Architecture Documentation
|
|
2
|
+
|
|
3
|
+
**Architecture Pattern:** Event-Driven Proactive Skill Engine with Hierarchical File Compaction.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🏗 3.1 Overall System Architecture Diagram
|
|
8
|
+
|
|
9
|
+
```mermaid
|
|
10
|
+
graph TD
|
|
11
|
+
User["👤 User / Terminal / Gemini Prompt"] -->|CLI Prompt / HTTP| Frontend["Frontend / Dashboard (index.html)"]
|
|
12
|
+
Frontend -->|HTTP API / REST| APIServer["API Server (src/index.js)"]
|
|
13
|
+
|
|
14
|
+
subgraph Core_Skill_System ["Core Skill System"]
|
|
15
|
+
APIServer --> CardManager["Card Manager Engine (scripts/card-manager.js)"]
|
|
16
|
+
CardManager --> ScopeGuard["Scope Enforcer Guard (scripts/scope-enforcer.js)"]
|
|
17
|
+
|
|
18
|
+
subgraph Storage_Tier ["Storage Tier (File Persistence)"]
|
|
19
|
+
CardManager --> CardsJSON["Level 0: data/cards.json (< 10 Active Cards)"]
|
|
20
|
+
CardsJSON -->|Compaction Engine (10-in-1)| Milestones["Level 1: data/milestones/MILESTONE-001.json"]
|
|
21
|
+
Milestones -->|Macro Summarizer (100-in-1)| MasterReport["Level 2: data/reports/MASTER_REPORT_001.md"]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
subgraph Proactive_System ["Proactive AI Engine"]
|
|
25
|
+
CardManager --> IdleDetector["Idle Scope Trigger (checkIdleScopeState)"]
|
|
26
|
+
CardManager --> ToolAdvisor["Multi-Category Tool Advisor"]
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
ExternalServices["External 3rd-Party Services (Not Implemented / Proposed)"]
|
|
31
|
+
Proactive_System -->|Proposed Integration| ExternalServices
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 📊 3.2 System Component Status
|
|
37
|
+
|
|
38
|
+
- **Frontend / Dashboard**: Implemented (`index.html` with Mermaid.js visual rendering).
|
|
39
|
+
- **API Server**: Implemented (`src/index.js` port 3000 native HTTP server).
|
|
40
|
+
- **Core Engine & Scope Guard**: Implemented (`scripts/card-manager.js`, `scripts/scope-enforcer.js`).
|
|
41
|
+
- **File Persistence Storage**: Implemented (`data/cards.json`, `data/milestones/`, `data/reports/`).
|
|
42
|
+
- **Redis / Distributed Queue / DB Cluster**: *Not Implemented* (Dự án sử dụng File-based Persistence phẳng cực nhẹ).
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="vi">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>DOCS SYSTEM ARCHITECTURE & VISUAL DIAGRAMS</title>
|
|
7
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
8
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
9
|
+
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@700;900&family=Plus+Jakarta+Sans:wght@400;600;700&family=Space+Grotesk:wght@500;700&display=swap" rel="stylesheet">
|
|
10
|
+
|
|
11
|
+
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
|
|
12
|
+
<script>
|
|
13
|
+
mermaid.initialize({
|
|
14
|
+
startOnLoad: true,
|
|
15
|
+
theme: 'dark',
|
|
16
|
+
themeVariables: {
|
|
17
|
+
darkMode: true,
|
|
18
|
+
background: '#080c18',
|
|
19
|
+
primaryColor: '#00ff66',
|
|
20
|
+
primaryTextColor: '#ffffff',
|
|
21
|
+
primaryBorderColor: '#00ff66',
|
|
22
|
+
lineColor: '#00f0ff',
|
|
23
|
+
secondaryColor: '#162036',
|
|
24
|
+
tertiaryColor: '#0e1424'
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<style>
|
|
30
|
+
:root {
|
|
31
|
+
--bg-dark: #050811;
|
|
32
|
+
--bg-card: #0e1424;
|
|
33
|
+
--accent-neon: #00ff66;
|
|
34
|
+
--accent-cyan: #00f0ff;
|
|
35
|
+
--accent-magenta: #ff0055;
|
|
36
|
+
--text-main: #ffffff;
|
|
37
|
+
--text-muted: #94a3b8;
|
|
38
|
+
--border-sharp: 1px solid rgba(0, 255, 102, 0.25);
|
|
39
|
+
--font-mono: 'Space Grotesk', monospace;
|
|
40
|
+
--font-title: 'Outfit', sans-serif;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
44
|
+
|
|
45
|
+
body {
|
|
46
|
+
background-color: var(--bg-dark);
|
|
47
|
+
color: var(--text-main);
|
|
48
|
+
font-family: 'Plus Jakarta Sans', sans-serif;
|
|
49
|
+
padding: 2rem;
|
|
50
|
+
line-height: 1.6;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.header-dashboard {
|
|
54
|
+
max-width: 1440px;
|
|
55
|
+
margin: 0 auto 2rem auto;
|
|
56
|
+
border-bottom: var(--border-sharp);
|
|
57
|
+
padding-bottom: 1.5rem;
|
|
58
|
+
display: flex;
|
|
59
|
+
justify-content: space-between;
|
|
60
|
+
align-items: flex-end;
|
|
61
|
+
flex-wrap: wrap;
|
|
62
|
+
gap: 1rem;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.header-dashboard h1 {
|
|
66
|
+
font-family: var(--font-title);
|
|
67
|
+
font-size: 2.2rem;
|
|
68
|
+
letter-spacing: 2px;
|
|
69
|
+
text-transform: uppercase;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.header-dashboard h1 span { color: var(--accent-neon); }
|
|
73
|
+
|
|
74
|
+
.tag-badge {
|
|
75
|
+
font-family: var(--font-mono);
|
|
76
|
+
background: rgba(0, 255, 102, 0.15);
|
|
77
|
+
color: var(--accent-neon);
|
|
78
|
+
border: 1px solid var(--accent-neon);
|
|
79
|
+
padding: 4px 12px;
|
|
80
|
+
font-size: 0.8rem;
|
|
81
|
+
letter-spacing: 1px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.grid-container {
|
|
85
|
+
display: grid;
|
|
86
|
+
grid-template-columns: repeat(auto-fit, minmax(680px, 1fr));
|
|
87
|
+
gap: 2rem;
|
|
88
|
+
max-width: 1440px;
|
|
89
|
+
margin: 0 auto;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.doc-card {
|
|
93
|
+
background: var(--bg-card);
|
|
94
|
+
border: var(--border-sharp);
|
|
95
|
+
padding: 1.8rem;
|
|
96
|
+
clip-path: polygon(0 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%);
|
|
97
|
+
display: flex;
|
|
98
|
+
flex-direction: column;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.doc-title {
|
|
102
|
+
font-family: var(--font-mono);
|
|
103
|
+
font-size: 1.05rem;
|
|
104
|
+
color: var(--accent-cyan);
|
|
105
|
+
letter-spacing: 1px;
|
|
106
|
+
margin-bottom: 1.2rem;
|
|
107
|
+
display: flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
justify-content: space-between;
|
|
110
|
+
border-bottom: 1px solid rgba(255,255,255,0.08);
|
|
111
|
+
padding-bottom: 0.6rem;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.mermaid-box {
|
|
115
|
+
flex: 1;
|
|
116
|
+
display: flex;
|
|
117
|
+
align-items: center;
|
|
118
|
+
justify-content: center;
|
|
119
|
+
background: #080c18;
|
|
120
|
+
border: 1px dashed rgba(0, 255, 102, 0.2);
|
|
121
|
+
padding: 1.5rem;
|
|
122
|
+
overflow: auto;
|
|
123
|
+
min-height: 280px;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
footer {
|
|
127
|
+
max-width: 1440px;
|
|
128
|
+
margin: 3rem auto 0 auto;
|
|
129
|
+
text-align: center;
|
|
130
|
+
font-family: var(--font-mono);
|
|
131
|
+
font-size: 0.8rem;
|
|
132
|
+
color: var(--text-muted);
|
|
133
|
+
border-top: 1px solid rgba(255,255,255,0.05);
|
|
134
|
+
padding-top: 1.5rem;
|
|
135
|
+
}
|
|
136
|
+
</style>
|
|
137
|
+
</head>
|
|
138
|
+
<body>
|
|
139
|
+
|
|
140
|
+
<header class="header-dashboard">
|
|
141
|
+
<div>
|
|
142
|
+
<span class="tag-badge">DOCS ISOLATED SYSTEM ARCHITECTURE</span>
|
|
143
|
+
<h1>SYSTEM ARCHITECTURE <span>VISUAL DIAGRAMS</span></h1>
|
|
144
|
+
</div>
|
|
145
|
+
<div style="font-family: var(--font-mono); color: var(--text-muted); font-size: 0.85rem;">
|
|
146
|
+
OUTPUT LOCATION: <span style="color: var(--accent-neon);">DOCS/ARCHITECTURE.HTML</span>
|
|
147
|
+
</div>
|
|
148
|
+
</header>
|
|
149
|
+
|
|
150
|
+
<div class="grid-container">
|
|
151
|
+
|
|
152
|
+
<!-- System Architecture Graph -->
|
|
153
|
+
<div class="doc-card">
|
|
154
|
+
<div class="doc-title">
|
|
155
|
+
<span>🏗 SYSTEM ARCHITECTURE (docs/architecture.html)</span>
|
|
156
|
+
</div>
|
|
157
|
+
<div class="mermaid-box">
|
|
158
|
+
<pre class="mermaid">
|
|
159
|
+
graph TD
|
|
160
|
+
User["👤 User / Terminal Prompt"] --> APIServer["Native HTTP Server (src/index.js:3000)"]
|
|
161
|
+
APIServer --> CardManager["Card Manager Engine (scripts/card-manager.js)"]
|
|
162
|
+
CardManager --> ScopeGuard["Scope Enforcer Guard (scripts/scope-enforcer.js)"]
|
|
163
|
+
|
|
164
|
+
subgraph Storage_Tier ["3-Tier File Persistence"]
|
|
165
|
+
CardManager --> Level0["Level 0: cards.json (< 10 Active)"]
|
|
166
|
+
Level0 -->|10-in-1 Compaction| Level1["Level 1: data/milestones/MILESTONE-001.json"]
|
|
167
|
+
Level1 -->|100-in-1 Compaction| Level2["Level 2: data/reports/MASTER_REPORT_001.md"]
|
|
168
|
+
end
|
|
169
|
+
</pre>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
|
|
173
|
+
<!-- Hierarchical Compaction Flowchart -->
|
|
174
|
+
<div class="doc-card">
|
|
175
|
+
<div class="doc-title">
|
|
176
|
+
<span>🗂 HIERARCHICAL COMPACTION FLOWCHART</span>
|
|
177
|
+
</div>
|
|
178
|
+
<div class="mermaid-box">
|
|
179
|
+
<pre class="mermaid">
|
|
180
|
+
flowchart LR
|
|
181
|
+
RawCards["Tầng 0: 10 Thẻ Lẻ (cards.json)"] -->|Compaction Engine| Milestones["Tầng 1: MILESTONE-001.json"]
|
|
182
|
+
Milestones -->|Executive Summarizer| MasterReports["Tầng 2: MASTER_REPORT_001.md"]
|
|
183
|
+
</pre>
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
</div>
|
|
188
|
+
|
|
189
|
+
<footer>
|
|
190
|
+
DOCS ISOLATED ARCHITECTURE VISUALIZER // SAVED IN DOCS/ARCHITECTURE.HTML
|
|
191
|
+
</footer>
|
|
192
|
+
</body>
|
|
193
|
+
</html>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# 7. Database Documentation
|
|
2
|
+
|
|
3
|
+
**Database Status:** File-Based JSON & Markdown Multi-Tier Persistence Storage (PostgreSQL/SQL Database was explicitly removed per user decision to keep the skill 100% lightweight).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🗄 7.1 Data Storage ERD Diagram (JSON Schema Entities)
|
|
8
|
+
|
|
9
|
+
```mermaid
|
|
10
|
+
erDiagram
|
|
11
|
+
CARD {
|
|
12
|
+
string id PK
|
|
13
|
+
string prompt
|
|
14
|
+
string title
|
|
15
|
+
string scope FK
|
|
16
|
+
string category
|
|
17
|
+
string status
|
|
18
|
+
string createdAt
|
|
19
|
+
string completedAt
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
MILESTONE {
|
|
23
|
+
string milestoneId PK
|
|
24
|
+
string compactedAt
|
|
25
|
+
int totalCardsCompacted
|
|
26
|
+
string_array scopesIncluded
|
|
27
|
+
string summary
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
MASTER_REPORT {
|
|
31
|
+
string reportId PK
|
|
32
|
+
string generatedAt
|
|
33
|
+
int totalMilestonesCompacted
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
CARD ||--o{ MILESTONE : "compacted into (10 cards -> 1 milestone)"
|
|
37
|
+
MILESTONE ||--o{ MASTER_REPORT : "compacted into (10 milestones -> 1 report)"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 📋 7.2 Storage File Schemas
|
|
43
|
+
|
|
44
|
+
### 1. Active Cards File (`data/cards.json`)
|
|
45
|
+
- **Type**: Array of Card Objects (Level 0 Persistence).
|
|
46
|
+
- **Max Capacity**: 10 Active Cards (Compaction Engine automatically purges completed cards when count >= 10).
|
|
47
|
+
- **Field Definitions**:
|
|
48
|
+
- `id` (String, Unique PK): E.g., `"CARD-001"`.
|
|
49
|
+
- `prompt` (String): Raw user input from Gemini/Terminal.
|
|
50
|
+
- `title` (String): Generated task summary title.
|
|
51
|
+
- `scope` (String): Assigned Scope Boundary (`SCOPE_DIAGRAM`, `SCOPE_CORE_ENGINE`, etc.).
|
|
52
|
+
- `category` (String): Task category.
|
|
53
|
+
- `status` (String): Status Enum (`"IN_PROGRESS"`, `"DONE"`, `"WAITING_USER_APPROVAL"`, `"PROPOSED_BY_AI"`).
|
|
54
|
+
- `createdAt` (String): ISO 8601 Timestamp.
|
|
55
|
+
- `completedAt` (String, Optional): ISO 8601 Timestamp when finished.
|
|
56
|
+
|
|
57
|
+
### 2. Milestone Files (`data/milestones/MILESTONE-xxx.json`)
|
|
58
|
+
- **Type**: Single JSON Document per 10 Completed Cards (Level 1 Persistence).
|
|
59
|
+
- **Fields**:
|
|
60
|
+
- `milestoneId`: E.g., `"MILESTONE-001"`.
|
|
61
|
+
- `compactedAt`: ISO 8601 Timestamp.
|
|
62
|
+
- `totalCardsCompacted`: Integer (10).
|
|
63
|
+
- `scopesIncluded`: Array of Strings (Unique scopes in this batch).
|
|
64
|
+
- `cards`: Array of 10 complete Card objects.
|
|
65
|
+
|
|
66
|
+
### 3. Executive Macro Reports (`data/reports/MASTER_EXECUTIVE_REPORT_xxx.md`)
|
|
67
|
+
- **Type**: Markdown Document per 10 Milestones / 100 Cards (Level 2 Persistence).
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# 12. Deployment Documentation
|
|
2
|
+
|
|
3
|
+
**Deployment Status:** Native Node.js Zero-Dependency Deployment (Docker & SQL were explicitly removed per user decision to ensure 100% lightweight skill execution).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🚀 12.1 Native Node.js Deployment Flow
|
|
8
|
+
|
|
9
|
+
```mermaid
|
|
10
|
+
graph TD
|
|
11
|
+
Developer["Developer / Agent Environment"] -->|1. Push to Repository| GitRepo["Git Repository"]
|
|
12
|
+
GitRepo -->|2. Pull Latest Code| Server["Target Host / Local Server"]
|
|
13
|
+
Server -->|3. Run Startup Script| StartCmd["npm start (node src/index.js)"]
|
|
14
|
+
StartCmd -->|4. Port 3000 Listening| LiveServer["HTTP API Server Live (http://localhost:3000)"]
|
|
15
|
+
LiveServer -->|5. Serves Static UI| Dashboard["Visual Dashboard (http://localhost:3000/index.html)"]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 📦 12.2 Deployment Checklist
|
|
21
|
+
|
|
22
|
+
- [x] Node.js >= v18 installed on host.
|
|
23
|
+
- [x] Dependencies installed (`npm install`).
|
|
24
|
+
- [x] Data directories exist (`data/`, `data/milestones/`, `data/reports/`).
|
|
25
|
+
- [x] HTTP Server port 3000 open.
|
|
26
|
+
- [ ] *Docker Containerization*: **Not Implemented** (Removed per user decision).
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# 14. CI/CD Pipeline Documentation
|
|
2
|
+
|
|
3
|
+
**CI/CD Status:** Local Direct Execution & Verification Mode (Automated CI/CD Actions Pipeline is *Not Implemented*, proposed blueprint below).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🔄 14.1 Proposed CI/CD Pipeline Diagram
|
|
8
|
+
|
|
9
|
+
```mermaid
|
|
10
|
+
graph TD
|
|
11
|
+
Dev["Developer"] -->|Git Commit & Push| GitHub["GitHub Repository"]
|
|
12
|
+
GitHub -->|Trigger Workflow| Actions["GitHub Actions CI/CD"]
|
|
13
|
+
|
|
14
|
+
subgraph CI_Pipeline ["CI Pipeline"]
|
|
15
|
+
Actions --> Step1["1. Checkout Code"]
|
|
16
|
+
Step1 --> Step2["2. Setup Node.js v20"]
|
|
17
|
+
Step2 --> Step3["3. Install Dependencies (npm ci)"]
|
|
18
|
+
Step3 --> Step4["4. Run Scope Enforcer Tests (node scripts/scope-enforcer.js)"]
|
|
19
|
+
Step4 --> Step5["5. Run Card Engine Verification (node scripts/card-manager.js)"]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
subgraph CD_Pipeline ["CD Pipeline"]
|
|
23
|
+
Step5 -->|Tests Passed| Step6["6. Deploy to Production Host / Vercel"]
|
|
24
|
+
Step6 --> Step7["7. Health Check Verification (GET /api/health)"]
|
|
25
|
+
end
|
|
26
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# 13. Infrastructure Documentation
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## 🌐 13.1 Infrastructure Topology Diagram
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
graph TD
|
|
9
|
+
Client["Client Browser / Terminal CLI"] -->|HTTP / Localhost| NodeServer["Node.js HTTP Server (src/index.js:3000)"]
|
|
10
|
+
|
|
11
|
+
subgraph Host_Environment ["Local Host Environment"]
|
|
12
|
+
NodeServer --> Engine["Scripts Layer (card-manager.js & scope-enforcer.js)"]
|
|
13
|
+
Engine --> LocalStorage["File System Storage (data/cards.json)"]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
subgraph Proposed_Cloud_Infrastructure ["Proposed Cloud Infrastructure (Not Implemented)"]
|
|
17
|
+
Cloudflare["Cloudflare Edge CDN"] --> LoadBalancer["Nginx Load Balancer"]
|
|
18
|
+
LoadBalancer --> AppCluster["Node.js Application Cluster"]
|
|
19
|
+
AppCluster --> CloudStorage["Supabase / Cloud Object Storage"]
|
|
20
|
+
end
|
|
21
|
+
```
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# 15. Logging Architecture Documentation
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## 🪵 15.1 Logging Architecture Diagram
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
graph TD
|
|
9
|
+
Engine["card-manager.js / scope-enforcer.js"] -->|Console Log / Error| Console["Standard Console Output (stdout/stderr)"]
|
|
10
|
+
Console -->|Audit Log Entries| AuditJSON["data/milestones/ & cards.json Log Entries"]
|
|
11
|
+
|
|
12
|
+
subgraph Proposed_Enterprise_Logging ["Proposed Enterprise Logging Stack (Not Implemented)"]
|
|
13
|
+
Console -->|Winston / Pino Logger| LogShipper["FluentBit Log Shipper"]
|
|
14
|
+
LogShipper --> ELK["Elasticsearch / Kibana Dashboard"]
|
|
15
|
+
end
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 📋 15.2 Current Log Event Types
|
|
21
|
+
|
|
22
|
+
1. `[COMPACTION ENGINE] ⚡ Đã nén 10 Thẻ Lẻ thành Milestone File: MILESTONE-xxx.json`
|
|
23
|
+
2. `[BẢO VỆ SCOPE] Hành động bị CHẶN! Thẻ hiện tại có scope là [SCOPE_X], không được phép sửa file [FILE_Y].`
|
|
24
|
+
3. `[AGY Server] Listening on http://localhost:3000`
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# 16. Monitoring & Health Architecture Documentation
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## 📈 16.1 Health & Monitoring Flow
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
graph TD
|
|
9
|
+
Monitor["Monitoring Probe / UptimeRobot"] -->|HTTP GET /api/health| Server["src/index.js"]
|
|
10
|
+
Server -->>Monitor: 200 OK { status: "UP", timestamp: "..." }
|
|
11
|
+
|
|
12
|
+
subgraph Proposed_Prometheus_Grafana ["Proposed Production Monitoring (Not Implemented)"]
|
|
13
|
+
Server -->|Prometheus Metrics Middleware| PromExporter["/metrics Endpoint"]
|
|
14
|
+
PromExporter --> Prometheus["Prometheus Server"]
|
|
15
|
+
Prometheus --> Grafana["Grafana Visual Dashboard"]
|
|
16
|
+
Prometheus --> AlertManager["AlertManager (Telegram / Email Alerts)"]
|
|
17
|
+
end
|
|
18
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# 17. Security Architecture Documentation
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## 🛡 17.1 Security Enforcement Architecture Diagram
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
graph TD
|
|
9
|
+
UserAction["User / AI Agent Action"] --> ScopeGuard["scripts/scope-enforcer.js (Scope Guard)"]
|
|
10
|
+
|
|
11
|
+
ScopeGuard -->|Check 1| ScopeCheck{"Target File in Allowed Scope Paths?"}
|
|
12
|
+
ScopeCheck -->|No| Block1["SCOPE_VIOLATION_BLOCKED (Action Prevented ⛔)"]
|
|
13
|
+
|
|
14
|
+
ScopeCheck -->|Yes| SanitizationCheck{"Input Sanitized?"}
|
|
15
|
+
SanitizationCheck -->|Yes| PassAction["Action Allowed (SCOPE_PASSED ✅)"]
|
|
16
|
+
|
|
17
|
+
subgraph Defense_in_Depth ["Defense-In-Depth Security Layer"]
|
|
18
|
+
DirectoryTraversalGuard["Path Traversal Prevention (src/index.js)"]
|
|
19
|
+
TokenBudgetGuard["Token Budget Guard (Max 2 Retries Limit)"]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
PassAction --> Defense_in_Depth
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 📋 17.2 Security Implementation Checklist
|
|
28
|
+
|
|
29
|
+
| Category | Status in Codebase | Implementation Details |
|
|
30
|
+
| :--- | :--- | :--- |
|
|
31
|
+
| **Scope Boundary Guard** | **IMPLEMENTED** | `scripts/scope-enforcer.js` blocks unauthorized file edits outside active card scope (`SCOPE_DIAGRAM`, `SCOPE_CORE_ENGINE`, etc.). |
|
|
32
|
+
| **Directory Traversal Defense** | **IMPLEMENTED** | `src/index.js` verifies `filePath.startsWith(PUBLIC_DIR)` before serving static files. |
|
|
33
|
+
| **Token Budget Protection** | **IMPLEMENTED** | `scripts/card-manager.js` limits max 2 retries per bug to prevent token exhaustion loops. |
|
|
34
|
+
| **CORS Restriction** | **IMPLEMENTED** | Headers set in `src/index.js`. |
|
|
35
|
+
| **OAuth / JWT / Password Hashing** | *Not Implemented* | Proposed in `docs/api/authentication-flow.md` for production deployment. |
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# 9. Sequence Diagram - Card Creation Workflow
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## 🔄 9.1 Sequence Diagram: Create Task Card from User Prompt
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
sequenceDiagram
|
|
9
|
+
autonumber
|
|
10
|
+
actor User as User / Terminal
|
|
11
|
+
participant Server as src/index.js (HTTP API)
|
|
12
|
+
participant Engine as card-manager.js (Card Engine)
|
|
13
|
+
participant Guard as scope-enforcer.js (Scope Guard)
|
|
14
|
+
participant Storage as data/cards.json
|
|
15
|
+
|
|
16
|
+
User->>Server: POST /api/cards { prompt: "Tích hợp mã ngân hàng" }
|
|
17
|
+
Server->>Engine: processUserPrompt("Tích hợp mã ngân hàng")
|
|
18
|
+
Engine->>Engine: detectScopeFromPrompt() => "SCOPE_PAYMENT"
|
|
19
|
+
Engine->>Guard: validateAction("SCOPE_PAYMENT", "scripts/card-manager.js")
|
|
20
|
+
Guard-->>Engine: { allowed: true, status: "SCOPE_PASSED" }
|
|
21
|
+
Engine->>Engine: Set previous active cards to DONE
|
|
22
|
+
Engine->>Storage: Save new CARD-xxx with IN_PROGRESS
|
|
23
|
+
Engine->>Engine: compactCardsIfNeeded()
|
|
24
|
+
Engine-->>Server: Return New Card Object
|
|
25
|
+
Server-->>User: 201 Created { status: "SUCCESS", card: CARD-xxx }
|
|
26
|
+
```
|