@zivis/cli 0.1.0-alpha.4 → 0.1.0-alpha.40

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.
Files changed (124) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +31 -0
  3. package/dist/commands/app/index.d.ts +0 -8
  4. package/dist/commands/app/index.js +4 -16
  5. package/dist/commands/auth/bind.d.ts +4 -0
  6. package/dist/commands/auth/bind.js +97 -0
  7. package/dist/commands/auth/index.js +20 -2
  8. package/dist/commands/auth/init.d.ts +1 -0
  9. package/dist/commands/auth/init.js +245 -73
  10. package/dist/commands/auth/login.d.ts +2 -0
  11. package/dist/commands/auth/login.js +136 -18
  12. package/dist/commands/auth/logout.js +19 -7
  13. package/dist/commands/auth/sessions.js +7 -4
  14. package/dist/commands/auth/status.js +33 -12
  15. package/dist/commands/auth/token.d.ts +4 -0
  16. package/dist/commands/auth/token.js +73 -0
  17. package/dist/commands/check/index.d.ts +2 -0
  18. package/dist/commands/check/index.js +463 -0
  19. package/dist/commands/credits/index.js +2 -3
  20. package/dist/commands/inspect/index.d.ts +2 -0
  21. package/dist/commands/inspect/index.js +136 -0
  22. package/dist/commands/mcp/index.js +81 -14
  23. package/dist/commands/open/index.d.ts +0 -8
  24. package/dist/commands/open/index.js +0 -11
  25. package/dist/commands/scan/index.js +3 -8
  26. package/dist/commands/target/index.js +0 -3
  27. package/dist/commands/tm/index.js +3 -10
  28. package/dist/index.js +13 -1
  29. package/dist/internal/binding-token-mint.d.ts +33 -0
  30. package/dist/internal/binding-token-mint.js +174 -0
  31. package/dist/internal/extractor/adapters/go/index.d.ts +0 -4
  32. package/dist/internal/extractor/adapters/go/index.js +0 -6
  33. package/dist/internal/extractor/adapters/go/manifest.d.ts +0 -17
  34. package/dist/internal/extractor/adapters/go/manifest.js +19 -25
  35. package/dist/internal/extractor/adapters/go/parser.d.ts +0 -4
  36. package/dist/internal/extractor/adapters/go/parser.js +0 -5
  37. package/dist/internal/extractor/adapters/go/scanner.d.ts +0 -20
  38. package/dist/internal/extractor/adapters/go/scanner.js +0 -43
  39. package/dist/internal/extractor/adapters/python/index.d.ts +0 -3
  40. package/dist/internal/extractor/adapters/python/index.js +0 -4
  41. package/dist/internal/extractor/adapters/python/manifest.d.ts +0 -8
  42. package/dist/internal/extractor/adapters/python/manifest.js +21 -18
  43. package/dist/internal/extractor/adapters/python/parser.d.ts +0 -3
  44. package/dist/internal/extractor/adapters/python/parser.js +0 -4
  45. package/dist/internal/extractor/adapters/python/scanner.d.ts +0 -18
  46. package/dist/internal/extractor/adapters/python/scanner.js +1 -54
  47. package/dist/internal/extractor/adapters/typescript/index.d.ts +0 -7
  48. package/dist/internal/extractor/adapters/typescript/index.js +1 -21
  49. package/dist/internal/extractor/adapters/typescript/manifest.d.ts +0 -14
  50. package/dist/internal/extractor/adapters/typescript/manifest.js +26 -17
  51. package/dist/internal/extractor/adapters/typescript/parser.d.ts +0 -8
  52. package/dist/internal/extractor/adapters/typescript/parser.js +0 -9
  53. package/dist/internal/extractor/adapters/typescript/scanner.d.ts +0 -24
  54. package/dist/internal/extractor/adapters/typescript/scanner.js +0 -43
  55. package/dist/internal/extractor/graph-builder.d.ts +10 -0
  56. package/dist/internal/extractor/graph-builder.js +245 -0
  57. package/dist/internal/extractor/graph-types.d.ts +89 -0
  58. package/dist/internal/extractor/graph-types.js +1 -0
  59. package/dist/internal/extractor/index.d.ts +0 -14
  60. package/dist/internal/extractor/index.js +0 -13
  61. package/dist/internal/extractor/types.d.ts +0 -45
  62. package/dist/internal/extractor/types.js +0 -27
  63. package/dist/internal/extractor/walker.d.ts +0 -18
  64. package/dist/internal/extractor/walker.js +0 -18
  65. package/dist/internal/github-linkage-prompt.d.ts +7 -0
  66. package/dist/internal/github-linkage-prompt.js +95 -0
  67. package/dist/internal/ide-setup.d.ts +16 -7
  68. package/dist/internal/ide-setup.js +320 -46
  69. package/dist/internal/org-picker.d.ts +11 -0
  70. package/dist/internal/org-picker.js +34 -0
  71. package/dist/internal/orgs.js +0 -1
  72. package/dist/internal/project-binding.d.ts +1 -0
  73. package/dist/internal/project-binding.js +14 -9
  74. package/dist/internal/target-auth/api-config.d.ts +0 -17
  75. package/dist/internal/target-auth/api-config.js +0 -18
  76. package/dist/internal/target-auth/config.d.ts +0 -12
  77. package/dist/internal/target-auth/config.js +0 -13
  78. package/dist/internal/target-auth/index.d.ts +0 -18
  79. package/dist/internal/target-auth/index.js +0 -19
  80. package/dist/internal/target-auth/keychain.d.ts +0 -18
  81. package/dist/internal/target-auth/keychain.js +3 -23
  82. package/dist/internal/target-auth/types.d.ts +0 -26
  83. package/dist/internal/target-auth/types.js +0 -10
  84. package/dist/internal/target-auth/workos.d.ts +0 -15
  85. package/dist/internal/target-auth/workos.js +9 -18
  86. package/package.json +19 -5
  87. package/dist/commands/app/index.js.map +0 -1
  88. package/dist/commands/auth/index.js.map +0 -1
  89. package/dist/commands/auth/init.js.map +0 -1
  90. package/dist/commands/auth/login.js.map +0 -1
  91. package/dist/commands/auth/logout.js.map +0 -1
  92. package/dist/commands/auth/sessions.js.map +0 -1
  93. package/dist/commands/auth/status.js.map +0 -1
  94. package/dist/commands/credits/index.js.map +0 -1
  95. package/dist/commands/mcp/index.js.map +0 -1
  96. package/dist/commands/open/index.js.map +0 -1
  97. package/dist/commands/scan/index.js.map +0 -1
  98. package/dist/commands/target/index.js.map +0 -1
  99. package/dist/commands/tm/index.js.map +0 -1
  100. package/dist/index.js.map +0 -1
  101. package/dist/internal/extractor/adapters/go/index.js.map +0 -1
  102. package/dist/internal/extractor/adapters/go/manifest.js.map +0 -1
  103. package/dist/internal/extractor/adapters/go/parser.js.map +0 -1
  104. package/dist/internal/extractor/adapters/go/scanner.js.map +0 -1
  105. package/dist/internal/extractor/adapters/python/index.js.map +0 -1
  106. package/dist/internal/extractor/adapters/python/manifest.js.map +0 -1
  107. package/dist/internal/extractor/adapters/python/parser.js.map +0 -1
  108. package/dist/internal/extractor/adapters/python/scanner.js.map +0 -1
  109. package/dist/internal/extractor/adapters/typescript/index.js.map +0 -1
  110. package/dist/internal/extractor/adapters/typescript/manifest.js.map +0 -1
  111. package/dist/internal/extractor/adapters/typescript/parser.js.map +0 -1
  112. package/dist/internal/extractor/adapters/typescript/scanner.js.map +0 -1
  113. package/dist/internal/extractor/index.js.map +0 -1
  114. package/dist/internal/extractor/types.js.map +0 -1
  115. package/dist/internal/extractor/walker.js.map +0 -1
  116. package/dist/internal/ide-setup.js.map +0 -1
  117. package/dist/internal/orgs.js.map +0 -1
  118. package/dist/internal/project-binding.js.map +0 -1
  119. package/dist/internal/target-auth/api-config.js.map +0 -1
  120. package/dist/internal/target-auth/config.js.map +0 -1
  121. package/dist/internal/target-auth/index.js.map +0 -1
  122. package/dist/internal/target-auth/keychain.js.map +0 -1
  123. package/dist/internal/target-auth/types.js.map +0 -1
  124. package/dist/internal/target-auth/workos.js.map +0 -1
