frontend-harness 0.1.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 (77) hide show
  1. package/AGENTS.md +48 -0
  2. package/CLAUDE.md +48 -0
  3. package/README.md +262 -0
  4. package/dist/cli/index.d.ts +2 -0
  5. package/dist/cli/index.js +380 -0
  6. package/dist/cli/index.js.map +1 -0
  7. package/dist/runtime/builtin-skills.d.ts +6 -0
  8. package/dist/runtime/builtin-skills.js +269 -0
  9. package/dist/runtime/builtin-skills.js.map +1 -0
  10. package/dist/runtime/clean.d.ts +11 -0
  11. package/dist/runtime/clean.js +85 -0
  12. package/dist/runtime/clean.js.map +1 -0
  13. package/dist/runtime/command-taxonomy.d.ts +12 -0
  14. package/dist/runtime/command-taxonomy.js +72 -0
  15. package/dist/runtime/command-taxonomy.js.map +1 -0
  16. package/dist/runtime/context.d.ts +71 -0
  17. package/dist/runtime/context.js +153 -0
  18. package/dist/runtime/context.js.map +1 -0
  19. package/dist/runtime/graph.d.ts +12 -0
  20. package/dist/runtime/graph.js +211 -0
  21. package/dist/runtime/graph.js.map +1 -0
  22. package/dist/runtime/knowledge.d.ts +48 -0
  23. package/dist/runtime/knowledge.js +383 -0
  24. package/dist/runtime/knowledge.js.map +1 -0
  25. package/dist/runtime/plan.d.ts +18 -0
  26. package/dist/runtime/plan.js +571 -0
  27. package/dist/runtime/plan.js.map +1 -0
  28. package/dist/runtime/policy-provenance.d.ts +17 -0
  29. package/dist/runtime/policy-provenance.js +195 -0
  30. package/dist/runtime/policy-provenance.js.map +1 -0
  31. package/dist/runtime/project-discovery.d.ts +17 -0
  32. package/dist/runtime/project-discovery.js +166 -0
  33. package/dist/runtime/project-discovery.js.map +1 -0
  34. package/dist/runtime/project-paths.d.ts +6 -0
  35. package/dist/runtime/project-paths.js +47 -0
  36. package/dist/runtime/project-paths.js.map +1 -0
  37. package/dist/runtime/protocol-init.d.ts +50 -0
  38. package/dist/runtime/protocol-init.js +256 -0
  39. package/dist/runtime/protocol-init.js.map +1 -0
  40. package/dist/runtime/repair-decision.d.ts +3 -0
  41. package/dist/runtime/repair-decision.js +195 -0
  42. package/dist/runtime/repair-decision.js.map +1 -0
  43. package/dist/runtime/repair-packet.d.ts +7 -0
  44. package/dist/runtime/repair-packet.js +159 -0
  45. package/dist/runtime/repair-packet.js.map +1 -0
  46. package/dist/runtime/skills.d.ts +19 -0
  47. package/dist/runtime/skills.js +230 -0
  48. package/dist/runtime/skills.js.map +1 -0
  49. package/dist/runtime/state-explain.d.ts +2 -0
  50. package/dist/runtime/state-explain.js +106 -0
  51. package/dist/runtime/state-explain.js.map +1 -0
  52. package/dist/runtime/state.d.ts +10 -0
  53. package/dist/runtime/state.js +237 -0
  54. package/dist/runtime/state.js.map +1 -0
  55. package/dist/runtime/units.d.ts +10 -0
  56. package/dist/runtime/units.js +181 -0
  57. package/dist/runtime/units.js.map +1 -0
  58. package/dist/runtime/verification-commands.d.ts +11 -0
  59. package/dist/runtime/verification-commands.js +89 -0
  60. package/dist/runtime/verification-commands.js.map +1 -0
  61. package/dist/runtime/verify.d.ts +7 -0
  62. package/dist/runtime/verify.js +192 -0
  63. package/dist/runtime/verify.js.map +1 -0
  64. package/dist/schemas/types.d.ts +244 -0
  65. package/dist/schemas/types.js +2 -0
  66. package/dist/schemas/types.js.map +1 -0
  67. package/dist/schemas/validation.d.ts +2 -0
  68. package/dist/schemas/validation.js +21 -0
  69. package/dist/schemas/validation.js.map +1 -0
  70. package/dist/storage/json.d.ts +5 -0
  71. package/dist/storage/json.js +24 -0
  72. package/dist/storage/json.js.map +1 -0
  73. package/dist/storage/paths.d.ts +3 -0
  74. package/dist/storage/paths.js +9 -0
  75. package/dist/storage/paths.js.map +1 -0
  76. package/docs/DIRECTION.md +67 -0
  77. package/package.json +35 -0
