@manhd_d/ai-harness 0.0.0-stage → 0.6.2

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 (231) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/CONTRIBUTING.md +13 -0
  3. package/LICENSE +21 -0
  4. package/README.md +70 -2
  5. package/SECURITY.md +10 -0
  6. package/adapters/ai-python/adapter.yaml +46 -0
  7. package/adapters/ai-python/checks/verification.yaml +32 -0
  8. package/adapters/ai-python/evals/cases.json +25 -0
  9. package/adapters/ai-python/rules/architecture.md +3 -0
  10. package/adapters/ai-python/rules/database.md +3 -0
  11. package/adapters/ai-python/rules/performance.md +3 -0
  12. package/adapters/ai-python/rules/security.md +3 -0
  13. package/adapters/ai-python/rules.md +29 -0
  14. package/adapters/ai-python/skills/harness-ai-python-rag-access/SKILL.md +23 -0
  15. package/adapters/ai-python/skills/harness-ai-python-tool-safety/SKILL.md +23 -0
  16. package/adapters/astro/README.md +23 -0
  17. package/adapters/astro/adapter.yaml +31 -0
  18. package/adapters/astro/checks/verification.yaml +59 -0
  19. package/adapters/astro/evals/cases.json +45 -0
  20. package/adapters/astro/rules/architecture.md +9 -0
  21. package/adapters/astro/rules/deployment.md +9 -0
  22. package/adapters/astro/rules/performance.md +8 -0
  23. package/adapters/astro/rules/security.md +9 -0
  24. package/adapters/astro/rules.md +17 -0
  25. package/adapters/astro/skills/harness-astro-cloudflare/SKILL.md +27 -0
  26. package/adapters/astro/skills/harness-astro-islands/SKILL.md +28 -0
  27. package/adapters/astro/skills/harness-astro-microfrontend/SKILL.md +27 -0
  28. package/adapters/astro/skills/harness-astro-performance/SKILL.md +27 -0
  29. package/adapters/astro/skills/harness-astro-project-architecture/SKILL.md +28 -0
  30. package/adapters/astro/skills/harness-astro-seo/SKILL.md +28 -0
  31. package/adapters/java-spring/adapter.yaml +42 -0
  32. package/adapters/java-spring/checks/verification.yaml +33 -0
  33. package/adapters/java-spring/evals/cases.json +25 -0
  34. package/adapters/java-spring/rules/architecture.md +3 -0
  35. package/adapters/java-spring/rules/database.md +3 -0
  36. package/adapters/java-spring/rules/performance.md +3 -0
  37. package/adapters/java-spring/rules/security.md +3 -0
  38. package/adapters/java-spring/rules.md +34 -0
  39. package/adapters/java-spring/skills/harness-java-spring-database-migration/SKILL.md +23 -0
  40. package/adapters/java-spring/skills/harness-java-spring-kafka-outbox/SKILL.md +23 -0
  41. package/adapters/java-spring/skills/harness-java-spring-spring-api/SKILL.md +23 -0
  42. package/adapters/kubernetes/adapter.yaml +58 -0
  43. package/adapters/kubernetes/checks/verification.yaml +63 -0
  44. package/adapters/kubernetes/evals/cases.json +25 -0
  45. package/adapters/kubernetes/rules/architecture.md +5 -0
  46. package/adapters/kubernetes/rules/reliability.md +5 -0
  47. package/adapters/kubernetes/rules/security.md +5 -0
  48. package/adapters/kubernetes/rules.md +9 -0
  49. package/adapters/kubernetes/skills/harness-kubernetes-helm-release/SKILL.md +26 -0
  50. package/adapters/kubernetes/skills/harness-kubernetes-rollout-safety/SKILL.md +27 -0
  51. package/adapters/kubernetes/skills/harness-kubernetes-workload-review/SKILL.md +27 -0
  52. package/adapters/react-native/adapter.yaml +28 -0
  53. package/adapters/react-native/checks/verification.yaml +30 -0
  54. package/adapters/react-native/evals/cases.json +25 -0
  55. package/adapters/react-native/rules/architecture.md +3 -0
  56. package/adapters/react-native/rules/database.md +3 -0
  57. package/adapters/react-native/rules/performance.md +3 -0
  58. package/adapters/react-native/rules/security.md +3 -0
  59. package/adapters/react-native/rules.md +23 -0
  60. package/adapters/react-native/skills/harness-react-native-device-permissions/SKILL.md +23 -0
  61. package/adapters/react-native/skills/harness-react-native-offline-sync/SKILL.md +23 -0
  62. package/adapters/react-nextjs/adapter.yaml +28 -0
  63. package/adapters/react-nextjs/checks/verification.yaml +49 -0
  64. package/adapters/react-nextjs/evals/cases.json +25 -0
  65. package/adapters/react-nextjs/rules/architecture.md +3 -0
  66. package/adapters/react-nextjs/rules/database.md +3 -0
  67. package/adapters/react-nextjs/rules/performance.md +3 -0
  68. package/adapters/react-nextjs/rules/security.md +3 -0
  69. package/adapters/react-nextjs/rules.md +27 -0
  70. package/adapters/react-nextjs/skills/harness-react-nextjs-accessible-ui/SKILL.md +23 -0
  71. package/adapters/react-nextjs/skills/harness-react-nextjs-server-boundaries/SKILL.md +23 -0
  72. package/bin/aih.js +4 -0
  73. package/capabilities/devops/README.md +24 -0
  74. package/capabilities/devops/capability.json +20 -0
  75. package/capabilities/devops/checks/verification.json +17 -0
  76. package/capabilities/devops/evals/cases.json +25 -0
  77. package/capabilities/devops/skills/harness-devops-ci-cd/SKILL.md +27 -0
  78. package/capabilities/devops/skills/harness-devops-deployment/SKILL.md +27 -0
  79. package/capabilities/devops/skills/harness-devops-docker/SKILL.md +25 -0
  80. package/capabilities/devops/skills/harness-devops-incident-response/SKILL.md +27 -0
  81. package/capabilities/devops/skills/harness-devops-infrastructure/SKILL.md +28 -0
  82. package/capabilities/devops/skills/harness-devops-observability/SKILL.md +25 -0
  83. package/capabilities/devops/workflows/incident-recovery.md +12 -0
  84. package/capabilities/devops/workflows/pr-to-production.md +16 -0
  85. package/capabilities/monetization/README.md +40 -0
  86. package/capabilities/monetization/capability.json +25 -0
  87. package/capabilities/monetization/checks/verification.json +53 -0
  88. package/capabilities/monetization/evals/cases.json +45 -0
  89. package/capabilities/monetization/skills/harness-monetization-ad-placement-ux/SKILL.md +28 -0
  90. package/capabilities/monetization/skills/harness-monetization-adsense-integration/SKILL.md +29 -0
  91. package/capabilities/monetization/skills/harness-monetization-analytics-revenue/SKILL.md +28 -0
  92. package/capabilities/monetization/skills/harness-monetization-publisher-compliance/SKILL.md +28 -0
  93. package/capabilities/monetization/skills/harness-monetization-seo-growth/SKILL.md +28 -0
  94. package/capabilities/monetization/templates/ad-placement-review.md +31 -0
  95. package/capabilities/monetization/templates/analytics-report.md +38 -0
  96. package/capabilities/monetization/templates/privacy-consent-checklist.md +39 -0
  97. package/capabilities/monetization/templates/site-monetization-plan.md +46 -0
  98. package/capabilities/monetization/workflows/site-to-adsense.md +19 -0
  99. package/capabilities/monetization/workflows/traffic-to-revenue-review.md +14 -0
  100. package/capabilities/product/README.md +78 -0
  101. package/capabilities/product/agents/business-analyst.md +15 -0
  102. package/capabilities/product/agents/product-manager.md +15 -0
  103. package/capabilities/product/agents/product-owner.md +15 -0
  104. package/capabilities/product/agents/project-manager.md +15 -0
  105. package/capabilities/product/agents/requirements-reviewer.md +15 -0
  106. package/capabilities/product/capability.json +55 -0
  107. package/capabilities/product/checks/verification.json +41 -0
  108. package/capabilities/product/evals/cases.json +35 -0
  109. package/capabilities/product/skills/harness-product-acceptance-criteria/SKILL.md +25 -0
  110. package/capabilities/product/skills/harness-product-backlog-prioritization/SKILL.md +25 -0
  111. package/capabilities/product/skills/harness-product-brd-generation/SKILL.md +25 -0
  112. package/capabilities/product/skills/harness-product-business-analysis/SKILL.md +26 -0
  113. package/capabilities/product/skills/harness-product-document-review/SKILL.md +26 -0
  114. package/capabilities/product/skills/harness-product-idea-discovery/SKILL.md +27 -0
  115. package/capabilities/product/skills/harness-product-knowledge-analysis/SKILL.md +28 -0
  116. package/capabilities/product/skills/harness-product-prd-generation/SKILL.md +26 -0
  117. package/capabilities/product/skills/harness-product-product-research/SKILL.md +27 -0
  118. package/capabilities/product/skills/harness-product-srs-generation/SKILL.md +28 -0
  119. package/capabilities/product/skills/harness-product-traceability/SKILL.md +24 -0
  120. package/capabilities/product/skills/harness-product-use-case-generation/SKILL.md +26 -0
  121. package/capabilities/product/skills/harness-product-user-stories/SKILL.md +25 -0
  122. package/capabilities/product/templates/acceptance-criteria.md +27 -0
  123. package/capabilities/product/templates/backlog.md +23 -0
  124. package/capabilities/product/templates/brd.md +43 -0
  125. package/capabilities/product/templates/business-rules.md +27 -0
  126. package/capabilities/product/templates/decision-log.md +7 -0
  127. package/capabilities/product/templates/delivery-plan.md +18 -0
  128. package/capabilities/product/templates/idea.md +38 -0
  129. package/capabilities/product/templates/prd-lite.md +39 -0
  130. package/capabilities/product/templates/prd.md +36 -0
  131. package/capabilities/product/templates/product-brief.md +27 -0
  132. package/capabilities/product/templates/research.md +31 -0
  133. package/capabilities/product/templates/review-report.md +26 -0
  134. package/capabilities/product/templates/source-register.md +19 -0
  135. package/capabilities/product/templates/srs.md +46 -0
  136. package/capabilities/product/templates/traceability.md +23 -0
  137. package/capabilities/product/templates/use-cases.md +34 -0
  138. package/capabilities/product/workflows/change-impact-analysis.md +15 -0
  139. package/capabilities/product/workflows/confluence-to-spec.md +21 -0
  140. package/capabilities/product/workflows/document-driven.md +13 -0
  141. package/capabilities/product/workflows/idea-driven.md +13 -0
  142. package/capabilities/product/workflows/idea-to-prd.md +20 -0
  143. package/capabilities/uiux/README.md +21 -0
  144. package/capabilities/uiux/capability.json +23 -0
  145. package/capabilities/uiux/checks/verification.json +17 -0
  146. package/capabilities/uiux/design-system/tokens.example.json +21 -0
  147. package/capabilities/uiux/evals/cases.json +15 -0
  148. package/capabilities/uiux/integrations/confluence.md +10 -0
  149. package/capabilities/uiux/integrations/figma.md +10 -0
  150. package/capabilities/uiux/skills/harness-uiux-design-review/SKILL.md +24 -0
  151. package/capabilities/uiux/skills/harness-uiux-design-system/SKILL.md +24 -0
  152. package/capabilities/uiux/skills/harness-uiux-figma-design/SKILL.md +26 -0
  153. package/capabilities/uiux/skills/harness-uiux-requirements-analysis/SKILL.md +26 -0
  154. package/capabilities/uiux/skills/harness-uiux-screen-planning/SKILL.md +24 -0
  155. package/capabilities/uiux/skills/harness-uiux-user-flow/SKILL.md +25 -0
  156. package/capabilities/uiux/templates/requirements.md +7 -0
  157. package/capabilities/uiux/templates/screen-spec.md +15 -0
  158. package/capabilities/uiux/workflows/docs-to-figma.md +22 -0
  159. package/capabilities/uiux/workflows/idea-to-figma.md +11 -0
  160. package/cli/adapter-schema.js +42 -0
  161. package/cli/adapters.js +149 -0
  162. package/cli/capabilities.js +93 -0
  163. package/cli/composition.js +96 -0
  164. package/cli/evaluation-contract.js +40 -0
  165. package/cli/files.js +125 -0
  166. package/cli/harness.js +255 -0
  167. package/cli/main.js +119 -0
  168. package/cli/module-contract.js +29 -0
  169. package/core/agents/implementer.md +16 -0
  170. package/core/agents/planner.md +16 -0
  171. package/core/agents/reviewer.md +16 -0
  172. package/core/agents/security-reviewer.md +16 -0
  173. package/core/agents/test-engineer.md +16 -0
  174. package/core/checks/verification.json +28 -0
  175. package/core/evals/cases.json +25 -0
  176. package/core/evals/composition.json +33 -0
  177. package/core/policies/permissions.md +17 -0
  178. package/core/policies/security.md +15 -0
  179. package/core/rules/context.md +15 -0
  180. package/core/rules/foundations.md +24 -0
  181. package/core/skills/harness-ai-evaluation/SKILL.md +21 -0
  182. package/core/skills/harness-debugging/SKILL.md +20 -0
  183. package/core/skills/harness-review/SKILL.md +20 -0
  184. package/core/skills/harness-spec/SKILL.md +21 -0
  185. package/core/skills/harness-tdd/SKILL.md +20 -0
  186. package/core/workflows/bugfix.md +9 -0
  187. package/core/workflows/spec-to-code.md +19 -0
  188. package/core/workflows/upgrade.md +10 -0
  189. package/docs/adapters.md +83 -0
  190. package/docs/agent-handoffs.md +79 -0
  191. package/docs/architecture.md +107 -0
  192. package/docs/cli.md +109 -0
  193. package/docs/documentation-workflows.md +71 -0
  194. package/docs/end-to-end-workflow.md +116 -0
  195. package/docs/examples/ai-rag-service.md +60 -0
  196. package/docs/examples/astro-adsense-microtools.md +80 -0
  197. package/docs/examples/astro-micro-tools.md +125 -0
  198. package/docs/examples/document-driven-project.md +62 -0
  199. package/docs/examples/fullstack-web.md +80 -0
  200. package/docs/examples/idea-driven-project.md +71 -0
  201. package/docs/examples/react-native-app.md +57 -0
  202. package/docs/examples/spring-boot-api.md +100 -0
  203. package/docs/getting-started.md +100 -0
  204. package/docs/monetization.md +53 -0
  205. package/docs/npm-release.md +57 -0
  206. package/docs/openspec.md +23 -0
  207. package/docs/pull-request.md +37 -0
  208. package/docs/reference-analysis.md +22 -0
  209. package/docs/release-policy.md +17 -0
  210. package/docs/skill-matrix.md +134 -0
  211. package/docs/verification.md +20 -0
  212. package/docs/versioning.md +96 -0
  213. package/evals/README.md +45 -0
  214. package/evals/cases.json +41 -0
  215. package/harness.yaml +24 -0
  216. package/integrations/confluence/README.md +31 -0
  217. package/integrations/github/README.md +17 -0
  218. package/integrations/github/pull_request_template.md +22 -0
  219. package/integrations/gitlab/README.md +9 -0
  220. package/integrations/gitlab/harness-ci.yml +10 -0
  221. package/integrations/mcp/README.md +16 -0
  222. package/integrations/mcp/server-inventory.example.json +16 -0
  223. package/package.json +42 -4
  224. package/scripts/score-eval.js +40 -0
  225. package/templates/AGENTS.md +18 -0
  226. package/templates/openspec/.openspec.yaml +1 -0
  227. package/templates/openspec/config.yaml +14 -0
  228. package/templates/openspec/design.md +14 -0
  229. package/templates/openspec/proposal.md +19 -0
  230. package/templates/openspec/spec.md +8 -0
  231. package/templates/openspec/tasks.md +11 -0
