cortex-tms 2.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/LICENSE +21 -0
- package/README.md +258 -0
- package/bin/cortex-tms.js +34 -0
- package/dist/__tests__/init.test.d.ts +2 -0
- package/dist/__tests__/init.test.d.ts.map +1 -0
- package/dist/__tests__/init.test.js +172 -0
- package/dist/__tests__/init.test.js.map +1 -0
- package/dist/__tests__/utils/temp-dir.d.ts +6 -0
- package/dist/__tests__/utils/temp-dir.d.ts.map +1 -0
- package/dist/__tests__/utils/temp-dir.js +34 -0
- package/dist/__tests__/utils/temp-dir.js.map +1 -0
- package/dist/__tests__/validate.test.d.ts +2 -0
- package/dist/__tests__/validate.test.d.ts.map +1 -0
- package/dist/__tests__/validate.test.js +207 -0
- package/dist/__tests__/validate.test.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +32 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +121 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/validate.d.ts +4 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +151 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/types/cli.d.ts +94 -0
- package/dist/types/cli.d.ts.map +1 -0
- package/dist/types/cli.js +2 -0
- package/dist/types/cli.js.map +1 -0
- package/dist/utils/config.d.ts +13 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +185 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/detection.d.ts +5 -0
- package/dist/utils/detection.d.ts.map +1 -0
- package/dist/utils/detection.js +60 -0
- package/dist/utils/detection.js.map +1 -0
- package/dist/utils/prompts.d.ts +5 -0
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +82 -0
- package/dist/utils/prompts.js.map +1 -0
- package/dist/utils/templates.d.ts +14 -0
- package/dist/utils/templates.d.ts.map +1 -0
- package/dist/utils/templates.js +98 -0
- package/dist/utils/templates.js.map +1 -0
- package/dist/utils/validator.d.ts +12 -0
- package/dist/utils/validator.d.ts.map +1 -0
- package/dist/utils/validator.js +241 -0
- package/dist/utils/validator.js.map +1 -0
- package/package.json +69 -0
- package/templates/.github/copilot-instructions.md +28 -0
- package/templates/CLAUDE.md +18 -0
- package/templates/FUTURE-ENHANCEMENTS.md +79 -0
- package/templates/NEXT-TASKS.md +20 -0
- package/templates/README.md +172 -0
- package/templates/docs/archive/v1.0-CHANGELOG.md +0 -0
- package/templates/docs/core/ARCHITECTURE.md +102 -0
- package/templates/docs/core/DECISIONS.md +83 -0
- package/templates/docs/core/DOMAIN-LOGIC.md +8 -0
- package/templates/docs/core/GLOSSARY.md +66 -0
- package/templates/docs/core/PATTERNS.md +55 -0
- package/templates/docs/core/SCHEMA.md +246 -0
- package/templates/docs/core/TROUBLESHOOTING.md +325 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Cortex TMS Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# Cortex TMS 🧠
|
|
2
|
+
|
|
3
|
+
**The Universal AI-Optimized Project Boilerplate (v2.1.0)**
|
|
4
|
+
|
|
5
|
+
Cortex TMS is a **meta-framework** for organizing project documentation to maximize AI agent performance. It's not a runtime library—it's a **structural pattern** that separates high-signal "Source of Truth" from noisy "Historical Context."
|
|
6
|
+
|
|
7
|
+
**Current Status**: ✅ **Production Ready** | [NPM Package](https://www.npmjs.com/package/cortex-tms) | [GitHub Template](https://github.com/cortex-tms/cortex-tms)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 🚀 Quick Start
|
|
12
|
+
|
|
13
|
+
### Option 1: CLI Tool (Recommended)
|
|
14
|
+
|
|
15
|
+
Get started in under 60 seconds:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
mkdir my-project && cd my-project
|
|
19
|
+
npx cortex-tms init
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Choose your scope (Nano/Standard/Enterprise) and start building with AI-optimized documentation.
|
|
23
|
+
|
|
24
|
+
### Option 2: GitHub Template
|
|
25
|
+
|
|
26
|
+
Click "Use this template" on the repository homepage to create a new project with all TMS files pre-configured.
|
|
27
|
+
|
|
28
|
+
### Option 3: Manual Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install -g cortex-tms
|
|
32
|
+
cortex-tms init --scope standard
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
📖 **New here?** Read the [Quick Start Guide](docs/guides/QUICK-START.md) or [Migration Guide](docs/guides/MIGRATION-GUIDE.md) for existing projects.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 🚀 The Philosophy: Signal over Noise
|
|
40
|
+
|
|
41
|
+
Traditional repos drown AI agents in thousands of lines of historical tasks and stale documentation. **Cortex TMS** forces the agent into a "Tiered" approach:
|
|
42
|
+
|
|
43
|
+
1. **HOT (Active)**: `NEXT-TASKS.md` — What we are doing _now_.
|
|
44
|
+
2. **WARM (Truth)**: `docs/core/` — The project's "Laws" (Architecture, Patterns, Domain Logic).
|
|
45
|
+
3. **COLD (History)**: `docs/archive/` — Historical changelogs (Ignore unless asked).
|
|
46
|
+
|
|
47
|
+
**Why this works**: AI agents have limited context windows. Reading everything is wasteful. The tier system maximizes signal, minimizes noise.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 📂 Documentation Structure
|
|
52
|
+
|
|
53
|
+
| Folder / File | Purpose | AI Context Tier |
|
|
54
|
+
|:-------------|:--------|:---------------|
|
|
55
|
+
| `NEXT-TASKS.md` | Active sprint and current focus | **HOT** (Always Read) |
|
|
56
|
+
| `FUTURE-ENHANCEMENTS.md` | Living backlog (not current sprint) | **PLANNING** |
|
|
57
|
+
| `CLAUDE.md` | CLI commands & workflow config | **HOT** (Always Read) |
|
|
58
|
+
| `.github/copilot-instructions.md` | Global guardrails and critical rules | **HOT** (Always Read) |
|
|
59
|
+
| `docs/core/ARCHITECTURE.md` | System design & tech stack | **WARM** (Read on Demand) |
|
|
60
|
+
| `docs/core/PATTERNS.md` | Canonical code examples (Do/Don't) | **WARM** (Read on Demand) |
|
|
61
|
+
| `docs/core/DOMAIN-LOGIC.md` | Immutable project rules | **WARM** (Read on Demand) |
|
|
62
|
+
| `docs/core/GIT-STANDARDS.md` | Git & PM conventions | **WARM** (Read on Demand) |
|
|
63
|
+
| `docs/core/DECISIONS.md` | Architecture Decision Records | **WARM** (Read on Demand) |
|
|
64
|
+
| `docs/core/GLOSSARY.md` | Project terminology | **WARM** (Read on Demand) |
|
|
65
|
+
| `docs/core/SCHEMA.md` | Data models (optional) | **WARM** (Read on Demand) |
|
|
66
|
+
| `docs/core/TROUBLESHOOTING.md` | Framework gotchas (optional) | **WARM** (Read on Demand) |
|
|
67
|
+
| `docs/archive/` | Historical changelogs | **COLD** (Ignore) |
|
|
68
|
+
| `templates/` | Boilerplate files for user projects | N/A (Toolkit) |
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 🎯 What Cortex TMS Provides
|
|
73
|
+
|
|
74
|
+
### For New Projects (Greenfield)
|
|
75
|
+
- **GitHub Template Repository**: Click "Use this template" to start a new AI-optimized project
|
|
76
|
+
- Pre-configured TMS structure
|
|
77
|
+
- Ready-to-customize templates
|
|
78
|
+
|
|
79
|
+
### For Existing Projects (Brownfield)
|
|
80
|
+
- **NPM CLI Tool**: `npx cortex-tms init` (Coming in Phase 4)
|
|
81
|
+
- Detects existing structure
|
|
82
|
+
- Merges TMS templates safely
|
|
83
|
+
|
|
84
|
+
### For Developers
|
|
85
|
+
- **Example Projects**: Reference implementations (Next.js, CLI tools, APIs)
|
|
86
|
+
- **Best Practices Guide**: How to write effective patterns and domain logic
|
|
87
|
+
- **Migration Guide**: How to adopt TMS incrementally
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 🤖 How to Work with AI Agents in this Repo
|
|
92
|
+
|
|
93
|
+
This repo is a **"Machine-Legible Project Constitution."** To get the best results from your AI pair programmer:
|
|
94
|
+
|
|
95
|
+
1. **The Context Trigger**: Start a session by saying:
|
|
96
|
+
> _"Review NEXT-TASKS.md and docs/core. Suggest a plan for Task 1 using the Propose, Justify, Recommend framework."_
|
|
97
|
+
|
|
98
|
+
2. **Pattern Enforcement**: When implementing a new component, say:
|
|
99
|
+
> _"Follow the patterns in docs/core/PATTERNS.md."_
|
|
100
|
+
|
|
101
|
+
3. **Truth Anchoring**: If the AI hallucinates logic, point it to `DOMAIN-LOGIC.md`:
|
|
102
|
+
> _"Your calculation is wrong. Refer to the rules in docs/core/DOMAIN-LOGIC.md."_
|
|
103
|
+
|
|
104
|
+
4. **Check Current Sprint**: Always ask:
|
|
105
|
+
> _"What's in NEXT-TASKS.md? What should I work on?"_
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 🛠 Setup (For Cortex TMS Development)
|
|
110
|
+
|
|
111
|
+
**Prerequisites**:
|
|
112
|
+
- Node.js (managed via FN - Fast Node Manager)
|
|
113
|
+
- pnpm (package manager)
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# 1. Clone the repository
|
|
117
|
+
git clone https://github.com/yourusername/cortex-tms.git
|
|
118
|
+
cd cortex-tms
|
|
119
|
+
|
|
120
|
+
# 2. Install dependencies
|
|
121
|
+
pnpm install
|
|
122
|
+
|
|
123
|
+
# 3. Review current tasks
|
|
124
|
+
cat NEXT-TASKS.md
|
|
125
|
+
|
|
126
|
+
# 4. Read the core documentation
|
|
127
|
+
# - docs/core/ARCHITECTURE.md - System design
|
|
128
|
+
# - docs/core/DOMAIN-LOGIC.md - TMS principles
|
|
129
|
+
# - docs/core/PATTERNS.md - Template patterns
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 📋 Development Roadmap
|
|
135
|
+
|
|
136
|
+
See `NEXT-TASKS.md` for current sprint and `FUTURE-ENHANCEMENTS.md` for backlog.
|
|
137
|
+
|
|
138
|
+
**Completed Phases**:
|
|
139
|
+
- [x] **Phase 1**: Dogfood the System - Apply TMS to Cortex itself
|
|
140
|
+
- [x] **Phase 1.5**: Resolve Rule 4 Violation - Modularize Git standards
|
|
141
|
+
- [x] **Phase 2**: Complete Template Library - All 15 templates built and validated
|
|
142
|
+
- [x] **Phase 3**: Build Example App - Gold Standard Next.js 15 Todo App ✨
|
|
143
|
+
- ✅ Full CRUD operations (create, read, update, delete, clear completed)
|
|
144
|
+
- ✅ Polished UX with empty states, bulk actions, and accessibility features
|
|
145
|
+
- ✅ Complete TMS documentation (ARCHITECTURE, PATTERNS, DOMAIN-LOGIC, SCHEMA)
|
|
146
|
+
- ✅ 10 documented implementation patterns with canonical examples
|
|
147
|
+
- ✅ Production build verified, TypeScript strict mode, lint passing
|
|
148
|
+
- 📍 **Location**: [`examples/todo-app/`](./examples/todo-app/)
|
|
149
|
+
|
|
150
|
+
**Current Phase**: Phase 4 - Create CLI Tool (🔄 In Progress)
|
|
151
|
+
- [ ] Design CLI architecture with Commander.js
|
|
152
|
+
- [ ] Implement interactive prompts with Inquirer.js
|
|
153
|
+
- [ ] Add template copy with placeholder replacement
|
|
154
|
+
- [ ] Support greenfield and brownfield scenarios
|
|
155
|
+
- [ ] Test `npx cortex-tms init` workflow
|
|
156
|
+
|
|
157
|
+
**Future Phases**:
|
|
158
|
+
- Phase 5: Write documentation guides (Quick Start, Migration, Best Practices)
|
|
159
|
+
- Phase 6: Publish to npm + GitHub Template
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## 🏗️ Project Structure
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
cortex-tms/
|
|
167
|
+
├── NEXT-TASKS.md # HOT: Current sprint
|
|
168
|
+
├── FUTURE-ENHANCEMENTS.md # PLANNING: Backlog
|
|
169
|
+
├── CLAUDE.md # HOT: Workflow config
|
|
170
|
+
├── README.md # This file
|
|
171
|
+
├── .github/
|
|
172
|
+
│ └── copilot-instructions.md # HOT: AI guardrails
|
|
173
|
+
├── templates/ # User-facing boilerplate
|
|
174
|
+
│ ├── NEXT-TASKS.md
|
|
175
|
+
│ ├── CLAUDE.md
|
|
176
|
+
│ ├── .github/
|
|
177
|
+
│ │ └── copilot-instructions.md
|
|
178
|
+
│ └── docs/
|
|
179
|
+
│ ├── core/
|
|
180
|
+
│ │ ├── ARCHITECTURE.md
|
|
181
|
+
│ │ ├── PATTERNS.md
|
|
182
|
+
│ │ ├── DOMAIN-LOGIC.md
|
|
183
|
+
│ │ ├── DECISIONS.md
|
|
184
|
+
│ │ ├── GLOSSARY.md
|
|
185
|
+
│ │ ├── SCHEMA.md
|
|
186
|
+
│ │ └── TROUBLESHOOTING.md
|
|
187
|
+
│ └── archive/
|
|
188
|
+
│ └── v1.0-CHANGELOG.md
|
|
189
|
+
├── docs/ # Cortex TMS documentation
|
|
190
|
+
│ ├── core/
|
|
191
|
+
│ │ ├── ARCHITECTURE.md
|
|
192
|
+
│ │ ├── PATTERNS.md
|
|
193
|
+
│ │ ├── DOMAIN-LOGIC.md
|
|
194
|
+
│ │ ├── DECISIONS.md
|
|
195
|
+
│ │ ├── GLOSSARY.md
|
|
196
|
+
│ │ └── PHILOSOPHY.md
|
|
197
|
+
│ └── archive/
|
|
198
|
+
│ └── v1.0-CHANGELOG.md
|
|
199
|
+
├── examples/ # Reference implementations
|
|
200
|
+
│ └── todo-app/ # ✅ Gold Standard Next.js 15 Todo App
|
|
201
|
+
├── bin/ # CLI tool entry point
|
|
202
|
+
└── src/ # CLI tool source code
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 🧪 Validation: Dogfooding
|
|
208
|
+
|
|
209
|
+
**This repository uses TMS to build itself.**
|
|
210
|
+
|
|
211
|
+
- Cortex's own `NEXT-TASKS.md` tracks Cortex development
|
|
212
|
+
- Cortex's own `docs/core/PATTERNS.md` documents template patterns
|
|
213
|
+
- If the structure doesn't work for Cortex, it won't work for users
|
|
214
|
+
|
|
215
|
+
**Validation Test**: "Can an AI agent working on Cortex find what it needs in < 3 file reads?"
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## 📚 Key Documentation
|
|
220
|
+
|
|
221
|
+
- **For AI Agents**: Read `.github/copilot-instructions.md` first
|
|
222
|
+
- **For Developers**: Read `docs/core/ARCHITECTURE.md` for system design
|
|
223
|
+
- **For Contributors**: Read `docs/core/PATTERNS.md` for template patterns
|
|
224
|
+
- **For Understanding**: Read `docs/core/DOMAIN-LOGIC.md` for TMS principles
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## 🤝 Contributing
|
|
229
|
+
|
|
230
|
+
1. Read `NEXT-TASKS.md` to see what's being worked on
|
|
231
|
+
2. Check `FUTURE-ENHANCEMENTS.md` for backlog items
|
|
232
|
+
3. Follow patterns in `docs/core/PATTERNS.md`
|
|
233
|
+
4. Verify changes against `docs/core/DOMAIN-LOGIC.md`
|
|
234
|
+
5. Test templates with AI agents before submitting
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## 📖 Learn More
|
|
239
|
+
|
|
240
|
+
- **Philosophy**: See `docs/core/PHILOSOPHY.md` (coming soon)
|
|
241
|
+
- **Architecture**: See `docs/core/ARCHITECTURE.md`
|
|
242
|
+
- **Decisions**: See `docs/core/DECISIONS.md` for ADRs
|
|
243
|
+
- **Glossary**: See `docs/core/GLOSSARY.md` for terminology
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## License
|
|
248
|
+
|
|
249
|
+
MIT
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Status
|
|
254
|
+
|
|
255
|
+
**Version**: 2.1 (In Development)
|
|
256
|
+
**Last Updated**: 2026-01-12
|
|
257
|
+
**Current Sprint**: Phase 4 - CLI Tool 🔄 In Progress
|
|
258
|
+
**Completed Sprints**: Phase 1, 1.5, 2, 3 (see `docs/archive/sprint-2026-01.md`)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cortex TMS CLI - Executable Wrapper
|
|
5
|
+
*
|
|
6
|
+
* This is a minimal shebang wrapper that delegates to the TypeScript source.
|
|
7
|
+
*
|
|
8
|
+
* In development: Uses tsx to execute TypeScript directly
|
|
9
|
+
* In production: Will execute compiled JavaScript from dist/
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { createRequire } from 'module';
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
14
|
+
import { dirname, join } from 'path';
|
|
15
|
+
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const __dirname = dirname(__filename);
|
|
18
|
+
const require = createRequire(import.meta.url);
|
|
19
|
+
|
|
20
|
+
// Check if we're running from source (dev) or compiled (prod)
|
|
21
|
+
const isSource = process.env.NODE_ENV !== 'production';
|
|
22
|
+
|
|
23
|
+
if (isSource) {
|
|
24
|
+
// Development: Use tsx to run TypeScript directly
|
|
25
|
+
const { register } = await import('tsx/esm/api');
|
|
26
|
+
const unregister = register();
|
|
27
|
+
|
|
28
|
+
await import(join(__dirname, '../src/cli.js'));
|
|
29
|
+
|
|
30
|
+
unregister();
|
|
31
|
+
} else {
|
|
32
|
+
// Production: Run compiled JavaScript
|
|
33
|
+
await import(join(__dirname, '../dist/cli.js'));
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/init.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { createTempDir, cleanupTempDir, fileExists, } from './utils/temp-dir.js';
|
|
4
|
+
import { copyTemplates, getTemplatesDir, generateReplacements, replacePlaceholders, } from '../utils/templates.js';
|
|
5
|
+
import { createConfigFromScope, saveConfig, loadConfig } from '../utils/config.js';
|
|
6
|
+
describe('Init Command - Scope Filtering', () => {
|
|
7
|
+
let tempDir;
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
tempDir = await createTempDir();
|
|
10
|
+
});
|
|
11
|
+
afterEach(async () => {
|
|
12
|
+
await cleanupTempDir(tempDir);
|
|
13
|
+
});
|
|
14
|
+
it('should copy exactly 2 files when scope is "nano"', async () => {
|
|
15
|
+
const templatesDir = getTemplatesDir();
|
|
16
|
+
const replacements = generateReplacements('test-project');
|
|
17
|
+
const result = await copyTemplates(templatesDir, tempDir, replacements, {
|
|
18
|
+
scope: 'nano',
|
|
19
|
+
overwrite: true,
|
|
20
|
+
});
|
|
21
|
+
expect(result.copied).toBe(2);
|
|
22
|
+
expect(result.skipped).toBe(0);
|
|
23
|
+
expect(await fileExists(join(tempDir, 'NEXT-TASKS.md'))).toBe(true);
|
|
24
|
+
expect(await fileExists(join(tempDir, 'CLAUDE.md'))).toBe(true);
|
|
25
|
+
expect(await fileExists(join(tempDir, 'FUTURE-ENHANCEMENTS.md'))).toBe(false);
|
|
26
|
+
expect(await fileExists(join(tempDir, 'docs/core/ARCHITECTURE.md'))).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
it('should copy exactly 9 files when scope is "standard"', async () => {
|
|
29
|
+
const templatesDir = getTemplatesDir();
|
|
30
|
+
const replacements = generateReplacements('test-project');
|
|
31
|
+
const result = await copyTemplates(templatesDir, tempDir, replacements, {
|
|
32
|
+
scope: 'standard',
|
|
33
|
+
overwrite: true,
|
|
34
|
+
});
|
|
35
|
+
expect(result.copied).toBe(9);
|
|
36
|
+
expect(result.skipped).toBe(0);
|
|
37
|
+
expect(await fileExists(join(tempDir, 'NEXT-TASKS.md'))).toBe(true);
|
|
38
|
+
expect(await fileExists(join(tempDir, 'CLAUDE.md'))).toBe(true);
|
|
39
|
+
expect(await fileExists(join(tempDir, '.github/copilot-instructions.md'))).toBe(true);
|
|
40
|
+
expect(await fileExists(join(tempDir, 'FUTURE-ENHANCEMENTS.md'))).toBe(true);
|
|
41
|
+
expect(await fileExists(join(tempDir, 'docs/core/ARCHITECTURE.md'))).toBe(true);
|
|
42
|
+
expect(await fileExists(join(tempDir, 'docs/core/PATTERNS.md'))).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
it('should copy exactly 11 files when scope is "enterprise"', async () => {
|
|
45
|
+
const templatesDir = getTemplatesDir();
|
|
46
|
+
const replacements = generateReplacements('test-project');
|
|
47
|
+
const result = await copyTemplates(templatesDir, tempDir, replacements, {
|
|
48
|
+
scope: 'enterprise',
|
|
49
|
+
overwrite: true,
|
|
50
|
+
});
|
|
51
|
+
expect(result.copied).toBe(11);
|
|
52
|
+
expect(result.skipped).toBe(0);
|
|
53
|
+
expect(await fileExists(join(tempDir, 'docs/core/GLOSSARY.md'))).toBe(true);
|
|
54
|
+
expect(await fileExists(join(tempDir, 'docs/core/SCHEMA.md'))).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
it('should never copy example files regardless of scope', async () => {
|
|
57
|
+
const templatesDir = getTemplatesDir();
|
|
58
|
+
const replacements = generateReplacements('test-project');
|
|
59
|
+
for (const scope of ['nano', 'standard', 'enterprise']) {
|
|
60
|
+
const scopeTempDir = await createTempDir();
|
|
61
|
+
await copyTemplates(templatesDir, scopeTempDir, replacements, {
|
|
62
|
+
scope,
|
|
63
|
+
overwrite: true,
|
|
64
|
+
});
|
|
65
|
+
expect(await fileExists(join(scopeTempDir, 'examples'))).toBe(false);
|
|
66
|
+
await cleanupTempDir(scopeTempDir);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
it('should skip existing files when overwrite is false', async () => {
|
|
70
|
+
const templatesDir = getTemplatesDir();
|
|
71
|
+
const replacements = generateReplacements('test-project');
|
|
72
|
+
const result1 = await copyTemplates(templatesDir, tempDir, replacements, {
|
|
73
|
+
scope: 'nano',
|
|
74
|
+
overwrite: false,
|
|
75
|
+
});
|
|
76
|
+
expect(result1.copied).toBe(2);
|
|
77
|
+
expect(result1.skipped).toBe(0);
|
|
78
|
+
const result2 = await copyTemplates(templatesDir, tempDir, replacements, {
|
|
79
|
+
scope: 'nano',
|
|
80
|
+
overwrite: false,
|
|
81
|
+
});
|
|
82
|
+
expect(result2.copied).toBe(0);
|
|
83
|
+
expect(result2.skipped).toBe(2);
|
|
84
|
+
});
|
|
85
|
+
it('should overwrite existing files when overwrite is true', async () => {
|
|
86
|
+
const templatesDir = getTemplatesDir();
|
|
87
|
+
const replacements = generateReplacements('test-project');
|
|
88
|
+
await copyTemplates(templatesDir, tempDir, replacements, {
|
|
89
|
+
scope: 'nano',
|
|
90
|
+
overwrite: true,
|
|
91
|
+
});
|
|
92
|
+
const result2 = await copyTemplates(templatesDir, tempDir, replacements, {
|
|
93
|
+
scope: 'nano',
|
|
94
|
+
overwrite: true,
|
|
95
|
+
});
|
|
96
|
+
expect(result2.copied).toBe(2);
|
|
97
|
+
expect(result2.skipped).toBe(0);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
describe('Init Command - Placeholder Replacement', () => {
|
|
101
|
+
let tempDir;
|
|
102
|
+
beforeEach(async () => {
|
|
103
|
+
tempDir = await createTempDir();
|
|
104
|
+
});
|
|
105
|
+
afterEach(async () => {
|
|
106
|
+
await cleanupTempDir(tempDir);
|
|
107
|
+
});
|
|
108
|
+
it('should correctly generate replacement map with project name', async () => {
|
|
109
|
+
const replacements = generateReplacements('My Awesome Project');
|
|
110
|
+
expect(replacements['Project Name']).toBe('My Awesome Project');
|
|
111
|
+
expect(replacements['project-name']).toBe('my-awesome-project');
|
|
112
|
+
expect(replacements['Description']).toBe('A project powered by Cortex TMS');
|
|
113
|
+
});
|
|
114
|
+
it('should replace placeholders in template content', async () => {
|
|
115
|
+
const content = 'Project: [Project Name] (slug: [project-name])\n[Description]';
|
|
116
|
+
const replacements = generateReplacements('My Awesome Project', 'A cool project');
|
|
117
|
+
const result = replacePlaceholders(content, replacements);
|
|
118
|
+
expect(result).toContain('My Awesome Project');
|
|
119
|
+
expect(result).toContain('my-awesome-project');
|
|
120
|
+
expect(result).toContain('A cool project');
|
|
121
|
+
expect(result).not.toContain('[Project Name]');
|
|
122
|
+
expect(result).not.toContain('[project-name]');
|
|
123
|
+
expect(result).not.toContain('[Description]');
|
|
124
|
+
});
|
|
125
|
+
it('should handle projects with special characters', async () => {
|
|
126
|
+
const projectName = 'Test@Project#123!!!';
|
|
127
|
+
const replacements = generateReplacements(projectName);
|
|
128
|
+
expect(replacements['project-name']).toBe('test-project-123');
|
|
129
|
+
});
|
|
130
|
+
it('should replace [Description] when provided', async () => {
|
|
131
|
+
const content = 'This is [Description] test';
|
|
132
|
+
const replacements = generateReplacements('Test', 'A cool project');
|
|
133
|
+
const result = replacePlaceholders(content, replacements);
|
|
134
|
+
expect(result).toBe('This is A cool project test');
|
|
135
|
+
});
|
|
136
|
+
it('should use default description when not provided', async () => {
|
|
137
|
+
const replacements = generateReplacements('Test');
|
|
138
|
+
expect(replacements.Description).toBe('A project powered by Cortex TMS');
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
describe('Init Command - Configuration Generation', () => {
|
|
142
|
+
let tempDir;
|
|
143
|
+
beforeEach(async () => {
|
|
144
|
+
tempDir = await createTempDir();
|
|
145
|
+
});
|
|
146
|
+
afterEach(async () => {
|
|
147
|
+
await cleanupTempDir(tempDir);
|
|
148
|
+
});
|
|
149
|
+
it('should create .cortexrc with correct scope', async () => {
|
|
150
|
+
const config = createConfigFromScope('nano', 'test-project');
|
|
151
|
+
await saveConfig(tempDir, config);
|
|
152
|
+
const loadedConfig = await loadConfig(tempDir);
|
|
153
|
+
expect(loadedConfig).not.toBeNull();
|
|
154
|
+
expect(loadedConfig?.scope).toBe('nano');
|
|
155
|
+
expect(loadedConfig?.metadata?.projectName).toBe('test-project');
|
|
156
|
+
});
|
|
157
|
+
it('should set correct line limits for nano scope', async () => {
|
|
158
|
+
const config = createConfigFromScope('nano');
|
|
159
|
+
expect(config.limits?.['NEXT-TASKS.md']).toBe(100);
|
|
160
|
+
});
|
|
161
|
+
it('should set correct line limits for enterprise scope', async () => {
|
|
162
|
+
const config = createConfigFromScope('enterprise');
|
|
163
|
+
expect(config.limits?.['NEXT-TASKS.md']).toBe(300);
|
|
164
|
+
expect(config.limits?.['ARCHITECTURE.md']).toBe(800);
|
|
165
|
+
});
|
|
166
|
+
it('should include creation timestamp in metadata', async () => {
|
|
167
|
+
const config = createConfigFromScope('standard', 'test-project');
|
|
168
|
+
expect(config.metadata?.created).toBeDefined();
|
|
169
|
+
expect(new Date(config.metadata.created).getTime()).toBeLessThanOrEqual(Date.now());
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
//# sourceMappingURL=init.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.test.js","sourceRoot":"","sources":["../../src/__tests__/init.test.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EACL,aAAa,EACb,cAAc,EACd,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEnF,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,IAAI,OAAe,CAAC;IAEpB,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,OAAO,GAAG,MAAM,aAAa,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAChE,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;QACvC,MAAM,YAAY,GAAG,oBAAoB,CAAC,cAAc,CAAC,CAAC;QAE1D,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE;YACtE,KAAK,EAAE,MA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+1,6 @@
|
|
|
1
|
+
export declare function createTempDir(): Promise<string>;
|
|
2
|
+
export declare function cleanupTempDir(dirPath: string): Promise<void>;
|
|
3
|
+
export declare function getFiles(dirPath: string): Promise<string[]>;
|
|
4
|
+
export declare function fileExists(filePath: string): Promise<boolean>;
|
|
5
|
+
export declare function readFile(filePath: string): Promise<string>;
|
|
6
|
+
//# sourceMappingURL=temp-dir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temp-dir.d.ts","sourceRoot":"","sources":["../../../src/__tests__/utils/temp-dir.ts"],"names":[],"mappings":"AAcA,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAGrD;AAMD,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOnE;AAKD,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAGjE;AAKD,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQnE;AAKD,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGhE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { mkdtemp, rm } from 'fs/promises';
|
|
2
|
+
import { tmpdir } from 'os';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
export async function createTempDir() {
|
|
5
|
+
const prefix = join(tmpdir(), 'cortex-test-');
|
|
6
|
+
return await mkdtemp(prefix);
|
|
7
|
+
}
|
|
8
|
+
export async function cleanupTempDir(dirPath) {
|
|
9
|
+
try {
|
|
10
|
+
await rm(dirPath, { recursive: true, force: true });
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
console.warn(`Warning: Failed to cleanup ${dirPath}:`, error);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export async function getFiles(dirPath) {
|
|
17
|
+
const { readdir } = await import('fs/promises');
|
|
18
|
+
return await readdir(dirPath);
|
|
19
|
+
}
|
|
20
|
+
export async function fileExists(filePath) {
|
|
21
|
+
const { access } = await import('fs/promises');
|
|
22
|
+
try {
|
|
23
|
+
await access(filePath);
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export async function readFile(filePath) {
|
|
31
|
+
const { readFile: fsReadFile } = await import('fs/promises');
|
|
32
|
+
return await fsReadFile(filePath, 'utf-8');
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=temp-dir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temp-dir.js","sourceRoot":"","sources":["../../../src/__tests__/utils/temp-dir.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAM5B,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,cAAc,CAAC,CAAC;IAC9C,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC;AAMD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAe;IAClD,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAEf,OAAO,CAAC,IAAI,CAAC,8BAA8B,OAAO,GAAG,EAAE,KAAK,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAKD,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAe;IAC5C,MA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