codehere 0.2.1 → 0.3.0-rc.1
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/README.md +88 -68
- package/dist/domain/entities/task.js +4 -4
- package/dist/error-handler.js +4 -9
- package/dist/index.js +253 -1219
- package/dist/infrastructure/config/product-context.js +7 -6
- package/dist/infrastructure/hooks/claude-sdk-hook.js +335 -63
- package/dist/infrastructure/observability/execution-tracer.js +11 -6
- package/dist/infrastructure/orchestration/agent-adapter.js +13 -0
- package/dist/infrastructure/orchestration/agent-installer.js +101 -0
- package/dist/infrastructure/orchestration/agents-config-seed.js +56 -0
- package/dist/infrastructure/orchestration/aider-adapter.js +319 -0
- package/dist/infrastructure/orchestration/artifacts-extractor.js +175 -0
- package/dist/infrastructure/orchestration/claude-code-adapter.js +352 -0
- package/dist/infrastructure/orchestration/codex-adapter.js +310 -0
- package/dist/infrastructure/orchestration/generic-cli-adapter.js +553 -0
- package/dist/infrastructure/orchestration/opencode-adapter.js +275 -0
- package/dist/infrastructure/orchestration/progress-aggregator.js +189 -0
- package/dist/infrastructure/orchestration/readiness.js +106 -0
- package/dist/infrastructure/orchestration/session-manager.js +272 -0
- package/dist/infrastructure/orchestration/session-persistence.js +109 -0
- package/dist/infrastructure/protocols/mcp-helpers.js +10 -30
- package/dist/infrastructure/protocols/mcp-server-impl.js +359 -21
- package/dist/infrastructure/protocols/ui-page.js +1827 -0
- package/dist/infrastructure/security/file-collection.js +115 -0
- package/dist/infrastructure/security/trust-scorer.js +301 -56
- package/dist/infrastructure/storage/task-repository.js +8 -7
- package/dist/monitoring.js +10 -49
- package/dist/presentation/cli/commands/help-command.js +96 -139
- package/dist/presentation/cli/commands/hook-command.js +17 -24
- package/dist/presentation/cli/commands/report-command.js +59 -72
- package/dist/presentation/cli/commands/setup-command.js +4 -4
- package/dist/presentation/cli/commands/status-command.js +334 -43
- package/dist/presentation/cli/commands/trust-command.js +115 -99
- package/dist/presentation/cli/error-display.js +17 -21
- package/dist/ui.js +17 -12
- package/package.json +35 -67
- package/dist/agents/base.js +0 -101
- package/dist/agents/orchestrator-model-driven.js +0 -141
- package/dist/agents/react-orchestrator-agent.js +0 -54
- package/dist/application/agents/execution-agent.js +0 -508
- package/dist/application/agents/multi-agent-orchestrator.js +0 -295
- package/dist/application/agents/planning-agent.js +0 -433
- package/dist/application/agents/validation-agent.js +0 -317
- package/dist/application/architectures/plan-and-act.js +0 -242
- package/dist/application/index.js +0 -12
- package/dist/application/services/agent-factory.js +0 -28
- package/dist/application/services/dependency-container.js +0 -596
- package/dist/application/services/git-context-service.js +0 -83
- package/dist/application/services/intelligent-router.js +0 -934
- package/dist/application/services/tool-executor-service.js +0 -94
- package/dist/application/use-cases/ask-question-use-case.js +0 -338
- package/dist/application/use-cases/edit-file-use-case.js +0 -830
- package/dist/application/use-cases/explain-file-use-case.js +0 -50
- package/dist/application/use-cases/index-codebase-use-case.js +0 -113
- package/dist/application/use-cases/planning-use-case.js +0 -276
- package/dist/application/use-cases/react-orchestration-use-case.js +0 -329
- package/dist/application/use-cases/reflexion-use-case.js +0 -30
- package/dist/application/workflows/deterministic-workflows.js +0 -189
- package/dist/ast-parser.js +0 -331
- package/dist/cache.js +0 -180
- package/dist/chat.js +0 -251
- package/dist/code-analysis.js +0 -327
- package/dist/context.js +0 -187
- package/dist/docs.js +0 -146
- package/dist/domain/entities/code-chunk.js +0 -6
- package/dist/domain/entities/decision.js +0 -9
- package/dist/domain/entities/edit.js +0 -6
- package/dist/domain/entities/knowledge-node.js +0 -9
- package/dist/domain/entities/knowledge-preservation.js +0 -10
- package/dist/domain/entities/memory.js +0 -6
- package/dist/domain/entities/pattern.js +0 -7
- package/dist/domain/entities/plan.js +0 -6
- package/dist/domain/entities/query.js +0 -6
- package/dist/domain/errors/embeddings-not-found-error.js +0 -13
- package/dist/domain/index.js +0 -19
- package/dist/domain/interfaces/ai-service.interface.js +0 -6
- package/dist/domain/interfaces/code-analyzer.interface.js +0 -6
- package/dist/domain/interfaces/decision-repository.interface.js +0 -9
- package/dist/domain/interfaces/embedding-repository.interface.js +0 -6
- package/dist/domain/interfaces/knowledge-graph-repository.interface.js +0 -9
- package/dist/domain/interfaces/knowledge-preservation-repository.interface.js +0 -8
- package/dist/domain/interfaces/memory-repository.interface.js +0 -6
- package/dist/domain/interfaces/pattern-repository.interface.js +0 -6
- package/dist/domain/interfaces/verification-service.interface.js +0 -6
- package/dist/domain/services/cross-team-pattern-sharing.js +0 -125
- package/dist/domain/services/decision-recorder.js +0 -223
- package/dist/domain/services/decision-retriever.js +0 -133
- package/dist/domain/services/environment-mode-manager.js +0 -22
- package/dist/domain/services/graded-memory-activation.js +0 -69
- package/dist/domain/services/knowledge-access.js +0 -132
- package/dist/domain/services/knowledge-extractor.js +0 -247
- package/dist/domain/services/knowledge-graph-builder.js +0 -268
- package/dist/domain/services/knowledge-graph-query.js +0 -187
- package/dist/domain/services/memory-retriever.js +0 -82
- package/dist/domain/services/memory-synthesizer.js +0 -91
- package/dist/domain/services/pattern-extractor.js +0 -442
- package/dist/domain/services/query-intent-classifier.js +0 -140
- package/dist/domain/services/react-loop.js +0 -186
- package/dist/domain/services/risk-tier-detector.js +0 -78
- package/dist/edit.js +0 -319
- package/dist/embed.js +0 -459
- package/dist/formatter.js +0 -168
- package/dist/git.js +0 -198
- package/dist/infrastructure/ai/cohere-ai-service.js +0 -607
- package/dist/infrastructure/ai/command-r-evaluation.js +0 -206
- package/dist/infrastructure/ai/model-config.js +0 -84
- package/dist/infrastructure/ai/provider-ai-service.js +0 -477
- package/dist/infrastructure/cache/embedding-cache.js +0 -175
- package/dist/infrastructure/cache/query-result-cache.js +0 -66
- package/dist/infrastructure/cache/response-cache.js +0 -48
- package/dist/infrastructure/cache/security-scan-cache.js +0 -47
- package/dist/infrastructure/chunking/ast-code-chunker.js +0 -19
- package/dist/infrastructure/chunking/code-aware-chunker.js +0 -397
- package/dist/infrastructure/context/context-compressor.js +0 -329
- package/dist/infrastructure/context/conversation-context.js +0 -128
- package/dist/infrastructure/context/session-manager.js +0 -94
- package/dist/infrastructure/cost/cost-tracker.js +0 -360
- package/dist/infrastructure/file-scanner/file-scanner.js +0 -106
- package/dist/infrastructure/governance/nist-ai-rmf.js +0 -292
- package/dist/infrastructure/governance/policy-as-code.js +0 -258
- package/dist/infrastructure/governance/prompt-to-code-lineage.js +0 -239
- package/dist/infrastructure/index.js +0 -7
- package/dist/infrastructure/observability/prompt-versioner.js +0 -145
- package/dist/infrastructure/protocols/a2a-metadata.js +0 -137
- package/dist/infrastructure/protocols/a2a-protocol.js +0 -314
- package/dist/infrastructure/protocols/mcp-oauth.js +0 -184
- package/dist/infrastructure/protocols/mcp-server.js +0 -333
- package/dist/infrastructure/protocols/streaming-handler.js +0 -103
- package/dist/infrastructure/providers/cohere-provider.js +0 -444
- package/dist/infrastructure/providers/fake-provider.js +0 -130
- package/dist/infrastructure/providers/local-llm-provider.js +0 -330
- package/dist/infrastructure/providers/model-config.types.js +0 -9
- package/dist/infrastructure/providers/model-provider.interface.js +0 -8
- package/dist/infrastructure/providers/openai-provider.js +0 -413
- package/dist/infrastructure/providers/openrouter-provider.js +0 -399
- package/dist/infrastructure/providers/operation-provider-resolver.js +0 -105
- package/dist/infrastructure/providers/provider-config-loader.js +0 -120
- package/dist/infrastructure/providers/provider-registry.js +0 -88
- package/dist/infrastructure/safety/pattern-detector.js +0 -133
- package/dist/infrastructure/security/ai-sast-scanner.js +0 -290
- package/dist/infrastructure/security/docker-sandbox.js +0 -178
- package/dist/infrastructure/security/enhanced-security-gate.js +0 -151
- package/dist/infrastructure/security/license-scanner.js +0 -167
- package/dist/infrastructure/security/provider-bias-detector.js +0 -164
- package/dist/infrastructure/security/sandbox-executor.js +0 -64
- package/dist/infrastructure/serialization/toon-serializer.js +0 -119
- package/dist/infrastructure/storage/memory-stream-service.js +0 -204
- package/dist/infrastructure/storage/plan-repository.js +0 -96
- package/dist/infrastructure/storage/sqlite-decision-repository.js +0 -232
- package/dist/infrastructure/storage/sqlite-embedding-repository.js +0 -311
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js +0 -417
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js +0 -230
- package/dist/infrastructure/storage/sqlite-memory-repository.js +0 -229
- package/dist/infrastructure/storage/sqlite-pattern-repository.js +0 -249
- package/dist/infrastructure/storage/task-helpers.js +0 -197
- package/dist/infrastructure/telemetry/telemetry-service.js +0 -167
- package/dist/infrastructure/ux/appropriate-friction.js +0 -213
- package/dist/infrastructure/ux/bi-directional-learning.js +0 -337
- package/dist/infrastructure/ux/capability-boundaries.js +0 -42
- package/dist/infrastructure/ux/comprehensive-formatter.js +0 -117
- package/dist/infrastructure/ux/contextual-feature-discovery.js +0 -10
- package/dist/infrastructure/ux/expectation-management.js +0 -327
- package/dist/infrastructure/ux/feature-discovery.js +0 -14
- package/dist/infrastructure/ux/feedback-prompt.js +0 -45
- package/dist/infrastructure/ux/hitl-validation.js +0 -297
- package/dist/infrastructure/ux/progress-indicator.js +0 -116
- package/dist/infrastructure/ux/progressive-disclosure.js +0 -236
- package/dist/infrastructure/ux/review-checkpoint.js +0 -72
- package/dist/infrastructure/ux/staged-feature-intro.js +0 -24
- package/dist/infrastructure/ux/stream-markdown.js +0 -151
- package/dist/infrastructure/ux/syntax-highlighter.js +0 -91
- package/dist/infrastructure/ux/team-standards.js +0 -196
- package/dist/infrastructure/ux/transparency.js +0 -71
- package/dist/infrastructure/validation/agent-feedback.js +0 -55
- package/dist/infrastructure/validation/agent-validation-helper.js +0 -137
- package/dist/infrastructure/validation/review-handler.js +0 -40
- package/dist/infrastructure/validation/summary-aggregator.js +0 -70
- package/dist/infrastructure/validation/summary-extractor.js +0 -45
- package/dist/infrastructure/validation/trace-summary.js +0 -52
- package/dist/infrastructure/verification/verification-service.js +0 -47
- package/dist/infrastructure/xai/attention-visualizer.js +0 -172
- package/dist/infrastructure/xai/cot-visualizer.js +0 -283
- package/dist/infrastructure/xai/decision-tree-log.js +0 -212
- package/dist/infrastructure/xai/interactive-xai.js +0 -260
- package/dist/infrastructure/xai/uncertainty-quantifier.js +0 -198
- package/dist/intelligent-retrieval.js +0 -272
- package/dist/intent/classifier.js +0 -2
- package/dist/intent/context.js +0 -2
- package/dist/iterative-refinement.js +0 -189
- package/dist/learning.js +0 -232
- package/dist/log.js +0 -31
- package/dist/migrate.js +0 -133
- package/dist/parallel-processor.js +0 -530
- package/dist/planner.js +0 -198
- package/dist/policy.js +0 -26
- package/dist/presentation/cli/commands/ask-command.js +0 -314
- package/dist/presentation/cli/commands/cost-command.js +0 -191
- package/dist/presentation/cli/commands/decision-command.js +0 -207
- package/dist/presentation/cli/commands/docs-command.js +0 -25
- package/dist/presentation/cli/commands/fix-command.js +0 -53
- package/dist/presentation/cli/commands/knowledge-command.js +0 -129
- package/dist/presentation/cli/commands/learning-dashboard-command.js +0 -183
- package/dist/presentation/cli/commands/models-command.js +0 -194
- package/dist/presentation/cli/commands/orchestrate-command.js +0 -207
- package/dist/presentation/cli/commands/plan-command.js +0 -246
- package/dist/presentation/cli/commands/product-command.js +0 -199
- package/dist/presentation/cli/commands/react-command.js +0 -181
- package/dist/presentation/cli/commands/review-command.js +0 -154
- package/dist/presentation/cli/commands/run-command.js +0 -188
- package/dist/presentation/cli/commands/smart-command.js +0 -395
- package/dist/presentation/cli/commands/suggest-command.js +0 -138
- package/dist/presentation/cli/commands/trace-command.js +0 -129
- package/dist/presentation/cli/commands/undo-command.js +0 -150
- package/dist/query-optimizer.js +0 -205
- package/dist/refactor.js +0 -116
- package/dist/review.js +0 -206
- package/dist/search.js +0 -163
- package/dist/session.js +0 -652
- package/dist/task-verification.js +0 -336
- package/dist/testgen.js +0 -166
- package/dist/token-optimizer.js +0 -277
- package/dist/tools/bash.js +0 -213
- package/dist/tools/edit.js +0 -235
- package/dist/tools/executor.js +0 -153
- package/dist/tools/git-tool.js +0 -292
- package/dist/tools/parser.js +0 -158
- package/dist/tools/registry.js +0 -302
- package/dist/tools/search.js +0 -100
- package/dist/types.js +0 -2
- package/dist/utils/check-api-status.js +0 -100
- package/dist/utils/diff-parser.js +0 -162
- package/dist/verification/backup.js +0 -259
- package/dist/verification/compiler.js +0 -264
- package/dist/verification/index.js +0 -273
- package/dist/verification/test-runner.js +0 -379
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Infrastructure: Bi-directional Learning System
|
|
3
|
-
*
|
|
4
|
-
* Continuous refinement of AI models based on explicit and implicit user feedback
|
|
5
|
-
* Research: Bi-directional learning from user corrections, adapt to team preferences
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Edit/deletion tracking
|
|
9
|
-
* - Personalization engine
|
|
10
|
-
* - Learning from user corrections
|
|
11
|
-
* - Preference adaptation
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Bi-directional Learning System
|
|
15
|
-
* Learns from user edits, deletions, and explicit feedback
|
|
16
|
-
*/
|
|
17
|
-
export class BiDirectionalLearning {
|
|
18
|
-
feedbackHistory = new Map(); // userId -> feedbacks
|
|
19
|
-
learningPatterns = new Map(); // userId -> patterns
|
|
20
|
-
userPreferences = new Map();
|
|
21
|
-
/**
|
|
22
|
-
* Record user feedback (edit, deletion, etc.)
|
|
23
|
-
*/
|
|
24
|
-
recordFeedback(userId, feedback) {
|
|
25
|
-
const feedbackId = `feedback-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
26
|
-
const fullFeedback = {
|
|
27
|
-
...feedback,
|
|
28
|
-
feedbackId,
|
|
29
|
-
timestamp: Date.now(),
|
|
30
|
-
};
|
|
31
|
-
// Store feedback
|
|
32
|
-
if (!this.feedbackHistory.has(userId)) {
|
|
33
|
-
this.feedbackHistory.set(userId, []);
|
|
34
|
-
}
|
|
35
|
-
this.feedbackHistory.get(userId).push(fullFeedback);
|
|
36
|
-
// Learn from feedback
|
|
37
|
-
this.learnFromFeedback(userId, fullFeedback);
|
|
38
|
-
// Update preferences
|
|
39
|
-
this.updatePreferences(userId, fullFeedback);
|
|
40
|
-
return feedbackId;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Record explicit feedback (thumbs up/down, comments)
|
|
44
|
-
*/
|
|
45
|
-
recordExplicitFeedback(userId, feedback) {
|
|
46
|
-
return this.recordFeedback(userId, {
|
|
47
|
-
type: 'explicit_feedback',
|
|
48
|
-
signal: feedback.signal,
|
|
49
|
-
filepath: feedback.codeExample || 'general',
|
|
50
|
-
context: {
|
|
51
|
-
...feedback.context,
|
|
52
|
-
},
|
|
53
|
-
metadata: {
|
|
54
|
-
explicitFeedback: feedback.message,
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Get user preferences
|
|
60
|
-
*/
|
|
61
|
-
getUserPreferences(userId) {
|
|
62
|
-
if (!this.userPreferences.has(userId)) {
|
|
63
|
-
this.userPreferences.set(userId, {
|
|
64
|
-
userId,
|
|
65
|
-
preferences: {},
|
|
66
|
-
learnedAt: Date.now(),
|
|
67
|
-
lastUpdated: Date.now(),
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return this.userPreferences.get(userId);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Get learned patterns for user
|
|
74
|
-
*/
|
|
75
|
-
getLearnedPatterns(userId) {
|
|
76
|
-
return this.learningPatterns.get(userId) || [];
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Apply learned preferences to code generation
|
|
80
|
-
* Task 6.2: Enhanced to apply learned patterns and preferences
|
|
81
|
-
*/
|
|
82
|
-
applyPreferences(userId, code) {
|
|
83
|
-
const preferences = this.getUserPreferences(userId);
|
|
84
|
-
const patterns = this.getLearnedPatterns(userId);
|
|
85
|
-
if (!preferences.preferences.codeStyle && patterns.length === 0) {
|
|
86
|
-
return code; // No preferences or patterns learned yet
|
|
87
|
-
}
|
|
88
|
-
// Apply basic style preferences (simplified - in production, use AST transformation)
|
|
89
|
-
let modifiedCode = code;
|
|
90
|
-
const style = preferences.preferences.codeStyle;
|
|
91
|
-
// Apply quote preference (basic example)
|
|
92
|
-
if (style?.quotes === 'single') {
|
|
93
|
-
modifiedCode = modifiedCode.replace(/"/g, "'");
|
|
94
|
-
}
|
|
95
|
-
else if (style?.quotes === 'double') {
|
|
96
|
-
modifiedCode = modifiedCode.replace(/'/g, '"');
|
|
97
|
-
}
|
|
98
|
-
// Task 6.2: Apply learned patterns (high confidence patterns only)
|
|
99
|
-
for (const pattern of patterns) {
|
|
100
|
-
if (pattern.confidence >= 0.7 && pattern.type === 'correction') {
|
|
101
|
-
// Apply high-confidence correction patterns
|
|
102
|
-
// In production, use AST transformation for accurate pattern application
|
|
103
|
-
// For now, this is a placeholder for pattern application logic
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
// In production, apply more sophisticated transformations based on preferences and patterns
|
|
107
|
-
return modifiedCode;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Task 6.2: Get learned patterns as prompt context for code generation
|
|
111
|
-
* Returns patterns formatted for inclusion in AI prompts
|
|
112
|
-
*/
|
|
113
|
-
getPatternsAsPromptContext(userId, maxPatterns = 5) {
|
|
114
|
-
const patterns = this.getLearnedPatterns(userId)
|
|
115
|
-
.filter(p => p.confidence >= 0.6) // Only high-confidence patterns
|
|
116
|
-
.sort((a, b) => b.confidence - a.confidence) // Sort by confidence
|
|
117
|
-
.slice(0, maxPatterns);
|
|
118
|
-
if (patterns.length === 0) {
|
|
119
|
-
return '';
|
|
120
|
-
}
|
|
121
|
-
const contextLines = [
|
|
122
|
-
'Learned patterns from previous edits:',
|
|
123
|
-
...patterns.map(p => {
|
|
124
|
-
const examples = p.examples.slice(0, 2).join('; ');
|
|
125
|
-
return `- ${p.pattern} (confidence: ${(p.confidence * 100).toFixed(0)}%, seen ${p.occurrences}x)${examples ? ` - Examples: ${examples}` : ''}`;
|
|
126
|
-
}),
|
|
127
|
-
];
|
|
128
|
-
return contextLines.join('\n');
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Task 6.2: Get user preferences as prompt context for code generation
|
|
132
|
-
*/
|
|
133
|
-
getPreferencesAsPromptContext(userId) {
|
|
134
|
-
const preferences = this.getUserPreferences(userId);
|
|
135
|
-
if (!preferences.preferences.codeStyle) {
|
|
136
|
-
return '';
|
|
137
|
-
}
|
|
138
|
-
const style = preferences.preferences.codeStyle;
|
|
139
|
-
const contextLines = [];
|
|
140
|
-
if (style.indentation) {
|
|
141
|
-
contextLines.push(`- Indentation: ${style.indentation === 'spaces' ? 'Use spaces' : 'Use tabs'}`);
|
|
142
|
-
}
|
|
143
|
-
if (style.quotes) {
|
|
144
|
-
contextLines.push(`- Quotes: Use ${style.quotes} quotes`);
|
|
145
|
-
}
|
|
146
|
-
if (style.naming) {
|
|
147
|
-
contextLines.push(`- Naming: Use ${style.naming} convention`);
|
|
148
|
-
}
|
|
149
|
-
if (style.spacing) {
|
|
150
|
-
contextLines.push(`- Spacing: ${style.spacing} spacing style`);
|
|
151
|
-
}
|
|
152
|
-
if (contextLines.length === 0) {
|
|
153
|
-
return '';
|
|
154
|
-
}
|
|
155
|
-
return 'User code style preferences:\n' + contextLines.join('\n');
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Get feedback history for user
|
|
159
|
-
*/
|
|
160
|
-
getFeedbackHistory(userId, filter) {
|
|
161
|
-
const feedbacks = this.feedbackHistory.get(userId) || [];
|
|
162
|
-
let filtered = [...feedbacks];
|
|
163
|
-
if (filter?.type) {
|
|
164
|
-
filtered = filtered.filter(f => f.type === filter.type);
|
|
165
|
-
}
|
|
166
|
-
if (filter?.signal) {
|
|
167
|
-
filtered = filtered.filter(f => f.signal === filter.signal);
|
|
168
|
-
}
|
|
169
|
-
if (filter?.startTime) {
|
|
170
|
-
filtered = filtered.filter(f => f.timestamp >= filter.startTime);
|
|
171
|
-
}
|
|
172
|
-
if (filter?.endTime) {
|
|
173
|
-
filtered = filtered.filter(f => f.timestamp <= filter.endTime);
|
|
174
|
-
}
|
|
175
|
-
return filtered.sort((a, b) => b.timestamp - a.timestamp);
|
|
176
|
-
}
|
|
177
|
-
// Private helpers
|
|
178
|
-
learnFromFeedback(userId, feedback) {
|
|
179
|
-
// Learn patterns from edits and deletions
|
|
180
|
-
if (feedback.type === 'edit' && feedback.originalCode && feedback.modifiedCode) {
|
|
181
|
-
const pattern = this.extractPattern(feedback.originalCode, feedback.modifiedCode);
|
|
182
|
-
if (pattern) {
|
|
183
|
-
this.addLearningPattern(userId, {
|
|
184
|
-
type: 'correction',
|
|
185
|
-
pattern: pattern,
|
|
186
|
-
confidence: 0.7,
|
|
187
|
-
occurrences: 1,
|
|
188
|
-
examples: [feedback.modifiedCode],
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
// Learn from deletions (what user removes = not wanted)
|
|
193
|
-
if (feedback.type === 'deletion' && feedback.originalCode) {
|
|
194
|
-
this.addLearningPattern(userId, {
|
|
195
|
-
type: 'pattern',
|
|
196
|
-
pattern: `Avoid: ${feedback.originalCode.substring(0, 50)}`,
|
|
197
|
-
confidence: 0.6,
|
|
198
|
-
occurrences: 1,
|
|
199
|
-
examples: [],
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
updatePreferences(userId, feedback) {
|
|
204
|
-
const preferences = this.getUserPreferences(userId);
|
|
205
|
-
// Infer preferences from edits
|
|
206
|
-
if (feedback.type === 'edit' && feedback.originalCode && feedback.modifiedCode) {
|
|
207
|
-
// Infer code style preferences (simplified)
|
|
208
|
-
if (feedback.modifiedCode.includes("'") && !feedback.originalCode.includes("'")) {
|
|
209
|
-
preferences.preferences.codeStyle = preferences.preferences.codeStyle || {};
|
|
210
|
-
preferences.preferences.codeStyle.quotes = 'single';
|
|
211
|
-
}
|
|
212
|
-
else if (feedback.modifiedCode.includes('"') && !feedback.originalCode.includes('"')) {
|
|
213
|
-
preferences.preferences.codeStyle = preferences.preferences.codeStyle || {};
|
|
214
|
-
preferences.preferences.codeStyle.quotes = 'double';
|
|
215
|
-
}
|
|
216
|
-
preferences.lastUpdated = Date.now();
|
|
217
|
-
}
|
|
218
|
-
// Update based on explicit feedback
|
|
219
|
-
if (feedback.type === 'explicit_feedback' && feedback.metadata?.explicitFeedback) {
|
|
220
|
-
// Parse explicit feedback for preferences
|
|
221
|
-
const message = feedback.metadata.explicitFeedback.toLowerCase();
|
|
222
|
-
if (message.includes('style') || message.includes('format')) {
|
|
223
|
-
// Extract style preferences from feedback
|
|
224
|
-
// (In production, use NLP to parse structured preferences)
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Task 6.2: Enhanced pattern extraction from edits
|
|
230
|
-
* Extracts meaningful patterns from code edits for learning
|
|
231
|
-
*/
|
|
232
|
-
extractPattern(original, modified) {
|
|
233
|
-
if (original.length === 0 || modified.length === 0) {
|
|
234
|
-
return null;
|
|
235
|
-
}
|
|
236
|
-
// Simple pattern extraction (in production, use AST diffing for better accuracy)
|
|
237
|
-
// For now, extract basic patterns:
|
|
238
|
-
// 1. Quote style changes
|
|
239
|
-
if (original.includes('"') && modified.includes("'") && !original.includes("'")) {
|
|
240
|
-
return 'Prefer single quotes over double quotes';
|
|
241
|
-
}
|
|
242
|
-
if (original.includes("'") && modified.includes('"') && !original.includes('"')) {
|
|
243
|
-
return 'Prefer double quotes over single quotes';
|
|
244
|
-
}
|
|
245
|
-
// 2. Indentation changes (basic detection)
|
|
246
|
-
const originalIndent = this.detectIndentation(original);
|
|
247
|
-
const modifiedIndent = this.detectIndentation(modified);
|
|
248
|
-
if (originalIndent !== modifiedIndent && modifiedIndent !== 'mixed') {
|
|
249
|
-
return `Prefer ${modifiedIndent} indentation`;
|
|
250
|
-
}
|
|
251
|
-
// 3. Naming convention changes (basic detection)
|
|
252
|
-
const namingChange = this.detectNamingChange(original, modified);
|
|
253
|
-
if (namingChange) {
|
|
254
|
-
return namingChange;
|
|
255
|
-
}
|
|
256
|
-
// Fallback: Generic pattern description
|
|
257
|
-
if (modified.length > 30) {
|
|
258
|
-
return `Pattern: ${modified.substring(0, 30)}...`;
|
|
259
|
-
}
|
|
260
|
-
return `Pattern: ${modified}`;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Task 6.2: Detect indentation style
|
|
264
|
-
*/
|
|
265
|
-
detectIndentation(code) {
|
|
266
|
-
const lines = code.split('\n').filter(line => line.trim().length > 0);
|
|
267
|
-
if (lines.length === 0)
|
|
268
|
-
return 'spaces';
|
|
269
|
-
let spacesCount = 0;
|
|
270
|
-
let tabsCount = 0;
|
|
271
|
-
for (const line of lines.slice(0, 10)) { // Check first 10 lines
|
|
272
|
-
const indent = line.match(/^(\s+)/)?.[1];
|
|
273
|
-
if (indent) {
|
|
274
|
-
if (indent.includes('\t')) {
|
|
275
|
-
tabsCount++;
|
|
276
|
-
}
|
|
277
|
-
else if (indent.includes(' ')) {
|
|
278
|
-
spacesCount++;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
if (tabsCount > spacesCount * 2)
|
|
283
|
-
return 'tabs';
|
|
284
|
-
if (spacesCount > tabsCount * 2)
|
|
285
|
-
return 'spaces';
|
|
286
|
-
return 'mixed';
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Task 6.2: Detect naming convention changes
|
|
290
|
-
*/
|
|
291
|
-
detectNamingChange(original, modified) {
|
|
292
|
-
// Simple detection: Look for camelCase vs snake_case vs PascalCase
|
|
293
|
-
const camelCaseRegex = /\b[a-z][a-zA-Z0-9]*\b/g;
|
|
294
|
-
const snakeCaseRegex = /\b[a-z][a-z0-9_]*\b/g;
|
|
295
|
-
const pascalCaseRegex = /\b[A-Z][a-zA-Z0-9]*\b/g;
|
|
296
|
-
const originalCamel = (original.match(camelCaseRegex) || []).length;
|
|
297
|
-
const originalSnake = (original.match(snakeCaseRegex) || []).length;
|
|
298
|
-
const originalPascal = (original.match(pascalCaseRegex) || []).length;
|
|
299
|
-
const modifiedCamel = (modified.match(camelCaseRegex) || []).length;
|
|
300
|
-
const modifiedSnake = (modified.match(snakeCaseRegex) || []).length;
|
|
301
|
-
const modifiedPascal = (modified.match(pascalCaseRegex) || []).length;
|
|
302
|
-
// Detect significant shifts
|
|
303
|
-
if (originalSnake > originalCamel && modifiedCamel > modifiedSnake) {
|
|
304
|
-
return 'Prefer camelCase over snake_case';
|
|
305
|
-
}
|
|
306
|
-
if (originalCamel > originalSnake && modifiedSnake > modifiedCamel) {
|
|
307
|
-
return 'Prefer snake_case over camelCase';
|
|
308
|
-
}
|
|
309
|
-
if (originalCamel > originalPascal && modifiedPascal > modifiedCamel) {
|
|
310
|
-
return 'Prefer PascalCase over camelCase';
|
|
311
|
-
}
|
|
312
|
-
return null;
|
|
313
|
-
}
|
|
314
|
-
addLearningPattern(userId, pattern) {
|
|
315
|
-
if (!this.learningPatterns.has(userId)) {
|
|
316
|
-
this.learningPatterns.set(userId, []);
|
|
317
|
-
}
|
|
318
|
-
const patterns = this.learningPatterns.get(userId);
|
|
319
|
-
// Check if similar pattern exists
|
|
320
|
-
const existing = patterns.find(p => p.pattern === pattern.pattern);
|
|
321
|
-
if (existing) {
|
|
322
|
-
existing.occurrences++;
|
|
323
|
-
existing.confidence = Math.min(1.0, existing.confidence + 0.1);
|
|
324
|
-
existing.examples.push(...pattern.examples.slice(0, 3)); // Keep max 3 examples
|
|
325
|
-
existing.lastSeen = Date.now();
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
patterns.push({
|
|
329
|
-
...pattern,
|
|
330
|
-
patternId: `pattern-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
331
|
-
createdAt: Date.now(),
|
|
332
|
-
lastSeen: Date.now(),
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
//# sourceMappingURL=bi-directional-learning.js.map
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Capability Boundaries
|
|
3
|
-
* Detects unsupported operations and displays boundaries
|
|
4
|
-
*
|
|
5
|
-
* Phase 1: v0.5.0-alpha.0
|
|
6
|
-
*/
|
|
7
|
-
import { colors, warning } from '../../ui.js';
|
|
8
|
-
export class CapabilityBoundaryDetector {
|
|
9
|
-
/**
|
|
10
|
-
* Detect unsupported operations
|
|
11
|
-
*/
|
|
12
|
-
detectUnsupported(query) {
|
|
13
|
-
// In alpha, minimal detection
|
|
14
|
-
// Can be enhanced later with more sophisticated detection
|
|
15
|
-
const unsupportedPatterns = [
|
|
16
|
-
{ pattern: /\b(deploy|publish|release|ship)\b/i, reason: 'Deployment operations are not supported' },
|
|
17
|
-
{ pattern: /\b(delete|remove|destroy|wipe)\s+(all|everything|database|data)\b/i, reason: 'Bulk deletion operations are not supported' },
|
|
18
|
-
];
|
|
19
|
-
for (const { pattern, reason } of unsupportedPatterns) {
|
|
20
|
-
if (pattern.test(query)) {
|
|
21
|
-
return {
|
|
22
|
-
operation: query,
|
|
23
|
-
reason,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Display capability boundary message
|
|
32
|
-
*/
|
|
33
|
-
export function displayCapabilityBoundary(boundary) {
|
|
34
|
-
console.log(warning('\n⚠️ Capability Boundary'));
|
|
35
|
-
console.log(warning(`Operation: ${boundary.operation}`));
|
|
36
|
-
console.log(warning(`Reason: ${boundary.reason}`));
|
|
37
|
-
if (boundary.alternative) {
|
|
38
|
-
console.log(colors.dim(`Alternative: ${boundary.alternative}`));
|
|
39
|
-
}
|
|
40
|
-
console.log('');
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=capability-boundaries.js.map
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Comprehensive Formatter
|
|
3
|
-
* Format content for CLI display with proper indentation and wrapping
|
|
4
|
-
*
|
|
5
|
-
* Phase 1: v0.5.0-alpha.0
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Format content for CLI display
|
|
9
|
-
*/
|
|
10
|
-
export function formatContent(content, options = {}) {
|
|
11
|
-
const { indent = 0, maxWidth = 76, preserveMarkdown = true, } = options;
|
|
12
|
-
if (!content) {
|
|
13
|
-
return '';
|
|
14
|
-
}
|
|
15
|
-
const indentStr = ' '.repeat(indent);
|
|
16
|
-
const actualMaxWidth = maxWidth - indent;
|
|
17
|
-
// If content is short enough, return as-is with indentation
|
|
18
|
-
if (content.length <= actualMaxWidth && !content.includes('\n')) {
|
|
19
|
-
return indentStr + content;
|
|
20
|
-
}
|
|
21
|
-
// Handle markdown code blocks
|
|
22
|
-
if (preserveMarkdown && content.includes('```')) {
|
|
23
|
-
return formatMarkdownContent(content, indent, actualMaxWidth);
|
|
24
|
-
}
|
|
25
|
-
// Simple word wrapping
|
|
26
|
-
const lines = content.split('\n');
|
|
27
|
-
const wrappedLines = [];
|
|
28
|
-
for (const line of lines) {
|
|
29
|
-
if (line.length <= actualMaxWidth) {
|
|
30
|
-
wrappedLines.push(indentStr + line);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
// Word wrap
|
|
34
|
-
const words = line.split(/\s+/);
|
|
35
|
-
let currentLine = '';
|
|
36
|
-
for (const word of words) {
|
|
37
|
-
if ((currentLine + word).length <= actualMaxWidth) {
|
|
38
|
-
currentLine += (currentLine ? ' ' : '') + word;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
if (currentLine) {
|
|
42
|
-
wrappedLines.push(indentStr + currentLine);
|
|
43
|
-
}
|
|
44
|
-
currentLine = word;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (currentLine) {
|
|
48
|
-
wrappedLines.push(indentStr + currentLine);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return wrappedLines.join('\n');
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Format reflection/analysis output
|
|
56
|
-
*/
|
|
57
|
-
export function formatReflection(reflection, options = {}) {
|
|
58
|
-
if (!reflection) {
|
|
59
|
-
return '';
|
|
60
|
-
}
|
|
61
|
-
if (typeof reflection === 'string') {
|
|
62
|
-
return formatContent(reflection, options);
|
|
63
|
-
}
|
|
64
|
-
if (typeof reflection === 'object') {
|
|
65
|
-
// Format structured reflection
|
|
66
|
-
const parts = [];
|
|
67
|
-
if (reflection.insight) {
|
|
68
|
-
parts.push(`💡 Insight:\n${formatContent(reflection.insight, { ...options, indent: (options.indent || 0) + 2 })}`);
|
|
69
|
-
}
|
|
70
|
-
if (reflection.reasoning) {
|
|
71
|
-
parts.push(`🧠 Reasoning:\n${formatContent(reflection.reasoning, { ...options, indent: (options.indent || 0) + 2 })}`);
|
|
72
|
-
}
|
|
73
|
-
if (reflection.summary) {
|
|
74
|
-
parts.push(`📋 Summary:\n${formatContent(reflection.summary, { ...options, indent: (options.indent || 0) + 2 })}`);
|
|
75
|
-
}
|
|
76
|
-
if (parts.length === 0) {
|
|
77
|
-
return formatContent(JSON.stringify(reflection, null, 2), options);
|
|
78
|
-
}
|
|
79
|
-
return parts.join('\n\n');
|
|
80
|
-
}
|
|
81
|
-
return String(reflection);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Format markdown content with code block preservation
|
|
85
|
-
*/
|
|
86
|
-
function formatMarkdownContent(content, indent, maxWidth) {
|
|
87
|
-
const indentStr = ' '.repeat(indent);
|
|
88
|
-
const lines = content.split('\n');
|
|
89
|
-
const formatted = [];
|
|
90
|
-
let inCodeBlock = false;
|
|
91
|
-
let codeBlockLang = '';
|
|
92
|
-
for (const line of lines) {
|
|
93
|
-
if (line.trim().startsWith('```')) {
|
|
94
|
-
inCodeBlock = !inCodeBlock;
|
|
95
|
-
if (inCodeBlock) {
|
|
96
|
-
codeBlockLang = line.trim().substring(3).trim();
|
|
97
|
-
}
|
|
98
|
-
formatted.push(indentStr + line);
|
|
99
|
-
}
|
|
100
|
-
else if (inCodeBlock) {
|
|
101
|
-
// Preserve code blocks as-is
|
|
102
|
-
formatted.push(indentStr + line);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
// Format regular markdown lines
|
|
106
|
-
if (line.length <= maxWidth) {
|
|
107
|
-
formatted.push(indentStr + line);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
// Word wrap for non-code content
|
|
111
|
-
formatted.push(formatContent(line, { indent, maxWidth: maxWidth + indent }));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return formatted.join('\n');
|
|
116
|
-
}
|
|
117
|
-
//# sourceMappingURL=comprehensive-formatter.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Contextual Feature Discovery (v0.5.0-alpha.0 - Stub)
|
|
3
|
-
* TODO: Implement contextual feature suggestions
|
|
4
|
-
*/
|
|
5
|
-
export function shouldShowContextualSuggestion(query, command) {
|
|
6
|
-
// In alpha, return null (no suggestions)
|
|
7
|
-
// Can be enhanced later with heuristics
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=contextual-feature-discovery.js.map
|