- Make structured `qmd query` with intent:/lex:/vec:/hyde: the default search mode, and emphasize that the caller authors the expansion rather than leaning on the built-in query-expansion model. - Tell the caller to cite the #docid and exact line numbers now printed by get/multi-get, and to slice files with the :from:count suffix or --from/-l instead of piping through sed/head/tail. - Document --full-path for handing the on-disk path to editor tools. - Bump skill version to 2.2.0 and record the behavior changes under ## [Unreleased] in CHANGELOG.md. - Update the package smoke test that pinned the old 'structured queries' wording to match the new, more specific intro phrasing.
72 lines
3.8 KiB
TypeScript
72 lines
3.8 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
import { readFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
|
|
const root = new URL("..", import.meta.url);
|
|
const pkg = JSON.parse(readFileSync(new URL("package.json", root), "utf8"));
|
|
|
|
describe("package test task", () => {
|
|
test("runs typecheck, unit tests, and package smoke checks", () => {
|
|
expect(pkg.scripts.test).toContain("scripts/test-all.mjs");
|
|
|
|
expect(pkg.scripts["test:types"]).toContain("tsconfig.build.json --noEmit");
|
|
expect(pkg.scripts["test:unit"]).toContain("vitest.mjs");
|
|
expect(pkg.scripts["test:unit"]).toContain("bun test");
|
|
expect(pkg.scripts["test:unit"]).toContain("CI=true");
|
|
|
|
expect(pkg.scripts["test:package"]).toContain("scripts/package-smoke.mjs");
|
|
|
|
const testAllScript = readFileSync(new URL("scripts/test-all.mjs", root), "utf8");
|
|
expect(testAllScript).toContain("TypeScript build typecheck");
|
|
expect(testAllScript).toContain("Vitest suite under Node");
|
|
expect(testAllScript).toContain("Bun test suite");
|
|
expect(testAllScript).toContain("Package smoke");
|
|
|
|
const packageSmokeScript = readFileSync(new URL("scripts/package-smoke.mjs", root), "utf8");
|
|
expect(packageSmokeScript).toContain("scripts/build.mjs");
|
|
expect(packageSmokeScript).toContain("scripts/check-package-grammars.mjs");
|
|
expect(packageSmokeScript).toContain("compiled CLI under Node");
|
|
expect(packageSmokeScript).toContain("compiled CLI under Bun");
|
|
expect(packageSmokeScript).toContain("package wrapper");
|
|
});
|
|
});
|
|
|
|
describe("package grammar distribution", () => {
|
|
test("installs AST grammar wasm packages as required runtime dependencies", () => {
|
|
for (const dep of ["tree-sitter-typescript", "tree-sitter-python", "tree-sitter-go", "tree-sitter-rust"]) {
|
|
expect(pkg.dependencies, `${dep} should be a required dependency`).toHaveProperty(dep);
|
|
expect(pkg.optionalDependencies ?? {}, `${dep} should not be optional`).not.toHaveProperty(dep);
|
|
}
|
|
});
|
|
|
|
test("documents a packaging smoke check for grammar wasm availability", () => {
|
|
expect(pkg.scripts, "package.json scripts").toHaveProperty("smoke:package-grammars");
|
|
expect(String(pkg.scripts["smoke:package-grammars"])).toContain("check-package-grammars");
|
|
|
|
expect(pkg.files, "published package files").toContain("scripts/build.mjs");
|
|
expect(pkg.files, "published package files").toContain("scripts/check-package-grammars.mjs");
|
|
expect(pkg.files, "published package files").toContain("scripts/package-smoke.mjs");
|
|
expect(pkg.files, "published package files").toContain("scripts/test-all.mjs");
|
|
expect(pkg.files, "published package files").toContain("skills/");
|
|
const qmdSkill = readFileSync(new URL("skills/qmd/SKILL.md", root), "utf8");
|
|
expect(qmdSkill).toContain("# QMD - Query Markdown Documents");
|
|
expect(qmdSkill).toContain("## How search works");
|
|
expect(qmdSkill).toContain("## MCP Tool: `query`");
|
|
expect(qmdSkill).not.toContain("This file is a discovery stub");
|
|
|
|
const firstSixtyLines = qmdSkill.split(/\r?\n/).slice(0, 60).join("\n");
|
|
expect(firstSixtyLines).toContain("Search for candidate documents");
|
|
expect(firstSixtyLines).toContain("qmd search");
|
|
expect(firstSixtyLines).toContain('qmd multi-get "#abc123,#def432"');
|
|
expect(firstSixtyLines).toContain("Retrieved:");
|
|
expect(firstSixtyLines).toContain("qmd query");
|
|
// The skill must teach structured, self-authored queries near the top.
|
|
expect(firstSixtyLines).toContain("Default to structured");
|
|
|
|
const scriptPath = join(root.pathname, "scripts", "check-package-grammars.mjs");
|
|
const script = readFileSync(scriptPath, "utf8");
|
|
expect(script).toContain("tree-sitter-typescript/tree-sitter-typescript.wasm");
|
|
expect(script).toContain("tree-sitter-typescript/tree-sitter-tsx.wasm");
|
|
});
|
|
});
|