mulch-cli 0.4.3 → 0.6.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 (193) hide show
  1. package/README.md +24 -4
  2. package/package.json +11 -16
  3. package/src/api.ts +310 -0
  4. package/src/cli.ts +54 -0
  5. package/src/commands/add.ts +61 -0
  6. package/src/commands/compact.ts +924 -0
  7. package/src/commands/delete.ts +103 -0
  8. package/src/commands/diff.ts +209 -0
  9. package/src/commands/doctor.ts +586 -0
  10. package/src/commands/edit.ts +253 -0
  11. package/src/commands/init.ts +33 -0
  12. package/src/commands/learn.ts +170 -0
  13. package/src/commands/onboard.ts +362 -0
  14. package/src/commands/prime.ts +327 -0
  15. package/src/commands/prune.ts +128 -0
  16. package/src/commands/query.ts +177 -0
  17. package/src/commands/ready.ts +194 -0
  18. package/src/commands/record.ts +959 -0
  19. package/src/commands/search.ts +234 -0
  20. package/src/commands/setup.ts +823 -0
  21. package/src/commands/status.ts +83 -0
  22. package/src/commands/sync.ts +224 -0
  23. package/src/commands/update.ts +112 -0
  24. package/src/commands/validate.ts +107 -0
  25. package/src/index.ts +50 -0
  26. package/src/schemas/config.ts +31 -0
  27. package/src/schemas/index.ts +18 -0
  28. package/src/schemas/record-schema.ts +177 -0
  29. package/src/schemas/record.ts +83 -0
  30. package/src/utils/bm25.ts +243 -0
  31. package/src/utils/budget.ts +157 -0
  32. package/src/utils/config.ts +117 -0
  33. package/src/utils/expertise.ts +379 -0
  34. package/src/utils/format.ts +767 -0
  35. package/src/utils/git.ts +89 -0
  36. package/src/utils/index.ts +54 -0
  37. package/src/utils/json-output.ts +13 -0
  38. package/src/utils/lock.ts +82 -0
  39. package/src/utils/markers.ts +51 -0
  40. package/src/utils/scoring.ts +101 -0
  41. package/src/utils/version.ts +46 -0
  42. package/dist/cli.d.ts +0 -3
  43. package/dist/cli.d.ts.map +0 -1
  44. package/dist/cli.js +0 -50
  45. package/dist/cli.js.map +0 -1
  46. package/dist/commands/add.d.ts +0 -3
  47. package/dist/commands/add.d.ts.map +0 -1
  48. package/dist/commands/add.js +0 -47
  49. package/dist/commands/add.js.map +0 -1
  50. package/dist/commands/compact.d.ts +0 -5
  51. package/dist/commands/compact.d.ts.map +0 -1
  52. package/dist/commands/compact.js +0 -709
  53. package/dist/commands/compact.js.map +0 -1
  54. package/dist/commands/delete.d.ts +0 -3
  55. package/dist/commands/delete.d.ts.map +0 -1
  56. package/dist/commands/delete.js +0 -82
  57. package/dist/commands/delete.js.map +0 -1
  58. package/dist/commands/diff.d.ts +0 -11
  59. package/dist/commands/diff.d.ts.map +0 -1
  60. package/dist/commands/diff.js +0 -170
  61. package/dist/commands/diff.js.map +0 -1
  62. package/dist/commands/doctor.d.ts +0 -3
  63. package/dist/commands/doctor.d.ts.map +0 -1
  64. package/dist/commands/doctor.js +0 -391
  65. package/dist/commands/doctor.js.map +0 -1
  66. package/dist/commands/edit.d.ts +0 -3
  67. package/dist/commands/edit.d.ts.map +0 -1
  68. package/dist/commands/edit.js +0 -210
  69. package/dist/commands/edit.js.map +0 -1
  70. package/dist/commands/init.d.ts +0 -3
  71. package/dist/commands/init.d.ts.map +0 -1
  72. package/dist/commands/init.js +0 -30
  73. package/dist/commands/init.js.map +0 -1
  74. package/dist/commands/learn.d.ts +0 -12
  75. package/dist/commands/learn.d.ts.map +0 -1
  76. package/dist/commands/learn.js +0 -130
  77. package/dist/commands/learn.js.map +0 -1
  78. package/dist/commands/onboard.d.ts +0 -10
  79. package/dist/commands/onboard.d.ts.map +0 -1
  80. package/dist/commands/onboard.js +0 -286
  81. package/dist/commands/onboard.js.map +0 -1
  82. package/dist/commands/prime.d.ts +0 -3
  83. package/dist/commands/prime.d.ts.map +0 -1
  84. package/dist/commands/prime.js +0 -242
  85. package/dist/commands/prime.js.map +0 -1
  86. package/dist/commands/prune.d.ts +0 -8
  87. package/dist/commands/prune.d.ts.map +0 -1
  88. package/dist/commands/prune.js +0 -90
  89. package/dist/commands/prune.js.map +0 -1
  90. package/dist/commands/query.d.ts +0 -3
  91. package/dist/commands/query.d.ts.map +0 -1
  92. package/dist/commands/query.js +0 -118
  93. package/dist/commands/query.js.map +0 -1
  94. package/dist/commands/ready.d.ts +0 -3
  95. package/dist/commands/ready.d.ts.map +0 -1
  96. package/dist/commands/ready.js +0 -160
  97. package/dist/commands/ready.js.map +0 -1
  98. package/dist/commands/record.d.ts +0 -13
  99. package/dist/commands/record.d.ts.map +0 -1
  100. package/dist/commands/record.js +0 -688
  101. package/dist/commands/record.js.map +0 -1
  102. package/dist/commands/search.d.ts +0 -3
  103. package/dist/commands/search.d.ts.map +0 -1
  104. package/dist/commands/search.js +0 -163
  105. package/dist/commands/search.js.map +0 -1
  106. package/dist/commands/setup.d.ts +0 -29
  107. package/dist/commands/setup.d.ts.map +0 -1
  108. package/dist/commands/setup.js +0 -548
  109. package/dist/commands/setup.js.map +0 -1
  110. package/dist/commands/status.d.ts +0 -3
  111. package/dist/commands/status.d.ts.map +0 -1
  112. package/dist/commands/status.js +0 -61
  113. package/dist/commands/status.js.map +0 -1
  114. package/dist/commands/sync.d.ts +0 -3
  115. package/dist/commands/sync.d.ts.map +0 -1
  116. package/dist/commands/sync.js +0 -176
  117. package/dist/commands/sync.js.map +0 -1
  118. package/dist/commands/update.d.ts +0 -3
  119. package/dist/commands/update.d.ts.map +0 -1
  120. package/dist/commands/update.js +0 -72
  121. package/dist/commands/update.js.map +0 -1
  122. package/dist/commands/validate.d.ts +0 -3
  123. package/dist/commands/validate.d.ts.map +0 -1
  124. package/dist/commands/validate.js +0 -86
  125. package/dist/commands/validate.js.map +0 -1
  126. package/dist/index.d.ts +0 -7
  127. package/dist/index.d.ts.map +0 -1
  128. package/dist/index.js +0 -8
  129. package/dist/index.js.map +0 -1
  130. package/dist/schemas/config.d.ts +0 -17
  131. package/dist/schemas/config.d.ts.map +0 -1
  132. package/dist/schemas/config.js +0 -16
  133. package/dist/schemas/config.js.map +0 -1
  134. package/dist/schemas/index.d.ts +0 -5
  135. package/dist/schemas/index.d.ts.map +0 -1
  136. package/dist/schemas/index.js +0 -3
  137. package/dist/schemas/index.js.map +0 -1
  138. package/dist/schemas/record-schema.d.ts +0 -379
  139. package/dist/schemas/record-schema.d.ts.map +0 -1
  140. package/dist/schemas/record-schema.js +0 -148
  141. package/dist/schemas/record-schema.js.map +0 -1
  142. package/dist/schemas/record.d.ts +0 -60
  143. package/dist/schemas/record.d.ts.map +0 -1
  144. package/dist/schemas/record.js +0 -2
  145. package/dist/schemas/record.js.map +0 -1
  146. package/dist/utils/bm25.d.ts +0 -39
  147. package/dist/utils/bm25.d.ts.map +0 -1
  148. package/dist/utils/bm25.js +0 -171
  149. package/dist/utils/bm25.js.map +0 -1
  150. package/dist/utils/budget.d.ts +0 -35
  151. package/dist/utils/budget.d.ts.map +0 -1
  152. package/dist/utils/budget.js +0 -114
  153. package/dist/utils/budget.js.map +0 -1
  154. package/dist/utils/config.d.ts +0 -12
  155. package/dist/utils/config.d.ts.map +0 -1
  156. package/dist/utils/config.js +0 -89
  157. package/dist/utils/config.js.map +0 -1
  158. package/dist/utils/expertise.d.ts +0 -57
  159. package/dist/utils/expertise.d.ts.map +0 -1
  160. package/dist/utils/expertise.js +0 -264
  161. package/dist/utils/expertise.js.map +0 -1
  162. package/dist/utils/format.d.ts +0 -31
  163. package/dist/utils/format.d.ts.map +0 -1
  164. package/dist/utils/format.js +0 -556
  165. package/dist/utils/format.js.map +0 -1
  166. package/dist/utils/git.d.ts +0 -6
  167. package/dist/utils/git.d.ts.map +0 -1
  168. package/dist/utils/git.js +0 -81
  169. package/dist/utils/git.js.map +0 -1
  170. package/dist/utils/index.d.ts +0 -8
  171. package/dist/utils/index.d.ts.map +0 -1
  172. package/dist/utils/index.js +0 -8
  173. package/dist/utils/index.js.map +0 -1
  174. package/dist/utils/json-output.d.ts +0 -8
  175. package/dist/utils/json-output.d.ts.map +0 -1
  176. package/dist/utils/json-output.js +0 -7
  177. package/dist/utils/json-output.js.map +0 -1
  178. package/dist/utils/lock.d.ts +0 -6
  179. package/dist/utils/lock.d.ts.map +0 -1
  180. package/dist/utils/lock.js +0 -70
  181. package/dist/utils/lock.js.map +0 -1
  182. package/dist/utils/markers.d.ts +0 -22
  183. package/dist/utils/markers.d.ts.map +0 -1
  184. package/dist/utils/markers.js +0 -42
  185. package/dist/utils/markers.js.map +0 -1
  186. package/dist/utils/scoring.d.ts +0 -73
  187. package/dist/utils/scoring.d.ts.map +0 -1
  188. package/dist/utils/scoring.js +0 -80
  189. package/dist/utils/scoring.js.map +0 -1
  190. package/dist/utils/version.d.ts +0 -15
  191. package/dist/utils/version.d.ts.map +0 -1
  192. package/dist/utils/version.js +0 -48
  193. package/dist/utils/version.js.map +0 -1
