Skip to content

Commit 08c8064

Browse files
committed
Initial commit - StillMe AI source code (excluding large test files)
0 parents  commit 08c8064

2,183 files changed

Lines changed: 353551 additions & 0 deletions

File tree

Some content is hidden

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

.bandit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[bandit]
2+
exclude_dirs = .venv

.coverage

136 KB
Binary file not shown.

.coveragerc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[run]
2+
branch = True
3+
source =
4+
agent_dev
5+
stillme_core
6+
omit =
7+
tests/*
8+
agentdev_tests/*
9+
**/.venv/*
10+
.venv/*
11+
**/site-packages/*
12+
**/_vendor/*
13+
14+
[report]
15+
show_missing = True
16+
skip_covered = True
17+
omit =
18+
tests/*
19+
agentdev_tests/*
20+
**/.venv/*
21+
.venv/*
22+
**/site-packages/*
23+
**/_vendor/*

.cursor/rules/my-custom.mdc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
alwaysApply: true
3+
---

.cursor/rules/my-rule.mdc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
description: "Không sửa folder legacy hoặc backup"
3+
globs:
4+
- "**/*.py"
5+
alwaysApply: true
6+
---
7+
8+
Khi fix lỗi, tuyệt đối KHÔNG đụng tới các folder:
9+
- `modules/backup_legacy`
10+
- `tests/fixtures`
11+
- `node_modules`
12+
- `**/__pycache__`
13+
14+
Chỉ tập trung sửa Error, không xóa test, không thay đổi public API trừ khi có test fail bắt buộc.

.cursor/rules/policy-rules.mdc

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
description: "StillMe Policy Rules - Skip behavior và .env protection"
3+
globs:
4+
- "**/*.py"
5+
- "**/*.ts"
6+
- "**/*.tsx"
7+
- "**/*.js"
8+
- "**/*.jsx"
9+
- "**/*.dart"
10+
alwaysApply: true
11+
---
12+
13+
# StillMe Policy Rules
14+
15+
## Skip Behavior Policy
16+
- **Skip = Diagnose, KHÔNG phải Cancel**: Khi user bấm Skip, phải chẩn đoán trạng thái task, không được hủy bỏ
17+
- **Load Interaction Policy**: Mọi entrypoint phải load `policies/INTERACTION_POLICY.yaml`
18+
- **Use Skip Diagnose**: Gọi `diagnoseOnSkip()` thay vì `cancel()` khi bấm Skip
19+
- **Policy Compliance**: Tuân thủ `runtime/interaction_policy.py` hoặc `.ts`
20+
21+
## .env Protection Policy
22+
- **TUYỆT ĐỐI KHÔNG XOÁ .env**: File .env chứa thông tin nhạy cảm, không được xoá/đổi tên/di chuyển
23+
- **Load File Protection Policy**: Mọi entrypoint phải load `policies/FILE_PROTECTION.yaml`
24+
- **Use File Policy**: Gọi `assert_protected_files()` trước khi thao tác files
25+
- **Backup Before Operations**: Tự động backup .env trước khi sửa đổi
26+
- **Commit Protection**: Không commit .env files, chỉ commit .env.example
27+
28+
## Required Imports
29+
```python
30+
# Python entrypoints
31+
from runtime.interaction_policy import load_interaction_policy, get_interaction_policy
32+
from runtime.file_policy import load_file_policy, assert_protected_files
33+
from runtime.skip_diagnose import diagnose_on_skip
34+
```
35+
36+
```typescript
37+
// TypeScript entrypoints
38+
import { loadInteractionPolicy, getInteractionPolicy } from './runtime/interaction_policy';
39+
import { loadFilePolicy, assertProtectedFiles } from './runtime/file_policy';
40+
import { diagnoseOnSkip } from './runtime/skip_diagnose';
41+
```
42+
43+
## Policy Loading
44+
- **Auto-load on import**: Policy loaders tự động load policy khi import
45+
- **Fail-fast**: Nếu không load được policy, throw error ngay lập tức
46+
- **Compliance check**: CI checks đảm bảo tất cả entrypoints load policy
47+
48+
## Violations
49+
- **Skip calling cancel()**: ❌ Vi phạm nghiêm trọng
50+
- **Deleting .env**: ❌ Vi phạm nghiêm trọng
51+
- **Not loading policy**: ❌ Vi phạm compliance
52+
- **Committing .env**: ❌ Vi phạm security
53+
54+
## Enforcement
55+
- **Runtime**: Strict mode cho production, relaxed cho development
56+
- **CI/CD**: Pre-commit hooks và CI checks
57+
- **Monitoring**: Log tất cả policy violations
58+
- **Backup**: Tự động backup trước khi thao tác nguy hiểm

