Initial CST-Agent: portable Linux/Termux/Windows coding agent.
Vendored sashidown, OpenAI-compatible env (OPENAI_*), and bootstrap scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
/* mini_calc — intentionally broken fixture for CST-Agent e2e / paper case study.
|
||||
*
|
||||
* Bugs (for the agent to fix):
|
||||
* 1) add(): off-by-one — returns a+b+1
|
||||
* 2) div(): missing — only stub returns 0
|
||||
* README claims all four ops work (false until fixed).
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int add(int a, int b) {
|
||||
/* BUG: off-by-one */
|
||||
return a + b + 1;
|
||||
}
|
||||
|
||||
int sub(int a, int b) { return a - b; }
|
||||
|
||||
int mul(int a, int b) { return a * b; }
|
||||
|
||||
int div_ints(int a, int b) {
|
||||
/* BUG: not implemented */
|
||||
(void)a;
|
||||
(void)b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void usage(const char *argv0) {
|
||||
fprintf(stderr, "Usage: %s <add|sub|mul|div> <a> <b>\n", argv0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc != 4) {
|
||||
usage(argv[0]);
|
||||
return 2;
|
||||
}
|
||||
int a = atoi(argv[2]);
|
||||
int b = atoi(argv[3]);
|
||||
int r = 0;
|
||||
if (strcmp(argv[1], "add") == 0)
|
||||
r = add(a, b);
|
||||
else if (strcmp(argv[1], "sub") == 0)
|
||||
r = sub(a, b);
|
||||
else if (strcmp(argv[1], "mul") == 0)
|
||||
r = mul(a, b);
|
||||
else if (strcmp(argv[1], "div") == 0) {
|
||||
if (b == 0) {
|
||||
fprintf(stderr, "div by zero\n");
|
||||
return 3;
|
||||
}
|
||||
r = div_ints(a, b);
|
||||
} else {
|
||||
usage(argv[0]);
|
||||
return 2;
|
||||
}
|
||||
printf("%d\n", r);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user