@blxzer/cursor-trellis 0.1.0 → 0.1.2
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 +124 -5
- package/README.zh-CN.md +170 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +1 -33
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/init.d.ts +0 -13
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +7 -14
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/uninstall.d.ts.map +1 -1
- package/dist/commands/uninstall.js +3 -32
- package/dist/commands/uninstall.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +7 -84
- package/dist/commands/update.js.map +1 -1
- package/dist/configurators/index.d.ts +7 -8
- package/dist/configurators/index.d.ts.map +1 -1
- package/dist/configurators/index.js +11 -236
- package/dist/configurators/index.js.map +1 -1
- package/dist/configurators/workflow.d.ts.map +1 -1
- package/dist/configurators/workflow.js +5 -1
- package/dist/configurators/workflow.js.map +1 -1
- package/dist/migrations/manifests/0.1.1.json +9 -0
- package/dist/migrations/manifests/0.1.2.json +9 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/SKILL.md +3 -3
- package/dist/templates/common/bundled-skills/trellis-meta/SKILL.md +4 -2
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-agents.md +8 -15
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-hooks.md +7 -7
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-skills-or-commands.md +18 -21
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/overview.md +2 -2
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/generated-files.md +10 -7
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/overview.md +4 -4
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/agents.md +20 -31
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/hooks-and-settings.md +20 -31
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/overview.md +24 -40
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md +28 -59
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/skills-and-commands.md +12 -28
- package/dist/templates/common/bundled-skills/trellis-skill-creator/references/trellis-skill-locations.md +2 -2
- package/dist/templates/cursor/hooks.json +6 -0
- package/dist/templates/cursor/rules/retrieval-routing.mdc +57 -0
- package/dist/templates/extract.d.ts +0 -14
- package/dist/templates/extract.d.ts.map +1 -1
- package/dist/templates/extract.js +0 -34
- package/dist/templates/extract.js.map +1 -1
- package/dist/templates/markdown/agents.md +2 -6
- package/dist/templates/markdown/index.d.ts +1 -0
- package/dist/templates/markdown/index.d.ts.map +1 -1
- package/dist/templates/markdown/index.js +1 -0
- package/dist/templates/markdown/index.js.map +1 -1
- package/dist/templates/markdown/prompts/run-semantic-slice-12.md.txt +41 -0
- package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md.txt +14 -14
- package/dist/templates/markdown/spec/guides/cross-layer-thinking-guide.md.txt +8 -20
- package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +15 -14
- package/dist/templates/markdown/spec/guides/cursor-context-injection-guide.md.txt +4 -2
- package/dist/templates/markdown/spec/guides/cursor-semantic-compliance.md.txt +49 -0
- package/dist/templates/markdown/spec/guides/cursor-subagent-policy.md.txt +18 -5
- package/dist/templates/markdown/spec/guides/retrieval-daily-guide.md.txt +68 -20
- package/dist/templates/shared-hooks/index.d.ts +1 -1
- package/dist/templates/shared-hooks/index.d.ts.map +1 -1
- package/dist/templates/shared-hooks/index.js +1 -0
- package/dist/templates/shared-hooks/index.js.map +1 -1
- package/dist/templates/shared-hooks/inject-retrieval-plan.py +163 -0
- package/dist/templates/shared-hooks/inject-subagent-context.py +31 -567
- package/dist/templates/shared-hooks/research-end-retrieval-pack.py +2 -11
- package/dist/templates/trellis/index.d.ts +12 -0
- package/dist/templates/trellis/index.d.ts.map +1 -1
- package/dist/templates/trellis/index.js +24 -0
- package/dist/templates/trellis/index.js.map +1 -1
- package/dist/templates/trellis/scripts/aggregate_retrieval_telemetry.py +342 -0
- package/dist/templates/trellis/scripts/batch_plan_envelope.py +105 -0
- package/dist/templates/trellis/scripts/codegraph_session_smoke.py +76 -0
- package/dist/templates/trellis/scripts/common/active_task.py +116 -147
- package/dist/templates/trellis/scripts/common/cli_adapter.py +34 -710
- package/dist/templates/trellis/scripts/common/codebase_retrieval_router.py +49 -106
- package/dist/templates/trellis/scripts/common/git_context.py +17 -2
- package/dist/templates/trellis/scripts/common/project_file_stats.py +91 -0
- package/dist/templates/trellis/scripts/common/retrieval_adapter_metadata.py +9 -11
- package/dist/templates/trellis/scripts/common/retrieval_agent_instructions.py +313 -0
- package/dist/templates/trellis/scripts/common/retrieval_pack.py +0 -6
- package/dist/templates/trellis/scripts/common/retrieval_pack_context.py +0 -4
- package/dist/templates/trellis/scripts/common/retrieval_plan_gate.py +76 -0
- package/dist/templates/trellis/scripts/common/retrieval_result_ranking.py +253 -0
- package/dist/templates/trellis/scripts/common/retrieval_tool_classification.py +157 -0
- package/dist/templates/trellis/scripts/common/semantic_plan_gate.py +52 -0
- package/dist/templates/trellis/scripts/common/subagent_dispatch.py +527 -0
- package/dist/templates/trellis/scripts/common/task_store.py +32 -0
- package/dist/templates/trellis/scripts/common/workflow_phase.py +3 -24
- package/dist/templates/trellis/scripts/rank_retrieval_candidates.py +80 -0
- package/dist/templates/trellis/scripts/route_codebase_retrieval.py +38 -11
- package/dist/templates/trellis/scripts/score_evidence.py +112 -0
- package/dist/templates/trellis/scripts/task.py +26 -0
- package/dist/templates/trellis/workflow.md +844 -960
- package/dist/types/ai-tools.d.ts +13 -16
- package/dist/types/ai-tools.d.ts.map +1 -1
- package/dist/types/ai-tools.js +5 -238
- package/dist/types/ai-tools.js.map +1 -1
- package/dist/utils/codebase-retrieval-router.d.ts +1 -8
- package/dist/utils/codebase-retrieval-router.d.ts.map +1 -1
- package/dist/utils/codebase-retrieval-router.js +39 -180
- package/dist/utils/codebase-retrieval-router.js.map +1 -1
- package/dist/utils/project-capabilities.d.ts.map +1 -1
- package/dist/utils/project-capabilities.js +10 -24
- package/dist/utils/project-capabilities.js.map +1 -1
- package/dist/utils/retrieval-agent-instructions.d.ts +14 -0
- package/dist/utils/retrieval-agent-instructions.d.ts.map +1 -0
- package/dist/utils/retrieval-agent-instructions.js +221 -0
- package/dist/utils/retrieval-agent-instructions.js.map +1 -0
- package/dist/utils/retrieval-execution-telemetry.d.ts +43 -85
- package/dist/utils/retrieval-execution-telemetry.d.ts.map +1 -1
- package/dist/utils/retrieval-execution-telemetry.js +289 -22
- package/dist/utils/retrieval-execution-telemetry.js.map +1 -1
- package/dist/utils/retrieval-result-ranking.js +1 -1
- package/dist/utils/retrieval-result-ranking.js.map +1 -1
- package/dist/utils/retrieval-tool-classification.d.ts +32 -0
- package/dist/utils/retrieval-tool-classification.d.ts.map +1 -0
- package/dist/utils/retrieval-tool-classification.js +113 -0
- package/dist/utils/retrieval-tool-classification.js.map +1 -0
- package/dist/utils/uninstall-scrubbers.d.ts +0 -36
- package/dist/utils/uninstall-scrubbers.d.ts.map +1 -1
- package/dist/utils/uninstall-scrubbers.js +0 -184
- package/dist/utils/uninstall-scrubbers.js.map +1 -1
- package/package.json +4 -2
- package/dist/commands/mem.d.ts +0 -30
- package/dist/commands/mem.d.ts.map +0 -1
- package/dist/commands/mem.js +0 -424
- package/dist/commands/mem.js.map +0 -1
- package/dist/configurators/antigravity.d.ts +0 -7
- package/dist/configurators/antigravity.d.ts.map +0 -1
- package/dist/configurators/antigravity.js +0 -19
- package/dist/configurators/antigravity.js.map +0 -1
- package/dist/configurators/claude.d.ts +0 -9
- package/dist/configurators/claude.d.ts.map +0 -1
- package/dist/configurators/claude.js +0 -72
- package/dist/configurators/claude.js.map +0 -1
- package/dist/configurators/codebuddy.d.ts +0 -10
- package/dist/configurators/codebuddy.d.ts.map +0 -1
- package/dist/configurators/codebuddy.js +0 -30
- package/dist/configurators/codebuddy.js.map +0 -1
- package/dist/configurators/codex.d.ts +0 -8
- package/dist/configurators/codex.d.ts.map +0 -1
- package/dist/configurators/codex.js +0 -87
- package/dist/configurators/codex.js.map +0 -1
- package/dist/configurators/copilot.d.ts +0 -10
- package/dist/configurators/copilot.d.ts.map +0 -1
- package/dist/configurators/copilot.js +0 -51
- package/dist/configurators/copilot.js.map +0 -1
- package/dist/configurators/droid.d.ts +0 -10
- package/dist/configurators/droid.d.ts.map +0 -1
- package/dist/configurators/droid.js +0 -30
- package/dist/configurators/droid.js.map +0 -1
- package/dist/configurators/gemini.d.ts +0 -16
- package/dist/configurators/gemini.d.ts.map +0 -1
- package/dist/configurators/gemini.js +0 -38
- package/dist/configurators/gemini.js.map +0 -1
- package/dist/configurators/kilo.d.ts +0 -7
- package/dist/configurators/kilo.d.ts.map +0 -1
- package/dist/configurators/kilo.js +0 -19
- package/dist/configurators/kilo.js.map +0 -1
- package/dist/configurators/kiro.d.ts +0 -8
- package/dist/configurators/kiro.d.ts.map +0 -1
- package/dist/configurators/kiro.js +0 -24
- package/dist/configurators/kiro.js.map +0 -1
- package/dist/configurators/opencode.d.ts +0 -14
- package/dist/configurators/opencode.d.ts.map +0 -1
- package/dist/configurators/opencode.js +0 -96
- package/dist/configurators/opencode.js.map +0 -1
- package/dist/configurators/pi.d.ts +0 -3
- package/dist/configurators/pi.d.ts.map +0 -1
- package/dist/configurators/pi.js +0 -45
- package/dist/configurators/pi.js.map +0 -1
- package/dist/configurators/qoder.d.ts +0 -11
- package/dist/configurators/qoder.d.ts.map +0 -1
- package/dist/configurators/qoder.js +0 -31
- package/dist/configurators/qoder.js.map +0 -1
- package/dist/configurators/windsurf.d.ts +0 -7
- package/dist/configurators/windsurf.d.ts.map +0 -1
- package/dist/configurators/windsurf.js +0 -19
- package/dist/configurators/windsurf.js.map +0 -1
- package/dist/templates/claude/agents/trellis-check.md +0 -124
- package/dist/templates/claude/agents/trellis-implement.md +0 -110
- package/dist/templates/claude/agents/trellis-research.md +0 -137
- package/dist/templates/claude/index.d.ts +0 -22
- package/dist/templates/claude/index.d.ts.map +0 -1
- package/dist/templates/claude/index.js +0 -46
- package/dist/templates/claude/index.js.map +0 -1
- package/dist/templates/claude/settings.json +0 -84
- package/dist/templates/codebuddy/agents/trellis-check.md +0 -115
- package/dist/templates/codebuddy/agents/trellis-implement.md +0 -110
- package/dist/templates/codebuddy/agents/trellis-research.md +0 -137
- package/dist/templates/codebuddy/index.d.ts +0 -15
- package/dist/templates/codebuddy/index.d.ts.map +0 -1
- package/dist/templates/codebuddy/index.js +0 -15
- package/dist/templates/codebuddy/index.js.map +0 -1
- package/dist/templates/codebuddy/settings.json +0 -70
- package/dist/templates/codex/agents/trellis-check.toml +0 -67
- package/dist/templates/codex/agents/trellis-implement.toml +0 -40
- package/dist/templates/codex/agents/trellis-research.toml +0 -73
- package/dist/templates/codex/config.toml +0 -28
- package/dist/templates/codex/hooks/session-start.py +0 -575
- package/dist/templates/codex/hooks.json +0 -15
- package/dist/templates/codex/index.d.ts +0 -39
- package/dist/templates/codex/index.d.ts.map +0 -1
- package/dist/templates/codex/index.js +0 -85
- package/dist/templates/codex/index.js.map +0 -1
- package/dist/templates/codex/skills/before-dev/SKILL.md +0 -40
- package/dist/templates/codex/skills/brainstorm/SKILL.md +0 -112
- package/dist/templates/codex/skills/break-loop/SKILL.md +0 -130
- package/dist/templates/codex/skills/check/SKILL.md +0 -98
- package/dist/templates/codex/skills/check-cross-layer/SKILL.md +0 -158
- package/dist/templates/codex/skills/create-command/SKILL.md +0 -101
- package/dist/templates/codex/skills/finish-work/SKILL.md +0 -90
- package/dist/templates/codex/skills/improve-ut/SKILL.md +0 -69
- package/dist/templates/codex/skills/integrate-skill/SKILL.md +0 -221
- package/dist/templates/codex/skills/onboard/SKILL.md +0 -363
- package/dist/templates/codex/skills/record-session/SKILL.md +0 -67
- package/dist/templates/codex/skills/start/SKILL.md +0 -66
- package/dist/templates/codex/skills/update-spec/SKILL.md +0 -335
- package/dist/templates/copilot/hooks/session-start.py +0 -557
- package/dist/templates/copilot/hooks.json +0 -19
- package/dist/templates/copilot/index.d.ts +0 -23
- package/dist/templates/copilot/index.d.ts.map +0 -1
- package/dist/templates/copilot/index.js +0 -54
- package/dist/templates/copilot/index.js.map +0 -1
- package/dist/templates/copilot/prompts/before-dev.prompt.md +0 -39
- package/dist/templates/copilot/prompts/brainstorm.prompt.md +0 -111
- package/dist/templates/copilot/prompts/break-loop.prompt.md +0 -129
- package/dist/templates/copilot/prompts/check-cross-layer.prompt.md +0 -157
- package/dist/templates/copilot/prompts/check.prompt.md +0 -97
- package/dist/templates/copilot/prompts/create-command.prompt.md +0 -116
- package/dist/templates/copilot/prompts/finish-work.prompt.md +0 -99
- package/dist/templates/copilot/prompts/integrate-skill.prompt.md +0 -223
- package/dist/templates/copilot/prompts/onboard.prompt.md +0 -362
- package/dist/templates/copilot/prompts/parallel.prompt.md +0 -204
- package/dist/templates/copilot/prompts/record-session.prompt.md +0 -66
- package/dist/templates/copilot/prompts/start.prompt.md +0 -63
- package/dist/templates/copilot/prompts/update-spec.prompt.md +0 -358
- package/dist/templates/droid/droids/trellis-check.md +0 -107
- package/dist/templates/droid/droids/trellis-implement.md +0 -102
- package/dist/templates/droid/droids/trellis-research.md +0 -137
- package/dist/templates/droid/index.d.ts +0 -15
- package/dist/templates/droid/index.d.ts.map +0 -1
- package/dist/templates/droid/index.js +0 -15
- package/dist/templates/droid/index.js.map +0 -1
- package/dist/templates/droid/settings.json +0 -70
- package/dist/templates/gemini/agents/trellis-check.md +0 -107
- package/dist/templates/gemini/agents/trellis-implement.md +0 -102
- package/dist/templates/gemini/agents/trellis-research.md +0 -136
- package/dist/templates/gemini/index.d.ts +0 -13
- package/dist/templates/gemini/index.d.ts.map +0 -1
- package/dist/templates/gemini/index.js +0 -13
- package/dist/templates/gemini/index.js.map +0 -1
- package/dist/templates/gemini/settings.json +0 -28
- package/dist/templates/kiro/agents/trellis-check.json +0 -26
- package/dist/templates/kiro/agents/trellis-implement.json +0 -26
- package/dist/templates/kiro/agents/trellis-research.json +0 -30
- package/dist/templates/kiro/index.d.ts +0 -18
- package/dist/templates/kiro/index.d.ts.map +0 -1
- package/dist/templates/kiro/index.js +0 -18
- package/dist/templates/kiro/index.js.map +0 -1
- package/dist/templates/opencode/agents/trellis-check.md +0 -122
- package/dist/templates/opencode/agents/trellis-implement.md +0 -118
- package/dist/templates/opencode/agents/trellis-research.md +0 -145
- package/dist/templates/opencode/lib/session-utils.js +0 -667
- package/dist/templates/opencode/lib/trellis-context.js +0 -336
- package/dist/templates/opencode/package.json +0 -5
- package/dist/templates/opencode/plugins/inject-subagent-context.js +0 -495
- package/dist/templates/opencode/plugins/inject-workflow-state.js +0 -159
- package/dist/templates/opencode/plugins/session-start.js +0 -101
- package/dist/templates/pi/agents/trellis-check.md +0 -37
- package/dist/templates/pi/agents/trellis-implement.md +0 -42
- package/dist/templates/pi/agents/trellis-research.md +0 -25
- package/dist/templates/pi/extensions/trellis/index.ts.txt +0 -1600
- package/dist/templates/pi/index.d.ts +0 -5
- package/dist/templates/pi/index.d.ts.map +0 -1
- package/dist/templates/pi/index.js +0 -12
- package/dist/templates/pi/index.js.map +0 -1
- package/dist/templates/pi/settings.json +0 -12
- package/dist/templates/qoder/agents/trellis-check.md +0 -108
- package/dist/templates/qoder/agents/trellis-implement.md +0 -103
- package/dist/templates/qoder/agents/trellis-research.md +0 -137
- package/dist/templates/qoder/index.d.ts +0 -15
- package/dist/templates/qoder/index.d.ts.map +0 -1
- package/dist/templates/qoder/index.js +0 -15
- package/dist/templates/qoder/index.js.map +0 -1
- package/dist/templates/qoder/settings.json +0 -47
|
@@ -7,12 +7,16 @@ from __future__ import annotations
|
|
|
7
7
|
|
|
8
8
|
import argparse
|
|
9
9
|
import json
|
|
10
|
+
import sys
|
|
10
11
|
from pathlib import Path
|
|
11
12
|
|
|
12
13
|
from common.codebase_retrieval_router import (
|
|
13
14
|
codebase_retrieval_selected_from_capabilities,
|
|
14
15
|
route_codebase_retrieval,
|
|
15
16
|
)
|
|
17
|
+
from common.paths import get_repo_root
|
|
18
|
+
from common.project_file_stats import resolve_project_file_count_arg
|
|
19
|
+
from common.retrieval_agent_instructions import render_agent_instructions
|
|
16
20
|
|
|
17
21
|
|
|
18
22
|
def load_capabilities(path: Path | None) -> dict[str, object] | None:
|
|
@@ -38,16 +42,24 @@ def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
|
|
38
42
|
help="Treat codebase-retrieval as unselected (omit optional adapter routes).",
|
|
39
43
|
)
|
|
40
44
|
parser.add_argument(
|
|
41
|
-
"--
|
|
42
|
-
default="
|
|
43
|
-
|
|
44
|
-
help=
|
|
45
|
+
"--project-file-count",
|
|
46
|
+
default="auto",
|
|
47
|
+
metavar="N|auto",
|
|
48
|
+
help=(
|
|
49
|
+
"File count for large-repo routing (>2000 promotes codegraph). "
|
|
50
|
+
"Default auto: git ls-files or walk from repo root. Example: 5000."
|
|
51
|
+
),
|
|
45
52
|
)
|
|
46
53
|
parser.add_argument(
|
|
47
|
-
"--
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
help="
|
|
54
|
+
"--locale",
|
|
55
|
+
default="zh",
|
|
56
|
+
choices=["zh", "en"],
|
|
57
|
+
help="Language for agent instructions (default: zh).",
|
|
58
|
+
)
|
|
59
|
+
parser.add_argument(
|
|
60
|
+
"--instructions",
|
|
61
|
+
action="store_true",
|
|
62
|
+
help="Print agent-executable instructions only (no JSON).",
|
|
51
63
|
)
|
|
52
64
|
parser.add_argument("--json", action="store_true", help="Emit JSON to stdout (default).")
|
|
53
65
|
parser.add_argument("--pretty", action="store_true", help="Pretty-print JSON.")
|
|
@@ -56,6 +68,14 @@ def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
|
|
56
68
|
|
|
57
69
|
def main(argv: list[str] | None = None) -> int:
|
|
58
70
|
args = parse_args(argv)
|
|
71
|
+
try:
|
|
72
|
+
project_file_count = resolve_project_file_count_arg(
|
|
73
|
+
args.project_file_count,
|
|
74
|
+
repo_root=get_repo_root(),
|
|
75
|
+
)
|
|
76
|
+
except ValueError as error:
|
|
77
|
+
print(f"route_codebase_retrieval: {error}", file=sys.stderr)
|
|
78
|
+
return 2
|
|
59
79
|
caps = load_capabilities(Path(args.capabilities) if args.capabilities else None)
|
|
60
80
|
selected = (
|
|
61
81
|
False
|
|
@@ -65,11 +85,18 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
65
85
|
plan = route_codebase_retrieval(
|
|
66
86
|
args.query,
|
|
67
87
|
codebase_retrieval_selected=selected,
|
|
68
|
-
|
|
69
|
-
|
|
88
|
+
project_file_count=project_file_count,
|
|
89
|
+
)
|
|
90
|
+
instructions = render_agent_instructions(
|
|
91
|
+
plan,
|
|
92
|
+
locale=args.locale,
|
|
70
93
|
)
|
|
94
|
+
if args.instructions:
|
|
95
|
+
sys.stdout.write(instructions)
|
|
96
|
+
return 0
|
|
97
|
+
payload: dict[str, object] = {**plan, "agentInstructions": instructions}
|
|
71
98
|
indent = 2 if args.pretty else None
|
|
72
|
-
print(json.dumps(
|
|
99
|
+
print(json.dumps(payload, indent=indent, ensure_ascii=False))
|
|
73
100
|
return 0
|
|
74
101
|
|
|
75
102
|
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""REC-11: derive evidence_score (0-2) from telemetry + optional rubric row."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import json
|
|
8
|
+
import sys
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
_SCRIPT_DIR = Path(__file__).resolve().parent
|
|
13
|
+
if str(_SCRIPT_DIR) not in sys.path:
|
|
14
|
+
sys.path.insert(0, str(_SCRIPT_DIR))
|
|
15
|
+
|
|
16
|
+
from common.retrieval_tool_classification import classify_tool_calls # noqa: E402
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def evidence_score_from_record(record: dict[str, Any]) -> int:
|
|
20
|
+
"""
|
|
21
|
+
Trellis verified layer proxy for eval (R-CR-014):
|
|
22
|
+
0 = no Read on candidates
|
|
23
|
+
1 = Read used but no corroborated_files / weak verify
|
|
24
|
+
2 = read_verification_done and (corroborated_files or read_count >= 1 with top1)
|
|
25
|
+
"""
|
|
26
|
+
if not record.get("read_verification_done") and int(record.get("read_count") or 0) <= 0:
|
|
27
|
+
return 0
|
|
28
|
+
corroborated = record.get("corroborated_files") or []
|
|
29
|
+
if isinstance(corroborated, list) and len(corroborated) > 0:
|
|
30
|
+
return 2
|
|
31
|
+
if record.get("read_verification_done") or int(record.get("read_count") or 0) > 0:
|
|
32
|
+
top1 = str(record.get("top1") or record.get("top_1") or "").strip()
|
|
33
|
+
if top1:
|
|
34
|
+
return 2
|
|
35
|
+
return 1
|
|
36
|
+
return 0
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def enrich_record(raw: dict[str, Any]) -> dict[str, Any]:
|
|
40
|
+
platform = str(raw.get("platform", "cursor"))
|
|
41
|
+
tools = raw.get("tools_called") or []
|
|
42
|
+
if not isinstance(tools, list):
|
|
43
|
+
tools = []
|
|
44
|
+
classified = classify_tool_calls([str(t) for t in tools], platform=platform)
|
|
45
|
+
out = dict(raw)
|
|
46
|
+
out["platform_semantic_executed"] = bool(
|
|
47
|
+
raw.get("platform_semantic_executed", classified.platform_semantic_executed)
|
|
48
|
+
)
|
|
49
|
+
out["semantic_executed"] = bool(raw.get("semantic_executed", classified.semantic_executed))
|
|
50
|
+
out["read_count"] = int(raw.get("read_count", classified.read_count))
|
|
51
|
+
if "read_verification_done" not in out:
|
|
52
|
+
out["read_verification_done"] = classified.read_count > 0
|
|
53
|
+
out["evidence_score"] = evidence_score_from_record(out)
|
|
54
|
+
ans = raw.get("answer_score")
|
|
55
|
+
if isinstance(ans, (int, float)):
|
|
56
|
+
out["combined_score"] = float(ans) + float(out["evidence_score"])
|
|
57
|
+
return out
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def main(argv: list[str] | None = None) -> int:
|
|
61
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
62
|
+
parser.add_argument("jsonl", type=Path, help="Per-query telemetry JSONL")
|
|
63
|
+
parser.add_argument("--pretty", action="store_true")
|
|
64
|
+
parser.add_argument("--markdown", action="store_true")
|
|
65
|
+
args = parser.parse_args(argv)
|
|
66
|
+
|
|
67
|
+
if not args.jsonl.is_file():
|
|
68
|
+
print(f"error: not found: {args.jsonl}", file=sys.stderr)
|
|
69
|
+
return 1
|
|
70
|
+
|
|
71
|
+
rows: list[dict[str, Any]] = []
|
|
72
|
+
for line in args.jsonl.read_text(encoding="utf-8").splitlines():
|
|
73
|
+
stripped = line.strip()
|
|
74
|
+
if not stripped:
|
|
75
|
+
continue
|
|
76
|
+
raw = json.loads(stripped)
|
|
77
|
+
if isinstance(raw, dict):
|
|
78
|
+
rows.append(enrich_record(raw))
|
|
79
|
+
|
|
80
|
+
evidence_total = sum(int(r.get("evidence_score", 0)) for r in rows)
|
|
81
|
+
combined: list[float] = []
|
|
82
|
+
for r in rows:
|
|
83
|
+
c = r.get("combined_score")
|
|
84
|
+
if isinstance(c, (int, float)):
|
|
85
|
+
combined.append(float(c))
|
|
86
|
+
|
|
87
|
+
summary = {
|
|
88
|
+
"n": len(rows),
|
|
89
|
+
"evidence_score_total": evidence_total,
|
|
90
|
+
"evidence_score_max": len(rows) * 2,
|
|
91
|
+
"avg_evidence_score": 0.0 if not rows else evidence_total / len(rows),
|
|
92
|
+
"avg_combined_score": 0.0 if not combined else sum(combined) / len(combined),
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if args.markdown:
|
|
96
|
+
print("## Evidence scores (REC-11)\n")
|
|
97
|
+
print("| query_id | evidence_score | read_verify | semantic_exec |")
|
|
98
|
+
print("| --- | ---: | --- | --- |")
|
|
99
|
+
for r in rows:
|
|
100
|
+
print(
|
|
101
|
+
f"| {r.get('query_id','')} | {r.get('evidence_score',0)} | "
|
|
102
|
+
f"{r.get('read_verification_done')} | {r.get('semantic_executed')} |"
|
|
103
|
+
)
|
|
104
|
+
print(f"\nTotal evidence: **{evidence_total}** / {summary['evidence_score_max']}")
|
|
105
|
+
else:
|
|
106
|
+
payload = {"summary": summary, "records": rows}
|
|
107
|
+
print(json.dumps(payload, ensure_ascii=False, indent=2 if args.pretty else None))
|
|
108
|
+
return 0
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
if __name__ == "__main__":
|
|
112
|
+
raise SystemExit(main())
|
|
@@ -28,6 +28,7 @@ Usage:
|
|
|
28
28
|
python task.py set-child-state <parent-dir> <child-dir> <state> --evidence <ref>
|
|
29
29
|
python task.py integrate-child <parent-dir> <child-dir> <state> --evidence <ref>
|
|
30
30
|
python task.py generate-child-prompt <parent-dir> <child-dir> [--mode inline|subagent]
|
|
31
|
+
python task.py generate-dispatch-prompt <task-dir> <role> [--scope TEXT] [--finish] [--max-chars N]
|
|
31
32
|
python task.py parent-status <parent-dir>
|
|
32
33
|
python task.py review-child <parent-dir> <child-dir> [--check] [--decision accept|changes|cancel|integrate-through]
|
|
33
34
|
"""
|
|
@@ -90,6 +91,7 @@ from common.task_store import (
|
|
|
90
91
|
cmd_set_child_state,
|
|
91
92
|
cmd_integrate_child,
|
|
92
93
|
cmd_generate_child_prompt,
|
|
94
|
+
cmd_generate_dispatch_prompt,
|
|
93
95
|
cmd_parent_status,
|
|
94
96
|
cmd_review_child,
|
|
95
97
|
)
|
|
@@ -750,6 +752,29 @@ def main() -> int:
|
|
|
750
752
|
p_integrate_child.add_argument("--execute-merge", action="store_true", help="Execute git merge --no-ff --no-commit for an integrated Child")
|
|
751
753
|
p_integrate_child.add_argument("--check", action="store_true", help="Run non-mutating integration readiness check")
|
|
752
754
|
|
|
755
|
+
# generate-dispatch-prompt
|
|
756
|
+
p_dispatch_prompt = subparsers.add_parser(
|
|
757
|
+
"generate-dispatch-prompt",
|
|
758
|
+
help="Build full Task dispatch prompt (Agent-facing)",
|
|
759
|
+
)
|
|
760
|
+
p_dispatch_prompt.add_argument("task_dir", help="Task directory")
|
|
761
|
+
p_dispatch_prompt.add_argument(
|
|
762
|
+
"role",
|
|
763
|
+
choices=["implement", "check", "research"],
|
|
764
|
+
help="Subagent role",
|
|
765
|
+
)
|
|
766
|
+
p_dispatch_prompt.add_argument("--scope", help="One-line task instruction for subagent")
|
|
767
|
+
p_dispatch_prompt.add_argument(
|
|
768
|
+
"--finish",
|
|
769
|
+
action="store_true",
|
|
770
|
+
help="Use finish check context (role=check only)",
|
|
771
|
+
)
|
|
772
|
+
p_dispatch_prompt.add_argument(
|
|
773
|
+
"--max-chars",
|
|
774
|
+
type=int,
|
|
775
|
+
help="Hard truncate embedded context block",
|
|
776
|
+
)
|
|
777
|
+
|
|
753
778
|
# generate-child-prompt
|
|
754
779
|
p_gen_prompt = subparsers.add_parser(
|
|
755
780
|
"generate-child-prompt",
|
|
@@ -834,6 +859,7 @@ def main() -> int:
|
|
|
834
859
|
"set-child-state": cmd_set_child_state,
|
|
835
860
|
"integrate-child": cmd_integrate_child,
|
|
836
861
|
"generate-child-prompt": cmd_generate_child_prompt,
|
|
862
|
+
"generate-dispatch-prompt": cmd_generate_dispatch_prompt,
|
|
837
863
|
"parent-status": cmd_parent_status,
|
|
838
864
|
"review-child": cmd_review_child,
|
|
839
865
|
"list": cmd_list,
|