frontend-harness 0.7.9 → 0.8.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 (98) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +20 -10
  3. package/dist/cli/index.js +388 -66
  4. package/dist/cli/index.js.map +1 -1
  5. package/dist/runtime/builtin-skills.js +1 -1
  6. package/dist/runtime/clean.js +25 -3
  7. package/dist/runtime/clean.js.map +1 -1
  8. package/dist/runtime/command-taxonomy.js +6 -1
  9. package/dist/runtime/command-taxonomy.js.map +1 -1
  10. package/dist/runtime/context.d.ts +33 -2
  11. package/dist/runtime/context.js +112 -13
  12. package/dist/runtime/context.js.map +1 -1
  13. package/dist/runtime/evidence.d.ts +27 -0
  14. package/dist/runtime/evidence.js +302 -19
  15. package/dist/runtime/evidence.js.map +1 -1
  16. package/dist/runtime/graph.js +11 -4
  17. package/dist/runtime/graph.js.map +1 -1
  18. package/dist/runtime/ingest.d.ts +38 -0
  19. package/dist/runtime/ingest.js +157 -0
  20. package/dist/runtime/ingest.js.map +1 -0
  21. package/dist/runtime/knowledge/constants.d.ts +9 -0
  22. package/dist/runtime/knowledge/constants.js +25 -0
  23. package/dist/runtime/knowledge/constants.js.map +1 -0
  24. package/dist/runtime/knowledge/core.d.ts +25 -0
  25. package/dist/runtime/knowledge/core.js +1569 -0
  26. package/dist/runtime/knowledge/core.js.map +1 -0
  27. package/dist/runtime/knowledge/types.d.ts +241 -0
  28. package/dist/runtime/knowledge/types.js +2 -0
  29. package/dist/runtime/knowledge/types.js.map +1 -0
  30. package/dist/runtime/knowledge.d.ts +2 -188
  31. package/dist/runtime/knowledge.js +1 -1126
  32. package/dist/runtime/knowledge.js.map +1 -1
  33. package/dist/runtime/plan/component-resolver.js +17 -6
  34. package/dist/runtime/plan/component-resolver.js.map +1 -1
  35. package/dist/runtime/plan/guidance.d.ts +1 -1
  36. package/dist/runtime/plan/guidance.js +88 -25
  37. package/dist/runtime/plan/guidance.js.map +1 -1
  38. package/dist/runtime/plan/proposal.js +9 -0
  39. package/dist/runtime/plan/proposal.js.map +1 -1
  40. package/dist/runtime/plan/workflow.d.ts +1 -0
  41. package/dist/runtime/plan/workflow.js +32 -1
  42. package/dist/runtime/plan/workflow.js.map +1 -1
  43. package/dist/runtime/plan.d.ts +13 -0
  44. package/dist/runtime/plan.js +137 -82
  45. package/dist/runtime/plan.js.map +1 -1
  46. package/dist/runtime/policy-provenance.d.ts +17 -1
  47. package/dist/runtime/policy-provenance.js +84 -16
  48. package/dist/runtime/policy-provenance.js.map +1 -1
  49. package/dist/runtime/project-discovery.js +32 -17
  50. package/dist/runtime/project-discovery.js.map +1 -1
  51. package/dist/runtime/project-paths.js +7 -1
  52. package/dist/runtime/project-paths.js.map +1 -1
  53. package/dist/runtime/protocol-init.js +117 -26
  54. package/dist/runtime/protocol-init.js.map +1 -1
  55. package/dist/runtime/repair-decision.js +76 -16
  56. package/dist/runtime/repair-decision.js.map +1 -1
  57. package/dist/runtime/repair-packet.js +141 -20
  58. package/dist/runtime/repair-packet.js.map +1 -1
  59. package/dist/runtime/scaffold/vue-template.js +1 -1
  60. package/dist/runtime/scaffold/vue-template.js.map +1 -1
  61. package/dist/runtime/scaffold.js +44 -8
  62. package/dist/runtime/scaffold.js.map +1 -1
  63. package/dist/runtime/skills.d.ts +9 -0
  64. package/dist/runtime/skills.js +133 -18
  65. package/dist/runtime/skills.js.map +1 -1
  66. package/dist/runtime/state-explain.js +39 -7
  67. package/dist/runtime/state-explain.js.map +1 -1
  68. package/dist/runtime/state.js +85 -10
  69. package/dist/runtime/state.js.map +1 -1
  70. package/dist/runtime/task-context.d.ts +122 -0
  71. package/dist/runtime/task-context.js +1322 -0
  72. package/dist/runtime/task-context.js.map +1 -0
  73. package/dist/runtime/task-signals.d.ts +1 -0
  74. package/dist/runtime/task-signals.js +1 -1
  75. package/dist/runtime/task-signals.js.map +1 -1
  76. package/dist/runtime/ui-restoration.d.ts +3 -3
  77. package/dist/runtime/ui-restoration.js +3 -3
  78. package/dist/runtime/ui-restoration.js.map +1 -1
  79. package/dist/runtime/ui-source.d.ts +6 -0
  80. package/dist/runtime/ui-source.js +66 -0
  81. package/dist/runtime/ui-source.js.map +1 -0
  82. package/dist/runtime/units.js +11 -4
  83. package/dist/runtime/units.js.map +1 -1
  84. package/dist/runtime/verification-commands.js +95 -21
  85. package/dist/runtime/verification-commands.js.map +1 -1
  86. package/dist/runtime/verify.js +129 -43
  87. package/dist/runtime/verify.js.map +1 -1
  88. package/dist/runtime/visual-compare.js +104 -12
  89. package/dist/runtime/visual-compare.js.map +1 -1
  90. package/dist/schemas/types.d.ts +75 -2
  91. package/dist/schemas/validation.js +257 -6
  92. package/dist/schemas/validation.js.map +1 -1
  93. package/dist/storage/json.d.ts +9 -1
  94. package/dist/storage/json.js +106 -8
  95. package/dist/storage/json.js.map +1 -1
  96. package/docs/DIRECTION.md +13 -11
  97. package/docs/RELEASE.md +5 -1
  98. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,35 @@ All notable changes to `frontend-harness` are documented here.
