@webpresso/agent-kit 3.1.30 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @webpresso/agent-kit might be problematic. Click here for more details.
- package/README.md +53 -15
- package/bin/_run.js +179 -19
- package/catalog/AGENTS.md.tpl +3 -3
- package/catalog/agent/agents/implementer.md +45 -0
- package/catalog/agent/rules/parallel-orchestration-quota.md +100 -0
- package/catalog/agent/rules/pre-implementation.md +28 -1
- package/catalog/agent/rules/supported-agent-clis.md +9 -0
- package/catalog/agent/rules/typescript-version.md +50 -0
- package/catalog/agent/skills/codex/SKILL.md +25 -1
- package/catalog/agent/skills/verify/SKILL.md +4 -2
- package/catalog/docs/templates/blueprint.md +1 -1
- package/dist/esm/audit/agents.js +1 -0
- package/dist/esm/audit/blueprint-lifecycle-sql.d.ts +12 -0
- package/dist/esm/audit/blueprint-lifecycle-sql.js +23 -2
- package/dist/esm/audit/blueprint-pr-coverage.js +4 -0
- package/dist/esm/audit/ci-guardrails-wiring.d.ts +22 -0
- package/dist/esm/audit/ci-guardrails-wiring.js +90 -0
- package/dist/esm/audit/ci-test-perf.js +30 -0
- package/dist/esm/audit/command-surface.js +4 -2
- package/dist/esm/audit/host-substitution-risk.d.ts +2 -0
- package/dist/esm/audit/host-substitution-risk.js +256 -0
- package/dist/esm/audit/registry.d.ts +4 -4
- package/dist/esm/audit/registry.js +8 -1
- package/dist/esm/audit/toolchain-isolation.js +1 -2
- package/dist/esm/audit/typescript-version.d.ts +2 -0
- package/dist/esm/audit/typescript-version.js +123 -0
- package/dist/esm/blueprint/core/parser.js +43 -1
- package/dist/esm/blueprint/core/validation/criteria.d.ts +14 -0
- package/dist/esm/blueprint/core/validation/criteria.js +41 -2
- package/dist/esm/blueprint/core/validation/state.js +25 -14
- package/dist/esm/blueprint/db/migrations/run.js +4 -2
- package/dist/esm/blueprint/lifecycle/audit.d.ts +20 -0
- package/dist/esm/blueprint/lifecycle/audit.js +65 -10
- package/dist/esm/blueprint/lifecycle/canonicalize.d.ts +6 -0
- package/dist/esm/blueprint/lifecycle/canonicalize.js +135 -0
- package/dist/esm/blueprint/lifecycle/local.d.ts +2 -1
- package/dist/esm/blueprint/lifecycle/local.js +19 -3
- package/dist/esm/blueprint/lifecycle/review-provenance.js +36 -11
- package/dist/esm/blueprint/service/BlueprintCreationService.d.ts +1 -0
- package/dist/esm/blueprint/service/BlueprintCreationService.js +53 -4
- package/dist/esm/blueprint/service/blueprint-tech-debt-links.js +16 -2
- package/dist/esm/blueprint/trust/command-runner.d.ts +26 -0
- package/dist/esm/blueprint/trust/command-runner.js +148 -0
- package/dist/esm/blueprint/trust/gates.d.ts +7 -0
- package/dist/esm/blueprint/trust/gates.js +20 -0
- package/dist/esm/blueprint/trust/promotion.d.ts +8 -0
- package/dist/esm/blueprint/trust/promotion.js +62 -112
- package/dist/esm/blueprint/trust/scaffold.d.ts +19 -0
- package/dist/esm/blueprint/trust/scaffold.js +64 -0
- package/dist/esm/blueprint/trust/validator.d.ts +1 -0
- package/dist/esm/blueprint/trust/validator.js +7 -1
- package/dist/esm/blueprint/utils/archive.js +27 -5
- package/dist/esm/blueprint/utils/document-paths.d.ts +18 -0
- package/dist/esm/blueprint/utils/document-paths.js +45 -12
- package/dist/esm/build/cli-mcp-parity.js +10 -0
- package/dist/esm/cli/bundle/commands/blueprint.d.ts +1 -0
- package/dist/esm/cli/bundle/commands/blueprint.js +1 -0
- package/dist/esm/cli/cli.d.ts +1 -1
- package/dist/esm/cli/cli.js +34 -0
- package/dist/esm/cli/commands/agent-launch.d.ts +6 -1
- package/dist/esm/cli/commands/agent-launch.js +82 -4
- package/dist/esm/cli/commands/audit-core.d.ts +1 -1
- package/dist/esm/cli/commands/audit-core.js +8 -1
- package/dist/esm/cli/commands/audit.js +17 -5
- package/dist/esm/cli/commands/blueprint/execution.js +18 -6
- package/dist/esm/cli/commands/blueprint/mutations.js +59 -40
- package/dist/esm/cli/commands/blueprint/router-dispatch.d.ts +2 -1
- package/dist/esm/cli/commands/blueprint/router-dispatch.js +20 -1
- package/dist/esm/cli/commands/blueprint/router-output.d.ts +21 -0
- package/dist/esm/cli/commands/blueprint/router-output.js +48 -17
- package/dist/esm/cli/commands/blueprint/router.d.ts +7 -0
- package/dist/esm/cli/commands/blueprint/router.js +13 -1
- package/dist/esm/cli/commands/ci-preflight.d.ts +13 -2
- package/dist/esm/cli/commands/ci-preflight.js +6 -3
- package/dist/esm/cli/commands/compile.js +5 -31
- package/dist/esm/cli/commands/dash/delivery-status.d.ts +1 -0
- package/dist/esm/cli/commands/dash/delivery-status.js +11 -4
- package/dist/esm/cli/commands/doctor.js +5 -0
- package/dist/esm/cli/commands/hook.d.ts +5 -0
- package/dist/esm/cli/commands/hook.js +15 -9
- package/dist/esm/cli/commands/init/config.js +2 -2
- package/dist/esm/cli/commands/init/convergence-apply.d.ts +24 -0
- package/dist/esm/cli/commands/init/convergence-apply.js +221 -0
- package/dist/esm/cli/commands/init/convergence-state.d.ts +13 -0
- package/dist/esm/cli/commands/init/convergence-state.js +54 -0
- package/dist/esm/cli/commands/init/convergence.d.ts +23 -0
- package/dist/esm/cli/commands/init/convergence.js +57 -0
- package/dist/esm/cli/commands/init/git-convergence.d.ts +19 -0
- package/dist/esm/cli/commands/init/git-convergence.js +168 -0
- package/dist/esm/cli/commands/init/gitignore-patcher.js +2 -0
- package/dist/esm/cli/commands/init/grok-privacy-smoke.d.ts +52 -0
- package/dist/esm/cli/commands/init/grok-privacy-smoke.js +91 -0
- package/dist/esm/cli/commands/init/host-native-proof.d.ts +18 -0
- package/dist/esm/cli/commands/init/host-native-proof.js +88 -0
- package/dist/esm/cli/commands/init/host-visibility.d.ts +2 -2
- package/dist/esm/cli/commands/init/host-visibility.js +94 -5
- package/dist/esm/cli/commands/init/index.d.ts +1 -0
- package/dist/esm/cli/commands/init/index.js +326 -173
- package/dist/esm/cli/commands/init/mcp-spec.d.ts +57 -0
- package/dist/esm/cli/commands/init/mcp-spec.js +273 -0
- package/dist/esm/cli/commands/init/merge.d.ts +1 -0
- package/dist/esm/cli/commands/init/merge.js +30 -1
- package/dist/esm/cli/commands/init/plugin-cache-prune.d.ts +0 -3
- package/dist/esm/cli/commands/init/plugin-cache-prune.js +0 -1
- package/dist/esm/cli/commands/init/scaffold-agents-md.d.ts +1 -1
- package/dist/esm/cli/commands/init/scaffold-agents-md.js +9 -3
- package/dist/esm/cli/commands/init/scaffold-base-kit.d.ts +11 -0
- package/dist/esm/cli/commands/init/scaffold-base-kit.js +56 -1
- package/dist/esm/cli/commands/init/scaffolders/agent-hooks/emitters/grok.d.ts +14 -8
- package/dist/esm/cli/commands/init/scaffolders/agent-hooks/emitters/grok.js +41 -24
- package/dist/esm/cli/commands/init/scaffolders/agent-hooks/index.d.ts +2 -0
- package/dist/esm/cli/commands/init/scaffolders/agent-hooks/index.js +51 -23
- package/dist/esm/cli/commands/init/scaffolders/codex-mcp/index.d.ts +12 -31
- package/dist/esm/cli/commands/init/scaffolders/codex-mcp/index.js +288 -202
- package/dist/esm/cli/commands/init/scaffolders/file-transaction.d.ts +7 -0
- package/dist/esm/cli/commands/init/scaffolders/file-transaction.js +58 -0
- package/dist/esm/cli/commands/init/scaffolders/grok-mcp/index.d.ts +38 -0
- package/dist/esm/cli/commands/init/scaffolders/grok-mcp/index.js +73 -0
- package/dist/esm/cli/commands/init/scaffolders/opencode-plugin/index.d.ts +21 -0
- package/dist/esm/cli/commands/init/scaffolders/opencode-plugin/index.js +559 -63
- package/dist/esm/cli/commands/init/untracked-collision.d.ts +14 -0
- package/dist/esm/cli/commands/init/untracked-collision.js +42 -0
- package/dist/esm/cli/commands/opencode-rotate.d.ts +49 -0
- package/dist/esm/cli/commands/opencode-rotate.js +135 -0
- package/dist/esm/cli/commands/public-readiness.d.ts +11 -0
- package/dist/esm/cli/commands/public-readiness.js +42 -0
- package/dist/esm/cli/commands/review.d.ts +35 -3
- package/dist/esm/cli/commands/review.js +729 -209
- package/dist/esm/cli/commands/run-wait.d.ts +2 -0
- package/dist/esm/cli/commands/run-wait.js +122 -0
- package/dist/esm/cli/commands/setup-help.js +1 -1
- package/dist/esm/cli/commands/setup-repair-help.js +1 -1
- package/dist/esm/cli/commands/worktree/router-dispatch.js +13 -8
- package/dist/esm/cli/direct-provider-launch.js +9 -5
- package/dist/esm/cli/optional-tool-freshness.d.ts +27 -0
- package/dist/esm/cli/optional-tool-freshness.js +219 -9
- package/dist/esm/daemon/domains/git-actions.d.ts +29 -0
- package/dist/esm/daemon/domains/git-actions.js +136 -0
- package/dist/esm/daemon/domains/run-registry-interop.d.ts +16 -0
- package/dist/esm/daemon/domains/run-registry-interop.js +45 -0
- package/dist/esm/daemon/domains/sessions-search.d.ts +11 -0
- package/dist/esm/daemon/domains/sessions-search.js +29 -0
- package/dist/esm/daemon/handlers/blueprints-handlers.d.ts +5 -0
- package/dist/esm/daemon/handlers/blueprints-handlers.js +36 -0
- package/dist/esm/daemon/handlers/deploy-handlers.d.ts +6 -0
- package/dist/esm/daemon/handlers/deploy-handlers.js +5 -0
- package/dist/esm/daemon/handlers/fleet-handlers.d.ts +15 -0
- package/dist/esm/daemon/handlers/fleet-handlers.js +91 -0
- package/dist/esm/daemon/handlers/git-handlers.d.ts +6 -0
- package/dist/esm/daemon/handlers/git-handlers.js +27 -0
- package/dist/esm/daemon/handlers/product.d.ts +7 -0
- package/dist/esm/daemon/handlers/product.js +10 -119
- package/dist/esm/daemon/handlers/sessions-handlers.d.ts +12 -0
- package/dist/esm/daemon/handlers/sessions-handlers.js +31 -0
- package/dist/esm/daemon/handlers/shared.d.ts +5 -0
- package/dist/esm/daemon/handlers/shared.js +16 -0
- package/dist/esm/daemon/methods.d.ts +8 -1
- package/dist/esm/daemon/methods.js +7 -0
- package/dist/esm/daemon/protocol/contract.d.ts +43 -0
- package/dist/esm/daemon/protocol/contract.js +26 -0
- package/dist/esm/daemon/protocol/index.d.ts +1 -1
- package/dist/esm/daemon/protocol/index.js +1 -1
- package/dist/esm/hooks/__conformance__/matrix.d.ts +6 -0
- package/dist/esm/hooks/__conformance__/matrix.js +137 -0
- package/dist/esm/hooks/conformance/batch.js +5 -0
- package/dist/esm/hooks/doctor.d.ts +3 -3
- package/dist/esm/hooks/doctor.js +30 -15
- package/dist/esm/hooks/permission-request/index.js +9 -3
- package/dist/esm/hooks/permission-request/policy.d.ts +9 -0
- package/dist/esm/hooks/permission-request/policy.js +13 -0
- package/dist/esm/hooks/pretool-guard/dev-routing.d.ts +9 -0
- package/dist/esm/hooks/pretool-guard/dev-routing.js +41 -5
- package/dist/esm/hooks/pretool-guard/logger.d.ts +7 -0
- package/dist/esm/hooks/pretool-guard/logger.js +16 -0
- package/dist/esm/hooks/pretool-guard/runner.d.ts +6 -0
- package/dist/esm/hooks/pretool-guard/runner.js +68 -16
- package/dist/esm/hooks/pretool-guard/validators/blueprint.js +30 -10
- package/dist/esm/hooks/pretool-guard/validators/forbidden-commands.js +54 -0
- package/dist/esm/hooks/pretool-guard/validators/index.d.ts +7 -0
- package/dist/esm/hooks/pretool-guard/validators/index.js +21 -0
- package/dist/esm/hooks/pretool-guard/validators/path-contract.d.ts +19 -0
- package/dist/esm/hooks/pretool-guard/validators/path-contract.js +25 -8
- package/dist/esm/hooks/shared/guard-outcome.d.ts +149 -0
- package/dist/esm/hooks/shared/guard-outcome.js +215 -0
- package/dist/esm/hooks/shared/hook-bootstrap.d.ts +26 -0
- package/dist/esm/hooks/shared/hook-bootstrap.js +64 -1
- package/dist/esm/hooks/shared/types.d.ts +8 -5
- package/dist/esm/hooks/shared/types.js +23 -8
- package/dist/esm/hooks/stop/qa-changed-files.d.ts +11 -0
- package/dist/esm/hooks/stop/qa-changed-files.js +74 -0
- package/dist/esm/mcp/blueprint/_shared/lifecycle.js +14 -1
- package/dist/esm/mcp/blueprint/handlers/document-mutations.js +78 -4
- package/dist/esm/mcp/blueprint/handlers/review-log.js +8 -1
- package/dist/esm/mcp/blueprint/handlers/task-advance.js +113 -54
- package/dist/esm/mcp/blueprint/handlers/task-verify.js +39 -19
- package/dist/esm/mcp/blueprint/registration.js +3 -2
- package/dist/esm/mcp/server.d.ts +1 -0
- package/dist/esm/mcp/server.js +27 -0
- package/dist/esm/mcp/tools/_names.d.ts +1 -1
- package/dist/esm/mcp/tools/_names.js +5 -0
- package/dist/esm/mcp/tools/_registry.js +10 -0
- package/dist/esm/mcp/tools/_shared/audit-kinds.d.ts +1 -1
- package/dist/esm/mcp/tools/_shared/result.js +44 -1
- package/dist/esm/mcp/tools/audit.d.ts +4 -1
- package/dist/esm/mcp/tools/audit.js +30 -0
- package/dist/esm/mcp/tools/audits.d.ts +3 -0
- package/dist/esm/mcp/tools/ci-preflight.d.ts +50 -0
- package/dist/esm/mcp/tools/ci-preflight.js +183 -0
- package/dist/esm/mcp/tools/pr-upsert.js +39 -1
- package/dist/esm/mcp/tools/review-run.d.ts +28 -0
- package/dist/esm/mcp/tools/review-run.js +216 -0
- package/dist/esm/mcp/tools/run-wait.d.ts +86 -0
- package/dist/esm/mcp/tools/run-wait.js +593 -0
- package/dist/esm/mcp/tools/session-id.d.ts +3 -0
- package/dist/esm/mcp/tools/session-id.js +45 -0
- package/dist/esm/mcp/tools/session-info.d.ts +3 -0
- package/dist/esm/mcp/tools/session-info.js +49 -0
- package/dist/esm/output-transforms/audit.d.ts +23 -0
- package/dist/esm/output-transforms/audit.js +47 -0
- package/dist/esm/output-transforms/index.js +2 -0
- package/dist/esm/review/authority.js +13 -5
- package/dist/esm/review/availability.d.ts +22 -0
- package/dist/esm/review/availability.js +107 -20
- package/dist/esm/review/delivery-verifier.d.ts +27 -0
- package/dist/esm/review/delivery-verifier.js +115 -0
- package/dist/esm/review/events.d.ts +3 -2
- package/dist/esm/review/events.js +23 -3
- package/dist/esm/review/execution/adapters.js +26 -9
- package/dist/esm/review/execution/output-policy.d.ts +2 -0
- package/dist/esm/review/execution/output-policy.js +12 -0
- package/dist/esm/review/execution/review-checkout.js +87 -6
- package/dist/esm/review/execution/supervisor.js +5 -0
- package/dist/esm/review/execution/types.d.ts +8 -0
- package/dist/esm/review/opencode-account.d.ts +24 -0
- package/dist/esm/review/opencode-account.js +68 -0
- package/dist/esm/review/opencode-auth.d.ts +33 -0
- package/dist/esm/review/opencode-auth.js +79 -0
- package/dist/esm/review/subject.d.ts +12 -0
- package/dist/esm/review/subject.js +74 -22
- package/dist/esm/runtime/opencode-account-materializer.d.ts +34 -0
- package/dist/esm/runtime/opencode-account-materializer.js +33 -0
- package/dist/esm/status/snapshot.js +30 -19
- package/dist/esm/test/duration-sequencer.d.ts +20 -0
- package/dist/esm/test/duration-sequencer.js +54 -0
- package/dist/esm/test/shard-durations.json +922 -0
- package/dist/esm/test/worker-budget.d.ts +6 -0
- package/dist/esm/test/worker-budget.js +59 -1
- package/dist/esm/test-helpers/global-setup.d.ts +1 -1
- package/dist/esm/test-helpers/global-setup.js +68 -24
- package/dist/esm/ultragoal/service.d.ts +7 -0
- package/dist/esm/ultragoal/service.js +42 -2
- package/dist/esm/utils/write-json-file.js +3 -1
- package/dist/esm/worktrees/codex-project-trust.d.ts +15 -0
- package/dist/esm/worktrees/codex-project-trust.js +56 -0
- package/dist/esm/worktrees/registry.d.ts +8 -0
- package/dist/esm/worktrees/registry.js +18 -3
- package/package.json +16 -13
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
* is enforced by `_names.test.ts` against `COMPILED_TOOL_REGISTRY`, so this list
|
|
9
9
|
* cannot silently drift.
|
|
10
10
|
*/
|
|
11
|
-
export declare const WP_TOOL_NAMES: readonly ["wp_audit", "wp_audits", "wp_bench", "wp_ci_act", "wp_e2e", "wp_fleet_status", "wp_format", "wp_gain", "wp_lint", "wp_pr_status", "wp_pr_upsert", "wp_pr_wait", "wp_qa", "wp_release_readiness", "wp_session_batch_execute", "wp_session_capture", "wp_session_context", "wp_session_doctor", "wp_session_execute", "wp_session_execute_file", "wp_session_fetch_and_index", "wp_session_index", "wp_session_purge", "wp_session_retrieve", "wp_session_restore", "wp_session_search", "wp_session_snapshot", "wp_session_stats", "wp_test", "wp_typecheck", "wp_ultragoal_cancel", "wp_ultragoal_handoff", "wp_ultragoal_new", "wp_ultragoal_run", "wp_ultragoal_status", "wp_worker_tail", "wp_worktree"];
|
|
11
|
+
export declare const WP_TOOL_NAMES: readonly ["wp_audit", "wp_audits", "wp_bench", "wp_ci_act", "wp_ci_preflight", "wp_e2e", "wp_fleet_status", "wp_format", "wp_gain", "wp_lint", "wp_pr_status", "wp_pr_upsert", "wp_pr_wait", "wp_qa", "wp_release_readiness", "wp_review_run", "wp_run_wait", "wp_session_batch_execute", "wp_session_capture", "wp_session_context", "wp_session_doctor", "wp_session_execute", "wp_session_execute_file", "wp_session_fetch_and_index", "wp_session_id", "wp_session_index", "wp_session_info", "wp_session_purge", "wp_session_retrieve", "wp_session_restore", "wp_session_search", "wp_session_snapshot", "wp_session_stats", "wp_test", "wp_typecheck", "wp_ultragoal_cancel", "wp_ultragoal_handoff", "wp_ultragoal_new", "wp_ultragoal_run", "wp_ultragoal_status", "wp_worker_tail", "wp_worktree"];
|
|
@@ -13,6 +13,7 @@ export const WP_TOOL_NAMES = [
|
|
|
13
13
|
"wp_audits",
|
|
14
14
|
"wp_bench",
|
|
15
15
|
"wp_ci_act",
|
|
16
|
+
"wp_ci_preflight",
|
|
16
17
|
"wp_e2e",
|
|
17
18
|
"wp_fleet_status",
|
|
18
19
|
"wp_format",
|
|
@@ -23,6 +24,8 @@ export const WP_TOOL_NAMES = [
|
|
|
23
24
|
"wp_pr_wait",
|
|
24
25
|
"wp_qa",
|
|
25
26
|
"wp_release_readiness",
|
|
27
|
+
"wp_review_run",
|
|
28
|
+
"wp_run_wait",
|
|
26
29
|
"wp_session_batch_execute",
|
|
27
30
|
"wp_session_capture",
|
|
28
31
|
"wp_session_context",
|
|
@@ -30,7 +33,9 @@ export const WP_TOOL_NAMES = [
|
|
|
30
33
|
"wp_session_execute",
|
|
31
34
|
"wp_session_execute_file",
|
|
32
35
|
"wp_session_fetch_and_index",
|
|
36
|
+
"wp_session_id",
|
|
33
37
|
"wp_session_index",
|
|
38
|
+
"wp_session_info",
|
|
34
39
|
"wp_session_purge",
|
|
35
40
|
"wp_session_retrieve",
|
|
36
41
|
"wp_session_restore",
|
|
@@ -2,6 +2,7 @@ import audit from "./audit.js";
|
|
|
2
2
|
import audits from "./audits.js";
|
|
3
3
|
import bench from "./bench.js";
|
|
4
4
|
import ciAct from "./ci-act.js";
|
|
5
|
+
import ciPreflight from "./ci-preflight.js";
|
|
5
6
|
import e2e from "./e2e.js";
|
|
6
7
|
import format from "./format.js";
|
|
7
8
|
import fleet from "./fleet.js";
|
|
@@ -12,6 +13,8 @@ import prUpsert from "./pr-upsert.js";
|
|
|
12
13
|
import prWait from "./pr-wait.js";
|
|
13
14
|
import qa from "./qa.js";
|
|
14
15
|
import releaseReadiness from "./release-readiness.js";
|
|
16
|
+
import reviewRun from "./review-run.js";
|
|
17
|
+
import runWait from "./run-wait.js";
|
|
15
18
|
import sessionBatchExecute from "./session-batch-execute.js";
|
|
16
19
|
import sessionCapture from "./session-capture.js";
|
|
17
20
|
import sessionContext from "./session-context.js";
|
|
@@ -19,7 +22,9 @@ import sessionDoctor from "./session-doctor.js";
|
|
|
19
22
|
import sessionExecute from "./session-execute.js";
|
|
20
23
|
import sessionExecuteFile from "./session-execute-file.js";
|
|
21
24
|
import sessionFetchAndIndex from "./session-fetch-and-index.js";
|
|
25
|
+
import sessionId from "./session-id.js";
|
|
22
26
|
import sessionIndex from "./session-index.js";
|
|
27
|
+
import sessionInfo from "./session-info.js";
|
|
23
28
|
import sessionPurge from "./session-purge.js";
|
|
24
29
|
import sessionRetrieve from "./session-retrieve.js";
|
|
25
30
|
import sessionRestore from "./session-restore.js";
|
|
@@ -40,6 +45,7 @@ export const COMPILED_TOOL_REGISTRY = [
|
|
|
40
45
|
audits,
|
|
41
46
|
bench,
|
|
42
47
|
ciAct,
|
|
48
|
+
ciPreflight,
|
|
43
49
|
e2e,
|
|
44
50
|
fleet,
|
|
45
51
|
format,
|
|
@@ -50,6 +56,8 @@ export const COMPILED_TOOL_REGISTRY = [
|
|
|
50
56
|
prWait,
|
|
51
57
|
qa,
|
|
52
58
|
releaseReadiness,
|
|
59
|
+
reviewRun,
|
|
60
|
+
runWait,
|
|
53
61
|
sessionBatchExecute,
|
|
54
62
|
sessionCapture,
|
|
55
63
|
sessionContext,
|
|
@@ -57,7 +65,9 @@ export const COMPILED_TOOL_REGISTRY = [
|
|
|
57
65
|
sessionExecute,
|
|
58
66
|
sessionExecuteFile,
|
|
59
67
|
sessionFetchAndIndex,
|
|
68
|
+
sessionId,
|
|
60
69
|
sessionIndex,
|
|
70
|
+
sessionInfo,
|
|
61
71
|
sessionPurge,
|
|
62
72
|
sessionRetrieve,
|
|
63
73
|
sessionRestore,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const MCP_AUDIT_KINDS: readonly ["test-smells", "tph-e2e", "agents", "catalog-drift", "package-surface", "reference-parity-matrix", "docs-frontmatter", "blueprint-readme-drift", "blueprint-pr-coverage", "blueprint-lifecycle", "blueprint-trust", "architecture-drift", "cloudflare-deploy-contract", "absolute-path-policy", "no-first-party-mjs", "no-math-random", "roadmap-links", "bundle-budget", "commit-message", "tech-debt", "supported-agent-clis", "hook-surface", "harness-surfaces", "weakness-mining", "harness-overlay-evidence", "ai-contracts", "atomic-state-writes", "no-relative-package-scripts", "toolchain-isolation", "open-source-licenses", "secrets-policy", "no-dev-vars", "github-actions-secrets", "secret-provider-quarantine", "security-quality-regressions", "secrets-config", "consumer-agent-kit-dependency", "ci-test-perf", "test-scan-perf", "session-memory-hardcut", "worktree-main-ownership", "sast"];
|
|
1
|
+
export declare const MCP_AUDIT_KINDS: readonly ["test-smells", "tph-e2e", "agents", "catalog-drift", "package-surface", "reference-parity-matrix", "docs-frontmatter", "blueprint-readme-drift", "blueprint-pr-coverage", "blueprint-lifecycle", "blueprint-trust", "architecture-drift", "cloudflare-deploy-contract", "absolute-path-policy", "no-first-party-mjs", "no-math-random", "roadmap-links", "bundle-budget", "commit-message", "tech-debt", "supported-agent-clis", "hook-surface", "harness-surfaces", "weakness-mining", "harness-overlay-evidence", "host-substitution-risk", "ai-contracts", "atomic-state-writes", "no-relative-package-scripts", "toolchain-isolation", "open-source-licenses", "secrets-policy", "no-dev-vars", "github-actions-secrets", "secret-provider-quarantine", "security-quality-regressions", "secrets-config", "consumer-agent-kit-dependency", "ci-test-perf", "test-scan-perf", "session-memory-hardcut", "worktree-main-ownership", "typescript-version", "ci-guardrails-wiring", "sast"];
|
|
2
2
|
export type MCPAuditKind = (typeof MCP_AUDIT_KINDS)[number];
|
|
3
3
|
export declare function isMCPAuditKind(value: string): value is MCPAuditKind;
|
|
@@ -82,8 +82,51 @@ export function clipRawOutput(rawOutput, maxChars = DEFAULT_RAW_OUTPUT_LIMIT, op
|
|
|
82
82
|
...(recorded?.warning ? { warnings: [recorded.warning] } : {}),
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Maximum bytes of serialized `details` appended to an ERROR result's text
|
|
87
|
+
* content. Generous enough to carry a full validation-error array or a failed
|
|
88
|
+
* command record, small enough that a pathological payload cannot flood the
|
|
89
|
+
* caller's context.
|
|
90
|
+
*/
|
|
91
|
+
const ERROR_DETAIL_TEXT_LIMIT = 2_000;
|
|
92
|
+
/**
|
|
93
|
+
* Render the actionable part of a failing payload for the text `content`.
|
|
94
|
+
*
|
|
95
|
+
* MCP hosts surface `content` (not `structuredContent`) when `isError` is set,
|
|
96
|
+
* so an error whose text is only the one-line `summary` forces the caller to
|
|
97
|
+
* go read the tool's source to learn WHAT failed — e.g. `wp_pr_upsert`
|
|
98
|
+
* returning bare "PR description validation failed; no GitHub mutation was
|
|
99
|
+
* attempted" while `details.validation.errors` held the exact missing fields.
|
|
100
|
+
* That round trip is pure wasted context. Fold the details into the text so
|
|
101
|
+
* one call is enough.
|
|
102
|
+
*/
|
|
103
|
+
function renderErrorDetail(payload) {
|
|
104
|
+
const details = payload.details;
|
|
105
|
+
if (details === undefined || details === null)
|
|
106
|
+
return undefined;
|
|
107
|
+
let serialized;
|
|
108
|
+
try {
|
|
109
|
+
// Compact (no pretty-print indentation): keeps the payload cheap in the
|
|
110
|
+
// caller's context, and avoids emitting whitespace runs that never came
|
|
111
|
+
// from the data — `session-index.test.ts` asserts a whitespace-only INPUT
|
|
112
|
+
// is not echoed back, which indented output would trip incidentally.
|
|
113
|
+
serialized = JSON.stringify(details);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return undefined; // circular/unserializable — summary alone still ships
|
|
117
|
+
}
|
|
118
|
+
if (!serialized || serialized === "{}" || serialized === "[]")
|
|
119
|
+
return undefined;
|
|
120
|
+
return serialized.length <= ERROR_DETAIL_TEXT_LIMIT
|
|
121
|
+
? serialized
|
|
122
|
+
: `${serialized.slice(0, ERROR_DETAIL_TEXT_LIMIT - 1)}…`;
|
|
123
|
+
}
|
|
85
124
|
export function createSummaryResult(payload, options = {}) {
|
|
86
|
-
const
|
|
125
|
+
const summaryText = clipSummaryText(options.text ?? payload.summary);
|
|
126
|
+
// Only errors get the detail block: success results are already summary-first
|
|
127
|
+
// by design, and their details are available via `structuredContent`.
|
|
128
|
+
const detail = options.isError ? renderErrorDetail(payload) : undefined;
|
|
129
|
+
const text = detail ? `${summaryText}\n\n${detail}` : summaryText;
|
|
87
130
|
return {
|
|
88
131
|
content: [{ type: "text", text }],
|
|
89
132
|
structuredContent: payload,
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { z } from "zod";
|
|
17
17
|
import type { ToolDescriptor } from "#mcp/auto-discover";
|
|
18
|
-
export declare const KINDS: readonly ["test-smells", "tph-e2e", "agents", "catalog-drift", "package-surface", "reference-parity-matrix", "docs-frontmatter", "blueprint-readme-drift", "blueprint-pr-coverage", "blueprint-lifecycle", "blueprint-trust", "architecture-drift", "cloudflare-deploy-contract", "absolute-path-policy", "no-first-party-mjs", "no-math-random", "roadmap-links", "bundle-budget", "commit-message", "tech-debt", "supported-agent-clis", "hook-surface", "harness-surfaces", "weakness-mining", "harness-overlay-evidence", "ai-contracts", "atomic-state-writes", "no-relative-package-scripts", "toolchain-isolation", "open-source-licenses", "secrets-policy", "no-dev-vars", "github-actions-secrets", "secret-provider-quarantine", "security-quality-regressions", "secrets-config", "consumer-agent-kit-dependency", "ci-test-perf", "test-scan-perf", "session-memory-hardcut", "worktree-main-ownership", "sast"];
|
|
18
|
+
export declare const KINDS: readonly ["test-smells", "tph-e2e", "agents", "catalog-drift", "package-surface", "reference-parity-matrix", "docs-frontmatter", "blueprint-readme-drift", "blueprint-pr-coverage", "blueprint-lifecycle", "blueprint-trust", "architecture-drift", "cloudflare-deploy-contract", "absolute-path-policy", "no-first-party-mjs", "no-math-random", "roadmap-links", "bundle-budget", "commit-message", "tech-debt", "supported-agent-clis", "hook-surface", "harness-surfaces", "weakness-mining", "harness-overlay-evidence", "host-substitution-risk", "ai-contracts", "atomic-state-writes", "no-relative-package-scripts", "toolchain-isolation", "open-source-licenses", "secrets-policy", "no-dev-vars", "github-actions-secrets", "secret-provider-quarantine", "security-quality-regressions", "secrets-config", "consumer-agent-kit-dependency", "ci-test-perf", "test-scan-perf", "session-memory-hardcut", "worktree-main-ownership", "typescript-version", "ci-guardrails-wiring", "sast"];
|
|
19
19
|
export declare const inputSchema: z.ZodObject<{
|
|
20
20
|
kind: z.ZodEnum<{
|
|
21
21
|
"absolute-path-policy": "absolute-path-policy";
|
|
@@ -29,6 +29,7 @@ export declare const inputSchema: z.ZodObject<{
|
|
|
29
29
|
"blueprint-trust": "blueprint-trust";
|
|
30
30
|
"bundle-budget": "bundle-budget";
|
|
31
31
|
"catalog-drift": "catalog-drift";
|
|
32
|
+
"ci-guardrails-wiring": "ci-guardrails-wiring";
|
|
32
33
|
"ci-test-perf": "ci-test-perf";
|
|
33
34
|
"cloudflare-deploy-contract": "cloudflare-deploy-contract";
|
|
34
35
|
"commit-message": "commit-message";
|
|
@@ -38,6 +39,7 @@ export declare const inputSchema: z.ZodObject<{
|
|
|
38
39
|
"harness-overlay-evidence": "harness-overlay-evidence";
|
|
39
40
|
"harness-surfaces": "harness-surfaces";
|
|
40
41
|
"hook-surface": "hook-surface";
|
|
42
|
+
"host-substitution-risk": "host-substitution-risk";
|
|
41
43
|
"no-dev-vars": "no-dev-vars";
|
|
42
44
|
"no-first-party-mjs": "no-first-party-mjs";
|
|
43
45
|
"no-math-random": "no-math-random";
|
|
@@ -58,6 +60,7 @@ export declare const inputSchema: z.ZodObject<{
|
|
|
58
60
|
"test-smells": "test-smells";
|
|
59
61
|
"toolchain-isolation": "toolchain-isolation";
|
|
60
62
|
"tph-e2e": "tph-e2e";
|
|
63
|
+
"typescript-version": "typescript-version";
|
|
61
64
|
"weakness-mining": "weakness-mining";
|
|
62
65
|
"worktree-main-ownership": "worktree-main-ownership";
|
|
63
66
|
}>;
|
|
@@ -128,6 +128,16 @@ export async function dispatchAudit(input) {
|
|
|
128
128
|
details: auditResult,
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
|
+
case "host-substitution-risk": {
|
|
132
|
+
const { auditHostSubstitutionRisk } = await import("#audit/host-substitution-risk");
|
|
133
|
+
const auditResult = auditHostSubstitutionRisk(input.cwd ?? input.directory ?? process.cwd());
|
|
134
|
+
return {
|
|
135
|
+
passed: auditResult.ok,
|
|
136
|
+
summary: summarizeRepoAudit(kind, auditResult),
|
|
137
|
+
kind,
|
|
138
|
+
details: auditResult,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
131
141
|
case "agents": {
|
|
132
142
|
const { auditAgents } = await import("#audit/agents");
|
|
133
143
|
const auditResult = auditAgents(input.cwd ?? input.directory ?? process.cwd());
|
|
@@ -464,6 +474,16 @@ export async function dispatchAudit(input) {
|
|
|
464
474
|
details: auditResult,
|
|
465
475
|
};
|
|
466
476
|
}
|
|
477
|
+
case "ci-guardrails-wiring": {
|
|
478
|
+
const { auditCiGuardrailsWiring } = await import("#audit/ci-guardrails-wiring");
|
|
479
|
+
const auditResult = auditCiGuardrailsWiring(input.cwd ?? input.directory ?? process.cwd());
|
|
480
|
+
return {
|
|
481
|
+
passed: auditResult.ok,
|
|
482
|
+
summary: summarizeRepoAudit(kind, auditResult),
|
|
483
|
+
kind,
|
|
484
|
+
details: auditResult,
|
|
485
|
+
};
|
|
486
|
+
}
|
|
467
487
|
case "test-scan-perf": {
|
|
468
488
|
const { auditTestScanPerf } = await import("#audit/test-scan-perf");
|
|
469
489
|
const auditResult = auditTestScanPerf(input.cwd ?? input.directory ?? process.cwd());
|
|
@@ -539,6 +559,16 @@ export async function dispatchAudit(input) {
|
|
|
539
559
|
},
|
|
540
560
|
};
|
|
541
561
|
}
|
|
562
|
+
case "typescript-version": {
|
|
563
|
+
const { auditTypescriptVersion } = await import("#audit/typescript-version");
|
|
564
|
+
const auditResult = auditTypescriptVersion(input.cwd ?? input.directory ?? process.cwd());
|
|
565
|
+
return {
|
|
566
|
+
passed: auditResult.ok,
|
|
567
|
+
summary: summarizeRepoAudit(kind, auditResult),
|
|
568
|
+
kind,
|
|
569
|
+
details: auditResult,
|
|
570
|
+
};
|
|
571
|
+
}
|
|
542
572
|
default: {
|
|
543
573
|
// Exhaustiveness check — z.enum should make this unreachable.
|
|
544
574
|
const _exhaustive = kind;
|
|
@@ -25,6 +25,7 @@ declare const inputSchema: z.ZodObject<{
|
|
|
25
25
|
"blueprint-trust": "blueprint-trust";
|
|
26
26
|
"bundle-budget": "bundle-budget";
|
|
27
27
|
"catalog-drift": "catalog-drift";
|
|
28
|
+
"ci-guardrails-wiring": "ci-guardrails-wiring";
|
|
28
29
|
"ci-test-perf": "ci-test-perf";
|
|
29
30
|
"cloudflare-deploy-contract": "cloudflare-deploy-contract";
|
|
30
31
|
"commit-message": "commit-message";
|
|
@@ -34,6 +35,7 @@ declare const inputSchema: z.ZodObject<{
|
|
|
34
35
|
"harness-overlay-evidence": "harness-overlay-evidence";
|
|
35
36
|
"harness-surfaces": "harness-surfaces";
|
|
36
37
|
"hook-surface": "hook-surface";
|
|
38
|
+
"host-substitution-risk": "host-substitution-risk";
|
|
37
39
|
"no-dev-vars": "no-dev-vars";
|
|
38
40
|
"no-first-party-mjs": "no-first-party-mjs";
|
|
39
41
|
"no-math-random": "no-math-random";
|
|
@@ -54,6 +56,7 @@ declare const inputSchema: z.ZodObject<{
|
|
|
54
56
|
"test-smells": "test-smells";
|
|
55
57
|
"toolchain-isolation": "toolchain-isolation";
|
|
56
58
|
"tph-e2e": "tph-e2e";
|
|
59
|
+
"typescript-version": "typescript-version";
|
|
57
60
|
"weakness-mining": "weakness-mining";
|
|
58
61
|
"worktree-main-ownership": "worktree-main-ownership";
|
|
59
62
|
}>>>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `wp_ci_preflight` MCP tool.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `runCiPreflight` (the single owner of the pre-push gate — see
|
|
5
|
+
* `src/cli/commands/ci-preflight.ts`) so agents can run the exact fail-fast,
|
|
6
|
+
* branch-scoped sequence CI mirrors — `format → guardrails → typecheck →
|
|
7
|
+
* lint → test` — without shelling out to `wp ci-preflight` via Bash.
|
|
8
|
+
*
|
|
9
|
+
* `runCiPreflight`'s default `runCheck` re-invokes `wp <subcommand>` via
|
|
10
|
+
* `spawnSync(..., {stdio: "inherit"})`. That is correct for a real terminal
|
|
11
|
+
* but unsafe here: `wp mcp` speaks stdio-transport JSON-RPC over the process's
|
|
12
|
+
* real stdout, and an inherited child write would corrupt that stream. This
|
|
13
|
+
* tool substitutes a `runCheck` that spawns each stage asynchronously via the
|
|
14
|
+
* shared `runCommand` helper (captured stdout/stderr, a bounded per-stage
|
|
15
|
+
* timeout, and `extra.signal` cancellation) using the same `wp` launcher
|
|
16
|
+
* resolution (`resolveWpLauncher`) the CLI uses, so behavior stays identical
|
|
17
|
+
* — only the transport of the output changes. `runCiPreflight`'s own
|
|
18
|
+
* `stdout`/`stderr` deps are swallowed for the same reason (they default to
|
|
19
|
+
* `process.stdout`/`process.stderr`); the equivalent progress detail is
|
|
20
|
+
* reconstructed from the per-stage results this tool collects itself.
|
|
21
|
+
*
|
|
22
|
+
* `runCiPreflight` returns only an exit code — there is no structured
|
|
23
|
+
* per-stage payload to "pass through." The `{passed, summary, details:
|
|
24
|
+
* {stages, stoppedAt}}` shape below mirrors `wp_qa`'s aggregate-gate
|
|
25
|
+
* convention (structured pass/fail + per-stage breakdown) since ci-preflight
|
|
26
|
+
* is the same shape of thing: a staged composite gate, just sequential and
|
|
27
|
+
* fail-fast instead of `wp_qa`'s parallel `Promise.all`.
|
|
28
|
+
*/
|
|
29
|
+
import { z } from "zod";
|
|
30
|
+
import type { ToolDescriptor } from "#mcp/auto-discover";
|
|
31
|
+
declare const inputSchema: z.ZodObject<{
|
|
32
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
33
|
+
full: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export type AkCiPreflightInput = z.infer<typeof inputSchema>;
|
|
36
|
+
declare const stageResultSchema: z.ZodObject<{
|
|
37
|
+
label: z.ZodString;
|
|
38
|
+
args: z.ZodArray<z.ZodString>;
|
|
39
|
+
passed: z.ZodBoolean;
|
|
40
|
+
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
timedOut: z.ZodOptional<z.ZodBoolean>;
|
|
42
|
+
aborted: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
+
spawnError: z.ZodOptional<z.ZodString>;
|
|
44
|
+
rawOutput: z.ZodOptional<z.ZodString>;
|
|
45
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
logPath: z.ZodOptional<z.ZodString>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export type CiPreflightStageResult = z.infer<typeof stageResultSchema>;
|
|
49
|
+
declare const tool: ToolDescriptor;
|
|
50
|
+
export default tool;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `wp_ci_preflight` MCP tool.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `runCiPreflight` (the single owner of the pre-push gate — see
|
|
5
|
+
* `src/cli/commands/ci-preflight.ts`) so agents can run the exact fail-fast,
|
|
6
|
+
* branch-scoped sequence CI mirrors — `format → guardrails → typecheck →
|
|
7
|
+
* lint → test` — without shelling out to `wp ci-preflight` via Bash.
|
|
8
|
+
*
|
|
9
|
+
* `runCiPreflight`'s default `runCheck` re-invokes `wp <subcommand>` via
|
|
10
|
+
* `spawnSync(..., {stdio: "inherit"})`. That is correct for a real terminal
|
|
11
|
+
* but unsafe here: `wp mcp` speaks stdio-transport JSON-RPC over the process's
|
|
12
|
+
* real stdout, and an inherited child write would corrupt that stream. This
|
|
13
|
+
* tool substitutes a `runCheck` that spawns each stage asynchronously via the
|
|
14
|
+
* shared `runCommand` helper (captured stdout/stderr, a bounded per-stage
|
|
15
|
+
* timeout, and `extra.signal` cancellation) using the same `wp` launcher
|
|
16
|
+
* resolution (`resolveWpLauncher`) the CLI uses, so behavior stays identical
|
|
17
|
+
* — only the transport of the output changes. `runCiPreflight`'s own
|
|
18
|
+
* `stdout`/`stderr` deps are swallowed for the same reason (they default to
|
|
19
|
+
* `process.stdout`/`process.stderr`); the equivalent progress detail is
|
|
20
|
+
* reconstructed from the per-stage results this tool collects itself.
|
|
21
|
+
*
|
|
22
|
+
* `runCiPreflight` returns only an exit code — there is no structured
|
|
23
|
+
* per-stage payload to "pass through." The `{passed, summary, details:
|
|
24
|
+
* {stages, stoppedAt}}` shape below mirrors `wp_qa`'s aggregate-gate
|
|
25
|
+
* convention (structured pass/fail + per-stage breakdown) since ci-preflight
|
|
26
|
+
* is the same shape of thing: a staged composite gate, just sequential and
|
|
27
|
+
* fail-fast instead of `wp_qa`'s parallel `Promise.all`.
|
|
28
|
+
*/
|
|
29
|
+
import { existsSync } from "node:fs";
|
|
30
|
+
import { join } from "node:path";
|
|
31
|
+
import { z } from "zod";
|
|
32
|
+
import { resolveWpLauncher, runCiPreflight, } from "#cli/commands/ci-preflight.js";
|
|
33
|
+
import { formatMcpToolOutput } from "./_shared/full-output.js";
|
|
34
|
+
import { resolveProjectRoot } from "./_shared/project-root.js";
|
|
35
|
+
import { createSummaryOutputSchema, createSummaryResult } from "./_shared/result.js";
|
|
36
|
+
import { isRunFailure, runCommand } from "./_shared/run-command.js";
|
|
37
|
+
const inputSchema = z.object({
|
|
38
|
+
cwd: z.string().optional(),
|
|
39
|
+
full: z.boolean().optional().default(false),
|
|
40
|
+
});
|
|
41
|
+
// Generous but bounded: mirrors `wp_typecheck`'s cap (the heaviest single
|
|
42
|
+
// sibling stage). In normal operation every stage here is branch-scoped
|
|
43
|
+
// (`--affected --branch`) so real runs finish in seconds to low minutes; this
|
|
44
|
+
// cap only exists to convert a hang into a diagnosable `timedOut: true`
|
|
45
|
+
// instead of blocking the MCP transport indefinitely. Applied per-stage (not
|
|
46
|
+
// as one combined budget) so an early hang doesn't eat the time later stages
|
|
47
|
+
// would have needed.
|
|
48
|
+
const CI_PREFLIGHT_STAGE_TIMEOUT_MS = 10 * 60 * 1_000;
|
|
49
|
+
const stageResultSchema = z.object({
|
|
50
|
+
label: z.string(),
|
|
51
|
+
args: z.array(z.string()),
|
|
52
|
+
passed: z.boolean(),
|
|
53
|
+
exitCode: z.number().optional(),
|
|
54
|
+
timedOut: z.boolean().optional(),
|
|
55
|
+
aborted: z.boolean().optional(),
|
|
56
|
+
spawnError: z.string().optional(),
|
|
57
|
+
rawOutput: z.string().optional(),
|
|
58
|
+
truncated: z.boolean().optional(),
|
|
59
|
+
logPath: z.string().optional(),
|
|
60
|
+
});
|
|
61
|
+
const outputSchema = createSummaryOutputSchema({
|
|
62
|
+
details: z.object({
|
|
63
|
+
stages: z.array(stageResultSchema),
|
|
64
|
+
stoppedAt: z.string().optional(),
|
|
65
|
+
bootstrapError: z.string().optional(),
|
|
66
|
+
}),
|
|
67
|
+
});
|
|
68
|
+
const noopWritable = { write: () => true };
|
|
69
|
+
/**
|
|
70
|
+
* Build the `runCheck` substitution: same stages, same launcher, same
|
|
71
|
+
* fail-fast contract as the CLI's `defaultRunCheck` — just async and
|
|
72
|
+
* output-capturing instead of `spawnSync(..., {stdio: "inherit"})`.
|
|
73
|
+
*/
|
|
74
|
+
function buildCapturingRunCheck(stages, options) {
|
|
75
|
+
return async (check, repoRoot) => {
|
|
76
|
+
const launcher = resolveWpLauncher(repoRoot);
|
|
77
|
+
const outcome = await runCommand(launcher.command, [...launcher.prefixArgs, ...check.args], {
|
|
78
|
+
timeoutMs: options.timeoutMs,
|
|
79
|
+
signal: options.signal,
|
|
80
|
+
cwd: repoRoot,
|
|
81
|
+
});
|
|
82
|
+
if (isRunFailure(outcome)) {
|
|
83
|
+
const spawnError = `${outcome.error.code ?? "unknown"} ${outcome.error.message}`;
|
|
84
|
+
stages.push({ label: check.label, args: [...check.args], passed: false, spawnError });
|
|
85
|
+
return 1;
|
|
86
|
+
}
|
|
87
|
+
const combined = [outcome.stdout, outcome.stderr].filter(Boolean).join("\n");
|
|
88
|
+
const compact = formatMcpToolOutput(combined, {
|
|
89
|
+
toolName: `wp_ci_preflight-${check.label}`,
|
|
90
|
+
full: options.full,
|
|
91
|
+
cwd: repoRoot,
|
|
92
|
+
});
|
|
93
|
+
stages.push({
|
|
94
|
+
label: check.label,
|
|
95
|
+
args: [...check.args],
|
|
96
|
+
passed: outcome.exitCode === 0,
|
|
97
|
+
exitCode: outcome.exitCode,
|
|
98
|
+
...(outcome.timedOut ? { timedOut: true } : {}),
|
|
99
|
+
...(outcome.aborted ? { aborted: true } : {}),
|
|
100
|
+
...compact,
|
|
101
|
+
});
|
|
102
|
+
return outcome.exitCode;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function summarizeCiPreflight(stages, bootstrapError) {
|
|
106
|
+
if (bootstrapError)
|
|
107
|
+
return bootstrapError;
|
|
108
|
+
if (stages.length === 0)
|
|
109
|
+
return "ci-preflight did not run any checks";
|
|
110
|
+
const failed = stages.find((stage) => !stage.passed);
|
|
111
|
+
if (!failed)
|
|
112
|
+
return `ci-preflight passed (${stages.map((stage) => stage.label).join(", ")})`;
|
|
113
|
+
if (failed.spawnError)
|
|
114
|
+
return `ci-preflight could not start ${failed.label}: ${failed.spawnError}`;
|
|
115
|
+
if (failed.timedOut)
|
|
116
|
+
return `ci-preflight: ${failed.label} timed out`;
|
|
117
|
+
if (failed.aborted)
|
|
118
|
+
return `ci-preflight: ${failed.label} aborted`;
|
|
119
|
+
return `ci-preflight failed at ${failed.label} (exit ${failed.exitCode ?? "unknown"})`;
|
|
120
|
+
}
|
|
121
|
+
const tool = {
|
|
122
|
+
name: "wp_ci_preflight",
|
|
123
|
+
description: "Run the locally-runnable required CI checks, fail-fast, branch-scoped: `format → audit guardrails → typecheck → lint → test` (mirrors `.husky/pre-push`). Returns `{passed, summary, details: {stages, stoppedAt}}`. Use before push / PR open-update; prefer over `wp_qa` when you need pre-push parity (branch-scoped `--affected --branch`, sequential fail-fast) rather than `wp_qa`'s parallel whole-scope lint+typecheck+test; run `wp ci-preflight` directly only if this tool is unavailable.",
|
|
124
|
+
inputSchema,
|
|
125
|
+
outputSchema,
|
|
126
|
+
annotations: {
|
|
127
|
+
title: "CI preflight (pre-push gate)",
|
|
128
|
+
readOnlyHint: true,
|
|
129
|
+
destructiveHint: false,
|
|
130
|
+
idempotentHint: true,
|
|
131
|
+
openWorldHint: false,
|
|
132
|
+
},
|
|
133
|
+
handler: async (raw, extra) => {
|
|
134
|
+
const input = inputSchema.parse(raw ?? {});
|
|
135
|
+
const cwd = resolveProjectRoot(input.cwd ? { cwd: input.cwd } : {});
|
|
136
|
+
const stages = [];
|
|
137
|
+
let bootstrapError;
|
|
138
|
+
const runCheck = buildCapturingRunCheck(stages, {
|
|
139
|
+
timeoutMs: CI_PREFLIGHT_STAGE_TIMEOUT_MS,
|
|
140
|
+
signal: extra?.signal,
|
|
141
|
+
full: input.full,
|
|
142
|
+
});
|
|
143
|
+
const exitCode = await runCiPreflight({
|
|
144
|
+
cwd,
|
|
145
|
+
// Already resolved via the MCP-safe `resolveProjectRoot` walk above;
|
|
146
|
+
// re-resolving via git-topLevel here would risk landing on a different
|
|
147
|
+
// root than the one we're about to spawn stages in.
|
|
148
|
+
resolveRepoRoot: () => cwd,
|
|
149
|
+
hasNodeModules: (repoRoot) => {
|
|
150
|
+
const ok = existsSync(join(repoRoot, "node_modules"));
|
|
151
|
+
if (!ok) {
|
|
152
|
+
bootstrapError = `wp_ci_preflight: ${repoRoot} is not bootstrapped — node_modules is missing. Run \`vp install\` in this worktree first, then retry.`;
|
|
153
|
+
}
|
|
154
|
+
return ok;
|
|
155
|
+
},
|
|
156
|
+
runCheck,
|
|
157
|
+
// Swallow progress writes — they default to process.stdout/stderr,
|
|
158
|
+
// which on a stdio-transport MCP server IS the JSON-RPC channel. The
|
|
159
|
+
// equivalent detail is already captured per-stage above.
|
|
160
|
+
stdout: noopWritable,
|
|
161
|
+
stderr: noopWritable,
|
|
162
|
+
});
|
|
163
|
+
const passed = exitCode === 0;
|
|
164
|
+
const stoppedAt = passed ? undefined : stages.at(-1)?.label;
|
|
165
|
+
const payload = {
|
|
166
|
+
passed,
|
|
167
|
+
summary: summarizeCiPreflight(stages, bootstrapError),
|
|
168
|
+
exitCode,
|
|
169
|
+
details: {
|
|
170
|
+
stages,
|
|
171
|
+
...(stoppedAt ? { stoppedAt } : {}),
|
|
172
|
+
...(bootstrapError ? { bootstrapError } : {}),
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
// `isError: true` is reserved for "we couldn't run the gate at all"
|
|
176
|
+
// (not bootstrapped, or a stage's spawn itself failed) — matching
|
|
177
|
+
// `wp_qa`'s convention that a check legitimately reporting `passed: false`
|
|
178
|
+
// is normal output the agent should act on, not a tool-execution error.
|
|
179
|
+
const executionFailed = bootstrapError !== undefined || stages.some((stage) => stage.spawnError !== undefined);
|
|
180
|
+
return createSummaryResult(payload, executionFailed ? { isError: true } : {});
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
export default tool;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { prDescriptionInputSchema, renderAndValidatePrDescription, } from "#pr-description/contract.js";
|
|
4
|
+
import { readCurrentSessionId } from "#session-memory/current-session.js";
|
|
4
5
|
import { createSummaryOutputSchema, createSummaryResult } from "./_shared/result.js";
|
|
5
6
|
import { resolveProjectRoot } from "./_shared/project-root.js";
|
|
6
7
|
import { redactText } from "./_shared/redact.js";
|
|
@@ -58,6 +59,42 @@ function resolveCwd(input) {
|
|
|
58
59
|
function branchFor(input) {
|
|
59
60
|
return input.branch ?? "HEAD";
|
|
60
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Best-effort fill for an omitted `description.sessionId`, using the same
|
|
64
|
+
* lookup `wp_session_id` wraps. Never overrides an explicit value and never
|
|
65
|
+
* fights an explicit `Session-skip` (a caller who set a skip reason has
|
|
66
|
+
* already made a deliberate choice not to disclose a session id).
|
|
67
|
+
*
|
|
68
|
+
* This DOES change one previously-fail-closed case: an omitted `sessionId`
|
|
69
|
+
* with no `Session-skip` used to fail validation outright; it now silently
|
|
70
|
+
* passes when the current worktree has a resolvable id (which may be a prior,
|
|
71
|
+
* still-accurate-for-this-worktree id when no capture has happened yet in the
|
|
72
|
+
* live session) — this is the intended best-effort automation of the paste a
|
|
73
|
+
* caller would otherwise do by hand. When NO id resolves, the outcome is
|
|
74
|
+
* unchanged: the description is returned as-is and the pre-existing
|
|
75
|
+
* "missing sessionId" validation error still blocks the mutation. So the only
|
|
76
|
+
* new behavior is "fills a real gap"; it never manufactures a fake id and
|
|
77
|
+
* never converts a genuine miss into a silent success.
|
|
78
|
+
*/
|
|
79
|
+
function withAutoResolvedSessionId(input) {
|
|
80
|
+
const description = input.description;
|
|
81
|
+
if (description.sessionId?.trim())
|
|
82
|
+
return description;
|
|
83
|
+
if (description.sessionSkipReason?.trim())
|
|
84
|
+
return description;
|
|
85
|
+
try {
|
|
86
|
+
const sessionId = readCurrentSessionId(resolveCwd(input), process.env);
|
|
87
|
+
return sessionId ? { ...description, sessionId } : description;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
// Match this module's stderr-breadcrumb philosophy (see current-session.ts):
|
|
91
|
+
// a lookup throw degrades to "leave as-is" (fail-closed — validation then
|
|
92
|
+
// reports the missing sessionId), but is surfaced so a genuine store bug
|
|
93
|
+
// is not silently swallowed.
|
|
94
|
+
process.stderr.write(`[wp_pr_upsert] sessionId auto-resolve failed; leaving description unchanged: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
95
|
+
return description;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
61
98
|
function clipOutput(value, maxOutputBytes) {
|
|
62
99
|
const redacted = redactText(value.trim());
|
|
63
100
|
if (!redacted)
|
|
@@ -152,7 +189,8 @@ const tool = {
|
|
|
152
189
|
},
|
|
153
190
|
handler: async (raw, extra) => {
|
|
154
191
|
const input = inputSchema.parse(raw ?? {});
|
|
155
|
-
const
|
|
192
|
+
const description = withAutoResolvedSessionId(input);
|
|
193
|
+
const { body, validation } = renderAndValidatePrDescription(description);
|
|
156
194
|
const branch = branchFor(input);
|
|
157
195
|
const bodySha256 = bodyHash(body);
|
|
158
196
|
const commands = [];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `wp_review_run` MCP tool.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `runReviewRunCommand` — the exact runtime `wp review run` and
|
|
5
|
+
* `wp review gate` use — so MCP callers get a first-class outside-voice
|
|
6
|
+
* review primitive instead of shelling into a provider CLI directly. Two
|
|
7
|
+
* ergonomic improvements over the raw `wp review run` CLI:
|
|
8
|
+
*
|
|
9
|
+
* 1. Accepts `prompt` directly instead of requiring a `--prompt-file` on
|
|
10
|
+
* disk. The tool writes the prompt to a private temp file under the
|
|
11
|
+
* resolved `artifactRoot` itself (cleaned up after each stage), since
|
|
12
|
+
* `runReviewRunCommand` requires a real file to read over stdin.
|
|
13
|
+
* 2. By default runs a synthesized `probe` stage (cheap liveness check)
|
|
14
|
+
* followed by the `review` stage in ONE call — removing the two-step
|
|
15
|
+
* probe-then-review dance every consumer previously had to hand-roll in
|
|
16
|
+
* bash (see the `codex` skill's pre-fix version). If the probe fails,
|
|
17
|
+
* the review stage is never attempted. Pass `skipProbe: true` to go
|
|
18
|
+
* straight to `review` once a provider is known-warm, or pass an
|
|
19
|
+
* explicit `stage` for CLI-parity manual control.
|
|
20
|
+
*
|
|
21
|
+
* Provider fallback (e.g. Codex out of API credits) is a `provider`
|
|
22
|
+
* parameter change on this SAME tool call — never a raw shell-out to a
|
|
23
|
+
* different provider's CLI. `forbidden-commands.ts`'s
|
|
24
|
+
* `findReviewCliRedirect` enforces that on the Bash-tool side.
|
|
25
|
+
*/
|
|
26
|
+
import type { ToolDescriptor } from "#mcp/auto-discover";
|
|
27
|
+
declare const tool: ToolDescriptor;
|
|
28
|
+
export default tool;
|