oneie 3.4.2 ā 3.6.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/.claude/agents/agent-director.md +902 -22
- package/.claude/agents/agent-onboard-example-output.md +600 -0
- package/.claude/agents/agent-onboard.md +576 -0
- package/.claude/commands/ONBOARDING_ENHANCEMENT_SUMMARY.md +266 -0
- package/.claude/commands/one.md +411 -10
- package/.claude/commands/release.md +64 -3
- package/CLAUDE.md +55 -69
- package/dist/commands/init.d.ts +5 -6
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +101 -101
- package/dist/commands/init.js.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/utils/installation-setup.d.ts +24 -1
- package/dist/utils/installation-setup.d.ts.map +1 -1
- package/dist/utils/installation-setup.js +85 -1
- package/dist/utils/installation-setup.js.map +1 -1
- package/dist/utils/launch-claude.d.ts +6 -0
- package/dist/utils/launch-claude.d.ts.map +1 -0
- package/dist/utils/launch-claude.js +51 -0
- package/dist/utils/launch-claude.js.map +1 -0
- package/dist/utils/validation.d.ts +48 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +73 -0
- package/dist/utils/validation.js.map +1 -0
- package/folders.yaml +1 -1
- package/one/.obsidian/app.json +8 -0
- package/one/.obsidian/appearance.json +1 -0
- package/one/.obsidian/community-plugins.json +3 -0
- package/one/.obsidian/core-plugins.json +33 -0
- package/one/.obsidian/plugins/easy-bake/main.js +361 -0
- package/one/.obsidian/plugins/easy-bake/manifest.json +11 -0
- package/one/.obsidian/plugins/easy-bake/styles.css +10 -0
- package/one/.obsidian/workspace.json +240 -0
- package/one/connections/workflow-onboarding.md +683 -0
- package/one/events/CART-DRAWER-INTEGRATION-GUIDE.md +354 -0
- package/one/events/CRITICAL-FIXES-COMPLETE.md +504 -0
- package/one/events/DEPLOYMENT.md +178 -0
- package/one/events/ECOMMERCE-DEMO-PLAN.md +225 -0
- package/one/events/ECOMMERCE-LIVE-DEMO.md +363 -0
- package/one/events/ECOMMERCE-TEMPLATE-COMPLETE.md +735 -0
- package/one/events/ECOMMERCE-TEMPLATES-SUMMARY.md +923 -0
- package/one/events/GRADIENT-TEXT-PERMANENT-FIX.md +223 -0
- package/one/events/HANDOFF.md +313 -0
- package/one/events/IMPLEMENTATION-SUMMARY-FINAL.md +503 -0
- package/one/events/IMPLEMENTATION_SUMMARY.md +529 -0
- package/one/events/LANDING-PAGE-EXAMPLE-OUTPUT.md +666 -0
- package/one/events/LANDING-PAGE-IMPLEMENTATION.md +642 -0
- package/one/events/LANDING-PAGE-QUICKSTART.md +407 -0
- package/one/events/MULTI-ONTOLOGY-COMPLETE-GUIDE.md +1627 -0
- package/one/events/MULTI-ONTOLOGY-IMPLEMENTATION-COMPLETE.md +573 -0
- package/one/events/ONBOARDING-IMPLEMENTATION-COMPLETE copy.md +398 -0
- package/one/events/ONTOLOGY-TUTORIALS-SUMMARY.md +525 -0
- package/one/events/ONTOLOGY-TYPE-GENERATOR-SUMMARY.md +455 -0
- package/one/events/ONTOLOGY_DISCOVERY_IMPLEMENTATION.md +486 -0
- package/one/events/ONTOLOGY_DISCOVERY_QUICKSTART.md +203 -0
- package/one/events/SECURITY-AUDIT-FIXES.md +376 -0
- package/one/events/SECURITY-SCAN-COMPLETE.md +281 -0
- package/one/events/SHOP-BUILD-STATUS.md +114 -0
- package/one/events/SHOP-PREMIUM-UPDATE.md +149 -0
- package/one/events/SITE-WIDE-GRADIENT-FIX.md +299 -0
- package/one/events/STORE-PRODUCTION-READY-STATUS.md +359 -0
- package/one/events/STRIPE-PAYMENT-METHODS-GUIDE.md +429 -0
- package/one/events/agent-director-enhancement-summary.md +386 -0
- package/one/events/agent-onboard-implementation-summary.md +457 -0
- package/one/events/clean-agent-ontology-cleanup-report.md +353 -0
- package/one/events/landing-page-generator.md +458 -0
- package/one/events/onboarding-implementation-complete.md +505 -0
- package/one/events/release.md +254 -0
- package/one/events/separate-implementation-status.md +537 -0
- package/one/groups/nine-padle-contents.baked.md +1252 -0
- package/one/groups/nine-padle-contents.md +6 -0
- package/one/knowledge/100-inference-quick-reference.md +431 -0
- package/one/knowledge/agent-onboard-usage.md +612 -0
- package/one/knowledge/cli-claude-handoff.md +718 -0
- package/one/knowledge/installation-folders.md +45 -1
- package/one/knowledge/ontology-blog.yaml +31 -0
- package/one/knowledge/ontology-cheatsheet.md +591 -0
- package/one/knowledge/ontology-community.yaml +42 -0
- package/one/knowledge/ontology-core-universal.md +722 -0
- package/one/knowledge/ontology-core.yaml +50 -0
- package/one/knowledge/ontology-courses.yaml +53 -0
- package/one/knowledge/ontology-creator.md +376 -0
- package/one/knowledge/ontology-developer-guide.md +789 -0
- package/one/knowledge/ontology-education.md +920 -0
- package/one/knowledge/ontology-index.md +354 -0
- package/one/knowledge/ontology-migration-guide.md +811 -0
- package/one/knowledge/ontology-minimal.yaml +1 -1
- package/one/knowledge/ontology-portfolio.yaml +31 -0
- package/one/knowledge/ontology-quickstart.md +576 -0
- package/one/knowledge/ontology-shop.yaml +121 -0
- package/one/knowledge/ontology-tokens.yaml +32 -0
- package/one/knowledge/ontology-tutorial.md +434 -0
- package/one/knowledge/ontology-video-script.md +890 -0
- package/one/things/docs/ecommerce/ARCHITECTURE-DIAGRAM.md +467 -0
- package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-IMPLEMENTATION.md +408 -0
- package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-SUMMARY.md +369 -0
- package/one/things/docs/ecommerce/CONVERSION-UX-IMPLEMENTATION-SUMMARY.md +396 -0
- package/one/things/docs/ecommerce/FEATURE-SUMMARY.md +468 -0
- package/one/things/docs/ecommerce/IMPLEMENTATION-NOTES.md +582 -0
- package/one/things/docs/ecommerce/INTEGRATION-EXAMPLE.md +449 -0
- package/one/things/docs/ecommerce/QUICK-START.md +368 -0
- package/one/things/docs/ecommerce/URGENCY-IMPLEMENTATION-SUMMARY.md +498 -0
- package/one/things/docs/ecommerce/URGENCY-QUICK-REFERENCE.md +237 -0
- package/one/things/docs/ecommerce/USAGE-EXAMPLE.astro +171 -0
- package/one/things/docs/ecommerce/demo.astro +309 -0
- package/one/things/plans/agent-director-100-inference-plans.md +410 -0
- package/one/things/plans/dual-website-strategy.md +612 -0
- package/one/things/plans/feature-based-sites.md +821 -0
- package/one/things/plans/multi-ontology-architecture.md +836 -0
- package/one/things/plans/onboarding.md +32 -0
- package/one/things/plans/separate.md +15 -17
- package/one/things/plans/start-new.md +738 -0
- package/one/things/templates.md +254 -0
- package/one/things/todo.md +23 -5
- package/package.json +2 -2
- package/one/things/claude/hooks/agent-hook-manager.js +0 -525
- package/one/things/claude/hooks/agent-load-balancer.js +0 -271
- package/one/things/claude/hooks/agent-request-interceptor.js +0 -70
- package/one/things/claude/hooks/cascade-feedback.js +0 -297
- package/one/things/claude/hooks/cascade-integration-hooks.js +0 -648
- package/one/things/claude/hooks/continuous-improvement-monitor.js +0 -510
- package/one/things/claude/hooks/file-organization-engine.js +0 -427
- package/one/things/claude/hooks/file-organization-monitor.js +0 -269
- package/one/things/claude/hooks/hook-config-manager.js +0 -202
- package/one/things/claude/hooks/hook-orchestrator.js +0 -662
- package/one/things/claude/hooks/hook-performance-report.js +0 -120
- package/one/things/claude/hooks/mcp-cascade-integration.js +0 -816
- package/one/things/claude/hooks/memory-optimizer.js +0 -510
- package/one/things/claude/hooks/ontology-compliance.js +0 -394
- package/one/things/claude/hooks/ontology-hook-manager.js +0 -316
- package/one/things/claude/hooks/ontology-validation-engine.js +0 -317
- package/one/things/claude/hooks/performance-monitoring-hook.js +0 -422
- package/one/things/claude/hooks/quality-scoring-engine.js +0 -834
- package/one/things/claude/hooks/simple-load-balancer.js +0 -238
- package/one/things/claude/hooks/startup-optimizer.js +0 -625
- package/one/things/claude/hooks/story-scoring-system.js +0 -445
- package/one/things/claude/hooks/story-validation-engine.js +0 -473
- package/one/things/claude/hooks/structure-synchronizer.js +0 -194
- package/one/things/claude/hooks/sub-agent-output-validator.js +0 -647
- package/one/things/claude/hooks/sub-agent-validation-hook.js +0 -343
- package/one/things/claude/hooks/trinity-validation-system.js +0 -392
- package/one/things/plans/organizations-to-groups.md +0 -705
|
@@ -1,625 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Startup Optimizer Hook - ONE Framework
|
|
5
|
-
*
|
|
6
|
-
* Claude Code hook that automatically optimizes startup time by:
|
|
7
|
-
* 1. Integrating with the lazy loading system
|
|
8
|
-
* 2. Preloading critical paths based on user context
|
|
9
|
-
* 3. Optimizing module resolution and caching
|
|
10
|
-
* 4. Monitoring and reporting performance metrics
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { promises as fs } from 'fs';
|
|
14
|
-
import path from 'path';
|
|
15
|
-
import { fileURLToPath } from 'url';
|
|
16
|
-
|
|
17
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
-
const __dirname = path.dirname(__filename);
|
|
19
|
-
|
|
20
|
-
class StartupOptimizer {
|
|
21
|
-
constructor() {
|
|
22
|
-
this.LazyLoader = null; // Will be dynamically imported
|
|
23
|
-
this.loader = null;
|
|
24
|
-
this.hookStartTime = Date.now();
|
|
25
|
-
this.enabled = true;
|
|
26
|
-
this.performanceLog = [];
|
|
27
|
-
this.configPath = path.join(__dirname, '../../one/config/performance-config.yaml');
|
|
28
|
-
this.lastOptimization = null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Main hook entry point - called by Claude Code
|
|
33
|
-
*/
|
|
34
|
-
async onStartup(context = {}) {
|
|
35
|
-
if (!this.enabled) return;
|
|
36
|
-
|
|
37
|
-
console.log('ā” Startup Optimizer Hook activated');
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
// Initialize lazy loader
|
|
41
|
-
await this.initializeLazyLoader();
|
|
42
|
-
|
|
43
|
-
// Context-aware preloading
|
|
44
|
-
await this.contextAwarePreload(context);
|
|
45
|
-
|
|
46
|
-
// Module resolution optimization
|
|
47
|
-
await this.optimizeModuleResolution();
|
|
48
|
-
|
|
49
|
-
// Performance monitoring setup
|
|
50
|
-
this.setupPerformanceMonitoring();
|
|
51
|
-
|
|
52
|
-
const hookTime = Date.now() - this.hookStartTime;
|
|
53
|
-
console.log(`ā” Startup optimization completed in ${hookTime}ms`);
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
success: true,
|
|
57
|
-
optimizationTime: hookTime,
|
|
58
|
-
loader: this.loader
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
} catch (error) {
|
|
62
|
-
console.error('ā Startup optimization failed:', error);
|
|
63
|
-
return { success: false, error: error.message };
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Initialize the lazy loader system
|
|
69
|
-
*/
|
|
70
|
-
async initializeLazyLoader() {
|
|
71
|
-
try {
|
|
72
|
-
// Dynamic import to avoid circular dependencies
|
|
73
|
-
const { default: LazyLoader } = await import('../../.one/tools/lazy-loader.js');
|
|
74
|
-
this.LazyLoader = LazyLoader;
|
|
75
|
-
this.loader = new this.LazyLoader();
|
|
76
|
-
|
|
77
|
-
// Initialize with performance tracking
|
|
78
|
-
const initStart = Date.now();
|
|
79
|
-
await this.loader.initialize();
|
|
80
|
-
const initTime = Date.now() - initStart;
|
|
81
|
-
|
|
82
|
-
this.logPerformance('lazy_loader_init', initTime);
|
|
83
|
-
|
|
84
|
-
console.log(`ā
Lazy Loader initialized in ${initTime}ms`);
|
|
85
|
-
return true;
|
|
86
|
-
|
|
87
|
-
} catch (error) {
|
|
88
|
-
console.error('ā Failed to initialize Lazy Loader:', error);
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Context-aware preloading based on user's likely needs
|
|
95
|
-
*/
|
|
96
|
-
async contextAwarePreload(context) {
|
|
97
|
-
const preloadStart = Date.now();
|
|
98
|
-
|
|
99
|
-
// Determine user context and preload accordingly
|
|
100
|
-
const userContext = await this.analyzeUserContext(context);
|
|
101
|
-
const preloadPaths = this.getContextualPreloadPaths(userContext);
|
|
102
|
-
|
|
103
|
-
console.log(`šÆ Context: ${userContext.primary} - Preloading ${preloadPaths.length} files`);
|
|
104
|
-
|
|
105
|
-
// Preload contextual files
|
|
106
|
-
const preloadPromises = preloadPaths.map(async (filePath) => {
|
|
107
|
-
try {
|
|
108
|
-
if (this.loader) {
|
|
109
|
-
return await this.loader.getFile(filePath);
|
|
110
|
-
}
|
|
111
|
-
} catch (error) {
|
|
112
|
-
console.warn(`ā ļø Preload failed: ${filePath}`);
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
const results = await Promise.allSettled(preloadPromises);
|
|
118
|
-
const successful = results.filter(r => r.status === 'fulfilled' && r.value).length;
|
|
119
|
-
|
|
120
|
-
const preloadTime = Date.now() - preloadStart;
|
|
121
|
-
this.logPerformance('contextual_preload', preloadTime);
|
|
122
|
-
|
|
123
|
-
console.log(`ā
Preloaded ${successful}/${preloadPaths.length} contextual files in ${preloadTime}ms`);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Analyze user context to determine what to preload
|
|
128
|
-
*/
|
|
129
|
-
async analyzeUserContext(context) {
|
|
130
|
-
const userContext = {
|
|
131
|
-
primary: 'general',
|
|
132
|
-
secondary: [],
|
|
133
|
-
confidence: 0.5
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
// Check recent git activity
|
|
138
|
-
const gitContext = await this.analyzeGitContext();
|
|
139
|
-
|
|
140
|
-
// Check current directory contents
|
|
141
|
-
const dirContext = await this.analyzeDirectoryContext();
|
|
142
|
-
|
|
143
|
-
// Check Claude Code context if provided
|
|
144
|
-
const claudeContext = this.analyzeClaudeContext(context);
|
|
145
|
-
|
|
146
|
-
// Combine contexts with weights
|
|
147
|
-
const contexts = [
|
|
148
|
-
{ type: 'git', data: gitContext, weight: 0.4 },
|
|
149
|
-
{ type: 'directory', data: dirContext, weight: 0.3 },
|
|
150
|
-
{ type: 'claude', data: claudeContext, weight: 0.3 }
|
|
151
|
-
];
|
|
152
|
-
|
|
153
|
-
// Determine primary context
|
|
154
|
-
const contextScores = {};
|
|
155
|
-
for (const ctx of contexts) {
|
|
156
|
-
for (const [key, score] of Object.entries(ctx.data)) {
|
|
157
|
-
contextScores[key] = (contextScores[key] || 0) + (score * ctx.weight);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Get highest scoring context
|
|
162
|
-
const sortedContexts = Object.entries(contextScores)
|
|
163
|
-
.sort(([,a], [,b]) => b - a);
|
|
164
|
-
|
|
165
|
-
if (sortedContexts.length > 0) {
|
|
166
|
-
userContext.primary = sortedContexts[0][0];
|
|
167
|
-
userContext.confidence = sortedContexts[0][1];
|
|
168
|
-
userContext.secondary = sortedContexts.slice(1, 3).map(([key]) => key);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
} catch (error) {
|
|
172
|
-
console.warn('ā ļø Context analysis failed, using defaults');
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return userContext;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Analyze recent git activity for context clues
|
|
180
|
-
*/
|
|
181
|
-
async analyzeGitContext() {
|
|
182
|
-
const contexts = {};
|
|
183
|
-
|
|
184
|
-
try {
|
|
185
|
-
const { exec } = await import('child_process');
|
|
186
|
-
const { promisify } = await import('util');
|
|
187
|
-
const execAsync = promisify(exec);
|
|
188
|
-
|
|
189
|
-
// Get recent commit messages
|
|
190
|
-
const { stdout } = await execAsync('git log --oneline -10 2>/dev/null || echo ""');
|
|
191
|
-
const commits = stdout.toLowerCase();
|
|
192
|
-
|
|
193
|
-
// Score based on commit content
|
|
194
|
-
if (commits.includes('mission')) contexts.mission = 0.8;
|
|
195
|
-
if (commits.includes('story')) contexts.story = 0.7;
|
|
196
|
-
if (commits.includes('agent')) contexts.agent = 0.6;
|
|
197
|
-
if (commits.includes('task')) contexts.task = 0.5;
|
|
198
|
-
if (commits.includes('playbook')) contexts.playbook = 0.4;
|
|
199
|
-
if (commits.includes('optimization') || commits.includes('performance')) contexts.optimization = 0.9;
|
|
200
|
-
|
|
201
|
-
} catch (error) {
|
|
202
|
-
// Git not available or no commits
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return contexts;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Analyze current directory for context
|
|
210
|
-
*/
|
|
211
|
-
async analyzeDirectoryContext() {
|
|
212
|
-
const contexts = {};
|
|
213
|
-
|
|
214
|
-
try {
|
|
215
|
-
// Check for recent file activity
|
|
216
|
-
const recentFiles = await this.getRecentFiles();
|
|
217
|
-
|
|
218
|
-
for (const file of recentFiles) {
|
|
219
|
-
if (file.includes('/missions/')) contexts.mission = 0.7;
|
|
220
|
-
if (file.includes('/stories/')) contexts.story = 0.6;
|
|
221
|
-
if (file.includes('/agents/')) contexts.agent = 0.8;
|
|
222
|
-
if (file.includes('/playbooks/')) contexts.playbook = 0.5;
|
|
223
|
-
if (file.includes('/tasks/')) contexts.task = 0.4;
|
|
224
|
-
if (file.includes('performance') || file.includes('optimization')) contexts.optimization = 0.9;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
} catch (error) {
|
|
228
|
-
// Directory analysis failed
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
return contexts;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Analyze Claude Code context
|
|
236
|
-
*/
|
|
237
|
-
analyzeClaudeContext(context) {
|
|
238
|
-
const contexts = {};
|
|
239
|
-
|
|
240
|
-
if (context.command) {
|
|
241
|
-
const cmd = context.command.toLowerCase();
|
|
242
|
-
if (cmd.includes('mission')) contexts.mission = 0.9;
|
|
243
|
-
if (cmd.includes('story')) contexts.story = 0.8;
|
|
244
|
-
if (cmd.includes('agent')) contexts.agent = 0.7;
|
|
245
|
-
if (cmd.includes('task')) contexts.task = 0.6;
|
|
246
|
-
if (cmd.includes('one')) contexts.general = 0.5;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if (context.workingDirectory) {
|
|
250
|
-
const wd = context.workingDirectory.toLowerCase();
|
|
251
|
-
if (wd.includes('mission')) contexts.mission = 0.6;
|
|
252
|
-
if (wd.includes('story')) contexts.story = 0.5;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return contexts;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Get contextual files to preload based on user context
|
|
260
|
-
*/
|
|
261
|
-
getContextualPreloadPaths(userContext) {
|
|
262
|
-
const basePaths = [
|
|
263
|
-
'.claude/agents/mission-commander.md',
|
|
264
|
-
'.claude/commands/one.md',
|
|
265
|
-
'one/config/core-config.yaml'
|
|
266
|
-
];
|
|
267
|
-
|
|
268
|
-
const contextPaths = {
|
|
269
|
-
mission: [
|
|
270
|
-
'.claude/agents/mission-commander.md',
|
|
271
|
-
'.one/workflows/mission-workflow.yaml',
|
|
272
|
-
'.one/templates/mission-tmpl.yaml',
|
|
273
|
-
'one/missions/'
|
|
274
|
-
],
|
|
275
|
-
story: [
|
|
276
|
-
'.claude/agents/story-teller.md',
|
|
277
|
-
'.one/workflows/story-workflow.yaml',
|
|
278
|
-
'.one/templates/story-tmpl.yaml',
|
|
279
|
-
'one/stories/'
|
|
280
|
-
],
|
|
281
|
-
agent: [
|
|
282
|
-
'.claude/agents/',
|
|
283
|
-
'.claude/commands/',
|
|
284
|
-
'.one/workflows/agent-coordination.yaml'
|
|
285
|
-
],
|
|
286
|
-
task: [
|
|
287
|
-
'.claude/agents/task-master.md',
|
|
288
|
-
'.one/workflows/task-workflow.yaml',
|
|
289
|
-
'one/tasks/'
|
|
290
|
-
],
|
|
291
|
-
playbook: [
|
|
292
|
-
'one/playbooks/',
|
|
293
|
-
'.one/templates/playbook-tmpl.yaml'
|
|
294
|
-
],
|
|
295
|
-
optimization: [
|
|
296
|
-
'.one/tools/lazy-loader.js',
|
|
297
|
-
'one/config/performance-config.yaml',
|
|
298
|
-
'.claude/hooks/startup-optimizer.js'
|
|
299
|
-
]
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
let paths = [...basePaths];
|
|
303
|
-
|
|
304
|
-
// Add primary context paths
|
|
305
|
-
if (contextPaths[userContext.primary]) {
|
|
306
|
-
paths.push(...contextPaths[userContext.primary]);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// Add secondary context paths (with lower priority)
|
|
310
|
-
for (const secondary of userContext.secondary) {
|
|
311
|
-
if (contextPaths[secondary]) {
|
|
312
|
-
paths.push(...contextPaths[secondary].slice(0, 2)); // Only top 2
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// Remove duplicates and expand directories
|
|
317
|
-
return [...new Set(paths)];
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Optimize Node.js module resolution
|
|
322
|
-
*/
|
|
323
|
-
async optimizeModuleResolution() {
|
|
324
|
-
const optimizeStart = Date.now();
|
|
325
|
-
|
|
326
|
-
try {
|
|
327
|
-
// Cache commonly used modules
|
|
328
|
-
const commonModules = [
|
|
329
|
-
'fs', 'path', 'crypto', 'util', 'child_process',
|
|
330
|
-
'yaml', 'markdown-it', 'glob'
|
|
331
|
-
];
|
|
332
|
-
|
|
333
|
-
for (const moduleName of commonModules) {
|
|
334
|
-
try {
|
|
335
|
-
await import(moduleName);
|
|
336
|
-
} catch (error) {
|
|
337
|
-
// Module not available, skip
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Set up module cache optimization
|
|
342
|
-
await this.warmupRequireCache();
|
|
343
|
-
|
|
344
|
-
} catch (error) {
|
|
345
|
-
console.warn('ā ļø Module resolution optimization failed:', error.message);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
const optimizeTime = Date.now() - optimizeStart;
|
|
349
|
-
this.logPerformance('module_optimization', optimizeTime);
|
|
350
|
-
console.log(`ā” Module resolution optimized in ${optimizeTime}ms`);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Warm up Node.js require cache
|
|
355
|
-
*/
|
|
356
|
-
async warmupRequireCache() {
|
|
357
|
-
// Pre-cache essential internal modules
|
|
358
|
-
const essentialModules = [
|
|
359
|
-
'events', 'stream', 'url', 'querystring', 'os',
|
|
360
|
-
'assert', 'buffer', 'timers', 'process'
|
|
361
|
-
];
|
|
362
|
-
|
|
363
|
-
for (const mod of essentialModules) {
|
|
364
|
-
try {
|
|
365
|
-
await import(mod);
|
|
366
|
-
} catch (error) {
|
|
367
|
-
// Skip if not available
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Setup performance monitoring
|
|
374
|
-
*/
|
|
375
|
-
setupPerformanceMonitoring() {
|
|
376
|
-
// Monitor file access patterns
|
|
377
|
-
this.setupFileAccessMonitoring();
|
|
378
|
-
|
|
379
|
-
// Monitor memory usage
|
|
380
|
-
this.setupMemoryMonitoring();
|
|
381
|
-
|
|
382
|
-
// Monitor startup times
|
|
383
|
-
this.setupStartupTimeMonitoring();
|
|
384
|
-
|
|
385
|
-
console.log('š Performance monitoring active');
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* Monitor file access patterns for optimization
|
|
390
|
-
*/
|
|
391
|
-
setupFileAccessMonitoring() {
|
|
392
|
-
if (!this.loader) return;
|
|
393
|
-
|
|
394
|
-
// Override getFile to track access patterns
|
|
395
|
-
const originalGetFile = this.loader.getFile.bind(this.loader);
|
|
396
|
-
this.loader.getFile = async (filePath) => {
|
|
397
|
-
const start = Date.now();
|
|
398
|
-
try {
|
|
399
|
-
const result = await originalGetFile(filePath);
|
|
400
|
-
const accessTime = Date.now() - start;
|
|
401
|
-
this.logFileAccess(filePath, accessTime, true);
|
|
402
|
-
return result;
|
|
403
|
-
} catch (error) {
|
|
404
|
-
const accessTime = Date.now() - start;
|
|
405
|
-
this.logFileAccess(filePath, accessTime, false);
|
|
406
|
-
throw error;
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Monitor memory usage
|
|
413
|
-
*/
|
|
414
|
-
setupMemoryMonitoring() {
|
|
415
|
-
// Log memory usage periodically
|
|
416
|
-
setInterval(() => {
|
|
417
|
-
const usage = process.memoryUsage();
|
|
418
|
-
this.logPerformance('memory_usage', usage.heapUsed / 1024 / 1024); // MB
|
|
419
|
-
}, 30000); // Every 30 seconds
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* Monitor startup times
|
|
424
|
-
*/
|
|
425
|
-
setupStartupTimeMonitoring() {
|
|
426
|
-
const totalStartup = Date.now() - this.hookStartTime;
|
|
427
|
-
this.logPerformance('total_startup', totalStartup);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* Get recent files based on modification time
|
|
432
|
-
*/
|
|
433
|
-
async getRecentFiles(hours = 24) {
|
|
434
|
-
const cutoff = Date.now() - (hours * 60 * 60 * 1000);
|
|
435
|
-
const recentFiles = [];
|
|
436
|
-
|
|
437
|
-
try {
|
|
438
|
-
const directories = ['.claude', '.one', 'one'];
|
|
439
|
-
|
|
440
|
-
for (const dir of directories) {
|
|
441
|
-
try {
|
|
442
|
-
const files = await this.getFilesRecursive(dir);
|
|
443
|
-
for (const file of files) {
|
|
444
|
-
try {
|
|
445
|
-
const stats = await fs.stat(file);
|
|
446
|
-
if (stats.mtime.getTime() > cutoff) {
|
|
447
|
-
recentFiles.push(file);
|
|
448
|
-
}
|
|
449
|
-
} catch (error) {
|
|
450
|
-
// Skip files we can't stat
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
} catch (error) {
|
|
454
|
-
// Skip directories we can't read
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
} catch (error) {
|
|
458
|
-
console.warn('ā ļø Could not analyze recent files');
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
return recentFiles;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* Get all files in a directory recursively
|
|
466
|
-
*/
|
|
467
|
-
async getFilesRecursive(dir) {
|
|
468
|
-
const files = [];
|
|
469
|
-
|
|
470
|
-
try {
|
|
471
|
-
const items = await fs.readdir(dir, { withFileTypes: true });
|
|
472
|
-
|
|
473
|
-
for (const item of items) {
|
|
474
|
-
const fullPath = path.join(dir, item.name);
|
|
475
|
-
|
|
476
|
-
if (item.isDirectory() && !item.name.startsWith('.git')) {
|
|
477
|
-
const subFiles = await this.getFilesRecursive(fullPath);
|
|
478
|
-
files.push(...subFiles);
|
|
479
|
-
} else if (item.isFile() && item.name.endsWith('.md')) {
|
|
480
|
-
files.push(fullPath);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
} catch (error) {
|
|
484
|
-
// Directory not accessible
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
return files;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* Performance logging
|
|
492
|
-
*/
|
|
493
|
-
logPerformance(metric, value, metadata = {}) {
|
|
494
|
-
const entry = {
|
|
495
|
-
timestamp: Date.now(),
|
|
496
|
-
metric,
|
|
497
|
-
value,
|
|
498
|
-
metadata
|
|
499
|
-
};
|
|
500
|
-
|
|
501
|
-
this.performanceLog.push(entry);
|
|
502
|
-
|
|
503
|
-
// Keep only last 1000 entries to prevent memory bloat
|
|
504
|
-
if (this.performanceLog.length > 1000) {
|
|
505
|
-
this.performanceLog = this.performanceLog.slice(-1000);
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
/**
|
|
510
|
-
* Log file access for optimization analysis
|
|
511
|
-
*/
|
|
512
|
-
logFileAccess(filePath, accessTime, success) {
|
|
513
|
-
this.logPerformance('file_access', accessTime, {
|
|
514
|
-
filePath,
|
|
515
|
-
success,
|
|
516
|
-
fileType: this.getFileType(filePath)
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
* Get file type for categorization
|
|
522
|
-
*/
|
|
523
|
-
getFileType(filePath) {
|
|
524
|
-
if (filePath.includes('/.claude/agents/')) return 'agent';
|
|
525
|
-
if (filePath.includes('/.claude/commands/')) return 'command';
|
|
526
|
-
if (filePath.includes('/.one/workflows/')) return 'workflow';
|
|
527
|
-
if (filePath.includes('/one/missions/')) return 'mission';
|
|
528
|
-
if (filePath.includes('/one/stories/')) return 'story';
|
|
529
|
-
return 'other';
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* Get performance statistics
|
|
534
|
-
*/
|
|
535
|
-
getPerformanceStats() {
|
|
536
|
-
if (this.performanceLog.length === 0) return {};
|
|
537
|
-
|
|
538
|
-
const stats = {};
|
|
539
|
-
const metrics = [...new Set(this.performanceLog.map(entry => entry.metric))];
|
|
540
|
-
|
|
541
|
-
for (const metric of metrics) {
|
|
542
|
-
const entries = this.performanceLog.filter(entry => entry.metric === metric);
|
|
543
|
-
const values = entries.map(entry => entry.value);
|
|
544
|
-
|
|
545
|
-
stats[metric] = {
|
|
546
|
-
count: values.length,
|
|
547
|
-
avg: values.reduce((sum, val) => sum + val, 0) / values.length,
|
|
548
|
-
min: Math.min(...values),
|
|
549
|
-
max: Math.max(...values),
|
|
550
|
-
latest: entries[entries.length - 1]?.value
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
return stats;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* Generate optimization report
|
|
559
|
-
*/
|
|
560
|
-
generateOptimizationReport() {
|
|
561
|
-
const stats = this.getPerformanceStats();
|
|
562
|
-
const loaderStats = this.loader ? this.loader.getStats() : {};
|
|
563
|
-
|
|
564
|
-
return {
|
|
565
|
-
timestamp: new Date().toISOString(),
|
|
566
|
-
uptime: Date.now() - this.hookStartTime,
|
|
567
|
-
performance: stats,
|
|
568
|
-
loader: loaderStats,
|
|
569
|
-
optimization: {
|
|
570
|
-
enabled: this.enabled,
|
|
571
|
-
lastRun: this.lastOptimization
|
|
572
|
-
}
|
|
573
|
-
};
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* Hook lifecycle methods
|
|
578
|
-
*/
|
|
579
|
-
async onShutdown() {
|
|
580
|
-
console.log('ā” Startup Optimizer shutting down...');
|
|
581
|
-
|
|
582
|
-
// Save performance data
|
|
583
|
-
await this.savePerformanceData();
|
|
584
|
-
|
|
585
|
-
// Clear caches
|
|
586
|
-
if (this.loader) {
|
|
587
|
-
this.loader.clearCache();
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Save performance data for analysis
|
|
593
|
-
*/
|
|
594
|
-
async savePerformanceData() {
|
|
595
|
-
try {
|
|
596
|
-
const report = this.generateOptimizationReport();
|
|
597
|
-
const reportPath = path.join(__dirname, '../../one/cache/performance-report.json');
|
|
598
|
-
|
|
599
|
-
await fs.mkdir(path.dirname(reportPath), { recursive: true });
|
|
600
|
-
await fs.writeFile(reportPath, JSON.stringify(report, null, 2));
|
|
601
|
-
|
|
602
|
-
console.log(`š Performance report saved: ${reportPath}`);
|
|
603
|
-
} catch (error) {
|
|
604
|
-
console.warn('ā ļø Could not save performance data:', error.message);
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
// Export for Claude Code integration
|
|
610
|
-
export default StartupOptimizer;
|
|
611
|
-
|
|
612
|
-
// CLI usage for testing
|
|
613
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
614
|
-
const optimizer = new StartupOptimizer();
|
|
615
|
-
|
|
616
|
-
optimizer.onStartup().then(result => {
|
|
617
|
-
if (result.success) {
|
|
618
|
-
console.log('\nš Startup Optimization Report:');
|
|
619
|
-
console.log(JSON.stringify(optimizer.generateOptimizationReport(), null, 2));
|
|
620
|
-
} else {
|
|
621
|
-
console.error('ā Optimization failed:', result.error);
|
|
622
|
-
process.exit(1);
|
|
623
|
-
}
|
|
624
|
-
});
|
|
625
|
-
}
|