@manhd_d/ai-harness 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/CONTRIBUTING.md +9 -0
  3. package/README.md +35 -70
  4. package/adapters/react-native/adapter.yaml +4 -2
  5. package/adapters/react-native/checks/verification.yaml +24 -0
  6. package/adapters/react-native/evals/cases.json +20 -0
  7. package/adapters/react-native/rules.md +3 -0
  8. package/adapters/react-native/skills/harness-react-native-behavior-testing/SKILL.md +48 -0
  9. package/adapters/react-native/skills/harness-react-native-screen-delivery/SKILL.md +53 -0
  10. package/adapters/react-nextjs/adapter.yaml +4 -2
  11. package/adapters/react-nextjs/checks/verification.yaml +24 -0
  12. package/adapters/react-nextjs/evals/cases.json +20 -0
  13. package/adapters/react-nextjs/rules.md +3 -0
  14. package/adapters/react-nextjs/skills/harness-react-nextjs-behavior-testing/SKILL.md +48 -0
  15. package/adapters/react-nextjs/skills/harness-react-nextjs-feature-delivery/SKILL.md +55 -0
  16. package/capabilities/product/capability.json +1 -1
  17. package/capabilities/product/workflows/change-impact-analysis.md +4 -0
  18. package/capabilities/product/workflows/document-driven.md +6 -1
  19. package/capabilities/product/workflows/idea-driven.md +6 -1
  20. package/capabilities/uiux/capability.json +1 -1
  21. package/capabilities/uiux/workflows/docs-to-figma.md +7 -0
  22. package/capabilities/uiux/workflows/idea-to-figma.md +7 -0
  23. package/cli/artifacts.js +168 -0
  24. package/cli/environment.js +9 -10
  25. package/cli/harness.js +13 -3
  26. package/cli/main.js +9 -2
  27. package/cli/project-config.js +11 -0
  28. package/cli/readiness.js +3 -1
  29. package/core/checks/verification.json +12 -0
  30. package/core/evals/cases.json +30 -0
  31. package/core/workflows/artifact-contract.md +53 -0
  32. package/core/workflows/project-setup.md +2 -0
  33. package/core/workflows/spec-to-code.md +5 -0
  34. package/docs/README.md +41 -0
  35. package/docs/adapters.md +4 -2
  36. package/docs/agent-handoffs.md +4 -0
  37. package/docs/architecture.md +9 -0
  38. package/docs/artifact-contract.md +197 -0
  39. package/docs/change-readiness.md +6 -0
  40. package/docs/cli.md +15 -3
  41. package/docs/documentation-workflows.md +7 -0
  42. package/docs/end-to-end-workflow.md +4 -0
  43. package/docs/examples/fullstack-web.md +4 -0
  44. package/docs/examples/react-native-app.md +4 -0
  45. package/docs/frontend-mobile.md +76 -0
  46. package/docs/getting-started.md +50 -94
  47. package/docs/harness-maintenance.md +1 -0
  48. package/docs/i18n/README.vi.md +53 -0
  49. package/docs/project-configuration.md +7 -0
  50. package/docs/skill-matrix.md +8 -4
  51. package/docs/tool-setup/README.md +5 -0
  52. package/docs/versioning.md +18 -0
  53. package/harness.yaml +1 -1
  54. package/integrations/mcp/README.md +5 -0
  55. package/package.json +1 -1
  56. package/templates/AGENTS.md +2 -0
  57. package/templates/artifacts.json +6 -0
  58. package/templates/integrations.json +4 -0
  59. package/templates/openspec/artifact-impact.json +5 -0
  60. package/templates/openspec/design.md +3 -0
@@ -3,6 +3,10 @@
3
3
  AI Harness hiện có **role contracts**, không tạo các agent chạy tự động hoặc agent-to-agent queue. Một assistant có thể đảm nhiệm nhiều vai trò theo thứ tự, nhưng phải tách evidence, quyền hạn và human approval. Dùng cùng [Full SDLC](end-to-end-workflow.md) và [Skill matrix](skill-matrix.md).
4
4
 
5
5
  ## Trách nhiệm theo vai trò
6
+ For React/Next.js and React Native implementation/testing, use the selective skill routing in
7
+ [Frontend/mobile coding](frontend-mobile.md). Handoff AC → route/screen → API/state → test evidence,
8
+ including reused public APIs and unavailable browser/native checks; retain the same Core roles.
9
+
6
10
 
7
11
  | Role contract trong source | Nhận | Bàn giao | Không được làm |
8
12
  | --- | --- | --- | --- |
@@ -137,3 +137,12 @@ the snapshot. agents.json is project-owned and preserved. agents.js validates/re
137
137
  namespaced roles; setup supplies an advisory host plan with availability unverified. No provider calls,
138
138
  native writes, orchestration, usage meter or automatic escalation. Old alternate sources use the packaged
139
139
  default when absent; old consumers without config remain valid. See [Agent configuration](agent-configuration.md).
