@nolrm/contextkit 0.14.1 → 0.15.1

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/README.md CHANGED
@@ -90,7 +90,7 @@ Each platform generates bridge files that the AI tool auto-reads. If a bridge fi
90
90
 
91
91
  - Reads `glossary.md` → `checkout` = checkout process; `customer` = customer account
92
92
  - Applies `code-style.md` → strict TS, functional components
93
- - Follows `testing.md` → numbered test cases
93
+ - Follows `testing.md` → testing levels, change-driven test selection, numbered test cases
94
94
 
95
95
  **Result (diff)**
96
96
 
@@ -161,7 +161,7 @@ ContextKit installs reusable slash commands for supported platforms:
161
161
  | `/squad` | Kick off a squad task — one task or many (auto-detects batch mode). Pushes back with clarifying questions if the task is vague. |
162
162
  | `/squad-architect` | Design the technical plan from the PO spec |
163
163
  | `/squad-dev` | Implement code following the architect plan |
164
- | `/squad-test` | Write and run tests against acceptance criteria |
164
+ | `/squad-test` | Classify test levels, write and run tests against acceptance criteria |
165
165
  | `/squad-review` | Review the full pipeline and give a verdict |
166
166
  | `/squad-doc` | Create companion `.md` files for new/modified code after review passes |
167
167
  | `/squad-auto` | Auto-run the full pipeline after kickoff (recommended, sequential) |
@@ -69,6 +69,7 @@ class InstallCommand {
69
69
  console.log(chalk.blue(`🔧 Adding ${requestedPlatform} integration...`));
70
70
  console.log('');
71
71
  await this.installPlatformIntegration(requestedPlatform);
72
+ await this.addContextKitGitignoreEntries();
72
73
  return;
73
74
  }
74
75
 
@@ -153,6 +154,9 @@ class InstallCommand {
153
154
  await this.installPlatformIntegration(chosenPlatform);
154
155
  }
155
156
 
157
+ // Add ephemeral ContextKit entries to .gitignore
158
+ await this.addContextKitGitignoreEntries();
159
+
156
160
  // Success message
157
161
  this.showSuccessMessage(hookChoices, chosenPlatform, projectType, packageManager);
158
162
  }
@@ -184,6 +188,31 @@ class InstallCommand {
184
188
  }
185
189
  }
186
190
 
