@ia-ccun/code-agent-cli 0.0.52-beta.6 → 0.0.52-beta.8
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-safety-guard.ts +2 -2
- package/config/agent/extensions/aicode-tips.ts +8 -0
- 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/milvus-skill/LICENSE +202 -0
- package/config/agent/skills/milvus-skill/README.md +37 -0
- package/config/agent/skills/milvus-skill/SKILL.md +259 -0
- package/config/agent/skills/milvus-skill/references/collection.md +86 -0
- package/config/agent/skills/milvus-skill/references/database.md +24 -0
- package/config/agent/skills/milvus-skill/references/index.md +69 -0
- package/config/agent/skills/milvus-skill/references/partition.md +29 -0
- package/config/agent/skills/milvus-skill/references/patterns.md +150 -0
- package/config/agent/skills/milvus-skill/references/user-role.md +90 -0
- package/config/agent/skills/milvus-skill/references/vector.md +247 -0
- package/package.json +1 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# User & Role Management (RBAC)
|
|
2
|
+
|
|
3
|
+
## User Operations
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
# Create a user
|
|
7
|
+
client.create_user(user_name="analyst", password="SecureP@ss123")
|
|
8
|
+
|
|
9
|
+
# List users
|
|
10
|
+
users = client.list_users()
|
|
11
|
+
|
|
12
|
+
# Describe a user (shows assigned roles)
|
|
13
|
+
info = client.describe_user(user_name="analyst")
|
|
14
|
+
|
|
15
|
+
# Update password
|
|
16
|
+
client.update_password(user_name="analyst", old_password="SecureP@ss123", new_password="NewP@ss456")
|
|
17
|
+
|
|
18
|
+
# Grant role to user
|
|
19
|
+
client.grant_role(user_name="analyst", role_name="read_only")
|
|
20
|
+
|
|
21
|
+
# Revoke role from user
|
|
22
|
+
client.revoke_role(user_name="analyst", role_name="read_only")
|
|
23
|
+
|
|
24
|
+
# Drop a user
|
|
25
|
+
client.drop_user(user_name="analyst")
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Role Operations
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
# Create a role
|
|
32
|
+
client.create_role(role_name="read_only")
|
|
33
|
+
|
|
34
|
+
# List roles
|
|
35
|
+
roles = client.list_roles()
|
|
36
|
+
|
|
37
|
+
# Grant privilege (v2 API — recommended)
|
|
38
|
+
client.grant_privilege_v2(
|
|
39
|
+
role_name="read_only",
|
|
40
|
+
privilege="Search", # e.g., "Search", "Insert", "Query", "Delete"
|
|
41
|
+
collection_name="my_collection", # Use "*" for all collections
|
|
42
|
+
db_name="default" # Use "*" for all databases
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Built-in privilege groups
|
|
46
|
+
client.grant_privilege_v2(
|
|
47
|
+
role_name="admin_role",
|
|
48
|
+
privilege="ClusterAdmin", # See privilege groups below
|
|
49
|
+
collection_name="*",
|
|
50
|
+
db_name="*"
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
# Revoke privilege
|
|
54
|
+
client.revoke_privilege_v2(
|
|
55
|
+
role_name="read_only",
|
|
56
|
+
privilege="Search",
|
|
57
|
+
collection_name="my_collection",
|
|
58
|
+
db_name="default"
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# Describe role (see granted privileges)
|
|
62
|
+
info = client.describe_role(role_name="read_only")
|
|
63
|
+
|
|
64
|
+
# Drop a role
|
|
65
|
+
client.drop_role(role_name="read_only")
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Built-in Privilege Groups
|
|
69
|
+
|
|
70
|
+
| Group | Scope |
|
|
71
|
+
|-------|-------|
|
|
72
|
+
| `ClusterAdmin` | Full cluster access |
|
|
73
|
+
| `ClusterReadOnly` | Read-only cluster access |
|
|
74
|
+
| `ClusterReadWrite` | Read-write cluster access |
|
|
75
|
+
| `DatabaseAdmin` | Full database access |
|
|
76
|
+
| `DatabaseReadOnly` | Read-only database access |
|
|
77
|
+
| `DatabaseReadWrite` | Read-write database access |
|
|
78
|
+
| `CollectionAdmin` | Full collection access |
|
|
79
|
+
| `CollectionReadOnly` | Read-only collection access |
|
|
80
|
+
| `CollectionReadWrite` | Read-write collection access |
|
|
81
|
+
|
|
82
|
+
## Common Individual Privileges
|
|
83
|
+
|
|
84
|
+
`Search`, `Query`, `Insert`, `Delete`, `Upsert`, `CreateIndex`, `DropIndex`, `CreateCollection`, `DropCollection`, `Load`, `Release`, `CreatePartition`, `DropPartition`
|
|
85
|
+
|
|
86
|
+
## Guidance
|
|
87
|
+
|
|
88
|
+
- Recommended workflow: create role -> grant privileges -> create user -> assign role.
|
|
89
|
+
- Use `"*"` for collection_name/db_name to grant on all resources.
|
|
90
|
+
- Before dropping a user or role, confirm with the user.
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# Vector Operations — Detailed Reference
|
|
2
|
+
|
|
3
|
+
Target collection must exist and be loaded.
|
|
4
|
+
|
|
5
|
+
> **Never use fake or placeholder vectors** (e.g., `[0.1, 0.2, ...]`). Always generate vectors from an embedding model. Use `pip install "pymilvus[model]"` for built-in embedding support, or use any external embedding model (OpenAI, Cohere, HuggingFace, etc.).
|
|
6
|
+
|
|
7
|
+
## Embedding Model Setup
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
# Option 1: Built-in pymilvus embedding (pip install "pymilvus[model]")
|
|
11
|
+
from pymilvus import model
|
|
12
|
+
embedding_fn = model.dense.SentenceTransformerEmbeddingFunction(model_name="all-MiniLM-L6-v2")
|
|
13
|
+
|
|
14
|
+
# Encode documents for insertion
|
|
15
|
+
doc_vectors = embedding_fn.encode_documents(["AI advances in 2024", "ML basics for beginners"])
|
|
16
|
+
# Encode queries for search (use the SAME model that encoded the stored documents)
|
|
17
|
+
query_vectors = embedding_fn.encode_queries(["What is artificial intelligence?"])
|
|
18
|
+
|
|
19
|
+
# Option 2: OpenAI embeddings (pip install openai)
|
|
20
|
+
from openai import OpenAI
|
|
21
|
+
openai_client = OpenAI()
|
|
22
|
+
response = openai_client.embeddings.create(input=["some text"], model="text-embedding-3-small")
|
|
23
|
+
vectors = [item.embedding for item in response.data]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Insert
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
docs = ["AI advances in 2024", "ML basics for beginners"]
|
|
30
|
+
vectors = embedding_fn.encode_documents(docs)
|
|
31
|
+
|
|
32
|
+
data = [
|
|
33
|
+
{"id": 1, "text": docs[0], "embedding": vectors[0]},
|
|
34
|
+
{"id": 2, "text": docs[1], "embedding": vectors[1]},
|
|
35
|
+
]
|
|
36
|
+
res = client.insert(collection_name="my_collection", data=data)
|
|
37
|
+
# Returns: {"insert_count": 2, "ids": [1, 2]}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Upsert (insert or update if PK exists)
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
res = client.upsert(collection_name="my_collection", data=data)
|
|
44
|
+
# Returns: {"upsert_count": 2}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Search (vector similarity)
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
query_vectors = embedding_fn.encode_queries(["What is artificial intelligence?"])
|
|
51
|
+
|
|
52
|
+
results = client.search(
|
|
53
|
+
collection_name="my_collection",
|
|
54
|
+
data=query_vectors, # Vectors from embedding model
|
|
55
|
+
anns_field="embedding", # Vector field name
|
|
56
|
+
limit=10, # Top-K
|
|
57
|
+
output_fields=["text", "id"], # Fields to return
|
|
58
|
+
filter='age > 20 and status == "active"', # Optional scalar filter
|
|
59
|
+
search_params={
|
|
60
|
+
"metric_type": "COSINE",
|
|
61
|
+
"params": {"nprobe": 10} # Index-specific params
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
# Returns: List[List[dict]]
|
|
65
|
+
# Each hit: {"id": 1, "distance": 0.95, "entity": {"text": "AI advances..."}}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Hybrid Search (multi-vector with reranking)
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from pymilvus import AnnSearchRequest, RRFRanker, WeightedRanker
|
|
72
|
+
|
|
73
|
+
# dense_query_vector and sparse_query_vector come from your embedding models
|
|
74
|
+
req1 = AnnSearchRequest(
|
|
75
|
+
data=[dense_query_vector],
|
|
76
|
+
anns_field="dense_embedding",
|
|
77
|
+
param={"metric_type": "COSINE", "params": {"nprobe": 10}},
|
|
78
|
+
limit=10
|
|
79
|
+
)
|
|
80
|
+
req2 = AnnSearchRequest(
|
|
81
|
+
data=[{1: 0.5, 100: 0.3}], # Sparse vector
|
|
82
|
+
anns_field="sparse_embedding",
|
|
83
|
+
param={"metric_type": "IP"},
|
|
84
|
+
limit=10
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# RRF reranking
|
|
88
|
+
results = client.hybrid_search(
|
|
89
|
+
collection_name="my_collection",
|
|
90
|
+
reqs=[req1, req2],
|
|
91
|
+
ranker=RRFRanker(k=60),
|
|
92
|
+
limit=10,
|
|
93
|
+
output_fields=["text"]
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Or weighted reranking
|
|
97
|
+
results = client.hybrid_search(
|
|
98
|
+
collection_name="my_collection",
|
|
99
|
+
reqs=[req1, req2],
|
|
100
|
+
ranker=WeightedRanker(0.7, 0.3),
|
|
101
|
+
limit=10
|
|
102
|
+
)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Full-Text Search
|
|
106
|
+
|
|
107
|
+
Full-text search uses Milvus's built-in BM25 tokenizer to convert text into sparse vectors automatically.
|
|
108
|
+
|
|
109
|
+
### Setup: Collection with Full-Text Search
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from pymilvus import MilvusClient, DataType, Function, FunctionType
|
|
113
|
+
|
|
114
|
+
client = MilvusClient(uri="<USER_URI>", token="<USER_TOKEN>")
|
|
115
|
+
|
|
116
|
+
schema = client.create_schema()
|
|
117
|
+
schema.add_field("id", DataType.INT64, is_primary=True, auto_id=True)
|
|
118
|
+
schema.add_field("text", DataType.VARCHAR, max_length=1000, enable_analyzer=True)
|
|
119
|
+
schema.add_field("sparse", DataType.SPARSE_FLOAT_VECTOR)
|
|
120
|
+
|
|
121
|
+
# Define BM25 function to auto-convert text -> sparse vector
|
|
122
|
+
bm25_function = Function(
|
|
123
|
+
name="text_bm25",
|
|
124
|
+
input_field_names=["text"],
|
|
125
|
+
output_field_names=["sparse"],
|
|
126
|
+
function_type=FunctionType.BM25,
|
|
127
|
+
)
|
|
128
|
+
schema.add_function(bm25_function)
|
|
129
|
+
|
|
130
|
+
index_params = client.prepare_index_params()
|
|
131
|
+
index_params.add_index(field_name="sparse", index_type="AUTOINDEX", metric_type="BM25")
|
|
132
|
+
|
|
133
|
+
client.create_collection(collection_name="full_text_col", schema=schema, index_params=index_params)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Search with Text
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
results = client.search(
|
|
140
|
+
collection_name="full_text_col",
|
|
141
|
+
data=["machine learning algorithms"], # Raw text query
|
|
142
|
+
anns_field="sparse",
|
|
143
|
+
limit=10,
|
|
144
|
+
output_fields=["text"]
|
|
145
|
+
)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Search Iterator (paginated search over large results)
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
query_vectors = embedding_fn.encode_queries(["search query text"])
|
|
152
|
+
|
|
153
|
+
iterator = client.search_iterator(
|
|
154
|
+
collection_name="my_collection",
|
|
155
|
+
data=query_vectors,
|
|
156
|
+
anns_field="embedding",
|
|
157
|
+
batch_size=100,
|
|
158
|
+
limit=10000,
|
|
159
|
+
output_fields=["text"],
|
|
160
|
+
search_params={"metric_type": "COSINE", "params": {"nprobe": 10}}
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
results = []
|
|
164
|
+
while True:
|
|
165
|
+
batch = iterator.next()
|
|
166
|
+
if not batch:
|
|
167
|
+
break
|
|
168
|
+
results.extend(batch)
|
|
169
|
+
|
|
170
|
+
iterator.close()
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Query Iterator (paginated filter-based retrieval)
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
iterator = client.query_iterator(
|
|
177
|
+
collection_name="my_collection",
|
|
178
|
+
filter='age > 20',
|
|
179
|
+
output_fields=["text", "age"],
|
|
180
|
+
batch_size=100,
|
|
181
|
+
limit=10000
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
results = []
|
|
185
|
+
while True:
|
|
186
|
+
batch = iterator.next()
|
|
187
|
+
if not batch:
|
|
188
|
+
break
|
|
189
|
+
results.extend(batch)
|
|
190
|
+
|
|
191
|
+
iterator.close()
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Query (filter-based retrieval)
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
results = client.query(
|
|
198
|
+
collection_name="my_collection",
|
|
199
|
+
filter='id in [1, 2, 3]',
|
|
200
|
+
output_fields=["text", "embedding"],
|
|
201
|
+
limit=100
|
|
202
|
+
)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Get (by primary key)
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
results = client.get(
|
|
209
|
+
collection_name="my_collection",
|
|
210
|
+
ids=[1, 2, 3],
|
|
211
|
+
output_fields=["text"]
|
|
212
|
+
)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Delete
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
# By primary keys
|
|
219
|
+
client.delete(collection_name="my_collection", ids=[1, 2, 3])
|
|
220
|
+
|
|
221
|
+
# By filter expression
|
|
222
|
+
client.delete(collection_name="my_collection", filter='status == "obsolete"')
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Filter Expression Syntax
|
|
226
|
+
|
|
227
|
+
| Expression | Example |
|
|
228
|
+
|---|---|
|
|
229
|
+
| Comparison | `age > 20` |
|
|
230
|
+
| Equality | `status == "active"` |
|
|
231
|
+
| IN list | `id in [1, 2, 3]` |
|
|
232
|
+
| AND/OR | `age > 20 and status == "active"` |
|
|
233
|
+
| String match | `text like "hello%"` |
|
|
234
|
+
| Array contains | `ARRAY_CONTAINS(tags, "ml")` |
|
|
235
|
+
| JSON field | `json_field["key"] > 100` |
|
|
236
|
+
| Match all | `id > 0` |
|
|
237
|
+
|
|
238
|
+
## Guidance
|
|
239
|
+
|
|
240
|
+
- **Never use fake or placeholder vectors.** Always generate vectors from an embedding model.
|
|
241
|
+
- The query embedding model must be the **same model** used to generate the stored vectors.
|
|
242
|
+
- The `data` parameter in search must match the collection's vector dimension exactly.
|
|
243
|
+
- For full-text search, pass raw text strings as `data` — Milvus handles tokenization via BM25.
|
|
244
|
+
- For large inserts, batch data into chunks (e.g., 1000 rows per batch).
|
|
245
|
+
- Always specify `output_fields` to control which fields are returned.
|
|
246
|
+
- For large result sets, use `search_iterator` or `query_iterator` instead of increasing `limit`.
|
|
247
|
+
- Always call `iterator.close()` when done to release server resources.
|