lat.md 0.4.1 → 0.4.3

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.
@@ -106,31 +106,31 @@ function ensureGitignored(root, entry) {
106
106
  function mcpCommand() {
107
107
  return { command: resolve(process.argv[1]), args: ['mcp'] };
108
108
  }
109
- function hasMcpServer(configPath) {
109
+ function hasMcpServer(configPath, key) {
110
110
  if (!existsSync(configPath))
111
111
  return false;
112
112
  try {
113
113
  const cfg = JSON.parse(readFileSync(configPath, 'utf-8'));
114
- return !!cfg?.mcpServers?.lat;
114
+ return !!cfg?.[key]?.lat;
115
115
  }
116
116
  catch {
117
117
  return false;
118
118
  }
119
119
  }
120
- function addMcpServer(configPath) {
121
- let cfg = { mcpServers: {} };
120
+ function addMcpServer(configPath, key) {
121
+ let cfg = { [key]: {} };
122
122
  if (existsSync(configPath)) {
123
123
  const raw = readFileSync(configPath, 'utf-8');
124
124
  try {
125
125
  cfg = JSON.parse(raw);
126
- if (!cfg.mcpServers)
127
- cfg.mcpServers = {};
126
+ if (!cfg[key])
127
+ cfg[key] = {};
128
128
  }
129
129
  catch (e) {
130
130
  throw new Error(`Cannot parse ${configPath}: ${e.message}`);
131
131
  }
132
132
  }
133
- cfg.mcpServers.lat = mcpCommand();
133
+ cfg[key].lat = mcpCommand();
134
134
  mkdirSync(join(configPath, '..'), { recursive: true });
135
135
  writeFileSync(configPath, JSON.stringify(cfg, null, 2) + '\n');
136
136
  }
@@ -182,11 +182,11 @@ async function setupClaudeCode(root, template) {
182
182
  console.log(chalk.dim(' Agents can call `lat` from the command line, but an MCP server gives lat'));
183
183
  console.log(chalk.dim(' more visibility and makes agents more likely to use it proactively.'));
184
184
  const mcpPath = join(root, '.mcp.json');
185
- if (hasMcpServer(mcpPath)) {
185
+ if (hasMcpServer(mcpPath, 'mcpServers')) {
186
186
  console.log(chalk.green(' MCP server') + ' already configured');
187
187
  }
188
188
  else {
189
- addMcpServer(mcpPath);
189
+ addMcpServer(mcpPath, 'mcpServers');
190
190
  console.log(chalk.green(' MCP server') + ' registered in .mcp.json');
191
191
  created.push('.mcp.json');
192
192
  }
@@ -213,11 +213,11 @@ async function setupCursor(root) {
213
213
  console.log(chalk.dim(' Agents can call `lat` from the command line, but an MCP server gives lat'));
214
214
  console.log(chalk.dim(' more visibility and makes agents more likely to use it proactively.'));
215
215
  const mcpPath = join(root, '.cursor', 'mcp.json');
216
- if (hasMcpServer(mcpPath)) {
216
+ if (hasMcpServer(mcpPath, 'mcpServers')) {
217
217
  console.log(chalk.green(' MCP server') + ' already configured');
218
218
  }
219
219
  else {
220
- addMcpServer(mcpPath);
220
+ addMcpServer(mcpPath, 'mcpServers');
221
221
  console.log(chalk.green(' MCP server') + ' registered in .cursor/mcp.json');
222
222
  created.push('.cursor/mcp.json');
223
223
  }
@@ -248,11 +248,11 @@ async function setupCopilot(root) {
248
248
  console.log(chalk.dim(' Agents can call `lat` from the command line, but an MCP server gives lat'));
249
249
  console.log(chalk.dim(' more visibility and makes agents more likely to use it proactively.'));
250
250
  const mcpPath = join(root, '.vscode', 'mcp.json');
251
- if (hasMcpServer(mcpPath)) {
251
+ if (hasMcpServer(mcpPath, 'servers')) {
252
252
  console.log(chalk.green(' MCP server') + ' already configured');
253
253
  }
254
254
  else {
255
- addMcpServer(mcpPath);
255
+ addMcpServer(mcpPath, 'servers');
256
256
  console.log(chalk.green(' MCP server') + ' registered in .vscode/mcp.json');
257
257
  created.push('.vscode/mcp.json');
258
258
  }
@@ -131,28 +131,14 @@ export function parseSections(filePath, content, latticeDir) {
131
131
  }
132
132
  return roots;
133
133
  }
134
- const sectionsCache = new Map();
135
- export function loadAllSections(latticeDir) {
136
- const noCache = !!process.env._LAT_TEST_DISABLE_FS_CACHE;
137
- const key = resolve(latticeDir);
138
- if (!noCache) {
139
- const cached = sectionsCache.get(key);
140
- if (cached)
141
- return cached;
134
+ export async function loadAllSections(latticeDir) {
135
+ const files = await listLatticeFiles(latticeDir);
136
+ const all = [];
137
+ for (const file of files) {
138
+ const content = await readFile(file, 'utf-8');
139
+ all.push(...parseSections(file, content, latticeDir));
142
140
  }
143
- const result = (async () => {
144
- const files = await listLatticeFiles(latticeDir);
145
- const all = [];
146
- for (const file of files) {
147
- const content = await readFile(file, 'utf-8');
148
- all.push(...parseSections(file, content, latticeDir));
149
- }
150
- return all;
151
- })();
152
- if (!noCache) {
153
- sectionsCache.set(key, result);
154
- }
155
- return result;
141
+ return all;
156
142
  }
157
143
  export function flattenSections(sections) {
158
144
  const result = [];
@@ -2,10 +2,6 @@
2
2
  * Walk a directory tree respecting .gitignore rules. Returns relative paths
3
3
  * of all non-ignored files, excluding .git/ and dotfiles (e.g. .gitignore).
4
4
  *
5
- * Results are memoized by resolved directory path — safe because CLI commands
6
- * don't modify the filesystem during a run. Set _LAT_TEST_DISABLE_FS_CACHE=1
7
- * to bypass caching in tests that mutate the filesystem mid-run.
8
- *
9
5
  * This is the single entry point for all directory walking in lat.md — both
10
6
  * code-ref scanning and lat.md/ index validation use it so .gitignore rules
11
7
  * are consistently honored.
package/dist/src/walk.js CHANGED
@@ -1,32 +1,16 @@
1
- import { resolve } from 'node:path';
2
1
  // @ts-expect-error -- no type declarations
3
2
  import walk from 'ignore-walk';
4
- const cache = new Map();
5
3
  /**
6
4
  * Walk a directory tree respecting .gitignore rules. Returns relative paths
7
5
  * of all non-ignored files, excluding .git/ and dotfiles (e.g. .gitignore).
8
6
  *
9
- * Results are memoized by resolved directory path — safe because CLI commands
10
- * don't modify the filesystem during a run. Set _LAT_TEST_DISABLE_FS_CACHE=1
11
- * to bypass caching in tests that mutate the filesystem mid-run.
12
- *
13
7
  * This is the single entry point for all directory walking in lat.md — both
14
8
  * code-ref scanning and lat.md/ index validation use it so .gitignore rules
15
9
  * are consistently honored.
16
10
  */
17
11
  export function walkEntries(dir) {
18
- const noCache = !!process.env._LAT_TEST_DISABLE_FS_CACHE;
19
- if (!noCache) {
20
- const cached = cache.get(resolve(dir));
21
- if (cached)
22
- return cached;
23
- }
24
- const result = walk({
12
+ return walk({
25
13
  path: dir,
26
14
  ignoreFiles: ['.gitignore'],
27
15
  }).then((entries) => entries.filter((e) => !e.startsWith('.git/') && !e.startsWith('.')));
28
- if (!noCache) {
29
- cache.set(resolve(dir), result);
30
- }
31
- return result;
32
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lat.md",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "A knowledge graph for your codebase, written in markdown",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@10.30.2",