140
+
141
+ ## Project artifact and integration contracts
142
+ Project-owned artifacts.json/integrations.json use schema 1 independently of project/lock schemas.
143
+ The installer seeds absent configs, validates before writes, and preserves custom bytes. The shared
144
+ JSON reader does not echo parse input. artifacts.js validates local paths/refs/dependencies and
145
+ provides a read-only host plan; no provider registry, connector runtime, secrets store or discovery.
146
+ new-doc routes to an explicit docs folder or returns an external template handoff without fallback
147
+ copies. OpenSpec stays repository-owned; configured outputs add structural artifact-impact coverage
148
+ and completion to readiness. See [Artifact contract](artifact-contract.md).
@@ -0,0 +1,197 @@
1
+ # Project artifacts and integrations
2
+
3
+ Define **Input → Output → Storage → Ownership → Maintenance** once per project.
4
+ The AI host executes tools; Harness validates declarations and provides workflows.
5
+
6
+ | Project-owned file | Purpose |
7
+ | --- | --- |
8
+ | .harness/artifacts.json | Input/output locations, source revisions, canonical ownership, write policy and dependencies |
9
+ | .harness/integrations.json | Dynamic connection IDs, host bindings, purpose, intended access and scope |
10
+ | .harness/environment.json | Existing executable/file/build/test contract; unchanged |
11
+
12
+ Init/update seed empty contracts if absent and preserve existing bytes. No secrets, native MCP
13
+ server configuration or account credentials belong in these files.
14
+
15
+ ## Quick setup
16
+
17
+ Ask the AI:
18
+ > Read AGENTS.md and inspect existing sources. If unknown, ask where docs and UI/UX should be
19
+ > stored and maintained. Record only the outputs this project needs, their canonical owner and
20
+ > source-write scope. Reuse established decisions and authorization.
21
+
22
+ `aih setup` suggests missing storage choices; `aih artifacts` reports the declarations.
23
+ Neither interviews the user, writes answers, connects accounts, retrieves docs nor discovers MCP.
24
+ An empty/unconfigured contract keeps old projects usable without forcing a new documentation phase.
25
+
26
+ For idea-driven work, select Product when its templates help; a small app can use PRD-lite + spec/tasks.
27
+ For existing docs, preserve approved sources and create only needed derived technical outputs.
28
+
29
+ ## Repository example
30
+
31
+ .harness/artifacts.json:
32
+ ```json
33
+ {
34
+ "schema_version": 1,
35
+ "mode": "idea-driven",
36
+ "inputs": {
37
+ "idea": {
38
+ "kind": "idea",
39
+ "location": { "path": "docs/discovery/idea.md" },
40
+ "owner": "project-owner",
41
+ "write_policy": "propose"
42
+ }
43
+ },
44
+ "outputs": {
45
+ "product": {
46
+ "kind": "docs",
47
+ "capability": "product",
48
+ "location": { "path": "docs/requirements" },
49
+ "owner": "project-owner",
50
+ "canonical": true,
51
+ "sources": ["idea"],
52
+ "write_policy": "propose"
53
+ },
54
+ "spec": {
55
+ "kind": "spec",
56
+ "location": { "path": "openspec" },
57
+ "canonical": true,
58
+ "depends_on": ["product"],
59
+ "write_policy": "propose"
60
+ }
61
+ }
62
+ }
63
+ ```
64
+
65
+ After installing Product, `aih new-doc prd-lite` now creates
66
+ `docs/requirements/prd-lite.md` and refuses overwrite. A configured contract must declare a docs
67
+ destination for the requested capability. For unconfigured/legacy contracts, the original
68
+ docs/discovery and docs/product (or other capability) defaults remain.
69
+
70
+ ## External sources and arbitrary tools
71
+
72
+ Example .harness/integrations.json:
73
+ ```json
74
+ {
75
+ "schema_version": 1,
76
+ "connections": {
77
+ "requirements-tool": {
78
+ "via": "connector",
79
+ "binding": "atlassian",
80
+ "purpose": "Read project requirements and issues",
81
+ "access": "read-only",
82
+ "scope": ["space/APP", "project/APP"]
83
+ },
84
+ "design-tool": {
85
+ "via": "mcp",
86
+ "binding": "figma",
87
+ "purpose": "Review project UI",
88
+ "access": "read-only",
89
+ "scope": ["approved-file-id"]
90
+ },
91
+ "test-db": {
92
+ "via": "mcp",
93
+ "binding": "postgres",
94
+ "purpose": "Inspect test schema",
95
+ "access": "read-only",
96
+ "scope": ["test-database"]
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ Connection IDs/bindings are aliases, not a fixed Figma/Jira/Confluence/DB registry. Map them to actual
103
+ authorized host tools; manual access can use via: manual. Runtime credentials and host configuration
104
+ stay outside Git. All reported availability is unverified until the host checks it.
105
+
106
+ An external input or output uses a location such as:
107
+ ```json
108
+ {
109
+ "kind": "docs",
110
+ "capability": "product",
111
+ "location": {
112
+ "url": "https://example.atlassian.net/wiki/pages/123",
113
+ "connection": "requirements-tool"
114
+ },
115
+ "owner": "product-owner",
116
+ "revision": "17",
117
+ "canonical": true,
118
+ "write_policy": "read-only"
119
+ }
120
+ ```
121
+
122
+ Use it under inputs for an existing source. An output uses its chosen target and usually propose;
123
+ do not mark a derived output canonical for the same kind/capability as its canonical input.
124
+ `aih new-doc` with an external output returns status planned, the actual locked template and
125
+ destination metadata, with executed false. It creates no local copy and performs no remote write.
126
+ The host prepares/reviews the draft or publishes only within existing explicit scope authorization.
127
+
128
+ ## Schema and defaults
129
+
130
+ - Schema 1 has mode (unconfigured / idea-driven / document-driven), inputs and outputs maps.
131
+ Unconfigured maps are empty. IDs and kinds are lowercase hyphenated slugs.
132
+ - Each artifact has kind and exactly one location path or HTTPS URL. Local inputs can name files
133
+ or directories; local output paths are directories. Paths stay inside the project, without
134
+ symlinks, traversal or managed/private output folders (.git/.harness/.agents/node_modules/AGENTS.md).
135
+ - Optional owner/revision are recorded facts; status is draft/approved/superseded. Defaults are draft,
136
+ not business approval. canonical defaults false; at most one canonical artifact per kind/capability.
137
+ Use different kinds for distinct authoritative artifacts or a collection input for a source set.
138
+ - Outputs may name input IDs in sources and output IDs in depends_on. Unknown refs, self/cyclic
139
+ dependencies, conflicting canonical owners and duplicate docs routes are rejected.
140
+ - docs output capability defaults product; only one docs route per capability. spec output must
141
+ point to repository openspec; OpenSpec CLI readiness/archive remains local. External specs can
142
+ be input or host-managed exports.
143
+ - write_policy is read-only/propose/write. Git defaults propose; external inputs default read-only;
144
+ outputs default propose. Propose is a reviewable patch/PR/handoff, not permission to mutate an
145
+ external canonical page. Read-only sources remain unchanged.
146
+ - Connection fields: via (mcp/connector/manual), binding alias, purpose, optional access and scope.
147
+ Access defaults read-only. Write requires nonempty scope. External write artifacts also require
148
+ a write connection and observed revision/snapshot reference. URL credentials and credential
149
+ query parameters are rejected. Config validation cannot detect every secret; never place secrets here.
150
+ - Declarations do not grant permissions or enforce connector calls. Verify host tools, user authorization,
151
+ current revisions and optimistic concurrency before a write. A changed/unavailable revision must
152
+ be reconciled; do not overwrite or infer successful publication.
153
+
154
+ ## Spec-driven maintenance
155
+
156
+ `aih new-change <id>` adds artifact-impact.json with its other draft templates:
157
+ ```json
158
+ {
159
+ "schema_version": 1,
160
+ "reviewed": true,
161
+ "items": [
162
+ {
163
+ "artifact": "output:product",
164
+ "action": "update",
165
+ "status": "pending",
166
+ "reason": "Add acceptance criteria for this feature"
167
+ },
168
+ {
169
+ "artifact": "output:spec",
170
+ "action": "create",
171
+ "status": "pending",
172
+ "reason": "Specify the new behavior"
173
+ }
174
+ ]
175
+ }
176
+ ```
177
+
178
+ Replace reasons with actual impact; use input:<id> for affected sources. Cover every configured output;
179
+ use unchanged with a reason when unaffected. Before implement, reviewed impact must not be blocked
180
+ or request changes to read-only artifacts. Before review, every item is done and changed artifacts
181
+ have concrete evidence (diff/PR/page/node/source revision/test log). Record remote publication evidence
182
+ and sync direction; pending/blocked required maintenance is not completion.
183
+
184
+ `aih ready` activates this gate only for configured contracts with outputs. It validates structure
185
+ and declared completion, not semantic correctness, actual permissions or truthful evidence.
186
+ The host reviews requirements → spec → UI/code → verification and updates affected artifacts in
187
+ the same change. Reuse prior approval within scope. Sync accepted specs/archive only after merge.
188
+
189
+ ## Update and rollback
190
+
191
+ Update seeds missing contracts without rewriting configured artifacts, agents.json, local docs or
192
+ external sources. Old changes without artifact-impact.json remain usable when no outputs are configured;
193
+ when opting in, copy the installed impact template and review actual change coverage. Project/lock
194
+ schemas remain 1. Review update --dry-run, then update/check and application tests; rollback via Git.
195
+
196
+ [Project configuration](project-configuration.md) · [Change readiness](change-readiness.md) ·
197
+ [Documentation workflows](documentation-workflows.md) · [MCP contract](../integrations/mcp/README.md).
@@ -65,3 +65,9 @@ kết quả. Ít nhất một check hoặc manual review đã pass phải đư
65
65
  Change cũ không bị tự sửa. Nếu muốn dùng ready, copy hai template từ
66
66
  `.harness/templates/openspec/` sau khi update, chỉ khi file đích chưa có; điền theo thực tế.
67
67
  Sửa nhỏ, ít rủi ro không cần full change: ghi rationale và bằng chứng ngay trong PR.
68
+
69
+ ## Artifact maintenance
70
+ With configured outputs in .harness/artifacts.json, readiness also reads artifact-impact.json.
71
+ Cover each output plus affected input IDs, record reviewed impact/reasons and respect read-only
72
+ sources. Implement allows pending plans; review requires done items and evidence for changes.
73
+ Unconfigured/legacy projects keep their existing readiness behavior. See [Artifact contract](artifact-contract.md).
package/docs/cli.md CHANGED
@@ -12,14 +12,15 @@ Exit 0 means the requested operation succeeded; 1 means validation/I/O/drift fai
12
12
  | resolve | --source; --adapters a,b; --capabilities a,b | Validate module selection and compatibility; read-only |
13
13
  | verify | --scope adapters/core/capabilities/all | Read installed advisory checks; executed false, no subprocesses |
14
14
  | eval | --scope adapters/core/capabilities/all; --report FILE | Emit unscored template or aggregate reviewed report; no model calls |
15
- | init | --detect OR --adapters a,b; --capabilities a,b; --source; --dry-run; --allow-major | Install a snapshot; exact rerun is idempotent |
15
+ | init | --detect OR --adapters a,b; --capabilities a,b; --agent-preset recommended/economy/custom; --source; --dry-run; --allow-major | Install a snapshot and seed project agent preferences; exact rerun without explicit preset is idempotent |
16
16
  | update | --source; --dry-run; --allow-major | Update unedited owned files and seed missing project files |
17
17
  | check | none | Compare installed files/block with lock and selection; no writes |
18
18
  | doctor | none | check plus configured environment/path diagnostics and generic PATH hints; no execution |
19
- | setup | none | Read-only host-facing question plan; skips tool-selection suggestions when tools are configured |
19
+ | setup | --host codex/claude-code/gemini-cli/cursor/copilot/custom-ID (optional) | Read-only question and agent-routing plan; skips tool-selection suggestions when tools are configured |
20
+ | artifacts | none | Report declared inputs/outputs/storage/write policy and host connection aliases; no discovery or tool calls |
20
21
  | ready ID | --stage implement/review | Structural readiness; blocked returns exit 1, ready returns exit 0; no business approval |
21
22
  | new-change ID | none | Create an unapproved OpenSpec draft using installed templates |
22
- | new-doc TYPE | none | Copy a selected locked Product template to `docs/discovery/` (idea, research) or `docs/product/` (other types) without overwriting |
23
+ | new-doc TYPE | --capability ID (default product) | Copy one selected locked template into the owner's project docs without overwrite; Product idea/research use `docs/discovery/`, other Product types use `docs/product/` |
23
24
  | skills | none | List installed skill metadata only |
24
25
  | skill NAME | none | Read one installed, locked skill |
25
26
 
@@ -145,3 +146,14 @@ existing files are validated/preserved and explicit preset overwrite is refused.
145
146
  (or claude-code/gemini-cli/cursor/copilot/custom ID) exports resolved roles and compatibility limitations
146
147
  without probing models or editing host files. No extra config command, runtime or usage tracking.
147
148
  See [Agent configuration](agent-configuration.md).
149
+ Setup exit 0 means the read-only plan was produced, not that all models are usable. Inspect the nested
150
+ agent_configuration.status and active route availability; host-incompatible/unverified requests require
151
+ actual host checks before execution.
152
+
153
+ ## Artifact contract
154
+ [Input/output/storage and integrations](artifact-contract.md) are project-owned configs. Init/update
155
+ seed absent configs and preserve existing bytes; check validates schemas/references before writes.
156
+ `aih artifacts` is read-only; setup suggests missing storage decisions. Explicit docs routes override
157
+ legacy new-doc folders; external routes return a template/host handoff with executed false and no
158
+ local fallback. Configured output contracts require reviewed artifact-impact.json coverage in ready;
159
+ review stage requires declared completion/evidence. No remote calls, source writes or approval claims.
@@ -76,3 +76,10 @@ For new/material journeys, reuse existing BA documents and continue with [Soluti
76
76
  PO defines a usable MVP and evidence-backed outcomes, SA evaluates quality/architecture/contracts,
77
77
  PM sequences dependent value slices. Accepted decisions and requirement IDs feed OpenSpec and adapters.
78
78
  Depth scales to the task; no mandatory full document set for small fixes. Use [tool setup](tool-setup/README.md).
79
+
80
+ ## Input/output storage and source maintenance
81
+ Use [Artifact contract](artifact-contract.md) before authoring: reuse known locations or ask where
82
+ docs/UI should be maintained, record canonical owner and source revisions, then use proportional
83
+ templates. Existing sources are read-only/propose/write as declared; host authorization still applies.
84
+ Update affected docs/spec/UI with the change and record artifact-impact evidence. new-doc respects
85
+ local output folders or returns a host handoff for external targets, without publishing itself.
@@ -104,6 +104,10 @@ Project tự sở hữu các file `docs/product/` và cập nhật `traceability
104
104
  - **No code yet:** Product + UI/UX có thể dừng sau design gate, không tạo PR implementation giả.
