@aprimediet/codewalker 1.2.0 → 1.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/README.md +28 -3
- package/package.json +1 -1
- package/prompts/codewalker.md +3 -1
- package/skills/codewalker/SKILL.md +118 -28
- package/src/cards.test.ts +123 -1
- package/src/cards.ts +53 -0
- package/src/db.test.ts +264 -8
- package/src/db.ts +208 -2
- package/src/enrich.test.ts +102 -0
- package/src/enrich.ts +107 -0
- package/src/format.test.ts +51 -0
- package/src/format.ts +5 -0
- package/src/index.contract.test.ts +31 -0
- package/src/index.ts +214 -9
- package/src/indexer.heal.test.ts +90 -0
- package/src/indexer.ts +9 -1
- package/src/notes-cards.test.ts +99 -0
- package/src/notes-cards.ts +92 -0
- package/src/notes.test.ts +172 -0
- package/src/notes.ts +145 -0
- package/src/project.test.ts +12 -1
- package/src/project.ts +5 -1
- package/src/query.test.ts +77 -1
- package/src/query.ts +10 -6
- package/src/types.ts +18 -2
package/src/query.ts
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* Query orchestration: wraps DB search with staleness detection.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { QueryResult, QueryResultRow, StalenessInfo } from "./types.ts";
|
|
6
|
-
import { openDb, searchSymbols, searchLibSymbols, getMeta } from "./db.ts";
|
|
5
|
+
import type { QueryResult, QueryResultRow, StalenessInfo, NoteKind } from "./types.ts";
|
|
6
|
+
import { openDb, searchSymbols, searchLibSymbols, searchNotes, getMeta } from "./db.ts";
|
|
7
7
|
import { getHeadSha, changedFilesSince } from "./git.ts";
|
|
8
8
|
|
|
9
9
|
export interface QueryParams {
|
|
10
10
|
query: string;
|
|
11
11
|
kind?: string;
|
|
12
12
|
limit?: number;
|
|
13
|
-
/** Source scope: "code" (default, only code symbols), "libs" (only lib symbols), or "all" (
|
|
14
|
-
source?: "code" | "libs" | "all";
|
|
13
|
+
/** Source scope: "code" (default, only code symbols), "libs" (only lib symbols), "notes" (only notes), or "all" (all three). */
|
|
14
|
+
source?: "code" | "libs" | "notes" | "all";
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -36,13 +36,17 @@ export function runQuery(
|
|
|
36
36
|
|
|
37
37
|
if (source === "libs") {
|
|
38
38
|
rows = searchLibSymbols(db, params.query, params.kind, limit) as unknown as QueryResultRow[];
|
|
39
|
+
} else if (source === "notes") {
|
|
40
|
+
const noteRows = searchNotes(db, params.query, params.kind as NoteKind | undefined, limit);
|
|
41
|
+
rows = noteRows as unknown as QueryResultRow[];
|
|
39
42
|
} else if (source === "all") {
|
|
40
|
-
// Run
|
|
43
|
+
// Run code + lib + note searches, merge, sort by score, apply limit
|
|
41
44
|
const codeRows = searchSymbols(db, params.query, params.kind, limit);
|
|
42
45
|
const libRows = searchLibSymbols(db, params.query, params.kind, limit) as unknown as QueryResultRow[];
|
|
46
|
+
const noteRows = searchNotes(db, params.query, params.kind as NoteKind | undefined, limit * 2) as unknown as QueryResultRow[];
|
|
43
47
|
|
|
44
48
|
// Merge and sort by score ascending (lower bm25 = better match)
|
|
45
|
-
const merged: QueryResultRow[] = [...codeRows, ...libRows];
|
|
49
|
+
const merged: QueryResultRow[] = [...codeRows, ...libRows, ...noteRows];
|
|
46
50
|
merged.sort((a, b) => a.score - b.score);
|
|
47
51
|
rows = merged.slice(0, limit);
|
|
48
52
|
} else {
|
package/src/types.ts
CHANGED
|
@@ -64,6 +64,19 @@ export interface CardHead {
|
|
|
64
64
|
summary: string;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/** Note kind discriminator for bridge cards. */
|
|
68
|
+
export type NoteKind = "glossary" | "decision";
|
|
69
|
+
|
|
70
|
+
/** A glossary/decision note (bridge card) for conceptual knowledge. */
|
|
71
|
+
export interface Note {
|
|
72
|
+
note_kind: NoteKind;
|
|
73
|
+
title: string;
|
|
74
|
+
body: string;
|
|
75
|
+
tags: string;
|
|
76
|
+
related: string;
|
|
77
|
+
card_path: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
67
80
|
/** A single row returned from a query. */
|
|
68
81
|
export interface QueryResultRow {
|
|
69
82
|
name: string;
|
|
@@ -75,10 +88,13 @@ export interface QueryResultRow {
|
|
|
75
88
|
summary: string;
|
|
76
89
|
score: number;
|
|
77
90
|
id: number;
|
|
78
|
-
/** Origin fields — code rows omit these; lib rows set them. */
|
|
79
|
-
source?: "code" | "lib";
|
|
91
|
+
/** Origin fields — code rows omit these; lib / note rows set them. */
|
|
92
|
+
source?: "code" | "lib" | "note";
|
|
80
93
|
lib?: string;
|
|
81
94
|
version?: string;
|
|
95
|
+
/** Note-specific fields — only for source === "note" rows. */
|
|
96
|
+
note_kind?: NoteKind;
|
|
97
|
+
tags?: string;
|
|
82
98
|
}
|
|
83
99
|
|
|
84
100
|
/** The full result of a query, including staleness info. */
|