@kirrosh/zond 0.22.0 → 0.23.0
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.
- package/CHANGELOG.md +648 -0
- package/README.md +58 -6
- package/package.json +9 -6
- package/src/cli/argv.ts +122 -0
- package/src/cli/commands/add-api.ts +134 -0
- package/src/cli/commands/api/annotate/idempotency.ts +59 -0
- package/src/cli/commands/api/annotate/index.ts +525 -0
- package/src/cli/commands/api/annotate/lifecycle.ts +74 -0
- package/src/cli/commands/api/annotate/overlay.ts +206 -0
- package/src/cli/commands/api/annotate/pagination.ts +60 -0
- package/src/cli/commands/api/annotate/prompts.ts +183 -0
- package/src/cli/commands/api/annotate/readback.ts +58 -0
- package/src/cli/commands/api/annotate/resources.ts +91 -0
- package/src/cli/commands/api/annotate/seed-bodies.ts +61 -0
- package/src/cli/commands/audit.ts +480 -0
- package/src/cli/commands/bootstrap.ts +710 -0
- package/src/cli/commands/catalog.ts +35 -0
- package/src/cli/commands/check.ts +348 -0
- package/src/cli/commands/checks.ts +756 -0
- package/src/cli/commands/ci-init.ts +43 -0
- package/src/cli/commands/clean.ts +212 -0
- package/src/cli/commands/cleanup.ts +262 -0
- package/src/cli/commands/completions.ts +16 -0
- package/src/cli/commands/coverage.ts +605 -132
- package/src/cli/commands/db.ts +178 -7
- package/src/cli/commands/describe.ts +37 -2
- package/src/cli/commands/discover.ts +1236 -0
- package/src/cli/commands/doctor.ts +607 -0
- package/src/cli/commands/fixtures.ts +402 -0
- package/src/cli/commands/generate.ts +420 -46
- package/src/cli/commands/init/bootstrap.ts +30 -1
- package/src/cli/commands/{init.ts → init/index.ts} +99 -5
- package/src/cli/commands/init/skills.ts +56 -3
- package/src/cli/commands/init/templates/agents.md +65 -61
- package/src/cli/commands/init/templates/skills/zond-checks.md +397 -0
- package/src/cli/commands/init/templates/skills/zond-triage.md +210 -0
- package/src/cli/commands/init/templates/skills/zond.md +592 -125
- package/src/cli/commands/init/templates/zond-config.yml +8 -9
- package/src/cli/commands/prepare-fixtures.ts +135 -0
- package/src/cli/commands/probe/mass-assignment.ts +503 -0
- package/src/cli/commands/probe/security.ts +454 -0
- package/src/cli/commands/probe/static.ts +255 -0
- package/src/cli/commands/probe/webhooks.ts +161 -0
- package/src/cli/commands/probe.ts +459 -0
- package/src/cli/commands/reference.ts +87 -0
- package/src/cli/commands/refresh-api.ts +169 -0
- package/src/cli/commands/remove-api.ts +150 -0
- package/src/cli/commands/report-bundle.ts +318 -0
- package/src/cli/commands/report.ts +241 -0
- package/src/cli/commands/request.ts +379 -4
- package/src/cli/commands/run.ts +842 -53
- package/src/cli/commands/session.ts +244 -0
- package/src/cli/commands/use.ts +18 -1
- package/src/cli/index.ts +20 -3
- package/src/cli/json-envelope.ts +112 -3
- package/src/cli/json-schemas.ts +263 -0
- package/src/cli/program.ts +198 -635
- package/src/cli/resolve.ts +105 -0
- package/src/cli/status-filter.ts +124 -0
- package/src/cli/util/api-context.ts +85 -0
- package/src/cli/version.ts +5 -0
- package/src/core/anti-fp/bootstrap.ts +34 -0
- package/src/core/anti-fp/index.ts +33 -0
- package/src/core/anti-fp/registry.ts +44 -0
- package/src/core/anti-fp/rules/baseline-echo.ts +74 -0
- package/src/core/anti-fp/rules/schemathesis/body_negation_becomes_valid.ts +52 -0
- package/src/core/anti-fp/rules/schemathesis/coverage_phase_boundary_positive.ts +38 -0
- package/src/core/anti-fp/rules/schemathesis/has_unverifiable_mutations.ts +35 -0
- package/src/core/anti-fp/rules/schemathesis/index.ts +24 -0
- package/src/core/anti-fp/rules/schemathesis/string_type_mutation_becomes_valid.ts +53 -0
- package/src/core/anti-fp/rules/subscription-gated/index.ts +11 -0
- package/src/core/anti-fp/rules/subscription-gated/paid-plan-403.ts +75 -0
- package/src/core/anti-fp/types.ts +68 -0
- package/src/core/checks/checks/_crud-helpers.ts +133 -0
- package/src/core/checks/checks/_negative_mutator.ts +133 -0
- package/src/core/checks/checks/_readback-helpers.ts +133 -0
- package/src/core/checks/checks/content_type_conformance.ts +39 -0
- package/src/core/checks/checks/cross_call_references.ts +134 -0
- package/src/core/checks/checks/ensure_resource_availability.ts +62 -0
- package/src/core/checks/checks/idempotency_replay.ts +246 -0
- package/src/core/checks/checks/ignored_auth.ts +211 -0
- package/src/core/checks/checks/index.ts +65 -0
- package/src/core/checks/checks/lifecycle_transitions.ts +273 -0
- package/src/core/checks/checks/missing_required_header.ts +40 -0
- package/src/core/checks/checks/negative_data_rejection.ts +45 -0
- package/src/core/checks/checks/not_a_server_error.ts +27 -0
- package/src/core/checks/checks/open_cors_on_sensitive.ts +131 -0
- package/src/core/checks/checks/pagination_invariants.ts +238 -0
- package/src/core/checks/checks/positive_data_acceptance.ts +36 -0
- package/src/core/checks/checks/rate_limit_headers_absent.ts +77 -0
- package/src/core/checks/checks/response_headers_conformance.ts +74 -0
- package/src/core/checks/checks/response_schema_conformance.ts +30 -0
- package/src/core/checks/checks/status_code_conformance.ts +61 -0
- package/src/core/checks/checks/unsupported_method.ts +63 -0
- package/src/core/checks/checks/use_after_free.ts +78 -0
- package/src/core/checks/index.ts +30 -0
- package/src/core/checks/mode.ts +79 -0
- package/src/core/checks/recommended-action.ts +64 -0
- package/src/core/checks/registry.ts +78 -0
- package/src/core/checks/runner.ts +874 -0
- package/src/core/checks/sarif.ts +230 -0
- package/src/core/checks/stateful.ts +121 -0
- package/src/core/checks/types.ts +189 -0
- package/src/core/classifier/recommended-action.ts +222 -0
- package/src/core/context/current.ts +22 -6
- package/src/core/context/session.ts +78 -0
- package/src/core/coverage/loader.ts +185 -0
- package/src/core/coverage/reasons.ts +300 -0
- package/src/core/diagnostics/db-analysis.ts +151 -11
- package/src/core/diagnostics/failure-class.ts +120 -0
- package/src/core/diagnostics/failure-hints.ts +212 -9
- package/src/core/diagnostics/spec-pointer.ts +99 -0
- package/src/core/diagnostics/suggested-fixes.ts +156 -0
- package/src/core/exporter/case-study/index.ts +270 -0
- package/src/core/exporter/curl.ts +40 -0
- package/src/core/exporter/exporter.ts +48 -0
- package/src/core/exporter/html-report/escape.ts +24 -0
- package/src/core/exporter/html-report/index.ts +479 -0
- package/src/core/exporter/html-report/script.ts +100 -0
- package/src/core/exporter/html-report/styles.ts +408 -0
- package/src/core/generator/chunker.ts +42 -16
- package/src/core/generator/coverage-phase.ts +0 -0
- package/src/core/generator/create-body.ts +89 -0
- package/src/core/generator/data-factory.ts +445 -19
- package/src/core/generator/describe.ts +1 -1
- package/src/core/generator/fixtures-builder.ts +325 -0
- package/src/core/generator/index.ts +7 -5
- package/src/core/generator/openapi-reader.ts +37 -3
- package/src/core/generator/path-param-disambig.ts +114 -0
- package/src/core/generator/resources-builder.ts +648 -0
- package/src/core/generator/schema-utils.ts +11 -3
- package/src/core/generator/serializer.ts +103 -13
- package/src/core/generator/suite-generator.ts +419 -111
- package/src/core/generator/types.ts +8 -0
- package/src/core/identity/identity-file.ts +129 -0
- package/src/core/lint/affects.ts +28 -0
- package/src/core/lint/config.ts +96 -0
- package/src/core/lint/format.ts +42 -0
- package/src/core/lint/index.ts +94 -0
- package/src/core/lint/reporter.ts +128 -0
- package/src/core/lint/rules/consistency.ts +158 -0
- package/src/core/lint/rules/heuristics.ts +97 -0
- package/src/core/lint/rules/strictness.ts +109 -0
- package/src/core/lint/types.ts +96 -0
- package/src/core/lint/walker.ts +248 -0
- package/src/core/meta/meta-store.ts +6 -73
- package/src/core/output/README.md +91 -0
- package/src/core/output/index.ts +13 -0
- package/src/core/output/run.ts +126 -0
- package/src/core/output/types.ts +129 -0
- package/src/core/parser/env-interpolation.ts +104 -0
- package/src/core/parser/filter.ts +57 -0
- package/src/core/parser/schema.ts +129 -4
- package/src/core/parser/types.ts +19 -1
- package/src/core/parser/variables.ts +0 -0
- package/src/core/parser/yaml-parser.ts +58 -12
- package/src/core/probe/bootstrap.ts +34 -0
- package/src/core/probe/dry-run-envelope.ts +57 -0
- package/src/core/probe/mass-assignment-probe-class.ts +198 -0
- package/src/core/probe/mass-assignment-probe.ts +1122 -0
- package/src/core/probe/mass-assignment-template.ts +212 -0
- package/src/core/probe/method-probe.ts +43 -76
- package/src/core/probe/method-shared.ts +69 -0
- package/src/core/probe/negative-probe.ts +183 -149
- package/src/core/probe/orphan-tracker.ts +188 -0
- package/src/core/probe/path-discovery.ts +440 -0
- package/src/core/probe/probe-harness.ts +120 -0
- package/src/core/probe/registry.ts +89 -0
- package/src/core/probe/runner.ts +136 -0
- package/src/core/probe/security-probe-class.ts +201 -0
- package/src/core/probe/security-probe.ts +1453 -0
- package/src/core/probe/shared.ts +505 -0
- package/src/core/probe/static-probe-class.ts +125 -0
- package/src/core/probe/types.ts +165 -0
- package/src/core/probe/verdict-aggregator.ts +33 -0
- package/src/core/probe/webhooks-probe.ts +284 -0
- package/src/core/reporter/console.ts +41 -2
- package/src/core/reporter/index.ts +2 -3
- package/src/core/reporter/json.ts +11 -1
- package/src/core/reporter/junit.ts +27 -12
- package/src/core/reporter/ndjson.ts +37 -0
- package/src/core/reporter/types.ts +3 -0
- package/src/core/runner/assertions.ts +58 -1
- package/src/core/runner/async-pool.ts +108 -0
- package/src/core/runner/auth-path.ts +8 -0
- package/src/core/runner/ci-context.ts +72 -0
- package/src/core/runner/executor.ts +264 -20
- package/src/core/runner/form-encode.ts +51 -0
- package/src/core/runner/http-client.ts +75 -2
- package/src/core/runner/learn-drift.ts +293 -0
- package/src/core/runner/preflight-vars.ts +149 -0
- package/src/core/runner/progress-tracker.ts +73 -0
- package/src/core/runner/rate-limiter.ts +89 -17
- package/src/core/runner/run-kind.ts +39 -0
- package/src/core/runner/schema-validator.ts +312 -0
- package/src/core/runner/send-request.ts +153 -20
- package/src/core/runner/types.ts +38 -0
- package/src/core/secrets/registry.ts +164 -0
- package/src/core/secrets/secrets-file.ts +115 -0
- package/src/core/selectors/operation-filter.ts +144 -0
- package/src/core/setup-api.ts +415 -16
- package/src/core/severity/category.ts +94 -0
- package/src/core/severity/index.ts +121 -0
- package/src/core/spec/layers.ts +154 -0
- package/src/core/util/format-eta.ts +21 -0
- package/src/core/utils.ts +5 -1
- package/src/core/workspace/config.ts +129 -0
- package/src/core/workspace/manifest.ts +283 -0
- package/src/core/workspace/output-rotation.ts +62 -0
- package/src/core/workspace/triage-path.ts +87 -0
- package/src/db/lint-runs.ts +47 -0
- package/src/db/migrate.ts +126 -0
- package/src/db/migrations/0001_run_kind.sql +25 -0
- package/src/db/migrations/sql.d.ts +4 -0
- package/src/db/queries/collections.ts +133 -0
- package/src/db/queries/coverage.ts +9 -0
- package/src/db/queries/dashboard.ts +59 -0
- package/src/db/queries/results.ts +128 -0
- package/src/db/queries/runs.ts +235 -0
- package/src/db/queries/sessions.ts +42 -0
- package/src/db/queries/settings.ts +28 -0
- package/src/db/queries/types.ts +172 -0
- package/src/db/queries.ts +72 -802
- package/src/db/schema.ts +178 -50
- package/src/cli/commands/export.ts +0 -144
- package/src/cli/commands/guide.ts +0 -127
- package/src/cli/commands/init/templates/skills/scenarios.md +0 -97
- package/src/cli/commands/probe-methods.ts +0 -108
- package/src/cli/commands/probe-validation.ts +0 -124
- package/src/cli/commands/serve.ts +0 -114
- package/src/cli/commands/sync.ts +0 -268
- package/src/cli/commands/update.ts +0 -189
- package/src/cli/commands/validate.ts +0 -34
- package/src/core/diagnostics/render-md.ts +0 -112
- package/src/core/exporter/postman.ts +0 -963
- package/src/core/generator/guide-builder.ts +0 -253
- package/src/core/meta/types.ts +0 -19
- package/src/core/parser/index.ts +0 -21
- package/src/core/runner/execute-run.ts +0 -132
- package/src/core/runner/index.ts +0 -12
- package/src/core/sync/spec-differ.ts +0 -38
- package/src/web/data/collection-state.ts +0 -362
- package/src/web/routes/api.ts +0 -314
- package/src/web/routes/dashboard.ts +0 -350
- package/src/web/routes/runs.ts +0 -64
- package/src/web/schemas.ts +0 -121
- package/src/web/server.ts +0 -134
- package/src/web/static/htmx.min.cjs +0 -1
- package/src/web/static/style.css +0 -1148
- package/src/web/views/endpoints-tab.ts +0 -174
- package/src/web/views/explorer-tab.ts +0 -402
- package/src/web/views/health-strip.ts +0 -92
- package/src/web/views/layout.ts +0 -48
- package/src/web/views/results.ts +0 -210
- package/src/web/views/runs-tab.ts +0 -126
- package/src/web/views/suites-tab.ts +0 -181
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
2
|
+
import { setupApi, type SetupApiResult } from "../../../core/setup-api.ts";
|
|
3
|
+
import { printError, printSuccess } from "../../output.ts";
|
|
4
|
+
import { jsonOk, jsonError, printJson } from "../../json-envelope.ts";
|
|
5
|
+
import { bootstrapWorkspace, type BootstrapResult } from "./bootstrap.ts";
|
|
5
6
|
|
|
6
7
|
export interface InitOptions {
|
|
7
8
|
// register-an-API options (existing)
|
|
@@ -21,6 +22,8 @@ export interface InitOptions {
|
|
|
21
22
|
noAgents?: boolean;
|
|
22
23
|
/** Skip writing Claude Code skills under .claude/skills/. */
|
|
23
24
|
noSkills?: boolean;
|
|
25
|
+
/** Remove legacy skill dirs (zond-base, zond-scenarios, …) — by default a warning is printed. */
|
|
26
|
+
pruneStaleSkills?: boolean;
|
|
24
27
|
/** Override cwd for bootstrap (used by tests; CLI always uses process.cwd()). */
|
|
25
28
|
cwd?: string;
|
|
26
29
|
/** Override $HOME for MCP install (used by tests). */
|
|
@@ -55,7 +58,13 @@ export async function initCommand(options: InitOptions): Promise<number> {
|
|
|
55
58
|
return 0;
|
|
56
59
|
}
|
|
57
60
|
|
|
58
|
-
const bootstrap = bootstrapWorkspace({
|
|
61
|
+
const bootstrap = bootstrapWorkspace({
|
|
62
|
+
writeAgents,
|
|
63
|
+
writeSkills,
|
|
64
|
+
pruneStaleSkills: options.pruneStaleSkills,
|
|
65
|
+
cwd: options.cwd,
|
|
66
|
+
home: options.home,
|
|
67
|
+
});
|
|
59
68
|
let register: SetupApiResult | null = null;
|
|
60
69
|
|
|
61
70
|
if (mode === "bootstrap+register") {
|
|
@@ -72,6 +81,8 @@ export async function initCommand(options: InitOptions): Promise<number> {
|
|
|
72
81
|
agentsPath: bootstrap.agents?.path ?? null,
|
|
73
82
|
agentsAction: bootstrap.agents?.action ?? null,
|
|
74
83
|
skills: bootstrap.skills.map((s) => ({ name: s.name, path: s.path, action: s.action })),
|
|
84
|
+
staleSkills: bootstrap.staleSkills.map((s) => ({ name: s.name, path: s.path })),
|
|
85
|
+
prunedSkills: bootstrap.prunedSkills.map((s) => ({ name: s.name, path: s.path })),
|
|
75
86
|
};
|
|
76
87
|
if (register) {
|
|
77
88
|
data.collectionId = register.collectionId;
|
|
@@ -134,6 +145,9 @@ function printBootstrapResult(b: BootstrapResult, writeAgents: boolean): void {
|
|
|
134
145
|
for (const s of b.skills) {
|
|
135
146
|
lines.push(` ${verb(s.action)} .claude/skills/${s.name}/SKILL.md`);
|
|
136
147
|
}
|
|
148
|
+
for (const s of b.prunedSkills) {
|
|
149
|
+
lines.push(` Removed .claude/skills/${s.name}/ (stale)`);
|
|
150
|
+
}
|
|
137
151
|
for (const w of b.warnings) {
|
|
138
152
|
process.stderr.write(`Warning: ${w}\n`);
|
|
139
153
|
}
|
|
@@ -143,8 +157,88 @@ function printBootstrapResult(b: BootstrapResult, writeAgents: boolean): void {
|
|
|
143
157
|
} else {
|
|
144
158
|
printSuccess("Workspace ready. See AGENTS.md for the CLI workflow.");
|
|
145
159
|
}
|
|
160
|
+
const apiNames = listExistingApis(b.cwd);
|
|
161
|
+
if (apiNames.length === 0) {
|
|
162
|
+
process.stderr.write(
|
|
163
|
+
`\nNext steps:\n` +
|
|
164
|
+
` 1. zond add api <name> --spec <path|url> # register API → builds .api-fixtures.yaml (manifest)\n` +
|
|
165
|
+
` 2. zond doctor --api <name> # gap report: which vars are UNSET in .env.yaml\n` +
|
|
166
|
+
` 3. zond prepare-fixtures --api <name> --apply [--seed] # fill .env.yaml values\n` +
|
|
167
|
+
`\nNote: zond init only refreshes workspace files (skills, AGENTS.md, zond.config.yml).\n` +
|
|
168
|
+
` It does NOT touch fixtures or .env.yaml — that's the doctor/prepare-fixtures loop above.\n`
|
|
169
|
+
);
|
|
170
|
+
} else {
|
|
171
|
+
const sample = apiNames[0]!;
|
|
172
|
+
process.stderr.write(
|
|
173
|
+
`\nFixtures untouched. zond init only refreshes skills/AGENTS.md/zond.config.yml.\n` +
|
|
174
|
+
`Verify env state with:\n` +
|
|
175
|
+
` zond doctor --api ${sample} --missing-only # show UNSET vars + blocked endpoints\n` +
|
|
176
|
+
` zond prepare-fixtures --api ${sample} --apply [--seed] # discover/seed values\n`
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function listExistingApis(cwd: string): string[] {
|
|
182
|
+
try {
|
|
183
|
+
const apisDir = `${cwd}/apis`;
|
|
184
|
+
if (!existsSync(apisDir)) return [];
|
|
185
|
+
return readdirSync(apisDir, { withFileTypes: true })
|
|
186
|
+
.filter((d) => d.isDirectory() && existsSync(`${apisDir}/${d.name}/spec.json`))
|
|
187
|
+
.map((d) => d.name)
|
|
188
|
+
.sort();
|
|
189
|
+
} catch {
|
|
190
|
+
return [];
|
|
191
|
+
}
|
|
146
192
|
}
|
|
147
193
|
|
|
148
194
|
function verb(action: "created" | "updated" | "noop"): string {
|
|
149
195
|
return action === "created" ? "Created" : action === "updated" ? "Updated" : "Up-to-date:";
|
|
150
196
|
}
|
|
197
|
+
|
|
198
|
+
import type { Command } from "commander";
|
|
199
|
+
import { globalJson } from "../../resolve.ts";
|
|
200
|
+
|
|
201
|
+
export function registerInit(program: Command): void {
|
|
202
|
+
program
|
|
203
|
+
.command("init [spec]")
|
|
204
|
+
.description("Bootstrap a workspace, or register an API when --spec is given")
|
|
205
|
+
.option("--name <name>", "API name (auto-detected from spec title if omitted)")
|
|
206
|
+
.option("--spec <path>", "Path to OpenAPI spec file (registers a single API)")
|
|
207
|
+
.option("--base-url <url>", "Override base URL")
|
|
208
|
+
.option("--dir <path>", "Target directory")
|
|
209
|
+
.option("--force", "Overwrite existing API collection")
|
|
210
|
+
.option("--insecure", "Skip TLS verification when fetching the spec")
|
|
211
|
+
.option("--db <path>", "Path to SQLite database file")
|
|
212
|
+
.option("--workspace", "Bootstrap a zond workspace (zond.config.yml, apis/, AGENTS.md)")
|
|
213
|
+
.option("--with-spec <path>", "Bootstrap workspace AND register first API from spec")
|
|
214
|
+
.option("--no-agents-md", "Skip writing AGENTS.md when bootstrapping")
|
|
215
|
+
.option("--no-skills", "Skip writing Claude Code skills under .claude/skills/")
|
|
216
|
+
.option(
|
|
217
|
+
"--prune-stale-skills",
|
|
218
|
+
"Remove .claude/skills/ dirs for retired template names (zond-base, zond-scenarios)",
|
|
219
|
+
)
|
|
220
|
+
.action(async (specPos: string | undefined, opts, cmd: Command) => {
|
|
221
|
+
const spec = opts.spec ?? specPos;
|
|
222
|
+
const json = globalJson(cmd);
|
|
223
|
+
if ((spec || opts.withSpec) && !json) {
|
|
224
|
+
process.stderr.write(
|
|
225
|
+
`Warning: 'zond init --spec' / '--with-spec' is deprecated. Use \`zond add api <name> --spec <path>\` (run \`zond init\` separately to bootstrap the workspace).\n`,
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
process.exitCode = await initCommand({
|
|
229
|
+
name: opts.name,
|
|
230
|
+
spec,
|
|
231
|
+
baseUrl: opts.baseUrl,
|
|
232
|
+
dir: opts.dir,
|
|
233
|
+
force: opts.force === true,
|
|
234
|
+
insecure: opts.insecure === true,
|
|
235
|
+
dbPath: opts.db,
|
|
236
|
+
workspace: opts.workspace === true,
|
|
237
|
+
withSpec: opts.withSpec,
|
|
238
|
+
noAgents: opts.agentsMd === false,
|
|
239
|
+
noSkills: opts.skills === false,
|
|
240
|
+
pruneStaleSkills: opts.pruneStaleSkills === true,
|
|
241
|
+
json,
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
|
|
4
4
|
import zondSkill from "./templates/skills/zond.md" with { type: "text" };
|
|
5
|
-
import
|
|
5
|
+
import checksSkill from "./templates/skills/zond-checks.md" with { type: "text" };
|
|
6
|
+
import triageSkill from "./templates/skills/zond-triage.md" with { type: "text" };
|
|
6
7
|
|
|
7
8
|
export interface SkillResult {
|
|
8
9
|
name: string;
|
|
@@ -16,10 +17,62 @@ interface SkillTemplate {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
const SKILLS: SkillTemplate[] = [
|
|
20
|
+
// Primary skill: artifact model + iron rules + full workflow
|
|
21
|
+
// (init → fixtures → annotate → generate → run → stateful checks →
|
|
22
|
+
// probes → coverage → share) + single-flow scenario authoring.
|
|
19
23
|
{ name: "zond", body: zondSkill },
|
|
20
|
-
|
|
24
|
+
// Depth-check reference: conformance + security + m-20 stateful
|
|
25
|
+
// (cross_call_references, idempotency_replay, pagination_invariants,
|
|
26
|
+
// lifecycle_transitions) with per-aspect annotate flow.
|
|
27
|
+
{ name: "zond-checks", body: checksSkill },
|
|
28
|
+
// Read-only triage of a finished run / probe artifact.
|
|
29
|
+
{ name: "zond-triage", body: triageSkill },
|
|
21
30
|
];
|
|
22
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Names previously emitted by `upsertSkills` but no longer in `SKILLS`.
|
|
34
|
+
* Detected as stale by `detectStaleSkills` and removed by
|
|
35
|
+
* `pruneStaleSkills` (only when the user opts in via `--prune-stale-skills`).
|
|
36
|
+
*
|
|
37
|
+
* Append a name here whenever a skill template is retired. User-authored
|
|
38
|
+
* skills (any name NOT in this list) are never touched.
|
|
39
|
+
*/
|
|
40
|
+
const LEGACY_SKILL_NAMES: readonly string[] = [
|
|
41
|
+
"zond-base", // retired by skills-consolidation refactor (folded into zond)
|
|
42
|
+
"zond-scenarios", // retired by skills-consolidation refactor (folded into zond)
|
|
43
|
+
] as const;
|
|
44
|
+
|
|
45
|
+
export interface StaleSkill {
|
|
46
|
+
name: string;
|
|
47
|
+
path: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns directories under `<cwd>/.claude/skills/` whose name is in
|
|
52
|
+
* `LEGACY_SKILL_NAMES`. User-authored skill directories (any other
|
|
53
|
+
* name) are intentionally ignored.
|
|
54
|
+
*/
|
|
55
|
+
export function detectStaleSkills(cwd: string): StaleSkill[] {
|
|
56
|
+
const out: StaleSkill[] = [];
|
|
57
|
+
for (const name of LEGACY_SKILL_NAMES) {
|
|
58
|
+
const path = join(cwd, ".claude", "skills", name);
|
|
59
|
+
if (existsSync(path)) out.push({ name, path });
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Recursively removes the directories returned by `detectStaleSkills`.
|
|
66
|
+
* Returns the list of names that were actually removed.
|
|
67
|
+
*/
|
|
68
|
+
export function pruneStaleSkills(cwd: string, opts: { dryRun?: boolean } = {}): StaleSkill[] {
|
|
69
|
+
const stale = detectStaleSkills(cwd);
|
|
70
|
+
if (!opts.dryRun) {
|
|
71
|
+
for (const { path } of stale) rmSync(path, { recursive: true, force: true });
|
|
72
|
+
}
|
|
73
|
+
return stale;
|
|
74
|
+
}
|
|
75
|
+
|
|
23
76
|
/**
|
|
24
77
|
* Idempotently writes Claude Code skills into `<cwd>/.claude/skills/<name>/SKILL.md`.
|
|
25
78
|
* Body is identical to the in-binary template — overwrites on drift, noop on match.
|
|
@@ -1,73 +1,77 @@
|
|
|
1
1
|
## API testing with zond
|
|
2
2
|
|
|
3
|
-
This workspace uses [zond](https://github.com/kirrosh/zond) for API testing
|
|
4
|
-
|
|
3
|
+
This workspace uses [zond](https://github.com/kirrosh/zond) for API testing — CLI
|
|
4
|
+
only, no MCP server in this workspace.
|
|
5
5
|
|
|
6
|
-
###
|
|
6
|
+
### Skills
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
- **`.claude/skills/zond/SKILL.md` (primary)** — artifact model + iron
|
|
9
|
+
rules + full workflow: fixtures → annotate → generate → smoke → CRUD
|
|
10
|
+
→ stateful checks → probes → coverage → report, plus single-flow
|
|
11
|
+
scenario authoring. Loads on workspace touch and on intent ("audit
|
|
12
|
+
this API", "find bugs", "write a test for X flow").
|
|
13
|
+
- **`.claude/skills/zond-checks/SKILL.md`** — depth-check reference:
|
|
14
|
+
conformance + security + m-20 stateful invariants
|
|
15
|
+
(cross_call_references, idempotency_replay, pagination_invariants,
|
|
16
|
+
lifecycle_transitions) and the `zond api annotate dump+apply` flow.
|
|
17
|
+
- **`.claude/skills/zond-triage/SKILL.md`** — read-only triage of a
|
|
18
|
+
finished run / probe artifact. Routes by `recommended_action` enum.
|
|
10
19
|
|
|
11
|
-
|
|
12
|
-
run, diagnose failures, hunt bugs via probes, report coverage. Has explicit
|
|
13
|
-
entry points so narrow requests (only diagnose, only probe) skip earlier phases.
|
|
14
|
-
- `.claude/skills/zond-scenarios/SKILL.md` — author multi-step user-journey tests
|
|
15
|
-
and fixture creation via the API (hand-written YAML with captures,
|
|
16
|
-
`setup: true`, `always: true`). NOT for spec coverage or bug hunting.
|
|
20
|
+
Both skills work off the per-API artifacts written by `zond add api`:
|
|
17
21
|
|
|
18
|
-
|
|
22
|
+
```
|
|
23
|
+
apis/<name>/
|
|
24
|
+
spec.json # dereferenced OpenAPI (machine source — only generators read it)
|
|
25
|
+
.api-catalog.yaml # endpoint index (cheap to read, agent-friendly)
|
|
26
|
+
.api-resources.yaml # CRUD chains, FK deps, ETag/soft-delete flags
|
|
27
|
+
.api-fixtures.yaml # MANIFEST: required {{vars}} (read-only, auto-generated)
|
|
28
|
+
.env.yaml # VALUES: variable values (user-edited; auto-gitignored)
|
|
29
|
+
tests/ scenarios/ probes/
|
|
30
|
+
```
|
|
19
31
|
|
|
20
|
-
- **
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- **NEVER** hardcode tokens — put them in `apis/<name>/.env.yaml` (already gitignored)
|
|
26
|
-
and reference as `{{auth_token}}` in test YAML.
|
|
27
|
-
- `--safe` enforces GET-only; never run CRUD tests against production without explicit
|
|
28
|
-
user confirmation and a staging environment.
|
|
29
|
-
- When `zond db diagnose` reports `recommended_action: report_backend_bug` — STOP, do
|
|
30
|
-
not change the test to make it pass.
|
|
32
|
+
`.api-fixtures.yaml` is the **manifest** (single source of truth for the
|
|
33
|
+
list of vars an API needs) and `.env.yaml` holds their **values**. Don't
|
|
34
|
+
add a key to `.env.yaml` that's not in the manifest — it'll be warned and
|
|
35
|
+
ignored. A missing entry in the manifest is a generator/manifest bug, not
|
|
36
|
+
an env fix.
|
|
31
37
|
|
|
32
|
-
###
|
|
38
|
+
### Setup flow
|
|
33
39
|
|
|
34
40
|
```bash
|
|
35
|
-
#
|
|
36
|
-
zond
|
|
37
|
-
zond
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
zond catalog <spec> --output apis/<name> # writes .api-catalog.yaml
|
|
41
|
-
zond describe <spec> --compact
|
|
42
|
-
|
|
43
|
-
# 3. Generate test stubs and run smoke (GET-only)
|
|
44
|
-
zond generate <spec> --output apis/<name>/tests --tag smoke
|
|
45
|
-
zond run --safe --json
|
|
46
|
-
|
|
47
|
-
# 4. Diagnose failures
|
|
48
|
-
zond db runs --limit 5
|
|
49
|
-
zond db diagnose <run-id> --json
|
|
50
|
-
|
|
51
|
-
# 5. Coverage gate
|
|
52
|
-
zond coverage --fail-on-coverage 50
|
|
53
|
-
|
|
54
|
-
# 6. CRUD only with explicit user confirmation + staging env
|
|
55
|
-
zond run --tag crud --dry-run # show what would be sent
|
|
56
|
-
zond run --tag crud --env staging
|
|
41
|
+
zond init # bootstrap workspace (no fixture changes)
|
|
42
|
+
zond add api <name> --spec <path-or-url> # register API + emit manifest + seed empty .env.yaml
|
|
43
|
+
zond doctor --api <name> --missing-only # gap report: which vars are UNSET
|
|
44
|
+
zond prepare-fixtures --api <name> --apply [--seed] # fill .env.yaml from live API
|
|
45
|
+
zond doctor --api <name> # re-check (exit 0 = ready)
|
|
57
46
|
```
|
|
58
47
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
`zond
|
|
73
|
-
|
|
48
|
+
What each step does to `.env.yaml`:
|
|
49
|
+
|
|
50
|
+
| Command | Touches `.env.yaml`? |
|
|
51
|
+
|---|---|
|
|
52
|
+
| `zond init` | no — only writes workspace/skills files |
|
|
53
|
+
| `zond add api` | seeds skeleton with empty placeholders for every required var |
|
|
54
|
+
| `zond doctor` | no — read-only diagnostic |
|
|
55
|
+
| `zond prepare-fixtures --apply` | writes discovered values (`.bak` backup); `--seed` POST-creates resources when list endpoints return `[]` |
|
|
56
|
+
| `zond refresh-api` | no — only re-snapshots `spec.json` and rebuilds the manifest |
|
|
57
|
+
|
|
58
|
+
`zond refresh-api <name> [--spec <new-source>]` re-snapshots when the upstream
|
|
59
|
+
spec changes.
|
|
60
|
+
|
|
61
|
+
**Re-running `zond init`** is safe and expected after a CLI upgrade: it
|
|
62
|
+
re-emits skills/AGENTS.md/zond.config.yml only. Fixtures stay exactly as
|
|
63
|
+
they were — never relies on init to fill `.env.yaml`.
|
|
64
|
+
|
|
65
|
+
### Mandatory rules (mirrored from the skills — non-negotiable)
|
|
66
|
+
|
|
67
|
+
- **NEVER read raw OpenAPI/Swagger** with Read/cat/grep — use the artifacts
|
|
68
|
+
in `apis/<name>/.api-*.yaml`. Drop into `spec.json` only when a probe
|
|
69
|
+
generator needs full schemas.
|
|
70
|
+
- **NEVER use curl/wget** — use `zond request <method> <url>` for ad-hoc HTTP.
|
|
71
|
+
- **NEVER write test YAML from scratch for autogen flows** — start with
|
|
72
|
+
`zond generate`, then edit failures. (Hand-written YAML is fine for
|
|
73
|
+
scenarios.)
|
|
74
|
+
- **NEVER hardcode tokens** — `apis/<name>/.env.yaml` (auto-gitignored),
|
|
75
|
+
reference as `{{auth_token}}`.
|
|
76
|
+
- **`recommended_action: report_backend_bug` (5xx) → STOP**, do not edit
|
|
77
|
+
assertions to make the test pass.
|