191
+ async addContextKitGitignoreEntries() {
192
+ if (!(await fs.pathExists('.gitignore'))) return;
193
+
194
+ const entries = [
195
+ '.contextkit/status.json',
196
+ '.contextkit/status.yml',
197
+ '.contextkit/context.md',
198
+ '.contextkit/squad/',
199
+ '.contextkit/squad-done-*/',
200
+ ];
201
+
202
+ try {
203
+ const content = await fs.readFile('.gitignore', 'utf-8');
204
+ const missing = entries.filter((e) => !content.includes(e));
205
+ if (missing.length === 0) return;
206
+
207
+ const hasHeader = content.includes('# ContextKit');
208
+ const header = hasHeader ? '' : '\n# ContextKit\n';
209
+ const separator = content.endsWith('\n') ? '' : '\n';
210
+ await fs.appendFile('.gitignore', `${separator}${header}${missing.join('\n')}\n`);
211
+ } catch (error) {
212
+ console.log(chalk.yellow('⚠️ Could not update .gitignore:'), error.message);
213
+ }
214
+ }
215
+
187
216
  showPlatformUsage(platform) {
188
217
  const { getIntegration } = require('../integrations');
189
218
  const integration = getIntegration(platform);
@@ -422,6 +451,38 @@ Your testing standards will be automatically generated based on your existing te
422
451
 
423
452
  Run \`/analyze\` to generate this content.
424
453
 
454
+ ## Testing Levels
455
+
456
+ Follow the **Testing Trophy** philosophy: integration tests are the sweet spot — they give the most confidence per test written. Unit tests cover isolated logic. E2E covers critical user paths only.
457
+
458
+ > Default bias: when in doubt, write an integration test, not a unit test.
459
+
460
+ ### The Three Levels
461
+
462
+ | Level | What it tests | Typical tools |
463
+ |-------|--------------|--------------|
464
+ | **Unit** | A single function, class, or component in isolation — dependencies mocked | Jest, testing-library (component only) |
465
+ | **Integration / Page** | A full page or feature rendered with its real component tree — only external APIs/services mocked | Jest + testing-library, Supertest |
466
+ | **E2E** | A complete user flow in a real browser or process | Playwright, Cypress |
467
+
468
+ ### Change-Driven Decision Table
469
+
470
+ Before writing any tests, classify what changed and apply the required level(s):
471
+
472
+ | What changed | Unit | Integration / Page | E2E |
473
+ |---|:---:|:---:|:---:|
474
+ | Pure function or utility | ✅ | — | — |
475
+ | New CLI command or module | ✅ | ✅ (cross-command) | — |
476
+ | UI component (used in 1 place) | ✅ | — | — |
477
+ | UI component (used in 2+ contexts: edit/view/create/…) | ✅ | ✅ one per context | — |
478
+ | New page or route | — | ✅ | — |
479
+ | Multi-step user flow | — | — | ✅ |
480
+ | Bug fix | At the level the bug was visible | | |
481
+
482
+ ### Context Coverage Rule
483
+
484
+ If a component is rendered in **two or more contexts** (e.g. Edit page, View page, Create page), each context requires its own integration test. A single unit test is not sufficient — it cannot catch wiring bugs that only appear in context.
485
+
425
486
  ## ⭐ REQUIRED: Numbered Test Cases
426
487
 
427
488
  **All test cases MUST use numbered descriptions for easy tracking and debugging:**
@@ -86,7 +86,11 @@ class UpdateCommand {
86
86
  await this.refreshIntegrations();
87
87
 
88
88
  // Update version in config
89
- await this.updateConfigVersion(updateInfo.latestVersion || '1.0.0');
89
+ await this.updateConfigVersion(
90
+ updateInfo.latestVersion && updateInfo.latestVersion !== 'unknown'
91
+ ? updateInfo.latestVersion
92
+ : require('../../package.json').version
93
+ );
90
94
 
91
95
  console.log(chalk.green('✅ ContextKit updated successfully!'));
92
96
  } catch (error) {
@@ -102,16 +106,15 @@ class UpdateCommand {
102
106
  }
103
107
 
104
108
  async checkForUpdates() {
109
+ const pkg = require('../../package.json');
105
110
  try {
106
111
  const axios = require('axios');
107
112
  const response = await axios.get(
108
- 'https://api.github.com/repos/nolrm/contextkit/releases/latest',
109
- {
110
- timeout: 5000,
111
- }
113
+ `https://registry.npmjs.org/${pkg.name}/latest`,
114
+ { timeout: 5000 }
112
115
  );
113
116
 
114
- const latestVersion = response.data.tag_name.replace('v', '');
117
+ const latestVersion = response.data.version;
115
118
  const currentVersion = await this.getCurrentVersion();
116
119
  const hasUpdate = this.isNewerVersion(latestVersion, currentVersion);
117
120
 
@@ -121,10 +124,11 @@ class UpdateCommand {
121
124
  latestVersion,
122
125
  };
123
126
  } catch (error) {
127
+ // Can't reach npm registry — skip update rather than blindly running
124
128
  return {
125
- hasUpdate: true, // Assume update available if we can't check
129
+ hasUpdate: false,
126
130
  currentVersion: await this.getCurrentVersion(),
127
- latestVersion: 'latest',
131
+ latestVersion: 'unknown',
128
132
  error: error.message,
129
133
  };
130
134
  }
