@hongmaple0820/scale-engine 0.43.0 → 0.45.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 (55) hide show
  1. package/README.en.md +2 -2
  2. package/README.md +3 -3
  3. package/dist/api/cli.js +24 -2
  4. package/dist/api/cli.js.map +1 -1
  5. package/dist/api/mcp.js +86 -0
  6. package/dist/api/mcp.js.map +1 -1
  7. package/dist/codegraph/CodeIntelligence.d.ts +67 -0
  8. package/dist/codegraph/CodeIntelligence.js +457 -5
  9. package/dist/codegraph/CodeIntelligence.js.map +1 -1
  10. package/dist/cortex/SessionInjector.d.ts +1 -0
  11. package/dist/cortex/SessionInjector.js +33 -0
  12. package/dist/cortex/SessionInjector.js.map +1 -1
  13. package/dist/dashboard/DashboardServer.d.ts +33 -13
  14. package/dist/dashboard/DashboardServer.js +314 -182
  15. package/dist/dashboard/DashboardServer.js.map +1 -1
  16. package/dist/dashboard/index.d.ts +2 -2
  17. package/dist/dashboard/index.js +1 -1
  18. package/dist/dashboard/index.js.map +1 -1
  19. package/dist/dashboard/server.d.ts +8 -22
  20. package/dist/dashboard/server.js +2 -83
  21. package/dist/dashboard/server.js.map +1 -1
  22. package/dist/index.d.ts +1 -1
  23. package/dist/index.js +1 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/memory/MemoryBrain.d.ts +22 -0
  26. package/dist/memory/MemoryBrain.js +183 -4
  27. package/dist/memory/MemoryBrain.js.map +1 -1
  28. package/dist/memory/MemoryProviders.d.ts +6 -1
  29. package/dist/memory/MemoryProviders.js +190 -6
  30. package/dist/memory/MemoryProviders.js.map +1 -1
  31. package/dist/setup/SetupWizard.js +21 -7
  32. package/dist/setup/SetupWizard.js.map +1 -1
  33. package/dist/skills/SkillRepository.js +64 -1
  34. package/dist/skills/SkillRepository.js.map +1 -1
  35. package/dist/topology/DomainMapper.d.ts +23 -0
  36. package/dist/topology/DomainMapper.js +179 -0
  37. package/dist/topology/DomainMapper.js.map +1 -0
  38. package/dist/topology/LayerClassifier.d.ts +8 -0
  39. package/dist/topology/LayerClassifier.js +109 -0
  40. package/dist/topology/LayerClassifier.js.map +1 -0
  41. package/dist/topology/TourGenerator.d.ts +18 -0
  42. package/dist/topology/TourGenerator.js +120 -0
  43. package/dist/topology/TourGenerator.js.map +1 -0
  44. package/dist/topology/index.d.ts +3 -0
  45. package/dist/topology/index.js +4 -0
  46. package/dist/topology/index.js.map +1 -0
  47. package/docs/README.md +3 -0
  48. package/docs/architecture/README.md +248 -0
  49. package/docs/migration/v0.38-to-v0.44.md +232 -0
  50. package/docs/reference/cli.md +234 -0
  51. package/package.json +6 -5
  52. package/docs/EXTERNAL_REFERENCES.md +0 -66
  53. package/docs/SKILL-REPOSITORY.md +0 -57
  54. package/docs/SKILL_RADAR.md +0 -135
  55. package/docs/THIRD_PARTY_SKILLS.md +0 -114
