@compilr-dev/sdk 0.2.4 → 0.2.6
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/dist/index.d.ts +2 -0
- package/dist/index.js +12 -0
- package/dist/platform/sqlite/db.js +5 -3
- package/dist/project-generator/detection.d.ts +42 -0
- package/dist/project-generator/detection.js +401 -0
- package/dist/project-generator/generator.d.ts +14 -0
- package/dist/project-generator/generator.js +245 -0
- package/dist/project-generator/index.d.ts +11 -0
- package/dist/project-generator/index.js +13 -0
- package/dist/project-generator/templates/coding-standards.d.ts +7 -0
- package/dist/project-generator/templates/coding-standards.js +299 -0
- package/dist/project-generator/templates/compilr-md-import.d.ts +8 -0
- package/dist/project-generator/templates/compilr-md-import.js +241 -0
- package/dist/project-generator/templates/compilr-md.d.ts +7 -0
- package/dist/project-generator/templates/compilr-md.js +141 -0
- package/dist/project-generator/templates/config-json.d.ts +13 -0
- package/dist/project-generator/templates/config-json.js +39 -0
- package/dist/project-generator/templates/gitignore.d.ts +7 -0
- package/dist/project-generator/templates/gitignore.js +85 -0
- package/dist/project-generator/templates/index.d.ts +11 -0
- package/dist/project-generator/templates/index.js +11 -0
- package/dist/project-generator/templates/package-json.d.ts +7 -0
- package/dist/project-generator/templates/package-json.js +111 -0
- package/dist/project-generator/templates/readme-md.d.ts +7 -0
- package/dist/project-generator/templates/readme-md.js +165 -0
- package/dist/project-generator/templates/tsconfig.d.ts +7 -0
- package/dist/project-generator/templates/tsconfig.js +61 -0
- package/dist/project-generator/types.d.ts +95 -0
- package/dist/project-generator/types.js +24 -0
- package/package.json +1 -1
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* README.md Template Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates the project README with next steps.
|
|
5
|
+
*/
|
|
6
|
+
import { TECH_STACK_LABELS } from '../types.js';
|
|
7
|
+
export function generateReadmeMd(config) {
|
|
8
|
+
const techStackSetup = getTechStackSetup(config.techStack);
|
|
9
|
+
return `# ${config.name}
|
|
10
|
+
|
|
11
|
+
${config.description}
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Getting Started
|
|
16
|
+
|
|
17
|
+
### Prerequisites
|
|
18
|
+
|
|
19
|
+
${getPrerequisites(config.techStack)}
|
|
20
|
+
|
|
21
|
+
### Installation
|
|
22
|
+
|
|
23
|
+
\`\`\`bash
|
|
24
|
+
cd ${config.name}
|
|
25
|
+
${techStackSetup.install}
|
|
26
|
+
\`\`\`
|
|
27
|
+
|
|
28
|
+
### Development
|
|
29
|
+
|
|
30
|
+
\`\`\`bash
|
|
31
|
+
${techStackSetup.dev}
|
|
32
|
+
\`\`\`
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Project Structure
|
|
37
|
+
|
|
38
|
+
\`\`\`
|
|
39
|
+
${config.name}/
|
|
40
|
+
├── src/ # Source code
|
|
41
|
+
${config.repoPattern === 'single'
|
|
42
|
+
? `├── .compilr/ # Workflow files (backlog, sessions, etc.)
|
|
43
|
+
├── COMPILR.md # AI assistant context`
|
|
44
|
+
: ''}
|
|
45
|
+
├── package.json
|
|
46
|
+
└── README.md
|
|
47
|
+
\`\`\`
|
|
48
|
+
${config.repoPattern === 'two-repo'
|
|
49
|
+
? `
|
|
50
|
+
**Documentation repo:** \`${config.name}-docs/\`
|
|
51
|
+
`
|
|
52
|
+
: ''}
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Next Steps
|
|
57
|
+
|
|
58
|
+
1. ${techStackSetup.nextSteps[0]}
|
|
59
|
+
2. ${techStackSetup.nextSteps[1]}
|
|
60
|
+
3. ${techStackSetup.nextSteps[2]}
|
|
61
|
+
4. Start coding with \`compilr start\`
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Workflow Commands
|
|
66
|
+
|
|
67
|
+
\`\`\`bash
|
|
68
|
+
compilr start # Begin coding session with context loaded
|
|
69
|
+
compilr save # Save session progress and generate notes
|
|
70
|
+
compilr backlog # View and manage tasks
|
|
71
|
+
compilr resume # Restore context after interruption
|
|
72
|
+
\`\`\`
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Tech Stack
|
|
77
|
+
|
|
78
|
+
**${TECH_STACK_LABELS[config.techStack]}**
|
|
79
|
+
|
|
80
|
+
${techStackSetup.description}
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
*Add your license here*
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
*Created with [compilr](https://compilr.dev)*
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
93
|
+
function getPrerequisites(techStack) {
|
|
94
|
+
const common = '- Node.js 20+\n- npm or yarn';
|
|
95
|
+
if (techStack === 'react-python-pg') {
|
|
96
|
+
return `${common}\n- Python 3.11+\n- PostgreSQL 15+`;
|
|
97
|
+
}
|
|
98
|
+
return `${common}\n- PostgreSQL 15+ (for database)`;
|
|
99
|
+
}
|
|
100
|
+
function getTechStackSetup(techStack) {
|
|
101
|
+
const setups = {
|
|
102
|
+
'react-node-pg': {
|
|
103
|
+
install: 'npm install',
|
|
104
|
+
dev: 'npm run dev',
|
|
105
|
+
description: `
|
|
106
|
+
| Layer | Technology |
|
|
107
|
+
|-------|------------|
|
|
108
|
+
| Frontend | React 18, Vite, TypeScript |
|
|
109
|
+
| Backend | Node.js, Express, TypeScript |
|
|
110
|
+
| Database | PostgreSQL |
|
|
111
|
+
| ORM | Prisma |
|
|
112
|
+
`,
|
|
113
|
+
nextSteps: [
|
|
114
|
+
'Install dependencies: `npm install`',
|
|
115
|
+
'Set up PostgreSQL and configure `.env`',
|
|
116
|
+
'Run database migrations: `npx prisma migrate dev`',
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
'react-python-pg': {
|
|
120
|
+
install: 'npm install # Frontend\npip install -r requirements.txt # Backend',
|
|
121
|
+
dev: 'npm run dev # Frontend\nuvicorn main:app --reload # Backend',
|
|
122
|
+
description: `
|
|
123
|
+
| Layer | Technology |
|
|
124
|
+
|-------|------------|
|
|
125
|
+
| Frontend | React 18, Vite, TypeScript |
|
|
126
|
+
| Backend | Python, FastAPI |
|
|
127
|
+
| Database | PostgreSQL |
|
|
128
|
+
| ORM | SQLAlchemy |
|
|
129
|
+
`,
|
|
130
|
+
nextSteps: [
|
|
131
|
+
'Install frontend deps: `npm install`',
|
|
132
|
+
'Install backend deps: `pip install -r requirements.txt`',
|
|
133
|
+
'Set up PostgreSQL and configure environment',
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
'vue-node-pg': {
|
|
137
|
+
install: 'npm install',
|
|
138
|
+
dev: 'npm run dev',
|
|
139
|
+
description: `
|
|
140
|
+
| Layer | Technology |
|
|
141
|
+
|-------|------------|
|
|
142
|
+
| Frontend | Vue 3, Vite, TypeScript |
|
|
143
|
+
| Backend | Node.js, Express, TypeScript |
|
|
144
|
+
| Database | PostgreSQL |
|
|
145
|
+
| ORM | Prisma |
|
|
146
|
+
`,
|
|
147
|
+
nextSteps: [
|
|
148
|
+
'Install dependencies: `npm install`',
|
|
149
|
+
'Set up PostgreSQL and configure `.env`',
|
|
150
|
+
'Run database migrations: `npx prisma migrate dev`',
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
custom: {
|
|
154
|
+
install: '# Add your installation command',
|
|
155
|
+
dev: '# Add your development command',
|
|
156
|
+
description: '*Configure your tech stack*',
|
|
157
|
+
nextSteps: [
|
|
158
|
+
'Choose and set up your tech stack',
|
|
159
|
+
'Configure development environment',
|
|
160
|
+
'Update this README with your stack details',
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
return setups[techStack] ?? setups.custom;
|
|
165
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TSConfig Template Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates a tsconfig.json file based on coding standards.
|
|
5
|
+
*/
|
|
6
|
+
export function generateTsconfig(config) {
|
|
7
|
+
const tsconfig = getTsconfigTemplate(config);
|
|
8
|
+
return JSON.stringify(tsconfig, null, 2) + '\n';
|
|
9
|
+
}
|
|
10
|
+
function getTsconfigTemplate(config) {
|
|
11
|
+
// Base config for all presets
|
|
12
|
+
const base = {
|
|
13
|
+
compilerOptions: {
|
|
14
|
+
target: 'ES2022',
|
|
15
|
+
useDefineForClassFields: true,
|
|
16
|
+
module: 'ESNext',
|
|
17
|
+
lib: ['ES2022', 'DOM', 'DOM.Iterable'],
|
|
18
|
+
skipLibCheck: true,
|
|
19
|
+
// Bundler mode
|
|
20
|
+
moduleResolution: 'bundler',
|
|
21
|
+
allowImportingTsExtensions: true,
|
|
22
|
+
resolveJsonModule: true,
|
|
23
|
+
isolatedModules: true,
|
|
24
|
+
noEmit: true,
|
|
25
|
+
// JSX for React/Vue
|
|
26
|
+
jsx: config.techStack === 'vue-node-pg' ? 'preserve' : 'react-jsx',
|
|
27
|
+
// Common strict settings
|
|
28
|
+
esModuleInterop: true,
|
|
29
|
+
forceConsistentCasingInFileNames: true,
|
|
30
|
+
},
|
|
31
|
+
include: ['src'],
|
|
32
|
+
exclude: ['node_modules'],
|
|
33
|
+
};
|
|
34
|
+
// Apply coding standards
|
|
35
|
+
if (config.codingStandards === 'strict') {
|
|
36
|
+
return {
|
|
37
|
+
...base,
|
|
38
|
+
compilerOptions: {
|
|
39
|
+
...base.compilerOptions,
|
|
40
|
+
strict: true,
|
|
41
|
+
noUncheckedIndexedAccess: true,
|
|
42
|
+
noImplicitReturns: true,
|
|
43
|
+
noFallthroughCasesInSwitch: true,
|
|
44
|
+
noUnusedLocals: true,
|
|
45
|
+
noUnusedParameters: true,
|
|
46
|
+
exactOptionalPropertyTypes: true,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (config.codingStandards === 'relaxed') {
|
|
51
|
+
return {
|
|
52
|
+
...base,
|
|
53
|
+
compilerOptions: {
|
|
54
|
+
...base.compilerOptions,
|
|
55
|
+
strict: true,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// Custom - minimal config
|
|
60
|
+
return base;
|
|
61
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Configuration Types
|
|
3
|
+
*
|
|
4
|
+
* Shared types for project initialization templates.
|
|
5
|
+
*/
|
|
6
|
+
export type TechStack = 'react-node-pg' | 'react-python-pg' | 'vue-node-pg' | 'custom';
|
|
7
|
+
export declare const TECH_STACK_LABELS: Record<TechStack, string>;
|
|
8
|
+
export type CodingStandards = 'strict' | 'relaxed' | 'custom';
|
|
9
|
+
export declare const CODING_STANDARDS_LABELS: Record<CodingStandards, string>;
|
|
10
|
+
export type GeneratorRepoPattern = 'single' | 'two-repo';
|
|
11
|
+
export declare const REPO_PATTERN_LABELS: Record<GeneratorRepoPattern, string>;
|
|
12
|
+
export interface ProjectConfig {
|
|
13
|
+
/** Project name (lowercase, alphanumeric + hyphens) */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Project description (1-2 sentences) */
|
|
16
|
+
description: string;
|
|
17
|
+
/** Repository pattern */
|
|
18
|
+
repoPattern: GeneratorRepoPattern;
|
|
19
|
+
/** Selected tech stack */
|
|
20
|
+
techStack: TechStack;
|
|
21
|
+
/** Coding standards preset */
|
|
22
|
+
codingStandards: CodingStandards;
|
|
23
|
+
/** Whether to initialize git */
|
|
24
|
+
initGit: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface GenerationResult {
|
|
27
|
+
success: boolean;
|
|
28
|
+
projectPath: string;
|
|
29
|
+
docsPath?: string;
|
|
30
|
+
filesCreated: string[];
|
|
31
|
+
error?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface CompilrConfig {
|
|
34
|
+
version: string;
|
|
35
|
+
project: {
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
createdAt: string;
|
|
39
|
+
};
|
|
40
|
+
paths: {
|
|
41
|
+
/** Absolute path to the project/code repository */
|
|
42
|
+
project: string;
|
|
43
|
+
/** Absolute path to the docs repository (two-repo pattern only) */
|
|
44
|
+
docs: string | null;
|
|
45
|
+
/** Directory where .compilr/config.json lives (for reference) */
|
|
46
|
+
workflowRoot: string;
|
|
47
|
+
};
|
|
48
|
+
settings: {
|
|
49
|
+
repoPattern: 'single' | 'two-repo';
|
|
50
|
+
techStack: string;
|
|
51
|
+
codingStandards: string;
|
|
52
|
+
};
|
|
53
|
+
sessions: {
|
|
54
|
+
count: number;
|
|
55
|
+
lastSession: string | null;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface DetectedProject {
|
|
59
|
+
/** Project name from package.json or folder name */
|
|
60
|
+
name: string;
|
|
61
|
+
/** Prettified display name */
|
|
62
|
+
displayName: string;
|
|
63
|
+
/** Source of the name (package.json, go.mod, folder) */
|
|
64
|
+
nameSource: 'package.json' | 'go.mod' | 'pyproject.toml' | 'Cargo.toml' | 'folder';
|
|
65
|
+
/** Detected primary language (null if unknown) */
|
|
66
|
+
language: string | null;
|
|
67
|
+
/** Detected framework (null if not detected) */
|
|
68
|
+
framework: string | null;
|
|
69
|
+
/** Detected package manager (null if not detected) */
|
|
70
|
+
packageManager: string | null;
|
|
71
|
+
/** Whether .git directory exists */
|
|
72
|
+
hasGit: boolean;
|
|
73
|
+
/** Git remote URL (null if not configured) */
|
|
74
|
+
gitRemote: string | null;
|
|
75
|
+
/** Current git branch (null if not in git repo) */
|
|
76
|
+
gitBranch: string | null;
|
|
77
|
+
/** Whether COMPILR.md exists */
|
|
78
|
+
hasCompilrMd: boolean;
|
|
79
|
+
/** Whether CLAUDE.md exists (alternative) */
|
|
80
|
+
hasClaudeMd: boolean;
|
|
81
|
+
}
|
|
82
|
+
export interface GitInfo {
|
|
83
|
+
hasGit: boolean;
|
|
84
|
+
remote: string | null;
|
|
85
|
+
branch: string | null;
|
|
86
|
+
}
|
|
87
|
+
export interface ImportProjectConfig {
|
|
88
|
+
name: string;
|
|
89
|
+
displayName: string;
|
|
90
|
+
description?: string;
|
|
91
|
+
path: string;
|
|
92
|
+
detected: DetectedProject;
|
|
93
|
+
workflowMode: 'flexible' | 'guided';
|
|
94
|
+
}
|
|
95
|
+
export declare const WORKFLOW_VERSION = "1.0.0";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Configuration Types
|
|
3
|
+
*
|
|
4
|
+
* Shared types for project initialization templates.
|
|
5
|
+
*/
|
|
6
|
+
export const TECH_STACK_LABELS = {
|
|
7
|
+
'react-node-pg': 'React + Node.js + PostgreSQL',
|
|
8
|
+
'react-python-pg': 'React + Python + PostgreSQL',
|
|
9
|
+
'vue-node-pg': 'Vue + Node.js + PostgreSQL',
|
|
10
|
+
custom: 'Custom (configure later)',
|
|
11
|
+
};
|
|
12
|
+
export const CODING_STANDARDS_LABELS = {
|
|
13
|
+
strict: 'TypeScript Strict (recommended)',
|
|
14
|
+
relaxed: 'TypeScript Relaxed',
|
|
15
|
+
custom: 'Custom (configure later)',
|
|
16
|
+
};
|
|
17
|
+
export const REPO_PATTERN_LABELS = {
|
|
18
|
+
single: 'Single repo (.compilr/ folder + COMPILR.md in project root)',
|
|
19
|
+
'two-repo': 'Two repos (project/ + project-docs/ separate repositories)',
|
|
20
|
+
};
|
|
21
|
+
// =============================================================================
|
|
22
|
+
// Workflow Version
|
|
23
|
+
// =============================================================================
|
|
24
|
+
export const WORKFLOW_VERSION = '1.0.0';
|