4
4
 
5
5
  This project follows semver while it is pre-1.0: patch releases may include harness policy improvements that tighten validation, and minor releases may change generated protocol expectations.
6
6
 
7
+ ## 0.7.9 - 2026-05-27
8
+
9
+ ### Fixed
10
+
11
+ - Hardened harness artifact writes, protocol initialization, visual comparison outputs, and log cleanup against symlink paths that could otherwise write or delete files outside the project.
12
+ - Rejected symlinked state lock files instead of waiting on or inspecting external lock targets.
13
+ - Ignored symlinked project knowledge and skill Markdown files during discovery so external files cannot be injected into project-local planning policy.
14
+ - Ignored symlinked protocol constraint files and PRD discovery roots, and rejected non-POSIX file paths in execution-unit and component-graph artifacts.
15
+ - Rejected duplicate CLI flags instead of letting later values silently override earlier inputs.
16
+ - Rejected malformed or oversized PNG inputs during visual comparison before decoding or allocating diff buffers.
17
+ - Bounded knowledge and PRD markdown scanning by file size, file count, and directory depth so checks fail visibly instead of consuming unbounded resources.
18
+ - Bounded project-local skill markdown scanning by file size, file count, and directory depth so checks fail visibly instead of consuming unbounded resources.
19
+ - Rejected oversized execution-unit and component-graph artifacts before parsing generated harness JSON.
20
+ - Skipped context artifact hashing for oversized harness files so context construction cannot read unbounded artifact contents.
21
+ - Read repair packet log excerpts from bounded tail windows while hashing logs in chunks.
22
+ - Skipped repair decision provenance hashes for oversized repair and verification artifacts.
23
+ - Rejected oversized agent proposal and repair decision input envelopes before JSON parsing.
24
+ - Bounded protocol initialization and check reads for managed protocol files, builtin project skills, and protocol provenance artifacts.
25
+ - Rejected oversized visual evidence artifacts before hash validation and hashed git change baselines in chunks.
26
+ - Failed verification command discovery when package verification scripts are malformed instead of treating invalid script values as runnable commands.
27
+ - Preserved failing verification command exit codes when test output contains phrases such as "not found" instead of misclassifying those failures as command launch errors.
28
+ - Wrote harness JSON and text artifacts through same-directory temporary files and atomic renames to reduce partial-write and symlink race exposure.
29
+ - Wrote visual comparison diff images through the same atomic write path as other harness artifacts.
30
+ - Rejected stale protocol provenance artifact paths instead of treating tampered path metadata as current.
31
+ - Applied scaffold executable modes through non-symlink file handles so generated file mode changes cannot follow replaced symlink targets.
32
+ - Revalidated accepted repair decision summaries before exposing them through context so tampered harness artifacts cannot publish unsafe target paths.
33
+ - Preserved quoted frontmatter scalar values during knowledge and skill parsing, preventing escaped quotes from accumulating during read/update cycles.
34
+ - Made context artifact reporting tolerate malformed artifact paths that exist as directories by reporting a missing hash instead of failing the whole context command.
35
+
7
36
  ## 0.7.8 - 2026-05-26
