promptwheel 0.7.1 → 0.7.3
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/LICENSE +202 -21
- package/README.md +11 -2
- package/bin/promptwheel.mjs +90 -2
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,21 +1,202 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# PromptWheel
|
|
2
2
|
|
|
3
|
-
[](https://github.com/promptwheel-ai/promptwheel/actions/workflows/ci.yml) [](https://github.com/promptwheel-ai/promptwheel/actions/workflows/ci.yml) [](LICENSE)  
|
|
4
4
|
|
|
5
5
|
**A deterministic check for your coding loop.** A green test should mean your agent *fixed the code*, not that it edited the test to match the bug. PromptWheel tells the difference: it re-proves every win from the source changes alone, with no LLM, so a win that only survived by editing the test reads `GAMED`. Un-gameable by construction, because the code being checked never gets to grade itself.
|
|
6
6
|
|
|
@@ -104,6 +104,15 @@ npx promptwheel suggest # UCB over the lever scores, proven le
|
|
|
104
104
|
npx promptwheel backfill -n 30 # cold start: seed the record from git history (cohort-tagged, commit types → labels)
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
+
## Give your agent the gate
|
|
108
|
+
|
|
109
|
+
`promptwheel init` writes this into your `AGENTS.md` for you (and `CLAUDE.md` / `.cursorrules` if present; `--no-agent-block` to skip), so a coding agent (or a loop) runs the gate itself, not just you. To paste it yourself:
|
|
110
|
+
|
|
111
|
+
After a change that should move a measurable metric (tests, lint, coverage, an eval), run
|
|
112
|
+
`npx promptwheel run --working`. Exit 2 (verdict GAMED) means the win came from editing a test,
|
|
113
|
+
config, or grader, not the source, so revert and earn it in the source. Exit 1 means a guarded
|
|
114
|
+
metric regressed, revert that too. Never weaken, skip, or delete a test to go green.
|
|
115
|
+
|
|
107
116
|
**The consequence ledger.** git records *what changed*; PromptWheel records *what the change did*, same trust model (local, deterministic, append-only, no server, no LLM in the verdict). `playbook` and `suggest` are pure re-derivations over that ledger: every rendered line was measured by the gate, decays unless re-earned, and stays hidden below an evidence threshold. No compounding claim is made for them until the A/B acceptance test (`bench/compounding-ab.mjs`) passes on real usage data.
|
|
108
117
|
|
|
109
118
|
**Footprint:** it never touches your working tree, every measurement runs in a throwaway git worktree **in your system temp dir** (one at a time; configured `linkDirs` are symlinked not copied, `node_modules` by default, `.venv` for Python, etc.), removed when the run finishes. The only thing PromptWheel writes to your repo is the optional `.promptwheel/outcomes.jsonl` record, commit it to build the per-repo "what moves what" history, or `.gitignore` it (`--no-record` to skip entirely). A hard-killed run can't leave clutter behind: the next run **self-heals** any orphaned worktree (stale registry entry + abandoned temp checkout).
|
|
@@ -256,4 +265,4 @@ The engine is one importable file; pure helpers are exported for unit tests, the
|
|
|
256
265
|
- [x] zero-config: `run` and `check()` auto-detect the gate with no committed config, `init` becomes optional (0.6.0)
|
|
257
266
|
- [x] declared override (`Sawbuck-Allow:` trailer / `--allow`) + `init` build-setup detection, so a build-gated test measures instead of reading inert (0.7.0)
|
|
258
267
|
|
|
259
|
-
> Status: **published** (npm `promptwheel`, v0.7.
|
|
268
|
+
> Status: **published** (npm `promptwheel`, v0.7.1), all core phases built. Lineage: CommandLayer → BlockSpool → PromptWheel (orchestrator, archived) → **PromptWheel (outcome gate)**.
|
package/bin/promptwheel.mjs
CHANGED
|
@@ -458,6 +458,45 @@ function gateFingerprint(metricsList, scalars) {
|
|
|
458
458
|
return createHash('sha256').update(JSON.stringify(norm)).digest('hex').slice(0, 16);
|
|
459
459
|
}
|
|
460
460
|
|
|
461
|
+
// tool version (read once from the sibling package.json) for the provenance receipt
|
|
462
|
+
const TOOL_VERSION = (() => {
|
|
463
|
+
try { return JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf8')).version || null; }
|
|
464
|
+
catch { return null; }
|
|
465
|
+
})();
|
|
466
|
+
|
|
467
|
+
// full sha of a ref, best-effort (never throws into the gate)
|
|
468
|
+
function safeRev(repo, ref) { try { return git(['rev-parse', ref], repo); } catch { return null; } }
|
|
469
|
+
|
|
470
|
+
// SHA-256 (truncated) of a file's content at a ref, or null if the file is absent there
|
|
471
|
+
function blobHashAt(repo, ref, path) {
|
|
472
|
+
try { return createHash('sha256').update(execFileSync('git', ['show', `${ref}:${path}`], { cwd: repo, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] })).digest('hex').slice(0, 16); }
|
|
473
|
+
catch { return null; } // absent at this ref (added or removed)
|
|
474
|
+
}
|
|
475
|
+
// declared evaluatorPaths whose CONTENT changed between base and head. A declared gate file is a
|
|
476
|
+
// goalpost the user named; editing it in the same diff that improves a metric is gamed by
|
|
477
|
+
// declaration (content-hash auto-fail) - deterministic even when the source-only re-run is inert.
|
|
478
|
+
// Fires ONLY on declared files, so the opt-in semantics (an undeclared config stays source) hold.
|
|
479
|
+
function changedEvaluatorPaths(repo, base, head, cfg) {
|
|
480
|
+
const isEval = evaluatorMatcher(cfg);
|
|
481
|
+
let changed = [];
|
|
482
|
+
try { changed = git(['diff', '--name-only', base, head], repo).split('\n').filter(Boolean).filter(isEval); }
|
|
483
|
+
catch { return []; }
|
|
484
|
+
return changed.map((p) => ({ path: p, base: blobHashAt(repo, base, p), head: blobHashAt(repo, head, p) }))
|
|
485
|
+
.filter((e) => e.base !== e.head);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// reproducible fingerprint of the verdict CONTENT (everything but the provenance block itself), so
|
|
489
|
+
// a skeptic who re-runs (base, head, config) gets the same hash - the tamper-evident receipt.
|
|
490
|
+
function verdictFingerprint(report) {
|
|
491
|
+
const norm = {
|
|
492
|
+
verdict: report.verdict,
|
|
493
|
+
metrics: (report.metrics || []).map((m) => ({ name: m.name, status: m.status, ok: m.ok === true, guard: m.guard === true, gamed: m.gamed === true }))
|
|
494
|
+
.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0)),
|
|
495
|
+
gate: (report.gate && report.gate.fingerprint) || null,
|
|
496
|
+
};
|
|
497
|
+
return createHash('sha256').update(JSON.stringify(norm)).digest('hex').slice(0, 16);
|
|
498
|
+
}
|
|
499
|
+
|
|
461
500
|
// guarded metrics that HEAD dropped relative to BASE (removed entirely, or guard turned off)
|
|
462
501
|
function gateWeakenings(baseGate, headMetrics) {
|
|
463
502
|
if (!baseGate) return [];
|
|
@@ -522,6 +561,22 @@ function gate(repo, opts) {
|
|
|
522
561
|
m.gamed = j.gamed; m.sourceOnly = j.sourceOnly; m.retained = j.retained; m.gamingReason = j.reason;
|
|
523
562
|
}
|
|
524
563
|
}
|
|
564
|
+
// content-hash auto-fail (Section 3): a declared evaluatorPath gate file edited in this diff is a
|
|
565
|
+
// moved goalpost, so a metric that improved alongside it is gamed by declaration - deterministic,
|
|
566
|
+
// even if the source-only re-run above read inert. An allow-trailer can still clear it, below.
|
|
567
|
+
let evalChanged = [];
|
|
568
|
+
if (opts.detectGaming) {
|
|
569
|
+
evalChanged = changedEvaluatorPaths(repo, base, head, cfg);
|
|
570
|
+
if (evalChanged.length) {
|
|
571
|
+
for (const m of metrics) {
|
|
572
|
+
if (m.status !== 'improved' || m.gamed === true) continue;
|
|
573
|
+
const cm = cfg.metrics.find((c) => c.name === m.name);
|
|
574
|
+
if (cm && cm.gamingCheck === false) continue; // tripwire/test-side guards legitimately live in gate files
|
|
575
|
+
m.gamed = true;
|
|
576
|
+
m.gamingReason = `a declared evaluatorPath gate file changed in this diff (${evalChanged.map((e) => e.path).join(', ')}); a win alongside a goalpost edit is gamed by declaration`;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
525
580
|
// gate integrity (Section 3): did HEAD weaken the gate it is judged by? Resolve the gate as
|
|
526
581
|
// of BASE; a guard HEAD dropped is re-measured under its base definition and only counts as
|
|
527
582
|
// tampering if it WOULD HAVE FAILED at head (a real regression hidden by dropping the guard).
|
|
@@ -545,6 +600,7 @@ function gate(repo, opts) {
|
|
|
545
600
|
head: gateFingerprint(cfg.metrics, cfg),
|
|
546
601
|
},
|
|
547
602
|
...(weakened.length ? { weakened } : {}),
|
|
603
|
+
...(evalChanged.length ? { evaluatorChanged: evalChanged } : {}),
|
|
548
604
|
};
|
|
549
605
|
}
|
|
550
606
|
// declared override: a Sawbuck-Allow trailer (or --allow) acknowledges an intentional
|
|
@@ -579,6 +635,14 @@ function gate(repo, opts) {
|
|
|
579
635
|
...(gateInfo ? { gate: gateInfo } : {}),
|
|
580
636
|
...(allowed ? { allowed } : {}),
|
|
581
637
|
};
|
|
638
|
+
// provenance receipt: makes the verdict tamper-evident + reproducible ("re-run and get the same
|
|
639
|
+
// verdict is checkable"). Additive to the record; never changes the verdict.
|
|
640
|
+
report.provenance = {
|
|
641
|
+
tool: 'promptwheel', toolVersion: TOOL_VERSION,
|
|
642
|
+
baseSha: safeRev(repo, base), headSha: opts.working ? head : safeRev(repo, head),
|
|
643
|
+
configHash: gateFingerprint(cfg.metrics, cfg),
|
|
644
|
+
verdictHash: verdictFingerprint(report),
|
|
645
|
+
};
|
|
582
646
|
if (!opts.noRecord && cfg.record !== false) recordOutcome(repo, report);
|
|
583
647
|
return report;
|
|
584
648
|
}
|
|
@@ -970,10 +1034,34 @@ function init(argv) {
|
|
|
970
1034
|
if (envCfg.linkDirs) note += ` · linking ${envCfg.linkDirs.join(', ')}`;
|
|
971
1035
|
writeFileSync(out, JSON.stringify({ repeat: 1, ...envCfg, ...(evaluatorPaths ? { evaluatorPaths } : {}), metrics }, null, 2) + '\n');
|
|
972
1036
|
console.log(`✓ wrote promptwheel.config.json, ${note}`);
|
|
1037
|
+
if (!argv.includes('--no-agent-block')) {
|
|
1038
|
+
const wrote = writeAgentBlock(repo);
|
|
1039
|
+
if (wrote.length) console.log(`✓ wrote the agent guide (when to run the gate) to ${wrote.join(', ')}`);
|
|
1040
|
+
}
|
|
973
1041
|
console.log('\n next: promptwheel run --working # gate your uncommitted changes');
|
|
974
1042
|
console.log(' promptwheel init --list # other presets (llm-eval, bundle-size, …)');
|
|
975
1043
|
}
|
|
976
1044
|
|
|
1045
|
+
// Write (or refresh) a short agent-orienting block so the coding AGENT runs the gate itself, not just
|
|
1046
|
+
// the human. Goes into AGENTS.md (the cross-tool convention; created if absent) and into CLAUDE.md /
|
|
1047
|
+
// .cursorrules when those already exist. Idempotent + safe: only the sentinel-delimited block is
|
|
1048
|
+
// touched, everything else in the file is left exactly as-is. `--no-agent-block` skips it.
|
|
1049
|
+
function writeAgentBlock(repo) {
|
|
1050
|
+
const START = '<!-- promptwheel:gate -->', END = '<!-- /promptwheel:gate -->';
|
|
1051
|
+
const block = `${START}\n## PromptWheel gate\n\nAfter a change that should move a measurable metric (tests, lint, coverage, an eval), run \`npx promptwheel run --working\`. Exit 2 (verdict GAMED) means the win came from editing a test, config, or grader, not the source, so revert and earn it in the source. Exit 1 means a guarded metric regressed, revert that too. Never weaken, skip, or delete a test to go green.\n${END}\n`;
|
|
1052
|
+
const targets = ['AGENTS.md', ...['CLAUDE.md', '.cursorrules'].filter((f) => existsSync(join(repo, f)))];
|
|
1053
|
+
const done = [];
|
|
1054
|
+
for (const f of targets) {
|
|
1055
|
+
const p = join(repo, f);
|
|
1056
|
+
let text = existsSync(p) ? readFileSync(p, 'utf8') : '';
|
|
1057
|
+
const s = text.indexOf(START);
|
|
1058
|
+
if (s > -1) { const e = text.indexOf(END, s); text = (e > -1 ? text.slice(0, s) + block + text.slice(e + END.length).replace(/^\n+/, '\n') : text.slice(0, s) + block); }
|
|
1059
|
+
else { text = (text.trim() ? text.replace(/\n*$/, '\n\n') : '') + block; }
|
|
1060
|
+
try { writeFileSync(p, text); done.push(f); } catch { /* best-effort */ }
|
|
1061
|
+
}
|
|
1062
|
+
return done;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
977
1065
|
// observability: list the EFFECTIVE guardrails (incl. inherited) + each one's flag record
|
|
978
1066
|
function guards(argv) {
|
|
979
1067
|
const args = parseArgs(argv);
|
|
@@ -1070,7 +1158,7 @@ function parseArgs(argv) {
|
|
|
1070
1158
|
|
|
1071
1159
|
// pure, side-effect-free helpers are exported for unit testing; the CLI below only
|
|
1072
1160
|
// runs when this file is executed directly (not when imported by the test suite).
|
|
1073
|
-
export { extract, evaluate, median, spread, renderMarkdown, isNonSource, evaluatorMatcher, gain, judgeGaming, foldOutcomes, betaMean, scoreKey };
|
|
1161
|
+
export { extract, evaluate, median, spread, renderMarkdown, isNonSource, evaluatorMatcher, gain, judgeGaming, foldOutcomes, betaMean, scoreKey, verdictFingerprint };
|
|
1074
1162
|
|
|
1075
1163
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
1076
1164
|
// Public library API: the Verified-Outcome Contract, in process.
|
|
@@ -1288,7 +1376,7 @@ function main() {
|
|
|
1288
1376
|
console.log([
|
|
1289
1377
|
'PromptWheel, catch your agent cheating. Prove a change moved a real metric (and that the agent earned it, not gamed it). The per-turn reward + source-only audit for AI coding loops.',
|
|
1290
1378
|
'',
|
|
1291
|
-
' promptwheel init [--preset <name> | --list] write a starter config (OPTIONAL: run works zero-config, auto-detecting your test command)',
|
|
1379
|
+
' promptwheel init [--preset <name> | --list] [--no-agent-block] write a starter config + an AGENTS.md guide so your agent runs the gate (OPTIONAL: run works zero-config, auto-detecting your test command)',
|
|
1292
1380
|
' promptwheel run [--base R] [--head R] [--repeat N] [--json|--markdown]',
|
|
1293
1381
|
' catches reward-hacking BY DEFAULT, re-proves each win from SOURCE edits alone (verdict GAMED,',
|
|
1294
1382
|
' exit 2, when a metric only moved by editing tests/config/grader). Use --no-detect-gaming for the bare gate.',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "promptwheel",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "A deterministic, zero-LLM check for your coding loop. It proves every change earned its win by re-running the result from the agent's source edits alone, so a green that came from editing the test reads GAMED. Runs in CI or a Claude Code hook, or import { check } in process.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"url": "https://github.com/promptwheel-ai/promptwheel/issues"
|
|
35
35
|
},
|
|
36
36
|
"author": "Matthew Owens",
|
|
37
|
-
"license": "
|
|
37
|
+
"license": "Apache-2.0",
|
|
38
38
|
"keywords": [
|
|
39
39
|
"agent",
|
|
40
40
|
"ci",
|