@ia-ccun/code-agent-cli 0.0.59-beta.4 → 0.0.59-beta.6

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.
Files changed (129) hide show
  1. package/config/agent/extensions/aicode-provider-scope.ts +388 -0
  2. package/config/agent/mcp.json +5 -0
  3. package/config/agent/skills/agent-browser/LICENSE +201 -0
  4. package/config/agent/skills/agent-browser/SKILL.md +55 -0
  5. package/config/agent/skills/codebase-design/DEEPENING.md +37 -0
  6. package/config/agent/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
  7. package/config/agent/skills/{chroma → codebase-design}/LICENSE +1 -1
  8. package/config/agent/skills/codebase-design/SKILL.md +118 -0
  9. package/config/agent/skills/codebase-design/agents/openai.yaml +3 -0
  10. package/config/agent/skills/domain-modeling/ADR-FORMAT.md +47 -0
  11. package/config/agent/skills/domain-modeling/GLOSSARY-FORMAT.md +61 -0
  12. package/config/agent/skills/{fireworks-tech-graph → domain-modeling}/LICENSE +1 -1
  13. package/config/agent/skills/domain-modeling/SKILL.md +78 -0
  14. package/config/agent/skills/domain-modeling/agents/openai.yaml +3 -0
  15. package/config/agent/skills/frontend-design/SKILL.md +55 -26
  16. package/config/agent/skills/grill-with-docs/LICENSE +21 -0
  17. package/config/agent/skills/grill-with-docs/SKILL.md +21 -0
  18. package/config/agent/skills/grill-with-docs/agents/openai.yaml +5 -0
  19. package/config/agent/skills/grilling/LICENSE +21 -0
  20. package/config/agent/skills/grilling/SKILL.md +34 -0
  21. package/config/agent/skills/grilling/agents/openai.yaml +3 -0
  22. package/config/agent/skills/tdd/LICENSE +21 -0
  23. package/config/agent/skills/tdd/SKILL.md +42 -0
  24. package/config/agent/skills/tdd/agents/openai.yaml +3 -0
  25. package/config/agent/skills/tdd/mocking.md +59 -0
  26. package/config/agent/skills/tdd/tests.md +77 -0
  27. package/config/agent/skills/ui-taste/CHECKSUMS.sha256 +25 -0
  28. package/config/agent/skills/{milvus-skill → ui-taste}/LICENSE +12 -23
  29. package/config/agent/skills/ui-taste/MANIFEST.json +256 -0
  30. package/config/agent/skills/ui-taste/MODIFICATIONS.md +23 -0
  31. package/config/agent/skills/ui-taste/NOTICE +74 -0
  32. package/config/agent/skills/ui-taste/SKILL.md +90 -0
  33. package/config/agent/skills/ui-taste/agents/openai.yaml +4 -0
  34. package/config/agent/skills/ui-taste/reference/anti-slop-craft.md +138 -0
  35. package/config/agent/skills/ui-taste/reference/audit.md +71 -0
  36. package/config/agent/skills/ui-taste/reference/audit.native.md +78 -0
  37. package/config/agent/skills/ui-taste/reference/craft.md +48 -0
  38. package/config/agent/skills/ui-taste/reference/distill.md +20 -0
  39. package/config/agent/skills/ui-taste/reference/image-assets.md +31 -0
  40. package/config/agent/skills/ui-taste/reference/ios.md +35 -0
  41. package/config/agent/skills/ui-taste/reference/mobile-controls.md +37 -0
  42. package/config/agent/skills/ui-taste/reference/mobile-state-performance.md +34 -0
  43. package/config/agent/skills/ui-taste/reference/native-verification.md +33 -0
  44. package/config/agent/skills/ui-taste/reference/new-work.md +87 -0
  45. package/config/agent/skills/ui-taste/reference/operate.md +37 -0
  46. package/config/agent/skills/ui-taste/reference/overdrive.md +65 -0
  47. package/config/agent/skills/ui-taste/reference/polish.md +63 -0
  48. package/config/agent/skills/ui-taste/reference/research.md +45 -0
  49. package/config/agent/skills/ui-taste/references/uizze-image-to-ui.md +77 -0
  50. package/config/agent/skills/ui-taste/references/uizze-reference-policy.md +27 -0
  51. package/config/agent/skills/ui-taste/references/uizze-visual-verification.md +62 -0
  52. package/config/agent/skills/ui-taste/scripts/verify-visual-evidence.mjs +108 -0
  53. package/package.json +5 -5
  54. package/scripts/postinstall.js +19 -0
  55. package/config/agent/extensions/aicode-safety-guard.ts +0 -924
  56. package/config/agent/skills/chroma/chroma-local/SKILL.md +0 -165
  57. package/config/agent/skills/chroma/chroma-local/cli.md +0 -48
  58. package/config/agent/skills/chroma/chroma-local/data-model.md +0 -103
  59. package/config/agent/skills/chroma/chroma-local/error-handling/python.md +0 -166
  60. package/config/agent/skills/chroma/chroma-local/error-handling/typescript.md +0 -231
  61. package/config/agent/skills/chroma/chroma-local/local-chroma/python.md +0 -95
  62. package/config/agent/skills/chroma/chroma-local/local-chroma/typescript.md +0 -101
  63. package/config/agent/skills/chroma/chroma-local/metadata/python.md +0 -154
  64. package/config/agent/skills/chroma/chroma-local/metadata/typescript.md +0 -153
  65. package/config/agent/skills/chroma/chroma-local/querying/python.md +0 -147
  66. package/config/agent/skills/chroma/chroma-local/querying/typescript.md +0 -157
  67. package/config/agent/skills/chroma/chroma-local/regex/python.md +0 -69
  68. package/config/agent/skills/chroma/chroma-local/regex/typescript.md +0 -71
  69. package/config/agent/skills/chroma/chroma-local/understanding-a-codebase.md +0 -80
  70. package/config/agent/skills/chroma/chroma-local/updating-deleting/python.md +0 -159
  71. package/config/agent/skills/chroma/chroma-local/updating-deleting/typescript.md +0 -228
  72. package/config/agent/skills/find-skills/SKILL.md +0 -137
  73. package/config/agent/skills/fireworks-tech-graph/README.md +0 -528
  74. package/config/agent/skills/fireworks-tech-graph/README.zh.md +0 -499
  75. package/config/agent/skills/fireworks-tech-graph/SKILL.md +0 -538
  76. package/config/agent/skills/fireworks-tech-graph/agentloop-core.svg +0 -101
  77. package/config/agent/skills/fireworks-tech-graph/agents/openai.yaml +0 -4
  78. package/config/agent/skills/fireworks-tech-graph/assets/samples/sample-style1-flat.png +0 -0
  79. package/config/agent/skills/fireworks-tech-graph/assets/samples/sample-style2-dark.png +0 -0
  80. package/config/agent/skills/fireworks-tech-graph/assets/samples/sample-style3-blueprint.png +0 -0
  81. package/config/agent/skills/fireworks-tech-graph/assets/samples/sample-style4-notion.png +0 -0
  82. package/config/agent/skills/fireworks-tech-graph/assets/samples/sample-style5-glass.png +0 -0
  83. package/config/agent/skills/fireworks-tech-graph/assets/samples/sample-style6-claude.png +0 -0
  84. package/config/agent/skills/fireworks-tech-graph/assets/samples/sample-style7-openai.png +0 -0
  85. package/config/agent/skills/fireworks-tech-graph/fixtures/agent-memory-types-style4.json +0 -181
  86. package/config/agent/skills/fireworks-tech-graph/fixtures/api-flow-style7.json +0 -40
  87. package/config/agent/skills/fireworks-tech-graph/fixtures/mem0-style1.json +0 -297
  88. package/config/agent/skills/fireworks-tech-graph/fixtures/microservices-style3.json +0 -64
  89. package/config/agent/skills/fireworks-tech-graph/fixtures/multi-agent-style5.json +0 -45
  90. package/config/agent/skills/fireworks-tech-graph/fixtures/system-architecture-style6.json +0 -48
  91. package/config/agent/skills/fireworks-tech-graph/fixtures/tool-call-style2.json +0 -182
  92. package/config/agent/skills/fireworks-tech-graph/package.json +0 -42
  93. package/config/agent/skills/fireworks-tech-graph/references/icons.md +0 -406
  94. package/config/agent/skills/fireworks-tech-graph/references/style-1-flat-icon.md +0 -108
  95. package/config/agent/skills/fireworks-tech-graph/references/style-2-dark-terminal.md +0 -107
  96. package/config/agent/skills/fireworks-tech-graph/references/style-3-blueprint.md +0 -113
  97. package/config/agent/skills/fireworks-tech-graph/references/style-4-notion-clean.md +0 -94
  98. package/config/agent/skills/fireworks-tech-graph/references/style-5-glassmorphism.md +0 -125
  99. package/config/agent/skills/fireworks-tech-graph/references/style-6-claude-official.md +0 -209
  100. package/config/agent/skills/fireworks-tech-graph/references/style-7-openai.md +0 -215
  101. package/config/agent/skills/fireworks-tech-graph/references/style-diagram-matrix.md +0 -135
  102. package/config/agent/skills/fireworks-tech-graph/references/svg-layout-best-practices.md +0 -100
  103. package/config/agent/skills/fireworks-tech-graph/scripts/README.md +0 -244
  104. package/config/agent/skills/fireworks-tech-graph/scripts/generate-diagram.sh +0 -157
  105. package/config/agent/skills/fireworks-tech-graph/scripts/generate-from-template.py +0 -1556
  106. package/config/agent/skills/fireworks-tech-graph/scripts/test-all-styles.sh +0 -135
  107. package/config/agent/skills/fireworks-tech-graph/scripts/validate-svg.sh +0 -292
  108. package/config/agent/skills/fireworks-tech-graph/templates/agent-architecture.svg +0 -28
  109. package/config/agent/skills/fireworks-tech-graph/templates/architecture.svg +0 -23
  110. package/config/agent/skills/fireworks-tech-graph/templates/comparison-matrix.svg +0 -14
  111. package/config/agent/skills/fireworks-tech-graph/templates/data-flow.svg +0 -28
  112. package/config/agent/skills/fireworks-tech-graph/templates/er-diagram.svg +0 -21
  113. package/config/agent/skills/fireworks-tech-graph/templates/flowchart.svg +0 -21
  114. package/config/agent/skills/fireworks-tech-graph/templates/sequence.svg +0 -20
  115. package/config/agent/skills/fireworks-tech-graph/templates/state-machine.svg +0 -20
  116. package/config/agent/skills/fireworks-tech-graph/templates/timeline.svg +0 -19
  117. package/config/agent/skills/fireworks-tech-graph/templates/use-case.svg +0 -21
  118. package/config/agent/skills/hello/SKILL.md +0 -26
  119. package/config/agent/skills/librarian/SKILL.md +0 -199
  120. package/config/agent/skills/milvus-skill/README.md +0 -37
  121. package/config/agent/skills/milvus-skill/SKILL.md +0 -259
  122. package/config/agent/skills/milvus-skill/references/collection.md +0 -86
  123. package/config/agent/skills/milvus-skill/references/database.md +0 -24
  124. package/config/agent/skills/milvus-skill/references/index.md +0 -69
  125. package/config/agent/skills/milvus-skill/references/partition.md +0 -29
  126. package/config/agent/skills/milvus-skill/references/patterns.md +0 -150
  127. package/config/agent/skills/milvus-skill/references/user-role.md +0 -90
  128. package/config/agent/skills/milvus-skill/references/vector.md +0 -247
  129. package/config/agent/skills/pr/SKILL.md +0 -59