105
105
 
106
106
  ## 5. Verify, eval và hồ sơ release
107
+ Web/mobile implementation and testing use [Frontend/mobile coding](frontend-mobile.md): select the
108
+ feature/screen skill plus relevant testing/boundary skills, preserve existing common APIs and hand off
109
+ actual browser/server or per-platform native evidence. Load only needed skill bodies for simple tasks.
110
+
107
111
 
108
112
  ~~~bash
109
113
  aih verify --scope all
@@ -52,11 +52,15 @@ aih new-change add-ticket-creation
52
52
  aih skill harness-spec
53
53
  aih skill harness-tdd
54
54
  aih skill harness-java-spring-spring-api
55
+ aih skill harness-react-nextjs-feature-delivery
55
56
  aih skill harness-react-nextjs-accessible-ui
56
57
  aih skill harness-react-nextjs-server-boundaries
58
+ aih skill harness-react-nextjs-behavior-testing
57
59
  ~~~
58
60
 
59
61
  Spec phải chứa contract `POST /...` thực tế đã review, authorization, error envelope, loading/empty/errors, client/server boundaries, cache invalidation và contract tests. Implement thành vertical slice API + UI cùng acceptance IDs. Đối với giao diện frontend, kiểm tra SSR/client boundary và tránh đưa credentials ra browser.
