@zivis/cli 0.1.0-alpha.34 → 0.1.0-alpha.36

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 (135) 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 +0 -12
  5. package/dist/commands/auth/bind.d.ts +0 -10
  6. package/dist/commands/auth/bind.js +0 -11
  7. package/dist/commands/auth/index.js +0 -1
  8. package/dist/commands/auth/init.js +0 -19
  9. package/dist/commands/auth/login.d.ts +0 -1
  10. package/dist/commands/auth/login.js +0 -6
  11. package/dist/commands/auth/logout.js +0 -3
  12. package/dist/commands/auth/sessions.js +0 -1
  13. package/dist/commands/auth/status.js +0 -2
  14. package/dist/commands/auth/token.d.ts +0 -13
  15. package/dist/commands/auth/token.js +0 -18
  16. package/dist/commands/check/index.d.ts +0 -18
  17. package/dist/commands/check/index.js +1 -37
  18. package/dist/commands/credits/index.js +0 -1
  19. package/dist/commands/inspect/index.d.ts +0 -15
  20. package/dist/commands/inspect/index.js +0 -23
  21. package/dist/commands/mcp/index.js +0 -9
  22. package/dist/commands/open/index.d.ts +0 -8
  23. package/dist/commands/open/index.js +0 -11
  24. package/dist/commands/scan/index.js +0 -6
  25. package/dist/commands/target/index.js +0 -3
  26. package/dist/commands/tm/index.js +0 -7
  27. package/dist/index.js +9 -1
  28. package/dist/internal/binding-token-mint.d.ts +0 -29
  29. package/dist/internal/binding-token-mint.js +0 -28
  30. package/dist/internal/extractor/adapters/go/index.d.ts +0 -4
  31. package/dist/internal/extractor/adapters/go/index.js +0 -6
  32. package/dist/internal/extractor/adapters/go/manifest.d.ts +0 -17
  33. package/dist/internal/extractor/adapters/go/manifest.js +1 -25
  34. package/dist/internal/extractor/adapters/go/parser.d.ts +0 -4
  35. package/dist/internal/extractor/adapters/go/parser.js +0 -5
  36. package/dist/internal/extractor/adapters/go/scanner.d.ts +0 -20
  37. package/dist/internal/extractor/adapters/go/scanner.js +0 -43
  38. package/dist/internal/extractor/adapters/python/index.d.ts +0 -3
  39. package/dist/internal/extractor/adapters/python/index.js +0 -4
  40. package/dist/internal/extractor/adapters/python/manifest.d.ts +0 -8
  41. package/dist/internal/extractor/adapters/python/manifest.js +3 -18
  42. package/dist/internal/extractor/adapters/python/parser.d.ts +0 -3
  43. package/dist/internal/extractor/adapters/python/parser.js +0 -4
  44. package/dist/internal/extractor/adapters/python/scanner.d.ts +0 -18
  45. package/dist/internal/extractor/adapters/python/scanner.js +1 -54
  46. package/dist/internal/extractor/adapters/typescript/index.d.ts +0 -7
  47. package/dist/internal/extractor/adapters/typescript/index.js +1 -21
  48. package/dist/internal/extractor/adapters/typescript/manifest.d.ts +0 -14
  49. package/dist/internal/extractor/adapters/typescript/manifest.js +1 -20
  50. package/dist/internal/extractor/adapters/typescript/parser.d.ts +0 -8
  51. package/dist/internal/extractor/adapters/typescript/parser.js +0 -9
  52. package/dist/internal/extractor/adapters/typescript/scanner.d.ts +0 -24
  53. package/dist/internal/extractor/adapters/typescript/scanner.js +0 -43
  54. package/dist/internal/extractor/graph-builder.d.ts +0 -25
  55. package/dist/internal/extractor/graph-builder.js +1 -39
  56. package/dist/internal/extractor/graph-types.d.ts +0 -10
  57. package/dist/internal/extractor/graph-types.js +0 -11
  58. package/dist/internal/extractor/index.d.ts +0 -14
  59. package/dist/internal/extractor/index.js +0 -13
  60. package/dist/internal/extractor/types.d.ts +0 -45
  61. package/dist/internal/extractor/types.js +0 -27
  62. package/dist/internal/extractor/walker.d.ts +0 -18
  63. package/dist/internal/extractor/walker.js +0 -18
  64. package/dist/internal/github-linkage-prompt.d.ts +0 -19
  65. package/dist/internal/github-linkage-prompt.js +1 -27
  66. package/dist/internal/ide-setup.d.ts +0 -23
  67. package/dist/internal/ide-setup.js +0 -53
  68. package/dist/internal/orgs.js +0 -1
  69. package/dist/internal/project-binding.d.ts +0 -1
  70. package/dist/internal/project-binding.js +0 -5
  71. package/dist/internal/target-auth/api-config.d.ts +0 -17
  72. package/dist/internal/target-auth/api-config.js +0 -18
  73. package/dist/internal/target-auth/config.d.ts +0 -12
  74. package/dist/internal/target-auth/config.js +0 -13
  75. package/dist/internal/target-auth/index.d.ts +0 -18
  76. package/dist/internal/target-auth/index.js +0 -19
  77. package/dist/internal/target-auth/keychain.d.ts +0 -18
  78. package/dist/internal/target-auth/keychain.js +3 -23
  79. package/dist/internal/target-auth/types.d.ts +0 -26
  80. package/dist/internal/target-auth/types.js +0 -10
  81. package/dist/internal/target-auth/workos.d.ts +0 -15
  82. package/dist/internal/target-auth/workos.js +0 -17
  83. package/package.json +22 -13
  84. package/dist/commands/app/index.js.map +0 -1
  85. package/dist/commands/auth/bind.js.map +0 -1
  86. package/dist/commands/auth/index.js.map +0 -1
  87. package/dist/commands/auth/init.js.map +0 -1
  88. package/dist/commands/auth/login.js.map +0 -1
  89. package/dist/commands/auth/logout.js.map +0 -1
  90. package/dist/commands/auth/sessions.js.map +0 -1
  91. package/dist/commands/auth/status.js.map +0 -1
  92. package/dist/commands/auth/token.js.map +0 -1
  93. package/dist/commands/check/index.js.map +0 -1
  94. package/dist/commands/credits/index.js.map +0 -1
  95. package/dist/commands/inspect/index.js.map +0 -1
  96. package/dist/commands/mcp/index.js.map +0 -1
  97. package/dist/commands/open/index.js.map +0 -1
  98. package/dist/commands/scan/index.js.map +0 -1
  99. package/dist/commands/target/index.js.map +0 -1
  100. package/dist/commands/tm/index.js.map +0 -1
  101. package/dist/index.js.map +0 -1
  102. package/dist/internal/binding-token-mint.js.map +0 -1
  103. package/dist/internal/extractor/adapters/go/index.js.map +0 -1
  104. package/dist/internal/extractor/adapters/go/manifest.js.map +0 -1
  105. package/dist/internal/extractor/adapters/go/parser.js.map +0 -1
  106. package/dist/internal/extractor/adapters/go/scanner.js.map +0 -1
  107. package/dist/internal/extractor/adapters/python/index.js.map +0 -1
  108. package/dist/internal/extractor/adapters/python/manifest.js.map +0 -1
  109. package/dist/internal/extractor/adapters/python/parser.js.map +0 -1
  110. package/dist/internal/extractor/adapters/python/scanner.js.map +0 -1
  111. package/dist/internal/extractor/adapters/typescript/index.js.map +0 -1
  112. package/dist/internal/extractor/adapters/typescript/manifest.js.map +0 -1
  113. package/dist/internal/extractor/adapters/typescript/parser.js.map +0 -1
  114. package/dist/internal/extractor/adapters/typescript/scanner.js.map +0 -1
  115. package/dist/internal/extractor/graph-builder.js.map +0 -1
  116. package/dist/internal/extractor/graph-types.js.map +0 -1
  117. package/dist/internal/extractor/index.js.map +0 -1
  118. package/dist/internal/extractor/types.js.map +0 -1
  119. package/dist/internal/extractor/walker.js.map +0 -1
  120. package/dist/internal/github-linkage-prompt.js.map +0 -1
  121. package/dist/internal/ide-setup.js.map +0 -1
  122. package/dist/internal/orgs.js.map +0 -1
  123. package/dist/internal/pattern-pack/index.d.ts +0 -123
  124. package/dist/internal/pattern-pack/index.js +0 -230
  125. package/dist/internal/pattern-pack/index.js.map +0 -1
  126. package/dist/internal/project-binding.js.map +0 -1
  127. package/dist/internal/target-auth/api-config.js.map +0 -1
  128. package/dist/internal/target-auth/config.js.map +0 -1
  129. package/dist/internal/target-auth/index.js.map +0 -1
  130. package/dist/internal/target-auth/keychain.js.map +0 -1
  131. package/dist/internal/target-auth/types.js.map +0 -1
  132. package/dist/internal/target-auth/workos.js.map +0 -1
  133. package/dist/pattern-packs/zivis-public-0.1.0/capsules/agents/privilege-separation.yaml +0 -228
  134. package/dist/pattern-packs/zivis-public-0.1.0/manifest.json +0 -31
  135. package/dist/pattern-packs/zivis-public-0.1.0/prompts/agents/privilege-separation/identify.md +0 -54
