@compilr-dev/sdk 0.2.5 → 0.2.7

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 (33) hide show
  1. package/dist/index.d.ts +4 -1
  2. package/dist/index.js +13 -1
  3. package/dist/platform/file-anchor-service.d.ts +62 -0
  4. package/dist/platform/file-anchor-service.js +241 -0
  5. package/dist/platform/index.d.ts +2 -0
  6. package/dist/platform/index.js +2 -0
  7. package/dist/project-generator/detection.d.ts +42 -0
  8. package/dist/project-generator/detection.js +401 -0
  9. package/dist/project-generator/generator.d.ts +14 -0
  10. package/dist/project-generator/generator.js +245 -0
  11. package/dist/project-generator/index.d.ts +11 -0
  12. package/dist/project-generator/index.js +13 -0
  13. package/dist/project-generator/templates/coding-standards.d.ts +7 -0
  14. package/dist/project-generator/templates/coding-standards.js +299 -0
  15. package/dist/project-generator/templates/compilr-md-import.d.ts +8 -0
  16. package/dist/project-generator/templates/compilr-md-import.js +241 -0
  17. package/dist/project-generator/templates/compilr-md.d.ts +7 -0
  18. package/dist/project-generator/templates/compilr-md.js +141 -0
  19. package/dist/project-generator/templates/config-json.d.ts +13 -0
  20. package/dist/project-generator/templates/config-json.js +39 -0
  21. package/dist/project-generator/templates/gitignore.d.ts +7 -0
  22. package/dist/project-generator/templates/gitignore.js +85 -0
  23. package/dist/project-generator/templates/index.d.ts +11 -0
  24. package/dist/project-generator/templates/index.js +11 -0
  25. package/dist/project-generator/templates/package-json.d.ts +7 -0
  26. package/dist/project-generator/templates/package-json.js +111 -0
  27. package/dist/project-generator/templates/readme-md.d.ts +7 -0
  28. package/dist/project-generator/templates/readme-md.js +165 -0
  29. package/dist/project-generator/templates/tsconfig.d.ts +7 -0
  30. package/dist/project-generator/templates/tsconfig.js +61 -0
  31. package/dist/project-generator/types.d.ts +95 -0
  32. package/dist/project-generator/types.js +24 -0
  33. package/package.json +1 -1
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Config JSON Template Generator
3
+ *
4
+ * Generates the .compilr/config.json file for workflow versioning and settings.
5
+ */
6
+ import { WORKFLOW_VERSION } from '../types.js';
7
+ /**
8
+ * Generate config.json content
9
+ * @param config Project configuration
10
+ * @param projectPath Absolute path to the project folder
11
+ * @param docsPath Absolute path to the docs folder (for two-repo pattern)
12
+ */
13
+ export function generateConfigJson(config, projectPath, docsPath) {
14
+ // Determine workflow root (where config.json lives)
15
+ const workflowRoot = config.repoPattern === 'two-repo' ? docsPath : projectPath;
16
+ const compilrConfig = {
17
+ version: WORKFLOW_VERSION,
18
+ project: {
19
+ name: config.name,
20
+ description: config.description,
21
+ createdAt: new Date().toISOString(),
22
+ },
23
+ paths: {
24
+ project: projectPath ?? '',
25
+ docs: config.repoPattern === 'two-repo' ? (docsPath ?? null) : null,
26
+ workflowRoot: workflowRoot ?? '',
27
+ },
28
+ settings: {
29
+ repoPattern: config.repoPattern,
30
+ techStack: config.techStack,
31
+ codingStandards: config.codingStandards,
32
+ },
33
+ sessions: {
34
+ count: 0,
35
+ lastSession: null,
36
+ },
37
+ };
38
+ return JSON.stringify(compilrConfig, null, 2) + '\n';
39
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Gitignore Template Generator
3
+ *
4
+ * Generates a .gitignore file based on tech stack.
5
+ */
6
+ import type { ProjectConfig } from '../types.js';
7
+ export declare function generateGitignore(config: ProjectConfig): string;
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Gitignore Template Generator
3
+ *
4
+ * Generates a .gitignore file based on tech stack.
5
+ */
6
+ export function generateGitignore(config) {
7
+ const common = `# Dependencies
8
+ node_modules/
9
+ .pnp/
10
+ .pnp.js
11
+
12
+ # Build outputs
13
+ dist/
14
+ build/
15
+ *.tsbuildinfo
16
+
17
+ # Environment files
18
+ .env
19
+ .env.local
20
+ .env.*.local
21
+
22
+ # IDE
23
+ .idea/
24
+ .vscode/
25
+ *.swp
26
+ *.swo
27
+ *~
28
+
29
+ # OS
30
+ .DS_Store
31
+ Thumbs.db
32
+
33
+ # Logs
34
+ logs/
35
+ *.log
36
+ npm-debug.log*
37
+
38
+ # Testing
39
+ coverage/
40
+ .nyc_output/
41
+
42
+ # Cache
43
+ .cache/
44
+ .parcel-cache/
45
+ `;
46
+ const techSpecific = getTechSpecificIgnore(config.techStack);
47
+ return common + '\n' + techSpecific;
48
+ }
49
+ function getTechSpecificIgnore(techStack) {
50
+ switch (techStack) {
51
+ case 'react-node-pg':
52
+ case 'vue-node-pg':
53
+ return `# Vite
54
+ .vite/
55
+
56
+ # Prisma
57
+ prisma/*.db
58
+ prisma/*.db-journal
59
+ `;
60
+ case 'react-python-pg':
61
+ return `# Vite
62
+ .vite/
63
+
64
+ # Python
65
+ __pycache__/
66
+ *.py[cod]
67
+ *$py.class
68
+ *.so
69
+ .Python
70
+ venv/
71
+ .venv/
72
+ ENV/
73
+ env/
74
+ .eggs/
75
+ *.egg-info/
76
+ *.egg
77
+ .mypy_cache/
78
+ .pytest_cache/
79
+ `;
80
+ case 'custom':
81
+ default:
82
+ return `# Add tech-specific ignores here
83
+ `;
84
+ }
85
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Template barrel export
3
+ */
4
+ export { generateCompilrMd } from './compilr-md.js';
5
+ export { generateConfigJson } from './config-json.js';
6
+ export { generateReadmeMd } from './readme-md.js';
7
+ export { generateCodingStandardsMd } from './coding-standards.js';
8
+ export { generatePackageJson } from './package-json.js';
9
+ export { generateTsconfig } from './tsconfig.js';
10
+ export { generateGitignore } from './gitignore.js';
11
+ export { generateCompilrMdForImport } from './compilr-md-import.js';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Template barrel export
3
+ */
4
+ export { generateCompilrMd } from './compilr-md.js';
5
+ export { generateConfigJson } from './config-json.js';
6
+ export { generateReadmeMd } from './readme-md.js';
7
+ export { generateCodingStandardsMd } from './coding-standards.js';
8
+ export { generatePackageJson } from './package-json.js';
9
+ export { generateTsconfig } from './tsconfig.js';
10
+ export { generateGitignore } from './gitignore.js';
11
+ export { generateCompilrMdForImport } from './compilr-md-import.js';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Package JSON Template Generator
3
+ *
4
+ * Generates a basic package.json for the project.
5
+ */
6
+ import type { ProjectConfig } from '../types.js';
7
+ export declare function generatePackageJson(config: ProjectConfig): string;
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Package JSON Template Generator
3
+ *
4
+ * Generates a basic package.json for the project.
5
+ */
6
+ export function generatePackageJson(config) {
7
+ const pkg = getPackageTemplate(config);
8
+ return JSON.stringify(pkg, null, 2) + '\n';
9
+ }
10
+ function getPackageTemplate(config) {
11
+ const base = {
12
+ name: config.name,
13
+ version: '0.0.1',
14
+ description: config.description,
15
+ type: 'module',
16
+ scripts: {},
17
+ dependencies: {},
18
+ devDependencies: {},
19
+ };
20
+ switch (config.techStack) {
21
+ case 'react-node-pg':
22
+ return {
23
+ ...base,
24
+ scripts: {
25
+ dev: 'vite',
26
+ build: 'tsc && vite build',
27
+ lint: 'eslint src/',
28
+ preview: 'vite preview',
29
+ },
30
+ dependencies: {
31
+ react: '^18.2.0',
32
+ 'react-dom': '^18.2.0',
33
+ },
34
+ devDependencies: {
35
+ '@types/react': '^18.2.0',
36
+ '@types/react-dom': '^18.2.0',
37
+ '@vitejs/plugin-react': '^4.2.0',
38
+ typescript: '^5.3.0',
39
+ vite: '^5.0.0',
40
+ ...(config.codingStandards !== 'custom'
41
+ ? {
42
+ eslint: '^9.0.0',
43
+ '@eslint/js': '^9.0.0',
44
+ 'typescript-eslint': '^8.0.0',
45
+ prettier: '^3.2.0',
46
+ }
47
+ : {}),
48
+ },
49
+ };
50
+ case 'vue-node-pg':
51
+ return {
52
+ ...base,
53
+ scripts: {
54
+ dev: 'vite',
55
+ build: 'vue-tsc && vite build',
56
+ lint: 'eslint src/',
57
+ preview: 'vite preview',
58
+ },
59
+ dependencies: {
60
+ vue: '^3.4.0',
61
+ },
62
+ devDependencies: {
63
+ '@vitejs/plugin-vue': '^5.0.0',
64
+ typescript: '^5.3.0',
65
+ 'vue-tsc': '^1.8.0',
66
+ vite: '^5.0.0',
67
+ ...(config.codingStandards !== 'custom'
68
+ ? {
69
+ eslint: '^9.0.0',
70
+ '@eslint/js': '^9.0.0',
71
+ 'typescript-eslint': '^8.0.0',
72
+ prettier: '^3.2.0',
73
+ }
74
+ : {}),
75
+ },
76
+ };
77
+ case 'react-python-pg':
78
+ // Frontend only - Python backend has its own requirements.txt
79
+ return {
80
+ ...base,
81
+ scripts: {
82
+ dev: 'vite',
83
+ build: 'tsc && vite build',
84
+ lint: 'eslint src/',
85
+ preview: 'vite preview',
86
+ },
87
+ dependencies: {
88
+ react: '^18.2.0',
89
+ 'react-dom': '^18.2.0',
90
+ },
91
+ devDependencies: {
92
+ '@types/react': '^18.2.0',
93
+ '@types/react-dom': '^18.2.0',
94
+ '@vitejs/plugin-react': '^4.2.0',
95
+ typescript: '^5.3.0',
96
+ vite: '^5.0.0',
97
+ },
98
+ };
99
+ case 'custom':
100
+ default:
101
+ return {
102
+ ...base,
103
+ scripts: {
104
+ dev: 'echo "Add your dev command"',
105
+ build: 'echo "Add your build command"',
106
+ lint: 'echo "Add your lint command"',
107
+ test: 'echo "Add your test command"',
108
+ },
109
+ };
110
+ }
111
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * README.md Template Generator
3
+ *
4
+ * Generates the project README with next steps.
5
+ */
6
+ import type { ProjectConfig } from '../types.js';
7
+ export declare function generateReadmeMd(config: ProjectConfig): string;
@@ -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,7 @@
1
+ /**
2
+ * TSConfig Template Generator
3
+ *
4
+ * Generates a tsconfig.json file based on coding standards.
5
+ */
6
+ import type { ProjectConfig } from '../types.js';
7
+ export declare function generateTsconfig(config: ProjectConfig): string;
@@ -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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",