62
+ Chỉ đọc skill body cần cho task; reuse client/query/FormField hiện có. Skills delivery/testing bao phủ
63
+ route/form/API/state và AC-linked component/browser evidence; không ép plain React dùng Next.js.
60
64
 
61
65
  Ví dụ kiểm tra **chỉ nếu repo có tương ứng**:
62
66
 
@@ -28,14 +28,18 @@ Nếu chỉ sửa một lỗi offline đã có ticket/AC duyệt, có thể bỏ
28
28
  aih new-change offline-draft-sync
29
29
  aih skill harness-spec
30
30
  aih skill harness-tdd
31
+ aih skill harness-react-native-screen-delivery
31
32
  aih skill harness-react-native-offline-sync
32
33
  aih skill harness-react-native-device-permissions
34
+ aih skill harness-react-native-behavior-testing
33
35
  ~~~
34
36
 
35
37
  - `offline-sync`: định nghĩa local persistence encryption/retention, idempotency key, queue/retry backoff, conflict resolution và đồng bộ lại khi token hết hạn.
36
38
  - `device-permissions`: chỉ cần nếu feature có camera/location/notification/deep link; kiểm tra iOS và Android riêng, fallback khi từ chối permission.
37
39
  - Spec chứa test matrix: airplane mode, offline restart, duplicate request, conflict, revoke session, low storage và app update.
