summaryrefslogtreecommitdiff
path: root/plugins/code-modernization
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/code-modernization')
-rw-r--r--plugins/code-modernization/commands/modernize-assess.md13
-rw-r--r--plugins/code-modernization/workflows/portfolio-assess.js11
2 files changed, 13 insertions, 11 deletions
diff --git a/plugins/code-modernization/commands/modernize-assess.md b/plugins/code-modernization/commands/modernize-assess.md
index 7f280347..dec2eb23 100644
--- a/plugins/code-modernization/commands/modernize-assess.md
+++ b/plugins/code-modernization/commands/modernize-assess.md
@@ -36,18 +36,19 @@ relaunch with `resumeFromRunId` and finished systems return from cache. Without
the Workflow tool, gather the same row per system yourself.
Per system: SLOC and dominant language (`cloc --csv`, else `scc`, else `find` +
-`wc -l`), file count, mean and max cyclomatic complexity (`lizard`, else count
-decision keywords), dependency freshness (age or pinned-version count of the
-manifest), documentation coverage (source files with a header comment, and
-architecture docs present), and the COCOMO index `2.94 × KSLOC^1.10`. **The
+`wc -l`), file count, complexity measured one way for every system (`scc`'s per-file
+complexity summed, divided by KSLOC, and the most complex single file; without `scc`,
+count decision keywords the same way everywhere), dependency freshness (age or pinned-version count of the
+manifest), documentation coverage (source files whose opening comment
+describes the file, not just a license, and architecture docs present), and the COCOMO index `2.94 × KSLOC^1.10`. **The
index is a relative size measure for ranking systems, never a timeline or a cost**
(it assumes human-team productivity): label the column "index", never print
person-months, a date or a duration.
Write `analysis/portfolio.html` (dark `#1e1e1e` background, `#d4d4d4` text,
`#cc785c` accent, system-ui, CSS inline): one row per system, columns **System ·
-Lang · KSLOC · Files · Mean CCN · Max CCN · Dep Freshness · Doc Coverage % ·
-Complexity index · Risk**, index and Risk cells graded green to red, and a
+Lang · KSLOC · Files · Complexity per KSLOC · Most complex file · Dep Freshness · Doc
+Coverage % · Complexity index · Risk**, index and Risk cells graded green to red, and a
2–3 sentence recommendation of which system goes first and why. Tell the user to
open it, then stop.
diff --git a/plugins/code-modernization/workflows/portfolio-assess.js b/plugins/code-modernization/workflows/portfolio-assess.js
index ddda5c7c..029748b3 100644
--- a/plugins/code-modernization/workflows/portfolio-assess.js
+++ b/plugins/code-modernization/workflows/portfolio-assess.js
@@ -41,14 +41,14 @@ see: file:line plus a 2-4 character preview, never the value.`
const SYSTEM_SCHEMA = {
type: 'object',
- required: ['sloc', 'dominantLanguage', 'fileCount', 'metricsTool'],
+ required: ['sloc', 'dominantLanguage', 'fileCount', 'metricsTool', 'complexityTotal', 'maxFileComplexity'],
properties: {
sloc: { type: 'number', description: 'Total source lines of code' },
dominantLanguage: { type: 'string' },
languages: { type: 'array', items: { type: 'string' }, description: 'All significant languages, largest first' },
fileCount: { type: 'number' },
- meanCcn: { type: 'number', description: 'Mean cyclomatic complexity, or -1 if not measurable' },
- maxCcn: { type: 'number', description: 'Max cyclomatic complexity, or -1 if not measurable' },
+ complexityTotal: { type: 'number', description: 'Sum of the per-file decision-point complexity over all source files, measured the one way the prompt says' },
+ maxFileComplexity: { type: 'number', description: 'The highest complexity of any single source file, measured the same way' },
metricsTool: { type: 'string', description: 'Which tool produced the numbers (scc / cloc / lizard / find+wc fallback) so figures are reproducible' },
depManifest: { type: 'string', description: 'Path of the dependency manifest found, or "none"' },
depFreshness: { type: 'string', description: 'One phrase: manifest age / pinned-version staleness signal' },
@@ -66,10 +66,10 @@ const rows = await pipeline(
agent(
`Measure the legacy system at ${parentDir}/${sys} for a modernization portfolio heat-map.
-1. LOC + complexity: prefer \`scc\`, then \`cloc\` + \`lizard\`, then find+wc with decision-keyword counting as last resort. Report which tool you used in metricsTool.
+1. Lines and complexity. Measure complexity the SAME way for every system so the numbers compare: run \`scc --by-file\` and take its Complexity column, summed over all source files (complexityTotal) and the largest single file (maxFileComplexity). Without \`scc\`, count decision keywords per file (if, else if, for, while, case, catch, &&, ||, and the language's equivalents) and say so in metricsTool. Never report lizard's per-function figures here: they do not add up to the same thing. Lines of code come from the same tool.
2. Dominant language and rough file split.
3. Dependency manifest (package.json, pom.xml, *.csproj, requirements*.txt, copybook dir): location, age, pinned-version staleness.
-4. Documentation coverage: % of source files with a header comment block; list architecture docs present (README, docs/, ADRs).
+4. Documentation coverage: % of source files whose opening comment describes the file (not just a license or copyright notice); list architecture docs present (README, docs/, ADRs).
5. 1-3 risk notes: the things that would most complicate modernizing this system.
${UNTRUSTED}`,
{
@@ -95,6 +95,7 @@ if (failed.length) {
// human-team productivity assumptions).
for (const r of surveyed) {
const ksloc = r.sloc / 1000
+ r.complexityPerKsloc = ksloc > 0 ? Math.round(r.complexityTotal / ksloc) : 0
r.complexityIndex = Math.round(2.94 * Math.pow(ksloc, 1.1) * 10) / 10
}