@imenam/mcp-documentor 1.0.80 → 1.0.82

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.
@@ -40,6 +40,7 @@ export declare class GitHubCodeApi {
40
40
  private readonly spec;
41
41
  private readonly token;
42
42
  private readonly treeByCommit;
43
+ private readonly commitByDate;
43
44
  private readonly truncatedCommits;
44
45
  private readonly blobCache;
45
46
  constructor(spec: RepoSpec, token: string | undefined);
@@ -52,6 +53,15 @@ export declare class GitHubCodeApi {
52
53
  * once within it, however many files that operation ends up reading.
53
54
  */
54
55
  resolveRef(): Promise<ResolvedRef>;
56
+ /**
57
+ * The newest commit on the configured ref at or before `isoDate`, or undefined if the branch
58
+ * has no commit that old.
59
+ *
60
+ * This is how a snapshot taken before commits were recorded still gets a diff base: the date it
61
+ * was taken at stands in for the revision it was taken from. History is immutable below the ref's
62
+ * head, so the answer is cached for the life of the process.
63
+ */
64
+ resolveCommitAtDate(isoDate: string): Promise<string | undefined>;
55
65
  /** path → blob sha for every file in the commit's tree. A commit's tree never changes. */
56
66
  getTree(commitSha: string): Promise<Map<string, string>>;
57
67
  /**
@@ -58,6 +58,7 @@ export class GitHubCodeApi {
58
58
  // at once, and they all need the same tree — and often the same blobs. Caching the promise makes
59
59
  // concurrent callers await one request instead of each firing its own.
60
60
  treeByCommit = new Map();
61
+ commitByDate = new Map();
61
62
  truncatedCommits = new Set();
62
63
  blobCache = new Map();
63
64
  constructor(spec, token) {
@@ -116,6 +117,24 @@ export class GitHubCodeApi {
116
117
  };
117
118
  });
118
119
  }
120
+ /**
121
+ * The newest commit on the configured ref at or before `isoDate`, or undefined if the branch
122
+ * has no commit that old.
123
+ *
124
+ * This is how a snapshot taken before commits were recorded still gets a diff base: the date it
125
+ * was taken at stands in for the revision it was taken from. History is immutable below the ref's
126
+ * head, so the answer is cached for the life of the process.
127
+ */
128
+ resolveCommitAtDate(isoDate) {
129
+ return this.cached(this.commitByDate, isoDate, async () => {
130
+ const ref = this.spec.ref ?? "HEAD";
131
+ const commits = await this.request(`/repos/${this.spec.owner}/${this.spec.repo}/commits` +
132
+ `?sha=${encodeURIComponent(ref)}&until=${encodeURIComponent(isoDate)}&per_page=1`);
133
+ const sha = Array.isArray(commits) && typeof commits[0]?.sha === "string" ? commits[0].sha : undefined;
134
+ logger.debug(`${this.label}: commit at or before ${isoDate} is ${sha ? sha.slice(0, 7) : "none"}`);
135
+ return sha;
136
+ });
137
+ }
119
138
  /** path → blob sha for every file in the commit's tree. A commit's tree never changes. */
120
139
  getTree(commitSha) {
121
140
  return this.cached(this.treeByCommit, commitSha, async () => {
package/dist/src/index.js CHANGED
@@ -1251,16 +1251,18 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
1251
1251
  },
1252
1252
  {
1253
1253
  name: "upload_image",
1254
- description: "Upload an image to a project's assets from a local file path and get back the markdown link to insert in a document. Returns the URL and a ready-to-use markdown snippet: ![alt](/api/images/{project}/{filename}).",
1254
+ description: "Upload an image to a project's assets from a file on your machine and get back the markdown link to insert in a document. Returns the URL and a ready-to-use markdown snippet: ![alt](/api/images/{project}/{filename}).",
1255
1255
  inputSchema: {
1256
1256
  type: "object",
1257
1257
  properties: {
1258
- filename: { type: "string", description: "Filename with extension, e.g. 'screenshot.png'" },
1259
- filePath: { type: "string", description: "Absolute path to the image file on the server" },
1258
+ filename: { type: "string", description: "Name the image gets in the project's assets, extension included, e.g. 'screenshot.png'" },
1259
+ file_path: { type: "string", description: "Absolute path to the image file on the agent machine." },
1260
+ file_content: { type: "string", description: "Filled in by the mcp-http-gateway relay, never by the agent: the base64 content of the file read on the agent machine." },
1261
+ file_name: { type: "string", description: "Filled in by the mcp-http-gateway relay, never by the agent: the original name of the file read on the agent machine." },
1260
1262
  project: { type: "string", description: "Target project whose assets receive the image. REQUIRED — never defaulted to the current project." },
1261
1263
  alt: { type: "string", description: "Alt text for the markdown image link (optional)" },
1262
1264
  },
1263
- required: ["filename", "filePath", "project"],
1265
+ required: ["filename", "file_path", "project"],
1264
1266
  },
1265
1267
  },
1266
1268
  {
@@ -46,31 +46,53 @@ function getLocalGitDiff(tracked, project) {
46
46
  * Diffs tracked files against the branch they are tracked on, using the commit each snapshot
47
47
  * was taken at as the base.
48
48
  *
49
+ * A snapshot with no recorded commit — taken before branch tracking, or from a local working copy —
50
+ * is anchored on the newest commit at or before its date instead, so it diffs like any other rather
51
+ * than demanding a refresh first.
52
+ *
49
53
  * Files are grouped by that base commit so one comparison covers every file snapshotted at the
50
54
  * same revision — which, for a doc refreshed in one go, means a single API call.
51
55
  */
52
56
  async function getGitHubDiffs(api, trackedFiles) {
53
57
  const diffs = new Map();
54
58
  const byBase = new Map();
59
+ const inferredBases = new Set();
55
60
  for (const tracked of trackedFiles) {
56
- if (!tracked.sourceRevision) {
57
- diffs.set(tracked.path, ` [INFO] No source commit recorded for "${tracked.path}" — this snapshot predates branch tracking, or was taken from a local working copy.\n` +
58
- ` → Call refresh_file_snapshot to re-anchor it on ${api.label}, after which diffs become available.`);
59
- continue;
61
+ let base = tracked.sourceRevision;
62
+ if (!base) {
63
+ try {
64
+ base = await api.resolveCommitAtDate(tracked.lastModifiedAt);
65
+ }
66
+ catch (err) {
67
+ const message = err instanceof Error ? err.message : String(err);
68
+ diffs.set(tracked.path, ` [ERROR] No source commit recorded, and the commit at the snapshot date (${tracked.lastModifiedAt}) could not be resolved on ${api.label}: ${message}`);
69
+ continue;
70
+ }
71
+ if (!base) {
72
+ diffs.set(tracked.path, ` [INFO] No source commit recorded, and ${api.label} has no commit at or before the snapshot date (${tracked.lastModifiedAt}) — nothing to diff against.\n` +
73
+ ` → Call refresh_file_snapshot to re-anchor this file on ${api.label}.`);
74
+ continue;
75
+ }
76
+ inferredBases.add(base);
60
77
  }
61
- const group = byBase.get(tracked.sourceRevision);
78
+ const group = byBase.get(base);
62
79
  if (group)
63
80
  group.push(tracked);
64
81
  else
65
- byBase.set(tracked.sourceRevision, [tracked]);
82
+ byBase.set(base, [tracked]);
66
83
  }
67
84
  if (byBase.size === 0)
68
85
  return diffs;
69
86
  const { commitSha: head } = await api.resolveRef();
70
87
  for (const [base, files] of byBase) {
88
+ // An inferred base is the branch state at the snapshot date, not a commit the snapshot was
89
+ // provably read from — worth saying, since the diff can then include changes already documented.
90
+ const note = inferredBases.has(base)
91
+ ? ` [INFO] Base commit ${base.slice(0, 7)} inferred from the snapshot date (no source commit recorded).\n\n`
92
+ : "";
71
93
  if (base === head) {
72
94
  for (const file of files) {
73
- diffs.set(file.path, ` [INFO] ${api.label} is still at the snapshot commit ${base.slice(0, 7)} — no changes.`);
95
+ diffs.set(file.path, `${note} [INFO] ${api.label} is still at the snapshot commit ${base.slice(0, 7)} — no changes.`);
74
96
  }
75
97
  continue;
76
98
  }
@@ -81,12 +103,12 @@ async function getGitHubDiffs(api, trackedFiles) {
81
103
  catch (err) {
82
104
  const message = err instanceof Error ? err.message : String(err);
83
105
  for (const file of files)
84
- diffs.set(file.path, ` [ERROR] Could not compare ${base.slice(0, 7)}...${head.slice(0, 7)}: ${message}`);
106
+ diffs.set(file.path, `${note} [ERROR] Could not compare ${base.slice(0, 7)}...${head.slice(0, 7)}: ${message}`);
85
107
  continue;
86
108
  }
87
109
  for (const file of files) {
88
110
  const patch = patches.get(file.path);
89
- diffs.set(file.path, patch ?? ` [INFO] No changes to this file between ${base.slice(0, 7)} and ${head.slice(0, 7)}.`);
111
+ diffs.set(file.path, note + (patch ?? ` [INFO] No changes to this file between ${base.slice(0, 7)} and ${head.slice(0, 7)}.`));
90
112
  }
91
113
  }
92
114
  return diffs;
@@ -3,7 +3,9 @@ import path from "path";
3
3
  import { z } from "zod";
4
4
  const UploadImageArgsSchema = z.object({
5
5
  filename: z.string().min(1),
6
- filePath: z.string(),
6
+ file_path: z.string().optional(),
7
+ file_content: z.string().optional(),
8
+ file_name: z.string().optional(),
7
9
  project: z
8
10
  .string()
9
11
  .min(1)
@@ -35,16 +37,29 @@ export async function uploadImage(storageEngine, args) {
35
37
  content: [{ type: "text", text: `Project "${project}" does not exist. Known projects: ${knownProjects.join(", ")}.` }],
36
38
  };
37
39
  }
38
- if (!fs.existsSync(validated.filePath)) {
39
- return {
40
- isError: true,
41
- content: [{ type: "text", text: `File not found: ${validated.filePath}` }],
42
- };
40
+ // Le relais du gateway a posé le contenu : il a lu le fichier sur la machine de
41
+ // l'agent, dont ce serveur ne voit pas le disque. Sans contenu, les deux machines
42
+ // n'en font qu'une et on lit le chemin directement.
43
+ let data;
44
+ if (validated.file_content) {
45
+ data = Buffer.from(validated.file_content.replace(/^data:[^;,]*;base64,/, ""), "base64");
46
+ }
47
+ else {
48
+ if (!validated.file_path) {
49
+ return { isError: true, content: [{ type: "text", text: "file_path is required." }] };
50
+ }
51
+ if (!fs.existsSync(validated.file_path)) {
52
+ return {
53
+ isError: true,
54
+ content: [{ type: "text", text: `File not found: ${validated.file_path}` }],
55
+ };
56
+ }
57
+ data = fs.readFileSync(validated.file_path);
43
58
  }
44
59
  const assetsDir = path.join(storageEngine.getDataDir(), "projects", project, "assets");
45
60
  fs.mkdirSync(assetsDir, { recursive: true });
46
61
  const finalName = resolveFilename(assetsDir, validated.filename);
47
- fs.copyFileSync(validated.filePath, path.join(assetsDir, finalName));
62
+ fs.writeFileSync(path.join(assetsDir, finalName), data);
48
63
  const url = `/api/images/${encodeURIComponent(project)}/${encodeURIComponent(finalName)}`;
49
64
  const alt = validated.alt ?? "";
50
65
  const markdownLink = `![${alt}](${url})`;
@@ -1 +1 @@
1
- export declare const APP_VERSION = "1.0.80";
1
+ export declare const APP_VERSION = "1.0.82";
@@ -1,2 +1,2 @@
1
1
  // Auto-generated version file - do not edit manually
2
- export const APP_VERSION = '1.0.80';
2
+ export const APP_VERSION = '1.0.82';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imenam/mcp-documentor",
3
- "version": "1.0.80",
3
+ "version": "1.0.82",
4
4
  "main": "dist/src/index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
package/gui/README.md DELETED
@@ -1,75 +0,0 @@
1
- # React + TypeScript + Vite
2
-
3
- This app is the browser UI for MCP Documentor. Shared MCP/proxy helpers live in the Node package `@imenam/mcp-gui-interface` (used from the repo root server and `gui-worker`, not from this Vite bundle).
4
-
5
- This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
6
-
7
- Currently, two official plugins are available:
8
-
9
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
10
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
11
-
12
- ## React Compiler
13
-
14
- The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
15
-
16
- ## Expanding the ESLint configuration
17
-
18
- If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
19
-
20
- ```js
21
- export default defineConfig([
22
- globalIgnores(['dist']),
23
- {
24
- files: ['**/*.{ts,tsx}'],
25
- extends: [
26
- // Other configs...
27
-
28
- // Remove tseslint.configs.recommended and replace with this
29
- tseslint.configs.recommendedTypeChecked,
30
- // Alternatively, use this for stricter rules
31
- tseslint.configs.strictTypeChecked,
32
- // Optionally, add this for stylistic rules
33
- tseslint.configs.stylisticTypeChecked,
34
-
35
- // Other configs...
36
- ],
37
- languageOptions: {
38
- parserOptions: {
39
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
40
- tsconfigRootDir: import.meta.dirname,
41
- },
42
- // other options...
43
- },
44
- },
45
- ])
46
- ```
47
-
48
- You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
49
-
50
- ```js
51
- // eslint.config.js
52
- import reactX from 'eslint-plugin-react-x'
53
- import reactDom from 'eslint-plugin-react-dom'
54
-
55
- export default defineConfig([
56
- globalIgnores(['dist']),
57
- {
58
- files: ['**/*.{ts,tsx}'],
59
- extends: [
60
- // Other configs...
61
- // Enable lint rules for React
62
- reactX.configs['recommended-typescript'],
63
- // Enable lint rules for React DOM
64
- reactDom.configs.recommended,
65
- ],
66
- languageOptions: {
67
- parserOptions: {
68
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
69
- tsconfigRootDir: import.meta.dirname,
70
- },
71
- // other options...
72
- },
73
- },
74
- ])
75
- ```