8
37
 
9
38
  ### Changed
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # frontend-harness
2
2
 
3
- `frontend-harness` is an Execution Policy Layer for frontend teams using Codex or Claude Code.
3
+ `frontend-harness` is a context and evidence policy layer for frontend teams using Codex or Claude Code.
4
4
 
5
5
  It does not replace the agent runtime. Codex and Claude Code already provide the loop, tool execution, context handling, permissions, retries, subagents, and skill loading. `frontend-harness` adds the project-level rules those agents should follow inside a frontend repository.
6
6
 
@@ -10,16 +10,18 @@ The product goal is simple:
10
10
  install once -> inject AGENTS.md / CLAUDE.md -> work normally with AI
11
11
  ```
12
12
 
13
- After initialization, team members should not need to manually run the harness loop. They keep asking Codex or Claude Code for frontend work in plain language. The injected project protocol and built-in project skills tell the agent how to plan, edit, verify, and repair.
13
+ After initialization, team members should not need to manually run a heavy harness workflow for every task. They keep asking Codex or Claude Code for frontend work in plain language. The injected project protocol tells the agent when to use the full context, planning, evidence, and repair loop, and when ordinary task guidance is enough.
14
14
 
15
15
  ## What It Does
16
16
 
17
- `frontend-harness` gives a project a deterministic execution contract:
17
+ `frontend-harness` gives complex frontend tasks a deterministic execution contract:
18
18
 
19
19
  ```text
20
20
  context -> plan -> implement -> record changes -> verify -> repair -> done
21
21
  ```
22
22
 
23
+ The full loop is intended for work where source material, evidence, or traceability matters: design-backed UI restoration, PRD-derived product knowledge, multi-source frontend changes, and handoffs that need durable verification artifacts. Simple bug fixes, tests, docs, maintenance, and small requirement edits should stay lightweight unless the task includes explicit PRD, API, UI, or audit evidence.
24
+
23
25
  The CLI exists mainly as a protocol API for AI agents. Humans use it to install, initialize, and occasionally check health.
24
26
 
25
27
  ## What It Is Not
@@ -35,7 +37,7 @@ It should not rebuild:
35
37
  - long-running runtime launchers or supervised agent wrappers
36
38
  - replacement workflows for Codex or Claude Code
37
39
 
38
- Those belong to the official agent runtimes. This package owns only the frontend project policy around them.
40
+ Those belong to the official agent runtimes. This package owns only the frontend project context, policy, and evidence around them. It should not wrap ordinary agent conversation in process for its own sake.
39
41
 
40
42
  ## Install
41
43
 
@@ -115,7 +117,7 @@ Once those files are present, the normal team workflow is:
115
117
  ```text
116
118
  Open Codex or Claude Code.
