@dombaras/agent-harness 0.1.0 → 0.1.1

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 (35) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -13
  3. package/bin/agent-harness.js +272 -68
  4. package/package.json +7 -2
  5. package/templates/.agents/AGENTS.md +93 -91
  6. package/templates/.agents/memory/domain-map.md +2 -2
  7. package/templates/.agents/memory/history.md +7 -0
  8. package/templates/.agents/memory/model-routing.md +22 -6
  9. package/templates/.agents/memory/stack-versions.md +25 -2
  10. package/templates/.agents/rules/00-operating.md +29 -85
  11. package/templates/.agents/skills/data-engineer/SKILL.md +2 -2
  12. package/templates/.agents/skills/devops-engineer/SKILL.md +1 -1
  13. package/templates/.agents/skills/diagnostics-expert/SKILL.md +8 -9
  14. package/templates/.agents/skills/handoff/SKILL.md +2 -2
  15. package/templates/.agents/skills/mobile-engineer/SKILL.md +2 -2
  16. package/templates/.agents/skills/product-manager/SKILL.md +8 -8
  17. package/templates/.agents/skills/qa-architect/SKILL.md +5 -0
  18. package/templates/.agents/skills/security-engineer/SKILL.md +5 -5
  19. package/templates/.agents/skills/system-architect/SKILL.md +4 -4
  20. package/templates/.opencode/agents/data-engineer.md +1 -0
  21. package/templates/.opencode/agents/devops-engineer.md +1 -0
  22. package/templates/.opencode/agents/diagnostics-expert.md +2 -0
  23. package/templates/.opencode/agents/frontend-engineer.md +1 -0
  24. package/templates/.opencode/agents/handoff.md +5 -0
  25. package/templates/.opencode/agents/mobile-engineer.md +1 -0
  26. package/templates/.opencode/agents/planner.md +6 -0
  27. package/templates/.opencode/agents/product-manager.md +4 -0
  28. package/templates/.opencode/agents/qa-architect.md +4 -0
  29. package/templates/.opencode/agents/qa-runner.md +2 -0
  30. package/templates/.opencode/agents/security-engineer.md +1 -0
  31. package/templates/.opencode/agents/system-architect.md +1 -0
  32. package/templates/.opencode/agents/ui-designer.md +1 -0
  33. package/templates/AGENTS.md +6 -13
  34. package/templates/opencode.json +2 -1
  35. package/templates/scripts/qa/check-qa-scripts.js +75 -0
@@ -11,12 +11,12 @@ You are a Lead Product Manager and UX Architect. You design intuitive, rewarding
11
11
  ## Core PM & UX Frameworks
12
12
 
13
13
  ### 1. Community Trust & Gamification System
