Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"highLevelSummary": "Refactor `Welcome.tsx` to use i18n. Add `welcome_message` to `src/locales/en.json`. Replace literal string 'Welcome to our App' with `t('welcome_message')`.",
"pagesOrScreens": [
"Welcome Screen"
],
"apis": [],
"dataModels": [],
"recommendedFileStructure": [
"src/components/Welcome.tsx",
"src/locales/en.json"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The `Welcome` component in `src/components/Welcome.tsx` has hardcoded text "Welcome to our App".
Please extract this to `src/locales/en.json` with key `welcome_message`.
Replace the hardcoded text with a call to the translation function `t('welcome_message')`.
Do not change valid layout or behavior.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {
verifyArchitect,
type VerifyCtx,
type VerifyResult
} from "../../../../src/fixture-helpers";

export function verify(ctx: VerifyCtx): VerifyResult {
return verifyArchitect(ctx, (parsed) => {
const summary = parsed.highLevelSummary.toLowerCase();
if (!summary.includes("locales") && !summary.includes("json")) {
return { ok: false, message: "Summary should mention locale file" };
}
return { ok: true };
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/src/components/Welcome.tsx b/src/components/Welcome.tsx
index ...
--- a/src/components/Welcome.tsx
+++ b/src/components/Welcome.tsx
@@ -1,7 +1,8 @@
import React from 'react';
+import { t } from '../i18n'; // or similar import

export const Welcome = () => {
return (
<div>
- <h1>Welcome to our App</h1>
+ <h1>{t('welcome_message')}</h1>
</div>
);
};
diff --git a/src/locales/en.json b/src/locales/en.json
index ...
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -1,3 +1,4 @@
{
- "app_name": "My App"
+ "app_name": "My App",
+ "welcome_message": "Welcome to our App"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Update `src/locales/en.json` to include `"welcome_message": "Welcome to our App"`.
Update `src/components/Welcome.tsx` to use `t('welcome_message')`. Assume a global `t` function or import `useTranslation`. For this task, just assume `t` is available or import it from `i18n`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

export const Welcome = () => {
return (
<div>
<h1>Welcome to our App</h1>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"app_name": "My App"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {
verifyCoder,
type VerifyCtx,
type VerifyResult
} from "../../../../src/fixture-helpers";

export function verify(ctx: VerifyCtx): VerifyResult {
return verifyCoder(ctx, (patch) => {
if (!patch.includes("welcome_message")) {
return { ok: false, message: "Patch should add welcome_message key" };
}
if (!patch.includes("t('welcome_message')") && !patch.includes('t("welcome_message")')) {
return { ok: false, message: "Patch should use translation function" };
}
return { ok: true };
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"tasks": [
{
"id": "1",
"type": "fix",
"description": "Add welcome_message to en.json",
"file": "src/locales/en.json",
"complexity": "low",
"dependsOn": []
},
{
"id": "2",
"type": "fix",
"description": "Replace hardcoded text with translation key in Welcome.tsx",
"file": "src/components/Welcome.tsx",
"complexity": "low",
"dependsOn": [
"1"
]
}
],
"ambiguities": [],
"invalidTaskCount": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Architect Plan
Extract "Welcome to our App" from `src/components/Welcome.tsx` to `src/locales/en.json` (key: `welcome_message`).
Use `t('welcome_message')`.

# Context
Files:
- src/components/Welcome.tsx
- src/locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {
verifyPlanner,
type VerifyCtx,
type VerifyResult
} from "../../../../src/fixture-helpers";

export function verify(ctx: VerifyCtx): VerifyResult {
return verifyPlanner(ctx, (parsed) => {
const tasks = parsed.tasks;
if (tasks.length < 2) {
return { ok: false, message: "Expected 2 tasks: update json and update component" };
}
const hasJson = tasks.some(t => t.file.includes("en.json"));
if (!hasJson) {
return { ok: false, message: "Must update locale file" };
}
return { ok: true };
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"comments": [
{
"path": "src/components/Welcome.tsx",
"line": 6,
"message": "Correctly replaces hardcoded string with translation key.",
"blocking": false
}
],
"decision": "approve"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Review the patch.
Verify:
1. `welcome_message` is added to en.json.
2. Hardcoded text is replaced.
3. No behavior change (text remains same via lookup).
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {
verifyReviewer,
type VerifyCtx,
type VerifyResult
} from "../../../../src/fixture-helpers";

export function verify(ctx: VerifyCtx): VerifyResult {
return verifyReviewer(ctx, (result) => {
if (result.decision !== "approve") {
return { ok: false, message: "Reviewer should approve valid patch" };
}
return { ok: true };
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"highLevelSummary": "Update `SignupForm.tsx` to improve accessibility. Change the submit `div` to a `<button type=\"submit\">`. Add `aria-label` or `<label>` tags to inputs.",
"pagesOrScreens": [
"Signup Screen"
],
"apis": [],
"dataModels": [],
"recommendedFileStructure": [
"src/components/SignupForm.tsx"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The `SignupForm` in `src/components/SignupForm.tsx` has accessibility issues:
1. Inputs missing `aria-label` or associated label.
2. Submit button is a `div` not a `button`.
Please improve accessibility without breaking the layout or logic.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {
verifyArchitect,
type VerifyCtx,
type VerifyResult
} from "../../../../src/fixture-helpers";

export function verify(ctx: VerifyCtx): VerifyResult {
return verifyArchitect(ctx, (parsed) => {
const summary = parsed.highLevelSummary.toLowerCase();
if (!summary.includes("accessibility") && !summary.includes("aria") && !summary.includes("label")) {
return { ok: false, message: "Summary should mention accessibility improvements" };
}
return { ok: true };
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/src/components/SignupForm.tsx b/src/components/SignupForm.tsx
index ...
--- a/src/components/SignupForm.tsx
+++ b/src/components/SignupForm.tsx
@@ -3,8 +3,8 @@ import React from 'react';
export const SignupForm = () => {
return (
<form>
- <input type="text" placeholder="Email" />
- <input type="password" placeholder="Password" />
- <div onClick={() => alert('submit')}>Sign Up</div>
+ <input type="text" placeholder="Email" aria-label="Email" />
+ <input type="password" placeholder="Password" aria-label="Password" />
+ <button type="submit" onClick={() => alert('submit')}>Sign Up</button>
</form>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Update `src/components/SignupForm.tsx` to be accessible:
1. Replace `<div onClick...>` with `<button type="submit">`.
2. Add `aria-label` to inputs.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';

export const SignupForm = () => {
return (
<form>
<input type="text" placeholder="Email" />
<input type="password" placeholder="Password" />
<div onClick={() => alert('submit')}>Sign Up</div>
</form>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {
verifyCoder,
type VerifyCtx,
type VerifyResult
} from "../../../../src/fixture-helpers";

export function verify(ctx: VerifyCtx): VerifyResult {
return verifyCoder(ctx, (patch) => {
if (!patch.includes("aria-label")) {
return { ok: false, message: "Patch should add aria-label" };
}
if (!patch.includes("<button") && !patch.includes("type=\"submit\"")) {
return { ok: false, message: "Patch should use button element" };
}
return { ok: true };
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"tasks": [
{
"id": "1",
"type": "fix",
"description": "Improve accessibility markup in SignupForm",
"file": "src/components/SignupForm.tsx",
"complexity": "low",
"dependsOn": []
}
],
"ambiguities": [],
"invalidTaskCount": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Architect Plan
Update `src/components/SignupForm.tsx`:
1. Change `div` button to `<button>`.
2. Add labels/aria-labels to inputs.

# Context
File:
- src/components/SignupForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {
verifyPlanner,
type VerifyCtx,
type VerifyResult
} from "../../../../src/fixture-helpers";

export function verify(ctx: VerifyCtx): VerifyResult {
return verifyPlanner(ctx, (parsed) => {
const tasks = parsed.tasks;
if (tasks.length < 1) {
return { ok: false, message: "Expected at least 1 task" };
}
const hasComponent = tasks.some(t => t.file.includes("SignupForm"));
if (!hasComponent) {
return { ok: false, message: "Must update SignupForm" };
}
return { ok: true };
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"comments": [
{
"path": "src/components/SignupForm.tsx",
"line": 6,
"message": "Good use of aria-label and semantic button element.",
"blocking": false
}
],
"decision": "approve"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Review the patch.
Verify:
1. Inputs have accessibility labels.
2. Submit is a button.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {
verifyReviewer,
type VerifyCtx,
type VerifyResult
} from "../../../../src/fixture-helpers";

export function verify(ctx: VerifyCtx): VerifyResult {
return verifyReviewer(ctx, (result) => {
if (result.decision !== "approve") {
return { ok: false, message: "Reviewer should approve valid patch" };
}
return { ok: true };
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"highLevelSummary": "Modify `processPayment` to handle idempotency and retries. Check a store for `idempotencyKey`. If missing, call external API with exponential backoff retry (3 attempts) on transient errors. Save result before returning.",
"pagesOrScreens": [],
"apis": [],
"dataModels": [
{
"name": "IdempotencyRecord",
"fields": [
"key",
"result",
"createdAt"
],
"primaryKey": "key"
}
],
"recommendedFileStructure": [
"src/services/payment.ts",
"src/utils/retry.ts"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The `processPayment` function in `src/services/payment.ts` calls an external API. It is currently unreliable.
Please implement:
1. Idempotency: Use the `idempotencyKey` provided in the arguments. Check if we already processed this key. If so, return the stored result. If not, proceed.
2. Retries: Wrap the external API call. Retry up to 3 times if it fails with a network error or 5xx status. Do not retry on 4xx.
3. Persistence: Save the result (success or failure) associated with the key so future calls return it.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {
verifyArchitect,
type VerifyCtx,
type VerifyResult
} from "../../../../src/fixture-helpers";

export function verify(ctx: VerifyCtx): VerifyResult {
return verifyArchitect(ctx, (parsed) => {
const summary = parsed.highLevelSummary.toLowerCase();
if (!summary.includes("idempotency") && !summary.includes("key")) {
return { ok: false, message: "Summary should mention idempotency" };
}
if (!summary.includes("retry") && !summary.includes("retries")) {
return { ok: false, message: "Summary should mention retries" };
}
return { ok: true };
});
}
Loading