38
40
  - Không log token/customer payload, không giả định AsyncStorage/SecureStore đã được chọn; dùng stack đang có.
41
+ - Dùng screen-delivery để reuse navigation/theme/client/form và behavior-testing cho test matrix;
42
+ chỉ nạp offline/permissions khi task chạm rủi ro đó. JS mocks không chứng minh native/device behavior.
39
43
 
40
44
  **Verification** — tùy project scripts/toolchain, không được Harness thực thi:
41
45
 
@@ -0,0 +1,76 @@
1
+ # Code React/Next.js và React Native
2
+
3
+ Adapter có rules/conventions và skills cho implementation, kiểm thử cùng các rủi ro chuyên biệt.
4
+ Không cần thêm bộ skills ngoài để bắt đầu. Chỉ cài module phù hợp; AI đọc một skill khi task cần nó.
5
+
6
+ ## Init và bắt đầu
7
+
8
+ Trong repository ứng dụng đã tạo, chọn **một** lệnh theo stack:
9
+
10
+ ```bash
11
+ # React web hoặc Next.js
12
+ aih init --adapters react-nextjs
13
+ # React Native hoặc Expo
14
+ aih init --adapters react-native
15
+ ```
16
+
17
+ Sau đó chạy `aih check`, `aih setup --host codex` (đổi host theo công cụ thực tế), mở AI tool và giao:
18
+
19
+ > Đọc AGENTS.md và workflow project-setup. Khảo sát router, versions, common components, API client,
20
+ > form/state/navigation và test setup. Dự án này cần [tính năng]. Hỏi phần còn thiếu, đề xuất slice/MVP
21
+ > và kiến trúc phù hợp, sau đó implement theo conventions hiện có và báo cáo checks thực chạy.
22
+
23
+ Core đã có TDD/debug/review. Nếu cần thiết kế UX/Figma, thêm `--capabilities uiux` khi init mới.
24
+ Nếu cần khám phá ý tưởng/MVP/kiến trúc/kế hoạch, thêm `product,architecture,delivery`; không bắt task nhỏ
25
+ tạo đủ tài liệu. Dự án đã cài đổi `.harness/project.json` rồi review update, không re-init với lựa chọn khác.
26
+ Harness không tạo app/framework, cài libraries hoặc cấu hình Figma/native AI host.
27
+
28
+ ## Chọn skill theo việc
29
+
30
+ | Việc | React/Next.js | React Native/Expo |
31
+ | --- | --- | --- |
32
+ | Route/screen, form, CRUD/search, API và state | `harness-react-nextjs-feature-delivery` | `harness-react-native-screen-delivery` |
33
+ | Test hành vi và luồng | `harness-react-nextjs-behavior-testing` | `harness-react-native-behavior-testing` |
34
+ | Rủi ro chuyên biệt | `harness-react-nextjs-accessible-ui`, `harness-react-nextjs-server-boundaries` khi có Next server | `harness-react-native-offline-sync`, `harness-react-native-device-permissions` khi cần |
35
+
36
+ `aih skills` liệt kê metadata; `aih skill <id>` đọc một body. AI có thể chọn skill qua description và
37
+ đọc `.agents/skills/<id>/SKILL.md`, không cần bạn gọi từng role. Xem [Skill matrix](skill-matrix.md).
38
+ Skill IDs dưới namespace react-nextjs cũng dùng cho React web; plain React không bị ép chuyển Next.js.
39
+
40
+ ## Dự án mới và maintain
41
+
42
+ Với maintain, đọc feature tương tự trước: reuse UI public APIs, theme, form schema, client/query keys,
43
+ auth/state/router và test helpers. Không tạo thêm HTTP client, store, navigation container hay wrappers
44
+ khi common hiện tại đáp ứng. Với dự án mới, đề xuất cấu trúc feature và state/data boundaries vừa đủ;
45
+ so sánh các lựa chọn quan trọng trước khi chốt. Ports/adapters, factory hay global state cần vấn đề cụ thể,
46
+ không áp như checklist. Xem [Project conventions](project-conventions.md) và [Solution workflow](solution-workflow.md).
47
+
48
+ Web: xác định router/version; tách state UI/form/server, xử lý stale responses và pending mutations.
49
+ Next server phải validate/authorize mỗi operation, giữ credentials và private caches đúng boundary.
50
+ Mobile: xác định Expo/bare và platforms; giữ navigation/auth/account boundaries, keyboard/safe areas,
51
+ lifecycle và secure storage. Offline queue/permissions chỉ thêm khi yêu cầu thực tế cần chúng.
52
+
53
+ ## Ví dụ đầu ra
54
+
55
+ - Web search: route dùng client/query/FormField hiện có; loading/empty/error/latest-result; tests gắn AC,
56
+ keyboard/focus và build/browser evidence thực có. Không thêm Next.js vào React SPA.
57
+ - Mobile profile: screen dùng navigator/theme/client đã có; validation/save/expiry/back/account changes;
58
+ JS/native/device matrix phân biệt Android và iOS, ghi rõ checks bị chặn.
59
+
60
+ Đây là output minh họa, không phải kết quả đã chạy. [Full-stack example](examples/fullstack-web.md) và
61
+ [React Native example](examples/react-native-app.md) liên kết skills vào luồng spec → code → review.
62
+
63
+ ## Kiểm chứng và nguồn
64
+
65
+ Chạy lint/type/test/build theo scripts thực của ứng dụng. Browser checks phải có browser/server thật;
66
+ mocked component test không chứng minh SSR/authorization. Với native, JS tests không xác minh iOS/Android;
67
+ ghi simulator/device/build result riêng. `aih verify/eval` chỉ xuất checklist/dataset và không chạy chúng.
68
+ Không có trial ứng dụng/browser/native hoặc live-model benchmark trong nâng cấp Harness này.
69
+
70
+ Đối chiếu official docs theo version dự án (tham khảo ngày 2026-10-12):
71
+ - [React state structure](https://react.dev/learn/choosing-the-state-structure): tránh duplicate/derived state lưu dư.
72
+ - [Next.js testing](https://nextjs.org/docs/app/guides/testing): chọn đúng unit/component/E2E boundary;
73
+ kiểm tra runner support cho async Server Components.
74
+ - [React Native testing](https://reactnative.dev/docs/testing-overview): tách JS component và native/device evidence.
75
+ - [React Navigation auth flow](https://reactnavigation.org/docs/auth-flow/): chỉ áp dụng khi app đang dùng
76
+ React Navigation; giữ version-specific auth/back behavior, không mặc định cài router đó.
@@ -1,127 +1,83 @@
1
1
  # Bắt đầu với AI Harness
2
2
 
3
- **Cài một lần → ghi context dự án → giao việc cho AI → kiểm tra kết quả.**
4
-
5
- Cần Node.js **22+**, Git và một repository ứng dụng đã tồn tại. AI IDE/assistant phải đọc được file trong repository; cách tự nạp `AGENTS.md` và skills phụ thuộc AI host. CLI `aih` quản lý hướng dẫn, không chạy LLM hay tạo ứng dụng.
3
+ **Cài vào project → mở AI → giao việc → review kết quả.** Cần Node.js **22+** và một thư mục project. Với dự án mới, tạo thư mục/repository trước; Harness không tạo ứng dụng hay chạy model.
6
4
 
7
5
  ## 1. Cài vào project
8
6
 
7
+ Chạy tại thư mục gốc của project:
8
+
9
9
  ```bash
10
- npm install -g @manhd_d/ai-harness
11
- cd /path/to/existing-project
12
- aih init --adapters java-spring
13
- aih check
10
+ npx --yes @manhd_d/ai-harness init --detect
14
11
  ```
15
12
 
16
- Chọn module theo nhu cầu, không cần cài cả bộ:
13
+ Lệnh nhận diện stack từ file ở thư mục gốc và cài hướng dẫn tương ứng. Nếu báo chưa nhận diện được, thay `--detect` theo bảng; bỏ `--detect` để chỉ cài quy tắc chung (Core):
17
14
 
18
- | Nhu cầu | Tham số cho `aih init` |
15
+ | Project / nhu cầu | Tham số cho `init` |
19
16
  | --- | --- |
20
- | Spring Boot API | `--adapters java-spring` |
21
- | React/Next.js + UI | `--adapters react-nextjs --capabilities uiux` |
22
- | Astro tool nhỏ | `--adapters astro` |
23
- | Website có quảng cáo | `--adapters astro --capabilities monetization` |
24
- | Viết tài liệu từ ý tưởng hoặc tài liệu BA | `--capabilities product` |
25
- | Spring + tài liệu + Kubernetes | `--adapters java-spring,kubernetes --capabilities product,devops` |
26
-
27
- `aih list` xem toàn bộ module. `aih init --dry-run` xem trước thay đổi với cùng tham số đã chọn. Với project đã cài, đổi module trong `.harness/project.json` rồi dùng `aih update`, không chạy lại `init` với lựa chọn khác.
28
-
29
- ## 2. Ghi context và bắt đầu giao việc
30
-
31
- Chạy `aih setup` rồi nhờ AI đọc workflow `project-setup`. Đây là gợi ý cho AI host, không phải wizard
32
- nhập liệu của CLI. AI đọc repo trước, chỉ hỏi 1–3 câu A/B/C cho điểm còn thiếu, có đề xuất và lý do.
33
- Không cần xác nhận lại thông tin hoặc quyền triển khai đã có.
34
-
35
- Điền `.harness/local.md` bằng thông tin thực của project:
36
-
37
- - Mục tiêu, phạm vi và quy tắc nghiệp vụ quan trọng.
38
- - Stack/phiên bản, database, cấu trúc service/module.
39
- - Lệnh build/test đã xác nhận chạy được.
40
- - Đường dẫn tài liệu BA, conventions và những ràng buộc cần giữ.
41
-
42
- Mở project trong AI IDE và giao yêu cầu, ví dụ:
43
-
44
- > Đọc AGENTS.md và .harness/local.md, chỉ nạp skill liên quan. Thêm API tìm kiếm khách hàng theo yêu cầu này: … Làm rõ điểm chưa chắc chắn, đề xuất acceptance scenarios; sau khi thống nhất scope, triển khai, chạy test phù hợp và báo cáo kết quả thực chạy.
45
-
46
- Bạn không cần gọi từng role/skill thủ công. Nếu host không tự phát hiện hướng dẫn, yêu cầu assistant đọc các đường dẫn trên. `aih skills` xem danh sách; `aih skill <tên>` đọc một skill khi cần.
47
-
48
- Review diff và kết quả test, rồi commit `AGENTS.md`, `.harness/`, `.agents/skills/` và tài liệu thay đổi cùng project. Sửa quy tắc riêng trong `.harness/local.md`; giữ nguyên snapshot do Harness quản lý.
17
+ | Spring Boot | `--adapters java-spring` |
18
+ | React / Next.js | `--adapters react-nextjs` |
19
+ | React Native / Expo | `--adapters react-native` |
20
+ | Python AI / RAG | `--adapters ai-python` |
21
+ | Astro tool / website | `--adapters astro` |
22
+ | Spring + Next.js | `--adapters java-spring,react-nextjs` |
23
+ | Viết tài liệu BA | `--capabilities product` |
49
24
 
50
- Lệnh/tool chung thuộc `.harness/environment.json`; đường dẫn máy riêng thuộc file ignored
51
- `.harness/machine.json`. `aih doctor` kiểm tra tham chiếu biến và sự hiện diện công cụ, không chạy chúng.
52
- Xem [cấu hình Maven nội bộ](project-configuration.md).
53
-
54
- ## 3. Tài liệu và spec khi cần
55
-
56
- Với capability `product`:
25
+ Ví dụ vừa code Spring vừa viết tài liệu:
57
26
 
58
27
  ```bash
59
- aih new-doc prd-lite
28
+ npx --yes @manhd_d/ai-harness init --adapters java-spring --capabilities product
60
29
  ```
61
30
 
62
- Lệnh tạo template `docs/product/prd-lite.md`; bạn và AI điền nội dung, nguồn và acceptance criteria. Chọn [Idea-driven](examples/idea-driven-project.md) nếu bắt đầu từ ý tưởng; chọn [Document-driven](examples/document-driven-project.md) nếu đã có tài liệu BA/Confluence.
63
-
64
- Khi một tính năng cần proposal/design/tasks/spec riêng:
31
+ Thêm `--capabilities uiux` khi cần UI/UX; `monetization` cho website có quảng cáo. [Danh mục đầy đủ](cli.md).
32
+ Với project đã cài, đổi lựa chọn trong `.harness/project.json` rồi dùng `update`.
65
33
 
66
- ```bash
67
- aih new-change add-customer-search
68
- ```
34
+ ## 2. Mở AI và giao việc
69
35
 
70
- Đây là bản nháp trong `openspec/changes/add-customer-search/`, chưa phải spec được duyệt.
71
- AI ghi câu trả lời thực tế trong `decisions.json`; kiểm tra bằng `aih ready add-customer-search --stage implement`.
72
- Sau code, ghi bằng chứng trong `verification.json` và chạy với `--stage review`. Xem [Change readiness](change-readiness.md). Sửa nhỏ, ít rủi ro có thể bỏ qua full spec với lý do rõ ràng; không bắt mọi task tạo đủ BRD/PRD/SRS.
36
+ Mở thư mục project trong công cụ AI, rồi gửi:
73
37
 
74
- `aih new-change` không cần OpenSpec CLI. Chỉ cài OpenSpec riêng khi cần validator/archive của công cụ đó; xem [OpenSpec](openspec.md).
38
+ > Đọc AGENTS.md và .harness/local.md. Khảo sát code, tài liệu và lệnh test hiện có;
39
+ > ghi context còn thiếu vào .harness/local.md, chỉ hỏi phần chưa rõ.
40
+ > Thực hiện yêu cầu: [mô tả công việc]. Chạy test phù hợp, báo cáo kết quả và phần chưa kiểm chứng.
75
41
 
76
- ## 4. Kiểm tra đúng thứ
42
+ Bạn có thể giao ý tưởng, tài liệu BA hoặc task code. Không cần gọi từng agent/skill.
43
+ Với web/mobile, giao màn hình hoặc tính năng theo common/API/state/navigation hiện có; [skills đã có](frontend-mobile.md).
44
+ Nếu công cụ chưa tự nạp hướng dẫn, xem [cách cấu hình công cụ AI](tool-setup/README.md).
45
+ Lệnh `setup` chỉ xuất gợi ý thiết lập, không phải bước bắt buộc để bắt đầu.
77
46
 
78
- | Lệnh | Ý nghĩa |
79
- | --- | --- |
80
- | `aih check` | Kiểm tra integrity của file Harness; không kiểm thử ứng dụng |
81
- | `aih doctor` | Kiểm tra công cụ và environment đã cấu hình; không chạy build/test |
82
- | `aih verify --scope all` | Xuất checklist, `executed: false`; không chạy build/test |
83
- | `aih eval --scope all` | Xuất tình huống và báo cáo chưa chấm; không gọi model |
84
- | Lệnh test của project | Do bạn, AI host hoặc CI thực chạy để xác minh code |
47
+ Review diff và test, rồi commit `AGENTS.md`, `.harness/`, `.agents/skills/` cùng code.
48
+ Quy tắc riêng sửa trong `.harness/local.md`; giữ nguyên file do Harness quản lý.
49
+ Lệnh/tool chung lưu trong `.harness/environment.json`; đường dẫn riêng máy trong `.harness/machine.json` được Git ignore. [Cấu hình Maven/JDK](project-configuration.md).
50
+ Cấu hình model là tùy chọn trong `.harness/agents.json`; chọn model tương thích với công cụ AI: [hướng dẫn](agent-configuration.md).
85
51
 
86
- Một lần `aih check` thành công không có nghĩa tính năng đã đúng. Ghi lệnh test thực chạy, kết quả và phần chưa kiểm chứng trong PR. Xem [đánh giá hành vi AI](../evals/README.md) nếu muốn đo hiệu quả Harness.
52
+ ## 3. Thêm tài liệu khi cần
87
53
 
88
- ## 5. Cập nhật: CLI trước, project sau
89
-
90
- Trên branch riêng, commit trạng thái hiện tại trước. Với cách cài global ở trên:
54
+ Với `product` đã cài, tạo bản nháp yêu cầu:
91
55
 
92
56
  ```bash
93
- npm install -g @manhd_d/ai-harness@latest
94
- aih --version
95
- aih check
96
- aih update --dry-run
97
- aih update
98
- aih check
57
+ npx --yes @manhd_d/ai-harness new-doc prd-lite
99
58
  ```
100
59
 
101
- `aih --version` là phiên bản CLI; `aih check` trả phiên bản snapshot trong project. `aih update` lấy bundle từ CLI đang cài (hoặc `--source`), **không tự tải npm**. Review diff, chạy test ứng dụng và commit snapshot/lock cùng nhau. Nếu báo drift, giữ lại thay đổi trong Git, chuyển tùy chỉnh sang `.harness/local.md` và khôi phục managed files trước khi update.
102
-
103
- Nếu cài local trong project, dùng `npm install --save-dev @manhd_d/ai-harness@latest` và `npx aih` thay cho `aih`.
104
-
105
- ## Đọc thêm theo nhu cầu
60
+ Tính năng cần spec riêng: dùng `new-change <id>`; [hướng dẫn spec](change-readiness.md).
61
+ Task nhỏ không cần bộ tài liệu đầy đủ. Không cần cài OpenSpec CLI để tạo bản nháp.
106
62
 
107
- - [CLI reference](cli.md) · [Full SDLC](end-to-end-workflow.md) · [Skill matrix](skill-matrix.md) · [Agent handoffs](agent-handoffs.md).
108
- - [Spring Boot API](examples/spring-boot-api.md) · [Full-stack](examples/fullstack-web.md) · [React Native](examples/react-native-app.md) · [Python AI/RAG](examples/ai-rag-service.md).
109
- - [Astro micro-tools](examples/astro-micro-tools.md) · [Astro + AdSense](examples/astro-adsense-microtools.md).
110
- - [Release guide](npm-release.md): dành cho maintainer; merge source không đồng nghĩa npm đã có bản mới.
63
+ ## 4. Kiểm tra và cập nhật
111
64
 
112
- ## Coding conventions
65
+ `check` kiểm tra file Harness; `verify` xuất checklist. Code cần **test của project** và review thực tế.
113
66
 
114
- Trước code, áp dụng [Project conventions](project-conventions.md): xác định new/maintain/mixed theo module, đọc chuẩn hiện có, tìm common và ghi lý do tạo mới. AI lưu nguồn và quyết định trong `.harness/local.md`; không hỏi lại thông tin đã rõ.
67
+ Trước cập nhật, tạo branch và commit trạng thái hiện tại. Xem trước, áp dụng rồi kiểm tra:
115
68
 
116
- ## BA/PO/SA/PM and coding tools
69
+ ```bash
70
+ npx --yes @manhd_d/ai-harness@latest update --dry-run
71
+ npx --yes @manhd_d/ai-harness@latest update
72
+ npx --yes @manhd_d/ai-harness@latest check
73
+ ```
117
74
 
118
- For a material new project choose `--capabilities product,architecture,delivery` with the actual adapter.
119
- Read [Solution workflow](solution-workflow.md) and the [setup guide for your coding tool](tool-setup/README.md).
120
- Skills/templates are selective context; use existing approved documents and compact notes when sufficient.
75
+ Review diff và chạy test project trước khi commit. Nếu có conflict, xem [cách xử lý](cli.md).
76
+ Dùng thường xuyên có thể cài global: `npm install -g @manhd_d/ai-harness`, rồi dùng `aih` thay cho `npx --yes @manhd_d/ai-harness`. Nâng CLI global trước khi `aih update`.
121
77
 
122
- ## Agent model and execution preferences
78
+ [Tra cứu & ví dụ theo nhu cầu](README.md).
123
79
 
124
- New installs seed `.harness/agents.json`: Sol recommended, hybrid/two concurrent agents only when
125
- supported; Luna low documentation, no automatic Astra escalation. Edit provider/model/reasoning and
126
- execution for your actual host. Use `aih setup --host codex` and [Agent configuration](agent-configuration.md).
127
- For a new economy consumer use `aih init --agent-preset economy`; never overwrite an existing config.
80
+ ## Docs/UI destinations
81
+ For idea-driven or existing-doc work, ask the AI to reuse or clarify input/output destinations,
82
+ canonical owners and source-write scope. Record them in project-owned artifacts.json/integrations.json;
83
+ `aih artifacts` shows declarations. See [Artifact contract](artifact-contract.md).
@@ -12,6 +12,7 @@ gốc được liên kết bên dưới; không sao chép quy tắc thành nhi
12
12
  | Adapter | [Registry](../harness.yaml), [adapter contract](adapters.md), [adapter assets](../adapters/) | Manifest `rules/skills/verification/evaluation` → [bundle/install](../cli/harness.js) → [installed verify/eval](../cli/adapters.js) |
13
13
  | Capability / skill | [Capability assets](../capabilities/), [schema/loader](../cli/capabilities.js) | Workflow/role bàn giao → exposed skill → [skill matrix](skill-matrix.md), [handoffs](agent-handoffs.md), [composition evals](../core/evals/composition.json) |
14
14
  | CLI / config | [CLI reference](cli.md), [implementation](../cli/), [templates](../templates/) | [Architecture/ownership](architecture.md), [project configuration](project-configuration.md), [tests](../tests/), [package smoke](../scripts/smoke-package.js) |
15
+ | Artifact / integration contracts | [Artifact contract](artifact-contract.md), [loader](../cli/artifacts.js), [seeds](../templates/artifacts.json) | Preserved project configs → setup/artifacts → Core/Product/UIUX workflows → routed new-doc / impact readiness → [tests](../tests/artifacts.test.js) and package smoke |
15
16
  | Agent preferences | [Canonical default](../config/agents.default.json), [configuration contract](agent-configuration.md) | Project-owned `agents.json` → read-only setup plan → [routing workflow](../core/workflows/agent-routing.md) → [host setup](tool-setup/README.md); tests verify preservation, not live model availability |
16
17
  | Quy trình sử dụng | [Getting started](getting-started.md), [full SDLC](end-to-end-workflow.md) | [Examples](examples/), [README](../README.md), [documentation workflows](documentation-workflows.md) |
17
18
  | Release / migration | [Versioning](versioning.md), [release policy](release-policy.md) | [Changelog](../CHANGELOG.md), [npm release](npm-release.md), [release workflow](../.github/workflows/npm-publish.yml) |