@@ -0,0 +1,269 @@
1
+ export const builtinProjectSkills = [
2
+ {
3
+ name: "frontend-discovery",
4
+ fileName: "frontend-discovery.md",
5
+ content: `---
6
+ name: frontend-discovery
7
+ title: Frontend Discovery
8
+ description: Use this project skill before non-trivial frontend work to identify local stack, conventions, source-of-truth files, and validation commands.
9
+ triggers: [discovery, inspect, convention, stack, project profile, 探查, 项目结构, 约定, 技术栈]
10
+ intents: [frontend_discovery]
11
+ examples: [discover project conventions before implementing order page, 先梳理前端项目约定]
12
+ ---
13
+ # Frontend Discovery
14
+
15
+ Use this project skill before non-trivial frontend work to produce repository facts, not guesses.
16
+
17
+ - Identify the app/package boundary, package manager, framework mode, language, UI library, styling system, aliases, env naming, and validation scripts.
18
+ - Locate routing, menu, permission, request, state, form, table, dialog, and testing conventions from source files.
19
+ - Prefer the closest implemented feature pattern over generic frontend or Vue advice.
20
+ - Classify evidence as direct, inferred, absent, or unknown; pass unresolved unknowns into planning instead of filling gaps silently.
21
+ - Treat package scripts as candidates and verify exact command names before relying on them.
22
+ - Do not install dependencies, change files, or pick patterns from another app/package without noting the boundary.
23
+ `
24
+ },
25
+ {
26
+ name: "architecture-boundary",
27
+ fileName: "architecture-boundary.md",
28
+ content: `---
29
+ name: architecture-boundary
30
+ title: Architecture Boundary
31
+ description: Use this project skill to decide frontend file placement and ownership across pages, components, composables, stores, API modules, routes, menus, and permissions.
32
+ triggers: [architecture, boundary, placement, layer, route, permission, menu, store, composable, 架构, 边界, 路由, 权限, 菜单]
33
+ intents: [architecture_boundary]
34
+ examples: [decide page component API store boundaries, 规划页面组件接口和权限边界]
35
+ ---
36
+ # Architecture Boundary
37
+
38
+ Use this project skill after discovery and before editing files. Its output is a placement and ownership plan.
39
+
40
+ - Classify each change as page orchestration, presentational component, feature component, composable, store, API/service module, route/menu permission, utility, or validation-only.
41
+ - Keep route/view files thin: bind route params, compose sections, call feature composables, and delegate display.
42
+ - Keep API transport in the existing request/API layer; do not call raw fetch or axios from components unless the project already does.
43
+ - Use local refs/computed for local state, composables for reusable or side-effect-heavy feature state, and stores only for cross-page or identity/tenant-scoped state.
44
+ - Put display-only UI behind explicit props, emits, slots, and optional v-model contracts.
45
+ - Plan route, menu, breadcrumb, title, keep-alive, permission, and action visibility together when navigation or access changes.
46
+ - Explicitly list what is not being changed to avoid unrelated architecture churn.
47
+ `
48
+ },
49
+ {
50
+ name: "ui-implementation",
51
+ fileName: "ui-implementation.md",
52
+ content: `---
53
+ name: ui-implementation
54
+ title: UI Implementation
55
+ description: Use this project skill when implementing frontend UI, adapting generated HTML, or converting design output into project code.
56
+ triggers: [ui, design, stitch, figma, html, component, page, dashboard, table, dialog, drawer, 界面, 页面, 组件, 设计稿, 视觉稿, 表格, 弹窗]
57
+ intents: [ui_implementation]
58
+ examples: [adapt Stitch HTML into order detail page, implement order list page, 实现订单列表页面, 根据设计稿还原页面]
59
+ ---
60
+ # UI Implementation
61
+
62
+ Use this project skill when implementing frontend UI, adapting generated HTML, or converting design output into project code.
63
+
64
+ - Run discovery and boundary planning for non-trivial UI changes before editing.
65
+ - Treat MCP, Stitch, Figma, or exported HTML as reference material, not production-ready source.
66
+ - Preserve the target project's component API, naming, routing, state, style, UI-library, icon, and layout conventions.
67
+ - Start from the closest existing page or component pattern; only introduce a new pattern when no local pattern exists.
68
+ - Split substantial pages into clear sections such as toolbar/filter, table/list, detail header, form panel, dialog/drawer, and footer actions.
69
+ - Keep derived display state in computed values or helpers; avoid complex inline template expressions.
70
+ - Cover user-visible states: first load, refreshing, empty, error, success, disabled, permission-limited, and responsive behavior when applicable.
71
+ - Prefer semantic HTML and UI-library accessibility behavior before adding ARIA; ensure icon-only controls have accessible names.
72
+ - Verify with project commands and, when interactions changed, a behavior smoke through tests, browser automation, or documented manual checks.
73
+ `
74
+ },
75
+ {
76
+ name: "api-integration",
77
+ fileName: "api-integration.md",
78
+ content: `---
79
+ name: api-integration
80
+ title: API Integration
81
+ description: Use this project skill when wiring frontend features to backend APIs or Swagger/OpenAPI contracts.
82
+ triggers: [api, swagger, openapi, endpoint, request, response, dto, pagination, search, mutation, 接口, 对接, 请求, 后端, 数据, 分页, 查询]
83
+ intents: [api_integration]
84
+ examples: [connect order list page to Swagger API endpoint, 根据 swagger 文档进行订单接口对接, 同步订单接口数据]
85
+ ---
86
+ # API Integration
87
+
88
+ Use this project skill when a feature touches backend or mocked server data.
89
+
90
+ - Discover the existing request client, API module layout, DTO naming, error handling, interceptors, mock strategy, cache/query pattern, cancellation, and pagination shape.
91
+ - Identify the source of truth for every endpoint, method, request field, response field, pagination wrapper, error shape, permission code, and action code.
92
+ - Acceptable evidence includes backend docs, OpenAPI/schema files, generated clients, TypeScript types, network fixtures, MSW/mock handlers, captured examples, or nearby implemented features.
93
+ - Do not invent endpoint paths, fields, enum values, pagination totals, permission codes, or error codes; record unknowns as blockers or assumptions.
94
+ - Keep backend DTO, UI model, form model, and request body boundaries explicit; map DTOs only when the project pattern or UI shape requires it.
95
+ - Preserve invalidation, refetch, cache key, cancellation, stale data, optimistic update, and retry conventions.
96
+ - Handle loading, refreshing, empty, error, retry, search, reset, pagination, submit, delete, and disabled/pending states as applicable.
97
+ - Validate data mapping, request payloads/params, error behavior, and user-visible state transitions with the project test/build tools or a documented smoke path.
98
+ `
99
+ },
100
+ {
101
+ name: "form-workflow",
102
+ fileName: "form-workflow.md",
103
+ content: `---
104
+ name: form-workflow
105
+ title: Form Workflow
106
+ description: Use this project skill for create/edit/detail forms, modal or drawer forms, validation, field linkage, async options, uploads, submit locking, and reset behavior.
107
+ triggers: [form, create form, edit form, validation, modal form, drawer form, upload, submit, 表单, 新增, 编辑, 校验, 上传, 提交]
108
+ intents: [form_workflow]
109
+ examples: [build create edit order form, 新增编辑表单, 修复弹窗表单回显]
110
+ ---
111
+ # Form Workflow
112
+
113
+ Use this project skill for forms because defects often come from lifecycle, validation, and submit edges.
114
+
115
+ - Identify the mode: create, edit, copy, detail-readonly, step form, inline edit, dialog, or drawer.
116
+ - Locate the project's form library and local conventions for schema/rules, refs, model shape, option loading, upload, validation, and submit feedback.
117
+ - Define form model defaults and normalization; keep backend DTO, form model, and UI-only fields separate when they differ.
118
+ - Load edit/detail data before applying validation that depends on remote values.
119
+ - Implement field linkage with clear computed values or watchers; avoid circular updates and stale option state.
120
+ - Implement submit lifecycle: validate, lock, transform, call API, handle success/error, unlock, refetch/close/navigate, and show feedback through local conventions.
121
+ - Reset stale form state on close, route change, record switch, or mode switch.
122
+ - Do not allow double submit, stale edit data, or generic-only server validation errors when field-level errors are supported.
123
+ `
124
+ },
125
+ {
126
+ name: "prd-knowledge",
127
+ fileName: "prd-knowledge.md",
128
+ content: `---
129
+ name: prd-knowledge
130
+ title: PRD Knowledge
131
+ description: Use this project skill when turning product requirements into durable project knowledge.
132
+ triggers: [prd, product requirement, requirement document, acceptance criteria, knowledge, 产品需求, 需求文档, 验收标准, 知识库, 沉淀]
133
+ intents: [prd_knowledge]
134
+ examples: [digest PRD into project knowledge, 根据产品需求沉淀知识库]
135
+ ---
136
+ # PRD Knowledge
137
+
138
+ Use this project skill when turning requirements into durable project knowledge.
139
+
140
+ - Extract domain terms, workflows, roles, permissions, business states, edge cases, data states, and acceptance criteria.
141
+ - Separate direct requirement evidence from implementation assumptions and unresolved product unknowns.
142
+ - Promote stable conclusions into .frontend-harness/knowledge instead of relying only on chat history.
143
+ - Keep knowledge concise, source-aware, scoped, and useful for future UI implementation, API mapping, tests, bug fixes, and requirement changes.
144
+ - Update or deprecate existing knowledge when a PRD changes instead of creating conflicting duplicate notes.
145
+ - Record unknowns as blockers or assumptions when they affect behavior, permission, API shape, validation, or user-visible copy.
146
+ `
147
+ },
148
+ {
149
+ name: "frontend-test",
150
+ fileName: "frontend-test.md",
151
+ content: `---
152
+ name: frontend-test
153
+ title: Frontend Test
154
+ description: Use this project skill when adding, updating, or reviewing frontend integration and E2E coverage.
155
+ triggers: [test, e2e, integration test, vitest, playwright, msw, testing library, smoke, 测试, 端到端, 集成测试, 用例, 回归测试]
156
+ intents: [frontend_test]
157
+ examples: [add order flow e2e test, 补充订单流程端到端测试]
158
+ ---
159
+ # Frontend Test
160
+
161
+ Use this project skill when adding, updating, or reviewing frontend behavior coverage.
162
+
163
+ - Prefer behavior-level assertions over implementation details, private methods, or snapshot-only checks.
164
+ - Start from the project's existing test harness, render helpers, providers, fixtures, router, store, i18n, auth, query, teleport, and mock conventions.
165
+ - Cover the changed workflow, loading/empty/error/success states, validation errors, permissions, route/query changes, request payloads, and regression risks.
166
+ - Mock network at the project-standard boundary, preferably HTTP/MSW when already established; do not mock both API client and HTTP for the same behavior.
167
+ - Drive behavior like a user through role, label, text, keyboard, route navigation, submit/delete/confirm, pagination, search, and reset flows.
168
+ - Reset mocks, stores, router, timers, and shared fixtures to avoid flaky cross-test state.
169
+ - Keep Playwright thin and high-value for browser-only or critical journeys; do not duplicate every integration test in E2E.
170
+ - Record coverage gaps explicitly when infrastructure is absent instead of adding a new test stack without local agreement.
171
+ `
172
+ },
173
+ {
174
+ name: "bug-fix",
175
+ fileName: "bug-fix.md",
176
+ content: `---
177
+ name: bug-fix
178
+ title: Bug Fix
179
+ description: Use this project skill when diagnosing and fixing frontend defects.
180
+ triggers: [bug, fix, error, regression, failure, async race, stale state, 修复, 错误, 报错, 缺陷, 回归, 异常]
181
+ intents: [bug_fix]
182
+ examples: [fix login redirect bug, 修复登录跳转错误, 需求变更导致登录报错]
183
+ ---
184
+ # Bug Fix
185
+
186
+ Use this project skill when diagnosing and fixing frontend defects.
187
+
188
+ - Reproduce or localize the failure before editing when evidence is available.
189
+ - Compare the failing path with the closest working local pattern and intended product knowledge.
190
+ - Check high-risk causes first: API contract mismatch, route/permission wiring, form lifecycle, stale state, async race, error swallowing, component boundary leakage, and validation gaps.
191
+ - Prefer the smallest fix that restores intended project behavior; avoid unrelated refactors or style churn.
192
+ - Add or adjust regression coverage when the failure path is important and testable.
193
+ - Update project knowledge when the bug reveals a durable rule, edge case, product constraint, or known pitfall.
194
+ - If validation cannot run, record the exact blocker and residual risk.
195
+ `
196
+ },
197
+ {
198
+ name: "requirement-change",
199
+ fileName: "requirement-change.md",
200
+ content: `---
201
+ name: requirement-change
202
+ title: Requirement Change
203
+ description: Use this project skill when a product requirement changes after implementation has started or shipped.
204
+ triggers: [change, changed requirement, requirement change, sync requirement, acceptance change, 需求变更, 变更, 同步修改, 调整需求]
205
+ intents: [requirement_change]
206
+ examples: [sync changed approval requirement into page and tests, 需求变更后同步修改知识库和页面]
207
+ ---
208
+ # Requirement Change
209
+
210
+ Use this project skill when a product requirement changes after implementation has started or shipped.
211
+
212
+ - Identify affected knowledge, UI, API mapping, tests, routes, permissions, state, analytics, documentation, and user-visible copy.
213
+ - Update .frontend-harness/knowledge before or alongside code when the change affects durable project understanding.
214
+ - Mark old assumptions as deprecated or replaced so future agents do not reuse stale behavior.
215
+ - Remove obsolete behavior instead of layering conflicting branches or hidden compatibility paths.
216
+ - Re-check architecture boundaries because a requirement change can move ownership between page, component, API, store, permission, or route layers.
217
+ - Verify both the new acceptance criteria and the most likely regression paths from the previous requirement.
218
+ `
219
+ },
220
+ {
221
+ name: "frontend-change-review",
222
+ fileName: "frontend-change-review.md",
223
+ content: `---
224
+ name: frontend-change-review
225
+ title: Frontend Change Review
226
+ description: Use this project skill before handoff to review frontend diffs for architecture, API contracts, components, forms, routing, state, validation evidence, and unrelated churn.
227
+ triggers: [review, code review, frontend review, handoff, validation evidence, 评审, 代码审查, 复核, 交付]
228
+ intents: [frontend_review]
229
+ examples: [review frontend changes before handoff, 交付前复核前端改动]
230
+ ---
231
+ # Frontend Change Review
232
+
233
+ Use this project skill as the final gate before handoff or as the primary mode when the user asks for review.
234
+
235
+ - Inspect the diff and changed files, then identify intended behavior from the user request and local project patterns.
236
+ - Review highest-risk areas first: API fields/contracts, route/permission access, form submit lifecycle, state ownership, async error handling, component boundaries, and unrelated refactors.
237
+ - Check whether implementation followed discovery facts and the placement plan.
238
+ - Check validation evidence: commands run, interaction flows checked, failed command logs, browser/manual checks, and unverified risks.
239
+ - Findings should lead, ordered by severity, with file and line references; if no findings, state that directly with residual risks.
240
+ - Do not approve code that bypasses request layers, permission systems, or project conventions without explicit justification.
241
+ - Do not request broad rewrites when a targeted fix resolves the risk.
242
+ `
243
+ },
244
+ {
245
+ name: "git-commit",
246
+ fileName: "git-commit.md",
247
+ content: `---
248
+ name: git-commit
249
+ title: Git Commit
250
+ description: Use this project skill when committing completed agent work.
251
+ triggers: [git, commit, stage, staging, 提交, 暂存, 版本提交]
252
+ intents: [version_control]
253
+ examples: [commit verified plan stage fixes to git, 提交当前关键节点]
254
+ ---
255
+ # Git Commit
256
+
257
+ Use this project skill when committing completed agent work.
258
+
259
+ - Commit at meaningful checkpoints after the relevant harness verification has passed.
260
+ - Inspect the repository commit protocol before writing the commit message; project AGENTS.md or CLAUDE.md may define the required format.
261
+ - Use commit header format: \`<type>(<scope>): <short description>\`.
262
+ - Allowed types: \`feat\`, \`fix\`, \`docs\`, \`style\`, \`refactor\`, \`perf\`, \`test\`, \`chore\`.
263
+ - Keep the header concise, and add the repository's required trailers such as \`Constraint:\`, \`Rejected:\`, \`Confidence:\`, \`Scope-risk:\`, \`Directive:\`, \`Tested:\`, and \`Not-tested:\` when applicable.
264
+ - Stage only files that belong to the completed task, and do not include unrelated user changes.
265
+ - Mention the verification evidence in the commit message when the project commit protocol provides a place for it.
266
+ `
267
+ }
268
+ ];
269
+ //# sourceMappingURL=builtin-skills.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtin-skills.js","sourceRoot":"","sources":["../../src/runtime/builtin-skills.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,oBAAoB,GAA0B;IACzD;QACE,IAAI,EAAE,oBAAoB;QAC1B,QAAQ,EAAE,uBAAuB;QACjC,OAAO,EAAE;;;;;;;;;;;;;;;;;;CAkBZ;KACE;IACD;QACE,IAAI,EAAE,uBAAuB;QAC7B,QAAQ,EAAE,0BAA0B;QACpC,OAAO,EAAE;;;;;;;;;;;;;;;;;;;CAmBZ;KACE;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,QAAQ,EAAE,sBAAsB;QAChC,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;CAqBZ;KACE;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE,oBAAoB;QAC9B,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;CAoBZ;KACE;IACD;QACE,IAAI,EAAE,eAAe;QACrB,QAAQ,EAAE,kBAAkB;QAC5B,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;CAoBZ;KACE;IACD;QACE,IAAI,EAAE,eAAe;QACrB,QAAQ,EAAE,kBAAkB;QAC5B,OAAO,EAAE;;;;;;;;;;;;;;;;;;CAkBZ;KACE;IACD;QACE,IAAI,EAAE,eAAe;QACrB,QAAQ,EAAE,kBAAkB;QAC5B,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;CAoBZ;KACE;IACD;QACE,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,YAAY;QACtB,OAAO,EAAE;;;;;;;;;;;;;;;;;;;CAmBZ;KACE;IACD;QACE,IAAI,EAAE,oBAAoB;QAC1B,QAAQ,EAAE,uBAAuB;QACjC,OAAO,EAAE;;;;;;;;;;;;;;;;;;CAkBZ;KACE;IACD;QACE,IAAI,EAAE,wBAAwB;QAC9B,QAAQ,EAAE,2BAA2B;QACrC,OAAO,EAAE;;;;;;;;;;;;;;;;;;;CAmBZ;KACE;IACD;QACE,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,eAAe;QACzB,OAAO,EAAE;;;;;;;;;;;;;;;;;;;CAmBZ;KACE;CACF,CAAC"}
@@ -0,0 +1,11 @@
1
+ export interface CleanOptions {
2
+ dryRun?: boolean;
3
+ keepLogs?: number;
4
+ }
5
+ export interface CleanResult {
6
+ status: "passed";
7
+ dryRun: boolean;
8
+ removed: string[];
9
+ kept: string[];
10
+ }
11
+ export declare function cleanRuntimeArtifacts(projectRoot: string, options?: CleanOptions): CleanResult;
@@ -0,0 +1,85 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { harnessPath, relativeHarnessPath } from "../storage/paths.js";
4
+ const GENERATED_ARTIFACTS = [
5
+ ["state.json"],
6
+ ["context"],
7
+ ["plans"],
8
+ ["guidance"],
9
+ ["verification"],
10
+ ["repair"],
11
+ ["repair-decision"],
12
+ ["state-explain"],
13
+ ["component-graph"],
14
+ ["execution-units"],
15
+ ["agent-run"],
16
+ ["agent-handoff"]
17
+ ];
18
+ const DURABLE_ARTIFACTS = [
19
+ relativeHarnessPath(".gitkeep"),
20
+ relativeHarnessPath("config.json"),
21
+ relativeHarnessPath("protocol"),
22
+ relativeHarnessPath("knowledge"),
23
+ relativeHarnessPath("skills")
24
+ ];
25
+ export function cleanRuntimeArtifacts(projectRoot, options = {}) {
26
+ const dryRun = Boolean(options.dryRun);
27
+ const keepLogs = normalizeKeepLogs(options.keepLogs);
28
+ const removed = [];
29
+ const kept = [...DURABLE_ARTIFACTS];
30
+ for (const segments of GENERATED_ARTIFACTS) {
31
+ const fullPath = harnessPath(projectRoot, ...segments);
32
+ if (!fs.existsSync(fullPath)) {
33
+ continue;
34
+ }
35
+ const relativePath = relativeHarnessPath(...segments);
36
+ removed.push(relativePath);
37
+ if (!dryRun) {
38
+ fs.rmSync(fullPath, { recursive: true, force: true });
39
+ }
40
+ }
41
+ removed.push(...cleanLogs(projectRoot, keepLogs, dryRun));
42
+ return {
43
+ status: "passed",
44
+ dryRun,
45
+ removed: removed.sort(),
46
+ kept
47
+ };
48
+ }
49
+ function cleanLogs(projectRoot, keepLogs, dryRun) {
50
+ const logsRoot = harnessPath(projectRoot, "logs");
51
+ if (!fs.existsSync(logsRoot)) {
52
+ return [];
53
+ }
54
+ const entries = fs.readdirSync(logsRoot, { withFileTypes: true })
55
+ .filter((entry) => entry.isFile())
56
+ .map((entry) => {
57
+ const fullPath = path.join(logsRoot, entry.name);
58
+ return {
59
+ fullPath,
60
+ relativePath: relativeHarnessPath("logs", entry.name),
61
+ mtimeMs: fs.statSync(fullPath).mtimeMs
62
+ };
63
+ })
64
+ .sort((a, b) => b.mtimeMs - a.mtimeMs);
65
+ const stale = entries.slice(keepLogs);
66
+ for (const entry of stale) {
67
+ if (!dryRun) {
68
+ fs.rmSync(entry.fullPath, { force: true });
69
+ }
70
+ }
71
+ if (!dryRun && fs.existsSync(logsRoot) && fs.readdirSync(logsRoot).length === 0) {
72
+ fs.rmdirSync(logsRoot);
73
+ }
74
+ return stale.map((entry) => entry.relativePath);
75
+ }
76
+ function normalizeKeepLogs(value) {
77
+ if (value === undefined) {
78
+ return 20;
79
+ }
80
+ if (!Number.isInteger(value) || value < 0) {
81
+ throw new Error("--keep-logs must be a non-negative integer");
82
+ }
83
+ return value;
84
+ }
85
+ //# sourceMappingURL=clean.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clean.js","sourceRoot":"","sources":["../../src/runtime/clean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAcvE,MAAM,mBAAmB,GAAG;IAC1B,CAAC,YAAY,CAAC;IACd,CAAC,SAAS,CAAC;IACX,CAAC,OAAO,CAAC;IACT,CAAC,UAAU,CAAC;IACZ,CAAC,cAAc,CAAC;IAChB,CAAC,QAAQ,CAAC;IACV,CAAC,iBAAiB,CAAC;IACnB,CAAC,eAAe,CAAC;IACjB,CAAC,iBAAiB,CAAC;IACnB,CAAC,iBAAiB,CAAC;IACnB,CAAC,WAAW,CAAC;IACb,CAAC,eAAe,CAAC;CACT,CAAC;AAEX,MAAM,iBAAiB,GAAG;IACxB,mBAAmB,CAAC,UAAU,CAAC;IAC/B,mBAAmB,CAAC,aAAa,CAAC;IAClC,mBAAmB,CAAC,UAAU,CAAC;IAC/B,mBAAmB,CAAC,WAAW,CAAC;IAChC,mBAAmB,CAAC,QAAQ,CAAC;CAC9B,CAAC;AAEF,MAAM,UAAU,qBAAqB,CAAC,WAAmB,EAAE,UAAwB,EAAE;IACnF,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,C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,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface HarnessCommand {
2
+ command: string;
3
+ description?: string;
4
+ }
5
+ export declare const PUBLIC_HUMAN_COMMANDS: HarnessCommand[];
6
+ export declare const PUBLIC_AGENT_POLICY_COMMANDS: HarnessCommand[];
7
+ export declare const PUBLIC_ADVISORY_COMMANDS: HarnessCommand[];
8
+ export declare const INTERNAL_CHECK_COMMANDS: HarnessCommand[];
9
+ export declare function publicRecommendedCommands(): string[];
10
+ export declare function publicHelpLines(): string[];
11
+ export declare function protocolUsefulCommandLines(): string[];
12
+ export declare function isPublicCommand(command: string): boolean;
@@ -0,0 +1,72 @@
1
+ export const PUBLIC_HUMAN_COMMANDS = [
2
+ { command: "frontend-harness init" },
3
+ { command: "frontend-harness init --json" },
4
+ { command: "frontend-harness init --dry-run --json" },
5
+ { command: "frontend-harness init --check --json" },
6
+ { command: "frontend-harness protocol check" },
7
+ { command: "frontend-harness protocol check --json" },
8
+ { command: "frontend-harness clean --json" },
9
+ { command: "frontend-harness clean --dry-run --json" },
10
+ { command: "frontend-harness help" },
11
+ { command: "frontend-harness --help" },
12
+ { command: "frontend-harness -h" }
13
+ ];
14
+ export const PUBLIC_AGENT_POLICY_COMMANDS = [
15
+ { command: "frontend-harness context --json" },
16
+ { command: "frontend-harness plan --json \"<task>\"" },
17
+ { command: "frontend-harness state record-change <file>" },
18
+ { command: "frontend-harness state record-change --from-git" },
19
+ { command: "frontend-harness verify --json" },
20
+ { command: "frontend-harness repair packet --json" },
21
+ { command: "frontend-harness state next --json" },
22
+ { command: "frontend-harness state explain --json" }
23
+ ];
24
+ export const PUBLIC_ADVISORY_COMMANDS = [
25
+ { command: "frontend-harness skills list --json" },
26
+ { command: "frontend-harness skills check --json" },
27
+ { command: "frontend-harness knowledge promote --json --title \"<title>\" --body \"<body>\"" },
28
+ { command: "frontend-harness knowledge check --json" }
29
+ ];
30
+ export const INTERNAL_CHECK_COMMANDS = [
31
+ { command: "frontend-harness decision check --json --file <agent-decision.json>" },
32
+ { command: "frontend-harness units check --json" },
33
+ { command: "frontend-harness graph check --json" },
34
+ { command: "frontend-harness repair decision check --json --file <repair-decision.json>" }
35
+ ];
36
+ export function publicRecommendedCommands() {
37
+ return [
38
+ ...PUBLIC_AGENT_POLICY_COMMANDS,
39
+ ...PUBLIC_HUMAN_COMMANDS.filter((item) => item.command.includes("init") || item.command.includes("protocol check")),
40
+ ...PUBLIC_ADVISORY_COMMANDS
41
+ ].map((item) => item.command);
42
+ }
43
+ export function publicHelpLines() {
44
+ return [
45
+ "Human setup and health:",
46
+ ...PUBLIC_HUMAN_COMMANDS.map((item) => ` ${stripBinaryName(item.command)}`),
47
+ "",
48
+ "Agent policy loop:",
49
+ ...PUBLIC_AGENT_POLICY_COMMANDS.map((item) => ` ${stripBinaryName(item.command)}`),
50
+ "",
51
+ "Project advisory/provenance:",
52
+ ...PUBLIC_ADVISORY_COMMANDS.map((item) => ` ${stripBinaryName(item.command)}`)
53
+ ];
54
+ }
55
+ export function protocolUsefulCommandLines() {
56
+ return [
57
+ ...PUBLIC_AGENT_POLICY_COMMANDS,
58
+ ...PUBLIC_ADVISORY_COMMANDS,
59
+ ...INTERNAL_CHECK_COMMANDS
60
+ ].map((item) => `- \`${item.command}\``);
61
+ }
62
+ export function isPublicCommand(command) {
63
+ return [
64
+ ...PUBLIC_HUMAN_COMMANDS,
65
+ ...PUBLIC_AGENT_POLICY_COMMANDS,
66
+ ...PUBLIC_ADVISORY_COMMANDS
67
+ ].some((item) => item.command === command);
68
+ }
69
+ function stripBinaryName(command) {
70
+ return command.replace(/^frontend-harness\s*/, "");
71
+ }
72
+ //# sourceMappingURL=command-taxonomy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command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,4BAA4B;QAC/B,GAAG,wBAAwB;KAC5B,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,eAAe,CAAC,OAAe;IACtC,OAAO,OAAO,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,71 @@
1
+ import type { VerificationCommandDiscovery } from "./verification-commands.js";
2
+ import { type ProjectSurface } from "./project-discovery.js";
3
+ import { type ProjectSkill } from "./skills.js";
4
+ import { type KnowledgeCard } from "./knowledge.js";
5
+ import { type GraphCheckResult } from "./graph.js";
6
+ import { type UnitCheckResult } from "./units.js";
7
+ import { type ProtocolCheckResult } from "./protocol-init.js";
8
+ import type { HarnessState, PlanningDecisionSummary, PolicyProvenance, RepairDecisionSummary } from "../schemas/types.js";
9
+ type ArtifactKey = "latestContext" | "latestPlan" | "latestExecutionUnits" | "latestComponentGraph" | "latestConfig" | "latestVerification" | "latestStateExplain" | "latestRepairPacket" | "latestRepairDecision" | "latestProtocol";
10
+ export interface ProjectContext {
11
+ projectRoot: string;
12
+ detectedStack: {
13
+ packageManager: string;
14
+ framework: string;
15
+ language: string;
16
+ };
17
+ constraints: string[];
18
+ knownArtifacts: {
19
+ latestContext: string;
20
+ latestPlan: string;
21
+ latestExecutionUnits: string;
22
+ latestComponentGraph: string;
23
+ latestConfig: string;
24
+ latestVerification: string;
25
+ latestStateExplain: string;
26
+ latestRepairPacket: string;
27
+ latestRepairDecision: string;
28
+ latestProtocol: string;
29
+ };
30
+ projectSurface: ProjectSurface;
31
+ projectStatus: {
32
+ artifacts: Record<ArtifactKey, {
33
+ path: string;
34
+ exists: boolean;
35
+ updatedAt: string | null;
36
+ sha256: string | null;
37
+ }>;
38
+ surface: ProjectSurface;
39
+ verificationCommands: VerificationCommandDiscovery[];
40
+ knowledge: ProjectKnowledgeSummary[];
41
+ skills: ProjectSkill[];
42
+ executionUnits: UnitCheckResult;
43
+ componentGraph: GraphCheckResult;
44
+ protocol: ProtocolCheckResult;
45
+ stateSummary: {
46
+ status: HarnessState["status"];
47
+ verificationStatus: HarnessState["verification"]["status"];
48
+ hasTask: boolean;
49
+ taskScope: string | null;
50
+ changedFilesCount: number;
51
+ retryCount: number;
52
+ blockerCount: number;
53
+ };
54
+ planReadiness: {
55
+ status: "ready" | "warning" | "blocked";
56
+ protocolReady: boolean;
57
+ skillsAvailable: boolean;
58
+ knowledgeAvailable: boolean;
59
+ verificationConfigured: boolean;
60
+ surfaceDetected: boolean;
61
+ warnings: string[];
62
+ };
63
+ planningDecision: PlanningDecisionSummary | null;
64
+ repairDecision: RepairDecisionSummary | null;
65
+ };
66
+ lastPlannedPolicyProvenance: PolicyProvenance;
67
+ recommendedNextCommands: string[];
68
+ }
69
+ type ProjectKnowledgeSummary = Omit<KnowledgeCard, "searchable">;
70
+ export declare function buildContext(projectRoot: string): ProjectContext;
71
+ export {};