@iamsyr/agentmind 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.
Files changed (229) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +21 -0
  3. package/README.md +462 -0
  4. package/RELEASING.md +42 -0
  5. package/dist/adapters/cursor.d.ts +2 -0
  6. package/dist/adapters/cursor.d.ts.map +1 -0
  7. package/dist/adapters/cursor.js +39 -0
  8. package/dist/adapters/cursor.js.map +1 -0
  9. package/dist/adapters/index.d.ts +9 -0
  10. package/dist/adapters/index.d.ts.map +1 -0
  11. package/dist/adapters/index.js +16 -0
  12. package/dist/adapters/index.js.map +1 -0
  13. package/dist/adapters/types.d.ts +24 -0
  14. package/dist/adapters/types.d.ts.map +1 -0
  15. package/dist/adapters/types.js +66 -0
  16. package/dist/adapters/types.js.map +1 -0
  17. package/dist/adapters/windsurf.d.ts +2 -0
  18. package/dist/adapters/windsurf.d.ts.map +1 -0
  19. package/dist/adapters/windsurf.js +44 -0
  20. package/dist/adapters/windsurf.js.map +1 -0
  21. package/dist/bridge/conflict.d.ts +9 -0
  22. package/dist/bridge/conflict.d.ts.map +1 -0
  23. package/dist/bridge/conflict.js +38 -0
  24. package/dist/bridge/conflict.js.map +1 -0
  25. package/dist/bridge/index.d.ts +5 -0
  26. package/dist/bridge/index.d.ts.map +1 -0
  27. package/dist/bridge/index.js +3 -0
  28. package/dist/bridge/index.js.map +1 -0
  29. package/dist/bridge/state.d.ts +30 -0
  30. package/dist/bridge/state.d.ts.map +1 -0
  31. package/dist/bridge/state.js +130 -0
  32. package/dist/bridge/state.js.map +1 -0
  33. package/dist/cli/commands/agents.d.ts +2 -0
  34. package/dist/cli/commands/agents.d.ts.map +1 -0
  35. package/dist/cli/commands/agents.js +38 -0
  36. package/dist/cli/commands/agents.js.map +1 -0
  37. package/dist/cli/commands/annotate.d.ts +4 -0
  38. package/dist/cli/commands/annotate.d.ts.map +1 -0
  39. package/dist/cli/commands/annotate.js +116 -0
  40. package/dist/cli/commands/annotate.js.map +1 -0
  41. package/dist/cli/commands/behaviors.d.ts +6 -0
  42. package/dist/cli/commands/behaviors.d.ts.map +1 -0
  43. package/dist/cli/commands/behaviors.js +76 -0
  44. package/dist/cli/commands/behaviors.js.map +1 -0
  45. package/dist/cli/commands/bridge.d.ts +15 -0
  46. package/dist/cli/commands/bridge.d.ts.map +1 -0
  47. package/dist/cli/commands/bridge.js +75 -0
  48. package/dist/cli/commands/bridge.js.map +1 -0
  49. package/dist/cli/commands/health.d.ts +4 -0
  50. package/dist/cli/commands/health.d.ts.map +1 -0
  51. package/dist/cli/commands/health.js +382 -0
  52. package/dist/cli/commands/health.js.map +1 -0
  53. package/dist/cli/commands/hooks.d.ts +3 -0
  54. package/dist/cli/commands/hooks.d.ts.map +1 -0
  55. package/dist/cli/commands/hooks.js +59 -0
  56. package/dist/cli/commands/hooks.js.map +1 -0
  57. package/dist/cli/commands/init.d.ts +2 -0
  58. package/dist/cli/commands/init.d.ts.map +1 -0
  59. package/dist/cli/commands/init.js +128 -0
  60. package/dist/cli/commands/init.js.map +1 -0
  61. package/dist/cli/commands/inject.d.ts +6 -0
  62. package/dist/cli/commands/inject.d.ts.map +1 -0
  63. package/dist/cli/commands/inject.js +84 -0
  64. package/dist/cli/commands/inject.js.map +1 -0
  65. package/dist/cli/commands/insights.d.ts +4 -0
  66. package/dist/cli/commands/insights.d.ts.map +1 -0
  67. package/dist/cli/commands/insights.js +124 -0
  68. package/dist/cli/commands/insights.js.map +1 -0
  69. package/dist/cli/commands/learn.d.ts +8 -0
  70. package/dist/cli/commands/learn.d.ts.map +1 -0
  71. package/dist/cli/commands/learn.js +121 -0
  72. package/dist/cli/commands/learn.js.map +1 -0
  73. package/dist/cli/commands/log-behavior.d.ts +14 -0
  74. package/dist/cli/commands/log-behavior.d.ts.map +1 -0
  75. package/dist/cli/commands/log-behavior.js +50 -0
  76. package/dist/cli/commands/log-behavior.js.map +1 -0
  77. package/dist/cli/commands/overlay.d.ts +10 -0
  78. package/dist/cli/commands/overlay.d.ts.map +1 -0
  79. package/dist/cli/commands/overlay.js +303 -0
  80. package/dist/cli/commands/overlay.js.map +1 -0
  81. package/dist/cli/commands/pull.d.ts +4 -0
  82. package/dist/cli/commands/pull.d.ts.map +1 -0
  83. package/dist/cli/commands/pull.js +93 -0
  84. package/dist/cli/commands/pull.js.map +1 -0
  85. package/dist/cli/commands/push.d.ts +5 -0
  86. package/dist/cli/commands/push.d.ts.map +1 -0
  87. package/dist/cli/commands/push.js +71 -0
  88. package/dist/cli/commands/push.js.map +1 -0
  89. package/dist/cli/commands/scan.d.ts +5 -0
  90. package/dist/cli/commands/scan.d.ts.map +1 -0
  91. package/dist/cli/commands/scan.js +134 -0
  92. package/dist/cli/commands/scan.js.map +1 -0
  93. package/dist/cli/commands/serve.d.ts +2 -0
  94. package/dist/cli/commands/serve.d.ts.map +1 -0
  95. package/dist/cli/commands/serve.js +17 -0
  96. package/dist/cli/commands/serve.js.map +1 -0
  97. package/dist/cli/commands/share.d.ts +5 -0
  98. package/dist/cli/commands/share.d.ts.map +1 -0
  99. package/dist/cli/commands/share.js +97 -0
  100. package/dist/cli/commands/share.js.map +1 -0
  101. package/dist/cli/commands/status.d.ts +2 -0
  102. package/dist/cli/commands/status.d.ts.map +1 -0
  103. package/dist/cli/commands/status.js +167 -0
  104. package/dist/cli/commands/status.js.map +1 -0
  105. package/dist/cli/commands/sync.d.ts +6 -0
  106. package/dist/cli/commands/sync.d.ts.map +1 -0
  107. package/dist/cli/commands/sync.js +60 -0
  108. package/dist/cli/commands/sync.js.map +1 -0
  109. package/dist/cli/commands/template.d.ts +5 -0
  110. package/dist/cli/commands/template.d.ts.map +1 -0
  111. package/dist/cli/commands/template.js +98 -0
  112. package/dist/cli/commands/template.js.map +1 -0
  113. package/dist/cli/index.d.ts +3 -0
  114. package/dist/cli/index.d.ts.map +1 -0
  115. package/dist/cli/index.js +172 -0
  116. package/dist/cli/index.js.map +1 -0
  117. package/dist/cli/utils.d.ts +6 -0
  118. package/dist/cli/utils.d.ts.map +1 -0
  119. package/dist/cli/utils.js +49 -0
  120. package/dist/cli/utils.js.map +1 -0
  121. package/dist/hooks/claude.d.ts +6 -0
  122. package/dist/hooks/claude.d.ts.map +1 -0
  123. package/dist/hooks/claude.js +189 -0
  124. package/dist/hooks/claude.js.map +1 -0
  125. package/dist/hooks/codex.d.ts +6 -0
  126. package/dist/hooks/codex.d.ts.map +1 -0
  127. package/dist/hooks/codex.js +120 -0
  128. package/dist/hooks/codex.js.map +1 -0
  129. package/dist/hooks/index.d.ts +5 -0
  130. package/dist/hooks/index.d.ts.map +1 -0
  131. package/dist/hooks/index.js +4 -0
  132. package/dist/hooks/index.js.map +1 -0
  133. package/dist/hooks/template.d.ts +5 -0
  134. package/dist/hooks/template.d.ts.map +1 -0
  135. package/dist/hooks/template.js +176 -0
  136. package/dist/hooks/template.js.map +1 -0
  137. package/dist/index.d.ts +5 -0
  138. package/dist/index.d.ts.map +1 -0
  139. package/dist/index.js +4 -0
  140. package/dist/index.js.map +1 -0
  141. package/dist/learn/analyzer.d.ts +11 -0
  142. package/dist/learn/analyzer.d.ts.map +1 -0
  143. package/dist/learn/analyzer.js +145 -0
  144. package/dist/learn/analyzer.js.map +1 -0
  145. package/dist/learn/generator.d.ts +12 -0
  146. package/dist/learn/generator.d.ts.map +1 -0
  147. package/dist/learn/generator.js +37 -0
  148. package/dist/learn/generator.js.map +1 -0
  149. package/dist/mcp/index.d.ts +2 -0
  150. package/dist/mcp/index.d.ts.map +1 -0
  151. package/dist/mcp/index.js +2 -0
  152. package/dist/mcp/index.js.map +1 -0
  153. package/dist/mcp/server.d.ts +2 -0
  154. package/dist/mcp/server.d.ts.map +1 -0
  155. package/dist/mcp/server.js +325 -0
  156. package/dist/mcp/server.js.map +1 -0
  157. package/dist/router/index.d.ts +3 -0
  158. package/dist/router/index.d.ts.map +1 -0
  159. package/dist/router/index.js +44 -0
  160. package/dist/router/index.js.map +1 -0
  161. package/dist/scanner/classify.d.ts +6 -0
  162. package/dist/scanner/classify.d.ts.map +1 -0
  163. package/dist/scanner/classify.js +101 -0
  164. package/dist/scanner/classify.js.map +1 -0
  165. package/dist/scanner/graph.d.ts +3 -0
  166. package/dist/scanner/graph.d.ts.map +1 -0
  167. package/dist/scanner/graph.js +104 -0
  168. package/dist/scanner/graph.js.map +1 -0
  169. package/dist/scanner/index.d.ts +6 -0
  170. package/dist/scanner/index.d.ts.map +1 -0
  171. package/dist/scanner/index.js +23 -0
  172. package/dist/scanner/index.js.map +1 -0
  173. package/dist/scanner/patterns.d.ts +3 -0
  174. package/dist/scanner/patterns.d.ts.map +1 -0
  175. package/dist/scanner/patterns.js +179 -0
  176. package/dist/scanner/patterns.js.map +1 -0
  177. package/dist/store/db.d.ts +21 -0
  178. package/dist/store/db.d.ts.map +1 -0
  179. package/dist/store/db.js +55 -0
  180. package/dist/store/db.js.map +1 -0
  181. package/dist/store/index.d.ts +3 -0
  182. package/dist/store/index.d.ts.map +1 -0
  183. package/dist/store/index.js +3 -0
  184. package/dist/store/index.js.map +1 -0
  185. package/dist/store/jsonl.d.ts +6 -0
  186. package/dist/store/jsonl.d.ts.map +1 -0
  187. package/dist/store/jsonl.js +55 -0
  188. package/dist/store/jsonl.js.map +1 -0
  189. package/dist/store/schema.d.ts +32 -0
  190. package/dist/store/schema.d.ts.map +1 -0
  191. package/dist/store/schema.js +210 -0
  192. package/dist/store/schema.js.map +1 -0
  193. package/dist/templates/go.d.ts +3 -0
  194. package/dist/templates/go.d.ts.map +1 -0
  195. package/dist/templates/go.js +35 -0
  196. package/dist/templates/go.js.map +1 -0
  197. package/dist/templates/index.d.ts +13 -0
  198. package/dist/templates/index.d.ts.map +1 -0
  199. package/dist/templates/index.js +98 -0
  200. package/dist/templates/index.js.map +1 -0
  201. package/dist/templates/nextjs.d.ts +3 -0
  202. package/dist/templates/nextjs.d.ts.map +1 -0
  203. package/dist/templates/nextjs.js +53 -0
  204. package/dist/templates/nextjs.js.map +1 -0
  205. package/dist/templates/python.d.ts +3 -0
  206. package/dist/templates/python.d.ts.map +1 -0
  207. package/dist/templates/python.js +41 -0
  208. package/dist/templates/python.js.map +1 -0
  209. package/dist/templates/react-native.d.ts +3 -0
  210. package/dist/templates/react-native.d.ts.map +1 -0
  211. package/dist/templates/react-native.js +35 -0
  212. package/dist/templates/react-native.js.map +1 -0
  213. package/dist/templates/registry.d.ts +24 -0
  214. package/dist/templates/registry.d.ts.map +1 -0
  215. package/dist/templates/registry.js +2 -0
  216. package/dist/templates/registry.js.map +1 -0
  217. package/dist/templates/rust.d.ts +3 -0
  218. package/dist/templates/rust.d.ts.map +1 -0
  219. package/dist/templates/rust.js +41 -0
  220. package/dist/templates/rust.js.map +1 -0
  221. package/dist/templates/sst.d.ts +3 -0
  222. package/dist/templates/sst.d.ts.map +1 -0
  223. package/dist/templates/sst.js +35 -0
  224. package/dist/templates/sst.js.map +1 -0
  225. package/dist/types/index.d.ts +92 -0
  226. package/dist/types/index.d.ts.map +1 -0
  227. package/dist/types/index.js +2 -0
  228. package/dist/types/index.js.map +1 -0
  229. package/package.json +62 -0
