@mindbricks/genesis-set 0.2.0 → 0.2.1
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/CHANGELOG.md +8 -0
- package/README.md +3 -2
- package/corpus/genesis/compiler-api.md +2 -1
- package/lib/config-cli.mjs +8 -2
- package/lib/install.mjs +3 -3
- package/mcp/config.mjs +23 -0
- package/mcp/key-page-html.mjs +1 -1
- package/mcp/key-store.mjs +7 -11
- package/mcp/key-tools.mjs +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
The package follows semantic versioning. Each release names the mind-set range it needs
|
|
4
4
|
(`dependencies["@mindbricks/mind-set"]` in `package.json`).
|
|
5
5
|
|
|
6
|
+
## 0.2.1 (pre-release)
|
|
7
|
+
|
|
8
|
+
- A stored key is shown as its type prefix and last four characters (`sk_mbx_...9f3a`,
|
|
9
|
+
`sk_test_...a1b2`) in `genesis config show`, `genesis doctor`, the install key step and the
|
|
10
|
+
key page, so the user can tell which key is set and whether it is a test or a live key. At
|
|
11
|
+
least eight characters always stay hidden; a shorter value is only shown as "set". The agent
|
|
12
|
+
tools still answer set or empty only.
|
|
13
|
+
|
|
6
14
|
## 0.2.0 (pre-release)
|
|
7
15
|
|
|
8
16
|
Needs mind-set `^0.2.0`.
|
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ as an alias). It depends on
|
|
|
31
31
|
| `genesis install [--claude] [--codex] [--force] [--no-mcp] [--no-key] [--dry-run]` | Makes sure a compatible mind-set is installed (it comes with this package and is installed by its own CLI), copies the corpus to `~/.genesis-set/<version>/` (linked as `~/.genesis-set/current`), writes each `genesis-*` skill to Claude Code (`~/.claude/skills/`) and Codex (`~/.agents/skills/`), registers the MCP server (below), and ends with the API key step (below). |
|
|
32
32
|
| `genesis update [...]` | Installs this version for every agent installed before (and every detected one), then deletes older corpus versions. |
|
|
33
33
|
| `genesis uninstall [--dry-run]` | Removes only what `install` recorded in `~/.genesis-set/installed.json`, including the MCP registrations. mind-set and your API key file stay. |
|
|
34
|
-
| `genesis doctor` | Both versions (genesis-set and mind-set) and whether they are compatible, the skills of each package and the MCP server per agent, where the API key comes from (never
|
|
34
|
+
| `genesis doctor` | Both versions (genesis-set and mind-set) and whether they are compatible, the skills of each package and the MCP server per agent, where the API key comes from and which key it is (its type prefix and last four characters, such as `sk_mbx_...9f3a`, never the whole key) and the API base. |
|
|
35
35
|
| `genesis config [show \| set-key \| unset-key \| set-base <url> \| unset-base]` | The API key and API base in `~/.genesis-set/config.json` (mode 0600). `set-key` reads the key from stdin (hidden on a terminal), never from the command line. |
|
|
36
36
|
| `genesis keys [--no-open]` | Opens the local key page in your browser: add, change, clear or delete the keys your agent uses. The link is new each time; the page closes after 15 idle minutes or on Ctrl+C. `--no-open` only prints the link. |
|
|
37
37
|
| `genesis mcp` | Runs the MCP server on stdio from the package (for a registration by hand). |
|
|
@@ -83,7 +83,8 @@ without a Genesis API key:
|
|
|
83
83
|
- **Where the keys live:** in `~/.genesis-set/config.json` (mode 0600).
|
|
84
84
|
- The Genesis API key is the built-in key `genesis-api-key`, the same value `config set-key` stores.
|
|
85
85
|
- Every other key is `keys.<name>`.
|
|
86
|
-
- **What the page shows:** whether a key is set
|
|
86
|
+
- **What the page shows:** whether a key is set and, for a long value, its type prefix and last
|
|
87
|
+
four characters (`sk_test_...a1b2`), so test and live keys can be told apart. A
|
|
87
88
|
value is sent once, when the user saves it. The field the user types into is hidden, with a
|
|
88
89
|
Show / Hide toggle; the stored value is never shown again.
|
|
89
90
|
- **Env files:** `genesis_writeKeyToEnvFile` accepts only a file named `.env`, `.env.local` or
|
|
@@ -59,7 +59,8 @@ Genesis never deploys anything and never runs your services.
|
|
|
59
59
|
and how to set the key: pass it on as it is.
|
|
60
60
|
3. The API base is `https://api.genesiscompiler.com`. Change it only when the user names
|
|
61
61
|
another one (`GENESIS_API_BASE`, or `genesis config set-base <url>`).
|
|
62
|
-
4. `genesis doctor` says where the key comes from
|
|
62
|
+
4. `genesis doctor` says where the key comes from and which key it is (type prefix and last four
|
|
63
|
+
characters, never the whole key), the API base and
|
|
63
64
|
whether each agent has the MCP server.
|
|
64
65
|
|
|
65
66
|
## 4. The tools
|
package/lib/config-cli.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
API_KEY_ENV,
|
|
9
9
|
DEFAULT_API_BASE,
|
|
10
10
|
configPathOf,
|
|
11
|
+
maskSecret,
|
|
11
12
|
normalizeApiBase,
|
|
12
13
|
portalKeysUrl,
|
|
13
14
|
readConfigFile,
|
|
@@ -54,6 +55,11 @@ async function readSecretLine(prompt, errOut) {
|
|
|
54
55
|
return text.split(/\r?\n/)[0] ?? '';
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
/** A set key as the user sees it: `sk_mbx_...9f3a`, or "set" when it is too short to show any of it. */
|
|
59
|
+
export function shownKey(key) {
|
|
60
|
+
return maskSecret(key) ?? 'set';
|
|
61
|
+
}
|
|
62
|
+
|
|
57
63
|
/** Why a key cannot be stored, or null when it can. */
|
|
58
64
|
function keyProblem(key) {
|
|
59
65
|
if (!key) return 'no key read';
|
|
@@ -78,7 +84,7 @@ export async function offerApiKey({
|
|
|
78
84
|
const s = resolveSettings(env);
|
|
79
85
|
const url = portalKeysUrl(s.apiBase);
|
|
80
86
|
if (s.apiKey) {
|
|
81
|
-
out(`Genesis API key:
|
|
87
|
+
out(`Genesis API key: ${shownKey(s.apiKey)} (from ${s.keySource}).`);
|
|
82
88
|
return;
|
|
83
89
|
}
|
|
84
90
|
const later = `"genesis config set-key" in a terminal, or set ${API_KEY_ENV} in the environment the agent starts from`;
|
|
@@ -114,7 +120,7 @@ export async function offerApiKey({
|
|
|
114
120
|
function show(env, out) {
|
|
115
121
|
const s = resolveSettings(env);
|
|
116
122
|
out(`config file: ${s.configFile}`);
|
|
117
|
-
out(`API key: ${s.apiKey ?
|
|
123
|
+
out(`API key: ${s.apiKey ? `${shownKey(s.apiKey)} (from ${s.keySource})` : `not set (${API_KEY_ENV} or "genesis config set-key"; create one at ${portalKeysUrl(s.apiBase)})`}`);
|
|
118
124
|
out(`API base: ${s.apiBase} (${s.baseSource})`);
|
|
119
125
|
for (const p of s.problems) out(`problem: ${p}`);
|
|
120
126
|
return s.problems.length ? 1 : 0;
|
package/lib/install.mjs
CHANGED
|
@@ -25,7 +25,7 @@ import os from 'node:os';
|
|
|
25
25
|
import path from 'node:path';
|
|
26
26
|
import { REGISTER, REGISTRATION, UNREGISTER, copyServer, mcpServerDir, mcpServerFile } from './mcp-config.mjs';
|
|
27
27
|
import { compareVersions, satisfies } from './semver.mjs';
|
|
28
|
-
import { portalKeysUrl, resolveSettings } from '../mcp/config.mjs';
|
|
28
|
+
import { maskSecret, portalKeysUrl, resolveSettings } from '../mcp/config.mjs';
|
|
29
29
|
|
|
30
30
|
export const PACKAGE_NAME = 'genesis-set';
|
|
31
31
|
export const MARKER = '.genesis-set.json';
|
|
@@ -584,8 +584,8 @@ export function doctor(ctx) {
|
|
|
584
584
|
if (manifest && !exists(mindSetCorpus(ctx))) problems.push(`the mind-set corpus ${mindSetCorpus(ctx)} the skills point at is missing`);
|
|
585
585
|
const settings = resolveSettings(ctx.env);
|
|
586
586
|
say(
|
|
587
|
-
`Genesis Compiler API key: ${settings.apiKey ?
|
|
588
|
-
'its
|
|
587
|
+
`Genesis Compiler API key: ${settings.apiKey ? `${maskSecret(settings.apiKey) ?? 'set'} (from ${settings.keySource})` : `not set (${API_KEY_ENV}, or "genesis config set-key"; create one at ${portalKeysUrl(settings.apiBase)})`}; ` +
|
|
588
|
+
'only its type prefix and last four characters are ever printed',
|
|
589
589
|
);
|
|
590
590
|
say(`Genesis Compiler API base: ${settings.apiBase} (${settings.baseSource})`);
|
|
591
591
|
for (const p of settings.problems) problems.push(p);
|
package/mcp/config.mjs
CHANGED
|
@@ -29,6 +29,29 @@ export function portalKeysUrl(apiBase) {
|
|
|
29
29
|
return PORTAL_KEYS_URL;
|
|
30
30
|
}
|
|
31
31
|
export const CONFIG_FILE = 'config.json';
|
|
32
|
+
|
|
33
|
+
/** How many characters of a stored key always stay hidden when it is shown. */
|
|
34
|
+
export const MASK_HIDDEN_MIN = 8;
|
|
35
|
+
/** The longest type prefix a masked key shows. */
|
|
36
|
+
export const MASK_PREFIX_MAX = 12;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A stored key as the user may see it: its type prefix and its last four
|
|
40
|
+
* characters, for example `sk_test_...a1b2` or `sk_mbx_...9f3a`, so the user can
|
|
41
|
+
* tell which key is set (test or live, which account) without the key being
|
|
42
|
+
* shown. The prefix is the leading marker, one or two letter segments that end
|
|
43
|
+
* in `_` or `-` (at most MASK_PREFIX_MAX characters), else the first four
|
|
44
|
+
* characters. Answers null when fewer than MASK_HIDDEN_MIN characters would stay
|
|
45
|
+
* hidden: a short value is only ever "set". Never for an agent's answer.
|
|
46
|
+
*/
|
|
47
|
+
export function maskSecret(value) {
|
|
48
|
+
if (typeof value !== 'string') return null;
|
|
49
|
+
const v = value.trim();
|
|
50
|
+
const marker = v.match(/^[A-Za-z]{1,8}[_-](?:[A-Za-z]{1,8}[_-])?/);
|
|
51
|
+
const prefix = marker && marker[0].length <= MASK_PREFIX_MAX ? marker[0] : v.slice(0, 4);
|
|
52
|
+
if (v.length - prefix.length - 4 < MASK_HIDDEN_MIN) return null;
|
|
53
|
+
return `${prefix}...${v.slice(-4)}`;
|
|
54
|
+
}
|
|
32
55
|
/** The server's default inline-blueprint limit (bytes of the compact JSON text). */
|
|
33
56
|
export const DEFAULT_MAX_BLUEPRINT_BYTES = 10 * 1024 * 1024;
|
|
34
57
|
export const DEFAULT_TIMEOUT_MS = 120_000;
|
package/mcp/key-page-html.mjs
CHANGED
|
@@ -112,7 +112,7 @@ const SCRIPT = `
|
|
|
112
112
|
c.append(head);
|
|
113
113
|
if (k.description) c.append(el('p', 'desc', k.description));
|
|
114
114
|
const meta = [];
|
|
115
|
-
if (k.
|
|
115
|
+
if (k.masked) meta.push('key ' + k.masked);
|
|
116
116
|
if (k.status === 'set' && k.updatedAt) meta.push('saved ' + when(k.updatedAt));
|
|
117
117
|
if (meta.length) c.append(el('p', 'meta', meta.join(' · ')));
|
|
118
118
|
if (k.source) c.append(el('p', 'note', 'The environment variable ' + k.source + ' is set and wins over a value saved here.'));
|
package/mcp/key-store.mjs
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// the last four characters for the page, and `keyValue` is for the code that
|
|
13
13
|
// uses a key (writing a gitignored env file), never for a tool answer.
|
|
14
14
|
|
|
15
|
-
import { API_KEY_ENV, configPathOf, readConfigFile, writeConfigFile } from './config.mjs';
|
|
15
|
+
import { API_KEY_ENV, configPathOf, maskSecret, readConfigFile, writeConfigFile } from './config.mjs';
|
|
16
16
|
|
|
17
17
|
export const BUILTIN_KEY = 'genesis-api-key';
|
|
18
18
|
const BUILTIN_LABEL = 'Genesis API key';
|
|
@@ -80,13 +80,9 @@ function checkValue(value) {
|
|
|
80
80
|
return v;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
function tailOf(value) {
|
|
85
|
-
return typeof value === 'string' && value.length >= 12 ? value.slice(-4) : null;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function row(name, entry, { builtin = false, envOverride = false } = {}) {
|
|
83
|
+
function row(name, entry, { builtin = false, envOverride = false, envValue = null } = {}) {
|
|
89
84
|
const value = typeof entry.value === 'string' && entry.value ? entry.value : null;
|
|
85
|
+
// The key in effect: for the Genesis API key the environment variable wins over the file.
|
|
90
86
|
return {
|
|
91
87
|
name,
|
|
92
88
|
label: entry.label || name,
|
|
@@ -94,14 +90,14 @@ function row(name, entry, { builtin = false, envOverride = false } = {}) {
|
|
|
94
90
|
builtin,
|
|
95
91
|
status: value || envOverride ? 'set' : 'empty',
|
|
96
92
|
...(envOverride ? { source: API_KEY_ENV } : {}),
|
|
97
|
-
|
|
93
|
+
masked: maskSecret(envOverride ? envValue : value),
|
|
98
94
|
updatedAt: entry.updatedAt ?? null,
|
|
99
95
|
};
|
|
100
96
|
}
|
|
101
97
|
|
|
102
98
|
/**
|
|
103
|
-
* Every key, the built-in Genesis API key first. `
|
|
104
|
-
* characters) is for the page; the tools drop it.
|
|
99
|
+
* Every key, the built-in Genesis API key first. `masked` (the type prefix and
|
|
100
|
+
* the last four characters, see maskSecret) is for the page; the tools drop it.
|
|
105
101
|
*/
|
|
106
102
|
export function listKeys(env = process.env) {
|
|
107
103
|
const { cfg, keys } = load(env);
|
|
@@ -110,7 +106,7 @@ export function listKeys(env = process.env) {
|
|
|
110
106
|
row(
|
|
111
107
|
BUILTIN_KEY,
|
|
112
108
|
{ label: BUILTIN_LABEL, description: BUILTIN_DESCRIPTION, value: cfg.apiKey, updatedAt: cfg.apiKeyUpdatedAt },
|
|
113
|
-
{ builtin: true, envOverride: envKey },
|
|
109
|
+
{ builtin: true, envOverride: envKey, envValue: envKey ? env[API_KEY_ENV] : null },
|
|
114
110
|
),
|
|
115
111
|
];
|
|
116
112
|
for (const name of Object.keys(keys).sort()) {
|
package/mcp/key-tools.mjs
CHANGED
|
@@ -91,10 +91,10 @@ export function isKeyTool(name) {
|
|
|
91
91
|
return KEY_TOOL_NAMES.has(name);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
/** A row for the agent: the page's row without the value
|
|
94
|
+
/** A row for the agent: the page's row without any part of the value. */
|
|
95
95
|
function forAgent(row) {
|
|
96
96
|
if (!row) return row;
|
|
97
|
-
const {
|
|
97
|
+
const { masked: _masked, ...rest } = row;
|
|
98
98
|
return rest;
|
|
99
99
|
}
|
|
100
100
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindbricks/genesis-set",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "PRE-RELEASE. Genesis compiler skills for coding agents (Claude Code, Codex): the generated code, its runtime and the Genesis Compiler API, on top of mind-set.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|