mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-12 09:13:17 +08:00
清理综合模式中的 Wiki/记忆遗留逻辑并完善自治技能文档。
彻底移除 manager_memory 与 wiki 注入写入分支,收敛网关分发路径和测试用例,同时补齐并中文化 session-bootstrap / wiki-first-autonomy / self-improvement 的 Wiki-first 规范,保证行为与提示词一致。 Made-with: Cursor
This commit is contained in:
parent
8b8265eb46
commit
3122b8a16c
23 changed files with 948 additions and 1093 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
# Skill Extraction Helper
|
||||
# Creates a new skill from a learning entry
|
||||
# Usage: ./extract-skill.sh <skill-name> [--dry-run]
|
||||
# 用法: ./extract-skill.sh <skill-name> [--dry-run]
|
||||
|
||||
set -e
|
||||
|
||||
|
|
@ -16,37 +16,37 @@ NC='\033[0m' # No Color
|
|||
|
||||
usage() {
|
||||
cat << EOF
|
||||
Usage: $(basename "$0") <skill-name> [options]
|
||||
用法: $(basename "$0") <skill-name> [options]
|
||||
|
||||
Create a new skill from a learning entry.
|
||||
根据学习条目创建新技能。
|
||||
|
||||
Arguments:
|
||||
skill-name Name of the skill (lowercase, hyphens for spaces)
|
||||
参数:
|
||||
skill-name 技能名称(小写,空格使用连字符)
|
||||
|
||||
Options:
|
||||
--dry-run Show what would be created without creating files
|
||||
--output-dir Relative output directory under current path (default: ./skills)
|
||||
-h, --help Show this help message
|
||||
选项:
|
||||
--dry-run 仅预览将创建的内容,不落盘
|
||||
--output-dir 当前路径下的相对输出目录(默认: ./skills)
|
||||
-h, --help 显示帮助信息
|
||||
|
||||
Examples:
|
||||
示例:
|
||||
$(basename "$0") docker-m1-fixes
|
||||
$(basename "$0") api-timeout-patterns --dry-run
|
||||
$(basename "$0") pnpm-setup --output-dir ./runtime/skills/custom
|
||||
|
||||
The skill will be created in: \$SKILLS_DIR/<skill-name>/
|
||||
技能将创建在: \$SKILLS_DIR/<skill-name>/
|
||||
EOF
|
||||
}
|
||||
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
echo -e "${GREEN}[信息]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
echo -e "${YELLOW}[警告]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1" >&2
|
||||
echo -e "${RED}[错误]${NC} $1" >&2
|
||||
}
|
||||
|
||||
# Parse arguments
|
||||
|
|
@ -61,7 +61,7 @@ while [[ $# -gt 0 ]]; do
|
|||
;;
|
||||
--output-dir)
|
||||
if [ -z "${2:-}" ] || [[ "${2:-}" == -* ]]; then
|
||||
log_error "--output-dir requires a relative path argument"
|
||||
log_error "--output-dir 需要提供相对路径参数"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -73,7 +73,7 @@ while [[ $# -gt 0 ]]; do
|
|||
exit 0
|
||||
;;
|
||||
-*)
|
||||
log_error "Unknown option: $1"
|
||||
log_error "未知选项: $1"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
|
|
@ -81,7 +81,7 @@ while [[ $# -gt 0 ]]; do
|
|||
if [ -z "$SKILL_NAME" ]; then
|
||||
SKILL_NAME="$1"
|
||||
else
|
||||
log_error "Unexpected argument: $1"
|
||||
log_error "意外参数: $1"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -92,26 +92,26 @@ done
|
|||
|
||||
# Validate skill name
|
||||
if [ -z "$SKILL_NAME" ]; then
|
||||
log_error "Skill name is required"
|
||||
log_error "必须提供技能名称"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate skill name format (lowercase, hyphens, no spaces)
|
||||
if ! [[ "$SKILL_NAME" =~ ^[a-z0-9]+(-[a-z0-9]+)*$ ]]; then
|
||||
log_error "Invalid skill name format. Use lowercase letters, numbers, and hyphens only."
|
||||
log_error "Examples: 'docker-fixes', 'api-patterns', 'pnpm-setup'"
|
||||
log_error "技能名称格式无效。仅允许小写字母、数字和连字符。"
|
||||
log_error "示例: 'docker-fixes', 'api-patterns', 'pnpm-setup'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate output path to avoid writes outside current workspace.
|
||||
if [[ "$SKILLS_DIR" = /* ]]; then
|
||||
log_error "Output directory must be a relative path under the current directory."
|
||||
log_error "输出目录必须是当前目录下的相对路径。"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$SKILLS_DIR" =~ (^|/)\.\.(/|$) ]]; then
|
||||
log_error "Output directory cannot include '..' path segments."
|
||||
log_error "输出目录不能包含 '..' 路径段。"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
@ -122,54 +122,54 @@ SKILL_PATH="$SKILLS_DIR/$SKILL_NAME"
|
|||
|
||||
# Check if skill already exists
|
||||
if [ -d "$SKILL_PATH" ] && [ "$DRY_RUN" = false ]; then
|
||||
log_error "Skill already exists: $SKILL_PATH"
|
||||
log_error "Use a different name or remove the existing skill first."
|
||||
log_error "技能已存在: $SKILL_PATH"
|
||||
log_error "请更换名称或先删除已有技能目录。"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dry run output
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
log_info "Dry run - would create:"
|
||||
log_info "预览模式 - 将会创建:"
|
||||
echo " $SKILL_PATH/"
|
||||
echo " $SKILL_PATH/SKILL.md"
|
||||
echo ""
|
||||
echo "Template content would be:"
|
||||
echo "模板内容预览:"
|
||||
echo "---"
|
||||
cat << TEMPLATE
|
||||
name: $SKILL_NAME
|
||||
description: "[TODO: Add a concise description of what this skill does and when to use it]"
|
||||
description: "[TODO: 用一句话说明技能作用与触发场景]"
|
||||
---
|
||||
|
||||
# $(echo "$SKILL_NAME" | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2))}1')
|
||||
|
||||
[TODO: Brief introduction explaining the skill's purpose]
|
||||
[TODO: 简要说明技能目的]
|
||||
|
||||
## Quick Reference
|
||||
|
||||
| Situation | Action |
|
||||
|-----------|--------|
|
||||
| [Trigger condition] | [What to do] |
|
||||
| [触发条件] | [执行动作] |
|
||||
|
||||
## Usage
|
||||
|
||||
[TODO: Detailed usage instructions]
|
||||
[TODO: 详细使用说明]
|
||||
|
||||
## Examples
|
||||
|
||||
[TODO: Add concrete examples]
|
||||
[TODO: 补充具体示例]
|
||||
|
||||
## Source Learning
|
||||
|
||||
This skill was extracted from a learning entry.
|
||||
- Learning ID: [TODO: Add original learning ID]
|
||||
- Original File: .learnings/LEARNINGS.md
|
||||
本技能由学习条目提炼生成。
|
||||
- Learning ID: [TODO: 填写原始学习条目 ID]
|
||||
- Original File: improvement/learnings.md
|
||||
TEMPLATE
|
||||
echo "---"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Create skill directory structure
|
||||
log_info "Creating skill: $SKILL_NAME"
|
||||
log_info "正在创建技能: $SKILL_NAME"
|
||||
|
||||
mkdir -p "$SKILL_PATH"
|
||||
|
||||
|
|
@ -177,45 +177,45 @@ mkdir -p "$SKILL_PATH"
|
|||
cat > "$SKILL_PATH/SKILL.md" << TEMPLATE
|
||||
---
|
||||
name: $SKILL_NAME
|
||||
description: "[TODO: Add a concise description of what this skill does and when to use it]"
|
||||
description: "[TODO: 用一句话说明技能作用与触发场景]"
|
||||
---
|
||||
|
||||
# $(echo "$SKILL_NAME" | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2))}1')
|
||||
|
||||
[TODO: Brief introduction explaining the skill's purpose]
|
||||
[TODO: 简要说明技能目的]
|
||||
|
||||
## Quick Reference
|
||||
|
||||
| Situation | Action |
|
||||
|-----------|--------|
|
||||
| [Trigger condition] | [What to do] |
|
||||
| [触发条件] | [执行动作] |
|
||||
|
||||
## Usage
|
||||
|
||||
[TODO: Detailed usage instructions]
|
||||
[TODO: 详细使用说明]
|
||||
|
||||
## Examples
|
||||
|
||||
[TODO: Add concrete examples]
|
||||
[TODO: 补充具体示例]
|
||||
|
||||
## Source Learning
|
||||
|
||||
This skill was extracted from a learning entry.
|
||||
- Learning ID: [TODO: Add original learning ID]
|
||||
- Original File: .learnings/LEARNINGS.md
|
||||
本技能由学习条目提炼生成。
|
||||
- Learning ID: [TODO: 填写原始学习条目 ID]
|
||||
- Original File: improvement/learnings.md
|
||||
TEMPLATE
|
||||
|
||||
log_info "Created: $SKILL_PATH/SKILL.md"
|
||||
log_info "已创建: $SKILL_PATH/SKILL.md"
|
||||
|
||||
# Suggest next steps
|
||||
echo ""
|
||||
log_info "Skill scaffold created successfully!"
|
||||
log_info "技能脚手架创建成功!"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Edit $SKILL_PATH/SKILL.md"
|
||||
echo " 2. Fill in the TODO sections with content from your learning"
|
||||
echo " 3. Add references/ folder if you have detailed documentation"
|
||||
echo " 4. Add scripts/ folder if you have executable code"
|
||||
echo " 5. Update the original learning entry with:"
|
||||
echo "下一步建议:"
|
||||
echo " 1. 编辑 $SKILL_PATH/SKILL.md"
|
||||
echo " 2. 用你的学习内容填写 TODO 区块"
|
||||
echo " 3. 若有详细文档,新增 references/ 目录"
|
||||
echo " 4. 若有可执行脚本,新增 scripts/ 目录"
|
||||
echo " 5. 在原学习条目中更新:"
|
||||
echo " **Status**: promoted_to_skill"
|
||||
echo " **Skill-Path**: skills/$SKILL_NAME"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue