@agntk/agent-harness 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 (212) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +41 -0
  3. package/README.md +445 -0
  4. package/defaults/agents/summarizer.md +49 -0
  5. package/defaults/instincts/lead-with-answer.md +24 -0
  6. package/defaults/instincts/qualify-before-recommending.md +40 -0
  7. package/defaults/instincts/read-before-edit.md +23 -0
  8. package/defaults/instincts/search-before-create.md +23 -0
  9. package/defaults/playbooks/ship-feature.md +31 -0
  10. package/defaults/rules/ask-before-assuming.md +35 -0
  11. package/defaults/rules/operations.md +35 -0
  12. package/defaults/rules/respect-the-user.md +39 -0
  13. package/defaults/skills/business-analyst.md +181 -0
  14. package/defaults/skills/content-marketer.md +184 -0
  15. package/defaults/skills/research.md +34 -0
  16. package/defaults/tools/example-web-search.md +60 -0
  17. package/defaults/workflows/daily-reflection.md +54 -0
  18. package/dist/agent-framework-K4GUIICH.js +344 -0
  19. package/dist/agent-framework-K4GUIICH.js.map +1 -0
  20. package/dist/analytics-RPT73WNM.js +12 -0
  21. package/dist/analytics-RPT73WNM.js.map +1 -0
  22. package/dist/auto-processor-OLE45UI3.js +13 -0
  23. package/dist/auto-processor-OLE45UI3.js.map +1 -0
  24. package/dist/chunk-274RV3YO.js +162 -0
  25. package/dist/chunk-274RV3YO.js.map +1 -0
  26. package/dist/chunk-4CWAGBNS.js +168 -0
  27. package/dist/chunk-4CWAGBNS.js.map +1 -0
  28. package/dist/chunk-4FDUOGSZ.js +69 -0
  29. package/dist/chunk-4FDUOGSZ.js.map +1 -0
  30. package/dist/chunk-5H34JPMB.js +199 -0
  31. package/dist/chunk-5H34JPMB.js.map +1 -0
  32. package/dist/chunk-6EMOEYGU.js +102 -0
  33. package/dist/chunk-6EMOEYGU.js.map +1 -0
  34. package/dist/chunk-A7BJPQQ6.js +236 -0
  35. package/dist/chunk-A7BJPQQ6.js.map +1 -0
  36. package/dist/chunk-AGAAFJEO.js +76 -0
  37. package/dist/chunk-AGAAFJEO.js.map +1 -0
  38. package/dist/chunk-BSKDOFRT.js +65 -0
  39. package/dist/chunk-BSKDOFRT.js.map +1 -0
  40. package/dist/chunk-CHJ5GNZC.js +100 -0
  41. package/dist/chunk-CHJ5GNZC.js.map +1 -0
  42. package/dist/chunk-CSL3ERUI.js +307 -0
  43. package/dist/chunk-CSL3ERUI.js.map +1 -0
  44. package/dist/chunk-DA7IKHC4.js +229 -0
  45. package/dist/chunk-DA7IKHC4.js.map +1 -0
  46. package/dist/chunk-DGUM43GV.js +11 -0
  47. package/dist/chunk-DGUM43GV.js.map +1 -0
  48. package/dist/chunk-DTTXPHFW.js +211 -0
  49. package/dist/chunk-DTTXPHFW.js.map +1 -0
  50. package/dist/chunk-FD55B3IO.js +204 -0
  51. package/dist/chunk-FD55B3IO.js.map +1 -0
  52. package/dist/chunk-FLZU44SV.js +230 -0
  53. package/dist/chunk-FLZU44SV.js.map +1 -0
  54. package/dist/chunk-GJNNR2RA.js +200 -0
  55. package/dist/chunk-GJNNR2RA.js.map +1 -0
  56. package/dist/chunk-GNUSHD2Y.js +111 -0
  57. package/dist/chunk-GNUSHD2Y.js.map +1 -0
  58. package/dist/chunk-GUJTBGVS.js +2212 -0
  59. package/dist/chunk-GUJTBGVS.js.map +1 -0
  60. package/dist/chunk-IZ6UZ3ZL.js +207 -0
  61. package/dist/chunk-IZ6UZ3ZL.js.map +1 -0
  62. package/dist/chunk-JKMGYWXB.js +197 -0
  63. package/dist/chunk-JKMGYWXB.js.map +1 -0
  64. package/dist/chunk-KFX54TQM.js +165 -0
  65. package/dist/chunk-KFX54TQM.js.map +1 -0
  66. package/dist/chunk-M7NXUK55.js +199 -0
  67. package/dist/chunk-M7NXUK55.js.map +1 -0
  68. package/dist/chunk-MPZ3BPUI.js +374 -0
  69. package/dist/chunk-MPZ3BPUI.js.map +1 -0
  70. package/dist/chunk-OC6YSTDX.js +119 -0
  71. package/dist/chunk-OC6YSTDX.js.map +1 -0
  72. package/dist/chunk-RC6MEZB6.js +469 -0
  73. package/dist/chunk-RC6MEZB6.js.map +1 -0
  74. package/dist/chunk-RY3ZFII7.js +3440 -0
  75. package/dist/chunk-RY3ZFII7.js.map +1 -0
  76. package/dist/chunk-TAT6JU3X.js +167 -0
  77. package/dist/chunk-TAT6JU3X.js.map +1 -0
  78. package/dist/chunk-UDZIS2AQ.js +79 -0
  79. package/dist/chunk-UDZIS2AQ.js.map +1 -0
  80. package/dist/chunk-UPLBF4RZ.js +115 -0
  81. package/dist/chunk-UPLBF4RZ.js.map +1 -0
  82. package/dist/chunk-UWQTZMNI.js +154 -0
  83. package/dist/chunk-UWQTZMNI.js.map +1 -0
  84. package/dist/chunk-W4T7PGI2.js +346 -0
  85. package/dist/chunk-W4T7PGI2.js.map +1 -0
  86. package/dist/chunk-XTBKL5BI.js +111 -0
  87. package/dist/chunk-XTBKL5BI.js.map +1 -0
  88. package/dist/chunk-YIJY5DBV.js +399 -0
  89. package/dist/chunk-YIJY5DBV.js.map +1 -0
  90. package/dist/chunk-YUFNYN2H.js +242 -0
  91. package/dist/chunk-YUFNYN2H.js.map +1 -0
  92. package/dist/chunk-Z2PUCXTZ.js +94 -0
  93. package/dist/chunk-Z2PUCXTZ.js.map +1 -0
  94. package/dist/chunk-ZZJOFKAT.js +13 -0
  95. package/dist/chunk-ZZJOFKAT.js.map +1 -0
  96. package/dist/cli/index.js +3661 -0
  97. package/dist/cli/index.js.map +1 -0
  98. package/dist/config-WVMRUOCA.js +13 -0
  99. package/dist/config-WVMRUOCA.js.map +1 -0
  100. package/dist/context-loader-3ORBPMHJ.js +13 -0
  101. package/dist/context-loader-3ORBPMHJ.js.map +1 -0
  102. package/dist/conversation-QDEIDQPH.js +22 -0
  103. package/dist/conversation-QDEIDQPH.js.map +1 -0
  104. package/dist/cost-tracker-RS3W7SVY.js +24 -0
  105. package/dist/cost-tracker-RS3W7SVY.js.map +1 -0
  106. package/dist/delegate-VJCJLYEK.js +29 -0
  107. package/dist/delegate-VJCJLYEK.js.map +1 -0
  108. package/dist/emotional-state-VQVRA6ED.js +206 -0
  109. package/dist/emotional-state-VQVRA6ED.js.map +1 -0
  110. package/dist/env-discovery-2BLVMAIM.js +251 -0
  111. package/dist/env-discovery-2BLVMAIM.js.map +1 -0
  112. package/dist/export-6GCYHEHQ.js +165 -0
  113. package/dist/export-6GCYHEHQ.js.map +1 -0
  114. package/dist/graph-YUIPOSOO.js +14 -0
  115. package/dist/graph-YUIPOSOO.js.map +1 -0
  116. package/dist/harness-LCHA3DWP.js +10 -0
  117. package/dist/harness-LCHA3DWP.js.map +1 -0
  118. package/dist/harness-WE4SLCML.js +26 -0
  119. package/dist/harness-WE4SLCML.js.map +1 -0
  120. package/dist/health-NZ6WNIMV.js +23 -0
  121. package/dist/health-NZ6WNIMV.js.map +1 -0
  122. package/dist/index.d.ts +3612 -0
  123. package/dist/index.js +13501 -0
  124. package/dist/index.js.map +1 -0
  125. package/dist/indexer-LONANRRM.js +16 -0
  126. package/dist/indexer-LONANRRM.js.map +1 -0
  127. package/dist/instinct-learner-SRM72DHF.js +20 -0
  128. package/dist/instinct-learner-SRM72DHF.js.map +1 -0
  129. package/dist/intake-4M3HNU43.js +21 -0
  130. package/dist/intake-4M3HNU43.js.map +1 -0
  131. package/dist/intelligence-HJOCA4SJ.js +1081 -0
  132. package/dist/intelligence-HJOCA4SJ.js.map +1 -0
  133. package/dist/journal-WANJL3MI.js +24 -0
  134. package/dist/journal-WANJL3MI.js.map +1 -0
  135. package/dist/loader-C3TKIKZR.js +23 -0
  136. package/dist/loader-C3TKIKZR.js.map +1 -0
  137. package/dist/mcp-WTQJJZAO.js +15 -0
  138. package/dist/mcp-WTQJJZAO.js.map +1 -0
  139. package/dist/mcp-discovery-WPAQFL6S.js +377 -0
  140. package/dist/mcp-discovery-WPAQFL6S.js.map +1 -0
  141. package/dist/mcp-installer-6O2XXD3V.js +394 -0
  142. package/dist/mcp-installer-6O2XXD3V.js.map +1 -0
  143. package/dist/metrics-KXGNFAAB.js +20 -0
  144. package/dist/metrics-KXGNFAAB.js.map +1 -0
  145. package/dist/primitive-registry-I6VTIR4W.js +512 -0
  146. package/dist/primitive-registry-I6VTIR4W.js.map +1 -0
  147. package/dist/project-discovery-C4UMD7JI.js +246 -0
  148. package/dist/project-discovery-C4UMD7JI.js.map +1 -0
  149. package/dist/provider-LQHQX7Z7.js +26 -0
  150. package/dist/provider-LQHQX7Z7.js.map +1 -0
  151. package/dist/provider-SXPQZ74H.js +28 -0
  152. package/dist/provider-SXPQZ74H.js.map +1 -0
  153. package/dist/rate-limiter-RLRVM325.js +22 -0
  154. package/dist/rate-limiter-RLRVM325.js.map +1 -0
  155. package/dist/rule-engine-YGQ3RYZM.js +182 -0
  156. package/dist/rule-engine-YGQ3RYZM.js.map +1 -0
  157. package/dist/scaffold-A3VRRCBV.js +347 -0
  158. package/dist/scaffold-A3VRRCBV.js.map +1 -0
  159. package/dist/scheduler-XHHIVHRI.js +397 -0
  160. package/dist/scheduler-XHHIVHRI.js.map +1 -0
  161. package/dist/search-V3W5JMJG.js +75 -0
  162. package/dist/search-V3W5JMJG.js.map +1 -0
  163. package/dist/semantic-search-2DTOO5UX.js +241 -0
  164. package/dist/semantic-search-2DTOO5UX.js.map +1 -0
  165. package/dist/serve-DTQ3HENY.js +291 -0
  166. package/dist/serve-DTQ3HENY.js.map +1 -0
  167. package/dist/sessions-CZGVXKQE.js +21 -0
  168. package/dist/sessions-CZGVXKQE.js.map +1 -0
  169. package/dist/sources-RW5DT56F.js +32 -0
  170. package/dist/sources-RW5DT56F.js.map +1 -0
  171. package/dist/starter-packs-76YUVHEU.js +893 -0
  172. package/dist/starter-packs-76YUVHEU.js.map +1 -0
  173. package/dist/state-GMXILIHW.js +13 -0
  174. package/dist/state-GMXILIHW.js.map +1 -0
  175. package/dist/state-merge-NKO5FRBA.js +174 -0
  176. package/dist/state-merge-NKO5FRBA.js.map +1 -0
  177. package/dist/telemetry-UC6PBXC7.js +22 -0
  178. package/dist/telemetry-UC6PBXC7.js.map +1 -0
  179. package/dist/tool-executor-MJ7IG7PQ.js +28 -0
  180. package/dist/tool-executor-MJ7IG7PQ.js.map +1 -0
  181. package/dist/tools-DZ4KETET.js +20 -0
  182. package/dist/tools-DZ4KETET.js.map +1 -0
  183. package/dist/types-EW7AIB3R.js +18 -0
  184. package/dist/types-EW7AIB3R.js.map +1 -0
  185. package/dist/types-WGDLSPO6.js +16 -0
  186. package/dist/types-WGDLSPO6.js.map +1 -0
  187. package/dist/universal-installer-QGS4SJGX.js +578 -0
  188. package/dist/universal-installer-QGS4SJGX.js.map +1 -0
  189. package/dist/validator-7WXMDIHH.js +22 -0
  190. package/dist/validator-7WXMDIHH.js.map +1 -0
  191. package/dist/verification-gate-FYXUX6LH.js +246 -0
  192. package/dist/verification-gate-FYXUX6LH.js.map +1 -0
  193. package/dist/versioning-Z3XNE2Q2.js +271 -0
  194. package/dist/versioning-Z3XNE2Q2.js.map +1 -0
  195. package/dist/watcher-ISJC7YKL.js +109 -0
  196. package/dist/watcher-ISJC7YKL.js.map +1 -0
  197. package/dist/web-server-DD7ZOP46.js +28 -0
  198. package/dist/web-server-DD7ZOP46.js.map +1 -0
  199. package/package.json +76 -0
  200. package/sources.yaml +121 -0
  201. package/templates/assistant/CORE.md +24 -0
  202. package/templates/assistant/SYSTEM.md +24 -0
  203. package/templates/assistant/config.yaml +51 -0
  204. package/templates/base/CORE.md +17 -0
  205. package/templates/base/SYSTEM.md +24 -0
  206. package/templates/base/config.yaml +51 -0
  207. package/templates/claude-opus/config.yaml +51 -0
  208. package/templates/code-reviewer/CORE.md +25 -0
  209. package/templates/code-reviewer/SYSTEM.md +30 -0
  210. package/templates/code-reviewer/config.yaml +51 -0
  211. package/templates/gpt4/config.yaml +51 -0
  212. package/templates/local/config.yaml +51 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runtime/starter-packs.ts"],"sourcesContent":["/**\n * Builtin starter packs — installable bundles of primitives (workflows,\n * rules, instincts, skills) that users can customize after installation.\n *\n * Install via: `harness install pack:<name>`\n * List available: `harness install pack:list`\n */\n\nimport type { PackedBundle, BundleManifest, BundleFileEntry } from './primitive-registry.js';\n\nexport interface StarterPack {\n name: string;\n description: string;\n tags: string[];\n files: Array<{ path: string; content: string; id: string; l0: string }>;\n}\n\nconst PACKS: Record<string, StarterPack> = {\n 'daily-briefs': {\n name: 'daily-briefs',\n description: 'Morning briefing and evening review workflows — summarize upcoming tasks, review completed work, and plan next steps.',\n tags: ['daily', 'briefing', 'review', 'productivity'],\n files: [\n {\n path: 'workflows/morning-brief.md',\n id: 'morning-brief',\n l0: 'Morning briefing workflow that summarizes recent sessions and plans the day.',\n content: `---\nid: morning-brief\ntags: [workflow, daily, morning]\nauthor: infrastructure\nstatus: active\nschedule: \"0 8 * * 1-5\"\n---\n# Morning Brief\n\nReview yesterday's sessions and journal, then produce a concise daily brief.\n\n## Instructions\n\n1. Load the most recent journal entry and any sessions from the last 24 hours.\n2. Summarize key accomplishments, open questions, and blockers.\n3. List the top 3 priorities for today based on recent activity patterns.\n4. Note any instincts or rules that were frequently triggered.\n5. Keep the output under 500 words — this is a quick scan, not a deep analysis.\n\n## Output Format\n\n**Yesterday's highlights:**\n- [bullet points]\n\n**Today's priorities:**\n1. [priority]\n2. [priority]\n3. [priority]\n\n**Open questions / blockers:**\n- [if any]\n`,\n },\n {\n path: 'workflows/evening-review.md',\n id: 'evening-review',\n l0: 'Evening review workflow that synthesizes the day and prepares for tomorrow.',\n content: `---\nid: evening-review\ntags: [workflow, daily, evening, review]\nauthor: infrastructure\nstatus: active\nschedule: \"0 18 * * 1-5\"\n---\n# Evening Review\n\nSynthesize today's work and prepare handoff notes for tomorrow.\n\n## Instructions\n\n1. Load all sessions from today.\n2. Identify what was accomplished vs. what was planned (from morning brief if available).\n3. Note any recurring patterns, surprises, or friction points.\n4. Suggest 1-2 instinct candidates if behavioral patterns emerge.\n5. Write a brief handoff note for tomorrow's morning brief.\n\n## Output Format\n\n**Completed today:**\n- [bullet points]\n\n**Planned but not completed:**\n- [if any, with reasons]\n\n**Observations:**\n- [patterns, friction, surprises]\n\n**Tomorrow's handoff:**\n- [brief note for morning brief]\n`,\n },\n ],\n },\n\n 'weekly-review': {\n name: 'weekly-review',\n description: 'End-of-week review workflow — analyze the week, compress journals, surface trends, and set goals for next week.',\n tags: ['weekly', 'review', 'retrospective', 'planning'],\n files: [\n {\n path: 'workflows/weekly-review.md',\n id: 'weekly-review',\n l0: 'Weekly review workflow that analyzes the week and sets goals.',\n content: `---\nid: weekly-review\ntags: [workflow, weekly, review, retrospective]\nauthor: infrastructure\nstatus: active\nschedule: \"0 17 * * 5\"\n---\n# Weekly Review\n\nAnalyze the past week's work, compress journals, and plan next week.\n\n## Instructions\n\n1. Load all journal entries from this week (Monday through today).\n2. Identify the top 3-5 themes across the week's work.\n3. Note which instincts fired most often and whether they were helpful.\n4. Identify any skills or playbooks that were missing or underperforming.\n5. Suggest concrete goals for next week (2-3 maximum).\n6. Flag any rules that seem outdated or contradictory.\n\n## Output Format\n\n**Week of [date range]**\n\n**Key themes:**\n1. [theme with brief explanation]\n2. [theme]\n3. [theme]\n\n**Instinct effectiveness:**\n- [instinct name]: [helpful / needs tuning / remove]\n\n**Gaps identified:**\n- [missing skill or playbook suggestion]\n\n**Next week's goals:**\n1. [specific, actionable goal]\n2. [goal]\n\n**Maintenance notes:**\n- [rules to review, primitives to archive, etc.]\n`,\n },\n ],\n },\n\n 'code-review': {\n name: 'code-review',\n description: 'Code review workflow — analyzes recent code changes, checks for patterns and anti-patterns, and generates review notes.',\n tags: ['code-review', 'development', 'quality'],\n files: [\n {\n path: 'workflows/code-review.md',\n id: 'code-review-workflow',\n l0: 'Code review workflow that analyzes recent changes and generates review notes.',\n content: `---\nid: code-review-workflow\ntags: [workflow, code-review, development]\nauthor: infrastructure\nstatus: active\n---\n# Code Review Workflow\n\nAnalyze recent code changes and generate structured review notes.\n\n## Instructions\n\n1. Review the most recent session where code was written or modified.\n2. Check for common issues:\n - Missing error handling (empty catches, unhandled promises)\n - Type safety violations (any usage, missing return types)\n - Security concerns (unsanitized input, hardcoded secrets)\n - Code duplication or missed reuse opportunities\n3. Check adherence to project rules and instincts.\n4. Note positive patterns worth reinforcing as instincts.\n5. Generate a structured review with severity levels.\n\n## Output Format\n\n**Review of [session/change description]**\n\n**Critical issues:**\n- [severity: high] [description]\n\n**Improvements:**\n- [severity: medium] [suggestion]\n\n**Good patterns:**\n- [pattern worth keeping / promoting to instinct]\n\n**Summary:**\n[1-2 sentence overall assessment]\n`,\n },\n {\n path: 'workflows/pr-checklist.md',\n id: 'pr-checklist',\n l0: 'PR checklist workflow that generates a pre-merge review checklist.',\n content: `---\nid: pr-checklist\ntags: [workflow, code-review, pr, checklist]\nauthor: infrastructure\nstatus: active\n---\n# PR Checklist\n\nGenerate a pre-merge checklist based on project rules and recent changes.\n\n## Instructions\n\n1. Load all active rules from the harness.\n2. For each rule category, generate a checklist item.\n3. Add standard items: tests pass, no type errors, no lint warnings.\n4. Include project-specific checks based on instincts.\n5. Output as a copy-pasteable markdown checklist.\n\n## Output Format\n\n**Pre-merge checklist:**\n\n- [ ] All tests pass\n- [ ] No TypeScript errors (tsc --noEmit)\n- [ ] No lint warnings\n- [ ] Error handling: no empty catches, async errors handled\n- [ ] Types: no \\`any\\`, explicit return types on exports\n- [ ] Security: no hardcoded secrets, input validated\n- [rule-specific items from harness rules]\n`,\n },\n ],\n },\n\n 'code-reviewer': {\n name: 'code-reviewer',\n description: 'Multi-primitive code review pack — rules for code quality, instincts for review patterns, and a skill for structured review technique.',\n tags: ['code-review', 'quality', 'rules', 'instincts', 'skills'],\n files: [\n {\n path: 'rules/code-quality.md',\n id: 'code-quality-rules',\n l0: 'Code quality rules enforcing error handling, type safety, and security.',\n content: `---\nid: code-quality-rules\ntags: [rule, code-quality, error-handling, type-safety, security]\nauthor: infrastructure\nstatus: active\n---\n# Code Quality Rules\n\nEnforceable rules for maintaining code quality across the codebase.\n\n## Error Handling\n\n- **Never** leave a catch block empty. Every catch must log or handle the error meaningfully.\n- **Always** handle async errors — every async function must have error handling at its boundary.\n- **Never** use generic \\`catch (e) { throw e }\\` — either handle or let it propagate naturally.\n\n## Type Safety\n\n- **Never** use \\`any\\` — use \\`unknown\\` with type narrowing, generics, or explicit types.\n- **Always** add explicit return types on exported functions.\n- **Never** trust external data at runtime — validate at system boundaries.\n\n## Security\n\n- **Never** hardcode secrets, API keys, or tokens in source code.\n- **Always** parameterize database queries — never concatenate user input.\n- **Never** use \\`eval()\\`, \\`innerHTML\\`, or \\`document.write()\\` with unsanitized input.\n- **Always** validate and sanitize user input at the boundary where it enters the system.\n\n## Structure\n\n- **Prefer** early returns and guard clauses — happy path last.\n- **Never** create a new utility function without first searching for an existing one.\n- **Always** prefer editing existing files over creating new ones.\n`,\n },\n {\n path: 'rules/review-standards.md',\n id: 'review-standards',\n l0: 'Review standards for consistent, actionable code review feedback.',\n content: `---\nid: review-standards\ntags: [rule, code-review, standards, feedback]\nauthor: infrastructure\nstatus: active\n---\n# Review Standards\n\nStandards for producing consistent, actionable code review feedback.\n\n## Severity Levels\n\n- **Critical**: Security vulnerability, data loss risk, or crash. Must fix before merge.\n- **High**: Logic error, missing error handling, or broken contract. Should fix before merge.\n- **Medium**: Code smell, duplication, or missed optimization. Fix soon.\n- **Low**: Style preference, naming suggestion, or minor improvement. Optional.\n\n## Review Checklist\n\n- Every review must note at least one positive pattern (reinforcement).\n- Every issue must include a suggested fix, not just a complaint.\n- Reviews should reference specific rules or instincts when applicable.\n- Avoid vague feedback like \"this could be better\" — be specific and actionable.\n\n## Scope\n\n- Review only what changed — do not nitpick unrelated code.\n- Flag pre-existing issues separately from new issues.\n- If a change is too large to review effectively, request it be split.\n`,\n },\n {\n path: 'instincts/review-pattern-detection.md',\n id: 'review-pattern-detection',\n l0: 'Instinct for detecting common code review patterns and anti-patterns.',\n content: `---\nid: review-pattern-detection\ntags: [instinct, code-review, patterns, anti-patterns]\nauthor: infrastructure\nstatus: active\n---\n# Review Pattern Detection\n\nBehavioral instinct for recognizing patterns during code review.\n\n## Trigger\n\nWhen reviewing code changes or analyzing session output that includes code modifications.\n\n## Patterns to Watch For\n\n- **Copy-paste duplication**: Same logic appearing in multiple places — suggest extraction.\n- **Error swallowing**: Catch blocks that log but don't re-throw or handle — flag as silent failure.\n- **Missing edge cases**: Functions that handle the happy path but not nulls, empty arrays, or errors.\n- **Leaky abstractions**: Implementation details exposed through public interfaces.\n- **Premature optimization**: Complex code with no measured performance need.\n- **Magic values**: Hardcoded numbers or strings that should be named constants.\n\n## Response\n\nWhen a pattern is detected, note it in the review with the pattern name and a brief explanation. Suggest the specific fix, not just the problem.\n`,\n },\n {\n path: 'instincts/refactor-opportunity.md',\n id: 'refactor-opportunity',\n l0: 'Instinct for spotting refactoring opportunities during review.',\n content: `---\nid: refactor-opportunity\ntags: [instinct, refactoring, code-review, improvement]\nauthor: infrastructure\nstatus: active\n---\n# Refactor Opportunity Detection\n\nBehavioral instinct for identifying refactoring opportunities.\n\n## Trigger\n\nWhen code changes reveal structural issues or when the same area is modified repeatedly.\n\n## Signals\n\n- **Shotgun surgery**: A single logical change requires touching 3+ files — extract shared logic.\n- **Feature envy**: A function that mostly uses data from another module — move it.\n- **Long parameter lists**: Functions with 4+ parameters — consider an options object.\n- **Nested conditionals**: 3+ levels of nesting — extract early returns or helper functions.\n- **God objects**: Classes or modules with 10+ responsibilities — split by concern.\n\n## Response\n\nNote the refactoring opportunity with the specific smell name. Only suggest refactoring if it improves clarity — not every code smell needs immediate action.\n`,\n },\n {\n path: 'skills/structured-review.md',\n id: 'structured-review-skill',\n l0: 'Skill for conducting structured, multi-pass code reviews.',\n content: `---\nid: structured-review-skill\ntags: [skill, code-review, technique, methodology]\nauthor: infrastructure\nstatus: active\n---\n# Structured Code Review\n\nA systematic approach to reviewing code changes in multiple passes.\n\n## Technique: Three-Pass Review\n\n### Pass 1: Correctness (5 minutes)\n- Does the code do what the author intended?\n- Are there logic errors, off-by-one issues, or race conditions?\n- Do all error paths terminate correctly?\n\n### Pass 2: Quality (3 minutes)\n- Does it follow project rules and coding standards?\n- Are there opportunities for reuse or simplification?\n- Is the code testable? Are there missing tests?\n\n### Pass 3: Design (2 minutes)\n- Does the change fit the existing architecture?\n- Are the abstractions at the right level?\n- Will this be easy to modify in the future?\n\n## Output Template\n\n\\`\\`\\`\n**Correctness**: [pass/issues found]\n**Quality**: [pass/improvements suggested]\n**Design**: [pass/concerns noted]\n**Verdict**: [approve / request changes / discuss]\n\\`\\`\\`\n\n## Tips\n\n- Time-box each pass to avoid rabbit holes.\n- Record the first pass findings before moving to the next — fresh eyes find different things.\n- If you find a critical issue in pass 1, stop and report it immediately.\n`,\n },\n ],\n },\n\n 'personal-assistant': {\n name: 'personal-assistant',\n description: 'Personal assistant pack — daily planning workflow, communication instincts, and a task management skill for organizing priorities.',\n tags: ['productivity', 'planning', 'communication', 'task-management'],\n files: [\n {\n path: 'workflows/daily-planner.md',\n id: 'daily-planner',\n l0: 'Daily planning workflow that organizes priorities and schedules tasks.',\n content: `---\nid: daily-planner\ntags: [workflow, daily, planning, productivity]\nauthor: infrastructure\nstatus: active\nschedule: \"0 7 * * 1-5\"\n---\n# Daily Planner\n\nCreate a structured daily plan from open tasks, calendar items, and recent context.\n\n## Instructions\n\n1. Load the most recent journal entry and state.md.\n2. Identify all open tasks from \\`unfinished_business\\` in state.\n3. Check for any scheduled workflows firing today.\n4. Categorize tasks by urgency and importance (Eisenhower matrix).\n5. Produce a time-blocked plan for the day.\n6. Estimate total focus hours needed vs. available.\n\n## Output Format\n\n**Date: [today]**\n\n**Must do today (urgent + important):**\n1. [task with estimated time]\n\n**Should do today (important, not urgent):**\n1. [task]\n\n**Quick wins (< 15 min):**\n- [task]\n\n**Scheduled:**\n- [time] [event or workflow]\n\n**Focus hours needed:** [N] / **Available:** [M]\n`,\n },\n {\n path: 'workflows/inbox-triage.md',\n id: 'inbox-triage',\n l0: 'Inbox triage workflow that processes and categorizes incoming items.',\n content: `---\nid: inbox-triage\ntags: [workflow, triage, inbox, productivity]\nauthor: infrastructure\nstatus: active\nproactive: true\n---\n# Inbox Triage\n\nProcess incoming items and categorize them for action.\n\n## Instructions\n\n1. Scan recent sessions and events for unprocessed items.\n2. For each item, determine:\n - **Action required?** Yes/No\n - **Urgency:** Now / Today / This week / Someday\n - **Category:** Task / Question / Reference / Noise\n3. Items requiring action go to state.md unfinished_business.\n4. Questions get queued for the next interactive session.\n5. Reference items get filed as session notes.\n6. Noise gets acknowledged and dropped.\n\n## Output Format\n\n**Processed [N] items:**\n\n| Item | Action | Urgency | Category |\n|------|--------|---------|----------|\n| [description] | [yes/no] | [urgency] | [category] |\n\n**Added to queue:** [count]\n**Filed as reference:** [count]\n**Dropped:** [count]\n`,\n },\n {\n path: 'instincts/clear-communication.md',\n id: 'clear-communication',\n l0: 'Instinct for clear, concise communication in responses.',\n content: `---\nid: clear-communication\ntags: [instinct, communication, clarity, writing]\nauthor: infrastructure\nstatus: active\n---\n# Clear Communication\n\nBehavioral instinct for producing clear, actionable communication.\n\n## Trigger\n\nWhen generating any output that will be read by a human — responses, summaries, reports, plans.\n\n## Principles\n\n- **Lead with the answer.** State the conclusion first, then provide supporting detail.\n- **Be specific.** Replace \"soon\" with dates, \"some\" with counts, \"improve\" with metrics.\n- **One idea per paragraph.** Dense paragraphs with multiple ideas are hard to scan.\n- **Use structure.** Headers, lists, and tables are faster to process than prose.\n- **Cut filler.** Remove \"I think\", \"basically\", \"in order to\", \"it should be noted that\".\n\n## Anti-patterns\n\n- Restating the question before answering it.\n- Using jargon without context.\n- Providing information the reader didn't ask for.\n- Hedging when confidence is high.\n\n## Response\n\nApply these principles automatically. If a draft is unclear, restructure before outputting.\n`,\n },\n {\n path: 'instincts/context-awareness.md',\n id: 'context-awareness',\n l0: 'Instinct for maintaining awareness of user context and recent history.',\n content: `---\nid: context-awareness\ntags: [instinct, context, memory, personalization]\nauthor: infrastructure\nstatus: active\n---\n# Context Awareness\n\nBehavioral instinct for maintaining awareness of what the user is working on.\n\n## Trigger\n\nAt the start of every session and when switching topics.\n\n## Behavior\n\n- Check state.md for current goals and active workflows before responding.\n- Reference recent session history when it adds value (not gratuitously).\n- Notice when the user returns to a topic from a previous session — offer continuity.\n- Track which tools, files, and topics appear frequently — these are the user's active context.\n- When the user's request is ambiguous, use recent context to disambiguate rather than asking.\n\n## Anti-patterns\n\n- Treating every session as a fresh start with no history.\n- Asking questions that were already answered in a recent session.\n- Ignoring state.md goals when prioritizing tasks.\n`,\n },\n {\n path: 'skills/task-prioritization.md',\n id: 'task-prioritization-skill',\n l0: 'Skill for prioritizing tasks using the Eisenhower matrix and energy mapping.',\n content: `---\nid: task-prioritization-skill\ntags: [skill, productivity, prioritization, planning]\nauthor: infrastructure\nstatus: active\n---\n# Task Prioritization\n\nSystematic approach to prioritizing tasks when everything feels urgent.\n\n## Technique: Eisenhower + Energy Mapping\n\n### Step 1: Classify by Urgency and Importance\n\n| | Urgent | Not Urgent |\n|---|--------|------------|\n| **Important** | Do first | Schedule |\n| **Not Important** | Delegate/batch | Drop or defer |\n\n### Step 2: Map to Energy Levels\n\n- **High energy tasks** (creative, complex decisions): Morning block\n- **Medium energy tasks** (meetings, reviews): Midday\n- **Low energy tasks** (admin, filing, routine): Late afternoon\n\n### Step 3: Apply Constraints\n\n- Maximum 3 \"must do\" items per day — more than 3 means nothing is truly prioritized.\n- If everything is urgent, ask: \"What happens if this waits 24 hours?\" If the answer is \"nothing\", it's not urgent.\n- Group similar tasks to reduce context-switching cost.\n\n## Output\n\nProduce a prioritized list with:\n1. Task name\n2. Quadrant (urgent-important, important, urgent, neither)\n3. Estimated time\n4. Suggested time block (morning/midday/afternoon)\n`,\n },\n ],\n },\n\n 'devops': {\n name: 'devops',\n description: 'DevOps safety pack — deployment rules, monitoring instincts, and an incident response skill for handling production issues.',\n tags: ['devops', 'deployment', 'monitoring', 'incident-response', 'safety'],\n files: [\n {\n path: 'rules/deployment-safety.md',\n id: 'deployment-safety-rules',\n l0: 'Deployment safety rules preventing common production failures.',\n content: `---\nid: deployment-safety-rules\ntags: [rule, devops, deployment, safety, production]\nauthor: infrastructure\nstatus: active\n---\n# Deployment Safety Rules\n\nRules to prevent common deployment failures and production incidents.\n\n## Pre-Deployment\n\n- **Never** deploy without all tests passing — no exceptions, no \"just this once\".\n- **Never** deploy directly to production — always go through staging first.\n- **Always** review the diff before deploying — automated deployments must still be human-approved.\n- **Never** deploy on Fridays after 2 PM or before holidays without explicit approval.\n- **Always** have a rollback plan before deploying — know the exact command to revert.\n\n## During Deployment\n\n- **Always** deploy incrementally — canary or blue-green, never all-at-once.\n- **Never** deploy multiple unrelated changes in a single deployment.\n- **Always** monitor error rates for 15 minutes after deployment — do not walk away.\n\n## Secrets and Config\n\n- **Never** hardcode environment-specific values — use environment variables or config maps.\n- **Never** commit secrets to version control — use secret management tools.\n- **Always** rotate credentials after any suspected exposure — assume compromise.\n\n## Database\n\n- **Never** run destructive migrations without a backup taken in the last hour.\n- **Always** test migrations on a copy of production data before running on production.\n- **Never** drop columns or tables without confirming zero references in running code.\n`,\n },\n {\n path: 'rules/infrastructure-standards.md',\n id: 'infrastructure-standards',\n l0: 'Infrastructure standards for consistent, maintainable deployments.',\n content: `---\nid: infrastructure-standards\ntags: [rule, devops, infrastructure, standards]\nauthor: infrastructure\nstatus: active\n---\n# Infrastructure Standards\n\nStandards for maintaining consistent, auditable infrastructure.\n\n## Configuration\n\n- All infrastructure must be defined as code (Terraform, Pulumi, CloudFormation, or similar).\n- Manual changes to production infrastructure require a follow-up PR within 24 hours.\n- Every service must have health check endpoints (/health, /ready).\n- Every service must emit structured logs (JSON) with request IDs for tracing.\n\n## Monitoring\n\n- Every service must have alerts for: error rate > 1%, latency p99 > 2s, availability < 99.9%.\n- Alerts must page on-call for critical issues — never rely on email-only alerts.\n- Dashboard must show: request rate, error rate, latency percentiles, resource utilization.\n\n## Access Control\n\n- Production access requires MFA and is logged.\n- Prefer role-based access over individual permissions.\n- Review access lists quarterly — remove unused permissions.\n\n## Backups\n\n- All persistent data must be backed up daily with 30-day retention.\n- Test backup restoration quarterly — untested backups are not backups.\n`,\n },\n {\n path: 'instincts/anomaly-detection.md',\n id: 'anomaly-detection',\n l0: 'Instinct for detecting anomalies in metrics, logs, and deployment behavior.',\n content: `---\nid: anomaly-detection\ntags: [instinct, devops, monitoring, anomaly, alerting]\nauthor: infrastructure\nstatus: active\n---\n# Anomaly Detection\n\nBehavioral instinct for noticing when something is off in operational metrics.\n\n## Trigger\n\nWhen reviewing deployment output, log summaries, or metric dashboards.\n\n## Signals\n\n- **Error rate spike**: Any increase > 2x baseline within 5 minutes of a deployment.\n- **Latency creep**: p99 latency increasing steadily over hours — memory leak or connection exhaustion.\n- **Silent failures**: Success rate stays high but throughput drops — upstream is failing to send.\n- **Resource divergence**: CPU/memory usage differs significantly between replicas — one is stuck.\n- **Clock skew**: Timestamps in logs jumping backward or forward — NTP issues.\n- **Cascade pattern**: Multiple unrelated services degrading simultaneously — shared dependency.\n\n## Response\n\nWhen an anomaly is detected:\n1. Note the specific metric and timeframe.\n2. Correlate with recent deployments or config changes.\n3. If post-deployment: recommend immediate rollback, investigate after.\n4. If no recent change: check upstream dependencies and shared infrastructure.\n`,\n },\n {\n path: 'instincts/change-risk-assessment.md',\n id: 'change-risk-assessment',\n l0: 'Instinct for assessing risk before infrastructure or deployment changes.',\n content: `---\nid: change-risk-assessment\ntags: [instinct, devops, risk, change-management]\nauthor: infrastructure\nstatus: active\n---\n# Change Risk Assessment\n\nBehavioral instinct for evaluating the risk of operational changes before executing them.\n\n## Trigger\n\nBefore any deployment, configuration change, or infrastructure modification.\n\n## Risk Factors\n\n- **Blast radius**: How many users or services are affected if this fails?\n- **Reversibility**: Can this be rolled back in under 5 minutes?\n- **Observability**: Will we know if this breaks something? Are there alerts?\n- **Timing**: Is this during peak traffic? During on-call handoff?\n- **Novelty**: Has this type of change been done before? By this team?\n- **Dependencies**: Does this change require coordinated changes in other services?\n\n## Risk Levels\n\n- **Low**: Small blast radius, instantly reversible, well-observed, done before.\n- **Medium**: Moderate blast radius, reversible with effort, some unknowns.\n- **High**: Large blast radius, difficult to reverse, novel, or during peak.\n\n## Response\n\nState the risk level and the primary risk factor before proceeding. For high-risk changes, suggest breaking the change into smaller, lower-risk steps.\n`,\n },\n {\n path: 'skills/incident-response.md',\n id: 'incident-response-skill',\n l0: 'Skill for structured incident response and post-incident analysis.',\n content: `---\nid: incident-response-skill\ntags: [skill, devops, incident-response, runbook]\nauthor: infrastructure\nstatus: active\n---\n# Incident Response\n\nStructured approach to handling production incidents.\n\n## Phase 1: Detect and Assess (0-5 minutes)\n\n1. **Confirm the incident**: Verify the alert is real, not a false positive.\n2. **Assess impact**: How many users affected? Is data at risk?\n3. **Classify severity**:\n - **SEV1**: Service down, data loss, or security breach. Page everyone.\n - **SEV2**: Significant degradation, partial outage. Page on-call.\n - **SEV3**: Minor degradation, workaround available. Notify team.\n4. **Communicate**: Post in incident channel with: what's happening, who's investigating, ETA for update.\n\n## Phase 2: Mitigate (5-30 minutes)\n\n1. **Check recent changes**: Was anything deployed in the last 2 hours? Roll it back.\n2. **Check dependencies**: Are upstream services healthy?\n3. **Scale or redirect**: Can traffic be shifted to healthy instances?\n4. **Apply known fix**: Check runbooks for this failure mode.\n5. **Update communication** every 15 minutes, even if no progress.\n\n## Phase 3: Resolve and Recover\n\n1. **Confirm resolution**: Metrics return to baseline for 15+ minutes.\n2. **Communicate all-clear** with summary of what happened.\n3. **Schedule post-mortem** within 48 hours.\n\n## Phase 4: Post-Mortem Template\n\n\\`\\`\\`\n**Incident**: [title]\n**Date**: [date] | **Duration**: [time]\n**Severity**: [SEV1/2/3]\n**Impact**: [users/services affected]\n\n**Timeline:**\n- [HH:MM] Alert fired\n- [HH:MM] Investigation started\n- [HH:MM] Root cause identified\n- [HH:MM] Fix applied\n- [HH:MM] Confirmed resolved\n\n**Root cause:** [description]\n**Contributing factors:** [list]\n**Action items:**\n- [ ] [preventive measure with owner and due date]\n\\`\\`\\`\n`,\n },\n ],\n },\n};\n\n/**\n * Get a builtin starter pack by name.\n * Returns null if the pack doesn't exist.\n */\nexport function getStarterPack(name: string): PackedBundle | null {\n const pack = PACKS[name];\n if (!pack) return null;\n\n const now = new Date().toISOString();\n const fileEntries: BundleFileEntry[] = pack.files.map(f => ({\n path: f.path,\n type: f.path.split('/')[0],\n id: f.id,\n l0: f.l0,\n }));\n\n const manifest: BundleManifest = {\n version: '1',\n name: `pack:${pack.name}`,\n description: pack.description,\n author: 'agent-harness',\n bundle_version: '1.0.0',\n created: now,\n types: [...new Set(fileEntries.map(f => f.type))],\n tags: pack.tags,\n files: fileEntries,\n };\n\n return {\n manifest,\n files: pack.files.map(f => ({ path: f.path, content: f.content })),\n };\n}\n\n/**\n * List all available builtin starter packs.\n */\nexport function listStarterPacks(): Array<{ name: string; description: string; fileCount: number; tags: string[] }> {\n return Object.values(PACKS).map(p => ({\n name: p.name,\n description: p.description,\n fileCount: p.files.length,\n tags: p.tags,\n }));\n}\n\n/**\n * Check if a source string is a pack reference (starts with \"pack:\").\n */\nexport function isPackReference(source: string): boolean {\n return source.startsWith('pack:');\n}\n\n/**\n * Parse the pack name from a \"pack:<name>\" reference.\n */\nexport function parsePackName(source: string): string {\n return source.slice(5); // Remove \"pack:\" prefix\n}\n"],"mappings":";;;;;AAiBA,IAAM,QAAqC;AAAA,EACzC,gBAAgB;AAAA,IACd,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM,CAAC,SAAS,YAAY,UAAU,cAAc;AAAA,IACpD,OAAO;AAAA,MACL;AAAA,QACE,MAAM;AAAA,QACN,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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ACvD,SAAO,OAAO,WAAW,OAAO;AAClC;AAKO,SAAS,cAAc,QAAwB;AACpD,SAAO,OAAO,MAAM,CAAC;AACvB;","names":[]}
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ loadState,
5
+ saveState
6
+ } from "./chunk-UDZIS2AQ.js";
7
+ import "./chunk-Z2PUCXTZ.js";
8
+ import "./chunk-ZZJOFKAT.js";
9
+ export {
10
+ loadState,
11
+ saveState
12
+ };
13
+ //# sourceMappingURL=state-GMXILIHW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,174 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ loadState,
5
+ saveState
6
+ } from "./chunk-UDZIS2AQ.js";
7
+ import {
8
+ withFileLockSync
9
+ } from "./chunk-Z2PUCXTZ.js";
10
+ import "./chunk-ZZJOFKAT.js";
11
+
12
+ // src/runtime/state-merge.ts
13
+ import { readFileSync, writeFileSync, existsSync } from "fs";
14
+ import { join } from "path";
15
+ var DEFAULT_OWNERSHIP = {
16
+ mode: "agent",
17
+ goals: "human",
18
+ active_workflows: "agent",
19
+ last_interaction: "infrastructure",
20
+ unfinished_business: "agent"
21
+ };
22
+ var OWNERSHIP_FILE = "state-ownership.json";
23
+ function loadOwnership(harnessDir) {
24
+ const ownershipPath = join(harnessDir, "memory", OWNERSHIP_FILE);
25
+ if (!existsSync(ownershipPath)) {
26
+ return { ...DEFAULT_OWNERSHIP };
27
+ }
28
+ try {
29
+ const raw = readFileSync(ownershipPath, "utf-8");
30
+ const parsed = JSON.parse(raw);
31
+ return { ...DEFAULT_OWNERSHIP, ...parsed };
32
+ } catch {
33
+ return { ...DEFAULT_OWNERSHIP };
34
+ }
35
+ }
36
+ function saveOwnership(harnessDir, ownership) {
37
+ const memoryDir = join(harnessDir, "memory");
38
+ const ownershipPath = join(memoryDir, OWNERSHIP_FILE);
39
+ withFileLockSync(harnessDir, ownershipPath, () => {
40
+ writeFileSync(ownershipPath, JSON.stringify(ownership, null, 2), "utf-8");
41
+ });
42
+ }
43
+ function mergeState(harnessDir, change, strategy = "human-wins") {
44
+ const currentState = loadState(harnessDir);
45
+ const ownership = loadOwnership(harnessDir);
46
+ const conflicts = [];
47
+ const mergedState = { ...currentState };
48
+ const mergedOwnership = { ...ownership };
49
+ const fields = Object.keys(change.changes);
50
+ for (const field of fields) {
51
+ const newValue = change.changes[field];
52
+ if (newValue === void 0) continue;
53
+ const currentOwner = ownership[field];
54
+ const changeAuthor = change.author;
55
+ if (currentOwner === changeAuthor) {
56
+ applyField(mergedState, field, newValue);
57
+ continue;
58
+ }
59
+ const currentValue = currentState[field];
60
+ if (valuesEqual(currentValue, newValue)) {
61
+ continue;
62
+ }
63
+ const resolved = resolveConflict(
64
+ field,
65
+ currentValue,
66
+ newValue,
67
+ currentOwner,
68
+ changeAuthor,
69
+ strategy
70
+ );
71
+ conflicts.push({
72
+ field,
73
+ humanValue: currentOwner === "human" ? currentValue : newValue,
74
+ agentValue: currentOwner === "agent" ? currentValue : newValue,
75
+ resolvedTo: resolved.winner,
76
+ resolvedValue: resolved.value
77
+ });
78
+ applyField(mergedState, field, resolved.value);
79
+ mergedOwnership[field] = resolved.winner;
80
+ }
81
+ for (const field of fields) {
82
+ if (!conflicts.some((c) => c.field === field)) {
83
+ mergedOwnership[field] = change.author;
84
+ }
85
+ }
86
+ mergedState.last_interaction = change.timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
87
+ mergedOwnership.last_interaction = "infrastructure";
88
+ saveState(harnessDir, mergedState);
89
+ saveOwnership(harnessDir, mergedOwnership);
90
+ return {
91
+ state: mergedState,
92
+ ownership: mergedOwnership,
93
+ conflicts,
94
+ hadConflicts: conflicts.length > 0
95
+ };
96
+ }
97
+ function applyStateChange(harnessDir, changes) {
98
+ const currentState = loadState(harnessDir);
99
+ const mergedState = { ...currentState };
100
+ for (const [key, value] of Object.entries(changes)) {
101
+ if (value !== void 0) {
102
+ applyField(mergedState, key, value);
103
+ }
104
+ }
105
+ saveState(harnessDir, mergedState);
106
+ return mergedState;
107
+ }
108
+ function resolveConflict(field, currentValue, newValue, currentOwner, changeAuthor, strategy) {
109
+ switch (strategy) {
110
+ case "human-wins":
111
+ if (currentOwner === "human") {
112
+ return { value: currentValue, winner: "human" };
113
+ }
114
+ if (changeAuthor === "human") {
115
+ return { value: newValue, winner: "human" };
116
+ }
117
+ return { value: newValue, winner: changeAuthor };
118
+ case "agent-wins":
119
+ if (currentOwner === "agent") {
120
+ return { value: currentValue, winner: "agent" };
121
+ }
122
+ if (changeAuthor === "agent") {
123
+ return { value: newValue, winner: "agent" };
124
+ }
125
+ return { value: newValue, winner: changeAuthor };
126
+ case "latest-wins":
127
+ return { value: newValue, winner: changeAuthor };
128
+ case "union":
129
+ if (isArrayField(field) && Array.isArray(currentValue) && Array.isArray(newValue)) {
130
+ const union = [.../* @__PURE__ */ new Set([...currentValue, ...newValue])];
131
+ return { value: union, winner: changeAuthor };
132
+ }
133
+ return { value: newValue, winner: changeAuthor };
134
+ default:
135
+ return { value: newValue, winner: changeAuthor };
136
+ }
137
+ }
138
+ function isArrayField(field) {
139
+ return field === "goals" || field === "active_workflows" || field === "unfinished_business";
140
+ }
141
+ function applyField(state, field, value) {
142
+ switch (field) {
143
+ case "mode":
144
+ state.mode = value;
145
+ break;
146
+ case "goals":
147
+ state.goals = value;
148
+ break;
149
+ case "active_workflows":
150
+ state.active_workflows = value;
151
+ break;
152
+ case "last_interaction":
153
+ state.last_interaction = value;
154
+ break;
155
+ case "unfinished_business":
156
+ state.unfinished_business = value;
157
+ break;
158
+ }
159
+ }
160
+ function valuesEqual(a, b) {
161
+ if (a === b) return true;
162
+ if (Array.isArray(a) && Array.isArray(b)) {
163
+ if (a.length !== b.length) return false;
164
+ return a.every((v, i) => v === b[i]);
165
+ }
166
+ return JSON.stringify(a) === JSON.stringify(b);
167
+ }
168
+ export {
169
+ applyStateChange,
170
+ loadOwnership,
171
+ mergeState,
172
+ saveOwnership
173
+ };
174
+ //# sourceMappingURL=state-merge-NKO5FRBA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runtime/state-merge.ts"],"sourcesContent":["import { readFileSync, writeFileSync, existsSync } from 'fs';\nimport { join } from 'path';\nimport type { AgentState } from '../core/types.js';\nimport { loadState, saveState } from './state.js';\nimport { withFileLockSync } from './file-lock.js';\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\nexport type StateOwner = 'human' | 'agent' | 'infrastructure';\n\n/** Tracks which entity last modified each field of the state. */\nexport interface StateOwnership {\n mode: StateOwner;\n goals: StateOwner;\n active_workflows: StateOwner;\n last_interaction: StateOwner;\n unfinished_business: StateOwner;\n}\n\n/** A state change with ownership metadata. */\nexport interface OwnedStateChange {\n /** Who is making this change */\n author: StateOwner;\n /** Partial state to merge — only provided fields are updated */\n changes: Partial<AgentState>;\n /** Timestamp of the change (ISO string) */\n timestamp?: string;\n}\n\n/** Strategy for resolving conflicting state changes. */\nexport type MergeStrategy = 'human-wins' | 'agent-wins' | 'latest-wins' | 'union';\n\nexport interface MergeResult {\n /** The merged state */\n state: AgentState;\n /** Updated ownership */\n ownership: StateOwnership;\n /** Fields that had conflicts */\n conflicts: StateConflict[];\n /** Whether any conflicts were resolved */\n hadConflicts: boolean;\n}\n\nexport interface StateConflict {\n field: keyof AgentState;\n humanValue: unknown;\n agentValue: unknown;\n resolvedTo: StateOwner;\n resolvedValue: unknown;\n}\n\n// ─── Ownership Tracking ─────────────────────────────────────────────────────\n\nconst DEFAULT_OWNERSHIP: StateOwnership = {\n mode: 'agent',\n goals: 'human',\n active_workflows: 'agent',\n last_interaction: 'infrastructure',\n unfinished_business: 'agent',\n};\n\nconst OWNERSHIP_FILE = 'state-ownership.json';\n\n/** Load ownership metadata from the harness directory. */\nexport function loadOwnership(harnessDir: string): StateOwnership {\n const ownershipPath = join(harnessDir, 'memory', OWNERSHIP_FILE);\n if (!existsSync(ownershipPath)) {\n return { ...DEFAULT_OWNERSHIP };\n }\n\n try {\n const raw = readFileSync(ownershipPath, 'utf-8');\n const parsed = JSON.parse(raw) as Partial<StateOwnership>;\n return { ...DEFAULT_OWNERSHIP, ...parsed };\n } catch {\n return { ...DEFAULT_OWNERSHIP };\n }\n}\n\n/** Save ownership metadata to the harness directory. */\nexport function saveOwnership(harnessDir: string, ownership: StateOwnership): void {\n const memoryDir = join(harnessDir, 'memory');\n const ownershipPath = join(memoryDir, OWNERSHIP_FILE);\n withFileLockSync(harnessDir, ownershipPath, () => {\n writeFileSync(ownershipPath, JSON.stringify(ownership, null, 2), 'utf-8');\n });\n}\n\n// ─── Merge Logic ─────────────────────────────────────────────────────────────\n\n/**\n * Merge a state change into the current state, respecting ownership.\n *\n * Rules:\n * - `human-wins`: If a human-owned field is being changed by an agent, the human value is kept.\n * - `agent-wins`: If an agent-owned field is being changed by a human, the agent value is kept.\n * - `latest-wins`: The most recent change always wins (default).\n * - `union`: For array fields (goals, active_workflows, unfinished_business), merge by union.\n * For scalar fields, latest-wins.\n *\n * @param harnessDir - Harness directory path\n * @param change - The state change to apply\n * @param strategy - Merge strategy (default: 'human-wins')\n */\nexport function mergeState(\n harnessDir: string,\n change: OwnedStateChange,\n strategy: MergeStrategy = 'human-wins',\n): MergeResult {\n const currentState = loadState(harnessDir);\n const ownership = loadOwnership(harnessDir);\n const conflicts: StateConflict[] = [];\n\n const mergedState = { ...currentState };\n const mergedOwnership = { ...ownership };\n\n const fields = Object.keys(change.changes) as Array<keyof AgentState>;\n\n for (const field of fields) {\n const newValue = change.changes[field];\n if (newValue === undefined) continue;\n\n const currentOwner = ownership[field];\n const changeAuthor = change.author;\n\n // Same owner → no conflict, apply directly\n if (currentOwner === changeAuthor) {\n applyField(mergedState, field, newValue);\n continue;\n }\n\n // Different owner → potential conflict\n const currentValue = currentState[field];\n\n // Check if values actually differ\n if (valuesEqual(currentValue, newValue)) {\n continue; // No actual conflict\n }\n\n // Resolve conflict based on strategy\n const resolved = resolveConflict(\n field,\n currentValue,\n newValue,\n currentOwner,\n changeAuthor,\n strategy,\n );\n\n conflicts.push({\n field,\n humanValue: currentOwner === 'human' ? currentValue : newValue,\n agentValue: currentOwner === 'agent' ? currentValue : newValue,\n resolvedTo: resolved.winner,\n resolvedValue: resolved.value,\n });\n\n applyField(mergedState, field, resolved.value);\n mergedOwnership[field] = resolved.winner;\n }\n\n // Update ownership for non-conflicting changes\n for (const field of fields) {\n if (!conflicts.some((c) => c.field === field)) {\n mergedOwnership[field] = change.author;\n }\n }\n\n // Update last_interaction\n mergedState.last_interaction = change.timestamp ?? new Date().toISOString();\n mergedOwnership.last_interaction = 'infrastructure';\n\n // Persist\n saveState(harnessDir, mergedState);\n saveOwnership(harnessDir, mergedOwnership);\n\n return {\n state: mergedState,\n ownership: mergedOwnership,\n conflicts,\n hadConflicts: conflicts.length > 0,\n };\n}\n\n/**\n * Apply a state change without ownership — direct write.\n * Use this when ownership tracking is not needed.\n */\nexport function applyStateChange(\n harnessDir: string,\n changes: Partial<AgentState>,\n): AgentState {\n const currentState = loadState(harnessDir);\n const mergedState = { ...currentState };\n\n for (const [key, value] of Object.entries(changes)) {\n if (value !== undefined) {\n applyField(mergedState, key as keyof AgentState, value);\n }\n }\n\n saveState(harnessDir, mergedState);\n return mergedState;\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\nfunction resolveConflict(\n field: keyof AgentState,\n currentValue: unknown,\n newValue: unknown,\n currentOwner: StateOwner,\n changeAuthor: StateOwner,\n strategy: MergeStrategy,\n): { value: unknown; winner: StateOwner } {\n switch (strategy) {\n case 'human-wins':\n if (currentOwner === 'human') {\n return { value: currentValue, winner: 'human' };\n }\n if (changeAuthor === 'human') {\n return { value: newValue, winner: 'human' };\n }\n // Neither is human — latest wins\n return { value: newValue, winner: changeAuthor };\n\n case 'agent-wins':\n if (currentOwner === 'agent') {\n return { value: currentValue, winner: 'agent' };\n }\n if (changeAuthor === 'agent') {\n return { value: newValue, winner: 'agent' };\n }\n return { value: newValue, winner: changeAuthor };\n\n case 'latest-wins':\n return { value: newValue, winner: changeAuthor };\n\n case 'union':\n if (isArrayField(field) && Array.isArray(currentValue) && Array.isArray(newValue)) {\n const union = [...new Set([...currentValue, ...newValue])];\n return { value: union, winner: changeAuthor };\n }\n // Non-array fields: latest wins\n return { value: newValue, winner: changeAuthor };\n\n default:\n return { value: newValue, winner: changeAuthor };\n }\n}\n\nfunction isArrayField(field: keyof AgentState): boolean {\n return field === 'goals' || field === 'active_workflows' || field === 'unfinished_business';\n}\n\nfunction applyField(state: AgentState, field: keyof AgentState, value: unknown): void {\n switch (field) {\n case 'mode':\n state.mode = value as string;\n break;\n case 'goals':\n state.goals = value as string[];\n break;\n case 'active_workflows':\n state.active_workflows = value as string[];\n break;\n case 'last_interaction':\n state.last_interaction = value as string;\n break;\n case 'unfinished_business':\n state.unfinished_business = value as string[];\n break;\n }\n}\n\nfunction valuesEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true;\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) return false;\n return a.every((v, i) => v === b[i]);\n }\n return JSON.stringify(a) === JSON.stringify(b);\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,cAAc,eAAe,kBAAkB;AACxD,SAAS,YAAY;AAoDrB,IAAM,oBAAoC;AAAA,EACxC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,qBAAqB;AACvB;AAEA,IAAM,iBAAiB;AAGhB,SAAS,cAAc,YAAoC;AAChE,QAAM,gBAAgB,KAAK,YAAY,UAAU,cAAc;AAC/D,MAAI,CAAC,WAAW,aAAa,GAAG;AAC9B,WAAO,EAAE,GAAG,kBAAkB;AAAA,EAChC;AAEA,MAAI;AACF,UAAM,MAAM,aAAa,eAAe,OAAO;AAC/C,UAAM,SAAS,KAAK,MAAM,GAAG;AAC7B,WAAO,EAAE,GAAG,mBAAmB,GAAG,OAAO;AAAA,EAC3C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,KAAK,KAAK,MAAM,QAAQ,YAAY,KAAK,MAAM,QAAQ,QAAQ,GAAG;AACjF,cAAM,QAAQ,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,cAAc,GAAG,QAAQ,CAAC,CAAC;AACzD,eAAO,EAAE,OAAO,OAAO,QAAQ,aAAa;AAAA,MAC9C;AAEA,aAAO,EAAE,OAAO,UAAU,QAAQ,aAAa;AAAA,IAEjD;AACE,aAAO,EAAE,OAAO,UAAU,QAAQ,aAAa;AAAA,EACnD;AACF;AAEA,SAAS,aAAa,OAAkC;AACtD,SAAO,UAAU,WAAW,UAAU,sBAAsB,UAAU;AACxE;AAEA,SAAS,WAAW,OAAmB,OAAyB,OAAsB;AACpF,UAAQ,OAAO;AAAA,IACb,KAAK;AACH,YAAM,OAAO;AACb;AAAA,IACF,KAAK;AACH,YAAM,QAAQ;AACd;AAAA,IACF,KAAK;AACH,YAAM,mBAAmB;AACzB;AAAA,IACF,KAAK;AACH,YAAM,mBAAmB;AACzB;AAAA,IACF,KAAK;AACH,YAAM,sBAAsB;AAC5B;AAAA,EACJ;AACF;AAEA,SAAS,YAAY,GAAY,GAAqB;AACpD,MAAI,MAAM,EAAG,QAAO;AACpB,MAAI,MAAM,QAAQ,CAAC,KAAK,MAAM,QAAQ,CAAC,GAAG;AACxC,QAAI,EAAE,WAAW,EAAE,OAAQ,QAAO;AAClC,WAAO,EAAE,MAAM,CAAC,GAAG,MAAM,MAAM,EAAE,CAAC,CAAC;AAAA,EACrC;AACA,SAAO,KAAK,UAAU,CAAC,MAAM,KAAK,UAAU,CAAC;AAC/C;","names":[]}
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ collectSnapshot,
5
+ formatDashboard
6
+ } from "./chunk-A7BJPQQ6.js";
7
+ import "./chunk-6EMOEYGU.js";
8
+ import "./chunk-GNUSHD2Y.js";
9
+ import "./chunk-5H34JPMB.js";
10
+ import "./chunk-UDZIS2AQ.js";
11
+ import "./chunk-Z2PUCXTZ.js";
12
+ import "./chunk-TAT6JU3X.js";
13
+ import "./chunk-JKMGYWXB.js";
14
+ import "./chunk-BSKDOFRT.js";
15
+ import "./chunk-CHJ5GNZC.js";
16
+ import "./chunk-4CWAGBNS.js";
17
+ import "./chunk-ZZJOFKAT.js";
18
+ export {
19
+ collectSnapshot,
20
+ formatDashboard
21
+ };
22
+ //# sourceMappingURL=telemetry-UC6PBXC7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ buildAuthHeaders,
5
+ buildOperationSchema,
6
+ buildToolSet,
7
+ convertToolDefinition,
8
+ createToolCallTracker,
9
+ executeHttpOperation,
10
+ getToolSetSummary,
11
+ resolveEndpoint
12
+ } from "./chunk-DA7IKHC4.js";
13
+ import "./chunk-XTBKL5BI.js";
14
+ import "./chunk-UPLBF4RZ.js";
15
+ import "./chunk-BSKDOFRT.js";
16
+ import "./chunk-4CWAGBNS.js";
17
+ import "./chunk-ZZJOFKAT.js";
18
+ export {
19
+ buildAuthHeaders,
20
+ buildOperationSchema,
21
+ buildToolSet,
22
+ convertToolDefinition,
23
+ createToolCallTracker,
24
+ executeHttpOperation,
25
+ getToolSetSummary,
26
+ resolveEndpoint
27
+ };
28
+ //# sourceMappingURL=tool-executor-MJ7IG7PQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ checkToolAuth,
5
+ getToolById,
6
+ listToolSummaries,
7
+ loadTools,
8
+ parseToolDefinition
9
+ } from "./chunk-XTBKL5BI.js";
10
+ import "./chunk-UPLBF4RZ.js";
11
+ import "./chunk-4CWAGBNS.js";
12
+ import "./chunk-ZZJOFKAT.js";
13
+ export {
14
+ checkToolAuth,
15
+ getToolById,
16
+ listToolSummaries,
17
+ loadTools,
18
+ parseToolDefinition
19
+ };
20
+ //# sourceMappingURL=tools-DZ4KETET.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ CONFIG_DEFAULTS,
5
+ CORE_PRIMITIVE_DIRS,
6
+ FrontmatterSchema,
7
+ HarnessConfigSchema,
8
+ getPrimitiveDirs
9
+ } from "./chunk-4CWAGBNS.js";
10
+ import "./chunk-ZZJOFKAT.js";
11
+ export {
12
+ CONFIG_DEFAULTS,
13
+ CORE_PRIMITIVE_DIRS,
14
+ FrontmatterSchema,
15
+ HarnessConfigSchema,
16
+ getPrimitiveDirs
17
+ };
18
+ //# sourceMappingURL=types-EW7AIB3R.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,16 @@
1
+ import {
2
+ CONFIG_DEFAULTS,
3
+ CORE_PRIMITIVE_DIRS,
4
+ FrontmatterSchema,
5
+ HarnessConfigSchema,
6
+ getPrimitiveDirs
7
+ } from "./chunk-KFX54TQM.js";
8
+ import "./chunk-DGUM43GV.js";
9
+ export {
10
+ CONFIG_DEFAULTS,
11
+ CORE_PRIMITIVE_DIRS,
12
+ FrontmatterSchema,
13
+ HarnessConfigSchema,
14
+ getPrimitiveDirs
15
+ };
16
+ //# sourceMappingURL=types-WGDLSPO6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}