@stackmemoryai/stackmemory 1.10.5 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +131 -64
- package/README.md +107 -24
- package/bin/claude-sm +16 -1
- package/bin/claude-smd +16 -1
- package/bin/codex-smd +16 -1
- package/bin/gemini-sm +16 -1
- package/bin/hermes-sm +21 -0
- package/bin/hermes-smd +21 -0
- package/bin/opencode-sm +16 -1
- package/dist/src/cli/claude-sm.js +266 -84
- package/dist/src/cli/codex-sm.js +225 -33
- package/dist/src/cli/commands/bench.js +209 -2
- package/dist/src/cli/commands/brain.js +206 -0
- package/dist/src/cli/commands/cache.js +126 -0
- package/dist/src/cli/commands/company-os.js +184 -0
- package/dist/src/cli/commands/context.js +5 -0
- package/dist/src/cli/commands/daemon.js +41 -0
- package/dist/src/cli/commands/handoff.js +40 -9
- package/dist/src/cli/commands/onboard.js +70 -3
- package/dist/src/cli/commands/operator.js +127 -0
- package/dist/src/cli/commands/optimize.js +117 -0
- package/dist/src/cli/commands/orchestrate.js +232 -5
- package/dist/src/cli/commands/orchestrator.js +315 -26
- package/dist/src/cli/commands/pack.js +322 -0
- package/dist/src/cli/commands/patterns.js +254 -0
- package/dist/src/cli/commands/portal.js +161 -0
- package/dist/src/cli/commands/scaffold.js +92 -0
- package/dist/src/cli/commands/search.js +40 -1
- package/dist/src/cli/commands/setup.js +178 -11
- package/dist/src/cli/commands/skills.js +10 -1
- package/dist/src/cli/commands/state.js +265 -0
- package/dist/src/cli/commands/sync.js +253 -0
- package/dist/src/cli/commands/tasks.js +130 -1
- package/dist/src/cli/commands/vision.js +221 -0
- package/dist/src/cli/gemini-sm.js +19 -29
- package/dist/src/cli/hermes-sm.js +224 -0
- package/dist/src/cli/index.js +105 -39
- package/dist/src/cli/opencode-sm.js +38 -21
- package/dist/src/cli/utils/determinism-watcher.js +66 -0
- package/dist/src/cli/utils/real-cli-bin.js +116 -0
- package/dist/src/core/brain/brain-store.js +187 -0
- package/dist/src/core/brain/brain-sync.js +193 -0
- package/dist/src/core/brain/index.js +78 -0
- package/dist/src/core/brain/types.js +10 -0
- package/dist/src/core/cache/content-cache.js +238 -0
- package/dist/src/{integrations/diffmem → core/cache}/index.js +5 -5
- package/dist/src/core/cache/token-estimator.js +39 -0
- package/dist/src/core/config/feature-flags.js +2 -6
- package/dist/src/core/context/frame-database.js +79 -27
- package/dist/src/core/context/recursive-context-manager.js +1 -1
- package/dist/src/core/context/rehydration.js +2 -1
- package/dist/src/core/cross-search/cross-project-search.js +269 -0
- package/dist/src/core/cross-search/index.js +10 -0
- package/dist/src/core/database/sqlite-adapter.js +14 -84
- package/dist/src/core/extensions/provider-adapter.js +5 -0
- package/dist/src/core/models/model-router.js +54 -2
- package/dist/src/core/models/provider-pricing.js +58 -4
- package/dist/src/core/monitoring/logger.js +2 -1
- package/dist/src/core/optimization/trace-optimizer.js +413 -0
- package/dist/src/core/patterns/index.js +22 -0
- package/dist/src/core/patterns/pattern-applier.js +39 -0
- package/dist/src/core/patterns/pattern-observer.js +157 -0
- package/dist/src/core/patterns/pattern-store.js +259 -0
- package/dist/src/core/patterns/types.js +19 -0
- package/dist/src/core/provenance/confidence-scorer.js +128 -0
- package/dist/src/core/provenance/index.js +40 -0
- package/dist/src/core/provenance/provenance-store.js +194 -0
- package/dist/src/core/provenance/types.js +82 -0
- package/dist/src/core/retrieval/llm-context-retrieval.js +5 -4
- package/dist/src/core/retrieval/unified-context-assembler.js +11 -66
- package/dist/src/core/session/project-handoff.js +64 -0
- package/dist/src/core/session/session-manager.js +28 -0
- package/dist/src/core/shared-state/canonical-store.js +564 -0
- package/dist/src/core/skill-packs/index.js +18 -0
- package/dist/src/core/skill-packs/parser.js +42 -0
- package/dist/src/core/skill-packs/registry.js +224 -0
- package/dist/src/core/skill-packs/types.js +79 -0
- package/dist/src/core/storage/cloud-sync-manager.js +116 -0
- package/dist/src/core/storage/cloud-sync.js +574 -0
- package/dist/src/core/storage/two-tier-storage.js +5 -1
- package/dist/src/core/tasks/master-tasks-template.js +43 -0
- package/dist/src/core/tasks/md-task-parser.js +138 -0
- package/dist/src/core/trace/trace-event-store.js +282 -0
- package/dist/src/core/vision/index.js +27 -0
- package/dist/src/core/vision/signals.js +79 -0
- package/dist/src/core/vision/types.js +22 -0
- package/dist/src/core/vision/vision-file.js +146 -0
- package/dist/src/core/vision/vision-loop.js +220 -0
- package/dist/src/core/wiki/wiki-compiler.js +103 -1
- package/dist/src/daemon/daemon-config.js +52 -0
- package/dist/src/daemon/services/desire-path-service.js +566 -0
- package/dist/src/daemon/services/github-service.js +126 -0
- package/dist/src/daemon/services/research-stream-service.js +320 -0
- package/dist/src/daemon/services/telemetry-service.js +192 -0
- package/dist/src/daemon/unified-daemon.js +58 -1
- package/dist/src/features/browser/cli-browser-agent.js +417 -0
- package/dist/src/features/browser/stagehand-workflows.js +578 -0
- package/dist/src/features/operator/adapter-factory.js +62 -0
- package/dist/src/features/operator/browser-adapter.js +109 -0
- package/dist/src/features/operator/desktop-adapter.js +125 -0
- package/dist/src/features/operator/index.js +39 -0
- package/dist/src/features/operator/llm-decision.js +137 -0
- package/dist/src/features/operator/operator-logger.js +92 -0
- package/dist/src/features/operator/overnight-runner.js +327 -0
- package/dist/src/features/operator/screen-adapter.js +91 -0
- package/dist/src/features/operator/session-manager.js +127 -0
- package/dist/src/features/operator/state-machine.js +227 -0
- package/dist/src/features/operator/task-queue.js +81 -0
- package/dist/src/features/portal/index.js +26 -0
- package/dist/src/features/portal/server.js +240 -0
- package/dist/src/features/portal/types.js +14 -0
- package/dist/src/features/portal/ui.js +195 -0
- package/dist/src/features/sweep/pty-wrapper.js +13 -5
- package/dist/src/features/tasks/task-aware-context.js +2 -1
- package/dist/src/features/tui/simple-monitor.js +0 -23
- package/dist/src/features/tui/swarm-monitor.js +8 -66
- package/dist/src/features/web/client/hooks/use-socket.js +12 -0
- package/dist/src/{core/merge/index.js → features/web/client/lib/utils.js} +8 -4
- package/dist/src/features/web/client/next-env.d.js +4 -0
- package/dist/src/features/web/client/stores/session-store.js +12 -0
- package/dist/src/features/web/server/gcp-billing.js +76 -0
- package/dist/src/features/web/server/index.js +10 -0
- package/dist/src/features/web/server/spend-calculator.js +228 -0
- package/dist/src/hooks/schemas.js +6 -1
- package/dist/src/integrations/anthropic/client.js +3 -2
- package/dist/src/integrations/claude-code/agent-bridge.js +0 -3
- package/dist/src/integrations/claude-code/subagent-client.js +307 -11
- package/dist/src/integrations/claude-code/task-coordinator.js +2 -1
- package/dist/src/integrations/github/pr-state.js +158 -0
- package/dist/src/integrations/linear/client.js +4 -1
- package/dist/src/integrations/linear/webhook-retry.js +196 -0
- package/dist/src/integrations/linear/webhook-server.js +18 -22
- package/dist/src/integrations/mcp/handlers/cloud-sync-handlers.js +101 -0
- package/dist/src/integrations/mcp/handlers/index.js +40 -84
- package/dist/src/integrations/mcp/server.js +542 -641
- package/dist/src/integrations/mcp/tool-alias-registry.js +297 -0
- package/dist/src/integrations/mcp/tool-definitions.js +152 -682
- package/dist/src/mcp/stackmemory-mcp-server.js +571 -231
- package/dist/src/orchestrators/multimodal/determinism.js +244 -0
- package/dist/src/orchestrators/multimodal/harness.js +149 -78
- package/dist/src/orchestrators/multimodal/providers.js +44 -3
- package/dist/src/skills/recursive-agent-orchestrator.js +2 -4
- package/dist/src/utils/hook-installer.js +0 -8
- package/dist/src/utils/process-cleanup.js +1 -7
- package/docs/README.md +42 -0
- package/docs/guides/README_INSTALL.md +208 -0
- package/package.json +27 -9
- package/packs/coding/python-fastapi/instructions.md +60 -0
- package/packs/coding/python-fastapi/pack.yaml +28 -0
- package/packs/coding/typescript-react/instructions.md +47 -0
- package/packs/coding/typescript-react/pack.yaml +28 -0
- package/packs/core/commands/capture.md +32 -0
- package/packs/core/commands/learn.md +73 -0
- package/packs/core/commands/next.md +36 -0
- package/packs/core/commands/restart.md +58 -0
- package/packs/core/commands/restore.md +29 -0
- package/packs/core/commands/start.md +57 -0
- package/packs/core/commands/stop.md +65 -0
- package/packs/core/commands/summary.md +40 -0
- package/packs/core/manifest.json +24 -0
- package/packs/ops/decision-recovery/instructions.md +65 -0
- package/packs/ops/decision-recovery/pack.yaml +89 -0
- package/scripts/claude-code-wrapper.sh +11 -0
- package/scripts/claude-sm-setup.sh +12 -1
- package/scripts/codex-wrapper.sh +11 -0
- package/scripts/git-hooks/branch-context-manager.sh +11 -0
- package/scripts/git-hooks/post-checkout-stackmemory.sh +11 -0
- package/scripts/git-hooks/post-commit-stackmemory.sh +11 -0
- package/scripts/git-hooks/pre-commit-stackmemory.sh +11 -0
- package/scripts/hooks/cleanup-shell.sh +12 -1
- package/scripts/hooks/task-complete.sh +12 -1
- package/scripts/install-code-execution-hooks.sh +12 -1
- package/scripts/install-sweep-hook.sh +12 -0
- package/scripts/install.sh +11 -0
- package/scripts/opencode-wrapper.sh +11 -0
- package/scripts/portal/cloud-init.yaml +69 -0
- package/scripts/portal/setup.sh +69 -0
- package/scripts/portal/stackmemory-portal.service +34 -0
- package/scripts/setup-claude-integration.sh +12 -1
- package/scripts/smoke-init-db.sh +23 -0
- package/scripts/stackmemory-daemon.sh +11 -0
- package/scripts/verify-dist.cjs +11 -4
- package/dist/src/cli/commands/ralph.js +0 -1053
- package/dist/src/cli/commands/team.js +0 -168
- package/dist/src/core/context/shared-context-layer.js +0 -620
- package/dist/src/core/context/stack-merge-resolver.js +0 -748
- package/dist/src/core/merge/conflict-detector.js +0 -430
- package/dist/src/core/merge/resolution-engine.js +0 -557
- package/dist/src/core/merge/stack-diff.js +0 -531
- package/dist/src/core/merge/unified-merge-resolver.js +0 -302
- package/dist/src/hooks/diffmem-hooks.js +0 -376
- package/dist/src/integrations/diffmem/client.js +0 -208
- package/dist/src/integrations/diffmem/config.js +0 -14
- package/dist/src/integrations/greptile/client.js +0 -101
- package/dist/src/integrations/greptile/config.js +0 -14
- package/dist/src/integrations/greptile/index.js +0 -11
- package/dist/src/integrations/mcp/handlers/cord-handlers.js +0 -397
- package/dist/src/integrations/mcp/handlers/diffmem-handlers.js +0 -455
- package/dist/src/integrations/mcp/handlers/greptile-handlers.js +0 -456
- package/dist/src/integrations/mcp/handlers/provider-handlers.js +0 -227
- package/dist/src/integrations/mcp/handlers/team-handlers.js +0 -211
- package/dist/src/integrations/ralph/bridge/ralph-stackmemory-bridge.js +0 -863
- package/dist/src/integrations/ralph/context/context-budget-manager.js +0 -308
- package/dist/src/integrations/ralph/context/stackmemory-context-loader.js +0 -391
- package/dist/src/integrations/ralph/index.js +0 -17
- package/dist/src/integrations/ralph/learning/pattern-learner.js +0 -435
- package/dist/src/integrations/ralph/lifecycle/iteration-lifecycle.js +0 -448
- package/dist/src/integrations/ralph/loopmax.js +0 -488
- package/dist/src/integrations/ralph/monitoring/swarm-dashboard.js +0 -293
- package/dist/src/integrations/ralph/monitoring/swarm-registry.js +0 -107
- package/dist/src/integrations/ralph/orchestration/multi-loop-orchestrator.js +0 -508
- package/dist/src/integrations/ralph/patterns/compounding-engineering-pattern.js +0 -407
- package/dist/src/integrations/ralph/patterns/extended-coherence-sessions.js +0 -495
- package/dist/src/integrations/ralph/patterns/oracle-worker-pattern.js +0 -387
- package/dist/src/integrations/ralph/performance/performance-optimizer.js +0 -357
- package/dist/src/integrations/ralph/recovery/crash-recovery.js +0 -461
- package/dist/src/integrations/ralph/state/state-reconciler.js +0 -420
- package/dist/src/integrations/ralph/swarm/git-workflow-manager.js +0 -444
- package/dist/src/integrations/ralph/swarm/swarm-coordinator.js +0 -1007
- package/dist/src/integrations/ralph/visualization/ralph-debugger.js +0 -635
- package/scripts/ralph-loop-implementation.js +0 -404
- /package/dist/src/core/{merge → cache}/types.js +0 -0
- /package/dist/src/{integrations/diffmem/types.js → core/storage/cloud-sync-types.js} +0 -0
- /package/dist/src/{integrations/greptile/types.js → core/trace/trace-event.js} +0 -0
- /package/dist/src/{integrations/ralph → features/operator}/types.js +0 -0
|
@@ -1,407 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
2
|
-
import { dirname as __pathDirname } from 'path';
|
|
3
|
-
const __filename = __fileURLToPath(import.meta.url);
|
|
4
|
-
const __dirname = __pathDirname(__filename);
|
|
5
|
-
import * as fs from "fs/promises";
|
|
6
|
-
import * as path from "path";
|
|
7
|
-
import { v4 as uuidv4 } from "uuid";
|
|
8
|
-
import { logger } from "../../../core/monitoring/logger.js";
|
|
9
|
-
class CompoundingEngineeringManager {
|
|
10
|
-
knowledgeBase;
|
|
11
|
-
baseDir;
|
|
12
|
-
projectId;
|
|
13
|
-
constructor(baseDir = "./.compounding", projectId) {
|
|
14
|
-
this.baseDir = baseDir;
|
|
15
|
-
this.projectId = projectId || "default";
|
|
16
|
-
this.knowledgeBase = {
|
|
17
|
-
totalFeatures: 0,
|
|
18
|
-
learningsByCategory: {
|
|
19
|
-
planning: [],
|
|
20
|
-
implementation: [],
|
|
21
|
-
testing: [],
|
|
22
|
-
deployment: []
|
|
23
|
-
},
|
|
24
|
-
bestPractices: [],
|
|
25
|
-
automatedHooks: [],
|
|
26
|
-
specializedAgents: [],
|
|
27
|
-
customCommands: [],
|
|
28
|
-
metrics: {
|
|
29
|
-
developmentVelocityTrend: [],
|
|
30
|
-
errorRateReduction: 0,
|
|
31
|
-
codeReuseIncrease: 0,
|
|
32
|
-
onboardingTimeReduction: 0
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Initialize the compounding system
|
|
38
|
-
*/
|
|
39
|
-
async initialize() {
|
|
40
|
-
await fs.mkdir(this.baseDir, { recursive: true });
|
|
41
|
-
await this.loadExistingKnowledge();
|
|
42
|
-
logger.info("Compounding Engineering Manager initialized", {
|
|
43
|
-
totalFeatures: this.knowledgeBase.totalFeatures,
|
|
44
|
-
baseDir: this.baseDir
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Capture learning from a feature development session
|
|
49
|
-
*/
|
|
50
|
-
async captureFeatureLearning(featureName, sessionData, agentOutputs, userFeedback) {
|
|
51
|
-
const learningId = uuidv4();
|
|
52
|
-
logger.info("Capturing feature learning", {
|
|
53
|
-
featureName,
|
|
54
|
-
learningId,
|
|
55
|
-
agentCount: agentOutputs.length
|
|
56
|
-
});
|
|
57
|
-
const learning = await this.extractLearningsFromSession(
|
|
58
|
-
learningId,
|
|
59
|
-
featureName,
|
|
60
|
-
sessionData,
|
|
61
|
-
agentOutputs,
|
|
62
|
-
userFeedback
|
|
63
|
-
);
|
|
64
|
-
await this.storeLearning(learning);
|
|
65
|
-
await this.updateCompoundedKnowledge(learning);
|
|
66
|
-
await this.generateArtifacts();
|
|
67
|
-
return learningId;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Extract actionable learnings from development session
|
|
71
|
-
*/
|
|
72
|
-
async extractLearningsFromSession(id, featureName, sessionData, agentOutputs, _userFeedback) {
|
|
73
|
-
const successes = this.identifySuccesses(sessionData, agentOutputs);
|
|
74
|
-
const failures = this.identifyFailures(sessionData, agentOutputs);
|
|
75
|
-
const patterns = this.extractPatterns(sessionData, agentOutputs);
|
|
76
|
-
const agentLearnings = this.analyzeAgentBehavior(agentOutputs);
|
|
77
|
-
const automationOpportunities = this.identifyAutomationOpportunities(
|
|
78
|
-
sessionData,
|
|
79
|
-
agentOutputs
|
|
80
|
-
);
|
|
81
|
-
return {
|
|
82
|
-
id,
|
|
83
|
-
featureName,
|
|
84
|
-
timestamp: Date.now(),
|
|
85
|
-
developmentPhase: this.inferDevelopmentPhase(sessionData),
|
|
86
|
-
successes,
|
|
87
|
-
failures,
|
|
88
|
-
patterns,
|
|
89
|
-
agentLearnings,
|
|
90
|
-
automationOpportunities
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Identify what worked well in the session
|
|
95
|
-
*/
|
|
96
|
-
identifySuccesses(sessionData, agentOutputs) {
|
|
97
|
-
const successes = [];
|
|
98
|
-
for (const output of agentOutputs) {
|
|
99
|
-
if (output.success && output.strategy) {
|
|
100
|
-
successes.push({
|
|
101
|
-
strategy: output.strategy,
|
|
102
|
-
impact: this.assessImpact(output),
|
|
103
|
-
reusability: this.assessReusability(output),
|
|
104
|
-
description: output.description || "Successful agent execution"
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (sessionData.codePatterns) {
|
|
109
|
-
for (const pattern of sessionData.codePatterns) {
|
|
110
|
-
if (pattern.successful) {
|
|
111
|
-
successes.push({
|
|
112
|
-
strategy: `Code pattern: ${pattern.name}`,
|
|
113
|
-
impact: "high",
|
|
114
|
-
reusability: "universal",
|
|
115
|
-
description: pattern.description
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return successes;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Identify failures and their resolutions
|
|
124
|
-
*/
|
|
125
|
-
identifyFailures(sessionData, agentOutputs) {
|
|
126
|
-
const failures = [];
|
|
127
|
-
for (const output of agentOutputs) {
|
|
128
|
-
if (output.errors && output.errors.length > 0) {
|
|
129
|
-
for (const error of output.errors) {
|
|
130
|
-
failures.push({
|
|
131
|
-
issue: error.message || "Agent execution failed",
|
|
132
|
-
cause: error.cause || "Unknown cause",
|
|
133
|
-
solution: error.resolution || "Manual intervention required",
|
|
134
|
-
prevention: this.generatePreventionStrategy(error)
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if (sessionData.buildErrors) {
|
|
140
|
-
for (const error of sessionData.buildErrors) {
|
|
141
|
-
failures.push({
|
|
142
|
-
issue: `Build error: ${error.type}`,
|
|
143
|
-
cause: error.details,
|
|
144
|
-
solution: error.fix,
|
|
145
|
-
prevention: "Add pre-build validation hook"
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return failures;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Extract reusable patterns from the session
|
|
153
|
-
*/
|
|
154
|
-
extractPatterns(sessionData, agentOutputs) {
|
|
155
|
-
const patterns = [];
|
|
156
|
-
if (agentOutputs.length > 1) {
|
|
157
|
-
const coordinationPattern = this.analyzeCoordinationPattern(agentOutputs);
|
|
158
|
-
if (coordinationPattern) {
|
|
159
|
-
patterns.push(coordinationPattern);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
if (sessionData.codeStructure) {
|
|
163
|
-
const structurePattern = this.analyzeCodeStructurePattern(
|
|
164
|
-
sessionData.codeStructure
|
|
165
|
-
);
|
|
166
|
-
if (structurePattern) {
|
|
167
|
-
patterns.push(structurePattern);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return patterns;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Analyze agent behavior for improvements
|
|
174
|
-
*/
|
|
175
|
-
analyzeAgentBehavior(agentOutputs) {
|
|
176
|
-
const commonMistakes = [];
|
|
177
|
-
const effectivePrompts = [];
|
|
178
|
-
const toolUsagePatterns = [];
|
|
179
|
-
const coordinationInsights = [];
|
|
180
|
-
for (const output of agentOutputs) {
|
|
181
|
-
if (output.retries && output.retries.length > 0) {
|
|
182
|
-
commonMistakes.push(...output.retries.map((r) => r.reason));
|
|
183
|
-
}
|
|
184
|
-
if (output.success && output.promptUsed) {
|
|
185
|
-
effectivePrompts.push(output.promptUsed);
|
|
186
|
-
}
|
|
187
|
-
if (output.toolsUsed) {
|
|
188
|
-
toolUsagePatterns.push(...output.toolsUsed);
|
|
189
|
-
}
|
|
190
|
-
if (output.coordination) {
|
|
191
|
-
coordinationInsights.push(output.coordination.insight);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return {
|
|
195
|
-
commonMistakes: [...new Set(commonMistakes)],
|
|
196
|
-
effectivePrompts: [...new Set(effectivePrompts)],
|
|
197
|
-
toolUsagePatterns: [...new Set(toolUsagePatterns)],
|
|
198
|
-
coordinationInsights: [...new Set(coordinationInsights)]
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Identify tasks that can be automated
|
|
203
|
-
*/
|
|
204
|
-
identifyAutomationOpportunities(sessionData, agentOutputs) {
|
|
205
|
-
const opportunities = [];
|
|
206
|
-
const taskFrequency = this.analyzeTaskFrequency(agentOutputs);
|
|
207
|
-
for (const [task, frequency] of Object.entries(taskFrequency)) {
|
|
208
|
-
if (frequency > 2) {
|
|
209
|
-
opportunities.push({
|
|
210
|
-
task,
|
|
211
|
-
frequency: "often",
|
|
212
|
-
complexity: "simple",
|
|
213
|
-
implementation: "hook"
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
if (sessionData.manualSteps) {
|
|
218
|
-
for (const step of sessionData.manualSteps) {
|
|
219
|
-
opportunities.push({
|
|
220
|
-
task: step.description,
|
|
221
|
-
frequency: "sometimes",
|
|
222
|
-
complexity: step.complexity || "simple",
|
|
223
|
-
implementation: "command"
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return opportunities;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Update compounded knowledge with new learning
|
|
231
|
-
*/
|
|
232
|
-
async updateCompoundedKnowledge(learning) {
|
|
233
|
-
this.knowledgeBase.learningsByCategory[learning.developmentPhase].push(
|
|
234
|
-
learning
|
|
235
|
-
);
|
|
236
|
-
this.knowledgeBase.totalFeatures++;
|
|
237
|
-
await this.updateBestPractices(learning);
|
|
238
|
-
await this.updateMetrics(learning);
|
|
239
|
-
await this.saveKnowledge();
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Generate artifacts (hooks, commands, agents) from accumulated learnings
|
|
243
|
-
*/
|
|
244
|
-
async generateArtifacts() {
|
|
245
|
-
await this.generateHooks();
|
|
246
|
-
await this.generateSpecializedAgents();
|
|
247
|
-
await this.generateCustomCommands();
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Generate automation hooks
|
|
251
|
-
*/
|
|
252
|
-
async generateHooks() {
|
|
253
|
-
const allOpportunities = Object.values(
|
|
254
|
-
this.knowledgeBase.learningsByCategory
|
|
255
|
-
).flat().flatMap((learning) => learning.automationOpportunities).filter((opp) => opp.implementation === "hook");
|
|
256
|
-
const hookCounts = /* @__PURE__ */ new Map();
|
|
257
|
-
for (const opp of allOpportunities) {
|
|
258
|
-
hookCounts.set(opp.task, (hookCounts.get(opp.task) || 0) + 1);
|
|
259
|
-
}
|
|
260
|
-
for (const [task, count] of hookCounts) {
|
|
261
|
-
if (count >= 3 && !this.knowledgeBase.automatedHooks.includes(task)) {
|
|
262
|
-
await this.createHook(task);
|
|
263
|
-
this.knowledgeBase.automatedHooks.push(task);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Create an automation hook
|
|
269
|
-
*/
|
|
270
|
-
async createHook(task) {
|
|
271
|
-
const hookName = task.replace(/\s+/g, "-").toLowerCase();
|
|
272
|
-
const hookPath = path.join(this.baseDir, "hooks", `${hookName}.ts`);
|
|
273
|
-
await fs.mkdir(path.dirname(hookPath), { recursive: true });
|
|
274
|
-
const hookContent = `
|
|
275
|
-
/**
|
|
276
|
-
* Auto-generated hook for: ${task}
|
|
277
|
-
* Generated by Compounding Engineering Pattern
|
|
278
|
-
*/
|
|
279
|
-
|
|
280
|
-
export async function ${hookName.replace(/-/g, "")}Hook() {
|
|
281
|
-
// TODO: Implement automation for: ${task}
|
|
282
|
-
console.log('Executing automated hook: ${task}');
|
|
283
|
-
}
|
|
284
|
-
`;
|
|
285
|
-
await fs.writeFile(hookPath, hookContent);
|
|
286
|
-
logger.info("Generated automation hook", { task, hookPath });
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Load existing knowledge base
|
|
290
|
-
*/
|
|
291
|
-
async loadExistingKnowledge() {
|
|
292
|
-
const knowledgePath = path.join(this.baseDir, "knowledge.json");
|
|
293
|
-
try {
|
|
294
|
-
const content = await fs.readFile(knowledgePath, "utf-8");
|
|
295
|
-
this.knowledgeBase = JSON.parse(content);
|
|
296
|
-
} catch {
|
|
297
|
-
logger.info("Starting fresh knowledge base");
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Save knowledge base to disk
|
|
302
|
-
*/
|
|
303
|
-
async saveKnowledge() {
|
|
304
|
-
const knowledgePath = path.join(this.baseDir, "knowledge.json");
|
|
305
|
-
await fs.writeFile(
|
|
306
|
-
knowledgePath,
|
|
307
|
-
JSON.stringify(this.knowledgeBase, null, 2)
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Get current compounding metrics
|
|
312
|
-
*/
|
|
313
|
-
getCompoundingMetrics() {
|
|
314
|
-
const totalLearnings = Object.values(
|
|
315
|
-
this.knowledgeBase.learningsByCategory
|
|
316
|
-
).flat().length;
|
|
317
|
-
const automationLevel = this.knowledgeBase.automatedHooks.length / Math.max(totalLearnings, 1);
|
|
318
|
-
const recentLearnings = totalLearnings > 5 ? totalLearnings / 5 : totalLearnings;
|
|
319
|
-
return {
|
|
320
|
-
totalFeatures: this.knowledgeBase.totalFeatures,
|
|
321
|
-
automationLevel,
|
|
322
|
-
learningVelocity: recentLearnings,
|
|
323
|
-
knowledgeReuse: this.knowledgeBase.bestPractices.length
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
// Helper methods
|
|
327
|
-
assessImpact(output) {
|
|
328
|
-
if (output.linesChanged > 100) return "high";
|
|
329
|
-
if (output.linesChanged > 20) return "medium";
|
|
330
|
-
return "low";
|
|
331
|
-
}
|
|
332
|
-
assessReusability(output) {
|
|
333
|
-
if (output.pattern === "generic") return "universal";
|
|
334
|
-
if (output.domain) return "domain_specific";
|
|
335
|
-
return "feature_specific";
|
|
336
|
-
}
|
|
337
|
-
generatePreventionStrategy(error) {
|
|
338
|
-
return `Add validation for: ${error.type || "unknown error type"}`;
|
|
339
|
-
}
|
|
340
|
-
inferDevelopmentPhase(sessionData) {
|
|
341
|
-
if (sessionData.phase) return sessionData.phase;
|
|
342
|
-
if (sessionData.testsRun) return "testing";
|
|
343
|
-
if (sessionData.codeGenerated) return "implementation";
|
|
344
|
-
return "planning";
|
|
345
|
-
}
|
|
346
|
-
analyzeCoordinationPattern(agentOutputs) {
|
|
347
|
-
return {
|
|
348
|
-
name: "Multi-agent coordination",
|
|
349
|
-
context: `${agentOutputs.length} agents worked together`,
|
|
350
|
-
solution: "Successful multi-agent coordination pattern",
|
|
351
|
-
examples: agentOutputs.map((a) => a.role || "unknown")
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
analyzeCodeStructurePattern(structure) {
|
|
355
|
-
return {
|
|
356
|
-
name: "Code structure pattern",
|
|
357
|
-
context: structure.type,
|
|
358
|
-
solution: structure.pattern,
|
|
359
|
-
examples: structure.examples || []
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
analyzeTaskFrequency(agentOutputs) {
|
|
363
|
-
const frequency = {};
|
|
364
|
-
for (const output of agentOutputs) {
|
|
365
|
-
if (output.task) {
|
|
366
|
-
frequency[output.task] = (frequency[output.task] || 0) + 1;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
return frequency;
|
|
370
|
-
}
|
|
371
|
-
async updateBestPractices(learning) {
|
|
372
|
-
for (const success of learning.successes) {
|
|
373
|
-
if (success.impact === "high" && success.reusability === "universal") {
|
|
374
|
-
const existing = this.knowledgeBase.bestPractices.find(
|
|
375
|
-
(bp) => bp.practice === success.strategy
|
|
376
|
-
);
|
|
377
|
-
if (existing) {
|
|
378
|
-
existing.evidence.push(learning.featureName);
|
|
379
|
-
existing.confidence = Math.min(existing.confidence + 0.1, 1);
|
|
380
|
-
} else {
|
|
381
|
-
this.knowledgeBase.bestPractices.push({
|
|
382
|
-
category: learning.developmentPhase,
|
|
383
|
-
practice: success.strategy,
|
|
384
|
-
evidence: [learning.featureName],
|
|
385
|
-
confidence: 0.7
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
async updateMetrics(learning) {
|
|
392
|
-
const velocityScore = learning.successes.length - learning.failures.length;
|
|
393
|
-
this.knowledgeBase.metrics.developmentVelocityTrend.push(velocityScore);
|
|
394
|
-
if (this.knowledgeBase.metrics.developmentVelocityTrend.length > 10) {
|
|
395
|
-
this.knowledgeBase.metrics.developmentVelocityTrend.shift();
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
async generateSpecializedAgents() {
|
|
399
|
-
}
|
|
400
|
-
async generateCustomCommands() {
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
var compounding_engineering_pattern_default = CompoundingEngineeringManager;
|
|
404
|
-
export {
|
|
405
|
-
CompoundingEngineeringManager,
|
|
406
|
-
compounding_engineering_pattern_default as default
|
|
407
|
-
};
|