@voidwire/lore 0.1.13 → 0.1.14
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/cli.ts +4 -1
- package/lib/list.ts +30 -6
- package/package.json +1 -1
package/cli.ts
CHANGED
|
@@ -318,9 +318,10 @@ function handleList(args: string[]): void {
|
|
|
318
318
|
? parseInt(parsed.get("limit")!, 10)
|
|
319
319
|
: undefined;
|
|
320
320
|
const format = parsed.get("format") || "json";
|
|
321
|
+
const project = parsed.get("project");
|
|
321
322
|
|
|
322
323
|
try {
|
|
323
|
-
const result = list(domain, { limit });
|
|
324
|
+
const result = list(domain, { limit, project });
|
|
324
325
|
|
|
325
326
|
if (format === "human") {
|
|
326
327
|
console.log(formatHumanOutput(result));
|
|
@@ -682,6 +683,7 @@ Usage:
|
|
|
682
683
|
Options:
|
|
683
684
|
--limit <n> Maximum entries (default: all)
|
|
684
685
|
--format <fmt> Output format: json (default), jsonl, human
|
|
686
|
+
--project <name> Filter by project name
|
|
685
687
|
--domains List available domains
|
|
686
688
|
--help Show this help
|
|
687
689
|
|
|
@@ -707,6 +709,7 @@ Available Domains:
|
|
|
707
709
|
Examples:
|
|
708
710
|
lore list development
|
|
709
711
|
lore list commits --limit 10 --format human
|
|
712
|
+
lore list commits --project=momentum --limit 5
|
|
710
713
|
lore list books --format jsonl
|
|
711
714
|
`);
|
|
712
715
|
process.exit(0);
|
package/lib/list.ts
CHANGED
|
@@ -59,8 +59,18 @@ const PERSONAL_SUBTYPES: Partial<Record<Domain, string>> = {
|
|
|
59
59
|
habits: "habit",
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
+
// Maps source to metadata field containing project name
|
|
63
|
+
const PROJECT_FIELD: Record<string, string> = {
|
|
64
|
+
commits: "project",
|
|
65
|
+
sessions: "project",
|
|
66
|
+
tasks: "project",
|
|
67
|
+
captures: "context",
|
|
68
|
+
teachings: "source",
|
|
69
|
+
};
|
|
70
|
+
|
|
62
71
|
export interface ListOptions {
|
|
63
72
|
limit?: number;
|
|
73
|
+
project?: string;
|
|
64
74
|
}
|
|
65
75
|
|
|
66
76
|
export interface ListEntry {
|
|
@@ -93,13 +103,27 @@ function queryBySource(
|
|
|
93
103
|
db: Database,
|
|
94
104
|
source: string,
|
|
95
105
|
limit?: number,
|
|
106
|
+
project?: string,
|
|
96
107
|
): ListEntry[] {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
108
|
+
let sql = "SELECT title, content, metadata FROM search WHERE source = ?";
|
|
109
|
+
const params: (string | number)[] = [source];
|
|
110
|
+
|
|
111
|
+
// Add project filter if provided and source has a project field
|
|
112
|
+
if (project) {
|
|
113
|
+
const field = PROJECT_FIELD[source];
|
|
114
|
+
if (field) {
|
|
115
|
+
sql += ` AND json_extract(metadata, '$.${field}') = ?`;
|
|
116
|
+
params.push(project);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (limit) {
|
|
121
|
+
sql += " LIMIT ?";
|
|
122
|
+
params.push(limit);
|
|
123
|
+
}
|
|
100
124
|
|
|
101
|
-
const stmt =
|
|
102
|
-
const rows =
|
|
125
|
+
const stmt = db.prepare(sql);
|
|
126
|
+
const rows = stmt.all(...params) as RawRow[];
|
|
103
127
|
|
|
104
128
|
return rows.map((row) => ({
|
|
105
129
|
title: row.title,
|
|
@@ -166,7 +190,7 @@ export function list(domain: Domain, options: ListOptions = {}): ListResult {
|
|
|
166
190
|
if (personalType) {
|
|
167
191
|
entries = queryPersonalType(db, personalType, options.limit);
|
|
168
192
|
} else {
|
|
169
|
-
entries = queryBySource(db, domain, options.limit);
|
|
193
|
+
entries = queryBySource(db, domain, options.limit, options.project);
|
|
170
194
|
}
|
|
171
195
|
|
|
172
196
|
return {
|