mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 17:23:25 +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,20 +1,23 @@
|
|||
#!/bin/bash
|
||||
# Self-Improvement Activator Hook
|
||||
# Triggers on UserPromptSubmit to remind Claude about learning capture
|
||||
# Keep output minimal (~50-100 tokens) to minimize overhead
|
||||
# 自我改进激活 Hook
|
||||
# 在 UserPromptSubmit 触发,用于提醒记录学习沉淀
|
||||
# 输出保持精简(约 50-100 tokens)以降低上下文负担
|
||||
|
||||
set -e
|
||||
|
||||
# Output reminder as system context
|
||||
# 以系统上下文形式输出提醒
|
||||
cat << 'EOF'
|
||||
<self-improvement-reminder>
|
||||
After completing this task, evaluate if extractable knowledge emerged:
|
||||
- Non-obvious solution discovered through investigation?
|
||||
- Workaround for unexpected behavior?
|
||||
- Project-specific pattern learned?
|
||||
- Error required debugging to resolve?
|
||||
本任务完成后,请判断是否产出可沉淀知识:
|
||||
- 是否通过排查得到非显而易见的解法?
|
||||
- 是否形成了异常行为的可复用绕过方案?
|
||||
- 是否识别出项目特有模式?
|
||||
- 是否有需要调试才能解决的错误?
|
||||
|
||||
If yes: Log to .learnings/ using the self-improvement skill format.
|
||||
If high-value (recurring, broadly applicable): Consider skill extraction.
|
||||
若是,请写入 Wiki:
|
||||
- improvement/learnings.md
|
||||
- improvement/errors.md
|
||||
- improvement/feature-requests.md
|
||||
若价值较高(复发、可广泛复用),请考虑提炼为独立技能。
|
||||
</self-improvement-reminder>
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
#!/bin/bash
|
||||
# Self-Improvement Error Detector Hook
|
||||
# Triggers on PostToolUse for Bash to detect command failures
|
||||
# Reads CLAUDE_TOOL_OUTPUT environment variable
|
||||
# 自我改进错误检测 Hook
|
||||
# 在 Bash 的 PostToolUse 触发,用于检测命令失败
|
||||
# 读取 CLAUDE_TOOL_OUTPUT 环境变量
|
||||
|
||||
set -e
|
||||
|
||||
# Check if tool output indicates an error
|
||||
# CLAUDE_TOOL_OUTPUT contains the result of the tool execution
|
||||
# 检查工具输出是否包含错误信号
|
||||
# CLAUDE_TOOL_OUTPUT 为工具执行结果
|
||||
OUTPUT="${CLAUDE_TOOL_OUTPUT:-}"
|
||||
|
||||
# Patterns indicating errors (case-insensitive matching)
|
||||
# 错误模式(大小写不敏感匹配)
|
||||
ERROR_PATTERNS=(
|
||||
"error:"
|
||||
"Error:"
|
||||
|
|
@ -30,7 +30,7 @@ ERROR_PATTERNS=(
|
|||
"non-zero"
|
||||
)
|
||||
|
||||
# Check if output contains any error pattern
|
||||
# 检查输出是否匹配任一错误模式
|
||||
contains_error=false
|
||||
for pattern in "${ERROR_PATTERNS[@]}"; do
|
||||
if [[ "$OUTPUT" == *"$pattern"* ]]; then
|
||||
|
|
@ -39,17 +39,17 @@ for pattern in "${ERROR_PATTERNS[@]}"; do
|
|||
fi
|
||||
done
|
||||
|
||||
# Only output reminder if error detected
|
||||
# 仅在检测到错误时输出提醒
|
||||
if [ "$contains_error" = true ]; then
|
||||
cat << 'EOF'
|
||||
<error-detected>
|
||||
A command error was detected. Consider logging this to .learnings/ERRORS.md if:
|
||||
- The error was unexpected or non-obvious
|
||||
- It required investigation to resolve
|
||||
- It might recur in similar contexts
|
||||
- The solution could benefit future sessions
|
||||
检测到命令错误。若满足以下任一条件,请记录到 improvement/errors.md:
|
||||
- 错误出乎预期或并不直观
|
||||
- 需要排查才能解决
|
||||
- 可能在相似场景复发
|
||||
- 解决方案对后续会话有复用价值
|
||||
|
||||
Use the self-improvement skill format: [ERR-YYYYMMDD-XXX]
|
||||
记录时请使用 self-improvement 技能格式:[ERR-YYYYMMDD-XXX]
|
||||
</error-detected>
|
||||
EOF
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -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