@@ -0,0 +1,120 @@
1
+ const LAYER_DESCRIPTIONS = {
2
+ api: 'API layer — handles external requests and routes them to the appropriate services',
3
+ service: 'Service layer — contains business logic and orchestrates operations',
4
+ data: 'Data layer — manages data persistence, models, and storage',
5
+ ui: 'UI layer — renders the user interface and handles user interactions',
6
+ utility: 'Utility layer — provides shared helpers and common functionality',
7
+ config: 'Configuration layer — defines settings and initialization',
8
+ test: 'Test layer — verifies correctness through automated tests',
9
+ unknown: 'Unclassified component',
10
+ };
11
+ export function generateTour(graph, options = {}) {
12
+ const maxStops = options.maxStops ?? 20;
13
+ const entryPoints = findEntryPoints(graph);
14
+ const orderedNodes = bfsFromEntries(graph, entryPoints);
15
+ const stops = [];
16
+ for (const nodeId of orderedNodes) {
17
+ if (stops.length >= maxStops)
18
+ break;
19
+ const node = graph.nodes.find(n => n.id === nodeId);
20
+ if (!node)
21
+ continue;
22
+ const relatedNodes = findRelatedNodes(graph, nodeId);
23
+ stops.push({
24
+ nodeId,
25
+ title: formatNodeTitle(node),
26
+ description: generateStopDescription(node, graph),
27
+ layer: node.layer ?? 'unknown',
28
+ relatedNodes,
29
+ order: stops.length + 1,
30
+ });
31
+ }
32
+ return {
33
+ name: options.focusDomain
34
+ ? `${options.focusDomain} Architecture Tour`
35
+ : 'Architecture Tour',
36
+ stops,
37
+ estimatedMinutes: Math.max(1, Math.ceil(stops.length * 0.5)),
38
+ };
39
+ }
40
+ function findEntryPoints(graph) {
41
+ const incomingCount = new Map();
42
+ for (const edge of graph.edges) {
43
+ incomingCount.set(edge.target, (incomingCount.get(edge.target) ?? 0) + 1);
44
+ }
45
+ // Entry points: nodes with no incoming edges, preferring main/index/app/server
46
+ const noIncoming = graph.nodes.filter(n => (incomingCount.get(n.id) ?? 0) === 0);
47
+ const priorityNames = ['main', 'index', 'app', 'server', 'cli', 'entry', 'run', 'start'];
48
+ const sorted = noIncoming.sort((a, b) => {
49
+ const aPriority = priorityNames.findIndex(name => a.name.toLowerCase().includes(name));
50
+ const bPriority = priorityNames.findIndex(name => b.name.toLowerCase().includes(name));
51
+ const aRank = aPriority === -1 ? 999 : aPriority;
52
+ const bRank = bPriority === -1 ? 999 : bPriority;
53
+ return aRank - bRank;
54
+ });
55
+ // If no entry points found, use all file-level nodes
56
+ if (sorted.length === 0) {
57
+ return graph.nodes.filter(n => n.kind === 'file').slice(0, 5).map(n => n.id);
58
+ }
59
+ return sorted.slice(0, 10).map(n => n.id);
60
+ }
61
+ function bfsFromEntries(graph, entries) {
62
+ const visited = new Set();
63
+ const order = [];
64
+ const queue = [...entries];
65
+ while (queue.length > 0) {
66
+ const current = queue.shift();
67
+ if (visited.has(current))
68
+ continue;
69
+ visited.add(current);
70
+ order.push(current);
71
+ // Follow outgoing edges (dependencies, calls)
72
+ for (const edge of graph.edges) {
73
+ if (edge.source === current && !visited.has(edge.target)) {
74
+ queue.push(edge.target);
75
+ }
76
+ }
77
+ }
78
+ // Add any unvisited nodes at the end
79
+ for (const node of graph.nodes) {
80
+ if (!visited.has(node.id)) {
81
+ order.push(node.id);
82
+ }
83
+ }
84
+ return order;
85
+ }
86
+ function findRelatedNodes(graph, nodeId) {
87
+ const related = new Set();
88
+ for (const edge of graph.edges) {
89
+ if (edge.source === nodeId)
90
+ related.add(edge.target);
91
+ if (edge.target === nodeId)
92
+ related.add(edge.source);
93
+ }
94
+ return Array.from(related).slice(0, 5);
95
+ }
96
+ function formatNodeTitle(node) {
97
+ const layerTag = node.layer ? `[${node.layer.toUpperCase()}] ` : '';
98
+ const kindTag = node.kind === 'file' ? '' : ` (${node.kind})`;
99
+ return `${layerTag}${node.name}${kindTag}`;
100
+ }
101
+ function generateStopDescription(node, graph) {
102
+ const layerDesc = LAYER_DESCRIPTIONS[node.layer ?? 'unknown'];
103
+ const parts = [layerDesc];
104
+ if (node.filePath) {
105
+ parts.push(`Located in ${node.filePath}`);
106
+ }
107
+ // Count connections
108
+ const outgoing = graph.edges.filter(e => e.source === node.id).length;
109
+ const incoming = graph.edges.filter(e => e.target === node.id).length;
110
+ if (outgoing > 0 || incoming > 0) {
111
+ const connDesc = [];
112
+ if (outgoing > 0)
113
+ connDesc.push(`depends on ${outgoing}`);
114
+ if (incoming > 0)
115
+ connDesc.push(`depended on by ${incoming}`);
116
+ parts.push(`Connections: ${connDesc.join(', ')}`);
117
+ }
118
+ return parts.join('. ') + '.';
119
+ }
120
+ //# sourceMappingURL=TourGenerator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TourGenerator.js","sourceRoot":"","sources":["../../src/topology/TourGenerator.ts"],"names":[],"mappings":"AAiBA,MAAM,kBAAkB,GAAsC;IAC5D,GAAG,EAAE,mFAAmF;IACxF,OAAO,EAAE,qEAAqE;IAC9E,IAAI,EAAE,4DAA4D;IAClE,EAAE,EAAE,qEAAqE;IACzE,OAAO,EAAE,kEAAkE;IAC3E,MAAM,EAAE,2DAA2D;IACnE,IAAI,EAAE,2DAA2D;IACjE,OAAO,EAAE,wBAAwB;CAClC,CAAA;AAED,MAAM,UAAU,YAAY,CAAC,KAAoB,EAAE,UAAuD,EAAE;IAC1G,MAAM,QAAQ,GAAG,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;QAClB,KAAK,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC3C,CAAC;IAED,oBAAoB;IACpB,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAA;IACrE,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAA;IACrE,IAAI,QAAQ,GAAG,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAa,EAAE,CAAA;QAC7B,IAAI,QAAQ,GAAG,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,cAAc,QAAQ,EAAE,CAAC,CAAA;QACzD,IAAI,QAAQ,GAAG,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,kBAAkB,QAAQ,EAAE,CAAC,CAAA;QAC7D,KAAK,CAAC,IAAI,CAAC,gBAAgB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACnD,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;AAC/B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { classifyLayers, getLayerColor, DEFAULT_LAYER_RULES, type LayerRule } from './LayerClassifier.js';
2
+ export { mapDomains, type BusinessDomain, type DomainFlow, type DomainMapping } from './DomainMapper.js';
3
+ export { generateTour, type TourStop, type GuidedTour } from './TourGenerator.js';
@@ -0,0 +1,4 @@
1
+ export { classifyLayers, getLayerColor, DEFAULT_LAYER_RULES } from './LayerClassifier.js';
2
+ export { mapDomains } from './DomainMapper.js';
3
+ export { generateTour } from './TourGenerator.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/topology/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAkB,MAAM,sBAAsB,CAAA;AACzG,OAAO,EAAE,UAAU,EAA4D,MAAM,mBAAmB,CAAA;AACxG,OAAO,EAAE,YAAY,EAAkC,MAAM,oBAAoB,CAAA"}
package/docs/README.md CHANGED
@@ -63,6 +63,9 @@
63
63
 