117
119
  Ask for the frontend change.
118
- Let the injected protocol drive planning, verification, and repair.
120
+ Let the injected protocol decide whether the task needs the full harness loop or lightweight project guidance.
119
121
  ```
120
122
 
121
123
  ## Human Commands
@@ -146,9 +148,10 @@ These commands are intended for Codex / Claude Code through the injected protoco
146
148
 
147
149
  ```bash
148
150
  npm run harness -- context --json
151
+ npm run harness -- context task --json "<task>" --prd <prd-file> --api-source <openapi-file-or-url> --ui-source <ui-artifact-or-design-url>
149
152
  npm run harness -- proposal check --json --file <agent-proposal.json>
150
153
  npm run harness -- plan --json "<task>"
151
- npm run harness -- plan --json "<task>" --prd <prd-file> --ui-source <ui-artifact-or-design-url>
154
+ npm run harness -- plan --json "<task>" --prd <prd-file> --api-source <openapi-file-or-url> --ui-source <ui-artifact-or-design-url>
152
155
  npm run harness -- plan --json "<task>" --agent-proposal <agent-proposal.json>
153
156
  npm run harness -- state record-change <file>
154
157
  npm run harness -- state record-change --from-git
@@ -162,7 +165,7 @@ npm run harness -- state next --json
162
165
  npm run harness -- state explain --json
163
166
  ```
164
167
 
165
- The agent should call them automatically while doing work. They persist local state under `.frontend-harness/` and provide deterministic evidence for each step. `evidence template --json` prints the machine-readable evidence entry shape for the current plan; it is a schema aid, not proof. Put real captures, checks, comparisons, and hashes in a project-local evidence input JSON, then use `evidence record --json --file <evidence-input.json>` so the harness validates and writes `.frontend-harness/verification/evidence.json`. Captured evidence and visual comparison files are local intermediate artifacts by default; scaffolded projects ignore them and `clean` may remove them.
168
+ The agent should call them automatically when the task needs harness-managed context, planning, or evidence. They persist local state under `.frontend-harness/` and provide deterministic evidence for each step. `context task --json` emits a compact task packet from workflow policy, selected knowledge cards, explicit PRD/API/UI inputs, candidate project files, and ingest provenance so agents can use PRD/UI/API context without loading entire source materials into the prompt. `evidence template --json` prints the machine-readable evidence entry shape for the current plan; it is a schema aid, not proof. Put real captures, checks, comparisons, and hashes in a project-local evidence input JSON, then use `evidence record --json --file <evidence-input.json>` so the harness validates and writes `.frontend-harness/verification/evidence.json`. Captured evidence and visual comparison files are local intermediate artifacts by default; scaffolded projects ignore them and `clean` may remove them.
166
169
 
167
170
  `state check --json` verifies that recorded changed files cover the current plan's execution-unit files before verification. `verify --json` runs that contract check first, enforces PRD knowledge coverage when the plan has PRD input, and then discovers the default `typecheck`, `test`, and `build` scripts when present. Projects can also declare custom verification commands in `.frontend-harness/config.json`:
168
171
 
@@ -189,7 +192,7 @@ The agent should call them automatically while doing work. They persist local st
189
192
  - `documentation`
190
193
  - `maintenance`
191
194
 
192
- Each plan includes required knowledge actions, implementation constraints, and verification focus. This keeps generated UI imports, PRD digestion, Swagger/API work, tests, bug fixes, and requirement changes inside the same controlled policy loop without turning skills into executable runtime commands.
195
+ Each plan includes required knowledge actions, implementation constraints, and verification focus. UI restoration, PRD knowledge, explicit source-backed API work, and evidence-heavy changes use the full controlled loop. Ordinary tests, bug fixes, docs, maintenance, and requirement edits are intentionally lightweight policy guidance unless the task supplies PRD/API/UI source material or asks for auditable evidence. Project skills remain guidance, not executable runtime commands.
193
196
 
194
197
  ### Agent Plan Proposals
195
198
 
@@ -251,7 +254,11 @@ These commands expose project-local knowledge and workflow guidance as provenanc
251
254
  ```bash
