feat(research): merge repository research and tune QMD search coverage
Research skills: - Merge repository-research into research as a Repository section, so an open repository search loads one skill fewer; move its evals and update every reference. - Tune semantic-search for QMD: one question per search, known domain terms in the query, --top-k 10 for survey questions, a small-repository exception, and a Coverage section stating what the index skips. QMD search: - Widen the index file mask to web templates and styles, .NET and WPF markup and project files, JVM build files, and more script modules, and reapply it to existing repository collections. - Add qmd-search.mjs --get to read qmd:// hits from other collections. - List the exact search command in the Claude sandbox excludedCommands, because the macOS/Linux sandbox blocks the localhost daemon and the index under the home directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
82d9992b3a
commit
eb7cecaaa2
18 files changed
+142
-95
No files matched your search
@@ -33,10 +33,12 @@ export function unsetModels(text, YAML) {
|
||||
}
|
||||
|
||||
// Returns the new text, or null when index.yml has no such collection (QMD's write-through always creates it).
|
||||
export function setCollectionIgnore(text, YAML, name, ignore) {
|
||||
// A pattern also refreshes collections created with an older file mask.
|
||||
export function setCollectionIgnore(text, YAML, name, ignore, pattern) {
|
||||
const document = YAML.parseDocument(text || '');
|
||||
if (document.errors.length) throw new Error(`index.yml cannot be parsed: ${document.errors[0].message}`);
|
||||
if (!document.hasIn(['collections', name])) return null;
|
||||
if (pattern) document.setIn(['collections', name, 'pattern'], pattern);
|
||||
if (ignore.length) document.setIn(['collections', name, 'ignore'], document.createNode(ignore));
|
||||
else document.deleteIn(['collections', name, 'ignore']);
|
||||
return document.toString();
|
||||
|
||||
@@ -242,7 +242,7 @@ async function main() {
|
||||
persistIgnore: async (name, ignore) => {
|
||||
const path = qmdConfigPath();
|
||||
const text = existsSync(path) ? readFileSync(path, 'utf8') : '';
|
||||
const next = setCollectionIgnore(text, YAML, name, ignore);
|
||||
const next = setCollectionIgnore(text, YAML, name, ignore, MASK);
|
||||
if (next === null) return; // never re-sync without the collection: the sync would delete it from SQLite
|
||||
if (next !== text) writeTextAtomic(path, next);
|
||||
syncConfigToDb(store.internal.db, loadConfig());
|
||||
|
||||
@@ -12,7 +12,9 @@ export const MODELS = {
|
||||
rerank: 'hf:giladgd/Qwen3-Reranker-4B-GGUF/Qwen3-Reranker-4B.Q4_K_M.gguf',
|
||||
generate: 'hf:tobil/qmd-query-expansion-1.7B-gguf/qmd-query-expansion-1.7B-q4_k_m.gguf',
|
||||
};
|
||||
export const MASK = '**/*.{md,py,cs,ts,tsx,js,jsx,mjs,go,rs,java,ps1,sh,json,yml,yaml,xml,sql}';
|
||||
// Covers the stacks with rules in this configuration: web templates and styles, .NET and WPF markup and projects, and JVM builds.
|
||||
export const MASK = '**/*.{md,py,cs,ts,tsx,mts,cts,js,jsx,mjs,cjs,go,rs,java,kt,kts,ps1,sh,json,yml,yaml,toml,xml,sql,'
|
||||
+ 'html,css,scss,xaml,razor,cshtml,csproj,props,targets,gradle,properties}';
|
||||
|
||||
export function collectionName(repoPath) {
|
||||
return 'repo-' + createHash('sha256').update(resolve(repoPath), 'utf8').digest('hex').slice(0, 12);
|
||||
|
||||
@@ -88,12 +88,22 @@ export async function runSearch({ root, query, topK, daemon = callDaemon, startD
|
||||
}
|
||||
}
|
||||
|
||||
// Hits from the user's own collections are qmd:// URIs, which only QMD can resolve to a file; no model is loaded.
|
||||
export function getDocument(uri, cli = runQmdCli) {
|
||||
if (!/^qmd:\/\/[^/]+\/.+/.test(uri)) throw new Error('--get needs a qmd://<collection>/<path> URI');
|
||||
return cli(['get', uri], { windowsHide: true });
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const { values } = parseArgs({ options: { query: { type: 'string' }, 'top-k': { type: 'string', default: '5' }, root: { type: 'string' }, stop: { type: 'boolean' } } });
|
||||
const { values } = parseArgs({ options: { query: { type: 'string' }, 'top-k': { type: 'string', default: '5' }, root: { type: 'string' }, stop: { type: 'boolean' }, get: { type: 'string' } } });
|
||||
if (values.stop) {
|
||||
try { await callDaemon('/stop', {}); } catch { /* nothing running */ }
|
||||
return;
|
||||
}
|
||||
if (values.get !== undefined) {
|
||||
process.stdout.write(getDocument(values.get));
|
||||
return;
|
||||
}
|
||||
if (!values.query?.trim()) throw new Error('--query is required');
|
||||
const root = resolve(values.root || execFileSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf8' }).trim());
|
||||
const topK = Math.min(Math.max(Number(values['top-k']) || 5, 1), 20);
|
||||
|
||||
Reference in new issue
Block a user