@@ -0,0 +1,107 @@
1
+ # Architecture and scope
2
+
3
+ AI Harness is a versioned instruction and workflow distribution framework. Its executable part is a
4
+ local installer and integrity checker. It is not an LLM gateway, an orchestration server or a sandbox.
5
+
6
+ | Layer | Responsibility | Owner |
7
+ | --- | --- | --- |
8
+ | core/rules | Evidence, context loading, code/change discipline | Harness maintainers |
9
+ | core/policies | Permission and security contracts | Maintainers plus runtime admins |
10
+ | core/skills | Repeatable task procedures | Harness maintainers |
11
+ | core/agents | Role inputs, outputs and authority limits | Harness maintainers |
12
+ | core/workflows | Stage order and review evidence | Harness maintainers |
13
+ | adapters | Technology-specific defaults and suggested checks | Adapter maintainers |
14
+ | capabilities | Optional cross-stack product, UI/UX, DevOps and ad monetization workflows | Capability maintainers |
15
+ | integrations | GitHub, GitLab and MCP setup contracts/templates | Project/runtime owners |
16
+ | templates | AGENTS entry point and OpenSpec draft structure | Harness maintainers |
17
+ | CLI + lock | Deterministic installation and update conflicts | Executable framework |
18
+ | project overrides | Domain facts, actual versions, approved exceptions | Consumer project |
19
+
20
+ ## Installation design
21
+ The consumer receives a vendored .harness snapshot and .agents/skills/harness-* files. AGENTS.md gets
22
+ one marked block. The CLI leaves text outside that block intact. The generated .harness/lock.json records
23
+ schema version, release version, selected adapters, each owned content hash and an aggregate hash.
24
+ The hashes detect accidental drift; they are not signatures and cannot detect a coordinated malicious
25
+ edit to both payload and lock. Review source commit provenance and consumer lock diffs in Git.
26
+
27
+ Project-owned seeds: .harness/project.json, .harness/local.md and openspec/config.yaml. Updates preserve
28
+ their contents. Existing openspec specs/changes are never rewritten. Only previously owned, unchanged
29
+ files can be deleted when a new bundle removes them. Unknown user files are never swept away.
30
+ Identical pre-existing payload may be adopted; conflicting payload aborts the entire preflight.
31
+
32
+ init/update take an exclusive installation marker, preflight changes, and write files atomically one at
33
+ a time. Ordinary write failures roll back bytes already changed. This is not a crash-safe multi-file
34
+ filesystem transaction: a power loss, process kill or rollback I/O failure can leave partial state.
35
+ Commit consumer state before updates; after interruption inspect the marker, run check and restore from Git.
36
+ Empty directories may remain after rollback/removal. Symlinked roots/paths are intentionally unsupported.
37
+ Concurrent hostile filesystem mutation is outside the threat model; run in a trusted local workspace.
38
+
39
+ ## Agent/runtime boundary
40
+ Roles are Markdown handoff contracts. The host decides tool execution and delegation. A role document
41
+ does not create another agent or supply an API key. Use the same framework in an IDE assistant or your
42
+ own model-backed runtime; actual permissions, cost limits and network allowlists live in that runtime.
43
+
44
+ ## Advertising monetization capability
45
+
46
+ `capabilities/monetization/` is an optional, stack-neutral guide for legitimate publisher readiness, safe ad UX, SEO and revenue analysis. It does not install provider SDKs, access Google accounts, claim consent compliance or guarantee approval/revenue. Templates are vendored into the selected consumer under `.harness/capabilities/monetization/templates/`; `aih new-doc` still only scaffolds Product documents. Owners copy monetization templates to project-owned `docs/monetization/` using authorized filesystem tools. Review [Monetization guide](monetization.md).
47
+
48
+ ## Astro static-first adapter
49
+
50
+ Astro là technology adapter độc lập (`adapters/astro/`), không phải capability chung, dùng chung Core/Product/UIUX/DevOps khi được chọn. Sáu skills tập trung website tool tĩnh, islands, SEO, performance, Cloudflare và đường nâng cấp Micro Frontend. `aih detect` nhận diện `astro` trong root `package.json` và bỏ nhận diện React/Next chỉ đến từ `react-dom` khi dùng Astro Islands (trừ khi có `next`). Không thêm Astro runtime vào Harness và không tự chạy build/deployment. Xem [Astro walkthrough](examples/astro-micro-tools.md).
51
+
52
+ ## Extending adapters
53
+ Add adapters/<id>/adapter.yaml (schema 2), rules.md, rules/, namespaced skills/, checks/verification.yaml
54
+ and evals/cases.json. Register the id in harness.yaml; add detection, installation and evaluation cases.
55
+ See docs/adapters.md for the strict JSON-compatible YAML contract. Detection is opt-in and read-only;
56
+ checks are advisory and never executed. Installed capabilities are read from the locked snapshot, not
57
+ from the latest global CLI source. Core TDD/debug/review are not duplicated in adapters.
58
+
59
+ ## npm distribution
60
+ The package exposes bin/aih.js as `aih`. It uses native JavaScript ES modules and Node.js built-ins:
61
+ there is no Python bridge, transpilation step, runtime dependency, network client or install hook.
62
+ Source paths resolve relative to the package, not cwd. The target defaults to cwd. Local node_modules
63
+ installation is an explicit exception to overlap rejection; payload destinations never include node_modules.
64
+ The npm files allowlist ships runtime assets including the hidden OpenSpec template. A smoke test packs
65
+ and installs a real tarball globally and locally without registry access. Development tests and fixtures
66
+ are excluded from distribution. Only the development smoke script launches npm subprocesses.
67
+
68
+ ## Optional capabilities (0.4.0)
69
+
70
+ Capabilities differ from technology adapters: they represent reusable workflows such as UI/UX,
71
+ not runtime stack defaults. A registered capability contains `capability.json` schema 1,
72
+ namespaced `SKILL.md` files and workflow contracts, installed only when selected. CLI copies
73
+ the selected capability under `.harness/capabilities/<id>/` and exposes its skills to
74
+ `.agents/skills/`. The existing Core and technology adapter contracts remain unchanged.
75
+
76
+ `aih skills` exposes metadata-only catalog and `aih skill <name>` retrieves a single locked
77
+ skill after drift validation. The agent host controls actual skill activation and remote MCP.
78
+ For package size, source npm distribution currently bundles all capabilities, but consumer
79
+ snapshot and AI context are selective; split distributable packages only when size warrants it.
80
+
81
+ ## Product documentation capability (0.5.0)
82
+
83
+ An optional `product` capability owns business-analysis and product-documentation
84
+ role contracts and templates. Capability schema-1 now supports optional unique safe
85
+ `agents` and `templates` Markdown path lists (required fields remain unchanged).
86
+ Role files must include Inputs, Outputs, Permissions and limits, Handoff sections.
87
+ The existing `uiux` manifest without these optional fields remains valid.
88
+ Selected capability artifacts are hashed and installed with the existing lock safety.
89
+
90
+ `aih new-doc <type>` reads a locked, drift-free Product template, creates
91
+ `docs/product/<type>.md` as project-owned data, and refuses overwrite/symlinked
92
+ destinations. It never fills confidential content, fetches Confluence or auto-approves.
93
+ The approved PRD/BRD/stories/AC serve as source of truth for UI/UX and OpenSpec.
94
+
95
+ ## DevOps and Kubernetes composition (0.6.0)
96
+
97
+ DevOps is an optional stack-neutral capability for release procedures and SRE; the Kubernetes adapter owns workload/Helm details. Product role/template support from 0.5 remains unchanged. Both are installed only when selected, vendored and hash-locked alongside existing modules. Integrations/runtime permissions are independently administered; no instructions can grant cloud access, override Core approval gates or trigger production changes. `aih verify`/`aih eval` use adapter-only defaults; opt in to Core and capability scenarios with `--scope all`, without executing runtime checks.
98
+
99
+ ## Foundation hardening (in source; candidate not published)
100
+
101
+ `cli/composition.js` validates a selected module graph before copying managed content. Optional `module_version`, hard `requires`, soft `recommends`, `conflicts` and `compatible_adapters` use namespaced refs like `adapter:kubernetes`. Cycles, unknown refs, missing required or explicitly incompatible modules fail before writes; recommendations only warn. Config and lock schemas remain 1, and module metadata is pinned inside installed snapshots.
102
+
103
+ `aih verify/eval --scope all` reads Core, selected adapters/capabilities and matching cross-module scenarios from locked files. Default without scope is still adapter-only for compatibility. Checklists are advisory, evaluations human-scored, and no local/remote commands or models run. See [release policy](release-policy.md).
104
+
105
+ ## Documented end-to-end usage
106
+
107
+ The cross-module route is described in [Getting started](getting-started.md), [Full SDLC](end-to-end-workflow.md), [Skill matrix](skill-matrix.md) and [Agent handoffs](agent-handoffs.md). All roles/skills remain instruction contracts. The four [stack walkthroughs](examples/spring-boot-api.md) illustrate permitted integrations, not a runnable scaffold or orchestration engine.
package/docs/cli.md ADDED
@@ -0,0 +1,109 @@
1
+ # CLI contract
2
+
3
+ Invocation: `aih COMMAND [--target /existing/project]`.
4
+ Node.js 22+; built-in modules only; no network, subprocesses, remote provider calls or dependency installs.
5
+ Output is JSON on stdout on success; errors use stderr. Drift reports from check and failed evaluation reports use stdout with exit 1.
6
+ Exit 0 means the requested operation succeeded; 1 means validation/I/O/drift failure; 2 is a CLI usage error. Help and version are plain text; no arguments displays help.
7
+
8
+ | Command | Options | Effect |
9
+ | --- | --- | --- |
10
+ | list | --source | List validated adapters and namespaced skills |
11
+ | detect | --source | Read target build files and return heuristic matches with evidence |
12
+ | resolve | --source; --adapters a,b; --capabilities a,b | Validate module selection and compatibility; read-only |
13
+ | verify | --scope adapters/core/capabilities/all | Read installed advisory checks; executed false, no subprocesses |
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 |
16
+ | update | --source; --dry-run; --allow-major | Update unedited owned files and seed missing project files |
17
+ | check | none | Compare installed files/block with lock and selection; no writes |
18
+ | doctor | none | check plus executable presence on PATH; no execution |
19
+ | new-change ID | none | Create an unapproved OpenSpec draft using installed templates |
20
+ | new-doc TYPE | none | Copy a selected locked Product template to `docs/discovery/` (idea, research) or `docs/product/` (other types) without overwriting |
21
+ | skills | none | List installed skill metadata only |
22
+ | skill NAME | none | Read one installed, locked skill |
23
+
24
+ All commands default --target to the current directory. --source defaults to the installed package.
25
+ For a global install, upgrade the CLI with `npm install -g @manhd_d/ai-harness@latest` before
26
+ `aih update --dry-run` and `aih update`. Update never fetches npm. `aih --version` reports the CLI
27
+ version; `aih check` reports the project snapshot version. For a local install, update the local
28
+ dependency and use `npx aih`. Application tests must be executed separately.
29
+ --help/-h and --version/-v are available. Unknown, duplicate and inapplicable flags fail.
30
+ Source and target cannot contain one another, except source inside target/node_modules for local npm installs. Symlinks in roots, source
31
+ payload or destination paths are rejected. IDs are lowercase hyphenated slugs; archive is reserved.
32
+ Astro projects are detected from `astro` in package.json dependencies; `react-dom` used only for Astro islands is not a standalone React/Next.js detection when `next` is absent. Explicit `--adapters astro,react-nextjs` remains valid. `aih init --adapters astro` installs static-first rules/skills but no Astro packages or Cloudflare deployment.
33
+ Selection changes belong in .harness/project.json; unknown or duplicate adapters fail validation.
34
+
35
+ ## Optional monetization capability
36
+
37
+ `aih init --capabilities monetization` installs five stack-independent advertising/revenue skills and 2 Markdown workflows with 4 templates. Combine with `--adapters astro` or `react-nextjs`; `product` and `uiux` are optional. `aih verify --scope capabilities` gives an unexecuted manual publisher policy/consent checklist. `aih new-doc` is **Product-only**; the editor may copy installed monetization Markdown templates to user-owned `docs/monetization/` with explicit no-overwrite review. No Google account access, ads publishing or metrics APIs are provided. See [Monetization guide](monetization.md).
38
+
39
+ ## Ownership and conflict behavior
40
+ AGENTS.md ownership covers only text between the unique start/end markers, inclusive. Any modification
41
+ inside the block is drift; text before/after is user-owned. A malformed marker pair fails safely.
42
+ The snapshot and exposed harness skills are fully owned files. init refuses different unmanaged content;
43
+ identical content can be adopted. Existing OpenSpec config is project-owned and preserved, not validated
44
+ by this CLI. Run the upstream OpenSpec validator for spec/config correctness.
45
+ check detects changed/missing locked files and mismatched adapter selection. It does not verify all
46
+ application code, external tools, remote origin or model behavior. The lock is not a cryptographic signature.
47
+
48
+ ## Recovering failures
49
+ For conflicts, preserve custom work in Git, move project-specific rules to local.md and restore managed
50
+ files from the last install commit. Re-run dry-run. Do not manually regenerate hashes to suppress drift.
51
+ For an interrupted install inspect .harness-install.lock, confirm no installer is running, remove the
52
+ stale marker and restore a known-good installation from Git. Then check and retry on a branch.
53
+ There is no uninstall command; revert the installation commit. No command merges or publishes changes.
54
+
55
+ ## Capability commands
56
+ list/detect read the CLI package or explicit --source. verify/eval require a valid installed snapshot and
57
+ read its pinned metadata, rules and cases. Every referenced capability file must be covered by the lock.
58
+ Detection reads only declared paths directly in --target, capped at 1 MiB per file; malformed package JSON
59
+ and symlink probes fail. It does not infer framework versions or recurse into workspaces/node_modules.
60
+ init --detect refuses empty detection; it cannot be combined with --adapters or used on update.
61
+ verify labels file presence as candidate/not-detected, and manual checks as review-required. This is not
62
+ proof that a script exists, a command is safe, or a native toolchain is available. Commands are never run.
63
+ eval without --report emits {dataset, report}; save/edit only the report object as the submission.
64
+ Missing metadata, null/nonboolean scores, missing/duplicate/unknown cases or stale hashes fail validation.
65
+ Any false criterion returns status fail and exit 1, including a list of critical failures where relevant.
66
+
67
+ ## Selective capabilities and progressive skill loading (0.4.0)
68
+
69
+ - `aih init --capabilities uiux` is optional and independent of `--adapters`.
70
+ - `aih list` returns a `capabilities` array alongside adapter metadata.
71
+ - `aih skills` lists **installed** names/descriptions and paths only (no full skill bodies).
72
+ - `aih skill harness-uiux-figma-design` returns only that single installed, locked skill text.
73
+ - Invalid, duplicate and unknown capability IDs fail before installing. Custom capabilities must have a registered and valid source manifest.
74
+ - For existing installs, edit the `capabilities` array in `.harness/project.json`, then use `aih update --dry-run` followed by `aih update`. Init refuses an already installed conflicting selection.
75
+ - Selecting a capability copies only its managed snapshot and exposed skills into the consumer. npm package transport itself still contains all bundled capabilities.
76
+ - Neither `skills` nor `skill` contacts the network or runs model/tool integrations. Both require a drift-free installed snapshot.
77
+
78
+ ## Product docs and safe template scaffolding (0.5.0)
79
+
80
+ - `aih init --capabilities product` or `aih init --capabilities product,uiux` installs
81
+ Product workflows, role contracts, document templates and skill pointers.
82
+ - `aih list` returns capability agents/templates metadata alongside skills/workflows.
83
+ - `aih new-doc brd`, `aih new-doc prd`, `aih new-doc backlog`, etc. safely
84
+ copy **one** locked template from `.harness/capabilities/product/templates/` to
85
+ the project-owned `docs/product/<type>.md`. An existing file is never overwritten.
86
+ - `aih skills` lists descriptions only; `aih skill harness-product-brd-generation`
87
+ loads specific task guidance when needed.
88
+ - For installed projects, change `.harness/project.json` selection and run update/check.
89
+ - Documents must be populated by an authorized AI host using source references;
90
+ no command retrieves Confluence, calls an LLM or claims stakeholder approval.
91
+
92
+ ## Module composition (foundation hardening)
93
+
94
+ `aih resolve --adapters java-spring,kubernetes --capabilities product,uiux,devops` is read-only and validates dependencies, conflicts, version metadata, and declared compatibility before install. Optional recommendations only warn. Init/update use the same resolver.
95
+
96
+ ## Unified eval scopes
97
+
98
+ `aih verify --scope all` and `aih eval --scope all` include the Core and installed capability/adapter contracts plus matching cross-module scenarios. `adapters` is the unchanged default for backward compatibility. `capabilities` and `core` isolate those cases. Older installed snapshots without Core evaluation assets must be upgraded first. The CLI emits advisory checks and a human-scored report; it never executes provider commands or AI evaluations.
99
+
100
+ ## Human workflows and examples
101
+
102
+ See [Getting started](getting-started.md) for CLI boundaries, [Full SDLC](end-to-end-workflow.md) for review gates, [Skill matrix](skill-matrix.md) for valid skill IDs and [Agent handoffs](agent-handoffs.md) for role responsibilities. The four [examples](examples/fullstack-web.md) distinguish advisory `aih` commands from external build, AI and deployment tools.
103
+
104
+
105
+ ## Product document templates — discovery and specifications
106
+
107
+ With the optional `product` capability selected, `aih new-doc idea` and `aih new-doc research` safely create `docs/discovery/<type>.md` in the consumer repository. Other names including `prd-lite`, `srs` and `use-cases` create `docs/product/<type>.md`.
108
+
109
+ All types must be declared templates in the installed, hash-locked Product manifest. Commands refuse unknown names, traversal, overwrite, collisions and installation drift. These are **blank templates only**, not AI-generated content. Read [Documentation workflows](documentation-workflows.md) for the two intake paths and approvals.
@@ -0,0 +1,71 @@
1
+ # Documentation workflows — developer idea or existing BA documentation
2
+
3
+ AI Harness intentionally supports **two entry points feeding one engineering pipeline**. The Product capability supplies role contracts, skills and drafts to an authorized AI host; the `aih` CLI never performs conversations, web research, ingestion, writes to Confluence or automatic approval.
4
+
5
+ ## Bắt đầu nhanh — ví dụ đầy đủ
6
+
7
+ - [Walkthrough A: Từ ý tưởng developer đến spec và PR](examples/idea-driven-project.md): lệnh CLI, prompt thảo luận/research, cách review và chuyển sang OpenSpec.
8
+ - [Walkthrough B: Dự án có BRD/PRD/SRS của BA](examples/document-driven-project.md): đọc đúng nguồn, kiểm tra gap, tránh viết lại tài liệu chính thức và tạo OpenSpec theo approved AC.
9
+
10
+ Để thử tài liệu chưa merge, cài CLI từ **branch PR #10 đã review** thay vì mặc định `main` (xem [Getting started](getting-started.md)).
11
+
12
+ ## Mode A — Idea-driven (developer → BA/PM/PO)
13
+
14
+ 1. Install with `aih init --capabilities product` (add optional UI/UX/adapters only if needed).
15
+ 2. Use `aih skill harness-product-idea-discovery` to instruct the AI host to preserve the original idea, clarify user problem and discuss MVP options iteratively.
16
+ 3. Use `aih skill harness-product-product-research` and permitted search tools to support market/competitive/feasibility decisions. Record citations and dates; mark unavailable research as pending.
17
+ 4. Draft the **minimum necessary** documentation:
18
+ - Solo developer/small scope: `aih new-doc idea`, `aih new-doc research` (optional), `aih new-doc prd-lite`.
19
+ - Larger/product or enterprise scope: `aih new-doc brd`, `aih new-doc prd`, `aih new-doc srs`, `aih new-doc use-cases`, backlog, AC and traceability as needed.
20
+ 5. AI proposes and reviews; **developer or explicitly authorized owner** records accepted decisions and approval. Continue discussion when important UNKNOWNs affect scope.
21
+ 6. Feed approved requirement IDs and acceptance criteria into `aih new-change <id>` plus the appropriate adapter; a human reviews specs and PRs.
22
+
23
+ This is not an automatic document-writing command: each `new-doc` simply copies a pinned template into the **consumer** repository. An AI assistant with filesystem permissions must populate the draft; the human reviews.
24
+
25
+ ## Mode B — Document-driven (existing BA sources → engineering)
26
+
27
+ 1. Register official BRD, PRD, SRS, Confluence page URLs/revisions, owners and permission scopes in `docs/product/source-register.md`.
28
+ 2. Use the `document-driven` workflow in the installed Product capability to inspect authorized input and build requirements / AC traceability. If an official SRS already exists, do **not** generate a competing one by default.
29
+ 3. Create only missing artifacts or project-specific derived docs; identify contradictions/staleness and obtain explicit owner decisions.
30
+ 4. Approved source-linked requirements → UI/UX if applicable → OpenSpec change → implementation/testing/PR review. Carry source/version and FR/US/AC IDs through each handoff.
31
+ 5. When upstream BA documents change, run change-impact analysis and propose diffs; do not rewrite approved BA sources or code without review.
32
+
33
+ ## Storage and ownership
34
+
35
+ | Artifact | Canonical location | Notes |
36
+ | --- | --- | --- |
37
+ | Harness roles, skills, workflows, templates | `ai-harness/capabilities/product/` | Versioned framework source; not real customer requirements |
38
+ | Original developer idea and evidence summary | Consumer `docs/discovery/` | Project-owned, Git versioned; `idea.md`, `research.md` |
39
+ | Project product artifacts | Consumer `docs/product/` | BRD/PRD/PRD-lite/SRS/UC/backlog/AC/traceability |
40
+ | Source enterprise Confluence/BA documents | Existing authorized external system | Canonical source; keep URLs/revisions and permission scope, avoid copying confidential content |
41
+ | Technical change specifications | Consumer `openspec/` | OpenSpec design/tasks/delta specs linked to approved requirement IDs |
42
+ | UI designs | Figma or approved system of record | Store screen-to-URL/node ID mapping, not copies of entire design |
43
+ | Large binary documentation | Authorized object storage | Store references rather than large sensitive binaries in Git |
44
+
45
+ A product spanning many services should ideally have a single product-owned documentation home, with service-local OpenSpec/architecture and links back to approved requirements. If multiple repositories are used, explicitly designate the system of record and prevent parallel editing of copies.
46
+
47
+ ## Metadata and quality
48
+
49
+ Every derived artifact should identify owner, status (`draft`, `pending-review`, `approved`), version/source revision, review history and stable IDs. Facts from external sources require anchors; AI inferences, proposals and unverified assumptions are labeled separately. Unavailable evidence or approvals remain UNKNOWN/pending; do not invent them.
50
+
51
+ Review checks: source freshness and access authorization; conflicting statements; missing FR/NFR to story/AC mapping; unsupported quantitative NFR; duplicate IDs; orphaned stories/screens/OpenSpec; missing review decisions; no claims of unexecuted validation. The current `aih verify` emits advisory checks, not executed document verification.
52
+
53
+ ## Confluence export/publishing contract (future host integration)
54
+
55
+ Confluence is a **publication platform**, not a file type interchangeable with SRS/PRD. For Confluence imports, record space/page ID, URL, version, access class and section links, and reconcile against local derived docs. For exports, prepare Markdown/Confluence-friendly pages and a mapping from stable document ID → Confluence page ID/version. Require explicit target-page selection, write permission, diff preview and human approval before creating/updating pages. Use version checks and refuse unknown concurrent changes; avoid duplicate pages and unapproved overwrites. The CLI does not integrate with Atlassian APIs.
56
+
57
+ Future permission-scoped indexing/RAG may improve retrieval for very large corpora, but Git/Confluence remains canonical. Do not require an embeddings database to use either mode.
58
+
59
+ ## Example handoff
60
+
61
+ ```text
62
+ Mode: idea-driven (or document-driven)
63
+ Source: IDEA-001 (or SRC-001 revision 5)
64
+ Status: pending-review (until human approval)
65
+ Requirements: FR-001, NFR-001, US-001, AC-US-001-01
66
+ Artifacts: docs/product/prd.md; docs/product/srs.md (if applicable)
67
+ Proposed OpenSpec change: add-expense-categorization
68
+ Risks/unknowns: threshold and privacy requirements pending decision
69
+ Permissions: read/write authorized project branch only; no external publish or merge
70
+ Human reviewer: developer or named BA/PO
71
+ ```
@@ -0,0 +1,116 @@
1
+ # Full SDLC — Idea → Product → UI/UX → Spec → Code → Test → PR → Release → Operate
2
+
3
+ Tài liệu này là **bản đồ điều phối** toàn bộ Core + Product + UI/UX + technology adapters + DevOps. Mỗi module vẫn có workflow riêng; chỉ **kích hoạt module đã cài và thật sự liên quan**, không bắt buộc dùng đủ tất cả cho một change. Bắt đầu với [Getting started](getting-started.md); xem [ma trận 53 skills](skill-matrix.md) và [role handoffs](agent-handoffs.md).
4
+
5
+ > **Ranh giới thực thi:** `aih` cài/gợi ý rules, templates, skills và check/eval **advisory**. AI host/IDE và các công cụ bên ngoài thực hiện phân tích, code, test và tương tác hệ thống trong phạm vi được cấp quyền. Không có `aih run` hay `aih deploy`; các hành động ghi Figma, production hoặc merge phải có phê duyệt.
6
+
7
+ ## Monetization: tùy chọn business/marketing
8
+
9
+ Website miễn phí kiếm tiền quảng cáo có thể cài `--capabilities monetization` cùng Astro/React/Next.js. Sau khi xây các tool hữu ích và được phê duyệt về product, workflow của `monetization` xử lý SEO, publisher policy, consent, ad placement, hiệu quả quảng cáo và Page RPM; qua human approval trước mọi thay đổi ad/deploy. Đọc [Monetization](monetization.md) và [Astro + AdSense walkthrough](examples/astro-adsense-microtools.md). Không được giả định AdSense đã duyệt hoặc tự phát sinh traffic/clicks.
10
+
11
+ ## Astro micro-tools: một stack tùy chọn
12
+
13
+ Website tiện ích nhỏ có thể chọn riêng adapter `astro` để theo hướng static-first và chỉ thêm React Islands, API/Cloudflare Workers hoặc tách Micro Frontend khi có nhu cầu thật. Product/UX vẫn là optional capabilities như các stack khác. Đọc [Astro walkthrough](examples/astro-micro-tools.md). Không cần backend hay Kubernetes cho tool xử lý hoàn toàn trong trình duyệt.
14
+
15
+ ## Hai chế độ bắt đầu
16
+
17
+ - **Idea-driven:** developer trình bày ý tưởng → thảo luận và nghiên cứu có nguồn → PRD-lite hoặc BRD/PRD/SRS/use cases tùy độ phức tạp → human approval → OpenSpec.
18
+ - **Document-driven:** BA/PO đã có BRD/PRD/SRS/Confluence → lập source register với URL/revision/quyền, gap/traceability → chỉ tạo artifact còn thiếu → human approval → OpenSpec.
19
+
20
+ Cả hai chế độ đều dùng chung các stage phía dưới và không bắt buộc cài mọi capability. Xem [Documentation workflows](documentation-workflows.md).
21
+
22
+ ## 0. Chọn module và xác định ownership
23
+
24
+ ~~~bash
25
+ cd /path/to/existing-repository
26
+ aih resolve --adapters java-spring,react-nextjs,kubernetes --capabilities product,uiux,devops
27
+ aih init --adapters java-spring,react-nextjs,kubernetes --capabilities product,uiux,devops --dry-run
28
+ aih init --adapters java-spring,react-nextjs,kubernetes --capabilities product,uiux,devops
29
+ aih check
30
+ aih skills
31
+ ~~~
32
+
33
+ Lệnh trên là **ví dụ một repo chứa BE/FE/manifests**; nếu frontend/backend thuộc nhiều repo, `aih init` được chạy tại từng repo và chỉ chọn module phù hợp. `aih resolve` không tự bổ sung module được recommend. Không dùng `--detect` như công cụ quét toàn monorepo.
34
+
35
+ **Project input:** `AGENTS.md`, `.harness/local.md`, source repo, scope và branch, quyền truy cập nguồn; tạo `change-id` và xác định nguồn của từng artifact.
36
+
37
+ ## 1. Các stage, outputs và human gates
38
+
39
+ | Stage | Input và việc phải làm | Module / skills & roles | Output / điều kiện bàn giao |
40
+ | --- | --- | --- | --- |
41
+ | **1. Intake** | Ý tưởng, ticket, Confluence/PDF được phép đọc, version/source, scope | Product: `knowledge-analysis`, `business-analysis`; BA | Source register, FACT/INFERENCE/UNKNOWN, AS-IS/TO-BE, quyết định còn thiếu |
42
+ | **2. Business & Product** | Nguồn có traceability, mục tiêu, rules, NFR | Product: `brd-generation`, `prd-generation`, `user-stories`, `acceptance-criteria`, `backlog-prioritization`, `document-review`, `traceability`; PM/PO/requirements reviewer | PRD-lite hoặc BRD/PRD/SRS/UC khi cần, story IDs, AC, backlog; **Gate A: stakeholder duyệt**, không gắn nhãn Approved bởi AI |
43
+ | **3. UX/UI (nếu cần)** | Approved PRD/stories/AC; Figma file và quyền (nếu dùng) | UI/UX: `requirements-analysis` (chỉ khi cần), `user-flow`, `screen-planning`, `design-system`, `figma-design`, `design-review` | User flows, screen specs, component/tokens, Figma node IDs; **Gate B trước ghi Figma**, gate sau design review |
44
+ | **4. Technical spec** | Approved requirements, API constraints, architecture, DB/event contracts | Core: `harness-spec`, planner; tech adapter phù hợp; OpenSpec | `openspec/changes/<change-id>/` (proposal, design, tasks, delta specs), measurable AC; **Gate C: duyệt thay đổi có ảnh hưởng** |
45
+ | **5. Implementation** | Change được duyệt, kiến trúc, repo, tests | Core: `harness-tdd`, `harness-debugging` khi sửa lỗi; Spring/React/Native/AI adapter theo stack; implementer | Minimal code diff, unit/integration/contract tests, migration plans, không thay đổi unrelated files |
46
+ | **6. Verify & code review** | Diff, specs, test logs thực chạy | Core: `harness-review`, `harness-ai-evaluation` nếu AI; test-engineer/security-reviewer; `aih verify/eval --scope all` (chỉ plan) | Evidence của test chạy thực tế, scope chưa test, security findings, trace requirement → test; **Gate D: human PR review** |
47
+ | **7. Delivery** | PR đã review/CI và artifact định danh | DevOps: `ci-cd`, `docker`, `deployment`, `infrastructure`; Kubernetes: workload/Helm/rollout skills | Build provenance, deploy/rollback runbook, staging evidence; **Gate E: approve artifact + production environment** |
48
+ | **Optional: Monetization** | Website/tool hoạt động hợp lệ, có traffic, quyền publisher | `monetization`: `adsense-integration`, `ad-placement-ux`, `seo-growth`, `analytics-revenue`, `publisher-compliance` | Plan ads.txt/consent, ads UX and revenue scenarios; **Gate: owner approves provider/production changes** |
49
+ | **8. Operations** | Authorized release, metrics/logs/traces và runbooks | DevOps: `observability`, `incident-response`; Kubernetes khi liên quan | SLO signals, incident timeline/postmortem, follow-up changes; không tự động thay đổi production |
50
+
51
+ **Nhớ:** bảng stage sử dụng tên kỹ năng viết gọn; sử dụng [skill-matrix.md](skill-matrix.md) để lấy **ID chính xác** và command `aih skill <name>`. Technical architecture hiện là trách nhiệm của Core + adapter, chưa có capability Architecture chuyên biệt.
52
+
53
+ ## 2. Luồng thực tế qua các handoff
54
+
55
+ 1. **Discover**: BA/PM ghi `SRC-001` từ nguồn có phiên bản và kiểm tra quyền, tạo `BR-001`, `FR-001`, `NFR-001` trong BRD. Không lấy tài liệu ngoài phạm vi để làm prompt.
56
+ 2. **Product gate**: PO xác nhận `US-001`, `AC-US-001-01` và trace tới `FR-001`; bản nháp chỉ chuyển sang Ready sau khi người có thẩm quyền chấp thuận.
57
+ 3. **Design gate**: UI/UX ánh xạ `US-001` đến screen `SCR-001`, mô tả loading/error/empty/accessibility. Figma chỉ được ghi khi được phê duyệt đúng file/node; giữ node-ID để review.
58
+ 4. **Spec gate**: planner và `harness-spec` tạo change (ví dụ `add-customer-api`) mang lại `FR-001`/`AC-US-001-01`, API semantics và test plan. Nếu dùng OpenSpec CLI riêng, chạy `openspec validate add-customer-api --strict` sau khi hoàn thiện TODO.
59
+ 5. **Implementation & QA**: từng nhiệm vụ dùng `harness-tdd` và skill adapter phù hợp, bảo vệ tenancy/auth, test failures và DB migration; reviewer kiểm tra diff theo approved AC.
60
+ 6. **PR**: branch riêng, PR có change ID, source/spec links, tests thực chạy, tests còn thiếu, plan rollback; không tự merge.
61
+ 7. **Release**: DevOps dùng artifact immutable + explicit human production gate; người vận hành hoặc runtime đã cấp quyền mới có thể deploy. Sau đó thu thập latency/errors/traffic/saturation và cập nhật postmortem nếu cần.
62
+
63
+ **Traceability mẫu (đây là ví dụ, không phải dữ liệu thật):**
64
+
65
+ ~~~text
66
+ SRC-001 (Confluence page, revision)
67
+ → BR-001 / FR-001 → PRD-001
68
+ → US-001 / AC-US-001-01
69
+ → SCR-001 / Figma node (nếu có UI)
70
+ → openspec/changes/add-customer-api/
71
+ → source/tests/commit SHA
72
+ → PR / CI evidence
73
+ → artifact digest / approved release / observed SLO
74
+ ~~~
75
+
76
+ Project tự sở hữu các file `docs/product/` và cập nhật `traceability.md`. Không có automation nào tự cập nhật trace ID giữa Figma, Jira, code và release.
77
+
78
+ ## 3. Thực thi từ AI IDE theo stage (prompts mẫu)
79
+
80
+ **Business phase:**
81
+
82
+ > Đọc AGENTS.md, tài liệu nguồn được phép truy cập và capability Product đã cài. Sử dụng knowledge-analysis → BRD/PRD → stories/AC/traceability. Ghi nguồn và revision cho mọi fact, tách suy luận và quyết định. Tạo draft trong docs/product/ và yêu cầu BA/PO review, không tự approve.
83
+
84
+ **Design phase (tùy chọn):**
85
+
86
+ > Dùng các requirement ID đã được phê duyệt, lập UX flow và screen inventory với trạng thái lỗi/rỗng/loading. Chờ duyệt trước mọi thay đổi Figma; chỉ thao tác trên file được cấp quyền. Ghi screen-to-node mapping.
87
+
88
+ **Implement phase:**
89
+
90
+ > Dựa trên approved OpenSpec change, chọn chính xác Core/adapter skill cần dùng; thực hiện test-first slice nhỏ, không đụng file ngoài scope. Báo kết quả tests đã chạy, cập nhật requirement-to-test evidence, mở PR để review, không tự merge.
91
+
92
+ **Release phase:**
93
+
94
+ > Lập CI/CD, container, deployment và rollback plan với các signal có thể đo. Chỉ đề xuất thao tác production; không deploy/rollback nếu chưa có phê duyệt riêng cho artifact và environment.
95
+
96
+ ## 4. Khi thay đổi không cần cả vòng đời
97
+
98
+ - **Bugfix nhỏ:** đọc [bugfix workflow](../core/workflows/bugfix.md), tái hiện lỗi → regression test → patch → PR. Không tự tạo BRD/PRD mới khi không cần.
99
+ - **Refactor/upgrade:** theo [upgrade workflow](../core/workflows/upgrade.md), inventory tương thích, baseline và rollback, giữ public contracts.
100
+ - **Backend-only:** bỏ UI/UX; dùng Product nếu cần xác nhận nghiệp vụ, Java/AI adapter khi implement.
101
+ - **Mobile-only:** dùng React Native adapter và UI/UX; không cài Kubernetes cho app di động chỉ vì cần release.
102
+ - **No code yet:** Product + UI/UX có thể dừng sau design gate, không tạo PR implementation giả.
103
+
104
+ ## 5. Verify, eval và hồ sơ release
105
+
106
+ ~~~bash
107
+ aih verify --scope all
108
+ aih eval --scope all
109
+ aih check
110
+ ~~~
111
+
112
+ `aih verify` **không chạy** lint/build/test; `aih eval` tạo report chưa chấm, không chạy model. Chạy các lệnh build/test từ repo bằng công cụ tương ứng, đính kèm evidence và run scenarios với mô hình thật nếu có nhu cầu. Chỉ khi đã ghi điểm có căn cứ mới dùng `aih eval --scope all --report /path/to/report.json` để tổng hợp.
113
+
114
+ **Checklist hoàn thành một change:** scope và approved AC rõ; diff có trace; tests thực chạy với kết quả chính xác; security/permissions đã review; CI xanh; PR được human quyết định; deployment (nếu có) có artifact/environment approval; OpenSpec archive/sync **chỉ sau khi các PR liên quan đã merge**, thông qua upstream CLI/human được quyền.
115
+
116
+ Xem [handoff contracts](agent-handoffs.md), [OpenSpec integration](openspec.md), [DevOps PR-to-production](../capabilities/devops/workflows/pr-to-production.md) và các [ví dụ theo stack](getting-started.md#ví-dụ-thực-hành).
@@ -0,0 +1,60 @@
1
+ # Walkthrough 4 — Python AI/RAG service có kiểm soát truy cập
2
+
3
+ **Tình huống giả định:** API hỏi đáp tri thức doanh nghiệp (Confluence/PDF) với quyền theo tenant/nhóm, citations, tool calling có giới hạn và AI quality gates. Nếu tài liệu ít, **không cần RAG**; trước tiên đo chất lượng retrieval và quyết định phương án phù hợp.
4
+
5
+ ## 1. Init theo phạm vi
6
+
7
+ ~~~bash
8
+ cd /path/to/existing-python-ai-service
9
+ aih resolve --adapters ai-python --capabilities product,devops
10
+ aih init --adapters ai-python --capabilities product,devops --dry-run
11
+ aih init --adapters ai-python --capabilities product,devops
12
+ aih check
13
+ aih skills
14
+ ~~~
15
+
16
+ Nếu AI application triển khai trên Kubernetes, cân nhắc thêm adapter `kubernetes`. Các framework Python, vector DB và API key **không** được `aih` cài/cấp. Dùng `java-spring` thêm nếu service thực tế viết bằng Spring Boot thay vì Python; `ai-python` không phải bắt buộc cho mọi AI application.
17
+
18
+ ## 2. Business/data intake và security gate
19
+
20
+ - BA/PO ghi nguồn tài liệu, owner, tenant/scope, revision, retention, consent và loại dữ liệu nhạy cảm; output là `source-register` và các `FR/NFR/AC` được duyệt.
21
+ - Design nêu rõ boundary: caller identity → authorized retrieval filter → chunk/citation → grounded answer, deny-by-default và audit metadata tối thiểu.
22
+ - Test scenarios: tenant A tìm thấy document B có độ giống cao vẫn **không lộ nội dung B**, missing access claim, prompt injection trong retrieved text, stale sources, no-evidence abstention, latency/cost budgets.
23
+ - Không upload tài liệu bí mật vào eval fixtures; dùng synthetic corpus với auth giả lập.
24
+
25
+ ## 3. Spec & implementation
26
+
27
+ ~~~bash
28
+ aih new-change authorized-knowledge-search
29
+ aih skill harness-spec
30
+ aih skill harness-tdd
31
+ aih skill harness-ai-python-rag-access
32
+ aih skill harness-ai-python-tool-safety
33
+ aih skill harness-ai-evaluation
34
+ ~~~
35
+
36
+ - `rag-access`: filter ACL **trước khi tài liệu được trả về model**, kết quả có source chunk/revision, giữ cross-tenant isolation; không dựa vào prompt "đừng tiết lộ".
37
+ - `tool-safety`: schema, allowlist, scoped credentials, bounded timeout/token/cost, human approval cho mutation, test denied actions.
38
+ - `harness-ai-evaluation`: versioned datasets, recall/groundedness/citation accuracy, denied leakage, regressions, latency/cost. Define measurement trước khi thử provider.
39
+ - Với project có nhiều trang tài liệu mới cần index hoặc phân vùng semantic search, tách pipeline ingestion/retention và ACL ở storage/retriever. Mô tả nguồn nào thực sự truy cập được.
40
+
41
+ ## 4. Tests và LLM evaluation
42
+
43
+ ~~~bash
44
+ # Thực hiện ở môi trường disposable sau khi xác nhận tool/test deps của repo:
45
+ # python -m pytest # chỉ khi dependency pytest đã cài và repo sử dụng nó
46
+ aih verify --scope all
47
+ aih eval --scope all
48
+ aih check
49
+ ~~~
50
+
51
+ `aih eval --scope all` cung cấp cases/report chưa chấm; chạy model/tập dữ liệu kiểm thử **bên ngoài CLI**, ghi trace đã redact và reviewer điền report. Báo real pass/fail; **không dùng synthetic score của unit test như bằng chứng model đạt chất lượng**. Kịch bản cross-module DevOps xuất hiện nếu chọn và phù hợp.
52
+
53
+ ## 5. PR → deployment/operations
54
+
55
+ - PR chứa OpenSpec change, ACL tests, retrieved citation evidence, eval threshold results, cost/latency assumptions, prompt-injection defense và failures.
56
+ - `harness-devops-ci-cd` / `harness-devops-deployment` lên kế hoạch artifact/staging/rollback. `harness-devops-observability` nêu access-deny counters, retrieval failures, token/cost, latency, errors, SLO.
57
+ - Secrets thuộc secret manager/runtime, không hardcode vào prompts, report hoặc Git. Production deploy chỉ khi có authorization riêng.
58
+ - Sau rollout, theo dõi drift source revision, tenant leak alerts và versioned dataset regressions.
59
+
60
+ **Handoff:** approved data-use rules → retrieval design → OpenSpec → ACL-enforced RAG and tool wrappers → human-reviewed model evidence → PR → controlled deployment/monitoring.
@@ -0,0 +1,80 @@
1
+ # Walkthrough — Astro micro-tools with AdSense monetization
2
+
3
+ Scenario: a free website with QR Generator, JSON Formatter and Image Compressor, aiming for **legitimate search traffic + advertising**. No guarantee of publisher approval, SEO ranking or earnings. Build useful tools first; ad placement is a secondary concern.
4
+
5
+ ## 1. Prerequisites and selection
6
+
7
+ Node.js 22+, Git, an existing Astro app, and an `aih` CLI bundle including the optional monetization capability. If you need an Astro starter use the upstream Astro CLI separately; Harness installs only rules/skills.
8
+
9
+ ```bash
10
+ cd /path/to/astro-utilities
11
+ aih resolve --adapters astro --capabilities product,uiux,monetization
12
+ aih init --adapters astro --capabilities product,uiux,monetization --dry-run
13
+ aih init --adapters astro --capabilities product,uiux,monetization
14
+ aih check
15
+ aih skills
16
+ aih skill harness-astro-project-architecture
17
+ aih skill harness-monetization-adsense-integration
18
+ aih skill harness-monetization-seo-growth
19
+ ```
20
+
21
+ Product/UIUX are optional; the smallest setup is `aih init --adapters astro --capabilities monetization`. An existing installation must update `.harness/project.json` and use `aih update` instead.
22
+
23
+ ## 2. Start with product and SEO, no ad code
24
+
25
+ Example route layout:
26
+
27
+ ```text
28
+ src/pages/index.astro
29
+ src/pages/tools/qr-generator.astro
30
+ src/pages/tools/json-formatter.astro
31
+ src/pages/tools/image-compressor.astro
32
+ src/lib/qr/
33
+ src/lib/json/
34
+ src/lib/image/
35
+ docs/monetization/
36
+ ```
37
+
38
+ First ask the AI host to inspect the project and plan tool-specific pages with useful original content, accessible forms/error handling and local processing. Example prompt:
39
+
40
+ > Read AGENTS.md plus harness-astro-project-architecture and harness-monetization-seo-growth. Plan three public micro-tools focused on real search intent, good mobile UX and static/browser-only processing. Separate verified keyword data, inference and unknowns. Do not add backend, database, web scraping, advertising scripts, ad account credentials or mock visitor counts. Propose routes, validation and meaningful descriptions; request my approval before code changes.
41
+
42
+ If Product is selected, use `aih new-doc prd-lite` for the product scope if needed. The monetization documents are **not** supported by `aih new-doc`; review and copy named installed templates into project-owned `docs/monetization/` once with a permitted filesystem tool.
43
+
44
+ ## 3. Publisher readiness and policy review
45
+
46
+ Check the actual AdSense account/site approval status, original site content, user trust pages, privacy disclosures, intended visitors and third-party rights. Use `harness-monetization-publisher-compliance`. Do not publish provider tags or claim Google approval without account access/owner authorization.
47
+
48
+ Example prompt:
49
+
50
+ > Read installed monetization skills and workflow site-to-adsense. Create or complete docs/monetization/site-monetization-plan.md and privacy-consent-checklist.md from supplied evidence. Read current Google policies if web is enabled, recording URLs and check dates. Confirm which visitors need a certified CMP and flag gaps. Do not assume I already have an AdSense account or a publisher ID, and do not publish anything externally.
51
+
52
+ ## 4. Review slots and add authorized ads only after approval
53
+
54
+ Draft mobile/desktop page designs with safe ad placement around, **not inside**, Generate/Download flows. Avoid accidental taps, misleading download-like labels and layout shift; confirm tool works when ads are blocked/not filled or required consent is absent.
55
+
56
+ Before production, confirm provider approval/permissions, account-supplied `ads.txt` content, deploy root path `/ads.txt`, correct CMP choice and actual deployment environment. Use `aih skill harness-monetization-ad-placement-ux`. For `ads.txt`, copy **only** a real seller line from the publisher account; Google highly recommends but does not universally require ads.txt.
57
+
58
+ Review actual responsive pages, consent choices, script loading, privacy and accessibility. Test production build using **scripts that exist** in the Astro project. `aih verify --scope all` is only advisory and no cloud/Google writes occur through CLI.
59
+
60
+ ## 5. Measure and improve when real data exists
61
+
62
+ After launch and account authorization, use analytics/Search Console exports and provider earnings for the **same time window**; compare legitimate organic traffic by tool, Page RPM, cost of hosting/API and qualitative task completion. If access is absent, label metrics UNKNOWN and use explicit assumptions rather than fabricated earnings.
63
+
64
+ Example prompt:
65
+
66
+ > Read harness-monetization-analytics-revenue. Using only authorized metric exports with source dates, prepare docs/monetization/analytics-report.md. Separate actual earnings from scenarios; calculate Page RPM only if earnings and page views share a window, list hosting/API costs and propose one measurable SEO/UX improvement with a stop rule. No growth hacks that generate clicks or fake ad impressions.
67
+
68
+ ```bash
69
+ aih verify --scope all
70
+ aih eval --scope all
71
+ aih check
72
+ ```
73
+
74
+ `aih eval` emits an unscored evaluation dataset; it does not test Google compliance or call a model. Human review, real site/browser tests and publisher console observations are separate activities.
75
+
76
+ ## 6. Scaling decisions
77
+
78
+ Keep a single Astro website with many routes until independent teams/deployments or very different runtimes require an MFE split. Monetization is stack-independent and follows your site/business across Astro/React changes. Never use MFE, Kubernetes or backend services simply because the website earns ad revenue.
79
+
80
+ Review [Monetization guide](../monetization.md), [Astro micro-tools](astro-micro-tools.md) and [Monetization capability](../../capabilities/monetization/README.md) for reusable procedures.