252
255
  npm run harness -- skills list --json
253
256
  npm run harness -- skills check --json
257
+ npm run harness -- ingest record --json --kind prd|openapi|ui-package --id <source-id> --source <file-or-url> --summary "<summary>"
258
+ npm run harness -- ingest list --json
259
+ npm run harness -- ingest show --json --ref ingest://<kind>/<source-id>
254
260
  npm run harness -- knowledge add --json --kind rule --subject "<subject>" --rule "<rule>"
261
+ npm run harness -- knowledge draft --json --ref ingest://<kind>/<source-id>
255
262
  npm run harness -- knowledge promote --json --title "<title>" --body "<body>"
256
263
  npm run harness -- knowledge update --json --id <knowledge-id> --source "docs/prd/<file>.md"
257
264
  npm run harness -- knowledge index --json
@@ -262,7 +269,7 @@ npm run harness -- knowledge show --json --id <knowledge-id>
262
269
  npm run harness -- knowledge check --json
263
270
  ```
264
271
 
265
- Prefer `knowledge add` for PRD digestion. It stores small atomic entries such as rules, workflows, permissions, terms, decisions, conventions, and pitfalls with `source_paths` pointing back to the original PRD. Use `knowledge update` when a requirement changes so existing cards are merged instead of duplicated. `knowledge index` writes `.frontend-harness/knowledge/index.json`, a deterministic manifest grouped by PRD source, card id, scope, and tag. `knowledge coverage` verifies active PRD semantics remain traceable to source documents. `knowledge promote` remains available for authored Markdown cards, but raw PRD prose should stay in source documents instead of being copied into knowledge.
272
+ Prefer `knowledge add` for PRD digestion. It stores small atomic entries such as rules, workflows, permissions, terms, decisions, conventions, and pitfalls with `source_paths` pointing back to a project file, external reference, or `ingest://...` provenance record. Use `ingest record` when PRD, OpenAPI, or UI package material is temporary but the distilled knowledge needs a lightweight source proof. Use `knowledge draft` to turn an ingest record into a reviewed `knowledge add` scaffold with placeholders for the atomic fact, coverage, verification, scope, and tags; do not add the scaffold unchanged. When existing cards already point at the same ingest record, produced card IDs, or source file, draft output includes `knowledge update` candidates so agents can merge before adding duplicates. Use `knowledge update` when a requirement changes so existing cards are merged instead of duplicated. `knowledge index` writes `.frontend-harness/knowledge/index.json`, a deterministic manifest grouped by PRD source, card id, scope, and tag. `knowledge coverage` verifies active PRD semantics remain traceable to source documents or ingest provenance. `knowledge promote` remains available for authored Markdown cards, but raw PRD prose should stay in source documents or temporary ingest inputs instead of being copied into knowledge.
266
273
 
267
274
  ## Runtime Boundary
268
275
 
@@ -272,7 +279,7 @@ The boundary is strict:
272
279
  - `frontend-harness` owns policy.
273
280
  - The project owns durable state and knowledge.
274
281
 
275
- Project skills under `.frontend-harness/skills/` are policy guidance and provenance for planning. They are intentionally separate from Codex or Claude runtime skills installed in the developer environment.
282
+ Project skills under `.frontend-harness/skills/` are policy guidance and provenance for planning. They are intentionally separate from Codex or Claude runtime skills installed in the developer environment. For simple tasks, they should be enough on their own; the harness should not force a full stateful loop when direct agent conversation plus local verification is cheaper.
276
283
 
277
284
  That means `frontend-harness` should stay small and focused. Its job is to make frontend work repeatable, not to become a second runtime.
278
285
 
@@ -289,6 +296,9 @@ The package writes project-local artifacts under `.frontend-harness/`:
289
296
  guidance/
290
297
  state.json
291
298
  verification/
299
+ design-sources/
300
+ evidence/
301
+ visual/
292
302
  logs/
293
303
  repair/
294
304
  repair-decision/