@@ -1,17 +1,2 @@
1
- /**
2
- * `zivis inspect` — local repo graph extraction.
3
- *
4
- * Walks the repo with the existing extractor, converts the result into a
5
- * RepoGraphArtifactV1 (the canonical contract), and writes it to the
6
- * user-level cache. This is the user-facing entrypoint for Phase 1 of the
7
- * local repo graph + pattern library work.
8
- *
9
- * Plan: docs/plans/LOCAL-REPO-GRAPH-IMPLEMENTATION.md
10
- * Schema: schemas/repo-graph-artifact.schema.json
11
- *
12
- * The command is local-only and never makes network calls. Persistence to
13
- * the platform happens in a separate step (Phase 4 — `/inspect` upload),
14
- * gated on Application mapping resolution per plan §Repo->Application Mapping.
15
- */
16
1
  import type { Command } from "commander";
17
2
  export declare function registerInspectCommands(program: Command): void;
@@ -1,18 +1,3 @@
1
- /**
2
- * `zivis inspect` — local repo graph extraction.
3
- *
4
- * Walks the repo with the existing extractor, converts the result into a
5
- * RepoGraphArtifactV1 (the canonical contract), and writes it to the
6
- * user-level cache. This is the user-facing entrypoint for Phase 1 of the
7
- * local repo graph + pattern library work.
8
- *
9
- * Plan: docs/plans/LOCAL-REPO-GRAPH-IMPLEMENTATION.md
10
- * Schema: schemas/repo-graph-artifact.schema.json
11
- *
12
- * The command is local-only and never makes network calls. Persistence to
13
- * the platform happens in a separate step (Phase 4 — `/inspect` upload),
14
- * gated on Application mapping resolution per plan §Repo->Application Mapping.
15
- */
16
1
  import * as crypto from "node:crypto";
