@polymorphism-tech/morph-spec 11.1.1 → 11.2.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 +1 -1
- package/bin/morph-spec.js +9 -19
- package/docs/CHEATSHEET.md +3 -3
- package/docs/QUICKSTART.md +1 -1
- package/framework/CLAUDE.md +2 -0
- package/framework/MORPH.md +7 -2
- package/framework/agents.json +3 -3
- package/framework/docs/CLI.md +14 -12
- package/framework/evals/review-checklist.md +9 -16
- package/framework/hooks/README.md +15 -9
- package/framework/hooks/claude-code/core/README.md +2 -2
- package/framework/hooks/claude-code/core/chain.js +9 -25
- package/framework/hooks/claude-code/core/comment-guard.js +3 -9
- package/framework/hooks/claude-code/core/conventional-commit.js +3 -3
- package/framework/hooks/claude-code/core/graph-refresh-kick.js +4 -4
- package/framework/hooks/claude-code/core/masked-exit.js +4 -3
- package/framework/hooks/claude-code/core/pre-bash-denylist.js +2 -2
- package/framework/hooks/claude-code/core/protect-spec-files.js +2 -4
- package/framework/hooks/claude-code/core/stack-changed.js +5 -4
- package/framework/hooks/claude-code/core/validate-completion.js +15 -12
- package/framework/hooks/shared/contract.js +22 -1
- package/framework/hooks/shared/git-paths.js +6 -0
- package/framework/hooks/shared/graph-freshness.js +3 -3
- package/framework/hooks/shared/graph-refresh.js +5 -10
- package/framework/hooks/shared/hook-response.js +1 -18
- package/framework/hooks/shared/payload-utils.js +12 -1
- package/framework/hooks/shared/phase-utils.js +4 -52
- package/framework/hooks/shared/report-progress.js +1 -1
- package/framework/mcp/registry.json +1 -17
- package/framework/rules/dotnet-templates.md +32 -33
- package/framework/rules/infrastructure-standards.md +9 -9
- package/framework/rules/neon-standards.md +4 -4
- package/framework/rules/nextjs-templates.md +10 -11
- package/framework/rules/ui-design.md +2 -2
- package/framework/schemas/config.schema.json +4 -0
- package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
- package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
- package/framework/skills/core/morph-apply/SKILL.md +5 -4
- package/framework/skills/core/morph-plan/SKILL.md +1 -1
- package/framework/skills/core/morph-uiux/SKILL.md +5 -5
- package/framework/standards/integration/mcp/mcp-tools.md +2 -2
- package/framework/templates/REGISTRY.json +1 -75
- package/framework/templates/docs/plan.md +1 -1
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Morph.AiKit.Tests.csproj +1 -1
- package/framework/templates/infrastructure/docker/docker-compose.template.yml +15 -16
- package/package.json +6 -15
- package/src/commands/graph/build.js +2 -2
- package/src/commands/mcp/mcp-setup.js +6 -4
- package/src/commands/project/doctor.js +42 -126
- package/src/commands/project/env.js +2 -1
- package/src/commands/project/init.js +28 -170
- package/src/commands/project/stack-set.js +3 -1
- package/src/commands/project/update.js +49 -153
- package/src/commands/scaffold/scaffold.js +21 -4
- package/src/commands/validation/check.js +12 -10
- package/src/commands/validation/prove-red.js +61 -22
- package/src/core/paths/output-schema.js +8 -27
- package/src/core/templates/template-registry.js +8 -43
- package/src/core/templates/template-renderer.js +3 -200
- package/src/lib/ai/ai-checks.js +1 -1
- package/src/lib/ai/ai-project-scan.js +1 -1
- package/src/lib/ai/code-audit.js +2 -2
- package/src/lib/check/signals.js +25 -7
- package/src/lib/contract/defaults.js +2 -2
- package/src/lib/detectors/claude-config-detector.js +0 -52
- package/src/lib/detectors/index.js +5 -30
- package/src/lib/diff/diff-lines.js +3 -3
- package/src/lib/generators/scaffold-generator.js +5 -17
- package/src/lib/git/default-branch.js +5 -13
- package/src/lib/graph/graph-health.js +1 -1
- package/src/lib/graph/graphifyignore.js +3 -4
- package/src/lib/graph/sanitize.js +2 -2
- package/src/lib/installers/effects.js +0 -13
- package/src/lib/installers/mcp-installer.js +5 -17
- package/src/lib/installers/memory-installer.js +5 -8
- package/src/lib/installers/stack-assets.js +33 -7
- package/src/lib/installers/stack-sync.js +4 -4
- package/src/lib/plan/checks.js +1 -1
- package/src/lib/plan/media.js +3 -3
- package/src/lib/plan/plan-parser.js +1 -1
- package/src/lib/review-reports.js +8 -14
- package/src/lib/scan/worktree-dirs.js +1 -3
- package/src/lib/specs/adr-index.js +4 -4
- package/src/lib/specs/revocations.js +3 -3
- package/src/lib/stack/stack-scan.js +3 -3
- package/src/lib/standards/registry.js +1 -1
- package/src/lib/standards/verified-against.js +2 -2
- package/src/lib/tests-audit/audit.js +2 -2
- package/src/scripts/global-install.js +41 -19
- package/src/scripts/setup-infra.js +57 -165
- package/src/utils/agents-installer.js +8 -30
- package/src/utils/claude-settings-manager.js +29 -27
- package/src/utils/hooks-installer.js +30 -44
- package/src/utils/version-checker.js +2 -31
- package/CLAUDE.md +0 -118
- package/framework/commands/create-umbraco-lp.md +0 -37
- package/framework/commands/migrate-lp-to-umbraco.md +0 -35
- package/framework/commands/morph-apply.md +0 -14
- package/framework/hooks/shared/spawn-command.js +0 -23
- package/framework/templates/CLAUDE.md.core.guide.md +0 -29
- package/framework/templates/CLAUDE.md.core.template +0 -22
- package/framework/templates/context/ARCHITECTURE.md +0 -106
- package/src/commands/context/context-refresh.js +0 -63
- package/src/lib/generators/architecture-scanner.js +0 -543
- package/src/lib/generators/settings-generator.js +0 -97
- package/src/lib/graph/god-nodes.js +0 -65
|
@@ -1,53 +1,19 @@
|
|
|
1
1
|
import { readFileSync, existsSync } from 'fs';
|
|
2
|
-
import { join
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
2
|
+
import { join } from 'path';
|
|
4
3
|
|
|
5
|
-
const
|
|
6
|
-
const __dirname = dirname(__filename);
|
|
4
|
+
const FRAMEWORK_TEMPLATES_DIR = join(import.meta.dirname, '../../../framework/templates');
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
const _registryCache = new Map();
|
|
6
|
+
let registry = null;
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
: join(__dirname, '../../../framework/templates/REGISTRY.json');
|
|
15
|
-
|
|
16
|
-
const cached = _registryCache.get(registryPath);
|
|
17
|
-
if (cached) {
|
|
18
|
-
return cached;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (!existsSync(registryPath)) {
|
|
22
|
-
throw new Error(`Template registry not found: ${registryPath}`);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
const content = readFileSync(registryPath, 'utf-8');
|
|
27
|
-
const parsed = JSON.parse(content);
|
|
28
|
-
_registryCache.set(registryPath, parsed);
|
|
29
|
-
return parsed;
|
|
30
|
-
} catch (error) {
|
|
31
|
-
throw new Error(`Failed to parse template registry: ${error.message}`);
|
|
32
|
-
}
|
|
8
|
+
function loadTemplateRegistry() {
|
|
9
|
+
registry ??= JSON.parse(readFileSync(join(FRAMEWORK_TEMPLATES_DIR, 'REGISTRY.json'), 'utf-8'));
|
|
10
|
+
return registry;
|
|
33
11
|
}
|
|
34
12
|
|
|
35
|
-
export function
|
|
36
|
-
|
|
13
|
+
export function getTemplateById(templateId) {
|
|
14
|
+
return (loadTemplateRegistry().templates || []).find(t => t.id === templateId) || null;
|
|
37
15
|
}
|
|
38
16
|
|
|
39
|
-
function getAllTemplates(projectPath = null) {
|
|
40
|
-
const registry = loadTemplateRegistry(projectPath);
|
|
41
|
-
return registry.templates || [];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function getTemplateById(templateId, projectPath = null) {
|
|
45
|
-
const templates = getAllTemplates(projectPath);
|
|
46
|
-
return templates.find(t => t.id === templateId) || null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const FRAMEWORK_TEMPLATES_DIR = join(__dirname, '../../../framework/templates');
|
|
50
|
-
|
|
51
17
|
/** Path inside this package's `framework/templates/`, not a project's `.morph/`; throws when missing. */
|
|
52
18
|
export function resolveFrameworkTemplatePath(templateId) {
|
|
53
19
|
const template = getTemplateById(templateId);
|
|
@@ -62,4 +28,3 @@ export function resolveFrameworkTemplatePath(templateId) {
|
|
|
62
28
|
}
|
|
63
29
|
return abs;
|
|
64
30
|
}
|
|
65
|
-
|
|
@@ -49,26 +49,6 @@ function registerHelpers() {
|
|
|
49
49
|
return a === b;
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
Handlebars.registerHelper('ne', function (a, b) {
|
|
53
|
-
return a !== b;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
Handlebars.registerHelper('lt', function (a, b) {
|
|
57
|
-
return a < b;
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
Handlebars.registerHelper('gt', function (a, b) {
|
|
61
|
-
return a > b;
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
Handlebars.registerHelper('lte', function (a, b) {
|
|
65
|
-
return a <= b;
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
Handlebars.registerHelper('gte', function (a, b) {
|
|
69
|
-
return a >= b;
|
|
70
|
-
});
|
|
71
|
-
|
|
72
52
|
Handlebars.registerHelper('and', function (...args) {
|
|
73
53
|
// Handlebars passes its options object as the last argument.
|
|
74
54
|
const values = args.slice(0, -1);
|
|
@@ -81,31 +61,10 @@ function registerHelpers() {
|
|
|
81
61
|
return values.some(Boolean);
|
|
82
62
|
});
|
|
83
63
|
|
|
84
|
-
Handlebars.registerHelper('not', function (value) {
|
|
85
|
-
return !value;
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
Handlebars.registerHelper('uppercase', function (str) {
|
|
89
|
-
return typeof str === 'string' ? str.toUpperCase() : '';
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
Handlebars.registerHelper('lowercase', function (str) {
|
|
93
|
-
return typeof str === 'string' ? str.toLowerCase() : '';
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
Handlebars.registerHelper('capitalize', function (str) {
|
|
97
|
-
if (typeof str !== 'string') return '';
|
|
98
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
64
|
Handlebars.registerHelper('default', function (value, defaultValue) {
|
|
102
65
|
return value != null && value !== '' ? value : defaultValue;
|
|
103
66
|
});
|
|
104
67
|
|
|
105
|
-
Handlebars.registerHelper('json', function (obj) {
|
|
106
|
-
return JSON.stringify(obj, null, 2);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
68
|
Handlebars.registerHelper('now', function (format) {
|
|
110
69
|
const date = new Date();
|
|
111
70
|
if (format === 'iso') {
|
|
@@ -118,39 +77,6 @@ function registerHelpers() {
|
|
|
118
77
|
return date.toISOString().split('T')[0];
|
|
119
78
|
});
|
|
120
79
|
|
|
121
|
-
Handlebars.registerHelper('year', function () {
|
|
122
|
-
return new Date().getFullYear();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
Handlebars.registerHelper('formatDate', function (date, format) {
|
|
126
|
-
if (!date) return '';
|
|
127
|
-
|
|
128
|
-
const d = new Date(date);
|
|
129
|
-
if (isNaN(d.getTime())) return date;
|
|
130
|
-
|
|
131
|
-
switch (format) {
|
|
132
|
-
case 'iso':
|
|
133
|
-
return d.toISOString();
|
|
134
|
-
case 'date':
|
|
135
|
-
return d.toISOString().split('T')[0];
|
|
136
|
-
case 'time':
|
|
137
|
-
return d.toTimeString().split(' ')[0];
|
|
138
|
-
case 'datetime':
|
|
139
|
-
return d.toISOString().replace('T', ' ').split('.')[0];
|
|
140
|
-
case 'short':
|
|
141
|
-
return d.toLocaleDateString();
|
|
142
|
-
case 'long':
|
|
143
|
-
return d.toLocaleDateString('en-US', {
|
|
144
|
-
weekday: 'long',
|
|
145
|
-
year: 'numeric',
|
|
146
|
-
month: 'long',
|
|
147
|
-
day: 'numeric'
|
|
148
|
-
});
|
|
149
|
-
default:
|
|
150
|
-
return d.toISOString().split('T')[0];
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
|
|
154
80
|
Handlebars.registerHelper('pluralize', function (str) {
|
|
155
81
|
if (typeof str !== 'string') return '';
|
|
156
82
|
|
|
@@ -184,129 +110,14 @@ function registerHelpers() {
|
|
|
184
110
|
}
|
|
185
111
|
});
|
|
186
112
|
|
|
187
|
-
Handlebars.registerHelper('singularize', function (str) {
|
|
188
|
-
if (typeof str !== 'string') return '';
|
|
189
|
-
|
|
190
|
-
const irregulars = {
|
|
191
|
-
'people': 'person',
|
|
192
|
-
'children': 'child',
|
|
193
|
-
'feet': 'foot',
|
|
194
|
-
'teeth': 'tooth',
|
|
195
|
-
'mice': 'mouse',
|
|
196
|
-
'geese': 'goose'
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
const lower = str.toLowerCase();
|
|
200
|
-
if (irregulars[lower]) {
|
|
201
|
-
return str[0] === str[0].toUpperCase()
|
|
202
|
-
? irregulars[lower].charAt(0).toUpperCase() + irregulars[lower].slice(1)
|
|
203
|
-
: irregulars[lower];
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (str.endsWith('ies')) {
|
|
207
|
-
return str.slice(0, -3) + 'y';
|
|
208
|
-
} else if (str.endsWith('ves')) {
|
|
209
|
-
return str.slice(0, -3) + 'f';
|
|
210
|
-
} else if (str.endsWith('es')) {
|
|
211
|
-
return str.slice(0, -2);
|
|
212
|
-
} else if (str.endsWith('s') && !str.endsWith('ss')) {
|
|
213
|
-
return str.slice(0, -1);
|
|
214
|
-
} else {
|
|
215
|
-
return str;
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
Handlebars.registerHelper('trim', function (str) {
|
|
220
|
-
return typeof str === 'string' ? str.trim() : '';
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
Handlebars.registerHelper('replace', function (str, search, replacement) {
|
|
224
|
-
if (typeof str !== 'string') return '';
|
|
225
|
-
return str.replace(new RegExp(search, 'g'), replacement);
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
Handlebars.registerHelper('concat', function (...args) {
|
|
229
|
-
// Handlebars passes its options object as the last argument.
|
|
230
|
-
const strings = args.slice(0, -1);
|
|
231
|
-
return strings.join('');
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
Handlebars.registerHelper('substr', function (str, start, length) {
|
|
235
|
-
if (typeof str !== 'string') return '';
|
|
236
|
-
return length !== undefined ? str.substring(start, start + length) : str.substring(start);
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
Handlebars.registerHelper('startsWith', function (str, prefix) {
|
|
240
|
-
if (typeof str !== 'string') return false;
|
|
241
|
-
return str.startsWith(prefix);
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
Handlebars.registerHelper('endsWith', function (str, suffix) {
|
|
245
|
-
if (typeof str !== 'string') return false;
|
|
246
|
-
return str.endsWith(suffix);
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
Handlebars.registerHelper('contains', function (str, substring) {
|
|
250
|
-
if (typeof str !== 'string') return false;
|
|
251
|
-
return str.includes(substring);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
Handlebars.registerHelper('length', function (value) {
|
|
255
|
-
if (Array.isArray(value) || typeof value === 'string') {
|
|
256
|
-
return value.length;
|
|
257
|
-
}
|
|
258
|
-
return 0;
|
|
259
|
-
});
|
|
260
|
-
|
|
261
113
|
Handlebars.registerHelper('add', function (a, b) {
|
|
262
114
|
return Number(a) + Number(b);
|
|
263
115
|
});
|
|
264
|
-
|
|
265
|
-
Handlebars.registerHelper('subtract', function (a, b) {
|
|
266
|
-
return Number(a) - Number(b);
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
Handlebars.registerHelper('multiply', function (a, b) {
|
|
270
|
-
return Number(a) * Number(b);
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
Handlebars.registerHelper('divide', function (a, b) {
|
|
274
|
-
return Number(b) !== 0 ? Number(a) / Number(b) : 0;
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
Handlebars.registerHelper('mod', function (a, b) {
|
|
278
|
-
return Number(a) % Number(b);
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
Handlebars.registerHelper('round', function (num, decimals = 0) {
|
|
282
|
-
const multiplier = Math.pow(10, decimals);
|
|
283
|
-
return Math.round(Number(num) * multiplier) / multiplier;
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
Handlebars.registerHelper('join', function (array, separator = ', ') {
|
|
287
|
-
if (!Array.isArray(array)) return '';
|
|
288
|
-
return array.join(separator);
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
Handlebars.registerHelper('first', function (array) {
|
|
292
|
-
if (!Array.isArray(array) || array.length === 0) return undefined;
|
|
293
|
-
return array[0];
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
Handlebars.registerHelper('last', function (array) {
|
|
297
|
-
if (!Array.isArray(array) || array.length === 0) return undefined;
|
|
298
|
-
return array[array.length - 1];
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
Handlebars.registerHelper('slice', function (array, start, end) {
|
|
302
|
-
if (!Array.isArray(array)) return [];
|
|
303
|
-
return array.slice(start, end);
|
|
304
|
-
});
|
|
305
116
|
}
|
|
306
117
|
|
|
307
118
|
registerHelpers();
|
|
308
119
|
|
|
309
|
-
export function renderTemplate(templatePath, variables
|
|
120
|
+
export function renderTemplate(templatePath, variables) {
|
|
310
121
|
if (!existsSync(templatePath)) {
|
|
311
122
|
throw new Error(`Template file not found: ${templatePath}`);
|
|
312
123
|
}
|
|
@@ -315,7 +126,7 @@ export function renderTemplate(templatePath, variables, options = {}) {
|
|
|
315
126
|
const templateContent = readFileSync(templatePath, 'utf-8');
|
|
316
127
|
|
|
317
128
|
const template = Handlebars.compile(templateContent, {
|
|
318
|
-
noEscape:
|
|
129
|
+
noEscape: true,
|
|
319
130
|
strict: false,
|
|
320
131
|
preventIndent: true,
|
|
321
132
|
});
|
|
@@ -337,16 +148,8 @@ export function getTemplatePlaceholdersFromString(templateString) {
|
|
|
337
148
|
|
|
338
149
|
const skipHelpers = [
|
|
339
150
|
'if', 'unless', 'each', 'with', 'lookup', 'log', 'else',
|
|
340
|
-
'eq', '
|
|
341
|
-
'and', 'or', 'not',
|
|
151
|
+
'eq', 'and', 'or', 'default', 'now', 'pluralize', 'add',
|
|
342
152
|
'pascalCase', 'camelCase', 'titleCase', 'upperSnakeCase', 'snakeCase', 'kebabCase',
|
|
343
|
-
'uppercase', 'lowercase', 'capitalize', 'trim', 'replace', 'concat', 'substr',
|
|
344
|
-
'startsWith', 'endsWith', 'contains', 'length',
|
|
345
|
-
'formatDate', 'now', 'year',
|
|
346
|
-
'pluralize', 'singularize',
|
|
347
|
-
'add', 'subtract', 'multiply', 'divide', 'mod', 'round',
|
|
348
|
-
'join', 'first', 'last', 'slice',
|
|
349
|
-
'default', 'json'
|
|
350
153
|
];
|
|
351
154
|
|
|
352
155
|
if (!skipHelpers.includes(placeholder)) {
|
package/src/lib/ai/ai-checks.js
CHANGED
|
@@ -9,7 +9,7 @@ import { auditRenamedApi, auditPromptSource, renamedApiGate } from './code-audit
|
|
|
9
9
|
/** Os cinco ids, na ordem em que o relatório os imprime. */
|
|
10
10
|
export const AI_CHECK_IDS = ['pin-drift', 'removed-api', 'pricing-missing', 'api-per-alias', 'prompt-source'];
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const AI_CHECK_NAMES = {
|
|
13
13
|
'pin-drift': 'pin × projeto (versões de pacote de IA)',
|
|
14
14
|
'removed-api': 'API renomeada antes do 1.0 GA',
|
|
15
15
|
'pricing-missing': 'tarifa por alias do registry de modelos',
|
|
@@ -15,7 +15,7 @@ export const SCAN_IGNORED_DIRS = new Set([
|
|
|
15
15
|
|
|
16
16
|
// Deliberadamente curto: decide se há assunto, não cataloga o ecossistema; um pacote de IA fora daqui
|
|
17
17
|
// que esteja no pin ainda é pego por `pin-drift`.
|
|
18
|
-
|
|
18
|
+
const AI_PACKAGE_PREFIXES = [
|
|
19
19
|
'Microsoft.Agents.AI',
|
|
20
20
|
'Microsoft.Extensions.AI',
|
|
21
21
|
'Microsoft.SemanticKernel',
|
package/src/lib/ai/code-audit.js
CHANGED
|
@@ -8,7 +8,7 @@ import { collectProjectFiles } from './ai-project-scan.js';
|
|
|
8
8
|
import { stripComments } from '../../../framework/hooks/shared/comment-stripper.js';
|
|
9
9
|
|
|
10
10
|
/** Símbolos renomeados antes do 1.0 GA, e o nome vivo de cada um. */
|
|
11
|
-
|
|
11
|
+
const RENAMED_SYMBOLS = {
|
|
12
12
|
AgentThread: 'AgentSession',
|
|
13
13
|
GetNewThread: 'CreateSessionAsync()',
|
|
14
14
|
ChatMessageStore: 'a conversa persistida do projeto (ver ai-agents/agent-session.md)',
|
|
@@ -20,7 +20,7 @@ function lineOf(text, index) {
|
|
|
20
20
|
return line;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
function collectCsharpFiles(root) {
|
|
24
24
|
return collectProjectFiles(root, (name) => name.toLowerCase().endsWith('.cs'));
|
|
25
25
|
}
|
|
26
26
|
|
package/src/lib/check/signals.js
CHANGED
|
@@ -6,7 +6,7 @@ import { detectDefaultBranch } from '../git/default-branch.js';
|
|
|
6
6
|
import { parseReport } from '../../../framework/hooks/shared/report-progress.js';
|
|
7
7
|
import { checksCoverage } from '../review-reports.js';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const RISK_CATEGORIES = ['dados', 'pessoas', 'acesso', 'infra'];
|
|
10
10
|
|
|
11
11
|
// Money charged to a real person sits with "pessoas": the harm lands on someone outside the repo.
|
|
12
12
|
const LINE_CATEGORY = [
|
|
@@ -18,7 +18,7 @@ const LINE_CATEGORY = [
|
|
|
18
18
|
const STOP_RUNGS = new Set(['migrar', 'irreversível']);
|
|
19
19
|
const MAX_READ = 512 * 1024;
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
function baseRefOf(cwd) {
|
|
22
22
|
const branch = detectDefaultBranch(cwd);
|
|
23
23
|
if (!branch) return null;
|
|
24
24
|
for (const ref of [`origin/${branch}`, branch]) {
|
|
@@ -47,7 +47,7 @@ export function changedFiles(cwd, { committed = false } = {}) {
|
|
|
47
47
|
/** Work outside `.morph/` that the PR would leave behind: modified tracked files and untracked, unignored ones. */
|
|
48
48
|
export function uncommittedSignals(cwd) {
|
|
49
49
|
let text;
|
|
50
|
-
try { text = git(cwd, ['status', '--porcelain', '-uall']); } catch { return []; }
|
|
50
|
+
try { text = git(cwd, ['-c', 'core.quotepath=off', 'status', '--porcelain', '-uall']); } catch { return []; }
|
|
51
51
|
const paths = text.split('\n').filter(Boolean).map((l) => l.slice(3).replace(/^"|"$/g, '')).filter((p) => !p.startsWith('.morph/'));
|
|
52
52
|
return paths.length ? [{ kind: 'nao-commitado', onde: paths.slice(0, 5).join(', ') + (paths.length > 5 ? ` e mais ${paths.length - 5}` : '') }] : [];
|
|
53
53
|
}
|
|
@@ -107,16 +107,34 @@ export function finalSignals(checks, reportText, runs) {
|
|
|
107
107
|
return out;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
// A review counts for the commit it read: code outside `.morph/` that changed after it was not reviewed.
|
|
111
|
+
function staleReason(cwd, sha) {
|
|
112
|
+
if (!cwd) return null;
|
|
113
|
+
if (!sha) return 'sem Reviewed-SHA';
|
|
114
|
+
try {
|
|
115
|
+
git(cwd, ['diff', '--quiet', sha, 'HEAD', '--', '.', ':(exclude).morph']);
|
|
116
|
+
return null;
|
|
117
|
+
} catch (error) {
|
|
118
|
+
return error.status === 1 ? `o código mudou depois do ${sha.slice(0, 7)} revisado` : `Reviewed-SHA ${sha.slice(0, 7)} não existe neste repo`;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Personas of the single review round: verifier and reviewer always, security when it wrote a report.
|
|
124
|
+
* With `cwd`, a report whose `Reviewed-SHA` is missing or older than the code counts as no review.
|
|
125
|
+
*/
|
|
126
|
+
export function reviewSignals(reports, checkIds = [], cwd = null) {
|
|
112
127
|
const required = ['verifier', 'reviewer', ...(reports.security.status === 'missing' ? [] : ['security'])];
|
|
113
128
|
const out = [];
|
|
114
129
|
const absent = required.filter((role) => reports[role].status !== 'ok');
|
|
115
130
|
if (absent.length) out.push({ kind: 'sem-revisao', onde: absent.map((r) => `${r} (${reports[r].status})`).join(', ') });
|
|
116
|
-
const
|
|
131
|
+
const open = (role) => [...reports[role].blockers, ...reports[role].untyped];
|
|
132
|
+
const fix = required.filter((role) => reports[role].status === 'ok' && (reports[role].verdict === 'FIX' || open(role).length));
|
|
117
133
|
if (fix.length) {
|
|
118
|
-
out.push({ kind: 'revisao-fix', onde: fix.map((r) => `${r}: ${
|
|
134
|
+
out.push({ kind: 'revisao-fix', onde: fix.map((r) => `${r}: ${open(r).map((b) => `${b.id} ${b.type}`).join(', ') || 'FIX'}`).join('; ') });
|
|
119
135
|
}
|
|
136
|
+
const stale = required.filter((role) => reports[role].status === 'ok').map((role) => [role, staleReason(cwd, reports[role].reviewedSha)]).filter(([, why]) => why);
|
|
137
|
+
if (stale.length) out.push({ kind: 'sem-revisao', onde: stale.map(([role, why]) => `${role} (${why})`).join(', ') });
|
|
120
138
|
if (reports.verifier.status === 'ok' && checkIds.length) {
|
|
121
139
|
const { missing, notProven } = checksCoverage(checkIds, reports.verifier.checks);
|
|
122
140
|
const open = [...missing, ...notProven.map((n) => `${n.id} ${n.status}`)];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const CONTRACT_VERSION = 1;
|
|
5
5
|
|
|
6
6
|
export const DEFAULT_LIMITS = Object.freeze({ maxScenarios: 6, maxFiles: 20, maxIterations: 8, sameErrorStop: 3 });
|
|
7
7
|
|
|
8
|
-
// Globs over repo-relative paths;
|
|
8
|
+
// Globs over repo-relative paths; `LINE_CATEGORY` in check/signals.js catches what a path cannot name.
|
|
9
9
|
export const DEFAULT_RISK = Object.freeze({
|
|
10
10
|
dados: ['**/Migrations/**', '**/migrations/**', '**/*.sql', '**/prisma/schema.prisma', '**/alembic/versions/**', '**/drizzle/**'],
|
|
11
11
|
pessoas: ['**/*{WhatsApp,Whatsapp,whatsapp,Kapso,kapso}*{,/**}', '**/*{Email,email,Mailer,mailer}*{,/**}', '**/*{Sms,sms,Twilio,twilio}*{,/**}'],
|
|
@@ -27,9 +27,6 @@ export function detectClaudeConfig(targetPath) {
|
|
|
27
27
|
plugins: [],
|
|
28
28
|
enabledPlugins: [],
|
|
29
29
|
mcpServers: [],
|
|
30
|
-
customSkills: [],
|
|
31
|
-
customCommands: [],
|
|
32
|
-
hooks: [],
|
|
33
30
|
};
|
|
34
31
|
|
|
35
32
|
result.enabledPlugins = readEnabledPlugins(targetPath);
|
|
@@ -69,16 +66,6 @@ export function detectClaudeConfig(targetPath) {
|
|
|
69
66
|
result.mcpServers.push({ name, config });
|
|
70
67
|
}
|
|
71
68
|
}
|
|
72
|
-
|
|
73
|
-
if (settings.hooks) {
|
|
74
|
-
for (const [event, eventHooks] of Object.entries(settings.hooks)) {
|
|
75
|
-
for (const group of (Array.isArray(eventHooks) ? eventHooks : [])) {
|
|
76
|
-
for (const h of (group.hooks || [])) {
|
|
77
|
-
result.hooks.push(`${event}:${h.type || 'unknown'}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
69
|
} catch {}
|
|
83
70
|
}
|
|
84
71
|
}
|
|
@@ -97,51 +84,12 @@ export function detectClaudeConfig(targetPath) {
|
|
|
97
84
|
result.plugins = Object.keys(plugins);
|
|
98
85
|
} catch {}
|
|
99
86
|
}
|
|
100
|
-
|
|
101
|
-
const skillsPath = join(targetPath, '.claude', 'skills');
|
|
102
|
-
if (existsSync(skillsPath)) {
|
|
103
|
-
try {
|
|
104
|
-
result.customSkills = readdirSync(skillsPath).filter(f => !f.startsWith('.'));
|
|
105
|
-
} catch {}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const commandsPath = join(targetPath, '.claude', 'commands');
|
|
109
|
-
if (existsSync(commandsPath)) {
|
|
110
|
-
try {
|
|
111
|
-
result.customCommands = readdirSync(commandsPath).filter(f => f.endsWith('.md'));
|
|
112
|
-
} catch {}
|
|
113
|
-
}
|
|
114
87
|
} catch {
|
|
115
88
|
}
|
|
116
89
|
|
|
117
90
|
return result;
|
|
118
91
|
}
|
|
119
92
|
|
|
120
|
-
// `phaseMatrix`/`currentPhase` default: `init` passes only `mcpServers`, and a throw here was
|
|
121
|
-
// swallowed by its outer catch, skipping the steps after it.
|
|
122
|
-
export function mapMcpsToPhases(mcpServers, phaseMatrix = {}, currentPhase = null) {
|
|
123
|
-
const configuredNames = new Set((mcpServers || []).map(m => m.name.toLowerCase()));
|
|
124
|
-
// No phase asked for → the union across every phase, deduped.
|
|
125
|
-
const recommended = currentPhase
|
|
126
|
-
? (phaseMatrix[currentPhase] || [])
|
|
127
|
-
: [...new Set(Object.values(phaseMatrix).flat())];
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
available: recommended.filter(name => configuredNames.has(name)),
|
|
131
|
-
recommended,
|
|
132
|
-
missing: recommended.filter(name => !configuredNames.has(name)),
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export function mcpAvailabilityByPhase(mcpServers, phaseMatrix = {}) {
|
|
137
|
-
return Object.keys(phaseMatrix)
|
|
138
|
-
.map(phase => ({
|
|
139
|
-
phase,
|
|
140
|
-
available: mapMcpsToPhases(mcpServers, phaseMatrix, phase).available,
|
|
141
|
-
}))
|
|
142
|
-
.filter(({ available }) => available.length > 0);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
93
|
export function formatConfigSummary(config) {
|
|
146
94
|
const parts = [];
|
|
147
95
|
if (config.mcpServers.length > 0) {
|
|
@@ -5,10 +5,9 @@ import { PACKAGE_LOCATIONS } from '../../../framework/hooks/shared/frontend-loca
|
|
|
5
5
|
|
|
6
6
|
export { PACKAGE_LOCATIONS };
|
|
7
7
|
|
|
8
|
-
export function detectProject(targetPath
|
|
8
|
+
export function detectProject(targetPath) {
|
|
9
9
|
const structure = {
|
|
10
10
|
stack: 'unknown',
|
|
11
|
-
architecture: null,
|
|
12
11
|
uiLibrary: null,
|
|
13
12
|
integrations: [],
|
|
14
13
|
hasVercel: false,
|
|
@@ -42,9 +41,9 @@ export function detectProject(targetPath, opts = {}) {
|
|
|
42
41
|
} else if (depNames.includes('vue')) {
|
|
43
42
|
structure.stack = 'vue';
|
|
44
43
|
} else if (depNames.includes('express') || depNames.includes('fastify') || depNames.includes('hono')) {
|
|
45
|
-
structure.stack = '
|
|
44
|
+
structure.stack = 'node';
|
|
46
45
|
} else if (rootPkg?.name) {
|
|
47
|
-
structure.stack = '
|
|
46
|
+
structure.stack = 'node';
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
if (existsSync(join(targetPath, 'components.json')) || existsSync(join(targetPath, structure.frontendPath || '.', 'components.json')) || depNames.includes('@shadcn/ui')) {
|
|
@@ -113,19 +112,9 @@ export function detectProject(targetPath, opts = {}) {
|
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
if (structure.stack === 'unknown' && existsSync(join(targetPath, 'tsconfig.json'))) {
|
|
116
|
-
structure.stack = '
|
|
115
|
+
structure.stack = 'node';
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
try {
|
|
120
|
-
const configPath = join(targetPath, '.morph/config/config.json');
|
|
121
|
-
if (existsSync(configPath)) {
|
|
122
|
-
const config = JSON.parse(readFileSync(configPath, 'utf8'));
|
|
123
|
-
if (config.architecture?.style) {
|
|
124
|
-
structure.architecture = config.architecture.style;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
} catch {}
|
|
128
|
-
|
|
129
118
|
if (existsSync(join(targetPath, 'docker-compose.yml')) ||
|
|
130
119
|
existsSync(join(targetPath, 'docker-compose.yaml')) ||
|
|
131
120
|
existsSync(join(targetPath, 'Dockerfile'))) {
|
|
@@ -152,12 +141,7 @@ export function detectProject(targetPath, opts = {}) {
|
|
|
152
141
|
} catch {
|
|
153
142
|
}
|
|
154
143
|
|
|
155
|
-
return {
|
|
156
|
-
structure,
|
|
157
|
-
inferred: {
|
|
158
|
-
markdown: opts.generateStandards ? generateInferredMarkdown(structure) : '',
|
|
159
|
-
},
|
|
160
|
-
};
|
|
144
|
+
return { structure };
|
|
161
145
|
}
|
|
162
146
|
|
|
163
147
|
function readdirSyncSafe(dir) {
|
|
@@ -167,12 +151,3 @@ function readdirSyncSafe(dir) {
|
|
|
167
151
|
return [];
|
|
168
152
|
}
|
|
169
153
|
}
|
|
170
|
-
|
|
171
|
-
function generateInferredMarkdown(structure) {
|
|
172
|
-
const lines = [`## Detected Stack: ${structure.stack}`];
|
|
173
|
-
if (structure.architecture) lines.push(`Architecture: ${structure.architecture}`);
|
|
174
|
-
if (structure.uiLibrary) lines.push(`UI Library: ${structure.uiLibrary}`);
|
|
175
|
-
if (structure.integrations.length > 0) lines.push(`Integrations: ${structure.integrations.join(', ')}`);
|
|
176
|
-
if (structure.hasVercel) lines.push(`Vercel: detected`);
|
|
177
|
-
return lines.join('\n');
|
|
178
|
-
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execFileSync } from 'child_process';
|
|
2
2
|
import { minimatch } from 'minimatch';
|
|
3
3
|
|
|
4
|
-
// O predicado único de teste
|
|
4
|
+
// O predicado único de "é teste" (grafo, stack-scan, prove-red). Só três formas de pasta, porque
|
|
5
5
|
// `[^/]*[Tt]ests?/` genérico também casaria `latest/` e `contests/`.
|
|
6
6
|
const TEST_PATH = /(^|\/)__tests__\/|\.(test|spec)\.[jt]sx?$|(^|\/)(?:[Tt]ests?|[^/]*\.[Tt]ests?|[^/]*[a-z0-9_]Tests?)\//;
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ export function isTestPath(sourceFile) {
|
|
|
12
12
|
const DOC_PATH = /(^|\/)docs\/|\.(md|mdx|txt|rst|adoc|png|jpe?g|gif|svg|webp|ico)$/i;
|
|
13
13
|
const CONFIG_PATH = /\.(json|jsonc|ya?ml|toml|ini|xml|editorconfig|env\.example)$|(^|\/)\.(gitignore|gitattributes|npmrc|nvmrc|prettierrc|eslintignore)$|(^|\/)\.env(\.[^/]+)?$/i;
|
|
14
14
|
// Resolves or compiles everything: a change here reaches code the diff does not name.
|
|
15
|
-
|
|
15
|
+
const WIDE_PATH = /(^|\/)(package(-lock)?\.json|pnpm-lock\.yaml|yarn\.lock|global\.json|Directory\.(Build|Packages)\.(props|targets)|tsconfig[^/]*\.json|[^/]+\.(csproj|sln|slnx|props|targets))$/i;
|
|
16
16
|
|
|
17
17
|
export function git(cwd, args) {
|
|
18
18
|
return execFileSync('git', args, { cwd, stdio: 'pipe', maxBuffer: 256 * 1024 * 1024 }).toString();
|
|
@@ -21,7 +21,7 @@ export function git(cwd, args) {
|
|
|
21
21
|
// An agent reads these as instructions: a changed sentence is changed behaviour, whatever the extension.
|
|
22
22
|
const PROMPT_PATH = /(^|\/)(prompts?|agents?|skills?|playbooks?|personas?|instructions?|\.claude)\/|(^|\/)(CLAUDE|AGENTS|GEMINI|MORPH|SKILL|copilot-instructions)\.md$|prompt[^/]*$/i;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
function isPromptPath(path, promptGlobs = []) {
|
|
25
25
|
return PROMPT_PATH.test(path) || promptGlobs.some((g) => minimatch(path, g));
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync, mkdirSync, readdirSync } from 'fs';
|
|
2
2
|
import { join, dirname, basename } from 'path';
|
|
3
|
-
import { renderTemplate } from '../../core/templates/template-renderer.js';
|
|
3
|
+
import { renderTemplate, Handlebars } from '../../core/templates/template-renderer.js';
|
|
4
4
|
import { resolveFrameworkTemplatePath } from '../../core/templates/template-registry.js';
|
|
5
|
+
import { readMorphConfig } from '../config/project-config.js';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
return str
|
|
8
|
-
.split('-')
|
|
9
|
-
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
10
|
-
.join('');
|
|
11
|
-
}
|
|
7
|
+
export const toPascalCase = (str) => Handlebars.helpers.pascalCase(str);
|
|
12
8
|
|
|
13
9
|
/** Kebab-case so Handlebars {{pascalCase}} reconstructs it: "MyBookStore" → "my-book-store", "My.App" → "my-app". */
|
|
14
10
|
export function normalizeNamespaceToKebab(ns) {
|
|
@@ -156,7 +152,7 @@ export function scaffoldNextjsFeature(options) {
|
|
|
156
152
|
return { files };
|
|
157
153
|
}
|
|
158
154
|
|
|
159
|
-
/** <RootNamespace> or the name of a .csproj here or one level deep, else
|
|
155
|
+
/** <RootNamespace> or the name of a .csproj here or one level deep, else the contract's `project.name`. */
|
|
160
156
|
export function detectNamespace(dir) {
|
|
161
157
|
const csprojInDir = findCsproj(dir);
|
|
162
158
|
if (csprojInDir) {
|
|
@@ -179,15 +175,7 @@ export function detectNamespace(dir) {
|
|
|
179
175
|
}
|
|
180
176
|
} catch {}
|
|
181
177
|
|
|
182
|
-
|
|
183
|
-
if (existsSync(configPath)) {
|
|
184
|
-
try {
|
|
185
|
-
const config = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
186
|
-
if (config.project?.name) return config.project.name;
|
|
187
|
-
} catch {}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return null;
|
|
178
|
+
return readMorphConfig(dir)?.project?.name || null;
|
|
191
179
|
}
|
|
192
180
|
|
|
193
181
|
function findCsproj(dir) {
|