create-smash-os 0.1.2 → 0.1.3

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.
Files changed (2) hide show
  1. package/install.mjs +239 -4
  2. package/package.json +1 -1
package/install.mjs CHANGED
@@ -3,23 +3,31 @@
3
3
  * smash-os-install — Install the SmashOS Claude Code harness into any repo.
4
4
  *
5
5
  * Usage (inside your repo root):
6
- * npx smash-os-install
6
+ * npx smash-os-install — connected mode (requires SmashOS web app)
7
+ * npx smash-os-install --local — local-only mode (no web app, no API keys)
7
8
  *
8
- * What it does:
9
+ * What it does (connected):
9
10
  * 1. Prompts for your SmashOS URL, Repo ID, and API key
10
11
  * 2. Validates credentials against the SmashOS API
11
12
  * 3. Fetches the generated harness files for your repo
12
13
  * 4. Writes CLAUDE.md, .claude/hooks/, .claude/skills/, .env.smash-os
13
14
  * 5. Merges hooks into existing .claude/settings.json (if present)
14
15
  * 6. Adds .env.smash-os to .gitignore
16
+ *
17
+ * What it does (--local):
18
+ * 1. Prompts for project name and tech stack only
19
+ * 2. Writes CLAUDE.md + /ai/ skeleton + 2 skills locally
20
+ * 3. No web app connection required
15
21
  */
16
22
 
17
23
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
18
- import { join, dirname } from 'path';
24
+ import { join, dirname, basename } from 'path';
25
+ import { homedir } from 'os';
19
26
  import prompts from 'prompts';
20
27
  import chalk from 'chalk';
21
28
 
22
29
  const cwd = process.cwd();
30
+ const isLocal = process.argv.includes('--local');
23
31
 
24
32
  // ─── Helpers ──────────────────────────────────────────────────────────────────
25
33
 
