autosnippet 2.0.2 → 2.4.0

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.
Files changed (47) hide show
  1. package/README.md +189 -113
  2. package/bin/api-server.js +1 -4
  3. package/bin/cli.js +1 -50
  4. package/config/constitution.yaml +33 -107
  5. package/dashboard/dist/assets/{icons-B4FfLfBA.js → icons-B5rs8uNb.js} +85 -80
  6. package/dashboard/dist/assets/index-0YzLw2ga.css +1 -0
  7. package/dashboard/dist/assets/index-B9py3ybr.js +154 -0
  8. package/dashboard/dist/index.html +3 -3
  9. package/lib/bootstrap.js +5 -31
  10. package/lib/cli/SetupService.js +16 -14
  11. package/lib/core/capability/CapabilityProbe.js +8 -6
  12. package/lib/core/constitution/Constitution.js +13 -4
  13. package/lib/core/constitution/ConstitutionValidator.js +106 -211
  14. package/lib/core/gateway/Gateway.js +34 -98
  15. package/lib/core/gateway/GatewayActionRegistry.js +12 -1
  16. package/lib/core/permission/PermissionManager.js +2 -2
  17. package/lib/external/mcp/McpServer.js +4 -7
  18. package/lib/external/mcp/handlers/bootstrap.js +13 -1
  19. package/lib/external/mcp/handlers/browse.js +0 -7
  20. package/lib/external/mcp/handlers/candidate.js +1 -1
  21. package/lib/external/mcp/handlers/guard.js +11 -0
  22. package/lib/external/mcp/handlers/skill.js +186 -18
  23. package/lib/external/mcp/tools.js +40 -1
  24. package/lib/http/middleware/roleResolver.js +1 -1
  25. package/lib/http/routes/auth.js +2 -2
  26. package/lib/http/routes/commands.js +58 -3
  27. package/lib/http/routes/monitoring.js +4 -4
  28. package/lib/http/routes/recipes.js +96 -4
  29. package/lib/http/routes/search.js +34 -35
  30. package/lib/injection/ServiceContainer.js +21 -40
  31. package/lib/service/candidate/CandidateService.js +12 -1
  32. package/lib/service/chat/ChatAgent.js +171 -30
  33. package/lib/service/chat/Memory.js +104 -0
  34. package/lib/service/chat/tools.js +244 -10
  35. package/lib/service/guard/GuardCheckEngine.js +9 -1
  36. package/lib/service/knowledge/KnowledgeGraphService.js +20 -9
  37. package/lib/service/recipe/RecipeService.js +8 -0
  38. package/lib/service/skills/SkillHooks.js +126 -0
  39. package/package.json +1 -1
  40. package/scripts/init-db.js +1 -2
  41. package/templates/constitution.yaml +29 -85
  42. package/dashboard/dist/assets/index-ChxJxX4B.js +0 -154
  43. package/dashboard/dist/assets/index-DwAp1mx5.css +0 -1
  44. package/lib/core/session/SessionManager.js +0 -232
  45. package/lib/infrastructure/logging/ReasoningLogger.js +0 -269
  46. package/lib/infrastructure/monitoring/RoleDriftMonitor.js +0 -259
  47. package/lib/infrastructure/quality/ComplianceEvaluator.js +0 -326
@@ -5,65 +5,45 @@
5
5
  # 三层权限架构:
6
6
  # ① 能力层 (capabilities) — git push --dry-run 探测物理写权限
7
7
  # ② 角色层 (roles) — 角色权限矩阵 (action:resource)
8
- # ③ 治理层 (priorities) 业务规则引擎
8
+ # ③ 治理层 (rules) 扁平规则引擎
9
9
  #
10
10
  # 双路径模式:
11
11
  # AUTH_ENABLED=false → 子仓库探针自动决定角色(能力层驱动)
12
12
  # AUTH_ENABLED=true → 登录后根据用户配置角色(角色层驱动)
13
13
  # ═══════════════════════════════════════════════════════════
14
14
 
15
- version: "2.0"
16
- effective_date: "2026-02-10"
15
+ version: "3.0"
16
+ effective_date: "2026-02-13"
17
17
 
18
18
  # ─── 能力探测 ─────────────────────────────────────────────
19
19
  capabilities:
20
20
  git_write:
21
21
  description: "子仓库 git push 权限"
22
22
  probe: "git push --dry-run"
23
- # 无子仓库 → 个人项目, 视为 admin (全权限)
24
23
  no_subrepo: "allow"
25
- # 有子仓库但无 remote → 本地开发, 视为 admin
26
24
  no_remote: "allow"
27
25
  cache_ttl: 86400
28
26
 
