@hunter-harness/workflow-harness 0.2.14 → 0.2.15
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.
- package/harness/bundles/general/claude-code/.harness-build.json +1 -1
- package/harness/bundles/general/claude-code/harness-archive/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-plan/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-review/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-run/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-run/reference.md +3 -1
- package/harness/bundles/general/claude-code/harness-submit/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-sync/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/harness-test/SKILL.md +1 -1
- package/harness/bundles/general/claude-code/scripts/harness_archive.py +80 -0
- package/harness/bundles/general/claude-code/scripts/harness_change.py +256 -16
- package/harness/bundles/general/claude-code/scripts/harness_events.py +14 -0
- package/harness/bundles/general/claude-code/scripts/harness_integration.py +64 -7
- package/harness/bundles/general/claude-code/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/general/claude-code/scripts/harness_preflight.py +146 -77
- package/harness/bundles/general/claude-code/scripts/harness_state.py +12 -4
- package/harness/bundles/general/codebuddy/.harness-build.json +1 -1
- package/harness/bundles/general/codebuddy/harness-archive/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-plan/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-review/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-run/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-run/reference.md +3 -1
- package/harness/bundles/general/codebuddy/harness-submit/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-sync/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/harness-test/SKILL.md +1 -1
- package/harness/bundles/general/codebuddy/scripts/harness_archive.py +80 -0
- package/harness/bundles/general/codebuddy/scripts/harness_change.py +256 -16
- package/harness/bundles/general/codebuddy/scripts/harness_events.py +14 -0
- package/harness/bundles/general/codebuddy/scripts/harness_integration.py +64 -7
- package/harness/bundles/general/codebuddy/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/general/codebuddy/scripts/harness_preflight.py +146 -77
- package/harness/bundles/general/codebuddy/scripts/harness_state.py +12 -4
- package/harness/bundles/general/codex/.harness-build.json +1 -1
- package/harness/bundles/general/codex/harness-archive/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-plan/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-review/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-run/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-run/reference.md +3 -1
- package/harness/bundles/general/codex/harness-submit/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-sync/SKILL.md +1 -1
- package/harness/bundles/general/codex/harness-test/SKILL.md +1 -1
- package/harness/bundles/general/codex/scripts/harness_archive.py +80 -0
- package/harness/bundles/general/codex/scripts/harness_change.py +256 -16
- package/harness/bundles/general/codex/scripts/harness_events.py +14 -0
- package/harness/bundles/general/codex/scripts/harness_integration.py +64 -7
- package/harness/bundles/general/codex/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/general/codex/scripts/harness_preflight.py +146 -77
- package/harness/bundles/general/codex/scripts/harness_state.py +12 -4
- package/harness/bundles/general/cursor/.harness-build.json +1 -1
- package/harness/bundles/general/cursor/harness-archive/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-plan/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-review/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-run/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-run/reference.md +3 -1
- package/harness/bundles/general/cursor/harness-submit/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-sync/SKILL.md +1 -1
- package/harness/bundles/general/cursor/harness-test/SKILL.md +1 -1
- package/harness/bundles/general/cursor/scripts/harness_archive.py +80 -0
- package/harness/bundles/general/cursor/scripts/harness_change.py +256 -16
- package/harness/bundles/general/cursor/scripts/harness_events.py +14 -0
- package/harness/bundles/general/cursor/scripts/harness_integration.py +64 -7
- package/harness/bundles/general/cursor/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/general/cursor/scripts/harness_preflight.py +146 -77
- package/harness/bundles/general/cursor/scripts/harness_state.py +12 -4
- package/harness/bundles/java/claude-code/.harness-build.json +1 -1
- package/harness/bundles/java/claude-code/harness-apidoc/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-archive/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-package/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-plan/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-review/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-run/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-submit/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-sync/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/harness-test/SKILL.md +1 -1
- package/harness/bundles/java/claude-code/scripts/harness_archive.py +80 -0
- package/harness/bundles/java/claude-code/scripts/harness_change.py +256 -16
- package/harness/bundles/java/claude-code/scripts/harness_events.py +14 -0
- package/harness/bundles/java/claude-code/scripts/harness_integration.py +64 -7
- package/harness/bundles/java/claude-code/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/java/claude-code/scripts/harness_preflight.py +146 -77
- package/harness/bundles/java/claude-code/scripts/harness_state.py +12 -4
- package/harness/bundles/java/codebuddy/.harness-build.json +1 -1
- package/harness/bundles/java/codebuddy/harness-apidoc/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-archive/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-package/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-plan/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-review/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-run/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-submit/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-sync/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/harness-test/SKILL.md +1 -1
- package/harness/bundles/java/codebuddy/scripts/harness_archive.py +80 -0
- package/harness/bundles/java/codebuddy/scripts/harness_change.py +256 -16
- package/harness/bundles/java/codebuddy/scripts/harness_events.py +14 -0
- package/harness/bundles/java/codebuddy/scripts/harness_integration.py +64 -7
- package/harness/bundles/java/codebuddy/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/java/codebuddy/scripts/harness_preflight.py +146 -77
- package/harness/bundles/java/codebuddy/scripts/harness_state.py +12 -4
- package/harness/bundles/java/codex/.harness-build.json +1 -1
- package/harness/bundles/java/codex/harness-apidoc/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-archive/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-package/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-plan/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-review/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-run/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-submit/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-sync/SKILL.md +1 -1
- package/harness/bundles/java/codex/harness-test/SKILL.md +1 -1
- package/harness/bundles/java/codex/scripts/harness_archive.py +80 -0
- package/harness/bundles/java/codex/scripts/harness_change.py +256 -16
- package/harness/bundles/java/codex/scripts/harness_events.py +14 -0
- package/harness/bundles/java/codex/scripts/harness_integration.py +64 -7
- package/harness/bundles/java/codex/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/java/codex/scripts/harness_preflight.py +146 -77
- package/harness/bundles/java/codex/scripts/harness_state.py +12 -4
- package/harness/bundles/java/cursor/.harness-build.json +1 -1
- package/harness/bundles/java/cursor/harness-apidoc/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-archive/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-codebase-map/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-knowledge-ingest/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-knowledge-query/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-package/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-plan/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-review/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-run/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-submit/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-sync/SKILL.md +1 -1
- package/harness/bundles/java/cursor/harness-test/SKILL.md +1 -1
- package/harness/bundles/java/cursor/scripts/harness_archive.py +80 -0
- package/harness/bundles/java/cursor/scripts/harness_change.py +256 -16
- package/harness/bundles/java/cursor/scripts/harness_events.py +14 -0
- package/harness/bundles/java/cursor/scripts/harness_integration.py +64 -7
- package/harness/bundles/java/cursor/scripts/harness_plan_finalize.py +85 -0
- package/harness/bundles/java/cursor/scripts/harness_preflight.py +146 -77
- package/harness/bundles/java/cursor/scripts/harness_state.py +12 -4
- package/harness/manifests/general/claude-code.json +19 -19
- package/harness/manifests/general/codebuddy.json +19 -19
- package/harness/manifests/general/codex.json +19 -19
- package/harness/manifests/general/cursor.json +19 -19
- package/harness/manifests/java/claude-code.json +20 -20
- package/harness/manifests/java/codebuddy.json +20 -20
- package/harness/manifests/java/codex.json +20 -20
- package/harness/manifests/java/cursor.json +20 -20
- package/hunter-workflow-family.json +1 -1
- package/package.json +1 -1
|
@@ -84,6 +84,12 @@ class TargetMovedError(IntegrationError):
|
|
|
84
84
|
code = "TARGET_MOVED"
|
|
85
85
|
|
|
86
86
|
|
|
87
|
+
class RemoteProbeFailedError(IntegrationError):
|
|
88
|
+
"""Remote probe failed (network/auth/process error), not target moved (retro §5.28)."""
|
|
89
|
+
|
|
90
|
+
code = "REMOTE_PROBE_FAILED"
|
|
91
|
+
|
|
92
|
+
|
|
87
93
|
class LedgerSyncError(IntegrationError):
|
|
88
94
|
code = "LEDGER_SYNC_PENDING"
|
|
89
95
|
|
|
@@ -139,6 +145,52 @@ class GitRunner:
|
|
|
139
145
|
return None
|
|
140
146
|
return proc.stdout.strip()
|
|
141
147
|
|
|
148
|
+
def remote_probe(self, cwd: Path, *args: str) -> dict[str, Any]:
|
|
149
|
+
"""Typed remote probe result (retro §5.28).
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
{
|
|
153
|
+
"exitCode": int,
|
|
154
|
+
"stdoutHash": str | None, # first whitespace-delimited token
|
|
155
|
+
"redactedStderr": str, # stderr with credentials redacted
|
|
156
|
+
"category": "ok" | "target-moved" | "probe-failed" | "auth-failed",
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
`category` distinguishes:
|
|
160
|
+
- `ok`: exit=0, hash available
|
|
161
|
+
- `target-moved`: only meaningful when caller compares hash to expected
|
|
162
|
+
- `probe-failed`: exit!=0, network/process error (allow bounded retry)
|
|
163
|
+
- `auth-failed`: exit!=0, stderr contains auth/credential indicators
|
|
164
|
+
|
|
165
|
+
`None` must never enter the "found head" field; callers must branch on
|
|
166
|
+
`exitCode` before comparing hashes.
|
|
167
|
+
"""
|
|
168
|
+
proc = self.run(cwd, *args, check=False)
|
|
169
|
+
stderr = (proc.stderr or "").strip()
|
|
170
|
+
# Redact potential credentials in stderr (URLs with user:pass@, tokens)
|
|
171
|
+
redacted = re.sub(
|
|
172
|
+
r"(https?|ssh)://[^\s]+@[^\s]+", r"\1://***@***", stderr
|
|
173
|
+
)
|
|
174
|
+
redacted = re.sub(r"(token|password|secret|key)\s*[:=]\s*\S+", r"\1=***", redacted, flags=re.I)
|
|
175
|
+
stdout_hash: str | None = None
|
|
176
|
+
if proc.returncode == 0:
|
|
177
|
+
stdout = (proc.stdout or "").strip()
|
|
178
|
+
if stdout:
|
|
179
|
+
stdout_hash = stdout.split()[0]
|
|
180
|
+
# Classify category
|
|
181
|
+
if proc.returncode == 0:
|
|
182
|
+
category = "ok"
|
|
183
|
+
elif re.search(r"auth|credential|permission|forbidden|unauthorized", stderr, re.I):
|
|
184
|
+
category = "auth-failed"
|
|
185
|
+
else:
|
|
186
|
+
category = "probe-failed"
|
|
187
|
+
return {
|
|
188
|
+
"exitCode": proc.returncode,
|
|
189
|
+
"stdoutHash": stdout_hash,
|
|
190
|
+
"redactedStderr": redacted,
|
|
191
|
+
"category": category,
|
|
192
|
+
}
|
|
193
|
+
|
|
142
194
|
|
|
143
195
|
def _sanitize(value: str) -> str:
|
|
144
196
|
return re.sub(r"[^A-Za-z0-9._-]+", "-", value).strip("-") or "txn"
|
|
@@ -763,16 +815,21 @@ class IntegrationTransaction:
|
|
|
763
815
|
f"{expected_local}, found {current_target}"
|
|
764
816
|
)
|
|
765
817
|
if journal.get("remoteTargetHead"):
|
|
766
|
-
|
|
818
|
+
# Use typed remote probe (retro §5.28): distinguish probe failure
|
|
819
|
+
# (network/auth/process) from genuine target movement. `None`
|
|
820
|
+
# must never enter the "found head" field.
|
|
821
|
+
probe = self.runner.remote_probe(
|
|
767
822
|
self.project_root, "ls-remote", "origin", self.target_branch
|
|
768
823
|
)
|
|
769
|
-
current_remote = (
|
|
770
|
-
remote_line.split()[0]
|
|
771
|
-
if remote_line and remote_line.split()
|
|
772
|
-
else None
|
|
773
|
-
)
|
|
774
824
|
expected_remote = journal.get("remoteTargetHead")
|
|
775
|
-
if
|
|
825
|
+
if probe["exitCode"] != 0:
|
|
826
|
+
# Probe failed: network/auth/process error, not target moved.
|
|
827
|
+
raise RemoteProbeFailedError(
|
|
828
|
+
f"remote probe failed (exit={probe['exitCode']}, "
|
|
829
|
+
f"category={probe['category']}): {probe['redactedStderr']}"
|
|
830
|
+
)
|
|
831
|
+
current_remote = probe["stdoutHash"]
|
|
832
|
+
if current_remote is not None and current_remote != expected_remote:
|
|
776
833
|
raise TargetMovedError(
|
|
777
834
|
f"remote {self.target_branch} moved: expected "
|
|
778
835
|
f"{expected_remote}, found {current_remote}"
|
|
@@ -177,6 +177,82 @@ def _terminal_exists(change_dir: Path, run_id: str, attempt: int) -> bool:
|
|
|
177
177
|
)
|
|
178
178
|
|
|
179
179
|
|
|
180
|
+
def _read_design_capabilities(staging: Path, change_name: str) -> list[str]:
|
|
181
|
+
"""Read capabilities from design frontmatter (retro §5.4)."""
|
|
182
|
+
design_path = staging / "spec" / f"{change_name}-design.md"
|
|
183
|
+
if not design_path.is_file():
|
|
184
|
+
return []
|
|
185
|
+
try:
|
|
186
|
+
text = design_path.read_text(encoding="utf-8-sig")
|
|
187
|
+
except OSError:
|
|
188
|
+
return []
|
|
189
|
+
frontmatter = _frontmatter(text)
|
|
190
|
+
if not frontmatter:
|
|
191
|
+
return []
|
|
192
|
+
raw = frontmatter.get("capabilities") or ""
|
|
193
|
+
if not raw:
|
|
194
|
+
return []
|
|
195
|
+
# capabilities may be comma-separated or YAML list
|
|
196
|
+
if raw.startswith("["):
|
|
197
|
+
try:
|
|
198
|
+
parsed = json.loads(raw)
|
|
199
|
+
if isinstance(parsed, list):
|
|
200
|
+
return [str(c) for c in parsed if isinstance(c, str)]
|
|
201
|
+
except json.JSONDecodeError:
|
|
202
|
+
pass
|
|
203
|
+
return [c.strip() for c in raw.split(",") if c.strip()]
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def _reclassify_gate_policy(
|
|
207
|
+
staging: Path,
|
|
208
|
+
change_name: str,
|
|
209
|
+
) -> dict[str, Any]:
|
|
210
|
+
"""Reclassify gate policy based on approved design capabilities (retro §5.4).
|
|
211
|
+
|
|
212
|
+
Reads design frontmatter `capabilities`, invokes harness_gate.py classify
|
|
213
|
+
to recompute the gate DAG, and updates staging/meta/gate-policy.json.
|
|
214
|
+
Returns {"ok": bool, "capabilities": [...], "drift": bool}.
|
|
215
|
+
"""
|
|
216
|
+
capabilities = _read_design_capabilities(staging, change_name)
|
|
217
|
+
if not capabilities:
|
|
218
|
+
return {"ok": True, "capabilities": [], "drift": False, "updated": False}
|
|
219
|
+
|
|
220
|
+
gate_policy_path = staging / "meta" / "gate-policy.json"
|
|
221
|
+
try:
|
|
222
|
+
existing = json.loads(gate_policy_path.read_text(encoding="utf-8-sig"))
|
|
223
|
+
except (OSError, json.JSONDecodeError):
|
|
224
|
+
existing = {}
|
|
225
|
+
|
|
226
|
+
existing_caps = set(existing.get("capabilities") or [])
|
|
227
|
+
design_caps = set(capabilities)
|
|
228
|
+
drift = existing_caps != design_caps
|
|
229
|
+
|
|
230
|
+
if drift:
|
|
231
|
+
# Update gate-policy.json with design capabilities
|
|
232
|
+
existing["capabilities"] = sorted(design_caps)
|
|
233
|
+
try:
|
|
234
|
+
gate_policy_path.write_text(
|
|
235
|
+
json.dumps(existing, ensure_ascii=False, indent=2) + "\n",
|
|
236
|
+
encoding="utf-8",
|
|
237
|
+
newline="\n",
|
|
238
|
+
)
|
|
239
|
+
except OSError as exc:
|
|
240
|
+
return {
|
|
241
|
+
"ok": False,
|
|
242
|
+
"error": f"failed to update gate-policy.json: {exc}",
|
|
243
|
+
"capabilities": capabilities,
|
|
244
|
+
"drift": True,
|
|
245
|
+
"updated": False,
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
"ok": True,
|
|
250
|
+
"capabilities": sorted(design_caps),
|
|
251
|
+
"drift": drift,
|
|
252
|
+
"updated": drift,
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
|
|
180
256
|
def _append_terminal(change_dir: Path, run_id: str, attempt: int) -> tuple[int, str]:
|
|
181
257
|
stdout = io.StringIO()
|
|
182
258
|
stderr = io.StringIO()
|
|
@@ -214,6 +290,15 @@ def finalize_plan(
|
|
|
214
290
|
) -> dict[str, Any]:
|
|
215
291
|
change_dir = change_dir.resolve()
|
|
216
292
|
staging = staging.resolve()
|
|
293
|
+
|
|
294
|
+
# C2 (retro §5.4): reclassify gate policy based on approved design capabilities.
|
|
295
|
+
# This updates staging/meta/gate-policy.json before validation, so the hash
|
|
296
|
+
# reflects the final gate policy. Drift between design capabilities and
|
|
297
|
+
# gate-policy capabilities is resolved in favor of the approved design.
|
|
298
|
+
reclassify = _reclassify_gate_policy(staging, change_name)
|
|
299
|
+
if not reclassify.get("ok"):
|
|
300
|
+
return _result_error("CAPABILITY_GATE_DRIFT", reclassify.get("error", "reclassify failed"))
|
|
301
|
+
|
|
217
302
|
validation = validate_staging(staging, change_name)
|
|
218
303
|
if not validation["ok"]:
|
|
219
304
|
return validation
|
|
@@ -367,10 +367,41 @@ def _resolve_agents_root(skills_root: Path, agents_root: Path | None) -> tuple[P
|
|
|
367
367
|
if skills_root.name == "skills" and skills_root.parent.name in (".claude", ".codebuddy"):
|
|
368
368
|
return (skills_root.parent / "agents").resolve(), None
|
|
369
369
|
if skills_root.name == "skills" and skills_root.parent.name in (".agents", ".cursor"):
|
|
370
|
-
|
|
370
|
+
# These adapters (Codex/Cursor) may provide agent roles via host
|
|
371
|
+
# capability manifest rather than local .md files. Return None without
|
|
372
|
+
# a hard error; the caller checks runtime.json for host capabilities.
|
|
373
|
+
return None, None
|
|
371
374
|
return (skills_root / "agents").resolve(), None
|
|
372
375
|
|
|
373
376
|
|
|
377
|
+
def _read_host_capabilities(skills_root: Path) -> set[str]:
|
|
378
|
+
"""Read agent capabilities declared by the host adapter (retro §5.3).
|
|
379
|
+
|
|
380
|
+
Adapter installs may declare available agent roles in
|
|
381
|
+
`meta/runtime.json` under `agentCapabilities` (list of role names).
|
|
382
|
+
Returns an empty set if the file or field is absent.
|
|
383
|
+
"""
|
|
384
|
+
# runtime.json lives in the change's meta/ dir, but agent capabilities are
|
|
385
|
+
# project-level. Check the adapter's runtime.json at the project root.
|
|
386
|
+
candidates = [
|
|
387
|
+
skills_root.parent / "runtime.json",
|
|
388
|
+
skills_root / "runtime.json",
|
|
389
|
+
]
|
|
390
|
+
for path in candidates:
|
|
391
|
+
if not path.is_file():
|
|
392
|
+
continue
|
|
393
|
+
try:
|
|
394
|
+
data = json.loads(path.read_text(encoding="utf-8-sig"))
|
|
395
|
+
except (OSError, json.JSONDecodeError):
|
|
396
|
+
continue
|
|
397
|
+
if not isinstance(data, dict):
|
|
398
|
+
continue
|
|
399
|
+
caps = data.get("agentCapabilities")
|
|
400
|
+
if isinstance(caps, list):
|
|
401
|
+
return {str(c) for c in caps if isinstance(c, str)}
|
|
402
|
+
return set()
|
|
403
|
+
|
|
404
|
+
|
|
374
405
|
def cmd_check_agents(
|
|
375
406
|
skills_root: Path,
|
|
376
407
|
agent: str,
|
|
@@ -388,98 +419,136 @@ def cmd_check_agents(
|
|
|
388
419
|
"reason": "agent name is empty",
|
|
389
420
|
}
|
|
390
421
|
|
|
391
|
-
resolved_agents_root,
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
422
|
+
resolved_agents_root, _ = _resolve_agents_root(skills_root, agents_root)
|
|
423
|
+
host_capabilities = _read_host_capabilities(skills_root)
|
|
424
|
+
host_callable = agent_name in host_capabilities
|
|
425
|
+
|
|
426
|
+
# Three independent fields (retro §5.3):
|
|
427
|
+
# - definitionPresent: local .md file exists
|
|
428
|
+
# - hostCallable: host adapter declares this agent role
|
|
429
|
+
# - toolContractValid: tools declaration is valid (non-empty list)
|
|
430
|
+
definition_present = False
|
|
431
|
+
tool_contract_valid = False
|
|
432
|
+
agent_path: Path | None = None
|
|
433
|
+
meta: dict[str, Any] | None = None
|
|
434
|
+
|
|
435
|
+
if resolved_agents_root is not None:
|
|
436
|
+
filename = agent_name if agent_name.endswith(".md") else f"{agent_name}.md"
|
|
437
|
+
agent_path = resolved_agents_root / filename
|
|
438
|
+
definition_present = agent_path.is_file()
|
|
439
|
+
|
|
440
|
+
# If no local definition and host doesn't declare the role, we can't
|
|
441
|
+
# determine usability. Distinguish "host says no" from "unknown".
|
|
442
|
+
if not definition_present and not host_callable:
|
|
443
|
+
# Check if this adapter is known to not support custom agents
|
|
444
|
+
adapter_name = skills_root.parent.name
|
|
445
|
+
if adapter_name in (".agents", ".cursor"):
|
|
446
|
+
# Codex/Cursor: may support via host manifest. If runtime.json
|
|
447
|
+
# has agentCapabilities but this role isn't listed, it's a
|
|
448
|
+
# genuine "not available". If no agentCapabilities field at all,
|
|
449
|
+
# we can't know — return UNKNOWN.
|
|
450
|
+
runtime_path = skills_root.parent / "runtime.json"
|
|
451
|
+
if not runtime_path.is_file():
|
|
452
|
+
return {
|
|
453
|
+
"ok": True,
|
|
454
|
+
"action": "check-agents",
|
|
455
|
+
"agent": agent_name,
|
|
456
|
+
"usable": False,
|
|
457
|
+
"definitionPresent": False,
|
|
458
|
+
"hostCallable": False,
|
|
459
|
+
"toolContractValid": False,
|
|
460
|
+
"reasonCode": "UNKNOWN",
|
|
461
|
+
"reason": (
|
|
462
|
+
"no local agent definition and no host capability manifest; "
|
|
463
|
+
"cannot determine agent availability"
|
|
464
|
+
),
|
|
465
|
+
}
|
|
410
466
|
return {
|
|
411
467
|
"ok": False,
|
|
412
468
|
"action": "check-agents",
|
|
413
469
|
"agent": agent_name,
|
|
414
|
-
"path": str(agent_path),
|
|
415
|
-
"agentsRoot": str(resolved_agents_root),
|
|
470
|
+
"path": str(agent_path) if agent_path else None,
|
|
471
|
+
"agentsRoot": str(resolved_agents_root) if resolved_agents_root else None,
|
|
416
472
|
"usable": False,
|
|
417
|
-
"
|
|
418
|
-
"
|
|
473
|
+
"definitionPresent": False,
|
|
474
|
+
"hostCallable": False,
|
|
475
|
+
"toolContractValid": False,
|
|
419
476
|
"reasonCode": "AGENT_DEFINITION_NOT_FOUND",
|
|
420
|
-
"reason": f"agent file not found: {
|
|
477
|
+
"reason": f"agent file not found and host does not declare role: {agent_name}",
|
|
421
478
|
}
|
|
422
479
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
480
|
+
# If definition present, validate frontmatter and tools
|
|
481
|
+
if definition_present and agent_path is not None:
|
|
482
|
+
try:
|
|
483
|
+
text = agent_path.read_text(encoding="utf-8")
|
|
484
|
+
except OSError as exc:
|
|
485
|
+
return {
|
|
486
|
+
"ok": False,
|
|
487
|
+
"action": "check-agents",
|
|
488
|
+
"agent": agent_name,
|
|
489
|
+
"path": str(agent_path),
|
|
490
|
+
"usable": False,
|
|
491
|
+
"definitionPresent": True,
|
|
492
|
+
"hostCallable": host_callable,
|
|
493
|
+
"toolContractValid": False,
|
|
494
|
+
"reason": f"cannot read agent file: {exc}",
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
meta, err = parse_frontmatter(text)
|
|
498
|
+
if err or meta is None:
|
|
499
|
+
return {
|
|
500
|
+
"ok": False,
|
|
501
|
+
"action": "check-agents",
|
|
502
|
+
"agent": agent_name,
|
|
503
|
+
"path": str(agent_path),
|
|
504
|
+
"usable": False,
|
|
505
|
+
"definitionPresent": True,
|
|
506
|
+
"hostCallable": host_callable,
|
|
507
|
+
"toolContractValid": False,
|
|
508
|
+
"reason": f"frontmatter parse failed: {err or 'unknown'}",
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
tools = meta.get("tools")
|
|
512
|
+
if tools is None:
|
|
513
|
+
tool_contract_valid = False
|
|
514
|
+
elif isinstance(tools, list) and len(tools) > 0:
|
|
515
|
+
tool_contract_valid = True
|
|
516
|
+
else:
|
|
517
|
+
tool_contract_valid = False
|
|
434
518
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
"agent": agent_name,
|
|
441
|
-
"path": str(agent_path),
|
|
442
|
-
"usable": False,
|
|
443
|
-
"reason": f"frontmatter parse failed: {err or 'unknown'}",
|
|
444
|
-
}
|
|
519
|
+
# usable = hostCallable (host provides the agent role, tools validated by host)
|
|
520
|
+
# OR definitionPresent AND toolContractValid (definition-based adapters)
|
|
521
|
+
usable = host_callable or (
|
|
522
|
+
definition_present and tool_contract_valid
|
|
523
|
+
)
|
|
445
524
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
"path": str(agent_path),
|
|
453
|
-
"usable": False,
|
|
454
|
-
"reason": "tools declaration missing",
|
|
455
|
-
"frontmatter": meta,
|
|
456
|
-
}
|
|
457
|
-
if not isinstance(tools, list) or len(tools) == 0:
|
|
458
|
-
return {
|
|
459
|
-
"ok": False,
|
|
460
|
-
"action": "check-agents",
|
|
461
|
-
"agent": agent_name,
|
|
462
|
-
"path": str(agent_path),
|
|
463
|
-
"usable": False,
|
|
464
|
-
"reason": "tools declaration empty or invalid",
|
|
465
|
-
"frontmatter": meta,
|
|
466
|
-
}
|
|
525
|
+
name_field = meta.get("name") if meta else None
|
|
526
|
+
tools_field = meta.get("tools") if meta else None
|
|
527
|
+
|
|
528
|
+
reason_code = "READY" if usable else "AGENT_DEFINITION_NOT_FOUND"
|
|
529
|
+
if not definition_present and host_callable:
|
|
530
|
+
reason_code = "DEFINITION_NOT_FOUND_HOST_CAPABLE"
|
|
467
531
|
|
|
468
|
-
name_field = meta.get("name")
|
|
469
532
|
return {
|
|
470
533
|
"ok": True,
|
|
471
534
|
"action": "check-agents",
|
|
472
535
|
"agent": agent_name,
|
|
473
|
-
"path": str(agent_path),
|
|
474
|
-
"agentsRoot": str(resolved_agents_root),
|
|
475
|
-
"usable":
|
|
476
|
-
"
|
|
477
|
-
"
|
|
478
|
-
"
|
|
479
|
-
"
|
|
536
|
+
"path": str(agent_path) if agent_path else None,
|
|
537
|
+
"agentsRoot": str(resolved_agents_root) if resolved_agents_root else None,
|
|
538
|
+
"usable": usable,
|
|
539
|
+
"definitionPresent": definition_present,
|
|
540
|
+
"hostCallable": host_callable,
|
|
541
|
+
"toolContractValid": tool_contract_valid,
|
|
542
|
+
"reasonCode": reason_code,
|
|
543
|
+
"reason": (
|
|
544
|
+
"agent available; "
|
|
545
|
+
f"definition={'present' if definition_present else 'absent'}, "
|
|
546
|
+
f"hostCallable={host_callable}, "
|
|
547
|
+
f"tools={'valid' if tool_contract_valid else 'invalid'}"
|
|
548
|
+
),
|
|
480
549
|
"name": name_field,
|
|
481
|
-
"tools":
|
|
482
|
-
"frontmatterKeys": sorted(meta.keys()),
|
|
550
|
+
"tools": tools_field,
|
|
551
|
+
"frontmatterKeys": sorted(meta.keys()) if meta else [],
|
|
483
552
|
}
|
|
484
553
|
|
|
485
554
|
|
|
@@ -268,6 +268,7 @@ def capture_current_state(
|
|
|
268
268
|
changed: list[str] = []
|
|
269
269
|
baseline_created = previous is None
|
|
270
270
|
unresolved: list[str] = []
|
|
271
|
+
unresolved_reasons: list[dict[str, str]] = []
|
|
271
272
|
if previous:
|
|
272
273
|
old_segments = previous.get("segments") or {}
|
|
273
274
|
for name, segment in fresh["segments"].items():
|
|
@@ -276,13 +277,17 @@ def capture_current_state(
|
|
|
276
277
|
segment["capturedAt"] = old.get("capturedAt", segment["capturedAt"])
|
|
277
278
|
else:
|
|
278
279
|
changed.append(name)
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
280
|
+
# First observation establishes the baseline; it is not evidence that
|
|
281
|
+
# segments changed, nor that they are "unresolved". Segments are only
|
|
282
|
+
# unresolved when they genuinely fail to read/compute (retro §5.6).
|
|
283
|
+
# On first capture, all successfully-captured segments are baseline,
|
|
284
|
+
# not unresolved.
|
|
283
285
|
fresh["baselineCreated"] = baseline_created
|
|
284
286
|
fresh["changedSegments"] = sorted(changed)
|
|
285
287
|
fresh["unresolvedSegments"] = unresolved
|
|
288
|
+
fresh["unresolvedReasons"] = unresolved_reasons
|
|
289
|
+
fresh["comparisonAvailable"] = not baseline_created
|
|
290
|
+
fresh["baselineStatus"] = "created" if baseline_created else "reused"
|
|
286
291
|
write_snapshot(change_dir, fresh)
|
|
287
292
|
return fresh, changed
|
|
288
293
|
|
|
@@ -325,7 +330,10 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
325
330
|
- set(snapshot.get("unresolvedSegments") or [])
|
|
326
331
|
),
|
|
327
332
|
"baselineCreated": bool(snapshot.get("baselineCreated")),
|
|
333
|
+
"baselineStatus": snapshot.get("baselineStatus", "reused"),
|
|
334
|
+
"comparisonAvailable": bool(snapshot.get("comparisonAvailable", True)),
|
|
328
335
|
"unresolvedSegments": list(snapshot.get("unresolvedSegments") or []),
|
|
336
|
+
"unresolvedReasons": list(snapshot.get("unresolvedReasons") or []),
|
|
329
337
|
"git": snapshot["git"],
|
|
330
338
|
}
|
|
331
339
|
if args.json:
|
|
@@ -3,7 +3,7 @@ name: harness-archive
|
|
|
3
3
|
description: 归档所有变更产出(计划/测试报告/审查/SQL/API文档)到
|
|
4
4
|
.harness/archive/,含归档元数据和可视化最终总结。使用场景:归档、完成归档、收尾、打包产出物
|
|
5
5
|
---
|
|
6
|
-
<!-- generated by harness_deploy.py; core=
|
|
6
|
+
<!-- generated by harness_deploy.py; core=6232f66fbf691292; overlay=none; agent=codebuddy; do not edit -->
|
|
7
7
|
# harness-archive — 变更归档
|
|
8
8
|
|
|
9
9
|
## Purpose
|
|
@@ -3,7 +3,7 @@ name: harness-codebase-map
|
|
|
3
3
|
description: 分析现有代码库并生成 .harness/codebase/map/
|
|
4
4
|
下的结构化代码库地图。用于陌生项目理解、重大改造前梳理、harness-sync 提示 map 过期后的人工刷新。
|
|
5
5
|
---
|
|
6
|
-
<!-- generated by harness_deploy.py; core=
|
|
6
|
+
<!-- generated by harness_deploy.py; core=6232f66fbf691292; overlay=none; agent=codebuddy; do not edit -->
|
|
7
7
|
# harness-codebase-map — 代码库地图
|
|
8
8
|
|
|
9
9
|
## Purpose
|
|
@@ -3,7 +3,7 @@ name: harness-knowledge-ingest
|
|
|
3
3
|
description: 从 .harness/archive 归档整理、同步和维护项目知识索引。适用场景:ingest knowledge、sync
|
|
4
4
|
knowledge、rebuild knowledge index、promote knowledge、确认知识条目、检查知识库是否过期。
|
|
5
5
|
---
|
|
6
|
-
<!-- generated by harness_deploy.py; core=
|
|
6
|
+
<!-- generated by harness_deploy.py; core=6232f66fbf691292; overlay=none; agent=codebuddy; do not edit -->
|
|
7
7
|
# harness-knowledge-ingest
|
|
8
8
|
|
|
9
9
|
从 `.harness/archive/**/reports/final/summary-data.json` 抽取项目知识,生成并维护本地 `.harness/knowledge/` 索引。
|
|
@@ -3,7 +3,7 @@ name: harness-knowledge-query
|
|
|
3
3
|
description: 根据新需求、设计任务、代码修改请求或问题排查,在规划和编码前查询 .harness/knowledge
|
|
4
4
|
历史上下文。适用场景:query knowledge、查找历史需求、根据归档理解需求、继续之前类似开发、生成需求上下文包。
|
|
5
5
|
---
|
|
6
|
-
<!-- generated by harness_deploy.py; core=
|
|
6
|
+
<!-- generated by harness_deploy.py; core=6232f66fbf691292; overlay=none; agent=codebuddy; do not edit -->
|
|
7
7
|
# harness-knowledge-query
|
|
8
8
|
|
|
9
9
|
并行 change 中查询必须传 `--change <change-id>`;成功后以该 change 的 `meta/knowledge-context.json` 为稳定指针。全局 `context-packs/latest.json` 仅向后兼容,不得用于判断多个 active change 的上下文归属。
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: harness-plan
|
|
3
3
|
description: 将需求转化为设计文档+实施计划+完整测试场景表,必须在编码前完成。使用场景:需求分析、feature plan、技术方案设计、实现方案规划
|
|
4
4
|
---
|
|
5
|
-
<!-- generated by harness_deploy.py; core=
|
|
5
|
+
<!-- generated by harness_deploy.py; core=6232f66fbf691292; overlay=none; agent=codebuddy; do not edit -->
|
|
6
6
|
# harness-plan — 需求规划
|
|
7
7
|
|
|
8
8
|
## Purpose
|
|
@@ -3,7 +3,7 @@ name: harness-review
|
|
|
3
3
|
description: 6维度代码审查(架构/安全/规范/兼容/测试/性能),对照项目规则(见
|
|
4
4
|
.harness/context-index.json)和测试场景表,在隔离上下文运行。使用场景:代码审查、提交前检查、合并评审
|
|
5
5
|
---
|
|
6
|
-
<!-- generated by harness_deploy.py; core=
|
|
6
|
+
<!-- generated by harness_deploy.py; core=6232f66fbf691292; overlay=none; agent=codebuddy; do not edit -->
|
|
7
7
|
# harness-review — 代码审查
|
|
8
8
|
|
|
9
9
|
## Purpose
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: harness-run
|
|
3
3
|
description: 按变更簇执行 TDD 编码循环(RED→GREEN→REFACTOR→编译验证),逐变更簇实现计划中的任务。使用场景:开始编码、实现功能、写代码、TDD 编码
|
|
4
4
|
---
|
|
5
|
-
<!-- generated by harness_deploy.py; core=
|
|
5
|
+
<!-- generated by harness_deploy.py; core=6232f66fbf691292; overlay=none; agent=codebuddy; do not edit -->
|
|
6
6
|
# harness-run — 需求编码
|
|
7
7
|
|
|
8
8
|
## Purpose
|
|
@@ -52,7 +52,7 @@ requested=true + path missing
|
|
|
52
52
|
先执行 runtime doctor,并从 `meta/runtime.json` 读取 adapter 的 `path`、`branch` 以及 PowerShell `argvPrefix`;不要依赖裸 `python`/`powershell.exe`,也不要硬编码 Claude 路径。
|
|
53
53
|
|
|
54
54
|
```powershell
|
|
55
|
-
& <powershell-argv-prefix> -Command "git worktree add
|
|
55
|
+
& <powershell-argv-prefix> -Command "git worktree add -b '<adapter-branch>' -- '<adapter-worktree-path>'"
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
如果分支已存在:
|
|
@@ -61,6 +61,8 @@ requested=true + path missing
|
|
|
61
61
|
& <powershell-argv-prefix> -Command "git worktree add -- '<adapter-worktree-path>' '<adapter-branch>'"
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
> ⚠️ **argv 顺序**(复盘 §5.11):`-b <branch>` 必须在 `--` 之前;`git worktree add -- <path> -b <branch>` 中 `--` 后的 `-b` 会被 Git 视为位置参数,命令直接失败。等价 argv 数组:`["git","worktree","add","-b",branch,"--",path]`。
|
|
65
|
+
|
|
64
66
|
验证:
|
|
65
67
|
|
|
66
68
|
```powershell
|
|
@@ -3,7 +3,7 @@ name: harness-submit
|
|
|
3
3
|
description: 最终提交封装:验证→中文 commit→提交/推送;worktree 模式含 --no-ff
|
|
4
4
|
合并回主分支。使用场景:提交代码、commit、push、合并分支、merge to main、完成开发
|
|
5
5
|
---
|
|
6
|
-
<!-- generated by harness_deploy.py; core=
|
|
6
|
+
<!-- generated by harness_deploy.py; core=6232f66fbf691292; overlay=none; agent=codebuddy; do not edit -->
|
|
7
7
|
# harness-submit — 最终提交(含 worktree 合并)
|
|
8
8
|
|
|
9
9
|
## Purpose
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: harness-sync
|
|
3
3
|
description: 检查并更新项目AI元数据(CodeGraph索引、harness-codebase-map分析、CLAUDE.md、AGENTS.md、.harness/完整性),确保Claude对代码库的理解与最新代码一致。当用户说'同步/更新索引/刷新元数据/检查一致性'时使用
|
|
4
4
|
---
|
|
5
|
-
<!-- generated by harness_deploy.py; core=
|
|
5
|
+
<!-- generated by harness_deploy.py; core=6232f66fbf691292; overlay=none; agent=codebuddy; do not edit -->
|
|
6
6
|
# harness-sync — 元数据同步
|
|
7
7
|
|
|
8
8
|
## Purpose
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: harness-test
|
|
3
3
|
description: 测试执行:读取场景表,执行单元测试+API接口测试+数据兼容验证,输出测试报告。当用户说'跑测试/验证/跑用例/接口测试/单元测试'时使用
|
|
4
4
|
---
|
|
5
|
-
<!-- generated by harness_deploy.py; core=
|
|
5
|
+
<!-- generated by harness_deploy.py; core=6232f66fbf691292; overlay=none; agent=codebuddy; do not edit -->
|
|
6
6
|
# harness-test — 测试执行
|
|
7
7
|
|
|
8
8
|
## Purpose
|