@giamme/forge 0.14.0 → 0.15.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/CHANGELOG.md +26 -0
- package/SKILL.md +47 -14
- package/VERSION +1 -1
- package/docs/artifacts.md +2 -1
- package/docs/commands.md +301 -7
- package/docs/models.md +53 -0
- package/package.json +1 -1
- package/references/dataset.md +12 -3
- package/references/decompose.md +108 -7
- package/references/harnesses.md +21 -1
- package/references/planning.md +59 -0
- package/references/ui.md +39 -1
- package/scripts/forge-compare.py +6 -3
- package/scripts/forge-config.py +531 -4
- package/scripts/forge-dispatch.sh +132 -22
- package/scripts/forge-lib-plans.sh +19 -2
- package/scripts/forge-lib-review.sh +5 -3
- package/scripts/forge-lib-task.sh +119 -0
- package/scripts/forge-parallel-options.sh +12 -6
- package/scripts/forge-parallel.sh +572 -26
- package/scripts/forge-plan-check.py +591 -8
- package/scripts/forge-planner.py +480 -0
- package/scripts/forge-route.py +72 -23
- package/scripts/forge-runtime.py +157 -1
- package/scripts/forge-shadow.py +51 -7
- package/scripts/forge-solo.sh +81 -7
- package/scripts/forge_dataset/cli.py +10 -0
- package/scripts/forge_dataset/efforts.py +215 -0
- package/scripts/forge_dataset/harvest.py +44 -0
- package/scripts/forge_decide/__init__.py +19 -1
- package/scripts/forge_decide/builtin_profiles.json +25 -0
- package/scripts/forge_decide/cli.py +12 -0
- package/scripts/forge_decide/profiles.py +866 -0
- package/scripts/forge_decide/resolve.py +38 -6
- package/ui/docs/api.md +87 -8
- package/ui/forge_ui/control.py +173 -12
- package/ui/forge_ui/executions.py +28 -8
- package/ui/forge_ui/models.py +60 -1
- package/ui/forge_ui/reader.py +21 -1
- package/ui/forge_ui/static/leaderboard.js +5 -1
- package/ui/forge_ui/static/modelstats.js +25 -1
- package/ui/forge_ui/static/panel.js +19 -2
- package/ui/forge_ui/static/settings.js +788 -25
- package/ui/forge_ui/static/style.css +23 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"""A note when a spec is measurably slower than a lower effort of the same model.
|
|
2
|
+
|
|
3
|
+
`slow_note` is advisory. It never changes the spec it was given, and the callers that
|
|
4
|
+
print it (doctor --spec, and the plan table) do not change an exit code because of it.
|
|
5
|
+
|
|
6
|
+
The dataset decides when it is on and both this effort and a lower one of the same model
|
|
7
|
+
have at least five first attempts. Each lower effort is checked, nearest first. The note
|
|
8
|
+
names the nearest one this effort is at least twice as slow as, with a first-try pass
|
|
9
|
+
rate no better. A nearer pair that has enough data but fails that rule does not hide a
|
|
10
|
+
farther pair that meets it. When at least one pair has enough data and none meet the
|
|
11
|
+
rule, there is no note: measured data overrides the built-in table. Otherwise one
|
|
12
|
+
built-in row applies, `haiku:max` against `haiku:xhigh` on the claude harness's model
|
|
13
|
+
(#86, 2026-10-28).
|
|
14
|
+
|
|
15
|
+
python3 -m forge_dataset.efforts SPEC
|
|
16
|
+
|
|
17
|
+
prints the note, or nothing. Run it from `scripts/`. `plan_notes` gives the plan table's
|
|
18
|
+
lines (`forge-dataset.py slow-notes PLAN`, printed by `forge-parallel.sh plan`), kept out
|
|
19
|
+
of forge-plan-check.py: that file builds the planner's send-back prompt, and nothing that
|
|
20
|
+
builds a prompt reads the dataset.
|
|
21
|
+
"""
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import math
|
|
25
|
+
import statistics
|
|
26
|
+
import subprocess
|
|
27
|
+
import sys
|
|
28
|
+
from pathlib import Path
|
|
29
|
+
|
|
30
|
+
from . import SKILL, connect, dataset_dir, enabled
|
|
31
|
+
from .export import Runs, Store
|
|
32
|
+
from .forecast import registry_models, resolve
|
|
33
|
+
from .routing import tasks as routing_tasks
|
|
34
|
+
|
|
35
|
+
MIN_TASKS = 5
|
|
36
|
+
# No measured pair had five first attempts on both sides, so the built-in table may speak.
|
|
37
|
+
_SKIP = object()
|
|
38
|
+
|
|
39
|
+
# alias, effort, the lower effort, and the harness whose model id the row belongs to.
|
|
40
|
+
# openclaude's haiku is that same model; opencode's is not, and does not match.
|
|
41
|
+
_TABLE = (
|
|
42
|
+
dict(alias='haiku', effort='max', lower='xhigh', harness='claude',
|
|
43
|
+
passes=(7, 7), lower_passes=(4, 4), minutes=7.8, lower_minutes=1.9,
|
|
44
|
+
source='#86, 2026-10-28'),
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _parts(spec):
|
|
49
|
+
"""(alias, effort or None, harness or None) of alias[:effort[:harness]]."""
|
|
50
|
+
parts = str(spec or '').split(':')
|
|
51
|
+
alias = parts[0]
|
|
52
|
+
effort = parts[1] if len(parts) > 1 and parts[1] else None
|
|
53
|
+
harness = parts[2] if len(parts) > 2 and parts[2] else None
|
|
54
|
+
return alias, effort, harness
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _efforts(spec) -> list:
|
|
58
|
+
"""Efforts the pairing accepts, weakest first. Empty when dispatch cannot say."""
|
|
59
|
+
try:
|
|
60
|
+
done = subprocess.run(
|
|
61
|
+
['bash', str(SKILL / 'scripts' / 'forge-dispatch.sh'), 'efforts', '--spec', spec],
|
|
62
|
+
capture_output=True, text=True, timeout=30)
|
|
63
|
+
except (OSError, subprocess.SubprocessError):
|
|
64
|
+
return []
|
|
65
|
+
if done.returncode != 0:
|
|
66
|
+
return []
|
|
67
|
+
return [line.strip() for line in done.stdout.splitlines() if line.strip()]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _runs(store):
|
|
71
|
+
"""A Runs over `store` (a Runs, a Store, or a connection), or over the dataset.
|
|
72
|
+
|
|
73
|
+
Reading the default store does not create one: a machine with no dataset yet is
|
|
74
|
+
simply a machine with no measured rows.
|
|
75
|
+
"""
|
|
76
|
+
if isinstance(store, Runs):
|
|
77
|
+
return store
|
|
78
|
+
if isinstance(store, Store):
|
|
79
|
+
return Runs(store)
|
|
80
|
+
if store is not None:
|
|
81
|
+
return Runs(Store(store))
|
|
82
|
+
if not (dataset_dir() / 'dataset.sqlite').is_file():
|
|
83
|
+
return None
|
|
84
|
+
db = connect()
|
|
85
|
+
try:
|
|
86
|
+
return Runs(Store(db))
|
|
87
|
+
finally:
|
|
88
|
+
db.close()
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _arm(records, model_id, effort) -> dict:
|
|
92
|
+
"""n (first attempts with an outcome), passes, and the median of runtime_s/attempts."""
|
|
93
|
+
group = [r for r in records if r.get('model_id') == model_id and r.get('effort') == effort
|
|
94
|
+
and r.get('first_pass') is not None]
|
|
95
|
+
samples = []
|
|
96
|
+
for record in group:
|
|
97
|
+
attempts = record.get('attempts') or 0
|
|
98
|
+
runtime = record.get('runtime_s')
|
|
99
|
+
if isinstance(runtime, bool) or isinstance(attempts, bool):
|
|
100
|
+
continue
|
|
101
|
+
if isinstance(runtime, (int, float)) and isinstance(attempts, (int, float)) and attempts > 0:
|
|
102
|
+
if math.isfinite(runtime) and math.isfinite(attempts):
|
|
103
|
+
samples.append(runtime / attempts)
|
|
104
|
+
return dict(n=len(group), k=sum(1 for r in group if r['first_pass']),
|
|
105
|
+
median=statistics.median(samples) if samples else None)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def _line(alias, effort, lower, passes, lower_passes, minutes, lower_minutes, source) -> str:
|
|
109
|
+
k, n = passes
|
|
110
|
+
k2, n2 = lower_passes
|
|
111
|
+
ratio = int(math.floor(minutes / lower_minutes + 0.5))
|
|
112
|
+
return ('%s:%s: no measured gain over %s:%s (first try %d/%d vs %d/%d) at about %dx the time '
|
|
113
|
+
'(%.1f vs %.1f min; %s). The spec is unchanged.'
|
|
114
|
+
% (alias, effort, alias, lower, k, n, k2, n2, ratio, minutes, lower_minutes, source))
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _from_dataset(records, alias, effort, model_id, lowers):
|
|
118
|
+
"""The dataset's note, None when measured pairs do not qualify, or _SKIP.
|
|
119
|
+
|
|
120
|
+
`lowers` is weakest first, so the walk starts at the nearest. The first lower
|
|
121
|
+
effort that meets the rule is the one named. A pair with enough data that fails
|
|
122
|
+
the rule does not stop the walk: a farther effort may still qualify. If any pair
|
|
123
|
+
had enough data and none met the rule, return None so the built-in table stays quiet.
|
|
124
|
+
"""
|
|
125
|
+
hi = _arm(records, model_id, effort)
|
|
126
|
+
measured = False
|
|
127
|
+
for lower in reversed(lowers):
|
|
128
|
+
lo = _arm(records, model_id, lower)
|
|
129
|
+
if hi['n'] < MIN_TASKS or lo['n'] < MIN_TASKS:
|
|
130
|
+
continue
|
|
131
|
+
measured = True
|
|
132
|
+
slower = (hi['median'] is not None and lo['median'] is not None and lo['median'] > 0
|
|
133
|
+
and hi['median'] >= 2 * lo['median'])
|
|
134
|
+
no_better = hi['k'] * lo['n'] <= lo['k'] * hi['n']
|
|
135
|
+
if slower and no_better:
|
|
136
|
+
return _line(alias, effort, lower, (hi['k'], hi['n']), (lo['k'], lo['n']),
|
|
137
|
+
hi['median'] / 60.0, lo['median'] / 60.0,
|
|
138
|
+
'forge dataset, %d runs' % (hi['n'] + lo['n']))
|
|
139
|
+
return None if measured else _SKIP
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _from_table(alias, effort, model_id, lowers, registry):
|
|
143
|
+
for row in _TABLE:
|
|
144
|
+
if (alias, effort) != (row['alias'], row['effort']) or row['lower'] not in lowers:
|
|
145
|
+
continue
|
|
146
|
+
same = (registry.get(alias) or {}).get(row['harness'])
|
|
147
|
+
if not same or model_id != same:
|
|
148
|
+
continue
|
|
149
|
+
return _line(alias, effort, row['lower'], row['passes'], row['lower_passes'],
|
|
150
|
+
row['minutes'], row['lower_minutes'], row['source'])
|
|
151
|
+
return None
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def slow_note(spec, *, store=None):
|
|
155
|
+
"""One note when `spec` is a measured slowdown, else None. Never raises."""
|
|
156
|
+
try:
|
|
157
|
+
alias, effort, _harness = _parts(spec)
|
|
158
|
+
if not alias or not effort:
|
|
159
|
+
return None
|
|
160
|
+
registry = registry_models()
|
|
161
|
+
model_id, effort = resolve(spec, registry)
|
|
162
|
+
if not model_id or not effort:
|
|
163
|
+
return None
|
|
164
|
+
ladder = _efforts(spec)
|
|
165
|
+
if effort not in ladder:
|
|
166
|
+
return None
|
|
167
|
+
lowers = ladder[:ladder.index(effort)]
|
|
168
|
+
if not lowers:
|
|
169
|
+
return None
|
|
170
|
+
# The flag gates the dataset, an injected store included. No file yet is not an error:
|
|
171
|
+
# there is nothing measured, so the built-in table still applies.
|
|
172
|
+
if enabled():
|
|
173
|
+
runs = _runs(store)
|
|
174
|
+
if runs is not None:
|
|
175
|
+
found = _from_dataset(routing_tasks(runs), alias, effort, model_id, lowers)
|
|
176
|
+
if found is not _SKIP:
|
|
177
|
+
return found
|
|
178
|
+
return _from_table(alias, effort, model_id, lowers, registry)
|
|
179
|
+
except Exception:
|
|
180
|
+
return None
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def plan_notes(plan) -> list:
|
|
184
|
+
"""`note:` lines for the distinct slow specs in a plan's dwarf and qa columns.
|
|
185
|
+
|
|
186
|
+
After routing, tasks.tsv holds concrete specs. The same spec twice is one line. A
|
|
187
|
+
missing table prints nothing.
|
|
188
|
+
"""
|
|
189
|
+
from .harvest import tasks_rows
|
|
190
|
+
seen, out = set(), []
|
|
191
|
+
for row in tasks_rows(Path(plan) / 'tasks.tsv').values():
|
|
192
|
+
for spec in (row.get('dwarf'), row.get('qa')):
|
|
193
|
+
spec = (spec or '').strip()
|
|
194
|
+
if not spec or spec == '-' or spec in seen:
|
|
195
|
+
continue
|
|
196
|
+
seen.add(spec)
|
|
197
|
+
text = slow_note(spec)
|
|
198
|
+
if text:
|
|
199
|
+
out.append('note: ' + text)
|
|
200
|
+
return out
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def main(argv=None) -> int:
|
|
204
|
+
args = list(sys.argv[1:] if argv is None else argv)
|
|
205
|
+
if len(args) != 1:
|
|
206
|
+
print('usage: python3 -m forge_dataset.efforts SPEC', file=sys.stderr)
|
|
207
|
+
return 2
|
|
208
|
+
text = slow_note(args[0])
|
|
209
|
+
if text:
|
|
210
|
+
print(text)
|
|
211
|
+
return 0
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
if __name__ == '__main__':
|
|
215
|
+
sys.exit(main())
|
|
@@ -120,6 +120,14 @@ def as_int(value) -> int | None:
|
|
|
120
120
|
return None
|
|
121
121
|
|
|
122
122
|
|
|
123
|
+
def as_text(value) -> str | None:
|
|
124
|
+
"""A non-empty string, or None. A missing tier field and a JSON null both land here."""
|
|
125
|
+
if isinstance(value, str):
|
|
126
|
+
value = value.strip()
|
|
127
|
+
return value or None
|
|
128
|
+
return None
|
|
129
|
+
|
|
130
|
+
|
|
123
131
|
def signature(path: Path) -> list | None:
|
|
124
132
|
try:
|
|
125
133
|
st = path.stat()
|
|
@@ -414,6 +422,10 @@ def dispatch_event(attempt: Path, root: Path, role: str, harness: str, rc, prov:
|
|
|
414
422
|
# gets its own role: nothing that reads qa dispatches mistakes it for the one that decided.
|
|
415
423
|
role='qa_shadow' if shadow and role == 'qa' else role, alias=resolved.get('alias'), harness=harness, model=resolved.get('model'),
|
|
416
424
|
effort=None if not effort or effort.startswith('<') else effort,
|
|
425
|
+
# metrics.json is the record finish() wrote. A run from before that record falls
|
|
426
|
+
# back to the resolved line, which exists only when a tier was asked.
|
|
427
|
+
service_tier=as_text(metrics.get('service_tier')) or as_text(resolved.get('service_tier')),
|
|
428
|
+
speed=as_text(metrics.get('speed')), speed_reason=as_text(metrics.get('speed_reason')),
|
|
417
429
|
yolo=resolved.get('yolo') == 'ON', passthrough=resolved.get('passthrough') == 'yes',
|
|
418
430
|
clamped=resolved.get('clamped'), timeout=as_int(resolved.get('timeout')),
|
|
419
431
|
timeout_source=resolved.get('timeout_source'), delivery=delivery,
|
|
@@ -710,6 +722,18 @@ def plan_event(plan: Path, prov: dict, src: str = 'live', inventory: bool = True
|
|
|
710
722
|
plan_gates = read_json(plan / 'plan-gates.json')
|
|
711
723
|
if plan_gates is not None:
|
|
712
724
|
later['plan_gates'] = plan_gates
|
|
725
|
+
# Same rule as plan_gates: hashed only when the file is there, so a plan from before
|
|
726
|
+
# these records keeps its id. plan-gate.json is the planner's one-task-or-plan record
|
|
727
|
+
# (plan-gates.json, plural, is the decision-model gates).
|
|
728
|
+
plan_shape = read_json(plan / 'plan-shape.json')
|
|
729
|
+
collapsed_record = read_json(plan / 'collapsed.json')
|
|
730
|
+
plan_gate = read_json(plan / 'plan-gate.json')
|
|
731
|
+
if plan_shape is not None:
|
|
732
|
+
later['plan_shape'] = plan_shape
|
|
733
|
+
if collapsed_record is not None:
|
|
734
|
+
later['collapsed'] = collapsed_record
|
|
735
|
+
if plan_gate is not None:
|
|
736
|
+
later['plan_gate'] = plan_gate
|
|
713
737
|
inputs = json.dumps([text(plan / 'goal.txt'), text(plan / 'tasks.tsv'), text(declared_path),
|
|
714
738
|
{t: [r['prompt'], r['approach']] for t, r in per_task.items()}] + ([later] if later else []),
|
|
715
739
|
sort_keys=True, default=str)
|
|
@@ -739,6 +763,26 @@ def plan_event(plan: Path, prov: dict, src: str = 'live', inventory: bool = True
|
|
|
739
763
|
)
|
|
740
764
|
if plan_gates is not None:
|
|
741
765
|
data['plan_gates'] = plan_gates
|
|
766
|
+
if plan_shape is not None:
|
|
767
|
+
# shape, widest and the count of waves come from plan-shape.json. The count is
|
|
768
|
+
# `wave_count`: `waves` stays the task→wave map on every plan, one type across the store.
|
|
769
|
+
if 'shape' in plan_shape:
|
|
770
|
+
data['shape'] = plan_shape['shape']
|
|
771
|
+
if 'widest' in plan_shape:
|
|
772
|
+
data['widest'] = plan_shape['widest']
|
|
773
|
+
if 'waves' in plan_shape:
|
|
774
|
+
data['wave_count'] = plan_shape['waves']
|
|
775
|
+
if collapsed_record is not None:
|
|
776
|
+
data['collapsed'] = True
|
|
777
|
+
origin = collapsed_record.get('from')
|
|
778
|
+
if isinstance(origin, list):
|
|
779
|
+
data['collapsed_from'] = origin
|
|
780
|
+
if plan_gate is not None:
|
|
781
|
+
data['plan_gate'] = plan_gate
|
|
782
|
+
# Who started the plan: `auto` for forge-parallel.sh auto. Absent for a plan built by hand.
|
|
783
|
+
orchestrator = first_line(plan / 'orchestrator')
|
|
784
|
+
if orchestrator:
|
|
785
|
+
data['orchestrator'] = orchestrator
|
|
742
786
|
return dict(rid='plan:%s:%s' % (prov.get('run'), sha256(inputs.encode())[:16]), kind='plan',
|
|
743
787
|
ts=time.time(), src=src, run=prov.get('run'), run_id=prov.get('run_id'), mode='parallel',
|
|
744
788
|
inv=prov.get('inv'), data=data)
|
|
@@ -14,9 +14,27 @@ File schema, the same at both levels (unknown keys are kept and ignored):
|
|
|
14
14
|
"budget": {"run_tokens", "run_usd", "daily_tokens", "daily_usd"},
|
|
15
15
|
"providers": {"<name>": {"type", "url", "model", "key_env", "key_file", "context",
|
|
16
16
|
"price_usd_per_mtok", "local"}},
|
|
17
|
-
"
|
|
17
|
+
"default_profile": "<name>",
|
|
18
|
+
"profiles": {"<name>": {
|
|
19
|
+
"routing": {"dwarf": {"any"|"low"|"medium"|"high": [spec, ...]},
|
|
20
|
+
"qa": {"any"|"low"|"medium"|"high": [spec, ...]},
|
|
21
|
+
"planner": spec, "fractal_planner": spec, "final_reviewer": spec,
|
|
22
|
+
"escalate_after": int >= 0, "escalate_effort": bool},
|
|
23
|
+
"policy": {"qa_threshold": "P0"|"P1"|"P2"|"P3"|"none", "retry_failed": int >= 0,
|
|
24
|
+
"infra_retries": int >= 0, "verify_retries": int >= 0, "timeout": int >= 0,
|
|
25
|
+
"explore": number in [0, 0.5], "shadow_qa": [spec, ...],
|
|
26
|
+
"shadow_rate": number in [0, 1],
|
|
27
|
+
"fast": ["dwarf"|"qa"|"planner"|"review", ...]},
|
|
28
|
+
"gates": {...as above...}, "budget": {...as above...}}},
|
|
18
29
|
"privacy": "never-send"}
|
|
19
30
|
|
|
31
|
+
A spec is alias[:effort[:harness]]. Every key of a profile is optional. Unknown keys inside
|
|
32
|
+
`routing` or `policy` (and unknown tiers under `dwarf`/`qa`) are refused by
|
|
33
|
+
profiles.validate(), to catch typos; unknown top-level keys of a profile are kept and
|
|
34
|
+
ignored. `default_profile` names the profile a run uses when none is asked for (the user
|
|
35
|
+
file's beats the repo file's). Two built-in profiles, `balanced` and `lite`
|
|
36
|
+
(builtin_profiles.json, read-only), are found after both files; see profiles.py.
|
|
37
|
+
|
|
20
38
|
A provider's key comes from `key_env` when that variable is set, else from `key_file`; it
|
|
21
39
|
may name both, or neither (a local server may need no key).
|
|
22
40
|
A gate may also be written as a bare mode string ("drift": "on"). USER_ONLY keys count only
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"profiles": {
|
|
4
|
+
"balanced": {
|
|
5
|
+
"source": "#86 SWE-bench Pro decomposed runs, 2026-10-28; docs/models.md",
|
|
6
|
+
"routing": {
|
|
7
|
+
"dwarf": {"low": ["haiku:xhigh"], "medium": ["sonnet:medium"], "high": ["opus:high"]},
|
|
8
|
+
"qa": {"low": ["sonnet:medium"], "medium": ["sonnet:high"], "high": ["opus:high"]},
|
|
9
|
+
"planner": "sonnet:high",
|
|
10
|
+
"escalate_after": 2
|
|
11
|
+
},
|
|
12
|
+
"policy": {"retry_failed": 2}
|
|
13
|
+
},
|
|
14
|
+
"lite": {
|
|
15
|
+
"source": "#86 SWE-bench Pro decomposed runs, 2026-10-28; docs/models.md",
|
|
16
|
+
"routing": {
|
|
17
|
+
"dwarf": {"low": ["haiku:xhigh"], "medium": ["sonnet:medium"], "high": ["sonnet:high"]},
|
|
18
|
+
"qa": {"low": ["sonnet:medium"], "medium": ["sonnet:high"], "high": ["sonnet:high"]},
|
|
19
|
+
"planner": "sonnet:high",
|
|
20
|
+
"escalate_after": 2
|
|
21
|
+
},
|
|
22
|
+
"policy": {"retry_failed": 2}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -402,6 +402,18 @@ def cmd_gate(args) -> int:
|
|
|
402
402
|
else:
|
|
403
403
|
data = _user_preview()
|
|
404
404
|
configured = data.get('providers') if isinstance(data.get('providers'), dict) else {}
|
|
405
|
+
if args.profile is not None and repo is None:
|
|
406
|
+
# Gates go into the user file's profile of that name. Where only another level has it (a
|
|
407
|
+
# built-in, a repo profile), that would create a user profile holding just the gates, which
|
|
408
|
+
# hides the other copy's routing and policy.
|
|
409
|
+
from . import profiles as profiles_module
|
|
410
|
+
own = data.get('profiles') if isinstance(data.get('profiles'), dict) else {}
|
|
411
|
+
other = profiles_module.available(_repo(None)).get(args.profile)
|
|
412
|
+
if args.profile not in own and other is not None:
|
|
413
|
+
kind = 'built-in' if other['level'] == 'builtin' else '%s-level' % other['level']
|
|
414
|
+
raise Usage('%s profile %r is not stored in your user file, and gates for it would hide it; '
|
|
415
|
+
'copy it first: forge config profile create NAME --from %s, then pass --profile NAME'
|
|
416
|
+
% (kind, args.profile, args.profile))
|
|
405
417
|
if args.provider is not None and args.provider not in configured:
|
|
406
418
|
# A legacy provider exists only once migrated; a --repo write never touches the user
|
|
407
419
|
# file, so there it has to be migrated already.
|