inclusion-md 0.1.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/lib/prompt.js ADDED
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+
3
+ const readline = require("readline");
4
+ const c = require("./colors");
5
+
6
+ function createPrompter({ acceptDefaults = false } = {}) {
7
+ const rl = readline.createInterface({
8
+ input: process.stdin,
9
+ output: process.stdout,
10
+ terminal: process.stdout.isTTY,
11
+ });
12
+
13
+ rl.on("SIGINT", () => {
14
+ rl.close();
15
+ const err = new Error("Cancelled by user");
16
+ err.code = "USER_CANCELLED";
17
+ throw err;
18
+ });
19
+
20
+ function ask(question) {
21
+ return new Promise((resolve, reject) => {
22
+ rl.question(question, (answer) => resolve(answer));
23
+ rl.once("close", () => {
24
+ const err = new Error("Cancelled by user");
25
+ err.code = "USER_CANCELLED";
26
+ reject(err);
27
+ });
28
+ });
29
+ }
30
+
31
+ function fmtDefault(d) {
32
+ if (d === undefined || d === null || d === "") return "";
33
+ return c.dim(` (${d})`);
34
+ }
35
+
36
+ async function text(label, { default: def = "", required = false } = {}) {
37
+ if (acceptDefaults) return def;
38
+ while (true) {
39
+ const raw = await ask(`${c.cyan("?")} ${c.bold(label)}${fmtDefault(def)}: `);
40
+ const val = (raw || "").trim();
41
+ if (val) return val;
42
+ if (def) return def;
43
+ if (!required) return "";
44
+ process.stdout.write(c.yellow(" This one's required - try again.\n"));
45
+ }
46
+ }
47
+
48
+ async function multiline(label, { default: def = "" } = {}) {
49
+ if (acceptDefaults) return def;
50
+ process.stdout.write(
51
+ `${c.cyan("?")} ${c.bold(label)}\n` +
52
+ c.dim(" (one item per line; empty line to finish")
53
+ );
54
+ if (def)
55
+ process.stdout.write(c.dim(`; press enter immediately to accept default`));
56
+ process.stdout.write(c.dim(")\n"));
57
+ const lines = [];
58
+ while (true) {
59
+ const raw = await ask(c.dim(" - "));
60
+ const val = (raw || "").trim();
61
+ if (val === "" && lines.length === 0 && def) return def;
62
+ if (val === "") break;
63
+ lines.push(val);
64
+ }
65
+ return lines.length ? lines.map((l) => `- ${l}`).join("\n") : def;
66
+ }
67
+
68
+ async function choice(label, options, { default: defIndex = 0 } = {}) {
69
+ if (acceptDefaults) return options[defIndex].value;
70
+ process.stdout.write(`${c.cyan("?")} ${c.bold(label)}\n`);
71
+ options.forEach((opt, i) => {
72
+ const marker = i === defIndex ? c.green("*") : " ";
73
+ process.stdout.write(
74
+ ` ${marker} ${c.bold(String(i + 1))}) ${opt.label}` +
75
+ (opt.hint ? c.dim(` - ${opt.hint}`) : "") +
76
+ "\n"
77
+ );
78
+ });
79
+ while (true) {
80
+ const raw = await ask(c.dim(` choose 1-${options.length} `) + fmtDefault(defIndex + 1) + ": ");
81
+ const val = (raw || "").trim();
82
+ if (val === "") return options[defIndex].value;
83
+ const n = parseInt(val, 10);
84
+ if (Number.isInteger(n) && n >= 1 && n <= options.length) {
85
+ return options[n - 1].value;
86
+ }
87
+ process.stdout.write(c.yellow(` Please enter a number 1-${options.length}.\n`));
88
+ }
89
+ }
90
+
91
+ async function confirm(label, { default: def = false } = {}) {
92
+ if (acceptDefaults) return def;
93
+ const hint = def ? "Y/n" : "y/N";
94
+ while (true) {
95
+ const raw = await ask(`${c.cyan("?")} ${c.bold(label)} ${c.dim(`(${hint})`)}: `);
96
+ const val = (raw || "").trim().toLowerCase();
97
+ if (val === "") return def;
98
+ if (val === "y" || val === "yes") return true;
99
+ if (val === "n" || val === "no") return false;
100
+ process.stdout.write(c.yellow(" Please answer y or n.\n"));
101
+ }
102
+ }
103
+
104
+ function close() {
105
+ rl.close();
106
+ }
107
+
108
+ return { text, multiline, choice, confirm, close };
109
+ }
110
+
111
+ module.exports = { createPrompter };
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+
6
+ const VARIANTS = {
7
+ generic: "INCLUSION.md",
8
+ "frontend-app": "examples/frontend-app/INCLUSION.md",
9
+ "design-system": "examples/design-system/INCLUSION.md",
10
+ "backend-api": "examples/backend-api/INCLUSION.md",
11
+ };
12
+
13
+ function loadTemplate(variant) {
14
+ const rel = VARIANTS[variant];
15
+ if (!rel) {
16
+ throw new Error(
17
+ `Unknown variant "${variant}". Choose one of: ${Object.keys(VARIANTS).join(", ")}.`
18
+ );
19
+ }
20
+ // Resolve relative to the package root (one level up from /lib).
21
+ const base = path.resolve(__dirname, "..");
22
+ const full = path.join(base, rel);
23
+ if (!fs.existsSync(full)) {
24
+ throw new Error(`Template not found at ${full}.`);
25
+ }
26
+ return fs.readFileSync(full, "utf8");
27
+ }
28
+
29
+ /**
30
+ * Render the generic template by substituting Section 1 (Project Context) and
31
+ * Section 12 (Maintenance) with the user's answers. We do a targeted block
32
+ * replace so we don't have to maintain a parallel templating language - the
33
+ * canonical INCLUSION.md is itself the template.
34
+ */
35
+ function renderGeneric(template, answers) {
36
+ let out = template;
37
+
38
+ // --- Section 1: Project Context -----------------------------------------
39
+ const newProjectContext =
40
+ `## 1. Project Context\n\n` +
41
+ `- **Product:** ${answers.product}\n` +
42
+ `- **Primary users:** ${answers.primaryUsers}\n` +
43
+ `- **Known underserved users:** ${answers.underservedUsers}\n` +
44
+ `- **Distribution context:** ${answers.distribution}\n` +
45
+ `- **Stakes:** ${answers.stakes}\n\n` +
46
+ `Generated code, copy, and interaction patterns should be evaluated against the\n` +
47
+ `context above before being merged.`;
48
+
49
+ out = replaceSection(out, /^## 1\. Project Context[\s\S]*?(?=^---\s*$)/m, newProjectContext + "\n\n");
50
+
51
+ // --- Section 12: Maintenance --------------------------------------------
52
+ const newMaintenance =
53
+ `## 12. Maintenance\n\n` +
54
+ `- **Owner:** ${answers.owner}\n` +
55
+ `- **Review cadence:** ${answers.cadence}\n` +
56
+ `- **Change log:** Track meaningful changes to this file in\n` +
57
+ ` [\`CHANGELOG.md\`](./CHANGELOG.md) or in repository releases.\n` +
58
+ `- **Feedback:** ${answers.feedback}`;
59
+
60
+ out = replaceSection(out, /^## 12\. Maintenance[\s\S]*?(?=^---\s*$)/m, newMaintenance + "\n\n");
61
+
62
+ return out;
63
+ }
64
+
65
+ function replaceSection(source, regex, replacement) {
66
+ if (!regex.test(source)) return source;
67
+ return source.replace(regex, replacement);
68
+ }
69
+
70
+ module.exports = { loadTemplate, renderGeneric, VARIANTS };
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "inclusion-md",
3
+ "version": "0.1.0",
4
+ "description": "Scaffold an INCLUSION.md - a context engineering doc that gives AI coding assistants inclusion-oriented guidance during code generation.",
5
+ "keywords": [
6
+ "inclusion",
7
+ "accessibility",
8
+ "a11y",
9
+ "ai",
10
+ "llm",
11
+ "context-engineering",
12
+ "copilot",
13
+ "claude",
14
+ "cursor",
15
+ "design-systems"
16
+ ],
17
+ "homepage": "https://github.com/BranonConor/inclusion.md#readme",
18
+ "bugs": {
19
+ "url": "https://github.com/BranonConor/inclusion.md/issues"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/BranonConor/inclusion.md.git"
24
+ },
25
+ "license": "MIT",
26
+ "author": "Branon Eusebio (https://branon.dev)",
27
+ "type": "commonjs",
28
+ "bin": {
29
+ "inclusion-md": "bin/inclusion-md.js"
30
+ },
31
+ "files": [
32
+ "bin",
33
+ "lib",
34
+ "templates",
35
+ "INCLUSION.md",
36
+ "examples",
37
+ "README.md",
38
+ "LICENSE"
39
+ ],
40
+ "engines": {
41
+ "node": ">=16"
42
+ },
43
+ "scripts": {
44
+ "test": "node bin/inclusion-md.js --help"
45
+ }
46
+ }