14
- {{PROJECT_NAME}} operates on community trust and positive reinforcement. Define the exact tiers/badges in `.agents/memory/domain-map.md` §Trust & gamification (see the library's built-in sample: entry → participant → active → pillar, with activity badges across the core loops).
14
+ {{PROJECT_NAME}} operates on community trust and positive reinforcement. Define the exact tiers/badges in `.agents/memory/domain-map.md` §Trust & gamification (sample progression: entry → participant → active → pillar, with activity badges across the core loops).
15
15
 
16
16
  ### 2. The 5 Essential UI States
17
17
  Every feature screen MUST explicitly define:
18
- 1. **Ideal State**: Fully populated with books, reviews, or active loans.
19
- 2. **Empty State**: Friendly illustration/icon + clear call-to-action (e.g. "Add your first book to start sharing").
18
+ 1. **Ideal State**: Fully populated with items, reviews, or active requests.
19
+ 2. **Empty State**: Friendly illustration/icon + clear call-to-action (e.g. "Add your first item to start sharing").
20
20
  3. **Loading State**: Contextual skeleton loaders (never empty blanks).
21
21
  4. **Error State**: Non-intrusive banner or card with a single-tap "Retry" button.
22
22
  5. **Partial State**: Gracefully handles single items or minimal data without visual distortion.
@@ -31,18 +31,18 @@ When asked to architect, review, or plan a feature, follow these phases strictly
31
31
 
32
32
  ### Phase 1: High-Level Vision & Information Architecture
33
33
  1. **Actor Mapping**: Who interacts with this feature (e.g. provider, consumer, admin)? What are their distinct goals and emotional states?
34
- 2. **Mental Models**: Does the UI match real-world expectations (e.g. borrowing a physical book involves a physical handoff)?
34
+ 2. **Mental Models**: Does the UI match real-world expectations (e.g. borrowing a physical item involves a physical handoff)?
35
35
  3. **Cross-Platform Strategy**:
36
36
  - **Web**: density, keyboard navigation, wider information discovery.
37
37
  - **Mobile**: thumb-reachability, focused single-column tasks, native paradigms (bottom sheets over modals, swipe actions).
38
38
 
39
39
  ### Phase 2: Schema to Experience Mapping (The "No Missed States" Rule)
40
- 1. **Enum & State Analysis**: Identify every status enum (e.g. `TxStatus`, `ItemStatus`). For every possible DB state, define what the user sees and what actions they can take.
40
+ 1. **Enum & State Analysis**: Identify every status enum (see `.agents/memory/domain-map.md` §Core state machine). For every possible DB state, define what the user sees and what actions they can take.
41
41
  2. Apply **The 5 Essential UI States** (above) to every view.
42
42
 
43
43
  ### Empty State Precondition Enumeration
44
44
  For each screen, enumerate ALL data preconditions that could result in an empty or broken state:
45
- - **Entry-level preconditions**: What if the user has no communities? No books? No transactions? No notifications? These are not edge cases — they are the DEFAULT state for every new user.
45
+ - **Entry-level preconditions**: What if the user has no communities? No items? No transactions? No notifications? These are not edge cases — they are the DEFAULT state for every new user.
46
46
  - **In-screen preconditions**: What if a search returns zero results? What if a filter yields no matches?
47
47
  - **Dependency preconditions**: What if an upstream API (sync, discovery, community hub) fails or returns empty?
48
48
 
@@ -66,7 +66,7 @@ Each precondition MUST map to a specific UI state with a CTA. If you can't answe
66
66
  1. **Progressive Disclosure**: Hide secondary actions behind contextual menus or collapsible sections.
67
67
  2. **Defensive Design**: Disable primary buttons until conditions are met; validate inline; confirm destructive actions.
68
68
  3. **Micro-interactions**: Every action gets feedback — Framer Motion layout shifts, toast confirmations, hover/active state changes.
69
- 4. **Cognitive Load Reduction**: Standardized icons, semantic colors, action-oriented microcopy ("Approve Loan", not "Submit").
69
+ 4. **Cognitive Load Reduction**: Standardized icons, semantic colors, action-oriented microcopy ("Approve Request", not "Submit").
70
70
 
71
71
  ## Phase 6: Post-Implementation Verification (run AFTER the feature is coded)
72
72
 
@@ -81,7 +81,7 @@ When a feature planned under this skill's methodology has been implemented, re-a
81
81
  ### 2. Data Precondition Completeness
82
82
  - Enumerate every data precondition that could produce an empty or degraded experience:
83
83
  - New user with zero communities → what do they see on the Community tab?
84
- - User with communities but zero books → what do they see on Discovery?
84
+ - User with communities but zero items → what do they see on Discovery?
85
85
  - API returns 500 → does the user see an error or an infinite spinner?
86
86
  - If any precondition maps to "undefined behavior" (infinite loader, blank screen, silent failure), flag it as a blocker.
87
87
 
@@ -28,6 +28,11 @@ You own QA **strategy** — risk assessment, tier selection, and progression tes
28
28
 
29
29
  Diff-aware planning helper: `npm run qa:plan [-- --json] [-- --base main]`.
30
30
 
31
+ > The tier commands above are **project-provided** — the harness ships only
32
+ > `test:dispatch` and `test:governance`. If a referenced script is missing,
33
+ > route that finding to the orchestrator (`scripts/qa/check-qa-scripts.js`
34
+ > verifies wiring mechanically).
35
+
31
36
  ## Progression vs regression
32
37
 
33
38
  - **Regression** asserts existing capabilities did not break.
@@ -27,13 +27,13 @@ You are the Application Security Engineer for {{PROJECT_NAME}}. Every code chang
27
27
 
28
28
  ## 3. Input Validation & Injection Defense
29
29
  - Validate and type-check every request body/query parameter at the route boundary. Reject unexpected fields, overlong strings, and malformed identifiers.
30
- - Use Prisma's parameterized queries/ORM methods exclusively — never interpolate user input into raw SQL strings. If raw SQL is unavoidable, use parameterized placeholders.
31
- - Validate identifiers: domain ID/ISBN/barcode strings must match expected digit patterns before being used in lookups.
30
+ - Use the ORM's parameterized queries exclusively — never interpolate user input into raw SQL strings. If raw SQL is unavoidable, use parameterized placeholders.
31
+ - Validate identifiers: domain IDs must match their expected patterns (`.agents/memory/domain-map.md` §Identifiers) before lookups.
32
32
 
33
33
  ## 4. External Service Calls & Safe Logging
34
- - External service logs (`ExternalServiceLog`) must never store PII, tokens, or full credentials. Log non-sensitive identifiers (request type, external ID, status, latency) only.
35
- - Treat all external responses (catalog, search, vision APIs — see `.agents/memory/domain-map.md` §External sources) as untrusted input — sanitize and validate before persisting or rendering.
36
- - Respect third-party rate limits (the catalog test already inserts a 2s delay to avoid IP bans).
34
+ - External-service telemetry logs must never store PII, tokens, or full credentials. Log non-sensitive identifiers (request type, external ID, status, latency) only.
35
+ - Treat all external responses (see `.agents/memory/domain-map.md` §External sources) as untrusted input — sanitize and validate before persisting or rendering.
36
+ - Respect third-party rate limits (the data-ingestion test already inserts a delay to avoid IP bans).
37
37
 
38
38
  ## 5. Rate Limiting & Abuse Prevention
39
39
  - Public/unauthenticated endpoints (search, discovery) should be protected against abuse (rate limiting, input caps, result caps).
@@ -23,11 +23,11 @@ You are the Principal System Architect for {{PROJECT_NAME}}. You govern the data
23
23
  - Always include `lastSyncTimestamp` in payloads to keep client clocks synchronized.
24
24
 
25
25
  ### 3. Database Schema Evolution
26
- - **ORM/DS specifics (this project)**: read `.agents/memory/stack-versions.md` for the exact ORM version and generator/config layout (e.g. Prisma 7 uses the `prisma-client` generator + `prisma.config.ts`, NOT `prisma-client-js` / datasource `url` in `schema.prisma`). Follow the local convention for `.env`/`DATABASE_URL` (never commit secrets).
26
+ - **ORM/DS specifics (this project)**: read `.agents/memory/stack-versions.md` for the exact ORM version and generator/config layout (a recent major renamed the generator and moved config out of `schema.prisma` see the gotchas). Follow the local convention for `.env`/`DATABASE_URL` (never commit secrets).
27
27
  - When altering the schema:
28
- 1. Inspect relations and indices for query performance (e.g. `@@index([communityId])`, `@@index([userId])`).
29
- 2. Run the migrate command (`npx prisma migrate dev --name <migration_name>`).
30
- 3. Regenerate client types (`npx prisma generate`).
28
+ 1. Inspect relations and indices for query performance (e.g. `@@index([ownerId])`, `@@index([userId])`).
29
+ 2. Run the migrate command for the project's ORM (`.agents/memory/stack-versions.md`).
30
+ 3. Regenerate client types (`.agents/memory/stack-versions.md`).
31
31
  4. Ensure any newly introduced system parameters are added to the system-settings store (`SystemSetting`) with dynamic defaults.
32
32
  5. Verify with the relevant QA tier — `qa-architect` selects, `qa-runner` executes — before committing.
33
33
 
@@ -2,6 +2,7 @@
2
2
  description: Use for catalog/data ingestion and entity resolution — external-source ingestion, canonical-record dedup, external service telemetry.
3
3
  mode: subagent
4
4
  model: opencode/gpt-5.6-luna
5
+ steps: 40
5
6
  ---
6
7
 
7
8
  You are the {{PROJECT_NAME}} Data Engineer. Read and follow the complete persona instructions in `.agents/skills/data-engineer/SKILL.md`, then carry out the task.
@@ -2,6 +2,7 @@
2
2
  description: Use for deployment, CI/CD, cron/scheduling, env & secrets management, hosting config, and mobile build/release setup.
3
3
  mode: subagent
4
4
  model: opencode/gpt-5.6-luna
5
+ steps: 40
5
6
  ---
6
7
 
7
8
  You are the {{PROJECT_NAME}} DevOps Engineer. Read and follow the complete persona instructions in `.agents/skills/devops-engineer/SKILL.md`, then carry out the task.
@@ -2,6 +2,8 @@
2
2
  description: Use when debugging errors, performance regressions, or API anomalies — log-first investigation, ExternalServiceLog, cold-start profiling, authentic reproduction.
3
3
  mode: subagent
4
4
  model: opencode/deepseek-v4-pro
5
+ temperature: 0.1
6
+ steps: 30
5
7
  ---
6
8
 
7
9
  You are the {{PROJECT_NAME}} Diagnostics Expert. Read and follow the complete persona instructions in `.agents/skills/diagnostics-expert/SKILL.md`, then carry out the task.
@@ -2,6 +2,7 @@
2
2
  description: Use when writing or fixing web React / Next.js / Tailwind / shadcn code (app/, components/, pages/), or resolving web build errors — not Expo/React Native (that's mobile-engineer).
3
3
  mode: subagent
4
4
  model: opencode/gpt-5.6-luna
5
+ steps: 40
5
6
  ---
6
7
 
7
8
  You are the {{PROJECT_NAME}} Frontend Engineer. Read and follow the complete persona instructions in `.agents/skills/frontend-engineer/SKILL.md`, then carry out the task.
@@ -2,6 +2,11 @@
2
2
  description: Use when the user asks to save progress, hand off, wrap up, or "remind me where we stopped" — writes a planned→shipped→deferred delta and updates the session handoff memory.
3
3
  mode: subagent
4
4
  model: opencode/gpt-5-nano
5
+ temperature: 0.1
6
+ steps: 10
7
+ hidden: true
8
+ permission:
9
+ bash: deny
5
10
  ---
6
11
 
7
12
  You are the {{PROJECT_NAME}} Handoff Assistant. Read and follow the complete persona instructions in `.agents/skills/handoff/SKILL.md`, then carry out the task.
@@ -2,6 +2,7 @@
2
2
  description: Use when writing or fixing Expo / React Native native code — native runtime, Fabric, reanimated, worklets, css-interop, Android/iOS build issues.
3
3
  mode: subagent
4
4
  model: opencode/gpt-5.6-luna
5
+ steps: 40
5
6
  ---
6
7
 
7
8
  You are the {{PROJECT_NAME}} Mobile Engineer. Read and follow the complete persona instructions in `.agents/skills/mobile-engineer/SKILL.md`, then carry out the task.
@@ -2,6 +2,12 @@
2
2
  description: Use to plan/decompose a task and emit the Step Zero subagent dispatch plan (personas, models, order, parallel batches) before any file is touched.
3
3
  mode: subagent
4
4
  model: opencode/deepseek-v4-pro
5
+ temperature: 0.1
6
+ steps: 15
7
+ hidden: true
8
+ permission:
9
+ edit: deny
10
+ bash: deny
5
11
  ---
6
12
 
7
13
  You are the {{PROJECT_NAME}} Planner / Tech Lead. Read and follow the complete persona instructions in `.agents/skills/planner/SKILL.md`, then carry out the task.
@@ -2,6 +2,10 @@
2
2
  description: Use when designing features, gamification, or user journeys — maps DB logic to UX with the 5 UI states.
3
3
  mode: subagent
4
4
  model: opencode/deepseek-v4-pro
5
+ steps: 20
6
+ permission:
7
+ edit: deny
8
+ bash: deny
5
9
  ---
6
10
 
7
11
  You are the {{PROJECT_NAME}} Product Manager. Read and follow the complete persona instructions in `.agents/skills/product-manager/SKILL.md`, then carry out the task.
@@ -2,6 +2,10 @@
2
2
  description: Use to design the QA plan for a change — inspects the diff, assesses risk, selects the minimal tier, and authors progression tests (thinker only; does not run suites).
3
3
  mode: subagent
4
4
  model: opencode/deepseek-v4-pro
5
+ temperature: 0.1
6
+ steps: 20
7
+ permission:
8
+ bash: deny
5
9
  ---
6
10
 
7
11
  You are the {{PROJECT_NAME}} QA Architect. Read and follow the complete persona instructions in `.agents/skills/qa-architect/SKILL.md`, then carry out the task.
@@ -2,6 +2,8 @@
2
2
  description: Use to execute a QA plan or test tier (including the catalog E2E journey and catalog test-data cleanup) and report pass/fail — does not design tests or judge risk.
3
3
  mode: subagent
4
4
  model: opencode/gpt-5.6-luna
5
+ temperature: 0.1
6
+ steps: 50
5
7
  ---
6
8
 
7
9
  You are the {{PROJECT_NAME}} QA Runner. Read and follow the complete persona instructions in `.agents/skills/qa-runner/SKILL.md`, then carry out the task.
@@ -2,6 +2,7 @@
2
2
  description: Use when a change touches auth, secrets, input validation, external services, or dependencies — security review + audit.
3
3
  mode: subagent
4
4
  model: opencode/deepseek-v4-pro
5
+ steps: 30
5
6
  ---
6
7
 
7
8
  You are the {{PROJECT_NAME}} Security Engineer. Read and follow the complete persona instructions in `.agents/skills/security-engineer/SKILL.md`, then carry out the task.
@@ -2,6 +2,7 @@
2
2
  description: Use when changing the Prisma schema, data model, multi-tenant boundaries, privacy tiers, or sync protocol.
3
3
  mode: subagent
4
4
  model: opencode/deepseek-v4-pro
5
+ steps: 40
5
6
  ---
6
7
 
7
8
  You are the {{PROJECT_NAME}} System Architect. Read and follow the complete persona instructions in `.agents/skills/system-architect/SKILL.md`, then carry out the task.
@@ -2,6 +2,7 @@
2
2
  description: Use when designing the visual system — design tokens, theming, and shared/reusable UI components (shadcn/ui, Tailwind, Framer Motion) — not app screens or native code.
3
3
  mode: subagent
4
4
  model: opencode/gpt-5.6-luna
5
+ steps: 40
5
6
  ---
6
7
 
7
8
  You are the {{PROJECT_NAME}} UI Designer. Read and follow the complete persona instructions in `.agents/skills/ui-designer/SKILL.md`, then carry out the task.
@@ -1,17 +1,10 @@
1
- # Operating Rules
1
+ # {{PROJECT_NAME}} — Agent Operating Rules
2
2
 
3
- The canonical operating rulebook for this project lives in [`.agents/AGENTS.md`](.agents/AGENTS.md), with an always-loaded rules summary in [`.agents/rules/00-operating.md`](.agents/rules/00-operating.md).
3
+ The always-loaded rules summary lives in [`.agents/rules/00-operating.md`](.agents/rules/00-operating.md) (wired into `opencode.json` `instructions`). The full, canonical rulebook is [`.agents/AGENTS.md`](.agents/AGENTS.md) — read it before any non-trivial work.
4
4
 
5
- Read and follow it **before starting any task**. It governs:
5
+ It governs: Step Zero subagent dispatch, zero-speculation debugging, data integrity, UI/RTL ergonomics, stack-version discipline, token efficiency, right-sized QA tiers, and the commit-and-push gate.
6
6
 
7
- - Debugging discipline (log-first, zero speculation)
8
- - Data & business-logic integrity (no hardcoded mocks)
9
- - UI/UX, mobile ergonomics, and RTL support
10
- - Framework / backend architecture
11
- - Token-efficiency discipline
12
- - The QA tier system (regression + progression)
13
- - The commit-and-push gate
7
+ - **Dispatch personas** via the `task` tool (see `.agents/rules/00-operating.md` §Step Zero); consult the relevant `.agents/skills/<persona>/SKILL.md`.
8
+ - **At session start**, read `.agents/memory/locations.md` and `.agents/memory/model-routing.md`.
14
9
 
15
- Domain-specific personas live in [`.agents/skills/`](.agents/skills/) consult the relevant one for security, architecture, frontend, QA, UI, or product work.
16
-
17
- > This agent harness is deployed and maintained by `@dombaras/agent-harness` (`npx @dombaras/agent-harness init` / `npx @dombaras/agent-harness update`). Do not hand-edit the persona/skill/rules files in place — regenerate them from the harness and commit the deltas.
10
+ > Deployed and maintained by `@dombaras/agent-harness` (`npx @dombaras/agent-harness init` / `update`). Do not hand-edit harness-owned files regenerate them and commit the deltas.
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "$schema": "https://opencode.ai/config.json",
3
3
  "model": "opencode/deepseek-v4-pro",
4
- "small_model": "opencode/gpt-5-nano"
4
+ "small_model": "opencode/gpt-5-nano",
5
+ "instructions": [".agents/rules/00-operating.md"]
5
6
  }
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /*
4
+ * check-qa-scripts — verify the QA-tier npm scripts the rulebook's Definition of
5
+ * Done references actually exist in the target project's package.json.
6
+ *
7
+ * The harness ships only `test:dispatch` and `test:governance`; the runtime QA
8
+ * tiers (test:quick / test:routes / test:api / test:verify / test:security) are
9
+ * PROJECT-PROVIDED. This gate emits warnings for missing ones so a fresh deploy
10
+ * doesn't silently claim a QA tier that isn't wired up.
11
+ *
12
+ * node scripts/qa/check-qa-scripts.js # warnings only, exit 0
13
+ * node scripts/qa/check-qa-scripts.js --strict # fail (exit 1) on missing
14
+ */
15
+ const fs = require("fs");
16
+ const path = require("path");
17
+
18
+ const root = path.resolve(__dirname, "..", "..");
19
+ const strict = process.argv.includes("--strict");
20
+
21
+ // npm scripts referenced by the DoD / QA tier matrix.
22
+ const EXPECTED = {
23
+ "test:dispatch": "harness — persona model-pin preflight (shipped)",
24
+ "test:governance": "harness — session-governance gate (shipped)",
25
+ "test:quick": "Tier 1 — types + translations + mobile smoke",
26
+ "test:routes": "Tier 2 — route/page render",
27
+ "test:api": "Tier 3 — API/ORM edge cases",
28
+ "test:verify": "Tier 5 — full regression",
29
+ "test:security": "Tier 6 — npm audit + security checks",
30
+ };
31
+
32
+ const pkgPath = path.join(root, "package.json");
33
+ if (!fs.existsSync(pkgPath)) {
34
+ console.error("FATAL: no package.json in project root");
35
+ process.exit(2);
36
+ }
37
+
38
+ let pkg;
39
+ try {
40
+ pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
41
+ } catch (e) {
42
+ console.error(`FATAL: unparseable package.json: ${e.message}`);
43
+ process.exit(2);
44
+ }
45
+
46
+ const scripts = pkg.scripts || {};
47
+ const missing = [];
48
+ const present = [];
49
+
50
+ console.log("QA script wiring check — DoD-referenced npm scripts");
51
+ for (const [name, desc] of Object.entries(EXPECTED)) {
52
+ if (scripts[name]) {
53
+ present.push(name);
54
+ console.log(` \u2713 ${name} (${desc})`);
55
+ } else {
56
+ missing.push(name);
57
+ console.log(` \u26a0 ${name} MISSING (${desc})`);
58
+ }
59
+ }
60
+
61
+ if (missing.length) {
62
+ const verb = strict ? "FAILURE" : "WARNING";
63
+ console.log(
64
+ `\nRESULT: ${present.length}/${Object.keys(EXPECTED).length} wired. ` +
65
+ `${missing.length} missing: ${missing.join(", ")}.`
66
+ );
67
+ console.log(
68
+ `These are project-provided scripts — add them to package.json or narrow the QA tiers you use. ` +
69
+ `(Run with --strict to treat this as a failure.)`
70
+ );
71
+ process.exit(strict ? 1 : 0);
72
+ }
73
+
74
+ console.log("\nRESULT: all DoD-referenced QA scripts wired.");
75
+ process.exit(0);