chore: remove cli qmd support

This commit is contained in:
Tienson Qin
2026-05-22 23:13:15 +08:00
committed by GitHub
parent b22fa0c1bc
commit d3518ae3e7
15 changed files with 120 additions and 3048 deletions

View File

@@ -610,108 +610,6 @@
:search ["--content"]}},
:tags [:upsert :search],
:extends :non-sync/graph-json-env}
{:id "qmd-and-qsearch-json",
:setup
["python3 - <<'PY'\nimport base64, pathlib\np = pathlib.Path('{{tmp-dir}}/fake-bin/qmd')\np.parent.mkdir(parents=True, exist_ok=True)\np.write_bytes(base64.b64decode('IyEvdXNyL2Jpbi9lbnYgcHl0aG9uMwppbXBvcnQganNvbgppbXBvcnQgb3MKaW1wb3J0IHBhdGhsaWIKaW1wb3J0IHJlCmltcG9ydCBzeXMKCmFyZ3MgPSBzeXMuYXJndlsxOl0Kc3RhdGUgPSBwYXRobGliLlBhdGgob3MuZW52aXJvblsnUU1EX0ZBS0VfU1RBVEUnXSkKCmlmIGFyZ3MgPT0gWyctLWhlbHAnXToKICAgIHByaW50KCdxbWQgaGVscCcpCiAgICBzeXMuZXhpdCgwKQoKaWYgYXJnc1s6Ml0gPT0gWydjb2xsZWN0aW9uJywgJ3Nob3cnXToKICAgIGlmIG5vdCBzdGF0ZS5leGlzdHMoKToKICAgICAgICBwcmludCgnQ29sbGVjdGlvbiBub3QgZm91bmQnLCBmaWxlPXN5cy5zdGRlcnIpCiAgICAgICAgc3lzLmV4aXQoMSkKICAgIHByaW50KCdDb2xsZWN0aW9uOiAnICsgYXJnc1syXSkKICAgIHByaW50KCcgIFBhdGg6ICAgICAnICsgc3RhdGUucmVhZF90ZXh0KCkuc3RyaXAoKSkKICAgIHByaW50KCcgIFBhdHRlcm46ICAqKi8qLm1kJykKICAgIHN5cy5leGl0KDApCgppZiBhcmdzWzoyXSA9PSBbJ2NvbGxlY3Rpb24nLCAnYWRkJ106CiAgICBzdGF0ZS53cml0ZV90ZXh0KGFyZ3NbMl0pCiAgICBwcmludCgnY3JlYXRlZCcpCiAgICBzeXMuZXhpdCgwKQoKaWYgYXJnc1s6MV0gPT0gWydlbWJlZCddOgogICAgcHJpbnQoJ2VtYmVkZGVkJykKICAgIHN5cy5leGl0KDApCgppZiBhcmdzWzoxXSA9PSBbJ3VwZGF0ZSddOgogICAgcHJpbnQoJ3VwZGF0ZWQnKQogICAgc3lzLmV4aXQoMCkKCmlmIGFyZ3NbOjFdID09IFsncXVlcnknXToKICAgIHJvb3QgPSBwYXRobGliLlBhdGgoc3RhdGUucmVhZF90ZXh0KCkuc3RyaXAoKSkKICAgIHJvd3MgPSBbXQogICAgZm9yIHBhdGggaW4gcm9vdC5yZ2xvYignKi5tZCcpOgogICAgICAgIHRleHQgPSBwYXRoLnJlYWRfdGV4dChlbmNvZGluZz0ndXRmOCcpCiAgICAgICAgbWF0Y2ggPSByZS5zZWFyY2gocic8IS0tIGlkOiAoXGQrKSAtLT4nLCB0ZXh0KQogICAgICAgIGlmIG1hdGNoOgogICAgICAgICAgICByb3dzLmFwcGVuZCh7CiAgICAgICAgICAgICAgICAnc2NvcmUnOiAxLAogICAgICAgICAgICAgICAgJ2ZpbGUnOiAncW1kOi8vY3VzdG9tLycgKyBwYXRoLm5hbWUsCiAgICAgICAgICAgICAgICAnc25pcHBldCc6ICctIHFtZCB0YXJnZXQgPCEtLSBpZDogJyArIG1hdGNoLmdyb3VwKDEpICsgJyAtLT4nLAogICAgICAgICAgICB9KQogICAgICAgICAgICBicmVhawogICAgcHJpbnQoanNvbi5kdW1wcyhyb3dzKSkKICAgIHN5cy5leGl0KDApCgpwcmludCgndW5leHBlY3RlZCBhcmdzOiAnICsgcmVwcihhcmdzKSwgZmlsZT1zeXMuc3RkZXJyKQpzeXMuZXhpdCgyKQo='))\np.chmod(0o755)\nPY"
"{{cli}} --root-dir {{root-dir-arg}} --config {{config-path-arg}} --output json upsert block --graph {{graph-arg}} --target-page QmdSearchPage --content \"qmd target\" >/dev/null"],
:cmds
["QMD_FAKE_STATE={{tmp-dir-arg}}/qmd-state PATH={{tmp-dir-arg}}/fake-bin:$PATH {{cli}} --root-dir {{root-dir-arg}} --config {{config-path-arg}} --output json qmd --graph {{graph-arg}}"
"QMD_FAKE_STATE={{tmp-dir-arg}}/qmd-state PATH={{tmp-dir-arg}}/fake-bin:$PATH {{cli}} --root-dir {{root-dir-arg}} --config {{config-path-arg}} --output json qsearch qmd target --graph {{graph-arg}} --no-rerank"],
:expect
{:exit 0,
:stdout-json-paths {[:status] "ok"},
:stdout-contains ["qmd target"]},
:covers
{:commands ["qmd" "qsearch"],
:options
{:global ["--config" "--graph" "--root-dir" "--output"],
:qmd []
:qsearch ["--no-rerank"]}},
:tags [:qmd :search],
:extends :non-sync/graph-json-env}
{:id "qmd-and-qsearch-human-page-groups",
:setup
["python3 - <<'PY'
import pathlib
p = pathlib.Path('{{tmp-dir}}/fake-bin/qmd')
p.parent.mkdir(parents=True, exist_ok=True)
p.write_text(r'''#!/usr/bin/env python3
import json
import os
import pathlib
import re
import sys
args = sys.argv[1:]
state = pathlib.Path(os.environ['QMD_FAKE_STATE'])
if args == ['--help']:
print('qmd help')
sys.exit(0)
if args[:2] == ['collection', 'show']:
if not state.exists():
print('Collection not found', file=sys.stderr)
sys.exit(1)
print('Collection: ' + args[2])
print(' Path: ' + state.read_text().strip())
print(' Pattern: **/*.md')
sys.exit(0)
if args[:2] == ['collection', 'add']:
state.write_text(args[2])
print('created')
sys.exit(0)
if args[:1] == ['embed']:
print('embedded')
sys.exit(0)
if args[:1] == ['update']:
print('updated')
sys.exit(0)
if args[:1] == ['query']:
root = pathlib.Path(state.read_text().strip())
rows = []
for path in sorted(root.rglob('*.md')):
text = path.read_text(encoding='utf8')
match = re.search(r'<!-- id: (\\d+) -->', text)
if match:
rows.append({
'score': 1,
'file': 'qmd://custom/' + path.name,
'snippet': '- qmd target <!-- id: ' + match.group(1) + ' -->',
})
break
print(json.dumps(rows))
sys.exit(0)
print('unexpected args: ' + repr(args), file=sys.stderr)
sys.exit(2)
''')
p.chmod(0o755)
PY"
"{{cli}} --root-dir {{root-dir-arg}} --config {{config-path-arg}} --output json upsert tag --graph {{graph-arg}} --name QmdHumanTag >/dev/null"
"{{cli}} --root-dir {{root-dir-arg}} --config {{config-path-arg}} --output json upsert property --graph {{graph-arg}} --name qmd-human-prop --public true >/dev/null"
"{{cli}} --root-dir {{root-dir-arg}} --config {{config-path-arg}} --output json upsert block --graph {{graph-arg}} --target-page QmdHumanPage --content \"qmd target\" --update-tags '[\"QmdHumanTag\"]' --update-properties '{:qmd-human-prop \"rich value\"}' >/dev/null"],
:cmds
["QMD_FAKE_STATE={{tmp-dir-arg}}/qmd-human-state PATH={{tmp-dir-arg}}/fake-bin:$PATH {{cli}} --root-dir {{root-dir-arg}} --config {{config-path-arg}} --output json qmd --graph {{graph-arg}} >/dev/null"
"{{cli}} --root-dir {{root-dir-arg}} --config {{config-path-arg}} --output json graph switch --graph {{graph-arg}} >/dev/null"
"QMD_FAKE_STATE={{tmp-dir-arg}}/qmd-human-state PATH={{tmp-dir-arg}}/fake-bin:$PATH {{cli}} --root-dir {{root-dir-arg}} --config {{config-path-arg}} --output human qsearch qmd target --no-rerank"],
:expect
{:exit 0,
:stdout-contains ["QmdHumanPage" "qmd target #QmdHumanTag" "qmd-human-prop: rich value" "└──"],
:stdout-not-contains ["QmdHumanPage (1 match)" "PAGE-TITLE" "Count:"]},
:covers
{:commands ["upsert tag" "upsert property" "qmd" "graph switch" "qsearch"],
:options
{:global ["--config" "--graph" "--root-dir" "--output"],
:upsert ["--name" "--target-page" "--content" "--update-tags" "--update-properties"],
:qmd []
:qsearch ["--no-rerank"]}},
:tags [:qmd :search],
:extends :non-sync/graph-json-env}
{:id "search-page-json",
:setup
["{{cli}} --root-dir {{root-dir-arg}} --config {{config-path-arg}} --output json upsert page --graph {{graph-arg}} --page SearchPageTarget >/dev/null"],