@aryam/fixmap 0.2.1 → 0.3.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/README.md +84 -0
- package/dist/cli.js +58 -38
- package/dist/cli.js.map +1 -1
- package/dist/mcp.d.ts +3 -0
- package/dist/mcp.js +95 -0
- package/dist/mcp.js.map +1 -0
- package/package.json +5 -3
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @aryam/fixmap
|
|
2
|
+
|
|
3
|
+
**Give your coding agent a map before it starts editing.**
|
|
4
|
+
|
|
5
|
+
FixMap turns an issue, prompt, or git diff into ranked context files, test routes, and risk notes — locally, with no account or API key. Nothing leaves your machine.
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
Run from a JavaScript or TypeScript repository:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx @aryam/fixmap plan --issue "password reset emails fail"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Use a real branch diff:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx @aryam/fixmap plan --diff main...HEAD
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Machine-readable output:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx @aryam/fixmap plan --base main --head HEAD --format json --output fixmap-report.json
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## MCP server
|
|
28
|
+
|
|
29
|
+
FixMap ships as a Model Context Protocol server, so coding agents can request a plan themselves. One tool is exposed: `fixmap_plan`.
|
|
30
|
+
|
|
31
|
+
Claude Code:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
claude mcp add fixmap -- npx -y @aryam/fixmap mcp
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Cursor, Windsurf, or any MCP client:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"mcpServers": {
|
|
42
|
+
"fixmap": {
|
|
43
|
+
"command": "npx",
|
|
44
|
+
"args": ["-y", "@aryam/fixmap", "mcp"]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Options
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
fixmap plan Generate a FixMap report for a task or diff
|
|
54
|
+
fixmap mcp Run FixMap as an MCP server over stdio
|
|
55
|
+
|
|
56
|
+
--issue <text> Issue, prompt, or task description
|
|
57
|
+
--diff <spec> Git diff spec, such as main...HEAD
|
|
58
|
+
--base <ref> Base ref for diffing when --diff is not given
|
|
59
|
+
--head <ref> Head ref for diffing (defaults to HEAD)
|
|
60
|
+
--repo <path> Repository root to scan (defaults to current directory)
|
|
61
|
+
--format <fmt> Output format: markdown (default) or json
|
|
62
|
+
--output <file> Write the report to a file instead of stdout
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Example output
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
## Context Files
|
|
69
|
+
- src/auth/reset-password.ts (high confidence): path and content match
|
|
70
|
+
|
|
71
|
+
## Test Route
|
|
72
|
+
- npm --prefix apps/api run test
|
|
73
|
+
|
|
74
|
+
## Risk Map
|
|
75
|
+
- high authentication: authentication-related files are affected
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Links
|
|
79
|
+
|
|
80
|
+
- [GitHub repository](https://github.com/aryamthecodebreaker/FixMap)
|
|
81
|
+
- [Live demo](https://fixmap-flax.vercel.app)
|
|
82
|
+
- [Changelog](https://github.com/aryamthecodebreaker/FixMap/blob/main/CHANGELOG.md)
|
|
83
|
+
|
|
84
|
+
MIT © FixMap contributors.
|
package/dist/cli.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
|
-
import { writeFile } from "node:fs/promises";
|
|
3
|
+
import { stat, writeFile } from "node:fs/promises";
|
|
4
4
|
import { dirname, join, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import {
|
|
6
|
+
import { buildFixMapReport, renderJsonReport, renderMarkdownReport } from "@aryam/fixmap-core";
|
|
7
7
|
const USAGE = `FixMap maps an issue, prompt, or diff to context files, test routes, and review risks.
|
|
8
8
|
|
|
9
9
|
Usage:
|
|
10
10
|
fixmap plan --issue "Users cannot reset passwords"
|
|
11
11
|
fixmap plan --diff main...HEAD
|
|
12
12
|
fixmap plan --base main --head HEAD --format json
|
|
13
|
+
fixmap mcp
|
|
14
|
+
|
|
15
|
+
Commands:
|
|
16
|
+
plan Generate a FixMap report for a task or diff
|
|
17
|
+
mcp Run FixMap as an MCP server over stdio for AI coding agents
|
|
13
18
|
|
|
14
19
|
Options:
|
|
15
20
|
--issue <text> Issue, prompt, or task description
|
|
@@ -32,45 +37,60 @@ if (rawArgs[0] === "--version" || rawArgs[0] === "version") {
|
|
|
32
37
|
console.log(packageJson.version);
|
|
33
38
|
process.exit(0);
|
|
34
39
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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);
|
|
40
|
+
if (rawArgs[0] === "mcp") {
|
|
41
|
+
const { runMcpServer } = await import("./mcp.js");
|
|
42
|
+
await runMcpServer();
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
process.exit(1);
|
|
44
|
+
else {
|
|
45
|
+
await runPlan(rawArgs);
|
|
47
46
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
47
|
+
async function runPlan(args) {
|
|
48
|
+
const options = parseArgs(args);
|
|
49
|
+
if (options.command !== "plan") {
|
|
50
|
+
console.error(`Unknown command: ${options.command || "(none)"}\n\n${USAGE}`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
if (options.unknownArgs.length > 0) {
|
|
54
|
+
console.error(`Unknown or incomplete option(s): ${options.unknownArgs.join(", ")}\n\n${USAGE}`);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
if (!options.issueText && !options.diffSpec && !options.baseRef) {
|
|
58
|
+
console.error("Provide --issue, --diff, or --base/--head so FixMap has a task signal.");
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
if (!(await isDirectory(options.repoRoot))) {
|
|
62
|
+
console.error(`Repository root "${options.repoRoot}" does not exist or is not a directory. Check the --repo path.`);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
const report = await buildFixMapReport({
|
|
66
|
+
repoRoot: options.repoRoot,
|
|
67
|
+
issueText: options.issueText,
|
|
68
|
+
diffSpec: options.diffSpec,
|
|
69
|
+
baseRef: options.baseRef,
|
|
70
|
+
headRef: options.headRef
|
|
71
|
+
});
|
|
72
|
+
if (!options.issueText) {
|
|
73
|
+
const diffFailure = report.diagnostics.find((diagnostic) => diagnostic.code === "diff-unavailable");
|
|
74
|
+
if (diffFailure) {
|
|
75
|
+
console.error(`${diffFailure.message}\nNo --issue text was provided to fall back to, so this report would be empty. Fix the ref or add --issue.`);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const rendered = options.format === "json" ? renderJsonReport(report) : renderMarkdownReport(report);
|
|
80
|
+
if (options.output) {
|
|
81
|
+
await writeFile(options.output, rendered, "utf8");
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
process.stdout.write(rendered);
|
|
85
|
+
}
|
|
71
86
|
}
|
|
72
|
-
|
|
73
|
-
|
|
87
|
+
async function isDirectory(path) {
|
|
88
|
+
try {
|
|
89
|
+
return (await stat(path)).isDirectory();
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
74
94
|
}
|
|
75
95
|
function parseArgs(args) {
|
|
76
96
|
const command = args[0] ?? "";
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAc/F,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;CAsBb,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,CAAC,KAAK,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CA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AC9B,KAAK,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChC,CAAC;aAAM,IAAI,GAAG,KAAK,UAAU,IAAI,CAAC,SAAS,KAAK,UAAU,IAAI,SAAS,KAAK,MAAM,CAAC,EAAE,CAAC;YACpF,MAAM,GAAG,SAAS,CAAC;YACnB,KAAK,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChC,CAAC;aAAM,IAAI,GAAG,KAAK,UAAU,IAAI,SAAS,EAAE,CAAC;YAC3C,MAAM,GAAG,SAAS,CAAC;YACnB,KAAK,IAAI,YAAY,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/dist/mcp.d.ts
ADDED
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { stat } from "node:fs/promises";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
6
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
8
|
+
import { buildFixMapReport, renderJsonReport, renderMarkdownReport } from "@aryam/fixmap-core";
|
|
9
|
+
const PLAN_TOOL = {
|
|
10
|
+
name: "fixmap_plan",
|
|
11
|
+
title: "FixMap plan",
|
|
12
|
+
description: "Map an issue, prompt, or git diff to the repository files worth reading first, " +
|
|
13
|
+
"the test commands most likely to validate a change, and the areas that deserve review attention. " +
|
|
14
|
+
"Run this before editing code so the change starts from the right context. " +
|
|
15
|
+
"Provide at least one of issue, diff, or base.",
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: "object",
|
|
18
|
+
properties: {
|
|
19
|
+
issue: { type: "string", description: "Issue, prompt, or task description" },
|
|
20
|
+
diff: { type: "string", description: "Git diff spec, such as main...HEAD" },
|
|
21
|
+
base: { type: "string", description: "Base git ref to diff against when diff is not given" },
|
|
22
|
+
head: { type: "string", description: "Head git ref, defaults to HEAD" },
|
|
23
|
+
repo: {
|
|
24
|
+
type: "string",
|
|
25
|
+
description: "Absolute path to the repository root, defaults to the server working directory"
|
|
26
|
+
},
|
|
27
|
+
format: {
|
|
28
|
+
type: "string",
|
|
29
|
+
enum: ["markdown", "json"],
|
|
30
|
+
description: "Report format, markdown by default"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export function createFixMapMcpServer() {
|
|
36
|
+
const server = new Server({ name: "fixmap", version: readVersion() }, { capabilities: { tools: {} } });
|
|
37
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [PLAN_TOOL] }));
|
|
38
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
39
|
+
if (request.params.name !== PLAN_TOOL.name) {
|
|
40
|
+
return {
|
|
41
|
+
isError: true,
|
|
42
|
+
content: [{ type: "text", text: `Unknown tool: ${request.params.name}` }]
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const args = (request.params.arguments ?? {});
|
|
46
|
+
if (!args.issue && !args.diff && !args.base) {
|
|
47
|
+
return {
|
|
48
|
+
isError: true,
|
|
49
|
+
content: [{ type: "text", text: "Provide issue, diff, or base/head so FixMap has a task signal." }]
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const repoRoot = args.repo ? resolve(args.repo) : process.cwd();
|
|
53
|
+
if (!(await isDirectory(repoRoot))) {
|
|
54
|
+
return {
|
|
55
|
+
isError: true,
|
|
56
|
+
content: [{ type: "text", text: `Repository root "${repoRoot}" does not exist or is not a directory.` }]
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const report = await buildFixMapReport({
|
|
60
|
+
repoRoot,
|
|
61
|
+
issueText: args.issue,
|
|
62
|
+
diffSpec: args.diff,
|
|
63
|
+
baseRef: args.base,
|
|
64
|
+
headRef: args.head
|
|
65
|
+
});
|
|
66
|
+
if (!args.issue) {
|
|
67
|
+
const diffFailure = report.diagnostics.find((diagnostic) => diagnostic.code === "diff-unavailable");
|
|
68
|
+
if (diffFailure) {
|
|
69
|
+
return {
|
|
70
|
+
isError: true,
|
|
71
|
+
content: [{ type: "text", text: `${diffFailure.message} No issue text was provided to fall back to.` }]
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const text = args.format === "json" ? renderJsonReport(report) : renderMarkdownReport(report);
|
|
76
|
+
return { content: [{ type: "text", text }] };
|
|
77
|
+
});
|
|
78
|
+
return server;
|
|
79
|
+
}
|
|
80
|
+
export async function runMcpServer() {
|
|
81
|
+
await createFixMapMcpServer().connect(new StdioServerTransport());
|
|
82
|
+
}
|
|
83
|
+
async function isDirectory(path) {
|
|
84
|
+
try {
|
|
85
|
+
return (await stat(path)).isDirectory();
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function readVersion() {
|
|
92
|
+
const packageJson = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), "..", "package.json"), "utf8"));
|
|
93
|
+
return packageJson.version;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=mcp.js.map
|
package/dist/mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],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,IAAY;IACrC,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,WAAW;IAClB,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC5B,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CACnE,CAAC;IACzB,OAAO,WAAW,CAAC,OAAO,CAAC;AAC7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aryam/fixmap",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "CLI for mapping issues and diffs to relevant files, tests, and review risks.",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "CLI and MCP server for mapping issues and diffs to relevant files, tests, and review risks.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -11,10 +11,12 @@
|
|
|
11
11
|
"publishConfig": { "access": "public" },
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "tsc -p tsconfig.json",
|
|
14
|
+
"test": "vitest run",
|
|
14
15
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
17
|
-
"@aryam/fixmap-core": "0.
|
|
18
|
+
"@aryam/fixmap-core": "0.3.1",
|
|
19
|
+
"@modelcontextprotocol/sdk": "^1.29.0"
|
|
18
20
|
},
|
|
19
21
|
"engines": {
|
|
20
22
|
"node": ">=20.11"
|