From d78017a521ee3f5fa26fdaa273d3d33af1899c1c Mon Sep 17 00:00:00 2001 From: r-hashi01 Date: Mon, 28 Sep 2026 17:32:12 +0900 Subject: [PATCH] Add what an open-source repository needs CHANGELOG.md for v0.0.1, CONTRIBUTING.md pointing at AGENTS.md for the rules, SECURITY.md sending reports to private GitHub advisories, Dify's Code of Conduct, issue and pull request templates, Dependabot for the workflows, and .env in .gitignore. The README gains badges, a note that the API may change below 1.0, and the security and license sections. Co-Authored-By: Claude Opus 5.5 --- .github/ISSUE_TEMPLATE/bug_report.yml | 39 +++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 11 ++++++ .github/ISSUE_TEMPLATE/feature_request.yml | 15 ++++++++ .github/dependabot.yml | 9 +++++ .github/pull_request_template.md | 15 ++++++++ .gitignore | 2 + CHANGELOG.md | 31 +++++++++++++++ CODE_OF_CONDUCT.md | 41 ++++++++++++++++++++ CONTRIBUTING.md | 44 ++++++++++++++++++++++ README.md | 26 ++++++++++--- SECURITY.md | 30 +++++++++++++++ 11 files changed, 258 insertions(+), 5 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/pull_request_template.md create mode 100644 CHANGELOG.md create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 SECURITY.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..3fc1c2a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,39 @@ +name: Bug report +description: The SDK sends, reads or does something wrong +labels: + - bug +body: + - type: checkboxes + attributes: + label: Self checks + options: + - label: I have searched existing issues, including closed ones. + required: true + - label: I am writing in English. + required: true + - type: input + attributes: + label: SDK version + description: The version in go.mod, or `dify.Version()`. + validations: + required: true + - type: input + attributes: + label: Dify version + description: "`dify.Probe(ctx, baseURL)` reports it, and every `*APIError` carries it." + validations: + required: true + - type: dropdown + attributes: + label: Cloud or self-hosted + options: + - Cloud + - Self-hosted + validations: + required: true + - type: textarea + attributes: + label: What happened, and what you expected + description: A minimal program that reproduces it, if you can. Leave out keys and tokens. + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..50fd4f0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,11 @@ +blank_issues_enabled: false +contact_links: + - name: "\U0001F510 Security vulnerabilities" + url: https://github.com/langgenius/dify-go-sdk/security/advisories/new + about: Report vulnerabilities privately through GitHub Security Advisories, not in a public issue. + - name: "\U0001F41E A bug in Dify itself" + url: https://github.com/langgenius/dify/issues/new/choose + about: When the server misbehaves whichever client calls it, report it to Dify. + - name: "\U0001F4AC Questions and discussion" + url: https://github.com/langgenius/dify/discussions/categories/general + about: Ask for help and discuss with the Dify community. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..ec69bda --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,15 @@ +name: Feature request +description: A Dify capability the SDK does not reach yet +labels: + - enhancement +body: + - type: textarea + attributes: + label: What you want to do + description: The task, and the Dify route or console action it needs, if you know it. + validations: + required: true + - type: textarea + attributes: + label: How you do it today + description: A workaround, the Python SDK, or the console. diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..0160775 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 + +# The module has no dependencies beyond the standard library, so the workflows +# are the only thing to keep current. +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..bd32680 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,15 @@ +## Summary + + + +## Checked against + + + +## Checklist + +- [ ] `gofmt -l .` and `go vet ./...` are clean, and `go test -race ./...` passes +- [ ] Each change has a test, named as a sentence +- [ ] User-visible changes are in CHANGELOG.md under "Unreleased" diff --git a/.gitignore b/.gitignore index 46620af..cd05652 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /coverage.out +.env +.env.* diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..4628325 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,31 @@ +# Changelog + +All notable changes to this project are recorded here. The project follows +[Semantic Versioning](https://semver.org/); while it is below 1.0, a minor +version may change the API. + +## Unreleased + +## v0.0.1 — 2026-09-28 + +The first release: a Go client for Dify, ported from the "using Dify" half of +[dify-python-sdk](https://github.com/langgenius/dify-python-sdk) and checked +against Dify 1.17.1. + +### Added + +- `App`, for one app's Service API: chat messages and conversations, workflow + runs and their events, completions, files, annotations, audio and + human-input forms. Streams are Go 1.23 iterators that accumulate a + `WorkflowRun` or `Message`. +- `Knowledge`, for the workspace's knowledge bases: datasets, documents, + segments, metadata, tags, retrieval settings, and RAG pipeline runs. +- `Management`, for the console API as an account: deploying apps (import, + publish, key) with each step reported on a `Deployment`, app keys and + triggers, Agents, knowledge pipelines, models, tools and plugins, skills, + and dataset keys. A login's session renews itself and ends with `Logout`. +- Retries that repeat a request only when that is safe, 429 handling that + honours Retry-After, stream idle timeouts, and errors classified by + `errors.Is` with the Dify version that answered. + +Requires Go 1.24 or later. No dependencies beyond the standard library. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..4c6b32d --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,41 @@ +# Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +- Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +- The use of sexualized language or imagery, and sexual attention or + advances of any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email + address, without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Language Policy + +To facilitate clear and effective communication, all discussions, comments, documentation, and pull requests in this project should be conducted in English. This ensures that all contributors can participate and collaborate effectively. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..63a54ac --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,44 @@ +# Contributing to dify-go-sdk + +Thanks for helping. Before changing anything, read [AGENTS.md](AGENTS.md): it +records how the package is laid out, the rules the code keeps, and the Dify +behaviours that each cost debugging time once. It is written for coding agents +and holds for people just as well. + +## The short version + +- **Dify's controllers are the specification** — not its docs, and not the + Python SDK. Read the route's pydantic query or payload model in + [langgenius/dify](https://github.com/langgenius/dify) under + `api/controllers/` before adding or changing a call, and say in the PR which + one you read. +- **A mocked server proves the request shape, nothing more.** A change to what + a call sends or reads should be run against a real Dify with the live + harness, and the PR should say whether it was. +- **Test names are sentences** describing the behaviour. When a test guards + something that was once broken, say so in it. +- **Comments say why, never what.** +- **No third-party dependencies.** + +## Commands + +```bash +go test -race ./... # offline; the live harness skips itself +gofmt -l . && go vet ./... # both must be clean + +# against a running Dify (the harness creates and deletes everything it uses) +export DIFY_HOST=http://localhost DIFY_CONSOLE_EMAIL=… DIFY_CONSOLE_PASSWORD=… +go test -run Live -v ./tests +``` + +The live harness costs nothing to run: its fixture apps use template nodes, +not model nodes. + +## Pull requests + +Keep one change per pull request, with a test for it. Describe what you +checked against a real Dify and what you could not. Record user-visible +changes in [CHANGELOG.md](CHANGELOG.md) under "Unreleased". + +All discussion, issues and pull requests are in English, following Dify's +[Code of Conduct](CODE_OF_CONDUCT.md). diff --git a/README.md b/README.md index 69de617..89e2642 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,17 @@ # dify-go-sdk -A Go client for Dify's Service API — running apps, and managing knowledge -bases. A port of the Service-API half of +[![Go Reference](https://pkg.go.dev/badge/github.com/langgenius/dify-go-sdk.svg)](https://pkg.go.dev/github.com/langgenius/dify-go-sdk) +[![CI](https://github.com/langgenius/dify-go-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/langgenius/dify-go-sdk/actions/workflows/ci.yml) + +A Go client for [Dify](https://github.com/langgenius/dify) — running apps and +managing knowledge bases through the Service API, and deploying apps through +the console API. A port of the "using Dify" half of [dify-python-sdk](https://github.com/langgenius/dify-python-sdk), verified against Dify 1.17.1. Go 1.24+, no dependencies beyond the standard library. +The API may still change between 0.x releases; [CHANGELOG.md](CHANGELOG.md) +says what did. + ```bash go get github.com/langgenius/dify-go-sdk ``` @@ -247,10 +254,19 @@ engine) — Management deploys DSL text — and `OpenApiClient`. ```bash go test -race ./... # offline -set -a; . ./.env; set +a # DIFY_HOST, DIFY_CONSOLE_EMAIL, DIFY_CONSOLE_PASSWORD -go test -run Live -v ./... # against a running Dify +export DIFY_HOST=… DIFY_CONSOLE_EMAIL=… DIFY_CONSOLE_PASSWORD=… +go test -run Live -v ./tests # against a running Dify ``` The live harness creates its apps and a dataset key through the console, runs template-only workflows (no model cost), and deletes everything -afterwards. See [AGENTS.md](AGENTS.md). +afterwards. See [CONTRIBUTING.md](CONTRIBUTING.md) and [AGENTS.md](AGENTS.md). + +## Security + +Report vulnerabilities privately, as [SECURITY.md](SECURITY.md) describes — +not in a public issue. + +## License + +[MIT](LICENSE) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..e022fef --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,30 @@ +# Security Policy + +## Reporting a vulnerability + +If you believe you have found a security vulnerability in dify-go-sdk, please +report it privately through GitHub Security Advisories: + +https://github.com/langgenius/dify-go-sdk/security/advisories/new + +Please do not report security vulnerabilities through public issues, +discussions or pull requests. + +Include as much as you can safely share: what the vulnerability is, how to +reproduce it, the SDK and Dify versions involved, and its potential impact. + +A vulnerability in Dify itself, rather than in this client, belongs in +[Dify's own advisories](https://github.com/langgenius/dify/security/advisories/new). + +## What this SDK holds + +Two things here are credentials and deserve care in a report: + +- **Service-API keys** (`app-…`, `dataset-…`), which a client holds and masks + wherever it is printed. +- **A console session**, held by `Management`. It is the credential to a whole + Dify account, since Dify offers nothing narrower; `Management.Logout` ends it. + +## Supported versions + +Only the latest release receives security fixes while the SDK is below 1.0.