mirror of
https://github.com/langgenius/dify.git
synced 2026-11-10 21:35:45 +08:00
2.6 KiB
2.6 KiB
AGENTS.md — difyctl (TypeScript CLI)
This package is the ESM TypeScript implementation of difyctl. Use the Node.js version pinned in package.json. Development also requires the Bun version pinned in .bun-version; command-tree generation and the dev, test, and build pre-scripts invoke it. Read ARD.md before adding a command or changing shared CLI infrastructure. Read src/commands/AGENTS.md for command-folder and registry rules.
Architecture Boundaries
- Every command extends
Command(src/plugins/commands/command.ts) and declares noneedsof its own; it reads whatever plugin services it uses directly throughctx.get(...)insiderun(input, ctx). - Plugins under
src/plugins/(argv global-flags env config session token catalog http ops io commands) own state. A plugin'sbuild()closes over its own cache or loaded document; nothing outside a plugin reaches into another plugin's internals. Outside a plugin folder, import only@/plugins/<name>and use the service fromctx.get(...); the command framework (plugins/commands/command.ts,cancel.ts,registry.ts) and the argv parser (plugins/argv/parse.ts) are the only modules imported directly. src/protocol/andsrc/call/are pure modules: catalog-shape logic (kinds, bind, pins, fold) and thecallflag table, request-building and rendering, with no op-specific branching anywhere undersrc/call/— kind and bind dispatch go through the tables insrc/protocol/andsrc/call/render/, keyed by the catalog's ownkind/bindvalues, never by operation id.- Preserve exit codes and the JSON output contract during refactors. Do not add dependencies or compatibility shims unless the task explicitly requires them.
- Local YAML files go through
localFile(src/store/local-file.ts), one schema each, no versions. Never change a key's name/type/meaning; add a new key (it may fall back to the old one). ARD.mdowns CLI code structure. Keep behavior aligned with the real mock-server (test/fixtures/dify-mock/) behavior tests.
Commands
Run package scripts from cli/:
- Source CLI:
pnpm dev <command> [args...] - Tests:
pnpm test - Build:
pnpm build - Build a local binary:
pnpm build:bin:local(pinsDIFYCTL_CHANNEL=devso it does not self-report the release channel) - Regenerate and verify the registry:
pnpm tree:genandpnpm tree:check
Run the scoped static check from the repository root with vp check cli.
Behavior tests use the real Hono server under test/fixtures/dify-mock/; do not replace it with nock, msw, or fetchMock. Keep tests colocated with their source files.