17
2
  import * as fs from "node:fs/promises";
18
3
  import * as os from "node:os";
@@ -115,12 +100,6 @@ function deriveRepoId(remoteUrl, rootDir) {
115
100
  function sha256Short(value) {
116
101
  return crypto.createHash("sha256").update(value).digest("hex").slice(0, 16);
117
102
  }
118
- /**
119
- * XDG-compliant user cache root. Layout follows the plan §2A:
120
- * macOS: ~/Library/Caches/zivis
121
- * Linux: $XDG_CACHE_HOME/zivis (or ~/.cache/zivis)
122
- * Windows: %LOCALAPPDATA%\zivis\Cache
123
- */
124
103
  function userCacheRoot() {
125
104
  const home = os.homedir();
126
105
  if (process.platform === "darwin") {
@@ -138,7 +117,6 @@ function defaultCacheOutPath(repoId, commitSha, extractedAt) {
138
117
  return path.join(userCacheRoot(), "repos", repoId, "inspect", "runs", `${runId}.json`);
139
118
  }
140
119
  function formatRunId(commitSha, extractedAt) {
141
- // <short-commit>-<compact-iso> e.g. abc1234-20260505T201600Z
142
120
  const compactTs = extractedAt.replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
143
121
  if (!commitSha)
144
122
  return `nogit-${compactTs}`;
@@ -156,4 +134,3 @@ function printSummary(artifact, suffix) {
156
134
  ` ${artifact.edges.length} edges (${exposes} exposes, ${dependsOn} depends_on)\n` +
157
135
  (suffix ? ` ${suffix}\n` : ""));
158
136
  }
159
- //# sourceMappingURL=index.js.map
@@ -12,10 +12,6 @@ const KNOWN_CLIENTS = [
12
12
  "vscode-copilot",
13
13
  "vscode-claude",
14
14
  ];
15
- /**
16
- * Map the CLI --client value to the GuidanceClient type used by writeGuidance().
17
- * "claude-code" (manual) has no guidance files — skip it.
18
- */
19
15
  function toGuidanceClient(client) {
20
16
  switch (client) {
21
17
  case "cursor": return "cursor";
@@ -97,23 +93,19 @@ export function registerMcpCommands(program) {
97
93
  console.error("Install failed:", err instanceof Error ? err.message : err);
98
94
  process.exit(1);
99
95
  }
100
- // "claude-code" is manual — no guidance files to write
101
96
  if (client === "claude-code")
102
97
  return;
103
98
  const guidanceClient = toGuidanceClient(client);
104
99
  if (!guidanceClient)
105
100
  return;
106
- // Determine whether to write guidance files
107
101
  let shouldWrite;
108
102
  if (opts.withGuidance) {
109
103
  shouldWrite = true;
110
104
  }
111
105
  else if (opts.guidance === false) {
112
- // Commander sets opts.guidance = false when --no-guidance is passed
113
106
  shouldWrite = false;
114
107
  }
115
108
  else {
116
- // Interactive default
117
109
  console.log("");
118
110
  shouldWrite = await promptYesNo("Write ZIVIS guidance files so your IDE knows when to suggest security checks?\n" +
119
111
  "(Adds a rule/instruction file to the project. You can edit or remove it anytime.) [Y/n] ");
@@ -133,4 +125,3 @@ export function registerMcpCommands(program) {
133
125
  }
134
126
  });
135
127
  }
136
- //# sourceMappingURL=index.js.map
@@ -1,10 +1,2 @@
1
- /**
2
- * `zivis open` — Build and (by default) launch a vscode:// or cursor:// deep link
3
- * that opens a ZIVIS artifact in the ZIVIS Code IDE extension. Use `--ide cursor`
4
- * for Cursor. With --print, emit the URI to stdout for piping/sharing.
5
- *
6
- * Mirrors the URI shape emitted by the `zivis_open_in_ide` MCP tool and the
7
- * web app's buildIdeLink() helper. See docs/platform/integrations/IDE-DEEP-LINKS.md.
8
- */
9
1
  import type { Command } from "commander";
10
2
  export declare function registerOpenCommands(program: Command): void;
@@ -1,11 +1,3 @@
1
- /**
2
- * `zivis open` — Build and (by default) launch a vscode:// or cursor:// deep link
3
- * that opens a ZIVIS artifact in the ZIVIS Code IDE extension. Use `--ide cursor`
4
- * for Cursor. With --print, emit the URI to stdout for piping/sharing.
5
- *
6
- * Mirrors the URI shape emitted by the `zivis_open_in_ide` MCP tool and the
7
- * web app's buildIdeLink() helper. See docs/platform/integrations/IDE-DEEP-LINKS.md.
8
- */
9
1
  const KINDS = ["diagram", "document", "threat-model"];
10
2
  export function registerOpenCommands(program) {
11
3
  program
@@ -47,11 +39,8 @@ export function registerOpenCommands(program) {
47
39
  console.log(uri);
48
40
  return;
49
41
  }
50
- // Lazy-import `open` so --print stays dependency-free in environments
51
- // (e.g. headless CI) where launching a URL handler would fail or hang.
52
42
  const { default: open } = await import("open");
53
43
  await open(uri);
54
44
  console.log(uri);
55
45
  });
56
46
  }
57
- //# sourceMappingURL=index.js.map
@@ -118,11 +118,6 @@ export function registerScanCommands(program) {
118
118
  }
119
119
  });
