@a1st/aix-core 0.0.3 → 0.0.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.
Files changed (135) hide show
  1. package/README.md +39 -0
  2. package/dist/cache/index.d.ts +1 -1
  3. package/dist/cache/index.d.ts.map +1 -1
  4. package/dist/cache/index.js +1 -1
  5. package/dist/cache/index.js.map +1 -1
  6. package/dist/cache/paths.d.ts +13 -8
  7. package/dist/cache/paths.d.ts.map +1 -1
  8. package/dist/cache/paths.js +19 -12
  9. package/dist/cache/paths.js.map +1 -1
  10. package/dist/editors/adapters/base.d.ts +9 -1
  11. package/dist/editors/adapters/base.d.ts.map +1 -1
  12. package/dist/editors/adapters/base.js +7 -5
  13. package/dist/editors/adapters/base.js.map +1 -1
  14. package/dist/editors/adapters/claude-code.d.ts +2 -1
  15. package/dist/editors/adapters/claude-code.d.ts.map +1 -1
  16. package/dist/editors/adapters/claude-code.js +13 -5
  17. package/dist/editors/adapters/claude-code.js.map +1 -1
  18. package/dist/editors/adapters/codex.d.ts +1 -0
  19. package/dist/editors/adapters/codex.d.ts.map +1 -1
  20. package/dist/editors/adapters/codex.js +9 -1
  21. package/dist/editors/adapters/codex.js.map +1 -1
  22. package/dist/editors/adapters/cursor.d.ts +1 -0
  23. package/dist/editors/adapters/cursor.d.ts.map +1 -1
  24. package/dist/editors/adapters/cursor.js +9 -1
  25. package/dist/editors/adapters/cursor.js.map +1 -1
  26. package/dist/editors/adapters/vscode.d.ts +1 -0
  27. package/dist/editors/adapters/vscode.d.ts.map +1 -1
  28. package/dist/editors/adapters/vscode.js +9 -1
  29. package/dist/editors/adapters/vscode.js.map +1 -1
  30. package/dist/editors/adapters/windsurf.d.ts +1 -0
  31. package/dist/editors/adapters/windsurf.d.ts.map +1 -1
  32. package/dist/editors/adapters/windsurf.js +9 -1
  33. package/dist/editors/adapters/windsurf.js.map +1 -1
  34. package/dist/editors/adapters/zed.d.ts +1 -0
  35. package/dist/editors/adapters/zed.d.ts.map +1 -1
  36. package/dist/editors/adapters/zed.js +9 -1
  37. package/dist/editors/adapters/zed.js.map +1 -1
  38. package/dist/editors/import.d.ts +2 -1
  39. package/dist/editors/import.d.ts.map +1 -1
  40. package/dist/editors/import.js +12 -9
  41. package/dist/editors/import.js.map +1 -1
  42. package/dist/editors/install.d.ts.map +1 -1
  43. package/dist/editors/install.js +1 -36
  44. package/dist/editors/install.js.map +1 -1
  45. package/dist/editors/strategies/claude-code/mcp.d.ts +6 -2
  46. package/dist/editors/strategies/claude-code/mcp.d.ts.map +1 -1
  47. package/dist/editors/strategies/claude-code/mcp.js +40 -2
  48. package/dist/editors/strategies/claude-code/mcp.js.map +1 -1
  49. package/dist/editors/strategies/claude-code/prompts.d.ts +11 -1
  50. package/dist/editors/strategies/claude-code/prompts.d.ts.map +1 -1
  51. package/dist/editors/strategies/claude-code/prompts.js +29 -0
  52. package/dist/editors/strategies/claude-code/prompts.js.map +1 -1
  53. package/dist/editors/strategies/claude-code/rules.d.ts +12 -1
  54. package/dist/editors/strategies/claude-code/rules.d.ts.map +1 -1
  55. package/dist/editors/strategies/claude-code/rules.js +49 -5
  56. package/dist/editors/strategies/claude-code/rules.js.map +1 -1
  57. package/dist/editors/strategies/codex/prompts.d.ts +11 -1
  58. package/dist/editors/strategies/codex/prompts.d.ts.map +1 -1
  59. package/dist/editors/strategies/codex/prompts.js +34 -0
  60. package/dist/editors/strategies/codex/prompts.js.map +1 -1
  61. package/dist/editors/strategies/cursor/rules.d.ts +14 -1
  62. package/dist/editors/strategies/cursor/rules.d.ts.map +1 -1
  63. package/dist/editors/strategies/cursor/rules.js +51 -5
  64. package/dist/editors/strategies/cursor/rules.js.map +1 -1
  65. package/dist/editors/strategies/shared/standard-mcp.d.ts +3 -1
  66. package/dist/editors/strategies/shared/standard-mcp.d.ts.map +1 -1
  67. package/dist/editors/strategies/shared/standard-mcp.js +5 -1
  68. package/dist/editors/strategies/shared/standard-mcp.js.map +1 -1
  69. package/dist/editors/strategies/types.d.ts +48 -2
  70. package/dist/editors/strategies/types.d.ts.map +1 -1
  71. package/dist/editors/strategies/vscode/prompts.d.ts +11 -1
  72. package/dist/editors/strategies/vscode/prompts.d.ts.map +1 -1
  73. package/dist/editors/strategies/vscode/prompts.js +29 -0
  74. package/dist/editors/strategies/vscode/prompts.js.map +1 -1
  75. package/dist/editors/strategies/windsurf/prompts.d.ts +11 -1
  76. package/dist/editors/strategies/windsurf/prompts.d.ts.map +1 -1
  77. package/dist/editors/strategies/windsurf/prompts.js +29 -0
  78. package/dist/editors/strategies/windsurf/prompts.js.map +1 -1
  79. package/dist/editors/strategies/windsurf/rules.d.ts +14 -1
  80. package/dist/editors/strategies/windsurf/rules.d.ts.map +1 -1
  81. package/dist/editors/strategies/windsurf/rules.js +43 -5
  82. package/dist/editors/strategies/windsurf/rules.js.map +1 -1
  83. package/dist/editors/types.d.ts +12 -0
  84. package/dist/editors/types.d.ts.map +1 -1
  85. package/dist/frontmatter-parser.d.ts +24 -0
  86. package/dist/frontmatter-parser.d.ts.map +1 -0
  87. package/dist/frontmatter-parser.js +137 -0
  88. package/dist/frontmatter-parser.js.map +1 -0
  89. package/dist/frontmatter-utils.d.ts +36 -0
  90. package/dist/frontmatter-utils.d.ts.map +1 -0
  91. package/dist/frontmatter-utils.js +109 -0
  92. package/dist/frontmatter-utils.js.map +1 -0
  93. package/dist/git-download.d.ts +18 -0
  94. package/dist/git-download.d.ts.map +1 -0
  95. package/dist/git-download.js +49 -0
  96. package/dist/git-download.js.map +1 -0
  97. package/dist/import-writer.d.ts +54 -10
  98. package/dist/import-writer.d.ts.map +1 -1
  99. package/dist/import-writer.js +305 -44
  100. package/dist/import-writer.js.map +1 -1
  101. package/dist/inheritance.d.ts +2 -0
  102. package/dist/inheritance.d.ts.map +1 -1
  103. package/dist/inheritance.js +172 -41
  104. package/dist/inheritance.js.map +1 -1
  105. package/dist/loader.d.ts +13 -0
  106. package/dist/loader.d.ts.map +1 -1
  107. package/dist/loader.js +5 -1
  108. package/dist/loader.js.map +1 -1
  109. package/dist/prompts/loader.d.ts.map +1 -1
  110. package/dist/prompts/loader.js +11 -39
  111. package/dist/prompts/loader.js.map +1 -1
  112. package/dist/remote-loader.d.ts +17 -1
  113. package/dist/remote-loader.d.ts.map +1 -1
  114. package/dist/remote-loader.js +76 -44
  115. package/dist/remote-loader.js.map +1 -1
  116. package/dist/rules/loader.d.ts.map +1 -1
  117. package/dist/rules/loader.js +23 -13
  118. package/dist/rules/loader.js.map +1 -1
  119. package/dist/skills/parser.d.ts +3 -1
  120. package/dist/skills/parser.d.ts.map +1 -1
  121. package/dist/skills/parser.js +22 -10
  122. package/dist/skills/parser.js.map +1 -1
  123. package/dist/skills/resolvers/git.d.ts.map +1 -1
  124. package/dist/skills/resolvers/git.js +10 -2
  125. package/dist/skills/resolvers/git.js.map +1 -1
  126. package/dist/skills/validate.js +1 -1
  127. package/dist/skills/validate.js.map +1 -1
  128. package/dist/updater.d.ts.map +1 -1
  129. package/dist/updater.js +5 -12
  130. package/dist/updater.js.map +1 -1
  131. package/dist/url-parsing.d.ts +1 -4
  132. package/dist/url-parsing.d.ts.map +1 -1
  133. package/dist/url-parsing.js +2 -6
  134. package/dist/url-parsing.js.map +1 -1
  135. package/package.json +11 -1
