@massu/core 1.10.7 → 1.12.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/CHANGELOG.md +1303 -0
- package/dist/adapter.js +6 -4
- package/dist/cli.js +559 -400
- package/dist/detect/adapters/.bundle-shasums.json +4 -7
- package/dist/detect/adapters/rails.js +6 -4
- package/dist/detect/adapters/spring.js +6 -4
- package/dist/detect/adapters/tree-sitter-loader.js +6 -4
- package/dist/hooks/auto-learning-pipeline.js +24 -1
- package/dist/hooks/classify-failure.js +32 -3
- package/dist/hooks/cost-tracker.js +24 -0
- package/dist/hooks/fix-detector.js +97 -1
- package/dist/hooks/incident-pipeline.js +30 -1
- package/dist/hooks/intent-suggester.js +6 -3
- package/dist/hooks/post-edit-context.js +24 -1
- package/dist/hooks/post-tool-use.js +66 -18
- package/dist/hooks/pre-compact.js +27 -2
- package/dist/hooks/pre-delete-check.js +48 -22
- package/dist/hooks/pre-tool-use-gate.js +962 -0
- package/dist/hooks/quality-event.js +24 -0
- package/dist/hooks/rule-enforcement-pipeline.js +24 -1
- package/dist/hooks/security-gate.js +29 -16
- package/dist/hooks/session-end.js +24 -0
- package/dist/hooks/session-start.js +8710 -8460
- package/dist/hooks/user-prompt.js +24 -0
- package/package.json +15 -18
- package/commands/README.md +0 -134
- package/src/adapter.ts +0 -121
- package/src/adr-generator.ts +0 -292
- package/src/analytics.ts +0 -373
- package/src/audit-trail.ts +0 -450
- package/src/backfill-sessions.ts +0 -182
- package/src/changelog-generator.ts +0 -178
- package/src/cli.ts +0 -246
- package/src/cloud-sync.ts +0 -234
- package/src/commands/adapters.ts +0 -824
- package/src/commands/changelog.ts +0 -165
- package/src/commands/config-check-drift.ts +0 -133
- package/src/commands/config-refresh.ts +0 -396
- package/src/commands/config-upgrade.ts +0 -127
- package/src/commands/doctor.ts +0 -485
- package/src/commands/hook-runner.ts +0 -145
- package/src/commands/init.ts +0 -1823
- package/src/commands/install-commands.ts +0 -692
- package/src/commands/install-hooks.ts +0 -27
- package/src/commands/permissions.ts +0 -150
- package/src/commands/refresh-log.ts +0 -37
- package/src/commands/show-template.ts +0 -65
- package/src/commands/template-engine.ts +0 -301
- package/src/commands/watch.ts +0 -430
- package/src/config.ts +0 -765
- package/src/cost-tracker.ts +0 -355
- package/src/db.ts +0 -370
- package/src/dependency-scorer.ts +0 -337
- package/src/detect/adapters/aspnet.ts +0 -4
- package/src/detect/adapters/discover.ts +0 -469
- package/src/detect/adapters/file-sampler.ts +0 -225
- package/src/detect/adapters/go-chi.ts +0 -4
- package/src/detect/adapters/index.ts +0 -51
- package/src/detect/adapters/nextjs-trpc.ts +0 -166
- package/src/detect/adapters/parse-guard.ts +0 -133
- package/src/detect/adapters/phoenix.ts +0 -4
- package/src/detect/adapters/python-django.ts +0 -208
- package/src/detect/adapters/python-fastapi.ts +0 -223
- package/src/detect/adapters/python-flask.ts +0 -235
- package/src/detect/adapters/query-helpers.ts +0 -170
- package/src/detect/adapters/rails.ts +0 -4
- package/src/detect/adapters/runner.ts +0 -284
- package/src/detect/adapters/spring.ts +0 -4
- package/src/detect/adapters/swift-swiftui.ts +0 -171
- package/src/detect/adapters/tree-sitter-loader.ts +0 -517
- package/src/detect/adapters/types.ts +0 -191
- package/src/detect/codebase-introspector.ts +0 -210
- package/src/detect/domain-inferrer.ts +0 -197
- package/src/detect/drift.ts +0 -199
- package/src/detect/framework-detector.ts +0 -307
- package/src/detect/index.ts +0 -209
- package/src/detect/manifest-registry.ts +0 -261
- package/src/detect/migrate.ts +0 -362
- package/src/detect/monorepo-detector.ts +0 -348
- package/src/detect/package-detector.ts +0 -828
- package/src/detect/passthrough.ts +0 -108
- package/src/detect/regex-fallback.ts +0 -449
- package/src/detect/source-dir-detector.ts +0 -297
- package/src/detect/vr-command-map.ts +0 -167
- package/src/docs-map.json +0 -100
- package/src/docs-tools.ts +0 -519
- package/src/domains.ts +0 -182
- package/src/hooks/auto-learning-pipeline.ts +0 -228
- package/src/hooks/classify-failure.ts +0 -259
- package/src/hooks/cost-tracker.ts +0 -66
- package/src/hooks/fix-detector.ts +0 -186
- package/src/hooks/incident-pipeline.ts +0 -190
- package/src/hooks/intent-suggester.ts +0 -131
- package/src/hooks/post-edit-context.ts +0 -91
- package/src/hooks/post-tool-use.ts +0 -413
- package/src/hooks/pre-compact.ts +0 -168
- package/src/hooks/pre-delete-check.ts +0 -243
- package/src/hooks/quality-event.ts +0 -127
- package/src/hooks/rule-enforcement-pipeline.ts +0 -159
- package/src/hooks/security-gate.ts +0 -153
- package/src/hooks/session-end.ts +0 -467
- package/src/hooks/session-start.ts +0 -436
- package/src/hooks/user-prompt.ts +0 -157
- package/src/import-resolver.ts +0 -226
- package/src/knowledge-db.ts +0 -176
- package/src/knowledge-indexer.ts +0 -708
- package/src/knowledge-tools.ts +0 -1414
- package/src/lib/fileLock.ts +0 -203
- package/src/lib/gitToplevel.ts +0 -22
- package/src/lib/hook-registry.ts +0 -43
- package/src/lib/installLock.ts +0 -66
- package/src/lib/memory-path.ts +0 -49
- package/src/lib/pidLiveness.ts +0 -67
- package/src/lib/settings-local.ts +0 -110
- package/src/lib/sql-table-names.ts +0 -71
- package/src/license.ts +0 -547
- package/src/lsp/auto-detect.ts +0 -98
- package/src/lsp/client.ts +0 -776
- package/src/lsp/enrich.ts +0 -127
- package/src/lsp/types.ts +0 -221
- package/src/memory-db.ts +0 -1614
- package/src/memory-file-ingest.ts +0 -128
- package/src/memory-tools.ts +0 -424
- package/src/middleware-tree.ts +0 -71
- package/src/observability-tools.ts +0 -343
- package/src/observation-extractor.ts +0 -418
- package/src/page-deps.ts +0 -285
- package/src/permissions.ts +0 -422
- package/src/prompt-analyzer.ts +0 -332
- package/src/python/coupling-detector.ts +0 -125
- package/src/python/domain-enforcer.ts +0 -84
- package/src/python/impact-analyzer.ts +0 -96
- package/src/python/import-parser.ts +0 -244
- package/src/python/import-resolver.ts +0 -136
- package/src/python/migration-indexer.ts +0 -116
- package/src/python/migration-parser.ts +0 -332
- package/src/python/model-indexer.ts +0 -71
- package/src/python/model-parser.ts +0 -279
- package/src/python/route-indexer.ts +0 -59
- package/src/python/route-parser.ts +0 -317
- package/src/python-tools.ts +0 -630
- package/src/regression-detector.ts +0 -319
- package/src/rules.ts +0 -57
- package/src/schema-mapper.ts +0 -232
- package/src/security/adapter-origin.ts +0 -130
- package/src/security/adapter-verifier.ts +0 -319
- package/src/security/atomic-write.ts +0 -164
- package/src/security/fetcher.ts +0 -200
- package/src/security/install-tracking.ts +0 -319
- package/src/security/license-pubkey.generated.ts +0 -30
- package/src/security/license-response-verifier.ts +0 -149
- package/src/security/local-fingerprint.ts +0 -225
- package/src/security/manifest-cache.ts +0 -333
- package/src/security/manifest-schema.ts +0 -129
- package/src/security/registry-pubkey.generated.ts +0 -35
- package/src/security/telemetry.ts +0 -320
- package/src/security-scorer.ts +0 -405
- package/src/security-utils.ts +0 -133
- package/src/sentinel-db.ts +0 -580
- package/src/sentinel-scanner.ts +0 -406
- package/src/sentinel-tools.ts +0 -513
- package/src/sentinel-types.ts +0 -140
- package/src/server-dispatch.ts +0 -225
- package/src/server.ts +0 -107
- package/src/session-archiver.ts +0 -111
- package/src/session-state-generator.ts +0 -174
- package/src/team-knowledge.ts +0 -407
- package/src/tool-db-needs.ts +0 -232
- package/src/tools.ts +0 -1205
- package/src/transcript-parser.ts +0 -458
- package/src/trpc-index.ts +0 -215
- package/src/validate-features-runner.ts +0 -107
- package/src/validation-engine.ts +0 -358
- package/src/watch/daemon.ts +0 -385
- package/src/watch/lockfile-detector.ts +0 -65
- package/src/watch/paths.ts +0 -279
- package/src/watch/state.ts +0 -178
|
@@ -348,6 +348,22 @@ var RawConfigSchema = z.object({
|
|
|
348
348
|
accessScopes: z.array(z.string()).optional(),
|
|
349
349
|
domains: z.array(DomainConfigSchema).default([]),
|
|
350
350
|
rules: z.array(PatternRuleConfigSchema).default([]),
|
|
351
|
+
// P-M-036 (plan-stage-d-medium-sweep): customer-authored CR-style
|
|
352
|
+
// governance rules. DISTINCT from `rules:` above (path-scoped lint hints
|
|
353
|
+
// used by pattern-scanner). At config-refresh time these entries are
|
|
354
|
+
// loaded into the `knowledge_rules` SQLite table with
|
|
355
|
+
// `source = 'customer-config'` so `massu_knowledge_rule` and the
|
|
356
|
+
// governance docs surface customer-defined rules alongside framework CRs.
|
|
357
|
+
governance_rules: z.array(
|
|
358
|
+
z.object({
|
|
359
|
+
id: z.string().min(1, "governance_rules[].id is required"),
|
|
360
|
+
title: z.string().min(1, "governance_rules[].title is required"),
|
|
361
|
+
description: z.string().min(1, "governance_rules[].description is required"),
|
|
362
|
+
vr_type: z.string().default("VR-CUSTOM"),
|
|
363
|
+
reference_path: z.string().optional(),
|
|
364
|
+
severity: z.enum(["critical", "high", "medium", "low", "info"]).default("medium")
|
|
365
|
+
}).passthrough()
|
|
366
|
+
).default([]),
|
|
351
367
|
analytics: AnalyticsConfigSchema,
|
|
352
368
|
governance: GovernanceConfigSchema,
|
|
353
369
|
security: SecurityConfigSchema,
|
|
@@ -466,6 +482,8 @@ Hint: run \`massu config refresh\` to regenerate a valid config or fix the liste
|
|
|
466
482
|
accessScopes: parsed.accessScopes,
|
|
467
483
|
domains: parsed.domains,
|
|
468
484
|
rules: parsed.rules,
|
|
485
|
+
// P-M-036: customer-authored CR-style governance rules.
|
|
486
|
+
governance_rules: parsed.governance_rules,
|
|
469
487
|
analytics: parsed.analytics,
|
|
470
488
|
governance: parsed.governance,
|
|
471
489
|
security: parsed.security,
|
|
@@ -1018,6 +1036,12 @@ function initMemorySchema(db) {
|
|
|
1018
1036
|
features TEXT DEFAULT '[]'
|
|
1019
1037
|
);
|
|
1020
1038
|
`);
|
|
1039
|
+
const licenseCacheCols = db.prepare(`PRAGMA table_info(license_cache)`).all();
|
|
1040
|
+
if (!licenseCacheCols.some((c) => c.name === "signed_payload_json")) {
|
|
1041
|
+
db.exec(
|
|
1042
|
+
`ALTER TABLE license_cache ADD COLUMN signed_payload_json TEXT NOT NULL DEFAULT ''`
|
|
1043
|
+
);
|
|
1044
|
+
}
|
|
1021
1045
|
db.exec(`
|
|
1022
1046
|
CREATE TABLE IF NOT EXISTS failure_classes (
|
|
1023
1047
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -339,6 +339,22 @@ var RawConfigSchema = z.object({
|
|
|
339
339
|
accessScopes: z.array(z.string()).optional(),
|
|
340
340
|
domains: z.array(DomainConfigSchema).default([]),
|
|
341
341
|
rules: z.array(PatternRuleConfigSchema).default([]),
|
|
342
|
+
// P-M-036 (plan-stage-d-medium-sweep): customer-authored CR-style
|
|
343
|
+
// governance rules. DISTINCT from `rules:` above (path-scoped lint hints
|
|
344
|
+
// used by pattern-scanner). At config-refresh time these entries are
|
|
345
|
+
// loaded into the `knowledge_rules` SQLite table with
|
|
346
|
+
// `source = 'customer-config'` so `massu_knowledge_rule` and the
|
|
347
|
+
// governance docs surface customer-defined rules alongside framework CRs.
|
|
348
|
+
governance_rules: z.array(
|
|
349
|
+
z.object({
|
|
350
|
+
id: z.string().min(1, "governance_rules[].id is required"),
|
|
351
|
+
title: z.string().min(1, "governance_rules[].title is required"),
|
|
352
|
+
description: z.string().min(1, "governance_rules[].description is required"),
|
|
353
|
+
vr_type: z.string().default("VR-CUSTOM"),
|
|
354
|
+
reference_path: z.string().optional(),
|
|
355
|
+
severity: z.enum(["critical", "high", "medium", "low", "info"]).default("medium")
|
|
356
|
+
}).passthrough()
|
|
357
|
+
).default([]),
|
|
342
358
|
analytics: AnalyticsConfigSchema,
|
|
343
359
|
governance: GovernanceConfigSchema,
|
|
344
360
|
security: SecurityConfigSchema,
|
|
@@ -457,6 +473,8 @@ Hint: run \`massu config refresh\` to regenerate a valid config or fix the liste
|
|
|
457
473
|
accessScopes: parsed.accessScopes,
|
|
458
474
|
domains: parsed.domains,
|
|
459
475
|
rules: parsed.rules,
|
|
476
|
+
// P-M-036: customer-authored CR-style governance rules.
|
|
477
|
+
governance_rules: parsed.governance_rules,
|
|
460
478
|
analytics: parsed.analytics,
|
|
461
479
|
governance: parsed.governance,
|
|
462
480
|
security: parsed.security,
|
|
@@ -487,6 +505,11 @@ Hint: run \`massu config refresh\` to regenerate a valid config or fix the liste
|
|
|
487
505
|
return _config;
|
|
488
506
|
}
|
|
489
507
|
|
|
508
|
+
// src/hooks/lib/write-hook-message.ts
|
|
509
|
+
function writeHookMessage(message) {
|
|
510
|
+
process.stdout.write(JSON.stringify({ message }) + "\n");
|
|
511
|
+
}
|
|
512
|
+
|
|
490
513
|
// src/hooks/rule-enforcement-pipeline.ts
|
|
491
514
|
async function main() {
|
|
492
515
|
try {
|
|
@@ -585,7 +608,7 @@ async function main() {
|
|
|
585
608
|
lines.push(" This step is MANDATORY per the auto-learning pipeline.");
|
|
586
609
|
lines.push("============================================================================");
|
|
587
610
|
lines.push("");
|
|
588
|
-
|
|
611
|
+
writeHookMessage(lines.join("\n"));
|
|
589
612
|
} catch {
|
|
590
613
|
}
|
|
591
614
|
process.exit(0);
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);
|
|
3
3
|
|
|
4
|
+
// src/hooks/lib/write-hook-message.ts
|
|
5
|
+
function writeHookMessage(message) {
|
|
6
|
+
process.stdout.write(JSON.stringify({ message }) + "\n");
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
// src/hooks/security-gate.ts
|
|
5
10
|
var DANGEROUS_BASH_PATTERNS = [
|
|
6
11
|
{ pattern: /rm\s+-[a-z]*r[a-z]*f[a-z]*\s+\/(?:\s|$)/, label: "rm -rf /" },
|
|
@@ -70,44 +75,47 @@ function checkPythonContent(content) {
|
|
|
70
75
|
}
|
|
71
76
|
return null;
|
|
72
77
|
}
|
|
73
|
-
|
|
78
|
+
function runSecurityGateChecks(hookInput) {
|
|
79
|
+
const messages = [];
|
|
74
80
|
try {
|
|
75
|
-
const input = await readStdin();
|
|
76
|
-
const hookInput = JSON.parse(input);
|
|
77
81
|
const { tool_name, tool_input } = hookInput;
|
|
78
82
|
if (tool_name === "Bash" && tool_input.command) {
|
|
79
83
|
const violation = checkBashCommand(tool_input.command);
|
|
80
84
|
if (violation) {
|
|
81
|
-
|
|
82
|
-
message: `SECURITY GATE: Dangerous command pattern detected: ${violation}
|
|
85
|
+
messages.push(`SECURITY GATE: Dangerous command pattern detected: ${violation}
|
|
83
86
|
Command: ${tool_input.command.slice(0, 200)}
|
|
84
|
-
Review carefully before proceeding.`
|
|
85
|
-
}));
|
|
87
|
+
Review carefully before proceeding.`);
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
90
|
if ((tool_name === "Write" || tool_name === "Edit") && tool_input.file_path) {
|
|
89
91
|
const violation = checkFilePath(tool_input.file_path);
|
|
90
92
|
if (violation) {
|
|
91
|
-
|
|
92
|
-
message: `SECURITY GATE: Attempt to write to protected file: ${violation}
|
|
93
|
+
messages.push(`SECURITY GATE: Attempt to write to protected file: ${violation}
|
|
93
94
|
Path: ${tool_input.file_path}
|
|
94
|
-
Ensure this is intentional and no secrets will be exposed.`
|
|
95
|
-
}));
|
|
95
|
+
Ensure this is intentional and no secrets will be exposed.`);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
const pyContent = tool_input.content || tool_input.new_string;
|
|
99
99
|
if ((tool_name === "Write" || tool_name === "Edit") && tool_input.file_path?.endsWith(".py") && pyContent) {
|
|
100
100
|
const pyViolation = checkPythonContent(pyContent);
|
|
101
101
|
if (pyViolation) {
|
|
102
|
-
|
|
103
|
-
message: `SECURITY GATE: Dangerous Python pattern detected: ${pyViolation}
|
|
102
|
+
messages.push(`SECURITY GATE: Dangerous Python pattern detected: ${pyViolation}
|
|
104
103
|
File: ${tool_input.file_path}
|
|
105
|
-
Review carefully before proceeding.`
|
|
106
|
-
}));
|
|
104
|
+
Review carefully before proceeding.`);
|
|
107
105
|
}
|
|
108
106
|
}
|
|
109
107
|
} catch {
|
|
110
108
|
}
|
|
109
|
+
return messages;
|
|
110
|
+
}
|
|
111
|
+
async function main() {
|
|
112
|
+
try {
|
|
113
|
+
const input = await readStdin();
|
|
114
|
+
const hookInput = JSON.parse(input);
|
|
115
|
+
const messages = runSecurityGateChecks(hookInput);
|
|
116
|
+
for (const msg of messages) writeHookMessage(msg);
|
|
117
|
+
} catch {
|
|
118
|
+
}
|
|
111
119
|
process.exit(0);
|
|
112
120
|
}
|
|
113
121
|
function readStdin() {
|
|
@@ -121,4 +129,9 @@ function readStdin() {
|
|
|
121
129
|
setTimeout(() => resolve(data), 400);
|
|
122
130
|
});
|
|
123
131
|
}
|
|
124
|
-
|
|
132
|
+
if (process.argv[1]?.endsWith("security-gate.js") || process.argv[1]?.endsWith("security-gate")) {
|
|
133
|
+
main();
|
|
134
|
+
}
|
|
135
|
+
export {
|
|
136
|
+
runSecurityGateChecks
|
|
137
|
+
};
|
|
@@ -348,6 +348,22 @@ var RawConfigSchema = z.object({
|
|
|
348
348
|
accessScopes: z.array(z.string()).optional(),
|
|
349
349
|
domains: z.array(DomainConfigSchema).default([]),
|
|
350
350
|
rules: z.array(PatternRuleConfigSchema).default([]),
|
|
351
|
+
// P-M-036 (plan-stage-d-medium-sweep): customer-authored CR-style
|
|
352
|
+
// governance rules. DISTINCT from `rules:` above (path-scoped lint hints
|
|
353
|
+
// used by pattern-scanner). At config-refresh time these entries are
|
|
354
|
+
// loaded into the `knowledge_rules` SQLite table with
|
|
355
|
+
// `source = 'customer-config'` so `massu_knowledge_rule` and the
|
|
356
|
+
// governance docs surface customer-defined rules alongside framework CRs.
|
|
357
|
+
governance_rules: z.array(
|
|
358
|
+
z.object({
|
|
359
|
+
id: z.string().min(1, "governance_rules[].id is required"),
|
|
360
|
+
title: z.string().min(1, "governance_rules[].title is required"),
|
|
361
|
+
description: z.string().min(1, "governance_rules[].description is required"),
|
|
362
|
+
vr_type: z.string().default("VR-CUSTOM"),
|
|
363
|
+
reference_path: z.string().optional(),
|
|
364
|
+
severity: z.enum(["critical", "high", "medium", "low", "info"]).default("medium")
|
|
365
|
+
}).passthrough()
|
|
366
|
+
).default([]),
|
|
351
367
|
analytics: AnalyticsConfigSchema,
|
|
352
368
|
governance: GovernanceConfigSchema,
|
|
353
369
|
security: SecurityConfigSchema,
|
|
@@ -466,6 +482,8 @@ Hint: run \`massu config refresh\` to regenerate a valid config or fix the liste
|
|
|
466
482
|
accessScopes: parsed.accessScopes,
|
|
467
483
|
domains: parsed.domains,
|
|
468
484
|
rules: parsed.rules,
|
|
485
|
+
// P-M-036: customer-authored CR-style governance rules.
|
|
486
|
+
governance_rules: parsed.governance_rules,
|
|
469
487
|
analytics: parsed.analytics,
|
|
470
488
|
governance: parsed.governance,
|
|
471
489
|
security: parsed.security,
|
|
@@ -1018,6 +1036,12 @@ function initMemorySchema(db) {
|
|
|
1018
1036
|
features TEXT DEFAULT '[]'
|
|
1019
1037
|
);
|
|
1020
1038
|
`);
|
|
1039
|
+
const licenseCacheCols = db.prepare(`PRAGMA table_info(license_cache)`).all();
|
|
1040
|
+
if (!licenseCacheCols.some((c) => c.name === "signed_payload_json")) {
|
|
1041
|
+
db.exec(
|
|
1042
|
+
`ALTER TABLE license_cache ADD COLUMN signed_payload_json TEXT NOT NULL DEFAULT ''`
|
|
1043
|
+
);
|
|
1044
|
+
}
|
|
1021
1045
|
db.exec(`
|
|
1022
1046
|
CREATE TABLE IF NOT EXISTS failure_classes (
|
|
1023
1047
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|