@blxzer/cursor-trellis 0.1.1 → 0.1.3
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 +2 -0
- package/dist/migrations/manifests/0.1.1.json +9 -0
- package/dist/migrations/manifests/0.1.2.json +9 -0
- package/dist/templates/cursor/rules/retrieval-routing.mdc +9 -7
- package/dist/templates/markdown/spec/guides/cursor-context-injection-guide.md.txt +2 -1
- package/dist/templates/markdown/spec/guides/cursor-subagent-policy.md.txt +16 -3
- package/dist/templates/markdown/spec/guides/retrieval-daily-guide.md.txt +11 -6
- package/dist/templates/shared-hooks/inject-subagent-context.py +31 -567
- package/dist/templates/trellis/index.d.ts +2 -0
- package/dist/templates/trellis/index.d.ts.map +1 -1
- package/dist/templates/trellis/index.js +4 -0
- package/dist/templates/trellis/index.js.map +1 -1
- package/dist/templates/trellis/scripts/common/codebase_retrieval_router.py +78 -29
- package/dist/templates/trellis/scripts/common/cursor_retrieval_env.py +92 -0
- package/dist/templates/trellis/scripts/common/retrieval_adapter_metadata.py +100 -9
- package/dist/templates/trellis/scripts/common/retrieval_agent_instructions.py +76 -31
- package/dist/templates/trellis/scripts/common/retrieval_tool_classification.py +18 -3
- package/dist/templates/trellis/scripts/common/semantic_plan_gate.py +19 -0
- package/dist/templates/trellis/scripts/common/smart_search_evidence.py +5 -2
- 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/cursor_retrieval_probe.py +396 -0
- package/dist/templates/trellis/scripts/cursor_retrieval_probe_prompt.md +300 -0
- package/dist/templates/trellis/scripts/retrieval_probe_matrix_template.json +126 -0
- package/dist/templates/trellis/scripts/task.py +26 -0
- package/dist/templates/trellis/workflow.md +5 -22
- package/dist/utils/codebase-retrieval-router.d.ts +5 -0
- package/dist/utils/codebase-retrieval-router.d.ts.map +1 -1
- package/dist/utils/codebase-retrieval-router.js +48 -28
- package/dist/utils/codebase-retrieval-router.js.map +1 -1
- package/dist/utils/cursor-retrieval-env.d.ts +28 -0
- package/dist/utils/cursor-retrieval-env.d.ts.map +1 -0
- package/dist/utils/cursor-retrieval-env.js +89 -0
- package/dist/utils/cursor-retrieval-env.js.map +1 -0
- package/dist/utils/project-capabilities.d.ts.map +1 -1
- package/dist/utils/project-capabilities.js +22 -15
- package/dist/utils/project-capabilities.js.map +1 -1
- package/dist/utils/retrieval-agent-instructions.d.ts.map +1 -1
- package/dist/utils/retrieval-agent-instructions.js +37 -21
- package/dist/utils/retrieval-agent-instructions.js.map +1 -1
- package/dist/utils/retrieval-tool-classification.d.ts +2 -0
- package/dist/utils/retrieval-tool-classification.d.ts.map +1 -1
- package/dist/utils/retrieval-tool-classification.js +10 -2
- package/dist/utils/retrieval-tool-classification.js.map +1 -1
- package/dist/utils/semantic-plan-gate.d.ts +8 -0
- package/dist/utils/semantic-plan-gate.d.ts.map +1 -0
- package/dist/utils/semantic-plan-gate.js +42 -0
- package/dist/utils/semantic-plan-gate.js.map +1 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -40,6 +40,8 @@ trellis init --cursor
|
|
|
40
40
|
|
|
41
41
|
Optional: `trellis init --cursor --cursor2plus` for Cursor++ BYOK local bundle; see [docs/cursor.md](docs/cursor.md#cursor-optional-appendix).
|
|
42
42
|
|
|
43
|
+
**Codebase retrieval (optional):** add `--capability codebase-retrieval` (or select it in the init prompt) to generate `.cursor/mcp.json` entries for **fast-context** and **codegraph**. Recommended for **Cursor++ BYOK** local concept search (`fast_context_search`); not required if you only need other capabilities (e.g. playwright).
|
|
44
|
+
|
|
43
45
|
## After init: what appears
|
|
44
46
|
|
|
45
47
|
```text
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.1.1",
|
|
3
|
+
"description": "v0.1.1 — Cursor-only platform reduction. Trellis templates, CLI init/update/uninstall, retrieval router, and docs converge on Cursor as the sole managed platform.",
|
|
4
|
+
"breaking": false,
|
|
5
|
+
"recommendMigrate": false,
|
|
6
|
+
"changelog": "**Cursor-only product trim.**\n\n- refactor(cli): platform registry, init, uninstall/update, and template dirs reduced to Cursor-only (S1–S11).\n- refactor(retrieval): drop `--platform` / non-Cursor dead branches from codebase retrieval planner (R12).\n- refactor(core): remove mem module export (R13).\n- docs/spec: workflow, AGENTS, README, and guides aligned to cursor-only surface.\n\nRun `trellis update` in each project to sync templates and scripts.",
|
|
7
|
+
"migrations": [],
|
|
8
|
+
"notes": "Backfilled manifest for npm 0.1.1 (published without local manifest). No automated migrations; template sync via `trellis update`."
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.1.2",
|
|
3
|
+
"description": "v0.1.2 — Agent dispatch context assembly: `generate-dispatch-prompt` CLI (Layer 2) plus shared subagent_dispatch builder and slim preToolUse hook.",
|
|
4
|
+
"breaking": false,
|
|
5
|
+
"recommendMigrate": false,
|
|
6
|
+
"changelog": "**Subagent dispatch Layer 2 (Agent-facing).**\n\n- feat(cli): `task.py generate-dispatch-prompt <task-dir> <role>` assembles full Task prompts (marker, Selected task, prd/jsonl/spec embed).\n- refactor(scripts): `common/subagent_dispatch.py` single builder; hook is thin wrapper with marker dedup.\n- docs: workflow Phase 2.1/2.2 orchestrator contract; cursor-context-injection-guide + cursor-subagent-policy Layer 2 rows.\n\nFull/Parent implement/check on Cursor: main session should run dispatch CLI before `Task(trellis-*)`. Hook remains best-effort.",
|
|
7
|
+
"migrations": [],
|
|
8
|
+
"notes": "No user README changes. Run `trellis update` in each project to sync `.trellis/scripts` and hooks."
|
|
9
|
+
}
|
|
@@ -13,7 +13,7 @@ If the user message or Trellis context contains a block starting with `## 代码
|
|
|
13
13
|
|
|
14
14
|
1. Execute steps **in order** before stating file paths or behavior claims.
|
|
15
15
|
2. Treat each step as mandatory tooling (not suggestions).
|
|
16
|
-
3. Finish with **Read**
|
|
16
|
+
3. Finish with **Read** verification on cited sources (definition jumps use **codegraph_node**, not LSP).
|
|
17
17
|
|
|
18
18
|
Generate a fresh plan when needed:
|
|
19
19
|
|
|
@@ -35,14 +35,16 @@ python ./.trellis/scripts/route_codebase_retrieval.py "<question>" --json
|
|
|
35
35
|
| Who calls / blast radius | **codegraph_callers** → Grep for imports/callbacks |
|
|
36
36
|
| Same name across packages (trap) | **codegraph_search** / **codegraph_explore** → Grep |
|
|
37
37
|
| Extension symbols | **codegraph_search** under `extensions/` |
|
|
38
|
-
| Conceptual / how does X work |
|
|
38
|
+
| Conceptual / how does X work | **Native:** built-in `@codebase` / semantic search. **BYOK:** **fast_context_search** (fast-context MCP). Plans show `cursorEnv`. |
|
|
39
39
|
| Policy / architecture / boundaries / storage rules | **Grep** on `AGENTS.md`, `**/AGENTS.md`, `.trellis/spec/**`, `README.md` (router `policy-docs-rg`) before implementation modules |
|
|
40
|
-
| Definition jump | **
|
|
41
|
-
| Wide cross-cutting explore | **DEEP_SEARCH
|
|
40
|
+
| Definition jump | **codegraph_node** / **codegraph_search**, then **Read** (Agent does not expose GO_TO_DEFINITION / LSP) |
|
|
41
|
+
| Wide cross-cutting explore | **Native:** DEEP_SEARCH or Explore subagent. **BYOK:** **Task explore** subagent, then Grep/codegraph/Read |
|
|
42
42
|
|
|
43
|
-
## Semantic on Cursor
|
|
43
|
+
## Semantic on Cursor (`platform-semantic`)
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
- **cursorEnv native:** built-in codebase semantic search (`platformNative`). Do **not** use fast-context MCP for semantic Primary.
|
|
46
|
+
- **cursorEnv byok:** **fast-context MCP** is **required** for concept retrieval; built-in `@codebase` is not available in the agent tool list.
|
|
47
|
+
- Override detection: `TRELLIS_CURSOR_BYOK=0|1` or `~/.ccursor/routes.json` `byokMode`.
|
|
46
48
|
|
|
47
49
|
## Result-layer ranking (B / E / D)
|
|
48
50
|
|
|
@@ -50,7 +52,7 @@ When the plan block includes **结果层排序**, apply it **after** collecting
|
|
|
50
52
|
|
|
51
53
|
## codegraph-only value
|
|
52
54
|
|
|
53
|
-
Use codegraph for **call chains**, **cross-package trap disambiguation**, **extension symbol resolution**, and **
|
|
55
|
+
Use codegraph for **call chains**, **cross-package trap disambiguation**, **extension symbol resolution**, **impact**, and **definition/reference** (replaces unavailable Agent LSP) — not for pure literal search (Grep) or BYOK concept Primary (use fast-context).
|
|
54
56
|
|
|
55
57
|
## External facts
|
|
56
58
|
|
|
@@ -15,8 +15,9 @@ Cursor has **four** channels that can put text in front of the model. They are *
|
|
|
15
15
|
| `AGENTS.md` (repo root + nested) | Read automatically, treated as an always-on rule | ✅ **Yes** | smart-search-first rule, command surface, remote policy (the `<!-- TRELLIS:START -->` block) |
|
|
16
16
|
| `sessionStart` hook → `additional_context` | Hook fires, JSON parsed... **but content never reaches the model's system context** | ❌ **No (confirmed bug)** | workflow.md Phase Index + Task Dashboard + first-reply notice |
|
|
17
17
|
| `.trellis/workflow.md` (read on demand) | Only if the agent explicitly runs `get_context.py` or reads the file | ⚠️ Depends on agent taking action | Full Request Triage section, Task Ladder, workflow-state breadcrumbs |
|
|
18
|
+
| **`task.py generate-dispatch-prompt` → Task `prompt`** (CLI Layer 2) | Main session runs Trellis script before `Task(...)` | ✅ **Yes (primary for subagent task context on Cursor)** | Full embed: marker, `Selected task:`, prd/jsonl/spec bodies |
|
|
18
19
|
|
|
19
|
-
**Key takeaway**: anything that must reach the model **every turn without the agent choosing to load it** must live in `.cursor/rules` or `AGENTS.md`. Anything in `workflow.md` that depends on `sessionStart` injection is **invisible to Cursor agents** until the bug is fixed.
|
|
20
|
+
**Key takeaway**: anything that must reach the model **every turn without the agent choosing to load it** must live in `.cursor/rules` or `AGENTS.md`. Subagent task context on Cursor uses **CLI Layer 2** before Task dispatch; `preToolUse` hook injection is best-effort only (see forum reports + 2026-06-22 spike). Anything in `workflow.md` that depends on `sessionStart` injection is **invisible to Cursor agents** until the bug is fixed.
|
|
20
21
|
|
|
21
22
|
---
|
|
22
23
|
|
|
@@ -19,7 +19,8 @@ How did I reach trellis-research / trellis-implement / trellis-check?
|
|
|
19
19
|
│
|
|
20
20
|
├─ Main session dispatched Task(subagent_type=trellis-*)
|
|
21
21
|
│ → Task dispatch. ONLY path where BYOK json5 + Method 2.5 applies.
|
|
22
|
-
│
|
|
22
|
+
│ Context: CLI Layer 2 pre-embed (primary on Cursor); hook is best-effort
|
|
23
|
+
│ (<!-- trellis-hook-injected --> marker; skips if already present).
|
|
23
24
|
│
|
|
24
25
|
└─ Used the trellis-check SKILL in main session (no subagent spawn)
|
|
25
26
|
→ Skill form. Main-session model. Only trellis-check has both
|
|
@@ -35,8 +36,8 @@ If unsure: Task dispatch is the path Trellis workflow routes through; Agent sess
|
|
|
35
36
|
| Scene | Mechanism | Mode | Output / notes |
|
|
36
37
|
| --------------------------------------------------- | -------------------------------------------------------------- | ----------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
37
38
|
| Code, history, or external research | `ttrellis-research` | Cursor **Agent** (writable) | `{TASK}/research/*.md`; smart-search-cli first, Cursor web fallback per skill |
|
|
38
|
-
| Implementation (after `start-execution --approved`) | `ttrellis-implement` | Agent | Code edits; no `git commit` in subagent
|
|
39
|
-
| Post-implementation verification | `ttrellis-check` | Agent | Fixes + `verify.md` / gate hints; main session records gates
|
|
39
|
+
| Implementation (after `start-execution --approved`) | `ttrellis-implement` | Agent | Code edits; no `git commit` in subagent; **CLI Layer 2** dispatch prompt on Cursor |
|
|
40
|
+
| Post-implementation verification | `ttrellis-check` | Agent | Fixes + `verify.md` / gate hints; **CLI Layer 2** on Cursor; main session records gates |
|
|
40
41
|
| Parent/Child child worker | `generate-child-prompt --mode subagent` | **Parent Task** `trellis-implement` (default) | Child delivers `verify.md` + `handoff.md`; rare per-child model → **new writable Agent** session when user names that child |
|
|
41
42
|
| Architecture / deep review | `ttrellis-check` or documented inline deep review | Agent or main session | Model via dispatch strategy (Methods 1–2.5, 3–4 below) |
|
|
42
43
|
| PRD Grill (planning) | `trellis-micro-grill` contract **inside** `trellis-brainstorm` | **Not** a subagent | Single-question business follow-ups only |
|
|
@@ -309,6 +310,18 @@ trellis_task_subagents:
|
|
|
309
310
|
|
|
310
311
|
---
|
|
311
312
|
|
|
313
|
+
## Maintainer: subagent missing task context (Cursor)
|
|
314
|
+
|
|
315
|
+
If a dispatched subagent cannot answer from `prd.md` / jsonl (empty or generic replies):
|
|
316
|
+
|
|
317
|
+
1. Confirm the main session used **CLI Layer 2** before `Task(...)` (workflow Phase 2.1 / 2.2).
|
|
318
|
+
2. **Manual fallback (Method 3):** run `python ./.trellis/scripts/task.py generate-dispatch-prompt <task-dir> <role> [--scope "..."]`, paste stdout into `Task(subagent_type=..., prompt=...)`.
|
|
319
|
+
3. Hook-only injection is best-effort on Cursor; do not treat `preToolUse` as the sole source.
|
|
320
|
+
|
|
321
|
+
This command is **Agent-facing** — not listed in user README or slash command surface.
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
312
325
|
## Hook fallback (no selected-task pointer)
|
|
313
326
|
|
|
314
327
|
When `preToolUse` cannot resolve a selected task, the subagent should read **`Selected task:`** from the first line of its dispatch prompt, then load `implement.jsonl` / `check.jsonl`, `prd.md`, `design.md`, and `implement.md` manually. Trellis does **not** document or depend on Cursor `/multitask` for workflow orchestration.
|
|
@@ -12,7 +12,7 @@ For **external / current / web facts**, **smart-search** (`run_smart_search.py`)
|
|
|
12
12
|
| --- | --- | --- |
|
|
13
13
|
| Exact string / path / log line | **rg** (Grep) | Fast literal match in repo |
|
|
14
14
|
| Symbol, callers, edit blast radius | **codegraph** MCP | Structure-first for caller/trap/extension intents |
|
|
15
|
-
| Unknown keywords, semantic discovery | **@codebase** (Cursor)
|
|
15
|
+
| Unknown keywords, semantic discovery | **@codebase** (Cursor Native) / **fast-context** (Cursor++ BYOK) | Native: built-in semantic; BYOK: `fast_context_search` MCP (see `cursorEnv` in plans) |
|
|
16
16
|
| External / current facts | **smart-search-cli** | **Mandatory first** — built-in web tools are downgrade-only (see rule above) |
|
|
17
17
|
| Trellis durable docs | **artifact-search** | `search_artifacts.py` |
|
|
18
18
|
| Past sessions | **session-memory** | Historical; verify against tasks/spec |
|
|
@@ -22,7 +22,12 @@ For **external / current / web facts**, **smart-search** (`run_smart_search.py`)
|
|
|
22
22
|
|
|
23
23
|
## Semantic routing (Cursor)
|
|
24
24
|
|
|
25
|
-
The
|
|
25
|
+
The planner emits **`platform-semantic`** with backend chosen by **`cursorEnv`** (`native` | `byok` from `~/.ccursor/routes.json` or `TRELLIS_CURSOR_BYOK`):
|
|
26
|
+
|
|
27
|
+
- **native:** built-in `@codebase` / agent semantic search — **do not** use fast-context as Primary.
|
|
28
|
+
- **byok:** **fast-context MCP** (`fast_context_search`) — built-in semantic is not in the agent tool list.
|
|
29
|
+
|
|
30
|
+
Definition / reference jumps: **codegraph** (not GO_TO_DEFINITION; Agent LSP unavailable).
|
|
26
31
|
|
|
27
32
|
## Token economy signals
|
|
28
33
|
|
|
@@ -99,9 +104,9 @@ Do **not** claim aggregate openclaw score gains from ranking alone without fresh
|
|
|
99
104
|
|
|
100
105
|
For structural intents (caller-chain, trap-package-disambiguation, extension-shared-symbol), the router now suggests **codegraph before rg**. This reflects codegraph's superior token economy for structural queries (~80-150 tokens/answer vs rg's ~3557 for naive grep). The agent should still use rg to fill gaps codegraph misses (dynamic dispatch, string-based callsites).
|
|
101
106
|
|
|
102
|
-
### Semantic routing on Cursor
|
|
107
|
+
### Semantic routing on Cursor (plans)
|
|
103
108
|
|
|
104
|
-
|
|
109
|
+
Envelopes include **`cursorEnv`**. `platform-semantic` uses **`platformNative: true`** on native and **`semanticBackend: fast-context-mcp`** on BYOK. Native: `@codebase` / built-in search; BYOK: `fast_context_search`.
|
|
105
110
|
|
|
106
111
|
### Semantic dual metrics (openclaw / eval)
|
|
107
112
|
|
|
@@ -110,7 +115,7 @@ On Cursor, the router outputs `platform-semantic` routes (with `platformNative:
|
|
|
110
115
|
| `semantic_plan_rate` | Share of queries whose routing envelope lists a semantic route |
|
|
111
116
|
| `semantic_exec_rate` | Share of queries with ≥1 semantic search tool call |
|
|
112
117
|
|
|
113
|
-
On **Cursor**, `semantic_exec_rate` uses
|
|
118
|
+
On **Cursor**, `semantic_exec_rate` uses `classify_tool_calls(..., platform=cursor, cursor_env=...)`: **native** counts built-in semantic only; **byok** counts `fast_context_search` as semantic exec. `cursor_fast_context_misuse` applies only when **native** (or non-byok) uses fast-context while the plan has `platform-semantic`. See `cursor-semantic-compliance.md`.
|
|
114
119
|
|
|
115
120
|
Plan-level presence does not imply execution-level use (see parent research `06-19` OQ-1 双轨).
|
|
116
121
|
|
|
@@ -126,7 +131,7 @@ Store **one JSON object per query** in JSONL (`schema_version: 2`). Split scores
|
|
|
126
131
|
Report **summary rates must not be hand-copied** from batch router envelopes. Aggregate from JSONL:
|
|
127
132
|
|
|
128
133
|
```powershell
|
|
129
|
-
python
|
|
134
|
+
python ./.trellis/scripts/aggregate_retrieval_telemetry.py runs/<run>/telemetry.jsonl --markdown
|
|
130
135
|
```
|
|
131
136
|
|
|
132
137
|
Key exec fields (fill from session tool log): `tools_called`, `grep_count`, `read_count`, `codegraph_executed`, `semantic_executed`, `router_cli_invoked`, `plan_block_in_prompt`, `read_verification_done`. TypeScript contract: `packages/cli/src/utils/retrieval-execution-telemetry.ts` (`RETRIEVAL_TELEMETRY_FIELD_OWNERSHIP`).
|