@dahch/muninn 0.0.0-stage → 0.1.0

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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +152 -2
  3. package/dist/cli.d.ts +23 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +170 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commands/check.d.ts +3 -0
  8. package/dist/commands/check.d.ts.map +1 -0
  9. package/dist/commands/check.js +56 -0
  10. package/dist/commands/check.js.map +1 -0
  11. package/dist/commands/memory.d.ts +6 -0
  12. package/dist/commands/memory.d.ts.map +1 -0
  13. package/dist/commands/memory.js +325 -0
  14. package/dist/commands/memory.js.map +1 -0
  15. package/dist/contracts/compiler.d.ts +71 -0
  16. package/dist/contracts/compiler.d.ts.map +1 -0
  17. package/dist/contracts/compiler.js +362 -0
  18. package/dist/contracts/compiler.js.map +1 -0
  19. package/dist/contracts/index.d.ts +2 -0
  20. package/dist/contracts/index.d.ts.map +1 -0
  21. package/dist/contracts/index.js +2 -0
  22. package/dist/contracts/index.js.map +1 -0
  23. package/dist/db/client.d.ts +84 -0
  24. package/dist/db/client.d.ts.map +1 -0
  25. package/dist/db/client.js +264 -0
  26. package/dist/db/client.js.map +1 -0
  27. package/dist/db/schema.sql +97 -0
  28. package/dist/index.d.ts +23 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +23 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/indexer/ast-indexer.d.ts +55 -0
  33. package/dist/indexer/ast-indexer.d.ts.map +1 -0
  34. package/dist/indexer/ast-indexer.js +445 -0
  35. package/dist/indexer/ast-indexer.js.map +1 -0
  36. package/dist/indexer/index.d.ts +2 -0
  37. package/dist/indexer/index.d.ts.map +1 -0
  38. package/dist/indexer/index.js +2 -0
  39. package/dist/indexer/index.js.map +1 -0
  40. package/dist/mcp/index.d.ts +2 -0
  41. package/dist/mcp/index.d.ts.map +1 -0
  42. package/dist/mcp/index.js +2 -0
  43. package/dist/mcp/index.js.map +1 -0
  44. package/dist/mcp/server.d.ts +233 -0
  45. package/dist/mcp/server.d.ts.map +1 -0
  46. package/dist/mcp/server.js +495 -0
  47. package/dist/mcp/server.js.map +1 -0
  48. package/dist/service/index.d.ts +2 -0
  49. package/dist/service/index.d.ts.map +1 -0
  50. package/dist/service/index.js +2 -0
  51. package/dist/service/index.js.map +1 -0
  52. package/dist/service/memory-service.d.ts +203 -0
  53. package/dist/service/memory-service.d.ts.map +1 -0
  54. package/dist/service/memory-service.js +891 -0
  55. package/dist/service/memory-service.js.map +1 -0
  56. package/dist/util/path-safety.d.ts +94 -0
  57. package/dist/util/path-safety.d.ts.map +1 -0
  58. package/dist/util/path-safety.js +162 -0
  59. package/dist/util/path-safety.js.map +1 -0
  60. package/dist/util/text.d.ts +9 -0
  61. package/dist/util/text.d.ts.map +1 -0
  62. package/dist/util/text.js +19 -0
  63. package/dist/util/text.js.map +1 -0
  64. package/package.json +87 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Daniel Hernández
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,153 @@
1
- # Temporary Holding Version
1
+ # Muninn
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Persistent **semantic and symbol memory** for AI coding agents.
4
+
5
+ Muninn stores the things a coding session learns — architectural decisions, conventions,
6
+ discoveries, bugfixes — next to the symbols they refer to, in a single SQLite file that lives
7
+ with the project. It speaks **MCP** so any agent can save and query it, and it exposes the same
8
+ engine as a plain Node/Bun library and a CLI.
9
+
10
+ It used to live inside [Huginn](https://github.com/dahch/huginn); it is now an independent
11
+ package with no dependency on the orchestrator.
12
+
13
+ ## What it gives you
14
+
15
+ - **Observations with categories** — `decision`, `convention`, `discovery`, `bugfix`,
16
+ `architecture` — searchable with SQLite **FTS5 + BM25** ranking.
17
+ - **A symbol graph** — the TypeScript Compiler API extracts files, functions, classes,
18
+ interfaces and modules from your sources, plus the `imports`/`calls`/`extends`/`implements`/
19
+ `references` edges between them, and links observations to symbols.
20
+ - **MCP tools** for agents: `muninn_context`, `muninn_save`, `muninn_search`,
21
+ `muninn_link_symbol`, `muninn_inspect_symbol`, `muninn_verify_contract`, `muninn_stats`.
22
+ - **Contract verification** — the same TypeScript execution-contract check as a CLI command
23
+ (`muninn check`) and as the `muninn_verify_contract` MCP tool.
24
+ - **JSONL sync** — export/import the whole memory as portable line-delimited JSON.
25
+ - **Local-first and self-contained** — no embeddings, no network, no server: one SQLite file
26
+ and one process.
27
+
28
+ ## Install
29
+
30
+ ```sh
31
+ npm install -g @dahch/muninn # CLI + MCP server
32
+ # or as a library
33
+ npm install @dahch/muninn
34
+ ```
35
+
36
+ Requires Node.js >= 20 (or Bun).
37
+
38
+ ## CLI
39
+
40
+ ```sh
41
+ muninn memory init [--db <path>] [--project <path>]
42
+ muninn memory search <query> [--category <cat>] [--limit <n>] [--project <path>]
43
+ muninn memory sync [--import] [--file <path>] [--project <path>]
44
+ muninn memory index [files...] [--project <path>] [--db <path>]
45
+
46
+ muninn check [files...] [--project <path>]
47
+
48
+ muninn mcp run [--db <path>] [--project <path>]
49
+ ```
50
+
51
+ The database resolves to `<git-root>/.huginn/muninn.db` inside a repository and to
52
+ `~/.huginn/muninn.db` outside one. `--db` overrides it; `:memory:` is accepted for tests.
53
+ Both the database file and the project record are resolved from the **same** root, so
54
+ `--project X` can never write into another project's database.
55
+
56
+ ## MCP
57
+
58
+ Register Muninn with any MCP-capable agent. For example, a Claude Code / Codex / Cursor config
59
+ (`mcpServers`):
60
+
61
+ ```json
62
+ {
63
+ "mcpServers": {
64
+ "muninn": {
65
+ "command": "muninn",
66
+ "args": ["mcp", "run", "--project", "/absolute/path/to/repo"]
67
+ }
68
+ }
69
+ }
70
+ ```
71
+
72
+ OpenCode uses the same shape under the `mcp` key with `"type": "local"` and a `command` array.
73
+ Huginn's `huginn setup` writes this for you in every runtime it knows about.
74
+
75
+ ```sh
76
+ muninn mcp run --project .
77
+ ```
78
+
79
+ ## Library
80
+
81
+ ```ts
82
+ import { MemoryService, indexFilesIntoMuninn } from "@dahch/muninn";
83
+
84
+ const memory = new MemoryService({ projectRoot: process.cwd() });
85
+
86
+ memory.saveObservation({
87
+ category: "decision",
88
+ title: "Auth is a port",
89
+ content: "Tokens are validated behind an AuthPort so the transport can change.",
90
+ symbols: ["src/auth/port.ts"],
91
+ });
92
+
93
+ indexFilesIntoMuninn(memory, ["src/auth/port.ts"], { projectRoot: process.cwd() });
94
+
95
+ for (const hit of memory.search({ query: "token validation", limit: 5 })) {
96
+ console.log(hit.category, hit.title, hit.rank);
97
+ }
98
+
99
+ memory.close();
100
+ ```
101
+
102
+ Subpath entry points are available for narrower imports:
103
+
104
+ | Import | Contents |
105
+ |---|---|
106
+ | `@dahch/muninn` | everything below |
107
+ | `@dahch/muninn/db` | SQLite client, schema, path resolution, project records |
108
+ | `@dahch/muninn/service` | `MemoryService` (save, search, context, linking, sync, stats) |
109
+ | `@dahch/muninn/indexer` | AST symbol/dependency extraction and indexing |
110
+ | `@dahch/muninn/mcp` | MCP server, tool registry, bounded stdio transport |
111
+ | `@dahch/muninn/contracts` | TypeScript contract verification |
112
+ | `@dahch/muninn/util` | terminal-text sanitizer |
113
+
114
+ ## Security notes
115
+
116
+ - Every path Muninn writes to — the SQLite file and the JSONL export — is screened: a symlink on
117
+ the final component is refused, and a project-relative path must resolve inside the project, so
118
+ a repository cannot redirect the write outside itself (the `src/util/path-safety.ts` rule, with
119
+ the tests in `test/db.test.ts` and `test/service.test.ts`).
120
+ - The MCP stdio transport is bounded and survives a dead parent instead of crashing or hanging.
121
+ - MCP tool inputs are validated with zod; unknown tools and bad arguments fail closed.
122
+
123
+ ## Development
124
+
125
+ The design of the engine — SQLite/FTS5 schema, service core, MCP server, CLI, contract verifier and
126
+ AST indexer — is documented in [`DESIGN.md`](./DESIGN.md), moved here from the orchestrator's design
127
+ document when Muninn became its own package.
128
+
129
+ ```sh
130
+ npm ci
131
+ npm run build # tsc -> dist/ (+ schema.sql, +x cli.js)
132
+ npm test # vitest run (storage, service, indexer, MCP, CLI)
133
+ npm run typecheck # tsc --noEmit
134
+ bun run src/cli.ts memory init --project .
135
+ ```
136
+
137
+ Publishing is tag-driven, but only once the package exists. The **first** publish is manual, from a
138
+ logged-in machine, because npm's trusted publishing attaches to a package page that has to exist first:
139
+
140
+ ```sh
141
+ npm login
142
+ npm run build && npm publish # 0.1.0, once
143
+ ```
144
+
145
+ After that, configure the trusted publisher on npm (repository `dahch/muninn`, workflow
146
+ `publish.yml`) and tagged releases need no token at all: `git tag v0.1.1 && git push origin v0.1.1`
147
+ runs the workflow, which checks the tag against `package.json`, builds, tests and publishes over
148
+ OIDC. A run whose version is already on npm skips the publish step and refreshes the GitHub release
149
+ instead, so re-tagging to fix a message stays safe.
150
+
151
+ ## License
152
+
153
+ MIT © Daniel Hernández
package/dist/cli.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ export declare const VERSION = "0.1.0";
3
+ export interface ParsedArgs {
4
+ [key: string]: string | boolean | undefined | string[];
5
+ _command?: string;
6
+ _positional?: string;
7
+ _positionals?: string[];
8
+ }
9
+ /**
10
+ * Parses argv into flags plus positionals.
11
+ *
12
+ * The first bare word is `_command`; every later bare word is appended to
13
+ * `_positionals` (and mirrored in `_positional` as the last one), which is what
14
+ * lets `memory search "vector search"` keep a multi-word query intact.
15
+ */
16
+ export declare function parseArgs(argv: string[]): ParsedArgs;
17
+ export declare function usage(): string;
18
+ /**
19
+ * Runs the CLI. Exported (rather than inlined) so tests can drive it with an
20
+ * explicit argv and assert on the routed handler.
21
+ */
22
+ export declare function main(argv: string[]): Promise<void>;
23
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAoBA,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,EAAE,CAAC;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAiBD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CA8BpD;AAED,wBAAgB,KAAK,IAAI,MAAM,CAoB9B;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA+DxD"}
package/dist/cli.js ADDED
@@ -0,0 +1,170 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `muninn` — command-line surface for the Muninn memory engine.
4
+ *
5
+ * Three commands, one per consumer:
6
+ *
7
+ * - `muninn memory …` — init / search / sync / index the project database.
8
+ * - `muninn mcp run` — the stdio MCP server an agent runtime registers.
9
+ * - `muninn check …` — TypeScript execution-contract verification, the same
10
+ * pass the MCP `muninn_verify_contract` tool performs.
11
+ *
12
+ * The parser and the usage text are deliberately small and dependency-free:
13
+ * this file is the only part of Muninn that has to be stable for other tools to
14
+ * embed it.
15
+ */
16
+ import { realpathSync } from "node:fs";
17
+ import { fileURLToPath } from "node:url";
18
+ import { handleMcpCommand, handleMemoryCommand } from "./commands/memory.js";
19
+ import { handleCheckCommand } from "./commands/check.js";
20
+ export const VERSION = "0.1.0";
21
+ /**
22
+ * Flags that never consume the next argv entry as their value. `--import` is the
23
+ * one that matters in practice: `muninn memory sync --import backup.jsonl` must
24
+ * leave `backup.jsonl` as a positional, not swallow it into the flag.
25
+ */
26
+ const BOOLEAN_FLAGS = new Set([
27
+ "-h",
28
+ "--help",
29
+ "-v",
30
+ "--version",
31
+ "--import",
32
+ "--json",
33
+ "--quiet",
34
+ ]);
35
+ /**
36
+ * Parses argv into flags plus positionals.
37
+ *
38
+ * The first bare word is `_command`; every later bare word is appended to
39
+ * `_positionals` (and mirrored in `_positional` as the last one), which is what
40
+ * lets `memory search "vector search"` keep a multi-word query intact.
41
+ */
42
+ export function parseArgs(argv) {
43
+ const out = { _positionals: [] };
44
+ for (let i = 0; i < argv.length; i++) {
45
+ const arg = argv[i];
46
+ if (arg.startsWith("-") && arg !== "-") {
47
+ const eq = arg.indexOf("=");
48
+ let key = arg;
49
+ let value = true;
50
+ if (eq !== -1) {
51
+ key = arg.slice(0, eq);
52
+ value = arg.slice(eq + 1);
53
+ }
54
+ else if (!BOOLEAN_FLAGS.has(key)) {
55
+ const next = argv[i + 1];
56
+ if (next !== undefined &&
57
+ (!next.startsWith("-") || /^-\d+(\.\d+)?$/.test(next))) {
58
+ value = next;
59
+ i++;
60
+ }
61
+ }
62
+ out[key] = value;
63
+ }
64
+ else if (out._command === undefined) {
65
+ out._command = arg;
66
+ }
67
+ else {
68
+ out._positional = arg;
69
+ out._positionals.push(arg);
70
+ }
71
+ }
72
+ return out;
73
+ }
74
+ export function usage() {
75
+ return `muninn — persistent semantic and symbol memory for coding agents.
76
+
77
+ Usage:
78
+ muninn memory init [--db <path>] [--project <path>]
79
+ muninn memory search <query> [--category <cat>] [--limit <n>] [--project <path>]
80
+ muninn memory sync [--import] [--file <path>] [--project <path>]
81
+ muninn memory index [files...] [--project <path>] [--db <path>]
82
+ muninn check [files...] [--project <path>]
83
+ muninn mcp run [--db <path>] [--project <path>]
84
+
85
+ Commands:
86
+ memory query and manage the persistent codebase memory (init, search, sync, index)
87
+ mcp start the Muninn MCP server for agent memory integration (run)
88
+ check verify TypeScript execution contracts and pre-emit diagnostics
89
+
90
+ Storage:
91
+ The database resolves to <git-root>/.huginn/muninn.db inside a repository and
92
+ to ~/.huginn/muninn.db outside one. --db overrides it (":memory:" is accepted).
93
+ `;
94
+ }
95
+ /**
96
+ * Runs the CLI. Exported (rather than inlined) so tests can drive it with an
97
+ * explicit argv and assert on the routed handler.
98
+ */
99
+ export async function main(argv) {
100
+ const args = parseArgs(argv);
101
+ const command = args._command;
102
+ if (args["--version"] === true || args["-v"] === true || command === "version") {
103
+ console.log(`muninn ${VERSION}`);
104
+ return;
105
+ }
106
+ if (command === undefined ||
107
+ command === "help" ||
108
+ command === "--help" ||
109
+ args["--help"] === true ||
110
+ args["-h"] === true) {
111
+ console.log(usage());
112
+ return;
113
+ }
114
+ if (command === "memory") {
115
+ const positionals = args._positionals ?? [];
116
+ const subcommand = typeof positionals[0] === "string"
117
+ ? positionals[0]
118
+ : typeof args._positional === "string"
119
+ ? args._positional
120
+ : undefined;
121
+ await handleMemoryCommand(subcommand, args, positionals.slice(1));
122
+ return;
123
+ }
124
+ if (command === "mcp") {
125
+ const positionals = args._positionals ?? [];
126
+ const subcommand = typeof positionals[0] === "string"
127
+ ? positionals[0]
128
+ : typeof args._positional === "string"
129
+ ? args._positional
130
+ : undefined;
131
+ await handleMcpCommand(subcommand, args);
132
+ return;
133
+ }
134
+ if (command === "check") {
135
+ const positionals = args._positionals ?? [];
136
+ const files = positionals.length > 0
137
+ ? positionals
138
+ : typeof args._positional === "string" && args._positional !== "check"
139
+ ? [args._positional]
140
+ : [];
141
+ await handleCheckCommand(files, args);
142
+ return;
143
+ }
144
+ console.error(`Unknown command: ${command}`);
145
+ console.log(usage());
146
+ process.exitCode = 1;
147
+ }
148
+ /**
149
+ * True only when this module is the process entry point — under `node dist/cli.js`,
150
+ * `bun dist/cli.js` or the installed `muninn` bin — and false when a test or a
151
+ * consumer merely imports it.
152
+ */
153
+ function isDirectRun() {
154
+ const entry = process.argv[1];
155
+ if (!entry)
156
+ return false;
157
+ try {
158
+ return realpathSync(entry) === realpathSync(fileURLToPath(import.meta.url));
159
+ }
160
+ catch {
161
+ return false;
162
+ }
163
+ }
164
+ if (isDirectRun()) {
165
+ main(process.argv.slice(2)).catch((err) => {
166
+ console.error(`muninn: ${err instanceof Error ? err.message : String(err)}`);
167
+ process.exitCode = 1;
168
+ });
169
+ }
170
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAS/B;;;;GAIG;AACH,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,IAAI;IACJ,QAAQ;IACR,IAAI;IACJ,WAAW;I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C,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,KAAK,CAAC,KAAK,YAAY,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,IAAI,WAAW,EAAE,EAAE,CAAC;IAClB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;QACjD,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC7E,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function printCheckUsage(): void;
2
+ export declare function handleCheckCommand(files: string[], args: Record<string, string | boolean | undefined>): Promise<void>;
3
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAIA,wBAAgB,eAAe,IAAI,IAAI,CAStC;AAED,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,GACjD,OAAO,CAAC,IAAI,CAAC,CAyDf"}
@@ -0,0 +1,56 @@
1
+ import path from "node:path";
2
+ import chalk from "chalk";
3
+ import { verifyTypeScriptContracts } from "../contracts/compiler.js";
4
+ export function printCheckUsage() {
5
+ console.log(`muninn check — Static TypeScript execution contract verification
6
+
7
+ Usage:
8
+ muninn check [files...] [--project <path>]
9
+
10
+ Options:
11
+ --project <path> Target project root containing tsconfig.json (default: cwd)
12
+ `);
13
+ }
14
+ export async function handleCheckCommand(files, args) {
15
+ if (args["--help"] || args["-h"]) {
16
+ printCheckUsage();
17
+ return;
18
+ }
19
+ const projectRoot = typeof args["--project"] === "string"
20
+ ? path.resolve(args["--project"])
21
+ : typeof args["--root"] === "string"
22
+ ? path.resolve(args["--root"])
23
+ : process.cwd();
24
+ const targetFiles = files.length > 0 ? files : undefined;
25
+ const result = verifyTypeScriptContracts(projectRoot, targetFiles);
26
+ if (result.valid) {
27
+ console.log(chalk.green(`✔ TypeScript contracts verified: 0 errors (${result.diagnostics.length} diagnostic(s)).`));
28
+ if (result.diagnostics.length > 0) {
29
+ console.log(chalk.yellow("\nDiagnostics:"));
30
+ for (const d of result.diagnostics) {
31
+ const loc = chalk.dim(`${d.filePath}:${d.line}:${d.character}`);
32
+ const code = chalk.yellow(`[${d.code}]`);
33
+ const category = chalk.yellow(d.category.toUpperCase());
34
+ console.log(`- ${loc} ${code} ${category}: ${d.message}`);
35
+ if (d.snippet) {
36
+ console.log(chalk.dim(d.snippet) + "\n");
37
+ }
38
+ }
39
+ }
40
+ return;
41
+ }
42
+ console.error(chalk.red.bold(`✖ TypeScript contracts check failed with ${result.errorsCount} error(s):\n`));
43
+ for (const d of result.diagnostics) {
44
+ const loc = chalk.cyan(`${d.filePath}:${d.line}:${d.character}`);
45
+ const code = chalk.yellow(`[${d.code}]`);
46
+ const category = d.category === "error"
47
+ ? chalk.red("ERROR")
48
+ : chalk.yellow(d.category.toUpperCase());
49
+ console.error(`- ${loc} ${code} ${category}: ${d.message}`);
50
+ if (d.snippet) {
51
+ console.error(chalk.dim(d.snippet) + "\n");
52
+ }
53
+ }
54
+ process.exitCode = 1;
55
+ }
56
+ //# sourceMappingURL=check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/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B,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;QAC7C,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,IAAI,IAAI,QAAQ,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;YACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function findSourceFiles(dir: string): string[];
2
+ export declare function printMemoryUsage(): void;
3
+ export declare function printMcpUsage(): void;
4
+ export declare function handleMemoryCommand(subcommand: string | undefined, args: Record<string, string | boolean | undefined>, positionals?: string[]): Promise<void>;
5
+ export declare function handleMcpCommand(subcommand: string | undefined, args: Record<string, string | boolean | undefined>): Promise<void>;
6
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/commands/memory.ts"],"names":[],"mappings":"AA6BA,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAwBrD;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAevC;AAED,wBAAgB,aAAa,IAAI,IAAI,CASpC;AAED,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,EAClD,WAAW,CAAC,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,IAAI,CAAC,CAkKf;AAsDD,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,GACjD,OAAO,CAAC,IAAI,CAAC,CA8Ef"}