okstra 0.235.0 → 0.237.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/dist/lib/host-registry-client.d.mts +9 -2
- package/dist/lib/host-registry-client.mjs +29 -3
- package/dist/lib/host-registry-client.mjs.map +1 -1
- package/dist/lib/runtime-payload.mjs +1 -0
- package/dist/lib/runtime-payload.mjs.map +1 -1
- package/docs/architecture/storage-model.md +1 -0
- package/docs/architecture.md +2 -2
- package/docs/cli.md +6 -0
- package/package.json +1 -1
- package/runtime/BUILD.json +2 -2
- package/runtime/bin/lib/okstra/usage.sh +8 -8
- package/runtime/bin/okstra-qwen-exec.sh +5 -0
- package/runtime/prompts/lead/convergence.md +4 -1
- package/runtime/prompts/lead/okstra-lead-contract.md +4 -4
- package/runtime/prompts/profiles/_clarification-recommendation.md +1 -1
- package/runtime/prompts/profiles/_common-contract.md +10 -1
- package/runtime/prompts/wizard/prompts.ko.json +16 -4
- package/runtime/python/okstra_ctl/adapters/providers/antigravity/adapter.py +10 -2
- package/runtime/python/okstra_ctl/adapters/providers/claude/adapter.py +16 -1
- package/runtime/python/okstra_ctl/adapters/providers/codex/adapter.py +20 -5
- package/runtime/python/okstra_ctl/adapters/providers/kimi/adapter.py +17 -9
- package/runtime/python/okstra_ctl/adapters/providers/qwen/adapter.py +88 -0
- package/runtime/python/okstra_ctl/adapters/providers/qwen/manifest.json +1 -0
- package/runtime/python/okstra_ctl/adapters/providers/qwen/settings.json +12 -0
- package/runtime/python/okstra_ctl/adapters/providers/zai/adapter.py +8 -2
- package/runtime/python/okstra_ctl/approval_decisions.py +22 -2
- package/runtime/python/okstra_ctl/business_flow/contracts.py +11 -0
- package/runtime/python/okstra_ctl/business_flow/engine.py +90 -32
- package/runtime/python/okstra_ctl/business_flow/hooks.py +4 -2
- package/runtime/python/okstra_ctl/business_flow/source.py +39 -7
- package/runtime/python/okstra_ctl/business_flow/store.py +94 -28
- package/runtime/python/okstra_ctl/convergence.py +95 -5
- package/runtime/python/okstra_ctl/convergence_critic_verify_prompt.py +11 -10
- package/runtime/python/okstra_ctl/convergence_engine.py +30 -15
- package/runtime/python/okstra_ctl/convergence_reverify_prompt.py +9 -2
- package/runtime/python/okstra_ctl/coverage_census.py +75 -12
- package/runtime/python/okstra_ctl/entrypoints/hosts.py +1 -1
- package/runtime/python/okstra_ctl/lead_progress.py +1 -1
- package/runtime/python/okstra_ctl/manager_cli.py +42 -5
- package/runtime/python/okstra_ctl/manager_launch.py +60 -1
- package/runtime/python/okstra_ctl/manager_store.py +45 -0
- package/runtime/python/okstra_ctl/model_discovery.py +1 -1
- package/runtime/python/okstra_ctl/models.py +2 -2
- package/runtime/python/okstra_ctl/phases/discussion/profile.md +2 -2
- package/runtime/python/okstra_ctl/phases/error_analysis/profile.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation_option_selection/profile.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation_planning/authoring.py +2 -1
- package/runtime/python/okstra_ctl/phases/implementation_planning/instructions/plan-body-verification.md +2 -2
- package/runtime/python/okstra_ctl/phases/implementation_planning/profile.md +3 -3
- package/runtime/python/okstra_ctl/phases/requirements_discovery/profile.md +5 -5
- package/runtime/python/okstra_ctl/plan_item_evidence.py +25 -1
- package/runtime/python/okstra_ctl/registry/provider_registry.py +1 -1
- package/runtime/python/okstra_ctl/render_final_report.py +1 -1
- package/runtime/python/okstra_ctl/run.py +1 -1
- package/runtime/python/okstra_ctl/run_context.py +18 -3
- package/runtime/python/okstra_ctl/schema_excerpt.py +14 -9
- package/runtime/python/okstra_ctl/verdict_blocks.py +7 -2
- package/runtime/python/okstra_ctl/wizard/cli.py +14 -2
- package/runtime/python/okstra_ctl/wizard/engine.py +28 -1
- package/runtime/python/okstra_ctl/wizard/ids.py +8 -0
- package/runtime/python/okstra_ctl/wizard/picker_navigation.py +64 -2
- package/runtime/python/okstra_ctl/wizard/roles.py +194 -45
- package/runtime/python/okstra_ctl/wizard/sources.py +10 -1
- package/runtime/python/okstra_ctl/wizard/state.py +71 -21
- package/runtime/python/okstra_ctl/wizard/statefile.py +8 -3
- package/runtime/python/okstra_ctl/wizard/steps_roles.py +6 -3
- package/runtime/python/okstra_ctl/wizard/worker_settings.py +129 -25
- package/runtime/python/okstra_ctl/worker_audit_ledger.py +50 -8
- package/runtime/python/okstra_ctl/worker_prompt_body.py +26 -2
- package/runtime/python/okstra_ctl/worker_prompt_headers.py +12 -9
- package/runtime/python/okstra_token_usage/claude.py +5 -1
- package/runtime/python/okstra_token_usage/collect.py +3 -3
- package/runtime/python/okstra_token_usage/pricing.py +1 -0
- package/runtime/skills/_fragments/wizard-relay-protocol.md +1 -1
- package/runtime/skills/okstra-discussion/SKILL.md +1 -1
- package/runtime/skills/okstra-manager/SKILL.md +8 -2
- package/runtime/skills/okstra-run/SKILL.md +2 -2
- package/runtime/skills/okstra-setup/SKILL.md +34 -5
- package/runtime/skills/okstra-setup/references/project-config.md +19 -0
- package/runtime/templates/worker-prompt-preamble.md +12 -2
|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
|
|
4
4
|
import hashlib
|
|
5
5
|
import json
|
|
6
|
+
import posixpath
|
|
6
7
|
import re
|
|
7
8
|
import stat
|
|
8
9
|
from collections.abc import Mapping, Sequence
|
|
@@ -31,6 +32,7 @@ class ReviewInputs(TypedDict):
|
|
|
31
32
|
complete: bool
|
|
32
33
|
planContext: dict[str, Any]
|
|
33
34
|
priorReviewHashes: dict[str, str]
|
|
35
|
+
runOwned: dict[str, Any]
|
|
34
36
|
|
|
35
37
|
|
|
36
38
|
def _digest(value: object) -> str:
|
|
@@ -63,6 +65,22 @@ def _file_snapshot(root: Path, name: str) -> FileSnapshot | None:
|
|
|
63
65
|
return None
|
|
64
66
|
|
|
65
67
|
|
|
68
|
+
def _run_owned(manifest: Mapping[str, Any]) -> dict[str, Any]:
|
|
69
|
+
"""The run and task manifests, which every dispatch rewrites.
|
|
70
|
+
|
|
71
|
+
A reviewer may cite them, but a snapshot of one changes with every dispatch, and the review
|
|
72
|
+
facts they hold (assignments, contracts) already enter the `context` digest. Other files in the
|
|
73
|
+
run directory, such as the plan narrative, stay evidence.
|
|
74
|
+
"""
|
|
75
|
+
names = (manifest.get("runManifestPath"), manifest.get("taskManifestPath"))
|
|
76
|
+
return {"files": sorted({posixpath.normpath(str(name)) for name in names if name})}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _is_run_owned(name: str, owned: Mapping[str, Any]) -> bool:
|
|
80
|
+
path = posixpath.normpath(name)
|
|
81
|
+
return any(path == file or path.endswith("/" + file) for file in owned.get("files", []))
|
|
82
|
+
|
|
83
|
+
|
|
66
84
|
def _payload_paths(value: object) -> set[str]:
|
|
67
85
|
if isinstance(value, str):
|
|
68
86
|
return {value} if value and not any(c in value for c in "\n`*") else set()
|
|
@@ -118,9 +136,12 @@ def capture_review_inputs(
|
|
|
118
136
|
"plan_items.py", "plan_item_evidence.py", "plan_review_context.py", "phases/implementation_planning/authoring.py",
|
|
119
137
|
"phases/implementation_planning/instructions/plan-body-verification.md",
|
|
120
138
|
)})
|
|
139
|
+
run_owned = _run_owned(manifest)
|
|
140
|
+
paths = {name for name in paths if not _is_run_owned(name, run_owned)}
|
|
121
141
|
files = {name: _file_snapshot(root, name) for name in sorted(paths)}
|
|
122
142
|
return {
|
|
123
143
|
"version": 1,
|
|
144
|
+
"runOwned": run_owned,
|
|
124
145
|
"planContext": metadata,
|
|
125
146
|
"priorReviewHashes": {str(row["id"]): str(row.get("verifiedReviewHash", "")) for row in previous_rows},
|
|
126
147
|
"items": {str(item["id"]): dict(item) for item in items},
|
|
@@ -180,6 +201,8 @@ def _dependency_closure(row: Mapping[str, Any], inputs: Mapping[str, Any]) -> tu
|
|
|
180
201
|
declared = _vote_dependencies(graph.get(key), inputs.get("workers", []))
|
|
181
202
|
if declared is None:
|
|
182
203
|
return None
|
|
204
|
+
owned = inputs.get("runOwned") or {}
|
|
205
|
+
declared = (declared[0], {name for name in declared[1] if not _is_run_owned(name, owned)})
|
|
183
206
|
if any(not inputs.get("files", {}).get(name)
|
|
184
207
|
or inputs["files"][name]["hash"] == "absent" for name in declared[1]):
|
|
185
208
|
return None
|
|
@@ -198,7 +221,8 @@ def _dependency_closure(row: Mapping[str, Any], inputs: Mapping[str, Any]) -> tu
|
|
|
198
221
|
)
|
|
199
222
|
for field in ("files", "plannedPaths"):
|
|
200
223
|
paths.update(_payload_paths(payload.get(field)))
|
|
201
|
-
|
|
224
|
+
owned = inputs.get("runOwned") or {}
|
|
225
|
+
return item_ids, {name for name in paths if not _is_run_owned(name, owned)}
|
|
202
226
|
|
|
203
227
|
|
|
204
228
|
def review_fingerprint(row: Mapping[str, Any], inputs: Mapping[str, Any]) -> str | None:
|
|
@@ -13,7 +13,7 @@ from ..json_boundary import JsonBoundaryError, load_owned_object
|
|
|
13
13
|
from .factory_loader import FactoryLoadError, load_relative_factory
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
_PROVIDER_DISPLAY_ORDER = ("claude", "codex", "grok", "antigravity", "zai", "kimi")
|
|
16
|
+
_PROVIDER_DISPLAY_ORDER = ("claude", "codex", "grok", "antigravity", "zai", "kimi", "qwen")
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def provider_display_order(provider_id: str) -> tuple[int, str]:
|
|
@@ -484,7 +484,7 @@ def _enforce_schema(data: dict) -> dict | None:
|
|
|
484
484
|
# 구체버전 계열로 돌았는지" 가독성만 준다. CLI 가 실제 고른 버전과 다를 수
|
|
485
485
|
# 있으나 표시이므로 실행에는 무해하다. 새 버전이 나오면 여기만 갱신한다.
|
|
486
486
|
_DISPLAY_CONCRETE_CLAUDE = {
|
|
487
|
-
"fable": "claude-fable-5-
|
|
487
|
+
"fable": "claude-fable-5-2",
|
|
488
488
|
"opus": "claude-opus-5",
|
|
489
489
|
"sonnet": "claude-sonnet-5",
|
|
490
490
|
"haiku": "claude-haiku-5-5",
|
|
@@ -2455,7 +2455,7 @@ def recommended_role_models(
|
|
|
2455
2455
|
codex 이고 다른 provider 요청은 거부된다(`resolve_lead_provider`). 그래서
|
|
2456
2456
|
`lead_provider` 를 받아 그 provider 의 기본값으로 해소한다. 받지 않으면
|
|
2457
2457
|
role 별 레거시 기본값(claude 계열)으로 떨어지는데, 그 값을 codex 호스트
|
|
2458
|
-
화면에 그대로 쓰면 안내는 `opus` 인데 prepare 는 `gpt-6.
|
|
2458
|
+
화면에 그대로 쓰면 안내는 `opus` 인데 prepare 는 `gpt-6.2-sol` 을 배정한다.
|
|
2459
2459
|
"""
|
|
2460
2460
|
lead_provider_id = lead_provider or "claude"
|
|
2461
2461
|
report_writer_provider_id = report_writer_provider or "claude"
|
|
@@ -41,7 +41,23 @@ def latest_run_inputs(
|
|
|
41
41
|
phase_segment: str = "",
|
|
42
42
|
stage: Optional[int] = None,
|
|
43
43
|
) -> dict:
|
|
44
|
-
"""
|
|
44
|
+
"""The latest run's ``inputs`` (see `latest_run_inputs_document`); ``{}`` when absent."""
|
|
45
|
+
document = latest_run_inputs_document(
|
|
46
|
+
project_root, task_group, task_id, phase_segment=phase_segment, stage=stage,
|
|
47
|
+
)
|
|
48
|
+
inputs = document.get("inputs")
|
|
49
|
+
return inputs if isinstance(inputs, dict) else {}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def latest_run_inputs_document(
|
|
53
|
+
project_root: object,
|
|
54
|
+
task_group: str,
|
|
55
|
+
task_id: str,
|
|
56
|
+
*,
|
|
57
|
+
phase_segment: str = "",
|
|
58
|
+
stage: Optional[int] = None,
|
|
59
|
+
) -> dict:
|
|
60
|
+
"""Return the whole latest ``run-inputs-*.json`` record (``{}`` when absent).
|
|
45
61
|
|
|
46
62
|
``phase_segment`` 가 주어지면 그 phase 의 ``runs/<seg>/manifests/`` 와
|
|
47
63
|
``runs/<seg>/stage-*/manifests/`` 만 스캔한다 (resume 는 같은 phase 를 재실행하므로
|
|
@@ -78,8 +94,7 @@ def latest_run_inputs(
|
|
|
78
94
|
data = load_owned_object(candidates[0][1], artifact="run context")
|
|
79
95
|
except JsonBoundaryError:
|
|
80
96
|
return {}
|
|
81
|
-
|
|
82
|
-
return inputs if isinstance(inputs, dict) else {}
|
|
97
|
+
return data if isinstance(data, dict) else {}
|
|
83
98
|
|
|
84
99
|
|
|
85
100
|
def _now_iso() -> str:
|
|
@@ -52,6 +52,19 @@ def _refs_in(obj) -> set[str]:
|
|
|
52
52
|
return set(_REF_RE.findall(json.dumps(obj, ensure_ascii=False)))
|
|
53
53
|
|
|
54
54
|
|
|
55
|
+
def reachable_defs(defs: dict, start: object) -> set[str]:
|
|
56
|
+
"""Names of the ``$defs`` that *start* reaches through ``$ref``, transitively."""
|
|
57
|
+
reachable: set[str] = set()
|
|
58
|
+
work = list(_refs_in(start))
|
|
59
|
+
while work:
|
|
60
|
+
name = work.pop()
|
|
61
|
+
if name in reachable or name not in defs:
|
|
62
|
+
continue
|
|
63
|
+
reachable.add(name)
|
|
64
|
+
work.extend(_refs_in(defs[name]))
|
|
65
|
+
return reachable
|
|
66
|
+
|
|
67
|
+
|
|
55
68
|
def _conditional_applies(entry: dict, task_type: str) -> bool:
|
|
56
69
|
"""True when an ``allOf`` if/then entry is relevant to *task_type*.
|
|
57
70
|
|
|
@@ -219,16 +232,8 @@ def build_schema_excerpt(schema: dict, task_type: str, cut_from_version: str = "
|
|
|
219
232
|
}
|
|
220
233
|
all_of = [e for e in schema.get("allOf", []) if _conditional_applies(e, task_type)]
|
|
221
234
|
|
|
222
|
-
# Reachable $defs = transitive closure of $ref from kept props + allOf.
|
|
223
235
|
defs = schema.get("$defs", {})
|
|
224
|
-
reachable
|
|
225
|
-
work = list(_refs_in(props) | _refs_in(all_of))
|
|
226
|
-
while work:
|
|
227
|
-
name = work.pop()
|
|
228
|
-
if name in reachable or name not in defs:
|
|
229
|
-
continue
|
|
230
|
-
reachable.add(name)
|
|
231
|
-
work.extend(_refs_in(defs[name]))
|
|
236
|
+
reachable = reachable_defs(defs, [props, all_of])
|
|
232
237
|
|
|
233
238
|
excerpt = {
|
|
234
239
|
k: v
|
|
@@ -65,7 +65,7 @@ _ITEM_RE = re.compile(r"^###[ \t]+(?P<id>[^\s:]+)[ \t]*:?.*$", re.MULTILINE)
|
|
|
65
65
|
# `_field_match` enforces that an opening `**` is closed exactly once and that
|
|
66
66
|
# a label without bold carries a bullet.
|
|
67
67
|
_FIELD_KEYS = ("Verdict", "Fixability", "Note", "Explanation", "Prior dissent",
|
|
68
|
-
"Basis", "Your evidence", "Dependencies")
|
|
68
|
+
"Basis", "Your evidence", "Dependencies", "Opened")
|
|
69
69
|
_CANONICAL_KEYS = {key.lower(): key for key in _FIELD_KEYS}
|
|
70
70
|
_FIELD_RE = re.compile(
|
|
71
71
|
r"^(?P<bullet>[-*+][ \t]+)?(?P<open>\*\*)?"
|
|
@@ -105,6 +105,7 @@ class FindingVote:
|
|
|
105
105
|
verdict: str
|
|
106
106
|
disagree_basis: str | None
|
|
107
107
|
explanation: str
|
|
108
|
+
opened: tuple[str, ...] = ()
|
|
108
109
|
|
|
109
110
|
|
|
110
111
|
def _scan_blocks(text: str) -> dict[str, dict[str, str]]:
|
|
@@ -221,7 +222,11 @@ def _finding_vote(
|
|
|
221
222
|
f"finding `{finding_id}` has basis `{basis}` — expected one of "
|
|
222
223
|
f"{sorted(DISAGREE_BASES)}"
|
|
223
224
|
)
|
|
224
|
-
|
|
225
|
+
from .worker_audit_ledger import named_files
|
|
226
|
+
|
|
227
|
+
return FindingVote(
|
|
228
|
+
finding_id, verdict, basis, explanation, named_files(fields.get("Opened", "")),
|
|
229
|
+
)
|
|
225
230
|
|
|
226
231
|
|
|
227
232
|
@dataclass(frozen=True)
|
|
@@ -9,7 +9,7 @@ from okstra_ctl.registry.host_registry import default_host_registry
|
|
|
9
9
|
|
|
10
10
|
from .ids import REQUESTABLE_TASK_TYPES
|
|
11
11
|
from .state import WizardError
|
|
12
|
-
from .statefile import load_state_file, save_state_file
|
|
12
|
+
from .statefile import load_state_file, read_state_file, save_state_file
|
|
13
13
|
from .confirmation import confirmation_block
|
|
14
14
|
from .engine import (
|
|
15
15
|
init_state,
|
|
@@ -113,7 +113,7 @@ def main(argv: list[str]) -> int:
|
|
|
113
113
|
return 0
|
|
114
114
|
|
|
115
115
|
if args.cmd == "step":
|
|
116
|
-
state =
|
|
116
|
+
state, restarted = read_state_file(state_path)
|
|
117
117
|
persisted_state = copy.deepcopy(state)
|
|
118
118
|
if args.no_submit and args.answer is not None:
|
|
119
119
|
print(json.dumps(
|
|
@@ -133,6 +133,18 @@ def main(argv: list[str]) -> int:
|
|
|
133
133
|
ensure_ascii=False, indent=2,
|
|
134
134
|
))
|
|
135
135
|
return 2
|
|
136
|
+
if restarted and not args.no_submit:
|
|
137
|
+
save_state_file(state_path, state)
|
|
138
|
+
print(json.dumps({
|
|
139
|
+
"ok": False,
|
|
140
|
+
"error": (
|
|
141
|
+
"the wizard state was saved by an older okstra version and has "
|
|
142
|
+
"restarted from the first step; the answer was not submitted. "
|
|
143
|
+
"Answer the current prompt instead."
|
|
144
|
+
),
|
|
145
|
+
"current": prompt_payload(state, next_prompt(state)),
|
|
146
|
+
}, ensure_ascii=False, indent=2))
|
|
147
|
+
return 0
|
|
136
148
|
try:
|
|
137
149
|
if args.no_submit:
|
|
138
150
|
result = {"echo": "", "next": prompt_payload(state, next_prompt(state))}
|
|
@@ -37,11 +37,12 @@ from .ids import (
|
|
|
37
37
|
_STEP_TO_GROUP,
|
|
38
38
|
)
|
|
39
39
|
from .state import Prompt, WizardError, WizardState, _is_role_selection_step
|
|
40
|
-
from .prompts import _domain_prompt
|
|
40
|
+
from .prompts import _domain_prompt, _msg
|
|
41
41
|
from .picker_navigation import (
|
|
42
42
|
is_split_picker,
|
|
43
43
|
merge_split_picker_answer,
|
|
44
44
|
present_picker,
|
|
45
|
+
split_by_vendor,
|
|
45
46
|
split_picker,
|
|
46
47
|
)
|
|
47
48
|
from .roles import _step_role, _submit_role_prompt, next_role_prompt
|
|
@@ -184,9 +185,19 @@ def next_prompt(state: WizardState) -> Prompt:
|
|
|
184
185
|
state.__dict__.update(attempt.__dict__)
|
|
185
186
|
|
|
186
187
|
|
|
188
|
+
def _is_model_pick(prompt: Prompt) -> bool:
|
|
189
|
+
return prompt.kind == "pick" and (
|
|
190
|
+
prompt.step.startswith(("role-models:", "role-model:"))
|
|
191
|
+
or prompt.step == "worker_settings_models"
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
|
|
187
195
|
def _native_picker_screen(state: WizardState, prompt: Prompt) -> Prompt:
|
|
188
196
|
"""호스트 네이티브 선택기 한도에 맞춘 화면.
|
|
189
197
|
|
|
198
|
+
모델 선택 화면은 후보 수와 상관없이 벤더별 탭으로 나눈다(`split_by_vendor`).
|
|
199
|
+
그 묶음이 호스트에 실리지 않을 때만 아래 규칙을 쓴다.
|
|
200
|
+
|
|
190
201
|
한도를 넘는 픽은 체크박스든 단일 선택이든 네이티브 질문 묶음에 실리는
|
|
191
202
|
크기(claude-code 4×4=16)까지 같은 화면의 체크박스 질문 여러 개로 자른다
|
|
192
203
|
(`split_picker`) — 사용자는 탭을 옮겨 다니며 한 번에 답한다. 단일 선택을
|
|
@@ -204,6 +215,16 @@ def _native_picker_screen(state: WizardState, prompt: Prompt) -> Prompt:
|
|
|
204
215
|
return prompt
|
|
205
216
|
prompt = prompt.questions[0]
|
|
206
217
|
port = default_host_registry().resolve(state.host_runtime).interaction()
|
|
218
|
+
if _is_model_pick(prompt):
|
|
219
|
+
by_vendor = split_by_vendor(
|
|
220
|
+
prompt,
|
|
221
|
+
max_options=port.native_option_limit,
|
|
222
|
+
max_questions=port.native_question_limit,
|
|
223
|
+
free_input_label=_msg(state.workspace_root, "model_tabs", "free_input", vendors="{vendors}"),
|
|
224
|
+
mixed_label=_msg(state.workspace_root, "model_tabs", "mixed", vendors="{vendors}"),
|
|
225
|
+
)
|
|
226
|
+
if by_vendor is not prompt and _interaction_plan(state, by_vendor).kind == "native-group":
|
|
227
|
+
return by_vendor
|
|
207
228
|
split = split_picker(
|
|
208
229
|
prompt,
|
|
209
230
|
max_options=port.native_option_limit,
|
|
@@ -276,6 +297,12 @@ def _sim_advance(state: WizardState, prompt: Prompt) -> None:
|
|
|
276
297
|
prompt = _next_prompt_screen(state)
|
|
277
298
|
try:
|
|
278
299
|
if _is_role_selection_step(prompt.step):
|
|
300
|
+
# A pending typed-model step has no default answer: count it and
|
|
301
|
+
# settle the role from its model screen's recommended set.
|
|
302
|
+
if prompt.kind == "text":
|
|
303
|
+
state.role_model_drafts.pop(_step_role(prompt.step), None)
|
|
304
|
+
state.answered.append(prompt.step)
|
|
305
|
+
prompt = next_role_prompt(state) or prompt
|
|
279
306
|
# 화면은 호스트 한도에 맞춰 쪽으로 잘린 사본일 수 있다 — 기본답은
|
|
280
307
|
# 잘리지 않은 원본(추천 집합)에서 낸다.
|
|
281
308
|
original = next_role_prompt(state) or prompt
|
|
@@ -348,8 +348,16 @@ _REUSE_FILLED_STEPS = (
|
|
|
348
348
|
S_CLARIFICATION_PICK, S_CLARIFICATION)
|
|
349
349
|
|
|
350
350
|
|
|
351
|
+
_INPUT_PREFIX = "role-model-input:"
|
|
351
352
|
_MODELS_PREFIX = "role-models:"
|
|
352
353
|
_SINGLE_PREFIX = "role-model:"
|
|
354
|
+
_ROLE_SELECTION_PREFIXES = (_INPUT_PREFIX, _MODELS_PREFIX, _SINGLE_PREFIX)
|
|
355
|
+
# A vendor tab's "type a model" row: the prefix plus the tab's providers joined by "+".
|
|
356
|
+
MODEL_FREE_INPUT_PREFIX = "__free_input__:"
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def _role_model_input_prompt_id(role: str) -> str:
|
|
360
|
+
return f"{_INPUT_PREFIX}{role}"
|
|
353
361
|
|
|
354
362
|
|
|
355
363
|
def _role_models_prompt_id(role: str) -> str:
|
|
@@ -13,8 +13,8 @@ import json
|
|
|
13
13
|
import math
|
|
14
14
|
from dataclasses import replace
|
|
15
15
|
|
|
16
|
-
from .ids import PICK_TYPE_CUSTOM
|
|
17
|
-
from .state import Prompt, WizardError
|
|
16
|
+
from .ids import MODEL_FREE_INPUT_PREFIX, PICK_TYPE_CUSTOM
|
|
17
|
+
from .state import Option, Prompt, WizardError
|
|
18
18
|
|
|
19
19
|
_SPLIT_SEPARATOR = "#"
|
|
20
20
|
|
|
@@ -69,6 +69,68 @@ def split_picker(
|
|
|
69
69
|
)
|
|
70
70
|
|
|
71
71
|
|
|
72
|
+
def split_by_vendor(
|
|
73
|
+
prompt: Prompt,
|
|
74
|
+
*,
|
|
75
|
+
max_options: int,
|
|
76
|
+
max_questions: int,
|
|
77
|
+
free_input_label: str,
|
|
78
|
+
mixed_label: str,
|
|
79
|
+
) -> Prompt:
|
|
80
|
+
"""Show a model pick as one checkbox tab per vendor on one screen.
|
|
81
|
+
|
|
82
|
+
Each tab lists up to `max_options - 1` of a vendor's models, keeping the
|
|
83
|
+
recommended ones, and ends with a "type a model" row whose value names the tab's
|
|
84
|
+
providers. A vendor with that many models gets its own tab; the others
|
|
85
|
+
share one mixed tab. When the own tabs and the mixed tab exceed
|
|
86
|
+
`max_questions`, the last own tabs join the mixed one. Rows that are not
|
|
87
|
+
`provider/model` refs (a skip row) are left out: an empty answer means
|
|
88
|
+
nothing picked. Returns the prompt unchanged when it holds no model.
|
|
89
|
+
"""
|
|
90
|
+
models = [option for option in prompt.options if "/" in option.value]
|
|
91
|
+
if prompt.kind != "pick" or not models or max_options < 2:
|
|
92
|
+
return prompt
|
|
93
|
+
shown = max_options - 1
|
|
94
|
+
vendors: dict[str, list[Option]] = {}
|
|
95
|
+
for option in models:
|
|
96
|
+
vendors.setdefault(option.value.split("/", 1)[0], []).append(option)
|
|
97
|
+
own = [vendor for vendor, rows in vendors.items() if len(rows) >= shown]
|
|
98
|
+
mixed = [vendor for vendor in vendors if vendor not in own]
|
|
99
|
+
if len(own) + (1 if mixed else 0) > max_questions:
|
|
100
|
+
keep = max_questions - 1
|
|
101
|
+
mixed = [vendor for vendor in vendors if vendor in own[keep:] or vendor in mixed]
|
|
102
|
+
own = own[:keep]
|
|
103
|
+
groups = [[vendor] for vendor in own] + ([mixed] if mixed else [])
|
|
104
|
+
questions: list[Prompt] = []
|
|
105
|
+
for index, group in enumerate(groups, start=1):
|
|
106
|
+
rows = [option for vendor in group for option in vendors[vendor]]
|
|
107
|
+
picked = sorted(rows, key=lambda option: not option.recommended)[:shown]
|
|
108
|
+
rows = [option for option in rows if option in picked]
|
|
109
|
+
name = group[0] if len(group) == 1 else mixed_label.format(vendors="·".join(group))
|
|
110
|
+
questions.append(replace(
|
|
111
|
+
prompt,
|
|
112
|
+
step=f"{prompt.step}{_SPLIT_SEPARATOR}{index}",
|
|
113
|
+
label=f"{prompt.label} [{name}]",
|
|
114
|
+
options=[
|
|
115
|
+
*rows,
|
|
116
|
+
Option(
|
|
117
|
+
f"{MODEL_FREE_INPUT_PREFIX}{'+'.join(group)}",
|
|
118
|
+
free_input_label.format(vendors=name),
|
|
119
|
+
),
|
|
120
|
+
],
|
|
121
|
+
multi=True,
|
|
122
|
+
))
|
|
123
|
+
return Prompt(
|
|
124
|
+
step=prompt.step,
|
|
125
|
+
kind="pick_group",
|
|
126
|
+
label=prompt.label,
|
|
127
|
+
help=prompt.help,
|
|
128
|
+
echo_template=prompt.echo_template,
|
|
129
|
+
multi=prompt.multi,
|
|
130
|
+
questions=questions,
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
|
|
72
134
|
def is_split_picker(prompt: Prompt) -> bool:
|
|
73
135
|
return prompt.kind == "pick_group" and bool(prompt.questions) and all(
|
|
74
136
|
question.multi
|