Skip to content

Commit 2ae4507

Browse files
committed
📝 Refactor AGENTS.md into hierarchical index structure
1 parent ea470b7 commit 2ae4507

File tree

5 files changed

+86
-60
lines changed

5 files changed

+86
-60
lines changed

AGENTS.md

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,35 @@
1-
# Agent Guidelines
1+
# Yutu
22

3-
## OVERVIEW
3+
Go CLI + MCP server + Agent for YouTube.
44

5-
Go CLI + MCP server for YouTube.
5+
## Quick Reference
66

7-
## STRUCTURE
8-
9-
```text
10-
.
11-
├── assets/ # Static assets (logos, etc.)
12-
├── cmd/ # CLI command definitions (Cobra)
13-
├── dist/ # Build artifacts
14-
├── internal/ # Internal tools and private packages
15-
├── pkg/ # Core domain logic and infrastructure
16-
└── scripts/ # Utility scripts and smoke tests
17-
```
18-
19-
## WHERE TO LOOK
20-
21-
- **CLI Entry**: `main.go` -> `cmd/`
22-
- **Domain Logic**: `pkg/<resource>/` (e.g., `pkg/video/`)
23-
- **Infrastructure**: `pkg/auth`, `pkg/utils`
24-
- **Tests**: Co-located `*_test.go` files within `pkg/`
7+
- **Build**: `go build -o yutu .` or `bazel build //...`
8+
- **Test**: `go test ./...` or `bazel test //...`
9+
- **Smoke Tests**: `./scripts/command-test.sh`
10+
- **Entry Point**: `main.go`
2511

26-
## CODE MAP
12+
## Directory Index
2713

28-
- `main.go`: Application entry point.
29-
- `cmd/root.go`: Cobra root command and global flag definitions.
30-
- `pkg/video/video.go`: Example of domain logic implementation.
14+
| Directory | Description |
15+
|-----------|-------------|
16+
| [cmd/](cmd/AGENTS.md) | CLI command definitions and MCP tool bindings |
17+
| [pkg/](pkg/AGENTS.md) | Core domain logic and shared infrastructure |
18+
| [internal/](internal/AGENTS.md) | Internal tools (docgen, skillgen) |
19+
| [scripts/](scripts/AGENTS.md) | Utility scripts and smoke tests |
20+
| [docs/](docs/) | Project documentation |
3121

32-
## CONVENTIONS
22+
## Documentation
3323

34-
- **Build System**: Bazel is used for build/test, though standard Go tools (`go build`, `go test`) also work.
35-
- **Testing**: Table-driven tests are preferred for consistency and coverage.
36-
- **Secrets**: `client_secret.json` and `youtube.token.json` are typically stored in the root directory (standard for
37-
this project).
24+
- [docs/FEATURES.md](docs/FEATURES.md) — Feature overview
25+
- [docs/HOW_TO_TEST.md](docs/HOW_TO_TEST.md) — Testing guide
26+
- [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md) — Contribution guidelines
27+
- [docs/CODE_OF_CONDUCT.md](docs/CODE_OF_CONDUCT.md) — Code of conduct
3828

39-
## COMMANDS
29+
## Conventions
4030

41-
- **Build**: `go build -o yutu .` or `bazel build //...`
42-
- **Test**: `go test ./...` or `bazel test //...`
43-
- **Smoke Tests**: `./scripts/command-test.sh`
31+
- **Secrets**: `client_secret.json` and `youtube.token.json` in root (standard for this project).
32+
- **Build System**: Bazel is primary, standard Go tools also work.
33+
- **BUILD.bazel files are auto-generated** — do NOT create or edit them manually. Run `bazel run //:gazelle` to regenerate.
34+
- After changing dependencies: `bazel run @rules_go//go -- mod tidy -v && bazel mod tidy`.
35+
- See [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md) for the full list of useful build/test/release commands.

cmd/AGENTS.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
# OVERVIEW
1+
# cmd/
22

33
CLI command definitions and MCP tool bindings.
44

5-
# STRUCTURE
5+
## Wiring
66

7-
- `root.go`: Root command entry point.
8-
- `<resource>/`: Subcommands (e.g., `video/`, `channel/`).
7+
- `main.go``cmd.Execute()``root.go`
8+
- Each `<resource>/` dir registers a subcommand + MCP tool
9+
- `Run` function: binds flags → calls `pkg/<resource>` method
910