@@ -82,9 +90,236 @@ function ensureGitignore(entry) {
82
90
 
83
91
  console.log('');
84
92
  console.log(chalk.bold(' SmashOS Harness Installer'));
85
- console.log(chalk.dim(' Installs the Claude Code harness into your repo'));
93
+ console.log(chalk.dim(isLocal ? ' Local-only mode — no web app required' : ' Installs the Claude Code harness into your repo'));
86
94
  console.log('');
87
95
 
96
+ // ─── Local-only mode ──────────────────────────────────────────────────────────
97
+
98
+ if (isLocal) {
99
+ const localAnswers = await prompts([
100
+ {
101
+ type: 'text',
102
+ name: 'projectName',
103
+ message: 'Project name',
104
+ initial: basename(cwd),
105
+ validate: (v) => (v.trim().length > 0 ? true : 'Required'),
106
+ },
107
+ {
108
+ type: 'text',
109
+ name: 'techStack',
110
+ message: 'Tech stack (e.g. React + Node.js + Postgres)',
111
+ initial: 'TypeScript',
112
+ },
113
+ ], { onCancel: () => { console.log(chalk.yellow('\n Cancelled.')); process.exit(0); } });
114
+
115
+ const { projectName, techStack } = localAnswers;
116
+ const today = new Date().toISOString().split('T')[0];
117
+
118
+ const claudeMd = `# ${projectName} — SmashOS Harness Active
119
+
120
+ You are operating inside the SmashOS AI Workflow Harness.
121
+ You are not a single assistant. You are a coordinated AI engineering organisation.
122
+
123
+ ## On Session Start
124
+ 1. Read \`ai/context/product.md\` (if it exists)
125
+ 2. Read \`ai/context/architecture.md\` (if it exists)
126
+ 3. Read \`ai/context/coding-standards.md\` (if it exists)
127
+ 4. Read \`ai/memory/decisions.md\` — last 20 entries (if it exists)
128
+ 5. Adopt the role: Staff Engineer
129
+
130
+ ## Cognitive Mode Rules
131
+ THINKING → Staff Engineer, Product Manager (no file writes)
132
+ EXECUTION → Senior Developer, DevOps (no specs or decisions)
133
+ VALIDATION → Security Engineer, QA Engineer (no production code)
134
+
135
+ ## Golden Rules
136
+ - Never skip architecture review
137
+ - Never write code without an approved spec
138
+ - Never deploy without QA + Security validation
139
+ - Output structured results only
140
+ - Save decisions to memory after every significant choice
141
+
142
+ ## Slash Commands
143
+ - /smash-os:role [name] — switch cognitive mode + load role definition
144
+
145
+ ## Tech Stack
146
+ ${techStack}
147
+ `;
148
+
149
+ const aiFiles = {
150
+ 'ai/orchestrator.md': `# ${projectName} — SmashOS Orchestrator
151
+ **Generated:** ${today}
152
+ **Version:** 1.0
153
+
154
+ ---
155
+
156
+ ## Overview
157
+
158
+ You are operating inside the SmashOS AI Workflow Harness for **${projectName}**.
159
+ You are not a single assistant. You are a coordinated AI engineering organisation.
160
+
161
+ This orchestrator.md is your master boot document. Read it fully at the start of every session.
162
+
163
+ ---
164
+
165
+ ## On Session Start
166
+
167
+ 1. Read \`/ai/context/product.md\` — understand what you are building and for whom
168
+ 2. Read \`/ai/context/architecture.md\` — understand the technical system
169
+ 3. Read \`/ai/context/coding-standards.md\` — know the rules before touching any file
170
+ 4. Read \`/ai/memory/decisions.md\` (last 20 entries) — know what has been decided and why
171
+ 5. Adopt the role: Staff Engineer
172
+
173
+ ---
174
+
175
+ ## Cognitive Mode Rules
176
+
177
+ | Mode | Roles | Permitted | Forbidden |
178
+ |---|---|---|---|
179
+ | THINKING | Staff Engineer, Product Manager | Specs, decisions, architecture docs | File writes, commits |
180
+ | EXECUTION | Senior Developer, DevOps Engineer | Code, commits, branches, PRs | Specs, decisions |
181
+ | VALIDATION | Security Engineer, QA Engineer | Scores, test results, audit reports | Production code |
182
+
183
+ The orchestrator hard-blocks mode mixing. Never mix thinking and execution in the same phase.
184
+
185
+ ---
186
+
187
+ ## Golden Rules
188
+
189
+ 1. Never skip architecture review
190
+ 2. Never write code without an approved spec
191
+ 3. Never deploy without QA + Security validation
192
+ 4. Output structured results only — every phase output is a typed JSON object
193
+ 5. Save decisions to memory after every significant architectural choice
194
+ 6. Revenue risk outranks technical purity
195
+ 7. Block automation when stability drops below 40
196
+
197
+ ---
198
+
199
+ ## Active Role Definitions
200
+
201
+ | Role | Mode | Primary Skill |
202
+ |---|---|---|
203
+ | Staff Engineer | THINKING | architecture-review |
204
+ | Product Manager | THINKING | — |
205
+ | Senior Developer | EXECUTION | code-generation |
206
+ | Security Engineer | VALIDATION | security-audit |
207
+ | QA Engineer | VALIDATION | qa-validation |
208
+ | DevOps Engineer | EXECUTION | — |
209
+
210
+ Full role definitions: \`/ai/roles/{role-name}.md\`
211
+
212
+ ---
213
+
214
+ ## Selective Context Loading
215
+
216
+ Load only what your role requires. Never load the full context bundle.
217
+
218
+ | Role | Load |
219
+ |---|---|
220
+ | Product Manager | product.md + database.md + trigger payload |
221
+ | Staff Engineer | architecture.md + coding-standards.md + decisions.md + previous phase output |
222
+ | Senior Developer | architecture.md + coding-standards.md + approved spec |
223
+ | Security Engineer | database.md + auth section of architecture.md + file diff |
224
+ | QA Engineer | coding-standards.md + acceptance criteria + file diff |
225
+ | DevOps Engineer | architecture.md + PR metadata + score summary |
226
+
227
+ ---
228
+
229
+ ## Product Summary
230
+
231
+ *Context not yet generated. Fill in \`/ai/context/product.md\` with your project details.*
232
+
233
+ ---
234
+
235
+ ## Architecture Summary
236
+
237
+ *Context not yet generated. Fill in \`/ai/context/architecture.md\` with your architecture.*
238
+
239
+ ---
240
+
241
+ ## Coding Standards Summary
242
+
243
+ *Context not yet generated. Fill in \`/ai/context/coding-standards.md\` with your coding standards.*
244
+
245
+ ---
246
+
247
+ ## Database Summary
248
+
249
+ *Context not yet generated. Fill in \`/ai/context/database.md\` with your database details.*
250
+
251
+ ---
252
+
253
+ ## Memory
254
+
255
+ - Architecture decisions: \`/ai/memory/decisions.md\`
256
+ - Lessons learned: \`/ai/memory/lessons.md\`
257
+
258
+ After every completed session, append decisions and lessons to the relevant memory file.
259
+
260
+ ---
261
+
262
+ ## Workflow References
263
+
264
+ - Feature: \`/ai/workflows/feature.md\`
265
+ - Bug Fix: \`/ai/workflows/bug-fix.md\`
266
+ - Weekly Improvement: \`/ai/workflows/weekly-improvement.md\`
267
+
268
+ ---
269
+
270
+ *Generated by smash-os-install (local mode) — fill in the /ai/context/ files to activate full context.*
271
+ `,
272
+ 'ai/context/product.md': `# Product Context — ${projectName}\n\n## What is this project?\n<!-- Describe what this project does -->\n\n## Who uses it?\n<!-- Describe the users -->\n\n## Core goals\n<!-- List the main goals -->\n\n## Tech Stack\n${techStack}\n`,
273
+ 'ai/context/architecture.md': `# Architecture — ${projectName}\n\n## Overview\n<!-- Describe the high-level architecture -->\n\n## Key decisions\n<!-- List major architectural decisions and why they were made -->\n\n## Constraints\n<!-- List things that must not change -->\n`,
274
+ 'ai/context/coding-standards.md': `# Coding Standards — ${projectName}\n\n## Language & formatting\n<!-- ESLint config, prettier, etc. -->\n\n## Naming conventions\n<!-- Variables, files, functions -->\n\n## Patterns to follow\n<!-- e.g. always use server actions, never bypass RLS -->\n\n## Patterns to avoid\n<!-- e.g. no raw SQL, no any types -->\n`,
275
+ 'ai/memory/decisions.md': `# Decisions Log\n\n<!-- SmashOS writes here after each session. Format: -->\n<!-- ## YYYY-MM-DD — Decision title -->\n<!-- **Rationale:** why this was chosen -->\n<!-- **Outcome:** what changed -->\n`,
276
+ 'ai/memory/lessons.md': `# Lessons Learned\n\n<!-- SmashOS writes here after bugs and incidents. Format: -->\n<!-- ## YYYY-MM-DD — Lesson title -->\n<!-- **What happened:** -->\n<!-- **What to do differently:** -->\n`,
277
+ };
278
+
279
+ const localSkills = {
280
+ 'smash-os-role': `---\nname: smash-os-role\ndescription: Switch cognitive mode and load a SmashOS role definition. Use when the user says "act as X", "switch to X role", "be the X", or names a SmashOS role (Staff Engineer, Product Manager, Senior Developer, Security Engineer, QA Engineer, DevOps Engineer).\n---\n\n# /smash-os:role\n\nSwitch to the named role and adopt its cognitive mode.\n\n## Roles\n\n| Role | Mode | Allowed |\n|---|---|---|\n| Staff Engineer | THINKING | Architecture, decisions, reviews |\n| Product Manager | THINKING | Specs, user stories, acceptance criteria |\n| Senior Developer | EXECUTION | Writing code, editing files |\n| Security Engineer | VALIDATION | Security review only, no code changes |\n| QA Engineer | VALIDATION | Testing and verification only |\n| DevOps Engineer | EXECUTION | Infrastructure, deployment |\n\n## Steps\n1. Read the role name from the argument (default: Staff Engineer)\n2. Announce: "Switching to [Role] — [Mode] mode"\n3. Load \`ai/roles/<role-slug>.md\` if it exists\n4. Apply the cognitive mode restrictions for the rest of the session\n`,
281
+ 'smash-os-memory': `---\nname: smash-os-memory\ndescription: Show recent SmashOS decisions and lessons from the ai/memory/ folder. Use when the user says "show memory", "what decisions were made", "show lessons", or "smash-os memory".\n---\n\n# /smash-os:memory\n\nRead and display the local SmashOS memory files.\n\n## Steps\n1. Read \`ai/memory/decisions.md\` (last 20 entries)\n2. Read \`ai/memory/lessons.md\` (last 10 entries)\n3. Display them clearly — decisions first, then lessons\n4. If either file is empty or missing, say so\n`,
282
+ };
283
+
284
+ let written = 0;
285
+
286
+ writeFile('CLAUDE.md', claudeMd);
287
+ console.log(' ' + chalk.green('✓') + ' ' + chalk.white('CLAUDE.md'));
288
+ written++;
289
+
290
+ for (const [relPath, content] of Object.entries(aiFiles)) {
291
+ if (!existsSync(join(cwd, relPath))) {
292
+ writeFile(relPath, content);
293
+ console.log(' ' + chalk.green('✓') + ' ' + chalk.white(relPath));
294
+ written++;
295
+ } else {
296
+ console.log(' ' + chalk.dim('↷') + ' ' + chalk.dim(`${relPath} (already exists — skipped)`));
297
+ }
298
+ }
299
+
300
+ console.log('');
301
+ for (const [skillName, skillContent] of Object.entries(localSkills)) {
302
+ const skillDir = join(homedir(), '.claude', 'skills', skillName);
303
+ mkdirSync(skillDir, { recursive: true });
304
+ writeFileSync(join(skillDir, 'SKILL.md'), skillContent, 'utf8');
305
+ console.log(' ' + chalk.green('✓') + ' ' + chalk.white(`/smash-os:${skillName.replace('smash-os-', '')}`) + chalk.dim(' → ~/.claude/skills/'));
306
+ written++;
307
+ }
308
+
309
+ console.log('');
310
+ console.log(chalk.bold.green(' SmashOS harness installed!') + chalk.dim(` (${written} files — local mode)`));
311
+ console.log('');
312
+ console.log(chalk.dim(' Open Claude Code in this directory and start working:'));
313
+ console.log(' ' + chalk.white(' claude .'));
314
+ console.log('');
315
+ console.log(chalk.dim(' Fill in the ai/context/ files with your project details,'));
316
+ console.log(chalk.dim(' then Claude Code will load them automatically every session.'));
317
+ console.log('');
318
+ process.exit(0);
319
+ }
320
+
321
+ // ─── Connected mode ────────────────────────────────────────────────────────────
322
+
88
323
  const answers = await prompts(
89
324
  [
90
325
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-smash-os",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Scaffold a SmashOS AI workflow platform into any directory",
5
5
  "type": "module",
6
6
  "bin": {