@@ -133,9 +137,9 @@ class UpdateCommand {
133
137
  async getCurrentVersion() {
134
138
  try {
135
139
  const config = await this.parseConfig();
136
- return config.version || '1.0.0';
140
+ return config.version || require('../../package.json').version;
137
141
  } catch {
138
- return '1.0.0';
142
+ return require('../../package.json').version;
139
143
  }
140
144
  }
141
145
 
@@ -132,8 +132,8 @@ Reference: @.contextkit/standards/code-style.md
132
132
 
133
133
  ## Commands
134
134
 
135
- - @.contextkit/commands/create-component.md — Create component workflow
136
- - @.contextkit/commands/spec.md — Write a component spec before coding
135
+ - @.contextkit/commands/dev/create-component.md — Create component workflow
136
+ - @.contextkit/commands/dev/spec.md — Write a component spec before coding
137
137
  `;
138
138
  await this.writeGeneratedFile('.cursor/rules/contextkit-components.mdc', componentsRule);
139
139
 
@@ -154,7 +154,7 @@ Reference: @.contextkit/standards/architecture.md
154
154
 
155
155
  ## Commands
156
156
 
157
- - @.contextkit/commands/create-feature.md — Create feature workflow
157
+ - @.contextkit/commands/dev/create-feature.md — Create feature workflow
158
158
  `;
159
159
  await this.writeGeneratedFile('.cursor/rules/contextkit-api.mdc', apiRule);
160
160
 
@@ -163,7 +163,7 @@ Reference: @.contextkit/standards/architecture.md
163
163
  '.cursor/prompts/analyze.md',
164
164
  `# Analyze Project
165
165
 
166
- Read \`.contextkit/commands/analyze.md\` and execute the analysis workflow for this project.
166
+ Read \`.contextkit/commands/dev/analyze.md\` and execute the analysis workflow for this project.
167
167
 
168
168
  Scan the codebase structure, detect frameworks and patterns, then generate customized standards files in \`.contextkit/standards/\`.
169
169
  `
@@ -173,7 +173,7 @@ Scan the codebase structure, detect frameworks and patterns, then generate custo
173
173
  '.cursor/prompts/review.md',
174
174
  `# Code Review
175
175
 
176
- Read \`.contextkit/commands/review.md\` and execute the review workflow.
176
+ Read \`.contextkit/commands/dev/review.md\` and execute the review workflow.
177
177
 
178
178
  Review current changes for correctness, standards compliance, and potential issues. Flag bugs, security concerns, and standards violations.
179
179
  `
@@ -183,7 +183,7 @@ Review current changes for correctness, standards compliance, and potential issu
183
183
  '.cursor/prompts/fix.md',
184
184
  `# Fix Bug
185
185
 
186
- Read \`.contextkit/commands/fix.md\` and execute the bug fix workflow.
186
+ Read \`.contextkit/commands/dev/fix.md\` and execute the bug fix workflow.
187
187
 
188
188
  Diagnose the root cause, implement the minimal fix, and add a regression test.
189
189
  `
@@ -193,7 +193,7 @@ Diagnose the root cause, implement the minimal fix, and add a regression test.
193
193
  '.cursor/prompts/refactor.md',
194
194
  `# Refactor
195
195
 
196
- Read \`.contextkit/commands/refactor.md\` and execute the refactoring workflow.
196
+ Read \`.contextkit/commands/dev/refactor.md\` and execute the refactoring workflow.
197
197
 
198
198
  Improve code structure without changing behavior, keeping tests green at every step.
199
199
  `
@@ -203,7 +203,7 @@ Improve code structure without changing behavior, keeping tests green at every s
203
203
  '.cursor/prompts/test.md',
204
204
  `# Run Tests
205
205
 
206
- Read \`.contextkit/commands/run-tests.md\` and execute the testing workflow.
206
+ Read \`.contextkit/commands/dev/run-tests.md\` and execute the testing workflow.
207
207
 
208
208
  Generate or run tests for the specified code, covering happy paths, edge cases, and errors.
209
209
  `
@@ -213,7 +213,7 @@ Generate or run tests for the specified code, covering happy paths, edge cases,
213
213
  '.cursor/prompts/doc.md',
214
214
  `# Add Documentation
215
215
 
216
- Read \`.contextkit/commands/add-documentation.md\` and execute the documentation workflow.
216
+ Read \`.contextkit/commands/docs/add-documentation.md\` and execute the documentation workflow.
217
217
 
218
218
  Add inline docs, README sections, and usage examples for the specified code.
219
219
  `
@@ -224,7 +224,7 @@ Add inline docs, README sections, and usage examples for the specified code.
224
224
  '.cursor/prompts/squad.md',
225
225
  `# Squad — Kickoff
226
226
 
227
- Read \`.contextkit/commands/squad.md\` and execute the squad kickoff workflow.
227
+ Read \`.contextkit/commands/squad/squad.md\` and execute the squad kickoff workflow.
228
228
 
229
229
  Create the handoff file and write the PO spec for the given task. Pass the user's task description as the input.
230
230
  `
@@ -234,7 +234,7 @@ Create the handoff file and write the PO spec for the given task. Pass the user'
234
234
  '.cursor/prompts/squad-architect.md',
235
235
  `# Squad — Architect
236
236
 
237
- Read \`.contextkit/commands/squad-architect.md\` and execute the architect workflow.
237
+ Read \`.contextkit/commands/squad/squad-architect.md\` and execute the architect workflow.
238
238
 
239
239
  Read the PO spec from the handoff file, design the technical approach, and write the implementation plan.
240
240
  `
@@ -244,7 +244,7 @@ Read the PO spec from the handoff file, design the technical approach, and write
244
244
  '.cursor/prompts/squad-dev.md',
245
245
  `# Squad — Dev
246
246
 
247
- Read \`.contextkit/commands/squad-dev.md\` and execute the dev workflow.
247
+ Read \`.contextkit/commands/squad/squad-dev.md\` and execute the dev workflow.
248
248
 
249
249
  Follow the architect's plan to implement the code changes.
250
250
  `
@@ -254,7 +254,7 @@ Follow the architect's plan to implement the code changes.
254
254
  '.cursor/prompts/squad-test.md',
255
255
  `# Squad — Test
256
256
 
257
- Read \`.contextkit/commands/squad-test.md\` and execute the test workflow.
257
+ Read \`.contextkit/commands/squad/squad-test.md\` and execute the test workflow.
258
258
 
259
259
  Write and run tests against the PO's acceptance criteria.
260
260
  `
@@ -264,7 +264,7 @@ Write and run tests against the PO's acceptance criteria.
264
264
  '.cursor/prompts/squad-review.md',
265
265
  `# Squad — Review
266
266
 
267
- Read \`.contextkit/commands/squad-review.md\` and execute the review workflow.
267
+ Read \`.contextkit/commands/squad/squad-review.md\` and execute the review workflow.
268
268
 
269
269
  Review the full handoff (spec, plan, implementation, tests) and write the final verdict.
270
270
  `
@@ -274,7 +274,7 @@ Review the full handoff (spec, plan, implementation, tests) and write the final
274
274
  '.cursor/prompts/squad-auto.md',
275
275
  `# Squad Auto — Full Pipeline (recommended)
276
276
 
277
- Read \`.contextkit/commands/squad-auto.md\` and execute the pipeline runner workflow.
277
+ Read \`.contextkit/commands/squad/squad-auto.md\` and execute the pipeline runner workflow.
278
278
 
279
279
  Run after kickoff. Automatically runs architect → dev → test → review for all tasks sequentially, hands-free.
280
280
  `
@@ -284,7 +284,7 @@ Run after kickoff. Automatically runs architect → dev → test → review for
284
284
  '.cursor/prompts/spec.md',
285
285
  `# Spec
286
286
 
287
- Read \`.contextkit/commands/spec.md\` and execute the spec workflow.
287
+ Read \`.contextkit/commands/dev/spec.md\` and execute the spec workflow.
288
288
 
289
289
  Write a component spec (MD-first) before any code is created. Scaffold the spec file colocated with the component and wait for review before coding begins.
290
290
  `
@@ -294,7 +294,7 @@ Write a component spec (MD-first) before any code is created. Scaffold the spec
294
294
  '.cursor/prompts/ck.md',
295
295
  `# ContextKit Health Check
296
296
 
297
- Read \`.contextkit/commands/health-check.md\` and execute the health check workflow.
297
+ Read \`.contextkit/commands/dev/health-check.md\` and execute the health check workflow.
298
298
 
299
299
  Check project setup, standards status, and integrations. Report what needs attention.
300
300
  `
@@ -11,7 +11,10 @@ class MigrationRunner {
11
11
  * @param {string} configPath - path to config.yml
12
12
  */
13
13
  async run(currentVersion, configPath) {
14
- const from = currentVersion === undefined || currentVersion === null ? 0 : currentVersion;
14
+ const from =
15
+ currentVersion === undefined || currentVersion === null || Number.isNaN(currentVersion)
16
+ ? 0
17
+ : currentVersion;
15
18
 
16
19
  if (from > CURRENT_FORMAT_VERSION) {
17
20
  console.log(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nolrm/contextkit",
3
- "version": "0.14.1",
3
+ "version": "0.15.1",
4
4
  "description": "ContextKit - Context Engineering for AI Development. Provide rich context to AI through structured MD files with standards, code guides, and documentation. Works with Cursor, Claude, Aider, VS Code Copilot, and more.",
5
5
  "main": "lib/index.js",
6
6
  "bin": {