@mindbricks/genesis-set 0.2.1 → 0.3.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/CHANGELOG.md +8 -0
- package/README.md +32 -1
- package/bin/genesis-set.mjs +17 -0
- package/lib/init.mjs +183 -0
- package/lib/install.mjs +2 -1
- 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.3.0 (pre-release)
|
|
7
|
+
|
|
8
|
+
- `genesis init [<folder>] [--dry-run]` prepares a project folder so the agent works the
|
|
9
|
+
OpenAPPL + Genesis way from its first session. It writes a marked block into `CLAUDE.md` and
|
|
10
|
+
`AGENTS.md` (the order of work with the skill for each step, and the key rules) and creates
|
|
11
|
+
`design/` and the env and secrets lines of `.gitignore`; it prints the API key status and a
|
|
12
|
+
starter prompt. Content outside the block is kept, and a second run changes nothing.
|
|
13
|
+
|
|
6
14
|
## 0.2.1 (pre-release)
|
|
7
15
|
|
|
8
16
|
- A stored key is shown as its type prefix and last four characters (`sk_mbx_...9f3a`,
|
package/README.md
CHANGED
|
@@ -24,10 +24,40 @@ as an alias). It depends on
|
|
|
24
24
|
`@mindbricks/mind-set`, so the global install brings mind-set's package too, and
|
|
25
25
|
`genesis install` runs `mindset install` when mind-set is not installed yet.
|
|
26
26
|
|
|
27
|
+
## Starting a project
|
|
28
|
+
|
|
29
|
+
The skills start when a request talks about OpenAPPL or Genesis. A plain "build me a booking
|
|
30
|
+
app" can make an agent hand-write a backend instead, so prepare the project folder once:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
mkdir my-app && cd my-app
|
|
34
|
+
genesis init
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`genesis init` writes a marked block into `CLAUDE.md` (Claude Code) and `AGENTS.md` (Codex),
|
|
38
|
+
which the agents read at the start of every session:
|
|
39
|
+
- the backend is an OpenAPPL blueprint compiled by Genesis, never hand-written;
|
|
40
|
+
- the order of work with the skill for each step;
|
|
41
|
+
- the key rules.
|
|
42
|
+
|
|
43
|
+
It also creates `design/` and the env and secrets lines of `.gitignore`, then prints the API
|
|
44
|
+
key status and a starter prompt.
|
|
45
|
+
- Your own content in `CLAUDE.md` and `AGENTS.md` is kept.
|
|
46
|
+
- A second run only refreshes the block.
|
|
47
|
+
- `--dry-run` shows what it would write.
|
|
48
|
+
|
|
49
|
+
Then open the agent in the folder and start, for example:
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
Let us design a new application with OpenAPPL and compile it with Genesis: a table booking
|
|
53
|
+
system for cafes, with owner, waiter and guest roles. Start with the requirements interview.
|
|
54
|
+
```
|
|
55
|
+
|
|
27
56
|
## Commands
|
|
28
57
|
|
|
29
58
|
| Command | What it does |
|
|
30
59
|
|---|---|
|
|
60
|
+
| `genesis init [<folder>] [--dry-run]` | Prepares a project folder (default: the current one) for the agent: the OpenAPPL + Genesis block in `CLAUDE.md` and `AGENTS.md`, `design/`, the env lines of `.gitignore`, then the key status and a starter prompt (see "Starting a project"). |
|
|
31
61
|
| `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
62
|
| `genesis update [...]` | Installs this version for every agent installed before (and every detected one), then deletes older corpus versions. |
|
|
33
63
|
| `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. |
|
|
@@ -112,7 +142,8 @@ without a Genesis API key:
|
|
|
112
142
|
### Projects and credentials
|
|
113
143
|
|
|
114
144
|
- The project's identity is the blueprint's (`projectSettings.basicSettings.name`); there is
|
|
115
|
-
no binding file
|
|
145
|
+
no binding file. Only `genesis init`, run on a project folder, writes there (the agent
|
|
146
|
+
instructions, `design/`, `.gitignore`); nothing else genesis-set does touches a project.
|
|
116
147
|
- **Getting the key:** the user signs in to the Genesis portal and creates one on its API keys
|
|
117
148
|
page, `https://portal.genesiscompiler.com/keys` (the stage API `sapi.genesiscompiler.com`
|
|
118
149
|
has `https://stage.genesiscompiler.com/keys`). The key is shown once.
|
package/bin/genesis-set.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import fs from 'node:fs';
|
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
8
|
import { configCommand, offerApiKey } from '../lib/config-cli.mjs';
|
|
9
|
+
import { initProject } from '../lib/init.mjs';
|
|
9
10
|
import { chooseAgents, doctor, install, resolveContext, uninstall, update } from '../lib/install.mjs';
|
|
10
11
|
|
|
11
12
|
const pkgRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
@@ -18,6 +19,7 @@ const HELP = `genesis ${pkg.version}: Genesis compiler skills for coding agents
|
|
|
18
19
|
|
|
19
20
|
Usage:
|
|
20
21
|
genesis install [--claude] [--codex] [--force] [--no-mcp] [--no-key] [--dry-run]
|
|
22
|
+
genesis init [<folder>] [--dry-run]
|
|
21
23
|
genesis update [--claude] [--codex] [--force] [--no-mcp] [--dry-run]
|
|
22
24
|
genesis uninstall [--dry-run]
|
|
23
25
|
genesis doctor
|
|
@@ -40,6 +42,13 @@ install makes sure mind-set ${pkg.dependencies?.['@mindbricks/mind-set'] ?? '
|
|
|
40
42
|
API key: with none set, it names the portal page that creates one
|
|
41
43
|
and, on a terminal, reads it hidden (Enter skips; --no-key skips
|
|
42
44
|
the step). Nothing is written into a project folder.
|
|
45
|
+
init prepares a project folder (default: the current one) so the agent
|
|
46
|
+
works the OpenAPPL + Genesis way from its first session: a marked
|
|
47
|
+
block in CLAUDE.md (Claude Code) and AGENTS.md (Codex) with the
|
|
48
|
+
order of work and the key rules (your own content in those files
|
|
49
|
+
is kept; a second run only refreshes the block), design/ and the
|
|
50
|
+
env and secrets lines of .gitignore. It prints the API key status
|
|
51
|
+
and a starter prompt. The one command that writes into a project.
|
|
43
52
|
update install for this version (and every agent installed before), then
|
|
44
53
|
delete older genesis-set corpus versions.
|
|
45
54
|
uninstall removes only what install recorded in ~/.genesis-set/installed.json;
|
|
@@ -81,6 +90,7 @@ function parseArgs(argv) {
|
|
|
81
90
|
|
|
82
91
|
const KNOWN_FLAGS = {
|
|
83
92
|
install: ['claude', 'codex', 'force', 'noMcp', 'noKey', 'dryRun'],
|
|
93
|
+
init: ['dryRun'],
|
|
84
94
|
update: ['claude', 'codex', 'force', 'noMcp', 'dryRun'],
|
|
85
95
|
uninstall: ['dryRun'],
|
|
86
96
|
doctor: [],
|
|
@@ -109,6 +119,13 @@ async function main(argv) {
|
|
|
109
119
|
err(`error: unknown option for ${command}: ${unknown.map((f) => `--${f}`).join(', ')}`);
|
|
110
120
|
return 2;
|
|
111
121
|
}
|
|
122
|
+
if (command === 'init') {
|
|
123
|
+
if (positional.length > 2) {
|
|
124
|
+
err('error: init takes one folder at most');
|
|
125
|
+
return 2;
|
|
126
|
+
}
|
|
127
|
+
return initProject({ dir: positional[1] ?? process.cwd(), env: process.env, out, err, dryRun: flags.dryRun === true });
|
|
128
|
+
}
|
|
112
129
|
if (command === 'keys') {
|
|
113
130
|
const { ensureKeyPage, keyPageClosed, closeKeyPage } = await import('../mcp/key-page.mjs');
|
|
114
131
|
const { openInBrowser } = await import('../mcp/key-tools.mjs');
|
package/lib/init.mjs
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// `genesis init [<folder>] [--dry-run]` (#9383): prepare a project folder so a
|
|
2
|
+
// coding agent works the OpenAPPL + Genesis way from its first session.
|
|
3
|
+
//
|
|
4
|
+
// The mind-set and genesis skills trigger on OpenAPPL / Genesis wording; a plain
|
|
5
|
+
// "build me a booking app" can make an agent hand-write a backend. The agents
|
|
6
|
+
// read CLAUDE.md (Claude Code) and AGENTS.md (Codex) at the start of every
|
|
7
|
+
// session, so init writes the project's way of working there:
|
|
8
|
+
//
|
|
9
|
+
// CLAUDE.md, AGENTS.md a marked block (begin / end markers); content outside
|
|
10
|
+
// it is the user's and is kept; a second run replaces
|
|
11
|
+
// only the block
|
|
12
|
+
// design/README.md where the design documents go (written only when absent)
|
|
13
|
+
// .gitignore the env and secrets lines that are missing
|
|
14
|
+
//
|
|
15
|
+
// This is the one genesis command that writes into a project folder, and only
|
|
16
|
+
// into the folder it is run on. It never runs git and never touches the key store.
|
|
17
|
+
|
|
18
|
+
import fs from 'node:fs';
|
|
19
|
+
import path from 'node:path';
|
|
20
|
+
|
|
21
|
+
import { maskSecret, portalKeysUrl, resolveSettings } from '../mcp/config.mjs';
|
|
22
|
+
|
|
23
|
+
export const BLOCK_BEGIN = '<!-- genesis init: begin. "genesis init" rewrites this block; edit outside it -->';
|
|
24
|
+
export const BLOCK_END = '<!-- genesis init: end -->';
|
|
25
|
+
|
|
26
|
+
export const GITIGNORE_LINES = ['.env', '.env.local', '*.secrets.env', 'node_modules/'];
|
|
27
|
+
|
|
28
|
+
/** The instructions both agents read. Plain text: the agent follows it, the user can edit around it. */
|
|
29
|
+
export const INSTRUCTIONS = `## How this project is built: OpenAPPL + Genesis
|
|
30
|
+
|
|
31
|
+
The backend of this project is an OpenAPPL blueprint, \`blueprint.json\`, compiled into service
|
|
32
|
+
code by the Genesis compiler. Never hand-write backend code: describe the system in the
|
|
33
|
+
blueprint, and the compiler writes the services. When a request is about the backend (data,
|
|
34
|
+
APIs, roles, payments, notifications), it is a change to the design or to the blueprint.
|
|
35
|
+
|
|
36
|
+
Work in this order; each step has its skill:
|
|
37
|
+
|
|
38
|
+
1. **Design** (openappl-blueprint-design): the requirements interview, then the requirement,
|
|
39
|
+
spec and blueprint-plan documents under \`design/\`. The user approves each document.
|
|
40
|
+
2. **Blueprint** (openappl-blueprint-authoring): write \`blueprint.json\` in small steps and run
|
|
41
|
+
\`mindset validate blueprint.json\` after every step. Custom logic the blueprint declares
|
|
42
|
+
(library functions, edge controllers) is written into the blueprint too
|
|
43
|
+
(genesis-generated-code).
|
|
44
|
+
3. **Review** (openappl-blueprint-review): the checklist audit; \`mindset spec-coverage\` shows
|
|
45
|
+
that every design document produced its part of the blueprint.
|
|
46
|
+
4. **Compile** (genesis-compiler-api): validate the whole blueprint, then build one service at a
|
|
47
|
+
time and follow each build to its final status. Builds are dry runs for now.
|
|
48
|
+
5. **Run and test** (genesis-run-and-test), **deploy** (genesis-deploy): on the generated code.
|
|
49
|
+
|
|
50
|
+
Code that talks to the system (a frontend, a client, tests) is written against the blueprint
|
|
51
|
+
as its contract (openappl-blueprint-contract).
|
|
52
|
+
|
|
53
|
+
**Keys and secrets:** never ask for a key or a password in the chat, and never write one into
|
|
54
|
+
a file of this project yourself. Register the key with the genesis key tools, give the user
|
|
55
|
+
the local key page link to save it there, and check that it is set; a key reaches a service's
|
|
56
|
+
gitignored env file only through the key tool that writes it. The user can open the key page
|
|
57
|
+
any time with \`genesis keys\`.`;
|
|
58
|
+
|
|
59
|
+
/** The block with its markers. */
|
|
60
|
+
export function instructionsBlock() {
|
|
61
|
+
return `${BLOCK_BEGIN}\n${INSTRUCTIONS}\n${BLOCK_END}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The new text of an instructions file: the block replaced, appended, or a new file. */
|
|
65
|
+
export function withBlock(existing) {
|
|
66
|
+
const block = instructionsBlock();
|
|
67
|
+
if (existing === null) return `# Project instructions\n\n${block}\n`;
|
|
68
|
+
const start = existing.indexOf(BLOCK_BEGIN);
|
|
69
|
+
const end = existing.indexOf(BLOCK_END, start < 0 ? 0 : start);
|
|
70
|
+
if (start >= 0 && end > start) {
|
|
71
|
+
return existing.slice(0, start) + block + existing.slice(end + BLOCK_END.length);
|
|
72
|
+
}
|
|
73
|
+
return `${existing.replace(/\s*$/, '')}\n\n${block}\n`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The .gitignore with the missing lines appended under a comment; unchanged when none is missing. */
|
|
77
|
+
export function withGitignore(existing) {
|
|
78
|
+
const have = new Set((existing ?? '').split(/\r?\n/).map((l) => l.trim()));
|
|
79
|
+
const missing = GITIGNORE_LINES.filter((l) => !have.has(l));
|
|
80
|
+
if (missing.length === 0) return existing;
|
|
81
|
+
const head = existing ? `${existing.replace(/\s*$/, '')}\n\n` : '';
|
|
82
|
+
return `${head}# genesis init: local env files hold secrets; never commit them\n${missing.join('\n')}\n`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const DESIGN_README = `# Design documents
|
|
86
|
+
|
|
87
|
+
The design of this project: the requirements interview record, the requirement and spec
|
|
88
|
+
documents, and the blueprint plan. The openappl-blueprint-design skill writes them here, one
|
|
89
|
+
file per document, and \`mindset design-check <docName>\` checks each one's structure.
|
|
90
|
+
`;
|
|
91
|
+
|
|
92
|
+
/** The prompt the user pastes into the agent to start. */
|
|
93
|
+
export const STARTER_PROMPT =
|
|
94
|
+
'Let us design a new application with OpenAPPL and compile it with Genesis: <one or two sentences on what it does and for whom>. ' +
|
|
95
|
+
'Start with the requirements interview.';
|
|
96
|
+
|
|
97
|
+
function read(file) {
|
|
98
|
+
try {
|
|
99
|
+
return fs.readFileSync(file, 'utf8');
|
|
100
|
+
} catch (e) {
|
|
101
|
+
if (e.code === 'ENOENT') return null;
|
|
102
|
+
throw e;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function isGitRepo(dir) {
|
|
107
|
+
let d = path.resolve(dir);
|
|
108
|
+
for (;;) {
|
|
109
|
+
if (fs.existsSync(path.join(d, '.git'))) return true;
|
|
110
|
+
const up = path.dirname(d);
|
|
111
|
+
if (up === d) return false;
|
|
112
|
+
d = up;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Prepare `dir`. Answers 0, or 1 when a file could not be written. `out` gets the
|
|
118
|
+
* actions (or, with dryRun, what would be done), the key status and the starter prompt.
|
|
119
|
+
*/
|
|
120
|
+
export function initProject({ dir = process.cwd(), env = process.env, out, err = out, dryRun = false }) {
|
|
121
|
+
const target = path.resolve(dir);
|
|
122
|
+
const act = (msg) => out(`${dryRun ? 'would ' : ''}${msg}`);
|
|
123
|
+
const writes = [];
|
|
124
|
+
|
|
125
|
+
if (!fs.existsSync(target)) {
|
|
126
|
+
act(`create ${target}`);
|
|
127
|
+
if (!dryRun) fs.mkdirSync(target, { recursive: true });
|
|
128
|
+
} else if (!fs.statSync(target).isDirectory()) {
|
|
129
|
+
err(`error: ${target} is not a folder`);
|
|
130
|
+
return 1;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
for (const name of ['CLAUDE.md', 'AGENTS.md']) {
|
|
134
|
+
const file = path.join(target, name);
|
|
135
|
+
const before = read(file);
|
|
136
|
+
const after = withBlock(before);
|
|
137
|
+
if (after === before) {
|
|
138
|
+
out(`${name}: up to date`);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
act(before === null ? `write ${name}` : before.includes(BLOCK_BEGIN) ? `update the genesis block in ${name}` : `add the genesis block to ${name} (your content is kept)`);
|
|
142
|
+
writes.push([file, after]);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const designReadme = path.join(target, 'design', 'README.md');
|
|
146
|
+
if (read(designReadme) === null) {
|
|
147
|
+
act('write design/README.md');
|
|
148
|
+
writes.push([designReadme, DESIGN_README]);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const gitignore = path.join(target, '.gitignore');
|
|
152
|
+
const gBefore = read(gitignore);
|
|
153
|
+
const gAfter = withGitignore(gBefore);
|
|
154
|
+
if (gAfter !== gBefore) {
|
|
155
|
+
act(gBefore === null ? 'write .gitignore' : 'add the env and secrets lines to .gitignore');
|
|
156
|
+
writes.push([gitignore, gAfter]);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (!dryRun) {
|
|
160
|
+
try {
|
|
161
|
+
for (const [file, text] of writes) {
|
|
162
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
163
|
+
fs.writeFileSync(file, text);
|
|
164
|
+
}
|
|
165
|
+
} catch (e) {
|
|
166
|
+
err(`error: ${e.message}`);
|
|
167
|
+
return 1;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const s = resolveSettings(env);
|
|
172
|
+
out('');
|
|
173
|
+
out(
|
|
174
|
+
s.apiKey
|
|
175
|
+
? `Genesis API key: ${maskSecret(s.apiKey) ?? 'set'} (from ${s.keySource}).`
|
|
176
|
+
: `Genesis API key: not set. Create one at ${portalKeysUrl(s.apiBase)}, then run "genesis config set-key" (or save it on the key page, "genesis keys").`,
|
|
177
|
+
);
|
|
178
|
+
if (!isGitRepo(target)) out('This folder is not a git repository yet; "git init" makes it one.');
|
|
179
|
+
out('');
|
|
180
|
+
out(`Next: open Claude Code or Codex in ${target} and start with:`);
|
|
181
|
+
out(` ${STARTER_PROMPT}`);
|
|
182
|
+
return 0;
|
|
183
|
+
}
|
package/lib/install.mjs
CHANGED
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
// mind-set keeps its own data folder (~/.mind-set, or MIND_SET_HOME) and is
|
|
17
17
|
// installed by its own CLI: when it is missing, or older than the range in
|
|
18
18
|
// package.json `dependencies["@mindbricks/mind-set"]`, install runs the mind-set package
|
|
19
|
-
// that came with genesis-set. Nothing is written into a project folder
|
|
19
|
+
// that came with genesis-set. Nothing is written into a project folder (only
|
|
20
|
+
// `genesis init`, run in a folder, writes there; see init.mjs).
|
|
20
21
|
|
|
21
22
|
import { spawnSync } from 'node:child_process';
|
|
22
23
|
import fs from 'node:fs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindbricks/genesis-set",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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": {
|