Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c360e94

Browse files
authored
Merge pull request #71 from theGeekist/sprint/5-move-hooks-to-ui
Sprint 5: React Hooks Integration — Complete WordPress data integration with 8 new hooks
2 parents 9a3409f + c25d6b2 commit c360e94

File tree

87 files changed

+5284
-1265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+5284
-1265
lines changed

.bin/watchman

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
# Minimal stub to disable real watchman usage in sandboxed environments.
4+
# Always respond with an empty sockname so clients fall back to node watchers.
5+
if [[ "$1" == "--no-pretty" && "$2" == "get-sockname" ]]; then
6+
printf '{ "version": "stub", "sockname": "" }\n'
7+
exit 0
8+
fi
9+
10+
# Return failure for any other commands to avoid unexpected behaviour.
11+
printf 'watchman stub: command not supported\n' >&2
12+
exit 1

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,13 @@ Tick any public packages this PR changes functionally.
6060

6161
## Release
6262

63-
Choose one and include a changeset summary (edit if scope grows).
63+
Choose one and document in CHANGELOG.md files.
6464

65-
- [ ] **patch** — bugfixes / alignment
66-
- [ ] **minor** — feature sprint (default)
67-
- [ ] **major** — breaking API
65+
- [ ] **patch** — bugfixes / alignment (0.x.1)
66+
- [ ] **minor** — feature sprint (default) (0.x.0)
67+
- [ ] **major** — breaking API (x.0.0)
6868

69-
> Create/update changeset:
70-
>
71-
> ```bash
72-
> pnpm cs:new:minor "Sprint 5: Bindings & Interactivity (Block Bindings, Interactivity API, providers)"
73-
> ```
69+
> Update CHANGELOG.md files in affected packages with summary of changes.
7470
>
7571
> _If infra/docs-only, add label **no-release**._
7672
@@ -79,6 +75,6 @@ Choose one and include a changeset summary (edit if scope grows).
7975
- [ ] Tests pass (`pnpm test`, where relevant: `pnpm e2e`)
8076
- [ ] Lint passes (`pnpm lint`)
8177
- [ ] Types pass (`pnpm typecheck`, `pnpm typecheck:tests`)
82-
- [ ] Changeset added/updated (or PR labelled `no-release`)
78+
- [ ] CHANGELOG.md updated in affected packages (or PR labelled `no-release`)
8379
- [ ] Docs updated (site/README)
8480
- [ ] Examples updated (if API changed)

.github/copilot-instructions.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,11 @@ WordPress plugin demonstrating a complete jobs & applications system that exerci
4545

4646
1. **Before starting**: Always update sprint docs and share your understanding of current scope with user
4747
2. **PR creation**: ALWAYS use `.github/PULL_REQUEST_TEMPLATE.md` - never create ad-hoc PRs
48-
3. **Changeset required**: One changeset per sprint (use `pnpm cs:new:minor "Sprint N: headline"`)
48+
3. **CHANGELOG updates**: Update CHANGELOG.md files in affected packages with changes
4949
4. **Roadmap alignment**: Link PR to roadmap section and sprint doc/spec
5050
5. **Branch management**: Delete branch when PR is merged
5151
6. **Issue tracking**: Ensure GitHub issue exists for new task before creating branch
5252

53-
See [RELEASING.md](../RELEASING.md) for complete release workflow.
54-
5553
## Core Code Practices
5654

5755
### Type Safety

.husky/pre-commit

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,4 @@ pnpm prettier --write '**/*.md' --log-level=error > /dev/null 2>&1
4545
node scripts/normalize-punctuation.js > /dev/null 2>&1
4646
git add '**/*.md'
4747

