@plainconceptsplatform/agent-harness 3.2.0 → 3.3.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 (141) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +454 -452
  3. package/cli/commands/join.js +259 -259
  4. package/cli/commands/migrate.js +310 -310
  5. package/cli/commands/shared.js +27 -27
  6. package/cli/commands/single.js +79 -79
  7. package/cli/commands/update.js +121 -121
  8. package/cli/commands/wizard.js +134 -134
  9. package/cli/fragments/archive/az.md +97 -97
  10. package/cli/fragments/archive/gh.md +96 -96
  11. package/cli/fragments/archive/gl.md +96 -96
  12. package/cli/fragments/archive/none.md +75 -75
  13. package/cli/fragments/guardrails/codegraph.md +5 -5
  14. package/cli/fragments/guardrails/humanizer.md +4 -4
  15. package/cli/fragments/guardrails/memory.md +4 -4
  16. package/cli/fragments/guardrails/rtk.md +3 -3
  17. package/cli/fragments/guardrails/simple-english.md +4 -4
  18. package/cli/fragments/ops-backlog/az.md +28 -28
  19. package/cli/fragments/ops-backlog/gh.md +28 -28
  20. package/cli/fragments/ops-backlog/jira.md +28 -28
  21. package/cli/fragments/ops-review/az.md +62 -62
  22. package/cli/fragments/ops-review/gh.md +51 -51
  23. package/cli/fragments/ops-review/gl.md +55 -55
  24. package/cli/fragments/ops-ship/az.md +81 -81
  25. package/cli/fragments/ops-ship/gh.md +67 -67
  26. package/cli/fragments/ops-ship/gl.md +84 -84
  27. package/cli/index.js +116 -116
  28. package/cli/presets/agents-content.json +34 -34
  29. package/cli/presets/browser.json +10 -10
  30. package/cli/presets/clean.json +21 -21
  31. package/cli/presets/models.json +68 -68
  32. package/cli/presets/optimization.json +32 -32
  33. package/cli/presets/platforms.json +76 -76
  34. package/cli/presets/source.json +23 -23
  35. package/cli/steps/browser/index.js +48 -48
  36. package/cli/steps/clean/index.js +120 -120
  37. package/cli/steps/copy/agents.js +120 -120
  38. package/cli/steps/copy/commands.js +79 -79
  39. package/cli/steps/copy/fullstack-engineer.js +89 -89
  40. package/cli/steps/copy/index.js +88 -88
  41. package/cli/steps/copy/opencode-json.js +324 -324
  42. package/cli/steps/copy/skills.js +316 -307
  43. package/cli/steps/metadata/index.js +115 -115
  44. package/cli/steps/models/format.js +88 -88
  45. package/cli/steps/models/index.js +64 -64
  46. package/cli/steps/models/write.js +38 -38
  47. package/cli/steps/openspec/index.js +136 -136
  48. package/cli/steps/optimization/codegraph.js +141 -127
  49. package/cli/steps/optimization/detect.js +66 -66
  50. package/cli/steps/optimization/humanizer.js +17 -17
  51. package/cli/steps/optimization/index.js +158 -158
  52. package/cli/steps/optimization/memory.js +91 -88
  53. package/cli/steps/optimization/patch-guardrails.js +111 -111
  54. package/cli/steps/optimization/simple-english.js +17 -17
  55. package/cli/steps/optimization/skills-lock.js +30 -30
  56. package/cli/steps/platform/index.js +109 -109
  57. package/cli/steps/source/index.js +123 -123
  58. package/cli/utils/agent-color.js +111 -111
  59. package/cli/utils/copy.js +134 -134
  60. package/cli/utils/exec-spinner.js +47 -47
  61. package/cli/utils/exec.js +134 -134
  62. package/cli/utils/legacy-check.js +30 -30
  63. package/cli/utils/models-cache.js +58 -58
  64. package/cli/utils/models-pricing.js +42 -42
  65. package/cli/utils/paths.js +80 -80
  66. package/cli/utils/process.js +3 -3
  67. package/cli/utils/terminal.js +6 -6
  68. package/cli/utils/update-manifest.js +75 -75
  69. package/harness/.opencode/_gitignore +9 -9
  70. package/harness/.opencode/commands/init.md +5 -5
  71. package/harness/.opencode/commands/make-architecture.md +5 -5
  72. package/harness/.opencode/commands/make-design.md +5 -5
  73. package/harness/.opencode/commands/make-engineer.md +5 -5
  74. package/harness/.opencode/commands/make-guardrails.md +5 -5
  75. package/harness/.opencode/commands/make-user-model.md +5 -5
  76. package/harness/.opencode/commands/ops-backlog.md +10 -10
  77. package/harness/.opencode/commands/ops-review.md +8 -8
  78. package/harness/.opencode/commands/ops-ship.md +9 -9
  79. package/harness/.opencode/commands/plan-apply.md +9 -9
  80. package/harness/.opencode/commands/plan-archive.md +5 -5
  81. package/harness/.opencode/commands/plan-explore.md +9 -9
  82. package/harness/.opencode/commands/plan-goal.md +5 -5
  83. package/harness/.opencode/commands/plan-propose.md +9 -9
  84. package/harness/.opencode/commands/plan-quick.md +5 -5
  85. package/harness/.opencode/commands/plan-story.md +9 -9
  86. package/harness/.opencode/commands/repo-audit.md +5 -5
  87. package/harness/.opencode/commands/repo-help.md +5 -5
  88. package/harness/.opencode/commands/repo-initialize.md +5 -5
  89. package/harness/.opencode/commands/repo-onboard.md +5 -5
  90. package/harness/.opencode/commands/repo-verify.md +5 -5
  91. package/harness/.opencode/package.json +5 -5
  92. package/harness/.opencode/plugins/pc-subagent-monitor.js +184 -184
  93. package/harness/.opencode/plugins/pc-subagent-tiers.js +354 -354
  94. package/harness/.opencode/plugins/pc-system-reminders.js +386 -386
  95. package/harness/.opencode/scripts/check-diff.mjs +26 -7
  96. package/harness/.opencode/scripts/code-rules.mjs +288 -280
  97. package/harness/AGENTS.md +49 -49
  98. package/harness/ARCHITECTURE.md +13 -13
  99. package/harness/DESIGN.md +13 -13
  100. package/harness/opencode.jsonc +36 -36
  101. package/harness/openspec/config.yaml +20 -20
  102. package/harness/skills-lock.json +17 -17
  103. package/package.json +14 -12
  104. package/skills/README.md +18 -18
  105. package/skills/agent-harness-cli/SKILL.md +86 -86
  106. package/skills/browser-automation/SKILL.md +72 -72
  107. package/skills/pc-guardrails-project/SKILL.md +8 -8
  108. package/skills/pc-make-architecture/SKILL.md +32 -32
  109. package/skills/pc-make-architecture/structure-template.md +64 -64
  110. package/skills/pc-make-design/SKILL.md +45 -45
  111. package/skills/pc-make-engineer/SKILL.md +59 -59
  112. package/skills/pc-make-engineer/signal-mapping.md +53 -53
  113. package/skills/pc-make-engineer/template.md +36 -36
  114. package/skills/pc-make-guardrails/SKILL.md +44 -44
  115. package/skills/pc-make-guardrails/category-reference.md +112 -112
  116. package/skills/pc-make-merge-risk-assess/SKILL.md +70 -70
  117. package/skills/pc-make-merge-risk-assess/category-reference.md +114 -114
  118. package/skills/pc-make-user-model/SKILL.md +56 -56
  119. package/skills/pc-ops-ship/SKILL.md +22 -18
  120. package/skills/pc-plan-apply/SKILL.md +86 -86
  121. package/skills/pc-plan-apply/simple-mode.md +21 -21
  122. package/skills/pc-plan-archive/SKILL.md +66 -66
  123. package/skills/pc-plan-explore/SKILL.md +21 -21
  124. package/skills/pc-plan-goal/SKILL.md +91 -91
  125. package/skills/pc-plan-goal/branching.md +39 -39
  126. package/skills/pc-plan-goal/failure-policy.md +30 -30
  127. package/skills/pc-plan-goal/output-mode.md +10 -10
  128. package/skills/pc-plan-goal/output.md +71 -71
  129. package/skills/pc-plan-propose/SKILL.md +125 -125
  130. package/skills/pc-plan-propose/task-annotation.md +39 -39
  131. package/skills/pc-plan-quick/SKILL.md +46 -46
  132. package/skills/pc-plan-story/SKILL.md +93 -93
  133. package/skills/pc-repo-audit/SKILL.md +44 -44
  134. package/skills/pc-repo-help/SKILL.md +87 -87
  135. package/skills/pc-repo-initialize/SKILL.md +119 -119
  136. package/skills/pc-repo-onboard/SKILL.md +32 -32
  137. package/skills/pc-repo-verify/SKILL.md +150 -150
  138. package/skills/pc-userstory-az/SKILL.md +71 -71
  139. package/skills/pc-userstory-browser/SKILL.md +64 -64
  140. package/skills/pc-userstory-gh/SKILL.md +63 -63
  141. package/skills/pc-userstory-jira/SKILL.md +74 -74
