botholomew 0.8.1 → 0.8.2
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/package.json +1 -1
- package/src/db/context.ts +16 -4
package/package.json
CHANGED
package/src/db/context.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolve as resolvePath } from "node:path";
|
|
1
2
|
import type { DbConnection } from "./connection.ts";
|
|
2
3
|
import { buildSetClauses, buildWhereClause, sanitizeInt } from "./query.ts";
|
|
3
4
|
import { isUuid, uuidv7 } from "./uuid.ts";
|
|
@@ -193,15 +194,26 @@ export async function getContextItemBySourcePath(
|
|
|
193
194
|
}
|
|
194
195
|
|
|
195
196
|
/**
|
|
196
|
-
* Look up a context item by UUID
|
|
197
|
+
* Look up a context item by UUID, `context_path`, or `source_path`.
|
|
198
|
+
*
|
|
199
|
+
* `source_path` fallbacks let users pass the same argument they used for
|
|
200
|
+
* `context add` (e.g. a bare `README.md`) to management commands like
|
|
201
|
+
* `context refresh` / `context chunks`. Relative file paths are resolved
|
|
202
|
+
* against `process.cwd()` to match the absolute `source_path` stored on add.
|
|
197
203
|
*/
|
|
198
204
|
export async function resolveContextItem(
|
|
199
205
|
db: DbConnection,
|
|
200
206
|
pathOrId: string,
|
|
201
207
|
): Promise<ContextItem | null> {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
208
|
+
if (isUuid(pathOrId)) return getContextItem(db, pathOrId);
|
|
209
|
+
|
|
210
|
+
const byContextPath = await getContextItemByPath(db, pathOrId);
|
|
211
|
+
if (byContextPath) return byContextPath;
|
|
212
|
+
|
|
213
|
+
const byUrl = await getContextItemBySourcePath(db, pathOrId, "url");
|
|
214
|
+
if (byUrl) return byUrl;
|
|
215
|
+
|
|
216
|
+
return getContextItemBySourcePath(db, resolvePath(pathOrId), "file");
|
|
205
217
|
}
|
|
206
218
|
|
|
207
219
|
/**
|