docs: add runnable examples/ directory#32
Conversation
Add examples/changeset.ts, a complete deterministic tool that demonstrates all three output levels (L1 data, L2 classification, L3 instructions) with one subcommand each, plus examples/README.md with exact run commands and expected JSON output. Link it from the main README. Closes #26 Co-authored-by: Juan Ignacio Gipponi <beogip@users.noreply.github.com>
Greptile SummaryAdds a clonable
Confidence Score: 5/5Safe to merge — purely additive docs and example code with no changes to library source or tests. All three files are additive only. The example tool uses the public API correctly, the classification logic is deterministic and consistent with the documented outputs, and the framework's ok: true stamping means handler omissions are not a concern. The PR description states tests and type-checking pass clean. No files require special attention.
|
| Filename | Overview |
|---|---|
| examples/changeset.ts | New runnable example tool; correctly registers three subcommands using l1Output/l2Output/l3Output, deterministic classification logic, and proper tool.run() entrypoint. |
| examples/README.md | New documentation file; expected JSON outputs match the implementation, error envelope snippets are accurate, and instructions are reproducible from the repo root. |
| README.md | Adds a short "Examples" section with a verified command and links to examples/README.md; no other changes. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["bun run examples/changeset.ts subcommand --files N --additions N --deletions N"] --> B{subcommand?}
B -->|stats| C["L1 — Data\nl1Output handler\nreturns files, additions,\ndeletions, total_lines"]
B -->|size| D["classifySize(files, churn)\nxs / small / medium / large / x-large"]
B -->|review-plan| E["classifySize → reviewPlan(size)\nL3 — Instructions string"]
B -->|help| F["dispatchBuiltin → help JSON"]
B -->|schema| G["dispatchBuiltin → JSON Schema"]
B -->|unknown| H["unknownSubcommandEnvelope\nok: false"]
D --> I["L2 — Classification\nl2Output envelope\n{ok, message, classification, total_lines}"]
E --> J["L3 — Instructions\nl3Output envelope\n{ok, message, instructions, size}"]
C --> K["validateOutput stamps ok: true\njsonOutput → stdout, exit 0"]
I --> K
J --> K
F --> K
G --> K
H --> K
Reviews (1): Last reviewed commit: "docs: add runnable examples/ directory" | Re-trigger Greptile
Resolve README.md conflict by keeping both the new Examples section (from main, #32) and the API Reference section (from this PR). Co-authored-by: Juan Ignacio Gipponi <beogip@users.noreply.github.com>
|
🎉 This PR is included in version 0.1.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Adds a clonable, runnable
examples/directory so the pattern reads as "this isn't theory" rather than spec prose. Resolves #26.examples/changeset.ts— one complete, deterministic tool that demonstrates all three output levels from the spec with one subcommand each:stats→ L1 (data) — raw signals for the LLM to interpretsize→ L2 (classification) — a discrete size class the skill can branch onreview-plan→ L3 (instructions) — a verbatim review procedure the LLM executesexamples/README.md— exact run commands and the expected JSON output for each level, plushelp/schemaintrospection and the always-exit-0 error envelopes.README.md— links toexamples/from the main docs.No LLM calls inside the tool; same input flags → same JSON. Imports from
../src/index.tsso it runs against source with no build step (bun run examples/changeset.ts ...), and the README notes the@code-first-agents/toolimport for real projects.Verification
bun test→ 113 pass, 0 failbunx tsc --noEmit→ cleanbunx biome check .→ clean (examples file included; only a pre-existing schema-version info note)examples/README.mdwas run; documented JSON matches actual output.Generated with Claude Code