@@ -0,0 +1,210 @@
1
+ import { mkdirSync, statSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { SqliteDatabase } from "./db.js";
4
+ const PRIORITY_THRESHOLDS = { critical: 80, high: 60, normal: 30 };
5
+ export class ContextStore {
6
+ db;
7
+ dbPath;
8
+ constructor(projectRoot) {
9
+ this.dbPath = join(projectRoot, ".agentmind", "context.db");
10
+ mkdirSync(dirname(this.dbPath), { recursive: true });
11
+ this.db = new SqliteDatabase(this.dbPath);
12
+ this.db.pragma("journal_mode = WAL");
13
+ this.init();
14
+ }
15
+ init() {
16
+ this.db.run(`
17
+ CREATE TABLE IF NOT EXISTS context_entries (
18
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
19
+ file_path TEXT,
20
+ type TEXT NOT NULL CHECK(type IN ('rule','annotation','behavior','convention')),
21
+ content TEXT NOT NULL DEFAULT '{}',
22
+ scope TEXT NOT NULL DEFAULT 'global',
23
+ priority TEXT NOT NULL DEFAULT 'normal' CHECK(priority IN ('critical','high','normal','low')),
24
+ source TEXT,
25
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
26
+ updated_at TEXT NOT NULL DEFAULT (datetime('now'))
27
+ )
28
+ `);
29
+ this.db.run(`
30
+ CREATE TABLE IF NOT EXISTS behavior_log (
31
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
32
+ agent_type TEXT NOT NULL,
33
+ action TEXT NOT NULL,
34
+ file_path TEXT,
35
+ success INTEGER NOT NULL DEFAULT 1,
36
+ timestamp TEXT NOT NULL DEFAULT (datetime('now')),
37
+ metadata TEXT NOT NULL DEFAULT '{}'
38
+ )
39
+ `);
40
+ this.db.run(`
41
+ CREATE TABLE IF NOT EXISTS project_meta (
42
+ key TEXT PRIMARY KEY,
43
+ value TEXT NOT NULL
44
+ )
45
+ `);
46
+ this.db.run("CREATE INDEX IF NOT EXISTS idx_entries_file ON context_entries(file_path)");
47
+ this.db.run("CREATE INDEX IF NOT EXISTS idx_entries_type ON context_entries(type)");
48
+ this.db.run("CREATE INDEX IF NOT EXISTS idx_entries_scope ON context_entries(scope)");
49
+ this.db.run("CREATE INDEX IF NOT EXISTS idx_entries_priority ON context_entries(priority)");
50
+ this.db.run("CREATE INDEX IF NOT EXISTS idx_behaviors_agent ON behavior_log(agent_type)");
51
+ this.db.run("CREATE INDEX IF NOT EXISTS idx_behaviors_file ON behavior_log(file_path)");
52
+ }
53
+ addRule(rule) {
54
+ const content = JSON.stringify(rule);
55
+ const priorityLabel = rule.priority >= PRIORITY_THRESHOLDS.critical ? "critical"
56
+ : rule.priority >= PRIORITY_THRESHOLDS.high ? "high"
57
+ : rule.priority >= PRIORITY_THRESHOLDS.normal ? "normal"
58
+ : "low";
59
+ this.db.run("INSERT INTO context_entries (file_path, type, content, scope, priority, source) VALUES (?, 'rule', ?, 'global', ?, 'scanner')", [rule.path ?? rule.pattern, content, priorityLabel]);
60
+ }
61
+ addAnnotation(annotation) {
62
+ const content = JSON.stringify(annotation);
63
+ this.db.run("INSERT INTO context_entries (file_path, type, content, scope, priority, source) VALUES (?, 'annotation', ?, ?, 'normal', ?)", [
64
+ annotation.path,
65
+ content,
66
+ annotation.line != null ? `line:${annotation.line}` : "global",
67
+ annotation.author,
68
+ ]);
69
+ }
70
+ replaceRules(source, rules) {
71
+ this.db.run("DELETE FROM context_entries WHERE type = 'rule' AND source = ?", [source]);
72
+ for (const rule of rules) {
73
+ const content = JSON.stringify(rule);
74
+ const priorityLabel = rule.priority >= PRIORITY_THRESHOLDS.critical ? "critical"
75
+ : rule.priority >= PRIORITY_THRESHOLDS.high ? "high"
76
+ : rule.priority >= PRIORITY_THRESHOLDS.normal ? "normal"
77
+ : "low";
78
+ this.db.run("INSERT INTO context_entries (file_path, type, content, scope, priority, source) VALUES (?, 'rule', ?, 'global', ?, ?)", [rule.path ?? rule.pattern, content, priorityLabel, source]);
79
+ }
80
+ }
81
+ getEntries(filter) {
82
+ let sql = "SELECT * FROM context_entries WHERE 1=1";
83
+ const params = [];
84
+ if (filter?.filePath) {
85
+ sql += " AND file_path = ?";
86
+ params.push(filter.filePath);
87
+ }
88
+ if (filter?.type) {
89
+ sql += " AND type = ?";
90
+ params.push(filter.type);
91
+ }
92
+ if (filter?.scope) {
93
+ sql += " AND scope = ?";
94
+ params.push(filter.scope);
95
+ }
96
+ sql += " ORDER BY CASE priority";
97
+ sql += " WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'normal' THEN 2 ELSE 3 END";
98
+ sql += ", created_at DESC";
99
+ const query = this.db.query(sql);
100
+ const rows = query.all(...params);
101
+ return rows.map(rowToEntry);
102
+ }
103
+ logBehavior(entry, success = true) {
104
+ const metadata = JSON.stringify({ pattern: entry.pattern, frequency: entry.frequency });
105
+ this.db.run("INSERT INTO behavior_log (agent_type, action, file_path, success, metadata) VALUES (?, ?, ?, ?, ?)", ["auto", entry.description, entry.path, success ? 1 : 0, metadata]);
106
+ }
107
+ getBehaviors(filter) {
108
+ let sql = "SELECT * FROM behavior_log WHERE 1=1";
109
+ const params = [];
110
+ if (filter?.agentType) {
111
+ sql += " AND agent_type = ?";
112
+ params.push(filter.agentType);
113
+ }
114
+ if (filter?.filePath) {
115
+ sql += " AND file_path = ?";
116
+ params.push(filter.filePath);
117
+ }
118
+ if (filter?.success != null) {
119
+ sql += " AND success = ?";
120
+ params.push(filter.success ? 1 : 0);
121
+ }
122
+ sql += " ORDER BY timestamp DESC";
123
+ const query = this.db.query(sql);
124
+ const rows = query.all(...params);
125
+ return rows.map((row) => ({
126
+ id: String(row.id),
127
+ path: row.file_path ?? "",
128
+ pattern: "",
129
+ description: row.action,
130
+ frequency: 1,
131
+ lastSeen: new Date(row.timestamp).getTime(),
132
+ }));
133
+ }
134
+ queryContext(opts) {
135
+ if (!opts.filePath) {
136
+ return this.getEntries({ scope: "global" });
137
+ }
138
+ const escaped = escapeLike(opts.filePath);
139
+ const query = this.db.query(`
140
+ SELECT * FROM context_entries
141
+ WHERE scope = 'global'
142
+ OR file_path = ?
143
+ OR (
144
+ file_path LIKE '%' || substr(?, instr(?, '*')) || '%' ESCAPE '\\'
145
+ AND scope = 'pattern'
146
+ )
147
+ ORDER BY CASE priority
148
+ WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'normal' THEN 2 ELSE 3 END
149
+ , created_at DESC
150
+ `);
151
+ const rows = query.all(opts.filePath, escaped, escaped);
152
+ return rows.map(rowToEntry);
153
+ }
154
+ setMeta(key, value) {
155
+ this.db.run("INSERT OR REPLACE INTO project_meta (key, value) VALUES (?, ?)", [key, value]);
156
+ }
157
+ getMeta(key) {
158
+ const query = this.db.query("SELECT value FROM project_meta WHERE key = ?");
159
+ const row = query.get(key);
160
+ return row?.value;
161
+ }
162
+ getHealth() {
163
+ const entriesQuery = this.db.query("SELECT COUNT(*) as c FROM context_entries");
164
+ const entries = entriesQuery.get();
165
+ const staleQuery = this.db.query("SELECT COUNT(*) as c FROM context_entries WHERE updated_at < datetime('now', '-30 days')");
166
+ const stale = staleQuery.get();
167
+ const orphanedQuery = this.db.query(`
168
+ SELECT COUNT(*) as c FROM context_entries
169
+ WHERE type = 'rule'
170
+ AND file_path IS NOT NULL
171
+ AND file_path != ''
172
+ AND file_path NOT IN (SELECT DISTINCT file_path FROM context_entries WHERE type = 'annotation')
173
+ `);
174
+ const orphaned = orphanedQuery.get();
175
+ let dbSize = 0;
176
+ try {
177
+ dbSize = statSync(this.dbPath).size;
178
+ }
179
+ catch { }
180
+ return {
181
+ dbSize,
182
+ entries: entries.c,
183
+ staleEntries: stale.c,
184
+ orphanedRules: orphaned.c,
185
+ };
186
+ }
187
+ getDb() {
188
+ return this.db;
189
+ }
190
+ close() {
191
+ this.db.close();
192
+ }
193
+ }
194
+ function escapeLike(input) {
195
+ return input.replace(/\\/g, "\\\\").replace(/%/g, "\\%").replace(/_/g, "\\_");
196
+ }
197
+ function rowToEntry(row) {
198
+ const parsed = JSON.parse(row.content);
199
+ return {
200
+ id: String(row.id),
201
+ path: row.file_path ?? "",
202
+ classification: "source",
203
+ rules: row.type === "rule" ? [parsed] : [],
204
+ annotations: row.type === "annotation" ? [parsed] : [],
205
+ behaviors: row.type === "behavior" ? [parsed] : [],
206
+ lastScanned: new Date(row.updated_at).getTime(),
207
+ hash: "",
208
+ };
209
+ }
210
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/store/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AASxC,MAAM,mBAAmB,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,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CAAC,CAAC,CAAC,CAAC,EAAE;QAC1C,WAAW,EAAE,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;QACtD,SAAS,EAAE,GAAG,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;QAClD,WAAW,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE;QAC/C,IAAI,EAAE,EAAE;KACT,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ContextTemplate } from "./registry.js";
2
+ export declare function goTemplate(): ContextTemplate;
3
+ //# sourceMappingURL=go.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"go.d.ts","sourceRoot":"","sources":["../../src/templates/go.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpD,wBAAgB,UAAU,IAAI,eAAe,CAiC5C"}
@@ -0,0 +1,35 @@
1
+ export function goTemplate() {
2
+ return {
3
+ name: "go",
4
+ description: "Go — standard module layout",
5
+ patterns: [
6
+ { glob: "go.mod", classification: "config" },
7
+ { glob: "cmd/**/main.go", classification: "source" },
8
+ { glob: "internal/**", classification: "source" },
9
+ { glob: "api/**", classification: "source" },
10
+ ],
11
+ rules: [
12
+ {
13
+ pattern: "go.mod",
14
+ description: "Go module definition",
15
+ priority: "critical",
16
+ },
17
+ {
18
+ pattern: "cmd/**/main.go",
19
+ description: "CLI entry point",
20
+ priority: "high",
21
+ },
22
+ {
23
+ pattern: "internal/**",
24
+ description: "Internal package — not importable outside module",
25
+ priority: "high",
26
+ },
27
+ {
28
+ pattern: "api/**",
29
+ description: "API handlers",
30
+ priority: "high",
31
+ },
32
+ ],
33
+ };
34
+ }
35
+ //# sourceMappingURL=go.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"go.js","sourceRoot":"","sources":["../../src/templates/go.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,UAAU;IACxB,OAAO;QACL,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,6BAA6B;QAC1C,QAAQ,EAAE;YACR,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE;YAC5C,EAAE,IAAI,EAAE,gBAAgB,EAAE,cAAc,EAAE,QAAQ,EAAE;YACpD,EAAE,IAAI,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE;YACjD,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE;SAC7C;QACD,KAAK,EAAE;YACL;gBACE,OAAO,EAAE,QAAQ;gBACjB,WAAW,EAAE,sBAAsB;gBACnC,QAAQ,EAAE,UAAU;aACrB;YACD;gBACE,OAAO,EAAE,gBAAgB;gBACzB,WAAW,EAAE,iBAAiB;gBAC9B,QAAQ,EAAE,MAAM;aACjB;YACD;gBACE,OAAO,EAAE,aAAa;gBACtB,WAAW,EAAE,kDAAkD;gBAC/D,QAAQ,EAAE,MAAM;aACjB;YACD;gBACE,OAAO,EAAE,QAAQ;gBACjB,WAAW,EAAE,cAAc;gBAC3B,QAAQ,EAAE,MAAM;aACjB;SACF;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { ContextStore } from "../store/schema.js";
2
+ import type { ContextTemplate } from "./registry.js";
3
+ export declare function listTemplates(): ContextTemplate[];
4
+ export declare function getTemplate(name: string): ContextTemplate | undefined;
5
+ export interface ApplyResult {
6
+ rulesAdded: number;
7
+ patternsMatched: number;
8
+ skipped: string[];
9
+ }
10
+ /** Idempotent. Skipped patterns match zero files. */
11
+ export declare function applyTemplate(templateName: string, projectRoot: string, store: ContextStore): Promise<ApplyResult>;
12
+ export declare function autoApplyTemplates(projectRoot: string, store: ContextStore): Promise<Map<string, ApplyResult>>;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,eAAe,CAAA;AA0BvE,wBAAgB,aAAa,IAAI,eAAe,EAAE,CAEjD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAErE;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,MAAM,CAAA;IACvB,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,qDAAqD;AACrD,wBAAsB,aAAa,CACjC,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,WAAW,CAAC,CA6CtB;AAED,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAgBnC"}
@@ -0,0 +1,98 @@
1
+ import { glob } from "glob";
2
+ import { nextjsTemplate } from "./nextjs.js";
3
+ import { sstTemplate } from "./sst.js";
4
+ import { reactNativeTemplate } from "./react-native.js";
5
+ import { pythonTemplate } from "./python.js";
6
+ import { goTemplate } from "./go.js";
7
+ import { rustTemplate } from "./rust.js";
8
+ const templates = [
9
+ nextjsTemplate(),
10
+ sstTemplate(),
11
+ reactNativeTemplate(),
12
+ pythonTemplate(),
13
+ goTemplate(),
14
+ rustTemplate(),
15
+ ];
16
+ const detectionGlobs = [
17
+ { name: "nextjs", detectGlob: "next.config.*" },
18
+ { name: "sst", detectGlob: "sst.config.ts" },
19
+ { name: "react-native", detectGlob: "app/**/_layout.tsx" },
20
+ { name: "python", detectGlob: "pyproject.toml" },
21
+ { name: "go", detectGlob: "go.mod" },
22
+ { name: "rust", detectGlob: "Cargo.toml" },
23
+ ];
24
+ export function listTemplates() {
25
+ return templates;
26
+ }
27
+ export function getTemplate(name) {
28
+ return templates.find((t) => t.name === name);
29
+ }
30
+ /** Idempotent. Skipped patterns match zero files. */
31
+ export async function applyTemplate(templateName, projectRoot, store) {
32
+ const template = getTemplate(templateName);
33
+ if (!template) {
34
+ throw new Error(`Unknown template: ${templateName}`);
35
+ }
36
+ const result = {
37
+ rulesAdded: 0,
38
+ patternsMatched: 0,
39
+ skipped: [],
40
+ };
41
+ for (const rule of template.rules) {
42
+ const matches = await glob(rule.pattern, { cwd: projectRoot, dot: true });
43
+ if (matches.length === 0) {
44
+ result.skipped.push(rule.pattern);
45
+ continue;
46
+ }
47
+ result.patternsMatched += matches.length;
48
+ for (const filePath of matches) {
49
+ const normPath = filePath.replace(/\\/g, "/");
50
+ if (isRuleDuplicate(store, normPath, rule.description)) {
51
+ continue;
52
+ }
53
+ const storeRule = {
54
+ id: `template-${templateName}-${normPath}`,
55
+ path: normPath,
56
+ pattern: rule.pattern,
57
+ description: rule.description,
58
+ priority: priorityToNumber(rule.priority),
59
+ };
60
+ store.addRule(storeRule);
61
+ result.rulesAdded++;
62
+ }
63
+ }
64
+ store.setMeta(`template:${templateName}`, new Date().toISOString());
65
+ return result;
66
+ }
67
+ export async function autoApplyTemplates(projectRoot, store) {
68
+ const results = new Map();
69
+ for (const detection of detectionGlobs) {
70
+ const matches = await glob(detection.detectGlob, {
71
+ cwd: projectRoot,
72
+ dot: true,
73
+ });
74
+ if (matches.length > 0) {
75
+ const applyResult = await applyTemplate(detection.name, projectRoot, store);
76
+ results.set(detection.name, applyResult);
77
+ }
78
+ }
79
+ return results;
80
+ }
81
+ // Makes applyTemplate idempotent
82
+ function isRuleDuplicate(store, filePath, description) {
83
+ const existing = store.getEntries({ filePath, type: "rule" });
84
+ return existing.some((entry) => entry.rules.some((r) => r.description === description));
85
+ }
86
+ function priorityToNumber(priority) {
87
+ switch (priority) {
88
+ case "critical":
89
+ return 80;
90
+ case "high":
91
+ return 60;
92
+ case "normal":
93
+ return 30;
94
+ case "low":
95
+ return 10;
96
+ }
97
+ }
98
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAI3B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,MAAM,SAAS,GAAsB;IACnC,cAAc,EAAE;IAChB,WAAW,EAAE;IACb,mBAAmB,EAAE;IACrB,cAAc,EAAE;IAChB,UAAU,EAAE;IACZ,YAAY,EAAE;CACf,CAAA;AAED,MAAM,cAAc,GAAwB;IAC1C,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE;IAC/C,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE;IAC5C,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,oBAAoB,EAAE;IAC1D,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE;IAChD,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE;IACpC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE;CAC3C,CAAA;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,SAAS,CAAC,IAAI,CAAC,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EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,WAAW,CAAC,CACvD,CAAA;AACH,CAAC;AAED,SAAS,gBAAgB,CACvB,QAAgD;IAEhD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,UAAU;YACb,OAAO,EAAE,CAAA;QACX,KAAK,MAAM;YACT,OAAO,EAAE,CAAA;QACX,KAAK,QAAQ;YACX,OAAO,EAAE,CAAA;QACX,KAAK,KAAK;YACR,OAAO,EAAE,CAAA;IACb,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ContextTemplate } from "./registry.js";
2
+ export declare function nextjsTemplate(): ContextTemplate;
3
+ //# sourceMappingURL=nextjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nextjs.d.ts","sourceRoot":"","sources":["../../src/templates/nextjs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpD,wBAAgB,cAAc,IAAI,eAAe,CAmDhD"}
@@ -0,0 +1,53 @@
1
+ export function nextjsTemplate() {
2
+ return {
3
+ name: "nextjs",
4
+ description: "Next.js App Router + TypeScript",
5
+ patterns: [
6
+ { glob: "next.config.*", classification: "config" },
7
+ { glob: "app/**/layout.tsx", classification: "source" },
8
+ { glob: "app/**/page.tsx", classification: "source" },
9
+ { glob: "app/**/loading.tsx", classification: "source" },
10
+ { glob: "app/**/error.tsx", classification: "source" },
11
+ { glob: "middleware.ts", classification: "source" },
12
+ { glob: ".env.local", classification: "config" },
13
+ ],
14
+ rules: [
15
+ {
16
+ pattern: "next.config.*",
17
+ description: "Next.js config — custom webpack/turbopack settings",
18
+ priority: "high",
19
+ },
20
+ {
21
+ pattern: "app/**/layout.tsx",
22
+ description: "App Router layout — wraps all child routes",
23
+ priority: "critical",
24
+ },
25
+ {
26
+ pattern: "app/**/page.tsx",
27
+ description: "Page component — server component by default, add 'use client' for client components",
28
+ priority: "critical",
29
+ },
30
+ {
31
+ pattern: "app/**/loading.tsx",
32
+ description: "Suspense boundary for route",
33
+ priority: "normal",
34
+ },
35
+ {
36
+ pattern: "app/**/error.tsx",
37
+ description: "Error boundary for route — must be a client component",
38
+ priority: "normal",
39
+ },
40
+ {
41
+ pattern: "middleware.ts",
42
+ description: "Edge middleware — runs on every request, no Node.js APIs",
43
+ priority: "high",
44
+ },
45
+ {
46
+ pattern: ".env.local",
47
+ description: "Environment variables — never commit to git",
48
+ priority: "critical",
49
+ },
50
+ ],
51
+ };
52
+ }
53
+ //# sourceMappingURL=nextjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nextjs.js","sourceRoot":"","sources":["../../src/templates/nextjs.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,cAAc;IAC5B,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,iCAAiC;QAC9C,QAAQ,EAAE;YACR,EAAE,IAAI,EAAE,eAAe,EAAE,cAAc,EAAE,QAAQ,EAAE;YACnD,EAAE,IAAI,EAAE,mBAAmB,EAAE,cAAc,EAAE,QAAQ,EAAE;YACvD,EAAE,IAAI,EAAE,iBAAiB,EAAE,cAAc,EAAE,QAAQ,EAAE;YACrD,EAAE,IAAI,EAAE,oBAAoB,EAAE,cAAc,EAAE,QAAQ,EAAE;YACxD,EAAE,IAAI,EAAE,kBAAkB,EAAE,cAAc,EAAE,QAAQ,EAAE;YACtD,EAAE,IAAI,EAAE,eAAe,EAAE,cAAc,EAAE,QAAQ,EAAE;YACnD,EAAE,IAAI,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE;SACjD;QACD,KAAK,EAAE;YACL;gBACE,OAAO,EAAE,eAAe;gBACxB,WAAW,EAAE,oDAAoD;gBACjE,QAAQ,EAAE,MAAM;aACjB;YACD;gBACE,OAAO,EAAE,mBAAmB;gBAC5B,WAAW,EAAE,4CAA4C;gBACzD,QAAQ,EAAE,UAAU;aACrB;YACD;gBACE,OAAO,EAAE,iBAAiB;gBAC1B,WAAW,EAAE,sFAAsF;gBACnG,QAAQ,EAAE,UAAU;aACrB;YACD;gBACE,OAAO,EAAE,oBAAoB;gBAC7B,WAAW,EAAE,6BAA6B;gBAC1C,QAAQ,EAAE,QAAQ;aACnB;YACD;gBACE,OAAO,EAAE,kBAAkB;gBAC3B,WAAW,EAAE,uDAAuD;gBACpE,QAAQ,EAAE,QAAQ;aACnB;YACD;gBACE,OAAO,EAAE,eAAe;gBACxB,WAAW,EAAE,0DAA0D;gBACvE,QAAQ,EAAE,MAAM;aACjB;YACD;gBACE,OAAO,EAAE,YAAY;gBACrB,WAAW,EAAE,6CAA6C;gBAC1D,QAAQ,EAAE,UAAU;aACrB;SACF;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ContextTemplate } from "./registry.js";
2
+ export declare function pythonTemplate(): ContextTemplate;
3
+ //# sourceMappingURL=python.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/templates/python.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpD,wBAAgB,cAAc,IAAI,eAAe,CAuChD"}
@@ -0,0 +1,41 @@
1
+ export function pythonTemplate() {
2
+ return {
3
+ name: "python",
4
+ description: "Python — standard project layout with pyproject.toml",
5
+ patterns: [
6
+ { glob: "pyproject.toml", classification: "config" },
7
+ { glob: "src/**/*.py", classification: "source" },
8
+ { glob: "tests/**/*.py", classification: "test" },
9
+ { glob: "requirements.txt", classification: "config" },
10
+ { glob: "Pipfile", classification: "config" },
11
+ ],
12
+ rules: [
13
+ {
14
+ pattern: "pyproject.toml",
15
+ description: "Python project config (PEP 621)",
16
+ priority: "critical",
17
+ },
18
+ {
19
+ pattern: "src/**/*.py",
20
+ description: "Source package layout",
21
+ priority: "high",
22
+ },
23
+ {
24
+ pattern: "tests/**/*.py",
25
+ description: "Pytest tests",
26
+ priority: "normal",
27
+ },
28
+ {
29
+ pattern: "requirements.txt",
30
+ description: "Dependency file",
31
+ priority: "high",
32
+ },
33
+ {
34
+ pattern: "Pipfile",
35
+ description: "Dependency file",
36
+ priority: "high",
37
+ },
38
+ ],
39
+ };
40
+ }
41
+ //# sourceMappingURL=python.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"python.js","sourceRoot":"","sources":["../../src/templates/python.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,cAAc;IAC5B,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,sDAAsD;QACnE,QAAQ,EAAE;YACR,EAAE,IAAI,EAAE,gBAAgB,EAAE,cAAc,EAAE,QAAQ,EAAE;YACpD,EAAE,IAAI,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE;YACjD,EAAE,IAAI,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,EAAE;YACjD,EAAE,IAAI,EAAE,kBAAkB,EAAE,cAAc,EAAE,QAAQ,EAAE;YACtD,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE;SAC9C;QACD,KAAK,EAAE;YACL;gBACE,OAAO,EAAE,gBAAgB;gBACzB,WAAW,EAAE,iCAAiC;gBAC9C,QAAQ,EAAE,UAAU;aACrB;YACD;gBACE,OAAO,EAAE,aAAa;gBACtB,WAAW,EAAE,uBAAuB;gBACpC,QAAQ,EAAE,MAAM;aACjB;YACD;gBACE,OAAO,EAAE,eAAe;gBACxB,WAAW,EAAE,cAAc;gBAC3B,QAAQ,EAAE,QAAQ;aACnB;YACD;gBACE,OAAO,EAAE,kBAAkB;gBAC3B,WAAW,EAAE,iBAAiB;gBAC9B,QAAQ,EAAE,MAAM;aACjB;YACD;gBACE,OAAO,EAAE,SAAS;gBAClB,WAAW,EAAE,iBAAiB;gBAC9B,QAAQ,EAAE,MAAM;aACjB;SACF;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ContextTemplate } from "./registry.js";
2
+ export declare function reactNativeTemplate(): ContextTemplate;
3
+ //# sourceMappingURL=react-native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-native.d.ts","sourceRoot":"","sources":["../../src/templates/react-native.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpD,wBAAgB,mBAAmB,IAAI,eAAe,CAiCrD"}
@@ -0,0 +1,35 @@
1
+ export function reactNativeTemplate() {
2
+ return {
3
+ name: "react-native",
4
+ description: "React Native + Expo Router",
5
+ patterns: [
6
+ { glob: "app/**/_layout.tsx", classification: "source" },
7
+ { glob: "app/**/+.ts", classification: "source" },
8
+ { glob: "metro.config.js", classification: "config" },
9
+ { glob: "eas.json", classification: "config" },
10
+ ],
11
+ rules: [
12
+ {
13
+ pattern: "app/**/_layout.tsx",
14
+ description: "Expo Router layout",
15
+ priority: "critical",
16
+ },
17
+ {
18
+ pattern: "app/**/+.ts",
19
+ description: "Dynamic route segment",
20
+ priority: "high",
21
+ },
22
+ {
23
+ pattern: "metro.config.js",
24
+ description: "Metro bundler config",
25
+ priority: "high",
26
+ },
27
+ {
28
+ pattern: "eas.json",
29
+ description: "EAS Build/Submit config",
30
+ priority: "normal",
31
+ },
32
+ ],
33
+ };
34
+ }
35
+ //# sourceMappingURL=react-native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-native.js","sourceRoot":"","sources":["../../src/templates/react-native.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,4BAA4B;QACzC,QAAQ,EAAE;YACR,EAAE,IAAI,EAAE,oBAAoB,EAAE,cAAc,EAAE,QAAQ,EAAE;YACxD,EAAE,IAAI,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE;YACjD,EAAE,IAAI,EAAE,iBAAiB,EAAE,cAAc,EAAE,QAAQ,EAAE;YACrD,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE;SAC/C;QACD,KAAK,EAAE;YACL;gBACE,OAAO,EAAE,oBAAoB;gBAC7B,WAAW,EAAE,oBAAoB;gBACjC,QAAQ,EAAE,UAAU;aACrB;YACD;gBACE,OAAO,EAAE,aAAa;gBACtB,WAAW,EAAE,uBAAuB;gBACpC,QAAQ,EAAE,MAAM;aACjB;YACD;gBACE,OAAO,EAAE,iBAAiB;gBAC1B,WAAW,EAAE,sBAAsB;gBACnC,QAAQ,EAAE,MAAM;aACjB;YACD;gBACE,OAAO,EAAE,UAAU;gBACnB,WAAW,EAAE,yBAAyB;gBACtC,QAAQ,EAAE,QAAQ;aACnB;SACF;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,24 @@
1
+ export interface TemplatePattern {
2
+ glob: string;
3
+ classification: string;
4
+ }
5
+ export interface TemplateRule {
6
+ pattern: string;
7
+ description: string;
8
+ priority: "critical" | "high" | "normal" | "low";
9
+ }
10
+ export interface ContextTemplate {
11
+ name: string;
12
+ description: string;
13
+ patterns: TemplatePattern[];
14
+ rules: TemplateRule[];
15
+ }
16
+ /**
17
+ * Each template has a "detection glob" — a single file pattern that, if found
18
+ * in the project root, means this template is relevant. Used by --all auto-detect.
19
+ */
20
+ export interface TemplateDetection {
21
+ name: string;
22
+ detectGlob: string;
23
+ }
24
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;CACjD;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,eAAe,EAAE,CAAA;IAC3B,KAAK,EAAE,YAAY,EAAE,CAAA;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACnB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import type { ContextTemplate } from "./registry.js";
2
+ export declare function rustTemplate(): ContextTemplate;
3
+ //# sourceMappingURL=rust.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rust.d.ts","sourceRoot":"","sources":["../../src/templates/rust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpD,wBAAgB,YAAY,IAAI,eAAe,CAuC9C"}