@10kdevs/matha 0.1.2 → 0.1.4
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/commands/init.js +32 -0
- package/dist/index.js +33 -30
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -132,6 +132,28 @@ export async function runInit(projectRoot = process.cwd(), deps) {
|
|
|
132
132
|
catch {
|
|
133
133
|
log('No git history found — cortex will build as commits accumulate');
|
|
134
134
|
}
|
|
135
|
+
// Write MCP server config
|
|
136
|
+
try {
|
|
137
|
+
const mcpServerPath = await resolveMcpServerPath(projectRoot);
|
|
138
|
+
const mcpConfigContent = {
|
|
139
|
+
mcpServers: {
|
|
140
|
+
matha: {
|
|
141
|
+
command: 'node',
|
|
142
|
+
args: [mcpServerPath, 'serve'],
|
|
143
|
+
description: 'MATHA persistent cognitive layer',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
const mcpConfigPath = path.join(mathaDir, 'mcp-config.json');
|
|
148
|
+
await writeAtomic(mcpConfigPath, mcpConfigContent, { overwrite: true });
|
|
149
|
+
log('');
|
|
150
|
+
log('MCP server config written to .matha/mcp-config.json');
|
|
151
|
+
log('Add this to your IDE MCP settings:');
|
|
152
|
+
log(JSON.stringify(mcpConfigContent, null, 2));
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
log(`Warning: Could not write MCP config: ${err.message}`);
|
|
156
|
+
}
|
|
135
157
|
return {
|
|
136
158
|
projectRoot,
|
|
137
159
|
brainDir: '.matha',
|
|
@@ -264,3 +286,13 @@ async function defaultAsk(message) {
|
|
|
264
286
|
const prompts = await import('@inquirer/prompts');
|
|
265
287
|
return prompts.input({ message });
|
|
266
288
|
}
|
|
289
|
+
async function resolveMcpServerPath(projectRoot) {
|
|
290
|
+
// Try node_modules/.bin/matha first
|
|
291
|
+
const npmBinPath = path.join(projectRoot, 'node_modules', '.bin', 'matha');
|
|
292
|
+
if (await pathExists(npmBinPath)) {
|
|
293
|
+
return npmBinPath;
|
|
294
|
+
}
|
|
295
|
+
// Fall back to dist/index.js
|
|
296
|
+
const distPath = path.join(projectRoot, 'dist', 'index.js');
|
|
297
|
+
return distPath;
|
|
298
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Command } from
|
|
3
|
-
import { runInit } from
|
|
4
|
-
import { runBefore } from
|
|
5
|
-
import { runAfter } from
|
|
6
|
-
import { runMigrate } from
|
|
7
|
-
import { parseMarkdownFile } from
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { runInit } from "./commands/init.js";
|
|
4
|
+
import { runBefore } from "./commands/before.js";
|
|
5
|
+
import { runAfter } from "./commands/after.js";
|
|
6
|
+
import { runMigrate } from "./commands/migrate.js";
|
|
7
|
+
import { parseMarkdownFile } from "./utils/markdown-parser.js";
|
|
8
|
+
import { createRequire } from "module";
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const { version } = require('../package.json');
|
|
8
11
|
const program = new Command();
|
|
9
12
|
program
|
|
10
|
-
.name(
|
|
11
|
-
.description(
|
|
12
|
-
|
|
13
|
+
.name("matha")
|
|
14
|
+
.description("MATHA: Persistent cognitive layer for AI-assisted development");
|
|
15
|
+
program.version(version);
|
|
13
16
|
// ──────────────────────────────────────────────────────────────────────
|
|
14
17
|
// INIT COMMAND
|
|
15
18
|
// ──────────────────────────────────────────────────────────────────────
|
|
16
19
|
program
|
|
17
|
-
.command(
|
|
18
|
-
.description(
|
|
19
|
-
.option(
|
|
20
|
-
.option(
|
|
20
|
+
.command("init")
|
|
21
|
+
.description("Initialize MATHA in a project (one-time setup)")
|
|
22
|
+
.option("--project <path>", "Project root path (default: current directory)")
|
|
23
|
+
.option("--from <filepath>", "Parse a markdown/text file to pre-fill init prompts")
|
|
21
24
|
.action(async (options) => {
|
|
22
25
|
try {
|
|
23
26
|
const projectRoot = options.project || process.cwd();
|
|
@@ -34,7 +37,7 @@ program
|
|
|
34
37
|
await runInit(projectRoot, { seed });
|
|
35
38
|
}
|
|
36
39
|
catch (err) {
|
|
37
|
-
console.error(
|
|
40
|
+
console.error("Init failed:", err.message);
|
|
38
41
|
process.exit(1);
|
|
39
42
|
}
|
|
40
43
|
});
|
|
@@ -42,16 +45,16 @@ program
|
|
|
42
45
|
// BEFORE COMMAND
|
|
43
46
|
// ──────────────────────────────────────────────────────────────────────
|
|
44
47
|
program
|
|
45
|
-
.command(
|
|
46
|
-
.description(
|
|
47
|
-
.option(
|
|
48
|
+
.command("before")
|
|
49
|
+
.description("Run gates 01-06: pre-session context gathering")
|
|
50
|
+
.option("--project <path>", "Project root path (default: current directory)")
|
|
48
51
|
.action(async (options) => {
|
|
49
52
|
try {
|
|
50
53
|
const projectRoot = options.project || process.cwd();
|
|
51
54
|
await runBefore(projectRoot, {});
|
|
52
55
|
}
|
|
53
56
|
catch (err) {
|
|
54
|
-
console.error(
|
|
57
|
+
console.error("Before failed:", err.message);
|
|
55
58
|
process.exit(1);
|
|
56
59
|
}
|
|
57
60
|
});
|
|
@@ -59,16 +62,16 @@ program
|
|
|
59
62
|
// AFTER COMMAND
|
|
60
63
|
// ──────────────────────────────────────────────────────────────────────
|
|
61
64
|
program
|
|
62
|
-
.command(
|
|
63
|
-
.description(
|
|
64
|
-
.option(
|
|
65
|
+
.command("after")
|
|
66
|
+
.description("Run gate 08: post-session write-back and loop closure")
|
|
67
|
+
.option("--project <path>", "Project root path (default: current directory)")
|
|
65
68
|
.action(async (options) => {
|
|
66
69
|
try {
|
|
67
70
|
const projectRoot = options.project || process.cwd();
|
|
68
71
|
await runAfter(projectRoot, {});
|
|
69
72
|
}
|
|
70
73
|
catch (err) {
|
|
71
|
-
console.error(
|
|
74
|
+
console.error("After failed:", err.message);
|
|
72
75
|
process.exit(1);
|
|
73
76
|
}
|
|
74
77
|
});
|
|
@@ -76,8 +79,8 @@ program
|
|
|
76
79
|
// MIGRATE COMMAND
|
|
77
80
|
// ──────────────────────────────────────────────────────────────────────
|
|
78
81
|
program
|
|
79
|
-
.command(
|
|
80
|
-
.description(
|
|
82
|
+
.command("migrate")
|
|
83
|
+
.description("Migrate .matha/ to current schema version")
|
|
81
84
|
.action(async () => {
|
|
82
85
|
const result = await runMigrate();
|
|
83
86
|
process.exit(result.exitCode);
|
|
@@ -86,21 +89,21 @@ program
|
|
|
86
89
|
// SERVE COMMAND
|
|
87
90
|
// ──────────────────────────────────────────────────────────────────────
|
|
88
91
|
program
|
|
89
|
-
.command(
|
|
90
|
-
.description(
|
|
91
|
-
.option(
|
|
92
|
+
.command("serve")
|
|
93
|
+
.description("Start MCP server on stdio for IDE integration")
|
|
94
|
+
.option("--project <path>", "Project root path (default: current directory)")
|
|
92
95
|
.action((options) => {
|
|
93
96
|
try {
|
|
94
97
|
const projectRoot = options.project || process.cwd();
|
|
95
98
|
// Import and run the server directly instead of spawning
|
|
96
99
|
// This keeps the stdio channel intact for MCP protocol
|
|
97
|
-
import(
|
|
98
|
-
console.error(
|
|
100
|
+
import("./mcp/server.js").catch((err) => {
|
|
101
|
+
console.error("Failed to start MCP server:", err.message);
|
|
99
102
|
process.exit(1);
|
|
100
103
|
});
|
|
101
104
|
}
|
|
102
105
|
catch (err) {
|
|
103
|
-
console.error(
|
|
106
|
+
console.error("Serve failed:", err.message);
|
|
104
107
|
process.exit(1);
|
|
105
108
|
}
|
|
106
109
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@10kdevs/matha",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "The persistent cognitive layer for AI-assisted development. Gives AI agents the project context that currently only exists inside a senior engineer's head.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"bin": {
|