ctxinit 0.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 +484 -0
- package/bin/ctx.js +3 -0
- package/dist/analysis/index.d.ts +2 -0
- package/dist/analysis/index.d.ts.map +1 -0
- package/dist/analysis/index.js +18 -0
- package/dist/analysis/index.js.map +1 -0
- package/dist/analysis/static-analysis.d.ts +79 -0
- package/dist/analysis/static-analysis.d.ts.map +1 -0
- package/dist/analysis/static-analysis.js +279 -0
- package/dist/analysis/static-analysis.js.map +1 -0
- package/dist/bootstrap/index.d.ts +8 -0
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/bootstrap/index.js +13 -0
- package/dist/bootstrap/index.js.map +1 -0
- package/dist/bootstrap/orchestrator.d.ts +48 -0
- package/dist/bootstrap/orchestrator.d.ts.map +1 -0
- package/dist/bootstrap/orchestrator.js +363 -0
- package/dist/bootstrap/orchestrator.js.map +1 -0
- package/dist/bootstrap/validator.d.ts +25 -0
- package/dist/bootstrap/validator.d.ts.map +1 -0
- package/dist/bootstrap/validator.js +412 -0
- package/dist/bootstrap/validator.js.map +1 -0
- package/dist/build/atomic.d.ts +74 -0
- package/dist/build/atomic.d.ts.map +1 -0
- package/dist/build/atomic.js +235 -0
- package/dist/build/atomic.js.map +1 -0
- package/dist/build/index.d.ts +10 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +26 -0
- package/dist/build/index.js.map +1 -0
- package/dist/build/lock.d.ts +102 -0
- package/dist/build/lock.d.ts.map +1 -0
- package/dist/build/lock.js +297 -0
- package/dist/build/lock.js.map +1 -0
- package/dist/build/manifest.d.ts +138 -0
- package/dist/build/manifest.d.ts.map +1 -0
- package/dist/build/manifest.js +269 -0
- package/dist/build/manifest.js.map +1 -0
- package/dist/build/orchestrator.d.ts +103 -0
- package/dist/build/orchestrator.d.ts.map +1 -0
- package/dist/build/orchestrator.js +524 -0
- package/dist/build/orchestrator.js.map +1 -0
- package/dist/cli/bootstrap.d.ts +77 -0
- package/dist/cli/bootstrap.d.ts.map +1 -0
- package/dist/cli/bootstrap.js +527 -0
- package/dist/cli/bootstrap.js.map +1 -0
- package/dist/cli/build.d.ts +32 -0
- package/dist/cli/build.d.ts.map +1 -0
- package/dist/cli/build.js +156 -0
- package/dist/cli/build.js.map +1 -0
- package/dist/cli/diff.d.ts +23 -0
- package/dist/cli/diff.d.ts.map +1 -0
- package/dist/cli/diff.js +226 -0
- package/dist/cli/diff.js.map +1 -0
- package/dist/cli/hooks.d.ts +29 -0
- package/dist/cli/hooks.d.ts.map +1 -0
- package/dist/cli/hooks.js +176 -0
- package/dist/cli/hooks.js.map +1 -0
- package/dist/cli/init.d.ts +53 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +254 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/lint.d.ts +46 -0
- package/dist/cli/lint.d.ts.map +1 -0
- package/dist/cli/lint.js +210 -0
- package/dist/cli/lint.js.map +1 -0
- package/dist/cli/migrate.d.ts +28 -0
- package/dist/cli/migrate.d.ts.map +1 -0
- package/dist/cli/migrate.js +350 -0
- package/dist/cli/migrate.js.map +1 -0
- package/dist/cli/verify.d.ts +21 -0
- package/dist/cli/verify.d.ts.map +1 -0
- package/dist/cli/verify.js +209 -0
- package/dist/cli/verify.js.map +1 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +262 -0
- package/dist/cli.js.map +1 -0
- package/dist/compiler/agents-compiler.d.ts +24 -0
- package/dist/compiler/agents-compiler.d.ts.map +1 -0
- package/dist/compiler/agents-compiler.js +192 -0
- package/dist/compiler/agents-compiler.js.map +1 -0
- package/dist/compiler/base-compiler.d.ts +152 -0
- package/dist/compiler/base-compiler.d.ts.map +1 -0
- package/dist/compiler/base-compiler.js +180 -0
- package/dist/compiler/base-compiler.js.map +1 -0
- package/dist/compiler/claude-compiler.d.ts +24 -0
- package/dist/compiler/claude-compiler.d.ts.map +1 -0
- package/dist/compiler/claude-compiler.js +182 -0
- package/dist/compiler/claude-compiler.js.map +1 -0
- package/dist/compiler/cursor-compiler.d.ts +33 -0
- package/dist/compiler/cursor-compiler.d.ts.map +1 -0
- package/dist/compiler/cursor-compiler.js +136 -0
- package/dist/compiler/cursor-compiler.js.map +1 -0
- package/dist/compiler/index.d.ts +7 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +24 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/rule-selector.d.ts +115 -0
- package/dist/compiler/rule-selector.d.ts.map +1 -0
- package/dist/compiler/rule-selector.js +273 -0
- package/dist/compiler/rule-selector.js.map +1 -0
- package/dist/compiler/token-estimator.d.ts +74 -0
- package/dist/compiler/token-estimator.d.ts.map +1 -0
- package/dist/compiler/token-estimator.js +191 -0
- package/dist/compiler/token-estimator.js.map +1 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +18 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +48 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +175 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/git/gitignore.d.ts +59 -0
- package/dist/git/gitignore.d.ts.map +1 -0
- package/dist/git/gitignore.js +268 -0
- package/dist/git/gitignore.js.map +1 -0
- package/dist/git/hooks.d.ts +34 -0
- package/dist/git/hooks.d.ts.map +1 -0
- package/dist/git/hooks.js +129 -0
- package/dist/git/hooks.js.map +1 -0
- package/dist/git/husky.d.ts +52 -0
- package/dist/git/husky.d.ts.map +1 -0
- package/dist/git/husky.js +219 -0
- package/dist/git/husky.js.map +1 -0
- package/dist/git/index.d.ts +9 -0
- package/dist/git/index.d.ts.map +1 -0
- package/dist/git/index.js +15 -0
- package/dist/git/index.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/base-provider.d.ts +43 -0
- package/dist/llm/base-provider.d.ts.map +1 -0
- package/dist/llm/base-provider.js +91 -0
- package/dist/llm/base-provider.js.map +1 -0
- package/dist/llm/index.d.ts +17 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +36 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/prompts/bootstrap-prompt.d.ts +27 -0
- package/dist/llm/prompts/bootstrap-prompt.d.ts.map +1 -0
- package/dist/llm/prompts/bootstrap-prompt.js +278 -0
- package/dist/llm/prompts/bootstrap-prompt.js.map +1 -0
- package/dist/llm/prompts/index.d.ts +5 -0
- package/dist/llm/prompts/index.d.ts.map +1 -0
- package/dist/llm/prompts/index.js +11 -0
- package/dist/llm/prompts/index.js.map +1 -0
- package/dist/llm/provider-factory.d.ts +27 -0
- package/dist/llm/provider-factory.d.ts.map +1 -0
- package/dist/llm/provider-factory.js +213 -0
- package/dist/llm/provider-factory.js.map +1 -0
- package/dist/llm/providers/claude-api.d.ts +21 -0
- package/dist/llm/providers/claude-api.d.ts.map +1 -0
- package/dist/llm/providers/claude-api.js +110 -0
- package/dist/llm/providers/claude-api.js.map +1 -0
- package/dist/llm/providers/claude-code.d.ts +21 -0
- package/dist/llm/providers/claude-code.d.ts.map +1 -0
- package/dist/llm/providers/claude-code.js +120 -0
- package/dist/llm/providers/claude-code.js.map +1 -0
- package/dist/llm/providers/codex-cli.d.ts +25 -0
- package/dist/llm/providers/codex-cli.d.ts.map +1 -0
- package/dist/llm/providers/codex-cli.js +129 -0
- package/dist/llm/providers/codex-cli.js.map +1 -0
- package/dist/llm/providers/cursor-cli.d.ts +24 -0
- package/dist/llm/providers/cursor-cli.d.ts.map +1 -0
- package/dist/llm/providers/cursor-cli.js +106 -0
- package/dist/llm/providers/cursor-cli.js.map +1 -0
- package/dist/llm/providers/gemini-api.d.ts +20 -0
- package/dist/llm/providers/gemini-api.d.ts.map +1 -0
- package/dist/llm/providers/gemini-api.js +121 -0
- package/dist/llm/providers/gemini-api.js.map +1 -0
- package/dist/llm/providers/gemini-cli.d.ts +20 -0
- package/dist/llm/providers/gemini-cli.d.ts.map +1 -0
- package/dist/llm/providers/gemini-cli.js +109 -0
- package/dist/llm/providers/gemini-cli.js.map +1 -0
- package/dist/llm/providers/interactive.d.ts +42 -0
- package/dist/llm/providers/interactive.d.ts.map +1 -0
- package/dist/llm/providers/interactive.js +200 -0
- package/dist/llm/providers/interactive.js.map +1 -0
- package/dist/llm/providers/openai-api.d.ts +21 -0
- package/dist/llm/providers/openai-api.d.ts.map +1 -0
- package/dist/llm/providers/openai-api.js +107 -0
- package/dist/llm/providers/openai-api.js.map +1 -0
- package/dist/llm/types.d.ts +128 -0
- package/dist/llm/types.d.ts.map +1 -0
- package/dist/llm/types.js +8 -0
- package/dist/llm/types.js.map +1 -0
- package/dist/parser/index.d.ts +3 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +19 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/path-security.d.ts +40 -0
- package/dist/parser/path-security.d.ts.map +1 -0
- package/dist/parser/path-security.js +183 -0
- package/dist/parser/path-security.js.map +1 -0
- package/dist/parser/rule-parser.d.ts +50 -0
- package/dist/parser/rule-parser.d.ts.map +1 -0
- package/dist/parser/rule-parser.js +203 -0
- package/dist/parser/rule-parser.js.map +1 -0
- package/dist/schemas/config.d.ts +202 -0
- package/dist/schemas/config.d.ts.map +1 -0
- package/dist/schemas/config.js +96 -0
- package/dist/schemas/config.js.map +1 -0
- package/dist/schemas/index.d.ts +3 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +19 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/rule.d.ts +67 -0
- package/dist/schemas/rule.d.ts.map +1 -0
- package/dist/schemas/rule.js +44 -0
- package/dist/schemas/rule.js.map +1 -0
- package/package.json +69 -0
- package/templates/architecture.md +35 -0
- package/templates/bootstrap-prompt.md +242 -0
- package/templates/config.yaml +25 -0
- package/templates/project.md +44 -0
- package/templates/rules/example.md +36 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-api.js","sourceRoot":"","sources":["../../../src/llm/providers/openai-api.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AASH,oDAAmD;AAEnD;;GAEG;AACH,MAAa,iBAAkB,SAAQ,+BAAe;IAC5C,MAAM,CAAU,OAAO,GAAG,4CAA4C,CAAC;IACvE,MAAM,CAAU,aAAa,GAAG,QAAQ,CAAC;IAEjD,YAAY,MAAyB;QACnC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,IAAI,YAAY;QACd,OAAO;YACL,QAAQ,EAAE,IAAI,EAAE,2BAA2B;YAC3C,YAAY,EAAE,IAAI;YAClB,SAAS,EAAE,IAAI;YACf,gBAAgB,EAAE,MAAM;YACxB,eAAe,EAAE,KAAK;SACvB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;QAChE,OAAO,CAAC,CAAC,MAAM,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAmB;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;QAChE,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,iBAAiB,CAAC,aAAa,CAAC;QACnE,MAAM,SAAS,GAAG,IAAI,CAAC,YA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,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Provider Types
|
|
3
|
+
*
|
|
4
|
+
* Unified interface for LLM providers supporting both API and CLI invocation.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Supported LLM provider types
|
|
8
|
+
*/
|
|
9
|
+
export type LLMProviderType = 'claude-api' | 'openai-api' | 'gemini-api' | 'claude-code' | 'cursor' | 'codex' | 'gemini-cli' | 'interactive';
|
|
10
|
+
/**
|
|
11
|
+
* Provider configuration
|
|
12
|
+
*/
|
|
13
|
+
export interface LLMProviderConfig {
|
|
14
|
+
type: LLMProviderType;
|
|
15
|
+
/** API key (for API providers) */
|
|
16
|
+
apiKey?: string;
|
|
17
|
+
/** Model to use */
|
|
18
|
+
model?: string;
|
|
19
|
+
/** CLI command path override */
|
|
20
|
+
cliPath?: string;
|
|
21
|
+
/** Max tokens for response */
|
|
22
|
+
maxTokens?: number;
|
|
23
|
+
/** Temperature for generation */
|
|
24
|
+
temperature?: number;
|
|
25
|
+
/** Timeout in milliseconds */
|
|
26
|
+
timeout?: number;
|
|
27
|
+
/** Enable verbose logging for debugging */
|
|
28
|
+
verbose?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Message format for LLM communication
|
|
32
|
+
*/
|
|
33
|
+
export interface LLMMessage {
|
|
34
|
+
role: 'system' | 'user' | 'assistant';
|
|
35
|
+
content: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* LLM request
|
|
39
|
+
*/
|
|
40
|
+
export interface LLMRequest {
|
|
41
|
+
messages: LLMMessage[];
|
|
42
|
+
/** Optional system prompt (some providers handle separately) */
|
|
43
|
+
systemPrompt?: string;
|
|
44
|
+
/** Max tokens for response */
|
|
45
|
+
maxTokens?: number;
|
|
46
|
+
/** Temperature */
|
|
47
|
+
temperature?: number;
|
|
48
|
+
/** JSON mode - request structured JSON output */
|
|
49
|
+
jsonMode?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* LLM response
|
|
53
|
+
*/
|
|
54
|
+
export interface LLMResponse {
|
|
55
|
+
content: string;
|
|
56
|
+
/** Tokens used in prompt */
|
|
57
|
+
promptTokens?: number;
|
|
58
|
+
/** Tokens used in response */
|
|
59
|
+
completionTokens?: number;
|
|
60
|
+
/** Total tokens */
|
|
61
|
+
totalTokens?: number;
|
|
62
|
+
/** Provider-specific metadata */
|
|
63
|
+
metadata?: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Provider capabilities
|
|
67
|
+
*/
|
|
68
|
+
export interface LLMProviderCapabilities {
|
|
69
|
+
/** Supports JSON mode */
|
|
70
|
+
jsonMode: boolean;
|
|
71
|
+
/** Supports system prompts */
|
|
72
|
+
systemPrompt: boolean;
|
|
73
|
+
/** Supports streaming */
|
|
74
|
+
streaming: boolean;
|
|
75
|
+
/** Max context window */
|
|
76
|
+
maxContextTokens: number;
|
|
77
|
+
/** Max output tokens */
|
|
78
|
+
maxOutputTokens: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Provider interface - all providers must implement this
|
|
82
|
+
*/
|
|
83
|
+
export interface LLMProvider {
|
|
84
|
+
/** Provider type */
|
|
85
|
+
readonly type: LLMProviderType;
|
|
86
|
+
/** Provider display name */
|
|
87
|
+
readonly name: string;
|
|
88
|
+
/** Provider capabilities */
|
|
89
|
+
readonly capabilities: LLMProviderCapabilities;
|
|
90
|
+
/**
|
|
91
|
+
* Check if provider is available (API key set, CLI installed, etc.)
|
|
92
|
+
*/
|
|
93
|
+
isAvailable(): Promise<boolean>;
|
|
94
|
+
/**
|
|
95
|
+
* Send request to LLM
|
|
96
|
+
*/
|
|
97
|
+
complete(request: LLMRequest): Promise<LLMResponse>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Bootstrap-specific output structure
|
|
101
|
+
*/
|
|
102
|
+
export interface BootstrapLLMOutput {
|
|
103
|
+
/** Enhanced project.md content */
|
|
104
|
+
projectMd?: string;
|
|
105
|
+
/** Enhanced architecture.md content */
|
|
106
|
+
architectureMd?: string;
|
|
107
|
+
/** Generated/enhanced rules */
|
|
108
|
+
rules: Array<{
|
|
109
|
+
/** Path relative to .context/ (e.g., "rules/typescript-patterns.md") */
|
|
110
|
+
path: string;
|
|
111
|
+
/** Full file content with frontmatter */
|
|
112
|
+
content: string;
|
|
113
|
+
}>;
|
|
114
|
+
/** Any warnings or suggestions from LLM */
|
|
115
|
+
suggestions?: string[];
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Provider detection result
|
|
119
|
+
*/
|
|
120
|
+
export interface ProviderDetectionResult {
|
|
121
|
+
available: LLMProviderType[];
|
|
122
|
+
recommended: LLMProviderType | null;
|
|
123
|
+
details: Record<LLMProviderType, {
|
|
124
|
+
available: boolean;
|
|
125
|
+
reason?: string;
|
|
126
|
+
}>;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/llm/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,eAAe,GAEvB,YAAY,GACZ,YAAY,GACZ,YAAY,GAEZ,aAAa,GACb,QAAQ,GACR,OAAO,GACP,YAAY,GAEZ,aAAa,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,eAAe,CAAC;IACtB,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CA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AQ,CAAC,YAAY,EAAE,uBAAuB,CAAC;IAE/C;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+BAA+B;IAC/B,KAAK,EAAE,KAAK,CAAC;QACX,wEAAwE;QACxE,IAAI,EAAE,MAAM,CAAC;QACb,yCAAyC;QACzC,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,WAAW,EAAE,eAAe,GAAG,IAAI,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,eAAe,EAAE;QAC/B,SAAS,EAAE,OAAO,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/llm/types.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./rule-parser"), exports);
|
|
18
|
+
__exportStar(require("./path-security"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,kDAAgC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path security validation error
|
|
3
|
+
*/
|
|
4
|
+
export declare class PathSecurityError extends Error {
|
|
5
|
+
readonly type: 'traversal' | 'absolute' | 'encoded' | 'null_byte' | 'symlink';
|
|
6
|
+
constructor(message: string, type: 'traversal' | 'absolute' | 'encoded' | 'null_byte' | 'symlink');
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Validate that a path is safe and within the project directory
|
|
10
|
+
*
|
|
11
|
+
* @param filePath - The file path to validate (relative to project root)
|
|
12
|
+
* @param projectRoot - The project root directory
|
|
13
|
+
* @throws PathSecurityError if the path is unsafe
|
|
14
|
+
*/
|
|
15
|
+
export declare function validatePath(filePath: string, projectRoot: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Validate that a symlink target is within the project directory
|
|
18
|
+
*
|
|
19
|
+
* @param symlinkPath - The path to the symlink
|
|
20
|
+
* @param projectRoot - The project root directory
|
|
21
|
+
* @throws PathSecurityError if the symlink target is outside the project
|
|
22
|
+
*/
|
|
23
|
+
export declare function validateSymlink(symlinkPath: string, projectRoot: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a path is safe (returns boolean instead of throwing)
|
|
26
|
+
*
|
|
27
|
+
* @param filePath - The file path to validate
|
|
28
|
+
* @param projectRoot - The project root directory
|
|
29
|
+
* @returns true if path is safe, false otherwise
|
|
30
|
+
*/
|
|
31
|
+
export declare function isPathSafe(filePath: string, projectRoot: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Sanitize a path by removing dangerous components
|
|
34
|
+
* Note: This is for display purposes only - always use validatePath for security
|
|
35
|
+
*
|
|
36
|
+
* @param filePath - The file path to sanitize
|
|
37
|
+
* @returns Sanitized path string
|
|
38
|
+
*/
|
|
39
|
+
export declare function sanitizePath(filePath: string): string;
|
|
40
|
+
//# sourceMappingURL=path-security.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-security.d.ts","sourceRoot":"","sources":["../../src/parser/path-security.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;aAGxB,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS;gBADpF,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS;CAKvF;AAwCD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CA2CxE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CA2B9E;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAOzE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CASrD"}
|
|
@@ -0,0 +1,183 @@
|
|
|
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.PathSecurityError = void 0;
|
|
37
|
+
exports.validatePath = validatePath;
|
|
38
|
+
exports.validateSymlink = validateSymlink;
|
|
39
|
+
exports.isPathSafe = isPathSafe;
|
|
40
|
+
exports.sanitizePath = sanitizePath;
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
/**
|
|
44
|
+
* Path security validation error
|
|
45
|
+
*/
|
|
46
|
+
class PathSecurityError extends Error {
|
|
47
|
+
type;
|
|
48
|
+
constructor(message, type) {
|
|
49
|
+
super(message);
|
|
50
|
+
this.type = type;
|
|
51
|
+
this.name = 'PathSecurityError';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.PathSecurityError = PathSecurityError;
|
|
55
|
+
/**
|
|
56
|
+
* Dangerous patterns that indicate path traversal attempts
|
|
57
|
+
*/
|
|
58
|
+
const TRAVERSAL_PATTERNS = [
|
|
59
|
+
/\.\./, // Parent directory reference
|
|
60
|
+
/\.\.%2[fF]/, // URL-encoded ../
|
|
61
|
+
/%2[fF]\.\./, // URL-encoded /..
|
|
62
|
+
/%252[fF]/, // Double-encoded /
|
|
63
|
+
/%00/, // Null byte (URL encoded)
|
|
64
|
+
/\0/, // Null byte (literal)
|
|
65
|
+
];
|
|
66
|
+
/**
|
|
67
|
+
* Check if a path contains traversal attempts
|
|
68
|
+
*/
|
|
69
|
+
function containsTraversalAttempt(filePath) {
|
|
70
|
+
return TRAVERSAL_PATTERNS.some(pattern => pattern.test(filePath));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Check if a path is absolute
|
|
74
|
+
*/
|
|
75
|
+
function isAbsolutePath(filePath) {
|
|
76
|
+
// Check for Windows-style paths (C:\ or \\)
|
|
77
|
+
if (/^[a-zA-Z]:[\\/]/.test(filePath) || filePath.startsWith('\\\\')) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
// Check for Unix-style absolute paths
|
|
81
|
+
return path.isAbsolute(filePath);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Check if a path contains null bytes
|
|
85
|
+
*/
|
|
86
|
+
function containsNullByte(filePath) {
|
|
87
|
+
return filePath.includes('\0') || /%00/i.test(filePath);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Validate that a path is safe and within the project directory
|
|
91
|
+
*
|
|
92
|
+
* @param filePath - The file path to validate (relative to project root)
|
|
93
|
+
* @param projectRoot - The project root directory
|
|
94
|
+
* @throws PathSecurityError if the path is unsafe
|
|
95
|
+
*/
|
|
96
|
+
function validatePath(filePath, projectRoot) {
|
|
97
|
+
// Check for null bytes first (most critical)
|
|
98
|
+
if (containsNullByte(filePath)) {
|
|
99
|
+
throw new PathSecurityError(`Path contains null byte: ${filePath}`, 'null_byte');
|
|
100
|
+
}
|
|
101
|
+
// Check for URL-encoded traversal patterns
|
|
102
|
+
if (/%2[fF]/.test(filePath) || /%252[fF]/.test(filePath)) {
|
|
103
|
+
throw new PathSecurityError(`Path contains URL-encoded characters: ${filePath}`, 'encoded');
|
|
104
|
+
}
|
|
105
|
+
// Check for absolute paths
|
|
106
|
+
if (isAbsolutePath(filePath)) {
|
|
107
|
+
throw new PathSecurityError(`Absolute paths are not allowed: ${filePath}`, 'absolute');
|
|
108
|
+
}
|
|
109
|
+
// Check for traversal attempts
|
|
110
|
+
if (containsTraversalAttempt(filePath)) {
|
|
111
|
+
throw new PathSecurityError(`Path traversal detected: ${filePath}`, 'traversal');
|
|
112
|
+
}
|
|
113
|
+
// Resolve the full path and verify it's within project
|
|
114
|
+
const resolvedPath = path.resolve(projectRoot, filePath);
|
|
115
|
+
const normalizedProject = path.normalize(projectRoot);
|
|
116
|
+
if (!resolvedPath.startsWith(normalizedProject)) {
|
|
117
|
+
throw new PathSecurityError(`Path escapes project directory: ${filePath}`, 'traversal');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Validate that a symlink target is within the project directory
|
|
122
|
+
*
|
|
123
|
+
* @param symlinkPath - The path to the symlink
|
|
124
|
+
* @param projectRoot - The project root directory
|
|
125
|
+
* @throws PathSecurityError if the symlink target is outside the project
|
|
126
|
+
*/
|
|
127
|
+
function validateSymlink(symlinkPath, projectRoot) {
|
|
128
|
+
const fullPath = path.resolve(projectRoot, symlinkPath);
|
|
129
|
+
try {
|
|
130
|
+
const stats = fs.lstatSync(fullPath);
|
|
131
|
+
if (!stats.isSymbolicLink()) {
|
|
132
|
+
return; // Not a symlink, nothing to validate
|
|
133
|
+
}
|
|
134
|
+
// Get the real path (follows all symlinks)
|
|
135
|
+
const realPath = fs.realpathSync(fullPath);
|
|
136
|
+
// Also resolve the project root to handle macOS /var -> /private/var symlinks
|
|
137
|
+
const realProjectRoot = fs.realpathSync(projectRoot);
|
|
138
|
+
if (!realPath.startsWith(realProjectRoot)) {
|
|
139
|
+
throw new PathSecurityError(`Symlink target is outside project: ${symlinkPath} -> ${realPath}`, 'symlink');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
if (error instanceof PathSecurityError) {
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
// File doesn't exist or can't be read - that's okay for validation
|
|
147
|
+
// The actual file reading will fail later with a clearer error
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Check if a path is safe (returns boolean instead of throwing)
|
|
152
|
+
*
|
|
153
|
+
* @param filePath - The file path to validate
|
|
154
|
+
* @param projectRoot - The project root directory
|
|
155
|
+
* @returns true if path is safe, false otherwise
|
|
156
|
+
*/
|
|
157
|
+
function isPathSafe(filePath, projectRoot) {
|
|
158
|
+
try {
|
|
159
|
+
validatePath(filePath, projectRoot);
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Sanitize a path by removing dangerous components
|
|
168
|
+
* Note: This is for display purposes only - always use validatePath for security
|
|
169
|
+
*
|
|
170
|
+
* @param filePath - The file path to sanitize
|
|
171
|
+
* @returns Sanitized path string
|
|
172
|
+
*/
|
|
173
|
+
function sanitizePath(filePath) {
|
|
174
|
+
return filePath
|
|
175
|
+
.replace(/\0/g, '') // Remove null bytes
|
|
176
|
+
.replace(/%00/gi, '') // Remove encoded null bytes
|
|
177
|
+
.replace(/%2[fF]/g, '/') // Decode URL-encoded slashes
|
|
178
|
+
.replace(/%252[fF]/g, '/') // Decode double-encoded slashes
|
|
179
|
+
.replace(/\.\./g, '') // Remove parent references
|
|
180
|
+
.replace(/\/+/g, '/') // Normalize multiple slashes
|
|
181
|
+
.replace(/^\//, ''); // Remove leading slash
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=path-security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-security.js","sourceRoot":"","sources":["../../src/parser/path-security.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,oCA2CC;AASD,0CA2BC;AASD,gCAOC;AASD,oCASC;AA9KD,uCAAyB;AACzB,2CAA6B;AAE7B;;GAEG;AACH,MAAa,iBAAkB,SAAQ,KAAK;IAGxB;IAFlB,YACE,OAAe,EACC,IAAoE;QAEpF,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,SAAI,GAAJ,IAAI,CAAgE;QAGpF,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AARD,8CAQC;AAED;;GAEG;AACH,MAAM,kBAAkB,GAAG;IACzB,MAAM,EAAqB,6BAA6B;IACxD,YAAY,EAAe,kBAAkB;IAC7C,YAAY,EAAe,kBAAkB;IAC7C,UAAU,EAAiB,mBAAmB;IAC9C,KAAK,EAAsB,0BAA0B;IACrD,IAAI,EAAuB,s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;QACd,CAAC;QACD,mEAAmE;QACnE,+DAA+D;IACjE,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,QAAgB,EAAE,WAAmB;IAC9D,IAAI,CAAC;QACH,YAAY,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,QAAgB;IAC3C,OAAO,QAAQ;SACZ,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAW,oBAAoB;SACjD,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAS,4BAA4B;SACzD,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAM,6BAA6B;SAC1D,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,CAAI,gCAAgC;SAC7D,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAS,2BAA2B;SACxD,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAS,6BAA6B;SAC1D,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAU,uBAAuB;AACzD,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ParsedRule } from '../schemas/rule';
|
|
3
|
+
/**
|
|
4
|
+
* Error thrown when rule parsing fails
|
|
5
|
+
*/
|
|
6
|
+
export declare class RuleParseError extends Error {
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly line?: number | undefined;
|
|
9
|
+
readonly details?: z.ZodError | undefined;
|
|
10
|
+
constructor(message: string, path: string, line?: number | undefined, details?: z.ZodError | undefined);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Options for parsing rules
|
|
14
|
+
*/
|
|
15
|
+
export interface ParseOptions {
|
|
16
|
+
/** Project root directory */
|
|
17
|
+
projectRoot: string;
|
|
18
|
+
/** Path to the rules directory (default: .context/rules) */
|
|
19
|
+
rulesDir?: string;
|
|
20
|
+
/** Whether to validate symlinks (default: true) */
|
|
21
|
+
validateSymlinks?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parse a single rule file
|
|
25
|
+
*
|
|
26
|
+
* @param filePath - Path to the rule file (relative to rulesDir)
|
|
27
|
+
* @param options - Parse options
|
|
28
|
+
* @returns Parsed rule
|
|
29
|
+
* @throws RuleParseError if parsing fails
|
|
30
|
+
* @throws PathSecurityError if path is unsafe
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseRule(filePath: string, options: ParseOptions): ParsedRule;
|
|
33
|
+
/**
|
|
34
|
+
* Parse all rule files in a directory
|
|
35
|
+
*
|
|
36
|
+
* @param options - Parse options
|
|
37
|
+
* @returns Array of parsed rules and any errors encountered
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseAllRules(options: ParseOptions): {
|
|
40
|
+
rules: ParsedRule[];
|
|
41
|
+
errors: RuleParseError[];
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Check if a file has valid frontmatter without fully parsing
|
|
45
|
+
*
|
|
46
|
+
* @param content - File content
|
|
47
|
+
* @returns true if frontmatter appears valid
|
|
48
|
+
*/
|
|
49
|
+
export declare function hasValidFrontmatter(content: string): boolean;
|
|
50
|
+
//# sourceMappingURL=rule-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-parser.d.ts","sourceRoot":"","sources":["../../src/parser/rule-parser.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAGL,UAAU,EAEX,MAAM,iBAAiB,CAAC;AAGzB;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;aAGrB,IAAI,EAAE,MAAM;aACZ,IAAI,CAAC,EAAE,MAAM;aACb,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ;gBAHpC,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,YAAA,EACb,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,YAAA;CAKvC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,6BAA6B;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,UAAU,CAwF7E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG;IACpD,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,MAAM,EAAE,cAAc,EAAE,CAAC;CAC1B,CAqDA;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAc5D"}
|