context-tracker-mcp1.0 1.0.6 → 1.0.7

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.
@@ -0,0 +1,151 @@
1
+ import { promises as fs } from 'fs';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ const __filename = fileURLToPath(import.meta.url);
5
+ const __dirname = path.dirname(__filename);
6
+ const DEFAULT_WORKFLOWS = [
7
+ {
8
+ name: 'context-tracking',
9
+ description: 'Track development context and code changes',
10
+ steps: ['Initialize file watcher', 'Setup context tracking', 'Enable auto-tracking']
11
+ },
12
+ {
13
+ name: 'documentation',
14
+ description: 'Generate and maintain project documentation',
15
+ steps: ['Scan project structure', 'Generate docs', 'Setup auto-doc generation']
16
+ },
17
+ {
18
+ name: 'error-analysis',
19
+ description: 'Analyze and track errors across sessions',
20
+ steps: ['Enable error tracking', 'Setup error patterns', 'Configure notifications']
21
+ },
22
+ {
23
+ name: 'project-intelligence',
24
+ description: 'Learn and suggest based on project patterns',
25
+ steps: ['Analyze project patterns', 'Build knowledge base', 'Enable suggestions']
26
+ }
27
+ ];
28
+ async function findProjectRoot() {
29
+ let currentDir = process.cwd();
30
+ while (currentDir !== path.dirname(currentDir)) {
31
+ const packageJsonPath = path.join(currentDir, 'package.json');
32
+ const gitPath = path.join(currentDir, '.git');
33
+ try {
34
+ await fs.access(packageJsonPath);
35
+ return currentDir;
36
+ }
37
+ catch {
38
+ try {
39
+ await fs.access(gitPath);
40
+ return currentDir;
41
+ }
42
+ catch {
43
+ currentDir = path.dirname(currentDir);
44
+ }
45
+ }
46
+ }
47
+ return process.cwd();
48
+ }
49
+ async function createMcpConfig(projectRoot) {
50
+ const configPath = path.join(projectRoot, '.windsurf', 'mcp-config.json');
51
+ const config = {
52
+ mcpServers: {
53
+ 'context-tracker': {
54
+ command: 'npx',
55
+ args: ['context-tracker-mcp1.0'],
56
+ transportType: 'stdio',
57
+ enabled: true
58
+ }
59
+ }
60
+ };
61
+ try {
62
+ await fs.mkdir(path.dirname(configPath), { recursive: true });
63
+ await fs.writeFile(configPath, JSON.stringify(config, null, 2));
64
+ console.log('✅ MCP config created at:', configPath);
65
+ }
66
+ catch (error) {
67
+ console.error('❌ Failed to create MCP config:', error);
68
+ throw error;
69
+ }
70
+ }
71
+ async function createWorkflowsDirectory(projectRoot) {
72
+ const workflowsDir = path.join(projectRoot, '.windsurf', 'workflows');
73
+ try {
74
+ await fs.mkdir(workflowsDir, { recursive: true });
75
+ for (const workflow of DEFAULT_WORKFLOWS) {
76
+ const workflowPath = path.join(workflowsDir, `${workflow.name}.md`);
77
+ const content = `---
78
+ description: ${workflow.description}
79
+ ---
80
+ # ${workflow.name} Workflow
81
+
82
+ ${workflow.steps.map((step, i) => `${i + 1}. ${step}`).join('\n')}
83
+
84
+ ## Usage
85
+
86
+ This workflow is automatically managed by the Context Tracker MCP.
87
+ `;
88
+ await fs.writeFile(workflowPath, content);
89
+ }
90
+ console.log('✅ Workflows created in:', workflowsDir);
91
+ }
92
+ catch (error) {
93
+ console.error('❌ Failed to create workflows:', error);
94
+ throw error;
95
+ }
96
+ }
97
+ async function createContextDataDirectory(projectRoot) {
98
+ const contextDir = path.join(projectRoot, '.context-data');
99
+ try {
100
+ await fs.mkdir(contextDir, { recursive: true });
101
+ await fs.writeFile(path.join(contextDir, 'README.md'), '# Context Data\n\nThis directory contains auto-generated context tracking data.\nDo not manually edit files in this directory.\n');
102
+ console.log('✅ Context data directory created:', contextDir);
103
+ }
104
+ catch (error) {
105
+ console.error('❌ Failed to create context data directory:', error);
106
+ throw error;
107
+ }
108
+ }
109
+ async function updateGitignore(projectRoot) {
110
+ const gitignorePath = path.join(projectRoot, '.gitignore');
111
+ const entries = ['.context-data/', '.windsurf/mcp-config.json'];
112
+ try {
113
+ let content = '';
114
+ try {
115
+ content = await fs.readFile(gitignorePath, 'utf-8');
116
+ }
117
+ catch {
118
+ // File doesn't exist, create new
119
+ }
120
+ const missingEntries = entries.filter(e => !content.includes(e));
121
+ if (missingEntries.length > 0) {
122
+ const newContent = content + '\n# Context Tracker MCP\n' + missingEntries.join('\n') + '\n';
123
+ await fs.writeFile(gitignorePath, newContent);
124
+ console.log('✅ Updated .gitignore');
125
+ }
126
+ }
127
+ catch (error) {
128
+ console.error('⚠️ Could not update .gitignore:', error);
129
+ }
130
+ }
131
+ async function main() {
132
+ console.log('🚀 Setting up Context Tracker MCP workflows...\n');
133
+ try {
134
+ const projectRoot = await findProjectRoot();
135
+ console.log('📁 Project root:', projectRoot);
136
+ await createMcpConfig(projectRoot);
137
+ await createWorkflowsDirectory(projectRoot);
138
+ await createContextDataDirectory(projectRoot);
139
+ await updateGitignore(projectRoot);
140
+ console.log('\n✨ Setup complete!');
141
+ console.log('\nNext steps:');
142
+ console.log('1. Restart your IDE (Windsurf/VS Code)');
143
+ console.log('2. The MCP server will be auto-detected');
144
+ console.log('3. Use @context-tracker to access tools');
145
+ }
146
+ catch (error) {
147
+ console.error('\n❌ Setup failed:', error);
148
+ process.exit(1);
149
+ }
150
+ }
151
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-tracker-mcp1.0",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "MCP server for tracking context, code changes, and generating documentation",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",