@cxtmanager/core 1.0.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.
Files changed (42) hide show
  1. package/README.md +132 -0
  2. package/dist/context-manager.d.ts +55 -0
  3. package/dist/context-manager.d.ts.map +1 -0
  4. package/dist/context-manager.js +676 -0
  5. package/dist/context-manager.js.map +1 -0
  6. package/dist/file-watcher.d.ts +31 -0
  7. package/dist/file-watcher.d.ts.map +1 -0
  8. package/dist/file-watcher.js +121 -0
  9. package/dist/file-watcher.js.map +1 -0
  10. package/dist/git-hooks-manager.d.ts +40 -0
  11. package/dist/git-hooks-manager.d.ts.map +1 -0
  12. package/dist/git-hooks-manager.js +210 -0
  13. package/dist/git-hooks-manager.js.map +1 -0
  14. package/dist/git-repository.d.ts +65 -0
  15. package/dist/git-repository.d.ts.map +1 -0
  16. package/dist/git-repository.js +352 -0
  17. package/dist/git-repository.js.map +1 -0
  18. package/dist/index.d.ts +13 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +37 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/plan-manager.d.ts +55 -0
  23. package/dist/plan-manager.d.ts.map +1 -0
  24. package/dist/plan-manager.js +208 -0
  25. package/dist/plan-manager.js.map +1 -0
  26. package/dist/plan-templates.d.ts +15 -0
  27. package/dist/plan-templates.d.ts.map +1 -0
  28. package/dist/plan-templates.js +127 -0
  29. package/dist/plan-templates.js.map +1 -0
  30. package/dist/types/index.d.ts +143 -0
  31. package/dist/types/index.d.ts.map +1 -0
  32. package/dist/types/index.js +26 -0
  33. package/dist/types/index.js.map +1 -0
  34. package/dist/types.d.ts +176 -0
  35. package/dist/types.d.ts.map +1 -0
  36. package/dist/types.js +3 -0
  37. package/dist/types.js.map +1 -0
  38. package/dist/validation-engine.d.ts +26 -0
  39. package/dist/validation-engine.d.ts.map +1 -0
  40. package/dist/validation-engine.js +344 -0
  41. package/dist/validation-engine.js.map +1 -0
  42. package/package.json +63 -0
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.PlanManager = void 0;
37
+ const fs = __importStar(require("fs-extra"));
38
+ const path = __importStar(require("path"));
39
+ const plan_templates_1 = require("./plan-templates");
40
+ class PlanManager {
41
+ constructor(cxtPath, gitRepo, config) {
42
+ this.cxtPath = cxtPath;
43
+ this.planPath = path.join(cxtPath, 'plan.md');
44
+ this.planHistoryPath = path.join(cxtPath, '.plan-history');
45
+ this.gitRepo = gitRepo;
46
+ this.config = config;
47
+ }
48
+ /**
49
+ * Get current branch name
50
+ */
51
+ async getCurrentBranch() {
52
+ const branches = await this.gitRepo.getBranches();
53
+ return branches.current;
54
+ }
55
+ /**
56
+ * Get sanitized branch name for file system (remove special chars)
57
+ */
58
+ sanitizeBranchName(branch) {
59
+ // Replace / with -, remove invalid characters
60
+ return branch
61
+ .replace(/\//g, '-')
62
+ .replace(/[^a-zA-Z0-9\-_]/g, '')
63
+ .replace(/-+/g, '-')
64
+ .replace(/^-|-$/g, '');
65
+ }
66
+ /**
67
+ * Get path to branch-specific plan backup
68
+ */
69
+ getBranchPlanPath(branch) {
70
+ const sanitized = this.sanitizeBranchName(branch);
71
+ return path.join(this.planHistoryPath, `${sanitized}.md`);
72
+ }
73
+ /**
74
+ * Save current plan.md to .plan-history/{branch}.md
75
+ */
76
+ async saveCurrentPlan(branch) {
77
+ // Ensure .plan-history directory exists
78
+ await fs.ensureDir(this.planHistoryPath);
79
+ // Check if plan.md exists
80
+ if (!await fs.pathExists(this.planPath)) {
81
+ return; // Nothing to save
82
+ }
83
+ const branchPlanPath = this.getBranchPlanPath(branch);
84
+ const currentContent = await fs.readFile(this.planPath, 'utf-8');
85
+ // Only save if there's actual content (not just template)
86
+ if (currentContent.trim().length > 0) {
87
+ await fs.writeFile(branchPlanPath, currentContent, 'utf-8');
88
+ }
89
+ }
90
+ /**
91
+ * Restore plan.md from .plan-history/{branch}.md
92
+ */
93
+ async restorePlan(branch) {
94
+ const branchPlanPath = this.getBranchPlanPath(branch);
95
+ if (await fs.pathExists(branchPlanPath)) {
96
+ const savedContent = await fs.readFile(branchPlanPath, 'utf-8');
97
+ await fs.writeFile(this.planPath, savedContent, 'utf-8');
98
+ return true;
99
+ }
100
+ return false;
101
+ }
102
+ /**
103
+ * Create blank plan.md template
104
+ */
105
+ async createBlankPlan(template = 'minimal') {
106
+ const branch = await this.getCurrentBranch();
107
+ const date = new Date().toISOString().split('T')[0];
108
+ const content = template === 'detailed'
109
+ ? plan_templates_1.PlanTemplates.getDetailed(branch, date)
110
+ : plan_templates_1.PlanTemplates.getMinimal(branch, date);
111
+ await fs.writeFile(this.planPath, content, 'utf-8');
112
+ }
113
+ /**
114
+ * Check if plan.md has uncommitted changes
115
+ */
116
+ async hasUncommittedChanges() {
117
+ try {
118
+ const status = await this.gitRepo.getStatus();
119
+ return status.modified.includes('.cxt/plan.md') ||
120
+ status.untracked.includes('.cxt/plan.md');
121
+ }
122
+ catch {
123
+ return false;
124
+ }
125
+ }
126
+ /**
127
+ * Main sync method: save current, restore for new branch
128
+ */
129
+ async syncPlan(options = {}) {
130
+ const { silent = false, createIfMissing = true, template = 'minimal' } = options;
131
+ // Get current branch
132
+ const currentBranch = await this.getCurrentBranch();
133
+ // Check for uncommitted changes
134
+ const hasChanges = await this.hasUncommittedChanges();
135
+ if (hasChanges && !silent) {
136
+ throw new Error('plan.md has uncommitted changes. Please commit or stash changes before switching branches.\n' +
137
+ ' git add .cxt/plan.md && git commit -m "Update plan.md"\n' +
138
+ ' OR\n' +
139
+ ' git stash');
140
+ }
141
+ // Get previous branch from stored state (if available)
142
+ // For now, we'll track this in a simple way
143
+ const statePath = path.join(this.cxtPath, '.plan-state.json');
144
+ let previousBranch = 'main';
145
+ if (await fs.pathExists(statePath)) {
146
+ try {
147
+ const state = await fs.readJson(statePath);
148
+ previousBranch = state.lastBranch || 'main';
149
+ }
150
+ catch {
151
+ // Ignore errors reading state
152
+ }
153
+ }
154
+ // Save current plan if we're switching from a different branch
155
+ if (previousBranch !== currentBranch && previousBranch) {
156
+ await this.saveCurrentPlan(previousBranch);
157
+ }
158
+ // Try to restore plan for current branch
159
+ const restored = await this.restorePlan(currentBranch);
160
+ // If no saved plan exists and createIfMissing is true, create blank template
161
+ let created = false;
162
+ if (!restored && createIfMissing) {
163
+ await this.createBlankPlan(template);
164
+ created = true;
165
+ }
166
+ // Save current branch to state
167
+ await fs.writeJson(statePath, { lastBranch: currentBranch }, { spaces: 2 });
168
+ return {
169
+ previousBranch,
170
+ currentBranch,
171
+ restored,
172
+ created
173
+ };
174
+ }
175
+ /**
176
+ * Check if branch has saved plan
177
+ */
178
+ async hasBranchPlan(branch) {
179
+ const branchPlanPath = this.getBranchPlanPath(branch);
180
+ return await fs.pathExists(branchPlanPath);
181
+ }
182
+ /**
183
+ * List all saved branch plans
184
+ */
185
+ async listBranchPlans() {
186
+ if (!await fs.pathExists(this.planHistoryPath)) {
187
+ return [];
188
+ }
189
+ const files = await fs.readdir(this.planHistoryPath);
190
+ return files
191
+ .filter(file => file.endsWith('.md'))
192
+ .map(file => file.replace('.md', ''));
193
+ }
194
+ /**
195
+ * Archive completed branch plan
196
+ */
197
+ async archivePlan(branch) {
198
+ const branchPlanPath = this.getBranchPlanPath(branch);
199
+ const archivePath = path.join(this.planHistoryPath, 'completed');
200
+ if (await fs.pathExists(branchPlanPath)) {
201
+ await fs.ensureDir(archivePath);
202
+ const archiveFile = path.join(archivePath, path.basename(branchPlanPath));
203
+ await fs.move(branchPlanPath, archiveFile);
204
+ }
205
+ }
206
+ }
207
+ exports.PlanManager = PlanManager;
208
+ //# sourceMappingURL=plan-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-manager.js","sourceRoot":"","sources":["../src/plan-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,2CAA6B;AAG7B,qDAAiD;AAEjD,MAAa,WAAW;IAOtB,YACE,OAAe,EACf,OAAsB,EACtB,MAAiB;QAEjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC9C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QAC3D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB;QACpB,MAAM,QAA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AAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;YACxC,MAAM,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YAChC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC;YAC1E,MAAM,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;CACF;AA7MD,kCA6MC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Plan templates for branch-aware plan.md files
3
+ * Manager not enforcer - provides structure, user/AI provides content
4
+ */
5
+ export declare class PlanTemplates {
6
+ /**
7
+ * Get minimal plan template
8
+ */
9
+ static getMinimal(branchName?: string, date?: string): string;
10
+ /**
11
+ * Get detailed plan template
12
+ */
13
+ static getDetailed(branchName?: string, date?: string): string;
14
+ }
15
+ //# sourceMappingURL=plan-templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-templates.d.ts","sourceRoot":"","sources":["../src/plan-templates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,qBAAa,aAAa;IACxB;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM;IA+C7D;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM;CAkE/D"}
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ /**
3
+ * Plan templates for branch-aware plan.md files
4
+ * Manager not enforcer - provides structure, user/AI provides content
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.PlanTemplates = void 0;
8
+ class PlanTemplates {
9
+ /**
10
+ * Get minimal plan template
11
+ */
12
+ static getMinimal(branchName, date) {
13
+ const branch = branchName || 'current branch';
14
+ const createdDate = date || new Date().toISOString().split('T')[0];
15
+ return `# Current Branch Implementation
16
+
17
+ *Branch: ${branch}*
18
+ *Created: ${createdDate}*
19
+
20
+ ## What's Being Built
21
+ <!--
22
+ GUIDANCE: Describe what is being built in this branch/feature.
23
+ This helps AI understand the current work when providing assistance.
24
+ Example: "OAuth2 authentication system with Google and GitHub providers"
25
+
26
+ TIP: Be specific about the feature or functionality being implemented.
27
+ -->
28
+
29
+ ## Implementation Approach
30
+ <!--
31
+ GUIDANCE: Describe the technical approach for implementing this feature.
32
+ This helps AI make appropriate suggestions and understand the architecture.
33
+ Example: "Use Passport.js for OAuth strategies, store tokens in encrypted session storage"
34
+
35
+ TIP: Include key technologies, patterns, or architectural decisions.
36
+ -->
37
+
38
+ ## Tasks & Progress
39
+ <!--
40
+ GUIDANCE: Track tasks and progress as work proceeds.
41
+ This helps AI understand what's done and what remains.
42
+ Example: "- [x] Set up OAuth providers, - [ ] Implement token refresh"
43
+
44
+ TIP: Update this section as work progresses. AI can help track completion.
45
+ -->
46
+
47
+ ## Decisions Made
48
+ <!--
49
+ GUIDANCE: Document key technical decisions made during implementation.
50
+ This helps maintain context and explain why certain approaches were chosen.
51
+ Example: "Chose JWT over session tokens for better scalability"
52
+
53
+ TIP: Include rationale for important architectural or design decisions.
54
+ -->
55
+ `;
56
+ }
57
+ /**
58
+ * Get detailed plan template
59
+ */
60
+ static getDetailed(branchName, date) {
61
+ const branch = branchName || 'current branch';
62
+ const createdDate = date || new Date().toISOString().split('T')[0];
63
+ return `# Current Branch Implementation
64
+
65
+ *Branch: ${branch}*
66
+ *Created: ${createdDate}*
67
+
68
+ ## What's Being Built
69
+ <!--
70
+ GUIDANCE: Describe what is being built in this branch/feature.
71
+ This helps AI understand the current work when providing assistance.
72
+ Example: "OAuth2 authentication system with Google and GitHub providers"
73
+
74
+ TIP: Be specific about the feature or functionality being implemented.
75
+ -->
76
+
77
+ ## Implementation Approach
78
+ <!--
79
+ GUIDANCE: Describe the technical approach for implementing this feature.
80
+ This helps AI make appropriate suggestions and understand the architecture.
81
+ Example: "Use Passport.js for OAuth strategies, store tokens in encrypted session storage"
82
+
83
+ TIP: Include key technologies, patterns, or architectural decisions.
84
+ -->
85
+
86
+ ## Architecture Decisions
87
+ <!--
88
+ GUIDANCE: Document architectural choices and their rationale.
89
+ This helps maintain consistency and explain design decisions.
90
+ Example: "Chose JWT over session tokens for better scalability"
91
+
92
+ TIP: Include trade-offs, alternatives considered, and why this approach was chosen.
93
+ -->
94
+
95
+ ## Tasks & Progress
96
+ - [ ] Task 1
97
+ - [ ] Task 2
98
+ <!--
99
+ GUIDANCE: Track tasks and progress as work proceeds.
100
+ This helps AI understand what's done and what remains.
101
+ Example: "- [x] Set up OAuth providers, - [ ] Implement token refresh"
102
+
103
+ TIP: Update this section as work progresses. AI can help track completion.
104
+ -->
105
+
106
+ ## Decisions Made
107
+ <!--
108
+ GUIDANCE: Document key technical decisions made during implementation.
109
+ This helps maintain context and explain why certain approaches were chosen.
110
+ Example: "Chose JWT over session tokens for better scalability"
111
+
112
+ TIP: Include rationale for important architectural or design decisions.
113
+ -->
114
+
115
+ ## Related Context
116
+ <!--
117
+ GUIDANCE: Links to related issues, PRs, or documentation.
118
+ This helps connect the implementation to broader project context.
119
+ Example: "Related to issue #123, see PR #456 for design discussion"
120
+
121
+ TIP: Include references to external resources that provide additional context.
122
+ -->
123
+ `;
124
+ }
125
+ }
126
+ exports.PlanTemplates = PlanTemplates;
127
+ //# sourceMappingURL=plan-templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-templates.js","sourceRoot":"","sources":["../src/plan-templates.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,MAAa,aAAa;IACxB;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,UAAmB,EAAE,IAAa;QAClD,MAAM,MAAM,GAAG,UAAU,IAAI,gBAAgB,CAAC;QAC9C,MAAM,WAAW,GAAG,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAEnE,OAAO;;WAEA,MAAM;YACL,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCtB,CAAC;IACA,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,UAAmB,EAAE,IAAa;QACnD,MAAM,MAAM,GAAG,UAAU,IAAI,gBAAgB,CAAC;QAC9C,MAAM,WAAW,GAAG,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAEnE,OAAO;;WAEA,MAAM;YACL,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyDtB,CAAC;IACA,CAAC;CACF;AAxHD,sCAwHC"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Core types for CxtManager - Git for AI Context
3
+ */
4
+ export interface CxtConfig {
5
+ version: string;
6
+ mcp: {
7
+ enabled: boolean;
8
+ auto_discover: boolean;
9
+ sources: {
10
+ local_files: {
11
+ enabled: boolean;
12
+ readme: boolean;
13
+ package_json: boolean;
14
+ git_history: boolean;
15
+ };
16
+ claude_desktop: {
17
+ enabled: boolean;
18
+ auto_discovered: boolean;
19
+ };
20
+ github: {
21
+ enabled: boolean;
22
+ repo: string | null;
23
+ include_issues: boolean;
24
+ include_prs: boolean;
25
+ };
26
+ external_apis: {
27
+ notion: {
28
+ enabled: boolean;
29
+ api_key: string | null;
30
+ };
31
+ linear: {
32
+ enabled: boolean;
33
+ api_key: string | null;
34
+ };
35
+ };
36
+ };
37
+ };
38
+ context: {
39
+ auto_sync: boolean;
40
+ health_checks: boolean;
41
+ ai_attribution: boolean;
42
+ };
43
+ }
44
+ export interface ContextFile {
45
+ name: string;
46
+ path: string;
47
+ content: string;
48
+ lastModified: Date;
49
+ size: number;
50
+ }
51
+ export interface InitOptions {
52
+ mode: 'auto' | 'manual';
53
+ template?: string;
54
+ ai_model?: string;
55
+ sources?: string[];
56
+ deep_analysis?: boolean;
57
+ trackInGit?: boolean;
58
+ }
59
+ export interface GitInfo {
60
+ isRepo: boolean;
61
+ currentBranch: string | null;
62
+ hasChanges: boolean;
63
+ commitCount: number;
64
+ lastCommit: string | null;
65
+ }
66
+ export interface ProjectAnalysis {
67
+ projectName: string;
68
+ description: string;
69
+ technologies: string[];
70
+ structure: ProjectStructure;
71
+ gitInfo: GitInfo;
72
+ dependencies: string[];
73
+ endpoints: string[];
74
+ hasDocumentation: boolean;
75
+ }
76
+ export interface ProjectStructure {
77
+ folders: string[];
78
+ files: string[];
79
+ hasPackageJson: boolean;
80
+ hasReadme: boolean;
81
+ hasTests: boolean;
82
+ hasDocs: boolean;
83
+ }
84
+ declare enum ContextSource {
85
+ AI = "ai",
86
+ HUMAN = "human",
87
+ CODE_TRIGGERED = "code-triggered",
88
+ EXTERNAL = "external"
89
+ }
90
+ declare enum AlignmentStatus {
91
+ ALIGNED = "aligned",
92
+ WARNING = "warning",
93
+ CONFLICT = "conflict"
94
+ }
95
+ export interface AttributionInfo {
96
+ author: string;
97
+ timestamp: Date;
98
+ commit: string;
99
+ source: ContextSource;
100
+ aiModel?: string;
101
+ reason?: string;
102
+ }
103
+ export interface HealthStatus {
104
+ overall: 'healthy' | 'warning' | 'error';
105
+ alignments: {
106
+ contextToPlan: AlignmentStatus;
107
+ allToGuardrails: AlignmentStatus;
108
+ };
109
+ issues: HealthIssue[];
110
+ suggestions: string[];
111
+ lastChecked: Date;
112
+ }
113
+ export interface HealthIssue {
114
+ type: 'warning' | 'error';
115
+ file: string;
116
+ line?: number;
117
+ message: string;
118
+ suggestion?: string;
119
+ autoFixable: boolean;
120
+ }
121
+ export interface BlameInfo extends AttributionInfo {
122
+ line: number;
123
+ content: string;
124
+ }
125
+ export interface StatusInfo {
126
+ contextFiles: Array<{
127
+ file: string;
128
+ status: string;
129
+ staged: boolean;
130
+ contentStatus?: 'populated' | 'template-only' | 'empty';
131
+ templatePercentage?: number;
132
+ size?: number;
133
+ }>;
134
+ health: HealthStatus;
135
+ gitStatus: {
136
+ staged: string[];
137
+ modified: string[];
138
+ untracked: string[];
139
+ };
140
+ lastUpdated: Date;
141
+ }
142
+ export {};
143
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE;QACH,OAAO,EAAE,OAAO,CAAC;QACjB,aAAa,EAAE,OAAO,CAAC;QACvB,OAAO,EAAE;YACP,WAAW,EAAE;gBACX,OAAO,EAAE,OAAO,CAAC;gBACjB,MAAM,EAAE,OAAO,CAAC;gBAChB,YAAY,EAAE,OAAO,CAAC;gBACtB,WAAW,EAAE,OAAO,CAAC;aACtB,CAAC;YACF,cAAc,EAAE;gBACd,OAAO,EAAE,OAAO,CAAC;gBACjB,eAAe,EAAE,OAAO,CAAC;aAC1B,CAAC;YACF,MAAM,EAAE;gBACN,OAAO,EAAE,OAAO,CAAC;gBACjB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;gBACpB,cAAc,EAAE,OAAO,CAAC;gBACxB,WAAW,EAAE,OAAO,CAAC;aACtB,CAAC;YACF,aAAa,EAAE;gBACb,MAAM,EAAE;oBAAE,OAAO,EAAE,OAAO,CAAC;oBAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;iBAAE,CAAC;gBACrD,MAAM,EAAE;oBAAE,OAAO,EAAE,OAAO,CAAC;oBAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;iBAAE,CAAC;aACtD,CAAC;SACH,CAAC;KACH,CAAC;IACF,OAAO,EAAE;QACP,SAAS,EAAE,OAAO,CAAC;QACnB,aAAa,EAAE,OAAO,CAAC;QACvB,cAAc,EAAE,OAAO,CAAC;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;KACf,CAAC,CAAC;IACH,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,EAAE;QACT,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,SAAS,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;IACF,WAAW,EAAE,IAAI,CAAC;CACnB"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ /**
3
+ * Core types for CxtManager - Git for AI Context
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var ContextSource;
7
+ (function (ContextSource) {
8
+ ContextSource["AI"] = "ai";
9
+ ContextSource["HUMAN"] = "human";
10
+ ContextSource["CODE_TRIGGERED"] = "code-triggered";
11
+ ContextSource["EXTERNAL"] = "external";
12
+ })(ContextSource || (ContextSource = {}));
13
+ var AlignmentStatus;
14
+ (function (AlignmentStatus) {
15
+ AlignmentStatus["ALIGNED"] = "aligned";
16
+ AlignmentStatus["WARNING"] = "warning";
17
+ AlignmentStatus["CONFLICT"] = "conflict";
18
+ })(AlignmentStatus || (AlignmentStatus = {}));
19
+ var ContextStatus;
20
+ (function (ContextStatus) {
21
+ ContextStatus["CLEAN"] = "clean";
22
+ ContextStatus["MODIFIED"] = "modified";
23
+ ContextStatus["NEW"] = "new";
24
+ ContextStatus["DELETED"] = "deleted";
25
+ })(ContextStatus || (ContextStatus = {}));
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAkFH,IAAK,aAKJ;AALD,WAAK,aAAa;IAChB,0BAAS,CAAA;IACT,gCAAe,CAAA;IACf,kDAAiC,CAAA;IACjC,sCAAqB,CAAA;AACvB,CAAC,EALI,aAAa,KAAb,aAAa,QAKjB;AAED,IAAK,eAIJ;AAJD,WAAK,eAAe;IAClB,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;IACnB,wCAAqB,CAAA;AACvB,CAAC,EAJI,eAAe,KAAf,eAAe,QAInB;AAED,IAAK,aAKJ;AALD,WAAK,aAAa;IAChB,gCAAe,CAAA;IACf,sCAAqB,CAAA;IACrB,4BAAW,CAAA;IACX,oCAAmB,CAAA;AACrB,CAAC,EALI,aAAa,KAAb,aAAa,QAKjB"}