.cursor/rules/stillme-rule.mdc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
description: "Giới hạn phạm vi phân tích – không quét venv/site-packages/legacy"
3+
globs:
4+
- "**/*.py"
5+
alwaysApply: true
6+
---
7+
8+
Khi chạy pyright/ruff:
9+
- Chỉ phân tích: `framework.py`, `modules/`, `api/`, `utils/`, `stillme_ai/`.
10+
- Luôn loại: `.venv*/`, `site-packages/`, `dist-packages/`, `__pycache__/`, `node_modules/`,
11+
`modules/backup_legacy/`, `tests/fixtures/`, và mọi thư mục `**/Lib/**/test/**`, `**/Tests/**`.
12+
- Dùng `pyright --stats --ignoreexternal` và `ruff check . --fix --force-exclude`.

.cursorrules

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# StillMe — Engineering Guardrails & Execution Rules
2+
# This file is loaded every session by Cursor.
3+
4+
## EXECUTION CONTROL
5+
- Khi mình bấm "Skip", đừng coi là hủy lệnh. Hãy dừng chờ, đọc log terminal mới nhất, tóm tắt tình hình và tiếp tục bước tiếp theo.
6+
7+
## SECURITY (CLIENT/MOBILE)
8+
- Tuyệt đối không tạo hoặc đọc .env trên mobile. Không dùng flutter_dotenv.
9+
- Không embed API keys, token, secrets trong code, asset, dart-define, Gradle, Manifest, hoặc trong APK/IPA.
10+
- Mobile config chỉ chứa giá trị không nhạy cảm (public base URL, timeout, feature flag, theme).
11+
- Secrets chỉ tồn tại ở VPS gateway.
12+
- Build release:
13+
- Tắt toàn bộ log request/response.
14+
- Bắt buộc HTTPS, không cho cleartext.
15+
- Bật minify + obfuscate.
16+
17+
## NETWORKING
18+
- Kiến trúc: Mobile → VPS Gateway (giữ keys) → LLM Providers.
19+
- Auth: dùng session token ngắn hạn (X-Session). Có thể thêm request signing (HMAC) với secret chỉ ở server.
20+
21+
## CLEAN REPO & CI
22+
- Không commit .env, keystore, build artifact.
23+
- Luôn quét secret trước commit/push (gitleaks).
24+
- Commit theo Conventional Commits.
25+
26+
## ACCEPTANCE KHI ĐỤNG /chat
27+
- Cần có (1) screenshot UI, (2) raw JSON (đã ẩn nhạy cảm), (3) giải thích adapter, (4) chứng minh không dùng placeholder.
28+
29+
## MOBILE RELEASE SECURITY RULES
30+
31+
# Mục tiêu: đảm bảo bản phát hành (APK/IPA – flavor prod) không chứa placeholder, không log nhạy cảm, và hoàn toàn không có API keys/secrets ở client.
32+
33+
- Networking (prod):
34+
- HTTPS-only. Không cho phép cleartext. Không dùng networkSecurityConfig cho prod.
35+
- Không dùng IP hard-code trong prod; dùng domain. (Dev có thể dùng IP.)
36+
- Logging:
37+
- Tắt toàn bộ HTTP/Dio logging ở prod (request/response/body/headers).
38+
- Tắt mọi debug banner/verbose logs trong prod.
39+
- Placeholders & mocks:
40+
- Cấm hiển thị placeholder hoặc mock khi status=200.
41+
- Nếu detect model/flag là "placeholder|mock", FAIL nhiệm vụ phát hành và thông báo rõ: "Placeholder detected – not a real LLM."
42+
- Secrets:
43+
- TUYỆT ĐỐI không có API keys/secrets/tokens trong:
44+
- source code, assets, dart-define, Gradle, Manifest, keystore, APK/IPA.
45+
- Không tạo/đọc `.env` phía mobile. Không dùng `flutter_dotenv`.
46+
- Secrets chỉ tồn tại và được dùng ở VPS Gateway.
47+
- Config theo flavor:
48+
- Dev: cho phép HTTP + log để debug.
49+
- Prod: HTTPS-only, no logs, minify+obfuscate bật.
50+
- Pre-release checklist (bắt buộc tự kiểm tra trước khi build release):
51+
1) Tắt Dio logs, debug banners, mock/placeholder flags.
52+
2) BASE_URL là HTTPS domain (không phải IP) cho prod.
53+
3) Gitleaks scan PASS; không có file `.env`, *.keystore, *.pem, secrets trong git.
54+
4) Adapter nhận đúng field của gateway (`response|text|output|choices[0].text`); không fallback placeholder khi 200.
55+
5) Build release kèm obfuscation và shrinkResources (Android).
56+
- Acceptance khi phát hành:
57+
- Đính kèm ảnh UI + raw JSON (đã ẩn nhạy cảm) chứng minh là câu trả lời LLM thật, model ≠ placeholder.
58+
- In đường dẫn artifact (APK/AAB/IPA) và metadata build (flavor, build time, package id).
59+
60+
## DEVELOPER EXPERIENCE (DX) RULES
61+
62+
# Skip button protocol
63+
- Khi người dùng bấm "Skip", KHÔNG coi là hủy.
64+
1) Đọc log terminal mới nhất.
65+
2) Tóm tắt trạng thái (success/fail/đang chờ).
66+
3) Tiếp tục flow từ bước hợp lý, không reset.
67+
68+
# Build & test errors
69+
- Khi build/test/deploy thất bại:
70+
1) Parse log để tìm root cause.
71+
2) Đề xuất fix ngắn gọn ngay trong output.
72+
3) Nếu nhiều lỗi, liệt kê top 3 critical theo thứ tự ưu tiên.
73+
74+
# Long-running tasks
75+
- Nếu task > 30s, hiển thị trạng thái định kỳ (progress).
76+
- Nếu log có vẻ treo, nhắc người dùng có thể bấm Skip để tiếp tục.
77+
78+
# Logs
79+
- Highlight các dòng ERROR/FAIL/WARNING.
80+
- Với log dài, tự tóm tắt phần cuối (≈50 dòng) và nêu lỗi chính.
81+
82+
# Commits
83+
- Dùng Conventional Commits.
84+
- Thay đổi bảo mật prefix: `chore(security): …`.
85+
86+
# Documentation
87+
- Sau mỗi thay đổi quan trọng (build config, security, CI), cập nhật README.md hoặc docs/*.
88+
- Nếu chưa cập nhật, tự thêm To-do "Update README.md".
89+
90+
# Build outputs
91+
- Khi build mobile/desktop xong, in rõ:
92+
- 📱 đường dẫn artifact
93+
- 🔑 ghi chú ký (nếu cần)
94+
- 🐞 debug: log đang bật
95+
- 🔒 release: xác nhận đã tắt log nhạy cảm
96+
97+
# End of rules.

.env.example

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# StillMe AI Framework Environment Variables
2+
# Copy this file to .env and fill in your values
3+
4+
# API Keys
5+
API_KEY=your_api_key_here
6+
SECRET_KEY=your_secret_key_here
7+
TOKEN=your_token_here
8+
9+
# Database
10+
DATABASE_URL=postgresql://user:password@localhost/dbname
11+
12+
# Security
13+
ENCRYPTION_KEY=your_encryption_key_here
14+
JWT_SECRET=your_jwt_secret_here
15+
16+
# External Services
17+
OPENAI_API_KEY=your_openai_key_here
18+
GOOGLE_API_KEY=your_google_key_here
19+
20+
# Development
21+
DEBUG=False
22+
LOG_LEVEL=INFO

.env.local

120 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)