Skip to content

release: 0.3.5 — codemap recall <query> CLI (P3-1, half 1)#16

Merged
qxbyte merged 1 commit into
mainfrom
feat/recall-cli
Jun 26, 2026
Merged

release: 0.3.5 — codemap recall <query> CLI (P3-1, half 1)#16
qxbyte merged 1 commit into
mainfrom
feat/recall-cli

Conversation

@qxbyte

@qxbyte qxbyte commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • New codemap recall '<query>' CLI in codemap-aimemory that token-matches the user's request against <project>/.ai-memory/knowledge/*.yml and returns the top-K most relevant knowledge.
  • Designed to be called by specode at the start of the requirements phase so the spec author sees prior rules / cases / pitfalls before writing.
  • Lockstep version bump 0.3.4 → 0.3.5 across all 20 packages.

Why

AI-Enterprise-Delivery-System roadmap P3-1: "Agent terminally becomes like an old employee." Until now .ai-memory/knowledge/ was write-only — the data was there but no one queried it. This PR adds the query CLI. The pluginhub-side companion PR wires specode to actually call it.

This is P3-1 half 1. Half 2 (the specode SKILL.md change to invoke this CLI) lands in pluginhub next.

Usage

codemap recall '新增优惠券互斥规则' --top-k 3 --types rules,pitfalls

Output (yaml default):

query: 新增优惠券互斥规则
tokens: [优惠, 互斥, 券规, 惠券, 新增, 规则]
matched_entities:
  - rule-coupon-mutex
knowledge:
  - knowledge_id: rule-coupon-mutex
    type: business_rule
    category: rules
    title: 优惠券和积分不能同时使用
    summary: 避免用户双重优惠导致亏损
    score: 7
    file: .ai-memory/knowledge/rules/rule-coupon-mutex.yml

Algorithm (v1, no embeddings)

  • Tokenize: English/digit words ≥ 2 chars + Chinese char-bigrams (zero external deps).
  • Score = sum of token hits in searchable fields (title / tags / statement / related_code / fix / symptom / …); title hits weighted ×2.
  • Sort by score desc, secondary by knowledge_id (stable).
  • Malformed yml silently skipped — a hand-edited knowledge file never crashes the build.

Embeddings + freshness reranking land in P1-3 / P4-1 respectively.

Test plan

  • pytest plugins/codemap-aimemory/tests/115 passed (97 → 115; 18 new in test_recall.py)
  • root pytest tests/ — 297 passed
  • codemap recall --help shows the new subcommand after pip install -e
  • ruff check + ruff format --check + mypy clean
  • CI green → merge → tag v0.3.5 → publish workflow uploads 20 packages

Roadmap progress

After this PR: P0-1/P0-2/P0-3/P0-3-follow-up/P1-2/P3-1 half 1 shipped. Next: pluginhub PR wires specode requirements phase to call codemap recall.

🤖 Generated with Claude Code

Lockstep version bump 0.3.4 → 0.3.5 across all 20 packages; the only
source change is in codemap-aimemory. First half of the AI-Enterprise-
Delivery-System roadmap P3-1: a deterministic recall CLI that lets
downstream tools (specode, custom Agents) pull relevant knowledge from
.ai-memory/ before drafting requirements.

New 'codemap recall' subcommand:

  codemap recall '<query>' [--project <abs>] [--top-k N]
                            [--types rules,cases,...] [-o yaml|json]

