feat(create-sdk): headless creation via --config/--config-json + NDJSON + skill

Add a headless create path: --config <file> / --config-json <json> supply a
structured project spec (answers + feature plan) that drives CreateWizard through
a HeadlessPromptPort, bypassing the TTY. --json emits NDJSON lifecycle events
(done / action-required / error) so an agent can fill a missing input and re-run.
Ship a thin SKILL.md playbook for agent-driven creation. Per-file 100% coverage.
This commit is contained in:
imccyu
2026-07-17 15:21:37 +08:00
parent a66b98d270
commit 472a683bdc
6 changed files with 307 additions and 10 deletions

View File

@@ -0,0 +1,57 @@
---
name: create-dsh-sdk-project
description: Create a DeepSeek Harness SDK project non-interactively (headless), driven by an agent instead of the interactive wizard. Use when asked to scaffold a new DSH SDK project without a terminal.
---
# Create a DeepSeek Harness SDK project headlessly
The `create-sdk` initializer normally runs an interactive wizard. To create a project
**without a terminal**, pass a structured spec and ask for machine-readable events:
```sh
npm create @deepseek-ai/sdk -- --config-json '<spec-json>' --json
```
- `--config-json '<json>'` supplies the whole spec inline (no prompts). Alternatively
`--config <path.json>` reads the same spec from a file.
- `--json` makes the command emit one NDJSON lifecycle event per line to stdout.
## Spec shape
All fields are optional except those a chosen feature requires. Unsupplied answers that
have a sensible default are taken from it; a *required* answer with no default (a secret,
a custom provider base URL, a required feature option) makes the run fail loud rather than
block.
```json
{
"directory": "my-agent",
"description": "A DeepSeek Harness agent",
"provider": "deepseek",
"apiKey": "<key>",
"model": "deepseek-v4-flash",
"interface": "stdio",
"pm": "npm",
"install": false,
"features": [
{ "id": "persistence", "options": ["sqlite"] },
{ "id": "web", "options": ["exa"], "secrets": { "apiKey": "<exa-key>" } }
]
}
```
`features` is the complete set of optional features to enable, each with its chosen
options and any secrets/values it needs. The interactive feature tree and its
recommended-feature prompts are skipped in headless mode.
## Reacting to events
Each line of stdout is one JSON object:
- `{"type":"done"}` — the project was created (and installed, if `install` was true).
- `{"type":"action-required","prompt":"<message>"}` — a required answer was missing.
Add the corresponding field to the spec (e.g. an `apiKey`, a feature secret, a custom
`baseURL`) and re-run.
- `{"type":"error","message":"<message>"}` — the run failed for another reason.
Iterate: read `action-required`, fill the named input into the spec, re-run until `done`.