lov-project-port
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese端口管家 · Port Keeper
Port Steward · Port Keeper
为项目生成稳定唯一的端口号(范围 3000-8999),同一项目名永远返回相同端口。
Generates a stable, unique port number for a project (within the 3000-8999 range). The same project name will always return the same port.
端口生成算法
Port Generation Algorithm
python
def generate_port(project_name: str) -> int:
hash_value = sum(ord(c) * (i + 1) for i, c in enumerate(project_name))
return 3000 + (hash_value % 6000)python
def generate_port(project_name: str) -> int:
hash_value = sum(ord(c) * (i + 1) for i, c in enumerate(project_name))
return 3000 + (hash_value % 6000)使用场景
Use Cases
1. 查询项目端口
1. Query a Project Port
用户询问端口时,直接计算并告知:
项目 "skill-publisher" 的端口号是:7965When the user asks for a port, calculate it directly and respond:
The port number for project "skill-publisher" is: 79652. 更新项目配置
2. Update the Project Configuration
检测并更新项目中的端口配置文件:
| 文件 | 配置方式 |
|---|---|
| |
| scripts 中的 |
| |
| 通常使用 .env |
更新时优先使用 方式,最小侵入性。
.envDetect and update the port configuration files in the project:
| File | Configuration Method |
|---|---|
| |
| |
| |
| Usually uses |
When updating, prefer the method to minimize changes.
.env3. 启动开发服务器
3. Start the Development Server
bash
PORT=$(scripts/hashport.sh) pnpm devbash
PORT=$(scripts/hashport.sh) pnpm dev脚本
Scripts
运行 生成端口:
scripts/hashport.sh [project-name]bash
undefinedRun to generate a port:
scripts/hashport.sh [project-name]bash
undefined使用当前目录名
Use the current directory name
./scripts/hashport.sh
./scripts/hashport.sh
输出: 7965
Output: 7965
指定项目名
Specify a project name
./scripts/hashport.sh my-project
./scripts/hashport.sh my-project
输出: 5123
Output: 5123
undefinedundefined端口冲突处理
Port Conflict Handling
若端口被占用:
- 提示用户哪个进程占用了端口
- 建议使用 查看
lsof -i :<port> - 可追加后缀生成备用端口:
generate_port("project-dev")
If the port is occupied:
- Inform the user which process is occupying the port
- Suggest using to inspect it
lsof -i :<port> - A suffix can be appended to generate a fallback port:
generate_port("project-dev")
Runtime context (shared)
Runtime Context (Shared)
运行前读取本 Skill 包的 ,由宿主提供 上下文。字段解析顺序为:当前请求、项目上下文、个人 Preferences、品牌 Profile、通用默认值。
skill.yamlskill-runtime/v1- 只使用 Manifest 声明的字段;Profile 保存公开品牌事实,Preferences 保存个人工作偏好。
- 字段缺失时,按 Manifest 的问题配置向用户提出一个聚焦问题;用户明确同意后再保存回答。
required: true - 报错提供可复制的 、字段路径与来源,诊断内容避开秘密、完整私人路径和原始配置。
context_id
Before running, read the file of this Skill package. The host provides the context. Fields are resolved in the following order: current request, project context, personal Preferences, brand Profile, and general defaults.
skill.yamlskill-runtime/v1- Use only fields declared in the Manifest. The Profile stores public brand facts, while Preferences stores personal work preferences.
- If a field is missing, ask the user one focused question based on the Manifest's question configuration. Save the answer only after the user explicitly agrees.
required: true - Errors should provide a copyable , field path, and source. Diagnostics must avoid secrets, full private paths, and raw configuration.
context_id
通用反馈闭环
General Feedback Loop
用户在 Skill 驱动任务中提出修改意见时,继续当前产物前必须执行:
- 先判断意见是 (仅本次)还是
task-specific(可跨任务复用)。reusable - 只修改当前任务,不改 Skill。
task-specific - 先确定作用域:领域规则先更新对应 canonical Skill;适用于所有 Skill 的规则先更新共享规范。
reusable - 完成规则更新、版本、lint 与分发核验后,再把修改应用到当前任务。
- 修改会使此前的“确认”“继续”“发吧”失效;完成当前产物修改和回读后必须停下,等待用户下一步指示,不自动进入发布、提交或其他外部写入。
reusable
When a user provides modification feedback during a Skill-driven task, perform the following steps before continuing with the current deliverable:
- Determine whether the feedback is (for this task only) or
task-specific(applicable across tasks).reusable - For feedback, modify only the current task and do not change the Skill.
task-specific - For feedback, determine the scope first: update the corresponding canonical Skill for domain-specific rules, or update the shared specification for rules that apply to all Skills.
reusable - After completing the rule update, versioning, linting, and distribution verification, apply the modification to the current task.
- A modification invalidates any previous "Confirm", "Continue", or "Ship" instruction. After modifying and reading back the current deliverable, stop and wait for the user's next instruction. Do not automatically proceed to publishing, committing, or any other external write.
reusable