okstra 0.232.0 → 0.233.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 +19 -283
- package/dist/cli-registry.mjs +8 -1
- package/dist/cli-registry.mjs.map +1 -1
- package/dist/commands/execute/render-bundle.d.mts +6 -1
- package/dist/commands/execute/render-bundle.mjs +139 -32
- package/dist/commands/execute/render-bundle.mjs.map +1 -1
- package/dist/commands/lifecycle/config.mjs +6 -74
- package/dist/commands/lifecycle/config.mjs.map +1 -1
- package/dist/commands/trace/capacity.d.mts +12 -0
- package/dist/commands/trace/capacity.mjs +21 -0
- package/dist/commands/trace/capacity.mjs.map +1 -0
- package/dist/commands/trace/model.d.mts +89 -0
- package/dist/commands/trace/model.mjs +251 -0
- package/dist/commands/trace/model.mjs.map +1 -0
- package/dist/commands/trace/progression.d.mts +11 -0
- package/dist/commands/trace/progression.mjs +194 -0
- package/dist/commands/trace/progression.mjs.map +1 -0
- package/dist/commands/trace/review.d.mts +7 -0
- package/dist/commands/trace/review.mjs +51 -0
- package/dist/commands/trace/review.mjs.map +1 -0
- package/dist/commands/trace/task-link.d.mts +18 -0
- package/dist/commands/trace/task-link.mjs +72 -0
- package/dist/commands/trace/task-link.mjs.map +1 -0
- package/dist/commands/trace/trace.d.mts +1 -0
- package/dist/commands/trace/trace.mjs +293 -0
- package/dist/commands/trace/trace.mjs.map +1 -0
- package/dist/lib/bounded-file.d.mts +1 -0
- package/dist/lib/bounded-file.mjs +36 -0
- package/dist/lib/bounded-file.mjs.map +1 -0
- package/dist/lib/config-store.d.mts +34 -0
- package/dist/lib/config-store.mjs +70 -0
- package/dist/lib/config-store.mjs.map +1 -0
- package/dist/lib/file-lock.mjs +4 -5
- package/dist/lib/file-lock.mjs.map +1 -1
- package/dist/lib/input-limit.d.mts +4 -0
- package/dist/lib/input-limit.mjs +8 -0
- package/dist/lib/input-limit.mjs.map +1 -0
- package/dist/lib/memory-auto-register.mjs +2 -17
- package/dist/lib/memory-auto-register.mjs.map +1 -1
- package/dist/lib/report-language-tag.d.mts +1 -0
- package/dist/lib/report-language-tag.mjs +4 -0
- package/dist/lib/report-language-tag.mjs.map +1 -0
- package/dist/lib/report-language.d.mts +1 -0
- package/dist/lib/report-language.mjs +50 -0
- package/dist/lib/report-language.mjs.map +1 -0
- package/dist/lib/skill-catalog.mjs +3 -0
- package/dist/lib/skill-catalog.mjs.map +1 -1
- package/docs/architecture/storage-model.md +36 -5
- package/docs/architecture.md +10 -4
- package/docs/cli.md +279 -2
- package/docs/contributor-change-matrix.md +1 -2
- package/docs/project-structure-overview.md +31 -41
- package/package.json +1 -1
- package/runtime/BUILD.json +2 -2
- package/runtime/agents/operations/trace-interface-review.json +6 -0
- package/runtime/agents/operations/trace-scope-review.json +6 -0
- package/runtime/prompts/coding-preflight/authoring-checks.md +1 -1
- package/runtime/prompts/coding-preflight/clean-code.md +18 -20
- package/runtime/prompts/coding-preflight/overview.md +1 -1
- package/runtime/prompts/duties/code-reviewer.json +1 -1
- package/runtime/prompts/duties/interface-reviewer.json +32 -0
- package/runtime/prompts/host-orchestration/README.md +18 -9
- package/runtime/prompts/launch.template.md +3 -2
- package/runtime/prompts/lead/context-loader.md +2 -0
- package/runtime/prompts/lead/okstra-lead-contract.md +7 -7
- package/runtime/prompts/lead/report-writer.md +6 -6
- package/runtime/prompts/profiles/_coding-conventions-preflight.md +2 -2
- package/runtime/prompts/profiles/_common-contract.md +1 -1
- package/runtime/python/okstra_ctl/agent/invocation.py +1 -0
- package/runtime/python/okstra_ctl/agent/prompt_cli/cli.py +66 -26
- package/runtime/python/okstra_ctl/agent/prompt_cli/corrections.py +23 -8
- package/runtime/python/okstra_ctl/agent/prompt_cli/materialize.py +28 -10
- package/runtime/python/okstra_ctl/agent/prompt_cli/results.py +8 -11
- package/runtime/python/okstra_ctl/agent/standalone.py +12 -0
- package/runtime/python/okstra_ctl/analysis_packet.py +22 -11
- package/runtime/python/okstra_ctl/code_review_census.py +93 -2
- package/runtime/python/okstra_ctl/code_review_prepare.py +381 -0
- package/runtime/python/okstra_ctl/code_review_run.py +384 -0
- package/runtime/python/okstra_ctl/code_review_scope.py +13 -0
- package/runtime/python/okstra_ctl/code_review_supervisor.py +41 -0
- package/runtime/python/okstra_ctl/code_review_target.py +140 -15
- package/runtime/python/okstra_ctl/coverage_census.py +11 -2
- package/runtime/python/okstra_ctl/design_snapshot.py +16 -9
- package/runtime/python/okstra_ctl/direct_work.py +45 -3
- package/runtime/python/okstra_ctl/dispatch_core.py +31 -15
- package/runtime/python/okstra_ctl/dispatch_state.py +9 -2
- package/runtime/python/okstra_ctl/domain/role.py +1 -0
- package/runtime/python/okstra_ctl/doyouknow/sources/manager.py +48 -9
- package/runtime/python/okstra_ctl/final_report_schema.py +37 -34
- package/runtime/python/okstra_ctl/incremental_carry.py +6 -7
- package/runtime/python/okstra_ctl/initial_prompt_materialization.py +9 -2
- package/runtime/python/okstra_ctl/json_boundary.py +33 -6
- package/runtime/python/okstra_ctl/manager_cli.py +122 -1
- package/runtime/python/okstra_ctl/manager_journal.py +126 -0
- package/runtime/python/okstra_ctl/manager_launch.py +3 -3
- package/runtime/python/okstra_ctl/manager_log.py +221 -0
- package/runtime/python/okstra_ctl/manager_paths.py +8 -0
- package/runtime/python/okstra_ctl/manager_resume.py +59 -0
- package/runtime/python/okstra_ctl/manager_split.py +2 -2
- package/runtime/python/okstra_ctl/manager_store.py +116 -17
- package/runtime/python/okstra_ctl/manager_sync.py +42 -3
- package/runtime/python/okstra_ctl/manager_view.py +35 -2
- package/runtime/python/okstra_ctl/material.py +2 -0
- package/runtime/python/okstra_ctl/model_cli.py +64 -14
- package/runtime/python/okstra_ctl/model_defaults.py +22 -0
- package/runtime/python/okstra_ctl/model_io/renderers.py +3 -0
- package/runtime/python/okstra_ctl/operation_invocation.py +207 -28
- package/runtime/python/okstra_ctl/path_hints.py +14 -3
- package/runtime/python/okstra_ctl/paths.py +6 -1
- package/runtime/python/okstra_ctl/phases/catalog.py +24 -7
- package/runtime/python/okstra_ctl/phases/implementation/host-rules.md +3 -3
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-diff-review.md +8 -6
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-self-check.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation_option_selection/profile.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation_option_selection/votes.py +11 -11
- package/runtime/python/okstra_ctl/phases/implementation_planning/authoring.py +12 -9
- package/runtime/python/okstra_ctl/phases/implementation_planning/host-rules.md +3 -6
- package/runtime/python/okstra_ctl/phases/implementation_planning/instructions/plan-body-verification.md +12 -10
- package/runtime/python/okstra_ctl/phases/implementation_planning/profile.md +5 -5
- package/runtime/python/okstra_ctl/phases/improvement_discovery/lenses.py +12 -0
- package/runtime/python/okstra_ctl/phases/improvement_discovery/profile.md +7 -6
- package/runtime/python/okstra_ctl/phases/improvement_discovery/resolved_census.py +159 -0
- package/runtime/python/okstra_ctl/phases/improvement_discovery/spec.md +5 -2
- package/runtime/python/okstra_ctl/phases/improvement_discovery/validation.py +21 -7
- package/runtime/python/okstra_ctl/phases/release_handoff/boundary.json +1 -1
- package/runtime/python/okstra_ctl/phases/release_handoff/profile.md +4 -1
- package/runtime/python/okstra_ctl/plan_verify_cli.py +6 -4
- package/runtime/python/okstra_ctl/render.py +28 -2
- package/runtime/python/okstra_ctl/report_assembly.py +38 -11
- package/runtime/python/okstra_ctl/report_contract.py +26 -0
- package/runtime/python/okstra_ctl/report_corrections.py +36 -20
- package/runtime/python/okstra_ctl/report_inputs.py +1 -0
- package/runtime/python/okstra_ctl/report_language.py +4 -1
- package/runtime/python/okstra_ctl/report_narrative.py +179 -7
- package/runtime/python/okstra_ctl/report_projections.py +64 -18
- package/runtime/python/okstra_ctl/report_synthesis_packet.py +86 -36
- package/runtime/python/okstra_ctl/run.py +43 -35
- package/runtime/python/okstra_ctl/run_context.py +10 -1
- package/runtime/python/okstra_ctl/set_work_status.py +4 -15
- package/runtime/python/okstra_ctl/task_list_cli.py +34 -8
- package/runtime/python/okstra_ctl/task_query.py +239 -0
- package/runtime/python/okstra_ctl/trace_review.py +264 -0
- package/runtime/python/okstra_ctl/trace_tasks.py +197 -0
- package/runtime/python/okstra_ctl/user_authorization.py +14 -0
- package/runtime/python/okstra_ctl/wizard/confirmation.py +7 -3
- package/runtime/python/okstra_ctl/wizard/launch.py +52 -0
- package/runtime/python/okstra_ctl/wizard/launch_cli.py +39 -0
- package/runtime/python/okstra_ctl/wizard/outcome.py +17 -16
- package/runtime/python/okstra_ctl/wizard/registry.py +1 -1
- package/runtime/python/okstra_ctl/wizard/render.py +8 -0
- package/runtime/python/okstra_ctl/wizard/state.py +2 -1
- package/runtime/python/okstra_project/state.py +20 -0
- package/runtime/python/okstra_token_usage/blocks.py +74 -0
- package/runtime/python/okstra_token_usage/cli.py +23 -10
- package/runtime/python/okstra_token_usage/collect.py +25 -22
- package/runtime/python/okstra_token_usage/policy.py +193 -0
- package/runtime/schemas/report-synthesis-packet-v1.0.schema.json +1 -1
- package/runtime/skills/_fragments/wizard-confirm-step.md +1 -1
- package/runtime/skills/_fragments/wizard-preflight.md +1 -1
- package/runtime/skills/_fragments/wizard-prompt-loop.md +3 -5
- package/runtime/skills/_fragments/wizard-relay-protocol.md +1 -1
- package/runtime/skills/_fragments/wizard-render-bundle.md +15 -29
- package/runtime/skills/okstra-brief-gen/SKILL.md +7 -7
- package/runtime/skills/okstra-brief-gen/references/tracker-recursion.md +1 -1
- package/runtime/skills/okstra-code-review/SKILL.md +58 -50
- package/runtime/skills/okstra-code-review/references/census-rules.md +6 -6
- package/runtime/skills/okstra-code-review/references/review-calibration.md +8 -12
- package/runtime/skills/okstra-discussion/SKILL.md +22 -38
- package/runtime/skills/okstra-explain-flow/SKILL.md +6 -2
- package/runtime/skills/okstra-manager/SKILL.md +24 -0
- package/runtime/skills/okstra-memory/SKILL.md +1 -1
- package/runtime/skills/okstra-pr-gen/SKILL.md +1 -1
- package/runtime/skills/okstra-run/SKILL.md +55 -183
- package/runtime/skills/okstra-schedule-gen/SKILL.md +9 -13
- package/runtime/skills/okstra-setup/SKILL.md +3 -2
- package/runtime/skills/okstra-setup/references/project-config.md +2 -4
- package/runtime/skills/okstra-tdd/SKILL.md +187 -0
- package/runtime/skills/okstra-user-response/SKILL.md +4 -2
- package/runtime/templates/manager/view.template.html +4 -0
- package/runtime/templates/report-writer-prompt-preamble.md +15 -3
- package/runtime/templates/trace/trace.template.md +42 -0
- package/runtime/validators/checks/fixtures-02.py +25 -33
- package/runtime/validators/validate-run.py +93 -36
|
@@ -26,10 +26,11 @@ from .stage_ledger import build_stage_ledger
|
|
|
26
26
|
from .scope_provenance import brief_end_state_id_sequence
|
|
27
27
|
|
|
28
28
|
from .final_report_schema import follow_up_task_rules, task_block_rules, verdict_token_rule
|
|
29
|
-
from .report_contract import TASK_TYPE_DATA_PROPERTY
|
|
29
|
+
from .report_contract import TASK_TYPE_DATA_PROPERTY, report_authoring_suffix
|
|
30
30
|
from .report_markdown import humanise
|
|
31
31
|
from .report_narrative import NarrativeContractError, allowed_top_level_fields
|
|
32
|
-
from .report_narrative import NARRATIVE_GRAMMAR_INSTRUCTIONS
|
|
32
|
+
from .report_narrative import JSON_NARRATIVE_INSTRUCTIONS, NARRATIVE_GRAMMAR_INSTRUCTIONS
|
|
33
|
+
from .report_inputs import report_authoring_format
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
@dataclass(frozen=True)
|
|
@@ -96,6 +97,7 @@ class ReportSynthesisPacket:
|
|
|
96
97
|
# 적던 동안 리드가 어느 task type 에도 없는 절을 지시했고, 작성자는 조립이
|
|
97
98
|
# 거절할 때까지 그 지시를 거를 근거가 없었다(2026-09-03 실측).
|
|
98
99
|
allowed_top_level: tuple[str, ...] = ()
|
|
100
|
+
authoring_format: str = "markdown-v1"
|
|
99
101
|
|
|
100
102
|
def _carry_instructions(self) -> list[str]:
|
|
101
103
|
"""이번 run 의 이월 지시. 증분이 아니면 빈 목록.
|
|
@@ -191,16 +193,21 @@ class ReportSynthesisPacket:
|
|
|
191
193
|
f"Required top-level fields for this task type: {labels}. "
|
|
192
194
|
"Report assembly refuses a narrative that omits any of them."
|
|
193
195
|
)
|
|
196
|
+
verdict_path = (
|
|
197
|
+
"`finalVerdict.verdictToken`"
|
|
198
|
+
if self.authoring_format == "json-v1"
|
|
199
|
+
else "`Final Verdict` -> `Verdict Token`"
|
|
200
|
+
)
|
|
194
201
|
if len(self.verdict_tokens) == 1:
|
|
195
202
|
lines.append(
|
|
196
|
-
f"
|
|
203
|
+
f"{verdict_path}: write exactly "
|
|
197
204
|
f"`{self.verdict_tokens[0]}`; the schema pins it for task type "
|
|
198
205
|
f"`{self.task_type}` and refuses every other value."
|
|
199
206
|
)
|
|
200
207
|
elif self.verdict_tokens:
|
|
201
208
|
allowed = ", ".join(f"`{token}`" for token in self.verdict_tokens)
|
|
202
209
|
lines.append(
|
|
203
|
-
f"
|
|
210
|
+
f"{verdict_path}: one of {allowed} for task type "
|
|
204
211
|
f"`{self.task_type}`."
|
|
205
212
|
)
|
|
206
213
|
if self.allowed_top_level:
|
|
@@ -212,13 +219,21 @@ class ReportSynthesisPacket:
|
|
|
212
219
|
)
|
|
213
220
|
lines.extend(self.follow_up_rules)
|
|
214
221
|
if self.block_rules:
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
+
if self.authoring_format == "json-v1":
|
|
223
|
+
lines.append(
|
|
224
|
+
f"Shape of the `{self.block_key}` block, one rule per object, "
|
|
225
|
+
"from the frozen writer-owned schema. Use exact JSON keys; "
|
|
226
|
+
"`[]` marks each array item. Report assembly refuses an input "
|
|
227
|
+
"that breaks any rule."
|
|
228
|
+
)
|
|
229
|
+
else:
|
|
230
|
+
lines.append(
|
|
231
|
+
f"Shape of the `{self.block_key}` block, one line per object, from "
|
|
232
|
+
"the frozen schema. Paths are schema keys: write each key as its "
|
|
233
|
+
"Title Case label (`rankedOptions` -> `Ranked Options`), and `[]` "
|
|
234
|
+
"marks the items of an `- Item N` list. Report assembly refuses a "
|
|
235
|
+
"narrative that breaks any line."
|
|
236
|
+
)
|
|
222
237
|
lines.extend(self.block_rules)
|
|
223
238
|
return lines
|
|
224
239
|
|
|
@@ -326,10 +341,10 @@ class ReportSynthesisPacket:
|
|
|
326
341
|
"taskType": self.task_type,
|
|
327
342
|
"authoringContract": {
|
|
328
343
|
"resultPath": self.result_path,
|
|
329
|
-
"format":
|
|
344
|
+
"format": self._output_format(),
|
|
330
345
|
"sourcePolicy": "read-only-synthesis-packet",
|
|
331
346
|
"instructions": [
|
|
332
|
-
*
|
|
347
|
+
*self._format_instructions(),
|
|
333
348
|
"Write the complete human-readable report narrative.",
|
|
334
349
|
"Preserve settled source values, identities, dissent, and user responses.",
|
|
335
350
|
"Do not invent a value when a source is missing or contradictory.",
|
|
@@ -364,8 +379,8 @@ class ReportSynthesisPacket:
|
|
|
364
379
|
"",
|
|
365
380
|
f"- Task type: `{self.task_type}`",
|
|
366
381
|
f"- Result path: `{self.result_path}`",
|
|
367
|
-
"- Output format: `
|
|
368
|
-
*(f"- {text}" for text in
|
|
382
|
+
f"- Output format: `{self._output_format()}`",
|
|
383
|
+
*(f"- {text}" for text in self._format_instructions()),
|
|
369
384
|
"- Input policy: read this synthesis packet as the dispatched source set",
|
|
370
385
|
"- Responsibility: write the complete human-readable narrative while preserving settled values",
|
|
371
386
|
"- Runtime-owned values: session identifiers, token usage, estimated cost, "
|
|
@@ -383,12 +398,22 @@ class ReportSynthesisPacket:
|
|
|
383
398
|
sections = [("Authoring Contract", "\n".join(lines[1:]).rstrip() + "\n")]
|
|
384
399
|
sections.extend(
|
|
385
400
|
(source.label, "\n".join(_source_markdown(
|
|
386
|
-
source, self.task_type, self.sources,
|
|
401
|
+
source, self.task_type, self.sources, self.authoring_format,
|
|
387
402
|
)).rstrip() + "\n")
|
|
388
403
|
for source in self.sources
|
|
389
404
|
)
|
|
390
405
|
return _indexed_markdown(lines[0], sections)
|
|
391
406
|
|
|
407
|
+
def _output_format(self) -> str:
|
|
408
|
+
return "json-v1" if self.authoring_format == "json-v1" else "report-narrative-v3.0"
|
|
409
|
+
|
|
410
|
+
def _format_instructions(self) -> tuple[str, ...]:
|
|
411
|
+
return (
|
|
412
|
+
JSON_NARRATIVE_INSTRUCTIONS
|
|
413
|
+
if self.authoring_format == "json-v1"
|
|
414
|
+
else NARRATIVE_GRAMMAR_INSTRUCTIONS
|
|
415
|
+
)
|
|
416
|
+
|
|
392
417
|
|
|
393
418
|
_SOURCE_FIELDS = (
|
|
394
419
|
("Analysis packet", "orchestrator", "instructionSet", "analysisPacketPath", True),
|
|
@@ -514,7 +539,9 @@ def _convergence_view(content: str) -> str:
|
|
|
514
539
|
return json.dumps(view, ensure_ascii=False, indent=1)
|
|
515
540
|
|
|
516
541
|
|
|
517
|
-
def _writer_schema_view(
|
|
542
|
+
def _writer_schema_view(
|
|
543
|
+
content: str, task_type: str, authoring_format: str = "markdown-v1",
|
|
544
|
+
) -> tuple[str, list[str]]:
|
|
518
545
|
try:
|
|
519
546
|
schema = json.loads(content)
|
|
520
547
|
except json.JSONDecodeError:
|
|
@@ -522,8 +549,10 @@ def _writer_schema_view(content: str, task_type: str) -> tuple[str, list[str]]:
|
|
|
522
549
|
if not isinstance(schema, dict) or not schema.get("properties"):
|
|
523
550
|
return content, []
|
|
524
551
|
owned = writer_owned_schema(schema)
|
|
525
|
-
#
|
|
526
|
-
|
|
552
|
+
# 기존 줄 문법의 읽기 계약은 유지한다. JSON은 작성자 몫만 전달하고
|
|
553
|
+
# 태스크 조건은 저작 계약의 별도 규칙으로 안내한다.
|
|
554
|
+
if authoring_format == "markdown-v1":
|
|
555
|
+
owned["allOf"] = schema.get("allOf", [])
|
|
527
556
|
owned["required"] = [
|
|
528
557
|
key for key in schema.get("required", []) if key in owned["properties"]
|
|
529
558
|
]
|
|
@@ -536,6 +565,7 @@ def _writer_schema_view(content: str, task_type: str) -> tuple[str, list[str]]:
|
|
|
536
565
|
def _source_markdown(
|
|
537
566
|
source: ReportSynthesisSource, task_type: str,
|
|
538
567
|
sources: tuple[ReportSynthesisSource, ...],
|
|
568
|
+
authoring_format: str = "markdown-v1",
|
|
539
569
|
) -> list[str]:
|
|
540
570
|
content = source.content.rstrip("\n")
|
|
541
571
|
view = []
|
|
@@ -568,7 +598,7 @@ def _source_markdown(
|
|
|
568
598
|
"the original line index is omitted.",
|
|
569
599
|
]
|
|
570
600
|
if source.label == "Final report schema":
|
|
571
|
-
content, view = _writer_schema_view(content, task_type)
|
|
601
|
+
content, view = _writer_schema_view(content, task_type, authoring_format)
|
|
572
602
|
longest = max((len(run) for run in re.findall(r"`+", content)), default=0)
|
|
573
603
|
fence = "`" * max(3, longest + 1)
|
|
574
604
|
return [
|
|
@@ -731,8 +761,10 @@ class CarriedStages:
|
|
|
731
761
|
prior_plan: dict[str, Any] | None = None
|
|
732
762
|
|
|
733
763
|
|
|
734
|
-
def carried_stages_path(
|
|
735
|
-
|
|
764
|
+
def carried_stages_path(
|
|
765
|
+
narrative_path: Path, authoring_format: str = "markdown-v1",
|
|
766
|
+
) -> Path:
|
|
767
|
+
_, markdown_path = report_synthesis_packet_paths(narrative_path, authoring_format)
|
|
736
768
|
return markdown_path.with_name(
|
|
737
769
|
markdown_path.name.replace(
|
|
738
770
|
"report-writer-synthesis-packet", "report-writer-carried-stages"
|
|
@@ -760,6 +792,7 @@ def materialize_carried_stages(
|
|
|
760
792
|
return _materialize_stage_rows(
|
|
761
793
|
project_root=project_root,
|
|
762
794
|
narrative_path=narrative_path,
|
|
795
|
+
authoring_format=report_authoring_format(manifest),
|
|
763
796
|
source_plan=_string(decision.get("prevDataPath")),
|
|
764
797
|
stages=[
|
|
765
798
|
stage for stage in decision["carryStages"] if isinstance(stage, int)
|
|
@@ -777,6 +810,7 @@ def materialize_carried_stages(
|
|
|
777
810
|
return _materialize_stage_rows(
|
|
778
811
|
project_root=project_root,
|
|
779
812
|
narrative_path=narrative_path,
|
|
813
|
+
authoring_format=report_authoring_format(manifest),
|
|
780
814
|
source_plan=_string(prior_plan.get("sourcePlanPath")),
|
|
781
815
|
stages=list(prior_plan["doneStages"]),
|
|
782
816
|
carried=CarriedStages("", prior_plan=prior_plan),
|
|
@@ -787,6 +821,7 @@ def _materialize_stage_rows(
|
|
|
787
821
|
*,
|
|
788
822
|
project_root: Path,
|
|
789
823
|
narrative_path: Path,
|
|
824
|
+
authoring_format: str,
|
|
790
825
|
source_plan: str,
|
|
791
826
|
stages: list[int],
|
|
792
827
|
carried: CarriedStages,
|
|
@@ -801,7 +836,7 @@ def _materialize_stage_rows(
|
|
|
801
836
|
rows = carried_stage_rows(prior_data, stages)
|
|
802
837
|
if not rows:
|
|
803
838
|
return None
|
|
804
|
-
path = carried_stages_path(narrative_path)
|
|
839
|
+
path = carried_stages_path(narrative_path, authoring_format)
|
|
805
840
|
write_owned_object_atomic(
|
|
806
841
|
path,
|
|
807
842
|
{
|
|
@@ -1028,6 +1063,8 @@ def build_report_synthesis_packet(
|
|
|
1028
1063
|
team_state: Mapping[str, Any],
|
|
1029
1064
|
narrative_path: Path,
|
|
1030
1065
|
) -> ReportSynthesisPacket:
|
|
1066
|
+
authoring_format = report_authoring_format(manifest)
|
|
1067
|
+
report_synthesis_packet_paths(narrative_path, authoring_format)
|
|
1031
1068
|
carried = materialize_carried_stages(
|
|
1032
1069
|
project_root=project_root, manifest=manifest, narrative_path=narrative_path,
|
|
1033
1070
|
)
|
|
@@ -1063,7 +1100,7 @@ def build_report_synthesis_packet(
|
|
|
1063
1100
|
if _string(worker) and _string(worker) != "report-writer"
|
|
1064
1101
|
)
|
|
1065
1102
|
required_top_level, verdict_tokens, block_rules, follow_up_rules = (
|
|
1066
|
-
_schema_authoring_rules(sources, task_type)
|
|
1103
|
+
_schema_authoring_rules(sources, task_type, authoring_format)
|
|
1067
1104
|
)
|
|
1068
1105
|
return ReportSynthesisPacket(
|
|
1069
1106
|
task_key=_string(manifest.get("taskKey")),
|
|
@@ -1074,7 +1111,8 @@ def build_report_synthesis_packet(
|
|
|
1074
1111
|
follow_up_rules=follow_up_rules,
|
|
1075
1112
|
block_key=TASK_TYPE_DATA_PROPERTY.get(task_type, "") if block_rules else "",
|
|
1076
1113
|
block_rules=block_rules,
|
|
1077
|
-
allowed_top_level=_allowed_top_level_labels(),
|
|
1114
|
+
allowed_top_level=_allowed_top_level_labels(authoring_format),
|
|
1115
|
+
authoring_format=authoring_format,
|
|
1078
1116
|
sources=sources,
|
|
1079
1117
|
accounting_snapshot=_accounting_snapshot(team_state),
|
|
1080
1118
|
original_requirement_ids=original_requirement_ids,
|
|
@@ -1086,11 +1124,12 @@ def build_report_synthesis_packet(
|
|
|
1086
1124
|
|
|
1087
1125
|
def _schema_authoring_rules(
|
|
1088
1126
|
sources: tuple[ReportSynthesisSource, ...], task_type: str,
|
|
1127
|
+
authoring_format: str = "markdown-v1",
|
|
1089
1128
|
) -> tuple[tuple[str, ...], tuple[str, ...], tuple[str, ...], tuple[str, ...]]:
|
|
1090
1129
|
"""넘겨받은(동결된) 완성 리포트 스키마에서 작성자 몫의 규칙 네 가지를 뽑는다.
|
|
1091
1130
|
|
|
1092
1131
|
최상위 `required` 가운데 작성자 소유 이름(서사 스키마의 properties)만
|
|
1093
|
-
|
|
1132
|
+
선언 형식의 키 또는 라벨로, 이 task type 의 판정 토큰 허용값, 이 task type 의
|
|
1094
1133
|
데이터 블록 안쪽 모양(`task_block_rules`), 그리고 `followUpTasks` 행 규칙
|
|
1095
1134
|
(`follow_up_task_rules`). 스키마 소스가 없거나
|
|
1096
1135
|
JSON 이 아니면 빈 값이다 — 이 함수는 조립 검증을 대신하지 않고 도달하지
|
|
@@ -1112,36 +1151,45 @@ def _schema_authoring_rules(
|
|
|
1112
1151
|
allowed = frozenset()
|
|
1113
1152
|
required = schema.get("required")
|
|
1114
1153
|
required_top_level = tuple(
|
|
1115
|
-
humanise(key)
|
|
1154
|
+
key if authoring_format == "json-v1" else humanise(key)
|
|
1116
1155
|
for key in (required if isinstance(required, list) else [])
|
|
1117
1156
|
if isinstance(key, str) and key in allowed
|
|
1118
1157
|
)
|
|
1119
1158
|
block_key = TASK_TYPE_DATA_PROPERTY.get(task_type, "")
|
|
1120
|
-
block_rules = task_block_rules(
|
|
1159
|
+
block_rules = task_block_rules(
|
|
1160
|
+
writer_owned_schema(schema), block_key, authoring_format=authoring_format,
|
|
1161
|
+
) if block_key else ()
|
|
1162
|
+
follow_up_rules = follow_up_task_rules(schema, task_type, authoring_format=authoring_format)
|
|
1121
1163
|
return (
|
|
1122
1164
|
required_top_level,
|
|
1123
1165
|
verdict_token_rule(schema, task_type),
|
|
1124
1166
|
block_rules,
|
|
1125
|
-
|
|
1167
|
+
follow_up_rules,
|
|
1126
1168
|
)
|
|
1127
1169
|
|
|
1128
1170
|
|
|
1129
|
-
def _allowed_top_level_labels() -> tuple[str, ...]:
|
|
1171
|
+
def _allowed_top_level_labels(authoring_format: str = "markdown-v1") -> tuple[str, ...]:
|
|
1130
1172
|
"""작성자 소유 최상위 필드 전체 — 서사 스키마 부재는 빈 값(조립이 판정한다)."""
|
|
1131
1173
|
try:
|
|
1132
1174
|
allowed = allowed_top_level_fields()
|
|
1133
1175
|
except (NarrativeContractError, JsonBoundaryError):
|
|
1134
1176
|
return ()
|
|
1135
|
-
return tuple(
|
|
1177
|
+
return tuple(
|
|
1178
|
+
key if authoring_format == "json-v1" else humanise(key)
|
|
1179
|
+
for key in sorted(allowed)
|
|
1180
|
+
)
|
|
1136
1181
|
|
|
1137
1182
|
|
|
1138
|
-
def report_synthesis_packet_paths(
|
|
1183
|
+
def report_synthesis_packet_paths(
|
|
1184
|
+
narrative_path: Path, authoring_format: str = "markdown-v1",
|
|
1185
|
+
) -> tuple[Path, Path]:
|
|
1139
1186
|
name = narrative_path.name
|
|
1140
1187
|
prefix = "report-writer-narrative-"
|
|
1141
|
-
|
|
1188
|
+
suffix = report_authoring_suffix(authoring_format)
|
|
1189
|
+
if name == "report-writer-narrative" + suffix:
|
|
1142
1190
|
packet_name = "report-writer-synthesis-packet.md"
|
|
1143
|
-
elif name.startswith(prefix) and name.endswith(
|
|
1144
|
-
packet_name = "report-writer-synthesis-packet-" +
|
|
1191
|
+
elif name.startswith(prefix) and name.endswith(suffix):
|
|
1192
|
+
packet_name = "report-writer-synthesis-packet-" + narrative_path.stem[len(prefix):] + ".md"
|
|
1145
1193
|
else:
|
|
1146
1194
|
raise ValueError(f"report narrative path has an unsupported name: {narrative_path}")
|
|
1147
1195
|
markdown_path = narrative_path.with_name(packet_name)
|
|
@@ -1164,7 +1212,9 @@ def materialize_report_synthesis_packet(
|
|
|
1164
1212
|
team_state=team_state,
|
|
1165
1213
|
narrative_path=narrative_path,
|
|
1166
1214
|
)
|
|
1167
|
-
data_path, markdown_path = report_synthesis_packet_paths(
|
|
1215
|
+
data_path, markdown_path = report_synthesis_packet_paths(
|
|
1216
|
+
narrative_path, packet.authoring_format,
|
|
1217
|
+
)
|
|
1168
1218
|
write_owned_object_atomic(
|
|
1169
1219
|
data_path,
|
|
1170
1220
|
packet.to_dict(),
|
|
@@ -56,6 +56,7 @@ from .phases.implementation_planning.entry import (
|
|
|
56
56
|
)
|
|
57
57
|
from . import fix_cycles
|
|
58
58
|
from .analysis_packet import build_analysis_packet, cited_documents_block
|
|
59
|
+
from .user_authorization import validate_wizard_authorization
|
|
59
60
|
from .mcp_servers import NO_MCP_SERVERS_LINE, prepare_mcp
|
|
60
61
|
from .coverage_census import (
|
|
61
62
|
CensusError,
|
|
@@ -161,7 +162,7 @@ from .legacy_model_selection import (
|
|
|
161
162
|
normalize_model_selection_inputs,
|
|
162
163
|
serialize_host_session_context,
|
|
163
164
|
)
|
|
164
|
-
from .model_defaults import ModelDefaultScopes
|
|
165
|
+
from .model_defaults import ModelDefaultError, ModelDefaultScopes, parse_model_lists
|
|
165
166
|
from .worker_prompt_policy import (
|
|
166
167
|
ANALYSIS_DUTY_BY_TASK_TYPE,
|
|
167
168
|
critic_assignment_ref,
|
|
@@ -1302,9 +1303,7 @@ class _ResolvedAssets:
|
|
|
1302
1303
|
lead_contract: Path
|
|
1303
1304
|
run_validator: Path
|
|
1304
1305
|
brief_validator: Path
|
|
1305
|
-
# None when
|
|
1306
|
-
# prompts/host-orchestration/README.md. Absence is a normal state, not a
|
|
1307
|
-
# broken install, so it is exempt from the _INSTALL_HINT contract above.
|
|
1306
|
+
# None only when the phase catalog declares no host orchestration rules.
|
|
1308
1307
|
host_rules_file: Path | None
|
|
1309
1308
|
|
|
1310
1309
|
|
|
@@ -1359,7 +1358,10 @@ def _resolve_runtime_assets(workspace_root: Path, inp: PrepareInputs) -> _Resolv
|
|
|
1359
1358
|
raise PrepareError(
|
|
1360
1359
|
f"required okstra template or lead contract missing: {required}.{_INSTALL_HINT}"
|
|
1361
1360
|
)
|
|
1362
|
-
|
|
1361
|
+
try:
|
|
1362
|
+
host_rules_file = host_rules(workspace_root, inp.task_type)
|
|
1363
|
+
except PhaseAssetError as exc:
|
|
1364
|
+
raise PrepareError(f"{exc}.{_INSTALL_HINT}") from exc
|
|
1363
1365
|
return _ResolvedAssets(
|
|
1364
1366
|
profile_file=profile_file,
|
|
1365
1367
|
prompt_template=prompt_template,
|
|
@@ -1368,7 +1370,7 @@ def _resolve_runtime_assets(workspace_root: Path, inp: PrepareInputs) -> _Resolv
|
|
|
1368
1370
|
lead_contract=lead_contract,
|
|
1369
1371
|
run_validator=run_validator,
|
|
1370
1372
|
brief_validator=brief_validator,
|
|
1371
|
-
host_rules_file=host_rules_file
|
|
1373
|
+
host_rules_file=host_rules_file,
|
|
1372
1374
|
)
|
|
1373
1375
|
|
|
1374
1376
|
|
|
@@ -1800,6 +1802,13 @@ def _clear_stale_stage_waiver(inp: "PrepareInputs", project_root: Path, stage: i
|
|
|
1800
1802
|
)
|
|
1801
1803
|
|
|
1802
1804
|
|
|
1805
|
+
def prepare_exception_applies(task_type: str, option: str) -> bool:
|
|
1806
|
+
return {
|
|
1807
|
+
"--qa-waiver": "implementation",
|
|
1808
|
+
"--tdd-bypass": "implementation-planning",
|
|
1809
|
+
}.get(option) == task_type
|
|
1810
|
+
|
|
1811
|
+
|
|
1803
1812
|
def _register_and_check_project(project_root: Path, inp: PrepareInputs) -> None:
|
|
1804
1813
|
"""project.json self-registration + (implementation 한정) qaCommands gate 검증."""
|
|
1805
1814
|
from okstra_project import ResolverError
|
|
@@ -1815,10 +1824,10 @@ def _register_and_check_project(project_root: Path, inp: PrepareInputs) -> None:
|
|
|
1815
1824
|
|
|
1816
1825
|
validate_project_qa_commands(inp.task_type, project_root)
|
|
1817
1826
|
# waiver 는 stage 단위 Tier 3 면제라 implementation 진입에서만 적용한다.
|
|
1818
|
-
if inp.task_type
|
|
1827
|
+
if prepare_exception_applies(inp.task_type, "--qa-waiver"):
|
|
1819
1828
|
_apply_qa_waiver_if_requested(inp, project_root)
|
|
1820
1829
|
# TDD 우회는 계획서의 stage 를 면제하므로 계획 진입에서만 적용한다.
|
|
1821
|
-
if inp.task_type
|
|
1830
|
+
if prepare_exception_applies(inp.task_type, "--tdd-bypass"):
|
|
1822
1831
|
_apply_tdd_bypass_if_requested(inp, project_root)
|
|
1823
1832
|
|
|
1824
1833
|
|
|
@@ -2350,20 +2359,10 @@ def _read_model_defaults(path: Path) -> dict[str, tuple[str, ...]]:
|
|
|
2350
2359
|
payload = load_owned_object(path, artifact="model defaults config")
|
|
2351
2360
|
except (OSError, JsonBoundaryError) as exc:
|
|
2352
2361
|
raise PrepareError(f"model defaults file is invalid: {path}: {exc}") from exc
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
for role, models in raw_defaults.items():
|
|
2358
|
-
if (
|
|
2359
|
-
not isinstance(role, str)
|
|
2360
|
-
or not isinstance(models, list)
|
|
2361
|
-
or not models
|
|
2362
|
-
or not all(isinstance(model, str) and model for model in models)
|
|
2363
|
-
):
|
|
2364
|
-
raise PrepareError(f"modelDefaults entries must be non-empty string arrays: {path}")
|
|
2365
|
-
defaults[role] = tuple(models)
|
|
2366
|
-
return defaults
|
|
2362
|
+
try:
|
|
2363
|
+
return parse_model_lists(payload, "modelDefaults", path)
|
|
2364
|
+
except ModelDefaultError as exc:
|
|
2365
|
+
raise PrepareError(str(exc)) from exc
|
|
2367
2366
|
|
|
2368
2367
|
|
|
2369
2368
|
@dataclass
|
|
@@ -3142,12 +3141,24 @@ def _write_instruction_set_sources(
|
|
|
3142
3141
|
def _write_coverage_census(
|
|
3143
3142
|
inp: PrepareInputs, ctx: dict, instruction_set: Path,
|
|
3144
3143
|
) -> str:
|
|
3145
|
-
"""
|
|
3144
|
+
"""Return the packet block for deferred or immediately persisted coverage.
|
|
3146
3145
|
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3146
|
+
Resolved-lens runs defer the canonical run-scoped census until the first
|
|
3147
|
+
analysis prompt; other runs persist any profile-declared census here.
|
|
3148
|
+
Invalid immediate census declarations are reported without blocking
|
|
3149
|
+
preparation. The packet is task-scoped.
|
|
3150
3150
|
"""
|
|
3151
|
+
if inp.task_type == "improvement-discovery":
|
|
3152
|
+
from .phases.improvement_discovery.lenses import RESOLVED_LENSES_POLICY
|
|
3153
|
+
from .phases.improvement_discovery.resolved_census import (
|
|
3154
|
+
improvement_census_policy_fields, pending_census_section,
|
|
3155
|
+
)
|
|
3156
|
+
|
|
3157
|
+
manifest_path = Path(ctx["RUN_MANIFEST_PATH"])
|
|
3158
|
+
recorded = _read_existing_manifest(manifest_path) if manifest_path.is_file() else None
|
|
3159
|
+
policy_fields = improvement_census_policy_fields(inp.task_type, recorded)
|
|
3160
|
+
if policy_fields.get("coverageCensusPolicy") == RESOLVED_LENSES_POLICY:
|
|
3161
|
+
return pending_census_section(ctx["RUN_MANIFEST_RELATIVE_PATH"])
|
|
3151
3162
|
changed_files: tuple[str, ...] = ()
|
|
3152
3163
|
if inp.task_type == "final-verification":
|
|
3153
3164
|
changed_files = tuple(_git_out(
|
|
@@ -4201,15 +4212,10 @@ def _prepare_user_authorization(inp: PrepareInputs) -> dict:
|
|
|
4201
4212
|
record = json.loads(inp.user_authorization_json)
|
|
4202
4213
|
except (TypeError, ValueError) as exc:
|
|
4203
4214
|
raise PrepareError("invalid user authorization JSON") from exc
|
|
4204
|
-
|
|
4205
|
-
record
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
or not isinstance(record.get("prompt"), str)
|
|
4209
|
-
or not record["prompt"].strip()
|
|
4210
|
-
or not isinstance(record.get("scope"), dict)
|
|
4211
|
-
):
|
|
4212
|
-
raise PrepareError("user authorization requires the displayed prompt, proceed response, and scope")
|
|
4215
|
+
try:
|
|
4216
|
+
validate_wizard_authorization(record)
|
|
4217
|
+
except ValueError as exc:
|
|
4218
|
+
raise PrepareError(str(exc)) from exc
|
|
4213
4219
|
if inp.task_type == "implementation":
|
|
4214
4220
|
stages = record.get("stageScope") or [record["scope"].get("stage")]
|
|
4215
4221
|
if not isinstance(stages, list) or inp.stage not in stages:
|
|
@@ -4436,6 +4442,8 @@ def prepare_task_bundle(inp: PrepareInputs) -> PrepareOutputs:
|
|
|
4436
4442
|
project_id=inp.project_id, task_group=inp.task_group, task_id=inp.task_id,
|
|
4437
4443
|
task_type=inp.task_type, run_seq_override=run_seq_override,
|
|
4438
4444
|
stage=stage_arg,
|
|
4445
|
+
report_authoring_format="json-v1",
|
|
4446
|
+
usage_accounting_policy="advisory",
|
|
4439
4447
|
)
|
|
4440
4448
|
|
|
4441
4449
|
ctx.update({
|
|
@@ -16,6 +16,7 @@ seq advance 와 파일 쓰기를 수행한다.
|
|
|
16
16
|
from __future__ import annotations
|
|
17
17
|
|
|
18
18
|
import fcntl
|
|
19
|
+
import hashlib
|
|
19
20
|
import json
|
|
20
21
|
import os
|
|
21
22
|
from contextlib import contextmanager
|
|
@@ -24,6 +25,8 @@ from pathlib import Path
|
|
|
24
25
|
from typing import Iterator, Optional
|
|
25
26
|
|
|
26
27
|
from okstra_project.dirs import okstra_home
|
|
28
|
+
from okstra_project.state import parse_task_key
|
|
29
|
+
from okstra_project.slug import slugify
|
|
27
30
|
|
|
28
31
|
from .path_hints import compact_run_context, hydrate_run_context
|
|
29
32
|
from .json_boundary import JsonBoundaryError, load_owned_object, write_owned_object_atomic
|
|
@@ -92,7 +95,9 @@ def _task_lock_path(task_key: str) -> Path:
|
|
|
92
95
|
home = okstra_home()
|
|
93
96
|
locks = home / ".locks"
|
|
94
97
|
locks.mkdir(parents=True, exist_ok=True)
|
|
95
|
-
|
|
98
|
+
project, group, task = parse_task_key(task_key)
|
|
99
|
+
identity = json.dumps((project, slugify(group), slugify(task)))
|
|
100
|
+
safe = hashlib.sha256(identity.encode("utf-8")).hexdigest()
|
|
96
101
|
return locks / f"{safe}.lock"
|
|
97
102
|
|
|
98
103
|
|
|
@@ -156,6 +161,8 @@ def compute_and_write_run_context(
|
|
|
156
161
|
task_type: str,
|
|
157
162
|
run_seq_override: Optional[int] = None,
|
|
158
163
|
stage: Optional[int] = None,
|
|
164
|
+
report_authoring_format: str = "markdown-v1",
|
|
165
|
+
usage_accounting_policy: str = "strict",
|
|
159
166
|
) -> dict:
|
|
160
167
|
"""task per-mutex 안에서 run paths 를 계산하고 디스크에 박는다.
|
|
161
168
|
|
|
@@ -180,7 +187,9 @@ def compute_and_write_run_context(
|
|
|
180
187
|
task_type=task_type,
|
|
181
188
|
run_seq_override=run_seq_override,
|
|
182
189
|
stage=stage,
|
|
190
|
+
report_authoring_format=report_authoring_format,
|
|
183
191
|
)
|
|
192
|
+
ctx["USAGE_ACCOUNTING_POLICY"] = usage_accounting_policy
|
|
184
193
|
ctx["RUN_TIMESTAMP_ISO"] = _now_iso()
|
|
185
194
|
ctx["TASK_DATE"] = _now_task_date()
|
|
186
195
|
run_manifests_dir = Path(ctx["RUN_MANIFESTS_DIR"])
|
|
@@ -14,7 +14,7 @@ from datetime import datetime, timezone
|
|
|
14
14
|
from pathlib import Path
|
|
15
15
|
|
|
16
16
|
from okstra_ctl import group_context
|
|
17
|
-
from okstra_ctl.direct_work import find_brief_tasks, publish_direct_work, record_direct_work
|
|
17
|
+
from okstra_ctl.direct_work import find_brief_tasks, load_direct_task, publish_direct_work, record_direct_work
|
|
18
18
|
from okstra_ctl.run_context import task_mutex
|
|
19
19
|
from okstra_ctl.ids import slugify_task_segment
|
|
20
20
|
from okstra_ctl.fixed_text import line, scalar
|
|
@@ -213,21 +213,10 @@ def _refresh_group_queue(project_root: Path, entry: dict) -> str:
|
|
|
213
213
|
def _write_status(project_root: Path, entry: dict, args) -> dict:
|
|
214
214
|
manifest_path = _manifest_path(project_root, entry)
|
|
215
215
|
manifest_path.resolve().relative_to((project_root / ".okstra" / "tasks").resolve())
|
|
216
|
-
if manifest_path.exists():
|
|
217
|
-
manifest = load_owned_object(manifest_path, artifact="task manifest")
|
|
218
|
-
elif entry.get("_briefVerified"):
|
|
219
|
-
if (manifest_path.parent / "runs").exists() or entry.get("latestRunPath"):
|
|
220
|
-
raise ValueError("Task manifest is missing for a task with run history")
|
|
221
|
-
identity_fields = (
|
|
222
|
-
"schemaVersion", "projectId", "projectRoot", "taskGroup", "taskId", "taskKey",
|
|
223
|
-
"taskGroupPathSegment", "taskIdPathSegment", "taskBriefPath", "taskRootPath", "taskManifestPath",
|
|
224
|
-
)
|
|
225
|
-
manifest = {key: entry[key] for key in identity_fields if key in entry}
|
|
226
|
-
manifest["registrationSource"] = "direct"
|
|
227
|
-
else:
|
|
216
|
+
if not manifest_path.exists() and not entry.get("_briefVerified"):
|
|
228
217
|
return {"ok": False, "stage": "manifest-missing", "taskKey": entry["taskKey"]}
|
|
229
|
-
|
|
230
|
-
|
|
218
|
+
manifest_path, manifest = load_direct_task(project_root, {**entry, "taskManifestPath": str(manifest_path)},
|
|
219
|
+
allow_create=bool(entry.get("_briefVerified")))
|
|
231
220
|
if manifest.get("registrationSource") == "direct" or args.note is not None:
|
|
232
221
|
project_id, group, task_id = entry["taskKey"].split(":")
|
|
233
222
|
for field, value in (("projectId", project_id), ("taskGroup", group), ("taskId", task_id)):
|
|
@@ -20,6 +20,7 @@ from okstra_project import (
|
|
|
20
20
|
)
|
|
21
21
|
|
|
22
22
|
from .fixed_text import line
|
|
23
|
+
from .task_query import TaskQueryError, query_project_tasks
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
def render_text(payload: dict) -> str:
|
|
@@ -36,7 +37,14 @@ def render_text(payload: dict) -> str:
|
|
|
36
37
|
line("Work status", task["workStatus"]) if task.get("workStatus") else "",
|
|
37
38
|
line("Direct work record", task["latestWorkRecordPath"]) if task.get("latestWorkRecordPath") else "",
|
|
38
39
|
line("Updated at", task.get("updatedAt")),
|
|
40
|
+
line("Execution kind", task["executionKind"]) if task.get("executionKind") else "",
|
|
41
|
+
line("Implementation trace", task["implementationTracePath"]) if task.get("implementationTracePath") else "",
|
|
42
|
+
line("Match", task["preview"]) if task.get("preview") else "",
|
|
43
|
+
line("Relation reasons", task["reasons"]) if task.get("reasons") else "",
|
|
39
44
|
))
|
|
45
|
+
if "truncated" in payload:
|
|
46
|
+
parts.extend((line("Truncated", payload["truncated"]), line("Next cursor", payload["nextCursor"])))
|
|
47
|
+
parts.extend(line("Unavailable task", row["taskKey"]) for row in payload["unavailable"])
|
|
40
48
|
return "".join(parts)
|
|
41
49
|
|
|
42
50
|
|
|
@@ -56,7 +64,16 @@ def collect(
|
|
|
56
64
|
latest_run_status: str | None = None,
|
|
57
65
|
task_group: str | None = None,
|
|
58
66
|
limit: int | None = None,
|
|
67
|
+
query: str | None = None,
|
|
68
|
+
related_to: str | None = None,
|
|
69
|
+
after: str | None = None,
|
|
59
70
|
) -> dict:
|
|
71
|
+
if query is not None or related_to is not None or after is not None:
|
|
72
|
+
return query_project_tasks(
|
|
73
|
+
project_root, query=query or "", related_to=related_to or "", after=after or "",
|
|
74
|
+
limit=20 if limit is None else limit, task_type=task_type or "",
|
|
75
|
+
latest_run_status=latest_run_status or "", task_group=task_group or "",
|
|
76
|
+
)
|
|
60
77
|
return {
|
|
61
78
|
"ok": True,
|
|
62
79
|
"projectRoot": str(project_root),
|
|
@@ -104,6 +121,9 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
104
121
|
parser.add_argument("--task-group", default="", help="filter by taskGroup")
|
|
105
122
|
parser.add_argument("--limit", default="",
|
|
106
123
|
help="keep the first N (the catalog is updatedAt desc)")
|
|
124
|
+
parser.add_argument("--query", default=None, help="match every whitespace-separated term")
|
|
125
|
+
parser.add_argument("--related-to", default=None, help="find explicit and shared-metadata relations")
|
|
126
|
+
parser.add_argument("--after", default=None, help="resume after the last inspected task key")
|
|
107
127
|
mode = parser.add_mutually_exclusive_group()
|
|
108
128
|
mode.add_argument("--json", dest="output_mode", action="store_const",
|
|
109
129
|
const="json", default="json", help="emit JSON (default)")
|
|
@@ -122,17 +142,23 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
122
142
|
print(json.dumps({"ok": False, "stage": "resolve", "reason": str(exc)}))
|
|
123
143
|
return 2
|
|
124
144
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
145
|
+
try:
|
|
146
|
+
payload = collect(
|
|
147
|
+
Path(resolved),
|
|
148
|
+
task_type=args.task_type or None,
|
|
149
|
+
latest_run_status=args.latest_run_status or None,
|
|
150
|
+
task_group=args.task_group or None,
|
|
151
|
+
limit=int(args.limit) if args.limit else None,
|
|
152
|
+
query=args.query, related_to=args.related_to, after=args.after,
|
|
153
|
+
)
|
|
154
|
+
except (TaskQueryError, ValueError) as exc:
|
|
155
|
+
payload = {"ok": False, "stage": "query", "reason": str(exc) if isinstance(exc, TaskQueryError) else "invalid-query"}
|
|
156
|
+
print(json.dumps(payload))
|
|
157
|
+
return 2
|
|
132
158
|
if args.output_mode == "text":
|
|
133
159
|
print(render_text(payload), end="")
|
|
134
160
|
else:
|
|
135
|
-
print(json.dumps(payload, default=str))
|
|
161
|
+
print(json.dumps(payload, default=str, ensure_ascii="truncated" not in payload))
|
|
136
162
|
return 0
|
|
137
163
|
|
|
138
164
|
|