plugins/tools/cortex/skills/cortex-memory/SKILL.md
记忆生命周期管理 — 自动维护 (晋级候选扫 / forget 标记 / 弱条目补充 / weight bump / uri-index 整理) + URI 寻址 CRUD 子命令。无入参跑全量维护; 有 verb 走 CRUD。Triggers on "整理记忆", "维护记忆", "记忆体检", "memory maintain", "记忆写入", "memory write/read/update/delete", "forget", "遗忘".
npx skillsauth add lazygophers/ccplugin cortex-memoryInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
[AUTO_MODE persistent: 禁询问, 自决执行, 禁中止]
记忆生命周期管理 — 默认跑维护扫 (非破坏); 有显式 verb 才降级到 CRUD。可独立调用, 也由 cortex-digest 阶段 4 委派。
/cortex:memory 无参 → 跑维护cortex-digest 阶段 4 委派 → 跑维护 (其内联 promote-candidates + forget-marker 子集)memory-promote / memory-forget / /cortex:forget → 等价于跑维护 (子集)入参为空 / 仅 --vault → 维护扫 (默认)
入参含 verb=read|write|update|delete → CRUD (走 crud-operations.md)
~/.cortex/scripts/ledger.sh uri_index_rebuild 重建 _meta/uri-index.json; 校验 frontmatter (level/uri/weight/last_recalled 完整 + URI 全局唯一)记忆/L3-短期/episodic/ + 记忆/L2-中期/semantic/:
needs_user_approval: true)记忆/views/candidates.md (覆写整页), 不自动晋examples / body; 不删原内容now - last_recalled > 90 天 且 recall_count < 3 → frontmatter archive_pending: truenow - last_recalled > 365 天 且 recall_count < 5 → 同上记忆/views/alerts.md ## memory-forget <UTC ISO> 列 uri 清单importance ↑; 用户 "不对/错了" → confidence -= 1.0, "对的" → confidence += 0.5 (scripts/cli/lib/evolution.py:update_doc_scores)破坏性操作 (实际归档 / L4 gzip / 腐化删除) 不在维护扫内, 由独立 cron 跑:
memory-archive(月 1st 06:00) — archive_pending 落归档/forgotten/memory-compact(周日 04:00) — L4 ledger gzipmemory-warden(1st/15th 05:00) — 腐化检测
verb=read → 解析 URI → 读 frontmatter + brief (详见 crud-operations.md §read)
verb=write → policy 校验 (L0 拒 / L1 weight≥0.8 / L2 dedupe / L3/L4 自动) → 写 frontmatter + body
verb=update→ 解析 → 校验 immutable_after_confirm → 写回, created 不变
verb=delete→ L0 拒 / L1 force-user / L2-L4 archive_pending=true
URI 解析失败 / 路径越界 → 立即拒绝, 不写盘。
L<N>://<path> (e.g. L2://semantic/go/goroutine)--level, --weight (0.0-1.0), --recall_when (string), --ref (知识库路径), --parents, --children--full (read 时返回完整 full 字段, 默认仅 brief){
"mode": "maintain",
"indexed": <N>, "invalid_frontmatter": <N>, "duplicate_uri": <N>,
"promote_candidates_L3_to_L2": <N>, "promote_candidates_L2_to_L1": <N>, "promote_candidates_L1_to_L0": <N>,
"auto_promoted_L4_to_L3": <N>,
"enriched": <N>,
"forget_marked_L2": <N>, "forget_marked_L3": <N>,
"scores_updated": <N>
}
{"ok": true, "mode": "<verb>", "uri": "<u>", "data": {...}}
auto 后缀触发)~/.cortex/scripts/memory.sh <verb> <uri> --interactive| 文件 | 用途 |
|---|---|
| references/crud-operations.md | CRUD 4 verb 详细流程 + URI 解析 + frontmatter 自动填 + 错误处理 |
| references/forget.md | forget 标记子流程 (维护阶段 4 详细; daily cron / /cortex:forget 触发等价) |
| references/scoring.md | importance / confidence 2 评分字段强制 (lint rule 23) + 启发式 + 衰减规则 |
development
Go 数据库规范——GORM Model 命名 ModelXxx、表名单数、枚举 uint8 + 常量、索引 idx_ 前缀 + deleted_at leading column、禁 time.Time 统一 int64 unix、禁指针/nullable 字段、TEXT/BLOB/JSON 禁 default、AutoMigrate 禁改主键。设计 DB model、写 GORM tag、建索引、做 migration 审查时触发。
development
Go HTTP API 规范——响应始终 200 + body code 字段、路由 /api/* 全 POST 单段 <Action><Model>、中间件逐路由注册禁 Group(prefix,mw...)、handler 仅返回 (rsp,error)、认证走 header。设计 HTTP API、写路由/handler/中间件时触发。
development
Go 项目结构规范——三层架构(API → Impl → State)、全局状态模式、internal/ 私有包、cmd/ 仅 main.go、go.work 多模块、禁止 Repository 接口和 DI 容器、struct 公共字段开头全 omitempty、handler var rsp 顶声明、禁 legacy migration。设计项目骨架、新建目录、组织包、做架构评审时触发。
development
Go 命名规范——Id/Uid 字段(非 ID)、IsActive/HasMFA 布尔前缀、CreatedAt 时间字段、接收者统一用 p、包名全小写无下划线、泛型类型参数描述性命名、集合字段 xxx_list 禁 xxxs 复数、Enum 0 值 XxxNil 禁 Unknown、禁 Status 统一 State、Set/Update 语义区分。定义结构体字段、函数、变量、包、接收者名、泛型、枚举时触发。