48-
# Check for changeset (only on feature branches)
49-
BRANCH=$(git branch --show-current)
50-
case "$BRANCH" in
51-
sprint-*|feat/*|fix/*)
52-
if [ -z "$(ls .changeset/*.md 2>/dev/null | grep -v README)" ]; then
53-
echo ""
54-
echo "⚠️ No changeset found. Consider: pnpm changeset"
55-
echo ""
56-
fi
57-
;;
58-
esac
48+
# Note: Manual versioning - update CHANGELOG.md files in affected packages before committing

AGENTS.md

Lines changed: 65 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,178 +1,84 @@
11
# AGENTS.md - WP Kernel
22

3-
> 💡 For human contributors: see [DEVELOPMENT.md](./DEVELOPMENT.md) for setup, workflow, and environment details.
4-
> This file focuses on agent/contribution rules.
5-
6-
**Purpose**: Operational guide for coding agents (Codex, etc.) working on WP Kernel. Follow the commands and constraints below. Finish only when checks are green and diffs are minimal.
7-
8-
## Project Overview (for agents)
9-
10-
- **Architecture**: Rails-like WordPress framework. **JS is source of truth**; PHP is a thin bridge (REST + capabilities + optional server bindings).
11-
- **Core primitives**: Actions (orchestrate writes), Resources (transport + stores + cache keys + events), Views (blocks + bindings + Interactivity API), Jobs (background).
12-
- **Non-negotiables**
13-
- UI never calls transport directly. **All writes flow through Actions.**
14-
- Events must use **canonical registry names**. No ad-hoc events.
15-
- Errors are typed `KernelError` subclasses. Never throw a plain `Error`.
16-
17-
## Monorepo Layout
18-
19-
```
20-
packages/
21-
wp-kernel/ # core framework (resources, actions, events, jobs)
22-
wp-kernel-ui/ # UI components & design system
23-
wp-kernel-cli/ # scaffolding & DX tools
24-
wp-kernel-e2e-utils/ # e2e utilities (validated via showcase)
25-
app/
26-
showcase/ # demo plugin exercising full kernel
27-
docs/ # public API docs & guides
28-
information/ # product spec, example plugin specs, roadmap, event taxonomy
29-
```
3+
## Scope & Precedence
304

31-
## Environment & Tooling
32-
33-
- **Node**: v20.x LTS or higher (minimum for Vite 7). **pnpm** workspace.
34-
- **WordPress**: 6.8+ required (Script Modules API is core to framework).
35-
- **Development environments**: wp-env (Docker + PHP 8.1+) OR WordPress Playground (WASM, no Docker).
36-
- **E2E testing**: Optional. Only needed if writing/running E2E tests (uses Playwright + `@geekist/wp-kernel-e2e-utils`).
37-
38-
- **Commands** (always use exactly these):
39-
- Install: `pnpm install`
40-
- Format/lint: `pnpm lint --fix` (or `pnpm format`)
41-
- Typecheck (code): `pnpm typecheck`
42-
- Typecheck (tests): `pnpm typecheck:tests`
43-
- Test (all): `pnpm test`
44-
> Do **not** use `--filter` for tests; it breaks our harness.
45-
- Build (if needed): `pnpm build`
46-
47-
- **When running agents (Codex, Co‑Pilot, etc.) inside private containers or CI**, set the environment variable `CI=1` before running any `git` or `pnpm` commands. This ensures non-interactive behaviour and avoids prompts that could block automation.
48-
49-
- **Note:** The pre-commit hook may take some time to complete. It performs typechecks and tests before allowing a commit. Contributors should wait patiently until it finishes.
50-
51-
**When in doubt**: run install → typecheck → tests → lint fix → tests again.
52-
53-
---
54-
55-
## Definition of Done (DoD)
56-
57-
1. `pnpm typecheck` and `pnpm typecheck:tests` pass.
58-
2. `pnpm test` is green and **coverage does not regress**:
59-
- ≥95% statements/lines, ≥98% functions globally.
60-
- Branch coverage median ≥90% (file-level dips acceptable if global median holds).
61-
3. New public APIs covered, error paths tested.
62-
4. No `any` types introduced; project/test globals updated if needed (`global.d.ts`, `tests/test-globals.d.ts`).
63-
5. Follow folder conventions:
64-
65-
```
66-
67-
app/
68-
resources/ # defineResource()
69-
actions/ # defineAction()
70-
views/ # bindings + Interactivity
71-
jobs/ # defineJob()
72-
73-
```
74-
75-
---
76-
77-
## File & Refactor Guards
78-
79-
- Keep modules/tests under **500 lines**. If approaching the limit:
80-
- Extract utilities/interfaces or split modules.
81-
- Before large refactors, open a planning comment and summarise the split.
82-
83-
---
84-
85-
## Action & Resource Patterns (enforced)
86-
87-
- **Actions-first**. Example:
88-
89-
```ts
90-
import { CreateThing } from '@/app/actions/Thing/Create';
91-
await CreateThing({ data: formData });
92-
```
93-
94-
- **Resources**: one `defineResource()` defines client, store, cache keys, events.
95-
- **Events**: import from the canonical registry only.
5+
This document provides operational guidance for coding agents (Codex, etc.) working on WP Kernel. Follow the commands and constraints below. Complete tasks only when checks are green and diffs are minimal.
966

97-
---
7+
## Project Architecture & Invariants
988

99-
## PHP Bridge
9+
- Rails-like WordPress framework: **JS is source of truth**; PHP acts as a thin transport and capability bridge.
10+
- Core primitives: Actions (handle writes), Resources (transport, stores, cache keys, events), Views (blocks, bindings, Interactivity API), Jobs (background).
11+
- Non-negotiables:
12+
- UI never calls transport directly; **all writes flow through Actions**.
13+
- Use only **canonical registry event names**; no ad-hoc events.
14+
- Errors must be typed `KernelError` subclasses; never throw plain `Error`.
10015

101-
- Treat PHP as a strict transport/capability contract. No business logic drift.
102-
- If changing types across PHP/JS, stop and raise a comment with a migration note.
16+
## Project Structure & Module Organisation
10317

104-
---
18+
- The repo is a monorepo with multiple packages under `packages/`.
19+
- Each package uses `src/` for source code, `tests/` for tests, and `types/` for TypeScript definitions.
20+
- Modules have clear separation of concerns and minimal cross-package dependencies.
21+
- Avoid deep imports across packages (e.g., no direct imports from `packages/*/src/**`).
22+
- Use explicit exports and imports to maintain encapsulation and module boundaries.
10523

106-
## Test Strategy
107-
108-
- **E2E tests are optional** for framework users - only needed if contributing or writing E2E tests for your own project.
109-
- Target e2e realism. `@geekist/wp-kernel-e2e-utils` is validated **via** `app/showcase` e2e; do not unit-test `e2e-utils` in isolation.
110-
- Flaky tests: prefer serial mode or better selectors/cleanup over sleeps.
111-
112-
---
113-
114-
## Coverage Hotspots
115-
116-
- Keep `error`, `http`, and `resource` core near **100%**.
117-
- Defensive branches that are genuinely hard to reach are acceptable if documented.
118-
119-
---
120-
121-
## Commit, PR, and Review Protocol
24+
## Environment & Tooling
12225

123-
- Small, cohesive commits. One concern per commit.
124-
- **ALWAYS use the PR template** (`.github/PULL_REQUEST_TEMPLATE.md`) - never create ad-hoc PRs
125-
- PR title format: Sprint headline (e.g., "Sprint 5: Bindings & Interactivity")
126-
- Link to Roadmap section and Sprint doc/spec in PR description
127-
- Include changeset unless labelled `no-release` (see [RELEASING.md](./RELEASING.md))
128-
- Before requesting review: run `pnpm lint --fix && pnpm typecheck && pnpm typecheck:tests && pnpm test`.
26+
- Node v20.x LTS or higher (required for Vite 7).
27+
- WordPress 6.8+ (Script Modules API required).
28+
- Development environments: `wp-env` (Docker + PHP 8.1+) or WordPress Playground (WASM, no Docker).
29+
- E2E testing is optional; uses Playwright and `@geekist/wp-kernel-e2e-utils`.
30+
- Commands:
31+
- Install: `pnpm install`
32+
- Format/lint: `pnpm lint --fix` and `pnpm format`
33+
- Typecheck code: `pnpm typecheck`
34+
- Typecheck tests: `pnpm typecheck:tests`
35+
- Test all: `pnpm test` (do not use `--filter`)
36+
- Build: `pnpm build` (if needed)
37+
- We have `types/globals.d.ts`, `tests/test-globals.d.ts`, and stubs in `tests/test-utils/wp.ts` for typing and testing support. Use these and update incrementally as needed.
38+
- When running agents (Codex, Co-Pilot, etc.) inside private containers or CI, set `CI=1` before running any `git` commands to ensure non-interactive behavior.
39+
40+
## Quality & Coverage
41+
42+
- Maintain ≥95% statements/lines and ≥98% functions coverage globally.
43+
- Branch coverage median ≥90% (some file-level dips allowed if global median holds).
44+
- Keep core modules (error, http, resource) near 100% coverage.
45+
- Defensive branches that are hard to reach are acceptable if documented.
46+
- Avoid flaky tests; use serial mode or improved selectors/cleanup instead of sleeps.
47+
48+
## Workflow & Policies
49+
50+
- Definition of Done (DoD):
51+
- Pass `pnpm typecheck` and `pnpm typecheck:tests`.
52+
- Pass `pnpm test` with no coverage regression.
53+
- Test new public APIs and error paths.
54+
- No `any` types introduced; update globals if needed.
55+
- Follow folder conventions.
56+
- Always run before requesting review:
57+
`pnpm lint --fix && pnpm typecheck && pnpm typecheck:tests && pnpm test`
58+
59+
## Commit & PR Guidelines
60+
61+
- Make small, focused commits (one concern per commit).
62+
- Always use the PR template (`.github/PULL_REQUEST_TEMPLATE.md`).
63+
- PR title format: Sprint headline (e.g., "Sprint 5: Bindings & Interactivity").
64+
- Link to Roadmap section and Sprint doc/spec in PR description.
12965
- Respond to all review feedback; avoid duplication; extract interfaces when suggested.
13066

131-
---
132-
13367
## Agent Execution Policy (Codex)
13468

135-
- **Approval mode**: default to read/write in workspace. Ask before:
69+
- Default to read/write in workspace.
70+
- Ask before:
13671
- Writing outside workspace, changing dotfiles, or enabling network access.
13772
- Installing new dev dependencies.
138-
- Creating or modifying PRs (always use PR template)
139-
140-
- **Never**: run destructive commands, alter Git history, or publish artefacts.
141-
- **PR creation**: Always use `.github/PULL_REQUEST_TEMPLATE.md` - no ad-hoc PRs
73+
- Creating or modifying PRs (always use PR template).
74+
- Never run destructive commands, alter Git history, or publish artifacts.
14275
- Always show plan, then diffs, then run checks. Close task only after DoD passes.
14376

144-
---
145-
146-
## Package-specific Notes
147-
148-
- `wp-kernel-e2e-utils`: treated as a support lib; validated by showcase e2e only.
149-
- `wp-kernel-ui`: respect design tokens and component boundaries; add stories if created.
150-
- `wp-kernel-cli`: keep scaffolds idempotent; snapshot tests preferred.
151-
152-
---
153-
154-
## Typical Flows
155-
156-
### Bug fix
157-
158-
1. Reproduce with a focused test.
159-
2. Minimal fix in the smallest package.
160-
3. Run full checks; ensure coverage does not drop.
161-
4. Add a short regression test name: `fix: <symptom>`.
162-
163-
### Feature
164-
165-
1. Add/extend Actions and Resources first; wire Views via bindings.
166-
2. Emit canonical events; update cache invalidation.
167-
3. Add tests; update docs if API changed.
168-
169-
---
170-
17177
## What NOT to do
17278

173-
- Call transport from UI components
174-
- Create ad-hoc event names
175-
- Deep-import across packages (`packages/*/src/**`)
176-
- Use `any` or throw plain `Error`
177-
- Skip cache invalidation after writes
178-
- Ignore TS errors or coverage regressions
79+
- Call transport from UI components.
80+
- Create ad-hoc event names.
81+
- Deep-import across packages (`packages/*/src/**`).
82+
- Use `any` or throw plain `Error`.
83+
- Skip cache invalidation after writes.
84+
- Ignore TypeScript errors or coverage regressions.

0 commit comments

Comments
 (0)