@ia-ccun/code-agent-cli 0.0.52 → 0.0.54-beta.1
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/config/agent/bin/README.md +102 -0
- package/config/agent/bin/fd.exe +0 -0
- package/config/agent/bin/rg.exe +0 -0
- package/config/agent/extensions/aicode-advisor.ts +13 -0
- package/config/agent/extensions/aicode-btw.ts +66 -14
- package/config/agent/extensions/aicode-cd.ts +834 -0
- package/config/agent/extensions/aicode-filter-outputs.ts +131 -0
- package/config/agent/extensions/aicode-grillMe.ts +198 -0
- package/config/agent/extensions/aicode-pets.ts +362 -0
- package/config/agent/extensions/aicode-safety-guard.ts +552 -0
- package/config/agent/extensions/aicode-snake.ts +354 -0
- package/config/agent/extensions/aicode-tips.ts +70 -16
- package/config/agent/extensions/aicode-todo-progress.ts +547 -0
- package/config/agent/extensions/custom.ts +93 -95
- package/config/agent/extensions/error-monitor.ts +1 -18
- package/config/agent/extensions/ponytail.ts +441 -0
- package/config/agent/extensions/tps.ts +87 -0
- package/config/agent/extensions/working-msg.ts +165 -50
- package/config/agent/help.md +0 -7
- package/config/agent/models.json +7 -7
- package/config/agent/settings.json +16 -16
- package/config/agent/skills/chroma/LICENSE +21 -0
- package/config/agent/skills/chroma/chroma-local/SKILL.md +165 -0
- package/config/agent/skills/chroma/chroma-local/cli.md +48 -0
- package/config/agent/skills/chroma/chroma-local/data-model.md +103 -0
- package/config/agent/skills/chroma/chroma-local/error-handling/python.md +166 -0
- package/config/agent/skills/chroma/chroma-local/error-handling/typescript.md +231 -0
- package/config/agent/skills/chroma/chroma-local/local-chroma/python.md +95 -0
- package/config/agent/skills/chroma/chroma-local/local-chroma/typescript.md +101 -0
- package/config/agent/skills/chroma/chroma-local/metadata/python.md +154 -0
- package/config/agent/skills/chroma/chroma-local/metadata/typescript.md +153 -0
- package/config/agent/skills/chroma/chroma-local/querying/python.md +147 -0
- package/config/agent/skills/chroma/chroma-local/querying/typescript.md +157 -0
- package/config/agent/skills/chroma/chroma-local/regex/python.md +69 -0
- package/config/agent/skills/chroma/chroma-local/regex/typescript.md +71 -0
- package/config/agent/skills/chroma/chroma-local/understanding-a-codebase.md +80 -0
- package/config/agent/skills/chroma/chroma-local/updating-deleting/python.md +159 -0
- package/config/agent/skills/chroma/chroma-local/updating-deleting/typescript.md +228 -0
- package/config/agent/skills/hello/SKILL.md +1 -1
- package/config/agent/skills/ponytail/SKILL.md +100 -0
- package/config/agent/skills/ponytail-audit/SKILL.md +40 -0
- package/config/agent/skills/ponytail-debt/SKILL.md +44 -0
- package/config/agent/skills/ponytail-help/SKILL.md +68 -0
- package/config/agent/skills/ponytail-review/SKILL.md +56 -0
- package/config/agent/skills_bak/milvus-skill/LICENSE +202 -0
- package/config/agent/skills_bak/milvus-skill/README.md +37 -0
- package/config/agent/skills_bak/milvus-skill/SKILL.md +259 -0
- package/config/agent/skills_bak/milvus-skill/references/collection.md +86 -0
- package/config/agent/skills_bak/milvus-skill/references/database.md +24 -0
- package/config/agent/skills_bak/milvus-skill/references/index.md +69 -0
- package/config/agent/skills_bak/milvus-skill/references/partition.md +29 -0
- package/config/agent/skills_bak/milvus-skill/references/patterns.md +150 -0
- package/config/agent/skills_bak/milvus-skill/references/user-role.md +90 -0
- package/config/agent/skills_bak/milvus-skill/references/vector.md +247 -0
- package/config/agent/skills_bak/zread/README.md +115 -0
- package/config/agent/skills_bak/zread/SKILL.md +103 -0
- package/config/agent/skills_bak/zread/references/stdio-protocol.md +312 -0
- package/package.json +7 -6
- package/scripts/postinstall.js +58 -1
- package/config/agent/dangerous-patterns.json +0 -106
- package/config/agent/extensions/bash-check.ts +0 -227
- package/config/agent/skills/refactor/SKILL.md +0 -40
- /package/config/agent/{skills → skills_bak}/csv-data-summarizer/SKILL.md +0 -0
- /package/config/agent/{skills → skills_bak}/csv-data-summarizer/analyze.py +0 -0
- /package/config/agent/{skills → skills_bak}/csv-data-summarizer/examples/showcase_financial_pl_data.csv +0 -0
- /package/config/agent/{skills → skills_bak}/csv-data-summarizer/requirements.txt +0 -0
- /package/config/agent/{skills → skills_bak}/csv-data-summarizer/resources/sample.csv +0 -0
- /package/config/agent/{skills → skills_bak}/dispatching-parallel-agents/SKILL.md +0 -0
- /package/config/agent/{skills → skills_bak}/find-skills/SKILL.md +0 -0
- /package/config/agent/{skills → skills_bak}/finishing-a-development-branch/SKILL.md +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/LICENSE +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/README.md +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/README.zh.md +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/SKILL.md +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/agentloop-core.svg +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/agents/openai.yaml +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/assets/samples/sample-style1-flat.png +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/assets/samples/sample-style2-dark.png +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/assets/samples/sample-style3-blueprint.png +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/assets/samples/sample-style4-notion.png +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/assets/samples/sample-style5-glass.png +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/assets/samples/sample-style6-claude.png +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/assets/samples/sample-style7-openai.png +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/fixtures/agent-memory-types-style4.json +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/fixtures/api-flow-style7.json +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/fixtures/mem0-style1.json +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/fixtures/microservices-style3.json +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/fixtures/multi-agent-style5.json +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/fixtures/system-architecture-style6.json +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/fixtures/tool-call-style2.json +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/package.json +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/references/icons.md +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/references/style-1-flat-icon.md +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/references/style-2-dark-terminal.md +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/references/style-3-blueprint.md +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/references/style-4-notion-clean.md +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/references/style-5-glassmorphism.md +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/references/style-6-claude-official.md +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/references/style-7-openai.md +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/references/style-diagram-matrix.md +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/references/svg-layout-best-practices.md +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/scripts/README.md +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/scripts/generate-diagram.sh +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/scripts/generate-from-template.py +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/scripts/test-all-styles.sh +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/scripts/validate-svg.sh +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/templates/agent-architecture.svg +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/templates/architecture.svg +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/templates/comparison-matrix.svg +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/templates/data-flow.svg +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/templates/er-diagram.svg +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/templates/flowchart.svg +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/templates/sequence.svg +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/templates/state-machine.svg +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/templates/timeline.svg +0 -0
- /package/config/agent/{skills → skills_bak}/fireworks-tech-graph/templates/use-case.svg +0 -0
- /package/config/agent/{skills → skills_bak}/librarian/SKILL.md +0 -0
- /package/config/agent/{skills → skills_bak}/markdown-to-html/SKILL.md +0 -0
- /package/config/agent/{skills → skills_bak}/pr/SKILL.md +0 -0
- /package/config/agent/{skills → skills_bak}/receiving-code-review/SKILL.md +0 -0
- /package/config/agent/{skills → skills_bak}/requesting-code-review/SKILL.md +0 -0
- /package/config/agent/{skills → skills_bak}/requesting-code-review/code-reviewer.md +0 -0
- /package/config/agent/{skills → skills_bak}/subagent-driven-development/SKILL.md +0 -0
- /package/config/agent/{skills → skills_bak}/subagent-driven-development/code-quality-reviewer-prompt.md +0 -0
- /package/config/agent/{skills → skills_bak}/subagent-driven-development/implementer-prompt.md +0 -0
- /package/config/agent/{skills → skills_bak}/subagent-driven-development/spec-reviewer-prompt.md +0 -0
- /package/config/agent/{skills → skills_bak}/systematic-debugging/CREATION-LOG.md +0 -0
- /package/config/agent/{skills → skills_bak}/systematic-debugging/SKILL.md +0 -0
- /package/config/agent/{skills → skills_bak}/systematic-debugging/condition-based-waiting-example.ts +0 -0
- /package/config/agent/{skills → skills_bak}/systematic-debugging/condition-based-waiting.md +0 -0
- /package/config/agent/{skills → skills_bak}/systematic-debugging/defense-in-depth.md +0 -0
- /package/config/agent/{skills → skills_bak}/systematic-debugging/find-polluter.sh +0 -0
- /package/config/agent/{skills → skills_bak}/systematic-debugging/root-cause-tracing.md +0 -0
- /package/config/agent/{skills → skills_bak}/systematic-debugging/test-academic.md +0 -0
- /package/config/agent/{skills → skills_bak}/systematic-debugging/test-pressure-1.md +0 -0
- /package/config/agent/{skills → skills_bak}/systematic-debugging/test-pressure-2.md +0 -0
- /package/config/agent/{skills → skills_bak}/systematic-debugging/test-pressure-3.md +0 -0
- /package/config/agent/{skills → skills_bak}/test-driven-development/SKILL.md +0 -0
- /package/config/agent/{skills → skills_bak}/test-driven-development/testing-anti-patterns.md +0 -0
- /package/config/agent/{skills → skills_bak}/unit-test/SKILL.md +0 -0
- /package/config/agent/{skills → skills_bak}/using-git-worktrees/SKILL.md +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ponytail-debt
|
|
3
|
+
description: >
|
|
4
|
+
Harvest every `ponytail:` comment in the codebase into a debt ledger, so the
|
|
5
|
+
deliberate shortcuts and deferrals ponytail leaves behind get tracked instead
|
|
6
|
+
of rotting into "later means never". Use when the user says "ponytail debt",
|
|
7
|
+
"/ponytail-debt", "what did ponytail defer", "list the shortcuts", "ponytail
|
|
8
|
+
ledger", or "what did we mark to do later". One-shot report, changes nothing.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Every deliberate ponytail shortcut is marked with a `ponytail:` comment naming
|
|
12
|
+
its ceiling and upgrade path. This collects them into one ledger so a deferral
|
|
13
|
+
can't quietly become permanent.
|
|
14
|
+
|
|
15
|
+
## Scan
|
|
16
|
+
|
|
17
|
+
Grep the repo for comment markers, skipping `node_modules`, `.git`, and build
|
|
18
|
+
output:
|
|
19
|
+
|
|
20
|
+
`grep -rnE '(#|//) ?ponytail:' .` (add other comment prefixes if your stack uses them)
|
|
21
|
+
|
|
22
|
+
Each hit is one ledger row. The comment prefix keeps prose that merely mentions
|
|
23
|
+
the convention out of the ledger.
|
|
24
|
+
|
|
25
|
+
## Output
|
|
26
|
+
|
|
27
|
+
One row per marker, grouped by file:
|
|
28
|
+
|
|
29
|
+
`<file>:<line> — <what was simplified>. ceiling: <the limit named>. upgrade: <the trigger to revisit>.`
|
|
30
|
+
|
|
31
|
+
The convention is `ponytail: <ceiling>, <upgrade path>`, so pull the ceiling
|
|
32
|
+
and the trigger straight from the comment. Want an owner per row too? add
|
|
33
|
+
`git blame -L<line>,<line>`.
|
|
34
|
+
|
|
35
|
+
Flag the rot risk: any `ponytail:` comment that names no upgrade path or
|
|
36
|
+
trigger gets a `no-trigger` tag, those are the ones that silently rot.
|
|
37
|
+
|
|
38
|
+
End with `<N> markers, <M> with no trigger.` Nothing found: `No ponytail: debt. Clean ledger.`
|
|
39
|
+
|
|
40
|
+
## Boundaries
|
|
41
|
+
|
|
42
|
+
Reads and reports only, changes nothing. To persist it, ask and it writes the
|
|
43
|
+
ledger to a file (e.g. `PONYTAIL-DEBT.md`). One-shot. "stop ponytail-debt" or
|
|
44
|
+
"normal mode" to revert.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ponytail-help
|
|
3
|
+
description: >
|
|
4
|
+
Quick-reference card for all ponytail modes, skills, and commands.
|
|
5
|
+
One-shot display, not a persistent mode. Trigger: /ponytail-help,
|
|
6
|
+
"ponytail help", "what ponytail commands", "how do I use ponytail".
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Ponytail Help
|
|
10
|
+
|
|
11
|
+
Display this reference card when invoked. One-shot, do NOT change mode,
|
|
12
|
+
write flag files, or persist anything.
|
|
13
|
+
|
|
14
|
+
## Levels
|
|
15
|
+
|
|
16
|
+
| Level | Trigger | What change |
|
|
17
|
+
|-------|---------|-------------|
|
|
18
|
+
| **Lite** | `/ponytail lite` | Build what's asked, name the lazier alternative in one line. |
|
|
19
|
+
| **Full** | `/ponytail` | The ladder enforced: YAGNI → stdlib → native → one line → minimum. Default. |
|
|
20
|
+
| **Ultra** | `/ponytail ultra` | YAGNI extremist. Deletion before addition. Challenges requirements before building. |
|
|
21
|
+
|
|
22
|
+
Level sticks until changed or session end.
|
|
23
|
+
|
|
24
|
+
## Skills
|
|
25
|
+
|
|
26
|
+
| Skill | Trigger | What it does |
|
|
27
|
+
|-------|---------|--------------|
|
|
28
|
+
| **ponytail** | `/ponytail` | Lazy mode itself. Simplest solution that works. |
|
|
29
|
+
| **ponytail-review** | `/ponytail-review` | Over-engineering review: `L42: yagni: factory, one product. Inline.` |
|
|
30
|
+
| **ponytail-help** | `/ponytail-help` | This card. |
|
|
31
|
+
|
|
32
|
+
Codex uses `@ponytail`, `@ponytail-review`, and `@ponytail-help`; Claude Code
|
|
33
|
+
and OpenCode use the slash-command forms above (OpenCode ships `/ponytail` and
|
|
34
|
+
`/ponytail-review`).
|
|
35
|
+
|
|
36
|
+
## Deactivate
|
|
37
|
+
|
|
38
|
+
Say "stop ponytail" or "normal mode". Resume anytime with `/ponytail`.
|
|
39
|
+
`/ponytail off` also works.
|
|
40
|
+
|
|
41
|
+
## Configure Default Mode
|
|
42
|
+
|
|
43
|
+
Default mode = `full`, auto-active every session. Change it:
|
|
44
|
+
|
|
45
|
+
**Environment variable** (highest priority):
|
|
46
|
+
```bash
|
|
47
|
+
export PONYTAIL_DEFAULT_MODE=ultra
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Config file** (`~/.config/ponytail/config.json`, Windows: `%APPDATA%\ponytail\config.json`):
|
|
51
|
+
```json
|
|
52
|
+
{ "defaultMode": "lite" }
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Set `"off"` to disable auto-activation on session start, activate manually
|
|
56
|
+
with `/ponytail` when wanted.
|
|
57
|
+
|
|
58
|
+
Resolution: env var > config file > `full`.
|
|
59
|
+
|
|
60
|
+
## Update
|
|
61
|
+
|
|
62
|
+
Enable auto-update once: open `/plugin`, go to Marketplaces, pick ponytail, Enable auto-update. Claude Code then pulls new versions at startup (run `/reload-plugins` when it prompts). Manual refresh: `/plugin marketplace update ponytail` then `/reload-plugins`.
|
|
63
|
+
|
|
64
|
+
If `/plugin` is not recognized, your Claude Code is out of date. Update it (`npm install -g @anthropic-ai/claude-code@latest`, or `brew upgrade claude-code`) and restart. Other hosts use their own update flow.
|
|
65
|
+
|
|
66
|
+
## More
|
|
67
|
+
|
|
68
|
+
Full docs + examples: https://github.com/DietrichGebert/ponytail
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ponytail-review
|
|
3
|
+
description: >
|
|
4
|
+
Code review focused exclusively on over-engineering. Finds what to delete:
|
|
5
|
+
reinvented standard library, unneeded dependencies, speculative abstractions,
|
|
6
|
+
dead flexibility. One line per finding: location, what to cut, what replaces
|
|
7
|
+
it. Use when the user says "review for over-engineering", "what can we
|
|
8
|
+
delete", "is this over-engineered", "simplify review", or invokes
|
|
9
|
+
/ponytail-review. Complements correctness-focused review, this one only
|
|
10
|
+
hunts complexity.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
Review diffs for unnecessary complexity. One line per finding: location, what
|
|
14
|
+
to cut, what replaces it. The diff's best outcome is getting shorter.
|
|
15
|
+
|
|
16
|
+
## Format
|
|
17
|
+
|
|
18
|
+
`L<line>: <tag> <what>. <replacement>.`, or `<file>:L<line>: ...` for
|
|
19
|
+
multi-file diffs.
|
|
20
|
+
|
|
21
|
+
Tags:
|
|
22
|
+
|
|
23
|
+
- `delete:` dead code, unused flexibility, speculative feature. Replacement: nothing.
|
|
24
|
+
- `stdlib:` hand-rolled thing the standard library ships. Name the function.
|
|
25
|
+
- `native:` dependency or code doing what the platform already does. Name the feature.
|
|
26
|
+
- `yagni:` abstraction with one implementation, config nobody sets, layer with one caller.
|
|
27
|
+
- `shrink:` same logic, fewer lines. Show the shorter form.
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
|
|
31
|
+
❌ "This EmailValidator class might be more complex than necessary, have you
|
|
32
|
+
considered whether all these validation rules are needed at this stage?"
|
|
33
|
+
|
|
34
|
+
✅ `L12-38: stdlib: 27-line validator class. "@" in email, 1 line, real validation is the confirmation mail.`
|
|
35
|
+
|
|
36
|
+
✅ `L4: native: moment.js imported for one format call. Intl.DateTimeFormat, 0 deps.`
|
|
37
|
+
|
|
38
|
+
✅ `repo.py:L88: yagni: AbstractRepository with one implementation. Inline it until a second one exists.`
|
|
39
|
+
|
|
40
|
+
✅ `L52-71: delete: retry wrapper around an idempotent local call. Nothing replaces it.`
|
|
41
|
+
|
|
42
|
+
✅ `L30-44: shrink: manual loop builds dict. dict(zip(keys, values)), 1 line.`
|
|
43
|
+
|
|
44
|
+
## Scoring
|
|
45
|
+
|
|
46
|
+
End with the only metric that matters: `net: -<N> lines possible.`
|
|
47
|
+
|
|
48
|
+
If there is nothing to cut, say `Lean already. Ship.` and stop.
|
|
49
|
+
|
|
50
|
+
## Boundaries
|
|
51
|
+
|
|
52
|
+
Complexity only, correctness bugs, security holes, and performance go to a
|
|
53
|
+
normal review pass, not this one. A single smoke test or `assert`-based
|
|
54
|
+
self-check is the ponytail minimum, not bloat, never flag it for deletion.
|
|
55
|
+
Does not apply the fixes, only lists them.
|
|
56
|
+
"stop ponytail-review" or "normal mode": revert to verbose review style.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# milvus-skill
|
|
2
|
+
|
|
3
|
+
An agent skill that teaches LLMs how to use [pymilvus](https://github.com/milvus-io/pymilvus) to operate [Milvus](https://milvus.io/) vector database.
|
|
4
|
+
|
|
5
|
+
## What's Included
|
|
6
|
+
|
|
7
|
+
- **SKILL.md** — Main skill definition with connection, collection management, vector operations, and index management
|
|
8
|
+
- **references/** — Detailed reference docs for each feature area:
|
|
9
|
+
- `collection.md` — Data types, schema fields, collection operations
|
|
10
|
+
- `vector.md` — Insert, search, hybrid search, full-text search, iterators, filters
|
|
11
|
+
- `index.md` — Index types, metric types, create/manage indexes
|
|
12
|
+
- `partition.md` — Partition CRUD
|
|
13
|
+
- `database.md` — Database management
|
|
14
|
+
- `user-role.md` — RBAC: users, roles, privileges
|
|
15
|
+
- `patterns.md` — Common patterns (RAG, semantic search, hybrid search, full-text search)
|
|
16
|
+
|
|
17
|
+
## Install as Claude Code Skill
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
claude skill add --url https://github.com/zilliztech/milvus-skill
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Capabilities
|
|
24
|
+
|
|
25
|
+
- Connect to Milvus Lite, Standalone, Cluster, or Zilliz Cloud
|
|
26
|
+
- Create collections with quick or custom schemas
|
|
27
|
+
- Insert, upsert, search, query, get, delete vectors
|
|
28
|
+
- Hybrid search with RRF/Weighted reranking
|
|
29
|
+
- Full-text search with BM25
|
|
30
|
+
- Paginated iteration over large result sets
|
|
31
|
+
- Index management (AUTOINDEX, HNSW, IVF_FLAT, etc.)
|
|
32
|
+
- Partition, database, and RBAC management
|
|
33
|
+
|
|
34
|
+
## Requirements
|
|
35
|
+
|
|
36
|
+
- Python 3.8+
|
|
37
|
+
- `pymilvus` (`pip install pymilvus`)
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: milvus-skill
|
|
3
|
+
description: Operate Milvus vector database with pymilvus Python SDK. Use when the user wants to connect to Milvus, create collections, insert vectors, perform similarity search, hybrid search, full-text search, manage indexes, partitions, databases, or RBAC via Python code.
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
compatibility: Requires Python 3.8+ and pymilvus (pip install pymilvus). Runs on macOS and Linux.
|
|
6
|
+
metadata:
|
|
7
|
+
author: zilliztech
|
|
8
|
+
version: "1.0.0"
|
|
9
|
+
allowed-tools: Bash Read Write
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Milvus Vector Database Skill
|
|
13
|
+
|
|
14
|
+
Operate [Milvus](https://milvus.io/) vector databases directly through Python code using the `pymilvus` SDK. Covers the full lifecycle — connecting, schema design, collection management, vector CRUD, search, hybrid search, full-text search, indexing, partitions, databases, and RBAC.
|
|
15
|
+
|
|
16
|
+
## When to Use
|
|
17
|
+
|
|
18
|
+
Use this skill when the user wants to:
|
|
19
|
+
- Connect to a Milvus instance (local, standalone, cluster, or Milvus Lite)
|
|
20
|
+
- Create collections with custom schemas
|
|
21
|
+
- Insert, upsert, search, query, get, or delete vectors
|
|
22
|
+
- Perform hybrid search with reranking
|
|
23
|
+
- Perform full-text search (BM25)
|
|
24
|
+
- Manage indexes, partitions, databases
|
|
25
|
+
- Set up users, roles, and access control (RBAC)
|
|
26
|
+
- Build RAG pipelines, semantic search, or recommendation systems with Milvus
|
|
27
|
+
- Iterate over large result sets with search/query iterators
|
|
28
|
+
|
|
29
|
+
## Requirements
|
|
30
|
+
|
|
31
|
+
- Python 3.8+
|
|
32
|
+
- `pymilvus` (`pip install pymilvus`)
|
|
33
|
+
- A running Milvus instance, or use Milvus Lite (embedded, file-based) for development
|
|
34
|
+
|
|
35
|
+
## Capabilities Overview
|
|
36
|
+
|
|
37
|
+
| Area | What You Can Do |
|
|
38
|
+
|------|----------------|
|
|
39
|
+
| **Connection** | Connect to Milvus Lite, Standalone, Cluster, or Zilliz Cloud |
|
|
40
|
+
| **Collections** | Create (quick or custom schema), list, describe, drop, rename, truncate, load, release |
|
|
41
|
+
| **Vectors** | Insert, upsert, search, hybrid search, query, get, delete |
|
|
42
|
+
| **Full-Text Search** | BM25-based keyword search with sparse vectors |
|
|
43
|
+
| **Iterators** | Paginated search and query over large datasets |
|
|
44
|
+
| **Indexes** | Create (AUTOINDEX, HNSW, IVF_FLAT, etc.), list, describe, drop |
|
|
45
|
+
| **Partitions** | Create, list, load, release, drop |
|
|
46
|
+
| **Databases** | Create, list, switch, drop |
|
|
47
|
+
| **RBAC** | Users, roles, privileges management |
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Connection
|
|
52
|
+
|
|
53
|
+
> **IMPORTANT: Before writing any connection code, you MUST ask the user for their connection details.** Ask:
|
|
54
|
+
> 1. **Deployment type** — Milvus Lite (local file), Standalone/Cluster (self-hosted), or Zilliz Cloud (managed)?
|
|
55
|
+
> 2. **URI** — For self-hosted: host and port (e.g., `http://localhost:19530`). For Zilliz Cloud: the endpoint URL.
|
|
56
|
+
> 3. **Authentication** — Token, API key, or username/password if required.
|
|
57
|
+
> 4. **Database name** — If not using the default database.
|
|
58
|
+
>
|
|
59
|
+
> **Never assume or hardcode connection parameters.** Use Milvus Lite (`uri="./milvus.db"`) only if the user explicitly wants local/embedded mode for development.
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from pymilvus import MilvusClient
|
|
63
|
+
|
|
64
|
+
# Milvus Lite (embedded, file-based — great for dev/test)
|
|
65
|
+
client = MilvusClient(uri="./milvus.db")
|
|
66
|
+
|
|
67
|
+
# Standalone / Cluster Milvus (ask user for actual host:port and credentials)
|
|
68
|
+
client = MilvusClient(uri="<USER_URI>", token="<USER_TOKEN>")
|
|
69
|
+
|
|
70
|
+
# Zilliz Cloud (ask user for endpoint and API key)
|
|
71
|
+
client = MilvusClient(uri="<USER_ZILLIZ_ENDPOINT>", token="<USER_API_KEY>")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Parameters:**
|
|
75
|
+
|
|
76
|
+
| Parameter | Type | Description |
|
|
77
|
+
|-----------|------|-------------|
|
|
78
|
+
| `uri` | str | `"./file.db"` for Milvus Lite, `"http://host:19530"` for server |
|
|
79
|
+
| `token` | str | API key or `"username:password"` |
|
|
80
|
+
| `user` | str | Username (alternative to token) |
|
|
81
|
+
| `password` | str | Password (alternative to token) |
|
|
82
|
+
| `db_name` | str | Target database (default: `"default"`) |
|
|
83
|
+
| `timeout` | float | Operation timeout in seconds |
|
|
84
|
+
|
|
85
|
+
### Async Client
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from pymilvus import AsyncMilvusClient
|
|
89
|
+
|
|
90
|
+
async with AsyncMilvusClient(uri="<USER_URI>") as client:
|
|
91
|
+
results = await client.search(collection_name="my_collection", data=[query_vector], limit=10)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Collection Management
|
|
97
|
+
|
|
98
|
+
### Quick Create (auto schema + auto index + auto load)
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
client.create_collection(
|
|
102
|
+
collection_name="my_collection",
|
|
103
|
+
dimension=768,
|
|
104
|
+
metric_type="COSINE" # Optional: "COSINE" (default), "L2", "IP"
|
|
105
|
+
)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
This automatically creates an `id` field (INT64, primary key, auto_id), a `vector` field (FLOAT_VECTOR), AUTOINDEX, and auto-loads the collection.
|
|
109
|
+
|
|
110
|
+
### Custom Schema Create
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from pymilvus import DataType
|
|
114
|
+
|
|
115
|
+
schema = client.create_schema(auto_id=False, enable_dynamic_field=True)
|
|
116
|
+
schema.add_field("id", DataType.INT64, is_primary=True)
|
|
117
|
+
schema.add_field("text", DataType.VARCHAR, max_length=512)
|
|
118
|
+
schema.add_field("embedding", DataType.FLOAT_VECTOR, dim=768)
|
|
119
|
+
|
|
120
|
+
index_params = client.prepare_index_params()
|
|
121
|
+
index_params.add_index(field_name="embedding", index_type="AUTOINDEX", metric_type="COSINE")
|
|
122
|
+
|
|
123
|
+
client.create_collection(collection_name="my_collection", schema=schema, index_params=index_params)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**See [references/collection.md](references/collection.md) for data types, add_field parameters, and all collection operations.**
|
|
127
|
+
|
|
128
|
+
### Other Collection Operations
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
client.list_collections()
|
|
132
|
+
client.describe_collection(collection_name="my_collection")
|
|
133
|
+
client.has_collection(collection_name="my_collection")
|
|
134
|
+
client.rename_collection(old_name="old", new_name="new")
|
|
135
|
+
client.drop_collection(collection_name="my_collection")
|
|
136
|
+
client.truncate_collection(collection_name="my_collection")
|
|
137
|
+
client.load_collection(collection_name="my_collection")
|
|
138
|
+
client.release_collection(collection_name="my_collection")
|
|
139
|
+
client.get_load_state(collection_name="my_collection")
|
|
140
|
+
client.get_collection_stats(collection_name="my_collection")
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
- Quick create is best for prototyping; use custom schema for production.
|
|
144
|
+
- A collection must be **loaded** before search or query.
|
|
145
|
+
- Use `enable_dynamic_field=True` to allow inserting fields not defined in the schema.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Vector Operations
|
|
150
|
+
|
|
151
|
+
**See [references/vector.md](references/vector.md) for hybrid search, full-text search, iterators, filter syntax, and detailed examples.**
|
|
152
|
+
|
|
153
|
+
### Insert / Upsert
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
# Vectors must come from an embedding model — never use fake/placeholder vectors
|
|
157
|
+
from pymilvus import model
|
|
158
|
+
|
|
159
|
+
embedding_fn = model.dense.SentenceTransformerEmbeddingFunction(model_name="all-MiniLM-L6-v2")
|
|
160
|
+
|
|
161
|
+
docs = ["AI advances in 2024", "ML basics for beginners"]
|
|
162
|
+
vectors = embedding_fn.encode_documents(docs)
|
|
163
|
+
|
|
164
|
+
data = [
|
|
165
|
+
{"id": 1, "text": docs[0], "embedding": vectors[0]},
|
|
166
|
+
{"id": 2, "text": docs[1], "embedding": vectors[1]},
|
|
167
|
+
]
|
|
168
|
+
client.insert(collection_name="my_collection", data=data)
|
|
169
|
+
client.upsert(collection_name="my_collection", data=data)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Search (vector similarity)
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
# Use the same embedding model to encode the query
|
|
176
|
+
query_vectors = embedding_fn.encode_queries(["What is artificial intelligence?"])
|
|
177
|
+
|
|
178
|
+
results = client.search(
|
|
179
|
+
collection_name="my_collection",
|
|
180
|
+
data=query_vectors,
|
|
181
|
+
anns_field="embedding",
|
|
182
|
+
limit=10,
|
|
183
|
+
output_fields=["text", "id"],
|
|
184
|
+
filter='age > 20 and status == "active"',
|
|
185
|
+
search_params={"metric_type": "COSINE", "params": {"nprobe": 10}}
|
|
186
|
+
)
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Query / Get / Delete
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
# Query by filter
|
|
193
|
+
client.query(collection_name="my_collection", filter='id in [1, 2, 3]', output_fields=["text"], limit=100)
|
|
194
|
+
|
|
195
|
+
# Get by primary key
|
|
196
|
+
client.get(collection_name="my_collection", ids=[1, 2, 3], output_fields=["text"])
|
|
197
|
+
|
|
198
|
+
# Delete
|
|
199
|
+
client.delete(collection_name="my_collection", ids=[1, 2, 3])
|
|
200
|
+
client.delete(collection_name="my_collection", filter='status == "obsolete"')
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
- **Never use fake or placeholder vectors** (e.g., `[0.1, 0.2, ...]`). Always generate vectors from an embedding model.
|
|
204
|
+
- Use `pip install "pymilvus[model]"` for built-in embedding functions, or use any embedding model (OpenAI, Cohere, etc.).
|
|
205
|
+
- Vector dimension in search must match the collection schema exactly.
|
|
206
|
+
- The query embedding model must be the **same model** used to generate the stored vectors.
|
|
207
|
+
- For large inserts, batch data into chunks (e.g., 1000 rows per batch).
|
|
208
|
+
- For large result sets, use iterators — see [references/vector.md](references/vector.md).
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Index Management
|
|
213
|
+
|
|
214
|
+
**See [references/index.md](references/index.md) for index types, metric types, and parameters.**
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
index_params = client.prepare_index_params()
|
|
218
|
+
index_params.add_index(
|
|
219
|
+
field_name="embedding",
|
|
220
|
+
index_type="HNSW",
|
|
221
|
+
metric_type="COSINE",
|
|
222
|
+
params={"M": 16, "efConstruction": 256}
|
|
223
|
+
)
|
|
224
|
+
client.create_index(collection_name="my_collection", index_params=index_params)
|
|
225
|
+
|
|
226
|
+
client.list_indexes(collection_name="my_collection")
|
|
227
|
+
client.describe_index(collection_name="my_collection", index_name="my_index")
|
|
228
|
+
client.drop_index(collection_name="my_collection", index_name="my_index")
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
- `AUTOINDEX` is recommended for most use cases.
|
|
232
|
+
- An index is required before loading a collection.
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Additional Features
|
|
237
|
+
|
|
238
|
+
| Feature | Reference |
|
|
239
|
+
|---------|-----------|
|
|
240
|
+
| Partition Management | [references/partition.md](references/partition.md) |
|
|
241
|
+
| Database Management | [references/database.md](references/database.md) |
|
|
242
|
+
| User & Role Management (RBAC) | [references/user-role.md](references/user-role.md) |
|
|
243
|
+
| Common Patterns (RAG, Semantic Search) | [references/patterns.md](references/patterns.md) |
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## General Guidance
|
|
248
|
+
|
|
249
|
+
- **Always ask the user for connection details** (URI, token/credentials) before writing connection code. Never assume or hardcode connection parameters.
|
|
250
|
+
- **Never generate fake or placeholder vectors.** Always use an embedding model to produce real vectors. Suggest `pip install "pymilvus[model]"` for built-in embedding functions.
|
|
251
|
+
- For quick prototyping, use **Milvus Lite** (`uri="./file.db"`) — no server needed, but only if the user explicitly requests local/embedded mode.
|
|
252
|
+
- A collection must be **loaded into memory** before search/query.
|
|
253
|
+
- The vector dimension in search data must **exactly match** the collection schema.
|
|
254
|
+
- The query embedding model must be the **same model** used to generate the stored vectors.
|
|
255
|
+
- Before any destructive operation (drop collection, drop database, delete vectors), always confirm with the user.
|
|
256
|
+
- Use `enable_dynamic_field=True` when the schema may evolve.
|
|
257
|
+
- Prefer `AUTOINDEX` unless the user has specific performance requirements.
|
|
258
|
+
- Use `truncate_collection` to clear all data without dropping the collection.
|
|
259
|
+
- For large datasets, use iterators (`search_iterator`, `query_iterator`) instead of increasing limit.
|