@shrkcrft/knowledge 0.1.0-alpha.1
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/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/define/define-knowledge-base.d.ts +7 -0
- package/dist/define/define-knowledge-base.d.ts.map +1 -0
- package/dist/define/define-knowledge-base.js +3 -0
- package/dist/define/define-knowledge-entry.d.ts +20 -0
- package/dist/define/define-knowledge-entry.d.ts.map +1 -0
- package/dist/define/define-knowledge-entry.js +35 -0
- package/dist/format/action-hints-formatter.d.ts +35 -0
- package/dist/format/action-hints-formatter.d.ts.map +1 -0
- package/dist/format/action-hints-formatter.js +120 -0
- package/dist/format/knowledge-formatter.d.ts +11 -0
- package/dist/format/knowledge-formatter.d.ts.map +1 -0
- package/dist/format/knowledge-formatter.js +58 -0
- package/dist/index/knowledge-index.d.ts +16 -0
- package/dist/index/knowledge-index.d.ts.map +1 -0
- package/dist/index/knowledge-index.js +63 -0
- package/dist/index/relevance-score.d.ts +9 -0
- package/dist/index/relevance-score.d.ts.map +1 -0
- package/dist/index/relevance-score.js +89 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/load/knowledge-loader.d.ts +11 -0
- package/dist/load/knowledge-loader.d.ts.map +1 -0
- package/dist/load/knowledge-loader.js +1 -0
- package/dist/load/markdown-knowledge-loader.d.ts +6 -0
- package/dist/load/markdown-knowledge-loader.d.ts.map +1 -0
- package/dist/load/markdown-knowledge-loader.js +84 -0
- package/dist/load/typescript-knowledge-loader.d.ts +11 -0
- package/dist/load/typescript-knowledge-loader.d.ts.map +1 -0
- package/dist/load/typescript-knowledge-loader.js +78 -0
- package/dist/model/action-hints.d.ts +63 -0
- package/dist/model/action-hints.d.ts.map +1 -0
- package/dist/model/action-hints.js +23 -0
- package/dist/model/knowledge-base.d.ts +6 -0
- package/dist/model/knowledge-base.d.ts.map +1 -0
- package/dist/model/knowledge-base.js +1 -0
- package/dist/model/knowledge-entry.d.ts +84 -0
- package/dist/model/knowledge-entry.d.ts.map +1 -0
- package/dist/model/knowledge-entry.js +1 -0
- package/dist/model/knowledge-priority.d.ts +9 -0
- package/dist/model/knowledge-priority.d.ts.map +1 -0
- package/dist/model/knowledge-priority.js +16 -0
- package/dist/model/knowledge-query.d.ts +17 -0
- package/dist/model/knowledge-query.d.ts.map +1 -0
- package/dist/model/knowledge-query.js +1 -0
- package/dist/model/knowledge-search-result.d.ts +11 -0
- package/dist/model/knowledge-search-result.d.ts.map +1 -0
- package/dist/model/knowledge-search-result.js +1 -0
- package/dist/model/knowledge-type.d.ts +25 -0
- package/dist/model/knowledge-type.d.ts.map +1 -0
- package/dist/model/knowledge-type.js +27 -0
- package/dist/search/knowledge-filter.d.ts +9 -0
- package/dist/search/knowledge-filter.d.ts.map +1 -0
- package/dist/search/knowledge-filter.js +15 -0
- package/dist/search/knowledge-search.d.ts +5 -0
- package/dist/search/knowledge-search.d.ts.map +1 -0
- package/dist/search/knowledge-search.js +5 -0
- package/dist/validate/validate-knowledge-entries.d.ts +29 -0
- package/dist/validate/validate-knowledge-entries.d.ts.map +1 -0
- package/dist/validate/validate-knowledge-entries.js +101 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SharkCraft contributors
|
|
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
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @shrkcrft/knowledge
|
|
2
|
+
|
|
3
|
+
SharkCraft structured knowledge model: typed entries, index, search, loaders (TS + markdown), validation.
|
|
4
|
+
|
|
5
|
+
Part of [SharkCraft](https://github.com/sharkcraft/sharkcraft) — a deterministic, local-first toolkit that gives AI coding agents durable project context. See the main repo for documentation, examples, and the `shrk` CLI.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun add @shrkcrft/knowledge
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
MIT — see [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IKnowledgeBaseDefinition } from '../model/knowledge-base.js';
|
|
2
|
+
import type { IKnowledgeEntry } from '../model/knowledge-entry.js';
|
|
3
|
+
export declare function defineKnowledgeBase(input: {
|
|
4
|
+
name?: string;
|
|
5
|
+
entries: readonly IKnowledgeEntry[];
|
|
6
|
+
}): IKnowledgeBaseDefinition;
|
|
7
|
+
//# sourceMappingURL=define-knowledge-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-knowledge-base.d.ts","sourceRoot":"","sources":["../../src/define/define-knowledge-base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;CACrC,GAAG,wBAAwB,CAE3B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IKnowledgeEntry, IKnowledgeExample, IKnowledgeSource } from '../model/knowledge-entry.js';
|
|
2
|
+
import type { IActionHints } from '../model/action-hints.js';
|
|
3
|
+
export interface DefineKnowledgeInput {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
type: string;
|
|
7
|
+
priority?: string;
|
|
8
|
+
scope?: readonly string[];
|
|
9
|
+
tags?: readonly string[];
|
|
10
|
+
appliesWhen?: readonly string[];
|
|
11
|
+
content: string;
|
|
12
|
+
summary?: string;
|
|
13
|
+
examples?: readonly IKnowledgeExample[];
|
|
14
|
+
related?: readonly string[];
|
|
15
|
+
source?: IKnowledgeSource;
|
|
16
|
+
metadata?: Readonly<Record<string, unknown>>;
|
|
17
|
+
actionHints?: IActionHints;
|
|
18
|
+
}
|
|
19
|
+
export declare function defineKnowledgeEntry(input: DefineKnowledgeInput): IKnowledgeEntry;
|
|
20
|
+
//# sourceMappingURL=define-knowledge-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-knowledge-entry.d.ts","sourceRoot":"","sources":["../../src/define/define-knowledge-entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACxG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAI7D,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACxC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7C,WAAW,CAAC,EAAE,YAAY,CAAC;CAC5B;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,oBAAoB,GAAG,eAAe,CAmCjF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { KnowledgePriority } from "../model/knowledge-priority.js";
|
|
2
|
+
import { isValidKnowledgeId } from '@shrkcrft/core';
|
|
3
|
+
export function defineKnowledgeEntry(input) {
|
|
4
|
+
if (!input.id || typeof input.id !== 'string') {
|
|
5
|
+
throw new Error(`defineKnowledgeEntry: 'id' is required (got ${String(input.id)})`);
|
|
6
|
+
}
|
|
7
|
+
if (!isValidKnowledgeId(input.id)) {
|
|
8
|
+
throw new Error(`defineKnowledgeEntry: 'id' must match /^[a-z0-9]+([.-][a-z0-9]+)*$/ (got "${input.id}")`);
|
|
9
|
+
}
|
|
10
|
+
if (!input.title) {
|
|
11
|
+
throw new Error(`defineKnowledgeEntry: 'title' is required for ${input.id}`);
|
|
12
|
+
}
|
|
13
|
+
if (!input.type) {
|
|
14
|
+
throw new Error(`defineKnowledgeEntry: 'type' is required for ${input.id}`);
|
|
15
|
+
}
|
|
16
|
+
if (typeof input.content !== 'string') {
|
|
17
|
+
throw new Error(`defineKnowledgeEntry: 'content' is required for ${input.id}`);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
id: input.id,
|
|
21
|
+
title: input.title,
|
|
22
|
+
type: input.type,
|
|
23
|
+
priority: input.priority ?? KnowledgePriority.Medium,
|
|
24
|
+
scope: Object.freeze([...(input.scope ?? [])]),
|
|
25
|
+
tags: Object.freeze([...(input.tags ?? [])]),
|
|
26
|
+
appliesWhen: Object.freeze([...(input.appliesWhen ?? [])]),
|
|
27
|
+
content: input.content,
|
|
28
|
+
summary: input.summary,
|
|
29
|
+
examples: input.examples ? Object.freeze([...input.examples]) : undefined,
|
|
30
|
+
related: input.related ? Object.freeze([...input.related]) : undefined,
|
|
31
|
+
source: input.source,
|
|
32
|
+
metadata: input.metadata,
|
|
33
|
+
actionHints: input.actionHints,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { IKnowledgeEntry } from '../model/knowledge-entry.js';
|
|
2
|
+
import type { IActionHintCommand, IActionHintMcpTool } from '../model/action-hints.js';
|
|
3
|
+
export interface IAggregatedActionHints {
|
|
4
|
+
commands: IActionHintCommand[];
|
|
5
|
+
mcpTools: IActionHintMcpTool[];
|
|
6
|
+
preferredFlow: readonly string[];
|
|
7
|
+
preferredFlowSourceId?: string;
|
|
8
|
+
forbiddenActions: string[];
|
|
9
|
+
relatedTemplates: string[];
|
|
10
|
+
relatedPathConventions: string[];
|
|
11
|
+
relatedKnowledge: string[];
|
|
12
|
+
verificationCommands: string[];
|
|
13
|
+
safetyNotes: string[];
|
|
14
|
+
requiresHumanReview: boolean;
|
|
15
|
+
writePolicy?: string;
|
|
16
|
+
/** Entry ids that contributed at least one hint. */
|
|
17
|
+
contributingEntries: string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Combine actionHints from a list of relevant entries into a single bundle.
|
|
21
|
+
* Order of entries determines tie-breaking: the highest-priority entry wins
|
|
22
|
+
* for `preferredFlow` and `writePolicy`. Other fields are deduped union.
|
|
23
|
+
*/
|
|
24
|
+
export declare function aggregateActionHints(entries: readonly IKnowledgeEntry[]): IAggregatedActionHints;
|
|
25
|
+
export interface FormatActionHintsOptions {
|
|
26
|
+
/** Title prefix (used by the context builder as section headings). */
|
|
27
|
+
level?: '##' | '###';
|
|
28
|
+
/** When true, omit empty subsections instead of rendering a heading. */
|
|
29
|
+
compact?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function formatAggregatedHints(hints: IAggregatedActionHints, options?: FormatActionHintsOptions): string;
|
|
32
|
+
export declare function formatEntryActionHints(entry: IKnowledgeEntry, options?: FormatActionHintsOptions): string;
|
|
33
|
+
/** Returns a single text block for an aggregated bundle. Useful for CLI output. */
|
|
34
|
+
export declare function aggregatedHintsToText(hints: IAggregatedActionHints): string;
|
|
35
|
+
//# sourceMappingURL=action-hints-formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-hints-formatter.d.ts","sourceRoot":"","sources":["../../src/format/action-hints-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAGlC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B;AAkBD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,SAAS,eAAe,EAAE,GAClC,sBAAsB,CAyCxB;AAED,MAAM,WAAW,wBAAwB;IACvC,sEAAsE;IACtE,KAAK,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC;IACrB,wEAAwE;IACxE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAgBD,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,sBAAsB,EAC7B,OAAO,GAAE,wBAA6B,GACrC,MAAM,CA2DR;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,eAAe,EACtB,OAAO,GAAE,wBAA6B,GACrC,MAAM,CAGR;AAED,mFAAmF;AACnF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,sBAAsB,GAAG,MAAM,CAE3E"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { priorityWeight } from "../model/knowledge-priority.js";
|
|
2
|
+
function dedupePush(out, items, key) {
|
|
3
|
+
if (!items)
|
|
4
|
+
return;
|
|
5
|
+
const seen = new Set(out.map(key));
|
|
6
|
+
for (const item of items) {
|
|
7
|
+
const k = key(item);
|
|
8
|
+
if (!seen.has(k)) {
|
|
9
|
+
seen.add(k);
|
|
10
|
+
out.push(item);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function dedupeStrings(out, items) {
|
|
15
|
+
dedupePush(out, items, (s) => s);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Combine actionHints from a list of relevant entries into a single bundle.
|
|
19
|
+
* Order of entries determines tie-breaking: the highest-priority entry wins
|
|
20
|
+
* for `preferredFlow` and `writePolicy`. Other fields are deduped union.
|
|
21
|
+
*/
|
|
22
|
+
export function aggregateActionHints(entries) {
|
|
23
|
+
const out = {
|
|
24
|
+
commands: [],
|
|
25
|
+
mcpTools: [],
|
|
26
|
+
preferredFlow: [],
|
|
27
|
+
forbiddenActions: [],
|
|
28
|
+
relatedTemplates: [],
|
|
29
|
+
relatedPathConventions: [],
|
|
30
|
+
relatedKnowledge: [],
|
|
31
|
+
verificationCommands: [],
|
|
32
|
+
safetyNotes: [],
|
|
33
|
+
requiresHumanReview: false,
|
|
34
|
+
contributingEntries: [],
|
|
35
|
+
};
|
|
36
|
+
// Sort by priority desc so highest-priority entries win for "preferredFlow".
|
|
37
|
+
const sorted = [...entries].sort((a, b) => priorityWeight(b.priority) - priorityWeight(a.priority));
|
|
38
|
+
for (const entry of sorted) {
|
|
39
|
+
const h = entry.actionHints;
|
|
40
|
+
if (!h)
|
|
41
|
+
continue;
|
|
42
|
+
dedupePush(out.commands, h.commands, (c) => c.command);
|
|
43
|
+
dedupePush(out.mcpTools, h.mcpTools, (m) => m.tool);
|
|
44
|
+
if (!out.preferredFlow.length && h.preferredFlow?.length) {
|
|
45
|
+
out.preferredFlow = h.preferredFlow;
|
|
46
|
+
out.preferredFlowSourceId = entry.id;
|
|
47
|
+
}
|
|
48
|
+
dedupeStrings(out.forbiddenActions, h.forbiddenActions);
|
|
49
|
+
dedupeStrings(out.relatedTemplates, h.relatedTemplates);
|
|
50
|
+
dedupeStrings(out.relatedPathConventions, h.relatedPathConventions);
|
|
51
|
+
dedupeStrings(out.relatedKnowledge, h.relatedKnowledge);
|
|
52
|
+
dedupeStrings(out.verificationCommands, h.verificationCommands);
|
|
53
|
+
dedupeStrings(out.safetyNotes, h.safetyNotes);
|
|
54
|
+
if (h.requiresHumanReview)
|
|
55
|
+
out.requiresHumanReview = true;
|
|
56
|
+
if (h.writePolicy && !out.writePolicy)
|
|
57
|
+
out.writePolicy = String(h.writePolicy);
|
|
58
|
+
out.contributingEntries.push(entry.id);
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
function formatCmd(c) {
|
|
63
|
+
const req = c.required ? ' (required)' : '';
|
|
64
|
+
const when = c.when ? ` — when: ${c.when}` : '';
|
|
65
|
+
const purpose = c.purpose ? ` — ${c.purpose}` : '';
|
|
66
|
+
return `\`${c.command}\`${req}${purpose}${when}`;
|
|
67
|
+
}
|
|
68
|
+
function formatTool(t) {
|
|
69
|
+
const req = t.required ? ' (required)' : '';
|
|
70
|
+
const when = t.when ? ` — when: ${t.when}` : '';
|
|
71
|
+
const purpose = t.purpose ? ` — ${t.purpose}` : '';
|
|
72
|
+
return `\`${t.tool}\`${req}${purpose}${when}`;
|
|
73
|
+
}
|
|
74
|
+
export function formatAggregatedHints(hints, options = {}) {
|
|
75
|
+
const level = options.level ?? '##';
|
|
76
|
+
const lines = [];
|
|
77
|
+
function section(name, body) {
|
|
78
|
+
if (!body)
|
|
79
|
+
return;
|
|
80
|
+
lines.push(`${level} ${name}`);
|
|
81
|
+
lines.push('');
|
|
82
|
+
lines.push(body);
|
|
83
|
+
lines.push('');
|
|
84
|
+
}
|
|
85
|
+
section('Recommended MCP Tools', hints.mcpTools.map((t) => `- ${formatTool(t)}`).join('\n'));
|
|
86
|
+
section('Recommended CLI Commands', hints.commands.map((c) => `- ${formatCmd(c)}`).join('\n'));
|
|
87
|
+
if (hints.preferredFlow.length) {
|
|
88
|
+
const src = hints.preferredFlowSourceId ? ` _(from ${hints.preferredFlowSourceId})_` : '';
|
|
89
|
+
section(`Preferred Flow${src}`, hints.preferredFlow.map((s, i) => `${i + 1}. ${s}`).join('\n'));
|
|
90
|
+
}
|
|
91
|
+
section('Forbidden Actions', hints.forbiddenActions.map((a) => `- ${a}`).join('\n'));
|
|
92
|
+
section('Verification Commands', hints.verificationCommands.map((c) => `- \`${c}\``).join('\n'));
|
|
93
|
+
section('Safety Notes', hints.safetyNotes.map((n) => `- ${n}`).join('\n'));
|
|
94
|
+
if (hints.relatedTemplates.length) {
|
|
95
|
+
section('Related Templates', hints.relatedTemplates.map((t) => `- \`${t}\``).join('\n'));
|
|
96
|
+
}
|
|
97
|
+
if (hints.relatedPathConventions.length) {
|
|
98
|
+
section('Related Path Conventions', hints.relatedPathConventions.map((p) => `- \`${p}\``).join('\n'));
|
|
99
|
+
}
|
|
100
|
+
if (hints.requiresHumanReview || hints.writePolicy) {
|
|
101
|
+
const parts = [];
|
|
102
|
+
if (hints.requiresHumanReview)
|
|
103
|
+
parts.push('Requires human review.');
|
|
104
|
+
if (hints.writePolicy)
|
|
105
|
+
parts.push(`Write policy: \`${hints.writePolicy}\`.`);
|
|
106
|
+
section('Human Review Points', parts.map((p) => `- ${p}`).join('\n'));
|
|
107
|
+
}
|
|
108
|
+
if (options.compact && lines.length === 0)
|
|
109
|
+
return '';
|
|
110
|
+
return lines.join('\n').trim();
|
|
111
|
+
}
|
|
112
|
+
export function formatEntryActionHints(entry, options = {}) {
|
|
113
|
+
if (!entry.actionHints)
|
|
114
|
+
return '';
|
|
115
|
+
return formatAggregatedHints(aggregateActionHints([entry]), options);
|
|
116
|
+
}
|
|
117
|
+
/** Returns a single text block for an aggregated bundle. Useful for CLI output. */
|
|
118
|
+
export function aggregatedHintsToText(hints) {
|
|
119
|
+
return formatAggregatedHints(hints, { compact: true });
|
|
120
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IKnowledgeEntry } from '../model/knowledge-entry.js';
|
|
2
|
+
export interface FormatEntryOptions {
|
|
3
|
+
includeExamples?: boolean;
|
|
4
|
+
includeContent?: boolean;
|
|
5
|
+
includeMetadata?: boolean;
|
|
6
|
+
includeActionHints?: boolean;
|
|
7
|
+
maxContentChars?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function formatEntryCompact(entry: IKnowledgeEntry): string;
|
|
10
|
+
export declare function formatEntryFull(entry: IKnowledgeEntry, options?: FormatEntryOptions): string;
|
|
11
|
+
//# sourceMappingURL=knowledge-formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge-formatter.d.ts","sourceRoot":"","sources":["../../src/format/knowledge-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAGnE,MAAM,WAAW,kBAAkB;IACjC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAKjE;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,eAAe,EACtB,OAAO,GAAE,kBAAuB,GAC/B,MAAM,CA4CR"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { formatEntryActionHints } from "./action-hints-formatter.js";
|
|
2
|
+
export function formatEntryCompact(entry) {
|
|
3
|
+
const tags = entry.tags.length ? ` tags=[${entry.tags.join(', ')}]` : '';
|
|
4
|
+
const scope = entry.scope.length ? ` scope=[${entry.scope.join(', ')}]` : '';
|
|
5
|
+
const appliesWhen = entry.appliesWhen.length ? ` appliesWhen=[${entry.appliesWhen.join(', ')}]` : '';
|
|
6
|
+
return `${entry.id} (${entry.type}, ${entry.priority}) — ${entry.title}${tags}${scope}${appliesWhen}`;
|
|
7
|
+
}
|
|
8
|
+
export function formatEntryFull(entry, options = {}) {
|
|
9
|
+
const { includeExamples = true, includeContent = true, maxContentChars } = options;
|
|
10
|
+
const lines = [];
|
|
11
|
+
lines.push(`# ${entry.title}`);
|
|
12
|
+
lines.push(`id: ${entry.id}`);
|
|
13
|
+
lines.push(`type: ${entry.type}`);
|
|
14
|
+
lines.push(`priority: ${entry.priority}`);
|
|
15
|
+
if (entry.scope.length)
|
|
16
|
+
lines.push(`scope: ${entry.scope.join(', ')}`);
|
|
17
|
+
if (entry.tags.length)
|
|
18
|
+
lines.push(`tags: ${entry.tags.join(', ')}`);
|
|
19
|
+
if (entry.appliesWhen.length)
|
|
20
|
+
lines.push(`appliesWhen: ${entry.appliesWhen.join(', ')}`);
|
|
21
|
+
if (entry.summary) {
|
|
22
|
+
lines.push('');
|
|
23
|
+
lines.push(`Summary: ${entry.summary}`);
|
|
24
|
+
}
|
|
25
|
+
if (includeContent) {
|
|
26
|
+
lines.push('');
|
|
27
|
+
let content = entry.content.trim();
|
|
28
|
+
if (maxContentChars && content.length > maxContentChars) {
|
|
29
|
+
content = content.slice(0, maxContentChars) + '…';
|
|
30
|
+
}
|
|
31
|
+
lines.push(content);
|
|
32
|
+
}
|
|
33
|
+
if (includeExamples && entry.examples?.length) {
|
|
34
|
+
lines.push('');
|
|
35
|
+
lines.push('Examples:');
|
|
36
|
+
for (const ex of entry.examples) {
|
|
37
|
+
if (ex.title)
|
|
38
|
+
lines.push(`- ${ex.title}`);
|
|
39
|
+
if (ex.description)
|
|
40
|
+
lines.push(` ${ex.description}`);
|
|
41
|
+
if (ex.code) {
|
|
42
|
+
const lang = ex.language ?? '';
|
|
43
|
+
lines.push(' ```' + lang);
|
|
44
|
+
for (const codeLine of ex.code.split('\n'))
|
|
45
|
+
lines.push(' ' + codeLine);
|
|
46
|
+
lines.push(' ```');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (options.includeActionHints !== false && entry.actionHints) {
|
|
51
|
+
const block = formatEntryActionHints(entry, { level: '###', compact: true });
|
|
52
|
+
if (block) {
|
|
53
|
+
lines.push('');
|
|
54
|
+
lines.push(block);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return lines.join('\n');
|
|
58
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IKnowledgeEntry } from '../model/knowledge-entry.js';
|
|
2
|
+
import type { IKnowledgeQuery } from '../model/knowledge-query.js';
|
|
3
|
+
import type { IKnowledgeSearchResult } from '../model/knowledge-search-result.js';
|
|
4
|
+
export declare class KnowledgeIndex {
|
|
5
|
+
private readonly byId;
|
|
6
|
+
private readonly all;
|
|
7
|
+
constructor(entries?: readonly IKnowledgeEntry[]);
|
|
8
|
+
add(entry: IKnowledgeEntry): void;
|
|
9
|
+
has(id: string): boolean;
|
|
10
|
+
get(id: string): IKnowledgeEntry | null;
|
|
11
|
+
list(): readonly IKnowledgeEntry[];
|
|
12
|
+
size(): number;
|
|
13
|
+
filter(predicate: (entry: IKnowledgeEntry) => boolean): IKnowledgeEntry[];
|
|
14
|
+
search(query: IKnowledgeQuery): IKnowledgeSearchResult[];
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=knowledge-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge-index.d.ts","sourceRoot":"","sources":["../../src/index/knowledge-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAIlF,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAsC;IAC3D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAyB;gBAEjC,OAAO,GAAE,SAAS,eAAe,EAAO;IAIpD,GAAG,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;IAajC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIxB,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI;IAIvC,IAAI,IAAI,SAAS,eAAe,EAAE;IAIlC,IAAI,IAAI,MAAM;IAId,MAAM,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,OAAO,GAAG,eAAe,EAAE;IAIzE,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,sBAAsB,EAAE;CA4BzD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { priorityWeight } from "../model/knowledge-priority.js";
|
|
2
|
+
import { scoreEntry } from "./relevance-score.js";
|
|
3
|
+
export class KnowledgeIndex {
|
|
4
|
+
byId = new Map();
|
|
5
|
+
all = [];
|
|
6
|
+
constructor(entries = []) {
|
|
7
|
+
for (const e of entries)
|
|
8
|
+
this.add(e);
|
|
9
|
+
}
|
|
10
|
+
add(entry) {
|
|
11
|
+
if (this.byId.has(entry.id)) {
|
|
12
|
+
// Keep the first definition; tolerate duplicates with a warning marker.
|
|
13
|
+
const existing = this.byId.get(entry.id);
|
|
14
|
+
if (existing.content !== entry.content || existing.title !== entry.title) {
|
|
15
|
+
// Don't throw — multiple files may legitimately re-export.
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
this.byId.set(entry.id, entry);
|
|
20
|
+
this.all.push(entry);
|
|
21
|
+
}
|
|
22
|
+
has(id) {
|
|
23
|
+
return this.byId.has(id);
|
|
24
|
+
}
|
|
25
|
+
get(id) {
|
|
26
|
+
return this.byId.get(id) ?? null;
|
|
27
|
+
}
|
|
28
|
+
list() {
|
|
29
|
+
return this.all;
|
|
30
|
+
}
|
|
31
|
+
size() {
|
|
32
|
+
return this.all.length;
|
|
33
|
+
}
|
|
34
|
+
filter(predicate) {
|
|
35
|
+
return this.all.filter(predicate);
|
|
36
|
+
}
|
|
37
|
+
search(query) {
|
|
38
|
+
const minPriorityWeight = query.minPriority
|
|
39
|
+
? priorityWeight(query.minPriority)
|
|
40
|
+
: 0;
|
|
41
|
+
const candidates = this.all.filter((e) => {
|
|
42
|
+
if (query.types?.length && !query.types.includes(String(e.type)))
|
|
43
|
+
return false;
|
|
44
|
+
if (minPriorityWeight > 0 && priorityWeight(e.priority) < minPriorityWeight) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
});
|
|
49
|
+
const scored = candidates
|
|
50
|
+
.map((entry) => {
|
|
51
|
+
const { score, reasons } = scoreEntry(entry, query);
|
|
52
|
+
return { entry, score, reasons };
|
|
53
|
+
})
|
|
54
|
+
.filter((r) => {
|
|
55
|
+
if (query.query || query.appliesWhen?.length || query.scope?.length || query.tags?.length) {
|
|
56
|
+
return r.score > 0 && r.reasons.length > 0;
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
})
|
|
60
|
+
.sort((a, b) => b.score - a.score);
|
|
61
|
+
return query.limit && query.limit > 0 ? scored.slice(0, query.limit) : scored;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IKnowledgeEntry } from '../model/knowledge-entry.js';
|
|
2
|
+
import type { IKnowledgeQuery } from '../model/knowledge-query.js';
|
|
3
|
+
import type { IKnowledgeMatchReason } from '../model/knowledge-search-result.js';
|
|
4
|
+
export interface ScoredMatch {
|
|
5
|
+
score: number;
|
|
6
|
+
reasons: IKnowledgeMatchReason[];
|
|
7
|
+
}
|
|
8
|
+
export declare function scoreEntry(entry: IKnowledgeEntry, query: IKnowledgeQuery): ScoredMatch;
|
|
9
|
+
//# sourceMappingURL=relevance-score.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relevance-score.d.ts","sourceRoot":"","sources":["../../src/index/relevance-score.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAGjF,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,qBAAqB,EAAE,CAAC;CAClC;AAYD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,GAAG,WAAW,CAiFtF"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { priorityWeight } from "../model/knowledge-priority.js";
|
|
2
|
+
const FIELD_WEIGHTS = {
|
|
3
|
+
id: 80,
|
|
4
|
+
title: 50,
|
|
5
|
+
tags: 35,
|
|
6
|
+
scope: 30,
|
|
7
|
+
appliesWhen: 40,
|
|
8
|
+
summary: 25,
|
|
9
|
+
content: 15,
|
|
10
|
+
};
|
|
11
|
+
export function scoreEntry(entry, query) {
|
|
12
|
+
let score = 0;
|
|
13
|
+
const reasons = [];
|
|
14
|
+
// Priority baseline always contributes (so a critical rule outranks a low-priority match).
|
|
15
|
+
score += priorityWeight(entry.priority) / 10;
|
|
16
|
+
// Type filter is a hard match — only score the rest if type matches when types specified.
|
|
17
|
+
const queryText = (query.query ?? '').trim().toLowerCase();
|
|
18
|
+
const queryWords = queryText
|
|
19
|
+
.split(/\s+/)
|
|
20
|
+
.map((w) => w.trim())
|
|
21
|
+
.filter((w) => w.length >= 2);
|
|
22
|
+
// Free-text matches
|
|
23
|
+
if (queryText.length > 0) {
|
|
24
|
+
if (entry.id.toLowerCase().includes(queryText)) {
|
|
25
|
+
score += FIELD_WEIGHTS.id;
|
|
26
|
+
reasons.push({ field: 'id', match: queryText });
|
|
27
|
+
}
|
|
28
|
+
if (entry.title.toLowerCase().includes(queryText)) {
|
|
29
|
+
score += FIELD_WEIGHTS.title;
|
|
30
|
+
reasons.push({ field: 'title', match: queryText });
|
|
31
|
+
}
|
|
32
|
+
if (entry.summary?.toLowerCase().includes(queryText)) {
|
|
33
|
+
score += FIELD_WEIGHTS.summary;
|
|
34
|
+
reasons.push({ field: 'summary', match: queryText });
|
|
35
|
+
}
|
|
36
|
+
if (entry.content.toLowerCase().includes(queryText)) {
|
|
37
|
+
score += FIELD_WEIGHTS.content;
|
|
38
|
+
reasons.push({ field: 'content', match: queryText });
|
|
39
|
+
}
|
|
40
|
+
// Per-word matches against tag/scope/appliesWhen.
|
|
41
|
+
for (const word of queryWords) {
|
|
42
|
+
if (entry.tags.some((t) => t.toLowerCase().includes(word))) {
|
|
43
|
+
score += FIELD_WEIGHTS.tags / queryWords.length;
|
|
44
|
+
reasons.push({ field: 'tags', match: word });
|
|
45
|
+
}
|
|
46
|
+
if (entry.scope.some((s) => s.toLowerCase().includes(word))) {
|
|
47
|
+
score += FIELD_WEIGHTS.scope / queryWords.length;
|
|
48
|
+
reasons.push({ field: 'scope', match: word });
|
|
49
|
+
}
|
|
50
|
+
if (entry.appliesWhen.some((a) => a.toLowerCase().includes(word))) {
|
|
51
|
+
score += FIELD_WEIGHTS.appliesWhen / queryWords.length;
|
|
52
|
+
reasons.push({ field: 'appliesWhen', match: word });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// appliesWhen exact-match bonus.
|
|
57
|
+
if (query.appliesWhen?.length) {
|
|
58
|
+
const matches = entry.appliesWhen.filter((a) => query.appliesWhen.includes(a));
|
|
59
|
+
if (matches.length > 0) {
|
|
60
|
+
score += FIELD_WEIGHTS.appliesWhen;
|
|
61
|
+
for (const m of matches)
|
|
62
|
+
reasons.push({ field: 'appliesWhen', match: m });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// scope exact-match bonus.
|
|
66
|
+
if (query.scope?.length) {
|
|
67
|
+
const matches = entry.scope.filter((s) => query.scope.includes(s));
|
|
68
|
+
if (matches.length > 0) {
|
|
69
|
+
score += FIELD_WEIGHTS.scope;
|
|
70
|
+
for (const m of matches)
|
|
71
|
+
reasons.push({ field: 'scope', match: m });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// tag exact-match bonus.
|
|
75
|
+
if (query.tags?.length) {
|
|
76
|
+
const matches = entry.tags.filter((t) => query.tags.includes(t));
|
|
77
|
+
if (matches.length === query.tags.length) {
|
|
78
|
+
score += FIELD_WEIGHTS.tags;
|
|
79
|
+
for (const m of matches)
|
|
80
|
+
reasons.push({ field: 'tags', match: m });
|
|
81
|
+
}
|
|
82
|
+
else if (matches.length > 0) {
|
|
83
|
+
score += FIELD_WEIGHTS.tags / 2;
|
|
84
|
+
for (const m of matches)
|
|
85
|
+
reasons.push({ field: 'tags', match: m });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return { score, reasons };
|
|
89
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './model/knowledge-entry.js';
|
|
2
|
+
export * from './model/action-hints.js';
|
|
3
|
+
export * from './model/knowledge-type.js';
|
|
4
|
+
export * from './model/knowledge-priority.js';
|
|
5
|
+
export * from './model/knowledge-query.js';
|
|
6
|
+
export * from './model/knowledge-search-result.js';
|
|
7
|
+
export * from './model/knowledge-base.js';
|
|
8
|
+
export * from './define/define-knowledge-entry.js';
|
|
9
|
+
export * from './define/define-knowledge-base.js';
|
|
10
|
+
export * from './load/knowledge-loader.js';
|
|
11
|
+
export * from './load/typescript-knowledge-loader.js';
|
|
12
|
+
export * from './load/markdown-knowledge-loader.js';
|
|
13
|
+
export * from './index/relevance-score.js';
|
|
14
|
+
export * from './index/knowledge-index.js';
|
|
15
|
+
export * from './search/knowledge-search.js';
|
|
16
|
+
export * from './search/knowledge-filter.js';
|
|
17
|
+
export * from './format/knowledge-formatter.js';
|
|
18
|
+
export * from './format/action-hints-formatter.js';
|
|
19
|
+
export * from './validate/validate-knowledge-entries.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,0CAA0C,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from "./model/knowledge-entry.js";
|
|
2
|
+
export * from "./model/action-hints.js";
|
|
3
|
+
export * from "./model/knowledge-type.js";
|
|
4
|
+
export * from "./model/knowledge-priority.js";
|
|
5
|
+
export * from "./model/knowledge-query.js";
|
|
6
|
+
export * from "./model/knowledge-search-result.js";
|
|
7
|
+
export * from "./model/knowledge-base.js";
|
|
8
|
+
export * from "./define/define-knowledge-entry.js";
|
|
9
|
+
export * from "./define/define-knowledge-base.js";
|
|
10
|
+
export * from "./load/knowledge-loader.js";
|
|
11
|
+
export * from "./load/typescript-knowledge-loader.js";
|
|
12
|
+
export * from "./load/markdown-knowledge-loader.js";
|
|
13
|
+
export * from "./index/relevance-score.js";
|
|
14
|
+
export * from "./index/knowledge-index.js";
|
|
15
|
+
export * from "./search/knowledge-search.js";
|
|
16
|
+
export * from "./search/knowledge-filter.js";
|
|
17
|
+
export * from "./format/knowledge-formatter.js";
|
|
18
|
+
export * from "./format/action-hints-formatter.js";
|
|
19
|
+
export * from "./validate/validate-knowledge-entries.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IKnowledgeEntry } from '../model/knowledge-entry.js';
|
|
2
|
+
export interface ILoadedKnowledge {
|
|
3
|
+
entries: IKnowledgeEntry[];
|
|
4
|
+
warnings: string[];
|
|
5
|
+
sourceFiles: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface IKnowledgeLoader {
|
|
8
|
+
load(filePath: string): Promise<ILoadedKnowledge>;
|
|
9
|
+
canLoad(filePath: string): boolean;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=knowledge-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge-loader.d.ts","sourceRoot":"","sources":["../../src/load/knowledge-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAClD,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ILoadedKnowledge, IKnowledgeLoader } from './knowledge-loader.js';
|
|
2
|
+
export declare class MarkdownKnowledgeLoader implements IKnowledgeLoader {
|
|
3
|
+
canLoad(filePath: string): boolean;
|
|
4
|
+
load(filePath: string): Promise<ILoadedKnowledge>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=markdown-knowledge-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-knowledge-loader.d.ts","sourceRoot":"","sources":["../../src/load/markdown-knowledge-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAqDhF,qBAAa,uBAAwB,YAAW,gBAAgB;IAC9D,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI5B,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAyCxD"}
|