@@ -11,6 +11,7 @@ export const DEFAULT_LIMITS = {
11
11
  testAllowance: 40,
12
12
  casesPerKloc: 40,
13
13
  caseAllowance: 3,
14
+ complexityBaseline: 'scripts/complexity-baseline.json',
14
15
  }
15
16
 
16
17
  const FIX = {
@@ -48,10 +49,13 @@ const SUSPICIOUS = {
48
49
 
49
50
  const EMPTY_STATS = { cases: 0, skipped: 0, focused: 0, snapshot: 0, noAssertion: 0, mockOnly: 0 }
50
51
 
51
- export function evaluate(files, limits = DEFAULT_LIMITS) {
52
+ // `tracked` holds the files a complexity gate has methods on record for. Their new lines buy twice
53
+ // the test budget: that gate fails a method whose coverage drops, so a change there needs its new
54
+ // branches tested, and trimming those tests to fit this budget is what broke Pliny-Bot #633.
55
+ export function evaluate(files, limits = DEFAULT_LIMITS, tracked = new Set()) {
52
56
  const violations = []
53
57
  const add = (rule, file, line, detail) => violations.push({ rule, file, line, detail, fix: FIX[rule] })
54
- const totals = { sourceCode: 0, testCode: 0, comments: 0, testLines: 0, cases: 0 }
58
+ const totals = { sourceCode: 0, trackedCode: 0, testCode: 0, comments: 0, testLines: 0, cases: 0 }
55
59
  const commentsByFile = new Map()
56
60
 
57
61
  for (const file of files) {
@@ -64,8 +68,11 @@ export function evaluate(files, limits = DEFAULT_LIMITS) {
64
68
  totals.comments += 1
65
69
  commentsByFile.set(file.path, (commentsByFile.get(file.path) ?? 0) + 1)
66
70
  } else if (k === 'code') {
67
- if (kind === 'source') totals.sourceCode += 1
68
- else totals.testCode += 1
71
+ if (kind !== 'source') totals.testCode += 1
72
+ else {
73
+ totals.sourceCode += 1
74
+ if (tracked.has(file.path)) totals.trackedCode += 1
75
+ }
69
76
  }
70
77
  }
71
78
 
@@ -100,8 +107,9 @@ export function evaluate(files, limits = DEFAULT_LIMITS) {
100
107
  }
101
108
 
102
109
  const commentBudget = Math.max(limits.commentAllowance, Math.floor(limits.commentRatio * (totals.sourceCode + totals.testCode)))
103
- const testBudget = Math.max(limits.testAllowance, Math.floor(limits.testRatio * totals.sourceCode))
104
- const caseBudget = Math.max(limits.caseAllowance, Math.floor((limits.casesPerKloc * totals.sourceCode) / 1000))
110
+ const testedCode = totals.sourceCode + totals.trackedCode
111
+ const testBudget = Math.max(limits.testAllowance, Math.floor(limits.testRatio * testedCode))
112
+ const caseBudget = Math.max(limits.caseAllowance, Math.floor((limits.casesPerKloc * testedCode) / 1000))
105
113
  if (totals.comments > commentBudget) {
106
114
  const where = [...commentsByFile].sort((a, b) => b[1] - a[1]).slice(0, 5).map(([f, n]) => `${f} (${n})`).join(', ')
107
115
  add('comment-budget', undefined, undefined, `${totals.comments} comment lines added, budget ${commentBudget}: ${where}`)
@@ -174,6 +182,16 @@ export function collect(root, base) {
174
182
  return files
175
183
  }
176
184
 
185
+ // Paths of the files a complexity gate tracks, from its baseline keyed `path::method`.
186
+ export function trackedFiles(root, baseline) {
187
+ try {
188
+ const entries = Object.keys(JSON.parse(fs.readFileSync(path.join(root, baseline), 'utf8')))
189
+ return new Set(entries.map(key => key.split('::')[0]))
190
+ } catch {
191
+ return new Set()
192
+ }
193
+ }
194
+
177
195
  function readLimits(root) {
178
196
  try {
179
197
  const config = JSON.parse(fs.readFileSync(path.join(root, '.opencode', 'harness.json'), 'utf8'))
@@ -217,7 +235,8 @@ function main(argv) {
217
235
  console.error('check-diff: no base to compare against. Pass --base <ref> or fetch origin.')
218
236
  return 2
219
237
  }
220
- const result = evaluate(collect(root, base.base), readLimits(root))
238
+ const limits = readLimits(root)
239
+ const result = evaluate(collect(root, base.base), limits, trackedFiles(root, limits.complexityBaseline))
221
240
  console.log(argv.includes('--json') ? JSON.stringify({ base, ...result }, null, 2) : report(result, base))
222
241
  return result.violations.length === 0 ? 0 : 1
223
242
  }