Skip to content

Commit 5bd0934

Browse files
committed
chore(docs): improve docs
1 parent 210ee6e commit 5bd0934

17 files changed

Lines changed: 193 additions & 1 deletion

File tree

.cursor/rules/agent-runtime.mdc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
description: Python agent runtime in isolated compute
3+
globs: agent/**/*.py
4+
alwaysApply: false
5+
---
6+
7+
# Agent runtime (`agent/`)
8+
9+
- **`entrypoint.py`** is the main task loop; prompts live under **`agent/prompts/`** with **`system_prompt.py`** for shared behavior.
10+
- Follow **`agent/README.md`** for GitHub PAT scopes, env vars, and local **`./agent/run.sh`** usage.
11+
- Use **`mise run quality`** in **`agent/`** (or root **`mise run build`**, which runs agent quality before CDK) after substantive changes.
12+
- Do not embed secrets; the stack supplies credentials via Secrets Manager / env as documented.
13+
- Prefer **`ruff`** / existing patterns; see **`pyproject.toml`** for **`ruff`** and **`pytest`** configuration.

.cursor/rules/cdk-handlers.mdc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
description: CDK Lambda handlers and shared task pipeline conventions
3+
globs: cdk/src/handlers/**/*.ts
4+
alwaysApply: false
5+
---
6+
7+
# CDK handlers
8+
9+
- Prefer extending existing helpers in `cdk/src/handlers/shared/` (orchestration, validation, preflight) over duplicating logic.
10+
- When changing API shapes, edit **`cdk/src/handlers/shared/types.ts`** and mirror the same definitions in **`cli/src/types.ts`**.
11+
- Add or update Jest tests under **`cdk/test/handlers/`** or **`cdk/test/handlers/shared/`** next to the behavior you change (see **AGENTS.md** for a file map).
12+
- Use **`mise //cdk:test`** and **`mise //cdk:compile`** from the repo root instead of ad-hoc `jest` / `tsc` in the wrong directory.
13+
- Task lifecycle and admission behavior are described in **`docs/design/ORCHESTRATOR.md`**.

.cursor/rules/cli-package.mdc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
description: bgagent CLI package conventions
3+
globs: cli/src/**/*.ts
4+
alwaysApply: false
5+
---
6+
7+
# CLI (`@backgroundagent/cli`)
8+
9+
- One command per file under **`cli/src/commands/`**; wire flags and options consistently with existing commands.
10+
- **`cli/src/types.ts`** must stay aligned with **`cdk/src/handlers/shared/types.ts`** when the REST API changes.
11+
- Console output is intentional: **`no-console`** is disabled for CLI sources.
12+
- The API base URL from deployment already includes the stage (e.g. **`/v1/`**); append only resource paths in **`api-client.ts`**.
13+
- Run **`mise //cli:build`** or **`cd cli && mise run test`** to verify changes.

.cursor/rules/docs-sources.mdc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
description: Authoritative docs live under guides/ and design/; Starlight is generated
3+
globs: docs/guides/**/*.md,docs/design/**/*.md
4+
alwaysApply: false
5+
---
6+
7+
# Documentation sources
8+
9+
- Edit **`docs/guides/`** and **`docs/design/`** (and root **`CONTRIBUTING.md`** when it affects the site). Do **not** hand-edit **`docs/src/content/docs/`** — that tree is produced by **`docs/scripts/sync-starlight.mjs`**.
10+
- After changing guides or design Markdown, run **`mise //docs:sync`** or **`mise //docs:build`** from the repo root.
11+
- **`AGENTS.md`** is the root entry for contributors and coding agents; keep it in sync conceptually when you change cross-cutting dev workflows.

.github/ISSUE_TEMPLATE/documentation.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ body:
99
attributes:
1010
value: |
1111
Thanks for helping improve the documentation. Relevant docs live in `docs/guides/`, `docs/design/`, and the repo README.
12+
- type: dropdown
13+
id: area
14+
attributes:
15+
label: Doc area
16+
description: What kind of documentation is affected?
17+
options:
18+
- User guide (`docs/guides/USER_GUIDE.md` or synced site)
19+
- Developer guide (`docs/guides/DEVELOPER_GUIDE.md` or synced site)
20+
- Design / architecture (`docs/design/`)
21+
- Roadmap or prompts (`docs/guides/`)
22+
- README / root docs
23+
- Other
24+
validations:
25+
required: true
1226
- type: textarea
1327
id: description
1428
attributes:

