mind-palace-graph 0.3.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.
- package/INSTALL.md +387 -0
- package/README.md +602 -0
- package/dist/api.d.ts +682 -0
- package/dist/api.js +660 -0
- package/dist/api.js.map +1 -0
- package/dist/cli.d.ts +95 -0
- package/dist/cli.js +856 -0
- package/dist/cli.js.map +1 -0
- package/dist/format.d.ts +16 -0
- package/dist/format.js +199 -0
- package/dist/format.js.map +1 -0
- package/dist/fuzzy.d.ts +45 -0
- package/dist/fuzzy.js +150 -0
- package/dist/fuzzy.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +528 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server.d.ts +24 -0
- package/dist/mcp-server.js +187 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/mind-palace.d.ts +148 -0
- package/dist/mind-palace.js +780 -0
- package/dist/mind-palace.js.map +1 -0
- package/dist/nodes.d.ts +57 -0
- package/dist/nodes.js +220 -0
- package/dist/nodes.js.map +1 -0
- package/dist/pagination.d.ts +41 -0
- package/dist/pagination.js +63 -0
- package/dist/pagination.js.map +1 -0
- package/dist/palace-format.d.ts +30 -0
- package/dist/palace-format.js +146 -0
- package/dist/palace-format.js.map +1 -0
- package/dist/rg.d.ts +34 -0
- package/dist/rg.js +288 -0
- package/dist/rg.js.map +1 -0
- package/dist/sources.d.ts +87 -0
- package/dist/sources.js +457 -0
- package/dist/sources.js.map +1 -0
- package/dist/tokens.d.ts +35 -0
- package/dist/tokens.js +95 -0
- package/dist/tokens.js.map +1 -0
- package/dist/types.d.ts +236 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +67 -0
- package/skills/mpg-context/SKILL.md +556 -0
- package/skills/mpg-context/references/anti-patterns.md +133 -0
- package/skills/mpg-context/references/integration.md +123 -0
- package/skills/mpg-context/references/mind-palace.md +217 -0
- package/skills/mpg-context/references/multi-agent.md +147 -0
- package/skills/mpg-context/references/sources.md +120 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for mpg.
|
|
3
|
+
*
|
|
4
|
+
* A "node" is the fundamental unit of retrieval: a search match plus
|
|
5
|
+
* its pre/post context window, sized in tokens (not lines).
|
|
6
|
+
*/
|
|
7
|
+
export type SourceType = "file" | "command" | "stdin" | "url" | "bulk";
|
|
8
|
+
export type Effort = "scan" | "quick" | "normal" | "deep" | "auto";
|
|
9
|
+
export type SortMode = "default" | "recent" | "oldest";
|
|
10
|
+
export type WindowCurve = "flat" | "linear" | "log";
|
|
11
|
+
export type Strategy = "fill" | "deep";
|
|
12
|
+
export type OutputFormat = "llm" | "markdown" | "json" | "text";
|
|
13
|
+
export type ResultStatus = "ok" | "no_matches" | "truncated" | "error";
|
|
14
|
+
/** Where text came from. */
|
|
15
|
+
export interface Source {
|
|
16
|
+
/** A stable identifier (file path, command, URL, "stdin"). */
|
|
17
|
+
id: string;
|
|
18
|
+
/** What kind of source this is. */
|
|
19
|
+
type: SourceType;
|
|
20
|
+
/** Optional display label, defaults to id. */
|
|
21
|
+
label?: string;
|
|
22
|
+
}
|
|
23
|
+
/** A single line match produced by ripgrep. */
|
|
24
|
+
export interface Match {
|
|
25
|
+
source: Source;
|
|
26
|
+
/** 1-indexed line number of the match. */
|
|
27
|
+
line: number;
|
|
28
|
+
/** The matched line's text (without trailing newline). */
|
|
29
|
+
text: string;
|
|
30
|
+
/** 0-indexed start byte offset of the match within `text`. */
|
|
31
|
+
match_start: number;
|
|
32
|
+
/** 0-indexed end byte offset of the match within `text` (exclusive). */
|
|
33
|
+
match_end: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A "node" is a search hit wrapped in a token-budgeted context window.
|
|
37
|
+
* It's the smallest unit the LLM consumes.
|
|
38
|
+
*/
|
|
39
|
+
export interface Node {
|
|
40
|
+
/** 1-indexed position of this node within the result set. */
|
|
41
|
+
id: number;
|
|
42
|
+
source: Source;
|
|
43
|
+
/** 1-indexed line number of the match within the source. */
|
|
44
|
+
match_line: number;
|
|
45
|
+
/** 1-indexed first line of the context window (start_line <= match_line). */
|
|
46
|
+
start_line: number;
|
|
47
|
+
/** 1-indexed last line of the context window (end_line >= match_line). */
|
|
48
|
+
end_line: number;
|
|
49
|
+
/** Pre-context lines (text only, no line numbers). */
|
|
50
|
+
context_before: string[];
|
|
51
|
+
/** The matched line. */
|
|
52
|
+
match_text: string;
|
|
53
|
+
/** Post-context lines. */
|
|
54
|
+
context_after: string[];
|
|
55
|
+
/** Highlight ranges within match_text (offsets from start of match_text). */
|
|
56
|
+
match_spans: Array<[number, number]>;
|
|
57
|
+
/** Estimated token count for the entire node (before + match + after). */
|
|
58
|
+
tokens: number;
|
|
59
|
+
}
|
|
60
|
+
/** Top-level result returned to the formatter. */
|
|
61
|
+
export interface Result {
|
|
62
|
+
pattern: string;
|
|
63
|
+
effort: Effort;
|
|
64
|
+
strategy: Strategy;
|
|
65
|
+
total_nodes: number;
|
|
66
|
+
total_tokens: number;
|
|
67
|
+
sources_count: number;
|
|
68
|
+
truncated: boolean;
|
|
69
|
+
nodes: Node[];
|
|
70
|
+
/** Wall-clock duration of the search in ms. */
|
|
71
|
+
duration_ms: number;
|
|
72
|
+
/** The configured per-node token windows that were applied. */
|
|
73
|
+
before_tokens: number;
|
|
74
|
+
after_tokens: number;
|
|
75
|
+
max_nodes: number;
|
|
76
|
+
max_tokens?: number;
|
|
77
|
+
/** True when the wide-record auto-tune shrank before/after to 0. */
|
|
78
|
+
auto_tune_applied?: boolean;
|
|
79
|
+
/** Shorthand status so LLMs can branch on outcome without parsing text. */
|
|
80
|
+
status: ResultStatus;
|
|
81
|
+
/** Token count of the actual nodes returned (after pagination).
|
|
82
|
+
* `total_tokens` is the pre-pagination total. */
|
|
83
|
+
page_tokens: number;
|
|
84
|
+
/** Optional pagination metadata; absent when pagination is off. */
|
|
85
|
+
pagination?: import("./pagination.js").PaginationMeta;
|
|
86
|
+
}
|
|
87
|
+
/** Resolved configuration after applying effort presets and CLI overrides. */
|
|
88
|
+
export interface ResolvedConfig {
|
|
89
|
+
pattern?: string;
|
|
90
|
+
before_tokens: number;
|
|
91
|
+
after_tokens: number;
|
|
92
|
+
max_nodes: number;
|
|
93
|
+
max_tokens?: number;
|
|
94
|
+
strategy: Strategy;
|
|
95
|
+
effort: Effort;
|
|
96
|
+
format: OutputFormat;
|
|
97
|
+
color: boolean;
|
|
98
|
+
/** Raw source inputs (paths, commands, urls, stdin) to be resolved. */
|
|
99
|
+
inputs: SourceInput[];
|
|
100
|
+
/** Forwarded to ripgrep. */
|
|
101
|
+
rg_options: RgOptions;
|
|
102
|
+
/** Mind palace operations. Any of these may be set; pattern is only
|
|
103
|
+
* required for operations that perform a search. */
|
|
104
|
+
mind_palace?: MindPalaceOps;
|
|
105
|
+
/** Pagination. 1-indexed page number; absence means no pagination. */
|
|
106
|
+
page?: number;
|
|
107
|
+
page_size?: number;
|
|
108
|
+
all: boolean;
|
|
109
|
+
/** --ls / --tree: list all searchable files and exit. */
|
|
110
|
+
ls: boolean;
|
|
111
|
+
/** --mp-stash-locations: stash locations only (no context text). */
|
|
112
|
+
mp_stash_locations: boolean;
|
|
113
|
+
/** --no-auto-tune: disable wide-record corpus detection. */
|
|
114
|
+
no_auto_tune: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* True iff the user did not pass explicit --before/--after AND
|
|
117
|
+
* --no-auto-tune was not set. The orchestrator uses this together
|
|
118
|
+
* with a runtime sample of the resolved sources to decide whether
|
|
119
|
+
* to drop before/after to 0 for wide-record corpora.
|
|
120
|
+
*/
|
|
121
|
+
auto_tune_eligible: boolean;
|
|
122
|
+
/** --sort recent|oldest|default. Order nodes by source file mtime. */
|
|
123
|
+
sort?: SortMode;
|
|
124
|
+
/** --window-curve flat|linear|log. Per-node window decay across ranks. */
|
|
125
|
+
window_curve?: WindowCurve;
|
|
126
|
+
/**
|
|
127
|
+
* --clip <N>: sub-line clip mode. Drops line-level context; trims the
|
|
128
|
+
* matched line itself to N chars on each side of the matched span.
|
|
129
|
+
*/
|
|
130
|
+
clip_chars?: number;
|
|
131
|
+
/** --fuzzy: typo-tolerant regex transform before passing to rg. */
|
|
132
|
+
fuzzy?: boolean;
|
|
133
|
+
}
|
|
134
|
+
export interface MindPalaceOps {
|
|
135
|
+
/** Path to the mind-palace JSON file. */
|
|
136
|
+
path?: string;
|
|
137
|
+
/** --mp-stash: stash the result of the current search. */
|
|
138
|
+
stash?: {
|
|
139
|
+
name: string;
|
|
140
|
+
note: string;
|
|
141
|
+
tags: string[];
|
|
142
|
+
replace: boolean;
|
|
143
|
+
};
|
|
144
|
+
/** --mp-list: list stashes. */
|
|
145
|
+
list?: {
|
|
146
|
+
tags: string[];
|
|
147
|
+
};
|
|
148
|
+
/** --mp-get: print a stash. Defaults to a card view (metadata, tags,
|
|
149
|
+
* relations, source paths — no captured nodes). Pass --with-nodes /
|
|
150
|
+
* --full to include the captured nodes block. */
|
|
151
|
+
get?: {
|
|
152
|
+
name: string;
|
|
153
|
+
with_nodes: boolean;
|
|
154
|
+
};
|
|
155
|
+
/** --mp-drop: remove a stash. */
|
|
156
|
+
drop?: string;
|
|
157
|
+
/** --mp-from: use a stashed file list as search target. */
|
|
158
|
+
from?: string;
|
|
159
|
+
/** --mp-compose: union of multiple stashes as search target. */
|
|
160
|
+
compose?: string[];
|
|
161
|
+
/** --mp-except: files in `except.base` not in any of `except.exclude`. */
|
|
162
|
+
except?: {
|
|
163
|
+
base: string;
|
|
164
|
+
exclude: string[];
|
|
165
|
+
};
|
|
166
|
+
/** --mp-intersect: files in all of the given stashes. */
|
|
167
|
+
intersect?: string[];
|
|
168
|
+
/** --mp-ttl: auto-expiry duration for stashed results. */
|
|
169
|
+
ttl?: string;
|
|
170
|
+
/** --mp-prune-older-than: prune stashes older than this duration. */
|
|
171
|
+
prune_older_than?: string;
|
|
172
|
+
/** --mp-prune-keep: keep only N most recent stashes. */
|
|
173
|
+
prune_keep?: number;
|
|
174
|
+
/** --mp-prune-tag: prune all stashes with this tag. */
|
|
175
|
+
prune_tag?: string;
|
|
176
|
+
/** --mp-prune-all: prune everything (requires --mp-prune-confirm). */
|
|
177
|
+
prune_all?: boolean;
|
|
178
|
+
/** --mp-prune-expired: prune stashes whose TTL has elapsed. */
|
|
179
|
+
prune_expired?: boolean;
|
|
180
|
+
/** --mp-prune-confirm: required for destructive prune ops. */
|
|
181
|
+
prune_confirm?: boolean;
|
|
182
|
+
/** --mp-prune-dry-run: show what would be pruned without deleting. */
|
|
183
|
+
prune_dry_run?: boolean;
|
|
184
|
+
/** --mp-link: create a relationship between stashes. */
|
|
185
|
+
link?: {
|
|
186
|
+
from: string;
|
|
187
|
+
to: string;
|
|
188
|
+
type: string;
|
|
189
|
+
note: string;
|
|
190
|
+
};
|
|
191
|
+
/** --mp-unlink: remove a relationship. */
|
|
192
|
+
unlink?: {
|
|
193
|
+
from: string;
|
|
194
|
+
to: string;
|
|
195
|
+
};
|
|
196
|
+
/** --mp-related: list related stashes. */
|
|
197
|
+
related?: string;
|
|
198
|
+
/** --mp-graph: traversal graph from a stash. */
|
|
199
|
+
graph?: {
|
|
200
|
+
name: string;
|
|
201
|
+
depth: number;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/** A source input as specified on the command line, pre-resolution. */
|
|
205
|
+
export type SourceInput = {
|
|
206
|
+
type: "path";
|
|
207
|
+
path: string;
|
|
208
|
+
} | {
|
|
209
|
+
type: "command";
|
|
210
|
+
command: string;
|
|
211
|
+
} | {
|
|
212
|
+
type: "stdin";
|
|
213
|
+
} | {
|
|
214
|
+
type: "url";
|
|
215
|
+
url: string;
|
|
216
|
+
};
|
|
217
|
+
export interface RgOptions {
|
|
218
|
+
case_insensitive?: boolean;
|
|
219
|
+
word_match?: boolean;
|
|
220
|
+
fixed_strings?: boolean;
|
|
221
|
+
multiline?: boolean;
|
|
222
|
+
hidden?: boolean;
|
|
223
|
+
no_ignore?: boolean;
|
|
224
|
+
include_globs?: string[];
|
|
225
|
+
exclude_globs?: string[];
|
|
226
|
+
type?: string;
|
|
227
|
+
glob_case_insensitive?: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Maximum columns rg will emit for a single line. Lines longer than
|
|
230
|
+
* this are reported via `--max-columns-preview` (rg notes a match
|
|
231
|
+
* existed but does not emit the megabyte-long body). Defaults to
|
|
232
|
+
* 1_000_000 — large enough for any sane corpus, small enough that a
|
|
233
|
+
* minified asset can't blow up the JSON parser.
|
|
234
|
+
*/
|
|
235
|
+
max_columns?: number;
|
|
236
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mind-palace-graph",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Node-centric context retrieval CLI for LLM harnesses. Token-budgeted search with effort presets, mind palace (stash/drop/compose/relationships), pagination, MCP server, multi-tool schemas for Claude & Gemini.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mpg": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/",
|
|
12
|
+
"skills/",
|
|
13
|
+
"README.md",
|
|
14
|
+
"INSTALL.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc && node -e \"const fs=require('fs'); const f='dist/index.js'; const c=fs.readFileSync(f,'utf8'); if(!c.startsWith('#!')) fs.writeFileSync(f,'#!/usr/bin/env node\\n'+c);\"",
|
|
19
|
+
"dev": "tsx src/index.ts",
|
|
20
|
+
"start": "node dist/index.js",
|
|
21
|
+
"mcp": "node dist/mcp-server.js",
|
|
22
|
+
"test": "tsx test/smoke.ts",
|
|
23
|
+
"bench": "npm run bench:micro && npm run bench:meso && npm run bench:meso-embed && npm run bench:conv && npm run bench:conv-chunked && npm run bench:semantic && npm run bench:macro && npm run bench:multiturn && npm run bench:compaction && npm run bench:agg",
|
|
24
|
+
"bench:micro": "tsx bench/micro/palace-semantics.ts",
|
|
25
|
+
"bench:meso": "tsx bench/meso/recall-vs-budget.ts",
|
|
26
|
+
"bench:meso-embed": "tsx bench/meso/embedding-baseline.ts",
|
|
27
|
+
"bench:conv": "tsx bench/conversational/run.ts",
|
|
28
|
+
"bench:conv-chunked": "tsx bench/conversational/run-chunked.ts",
|
|
29
|
+
"bench:semantic": "tsx bench/semantic/run.ts",
|
|
30
|
+
"bench:typo": "tsx bench/typo/run.ts",
|
|
31
|
+
"bench:macro": "tsx bench/macro/run.ts",
|
|
32
|
+
"bench:multiturn": "tsx bench/multiturn/run.ts",
|
|
33
|
+
"bench:compaction": "tsx bench/compaction/run.ts",
|
|
34
|
+
"bench:perf": "tsx bench/perf/run.ts",
|
|
35
|
+
"bench:agg": "tsx bench/aggregate.ts",
|
|
36
|
+
"clean": "rm -rf dist"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=20"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "https://github.com/JadeZaher/mind-palace-graph"
|
|
44
|
+
},
|
|
45
|
+
"bugs": "https://github.com/JadeZaher/mind-palace-graph/issues",
|
|
46
|
+
"homepage": "https://github.com/JadeZaher/mind-palace-graph#readme",
|
|
47
|
+
"keywords": [
|
|
48
|
+
"llm",
|
|
49
|
+
"context",
|
|
50
|
+
"retrieval",
|
|
51
|
+
"ripgrep",
|
|
52
|
+
"cli",
|
|
53
|
+
"ai",
|
|
54
|
+
"harness",
|
|
55
|
+
"rag",
|
|
56
|
+
"node-search"
|
|
57
|
+
],
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@anthropic-ai/sdk": "^0.102.0",
|
|
61
|
+
"@types/node": "^22.10.0",
|
|
62
|
+
"@xenova/transformers": "^2.17.2",
|
|
63
|
+
"openai": "^6.42.0",
|
|
64
|
+
"tsx": "^4.19.0",
|
|
65
|
+
"typescript": "^5.7.0"
|
|
66
|
+
}
|
|
67
|
+
}
|