@@ -1,165 +0,0 @@
1
- ---
2
- name: chroma-local
3
- description: Use when the user needs self-hosted or local Chroma for semantic search, including `ChromaClient`, `HttpClient`, or Python `EphemeralClient`, local persistence, Docker or `chroma run`, or OSS Chroma without Chroma Cloud features.
4
- ---
5
-
6
- ## Instructions
7
-
8
- Determine these before writing code. Prefer discovering them from the repo and the user request. Ask only when the choice materially changes the implementation.
9
-
10
- 1. **Runtime shape**
11
- - Are they connecting to a running local server, embedding Chroma into tests, or setting up local development from scratch?
12
- - Decide whether they need `chroma run`, a Docker or service command, `HttpClient` or `ChromaClient`, or Python `EphemeralClient`.
13
-
14
- 2. **Persistence**
15
- - Persistent local data: choose an intentional data path.
16
- - Disposable test data: use defaults or a temp directory.
17
-
18
- 3. **Embedding model**
19
- - Reuse the app's existing embedding provider when possible.
20
- - Otherwise default to `@chroma-core/default-embed` in TypeScript or the standard local default in Python.
21
- - If the user explicitly wants OpenAI embeddings in TypeScript, install and use `@chroma-core/openai`.
22
-
23
- 4. **Indexed data shape**
24
- - Determine what is being indexed, how it should be chunked, and what metadata is needed for filtering and updates.
25
-
26
- ## Routing
27
-
28
- - **Existing local server**
29
- - Confirm host and port before changing client code.
30
- - Validate the server is reachable before assuming collections are missing.
31
-
32
- - **Fresh local development**
33
- - Add a local startup path such as `chroma run` or the repo's existing Docker or service command.
34
- - Default to `localhost:8000` unless the repo already uses another address.
35
-
36
- - **Python tests or disposable local workflows**
37
- - Prefer `EphemeralClient` when persistence is unnecessary.
38
- - Call out that data is lost when the process exits.
39
-
40
- - **Persistent local development**
41
- - Use a stable data path and make persistence explicit in code or config.
42
- - Do not silently switch between ephemeral and persistent modes.
43
-
44
- - **Search integration work**
45
- - Use `getOrCreateCollection()` in TypeScript or `get_or_create_collection()` in Python.
46
- - Design document IDs and metadata so upserts and deletes are straightforward.
47
- - Batch writes when syncing large datasets.
48
-
49
- ## Ask vs proceed
50
-
51
- **Ask first:**
52
- - Embedding model choice (cost and quality implications)
53
- - Whether they need persistent local data
54
- - How they are starting the local server
55
- - Multi-tenant data isolation strategy
56
-
57
- **Proceed with sensible defaults:**
58
- - Use `getOrCreateCollection()` (TypeScript) / `get_or_create_collection()` (Python)
59
- - Use cosine similarity (most common)
60
- - Chunk size under 8KB
61
- - Store source IDs in metadata for updates/deletes
62
- - Use a local server on `localhost:8000` unless the repo already configures another address or is using Python `EphemeralClient`
63
-
64
- ## What to validate
65
-
66
- - Correct client import (`ChromaClient`, `HttpClient`, or `Client`)
67
- - Embedding function package is installed (TypeScript)
68
- - Local server is reachable before assuming collections are missing
69
- - Local path and persistence mode are intentional
70
-
71
- ## Implementation notes
72
-
73
- - Local Chroma is the right default for development, tests, and self-hosted deployments.
74
- - OSS Chroma does not include Chroma Cloud-only features such as `Schema()` and `Search()`.
75
- - If the user asks for hybrid dense and sparse retrieval, treat that as a likely Chroma Cloud requirement unless the repo already implements an OSS workaround.
76
- - For open source Chroma, dense retrieval with a single embedding function is the normal baseline.
77
-
78
- ## Minimal patterns
79
-
80
- Start a local Chroma server when the repo needs one:
81
-
82
- ```bash
83
- chroma run
84
- ```
85
-
86
- Default address: `localhost:8000`.
87
-
88
- TypeScript local client:
89
-
90
- ```typescript
91
- import { ChromaClient } from 'chromadb';
92
- import { DefaultEmbeddingFunction } from '@chroma-core/default-embed';
93
-
94
- const client = new ChromaClient();
95
-
96
- const embeddingFunction = new DefaultEmbeddingFunction();
97
- const collection = await client.getOrCreateCollection({
98
- name: 'my_collection',
99
- embeddingFunction,
100
- });
101
-
102
- // Add documents
103
- await collection.add({
104
- ids: ['doc1', 'doc2'],
105
- documents: ['First document text', 'Second document text'],
106
- });
107
-
108
- // Query
109
- const results = await collection.query({
110
- queryTexts: ['search query'],
111
- nResults: 5,
112
- });
113
- ```
114
-
115
- Python local client:
116
-
117
- ```python
118
- import chromadb
119
-
120
- client = chromadb.HttpClient(host="localhost", port=8000)
121
-
122
- collection = client.get_or_create_collection(name="my_collection")
123
-
124
- # Add documents
125
- collection.add(
126
- ids=["doc1", "doc2"] ,
127
- documents=["First document text", "Second document text"],
128
- )
129
-
130
- # Query
131
- results = collection.query(
132
- query_texts=["search query"],
133
- n_results=5,
134
- )
135
- ```
136
-
137
- ## Learn More
138
-
139
- Fetch Chroma's `llms.txt` only when you need API or product details that are not already in the repo or this skill: https://docs.trychroma.com/llms.txt
140
-
141
- ## Available Topics
142
-
143
- ### Typescript
144
-
145
- - [Chroma Regex Filtering](./regex/typescript.md) - Learn how to use regex filters in Chroma queries
146
- - [Query and Get](./querying/typescript.md) - Query and Get Data from Chroma Collections
147
- - [Metadata](./metadata/typescript.md) - Store and query metadata, including filters and array values
148
- - [Updating and Deleting](./updating-deleting/typescript.md) - Update existing documents and delete data from collections
149
- - [Error Handling](./error-handling/typescript.md) - Handling errors and failures when working with Chroma
150
- - [Local Chroma](./local-chroma/typescript.md) - How to run and use local chroma
151
-
152
- ### Python
153
-
154
- - [Chroma Regex Filtering](./regex/python.md) - Learn how to use regex filters in Chroma queries
155
- - [Query and Get](./querying/python.md) - Query and Get Data from Chroma Collections
156
- - [Metadata](./metadata/python.md) - Store and query metadata, including filters and array values
157
- - [Updating and Deleting](./updating-deleting/python.md) - Update existing documents and delete data from collections
158
- - [Error Handling](./error-handling/python.md) - Handling errors and failures when working with Chroma
159
- - [Local Chroma](./local-chroma/python.md) - How to run and use local chroma
160
-
161
- ## General
162
-
163
- - [Data Model](./data-model.md) - An overview of how Chroma stores data
164
- - [Integrating Chroma into an existing system](./understanding-a-codebase.md) - Guidance for adding Chroma search to an existing application
165
- - [Chroma CLI](./cli.md) - Starting and managing a local open source Chroma server from the CLI
@@ -1,48 +0,0 @@
1
- ---
2
- name: Chroma CLI
3
- description: Starting and managing a local open source Chroma server from the CLI
4
- ---
5
-
6
- ## Chroma CLI
7
-
8
- The Chroma CLI can also be used for local open source Chroma workflows. This topic focuses on starting and managing a local server, not Chroma Cloud account setup.
9
-
10
- ### Install
11
-
12
- ```bash
13
- pip install chromadb
14
- ```
15
-
16
- ### Start a local server
17
-
18
- Run Chroma locally on the default address:
19
-
20
- ```bash
21
- chroma run
22
- ```
23
-
24
- This starts a server on `localhost:8000`.
25
-
26
- ### Choose a persistent data directory
27
-
28
- Store local data in a specific path instead of the default working directory:
29
-
30
- ```bash
31
- chroma run --path ./chroma-data
32
- ```
33
-
34
- ### Change the port
35
-
36
- If another process already uses port `8000`, pick another one:
37
-
38
- ```bash
39
- chroma run --port 8001
40
- ```
41
-
42
- Update your client code to match the chosen host and port.
43
-
44
- ### Local workflow tips
45
-
46
- - Use a dedicated data directory per environment so dev and test data do not mix.
47
- - In tests, use disposable directories or clear collections between runs.
48
- - Check that the server is running before debugging client-side collection errors.
@@ -1,103 +0,0 @@
1
- ---
2
- name: Data Model
3
- description: An overview of how Chroma stores data
4
- ---
5
-
6
- ## Data Model
7
-
8
- Use this reference when designing collection layout, chunking, IDs, metadata, and filtering for Chroma.
9
-
10
- ### Core concepts
11
-
12
- **Collections** are the top-level containers, similar to tables in a relational database. Each collection has its own embedding configuration and indexes.
13
-
14
- **Documents** are the searchable units within a collection. Each document has:
15
- - **ID** - A unique string identifier
16
- - **Content** - The text that gets embedded and searched
17
- - **Embedding** - The vector representation
18
- - **Metadata** - Key-value pairs for filtering
19
-
20
- ## Chunking
21
-
22
- Most real-world data is too large to fit in a single document. Chunking splits content into searchable pieces.
23
-
24
- ### Chunking strategy
25
-
26
- **Recommended chunk size:** Keep chunks comfortably below product limits and small enough to preserve search precision and context. Generally, 8KB or less is a good default starting point.
27
-
28
- **Good chunking preserves meaning:**
29
- - Split at natural boundaries (paragraphs, sentences, sections)
30
- - Don't cut mid-sentence or mid-word
31
- - Include enough context for the chunk to be meaningful on its own
32
-
33
- **Determine from the repo or ask if ambiguous:**
34
- - What type of content are they indexing?
35
- - Are there natural boundaries (chapters, sections, records)?
36
- - How much context does a search result need to be useful?
37
-
38
- ### Tracking chunks with metadata
39
-
40
- When a single source document becomes multiple chunks, use metadata to track the relationship:
41
-
42
- ```
43
- {
44
- "source_id": "post-123", // ID in the primary database
45
- "source_type": "blog_post", // Type of content
46
- "chunk_index": 0, // Position in sequence
47
- "total_chunks": 3 // Total chunks from this source
48
- }
49
- ```
50
-
51
- This approach is better than encoding information in the document ID because:
52
- - IDs can be simple UUIDs
53
- - Metadata is filterable
54
- - Updates and deletes are easier (filter by `source_id`)
55
-
56
- ## Collection organization
57
-
58
- For multi-tenant applications, separate collections per tenant are a strong default when isolation, deletion, and search quality matter more than minimizing collection count.
59
-
60
- **Why this works better:**
61
- - Nearest neighbor search is more accurate with fewer candidates
62
- - Lower latency with smaller collections
63
- - Natural isolation between tenants
64
- - Easy to delete all tenant data by dropping the collection
65
-
66
- **Example:** A knowledge base SaaS might have collections like `kb_customer_123`, `kb_customer_456`, etc.
67
-
68
- **Determine from the repo or ask if ambiguous:** What's the smallest logical unit of data isolation in their application?
69
-
70
- ## Filtering
71
-
72
- Metadata filtering reduces the candidate set before vector search runs, making queries faster and more precise.
73
-
74
- ### Filter operators
75
-
76
- | Operator | Description | Types |
77
- |----------|-------------|-------|
78
- | `$eq` | Equal (default) | string, int, bool |
79
- | `$ne` | Not equal | string, int, bool |
80
- | `$gt`, `$gte` | Greater than (or equal) | int |
81
- | `$lt`, `$lte` | Less than (or equal) | int |
82
- | `$in` | In list | string, int |
83
- | `$nin` | Not in list | string, int |
84
- | `$and`, `$or` | Logical combinators | filter arrays |
85
- | `$contains`, `$not_contains` | Check within arrays | arrays of string, int, bool |
86
-
87
- ### Document content filtering
88
-
89
- Beyond metadata, you can filter on the document text itself using `where_document`:
90
- - `$contains` - Full-text substring search
91
- - `$regex` - Regular expression matching
92
-
93
- ## Dense vs sparse vectors
94
-
95
- **Dense vectors** (default) are produced by neural embedding models. They capture semantic meaning, so "car" and "automobile" will be similar.
96
-
97
- **Sparse vectors** (BM25, SPLADE) are high-dimensional but mostly zeros. They excel at exact keyword matching.
98
-
99
- **Hybrid search** combines both, often outperforming either alone. Chroma Cloud supports hybrid search through the Schema and Search APIs.
100
-
101
- ### Important note
102
-
103
- When creating collections, `get_or_create_collection()` accepts either an `embedding_function` OR a `schema`, but not both. Use Schema when you need multiple indexes or sparse embeddings.
@@ -1,166 +0,0 @@
1
- ---
2
- name: Error Handling
3
- description: Handling errors and failures when working with Chroma
4
- ---
5
-
6
- ## Error Handling
7
-
8
- Local Chroma operations can fail for various reasons: the local server may not be running, collections may be missing, or input data may be invalid. This guide covers the common local error scenarios and how to handle them.
9
-
10
- ```python
11
- import json
12
- import time
13
-
14
- import chromadb
15
- from chromadb.errors import NotFoundError
16
- from chromadb.types import Metadata
17
- ```
18
-
19
- ### Error types
20
-
21
- **Python** uses specific exception classes:
22
- - `chromadb.errors.NotFoundError` - Collection, tenant, or database doesn't exist
23
- - `ValueError` - Invalid collection name or duplicate creation attempt
24
-
25
- **TypeScript** throws standard `Error` objects with descriptive messages. Check the error message to determine the cause.
26
-
27
- ### Connection errors
28
-
29
- Connection failures occur when the client can't reach the Chroma server. This is common during startup or when network issues occur.
30
-
31
- ```python
32
- def connect_with_retry(max_retries: int = 3):
33
- """Connect to a local Chroma server with exponential backoff retry."""
34
- client = chromadb.HttpClient(host="localhost", port=8000)
35
-
36
- for attempt in range(1, max_retries + 1):
37
- try:
38
- client.heartbeat()
39
- return client
40
- except Exception as e:
41
- if attempt == max_retries:
42
- raise ConnectionError(
43
- f"Failed to connect to local Chroma after {max_retries} attempts: {e}"
44
- )
45
-
46
- time.sleep(2 ** (attempt - 1))
47
-
48
- raise ConnectionError("Chroma is unreachable")
49
- ```
50
-
51
- ### Collection not found
52
-
53
- When working with collections that may not exist, handle the `NotFoundError` (Python) or catch the error and check its message (TypeScript).
54
-
55
- ```python
56
- client = chromadb.HttpClient(host="localhost", port=8000)
57
-
58
- try:
59
- collection = client.get_collection(name="my_collection")
60
- except NotFoundError:
61
- print("Collection not found, creating it...")
62
- collection = client.create_collection(name="my_collection")
63
- ```
64
-
65
- ### Safe collection access pattern
66
-
67
- The `getOrCreateCollection` method is the recommended way to avoid "not found" errors entirely. Use `getCollection` only when you specifically need to verify a collection exists.
68
-
69
- ```python
70
- client = chromadb.HttpClient(host="localhost", port=8000)
71
- collection = client.get_or_create_collection(name="my_collection")
72
-
73
- results = collection.query(
74
- query_texts=["search query"],
75
- n_results=5,
76
- )
77
-
78
- if results["documents"] and len(results["documents"][0]) > 0:
79
- first_doc = results["documents"][0][0]
80
- else:
81
- pass
82
- ```
83
-
84
- ### Validation errors
85
-
86
- Chroma validates data before operations. Common validation failures include:
87
- - Document content exceeding 16KB
88
- - Embedding dimensions not matching the collection
89
- - Metadata exceeding limits (4KB total, 32 keys max)
90
- - Invalid collection names
91
-
92
- ```python
93
- client = chromadb.HttpClient(host="localhost", port=8000)
94
-
95
-
96
- def validate_document(doc: str) -> bool:
97
- byte_size = len(doc.encode("utf-8"))
98
- return byte_size <= 16384
99
-
100
-
101
- def validate_metadata(metadata: Metadata) -> bool:
102
- if len(metadata.keys()) > 32:
103
- return False
104
-
105
- json_size = len(json.dumps(metadata).encode("utf-8"))
106
- return json_size <= 4096
107
-
108
-
109
- def safe_add(
110
- collection_name: str,
111
- ids: list[str],
112
- documents: list[str],
113
- metadatas: list[Metadata] | None
114
- ) -> None:
115
- for doc in documents:
116
- if not validate_document(doc):
117
- raise ValueError("Document exceeds 16KB limit")
118
-
119
- if metadatas:
120
- for meta in metadatas:
121
- if not validate_metadata(meta):
122
- raise ValueError("Metadata exceeds limits (4KB or 32 keys)")
123
-
124
- collection = client.get_or_create_collection(name=collection_name)
125
- collection.add(ids=ids, documents=documents, metadatas=metadatas)
126
- ```
127
-
128
- ### Batch operation failures
129
-
130
- When adding or upserting multiple documents, a single invalid document fails the entire batch. Validate data before sending, or implement retry logic for partial failures.
131
-
132
- ```python
133
- client = chromadb.HttpClient(host="localhost", port=8000)
134
-
135
-
136
- def batch_add(
137
- collection_name: str,
138
- ids: list[str],
139
- documents: list[str],
140
- batch_size: int = 100,
141
- ) -> dict:
142
- collection = client.get_or_create_collection(name=collection_name)
143
- failures = []
144
-
145
- for i in range(0, len(ids), batch_size):
146
- batch_ids = ids[i : i + batch_size]
147
- batch_docs = documents[i : i + batch_size]
148
-
149
- try:
150
- collection.add(ids=batch_ids, documents=batch_docs)
151
- except Exception as e:
152
- failures.append({"index": i, "error": str(e)})
153
-
154
- total_batches = (len(ids) + batch_size - 1) // batch_size
155
- return {"total_batches": total_batches, "failures": failures}
156
- ```
157
-
158
- ### Defensive patterns summary
159
-
160
- | Scenario | Recommended approach |
161
- |----------|---------------------|
162
- | Collection access | Use `getOrCreateCollection` instead of `getCollection` |
163
- | Missing data | Check results length before accessing |
164
- | Connection issues | Implement retry with exponential backoff |
165
- | Large batches | Validate data size before operations |
166
- | Local server startup | Verify the server is running before debugging query logic |