@@ -86,6 +86,13 @@ export interface ApplyOptions {
86
86
  * This ensures the folder contents exactly match what ai.json declares.
87
87
  */
88
88
  clean?: boolean;
89
+ /**
90
+ * Base directory/URL for resolving relative paths in the config (skills, rules, etc.). When
91
+ * installing from a remote URL, this is the remote URL directory. When installing from a local
92
+ * config, this defaults to the directory containing the config file. If not provided, falls back
93
+ * to projectRoot.
94
+ */
95
+ configBaseDir?: string;
89
96
  }
90
97
  /**
91
98
  * Category of a file change for display grouping.
@@ -144,6 +151,11 @@ export interface ApplyResult {
144
151
  export interface EditorAdapter {
145
152
  readonly name: EditorName;
146
153
  readonly configDir: string;
154
+ /**
155
+ * Get the global data/config paths for this editor by platform. Used to detect if the editor is
156
+ * installed globally on the system. Paths are relative to the user's home directory.
157
+ */
158
+ getGlobalDataPaths(): Partial<Record<NodeJS.Platform, string[]>>;
147
159
  /**
148
160
  * Check if this editor's config directory exists in the project.
149
161
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/editors/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IACjC,wEAAwE;IACxE,GAAG,CAAC,EAAE;QACH,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IACF,qCAAqC;IACrC,KAAK,CAAC,EAAE;QACL,MAAM,EAAE,MAAM,CAAC;QACf,4EAA4E;QAC5E,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;QAC7B,mDAAmD;QACnD,cAAc,CAAC,EAAE,OAAO,CAAC;KAC3B,CAAC;IACF,wEAAwE;IACxE,OAAO,CAAC,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACJ;AAED,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC;AAE5F;;GAEG;AACH,MAAM,WAAW,UAAU;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE;QACT,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;QAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;IACF,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CA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W,CAAC,CAAC;IAErG;;OAEG;IACH,sBAAsB,CAAC,MAAM,EAAE,YAAY,GAAG,mBAAmB,CAAC;CACpE"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Auto-detecting frontmatter parser that uses editor-specific strategies to parse frontmatter.
3
+ * Uses ordered priority for detection: Windsurf → Cursor → Claude Code → VS Code.
4
+ */
5
+ import type { ParsedRuleFrontmatter, ParsedPromptFrontmatter, RulesStrategy, PromptsStrategy } from './editors/strategies/types.js';
6
+ /**
7
+ * Parse rule frontmatter using auto-detection. Tries each strategy in priority order and uses the
8
+ * first one that detects its format. Falls back to generic parsing if no strategy matches.
9
+ *
10
+ * @param rawContent - Raw markdown content potentially containing front-matter
11
+ * @param strategy - Optional specific strategy to use (skips auto-detection)
12
+ * @returns Parsed frontmatter with unified metadata
13
+ */
14
+ export declare function parseRuleFrontmatter(rawContent: string, strategy?: RulesStrategy): ParsedRuleFrontmatter;
15
+ /**
16
+ * Parse prompt frontmatter using auto-detection. Tries each strategy in priority order and uses
17
+ * the first one that detects its format. Falls back to generic parsing if no strategy matches.
18
+ *
19
+ * @param rawContent - Raw markdown content potentially containing front-matter
20
+ * @param strategy - Optional specific strategy to use (skips auto-detection)
21
+ * @returns Parsed frontmatter with unified fields
22
+ */
23
+ export declare function parsePromptFrontmatter(rawContent: string, strategy?: PromptsStrategy): ParsedPromptFrontmatter;
24
+ //# sourceMappingURL=frontmatter-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter-parser.d.ts","sourceRoot":"","sources":["../src/frontmatter-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAyBpI;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CACjC,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,aAAa,GACxB,qBAAqB,CAevB;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACnC,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,eAAe,GAC1B,uBAAuB,CAezB"}
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Auto-detecting frontmatter parser that uses editor-specific strategies to parse frontmatter.
3
+ * Uses ordered priority for detection: Windsurf → Cursor → Claude Code → VS Code.
4
+ */
5
+ import { WindsurfRulesStrategy } from './editors/strategies/windsurf/rules.js';
6
+ import { WindsurfPromptsStrategy } from './editors/strategies/windsurf/prompts.js';
7
+ import { CursorRulesStrategy } from './editors/strategies/cursor/rules.js';
8
+ import { ClaudeCodeRulesStrategy } from './editors/strategies/claude-code/rules.js';
9
+ import { ClaudeCodePromptsStrategy } from './editors/strategies/claude-code/prompts.js';
10
+ import { VSCodePromptsStrategy } from './editors/strategies/vscode/prompts.js';
11
+ import { CodexPromptsStrategy } from './editors/strategies/codex/prompts.js';
12
+ import { extractFrontmatter, parseYamlValue } from './frontmatter-utils.js';
13
+ /** Ordered list of rules strategies for auto-detection (priority order) */
14
+ const RULES_STRATEGIES = [
15
+ new WindsurfRulesStrategy(),
16
+ new CursorRulesStrategy(),
17
+ new ClaudeCodeRulesStrategy(),
18
+ ];
19
+ /** Ordered list of prompts strategies for auto-detection (priority order) */
20
+ const PROMPTS_STRATEGIES = [
21
+ new WindsurfPromptsStrategy(),
22
+ new ClaudeCodePromptsStrategy(),
23
+ new VSCodePromptsStrategy(),
24
+ new CodexPromptsStrategy(),
25
+ ];
26
+ /**
27
+ * Parse rule frontmatter using auto-detection. Tries each strategy in priority order and uses the
28
+ * first one that detects its format. Falls back to generic parsing if no strategy matches.
29
+ *
30
+ * @param rawContent - Raw markdown content potentially containing front-matter
31
+ * @param strategy - Optional specific strategy to use (skips auto-detection)
32
+ * @returns Parsed frontmatter with unified metadata
33
+ */
34
+ export function parseRuleFrontmatter(rawContent, strategy) {
35
+ // Use provided strategy if given
36
+ if (strategy?.parseFrontmatter) {
37
+ return strategy.parseFrontmatter(rawContent);
38
+ }
39
+ // Try auto-detection with priority order
40
+ for (const strat of RULES_STRATEGIES) {
41
+ if (strat.detectFormat?.(rawContent)) {
42
+ return strat.parseFrontmatter(rawContent);
43
+ }
44
+ }
45
+ // Fall back to generic parsing
46
+ return parseGenericRuleFrontmatter(rawContent);
47
+ }
48
+ /**
49
+ * Parse prompt frontmatter using auto-detection. Tries each strategy in priority order and uses
50
+ * the first one that detects its format. Falls back to generic parsing if no strategy matches.
51
+ *
52
+ * @param rawContent - Raw markdown content potentially containing front-matter
53
+ * @param strategy - Optional specific strategy to use (skips auto-detection)
54
+ * @returns Parsed frontmatter with unified fields
55
+ */
56
+ export function parsePromptFrontmatter(rawContent, strategy) {
57
+ // Use provided strategy if given
58
+ if (strategy?.parseFrontmatter) {
59
+ return strategy.parseFrontmatter(rawContent);
60
+ }
61
+ // Try auto-detection with priority order
62
+ for (const strat of PROMPTS_STRATEGIES) {
63
+ if (strat.detectFormat?.(rawContent)) {
64
+ return strat.parseFrontmatter(rawContent);
65
+ }
66
+ }
67
+ // Fall back to generic parsing
68
+ return parseGenericPromptFrontmatter(rawContent);
69
+ }
70
+ /**
71
+ * Generic rule frontmatter parsing that handles common fields across editors.
72
+ * Used as fallback when no editor-specific format is detected.
73
+ */
74
+ function parseGenericRuleFrontmatter(rawContent) {
75
+ const { frontmatter, content, hasFrontmatter } = extractFrontmatter(rawContent);
76
+ if (!hasFrontmatter) {
77
+ return { content: rawContent, metadata: {} };
78
+ }
79
+ const lines = frontmatter.split('\n'), description = parseYamlValue(lines, 'description'), globs = parseYamlValue(lines, 'globs'), paths = parseYamlValue(lines, 'paths'), trigger = parseYamlValue(lines, 'trigger'), alwaysApply = parseYamlValue(lines, 'alwaysApply');
80
+ // Parse globs from various sources
81
+ let globsArray;
82
+ if (typeof globs === 'string') {
83
+ globsArray = globs.split(',').map((g) => g.trim());
84
+ }
85
+ else if (Array.isArray(globs)) {
86
+ globsArray = globs;
87
+ }
88
+ else if (Array.isArray(paths)) {
89
+ globsArray = paths;
90
+ }
91
+ // Determine activation mode from various editor formats
92
+ let activation;
93
+ // Windsurf trigger values
94
+ const triggerToActivation = {
95
+ always_on: 'always',
96
+ model_decision: 'auto',
97
+ glob: 'glob',
98
+ manual: 'manual',
99
+ };
100
+ if (trigger && triggerToActivation[trigger]) {
101
+ activation = triggerToActivation[trigger];
102
+ }
103
+ else if (alwaysApply === true) {
104
+ activation = 'always';
105
+ }
106
+ else if (globsArray && globsArray.length > 0) {
107
+ activation = 'glob';
108
+ }
109
+ else if (alwaysApply === false) {
110
+ activation = description ? 'auto' : 'manual';
111
+ }
112
+ return {
113
+ content,
114
+ metadata: {
115
+ activation,
116
+ description,
117
+ globs: globsArray,
118
+ },
119
+ };
120
+ }
121
+ /**
122
+ * Generic prompt frontmatter parsing that handles common fields across editors.
123
+ * Used as fallback when no editor-specific format is detected.
124
+ */
125
+ function parseGenericPromptFrontmatter(rawContent) {
126
+ const { frontmatter, content, hasFrontmatter } = extractFrontmatter(rawContent);
127
+ if (!hasFrontmatter) {
128
+ return { content: rawContent };
129
+ }
130
+ const lines = frontmatter.split('\n'), description = parseYamlValue(lines, 'description'), argumentHint = parseYamlValue(lines, 'argument-hint');
131
+ return {
132
+ content,
133
+ description,
134
+ argumentHint,
135
+ };
136
+ }
137
+ //# sourceMappingURL=frontmatter-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter-parser.js","sourceRoot":"","sources":["../src/frontmatter-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EAAE,q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YAAY;KACd,CAAC;AACL,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Shared utilities for parsing YAML front-matter from markdown files. These low-level utilities are
3
+ * used by editor-specific strategies to implement their own frontmatter parsing.
4
+ */
5
+ /**
6
+ * Result of extracting frontmatter from content.
7
+ */
8
+ export interface ExtractedFrontmatter {
9
+ /** The frontmatter content (without delimiters) */
10
+ frontmatter: string;
11
+ /** The content after the frontmatter */
12
+ content: string;
13
+ /** Whether frontmatter was found */
14
+ hasFrontmatter: boolean;
15
+ }
16
+ /**
17
+ * Extract YAML frontmatter from markdown content.
18
+ * @param rawContent - Raw markdown content potentially containing front-matter
19
+ * @returns Extracted frontmatter and remaining content
20
+ */
21
+ export declare function extractFrontmatter(rawContent: string): ExtractedFrontmatter;
22
+ /**
23
+ * Parse a YAML value from frontmatter by key.
24
+ * @param lines - Array of frontmatter lines (joined back for YAML parsing)
25
+ * @param key - The key to look for
26
+ * @returns The parsed value, or undefined if not found
27
+ */
28
+ export declare function parseYamlValue(lines: string[], key: string): string | boolean | string[] | undefined;
29
+ /**
30
+ * Parse all key-value pairs from frontmatter into a raw object using the yaml library.
31
+ * Falls back to simple line-based parsing if YAML parsing fails (e.g., for unquoted glob patterns).
32
+ * @param frontmatter - The frontmatter content (without delimiters)
33
+ * @returns Object with all parsed key-value pairs
34
+ */
35
+ export declare function parseAllFrontmatter(frontmatter: string): Record<string, unknown>;
36
+ //# sourceMappingURL=frontmatter-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter-utils.d.ts","sourceRoot":"","sources":["../src/frontmatter-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IAClC,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,cAAc,EAAE,OAAO,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,oBAAoB,CAY3E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,SAAS,CAgBpG;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAahF"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Shared utilities for parsing YAML front-matter from markdown files. These low-level utilities are
3
+ * used by editor-specific strategies to implement their own frontmatter parsing.
4
+ */
5
+ import { parse as parseYaml } from 'yaml';
6
+ /**
7
+ * Extract YAML frontmatter from markdown content.
8
+ * @param rawContent - Raw markdown content potentially containing front-matter
9
+ * @returns Extracted frontmatter and remaining content
10
+ */
11
+ export function extractFrontmatter(rawContent) {
12
+ const frontmatterMatch = rawContent.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/);
13
+ if (!frontmatterMatch) {
14
+ return { frontmatter: '', content: rawContent, hasFrontmatter: false };
15
+ }
16
+ return {
17
+ frontmatter: frontmatterMatch[1],
18
+ content: rawContent.slice(frontmatterMatch[0].length).trim(),
19
+ hasFrontmatter: true,
20
+ };
21
+ }
22
+ /**
23
+ * Parse a YAML value from frontmatter by key.
24
+ * @param lines - Array of frontmatter lines (joined back for YAML parsing)
25
+ * @param key - The key to look for
26
+ * @returns The parsed value, or undefined if not found
27
+ */
28
+ export function parseYamlValue(lines, key) {
29
+ const frontmatter = lines.join('\n'), parsed = parseAllFrontmatter(frontmatter), value = parsed[key];
30
+ if (value === undefined) {
31
+ return undefined;
32
+ }
33
+ // Return primitives and arrays directly
34
+ if (typeof value === 'string' || typeof value === 'boolean' || Array.isArray(value)) {
35
+ return value;
36
+ }
37
+ // Convert other types to string
38
+ return String(value);
39
+ }
40
+ /**
41
+ * Parse all key-value pairs from frontmatter into a raw object using the yaml library.
42
+ * Falls back to simple line-based parsing if YAML parsing fails (e.g., for unquoted glob patterns).
43
+ * @param frontmatter - The frontmatter content (without delimiters)
44
+ * @returns Object with all parsed key-value pairs
45
+ */
46
+ export function parseAllFrontmatter(frontmatter) {
47
+ if (!frontmatter.trim()) {
48
+ return {};
49
+ }
50
+ try {
51
+ const parsed = parseYaml(frontmatter);
52
+ return parsed ?? {};
53
+ }
54
+ catch {
55
+ // Fall back to simple line-based parsing for edge cases like unquoted glob patterns
56
+ return parseSimpleFrontmatter(frontmatter);
57
+ }
58
+ }
59
+ /**
60
+ * Simple line-based frontmatter parser for cases where YAML parsing fails.
61
+ * Handles basic key: value pairs and YAML arrays.
62
+ */
63
+ function parseSimpleFrontmatter(frontmatter) {
64
+ const result = {}, lines = frontmatter.split('\n');
65
+ let currentKey = null, arrayValues = [];
66
+ for (const line of lines) {
67
+ // Check for array item (indented with -)
68
+ const arrayItemMatch = line.match(/^\s+-\s+(.+)$/);
69
+ if (arrayItemMatch && currentKey) {
70
+ arrayValues.push(arrayItemMatch[1].trim());
71
+ continue;
72
+ }
73
+ // If we were collecting array values, store them
74
+ if (currentKey && arrayValues.length > 0) {
75
+ result[currentKey] = arrayValues;
76
+ arrayValues = [];
77
+ currentKey = null;
78
+ }
79
+ // Check for key: value pair
80
+ const keyValueMatch = line.match(/^([\w-]+):\s*(.*)$/);
81
+ if (!keyValueMatch) {
82
+ continue;
83
+ }
84
+ const key = keyValueMatch[1], rawValue = keyValueMatch[2].trim();
85
+ // Empty value means array starts on next line
86
+ if (!rawValue) {
87
+ currentKey = key;
88
+ arrayValues = [];
89
+ continue;
90
+ }
91
+ // Boolean values
92
+ if (rawValue === 'true') {
93
+ result[key] = true;
94
+ }
95
+ else if (rawValue === 'false') {
96
+ result[key] = false;
97
+ }
98
+ else {
99
+ // Remove surrounding quotes if present
100
+ result[key] = rawValue.replace(/^["']|["']$/g, '');
101
+ }
102
+ }
103
+ // Handle any remaining array values
104
+ if (currentKey && arrayValues.length > 0) {
105
+ result[currentKey] = arrayValues;
106
+ }
107
+ return result;
108
+ }
109
+ //# sourceMappingURL=frontmatter-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter-utils.js","sourceRoot":"","sources":["../src/frontmatter-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAc1C;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAkB;IAClD,MAAM,gBAAgB,GAAG,UAAU,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;IAE/E,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACrB,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;IAC1E,CAAC;IAED,OAAO;QACJ,WAAW,EAAE,gBAAgB,CAAC,CAAC,CAAE;QACjC,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE;QAC5D,cAAc,EAAE,IAAI;KACtB,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAAe,EAAE,GAAW;IACxD,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAC9B,MAAM,GAAG,mBAAmB,CAAC,WAAW,CAAC,EACzC,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAE1B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IACpB,CAAC;IAED,wCAAwC;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACnF,OAAO,KAAoC,CAAC;IAC/C,CAAC;IAED,gC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SAAS;QACZ,CAAC;QAED,MAAM,GAAG,GAAG,aAAa,CAAC,CAAC,CAAE,EACvB,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,CAAC;QAE1C,8CAA8C;QAC9C,IAAI,CAAC,QAAQ,EAAE,CAAC;YACb,UAAU,GAAG,GAAG,CAAC;YACjB,WAAW,GAAG,EAAE,CAAC;YACjB,SAAS;QACZ,CAAC;QAED,iBAAiB;QACjB,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QACtB,CAAC;aAAM,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;YAC/B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACvB,CAAC;aAAM,CAAC;YACL,uCAAuC;YACvC,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QACtD,CAAC;IACJ,CAAC;IAED,oCAAoC;IACpC,IAAI,UAAU,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxC,MAAM,CAAC,UAAU,CAAC,GAAG,WAAW,CAAC;IACpC,CAAC;IAED,OAAO,MAAM,CAAC;AACjB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Create a unique directory name from a git template string. Includes the ref to avoid collisions
3
+ * between different branches/tags.
4
+ *
5
+ * @example "github:org/repo#main" → "org-repo-main-a1b2c3d4"
6
+ */
7
+ export declare function createDownloadKey(template: string): string;
8
+ /**
9
+ * Download a git template, run an operation, then clean up. Always cleans up after use - no
10
+ * persistent caching. This ensures the cache doesn't grow indefinitely and prevents stale data.
11
+ *
12
+ * @param template - Git template string (e.g., "github:org/repo#main")
13
+ * @param projectRoot - Project root for determining temp directory location
14
+ * @param operation - Async operation to run with the downloaded directory
15
+ * @returns Result of the operation
16
+ */
17
+ export declare function withGitDownload<T>(template: string, projectRoot: string, operation: (dir: string) => Promise<T>): Promise<T>;
18
+ //# sourceMappingURL=git-download.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-download.d.ts","sourceRoot":"","sources":["../src/git-download.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAe1D;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,CAAC,EACpC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GACtC,OAAO,CAAC,CAAC,CAAC,CAgBZ"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Safe git download utility with automatic cleanup.
3
+ */
4
+ import { join } from 'pathe';
5
+ import { downloadTemplate } from 'giget';
6
+ import { safeRm } from './fs/safe-rm.js';
7
+ import { getGitDownloadsDir } from './cache/paths.js';
8
+ /**
9
+ * Create a unique directory name from a git template string. Includes the ref to avoid collisions
10
+ * between different branches/tags.
11
+ *
12
+ * @example "github:org/repo#main" → "org-repo-main-a1b2c3d4"
13
+ */
14
+ export function createDownloadKey(template) {
15
+ // Parse template to extract components
16
+ // Format: "provider:user/repo/path#ref" or "provider:user/repo#ref"
17
+ const match = template.match(/^(?:github|gitlab|bitbucket):([^#]+)(?:#(.+))?$/);
18
+ if (match) {
19
+ const [, repoPath, ref = 'HEAD'] = match, safePath = repoPath.replace(/\//g, '-'), hash = Buffer.from(template).toString('base64url').slice(0, 8);
20
+ return `${safePath}-${ref}-${hash}`;
21
+ }
22
+ // Fallback for other formats (e.g., https URLs)
23
+ return Buffer.from(template).toString('base64url').slice(0, 32);
24
+ }
25
+ /**
26
+ * Download a git template, run an operation, then clean up. Always cleans up after use - no
27
+ * persistent caching. This ensures the cache doesn't grow indefinitely and prevents stale data.
28
+ *
29
+ * @param template - Git template string (e.g., "github:org/repo#main")
30
+ * @param projectRoot - Project root for determining temp directory location
31
+ * @param operation - Async operation to run with the downloaded directory
32
+ * @returns Result of the operation
33
+ */
34
+ export async function withGitDownload(template, projectRoot, operation) {
35
+ const downloadKey = createDownloadKey(template), targetDir = join(getGitDownloadsDir(projectRoot), downloadKey);
36
+ try {
37
+ const { dir } = await downloadTemplate(template, {
38
+ dir: targetDir,
39
+ force: true,
40
+ forceClean: true,
41
+ });
42
+ return await operation(dir);
43
+ }
44
+ finally {
45
+ // Always clean up - no persistent cache
46
+ await safeRm(targetDir, { force: true }).catch(() => { });
47
+ }
48
+ }
49
+ //# sourceMappingURL=git-download.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-download.js","sourceRoot":"","sources":["../src/git-download.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAC/C,uCAAuC;IACvC,oEAAoE;IACpE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAEhF,IAAI,KAAK,EAAE,CAAC;QACT,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,GAAG,MAAM,CAAC,GAAG,KAAK,EAClC,QAAQ,GAAG,QAAS,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EACxC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAErE,OAAO,GAAG,QAAQ,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IACvC,CAAC;IAED,gDAAgD;IAChD,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACnE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAClC,QAAgB,EAChB,WAAmB,EACnB,SAAsC;IAEtC,MAAM,WAAW,GAAG,iBAAiB,CAAC,QAAQ,CAAC,EACzC,SAAS,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,CAAC;IAErE,IAAI,CAAC;QACF,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,gBAAgB,CAAC,QAAQ,EAAE;YAC9C,GAAG,EAAE,SAAS;YACd,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,IAAI;SAClB,CAAC,CAAC;QAEH,OAAO,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;YAAS,CAAC;QACR,wCAAwC;QACxC,MAAM,MAAM,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC5D,CAAC;AACJ,CAAC"}
@@ -1,37 +1,81 @@
1
- import type { EditorName } from './editors/types.js';
1
+ import type { AiJsonConfig } from '@a1st/aix-schema';
2
+ import type { GitSourceInfo } from './remote-loader.js';
2
3
  export interface WrittenImports {
3
4
  rules: Record<string, string>;
4
5
  prompts: Record<string, string>;
5
6
  }
7
+ /** A rule with a suggested name for the output file. */
8
+ export interface NamedRule {
9
+ content: string;
10
+ name: string;
11
+ }
6
12
  export interface ImportContent {
7
- rules: string[];
13
+ rules: NamedRule[];
8
14
  prompts: Record<string, string>;
9
15
  }
16
+ export interface LocalizedConfig {
17
+ /** The config with paths updated to point to local copies */
18
+ config: Partial<AiJsonConfig>;
19
+ /** Number of files that were copied */
20
+ filesCopied: number;
21
+ /** Warnings about files that couldn't be copied */
22
+ warnings: string[];
23
+ }
10
24
  /**
11
25
  * Write imported content to staging directory and return path references.
12
- * Files are written to `.aix/.tmp/import-staging/<editor>/` and path references
13
- * point to the final location `.aix/imported/<editor>/`.
26
+ * Files are written to `.aix/.tmp/import-staging/` and path references
27
+ * point to the final location `.aix/imported/`.
14
28
  *
15
29
  * @param projectRoot - The project root directory
16
- * @param editor - The source editor name
17
30
  * @param content - The imported content (rules and prompts)
18
31
  * @returns Path references for rules and prompts (relative to project root)
19
32
  */
20
- export declare function writeImportedContent(projectRoot: string, editor: EditorName, content: ImportContent): Promise<WrittenImports>;
33
+ export declare function writeImportedContent(projectRoot: string, content: ImportContent): Promise<WrittenImports>;
21
34
  /**
22
35
  * Commit staged import: backup existing, move staging to final location, cleanup.
23
36
  * This should be called after ai.json has been successfully written.
24
37
  *
25
38
  * @param projectRoot - The project root directory
26
- * @param editor - The source editor name
27
39
  */
28
- export declare function commitImport(projectRoot: string, editor: EditorName): Promise<void>;
40
+ export declare function commitImport(projectRoot: string): Promise<void>;
29
41
  /**
30
42
  * Rollback import: delete staging, restore backup if exists.
31
43
  * This should be called if ai.json write or any subsequent step fails.
32
44
  *
33
45
  * @param projectRoot - The project root directory
34
- * @param editor - The source editor name
35
46
  */
36
- export declare function rollbackImport(projectRoot: string, editor: EditorName): Promise<void>;
47
+ export declare function rollbackImport(projectRoot: string): Promise<void>;
48
+ /**
49
+ * Localize a remote config by copying referenced files to .aix/imported/ and updating paths.
50
+ * This handles rules, prompts, and skills that have relative path references.
51
+ *
52
+ * @param config - The remote config to localize
53
+ * @param configBaseDir - The base directory where the remote config's files are located
54
+ * @param projectRoot - The local project root where files should be copied to
55
+ * @returns The localized config with updated paths
56
+ */
57
+ export declare function localizeRemoteConfig(config: Partial<AiJsonConfig>, configBaseDir: string, projectRoot: string): Promise<LocalizedConfig>;
58
+ /** Result of converting relative paths to git references */
59
+ export interface GitRefsConversionResult {
60
+ /** The config with relative paths converted to git references */
61
+ config: Partial<AiJsonConfig>;
62
+ /** Number of items converted to git references */
63
+ convertedCount: number;
64
+ /** Details of each converted reference for display */
65
+ converted: Array<{
66
+ name: string;
67
+ type: 'rule' | 'prompt' | 'skill';
68
+ gitRef: string;
69
+ }>;
70
+ }
71
+ /**
72
+ * Convert a config with relative paths to use git references instead.
73
+ * This is used when saving a remote git config with --save to preserve
74
+ * the git source rather than copying files locally.
75
+ *
76
+ * @param config - The config with relative paths
77
+ * @param gitSource - Git source metadata from the remote loader
78
+ * @returns The config with git references and conversion details
79
+ */
80
+ export declare function convertToGitReferences(config: Partial<AiJsonConfig>, gitSource: GitSourceInfo): GitRefsConversionResult;
37
81
  //# sourceMappingURL=import-writer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"import-writer.d.ts","sourceRoot":"","sources":["../src/import-writer.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,MAAM,WAAW,cAAc;IAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,aAAa;IAC3B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAyBD;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACvC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,aAAa,GACtB,OAAO,CAAC,cAAc,CAAC,CAsCzB;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAkCzF;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG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