@massu/core 0.6.3 → 0.8.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/README.md +2 -2
- package/dist/cli.js +180 -5
- package/dist/hooks/auto-learning-pipeline.js +481 -0
- package/dist/hooks/classify-failure.js +1146 -0
- package/dist/hooks/cost-tracker.js +59 -1
- package/dist/hooks/fix-detector.js +474 -0
- package/dist/hooks/incident-pipeline.js +1114 -0
- package/dist/hooks/post-edit-context.js +40 -1
- package/dist/hooks/post-tool-use.js +59 -1
- package/dist/hooks/pre-compact.js +59 -1
- package/dist/hooks/pre-delete-check.js +40 -1
- package/dist/hooks/quality-event.js +59 -1
- package/dist/hooks/rule-enforcement-pipeline.js +453 -0
- package/dist/hooks/session-end.js +59 -1
- package/dist/hooks/session-start.js +60 -2
- package/dist/hooks/user-prompt.js +91 -2
- package/package.json +2 -2
- package/reference/hook-execution-order.md +25 -17
- package/src/commands/doctor.ts +1 -1
- package/src/commands/init.ts +11 -1
- package/src/config.ts +43 -0
- package/src/hooks/auto-learning-pipeline.ts +195 -0
- package/src/hooks/classify-failure.ts +259 -0
- package/src/hooks/fix-detector.ts +186 -0
- package/src/hooks/incident-pipeline.ts +190 -0
- package/src/hooks/rule-enforcement-pipeline.ts +159 -0
- package/src/hooks/session-start.ts +1 -1
- package/src/hooks/user-prompt.ts +21 -1
- package/src/license.ts +2 -1
- package/src/mcp-bridge-tools.ts +1 -1
- package/src/memory-db.ts +201 -0
|
@@ -129,6 +129,44 @@ var RegressionConfigSchema = z.object({
|
|
|
129
129
|
warning: z.number().default(50)
|
|
130
130
|
}).optional()
|
|
131
131
|
}).optional();
|
|
132
|
+
var AutoLearningConfigSchema = z.object({
|
|
133
|
+
enabled: z.boolean().default(true),
|
|
134
|
+
incidentDir: z.string().default("docs/incidents"),
|
|
135
|
+
memoryDir: z.string().default("memory"),
|
|
136
|
+
memoryIndexFile: z.string().default("MEMORY.md"),
|
|
137
|
+
enforcementHooksDir: z.string().default("scripts/hooks"),
|
|
138
|
+
fixDetection: z.object({
|
|
139
|
+
enabled: z.boolean().default(true),
|
|
140
|
+
lookbackDays: z.number().default(7),
|
|
141
|
+
signals: z.array(z.string()).default([
|
|
142
|
+
"removed_broken_code",
|
|
143
|
+
"added_error_handling",
|
|
144
|
+
"method_name_correction",
|
|
145
|
+
"auth_fix",
|
|
146
|
+
"nil_handling_fix",
|
|
147
|
+
"concurrency_fix",
|
|
148
|
+
"async_pattern_fix",
|
|
149
|
+
"added_missing_import"
|
|
150
|
+
])
|
|
151
|
+
}).default({}),
|
|
152
|
+
failureClassification: z.object({
|
|
153
|
+
enabled: z.boolean().default(true),
|
|
154
|
+
thresholds: z.object({
|
|
155
|
+
known: z.number().default(5),
|
|
156
|
+
similar: z.number().default(3)
|
|
157
|
+
}).default({}),
|
|
158
|
+
scoring: z.object({
|
|
159
|
+
diffPatternWeight: z.number().default(3),
|
|
160
|
+
filePatternWeight: z.number().default(2),
|
|
161
|
+
promptKeywordWeight: z.number().default(2)
|
|
162
|
+
}).default({})
|
|
163
|
+
}).default({}),
|
|
164
|
+
pipeline: z.object({
|
|
165
|
+
requireIncidentReport: z.boolean().default(true),
|
|
166
|
+
requirePreventionRule: z.boolean().default(true),
|
|
167
|
+
requireEnforcement: z.boolean().default(true)
|
|
168
|
+
}).default({})
|
|
169
|
+
}).optional();
|
|
132
170
|
var CloudConfigSchema = z.object({
|
|
133
171
|
enabled: z.boolean().default(false),
|
|
134
172
|
apiKey: z.string().optional(),
|
|
@@ -218,7 +256,8 @@ var RawConfigSchema = z.object({
|
|
|
218
256
|
regression: RegressionConfigSchema,
|
|
219
257
|
cloud: CloudConfigSchema,
|
|
220
258
|
conventions: ConventionsConfigSchema,
|
|
221
|
-
python: PythonConfigSchema
|
|
259
|
+
python: PythonConfigSchema,
|
|
260
|
+
autoLearning: AutoLearningConfigSchema
|
|
222
261
|
}).passthrough();
|
|
223
262
|
var _config = null;
|
|
224
263
|
var _projectRoot = null;
|
|
@@ -131,6 +131,44 @@ var RegressionConfigSchema = z.object({
|
|
|
131
131
|
warning: z.number().default(50)
|
|
132
132
|
}).optional()
|
|
133
133
|
}).optional();
|
|
134
|
+
var AutoLearningConfigSchema = z.object({
|
|
135
|
+
enabled: z.boolean().default(true),
|
|
136
|
+
incidentDir: z.string().default("docs/incidents"),
|
|
137
|
+
memoryDir: z.string().default("memory"),
|
|
138
|
+
memoryIndexFile: z.string().default("MEMORY.md"),
|
|
139
|
+
enforcementHooksDir: z.string().default("scripts/hooks"),
|
|
140
|
+
fixDetection: z.object({
|
|
141
|
+
enabled: z.boolean().default(true),
|
|
142
|
+
lookbackDays: z.number().default(7),
|
|
143
|
+
signals: z.array(z.string()).default([
|
|
144
|
+
"removed_broken_code",
|
|
145
|
+
"added_error_handling",
|
|
146
|
+
"method_name_correction",
|
|
147
|
+
"auth_fix",
|
|
148
|
+
"nil_handling_fix",
|
|
149
|
+
"concurrency_fix",
|
|
150
|
+
"async_pattern_fix",
|
|
151
|
+
"added_missing_import"
|
|
152
|
+
])
|
|
153
|
+
}).default({}),
|
|
154
|
+
failureClassification: z.object({
|
|
155
|
+
enabled: z.boolean().default(true),
|
|
156
|
+
thresholds: z.object({
|
|
157
|
+
known: z.number().default(5),
|
|
158
|
+
similar: z.number().default(3)
|
|
159
|
+
}).default({}),
|
|
160
|
+
scoring: z.object({
|
|
161
|
+
diffPatternWeight: z.number().default(3),
|
|
162
|
+
filePatternWeight: z.number().default(2),
|
|
163
|
+
promptKeywordWeight: z.number().default(2)
|
|
164
|
+
}).default({})
|
|
165
|
+
}).default({}),
|
|
166
|
+
pipeline: z.object({
|
|
167
|
+
requireIncidentReport: z.boolean().default(true),
|
|
168
|
+
requirePreventionRule: z.boolean().default(true),
|
|
169
|
+
requireEnforcement: z.boolean().default(true)
|
|
170
|
+
}).default({})
|
|
171
|
+
}).optional();
|
|
134
172
|
var CloudConfigSchema = z.object({
|
|
135
173
|
enabled: z.boolean().default(false),
|
|
136
174
|
apiKey: z.string().optional(),
|
|
@@ -220,7 +258,8 @@ var RawConfigSchema = z.object({
|
|
|
220
258
|
regression: RegressionConfigSchema,
|
|
221
259
|
cloud: CloudConfigSchema,
|
|
222
260
|
conventions: ConventionsConfigSchema,
|
|
223
|
-
python: PythonConfigSchema
|
|
261
|
+
python: PythonConfigSchema,
|
|
262
|
+
autoLearning: AutoLearningConfigSchema
|
|
224
263
|
}).passthrough();
|
|
225
264
|
var _config = null;
|
|
226
265
|
var _projectRoot = null;
|
|
@@ -821,6 +860,25 @@ function initMemorySchema(db) {
|
|
|
821
860
|
features TEXT DEFAULT '[]'
|
|
822
861
|
);
|
|
823
862
|
`);
|
|
863
|
+
db.exec(`
|
|
864
|
+
CREATE TABLE IF NOT EXISTS failure_classes (
|
|
865
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
866
|
+
name TEXT NOT NULL UNIQUE,
|
|
867
|
+
description TEXT NOT NULL,
|
|
868
|
+
diff_patterns TEXT NOT NULL DEFAULT '[]',
|
|
869
|
+
file_patterns TEXT NOT NULL DEFAULT '[]',
|
|
870
|
+
prompt_keywords TEXT NOT NULL DEFAULT '[]',
|
|
871
|
+
incidents TEXT NOT NULL DEFAULT '[]',
|
|
872
|
+
rules TEXT NOT NULL DEFAULT '[]',
|
|
873
|
+
scanner_checks TEXT NOT NULL DEFAULT '[]',
|
|
874
|
+
known_message TEXT NOT NULL DEFAULT '',
|
|
875
|
+
needs_review INTEGER NOT NULL DEFAULT 0,
|
|
876
|
+
created_at TEXT DEFAULT (datetime('now')),
|
|
877
|
+
updated_at TEXT DEFAULT (datetime('now'))
|
|
878
|
+
);
|
|
879
|
+
CREATE INDEX IF NOT EXISTS idx_fc_name ON failure_classes(name);
|
|
880
|
+
CREATE INDEX IF NOT EXISTS idx_fc_needs_review ON failure_classes(needs_review);
|
|
881
|
+
`);
|
|
824
882
|
}
|
|
825
883
|
function assignImportance(type, vrResult) {
|
|
826
884
|
switch (type) {
|
|
@@ -131,6 +131,44 @@ var RegressionConfigSchema = z.object({
|
|
|
131
131
|
warning: z.number().default(50)
|
|
132
132
|
}).optional()
|
|
133
133
|
}).optional();
|
|
134
|
+
var AutoLearningConfigSchema = z.object({
|
|
135
|
+
enabled: z.boolean().default(true),
|
|
136
|
+
incidentDir: z.string().default("docs/incidents"),
|
|
137
|
+
memoryDir: z.string().default("memory"),
|
|
138
|
+
memoryIndexFile: z.string().default("MEMORY.md"),
|
|
139
|
+
enforcementHooksDir: z.string().default("scripts/hooks"),
|
|
140
|
+
fixDetection: z.object({
|
|
141
|
+
enabled: z.boolean().default(true),
|
|
142
|
+
lookbackDays: z.number().default(7),
|
|
143
|
+
signals: z.array(z.string()).default([
|
|
144
|
+
"removed_broken_code",
|
|
145
|
+
"added_error_handling",
|
|
146
|
+
"method_name_correction",
|
|
147
|
+
"auth_fix",
|
|
148
|
+
"nil_handling_fix",
|
|
149
|
+
"concurrency_fix",
|
|
150
|
+
"async_pattern_fix",
|
|
151
|
+
"added_missing_import"
|
|
152
|
+
])
|
|
153
|
+
}).default({}),
|
|
154
|
+
failureClassification: z.object({
|
|
155
|
+
enabled: z.boolean().default(true),
|
|
156
|
+
thresholds: z.object({
|
|
157
|
+
known: z.number().default(5),
|
|
158
|
+
similar: z.number().default(3)
|
|
159
|
+
}).default({}),
|
|
160
|
+
scoring: z.object({
|
|
161
|
+
diffPatternWeight: z.number().default(3),
|
|
162
|
+
filePatternWeight: z.number().default(2),
|
|
163
|
+
promptKeywordWeight: z.number().default(2)
|
|
164
|
+
}).default({})
|
|
165
|
+
}).default({}),
|
|
166
|
+
pipeline: z.object({
|
|
167
|
+
requireIncidentReport: z.boolean().default(true),
|
|
168
|
+
requirePreventionRule: z.boolean().default(true),
|
|
169
|
+
requireEnforcement: z.boolean().default(true)
|
|
170
|
+
}).default({})
|
|
171
|
+
}).optional();
|
|
134
172
|
var CloudConfigSchema = z.object({
|
|
135
173
|
enabled: z.boolean().default(false),
|
|
136
174
|
apiKey: z.string().optional(),
|
|
@@ -220,7 +258,8 @@ var RawConfigSchema = z.object({
|
|
|
220
258
|
regression: RegressionConfigSchema,
|
|
221
259
|
cloud: CloudConfigSchema,
|
|
222
260
|
conventions: ConventionsConfigSchema,
|
|
223
|
-
python: PythonConfigSchema
|
|
261
|
+
python: PythonConfigSchema,
|
|
262
|
+
autoLearning: AutoLearningConfigSchema
|
|
224
263
|
}).passthrough();
|
|
225
264
|
var _config = null;
|
|
226
265
|
var _projectRoot = null;
|
|
@@ -821,6 +860,25 @@ function initMemorySchema(db) {
|
|
|
821
860
|
features TEXT DEFAULT '[]'
|
|
822
861
|
);
|
|
823
862
|
`);
|
|
863
|
+
db.exec(`
|
|
864
|
+
CREATE TABLE IF NOT EXISTS failure_classes (
|
|
865
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
866
|
+
name TEXT NOT NULL UNIQUE,
|
|
867
|
+
description TEXT NOT NULL,
|
|
868
|
+
diff_patterns TEXT NOT NULL DEFAULT '[]',
|
|
869
|
+
file_patterns TEXT NOT NULL DEFAULT '[]',
|
|
870
|
+
prompt_keywords TEXT NOT NULL DEFAULT '[]',
|
|
871
|
+
incidents TEXT NOT NULL DEFAULT '[]',
|
|
872
|
+
rules TEXT NOT NULL DEFAULT '[]',
|
|
873
|
+
scanner_checks TEXT NOT NULL DEFAULT '[]',
|
|
874
|
+
known_message TEXT NOT NULL DEFAULT '',
|
|
875
|
+
needs_review INTEGER NOT NULL DEFAULT 0,
|
|
876
|
+
created_at TEXT DEFAULT (datetime('now')),
|
|
877
|
+
updated_at TEXT DEFAULT (datetime('now'))
|
|
878
|
+
);
|
|
879
|
+
CREATE INDEX IF NOT EXISTS idx_fc_name ON failure_classes(name);
|
|
880
|
+
CREATE INDEX IF NOT EXISTS idx_fc_needs_review ON failure_classes(needs_review);
|
|
881
|
+
`);
|
|
824
882
|
}
|
|
825
883
|
function assignImportance(type, vrResult) {
|
|
826
884
|
switch (type) {
|
|
@@ -130,6 +130,44 @@ var RegressionConfigSchema = z.object({
|
|
|
130
130
|
warning: z.number().default(50)
|
|
131
131
|
}).optional()
|
|
132
132
|
}).optional();
|
|
133
|
+
var AutoLearningConfigSchema = z.object({
|
|
134
|
+
enabled: z.boolean().default(true),
|
|
135
|
+
incidentDir: z.string().default("docs/incidents"),
|
|
136
|
+
memoryDir: z.string().default("memory"),
|
|
137
|
+
memoryIndexFile: z.string().default("MEMORY.md"),
|
|
138
|
+
enforcementHooksDir: z.string().default("scripts/hooks"),
|
|
139
|
+
fixDetection: z.object({
|
|
140
|
+
enabled: z.boolean().default(true),
|
|
141
|
+
lookbackDays: z.number().default(7),
|
|
142
|
+
signals: z.array(z.string()).default([
|
|
143
|
+
"removed_broken_code",
|
|
144
|
+
"added_error_handling",
|
|
145
|
+
"method_name_correction",
|
|
146
|
+
"auth_fix",
|
|
147
|
+
"nil_handling_fix",
|
|
148
|
+
"concurrency_fix",
|
|
149
|
+
"async_pattern_fix",
|
|
150
|
+
"added_missing_import"
|
|
151
|
+
])
|
|
152
|
+
}).default({}),
|
|
153
|
+
failureClassification: z.object({
|
|
154
|
+
enabled: z.boolean().default(true),
|
|
155
|
+
thresholds: z.object({
|
|
156
|
+
known: z.number().default(5),
|
|
157
|
+
similar: z.number().default(3)
|
|
158
|
+
}).default({}),
|
|
159
|
+
scoring: z.object({
|
|
160
|
+
diffPatternWeight: z.number().default(3),
|
|
161
|
+
filePatternWeight: z.number().default(2),
|
|
162
|
+
promptKeywordWeight: z.number().default(2)
|
|
163
|
+
}).default({})
|
|
164
|
+
}).default({}),
|
|
165
|
+
pipeline: z.object({
|
|
166
|
+
requireIncidentReport: z.boolean().default(true),
|
|
167
|
+
requirePreventionRule: z.boolean().default(true),
|
|
168
|
+
requireEnforcement: z.boolean().default(true)
|
|
169
|
+
}).default({})
|
|
170
|
+
}).optional();
|
|
133
171
|
var CloudConfigSchema = z.object({
|
|
134
172
|
enabled: z.boolean().default(false),
|
|
135
173
|
apiKey: z.string().optional(),
|
|
@@ -219,7 +257,8 @@ var RawConfigSchema = z.object({
|
|
|
219
257
|
regression: RegressionConfigSchema,
|
|
220
258
|
cloud: CloudConfigSchema,
|
|
221
259
|
conventions: ConventionsConfigSchema,
|
|
222
|
-
python: PythonConfigSchema
|
|
260
|
+
python: PythonConfigSchema,
|
|
261
|
+
autoLearning: AutoLearningConfigSchema
|
|
223
262
|
}).passthrough();
|
|
224
263
|
var _config = null;
|
|
225
264
|
var _projectRoot = null;
|
|
@@ -131,6 +131,44 @@ var RegressionConfigSchema = z.object({
|
|
|
131
131
|
warning: z.number().default(50)
|
|
132
132
|
}).optional()
|
|
133
133
|
}).optional();
|
|
134
|
+
var AutoLearningConfigSchema = z.object({
|
|
135
|
+
enabled: z.boolean().default(true),
|
|
136
|
+
incidentDir: z.string().default("docs/incidents"),
|
|
137
|
+
memoryDir: z.string().default("memory"),
|
|
138
|
+
memoryIndexFile: z.string().default("MEMORY.md"),
|
|
139
|
+
enforcementHooksDir: z.string().default("scripts/hooks"),
|
|
140
|
+
fixDetection: z.object({
|
|
141
|
+
enabled: z.boolean().default(true),
|
|
142
|
+
lookbackDays: z.number().default(7),
|
|
143
|
+
signals: z.array(z.string()).default([
|
|
144
|
+
"removed_broken_code",
|
|
145
|
+
"added_error_handling",
|
|
146
|
+
"method_name_correction",
|
|
147
|
+
"auth_fix",
|
|
148
|
+
"nil_handling_fix",
|
|
149
|
+
"concurrency_fix",
|
|
150
|
+
"async_pattern_fix",
|
|
151
|
+
"added_missing_import"
|
|
152
|
+
])
|
|
153
|
+
}).default({}),
|
|
154
|
+
failureClassification: z.object({
|
|
155
|
+
enabled: z.boolean().default(true),
|
|
156
|
+
thresholds: z.object({
|
|
157
|
+
known: z.number().default(5),
|
|
158
|
+
similar: z.number().default(3)
|
|
159
|
+
}).default({}),
|
|
160
|
+
scoring: z.object({
|
|
161
|
+
diffPatternWeight: z.number().default(3),
|
|
162
|
+
filePatternWeight: z.number().default(2),
|
|
163
|
+
promptKeywordWeight: z.number().default(2)
|
|
164
|
+
}).default({})
|
|
165
|
+
}).default({}),
|
|
166
|
+
pipeline: z.object({
|
|
167
|
+
requireIncidentReport: z.boolean().default(true),
|
|
168
|
+
requirePreventionRule: z.boolean().default(true),
|
|
169
|
+
requireEnforcement: z.boolean().default(true)
|
|
170
|
+
}).default({})
|
|
171
|
+
}).optional();
|
|
134
172
|
var CloudConfigSchema = z.object({
|
|
135
173
|
enabled: z.boolean().default(false),
|
|
136
174
|
apiKey: z.string().optional(),
|
|
@@ -220,7 +258,8 @@ var RawConfigSchema = z.object({
|
|
|
220
258
|
regression: RegressionConfigSchema,
|
|
221
259
|
cloud: CloudConfigSchema,
|
|
222
260
|
conventions: ConventionsConfigSchema,
|
|
223
|
-
python: PythonConfigSchema
|
|
261
|
+
python: PythonConfigSchema,
|
|
262
|
+
autoLearning: AutoLearningConfigSchema
|
|
224
263
|
}).passthrough();
|
|
225
264
|
var _config = null;
|
|
226
265
|
var _projectRoot = null;
|
|
@@ -821,6 +860,25 @@ function initMemorySchema(db) {
|
|
|
821
860
|
features TEXT DEFAULT '[]'
|
|
822
861
|
);
|
|
823
862
|
`);
|
|
863
|
+
db.exec(`
|
|
864
|
+
CREATE TABLE IF NOT EXISTS failure_classes (
|
|
865
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
866
|
+
name TEXT NOT NULL UNIQUE,
|
|
867
|
+
description TEXT NOT NULL,
|
|
868
|
+
diff_patterns TEXT NOT NULL DEFAULT '[]',
|
|
869
|
+
file_patterns TEXT NOT NULL DEFAULT '[]',
|
|
870
|
+
prompt_keywords TEXT NOT NULL DEFAULT '[]',
|
|
871
|
+
incidents TEXT NOT NULL DEFAULT '[]',
|
|
872
|
+
rules TEXT NOT NULL DEFAULT '[]',
|
|
873
|
+
scanner_checks TEXT NOT NULL DEFAULT '[]',
|
|
874
|
+
known_message TEXT NOT NULL DEFAULT '',
|
|
875
|
+
needs_review INTEGER NOT NULL DEFAULT 0,
|
|
876
|
+
created_at TEXT DEFAULT (datetime('now')),
|
|
877
|
+
updated_at TEXT DEFAULT (datetime('now'))
|
|
878
|
+
);
|
|
879
|
+
CREATE INDEX IF NOT EXISTS idx_fc_name ON failure_classes(name);
|
|
880
|
+
CREATE INDEX IF NOT EXISTS idx_fc_needs_review ON failure_classes(needs_review);
|
|
881
|
+
`);
|
|
824
882
|
}
|
|
825
883
|
|
|
826
884
|
// src/hooks/quality-event.ts
|