lat.md 0.4.1 → 0.4.2
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/src/cli/init.js +13 -13
- package/package.json +1 -1
package/dist/src/cli/init.js
CHANGED
|
@@ -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?.
|
|
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 = {
|
|
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
|
|
127
|
-
cfg
|
|
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.
|
|
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
|
}
|