Skip to content

Commit e6d211c

Browse files
committed
Fix a few bugs
1 parent a420664 commit e6d211c

9 files changed

Lines changed: 384 additions & 45 deletions

File tree

AI_USAGE_POLICY.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# AI Usage Policy
2+
3+
> [!IMPORTANT]
4+
> Chilli does not accept fully AI-generated pull requests.
5+
> AI tools may be used only for assistance.
6+
> You must understand and take responsibility for every change you submit.
7+
>
8+
> Read and follow [AGENTS.md](./AGENTS.md), [CONTRIBUTING.md](./CONTRIBUTING.md), and [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md).
9+
10+
## Our Rule
11+
12+
All contributions must come from humans who understand and can take full responsibility for their code. LLMs make mistakes and cannot be held
13+
accountable.
14+
Chilli is a CLI framework, so its users trust it to parse their arguments correctly, dispatch to the right command, and emit help text that matches
15+
reality. Subtle issues in the parser, command-tree teardown, or help generator silently corrupt every downstream CLI that depends on Chilli, so human
16+
ownership matters.
17+
18+
> [!WARNING]
19+
> Maintainers may close PRs that appear to be fully or largely AI-generated.
20+
21+
## Getting Help
22+
23+
Before asking an AI, please open or comment on an issue on the [Chilli issue tracker](https://github.com/CogitatorTech/chilli/issues). There are
24+
no silly questions, and CLI-parsing topics (POSIX vs GNU flag conventions, grouped short flags, subcommand dispatch, environment-variable fallback,
25+
and allocator and lifetime management across the command tree) are an area where LLMs often give confident but incorrect answers.
26+
27+
If you do use AI tools, use them for assistance (like a reference or tutor), not generatively (to fully write code for you).
28+
29+
## Guidelines for Using AI Tools
30+
31+
1. Complete understanding of every line of code you submit.
32+
2. Local review and testing before submission, including `make test` and `make lint`.
33+
3. Personal responsibility for bugs, regressions, and cross-platform issues in your contribution.
34+
4. Disclosure of which AI tools you used in your PR description.
35+
5. Compliance with all rules in [AGENTS.md](./AGENTS.md) and [CONTRIBUTING.md](./CONTRIBUTING.md).
36+
37+
### Example Disclosure
38+
39+
> I used Claude to help understand a parsing regression in `src/chilli/parser.zig`.
40+
> I reviewed the suggested fix, ran `make test` and `make run` locally against the relevant examples, and verified the `--help` output is unchanged.
41+
42+
## Allowed (Assistive Use)
43+
44+
- Explanations of existing code in `src/lib.zig`, `src/chilli/`, and `examples/`.
45+
- Suggestions for debugging failing inline `test` blocks or help-output mismatches.
46+
- Help understanding Zig compiler errors, allocator lifetimes, or prior-art conventions from other CLI frameworks.
47+
- Review of your own code for correctness, clarity, and style.
48+
49+
## Not Allowed (Generative Use)
50+
51+
- Generation of entire PRs or large code blocks, including new parser branches in `src/chilli/parser.zig`, new flag or argument types in
52+
`src/chilli/types.zig`, new command-tree logic in `src/chilli/command.zig`, or new example programs under `examples/`.
53+
- Delegation of implementation or API decisions to the tool, especially for the shape of the public API re-exported from `src/lib.zig` or for help
54+
and error output that users will see.
55+
- Submission of code you do not understand.
56+
- Generation of documentation, README content, or doc comments without your own review.
57+
- Automated or bulk submission of changes produced by agents.
58+
59+
## About AGENTS.md
60+
61+
[AGENTS.md](./AGENTS.md) encodes project rules about architecture, testing, and conventions, and is structured so that LLMs can better comply with
62+
them. Agents may still ignore or be talked out of it; it is a best effort, not a guarantee.
63+
Its presence does not imply endorsement of any specific AI tool or service.
64+
65+
## Licensing Note
66+
67+
Chilli is licensed under the MIT License and has no external Zig or C dependencies, so all source in this repository is expected to be originally
68+
authored by contributors. AI-generated code of unclear provenance would muddy that boundary, which is another reason to keep contributions
69+
human-authored.
70+
71+
## AI Disclosure
72+
73+
This policy was adapted, with the assistance of AI tools, from a similar policy used by other open-source projects, and was reviewed and edited by
74+
human contributors to fit Chilli.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ docs: ## Generate API documentation
8181
@echo "Generating API documentation..."
8282
@$(ZIG) build docs
8383

84-
serve-docs: ## Serve the generated documentation on a local server
84+
serve-docs: docs ## Serve the generated documentation on a local server
8585
@echo "Serving documentation at http://localhost:8000..."
8686
@cd docs/api && python3 -m http.server 8000
8787

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ A microframework for creating command-line applications in Zig
1919

2020
---
2121

22-
Chilli is a lightweight command-line interface (CLI) framework for the Zig programming language.
23-
Its goal is to make it easy to create structured, maintainable, and user-friendly CLIs with minimal boilerplate,
24-
while being small and fast, and not getting in the way of your application logic.
22+
Chilli is a command-line interface (CLI) framework for Zig.
23+
It turns a declarative description of commands, flags, and positional arguments into a parser, help generator, and
24+
dispatcher, with zero external dependencies and minimal boilerplate.
2525

2626
### Features
2727

28-
- Provides a simple, low-overhead, declarative API for building CLI applications
28+
- Provides a declarative API for building CLI applications
2929
- Supports nested commands, subcommands, and aliases
3030
- Provides type-safe parsing for flags, positional arguments, and environment variables
3131
- Supports generating automatic `--help` and `--version` output with custom sections
@@ -62,7 +62,6 @@ Zig version supported by the main releases of Chilli:
6262
|----------|-------------|
6363
| `0.16.0` | `v0.3.x` |
6464
| `0.15.x` | `v0.2.x` |
65-
| `0.14.1` | `v0.1.0` |
6665

6766
The `main` branch normally tracks the latest (non-developmental) Zig release.
6867

@@ -160,7 +159,7 @@ You can now run your CLI application with the `--help` flag to see the output be
160159

161160
```bash
162161
$ ./your-cli-app --help
163-
your-cli-app v0.3.0
162+
your-cli-app v0.1.0
164163
A new CLI built with Chilli
165164

166165
USAGE:

build.zig

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,18 @@ pub fn build(b: *std.Build) void {
3131
const docs_step = b.step("docs", "Generate API documentation");
3232
const doc_install_path = "docs/api";
3333

34+
// Zig's `-femit-docs=<path>` writes the leaf dir but does not create
35+
// intermediate parents, and git does not track empty directories, so a
36+
// fresh checkout may have no `docs/` at all. Create it portably here
37+
// (idempotent: createDirPath is a no-op when the directory already exists).
38+
const ensure_docs_dir = EnsureDirStep.create(b, "docs");
3439
const gen_docs_cmd = b.addSystemCommand(&[_][]const u8{
3540
b.graph.zig_exe, // Use the same zig that is running the build
3641
"build-lib",
3742
"src/lib.zig",
3843
"-femit-docs=" ++ doc_install_path,
3944
});
45+
gen_docs_cmd.step.dependOn(&ensure_docs_dir.step);
4046

4147
docs_step.dependOn(&gen_docs_cmd.step);
4248

@@ -95,3 +101,32 @@ pub fn build(b: *std.Build) void {
95101
}
96102
}
97103
}
104+
105+
/// Build step that ensures a directory (relative to the build root) exists.
106+
/// Runs `std.fs.Dir.createDirPath` at make-time, so it only fires when a
107+
/// step that depends on it is actually being built. Portable across Linux,
108+
/// macOS, and Windows.
109+
const EnsureDirStep = struct {
110+
step: std.Build.Step,
111+
sub_path: []const u8,
112+
113+
fn create(b: *std.Build, sub_path: []const u8) *EnsureDirStep {
114+
const self = b.allocator.create(EnsureDirStep) catch @panic("OOM");
115+
self.* = .{
116+
.step = std.Build.Step.init(.{
117+
.id = .custom,
118+
.name = b.fmt("ensure {s}/", .{sub_path}),
119+
.owner = b,
120+
.makeFn = make,
121+
}),
122+
.sub_path = sub_path,
123+
};
124+
return self;
125+
}
126+
127+
fn make(step: *std.Build.Step, options: std.Build.Step.MakeOptions) anyerror!void {
128+
_ = options;
129+
const self: *EnsureDirStep = @fieldParentPtr("step", step);
130+
try step.owner.build_root.handle.createDirPath(step.owner.graph.io, self.sub_path);
131+
}
132+
};

0 commit comments

Comments
 (0)