@@ -0,0 +1,89 @@
1
+ export type Lane = "trusted" | "inferred";
2
+ export type Source = "inspect.trusted" | "inspect.inferred";
3
+ export type GraphLanguage = "typescript" | "javascript" | "python" | "go";
4
+ export type AnalysisMode = "local" | "cloud";
5
+ export type EvidenceKind = "import" | "http_route" | "config" | "manifest" | "decorator" | "annotation";
6
+ export type NodeType = "service" | "endpoint" | "external_dependency";
7
+ export type EdgeType = "exposes" | "depends_on";
8
+ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "WS" | "SSE" | "RPC";
9
+ export type DependencyRegistry = "npm" | "pypi" | "go";
10
+ export interface EvidenceSpan {
11
+ file: string;
12
+ start_line?: number;
13
+ end_line?: number;
14
+ kind: EvidenceKind;
15
+ detail?: Record<string, unknown>;
16
+ }
17
+ export interface ServiceAttributes {
18
+ framework?: string;
19
+ source_files?: string[];
20
+ }
21
+ export interface EndpointAttributes {
22
+ method: HttpMethod;
23
+ path: string;
24
+ }
25
+ export interface ExternalDependencyAttributes {
26
+ package: string;
27
+ version?: string;
28
+ registry: DependencyRegistry;
29
+ kind?: string;
30
+ }
31
+ export type NodeAttributes = ServiceAttributes | EndpointAttributes | ExternalDependencyAttributes;
32
+ interface BaseNode {
33
+ id: string;
34
+ name: string;
35
+ lane: Lane;
36
+ source: Source;
37
+ confidence?: number;
38
+ language?: GraphLanguage;
39
+ evidence: EvidenceSpan[];
40
+ }
41
+ export interface ServiceNode extends BaseNode {
42
+ type: "service";
43
+ attributes?: ServiceAttributes;
44
+ }
45
+ export interface EndpointNode extends BaseNode {
46
+ type: "endpoint";
47
+ attributes: EndpointAttributes;
48
+ }
49
+ export interface ExternalDependencyNode extends BaseNode {
50
+ type: "external_dependency";
51
+ attributes: ExternalDependencyAttributes;
52
+ }
53
+ export type GraphNode = ServiceNode | EndpointNode | ExternalDependencyNode;
54
+ export interface GraphEdge {
55
+ id: string;
56
+ type: EdgeType;
57
+ source_id: string;
58
+ target_id: string;
59
+ lane: Lane;
60
+ source: Source;
61
+ confidence?: number;
62
+ evidence?: EvidenceSpan[];
63
+ attributes?: Record<string, unknown>;
64
+ }
65
+ export interface GraphProvenance {
66
+ root_dir: string;
67
+ repo_id?: string;
68
+ commit_sha?: string;
69
+ branch?: string;
70
+ application_id?: string;
71
+ analysis_mode: AnalysisMode;
72
+ }
73
+ export interface GraphScope {
74
+ files_scanned: number;
75
+ files_skipped: number;
76
+ duration_ms: number;
77
+ languages?: GraphLanguage[];
78
+ }
79
+ export interface RepoGraphArtifactV1 {
80
+ version: "1.0.0";
81
+ kind: "repo_graph_artifact";
82
+ extracted_at: string;
83
+ extractor: string;
84
+ provenance: GraphProvenance;
85
+ scope: GraphScope;
86
+ nodes: GraphNode[];
87
+ edges: GraphEdge[];
88
+ }
89
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,22 +1,8 @@
1
- /**
2
- * Extractor orchestrator.
3
- *
4
- * Walks the customer's repo, dispatches matched files to per-language
5
- * adapters, merges their findings into a single ExtractionResult.
6
- *
7
- * Adapters register their own file extensions + manifest filenames; the
8
- * walker only reads files those filters claim. So adding a Go or Python
9
- * adapter doesn't change anything here — register the adapter and the
10
- * orchestrator picks up its files.
11
- */
12
1
  import type { ExtractionResult } from "./types.js";
