create-nisc 0.9.4 → 0.11.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 CHANGED
@@ -1,5 +1,46 @@
1
1
  # create-nisc
2
2
 
3
+ ## 0.11.0
4
+
5
+ ### Patch Changes
6
+
7
+ - c2d3c7c: A folder that is a file, inside a file, or with a file where the app needs a folder (a file named `src`) is refused with a sentence that names it, and nothing is written; before, it failed with Node's own ENOTDIR, sometimes after writing part of the app.
8
+ An `item.json` of the wrong shape is refused when the templates are read, with the file and the field named.
9
+ - 7842b56: Its source is made of modules (`command`, `generate`, `catalog`); the command, its exports and the apps it makes are the same.
10
+ The question asked about a folder that is not empty says it `already has` that many things in it; the README and the templates' comments and words are reworded to match.
11
+ A new app behind moss (classic or model-first) checks that its charter reads every key it is given: `npm run check` fails on a misspelt key such as `denny`. Apps made before are not changed.
12
+ A `.gitignore` that is a folder, or an `.env` that is a folder when the app asks for keys, is refused with the sentence that names what is in the way, and nothing is written; before, it failed with Node's own EISDIR.
13
+ An `.env` that already sets a key as `NAME = value` or `export NAME=value` no longer gains an empty `NAME=` after it when the key is left empty, which hid the key from Node. A key that is given is added as before.
14
+ The "Next" lines quote a folder whose path has a space or a shell character: `cd "with space\app"`.
15
+ The README's `env` row names an option's `hint`, which the question shows.
16
+ A new model-first app reads its own `.env` wherever the command is run from (`nisc build --root app` from the folder above found no key before).
17
+ A new model-first app's words match its code: the `ask` function's description says it is sent `{ asked }`, and its AGENTS.md names `begin` and `said` and counts the tour's places right.
18
+ A new model-first app's PLAN.md lists, as open, who may ask the model: as made, everyone (`public`), so anybody who reaches the deployed app spends the Groq key; its AGENTS.md says the same under "Deploying".
19
+ A new app behind moss no longer depends on `@niscorp/tide`, which nothing in it imports; an app that wants tide adds it.
20
+ A new app has `@niscorp/cli` as a dependency, and an own-shell DOM app `jsdom` (its `nisc.config.ts` imports it), so a host that installs the dependencies alone can `npm start` it. An own-shell React app keeps `jsdom` as a dev dependency, for the build's check.
21
+
22
+ ## 0.10.0
23
+
24
+ No changes in this release.
25
+
26
+ ## 0.9.6
27
+
28
+ ### Patch Changes
29
+
30
+ - 686e9c7: **`$localeDate` takes its zone from the source, and Prism's grammar is at version 4.** `options.timeZone` is a node, as `value` and `locale` already were: `{ "timeZone": { "$ref": "$.zone" } }` words a date where its reader is, so one mapping serves every zone instead of one config per zone. A written zone works as before and is still folded at compile time; a config with a bound zone compiles to one fingerprint, and `execute` reads the zone from each source.
31
+
32
+ A zone written in the program is still text or it is refused as the config is read, as before (`E_SCHEMA`, its message now naming both forms a zone may take); what is new is an op there that reads one. The JSON Schema (`getConfigJsonSchema`, a profile's) says only "a node" at `timeZone` and does not carry that rule, as it does not carry a `$ref` path's; `validate` and `compile` do. The form an error message shows for `$localeDate` reads `"timeZone"?: <node>`. A zone `Intl` does not know, written or read — or a bound one that is not text, `null` included — is refused with `E_TYPE` at `$localeDate.options.timeZone`, saying what it got. An unknown written zone used to escape as a bare `RangeError` from `Intl`; it is now a `PrismError`, which is still an `Error`. The zone is looked at after the date, so a bad date is still `E_DATE_INVALID` whatever the zone, and a written zone spends no step of the budget, as before.
33
+
34
+ **A locale tag `Intl` cannot read is refused the same way.** `$localeDate` and `$localeNumber` refuse text `Intl` cannot read as a locale tag (`"en_GB"`), written or read, with `E_TYPE` at `locale`, where it escaped as a bare `RangeError`. It is looked at after the date, so a bad date is still `E_DATE_INVALID`; where both the zone and the locale are bad, the zone is refused first. A well-formed tag `Intl` has no data for is read as before. `$localeMoney` is unchanged: it still prints the code beside the amount for a locale it cannot read, with a divisor of 100 whatever the currency, which DOCS.md now says.
35
+
36
+ **The grammar.** `nisc.prism` goes from 3 to 4 with one migration that rewrites nothing: this is an addition, and a reader at 3 must refuse a config with a bound zone.
37
+
38
+ **What to change:** an app that keeps Prism configs in its source moves its stamp: `npm run strata upgrade`, then `npm run strata verify`. There is nothing to edit; `strata.lock.json` goes to `nisc.prism 4`. A config written before parses to exactly what it did, so a compiled IR's fingerprint does not move. An app made by `create-nisc` from this release starts at `nisc.prism 4`.
39
+
40
+ ## 0.9.5
41
+
42
+ No changes in this release.
43
+
3
44
  ## 0.9.4
4
45
 
5
46
  ### Patch Changes
package/README.md CHANGED
@@ -50,7 +50,7 @@ The structure the rulebook describes, and a first screen that works:
50
50
  is picked up by the page;
51
51
  - `npm run dev`, `build`, `check` and `start` — and, with the shell in the
52
52
  page, `export` — all the `nisc` command; `nisc dev` runs a moss app's server inside vite, so its
53
- `vite.config.ts` holds nothing but the framework's plugin;
53
+ `vite.config.ts` has nothing but the framework's plugin;
54
54
  - four checks: the artifacts are pure, schema-valid JSON; the app keeps nisc's
55
55
  shape (`shape-check`); the source is at the installed grammars
56
56
  (`strata.lock.json`); the welcome screen is served, drawn and pressed — with
@@ -95,16 +95,19 @@ And the documents:
95
95
 
96
96
  ## A folder that already exists
97
97
 
98
- It never overwrites. A folder that already holds something is fine — a fresh
98
+ It never overwrites. A folder that already has something in it is fine — a fresh
99
99
  repository's `.git`, a `LICENSE` — as long as nothing a new app would write is
100
100
  there. Your `README.md` is kept; your `.gitignore` gets the lines it lacks. If
101
- anything else it would write already exists, it writes **nothing** and names
102
- the files; make the app in a subfolder instead:
101
+ anything else it would write already exists, or a file stands where it needs a
102
+ folder (a file named `src`), it writes **nothing** and names them; make the app
103
+ in a subfolder instead:
103
104
 
104
105
  ```bash
105
106
  npm create nisc site -- --page --dom
106
107
  ```
107
108
 
109
+ A folder that is a file, or inside one, is refused before any other question.
110
+
108
111
  ## How an app is put together
109
112
 
110
113
  An app is made of **items**, one for each answer, plus the ones every app has.
@@ -133,13 +136,15 @@ templates/
133
136
  | `default` | the answer taken when nobody gives one: exactly one per question |
134
137
  | `requires` | `{ question: item }` — what another question must be answered with; that question is then not asked |
135
138
  | `package` | a `package.json` fragment: fields, `scripts`, `dependencies`, `devDependencies` (`workspace:^` for a nisc package) |
136
- | `env` | the keys it asks for: `{ name, message, required? }`, or `{ choose, message, options: [{ value, label, keys? }] }` |
139
+ | `env` | the keys it asks for: `{ name, message, required? }`, or `{ choose, message, options: [{ value, label, hint?, keys? }] }` |
137
140
  | `docs` | its lines in AGENTS.md and PLAN.md: `is`, `where`, `runs`, `decisions`, `answered`, `open`, `order` |
138
141
  | `with` | `{ <other item>: { package, env, docs } }` — added only when that other item is chosen too |
139
142
 
140
- Two items that write the same file, or disagree about a field, a script or a
141
- dependency, is a mistake in the templates: it is refused before anything is
142
- written. In every file, `nisc-template-app` becomes the app's name.
143
+ An `item.json` with a field of the wrong shape is refused when the templates
144
+ are read, naming the file and the field (`in round/item.json, env[0].message is
145
+ not a string`). Two items that write the same file, or disagree about a field, a
146
+ script or a dependency, is a mistake in the templates: it is refused before
147
+ anything is written. In every file, `nisc-template-app` becomes the app's name.
143
148
 
144
149
  ## Keys
145
150
 
@@ -147,7 +152,7 @@ An item that needs keys asks for them after the questions, masked, and they go
147
152
  into `.env`; `.env.example` gets the names alone. A key left empty is filled in
148
153
  `.env` later. Keys are never flags — a flag stays in the shell's history — so
149
154
  with no terminal to ask in, they are read from the environment. A `.env` that
150
- is already there keeps what it holds and gains only the lines it lacks.
155
+ is already there keeps what it has and gains only the lines it lacks.
151
156
 
152
157
  ## Why it can be trusted to work
153
158
 
@@ -1,9 +1,9 @@
1
- import { readdirSync, existsSync, statSync, readFileSync, mkdirSync, writeFileSync } from 'fs';
2
- import { join, extname, dirname } from 'path';
1
+ import { existsSync, readdirSync, readFileSync, mkdirSync, writeFileSync, statSync } from 'fs';
2
+ import { join, extname, dirname, relative, sep } from 'path';
3
3
  import { fileURLToPath } from 'url';
4
4
 
5
5
  // <define:__NISC_SET__>
6
- var define_NISC_SET_default = { "@niscorp/charter": "0.1.5", "@niscorp/cli": "0.9.1", "@niscorp/cortex": "0.1.6", "@niscorp/loom": "0.5.0", "@niscorp/moss": "0.9.2", "@niscorp/nisc": "0.9.4", "@niscorp/nova": "0.5.2", "@niscorp/prism": "0.3.3", "@niscorp/signal": "0.1.9", "@niscorp/solid": "0.1.3", "@niscorp/strata": "0.1.9", "@niscorp/tide": "0.1.11", "@niscorp/vex": "0.4.4" };
6
+ var define_NISC_SET_default = { "@niscorp/charter": "0.2.0", "@niscorp/cli": "0.10.0", "@niscorp/cortex": "0.2.0", "@niscorp/haptic": "0.3.0", "@niscorp/loom": "0.6.0", "@niscorp/moss": "0.10.0", "@niscorp/nisc": "0.11.0", "@niscorp/nova": "0.6.0", "@niscorp/prism": "0.4.0", "@niscorp/signal": "0.2.0", "@niscorp/solid": "0.2.0", "@niscorp/strata": "0.2.0", "@niscorp/tide": "0.2.0", "@niscorp/vex": "0.5.0" };
7
7
  var isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
8
8
  var json = (path) => {
9
9
  try {
@@ -13,87 +13,131 @@ var json = (path) => {
13
13
  }
14
14
  };
15
15
  var isChoice = (spec) => "choose" in spec;
16
+ var inside = (at, key) => ({
17
+ file: at.file,
18
+ field: typeof key === "number" ? `${at.field}[${key}]` : at.field === "" ? key : `${at.field}.${key}`
19
+ });
20
+ var wrongShape = (at, what) => {
21
+ throw new Error(`create-nisc: in ${at.file}, ${at.field === "" ? "the whole file" : at.field} ${what}`);
22
+ };
23
+ var text = (value, at) => typeof value === "string" ? value : wrongShape(at, "is not a string");
24
+ var flag = (value, at) => typeof value === "boolean" ? value : wrongShape(at, "is not true or false");
25
+ var object = (value, at) => isRecord(value) ? value : wrongShape(at, "is not an object");
26
+ var optional = (parse) => (value, at) => value === void 0 ? void 0 : parse(value, at);
27
+ var listOf = (each) => (value, at) => Array.isArray(value) ? value.map((entry, index) => each(entry, inside(at, index))) : wrongShape(at, "is not a list");
28
+ var recordOf = (each) => (value, at) => Object.fromEntries(Object.entries(object(value, at)).map(([key, entry]) => [key, each(entry, inside(at, key))]));
29
+ var fieldsOf = (value, at, read) => {
30
+ const record = object(value, at);
31
+ return read((key, parse) => parse(record[key], inside(at, key)));
32
+ };
33
+ var envKey = (value, at) => fieldsOf(value, at, (field) => ({ name: field("name", text), message: field("message", text), required: field("required", optional(flag)) }));
34
+ var envOption = (value, at) => fieldsOf(value, at, (field) => ({ value: field("value", text), label: field("label", text), hint: field("hint", optional(text)), keys: field("keys", optional(listOf(envKey))) }));
35
+ var envSpec = (value, at) => isRecord(value) && value["choose"] !== void 0 ? fieldsOf(value, at, (field) => ({ choose: field("choose", text), message: field("message", text), options: field("options", listOf(envOption)) })) : envKey(value, at);
36
+ var lines = optional(listOf(text));
37
+ var docs = (value, at) => fieldsOf(value, at, (field) => ({
38
+ is: field("is", optional(text)),
39
+ where: field("where", lines),
40
+ runs: field("runs", lines),
41
+ decisions: field("decisions", lines),
42
+ answered: field("answered", lines),
43
+ open: field("open", lines),
44
+ order: field("order", lines)
45
+ }));
46
+ var part = (value, at) => fieldsOf(value, at, (field) => ({ package: field("package", optional(object)), env: field("env", optional(listOf(envSpec))), docs: field("docs", optional(docs)) }));
47
+ var item = (value, at) => ({
48
+ ...part(value, at),
49
+ ...fieldsOf(value, at, (field) => ({
50
+ id: field("id", text),
51
+ answers: field("answers", optional(text)),
52
+ label: field("label", optional(text)),
53
+ hint: field("hint", optional(text)),
54
+ usage: field("usage", optional(text)),
55
+ summary: field("summary", optional(text)),
56
+ default: field("default", optional(flag)),
57
+ requires: field("requires", optional(recordOf(text))),
58
+ with: field("with", optional(recordOf(part)))
59
+ }))
60
+ });
61
+ var question = (value, at) => fieldsOf(value, at, (field) => ({ id: field("id", text), message: field("message", text) }));
16
62
  var readCatalog = (root) => {
17
- const questions = json(join(root, "questions.json"));
18
- if (!Array.isArray(questions) || !questions.every((q) => isRecord(q) && typeof q["id"] === "string" && typeof q["message"] === "string")) {
19
- throw new Error(`create-nisc: ${root}/questions.json is not a list of { id, message }`);
20
- }
63
+ const questions = listOf(question)(json(join(root, "questions.json")), { file: "questions.json", field: "" });
21
64
  const items = readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && existsSync(join(root, entry.name, "item.json"))).map((entry) => {
22
- const item = json(join(root, entry.name, "item.json"));
23
- if (!isRecord(item) || item["id"] !== entry.name) throw new Error(`create-nisc: ${entry.name}/item.json must say "id": "${entry.name}"`);
24
- return item;
65
+ const file = `${entry.name}/item.json`;
66
+ const value = json(join(root, file));
67
+ if (!isRecord(value) || value["id"] !== entry.name) throw new Error(`create-nisc: ${file} must say "id": "${entry.name}"`);
68
+ return item(value, { file, field: "" });
25
69
  });
26
70
  const asked = new Set(questions.map((q) => q.id));
27
- const known = new Set(items.map((item) => item.id));
28
- const answering = (question) => items.filter((item) => item.answers === question);
29
- for (const item of items) {
30
- if (item.answers !== void 0 && !asked.has(item.answers)) throw new Error(`create-nisc: item "${item.id}" answers "${item.answers}", which questions.json does not ask`);
31
- if (item.answers !== void 0 && item.label === void 0) throw new Error(`create-nisc: item "${item.id}" answers a question but has no label to offer`);
32
- for (const [question, wanted] of Object.entries(item.requires ?? {})) {
33
- if (!answering(question).some((other) => other.id === wanted)) throw new Error(`create-nisc: item "${item.id}" requires "${wanted}" for "${question}", which no item answering it is`);
71
+ const known = new Set(items.map((item2) => item2.id));
72
+ const answering = (question2) => items.filter((item2) => item2.answers === question2);
73
+ for (const item2 of items) {
74
+ if (item2.answers !== void 0 && !asked.has(item2.answers)) throw new Error(`create-nisc: item "${item2.id}" answers "${item2.answers}", which questions.json does not ask`);
75
+ if (item2.answers !== void 0 && item2.label === void 0) throw new Error(`create-nisc: item "${item2.id}" answers a question but has no label to offer`);
76
+ for (const [question2, wanted] of Object.entries(item2.requires ?? {})) {
77
+ if (!answering(question2).some((other) => other.id === wanted)) throw new Error(`create-nisc: item "${item2.id}" requires "${wanted}" for "${question2}", which no item answering it is`);
34
78
  }
35
- for (const other of Object.keys(item.with ?? {})) if (!known.has(other)) throw new Error(`create-nisc: item "${item.id}" has a part for "${other}", which is no item`);
79
+ for (const other of Object.keys(item2.with ?? {})) if (!known.has(other)) throw new Error(`create-nisc: item "${item2.id}" has a part for "${other}", which is no item`);
36
80
  }
37
- for (const question of questions) {
38
- const offered2 = answering(question.id);
39
- if (offered2.length === 0) throw new Error(`create-nisc: nothing answers "${question.id}"`);
40
- if (offered2.filter((item) => item.default === true).length !== 1) throw new Error(`create-nisc: exactly one item answering "${question.id}" is its default`);
81
+ for (const question2 of questions) {
82
+ const offered2 = answering(question2.id);
83
+ if (offered2.length === 0) throw new Error(`create-nisc: nothing answers "${question2.id}"`);
84
+ if (offered2.filter((item2) => item2.default === true).length !== 1) throw new Error(`create-nisc: exactly one item answering "${question2.id}" is its default`);
41
85
  }
42
86
  return { root, questions, items };
43
87
  };
44
88
 
45
89
  // src/catalog/choose.ts
46
- var itemNamed = (catalog, id) => catalog.items.find((item) => item.id === id);
90
+ var itemNamed = (catalog, id) => catalog.items.find((item2) => item2.id === id);
47
91
  var impliedBy = (catalog, picks) => {
48
92
  const implied = {};
49
93
  for (const id of Object.values(picks)) Object.assign(implied, itemNamed(catalog, id)?.requires ?? {});
50
94
  return implied;
51
95
  };
52
- var offered = (catalog, question, picks) => {
53
- const implied = impliedBy(catalog, picks)[question];
96
+ var offered = (catalog, question2, picks) => {
97
+ const implied = impliedBy(catalog, picks)[question2];
54
98
  return catalog.items.filter(
55
- (item) => item.answers === question && (implied === void 0 || implied === item.id) && Object.entries(item.requires ?? {}).every(([other, wanted]) => picks[other] === void 0 || picks[other] === wanted)
99
+ (item2) => item2.answers === question2 && (implied === void 0 || implied === item2.id) && Object.entries(item2.requires ?? {}).every(([other, wanted]) => picks[other] === void 0 || picks[other] === wanted)
56
100
  );
57
101
  };
58
102
  var completed = (catalog, picks) => {
59
103
  const done = { ...picks };
60
- for (const question of catalog.questions) {
61
- if (done[question.id] !== void 0) continue;
62
- const choices = offered(catalog, question.id, done);
63
- const chosen = choices.find((item) => item.default === true) ?? choices[0];
64
- if (chosen === void 0) throw new Error(`create-nisc: nothing can answer "${question.message}" beside ${Object.values(done).join(", ")}`);
65
- done[question.id] = chosen.id;
104
+ for (const question2 of catalog.questions) {
105
+ if (done[question2.id] !== void 0) continue;
106
+ const choices = offered(catalog, question2.id, done);
107
+ const chosen = choices.find((item2) => item2.default === true) ?? choices[0];
108
+ if (chosen === void 0) throw new Error(`create-nisc: nothing can answer "${question2.message}" beside ${Object.values(done).join(", ")}`);
109
+ done[question2.id] = chosen.id;
66
110
  }
67
111
  return done;
68
112
  };
69
113
  var itemsOf = (catalog, picks) => {
70
- const answering = catalog.questions.map((question) => {
71
- const id = picks[question.id];
72
- const item = id === void 0 ? void 0 : itemNamed(catalog, id);
73
- if (item === void 0 || item.answers !== question.id) throw new Error(`create-nisc: "${question.message}" has no answer${id === void 0 ? "" : ` \u2014 "${id}" does not answer it`}`);
74
- return item;
114
+ const answering = catalog.questions.map((question2) => {
115
+ const id = picks[question2.id];
116
+ const item2 = id === void 0 ? void 0 : itemNamed(catalog, id);
117
+ if (item2 === void 0 || item2.answers !== question2.id) throw new Error(`create-nisc: "${question2.message}" has no answer${id === void 0 ? "" : ` \u2014 "${id}" does not answer it`}`);
118
+ return item2;
75
119
  });
76
- for (const item of answering) {
77
- for (const [question, wanted] of Object.entries(item.requires ?? {})) {
78
- if (picks[question] !== wanted) throw new Error(`create-nisc: "${item.id}" needs "${wanted}", not "${picks[question] ?? "nothing"}"`);
120
+ for (const item2 of answering) {
121
+ for (const [question2, wanted] of Object.entries(item2.requires ?? {})) {
122
+ if (picks[question2] !== wanted) throw new Error(`create-nisc: "${item2.id}" needs "${wanted}", not "${picks[question2] ?? "nothing"}"`);
79
123
  }
80
124
  }
81
- return [...answering, ...catalog.items.filter((item) => item.answers === void 0)];
125
+ return [...answering, ...catalog.items.filter((item2) => item2.answers === void 0)];
82
126
  };
83
127
  var partsOf = (items) => {
84
- const ids = new Set(items.map((item) => item.id));
85
- return items.flatMap((item) => [item, ...Object.entries(item.with ?? {}).flatMap(([other, part]) => ids.has(other) ? [part] : [])]);
128
+ const ids = new Set(items.map((item2) => item2.id));
129
+ return items.flatMap((item2) => [item2, ...Object.entries(item2.with ?? {}).flatMap(([other, part2]) => ids.has(other) ? [part2] : [])]);
86
130
  };
87
- var envOf = (items) => partsOf(items).flatMap((part) => part.env ?? []);
131
+ var envOf = (items) => partsOf(items).flatMap((part2) => part2.env ?? []);
88
132
 
89
- // src/docs.ts
90
- var all = (parts, key) => parts.flatMap((part) => {
91
- const value = part.docs?.[key];
133
+ // src/generate/docs.ts
134
+ var all = (parts, key) => parts.flatMap((part2) => {
135
+ const value = part2.docs?.[key];
92
136
  return value === void 0 ? [] : typeof value === "string" ? [value] : [...value];
93
137
  });
94
138
  var decisionNumber = (row) => Number(/^\| D(\d+) /.exec(row)?.[1] ?? Number.POSITIVE_INFINITY);
95
- var sections = (texts) => texts.map((text) => `
96
- ${text.trim()}
139
+ var sections = (texts) => texts.map((text2) => `
140
+ ${text2.trim()}
97
141
  `).join("");
98
142
  var agentsDoc = (facts) => {
99
143
  const [first = "a nisc application", ...rest] = all(facts.parts, "is");
@@ -139,13 +183,22 @@ ${all(facts.parts, "order").map((line, at) => `${at + 1}. ${line}`).join("\n")}
139
183
  `;
140
184
  var gitignoreLines = ["node_modules/", "dist/", "out/", ".strata/", "*.tsbuildinfo", ".env", ".env.*", "!.env.example"];
141
185
 
142
- // src/generate.ts
143
- var TEMPLATES = fileURLToPath(new URL("../templates", import.meta.url));
186
+ // src/generate/generate.ts
187
+ var BUILT_TEMPLATES = fileURLToPath(new URL("../templates", import.meta.url));
188
+ var TEMPLATES = existsSync(BUILT_TEMPLATES) ? BUILT_TEMPLATES : fileURLToPath(new URL("../../templates", import.meta.url));
144
189
  var TOKEN = "nisc-template-app";
145
190
  var SKIP = /* @__PURE__ */ new Set(["node_modules", "dist", "out", ".turbo"]);
146
191
  var TEXT = /* @__PURE__ */ new Set([".ts", ".tsx", ".json", ".html", ".css", ".md"]);
147
192
  var KEEP_THEIRS = /* @__PURE__ */ new Set(["README.md"]);
148
193
  var validName = (name) => /^[a-z0-9][a-z0-9._-]*$/.test(name) && name.length <= 214;
194
+ var fileInTheWayOf = (folder) => {
195
+ if (existsSync(folder)) return statSync(folder).isDirectory() ? void 0 : folder;
196
+ return dirname(folder) === folder ? void 0 : fileInTheWayOf(dirname(folder));
197
+ };
198
+ var refuseFileInTheWay = (folder) => {
199
+ const file = fileInTheWayOf(folder);
200
+ if (file !== void 0) throw new Error(`create-nisc: ${file} is a file, and the app needs a folder there. Make it somewhere else.`);
201
+ };
149
202
  var filesIn = (dir, base = "") => existsSync(join(dir, base)) ? readdirSync(join(dir, base), { withFileTypes: true }).flatMap((entry) => {
150
203
  if (SKIP.has(entry.name)) return [];
151
204
  const rel = base === "" ? entry.name : `${base}/${entry.name}`;
@@ -153,18 +206,18 @@ var filesIn = (dir, base = "") => existsSync(join(dir, base)) ? readdirSync(join
153
206
  }) : [];
154
207
  var isRecord2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
155
208
  var sourcesOf = (root, items) => {
156
- const ids = new Set(items.map((item) => item.id));
209
+ const ids = new Set(items.map((item2) => item2.id));
157
210
  const sources = /* @__PURE__ */ new Map();
158
- for (const item of items) {
159
- const withDir = join(root, item.id, "with");
211
+ for (const item2 of items) {
212
+ const withDir = join(root, item2.id, "with");
160
213
  const others = existsSync(withDir) ? readdirSync(withDir) : [];
161
- for (const other of others) if (!existsSync(join(root, other, "item.json"))) throw new Error(`create-nisc: ${item.id}/with/${other} is for "${other}", which is no item`);
162
- const dirs = [join(root, item.id, "files"), ...others.filter((other) => ids.has(other)).map((other) => join(withDir, other))];
214
+ for (const other of others) if (!existsSync(join(root, other, "item.json"))) throw new Error(`create-nisc: ${item2.id}/with/${other} is for "${other}", which is no item`);
215
+ const dirs = [join(root, item2.id, "files"), ...others.filter((other) => ids.has(other)).map((other) => join(withDir, other))];
163
216
  for (const dir of dirs) {
164
217
  for (const rel of filesIn(dir)) {
165
218
  const there = sources.get(rel);
166
- if (there !== void 0) throw new Error(`create-nisc: ${rel} is written by both "${there.item}" and "${item.id}"`);
167
- sources.set(rel, { item: item.id, from: join(dir, rel) });
219
+ if (there !== void 0) throw new Error(`create-nisc: ${rel} is written by both "${there.item}" and "${item2.id}"`);
220
+ sources.set(rel, { item: item2.id, from: join(dir, rel) });
168
221
  }
169
222
  }
170
223
  }
@@ -183,7 +236,7 @@ var manifestOf = (parts, options) => {
183
236
  const agree = (where, key, have, value) => {
184
237
  if (have !== void 0 && JSON.stringify(have) !== JSON.stringify(value)) throw new Error(`create-nisc: two items disagree about ${where} "${key}"`);
185
238
  };
186
- for (const fragment of parts.map((part) => part.package ?? {})) {
239
+ for (const fragment of parts.map((part2) => part2.package ?? {})) {
187
240
  for (const [key, value] of Object.entries(fragment)) {
188
241
  if (key === "scripts" || key === "dependencies" || key === "devDependencies") {
189
242
  if (!isRecord2(value)) throw new Error(`create-nisc: a package fragment's ${key} is not an object`);
@@ -249,15 +302,15 @@ var generate = (options) => {
249
302
  const items = itemsOf(catalog, options.picks);
250
303
  const parts = partsOf(items);
251
304
  if (!validName(options.name)) throw new Error(`create-nisc: "${options.name}" is not a package name (lowercase letters, digits, - . _)`);
252
- if (existsSync(options.dir) && !statSync(options.dir).isDirectory()) throw new Error(`create-nisc: ${options.dir} is a file`);
305
+ refuseFileInTheWay(options.dir);
253
306
  const planned = /* @__PURE__ */ new Map();
254
307
  for (const [rel, { from }] of sourcesOf(catalog.root, items)) {
255
308
  planned.set(rel, TEXT.has(extname(rel)) ? readFileSync(from, "utf8").split(TOKEN).join(options.name) : readFileSync(from));
256
309
  }
257
310
  planned.set("package.json", `${JSON.stringify(manifestOf(parts, options), null, 2)}
258
311
  `);
259
- const sections2 = items.flatMap((item) => {
260
- const path = join(catalog.root, item.id, "agents-section.md");
312
+ const sections2 = items.flatMap((item2) => {
313
+ const path = join(catalog.root, item2.id, "agents-section.md");
261
314
  return existsSync(path) ? [readFileSync(path, "utf8").split(TOKEN).join(options.name)] : [];
262
315
  });
263
316
  const facts = { name: options.name, today: options.today, nisc: options.versions["@niscorp/nisc"] ?? "unknown", parts, agents: sections2 };
@@ -267,8 +320,15 @@ var generate = (options) => {
267
320
  const envs = specs.length > 0 ? envFiles(specs, options) : void 0;
268
321
  if (envs !== void 0) planned.set(".env.example", envs.example);
269
322
  const there = (rel) => existsSync(join(options.dir, rel));
323
+ const inTheWay = (rel) => {
324
+ const file = fileInTheWayOf(dirname(join(options.dir, rel)));
325
+ if (file !== void 0) return [`${relative(options.dir, file).split(sep).join("/")} (a file, where the app needs a folder)`];
326
+ return !KEEP_THEIRS.has(rel) && there(rel) ? [rel] : [];
327
+ };
328
+ const folderInTheWay = (rel) => there(rel) && statSync(join(options.dir, rel)).isDirectory() ? [`${rel} (a folder, where the app needs a file)`] : [];
329
+ const addedTo = [".gitignore", ...envs !== void 0 ? [".env"] : []];
270
330
  const kept = [...planned.keys()].filter((rel) => KEEP_THEIRS.has(rel) && there(rel));
271
- const collisions = [...planned.keys()].filter((rel) => !KEEP_THEIRS.has(rel) && there(rel)).sort();
331
+ const collisions = [.../* @__PURE__ */ new Set([...[...planned.keys()].flatMap(inTheWay), ...addedTo.flatMap(folderInTheWay)])].sort();
272
332
  if (collisions.length > 0) {
273
333
  throw new Error(
274
334
  `create-nisc: ${options.dir} already has ${collisions.length === 1 ? "a file" : "files"} a new app would write \u2014 nothing was written:
@@ -278,7 +338,7 @@ Make the app in an empty folder, or in a subfolder of this one.`
278
338
  }
279
339
  for (const rel of kept) planned.delete(rel);
280
340
  const extended = [];
281
- const addTo = (rel, fresh, lines, has) => {
341
+ const addTo = (rel, fresh, lines2, has) => {
282
342
  const path = join(options.dir, rel);
283
343
  if (!existsSync(path)) {
284
344
  planned.set(rel, fresh);
@@ -286,7 +346,7 @@ Make the app in an empty folder, or in a subfolder of this one.`
286
346
  }
287
347
  const theirs = readFileSync(path, "utf8");
288
348
  const have = new Set(theirs.split("\n").map((line) => line.trim()));
289
- const missing = lines.filter((line) => !has(line, have));
349
+ const missing = lines2.filter((line) => !has(line, have));
290
350
  if (missing.length === 0) return;
291
351
  planned.set(rel, `${theirs.replace(/\n*$/, "\n")}${missing.join("\n")}
292
352
  `);
@@ -296,7 +356,13 @@ Make the app in an empty folder, or in a subfolder of this one.`
296
356
  `, gitignoreLines, (line, have) => have.has(line));
297
357
  if (envs !== void 0) {
298
358
  const named = (line) => line.slice(0, line.indexOf("=") + 1);
299
- addTo(".env", envs.env, envs.assigned, (line, have) => [...have].some((theirs) => theirs.startsWith(named(line))));
359
+ const sets = (name, theirs) => new RegExp(`^(export\\s+)?${name}\\s*=`).test(theirs);
360
+ addTo(
361
+ ".env",
362
+ envs.env,
363
+ envs.assigned,
364
+ (line, have) => [...have].some((theirs) => theirs.startsWith(named(line)) || line === named(line) && sets(line.slice(0, -1), theirs))
365
+ );
300
366
  }
301
367
  for (const [rel, content] of planned) {
302
368
  const to = join(options.dir, rel);
@@ -306,12 +372,12 @@ Make the app in an empty folder, or in a subfolder of this one.`
306
372
  return { files: [...planned.keys()].filter((rel) => !extended.includes(rel)).sort(), kept, extended };
307
373
  };
308
374
 
309
- // src/set.ts
375
+ // src/command/set.ts
310
376
  var testedSet = () => {
311
377
  if (typeof define_NISC_SET_default === "undefined") throw new Error("create-nisc: this copy was not built \u2014 it carries no nisc release to pin a new app to");
312
378
  return define_NISC_SET_default;
313
379
  };
314
380
 
315
- export { TEMPLATES, completed, envOf, generate, isChoice, itemsOf, offered, readCatalog, testedSet, validName };
316
- //# sourceMappingURL=chunk-2W7KLXCO.js.map
317
- //# sourceMappingURL=chunk-2W7KLXCO.js.map
381
+ export { TEMPLATES, completed, envOf, generate, isChoice, itemsOf, offered, readCatalog, refuseFileInTheWay, testedSet, validName };
382
+ //# sourceMappingURL=chunk-TLJ3YNUU.js.map
383
+ //# sourceMappingURL=chunk-TLJ3YNUU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["%3Cdefine:__NISC_SET__%3E","../src/catalog/items.ts","../src/catalog/choose.ts","../src/generate/docs.ts","../src/generate/generate.ts","../src/command/set.ts"],"names":["item","question","offered","part","text","existsSync","join","readdirSync","isRecord","readFileSync","sections","lines"],"mappings":";;;;;AAAA,IAAA,uBAAA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chunk-TLJ3YNUU.js","sourcesContent":["{\"@niscorp/charter\":\"0.2.0\",\"@niscorp/cli\":\"0.10.0\",\"@niscorp/cortex\":\"0.2.0\",\"@niscorp/haptic\":\"0.3.0\",\"@niscorp/loom\":\"0.6.0\",\"@niscorp/moss\":\"0.10.0\",\"@niscorp/nisc\":\"0.11.0\",\"@niscorp/nova\":\"0.6.0\",\"@niscorp/prism\":\"0.4.0\",\"@niscorp/signal\":\"0.2.0\",\"@niscorp/solid\":\"0.2.0\",\"@niscorp/strata\":\"0.2.0\",\"@niscorp/tide\":\"0.2.0\",\"@niscorp/vex\":\"0.5.0\"}","import { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\nexport type EnvKey = { name: string; message: string; required?: boolean };\nexport type EnvOption = { value: string; label: string; hint?: string; keys?: readonly EnvKey[] };\nexport type EnvChoice = { choose: string; message: string; options: readonly EnvOption[] };\nexport type EnvSpec = EnvKey | EnvChoice;\n\nexport type Docs = {\n is?: string;\n where?: readonly string[];\n runs?: readonly string[];\n decisions?: readonly string[];\n answered?: readonly string[];\n open?: readonly string[];\n order?: readonly string[];\n};\n\nexport type Part = {\n package?: Readonly<Record<string, unknown>>;\n env?: readonly EnvSpec[];\n docs?: Docs;\n};\n\nexport type Item = Part & {\n id: string;\n answers?: string;\n label?: string;\n hint?: string;\n usage?: string;\n summary?: string;\n default?: boolean;\n requires?: Readonly<Record<string, string>>;\n with?: Readonly<Record<string, Part>>;\n};\n\nexport type Question = { id: string; message: string };\n\nexport type Catalog = { root: string; questions: readonly Question[]; items: readonly Item[] };\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === 'object' && !Array.isArray(value);\n\nconst json = (path: string): unknown => {\n try {\n return JSON.parse(readFileSync(path, 'utf8'));\n } catch (error) {\n throw new Error(`create-nisc: ${path} is not JSON — ${error instanceof Error ? error.message : String(error)}`);\n }\n};\n\nexport const isChoice = (spec: EnvSpec): spec is EnvChoice => 'choose' in spec;\n\ntype At = { file: string; field: string };\ntype Parse<T> = (value: unknown, at: At) => T;\n\nconst inside = (at: At, key: string | number): At => ({\n file: at.file,\n field: typeof key === 'number' ? `${at.field}[${key}]` : at.field === '' ? key : `${at.field}.${key}`,\n});\n\nconst wrongShape = (at: At, what: string): never => {\n throw new Error(`create-nisc: in ${at.file}, ${at.field === '' ? 'the whole file' : at.field} ${what}`);\n};\n\nconst text: Parse<string> = (value, at) => (typeof value === 'string' ? value : wrongShape(at, 'is not a string'));\nconst flag: Parse<boolean> = (value, at) => (typeof value === 'boolean' ? value : wrongShape(at, 'is not true or false'));\nconst object: Parse<Record<string, unknown>> = (value, at) => (isRecord(value) ? value : wrongShape(at, 'is not an object'));\nconst optional =\n <T>(parse: Parse<T>): Parse<T | undefined> =>\n (value, at) =>\n value === undefined ? undefined : parse(value, at);\nconst listOf =\n <T>(each: Parse<T>): Parse<T[]> =>\n (value, at) =>\n Array.isArray(value) ? value.map((entry, index) => each(entry, inside(at, index))) : wrongShape(at, 'is not a list');\nconst recordOf =\n <T>(each: Parse<T>): Parse<Record<string, T>> =>\n (value, at) =>\n Object.fromEntries(Object.entries(object(value, at)).map(([key, entry]) => [key, each(entry, inside(at, key))]));\nconst fieldsOf = <T>(value: unknown, at: At, read: (field: <F>(key: string, parse: Parse<F>) => F) => T): T => {\n const record = object(value, at);\n return read((key, parse) => parse(record[key], inside(at, key)));\n};\n\nconst envKey: Parse<EnvKey> = (value, at) =>\n fieldsOf(value, at, (field) => ({ name: field('name', text), message: field('message', text), required: field('required', optional(flag)) }));\nconst envOption: Parse<EnvOption> = (value, at) =>\n fieldsOf(value, at, (field) => ({ value: field('value', text), label: field('label', text), hint: field('hint', optional(text)), keys: field('keys', optional(listOf(envKey))) }));\nconst envSpec: Parse<EnvSpec> = (value, at) =>\n isRecord(value) && value['choose'] !== undefined\n ? fieldsOf(value, at, (field) => ({ choose: field('choose', text), message: field('message', text), options: field('options', listOf(envOption)) }))\n : envKey(value, at);\nconst lines = optional(listOf(text));\nconst docs: Parse<Docs> = (value, at) =>\n fieldsOf(value, at, (field) => ({\n is: field('is', optional(text)),\n where: field('where', lines),\n runs: field('runs', lines),\n decisions: field('decisions', lines),\n answered: field('answered', lines),\n open: field('open', lines),\n order: field('order', lines),\n }));\nconst part: Parse<Part> = (value, at) =>\n fieldsOf(value, at, (field) => ({ package: field('package', optional(object)), env: field('env', optional(listOf(envSpec))), docs: field('docs', optional(docs)) }));\nconst item: Parse<Item> = (value, at) => ({\n ...part(value, at),\n ...fieldsOf(value, at, (field) => ({\n id: field('id', text),\n answers: field('answers', optional(text)),\n label: field('label', optional(text)),\n hint: field('hint', optional(text)),\n usage: field('usage', optional(text)),\n summary: field('summary', optional(text)),\n default: field('default', optional(flag)),\n requires: field('requires', optional(recordOf(text))),\n with: field('with', optional(recordOf(part))),\n })),\n});\nconst question: Parse<Question> = (value, at) => fieldsOf(value, at, (field) => ({ id: field('id', text), message: field('message', text) }));\n\n// The templates are ours, so a mistake in them is a bug: it is refused here with a sentence, before anything is written.\nexport const readCatalog = (root: string): Catalog => {\n const questions = listOf(question)(json(join(root, 'questions.json')), { file: 'questions.json', field: '' });\n const items: Item[] = readdirSync(root, { withFileTypes: true })\n .filter((entry) => entry.isDirectory() && existsSync(join(root, entry.name, 'item.json')))\n .map((entry) => {\n const file = `${entry.name}/item.json`;\n const value = json(join(root, file));\n if (!isRecord(value) || value['id'] !== entry.name) throw new Error(`create-nisc: ${file} must say \"id\": \"${entry.name}\"`);\n return item(value, { file, field: '' });\n });\n\n const asked = new Set(questions.map((q) => q.id));\n const known = new Set(items.map((item) => item.id));\n const answering = (question: string): Item[] => items.filter((item) => item.answers === question);\n for (const item of items) {\n if (item.answers !== undefined && !asked.has(item.answers)) throw new Error(`create-nisc: item \"${item.id}\" answers \"${item.answers}\", which questions.json does not ask`);\n if (item.answers !== undefined && item.label === undefined) throw new Error(`create-nisc: item \"${item.id}\" answers a question but has no label to offer`);\n for (const [question, wanted] of Object.entries(item.requires ?? {})) {\n if (!answering(question).some((other) => other.id === wanted)) throw new Error(`create-nisc: item \"${item.id}\" requires \"${wanted}\" for \"${question}\", which no item answering it is`);\n }\n for (const other of Object.keys(item.with ?? {})) if (!known.has(other)) throw new Error(`create-nisc: item \"${item.id}\" has a part for \"${other}\", which is no item`);\n }\n for (const question of questions) {\n const offered = answering(question.id);\n if (offered.length === 0) throw new Error(`create-nisc: nothing answers \"${question.id}\"`);\n if (offered.filter((item) => item.default === true).length !== 1) throw new Error(`create-nisc: exactly one item answering \"${question.id}\" is its default`);\n }\n return { root, questions, items };\n};\n","import type { Catalog, EnvSpec, Item, Part } from './items';\n\n// Question id → the id of the item that answers it.\nexport type Picks = Readonly<Record<string, string>>;\n\nconst itemNamed = (catalog: Catalog, id: string): Item | undefined => catalog.items.find((item) => item.id === id);\n\n// What the items picked so far say other questions must be answered with.\nexport const impliedBy = (catalog: Catalog, picks: Picks): Record<string, string> => {\n const implied: Record<string, string> = {};\n for (const id of Object.values(picks)) Object.assign(implied, itemNamed(catalog, id)?.requires ?? {});\n return implied;\n};\n\n// The items that can still answer a question, beside what is picked.\nexport const offered = (catalog: Catalog, question: string, picks: Picks): Item[] => {\n const implied = impliedBy(catalog, picks)[question];\n return catalog.items.filter(\n (item) =>\n item.answers === question &&\n (implied === undefined || implied === item.id) &&\n Object.entries(item.requires ?? {}).every(([other, wanted]) => picks[other] === undefined || picks[other] === wanted),\n );\n};\n\n// Answers every question the picks leave open the way a person who takes the defaults would.\nexport const completed = (catalog: Catalog, picks: Picks): Record<string, string> => {\n const done: Record<string, string> = { ...picks };\n for (const question of catalog.questions) {\n if (done[question.id] !== undefined) continue;\n const choices = offered(catalog, question.id, done);\n const chosen = choices.find((item) => item.default === true) ?? choices[0];\n if (chosen === undefined) throw new Error(`create-nisc: nothing can answer \"${question.message}\" beside ${Object.values(done).join(', ')}`);\n done[question.id] = chosen.id;\n }\n return done;\n};\n\n// The items an app is made of: the one answering each question, in the order they are asked, then the ones every\n// app has. Refused when a question is unanswered or an item's requirement is not met.\nexport const itemsOf = (catalog: Catalog, picks: Picks): Item[] => {\n const answering = catalog.questions.map((question) => {\n const id = picks[question.id];\n const item = id === undefined ? undefined : itemNamed(catalog, id);\n if (item === undefined || item.answers !== question.id) throw new Error(`create-nisc: \"${question.message}\" has no answer${id === undefined ? '' : ` — \"${id}\" does not answer it`}`);\n return item;\n });\n for (const item of answering) {\n for (const [question, wanted] of Object.entries(item.requires ?? {})) {\n if (picks[question] !== wanted) throw new Error(`create-nisc: \"${item.id}\" needs \"${wanted}\", not \"${picks[question] ?? 'nothing'}\"`);\n }\n }\n return [...answering, ...catalog.items.filter((item) => item.answers === undefined)];\n};\n\n// Each item's own part, followed by its part for every other item the app is made of.\nexport const partsOf = (items: readonly Item[]): Part[] => {\n const ids = new Set(items.map((item) => item.id));\n return items.flatMap((item) => [item, ...Object.entries(item.with ?? {}).flatMap(([other, part]) => (ids.has(other) ? [part] : []))]);\n};\n\nexport const envOf = (items: readonly Item[]): EnvSpec[] => partsOf(items).flatMap((part) => part.env ?? []);\n","import type { Part } from '../catalog';\n\nexport type DocFacts = {\n name: string;\n today: string;\n nisc: string;\n parts: readonly Part[];\n // The sections items add to AGENTS.md, each from its own agents-section.md.\n agents: readonly string[];\n};\n\nconst all = <K extends 'is' | 'where' | 'runs' | 'decisions' | 'answered' | 'open' | 'order'>(parts: readonly Part[], key: K): string[] =>\n parts.flatMap((part) => {\n const value = part.docs?.[key];\n return value === undefined ? [] : typeof value === 'string' ? [value] : [...value];\n });\n\nconst decisionNumber = (row: string): number => Number(/^\\| D(\\d+) /.exec(row)?.[1] ?? Number.POSITIVE_INFINITY);\n\nconst sections = (texts: readonly string[]): string => texts.map((text) => `\\n${text.trim()}\\n`).join('');\n\nexport const agentsDoc = (facts: DocFacts): string => {\n const [first = 'a nisc application', ...rest] = all(facts.parts, 'is');\n return `# ${facts.name}\n\nA nisc application. **The rules it is built by are \\`node_modules/@niscorp/nisc/AGENTS.md\\`** — read all of it before changing anything here (it is there once the app's dependencies are installed). It is the rulebook for the nisc version this app has installed, and \\`STYLE_GUIDE.md\\` sits beside it. The grammars it names — a layout node, an \\`ActionDefinition\\`, a Prism config, a charter, a Vex DSL — are in each package's own \\`README.md\\` and \\`DESIGN.md\\`, under \\`node_modules/@niscorp/<name>/\\`.\n\nWhat is particular to this app:\n\n- **Its decisions are in PLAN.md.** What was answered when it was made, what was derived, and what is still open. An open decision point is asked before anything is built on it, never resolved silently.\n- **It is ${first}**${rest.map((clause) => `, ${clause}`).join('')}.\n- **Where things go:**\n\n\\`\\`\\`\n${all(facts.parts, 'where').join('\\n')}\n\\`\\`\\`\n\n- **How it runs:** ${all(facts.parts, 'runs').join(', ')} — all of them the \\`nisc\\` command — and \\`npm run strata status\\` for the grammars.\n- **How it is reviewed:** by the \\`nisc-reviewer\\` agent (\\`.claude/agents/nisc-reviewer.md\\`), which follows \\`node_modules/@niscorp/nisc/REVIEW.md\\` — after each step of PLAN.md's order of work, not only at the end. \\`npm run check\\` passing says the app does what it should; a review says it is still built the nisc way.\n${sections(facts.agents)}`;\n};\n\nexport const planDoc = (facts: DocFacts): string => `# PLAN — ${facts.name}\n\nMade ${facts.today} by \\`npm create nisc\\`, on nisc ${facts.nisc}. This is the record AGENTS.md's interview asks for (\"Before any code\"). The walkthrough asked what shapes the files; everything else is **open**, and an open decision blocks the build that depends on it until it is answered by the user or delegated by name. A blanket \"go\" delegates nothing.\n\n## Decision points\n\n| | Tier | |\n|---|---|---|\n${all(facts.parts, 'decisions')\n .sort((a, b) => decisionNumber(a) - decisionNumber(b))\n .join('\\n')}\n\n## Answered when it was made\n\n${all(facts.parts, 'answered')\n .map((line) => `- ${line}`)\n .join('\\n')}\n\n## The dial-in — open\n\n${all(facts.parts, 'open')\n .map((line) => `- ${line}`)\n .join('\\n')}\n\n## Order of work\n\n${all(facts.parts, 'order')\n .map((line, at) => `${at + 1}. ${line}`)\n .join('\\n')}\n`;\n\nexport const gitignoreLines = ['node_modules/', 'dist/', 'out/', '.strata/', '*.tsbuildinfo', '.env', '.env.*', '!.env.example'];\n","import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';\nimport { dirname, extname, join, relative, sep } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { envOf, isChoice, itemsOf, partsOf, readCatalog } from '../catalog';\nimport type { EnvKey, EnvSpec, Item, Part, Picks } from '../catalog';\nimport { agentsDoc, gitignoreLines, planDoc } from './docs';\n\nexport type CreateOptions = {\n dir: string;\n name: string;\n picks: Picks;\n // The values given for the keys the items ask for, by variable name. A key left out is written empty.\n env?: Readonly<Record<string, string>>;\n versions: Readonly<Record<string, string>>;\n // Depend on the nisc packages of the workspace the app is made in, for an app inside the nisc repository.\n workspace?: boolean;\n // YYYY-MM-DD\n today: string;\n templates?: string;\n};\n\nexport type Created = {\n files: string[];\n kept: string[];\n extended: string[];\n};\n\nconst BUILT_TEMPLATES = fileURLToPath(new URL('../templates', import.meta.url));\n// From source (the package's own tests) this file sits a folder deeper than in dist/.\nexport const TEMPLATES = existsSync(BUILT_TEMPLATES) ? BUILT_TEMPLATES : fileURLToPath(new URL('../../templates', import.meta.url));\n\nconst TOKEN = 'nisc-template-app';\nconst SKIP = new Set(['node_modules', 'dist', 'out', '.turbo']);\nconst TEXT = new Set(['.ts', '.tsx', '.json', '.html', '.css', '.md']);\nconst KEEP_THEIRS = new Set(['README.md']);\nconst DEPENDENCIES = ['dependencies', 'devDependencies'] as const;\n\n// npm's rule for a package name.\nexport const validName = (name: string): boolean => /^[a-z0-9][a-z0-9._-]*$/.test(name) && name.length <= 214;\n\nconst fileInTheWayOf = (folder: string): string | undefined => {\n if (existsSync(folder)) return statSync(folder).isDirectory() ? undefined : folder;\n return dirname(folder) === folder ? undefined : fileInTheWayOf(dirname(folder));\n};\n\nexport const refuseFileInTheWay = (folder: string): void => {\n const file = fileInTheWayOf(folder);\n if (file !== undefined) throw new Error(`create-nisc: ${file} is a file, and the app needs a folder there. Make it somewhere else.`);\n};\n\nconst filesIn = (dir: string, base = ''): string[] =>\n existsSync(join(dir, base))\n ? readdirSync(join(dir, base), { withFileTypes: true }).flatMap((entry) => {\n if (SKIP.has(entry.name)) return [];\n const rel = base === '' ? entry.name : `${base}/${entry.name}`;\n return entry.isDirectory() ? filesIn(dir, rel) : [rel];\n })\n : [];\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === 'object' && !Array.isArray(value);\n\n// An item's files, then its files for each other item the app is made of (`with/<other>/`).\nconst sourcesOf = (root: string, items: readonly Item[]): Map<string, { item: string; from: string }> => {\n const ids = new Set(items.map((item) => item.id));\n const sources = new Map<string, { item: string; from: string }>();\n for (const item of items) {\n const withDir = join(root, item.id, 'with');\n const others = existsSync(withDir) ? readdirSync(withDir) : [];\n for (const other of others) if (!existsSync(join(root, other, 'item.json'))) throw new Error(`create-nisc: ${item.id}/with/${other} is for \"${other}\", which is no item`);\n const dirs = [join(root, item.id, 'files'), ...others.filter((other) => ids.has(other)).map((other) => join(withDir, other))];\n for (const dir of dirs) {\n for (const rel of filesIn(dir)) {\n const there = sources.get(rel);\n if (there !== undefined) throw new Error(`create-nisc: ${rel} is written by both \"${there.item}\" and \"${item.id}\"`);\n sources.set(rel, { item: item.id, from: join(dir, rel) });\n }\n }\n }\n return sources;\n};\n\nconst pin = (name: string, spec: string, options: CreateOptions): string => {\n if (!spec.startsWith('workspace:') || options.workspace === true) return spec;\n const version = options.versions[name];\n if (version === undefined) throw new Error(`create-nisc: the nisc release has no ${name} — the set it was given is incomplete`);\n return `^${version}`;\n};\n\n// The parts' package fragments as one manifest: fields in the order they come, then the scripts, then the\n// dependencies sorted. Two parts that disagree about one field, script or dependency is a mistake in the templates.\nconst manifestOf = (parts: readonly Part[], options: CreateOptions): Record<string, unknown> => {\n const fields: Record<string, unknown> = {};\n const scripts: Record<string, string> = {};\n const deps: Record<(typeof DEPENDENCIES)[number], Record<string, string>> = { dependencies: {}, devDependencies: {} };\n const agree = (where: string, key: string, have: unknown, value: unknown): void => {\n if (have !== undefined && JSON.stringify(have) !== JSON.stringify(value)) throw new Error(`create-nisc: two items disagree about ${where} \"${key}\"`);\n };\n for (const fragment of parts.map((part) => part.package ?? {})) {\n for (const [key, value] of Object.entries(fragment)) {\n if (key === 'scripts' || key === 'dependencies' || key === 'devDependencies') {\n if (!isRecord(value)) throw new Error(`create-nisc: a package fragment's ${key} is not an object`);\n const into = key === 'scripts' ? scripts : deps[key];\n for (const [name, spec] of Object.entries(value)) {\n if (typeof spec !== 'string') throw new Error(`create-nisc: ${name} in ${key} is not a string`);\n agree(key, name, into[name], spec);\n into[name] = spec;\n }\n } else {\n agree('the package field', key, fields[key], value);\n fields[key] = value;\n }\n }\n }\n const sorted = (from: Record<string, string>): Record<string, string> =>\n Object.fromEntries(\n Object.keys(from)\n .sort()\n .map((name) => [name, pin(name, from[name] ?? '', options)]),\n );\n return {\n name: options.name,\n ...fields,\n ...(Object.keys(scripts).length > 0 ? { scripts } : {}),\n dependencies: sorted(deps.dependencies),\n devDependencies: sorted(deps.devDependencies),\n };\n};\n\nconst envValue = (name: string, options: CreateOptions): string => {\n const value = (options.env?.[name] ?? '').trim();\n if (/\\s/.test(value)) throw new Error(`create-nisc: the value given for ${name} has a space or a line break in it`);\n return value;\n};\n\n// `.env` with the values given, `.env.example` with the names alone. A choice keeps its value in both: it is not a\n// secret, and it says which keys follow.\nconst envFiles = (specs: readonly EnvSpec[], options: CreateOptions): { env: string; example: string; assigned: string[] } => {\n const env: string[] = [];\n const example: string[] = [];\n const assigned: string[] = [];\n const key = (spec: EnvKey): void => {\n const comment = `# ${spec.message}${spec.required === true ? ' (required)' : ''}`;\n const line = `${spec.name}=${envValue(spec.name, options)}`;\n env.push(comment, line);\n example.push(comment, `${spec.name}=`);\n assigned.push(line);\n };\n for (const spec of specs) {\n if (!isChoice(spec)) {\n key(spec);\n continue;\n }\n const value = envValue(spec.choose, options) || (spec.options[0]?.value ?? '');\n const option = spec.options.find((candidate) => candidate.value === value);\n if (option === undefined) throw new Error(`create-nisc: ${spec.choose} is one of ${spec.options.map((candidate) => candidate.value).join(', ')} — not \"${value}\"`);\n const comment = `# ${spec.message} (${spec.options.map((candidate) => candidate.value).join(' | ')})`;\n env.push(comment, `${spec.choose}=${value}`);\n example.push(comment, `${spec.choose}=${value}`);\n assigned.push(`${spec.choose}=${value}`);\n for (const inner of option.keys ?? []) key(inner);\n }\n return { env: `${env.join('\\n')}\\n`, example: `${example.join('\\n')}\\n`, assigned };\n};\n\nexport const generate = (options: CreateOptions): Created => {\n const catalog = readCatalog(options.templates ?? TEMPLATES);\n const items = itemsOf(catalog, options.picks);\n const parts = partsOf(items);\n if (!validName(options.name)) throw new Error(`create-nisc: \"${options.name}\" is not a package name (lowercase letters, digits, - . _)`);\n refuseFileInTheWay(options.dir);\n\n const planned = new Map<string, string | Buffer>();\n for (const [rel, { from }] of sourcesOf(catalog.root, items)) {\n planned.set(rel, TEXT.has(extname(rel)) ? readFileSync(from, 'utf8').split(TOKEN).join(options.name) : readFileSync(from));\n }\n planned.set('package.json', `${JSON.stringify(manifestOf(parts, options), null, 2)}\\n`);\n\n const sections = items.flatMap((item) => {\n const path = join(catalog.root, item.id, 'agents-section.md');\n return existsSync(path) ? [readFileSync(path, 'utf8').split(TOKEN).join(options.name)] : [];\n });\n const facts = { name: options.name, today: options.today, nisc: options.versions['@niscorp/nisc'] ?? 'unknown', parts, agents: sections };\n planned.set('AGENTS.md', agentsDoc(facts));\n planned.set('PLAN.md', planDoc(facts));\n\n const specs = envOf(items);\n const envs = specs.length > 0 ? envFiles(specs, options) : undefined;\n if (envs !== undefined) planned.set('.env.example', envs.example);\n\n const there = (rel: string): boolean => existsSync(join(options.dir, rel));\n const inTheWay = (rel: string): string[] => {\n const file = fileInTheWayOf(dirname(join(options.dir, rel)));\n if (file !== undefined) return [`${relative(options.dir, file).split(sep).join('/')} (a file, where the app needs a folder)`];\n return !KEEP_THEIRS.has(rel) && there(rel) ? [rel] : [];\n };\n const folderInTheWay = (rel: string): string[] => (there(rel) && statSync(join(options.dir, rel)).isDirectory() ? [`${rel} (a folder, where the app needs a file)`] : []);\n const addedTo = ['.gitignore', ...(envs !== undefined ? ['.env'] : [])];\n const kept = [...planned.keys()].filter((rel) => KEEP_THEIRS.has(rel) && there(rel));\n const collisions = [...new Set([...[...planned.keys()].flatMap(inTheWay), ...addedTo.flatMap(folderInTheWay)])].sort();\n if (collisions.length > 0) {\n throw new Error(\n `create-nisc: ${options.dir} already has ${collisions.length === 1 ? 'a file' : 'files'} a new app would write — nothing was written:\\n ${collisions.join('\\n ')}\\nMake the app in an empty folder, or in a subfolder of this one.`,\n );\n }\n for (const rel of kept) planned.delete(rel);\n\n // A .gitignore or .env that is there is added to, never replaced: what it contains is theirs.\n const extended: string[] = [];\n const addTo = (rel: string, fresh: string, lines: readonly string[], has: (line: string, theirs: ReadonlySet<string>) => boolean): void => {\n const path = join(options.dir, rel);\n if (!existsSync(path)) {\n planned.set(rel, fresh);\n return;\n }\n const theirs = readFileSync(path, 'utf8');\n const have = new Set(theirs.split('\\n').map((line) => line.trim()));\n const missing = lines.filter((line) => !has(line, have));\n if (missing.length === 0) return;\n planned.set(rel, `${theirs.replace(/\\n*$/, '\\n')}${missing.join('\\n')}\\n`);\n extended.push(rel);\n };\n addTo('.gitignore', `${gitignoreLines.join('\\n')}\\n`, gitignoreLines, (line, have) => have.has(line));\n if (envs !== undefined) {\n const named = (line: string): string => line.slice(0, line.indexOf('=') + 1);\n // Node also reads `NAME = value` and `export NAME=value`; an empty `NAME=` after either would win and hide it.\n const sets = (name: string, theirs: string): boolean => new RegExp(`^(export\\\\s+)?${name}\\\\s*=`).test(theirs);\n addTo('.env', envs.env, envs.assigned, (line, have) =>\n [...have].some((theirs) => theirs.startsWith(named(line)) || (line === named(line) && sets(line.slice(0, -1), theirs))),\n );\n }\n\n for (const [rel, content] of planned) {\n const to = join(options.dir, rel);\n mkdirSync(dirname(to), { recursive: true });\n writeFileSync(to, content);\n }\n return { files: [...planned.keys()].filter((rel) => !extended.includes(rel)).sort(), kept, extended };\n};\n","// Written in when this package is built (tsup.config.ts), never looked up:\n// \"whatever is newest on npm\" would be a set nobody tested the templates with.\ndeclare const __NISC_SET__: Readonly<Record<string, string>> | undefined;\n\nexport const testedSet = (): Readonly<Record<string, string>> => {\n if (typeof __NISC_SET__ === 'undefined') throw new Error('create-nisc: this copy was not built — it carries no nisc release to pin a new app to');\n return __NISC_SET__;\n};\n"]}
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { readCatalog, TEMPLATES, validName, offered, itemsOf, envOf, isChoice, generate, testedSet } from './chunk-2W7KLXCO.js';
1
+ import { readCatalog, TEMPLATES, validName, refuseFileInTheWay, offered, itemsOf, envOf, isChoice, generate, testedSet } from './chunk-TLJ3YNUU.js';
2
2
  import { existsSync, readdirSync } from 'fs';
3
3
  import { basename, resolve, relative } from 'path';
4
4
  import { intro, text, confirm, cancel, select, note, outro, isCancel, password } from '@clack/prompts';
@@ -83,10 +83,11 @@ ${usage}`);
83
83
  const dir = resolve(dirInput === "" ? DEFAULT_DIR : dirInput);
84
84
  const name = basename(dir);
85
85
  if (!validName(name)) refuse(`"${name}" cannot be a package name \u2014 the folder\u2019s name becomes it: lowercase letters, digits, - . _`);
86
- const holds = existsSync(dir) ? readdirSync(dir).length : 0;
87
- if (holds > 0 && ask) {
86
+ refuseFileInTheWay(dir);
87
+ const present = existsSync(dir) ? readdirSync(dir).length : 0;
88
+ if (present > 0 && ask) {
88
89
  const proceed = answered(
89
- await confirm({ message: `${relative(process.cwd(), dir) || "."} already holds ${holds} ${holds === 1 ? "thing" : "things"}. Nothing there will be overwritten \u2014 make the app in it?`, initialValue: true })
90
+ await confirm({ message: `${relative(process.cwd(), dir) || "."} already has ${present} ${present === 1 ? "thing" : "things"} in it. Nothing there will be overwritten \u2014 make the app in it?`, initialValue: true })
90
91
  );
91
92
  if (!proceed) {
92
93
  cancel("Nothing was made.");
@@ -132,7 +133,8 @@ ${usage}`);
132
133
  const made = generate({ dir, name, picks, env, versions: testedSet(), workspace: flags.includes("--workspace"), today: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10) });
133
134
  const run = manager();
134
135
  const where = relative(process.cwd(), dir) || ".";
135
- const next = [...where === "." ? [] : [`cd ${where}`], `${run} install`, `${run} run dev`].join("\n");
136
+ const quoted = /^[\w./\\:-]+$/.test(where) ? where : `"${where}"`;
137
+ const next = [...where === "." ? [] : [`cd ${quoted}`], `${run} install`, `${run} run dev`].join("\n");
136
138
  const left = [...made.kept.map((file) => `kept your ${file}`), ...made.extended.map((file) => `added to your ${file}`)];
137
139
  const what = items.flatMap((item) => item.summary ?? []).join(", ");
138
140
  const summary = `${name} \u2014 ${what} \u2014 ${made.files.length} files${left.length > 0 ? ` (${left.join("; ")})` : ""}`;
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts"],"names":[],"mappings":";;;;;AAQA,IAAM,WAAA,GAAc,aAAA;AACpB,IAAM,SAAA,GAAY,CAAC,OAAA,EAAS,aAAA,EAAe,UAAU,IAAI,CAAA;AAGzD,IAAM,YAAA,GAAe,CAAC,KAAA,KAAmC,CAAC,GAAG,KAAK,CAAA,CAAE,KAAK,CAAC,GAAA,EAAK,UAAU,MAAA,CAAO,KAAA,CAAM,YAAY,IAAI,CAAA,GAAI,OAAO,GAAA,CAAI,OAAA,KAAY,IAAI,CAAC,CAAA;AAEtJ,IAAM,SAAA,GAAY,CAAC,OAAA,EAAkB,QAAA,KAA+B,aAAa,OAAA,CAAQ,KAAA,CAAM,MAAA,CAAO,CAAC,IAAA,KAAS,IAAA,CAAK,OAAA,KAAY,QAAA,CAAS,EAAE,CAAC,CAAA;AAG7I,IAAM,OAAA,GAAU,CAAC,OAAA,KAA6B;AAC5C,EAAA,MAAM,IAAA,GAA2B;AAAA,IAC/B,CAAC,KAAA,EAAO,CAAA,6BAAA,EAAgC,WAAW,CAAA,2BAAA,CAA6B,CAAA;AAAA,IAChF,GAAG,QAAQ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AAA,EAAM,KAAK,KAAA,CAAM,MAAM,SAAS,IAAA,CAAK,MAAA,GAAS,IAAI,CAAA,EAAA,EAAK,IAAA,CAAK,KAAK,IAAI,CAAC,MAAM,EAAE,CAAA,CAAA;AAC/G,EAAA,MAAM,IAAA,GAAO,MAAM,MAAA,GAAS,CAAA,GAAI,eAAe,KAAA,CAAM,IAAA,CAAK,IAAI,CAAC,CAAA,gBAAA,CAAA,GAAqB,EAAA;AACpF,EAAA,MAAM,KAAA,GAAQ,oFAA0E,IAAI,CAAA,CAAA;AAC5F,EAAA,IAAI,GAAA,EAAK;AACP,IAAA,IAAA,CAAK,MAAM,MAAM,CAAA;AACjB,IAAA,KAAA,CAAM,CAAA,EAAG,OAAO,CAAA,EAAA,EAAK,KAAK,CAAA,CAAE,CAAA;AAAA,EAC9B,CAAA,MAAO;AACL,IAAA,OAAA,CAAQ,GAAA,CAAI,gBAAgB,OAAO;;AAAA,EAAO,IAAI;;AAAA,EAAO,KAAK,CAAA,CAAE,CAAA;AAAA,EAC9D;AACF,CAAA;AAEA,IAAA,EAAK,CAAE,KAAA,CAAM,CAAC,KAAA,KAAmB;AAC/B,EAAA,OAAA,CAAQ,MAAM,KAAA,YAAiB,KAAA,GAAQ,MAAM,OAAA,GAAU,MAAA,CAAO,KAAK,CAAC,CAAA;AACpE,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAChB,CAAC,CAAA","file":"cli.js","sourcesContent":["import { existsSync, readdirSync } from 'node:fs';\nimport { basename, relative, resolve } from 'node:path';\nimport { cancel, confirm, intro, isCancel, note, outro, password, select, text } from '@clack/prompts';\nimport { envOf, isChoice, itemsOf, offered, readCatalog } from './catalog';\nimport type { Catalog, EnvKey, Item, Question } from './catalog';\nimport { TEMPLATES, generate, validName } from './generate';\nimport { testedSet } from './set';\n\nconst DEFAULT_DIR = 'my-nisc-app';\nconst OWN_FLAGS = ['--yes', '--workspace', '--help', '-h'];\n\n// The default first, then the rest in the order of their folders.\nconst defaultFirst = (items: readonly Item[]): Item[] => [...items].sort((one, other) => Number(other.default === true) - Number(one.default === true));\n\nconst answering = (catalog: Catalog, question: Question): Item[] => defaultFirst(catalog.items.filter((item) => item.answers === question.id));\n\n// Written from the templates, so a new kit, shell or kind of app is in it without a line here changing.\nconst usageOf = (catalog: Catalog): string => {\n const rows: [string, string][] = [\n ['dir', `where the app goes (default: ${DEFAULT_DIR}); its name is the folder's`],\n ...catalog.questions.flatMap((question) =>\n answering(catalog, question).map((item): [string, string] => {\n const needs = Object.values(item.requires ?? {}).map((id) => `--${id}`);\n return [`--${item.id}`, `${item.usage ?? item.label ?? item.id}${item.default === true ? ' — the default' : ''}${needs.length > 0 ? ` (with ${needs.join(', ')})` : ''}`];\n }),\n ),\n ['--yes', 'take the defaults for anything not given, and ask nothing'],\n ['--workspace', 'depend on the nisc packages of the workspace it is made in — for an app inside the nisc repository'],\n ];\n const width = Math.max(...rows.map(([flag]) => flag.length)) + 2;\n const choices = catalog.questions.map((question) => `[${answering(catalog, question).map((item) => `--${item.id}`).join(' | ')}]`).join(' ');\n return `npm create nisc [dir] ${choices} [--yes]\\n\\n${rows.map(([flag, what]) => ` ${flag.padEnd(width)}${what}`).join('\\n')}`;\n};\n\nconst answered = <T extends string | boolean>(value: T | symbol): T => {\n if (typeof value === 'symbol' || isCancel(value)) {\n cancel('Nothing was made.');\n process.exit(1);\n }\n return value;\n};\n\nconst manager = (): string => {\n const agent = process.env['npm_config_user_agent'] ?? '';\n return ['pnpm', 'yarn', 'bun'].find((name) => agent.startsWith(name)) ?? 'npm';\n};\n\nconst main = async (): Promise<void> => {\n const catalog = readCatalog(TEMPLATES);\n const usage = usageOf(catalog);\n const refuse = (message: string): never => {\n console.error(`create-nisc: ${message}\\n\\n${usage}`);\n process.exit(1);\n };\n\n const args = process.argv.slice(2);\n if (args.includes('--help') || args.includes('-h')) {\n console.log(usage);\n return;\n }\n const flags = args.filter((arg) => arg.startsWith('-'));\n const positional = args.filter((arg) => !arg.startsWith('-'));\n const byFlag = new Map(catalog.items.filter((item) => item.answers !== undefined).map((item) => [`--${item.id}`, item]));\n const unknown = flags.filter((flag) => !OWN_FLAGS.includes(flag) && !byFlag.has(flag));\n if (unknown.length > 0) refuse(`unknown option ${unknown.join(', ')}`);\n if (positional.length > 1) refuse(`one folder at a time — got ${positional.join(', ')}`);\n\n const picks: Record<string, string> = {};\n for (const item of flags.flatMap((flag) => byFlag.get(flag) ?? [])) {\n const question = item.answers ?? '';\n const before = picks[question];\n if (before !== undefined && before !== item.id) refuse(`--${before} and --${item.id} are two different apps; pick one`);\n picks[question] = item.id;\n }\n for (const id of Object.values(picks)) {\n for (const [question, wanted] of Object.entries(byFlag.get(`--${id}`)?.requires ?? {})) {\n const other = picks[question];\n if (other !== undefined && other !== wanted) refuse(`--${id} needs --${wanted}, not --${other}`);\n }\n }\n\n const ask = process.stdout.isTTY === true && process.stdin.isTTY === true && !flags.includes('--yes');\n if (ask) intro('a new nisc app');\n\n const given = positional[0];\n const dirInput =\n given ??\n (ask\n ? answered<string>(\n await text({\n message: 'Where should it go?',\n placeholder: DEFAULT_DIR,\n defaultValue: DEFAULT_DIR,\n validate: (value) =>\n validName(basename(resolve(value === undefined || value === '' ? DEFAULT_DIR : value))) ? undefined : 'the folder’s name becomes the package name: lowercase letters, digits, - . _',\n }),\n )\n : DEFAULT_DIR);\n const dir = resolve(dirInput === '' ? DEFAULT_DIR : dirInput);\n const name = basename(dir);\n if (!validName(name)) refuse(`\"${name}\" cannot be a package name — the folder’s name becomes it: lowercase letters, digits, - . _`);\n\n const holds = existsSync(dir) ? readdirSync(dir).length : 0;\n if (holds > 0 && ask) {\n const proceed = answered<boolean>(\n await confirm({ message: `${relative(process.cwd(), dir) || '.'} already holds ${holds} ${holds === 1 ? 'thing' : 'things'}. Nothing there will be overwritten — make the app in it?`, initialValue: true }),\n );\n if (!proceed) {\n cancel('Nothing was made.');\n process.exit(1);\n }\n }\n\n for (const question of catalog.questions) {\n if (picks[question.id] !== undefined) continue;\n const choices = defaultFirst(offered(catalog, question.id, picks));\n const preferred = choices.find((item) => item.default === true) ?? choices[0];\n if (preferred === undefined) refuse(`nothing can answer \"${question.message}\" beside ${Object.values(picks).map((id) => `--${id}`).join(' ')}`);\n picks[question.id] =\n ask && choices.length > 1\n ? answered<string>(\n await select<string>({\n message: question.message,\n options: choices.map((item) => ({ value: item.id, label: item.label ?? item.id, ...(item.hint !== undefined ? { hint: item.hint } : {}) })),\n initialValue: preferred?.id ?? '',\n }),\n )\n : (preferred?.id ?? '');\n }\n const items = itemsOf(catalog, picks);\n\n // A key is asked for masked, or read from the environment when there is no terminal to ask in — never a flag,\n // which would leave it in the shell's history.\n const env: Record<string, string> = {};\n const empty: string[] = [];\n const keyed = async (key: EnvKey): Promise<void> => {\n const value = ask\n ? answered<string>(await password({ message: `${key.message}${key.required === true ? '' : ' — optional'} · empty: fill it in .env later` }))\n : (process.env[key.name] ?? '');\n env[key.name] = value.trim();\n if (key.required === true && env[key.name] === '') empty.push(key.name);\n };\n for (const spec of envOf(items)) {\n if (!isChoice(spec)) {\n await keyed(spec);\n continue;\n }\n const value = ask\n ? answered<string>(\n await select<string>({\n message: spec.message,\n options: spec.options.map((option) => ({ value: option.value, label: option.label, ...(option.hint !== undefined ? { hint: option.hint } : {}) })),\n initialValue: spec.options[0]?.value ?? '',\n }),\n )\n : (process.env[spec.choose] ?? spec.options[0]?.value ?? '');\n env[spec.choose] = value;\n for (const key of spec.options.find((option) => option.value === value)?.keys ?? []) await keyed(key);\n }\n\n const made = generate({ dir, name, picks, env, versions: testedSet(), workspace: flags.includes('--workspace'), today: new Date().toISOString().slice(0, 10) });\n\n const run = manager();\n const where = relative(process.cwd(), dir) || '.';\n const next = [...(where === '.' ? [] : [`cd ${where}`]), `${run} install`, `${run} run dev`].join('\\n');\n const left = [...made.kept.map((file) => `kept your ${file}`), ...made.extended.map((file) => `added to your ${file}`)];\n const what = items.flatMap((item) => item.summary ?? []).join(', ');\n const summary = `${name} — ${what} — ${made.files.length} files${left.length > 0 ? ` (${left.join('; ')})` : ''}`;\n const keys = empty.length > 0 ? ` .env needs ${empty.join(', ')} before it runs.` : '';\n const after = `Before building anything: PLAN.md — what is still open — and AGENTS.md.${keys}`;\n if (ask) {\n note(next, 'Next');\n outro(`${summary}. ${after}`);\n } else {\n console.log(`create-nisc: ${summary}\\n\\n${next}\\n\\n${after}`);\n }\n};\n\nmain().catch((error: unknown) => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exit(1);\n});\n"]}
1
+ {"version":3,"sources":["../src/command/cli.ts"],"names":[],"mappings":";;;;;AAQA,IAAM,WAAA,GAAc,aAAA;AACpB,IAAM,SAAA,GAAY,CAAC,OAAA,EAAS,aAAA,EAAe,UAAU,IAAI,CAAA;AAGzD,IAAM,YAAA,GAAe,CAAC,KAAA,KAAmC,CAAC,GAAG,KAAK,CAAA,CAAE,KAAK,CAAC,GAAA,EAAK,UAAU,MAAA,CAAO,KAAA,CAAM,YAAY,IAAI,CAAA,GAAI,OAAO,GAAA,CAAI,OAAA,KAAY,IAAI,CAAC,CAAA;AAEtJ,IAAM,SAAA,GAAY,CAAC,OAAA,EAAkB,QAAA,KAA+B,aAAa,OAAA,CAAQ,KAAA,CAAM,MAAA,CAAO,CAAC,IAAA,KAAS,IAAA,CAAK,OAAA,KAAY,QAAA,CAAS,EAAE,CAAC,CAAA;AAG7I,IAAM,OAAA,GAAU,CAAC,OAAA,KAA6B;AAC5C,EAAA,MAAM,IAAA,GAA2B;AAAA,IAC/B,CAAC,KAAA,EAAO,CAAA,6BAAA,EAAgC,WAAW,CAAA,2BAAA,CAA6B,CAAA;AAAA,IAChF,GAAG,QAAQ,SAAA,CAAU,OAAA;AAAA,MAAQ,CAAC,aAC5B,SAAA,CAAU,OAAA,EAAS,QAAQ,CAAA,CAAE,GAAA,CAAI,CAAC,IAAA,KAA2B;AAC3D,QAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,MAAA,CAAO,IAAA,CAAK,QAAA,IAAY,EAAE,CAAA,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AAI,CAAA,EAAA,EAAK,IAAA,CAAK,KAAK,IAAI,CAAC,MAAM,EAAE,CAAA,CAAA;AAC/G,EAAA,MAAM,IAAA,GAAO,MAAM,MAAA,GAAS,CAAA,GAAI,eAAe,KAAA,CAAM,IAAA,CAAK,IAAI,CAAC,CAAA,gBAAA,CAAA,GAAqB,EAAA;AACpF,EAAA,MAAM,KAAA,GAAQ,oFAA0E,IAAI,CAAA,CAAA;AAC5F,EAAA,IAAI,GAAA,EAAK;AACP,IAAA,IAAA,CAAK,MAAM,MAAM,CAAA;AACjB,IAAA,KAAA,CAAM,CAAA,EAAG,OAAO,CAAA,EAAA,EAAK,KAAK,CAAA,CAAE,CAAA;AAAA,EAC9B,CAAA,MAAO;AACL,IAAA,OAAA,CAAQ,GAAA,CAAI,gBAAgB,OAAO;;AAAA,EAAO,IAAI;;AAAA,EAAO,KAAK,CAAA,CAAE,CAAA;AAAA,EAC9D;AACF,CAAA;AAEA,IAAA,EAAK,CAAE,KAAA,CAAM,CAAC,KAAA,KAAmB;AAC/B,EAAA,OAAA,CAAQ,MAAM,KAAA,YAAiB,KAAA,GAAQ,MAAM,OAAA,GAAU,MAAA,CAAO,KAAK,CAAC,CAAA;AACpE,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAChB,CAAC,CAAA","file":"cli.js","sourcesContent":["import { existsSync, readdirSync } from 'node:fs';\nimport { basename, relative, resolve } from 'node:path';\nimport { cancel, confirm, intro, isCancel, note, outro, password, select, text } from '@clack/prompts';\nimport { envOf, isChoice, itemsOf, offered, readCatalog } from '../catalog';\nimport type { Catalog, EnvKey, Item, Question } from '../catalog';\nimport { TEMPLATES, generate, refuseFileInTheWay, validName } from '../generate';\nimport { testedSet } from './set';\n\nconst DEFAULT_DIR = 'my-nisc-app';\nconst OWN_FLAGS = ['--yes', '--workspace', '--help', '-h'];\n\n// The default first, then the rest in the order of their folders.\nconst defaultFirst = (items: readonly Item[]): Item[] => [...items].sort((one, other) => Number(other.default === true) - Number(one.default === true));\n\nconst answering = (catalog: Catalog, question: Question): Item[] => defaultFirst(catalog.items.filter((item) => item.answers === question.id));\n\n// Written from the templates, so a new kit, shell or kind of app is in it without a line here changing.\nconst usageOf = (catalog: Catalog): string => {\n const rows: [string, string][] = [\n ['dir', `where the app goes (default: ${DEFAULT_DIR}); its name is the folder's`],\n ...catalog.questions.flatMap((question) =>\n answering(catalog, question).map((item): [string, string] => {\n const needs = Object.values(item.requires ?? {}).map((id) => `--${id}`);\n return [`--${item.id}`, `${item.usage ?? item.label ?? item.id}${item.default === true ? ' — the default' : ''}${needs.length > 0 ? ` (with ${needs.join(', ')})` : ''}`];\n }),\n ),\n ['--yes', 'take the defaults for anything not given, and ask nothing'],\n ['--workspace', 'depend on the nisc packages of the workspace it is made in — for an app inside the nisc repository'],\n ];\n const width = Math.max(...rows.map(([flag]) => flag.length)) + 2;\n const choices = catalog.questions.map((question) => `[${answering(catalog, question).map((item) => `--${item.id}`).join(' | ')}]`).join(' ');\n return `npm create nisc [dir] ${choices} [--yes]\\n\\n${rows.map(([flag, what]) => ` ${flag.padEnd(width)}${what}`).join('\\n')}`;\n};\n\nconst answered = <T extends string | boolean>(value: T | symbol): T => {\n if (typeof value === 'symbol' || isCancel(value)) {\n cancel('Nothing was made.');\n process.exit(1);\n }\n return value;\n};\n\nconst manager = (): string => {\n const agent = process.env['npm_config_user_agent'] ?? '';\n return ['pnpm', 'yarn', 'bun'].find((name) => agent.startsWith(name)) ?? 'npm';\n};\n\nconst main = async (): Promise<void> => {\n const catalog = readCatalog(TEMPLATES);\n const usage = usageOf(catalog);\n const refuse = (message: string): never => {\n console.error(`create-nisc: ${message}\\n\\n${usage}`);\n process.exit(1);\n };\n\n const args = process.argv.slice(2);\n if (args.includes('--help') || args.includes('-h')) {\n console.log(usage);\n return;\n }\n const flags = args.filter((arg) => arg.startsWith('-'));\n const positional = args.filter((arg) => !arg.startsWith('-'));\n const byFlag = new Map(catalog.items.filter((item) => item.answers !== undefined).map((item) => [`--${item.id}`, item]));\n const unknown = flags.filter((flag) => !OWN_FLAGS.includes(flag) && !byFlag.has(flag));\n if (unknown.length > 0) refuse(`unknown option ${unknown.join(', ')}`);\n if (positional.length > 1) refuse(`one folder at a time — got ${positional.join(', ')}`);\n\n const picks: Record<string, string> = {};\n for (const item of flags.flatMap((flag) => byFlag.get(flag) ?? [])) {\n const question = item.answers ?? '';\n const before = picks[question];\n if (before !== undefined && before !== item.id) refuse(`--${before} and --${item.id} are two different apps; pick one`);\n picks[question] = item.id;\n }\n for (const id of Object.values(picks)) {\n for (const [question, wanted] of Object.entries(byFlag.get(`--${id}`)?.requires ?? {})) {\n const other = picks[question];\n if (other !== undefined && other !== wanted) refuse(`--${id} needs --${wanted}, not --${other}`);\n }\n }\n\n const ask = process.stdout.isTTY === true && process.stdin.isTTY === true && !flags.includes('--yes');\n if (ask) intro('a new nisc app');\n\n const given = positional[0];\n const dirInput =\n given ??\n (ask\n ? answered<string>(\n await text({\n message: 'Where should it go?',\n placeholder: DEFAULT_DIR,\n defaultValue: DEFAULT_DIR,\n validate: (value) =>\n validName(basename(resolve(value === undefined || value === '' ? DEFAULT_DIR : value))) ? undefined : 'the folder’s name becomes the package name: lowercase letters, digits, - . _',\n }),\n )\n : DEFAULT_DIR);\n const dir = resolve(dirInput === '' ? DEFAULT_DIR : dirInput);\n const name = basename(dir);\n if (!validName(name)) refuse(`\"${name}\" cannot be a package name — the folder’s name becomes it: lowercase letters, digits, - . _`);\n refuseFileInTheWay(dir);\n\n const present = existsSync(dir) ? readdirSync(dir).length : 0;\n if (present > 0 && ask) {\n const proceed = answered<boolean>(\n await confirm({ message: `${relative(process.cwd(), dir) || '.'} already has ${present} ${present === 1 ? 'thing' : 'things'} in it. Nothing there will be overwritten — make the app in it?`, initialValue: true }),\n );\n if (!proceed) {\n cancel('Nothing was made.');\n process.exit(1);\n }\n }\n\n for (const question of catalog.questions) {\n if (picks[question.id] !== undefined) continue;\n const choices = defaultFirst(offered(catalog, question.id, picks));\n const preferred = choices.find((item) => item.default === true) ?? choices[0];\n if (preferred === undefined) refuse(`nothing can answer \"${question.message}\" beside ${Object.values(picks).map((id) => `--${id}`).join(' ')}`);\n picks[question.id] =\n ask && choices.length > 1\n ? answered<string>(\n await select<string>({\n message: question.message,\n options: choices.map((item) => ({ value: item.id, label: item.label ?? item.id, ...(item.hint !== undefined ? { hint: item.hint } : {}) })),\n initialValue: preferred?.id ?? '',\n }),\n )\n : (preferred?.id ?? '');\n }\n const items = itemsOf(catalog, picks);\n\n // A key is asked for masked, or read from the environment when there is no terminal to ask in — never a flag,\n // which would leave it in the shell's history.\n const env: Record<string, string> = {};\n const empty: string[] = [];\n const keyed = async (key: EnvKey): Promise<void> => {\n const value = ask\n ? answered<string>(await password({ message: `${key.message}${key.required === true ? '' : ' — optional'} · empty: fill it in .env later` }))\n : (process.env[key.name] ?? '');\n env[key.name] = value.trim();\n if (key.required === true && env[key.name] === '') empty.push(key.name);\n };\n for (const spec of envOf(items)) {\n if (!isChoice(spec)) {\n await keyed(spec);\n continue;\n }\n const value = ask\n ? answered<string>(\n await select<string>({\n message: spec.message,\n options: spec.options.map((option) => ({ value: option.value, label: option.label, ...(option.hint !== undefined ? { hint: option.hint } : {}) })),\n initialValue: spec.options[0]?.value ?? '',\n }),\n )\n : (process.env[spec.choose] ?? spec.options[0]?.value ?? '');\n env[spec.choose] = value;\n for (const key of spec.options.find((option) => option.value === value)?.keys ?? []) await keyed(key);\n }\n\n const made = generate({ dir, name, picks, env, versions: testedSet(), workspace: flags.includes('--workspace'), today: new Date().toISOString().slice(0, 10) });\n\n const run = manager();\n const where = relative(process.cwd(), dir) || '.';\n const quoted = /^[\\w./\\\\:-]+$/.test(where) ? where : `\"${where}\"`;\n const next = [...(where === '.' ? [] : [`cd ${quoted}`]), `${run} install`, `${run} run dev`].join('\\n');\n const left = [...made.kept.map((file) => `kept your ${file}`), ...made.extended.map((file) => `added to your ${file}`)];\n const what = items.flatMap((item) => item.summary ?? []).join(', ');\n const summary = `${name} — ${what} — ${made.files.length} files${left.length > 0 ? ` (${left.join('; ')})` : ''}`;\n const keys = empty.length > 0 ? ` .env needs ${empty.join(', ')} before it runs.` : '';\n const after = `Before building anything: PLAN.md — what is still open — and AGENTS.md.${keys}`;\n if (ask) {\n note(next, 'Next');\n outro(`${summary}. ${after}`);\n } else {\n console.log(`create-nisc: ${summary}\\n\\n${next}\\n\\n${after}`);\n }\n};\n\nmain().catch((error: unknown) => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exit(1);\n});\n"]}
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { TEMPLATES, completed, generate, readCatalog, testedSet, validName } from './chunk-2W7KLXCO.js';
1
+ export { TEMPLATES, completed, generate, readCatalog, testedSet, validName } from './chunk-TLJ3YNUU.js';
2
2
  //# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nisc",
3
- "version": "0.9.4",
3
+ "version": "0.11.0",
4
4
  "description": "npm create nisc — a new nisc application: a few questions, then an app with the right structure, its rulebook, and a first screen that works.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -7,7 +7,7 @@ tools: Read, Grep, Glob
7
7
  You review a nisc application. You read; you change nothing.
8
8
 
9
9
  1. Read `node_modules/@niscorp/nisc/REVIEW.md` in full. It is the guide for the nisc version this app has installed, and it says what to read, in what order, and how to report. Then read this app's `PLAN.md` and `AGENTS.md`.
10
- 2. The gates come first. If the request holds the output of `npm run typecheck` and `npm run check`, a failure in it is your first finding. If it does not, say at the top of your report that the gates were not run, and review anyway.
10
+ 2. The gates come first. If the request contains the output of `npm run typecheck` and `npm run check`, a failure in it is your first finding. If it does not, say at the top of your report that the gates were not run, and review anyway.
11
11
  3. Take the counts in REVIEW.md's "Measure first" with Grep, and let them say where to read.
12
12
  4. Go through REVIEW.md's checklist and "What to look for". Where a finding needs a rule's exact words, read it in `node_modules/@niscorp/nisc/AGENTS.md`, or in a package's own docs under `node_modules/@niscorp/<name>/`.
13
13
  5. Verify every finding in the code before you report it: open the file and quote the line. A finding you could not verify is left out, or reported as a question.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "grammar": {
3
3
  "nisc.nova": 2,
4
- "nisc.prism": 3
4
+ "nisc.prism": 4
5
5
  }
6
6
  }
@@ -6,13 +6,13 @@
6
6
  "type": "module",
7
7
  "engines": { "node": ">=22.12" },
8
8
  "dependencies": {
9
+ "@niscorp/cli": "workspace:^",
9
10
  "@niscorp/nova": "workspace:^",
10
11
  "@niscorp/prism": "workspace:^",
11
12
  "@niscorp/strata": "workspace:^",
12
13
  "zod": "^4.6.5"
13
14
  },
14
15
  "devDependencies": {
15
- "@niscorp/cli": "workspace:^",
16
16
  "@niscorp/nisc": "workspace:^",
17
17
  "@types/node": "^26.6.4",
18
18
  "tsx": "^4.23.1",
@@ -1,3 +1,4 @@
1
+ import { verifyApp } from '@niscorp/moss';
1
2
  import { ActionDefinitionSchema, LayoutNodeSchema } from '@niscorp/nova';
2
3
  import { actions } from '../app/action-catalog';
3
4
  import { assignments } from '../app/charter/assignments';
@@ -37,6 +38,9 @@ pure('the assignments', assignments);
37
38
  pure('the shell', shell);
38
39
  if (shell.layout !== undefined) parses('the shell’s frame', () => LayoutNodeSchema.parse(shell.layout));
39
40
 
41
+ const unread = verifyApp({ charter, assignments, actions, shell }, []).charter.warnings.flatMap((warning) => (warning.rule === 'shape' ? [warning.detail] : []));
42
+ check('the charter reads every key it is given', unread.length === 0, unread.join('; '));
43
+
40
44
  for (const [id, definition] of Object.entries(actions)) {
41
45
  check(`action "${id}" is catalogued under its own id`, definition.id === id, `its id is "${definition.id}"`);
42
46
  parses(`action "${id}"`, () => ActionDefinitionSchema.parse(definition));
@@ -1,4 +1,5 @@
1
1
  import { renderDocument } from '@niscorp/moss';
2
+ import { walkNodes } from '@niscorp/nova/reflect';
2
3
  import { boot } from '../server/boot';
3
4
  import { drawing } from '../server/document';
4
5
 
@@ -15,9 +16,11 @@ try {
15
16
  const shells = server.shells;
16
17
  if (shells === undefined) throw new Error('the manifest has no shell');
17
18
  const snapshot = await shells.snapshot(null, null);
18
- const main = JSON.stringify(snapshot.trees['main'] ?? []);
19
- check('the anonymous principal is served the welcome action', main.includes('"definitionId":"welcome"'), main.slice(0, 200));
20
- check('its screen has a button to press', main.includes('"ref":"press"'));
19
+ const main = snapshot.trees['main'] ?? [];
20
+ const nodes: Record<string, unknown>[] = [];
21
+ walkNodes(main, (node) => nodes.push(node));
22
+ check('the anonymous principal is served the welcome action', nodes.some((node) => node['definitionId'] === 'welcome'), JSON.stringify(main).slice(0, 200));
23
+ check('its screen has a button to press', nodes.some((node) => node['ref'] === 'press'));
21
24
 
22
25
  const template = '<!doctype html><html><head></head><body><div id="root"></div></body></html>';
23
26
  const page = await renderDocument({ ...drawing, server, template, request: { path: '/', cookie: null } });
@@ -4,7 +4,7 @@ import type { DomComponent } from '@niscorp/nova/adapters/dom';
4
4
  // nova's DOM adapter wires the clicks of an element with a `ref` (its `value` the payload), and the input and keys of
5
5
  // one with a `model`, itself.
6
6
 
7
- // A value a component does not take falls back to its default on its own; the others still hold.
7
+ // A value a component does not take falls back to its default on its own; the others still apply.
8
8
  const parsed = <S extends z.ZodRawShape>(schema: z.ZodObject<S>, props: Record<string, unknown>, fallback: z.output<z.ZodObject<S>>): z.output<z.ZodObject<S>> => {
9
9
  const taken = Object.fromEntries(
10
10
  Object.entries(props).filter(([key, value]) => {
@@ -18,6 +18,7 @@
18
18
  "docs": { "where": ["src/ui/ the kit — the only renderer code, with src/main.ts, the terminal entry"] }
19
19
  },
20
20
  "page": {
21
+ "package": { "dependencies": { "jsdom": "^25.0.1" } },
21
22
  "docs": { "where": ["src/ui/ the kit and the screen — the only renderer code, with src/main.ts, the entry"] }
22
23
  }
23
24
  }
@@ -20,7 +20,7 @@ The screen fills the page and scrolls; one dock stays at the bottom (`src/app/ac
20
20
 
21
21
  The tour is a starting point, there to be deleted. First the interview: PLAN.md's open items, each answered or delegated by name (the rulebook's "Before any code").
22
22
 
23
- **Remove the tour.** It lives in four places and is named in seven:
23
+ **Remove the tour.** It lives in four places (step 1) and is named in seven files and the two documents (steps 2–8):
24
24
 
25
25
  1. Delete `src/app/actions/guide/`, `src/dev/guide-check.ts` and `src/app/vex/guide.entries.ts`; in `src/db/schema.ts`, the tour's migration. Deleting a migration is safe only because no database that lasts has run it — the app runs on PGlite, which starts empty every boot. Once one has, the migration is history, and a table goes by appending a migration that drops it (rule 17).
26
26
  2. `src/app/action-catalog.ts`: drop the `GUIDE` import; `placeable` is `[]` until your own actions are in it.
@@ -43,7 +43,7 @@ What the template leaves out, so that it starts small. None of it is required, a
43
43
  - **Your data, and cards that show it.** A table in `src/db/schema.ts`, a read in `src/app/vex/`, an action that replays it — as `guide.packages` does — in `placeable`, granted in the charter, with a `live-ask` case for the question it answers. The model is told what a card shows, never the rows: to answer about your data, it shows the card.
44
44
  - **Writes.** A form card the model may open filled in (D4); the person saves it, through a vex mutation, never the model.
45
45
  - **Sign-in and roles.** Once more than one person uses the app, or anything in it is somebody's own: who is signed in is moss's (`runtime.session`), what each role may reach is the charter's. The model is offered, and a screen opens with, only the cards the person's roles reach — that filter is already there (`session.actions`). The dock lists every screen: when roles see different ones, give each person their own list through moss's `inputs`.
46
- - **A conversation that outlives the shell** (D8, once there is sign-in). The turns become rows the person owns, written by the server as a machine role at the person's own reach (`executeAs`), read back when their shell is built (`seeds`); `place` and `said` in `src/server/compose/index.ts` are where it goes.
46
+ - **A conversation that outlives the shell** (D8, once there is sign-in). The turns become rows the person owns, written by the server as a machine role at the person's own reach (`executeAs`), read back when their shell is built (`seeds`); `begin` and `said` in `src/server/compose/index.ts` are where it goes.
47
47
  - **Facts the model can rely on,** as the cards need them. When a card takes a date, tell the model today's date, in the app's time zone, in `messageInput`. When it opens a record by its id, tell it the ids that exist, and refuse in `turnRefusals` an id it was not told: a model that makes up an id shows a card of nothing.
48
48
  - **Asking back, and what to ask next.** A card of choices, each one a message emitted on `ask` when tapped — as the tour's examples are — for when the message could mean two things, or to offer the next question.
49
- - **Deploying.** A real Postgres in `src/server/runtime.ts`, its tables applied by `nisc migrate`, never at boot (rule 17).
49
+ - **Deploying.** A real Postgres in `src/server/runtime.ts`, its tables applied by `nisc migrate`, never at boot (rule 17). As made, everyone may `ask` (`public` in the charter), so anybody who can reach the deployed app spends your Groq key: sign-in and a role that may ask, or a limit in `ask`, come first.
@@ -55,7 +55,7 @@ export const GUIDE: readonly ActionDefinition[] = [
55
55
  text: 'That is the counter on this screen. Actions live in src/app/actions/.',
56
56
  links: [{ label: 'Next: asking →', screen: 'asking' }],
57
57
  }),
58
- card('guide.layouts', 'Layouts and the kit: a layout is JSON that names components and binds them to the action’s data, and never styles; the kit in src/ui/ draws them, and its stylesheet holds the look.', exampleLayout, {
58
+ card('guide.layouts', 'Layouts and the kit: a layout is JSON that names components and binds them to the action’s data, and never styles; the kit in src/ui/ draws them, and its stylesheet has the look.', exampleLayout, {
59
59
  title: 'Layouts and the kit',
60
60
  lead: 'A layout is JSON that names components and binds them to the action’s data. It never styles anything.',
61
61
  example: ['{', ' "component": "Card",', ' "props": { "title": "{{$.title}}" },', ' "children": [', ' { "component": "Text", "children": "{{$.count}}" }', ' ]', '}'].join('\n'),
@@ -84,9 +84,9 @@ export const GUIDE: readonly ActionDefinition[] = [
84
84
  },
85
85
  [asks],
86
86
  ),
87
- card('guide.shell', 'The shell and moss: moss keeps one shell per person, on the server, which holds the cards and runs what they do; the browser only draws the frames moss sends over a socket.', pointsLayout, {
87
+ card('guide.shell', 'The shell and moss: moss keeps one shell per person, on the server, which has the cards and runs what they do; the browser only draws the frames moss sends over a socket.', pointsLayout, {
88
88
  title: 'The shell and moss',
89
- lead: 'The shell holds the cards and runs what they do.',
89
+ lead: 'The shell has the cards and runs what they do.',
90
90
  points: [
91
91
  { title: 'One per person', text: 'moss keeps a shell for each person who signs in; until then, one a connection.' },
92
92
  { title: 'Drawn where you are', text: 'Your browser draws the frames moss sends over a socket.' },
@@ -31,7 +31,7 @@ export const SCREENS: readonly [Screen, ...Screen[]] = [
31
31
  cards: [
32
32
  card('guide.actions'),
33
33
  COUNTER,
34
- quiz('Where does the look of a card live?', ['In its layout', 'In the model’s answer', 'In the kit’s stylesheet'], 2, 'A layout only names components; the kit in src/ui/ draws them, and its stylesheet holds the look.'),
34
+ quiz('Where does the look of a card live?', ['In its layout', 'In the model’s answer', 'In the kit’s stylesheet'], 2, 'A layout only names components; the kit in src/ui/ draws them, and its stylesheet has the look.'),
35
35
  card('guide.layouts'),
36
36
  { action: 'guide.checklist', input: { title: 'Try it', todo: ['Press + until the counter says 5', 'Press Reset', 'Ask for a counter that starts at 100', 'Ask what a layout is'] } },
37
37
  ],
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { verifyApp } from '@niscorp/moss';
2
3
  import { ActionDefinitionSchema, LayoutNodeSchema } from '@niscorp/nova';
3
4
  import type { LayoutNode } from '@niscorp/nova';
4
5
  import { componentsOf, walkNodes } from '@niscorp/nova/reflect';
@@ -39,6 +40,9 @@ pure('the assignments', assignments);
39
40
  pure('the shell', shell);
40
41
  if (shell.layout !== undefined) parses('the shell’s frame', () => LayoutNodeSchema.parse(shell.layout));
41
42
 
43
+ const unread = verifyApp({ charter, assignments, actions, shell }, []).charter.warnings.flatMap((warning) => (warning.rule === 'shape' ? [warning.detail] : []));
44
+ check('the charter reads every key it is given', unread.length === 0, unread.join('; '));
45
+
42
46
  for (const [id, definition] of Object.entries(actions)) {
43
47
  check(`action "${id}" is catalogued under its own id`, definition.id === id, `its id is "${definition.id}"`);
44
48
  parses(`action "${id}"`, () => ActionDefinitionSchema.parse(definition));
@@ -1,4 +1,5 @@
1
1
  import { existsSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
2
3
  import type { SignalClient } from '@niscorp/cortex';
3
4
  import type { Chat } from '../server/compose';
4
5
  import { modelsFromEnv } from '../server/models';
@@ -34,7 +35,8 @@ const runs = Number(process.argv.find((arg) => arg.startsWith('--runs='))?.slice
34
35
  const own = process.argv.slice(2).filter((arg) => !arg.startsWith('--'));
35
36
  const cases: readonly Case[] = own.length > 0 ? own.map((ask) => ({ ask, want: () => undefined, follows: true })) : CASES;
36
37
 
37
- if (existsSync('.env')) process.loadEnvFile('.env');
38
+ const envFile = fileURLToPath(new URL('../../.env', import.meta.url));
39
+ if (existsSync(envFile)) process.loadEnvFile(envFile);
38
40
  const models = modelsFromEnv(process.env);
39
41
  if (models.chat === undefined) {
40
42
  console.log(`Set ${models.missing.join(' and ')} in .env: live-ask asks the real model.`);
@@ -1,4 +1,5 @@
1
1
  import { existsSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
2
3
  import { createServer } from '@niscorp/moss';
3
4
  import type { MossServer, NiscRuntime, RunSink } from '@niscorp/moss';
4
5
  import { buildApp } from '../app/app';
@@ -9,8 +10,10 @@ import { modelsFromEnv } from './models';
9
10
  import { logRun } from './runs';
10
11
  import { runtime as database } from './runtime';
11
12
 
13
+ const ENV_FILE = fileURLToPath(new URL('../../.env', import.meta.url));
14
+
12
15
  const fromEnvFile = (): Models => {
13
- if (existsSync('.env')) process.loadEnvFile('.env');
16
+ if (existsSync(ENV_FILE)) process.loadEnvFile(ENV_FILE);
14
17
  const models = modelsFromEnv(process.env);
15
18
  console.log(`[app] ${models.summary}`);
16
19
  if (models.missing.length > 0) console.log(`[app] ${models.missing.join(', ')} is empty in .env: until it is set, a message is answered with a notice saying so.`);
@@ -27,8 +27,8 @@ export const firstScreen: NonNullable<ShellManifest['seeds']> = () => ({ screen:
27
27
  export const composer =
28
28
  (models: Models): ((session: FunctionSession) => FunctionDefinition[]) =>
29
29
  (session) => {
30
- const held = new Set(session.actions);
31
- const catalog: Catalog = { actions: CATALOG.actions.filter((action) => held.has(action.id)) };
30
+ const granted = new Set(session.actions);
31
+ const catalog: Catalog = { actions: CATALOG.actions.filter((action) => granted.has(action.id)) };
32
32
  // The conversation lives as long as this shell: the turns on its `talk` canvas, and what they said, here.
33
33
  const said: Said[] = [];
34
34
 
@@ -82,12 +82,12 @@ export const composer =
82
82
  const screen = SCREENS.find((candidate) => candidate.id === OpenSchema.parse(data).opening);
83
83
  if (screen === undefined) throw new Error('There is no such screen.');
84
84
  for (const shown of session.shell.getState().canvases['screen']?.stack ?? []) session.shell.removeInstance('screen', shown.id);
85
- for (const card of screen.cards) if (held.has(card.action)) session.shell.push('screen', card.action, card.input, undefined, { history: false });
85
+ for (const card of screen.cards) if (granted.has(card.action)) session.shell.push('screen', card.action, card.input, undefined, { history: false });
86
86
  return { screen: screen.id };
87
87
  };
88
88
 
89
89
  return [
90
- { id: 'ask', description: 'Answers a message with a turn of the conversation: a sentence, and the cards under it. Send { text }.', execute: ask },
90
+ { id: 'ask', description: 'Answers a message with a turn of the conversation: a sentence, and the cards under it. Send { asked: <the message> }.', execute: ask },
91
91
  { id: 'screens.open', description: 'Shows one of the screens in the dock: its cards, one under another. Send { opening: <screen id> }; answers { screen }.', execute: open },
92
92
  ];
93
93
  };
@@ -59,6 +59,7 @@
59
59
  "Memory: what the app keeps of a person between messages (D8).",
60
60
  "Look and feel.",
61
61
  "Where it is deployed.",
62
+ "Who may ask the model: today everyone (`public`, `src/app/charter/charter.ts`), so anybody who can reach the deployed app spends your Groq key, with no limit. Before deploying: sign-in and a role that may ask, or a limit in `ask`.",
62
63
  "What happens to the data long-term."
63
64
  ],
64
65
  "order": [
@@ -20,7 +20,6 @@
20
20
  "@electric-sql/pglite": "^0.5.1",
21
21
  "@niscorp/charter": "workspace:^",
22
22
  "@niscorp/moss": "workspace:^",
23
- "@niscorp/tide": "workspace:^",
24
23
  "@niscorp/vex": "workspace:^"
25
24
  }
26
25
  },
@@ -17,8 +17,7 @@
17
17
  "strata": "tsx src/dev/strata.ts"
18
18
  },
19
19
  "devDependencies": {
20
- "@types/jsdom": "^30.0.0",
21
- "jsdom": "^25.0.1"
20
+ "@types/jsdom": "^30.0.0"
22
21
  }
23
22
  },
24
23
  "docs": {
@@ -3,7 +3,7 @@ import { z } from 'zod';
3
3
  import { useNovaDispatch } from '@niscorp/nova/adapters/react';
4
4
  import type { NovaComponent } from '@niscorp/nova/adapters/react';
5
5
 
6
- // A value a component does not take falls back to its default on its own; the others still hold.
6
+ // A value a component does not take falls back to its default on its own; the others still apply.
7
7
  const parsed = <S extends z.ZodRawShape>(schema: z.ZodObject<S>, props: Record<string, unknown>, fallback: z.output<z.ZodObject<S>>): z.output<z.ZodObject<S>> => {
8
8
  const taken = Object.fromEntries(
9
9
  Object.entries(props).filter(([key, value]) => {
@@ -25,6 +25,7 @@
25
25
  "docs": { "where": ["src/ui/ the kit — the only renderer code, with src/main.tsx, the terminal entry"] }
26
26
  },
27
27
  "page": {
28
+ "package": { "devDependencies": { "jsdom": "^25.0.1" } },
28
29
  "docs": { "where": ["src/ui/ the kit and the screen — the only renderer code, with src/main.tsx, the entry"] }
29
30
  }
30
31
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["%3Cdefine:__NISC_SET__%3E","../src/catalog/items.ts","../src/catalog/choose.ts","../src/docs.ts","../src/generate.ts","../src/set.ts"],"names":["offered","existsSync","join","readdirSync","isRecord","readFileSync","sections"],"mappings":";;;;;AAAA,IAAA,uBAAA,GAAA,EAAC,kBAAA,EAAmB,OAAA,EAAQ,cAAA,EAAe,OAAA,EAAQ,iBAAA,EAAkB,SAAQ,eAAA,EAAgB,OAAA,EAAQ,eAAA,EAAgB,OAAA,EAAQ,eAAA,EAAgB,OAAA,EAAQ,iBAAgB,OAAA,EAAQ,gBAAA,EAAiB,OAAA,EAAQ,iBAAA,EAAkB,OAAA,EAAQ,gBAAA,EAAiB,OAAA,EAAQ,iBAAA,EAAkB,OAAA,EAAQ,eAAA,EAAgB,QAAA,EAAS,cAAA,EAAe,OAAA,EAAO;ACwClU,IAAM,QAAA,GAAW,CAAC,KAAA,KAAqD,KAAA,KAAU,IAAA,IAAQ,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,KAAA,CAAM,OAAA,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orp/charter\":\"0.1.5\",\"@niscorp/cli\":\"0.9.1\",\"@niscorp/cortex\":\"0.1.6\",\"@niscorp/loom\":\"0.5.0\",\"@niscorp/moss\":\"0.9.2\",\"@niscorp/nisc\":\"0.9.4\",\"@niscorp/nova\":\"0.5.2\",\"@niscorp/prism\":\"0.3.3\",\"@niscorp/signal\":\"0.1.9\",\"@niscorp/solid\":\"0.1.3\",\"@niscorp/strata\":\"0.1.9\",\"@niscorp/tide\":\"0.1.11\",\"@niscorp/vex\":\"0.4.4\"}","import { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\nexport type EnvKey = { name: string; message: string; required?: boolean };\nexport type EnvOption = { value: string; label: string; hint?: string; keys?: readonly EnvKey[] };\nexport type EnvChoice = { choose: string; message: string; options: readonly EnvOption[] };\nexport type EnvSpec = EnvKey | EnvChoice;\n\nexport type Docs = {\n is?: string;\n where?: readonly string[];\n runs?: readonly string[];\n decisions?: readonly string[];\n answered?: readonly string[];\n open?: readonly string[];\n order?: readonly string[];\n};\n\nexport type Part = {\n package?: Readonly<Record<string, unknown>>;\n env?: readonly EnvSpec[];\n docs?: Docs;\n};\n\nexport type Item = Part & {\n id: string;\n answers?: string;\n label?: string;\n hint?: string;\n usage?: string;\n summary?: string;\n default?: boolean;\n requires?: Readonly<Record<string, string>>;\n with?: Readonly<Record<string, Part>>;\n};\n\nexport type Question = { id: string; message: string };\n\nexport type Catalog = { root: string; questions: readonly Question[]; items: readonly Item[] };\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === 'object' && !Array.isArray(value);\n\nconst json = (path: string): unknown => {\n try {\n return JSON.parse(readFileSync(path, 'utf8'));\n } catch (error) {\n throw new Error(`create-nisc: ${path} is not JSON — ${error instanceof Error ? error.message : String(error)}`);\n }\n};\n\nexport const isChoice = (spec: EnvSpec): spec is EnvChoice => 'choose' in spec;\n\n// The templates are ours, so a mistake in them is a bug: it is refused here with a sentence, before anything is written.\nexport const readCatalog = (root: string): Catalog => {\n const questions = json(join(root, 'questions.json'));\n if (!Array.isArray(questions) || !questions.every((q) => isRecord(q) && typeof q['id'] === 'string' && typeof q['message'] === 'string')) {\n throw new Error(`create-nisc: ${root}/questions.json is not a list of { id, message }`);\n }\n const items: Item[] = readdirSync(root, { withFileTypes: true })\n .filter((entry) => entry.isDirectory() && existsSync(join(root, entry.name, 'item.json')))\n .map((entry) => {\n const item = json(join(root, entry.name, 'item.json'));\n if (!isRecord(item) || item['id'] !== entry.name) throw new Error(`create-nisc: ${entry.name}/item.json must say \"id\": \"${entry.name}\"`);\n return item as Item;\n });\n\n const asked = new Set((questions as Question[]).map((q) => q.id));\n const known = new Set(items.map((item) => item.id));\n const answering = (question: string): Item[] => items.filter((item) => item.answers === question);\n for (const item of items) {\n if (item.answers !== undefined && !asked.has(item.answers)) throw new Error(`create-nisc: item \"${item.id}\" answers \"${item.answers}\", which questions.json does not ask`);\n if (item.answers !== undefined && item.label === undefined) throw new Error(`create-nisc: item \"${item.id}\" answers a question but has no label to offer`);\n for (const [question, wanted] of Object.entries(item.requires ?? {})) {\n if (!answering(question).some((other) => other.id === wanted)) throw new Error(`create-nisc: item \"${item.id}\" requires \"${wanted}\" for \"${question}\", which no item answering it is`);\n }\n for (const other of Object.keys(item.with ?? {})) if (!known.has(other)) throw new Error(`create-nisc: item \"${item.id}\" has a part for \"${other}\", which is no item`);\n }\n for (const question of questions as Question[]) {\n const offered = answering(question.id);\n if (offered.length === 0) throw new Error(`create-nisc: nothing answers \"${question.id}\"`);\n if (offered.filter((item) => item.default === true).length !== 1) throw new Error(`create-nisc: exactly one item answering \"${question.id}\" is its default`);\n }\n return { root, questions: questions as Question[], items };\n};\n","import type { Catalog, EnvSpec, Item, Part } from './items';\n\n// Question id → the id of the item that answers it.\nexport type Picks = Readonly<Record<string, string>>;\n\nconst itemNamed = (catalog: Catalog, id: string): Item | undefined => catalog.items.find((item) => item.id === id);\n\n// What the items picked so far say other questions must be answered with.\nexport const impliedBy = (catalog: Catalog, picks: Picks): Record<string, string> => {\n const implied: Record<string, string> = {};\n for (const id of Object.values(picks)) Object.assign(implied, itemNamed(catalog, id)?.requires ?? {});\n return implied;\n};\n\n// The items that can still answer a question, beside what is picked.\nexport const offered = (catalog: Catalog, question: string, picks: Picks): Item[] => {\n const implied = impliedBy(catalog, picks)[question];\n return catalog.items.filter(\n (item) =>\n item.answers === question &&\n (implied === undefined || implied === item.id) &&\n Object.entries(item.requires ?? {}).every(([other, wanted]) => picks[other] === undefined || picks[other] === wanted),\n );\n};\n\n// Answers every question the picks leave open the way a person who takes the defaults would.\nexport const completed = (catalog: Catalog, picks: Picks): Record<string, string> => {\n const done: Record<string, string> = { ...picks };\n for (const question of catalog.questions) {\n if (done[question.id] !== undefined) continue;\n const choices = offered(catalog, question.id, done);\n const chosen = choices.find((item) => item.default === true) ?? choices[0];\n if (chosen === undefined) throw new Error(`create-nisc: nothing can answer \"${question.message}\" beside ${Object.values(done).join(', ')}`);\n done[question.id] = chosen.id;\n }\n return done;\n};\n\n// The items an app is made of: the one answering each question, in the order they are asked, then the ones every\n// app has. Refused when a question is unanswered or an item's requirement is not met.\nexport const itemsOf = (catalog: Catalog, picks: Picks): Item[] => {\n const answering = catalog.questions.map((question) => {\n const id = picks[question.id];\n const item = id === undefined ? undefined : itemNamed(catalog, id);\n if (item === undefined || item.answers !== question.id) throw new Error(`create-nisc: \"${question.message}\" has no answer${id === undefined ? '' : ` — \"${id}\" does not answer it`}`);\n return item;\n });\n for (const item of answering) {\n for (const [question, wanted] of Object.entries(item.requires ?? {})) {\n if (picks[question] !== wanted) throw new Error(`create-nisc: \"${item.id}\" needs \"${wanted}\", not \"${picks[question] ?? 'nothing'}\"`);\n }\n }\n return [...answering, ...catalog.items.filter((item) => item.answers === undefined)];\n};\n\n// Each item's own part, followed by its part for every other item the app is made of.\nexport const partsOf = (items: readonly Item[]): Part[] => {\n const ids = new Set(items.map((item) => item.id));\n return items.flatMap((item) => [item, ...Object.entries(item.with ?? {}).flatMap(([other, part]) => (ids.has(other) ? [part] : []))]);\n};\n\nexport const envOf = (items: readonly Item[]): EnvSpec[] => partsOf(items).flatMap((part) => part.env ?? []);\n","import type { Part } from './catalog';\n\nexport type DocFacts = {\n name: string;\n today: string;\n nisc: string;\n parts: readonly Part[];\n // The sections items add to AGENTS.md, each from its own agents-section.md.\n agents: readonly string[];\n};\n\nconst all = <K extends 'is' | 'where' | 'runs' | 'decisions' | 'answered' | 'open' | 'order'>(parts: readonly Part[], key: K): string[] =>\n parts.flatMap((part) => {\n const value = part.docs?.[key];\n return value === undefined ? [] : typeof value === 'string' ? [value] : [...value];\n });\n\nconst decisionNumber = (row: string): number => Number(/^\\| D(\\d+) /.exec(row)?.[1] ?? Number.POSITIVE_INFINITY);\n\nconst sections = (texts: readonly string[]): string => texts.map((text) => `\\n${text.trim()}\\n`).join('');\n\nexport const agentsDoc = (facts: DocFacts): string => {\n const [first = 'a nisc application', ...rest] = all(facts.parts, 'is');\n return `# ${facts.name}\n\nA nisc application. **The rules it is built by are \\`node_modules/@niscorp/nisc/AGENTS.md\\`** — read all of it before changing anything here (it is there once the app's dependencies are installed). It is the rulebook for the nisc version this app has installed, and \\`STYLE_GUIDE.md\\` sits beside it. The grammars it names — a layout node, an \\`ActionDefinition\\`, a Prism config, a charter, a Vex DSL — are in each package's own \\`README.md\\` and \\`DESIGN.md\\`, under \\`node_modules/@niscorp/<name>/\\`.\n\nWhat is particular to this app:\n\n- **Its decisions are in PLAN.md.** What was answered when it was made, what was derived, and what is still open. An open decision point is asked before anything is built on it, never resolved silently.\n- **It is ${first}**${rest.map((clause) => `, ${clause}`).join('')}.\n- **Where things go:**\n\n\\`\\`\\`\n${all(facts.parts, 'where').join('\\n')}\n\\`\\`\\`\n\n- **How it runs:** ${all(facts.parts, 'runs').join(', ')} — all of them the \\`nisc\\` command — and \\`npm run strata status\\` for the grammars.\n- **How it is reviewed:** by the \\`nisc-reviewer\\` agent (\\`.claude/agents/nisc-reviewer.md\\`), which follows \\`node_modules/@niscorp/nisc/REVIEW.md\\` — after each step of PLAN.md's order of work, not only at the end. \\`npm run check\\` passing says the app does what it should; a review says it is still built the nisc way.\n${sections(facts.agents)}`;\n};\n\nexport const planDoc = (facts: DocFacts): string => `# PLAN — ${facts.name}\n\nMade ${facts.today} by \\`npm create nisc\\`, on nisc ${facts.nisc}. This is the record AGENTS.md's interview asks for (\"Before any code\"). The walkthrough asked what shapes the files; everything else is **open**, and an open decision blocks the build that depends on it until it is answered by the user or delegated by name. A blanket \"go\" delegates nothing.\n\n## Decision points\n\n| | Tier | |\n|---|---|---|\n${all(facts.parts, 'decisions')\n .sort((a, b) => decisionNumber(a) - decisionNumber(b))\n .join('\\n')}\n\n## Answered when it was made\n\n${all(facts.parts, 'answered')\n .map((line) => `- ${line}`)\n .join('\\n')}\n\n## The dial-in — open\n\n${all(facts.parts, 'open')\n .map((line) => `- ${line}`)\n .join('\\n')}\n\n## Order of work\n\n${all(facts.parts, 'order')\n .map((line, at) => `${at + 1}. ${line}`)\n .join('\\n')}\n`;\n\nexport const gitignoreLines = ['node_modules/', 'dist/', 'out/', '.strata/', '*.tsbuildinfo', '.env', '.env.*', '!.env.example'];\n","import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';\nimport { dirname, extname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { envOf, isChoice, itemsOf, partsOf, readCatalog } from './catalog';\nimport type { EnvKey, EnvSpec, Item, Part, Picks } from './catalog';\nimport { agentsDoc, gitignoreLines, planDoc } from './docs';\n\nexport type CreateOptions = {\n dir: string;\n name: string;\n picks: Picks;\n // The values given for the keys the items ask for, by variable name. A key left out is written empty.\n env?: Readonly<Record<string, string>>;\n versions: Readonly<Record<string, string>>;\n // Depend on the nisc packages of the workspace the app is made in, for an app inside the nisc repository.\n workspace?: boolean;\n // YYYY-MM-DD\n today: string;\n templates?: string;\n};\n\nexport type Created = {\n files: string[];\n kept: string[];\n extended: string[];\n};\n\nexport const TEMPLATES = fileURLToPath(new URL('../templates', import.meta.url));\n\nconst TOKEN = 'nisc-template-app';\nconst SKIP = new Set(['node_modules', 'dist', 'out', '.turbo']);\nconst TEXT = new Set(['.ts', '.tsx', '.json', '.html', '.css', '.md']);\nconst KEEP_THEIRS = new Set(['README.md']);\nconst DEPENDENCIES = ['dependencies', 'devDependencies'] as const;\n\n// npm's rule for a package name.\nexport const validName = (name: string): boolean => /^[a-z0-9][a-z0-9._-]*$/.test(name) && name.length <= 214;\n\nconst filesIn = (dir: string, base = ''): string[] =>\n existsSync(join(dir, base))\n ? readdirSync(join(dir, base), { withFileTypes: true }).flatMap((entry) => {\n if (SKIP.has(entry.name)) return [];\n const rel = base === '' ? entry.name : `${base}/${entry.name}`;\n return entry.isDirectory() ? filesIn(dir, rel) : [rel];\n })\n : [];\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === 'object' && !Array.isArray(value);\n\n// An item's files, then its files for each other item the app is made of (`with/<other>/`).\nconst sourcesOf = (root: string, items: readonly Item[]): Map<string, { item: string; from: string }> => {\n const ids = new Set(items.map((item) => item.id));\n const sources = new Map<string, { item: string; from: string }>();\n for (const item of items) {\n const withDir = join(root, item.id, 'with');\n const others = existsSync(withDir) ? readdirSync(withDir) : [];\n for (const other of others) if (!existsSync(join(root, other, 'item.json'))) throw new Error(`create-nisc: ${item.id}/with/${other} is for \"${other}\", which is no item`);\n const dirs = [join(root, item.id, 'files'), ...others.filter((other) => ids.has(other)).map((other) => join(withDir, other))];\n for (const dir of dirs) {\n for (const rel of filesIn(dir)) {\n const there = sources.get(rel);\n if (there !== undefined) throw new Error(`create-nisc: ${rel} is written by both \"${there.item}\" and \"${item.id}\"`);\n sources.set(rel, { item: item.id, from: join(dir, rel) });\n }\n }\n }\n return sources;\n};\n\nconst pin = (name: string, spec: string, options: CreateOptions): string => {\n if (!spec.startsWith('workspace:') || options.workspace === true) return spec;\n const version = options.versions[name];\n if (version === undefined) throw new Error(`create-nisc: the nisc release has no ${name} — the set it was given is incomplete`);\n return `^${version}`;\n};\n\n// The parts' package fragments as one manifest: fields in the order they come, then the scripts, then the\n// dependencies sorted. Two parts that disagree about one field, script or dependency is a mistake in the templates.\nconst manifestOf = (parts: readonly Part[], options: CreateOptions): Record<string, unknown> => {\n const fields: Record<string, unknown> = {};\n const scripts: Record<string, string> = {};\n const deps: Record<(typeof DEPENDENCIES)[number], Record<string, string>> = { dependencies: {}, devDependencies: {} };\n const agree = (where: string, key: string, have: unknown, value: unknown): void => {\n if (have !== undefined && JSON.stringify(have) !== JSON.stringify(value)) throw new Error(`create-nisc: two items disagree about ${where} \"${key}\"`);\n };\n for (const fragment of parts.map((part) => part.package ?? {})) {\n for (const [key, value] of Object.entries(fragment)) {\n if (key === 'scripts' || key === 'dependencies' || key === 'devDependencies') {\n if (!isRecord(value)) throw new Error(`create-nisc: a package fragment's ${key} is not an object`);\n const into = key === 'scripts' ? scripts : deps[key];\n for (const [name, spec] of Object.entries(value)) {\n if (typeof spec !== 'string') throw new Error(`create-nisc: ${name} in ${key} is not a string`);\n agree(key, name, into[name], spec);\n into[name] = spec;\n }\n } else {\n agree('the package field', key, fields[key], value);\n fields[key] = value;\n }\n }\n }\n const sorted = (from: Record<string, string>): Record<string, string> =>\n Object.fromEntries(\n Object.keys(from)\n .sort()\n .map((name) => [name, pin(name, from[name] ?? '', options)]),\n );\n return {\n name: options.name,\n ...fields,\n ...(Object.keys(scripts).length > 0 ? { scripts } : {}),\n dependencies: sorted(deps.dependencies),\n devDependencies: sorted(deps.devDependencies),\n };\n};\n\nconst envValue = (name: string, options: CreateOptions): string => {\n const value = (options.env?.[name] ?? '').trim();\n if (/\\s/.test(value)) throw new Error(`create-nisc: the value given for ${name} has a space or a line break in it`);\n return value;\n};\n\n// `.env` with the values given, `.env.example` with the names alone. A choice keeps its value in both: it is not a\n// secret, and it says which keys follow.\nconst envFiles = (specs: readonly EnvSpec[], options: CreateOptions): { env: string; example: string; assigned: string[] } => {\n const env: string[] = [];\n const example: string[] = [];\n const assigned: string[] = [];\n const key = (spec: EnvKey): void => {\n const comment = `# ${spec.message}${spec.required === true ? ' (required)' : ''}`;\n const line = `${spec.name}=${envValue(spec.name, options)}`;\n env.push(comment, line);\n example.push(comment, `${spec.name}=`);\n assigned.push(line);\n };\n for (const spec of specs) {\n if (!isChoice(spec)) {\n key(spec);\n continue;\n }\n const value = envValue(spec.choose, options) || (spec.options[0]?.value ?? '');\n const option = spec.options.find((candidate) => candidate.value === value);\n if (option === undefined) throw new Error(`create-nisc: ${spec.choose} is one of ${spec.options.map((candidate) => candidate.value).join(', ')} — not \"${value}\"`);\n const comment = `# ${spec.message} (${spec.options.map((candidate) => candidate.value).join(' | ')})`;\n env.push(comment, `${spec.choose}=${value}`);\n example.push(comment, `${spec.choose}=${value}`);\n assigned.push(`${spec.choose}=${value}`);\n for (const inner of option.keys ?? []) key(inner);\n }\n return { env: `${env.join('\\n')}\\n`, example: `${example.join('\\n')}\\n`, assigned };\n};\n\nexport const generate = (options: CreateOptions): Created => {\n const catalog = readCatalog(options.templates ?? TEMPLATES);\n const items = itemsOf(catalog, options.picks);\n const parts = partsOf(items);\n if (!validName(options.name)) throw new Error(`create-nisc: \"${options.name}\" is not a package name (lowercase letters, digits, - . _)`);\n if (existsSync(options.dir) && !statSync(options.dir).isDirectory()) throw new Error(`create-nisc: ${options.dir} is a file`);\n\n const planned = new Map<string, string | Buffer>();\n for (const [rel, { from }] of sourcesOf(catalog.root, items)) {\n planned.set(rel, TEXT.has(extname(rel)) ? readFileSync(from, 'utf8').split(TOKEN).join(options.name) : readFileSync(from));\n }\n planned.set('package.json', `${JSON.stringify(manifestOf(parts, options), null, 2)}\\n`);\n\n const sections = items.flatMap((item) => {\n const path = join(catalog.root, item.id, 'agents-section.md');\n return existsSync(path) ? [readFileSync(path, 'utf8').split(TOKEN).join(options.name)] : [];\n });\n const facts = { name: options.name, today: options.today, nisc: options.versions['@niscorp/nisc'] ?? 'unknown', parts, agents: sections };\n planned.set('AGENTS.md', agentsDoc(facts));\n planned.set('PLAN.md', planDoc(facts));\n\n const specs = envOf(items);\n const envs = specs.length > 0 ? envFiles(specs, options) : undefined;\n if (envs !== undefined) planned.set('.env.example', envs.example);\n\n const there = (rel: string): boolean => existsSync(join(options.dir, rel));\n const kept = [...planned.keys()].filter((rel) => KEEP_THEIRS.has(rel) && there(rel));\n const collisions = [...planned.keys()].filter((rel) => !KEEP_THEIRS.has(rel) && there(rel)).sort();\n if (collisions.length > 0) {\n throw new Error(\n `create-nisc: ${options.dir} already has ${collisions.length === 1 ? 'a file' : 'files'} a new app would write — nothing was written:\\n ${collisions.join('\\n ')}\\nMake the app in an empty folder, or in a subfolder of this one.`,\n );\n }\n for (const rel of kept) planned.delete(rel);\n\n // A .gitignore or .env that is there is added to, never replaced: what it holds is theirs.\n const extended: string[] = [];\n const addTo = (rel: string, fresh: string, lines: readonly string[], has: (line: string, theirs: ReadonlySet<string>) => boolean): void => {\n const path = join(options.dir, rel);\n if (!existsSync(path)) {\n planned.set(rel, fresh);\n return;\n }\n const theirs = readFileSync(path, 'utf8');\n const have = new Set(theirs.split('\\n').map((line) => line.trim()));\n const missing = lines.filter((line) => !has(line, have));\n if (missing.length === 0) return;\n planned.set(rel, `${theirs.replace(/\\n*$/, '\\n')}${missing.join('\\n')}\\n`);\n extended.push(rel);\n };\n addTo('.gitignore', `${gitignoreLines.join('\\n')}\\n`, gitignoreLines, (line, have) => have.has(line));\n if (envs !== undefined) {\n const named = (line: string): string => line.slice(0, line.indexOf('=') + 1);\n addTo('.env', envs.env, envs.assigned, (line, have) => [...have].some((theirs) => theirs.startsWith(named(line))));\n }\n\n for (const [rel, content] of planned) {\n const to = join(options.dir, rel);\n mkdirSync(dirname(to), { recursive: true });\n writeFileSync(to, content);\n }\n return { files: [...planned.keys()].filter((rel) => !extended.includes(rel)).sort(), kept, extended };\n};\n","// Written in when this package is built (tsup.config.ts), never looked up:\n// \"whatever is newest on npm\" would be a set nobody tested the templates with.\ndeclare const __NISC_SET__: Readonly<Record<string, string>> | undefined;\n\nexport const testedSet = (): Readonly<Record<string, string>> => {\n if (typeof __NISC_SET__ === 'undefined') throw new Error('create-nisc: this copy was not built — it carries no nisc release to pin a new app to');\n return __NISC_SET__;\n};\n"]}