@mindbricks/genesis-set 0.2.1 → 0.4.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 +27 -0
- package/README.md +69 -1
- package/bin/genesis-set.mjs +58 -0
- package/lib/init.mjs +206 -0
- package/lib/install.mjs +5 -1
- package/mcp/board-data.mjs +267 -0
- package/mcp/board-html.mjs +329 -0
- package/mcp/board-md.mjs +123 -0
- package/mcp/board.mjs +316 -0
- package/mcp/key-store.mjs +56 -22
- package/mcp/key-tools.mjs +57 -10
- package/mcp/project.mjs +90 -0
- package/mcp/server.mjs +3 -1
- package/package.json +1 -1
- package/skills/genesis-compiler-api/SKILL.md +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
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.4.0 (pre-release)
|
|
7
|
+
|
|
8
|
+
- **`genesis board`:** a local board for a genesis project. It is read live from the folder and
|
|
9
|
+
shows:
|
|
10
|
+
- the design flow with each document's state and `design-check` result;
|
|
11
|
+
- the rendered documents;
|
|
12
|
+
- the interview (status, coverage ledger, open questions);
|
|
13
|
+
- the blueprint with its validation;
|
|
14
|
+
- the project and global keys;
|
|
15
|
+
- the next step.
|
|
16
|
+
|
|
17
|
+
It runs on 127.0.0.1:4747 (bookmarkable, read-only); the link `genesis board` opens can
|
|
18
|
+
change keys. One board per project, reused. The agent gets it with `genesis_openBoard`, and
|
|
19
|
+
the `genesis init` instructions tell it to offer the board.
|
|
20
|
+
- **Projects:** `genesis init` writes `.genesis/project.json` (a random id and a name).
|
|
21
|
+
- **Project keys:** they live in the home folder under that id. Inside a project,
|
|
22
|
+
`genesis_requestKey` stores a project key by default, `genesis_listKeys` labels each key's
|
|
23
|
+
scope, and `genesis_writeKeyToEnvFile` prefers the project key. `genesis keys` stays global.
|
|
24
|
+
|
|
25
|
+
## 0.3.0 (pre-release)
|
|
26
|
+
|
|
27
|
+
- `genesis init [<folder>] [--dry-run]` prepares a project folder so the agent works the
|
|
28
|
+
OpenAPPL + Genesis way from its first session. It writes a marked block into `CLAUDE.md` and
|
|
29
|
+
`AGENTS.md` (the order of work with the skill for each step, and the key rules) and creates
|
|
30
|
+
`design/` and the env and secrets lines of `.gitignore`; it prints the API key status and a
|
|
31
|
+
starter prompt. Content outside the block is kept, and a second run changes nothing.
|
|
32
|
+
|
|
6
33
|
## 0.2.1 (pre-release)
|
|
7
34
|
|
|
8
35
|
- A stored key is shown as its type prefix and last four characters (`sk_mbx_...9f3a`,
|
package/README.md
CHANGED
|
@@ -24,15 +24,70 @@ 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 writes the project identity `.genesis/project.json` (a random id and a name, no secret,
|
|
44
|
+
fine to commit), creates `design/` and the env and secrets lines of `.gitignore`, and prints the
|
|
45
|
+
API key status and a starter prompt.
|
|
46
|
+
- Your own content in `CLAUDE.md` and `AGENTS.md` is kept.
|
|
47
|
+
- A second run only refreshes the block.
|
|
48
|
+
- `--dry-run` shows what it would write.
|
|
49
|
+
|
|
50
|
+
Then open the agent in the folder and start, for example:
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
Let us design a new application with OpenAPPL and compile it with Genesis: a table booking
|
|
54
|
+
system for cafes, with owner, waiter and guest roles. Start with the requirements interview.
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## The project board
|
|
58
|
+
|
|
59
|
+
`genesis board` in a project folder opens the project's board in your browser. The board is read
|
|
60
|
+
live from the folder as the agent writes, and shows:
|
|
61
|
+
- **Overview:** the next step, and the design flow from the interview to the test report, with
|
|
62
|
+
every document written, waiting or "if needed" and its `design-check` result;
|
|
63
|
+
- **Documents:** every design document, rendered;
|
|
64
|
+
- **Interview:** its status, the coverage ledger and the open questions;
|
|
65
|
+
- **Blueprint:** its services, data objects and APIs, and the `mindset validate` result;
|
|
66
|
+
- **Keys:** this project's keys and your global ones; set, replace, clear, delete and add.
|
|
67
|
+
|
|
68
|
+
The board runs on `http://127.0.0.1:4747/` (the next free port if that one is taken;
|
|
69
|
+
`GENESIS_BOARD_PORT` moves it) until it is idle for an hour or you press Ctrl+C.
|
|
70
|
+
- **Bookmark it:** the plain address is read-only.
|
|
71
|
+
- **Changing keys** takes the link `genesis board` opens, which sets a write cookie for that run.
|
|
72
|
+
- **One board per project:** a second `genesis board` for the same project reuses the running
|
|
73
|
+
one.
|
|
74
|
+
- **The agent knows the board** (the `genesis init` instructions and the `genesis_openBoard`
|
|
75
|
+
tool). It offers the link when it finishes a design document, and answers "where can I see
|
|
76
|
+
this?" with it.
|
|
77
|
+
|
|
78
|
+
`genesis keys` stays the page of your global keys only, from any folder.
|
|
79
|
+
|
|
27
80
|
## Commands
|
|
28
81
|
|
|
29
82
|
| Command | What it does |
|
|
30
83
|
|---|---|
|
|
84
|
+
| `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
85
|
| `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
86
|
| `genesis update [...]` | Installs this version for every agent installed before (and every detected one), then deletes older corpus versions. |
|
|
33
87
|
| `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
88
|
| `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
89
|
| `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. |
|
|
90
|
+
| `genesis board [<folder>] [--no-open]` | Opens the board of the genesis project in `<folder>` (default: the current one): design flow, documents, interview, blueprint, project and global keys (see "The project board"). |
|
|
36
91
|
| `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
92
|
| `genesis mcp` | Runs the MCP server on stdio from the package (for a registration by hand). |
|
|
38
93
|
|
|
@@ -60,6 +115,18 @@ comes back in the Genesis error shape `{ "error": { "code", "message", "details"
|
|
|
60
115
|
|
|
61
116
|
### Keys: the local key page
|
|
62
117
|
|
|
118
|
+
Keys have a **scope**:
|
|
119
|
+
- **project:** this genesis project only; the default for a key the agent requests inside a
|
|
120
|
+
project.
|
|
121
|
+
- **global:** yours in every project, like the Genesis API key.
|
|
122
|
+
|
|
123
|
+
Both scopes are stored in your home folder: the global ones in `~/.genesis-set/config.json`, a
|
|
124
|
+
project's in `~/.genesis-set/projects/<project id>/keys.json`. Neither is ever stored in the
|
|
125
|
+
project folder. A key is looked up in the project first, then globally.
|
|
126
|
+
|
|
127
|
+
- **The board:** inside a project, the board's Keys tab shows both scopes.
|
|
128
|
+
- **`genesis keys`:** shows the global ones.
|
|
129
|
+
|
|
63
130
|
A coding agent keeps needing secrets: the Genesis API key, and provider keys (payment, mail,
|
|
64
131
|
storage, AI) to run the generated services. The rule is that no value is ever typed into the chat.
|
|
65
132
|
Instead the MCP server serves a local key page, and four tools that never call the API and work
|
|
@@ -112,7 +179,8 @@ without a Genesis API key:
|
|
|
112
179
|
### Projects and credentials
|
|
113
180
|
|
|
114
181
|
- The project's identity is the blueprint's (`projectSettings.basicSettings.name`); there is
|
|
115
|
-
no binding file
|
|
182
|
+
no binding file. Only `genesis init`, run on a project folder, writes there (the agent
|
|
183
|
+
instructions, `design/`, `.gitignore`); nothing else genesis-set does touches a project.
|
|
116
184
|
- **Getting the key:** the user signs in to the Genesis portal and creates one on its API keys
|
|
117
185
|
page, `https://portal.genesiscompiler.com/keys` (the stage API `sapi.genesiscompiler.com`
|
|
118
186
|
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,10 +19,12 @@ 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
|
|
24
26
|
genesis config [show | set-key | unset-key | set-base <url> | unset-base]
|
|
27
|
+
genesis board [<folder>] [--no-open]
|
|
25
28
|
genesis keys [--no-open]
|
|
26
29
|
genesis mcp
|
|
27
30
|
genesis --version | --help
|
|
@@ -40,6 +43,13 @@ install makes sure mind-set ${pkg.dependencies?.['@mindbricks/mind-set'] ?? '
|
|
|
40
43
|
API key: with none set, it names the portal page that creates one
|
|
41
44
|
and, on a terminal, reads it hidden (Enter skips; --no-key skips
|
|
42
45
|
the step). Nothing is written into a project folder.
|
|
46
|
+
init prepares a project folder (default: the current one) so the agent
|
|
47
|
+
works the OpenAPPL + Genesis way from its first session: a marked
|
|
48
|
+
block in CLAUDE.md (Claude Code) and AGENTS.md (Codex) with the
|
|
49
|
+
order of work and the key rules (your own content in those files
|
|
50
|
+
is kept; a second run only refreshes the block), design/ and the
|
|
51
|
+
env and secrets lines of .gitignore. It prints the API key status
|
|
52
|
+
and a starter prompt. The one command that writes into a project.
|
|
43
53
|
update install for this version (and every agent installed before), then
|
|
44
54
|
delete older genesis-set corpus versions.
|
|
45
55
|
uninstall removes only what install recorded in ~/.genesis-set/installed.json;
|
|
@@ -47,6 +57,14 @@ uninstall removes only what install recorded in ~/.genesis-set/installed.json;
|
|
|
47
57
|
doctor both versions (genesis-set and mind-set) and whether they are
|
|
48
58
|
compatible, the skills and the MCP server per agent, where the API
|
|
49
59
|
key comes from (never its value) and the API base.
|
|
60
|
+
board opens the project board of the genesis project in <folder>
|
|
61
|
+
(default: the current one; "genesis init" makes a project): the
|
|
62
|
+
design flow with each document's state and check, the documents,
|
|
63
|
+
the interview, the blueprint and its validation, and the project's
|
|
64
|
+
and your global keys. It runs on 127.0.0.1:${'4747'} (or the next free
|
|
65
|
+
port) until it is idle for an hour or Ctrl+C; a board already
|
|
66
|
+
running for the project is reused. The link it opens can change
|
|
67
|
+
keys; the plain address (bookmark it) is read-only.
|
|
50
68
|
keys opens the local key page in your browser (the page the agent
|
|
51
69
|
links to): add, change, clear or delete the keys your agent uses.
|
|
52
70
|
The link is new every time; the page closes after 15 idle minutes
|
|
@@ -81,11 +99,13 @@ function parseArgs(argv) {
|
|
|
81
99
|
|
|
82
100
|
const KNOWN_FLAGS = {
|
|
83
101
|
install: ['claude', 'codex', 'force', 'noMcp', 'noKey', 'dryRun'],
|
|
102
|
+
init: ['dryRun'],
|
|
84
103
|
update: ['claude', 'codex', 'force', 'noMcp', 'dryRun'],
|
|
85
104
|
uninstall: ['dryRun'],
|
|
86
105
|
doctor: [],
|
|
87
106
|
config: [],
|
|
88
107
|
keys: ['noOpen'],
|
|
108
|
+
board: ['noOpen'],
|
|
89
109
|
mcp: [],
|
|
90
110
|
};
|
|
91
111
|
|
|
@@ -109,6 +129,44 @@ async function main(argv) {
|
|
|
109
129
|
err(`error: unknown option for ${command}: ${unknown.map((f) => `--${f}`).join(', ')}`);
|
|
110
130
|
return 2;
|
|
111
131
|
}
|
|
132
|
+
if (command === 'init') {
|
|
133
|
+
if (positional.length > 2) {
|
|
134
|
+
err('error: init takes one folder at most');
|
|
135
|
+
return 2;
|
|
136
|
+
}
|
|
137
|
+
return initProject({ dir: positional[1] ?? process.cwd(), env: process.env, out, err, dryRun: flags.dryRun === true });
|
|
138
|
+
}
|
|
139
|
+
if (command === 'board') {
|
|
140
|
+
if (positional.length > 2) {
|
|
141
|
+
err('error: board takes one folder at most');
|
|
142
|
+
return 2;
|
|
143
|
+
}
|
|
144
|
+
const { findProject } = await import('../mcp/project.mjs');
|
|
145
|
+
const folder = path.resolve(positional[1] ?? process.cwd());
|
|
146
|
+
const project = findProject(folder);
|
|
147
|
+
if (!project) {
|
|
148
|
+
err(`error: ${folder} is not a genesis project. Run "genesis init" there first (or "genesis keys" for your global keys).`);
|
|
149
|
+
return 1;
|
|
150
|
+
}
|
|
151
|
+
const { ensureBoard, boardClosed, closeBoard } = await import('../mcp/board.mjs');
|
|
152
|
+
const { openInBrowser } = await import('../mcp/key-tools.mjs');
|
|
153
|
+
const board = await ensureBoard({ env: process.env, project });
|
|
154
|
+
out(`Genesis board for "${project.name}": ${board.readUrl}`);
|
|
155
|
+
if (flags.noOpen !== true && !openInBrowser(board.url)) out('Could not open a browser: open the link yourself.');
|
|
156
|
+
if (board.reused && board.idleMinutes === null) {
|
|
157
|
+
out(board.url === board.readUrl ? 'The board already runs in another process (read-only link).' : 'The board already runs in another process; opened it there.');
|
|
158
|
+
return 0;
|
|
159
|
+
}
|
|
160
|
+
if (flags.noOpen === true) out(`To change keys, open: ${board.url}`);
|
|
161
|
+
out(`It closes after ${board.idleMinutes} idle minutes, or press Ctrl+C.`);
|
|
162
|
+
process.once('SIGINT', () => closeBoard());
|
|
163
|
+
process.once('SIGTERM', () => closeBoard());
|
|
164
|
+
const keepAlive = setInterval(() => {}, 1 << 30);
|
|
165
|
+
await boardClosed();
|
|
166
|
+
clearInterval(keepAlive);
|
|
167
|
+
out('The board is closed.');
|
|
168
|
+
return 0;
|
|
169
|
+
}
|
|
112
170
|
if (command === 'keys') {
|
|
113
171
|
const { ensureKeyPage, keyPageClosed, closeKeyPage } = await import('../mcp/key-page.mjs');
|
|
114
172
|
const { openInBrowser } = await import('../mcp/key-tools.mjs');
|
package/lib/init.mjs
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
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
|
+
// .genesis/project.json the project identity (random id, name; no secret,
|
|
15
|
+
// may be committed); an existing one is never changed.
|
|
16
|
+
// The project's keys live in the user's home under it.
|
|
17
|
+
//
|
|
18
|
+
// This is the one genesis command that writes into a project folder, and only
|
|
19
|
+
// into the folder it is run on. It never runs git and never touches the key store.
|
|
20
|
+
|
|
21
|
+
import fs from 'node:fs';
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
|
|
24
|
+
import { maskSecret, portalKeysUrl, resolveSettings } from '../mcp/config.mjs';
|
|
25
|
+
import { PROJECT_DIR, PROJECT_FILE, ensureProject } from '../mcp/project.mjs';
|
|
26
|
+
|
|
27
|
+
export const BLOCK_BEGIN = '<!-- genesis init: begin. "genesis init" rewrites this block; edit outside it -->';
|
|
28
|
+
export const BLOCK_END = '<!-- genesis init: end -->';
|
|
29
|
+
|
|
30
|
+
export const GITIGNORE_LINES = ['.env', '.env.local', '*.secrets.env', 'node_modules/'];
|
|
31
|
+
|
|
32
|
+
/** The instructions both agents read. Plain text: the agent follows it, the user can edit around it. */
|
|
33
|
+
export const INSTRUCTIONS = `## How this project is built: OpenAPPL + Genesis
|
|
34
|
+
|
|
35
|
+
The backend of this project is an OpenAPPL blueprint, \`blueprint.json\`, compiled into service
|
|
36
|
+
code by the Genesis compiler. Never hand-write backend code: describe the system in the
|
|
37
|
+
blueprint, and the compiler writes the services. When a request is about the backend (data,
|
|
38
|
+
APIs, roles, payments, notifications), it is a change to the design or to the blueprint.
|
|
39
|
+
|
|
40
|
+
Work in this order; each step has its skill:
|
|
41
|
+
|
|
42
|
+
1. **Design** (openappl-blueprint-design): the requirements interview, then the requirement,
|
|
43
|
+
spec and blueprint-plan documents under \`design/\`. The user approves each document.
|
|
44
|
+
2. **Blueprint** (openappl-blueprint-authoring): write \`blueprint.json\` in small steps and run
|
|
45
|
+
\`mindset validate blueprint.json\` after every step. Custom logic the blueprint declares
|
|
46
|
+
(library functions, edge controllers) is written into the blueprint too
|
|
47
|
+
(genesis-generated-code).
|
|
48
|
+
3. **Review** (openappl-blueprint-review): the checklist audit; \`mindset spec-coverage\` shows
|
|
49
|
+
that every design document produced its part of the blueprint.
|
|
50
|
+
4. **Compile** (genesis-compiler-api): validate the whole blueprint, then build one service at a
|
|
51
|
+
time and follow each build to its final status. Builds are dry runs for now.
|
|
52
|
+
5. **Run and test** (genesis-run-and-test), **deploy** (genesis-deploy): on the generated code.
|
|
53
|
+
|
|
54
|
+
Code that talks to the system (a frontend, a client, tests) is written against the blueprint
|
|
55
|
+
as its contract (openappl-blueprint-contract).
|
|
56
|
+
|
|
57
|
+
**Keys and secrets:** never ask for a key or a password in the chat, and never write one into
|
|
58
|
+
a file of this project yourself. Register the key with the genesis key tools, give the user
|
|
59
|
+
the local key page link to save it there, and check that it is set; a key reaches a service's
|
|
60
|
+
gitignored env file only through the key tool that writes it. A key this project needs is a
|
|
61
|
+
project key (the default here); the user's own keys, such as the Genesis API key, are global.
|
|
62
|
+
|
|
63
|
+
**The project board:** the user follows this project on a local board: the design flow with the
|
|
64
|
+
state of every document, the documents, the interview, the blueprint and its validation, and
|
|
65
|
+
the keys. They open it with \`genesis board\` in this folder; you give its link with the genesis
|
|
66
|
+
board tool (and open it in the browser when they ask). Offer it when you finish a design
|
|
67
|
+
document or the blueprint, and answer "where can I see this?" with it. The user's global keys
|
|
68
|
+
alone are behind \`genesis keys\`.`;
|
|
69
|
+
|
|
70
|
+
/** The block with its markers. */
|
|
71
|
+
export function instructionsBlock() {
|
|
72
|
+
return `${BLOCK_BEGIN}\n${INSTRUCTIONS}\n${BLOCK_END}`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The new text of an instructions file: the block replaced, appended, or a new file. */
|
|
76
|
+
export function withBlock(existing) {
|
|
77
|
+
const block = instructionsBlock();
|
|
78
|
+
if (existing === null) return `# Project instructions\n\n${block}\n`;
|
|
79
|
+
const start = existing.indexOf(BLOCK_BEGIN);
|
|
80
|
+
const end = existing.indexOf(BLOCK_END, start < 0 ? 0 : start);
|
|
81
|
+
if (start >= 0 && end > start) {
|
|
82
|
+
return existing.slice(0, start) + block + existing.slice(end + BLOCK_END.length);
|
|
83
|
+
}
|
|
84
|
+
return `${existing.replace(/\s*$/, '')}\n\n${block}\n`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The .gitignore with the missing lines appended under a comment; unchanged when none is missing. */
|
|
88
|
+
export function withGitignore(existing) {
|
|
89
|
+
const have = new Set((existing ?? '').split(/\r?\n/).map((l) => l.trim()));
|
|
90
|
+
const missing = GITIGNORE_LINES.filter((l) => !have.has(l));
|
|
91
|
+
if (missing.length === 0) return existing;
|
|
92
|
+
const head = existing ? `${existing.replace(/\s*$/, '')}\n\n` : '';
|
|
93
|
+
return `${head}# genesis init: local env files hold secrets; never commit them\n${missing.join('\n')}\n`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const DESIGN_README = `# Design documents
|
|
97
|
+
|
|
98
|
+
The design of this project: the requirements interview record, the requirement and spec
|
|
99
|
+
documents, and the blueprint plan. The openappl-blueprint-design skill writes them here, one
|
|
100
|
+
file per document, and \`mindset design-check <docName>\` checks each one's structure.
|
|
101
|
+
`;
|
|
102
|
+
|
|
103
|
+
/** The prompt the user pastes into the agent to start. */
|
|
104
|
+
export const STARTER_PROMPT =
|
|
105
|
+
'Let us design a new application with OpenAPPL and compile it with Genesis: <one or two sentences on what it does and for whom>. ' +
|
|
106
|
+
'Start with the requirements interview.';
|
|
107
|
+
|
|
108
|
+
function read(file) {
|
|
109
|
+
try {
|
|
110
|
+
return fs.readFileSync(file, 'utf8');
|
|
111
|
+
} catch (e) {
|
|
112
|
+
if (e.code === 'ENOENT') return null;
|
|
113
|
+
throw e;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function isGitRepo(dir) {
|
|
118
|
+
let d = path.resolve(dir);
|
|
119
|
+
for (;;) {
|
|
120
|
+
if (fs.existsSync(path.join(d, '.git'))) return true;
|
|
121
|
+
const up = path.dirname(d);
|
|
122
|
+
if (up === d) return false;
|
|
123
|
+
d = up;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Prepare `dir`. Answers 0, or 1 when a file could not be written. `out` gets the
|
|
129
|
+
* actions (or, with dryRun, what would be done), the key status and the starter prompt.
|
|
130
|
+
*/
|
|
131
|
+
export function initProject({ dir = process.cwd(), env = process.env, out, err = out, dryRun = false }) {
|
|
132
|
+
const target = path.resolve(dir);
|
|
133
|
+
const act = (msg) => out(`${dryRun ? 'would ' : ''}${msg}`);
|
|
134
|
+
const writes = [];
|
|
135
|
+
|
|
136
|
+
if (!fs.existsSync(target)) {
|
|
137
|
+
act(`create ${target}`);
|
|
138
|
+
if (!dryRun) fs.mkdirSync(target, { recursive: true });
|
|
139
|
+
} else if (!fs.statSync(target).isDirectory()) {
|
|
140
|
+
err(`error: ${target} is not a folder`);
|
|
141
|
+
return 1;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
for (const name of ['CLAUDE.md', 'AGENTS.md']) {
|
|
145
|
+
const file = path.join(target, name);
|
|
146
|
+
const before = read(file);
|
|
147
|
+
const after = withBlock(before);
|
|
148
|
+
if (after === before) {
|
|
149
|
+
out(`${name}: up to date`);
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
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)`);
|
|
153
|
+
writes.push([file, after]);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let project;
|
|
157
|
+
try {
|
|
158
|
+
const res = ensureProject(target, { dryRun });
|
|
159
|
+
project = res.project;
|
|
160
|
+
if (res.created) act(`write ${PROJECT_DIR}/${PROJECT_FILE} (project "${project.name}")`);
|
|
161
|
+
} catch (e) {
|
|
162
|
+
err(`error: ${e.message}`);
|
|
163
|
+
return 1;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const designReadme = path.join(target, 'design', 'README.md');
|
|
167
|
+
if (read(designReadme) === null) {
|
|
168
|
+
act('write design/README.md');
|
|
169
|
+
writes.push([designReadme, DESIGN_README]);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const gitignore = path.join(target, '.gitignore');
|
|
173
|
+
const gBefore = read(gitignore);
|
|
174
|
+
const gAfter = withGitignore(gBefore);
|
|
175
|
+
if (gAfter !== gBefore) {
|
|
176
|
+
act(gBefore === null ? 'write .gitignore' : 'add the env and secrets lines to .gitignore');
|
|
177
|
+
writes.push([gitignore, gAfter]);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (!dryRun) {
|
|
181
|
+
try {
|
|
182
|
+
for (const [file, text] of writes) {
|
|
183
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
184
|
+
fs.writeFileSync(file, text);
|
|
185
|
+
}
|
|
186
|
+
} catch (e) {
|
|
187
|
+
err(`error: ${e.message}`);
|
|
188
|
+
return 1;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const s = resolveSettings(env);
|
|
193
|
+
out('');
|
|
194
|
+
out(`Project "${project.name}" (id ${project.id}). Its keys are kept in your home folder, never in this folder.`);
|
|
195
|
+
out(
|
|
196
|
+
s.apiKey
|
|
197
|
+
? `Genesis API key: ${maskSecret(s.apiKey) ?? 'set'} (from ${s.keySource}).`
|
|
198
|
+
: `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").`,
|
|
199
|
+
);
|
|
200
|
+
if (!isGitRepo(target)) out('This folder is not a git repository yet; "git init" makes it one.');
|
|
201
|
+
out('');
|
|
202
|
+
out('Follow the project on its board: "genesis board" in this folder.');
|
|
203
|
+
out(`Next: open Claude Code or Codex in ${target} and start with:`);
|
|
204
|
+
out(` ${STARTER_PROMPT}`);
|
|
205
|
+
return 0;
|
|
206
|
+
}
|
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';
|
|
@@ -435,6 +436,9 @@ export function install(ctx, agentNames, { force = false, skipMindSet = false, m
|
|
|
435
436
|
corpus: corpusDir,
|
|
436
437
|
current,
|
|
437
438
|
mindSetCorpus: mindSet,
|
|
439
|
+
// Where the mind-set package is, so the board can run its design-check and
|
|
440
|
+
// validate code from the standalone MCP server copy (#9386).
|
|
441
|
+
mindSetPackage: bundledMindSet(ctx)?.dir ?? previous?.mindSetPackage,
|
|
438
442
|
corpora: [...new Set([...(previous?.corpora ?? []), corpusDir])],
|
|
439
443
|
agents,
|
|
440
444
|
mcp: mcp || previous?.mcp ? { server: mcpServerFile(ctx), agents: mcpAgents } : undefined,
|