.github/ISSUE_TEMPLATE/rfc.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ body:
99
attributes:
1010
value: |
1111
Use this template for significant feature or design proposals. Please add as much detail as possible. See the [ROADMAP](https://github.com/krokoko/bgagent/blob/main/docs/guides/ROADMAP.md) and [design docs](https://github.com/krokoko/bgagent/tree/main/docs/design) for existing direction; your RFC should align or explain divergence.
12+
- type: dropdown
13+
id: area
14+
attributes:
15+
label: Primary area
16+
description: Which part of the repo does this RFC mainly affect?
17+
options:
18+
- CDK / infrastructure
19+
- Agent (Python runtime)
20+
- CLI (bgagent)
21+
- API or orchestration
22+
- Documentation
23+
- Tooling / CI
24+
- Cross-cutting / multiple
25+
validations:
26+
required: true
1227
- type: input
1328
id: relation
1429
attributes:

.github/pull_request_template.md

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AGENTS.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,40 @@ You are an **AWS CDK (Cloud Development Kit) and TypeScript** expert. This proje
88

99
## Project knowledge
1010

11-
To get started and understand the developer flow, follow the [Developer guide](./docs/guides/DEVELOPER_GUIDE.md). For architecture and design, see [docs/design/](./docs/design/ARCHITECTURE.md).
11+
To get started and understand the developer flow, follow the [Developer guide](./docs/guides/DEVELOPER_GUIDE.md). For architecture and design, see [docs/design/](./docs/design/ARCHITECTURE.md). Task lifecycle and handler contracts are summarized in [Orchestrator design](./docs/design/ORCHESTRATOR.md) (including **API and agent contracts**).
12+
13+
### Where to make changes
14+
15+
Use this routing before editing so the right package and tests get updated:
16+
17+
| Change | Primary location | Also update |
18+
|--------|------------------|-------------|
19+
| REST API, Lambdas, task validation, orchestration | `cdk/src/handlers/`, `cdk/src/stacks/`, `cdk/src/constructs/` | Matching tests under `cdk/test/` |
20+
| Shared API request/response shapes | `cdk/src/handlers/shared/types.ts` | **`cli/src/types.ts`** (must stay in sync) |
21+
| `bgagent` CLI commands and HTTP client | `cli/src/`, `cli/test/` | `cli/src/types.ts` if API types change |
22+
| Agent runtime (clone, tools, prompts, container) | `agent/` (`entrypoint.py`, `prompts/`, `Dockerfile`, etc.) | `agent/tests/`, `agent/README.md` for env/PAT |
23+
| User-facing or design prose | `docs/guides/`, `docs/design/` | Run **`mise //docs:sync`** or **`mise //docs:build`** (do not edit `docs/src/content/docs/` by hand) |
24+
| Monorepo tasks, CI glue | Root `mise.toml`, `scripts/`, `.github/workflows/` ||
25+
26+
### CDK handler tests (quick map)
27+
28+
Colocated tests under `cdk/test/handlers/shared/` cover most shared logic:
29+
30+
- `validation.test.ts` — request validation
31+
- `preflight.test.ts` — preflight / admission checks
32+
- `create-task-core.test.ts` — task creation core path
33+
- `context-hydration.test.ts` — prompt / context assembly
34+
- `repo-config.test.ts`, `memory.test.ts`, `gateway.test.ts`, `response.test.ts`, `prompt-version.test.ts` — respective modules
35+
36+
Handler entry tests: `cdk/test/handlers/orchestrate-task.test.ts`, `create-task.test.ts`, `webhook-create-task.test.ts`. Construct wiring: `cdk/test/constructs/task-orchestrator.test.ts`, `task-api.test.ts`.
37+
38+
### Common mistakes
39+
40+
- Editing **`docs/src/content/docs/`** instead of **`docs/guides/`** or **`docs/design/`** — content is generated; sync from sources.
41+
- Changing **`cdk/.../types.ts`** without updating **`cli/src/types.ts`** — CLI and API drift.
42+
- Running raw **`jest`/`tsc`/`cdk`** from muscle memory — prefer **`mise //cdk:test`**, **`mise //cdk:compile`**, **`mise //cdk:synth`** (see [Commands you can use](#commands-you-can-use)).
43+
- **`MISE_EXPERIMENTAL=1`** — required for namespaced tasks like **`mise //cdk:build`** (see [CONTRIBUTING.md](./CONTRIBUTING.md)).
44+
- **`mise run build`** runs **`//agent:quality`** before CDK — the deployed image bundles **`agent/`**; agent changes belong in that tree.
1245

1346
### Tech stack
1447

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ When filing an issue, please check [existing open](https://github.com/aws-sample
2222

2323
### Pull Request Checklist
2424

25+
When planning edits, use **[AGENTS.md](./AGENTS.md)** at the repo root for **where to change code** (CDK vs CLI vs agent vs docs), **which tests to extend**, and **common pitfalls** (generated docs, mirrored API types, `mise` tasks).
26+
2527
* [ ] Testing
2628
- Unit test added (prefer not to modify an existing test, otherwise, it's probably a breaking change)
2729
- Integration test added (if adding a new pattern or making a significant update to an existing pattern)

cdk/src/handlers/shared/create-task-core.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
* SOFTWARE.
1818
*/
1919

20+
// HTTP create-task path: validation, persistence, orchestrator invoke. Related: orchestrator.ts, preflight.ts.
21+
// Tests: cdk/test/handlers/shared/create-task-core.test.ts, cdk/test/handlers/create-task.test.ts
22+
2023
import { BedrockRuntimeClient, ApplyGuardrailCommand } from '@aws-sdk/client-bedrock-runtime';
2124
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
2225
import { InvokeCommand, LambdaClient } from '@aws-sdk/client-lambda';

0 commit comments

Comments
 (0)