10-
# WIRING PATTERN
11+
## Conventions
1112

12-
- `main.go` -> `cmd.Execute()` -> `root.go`.
13-
- `<resource>.go`: Registers subcommand + MCP tool.
14-
- `Run`: Binds flags -> Calls `pkg/<resource>` method.
15-
16-
# CONVENTIONS
17-
18-
- `resetFlags` in `PersistentPreRun`: Ensures clean state for MCP.
13+
- `resetFlags` in `PersistentPreRun`: ensures clean state for MCP.
1914
- MCP tools registered via `mcp.AddTool`.
2015
- Flags bound to package-level variables.
16+
- `BUILD.bazel` files are auto-generated — do NOT create or edit them manually.
17+
18+
## Subcommands
19+
20+
Each subdirectory is a 1:1 mapping to a YouTube API resource:
21+
22+
`activity/`, `agent/`, `caption/`, `channel/`, `channelBanner/`, `channelSection/`, `comment/`, `commentThread/`, `i18nLanguage/`, `i18nRegion/`, `member/`, `membershipsLevel/`, `playlist/`, `playlistImage/`, `playlistItem/`, `search/`, `subscription/`, `superChatEvent/`, `thumbnail/`, `video/`, `videoAbuseReportReason/`, `videoCategory/`, `watermark/`
23+
24+
All follow the same pattern — see [Wiring](#wiring) above.

internal/AGENTS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# internal/
2+
3+
Internal tools and private packages. Not importable by external code.
4+
5+
## Tools
6+
7+
| Tool | Description |
8+
|------|-------------|
9+
| `tools/docgen/` | Documentation generator |
10+
| `tools/skillgen/` | Skill file generator |
11+
12+
Each tool is a standalone `main.go` with its own `BUILD.bazel` (auto-generated — do NOT edit manually).

pkg/AGENTS.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
# Package Guidelines
2-
3-
## OVERVIEW
1+
# pkg/
42

53
Core domain logic and shared infrastructure.
64

7-
## STRUCTURE
8-
9-
- `<resource>/`: Domain logic (video, channel, etc.).
10-
- `auth/`: Authentication service.
11-
- `utils/`: Generic helpers.
12-
- `common/`: Shared types.
13-
14-
## PATTERNS
5+
## Patterns
156

167
- 1:1 mapping with YouTube API resources.
17-
- Structure: `<resource>.go` + `<resource>_test.go` + `BUILD.bazel`.
18-
- Domain packages depend on `auth` and `common`.
8+
- Structure: `<resource>.go` + `<resource>_test.go` + `BUILD.bazel` (auto-generated by `bazel run //:gazelle` — do NOT edit manually).
9+
- Domain packages depend on `auth/` and `common/`.
1910

20-
## TESTING
11+
## Testing
2112

2213
- Table-driven tests.
2314
- Real `youtube.Service` with `httptest.NewServer`.
2415
- Global state (envs) carefully managed/restored.
16+
- See [docs/HOW_TO_TEST.md](../docs/HOW_TO_TEST.md) for details.
17+
18+
## Packages
19+
20+
| Package | Description |
21+
|---------|-------------|
22+
| `auth/` | Authentication service |
23+
| `common/` | Shared types |
24+
| `utils/` | Generic helpers |
25+
26+
### Resource Packages
27+
28+
Each maps 1:1 to a YouTube API resource:
29+
30+
`activity/`, `caption/`, `channel/`, `channelBanner/`, `channelSection/`, `comment/`, `commentThread/`, `i18nLanguage/`, `i18nRegion/`, `member/`, `membershipsLevel/`, `playlist/`, `playlistImage/`, `playlistItem/`, `search/`, `subscription/`, `superChatEvent/`, `thumbnail/`, `video/`, `videoAbuseReportReason/`, `videoCategory/`, `watermark/`

scripts/AGENTS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# scripts/
2+
3+
Utility scripts for build, test, and release.
4+
5+
## Scripts
6+
7+
| Script | Description |
8+
|--------|-------------|
9+
| `command-test.sh` | Smoke tests for CLI commands |
10+
| `bazel-status.sh` | Bazel build status helper |
11+
| `install.sh` | Installation script |
12+
| `npm-publish.sh` | NPM package publishing |

0 commit comments

Comments
 (0)