@spikedpunch/mast 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 (257) hide show
  1. package/LICENSE +21 -0
  2. package/MAST_SPEC.md +2926 -0
  3. package/README.md +842 -0
  4. package/assets/skill.md +45 -0
  5. package/dist/ast/extract.d.ts +65 -0
  6. package/dist/ast/extract.d.ts.map +1 -0
  7. package/dist/ast/extract.js +147 -0
  8. package/dist/ast/extract.js.map +1 -0
  9. package/dist/ast/extractor.d.ts +85 -0
  10. package/dist/ast/extractor.d.ts.map +1 -0
  11. package/dist/ast/extractor.js +2 -0
  12. package/dist/ast/extractor.js.map +1 -0
  13. package/dist/ast/extractors/markdown.d.ts +40 -0
  14. package/dist/ast/extractors/markdown.d.ts.map +1 -0
  15. package/dist/ast/extractors/markdown.js +175 -0
  16. package/dist/ast/extractors/markdown.js.map +1 -0
  17. package/dist/ast/extractors/typescript.d.ts +179 -0
  18. package/dist/ast/extractors/typescript.d.ts.map +1 -0
  19. package/dist/ast/extractors/typescript.js +1439 -0
  20. package/dist/ast/extractors/typescript.js.map +1 -0
  21. package/dist/ast/parser.d.ts +5 -0
  22. package/dist/ast/parser.d.ts.map +1 -0
  23. package/dist/ast/parser.js +21 -0
  24. package/dist/ast/parser.js.map +1 -0
  25. package/dist/ast/types.d.ts +586 -0
  26. package/dist/ast/types.d.ts.map +1 -0
  27. package/dist/ast/types.js +3 -0
  28. package/dist/ast/types.js.map +1 -0
  29. package/dist/cli/docs-cmd.d.ts +22 -0
  30. package/dist/cli/docs-cmd.d.ts.map +1 -0
  31. package/dist/cli/docs-cmd.js +100 -0
  32. package/dist/cli/docs-cmd.js.map +1 -0
  33. package/dist/cli/index-cmd.d.ts +72 -0
  34. package/dist/cli/index-cmd.d.ts.map +1 -0
  35. package/dist/cli/index-cmd.js +263 -0
  36. package/dist/cli/index-cmd.js.map +1 -0
  37. package/dist/cli/index.d.ts +3 -0
  38. package/dist/cli/index.d.ts.map +1 -0
  39. package/dist/cli/index.js +4 -0
  40. package/dist/cli/index.js.map +1 -0
  41. package/dist/cli/init.d.ts +14 -0
  42. package/dist/cli/init.d.ts.map +1 -0
  43. package/dist/cli/init.js +64 -0
  44. package/dist/cli/init.js.map +1 -0
  45. package/dist/cli/install-hooks.d.ts +3 -0
  46. package/dist/cli/install-hooks.d.ts.map +1 -0
  47. package/dist/cli/install-hooks.js +34 -0
  48. package/dist/cli/install-hooks.js.map +1 -0
  49. package/dist/cli/metrics-cmd.d.ts +3 -0
  50. package/dist/cli/metrics-cmd.d.ts.map +1 -0
  51. package/dist/cli/metrics-cmd.js +164 -0
  52. package/dist/cli/metrics-cmd.js.map +1 -0
  53. package/dist/cli/program.d.ts +14 -0
  54. package/dist/cli/program.d.ts.map +1 -0
  55. package/dist/cli/program.js +44 -0
  56. package/dist/cli/program.js.map +1 -0
  57. package/dist/cli/query.d.ts +46 -0
  58. package/dist/cli/query.d.ts.map +1 -0
  59. package/dist/cli/query.js +153 -0
  60. package/dist/cli/query.js.map +1 -0
  61. package/dist/cli/search-cmd.d.ts +33 -0
  62. package/dist/cli/search-cmd.d.ts.map +1 -0
  63. package/dist/cli/search-cmd.js +114 -0
  64. package/dist/cli/search-cmd.js.map +1 -0
  65. package/dist/cli/serve.d.ts +3 -0
  66. package/dist/cli/serve.d.ts.map +1 -0
  67. package/dist/cli/serve.js +19 -0
  68. package/dist/cli/serve.js.map +1 -0
  69. package/dist/cli/skill-install.d.ts +39 -0
  70. package/dist/cli/skill-install.d.ts.map +1 -0
  71. package/dist/cli/skill-install.js +57 -0
  72. package/dist/cli/skill-install.js.map +1 -0
  73. package/dist/cli/status.d.ts +35 -0
  74. package/dist/cli/status.d.ts.map +1 -0
  75. package/dist/cli/status.js +117 -0
  76. package/dist/cli/status.js.map +1 -0
  77. package/dist/cli/upgrade-cmd.d.ts +48 -0
  78. package/dist/cli/upgrade-cmd.d.ts.map +1 -0
  79. package/dist/cli/upgrade-cmd.js +129 -0
  80. package/dist/cli/upgrade-cmd.js.map +1 -0
  81. package/dist/cli/version.d.ts +3 -0
  82. package/dist/cli/version.d.ts.map +1 -0
  83. package/dist/cli/version.js +19 -0
  84. package/dist/cli/version.js.map +1 -0
  85. package/dist/env.d.ts +17 -0
  86. package/dist/env.d.ts.map +1 -0
  87. package/dist/env.js +17 -0
  88. package/dist/env.js.map +1 -0
  89. package/dist/graph/checker-resolver.d.ts +156 -0
  90. package/dist/graph/checker-resolver.d.ts.map +1 -0
  91. package/dist/graph/checker-resolver.js +458 -0
  92. package/dist/graph/checker-resolver.js.map +1 -0
  93. package/dist/graph/db.d.ts +318 -0
  94. package/dist/graph/db.d.ts.map +1 -0
  95. package/dist/graph/db.js +266 -0
  96. package/dist/graph/db.js.map +1 -0
  97. package/dist/graph/index.d.ts +4 -0
  98. package/dist/graph/index.d.ts.map +1 -0
  99. package/dist/graph/index.js +5 -0
  100. package/dist/graph/index.js.map +1 -0
  101. package/dist/graph/local-type-env.d.ts +45 -0
  102. package/dist/graph/local-type-env.d.ts.map +1 -0
  103. package/dist/graph/local-type-env.js +59 -0
  104. package/dist/graph/local-type-env.js.map +1 -0
  105. package/dist/graph/path-range.d.ts +40 -0
  106. package/dist/graph/path-range.d.ts.map +1 -0
  107. package/dist/graph/path-range.js +42 -0
  108. package/dist/graph/path-range.js.map +1 -0
  109. package/dist/graph/populate.d.ts +263 -0
  110. package/dist/graph/populate.d.ts.map +1 -0
  111. package/dist/graph/populate.js +984 -0
  112. package/dist/graph/populate.js.map +1 -0
  113. package/dist/graph/queries.d.ts +114 -0
  114. package/dist/graph/queries.d.ts.map +1 -0
  115. package/dist/graph/queries.js +415 -0
  116. package/dist/graph/queries.js.map +1 -0
  117. package/dist/graph/sqliteBatch.d.ts +48 -0
  118. package/dist/graph/sqliteBatch.d.ts.map +1 -0
  119. package/dist/graph/sqliteBatch.js +93 -0
  120. package/dist/graph/sqliteBatch.js.map +1 -0
  121. package/dist/indexer/freshness.d.ts +48 -0
  122. package/dist/indexer/freshness.d.ts.map +1 -0
  123. package/dist/indexer/freshness.js +72 -0
  124. package/dist/indexer/freshness.js.map +1 -0
  125. package/dist/indexer/import-resolver.d.ts +50 -0
  126. package/dist/indexer/import-resolver.d.ts.map +1 -0
  127. package/dist/indexer/import-resolver.js +318 -0
  128. package/dist/indexer/import-resolver.js.map +1 -0
  129. package/dist/indexer/index.d.ts +249 -0
  130. package/dist/indexer/index.d.ts.map +1 -0
  131. package/dist/indexer/index.js +560 -0
  132. package/dist/indexer/index.js.map +1 -0
  133. package/dist/indexer/walker.d.ts +60 -0
  134. package/dist/indexer/walker.d.ts.map +1 -0
  135. package/dist/indexer/walker.js +128 -0
  136. package/dist/indexer/walker.js.map +1 -0
  137. package/dist/indexer/watcher.d.ts +80 -0
  138. package/dist/indexer/watcher.d.ts.map +1 -0
  139. package/dist/indexer/watcher.js +151 -0
  140. package/dist/indexer/watcher.js.map +1 -0
  141. package/dist/mcp/context.d.ts +23 -0
  142. package/dist/mcp/context.d.ts.map +1 -0
  143. package/dist/mcp/context.js +2 -0
  144. package/dist/mcp/context.js.map +1 -0
  145. package/dist/mcp/register-tools.d.ts +21 -0
  146. package/dist/mcp/register-tools.d.ts.map +1 -0
  147. package/dist/mcp/register-tools.js +42 -0
  148. package/dist/mcp/register-tools.js.map +1 -0
  149. package/dist/mcp/server.d.ts +58 -0
  150. package/dist/mcp/server.d.ts.map +1 -0
  151. package/dist/mcp/server.js +177 -0
  152. package/dist/mcp/server.js.map +1 -0
  153. package/dist/mcp/staleness.d.ts +72 -0
  154. package/dist/mcp/staleness.d.ts.map +1 -0
  155. package/dist/mcp/staleness.js +213 -0
  156. package/dist/mcp/staleness.js.map +1 -0
  157. package/dist/mcp/startup.d.ts +40 -0
  158. package/dist/mcp/startup.d.ts.map +1 -0
  159. package/dist/mcp/startup.js +114 -0
  160. package/dist/mcp/startup.js.map +1 -0
  161. package/dist/mcp/tools/_helpers.d.ts +26 -0
  162. package/dist/mcp/tools/_helpers.d.ts.map +1 -0
  163. package/dist/mcp/tools/_helpers.js +54 -0
  164. package/dist/mcp/tools/_helpers.js.map +1 -0
  165. package/dist/mcp/tools/callers.d.ts +4 -0
  166. package/dist/mcp/tools/callers.d.ts.map +1 -0
  167. package/dist/mcp/tools/callers.js +112 -0
  168. package/dist/mcp/tools/callers.js.map +1 -0
  169. package/dist/mcp/tools/dependencies.d.ts +4 -0
  170. package/dist/mcp/tools/dependencies.d.ts.map +1 -0
  171. package/dist/mcp/tools/dependencies.js +36 -0
  172. package/dist/mcp/tools/dependencies.js.map +1 -0
  173. package/dist/mcp/tools/efficiency.d.ts +4 -0
  174. package/dist/mcp/tools/efficiency.d.ts.map +1 -0
  175. package/dist/mcp/tools/efficiency.js +39 -0
  176. package/dist/mcp/tools/efficiency.js.map +1 -0
  177. package/dist/mcp/tools/exports.d.ts +4 -0
  178. package/dist/mcp/tools/exports.d.ts.map +1 -0
  179. package/dist/mcp/tools/exports.js +56 -0
  180. package/dist/mcp/tools/exports.js.map +1 -0
  181. package/dist/mcp/tools/implementors.d.ts +4 -0
  182. package/dist/mcp/tools/implementors.d.ts.map +1 -0
  183. package/dist/mcp/tools/implementors.js +47 -0
  184. package/dist/mcp/tools/implementors.js.map +1 -0
  185. package/dist/mcp/tools/project-skeleton.d.ts +4 -0
  186. package/dist/mcp/tools/project-skeleton.d.ts.map +1 -0
  187. package/dist/mcp/tools/project-skeleton.js +61 -0
  188. package/dist/mcp/tools/project-skeleton.js.map +1 -0
  189. package/dist/mcp/tools/reindex.d.ts +14 -0
  190. package/dist/mcp/tools/reindex.d.ts.map +1 -0
  191. package/dist/mcp/tools/reindex.js +32 -0
  192. package/dist/mcp/tools/reindex.js.map +1 -0
  193. package/dist/mcp/tools/rename-impact.d.ts +4 -0
  194. package/dist/mcp/tools/rename-impact.d.ts.map +1 -0
  195. package/dist/mcp/tools/rename-impact.js +124 -0
  196. package/dist/mcp/tools/rename-impact.js.map +1 -0
  197. package/dist/mcp/tools/search.d.ts +4 -0
  198. package/dist/mcp/tools/search.d.ts.map +1 -0
  199. package/dist/mcp/tools/search.js +69 -0
  200. package/dist/mcp/tools/search.js.map +1 -0
  201. package/dist/mcp/tools/signature.d.ts +4 -0
  202. package/dist/mcp/tools/signature.d.ts.map +1 -0
  203. package/dist/mcp/tools/signature.js +127 -0
  204. package/dist/mcp/tools/signature.js.map +1 -0
  205. package/dist/mcp/tools/status.d.ts +4 -0
  206. package/dist/mcp/tools/status.d.ts.map +1 -0
  207. package/dist/mcp/tools/status.js +30 -0
  208. package/dist/mcp/tools/status.js.map +1 -0
  209. package/dist/search/declex.d.ts +109 -0
  210. package/dist/search/declex.d.ts.map +1 -0
  211. package/dist/search/declex.js +242 -0
  212. package/dist/search/declex.js.map +1 -0
  213. package/dist/search/fts.d.ts +77 -0
  214. package/dist/search/fts.d.ts.map +1 -0
  215. package/dist/search/fts.js +223 -0
  216. package/dist/search/fts.js.map +1 -0
  217. package/dist/search/fused.d.ts +110 -0
  218. package/dist/search/fused.d.ts.map +1 -0
  219. package/dist/search/fused.js +323 -0
  220. package/dist/search/fused.js.map +1 -0
  221. package/dist/search/potential-matches.d.ts +88 -0
  222. package/dist/search/potential-matches.d.ts.map +1 -0
  223. package/dist/search/potential-matches.js +83 -0
  224. package/dist/search/potential-matches.js.map +1 -0
  225. package/dist/search/scope.d.ts +66 -0
  226. package/dist/search/scope.d.ts.map +1 -0
  227. package/dist/search/scope.js +71 -0
  228. package/dist/search/scope.js.map +1 -0
  229. package/dist/store/config.d.ts +57 -0
  230. package/dist/store/config.d.ts.map +1 -0
  231. package/dist/store/config.js +208 -0
  232. package/dist/store/config.js.map +1 -0
  233. package/dist/store/lock.d.ts +101 -0
  234. package/dist/store/lock.d.ts.map +1 -0
  235. package/dist/store/lock.js +182 -0
  236. package/dist/store/lock.js.map +1 -0
  237. package/dist/store/lockMetrics.d.ts +52 -0
  238. package/dist/store/lockMetrics.d.ts.map +1 -0
  239. package/dist/store/lockMetrics.js +29 -0
  240. package/dist/store/lockMetrics.js.map +1 -0
  241. package/dist/store/sqliteChunkStore.d.ts +44 -0
  242. package/dist/store/sqliteChunkStore.d.ts.map +1 -0
  243. package/dist/store/sqliteChunkStore.js +135 -0
  244. package/dist/store/sqliteChunkStore.js.map +1 -0
  245. package/dist/telemetry/lockMetricsSummary.d.ts +42 -0
  246. package/dist/telemetry/lockMetricsSummary.d.ts.map +1 -0
  247. package/dist/telemetry/lockMetricsSummary.js +139 -0
  248. package/dist/telemetry/lockMetricsSummary.js.map +1 -0
  249. package/dist/telemetry/metrics.d.ts +140 -0
  250. package/dist/telemetry/metrics.d.ts.map +1 -0
  251. package/dist/telemetry/metrics.js +312 -0
  252. package/dist/telemetry/metrics.js.map +1 -0
  253. package/dist/telemetry/tokenizer.d.ts +125 -0
  254. package/dist/telemetry/tokenizer.d.ts.map +1 -0
  255. package/dist/telemetry/tokenizer.js +174 -0
  256. package/dist/telemetry/tokenizer.js.map +1 -0
  257. package/package.json +81 -0