13
2
  export interface RunOptions {
14
3
  rootDir: string;
15
- /** Subset of language adapters to run; defaults to all registered. */
16
4
  languages?: Array<"typescript" | "go" | "python">;
17
- /** Extra ignore patterns from --ignore flags. */
18
5
  extraIgnores?: string[];
19
- /** Version string for the extractor — usually @zivis/cli's package version. */
20
6
  extractorVersion: string;
21
7
  }
22
8
  export declare function runExtractor(opts: RunOptions): Promise<ExtractionResult>;
@@ -1,14 +1,3 @@
1
- /**
2
- * Extractor orchestrator.
3
- *
4
- * Walks the customer's repo, dispatches matched files to per-language
5
- * adapters, merges their findings into a single ExtractionResult.
6
- *
7
- * Adapters register their own file extensions + manifest filenames; the
8
- * walker only reads files those filters claim. So adding a Go or Python
9
- * adapter doesn't change anything here — register the adapter and the
10
- * orchestrator picks up its files.
11
- */
12
1
  import * as path from "node:path";
13
2
  import { walk } from "./walker.js";
14
3
  import { typescriptAdapter } from "./adapters/typescript/index.js";
@@ -25,7 +14,6 @@ export async function runExtractor(opts) {
25
14
  const adapters = opts.languages
26
15
  ? ADAPTERS.filter((a) => opts.languages.includes(a.language))
27
16
  : ADAPTERS;
28
- // Aggregate the file filters from each adapter so we walk the tree once.
29
17
  const extensions = new Set();
30
18
  const manifests = new Set();
31
19
  for (const a of adapters) {
@@ -104,4 +92,3 @@ function dedupeExternalServices(items) {
104
92
  }
105
93
  return [...out.values()];
106
94
  }
107
- //# sourceMappingURL=index.js.map
@@ -1,29 +1,3 @@
1
- /**
2
- * Extractor output schema.
3
- *
4
- * Matches `THREAT-MODEL-PHASE-J.md`'s J.2 output shape, with additions
5
- * for privacy-audit metadata. The shape is the contract between the CLI
6
- * and the eventual `--apply` endpoint that maps into ThreatModelComponent
7
- * / OrgComponent records (RECON.3-gated).
8
- *
9
- * Privacy invariant — what's IN the JSON:
10
- * component names ("auth-service")
11
- * file paths ("src/auth/login.ts")
12
- * line numbers (42)
13
- * framework + SDK identifiers ("express", "@anthropic-ai/sdk")
14
- * detected protocols / methods (POST /login)
15
- * dependency versions (from package.json / go.mod / pyproject.toml)
16
- *
17
- * What's NOT:
18
- * function bodies, file contents, code snippets
19
- * variable names from inside functions
20
- * comments
21
- * raw AST nodes
22
- *
23
- * `zivis tm extract --privacy-audit` prints this whole object to stdout
24
- * before any network call, so the customer can see exactly what would
25
- * be sent.
26
- */
27
1
  export type Language = "typescript" | "javascript" | "go" | "python";
28
2
  export interface EvidenceLocation {
29
3
  file: string;
@@ -44,21 +18,16 @@ export interface ConfigEvidence extends EvidenceLocation {
44
18
  export type Evidence = HttpRouteEvidence | ImportEvidence | ConfigEvidence;
45
19
  export type ComponentKind = "process" | "data_store" | "external_service" | "frontend";
46
20
  export interface ExtractedComponent {
47
- /** Stable name derived from path / module — never a value from inside a function. */
48
21
  name: string;
49
22
  kind: ComponentKind;
50
23
  language: Language;
51
- /** Detected web framework, if any (express | fastify | nextjs | trpc | hono | gin | echo | …). */
52
24
  framework?: string;
53
25
  sourceFiles: string[];
54
26
  evidence: Evidence[];
55
27
  }
56
28
  export interface ExtractedExternalService {
57
- /** Vendor / SDK name — "Anthropic", "OpenAI", "WorkOS". */
58
29
  name: string;
59
- /** What kind of integration: ai_sdk, payments, auth, observability, etc. */
60
30
  kind: string;
61
- /** npm/PyPI/Go module identifier ("@anthropic-ai/sdk"). */
62
31
  package: string;
63
32
  version?: string;
64
33
  callSites: EvidenceLocation[];
@@ -84,30 +53,16 @@ export interface ExtractionResult {
84
53
  components: ExtractedComponent[];
85
54
  externalServices: ExtractedExternalService[];
86
55
  dataStores: ExtractedDataStore[];
87
- /**
88
- * Per-language manifests detected in the scope. Surfaces dependency-only
89
- * findings (e.g., "this repo uses @anthropic-ai/sdk@^0.30") even when
90
- * we can't yet match call sites.
91
- */
92
56
  manifests: ManifestSummary[];
93
57
  }
94
58
  export interface ManifestSummary {
95
59
  language: Language;
96
60
  file: string;
97
- /** Direct dependency names → version (verbatim from manifest). */
98
61
  dependencies: Record<string, string>;
99
62
  }
100
- /**
101
- * Adapter contract — one per language. Each adapter is fed the list of
102
- * source files matched for it (already filtered by .gitignore + .zivisignore)
103
- * plus any manifest files (package.json, go.mod, pyproject.toml). Returns
104
- * structured findings the framework merges into the final ExtractionResult.
105
- */
106
63
  export interface LanguageAdapter {
107
64
  language: Language;
108
- /** File extensions this adapter handles. */
109
65
  extensions: string[];
110
- /** Manifest filenames this adapter cares about. */
111
66
  manifests: string[];
112
67
  extract(input: AdapterInput): Promise<AdapterOutput>;
113
68
  }
@@ -1,28 +1 @@
1
- /**
2
- * Extractor output schema.
3
- *
4
- * Matches `THREAT-MODEL-PHASE-J.md`'s J.2 output shape, with additions
5
- * for privacy-audit metadata. The shape is the contract between the CLI
6
- * and the eventual `--apply` endpoint that maps into ThreatModelComponent
7
- * / OrgComponent records (RECON.3-gated).
8
- *
9
- * Privacy invariant — what's IN the JSON:
10
- * component names ("auth-service")
11
- * file paths ("src/auth/login.ts")
12
- * line numbers (42)
13
- * framework + SDK identifiers ("express", "@anthropic-ai/sdk")
14
- * detected protocols / methods (POST /login)
15
- * dependency versions (from package.json / go.mod / pyproject.toml)
16
- *
17
- * What's NOT:
18
- * function bodies, file contents, code snippets
19
- * variable names from inside functions
20
- * comments
21
- * raw AST nodes
22
- *
23
- * `zivis tm extract --privacy-audit` prints this whole object to stdout
24
- * before any network call, so the customer can see exactly what would
25
- * be sent.
26
- */
27
1
  export {};
28
- //# sourceMappingURL=types.js.map
@@ -1,24 +1,7 @@
1
- /**
2
- * Filesystem walker — yields source files relative to the scan root,
3
- * filtered by .gitignore + .zivisignore + per-extractor extension filters.
4
- *
5
- * Uses the `ignore` npm package (the same engine git ships with) so the
6
- * matching semantics mirror what developers expect from .gitignore.
7
- *
8
- * Hard limits:
9
- * - Skips node_modules, dist, build, .next, .git, .yarn, vendor — even
10
- * if not in .gitignore. These exist by convention and contain
11
- * third-party code that pollutes the inventory.
12
- * - Caps total files at 50_000 to refuse to scan a generated monorepo
13
- * by accident (extractor would take forever; user should narrow scope).
14
- */
15
1
  export interface WalkOptions {
16
2
  rootDir: string;
17
- /** Extensions to include (with the leading dot, e.g. [".ts", ".tsx"]). */
18
3
  extensions: string[];
19
- /** Manifest basenames to capture regardless of extension (e.g. ["package.json"]). */
20
4
  manifests: string[];
21
- /** Extra ignore patterns from --ignore CLI flags. */
22
5
  extraIgnores?: string[];
23
6
  }
24
7
  export interface WalkResult {
@@ -28,5 +11,4 @@ export interface WalkResult {
28
11
  filesSkipped: number;
29
12
  }
30
13
  export declare function walk(opts: WalkOptions): Promise<WalkResult>;
31
- /** Convert an absolute path to a posix-style repo-relative path. */
32
14
  export declare function repoRelative(rootDir: string, absPath: string): string;
@@ -1,17 +1,3 @@
1
- /**
2
- * Filesystem walker — yields source files relative to the scan root,
3
- * filtered by .gitignore + .zivisignore + per-extractor extension filters.
4
- *
5
- * Uses the `ignore` npm package (the same engine git ships with) so the
6
- * matching semantics mirror what developers expect from .gitignore.
7
- *
8
- * Hard limits:
9
- * - Skips node_modules, dist, build, .next, .git, .yarn, vendor — even
10
- * if not in .gitignore. These exist by convention and contain
11
- * third-party code that pollutes the inventory.
12
- * - Caps total files at 50_000 to refuse to scan a generated monorepo
13
- * by accident (extractor would take forever; user should narrow scope).
14
- */
15
1
  import * as fs from "node:fs/promises";
16
2
  import * as path from "node:path";
17
3
  import ignore from "ignore";
@@ -64,7 +50,6 @@ export async function walk(opts) {
64
50
  filesSkipped++;
65
51
  continue;
66
52
  }
67
- // ignore() expects gitignore-style paths with trailing /
68
53
  if (ig.ignores(childRel + "/")) {
69
54
  filesSkipped++;
70
55
  continue;
@@ -99,12 +84,9 @@ async function loadIgnoreFile(ig, filePath) {
99
84
  ig.add(content);
100
85
  }
101
86
  catch {
102
- // No ignore file — fine.
103
87
  }
104
88
  }
105
- /** Convert an absolute path to a posix-style repo-relative path. */
106
89
  export function repoRelative(rootDir, absPath) {
107
90
  const rel = path.relative(rootDir, absPath);
108
91
  return rel.split(path.sep).join("/");
109
92
  }
110
- //# sourceMappingURL=walker.js.map
@@ -0,0 +1,7 @@
1
+ import type { ZivisConfig } from "@zivis/mcp/types";
2
+ export interface BuildLinkagePromptOpts {
3
+ config: ZivisConfig;
4
+ applicationId?: string;
5
+ style?: "short" | "full";
6
+ }
7
+ export declare function buildLinkagePrompt(opts: BuildLinkagePromptOpts): Promise<string | null>;
@@ -0,0 +1,95 @@
1
+ import { resolveAuth } from "@zivis/mcp/auth";
2
+ export async function buildLinkagePrompt(opts) {
3
+ const creds = await resolveAuth(opts.config);
4
+ if (creds.method === "none")
5
+ return null;
6
+ const appStatus = await fetchGitHubAppStatus(opts.config, creds);
7
+ if (!appStatus)
8
+ return null;
9
+ if (!appStatus.installed) {
10
+ if (!appStatus.installUrl)
11
+ return null;
12
+ return formatInstallPrompt(appStatus.installUrl, opts.style ?? "full");
13
+ }
14
+ if (opts.applicationId) {
15
+ const repoStatus = await fetchAppRepoStatus(opts.config, creds, opts.applicationId);
16
+ if (repoStatus && !repoStatus.linked) {
17
+ return formatLinkRepoPrompt(opts.config, opts.applicationId, opts.style ?? "full");
18
+ }
19
+ }
20
+ return null;
21
+ }
22
+ async function fetchGitHubAppStatus(config, creds) {
23
+ try {
24
+ const res = await fetch(`${config.apiBaseUrl}/api/github-app/status`, {
25
+ headers: authHeaders(creds),
26
+ });
27
+ if (!res.ok)
28
+ return null;
29
+ return (await res.json());
30
+ }
31
+ catch {
32
+ return null;
33
+ }
34
+ }
35
+ async function fetchAppRepoStatus(config, creds, applicationId) {
36
+ try {
37
+ const res = await fetch(`${config.apiBaseUrl}/api/applications/${encodeURIComponent(applicationId)}/repos/status`, { headers: authHeaders(creds) });
38
+ if (!res.ok)
39
+ return null;
40
+ return (await res.json());
41
+ }
42
+ catch {
43
+ return null;
44
+ }
45
+ }
46
+ function authHeaders(creds) {
47
+ const base = {
48
+ "Content-Type": "application/json",
49
+ "User-Agent": "@zivis/cli",
50
+ };
51
+ if (creds.method === "oauth" && creds.accessToken) {
52
+ base.Authorization = `Bearer ${creds.accessToken}`;
53
+ }
54
+ else if (creds.method === "apikey" && creds.apiKey) {
55
+ base["X-API-Key"] = creds.apiKey;
56
+ }
57
+ return base;
58
+ }
59
+ function formatInstallPrompt(installUrl, style) {
60
+ if (style === "short") {
61
+ return `Next: install the ZIVIS GitHub App — ${installUrl}`;
62
+ }
63
+ return [
64
+ "",
65
+ "Next: install the ZIVIS GitHub App",
66
+ ` ${installUrl}`,
67
+ " Enables continuous monitoring + automatic threat-model updates on push.",
68
+ ].join("\n");
69
+ }
70
+ function formatLinkRepoPrompt(config, applicationId, style) {
71
+ const appBase = process.env.ZIVIS_APP_URL || guessAppUrlFromApi(config.apiBaseUrl);
72
+ const url = `${appBase}/applications/${applicationId}`;
73
+ if (style === "short") {
74
+ return `Next: link a GitHub repo to this application — ${url}`;
75
+ }
76
+ return [
77
+ "",
78
+ "Next: link a GitHub repo to this application",
79
+ ` ${url}`,
80
+ " The GitHub App is installed but this app has no linked repo yet.",
81
+ ].join("\n");
82
+ }
83
+ function guessAppUrlFromApi(apiBaseUrl) {
84
+ try {
85
+ const u = new URL(apiBaseUrl);
86
+ if (u.host.startsWith("api.")) {
87
+ u.host = "app." + u.host.slice(4);
88
+ return `${u.protocol}//${u.host}`;
89
+ }
90
+ return apiBaseUrl;
91
+ }
92
+ catch {
93
+ return "https://app.zivis.ai";
94
+ }
95
+ }
@@ -1,7 +1,16 @@
1
- export declare function setupCursor(session?: string): Promise<void>;
2
- export declare function setupVsCodeCopilot(session?: string): Promise<void>;
3
- export declare function setupVsCodeClaude(session?: string): Promise<void>;
4
- export declare function setupClaudeCodeCli(session?: string): Promise<void>;
5
- export declare function setupCline(session?: string): Promise<void>;
6
- export declare function setupWindsurf(session?: string): Promise<void>;
7
- export declare function printClaudeCodeManual(session?: string): void;
1
+ export type Package = "appsec" | "builder";
2
+ export type GuidanceClient = "cursor" | "claude-code-cli" | "vscode-copilot" | "vscode-claude" | "cline" | "windsurf";
3
+ export interface GuidanceOptions {
4
+ cwd: string;
5
+ client: GuidanceClient;
6
+ }
7
+ export declare function writeGuidance(opts: GuidanceOptions): string[];
8
+ export declare function detectIdesInRepo(cwd: string): GuidanceClient[];
9
+ export declare function setupCursor(pkg?: Package): Promise<void>;
10
+ export declare function setupCursorWorkspace(pkg?: Package): Promise<void>;
11
+ export declare function setupVsCodeCopilot(pkg?: Package): Promise<void>;
12
+ export declare function setupVsCodeClaude(pkg?: Package): Promise<void>;
13
+ export declare function setupClaudeCodeCli(pkg?: Package): Promise<void>;
14
+ export declare function setupCline(pkg?: Package): Promise<void>;
15
+ export declare function setupWindsurf(pkg?: Package): Promise<void>;
16
+ export declare function printClaudeCodeManual(pkg?: Package): void;