Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,48 @@ permissions:
contents: read

jobs:
java:
runs-on: ubuntu-latest
strategy:
matrix:
java: [11, 17]
# The external session storage contract tests run against these services.
services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 3s
--health-retries 10
postgres:
image: postgres:17-alpine
env:
POSTGRES_USER: qoder
POSTGRES_PASSWORD: qoder
POSTGRES_DB: qoder_session_store
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U qoder -d qoder_session_store"
--health-interval 5s
--health-timeout 3s
--health-retries 10
env:
QODER_SAMPLE_TEST_REDIS_URL: redis://127.0.0.1:6379
QODER_SAMPLE_TEST_POSTGRES_URL: postgresql://qoder:qoder@127.0.0.1:5432/qoder_session_store
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java }}
- name: Build and test Java samples from Central
run: mvn -B -ntp -Dmaven.repo.local="${{ runner.temp }}/java-maven-cache" clean verify
working-directory: java

typescript:
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ __pycache__/
# Editors
.idea/
.vscode/

# Java / Maven
target/
32 changes: 32 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ this repository.
environment (see the sample README). Maintainer checks use
[`uv`](https://docs.astral.sh/uv/); contributors do not need `uv` to run a
sample.
- Java: JDK 11 or later (17 recommended) and Maven 3.6.3 or later. Run
`mvn clean verify` from `java/`, or build a sample from its own directory.

## Sample requirements

Expand All @@ -42,6 +44,12 @@ Every sample must:
- Avoid shared source modules that hide the SDK calls being demonstrated.
- Keep generated files and expected model output out of the sample directory.

Java coverage is incremental. Keep Java ports behaviorally equivalent and mark
missing Java entries with an em dash in both indexes.
Document differences required by the released Java API and verify them with the
actual SDK/CLI pair. Adding a Java port of an existing concept does not require
porting unrelated concepts.

## Adding a new sample

Use an existing sample (for example, `quickstart`) as a template, then register
Expand All @@ -61,6 +69,29 @@ kebab-case sample name.
5. **List it in both READMEs:** add a row to the sample table in `README.md` and
in `README.zh-CN.md`.

For a Java port, create `java/<sample>/` with a standalone `pom.xml`, a README,
and sources under `src/main/java`. Register it in `java/pom.xml` and both sample
indexes. The Java CI job builds every registered module. Pin a released Central
SDK version, compile with `--release 8`, and keep the sample independent of
the aggregator and any SDK source checkout. Tests must run without credentials
or a real CLI; document real queries as opt-in checks.

When updating the Java SDK, update every sample's `qoder.sdk.version` and any
explicit dependency versions, both root README compatibility lists, the Java
overview coordinate, and affected sample requirements. Validate the published
artifact using an empty Maven local repository:

```bash
cd java
mvn -B -ntp -Dmaven.repo.local=/path/to/empty/maven-cache clean verify
```

Use Central or a verified Central mirror, and build each changed sample from
its own directory as well. For real queries, use the SDK's managed CLI; record
the SDK/CLI versions and platform actually exercised. Keep historical
verification records accurate. A newer version in registry metadata or a green
compile is not a real-runtime compatibility result.

Keep the TypeScript and Python versions behaviorally equivalent so readers can
switch between languages. When one concept has multiple independently copyable
variants, keep them in one sample directory and list every entry in its README.
Expand All @@ -80,6 +111,7 @@ cd ../python && uv sync && uv run ruff check . && uv run ruff format --check .
for sample in quickstart multi-turn-conversation streaming-chat code-review tool-permissions ask-user-question model-selection hooks custom-tools subagents external-session-storage; do
uv run mypy "$sample"
done
cd ../java && mvn -B -ntp clean verify
```

If `ruff format --check` reports changes, run `uv run ruff format .` to apply
Expand Down
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Qoder Agent SDK Samples

Runnable, focused examples for building applications with the Qoder Agent SDK.
Every sample is available in TypeScript and Python.
Samples are available in TypeScript, Python, and Java, with coverage listed below.

## Application templates

Expand All @@ -11,19 +11,19 @@ Every sample is available in TypeScript and Python.

## Samples

| Sample | What it demonstrates | TypeScript | Python |
| --- | --- | --- | --- |
| Quickstart | Run one repository-aware query and handle the result | [Open](typescript/quickstart) | [Open](python/quickstart) |
| Multi-turn conversation | Control the query lifecycle and resume context after closing | [Open](typescript/multi-turn-conversation) | [Open](python/multi-turn-conversation) |
| Streaming chat | Stream output while keeping one live session open | [Open](typescript/streaming-chat) | [Open](python/streaming-chat) |
| Code review | Review a Git diff with read-only repository tools | [Open](typescript/code-review) | [Open](python/code-review) |
| Tool permissions | Separate tool visibility, pre-approval, and runtime authorization | [Open](typescript/tool-permissions) | [Open](python/tool-permissions) |
| Ask user question | Render structured questions and return user answers | [Open](typescript/ask-user-question) | [Open](python/ask-user-question) |
| Model selection | List models and select context-window and reasoning parameters | [Open](typescript/model-selection) | [Open](python/model-selection) |
| Hooks | Add lifecycle observation, context injection, and tool policy | [Open](typescript/hooks) | [Open](python/hooks) |
| Custom tools | Expose application functions as in-process MCP tools | [Open](typescript/custom-tools) | [Open](python/custom-tools) |
| Subagents | Delegate a task to specialized SDK-defined agents | [Open](typescript/subagents) | [Open](python/subagents) |
| External session storage | Resume a session on another runtime through Redis or PostgreSQL | [Open](typescript/external-session-storage) | [Open](python/external-session-storage) |
| Sample | What it demonstrates | TypeScript | Python | Java |
| --- | --- | --- | --- | --- |
| Quickstart | Run one repository-aware query and handle the result | [Open](typescript/quickstart) | [Open](python/quickstart) | [Open](java/quickstart) |
| Multi-turn conversation | Control the query lifecycle and resume context after closing | [Open](typescript/multi-turn-conversation) | [Open](python/multi-turn-conversation) | [Open](java/multi-turn-conversation) |
| Streaming chat | Stream output while keeping one live session open | [Open](typescript/streaming-chat) | [Open](python/streaming-chat) | [Open](java/streaming-chat) |
| Code review | Review a Git diff with read-only repository tools | [Open](typescript/code-review) | [Open](python/code-review) | [Open](java/code-review) |
| Tool permissions | Separate tool visibility, pre-approval, and runtime authorization | [Open](typescript/tool-permissions) | [Open](python/tool-permissions) | [Open](java/tool-permissions) |
| Ask user question | Render structured questions and return user answers | [Open](typescript/ask-user-question) | [Open](python/ask-user-question) | [Open](java/ask-user-question) |
| Model selection | List models and select context-window and reasoning parameters | [Open](typescript/model-selection) | [Open](python/model-selection) | [Open](java/model-selection) |
| Hooks | Add lifecycle observation, context injection, and tool policy | [Open](typescript/hooks) | [Open](python/hooks) | [Open](java/hooks) |
| Custom tools | Expose application functions as in-process MCP tools | [Open](typescript/custom-tools) | [Open](python/custom-tools) | [Open](java/custom-tools) |
| Subagents | Delegate a task to specialized SDK-defined agents | [Open](typescript/subagents) | [Open](python/subagents) | [Open](java/subagents) |
| External session storage | Resume a session on another runtime through Redis or PostgreSQL | [Open](typescript/external-session-storage) | [Open](python/external-session-storage) | [Open](java/external-session-storage) |

## Setup

Expand All @@ -43,20 +43,23 @@ For the complete API guide, see the

- TypeScript samples: Node.js 18 or later
- Python samples: Python 3.10 or later
- Java samples: JDK 11 or later (17 recommended), Maven 3.6.3 or later; see [Java setup](java)
- Qoder authentication configured as described above

Each sample is self-contained. Open its README for installation and run
commands.

## Compatibility

The sample manifests declare compatible SDK version ranges, while the
repository lockfiles record the exact versions used by CI.
TypeScript and Python manifests declare compatible SDK version ranges; their
lockfiles record the exact versions used by CI. Java POMs pin SDK 0.2.5 from
Maven Central and compile with `--release 8`.

Last verified on July 29, 2026:
Dependency versions (build and runtime checks are reported separately):

- TypeScript SDK 1.0.16
- Python SDK 1.0.10
- Java SDK 0.2.5

## License and terms

Expand Down
37 changes: 20 additions & 17 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Qoder Agent SDK Samples

本仓库提供面向实际开发者的 Qoder Agent SDK 示例。每个场景同时提供
TypeScript 和 Python 实现。
本仓库提供面向实际开发者的 Qoder Agent SDK 示例,包含 TypeScript、Python 和 Java 实现;
各语言的覆盖范围见下表。

## 应用样板

Expand All @@ -11,19 +11,19 @@ TypeScript 和 Python 实现。

## 示例列表

| 示例 | 展示内容 | TypeScript | Python |
| --- | --- | --- | --- |
| Quickstart | 发起一次理解代码仓库的查询并处理结果 | [查看](typescript/quickstart) | [查看](python/quickstart) |
| Multi-turn conversation | 控制 query 生命周期并在关闭后恢复上下文 | [查看](typescript/multi-turn-conversation) | [查看](python/multi-turn-conversation) |
| Streaming chat | 在一个持续连接的会话中进行流式输出 | [查看](typescript/streaming-chat) | [查看](python/streaming-chat) |
| Code review | 使用只读仓库工具审查 Git diff | [查看](typescript/code-review) | [查看](python/code-review) |
| Tool permissions | 区分工具可见性、预授权和运行时授权 | [查看](typescript/tool-permissions) | [查看](python/tool-permissions) |
| Ask user question | 渲染结构化问题并将用户回答返回给 Agent | [查看](typescript/ask-user-question) | [查看](python/ask-user-question) |
| Model selection | 列出模型并选择上下文窗口和推理参数 | [查看](typescript/model-selection) | [查看](python/model-selection) |
| Hooks | 添加生命周期观测、上下文注入和工具策略 | [查看](typescript/hooks) | [查看](python/hooks) |
| Custom tools | 将应用函数注册为进程内 MCP 工具 | [查看](typescript/custom-tools) | [查看](python/custom-tools) |
| Subagents | 将任务委派给 SDK 定义的专业子 Agent | [查看](typescript/subagents) | [查看](python/subagents) |
| External session storage | 通过 Redis 或 PostgreSQL 在另一个运行实例上恢复会话 | [查看](typescript/external-session-storage) | [查看](python/external-session-storage) |
| 示例 | 展示内容 | TypeScript | Python | Java |
| --- | --- | --- | --- | --- |
| Quickstart | 发起一次理解代码仓库的查询并处理结果 | [查看](typescript/quickstart) | [查看](python/quickstart) | [查看](java/quickstart) |
| Multi-turn conversation | 控制 query 生命周期并在关闭后恢复上下文 | [查看](typescript/multi-turn-conversation) | [查看](python/multi-turn-conversation) | [查看](java/multi-turn-conversation) |
| Streaming chat | 在一个持续连接的会话中进行流式输出 | [查看](typescript/streaming-chat) | [查看](python/streaming-chat) | [查看](java/streaming-chat) |
| Code review | 使用只读仓库工具审查 Git diff | [查看](typescript/code-review) | [查看](python/code-review) | [查看](java/code-review) |
| Tool permissions | 区分工具可见性、预授权和运行时授权 | [查看](typescript/tool-permissions) | [查看](python/tool-permissions) | [查看](java/tool-permissions) |
| Ask user question | 渲染结构化问题并将用户回答返回给 Agent | [查看](typescript/ask-user-question) | [查看](python/ask-user-question) | [查看](java/ask-user-question) |
| Model selection | 列出模型并选择上下文窗口和推理参数 | [查看](typescript/model-selection) | [查看](python/model-selection) | [查看](java/model-selection) |
| Hooks | 添加生命周期观测、上下文注入和工具策略 | [查看](typescript/hooks) | [查看](python/hooks) | [查看](java/hooks) |
| Custom tools | 将应用函数注册为进程内 MCP 工具 | [查看](typescript/custom-tools) | [查看](python/custom-tools) | [查看](java/custom-tools) |
| Subagents | 将任务委派给 SDK 定义的专业子 Agent | [查看](typescript/subagents) | [查看](python/subagents) | [查看](java/subagents) |
| External session storage | 通过 Redis 或 PostgreSQL 在另一个运行实例上恢复会话 | [查看](typescript/external-session-storage) | [查看](python/external-session-storage) | [查看](java/external-session-storage) |

## 准备工作

Expand All @@ -37,17 +37,20 @@ export QODER_PERSONAL_ACCESS_TOKEN="<your-token>"

完整 API 指南见 [Qoder Agent SDK 文档](https://docs.qoder.com/en/cli/sdk)。
TypeScript 需要 Node.js 18 或更高版本,Python 需要 Python 3.10 或更高版本。
Java 构建需要 JDK 11 或更高版本(推荐 17)和 Maven 3.6.3 或更高版本,见 [Java 说明](java)。

每个示例都是独立项目,具体安装和运行方式见对应目录的 README。

## 兼容性

各示例的依赖清单声明了兼容的 SDK 版本范围,仓库锁文件则记录了 CI 使用的确切版本。
TypeScript/Python 依赖清单声明兼容的版本范围,锁文件记录 CI 使用的确切版本。
Java POM 固定使用 Maven Central 的 SDK 0.2.5,并以 `--release 8` 编译。

最近一次验证时间:2026 年 7 月 29 日:
依赖版本(构建与真实运行验证分别记录):

- TypeScript SDK 1.0.16
- Python SDK 1.0.10
- Java SDK 0.2.5

## 许可与条款

Expand Down
Loading
Loading