pro-craft 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl

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.

Potentially problematic release.


This version of pro-craft might be problematic. Click here for more details.

@@ -0,0 +1,52 @@
1
+ Metadata-Version: 2.4
2
+ Name: pro-craft
3
+ Version: 0.1.4
4
+ Summary: Add your description here
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: anyio>=4.11.0
8
+ Requires-Dist: db-help>=0.2.2
9
+ Requires-Dist: fastapi>=0.119.0
10
+ Requires-Dist: llmada>=1.1.11
11
+ Requires-Dist: pytest>=8.4.2
12
+ Requires-Dist: pytest-asyncio>=1.2.0
13
+ Requires-Dist: pytest-tornasync>=0.6.0.post2
14
+ Requires-Dist: pyyaml>=6.0.3
15
+ Requires-Dist: toml>=0.10.2
16
+ Requires-Dist: utils-tool==0.1.3
17
+ Requires-Dist: uvicorn>=0.38.0
18
+
19
+ uv run mcp dev src/prompt_writing_assistant/mcp.py
20
+
21
+
22
+
23
+ ```python
24
+
25
+
26
+ @mcp.tool()
27
+ async def my_tool(x: int, ctx: Context) -> str:
28
+ """Tool that uses context capabilities.
29
+
30
+ The Context object provides the following capabilities:
31
+
32
+ ctx.request_id - Unique ID for the current request
33
+ ctx.client_id - Client ID if available
34
+ ctx.fastmcp - Access to the FastMCP server instance (see FastMCP Properties)
35
+ ctx.session - Access to the underlying session for advanced communication (see Session Properties and Methods)
36
+ ctx.request_context - Access to request-specific data and lifespan resources (see Request Context Properties)
37
+ await ctx.debug(message) - Send debug log message
38
+ await ctx.info(message) - Send info log message
39
+ await ctx.warning(message) - Send warning log message
40
+ await ctx.error(message) - Send error log message
41
+ await ctx.log(level, message, logger_name=None) - Send log with custom level
42
+ await ctx.report_progress(progress, total=None, message=None) - Report operation progress
43
+ await ctx.read_resource(uri) - Read a resource by URI
44
+ await ctx.elicit(message, schema) - Request additional information from user with validation
45
+
46
+ """
47
+ # The context parameter can have any name as long as it's type-annotated
48
+ return ctx.client_id
49
+
50
+ ```
51
+
52
+
@@ -0,0 +1,23 @@
1
+ pro_craft/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ pro_craft/database.py,sha256=5dV-h9dVaS6euHLCtf0gYfq2pchl2QFdb2PEM4gTEU4,8740
3
+ pro_craft/designer.py,sha256=3gyCqrjcw61sHzDjUPKhL1LOAE8xWLLbNT8NlK2mFLc,4739
4
+ pro_craft/evals.py,sha256=1T86jur4k3cLk43j1GyAW4JS0nPNfl6P0ZOQmu-SgpA,1928
5
+ pro_craft/file_manager.py,sha256=2j7lCt9L4mtvAy8_76ibTthXLwKKmVatWIB3DSvQM7U,3805
6
+ pro_craft/log.py,sha256=MZf9jCZsiRoAq8v4FxVnJqeSXxgzAiiKf7mxz6bFtwM,4263
7
+ pro_craft/prompt_helper.py,sha256=SFIhju0Y3rRdb-T1WocUgz7qCocq1Ja2zlaEZo1RM3o,23832
8
+ pro_craft/prompt_helper_async.py,sha256=tvs2NywEqv_THvMpalu5PfewhhTm9wP89JqdKiKIUbU,25004
9
+ pro_craft/server.py,sha256=fPAosQIU0d7gxICiALl8u6QwbLI4cawVFyoRYebRES0,2827
10
+ pro_craft/utils.py,sha256=27A3CFhbRsEAP5GY6oxAz2M-beiIuPgCNSjQUyzOVW0,5685
11
+ pro_craft/code_helper/coder.py,sha256=NXglF1KiPtGe4HZN0MZvFJ8p9Iyd5kzIt72DQGgRwXA,24715
12
+ pro_craft/server/__main__.py,sha256=LDTERPMe7RKj3eifVRo9aO9fNXdd16W5Hzr1APd04T0,4227
13
+ pro_craft/server/models.py,sha256=CiUK8e73Bl7fo7ZbnwNTLYLeD4pb1fHMzWR13d3Y6vs,112
14
+ pro_craft/server/mcp/__init__.py,sha256=4dbl-lFcm0r2tkOP04OxqiZG2jR-rqF181qi2AfU6UA,123
15
+ pro_craft/server/mcp/content.py,sha256=DombC1DlasvEl_lzy4u6soVR7rxgmyWFlaEvTSdCiOU,2745
16
+ pro_craft/server/mcp/math.py,sha256=OOzGXx64nK4bOVlu33PtVddcCQ9ilqA3Em9yxjSX9cg,641
17
+ pro_craft/server/mcp/resource.py,sha256=z94jP3qZofO-1lZCM3TuOfLajw41HARs1ojXab1ymas,776
18
+ pro_craft/server/mcp/weather.py,sha256=RAGuf4sgjlTQSfRRZ1Fo18JnuMQRS_Db9p6AqBQrl8E,455
19
+ pro_craft/server/router/recommended.py,sha256=IAZFdmb8HSl2_TOJeuv5uOKIX47XyX4p4sEwxG-0vt0,9968
20
+ pro_craft-0.1.4.dist-info/METADATA,sha256=Z6XT0MYyKz3-HhE-TUxQJp52Ju_uQeCOZDxAaN9kGVw,1768
21
+ pro_craft-0.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
+ pro_craft-0.1.4.dist-info/top_level.txt,sha256=yqYDHArnYMWpeCxkmGRwlL6sJtxiOUnYylLDx9EOgFg,10
23
+ pro_craft-0.1.4.dist-info/RECORD,,
pro_craft/core.py DELETED
@@ -1 +0,0 @@
1
- print("hello world")
File without changes
File without changes
@@ -1,48 +0,0 @@
1
-
2
- import uuid
3
- from typing import Optional
4
-
5
- from sqlalchemy import String, Boolean, Column
6
- from sqlalchemy.dialects.mysql import CHAR # Use CHAR for UUID to store as fixed length string
7
- from fastapi_users.db import SQLAlchemyBaseUserTableUUID
8
- from pydantic import BaseModel, Field
9
-
10
- from umanager.server.utils import Base # 引入Base
11
-
12
- # SQLAlchemy 用户模型
13
- # 使用 SQLAlchemyBaseUserTableUUID 来自动处理 UUID 主键
14
- class User(SQLAlchemyBaseUserTableUUID, Base):
15
- __tablename__ = "users" # 表名
16
-
17
- # 可以在这里添加额外的用户属性
18
- first_name: str = Column(String(255), nullable=True)
19
- last_name: str = Column(String(255), nullable=True)
20
- is_admin: bool = Column(Boolean, default=False)
21
-
22
- # Pydantic 模型 (用于请求和响应)
23
- class UserRead(BaseModel):
24
- id: uuid.UUID
25
- email: str
26
- is_active: bool = True
27
- is_superuser: bool = False
28
- is_verified: bool = False
29
- first_name: Optional[str] = None
30
- last_name: Optional[str] = None
31
- is_admin: bool = False
32
-
33
- class Config:
34
- from_attributes = True # updated from orm_mode = True
35
-
36
- class UserCreate(BaseModel):
37
- email: str
38
- password: str
39
- first_name: Optional[str] = None
40
- last_name: Optional[str] = None
41
-
42
- class UserUpdate(UserCreate):
43
- is_active: Optional[bool] = None
44
- is_superuser: Optional[bool] = None
45
- is_verified: Optional[bool] = None
46
- first_name: Optional[str] = None
47
- last_name: Optional[str] = None
48
- is_admin: Optional[bool] = None
@@ -1,2 +0,0 @@
1
- from .admin import router as admin_router
2
- from .user import router as user_router
@@ -1,42 +0,0 @@
1
-
2
- # app/routers/admin.py
3
- from fastapi import APIRouter, Depends, HTTPException, status
4
- from fastapi import FastAPI, HTTPException, Header
5
-
6
-
7
- # 模拟获取当前用户的依赖项
8
- async def get_current_user(x_token: str = Header(...)):
9
- if x_token != "valid-secret-token":
10
- raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid X-Token header")
11
- return {"username": "admin", "roles": ["user", "admin"]}
12
-
13
- # 模拟一个管理员权限检查的依赖项
14
- async def verify_admin_role(user: dict = Depends(get_current_user)):
15
- if "admin" not in user.get("roles", []):
16
- raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="Not enough permissions")
17
- return user
18
-
19
-
20
- router = APIRouter(
21
- tags=["Admin"],
22
- dependencies=[Depends(get_current_user), Depends(verify_admin_role)] # 统一的依赖项列表
23
- )
24
-
25
-
26
-
27
- @router.get("/dashboard/")
28
- async def get_admin_dashboard_data(user):
29
- # 这个函数会自动接收到 get_current_user 和 verify_admin_role 的结果(如果需要)
30
- # 但我们在这里不需要显式接收它们,因为它们只是做权限检查
31
- print(user,'user')
32
- return {"message": "Welcome to the admin dashboard!"}
33
-
34
- @router.post("/settings/")
35
- async def update_admin_settings(settings: dict):
36
- # 这个函数也会自动执行 get_current_user 和 verify_admin_role
37
- return {"message": "Admin settings updated", "settings": settings}
38
-
39
- # 这个API也需要认证和管理员权限
40
- @router.delete("/users/{user_id}")
41
- async def delete_user(user_id: int):
42
- return {"message": f"User {user_id} deleted by admin."}
@@ -1,24 +0,0 @@
1
-
2
- # app/routers/admin.py
3
- from fastapi import APIRouter, Depends, HTTPException, status
4
- from fastapi import FastAPI, Header
5
-
6
-
7
- # 模拟获取当前用户的依赖项
8
- async def get_current_user(x_token: str = Header(...)):
9
- if x_token not in ["1234",
10
- "5678"]:
11
- raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid X-Token header")
12
- return {"username": "admin", "roles": ["user", "admin"]}
13
-
14
-
15
- router = APIRouter(
16
- tags=["users"],
17
- dependencies=[Depends(get_current_user)] # 统一的依赖项列表
18
- )
19
-
20
-
21
- @router.get("/dashboard")
22
- async def get_user(user_info :dict = Depends(get_current_user)):
23
- pass
24
- return {"message": "Welcome to the admin dashboard!"}
@@ -1,3 +0,0 @@
1
- from .database import Base, create_db_and_tables
2
- from .auth_backends import auth_backend
3
- from .user_manager import get_user_manager
@@ -1,15 +0,0 @@
1
- # auth_backends.py
2
- from fastapi_users.authentication import BearerTransport, JWTStrategy, AuthenticationBackend
3
-
4
- from .user_manager import SECRET # 从 user_manager 引入 SECRET
5
-
6
- bearer_transport = BearerTransport(tokenUrl="auth/jwt/login")
7
-
8
- def get_jwt_strategy() -> JWTStrategy:
9
- return JWTStrategy(secret=SECRET, lifetime_seconds=3600) # JWT有效期1小时
10
-
11
- auth_backend = AuthenticationBackend(
12
- name="jwt",
13
- transport=bearer_transport,
14
- get_strategy=get_jwt_strategy,
15
- )
@@ -1,27 +0,0 @@
1
- # database.py
2
- from typing import AsyncGenerator
3
-
4
- from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
5
- from sqlalchemy.orm import sessionmaker, DeclarativeBase
6
-
7
- # 您的 MySQL 连接字符串
8
- # 格式:mysql+aiomysql://user:password@host:port/database
9
- # 注意:fastapi_users 的 sqlalchemy 适配器通常需要异步驱动,
10
- # 所以我们使用 `aiomysql` (虽然你安装的是 mysql-connector-python,
11
- # 但为了异步,我们实际会用 aiomysql,请确保安装它:pip install aiomysql)
12
- DATABASE_URL = "mysql+aiomysql://root:1234@localhost:3306/prompts"
13
-
14
- class Base(DeclarativeBase):
15
- pass
16
-
17
- engine = create_async_engine(DATABASE_URL)
18
- async_session_maker = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
19
-
20
- async def get_async_session() -> AsyncGenerator[AsyncSession, None]:
21
- async with async_session_maker() as session:
22
- yield session
23
-
24
- # 创建所有定义的表(在应用启动时调用)
25
- async def create_db_and_tables():
26
- async with engine.begin() as conn:
27
- await conn.run_sync(Base.metadata.create_all)
@@ -1,87 +0,0 @@
1
- # user_manager.py
2
- import uuid
3
- from typing import Optional
4
-
5
- from fastapi import Depends, Request
6
- from fastapi_users import BaseUserManager, UUIDIDMixin
7
- # from fastapi_users_sqlalchemy import SQLAlchemyUserDatabase
8
- from fastapi_users.db import SQLAlchemyUserDatabase
9
- from .database import get_async_session
10
-
11
- from fastapi import Depends, Request, HTTPException, status # <-- 确保 HTTPException 在这里
12
- from sqlalchemy.exc import IntegrityError # <-- 确保这一行存在
13
-
14
- from umanager.server.models.models import User, UserCreate # <--- 在这里添加 UserCreate 的导入
15
-
16
- from passlib.context import CryptContext # 确保这里引入了 CryptContext
17
-
18
- # ---------- 确保 pwd_context 在模块级别定义 ----------
19
- # 它应该在任何使用它的类或函数之外
20
- pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
21
-
22
- # 替换为您的安全密钥,最好从环境变量中获取
23
- SECRET = "YOUR_SUPER_SECRET_KEY_REPLACE_ME" # !!! 重要:在生产环境中,请务必使用环境变量
24
-
25
-
26
- class UserManager(UUIDIDMixin, BaseUserManager[User, uuid.UUID]):
27
- # ... (reset_password_token_secret, verification_token_secret 保持不变)
28
-
29
- async def create(
30
- self,
31
- user_create: UserCreate,
32
- safe: bool = False,
33
- request: Optional[Request] = None,
34
- ) -> User:
35
- existing_user = await self.user_db.get_by_email(user_create.email)
36
- if existing_user is not None:
37
- raise HTTPException(
38
- status_code=status.HTTP_400_BAD_REQUEST,
39
- detail="A user with this email already exists."
40
- )
41
-
42
- hashed_password = pwd_context.hash(user_create.password)
43
-
44
- # 使用 model_dump 获取 Pydantic V2 的字典表示
45
- user_data = user_create.model_dump(exclude_unset=True)
46
- user_data["hashed_password"] = hashed_password
47
- user_data["id"] = uuid.uuid4()
48
-
49
- if "password" in user_data: # 确保移除明文密码
50
- del user_data["password"]
51
-
52
- # 创建 SQLAlchemy User 实例
53
- # 这里的 self.user_db.user_table 就是 models.User
54
- new_user = self.user_db.user_table(**user_data)
55
-
56
- # 确保默认字段被设置
57
- new_user.is_active = True
58
- new_user.is_superuser = False
59
- new_user.is_verified = False
60
-
61
- # created_user = await self.user_db.create(new_user)
62
- try:
63
- self.user_db.session.add(new_user)
64
- await self.user_db.session.commit()
65
- await self.user_db.session.refresh(new_user) # 刷新以获取可能由数据库生成的字段(如默认值)
66
- except IntegrityError:
67
- await self.user_db.session.rollback()
68
- raise HTTPException(
69
- status_code=status.HTTP_400_BAD_REQUEST,
70
- detail="A database integrity error occurred (e.g., duplicate email)."
71
- )
72
- # await self.on_after_register(created_user, request)
73
- # return created_user
74
- await self.on_after_register(new_user, request) # 这里也是 new_user
75
- return new_user
76
-
77
- async def get_user_db(session = Depends(get_async_session)):
78
- yield SQLAlchemyUserDatabase(session, User)
79
-
80
-
81
-
82
- async def get_user_manager(user_db: SQLAlchemyUserDatabase = Depends(get_user_db)):
83
- yield UserManager(user_db)
84
-
85
-
86
- # uv venv .venv --python 3.11
87
- # python -c "import pydantic; print(pydantic.VERSION)"
@@ -1,14 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pro-craft
3
- Version: 0.1.2
4
- Summary: Add your description here
5
- Requires-Python: >=3.13
6
- Description-Content-Type: text/markdown
7
- Requires-Dist: anyio>=4.11.0
8
- Requires-Dist: fastapi>=0.119.0
9
- Requires-Dist: pytest>=8.4.2
10
- Requires-Dist: pytest-asyncio>=1.2.0
11
- Requires-Dist: pytest-tornasync>=0.6.0.post2
12
- Requires-Dist: toml>=0.10.2
13
- Requires-Dist: utils-tool==0.1.3
14
- Requires-Dist: uvicorn>=0.38.0
@@ -1,25 +0,0 @@
1
- pro_craft/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- pro_craft/core.py,sha256=qEuxIwsu3XP0aa_Vq6abPKGR5sJbREz5PSM0K2TWrxg,20
3
- pro_craft/log.py,sha256=MZf9jCZsiRoAq8v4FxVnJqeSXxgzAiiKf7mxz6bFtwM,4263
4
- pro_craft/server.py,sha256=fPAosQIU0d7gxICiALl8u6QwbLI4cawVFyoRYebRES0,2827
5
- pro_craft/utils.py,sha256=Pi6-tconaDYaYV5E-Bb-gt9jDasqcVnNBAjpdXtGY5I,25
6
- pro_craft/server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- pro_craft/server/__main__.py,sha256=e4Ygx01-YHkgk0AJTHdf7N--q1_7XwxtfS2ba5yPViM,4331
8
- pro_craft/server/mcp/__init__.py,sha256=4dbl-lFcm0r2tkOP04OxqiZG2jR-rqF181qi2AfU6UA,123
9
- pro_craft/server/mcp/content.py,sha256=DombC1DlasvEl_lzy4u6soVR7rxgmyWFlaEvTSdCiOU,2745
10
- pro_craft/server/mcp/math.py,sha256=OOzGXx64nK4bOVlu33PtVddcCQ9ilqA3Em9yxjSX9cg,641
11
- pro_craft/server/mcp/resource.py,sha256=z94jP3qZofO-1lZCM3TuOfLajw41HARs1ojXab1ymas,776
12
- pro_craft/server/mcp/weather.py,sha256=RAGuf4sgjlTQSfRRZ1Fo18JnuMQRS_Db9p6AqBQrl8E,455
13
- pro_craft/server/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- pro_craft/server/models/models.py,sha256=VlYy3VYuIAZ8p8vd5Qcnyjzy8-EnQQbbVPl6YN1mCjg,1491
15
- pro_craft/server/routers/__init__.py,sha256=mnJ7XmAzyZePf6CxusxbTZZF0xbqnDqYg3Z929rbSqQ,81
16
- pro_craft/server/routers/admin.py,sha256=4flQtIMhVFoEf4z3rxC3W0k70Gtpupbv_JrM_AqWZnc,1608
17
- pro_craft/server/routers/user.py,sha256=SHNXnJDSM2hKVpKQVUnjlBN-sVWuANlrAF26TWpDCR8,723
18
- pro_craft/server/utils/__init__.py,sha256=ziKn9B14SbHdwnRH9cxiA-rXHuzjtPDM1mAIdRc9p-I,131
19
- pro_craft/server/utils/auth_backends.py,sha256=7eZ2tC7P6Tw1wBN3X5RWt1FNJKtzpZutmMg5rRbDbNQ,490
20
- pro_craft/server/utils/database.py,sha256=t2cTLmTT0yD9ObXZxpJrLo-d38C_QRtHTVrtLcgem3o,1083
21
- pro_craft/server/utils/user_manager.py,sha256=tmvmoCfblMpBQtvhYsy5YS0ANy2mSW3vvS-rsajhzVw,3380
22
- pro_craft-0.1.2.dist-info/METADATA,sha256=_IHzx-JjxD30BDY0LSm6BL3uIpollO2HzM169oiU_kg,416
23
- pro_craft-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
- pro_craft-0.1.2.dist-info/top_level.txt,sha256=yqYDHArnYMWpeCxkmGRwlL6sJtxiOUnYylLDx9EOgFg,10
25
- pro_craft-0.1.2.dist-info/RECORD,,