@polymorphism-tech/morph-spec 10.12.1 → 11.1.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/CLAUDE.md +27 -57
- package/README.md +53 -338
- package/bin/morph-spec.js +22 -373
- package/docs/CHEATSHEET.md +37 -166
- package/docs/QUICKSTART.md +14 -74
- package/framework/CLAUDE.md +15 -26
- package/framework/MORPH.md +34 -101
- package/framework/agents.json +12 -9
- package/framework/commands/morph-apply.md +5 -5
- package/framework/commands/morph-infra.md +1 -1
- package/framework/docs/CLI.md +74 -886
- package/framework/evals/review-checklist.md +14 -14
- package/framework/hooks/README.md +21 -189
- package/framework/hooks/claude-code/core/README.md +2 -5
- package/framework/hooks/claude-code/core/conventional-commit.js +2 -2
- package/framework/hooks/claude-code/core/denylist.json +3 -3
- package/framework/hooks/claude-code/core/graph-refresh-kick.js +2 -2
- package/framework/hooks/claude-code/core/masked-exit.js +6 -6
- package/framework/hooks/claude-code/core/pre-bash-denylist.js +2 -2
- package/framework/hooks/claude-code/core/protect-spec-files.js +17 -61
- package/framework/hooks/claude-code/core/stack-changed.js +35 -0
- package/framework/hooks/claude-code/core/validate-completion.js +32 -87
- package/framework/hooks/shared/{heavy-command.js → command-kind.js} +6 -79
- package/framework/hooks/shared/command-tokens.js +0 -139
- package/framework/hooks/shared/contract.js +14 -0
- package/framework/hooks/shared/feature-slug.js +21 -0
- package/framework/hooks/shared/frontend-locations.js +0 -1
- package/framework/hooks/shared/git-paths.js +0 -15
- package/framework/hooks/shared/graph-freshness.js +0 -19
- package/framework/hooks/shared/hook-response.js +0 -7
- package/framework/hooks/shared/morph-cli.js +2 -81
- package/framework/hooks/shared/owner-words.js +2 -120
- package/framework/hooks/shared/payload-utils.js +0 -39
- package/framework/hooks/shared/report-progress.js +7 -101
- package/framework/hooks/statusline.js +16 -60
- package/framework/mcp/registry.json +2 -2
- package/framework/rules/ai-agents-standards.md +1 -1
- package/framework/rules/asaas-standards.md +1 -1
- package/framework/rules/ef-standards.md +1 -1
- package/framework/rules/gsap-standards.md +1 -1
- package/framework/rules/hangfire-standards.md +1 -1
- package/framework/rules/implement-report.md +3 -3
- package/framework/rules/neon-auth-standards.md +1 -1
- package/framework/rules/nextjs-standards.md +1 -1
- package/framework/rules/plan-grammar.md +15 -13
- package/framework/rules/resend-standards.md +1 -1
- package/framework/rules/ui-design.md +5 -1
- package/framework/schemas/config.schema.json +95 -310
- package/framework/skills/README.md +12 -32
- 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 +21 -46
- package/framework/skills/core/morph-plan/SKILL.md +28 -63
- package/framework/skills/core/morph-uiux/SKILL.md +23 -25
- package/framework/{templates/docs/ui-mockups.md → skills/core/morph-uiux/references/mockups.md} +4 -4
- package/framework/standards/STANDARDS.json +10 -11
- package/framework/standards/STANDARDS.meta.json +1 -1
- package/framework/standards/ai-agents/evals-with-cache.md +18 -32
- package/framework/standards/ai-agents/observability-patterns.md +2 -2
- package/framework/standards/architecture/code-comments.md +2 -5
- package/framework/standards/architecture/engineering-lens.md +1 -1
- package/framework/standards/backend/dotnet/testing.md +4 -4
- package/framework/standards/frontend/nextjs/lint.md +24 -10
- package/framework/standards/frontend/nextjs/testing.md +2 -2
- package/framework/standards/infrastructure/docker/local-compose-isolation.md +14 -30
- package/framework/templates/CLAUDE.md.core.guide.md +2 -2
- package/framework/templates/README.md +1 -1
- package/framework/templates/REGISTRY.json +3 -33
- package/framework/templates/docs/plan.md +3 -2
- package/framework/templates/dotnet/ai-kit/README.md +2 -4
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheMissException.cs +1 -1
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalFixture.cs +1 -1
- package/package.json +1 -2
- package/src/commands/graph/explain.js +2 -1
- package/src/commands/graph/status.js +2 -1
- package/src/commands/mcp/mcp-setup.js +1 -2
- package/src/commands/project/doctor.js +13 -342
- package/src/commands/project/env.js +21 -52
- package/src/commands/project/init-contract.js +47 -0
- package/src/commands/project/init.js +36 -66
- package/src/commands/project/stack-scan.js +1 -1
- package/src/commands/project/update.js +16 -53
- package/src/commands/validation/check.js +128 -0
- package/src/commands/validation/plan-check.js +41 -64
- package/src/commands/validation/prove-red.js +1 -1
- package/src/core/paths/output-schema.js +0 -22
- package/src/core/templates/template-renderer.js +0 -14
- package/src/lib/ai/ai-project-scan.js +1 -6
- package/src/lib/check/attempts.js +38 -0
- package/src/lib/check/signals.js +145 -0
- package/src/lib/config/project-config.js +13 -0
- package/src/lib/contract/apply.js +62 -0
- package/src/lib/contract/defaults.js +96 -0
- package/src/lib/contract/merge.js +79 -0
- package/src/lib/contract/ports.js +43 -0
- package/src/lib/contract/scan.js +102 -0
- package/src/lib/detectors/claude-config-detector.js +7 -0
- package/src/lib/{procs → detectors}/mcp-config.js +1 -37
- package/src/lib/diff/diff-lines.js +64 -0
- package/src/lib/generators/architecture-scanner.js +1 -1
- package/src/lib/generators/scaffold-generator.js +0 -7
- package/src/lib/git/default-branch.js +0 -122
- package/src/lib/graph/diff-tree.js +2 -1
- package/src/lib/graph/god-nodes.js +2 -1
- package/src/lib/graph/graphify-runtime.js +0 -1
- package/src/lib/graph/graphifyignore.js +1 -1
- package/src/lib/graph/sanitize.js +2 -8
- package/src/lib/installers/memory-installer.js +15 -30
- package/src/lib/installers/stack-sync.js +16 -9
- package/src/lib/plan/checks.js +20 -64
- package/src/lib/plan/media.js +1 -1
- package/src/lib/plan/plan-parser.js +5 -5
- package/src/lib/review-reports.js +3 -77
- package/src/lib/scan/worktree-dirs.js +3 -0
- package/src/lib/specs/adr-index.js +2 -2
- package/src/lib/stack/dotnet-build-ignores.js +10 -2
- package/src/lib/stack/stack-scan.js +2 -2
- package/src/lib/stack-filter.js +3 -2
- package/src/lib/tests-audit/audit.js +1 -1
- package/src/scripts/setup-infra.js +6 -59
- package/src/utils/agents-installer.js +13 -37
- package/src/utils/atomic-json.js +27 -0
- package/src/utils/file-copier.js +24 -24
- package/src/utils/hooks-installer.js +9 -107
- package/claude-plugin.json +0 -14
- package/framework/commands/morph-archive.md +0 -46
- package/framework/commands/morph-hotfix.md +0 -17
- package/framework/commands/morph-preflight.md +0 -180
- package/framework/commands/morph-review.md +0 -15
- package/framework/commands/morph-status.md +0 -37
- package/framework/hooks/claude-code/core/block-destructive-worktree-removal.js +0 -80
- package/framework/hooks/claude-code/core/block-raw-worktree-add.js +0 -72
- package/framework/hooks/claude-code/core/enforce-phase-writes.js +0 -100
- package/framework/hooks/claude-code/core/gate-guard.js +0 -148
- package/framework/hooks/claude-code/core/heavy-gate.js +0 -78
- package/framework/hooks/claude-code/core/heavy-release.js +0 -23
- package/framework/hooks/claude-code/core/loop-detect.js +0 -79
- package/framework/hooks/claude-code/core/state-sync.js +0 -214
- package/framework/hooks/claude-code/core/telemetry-log.js +0 -259
- package/framework/hooks/claude-code/core/test-budget.js +0 -29
- package/framework/hooks/claude-code/core/worktree-context.js +0 -249
- package/framework/hooks/claude-code/core/worktree-create.js +0 -119
- package/framework/hooks/claude-code/core/worktree-env-inject.js +0 -68
- package/framework/hooks/claude-code/core/worktree-remove.js +0 -55
- package/framework/hooks/shared/build-check.js +0 -120
- package/framework/hooks/shared/claim-registry.js +0 -125
- package/framework/hooks/shared/e2e-check.js +0 -1022
- package/framework/hooks/shared/feature-locator.js +0 -82
- package/framework/hooks/shared/gate-event.js +0 -18
- package/framework/hooks/shared/gate-question.js +0 -20
- package/framework/hooks/shared/heavy-config.js +0 -113
- package/framework/hooks/shared/heavy-holders.js +0 -85
- package/framework/hooks/shared/heavy-slots.js +0 -280
- package/framework/hooks/shared/host-services.js +0 -440
- package/framework/hooks/shared/next-step.js +0 -181
- package/framework/hooks/shared/redact-secrets.js +0 -44
- package/framework/hooks/shared/reparse-scan.js +0 -40
- package/framework/hooks/shared/state-reader.js +0 -220
- package/framework/hooks/shared/state-writer.js +0 -112
- package/framework/hooks/shared/telemetry-logger.js +0 -101
- package/framework/hooks/shared/transcript-usage.js +0 -58
- package/framework/hooks/shared/worktree-root.js +0 -71
- package/framework/phases.json +0 -92
- package/framework/schemas/feature.schema.json +0 -242
- package/framework/skills/core/morph-apply/references/hotfix.md +0 -46
- package/framework/skills/core/morph-apply/references/machine.md +0 -30
- package/framework/skills/core/morph-apply/references/review.md +0 -77
- package/framework/skills/core/morph-plan/references/critique.md +0 -51
- package/framework/skills/core/morph-plan/references/interview.md +0 -37
- package/framework/templates/state.template.json +0 -17
- package/src/commands/dashboard/dashboard.js +0 -74
- package/src/commands/e2e/e2e.js +0 -400
- package/src/commands/observability/cost.js +0 -283
- package/src/commands/project/branch.js +0 -129
- package/src/commands/project/claim.js +0 -132
- package/src/commands/project/doctor-procs.js +0 -162
- package/src/commands/project/fleet.js +0 -66
- package/src/commands/project/heavy.js +0 -81
- package/src/commands/project/install-plugin-cmd.js +0 -27
- package/src/commands/project/status.js +0 -61
- package/src/commands/project/worktree.js +0 -1234
- package/src/commands/state/advance.js +0 -248
- package/src/commands/state/approve.js +0 -303
- package/src/commands/state/archive.js +0 -231
- package/src/commands/state/auto-approval.js +0 -67
- package/src/commands/state/create.js +0 -274
- package/src/commands/state/delete.js +0 -192
- package/src/commands/state/finish.js +0 -1247
- package/src/commands/state/gate-check.js +0 -244
- package/src/commands/state/gate-decision.js +0 -122
- package/src/commands/state/list.js +0 -244
- package/src/commands/state/next.js +0 -24
- package/src/commands/state/recap.js +0 -80
- package/src/commands/state/report-check.js +0 -244
- package/src/commands/state/retype.js +0 -110
- package/src/commands/validation/verify.js +0 -421
- package/src/core/state/feature-identity.js +0 -10
- package/src/core/state/gate-order.js +0 -23
- package/src/core/state/lifecycle-audit.js +0 -171
- package/src/core/state/state-manager.js +0 -523
- package/src/core/templates/template-seed.js +0 -21
- package/src/core/work-types.js +0 -44
- package/src/dashboard/app/App.jsx +0 -84
- package/src/dashboard/app/components/ActivityFeed.jsx +0 -166
- package/src/dashboard/app/components/CommandPalette.jsx +0 -144
- package/src/dashboard/app/components/DetailPanel.jsx +0 -43
- package/src/dashboard/app/components/EntityLink.jsx +0 -42
- package/src/dashboard/app/components/ErrorBoundary.jsx +0 -47
- package/src/dashboard/app/components/FlowGraph.jsx +0 -19
- package/src/dashboard/app/components/GatePauses.jsx +0 -116
- package/src/dashboard/app/components/KnowledgeMarkdown.jsx +0 -42
- package/src/dashboard/app/components/Markdown.jsx +0 -38
- package/src/dashboard/app/components/PhaseRail.jsx +0 -100
- package/src/dashboard/app/components/SearchFilter.jsx +0 -36
- package/src/dashboard/app/components/SessionMap.jsx +0 -77
- package/src/dashboard/app/components/Sidebar.jsx +0 -147
- package/src/dashboard/app/hooks/useMorphQuery.js +0 -44
- package/src/dashboard/app/hooks/usePref.js +0 -34
- package/src/dashboard/app/lib/format.js +0 -69
- package/src/dashboard/app/lib/phases.js +0 -75
- package/src/dashboard/app/lib/project.js +0 -38
- package/src/dashboard/app/main.jsx +0 -13
- package/src/dashboard/app/pages/Activity.jsx +0 -28
- package/src/dashboard/app/pages/AgentMap.jsx +0 -363
- package/src/dashboard/app/pages/FeatureDetail.jsx +0 -579
- package/src/dashboard/app/pages/Features.jsx +0 -393
- package/src/dashboard/app/pages/Guide.jsx +0 -145
- package/src/dashboard/app/pages/HookInspector.jsx +0 -444
- package/src/dashboard/app/pages/PhasePipeline.jsx +0 -273
- package/src/dashboard/app/pages/Portfolio.jsx +0 -190
- package/src/dashboard/app/pages/RulesMap.jsx +0 -285
- package/src/dashboard/app/pages/SkillsLibrary.jsx +0 -468
- package/src/dashboard/app/pages/Standards.jsx +0 -392
- package/src/dashboard/app/styles/index.css +0 -187
- package/src/dashboard/index.html +0 -14
- package/src/dashboard/package.json +0 -32
- package/src/dashboard/scanner/activity-scanner.js +0 -321
- package/src/dashboard/scanner/agents-scanner.js +0 -67
- package/src/dashboard/scanner/docs-scanner.js +0 -34
- package/src/dashboard/scanner/feature-status.js +0 -7
- package/src/dashboard/scanner/features-scanner.js +0 -397
- package/src/dashboard/scanner/hooks-scanner.js +0 -96
- package/src/dashboard/scanner/index.js +0 -21
- package/src/dashboard/scanner/phases-scanner.js +0 -14
- package/src/dashboard/scanner/portfolio.js +0 -129
- package/src/dashboard/scanner/project-api.js +0 -160
- package/src/dashboard/scanner/rules-scanner.js +0 -46
- package/src/dashboard/scanner/skills-scanner.js +0 -104
- package/src/dashboard/scanner/standards-scanner.js +0 -38
- package/src/dashboard/vite-plugin-morph-data.js +0 -120
- package/src/dashboard/vite.config.js +0 -26
- package/src/lib/ci/ci-verify.js +0 -30
- package/src/lib/ci/github-ci.js +0 -52
- package/src/lib/ci/pr-checks.js +0 -76
- package/src/lib/e2e/applicability.js +0 -39
- package/src/lib/e2e/compose-env.js +0 -80
- package/src/lib/e2e/stack-teardown.js +0 -96
- package/src/lib/git/branch-classifier.js +0 -104
- package/src/lib/git/evidence-staleness.js +0 -40
- package/src/lib/git/gh.js +0 -15
- package/src/lib/git/pending-prs.js +0 -58
- package/src/lib/git/pr-files.js +0 -31
- package/src/lib/git/pr-index.js +0 -39
- package/src/lib/git/tree-fingerprint.js +0 -58
- package/src/lib/git/tree-state.js +0 -125
- package/src/lib/heavy/cleanup.js +0 -72
- package/src/lib/heavy/gate.js +0 -168
- package/src/lib/heavy/live-stacks.js +0 -64
- package/src/lib/heavy/reclaim.js +0 -107
- package/src/lib/heavy/watchdog.js +0 -46
- package/src/lib/next-step.js +0 -12
- package/src/lib/plan/critique.js +0 -67
- package/src/lib/plan/plan-template.js +0 -18
- package/src/lib/procs/classify.js +0 -91
- package/src/lib/procs/list.js +0 -124
- package/src/lib/procs/prune.js +0 -47
- package/src/lib/procs/wslconfig.js +0 -70
- package/src/lib/projects/registry.js +0 -121
- package/src/lib/recap/piper.js +0 -36
- package/src/lib/recap/recap.js +0 -259
- package/src/lib/review-confirmation.js +0 -66
- package/src/lib/risk/diff-risk.js +0 -137
- package/src/lib/risk-detector.js +0 -638
- package/src/lib/specs/design-seed.js +0 -18
- package/src/lib/specs/screen-checklist.js +0 -315
- package/src/lib/stack/stack-profile.js +0 -69
- package/src/lib/tasks/eval-node.js +0 -293
- package/src/lib/tasks/linux-runner.js +0 -200
- package/src/lib/tasks/test-nodes.js +0 -414
- package/src/lib/tasks/test-runner.js +0 -569
- package/src/lib/telemetry/metrics.js +0 -384
- package/src/lib/telemetry/telemetry-reader.js +0 -276
- package/src/lib/telemetry/verify-event.js +0 -57
- package/src/lib/validators/code-budget/code-budget-validator.js +0 -170
- package/src/lib/validators/contracts/contract-compliance-validator.js +0 -219
- package/src/lib/validators/nextjs/next-component-validator.js +0 -142
- package/src/lib/validators/packages/package-validator.js +0 -310
- package/src/lib/validators/reuse/reuse-validator.js +0 -202
- package/src/lib/validators/reuse/symbol-scanner.js +0 -64
- package/src/lib/validators/validation-runner.js +0 -188
- package/src/lib/validators/verify-cache.js +0 -63
- package/src/lib/validators/verify-runner.js +0 -971
- package/src/lib/verify/affected.js +0 -143
- package/src/lib/verify/detached.js +0 -159
- package/src/lib/view/feature-html.js +0 -480
- package/src/lib/view/feature-page.client.js +0 -109
- package/src/lib/view/feature-page.css +0 -278
- package/src/lib/view/feature-view.js +0 -113
- package/src/lib/view/flow-layers.js +0 -79
- package/src/lib/view/flow-svg.js +0 -63
- package/src/lib/view/tokens.css +0 -18
- package/src/lib/work-type-detector.js +0 -81
- package/src/lib/worktree/dirs.js +0 -3
- package/src/lib/worktree/docker-audit.js +0 -175
- package/src/lib/worktree/env-allocator.js +0 -177
- package/src/lib/worktree/feature-truth.js +0 -145
- package/src/lib/worktree/finish-backup.js +0 -529
- package/src/lib/worktree/fleet-scanner.js +0 -223
- package/src/lib/worktree/ignored-triage.js +0 -136
- package/src/lib/worktree/vscode-settings.js +0 -112
- package/src/lib/worktree/worktree-audit.js +0 -323
- package/src/lib/worktree/worktree-include.js +0 -44
- package/src/scripts/install-plugin.js +0 -114
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'fs';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import { glob } from 'glob';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
|
|
6
|
-
// Source: framework/standards/dotnet10-compatibility.md
|
|
7
|
-
const COMPATIBILITY_MATRIX = {
|
|
8
|
-
'Hangfire.AspNetCore': {
|
|
9
|
-
9: '1.8.0',
|
|
10
|
-
10: '1.8.22',
|
|
11
|
-
breaking: false,
|
|
12
|
-
reason: '.NET 10 runtime compatibility'
|
|
13
|
-
},
|
|
14
|
-
'Hangfire.Core': {
|
|
15
|
-
9: '1.8.0',
|
|
16
|
-
10: '1.8.22',
|
|
17
|
-
breaking: false
|
|
18
|
-
},
|
|
19
|
-
'Microsoft.EntityFrameworkCore': {
|
|
20
|
-
9: '9.0.0',
|
|
21
|
-
10: '10.0.0',
|
|
22
|
-
breaking: true,
|
|
23
|
-
reason: 'EF Core 10 required for .NET 10 runtime'
|
|
24
|
-
},
|
|
25
|
-
'Microsoft.EntityFrameworkCore.SqlServer': {
|
|
26
|
-
9: '9.0.0',
|
|
27
|
-
10: '10.0.0',
|
|
28
|
-
breaking: true
|
|
29
|
-
},
|
|
30
|
-
'Microsoft.EntityFrameworkCore.Design': {
|
|
31
|
-
9: '9.0.0',
|
|
32
|
-
10: '10.0.0',
|
|
33
|
-
breaking: true
|
|
34
|
-
},
|
|
35
|
-
'Microsoft.AspNetCore.Components.WebAssembly': {
|
|
36
|
-
9: '9.0.0',
|
|
37
|
-
10: '10.0.0',
|
|
38
|
-
breaking: false
|
|
39
|
-
},
|
|
40
|
-
'Microsoft.SemanticKernel': {
|
|
41
|
-
9: null,
|
|
42
|
-
10: null,
|
|
43
|
-
deprecated: true,
|
|
44
|
-
replacement: 'Microsoft.Extensions.AI.Abstractions',
|
|
45
|
-
reason: 'Use Microsoft Agent Framework for .NET 10'
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export class PackageValidator {
|
|
50
|
-
constructor(projectPath = '.') {
|
|
51
|
-
this.projectPath = projectPath;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async validateAll() {
|
|
55
|
-
const csprojFiles = await glob('**/*.csproj', {
|
|
56
|
-
cwd: this.projectPath,
|
|
57
|
-
ignore: ['**/obj/**', '**/bin/**', '**/node_modules/**']
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
if (csprojFiles.length === 0) {
|
|
61
|
-
return {
|
|
62
|
-
status: 'ok',
|
|
63
|
-
message: 'No .csproj files found'
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const results = [];
|
|
68
|
-
const allIssues = [];
|
|
69
|
-
|
|
70
|
-
for (const file of csprojFiles) {
|
|
71
|
-
// glob paths are relative to `cwd: this.projectPath`, never to process.cwd().
|
|
72
|
-
const result = await this.validateFile(join(this.projectPath, file));
|
|
73
|
-
if (result.issues.length > 0) {
|
|
74
|
-
results.push({ file, ...result });
|
|
75
|
-
allIssues.push(...result.issues.map(i => ({ ...i, file })));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
status: allIssues.some(i => i.level === 'error') ? 'error' : 'ok',
|
|
81
|
-
totalFiles: csprojFiles.length,
|
|
82
|
-
filesWithIssues: results.length,
|
|
83
|
-
// The runner's contract: without these counts the findings read as `errors: 0`.
|
|
84
|
-
errors: allIssues.filter(i => i.level === 'error').length,
|
|
85
|
-
warnings: allIssues.filter(i => i.level === 'warning').length,
|
|
86
|
-
issues: allIssues,
|
|
87
|
-
results
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async validateFile(filePath) {
|
|
92
|
-
const content = readFileSync(filePath, 'utf-8');
|
|
93
|
-
|
|
94
|
-
const tfmMatch = content.match(/<TargetFramework>(.*?)<\/TargetFramework>/);
|
|
95
|
-
if (!tfmMatch) {
|
|
96
|
-
return {
|
|
97
|
-
dotnetVersion: null,
|
|
98
|
-
issues: [{
|
|
99
|
-
level: 'warning',
|
|
100
|
-
message: 'Could not detect TargetFramework'
|
|
101
|
-
}]
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const targetFramework = tfmMatch[1];
|
|
106
|
-
const dotnetVersion = parseInt(targetFramework.replace('net', ''));
|
|
107
|
-
|
|
108
|
-
if (dotnetVersion < 9) {
|
|
109
|
-
return {
|
|
110
|
-
dotnetVersion,
|
|
111
|
-
issues: [{
|
|
112
|
-
level: 'info',
|
|
113
|
-
message: `Using .NET ${dotnetVersion} (no validation rules for versions < 9)`
|
|
114
|
-
}]
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const packages = this.extractPackages(content);
|
|
119
|
-
|
|
120
|
-
const issues = [];
|
|
121
|
-
|
|
122
|
-
for (const pkg of packages) {
|
|
123
|
-
const issue = this.validatePackage(pkg, dotnetVersion);
|
|
124
|
-
if (issue) {
|
|
125
|
-
issues.push(issue);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
dotnetVersion,
|
|
131
|
-
packages,
|
|
132
|
-
issues
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
extractPackages(csprojContent) {
|
|
137
|
-
const packages = [];
|
|
138
|
-
const packageRegex = /<PackageReference\s+Include="([^"]+)"\s+Version="([^"]+)"/g;
|
|
139
|
-
let match;
|
|
140
|
-
|
|
141
|
-
while ((match = packageRegex.exec(csprojContent)) !== null) {
|
|
142
|
-
packages.push({
|
|
143
|
-
name: match[1],
|
|
144
|
-
version: match[2]
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return packages;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
validatePackage(pkg, dotnetVersion) {
|
|
152
|
-
const rule = COMPATIBILITY_MATRIX[pkg.name];
|
|
153
|
-
|
|
154
|
-
if (!rule) {
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (rule.deprecated) {
|
|
159
|
-
return {
|
|
160
|
-
level: 'error',
|
|
161
|
-
package: pkg.name,
|
|
162
|
-
installedVersion: pkg.version,
|
|
163
|
-
message: `${pkg.name} is deprecated for .NET ${dotnetVersion}`,
|
|
164
|
-
reason: rule.reason,
|
|
165
|
-
replacement: rule.replacement,
|
|
166
|
-
autoFix: false
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const requiredVersion = rule[dotnetVersion];
|
|
171
|
-
|
|
172
|
-
if (!requiredVersion) {
|
|
173
|
-
return {
|
|
174
|
-
level: 'info',
|
|
175
|
-
package: pkg.name,
|
|
176
|
-
installedVersion: pkg.version,
|
|
177
|
-
message: `No validation rule for ${pkg.name} on .NET ${dotnetVersion}`
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const comparison = this.compareVersions(pkg.version, requiredVersion);
|
|
182
|
-
|
|
183
|
-
if (comparison < 0) {
|
|
184
|
-
return {
|
|
185
|
-
level: rule.breaking ? 'error' : 'warning',
|
|
186
|
-
package: pkg.name,
|
|
187
|
-
installedVersion: pkg.version,
|
|
188
|
-
requiredVersion,
|
|
189
|
-
message: `${pkg.name} ${pkg.version} is incompatible with .NET ${dotnetVersion} (requires ≥${requiredVersion})`,
|
|
190
|
-
reason: rule.reason,
|
|
191
|
-
migration: rule.migration,
|
|
192
|
-
breaking: rule.breaking,
|
|
193
|
-
autoFix: {
|
|
194
|
-
available: true,
|
|
195
|
-
command: `dotnet add package ${pkg.name} --version ${requiredVersion}`
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// -1 (v1 < v2), 0 (equal), 1 (v1 > v2)
|
|
204
|
-
compareVersions(v1, v2) {
|
|
205
|
-
const parts1 = v1.split('.').map(p => parseInt(p.replace(/[^0-9]/g, '')) || 0);
|
|
206
|
-
const parts2 = v2.split('.').map(p => parseInt(p.replace(/[^0-9]/g, '')) || 0);
|
|
207
|
-
|
|
208
|
-
const maxLength = Math.max(parts1.length, parts2.length);
|
|
209
|
-
|
|
210
|
-
for (let i = 0; i < maxLength; i++) {
|
|
211
|
-
const p1 = parts1[i] || 0;
|
|
212
|
-
const p2 = parts2[i] || 0;
|
|
213
|
-
|
|
214
|
-
if (p1 < p2) return -1;
|
|
215
|
-
if (p1 > p2) return 1;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return 0;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
formatResults(results) {
|
|
222
|
-
if (results.status === 'ok') {
|
|
223
|
-
console.log(chalk.green('✅ All packages are compatible'));
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
console.log(chalk.yellow(`\n⚠️ Found issues in ${results.filesWithIssues} of ${results.totalFiles} .csproj files:\n`));
|
|
228
|
-
|
|
229
|
-
for (const fileResult of results.results) {
|
|
230
|
-
console.log(chalk.cyan(`📄 ${fileResult.file} (.NET ${fileResult.dotnetVersion})`));
|
|
231
|
-
|
|
232
|
-
const errors = fileResult.issues.filter(i => i.level === 'error');
|
|
233
|
-
const warnings = fileResult.issues.filter(i => i.level === 'warning');
|
|
234
|
-
const infos = fileResult.issues.filter(i => i.level === 'info');
|
|
235
|
-
|
|
236
|
-
if (errors.length > 0) {
|
|
237
|
-
console.log(chalk.red(`\n ❌ ${errors.length} error(s):`));
|
|
238
|
-
errors.forEach(e => {
|
|
239
|
-
console.log(chalk.red(` - ${e.message}`));
|
|
240
|
-
if (e.reason) {
|
|
241
|
-
console.log(chalk.gray(` Reason: ${e.reason}`));
|
|
242
|
-
}
|
|
243
|
-
if (e.replacement) {
|
|
244
|
-
console.log(chalk.cyan(` Use instead: ${e.replacement}`));
|
|
245
|
-
}
|
|
246
|
-
if (e.autoFix?.available) {
|
|
247
|
-
console.log(chalk.green(` Auto-fix: ${e.autoFix.command}`));
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (warnings.length > 0) {
|
|
253
|
-
console.log(chalk.yellow(`\n ⚠️ ${warnings.length} warning(s):`));
|
|
254
|
-
warnings.forEach(w => {
|
|
255
|
-
console.log(chalk.yellow(` - ${w.message}`));
|
|
256
|
-
if (w.autoFix?.available) {
|
|
257
|
-
console.log(chalk.green(` Auto-fix: ${w.autoFix.command}`));
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
if (infos.length > 0) {
|
|
263
|
-
console.log(chalk.gray(`\n ℹ️ ${infos.length} info(s):`));
|
|
264
|
-
infos.forEach(i => {
|
|
265
|
-
console.log(chalk.gray(` - ${i.message}`));
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
console.log('');
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
async autoFix(results) {
|
|
274
|
-
const { execSync } = await import('child_process');
|
|
275
|
-
let fixedCount = 0;
|
|
276
|
-
|
|
277
|
-
for (const fileResult of results.results) {
|
|
278
|
-
for (const issue of fileResult.issues) {
|
|
279
|
-
if (issue.autoFix?.available) {
|
|
280
|
-
try {
|
|
281
|
-
console.log(chalk.cyan(`🔧 Fixing ${issue.package}...`));
|
|
282
|
-
execSync(issue.autoFix.command, { stdio: 'inherit' });
|
|
283
|
-
fixedCount++;
|
|
284
|
-
console.log(chalk.green(` ✅ Fixed: ${issue.package} → ${issue.requiredVersion}`));
|
|
285
|
-
} catch (error) {
|
|
286
|
-
console.log(chalk.red(` ❌ Failed to fix ${issue.package}: ${error.message}`));
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
return fixedCount;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export async function validatePackages(projectPath = '.', options = {}) {
|
|
297
|
-
const validator = new PackageValidator(projectPath);
|
|
298
|
-
const results = await validator.validateAll();
|
|
299
|
-
|
|
300
|
-
if (options.verbose) {
|
|
301
|
-
validator.formatResults(results);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
if (options.autoFix && results.results?.length) {
|
|
305
|
-
const fixedCount = await validator.autoFix(results);
|
|
306
|
-
console.log(chalk.green(`\n✅ Auto-fixed ${fixedCount} issue(s)`));
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
return results;
|
|
310
|
-
}
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
// Só tipos, só mesma linguagem (contrato espelhado C#↔TS não se resolve por aviso).
|
|
2
|
-
// Mesma feature = error; outra feature = warning (VSA admite DTO homônimo entre slices).
|
|
3
|
-
// Veredito CRIAR no plano rebaixa a warning: cobra-se a decisão AUSENTE, não a tomada.
|
|
4
|
-
|
|
5
|
-
import { existsSync, readFileSync } from 'fs';
|
|
6
|
-
import { execFileSync } from 'child_process';
|
|
7
|
-
import { join, isAbsolute } from 'path';
|
|
8
|
-
|
|
9
|
-
import { loadGraph } from '../../graph/graph-loader.js';
|
|
10
|
-
import { languageOf } from '../../graph/sanitize.js';
|
|
11
|
-
import {
|
|
12
|
-
featureOf,
|
|
13
|
-
isIdiomaticLocalName,
|
|
14
|
-
isScannableFile,
|
|
15
|
-
scanDeclarations,
|
|
16
|
-
} from './symbol-scanner.js';
|
|
17
|
-
import { readPlanChecks } from '../../plan/checks.js';
|
|
18
|
-
|
|
19
|
-
const MAX_CITED = 4;
|
|
20
|
-
|
|
21
|
-
export function buildExistingIndex(graph) {
|
|
22
|
-
const index = new Map();
|
|
23
|
-
|
|
24
|
-
for (const node of graph?.nodes ?? []) {
|
|
25
|
-
// `source_file` vazio é stub não resolvido (BCL, NuGet): `Task` do .NET não é duplicação.
|
|
26
|
-
if (!node.source_file) continue;
|
|
27
|
-
// Nós de ARQUIVO também têm `_callable_class`; distinguem-se pelo label com extensão.
|
|
28
|
-
if (node._callable_class !== true) continue;
|
|
29
|
-
if (/\.[a-z0-9]+$/i.test(node.label)) continue;
|
|
30
|
-
if (!isScannableFile(node.source_file)) continue;
|
|
31
|
-
|
|
32
|
-
const key = String(node.label).toLowerCase();
|
|
33
|
-
const entry = {
|
|
34
|
-
name: node.label,
|
|
35
|
-
file: node.source_file.replace(/\\/g, '/'),
|
|
36
|
-
language: languageOf(node.source_file),
|
|
37
|
-
feature: featureOf(node.source_file),
|
|
38
|
-
};
|
|
39
|
-
const bucket = index.get(key);
|
|
40
|
-
if (bucket) bucket.push(entry);
|
|
41
|
-
else index.set(key, [entry]);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return index;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function findDuplicateSymbols(declarations, existing, opts = {}) {
|
|
48
|
-
const verdicts = opts.verdicts ?? new Map();
|
|
49
|
-
const issues = [];
|
|
50
|
-
|
|
51
|
-
const byName = new Map();
|
|
52
|
-
for (const decl of declarations) {
|
|
53
|
-
const key = decl.name.toLowerCase();
|
|
54
|
-
const bucket = byName.get(key);
|
|
55
|
-
if (bucket) bucket.push(decl);
|
|
56
|
-
else byName.set(key, [decl]);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
for (const [key, decls] of byName) {
|
|
60
|
-
if (isIdiomaticLocalName(decls[0].name)) continue;
|
|
61
|
-
|
|
62
|
-
const declaredFiles = new Set(decls.map((d) => d.file));
|
|
63
|
-
const language = languageOf(decls[0].file);
|
|
64
|
-
|
|
65
|
-
// A leva também conta: o grafo só é refeito depois do commit e ainda não viu o código novo.
|
|
66
|
-
const fromGraph = (existing.get(key) ?? []).filter(
|
|
67
|
-
(e) => e.language === language && !declaredFiles.has(e.file),
|
|
68
|
-
);
|
|
69
|
-
const fromBatch = decls
|
|
70
|
-
.slice(1)
|
|
71
|
-
.filter((d) => languageOf(d.file) === language)
|
|
72
|
-
.map((d) => ({ name: d.name, file: d.file, language, feature: featureOf(d.file) }));
|
|
73
|
-
|
|
74
|
-
const elsewhere = [...fromGraph, ...fromBatch];
|
|
75
|
-
if (elsewhere.length === 0) continue;
|
|
76
|
-
|
|
77
|
-
const homeFeature = featureOf(decls[0].file);
|
|
78
|
-
const intra = elsewhere.some((e) => e.feature === homeFeature);
|
|
79
|
-
const verdict = verdicts.get(key);
|
|
80
|
-
const planned = verdict?.verdict === 'CRIAR';
|
|
81
|
-
|
|
82
|
-
const locations = elsewhere.slice(0, MAX_CITED).map((e) => e.file);
|
|
83
|
-
const more = elsewhere.length - locations.length;
|
|
84
|
-
|
|
85
|
-
issues.push({
|
|
86
|
-
level: intra && !planned ? 'error' : 'warning',
|
|
87
|
-
scope: intra ? 'intra-feature' : 'cross-feature',
|
|
88
|
-
symbol: decls[0].name,
|
|
89
|
-
file: decls[0].file,
|
|
90
|
-
line: decls[0].line,
|
|
91
|
-
planned,
|
|
92
|
-
message:
|
|
93
|
-
`${decls[0].kind} "${decls[0].name}" já existe ${intra ? 'na MESMA feature' : 'no projeto'} ` +
|
|
94
|
-
`(${elsewhere.length}× em ${locations.join(', ')}${more > 0 ? ` (+${more})` : ''})` +
|
|
95
|
-
(planned ? ' — o plano declarou CRIAR, mas confira se a justificativa ainda vale' : ''),
|
|
96
|
-
solution: intra
|
|
97
|
-
? `Reuse ou estenda o tipo existente em vez de redeclarar. Confirme com ` +
|
|
98
|
-
`\`morph-spec graph explain ${decls[0].name}\` (sem grafo: ` +
|
|
99
|
-
`\`grep -rn "${decls[0].name}"\`) e, se a criação for mesmo necessária, ` +
|
|
100
|
-
'registre o veredito CRIAR com a justificativa em "why" na tabela ## Reuso do plan.md.'
|
|
101
|
-
: `VSA tolera DTO homônimo entre slices — confirme que são conceitos ` +
|
|
102
|
-
`diferentes e não a mesma coisa escrita duas vezes.`,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return issues.sort((a, b) => {
|
|
107
|
-
if (a.level !== b.level) return a.level === 'error' ? -1 : 1;
|
|
108
|
-
return a.symbol.localeCompare(b.symbol);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function readReuseVerdicts(projectPath, featureName) {
|
|
113
|
-
const verdicts = new Map();
|
|
114
|
-
if (!featureName) return verdicts;
|
|
115
|
-
// Sem extração, nenhum veredito: a cobrança só fica mais rígida, nunca mais frouxa.
|
|
116
|
-
for (const entry of readPlanChecks(projectPath, featureName).checks?.reuse ?? []) {
|
|
117
|
-
if (!entry?.concept) continue;
|
|
118
|
-
verdicts.set(String(entry.concept).toLowerCase(), {
|
|
119
|
-
verdict: String(entry.verdict || '').toUpperCase(),
|
|
120
|
-
target: entry.target,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
return verdicts;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function collectChangedFiles(projectPath) {
|
|
127
|
-
const files = new Set();
|
|
128
|
-
try {
|
|
129
|
-
const out = execFileSync('git', ['status', '--porcelain', '--untracked-files=all'], {
|
|
130
|
-
cwd: projectPath,
|
|
131
|
-
encoding: 'utf-8',
|
|
132
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
133
|
-
windowsHide: true,
|
|
134
|
-
});
|
|
135
|
-
for (const line of out.split(/\r?\n/)) {
|
|
136
|
-
if (!line.trim()) continue;
|
|
137
|
-
// Rename vem como "XY antigo -> novo": só o destino interessa.
|
|
138
|
-
const path = line.slice(3).split(' -> ').pop().replace(/^"|"$/g, '');
|
|
139
|
-
if (path) files.add(path.replace(/\\/g, '/'));
|
|
140
|
-
}
|
|
141
|
-
} catch {
|
|
142
|
-
// Fora de um repo git, ou git indisponível: o plano já respondeu.
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return [...files];
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export async function validateReuse(projectPath, featureName = null, options = {}) {
|
|
149
|
-
const result = { errors: 0, warnings: 0, issues: [] };
|
|
150
|
-
|
|
151
|
-
const graph = options._graph ?? (() => {
|
|
152
|
-
const loaded = loadGraph(projectPath);
|
|
153
|
-
return loaded.ok ? loaded.graph : null;
|
|
154
|
-
})();
|
|
155
|
-
|
|
156
|
-
if (!graph) {
|
|
157
|
-
// Sem grafo segue em frente: reprovar faria de uma dependência opcional um pré-requisito.
|
|
158
|
-
result._skipReason = 'sem grafo de codebase — `morph-spec graph build` habilita esta verificação';
|
|
159
|
-
// "Não pude checar", diferente de "nada a checar": o verify relata em voz alta.
|
|
160
|
-
result._skipUnavailable = true;
|
|
161
|
-
return result;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const changed = options.changedFiles ?? collectChangedFiles(projectPath, featureName);
|
|
165
|
-
const declarations = [];
|
|
166
|
-
|
|
167
|
-
for (const rel of changed) {
|
|
168
|
-
if (!isScannableFile(rel)) continue;
|
|
169
|
-
const abs = isAbsolute(rel) ? rel : join(projectPath, rel);
|
|
170
|
-
if (!existsSync(abs)) continue;
|
|
171
|
-
let content;
|
|
172
|
-
try {
|
|
173
|
-
content = readFileSync(abs, 'utf8');
|
|
174
|
-
} catch {
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
for (const decl of scanDeclarations(content, rel)) {
|
|
178
|
-
declarations.push({ ...decl, file: rel.replace(/\\/g, '/') });
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (declarations.length === 0) {
|
|
183
|
-
result._skipReason = 'nenhum tipo novo declarado nos arquivos desta feature';
|
|
184
|
-
return result;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const existing = buildExistingIndex(graph);
|
|
188
|
-
const verdicts = readReuseVerdicts(projectPath, featureName);
|
|
189
|
-
const issues = findDuplicateSymbols(declarations, existing, { verdicts });
|
|
190
|
-
|
|
191
|
-
result.issues = issues.map((i) => ({
|
|
192
|
-
level: i.level,
|
|
193
|
-
message: i.message,
|
|
194
|
-
file: i.file,
|
|
195
|
-
line: i.line,
|
|
196
|
-
solution: i.solution,
|
|
197
|
-
}));
|
|
198
|
-
result.errors = issues.filter((i) => i.level === 'error').length;
|
|
199
|
-
result.warnings = issues.filter((i) => i.level === 'warning').length;
|
|
200
|
-
|
|
201
|
-
return result;
|
|
202
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// Lê declarações do disco, não do grafo: o grafo só é refeito depois de um commit,
|
|
2
|
-
// então o código recém-escrito (o que este validador existe para pegar) ainda não está nele.
|
|
3
|
-
|
|
4
|
-
import { isTestPath, languageOf } from '../../graph/sanitize.js';
|
|
5
|
-
import { isProjectSource } from '../../../../framework/hooks/shared/source-files.js';
|
|
6
|
-
|
|
7
|
-
// Tipo LOCAL de arquivo por convenção (todo componente tem seu `Props`), não conceito do
|
|
8
|
-
// domínio. Só nome genérico de UMA palavra: com qualificador (`FilterOption`) a regra vale.
|
|
9
|
-
const IDIOMATIC_LOCAL_NAMES = new Set([
|
|
10
|
-
'props', 'state', 'row', 'item', 'column', 'context', 'params', 'options',
|
|
11
|
-
]);
|
|
12
|
-
|
|
13
|
-
const CSHARP_DECL =
|
|
14
|
-
/^\s*(?:\[[^\]]*\]\s*)*(?:(?:public|internal|private|protected|sealed|abstract|static|readonly|new|file|partial)\s+)*(class|record|interface|enum|struct)\s+([A-Za-z_]\w*)/;
|
|
15
|
-
|
|
16
|
-
const WEB_DECL =
|
|
17
|
-
/^\s*(?:export\s+(?:default\s+)?)?(?:declare\s+)?(?:abstract\s+)?(interface|type|class|enum)\s+([A-Za-z_$][\w$]*)/;
|
|
18
|
-
|
|
19
|
-
const COMMENT_LINE = /^\s*(?:\/\/|\/\*|\*|<!--)/;
|
|
20
|
-
|
|
21
|
-
export function isTestFile(sourceFile) {
|
|
22
|
-
return isTestPath(String(sourceFile || '').replace(/\\/g, '/'));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function isScannableFile(sourceFile) {
|
|
26
|
-
return isProjectSource(sourceFile) && !isTestFile(sourceFile);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Segmento após `features/`/`Features/`, senão a pasta do arquivo. */
|
|
30
|
-
export function featureOf(sourceFile) {
|
|
31
|
-
const f = String(sourceFile || '').replace(/\\/g, '/');
|
|
32
|
-
const m = /(?:^|\/)(?:features|Features)\/([^/]+)/.exec(f);
|
|
33
|
-
if (m) return m[1].toLowerCase();
|
|
34
|
-
return f.split('/').slice(0, -1).join('/').toLowerCase();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function isIdiomaticLocalName(name) {
|
|
38
|
-
return IDIOMATIC_LOCAL_NAMES.has(String(name).toLowerCase());
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// `partial` (C#) é descartado: declarar a mesma classe em dois arquivos é o propósito da palavra-chave.
|
|
42
|
-
export function scanDeclarations(content, sourceFile) {
|
|
43
|
-
const language = languageOf(sourceFile);
|
|
44
|
-
const re = language === 'dotnet' ? CSHARP_DECL : WEB_DECL;
|
|
45
|
-
const out = [];
|
|
46
|
-
const seen = new Set();
|
|
47
|
-
|
|
48
|
-
const lines = String(content || '').split(/\r?\n/);
|
|
49
|
-
for (let i = 0; i < lines.length; i++) {
|
|
50
|
-
const line = lines[i];
|
|
51
|
-
if (COMMENT_LINE.test(line)) continue;
|
|
52
|
-
if (language === 'dotnet' && /\bpartial\s+(class|record|interface|struct)\b/.test(line)) continue;
|
|
53
|
-
|
|
54
|
-
const m = re.exec(line);
|
|
55
|
-
if (!m) continue;
|
|
56
|
-
|
|
57
|
-
const [, kind, name] = m;
|
|
58
|
-
if (seen.has(name)) continue;
|
|
59
|
-
seen.add(name);
|
|
60
|
-
out.push({ name, kind, line: i + 1 });
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return out;
|
|
64
|
-
}
|