pmp-gywd 3.3.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.
- package/LICENSE +27 -0
- package/README.md +567 -0
- package/bin/install.js +348 -0
- package/commands/gywd/add-phase.md +207 -0
- package/commands/gywd/anticipate.md +271 -0
- package/commands/gywd/bootstrap.md +336 -0
- package/commands/gywd/challenge.md +344 -0
- package/commands/gywd/check-drift.md +144 -0
- package/commands/gywd/complete-milestone.md +106 -0
- package/commands/gywd/consider-issues.md +202 -0
- package/commands/gywd/context.md +93 -0
- package/commands/gywd/create-roadmap.md +115 -0
- package/commands/gywd/deps.md +169 -0
- package/commands/gywd/digest.md +138 -0
- package/commands/gywd/discuss-milestone.md +47 -0
- package/commands/gywd/discuss-phase.md +60 -0
- package/commands/gywd/execute-plan.md +161 -0
- package/commands/gywd/extract-decisions.md +325 -0
- package/commands/gywd/health.md +150 -0
- package/commands/gywd/help.md +556 -0
- package/commands/gywd/history.md +278 -0
- package/commands/gywd/impact.md +317 -0
- package/commands/gywd/init.md +95 -0
- package/commands/gywd/insert-phase.md +227 -0
- package/commands/gywd/list-phase-assumptions.md +50 -0
- package/commands/gywd/map-codebase.md +84 -0
- package/commands/gywd/memory.md +159 -0
- package/commands/gywd/new-milestone.md +59 -0
- package/commands/gywd/new-project.md +315 -0
- package/commands/gywd/pause-work.md +123 -0
- package/commands/gywd/plan-fix.md +205 -0
- package/commands/gywd/plan-phase.md +93 -0
- package/commands/gywd/preview-plan.md +139 -0
- package/commands/gywd/profile.md +363 -0
- package/commands/gywd/progress.md +317 -0
- package/commands/gywd/remove-phase.md +338 -0
- package/commands/gywd/research-phase.md +91 -0
- package/commands/gywd/resume-work.md +40 -0
- package/commands/gywd/rollback.md +179 -0
- package/commands/gywd/status.md +42 -0
- package/commands/gywd/sync-github.md +234 -0
- package/commands/gywd/verify-work.md +71 -0
- package/commands/gywd/why.md +251 -0
- package/docs/COMMANDS.md +722 -0
- package/docs/CONTRIBUTING.md +342 -0
- package/docs/EXAMPLES.md +535 -0
- package/docs/GETTING-STARTED.md +262 -0
- package/docs/README.md +55 -0
- package/docs/RELEASING.md +159 -0
- package/get-your-work-done/core/agent-patterns.md +331 -0
- package/get-your-work-done/core/architecture.md +334 -0
- package/get-your-work-done/core/context-model-schema.json +154 -0
- package/get-your-work-done/core/decisions-schema.json +193 -0
- package/get-your-work-done/core/learning-state-schema.json +133 -0
- package/get-your-work-done/core/profile-schema.json +257 -0
- package/get-your-work-done/references/adaptive-decomposition.md +175 -0
- package/get-your-work-done/references/checkpoints.md +287 -0
- package/get-your-work-done/references/confidence-scoring.md +169 -0
- package/get-your-work-done/references/continuation-format.md +255 -0
- package/get-your-work-done/references/git-integration.md +254 -0
- package/get-your-work-done/references/plan-format.md +428 -0
- package/get-your-work-done/references/principles.md +157 -0
- package/get-your-work-done/references/questioning.md +162 -0
- package/get-your-work-done/references/research-pitfalls.md +215 -0
- package/get-your-work-done/references/scope-estimation.md +172 -0
- package/get-your-work-done/references/tdd.md +263 -0
- package/get-your-work-done/templates/codebase/architecture.md +255 -0
- package/get-your-work-done/templates/codebase/concerns.md +310 -0
- package/get-your-work-done/templates/codebase/conventions.md +307 -0
- package/get-your-work-done/templates/codebase/integrations.md +280 -0
- package/get-your-work-done/templates/codebase/stack.md +186 -0
- package/get-your-work-done/templates/codebase/structure.md +285 -0
- package/get-your-work-done/templates/codebase/testing.md +480 -0
- package/get-your-work-done/templates/config.json +18 -0
- package/get-your-work-done/templates/context.md +161 -0
- package/get-your-work-done/templates/continue-here.md +78 -0
- package/get-your-work-done/templates/discovery.md +146 -0
- package/get-your-work-done/templates/issues.md +32 -0
- package/get-your-work-done/templates/milestone-archive.md +123 -0
- package/get-your-work-done/templates/milestone-context.md +93 -0
- package/get-your-work-done/templates/milestone.md +115 -0
- package/get-your-work-done/templates/phase-prompt.md +303 -0
- package/get-your-work-done/templates/project.md +184 -0
- package/get-your-work-done/templates/research.md +529 -0
- package/get-your-work-done/templates/roadmap.md +196 -0
- package/get-your-work-done/templates/state.md +210 -0
- package/get-your-work-done/templates/summary.md +273 -0
- package/get-your-work-done/templates/uat-issues.md +143 -0
- package/get-your-work-done/workflows/complete-milestone.md +643 -0
- package/get-your-work-done/workflows/create-milestone.md +416 -0
- package/get-your-work-done/workflows/create-roadmap.md +481 -0
- package/get-your-work-done/workflows/discovery-phase.md +293 -0
- package/get-your-work-done/workflows/discuss-milestone.md +236 -0
- package/get-your-work-done/workflows/discuss-phase.md +247 -0
- package/get-your-work-done/workflows/execute-phase.md +1625 -0
- package/get-your-work-done/workflows/list-phase-assumptions.md +178 -0
- package/get-your-work-done/workflows/map-codebase.md +434 -0
- package/get-your-work-done/workflows/plan-phase.md +488 -0
- package/get-your-work-done/workflows/research-phase.md +436 -0
- package/get-your-work-done/workflows/resume-project.md +287 -0
- package/get-your-work-done/workflows/transition.md +580 -0
- package/get-your-work-done/workflows/verify-work.md +202 -0
- package/lib/automation/dependency-analyzer.js +635 -0
- package/lib/automation/doc-generator.js +643 -0
- package/lib/automation/index.js +42 -0
- package/lib/automation/test-generator.js +628 -0
- package/lib/context/context-analyzer.js +554 -0
- package/lib/context/context-cache.js +426 -0
- package/lib/context/context-predictor.js +622 -0
- package/lib/context/index.js +44 -0
- package/lib/memory/confidence-calibrator.js +484 -0
- package/lib/memory/feedback-collector.js +551 -0
- package/lib/memory/global-memory.js +465 -0
- package/lib/memory/index.js +75 -0
- package/lib/memory/pattern-aggregator.js +487 -0
- package/lib/memory/team-sync.js +501 -0
- package/lib/profile/index.js +24 -0
- package/lib/profile/pattern-learner.js +303 -0
- package/lib/profile/profile-manager.js +445 -0
- package/lib/questioning/index.js +49 -0
- package/lib/questioning/question-engine.js +311 -0
- package/lib/questioning/question-templates.js +315 -0
- package/lib/validators/command-validator.js +188 -0
- package/lib/validators/index.js +29 -0
- package/lib/validators/schema-validator.js +183 -0
- package/package.json +61 -0
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Storage locations for global memory
|
|
9
|
+
*/
|
|
10
|
+
const GLOBAL_DIR = path.join(os.homedir(), '.gywd', 'global');
|
|
11
|
+
const PATTERNS_FILE = path.join(GLOBAL_DIR, 'patterns.json');
|
|
12
|
+
const EXPERTISE_FILE = path.join(GLOBAL_DIR, 'expertise.json');
|
|
13
|
+
const PREFERENCES_FILE = path.join(GLOBAL_DIR, 'preferences.json');
|
|
14
|
+
const PROJECTS_FILE = path.join(GLOBAL_DIR, 'projects.json');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* GlobalMemory - Cross-project pattern persistence
|
|
18
|
+
*
|
|
19
|
+
* Stores learned patterns, expertise, and preferences in a user-wide
|
|
20
|
+
* location (~/.gywd/global/) that persists across all projects.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const memory = new GlobalMemory();
|
|
24
|
+
* memory.init();
|
|
25
|
+
* memory.recordPattern({ type: 'naming', pattern: 'camelCase', confidence: 0.9 });
|
|
26
|
+
* memory.addExpertise('backend', 0.8);
|
|
27
|
+
*/
|
|
28
|
+
class GlobalMemory {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.patterns = [];
|
|
31
|
+
this.expertise = {};
|
|
32
|
+
this.preferences = {};
|
|
33
|
+
this.projects = [];
|
|
34
|
+
this.initialized = false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Initialize global memory, creating directories and loading existing data
|
|
39
|
+
* @returns {GlobalMemory} this instance for chaining
|
|
40
|
+
*/
|
|
41
|
+
init() {
|
|
42
|
+
this._ensureDirectories();
|
|
43
|
+
this._loadAll();
|
|
44
|
+
this.initialized = true;
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Ensure global directories exist
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
_ensureDirectories() {
|
|
53
|
+
if (!fs.existsSync(GLOBAL_DIR)) {
|
|
54
|
+
fs.mkdirSync(GLOBAL_DIR, { recursive: true });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Load all global data from files
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
_loadAll() {
|
|
63
|
+
this.patterns = this._loadFile(PATTERNS_FILE, []);
|
|
64
|
+
this.expertise = this._loadFile(EXPERTISE_FILE, {});
|
|
65
|
+
this.preferences = this._loadFile(PREFERENCES_FILE, {});
|
|
66
|
+
this.projects = this._loadFile(PROJECTS_FILE, []);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Load a JSON file safely
|
|
71
|
+
* @private
|
|
72
|
+
* @param {string} filePath - Path to file
|
|
73
|
+
* @param {*} defaultValue - Default value if file doesn't exist
|
|
74
|
+
* @returns {*} Parsed JSON or default value
|
|
75
|
+
*/
|
|
76
|
+
_loadFile(filePath, defaultValue) {
|
|
77
|
+
try {
|
|
78
|
+
if (fs.existsSync(filePath)) {
|
|
79
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
80
|
+
return JSON.parse(content);
|
|
81
|
+
}
|
|
82
|
+
} catch (err) {
|
|
83
|
+
// Return default on error
|
|
84
|
+
}
|
|
85
|
+
return defaultValue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Save a JSON file
|
|
90
|
+
* @private
|
|
91
|
+
* @param {string} filePath - Path to file
|
|
92
|
+
* @param {*} data - Data to save
|
|
93
|
+
*/
|
|
94
|
+
_saveFile(filePath, data) {
|
|
95
|
+
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf8');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Save all global data to files
|
|
100
|
+
*/
|
|
101
|
+
save() {
|
|
102
|
+
this._ensureDirectories();
|
|
103
|
+
this._saveFile(PATTERNS_FILE, this.patterns);
|
|
104
|
+
this._saveFile(EXPERTISE_FILE, this.expertise);
|
|
105
|
+
this._saveFile(PREFERENCES_FILE, this.preferences);
|
|
106
|
+
this._saveFile(PROJECTS_FILE, this.projects);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ==================== PATTERNS ====================
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Record a learned pattern to global memory
|
|
113
|
+
* @param {object} pattern - Pattern object
|
|
114
|
+
* @param {string} pattern.type - Pattern type (naming, structure, async, etc.)
|
|
115
|
+
* @param {string} pattern.pattern - The actual pattern value
|
|
116
|
+
* @param {number} [pattern.confidence=0.5] - Confidence level 0-1
|
|
117
|
+
* @param {string} [pattern.source] - Source project or context
|
|
118
|
+
*/
|
|
119
|
+
recordPattern(pattern) {
|
|
120
|
+
if (!this.initialized) this.init();
|
|
121
|
+
|
|
122
|
+
const existing = this.patterns.find(
|
|
123
|
+
p => p.type === pattern.type && p.pattern === pattern.pattern,
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
if (existing) {
|
|
127
|
+
// Reinforce existing pattern
|
|
128
|
+
existing.occurrences = (existing.occurrences || 1) + 1;
|
|
129
|
+
existing.confidence = Math.min(1, (existing.confidence || 0.5) + 0.1);
|
|
130
|
+
existing.lastSeen = new Date().toISOString();
|
|
131
|
+
if (pattern.source && !existing.sources.includes(pattern.source)) {
|
|
132
|
+
existing.sources.push(pattern.source);
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
// Add new pattern
|
|
136
|
+
this.patterns.push({
|
|
137
|
+
id: `gp-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
138
|
+
type: pattern.type,
|
|
139
|
+
pattern: pattern.pattern,
|
|
140
|
+
confidence: pattern.confidence || 0.5,
|
|
141
|
+
occurrences: 1,
|
|
142
|
+
sources: pattern.source ? [pattern.source] : [],
|
|
143
|
+
createdAt: new Date().toISOString(),
|
|
144
|
+
lastSeen: new Date().toISOString(),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
this.save();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Get patterns by type
|
|
153
|
+
* @param {string} type - Pattern type to filter by
|
|
154
|
+
* @returns {Array} Matching patterns sorted by confidence
|
|
155
|
+
*/
|
|
156
|
+
getPatternsByType(type) {
|
|
157
|
+
if (!this.initialized) this.init();
|
|
158
|
+
return this.patterns
|
|
159
|
+
.filter(p => p.type === type)
|
|
160
|
+
.sort((a, b) => b.confidence - a.confidence);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Get the most confident pattern of a type
|
|
165
|
+
* @param {string} type - Pattern type
|
|
166
|
+
* @returns {object|null} Most confident pattern or null
|
|
167
|
+
*/
|
|
168
|
+
getDominantPattern(type) {
|
|
169
|
+
const patterns = this.getPatternsByType(type);
|
|
170
|
+
return patterns.length > 0 ? patterns[0] : null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Get all patterns above a confidence threshold
|
|
175
|
+
* @param {number} [minConfidence=0.7] - Minimum confidence
|
|
176
|
+
* @returns {Array} High confidence patterns
|
|
177
|
+
*/
|
|
178
|
+
getConfidentPatterns(minConfidence = 0.7) {
|
|
179
|
+
if (!this.initialized) this.init();
|
|
180
|
+
return this.patterns
|
|
181
|
+
.filter(p => p.confidence >= minConfidence)
|
|
182
|
+
.sort((a, b) => b.confidence - a.confidence);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ==================== EXPERTISE ====================
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Add or update expertise area
|
|
189
|
+
* @param {string} domain - Expertise domain (backend, frontend, devops, etc.)
|
|
190
|
+
* @param {number} level - Expertise level 0-1
|
|
191
|
+
*/
|
|
192
|
+
addExpertise(domain, level) {
|
|
193
|
+
if (!this.initialized) this.init();
|
|
194
|
+
|
|
195
|
+
const current = this.expertise[domain];
|
|
196
|
+
if (current) {
|
|
197
|
+
// Average with existing, weighted toward new observation
|
|
198
|
+
this.expertise[domain] = {
|
|
199
|
+
level: current.level * 0.7 + level * 0.3,
|
|
200
|
+
observations: (current.observations || 1) + 1,
|
|
201
|
+
lastUpdated: new Date().toISOString(),
|
|
202
|
+
};
|
|
203
|
+
} else {
|
|
204
|
+
this.expertise[domain] = {
|
|
205
|
+
level,
|
|
206
|
+
observations: 1,
|
|
207
|
+
createdAt: new Date().toISOString(),
|
|
208
|
+
lastUpdated: new Date().toISOString(),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
this.save();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Get expertise level for a domain
|
|
217
|
+
* @param {string} domain - Domain to check
|
|
218
|
+
* @returns {number} Expertise level 0-1, or 0 if unknown
|
|
219
|
+
*/
|
|
220
|
+
getExpertise(domain) {
|
|
221
|
+
if (!this.initialized) this.init();
|
|
222
|
+
return this.expertise[domain]?.level || 0;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Get all expertise areas
|
|
227
|
+
* @returns {object} All expertise with levels
|
|
228
|
+
*/
|
|
229
|
+
getAllExpertise() {
|
|
230
|
+
if (!this.initialized) this.init();
|
|
231
|
+
return { ...this.expertise };
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Get top expertise areas
|
|
236
|
+
* @param {number} [limit=5] - Number of areas to return
|
|
237
|
+
* @returns {Array} Top expertise areas sorted by level
|
|
238
|
+
*/
|
|
239
|
+
getTopExpertise(limit = 5) {
|
|
240
|
+
if (!this.initialized) this.init();
|
|
241
|
+
return Object.entries(this.expertise)
|
|
242
|
+
.map(([domain, data]) => ({ domain, ...data }))
|
|
243
|
+
.sort((a, b) => b.level - a.level)
|
|
244
|
+
.slice(0, limit);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// ==================== PREFERENCES ====================
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Set a preference
|
|
251
|
+
* @param {string} key - Preference key
|
|
252
|
+
* @param {*} value - Preference value
|
|
253
|
+
*/
|
|
254
|
+
setPreference(key, value) {
|
|
255
|
+
if (!this.initialized) this.init();
|
|
256
|
+
this.preferences[key] = {
|
|
257
|
+
value,
|
|
258
|
+
updatedAt: new Date().toISOString(),
|
|
259
|
+
};
|
|
260
|
+
this.save();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Get a preference
|
|
265
|
+
* @param {string} key - Preference key
|
|
266
|
+
* @param {*} [defaultValue] - Default if not set
|
|
267
|
+
* @returns {*} Preference value or default
|
|
268
|
+
*/
|
|
269
|
+
getPreference(key, defaultValue = null) {
|
|
270
|
+
if (!this.initialized) this.init();
|
|
271
|
+
return this.preferences[key]?.value ?? defaultValue;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Get all preferences
|
|
276
|
+
* @returns {object} All preferences
|
|
277
|
+
*/
|
|
278
|
+
getAllPreferences() {
|
|
279
|
+
if (!this.initialized) this.init();
|
|
280
|
+
const result = {};
|
|
281
|
+
for (const [key, data] of Object.entries(this.preferences)) {
|
|
282
|
+
result[key] = data.value;
|
|
283
|
+
}
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// ==================== PROJECTS ====================
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Register a project with global memory
|
|
291
|
+
* @param {string} projectPath - Absolute path to project
|
|
292
|
+
* @param {object} [metadata] - Optional project metadata
|
|
293
|
+
*/
|
|
294
|
+
registerProject(projectPath, metadata = {}) {
|
|
295
|
+
if (!this.initialized) this.init();
|
|
296
|
+
|
|
297
|
+
const existing = this.projects.find(p => p.path === projectPath);
|
|
298
|
+
if (existing) {
|
|
299
|
+
existing.lastAccessed = new Date().toISOString();
|
|
300
|
+
existing.accessCount = (existing.accessCount || 1) + 1;
|
|
301
|
+
Object.assign(existing.metadata, metadata);
|
|
302
|
+
} else {
|
|
303
|
+
this.projects.push({
|
|
304
|
+
path: projectPath,
|
|
305
|
+
name: metadata.name || path.basename(projectPath),
|
|
306
|
+
metadata,
|
|
307
|
+
registeredAt: new Date().toISOString(),
|
|
308
|
+
lastAccessed: new Date().toISOString(),
|
|
309
|
+
accessCount: 1,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
this.save();
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Get all registered projects
|
|
318
|
+
* @returns {Array} List of registered projects
|
|
319
|
+
*/
|
|
320
|
+
getProjects() {
|
|
321
|
+
if (!this.initialized) this.init();
|
|
322
|
+
return [...this.projects];
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Get recently accessed projects
|
|
327
|
+
* @param {number} [limit=10] - Number of projects to return
|
|
328
|
+
* @returns {Array} Recent projects sorted by last access
|
|
329
|
+
*/
|
|
330
|
+
getRecentProjects(limit = 10) {
|
|
331
|
+
if (!this.initialized) this.init();
|
|
332
|
+
return [...this.projects]
|
|
333
|
+
.sort((a, b) => new Date(b.lastAccessed) - new Date(a.lastAccessed))
|
|
334
|
+
.slice(0, limit);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// ==================== SYNC ====================
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Import patterns from a local project profile
|
|
341
|
+
* @param {object} localProfile - Local profile object
|
|
342
|
+
* @param {string} projectPath - Project path for source tracking
|
|
343
|
+
*/
|
|
344
|
+
importFromProfile(localProfile, projectPath) {
|
|
345
|
+
if (!this.initialized) this.init();
|
|
346
|
+
|
|
347
|
+
const projectName = path.basename(projectPath);
|
|
348
|
+
|
|
349
|
+
// Import patterns
|
|
350
|
+
if (localProfile.patterns && Array.isArray(localProfile.patterns)) {
|
|
351
|
+
for (const pattern of localProfile.patterns) {
|
|
352
|
+
this.recordPattern({
|
|
353
|
+
type: pattern.type,
|
|
354
|
+
pattern: pattern.description || pattern.pattern,
|
|
355
|
+
confidence: 0.6, // Start with moderate confidence from import
|
|
356
|
+
source: projectName,
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Import expertise
|
|
362
|
+
if (localProfile.tooling?.primaryLanguages) {
|
|
363
|
+
for (const lang of localProfile.tooling.primaryLanguages) {
|
|
364
|
+
this.addExpertise(lang, 0.7);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (localProfile.expertise) {
|
|
369
|
+
for (const area of localProfile.expertise) {
|
|
370
|
+
if (typeof area === 'string') {
|
|
371
|
+
this.addExpertise(area, 0.6);
|
|
372
|
+
} else if (area.domain) {
|
|
373
|
+
this.addExpertise(area.domain, area.level || 0.6);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// Register project
|
|
379
|
+
this.registerProject(projectPath, {
|
|
380
|
+
name: localProfile.name || projectName,
|
|
381
|
+
languages: localProfile.tooling?.primaryLanguages || [],
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Export global patterns to enhance a local profile
|
|
387
|
+
* @param {object} localProfile - Local profile to enhance
|
|
388
|
+
* @returns {object} Enhanced profile
|
|
389
|
+
*/
|
|
390
|
+
exportToProfile(localProfile) {
|
|
391
|
+
if (!this.initialized) this.init();
|
|
392
|
+
|
|
393
|
+
const enhanced = { ...localProfile };
|
|
394
|
+
|
|
395
|
+
// Add high-confidence global patterns
|
|
396
|
+
const globalPatterns = this.getConfidentPatterns(0.7);
|
|
397
|
+
if (!enhanced.globalPatterns) {
|
|
398
|
+
enhanced.globalPatterns = [];
|
|
399
|
+
}
|
|
400
|
+
enhanced.globalPatterns = globalPatterns.map(p => ({
|
|
401
|
+
type: p.type,
|
|
402
|
+
pattern: p.pattern,
|
|
403
|
+
confidence: p.confidence,
|
|
404
|
+
fromProjects: p.sources.length,
|
|
405
|
+
}));
|
|
406
|
+
|
|
407
|
+
// Add global expertise hints
|
|
408
|
+
const topExpertise = this.getTopExpertise(10);
|
|
409
|
+
if (!enhanced.globalExpertise) {
|
|
410
|
+
enhanced.globalExpertise = [];
|
|
411
|
+
}
|
|
412
|
+
enhanced.globalExpertise = topExpertise;
|
|
413
|
+
|
|
414
|
+
// Add global preferences
|
|
415
|
+
enhanced.globalPreferences = this.getAllPreferences();
|
|
416
|
+
|
|
417
|
+
return enhanced;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// ==================== UTILITIES ====================
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Clear all global memory (use with caution)
|
|
424
|
+
*/
|
|
425
|
+
clear() {
|
|
426
|
+
this.patterns = [];
|
|
427
|
+
this.expertise = {};
|
|
428
|
+
this.preferences = {};
|
|
429
|
+
this.projects = [];
|
|
430
|
+
this.save();
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Get memory statistics
|
|
435
|
+
* @returns {object} Statistics about stored data
|
|
436
|
+
*/
|
|
437
|
+
getStats() {
|
|
438
|
+
if (!this.initialized) this.init();
|
|
439
|
+
return {
|
|
440
|
+
totalPatterns: this.patterns.length,
|
|
441
|
+
patternTypes: [...new Set(this.patterns.map(p => p.type))],
|
|
442
|
+
expertiseAreas: Object.keys(this.expertise).length,
|
|
443
|
+
preferencesCount: Object.keys(this.preferences).length,
|
|
444
|
+
projectsCount: this.projects.length,
|
|
445
|
+
highConfidencePatterns: this.patterns.filter(p => p.confidence >= 0.7).length,
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Get the global directory path
|
|
451
|
+
* @returns {string} Path to global memory directory
|
|
452
|
+
*/
|
|
453
|
+
static getGlobalDir() {
|
|
454
|
+
return GLOBAL_DIR;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
module.exports = {
|
|
459
|
+
GlobalMemory,
|
|
460
|
+
GLOBAL_DIR,
|
|
461
|
+
PATTERNS_FILE,
|
|
462
|
+
EXPERTISE_FILE,
|
|
463
|
+
PREFERENCES_FILE,
|
|
464
|
+
PROJECTS_FILE,
|
|
465
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Memory Module - Cross-project learning and persistence
|
|
5
|
+
*
|
|
6
|
+
* Provides global memory that persists across all projects,
|
|
7
|
+
* enabling pattern learning and expertise tracking.
|
|
8
|
+
*
|
|
9
|
+
* @module memory
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const {
|
|
13
|
+
GlobalMemory,
|
|
14
|
+
GLOBAL_DIR,
|
|
15
|
+
PATTERNS_FILE,
|
|
16
|
+
EXPERTISE_FILE,
|
|
17
|
+
PREFERENCES_FILE,
|
|
18
|
+
PROJECTS_FILE,
|
|
19
|
+
} = require('./global-memory');
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
PatternAggregator,
|
|
23
|
+
CONSENSUS_THRESHOLDS,
|
|
24
|
+
CONFIDENCE_FACTORS,
|
|
25
|
+
} = require('./pattern-aggregator');
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
FeedbackCollector,
|
|
29
|
+
FEEDBACK_TYPES,
|
|
30
|
+
SUGGESTION_CATEGORIES,
|
|
31
|
+
FEEDBACK_DIR,
|
|
32
|
+
FEEDBACK_FILE,
|
|
33
|
+
STATS_FILE,
|
|
34
|
+
} = require('./feedback-collector');
|
|
35
|
+
|
|
36
|
+
const {
|
|
37
|
+
ConfidenceCalibrator,
|
|
38
|
+
DEFAULT_PRIOR,
|
|
39
|
+
CALIBRATION_DIR,
|
|
40
|
+
CALIBRATION_FILE,
|
|
41
|
+
} = require('./confidence-calibrator');
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
TeamSync,
|
|
45
|
+
CONFLICT_STRATEGIES,
|
|
46
|
+
EXPORT_VERSION,
|
|
47
|
+
} = require('./team-sync');
|
|
48
|
+
|
|
49
|
+
module.exports = {
|
|
50
|
+
// Classes
|
|
51
|
+
GlobalMemory,
|
|
52
|
+
PatternAggregator,
|
|
53
|
+
FeedbackCollector,
|
|
54
|
+
ConfidenceCalibrator,
|
|
55
|
+
TeamSync,
|
|
56
|
+
|
|
57
|
+
// Constants
|
|
58
|
+
GLOBAL_DIR,
|
|
59
|
+
PATTERNS_FILE,
|
|
60
|
+
EXPERTISE_FILE,
|
|
61
|
+
PREFERENCES_FILE,
|
|
62
|
+
PROJECTS_FILE,
|
|
63
|
+
CONSENSUS_THRESHOLDS,
|
|
64
|
+
CONFIDENCE_FACTORS,
|
|
65
|
+
FEEDBACK_TYPES,
|
|
66
|
+
SUGGESTION_CATEGORIES,
|
|
67
|
+
FEEDBACK_DIR,
|
|
68
|
+
FEEDBACK_FILE,
|
|
69
|
+
STATS_FILE,
|
|
70
|
+
DEFAULT_PRIOR,
|
|
71
|
+
CALIBRATION_DIR,
|
|
72
|
+
CALIBRATION_FILE,
|
|
73
|
+
CONFLICT_STRATEGIES,
|
|
74
|
+
EXPORT_VERSION,
|
|
75
|
+
};
|