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
package/dist/context.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enhanced Context Understanding System
|
|
3
|
-
* Senior-level codebase comprehension with file relationships
|
|
4
|
-
*/
|
|
5
|
-
import { readFileSync, existsSync } from 'fs';
|
|
6
|
-
import { join, dirname, extname } from 'path';
|
|
7
|
-
import { searchSimilar } from './search.js';
|
|
8
|
-
/**
|
|
9
|
-
* Extract imports/exports from code
|
|
10
|
-
*/
|
|
11
|
-
export function extractImports(content, filepath) {
|
|
12
|
-
const imports = [];
|
|
13
|
-
const lines = content.split('\n');
|
|
14
|
-
const ext = extname(filepath).toLowerCase();
|
|
15
|
-
// TypeScript/JavaScript imports
|
|
16
|
-
if (['.ts', '.tsx', '.js', '.jsx'].includes(ext)) {
|
|
17
|
-
for (const line of lines) {
|
|
18
|
-
// ES6 imports
|
|
19
|
-
const es6Match = line.match(/import\s+(?:.*\s+from\s+)?['"]([^'"]+)['"]/);
|
|
20
|
-
if (es6Match) {
|
|
21
|
-
imports.push(es6Match[1]);
|
|
22
|
-
}
|
|
23
|
-
// CommonJS requires
|
|
24
|
-
const requireMatch = line.match(/require\(['"]([^'"]+)['"]\)/);
|
|
25
|
-
if (requireMatch) {
|
|
26
|
-
imports.push(requireMatch[1]);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
// Python imports
|
|
31
|
-
if (ext === '.py') {
|
|
32
|
-
for (const line of lines) {
|
|
33
|
-
const importMatch = line.match(/^(?:from\s+(\S+)\s+)?import\s+(\S+)/);
|
|
34
|
-
if (importMatch) {
|
|
35
|
-
imports.push(importMatch[1] || importMatch[2]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return imports;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Extract exports from code
|
|
43
|
-
*/
|
|
44
|
-
export function extractExports(content, filepath) {
|
|
45
|
-
const exports = [];
|
|
46
|
-
const lines = content.split('\n');
|
|
47
|
-
const ext = extname(filepath).toLowerCase();
|
|
48
|
-
// TypeScript/JavaScript exports
|
|
49
|
-
if (['.ts', '.tsx', '.js', '.jsx'].includes(ext)) {
|
|
50
|
-
for (const line of lines) {
|
|
51
|
-
// Named exports
|
|
52
|
-
const namedExport = line.match(/export\s+(?:const|function|class|interface|type|enum)\s+(\w+)/);
|
|
53
|
-
if (namedExport) {
|
|
54
|
-
exports.push(namedExport[1]);
|
|
55
|
-
}
|
|
56
|
-
// Default export
|
|
57
|
-
if (line.includes('export default')) {
|
|
58
|
-
exports.push('default');
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return exports;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Build file relationship map
|
|
66
|
-
*/
|
|
67
|
-
export async function buildFileRelationships(filepaths, baseDir) {
|
|
68
|
-
const relationships = new Map();
|
|
69
|
-
for (const filepath of filepaths) {
|
|
70
|
-
const fullPath = join(baseDir, filepath);
|
|
71
|
-
if (!existsSync(fullPath)) {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
const content = readFileSync(fullPath, 'utf-8');
|
|
76
|
-
const imports = extractImports(content, filepath);
|
|
77
|
-
const exports = extractExports(content, filepath);
|
|
78
|
-
relationships.set(filepath, {
|
|
79
|
-
filepath,
|
|
80
|
-
imports,
|
|
81
|
-
exports,
|
|
82
|
-
dependencies: [],
|
|
83
|
-
dependents: [],
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
// Skip files that can't be read
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
// Build dependency graph
|
|
92
|
-
for (const [filepath, relationship] of relationships.entries()) {
|
|
93
|
-
for (const imp of relationship.imports) {
|
|
94
|
-
// Try to resolve import to actual file
|
|
95
|
-
// This is simplified - real implementation would resolve module paths
|
|
96
|
-
for (const [otherPath, otherRel] of relationships.entries()) {
|
|
97
|
-
if (otherPath !== filepath && (otherPath.includes(imp) || imp.includes(otherPath))) {
|
|
98
|
-
relationship.dependencies.push(otherPath);
|
|
99
|
-
if (!otherRel.dependents.includes(filepath)) {
|
|
100
|
-
otherRel.dependents.push(filepath);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return relationships;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Get enhanced context with file relationships
|
|
110
|
-
*/
|
|
111
|
-
export async function getEnhancedContext(query, options = {}) {
|
|
112
|
-
const { primaryChunks = 15, relatedChunks = 5, includeRelationships = true, } = options;
|
|
113
|
-
// Get primary search results
|
|
114
|
-
const primaryResults = await searchSimilar(query, primaryChunks);
|
|
115
|
-
// Get unique filepaths
|
|
116
|
-
const filepaths = [...new Set(primaryResults.map(r => r.filepath))];
|
|
117
|
-
// Build file relationships if requested
|
|
118
|
-
let fileRelationships = new Map();
|
|
119
|
-
let dependencyGraph = new Map();
|
|
120
|
-
if (includeRelationships && filepaths.length > 0) {
|
|
121
|
-
// Get base directory from first file
|
|
122
|
-
const baseDir = dirname(filepaths[0]);
|
|
123
|
-
fileRelationships = await buildFileRelationships(filepaths, baseDir);
|
|
124
|
-
// Build dependency graph
|
|
125
|
-
for (const [filepath, relationship] of fileRelationships.entries()) {
|
|
126
|
-
dependencyGraph.set(filepath, relationship.dependencies);
|
|
127
|
-
}
|
|
128
|
-
// Get related chunks from dependent files
|
|
129
|
-
const dependentFiles = new Set();
|
|
130
|
-
for (const relationship of fileRelationships.values()) {
|
|
131
|
-
relationship.dependents.forEach(dep => dependentFiles.add(dep));
|
|
132
|
-
}
|
|
133
|
-
// Search for related chunks in dependent files
|
|
134
|
-
const relatedQueries = Array.from(dependentFiles).slice(0, 3);
|
|
135
|
-
const relatedResults = [];
|
|
136
|
-
for (const relatedQuery of relatedQueries) {
|
|
137
|
-
const results = await searchSimilar(relatedQuery, Math.ceil(relatedChunks / relatedQueries.length));
|
|
138
|
-
relatedResults.push(...results);
|
|
139
|
-
}
|
|
140
|
-
// Combine and deduplicate
|
|
141
|
-
const allChunks = [...primaryResults, ...relatedResults];
|
|
142
|
-
const seen = new Set();
|
|
143
|
-
const uniqueChunks = allChunks.filter(chunk => {
|
|
144
|
-
const key = `${chunk.filepath}:${chunk.content.substring(0, 50)}`;
|
|
145
|
-
if (seen.has(key)) {
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
seen.add(key);
|
|
149
|
-
return true;
|
|
150
|
-
});
|
|
151
|
-
return {
|
|
152
|
-
primaryChunks: primaryResults,
|
|
153
|
-
relatedChunks: uniqueChunks.slice(primaryChunks),
|
|
154
|
-
fileRelationships,
|
|
155
|
-
dependencyGraph,
|
|
156
|
-
totalChunks: uniqueChunks.length,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
return {
|
|
160
|
-
primaryChunks: primaryResults,
|
|
161
|
-
relatedChunks: [],
|
|
162
|
-
fileRelationships,
|
|
163
|
-
dependencyGraph,
|
|
164
|
-
totalChunks: primaryResults.length,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Format context for display
|
|
169
|
-
*/
|
|
170
|
-
export function formatContext(context) {
|
|
171
|
-
let output = `Found ${context.totalChunks} relevant chunks from ${context.primaryChunks.length} primary files.\n\n`;
|
|
172
|
-
if (context.fileRelationships.size > 0) {
|
|
173
|
-
output += 'File Relationships:\n';
|
|
174
|
-
for (const [filepath, relationship] of context.fileRelationships.entries()) {
|
|
175
|
-
output += ` ${filepath}:\n`;
|
|
176
|
-
if (relationship.dependencies.length > 0) {
|
|
177
|
-
output += ` Dependencies: ${relationship.dependencies.join(', ')}\n`;
|
|
178
|
-
}
|
|
179
|
-
if (relationship.dependents.length > 0) {
|
|
180
|
-
output += ` Dependents: ${relationship.dependents.join(', ')}\n`;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
output += '\n';
|
|
184
|
-
}
|
|
185
|
-
return output;
|
|
186
|
-
}
|
|
187
|
-
//# sourceMappingURL=context.js.map
|
package/dist/docs.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Documentation Generator
|
|
3
|
-
* Auto-generate and maintain documentation
|
|
4
|
-
*/
|
|
5
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';
|
|
6
|
-
import { join, dirname } from 'path';
|
|
7
|
-
import { chatWithContext } from './chat.js';
|
|
8
|
-
import { getEnhancedContext } from './context.js';
|
|
9
|
-
/**
|
|
10
|
-
* Generate documentation for a file
|
|
11
|
-
*/
|
|
12
|
-
export async function generateFileDocs(filepath) {
|
|
13
|
-
const fullPath = join(process.cwd(), filepath);
|
|
14
|
-
if (!existsSync(fullPath)) {
|
|
15
|
-
throw new Error(`File not found: ${filepath}`);
|
|
16
|
-
}
|
|
17
|
-
const content = readFileSync(fullPath, 'utf-8');
|
|
18
|
-
const ext = filepath.split('.').pop()?.toLowerCase() || '';
|
|
19
|
-
// Get context
|
|
20
|
-
const context = await getEnhancedContext(`Generate documentation for ${filepath}`, {
|
|
21
|
-
primaryChunks: 10,
|
|
22
|
-
includeRelationships: true,
|
|
23
|
-
});
|
|
24
|
-
// Create documentation prompt
|
|
25
|
-
const docPrompt = `Generate comprehensive documentation for this code file:
|
|
26
|
-
|
|
27
|
-
File: ${filepath}
|
|
28
|
-
Code:
|
|
29
|
-
\`\`\`${ext}
|
|
30
|
-
${content}
|
|
31
|
-
\`\`\`
|
|
32
|
-
|
|
33
|
-
Provide:
|
|
34
|
-
1. File overview and purpose
|
|
35
|
-
2. Main functions/classes and their purposes
|
|
36
|
-
3. Parameters and return values
|
|
37
|
-
4. Usage examples
|
|
38
|
-
5. Important notes or warnings
|
|
39
|
-
|
|
40
|
-
Format as clear markdown documentation.`;
|
|
41
|
-
const contextResults = [{
|
|
42
|
-
filepath,
|
|
43
|
-
content,
|
|
44
|
-
score: 1.0,
|
|
45
|
-
}, ...context.primaryChunks];
|
|
46
|
-
const docs = await chatWithContext(docPrompt, contextResults);
|
|
47
|
-
return docs;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Generate README for a project
|
|
51
|
-
*/
|
|
52
|
-
export async function generateREADME(files) {
|
|
53
|
-
// Get project context
|
|
54
|
-
const context = await getEnhancedContext('Generate project README documentation', {
|
|
55
|
-
primaryChunks: 30,
|
|
56
|
-
includeRelationships: true,
|
|
57
|
-
});
|
|
58
|
-
const fileList = files || context.primaryChunks.map(c => c.filepath);
|
|
59
|
-
const fileContents = fileList
|
|
60
|
-
.slice(0, 10)
|
|
61
|
-
.map(f => {
|
|
62
|
-
try {
|
|
63
|
-
const content = readFileSync(join(process.cwd(), f), 'utf-8');
|
|
64
|
-
return `\n### ${f}\n\`\`\`\n${content.substring(0, 200)}...\n\`\`\``;
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
return '';
|
|
68
|
-
}
|
|
69
|
-
})
|
|
70
|
-
.join('\n');
|
|
71
|
-
const readmePrompt = `Generate a comprehensive README.md for this project:
|
|
72
|
-
|
|
73
|
-
Key files:
|
|
74
|
-
${fileList.slice(0, 20).map(f => `- ${f}`).join('\n')}
|
|
75
|
-
|
|
76
|
-
${fileContents}
|
|
77
|
-
|
|
78
|
-
Create a professional README with:
|
|
79
|
-
1. Project title and description
|
|
80
|
-
2. Features
|
|
81
|
-
3. Installation instructions
|
|
82
|
-
4. Usage examples
|
|
83
|
-
5. Project structure
|
|
84
|
-
6. Contributing guidelines
|
|
85
|
-
7. License information
|
|
86
|
-
|
|
87
|
-
Format as markdown.`;
|
|
88
|
-
const contextResults = context.primaryChunks;
|
|
89
|
-
const readme = await chatWithContext(readmePrompt, contextResults);
|
|
90
|
-
return readme;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Update existing documentation
|
|
94
|
-
*/
|
|
95
|
-
export async function updateDocs(filepath) {
|
|
96
|
-
const fullPath = join(process.cwd(), filepath);
|
|
97
|
-
if (!existsSync(fullPath)) {
|
|
98
|
-
throw new Error(`File not found: ${filepath}`);
|
|
99
|
-
}
|
|
100
|
-
const currentContent = readFileSync(fullPath, 'utf-8');
|
|
101
|
-
const codePath = filepath.replace(/\.md$/, '').replace(/docs\//, '');
|
|
102
|
-
// Get current code
|
|
103
|
-
let codeContent = '';
|
|
104
|
-
try {
|
|
105
|
-
const codeFile = join(process.cwd(), codePath);
|
|
106
|
-
if (existsSync(codeFile)) {
|
|
107
|
-
codeContent = readFileSync(codeFile, 'utf-8');
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
catch {
|
|
111
|
-
// Code file might not exist
|
|
112
|
-
}
|
|
113
|
-
const updatePrompt = `Update this documentation to match the current code:
|
|
114
|
-
|
|
115
|
-
Documentation file: ${filepath}
|
|
116
|
-
Current docs:
|
|
117
|
-
\`\`\`
|
|
118
|
-
${currentContent}
|
|
119
|
-
\`\`\`
|
|
120
|
-
|
|
121
|
-
Current code:
|
|
122
|
-
\`\`\`
|
|
123
|
-
${codeContent.substring(0, 1000)}
|
|
124
|
-
\`\`\`
|
|
125
|
-
|
|
126
|
-
Update the documentation to accurately reflect the current code implementation.`;
|
|
127
|
-
const contextResults = [{
|
|
128
|
-
filepath,
|
|
129
|
-
content: currentContent,
|
|
130
|
-
score: 1.0,
|
|
131
|
-
}];
|
|
132
|
-
const updatedDocs = await chatWithContext(updatePrompt, contextResults);
|
|
133
|
-
return updatedDocs;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Save documentation to file
|
|
137
|
-
*/
|
|
138
|
-
export function saveDocs(filepath, content) {
|
|
139
|
-
const fullPath = join(process.cwd(), filepath);
|
|
140
|
-
const dir = dirname(fullPath);
|
|
141
|
-
if (!existsSync(dir)) {
|
|
142
|
-
mkdirSync(dir, { recursive: true });
|
|
143
|
-
}
|
|
144
|
-
writeFileSync(fullPath, content, 'utf-8');
|
|
145
|
-
}
|
|
146
|
-
//# sourceMappingURL=docs.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Domain Entity: Knowledge Preservation
|
|
3
|
-
* Represents preserved knowledge extracted from codebases
|
|
4
|
-
*
|
|
5
|
-
* Part of Organizational Memory system - preserves institutional knowledge
|
|
6
|
-
*
|
|
7
|
-
* Clean Architecture: Domain Layer
|
|
8
|
-
*/
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=knowledge-preservation.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Domain Error: EmbeddingsNotFoundError
|
|
3
|
-
* Thrown when embeddings database doesn't exist or is empty for a repository
|
|
4
|
-
*/
|
|
5
|
-
export class EmbeddingsNotFoundError extends Error {
|
|
6
|
-
repoPath;
|
|
7
|
-
constructor(repoPath) {
|
|
8
|
-
super(`No embeddings found for this repository. Run 'codehere index' first.`);
|
|
9
|
-
this.repoPath = repoPath;
|
|
10
|
-
this.name = 'EmbeddingsNotFoundError';
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=embeddings-not-found-error.js.map
|
package/dist/domain/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Domain Layer - Public Exports
|
|
3
|
-
* Core business logic with no external dependencies
|
|
4
|
-
*/
|
|
5
|
-
// Entities
|
|
6
|
-
export * from './entities/query.js';
|
|
7
|
-
export * from './entities/code-chunk.js';
|
|
8
|
-
export * from './entities/memory.js';
|
|
9
|
-
export * from './entities/edit.js';
|
|
10
|
-
// Interfaces
|
|
11
|
-
export * from './interfaces/ai-service.interface.js';
|
|
12
|
-
export * from './interfaces/embedding-repository.interface.js';
|
|
13
|
-
export * from './interfaces/memory-repository.interface.js';
|
|
14
|
-
export * from './interfaces/code-analyzer.interface.js';
|
|
15
|
-
export * from './interfaces/verification-service.interface.js';
|
|
16
|
-
// Services
|
|
17
|
-
export * from './services/query-intent-classifier.js';
|
|
18
|
-
export * from './services/memory-retriever.js';
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Domain Service: Cross-Team Pattern Sharing
|
|
3
|
-
* Enables sharing patterns across teams (opt-in, anonymous)
|
|
4
|
-
*
|
|
5
|
-
* Clean Architecture: Domain Layer
|
|
6
|
-
* Strategic: Foundation for Learning Network and Marketplace
|
|
7
|
-
*/
|
|
8
|
-
import { randomUUID } from 'crypto';
|
|
9
|
-
/**
|
|
10
|
-
* Cross-Team Pattern Sharing Service
|
|
11
|
-
* Handles opt-in pattern sharing across teams
|
|
12
|
-
*/
|
|
13
|
-
export class CrossTeamPatternSharing {
|
|
14
|
-
patternRepository;
|
|
15
|
-
constructor(patternRepository) {
|
|
16
|
-
this.patternRepository = patternRepository;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Share a pattern (opt-in)
|
|
20
|
-
* Anonymizes if requested, prepares for sharing
|
|
21
|
-
*/
|
|
22
|
-
async sharePattern(patternId, codebaseId, options) {
|
|
23
|
-
// Retrieve original pattern
|
|
24
|
-
const patterns = await this.patternRepository.findByCodebase(codebaseId);
|
|
25
|
-
const pattern = patterns.find(p => p.id === patternId);
|
|
26
|
-
if (!pattern) {
|
|
27
|
-
throw new Error(`Pattern not found: ${patternId}`);
|
|
28
|
-
}
|
|
29
|
-
// Create shared version
|
|
30
|
-
const sharedPattern = {
|
|
31
|
-
id: randomUUID(),
|
|
32
|
-
originalPatternId: patternId,
|
|
33
|
-
patternType: pattern.type,
|
|
34
|
-
name: this.anonymizeIfNeeded(pattern.name, options.anonymize),
|
|
35
|
-
description: this.anonymizeIfNeeded(pattern.description, options.anonymize),
|
|
36
|
-
codeExample: options.includeCodeExample ? this.anonymizeCodeExample(pattern.codeExample, options.anonymize) : undefined,
|
|
37
|
-
tags: [...(pattern.metadata?.tags || []), ...(options.tags || [])],
|
|
38
|
-
language: this.detectLanguage(pattern.filepath),
|
|
39
|
-
usageCount: pattern.usageCount || 0,
|
|
40
|
-
sharedAt: new Date(),
|
|
41
|
-
anonymized: options.anonymize,
|
|
42
|
-
metadata: {
|
|
43
|
-
complexity: pattern.metadata?.complexity,
|
|
44
|
-
confidence: pattern.metadata?.confidence,
|
|
45
|
-
rationale: pattern.metadata?.rationale,
|
|
46
|
-
alternatives: pattern.metadata?.alternatives,
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
// In future: Store in shared patterns repository/marketplace
|
|
50
|
-
// For now, return the shared pattern structure
|
|
51
|
-
return sharedPattern;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Find shared patterns that match query
|
|
55
|
-
* Future: Query from marketplace/shared repository
|
|
56
|
-
*/
|
|
57
|
-
async findSharedPatterns(query, filters) {
|
|
58
|
-
// For now: Return empty array (marketplace not yet implemented)
|
|
59
|
-
// Future: Query shared patterns repository
|
|
60
|
-
return [];
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Import shared pattern into codebase
|
|
64
|
-
*/
|
|
65
|
-
async importSharedPattern(sharedPattern, targetCodebaseId, targetCodebasePath) {
|
|
66
|
-
// Create new pattern from shared pattern
|
|
67
|
-
const importedPattern = {
|
|
68
|
-
id: randomUUID(),
|
|
69
|
-
codebaseId: targetCodebaseId,
|
|
70
|
-
type: sharedPattern.patternType,
|
|
71
|
-
name: sharedPattern.name,
|
|
72
|
-
description: sharedPattern.description,
|
|
73
|
-
codeExample: sharedPattern.codeExample,
|
|
74
|
-
metadata: {
|
|
75
|
-
tags: sharedPattern.tags,
|
|
76
|
-
complexity: sharedPattern.metadata?.complexity,
|
|
77
|
-
confidence: sharedPattern.metadata?.confidence,
|
|
78
|
-
rationale: sharedPattern.metadata?.rationale,
|
|
79
|
-
alternatives: sharedPattern.metadata?.alternatives,
|
|
80
|
-
context: 'Imported from shared pattern marketplace',
|
|
81
|
-
},
|
|
82
|
-
createdAt: new Date(),
|
|
83
|
-
usageCount: 0,
|
|
84
|
-
};
|
|
85
|
-
// Store in target codebase
|
|
86
|
-
await this.patternRepository.store(importedPattern);
|
|
87
|
-
return importedPattern;
|
|
88
|
-
}
|
|
89
|
-
anonymizeIfNeeded(text, anonymize) {
|
|
90
|
-
if (!text)
|
|
91
|
-
return '';
|
|
92
|
-
if (!anonymize)
|
|
93
|
-
return text;
|
|
94
|
-
// Remove codebase-specific references
|
|
95
|
-
// Simple anonymization - remove file paths, project names, etc.
|
|
96
|
-
return text
|
|
97
|
-
.replace(/\/[^\s]+\/[^\s]+\.(ts|js|tsx|jsx)/g, 'file.ts')
|
|
98
|
-
.replace(/src\/[^\s]+/g, 'src/...')
|
|
99
|
-
.replace(/(project|codebase|app)[^\s]*/gi, '[project]');
|
|
100
|
-
}
|
|
101
|
-
anonymizeCodeExample(code, anonymize) {
|
|
102
|
-
if (!code || !anonymize)
|
|
103
|
-
return code;
|
|
104
|
-
// Remove codebase-specific paths, project names
|
|
105
|
-
return this.anonymizeIfNeeded(code, true);
|
|
106
|
-
}
|
|
107
|
-
detectLanguage(filepath) {
|
|
108
|
-
if (!filepath)
|
|
109
|
-
return undefined;
|
|
110
|
-
if (filepath.endsWith('.ts') || filepath.endsWith('.tsx'))
|
|
111
|
-
return 'TypeScript';
|
|
112
|
-
if (filepath.endsWith('.js') || filepath.endsWith('.jsx'))
|
|
113
|
-
return 'JavaScript';
|
|
114
|
-
if (filepath.endsWith('.py'))
|
|
115
|
-
return 'Python';
|
|
116
|
-
if (filepath.endsWith('.java'))
|
|
117
|
-
return 'Java';
|
|
118
|
-
if (filepath.endsWith('.go'))
|
|
119
|
-
return 'Go';
|
|
120
|
-
if (filepath.endsWith('.rs'))
|
|
121
|
-
return 'Rust';
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
//# sourceMappingURL=cross-team-pattern-sharing.js.map
|