@massu/core 2.5.2 → 2.5.3
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 +70 -0
- package/agents/massu-output-scorer.md +2 -2
- package/agents/massu-plan-auditor.md +1 -1
- package/commands/_shared-references/test-first-protocol.md +4 -4
- package/commands/_shared-references/verification-table.md +5 -5
- package/commands/massu-audit-deps.md +2 -2
- package/commands/massu-batch.md +3 -3
- package/commands/massu-checkpoint.md +7 -7
- package/commands/massu-ci-fix.md +1 -1
- package/commands/massu-cleanup.md +16 -16
- package/commands/massu-commit.md +7 -7
- package/commands/massu-create-plan.md +7 -7
- package/commands/massu-dead-code.md +3 -3
- package/commands/massu-debug/references/common-shortcuts.md +1 -1
- package/commands/massu-debug/references/investigation-phases.md +4 -4
- package/commands/massu-debug/references/report-format.md +2 -2
- package/commands/massu-deploy.md +1 -1
- package/commands/massu-deps.md +5 -5
- package/commands/massu-doc-gen.md +3 -3
- package/commands/massu-docs.md +6 -6
- package/commands/massu-estimate.md +3 -3
- package/commands/massu-golden-path/references/competitive-mode.md +2 -2
- package/commands/massu-golden-path/references/phase-1-plan-creation.md +1 -1
- package/commands/massu-golden-path/references/phase-2-implementation.md +2 -2
- package/commands/massu-golden-path/references/phase-4-commit.md +3 -3
- package/commands/massu-golden-path/references/phase-5-push.md +5 -5
- package/commands/massu-guide.md +3 -3
- package/commands/massu-hotfix.md +14 -14
- package/commands/massu-loop/references/checkpoint-audit.md +3 -3
- package/commands/massu-loop/references/iteration-structure.md +3 -3
- package/commands/massu-loop/references/loop-controller.md +5 -5
- package/commands/massu-loop/references/plan-extraction.md +4 -4
- package/commands/massu-loop/references/vr-plan-spec.md +3 -3
- package/commands/massu-loop-playwright.md +5 -5
- package/commands/massu-loop.md +1 -1
- package/commands/massu-new-feature.md +6 -24
- package/commands/massu-perf.md +1 -1
- package/commands/massu-plan.md +21 -21
- package/commands/massu-push-light.md +9 -9
- package/commands/massu-recap.md +1 -1
- package/commands/massu-refactor.md +8 -8
- package/commands/massu-release.md +3 -3
- package/commands/massu-review.md +1 -1
- package/commands/massu-rollback.md +6 -6
- package/commands/massu-scaffold-page.md +1 -1
- package/commands/massu-scaffold-router.md +1 -1
- package/commands/massu-status.md +9 -9
- package/commands/massu-tdd.md +2 -2
- package/commands/massu-test.md +13 -13
- package/commands/massu-verify-playwright.md +1 -1
- package/commands/massu-verify.md +20 -20
- package/dist/cli.js +1265 -876
- package/dist/hooks/auto-learning-pipeline.js +517 -56
- package/dist/hooks/classify-failure.js +495 -47
- package/dist/hooks/cost-tracker.js +65 -27
- package/dist/hooks/fix-detector.js +496 -47
- package/dist/hooks/incident-pipeline.js +72 -28
- package/dist/hooks/intent-suggester.js +65 -27
- package/dist/hooks/memory-recall.js +65 -27
- package/dist/hooks/post-edit-context.js +65 -27
- package/dist/hooks/post-tool-use.js +70 -29
- package/dist/hooks/pre-compact.js +65 -27
- package/dist/hooks/pre-delete-check.js +65 -27
- package/dist/hooks/pre-tool-use-gate.js +193 -37
- package/dist/hooks/quality-event.js +65 -27
- package/dist/hooks/rule-enforcement-pipeline.js +65 -27
- package/dist/hooks/security-gate.js +197 -38
- package/dist/hooks/session-end.js +68 -27
- package/dist/hooks/session-start.js +116 -61
- package/dist/hooks/user-prompt.js +65 -27
- package/fragments/feature-components.md +15 -0
- package/fragments/feature-components.python.md +15 -0
- package/fragments/feature-components.typescript.md +15 -0
- package/package.json +6 -5
- package/patterns/testing-patterns.md +8 -8
- package/protocols/plan-implementation.md +2 -2
- package/protocols/verification.md +4 -4
- package/reference/lessons-learned.md +4 -4
- package/reference/vr-verification-reference.md +9 -9
- package/templates/aspnet/massu.config.yaml +2 -0
- package/templates/go-chi/massu.config.yaml +2 -0
- package/templates/multi-runtime/massu.config.yaml +4 -2
- package/templates/phoenix/massu.config.yaml +2 -0
- package/templates/python-django/massu.config.yaml +3 -1
- package/templates/python-fastapi/massu.config.yaml +3 -1
- package/templates/python-flask/massu.config.yaml +3 -1
- package/templates/rails/massu.config.yaml +4 -2
- package/templates/rust-actix/massu.config.yaml +2 -0
- package/templates/spring/massu.config.yaml +2 -0
- package/templates/swift-ios/massu.config.yaml +3 -1
- package/templates/ts-nestjs/massu.config.yaml +2 -0
- package/templates/ts-nextjs/massu.config.yaml +2 -0
|
@@ -574,6 +574,15 @@ var init_memory_path = __esm({
|
|
|
574
574
|
}
|
|
575
575
|
});
|
|
576
576
|
|
|
577
|
+
// src/lib/corrections-md.ts
|
|
578
|
+
var CORRECTIONS_FILENAME;
|
|
579
|
+
var init_corrections_md = __esm({
|
|
580
|
+
"src/lib/corrections-md.ts"() {
|
|
581
|
+
"use strict";
|
|
582
|
+
CORRECTIONS_FILENAME = "corrections.md";
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
|
|
577
586
|
// src/config-memory-schema.ts
|
|
578
587
|
import { z } from "zod";
|
|
579
588
|
var MemoryConfigSchema;
|
|
@@ -607,7 +616,7 @@ var init_config_memory_schema = __esm({
|
|
|
607
616
|
message: "memory.recall.embedEndpoint must be an http(s) URL"
|
|
608
617
|
}).optional(),
|
|
609
618
|
embedModel: z.string().min(1).optional()
|
|
610
|
-
}).
|
|
619
|
+
}).prefault({}),
|
|
611
620
|
// --- Contradiction / supersede gate (plan-living-memory-slice-2-temporal-model, P5-001) ---
|
|
612
621
|
// When a new high-value memory (decision/correction) is written, find
|
|
613
622
|
// semantically-related existing records and, if the new one contradicts an
|
|
@@ -636,7 +645,7 @@ var init_config_memory_schema = __esm({
|
|
|
636
645
|
annotateSuperseded: z.boolean().default(false),
|
|
637
646
|
// Time budget (ms) for the contradiction check; exceeded → fail-open (ADD).
|
|
638
647
|
budgetMs: z.number().int().positive().default(800)
|
|
639
|
-
}).
|
|
648
|
+
}).prefault({}),
|
|
640
649
|
// --- Background consolidation, the "sleep-time" pass
|
|
641
650
|
// (plan-living-memory-slice-3-consolidation) ---
|
|
642
651
|
// Keeps memory sharp over years: dedupes, distills dying sessions into
|
|
@@ -682,7 +691,7 @@ var init_config_memory_schema = __esm({
|
|
|
682
691
|
// Surface optional upgrades (e.g. "a local model was detected") in chat.
|
|
683
692
|
suggestUpgrades: z.boolean().default(true),
|
|
684
693
|
suggestIntervalDays: z.number().int().positive().default(30)
|
|
685
|
-
}).
|
|
694
|
+
}).prefault({}),
|
|
686
695
|
// A-20 (Slice 4) — memory FILES: the mirror, and the one switch that decides whether
|
|
687
696
|
// Massu may ever WRITE into the user's memory directory.
|
|
688
697
|
//
|
|
@@ -707,7 +716,7 @@ var init_config_memory_schema = __esm({
|
|
|
707
716
|
// turn of EVERY session, so an unbounded index is a permanent context tax — and the
|
|
708
717
|
// per-session cap bounds only the RATE, never the total.
|
|
709
718
|
indexMaxLines: z.number().int().min(1).default(50)
|
|
710
|
-
}).
|
|
719
|
+
}).prefault({}),
|
|
711
720
|
// --- Cross-repo memory surfacing (plan-living-memory-slice-5-cross-repo-surfacing) ---
|
|
712
721
|
// A decision made in one of your repos can surface in another — opt-in per
|
|
713
722
|
// decision AND opt-in per repo, signed, verified, and materialized ONLY on
|
|
@@ -732,8 +741,8 @@ var init_config_memory_schema = __esm({
|
|
|
732
741
|
enabled: z.boolean().default(true),
|
|
733
742
|
maxCrossRepoItems: z.number().int().min(0).default(1),
|
|
734
743
|
minScore: z.number().optional()
|
|
735
|
-
}).
|
|
736
|
-
}).
|
|
744
|
+
}).prefault({})
|
|
745
|
+
}).prefault({})
|
|
737
746
|
}).optional();
|
|
738
747
|
}
|
|
739
748
|
});
|
|
@@ -913,13 +922,19 @@ function getResolvedPaths() {
|
|
|
913
922
|
settingsLocalPath: resolve2(root, claudeDirName, "settings.local.json")
|
|
914
923
|
};
|
|
915
924
|
}
|
|
916
|
-
var DomainConfigSchema, PatternRuleConfigSchema, CostModelSchema, AnalyticsConfigSchema, CustomPatternSchema, GovernanceConfigSchema, SecurityPatternSchema, SecurityConfigSchema, TeamConfigSchema, RegressionConfigSchema, AutoLearningConfigSchema, CloudConfigSchema, ConventionsConfigSchema, PythonDomainConfigSchema, PythonConfigSchema, PathsConfigSchema, LanguageFrameworkEntrySchema, FrameworkConfigSchema, DetectedConfigSchema, VerificationEntrySchema, VerificationConfigSchema, CanonicalPathsSchema, VerificationTypesSchema, DetectionRuleEntrySchema, DetectionConfigSchema, WatchConfigSchema, AdapterLocalPathSchema, AdaptersConfigSchema, TelemetryConfigSchema, LSPConfigSchema, RawConfigSchema, _config, _resolvedApiKeySource, _projectRoot;
|
|
925
|
+
var DEFAULT_KNOWLEDGE_SOURCE_FILES, DomainConfigSchema, PatternRuleConfigSchema, CostModelSchema, AnalyticsConfigSchema, CustomPatternSchema, GovernanceConfigSchema, SecurityPatternSchema, SecurityConfigSchema, TeamConfigSchema, RegressionConfigSchema, AutoLearningConfigSchema, CloudConfigSchema, ConventionsConfigSchema, PythonDomainConfigSchema, PythonConfigSchema, PathsConfigSchema, LanguageFrameworkEntrySchema, FrameworkConfigSchema, DetectedConfigSchema, VerificationEntrySchema, VerificationConfigSchema, CanonicalPathsSchema, VerificationTypesSchema, DetectionRuleEntrySchema, DetectionConfigSchema, WatchConfigSchema, AdapterLocalPathSchema, AdaptersConfigSchema, TelemetryConfigSchema, LSPConfigSchema, RawConfigSchema, _config, _resolvedApiKeySource, _projectRoot;
|
|
917
926
|
var init_config = __esm({
|
|
918
927
|
"src/config.ts"() {
|
|
919
928
|
"use strict";
|
|
920
929
|
init_memory_path();
|
|
930
|
+
init_corrections_md();
|
|
921
931
|
init_credentials();
|
|
922
932
|
init_config_memory_schema();
|
|
933
|
+
DEFAULT_KNOWLEDGE_SOURCE_FILES = [
|
|
934
|
+
"CLAUDE.md",
|
|
935
|
+
"MEMORY.md",
|
|
936
|
+
CORRECTIONS_FILENAME
|
|
937
|
+
];
|
|
923
938
|
DomainConfigSchema = z2.object({
|
|
924
939
|
name: z2.string().default("Unknown"),
|
|
925
940
|
routers: z2.array(z2.string()).default([]),
|
|
@@ -1048,34 +1063,40 @@ var init_config = __esm({
|
|
|
1048
1063
|
fixDetection: z2.object({
|
|
1049
1064
|
enabled: z2.boolean().default(true),
|
|
1050
1065
|
lookbackDays: z2.number().default(7),
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1066
|
+
// ⛔ NO DEFAULT LIST HERE, DELIBERATELY — the heuristics are the SSOT.
|
|
1067
|
+
//
|
|
1068
|
+
// This carried a hand-typed copy of all eight signal names while
|
|
1069
|
+
// `fix-detector.ts` already read `config…signals ?? FIX_HEURISTICS.map(h => h.name)`.
|
|
1070
|
+
// Because zod ALWAYS materialised the default, that fallback — the correct expression
|
|
1071
|
+
// — was unreachable, and the duplicate was the only thing in effect. Two authoring
|
|
1072
|
+
// sites for one vocabulary, and the drift is SILENT: a name listed here that no longer
|
|
1073
|
+
// exists simply never matches `enabledSignals.has(...)`, so a retired heuristic lingers
|
|
1074
|
+
// as a dead entry with no error. Retiring `method_name_correction` would have landed at
|
|
1075
|
+
// one site of two (CR-74).
|
|
1076
|
+
//
|
|
1077
|
+
// Optional, so an ABSENT value reaches the `??` and the heuristic list defines itself
|
|
1078
|
+
// (Rule 25). An explicit list in massu.config.yaml still overrides, which is the only
|
|
1079
|
+
// behaviour anyone actually configured — measured: `fix-detector.ts:267` is the sole
|
|
1080
|
+
// consumer and no config file in the repo sets it.
|
|
1081
|
+
signals: z2.array(z2.string()).optional()
|
|
1082
|
+
}).prefault({}),
|
|
1062
1083
|
failureClassification: z2.object({
|
|
1063
1084
|
enabled: z2.boolean().default(true),
|
|
1064
1085
|
thresholds: z2.object({
|
|
1065
1086
|
known: z2.number().default(5),
|
|
1066
1087
|
similar: z2.number().default(3)
|
|
1067
|
-
}).
|
|
1088
|
+
}).prefault({}),
|
|
1068
1089
|
scoring: z2.object({
|
|
1069
1090
|
diffPatternWeight: z2.number().default(3),
|
|
1070
1091
|
filePatternWeight: z2.number().default(2),
|
|
1071
1092
|
promptKeywordWeight: z2.number().default(2)
|
|
1072
|
-
}).
|
|
1073
|
-
}).
|
|
1093
|
+
}).prefault({})
|
|
1094
|
+
}).prefault({}),
|
|
1074
1095
|
pipeline: z2.object({
|
|
1075
1096
|
requireIncidentReport: z2.boolean().default(true),
|
|
1076
1097
|
requirePreventionRule: z2.boolean().default(true),
|
|
1077
1098
|
requireEnforcement: z2.boolean().default(true)
|
|
1078
|
-
}).
|
|
1099
|
+
}).prefault({}),
|
|
1079
1100
|
// plan-v0.2-interactive-rule-approval P-D-008 / P-D-009: project-configured
|
|
1080
1101
|
// custom destinations for the rule-candidate funnel. The classifier matches
|
|
1081
1102
|
// a candidate to one of these entries when none of the framework
|
|
@@ -1108,7 +1129,7 @@ var init_config = __esm({
|
|
|
1108
1129
|
memory: z2.boolean().default(true),
|
|
1109
1130
|
analytics: z2.boolean().default(true),
|
|
1110
1131
|
audit: z2.boolean().default(true)
|
|
1111
|
-
}).
|
|
1132
|
+
}).prefault({ memory: true, analytics: true, audit: true })
|
|
1112
1133
|
}).optional();
|
|
1113
1134
|
ConventionsConfigSchema = z2.object({
|
|
1114
1135
|
claudeDirName: z2.string().default(".claude").refine(
|
|
@@ -1139,7 +1160,7 @@ var init_config = __esm({
|
|
|
1139
1160
|
"session-state",
|
|
1140
1161
|
"agents"
|
|
1141
1162
|
]),
|
|
1142
|
-
knowledgeSourceFiles: z2.array(z2.string()).default([
|
|
1163
|
+
knowledgeSourceFiles: z2.array(z2.string()).default([...DEFAULT_KNOWLEDGE_SOURCE_FILES]),
|
|
1143
1164
|
excludePatterns: z2.array(z2.string()).default(["/ARCHIVE/", "/SESSION-HISTORY/"])
|
|
1144
1165
|
}).optional();
|
|
1145
1166
|
PythonDomainConfigSchema = z2.object({
|
|
@@ -1155,6 +1176,23 @@ var init_config = __esm({
|
|
|
1155
1176
|
}).optional();
|
|
1156
1177
|
PathsConfigSchema = z2.object({
|
|
1157
1178
|
source: z2.string().default("src"),
|
|
1179
|
+
/**
|
|
1180
|
+
* Where this stack's tests live, relative to the project root.
|
|
1181
|
+
*
|
|
1182
|
+
* Added 2026-09-20 for P4.3 of docs/plans/2026-09-20-stack-conformant-asset-rendering.md.
|
|
1183
|
+
* ~25 shipped assets told every customer their tests belong in
|
|
1184
|
+
* `packages/core/src/__tests__/` — massu's OWN layout — and no vocabulary could express
|
|
1185
|
+
* the alternative because none existed. A test directory is a first-class property of
|
|
1186
|
+
* every stack (`tests/` on FastAPI, `test/` on Rails, `src/test/java` on Spring,
|
|
1187
|
+
* `Tests/` on SwiftPM, and Go keeps `_test.go` beside the source), so it belongs here
|
|
1188
|
+
* rather than in prose.
|
|
1189
|
+
*
|
|
1190
|
+
* OPTIONAL, so every config written before this key existed keeps loading unchanged; an
|
|
1191
|
+
* asset that needs it uses `{{paths.tests | default("...")}}`. All 13 shipped templates
|
|
1192
|
+
* declare it, each with the convention it follows recorded at the site (G32 option 2),
|
|
1193
|
+
* and `stack-template-conformance.test.ts` asserts that.
|
|
1194
|
+
*/
|
|
1195
|
+
tests: z2.string().optional(),
|
|
1158
1196
|
aliases: z2.record(z2.string(), z2.string()).default({ "@": "src" }),
|
|
1159
1197
|
monorepo_roots: z2.array(z2.string()).optional(),
|
|
1160
1198
|
routers: z2.string().optional(),
|
|
@@ -1264,14 +1302,14 @@ var init_config = __esm({
|
|
|
1264
1302
|
project: z2.object({
|
|
1265
1303
|
name: z2.string().default("my-project"),
|
|
1266
1304
|
root: z2.string().default("auto")
|
|
1267
|
-
}).
|
|
1268
|
-
framework: FrameworkConfigSchema.
|
|
1305
|
+
}).prefault({ name: "my-project", root: "auto" }),
|
|
1306
|
+
framework: FrameworkConfigSchema.prefault({
|
|
1269
1307
|
type: "typescript",
|
|
1270
1308
|
router: "none",
|
|
1271
1309
|
orm: "none",
|
|
1272
1310
|
ui: "none"
|
|
1273
1311
|
}),
|
|
1274
|
-
paths: PathsConfigSchema.
|
|
1312
|
+
paths: PathsConfigSchema.prefault({ source: "src", aliases: { "@": "src" } }),
|
|
1275
1313
|
toolPrefix: z2.string().default("massu"),
|
|
1276
1314
|
dbAccessPattern: z2.string().optional(),
|
|
1277
1315
|
knownMismatches: z2.record(z2.string(), z2.record(z2.string(), z2.string())).optional(),
|
|
@@ -4081,6 +4119,76 @@ var PROTECTED_FILE_PATTERNS = [
|
|
|
4081
4119
|
{ pattern: /aws\/credentials$/, label: "AWS credentials file" },
|
|
4082
4120
|
{ pattern: /kubeconfig$/, label: "Kubernetes config file" }
|
|
4083
4121
|
];
|
|
4122
|
+
var SECRET_BASENAME_EXTENSIONS = ["pem", "key", "p12", "pfx", "secret"];
|
|
4123
|
+
var DOTENV_TEMPLATE_SUFFIXES = ["example", "template", "sample", "defaults", "dist"];
|
|
4124
|
+
var SECRET_EXACT_BASENAMES = [
|
|
4125
|
+
"id_rsa",
|
|
4126
|
+
"id_ed25519",
|
|
4127
|
+
"id_ecdsa",
|
|
4128
|
+
".netrc",
|
|
4129
|
+
"kubeconfig",
|
|
4130
|
+
"credentials.json",
|
|
4131
|
+
"secrets.yaml",
|
|
4132
|
+
"secrets.yml"
|
|
4133
|
+
];
|
|
4134
|
+
var CREDENTIALS_PATH_SUFFIX = "/credentials";
|
|
4135
|
+
var DOTENV = ".env";
|
|
4136
|
+
function looksLikeCode(token) {
|
|
4137
|
+
return /[()[\]{};=`$<>|&*?!"']/.test(token) || /\s/.test(token);
|
|
4138
|
+
}
|
|
4139
|
+
function namesSecretFile(token) {
|
|
4140
|
+
if (!token || looksLikeCode(token)) return null;
|
|
4141
|
+
const clean = token.replace(/[,:.]+$/, "");
|
|
4142
|
+
if (!clean) return null;
|
|
4143
|
+
const base = clean.split("/").pop() ?? "";
|
|
4144
|
+
if (!base) return null;
|
|
4145
|
+
if (SECRET_EXACT_BASENAMES.includes(base)) return base;
|
|
4146
|
+
if (clean.endsWith(".ssh/config")) return "SSH config file";
|
|
4147
|
+
if (clean.endsWith(CREDENTIALS_PATH_SUFFIX)) return "credentials file";
|
|
4148
|
+
if (base === DOTENV) return `${DOTENV} file`;
|
|
4149
|
+
if (base.startsWith(`${DOTENV}.`)) {
|
|
4150
|
+
const suffix = base.slice(DOTENV.length + 1);
|
|
4151
|
+
return DOTENV_TEMPLATE_SUFFIXES.includes(suffix) ? null : `${base} file`;
|
|
4152
|
+
}
|
|
4153
|
+
if (base.endsWith(DOTENV) && clean.includes("/")) return `${base} file`;
|
|
4154
|
+
for (const ext of SECRET_BASENAME_EXTENSIONS) {
|
|
4155
|
+
if (base.endsWith(`.${ext}`)) return `${base} file`;
|
|
4156
|
+
}
|
|
4157
|
+
return null;
|
|
4158
|
+
}
|
|
4159
|
+
function shellTokens(command) {
|
|
4160
|
+
const out = [];
|
|
4161
|
+
let cur = "";
|
|
4162
|
+
let quote = null;
|
|
4163
|
+
for (const ch of command) {
|
|
4164
|
+
if (quote) {
|
|
4165
|
+
if (ch === quote) quote = null;
|
|
4166
|
+
else cur += ch;
|
|
4167
|
+
continue;
|
|
4168
|
+
}
|
|
4169
|
+
if (ch === "'" || ch === '"') {
|
|
4170
|
+
quote = ch;
|
|
4171
|
+
cur += ch;
|
|
4172
|
+
continue;
|
|
4173
|
+
}
|
|
4174
|
+
if (/\s/.test(ch)) {
|
|
4175
|
+
if (cur) out.push(cur);
|
|
4176
|
+
cur = "";
|
|
4177
|
+
continue;
|
|
4178
|
+
}
|
|
4179
|
+
cur += ch;
|
|
4180
|
+
}
|
|
4181
|
+
if (cur) out.push(cur);
|
|
4182
|
+
return out;
|
|
4183
|
+
}
|
|
4184
|
+
function secretFilesInCommand(command) {
|
|
4185
|
+
const hits = [];
|
|
4186
|
+
for (const token of shellTokens(command)) {
|
|
4187
|
+
const label = namesSecretFile(token);
|
|
4188
|
+
if (label) hits.push(label);
|
|
4189
|
+
}
|
|
4190
|
+
return hits;
|
|
4191
|
+
}
|
|
4084
4192
|
function checkBashCommand(command) {
|
|
4085
4193
|
for (const { pattern, label, severity } of DANGEROUS_BASH_PATTERNS) {
|
|
4086
4194
|
if (pattern.test(command)) {
|
|
@@ -4098,18 +4206,57 @@ function checkFilePath(filePath) {
|
|
|
4098
4206
|
return null;
|
|
4099
4207
|
}
|
|
4100
4208
|
var DANGEROUS_PYTHON_PATTERNS = [
|
|
4101
|
-
{ pattern: /\beval\s*\(/, label: "Python eval() \u2014 arbitrary code execution" },
|
|
4102
|
-
{ pattern: /\bexec\s*\(/, label: "Python exec() \u2014 arbitrary code execution" },
|
|
4103
|
-
{ pattern: /\b__import__\s*\(/, label: "Python __import__() \u2014 dynamic import (potential code injection)" },
|
|
4104
|
-
{ pattern: /subprocess\.call\([^)]*shell\s*=\s*True/, label: "subprocess.call(shell=True) \u2014 shell injection risk" },
|
|
4105
|
-
{ pattern: /subprocess\.Popen\([^)]*shell\s*=\s*True/, label: "subprocess.Popen(shell=True) \u2014 shell injection risk" },
|
|
4106
|
-
{ pattern: /os\.system\s*\(/, label: "os.system() \u2014 shell injection risk" },
|
|
4107
|
-
{ pattern: /\bf['"].*\{.*\}.*['"].*(?:execute|cursor|query)/, label: "f-string in SQL \u2014 SQL injection risk" },
|
|
4108
|
-
{ pattern: /['"].*%s.*['"].*%.*(?:execute|cursor|query)/, label: "String formatting in SQL \u2014 SQL injection risk" }
|
|
4209
|
+
{ pattern: /\beval\s*\(/, label: "Python eval() \u2014 arbitrary code execution", scope: "code" },
|
|
4210
|
+
{ pattern: /\bexec\s*\(/, label: "Python exec() \u2014 arbitrary code execution", scope: "code" },
|
|
4211
|
+
{ pattern: /\b__import__\s*\(/, label: "Python __import__() \u2014 dynamic import (potential code injection)", scope: "code" },
|
|
4212
|
+
{ pattern: /subprocess\.call\([^)]*shell\s*=\s*True/, label: "subprocess.call(shell=True) \u2014 shell injection risk", scope: "code" },
|
|
4213
|
+
{ pattern: /subprocess\.Popen\([^)]*shell\s*=\s*True/, label: "subprocess.Popen(shell=True) \u2014 shell injection risk", scope: "code" },
|
|
4214
|
+
{ pattern: /os\.system\s*\(/, label: "os.system() \u2014 shell injection risk", scope: "code" },
|
|
4215
|
+
{ pattern: /\bf['"].*\{.*\}.*['"].*(?:execute|cursor|query)/, label: "f-string in SQL \u2014 SQL injection risk", scope: "raw" },
|
|
4216
|
+
{ pattern: /['"].*%s.*['"].*%.*(?:execute|cursor|query)/, label: "String formatting in SQL \u2014 SQL injection risk", scope: "raw" }
|
|
4109
4217
|
];
|
|
4218
|
+
function stripPythonCommentsAndStringBodies(src) {
|
|
4219
|
+
let out = "";
|
|
4220
|
+
let i = 0;
|
|
4221
|
+
while (i < src.length) {
|
|
4222
|
+
const ch = src[i];
|
|
4223
|
+
if (ch === "#") {
|
|
4224
|
+
while (i < src.length && src[i] !== "\n") i++;
|
|
4225
|
+
continue;
|
|
4226
|
+
}
|
|
4227
|
+
if (ch === '"' || ch === "'") {
|
|
4228
|
+
const triple = src.startsWith(ch.repeat(3), i);
|
|
4229
|
+
const delim = triple ? ch.repeat(3) : ch;
|
|
4230
|
+
out += delim;
|
|
4231
|
+
i += delim.length;
|
|
4232
|
+
let closed = false;
|
|
4233
|
+
while (i < src.length) {
|
|
4234
|
+
if (src[i] === "\\") {
|
|
4235
|
+
i += 2;
|
|
4236
|
+
continue;
|
|
4237
|
+
}
|
|
4238
|
+
if (src.startsWith(delim, i)) {
|
|
4239
|
+
out += delim;
|
|
4240
|
+
i += delim.length;
|
|
4241
|
+
closed = true;
|
|
4242
|
+
break;
|
|
4243
|
+
}
|
|
4244
|
+
if (!triple && src[i] === "\n") break;
|
|
4245
|
+
i++;
|
|
4246
|
+
}
|
|
4247
|
+
if (!closed) return null;
|
|
4248
|
+
continue;
|
|
4249
|
+
}
|
|
4250
|
+
out += ch;
|
|
4251
|
+
i++;
|
|
4252
|
+
}
|
|
4253
|
+
return out;
|
|
4254
|
+
}
|
|
4110
4255
|
function checkPythonContent(content) {
|
|
4111
|
-
|
|
4112
|
-
|
|
4256
|
+
const stripped = stripPythonCommentsAndStringBodies(content);
|
|
4257
|
+
for (const { pattern, label, scope } of DANGEROUS_PYTHON_PATTERNS) {
|
|
4258
|
+
const subject = scope === "raw" || stripped === null ? content : stripped;
|
|
4259
|
+
if (pattern.test(subject)) {
|
|
4113
4260
|
return label;
|
|
4114
4261
|
}
|
|
4115
4262
|
}
|
|
@@ -4119,6 +4266,15 @@ function runSecurityGateFindings(hookInput) {
|
|
|
4119
4266
|
const findings = [];
|
|
4120
4267
|
const { tool_name, tool_input } = hookInput;
|
|
4121
4268
|
if (tool_name === "Bash" && tool_input.command) {
|
|
4269
|
+
const secretFiles = secretFilesInCommand(tool_input.command);
|
|
4270
|
+
if (secretFiles.length > 0) {
|
|
4271
|
+
findings.push({
|
|
4272
|
+
severity: "block",
|
|
4273
|
+
message: `SECURITY GATE: command names a secret file: ${secretFiles.join(", ")}
|
|
4274
|
+
Command: ${tool_input.command.slice(0, 200)}
|
|
4275
|
+
BLOCKED. If this file is a template or fixture, name it with a template suffix (.example/.template/.sample) rather than weakening this check.`
|
|
4276
|
+
});
|
|
4277
|
+
}
|
|
4122
4278
|
const violation = checkBashCommand(tool_input.command);
|
|
4123
4279
|
if (violation) {
|
|
4124
4280
|
findings.push({
|
|
@@ -4186,6 +4342,9 @@ if (isDirectInvocation(import.meta.url)) {
|
|
|
4186
4342
|
main();
|
|
4187
4343
|
}
|
|
4188
4344
|
export {
|
|
4345
|
+
namesSecretFile,
|
|
4189
4346
|
runSecurityGateChecks,
|
|
4190
|
-
runSecurityGateFindings
|
|
4347
|
+
runSecurityGateFindings,
|
|
4348
|
+
secretFilesInCommand,
|
|
4349
|
+
stripPythonCommentsAndStringBodies
|
|
4191
4350
|
};
|
|
@@ -574,6 +574,15 @@ var init_memory_path = __esm({
|
|
|
574
574
|
}
|
|
575
575
|
});
|
|
576
576
|
|
|
577
|
+
// src/lib/corrections-md.ts
|
|
578
|
+
var CORRECTIONS_FILENAME;
|
|
579
|
+
var init_corrections_md = __esm({
|
|
580
|
+
"src/lib/corrections-md.ts"() {
|
|
581
|
+
"use strict";
|
|
582
|
+
CORRECTIONS_FILENAME = "corrections.md";
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
|
|
577
586
|
// src/config-memory-schema.ts
|
|
578
587
|
import { z } from "zod";
|
|
579
588
|
var MemoryConfigSchema;
|
|
@@ -607,7 +616,7 @@ var init_config_memory_schema = __esm({
|
|
|
607
616
|
message: "memory.recall.embedEndpoint must be an http(s) URL"
|
|
608
617
|
}).optional(),
|
|
609
618
|
embedModel: z.string().min(1).optional()
|
|
610
|
-
}).
|
|
619
|
+
}).prefault({}),
|
|
611
620
|
// --- Contradiction / supersede gate (plan-living-memory-slice-2-temporal-model, P5-001) ---
|
|
612
621
|
// When a new high-value memory (decision/correction) is written, find
|
|
613
622
|
// semantically-related existing records and, if the new one contradicts an
|
|
@@ -636,7 +645,7 @@ var init_config_memory_schema = __esm({
|
|
|
636
645
|
annotateSuperseded: z.boolean().default(false),
|
|
637
646
|
// Time budget (ms) for the contradiction check; exceeded → fail-open (ADD).
|
|
638
647
|
budgetMs: z.number().int().positive().default(800)
|
|
639
|
-
}).
|
|
648
|
+
}).prefault({}),
|
|
640
649
|
// --- Background consolidation, the "sleep-time" pass
|
|
641
650
|
// (plan-living-memory-slice-3-consolidation) ---
|
|
642
651
|
// Keeps memory sharp over years: dedupes, distills dying sessions into
|
|
@@ -682,7 +691,7 @@ var init_config_memory_schema = __esm({
|
|
|
682
691
|
// Surface optional upgrades (e.g. "a local model was detected") in chat.
|
|
683
692
|
suggestUpgrades: z.boolean().default(true),
|
|
684
693
|
suggestIntervalDays: z.number().int().positive().default(30)
|
|
685
|
-
}).
|
|
694
|
+
}).prefault({}),
|
|
686
695
|
// A-20 (Slice 4) — memory FILES: the mirror, and the one switch that decides whether
|
|
687
696
|
// Massu may ever WRITE into the user's memory directory.
|
|
688
697
|
//
|
|
@@ -707,7 +716,7 @@ var init_config_memory_schema = __esm({
|
|
|
707
716
|
// turn of EVERY session, so an unbounded index is a permanent context tax — and the
|
|
708
717
|
// per-session cap bounds only the RATE, never the total.
|
|
709
718
|
indexMaxLines: z.number().int().min(1).default(50)
|
|
710
|
-
}).
|
|
719
|
+
}).prefault({}),
|
|
711
720
|
// --- Cross-repo memory surfacing (plan-living-memory-slice-5-cross-repo-surfacing) ---
|
|
712
721
|
// A decision made in one of your repos can surface in another — opt-in per
|
|
713
722
|
// decision AND opt-in per repo, signed, verified, and materialized ONLY on
|
|
@@ -732,8 +741,8 @@ var init_config_memory_schema = __esm({
|
|
|
732
741
|
enabled: z.boolean().default(true),
|
|
733
742
|
maxCrossRepoItems: z.number().int().min(0).default(1),
|
|
734
743
|
minScore: z.number().optional()
|
|
735
|
-
}).
|
|
736
|
-
}).
|
|
744
|
+
}).prefault({})
|
|
745
|
+
}).prefault({})
|
|
737
746
|
}).optional();
|
|
738
747
|
}
|
|
739
748
|
});
|
|
@@ -913,13 +922,19 @@ function getResolvedPaths() {
|
|
|
913
922
|
settingsLocalPath: resolve2(root, claudeDirName, "settings.local.json")
|
|
914
923
|
};
|
|
915
924
|
}
|
|
916
|
-
var DomainConfigSchema, PatternRuleConfigSchema, CostModelSchema, AnalyticsConfigSchema, CustomPatternSchema, GovernanceConfigSchema, SecurityPatternSchema, SecurityConfigSchema, TeamConfigSchema, RegressionConfigSchema, AutoLearningConfigSchema, CloudConfigSchema, ConventionsConfigSchema, PythonDomainConfigSchema, PythonConfigSchema, PathsConfigSchema, LanguageFrameworkEntrySchema, FrameworkConfigSchema, DetectedConfigSchema, VerificationEntrySchema, VerificationConfigSchema, CanonicalPathsSchema, VerificationTypesSchema, DetectionRuleEntrySchema, DetectionConfigSchema, WatchConfigSchema, AdapterLocalPathSchema, AdaptersConfigSchema, TelemetryConfigSchema, LSPConfigSchema, RawConfigSchema, _config, _resolvedApiKeySource, _projectRoot;
|
|
925
|
+
var DEFAULT_KNOWLEDGE_SOURCE_FILES, DomainConfigSchema, PatternRuleConfigSchema, CostModelSchema, AnalyticsConfigSchema, CustomPatternSchema, GovernanceConfigSchema, SecurityPatternSchema, SecurityConfigSchema, TeamConfigSchema, RegressionConfigSchema, AutoLearningConfigSchema, CloudConfigSchema, ConventionsConfigSchema, PythonDomainConfigSchema, PythonConfigSchema, PathsConfigSchema, LanguageFrameworkEntrySchema, FrameworkConfigSchema, DetectedConfigSchema, VerificationEntrySchema, VerificationConfigSchema, CanonicalPathsSchema, VerificationTypesSchema, DetectionRuleEntrySchema, DetectionConfigSchema, WatchConfigSchema, AdapterLocalPathSchema, AdaptersConfigSchema, TelemetryConfigSchema, LSPConfigSchema, RawConfigSchema, _config, _resolvedApiKeySource, _projectRoot;
|
|
917
926
|
var init_config = __esm({
|
|
918
927
|
"src/config.ts"() {
|
|
919
928
|
"use strict";
|
|
920
929
|
init_memory_path();
|
|
930
|
+
init_corrections_md();
|
|
921
931
|
init_credentials();
|
|
922
932
|
init_config_memory_schema();
|
|
933
|
+
DEFAULT_KNOWLEDGE_SOURCE_FILES = [
|
|
934
|
+
"CLAUDE.md",
|
|
935
|
+
"MEMORY.md",
|
|
936
|
+
CORRECTIONS_FILENAME
|
|
937
|
+
];
|
|
923
938
|
DomainConfigSchema = z2.object({
|
|
924
939
|
name: z2.string().default("Unknown"),
|
|
925
940
|
routers: z2.array(z2.string()).default([]),
|
|
@@ -1048,34 +1063,40 @@ var init_config = __esm({
|
|
|
1048
1063
|
fixDetection: z2.object({
|
|
1049
1064
|
enabled: z2.boolean().default(true),
|
|
1050
1065
|
lookbackDays: z2.number().default(7),
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1066
|
+
// ⛔ NO DEFAULT LIST HERE, DELIBERATELY — the heuristics are the SSOT.
|
|
1067
|
+
//
|
|
1068
|
+
// This carried a hand-typed copy of all eight signal names while
|
|
1069
|
+
// `fix-detector.ts` already read `config…signals ?? FIX_HEURISTICS.map(h => h.name)`.
|
|
1070
|
+
// Because zod ALWAYS materialised the default, that fallback — the correct expression
|
|
1071
|
+
// — was unreachable, and the duplicate was the only thing in effect. Two authoring
|
|
1072
|
+
// sites for one vocabulary, and the drift is SILENT: a name listed here that no longer
|
|
1073
|
+
// exists simply never matches `enabledSignals.has(...)`, so a retired heuristic lingers
|
|
1074
|
+
// as a dead entry with no error. Retiring `method_name_correction` would have landed at
|
|
1075
|
+
// one site of two (CR-74).
|
|
1076
|
+
//
|
|
1077
|
+
// Optional, so an ABSENT value reaches the `??` and the heuristic list defines itself
|
|
1078
|
+
// (Rule 25). An explicit list in massu.config.yaml still overrides, which is the only
|
|
1079
|
+
// behaviour anyone actually configured — measured: `fix-detector.ts:267` is the sole
|
|
1080
|
+
// consumer and no config file in the repo sets it.
|
|
1081
|
+
signals: z2.array(z2.string()).optional()
|
|
1082
|
+
}).prefault({}),
|
|
1062
1083
|
failureClassification: z2.object({
|
|
1063
1084
|
enabled: z2.boolean().default(true),
|
|
1064
1085
|
thresholds: z2.object({
|
|
1065
1086
|
known: z2.number().default(5),
|
|
1066
1087
|
similar: z2.number().default(3)
|
|
1067
|
-
}).
|
|
1088
|
+
}).prefault({}),
|
|
1068
1089
|
scoring: z2.object({
|
|
1069
1090
|
diffPatternWeight: z2.number().default(3),
|
|
1070
1091
|
filePatternWeight: z2.number().default(2),
|
|
1071
1092
|
promptKeywordWeight: z2.number().default(2)
|
|
1072
|
-
}).
|
|
1073
|
-
}).
|
|
1093
|
+
}).prefault({})
|
|
1094
|
+
}).prefault({}),
|
|
1074
1095
|
pipeline: z2.object({
|
|
1075
1096
|
requireIncidentReport: z2.boolean().default(true),
|
|
1076
1097
|
requirePreventionRule: z2.boolean().default(true),
|
|
1077
1098
|
requireEnforcement: z2.boolean().default(true)
|
|
1078
|
-
}).
|
|
1099
|
+
}).prefault({}),
|
|
1079
1100
|
// plan-v0.2-interactive-rule-approval P-D-008 / P-D-009: project-configured
|
|
1080
1101
|
// custom destinations for the rule-candidate funnel. The classifier matches
|
|
1081
1102
|
// a candidate to one of these entries when none of the framework
|
|
@@ -1108,7 +1129,7 @@ var init_config = __esm({
|
|
|
1108
1129
|
memory: z2.boolean().default(true),
|
|
1109
1130
|
analytics: z2.boolean().default(true),
|
|
1110
1131
|
audit: z2.boolean().default(true)
|
|
1111
|
-
}).
|
|
1132
|
+
}).prefault({ memory: true, analytics: true, audit: true })
|
|
1112
1133
|
}).optional();
|
|
1113
1134
|
ConventionsConfigSchema = z2.object({
|
|
1114
1135
|
claudeDirName: z2.string().default(".claude").refine(
|
|
@@ -1139,7 +1160,7 @@ var init_config = __esm({
|
|
|
1139
1160
|
"session-state",
|
|
1140
1161
|
"agents"
|
|
1141
1162
|
]),
|
|
1142
|
-
knowledgeSourceFiles: z2.array(z2.string()).default([
|
|
1163
|
+
knowledgeSourceFiles: z2.array(z2.string()).default([...DEFAULT_KNOWLEDGE_SOURCE_FILES]),
|
|
1143
1164
|
excludePatterns: z2.array(z2.string()).default(["/ARCHIVE/", "/SESSION-HISTORY/"])
|
|
1144
1165
|
}).optional();
|
|
1145
1166
|
PythonDomainConfigSchema = z2.object({
|
|
@@ -1155,6 +1176,23 @@ var init_config = __esm({
|
|
|
1155
1176
|
}).optional();
|
|
1156
1177
|
PathsConfigSchema = z2.object({
|
|
1157
1178
|
source: z2.string().default("src"),
|
|
1179
|
+
/**
|
|
1180
|
+
* Where this stack's tests live, relative to the project root.
|
|
1181
|
+
*
|
|
1182
|
+
* Added 2026-09-20 for P4.3 of docs/plans/2026-09-20-stack-conformant-asset-rendering.md.
|
|
1183
|
+
* ~25 shipped assets told every customer their tests belong in
|
|
1184
|
+
* `packages/core/src/__tests__/` — massu's OWN layout — and no vocabulary could express
|
|
1185
|
+
* the alternative because none existed. A test directory is a first-class property of
|
|
1186
|
+
* every stack (`tests/` on FastAPI, `test/` on Rails, `src/test/java` on Spring,
|
|
1187
|
+
* `Tests/` on SwiftPM, and Go keeps `_test.go` beside the source), so it belongs here
|
|
1188
|
+
* rather than in prose.
|
|
1189
|
+
*
|
|
1190
|
+
* OPTIONAL, so every config written before this key existed keeps loading unchanged; an
|
|
1191
|
+
* asset that needs it uses `{{paths.tests | default("...")}}`. All 13 shipped templates
|
|
1192
|
+
* declare it, each with the convention it follows recorded at the site (G32 option 2),
|
|
1193
|
+
* and `stack-template-conformance.test.ts` asserts that.
|
|
1194
|
+
*/
|
|
1195
|
+
tests: z2.string().optional(),
|
|
1158
1196
|
aliases: z2.record(z2.string(), z2.string()).default({ "@": "src" }),
|
|
1159
1197
|
monorepo_roots: z2.array(z2.string()).optional(),
|
|
1160
1198
|
routers: z2.string().optional(),
|
|
@@ -1264,14 +1302,14 @@ var init_config = __esm({
|
|
|
1264
1302
|
project: z2.object({
|
|
1265
1303
|
name: z2.string().default("my-project"),
|
|
1266
1304
|
root: z2.string().default("auto")
|
|
1267
|
-
}).
|
|
1268
|
-
framework: FrameworkConfigSchema.
|
|
1305
|
+
}).prefault({ name: "my-project", root: "auto" }),
|
|
1306
|
+
framework: FrameworkConfigSchema.prefault({
|
|
1269
1307
|
type: "typescript",
|
|
1270
1308
|
router: "none",
|
|
1271
1309
|
orm: "none",
|
|
1272
1310
|
ui: "none"
|
|
1273
1311
|
}),
|
|
1274
|
-
paths: PathsConfigSchema.
|
|
1312
|
+
paths: PathsConfigSchema.prefault({ source: "src", aliases: { "@": "src" } }),
|
|
1275
1313
|
toolPrefix: z2.string().default("massu"),
|
|
1276
1314
|
dbAccessPattern: z2.string().optional(),
|
|
1277
1315
|
knownMismatches: z2.record(z2.string(), z2.record(z2.string(), z2.string())).optional(),
|
|
@@ -5111,6 +5149,9 @@ function deriveSlug(input) {
|
|
|
5111
5149
|
return cleaned.slice(0, 60) || "rule_candidate";
|
|
5112
5150
|
}
|
|
5113
5151
|
|
|
5152
|
+
// src/rule-candidate-applier.ts
|
|
5153
|
+
init_corrections_md();
|
|
5154
|
+
|
|
5114
5155
|
// src/memory-index-region.ts
|
|
5115
5156
|
init_fileLock();
|
|
5116
5157
|
|