@@ -1,242 +0,0 @@
1
- import { writeFile } from "node:fs/promises";
2
- import { Option } from "commander";
3
- import chalk from "chalk";
4
- import { readConfig, getExpertisePath } from "../utils/config.js";
5
- import { readExpertiseFile, getFileModTime } from "../utils/expertise.js";
6
- import { formatDomainExpertise, formatPrimeOutput, formatDomainExpertiseXml, formatPrimeOutputXml, formatDomainExpertisePlain, formatPrimeOutputPlain, formatDomainExpertiseCompact, formatPrimeOutputCompact, formatMcpOutput, getSessionEndReminder, } from "../utils/format.js";
7
- import { outputJsonError } from "../utils/json-output.js";
8
- import { isGitRepo, getChangedFiles, filterByContext } from "../utils/git.js";
9
- import { DEFAULT_BUDGET, applyBudget, formatBudgetSummary, } from "../utils/budget.js";
10
- /**
11
- * Produce a rough text representation of a record for token estimation.
12
- * Uses a simple format similar to compact lines.
13
- */
14
- function estimateRecordText(record) {
15
- switch (record.type) {
16
- case "convention":
17
- return `[convention] ${record.content}`;
18
- case "pattern": {
19
- const files = record.files && record.files.length > 0 ? ` (${record.files.join(", ")})` : "";
20
- return `[pattern] ${record.name}: ${record.description}${files}`;
21
- }
22
- case "failure":
23
- return `[failure] ${record.description} -> ${record.resolution}`;
24
- case "decision":
25
- return `[decision] ${record.title}: ${record.rationale}`;
26
- case "reference": {
27
- const refFiles = record.files && record.files.length > 0 ? `: ${record.files.join(", ")}` : `: ${record.description}`;
28
- return `[reference] ${record.name}${refFiles}`;
29
- }
30
- case "guide":
31
- return `[guide] ${record.name}: ${record.description}`;
32
- }
33
- }
34
- export function registerPrimeCommand(program) {
35
- program
36
- .command("prime")
37
- .description("Generate a priming prompt from expertise records")
38
- .argument("[domains...]", "optional domain(s) to scope output to")
39
- .option("--full", "include full record details (classification, evidence)")
40
- .option("-v, --verbose", "full output with section headers and recording instructions")
41
- .option("--mcp", "output in MCP-compatible JSON format")
42
- .option("--domain <domains...>", "domain(s) to include")
43
- .option("--exclude-domain <domains...>", "domain(s) to exclude")
44
- .addOption(new Option("--format <format>", "output format")
45
- .choices(["markdown", "xml", "plain"])
46
- .default("markdown"))
47
- .option("--context", "filter records to only those relevant to changed files")
48
- .option("--files <paths...>", "filter records to only those relevant to specified files")
49
- .option("--export <path>", "export output to a file")
50
- .option("--budget <tokens>", `token budget for output (default: ${DEFAULT_BUDGET})`)
51
- .option("--no-limit", "disable token budget limit")
52
- .action(async (domainsArg, options) => {
53
- const jsonMode = program.opts().json === true;
54
- try {
55
- const config = await readConfig();
56
- const format = options.format ?? "markdown";
57
- const requested = [...domainsArg, ...(options.domain ?? [])];
58
- const unique = [...new Set(requested)];
59
- for (const d of unique) {
60
- if (!config.domains.includes(d)) {
61
- if (jsonMode) {
62
- outputJsonError("prime", `Domain "${d}" not found in config. Available domains: ${config.domains.join(", ")}`);
63
- }
64
- else {
65
- console.error(`Error: Domain "${d}" not found in config. Available domains: ${config.domains.join(", ")}`);
66
- }
67
- process.exitCode = 1;
68
- return;
69
- }
70
- }
71
- const excluded = options.excludeDomain ?? [];
72
- for (const d of excluded) {
73
- if (!config.domains.includes(d)) {
74
- if (jsonMode) {
75
- outputJsonError("prime", `Excluded domain "${d}" not found in config. Available domains: ${config.domains.join(", ")}`);
76
- }
77
- else {
78
- console.error(`Error: Excluded domain "${d}" not found in config. Available domains: ${config.domains.join(", ")}`);
79
- }
80
- process.exitCode = 1;
81
- return;
82
- }
83
- }
84
- let targetDomains = unique.length > 0
85
- ? unique
86
- : config.domains;
87
- targetDomains = targetDomains.filter(d => !excluded.includes(d));
88
- // Resolve changed files for --context or --files filtering
89
- let filesToFilter;
90
- if (options.context) {
91
- const cwd = process.cwd();
92
- if (!isGitRepo(cwd)) {
93
- const msg = "Not in a git repository. --context requires git.";
94
- if (jsonMode) {
95
- outputJsonError("prime", msg);
96
- }
97
- else {
98
- console.error(`Error: ${msg}`);
99
- }
100
- process.exitCode = 1;
101
- return;
102
- }
103
- filesToFilter = getChangedFiles(cwd, "HEAD~1");
104
- if (filesToFilter.length === 0) {
105
- if (jsonMode) {
106
- outputJsonError("prime", "No changed files found. Nothing to filter by.");
107
- }
108
- else {
109
- console.log("No changed files found. Nothing to filter by.");
110
- }
111
- return;
112
- }
113
- }
114
- else if (options.files && options.files.length > 0) {
115
- filesToFilter = options.files;
116
- }
117
- // Determine budget settings
118
- const isMachineOutput = options.mcp === true || jsonMode;
119
- const budgetEnabled = !isMachineOutput && options.noLimit !== true;
120
- const budget = options.budget ? parseInt(options.budget, 10) : DEFAULT_BUDGET;
121
- let output;
122
- if (isMachineOutput) {
123
- // --json and --mcp produce the same structured output — no budget
124
- const domains = [];
125
- for (const domain of targetDomains) {
126
- const filePath = getExpertisePath(domain);
127
- let records = await readExpertiseFile(filePath);
128
- if (filesToFilter) {
129
- records = filterByContext(records, filesToFilter);
130
- }
131
- if (!filesToFilter || records.length > 0) {
132
- domains.push({ domain, entry_count: records.length, records });
133
- }
134
- }
135
- output = formatMcpOutput(domains);
136
- }
137
- else {
138
- // Load all records per domain
139
- const allDomainRecords = [];
140
- const modTimes = new Map();
141
- for (const domain of targetDomains) {
142
- const filePath = getExpertisePath(domain);
143
- let records = await readExpertiseFile(filePath);
144
- if (filesToFilter) {
145
- records = filterByContext(records, filesToFilter);
146
- if (records.length === 0)
147
- continue;
148
- }
149
- allDomainRecords.push({ domain, records });
150
- const lastUpdated = await getFileModTime(filePath);
151
- modTimes.set(domain, lastUpdated);
152
- }
153
- // Apply budget filtering
154
- let domainRecordsToFormat;
155
- let droppedCount = 0;
156
- let droppedDomainCount = 0;
157
- if (budgetEnabled) {
158
- const result = applyBudget(allDomainRecords, budget, (record) => estimateRecordText(record));
159
- domainRecordsToFormat = result.kept;
160
- droppedCount = result.droppedCount;
161
- droppedDomainCount = result.droppedDomainCount;
162
- }
163
- else {
164
- domainRecordsToFormat = allDomainRecords;
165
- }
166
- // Format domain sections
167
- const domainSections = [];
168
- for (const { domain, records } of domainRecordsToFormat) {
169
- const lastUpdated = modTimes.get(domain) ?? null;
170
- if (options.verbose || options.full || format !== "markdown") {
171
- switch (format) {
172
- case "xml":
173
- domainSections.push(formatDomainExpertiseXml(domain, records, lastUpdated));
174
- break;
175
- case "plain":
176
- domainSections.push(formatDomainExpertisePlain(domain, records, lastUpdated));
177
- break;
178
- default:
179
- domainSections.push(formatDomainExpertise(domain, records, lastUpdated, {
180
- full: options.full,
181
- }));
182
- break;
183
- }
184
- }
185
- else {
186
- domainSections.push(formatDomainExpertiseCompact(domain, records, lastUpdated));
187
- }
188
- }
189
- if (options.verbose || options.full || format !== "markdown") {
190
- switch (format) {
191
- case "xml":
192
- output = formatPrimeOutputXml(domainSections);
193
- break;
194
- case "plain":
195
- output = formatPrimeOutputPlain(domainSections);
196
- break;
197
- default:
198
- output = formatPrimeOutput(domainSections);
199
- break;
200
- }
201
- }
202
- else {
203
- output = formatPrimeOutputCompact(domainSections);
204
- }
205
- // Append truncation summary before session reminder
206
- if (droppedCount > 0) {
207
- output += "\n\n" + formatBudgetSummary(droppedCount, droppedDomainCount);
208
- }
209
- output += "\n\n" + getSessionEndReminder(format);
210
- }
211
- if (options.export) {
212
- await writeFile(options.export, output + "\n", "utf-8");
213
- if (!jsonMode) {
214
- console.log(chalk.green(`Exported to ${options.export}`));
215
- }
216
- }
217
- else {
218
- console.log(output);
219
- }
220
- }
221
- catch (err) {
222
- if (err.code === "ENOENT") {
223
- if (jsonMode) {
224
- outputJsonError("prime", "No .mulch/ directory found. Run `mulch init` first.");
225
- }
226
- else {
227
- console.error("Error: No .mulch/ directory found. Run `mulch init` first.");
228
- }
229
- }
230
- else {
231
- if (jsonMode) {
232
- outputJsonError("prime", err.message);
233
- }
234
- else {
235
- console.error(`Error: ${err.message}`);
236
- }
237
- }
238
- process.exitCode = 1;
239
- }
240
- });
241
- }
242
- //# sourceMappingURL=prime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prime.js","sourceRoot":"","sources":["../../src/commands/prime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,eAAe,EACf,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EACL,cAAc,EACd,WAAW,EACX,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAiB5B;;;GAGG;AACH,SAAS,kBAAkB,CAAC,MAAsD;IAChF,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,YAAY;YACf,OAAO,gBAAgB,MAAM,CAAC,OAAO,EAAE,CAAC;QAC1C,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,MAAM,KAAK,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AAK,QAAQ,EAAE,CAAC;gBACrD,IAAI,QAAQ,EAAE,CAAC;oBACb,eAAe,CAAC,OAAO,EAAE,qDAAqD,CAAC,CAAC;gBAClF,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,KAAK,CAAC,4DAA4D,CAAC,CAAC;gBAC9E,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,QAAQ,EAAE,CAAC;oBACb,eAAe,CAAC,OAAO,EAAG,GAAa,CAAC,OAAO,CAAC,CAAC;gBACnD,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,KAAK,CAAC,UAAW,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;gBACpD,CAAC;YACH,CAAC;YACD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1,8 +0,0 @@
1
- import { Command } from "commander";
2
- import type { ExpertiseRecord } from "../schemas/record.js";
3
- export declare function isStale(record: ExpertiseRecord, now: Date, shelfLife: {
4
- tactical: number;
5
- observational: number;
6
- }): boolean;
7
- export declare function registerPruneCommand(program: Command): void;
8
- //# sourceMappingURL=prune.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../../src/commands/prune.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,sBAAsB,CAAC;AAU5E,wBAAgB,OAAO,CACrB,MAAM,EAAE,eAAe,EACvB,GAAG,EAAE,IAAI,EACT,SAAS,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GACrD,OAAO,CAqBT;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmF3D"}
@@ -1,90 +0,0 @@
1
- import chalk from "chalk";
2
- import { readConfig, getExpertisePath } from "../utils/config.js";
3
- import { readExpertiseFile, writeExpertiseFile } from "../utils/expertise.js";
4
- import { withFileLock } from "../utils/lock.js";
5
- import { outputJson } from "../utils/json-output.js";
6
- export function isStale(record, now, shelfLife) {
7
- const classification = record.classification;
8
- if (classification === "foundational") {
9
- return false;
10
- }
11
- const recordedAt = new Date(record.recorded_at);
12
- const ageInDays = Math.floor((now.getTime() - recordedAt.getTime()) / (1000 * 60 * 60 * 24));
13
- if (classification === "tactical") {
14
- return ageInDays > shelfLife.tactical;
15
- }
16
- if (classification === "observational") {
17
- return ageInDays > shelfLife.observational;
18
- }
19
- return false;
20
- }
21
- export function registerPruneCommand(program) {
22
- program
23
- .command("prune")
24
- .description("Remove outdated or low-value expertise records")
25
- .option("--dry-run", "Show what would be pruned without removing", false)
26
- .action(async (options) => {
27
- const jsonMode = program.opts().json === true;
28
- const config = await readConfig();
29
- const now = new Date();
30
- const shelfLife = config.classification_defaults.shelf_life;
31
- const results = [];
32
- let totalPruned = 0;
33
- for (const domain of config.domains) {
34
- const filePath = getExpertisePath(domain);
35
- const domainResult = await withFileLock(filePath, async () => {
36
- const records = await readExpertiseFile(filePath);
37
- if (records.length === 0) {
38
- return null;
39
- }
40
- const kept = [];
41
- let pruned = 0;
42
- for (const record of records) {
43
- if (isStale(record, now, shelfLife)) {
44
- pruned++;
45
- }
46
- else {
47
- kept.push(record);
48
- }
49
- }
50
- if (pruned > 0) {
51
- if (!options.dryRun) {
52
- await writeExpertiseFile(filePath, kept);
53
- }
54
- return {
55
- domain,
56
- before: records.length,
57
- pruned,
58
- after: kept.length,
59
- };
60
- }
61
- return null;
62
- });
63
- if (domainResult) {
64
- results.push(domainResult);
65
- totalPruned += domainResult.pruned;
66
- }
67
- }
68
- if (jsonMode) {
69
- outputJson({
70
- success: true,
71
- command: "prune",
72
- dryRun: options.dryRun,
73
- totalPruned,
74
- results,
75
- });
76
- return;
77
- }
78
- if (totalPruned === 0) {
79
- console.log(chalk.green("No stale records found. All records are current."));
80
- return;
81
- }
82
- const label = options.dryRun ? "Would prune" : "Pruned";
83
- const prefix = options.dryRun ? chalk.yellow("[DRY RUN] ") : "";
84
- for (const result of results) {
85
- console.log(`${prefix}${chalk.cyan(result.domain)}: ${label} ${chalk.red(String(result.pruned))} of ${result.before} records (${result.after} remaining)`);
86
- }
87
- console.log(`\n${prefix}${chalk.bold(`Total: ${label.toLowerCase()} ${totalPruned} stale ${totalPruned === 1 ? "record" : "records"}.`)}`);
88
- });
89
- }
90
- //# sourceMappingURL=prune.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prune.js","sourceRoot":"","sources":["../../src/commands/prune.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AASrD,MAAM,UAAU,OAAO,CACrB,MAAuB,EACvB,GAAS,EACT,SAAsD;IAEtD,MAAM,cAAc,GAAmB,MAAM,CAAC,cAAc,CAAC;IAE7D,IAAI,cAAc,KAAK,cAAc,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAC1B,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAC/D,CAAC;IAEF,IAAI,cAAc,KAAK,UAAU,EAAE,CAAC;QAClC,OAAO,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC;IACxC,CAAC;IAED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AAC,GAAG,CACT,GAAG,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,MAAM,CAAC,MAAM,aAAa,MAAM,CAAC,KAAK,aAAa,CAC9I,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,GAAG,CACT,KAAK,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,KAAK,CAAC,WAAW,EAAE,IAAI,WAAW,UAAU,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,EAAE,CAC9H,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1,3 +0,0 @@
1
- import { Command } from "commander";
2
- export declare function registerQueryCommand(program: Command): void;
3
- //# sourceMappingURL=query.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/commands/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAM5C,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA0G3D"}
@@ -1,118 +0,0 @@
1
- import { Option } from "commander";
2
- import { readConfig, getExpertisePath } from "../utils/config.js";
3
- import { readExpertiseFile, getFileModTime, filterByType, filterByClassification, filterByFile } from "../utils/expertise.js";
4
- import { formatDomainExpertise } from "../utils/format.js";
5
- import { outputJson, outputJsonError } from "../utils/json-output.js";
6
- export function registerQueryCommand(program) {
7
- program
8
- .command("query")
9
- .argument("[domain]", "expertise domain to query")
10
- .description("Query expertise records")
11
- .option("--type <type>", "filter by record type")
12
- .addOption(new Option("--classification <classification>", "filter by classification").choices([
13
- "foundational",
14
- "tactical",
15
- "observational",
16
- ]))
17
- .option("--file <file>", "filter by associated file path (substring match)")
18
- .option("--all", "show all domains")
19
- .action(async (domain, options) => {
20
- const jsonMode = program.opts().json === true;
21
- try {
22
- const config = await readConfig();
23
- const domainsToQuery = [];
24
- if (options.all) {
25
- domainsToQuery.push(...config.domains);
26
- if (domainsToQuery.length === 0) {
27
- if (jsonMode) {
28
- outputJson({ success: true, command: "query", domains: [] });
29
- }
30
- else {
31
- console.log("No domains configured. Run `mulch add <domain>` to get started.");
32
- }
33
- return;
34
- }
35
- }
36
- else if (domain) {
37
- if (!config.domains.includes(domain)) {
38
- if (jsonMode) {
39
- outputJsonError("query", `Domain "${domain}" not found in config. Available domains: ${config.domains.join(", ") || "(none)"}`);
40
- }
41
- else {
42
- console.error(`Error: Domain "${domain}" not found in config. Available domains: ${config.domains.join(", ") || "(none)"}`);
43
- }
44
- process.exitCode = 1;
45
- return;
46
- }
47
- domainsToQuery.push(domain);
48
- }
49
- else {
50
- if (jsonMode) {
51
- outputJsonError("query", "Please specify a domain or use --all to query all domains.");
52
- }
53
- else {
54
- console.error("Error: Please specify a domain or use --all to query all domains.");
55
- }
56
- process.exitCode = 1;
57
- return;
58
- }
59
- if (jsonMode) {
60
- const result = [];
61
- for (const d of domainsToQuery) {
62
- const filePath = getExpertisePath(d);
63
- let records = await readExpertiseFile(filePath);
64
- if (options.type) {
65
- records = filterByType(records, options.type);
66
- }
67
- if (options.classification) {
68
- records = filterByClassification(records, options.classification);
69
- }
70
- if (options.file) {
71
- records = filterByFile(records, options.file);
72
- }
73
- result.push({ domain: d, records });
74
- }
75
- outputJson({ success: true, command: "query", domains: result });
76
- }
77
- else {
78
- const sections = [];
79
- for (const d of domainsToQuery) {
80
- const filePath = getExpertisePath(d);
81
- let records = await readExpertiseFile(filePath);
82
- const lastUpdated = await getFileModTime(filePath);
83
- if (options.type) {
84
- records = filterByType(records, options.type);
85
- }
86
- if (options.classification) {
87
- records = filterByClassification(records, options.classification);
88
- }
89
- if (options.file) {
90
- records = filterByFile(records, options.file);
91
- }
92
- sections.push(formatDomainExpertise(d, records, lastUpdated));
93
- }
94
- console.log(sections.join("\n\n"));
95
- }
96
- }
97
- catch (err) {
98
- if (err.code === "ENOENT") {
99
- if (jsonMode) {
100
- outputJsonError("query", "No .mulch/ directory found. Run `mulch init` first.");
101
- }
102
- else {
103
- console.error("Error: No .mulch/ directory found. Run `mulch init` first.");
104
- }
105
- }
106
- else {
107
- if (jsonMode) {
108
- outputJsonError("query", err.message);
109
- }
110
- else {
111
- console.error(`Error: ${err.message}`);
112
- }
113
- }
114
- process.exitCode = 1;
115
- }
116
- });
117
- }
118
- //# sourceMappingURL=query.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/commands/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC9H,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEtE,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,QAAQ,CAAC,UAAU,EAAE,2BAA2B,CAAC;SACjD,WAAW,CAAC,yBAAyB,CAAC;SACtC,MAAM,CAAC,eAAe,EAAE,uBAAuB,CAAC;SAChD,SAAS,CACR,IAAI,MAAM,CAAC,mCAAmC,EAAE,0BAA0B,CAAC,CAAC,OAAO,CAAC;QAClF,cAAc;QACd,UAAU;QACV,eAAe;KAChB,CAAC,CACH;SACA,MAAM,CAAC,eAAe,EAAE,kDAAkD,CAAC;SAC3E,MAAM,CAAC,OAAO,EAAE,kBAAkB,CAAC;SACnC,MAAM,CAAC,KAAK,EAAE,MAA0B,EA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pD,CAAC;YACH,CAAC;YACD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1,3 +0,0 @@
1
- import { Command } from "commander";
2
- export declare function registerReadyCommand(program: Command): void;
3
- //# sourceMappingURL=ready.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ready.d.ts","sourceRoot":"","sources":["../../src/commands/ready.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgCpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAwI3D"}