@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
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"""Classify agent tool names for retrieval execution telemetry (Cursor-first)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
|
|
8
|
+
CODEGRAPH_PATTERNS = (
|
|
9
|
+
re.compile(r"^codegraph_", re.I),
|
|
10
|
+
re.compile(r"^project-0-.*-codegraph-", re.I),
|
|
11
|
+
re.compile(r"codegraph_search", re.I),
|
|
12
|
+
re.compile(r"codegraph_explore", re.I),
|
|
13
|
+
re.compile(r"codegraph_callers", re.I),
|
|
14
|
+
re.compile(r"codegraph_node", re.I),
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
PLATFORM_SEMANTIC_PATTERNS = (
|
|
18
|
+
re.compile(r"@codebase", re.I),
|
|
19
|
+
re.compile(r"semantic.?search", re.I),
|
|
20
|
+
re.compile(r"DEEP_SEARCH", re.I),
|
|
21
|
+
re.compile(r"codebase.?search", re.I),
|
|
22
|
+
re.compile(r"SemanticSearch", re.I),
|
|
23
|
+
re.compile(r"Instant Search", re.I),
|
|
24
|
+
re.compile(r"Cursor.*semantic", re.I),
|
|
25
|
+
re.compile(r"built-?in.*codebase", re.I),
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
FAST_CONTEXT_PATTERNS = (
|
|
29
|
+
re.compile(r"fast_context_search", re.I),
|
|
30
|
+
re.compile(r"fast-context", re.I),
|
|
31
|
+
re.compile(r"fast_context", re.I),
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
GREP_PATTERNS = (
|
|
35
|
+
re.compile(r"^grep$", re.I),
|
|
36
|
+
re.compile(r"^Grep$", re.I),
|
|
37
|
+
re.compile(r"^rg$", re.I),
|
|
38
|
+
re.compile(r"ripgrep", re.I),
|
|
39
|
+
re.compile(r"Instant Grep", re.I),
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
READ_PATTERNS = (
|
|
43
|
+
re.compile(r"^read$", re.I),
|
|
44
|
+
re.compile(r"^Read$", re.I),
|
|
45
|
+
re.compile(r"ReadFile", re.I),
|
|
46
|
+
re.compile(r"Get-Content", re.I),
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
ROUTER_CLI_PATTERNS = (
|
|
50
|
+
re.compile(r"route_codebase_retrieval", re.I),
|
|
51
|
+
re.compile(r"retrieval-routing", re.I),
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
STRUCTURAL_ROUTE_IDS = frozenset(
|
|
55
|
+
{
|
|
56
|
+
"caller-chain-ast",
|
|
57
|
+
"trap-demote-codegraph",
|
|
58
|
+
"extension-codegraph",
|
|
59
|
+
"ast-codegraph",
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _matches(name: str, patterns: tuple[re.Pattern[str], ...]) -> bool:
|
|
65
|
+
return any(p.search(name) for p in patterns)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def is_platform_semantic_tool_name(name: str) -> bool:
|
|
69
|
+
return _matches(name.strip(), PLATFORM_SEMANTIC_PATTERNS)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def is_fast_context_tool_name(name: str) -> bool:
|
|
73
|
+
return _matches(name.strip(), FAST_CONTEXT_PATTERNS)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@dataclass(frozen=True)
|
|
77
|
+
class ClassifiedToolCalls:
|
|
78
|
+
tools_called: list[str]
|
|
79
|
+
grep_count: int
|
|
80
|
+
read_count: int
|
|
81
|
+
codegraph_attempted: bool
|
|
82
|
+
codegraph_executed: bool
|
|
83
|
+
semantic_attempted: bool
|
|
84
|
+
semantic_executed: bool
|
|
85
|
+
router_cli_invoked: bool
|
|
86
|
+
platform_semantic_executed: bool = False
|
|
87
|
+
fast_context_count: int = 0
|
|
88
|
+
cursor_fast_context_misuse: bool = False
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def classify_tool_calls(raw: list[str], *, platform: str = "cursor") -> ClassifiedToolCalls:
|
|
92
|
+
tools_called = list(raw)
|
|
93
|
+
grep_count = 0
|
|
94
|
+
read_count = 0
|
|
95
|
+
codegraph_executed = False
|
|
96
|
+
router_cli_invoked = False
|
|
97
|
+
platform_semantic_executed = False
|
|
98
|
+
fast_context_count = 0
|
|
99
|
+
plat = (platform or "cursor").lower()
|
|
100
|
+
|
|
101
|
+
for name in raw:
|
|
102
|
+
trimmed = name.strip()
|
|
103
|
+
if not trimmed:
|
|
104
|
+
continue
|
|
105
|
+
if _matches(trimmed, GREP_PATTERNS):
|
|
106
|
+
grep_count += 1
|
|
107
|
+
if _matches(trimmed, READ_PATTERNS):
|
|
108
|
+
read_count += 1
|
|
109
|
+
if _matches(trimmed, CODEGRAPH_PATTERNS):
|
|
110
|
+
codegraph_executed = True
|
|
111
|
+
if _matches(trimmed, ROUTER_CLI_PATTERNS):
|
|
112
|
+
router_cli_invoked = True
|
|
113
|
+
if is_fast_context_tool_name(trimmed):
|
|
114
|
+
fast_context_count += 1
|
|
115
|
+
if is_platform_semantic_tool_name(trimmed):
|
|
116
|
+
platform_semantic_executed = True
|
|
117
|
+
|
|
118
|
+
if plat == "cursor":
|
|
119
|
+
semantic_executed = platform_semantic_executed
|
|
120
|
+
else:
|
|
121
|
+
semantic_executed = platform_semantic_executed or fast_context_count > 0
|
|
122
|
+
|
|
123
|
+
semantic_attempted = semantic_executed or fast_context_count > 0
|
|
124
|
+
misuse = plat == "cursor" and fast_context_count > 0
|
|
125
|
+
|
|
126
|
+
return ClassifiedToolCalls(
|
|
127
|
+
tools_called=tools_called,
|
|
128
|
+
grep_count=grep_count,
|
|
129
|
+
read_count=read_count,
|
|
130
|
+
codegraph_attempted=codegraph_executed,
|
|
131
|
+
codegraph_executed=codegraph_executed,
|
|
132
|
+
semantic_attempted=semantic_attempted,
|
|
133
|
+
semantic_executed=semantic_executed,
|
|
134
|
+
router_cli_invoked=router_cli_invoked,
|
|
135
|
+
platform_semantic_executed=platform_semantic_executed,
|
|
136
|
+
fast_context_count=fast_context_count,
|
|
137
|
+
cursor_fast_context_misuse=misuse,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def structural_routes_in_plan(route_ids: list[str]) -> bool:
|
|
142
|
+
return any(
|
|
143
|
+
"codegraph" in rid or rid in STRUCTURAL_ROUTE_IDS for rid in route_ids
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def semantic_routes_in_plan(route_ids: list[str]) -> bool:
|
|
148
|
+
return any(rid in ("platform-semantic", "semantic-fast-context") for rid in route_ids)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def platform_semantic_route_order(routes: list[dict]) -> int | None:
|
|
152
|
+
for route in routes:
|
|
153
|
+
if isinstance(route, dict) and route.get("id") == "platform-semantic":
|
|
154
|
+
order = route.get("order")
|
|
155
|
+
if isinstance(order, int):
|
|
156
|
+
return order
|
|
157
|
+
return None
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""REC-11: post-plan hints when platform-semantic is first-class in the router envelope."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def platform_semantic_order_from_envelope(envelope: dict[str, Any]) -> int | None:
|
|
9
|
+
routes = envelope.get("routes")
|
|
10
|
+
if not isinstance(routes, list):
|
|
11
|
+
return None
|
|
12
|
+
for route in routes:
|
|
13
|
+
if not isinstance(route, dict):
|
|
14
|
+
continue
|
|
15
|
+
if route.get("id") == "platform-semantic":
|
|
16
|
+
order = route.get("order")
|
|
17
|
+
if isinstance(order, int):
|
|
18
|
+
return order
|
|
19
|
+
return None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def semantic_compliance_gate_hint(
|
|
23
|
+
envelope: dict[str, Any],
|
|
24
|
+
*,
|
|
25
|
+
locale: str = "zh",
|
|
26
|
+
) -> str:
|
|
27
|
+
"""
|
|
28
|
+
When platform-semantic is order 1 (or 2 on policy-first routes), append a
|
|
29
|
+
hard compliance strip for eval / hook-injected plans (REC-06 + REC-11).
|
|
30
|
+
"""
|
|
31
|
+
order = platform_semantic_order_from_envelope(envelope)
|
|
32
|
+
if order is None or order > 2:
|
|
33
|
+
return ""
|
|
34
|
+
routes = envelope.get("routes") or []
|
|
35
|
+
if not isinstance(routes, list):
|
|
36
|
+
return ""
|
|
37
|
+
if not any(isinstance(r, dict) and r.get("id") == "platform-semantic" for r in routes):
|
|
38
|
+
return ""
|
|
39
|
+
|
|
40
|
+
if locale != "zh":
|
|
41
|
+
return (
|
|
42
|
+
"**Plan gate (REC-11):** `platform-semantic` is step "
|
|
43
|
+
f"#{order}. Before Top-1 you MUST run one Cursor built-in codebase "
|
|
44
|
+
"semantic search and log the exact tool name. Do not use fast-context MCP. "
|
|
45
|
+
"If semantic returns paths, corroborate with Read on candidate ranges."
|
|
46
|
+
)
|
|
47
|
+
return (
|
|
48
|
+
"**计划门控(REC-11):** 本问 `platform-semantic` 为第 "
|
|
49
|
+
f"{order} 步。定 Top-1 前 **必须** 执行 1 次 Cursor **内置代码库语义搜索**,"
|
|
50
|
+
"并在记录中写下宿主工具名;**禁止** fast-context MCP。"
|
|
51
|
+
"语义命中路径后须 **Read** 验证候选片段(verified 层)。"
|
|
52
|
+
)
|