@@ -0,0 +1,19 @@
1
+ import { resolveConfig } from '../store/config.js';
2
+ import { serve } from '../mcp/server.js';
3
+ export function registerServeCommand(program) {
4
+ program
5
+ .command('serve')
6
+ .description('Start the MCP server over stdio')
7
+ .option('--state-dir <dir>', 'State directory')
8
+ .option('--no-startup-reindex', 'Skip the startup staleness check (not recommended)')
9
+ .option('--watch', 'Watch source files and incrementally reindex on change (interactive use)')
10
+ .action(async (opts) => {
11
+ const config = resolveConfig({ stateDirOverride: opts.stateDir });
12
+ await serve({
13
+ config,
14
+ noStartupReindex: !opts.startupReindex,
15
+ watch: opts.watch === true,
16
+ });
17
+ });
18
+ }
19
+ //# sourceMappingURL=serve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/cli/serve.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,iCAAiC,CAAC;SAC9C,MAAM,CAAC,mBAAmB,EAAE,iBAAiB,CAAC;SAC9C,MAAM,CAAC,sBAAsB,EAAE,oDAAoD,CAAC;SACpF,MAAM,CAAC,SAAS,EAAE,0EAA0E,CAAC;SAC7F,MAAM,CAAC,KAAK,EAAE,IAId,EAAE,EAAE;QACH,MAAM,MAAM,GAAG,aAAa,CAAC,EAAE,gBAAgB,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAClE,MAAM,KAAK,CAAC;YACV,MAAM;YACN,gBAAgB,EAAE,CAAC,IAAI,CAAC,cAAc;YACtC,KAAK,EAAE,IAAI,CAAC,KAAK,KAAK,IAAI;SAC3B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * `mast skill --install` — splices the MAST instructions into a project's agent config.
3
+ *
4
+ * Two rules shape this, both about not surprising someone. It writes only into files that
5
+ * ALREADY exist — creating a `CLAUDE.md` in a repo that deliberately has none is not a
6
+ * decision this tool gets to make. And it writes inside a marked block, so re-running
7
+ * after an upgrade replaces the previous copy instead of appending a second one; two
8
+ * copies of the skill in a prompt is worse than none, because after the next upgrade they
9
+ * disagree with each other.
10
+ *
11
+ * It is never automatic. `mast skill` prints; `--install` writes, and `--dry-run` shows
12
+ * exactly what would change first. These files are hand-curated and committed, and a tool
13
+ * that edits them uninvited is a tool that turns up in someone's `git diff` unannounced.
14
+ */
15
+ export declare const BEGIN_MARKER = "<!-- BEGIN mast skill \u2014 managed by `mast skill --install`, edits here are overwritten -->";
16
+ export declare const END_MARKER = "<!-- END mast skill -->";
17
+ export interface SkillTarget {
18
+ /** Path relative to the project root, as displayed. */
19
+ readonly file: string;
20
+ /** Absolute path. */
21
+ readonly path: string;
22
+ /** The agent this file configures, for the confirmation line. */
23
+ readonly agent: string;
24
+ }
25
+ /** Agent config files that exist in this project. Never invents one. */
26
+ export declare function detectSkillTargets(projectRoot: string): readonly SkillTarget[];
27
+ /**
28
+ * Inserts or replaces the managed block. Returns the content unchanged when the block is
29
+ * already present and identical, so a re-run is a genuine no-op rather than a whitespace diff.
30
+ */
31
+ export declare function spliceSkillBlock(existing: string, skillText: string): string;
32
+ export interface InstallOutcome {
33
+ readonly target: SkillTarget;
34
+ readonly changed: boolean;
35
+ }
36
+ export declare function installSkillInto(targets: readonly SkillTarget[], skillText: string, options?: {
37
+ dryRun?: boolean;
38
+ }): readonly InstallOutcome[];
39
+ //# sourceMappingURL=skill-install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-install.d.ts","sourceRoot":"","sources":["../../src/cli/skill-install.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,YAAY,mGAA8F,CAAC;AACxH,eAAO,MAAM,UAAU,4BAA4B,CAAC;AAEpD,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qBAAqB;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAUD,wEAAwE;AACxE,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,WAAW,EAAE,CAI9E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAW5E;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,SAAS,cAAc,EAAE,CAQ3B"}
@@ -0,0 +1,57 @@
1
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ /**
4
+ * `mast skill --install` — splices the MAST instructions into a project's agent config.
5
+ *
6
+ * Two rules shape this, both about not surprising someone. It writes only into files that
7
+ * ALREADY exist — creating a `CLAUDE.md` in a repo that deliberately has none is not a
8
+ * decision this tool gets to make. And it writes inside a marked block, so re-running
9
+ * after an upgrade replaces the previous copy instead of appending a second one; two
10
+ * copies of the skill in a prompt is worse than none, because after the next upgrade they
11
+ * disagree with each other.
12
+ *
13
+ * It is never automatic. `mast skill` prints; `--install` writes, and `--dry-run` shows
14
+ * exactly what would change first. These files are hand-curated and committed, and a tool
15
+ * that edits them uninvited is a tool that turns up in someone's `git diff` unannounced.
16
+ */
17
+ export const BEGIN_MARKER = '<!-- BEGIN mast skill — managed by `mast skill --install`, edits here are overwritten -->';
18
+ export const END_MARKER = '<!-- END mast skill -->';
19
+ const CANDIDATES = [
20
+ { file: 'CLAUDE.md', agent: 'Claude Code / Claude Desktop' },
21
+ { file: 'AGENTS.md', agent: 'Codex and other AGENTS.md readers' },
22
+ { file: '.cursorrules', agent: 'Cursor' },
23
+ { file: '.windsurfrules', agent: 'Windsurf' },
24
+ { file: '.github/copilot-instructions.md', agent: 'GitHub Copilot' },
25
+ ];
26
+ /** Agent config files that exist in this project. Never invents one. */
27
+ export function detectSkillTargets(projectRoot) {
28
+ return CANDIDATES
29
+ .map((c) => ({ ...c, path: join(projectRoot, c.file) }))
30
+ .filter((c) => existsSync(c.path));
31
+ }
32
+ /**
33
+ * Inserts or replaces the managed block. Returns the content unchanged when the block is
34
+ * already present and identical, so a re-run is a genuine no-op rather than a whitespace diff.
35
+ */
36
+ export function spliceSkillBlock(existing, skillText) {
37
+ const block = `${BEGIN_MARKER}\n\n${skillText.trimEnd()}\n\n${END_MARKER}`;
38
+ const begin = existing.indexOf(BEGIN_MARKER);
39
+ const end = existing.indexOf(END_MARKER);
40
+ if (begin !== -1 && end !== -1 && end > begin) {
41
+ const replaced = existing.slice(0, begin) + block + existing.slice(end + END_MARKER.length);
42
+ return replaced === existing ? existing : replaced;
43
+ }
44
+ const base = existing.trimEnd();
45
+ return base === '' ? block + '\n' : `${base}\n\n${block}\n`;
46
+ }
47
+ export function installSkillInto(targets, skillText, options = {}) {
48
+ return targets.map((target) => {
49
+ const before = existsSync(target.path) ? readFileSync(target.path, 'utf8') : '';
50
+ const after = spliceSkillBlock(before, skillText);
51
+ const changed = after !== before;
52
+ if (changed && options.dryRun !== true)
53
+ writeFileSync(target.path, after);
54
+ return { target, changed };
55
+ });
56
+ }
57
+ //# sourceMappingURL=skill-install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-install.js","sourceRoot":"","sources":["../../src/cli/skill-install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;;;;;GAaG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,2FAA2F,CAAC;AACxH,MAAM,CAAC,MAAM,UAAU,GAAG,yBAAyB,CAAC;AAWpD,MAAM,UAAU,GAA+C;IAC7D,EAAE,IAAI,EAAE,WAAW,EAAyB,KAAK,EAAE,8BAA8B,EAAE;IACnF,EAAE,IAAI,EAAE,WAAW,EAAyB,KAAK,EAAE,mCAAmC,EAAE;IACxF,EAAE,IAAI,EAAE,cAAc,EAAsB,KAAK,EAAE,QAAQ,EAAE;IAC7D,EAAE,IAAI,EAAE,gBAAgB,EAAoB,KAAK,EAAE,UAAU,EAAE;IAC/D,EAAE,IAAI,EAAE,iCAAiC,EAAG,KAAK,EAAE,gBAAgB,EAAE;CACtE,CAAC;AAEF,wEAAwE;AACxE,MAAM,UAAU,kBAAkB,CAAC,WAAmB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G,CAAC,CAAC,MAAM,EAAE,EAAE;QAC5B,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAChF,MAAM,KAAK,GAAG,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAClD,MAAM,OAAO,GAAG,KAAK,KAAK,MAAM,CAAC;QACjC,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI;YAAE,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC1E,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { Command } from 'commander';
2
+ export interface StatusReport {
3
+ readonly state_dir: string;
4
+ /** False when nothing has ever been indexed at `state_dir`. */
5
+ readonly initialised: boolean;
6
+ readonly schema_version: string;
7
+ readonly last_indexed: string | null;
8
+ readonly indexed_files: number | null;
9
+ readonly chunk_count: number | null;
10
+ /** `null` when there is no index — a stale count against nothing is meaningless. */
11
+ readonly stale_files: number | null;
12
+ readonly parse_errors: number | null;
13
+ readonly write_errors: number | null;
14
+ readonly index_fresh: boolean;
15
+ readonly freshness_cause: string | null;
16
+ readonly seed_commit?: string | undefined;
17
+ }
18
+ /**
19
+ * Builds the status report.
20
+ *
21
+ * The `initialised` distinction is load-bearing. M6 (ADR 008) fixed `mast serve`
22
+ * answering meaningfully against a never-indexed state directory; the same shape
23
+ * survived here. Pointed at a path with no index, this used to report an invented
24
+ * schema version, a stale-file count computed against an empty manifest, and
25
+ * `freshness_cause: phase1_stale` — telling a caller their index was stale when in
26
+ * fact they were looking in the wrong place. The case that produces it is ordinary:
27
+ * `mast init --state-dir ./elsewhere`, then any later command without the flag,
28
+ * because path keys are deliberately never read back from a persisted config.
29
+ */
30
+ export declare function buildStatus(options?: {
31
+ path?: string;
32
+ stateDir?: string;
33
+ }): Promise<StatusReport>;
34
+ export declare function registerStatusCommand(program: Command): void;
35
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/cli/status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,+DAA+D;IAC/D,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,oFAAoF;IACpF,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3C;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAC/B,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GACjD,OAAO,CAAC,YAAY,CAAC,CA+CvB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkD5D"}
@@ -0,0 +1,117 @@
1
+ import { resolveConfig, CURRENT_SCHEMA_VERSION } from '../store/config.js';
2
+ import { loadIndexMeta, freshnessCause } from '../indexer/index.js';
3
+ import { measureFreshness } from '../indexer/freshness.js';
4
+ import { openDatabase } from '../graph/db.js';
5
+ /**
6
+ * Builds the status report.
7
+ *
8
+ * The `initialised` distinction is load-bearing. M6 (ADR 008) fixed `mast serve`
9
+ * answering meaningfully against a never-indexed state directory; the same shape
10
+ * survived here. Pointed at a path with no index, this used to report an invented
11
+ * schema version, a stale-file count computed against an empty manifest, and
12
+ * `freshness_cause: phase1_stale` — telling a caller their index was stale when in
13
+ * fact they were looking in the wrong place. The case that produces it is ordinary:
14
+ * `mast init --state-dir ./elsewhere`, then any later command without the flag,
15
+ * because path keys are deliberately never read back from a persisted config.
16
+ */
17
+ export async function buildStatus(options = {}) {
18
+ const config = resolveConfig({ projectRoot: options.path, stateDirOverride: options.stateDir });
19
+ const meta = loadIndexMeta(config.resolved_state_dir);
20
+ if (meta === null) {
21
+ return {
22
+ state_dir: config.resolved_state_dir,
23
+ initialised: false,
24
+ schema_version: CURRENT_SCHEMA_VERSION,
25
+ last_indexed: null,
26
+ indexed_files: null,
27
+ chunk_count: null,
28
+ stale_files: null,
29
+ parse_errors: null,
30
+ write_errors: null,
31
+ index_fresh: false,
32
+ freshness_cause: 'not_initialised',
33
+ };
34
+ }
35
+ // Freshness needs the `files` stamps as well as the manifest (see
36
+ // `measureFreshness`), so this opens the graph db — safe here and nowhere
37
+ // above, because the `meta === null` branch has already returned for a state
38
+ // dir that was never indexed.
39
+ const db = openDatabase(config.resolved_state_dir);
40
+ let staleCount;
41
+ try {
42
+ staleCount = (await measureFreshness(config, db)).total;
43
+ }
44
+ finally {
45
+ await db.destroy();
46
+ }
47
+ return {
48
+ state_dir: config.resolved_state_dir,
49
+ initialised: true,
50
+ // From the binary, never from index.json — see StatusResult.schema_version.
51
+ schema_version: CURRENT_SCHEMA_VERSION,
52
+ last_indexed: meta.last_indexed ?? null,
53
+ indexed_files: meta.file_count ?? 0,
54
+ chunk_count: meta.chunk_count ?? 0,
55
+ stale_files: staleCount,
56
+ parse_errors: meta.parse_errors ?? 0,
57
+ write_errors: meta.write_errors ?? 0,
58
+ index_fresh: staleCount === 0,
59
+ freshness_cause: freshnessCause(staleCount),
60
+ seed_commit: meta.seed_commit,
61
+ };
62
+ }
63
+ export function registerStatusCommand(program) {
64
+ program
65
+ .command('status [path]')
66
+ .description('Print index health')
67
+ .option('--state-dir <dir>', 'State directory')
68
+ .option('--json', 'Output as JSON')
69
+ .action(async (projectPath, opts) => {
70
+ const status = await buildStatus({ path: projectPath, stateDir: opts.stateDir });
71
+ if (opts.json) {
72
+ process.stdout.write(JSON.stringify(status, null, 2) + '\n');
73
+ return;
74
+ }
75
+ // An absent index gets a short, unambiguous answer and a non-zero exit — not a
76
+ // health table with zeros in it, which reads as a report on something real.
77
+ if (!status.initialised) {
78
+ process.stdout.write([
79
+ `state_dir: ${status.state_dir}`,
80
+ 'index: NOT INITIALISED — nothing has been indexed at this path',
81
+ '',
82
+ 'Run `mast init` here, or pass --state-dir if you indexed somewhere else.',
83
+ 'A custom --state-dir is not remembered between runs; set `state_dir` in',
84
+ 'mast.config.json or export MAST_STATE_DIR to make it stick.',
85
+ ].join('\n') + '\n');
86
+ process.exitCode = 1;
87
+ return;
88
+ }
89
+ const ago = status.last_indexed != null
90
+ ? ` (${formatAge(new Date(status.last_indexed))} ago)`
91
+ : '';
92
+ process.stdout.write([
93
+ `state_dir: ${status.state_dir}`,
94
+ `schema_version: ${status.schema_version}`,
95
+ `last_indexed: ${status.last_indexed ?? 'never'}${ago}`,
96
+ `indexed_files: ${String(status.indexed_files)}`,
97
+ `chunk_count: ${String(status.chunk_count)}`,
98
+ `stale_files: ${String(status.stale_files)}`,
99
+ `parse_errors: ${String(status.parse_errors)}`,
100
+ `write_errors: ${String(status.write_errors)}`,
101
+ `index_fresh: ${String(status.index_fresh)}`,
102
+ `freshness_cause: ${status.freshness_cause ?? 'none'}`,
103
+ ...(status.seed_commit != null ? [`seed_commit: ${status.seed_commit}`] : []),
104
+ ].join('\n') + '\n');
105
+ });
106
+ }
107
+ function formatAge(date) {
108
+ const seconds = Math.floor((Date.now() - date.getTime()) / 1_000);
109
+ if (seconds < 60)
110
+ return `${seconds}s`;
111
+ if (seconds < 3_600)
112
+ return `${Math.floor(seconds / 60)}m`;
113
+ if (seconds < 86_400)
114
+ return `${Math.floor(seconds / 3_600)}h`;
115
+ return `${Math.floor(seconds / 86_400)}d`;
116
+ }
117
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/cli/status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAmB9C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,UAAgD,EAAE;IAElD,MAAM,MAAM,GAAG,aAAa,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAChG,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAEtD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO;YACL,SAAS,EAAE,MAAM,CAAC,kBAAkB;YACpC,WAAW,EAAE,KAAK;YAClB,cAAc,EAAE,sBAAsB;YACtC,YAAY,EAAE,IAAI;YAClB,aAAa,EAAE,IAAI;YACnB,WAAW,EAAE,IAAI;YACjB,WAAW,EAAE,IAAI;YACjB,YAAY,EAAE,IAAI;YAClB,YAAY,EAAE,IAAI;YAClB,WA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D,mBAAmB,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE;YAChD,mBAAmB,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE;YAC/C,oBAAoB,MAAM,CAAC,eAAe,IAAI,MAAM,EAAE;YACtD,GAAG,CAAC,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,mBAAmB,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACjF,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,SAAS,CAAC,IAAU;IAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC;IAClE,IAAI,OAAO,GAAG,EAAE;QAAE,OAAO,GAAG,OAAO,GAAG,CAAC;IACvC,IAAI,OAAO,GAAG,KAAK;QAAE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC;IAC3D,IAAI,OAAO,GAAG,MAAM;QAAE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC;IAC/D,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,48 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * `mast upgrade` — checks and instructs. It deliberately does NOT perform the upgrade.
4
+ *
5
+ * Two reasons, both practical rather than stylistic. A CLI cannot reliably know how it
6
+ * was installed — global, devDependency, dlx, a monorepo catalog — and guessing wrong
7
+ * means running the wrong command in someone's repository. And self-mutating requires
8
+ * write access to its own install directory, which is exactly what fails in CI and
9
+ * containers.
10
+ *
11
+ * What the package manager *cannot* do is the reason this command exists at all:
12
+ * upgrading across a schema-version change makes `bootstrapState` discard the index and
13
+ * reindex from scratch (`mcp/startup.ts`). On a 150k-chunk monorepo that is minutes of
14
+ * silence on the next `serve`, and `pnpm up` will never mention it. Telling the user
15
+ * before they upgrade is this command's whole job.
16
+ */
17
+ export type InstallKind = 'local' | 'global' | 'source';
18
+ export type PackageManager = 'pnpm' | 'npm' | 'yarn';
19
+ export interface UpgradeFacts {
20
+ readonly current: string;
21
+ /** `null` when the registry could not be reached — never conflated with "current". */
22
+ readonly latest: string | null;
23
+ readonly installKind: InstallKind;
24
+ readonly packageManager: PackageManager;
25
+ readonly currentSchema: string;
26
+ /** Schema recorded in the user's index, or `null` if never indexed. */
27
+ readonly indexedSchema: string | null;
28
+ readonly chunkCount: number | null;
29
+ }
30
+ /** Semver compare, prerelease-aware. Returns <0, 0, or >0. */
31
+ export declare function compareVersions(a: string, b: string): number;
32
+ /**
33
+ * Classifies how this binary was installed, from the directory it is executing out of.
34
+ * `node_modules` under the project being indexed is a dependency; `node_modules`
35
+ * elsewhere is a global prefix; anything else is a checkout.
36
+ */
37
+ export declare function detectInstallKind(moduleDir: string, projectRoot: string): InstallKind;
38
+ export declare function upgradeCommandFor(kind: InstallKind, pm: PackageManager): string;
39
+ export declare function buildUpgradeReport(f: UpgradeFacts): string;
40
+ /** Registry lookup, injected so tests never depend on the network. */
41
+ export type LatestVersionLookup = () => Promise<string | null>;
42
+ export declare const fetchLatestFromNpm: LatestVersionLookup;
43
+ export declare function gatherUpgradeFacts(options?: {
44
+ path?: string;
45
+ stateDir?: string;
46
+ }, lookup?: LatestVersionLookup): Promise<UpgradeFacts>;
47
+ export declare function registerUpgradeCommand(program: Command): void;
48
+ //# sourceMappingURL=upgrade-cmd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-cmd.d.ts","sourceRoot":"","sources":["../../src/cli/upgrade-cmd.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,E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wC,GAC/C,OAAO,CAAC,YAAY,CAAC,CAqBvB;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAa7D"}
@@ -0,0 +1,129 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { dirname, join, relative, isAbsolute } from 'node:path';
4
+ import { CLI_VERSION, PACKAGE_NAME } from './version.js';
5
+ import { resolveConfig, CURRENT_SCHEMA_VERSION } from '../store/config.js';
6
+ /** Semver compare, prerelease-aware. Returns <0, 0, or >0. */
7
+ export function compareVersions(a, b) {
8
+ const split = (v) => {
9
+ const [core = '', ...rest] = v.split('-');
10
+ return { nums: core.split('.').map((n) => Number(n) || 0), pre: rest.join('-') };
11
+ };
12
+ const x = split(a), y = split(b);
13
+ for (let i = 0; i < 3; i++) {
14
+ const d = (x.nums[i] ?? 0) - (y.nums[i] ?? 0);
15
+ if (d !== 0)
16
+ return d;
17
+ }
18
+ // Equal cores: a prerelease sorts BEFORE its release (1.0.0-rc.1 < 1.0.0).
19
+ if (x.pre === y.pre)
20
+ return 0;
21
+ if (x.pre === '')
22
+ return 1;
23
+ if (y.pre === '')
24
+ return -1;
25
+ return x.pre < y.pre ? -1 : 1;
26
+ }
27
+ /**
28
+ * Classifies how this binary was installed, from the directory it is executing out of.
29
+ * `node_modules` under the project being indexed is a dependency; `node_modules`
30
+ * elsewhere is a global prefix; anything else is a checkout.
31
+ */
32
+ export function detectInstallKind(moduleDir, projectRoot) {
33
+ if (!moduleDir.includes('node_modules'))
34
+ return 'source';
35
+ const rel = relative(projectRoot, moduleDir);
36
+ return rel !== '' && !rel.startsWith('..') && !isAbsolute(rel) ? 'local' : 'global';
37
+ }
38
+ export function upgradeCommandFor(kind, pm) {
39
+ if (kind === 'source')
40
+ return 'git pull && pnpm install && pnpm build';
41
+ if (kind === 'global') {
42
+ return pm === 'npm' ? `npm install -g ${PACKAGE_NAME}@latest`
43
+ : pm === 'yarn' ? `yarn global add ${PACKAGE_NAME}@latest`
44
+ : `pnpm add -g ${PACKAGE_NAME}@latest`;
45
+ }
46
+ return pm === 'npm' ? `npm install --save-dev ${PACKAGE_NAME}@latest`
47
+ : pm === 'yarn' ? `yarn upgrade ${PACKAGE_NAME}@latest`
48
+ : `pnpm up ${PACKAGE_NAME}@latest`;
49
+ }
50
+ export function buildUpgradeReport(f) {
51
+ const out = [`${PACKAGE_NAME} ${f.current}`, ''];
52
+ if (f.latest === null) {
53
+ out.push('Could not reach the npm registry, so the latest version is unknown.', `When you do upgrade: ${upgradeCommandFor(f.installKind, f.packageManager)}`, '');
54
+ }
55
+ else if (compareVersions(f.current, f.latest) >= 0) {
56
+ out.push(`Up to date — ${f.latest} is the latest release.`, '');
57
+ }
58
+ else {
59
+ out.push(`${f.current} → ${f.latest} available`, '', ` installed as: ${f.installKind === 'local' ? 'project dependency' : f.installKind === 'global' ? 'global install' : 'source checkout'} (${f.packageManager})`, ` run: ${upgradeCommandFor(f.installKind, f.packageManager)}`, '');
60
+ }
61
+ // The half npm cannot tell them. Only warn when there is an index to lose.
62
+ if (f.indexedSchema !== null && f.indexedSchema !== f.currentSchema) {
63
+ const size = f.chunkCount === null ? 'your whole project' : `${f.chunkCount.toLocaleString('en-US')} chunks`;
64
+ out.push(`Your index was built under schema ${f.indexedSchema}; this build expects ${f.currentSchema}.`, `The next \`mast serve\` or \`mast index\` will discard it and reindex ${size} from scratch.`, 'Nothing is lost that cannot be rebuilt — the index is derived state — but budget the time.', '');
65
+ }
66
+ return out.join('\n').trimEnd();
67
+ }
68
+ export const fetchLatestFromNpm = async () => {
69
+ try {
70
+ const res = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, {
71
+ headers: { accept: 'application/vnd.npm.install-v1+json' },
72
+ signal: AbortSignal.timeout(5000),
73
+ });
74
+ if (!res.ok)
75
+ return null;
76
+ return (await res.json()).version ?? null;
77
+ }
78
+ catch {
79
+ // Offline, proxied, or unpublished. The report handles null honestly; a thrown
80
+ // error here would make `mast upgrade` useless exactly when it is most wanted.
81
+ return null;
82
+ }
83
+ };
84
+ function detectPackageManager() {
85
+ const ua = process.env['npm_config_user_agent'] ?? '';
86
+ if (ua.startsWith('npm'))
87
+ return 'npm';
88
+ if (ua.startsWith('yarn'))
89
+ return 'yarn';
90
+ return 'pnpm';
91
+ }
92
+ export async function gatherUpgradeFacts(options = {}, lookup = fetchLatestFromNpm) {
93
+ const config = resolveConfig({ projectRoot: options.path, stateDirOverride: options.stateDir });
94
+ let indexedSchema = null;
95
+ let chunkCount = null;
96
+ try {
97
+ const meta = JSON.parse(readFileSync(join(config.resolved_state_dir, 'index.json'), 'utf8'));
98
+ indexedSchema = meta.schema_version ?? null;
99
+ chunkCount = meta.chunk_count ?? null;
100
+ }
101
+ catch {
102
+ // No index yet — then there is nothing to warn about losing.
103
+ }
104
+ return {
105
+ current: CLI_VERSION,
106
+ latest: await lookup(),
107
+ installKind: detectInstallKind(dirname(fileURLToPath(import.meta.url)), config.resolved_project_root),
108
+ packageManager: detectPackageManager(),
109
+ currentSchema: CURRENT_SCHEMA_VERSION,
110
+ indexedSchema,
111
+ chunkCount,
112
+ };
113
+ }
114
+ export function registerUpgradeCommand(program) {
115
+ program
116
+ .command('upgrade [path]')
117
+ .description('Check for a newer release and print how to install it, including any reindex it will cost')
118
+ .option('--state-dir <dir>', 'State directory')
119
+ .action(async (path, opts) => {
120
+ try {
121
+ process.stdout.write(buildUpgradeReport(await gatherUpgradeFacts({ path, stateDir: opts.stateDir })) + '\n');
122
+ }
123
+ catch (err) {
124
+ process.stderr.write(`${err instanceof Error ? err.message : String(err)}\n`);
125
+ process.exitCode = 1;
126
+ }
127
+ });
128
+ }
129
+ //# sourceMappingURL=upgrade-cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-cmd.js","sourceRoot":"","sources":["../../src/cli/upgrade-cmd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO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C,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC9E,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const PACKAGE_NAME: string;
2
+ export declare const CLI_VERSION: string;
3
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/cli/version.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,YAAY,EAAE,MAAsB,CAAC;AAClD,eAAO,MAAM,WAAW,EAAE,MAAyB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { createRequire } from 'node:module';
2
+ /**
3
+ * Package identity, read from the manifest rather than restated.
4
+ *
5
+ * The CLI previously carried a literal `.version('0.1.0')` next to package.json's
6
+ * own `"version"`. Two producers of one value drift (defect shape S-05), and this
7
+ * pair drifts silently: nothing fails when `mast --version` reports a release the
8
+ * binary is not, which is precisely the confusion D8 cost three days to untangle.
9
+ *
10
+ * `createRequire` rather than a JSON import attribute: the same mechanism
11
+ * `ast/parser.ts` already uses, and it resolves identically from `src/` under
12
+ * vitest and from `dist/cli/` in the published package, because both sit two
13
+ * directories below the manifest.
14
+ */
15
+ const require = createRequire(import.meta.url);
16
+ const manifest = require('../../package.json');
17
+ export const PACKAGE_NAME = manifest.name;
18
+ export const CLI_VERSION = manifest.version;
19
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/cli/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAsC,CAAC;AAEpF,MAAM,CAAC,MAAM,YAAY,GAAW,QAAQ,CAAC,IAAI,CAAC;AAClD,MAAM,CAAC,MAAM,WAAW,GAAW,QAAQ,CAAC,OAAO,CAAC"}
package/dist/env.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Single source of truth for all environment variables read by MAST.
3
+ *
4
+ * `ConfigEnvSchema` is used by the main process in `store/config.ts`. The
5
+ * background embedder worker's `WorkerEnvSchema` was removed in Stage 7.1
6
+ * (IMPLEMENTATION_PLAN.md "Stage 7: Vector-store deletion") along with the
7
+ * worker process it configured.
8
+ *
9
+ * Nothing below the process entry point should call `process.env` directly.
10
+ */
11
+ import { z } from 'zod';
12
+ /** Environment variables relevant to the main CLI / MCP server process. */
13
+ export declare const ConfigEnvSchema: z.ZodObject<{
14
+ MAST_STATE_DIR: z.ZodOptional<z.ZodString>;
15
+ }, z.core.$strip>;
16
+ export type ConfigEnv = z.infer<typeof ConfigEnvSchema>;
17
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,2EAA2E;AAC3E,eAAO,MAAM,eAAe;;iBAG1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
package/dist/env.js ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Single source of truth for all environment variables read by MAST.
3
+ *
4
+ * `ConfigEnvSchema` is used by the main process in `store/config.ts`. The
5
+ * background embedder worker's `WorkerEnvSchema` was removed in Stage 7.1
6
+ * (IMPLEMENTATION_PLAN.md "Stage 7: Vector-store deletion") along with the
7
+ * worker process it configured.
8
+ *
9
+ * Nothing below the process entry point should call `process.env` directly.
10
+ */
11
+ import { z } from 'zod';
12
+ /** Environment variables relevant to the main CLI / MCP server process. */
13
+ export const ConfigEnvSchema = z.object({
14
+ /** Override for the state directory path. Falls back to config file then default. */
15
+ MAST_STATE_DIR: z.string().min(1).optional(),
16
+ });
17
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,2EAA2E;AAC3E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,qFAAqF;IACrF,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC7C,CAAC,CAAC"}