@shiftleftpt/sbd-toe-mcp 0.20.0-beta.23 → 0.20.0-beta.25

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.
@@ -21,8 +21,10 @@ adjacências do grafo, de forma reproduzível e auditável.
21
21
  É a lista **fechada** de valores que aceito e, para cada valor, **o que ele activa**
22
22
  (categorias, capítulos, contagens por nível). É ele que substitui a adivinhação de palavras.
23
23
  2. **Mapeia e declara** — `select_sbd_toe_requirements(risk_level, concerns=[…], …)`.
24
- O `task` podes enviá-lo à mesma: fica **registado para auditoria** (`role:
24
+ O enunciado podes enviá-lo à mesma em **`task_context`** (nome canónico desde
25
+ 0.20.0-beta.24; `task` continua aceite): fica **registado para auditoria** (`role:
25
26
  "recorded_context"`, `affects_selection: false`) e **não influencia o resultado**.
27
+ O campo mudou de nome porque o nome antigo convidava a acreditar que o texto decide.
26
28
  3. **Sem declarações** recebes `needs_input`: o vocabulário aplicável, **candidatos A
27
29
  CONFIRMAR** derivados do texto (sugestão, nunca selecção) e um exemplo copiável.
28
30
  Nunca devolvo zero em silêncio e nunca invento o teu âmbito.
@@ -46,8 +48,11 @@ SbD-ToE is a **security guidance framework only**. It guides *what security prac
46
48
  be applied* at each phase of the development lifecycle. It does **not** impose development
47
49
  standards, testing requirements, coding conventions, or any non-security practice.
48
50
 
49
- **Project rules always take precedence.** An L1 risk level reduces the scope of required
50
- security controls — it does not reduce code quality, test coverage, or engineering expectations.
51
+ **Project rules always take precedence.** An L1 risk level reduces the **DEMAND** on the
52
+ security controls — never the scope: graduated applicability (0.14.0) keeps every chapter
53
+ present at every level, and `map_sbd_toe_applicability` states it outright («nothing is
54
+ excluded by level»). And it does not reduce code quality, test coverage, or engineering
55
+ expectations.
51
56
 
52
57
  ---
53
58
 
@@ -66,7 +71,9 @@ or — on clients without resource support — call `read_sbd_toe_resource(uri="
66
71
  It returns the server name/version plus the served knowledge identity from the verified pin:
67
72
  `manual {tag, commit}`, `kg {release_tag, sha256, source, consumer_contract_version}`,
68
73
  `ontology {tag, commit}`. Every tool response also carries the compact stamp
69
- `provenance.kg` (the served kg release_tag). The same tool mirrors ANY resource of the
74
+ `provenance.kg` (the served kg release_tag) **and `provenance.server`** (the package version
75
+ that produced the answer — since 0.20.0-beta.23: `kg` is the knowledge served, `server` is
76
+ who served it). The same tool mirrors ANY resource of the
70
77
  list below — including the templated ones (e.g. `sbd://toe/codegen-instructions/codegen`,
71
78
  the target of `codegen_instructions_ref` in dieted payloads).
72
79
 
@@ -81,8 +88,9 @@ This returns the list of active chapters and risk-level specific rules for the p
81
88
  > **Verdade do canal:** `setup_sbd_toe_agent` é um **prompt MCP**, não uma tool — clientes
82
89
  > sem suporte de prompts (p.ex. Claude Desktop) não o expõem. Alternativa equivalente: já
83
90
  > leste este guia (via `read_sbd_toe_resource`); passa `risk_level` e os **activadores
84
- > estruturados** (`exposure`, `data_sensitivity`, `stack`, `changed_files`) directamente
85
- > ao `select_sbd_toe_requirements`.
91
+ > DECLARADOS** (`concerns`, `exposure`, `data_sensitivity`, `technologies`, `changed_files`)
92
+ > directamente ao `select_sbd_toe_requirements`. O `stack` é texto livre e só conta quando
93
+ > traz um valor de `technologies` como token exacto — prefere `technologies`.
86
94
 
87
95
  If you do not know the project's risk level, use `map_sbd_toe_applicability` or
88
96
  `list_sbd_toe_chapters` to help the user determine it.
@@ -96,28 +104,40 @@ Use when the user asks *what the manual says*, what applies, how to classify a p
96
104
  what controls or artefacts are required, or whether something is aligned with the manual.
97
105
 
98
106
  ```
99
- search_sbd_toe_manual ← conceptual questions, narrative context
107
+ search_sbd_toe_manual ← NÃO-NORMATIVO: ler e localizar passagens, NUNCA caminho
108
+ para um conjunto de requisitos (o que sai daqui não
109
+ selecciona nada e não se cita como selecção)
100
110
  map_sbd_toe_applicability ← which chapters/controls apply to this project
101
111
  get_sbd_toe_chapter_brief ← what a specific chapter covers (phases, artefacts, topics)
102
112
  list_sbd_toe_chapters ← chapter discovery and navigation
103
113
  query_sbd_toe_entities ← specific controls (CTRL-*), artefacts (ART-*), practices
104
114
 
105
115
  select_sbd_toe_requirements ← MP1 selection: which requirements apply to THIS task in THIS
106
- context — baseline (ch. 02, by level) ∪ context-activated
107
- chapters ⊕ overlay(extend), narrowed by declared task signals;
108
- params: risk_level (required), task?, changed_files?,
109
- technologies?, exposure?, data_sensitivity?, concerns?
110
- returns TWO bands, both always listed:
111
- selected[] — the recommendation for the task (each item
112
- carries its selection_trace: source/trigger/
113
- score, incl. named rules like
114
- R1:principal-nao-humano)
115
- narrowed_out[] — what was ELIGIBLE and why it left (grouped
116
- by category, with reason). Nothing is dropped
117
- silently: if you need something from there,
118
- call again WITH the missing signal (e.g. the
119
- SES group returns when the task mentions the
120
- user session/login/token surface)
116
+ context — baseline (ch. 02, by level) ∪ chapters activated by
117
+ the DECLARED activators ∪ the categories the vocabulary
118
+ promises ⊕ overlay(extend), narrowed by those same
119
+ declarations. The task text is NEVER an activator here;
120
+ params: risk_level (required), concerns?, exposure?,
121
+ data_sensitivity?, technologies?, changed_files?,
122
+ task_context? (recorded, inert), mode? (declarative|baseline|
123
+ discover)
124
+ returns FOUR bands, all always listed:
125
+ selected[] — the answer to what you declared (each
126
+ item carries its selection_trace:
127
+ layer/source/trigger/score, incl.
128
+ named rules like R1:principal-nao-humano
129
+ and declared_category)
130
+ narrowed_out[] — what was ELIGIBLE and why it left
131
+ (grouped by category, with reason)
132
+ excluded_by_level[] — what exists at ANOTHER level (0.15.0)
133
+ out_of_scope_chapters — what NO declaration activated, per
134
+ chapter, with a copyable activate_with
135
+ (0.20.0-beta.24)
136
+ Nothing is dropped silently, and the SCOPE of that promise is
137
+ the universe, not just the baseline: if you need something from
138
+ a band, call again DECLARING what brings it (e.g. the SES group
139
+ returns with technologies=["jwt"], not by mentioning tokens in
140
+ the task text)
121
141
  consult_security_requirements ← deterministic: requirements + controls for a risk level
122
142
  (mode: "index" opt-in returns a per-category id index)
123
143
  params: risk_level (L1|L2|L3), concerns? (string[])
@@ -130,9 +150,9 @@ resolve_entities ← low-level ontology filter engine
130
150
  listing requirements by category, exploring the ontology
131
151
  ```
132
152
 
133
- **Choosing between the three requirement surfaces:** *(ACTIVADORES ESTRUTURADOS primeiro — `task` + `exposure` + `data_sensitivity` + `stack` (+ `changed_files`): qualquer agente os preenche a partir do enunciado, sem léxico — medição da ronda 5: 63 requisitos vs 7 da task sozinha; concerns declarados REFORÇAM e estabilizam vocabulário; a task refina)*
153
+ **Choosing between the three requirement surfaces:** *(DECLARA os activadores do vocabulário fechado — `concerns` + `exposure` + `data_sensitivity` + `technologies` (+ `changed_files`): lês o pedido, o código e a conversa e mapeias para valores publicados. O `task_context` NÃO refina nada no modo declarativo — fica registado para auditoria. Porquê: a mesma feature escrita de cinco maneiras dava de 0 a 58 requisitos quando a prosa decidia; declarada, dá um conjunto, sempre o mesmo.)*
134
154
  - `select_sbd_toe_requirements` — *"which requirements apply to THIS task / this change?"*
135
- Task-scoped recommendation with declared narrowing (two bands, above). Start here for
155
+ Task-scoped recommendation with declared narrowing (the four bands, above). Start here for
136
156
  any concrete piece of work.
137
157
  - `consult_security_requirements` — *"what does the catalogue hold at this level?"*
138
158
  Level-wide, deterministic. `mode: "index"` (opt-in) returns a compact per-category id
@@ -143,30 +163,26 @@ resolve_entities ← low-level ontology filter engine
143
163
 
144
164
  **Prefer `consult_security_requirements` over `search_sbd_toe_manual`** when the question
145
165
  is structured ("what requirements apply at L2?", "which controls are active for auth?").
146
- Use `search_sbd_toe_manual` for narrative/conceptual questions.
147
-
148
- **Output size:** L1 ≈ 22k chars, L2 ≈ 36k chars, L3 ≈ 36k chars (may exceed context).
149
- **Always use `concerns` to scope L2/L3 queries** — reduces to ~9k chars per concern set.
150
-
151
- #### Valid `concerns` values (ontology-controlled vocabulary)
152
-
153
- | concern | Categories resolved | Meaning |
154
- |---|---|---|
155
- | `auth` | AUT, ACC, SES | Authentication, access control, sessions |
156
- | `logging` | LOG | Audit logging, monitoring |
157
- | `validation` | VAL, ERR | Input validation, error handling |
158
- | `api` | API | API security |
159
- | `config` | CFG | Configuration & environment hardening |
160
- | `integrity` | INT | Integrity & integration |
161
- | `distribution` | DST | Supply chain, packaging |
162
- | `ide` | IDE | Development environment |
163
- | `requirements` | REQ | Security requirements in SDLC |
164
- | `architecture` | ARC | Secure architecture |
165
- | `iac` | IAC | Infrastructure-as-Code |
166
- | `encryption` | ENC | Cryptography & sensitive data |
167
- | `agents` | AGN | AI-agent / automation governance — mandate, autonomy A0–A4, kill-switch, intent declaration (`REQ-AGN-001…004`; consult only) |
168
-
169
- Pass concerns as exact lowercase strings from the table above.
166
+ Use `search_sbd_toe_manual` for narrative/conceptual questions — **e nunca para decidir
167
+ âmbito**: é NÃO-NORMATIVO por declaração da própria tool. O conjunto de requisitos vem
168
+ sempre de `select_sbd_toe_requirements` com activadores DECLARADOS.
169
+
170
+ **Output size — medido, não recordado:**
171
+
172
+ <!-- BEGIN GENERATED: output-sizes -->
173
+ <!-- END GENERATED: output-sizes -->
174
+
175
+ #### `concerns` — o vocabulário FECHADO desta linha (derivado do bundle)
176
+
177
+ <!-- BEGIN GENERATED: concerns -->
178
+ <!-- END GENERATED: concerns -->
179
+
180
+ #### Os restantes activadores declaráveis
181
+
182
+ <!-- BEGIN GENERATED: activators -->
183
+ <!-- END GENERATED: activators -->
184
+
185
+
170
186
 
171
187
  ### GUIDE mode
172
188
  Use when the user asks *how to implement, design, structure, document, or review* something
@@ -192,13 +208,10 @@ get_threat_landscape ← deterministic: threats relevant to a risk level
192
208
  use for: threat modelling context, "what threats apply to auth?"
193
209
  ```
194
210
 
195
- #### Valid `role` values for `get_guide_by_role`
196
-
197
- Canonical role IDs (pass exact or common alias — resolved automatically):
211
+ #### `role` — papéis aceites por `get_guide_by_role`
198
212
 
199
- `developer` · `appsec` · `devops` · `grc` · `qa` · `security_champion` · `software_architect`
200
- · `product_owner` · `scrum_master` · `team_lead` · `ciso` · `executive_management`
201
- · `ops` · `compliance` · `auditor` · `ir` · `sre`
213
+ <!-- BEGIN GENERATED: roles -->
214
+ <!-- END GENERATED: roles -->
202
215
 
203
216
  #### Interpreting tool output
204
217
 
@@ -214,8 +227,9 @@ Canonical role IDs (pass exact or common alias — resolved automatically):
214
227
  | `match: "declared_gap"` / `meta.declared_gap` (query_sbd_toe_entities, resolve_entities) | Cite `declared_gap.note` verbatim — a legacy / unresolvable citation, not a missing requirement |
215
228
  | `citation_note` / `meta.citation_note` (informative) | The id is an illustrative example (`REQ-NNN`) or a non-requirement token (`CWE-`, `SHA-`) cited by the Manual — say so; it is not a requirement and not a gap |
216
229
  | `selection.selected[]` (select) | The recommendation for the task — cite each item's `selection_trace` when asked *why* |
230
+ | `selection.out_of_scope_chapters` (select) | O que **nenhuma declaração activou**, por capítulo e por contagem, com `activate_with` copiável. **Não é «não aplicável»** — é não-perguntado: se o capítulo é relevante para a tarefa, re-chama com a declaração indicada. `SEM ACTIVADOR PUBLICADO` significa que o vocabulário não tem forma de o activar — diz-se, não se inventa |
217
231
  | `selection.narrowed_out[]` (select) | Eligible-but-narrowed, grouped with reason — never treat as "not applicable"; re-call with the missing signal to recover a group |
218
- | `completeness_report.selection` (prepare) | The same two-band summary behind the codegen context — `narrowed_out_ref` names the tool to inspect it |
232
+ | `completeness_report.selection` (prepare) | The same band summary behind the codegen context — `narrowed_out_ref` names the tool to inspect it |
219
233
 
220
234
  #### Pattern for complex answers (threat model / security plan / checklist)
221
235
 
@@ -313,13 +327,13 @@ Always distinguish between:
313
327
 
314
328
  | Question | Approach |
315
329
  |---|---|
316
- | "What is X?" / "How does Y work?" | `search_sbd_toe_manual` |
330
+ | "What is X?" / "How does Y work?" | `search_sbd_toe_manual` (NÃO-NORMATIVO — leitura, não selecção) |
317
331
  | "What applies to my project?" | `map_sbd_toe_applicability` → `get_sbd_toe_chapter_brief` |
318
332
  | "What does chapter N cover?" | `get_sbd_toe_chapter_brief` |
319
333
  | "List all chapters" | `list_sbd_toe_chapters` |
320
334
  | "Find control / artefact / practice" | `query_sbd_toe_entities` |
321
335
  | "What requirements apply at L1/L2/L3?" | `consult_security_requirements(risk_level)` |
322
- | "Which requirements apply to THIS task / this change?" | `select_sbd_toe_requirements(risk_level, concerns=[…], exposure?, data_sensitivity?, technologies?, changed_files?)` — **declara** o que a tua leitura justifica (vocabulário: `sbd://toe/activation-vocabulary`); `selected[]` é a resposta ao declarado, `narrowed_out[]` diz o que ficou de fora e porquê. Sem declarações → `needs_input` (com candidatos a confirmar). O `task` é contexto registado, não motor. |
336
+ | "Which requirements apply to THIS task / this change?" | `select_sbd_toe_requirements(risk_level, concerns=[…], exposure?, data_sensitivity?, technologies?, changed_files?)` — **declara** o que a tua leitura justifica (vocabulário: `sbd://toe/activation-vocabulary`); `selected[]` é a resposta ao declarado, `narrowed_out[]` diz o que ficou de fora e porquê. Sem declarações → `needs_input` (com candidatos a confirmar). O `task_context` (antes `task`, alias mantido) é contexto registado, não motor. |
323
337
  | "How do I PROVE these requirements?" | `get_sbd_toe_verification_matrix(risk_level, requirement_ids=[…os selected…])` — o fecho requisito → prova; ids sem EvidencePattern vêm declarados |
324
338
  | "Where is the SOURCE of this requirement?" | `trace_sbd_toe_requirement_sources(requirement_ids)` — directas (autoria) vs cadeia compensada (cobertura, NÃO autoria; rótulo coverage_compensated); sem-fonte declarados |
325
339
  | "Give me a compact id map of the catalogue by category" | `consult_security_requirements(risk_level, mode="index")` |
@@ -342,54 +356,29 @@ Always distinguish between:
342
356
 
343
357
  ## Resources
344
358
 
345
- | Resource URI | When to use |
346
- |---|---|
347
- | `sbd://toe/agent-guide` | This document — full operational guide |
348
- | `sbd://toe/index-compact` | Full chapter map as JSON — fast structured lookup |
349
- | `sbd://toe/chapter-applicability/{riskLevel}` | Graduated applicability: every chapter present, per-chapter demand for the level |
350
- | `sbd://toe/ontology` | Full ontology YAML — domain_mapping, concerns, inference rules |
351
- | `sbd://toe/version` | Server identity + served knowledge provenance (manual/kg/ontology, from the pin) — read at session start |
359
+ <!-- BEGIN GENERATED: resources -->
360
+ <!-- END GENERATED: resources -->
352
361
 
353
362
  ---
354
363
 
355
364
  ## Prompts
356
365
 
357
- | Prompt | When to use |
358
- |---|---|
359
- | `setup_sbd_toe_agent(riskLevel, projectRole)` | Session setup — active chapters + risk-specific rules. **Prompt MCP** (clientes sem prompts: activadores directos no select) |
360
- | `ask_sbd_toe_manual(question)` | Direct grounded Q&A |
366
+ <!-- BEGIN GENERATED: prompts -->
367
+ <!-- END GENERATED: prompts -->
361
368
 
362
369
  ---
363
370
 
364
371
  ## Chapter reference
365
372
 
366
- | chapterId | Title | Min level | Domains |
367
- |---|---|---|---|
368
- | `00-fundamentos` | Fundamentos SbD-ToE | L1 | governance, foundation |
369
- | `01-classificacao-aplicacoes` | Classificação de Aplicações | L1 | governance, risk |
370
- | `02-requisitos-seguranca` | Requisitos de Segurança | L1 | governance, requirements |
371
- | `03-threat-modeling` | Threat Modeling | L1 | risk, architecture |
372
- | `04-arquitetura-segura` | Arquitetura Segura | L1 | architecture, design |
373
- | `05-dependencias-sbom-sca` | Dependências, SBOM e SCA | L1 | supply-chain |
374
- | `06-desenvolvimento-seguro` | Desenvolvimento Seguro | L2 | development, coding |
375
- | `07-cicd-seguro` | CI/CD Seguro | L1 | devops, pipeline |
376
- | `08-iac-infraestrutura` | IaC e Infraestrutura | L1 | infrastructure |
377
- | `09-containers-imagens` | Containers e Imagens | L1 | containers |
378
- | `10-testes-seguranca` | Testes de Segurança | L1 | testing |
379
- | `11-deploy-seguro` | Deploy Seguro | L2 | deploy |
380
- | `12-monitorizacao-operacoes` | Monitorização e Operações | L1 | monitoring |
381
- | `13-formacao-onboarding` | Formação e Onboarding | L3 | training |
382
- | `14-governanca-contratacao` | Governança e Contratação | L1 | governance |
373
+ <!-- BEGIN GENERATED: chapters -->
374
+ <!-- END GENERATED: chapters -->
383
375
 
384
376
  ---
385
377
 
386
378
  ## Risk levels
387
379
 
388
- | Level | Scope | Unlocks |
389
- |---|---|---|
390
- | `L1` | Low risk — internal, no sensitive data | ALL chapters — demand mostly recomendado/opcional |
391
- | `L2` | Medium risk — public APIs, user data | + chapters 06, 11 |
392
- | `L3` | High risk — PII, regulated systems | + chapter 13 |
380
+ <!-- BEGIN GENERATED: risk-levels -->
381
+ <!-- END GENERATED: risk-levels -->
393
382
 
394
383
  ---
395
384
 
package/dist/index.js CHANGED
@@ -38,6 +38,8 @@ const DECLARED_CONCERNS = buildActivationVocabulary().concerns.values.map((c) =>
38
38
  const CONCERNS_VOCABULARY_NOTE = `Conjunto FECHADO de ${DECLARED_CONCERNS.length} valores, gerado do mesmo vocabulário que sbd://toe/activation-vocabulary publica (com o que cada valor activa e quantos requisitos traz por nível). Valores fora do conjunto são DECLARADOS na resposta (unknown_concerns), nunca descartados em silêncio.`;
39
39
  import { buildCodegenInstructionsResourceContent, handlePrepareCodegenContext } from "./tools/prepare-codegen-context.js";
40
40
  import { buildChapterApplicabilityJson, buildGroundedCodegenPrompt, buildSetupAgentPrompt, readGroundedCodegenGuide } from "./resources/sbd-toe-resources.js";
41
+ import { RESOURCE_CATALOG, PROMPT_CATALOG } from "./serving/server-surface.js";
42
+ import { buildAgentGuide } from "./serving/agent-guide.js";
41
43
  const PROTOCOL_VERSION = "2025-03-26";
42
44
  let cachedPackageMetadata;
43
45
  const LOG_LEVELS = [
@@ -70,83 +72,6 @@ function loadPackageMetadata() {
70
72
  };
71
73
  return cachedPackageMetadata;
72
74
  }
73
- /** The single source of the resource surface — resources/list AND the
74
- * read_sbd_toe_resource tool derive from THIS list (never hardcoded twice). */
75
- const RESOURCE_CATALOG = [
76
- {
77
- uri: "sbd://toe/agent-guide",
78
- name: "SbD-ToE Agent Guide",
79
- description: "ENTRY POINT — READ THIS FIRST. Operational guide for AI agents: SbD-ToE identity (Security by Design — Theory of Everything), CONSULT/GUIDE modes, routing by SDLC phase and domain, tool selection, epistemic standards, chapter map, risk levels, identifier conventions.",
80
- mimeType: "text/markdown"
81
- },
82
- {
83
- uri: "sbd://toe/chapter-applicability/{riskLevel}",
84
- name: "SbD-ToE Chapter Applicability",
85
- description: "Graduated chapter applicability for a risk level (L1/L2/L3): presence always, demand scales — derived from authored assignment proportionality (0.14.0).",
86
- mimeType: "application/json"
87
- },
88
- {
89
- uri: "sbd://toe/activation-vocabulary",
90
- name: "SbD-ToE Activation Vocabulary",
91
- description: "DECLARATIVE-FIRST (0.20-beta): the CLOSED vocabulary this server accepts and what each value activates — concerns, exposure, data_sensitivity, technologies, changed_files path table, roles, phases, risk levels. Derived from the served bundle and the engine's own tables, never hand-written. Read it, map your reading of the request onto these values, and DECLARE them: the server answers the declared, it does not interpret prose.",
92
- mimeType: "application/json"
93
- },
94
- {
95
- uri: "sbd://toe/index-compact",
96
- name: "SbD-ToE Index Compact",
97
- description: "Compact JSON index of the manual, DERIVED at read-time from the served bundle (graduated demand_by_level; no minLevel). Injectable into system prompt to eliminate exploratory discovery.",
98
- mimeType: "application/json"
99
- },
100
- {
101
- uri: "sbd://toe/ontology",
102
- name: "SbD-ToE Ontology",
103
- description: "Full SbD-ToE ontology YAML: domain_mapping (requirement category → control domains), " +
104
- "inference rules with priorities, resolution pipelines (consult/guide/threats/review), " +
105
- "and entity schemas. Read once per session to understand the deterministic resolution model " +
106
- "before calling consult_security_requirements, get_threat_landscape or get_guide_by_role.",
107
- mimeType: "application/yaml"
108
- },
109
- {
110
- uri: "sbd://toe/skill/{role}",
111
- name: "SbD-ToE Role Skill",
112
- description: "Role-specialised SbD-ToE skill for a canonical role — RISK LEVEL FIXED AT L2 neste URI; " +
113
- "para outro nível usa generate_sbd_toe_skill(role, risk_level=…). Same output as generate_sbd_toe_skill(role, format=skill).",
114
- mimeType: "text/markdown"
115
- },
116
- {
117
- uri: "sbd://toe/subagent/{role}",
118
- name: "SbD-ToE Role Sub-agent Definition",
119
- description: "Installable sub-agent definition for a canonical role (default risk L2, harnessed flavour — " +
120
- "grants mcp__sbd-toe__* tools). Same output as generate_sbd_toe_skill(role, format=subagent).",
121
- mimeType: "text/markdown"
122
- },
123
- {
124
- uri: "sbd://toe/codegen-instructions/{mode}",
125
- name: "SbD-ToE Codegen Instructions (per mode)",
126
- description: "Static per-mode boilerplate of prepare_sbd_toe_codegen_context (mode: codegen, review or " +
127
- "test-plan): llm_codegen_instructions slots + security_rationale_template skeleton — " +
128
- "byte-identical to the detail=full inline content when assembled per the embedded rules — " +
129
- "plus the detail_encoding legend for detail=standard/minimal payloads (v2 token diet). " +
130
- "Referenced by codegen_instructions_ref in dieted payloads.",
131
- mimeType: "application/json"
132
- },
133
- {
134
- uri: "sbd://toe/version",
135
- name: "SbD-ToE MCP Version",
136
- description: "Version of the running SbD-ToE MCP server (name, version, description) plus the provenance of the served knowledge: manual {version, commit}, kg {release_tag, substrate_version, consumer_contract_version} and ontology {tag, commit}, read from the consumed-bundle pin.",
137
- mimeType: "application/json"
138
- },
139
- {
140
- uri: "sbd://toe/grounded-codegen-guide",
141
- name: "SbD-ToE Grounded Codegen Guide",
142
- description: "Agent-facing guide for using prepare_sbd_toe_codegen_context. " +
143
- "Covers workflow, branching by status (ready_for_codegen / needs_clarification / " +
144
- "needs_decomposition / unsupported_scope), output discipline (cite citation_map, fill " +
145
- "security_rationale, distinguish code/tests/evidence), and explicit prohibitions " +
146
- "(no invented IDs, no compliance claims, no rastreabilidade-noise inside source files).",
147
- mimeType: "text/markdown"
148
- }
149
- ];
150
75
  /** Declared resource-read failure (never-silent): carries the JSON-RPC code. */
151
76
  /**
152
77
  * Materialize any resource of RESOURCE_CATALOG by concrete URI (templated URIs
@@ -195,7 +120,7 @@ async function materializeResource(uri) {
195
120
  }
196
121
  if (uri === "sbd://toe/agent-guide") {
197
122
  try {
198
- return { mimeType: "text/markdown", text: readFileSync(resolveAppPath("assets/agent-guide.md"), "utf-8") };
123
+ return { mimeType: "text/markdown", text: buildAgentGuide() };
199
124
  }
200
125
  catch {
201
126
  throw new ResourceReadError(-32603, "Could not read SbD-ToE agent guide.");
@@ -1035,16 +960,21 @@ class McpRuntime {
1035
960
  title: "Select SbD-ToE Requirements (MP1)",
1036
961
  description: "START HERE — para qualquer tarefa concreta esta é a 1ª tool. Arranque: lê sbd://toe/agent-guide (read_sbd_toe_resource); setup_sbd_toe_agent é um PROMPT MCP — clientes sem prompts (p.ex. Desktop) não o expõem: segue directo por aqui. DECLARATIVO PRIMEIRO (contrato v1.18-beta, linha 0.20): TU tens o contexto — lê o pedido, o código e a conversa e DECLARA o que interpretaste (risk_level, concerns, exposure, data_sensitivity, technologies, changed_files). EU NÃO INTERPRETO PROSA: respondo com o que o KG sabe sobre o declarado, mais as adjacências do grafo, de forma reproduzível. Vocabulário fechado em sbd://toe/activation-vocabulary. O `task` fica REGISTADO para auditoria e NÃO influencia o resultado; sem nenhuma declaração devolvo needs_input com o vocabulário e candidatos A CONFIRMAR (nunca adivinho, nunca devolvo zero em silêncio); a baseline do nível pede-se explicitamente (mode='baseline'); o motor inferencial antigo fica em mode='discover' (exploratório). The MP1 selection operation (Classificar → Seleccionar): which requirements apply to THIS task in THIS " +
1037
962
  "context. Composes the reference semantics the published ontology declares — baseline (cap. 02 base " +
1038
- "catalogue, by risk level) ∪ domain chapters activated by the context (changed_files, technologies, stack, " +
1039
- "task) ⊕ regulatory overlay (extend) — then narrows deterministically by the task's declared signals. " +
1040
- "Returns BOTH bands: selected[] (each with its selection_trace: source/trigger/score) and narrowed_out[] " +
1041
- "(eligible-without-signal, grouped by category, with reason) — never silent. Paginated. " +
963
+ "catalogue, by risk level) ∪ domain chapters activated by the DECLARED activators (concerns, exposure, " +
964
+ "data_sensitivity, technologies, changed_files) ∪ the categories the published vocabulary promises " +
965
+ "⊕ regulatory overlay (extend) — then narrows deterministically by those same declarations. The task " +
966
+ "text is NEVER an activator in declarative mode (it is recorded context; it is only an engine in " +
967
+ "mode='discover'). Returns the bands: selected[] (each with its selection_trace: source/trigger/score), " +
968
+ "narrowed_out[] (eligible-without-signal, grouped by category, with reason), excluded_by_level[] and " +
969
+ "out_of_scope_chapters (what no declaration activated, by chapter and count, with how to bring it in) — " +
970
+ "never silent, and the SCOPE of that promise is the universe, not just the baseline. Paginated. " +
1042
971
  "All data from the published deterministic runtime bundle — nothing is invented.",
1043
972
  inputSchema: {
1044
973
  type: "object",
1045
974
  properties: {
1046
975
  risk_level: { type: "string", enum: ["L1", "L2", "L3"], description: "Application risk level (drives the baseline)." },
1047
- task: { type: "string", description: "RECORDED CONTEXT (auditoria): o enunciado da tarefa. NÃO influencia a selecção no modo declarativo — o servidor não interpreta prosa. Só é motor em mode='discover'." },
976
+ task_context: { type: "string", description: "CONTEXTO REGISTADO (auditoria): o enunciado da tarefa. NOME CANÓNICO desde 0.20.0-beta.24 — um campo chamado `task` convidava a ser o motor, e não é: NÃO influencia a selecção no modo declarativo. Alias `task` continua aceite (aditivo, nunca renomeámos nada); em mode='discover' o texto é motor e `task` é o nome a usar." },
977
+ task: { type: "string", description: "ALIAS de `task_context` (compatibilidade). Em mode='discover' é o MOTOR (casamento lexical, exploratório); no modo declarativo é apenas contexto registado." },
1048
978
  mode: { type: "string", enum: ["declarative", "baseline", "discover"], description: "declarative (default): responde ao DECLARADO; sem declarações devolve needs_input com vocabulário e candidatos a confirmar. baseline: baseline completa do nível, por pedido EXPLÍCITO (nunca fallback). discover: motor inferencial histórico (casamento lexical da prosa), exploratório — investigação e estudo de paráfrase." },
1049
979
  stack: { type: "string", description: "Texto livre da stack. No modo declarativo só conta quando traz, como TOKEN EXACTO, um valor de `technologies` (normalizar o declarado é legítimo; adivinhar prosa não). Preferir `technologies`." },
1050
980
  exposure: { type: "string", enum: ["local", "internal", "authenticated", "public"], description: "Declared activator: authenticated/public activate auth+logging (+api/validation/architecture for public)." },
@@ -1437,88 +1367,10 @@ class McpRuntime {
1437
1367
  });
1438
1368
  }
1439
1369
  getPromptDefinition() {
1440
- return {
1441
- name: "ask_sbd_toe_manual",
1442
- title: "Ask SbD-ToE Manual",
1443
- description: "MCP prompt to guide the AI chat to answer questions about the SbD-ToE manual with grounding.",
1444
- arguments: [
1445
- {
1446
- name: "question",
1447
- description: "Question about the SbD-ToE manual.",
1448
- required: true
1449
- }
1450
- ]
1451
- };
1370
+ return PROMPT_CATALOG[0];
1452
1371
  }
1453
1372
  handlePromptsList(request) {
1454
- this.sendResponse(request.id, {
1455
- prompts: [
1456
- this.getPromptDefinition(),
1457
- {
1458
- name: "setup_sbd_toe_agent",
1459
- title: "Setup SbD-ToE Agent",
1460
- description: "START HERE — entry point (2ª chamada, após leres sbd://toe/agent-guide): MCP PROMPT (clientes sem suporte de prompts não o expõem — alternativa: activadores estruturados directos no select) to configure an agent with SbD-ToE manual context and rules for a given risk level.",
1461
- arguments: [
1462
- {
1463
- name: "riskLevel",
1464
- description: "Project risk level: L1, L2 or L3.",
1465
- required: true
1466
- },
1467
- {
1468
- name: "projectRole",
1469
- description: "Project role or description (optional).",
1470
- required: false
1471
- }
1472
- ]
1473
- },
1474
- {
1475
- name: "prepare_grounded_codegen",
1476
- title: "Prepare Grounded Codegen (SbD-ToE)",
1477
- description: "MCP prompt that bundles the grounded-codegen guide with a user task and instructs the " +
1478
- "agent to call prepare_sbd_toe_codegen_context before producing code. Forces citation of " +
1479
- "citation_map IDs, fills security_rationale_template, distinguishes code/tests/evidence, " +
1480
- "blocks compliance claims, and routes needs_clarification / needs_decomposition / " +
1481
- "unsupported_scope to user dialog instead of silent guessing.",
1482
- arguments: [
1483
- {
1484
- name: "task",
1485
- description: "Concrete coding task (e.g. 'Add payload validation to PATCH /users/:id/email').",
1486
- required: true
1487
- },
1488
- {
1489
- name: "mode",
1490
- description: "codegen | review | test-plan. Defaults to codegen.",
1491
- required: false
1492
- },
1493
- {
1494
- name: "riskLevel",
1495
- description: "Project risk level: L1, L2 or L3.",
1496
- required: false
1497
- },
1498
- {
1499
- name: "concerns",
1500
- description: "Optional explicit concerns (comma-separated string or array). Otherwise inferred by the activation engine.",
1501
- required: false
1502
- },
1503
- {
1504
- name: "stack",
1505
- description: "Stack hint (e.g. 'Node.js/Express'). Informational.",
1506
- required: false
1507
- },
1508
- {
1509
- name: "regulatoryFrameworks",
1510
- description: "Optional regulatory framework short codes or IDs (e.g. 'GDPR', 'EXT-DORA'). Comma-separated string or array.",
1511
- required: false
1512
- },
1513
- {
1514
- name: "includeRegulatoryOverlay",
1515
- description: "When true, asks the tool to surface regulatory overlay context.",
1516
- required: false
1517
- }
1518
- ]
1519
- }
1520
- ]
1521
- });
1373
+ this.sendResponse(request.id, { prompts: [...PROMPT_CATALOG] });
1522
1374
  }
1523
1375
  handlePromptGet(request) {
1524
1376
  const name = typeof request.params?.name === "string" ? request.params.name : "";