120
120
  }
121
- /**
122
- * Map customer-facing ApplicationType to the RT scan's targetType enum.
123
- * The two enums differ historically: ApplicationType is product-shape,
124
- * targetType is what the RT runner needs to know about the wire format.
125
- */
126
121
  function appTypeToTargetType(appType) {
127
122
  switch (appType) {
128
123
  case "agent":
@@ -137,4 +132,3 @@ function appTypeToTargetType(appType) {
137
132
  return undefined;
138
133
  }
139
134
  }
140
- //# sourceMappingURL=index.js.map
@@ -4,8 +4,6 @@ import { getStorageName } from "../../internal/target-auth/keychain.js";
4
4
  import { decodeJwtPayload } from "../../internal/target-auth/workos.js";
5
5
  const DEFAULT_PERSONA = "default";
6
6
  function warnDeprecated() {
7
- // stderr so it doesn't pollute stdout (CLI scripts pipe `zivis target token`
8
- // straight into curl). One line, no color codes — keeps grep-friendly.
9
7
  console.error("[zivis] WARNING: 'zivis target' is deprecated; use 'zivis app' instead.");
10
8
  }
11
9
  export function registerTargetCommands(program) {
@@ -143,4 +141,3 @@ export function registerTargetCommands(program) {
143
141
  console.log(`✓ Cleared tokens for target ${targetId} (persona: ${opts.persona})`);
144
142
  });
145
143
  }
146
- //# sourceMappingURL=index.js.map
@@ -14,7 +14,6 @@ function collect(value, previous) {
14
14
  return previous.concat([value]);
15
15
  }
16
16
  function defaultOutPath(extractedAt) {
17
- // .zivis/extracted/<iso-no-colons>.json — matches the doc's example.
18
17
  const ts = extractedAt.replace(/[:.]/g, "-");
19
18
  return `.zivis/extracted/${ts}.json`;
20
19
  }
@@ -80,9 +79,6 @@ export function registerTmCommands(program) {
80
79
  process.exit(1);
81
80
  });
82
81
  const parsed = JSON.parse(raw);
83
- // Only fields the PATCH endpoint accepts. tm pull dumps the full
84
- // record; tm push only sends the editable subset, so a round-trip
85
- // edit cycle Just Works.
86
82
  const payload = {};
87
83
  for (const k of ["name", "description", "status", "campaignId"]) {
88
84
  if (parsed[k] !== undefined)
@@ -123,8 +119,6 @@ export function registerTmCommands(program) {
123
119
  extractorVersion: cliPkg.version,
124
120
  });
125
121
  if (opts.privacyAudit) {
126
- // Prints the entire object that WOULD be sent to ZIVIS via --apply.
127
- // Never makes a network call; the extractor itself is local-only.
128
122
  process.stdout.write(JSON.stringify(result, null, 2) + "\n");
129
123
  process.stderr.write(`\n[zivis] Privacy audit: ${result.scope.filesScanned} files scanned, ` +
130
124
  `${result.components.length} component(s), ${result.externalServices.length} external service(s), ` +
@@ -263,4 +257,3 @@ export function registerTmCommands(program) {
263
257
  }
264
258
  });
265
259
  }
266
- //# sourceMappingURL=index.js.map
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import * as fs from "node:fs";
4
4
  import * as path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { registerAuthCommands } from "./commands/auth/index.js";
7
+ import { initCommand as authInitCommand } from "./commands/auth/init.js";
7
8
  import { registerAppCommands } from "./commands/app/index.js";
8
9
  import { registerTargetCommands } from "./commands/target/index.js";
9
10
  import { registerTmCommands } from "./commands/tm/index.js";
@@ -28,6 +29,14 @@ program
28
29
  .name("zivis")
29
30
  .description("ZIVIS CLI — threat modeling, scans, and MCP server")
30
31
  .version(getVersion(), "-v, --version", "show version");
32
+ program
33
+ .command("init")
34
+ .description("interactive setup: authenticate, pick org, and bind this repo (alias for `zivis auth init`)")
35
+ .option("-s, --session <name>", "named session for multi-tenant")
36
+ .option("--skip-mint-key", "skip MCP API key mint after successful OAuth")
37
+ .action(async (opts) => {
38
+ await authInitCommand(opts);
39
+ });
31
40
  registerAuthCommands(program);
32
41
  registerCheckCommands(program);
33
42
  registerAppCommands(program);
@@ -42,4 +51,3 @@ program.parseAsync(process.argv).catch((err) => {
42
51
  console.error(err instanceof Error ? err.message : err);
43
52
  process.exit(1);
44
53
  });
45
- //# sourceMappingURL=index.js.map
@@ -1,7 +1,3 @@
1
- /**
2
- * Mint a Local Project Binding Token via POST /api/auth/bind and store it as
3
- * apikey.<session>. Shared by `zivis auth bind` and post-login auto-mint.
4
- */
5
1
  import { type ZivisConfig } from "@zivis/mcp/types";