29
- # ─── 治理优先级 ───────────────────────────────────────────
30
- priorities:
31
- - id: 1
32
- name: "Data Integrity"
33
- description: "保护用户项目数据不被破坏"
34
- rules:
35
- - "所有写操作必须经过备份"
36
- - "删除操作必须有确认步骤"
37
- - "关键文件修改需要记录审计日志"
38
-
39
- - id: 2
40
- name: "Human Oversight"
41
- description: "保持人类对 AI 决策的监督"
42
- rules:
43
- - "AI 生成的 Candidate 必须经人工审核"
44
- - "Guard 规则修改需要人工批准"
45
- - "批量操作需要明确授权"
46
-
47
- - id: 3
48
- name: "AI Transparency"
49
- description: "AI 决策过程必须可追溯"
50
- rules:
51
- - "Candidate 必须包含 Reasoning 信息"
52
- - "Guard 规则必须关联来源 Recipe"
53
- - "所有 AI 操作记录到审计日志"
54
-
55
- - id: 4
56
- name: "Helpfulness"
57
- description: "在保证安全前提下尽可能帮助用户"
58
- rules:
59
- - "提供充分的错误信息和修复建议"
60
- - "优先推荐高质量 Recipe"
61
- - "自动优化常见操作"
27
+ # ─── 治理规则(扁平规则替代优先级层级) ─────────────────
28
+ rules:
29
+ - id: "destructive_confirm"
30
+ description: "删除操作需要确认"
31
+ check: "destructive_needs_confirmation"
32
+ - id: "content_required"
33
+ description: "创建 candidate/recipe 需要内容"
34
+ check: "creation_needs_content"
35
+ - id: "ai_no_direct_recipe"
36
+ description: "AI 不能直接创建/批准 recipe"
37
+ check: "ai_cannot_approve_recipe"
38
+ - id: "batch_authorized"
39
+ description: "批量操作需要授权"
40
+ check: "batch_needs_authorization"
62
41
 
42
+ # ─── 角色定义 ─────────────────────────────────────────────
63
43
  roles:
64
- - id: "cursor_agent"
65
- name: "Cursor / Copilot Agent"
66
- description: "IDE 中运行的 AI 助手"
44
+ - id: "external_agent"
45
+ name: "External Agent"
46
+ description: "IDE 中的外部 AI Agent(Cursor / Copilot / Claude Code)"
67
47
  permissions:
68
48
  - "read:recipes"
69
49
  - "read:guard_rules"
@@ -71,14 +51,15 @@ roles:
71
51
  - "submit:candidates"
72
52
  - "read:audit_logs:self"
73
53
  - "knowledge:bootstrap"
54
+ - "create:skills"
74
55
  constraints:
75
56
  - "不能直接修改 Recipe"
76
57
  - "不能修改 Guard 规则"
77
58
  - "不能删除任何数据"
78
59
 
79
- - id: "asd_ais"
80
- name: "ASD AI审查"
81
- description: "AutoSnippet 内置的 AI 审查系统"
60
+ - id: "chat_agent"
61
+ name: "ChatAgent"
62
+ description: "AutoSnippet 内置 AI Agent(Dashboard 对话 / 程序化调用)"
82
63
  permissions:
83
64
  - "read:recipes"
84
65
  - "read:candidates"
@@ -88,47 +69,10 @@ roles:
88
69
  - "生成的 Candidate 必须包含完整 Reasoning"
89
70
  - "不能绕过 Guard 检查"
90
71
 
91
- - id: "guard_engine"
92
- name: "Guard 检查引擎"
93
- description: "代码质量检查系统"
94
- permissions:
95
- - "read:candidates"
96
- - "read:guard_rules"
97
- - "write:audit_logs"
98
- constraints:
99
- - "只能读取,不能修改数据"
100
-
101
- - id: "developer_admin"
102
- name: "开发者(管理员)"
103
- description: "项目管理员"
72
+ - id: "developer"
73
+ name: "开发者"
74
+ description: "项目 Owner,完整权限"
104
75
  permissions:
105
- - "*" # 全部权限
76
+ - "*"
106
77
  requires_capability:
107
78
  - "git_write"
108
-
109
- - id: "developer_contributor"
110
- name: "开发者(贡献者)"
111
- description: "项目贡献者"
112
- permissions:
113
- - "read:*"
114
- - "approve:candidates"
115
- - "reject:candidates"
116
- - "create:recipes"
117
- constraints:
118
- - "不能删除 Recipe"
119
- - "不能禁用 Guard 规则"
120
- requires_capability:
121
- - "git_write"
122
-
123
- - id: "visitor"
124
- name: "访问者"
125
- description: "只读访问(无子仓库写权限或未登录)"
126
- permissions:
127
- - "read:recipes"
128
- - "read:snippets"
129
- - "read:candidates"
130
- - "read:guard_rules"
131
- - "search:query"
132
- constraints:
133
- - "只能查看,不能修改任何数据"
134
- - "不能创建 Candidate 或 Recipe"