64
64
  | 文档 | 说明 |
65
65
  | --- | --- |
66
+ | [architecture/README.md](architecture/README.md) | **架构总览** — Mermaid 图解系统架构、核心引擎、数据流 |
67
+ | [reference/cli.md](reference/cli.md) | **CLI 参考** — 完整命令列表和用法示例 |
68
+ | [migration/v0.38-to-v0.44.md](migration/v0.38-to-v0.44.md) | **迁移指南** — v0.38 到 v0.44 的破坏性变更和升级步骤 |
66
69
  | [00-OVERVIEW.md](00-OVERVIEW.md) | 系统概览 |
67
70
  | [01-ARCHITECTURE.md](01-ARCHITECTURE.md) | 架构设计 |
68
71
  | [02-DATA-MODEL.md](02-DATA-MODEL.md) | 数据模型 |
@@ -0,0 +1,248 @@
1
+ # SCALE Engine Architecture
2
+
3
+ ## System Overview
4
+
5
+ SCALE Engine is an AI Engineering Operating System that provides governance, workflow automation, and continuous evolution for AI-assisted development.
6
+
7
+ ```mermaid
8
+ graph TB
9
+ subgraph "Entry Points"
10
+ CLI[CLI]
11
+ MCP[MCP Server]
12
+ HTTP[HTTP API]
13
+ end
14
+
15
+ subgraph "Core Engines"
16
+ Shield[Shield<br/>Security Hooks]
17
+ Orch[Orchestrator<br/>Declarative Workflow]
18
+ Cortex[Cortex<br/>Continuous Evolution]
19
+ end
20
+
21
+ subgraph "Intelligence Layer"
22
+ CodeGraph[CodeGraph<br/>AST Analysis]
23
+ Memory[Memory<br/>3-Layer Architecture]
24
+ Skills[Skills<br/>Capability Routing]
25
+ end
26
+
27
+ subgraph "Workflow Pipeline"
28
+ Define[Define]
29
+ Plan[Plan]
30
+ Build[Build]
31
+ Verify[Verify]
32
+ Review[Review]
33
+ Ship[Ship]
34
+ end
35
+
36
+ subgraph "Storage"
37
+ SQLite[(SQLite)]
38
+ JSON[JSON Files]
39
+ Git[Git]
40
+ end
41
+
42
+ CLI --> Shield
43
+ CLI --> Orch
44
+ CLI --> Cortex
45
+ MCP --> CodeGraph
46
+ HTTP --> Memory
47
+
48
+ Shield --> Skills
49
+ Orch --> Define
50
+ Cortex --> Memory
51
+
52
+ Define --> Plan --> Build --> Verify --> Review --> Ship
53
+
54
+ CodeGraph --> SQLite
55
+ Memory --> SQLite
56
+ Skills --> JSON
57
+ Orch --> Git
58
+ ```
59
+
60
+ ## Core Engines
61
+
62
+ ### Shield
63
+
64
+ Hook-based security engine that intercepts dangerous commands.
65
+
66
+ ```mermaid
67
+ graph LR
68
+ YAML[YAML Policies] --> Compiler[Compiler]
69
+ Compiler --> Hooks[Shell Hooks]
70
+ Hooks --> Intercept[Intercept]
71
+ Intercept --> Block[Block]
72
+ Intercept --> Allow[Allow]
73
+ Intercept --> Warn[Warn]
74
+ ```
75
+
76
+ ### Orchestrator
77
+
78
+ Declarative orchestration daemon with git worktree isolation.
79
+
80
+ ```mermaid
81
+ graph TB
82
+ Config[Config] --> Engine[Engine]
83
+ Engine --> Tracker[Tracker]
84
+ Engine --> Worktree[Worktree]
85
+ Engine --> Loop[Coordination Loop]
86
+ Loop --> Task[Task]
87
+ Loop --> Evidence[Evidence]
88
+ Loop --> Gate[Gate]
89
+ ```
90
+
91
+ ### Cortex
92
+
93
+ Evidence-driven continuous evolution with instinct extraction.
94
+
95
+ ```mermaid
96
+ graph LR
97
+ Obs[Observations] --> Extract[Extract]
98
+ Extract --> Instincts[Instincts]
99
+ Instincts --> Inject[Inject]
100
+ Inject --> Session[Session]
101
+ Session --> Metrics[Metrics]
102
+ ```
103
+
104
+ ## Intelligence Layer
105
+
106
+ ### CodeGraph
107
+
108
+ AST-based code intelligence using tree-sitter.
109
+
110
+ ```mermaid
111
+ graph TB
112
+ Source[Source Code] --> Parser[Tree-sitter]
113
+ Parser --> AST[AST]
114
+ AST --> Graph[Knowledge Graph]
115
+ Graph --> Query[Query Engine]
116
+ Query --> Impact[Impact Analysis]
117
+ Query --> Context[Context Building]
118
+ ```
119
+
120
+ ### Memory (3-Layer Architecture)
121
+
122
+ ```mermaid
123
+ graph TB
124
+ L1[L1: Trace<br/>Raw observations] --> Refine1[Refine]
125
+ Refine1 --> L2[L2: Policy<br/>Extracted patterns]
126
+ L2 --> Refine2[Refine]
127
+ Refine2 --> L3[L3: World Model<br/>Consolidated knowledge]
128
+ L3 --> Crystal[Crystallized<br/>Global wisdom]
129
+ ```
130
+
131
+ ### Skills
132
+
133
+ Capability routing with supply chain safety.
134
+
135
+ ```mermaid
136
+ graph LR
137
+ Task[Task] --> Recommend[Recommend]
138
+ Recommend --> Skills[Skills]
139
+ Skills --> Safety[Safety Check]
140
+ Safety --> Install[Install]
141
+ Install --> Evidence[Evidence]
142
+ ```
143
+
144
+ ## Workflow Pipeline
145
+
146
+ ```mermaid
147
+ stateDiagram-v2
148
+ [*] --> Define
149
+ Define --> Plan
150
+ Plan --> Build
151
+ Build --> Verify
152
+ Verify --> Review
153
+ Review --> Ship
154
+ Ship --> [*]
155
+
156
+ Define --> Define: Scope unclear
157
+ Plan --> Plan: Missing info
158
+ Build --> Build: Tests fail
159
+ Verify --> Verify: Gates fail
160
+ Review --> Review: Issues found
161
+ Ship --> Ship: Checks fail
162
+ ```
163
+
164
+ ## Data Flow
165
+
166
+ ```mermaid
167
+ sequenceDiagram
168
+ participant User
169
+ participant CLI
170
+ participant Engine
171
+ participant Memory
172
+ participant CodeGraph
173
+
174
+ User->>CLI: scale define "task"
175
+ CLI->>Engine: Create artifact
176
+ Engine->>Memory: Query similar
177
+ Memory-->>Engine: Context
178
+
179
+ User->>CLI: scale build
180
+ CLI->>Engine: Execute TDD
181
+ Engine->>CodeGraph: Query symbols
182
+ CodeGraph-->>Engine: Impact analysis
183
+
184
+ User->>CLI: scale verify
185
+ CLI->>Engine: Run gates
186
+ Engine->>Memory: Record evidence
187
+ Memory-->>Engine: Confirmation
188
+ ```
189
+
190
+ ## Storage Architecture
191
+
192
+ ```mermaid
193
+ graph TB
194
+ subgraph ".scale/"
195
+ SQLite[(brain.sqlite)]
196
+ Instincts[instincts/]
197
+ Evidence[evidence/]
198
+ Specs[specs/]
199
+ Memory[memory/]
200
+ end
201
+
202
+ subgraph "Project"
203
+ SRC[src/]
204
+ TESTS[tests/]
205
+ DOCS[docs/]
206
+ end
207
+
208
+ SQLite --> Memory
209
+ Instincts --> Cortex
210
+ Evidence --> Runtime
211
+ Specs --> Inject
212
+ ```
213
+
214
+ ## Integration Points
215
+
216
+ ### MCP Server
217
+
218
+ Model Context Protocol server over stdio for AI agent integration.
219
+
220
+ ```mermaid
221
+ graph LR
222
+ Agent[AI Agent] -->|JSON-RPC| MCP[MCP Server]
223
+ MCP --> Tools[Tools]
224
+ Tools --> Scale[SCALE Engine]
225
+ Scale --> Results[Results]
226
+ Results --> Agent
227
+ ```
228
+
229
+ ### HTTP API
230
+
231
+ Hono-based HTTP server for dashboard and external integrations.
232
+
233
+ ```mermaid
234
+ graph LR
235
+ Client[Client] -->|HTTP| Hono[Hono Server]
236
+ Hono --> Routes[Routes]
237
+ Routes --> Engine[SCALE Engine]
238
+ Engine --> Response[Response]
239
+ Response --> Client
240
+ ```
241
+
242
+ ## Key Design Decisions
243
+
244
+ 1. **SQLite over PostgreSQL**: Embedded, zero-config, sufficient for project-scoped data
245
+ 2. **Functional composition**: Pure functions over classes for testability
246
+ 3. **Evidence-first**: All decisions backed by observable evidence
247
+ 4. **Progressive governance**: Gradual adoption of governance practices
248
+ 5. **Supply chain safety**: Every external dependency verified before use
@@ -0,0 +1,232 @@
1
+ # Migration Guide: v0.38 → v0.44
2
+
3
+ This guide covers breaking changes and migration steps from SCALE Engine v0.38 to v0.44.
4
+
5
+ ## Breaking Changes
6
+
7
+ ### 1. CLI Command Restructuring
8
+
9
+ The CLI has been reorganized into modular subcommands:
10
+
11
+ | Old Command | New Command |
12
+ |-------------|-------------|
13
+ | `scale session start` | `scale session start` (unchanged) |
14
+ | `scale gate pre-tool` | `scale gate pre-tool` (unchanged) |
15
+ | `scale shield compile` | `scale shield compile` (unchanged) |
16
+ | `scale orch start` | `scale orch start` (unchanged) |
17
+ | `scale cortex extract` | `scale cortex extract` (unchanged) |
18
+
19
+ Most commands remain backward-compatible. New phase-aligned commands added:
20
+
21
+ ```bash
22
+ scale define "task description" --level M
23
+ scale plan
24
+ scale build
25
+ scale verify
26
+ scale review
27
+ scale ship
28
+ ```
29
+
30
+ ### 2. Memory Provider Configuration
31
+
32
+ Memory providers now use a unified configuration file:
33
+
34
+ **Before:** Inline configuration in various places
35
+ **After:** `.scale/memory-providers.json`
36
+
37
+ ```json
38
+ {
39
+ "version": "1.0",
40
+ "routing": {
41
+ "mode": "external-first",
42
+ "defaultOrder": ["gbrain", "memos", "agentmemory", "scale-local"]
43
+ },
44
+ "providers": [...]
45
+ }
46
+ ```
47
+
48
+ Initialize with:
49
+ ```bash
50
+ scale memory provider init
51
+ ```
52
+
53
+ ### 3. Gate System Changes
54
+
55
+ Gates G16-G22 have been added:
56
+
57
+ | Gate | Name | Default | Blocking |
58
+ |------|------|---------|----------|
59
+ | G16 | Commit Discipline | yes | yes |
60
+ | G17 | Documentation Hygiene | yes | no (M) / yes (L) |
61
+ | G18 | Runtime Evidence | yes | yes |
62
+ | G19 | Code Review | profile | yes (L+) |
63
+ | G20 | Supply Chain | yes | yes |
64
+ | G21 | Context Budget | yes | no |
65
+ | G22 | Session Health | yes | no |
66
+
67
+ ### 4. Memory Architecture
68
+
69
+ MemoryBrain now uses a 3-layer architecture:
70
+
71
+ - **L1-trace**: Raw observations (default for new nodes)
72
+ - **L2-policy**: Extracted patterns from L1 traces
73
+ - **L3-world-model**: Consolidated knowledge from L2 policies
74
+ - **crystallized**: High-confidence global wisdom
75
+
76
+ Run `scale memory dream` to see layer statistics.
77
+
78
+ ### 5. Code Intelligence
79
+
80
+ CodeGraph and code-review-graph integration:
81
+
82
+ ```bash
83
+ # Initialize codegraph
84
+ scale codegraph init
85
+
86
+ # Query symbols
87
+ scale codegraph query "UserService"
88
+
89
+ # Analyze impact
90
+ scale codegraph impact src/auth/login.ts
91
+ ```
92
+
93
+ ## New Features
94
+
95
+ ### 1. MCP Server
96
+
97
+ SCALE now includes an MCP server for AI agent integration:
98
+
99
+ ```bash
100
+ scale mcp # Start MCP server over stdio
101
+ ```
102
+
103
+ ### 2. HTTP API
104
+
105
+ Hono-based HTTP server for dashboard:
106
+
107
+ ```bash
108
+ scale serve # Start HTTP server
109
+ ```
110
+
111
+ ### 3. Skills System
112
+
113
+ Skills are now managed through a repository:
114
+
115
+ ```bash
116
+ scale skill scan # Scan for available skills
117
+ scale skill recommend # Get recommendations
118
+ scale skill repo # Browse repository
119
+ ```
120
+
121
+ ### 4. Memory Providers
122
+
123
+ External memory providers supported:
124
+
125
+ - **gbrain**: Graph memory (CLI mode)
126
+ - **MemOS**: 3-layer memory architecture
127
+ - **agentmemory**: Semantic search (self-hosted)
128
+ - **scale-local**: Local SQLite (zero deps)
129
+
130
+ ### 5. Code Review Graph
131
+
132
+ Integration with code-review-graph for blast radius analysis:
133
+
134
+ ```bash
135
+ pip install code-review-graph
136
+ code-review-graph build
137
+
138
+ # Use in SCALE
139
+ scale codegraph status
140
+ ```
141
+
142
+ ## Configuration Changes
143
+
144
+ ### 1. Settings Location
145
+
146
+ ```
147
+ .scale/
148
+ ├── memory-providers.json # Memory provider config
149
+ ├── code-intelligence.json # Code intelligence config
150
+ ├── policy.yaml # Shield policy
151
+ ├── instincts/ # Cortex instincts
152
+ ├── memory/ # Memory brain
153
+ └── specs/ # Scoped specs
154
+ ```
155
+
156
+ ### 2. Hook System
157
+
158
+ Hooks are now in `.claude/hooks/`:
159
+
160
+ ```
161
+ .claude/hooks/
162
+ ├── session-start-reminder.sh
163
+ ├── gate-execute-phase.sh
164
+ ├── crg-incremental-update.sh
165
+ └── shield-pre-tool.js
166
+ ```
167
+
168
+ ### 3. Environment Variables
169
+
170
+ New environment variables:
171
+
172
+ | Variable | Description |
173
+ |----------|-------------|
174
+ | `GBRAIN_API_KEY` | GBrain API key |
175
+ | `MEMOS_API_KEY` | MemOS API key |
176
+ | `MEMOS_BASE_URL` | MemOS endpoint |
177
+ | `AGENTMEMORY_ENDPOINT` | AgentMemory endpoint |
178
+
179
+ ## Upgrade Steps
180
+
181
+ ### 1. Backup Current State
182
+
183
+ ```bash
184
+ cp -r .scale .scale.backup
185
+ cp .claude/settings.json .claude/settings.json.backup
186
+ ```
187
+
188
+ ### 2. Update Package
189
+
190
+ ```bash
191
+ npm update @hongmaple0820/scale-engine
192
+ ```
193
+
194
+ ### 3. Run Doctor
195
+
196
+ ```bash
197
+ scale doctor
198
+ ```
199
+
200
+ ### 4. Reinitialize if Needed
201
+
202
+ ```bash
203
+ scale init
204
+ scale setup --interactive
205
+ ```
206
+
207
+ ### 5. Verify Installation
208
+
209
+ ```bash
210
+ scale preflight
211
+ scale shield status
212
+ scale cortex verify
213
+ ```
214
+
215
+ ## Rollback
216
+
217
+ If issues occur:
218
+
219
+ ```bash
220
+ # Restore backup
221
+ cp -r .scale.backup .scale
222
+ cp .claude/settings.json.backup .claude/settings.json
223
+
224
+ # Reinstall previous version
225
+ npm install @hongmaple0820/scale-engine@0.38.0
226
+ ```
227
+
228
+ ## Support
229
+
230
+ - GitHub Issues: https://github.com/your-org/scale-engine/issues
231
+ - Documentation: docs/README.md
232
+ - Migration help: `scale doctor --migration`