ralph-hero-knowledge-index 0.1.7 → 0.1.8
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/.claude-plugin/plugin.json +1 -1
- package/.mcp.json +1 -1
- package/dist/parser.js +7 -1
- package/dist/parser.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/parser.test.ts +83 -0
- package/src/parser.ts +7 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ralph-knowledge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Knowledge graph for ralph-hero: semantic search, relationship traversal, and document indexing across thoughts/ documents. Optional companion to ralph-hero.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Chad Dubiel",
|
package/.mcp.json
CHANGED
package/dist/parser.js
CHANGED
|
@@ -32,7 +32,13 @@ export function parseDocument(id, path, raw) {
|
|
|
32
32
|
date: frontmatter.date ? String(frontmatter.date) : null,
|
|
33
33
|
type: frontmatter.type ?? null,
|
|
34
34
|
status: frontmatter.status ?? null,
|
|
35
|
-
githubIssue: typeof frontmatter.github_issue === "number"
|
|
35
|
+
githubIssue: typeof frontmatter.github_issue === "number"
|
|
36
|
+
? frontmatter.github_issue
|
|
37
|
+
: Array.isArray(frontmatter.github_issues) && typeof frontmatter.github_issues[0] === "number"
|
|
38
|
+
? frontmatter.github_issues[0]
|
|
39
|
+
: typeof frontmatter.primary_issue === "number"
|
|
40
|
+
? frontmatter.primary_issue
|
|
41
|
+
: null,
|
|
36
42
|
tags, relationships, content: body,
|
|
37
43
|
};
|
|
38
44
|
}
|
package/dist/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAqB1C,MAAM,cAAc,GAA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AAE,eAAe,EAAE,CAAC,CAAC;QACpF,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAa,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE3F,OAAO;QACL,EAAE,EAAE,IAAI,EAAE,KAAK;QACf,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;QACxD,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,IAAI;QAC9B,MAAM,EAAE,WAAW,CAAC,MAAM,IAAI,IAAI;QAClC,WAAW,EAAE,OAAO,WAAW,CAAC,YAAY,KAAK,QAAQ;YACvD,CAAC,CAAC,WAAW,CAAC,YAAY;YAC1B,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,OAAO,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,QAAQ;gBAC5F,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;gBAC9B,CAAC,CAAC,OAAO,WAAW,CAAC,aAAa,KAAK,QAAQ;oBAC7C,CAAC,CAAC,WAAW,CAAC,aAAa;oBAC3B,CAAC,CAAC,IAAI;QACZ,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI;KACnC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -97,4 +97,87 @@ describe("parseDocument", () => {
|
|
|
97
97
|
expect(doc.content).toContain("current cache has no TTL");
|
|
98
98
|
expect(doc.content).not.toContain("---");
|
|
99
99
|
});
|
|
100
|
+
|
|
101
|
+
describe("githubIssue fallback chain", () => {
|
|
102
|
+
function makeDoc(frontmatter: string, body = "# Test\n\nContent."): string {
|
|
103
|
+
return `---\n${frontmatter}\n---\n\n${body}`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
it("falls back to github_issues[0] when github_issue is absent", () => {
|
|
107
|
+
const raw = makeDoc("github_issues: [42, 43, 44]");
|
|
108
|
+
const doc = parseDocument("test", "test.md", raw);
|
|
109
|
+
expect(doc.githubIssue).toBe(42);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("falls back to primary_issue when both github_issue and github_issues are absent", () => {
|
|
113
|
+
const raw = makeDoc("primary_issue: 42");
|
|
114
|
+
const doc = parseDocument("test", "test.md", raw);
|
|
115
|
+
expect(doc.githubIssue).toBe(42);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("prefers github_issue over github_issues and primary_issue", () => {
|
|
119
|
+
const raw = makeDoc("github_issue: 10\ngithub_issues: [20, 30]\nprimary_issue: 40");
|
|
120
|
+
const doc = parseDocument("test", "test.md", raw);
|
|
121
|
+
expect(doc.githubIssue).toBe(10);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("prefers github_issues[0] over primary_issue when github_issue is absent", () => {
|
|
125
|
+
const raw = makeDoc("github_issues: [20, 30]\nprimary_issue: 40");
|
|
126
|
+
const doc = parseDocument("test", "test.md", raw);
|
|
127
|
+
expect(doc.githubIssue).toBe(20);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("returns null for empty github_issues array with no other fallbacks", () => {
|
|
131
|
+
const raw = makeDoc("github_issues: []");
|
|
132
|
+
const doc = parseDocument("test", "test.md", raw);
|
|
133
|
+
expect(doc.githubIssue).toBeNull();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("returns null when primary_issue is null", () => {
|
|
137
|
+
const raw = makeDoc("primary_issue: null");
|
|
138
|
+
const doc = parseDocument("test", "test.md", raw);
|
|
139
|
+
expect(doc.githubIssue).toBeNull();
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("returns null when no issue fields are present", () => {
|
|
143
|
+
const raw = makeDoc("status: draft\ntype: plan");
|
|
144
|
+
const doc = parseDocument("test", "test.md", raw);
|
|
145
|
+
expect(doc.githubIssue).toBeNull();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("returns null when github_issues contains non-number first element", () => {
|
|
149
|
+
const raw = makeDoc('github_issues: ["not-a-number"]');
|
|
150
|
+
const doc = parseDocument("test", "test.md", raw);
|
|
151
|
+
expect(doc.githubIssue).toBeNull();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("handles typical group plan frontmatter with all fields", () => {
|
|
155
|
+
const raw = makeDoc([
|
|
156
|
+
"date: 2026-03-09",
|
|
157
|
+
"status: draft",
|
|
158
|
+
"type: plan",
|
|
159
|
+
"github_issue: 550",
|
|
160
|
+
"github_issues: [550, 551, 552]",
|
|
161
|
+
"primary_issue: 550",
|
|
162
|
+
"tags: [knowledge-graph, metadata]",
|
|
163
|
+
].join("\n"));
|
|
164
|
+
const doc = parseDocument("test-plan", "thoughts/shared/plans/test-plan.md", raw);
|
|
165
|
+
expect(doc.githubIssue).toBe(550);
|
|
166
|
+
expect(doc.type).toBe("plan");
|
|
167
|
+
expect(doc.tags).toEqual(["knowledge-graph", "metadata"]);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("handles plan with only github_issues array (no singular)", () => {
|
|
171
|
+
const raw = makeDoc([
|
|
172
|
+
"date: 2026-03-09",
|
|
173
|
+
"status: draft",
|
|
174
|
+
"type: plan",
|
|
175
|
+
"github_issues: [550, 551, 552]",
|
|
176
|
+
"primary_issue: 550",
|
|
177
|
+
"tags: [knowledge-graph]",
|
|
178
|
+
].join("\n"));
|
|
179
|
+
const doc = parseDocument("test-plan", "thoughts/shared/plans/test-plan.md", raw);
|
|
180
|
+
expect(doc.githubIssue).toBe(550);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
100
183
|
});
|
package/src/parser.ts
CHANGED
|
@@ -57,7 +57,13 @@ export function parseDocument(id: string, path: string, raw: string): ParsedDocu
|
|
|
57
57
|
date: frontmatter.date ? String(frontmatter.date) : null,
|
|
58
58
|
type: frontmatter.type ?? null,
|
|
59
59
|
status: frontmatter.status ?? null,
|
|
60
|
-
githubIssue: typeof frontmatter.github_issue === "number"
|
|
60
|
+
githubIssue: typeof frontmatter.github_issue === "number"
|
|
61
|
+
? frontmatter.github_issue
|
|
62
|
+
: Array.isArray(frontmatter.github_issues) && typeof frontmatter.github_issues[0] === "number"
|
|
63
|
+
? frontmatter.github_issues[0]
|
|
64
|
+
: typeof frontmatter.primary_issue === "number"
|
|
65
|
+
? frontmatter.primary_issue
|
|
66
|
+
: null,
|
|
61
67
|
tags, relationships, content: body,
|
|
62
68
|
};
|
|
63
69
|
}
|