docs: rewrite README with complete usage guide#17
Conversation
The previous Usage section had an incomplete, incorrect example. Replace it with working examples derived from the test fixture, covering all three output levels (L1/L2/L3), error handling, built-in introspection, and programmatic invocation. Add a dedicated section linking to the Code-First Agents pattern repo.
Greptile SummaryThis PR rewrites the README's Usage section with working examples derived from
Confidence Score: 5/5Documentation-only change; no runtime code is modified. All code examples match the current implementation. Every code snippet in the new Usage section was cross-checked against the source files and the dummy-tool.ts fixture. API signatures, output helpers, error codes, CLI flag parsing, and the .invoke() contract are all accurately represented. No new source files are touched. No files require special attention.
|
| Filename | Overview |
|---|---|
| README.md | Complete usage guide rewrite — all code examples match the current API surface and fixture; previous thread issues (missing non_object_return error code, ToolError code-slot misuse) are resolved in this PR. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["tool.run(argv) / tool.invoke(name, args)"] --> B{Builtin subcommand?}
B -- "schema / help" --> C["Return schema/help envelope\n{ok: true, ...}"]
B -- No --> D{Registered subcommand?}
D -- No --> E["unknown_subcommand envelope\n{ok: false, error: 'unknown_subcommand'}"]
D -- Yes --> F[Validate input against Zod schema]
F -- Fail --> G["input_validation_error envelope\n{ok: false, error: 'input_validation_error'}"]
F -- Pass --> H["await handler(validatedInput)"]
H -- "throws ToolError" --> I["toolError envelope\n{ok: false, error: customCode}"]
H -- "throws Error" --> J["unexpected_error envelope\n{ok: false, error: 'unexpected_error'}"]
H -- "non-object return" --> K["non_object_return envelope\n{ok: false, error: 'non_object_return'}"]
H -- "plain object" --> L["Stamp ok: true, validate output schema"]
L -- Fail --> M["schema_violation envelope\n{ok: false, error: 'schema_violation'}"]
L -- Pass --> N["Success envelope\n{ok: true, message, ...data}"]
Reviews (2): Last reviewed commit: "docs: fix ToolError example and add miss..." | Re-trigger Greptile
Address Greptile review feedback: - Use a hardcoded snake_case error code instead of user input - Add non_object_return to the list of framework error codes
Summary
tests/fixtures/dummy-tool.ts)ToolError, built-inschema/helpsubcommands, and programmatic.invoke()Test plan