create-nisc 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +72 -0
- package/bin/create-nisc.js +5 -0
- package/dist/chunk-A4727PE2.js +174 -0
- package/dist/chunk-A4727PE2.js.map +1 -0
- package/dist/chunk-TEYNNEJA.js +173 -0
- package/dist/chunk-TEYNNEJA.js.map +1 -0
- package/dist/cli.js +113 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
- package/templates/moss-dom/.turbo/turbo-build.log +32 -0
- package/templates/moss-dom/.turbo/turbo-test.log +15 -0
- package/templates/moss-dom/.turbo/turbo-typecheck.log +4 -0
- package/templates/moss-dom/README.md +15 -0
- package/templates/moss-dom/index.html +12 -0
- package/templates/moss-dom/nisc.config.ts +19 -0
- package/templates/moss-dom/package.json +39 -0
- package/templates/moss-dom/src/app/action-catalog.ts +8 -0
- package/templates/moss-dom/src/app/actions/surfaces/welcome.action.ts +13 -0
- package/templates/moss-dom/src/app/actions/surfaces/welcome.layout.ts +27 -0
- package/templates/moss-dom/src/app/app.ts +10 -0
- package/templates/moss-dom/src/app/charter/assignments.ts +3 -0
- package/templates/moss-dom/src/app/charter/charter.ts +8 -0
- package/templates/moss-dom/src/app/shell/frame.layout.ts +5 -0
- package/templates/moss-dom/src/app/shell/shell.ts +10 -0
- package/templates/moss-dom/src/dev/all-checks.ts +20 -0
- package/templates/moss-dom/src/dev/artifacts-check.ts +56 -0
- package/templates/moss-dom/src/dev/strata.ts +28 -0
- package/templates/moss-dom/src/dev/welcome-check.ts +43 -0
- package/templates/moss-dom/src/main.ts +22 -0
- package/templates/moss-dom/src/server/boot.ts +9 -0
- package/templates/moss-dom/src/server/document.ts +15 -0
- package/templates/moss-dom/src/server/runtime.ts +21 -0
- package/templates/moss-dom/src/ui/kit.css +42 -0
- package/templates/moss-dom/src/ui/kit.ts +41 -0
- package/templates/moss-dom/src/ui/registry.ts +16 -0
- package/templates/moss-dom/strata.lock.json +6 -0
- package/templates/moss-dom/tsconfig.json +27 -0
- package/templates/moss-dom/vite.config.ts +8 -0
- package/templates/moss-react/.turbo/turbo-build.log +32 -0
- package/templates/moss-react/.turbo/turbo-test.log +15 -0
- package/templates/moss-react/.turbo/turbo-typecheck.log +4 -0
- package/templates/moss-react/README.md +15 -0
- package/templates/moss-react/index.html +12 -0
- package/templates/moss-react/nisc.config.ts +19 -0
- package/templates/moss-react/package.json +42 -0
- package/templates/moss-react/src/app/action-catalog.ts +8 -0
- package/templates/moss-react/src/app/actions/surfaces/welcome.action.ts +13 -0
- package/templates/moss-react/src/app/actions/surfaces/welcome.layout.ts +27 -0
- package/templates/moss-react/src/app/app.ts +10 -0
- package/templates/moss-react/src/app/charter/assignments.ts +3 -0
- package/templates/moss-react/src/app/charter/charter.ts +8 -0
- package/templates/moss-react/src/app/shell/frame.layout.ts +5 -0
- package/templates/moss-react/src/app/shell/shell.ts +10 -0
- package/templates/moss-react/src/dev/all-checks.ts +20 -0
- package/templates/moss-react/src/dev/artifacts-check.ts +56 -0
- package/templates/moss-react/src/dev/strata.ts +28 -0
- package/templates/moss-react/src/dev/welcome-check.ts +43 -0
- package/templates/moss-react/src/main.tsx +20 -0
- package/templates/moss-react/src/server/boot.ts +9 -0
- package/templates/moss-react/src/server/document.ts +12 -0
- package/templates/moss-react/src/server/runtime.ts +21 -0
- package/templates/moss-react/src/ui/kit.css +42 -0
- package/templates/moss-react/src/ui/kit.tsx +49 -0
- package/templates/moss-react/src/ui/registry.ts +14 -0
- package/templates/moss-react/strata.lock.json +6 -0
- package/templates/moss-react/tsconfig.json +17 -0
- package/templates/moss-react/vite.config.ts +11 -0
- package/templates/shell-dom/.turbo/turbo-build.log +31 -0
- package/templates/shell-dom/.turbo/turbo-test.log +12 -0
- package/templates/shell-dom/.turbo/turbo-typecheck.log +4 -0
- package/templates/shell-dom/README.md +16 -0
- package/templates/shell-dom/index.html +12 -0
- package/templates/shell-dom/nisc.config.ts +19 -0
- package/templates/shell-dom/package.json +35 -0
- package/templates/shell-dom/src/app/action-catalog.ts +8 -0
- package/templates/shell-dom/src/app/actions/surfaces/welcome.action.ts +12 -0
- package/templates/shell-dom/src/app/actions/surfaces/welcome.layout.ts +27 -0
- package/templates/shell-dom/src/app/shell/frame.layout.ts +5 -0
- package/templates/shell-dom/src/app/shell/shell.ts +10 -0
- package/templates/shell-dom/src/boot.ts +18 -0
- package/templates/shell-dom/src/dev/all-checks.ts +20 -0
- package/templates/shell-dom/src/dev/artifacts-check.ts +52 -0
- package/templates/shell-dom/src/dev/strata.ts +28 -0
- package/templates/shell-dom/src/dev/welcome-check.ts +26 -0
- package/templates/shell-dom/src/main.ts +14 -0
- package/templates/shell-dom/src/ui/kit.css +42 -0
- package/templates/shell-dom/src/ui/kit.ts +41 -0
- package/templates/shell-dom/src/ui/registry.ts +16 -0
- package/templates/shell-dom/src/ui/screen.ts +16 -0
- package/templates/shell-dom/strata.lock.json +6 -0
- package/templates/shell-dom/tsconfig.json +27 -0
- package/templates/shell-dom/vite.config.ts +6 -0
- package/templates/shell-react/.turbo/turbo-build.log +31 -0
- package/templates/shell-react/.turbo/turbo-test.log +12 -0
- package/templates/shell-react/.turbo/turbo-typecheck.log +4 -0
- package/templates/shell-react/README.md +16 -0
- package/templates/shell-react/index.html +12 -0
- package/templates/shell-react/nisc.config.ts +19 -0
- package/templates/shell-react/package.json +40 -0
- package/templates/shell-react/src/app/action-catalog.ts +8 -0
- package/templates/shell-react/src/app/actions/surfaces/welcome.action.ts +12 -0
- package/templates/shell-react/src/app/actions/surfaces/welcome.layout.ts +27 -0
- package/templates/shell-react/src/app/shell/frame.layout.ts +5 -0
- package/templates/shell-react/src/app/shell/shell.ts +10 -0
- package/templates/shell-react/src/boot.ts +18 -0
- package/templates/shell-react/src/dev/all-checks.ts +20 -0
- package/templates/shell-react/src/dev/artifacts-check.ts +52 -0
- package/templates/shell-react/src/dev/strata.ts +28 -0
- package/templates/shell-react/src/dev/welcome-check.ts +26 -0
- package/templates/shell-react/src/main.tsx +25 -0
- package/templates/shell-react/src/ui/kit.css +42 -0
- package/templates/shell-react/src/ui/kit.tsx +49 -0
- package/templates/shell-react/src/ui/registry.ts +14 -0
- package/templates/shell-react/src/ui/screen.tsx +15 -0
- package/templates/shell-react/strata.lock.json +6 -0
- package/templates/shell-react/tsconfig.json +28 -0
- package/templates/shell-react/vite.config.ts +9 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { existsSync, statSync, readdirSync, mkdirSync, readFileSync, writeFileSync, cpSync } from 'fs';
|
|
2
|
+
import { join, extname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
// src/generate.ts
|
|
6
|
+
|
|
7
|
+
// src/docs.ts
|
|
8
|
+
var uiName = (ui) => ui === "react" ? "React" : "plain DOM (nova\u2019s DOM adapter \u2014 no framework in the page)";
|
|
9
|
+
var layoutOf = (facts) => facts.posture === "moss" ? `src/app/ ARTIFACTS ONLY \u2014 the manifest (app.ts), the charter, the actions, the shell
|
|
10
|
+
src/server/ the environment (runtime.ts), the boot, how a screen is drawn (document.ts)
|
|
11
|
+
src/ui/ the kit \u2014 the only renderer code, with ${facts.ui === "react" ? "src/main.tsx" : "src/main.ts"}, the terminal entry
|
|
12
|
+
src/dev/ the checks (\`npm run check\`)
|
|
13
|
+
nisc.config.ts how the app boots and how a screen is drawn, for the \`nisc\` command` : `src/app/ ARTIFACTS ONLY \u2014 the actions and the shell's canvases
|
|
14
|
+
src/boot.ts the shell factory: the artifacts plus everything environmental
|
|
15
|
+
src/ui/ the kit and the screen \u2014 the only renderer code, with ${facts.ui === "react" ? "src/main.tsx" : "src/main.ts"}, the entry
|
|
16
|
+
src/dev/ the checks (\`npm run check\`)
|
|
17
|
+
nisc.config.ts how the app boots and how its screen is drawn and picked up, for the \`nisc\` command`;
|
|
18
|
+
var agentsDoc = (facts) => `# ${facts.name}
|
|
19
|
+
|
|
20
|
+
A nisc application. **The rules it is built by are \`node_modules/@niscorp/nisc/AGENTS.md\`** \u2014 read all of it before changing anything here (install first: \`npm install\`). It is the rulebook for the nisc version this app has installed, and \`STYLE_GUIDE.md\` sits beside it. The grammars it names \u2014 a layout node, an \`ActionDefinition\`, a Prism config, a charter, a Vex DSL \u2014 are in each package's own \`README.md\` and \`DESIGN.md\`, under \`node_modules/@niscorp/<name>/\`.
|
|
21
|
+
|
|
22
|
+
What is particular to this app:
|
|
23
|
+
|
|
24
|
+
- **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.
|
|
25
|
+
- **It is ${facts.posture === "moss" ? "behind moss" : "its own shell"}**, drawn with ${uiName(facts.ui)}.
|
|
26
|
+
- **Where things go:**
|
|
27
|
+
|
|
28
|
+
\`\`\`
|
|
29
|
+
${layoutOf(facts)}
|
|
30
|
+
\`\`\`
|
|
31
|
+
|
|
32
|
+
- **How it runs:** \`npm run dev\`, \`npm run build\`, \`npm run check\`${facts.posture === "page" ? ", `npm run export`" : ", `npm start`"} \u2014 all of them the \`nisc\` command.
|
|
33
|
+
`;
|
|
34
|
+
var d1 = (posture) => posture === "moss" ? `| D1 Posture | answered | **A moss server app.** The shell runs on the server, one per person; the browser is a canvas terminal over a socket. The charter is enforced there, and data never leaves the server except as the screens a principal is granted. |` : `| D1 Posture | answered | **Its own shell, in the page \u2014 no server.** The shell, its actions and its endpoints run in the browser. Consequence, said plainly: **the charter is not enforcement here.** Whatever data and policy the page has, its user has; nothing in this posture is a security boundary. An app that needs one needs a server \u2014 moss. |`;
|
|
35
|
+
var d2 = (posture) => posture === "moss" ? `| D2 Environment | derived \xB7 **open for deployment** | Development and the checks run on PGlite, an in-memory Postgres that starts empty every boot (\`src/server/runtime.ts\`). Open: the Postgres a deployment hands it, and where it runs. |` : `| D2 Environment | **open** | The app has no data yet. Open: what serves its endpoints \u2014 in-memory fixtures, PGlite in the page (your data lives in one browser profile: no sync, no other devices, gone if site data is cleared), a real backend, or a mix. |`;
|
|
36
|
+
var d5 = (posture) => posture === "moss" ? `| D5 Routing | derived \xB7 **partly open** | The first screen is drawn on the server and adopted by the terminal \u2014 it costs nothing while nobody can sign in. Open: once sign-in exists, the wire keeps a cookie copy of the session token so a page can be drawn for the person asking (AGENTS.md rule 12), and a page drawn for somebody is theirs alone (\`private, no-store\`). Open: which paths are **pages** rather than the app, and whether the app's shell state syncs to the address bar. |` : `| D5 Routing | derived \xB7 **partly open** | The first screen is drawn at build (\`nisc export\`) \u2014 one file per path, the screen as nobody in particular sees it \u2014 and the page's own shell picks it up. Open: which paths exist beyond \`/\`, and whether shell state syncs to the address bar. |`;
|
|
37
|
+
var planDoc = (facts) => `# PLAN \u2014 ${facts.name}
|
|
38
|
+
|
|
39
|
+
Made ${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.
|
|
40
|
+
|
|
41
|
+
## Decision points
|
|
42
|
+
|
|
43
|
+
| | Tier | |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
${d1(facts.posture)}
|
|
46
|
+
${d2(facts.posture)}
|
|
47
|
+
| D3 Reads | **open** | Vex entries (\`{ fingerprint, context }\`, the shape an AI feature can reach later) or plain endpoints with hand-written handlers. |
|
|
48
|
+
| D4 Writes | **open** | Vex mutation entries or plain endpoint handlers. Either way a write is an endpoint, never inline. |
|
|
49
|
+
${d5(facts.posture)}
|
|
50
|
+
|
|
51
|
+
## Answered when it was made
|
|
52
|
+
|
|
53
|
+
- **What draws the screen:** ${uiName(facts.ui)}. The kit in \`src/ui/\` is where the look lives; a layout names components, never styles.
|
|
54
|
+
|
|
55
|
+
## The dial-in \u2014 open
|
|
56
|
+
|
|
57
|
+
- The entities, and how they relate.
|
|
58
|
+
- Expected scale.
|
|
59
|
+
- Who uses it: one person, or roles. More than one principal sketches its roles and charter now, not later.
|
|
60
|
+
- AI features: now, later, never. (Later still shapes D3.)
|
|
61
|
+
- Look and feel.
|
|
62
|
+
- Where it is deployed.
|
|
63
|
+
- What happens to the data long-term.
|
|
64
|
+
|
|
65
|
+
## Order of work
|
|
66
|
+
|
|
67
|
+
1. **The interview** \u2014 every open item above, answered or delegated by name. \u2190 here
|
|
68
|
+
2. **Scaffold** \u2014 done: ${facts.posture === "moss" ? "manifest, runtime and terminal" : "the shell factory and the entry"}, one action rendering, a check.
|
|
69
|
+
3. **Kit** \u2014 the primitives, against a kitchen-sink action; lock the look before any feature.
|
|
70
|
+
4. **Data layer** \u2014 per D2/D3: schema, seed, entries; one read end to end.
|
|
71
|
+
5. **Actions** \u2014 domain by domain: list \u2192 detail \u2192 form.
|
|
72
|
+
6. **Writes** \u2014 per D4; one round trip: create \u2192 announce \u2192 re-read.
|
|
73
|
+
7. **Checks and polish** \u2014 a check per feature in \`src/dev/\`; empty states and transitions last.
|
|
74
|
+
`;
|
|
75
|
+
var gitignore = `node_modules/
|
|
76
|
+
dist/
|
|
77
|
+
out/
|
|
78
|
+
*.tsbuildinfo
|
|
79
|
+
.env
|
|
80
|
+
.env.*
|
|
81
|
+
!.env.example
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
// src/generate.ts
|
|
85
|
+
var TEMPLATES = fileURLToPath(new URL("../templates", import.meta.url));
|
|
86
|
+
var templateOf = (posture, ui) => `${posture === "moss" ? "moss" : "shell"}-${ui}`;
|
|
87
|
+
var tokenOf = (template) => `nisc-template-${template}`;
|
|
88
|
+
var SKIP = /* @__PURE__ */ new Set(["node_modules", "dist", "out", ".turbo"]);
|
|
89
|
+
var TEXT = /* @__PURE__ */ new Set([".ts", ".tsx", ".json", ".html", ".css", ".md"]);
|
|
90
|
+
var validName = (name) => /^[a-z0-9][a-z0-9._-]*$/.test(name) && name.length <= 214;
|
|
91
|
+
var filesIn = (dir, base = "") => readdirSync(join(dir, base), { withFileTypes: true }).flatMap((entry) => {
|
|
92
|
+
if (SKIP.has(entry.name)) return [];
|
|
93
|
+
const rel = base === "" ? entry.name : `${base}/${entry.name}`;
|
|
94
|
+
return entry.isDirectory() ? filesIn(dir, rel) : [rel];
|
|
95
|
+
});
|
|
96
|
+
var isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
97
|
+
var pinned = (deps, versions) => {
|
|
98
|
+
if (!isRecord(deps)) return {};
|
|
99
|
+
return Object.fromEntries(
|
|
100
|
+
Object.entries(deps).map(([name, spec]) => {
|
|
101
|
+
if (typeof spec !== "string") throw new Error(`create-nisc: ${name} has no version in the template`);
|
|
102
|
+
if (!spec.startsWith("workspace:")) return [name, spec];
|
|
103
|
+
const version = versions[name];
|
|
104
|
+
if (version === void 0) throw new Error(`create-nisc: the nisc release has no ${name} \u2014 the set it was given is incomplete`);
|
|
105
|
+
return [name, `^${version}`];
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
var generate = (options) => {
|
|
110
|
+
const template = templateOf(options.posture, options.ui);
|
|
111
|
+
const source = join(TEMPLATES, template);
|
|
112
|
+
if (!existsSync(source)) throw new Error(`create-nisc: no template "${template}"`);
|
|
113
|
+
if (!validName(options.name)) throw new Error(`create-nisc: "${options.name}" is not a package name (lowercase letters, digits, - . _)`);
|
|
114
|
+
if (existsSync(options.dir) && (!statSync(options.dir).isDirectory() || readdirSync(options.dir).length > 0)) {
|
|
115
|
+
throw new Error(`create-nisc: ${options.dir} already exists and is not empty`);
|
|
116
|
+
}
|
|
117
|
+
mkdirSync(options.dir, { recursive: true });
|
|
118
|
+
const token = tokenOf(template);
|
|
119
|
+
const written = [];
|
|
120
|
+
for (const rel of filesIn(source)) {
|
|
121
|
+
const from = join(source, rel);
|
|
122
|
+
const to = join(options.dir, rel);
|
|
123
|
+
mkdirSync(join(to, ".."), { recursive: true });
|
|
124
|
+
if (rel === "package.json") {
|
|
125
|
+
const manifest = JSON.parse(readFileSync(from, "utf8"));
|
|
126
|
+
if (!isRecord(manifest)) throw new Error(`create-nisc: ${template}/package.json is not an object`);
|
|
127
|
+
const app = {
|
|
128
|
+
...manifest,
|
|
129
|
+
name: options.name,
|
|
130
|
+
dependencies: pinned(manifest["dependencies"], options.versions),
|
|
131
|
+
devDependencies: pinned(manifest["devDependencies"], options.versions)
|
|
132
|
+
};
|
|
133
|
+
writeFileSync(to, `${JSON.stringify(app, null, 2)}
|
|
134
|
+
`);
|
|
135
|
+
} else if (TEXT.has(extname(rel))) {
|
|
136
|
+
writeFileSync(to, readFileSync(from, "utf8").split(token).join(options.name));
|
|
137
|
+
} else {
|
|
138
|
+
cpSync(from, to);
|
|
139
|
+
}
|
|
140
|
+
written.push(rel);
|
|
141
|
+
}
|
|
142
|
+
const facts = { name: options.name, posture: options.posture, ui: options.ui, today: options.today, nisc: options.versions["@niscorp/nisc"] ?? "unknown" };
|
|
143
|
+
writeFileSync(join(options.dir, "AGENTS.md"), agentsDoc(facts));
|
|
144
|
+
writeFileSync(join(options.dir, "PLAN.md"), planDoc(facts));
|
|
145
|
+
writeFileSync(join(options.dir, ".gitignore"), gitignore);
|
|
146
|
+
return [...written, "AGENTS.md", "PLAN.md", ".gitignore"].sort();
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// src/versions.ts
|
|
150
|
+
var isRecord2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
151
|
+
var releasedSet = async (registry) => {
|
|
152
|
+
const url = `${registry.replace(/\/$/, "")}/@niscorp%2fnisc/latest`;
|
|
153
|
+
let response;
|
|
154
|
+
try {
|
|
155
|
+
response = await fetch(url, { headers: { accept: "application/json" } });
|
|
156
|
+
} catch (error) {
|
|
157
|
+
throw new Error(`create-nisc: could not reach ${registry} to ask which nisc release is current (${error instanceof Error ? error.message : String(error)})`);
|
|
158
|
+
}
|
|
159
|
+
if (!response.ok) throw new Error(`create-nisc: ${url} answered ${response.status}`);
|
|
160
|
+
const manifest = await response.json();
|
|
161
|
+
if (!isRecord2(manifest) || typeof manifest["version"] !== "string" || !isRecord2(manifest["dependencies"])) {
|
|
162
|
+
throw new Error(`create-nisc: ${url} is not a package manifest`);
|
|
163
|
+
}
|
|
164
|
+
const set = { "@niscorp/nisc": manifest["version"] };
|
|
165
|
+
for (const [name, version] of Object.entries(manifest["dependencies"])) {
|
|
166
|
+
if (typeof version === "string") set[name] = version.replace(/^[\^~=]/, "");
|
|
167
|
+
}
|
|
168
|
+
return set;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export { TEMPLATES, generate, releasedSet, templateOf, validName };
|
|
172
|
+
//# sourceMappingURL=chunk-TEYNNEJA.js.map
|
|
173
|
+
//# sourceMappingURL=chunk-TEYNNEJA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/docs.ts","../src/generate.ts","../src/versions.ts"],"names":["isRecord"],"mappings":";;;;;;;AAkBA,IAAM,MAAA,GAAS,CAAC,EAAA,KAAoB,EAAA,KAAO,UAAU,OAAA,GAAU,qEAAA;AAE/D,IAAM,QAAA,GAAW,CAAC,KAAA,KAChB,KAAA,CAAM,YAAY,MAAA,GACd,CAAA;AAAA;AAAA,4DAAA,EAEmD,KAAA,CAAM,EAAA,KAAO,OAAA,GAAU,cAAA,GAAiB,aAAa,CAAA;AAAA;AAAA,qFAAA,CAAA,GAGxG,CAAA;AAAA;AAAA,2EAAA,EAEkE,KAAA,CAAM,EAAA,KAAO,OAAA,GAAU,cAAA,GAAiB,aAAa,CAAA;AAAA;AAAA,qGAAA,CAAA;AAItH,IAAM,SAAA,GAAY,CAAC,KAAA,KAAyB,CAAA,EAAA,EAAK,MAAM,IAAI;;AAAA;;AAAA;;AAAA;AAAA,UAAA,EAOtD,KAAA,CAAM,YAAY,MAAA,GAAS,aAAA,GAAgB,eAAe,CAAA,eAAA,EAAkB,MAAA,CAAO,KAAA,CAAM,EAAE,CAAC,CAAA;AAAA;;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,CAAQ,SAAA,EAAW,EAAE,CAAA;AAAA,EAC5E;AACA,EAAA,OAAO,GAAA;AACT","file":"chunk-TEYNNEJA.js","sourcesContent":["import type { Posture, Ui } from './generate';\n\n// ═══════════════════════════════════════════════════════════════\n// The two documents only a new app has.\n//\n// AGENTS.md says where the rules are — the installed @niscorp/nisc carries\n// them, for the version installed — and what is particular to this app. It\n// does not restate a rule: a copy would be frozen at the version it was made\n// with, and the rules move with releases.\n//\n// PLAN.md is the interview's record (AGENTS.md, \"Before any code\"). The\n// walkthrough asks what shapes the files; everything else is written down as\n// OPEN, and an open decision point blocks the build until it is answered or\n// delegated by name.\n// ═══════════════════════════════════════════════════════════════\n\ntype Facts = { name: string; posture: Posture; ui: Ui; today: string; nisc: string };\n\nconst uiName = (ui: Ui): string => (ui === 'react' ? 'React' : 'plain DOM (nova’s DOM adapter — no framework in the page)');\n\nconst layoutOf = (facts: Facts): string =>\n facts.posture === 'moss'\n ? `src/app/ ARTIFACTS ONLY — the manifest (app.ts), the charter, the actions, the shell\nsrc/server/ the environment (runtime.ts), the boot, how a screen is drawn (document.ts)\nsrc/ui/ the kit — the only renderer code, with ${facts.ui === 'react' ? 'src/main.tsx' : 'src/main.ts'}, the terminal entry\nsrc/dev/ the checks (\\`npm run check\\`)\nnisc.config.ts how the app boots and how a screen is drawn, for the \\`nisc\\` command`\n : `src/app/ ARTIFACTS ONLY — the actions and the shell's canvases\nsrc/boot.ts the shell factory: the artifacts plus everything environmental\nsrc/ui/ the kit and the screen — the only renderer code, with ${facts.ui === 'react' ? 'src/main.tsx' : 'src/main.ts'}, the entry\nsrc/dev/ the checks (\\`npm run check\\`)\nnisc.config.ts how the app boots and how its screen is drawn and picked up, for the \\`nisc\\` command`;\n\nexport const agentsDoc = (facts: Facts): string => `# ${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 (install first: \\`npm install\\`). 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 ${facts.posture === 'moss' ? 'behind moss' : 'its own shell'}**, drawn with ${uiName(facts.ui)}.\n- **Where things go:**\n\n\\`\\`\\`\n${layoutOf(facts)}\n\\`\\`\\`\n\n- **How it runs:** \\`npm run dev\\`, \\`npm run build\\`, \\`npm run check\\`${facts.posture === 'page' ? ', `npm run export`' : ', `npm start`'} — all of them the \\`nisc\\` command.\n`;\n\nconst d1 = (posture: Posture): string =>\n posture === 'moss'\n ? `| D1 Posture | answered | **A moss server app.** The shell runs on the server, one per person; the browser is a canvas terminal over a socket. The charter is enforced there, and data never leaves the server except as the screens a principal is granted. |`\n : `| D1 Posture | answered | **Its own shell, in the page — no server.** The shell, its actions and its endpoints run in the browser. Consequence, said plainly: **the charter is not enforcement here.** Whatever data and policy the page has, its user has; nothing in this posture is a security boundary. An app that needs one needs a server — moss. |`;\n\nconst d2 = (posture: Posture): string =>\n posture === 'moss'\n ? `| D2 Environment | derived · **open for deployment** | Development and the checks run on PGlite, an in-memory Postgres that starts empty every boot (\\`src/server/runtime.ts\\`). Open: the Postgres a deployment hands it, and where it runs. |`\n : `| D2 Environment | **open** | The app has no data yet. Open: what serves its endpoints — in-memory fixtures, PGlite in the page (your data lives in one browser profile: no sync, no other devices, gone if site data is cleared), a real backend, or a mix. |`;\n\nconst d5 = (posture: Posture): string =>\n posture === 'moss'\n ? `| D5 Routing | derived · **partly open** | The first screen is drawn on the server and adopted by the terminal — it costs nothing while nobody can sign in. Open: once sign-in exists, the wire keeps a cookie copy of the session token so a page can be drawn for the person asking (AGENTS.md rule 12), and a page drawn for somebody is theirs alone (\\`private, no-store\\`). Open: which paths are **pages** rather than the app, and whether the app's shell state syncs to the address bar. |`\n : `| D5 Routing | derived · **partly open** | The first screen is drawn at build (\\`nisc export\\`) — one file per path, the screen as nobody in particular sees it — and the page's own shell picks it up. Open: which paths exist beyond \\`/\\`, and whether shell state syncs to the address bar. |`;\n\nexport const planDoc = (facts: Facts): 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${d1(facts.posture)}\n${d2(facts.posture)}\n| D3 Reads | **open** | Vex entries (\\`{ fingerprint, context }\\`, the shape an AI feature can reach later) or plain endpoints with hand-written handlers. |\n| D4 Writes | **open** | Vex mutation entries or plain endpoint handlers. Either way a write is an endpoint, never inline. |\n${d5(facts.posture)}\n\n## Answered when it was made\n\n- **What draws the screen:** ${uiName(facts.ui)}. The kit in \\`src/ui/\\` is where the look lives; a layout names components, never styles.\n\n## The dial-in — open\n\n- The entities, and how they relate.\n- Expected scale.\n- Who uses it: one person, or roles. More than one principal sketches its roles and charter now, not later.\n- AI features: now, later, never. (Later still shapes D3.)\n- Look and feel.\n- Where it is deployed.\n- What happens to the data long-term.\n\n## Order of work\n\n1. **The interview** — every open item above, answered or delegated by name. ← here\n2. **Scaffold** — done: ${facts.posture === 'moss' ? 'manifest, runtime and terminal' : 'the shell factory and the entry'}, one action rendering, a check.\n3. **Kit** — the primitives, against a kitchen-sink action; lock the look before any feature.\n4. **Data layer** — per D2/D3: schema, seed, entries; one read end to end.\n5. **Actions** — domain by domain: list → detail → form.\n6. **Writes** — per D4; one round trip: create → announce → re-read.\n7. **Checks and polish** — a check per feature in \\`src/dev/\\`; empty states and transitions last.\n`;\n\nexport const gitignore = `node_modules/\ndist/\nout/\n*.tsbuildinfo\n.env\n.env.*\n!.env.example\n`;\n","import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';\nimport { extname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { agentsDoc, gitignore, planDoc } from './docs';\n\n// ═══════════════════════════════════════════════════════════════\n// A new app, from a template — and nothing in it that the walkthrough did not\n// decide or PLAN.md does not record.\n//\n// The templates (../templates) are real apps: members of the nisc repository's\n// workspace, typechecked, built and checked by its CI like any other. What a\n// new app gets is one of them, copied, with three things changed: its name, the\n// `workspace:^` versions turned into the published set, and the two documents\n// that only exist for a new app — PLAN.md (the decisions) and AGENTS.md (where\n// the rules are).\n// ═══════════════════════════════════════════════════════════════\n\n// Where the shell runs (D1): on a server (moss), or in the page.\nexport type Posture = 'moss' | 'page';\n// What draws the screen: React, or plain DOM.\nexport type Ui = 'react' | 'dom';\n\nexport type CreateOptions = {\n // where the app goes — must not exist, or be empty\n dir: string;\n // its package name\n name: string;\n posture: Posture;\n ui: Ui;\n // the @niscorp versions to depend on: package name → version\n versions: Readonly<Record<string, string>>;\n // the day it was made (PLAN.md), as YYYY-MM-DD\n today: string;\n};\n\nexport const TEMPLATES = fileURLToPath(new URL('../templates', import.meta.url));\n\nexport const templateOf = (posture: Posture, ui: Ui): string => `${posture === 'moss' ? 'moss' : 'shell'}-${ui}`;\n\n// The token each template is named by — its package name, and wherever the\n// name shows (the page title, the welcome screen).\nconst tokenOf = (template: string): string => `nisc-template-${template}`;\n\nconst SKIP = new Set(['node_modules', 'dist', 'out', '.turbo']);\nconst TEXT = new Set(['.ts', '.tsx', '.json', '.html', '.css', '.md']);\n\n// npm's rule for a package name, as the app's directory will mostly be named.\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 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\nconst isRecord = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === 'object' && !Array.isArray(value);\n\n// `workspace:^` → `^<the published version>`, for every dependency the\n// template takes from the workspace. A version the set does not have is a\n// broken set, not something to guess.\nconst pinned = (deps: unknown, versions: Readonly<Record<string, string>>): Record<string, string> => {\n if (!isRecord(deps)) return {};\n return Object.fromEntries(\n Object.entries(deps).map(([name, spec]): [string, string] => {\n if (typeof spec !== 'string') throw new Error(`create-nisc: ${name} has no version in the template`);\n if (!spec.startsWith('workspace:')) return [name, spec];\n const version = 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 [name, `^${version}`];\n }),\n );\n};\n\nexport const generate = (options: CreateOptions): string[] => {\n const template = templateOf(options.posture, options.ui);\n const source = join(TEMPLATES, template);\n if (!existsSync(source)) throw new Error(`create-nisc: no template \"${template}\"`);\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() || readdirSync(options.dir).length > 0)) {\n throw new Error(`create-nisc: ${options.dir} already exists and is not empty`);\n }\n mkdirSync(options.dir, { recursive: true });\n\n const token = tokenOf(template);\n const written: string[] = [];\n for (const rel of filesIn(source)) {\n const from = join(source, rel);\n const to = join(options.dir, rel);\n mkdirSync(join(to, '..'), { recursive: true });\n if (rel === 'package.json') {\n const manifest: unknown = JSON.parse(readFileSync(from, 'utf8'));\n if (!isRecord(manifest)) throw new Error(`create-nisc: ${template}/package.json is not an object`);\n const app = {\n ...manifest,\n name: options.name,\n dependencies: pinned(manifest['dependencies'], options.versions),\n devDependencies: pinned(manifest['devDependencies'], options.versions),\n };\n writeFileSync(to, `${JSON.stringify(app, null, 2)}\\n`);\n } else if (TEXT.has(extname(rel))) {\n writeFileSync(to, readFileSync(from, 'utf8').split(token).join(options.name));\n } else {\n cpSync(from, to);\n }\n written.push(rel);\n }\n\n const facts = { name: options.name, posture: options.posture, ui: options.ui, today: options.today, nisc: options.versions['@niscorp/nisc'] ?? 'unknown' };\n writeFileSync(join(options.dir, 'AGENTS.md'), agentsDoc(facts));\n writeFileSync(join(options.dir, 'PLAN.md'), planDoc(facts));\n writeFileSync(join(options.dir, '.gitignore'), gitignore);\n return [...written, 'AGENTS.md', 'PLAN.md', '.gitignore'].sort();\n};\n","// The versions a new app depends on: the set @niscorp/nisc was released with.\n//\n// That package exists to say which versions of every @niscorp package belong\n// together — its dependencies pin each one exactly — so a new app asks it,\n// rather than taking whatever is newest of each and hoping they agree.\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === 'object' && !Array.isArray(value);\n\nexport const releasedSet = async (registry: string): Promise<Record<string, string>> => {\n const url = `${registry.replace(/\\/$/, '')}/@niscorp%2fnisc/latest`;\n let response: Response;\n try {\n response = await fetch(url, { headers: { accept: 'application/json' } });\n } catch (error) {\n throw new Error(`create-nisc: could not reach ${registry} to ask which nisc release is current (${error instanceof Error ? error.message : String(error)})`);\n }\n if (!response.ok) throw new Error(`create-nisc: ${url} answered ${response.status}`);\n const manifest: unknown = await response.json();\n if (!isRecord(manifest) || typeof manifest['version'] !== 'string' || !isRecord(manifest['dependencies'])) {\n throw new Error(`create-nisc: ${url} is not a package manifest`);\n }\n const set: Record<string, string> = { '@niscorp/nisc': manifest['version'] };\n for (const [name, version] of Object.entries(manifest['dependencies'])) {\n if (typeof version === 'string') set[name] = version.replace(/^[\\^~=]/, '');\n }\n return set;\n};\n"]}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { validName, generate, testedSet } from './chunk-A4727PE2.js';
|
|
2
|
+
import { existsSync, readdirSync } from 'fs';
|
|
3
|
+
import { basename, resolve, relative } from 'path';
|
|
4
|
+
import { intro, text, confirm, cancel, select, note, outro, isCancel } from '@clack/prompts';
|
|
5
|
+
|
|
6
|
+
var USAGE = `npm create nisc [dir] [--moss | --page] [--react | --dom] [--yes]
|
|
7
|
+
|
|
8
|
+
dir where the app goes (default: my-nisc-app); its name is the folder's
|
|
9
|
+
--moss the shell runs on a server (moss) \u2014 the default
|
|
10
|
+
--page the shell runs in the page, no server (offline, static hosting)
|
|
11
|
+
--react React draws the screen \u2014 the default
|
|
12
|
+
--dom plain DOM draws the screen, no framework in the page
|
|
13
|
+
--yes take the defaults for anything not given, and ask nothing`;
|
|
14
|
+
var FLAGS = /* @__PURE__ */ new Set(["--moss", "--page", "--react", "--dom", "--yes", "--help", "-h"]);
|
|
15
|
+
var DEFAULT_DIR = "my-nisc-app";
|
|
16
|
+
var refuse = (message) => {
|
|
17
|
+
console.error(`create-nisc: ${message}
|
|
18
|
+
|
|
19
|
+
${USAGE}`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
};
|
|
22
|
+
var answered = (value) => {
|
|
23
|
+
if (typeof value === "symbol" || isCancel(value)) {
|
|
24
|
+
cancel("Nothing was made.");
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
};
|
|
29
|
+
var manager = () => {
|
|
30
|
+
const agent = process.env["npm_config_user_agent"] ?? "";
|
|
31
|
+
return ["pnpm", "yarn", "bun"].find((name) => agent.startsWith(name)) ?? "npm";
|
|
32
|
+
};
|
|
33
|
+
var main = async () => {
|
|
34
|
+
const args = process.argv.slice(2);
|
|
35
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
36
|
+
console.log(USAGE);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const flags = args.filter((arg) => arg.startsWith("-"));
|
|
40
|
+
const positional = args.filter((arg) => !arg.startsWith("-"));
|
|
41
|
+
const unknown = flags.filter((flag) => !FLAGS.has(flag));
|
|
42
|
+
if (unknown.length > 0) refuse(`unknown option ${unknown.join(", ")}`);
|
|
43
|
+
if (positional.length > 1) refuse(`one folder at a time \u2014 got ${positional.join(", ")}`);
|
|
44
|
+
if (flags.includes("--moss") && flags.includes("--page")) refuse("--moss and --page are two different apps; pick one");
|
|
45
|
+
if (flags.includes("--react") && flags.includes("--dom")) refuse("--react and --dom are two different kits; pick one");
|
|
46
|
+
const ask = process.stdout.isTTY === true && process.stdin.isTTY === true && !flags.includes("--yes");
|
|
47
|
+
if (ask) intro("a new nisc app");
|
|
48
|
+
const given = positional[0];
|
|
49
|
+
const dirInput = given ?? (ask ? answered(
|
|
50
|
+
await text({
|
|
51
|
+
message: "Where should it go?",
|
|
52
|
+
placeholder: DEFAULT_DIR,
|
|
53
|
+
defaultValue: DEFAULT_DIR,
|
|
54
|
+
validate: (value) => validName(basename(resolve(value === void 0 || value === "" ? DEFAULT_DIR : value))) ? void 0 : "the folder\u2019s name becomes the package name: lowercase letters, digits, - . _"
|
|
55
|
+
})
|
|
56
|
+
) : DEFAULT_DIR);
|
|
57
|
+
const dir = resolve(dirInput === "" ? DEFAULT_DIR : dirInput);
|
|
58
|
+
const name = basename(dir);
|
|
59
|
+
if (!validName(name)) refuse(`"${name}" cannot be a package name \u2014 the folder\u2019s name becomes it: lowercase letters, digits, - . _`);
|
|
60
|
+
const holds = existsSync(dir) ? readdirSync(dir).length : 0;
|
|
61
|
+
if (holds > 0 && ask) {
|
|
62
|
+
const proceed = answered(
|
|
63
|
+
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 })
|
|
64
|
+
);
|
|
65
|
+
if (!proceed) {
|
|
66
|
+
cancel("Nothing was made.");
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const posture = flags.includes("--page") ? "page" : flags.includes("--moss") || !ask ? "moss" : answered(
|
|
71
|
+
await select({
|
|
72
|
+
message: "Where does the shell run?",
|
|
73
|
+
options: [
|
|
74
|
+
{ value: "moss", label: "On a server \u2014 moss", hint: "one shell per person on the server; the charter is enforced there" },
|
|
75
|
+
{ value: "page", label: "In the page \u2014 no server", hint: "offline, static hosting; the charter is not a security boundary" }
|
|
76
|
+
],
|
|
77
|
+
initialValue: "moss"
|
|
78
|
+
})
|
|
79
|
+
);
|
|
80
|
+
const ui = flags.includes("--dom") ? "dom" : flags.includes("--react") || !ask ? "react" : answered(
|
|
81
|
+
await select({
|
|
82
|
+
message: "What draws the screen?",
|
|
83
|
+
options: [
|
|
84
|
+
{ value: "react", label: "React" },
|
|
85
|
+
{ value: "dom", label: "Plain DOM", hint: "no framework in the page" }
|
|
86
|
+
],
|
|
87
|
+
initialValue: "react"
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
const made = generate({ dir, name, posture, ui, versions: testedSet(), today: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10) });
|
|
91
|
+
const run = manager();
|
|
92
|
+
const where = relative(process.cwd(), dir) || ".";
|
|
93
|
+
const next = [...where === "." ? [] : [`cd ${where}`], `${run} install`, `${run} run dev`].join("\n");
|
|
94
|
+
const left = [...made.kept.map((file) => `kept your ${file}`), ...made.extended.map((file) => `added to your ${file}`)];
|
|
95
|
+
const summary = `${name} \u2014 ${posture === "moss" ? "behind moss" : "its own shell"}, ${ui === "react" ? "React" : "plain DOM"} \u2014 ${made.files.length} files${left.length > 0 ? ` (${left.join("; ")})` : ""}`;
|
|
96
|
+
const after = "Before building anything: PLAN.md \u2014 what is still open \u2014 and AGENTS.md.";
|
|
97
|
+
if (ask) {
|
|
98
|
+
note(next, "Next");
|
|
99
|
+
outro(`${summary}. ${after}`);
|
|
100
|
+
} else {
|
|
101
|
+
console.log(`create-nisc: ${summary}
|
|
102
|
+
|
|
103
|
+
${next}
|
|
104
|
+
|
|
105
|
+
${after}`);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
main().catch((error) => {
|
|
109
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
110
|
+
process.exit(1);
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=cli.js.map
|
|
113
|
+
//# sourceM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AA,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, select, text } from '@clack/prompts';\nimport { generate, validName } from './generate';\nimport type { Posture, Ui } from './generate';\nimport { testedSet } from './set';\n\n// ═══════════════════════════════════════════════════════════════\n// npm create nisc [dir] [--moss | --page] [--react | --dom] [--yes]\n//\n// Three questions — where the app goes, where its shell runs (D1), what draws\n// the screen — because those are what shape the files. Everything else the\n// rulebook's interview asks is written into the app's PLAN.md as open, for the\n// conversation that comes next. A flag answers its question; `--yes` takes the\n// defaults for the rest (moss, React); with no terminal to ask in, the flags\n// are all there is. A flag it does not know is an error, never ignored: a typo\n// must not quietly make a different app.\n// ═══════════════════════════════════════════════════════════════\n\nconst USAGE = `npm create nisc [dir] [--moss | --page] [--react | --dom] [--yes]\n\n dir where the app goes (default: my-nisc-app); its name is the folder's\n --moss the shell runs on a server (moss) — the default\n --page the shell runs in the page, no server (offline, static hosting)\n --react React draws the screen — the default\n --dom plain DOM draws the screen, no framework in the page\n --yes take the defaults for anything not given, and ask nothing`;\n\nconst FLAGS = new Set(['--moss', '--page', '--react', '--dom', '--yes', '--help', '-h']);\nconst DEFAULT_DIR = 'my-nisc-app';\n\nconst refuse = (message: string): never => {\n console.error(`create-nisc: ${message}\\n\\n${USAGE}`);\n process.exit(1);\n};\n\n// An answer, or the walkthrough was cancelled (Ctrl-C) and nothing is made.\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\n// The package manager this was run with, to say the next commands in its words.\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 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 unknown = flags.filter((flag) => !FLAGS.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 if (flags.includes('--moss') && flags.includes('--page')) refuse('--moss and --page are two different apps; pick one');\n if (flags.includes('--react') && flags.includes('--dom')) refuse('--react and --dom are two different kits; pick one');\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 // A folder that already holds something: nothing in it is overwritten (the\n // generator refuses if anything would be), but making an app in the wrong\n // place is worth one question.\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 const posture: Posture = flags.includes('--page')\n ? 'page'\n : flags.includes('--moss') || !ask\n ? 'moss'\n : answered<Posture>(\n await select<Posture>({\n message: 'Where does the shell run?',\n options: [\n { value: 'moss', label: 'On a server — moss', hint: 'one shell per person on the server; the charter is enforced there' },\n { value: 'page', label: 'In the page — no server', hint: 'offline, static hosting; the charter is not a security boundary' },\n ],\n initialValue: 'moss',\n }),\n );\n\n const ui: Ui = flags.includes('--dom')\n ? 'dom'\n : flags.includes('--react') || !ask\n ? 'react'\n : answered<Ui>(\n await select<Ui>({\n message: 'What draws the screen?',\n options: [\n { value: 'react', label: 'React' },\n { value: 'dom', label: 'Plain DOM', hint: 'no framework in the page' },\n ],\n initialValue: 'react',\n }),\n );\n\n const made = generate({ dir, name, posture, ui, versions: testedSet(), 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 summary = `${name} — ${posture === 'moss' ? 'behind moss' : 'its own shell'}, ${ui === 'react' ? 'React' : 'plain DOM'} — ${made.files.length} files${left.length > 0 ? ` (${left.join('; ')})` : ''}`;\n const after = 'Before building anything: PLAN.md — what is still open — and AGENTS.md.';\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.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type Posture = 'moss' | 'page';
|
|
2
|
+
type Ui = 'react' | 'dom';
|
|
3
|
+
type CreateOptions = {
|
|
4
|
+
dir: string;
|
|
5
|
+
name: string;
|
|
6
|
+
posture: Posture;
|
|
7
|
+
ui: Ui;
|
|
8
|
+
versions: Readonly<Record<string, string>>;
|
|
9
|
+
today: string;
|
|
10
|
+
};
|
|
11
|
+
type Created = {
|
|
12
|
+
files: string[];
|
|
13
|
+
kept: string[];
|
|
14
|
+
extended: string[];
|
|
15
|
+
};
|
|
16
|
+
declare const TEMPLATES: string;
|
|
17
|
+
declare const templateOf: (posture: Posture, ui: Ui) => string;
|
|
18
|
+
declare const validName: (name: string) => boolean;
|
|
19
|
+
declare const generate: (options: CreateOptions) => Created;
|
|
20
|
+
|
|
21
|
+
declare const testedSet: () => Readonly<Record<string, string>>;
|
|
22
|
+
|
|
23
|
+
export { type CreateOptions, type Created, type Posture, TEMPLATES, type Ui, generate, templateOf, testedSet, validName };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-nisc",
|
|
3
|
+
"version": "0.2.0",
|
|
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
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/moccadroid/niscorp.git",
|
|
9
|
+
"directory": "packages/create-nisc"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"bin": {
|
|
14
|
+
"create-nisc": "./bin/create-nisc.js"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"bin",
|
|
26
|
+
"dist",
|
|
27
|
+
"templates",
|
|
28
|
+
"!templates/*/node_modules",
|
|
29
|
+
"!templates/*/dist",
|
|
30
|
+
"!templates/*/out",
|
|
31
|
+
"*.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=22.12"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@clack/prompts": "^1.8.1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^26.6.4",
|
|
45
|
+
"tsup": "^8.5.1",
|
|
46
|
+
"typescript": "^6.0.2",
|
|
47
|
+
"vitest": "^4.1.2"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsup",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"typecheck": "tsc --noEmit -p tsconfig.test.json"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
> nisc-template-moss-dom@0.0.0 build /Users/max/Development/niscorp/.claude/worktrees/prerender/packages/create-nisc/templates/moss-dom
|
|
3
|
+
> tsc --noEmit && nisc build
|
|
4
|
+
|
|
5
|
+
vite v7.3.2 building client environment for production...
|
|
6
|
+
transforming...
|
|
7
|
+
../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/util.js (400:0): A comment
|
|
8
|
+
|
|
9
|
+
"// Wrapped in a `@__PURE__` IIFE: esbuild never tree-shakes a top-level initializer that contains a member access on `Number`, so the bare object literal survived into every bundle."
|
|
10
|
+
|
|
11
|
+
in "../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/util.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.
|
|
12
|
+
../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/regexes.js (74:0): A comment
|
|
13
|
+
|
|
14
|
+
"/** Anchors a pattern source. The interpolation lives here rather than at the call site because
|
|
15
|
+
* esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
|
|
16
|
+
* will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */"
|
|
17
|
+
|
|
18
|
+
in "../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/regexes.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.
|
|
19
|
+
✓ 138 modules transformed.
|
|
20
|
+
rendering chunks...
|
|
21
|
+
computing gzip size...
|
|
22
|
+
dist/index.html 0.41 kB │ gzip: 0.27 kB
|
|
23
|
+
dist/assets/index-DALMMv7I.css 0.74 kB │ gzip: 0.43 kB
|
|
24
|
+
dist/assets/index-BDUN-Hte.js 103.14 kB │ gzip: 31.36 kB
|
|
25
|
+
✓ built in 4.00s
|
|
26
|
+
[vex] reads are not bounded: this database cannot enforce statement_timeout (10000ms asked). Fine for development; production wants Postgres.
|
|
27
|
+
|
|
28
|
+
Route What Served as Because
|
|
29
|
+
● / the app server welcome: a person can act on it
|
|
30
|
+
|
|
31
|
+
○ file drawn once, for nobody in particular; nothing on it can still happen
|
|
32
|
+
● server something on it can still happen; it wants moss behind it
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
> nisc-template-moss-dom@0.0.0 test /Users/max/Development/niscorp/.claude/worktrees/prerender/packages/create-nisc/templates/moss-dom
|
|
3
|
+
> nisc check
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
── welcome-check — the welcome screen: served, drawn, and pressed
|
|
7
|
+
[vex] reads are not bounded: this database cannot enforce statement_timeout (10000ms asked). Fine for development; production wants Postgres.
|
|
8
|
+
[pass] the anonymous principal is served the welcome action
|
|
9
|
+
[pass] its screen has a button to press
|
|
10
|
+
[pass] the page arrives drawn
|
|
11
|
+
[pass] a page drawn for nobody may be kept by a cache
|
|
12
|
+
[pass] a press reaches the shell on the server
|
|
13
|
+
[pass] welcome: all checks passed
|
|
14
|
+
|
|
15
|
+
All 1 checks pass.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# nisc-template-moss-dom
|
|
2
|
+
|
|
3
|
+
A [nisc](https://github.com/moccadroid/niscorp) application behind moss — the shell runs on the server, one per person; the browser is a canvas terminal.
|
|
4
|
+
|
|
5
|
+
| | |
|
|
6
|
+
|---|---|
|
|
7
|
+
| `npm run dev` | the app, in vite — with its server inside |
|
|
8
|
+
| `npm run build` | typecheck, bundle, draw every path and say how it is served |
|
|
9
|
+
| `npm start` | serve the built app, each first screen drawn |
|
|
10
|
+
| `npm run check` | the checks in `src/dev/` |
|
|
11
|
+
| `npm run strata status` | which grammar versions the source is written at |
|
|
12
|
+
|
|
13
|
+
**Before building anything:** [PLAN.md](PLAN.md) — what was decided when this app
|
|
14
|
+
was made and what is still open — and [AGENTS.md](AGENTS.md), which says where
|
|
15
|
+
the rules are.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>nisc-template-moss-dom</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="/src/main.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NiscMossProject } from '@niscorp/cli';
|
|
2
|
+
import { boot } from './src/server/boot';
|
|
3
|
+
import { drawing } from './src/server/document';
|
|
4
|
+
|
|
5
|
+
// What this app tells the `nisc` command: how it stands up (the same boot the
|
|
6
|
+
// checks run) and how one of its screens is drawn (the same drawing the dev
|
|
7
|
+
// server and `nisc start` use). Everything else is read off the app.
|
|
8
|
+
//
|
|
9
|
+
// npm run dev the app, with its server inside vite
|
|
10
|
+
// npm run build bundle, then say how each path is served
|
|
11
|
+
// npm start serve the built app, each first screen drawn
|
|
12
|
+
// npm run check the checks in src/dev
|
|
13
|
+
export const project: NiscMossProject = {
|
|
14
|
+
boot: async () => {
|
|
15
|
+
const { server } = await boot();
|
|
16
|
+
return { server, close: () => server.close() };
|
|
17
|
+
},
|
|
18
|
+
...drawing,
|
|
19
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nisc-template-moss-dom",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=22.12"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "nisc dev",
|
|
11
|
+
"build": "tsc --noEmit && nisc build",
|
|
12
|
+
"start": "nisc start",
|
|
13
|
+
"check": "nisc check",
|
|
14
|
+
"test": "nisc check",
|
|
15
|
+
"typecheck": "tsc --noEmit",
|
|
16
|
+
"strata": "tsx src/dev/strata.ts"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@electric-sql/pglite": "^0.5.1",
|
|
20
|
+
"@niscorp/charter": "workspace:^",
|
|
21
|
+
"@niscorp/moss": "workspace:^",
|
|
22
|
+
"@niscorp/nova": "workspace:^",
|
|
23
|
+
"@niscorp/prism": "workspace:^",
|
|
24
|
+
"@niscorp/strata": "workspace:^",
|
|
25
|
+
"@niscorp/tide": "workspace:^",
|
|
26
|
+
"@niscorp/vex": "workspace:^",
|
|
27
|
+
"jsdom": "^25.0.1",
|
|
28
|
+
"zod": "^4.6.5"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@niscorp/cli": "workspace:^",
|
|
32
|
+
"@niscorp/nisc": "workspace:^",
|
|
33
|
+
"@types/jsdom": "^30.0.0",
|
|
34
|
+
"@types/node": "^26.6.4",
|
|
35
|
+
"tsx": "^4.23.1",
|
|
36
|
+
"typescript": "^6.0.2",
|
|
37
|
+
"vite": "^7.1.12"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ActionDefinition } from '@niscorp/nova';
|
|
2
|
+
import { welcomeAction } from './actions/surfaces/welcome.action';
|
|
3
|
+
|
|
4
|
+
// Ring 1: every action the app ships, by id. Which of them exist for a given
|
|
5
|
+
// principal is the charter's answer, not this file's.
|
|
6
|
+
export const actions: Record<string, ActionDefinition> = {
|
|
7
|
+
[welcomeAction.id]: welcomeAction,
|
|
8
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ActionDefinition } from '@niscorp/nova';
|
|
2
|
+
import { welcomeLayout } from './welcome.layout';
|
|
3
|
+
|
|
4
|
+
// The first action: data with defaults, a JSON layout, and one trigger. The
|
|
5
|
+
// press is counted in the shell on the server — the browser only draws what
|
|
6
|
+
// the socket sends and sends back what was pressed.
|
|
7
|
+
export const welcomeAction: ActionDefinition = {
|
|
8
|
+
id: 'welcome',
|
|
9
|
+
title: 'Welcome',
|
|
10
|
+
data: { name: 'nisc-template-moss-dom', presses: 0 },
|
|
11
|
+
layout: welcomeLayout,
|
|
12
|
+
triggers: [{ event: 'ui:click', ref: 'press', do: [{ increment: 'presses' }] }],
|
|
13
|
+
};
|