strray-ai 1.7.2 โ 1.7.5
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/.opencode/hooks/post-commit +152 -55
- package/.opencode/hooks/post-commit.backup +110 -174
- package/.opencode/hooks/post-push +47 -64
- package/.opencode/hooks/post-push.backup +34 -38
- package/.opencode/strray/features.json +3 -3
- package/.opencode/strray/routing-mappings.json +90 -34
- package/AGENTS.md +7 -2
- package/dist/analytics/anonymization-engine.d.ts +108 -0
- package/dist/analytics/anonymization-engine.d.ts.map +1 -0
- package/dist/analytics/anonymization-engine.js +352 -0
- package/dist/analytics/anonymization-engine.js.map +1 -0
- package/dist/analytics/consent-manager.d.ts +94 -0
- package/dist/analytics/consent-manager.d.ts.map +1 -0
- package/dist/analytics/consent-manager.js +257 -0
- package/dist/analytics/consent-manager.js.map +1 -0
- package/dist/analytics/emerging-pattern-detector.d.ts +68 -0
- package/dist/analytics/emerging-pattern-detector.d.ts.map +1 -0
- package/dist/analytics/emerging-pattern-detector.js +250 -0
- package/dist/analytics/emerging-pattern-detector.js.map +1 -0
- package/dist/analytics/pattern-learning-engine.d.ts +81 -0
- package/dist/analytics/pattern-learning-engine.d.ts.map +1 -0
- package/dist/analytics/pattern-learning-engine.js +262 -0
- package/dist/analytics/pattern-learning-engine.js.map +1 -0
- package/dist/analytics/pattern-performance-tracker.d.ts +89 -0
- package/dist/analytics/pattern-performance-tracker.d.ts.map +1 -0
- package/dist/analytics/pattern-performance-tracker.js +289 -0
- package/dist/analytics/pattern-performance-tracker.js.map +1 -0
- package/dist/analytics/prompt-pattern-analyzer.d.ts +100 -0
- package/dist/analytics/prompt-pattern-analyzer.d.ts.map +1 -0
- package/dist/analytics/prompt-pattern-analyzer.js +372 -0
- package/dist/analytics/prompt-pattern-analyzer.js.map +1 -0
- package/dist/analytics/routing-performance-analyzer.d.ts +102 -0
- package/dist/analytics/routing-performance-analyzer.d.ts.map +1 -0
- package/dist/analytics/routing-performance-analyzer.js +342 -0
- package/dist/analytics/routing-performance-analyzer.js.map +1 -0
- package/dist/analytics/routing-refiner.d.ts +105 -0
- package/dist/analytics/routing-refiner.d.ts.map +1 -0
- package/dist/analytics/routing-refiner.js +381 -0
- package/dist/analytics/routing-refiner.js.map +1 -0
- package/dist/cli/commands/analytics-disable.d.ts +10 -0
- package/dist/cli/commands/analytics-disable.d.ts.map +1 -0
- package/dist/cli/commands/analytics-disable.js +73 -0
- package/dist/cli/commands/analytics-disable.js.map +1 -0
- package/dist/cli/commands/analytics-enable-action.d.ts +9 -0
- package/dist/cli/commands/analytics-enable-action.d.ts.map +1 -0
- package/dist/cli/commands/analytics-enable-action.js +83 -0
- package/dist/cli/commands/analytics-enable-action.js.map +1 -0
- package/dist/cli/commands/analytics-preview.d.ts +10 -0
- package/dist/cli/commands/analytics-preview.d.ts.map +1 -0
- package/dist/cli/commands/analytics-preview.js +107 -0
- package/dist/cli/commands/analytics-preview.js.map +1 -0
- package/dist/cli/commands/analytics-status.d.ts +10 -0
- package/dist/cli/commands/analytics-status.d.ts.map +1 -0
- package/dist/cli/commands/analytics-status.js +68 -0
- package/dist/cli/commands/analytics-status.js.map +1 -0
- package/dist/cli/index.js +6 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/core/adaptive-kernel.d.ts +110 -0
- package/dist/core/adaptive-kernel.d.ts.map +1 -0
- package/dist/core/adaptive-kernel.js +193 -0
- package/dist/core/adaptive-kernel.js.map +1 -0
- package/dist/core/kernel-patterns.d.ts +105 -0
- package/dist/core/kernel-patterns.d.ts.map +1 -0
- package/dist/core/kernel-patterns.js +328 -0
- package/dist/core/kernel-patterns.js.map +1 -0
- package/dist/core/orchestrator.d.ts +1 -0
- package/dist/core/orchestrator.d.ts.map +1 -1
- package/dist/core/orchestrator.js +40 -11
- package/dist/core/orchestrator.js.map +1 -1
- package/dist/delegation/agent-delegator.d.ts +11 -0
- package/dist/delegation/agent-delegator.d.ts.map +1 -1
- package/dist/delegation/agent-delegator.js +91 -16
- package/dist/delegation/agent-delegator.js.map +1 -1
- package/dist/delegation/task-skill-router.d.ts +269 -5
- package/dist/delegation/task-skill-router.d.ts.map +1 -1
- package/dist/delegation/task-skill-router.js +810 -23
- package/dist/delegation/task-skill-router.js.map +1 -1
- package/dist/postprocessor/PostProcessor.d.ts +10 -0
- package/dist/postprocessor/PostProcessor.d.ts.map +1 -1
- package/dist/postprocessor/PostProcessor.js +87 -17
- package/dist/postprocessor/PostProcessor.js.map +1 -1
- package/dist/processors/agents-md-validation-processor.d.ts +1 -0
- package/dist/processors/agents-md-validation-processor.d.ts.map +1 -1
- package/dist/processors/agents-md-validation-processor.js +34 -12
- package/dist/processors/agents-md-validation-processor.js.map +1 -1
- package/dist/processors/processor-manager.d.ts +12 -5
- package/dist/processors/processor-manager.d.ts.map +1 -1
- package/dist/processors/processor-manager.js +105 -10
- package/dist/processors/processor-manager.js.map +1 -1
- package/dist/processors/processor-types.d.ts +25 -8
- package/dist/processors/processor-types.d.ts.map +1 -1
- package/dist/processors/processor-types.js +2 -1
- package/dist/processors/processor-types.js.map +1 -1
- package/dist/processors/test-auto-creation-processor.d.ts.map +1 -1
- package/dist/processors/test-auto-creation-processor.js +52 -38
- package/dist/processors/test-auto-creation-processor.js.map +1 -1
- package/dist/scripts/analytics/daily-routing-analysis.d.ts +18 -0
- package/dist/scripts/analytics/daily-routing-analysis.d.ts.map +1 -0
- package/dist/scripts/analytics/daily-routing-analysis.js +268 -0
- package/dist/scripts/analytics/daily-routing-analysis.js.map +1 -0
- package/dist/scripts/analytics/index.d.ts +15 -0
- package/dist/scripts/analytics/index.d.ts.map +1 -0
- package/dist/scripts/analytics/index.js +17 -0
- package/dist/scripts/analytics/index.js.map +1 -0
- package/dist/scripts/test-p9.d.ts +15 -0
- package/dist/scripts/test-p9.d.ts.map +1 -0
- package/dist/scripts/test-p9.js +220 -0
- package/dist/scripts/test-p9.js.map +1 -0
- package/package.json +6 -2
- package/scripts/node/kernel-e2e-test.mjs +168 -0
- package/scripts/node/kernel-framework-test.mjs +127 -0
- package/scripts/node/kernel-live-test.mjs +147 -0
- package/scripts/node/kernel-real-framework-test.mjs +103 -0
- package/scripts/node/kernel-update.cjs +379 -0
- package/scripts/node/reflection-check.sh +245 -27
- package/scripts/node/test-simple-names-comprehensive.mjs +221 -0
- package/scripts/node/test-simple-names.mjs +39 -0
- package/dist/agents/documentation-writer.d.ts +0 -9
- package/dist/agents/documentation-writer.d.ts.map +0 -1
- package/dist/agents/documentation-writer.js +0 -85
- package/dist/agents/documentation-writer.js.map +0 -1
- package/dist/agents/explore.d.ts +0 -8
- package/dist/agents/explore.d.ts.map +0 -1
- package/dist/agents/explore.js +0 -55
- package/dist/agents/explore.js.map +0 -1
- package/dist/agents/librarian.d.ts +0 -3
- package/dist/agents/librarian.d.ts.map +0 -1
- package/dist/agents/librarian.js +0 -84
- package/dist/agents/librarian.js.map +0 -1
- package/dist/agents/marketing-expert.d.ts +0 -9
- package/dist/agents/marketing-expert.d.ts.map +0 -1
- package/dist/agents/marketing-expert.js +0 -112
- package/dist/agents/marketing-expert.js.map +0 -1
- package/dist/agents/oracle.d.ts +0 -8
- package/dist/agents/oracle.d.ts.map +0 -1
- package/dist/agents/oracle.js +0 -51
- package/dist/agents/oracle.js.map +0 -1
- package/dist/agents/seo-copywriter.d.ts +0 -10
- package/dist/agents/seo-copywriter.d.ts.map +0 -1
- package/dist/agents/seo-copywriter.js +0 -73
- package/dist/agents/seo-copywriter.js.map +0 -1
- package/dist/agents/seo-specialist.d.ts +0 -9
- package/dist/agents/seo-specialist.d.ts.map +0 -1
- package/dist/agents/seo-specialist.js +0 -54
- package/dist/agents/seo-specialist.js.map +0 -1
- package/dist/agents/test-architect.d.ts +0 -3
- package/dist/agents/test-architect.d.ts.map +0 -1
- package/dist/agents/test-architect.js +0 -96
- package/dist/agents/test-architect.js.map +0 -1
- package/dist/mcps/enhanced-orchestrator.server.d.ts +0 -14
- package/dist/mcps/enhanced-orchestrator.server.d.ts.map +0 -1
- package/dist/mcps/enhanced-orchestrator.server.js +0 -266
- package/dist/mcps/enhanced-orchestrator.server.js.map +0 -1
- package/dist/mcps/knowledge-skills/analyzer.server.d.ts +0 -7
- package/dist/mcps/knowledge-skills/analyzer.server.d.ts.map +0 -1
- package/dist/mcps/knowledge-skills/analyzer.server.js +0 -282
- package/dist/mcps/knowledge-skills/analyzer.server.js.map +0 -1
- package/dist/mcps/knowledge-skills/documentation-generation.server.d.ts +0 -48
- package/dist/mcps/knowledge-skills/documentation-generation.server.d.ts.map +0 -1
- package/dist/mcps/knowledge-skills/documentation-generation.server.js +0 -1238
- package/dist/mcps/knowledge-skills/documentation-generation.server.js.map +0 -1
- package/dist/mcps/knowledge-skills/explore.server.d.ts +0 -21
- package/dist/mcps/knowledge-skills/explore.server.d.ts.map +0 -1
- package/dist/mcps/knowledge-skills/explore.server.js +0 -582
- package/dist/mcps/knowledge-skills/explore.server.js.map +0 -1
- package/dist/mcps/knowledge-skills/marketing-expert.server.d.ts +0 -8
- package/dist/mcps/knowledge-skills/marketing-expert.server.d.ts.map +0 -1
- package/dist/mcps/knowledge-skills/marketing-expert.server.js +0 -356
- package/dist/mcps/knowledge-skills/marketing-expert.server.js.map +0 -1
- package/dist/mcps/knowledge-skills/oracle.server.d.ts +0 -25
- package/dist/mcps/knowledge-skills/oracle.server.d.ts.map +0 -1
- package/dist/mcps/knowledge-skills/oracle.server.js +0 -569
- package/dist/mcps/knowledge-skills/oracle.server.js.map +0 -1
- package/dist/mcps/knowledge-skills/seo-copywriter.server.d.ts +0 -8
- package/dist/mcps/knowledge-skills/seo-copywriter.server.d.ts.map +0 -1
- package/dist/mcps/knowledge-skills/seo-copywriter.server.js +0 -251
- package/dist/mcps/knowledge-skills/seo-copywriter.server.js.map +0 -1
- package/dist/mcps/knowledge-skills/seo-specialist.server.d.ts +0 -8
- package/dist/mcps/knowledge-skills/seo-specialist.server.d.ts.map +0 -1
- package/dist/mcps/knowledge-skills/seo-specialist.server.js +0 -211
- package/dist/mcps/knowledge-skills/seo-specialist.server.js.map +0 -1
- package/dist/mcps/librarian.server.d.ts +0 -17
- package/dist/mcps/librarian.server.d.ts.map +0 -1
- package/dist/mcps/librarian.server.js +0 -382
- package/dist/mcps/librarian.server.js.map +0 -1
- package/dist/optimization/performance-optimizer.d.ts +0 -179
- package/dist/optimization/performance-optimizer.d.ts.map +0 -1
- package/dist/optimization/performance-optimizer.js +0 -556
- package/dist/optimization/performance-optimizer.js.map +0 -1
- package/dist/utils/memory-pool.d.ts +0 -90
- package/dist/utils/memory-pool.d.ts.map +0 -1
- package/dist/utils/memory-pool.js +0 -245
- package/dist/utils/memory-pool.js.map +0 -1
|
@@ -1,75 +1,172 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
#
|
|
3
|
-
# Automatically triggers post-processor after commit
|
|
4
|
-
# Suggests reflection writing for significant changes
|
|
5
|
-
|
|
6
|
-
set -e
|
|
2
|
+
# StringRay Post-Processor post-commit Hook
|
|
3
|
+
# Automatically triggers post-processor after post-commit
|
|
7
4
|
|
|
5
|
+
# Get hook type from script name
|
|
8
6
|
HOOK_NAME=$(basename "$0")
|
|
9
|
-
COMMIT_SHA
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
COMMIT_SHA=""
|
|
8
|
+
|
|
9
|
+
if [ "$HOOK_NAME" = "post-commit" ]; then
|
|
10
|
+
# Light monitoring for local commits - just basic validation
|
|
11
|
+
COMMIT_SHA=$(git rev-parse HEAD)
|
|
12
|
+
MONITORING_LEVEL="basic"
|
|
13
|
+
elif [ "$HOOK_NAME" = "post-push" ]; then
|
|
14
|
+
# Full monitoring for pushes - comprehensive validation
|
|
15
|
+
# For push hooks, we need to parse the pushed refs from stdin
|
|
16
|
+
while read local_ref local_sha remote_ref remote_sha; do
|
|
17
|
+
if [ "$local_sha" != "0000000000000000000000000000000000000000" ]; then
|
|
18
|
+
COMMIT_SHA=$local_sha
|
|
19
|
+
break
|
|
20
|
+
fi
|
|
21
|
+
done
|
|
22
|
+
MONITORING_LEVEL="full"
|
|
23
|
+
else
|
|
24
|
+
COMMIT_SHA=$(git rev-parse HEAD)
|
|
25
|
+
MONITORING_LEVEL="basic"
|
|
26
|
+
fi
|
|
12
27
|
|
|
13
28
|
if [ -z "$COMMIT_SHA" ]; then
|
|
29
|
+
echo "Warning: Could not determine commit SHA for post-processor"
|
|
14
30
|
exit 0
|
|
15
31
|
fi
|
|
16
32
|
|
|
17
|
-
# Get
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
COMMIT_MSG=$(git log -1 --pretty=format:'%s')
|
|
33
|
+
# Get repository info
|
|
34
|
+
REPO="strray-framework/stringray" # Placeholder for now
|
|
35
|
+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
36
|
+
AUTHOR=$(git log -1 --pretty=format:'%an <%ae>')
|
|
22
37
|
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
echo " Consider writing a reflection using the template at docs/reflections/TEMPLATE.md"
|
|
29
|
-
echo ""
|
|
38
|
+
# Get changed files (different logic for commit vs push)
|
|
39
|
+
if [ "$HOOK_NAME" = "post-commit" ]; then
|
|
40
|
+
FILES=$(git diff --name-only HEAD~1 2>/dev/null || git diff --name-only --cached)
|
|
41
|
+
else
|
|
42
|
+
FILES=$(git log --name-only --oneline -1 $COMMIT_SHA | tail -n +2)
|
|
30
43
|
fi
|
|
31
44
|
|
|
32
|
-
#
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
for pkg in "strray-ai" "strray-framework"; do
|
|
36
|
-
if [ -d "node_modules/$pkg/dist" ]; then
|
|
37
|
-
STRRAY_PATH="node_modules/$pkg"
|
|
38
|
-
break
|
|
39
|
-
fi
|
|
40
|
-
done
|
|
45
|
+
# Trigger post-processor asynchronously (don't block git operations)
|
|
46
|
+
(
|
|
47
|
+
cd "$(dirname "$0")/../.." # Navigate to project root
|
|
41
48
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if [ -d "
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
# Find the StringRay plugin in node_modules or current project (development)
|
|
50
|
+
STRRAY_PLUGIN=""
|
|
51
|
+
if [ -d "node_modules/strray-framework" ]; then
|
|
52
|
+
STRRAY_PLUGIN="node_modules/strray-framework"
|
|
53
|
+
elif [ -d "node_modules/@strray/strray-framework" ]; then
|
|
54
|
+
STRRAY_PLUGIN="node_modules/@strray/strray-framework"
|
|
55
|
+
elif [ -d "node_modules/OpenCode/plugins/strray-framework" ]; then
|
|
56
|
+
STRRAY_PLUGIN="node_modules/OpenCode/plugins/strray-framework"
|
|
57
|
+
elif [ -f "dist/postprocessor/PostProcessor.js" ]; then
|
|
58
|
+
# Development mode - use current project
|
|
59
|
+
STRRAY_PLUGIN="."
|
|
48
60
|
fi
|
|
49
|
-
fi
|
|
50
61
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
if command -v node >/dev/null 2>&1 && [ -n "$STRRAY_PLUGIN" ]; then
|
|
63
|
+
# Call a separate script to avoid bash variable issues
|
|
64
|
+
export COMMIT_SHA="$COMMIT_SHA"
|
|
65
|
+
export REPO="$REPO"
|
|
66
|
+
export BRANCH="$BRANCH"
|
|
67
|
+
export AUTHOR="$AUTHOR"
|
|
68
|
+
export STRRAY_PLUGIN="$STRRAY_PLUGIN"
|
|
69
|
+
export MONITORING_LEVEL="$MONITORING_LEVEL"
|
|
70
|
+
export IS_FULL_MONITORING="$([ "$MONITORING_LEVEL" = "full" ] && echo "true" || echo "false")"
|
|
71
|
+
|
|
72
|
+
# Run appropriate monitoring based on hook type
|
|
73
|
+
if [ "$HOOK_NAME" = "post-commit" ]; then
|
|
74
|
+
# LIGHT MONITORING: Quick validation, don't block git workflow
|
|
75
|
+
# Timeout: 2 seconds max, log metrics for monitoring
|
|
76
|
+
START_TIME=$(date +%s)
|
|
77
|
+
timeout 2 node -e "
|
|
78
|
+
(async () => {
|
|
79
|
+
try {
|
|
80
|
+
// Use import resolver to avoid hardcoded dist paths
|
|
81
|
+
const { importResolver } = await import('./utils/import-resolver.js');
|
|
82
|
+
const { LightweightValidator } = await importResolver.importModule('postprocessor/validation/LightweightValidator');
|
|
83
|
+
|
|
84
|
+
const validator = new LightweightValidator();
|
|
85
|
+
const result = await validator.validate();
|
|
86
|
+
|
|
87
|
+
if (result.warnings.length > 0) {
|
|
88
|
+
await frameworkLogger.log('-git-hook-trigger', '-result-warnings-length-warning-s-found-', 'info', { message: 'โ ๏ธ ' + result.warnings.length + ' warning(s) found:' });
|
|
89
|
+
result.warnings.forEach(w => await frameworkLogger.log('-git-hook-trigger', '-w-', 'info', { message: ' ' + w) });
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!result.passed) {
|
|
93
|
+
await frameworkLogger.log('-git-hook-trigger', '-result-errors-length-error-s-found-', 'error', { message: 'โ ' + result.errors.length + ' error(s) found:' });
|
|
94
|
+
result.errors.forEach(e => await frameworkLogger.log('-git-hook-trigger', '-e-', 'info', { message: ' ' + e) });
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
55
97
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
98
|
+
await frameworkLogger.log('-git-hook-trigger', '-post-commit-validation-passed-in-result-duration-', 'success', { message: 'โ
Post-commit: Validation passed in ' + result.duration + 'ms' });
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.error('โ Post-commit validation failed:', error instanceof Error ? error.message : String(error));
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
})();
|
|
104
|
+
" 2>/dev/null
|
|
105
|
+
EXIT_CODE=$?
|
|
106
|
+
END_TIME=$(date +%s)
|
|
107
|
+
DURATION=$((END_TIME - START_TIME))
|
|
60
108
|
|
|
61
|
-
|
|
109
|
+
# Log metrics for monitoring (convert to milliseconds)
|
|
110
|
+
DURATION_MS=$((DURATION * 1000))
|
|
111
|
+
# LOG CLEANUP: Remove old log files after validation
|
|
112
|
+
# Use relative path from CWD - works in both dev and consumer
|
|
113
|
+
node -e "
|
|
114
|
+
(async () => {
|
|
115
|
+
try {
|
|
116
|
+
// Use dynamic import that works in both dev and consumer
|
|
117
|
+
const basePath = process.env.STRRAY_BASE_PATH || '.';
|
|
118
|
+
const { cleanupLogFiles } = await import(basePath + '/dist/postprocessor/triggers/GitHookTrigger.js');
|
|
119
|
+
const result = await cleanupLogFiles({
|
|
120
|
+
maxAgeHours: 24,
|
|
121
|
+
excludePatterns: ['logs/framework/activity.log', 'logs/agents/refactoring-log.md', 'current-session.log'],
|
|
122
|
+
directories: ['logs/'],
|
|
123
|
+
enabled: true
|
|
124
|
+
});
|
|
125
|
+
if (result.cleaned > 0) {
|
|
126
|
+
await frameworkLogger.log('-git-hook-trigger', '-cleaned-result-cleaned-old-log-files-', 'info', { message: `๐งน Cleaned ${result.cleaned} old log files` });
|
|
127
|
+
}
|
|
128
|
+
if (result.errors.length > 0) {
|
|
129
|
+
console.error('Log cleanup errors:', result.errors);
|
|
130
|
+
}
|
|
131
|
+
} catch (error) {
|
|
132
|
+
console.error('Log cleanup failed:', error.message);
|
|
133
|
+
}
|
|
134
|
+
})();
|
|
135
|
+
"
|
|
62
136
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
trigger: 'git-hook'
|
|
70
|
-
});
|
|
137
|
+
echo "HOOK_METRICS: post-commit duration=${DURATION_MS}ms exit_code=${EXIT_CODE}" >&2
|
|
138
|
+
collector.recordMetrics('post-commit', ${DURATION_MS}, ${EXIT_CODE});
|
|
139
|
+
" 2>/dev/null
|
|
140
|
+
EXIT_CODE=$?
|
|
141
|
+
END_TIME=$(date +%s)
|
|
142
|
+
DURATION=$((END_TIME - START_TIME))
|
|
71
143
|
|
|
72
|
-
|
|
73
|
-
|
|
144
|
+
# Log comprehensive metrics for monitoring (convert to milliseconds)
|
|
145
|
+
DURATION_MS=$((DURATION * 1000))
|
|
146
|
+
echo "HOOK_METRICS: post-push duration=${DURATION_MS}ms exit_code=${EXIT_CODE}" >&2
|
|
147
|
+
|
|
148
|
+
# Record metrics using metrics collector (direct import for reliability)
|
|
149
|
+
# Use environment variable for base path - works in both dev and consumer
|
|
150
|
+
node -e "
|
|
151
|
+
(async () => {
|
|
152
|
+
try {
|
|
153
|
+
const basePath = process.env.STRRAY_BASE_PATH || '.';
|
|
154
|
+
const distPath = process.env.STRRAY_DIST_PATH || 'dist';
|
|
155
|
+
const { HookMetricsCollector } = await import(basePath + '/' + distPath + '/postprocessor/validation/HookMetricsCollector.js');
|
|
156
|
+
const collector = new HookMetricsCollector();
|
|
157
|
+
collector.recordMetrics('post-push', ${DURATION_MS}, ${EXIT_CODE});
|
|
158
|
+
} catch (error) {
|
|
159
|
+
// Silently fail if metrics collection fails
|
|
160
|
+
}
|
|
161
|
+
})();
|
|
162
|
+
" 2>/dev/null || true
|
|
163
|
+
|
|
164
|
+
[ $EXIT_CODE -eq 0 ] && exit 0 || exit 1
|
|
165
|
+
fi
|
|
166
|
+
else
|
|
167
|
+
echo "Warning: StringRay plugin not found or Node.js not available, skipping post-processor"
|
|
168
|
+
fi
|
|
169
|
+
)
|
|
74
170
|
|
|
171
|
+
# Don't wait for background process
|
|
75
172
|
exit 0
|
|
@@ -1,193 +1,129 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
# StrRay Post-Processor post-commit Hook
|
|
3
|
-
# Automatically triggers post-processor after
|
|
3
|
+
# Automatically triggers post-processor after commit
|
|
4
|
+
# Suggests reflection writing for significant changes
|
|
5
|
+
|
|
6
|
+
set -e
|
|
4
7
|
|
|
5
|
-
# Get hook type from script name
|
|
6
8
|
HOOK_NAME=$(basename "$0")
|
|
7
|
-
COMMIT_SHA
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# Light monitoring for local commits - just basic validation
|
|
11
|
-
COMMIT_SHA=$(git rev-parse HEAD)
|
|
12
|
-
MONITORING_LEVEL="basic"
|
|
13
|
-
elif [ "$HOOK_NAME" = "post-push" ]; then
|
|
14
|
-
# Full monitoring for pushes - comprehensive validation
|
|
15
|
-
# For push hooks, we need to parse the pushed refs from stdin
|
|
16
|
-
while read local_ref local_sha remote_ref remote_sha; do
|
|
17
|
-
if [ "$local_sha" != "0000000000000000000000000000000000000000" ]; then
|
|
18
|
-
COMMIT_SHA=$local_sha
|
|
19
|
-
break
|
|
20
|
-
fi
|
|
21
|
-
done
|
|
22
|
-
MONITORING_LEVEL="full"
|
|
23
|
-
else
|
|
24
|
-
COMMIT_SHA=$(git rev-parse HEAD)
|
|
25
|
-
MONITORING_LEVEL="basic"
|
|
26
|
-
fi
|
|
9
|
+
COMMIT_SHA=$(git rev-parse HEAD)
|
|
10
|
+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
11
|
+
AUTHOR=$(git log -1 --pretty=format:'%an <%ae>')
|
|
27
12
|
|
|
28
13
|
if [ -z "$COMMIT_SHA" ]; then
|
|
29
|
-
echo "Warning: Could not determine commit SHA for post-processor"
|
|
30
14
|
exit 0
|
|
31
15
|
fi
|
|
32
16
|
|
|
33
|
-
# Get
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
# Get changed files
|
|
18
|
+
FILES=$(git diff --name-only HEAD~1 2>/dev/null || git diff --name-only --cached)
|
|
19
|
+
|
|
20
|
+
# Get commit message for reflection decision
|
|
21
|
+
COMMIT_MSG=$(git log -1 --pretty=format:'%s')
|
|
37
22
|
|
|
38
|
-
#
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
23
|
+
# Check if this commit warrants reflection
|
|
24
|
+
# (debugging, bug fixes, path issues, significant changes)
|
|
25
|
+
REFLECTION_TRIGGERS="debug|fix|bug|path|mcp|consumer|installation|reflection"
|
|
26
|
+
if echo "$COMMIT_MSG" | grep -qiE "$REFLECTION_TRIGGERS"; then
|
|
27
|
+
echo "๐ Reflection Suggestion: This commit appears to involve debugging, fixes, or significant changes."
|
|
28
|
+
echo " Consider writing a reflection using the template at docs/reflections/TEMPLATE.md"
|
|
29
|
+
echo ""
|
|
43
30
|
fi
|
|
44
31
|
|
|
45
|
-
#
|
|
46
|
-
(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
32
|
+
# Check for new reflection files and validate them
|
|
33
|
+
NEW_REFLECTIONS=$(git diff --name-only HEAD~1 2>/dev/null | grep "^docs/reflections/.*\.md$" | grep -v "TEMPLATE.md" || true)
|
|
34
|
+
if [ -n "$NEW_REFLECTIONS" ]; then
|
|
35
|
+
echo "๐ Validating new reflection files..."
|
|
36
|
+
for ref in $NEW_REFLECTIONS; do
|
|
37
|
+
if [ -f "$ref" ]; then
|
|
38
|
+
if bash scripts/node/reflection-check.sh "$ref" 2>/dev/null; then
|
|
39
|
+
echo " โ
$ref passes template validation"
|
|
40
|
+
else
|
|
41
|
+
echo " โ $ref FAILED template validation"
|
|
42
|
+
echo " ๐ Read the template: docs/reflections/TEMPLATE.md"
|
|
43
|
+
echo " โ ๏ธ Please fix the reflection to match the template before committing"
|
|
44
|
+
fi
|
|
45
|
+
fi
|
|
46
|
+
done
|
|
47
|
+
echo ""
|
|
48
|
+
fi
|
|
61
49
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const { LightweightValidator } = await importResolver.importModule('postprocessor/validation/LightweightValidator');
|
|
83
|
-
|
|
84
|
-
const validator = new LightweightValidator();
|
|
85
|
-
const result = await validator.validate();
|
|
86
|
-
|
|
87
|
-
if (result.warnings.length > 0) {
|
|
88
|
-
console.log('โ ๏ธ ' + result.warnings.length + ' warning(s) found:');
|
|
89
|
-
result.warnings.forEach(w => console.log(' ' + w));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (!result.passed) {
|
|
93
|
-
console.log('โ ' + result.errors.length + ' error(s) found:');
|
|
94
|
-
result.errors.forEach(e => console.log(' ' + e));
|
|
95
|
-
process.exit(1);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
console.log('โ
Post-commit: Validation passed in ' + result.duration + 'ms');
|
|
99
|
-
} catch (error) {
|
|
100
|
-
console.error('โ Post-commit validation failed:', error instanceof Error ? error.message : String(error));
|
|
101
|
-
process.exit(1);
|
|
102
|
-
}
|
|
103
|
-
})();
|
|
104
|
-
" 2>/dev/null
|
|
105
|
-
EXIT_CODE=$?
|
|
106
|
-
END_TIME=$(date +%s)
|
|
107
|
-
DURATION=$((END_TIME - START_TIME))
|
|
108
|
-
|
|
109
|
-
# Log metrics for monitoring (convert to milliseconds)
|
|
110
|
-
DURATION_MS=$((DURATION * 1000))
|
|
111
|
-
echo "HOOK_METRICS: post-commit duration=${DURATION_MS}ms exit_code=${EXIT_CODE}" >&2
|
|
112
|
-
|
|
113
|
-
# Record metrics using metrics collector (direct import for reliability)
|
|
114
|
-
node -e "
|
|
115
|
-
(async () => {
|
|
116
|
-
try {
|
|
117
|
-
const { HookMetricsCollector } = await import('./dist/postprocessor/validation/HookMetricsCollector.js');
|
|
118
|
-
const collector = new HookMetricsCollector();
|
|
119
|
-
collector.recordMetrics('post-commit', ${DURATION_MS}, ${EXIT_CODE});
|
|
120
|
-
} catch (error) {
|
|
121
|
-
// Silently fail if metrics collection fails
|
|
122
|
-
}
|
|
123
|
-
})();
|
|
124
|
-
" 2>/dev/null || true
|
|
125
|
-
|
|
126
|
-
[ $EXIT_CODE -eq 0 ] && exit 0 || exit 1
|
|
50
|
+
# Check if AGENTS.md was modified and validate it
|
|
51
|
+
AGENTS_MODIFIED=$(git diff --name-only HEAD~1 2>/dev/null | grep "^AGENTS.md$" || true)
|
|
52
|
+
if [ -n "$AGENTS_MODIFIED" ]; then
|
|
53
|
+
echo "๐ Validating AGENTS.md..."
|
|
54
|
+
if [ -f "AGENTS.md" ]; then
|
|
55
|
+
# Check required sections
|
|
56
|
+
ERRORS=0
|
|
57
|
+
for section in "## Available Agents" "## Complexity Routing" "## CLI Commands" "## Codex"; do
|
|
58
|
+
if grep -q "$section" AGENTS.md; then
|
|
59
|
+
echo " โ
Contains: $section"
|
|
60
|
+
else
|
|
61
|
+
echo " โ Missing: $section"
|
|
62
|
+
ERRORS=$((ERRORS + 1))
|
|
63
|
+
fi
|
|
64
|
+
done
|
|
65
|
+
|
|
66
|
+
# Check agent count
|
|
67
|
+
AGENT_COUNT=$(grep -o '@[a-z-]*' AGENTS.md | wc -l)
|
|
68
|
+
if [ "$AGENT_COUNT" -ge 15 ]; then
|
|
69
|
+
echo " โ
Agent count: $AGENT_COUNT (recommended: 20+)"
|
|
127
70
|
else
|
|
128
|
-
|
|
129
|
-
# Timeout: 5 minutes max, comprehensive CI/CD validation
|
|
130
|
-
START_TIME=$(date +%s)
|
|
131
|
-
timeout 300 node -e "
|
|
132
|
-
(async () => {
|
|
133
|
-
try {
|
|
134
|
-
console.log('๐ Post-push: Comprehensive validation initiated');
|
|
135
|
-
// Use import resolver for environment-aware imports
|
|
136
|
-
const { importResolver } = await import('./utils/import-resolver.js');
|
|
137
|
-
const { ComprehensiveValidator } = await importResolver.importModule('postprocessor/validation/ComprehensiveValidator');
|
|
138
|
-
|
|
139
|
-
const validator = new ComprehensiveValidator();
|
|
140
|
-
const result = await validator.validate();
|
|
141
|
-
|
|
142
|
-
if (result.warnings.length > 0) {
|
|
143
|
-
console.log('โ ๏ธ ' + result.warnings.length + ' warning(s) found:');
|
|
144
|
-
result.warnings.forEach(w => console.log(' ' + w));
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (!result.passed) {
|
|
148
|
-
console.log('โ ' + result.errors.length + ' error(s) found:');
|
|
149
|
-
result.errors.forEach(e => console.log(' ' + e));
|
|
150
|
-
process.exit(1);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (result.testResults) {
|
|
154
|
-
console.log('๐งช Tests: ' + result.testResults.passed + '/' + result.testResults.total + ' passed');
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
console.log('โ
Post-push: Comprehensive validation passed in ' + result.duration + 'ms');
|
|
158
|
-
} catch (error) {
|
|
159
|
-
console.error('โ Post-push validation failed:', error instanceof Error ? error.message : String(error));
|
|
160
|
-
process.exit(1);
|
|
161
|
-
}
|
|
162
|
-
})();
|
|
163
|
-
" 2>/dev/null
|
|
164
|
-
EXIT_CODE=$?
|
|
165
|
-
END_TIME=$(date +%s)
|
|
166
|
-
DURATION=$((END_TIME - START_TIME))
|
|
167
|
-
|
|
168
|
-
# Log comprehensive metrics for monitoring (convert to milliseconds)
|
|
169
|
-
DURATION_MS=$((DURATION * 1000))
|
|
170
|
-
echo "HOOK_METRICS: post-push duration=${DURATION_MS}ms exit_code=${EXIT_CODE}" >&2
|
|
171
|
-
|
|
172
|
-
# Record metrics using metrics collector (direct import for reliability)
|
|
173
|
-
node -e "
|
|
174
|
-
(async () => {
|
|
175
|
-
try {
|
|
176
|
-
const { HookMetricsCollector } = await import('./dist/postprocessor/validation/HookMetricsCollector.js');
|
|
177
|
-
const collector = new HookMetricsCollector();
|
|
178
|
-
collector.recordMetrics('post-push', ${DURATION_MS}, ${EXIT_CODE});
|
|
179
|
-
} catch (error) {
|
|
180
|
-
// Silently fail if metrics collection fails
|
|
181
|
-
}
|
|
182
|
-
})();
|
|
183
|
-
" 2>/dev/null || true
|
|
184
|
-
|
|
185
|
-
[ $EXIT_CODE -eq 0 ] && exit 0 || exit 1
|
|
71
|
+
echo " โ ๏ธ Agent count: $AGENT_COUNT (recommended: 20+)"
|
|
186
72
|
fi
|
|
73
|
+
|
|
74
|
+
if [ "$ERRORS" -gt 0 ]; then
|
|
75
|
+
echo " โ ๏ธ AGENTS.md has $ERRORS missing required sections"
|
|
76
|
+
echo " ๐ See AGENTS.md in root for current format"
|
|
77
|
+
else
|
|
78
|
+
echo " โ
AGENTS.md validation passed"
|
|
79
|
+
fi
|
|
80
|
+
else
|
|
81
|
+
echo " โ AGENTS.md not found"
|
|
82
|
+
fi
|
|
83
|
+
echo ""
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
# For consumer projects, always use the full node_modules path to avoid symlink issues
|
|
87
|
+
# This ensures imports resolve correctly
|
|
88
|
+
STRRAY_PATH=""
|
|
89
|
+
for pkg in "strray-ai" "strray-framework"; do
|
|
90
|
+
if [ -d "node_modules/$pkg/dist" ]; then
|
|
91
|
+
STRRAY_PATH="node_modules/$pkg"
|
|
92
|
+
break
|
|
93
|
+
fi
|
|
94
|
+
done
|
|
95
|
+
|
|
96
|
+
if [ -z "$STRRAY_PATH" ]; then
|
|
97
|
+
# Fallback to local dist for development
|
|
98
|
+
if [ -d "dist" ]; then
|
|
99
|
+
STRRAY_PATH="."
|
|
187
100
|
else
|
|
188
|
-
|
|
101
|
+
exit 0
|
|
189
102
|
fi
|
|
190
|
-
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
# Run post-processor in background with Node.js
|
|
106
|
+
node --input-type=module << EOF &>/dev/null || true
|
|
107
|
+
import { PostProcessor } from './$STRRAY_PATH/dist/postprocessor/PostProcessor.js';
|
|
108
|
+
import { StrRayStateManager } from './$STRRAY_PATH/dist/state/state-manager.js';
|
|
109
|
+
|
|
110
|
+
const stateManager = new StrRayStateManager();
|
|
111
|
+
const postProcessor = new PostProcessor(stateManager, null, {
|
|
112
|
+
reporting: { enabled: false }
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const files = \`$FILES\`.split('\n').filter(f => f.endsWith('.ts') && !f.includes('.test.'));
|
|
116
|
+
|
|
117
|
+
await postProcessor.executePostProcessorLoop({
|
|
118
|
+
commitSha: '$COMMIT_SHA',
|
|
119
|
+
repository: 'strray-framework/stringray',
|
|
120
|
+
branch: '$BRANCH',
|
|
121
|
+
author: '$AUTHOR',
|
|
122
|
+
files: files,
|
|
123
|
+
trigger: 'git-hook'
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
console.log('Post-processor completed for', files.length, 'files');
|
|
127
|
+
EOF
|
|
191
128
|
|
|
192
|
-
# Don't wait for background process
|
|
193
129
|
exit 0
|