Scans <project>/.ai-memory/knowledge/{rules,business,modules,cases,
pitfalls}/*.yml and ranks by token overlap with each yml's searchable
fields (title / tags / statement / related_code / fix / symptom / ...).
Title hits weighted higher than body hits.

Tokenizer is dependency-free: English/digit words >= 2 chars plus
Chinese char-bigrams. Good enough for the few-word query that shows up
at the requirements stage; embeddings land in P1-3.

Output (yaml or json) carries:
  - query (original)
  - tokens (parsed)
  - matched_entities (id-based hits against _global/entities.yml)
  - knowledge (top-K rows with knowledge_id / type / category / title
    / summary / score / file path)

Registered through the codemap.cli_commands entry-point group, same
mechanism as 'enrich' and 'llm'. Without codemap-aimemory installed
the subcommand simply isn't there.

Tests: 18 new in test_recall.py cover tokenizer edge cases (English /
Chinese / mixed / empty), ranking, top-k, type filter, title weight,
related_code / symptom / fix matching, malformed yml graceful skip,
matched_entities, and full output shape. Aimemory plugin: 97 -> 115.
Root and other plugins unchanged.

The companion change in pluginhub extends specode's requirements
phase to call 'codemap recall' and inject the top hits into the
"已知约束 / 历史坑" section — closing the P3-1 loop end-to-end.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: qxbyte <qiang_xue0@outlook.com>
@pronto-qxbyte

pronto-qxbyte Bot commented Jun 26, 2026

Copy link
Copy Markdown

PRonto 评审

PR: #16 release: 0.3.5 — codemap recall CLI (P3-1, half 1)
作者: @qxbyte
分支: feat/recall-cli -> main

概览

新 recall.py 实现 token-based 知识召回,代码清晰,无明显问题。

问题清单

  • ✅ 未发现明显问题

建议改进

  • 建议补充 recall 函数的单元测试覆盖核心评分逻辑

本评审由 PRonto 经 DeepSeek 生成

@qxbyte qxbyte merged commit a501b71 into main Jun 26, 2026
8 of 9 checks passed
@qxbyte qxbyte deleted the feat/recall-cli branch June 26, 2026 01:21
qxbyte added a commit that referenced this pull request Jun 28, 2026
试跑发现的 3 个 onboarding 痛点一起修,都在 cli.py 加 echo + 2 个 helper:

🟢 v0.9 #15: codemap embed 首次跑(未走 install)静默下 1.2GB 模型
  - 检测 config 不存在 + 默认走 local backend + 模型未 cache → echo
    "First-time embed... will download ~1.2GB" + 给两个 alternative
    (`embed install` / `backend set --provider qwen`)
  - 已存在 config 或模型已 cache → 不啰嗦

🟢 v0.9 #16: HF Hub 大陆超时无镜像提示
  - 同样首次跑分支下,HF_ENDPOINT 未设 → echo CN mirror workaround:
    `export HF_ENDPOINT=https://hf-mirror.com` + HF_TOKEN
  - 用户已设 HF_ENDPOINT → 不啰嗦

🟢 v0.9 #5: codemap embed 空 knowledge-base 提示太隐晦
  - result.n_total==0 时按 3 种 case 分别 echo:
    a) knowledge-base/ 不存在 → "normal for fresh project, run distill/swarm first"
    b) 存在但 0 个 .md → "exists but has no .md files"
    c) 有 .md 但切出 0 chunks → "unusual, check heading/size"

新增 helper:
  _model_cached(model_id) — 探 ~/.cache/huggingface/hub
  _emit_first_run_hints(cfg) — #15+#16 一体
  _emit_zero_chunks_hint(project_root) — #5

6 regression tests in tests/test_cli_onboarding_hints.py:
  * 首次跑 + 模型未 cache → 1.2GB hint emitted
  * 同上 + HF_ENDPOINT 未设 → hf-mirror hint emitted
  * 已设 HF_ENDPOINT → 不 emit hint
  * config 存在 → 不 emit hint
  * 空 KB dir 不存在 → distill/swarm hint
  * 空 KB dir 存在但无 .md → "no .md files" hint

81/81 plugin tests pass,ruff/format/mypy clean.

No version bump in this PR — lead agent merges and bumps with phase 4 release.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
qxbyte added a commit that referenced this pull request Jun 28, 2026
First plugin-only release using the new tag suffix support (publish.yml
regex updated in 0.4.6 / PR #33). Lockstep 20 packages unchanged at
0.4.6 — no noop bump needed.

semantic-index 0.2.1 → 0.2.2 ships:
  v0.9 痛点 #5  (empty KB hint)
  v0.9 痛点 #15 (first-run download warn)
  v0.9 痛点 #16 (CN HF mirror hint)
  + INSTALL.md / INSTALL.zh-CN.md HF mirror onboarding doc

All from merged PR #35 (now on main).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: qxbyte <qiang_xue0@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant