@contextq/cli 0.1.0 → 0.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contextq/cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "One-command installer for ContextQ -- wires the MCP server, the contextq SessionStart boot hook, and the task manifest into a project (or prints a manual connect guide for Desktop/Cowork).",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,9 +12,9 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "dev": "tsx src/index.ts",
15
- "build": "tsc",
15
+ "build": "tsc --noEmit && tsup",
16
16
  "test": "tsx --test 'src/**/*.test.ts'",
17
- "prepublishOnly": "tsc"
17
+ "prepublishOnly": "npm run build"
18
18
  },
19
19
  "keywords": [
20
20
  "contextq",
@@ -36,8 +36,12 @@
36
36
  "access": "public"
37
37
  },
38
38
  "devDependencies": {
39
- "typescript": "^5.8.3",
39
+ "@types/node": "^22.15.0",
40
+ "tsup": "^8.5.1",
40
41
  "tsx": "^4.23.12",
41
- "@types/node": "^22.15.0"
42
+ "typescript": "^5.8.3"
43
+ },
44
+ "dependencies": {
45
+ "smol-toml": "^1.9.1"
42
46
  }
43
47
  }
@@ -1,8 +0,0 @@
1
- /**
2
- * desktop-guide.ts — the Lane 2 (remote MCP) connect guide for Claude
3
- * Desktop / Cowork / any client that only reads a manually-edited config
4
- * file. There is no auto-connect path for these clients (verified
5
- * impossible -- they only read their config on start), so this prints the
6
- * exact 3-step manual flow instead of pretending to automate it.
7
- */
8
- export declare function printDesktopGuide(apiUrl: string): void;
@@ -1,40 +0,0 @@
1
- /**
2
- * desktop-guide.ts — the Lane 2 (remote MCP) connect guide for Claude
3
- * Desktop / Cowork / any client that only reads a manually-edited config
4
- * file. There is no auto-connect path for these clients (verified
5
- * impossible -- they only read their config on start), so this prints the
6
- * exact 3-step manual flow instead of pretending to automate it.
7
- */
8
- export function printDesktopGuide(apiUrl) {
9
- console.log(`
10
- No git repo or existing Claude Code project found here, so there is nothing on
11
- disk to scaffold. For Claude Desktop, Cowork, or any other MCP-capable client
12
- that reads a manually-edited config file, connect ContextQ in 3 steps:
13
-
14
- 1. Open the ContextQ dashboard -> Settings -> API keys -> create a key
15
- ${apiUrl}/dashboard/api-keys
16
-
17
- 2. Add this to your client's MCP config file (e.g. claude_desktop_config.json):
18
-
19
- {
20
- "mcpServers": {
21
- "contextq": {
22
- "command": "npx",
23
- "args": ["-y", "@contextq/mcp"],
24
- "env": {
25
- "CONTEXT_API_URL": "${apiUrl}",
26
- "CONTEXT_API_KEY": "<your key from step 1>"
27
- }
28
- }
29
- }
30
- }
31
-
32
- 3. Restart the client so it picks up the new MCP server.
33
-
34
- There is no auto-connect for Desktop/Cowork today -- these clients only read
35
- their config file on start, so step 2 has to be a manual paste. Re-run
36
- "npx @contextq/cli init" inside a git repo (or an existing Claude Code project) to
37
- get the automatic .mcp.json + hook + task-manifest scaffolding instead.
38
- `);
39
- }
40
- //# sourceMappingURL=desktop-guide.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"desktop-guide.js","sourceRoot":"","sources":["../src/desktop-guide.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,OAAO,CAAC,GAAG,CAAC;;;;;;OAMP,MAAM;;;;;;;;;;mCAUsB,MAAM;;;;;;;;;;;;;CAaxC,CAAC,CAAC;AACH,CAAC"}
package/dist/detect.d.ts DELETED
@@ -1,42 +0,0 @@
1
- /**
2
- * detect.ts — surface detection.
3
- *
4
- * Claude Code lane: cwd is inside a git repo, OR a `.claude/` dir already
5
- * exists at cwd -- either signal means there is a real project here the
6
- * installer can safely scaffold into.
7
- *
8
- * Codex lane (T665): a project is treated as a Codex target when EITHER of
9
- * two signals holds -- a `.codex/` dir at the repo root (covers both
10
- * `.codex/config.toml` and `.codex/hooks.json`, since both live inside that
11
- * one directory -- there is no separate "config at repo level" signal to
12
- * check, it's the same dir), OR `~/.codex/` existing on this machine at all
13
- * (Codex CLI installed here, even if this particular repo hasn't been
14
- * opened with it yet -- the same breadth Claude Code's own `git repo OR
15
- * .claude/` rule already uses). The write itself is low-risk (idempotent,
16
- * additive-only, gitignored -- see session-hook.ts) so erring toward
17
- * detecting Codex is deliberate, not an oversight.
18
- *
19
- * Claude Code and Codex are detected INDEPENDENTLY -- a repo can be (and
20
- * commonly is) both, so `surfaces` is an array, not a single value. Only
21
- * when NEITHER signal fires does detection fall back to the single
22
- * `'desktop'` value (nothing on disk to scaffold -- print the manual guide).
23
- *
24
- * `forcedSurface` (wired from index.ts's `--surface` flag) bypasses
25
- * autodetection entirely and pins exactly one surface -- e.g. `--surface
26
- * codex` on a bare folder with neither a repo-level `.codex/` nor a
27
- * `~/.codex/` install (a fresh CI sandbox, a machine where Codex isn't
28
- * installed yet but the hooks file should still be scaffolded ahead of it).
29
- */
30
- export type Surface = 'claude-code' | 'codex' | 'desktop';
31
- export interface DetectOptions {
32
- /** Wired from `--surface` -- when set, skip autodetection and pin exactly this one surface. */
33
- forcedSurface?: Exclude<Surface, 'desktop'>;
34
- /** Override for os.homedir(), tests only -- production always uses the real home dir. */
35
- homeDir?: string;
36
- }
37
- export interface DetectResult {
38
- surfaces: Surface[];
39
- root: string;
40
- }
41
- export declare function gitRoot(cwd: string): string;
42
- export declare function detectSurface(cwd: string, opts?: DetectOptions): DetectResult;
package/dist/detect.js DELETED
@@ -1,70 +0,0 @@
1
- /**
2
- * detect.ts — surface detection.
3
- *
4
- * Claude Code lane: cwd is inside a git repo, OR a `.claude/` dir already
5
- * exists at cwd -- either signal means there is a real project here the
6
- * installer can safely scaffold into.
7
- *
8
- * Codex lane (T665): a project is treated as a Codex target when EITHER of
9
- * two signals holds -- a `.codex/` dir at the repo root (covers both
10
- * `.codex/config.toml` and `.codex/hooks.json`, since both live inside that
11
- * one directory -- there is no separate "config at repo level" signal to
12
- * check, it's the same dir), OR `~/.codex/` existing on this machine at all
13
- * (Codex CLI installed here, even if this particular repo hasn't been
14
- * opened with it yet -- the same breadth Claude Code's own `git repo OR
15
- * .claude/` rule already uses). The write itself is low-risk (idempotent,
16
- * additive-only, gitignored -- see session-hook.ts) so erring toward
17
- * detecting Codex is deliberate, not an oversight.
18
- *
19
- * Claude Code and Codex are detected INDEPENDENTLY -- a repo can be (and
20
- * commonly is) both, so `surfaces` is an array, not a single value. Only
21
- * when NEITHER signal fires does detection fall back to the single
22
- * `'desktop'` value (nothing on disk to scaffold -- print the manual guide).
23
- *
24
- * `forcedSurface` (wired from index.ts's `--surface` flag) bypasses
25
- * autodetection entirely and pins exactly one surface -- e.g. `--surface
26
- * codex` on a bare folder with neither a repo-level `.codex/` nor a
27
- * `~/.codex/` install (a fresh CI sandbox, a machine where Codex isn't
28
- * installed yet but the hooks file should still be scaffolded ahead of it).
29
- */
30
- import { existsSync } from 'node:fs';
31
- import { execSync } from 'node:child_process';
32
- import { homedir } from 'node:os';
33
- import { join } from 'node:path';
34
- export function gitRoot(cwd) {
35
- try {
36
- return execSync('git rev-parse --show-toplevel', {
37
- cwd,
38
- stdio: ['ignore', 'pipe', 'ignore'],
39
- encoding: 'utf-8',
40
- }).trim();
41
- }
42
- catch {
43
- return '';
44
- }
45
- }
46
- function hasCodexProjectDir(root) {
47
- return existsSync(join(root, '.codex'));
48
- }
49
- function hasCodexHome(homeDir) {
50
- return existsSync(join(homeDir, '.codex'));
51
- }
52
- export function detectSurface(cwd, opts = {}) {
53
- const gitRootPath = gitRoot(cwd);
54
- const root = gitRootPath || cwd;
55
- if (opts.forcedSurface) {
56
- return { surfaces: [opts.forcedSurface], root };
57
- }
58
- const hasClaudeDir = existsSync(join(cwd, '.claude'));
59
- const claudeCode = Boolean(gitRootPath || hasClaudeDir);
60
- const codex = hasCodexProjectDir(root) || hasCodexHome(opts.homeDir ?? homedir());
61
- const surfaces = [];
62
- if (claudeCode)
63
- surfaces.push('claude-code');
64
- if (codex)
65
- surfaces.push('codex');
66
- if (surfaces.length === 0)
67
- surfaces.push('desktop');
68
- return { surfaces, root: claudeCode || codex ? root : cwd };
69
- }
70
- //# sourceMappingURL=detect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"detect.js","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAgBjC,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,+BAA+B,EAAE;YAC/C,GAAG;YACH,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;YACnC,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC,IAAI,EAAE,CAAC;IACZ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAY;IACtC,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,YAAY,CAAC,OAAe;IACnC,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,OAAsB,EAAE;IACjE,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,IAAI,GAAG,WAAW,IAAI,GAAG,CAAC;IAEhC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,CAAC;IAClD,CAAC;IAED,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;IACtD,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,IAAI,YAAY,CAAC,CAAC;IACxD,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,EAAE,CAAC,CAAC;IAElF,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,IAAI,UAAU;QAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC7C,IAAI,KAAK;QAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAEpD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AAC9D,CAAC"}
package/dist/index.d.ts DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * contextq — one-command installer.
4
- *
5
- * `npx @contextq/cli init` detects which surface(s) are present -- Claude Code
6
- * project, Codex CLI project (T665), or neither (Desktop/Cowork) -- and
7
- * scaffolds the matching wiring: for Claude Code, .mcp.json + the contextq
8
- * SessionStart hook + .contextq/tasks/; for Codex, a `.codex/hooks.json`
9
- * SessionStart hook (see cli/src/session-hook.ts for why the two harnesses
10
- * share one command builder and one merge implementation). A repo can be
11
- * (and often is) both at once -- both get wired in the same run unless
12
- * `--surface` pins exactly one. Neither detected -> print the manual
13
- * 3-step connect guide instead. Idempotent throughout: re-running reports
14
- * "already configured" / "[skip]" for anything already wired and writes
15
- * nothing new.
16
- */
17
- export {};
package/dist/index.js.map DELETED
@@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"}
@@ -1,17 +0,0 @@
1
- /**
2
- * mcp-config.ts — idempotent .mcp.json merge.
3
- *
4
- * Mirrors skills/contextq/scripts/install-hook.sh's wire_mcp(): never
5
- * clobbers an existing .mcp.json, only ever sets/reads the "contextq" key
6
- * under mcpServers, and defaults the key value to the ${CONTEXT_API_KEY}
7
- * placeholder (safe default -- no secret on disk) unless --embed-key is
8
- * passed. Claude Code expands ${VAR} from ITS OWN process environment, not
9
- * from the credential file this installer writes -- same documented gap
10
- * install-hook.sh warns about.
11
- */
12
- export interface McpWireResult {
13
- path: string;
14
- action: 'created' | 'added' | 'skipped';
15
- detail: string;
16
- }
17
- export declare function wireMcpJson(root: string, apiUrl: string, embedKey: boolean, apiKey: string): McpWireResult;
@@ -1,79 +0,0 @@
1
- /**
2
- * mcp-config.ts — idempotent .mcp.json merge.
3
- *
4
- * Mirrors skills/contextq/scripts/install-hook.sh's wire_mcp(): never
5
- * clobbers an existing .mcp.json, only ever sets/reads the "contextq" key
6
- * under mcpServers, and defaults the key value to the ${CONTEXT_API_KEY}
7
- * placeholder (safe default -- no secret on disk) unless --embed-key is
8
- * passed. Claude Code expands ${VAR} from ITS OWN process environment, not
9
- * from the credential file this installer writes -- same documented gap
10
- * install-hook.sh warns about.
11
- */
12
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
13
- import { execFileSync } from 'node:child_process';
14
- import { join } from 'node:path';
15
- /**
16
- * T474: whether `relPath` (relative to `root`) is covered by a gitignore rule.
17
- * Returns null when this can't be determined (no git repo at `root`, or git
18
- * itself is unavailable) -- callers must treat that as "unknown", not "safe".
19
- */
20
- function isPathGitIgnored(root, relPath) {
21
- try {
22
- execFileSync('git', ['check-ignore', '-q', '--', relPath], { cwd: root, stdio: 'ignore' });
23
- return true;
24
- }
25
- catch (err) {
26
- const status = err.status;
27
- if (status === 1)
28
- return false;
29
- return null;
30
- }
31
- }
32
- export function wireMcpJson(root, apiUrl, embedKey, apiKey) {
33
- const path = join(root, '.mcp.json');
34
- const existed = existsSync(path);
35
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
- let doc = {};
37
- if (existed) {
38
- const raw = readFileSync(path, 'utf-8');
39
- try {
40
- doc = raw.trim() === '' ? {} : JSON.parse(raw);
41
- }
42
- catch (err) {
43
- throw new Error(`.mcp.json exists but is not valid JSON (${err.message}) -- refusing to touch it`);
44
- }
45
- }
46
- doc.mcpServers ??= {};
47
- if (doc.mcpServers.contextq) {
48
- return { path, action: 'skipped', detail: 'contextq server entry already present' };
49
- }
50
- // T474: --embed-key is about to write the raw secret to disk -- refuse when
51
- // .mcp.json would land in a commit, since that turns a local convenience
52
- // flag into a leaked-credential incident the moment someone runs `git add .`.
53
- if (embedKey) {
54
- const ignored = isPathGitIgnored(root, '.mcp.json');
55
- if (ignored === false) {
56
- throw new Error('.mcp.json is not covered by .gitignore in this repo -- refusing to write the raw API key into a ' +
57
- 'file git would track. Add ".mcp.json" to .gitignore first, or re-run without --embed-key to use ' +
58
- 'the safer ${CONTEXT_API_KEY} placeholder instead.');
59
- }
60
- if (ignored === null) {
61
- console.log('[warn] could not verify .mcp.json is gitignored (no git repo detected at this path) -- writing the raw key anyway.');
62
- }
63
- }
64
- doc.mcpServers.contextq = {
65
- command: 'npx',
66
- args: ['-y', '@contextq/mcp'],
67
- env: {
68
- CONTEXT_API_URL: apiUrl,
69
- CONTEXT_API_KEY: embedKey ? apiKey : '${CONTEXT_API_KEY}',
70
- },
71
- };
72
- writeFileSync(path, `${JSON.stringify(doc, null, 2)}\n`);
73
- return {
74
- path,
75
- action: existed ? 'added' : 'created',
76
- detail: `contextq server wired (key=${embedKey ? 'embedded literal' : '${CONTEXT_API_KEY} placeholder'})`,
77
- };
78
- }
79
- //# sourceMappingURL=mcp-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mcp-config.js","sourceRoot":"","sources":["../src/mcp-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE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the existing T144 web installer (src/routes/installer.ts)
5
- * and the same path the contextq skill's bash scripts (contextq-api.sh,
6
- * install-hook.sh, contextq-boot.sh) and Bun cred-resolve.ts already read:
7
- *
8
- * macOS: ~/Library/Application Support/contextq/credentials
9
- * Windows: %APPDATA%/contextq/credentials
10
- * Linux: $XDG_CONFIG_HOME/contextq/credentials (default ~/.config)
11
- *
12
- * The existing readers disagree on which key names they check: install.sh
13
- * (T144) writes CTQ_API_KEY/CTQ_API_URL (read by cred-resolve.ts's Bun path),
14
- * while every bash script (contextq-api.sh, install-hook.sh, contextq-boot.sh)
15
- * only ever reads CONTEXT_API_KEY/CONTEXT_API_URL from this same file. Rather
16
- * than picking a side, this installer writes BOTH pairs so the credential it
17
- * writes is visible to every existing reader regardless of that pre-existing
18
- * inconsistency.
19
- *
20
- * Never logs or prints the key value.
21
- *
22
- * T676: writeCreds() itself remains an unconditional overwrite -- callers
23
- * decide when that's appropriate. The safety layer lives in the helpers
24
- * below (credsFileExists/credsEqual/backupCredsFile), which index.ts's
25
- * runInit() composes into: no write on an ambient env var alone when a
26
- * credential file already exists, a timestamped backup before any write
27
- * that would actually change an existing file, and a no-op when the new
28
- * value is identical to what's already on disk.
29
- */
30
- export interface Creds {
31
- apiKey: string;
32
- apiUrl: string;
33
- }
34
- /**
35
- * T676: test-only override so cli/ tests can point every read/write at a
36
- * throwaway temp dir instead of the real machine-wide credential path.
37
- * Checked first, ahead of every OS-specific branch below. Production never
38
- * sets this -- there is no code path that sets it outside a test.
39
- */
40
- export declare function platformCredDir(): string;
41
- export declare function platformCredFile(): string;
42
- /** Does a credential file already exist on disk (real or overridden dir)? */
43
- export declare function credsFileExists(): boolean;
44
- /** Same apiKey AND same apiUrl -- the "nothing would actually change" case. */
45
- export declare function credsEqual(a: Creds, b: Creds): boolean;
46
- /**
47
- * Copy whatever credential file is currently on disk to a timestamped
48
- * sibling (mode 600, same directory) BEFORE it gets overwritten. Returns
49
- * the backup path, or null when there was no existing file to back up.
50
- * Never throws on missing source -- callers gate this on credsFileExists().
51
- */
52
- export declare function backupCredsFile(): string | null;
53
- /** Read whatever is already on disk. Both apiKey/apiUrl are '' when absent. */
54
- export declare function readExistingCreds(): Creds;
55
- /**
56
- * Write the credential file at mode 0600 (dir at 0700). Overwrites whatever
57
- * was there before — callers decide when that's appropriate (explicit --key,
58
- * or no existing credential at all).
59
- */
60
- export declare function writeCreds(creds: Creds): string;
61
- export declare const KEY_RE: RegExp;
62
- export interface CredentialDecisionInput {
63
- /** `--key` flag value, if the caller passed one. */
64
- explicitKey?: string;
65
- /** Name of whichever ambient env var supplied a key, or null when neither is set. */
66
- ambientVarName: 'CONTEXT_API_KEY' | 'CTQ_API_KEY' | null;
67
- /** The ambient env var's value; '' when ambientVarName is null. */
68
- ambientKey: string;
69
- apiUrl: string;
70
- }
71
- export interface CredentialDecision {
72
- apiKey: string;
73
- credLine: string;
74
- /**
75
- * null only when the caller must fall through to an interactive prompt:
76
- * no --key, no ambient env var, and no existing file to fall back to.
77
- */
78
- action: 'created' | 'rotated' | 'skipped' | null;
79
- backupPath: string | null;
80
- }
81
- /**
82
- * T676: the non-interactive half of `contextq init`'s credential
83
- * resolution. Fixes the real incident this task is named for -- a demo run
84
- * with only an AMBIENT env var set (direnv-exported CONTEXT_API_KEY from
85
- * some repo's .env.local) used to be treated exactly like an explicit
86
- * --key, silently overwriting a pre-existing machine-wide credential file
87
- * with no backup. Branches, matching T676's required behavior 1-4:
88
- *
89
- * 1. no --key, ambient env only, file exists -> file untouched, used as-is,
90
- * "skipped" naming the ignored env var
91
- * 2. --key given, file exists with a different key or url -> back up the
92
- * existing file (mode 600, timestamped) THEN write, "rotated"
93
- * 3. --key given, file exists with the identical key AND url -> no write,
94
- * "skipped (unchanged)"
95
- * 4. no existing file at all -> unchanged prior behavior, "created"
96
- * (works from either --key or an ambient env var, since there is
97
- * nothing to protect)
98
- *
99
- * The one case this function does not resolve on its own is "no --key, no
100
- * ambient env var, no existing file" -- action comes back null and the
101
- * caller must prompt interactively, then call this function again with the
102
- * typed value as `explicitKey` to get a consistent created/rotated/skipped
103
- * decision (falls into branch 4 in practice, since there is no file yet).
104
- */
105
- export declare function decideCredentialWrite(input: CredentialDecisionInput): CredentialDecision;