@zivis/mcp 0.1.0-alpha.26 → 0.1.0-alpha.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/dist/api-client.d.ts +24 -1
- package/dist/api-client.js +52 -29
- package/dist/api-client.js.map +1 -0
- package/dist/auth/index.d.ts +22 -1
- package/dist/auth/index.js +38 -17
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/jwt.d.ts +16 -0
- package/dist/auth/jwt.js +13 -0
- package/dist/auth/jwt.js.map +1 -0
- package/dist/auth/keychain.d.ts +32 -6
- package/dist/auth/keychain.js +114 -83
- package/dist/auth/keychain.js.map +1 -0
- package/dist/auth/oauth.d.ts +37 -2
- package/dist/auth/oauth.js +48 -38
- package/dist/auth/oauth.js.map +1 -0
- package/dist/auth/sessions.d.ts +25 -5
- package/dist/auth/sessions.js +39 -20
- package/dist/auth/sessions.js.map +1 -0
- package/dist/auth/token-refresh.d.ts +22 -2
- package/dist/auth/token-refresh.js +35 -32
- package/dist/auth/token-refresh.js.map +1 -0
- package/dist/cli.d.ts +18 -1
- package/dist/cli.js +908 -30
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/project-binding.d.ts +19 -2
- package/dist/project-binding.js +21 -38
- package/dist/project-binding.js.map +1 -0
- package/dist/resolve-application-id.d.ts +4 -0
- package/dist/resolve-application-id.js +5 -0
- package/dist/resolve-application-id.js.map +1 -0
- package/dist/sanitize.d.ts +21 -0
- package/dist/sanitize.js +41 -0
- package/dist/sanitize.js.map +1 -0
- package/dist/server.d.ts +13 -1
- package/dist/server.js +247 -122
- package/dist/server.js.map +1 -0
- package/dist/tools/check-project.d.ts +18 -5
- package/dist/tools/check-project.js +110 -122
- package/dist/tools/check-project.js.map +1 -0
- package/dist/tools/check-repo-trust.d.ts +19 -4
- package/dist/tools/check-repo-trust.js +47 -56
- package/dist/tools/check-repo-trust.js.map +1 -0
- package/dist/tools/create-diagram.d.ts +5 -0
- package/dist/tools/create-diagram.js +10 -0
- package/dist/tools/create-diagram.js.map +1 -0
- package/dist/tools/create-document.d.ts +5 -0
- package/dist/tools/create-document.js +6 -0
- package/dist/tools/create-document.js.map +1 -0
- package/dist/tools/discover-local-infra.d.ts +10 -0
- package/dist/tools/discover-local-infra.js +73 -3
- package/dist/tools/discover-local-infra.js.map +1 -0
- package/dist/tools/enterprise/capture-evidence.d.ts +54 -0
- package/dist/tools/enterprise/capture-evidence.js +72 -0
- package/dist/tools/enterprise/capture-evidence.js.map +1 -0
- package/dist/tools/enterprise/create-report-ticket.d.ts +34 -0
- package/dist/tools/enterprise/create-report-ticket.js +44 -0
- package/dist/tools/enterprise/create-report-ticket.js.map +1 -0
- package/dist/tools/enterprise/end-pentest-session.d.ts +33 -0
- package/dist/tools/enterprise/end-pentest-session.js +42 -0
- package/dist/tools/enterprise/end-pentest-session.js.map +1 -0
- package/dist/tools/enterprise/generate-report.d.ts +55 -0
- package/dist/tools/enterprise/generate-report.js +111 -0
- package/dist/tools/enterprise/generate-report.js.map +1 -0
- package/dist/tools/enterprise/get-org-zat.d.ts +5 -0
- package/dist/tools/enterprise/get-org-zat.js +6 -0
- package/dist/tools/enterprise/get-org-zat.js.map +1 -0
- package/dist/tools/enterprise/get-report-status.d.ts +27 -0
- package/dist/tools/enterprise/get-report-status.js +38 -0
- package/dist/tools/enterprise/get-report-status.js.map +1 -0
- package/dist/tools/enterprise/get-threat-model.d.ts +6 -1
- package/dist/tools/enterprise/get-threat-model.js +17 -52
- package/dist/tools/enterprise/get-threat-model.js.map +1 -0
- package/dist/tools/enterprise/list-agents.d.ts +42 -0
- package/dist/tools/enterprise/list-agents.js +95 -0
- package/dist/tools/enterprise/list-agents.js.map +1 -0
- package/dist/tools/enterprise/list-report-issues.d.ts +36 -0
- package/dist/tools/enterprise/list-report-issues.js +50 -0
- package/dist/tools/enterprise/list-report-issues.js.map +1 -0
- package/dist/tools/enterprise/list-threat-models.d.ts +5 -0
- package/dist/tools/enterprise/list-threat-models.js +8 -0
- package/dist/tools/enterprise/list-threat-models.js.map +1 -0
- package/dist/tools/enterprise/manage-actor.d.ts +6 -1
- package/dist/tools/enterprise/manage-actor.js +7 -14
- package/dist/tools/enterprise/manage-actor.js.map +1 -0
- package/dist/tools/enterprise/manage-attack-scenario.d.ts +6 -1
- package/dist/tools/enterprise/manage-attack-scenario.js +7 -13
- package/dist/tools/enterprise/manage-attack-scenario.js.map +1 -0
- package/dist/tools/enterprise/manage-component.d.ts +6 -1
- package/dist/tools/enterprise/manage-component.js +7 -20
- package/dist/tools/enterprise/manage-component.js.map +1 -0
- package/dist/tools/enterprise/manage-data-asset.d.ts +7 -2
- package/dist/tools/enterprise/manage-data-asset.js +7 -17
- package/dist/tools/enterprise/manage-data-asset.js.map +1 -0
- package/dist/tools/enterprise/manage-data-flow.d.ts +7 -2
- package/dist/tools/enterprise/manage-data-flow.js +7 -19
- package/dist/tools/enterprise/manage-data-flow.js.map +1 -0
- package/dist/tools/enterprise/manage-finding.d.ts +69 -0
- package/dist/tools/enterprise/manage-finding.js +106 -0
- package/dist/tools/enterprise/manage-finding.js.map +1 -0
- package/dist/tools/enterprise/manage-security-control.d.ts +6 -1
- package/dist/tools/enterprise/manage-security-control.js +7 -18
- package/dist/tools/enterprise/manage-security-control.js.map +1 -0
- package/dist/tools/enterprise/manage-test-case.d.ts +7 -2
- package/dist/tools/enterprise/manage-test-case.js +6 -8
- package/dist/tools/enterprise/manage-test-case.js.map +1 -0
- package/dist/tools/enterprise/promote-finding-to-issue.d.ts +36 -0
- package/dist/tools/enterprise/promote-finding-to-issue.js +65 -0
- package/dist/tools/enterprise/promote-finding-to-issue.js.map +1 -0
- package/dist/tools/enterprise/publish-report-version.d.ts +34 -0
- package/dist/tools/enterprise/publish-report-version.js +75 -0
- package/dist/tools/enterprise/publish-report-version.js.map +1 -0
- package/dist/tools/enterprise/publish-test-to-library.d.ts +31 -0
- package/dist/tools/enterprise/publish-test-to-library.js +40 -0
- package/dist/tools/enterprise/publish-test-to-library.js.map +1 -0
- package/dist/tools/enterprise/record-test-result.d.ts +67 -0
- package/dist/tools/enterprise/record-test-result.js +75 -0
- package/dist/tools/enterprise/record-test-result.js.map +1 -0
- package/dist/tools/enterprise/start-pentest-session.d.ts +35 -0
- package/dist/tools/enterprise/start-pentest-session.js +50 -0
- package/dist/tools/enterprise/start-pentest-session.js.map +1 -0
- package/dist/tools/enterprise/sync-report-section.d.ts +41 -0
- package/dist/tools/enterprise/sync-report-section.js +79 -0
- package/dist/tools/enterprise/sync-report-section.js.map +1 -0
- package/dist/tools/enterprise/update-report-issue.d.ts +55 -0
- package/dist/tools/enterprise/update-report-issue.js +69 -0
- package/dist/tools/enterprise/update-report-issue.js.map +1 -0
- package/dist/tools/generate-diagram.d.ts +6 -0
- package/dist/tools/generate-diagram.js +9 -0
- package/dist/tools/generate-diagram.js.map +1 -0
- package/dist/tools/get-agent-test-results.d.ts +41 -0
- package/dist/tools/get-agent-test-results.js +86 -0
- package/dist/tools/get-agent-test-results.js.map +1 -0
- package/dist/tools/get-application-overview.d.ts +5 -0
- package/dist/tools/get-application-overview.js +6 -0
- package/dist/tools/get-application-overview.js.map +1 -0
- package/dist/tools/get-application.d.ts +5 -0
- package/dist/tools/get-application.js +6 -0
- package/dist/tools/get-application.js.map +1 -0
- package/dist/tools/get-artifact-content.d.ts +29 -0
- package/dist/tools/get-artifact-content.js +86 -0
- package/dist/tools/get-artifact-content.js.map +1 -0
- package/dist/tools/get-diagram.d.ts +5 -0
- package/dist/tools/get-diagram.js +11 -1
- package/dist/tools/get-diagram.js.map +1 -0
- package/dist/tools/get-document.d.ts +5 -0
- package/dist/tools/get-document.js +6 -0
- package/dist/tools/get-document.js.map +1 -0
- package/dist/tools/get-finding-details.d.ts +28 -0
- package/dist/tools/get-finding-details.js +43 -0
- package/dist/tools/get-finding-details.js.map +1 -0
- package/dist/tools/get-findings.d.ts +57 -0
- package/dist/tools/get-findings.js +103 -0
- package/dist/tools/get-findings.js.map +1 -0
- package/dist/tools/get-oss-zat.d.ts +5 -0
- package/dist/tools/get-oss-zat.js +7 -0
- package/dist/tools/get-oss-zat.js.map +1 -0
- package/dist/tools/get-recon-scan.d.ts +27 -0
- package/dist/tools/get-recon-scan.js +46 -0
- package/dist/tools/get-recon-scan.js.map +1 -0
- package/dist/tools/get-scan-output.d.ts +27 -0
- package/dist/tools/get-scan-output.js +64 -0
- package/dist/tools/get-scan-output.js.map +1 -0
- package/dist/tools/get-scenario-details.d.ts +27 -0
- package/dist/tools/get-scenario-details.js +46 -0
- package/dist/tools/get-scenario-details.js.map +1 -0
- package/dist/tools/get-test-case-results.d.ts +37 -0
- package/dist/tools/get-test-case-results.js +66 -0
- package/dist/tools/get-test-case-results.js.map +1 -0
- package/dist/tools/get-test-details.d.ts +29 -0
- package/dist/tools/get-test-details.js +49 -0
- package/dist/tools/get-test-details.js.map +1 -0
- package/dist/tools/get-trust-keys.d.ts +5 -0
- package/dist/tools/get-trust-keys.js +6 -0
- package/dist/tools/get-trust-keys.js.map +1 -0
- package/dist/tools/import-openapi-endpoints.d.ts +5 -0
- package/dist/tools/import-openapi-endpoints.js +6 -0
- package/dist/tools/import-openapi-endpoints.js.map +1 -0
- package/dist/tools/inspect-zat.d.ts +5 -0
- package/dist/tools/inspect-zat.js +19 -0
- package/dist/tools/inspect-zat.js.map +1 -0
- package/dist/tools/list-agent-test-cases.d.ts +41 -0
- package/dist/tools/list-agent-test-cases.js +73 -0
- package/dist/tools/list-agent-test-cases.js.map +1 -0
- package/dist/tools/list-applications.d.ts +6 -1
- package/dist/tools/list-applications.js +6 -0
- package/dist/tools/list-applications.js.map +1 -0
- package/dist/tools/list-diagrams.d.ts +5 -0
- package/dist/tools/list-diagrams.js +6 -0
- package/dist/tools/list-diagrams.js.map +1 -0
- package/dist/tools/list-documents.d.ts +5 -0
- package/dist/tools/list-documents.js +6 -0
- package/dist/tools/list-documents.js.map +1 -0
- package/dist/tools/list-endpoints.d.ts +5 -0
- package/dist/tools/list-endpoints.js +6 -0
- package/dist/tools/list-endpoints.js.map +1 -0
- package/dist/tools/list-recon-scans.d.ts +36 -0
- package/dist/tools/list-recon-scans.js +74 -0
- package/dist/tools/list-recon-scans.js.map +1 -0
- package/dist/tools/list-scan-artifacts.d.ts +41 -0
- package/dist/tools/list-scan-artifacts.js +63 -0
- package/dist/tools/list-scan-artifacts.js.map +1 -0
- package/dist/tools/list-scans.d.ts +44 -0
- package/dist/tools/list-scans.js +91 -0
- package/dist/tools/list-scans.js.map +1 -0
- package/dist/tools/list-test-library.d.ts +44 -0
- package/dist/tools/list-test-library.js +83 -0
- package/dist/tools/list-test-library.js.map +1 -0
- package/dist/tools/list-test-scenarios.d.ts +31 -0
- package/dist/tools/list-test-scenarios.js +66 -0
- package/dist/tools/list-test-scenarios.js.map +1 -0
- package/dist/tools/local-scan.d.ts +40 -0
- package/dist/tools/local-scan.js +261 -0
- package/dist/tools/local-scan.js.map +1 -0
- package/dist/tools/manage-diagram.d.ts +5 -0
- package/dist/tools/manage-diagram.js +16 -0
- package/dist/tools/manage-diagram.js.map +1 -0
- package/dist/tools/open-in-ide.d.ts +13 -1
- package/dist/tools/open-in-ide.js +13 -0
- package/dist/tools/open-in-ide.js.map +1 -0
- package/dist/tools/run-test-scenario.d.ts +37 -0
- package/dist/tools/run-test-scenario.js +70 -0
- package/dist/tools/run-test-scenario.js.map +1 -0
- package/dist/tools/scan-pr.d.ts +27 -0
- package/dist/tools/scan-pr.js +51 -0
- package/dist/tools/scan-pr.js.map +1 -0
- package/dist/tools/security-review.d.ts +16 -0
- package/dist/tools/security-review.js +77 -63
- package/dist/tools/security-review.js.map +1 -0
- package/dist/tools/setup-red-team-target.d.ts +79 -0
- package/dist/tools/setup-red-team-target.js +430 -0
- package/dist/tools/setup-red-team-target.js.map +1 -0
- package/dist/tools/triage-finding.d.ts +47 -0
- package/dist/tools/triage-finding.js +116 -0
- package/dist/tools/triage-finding.js.map +1 -0
- package/dist/tools/update-document.d.ts +5 -0
- package/dist/tools/update-document.js +6 -0
- package/dist/tools/update-document.js.map +1 -0
- package/dist/tools/update-endpoint.d.ts +5 -0
- package/dist/tools/update-endpoint.js +7 -0
- package/dist/tools/update-endpoint.js.map +1 -0
- package/dist/tools/update-mermaid-source.d.ts +13 -0
- package/dist/tools/update-mermaid-source.js +14 -0
- package/dist/tools/update-mermaid-source.js.map +1 -0
- package/dist/tools/verify-trust-mark.d.ts +5 -0
- package/dist/tools/verify-trust-mark.js +6 -0
- package/dist/tools/verify-trust-mark.js.map +1 -0
- package/dist/types.d.ts +14 -14
- package/dist/types.js +28 -22
- package/dist/types.js.map +1 -0
- package/package.json +4 -24
- package/LICENSE +0 -201
- package/README.md +0 -19
- package/dist/lib/inspect-cache.d.ts +0 -10
- package/dist/lib/inspect-cache.js +0 -75
- package/dist/lib/next-steps.d.ts +0 -27
- package/dist/lib/next-steps.js +0 -21
- package/dist/matcher/ast-eval.d.ts +0 -8
- package/dist/matcher/ast-eval.js +0 -95
- package/dist/matcher/finding.d.ts +0 -55
- package/dist/matcher/finding.js +0 -1
- package/dist/matcher/index.d.ts +0 -8
- package/dist/matcher/index.js +0 -202
- package/dist/matcher/inference-candidates.d.ts +0 -26
- package/dist/matcher/inference-candidates.js +0 -81
- package/dist/matcher/walker.d.ts +0 -7
- package/dist/matcher/walker.js +0 -71
- package/dist/pattern-pack/index.d.ts +0 -125
- package/dist/pattern-pack/index.js +0 -189
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/agents/privilege-separation.yaml +0 -224
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/prompting/self-consistency-no-isolation.yaml +0 -237
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/retrieval/context-injection-no-validator.yaml +0 -348
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/security/late-org-filter.yaml +0 -266
- package/dist/pattern-packs/zivis-public-0.2.0/controls/external_validator_on_facts.yaml +0 -37
- package/dist/pattern-packs/zivis-public-0.2.0/controls/fact_validator_present.yaml +0 -68
- package/dist/pattern-packs/zivis-public-0.2.0/controls/human_approval_gate.yaml +0 -44
- package/dist/pattern-packs/zivis-public-0.2.0/controls/langgraph_state_machine_with_per_node_tools.yaml +0 -35
- package/dist/pattern-packs/zivis-public-0.2.0/controls/per_sample_retrieval_diversification.yaml +0 -38
- package/dist/pattern-packs/zivis-public-0.2.0/controls/prisma_extension_or_middleware_attaching_org_filter.yaml +0 -31
- package/dist/pattern-packs/zivis-public-0.2.0/controls/row_level_security_policy.yaml +0 -37
- package/dist/pattern-packs/zivis-public-0.2.0/controls/source_attribution_present.yaml +0 -58
- package/dist/pattern-packs/zivis-public-0.2.0/manifest.json +0 -167
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/agents/privilege-separation/identify.md +0 -54
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/prompting/self-consistency-no-isolation/identify.md +0 -60
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/retrieval/context-injection-no-validator/identify.md +0 -109
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/security/late-org-filter/identify.md +0 -78
- package/dist/prompts/audit-dependencies.d.ts +0 -2
- package/dist/prompts/audit-dependencies.js +0 -47
- package/dist/prompts/getting-started.d.ts +0 -2
- package/dist/prompts/getting-started.js +0 -37
- package/dist/prompts/index.d.ts +0 -2
- package/dist/prompts/index.js +0 -6
- package/dist/tools/enterprise/get-threat-model-artifact.d.ts +0 -24
- package/dist/tools/enterprise/get-threat-model-artifact.js +0 -68
- package/dist/tools/enterprise/list-attack-scenarios.d.ts +0 -24
- package/dist/tools/enterprise/list-attack-scenarios.js +0 -63
- package/dist/tools/enterprise/list-attack-step-library-tests.d.ts +0 -24
- package/dist/tools/enterprise/list-attack-step-library-tests.js +0 -55
- package/dist/tools/enterprise/list-threat-model-artifacts.d.ts +0 -55
- package/dist/tools/enterprise/list-threat-model-artifacts.js +0 -108
- package/dist/tools/enterprise/list-threat-model-review-items.d.ts +0 -30
- package/dist/tools/enterprise/list-threat-model-review-items.js +0 -54
- package/dist/tools/enterprise/list-threat-model-versions.d.ts +0 -24
- package/dist/tools/enterprise/list-threat-model-versions.js +0 -54
- package/dist/tools/enterprise/manage-threat-model-analysis.d.ts +0 -44
- package/dist/tools/enterprise/manage-threat-model-analysis.js +0 -83
- package/dist/tools/enterprise/manage-threat-model-review.d.ts +0 -38
- package/dist/tools/enterprise/manage-threat-model-review.js +0 -72
- package/dist/tools/get-started.d.ts +0 -18
- package/dist/tools/get-started.js +0 -470
- package/dist/tools/inspect.d.ts +0 -21
- package/dist/tools/inspect.js +0 -222
- package/dist/tools/manage-application.d.ts +0 -64
- package/dist/tools/manage-application.js +0 -129
- package/dist/tools/manage-endpoint-lifecycle.d.ts +0 -80
- package/dist/tools/manage-endpoint-lifecycle.js +0 -180
- package/dist/tools/threat-get-capsule.d.ts +0 -15
- package/dist/tools/threat-get-capsule.js +0 -53
- package/dist/tools/threat-get-inference-prompt.d.ts +0 -15
- package/dist/tools/threat-get-inference-prompt.js +0 -73
- package/dist/tools/threat-guide.d.ts +0 -28
- package/dist/tools/threat-guide.js +0 -175
- package/dist/tools/threat-list-relevant-capsules.d.ts +0 -17
- package/dist/tools/threat-list-relevant-capsules.js +0 -158
- package/dist/tools/threat-run-matcher.d.ts +0 -17
- package/dist/tools/threat-run-matcher.js +0 -145
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const THREAT_GET_CAPSULE_NAME = "zivis_threat_get_capsule";
|
|
3
|
-
export declare const THREAT_GET_CAPSULE_DESCRIPTION = "Return the full capsule for a single threat-model pattern.\n\nUse after zivis_threat_list_relevant_capsules has surfaced an id the user wants to dig into. The capsule includes:\n- safe_summary, detect_when, risk_hints, architectural_signals \u2014 for explaining the pattern in threat-model language\n- threats[] with STRIDE categories and remediations \u2014 for grounding the conversation in component/flow/boundary terms\n- repair_contract.allowed / forbidden \u2014 what refactors are safe\n- related_patterns \u2014 adjacent ids in the library\n- model_task_prompt_ref \u2014 pass to zivis_threat_get_inference_prompt to get the prompt the host LLM should run for a deeper check\n\nCapsule data is read from the local pack (~/Library/Caches/zivis/pattern-packs/) with SHA256 integrity verification on every read.";
|
|
4
|
-
export declare const THREAT_GET_CAPSULE_SCHEMA: {
|
|
5
|
-
capsule_id: z.ZodString;
|
|
6
|
-
};
|
|
7
|
-
export declare function createThreatGetCapsuleHandler(): (params: {
|
|
8
|
-
capsule_id: string;
|
|
9
|
-
}) => Promise<{
|
|
10
|
-
content: Array<{
|
|
11
|
-
type: "text";
|
|
12
|
-
text: string;
|
|
13
|
-
}>;
|
|
14
|
-
isError?: boolean;
|
|
15
|
-
}>;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { loadActivePack, getCapsule, listCapsuleIds } from "../pattern-pack/index.js";
|
|
3
|
-
import { withNextSteps, withNextStepsError } from "../lib/next-steps.js";
|
|
4
|
-
export const THREAT_GET_CAPSULE_NAME = "zivis_threat_get_capsule";
|
|
5
|
-
export const THREAT_GET_CAPSULE_DESCRIPTION = `Return the full capsule for a single threat-model pattern.
|
|
6
|
-
|
|
7
|
-
Use after zivis_threat_list_relevant_capsules has surfaced an id the user wants to dig into. The capsule includes:
|
|
8
|
-
- safe_summary, detect_when, risk_hints, architectural_signals — for explaining the pattern in threat-model language
|
|
9
|
-
- threats[] with STRIDE categories and remediations — for grounding the conversation in component/flow/boundary terms
|
|
10
|
-
- repair_contract.allowed / forbidden — what refactors are safe
|
|
11
|
-
- related_patterns — adjacent ids in the library
|
|
12
|
-
- model_task_prompt_ref — pass to zivis_threat_get_inference_prompt to get the prompt the host LLM should run for a deeper check
|
|
13
|
-
|
|
14
|
-
Capsule data is read from the local pack (~/Library/Caches/zivis/pattern-packs/) with SHA256 integrity verification on every read.`;
|
|
15
|
-
export const THREAT_GET_CAPSULE_SCHEMA = {
|
|
16
|
-
capsule_id: z
|
|
17
|
-
.string()
|
|
18
|
-
.describe("Capsule id, e.g. 'agents.privilege-separation'. Discoverable via zivis_threat_list_relevant_capsules."),
|
|
19
|
-
};
|
|
20
|
-
export function createThreatGetCapsuleHandler() {
|
|
21
|
-
return async (params) => {
|
|
22
|
-
const handle = await loadActivePack();
|
|
23
|
-
let capsule;
|
|
24
|
-
try {
|
|
25
|
-
capsule = await getCapsule(handle, params.capsule_id);
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
const ids = await listCapsuleIds(handle);
|
|
29
|
-
return withNextStepsError(`Capsule '${params.capsule_id}' not found in pack ${handle.manifest.pack_id}@${handle.manifest.version}. ${err.message}`, [
|
|
30
|
-
{
|
|
31
|
-
id: "list_relevant_capsules_first",
|
|
32
|
-
label: "Find relevant capsules for the current repo first",
|
|
33
|
-
tool: "zivis_threat_list_relevant_capsules",
|
|
34
|
-
why: "Returns ids you can pass back into zivis_threat_get_capsule.",
|
|
35
|
-
},
|
|
36
|
-
], `Available capsule ids in this pack: ${ids.join(", ")}`);
|
|
37
|
-
}
|
|
38
|
-
return withNextSteps({
|
|
39
|
-
pack: { id: handle.manifest.pack_id, version: handle.manifest.version },
|
|
40
|
-
capsule,
|
|
41
|
-
}, capsule.model_task_prompt_ref
|
|
42
|
-
? [
|
|
43
|
-
{
|
|
44
|
-
id: "get_inference_prompt",
|
|
45
|
-
label: "Get the inference prompt template the host LLM should run",
|
|
46
|
-
tool: "zivis_threat_get_inference_prompt",
|
|
47
|
-
args_hint: { capsule_id: capsule.id },
|
|
48
|
-
why: "Inference prompt + expected_output_schema together form the prompt bundle the IDE LLM executes.",
|
|
49
|
-
},
|
|
50
|
-
]
|
|
51
|
-
: [], `Capsule ${capsule.id}@${capsule.version} (${capsule.lifecycle}, ${capsule.sensitivity_level ?? "unspecified-tier"}). Threats: ${(capsule.threats?.length ?? 0)}.`);
|
|
52
|
-
};
|
|
53
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const THREAT_GET_INFERENCE_PROMPT_NAME = "zivis_threat_get_inference_prompt";
|
|
3
|
-
export declare const THREAT_GET_INFERENCE_PROMPT_DESCRIPTION = "Return the prompt bundle for the host LLM to run local inference for a capsule.\n\nZIVIS doesn't run an LLM itself \u2014 the host (Cursor, Claude Code, etc.) does. This tool returns the prompt template + structured output schema + ambient capsule context so the host model can run the inference and produce JSON the inferred lane accepts.\n\nUse this when:\n- After zivis_threat_get_capsule, the user wants the host LLM to actually evaluate whether the pattern is present in the code\n- The user says \"go check if my code does this\" / \"is this pattern actually in my repo\"\n- The matcher emits an INFER candidate that needs host-LLM evaluation\n\nThe bundle includes:\n- prompt: the markdown inference prompt\n- expected_output_schema: JSON Schema for the structured response\n- safe_summary: ambient capsule context\n- minimum_context_required: hint to the host for how much code to attach\n- evidence_focus: spans the deterministic strategies already flagged\n\nThe host LLM is expected to gather the indicated code spans, fill in the prompt, return JSON matching the schema. That output then flows back into the inferred lane.";
|
|
4
|
-
export declare const THREAT_GET_INFERENCE_PROMPT_SCHEMA: {
|
|
5
|
-
capsule_id: z.ZodString;
|
|
6
|
-
};
|
|
7
|
-
export declare function createThreatGetInferencePromptHandler(): (params: {
|
|
8
|
-
capsule_id: string;
|
|
9
|
-
}) => Promise<{
|
|
10
|
-
content: Array<{
|
|
11
|
-
type: "text";
|
|
12
|
-
text: string;
|
|
13
|
-
}>;
|
|
14
|
-
isError?: boolean;
|
|
15
|
-
}>;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { loadActivePack, getCapsule, getInferencePrompt } from "../pattern-pack/index.js";
|
|
3
|
-
import { withNextSteps, withNextStepsError } from "../lib/next-steps.js";
|
|
4
|
-
export const THREAT_GET_INFERENCE_PROMPT_NAME = "zivis_threat_get_inference_prompt";
|
|
5
|
-
export const THREAT_GET_INFERENCE_PROMPT_DESCRIPTION = `Return the prompt bundle for the host LLM to run local inference for a capsule.
|
|
6
|
-
|
|
7
|
-
ZIVIS doesn't run an LLM itself — the host (Cursor, Claude Code, etc.) does. This tool returns the prompt template + structured output schema + ambient capsule context so the host model can run the inference and produce JSON the inferred lane accepts.
|
|
8
|
-
|
|
9
|
-
Use this when:
|
|
10
|
-
- After zivis_threat_get_capsule, the user wants the host LLM to actually evaluate whether the pattern is present in the code
|
|
11
|
-
- The user says "go check if my code does this" / "is this pattern actually in my repo"
|
|
12
|
-
- The matcher emits an INFER candidate that needs host-LLM evaluation
|
|
13
|
-
|
|
14
|
-
The bundle includes:
|
|
15
|
-
- prompt: the markdown inference prompt
|
|
16
|
-
- expected_output_schema: JSON Schema for the structured response
|
|
17
|
-
- safe_summary: ambient capsule context
|
|
18
|
-
- minimum_context_required: hint to the host for how much code to attach
|
|
19
|
-
- evidence_focus: spans the deterministic strategies already flagged
|
|
20
|
-
|
|
21
|
-
The host LLM is expected to gather the indicated code spans, fill in the prompt, return JSON matching the schema. That output then flows back into the inferred lane.`;
|
|
22
|
-
export const THREAT_GET_INFERENCE_PROMPT_SCHEMA = {
|
|
23
|
-
capsule_id: z
|
|
24
|
-
.string()
|
|
25
|
-
.describe("Capsule id whose INFER prompt should be returned (e.g. 'agents.privilege-separation')."),
|
|
26
|
-
};
|
|
27
|
-
export function createThreatGetInferencePromptHandler() {
|
|
28
|
-
return async (params) => {
|
|
29
|
-
const handle = await loadActivePack();
|
|
30
|
-
let capsule;
|
|
31
|
-
try {
|
|
32
|
-
capsule = await getCapsule(handle, params.capsule_id);
|
|
33
|
-
}
|
|
34
|
-
catch (err) {
|
|
35
|
-
return withNextStepsError(`Capsule '${params.capsule_id}' not found. ${err.message}`, [
|
|
36
|
-
{
|
|
37
|
-
id: "list_relevant_capsules_first",
|
|
38
|
-
label: "List relevant capsules for the current repo first",
|
|
39
|
-
tool: "zivis_threat_list_relevant_capsules",
|
|
40
|
-
why: "Returns ids you can pass back here.",
|
|
41
|
-
},
|
|
42
|
-
], "Capsule not found — list first to discover ids.");
|
|
43
|
-
}
|
|
44
|
-
if (!capsule.model_task_prompt_ref) {
|
|
45
|
-
return withNextStepsError(`Capsule '${capsule.id}' has no inference prompt defined (model_task_prompt_ref missing). This capsule is deterministic-only.`, [
|
|
46
|
-
{
|
|
47
|
-
id: "get_capsule",
|
|
48
|
-
label: "Read the full capsule to see its deterministic strategies",
|
|
49
|
-
tool: "zivis_threat_get_capsule",
|
|
50
|
-
args_hint: { capsule_id: capsule.id },
|
|
51
|
-
why: "Some capsules have no INFER strategy — only AST/GRAPH/META/etc. that the matcher runs locally.",
|
|
52
|
-
},
|
|
53
|
-
], "No inference prompt for this capsule (deterministic only).");
|
|
54
|
-
}
|
|
55
|
-
const promptText = await getInferencePrompt(handle, capsule.model_task_prompt_ref);
|
|
56
|
-
return withNextSteps({
|
|
57
|
-
pack: { id: handle.manifest.pack_id, version: handle.manifest.version },
|
|
58
|
-
capsule_id: capsule.id,
|
|
59
|
-
prompt: promptText,
|
|
60
|
-
expected_output_schema: capsule.expected_output_schema ?? null,
|
|
61
|
-
safe_summary: capsule.safe_summary ?? null,
|
|
62
|
-
minimum_context_required: capsule.minimum_context_required ?? null,
|
|
63
|
-
host_instructions: "Gather the code spans indicated by minimum_context_required.symbols (or any deterministic match spans the matcher already flagged), attach them to the prompt above, run inference with your model, and return JSON matching expected_output_schema. The structured output flows back into the inferred lane.",
|
|
64
|
-
}, [
|
|
65
|
-
{
|
|
66
|
-
id: "host_runs_inference",
|
|
67
|
-
label: "Host LLM runs inference now (no further tool call)",
|
|
68
|
-
tool: "zivis_threat_get_inference_prompt",
|
|
69
|
-
why: "MCP cannot invoke your model. The host orchestrates the inference using this bundle.",
|
|
70
|
-
},
|
|
71
|
-
], `Prompt bundle ready for host-side inference of ${capsule.id}.`);
|
|
72
|
-
};
|
|
73
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { ApiClient } from "../api-client.js";
|
|
3
|
-
export declare const THREAT_GUIDE_NAME = "zivis_threat_guide";
|
|
4
|
-
export declare const THREAT_GUIDE_DESCRIPTION = "Per-turn grounding for the IDE assistant. ZIVIS is not the analyst here \u2014 you are. ZIVIS is the structured grounding layer that makes you smarter about THIS specific codebase: graph, pattern library, threat-model state, enterprise-readiness gaps. Read context_for_host_llm and use it to inform your reply. The user does not need to see the raw fields \u2014 incorporate them as you would any other grounding.\n\nReads the local inspect cache and will not nag the user to re-inspect if a recent run exists. Call this on every conversation turn that touches code, architecture, integrations, dependencies, security, or a launch.\n\nUse this when the user says any of:\n- \"we just added <X>\" / \"we're going to integrate <X>\" / \"we're using <library>\"\n- \"<service A> calls / sends to / fetches from <service B>\"\n- describes any user role, attacker, partner, or external system\n- \"what if <bad thing>?\" / \"could someone <attack>?\" / \"is this safe?\"\n- \"we store <data type>\" / \"we process <PII / payments / credentials>\"\n- \"we added <encryption / rate limiting / WAF / audit logging>\"\n- mentions of launch, audit, compliance, customer ask, regulated buyer\n- any architecture or security clarification request\n\nHow to use the response:\n\nGROUNDING (use silently to inform your reply, do not echo verbatim):\n- context_for_host_llm.graph_summary \u2014 what ZIVIS sees in this repo. Use this to ground your reply in their actual architecture.\n- context_for_host_llm.matched_patterns \u2014 pattern-library matches against the graph. Treat as signals, NOT verdicts. Decide what's actually relevant given what the user just said. False positives are expected; you are the filter.\n- context_for_host_llm.applicable_patterns \u2014 patterns ZIVIS thinks the user could adopt or is bumping into. Surface to the user only when relevant to their utterance.\n- context_for_host_llm.github_app \u2014 Lane-2 conversion grounding. When installed=false, the user has not yet linked their repo to ZIVIS. Surface the install_url ONLY when the user asks about continuous monitoring, CI integration, automated PR scanning, or how ZIVIS picks up code changes \u2014 do not interrupt other conversations to push this.\n- readiness_gaps \u2014 enterprise-readiness artifacts the user hasn't yet built (no threat model, no documented data flows, etc.). Useful for \"is this ready for procurement\" or \"what's missing\" questions. Do not lecture if the user didn't ask.\n- vocabulary_map + teaching_note \u2014 a concept the user is unknowingly bumping into. Weave the term into your reply naturally; don't deliver a lesson.\n\nACTION (act on if the user shows interest, not before):\n- next_action.type === \"call_tool\" \u2192 suggest calling next_action.tool with next_action.args_preview. Confirm with the user before calling unless the call is obviously safe (read-only).\n- next_action.type === \"ask_user\" \u2192 ask next_action.question (use it verbatim or paraphrase).\n- next_action.type === \"run_inspect_first\" \u2192 call zivis_inspect to bootstrap the threat model. (Suppressed automatically if a fresh local artifact exists.)\n- next_action.type === \"no_action\" \u2192 continue the conversation; no ZIVIS-side write is needed.\n\nPRODUCED ARTIFACTS (informational):\n- produced_artifacts \u2014 what this turn added to the user's accumulating record on ZIVIS. Mention if relevant (\"ZIVIS just captured this data flow\"); otherwise stay silent.\n\nThe user is paying $20/mo + credits for this grounding. Make every turn feel like ZIVIS is contributing structure \u2014 not analysis. If you find yourself echoing ZIVIS's matched_patterns or readiness_gaps as a checklist, you're doing it wrong; the user wanted a conversation, not a report.\n\nInputs are all optional. If user_utterance is empty, the response is driven by the highest-priority gap \u2014 useful for \"what should I work on next?\" prompts.";
|
|
5
|
-
export declare const THREAT_GUIDE_SCHEMA: {
|
|
6
|
-
user_utterance: z.ZodOptional<z.ZodString>;
|
|
7
|
-
application_id: z.ZodOptional<z.ZodString>;
|
|
8
|
-
context_hint: z.ZodOptional<z.ZodEnum<{
|
|
9
|
-
code_change: "code_change";
|
|
10
|
-
architecture_question: "architecture_question";
|
|
11
|
-
security_worry: "security_worry";
|
|
12
|
-
feature: "feature";
|
|
13
|
-
unknown: "unknown";
|
|
14
|
-
}>>;
|
|
15
|
-
cwd: z.ZodOptional<z.ZodString>;
|
|
16
|
-
};
|
|
17
|
-
export declare function createThreatGuideHandler(apiClient: ApiClient): (params: {
|
|
18
|
-
user_utterance?: string;
|
|
19
|
-
application_id?: string;
|
|
20
|
-
context_hint?: "code_change" | "architecture_question" | "security_worry" | "feature" | "unknown";
|
|
21
|
-
cwd?: string;
|
|
22
|
-
}) => Promise<{
|
|
23
|
-
content: Array<{
|
|
24
|
-
type: "text";
|
|
25
|
-
text: string;
|
|
26
|
-
}>;
|
|
27
|
-
isError?: boolean;
|
|
28
|
-
}>;
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { withNextSteps, withNextStepsError } from "../lib/next-steps.js";
|
|
3
|
-
import { locateLatestArtifact, isFresh, inspectCacheTtlMs, } from "../lib/inspect-cache.js";
|
|
4
|
-
export const THREAT_GUIDE_NAME = "zivis_threat_guide";
|
|
5
|
-
export const THREAT_GUIDE_DESCRIPTION = `Per-turn grounding for the IDE assistant. ZIVIS is not the analyst here — you are. ZIVIS is the structured grounding layer that makes you smarter about THIS specific codebase: graph, pattern library, threat-model state, enterprise-readiness gaps. Read context_for_host_llm and use it to inform your reply. The user does not need to see the raw fields — incorporate them as you would any other grounding.
|
|
6
|
-
|
|
7
|
-
Reads the local inspect cache and will not nag the user to re-inspect if a recent run exists. Call this on every conversation turn that touches code, architecture, integrations, dependencies, security, or a launch.
|
|
8
|
-
|
|
9
|
-
Use this when the user says any of:
|
|
10
|
-
- "we just added <X>" / "we're going to integrate <X>" / "we're using <library>"
|
|
11
|
-
- "<service A> calls / sends to / fetches from <service B>"
|
|
12
|
-
- describes any user role, attacker, partner, or external system
|
|
13
|
-
- "what if <bad thing>?" / "could someone <attack>?" / "is this safe?"
|
|
14
|
-
- "we store <data type>" / "we process <PII / payments / credentials>"
|
|
15
|
-
- "we added <encryption / rate limiting / WAF / audit logging>"
|
|
16
|
-
- mentions of launch, audit, compliance, customer ask, regulated buyer
|
|
17
|
-
- any architecture or security clarification request
|
|
18
|
-
|
|
19
|
-
How to use the response:
|
|
20
|
-
|
|
21
|
-
GROUNDING (use silently to inform your reply, do not echo verbatim):
|
|
22
|
-
- context_for_host_llm.graph_summary — what ZIVIS sees in this repo. Use this to ground your reply in their actual architecture.
|
|
23
|
-
- context_for_host_llm.matched_patterns — pattern-library matches against the graph. Treat as signals, NOT verdicts. Decide what's actually relevant given what the user just said. False positives are expected; you are the filter.
|
|
24
|
-
- context_for_host_llm.applicable_patterns — patterns ZIVIS thinks the user could adopt or is bumping into. Surface to the user only when relevant to their utterance.
|
|
25
|
-
- context_for_host_llm.github_app — Lane-2 conversion grounding. When installed=false, the user has not yet linked their repo to ZIVIS. Surface the install_url ONLY when the user asks about continuous monitoring, CI integration, automated PR scanning, or how ZIVIS picks up code changes — do not interrupt other conversations to push this.
|
|
26
|
-
- readiness_gaps — enterprise-readiness artifacts the user hasn't yet built (no threat model, no documented data flows, etc.). Useful for "is this ready for procurement" or "what's missing" questions. Do not lecture if the user didn't ask.
|
|
27
|
-
- vocabulary_map + teaching_note — a concept the user is unknowingly bumping into. Weave the term into your reply naturally; don't deliver a lesson.
|
|
28
|
-
|
|
29
|
-
ACTION (act on if the user shows interest, not before):
|
|
30
|
-
- next_action.type === "call_tool" → suggest calling next_action.tool with next_action.args_preview. Confirm with the user before calling unless the call is obviously safe (read-only).
|
|
31
|
-
- next_action.type === "ask_user" → ask next_action.question (use it verbatim or paraphrase).
|
|
32
|
-
- next_action.type === "run_inspect_first" → call zivis_inspect to bootstrap the threat model. (Suppressed automatically if a fresh local artifact exists.)
|
|
33
|
-
- next_action.type === "no_action" → continue the conversation; no ZIVIS-side write is needed.
|
|
34
|
-
|
|
35
|
-
PRODUCED ARTIFACTS (informational):
|
|
36
|
-
- produced_artifacts — what this turn added to the user's accumulating record on ZIVIS. Mention if relevant ("ZIVIS just captured this data flow"); otherwise stay silent.
|
|
37
|
-
|
|
38
|
-
The user is paying $20/mo + credits for this grounding. Make every turn feel like ZIVIS is contributing structure — not analysis. If you find yourself echoing ZIVIS's matched_patterns or readiness_gaps as a checklist, you're doing it wrong; the user wanted a conversation, not a report.
|
|
39
|
-
|
|
40
|
-
Inputs are all optional. If user_utterance is empty, the response is driven by the highest-priority gap — useful for "what should I work on next?" prompts.`;
|
|
41
|
-
export const THREAT_GUIDE_SCHEMA = {
|
|
42
|
-
user_utterance: z
|
|
43
|
-
.string()
|
|
44
|
-
.max(2000)
|
|
45
|
-
.optional()
|
|
46
|
-
.describe("Verbatim or near-verbatim of what the user just said. Pass the user's actual words — the classifier reads phrasing cues (verbs, vendor names, role nouns). Omit only when the user is asking 'what should I do next?' with no specific topic."),
|
|
47
|
-
application_id: z
|
|
48
|
-
.string()
|
|
49
|
-
.optional()
|
|
50
|
-
.describe("Application UUID. If omitted, uses applicationId from .zivis/project.json when set. Required when the binding doesn't resolve a unique app."),
|
|
51
|
-
context_hint: z
|
|
52
|
-
.enum(["code_change", "architecture_question", "security_worry", "feature", "unknown"])
|
|
53
|
-
.optional()
|
|
54
|
-
.describe("Optional hint about the kind of turn this is. Helps the classifier disambiguate. If unsure, omit or pass 'unknown'."),
|
|
55
|
-
cwd: z
|
|
56
|
-
.string()
|
|
57
|
-
.optional()
|
|
58
|
-
.describe("Working directory to derive repo identity from when checking the local inspect cache. Defaults to server cwd."),
|
|
59
|
-
};
|
|
60
|
-
export function createThreatGuideHandler(apiClient) {
|
|
61
|
-
return async (params) => {
|
|
62
|
-
const cwd = params.cwd ?? process.cwd();
|
|
63
|
-
let localArtifact;
|
|
64
|
-
try {
|
|
65
|
-
localArtifact = await locateLatestArtifact(cwd);
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
localArtifact = undefined;
|
|
69
|
-
}
|
|
70
|
-
const localFresh = !!localArtifact && isFresh(localArtifact.mtimeMs);
|
|
71
|
-
try {
|
|
72
|
-
const result = await apiClient.request("POST", "/api/mcp/guide", {
|
|
73
|
-
user_utterance: params.user_utterance,
|
|
74
|
-
application_id: params.application_id,
|
|
75
|
-
context_hint: params.context_hint,
|
|
76
|
-
local_inspect_mtime_ms: localArtifact?.mtimeMs,
|
|
77
|
-
local_inspect_fresh: localFresh,
|
|
78
|
-
});
|
|
79
|
-
let cacheOverrideNote;
|
|
80
|
-
if (result.next_action.type === "run_inspect_first" && localArtifact && localFresh) {
|
|
81
|
-
const ageMin = Math.max(0, Math.round((Date.now() - localArtifact.mtimeMs) / 60000));
|
|
82
|
-
cacheOverrideNote = `Inspect already fresh (${ageMin}m ago, TTL ${Math.round(inspectCacheTtlMs() / 60000)}m). Using cached graph at ${localArtifact.path} — skipping re-inspection.`;
|
|
83
|
-
result.next_action = {
|
|
84
|
-
type: "call_tool",
|
|
85
|
-
tool: "zivis_threat_run_matcher",
|
|
86
|
-
args_preview: { artifact_path: localArtifact.path, cwd },
|
|
87
|
-
follow_up: cacheOverrideNote,
|
|
88
|
-
original_action: "run_inspect_first",
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
const next = result.next_action;
|
|
92
|
-
const nextSteps = [];
|
|
93
|
-
if (next.type === "call_tool") {
|
|
94
|
-
nextSteps.push({
|
|
95
|
-
id: "execute_suggested_tool",
|
|
96
|
-
label: `Call ${next.tool} with the suggested args`,
|
|
97
|
-
tool: String(next.tool),
|
|
98
|
-
args_hint: next.args_preview ?? {},
|
|
99
|
-
why: next.follow_up ??
|
|
100
|
-
"The threat-guide endpoint mapped this utterance to a concrete graph operation.",
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
else if (next.type === "ask_user") {
|
|
104
|
-
nextSteps.push({
|
|
105
|
-
id: "ask_clarifying_question",
|
|
106
|
-
label: "Ask the user this clarifying question",
|
|
107
|
-
tool: "zivis_threat_guide",
|
|
108
|
-
args_hint: {},
|
|
109
|
-
why: String(next.question ?? "Need more info before acting on the graph."),
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
else if (next.type === "run_inspect_first") {
|
|
113
|
-
nextSteps.push({
|
|
114
|
-
id: "run_inspect",
|
|
115
|
-
label: "Run /inspect to bootstrap the threat model from the repo",
|
|
116
|
-
tool: "zivis_inspect",
|
|
117
|
-
args_hint: {},
|
|
118
|
-
why: "The threat model is empty — bootstrap from the repo before modeling further.",
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
let githubAppStatus;
|
|
122
|
-
try {
|
|
123
|
-
const ghResp = await apiClient.request("GET", "/api/github-app/status", undefined);
|
|
124
|
-
githubAppStatus = {
|
|
125
|
-
installed: ghResp.installed,
|
|
126
|
-
install_url: ghResp.installUrl,
|
|
127
|
-
next_step: ghResp.installed
|
|
128
|
-
? undefined
|
|
129
|
-
: ghResp.installUrl
|
|
130
|
-
? `Install the ZIVIS GitHub App at ${ghResp.installUrl} to enable continuous monitoring on push.`
|
|
131
|
-
: undefined,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
catch {
|
|
135
|
-
}
|
|
136
|
-
const baseContext = result.context_for_host_llm ?? {
|
|
137
|
-
graph_summary: undefined,
|
|
138
|
-
matched_patterns: [],
|
|
139
|
-
applicable_patterns: [],
|
|
140
|
-
};
|
|
141
|
-
const enriched = {
|
|
142
|
-
...result,
|
|
143
|
-
context_for_host_llm: {
|
|
144
|
-
...baseContext,
|
|
145
|
-
...(githubAppStatus ? { github_app: githubAppStatus } : {}),
|
|
146
|
-
},
|
|
147
|
-
readiness_gaps: result.readiness_gaps ?? [],
|
|
148
|
-
produced_artifacts: result.produced_artifacts ?? [],
|
|
149
|
-
local_inspect_cache: localArtifact
|
|
150
|
-
? {
|
|
151
|
-
artifact_path: localArtifact.path,
|
|
152
|
-
mtime_ms: localArtifact.mtimeMs,
|
|
153
|
-
fresh: localFresh,
|
|
154
|
-
ttl_ms: inspectCacheTtlMs(),
|
|
155
|
-
override_applied: !!cacheOverrideNote,
|
|
156
|
-
}
|
|
157
|
-
: { artifact_path: null, fresh: false, ttl_ms: inspectCacheTtlMs() },
|
|
158
|
-
};
|
|
159
|
-
return withNextSteps(enriched, nextSteps, next.type === "no_action"
|
|
160
|
-
? "No graph operation needed for this turn — continue conversationally."
|
|
161
|
-
: `Next: ${next.type === "call_tool" ? `call ${next.tool}` : next.type === "ask_user" ? "ask the clarifying question" : next.type}`);
|
|
162
|
-
}
|
|
163
|
-
catch (err) {
|
|
164
|
-
const message = err instanceof Error ? err.message : "threat_guide call failed";
|
|
165
|
-
return withNextStepsError(message, [
|
|
166
|
-
{
|
|
167
|
-
id: "check_project",
|
|
168
|
-
label: "Verify project binding + auth",
|
|
169
|
-
tool: "zivis_check_project",
|
|
170
|
-
why: "If the call failed because of auth or binding, this surfaces the specific fix.",
|
|
171
|
-
},
|
|
172
|
-
], "threat_guide call failed — check binding/auth.");
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const THREAT_LIST_RELEVANT_CAPSULES_NAME = "zivis_threat_list_relevant_capsules";
|
|
3
|
-
export declare const THREAT_LIST_RELEVANT_CAPSULES_DESCRIPTION = "List threat-model patterns relevant to the user's current repo.\n\nUse this when the user asks any of:\n- \"what should I be worried about in this code\"\n- \"what threats apply to my app\"\n- \"are there known patterns that match my architecture\"\n- \"what's in my threat model\"\n- mid-conversation when the user describes a feature that touches deps the threat library covers\n\nReads the latest local repo graph artifact (produced by 'zivis inspect') from the user cache, runs every capsule's relevance_filter against it, and returns the subset whose filter passes \u2014 together with each capsule's safe_summary so you can frame the conversation in threat-model terms (component, flow, trust boundary, scenario).\n\nIf no graph artifact exists yet for this repo, the tool returns a next-step pointing to 'zivis inspect'. Always speak in threat-model vocabulary even when the user doesn't.";
|
|
4
|
-
export declare const THREAT_LIST_RELEVANT_CAPSULES_SCHEMA: {
|
|
5
|
-
artifact_path: z.ZodOptional<z.ZodString>;
|
|
6
|
-
cwd: z.ZodOptional<z.ZodString>;
|
|
7
|
-
};
|
|
8
|
-
export declare function createThreatListRelevantCapsulesHandler(): (params: {
|
|
9
|
-
artifact_path?: string;
|
|
10
|
-
cwd?: string;
|
|
11
|
-
}) => Promise<{
|
|
12
|
-
content: Array<{
|
|
13
|
-
type: "text";
|
|
14
|
-
text: string;
|
|
15
|
-
}>;
|
|
16
|
-
isError?: boolean;
|
|
17
|
-
}>;
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import * as fs from "node:fs/promises";
|
|
3
|
-
import * as fssync from "node:fs";
|
|
4
|
-
import * as os from "node:os";
|
|
5
|
-
import * as path from "node:path";
|
|
6
|
-
import { loadActivePack, findRelevantCapsules, } from "../pattern-pack/index.js";
|
|
7
|
-
import { withNextSteps, withNextStepsError } from "../lib/next-steps.js";
|
|
8
|
-
export const THREAT_LIST_RELEVANT_CAPSULES_NAME = "zivis_threat_list_relevant_capsules";
|
|
9
|
-
export const THREAT_LIST_RELEVANT_CAPSULES_DESCRIPTION = `List threat-model patterns relevant to the user's current repo.
|
|
10
|
-
|
|
11
|
-
Use this when the user asks any of:
|
|
12
|
-
- "what should I be worried about in this code"
|
|
13
|
-
- "what threats apply to my app"
|
|
14
|
-
- "are there known patterns that match my architecture"
|
|
15
|
-
- "what's in my threat model"
|
|
16
|
-
- mid-conversation when the user describes a feature that touches deps the threat library covers
|
|
17
|
-
|
|
18
|
-
Reads the latest local repo graph artifact (produced by 'zivis inspect') from the user cache, runs every capsule's relevance_filter against it, and returns the subset whose filter passes — together with each capsule's safe_summary so you can frame the conversation in threat-model terms (component, flow, trust boundary, scenario).
|
|
19
|
-
|
|
20
|
-
If no graph artifact exists yet for this repo, the tool returns a next-step pointing to 'zivis inspect'. Always speak in threat-model vocabulary even when the user doesn't.`;
|
|
21
|
-
export const THREAT_LIST_RELEVANT_CAPSULES_SCHEMA = {
|
|
22
|
-
artifact_path: z
|
|
23
|
-
.string()
|
|
24
|
-
.optional()
|
|
25
|
-
.describe("Optional path to a specific RepoGraphArtifactV1 JSON. If omitted, the tool finds the most recent artifact in ~/Library/Caches/zivis/repos/<repo-id>/inspect/runs/ for the repo at cwd."),
|
|
26
|
-
cwd: z
|
|
27
|
-
.string()
|
|
28
|
-
.optional()
|
|
29
|
-
.describe("Working directory whose repo cache to search (defaults to server cwd)."),
|
|
30
|
-
};
|
|
31
|
-
export function createThreatListRelevantCapsulesHandler() {
|
|
32
|
-
return async (params) => {
|
|
33
|
-
const cwd = params.cwd ?? process.cwd();
|
|
34
|
-
let artifact;
|
|
35
|
-
let artifactPath;
|
|
36
|
-
try {
|
|
37
|
-
const resolved = await resolveArtifactPath(params.artifact_path, cwd);
|
|
38
|
-
artifactPath = resolved;
|
|
39
|
-
const raw = await fs.readFile(resolved, "utf8");
|
|
40
|
-
artifact = JSON.parse(raw);
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
return withNextStepsError(`No repo graph artifact found. ${err.message}`, [
|
|
44
|
-
{
|
|
45
|
-
id: "run_zivis_inspect",
|
|
46
|
-
label: "Run `zivis inspect` to build the local repo graph",
|
|
47
|
-
tool: "zivis_inspect",
|
|
48
|
-
why: "The relevance evaluation reads from the latest inspect run in the user cache.",
|
|
49
|
-
},
|
|
50
|
-
], "Run `zivis inspect` first; this tool reads from its output.");
|
|
51
|
-
}
|
|
52
|
-
const handle = await loadActivePack();
|
|
53
|
-
const relevant = await findRelevantCapsules(handle, artifact);
|
|
54
|
-
const summaries = relevant.map((cap) => ({
|
|
55
|
-
id: cap.id,
|
|
56
|
-
title: cap.title,
|
|
57
|
-
category: cap.category,
|
|
58
|
-
safe_summary: cap.safe_summary,
|
|
59
|
-
applicable_languages: cap.applicable_languages,
|
|
60
|
-
matched_on: matchedTerms(cap, artifact),
|
|
61
|
-
}));
|
|
62
|
-
return withNextSteps({
|
|
63
|
-
artifact_path: artifactPath,
|
|
64
|
-
pack: { id: handle.manifest.pack_id, version: handle.manifest.version },
|
|
65
|
-
languages_in_scope: artifact.scope.languages ?? [],
|
|
66
|
-
relevant_count: summaries.length,
|
|
67
|
-
relevant_capsules: summaries,
|
|
68
|
-
}, summaries.length > 0
|
|
69
|
-
? [
|
|
70
|
-
{
|
|
71
|
-
id: "get_capsule_details",
|
|
72
|
-
label: "Pull the full capsule for any item the user wants to investigate",
|
|
73
|
-
tool: "zivis_threat_get_capsule",
|
|
74
|
-
why: "The full capsule has threats (with STRIDE), risk_hints, repair_contract, related_patterns.",
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
id: "get_inference_prompt",
|
|
78
|
-
label: "Get the inference prompt for the host LLM to run a deeper check",
|
|
79
|
-
tool: "zivis_threat_get_inference_prompt",
|
|
80
|
-
why: "INFER strategies in each capsule reference a prompt template the user's IDE model executes.",
|
|
81
|
-
},
|
|
82
|
-
]
|
|
83
|
-
: [
|
|
84
|
-
{
|
|
85
|
-
id: "no_relevant_patterns",
|
|
86
|
-
label: "No public-pack patterns matched this repo",
|
|
87
|
-
tool: "zivis_threat_list_relevant_capsules",
|
|
88
|
-
why: "This is normal for repos without agentic / RAG / self-consistency / multi-tenant patterns. Proprietary patterns may still apply server-side.",
|
|
89
|
-
},
|
|
90
|
-
], summaries.length > 0
|
|
91
|
-
? `Found ${summaries.length} relevant capsule(s) in the threat library.`
|
|
92
|
-
: "No public-pack capsules matched this repo. Proprietary patterns evaluated server-side may still apply.");
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
function userCacheRoot() {
|
|
96
|
-
const home = os.homedir();
|
|
97
|
-
if (process.platform === "darwin") {
|
|
98
|
-
return path.join(home, "Library", "Caches", "zivis");
|
|
99
|
-
}
|
|
100
|
-
if (process.platform === "win32") {
|
|
101
|
-
const localAppData = process.env.LOCALAPPDATA ?? path.join(home, "AppData", "Local");
|
|
102
|
-
return path.join(localAppData, "zivis", "Cache");
|
|
103
|
-
}
|
|
104
|
-
const xdg = process.env.XDG_CACHE_HOME;
|
|
105
|
-
return path.join(xdg ?? path.join(home, ".cache"), "zivis");
|
|
106
|
-
}
|
|
107
|
-
async function resolveArtifactPath(explicit, cwd) {
|
|
108
|
-
if (explicit) {
|
|
109
|
-
if (!fssync.existsSync(explicit)) {
|
|
110
|
-
throw new Error(`Artifact path does not exist: ${explicit}`);
|
|
111
|
-
}
|
|
112
|
-
return explicit;
|
|
113
|
-
}
|
|
114
|
-
const reposRoot = path.join(userCacheRoot(), "repos");
|
|
115
|
-
if (!fssync.existsSync(reposRoot)) {
|
|
116
|
-
throw new Error(`No inspect cache found at ${reposRoot}. Run \`zivis inspect\` from the repo to populate it.`);
|
|
117
|
-
}
|
|
118
|
-
const candidates = [];
|
|
119
|
-
for (const repo of await fs.readdir(reposRoot, { withFileTypes: true })) {
|
|
120
|
-
if (!repo.isDirectory())
|
|
121
|
-
continue;
|
|
122
|
-
const runs = path.join(reposRoot, repo.name, "inspect", "runs");
|
|
123
|
-
if (!fssync.existsSync(runs))
|
|
124
|
-
continue;
|
|
125
|
-
for (const entry of await fs.readdir(runs)) {
|
|
126
|
-
if (!entry.endsWith(".json"))
|
|
127
|
-
continue;
|
|
128
|
-
const full = path.join(runs, entry);
|
|
129
|
-
const stat = await fs.stat(full);
|
|
130
|
-
candidates.push({ file: full, mtime: stat.mtimeMs });
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
if (candidates.length === 0) {
|
|
134
|
-
throw new Error(`No inspect runs found under ${reposRoot}. Run \`zivis inspect\` from the repo to produce one.`);
|
|
135
|
-
}
|
|
136
|
-
candidates.sort((a, b) => b.mtime - a.mtime);
|
|
137
|
-
return candidates[0].file;
|
|
138
|
-
}
|
|
139
|
-
function matchedTerms(cap, artifact) {
|
|
140
|
-
const matched = [];
|
|
141
|
-
const pkgs = new Set();
|
|
142
|
-
for (const node of artifact.nodes) {
|
|
143
|
-
if (node.type === "external_dependency" && node.attributes?.package) {
|
|
144
|
-
pkgs.add(node.attributes.package);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
const langs = new Set(artifact.scope.languages ?? []);
|
|
148
|
-
const f = cap.relevance_filter;
|
|
149
|
-
if (!f)
|
|
150
|
-
return ["always-applicable (no relevance_filter set)"];
|
|
151
|
-
for (const term of [...(f.any_of ?? []), ...(f.all_of ?? [])]) {
|
|
152
|
-
if (term.dependency && pkgs.has(term.dependency))
|
|
153
|
-
matched.push(`dep:${term.dependency}`);
|
|
154
|
-
if (term.language && langs.has(term.language))
|
|
155
|
-
matched.push(`language:${term.language}`);
|
|
156
|
-
}
|
|
157
|
-
return matched.length > 0 ? matched : ["language match only"];
|
|
158
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const THREAT_RUN_MATCHER_NAME = "zivis_threat_run_matcher";
|
|
3
|
-
export declare const THREAT_RUN_MATCHER_DESCRIPTION = "Run the local pattern matcher against the latest repo graph artifact and emit normalized threat findings.\n\nUse this when:\n- The user asks ZIVIS to actually evaluate (not just list) which patterns fire on their code\n- After 'zivis inspect' has produced an artifact and the user wants concrete findings\n- \"find security issues in my code\", \"check this against the threat library\", \"what's actually wrong here\"\n\nPhase 3 v1 evaluates AST strategies for real (via @ast-grep/napi for TS/JS, plus Python and Go via dynamic language packs). INFER strategies emit a candidate the host LLM is expected to pick up via zivis_threat_get_inference_prompt and run with its own model. GRAPH / META / DEP / CONFIG strategies are surfaced as fired_strategies with match_count: 0 \u2014 visible-but-not-evaluated for now.\n\nLane assignment per finding:\n- trusted: count of fired deterministic strategies meets the capsule's required_evidence_count\n- inferred: at least one strategy fired but the bar wasn't met (host should run inference to confirm)\n\nThe output is a normalized findings array with pattern_id, lane, confidence, evidence spans, and (for inferred-lane findings) an inference_candidate the host LLM uses to run deeper analysis.";
|
|
4
|
-
export declare const THREAT_RUN_MATCHER_SCHEMA: {
|
|
5
|
-
artifact_path: z.ZodOptional<z.ZodString>;
|
|
6
|
-
cwd: z.ZodOptional<z.ZodString>;
|
|
7
|
-
};
|
|
8
|
-
export declare function createThreatRunMatcherHandler(): (params: {
|
|
9
|
-
artifact_path?: string;
|
|
10
|
-
cwd?: string;
|
|
11
|
-
}) => Promise<{
|
|
12
|
-
content: Array<{
|
|
13
|
-
type: "text";
|
|
14
|
-
text: string;
|
|
15
|
-
}>;
|
|
16
|
-
isError?: boolean;
|
|
17
|
-
}>;
|