6
2
  export type MintBindingTokenResult = {
7
3
  ok: true;
@@ -13,10 +9,6 @@ export type MintBindingTokenResult = {
13
9
  ok: false;
14
10
  error: string;
15
11
  };
16
- /**
17
- * Calls the bind API with a fresh access JWT and persists the minted WorkOS API key.
18
- * Does not start OAuth nor update IDE configs.
19
- */
20
12
  export declare function mintLocalProjectBindingToken(params: {
21
13
  config: ZivisConfig;
22
14
  session: string;
@@ -27,35 +19,14 @@ export interface TryAutoMintOptions {
27
19
  cwd: string;
28
20
  sessionName: string;
29
21
  accessToken: string;
30
- /** Caller flag (e.g. `zivis auth login --no-mint-key`). */
31
22
  skip?: boolean;
32
- /**
33
- * When false (login after ensureProjectBinding): mint failures log a warning and return.
34
- * When true (`zivis auth bind`): caller should exit 1 if result not ok — not handled here.
35
- */
36
23
  warnOnFailure: boolean;
37
24
  }
38
- /**
39
- * After OAuth login finishes, mint an MCP-friendly API key if the repo is bound
40
- * and JWT org matches `.zivis/project.json`.
41
- * Skips if `apikey.<session>` already exists (avoid spawning keys on every login).
42
- */
43
25
  export declare function tryAutoMintBindingTokenAfterLogin(opts: TryAutoMintOptions): Promise<{
44
26
  ran: boolean;
45
27
  ok: boolean;
46
28
  message?: string;
47
29
  }>;
48
- /**
49
- * Drop the OAuth tokens stored under `oauth.<session>` (or `oauth` when no
50
- * session). OAuth exists only to mint the MCP API key — once login finishes,
51
- * MCP and tenant API calls go through `apikey.<session>`. Keeping the OAuth
52
- * tokens around adds attack surface and risks org-drift if the refresh token
53
- * outlives the binding.
54
- *
55
- * Verifies the delete actually emptied the keychain before returning — macOS
56
- * keychain access prompts can be denied without surfacing an error code, and
57
- * stale duplicates from older builds can mask a successful single delete.
58
- */
59
30
  export declare function discardOauthAfterLogin(params: {
60
31
  session: string | undefined;
61
32
  config: ZivisConfig;
@@ -1,7 +1,3 @@
1
- /**
2
- * Mint a Local Project Binding Token via POST /api/auth/bind and store it as
3
- * apikey.<session>. Shared by `zivis auth bind` and post-login auto-mint.
4
- */
5
1
  import * as os from "node:os";
6
2
  import * as crypto from "node:crypto";
7
3
  import * as child_process from "node:child_process";
@@ -9,7 +5,6 @@ import { getSessionAccount, keychainClearSession, keychainRead, keychainStore, }
9
5
  import { decodeJwtPayload } from "@zivis/mcp/auth/jwt";
10
6
  import { DEFAULT_CONFIG, credentialStorageFromConfig } from "@zivis/mcp/types";
11
7
  import { detectProjectBinding, resolveConfigFromBinding } from "@zivis/mcp/project-binding";
12
- /** Same fingerprint strategy as bind command — stable-ish per-repo key name suffix. */
13
8
  function getRepoFingerprint(cwd) {
14
9
  try {
15
10
  const remote = child_process
@@ -20,14 +15,9 @@ function getRepoFingerprint(cwd) {
20
15
  }
21
16
  }
22
17
  catch {
23
- /* no git or no remote */
24
18
  }
25
19
  return crypto.createHash("sha256").update(cwd).digest("hex").slice(0, 12);
26
20
  }
27
- /**
28
- * Calls the bind API with a fresh access JWT and persists the minted WorkOS API key.
29
- * Does not start OAuth nor update IDE configs.
30
- */
31
21
  export async function mintLocalProjectBindingToken(params) {
32
22
  const { config, session, accessToken, cwd } = params;
33
23
  const credentialStorage = credentialStorageFromConfig(config);
@@ -77,11 +67,6 @@ export async function mintLocalProjectBindingToken(params) {
77
67
  workosOrgId: bindResult.workosOrgId,
78
68
  };
79
69
  }
80
- /**
81
- * After OAuth login finishes, mint an MCP-friendly API key if the repo is bound
82
- * and JWT org matches `.zivis/project.json`.
83
- * Skips if `apikey.<session>` already exists (avoid spawning keys on every login).
84
- */
85
70
  export async function tryAutoMintBindingTokenAfterLogin(opts) {
86
71
  if (opts.skip) {
87
72
  return { ran: false, ok: true };
@@ -147,24 +132,12 @@ export async function tryAutoMintBindingTokenAfterLogin(opts) {
147
132
  console.log(`✓ MCP API key stored (${result.keyName}; org: ${result.orgName})`);
148
133
  return { ran: true, ok: true };
149
134
  }
150
- /**
151
- * Drop the OAuth tokens stored under `oauth.<session>` (or `oauth` when no
152
- * session). OAuth exists only to mint the MCP API key — once login finishes,
153
- * MCP and tenant API calls go through `apikey.<session>`. Keeping the OAuth
154
- * tokens around adds attack surface and risks org-drift if the refresh token
155
- * outlives the binding.
156
- *
157
- * Verifies the delete actually emptied the keychain before returning — macOS
158
- * keychain access prompts can be denied without surfacing an error code, and
159
- * stale duplicates from older builds can mask a successful single delete.
160
- */
161
135
  export async function discardOauthAfterLogin(params) {
162
136
  const storage = credentialStorageFromConfig(params.config);
163
137
  try {
164
138
  await keychainClearSession(params.session, storage);
165
139
  }
166
140
  catch {
167
- /* No-op — see verify step below. */
168
141
  }
169
142
  const leftover = await keychainRead(getSessionAccount(params.session), storage).catch(() => null);
170
143
  if (leftover) {
@@ -199,4 +172,3 @@ function printMintFailureBanner(message) {
199
172
  console.error(bar);
200
173
  console.error("");
201
174
  }
202
- //# sourceMappingURL=binding-token-mint.js.map
@@ -1,7 +1,3 @@
1
- /**
2
- * Go language adapter. Same shape as the TypeScript adapter — manifest
3
- * pass + AST pass — different parser + framework table.
4
- */
5
1
  import type { LanguageAdapter } from "../../types.js";
6
2
  export declare const goAdapter: LanguageAdapter;
7
3
  export declare const _stdlibFrameworkSet: Set<string>;
@@ -1,7 +1,3 @@
1
- /**
2
- * Go language adapter. Same shape as the TypeScript adapter — manifest
3
- * pass + AST pass — different parser + framework table.
4
- */
5
1
  import * as path from "node:path";
6
2
  import { readManifests, summarizeManifests, findExternalServices, findDataStores, detectFrameworkFromManifest, STDLIB_FRAMEWORKS, } from "./manifest.js";
7
3
  import { scanFile, aggregate } from "./scanner.js";
@@ -66,6 +62,4 @@ function frameworkFromOwningManifest(sourceFile, manifests) {
66
62
  .sort((a, b) => b.dir.length - a.dir.length);
67
63
  return candidates[0] ? detectFrameworkFromManifest(candidates[0].m) : undefined;
68
64
  }
69
- // Used by orchestrator-side typing to widen the language union if needed.
70
65
  export const _stdlibFrameworkSet = STDLIB_FRAMEWORKS;
71
- //# sourceMappingURL=index.js.map
@@ -1,14 +1,5 @@
1
- /**
2
- * Go manifest analysis.
3
- *
4
- * Parses go.mod (line-based, no real grammar needed) to build the
5
- * dependency map. Doesn't read go.sum — that's a hash list, not version
6
- * authority. Direct vs indirect deps are both in the require block;
7
- * we keep the // indirect annotation as a hint but don't filter on it.
8
- */
9
1
  import type { ExtractedExternalService, ExtractedDataStore, ManifestSummary } from "../../types.js";
10
2
  export declare const WEB_FRAMEWORK_MODULES: Record<string, string>;
11
- /** stdlib router lives at "net/http"; not in go.mod, only detected via imports. */
12
3
  export declare const STDLIB_FRAMEWORKS: Set<string>;
13
4
  export declare const DATA_STORE_MODULES: Record<string, {
14
5
  kind: ExtractedDataStore["kind"];
@@ -19,17 +10,9 @@ export interface ParsedGoMod {
19
10
  filePath: string;
20
11
  module?: string;
21
12
  goVersion?: string;
22
- /** module path → version. */
23
13
  deps: Record<string, string>;
24
14
  }
25
15
  export declare function readManifests(rootDir: string, manifestFiles: string[]): Promise<ParsedGoMod[]>;
26
- /**
27
- * Minimal go.mod parser. Supports the two block forms:
28
- * require modulePath v1.2.3
29
- * require ( modulePath v1.2.3 \n other v0.0.1 )
30
- * Strips trailing "// indirect" markers. Does NOT handle replace/exclude
31
- * directives (out of scope for inventory).
32
- */
33
16
  export declare function parseGoMod(filePath: string, rootDir: string, raw: string): ParsedGoMod;
34
17
  export declare function summarizeManifests(parsed: ParsedGoMod[]): ManifestSummary[];
35
18
  export declare function findExternalServices(parsed: ParsedGoMod[]): ExtractedExternalService[];
@@ -1,11 +1,3 @@
1
- /**
2
- * Go manifest analysis.
3
- *
4
- * Parses go.mod (line-based, no real grammar needed) to build the
5
- * dependency map. Doesn't read go.sum — that's a hash list, not version
6
- * authority. Direct vs indirect deps are both in the require block;
7
- * we keep the // indirect annotation as a hint but don't filter on it.
8
- */
9
1
  import * as fs from "node:fs/promises";
10
2
  import * as path from "node:path";
11
3
  export const WEB_FRAMEWORK_MODULES = {
@@ -18,14 +10,13 @@ export const WEB_FRAMEWORK_MODULES = {
18
10
  "github.com/gofiber/fiber/v2": "fiber",
19
11
  "github.com/gorilla/mux": "gorilla-mux",
20
12
  };
21
- /** stdlib router lives at "net/http"; not in go.mod, only detected via imports. */
22
13
  export const STDLIB_FRAMEWORKS = new Set(["net/http"]);
23
14
  export const DATA_STORE_MODULES = {
24
15
  "github.com/jackc/pgx": { kind: "postgres", client: "pgx" },
25
16
  "github.com/jackc/pgx/v5": { kind: "postgres", client: "pgx" },
26
17
  "github.com/jackc/pgx/v4": { kind: "postgres", client: "pgx" },
27
18
  "github.com/lib/pq": { kind: "postgres", client: "pq" },
28
- "gorm.io/gorm": { kind: "postgres", client: "gorm" }, // dialect varies; gorm itself is most often pg
19
+ "gorm.io/gorm": { kind: "postgres", client: "gorm" },
29
20
  "go.mongodb.org/mongo-driver": { kind: "mongo", client: "mongo-driver" },
30
21
  "github.com/redis/go-redis": { kind: "redis", client: "go-redis" },
31
22
  "github.com/redis/go-redis/v9": { kind: "redis", client: "go-redis" },
@@ -48,18 +39,10 @@ export async function readManifests(rootDir, manifestFiles) {
48
39
  out.push(parseGoMod(file, rootDir, raw));
49
40
  }
50
41
  catch {
51
- // skip unreadable
52
42
  }
53
43
  }
54
44
  return out;
55
45
  }
56
- /**
57
- * Minimal go.mod parser. Supports the two block forms:
58
- * require modulePath v1.2.3
59
- * require ( modulePath v1.2.3 \n other v0.0.1 )
60
- * Strips trailing "// indirect" markers. Does NOT handle replace/exclude
61
- * directives (out of scope for inventory).
62
- */
63
46
  export function parseGoMod(filePath, rootDir, raw) {
64
47
  const lines = raw.split("\n");
65
48
  const result = {
@@ -92,7 +75,6 @@ export function parseGoMod(filePath, rootDir, raw) {
92
75
  body = body.slice("require ".length).trim();
93
76
  else if (!inBlock)
94
77
  continue;
95
- // Strip "// indirect" / other line comments
96
78
  const commentAt = body.indexOf("//");
97
79
  if (commentAt >= 0)
98
80
  body = body.slice(0, commentAt).trim();
@@ -184,14 +166,9 @@ export function detectFrameworkFromManifest(m) {
184
166
  }
185
167
  return undefined;
186
168
  }
187
- /**
188
- * Match a module path including its versioned variants (mod, mod/v2, etc.).
189
- * Returns the version of the first match.
190
- */
191
169
  function matchModuleVersion(deps, modulePath) {
192
170
  if (deps[modulePath])
193
171
  return deps[modulePath];
194
- // Try versioned variants
195
172
  for (const [k, v] of Object.entries(deps)) {
196
173
  if (k === modulePath)
197
174
  return v;
@@ -214,4 +191,3 @@ function relPosix(rootDir, abs) {
214
191
  const rel = path.relative(rootDir, abs);
215
192
  return rel.split(path.sep).join("/");
216
193
  }
217
- //# sourceMappingURL=manifest.js.map
@@ -1,6 +1,2 @@
1
- /**
2
- * tree-sitter-go loader. Lazy-init, reuses the same WASM directory as
3
- * the TypeScript adapter (both come from @vscode/tree-sitter-wasm).
4
- */
5
1
  import { Parser } from "web-tree-sitter";
6
2
  export declare function getGoParser(): Promise<Parser>;
@@ -1,7 +1,3 @@
1
- /**
2
- * tree-sitter-go loader. Lazy-init, reuses the same WASM directory as
3
- * the TypeScript adapter (both come from @vscode/tree-sitter-wasm).
4
- */
5
1
  import { createRequire } from "node:module";
6
2
  import * as path from "node:path";
7
3
  import { Parser, Language } from "web-tree-sitter";
@@ -20,4 +16,3 @@ export function getGoParser() {
20
16
  }
21
17
  return parserPromise;
22
18
  }
23
- //# sourceMappingURL=parser.js.map
@@ -1,23 +1,3 @@
1
- /**
2
- * AST scanner for Go source files.
3
- *
4
- * Walks tree-sitter-go for two things:
5
- *
6
- * 1. import declarations naming any tracked module (AI SDKs, web
7
- * frameworks, DB clients) → ImportEvidence
8
- * 2. HTTP route calls. Three flavors:
9
- * net/http : http.HandleFunc("/path", h)
10
- * chi : r.Get("/path", h), r.Post(…) (TitleCase)
11
- * echo/gin : e.GET("/path", h), r.POST(…) (UPPER)
12
- * fiber : app.Get("/path", h), app.Post(…) (TitleCase)
13
- *
14
- * Method-name normalization happens after we identify the call-shape;
15
- * output is always UPPERCASE in the JSON.
16
- *
17
- * Privacy invariant: same as the TS adapter — only identifier names,
18
- * file paths, line numbers, package paths, and route method/path strings.
19
- * Function bodies are never read.
20
- */
21
1
  import type { EvidenceLocation, Evidence, HttpRouteEvidence, ImportEvidence } from "../../types.js";
22
2
  export interface FileScanResult {
23
3
  file: string;
@@ -1,23 +1,3 @@
1
- /**
2
- * AST scanner for Go source files.
3
- *
4
- * Walks tree-sitter-go for two things:
5
- *
6
- * 1. import declarations naming any tracked module (AI SDKs, web
7
- * frameworks, DB clients) → ImportEvidence
8
- * 2. HTTP route calls. Three flavors:
9
- * net/http : http.HandleFunc("/path", h)
10
- * chi : r.Get("/path", h), r.Post(…) (TitleCase)
11
- * echo/gin : e.GET("/path", h), r.POST(…) (UPPER)
12
- * fiber : app.Get("/path", h), app.Post(…) (TitleCase)
13
- *
14
- * Method-name normalization happens after we identify the call-shape;
15
- * output is always UPPERCASE in the JSON.
16
- *
17
- * Privacy invariant: same as the TS adapter — only identifier names,
18
- * file paths, line numbers, package paths, and route method/path strings.
19
- * Function bodies are never read.
20
- */
21
1
  import * as fs from "node:fs/promises";
22
2
  import { getGoParser } from "./parser.js";
23
3
  import { AI_SDK_MODULES, DATA_STORE_MODULES, WEB_FRAMEWORK_MODULES, STDLIB_FRAMEWORKS, } from "./manifest.js";
@@ -74,64 +54,45 @@ function walk(node, visit) {
74
54
  walk(child, visit);
75
55
  }
76
56
  }
77
- /** Pull the quoted module path out of an import_spec node. */
78
57
  function extractImportPath(node) {
79
- // import_spec → optional package_identifier + interpreted_string_literal
80
58
  const stringNode = node.namedChildren.find((c) => c?.type === "interpreted_string_literal");
81
59
  if (!stringNode)
82
60
  return null;
83
- // text is the quoted form; strip the surrounding quotes.
84
61
  const text = stringNode.text;
85
62
  return text.length >= 2 ? text.slice(1, -1) : null;
86
63
  }
87
64
  function trackedModuleMatch(pkg) {
88
65
  if (TRACKED_MODULES.has(pkg))
89
66
  return pkg;
90
- // Sub-package import — e.g., "github.com/jackc/pgx/v5/pgxpool"
91
67
  for (const tracked of TRACKED_MODULES) {
92
68
  if (pkg.startsWith(tracked + "/"))
93
69
  return tracked;
94
70
  }
95
71
  return null;
96
72
  }
97
- /**
98
- * Match an HTTP-route call by inspecting the call-expression shape.
99
- * Two AST patterns to handle:
100
- * - selector_expression(operand=identifier, field=field_identifier) called with args
101
- * ⇒ http.HandleFunc, app.Get, e.GET, r.Post …
102
- * - identifier called with args (rare for routes; ignored)
103
- */
104
73
  function extractRouteCall(node) {
105
- // call_expression has: function (selector_expression | identifier) + argument_list
106
74
  const fn = node.namedChildren.find((c) => c?.type === "selector_expression");
107
75
  const args = node.namedChildren.find((c) => c?.type === "argument_list");
108
76
  if (!fn || !args)
109
77
  return null;
110
- // selector_expression: operand (any) . field (field_identifier)
111
78
  const operand = fn.namedChildren[0];
112
79
  const field = fn.namedChildren.find((c) => c?.type === "field_identifier");
113
80
  if (!operand || !field)
114
81
  return null;
115
82
  const operandText = operand.text;
116
83
  const fieldName = field.text;
117
- // Determine the HTTP method from the field name + operand shape.
118
84
  let method = null;
119
85
  if (HTTP_METHODS_UPPER.has(fieldName)) {
120
- // echo/gin: e.GET, r.POST … — operand is a router-like local var
121
86
  method = fieldName === "ANY" ? "ALL" : fieldName;
122
87
  }
123
88
  else if (HTTP_METHODS_TITLE.has(fieldName)) {
124
- // chi/fiber: r.Get, app.Post …
125
89
  method = fieldName.toUpperCase();
126
90
  }
127
91
  else if (STDLIB_HANDLER_FNS.has(fieldName) && operandText === "http") {
128
- // net/http: http.HandleFunc("/x", h) / http.Handle("/x", h)
129
- // We don't know the HTTP verb statically — emit "ALL".
130
92
  method = "ALL";
131
93
  }
132
94
  if (!method)
133
95
  return null;
134
- // First arg = string literal route path.
135
96
  const firstArg = args.namedChildren[0];
136
97
  if (!firstArg)
137
98
  return null;
@@ -150,7 +111,6 @@ export function aggregate(scans) {
150
111
  if (s.routes.length === 0 && s.imports.length === 0)
151
112
  continue;
152
113
  for (const imp of s.imports) {
153
- // Match against the FULL tracked module (allowing sub-paths).
154
114
  const matched = matchTracked(imp.package);
155
115
  if (!matched)
156
116
  continue;
@@ -191,8 +151,6 @@ function matchTracked(pkg) {
191
151
  }
192
152
  function deriveComponentName(filePath) {
193
153
  const segs = filePath.split("/");
194
- // Go convention: cmd/foo/main.go → "foo"; internal/auth/handler.go → "auth"
195
- // Use the deepest directory that isn't a stdlib-ish folder name.
196
154
  const skipPrefixes = new Set(["cmd", "internal", "pkg", "src", "app"]);
197
155
  const start = skipPrefixes.has(segs[0]) ? 1 : 0;
198
156
  if (segs.length - start >= 2)
@@ -213,4 +171,3 @@ function detectFrameworkFromImports(imports) {
213
171
  }
214
172
  return undefined;
215
173
  }
216
- //# sourceMappingURL=scanner.js.map
@@ -1,5 +1,2 @@
1
- /**
2
- * Python language adapter. Same shape as TS/Go.
3
- */
4
1
  import type { LanguageAdapter } from "../../types.js";
5
2
  export declare const pythonAdapter: LanguageAdapter;
@@ -1,6 +1,3 @@
1
- /**
2
- * Python language adapter. Same shape as TS/Go.
3
- */
4
1
  import * as path from "node:path";
5
2
  import { readManifests, summarizeManifests, findExternalServices, findDataStores, detectFrameworkFromManifest, } from "./manifest.js";
6
3
  import { scanFile, aggregate } from "./scanner.js";
@@ -65,4 +62,3 @@ function frameworkFromOwningManifest(sourceFile, manifests) {
65
62
  .sort((a, b) => b.dir.length - a.dir.length);
66
63
  return candidates[0] ? detectFrameworkFromManifest(candidates[0].m) : undefined;
67
64
  }
68
- //# sourceMappingURL=index.js.map