god-prompt-mcp 1.2.1 → 1.4.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.
- package/README.md +45 -17
- package/bin/godprompt-proof.mjs +66 -1
- package/bin/godprompt-repo-map.mjs +125 -0
- package/dist/adversarial-planning.js +94 -0
- package/dist/agent-trajectory.js +128 -0
- package/dist/change-impact.js +134 -0
- package/dist/decision-support.js +40 -0
- package/dist/instruction-audit.js +97 -0
- package/dist/mcp-contract-audit.js +88 -0
- package/dist/quality-view.js +8 -0
- package/dist/server.js +2 -2
- package/dist/stdio.js +12 -0
- package/dist/tailored-guidance.js +14 -0
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -35,11 +35,20 @@ To buy the review, use the [US$49 one-time GitHub Sponsors tier](https://github.
|
|
|
35
35
|
| `assess_release_readiness` | Find blockers in reported CI, artifact provenance, rollback, migrations and approvals; never authorizes deployment (v1.2.0+) |
|
|
36
36
|
| `create_context_handoff` | Produce bounded cross-chat/agent state with best-effort secret redaction and explicit verification limitations (v1.2.0+) |
|
|
37
37
|
| `compare_evaluation_runs` | Compare caller-supplied paired cases and observed pass rates, durations and costs with sample-size warnings (v1.2.0+) |
|
|
38
|
+
| `audit_agent_trajectory` | Review bounded, sanitized agent event metadata for repeated failures, scope drift, stale checks and unsupported completion claims (v1.3.0+) |
|
|
39
|
+
| `trace_change_impact` | Use supplied dependencies, requirement mappings and test receipts to trace affected files and uncovered verification (v1.3.0+) |
|
|
40
|
+
| `review_mcp_tool_contracts` | Flag possible MCP schema, annotation and behavioral contract inconsistencies without invoking tools (v1.3.0+) |
|
|
41
|
+
| `audit_agent_instructions` | Inspect scoped caller-supplied instruction excerpts for duplicate rules, opposing constraints and suspicious bypasses (v1.3.0+) |
|
|
42
|
+
| `design_adversarial_tests` | Suggest bounded negative, boundary, property, metamorphic and trust-boundary cases; never run tests (v1.3.0+) |
|
|
38
43
|
|
|
39
44
|
> **Version 1.1.1:** `create_work_contract` and `review_work_evidence` expand the seven original MCP tools to nine. Older hosted or version-pinned installations may still expose only the original seven until separately updated. Both tools remain stateless and read-only, and neither independently authenticates caller-supplied evidence. See the [task-contract workflow and security limitations](docs/task-contracts.md).
|
|
40
45
|
|
|
41
46
|
**Version 1.2.1:** All seventeen public MCP tools are available, including the eight engineering-quality functions introduced in v1.2.0. This patch refines code-review signal precision, requirement-conflict detection and duplicate CI-check blocking without adding permissions or storage. The Codexify checkpoint remains an optional **stdio-only** eighteenth tool. Install a versioned MCP package or inspect the hosted `tools/list` response to determine which functions your client actually receives. None of the tools independently execute tests, inspect external repositories or authorize deployment. See the [toolkit QA and limitations](docs/qa/godprompt-public-toolkit-20261120.md). The OpenAI marketplace distribution remains a separate, Skill-only integration until its eventual dedicated upgrade.
|
|
42
47
|
|
|
48
|
+
**Version 1.3.0:** All **22 public read-only tools** are available from the published hosted MCP and npm stdio package. Five P4 diagnostics were added, with strict bounded output schemas and paired evaluation statistics. The optional local Codexify checkpoint is the 23rd tool **only when explicitly enabled** on local stdio. The remote MCP does not execute code, fetch repositories or approve changes. See [P4 evidence and release status](docs/roadmaps/godprompt-p4-agent-quality-20261120.md). The combined OpenAI Skill+MCP source package is ready for review, but the existing directory listing is still Skill-only; GHCR 1.3.0 publication is a separately manual step.
|
|
49
|
+
|
|
50
|
+
**Version 1.4.0 (P5 release candidate):** The public tool count remains **22**, with improved advisory trajectory diagnostics, optional accessible MCP Apps evidence display for two existing tools, and smaller task-specific guidance suggestions. The local npm distribution adds `godprompt-repo-map` to derive a bounded static JavaScript/TypeScript dependency map from an explicitly authorized checkout, and `godprompt-proof pack` to combine pinned GitHub evidence with optional Codexify receipts, invalidating contradictions. Both CLIs are **local opt-in**, not hosted MCP permissions. The free coding-agent benchmark runner and 12 deliberately failing grader microtasks help set up paired A/B evaluation; they do **not** prove a model productivity improvement. This release-candidate statement describes source features pending exact-head release verification.
|
|
51
|
+
|
|
43
52
|
### Optional local proof bridge (from v1.1.1)
|
|
44
53
|
|
|
45
54
|
The new **godprompt-proof** CLI (Node 22+, **no additional dependencies**) can normalize pinned GitHub CI checks and exported Codexify command receipts into inputs for the existing GodPrompt evidence reviewer. It also supports an optional **single 256 KiB local JSONL feedback file** for project-scoped generic lessons, **on-demand read-only metrics**, and **versioned workflow previews** from that same file (no telemetry or automatic rule changes). No database server, GPU, background worker or global telemetry is involved.
|
|
@@ -80,13 +89,13 @@ The hosted endpoint exposes the read-only GodPrompt tools included in its **curr
|
|
|
80
89
|
|
|
81
90
|
### Agent Skills over MCP (SEP-2640)
|
|
82
91
|
|
|
83
|
-
On MCP 2026-07-28, both the hosted and stdio servers advertise the Final `io.modelcontextprotocol/skills` extension from SEP-2640. Supporting clients can discover the same relevance-scoped `god-prompt` Agent Skill with `skills/list` / `skills/get`, then fetch `SKILL.md` and its three reference files through `resources/read`. The skill manifest includes SHA-256 digests and exact byte sizes so clients can verify what they import. Clients that do not implement this extension continue to use the
|
|
92
|
+
On MCP 2026-07-28, both the hosted and stdio servers advertise the Final `io.modelcontextprotocol/skills` extension from SEP-2640. Supporting clients can discover the same relevance-scoped `god-prompt` Agent Skill with `skills/list` / `skills/get`, then fetch `SKILL.md` and its three reference files through `resources/read`. The skill manifest includes SHA-256 digests and exact byte sizes so clients can verify what they import. Clients that do not implement this extension continue to use the 22 public GodPrompt tools normally.
|
|
84
93
|
|
|
85
94
|
This transports GodPrompt's existing skill package; it does not force the skill into every request or change the host's own approval, verification, or activation policy. See the [MCP Skills extension specification](https://modelcontextprotocol.io/extensions/skills/overview).
|
|
86
95
|
|
|
87
96
|
### ChatGPT Plugin Directory (skill-only)
|
|
88
97
|
|
|
89
|
-
For the lowest-friction ChatGPT path, install [GodPrompt from the first-party Plugin Directory](https://chatgpt.com/plugins/plugins_6ab2f1cc5d0081919d729fd1c2884f86). That published plugin carries the scoped `god-prompt` Agent Skill; use the custom MCP app setup below when you specifically want the
|
|
98
|
+
For the lowest-friction ChatGPT path, install [GodPrompt from the first-party Plugin Directory](https://chatgpt.com/plugins/plugins_6ab2f1cc5d0081919d729fd1c2884f86). That published plugin carries the scoped `god-prompt` Agent Skill; use the custom MCP app setup below when you specifically want the 22 callable public GodPrompt tools.
|
|
90
99
|
|
|
91
100
|
### ChatGPT (hosted remote MCP)
|
|
92
101
|
|
|
@@ -132,7 +141,7 @@ For MCP clients that can launch a local process, the [public GHCR image](https:/
|
|
|
132
141
|
}
|
|
133
142
|
```
|
|
134
143
|
|
|
135
|
-
Keep `-i` so the MCP client can exchange JSON-RPC over standard input/output; do not add `-t` (a TTY changes the stdio stream). The version tag selects the verified v1.1.1 image; update it deliberately for future releases rather than silently following the moving `latest` tag. The image is Linux/amd64 and runs as non-root user `10001:10001`. If Docker is unavailable, use the [hosted remote endpoint](#hosted-remote-no-nodejs-required) instead.
|
|
144
|
+
Keep `-i` so the MCP client can exchange JSON-RPC over standard input/output; do not add `-t` (a TTY changes the stdio stream). The version tag selects the verified v1.1.1 image; update it deliberately for future releases rather than silently following the moving `latest` tag. The image is Linux/amd64 and runs as non-root user `10001:10001`. The newer v1.3.0 Docker source has passed image and stdio smoke testing, but the GHCR version tag requires a separate explicit manual publish and post-publish verification. See [the final GHCR checklist](docs/qa/godprompt-ghcr-v130-final-readiness-20261120.md); do not change the pinned example before that verification. If Docker is unavailable, use the [hosted remote endpoint](#hosted-remote-no-nodejs-required) instead.
|
|
136
145
|
|
|
137
146
|
### Glama
|
|
138
147
|
|
|
@@ -299,7 +308,7 @@ npx -y skills@latest add AKzar1el/god-prompt-mcp --skill god-prompt --agent droi
|
|
|
299
308
|
Droid discovers compatible project skills under `.agents/skills/`. To add the callable GodPrompt tools as a local stdio MCP server, use Droid's native MCP command with the published version pinned:
|
|
300
309
|
|
|
301
310
|
```bash
|
|
302
|
-
droid mcp add god-prompt "npx -y god-prompt-mcp@1.
|
|
311
|
+
droid mcp add god-prompt "npx -y god-prompt-mcp@1.4.0"
|
|
303
312
|
```
|
|
304
313
|
|
|
305
314
|
Open `/mcp` in Droid to verify the server and available tools. The Agent Skill supplies the reusable workflow while MCP exposes GodPrompt's read-only task and protocol tools. Node.js 22+ is required for the MCP server.
|
|
@@ -312,7 +321,7 @@ Warp can use GodPrompt as both an Agent Skill and a local MCP server. Install th
|
|
|
312
321
|
npx -y skills@latest add AKzar1el/god-prompt-mcp --skill god-prompt --agent warp --copy -y
|
|
313
322
|
```
|
|
314
323
|
|
|
315
|
-
Warp discovers project skills from `.agents/skills/` and `.warp/skills/`. For MCP tools, add a CLI-based MCP server in Warp with command `npx` and arguments `-y`, `god-prompt-mcp`; Warp's Oz CLI can also receive MCP configuration through `oz agent run --mcp`. The skill supplies the reusable workflow while MCP exposes GodPrompt's
|
|
324
|
+
Warp discovers project skills from `.agents/skills/` and `.warp/skills/`. For MCP tools, add a CLI-based MCP server in Warp with command `npx` and arguments `-y`, `god-prompt-mcp`; Warp's Oz CLI can also receive MCP configuration through `oz agent run --mcp`. The skill supplies the reusable workflow while MCP exposes GodPrompt's 22 public tools in v1.4.0. Node.js 22+ is required for the MCP server.
|
|
316
325
|
|
|
317
326
|
### Goose
|
|
318
327
|
|
|
@@ -325,10 +334,10 @@ npx -y skills@latest add AKzar1el/god-prompt-mcp --skill god-prompt --agent goos
|
|
|
325
334
|
Goose discovers the copied skill under `.goose/skills/god-prompt/`. To expose GodPrompt's callable tools for a session, start Goose with the published MCP package as an external stdio extension:
|
|
326
335
|
|
|
327
336
|
```bash
|
|
328
|
-
goose session --with-extension "npx -y god-prompt-mcp@1.
|
|
337
|
+
goose session --with-extension "npx -y god-prompt-mcp@1.4.0"
|
|
329
338
|
```
|
|
330
339
|
|
|
331
|
-
Goose currently treats Agent Skills and MCP extensions as separate native surfaces, so this path does not depend on Agent Plugins support. The skill supplies the reusable workflow while MCP exposes GodPrompt's
|
|
340
|
+
Goose currently treats Agent Skills and MCP extensions as separate native surfaces, so this path does not depend on Agent Plugins support. The skill supplies the reusable workflow while MCP exposes GodPrompt's 22 public tools in v1.4.0. Node.js 22+ is required for the MCP server.
|
|
332
341
|
|
|
333
342
|
### Zed
|
|
334
343
|
|
|
@@ -373,7 +382,7 @@ The add command writes the project MCP configuration for you. If you prefer to c
|
|
|
373
382
|
|
|
374
383
|
OpenCode 1.x used the same server entry directly under `mcp`; the v2 schema shown above nests named servers under `mcp.servers`.
|
|
375
384
|
|
|
376
|
-
The Agent Skill provides the reusable workflow; MCP adds the
|
|
385
|
+
The Agent Skill provides the reusable workflow; MCP adds the 22 public read-only tools available in v1.3.0. Node.js 22+ is required for the MCP server.
|
|
377
386
|
|
|
378
387
|
### TraeCode
|
|
379
388
|
|
|
@@ -390,13 +399,13 @@ The Trae target installs the skill under `.trae/skills/god-prompt/`, where TraeC
|
|
|
390
399
|
"mcpServers": {
|
|
391
400
|
"god-prompt": {
|
|
392
401
|
"command": "npx",
|
|
393
|
-
"args": ["-y", "god-prompt-mcp@1.
|
|
402
|
+
"args": ["-y", "god-prompt-mcp@1.4.0"]
|
|
394
403
|
}
|
|
395
404
|
}
|
|
396
405
|
}
|
|
397
406
|
```
|
|
398
407
|
|
|
399
|
-
TraeCode also supports the portable `.agents/skills/` convention when **Enable .agents Skills Directory** is turned on in its import settings. Treat project MCP configuration as executable workspace configuration and enable it only in repositories you trust. The Agent Skill supplies the reusable workflow while MCP exposes GodPrompt's
|
|
408
|
+
TraeCode also supports the portable `.agents/skills/` convention when **Enable .agents Skills Directory** is turned on in its import settings. Treat project MCP configuration as executable workspace configuration and enable it only in repositories you trust. The Agent Skill supplies the reusable workflow while MCP exposes GodPrompt's 22 public tools in v1.4.0. Node.js 22+ is required for the MCP server.
|
|
400
409
|
|
|
401
410
|
### OpenClaw
|
|
402
411
|
|
|
@@ -409,11 +418,11 @@ npx -y skills@latest add AKzar1el/god-prompt-mcp --skill god-prompt --agent open
|
|
|
409
418
|
The copied skill lands under `.agents/skills/god-prompt/`, one of OpenClaw's documented project skill roots. To expose GodPrompt's callable tools to OpenClaw-managed agent runtimes as well, register the published stdio server:
|
|
410
419
|
|
|
411
420
|
```bash
|
|
412
|
-
openclaw mcp add god-prompt --command npx --arg -y --arg god-prompt-mcp@1.
|
|
421
|
+
openclaw mcp add god-prompt --command npx --arg -y --arg god-prompt-mcp@1.4.0
|
|
413
422
|
openclaw mcp probe god-prompt
|
|
414
423
|
```
|
|
415
424
|
|
|
416
|
-
`mcp probe` opens a live MCP connection and reports the discovered capabilities, making it a direct verification step after registration. The Agent Skill supplies the reusable workflow while MCP exposes GodPrompt's
|
|
425
|
+
`mcp probe` opens a live MCP connection and reports the discovered capabilities, making it a direct verification step after registration. The Agent Skill supplies the reusable workflow while MCP exposes GodPrompt's 22 public tools in v1.4.0. Node.js 22+ is required for the MCP server.
|
|
417
426
|
|
|
418
427
|
### Qoder
|
|
419
428
|
|
|
@@ -430,13 +439,13 @@ The Qoder target installs the skill under `.qoder/skills/god-prompt/`, where Qod
|
|
|
430
439
|
"mcpServers": {
|
|
431
440
|
"god-prompt": {
|
|
432
441
|
"command": "npx",
|
|
433
|
-
"args": ["-y", "god-prompt-mcp@1.
|
|
442
|
+
"args": ["-y", "god-prompt-mcp@1.4.0"]
|
|
434
443
|
}
|
|
435
444
|
}
|
|
436
445
|
}
|
|
437
446
|
```
|
|
438
447
|
|
|
439
|
-
Qoder requires approval before using project-level MCP servers by default. After adding or changing the server, start a new session or run `/mcp reload`, then use `/mcp` to verify the connection. The Agent Skill supplies the reusable workflow while MCP exposes GodPrompt's
|
|
448
|
+
Qoder requires approval before using project-level MCP servers by default. After adding or changing the server, start a new session or run `/mcp reload`, then use `/mcp` to verify the connection. The Agent Skill supplies the reusable workflow while MCP exposes GodPrompt's 22 public tools in v1.4.0. Node.js 22+ is required for the MCP server.
|
|
440
449
|
|
|
441
450
|
### Qwen Code
|
|
442
451
|
|
|
@@ -459,7 +468,7 @@ This installs GodPrompt under `.qwen/skills/god-prompt/`, where Qwen Code can di
|
|
|
459
468
|
}
|
|
460
469
|
```
|
|
461
470
|
|
|
462
|
-
Restart Qwen Code after changing MCP configuration, then open `/mcp` to verify the server. The Agent Skill provides the reusable workflow while MCP exposes GodPrompt's
|
|
471
|
+
Restart Qwen Code after changing MCP configuration, then open `/mcp` to verify the server. The Agent Skill provides the reusable workflow while MCP exposes GodPrompt's 22 public tools in v1.4.0. Node.js 22+ is required for the MCP server.
|
|
463
472
|
|
|
464
473
|
### Kimi Code
|
|
465
474
|
|
|
@@ -470,7 +479,7 @@ Kimi Code CLI can install GodPrompt as one native custom plugin containing the e
|
|
|
470
479
|
/reload
|
|
471
480
|
```
|
|
472
481
|
|
|
473
|
-
The Kimi manifest points at `skills/`, so the `god-prompt` skill remains available through Kimi's normal relevance-based skill loading instead of being forced into every session. The same manifest exposes `god-prompt-mcp@1.
|
|
482
|
+
The Kimi manifest points at `skills/`, so the `god-prompt` skill remains available through Kimi's normal relevance-based skill loading instead of being forced into every session. The same manifest exposes `god-prompt-mcp@1.4.0` as a local stdio MCP server, including the 22 public tools available in v1.4.0. The explicit `tree/main` URL matters because Kimi's bare GitHub-repository install form prefers the latest GitHub release; using `main` makes the current plugin manifest available without forcing a documentation-only npm/MCP Registry release. Node.js 22+ is required for the MCP server.
|
|
474
483
|
|
|
475
484
|
### JetBrains AI Assistant
|
|
476
485
|
|
|
@@ -508,7 +517,7 @@ If you only want the portable skill, place the complete skill directory at `.age
|
|
|
508
517
|
devin mcp add god-prompt -- npx -y god-prompt-mcp
|
|
509
518
|
```
|
|
510
519
|
|
|
511
|
-
Run `devin mcp list` to verify the direct server registration. The Agent Skill provides the reusable workflow while MCP exposes GodPrompt's
|
|
520
|
+
Run `devin mcp list` to verify the direct server registration. The Agent Skill provides the reusable workflow while MCP exposes GodPrompt's 22 public tools in v1.4.0. Node.js 22+ is required for the MCP server.
|
|
512
521
|
|
|
513
522
|
### Cursor
|
|
514
523
|
|
|
@@ -627,3 +636,22 @@ The generator reads the current source layout: `GodPrompt.md`, `SKILL.md`, and t
|
|
|
627
636
|
Project page: [GodPrompt — AI software-development system prompt](https://tomiseregi.si/projects/god-prompt) · [GodPrompt source](https://github.com/AKzar1el/god-prompt)
|
|
628
637
|
|
|
629
638
|
Related MCP servers: [Google Search Console](https://github.com/AKzar1el/mcp-gsc) · [GEO Tracker](https://github.com/AKzar1el/mcp-geo) · [Web Validator](https://github.com/AKzar1el/mcp-web-validator) · [Google News & Trends](https://github.com/AKzar1el/mcp-trendpulse)
|
|
639
|
+
|
|
640
|
+
### P4 shipped in v1.3.0
|
|
641
|
+
|
|
642
|
+
The five P4 diagnostic tools listed above and the paired evaluation enhancements shipped in the versioned v1.3.0 source, npm and MCP Registry release. The reproducible 74-case legacy fixture corpus was retained, with additional independent synthetic holdout cases. All evidence remains advisory and unverified unless separately authenticated by the host. See [P4 release documentation](docs/roadmaps/godprompt-p4-agent-quality-20261120.md).
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
### Unpublished combined OpenAI Skill + MCP preview
|
|
646
|
+
|
|
647
|
+
The reviewed combined OpenAI plugin source is now in `distribution/openai/` on `main`, while the published marketplace listing remains unchanged. It contains the existing scoped Skill plus a **single remote MCP** declaration for the current 22 public GodPrompt v1.3.0 tools. Two metadata formats (portable `mcp.json` and Codex compatibility `.mcp.json`) describe the same URL; they are not separate services. A dedicated GitHub workflow builds an **unpublished review ZIP** and validates the hosted tool list and a read-only call. The currently published OpenAI directory listing remains Skill-only until its separate reviewed update. See `docs/qa/godprompt-openai-combined-preview-20261120.md`.
|
|
648
|
+
|
|
649
|
+
### P5 — local intelligence, benchmark and optional visualization
|
|
650
|
+
|
|
651
|
+
After installing the versioned Node 22+ npm distribution, the local-only repo mapper can generate a compact import/export graph **without transmitting source code**. For example, in a working directory you already own, run `godprompt-repo-map C:/path/to/authorized-repo src/example.ts` (change paths to match your checkout). The JSON output is heuristic: dynamic imports, aliases, symlink/hardlink relationships and test coverage still require review.
|
|
652
|
+
|
|
653
|
+
To collate verification receipts, use `godprompt-proof pack --contract contract.json --repo OWNER/REPO --sha EXACT40CHAR_COMMIT --map checks.json`, optionally with `--snapshot connector-export.json` and `--codexify codexify-export.json`. It reuses the existing evidence adapters, never executes a test or approves a release, and does not turn self-reported results into authenticated proof.
|
|
654
|
+
|
|
655
|
+
The [paired benchmark](benchmarks/agent-ab/README.md) generates deterministic matched-task order and scoring, and includes twelve independently failing microtask tests as initial grading fixtures. It **does not run models** or claim causal productivity gains. [P5 design, security and limits](docs/roadmaps/godprompt-p5-quality-intelligence-20261120.md).
|
|
656
|
+
|
|
657
|
+
MCP Apps-compatible clients can optionally present read-only, keyboard-accessible trajectory and impact reports through `ui://godprompt/evidence-review.html`. Text and `structuredContent` remain available to clients without MCP Apps and remain the basis for verification. No remote repository access or automatic policy execution has been added to the Worker.
|
package/bin/godprompt-proof.mjs
CHANGED
|
@@ -215,6 +215,60 @@ export async function githubSnapshotEvidence({ repo, sha, contract, mapping = {}
|
|
|
215
215
|
bundle.gaps.push("CONNECTOR_SNAPSHOT_PROVENANCE_NOT_AUTHENTICATED");
|
|
216
216
|
return bundle;
|
|
217
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* One opt-in evidence collection call. Reuses the existing pinned GitHub and
|
|
220
|
+
* Codexify adapters; does not execute commands, merge scopes or authenticate text.
|
|
221
|
+
*/
|
|
222
|
+
export async function combinedEvidence({
|
|
223
|
+
repo, sha, contract, mapping={}, pr=null, codexifyExport=null, snapshot=null, fetchImpl=fetch,
|
|
224
|
+
}) {
|
|
225
|
+
const valid=validateWorkContractEnvelope(contract);
|
|
226
|
+
if(!repo || !sha) fail("Combined evidence requires a pinned GitHub repository and commit");
|
|
227
|
+
const github=snapshot
|
|
228
|
+
? await githubSnapshotEvidence({repo,sha,contract:valid,mapping,pr,snapshot})
|
|
229
|
+
: await githubEvidence({repo,sha,contract:valid,mapping,pr,fetchImpl});
|
|
230
|
+
const codex=codexifyExport===null ? null :
|
|
231
|
+
await codexifyEvidence({contract:valid,exportData:codexifyExport});
|
|
232
|
+
const gaps=[...github.gaps.map(x=>"github:"+x),...(codex?.gaps??[]).map(x=>"codexify:"+x)];
|
|
233
|
+
const files=[...new Set([...(github.review_input.changed_files??[]),
|
|
234
|
+
...(codex?.review_input?.changed_files??[])])].sort();
|
|
235
|
+
if(files.length>150) fail("Combined changed file list exceeds review safety limit");
|
|
236
|
+
const grouped=new Map();
|
|
237
|
+
for(const source of [{key:"github",checks:github.review_input.checks},
|
|
238
|
+
...(codex?[{key:"codexify",checks:codex.review_input.checks}]:[])]) {
|
|
239
|
+
for(const check of source.checks) {
|
|
240
|
+
if(!grouped.has(check.id))grouped.set(check.id,[]);
|
|
241
|
+
grouped.get(check.id).push({...check,provider:source.key});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
const checks=[];
|
|
245
|
+
for(const expected of valid.verification_commands) {
|
|
246
|
+
const options=grouped.get(expected.id)??[];
|
|
247
|
+
if(!options.length){gaps.push("CHECK_NOT_OBSERVED:"+expected.id);continue;}
|
|
248
|
+
if(options.some(x=>x.command!==expected.command)||options.some(x=>x.exit_code!==options[0].exit_code)){
|
|
249
|
+
checks.push({id:expected.id,command:expected.command,exit_code:null,
|
|
250
|
+
source:"self_report",evidence_excerpt:"Multiple sources disagree on command or exit status; reconcile original receipts."});
|
|
251
|
+
gaps.push("CHECK_EVIDENCE_CONFLICT:"+expected.id);
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
const best=options.find(x=>x.source==="tool_output")??options[0];
|
|
255
|
+
checks.push({id:expected.id,command:expected.command,exit_code:best.exit_code,
|
|
256
|
+
source:best.source,evidence_excerpt:"Concordant "+options.map(x=>x.provider).join("+")+
|
|
257
|
+
" receipt; matched contract VC ID. Original outputs and execution must still be verified independently."});
|
|
258
|
+
if(best.source!=="tool_output")gaps.push("CHECK_NOT_STRUCTURED:"+expected.id);
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
...makeBundle("combined_github_codexify",valid,files,checks,gaps,{
|
|
262
|
+
provider:"combined_local_collectors",
|
|
263
|
+
github:github.provenance,
|
|
264
|
+
codexify:codex ? codex.provenance : null,
|
|
265
|
+
commit_sha:sha,
|
|
266
|
+
}),
|
|
267
|
+
observed_sources:codex ? 2 : 1,
|
|
268
|
+
receipt_conflicts:gaps.filter(x=>x.startsWith("CHECK_EVIDENCE_CONFLICT:")).length,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
218
272
|
function filePath(env = process.env) {
|
|
219
273
|
if (env.GODPROMPT_FEEDBACK_FILE) {
|
|
220
274
|
if (!isAbsolute(env.GODPROMPT_FEEDBACK_FILE)) fail("GODPROMPT_FEEDBACK_FILE must be an absolute path");
|
|
@@ -506,13 +560,14 @@ function parseOptions(argv) {
|
|
|
506
560
|
github: ["repo", "sha", "contract", "map", "pr"],
|
|
507
561
|
"github-snapshot": ["repo", "sha", "contract", "map", "snapshot", "pr"],
|
|
508
562
|
codexify: ["contract", "export"],
|
|
563
|
+
pack: ["contract","repo","sha","map","pr","snapshot","codexify"],
|
|
509
564
|
learn: ["project", "outcome", "pattern", "lesson", "verified"],
|
|
510
565
|
lessons: ["project"],
|
|
511
566
|
"learn-review": ["project", "review"],
|
|
512
567
|
metrics: ["project", "days"],
|
|
513
568
|
workflow: ["project", "type", "risk", "min-reports", "format"],
|
|
514
569
|
};
|
|
515
|
-
if (!allowed[command]) fail("Usage: godprompt-proof github|github-snapshot|codexify|learn|learn-review|lessons|metrics|workflow [--name value ...]");
|
|
570
|
+
if (!allowed[command]) fail("Usage: godprompt-proof github|github-snapshot|codexify|pack|learn|learn-review|lessons|metrics|workflow [--name value ...]");
|
|
516
571
|
for (const key of Object.keys(opts)) if (!allowed[command].includes(key)) fail("Unknown option --" + key);
|
|
517
572
|
return { command, opts };
|
|
518
573
|
}
|
|
@@ -546,6 +601,16 @@ export async function cli(argv = process.argv.slice(2)) {
|
|
|
546
601
|
exportData: await readSmallJson(opts.export),
|
|
547
602
|
});
|
|
548
603
|
}
|
|
604
|
+
if(command==="pack"){
|
|
605
|
+
if(!opts.contract||!opts.repo||!opts.sha)fail("pack requires --contract --repo --sha");
|
|
606
|
+
return combinedEvidence({
|
|
607
|
+
contract:validateWorkContractEnvelope(await readSmallJson(opts.contract)),
|
|
608
|
+
repo:opts.repo,sha:opts.sha,pr:opts.pr?Number(opts.pr):null,
|
|
609
|
+
mapping:opts.map?await readSmallJson(opts.map):{},
|
|
610
|
+
snapshot:opts.snapshot?await readSmallJson(opts.snapshot):null,
|
|
611
|
+
codexifyExport:opts.codexify?await readSmallJson(opts.codexify):null,
|
|
612
|
+
});
|
|
613
|
+
}
|
|
549
614
|
if (command === "learn-review") {
|
|
550
615
|
if (!opts.project || !opts.review) fail("learn-review requires --project --review");
|
|
551
616
|
return learnFromReview({ project: opts.project, review: await readSmallJson(opts.review) });
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Local, opt-in, non-executing repository map. Static import matching is not semantic AST parsing. */
|
|
3
|
+
import { readdir, lstat, readFile, realpath } from "node:fs/promises";
|
|
4
|
+
import { resolve, relative, dirname, extname, posix, sep, join } from "node:path";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
const DENY_DIRS=new Set([".git",".hg","node_modules","vendor",".next","dist","build","coverage",".cache","tmp"]);
|
|
7
|
+
const CODE_EXTS=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".mts",".cts"]);
|
|
8
|
+
const ID=/^[A-Za-z0-9_./-]{1,240}$/;
|
|
9
|
+
const LIMIT_FILES=700, LIMIT_PER_FILE=64*1024, LIMIT_TOTAL=3*1024*1024;
|
|
10
|
+
const bail=(msg)=>{throw new Error(msg)};
|
|
11
|
+
function safeRel(p) {
|
|
12
|
+
return typeof p==="string" && ID.test(p) && !p.startsWith("/") &&
|
|
13
|
+
!p.split("/").includes("..") && !p.split("/").includes(".") && !p.includes("\\");
|
|
14
|
+
}
|
|
15
|
+
function normalize(root,path) {
|
|
16
|
+
const rel=relative(root,path).split(sep).join("/");
|
|
17
|
+
return rel && safeRel(rel) ? rel : null;
|
|
18
|
+
}
|
|
19
|
+
function imports(text) {
|
|
20
|
+
const found=new Set();
|
|
21
|
+
const patterns=[
|
|
22
|
+
/\b(?:import|export)\s+(?:[\s\S]{0,400}?\s+from\s*)?["'](\.{1,2}\/[^"'\r\n]{1,220})["']/g,
|
|
23
|
+
/\brequire\s*\(\s*["'](\.{1,2}\/[^"'\r\n]{1,220})["']\s*\)/g,
|
|
24
|
+
/\bimport\s*\(\s*["'](\.{1,2}\/[^"'\r\n]{1,220})["']\s*\)/g,
|
|
25
|
+
];
|
|
26
|
+
for(const re of patterns) {
|
|
27
|
+
let m,count=0;
|
|
28
|
+
while((m=re.exec(text))&&count++<300)found.add(m[1]);
|
|
29
|
+
}
|
|
30
|
+
return [...found];
|
|
31
|
+
}
|
|
32
|
+
function symbols(text) {
|
|
33
|
+
const out=new Set();
|
|
34
|
+
const regex=/^\s*export\s+(?:default\s+)?(?:async\s+)?(?:function|class|interface|type|enum|const)\s+([A-Za-z_$][\w$]{0,80})/gm;
|
|
35
|
+
let m;
|
|
36
|
+
while((m=regex.exec(text))&&out.size<60)out.add(m[1]);
|
|
37
|
+
return [...out].sort();
|
|
38
|
+
}
|
|
39
|
+
function resolveImport(consumer, spec, available) {
|
|
40
|
+
const base=posix.normalize(posix.join(posix.dirname(consumer),spec));
|
|
41
|
+
if(!safeRel(base))return null;
|
|
42
|
+
const variants=[base,...[...CODE_EXTS].map(ext=>base+ext),...["index.ts","index.tsx","index.js","index.mjs"].map(x=>base+"/"+x)];
|
|
43
|
+
return variants.find(x=>available.has(x))??null;
|
|
44
|
+
}
|
|
45
|
+
export async function mapRepository({root,changed_files=[],max_files=LIMIT_FILES}={}) {
|
|
46
|
+
if(typeof root!=="string"||!root.trim())bail("Explicit repository root required");
|
|
47
|
+
if(!Number.isInteger(max_files)||max_files<1||max_files>LIMIT_FILES)bail("max_files must be 1..700");
|
|
48
|
+
if(!Array.isArray(changed_files)||changed_files.length<1||changed_files.length>50||
|
|
49
|
+
changed_files.some(x=>!safeRel(x)))bail("Supply 1..50 safe relative changed_files");
|
|
50
|
+
const base=await realpath(resolve(root));
|
|
51
|
+
if(!(await lstat(base)).isDirectory())bail("Root must be a regular directory");
|
|
52
|
+
let bytes=0,skipped=0,skipped_links=0,oversized=0;
|
|
53
|
+
const files=[];
|
|
54
|
+
const stack=[base];
|
|
55
|
+
let directoryCount=0;
|
|
56
|
+
while(stack.length){
|
|
57
|
+
const dir=stack.pop();
|
|
58
|
+
const directoryReal=await realpath(dir);
|
|
59
|
+
if(directoryReal!==base&&!directoryReal.startsWith(base+sep)){skipped_links++;continue;}
|
|
60
|
+
if(++directoryCount>1000){skipped++;break;}
|
|
61
|
+
const entries=await readdir(dir,{withFileTypes:true});
|
|
62
|
+
entries.sort((a,b)=>a.name.localeCompare(b.name));
|
|
63
|
+
for(const entry of entries){
|
|
64
|
+
if(entry.name.startsWith(".") && entry.name!==".github")continue;
|
|
65
|
+
const abs=join(dir,entry.name);
|
|
66
|
+
if(entry.isSymbolicLink()){skipped_links++;continue;}
|
|
67
|
+
if(entry.isDirectory()){
|
|
68
|
+
if(!DENY_DIRS.has(entry.name) && stack.length<1000)stack.push(abs);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if(!entry.isFile() || !CODE_EXTS.has(extname(entry.name)))continue;
|
|
72
|
+
const info=await lstat(abs);
|
|
73
|
+
if(!info.isFile() || info.nlink>1){skipped_links++;continue;}
|
|
74
|
+
if(info.size>LIMIT_PER_FILE){oversized++;continue;}
|
|
75
|
+
const rel=normalize(base,abs);
|
|
76
|
+
if(!rel){skipped++;continue;}
|
|
77
|
+
if(files.length>=max_files || bytes+info.size>LIMIT_TOTAL){skipped++;continue;}
|
|
78
|
+
bytes+=info.size;
|
|
79
|
+
files.push({path:rel,abs});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
files.sort((a,b)=>a.path.localeCompare(b.path));
|
|
83
|
+
const available=new Set(files.map(x=>x.path));
|
|
84
|
+
const dependencies=[];
|
|
85
|
+
const outputSymbols=[];
|
|
86
|
+
const proposedTests=[];
|
|
87
|
+
const changes=[...new Set(changed_files)];
|
|
88
|
+
let unresolved=0;
|
|
89
|
+
for(const file of files) {
|
|
90
|
+
// No source content leaves the output; ignore injected instructions in comments.
|
|
91
|
+
const code=await readFile(file.abs,"utf8");
|
|
92
|
+
const edges=new Set();
|
|
93
|
+
for(const ref of imports(code)){
|
|
94
|
+
const target=resolveImport(file.path,ref,available);
|
|
95
|
+
if(target && target!==file.path)edges.add(target);
|
|
96
|
+
else unresolved++;
|
|
97
|
+
}
|
|
98
|
+
for(const target of [...edges].sort())dependencies.push({consumer:file.path,dependency:target});
|
|
99
|
+
if(changes.includes(file.path))outputSymbols.push({path:file.path,exports:symbols(code)});
|
|
100
|
+
if(/(?:^|\/)[^/]+\.(?:test|spec)\.[cm]?[jt]sx?$/.test(file.path)){
|
|
101
|
+
const relevant=[...edges].filter(x=>changes.includes(x));
|
|
102
|
+
if(relevant.length)proposedTests.push({test_file:file.path,imports_changed_files:relevant});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
status:skipped||oversized||skipped_links?"PARTIAL_STATIC_MAP":"STATIC_MAP_ONLY",
|
|
107
|
+
schema:"godprompt.local_code_map.v1",
|
|
108
|
+
changed_files:changes,dependencies:dependencies.slice(0,3500),
|
|
109
|
+
changed_file_exports:outputSymbols,
|
|
110
|
+
candidate_test_imports:proposedTests.slice(0,100),
|
|
111
|
+
files_scanned:files.length,bytes_scanned:bytes,unresolved_relative_imports:unresolved,
|
|
112
|
+
skipped_files:skipped,oversized_files:oversized,skipped_links,
|
|
113
|
+
truncated:dependencies.length>3500 || proposedTests.length>100||skipped>0,
|
|
114
|
+
remote_transmission:false,independently_verified:false,
|
|
115
|
+
warning:"Local static import and export heuristics, NOT a TypeScript/JavaScript AST or proof of test coverage. No code content is returned. Check dynamic imports, path aliases, joins and file links independently. Use dependencies only as caller-supplied graph for trace_change_impact.",
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async function main(args){
|
|
119
|
+
if(args.length<2||args.length>51)bail("Usage: godprompt-repo-map ROOT CHANGED_FILE [CHANGED_FILE...]");
|
|
120
|
+
return mapRepository({root:args[0],changed_files:args.slice(1)});
|
|
121
|
+
}
|
|
122
|
+
if(process.argv[1]&&import.meta.url===pathToFileURL(resolve(process.argv[1])).href) {
|
|
123
|
+
main(process.argv.slice(2)).then(v=>process.stdout.write(JSON.stringify(v,null,2)+"\n"))
|
|
124
|
+
.catch(()=>{process.stderr.write("Unable to map bounded local codebase; check root and scope.\n");process.exitCode=1;});
|
|
125
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
const fieldSchema = z.object({
|
|
3
|
+
id: z.string().regex(/^[A-Za-z0-9_.-]{1,64}$/),
|
|
4
|
+
type: z.enum(["string", "number", "boolean", "array", "object"]),
|
|
5
|
+
required: z.boolean().default(true),
|
|
6
|
+
min: z.number().finite().optional(),
|
|
7
|
+
max: z.number().finite().optional(),
|
|
8
|
+
invariant: z.enum(["none", "idempotent", "monotonic", "order_independent"]).default("none"),
|
|
9
|
+
untrusted: z.boolean().default(false),
|
|
10
|
+
}).strict();
|
|
11
|
+
export const AdversarialPlanSchema = z.object({
|
|
12
|
+
fields: z.array(fieldSchema).min(1).max(30),
|
|
13
|
+
max_cases: z.number().int().min(4).max(80).default(30),
|
|
14
|
+
}).strict();
|
|
15
|
+
export function designAdversarialTests(fields, maxCases) {
|
|
16
|
+
const proposed = [];
|
|
17
|
+
const issues = [];
|
|
18
|
+
const used = new Set();
|
|
19
|
+
for (const field of fields) {
|
|
20
|
+
if (used.has(field.id))
|
|
21
|
+
issues.push({ code: "DUPLICATE_FIELD_ID", field_id: field.id });
|
|
22
|
+
used.add(field.id);
|
|
23
|
+
if (field.min !== undefined && field.max !== undefined && field.min > field.max) {
|
|
24
|
+
issues.push({ code: "INVALID_BOUNDS", field_id: field.id });
|
|
25
|
+
}
|
|
26
|
+
if ((field.min !== undefined || field.max !== undefined) && !["number", "string", "array"].includes(field.type)) {
|
|
27
|
+
issues.push({ code: "UNSUPPORTED_BOUNDS_FOR_TYPE", field_id: field.id });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function add(field, category, variation, expected) {
|
|
31
|
+
if (proposed.length >= maxCases)
|
|
32
|
+
return;
|
|
33
|
+
proposed.push({ id: "AT-" + String(proposed.length + 1).padStart(3, "0"), field_id: field.id, category, variation, expected, status: "PROPOSED_NOT_RUN" });
|
|
34
|
+
}
|
|
35
|
+
// Distribute one negative baseline across fields before deeper cases.
|
|
36
|
+
for (const f of fields) {
|
|
37
|
+
if (proposed.length >= maxCases)
|
|
38
|
+
break;
|
|
39
|
+
add(f, "negative", "wrong_type", "REJECT_WRONG_TYPE_IF_STRICT_SCHEMA");
|
|
40
|
+
}
|
|
41
|
+
for (const f of fields) {
|
|
42
|
+
if (proposed.length >= maxCases)
|
|
43
|
+
break;
|
|
44
|
+
if (f.required)
|
|
45
|
+
add(f, "negative", "missing_field", "REJECT_MISSING_REQUIRED_FIELD");
|
|
46
|
+
if (f.min !== undefined && (f.max === undefined || f.min <= f.max)) {
|
|
47
|
+
add(f, "boundary", "at_minimum", "ACCEPT_IF_WITHIN_CONTRACT");
|
|
48
|
+
add(f, "boundary", "below_minimum", "REJECT_BELOW_DECLARED_MINIMUM");
|
|
49
|
+
}
|
|
50
|
+
if (f.max !== undefined && (f.min === undefined || f.max >= f.min)) {
|
|
51
|
+
add(f, "boundary", "at_maximum", "ACCEPT_IF_WITHIN_CONTRACT");
|
|
52
|
+
add(f, "boundary", "above_maximum", "REJECT_ABOVE_DECLARED_MAXIMUM");
|
|
53
|
+
}
|
|
54
|
+
add(f, "property", "repeat_same_valid_input", "CHECK_DETERMINISTIC_OUTPUT_IF_REQUIRED_BY_INTERFACE");
|
|
55
|
+
if (f.invariant !== "none")
|
|
56
|
+
add(f, "metamorphic", "assert_" + f.invariant.toLowerCase(), "VERIFY_EXPLICIT_" + f.invariant.toUpperCase() + "_CONTRACT");
|
|
57
|
+
if (f.untrusted)
|
|
58
|
+
add(f, "trust_boundary", "instruction_like_untrusted_content", "VERIFY_UNTRUSTED_INPUT_IS_TREATED_AS_DATA_NOT_AUTHORITY");
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
status: issues.length ? "INVALID_OR_AMBIGUOUS_CONTRACT" : proposed.length >= maxCases ? "PARTIAL_ADVERSARIAL_PLAN" : "DRAFT_ADVERSARIAL_PLAN",
|
|
62
|
+
cases: proposed,
|
|
63
|
+
issues,
|
|
64
|
+
total_fields: fields.length,
|
|
65
|
+
truncated: proposed.length >= maxCases,
|
|
66
|
+
tests_executed: 0,
|
|
67
|
+
independently_verified: false,
|
|
68
|
+
warning: "These are deterministic test design suggestions. Actual samples, oracles, execution, security findings and invariants need independent verification.",
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export const AdversarialOutputSchema = z.object({
|
|
72
|
+
status: z.enum(["INVALID_OR_AMBIGUOUS_CONTRACT", "PARTIAL_ADVERSARIAL_PLAN", "DRAFT_ADVERSARIAL_PLAN"]),
|
|
73
|
+
cases: z.array(z.object({
|
|
74
|
+
id: z.string(), field_id: z.string(),
|
|
75
|
+
category: z.enum(["negative", "boundary", "property", "metamorphic", "trust_boundary"]),
|
|
76
|
+
variation: z.string(), expected: z.string(), status: z.literal("PROPOSED_NOT_RUN"),
|
|
77
|
+
}).strict()),
|
|
78
|
+
issues: z.array(z.object({ code: z.string(), field_id: z.string() }).strict()),
|
|
79
|
+
total_fields: z.number().int(), truncated: z.boolean(), tests_executed: z.literal(0),
|
|
80
|
+
independently_verified: z.literal(false), warning: z.string(),
|
|
81
|
+
}).strict();
|
|
82
|
+
export function registerAdversarialPlanningTool(server) {
|
|
83
|
+
server.registerTool("design_adversarial_tests", {
|
|
84
|
+
title: "Design adversarial and property test cases",
|
|
85
|
+
description: "Generate bounded negative, boundary, metamorphic, property and trust-boundary test ideas from explicit caller-supplied field contracts. Never runs or generates executable tests.",
|
|
86
|
+
inputSchema: AdversarialPlanSchema.shape,
|
|
87
|
+
outputSchema: AdversarialOutputSchema.shape,
|
|
88
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
89
|
+
}, async (args) => {
|
|
90
|
+
const input = AdversarialPlanSchema.parse(args);
|
|
91
|
+
const output = designAdversarialTests(input.fields, input.max_cases);
|
|
92
|
+
return { structuredContent: output, content: [{ type: "text", text: JSON.stringify(output) }] };
|
|
93
|
+
});
|
|
94
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { QUALITY_UI_URI } from "./quality-view.js";
|
|
2
|
+
import * as z from "zod/v4";
|
|
3
|
+
export const TrajectoryEventSchema = z.object({
|
|
4
|
+
id: z.string().regex(/^[A-Za-z0-9_.-]{1,64}$/),
|
|
5
|
+
kind: z.enum(["tool_call", "tool_result", "verification", "completion", "decision"]),
|
|
6
|
+
operation: z.enum(["read", "write", "verify", "other"]).optional(),
|
|
7
|
+
tool: z.string().max(100).optional(),
|
|
8
|
+
status: z.enum(["ok", "failed", "skipped", "unknown"]).optional(),
|
|
9
|
+
scope: z.enum(["allowed", "outside", "unknown"]).optional(),
|
|
10
|
+
fingerprint: z.string().regex(/^[A-Za-z0-9_.:-]{1,80}$/).optional(),
|
|
11
|
+
tokens: z.number().int().min(0).max(200_000).optional(),
|
|
12
|
+
}).strict();
|
|
13
|
+
export const TrajectoryInputSchema = z.object({
|
|
14
|
+
events: z.array(TrajectoryEventSchema).min(1).max(150),
|
|
15
|
+
budget_tokens: z.number().int().min(1).max(2_000_000).optional(),
|
|
16
|
+
}).strict();
|
|
17
|
+
const hint = (code, severity, event_index, recommendation) => ({ code, severity, event_index, recommendation });
|
|
18
|
+
export function auditAgentTrajectory(events, budget_tokens) {
|
|
19
|
+
const findings = [];
|
|
20
|
+
const IDs = new Set();
|
|
21
|
+
const failing = new Map();
|
|
22
|
+
const redundantReads = new Map();
|
|
23
|
+
let uncheckedWrites = 0;
|
|
24
|
+
let reportedTokens = 0;
|
|
25
|
+
let eventsWithTokens = 0;
|
|
26
|
+
let budgetReported = false;
|
|
27
|
+
let latestCheckOutcome = null;
|
|
28
|
+
let writes = 0;
|
|
29
|
+
let verification = 0;
|
|
30
|
+
let lastWrite = -1;
|
|
31
|
+
let lastCheck = -1;
|
|
32
|
+
let completed = 0;
|
|
33
|
+
for (let i = 0; i < events.length; i++) {
|
|
34
|
+
const event = events[i];
|
|
35
|
+
const position = i + 1;
|
|
36
|
+
if (IDs.has(event.id))
|
|
37
|
+
findings.push(hint("DUPLICATE_EVENT_ID", "medium", position, "Provide unique event identifiers before trusting the trajectory."));
|
|
38
|
+
IDs.add(event.id);
|
|
39
|
+
if (event.tokens !== undefined) {
|
|
40
|
+
reportedTokens += event.tokens;
|
|
41
|
+
eventsWithTokens++;
|
|
42
|
+
if (!budgetReported && budget_tokens !== undefined && reportedTokens > budget_tokens) {
|
|
43
|
+
budgetReported = true;
|
|
44
|
+
findings.push(hint("TOKEN_BUDGET_EXCEEDED_REPORTED", "medium", position, "Review reported token spend and scope; stop avoidable exploration without skipping necessary verification."));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (event.kind === "decision" || (event.operation === "write" && event.status === "ok"))
|
|
48
|
+
redundantReads.clear();
|
|
49
|
+
if (event.kind === "tool_result" && event.operation === "read" && event.status === "ok" && event.fingerprint) {
|
|
50
|
+
const key = (event.tool ?? "unnamed") + ":" + event.fingerprint;
|
|
51
|
+
const count = (redundantReads.get(key) ?? 0) + 1;
|
|
52
|
+
redundantReads.set(key, count);
|
|
53
|
+
if (count === 4)
|
|
54
|
+
findings.push(hint("REPEATED_UNCHANGED_READ", "low", position, "Consider caching or reusing this reported identical read; polling may be legitimate."));
|
|
55
|
+
}
|
|
56
|
+
if (event.kind === "verification" || event.operation === "verify")
|
|
57
|
+
latestCheckOutcome = event.status ?? "unknown";
|
|
58
|
+
if (event.operation === "write" && event.scope === "outside" &&
|
|
59
|
+
event.kind === "tool_result" && event.status === "ok") {
|
|
60
|
+
findings.push(hint("OUT_OF_SCOPE_WRITE_REPORTED", "high", position, "Reconcile the successful reported write with the approved task scope."));
|
|
61
|
+
}
|
|
62
|
+
if (event.kind === "tool_result" && event.status === "failed") {
|
|
63
|
+
const key = (event.tool ?? "unnamed") + ":" + (event.fingerprint ?? "unspecified");
|
|
64
|
+
const count = (failing.get(key) ?? 0) + 1;
|
|
65
|
+
failing.set(key, count);
|
|
66
|
+
if (count === 3)
|
|
67
|
+
findings.push(hint("REPEATED_FAILURE", "medium", position, "Stop repeating this failing call unchanged; inspect the cause or adjust the plan."));
|
|
68
|
+
}
|
|
69
|
+
if (event.kind === "tool_result" && event.operation === "write" && event.status === "ok") {
|
|
70
|
+
writes++;
|
|
71
|
+
lastWrite = i;
|
|
72
|
+
uncheckedWrites++;
|
|
73
|
+
if (uncheckedWrites === 12)
|
|
74
|
+
findings.push(hint("LONG_UNCHECKED_WRITE_STREAK", "low", position, "Consider a focused checkpoint to catch regressions before more changes."));
|
|
75
|
+
}
|
|
76
|
+
if ((event.kind === "verification" || event.operation === "verify") && event.status === "ok") {
|
|
77
|
+
verification++;
|
|
78
|
+
lastCheck = i;
|
|
79
|
+
uncheckedWrites = 0;
|
|
80
|
+
}
|
|
81
|
+
if (event.kind === "completion") {
|
|
82
|
+
completed++;
|
|
83
|
+
if (lastCheck < lastWrite || lastCheck < 0 || latestCheckOutcome !== "ok")
|
|
84
|
+
findings.push(hint("PREMATURE_COMPLETION", "high", position, "Obtain current verification evidence before claiming completion."));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (completed > 0 && latestCheckOutcome === "failed")
|
|
88
|
+
findings.push(hint("FAILED_FINAL_VERIFICATION", "high", events.length, "The latest reported verification failed; do not claim completion."));
|
|
89
|
+
if (writes > 0 && lastCheck < 0)
|
|
90
|
+
findings.push(hint("MISSING_VERIFICATION", "high", events.length, "Capture a real post-change check; event reports are not independently authenticated."));
|
|
91
|
+
else if (writes > 0 && lastCheck < lastWrite)
|
|
92
|
+
findings.push(hint("STALE_VERIFICATION", "high", events.length, "Rerun verification after the most recent write."));
|
|
93
|
+
return {
|
|
94
|
+
status: findings.length ? "RECHECK" : "NO_DETERMINISTIC_SIGNALS",
|
|
95
|
+
findings: findings.slice(0, 40),
|
|
96
|
+
truncated: findings.length > 40,
|
|
97
|
+
events_reviewed: events.length,
|
|
98
|
+
reported_writes: writes,
|
|
99
|
+
reported_successful_verifications: verification,
|
|
100
|
+
reported_completions: completed,
|
|
101
|
+
reported_tokens: eventsWithTokens ? reportedTokens : null,
|
|
102
|
+
token_budget: budget_tokens ?? null,
|
|
103
|
+
independently_verified: false,
|
|
104
|
+
completion_authorized: false,
|
|
105
|
+
warning: "Caller-supplied event metadata is unverified. No logs, commands or file contents were accessed or replayed.",
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export const TrajectoryOutputSchema = z.object({
|
|
109
|
+
status: z.enum(["RECHECK", "NO_DETERMINISTIC_SIGNALS"]),
|
|
110
|
+
findings: z.array(z.object({ code: z.string(), severity: z.enum(["high", "medium", "low"]), event_index: z.number().int(), recommendation: z.string() }).strict()),
|
|
111
|
+
truncated: z.boolean(), events_reviewed: z.number().int(), reported_writes: z.number().int(),
|
|
112
|
+
reported_successful_verifications: z.number().int(), reported_completions: z.number().int(),
|
|
113
|
+
reported_tokens: z.number().int().nullable(), token_budget: z.number().int().nullable(),
|
|
114
|
+
independently_verified: z.literal(false), completion_authorized: z.literal(false), warning: z.string(),
|
|
115
|
+
}).strict();
|
|
116
|
+
export function registerTrajectoryTool(server) {
|
|
117
|
+
server.registerTool("audit_agent_trajectory", {
|
|
118
|
+
title: "Audit reported agent trajectory",
|
|
119
|
+
description: "Read-only review of bounded, sanitized event metadata for repeated failures, scope drift, stale verification and premature completion. No raw logs or independent execution evidence; cannot authorize an agent.",
|
|
120
|
+
inputSchema: TrajectoryInputSchema.shape,
|
|
121
|
+
outputSchema: TrajectoryOutputSchema.shape,
|
|
122
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
123
|
+
_meta: { ui: { resourceUri: QUALITY_UI_URI } },
|
|
124
|
+
}, async ({ events, budget_tokens }) => {
|
|
125
|
+
const output = auditAgentTrajectory(events, budget_tokens);
|
|
126
|
+
return { structuredContent: output, content: [{ type: "text", text: JSON.stringify(output) }] };
|
|
127
|
+
});
|
|
128
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { QUALITY_UI_URI } from "./quality-view.js";
|
|
2
|
+
import * as z from "zod/v4";
|
|
3
|
+
const file = z.string().trim().min(1).max(240).refine(value => /^[A-Za-z0-9_.\/-]+$/.test(value) && !value.startsWith("/") &&
|
|
4
|
+
value.split("/").every(segment => segment.length > 0 && segment !== "." && segment !== ".."), "Supply a safe nonempty relative file path without traversal or empty segments.");
|
|
5
|
+
const id = z.string().regex(/^[A-Za-z0-9_.-]{1,64}$/);
|
|
6
|
+
const files = z.array(file).max(25);
|
|
7
|
+
export const ImpactSchema = z.object({
|
|
8
|
+
changed_files: z.array(file).min(1).max(50),
|
|
9
|
+
dependencies: z.array(z.object({ consumer: file, dependency: file }).strict()).max(250).default([]),
|
|
10
|
+
requirements: z.array(z.object({ id, files }).strict()).max(50).default([]),
|
|
11
|
+
tests: z.array(z.object({
|
|
12
|
+
id,
|
|
13
|
+
covers_files: files.default([]),
|
|
14
|
+
covers_requirements: z.array(id).max(30).default([]),
|
|
15
|
+
duration_ms: z.number().int().min(1).max(3_600_000).optional(),
|
|
16
|
+
}).strict()).max(70).default([]),
|
|
17
|
+
receipts: z.array(z.object({
|
|
18
|
+
test_id: id,
|
|
19
|
+
status: z.enum(["passed", "failed", "not_run"]),
|
|
20
|
+
}).strict()).max(70).default([]),
|
|
21
|
+
}).strict();
|
|
22
|
+
export function traceChangeImpact(input) {
|
|
23
|
+
const issues = [];
|
|
24
|
+
const affected = new Map();
|
|
25
|
+
const dependents = new Map();
|
|
26
|
+
for (const link of input.dependencies) {
|
|
27
|
+
const list = dependents.get(link.dependency) ?? [];
|
|
28
|
+
if (!list.includes(link.consumer))
|
|
29
|
+
list.push(link.consumer);
|
|
30
|
+
dependents.set(link.dependency, list);
|
|
31
|
+
}
|
|
32
|
+
const queue = [];
|
|
33
|
+
for (const path of input.changed_files)
|
|
34
|
+
if (!affected.has(path)) {
|
|
35
|
+
affected.set(path, { depth: 0, via: null });
|
|
36
|
+
queue.push(path);
|
|
37
|
+
}
|
|
38
|
+
for (let i = 0; i < queue.length; i++) {
|
|
39
|
+
const path = queue[i];
|
|
40
|
+
const info = affected.get(path);
|
|
41
|
+
if (info.depth >= 6)
|
|
42
|
+
continue;
|
|
43
|
+
for (const child of (dependents.get(path) ?? []).sort()) {
|
|
44
|
+
if (affected.size >= 150 || affected.has(child))
|
|
45
|
+
continue;
|
|
46
|
+
affected.set(child, { depth: info.depth + 1, via: path });
|
|
47
|
+
queue.push(child);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (affected.size >= 150)
|
|
51
|
+
issues.push({ code: "IMPACT_GRAPH_TRUNCATED", severity: "medium", reference: "graph" });
|
|
52
|
+
const impacted = input.requirements.filter(r => r.files.some(path => affected.has(path)));
|
|
53
|
+
const targets = new Set([
|
|
54
|
+
...impacted.map(r => "requirement:" + r.id),
|
|
55
|
+
...[...affected.keys()].map(path => "file:" + path),
|
|
56
|
+
]);
|
|
57
|
+
const selected = [];
|
|
58
|
+
const used = new Set();
|
|
59
|
+
const receiptByID = new Map(input.receipts.map(r => [r.test_id, r.status]));
|
|
60
|
+
const seenTestIDs = new Set();
|
|
61
|
+
for (const test of input.tests) {
|
|
62
|
+
if (seenTestIDs.has(test.id))
|
|
63
|
+
issues.push({ code: "DUPLICATE_TEST_ID", severity: "medium", reference: test.id });
|
|
64
|
+
seenTestIDs.add(test.id);
|
|
65
|
+
}
|
|
66
|
+
const remaining = new Set(targets);
|
|
67
|
+
for (let step = 0; step < 12 && remaining.size > 0; step++) {
|
|
68
|
+
let best = null;
|
|
69
|
+
let coverage = [];
|
|
70
|
+
let bestScore = -1;
|
|
71
|
+
for (const test of input.tests) {
|
|
72
|
+
if (used.has(test.id))
|
|
73
|
+
continue;
|
|
74
|
+
const matching = [
|
|
75
|
+
...test.covers_files.map(path => "file:" + path),
|
|
76
|
+
...test.covers_requirements.map(r => "requirement:" + r),
|
|
77
|
+
].filter(key => remaining.has(key));
|
|
78
|
+
const score = matching.length / (1 + Math.log2(1 + (test.duration_ms ?? 1000) / 1000));
|
|
79
|
+
if (matching.length > 0 && (score > bestScore || (score === bestScore && test.id < (best?.id ?? "")))) {
|
|
80
|
+
best = test;
|
|
81
|
+
coverage = [...new Set(matching)];
|
|
82
|
+
bestScore = score;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (!best)
|
|
86
|
+
break;
|
|
87
|
+
used.add(best.id);
|
|
88
|
+
for (const target of coverage)
|
|
89
|
+
remaining.delete(target);
|
|
90
|
+
selected.push({ id: best.id, covers: coverage, reported_status: receiptByID.get(best.id) ?? "missing" });
|
|
91
|
+
if (receiptByID.get(best.id) !== "passed")
|
|
92
|
+
issues.push({
|
|
93
|
+
code: "SELECTED_TEST_NOT_VERIFIED", severity: "medium", reference: best.id,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
for (const target of [...remaining].sort().slice(0, 40))
|
|
97
|
+
issues.push({
|
|
98
|
+
code: "UNCOVERED_IMPACT_TARGET", severity: "high", reference: target,
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
status: issues.length ? "RECHECK_IMPACT_EVIDENCE" : "REPORTED_COVERAGE_ONLY",
|
|
102
|
+
affected_files: [...affected].slice(0, 150).map(([path, trace]) => ({ path, ...trace })),
|
|
103
|
+
impacted_requirement_ids: [...new Set(impacted.map(r => r.id))],
|
|
104
|
+
recommended_tests: selected,
|
|
105
|
+
uncovered_targets: [...remaining].sort().slice(0, 40),
|
|
106
|
+
issues: issues.slice(0, 70),
|
|
107
|
+
truncated: affected.size >= 150 || remaining.size > 40 || issues.length > 70,
|
|
108
|
+
independently_verified: false,
|
|
109
|
+
tests_executed: 0,
|
|
110
|
+
warning: "Dependencies, test mappings and receipts are caller-supplied. Graph traversal and test selection do not inspect code, execute tests or prove correctness.",
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export const ImpactOutputSchema = z.object({
|
|
114
|
+
status: z.enum(["RECHECK_IMPACT_EVIDENCE", "REPORTED_COVERAGE_ONLY"]),
|
|
115
|
+
affected_files: z.array(z.object({ path: z.string(), depth: z.number().int(), via: z.string().nullable() }).strict()),
|
|
116
|
+
impacted_requirement_ids: z.array(z.string()),
|
|
117
|
+
recommended_tests: z.array(z.object({ id: z.string(), covers: z.array(z.string()), reported_status: z.enum(["passed", "failed", "not_run", "missing"]) }).strict()),
|
|
118
|
+
uncovered_targets: z.array(z.string()),
|
|
119
|
+
issues: z.array(z.object({ code: z.string(), severity: z.enum(["high", "medium", "low"]), reference: z.string() }).strict()),
|
|
120
|
+
truncated: z.boolean(), independently_verified: z.literal(false), tests_executed: z.literal(0), warning: z.string(),
|
|
121
|
+
}).strict();
|
|
122
|
+
export function registerImpactTool(server) {
|
|
123
|
+
server.registerTool("trace_change_impact", {
|
|
124
|
+
title: "Trace changed-code impact and test coverage",
|
|
125
|
+
description: "Rank affected files and select test cases with explicit dependency and requirement-to-test mappings. All graph and receipt evidence must be supplied by caller; no repository or command execution.",
|
|
126
|
+
inputSchema: ImpactSchema.shape,
|
|
127
|
+
outputSchema: ImpactOutputSchema.shape,
|
|
128
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
129
|
+
_meta: { ui: { resourceUri: QUALITY_UI_URI } },
|
|
130
|
+
}, async (args) => {
|
|
131
|
+
const output = traceChangeImpact(ImpactSchema.parse(args));
|
|
132
|
+
return { structuredContent: output, content: [{ type: "text", text: JSON.stringify(output) }] };
|
|
133
|
+
});
|
|
134
|
+
}
|
package/dist/decision-support.js
CHANGED
|
@@ -134,6 +134,28 @@ function duplicateIDs(cases) {
|
|
|
134
134
|
}
|
|
135
135
|
return [...duplicates].sort();
|
|
136
136
|
}
|
|
137
|
+
/** Exact two-sided McNemar/binomial test on discordant paired outcomes. */
|
|
138
|
+
function pairedMcNemarExact(improved, regressed) {
|
|
139
|
+
const discordant = improved + regressed;
|
|
140
|
+
if (!discordant)
|
|
141
|
+
return null;
|
|
142
|
+
const tail = Math.min(improved, regressed);
|
|
143
|
+
let choose = 1;
|
|
144
|
+
let sum = 0;
|
|
145
|
+
for (let k = 0; k <= tail; k++) {
|
|
146
|
+
if (k > 0)
|
|
147
|
+
choose = choose * (discordant - k + 1) / k;
|
|
148
|
+
sum += choose;
|
|
149
|
+
}
|
|
150
|
+
return Math.min(1, 2 * sum / 2 ** discordant);
|
|
151
|
+
}
|
|
152
|
+
function median(values) {
|
|
153
|
+
if (!values.length)
|
|
154
|
+
return null;
|
|
155
|
+
const ordered = [...values].sort((a, b) => a - b);
|
|
156
|
+
const middle = Math.floor(ordered.length / 2);
|
|
157
|
+
return ordered.length % 2 ? ordered[middle] : (ordered[middle - 1] + ordered[middle]) / 2;
|
|
158
|
+
}
|
|
137
159
|
export function compareEvaluationRuns(baseline, candidate) {
|
|
138
160
|
const duplicates = [...new Set([...duplicateIDs(baseline), ...duplicateIDs(candidate)])];
|
|
139
161
|
const previous = new Map(baseline.map((item) => [item.case_id, item]));
|
|
@@ -163,6 +185,8 @@ export function compareEvaluationRuns(baseline, candidate) {
|
|
|
163
185
|
let costPairs = 0;
|
|
164
186
|
let baselineCost = 0;
|
|
165
187
|
let candidateCost = 0;
|
|
188
|
+
const durationDifferences = [];
|
|
189
|
+
const costDifferences = [];
|
|
166
190
|
for (const id of matching) {
|
|
167
191
|
const old = previous.get(id);
|
|
168
192
|
const now = current.get(id);
|
|
@@ -180,14 +204,26 @@ export function compareEvaluationRuns(baseline, candidate) {
|
|
|
180
204
|
durationPairs++;
|
|
181
205
|
baselineMs += old.duration_ms;
|
|
182
206
|
candidateMs += now.duration_ms;
|
|
207
|
+
durationDifferences.push(now.duration_ms - old.duration_ms);
|
|
183
208
|
}
|
|
184
209
|
if (old.cost_usd !== undefined && now.cost_usd !== undefined) {
|
|
185
210
|
costPairs++;
|
|
186
211
|
baselineCost += old.cost_usd;
|
|
187
212
|
candidateCost += now.cost_usd;
|
|
213
|
+
costDifferences.push(now.cost_usd - old.cost_usd);
|
|
188
214
|
}
|
|
189
215
|
}
|
|
190
216
|
const ratio = (count) => Math.round((count / matching.length) * 10_000) / 100;
|
|
217
|
+
const round = (v) => Math.round(v * 100) / 100;
|
|
218
|
+
const pairedMean = (improved - regressed) / matching.length;
|
|
219
|
+
// Approximate normal interval on paired differences {-1,0,1}; expose only at n>=20.
|
|
220
|
+
const dispersion = (improved + regressed) / matching.length - pairedMean * pairedMean;
|
|
221
|
+
const se = matching.length > 1 ? Math.sqrt(Math.max(0, dispersion / (matching.length - 1))) : 0;
|
|
222
|
+
const pairedInterval = matching.length >= 20 ? {
|
|
223
|
+
lower_points: round(Math.max(-100, 100 * (pairedMean - 1.96 * se))),
|
|
224
|
+
upper_points: round(Math.min(100, 100 * (pairedMean + 1.96 * se))),
|
|
225
|
+
method: "approximate_normal_paired_difference_95_percent",
|
|
226
|
+
} : null;
|
|
191
227
|
return {
|
|
192
228
|
status: matching.length < 20 ? "LOW_SAMPLE_DIRECTIONAL" : "PAIRED_COMPARISON_UNVERIFIED",
|
|
193
229
|
matched_cases: matching.length,
|
|
@@ -203,6 +239,10 @@ export function compareEvaluationRuns(baseline, candidate) {
|
|
|
203
239
|
mean_duration_ms: durationPairs ? { baseline: Math.round(baselineMs / durationPairs), candidate: Math.round(candidateMs / durationPairs) } : null,
|
|
204
240
|
measured_cost_pairs: costPairs,
|
|
205
241
|
mean_cost_usd: costPairs ? { baseline: baselineCost / costPairs, candidate: candidateCost / costPairs } : null,
|
|
242
|
+
paired_delta_95_percent_ci: pairedInterval,
|
|
243
|
+
mcnemar_two_sided_exact_p: pairedMcNemarExact(improved, regressed),
|
|
244
|
+
median_duration_delta_ms: median(durationDifferences),
|
|
245
|
+
median_cost_delta_usd: median(costDifferences),
|
|
206
246
|
independently_verified: false,
|
|
207
247
|
warning: "Paired outcomes are caller-supplied and not independently verified. Small or selectively chosen samples do not establish statistically significant productivity gains.",
|
|
208
248
|
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
export const InstructionAuditSchema = z.object({
|
|
3
|
+
instructions: z.array(z.object({
|
|
4
|
+
source_id: z.string().regex(/^[A-Za-z0-9_.-]{1,64}$/),
|
|
5
|
+
priority: z.enum(["organization", "project", "task"]),
|
|
6
|
+
text: z.string().trim().min(10).max(4_000),
|
|
7
|
+
}).strict()).min(1).max(20),
|
|
8
|
+
}).strict();
|
|
9
|
+
const actionRE = "(?:deploy|publish|merge|delete|write|edit|execute|test|verify|commit|push|share|read)";
|
|
10
|
+
const negate = new RegExp("\\b(?:must\\s+never|must\\s+not|do\\s+not|don't|should\\s+not|never|cannot|prohibited\\s+to)\\s+(" + actionRE + ")\\b", "i");
|
|
11
|
+
const requireAction = new RegExp("\\b(?:must|always|should|required\\s+to)\\s+(" + actionRE + ")\\b", "i");
|
|
12
|
+
export function auditAgentInstructions(instructions) {
|
|
13
|
+
const hints = [];
|
|
14
|
+
const seen = new Map();
|
|
15
|
+
const actions = new Map();
|
|
16
|
+
const refs = new Set();
|
|
17
|
+
let verificationMentioned = false;
|
|
18
|
+
for (let i = 0; i < instructions.length; i++) {
|
|
19
|
+
const doc = instructions[i];
|
|
20
|
+
const ix = i + 1;
|
|
21
|
+
if (refs.has(doc.source_id))
|
|
22
|
+
hints.push({ code: "DUPLICATE_SOURCE_ID", severity: "medium", source_indices: [ix],
|
|
23
|
+
recommendation: "Assign stable unique IDs to policy documents." });
|
|
24
|
+
refs.add(doc.source_id);
|
|
25
|
+
let fenced = false;
|
|
26
|
+
for (const original of doc.text.split(/\r?\n/).slice(0, 120)) {
|
|
27
|
+
let line = original.trim();
|
|
28
|
+
if (line.startsWith("~~~") || line.startsWith(String.fromCharCode(96).repeat(3))) {
|
|
29
|
+
fenced = !fenced;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (fenced || !line)
|
|
33
|
+
continue;
|
|
34
|
+
line = line.replace(/^(?:[-*]\s+|#{1,6}\s+|\d+[.)]\s+)/, "").trim();
|
|
35
|
+
if (!line || line.length > 500)
|
|
36
|
+
continue;
|
|
37
|
+
const normalized = line.toLowerCase().replace(/\s+/g, " ").replace(/[.!]+$/, "");
|
|
38
|
+
if (/\b(test|verify|verification|check)\b/i.test(line))
|
|
39
|
+
verificationMentioned = true;
|
|
40
|
+
if (seen.has(normalized))
|
|
41
|
+
hints.push({ code: "DUPLICATE_RULE", severity: "low",
|
|
42
|
+
source_indices: [seen.get(normalized), ix],
|
|
43
|
+
recommendation: "Deduplicate overlapping agent rules or reference the canonical policy." });
|
|
44
|
+
else
|
|
45
|
+
seen.set(normalized, ix);
|
|
46
|
+
if (/\b(?:skip|bypass|ignore)\s+(?:all\s+)?(?:tests|verification|approvals?)\b/i.test(line) ||
|
|
47
|
+
/\b(?:do anything|without any approval)\b/i.test(line)) {
|
|
48
|
+
hints.push({ code: "RISKY_OVERRIDING_INSTRUCTION", severity: "high", source_indices: [ix],
|
|
49
|
+
recommendation: "Reconcile any blanket bypass with project safety and approval requirements." });
|
|
50
|
+
}
|
|
51
|
+
const negative = negate.exec(line);
|
|
52
|
+
const positive = negative ? null : requireAction.exec(line);
|
|
53
|
+
const match = negative ?? positive;
|
|
54
|
+
if (!match)
|
|
55
|
+
continue;
|
|
56
|
+
const action = match[1].toLowerCase();
|
|
57
|
+
const polarity = negative ? "forbid" : "permit";
|
|
58
|
+
const prior = actions.get(action);
|
|
59
|
+
if (prior && prior.polarity !== polarity)
|
|
60
|
+
hints.push({ code: "POSSIBLE_ACTION_POLICY_CONFLICT",
|
|
61
|
+
severity: "high", source_indices: [prior.index, ix],
|
|
62
|
+
recommendation: "Clarify the scope and precedence of opposing action constraints; do not silently override either." });
|
|
63
|
+
if (!prior)
|
|
64
|
+
actions.set(action, { polarity, index: ix, priority: doc.priority });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (!verificationMentioned && instructions.length > 1)
|
|
68
|
+
hints.push({
|
|
69
|
+
code: "VERIFICATION_POLICY_UNSPECIFIED", severity: "low", source_indices: [],
|
|
70
|
+
recommendation: "Consider documenting observable verification before declaring task completion.",
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
status: hints.length ? "INSTRUCTIONS_NEED_REVIEW" : "NO_DETERMINISTIC_SIGNALS",
|
|
74
|
+
findings: hints.slice(0, 60),
|
|
75
|
+
truncated: hints.length > 60,
|
|
76
|
+
sources_reviewed: instructions.length,
|
|
77
|
+
independently_verified: false,
|
|
78
|
+
warning: "Input documents are treated as untrusted data. Regex-level warnings do not establish semantic conflict, actual rule hierarchy or permission to act.",
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export const InstructionAuditOutputSchema = z.object({
|
|
82
|
+
status: z.enum(["INSTRUCTIONS_NEED_REVIEW", "NO_DETERMINISTIC_SIGNALS"]),
|
|
83
|
+
findings: z.array(z.object({ code: z.string(), severity: z.enum(["high", "medium", "low"]), source_indices: z.array(z.number().int()), recommendation: z.string() }).strict()),
|
|
84
|
+
truncated: z.boolean(), sources_reviewed: z.number().int(), independently_verified: z.literal(false), warning: z.string(),
|
|
85
|
+
}).strict();
|
|
86
|
+
export function registerInstructionAuditTool(server) {
|
|
87
|
+
server.registerTool("audit_agent_instructions", {
|
|
88
|
+
title: "Audit agent instruction consistency",
|
|
89
|
+
description: "Review bounded caller-supplied instruction documents for duplicates, possible opposing action constraints and risky bypass wording. No instruction is executed or promoted.",
|
|
90
|
+
inputSchema: InstructionAuditSchema.shape,
|
|
91
|
+
outputSchema: InstructionAuditOutputSchema.shape,
|
|
92
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
93
|
+
}, async ({ instructions }) => {
|
|
94
|
+
const output = auditAgentInstructions(instructions);
|
|
95
|
+
return { structuredContent: output, content: [{ type: "text", text: JSON.stringify(output) }] };
|
|
96
|
+
});
|
|
97
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
const annotationSchema = z.object({
|
|
3
|
+
readOnlyHint: z.boolean().optional(),
|
|
4
|
+
destructiveHint: z.boolean().optional(),
|
|
5
|
+
idempotentHint: z.boolean().optional(),
|
|
6
|
+
openWorldHint: z.boolean().optional(),
|
|
7
|
+
}).strict();
|
|
8
|
+
const toolSchema = z.object({
|
|
9
|
+
name: z.string().trim().min(1).max(120),
|
|
10
|
+
description: z.string().max(1200).optional(),
|
|
11
|
+
input_schema: z.record(z.string(), z.unknown()).optional(),
|
|
12
|
+
output_schema: z.record(z.string(), z.unknown()).optional(),
|
|
13
|
+
annotations: annotationSchema.optional(),
|
|
14
|
+
}).strict();
|
|
15
|
+
export const McpContractAuditSchema = z.object({ tools: z.array(toolSchema).min(1).max(40) }).strict();
|
|
16
|
+
const flag = (tool_index, code, severity, advice) => ({ tool_index, code, severity, advice });
|
|
17
|
+
function object(value) {
|
|
18
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ?
|
|
19
|
+
value : null;
|
|
20
|
+
}
|
|
21
|
+
function text(value) { return typeof value === "string" ? value : ""; }
|
|
22
|
+
function unsafeArgLimit(prop) {
|
|
23
|
+
return !Number.isFinite(prop.maxLength) && !Array.isArray(prop.enum) && !Object.hasOwn(prop, "const");
|
|
24
|
+
}
|
|
25
|
+
export function reviewMcpToolContracts(tools) {
|
|
26
|
+
const issues = [];
|
|
27
|
+
for (let i = 0; i < tools.length; i++) {
|
|
28
|
+
const item = tools[i];
|
|
29
|
+
const ix = i + 1;
|
|
30
|
+
const name = item.name.toLowerCase();
|
|
31
|
+
const description = item.description ?? "";
|
|
32
|
+
const hasWrites = /(?:^|[_-])(delete|remove|write|edit|execute|run|send|deploy|publish|merge|push|update|create)(?:$|[_-])/.test(name);
|
|
33
|
+
const destructive = /(?:^|[_-])(delete|remove|purge|drop)(?:$|[_-])/.test(name);
|
|
34
|
+
if (description.trim().length < 25)
|
|
35
|
+
issues.push(flag(ix, "UNDERSPECIFIED_TOOL_DESCRIPTION", "medium", "Describe observable behavior, side effects and trust boundary in the tool contract."));
|
|
36
|
+
if (!item.annotations)
|
|
37
|
+
issues.push(flag(ix, "MISSING_BEHAVIOR_ANNOTATIONS", "low", "Declare accurate read-only and destructive hints for client decision-making."));
|
|
38
|
+
if (hasWrites && item.annotations?.readOnlyHint === true)
|
|
39
|
+
issues.push(flag(ix, "READONLY_BEHAVIOR_CONTRADICTION", "high", "Reconcile mutation-like tool name with its readOnlyHint before advertising the tool."));
|
|
40
|
+
if (destructive && item.annotations?.destructiveHint === false)
|
|
41
|
+
issues.push(flag(ix, "DESTRUCTIVE_BEHAVIOR_CONTRADICTION", "high", "Review whether the tool may delete resources and correct descriptive safety hints."));
|
|
42
|
+
if (!item.output_schema)
|
|
43
|
+
issues.push(flag(ix, "OUTPUT_SCHEMA_ABSENT", "low", "Consider a bounded structured result contract for reliable agent consumption."));
|
|
44
|
+
if (item.input_schema) {
|
|
45
|
+
const schema = object(item.input_schema);
|
|
46
|
+
if (schema?.type !== "object")
|
|
47
|
+
issues.push(flag(ix, "UNUSUAL_INPUT_SCHEMA", "medium", "Check whether the declared input schema is a well-scoped object."));
|
|
48
|
+
const properties = object(schema?.properties) ?? {};
|
|
49
|
+
for (const [key, value] of Object.entries(properties).slice(0, 35)) {
|
|
50
|
+
const p = object(value);
|
|
51
|
+
if (/(?:^|_)(?:command|script|code|url|shell|path)(?:$|_)/i.test(key) &&
|
|
52
|
+
p?.type === "string" && unsafeArgLimit(p)) {
|
|
53
|
+
issues.push(flag(ix, "UNBOUNDED_SENSITIVE_ARGUMENT", "medium", "Constrain sensitive text arguments and validate access scope before execution."));
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (/\b(read[- ]only|does not mutate)\b/i.test(description) && hasWrites)
|
|
59
|
+
issues.push(flag(ix, "DESCRIPTION_NAME_MISMATCH", "low", "Confirm actual side effects; natural-language descriptions are not enforcement."));
|
|
60
|
+
if (issues.length > 200)
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
status: issues.length ? "CONTRACT_REVIEW_HINTS" : "NO_DETERMINISTIC_SIGNALS",
|
|
65
|
+
issues: issues.slice(0, 80),
|
|
66
|
+
truncated: issues.length > 80,
|
|
67
|
+
reviewed_tools: tools.length,
|
|
68
|
+
independently_verified: false,
|
|
69
|
+
warning: "Caller-supplied schemas were inspected without executing tools, validating server behavior or verifying annotations. These are heuristics, not vulnerabilities.",
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export const McpContractOutputSchema = z.object({
|
|
73
|
+
status: z.enum(["CONTRACT_REVIEW_HINTS", "NO_DETERMINISTIC_SIGNALS"]),
|
|
74
|
+
issues: z.array(z.object({ tool_index: z.number().int(), code: z.string(), severity: z.enum(["high", "medium", "low"]), advice: z.string() }).strict()),
|
|
75
|
+
truncated: z.boolean(), reviewed_tools: z.number().int(), independently_verified: z.literal(false), warning: z.string(),
|
|
76
|
+
}).strict();
|
|
77
|
+
export function registerMcpContractAuditTool(server) {
|
|
78
|
+
server.registerTool("review_mcp_tool_contracts", {
|
|
79
|
+
title: "Review supplied MCP contracts",
|
|
80
|
+
description: "Read-only bounded design audit of MCP tool descriptions, input/output schemas and annotations. Not a protocol validator, vulnerability scanner or permission grant.",
|
|
81
|
+
inputSchema: McpContractAuditSchema.shape,
|
|
82
|
+
outputSchema: McpContractOutputSchema.shape,
|
|
83
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
84
|
+
}, async ({ tools }) => {
|
|
85
|
+
const output = reviewMcpToolContracts(tools);
|
|
86
|
+
return { structuredContent: output, content: [{ type: "text", text: JSON.stringify(output) }] };
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Optional MCP Apps UI; text-only clients still receive ordinary tool results. */
|
|
2
|
+
export const QUALITY_UI_URI = "ui://godprompt/evidence-review.html";
|
|
3
|
+
export const QUALITY_UI_MIME = "text/html;profile=mcp-app";
|
|
4
|
+
export const QUALITY_UI_HTML = "<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n<meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src 'none'; connect-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'\">\n<title>GodPrompt Evidence Review</title>\n<style>\n:root{color-scheme:light dark;font:14px/1.5 system-ui,sans-serif}\n*{box-sizing:border-box}body{margin:0;padding:14px;color:CanvasText;background:Canvas}\nh1{font-size:1.08rem;margin:0 0 4px}p{margin:2px 0 8px;color:GrayText}\nheader{border-bottom:1px solid GrayText;padding-bottom:10px;margin-bottom:10px}\n.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(100px,1fr));gap:7px;margin:10px 0}\n.stat{border:1px solid GrayText;border-radius:8px;padding:8px}.stat strong{display:block;font-size:1.08rem}\n.controls{display:flex;gap:6px;flex-wrap:wrap;align-items:center;margin:10px 0}\nbutton,input{font:inherit;border:1px solid GrayText;border-radius:6px;padding:5px 8px;color:CanvasText;background:Canvas}\nbutton[aria-pressed=\"true\"]{font-weight:700;outline:2px solid Highlight}\ninput{max-width:100%;flex:1;min-width:130px}\nh2{font-size:1rem;margin:14px 0 5px}\nol,ul{list-style:none;padding:0;margin:0}\nli{margin:4px 0;padding:6px;border-inline-start:3px solid GrayText;background:Canvas;border-radius:4px}\nli.high{border-inline-start-color:#d94646}\nli.medium{border-inline-start-color:#cc8a00}\nli.low{border-inline-start-color:#4f8c8d}\nsmall{color:GrayText}\ncode{overflow-wrap:anywhere}#status{font-weight:650}\n.empty{padding:12px;border:1px dashed GrayText;border-radius:8px}\n</style>\n</head>\n<body>\n<header><h1>GodPrompt · evidence review</h1>\n<p>Read-only, advisory analysis. Supplied results are not independent verification or authorization.</p>\n<div id=\"status\" role=\"status\" aria-live=\"polite\">Connecting to MCP Apps host…</div></header>\n<div class=\"stats\" id=\"stats\"></div>\n<div class=\"controls\">\n<label for=\"query\">Filter</label><input id=\"query\" type=\"search\" placeholder=\"Filter by code or path\" autocomplete=\"off\">\n<button id=\"all\" aria-pressed=\"true\">All</button><button id=\"high\" aria-pressed=\"false\">High</button>\n<button id=\"medium\" aria-pressed=\"false\">Medium</button><button id=\"low\" aria-pressed=\"false\">Low</button>\n</div>\n<section aria-label=\"Findings\"><h2>Findings</h2><ol id=\"findings\"><li class=\"empty\">No result received.</li></ol></section>\n<section aria-label=\"Affected file graph\"><h2>Affected files & dependency paths</h2><ul id=\"graph\"><li class=\"empty\">Graph available for impact reports.</li></ul></section>\n<script>\n\"use strict\";\n(function(){\n const $=id=>document.getElementById(id);\n const state={data:null,filter:\"all\",query:\"\",connected:false};\n function clear(el){while(el.firstChild)el.removeChild(el.firstChild);}\n function item(where,heading,details,severity){\n const li=document.createElement(\"li\");\n if([\"high\",\"medium\",\"low\"].includes(severity))li.className=severity;\n const strong=document.createElement(\"strong\");strong.textContent=String(heading).slice(0,280);li.appendChild(strong);\n if(details){const text=document.createElement(\"div\");text.textContent=String(details).slice(0,600);li.appendChild(text);}\n where.appendChild(li);\n }\n function metric(label,value){\n const div=document.createElement(\"div\");div.className=\"stat\";\n const t=document.createElement(\"small\");t.textContent=label;\n const v=document.createElement(\"strong\");v.textContent=String(value);\n div.appendChild(t);div.appendChild(v);$(\"stats\").appendChild(div);\n }\n function render(){\n const d=state.data;\n if(!d){$(\"status\").textContent=state.connected?\"Waiting for tool result…\":\"Host not initialized.\";return;}\n $(\"status\").textContent=String(d.status??\"REPORTED_ADVISORY\").slice(0,90);\n clear($(\"stats\"));metric(\"Independently verified\",\"No\");\n if(typeof d.events_reviewed===\"number\")metric(\"Events\",d.events_reviewed);\n if(Array.isArray(d.affected_files))metric(\"Affected files\",d.affected_files.length);\n if(Array.isArray(d.recommended_tests))metric(\"Suggested tests\",d.recommended_tests.length);\n const findings=(Array.isArray(d.findings)?d.findings:Array.isArray(d.issues)?d.issues:[]).slice(0,80);\n clear($(\"findings\"));let shown=0;\n for(const f of findings){\n if(!f||typeof f!==\"object\")continue;\n const severity=String(f.severity??\"low\").toLowerCase();\n if(state.filter!==\"all\"&&state.filter!==severity)continue;\n const label=String(f.code??\"Unclassified\").slice(0,140);\n const details=String(f.recommendation??f.advice??f.reference??\"\").slice(0,600);\n if(state.query&&!((label+\" \"+details).toLowerCase().includes(state.query)))continue;\n item($(\"findings\"),label,details,severity);shown++;\n }\n if(!shown)item($(\"findings\"),\"No matching findings\",\"Try another filter.\",\"\");\n clear($(\"graph\"));\n let paths=0;\n for(const entry of (Array.isArray(d.affected_files)?d.affected_files:[]).slice(0,150)){\n if(!entry||typeof entry.path!==\"string\")continue;\n const label=entry.path.slice(0,220);\n if(state.query&&!label.toLowerCase().includes(state.query))continue;\n item($(\"graph\"),label,\"Depth \"+String(entry.depth??\"?\")+\" · linked via \"+String(entry.via??\"changed file\").slice(0,220),\"\");\n paths++;\n }\n if(!paths)item($(\"graph\"),\"No graph entries\",\"Dependency graph is optional and evidence-dependent.\",\"\");\n }\n for(const filter of [\"all\",\"high\",\"medium\",\"low\"]){\n $(filter).addEventListener(\"click\",()=>{state.filter=filter;for(const other of [\"all\",\"high\",\"medium\",\"low\"])$(other).setAttribute(\"aria-pressed\",String(other===filter));render();});\n }\n $(\"query\").addEventListener(\"input\",()=>{state.query=$(\"query\").value.toLowerCase().trim().slice(0,80);render();});\n window.addEventListener(\"message\",event=>{\n if(event.source!==window.parent)return;\n const msg=event.data;\n if(!msg||msg.jsonrpc!==\"2.0\")return;\n if(msg.id===1&&msg.result&&typeof msg.result===\"object\"){\n state.connected=true;\n window.parent.postMessage({jsonrpc:\"2.0\",method:\"ui/notifications/initialized\",params:{}},\"*\");\n render();\n }\n if(msg.method===\"ui/notifications/tool-result\"){\n const d=msg.params&&msg.params.structuredContent;\n if(d&&typeof d===\"object\"&&d.independently_verified===false){state.data=d;render();}\n else $(\"status\").textContent=\"Missing bounded structured result.\";\n }\n });\n window.parent.postMessage({jsonrpc:\"2.0\",id:1,method:\"ui/initialize\",\n params:{protocolVersion:\"2026-01-26\",clientInfo:{name:\"GodPrompt Evidence View\",version:\"1.0.0\"},appCapabilities:{availableDisplayModes:[\"inline\"]}}},\"*\");\n})();\n</script>\n</body>\n</html>";
|
|
5
|
+
export function registerQualityView(server) {
|
|
6
|
+
server.registerResource("godprompt-evidence-view", QUALITY_UI_URI, { mimeType: QUALITY_UI_MIME,
|
|
7
|
+
description: "Read-only interactive display of caller-supplied engineering findings and affected dependencies." }, async (resourceUri) => ({ contents: [{ uri: resourceUri.href, mimeType: QUALITY_UI_MIME, text: QUALITY_UI_HTML }] }));
|
|
8
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -3,9 +3,9 @@ import { CONTENT, VERSION } from "./content.js";
|
|
|
3
3
|
import { CORE_SKILL } from "./skill-content.js";
|
|
4
4
|
export const SERVER_INFO = {
|
|
5
5
|
name: "god-prompt-mcp",
|
|
6
|
-
version: "1.
|
|
6
|
+
version: "1.4.0",
|
|
7
7
|
};
|
|
8
|
-
export const SERVER_INSTRUCTIONS = "For scoped engineering tasks, use classify_task to route the work and get_tailored_guidance to load only the needed phase. Use get_core_skill if the entire core protocol is needed, not on every request. Use review_code_change, audit_requirements and build_test_matrix for bounded caller-supplied evidence and draft test planning. Use diagnose_failure, assess_release_readiness, create_context_handoff and compare_evaluation_runs only for their respective supplied-evidence workflows. None of these tools run external checks, authenticate evidence, authorize release or independently verify work. Load get_protocols, get_gates, or get_anti_patterns only when focused guidance is insufficient. Use get_god_prompt only when the full single-file payload is preferable; request bounded start/maxChars chunks if an MCP bridge truncates large responses. All GodPrompt tools are read-only.";
|
|
8
|
+
export const SERVER_INSTRUCTIONS = "For scoped engineering tasks, use classify_task to route the work and get_tailored_guidance to load only the needed phase. Use get_core_skill if the entire core protocol is needed, not on every request. Use review_code_change, audit_requirements and build_test_matrix for bounded caller-supplied evidence and draft test planning. Use diagnose_failure, assess_release_readiness, create_context_handoff and compare_evaluation_runs only for their respective supplied-evidence workflows. Use audit_agent_trajectory, trace_change_impact, review_mcp_tool_contracts, audit_agent_instructions and design_adversarial_tests only with explicit caller-supplied bounded inputs; they produce unverified review hints or test ideas. None of these tools run external checks, authenticate evidence, authorize release or independently verify work. Load get_protocols, get_gates, or get_anti_patterns only when focused guidance is insufficient. Use get_god_prompt only when the full single-file payload is preferable; request bounded start/maxChars chunks if an MCP bridge truncates large responses. All GodPrompt tools are read-only.";
|
|
9
9
|
const READ_ONLY_ANNOTATIONS = {
|
|
10
10
|
readOnlyHint: true,
|
|
11
11
|
destructiveHint: false,
|
package/dist/stdio.js
CHANGED
|
@@ -7,6 +7,12 @@ import { registerWorkContractTools, WORK_CONTRACT_INSTRUCTIONS } from "./work-co
|
|
|
7
7
|
import { registerPublicEngineeringTools } from "./public-engineering.js";
|
|
8
8
|
import { registerTailoredGuidanceTool } from "./tailored-guidance.js";
|
|
9
9
|
import { registerDecisionSupportTools } from "./decision-support.js";
|
|
10
|
+
import { registerTrajectoryTool } from "./agent-trajectory.js";
|
|
11
|
+
import { registerImpactTool } from "./change-impact.js";
|
|
12
|
+
import { registerMcpContractAuditTool } from "./mcp-contract-audit.js";
|
|
13
|
+
import { registerInstructionAuditTool } from "./instruction-audit.js";
|
|
14
|
+
import { registerAdversarialPlanningTool } from "./adversarial-planning.js";
|
|
15
|
+
import { registerQualityView } from "./quality-view.js";
|
|
10
16
|
import { registerCodexifyCheckpointTool, CODEXIFY_CHECKPOINT_INSTRUCTIONS, } from "./codexify-checkpoint.js";
|
|
11
17
|
function checkpointOptIn() {
|
|
12
18
|
// Only the local Node stdio entrypoint reads this exact opt-in. The Worker
|
|
@@ -27,6 +33,12 @@ function createServer() {
|
|
|
27
33
|
registerPublicEngineeringTools(server);
|
|
28
34
|
registerTailoredGuidanceTool(server);
|
|
29
35
|
registerDecisionSupportTools(server);
|
|
36
|
+
registerTrajectoryTool(server);
|
|
37
|
+
registerImpactTool(server);
|
|
38
|
+
registerMcpContractAuditTool(server);
|
|
39
|
+
registerInstructionAuditTool(server);
|
|
40
|
+
registerAdversarialPlanningTool(server);
|
|
41
|
+
registerQualityView(server);
|
|
30
42
|
if (enabled)
|
|
31
43
|
registerCodexifyCheckpointTool(server);
|
|
32
44
|
registerGodPromptSkillExtension(server);
|
|
@@ -2,6 +2,18 @@ import * as z from "zod/v4";
|
|
|
2
2
|
import { CONTENT } from "./content.js";
|
|
3
3
|
const TYPES = ["BUILD", "DEBUG", "REFACTOR", "CONTENT", "DESIGN", "SHIP", "ANALYZE", "AUTOMATE", "PLAN"];
|
|
4
4
|
const PHASES = ["plan", "execute", "verify", "handoff"];
|
|
5
|
+
/** Small goal-to-tool hints; never automatic tool invocation or permission. */
|
|
6
|
+
const TOOL_HINTS = {
|
|
7
|
+
BUILD: { plan: ["audit_requirements", "build_test_matrix", "create_work_contract"], execute: ["review_code_change", "trace_change_impact"], verify: ["review_work_evidence", "design_adversarial_tests"], handoff: ["create_context_handoff"] },
|
|
8
|
+
DEBUG: { plan: ["diagnose_failure", "create_work_contract"], execute: ["review_code_change", "audit_agent_trajectory"], verify: ["review_work_evidence", "trace_change_impact"], handoff: ["create_context_handoff"] },
|
|
9
|
+
REFACTOR: { plan: ["create_work_contract", "trace_change_impact"], execute: ["review_code_change", "audit_agent_trajectory"], verify: ["review_work_evidence", "build_test_matrix"], handoff: ["create_context_handoff"] },
|
|
10
|
+
CONTENT: { plan: ["audit_requirements"], execute: ["review_code_change"], verify: ["review_work_evidence"], handoff: ["create_context_handoff"] },
|
|
11
|
+
DESIGN: { plan: ["audit_requirements", "build_test_matrix"], execute: ["review_code_change"], verify: ["design_adversarial_tests", "review_work_evidence"], handoff: ["create_context_handoff"] },
|
|
12
|
+
SHIP: { plan: ["assess_release_readiness", "create_work_contract"], execute: ["trace_change_impact"], verify: ["assess_release_readiness", "review_work_evidence"], handoff: ["create_context_handoff"] },
|
|
13
|
+
ANALYZE: { plan: ["audit_requirements", "diagnose_failure"], execute: ["audit_agent_trajectory", "review_mcp_tool_contracts"], verify: ["review_work_evidence"], handoff: ["create_context_handoff"] },
|
|
14
|
+
AUTOMATE: { plan: ["audit_requirements", "review_mcp_tool_contracts"], execute: ["audit_agent_trajectory"], verify: ["build_test_matrix", "review_work_evidence"], handoff: ["create_context_handoff"] },
|
|
15
|
+
PLAN: { plan: ["audit_requirements"], execute: ["build_test_matrix"], verify: ["audit_requirements"], handoff: ["create_context_handoff"] },
|
|
16
|
+
};
|
|
5
17
|
function headingSection(content, heading) {
|
|
6
18
|
const lines = content.split("\n");
|
|
7
19
|
const start = lines.findIndex((line) => line.trim() === `## ${heading}`);
|
|
@@ -47,6 +59,8 @@ export function getTailoredGuidance(taskType, phase, start = 0, maxChars = 1800)
|
|
|
47
59
|
next_start: start + selected.length < text.length ? start + selected.length : null,
|
|
48
60
|
total_chars: text.length,
|
|
49
61
|
truncated: start + selected.length < text.length,
|
|
62
|
+
suggested_tools: start === 0 ? [...TOOL_HINTS[taskType][phase]] : [],
|
|
63
|
+
tool_selection_rule: start === 0 ? "Only use a suggested tool when the caller supplies appropriate bounded evidence; tools are optional, not automatically invoked." : null,
|
|
50
64
|
warning: "Guidance only: the MCP did not inspect a codebase, execute checks, or verify results. Load additional chunks when truncated.",
|
|
51
65
|
};
|
|
52
66
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "god-prompt-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"mcpName": "io.github.AKzar1el/god-prompt-mcp",
|
|
5
5
|
"description": "GodPrompt MCP server + portable Agent Skill for coding agents — TDD, debugging, verification gates, task routing, and progressive disclosure.",
|
|
6
6
|
"private": false,
|
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
"dist/public-engineering.js",
|
|
14
14
|
"dist/tailored-guidance.js",
|
|
15
15
|
"dist/decision-support.js",
|
|
16
|
+
"dist/agent-trajectory.js",
|
|
17
|
+
"dist/change-impact.js",
|
|
18
|
+
"dist/mcp-contract-audit.js",
|
|
19
|
+
"dist/instruction-audit.js",
|
|
20
|
+
"dist/adversarial-planning.js",
|
|
21
|
+
"dist/quality-view.js",
|
|
16
22
|
"dist/codexify-evidence.js",
|
|
17
23
|
"dist/codexify-host-audit.js",
|
|
18
24
|
"dist/codexify-checkpoint.js",
|
|
@@ -20,12 +26,14 @@
|
|
|
20
26
|
"dist/skills.js",
|
|
21
27
|
"dist/content.js",
|
|
22
28
|
"bin/godprompt-proof.mjs",
|
|
29
|
+
"bin/godprompt-repo-map.mjs",
|
|
23
30
|
"README.md",
|
|
24
31
|
"LICENSE"
|
|
25
32
|
],
|
|
26
33
|
"bin": {
|
|
27
34
|
"god-prompt-mcp": "dist/stdio.js",
|
|
28
|
-
"godprompt-proof": "bin/godprompt-proof.mjs"
|
|
35
|
+
"godprompt-proof": "bin/godprompt-proof.mjs",
|
|
36
|
+
"godprompt-repo-map": "bin/godprompt-repo-map.mjs"
|
|
29
37
|
},
|
|
30
38
|
"repository": {
|
|
31
39
|
"type": "git",
|