@aryam/fixmap 0.2.1
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/dist/cli.d.ts +2 -0
- package/dist/cli.js +139 -0
- package/dist/cli.js.map +1 -0
- package/package.json +22 -0
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { writeFile } from "node:fs/promises";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { buildRiskNotes, buildSummary, buildTestRoutes, rankContextFiles, renderJsonReport, renderMarkdownReport, scanRepo } from "@aryam/fixmap-core";
|
|
7
|
+
const USAGE = `FixMap maps an issue, prompt, or diff to context files, test routes, and review risks.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
fixmap plan --issue "Users cannot reset passwords"
|
|
11
|
+
fixmap plan --diff main...HEAD
|
|
12
|
+
fixmap plan --base main --head HEAD --format json
|
|
13
|
+
|
|
14
|
+
Options:
|
|
15
|
+
--issue <text> Issue, prompt, or task description
|
|
16
|
+
--diff <spec> Git diff spec, such as main...HEAD
|
|
17
|
+
--base <ref> Base ref for diffing when --diff is not given
|
|
18
|
+
--head <ref> Head ref for diffing (defaults to HEAD)
|
|
19
|
+
--repo <path> Repository root to scan (defaults to current directory)
|
|
20
|
+
--format <fmt> Output format: markdown (default) or json
|
|
21
|
+
--output <file> Write the report to a file instead of stdout
|
|
22
|
+
--help, -h Show this help
|
|
23
|
+
--version Show the FixMap version
|
|
24
|
+
`;
|
|
25
|
+
const rawArgs = process.argv.slice(2);
|
|
26
|
+
if (rawArgs.length === 0 || rawArgs[0] === "help" || rawArgs.includes("--help") || rawArgs.includes("-h")) {
|
|
27
|
+
process.stdout.write(USAGE);
|
|
28
|
+
process.exit(rawArgs.length === 0 ? 1 : 0);
|
|
29
|
+
}
|
|
30
|
+
if (rawArgs[0] === "--version" || rawArgs[0] === "version") {
|
|
31
|
+
const packageJson = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), "..", "package.json"), "utf8"));
|
|
32
|
+
console.log(packageJson.version);
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
const options = parseArgs(rawArgs);
|
|
36
|
+
if (options.command !== "plan") {
|
|
37
|
+
console.error(`Unknown command: ${options.command || "(none)"}\n\n${USAGE}`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
if (options.unknownArgs.length > 0) {
|
|
41
|
+
console.error(`Unknown or incomplete option(s): ${options.unknownArgs.join(", ")}\n\n${USAGE}`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
if (!options.issueText && !options.diffSpec && !options.baseRef) {
|
|
45
|
+
console.error("Provide --issue, --diff, or --base/--head so FixMap has a task signal.");
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
const repo = await scanRepo({
|
|
49
|
+
repoRoot: options.repoRoot,
|
|
50
|
+
diffSpec: options.diffSpec,
|
|
51
|
+
baseRef: options.baseRef,
|
|
52
|
+
headRef: options.headRef
|
|
53
|
+
});
|
|
54
|
+
const contextFiles = rankContextFiles(repo, {
|
|
55
|
+
issueText: options.issueText,
|
|
56
|
+
diffText: repo.diffText
|
|
57
|
+
});
|
|
58
|
+
const contextPaths = contextFiles.map((file) => file.path);
|
|
59
|
+
const testRoutes = buildTestRoutes(repo, contextPaths);
|
|
60
|
+
const report = {
|
|
61
|
+
summary: buildSummary(contextFiles.length, testRoutes.length),
|
|
62
|
+
contextFiles,
|
|
63
|
+
testRoutes,
|
|
64
|
+
risks: buildRiskNotes(contextPaths),
|
|
65
|
+
changedFiles: repo.changedFiles,
|
|
66
|
+
diagnostics: repo.diagnostics
|
|
67
|
+
};
|
|
68
|
+
const rendered = options.format === "json" ? renderJsonReport(report) : renderMarkdownReport(report);
|
|
69
|
+
if (options.output) {
|
|
70
|
+
await writeFile(options.output, rendered, "utf8");
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
process.stdout.write(rendered);
|
|
74
|
+
}
|
|
75
|
+
function parseArgs(args) {
|
|
76
|
+
const command = args[0] ?? "";
|
|
77
|
+
let issueText = "";
|
|
78
|
+
let repoRoot = process.cwd();
|
|
79
|
+
let diffSpec;
|
|
80
|
+
let baseRef;
|
|
81
|
+
let headRef;
|
|
82
|
+
let format = "markdown";
|
|
83
|
+
let output;
|
|
84
|
+
const unknownArgs = [];
|
|
85
|
+
for (let index = 1; index < args.length; index += 1) {
|
|
86
|
+
const rawArg = args[index];
|
|
87
|
+
if (!rawArg) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const separatorIndex = rawArg.indexOf("=");
|
|
91
|
+
const arg = separatorIndex === -1 ? rawArg : rawArg.slice(0, separatorIndex);
|
|
92
|
+
const inlineValue = separatorIndex === -1 ? undefined : rawArg.slice(separatorIndex + 1);
|
|
93
|
+
const nextValue = inlineValue ?? args[index + 1];
|
|
94
|
+
const consumedNext = inlineValue === undefined;
|
|
95
|
+
if (arg === "--issue" && nextValue) {
|
|
96
|
+
issueText = nextValue;
|
|
97
|
+
index += consumedNext ? 1 : 0;
|
|
98
|
+
}
|
|
99
|
+
else if (arg === "--diff" && nextValue) {
|
|
100
|
+
diffSpec = nextValue;
|
|
101
|
+
index += consumedNext ? 1 : 0;
|
|
102
|
+
}
|
|
103
|
+
else if (arg === "--base" && nextValue) {
|
|
104
|
+
baseRef = nextValue;
|
|
105
|
+
index += consumedNext ? 1 : 0;
|
|
106
|
+
}
|
|
107
|
+
else if (arg === "--head" && nextValue) {
|
|
108
|
+
headRef = nextValue;
|
|
109
|
+
index += consumedNext ? 1 : 0;
|
|
110
|
+
}
|
|
111
|
+
else if (arg === "--repo" && nextValue) {
|
|
112
|
+
repoRoot = resolve(nextValue);
|
|
113
|
+
index += consumedNext ? 1 : 0;
|
|
114
|
+
}
|
|
115
|
+
else if (arg === "--format" && (nextValue === "markdown" || nextValue === "json")) {
|
|
116
|
+
format = nextValue;
|
|
117
|
+
index += consumedNext ? 1 : 0;
|
|
118
|
+
}
|
|
119
|
+
else if (arg === "--output" && nextValue) {
|
|
120
|
+
output = nextValue;
|
|
121
|
+
index += consumedNext ? 1 : 0;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
unknownArgs.push(rawArg);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
command,
|
|
129
|
+
issueText,
|
|
130
|
+
repoRoot,
|
|
131
|
+
diffSpec,
|
|
132
|
+
baseRef,
|
|
133
|
+
headRef,
|
|
134
|
+
format,
|
|
135
|
+
output,
|
|
136
|
+
unknownArgs
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,cAAc,EACd,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,QAAQ,EACT,MAAM,oBAAoB,CAAC;AAe5B,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;CAiBb,CAAC;AAEF,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEtC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CA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CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO;QACP,SAAS;QACT,QAAQ;QACR,QAAQ;QACR,OAAO;QACP,OAAO;QACP,MAAM;QACN,MAAM;QACN,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aryam/fixmap",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "CLI for mapping issues and diffs to relevant files, tests, and review risks.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"fixmap": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"files": ["dist"],
|
|
11
|
+
"publishConfig": { "access": "public" },
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc -p tsconfig.json",
|
|
14
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@aryam/fixmap-core": "0.2.1"
|
|
18
|
+
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20.11"
|
|
21
|
+
}
|
|
22
|
+
}
|