@phuc1403/musketeer 0.9.0 → 0.10.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 (163) hide show
  1. package/INSTALLATION.md +52 -52
  2. package/bin/musketeer.js +168 -168
  3. package/package.json +48 -48
  4. package/src/dotnet-scaffold-copier.js +79 -79
  5. package/src/provisioner/detect.js +93 -93
  6. package/src/self-update.js +77 -77
  7. package/template/.claude/agents/git-manager.md +18 -18
  8. package/template/.claude/agents/hallmark-auditor.md +78 -78
  9. package/template/.claude/agents/researcher.md +33 -33
  10. package/template/.claude/hooks/block-unsafe-adr-title.cjs +85 -85
  11. package/template/.claude/hooks/init-adr-dir.cjs +173 -173
  12. package/template/.claude/hooks/inject-adr-flags.cjs +94 -94
  13. package/template/.claude/hooks/lib/adr/command-scan.cjs +115 -115
  14. package/template/.claude/hooks/lib/characteristics/checker.cjs +357 -357
  15. package/template/.claude/hooks/lib/git-info-cache.cjs +191 -191
  16. package/template/.claude/hooks/sync-adr-toc.cjs +146 -146
  17. package/template/.claude/hooks/usage-quota-cache-refresh.cjs +166 -166
  18. package/template/.claude/hooks/validate-characteristics-hook.cjs +66 -66
  19. package/template/.claude/hooks/validate-cml-hook.js +145 -145
  20. package/template/.claude/skills/adr-writer/SKILL.md +48 -48
  21. package/template/.claude/skills/adr-writer/references/adr-example.md +35 -35
  22. package/template/.claude/skills/architecture-characteristic-writer/SKILL.md +215 -215
  23. package/template/.claude/skills/architecture-characteristic-writer/assets/worksheet-template.md +29 -29
  24. package/template/.claude/skills/architecture-characteristic-writer/references/characteristics-catalog.md +40 -40
  25. package/template/.claude/skills/architecture-characteristic-writer/scripts/ranking-table.cjs +171 -171
  26. package/template/.claude/skills/context-map/SKILL.md +80 -80
  27. package/template/.claude/skills/context-map/example.cml +106 -106
  28. package/template/.claude/skills/context-map/reference/Bounded Context/Bounded Context.md +40 -40
  29. package/template/.claude/skills/context-map/reference/Bounded Context/businessModel.md +5 -5
  30. package/template/.claude/skills/context-map/reference/Bounded Context/domainVisionStatement.md +2 -2
  31. package/template/.claude/skills/context-map/reference/Bounded Context/evolution.md +5 -5
  32. package/template/.claude/skills/context-map/reference/Bounded Context/implementationTechnology.md +1 -1
  33. package/template/.claude/skills/context-map/reference/Bounded Context/implements.md +1 -1
  34. package/template/.claude/skills/context-map/reference/Bounded Context/knowledgeLevel.md +4 -4
  35. package/template/.claude/skills/context-map/reference/Bounded Context/realizes.md +9 -9
  36. package/template/.claude/skills/context-map/reference/Bounded Context/refines.md +10 -10
  37. package/template/.claude/skills/context-map/reference/Bounded Context/responsibilities.md +26 -26
  38. package/template/.claude/skills/context-map/reference/Bounded Context/type.md +23 -23
  39. package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Anticorruption Layer.md +5 -5
  40. package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Bounded Context Relationship.md +12 -12
  41. package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Conformist.md +5 -5
  42. package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Customer-Supplier (C-S).md +22 -22
  43. package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Open Host Service.md +4 -4
  44. package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Partnership (P).md +13 -13
  45. package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Published Language.md +4 -4
  46. package/template/.claude/skills/context-map/reference/Bounded Context Relationship/Shared Kernel (SK).md +12 -12
  47. package/template/.claude/skills/context-map/reference/Context Map.md +62 -62
  48. package/template/.claude/skills/context-map/reference/Domain/Domain.md +30 -30
  49. package/template/.claude/skills/context-map/reference/Domain/supports.md +33 -33
  50. package/template/.claude/skills/context-map/reference/Domain/type.md +3 -3
  51. package/template/.claude/skills/context-map/reference/Semantic Rules.md +32 -32
  52. package/template/.claude/skills/hallmark/SKILL.md +552 -552
  53. package/template/.claude/skills/hallmark/references/anti-patterns.md +412 -412
  54. package/template/.claude/skills/hallmark/references/assets.md +406 -406
  55. package/template/.claude/skills/hallmark/references/color.md +95 -95
  56. package/template/.claude/skills/hallmark/references/component-cookbook.md +256 -256
  57. package/template/.claude/skills/hallmark/references/components/c1-outlined-chip.md +12 -12
  58. package/template/.claude/skills/hallmark/references/components/c2-inline-form-as-cta.md +16 -16
  59. package/template/.claude/skills/hallmark/references/components/c3-typographic-link.md +8 -8
  60. package/template/.claude/skills/hallmark/references/components/c4-sticky-bottom-bar.md +16 -16
  61. package/template/.claude/skills/hallmark/references/components/f1-bento-grid.md +20 -20
  62. package/template/.claude/skills/hallmark/references/components/f2-sticky-scroll-stack.md +20 -20
  63. package/template/.claude/skills/hallmark/references/components/f3-tabular-spec-sheet.md +11 -11
  64. package/template/.claude/skills/hallmark/references/components/f4-step-sequence.md +11 -11
  65. package/template/.claude/skills/hallmark/references/components/f5-annotated-screenshot.md +11 -11
  66. package/template/.claude/skills/hallmark/references/components/f6-product-card-grid.md +41 -41
  67. package/template/.claude/skills/hallmark/references/components/ft1-mast-headed.md +13 -13
  68. package/template/.claude/skills/hallmark/references/components/ft2-inline-rule-single-line.md +10 -10
  69. package/template/.claude/skills/hallmark/references/components/ft3-index-style-category-list.md +12 -12
  70. package/template/.claude/skills/hallmark/references/components/ft4-dense-typographic.md +10 -10
  71. package/template/.claude/skills/hallmark/references/components/ft5-statement.md +21 -21
  72. package/template/.claude/skills/hallmark/references/components/ft6-letter-close.md +19 -19
  73. package/template/.claude/skills/hallmark/references/components/ft7-newsletter-first.md +27 -27
  74. package/template/.claude/skills/hallmark/references/components/ft8-marquee-scroll.md +25 -25
  75. package/template/.claude/skills/hallmark/references/components/h1-marquee.md +15 -15
  76. package/template/.claude/skills/hallmark/references/components/h2-split-diptych.md +15 -15
  77. package/template/.claude/skills/hallmark/references/components/h3-quote-led.md +11 -11
  78. package/template/.claude/skills/hallmark/references/components/h4-stat-led.md +14 -14
  79. package/template/.claude/skills/hallmark/references/components/h5-letter-hero.md +11 -11
  80. package/template/.claude/skills/hallmark/references/components/h6-photographic-fold.md +16 -16
  81. package/template/.claude/skills/hallmark/references/components/h7-demo-video-clipped-by-viewport-edge.md +27 -27
  82. package/template/.claude/skills/hallmark/references/components/h8-mockup-split-browser-framed.md +23 -23
  83. package/template/.claude/skills/hallmark/references/components/h9-custom-illustration-centerpiece.md +27 -27
  84. package/template/.claude/skills/hallmark/references/components/n1-wordmark-2-links.md +12 -12
  85. package/template/.claude/skills/hallmark/references/components/n10-floating-on-scroll-morph.md +19 -19
  86. package/template/.claude/skills/hallmark/references/components/n2-floating-chip.md +14 -14
  87. package/template/.claude/skills/hallmark/references/components/n3-side-rail.md +14 -14
  88. package/template/.claude/skills/hallmark/references/components/n4-hidden-behind-k.md +9 -9
  89. package/template/.claude/skills/hallmark/references/components/n5-floating-pill.md +28 -28
  90. package/template/.claude/skills/hallmark/references/components/n6-newspaper-masthead.md +24 -24
  91. package/template/.claude/skills/hallmark/references/components/n7-brutal-slab.md +22 -22
  92. package/template/.claude/skills/hallmark/references/components/n8-terminal-command.md +21 -21
  93. package/template/.claude/skills/hallmark/references/components/n9-edge-aligned-minimal.md +17 -17
  94. package/template/.claude/skills/hallmark/references/components/s1-left-margin-numbered.md +15 -15
  95. package/template/.claude/skills/hallmark/references/components/s2-hanging.md +13 -13
  96. package/template/.claude/skills/hallmark/references/components/s3-sticky-pinned.md +19 -19
  97. package/template/.claude/skills/hallmark/references/components/s4-inline-no-break.md +11 -11
  98. package/template/.claude/skills/hallmark/references/components/s5-bottom-anchored.md +13 -13
  99. package/template/.claude/skills/hallmark/references/components/t1-pull-quote-with-marginalia.md +12 -12
  100. package/template/.claude/skills/hallmark/references/components/t2-logo-wall-hairline.md +19 -19
  101. package/template/.claude/skills/hallmark/references/components/t3-single-huge-quote.md +11 -11
  102. package/template/.claude/skills/hallmark/references/components/t4-numbered-stat-strip.md +14 -14
  103. package/template/.claude/skills/hallmark/references/contract.md +24 -24
  104. package/template/.claude/skills/hallmark/references/copy.md +182 -182
  105. package/template/.claude/skills/hallmark/references/custom-craft.md +626 -626
  106. package/template/.claude/skills/hallmark/references/custom-theme.md +329 -329
  107. package/template/.claude/skills/hallmark/references/design-md.md +116 -116
  108. package/template/.claude/skills/hallmark/references/export-formats.md +328 -328
  109. package/template/.claude/skills/hallmark/references/floating-nav.md +89 -89
  110. package/template/.claude/skills/hallmark/references/genres/atmospheric.md +65 -65
  111. package/template/.claude/skills/hallmark/references/genres/editorial.md +70 -70
  112. package/template/.claude/skills/hallmark/references/genres/modern-minimal.md +67 -67
  113. package/template/.claude/skills/hallmark/references/genres/playful.md +65 -65
  114. package/template/.claude/skills/hallmark/references/hero-enrichment.md +474 -474
  115. package/template/.claude/skills/hallmark/references/imagery-kit.md +170 -170
  116. package/template/.claude/skills/hallmark/references/interaction-and-states.md +207 -207
  117. package/template/.claude/skills/hallmark/references/layout-and-space.md +111 -111
  118. package/template/.claude/skills/hallmark/references/macrostructures/01-bento-grid.md +35 -35
  119. package/template/.claude/skills/hallmark/references/macrostructures/02-long-document.md +34 -34
  120. package/template/.claude/skills/hallmark/references/macrostructures/03-marquee-hero.md +31 -31
  121. package/template/.claude/skills/hallmark/references/macrostructures/04-stat-led.md +32 -32
  122. package/template/.claude/skills/hallmark/references/macrostructures/05-workbench.md +32 -32
  123. package/template/.claude/skills/hallmark/references/macrostructures/06-conversational-faq.md +33 -33
  124. package/template/.claude/skills/hallmark/references/macrostructures/07-manifesto.md +32 -32
  125. package/template/.claude/skills/hallmark/references/macrostructures/08-photographic.md +34 -34
  126. package/template/.claude/skills/hallmark/references/macrostructures/09-quote-led.md +32 -32
  127. package/template/.claude/skills/hallmark/references/macrostructures/10-specimen.md +32 -32
  128. package/template/.claude/skills/hallmark/references/macrostructures/11-catalogue.md +23 -23
  129. package/template/.claude/skills/hallmark/references/macrostructures/12-letter.md +23 -23
  130. package/template/.claude/skills/hallmark/references/macrostructures/13-index-first.md +23 -23
  131. package/template/.claude/skills/hallmark/references/macrostructures/14-narrative-workflow.md +23 -23
  132. package/template/.claude/skills/hallmark/references/macrostructures/15-split-studio.md +23 -23
  133. package/template/.claude/skills/hallmark/references/macrostructures/16-feature-stack.md +23 -23
  134. package/template/.claude/skills/hallmark/references/macrostructures/17-type-specimen.md +23 -23
  135. package/template/.claude/skills/hallmark/references/macrostructures/18-portfolio-grid.md +23 -23
  136. package/template/.claude/skills/hallmark/references/macrostructures/19-map-diagram.md +23 -23
  137. package/template/.claude/skills/hallmark/references/macrostructures/20-ecosystem-index.md +23 -23
  138. package/template/.claude/skills/hallmark/references/macrostructures/21-component-playground.md +23 -23
  139. package/template/.claude/skills/hallmark/references/macrostructures.md +89 -89
  140. package/template/.claude/skills/hallmark/references/microinteractions.md +260 -260
  141. package/template/.claude/skills/hallmark/references/motion.md +109 -109
  142. package/template/.claude/skills/hallmark/references/preview-examples.md +49 -49
  143. package/template/.claude/skills/hallmark/references/responsive.md +138 -138
  144. package/template/.claude/skills/hallmark/references/slop-test.md +205 -205
  145. package/template/.claude/skills/hallmark/references/structure.md +164 -164
  146. package/template/.claude/skills/hallmark/references/study.md +511 -511
  147. package/template/.claude/skills/hallmark/references/typography.md +243 -243
  148. package/template/.claude/skills/hallmark/references/verbs/audit.md +25 -25
  149. package/template/.claude/skills/hallmark/references/verbs/redesign.md +269 -269
  150. package/template/.claude/skills/hallmark-loop/SKILL.md +105 -105
  151. package/template/.claude/skills/hallmark-loop/references/auditor-call.md +60 -60
  152. package/template/.claude/skills/hallmark-loop/references/capture.md +78 -78
  153. package/template/.claude/skills/hallmark-loop/references/loop-control.md +79 -79
  154. package/template/.claude/skills/handoff/SKILL.md +15 -15
  155. package/template/.claude/skills/knowledge-crunching/SKILL.md +94 -94
  156. package/template/.claude/skills/research/SKILL.md +69 -69
  157. package/template/.claude/skills/tdd/SKILL.md +142 -142
  158. package/template/.claude/skills/tdd/deep-modules.md +15 -15
  159. package/template/.claude/skills/tdd/interface-design.md +31 -31
  160. package/template/.claude/skills/tdd/mocking.md +59 -59
  161. package/template/.claude/skills/tdd/refactoring.md +10 -10
  162. package/template/.claude/skills/tdd/tests.md +61 -61
  163. package/template/.claude/statusline.cjs +100 -37
@@ -23,6 +23,12 @@ const { getGitInfo } = require('./hooks/lib/git-info-cache.cjs');
23
23
 
24
24
  // Buffer constant for fallback context calculation
25
25
  const AUTOCOMPACT_BUFFER = 40000;
26
+
27
+ // Quota cache older than this is not rendered — a stale number is worse than none.
28
+ const USAGE_CACHE_RENDER_TTL_MS = 300000;
29
+ // Any window at or above this utilization flips the quota segment to red.
30
+ const QUOTA_HIGH_PERCENT = 85;
31
+
26
32
  const GRAPHEME_SEGMENTER = (
27
33
  typeof Intl !== 'undefined' && typeof Intl.Segmenter === 'function'
28
34
  )
@@ -169,14 +175,98 @@ async function readStdin() {
169
175
  // ============================================================================
170
176
 
171
177
  /**
172
- * Build usage time string with optional percentage
173
- * @returns {string|null} Formatted usage string or null if unavailable
178
+ * Read the usage limits cache written by the usage-quota-cache-refresh hook.
179
+ * @returns {object|null} Parsed cache, or null when absent/unreadable
180
+ */
181
+ function readUsageCache() {
182
+ try {
183
+ const cachePath = env.CK_USAGE_CACHE_PATH || path.join(os.tmpdir(), 'ck-usage-limits-cache.json');
184
+ if (!fs.existsSync(cachePath)) return null;
185
+ return JSON.parse(fs.readFileSync(cachePath, 'utf8'));
186
+ } catch {
187
+ return null;
188
+ }
189
+ }
190
+
191
+ /**
192
+ * Coerce an API utilization value to a whole percent.
193
+ * The API returns either a 0-1 fraction or an already-scaled percent.
194
+ * @returns {number|null} Percent, or null when the value is unusable
195
+ */
196
+ function normalizeUtilization(utilization) {
197
+ if (typeof utilization !== 'number' || !Number.isFinite(utilization)) return null;
198
+ if (utilization > 0 && utilization < 1) return Math.round(utilization * 100);
199
+ return Math.max(0, Math.round(utilization));
200
+ }
201
+
202
+ /**
203
+ * Compact countdown: "45m", "2h21m", "5d".
204
+ * @returns {string} Empty string once the deadline has passed
205
+ */
206
+ function formatCountdown(msLeft) {
207
+ if (msLeft <= 0) return '';
208
+ const mins = Math.floor(msLeft / 60000);
209
+ if (mins < 60) return `${mins}m`;
210
+ if (mins < 1440) {
211
+ const h = Math.floor(mins / 60);
212
+ const m = mins % 60;
213
+ return m > 0 ? `${h}h${m}m` : `${h}h`;
214
+ }
215
+ return `${Math.floor(mins / 1440)}d`;
216
+ }
217
+
218
+ /**
219
+ * Build the quota window strings, e.g. ["5h 14% (2h21m)", "wk 43% (5d)"].
220
+ *
221
+ * Reads the pre-calculated `snapshot` when the cache carries one, and falls
222
+ * back to the raw `data.*.utilization` otherwise — the hook in this project
223
+ * writes only `{timestamp, status, data}`, so the fallback is the normal path.
224
+ *
225
+ * @returns {string[]} One entry per window; empty when unavailable or stale
226
+ */
227
+ function buildUsageWindows(cache) {
228
+ if (!cache || cache.status !== 'available') return [];
229
+ if (typeof cache.timestamp !== 'number') return [];
230
+ const now = Date.now();
231
+ if (now - cache.timestamp > USAGE_CACHE_RENDER_TTL_MS) return [];
232
+
233
+ return [
234
+ { label: '5h', snapPercent: cache.snapshot?.fiveHourPercent, window: cache.data?.five_hour },
235
+ { label: 'wk', snapPercent: cache.snapshot?.weekPercent, window: cache.data?.seven_day }
236
+ ].map(({ label, snapPercent, window }) => {
237
+ const percent = snapPercent != null ? snapPercent : normalizeUtilization(window?.utilization);
238
+ if (percent == null) return null;
239
+ let countdown = '';
240
+ if (window?.resets_at) {
241
+ const cd = formatCountdown(new Date(window.resets_at).getTime() - now);
242
+ if (cd) countdown = ` (${cd})`;
243
+ }
244
+ return `${label} ${percent}%${countdown}`;
245
+ }).filter(Boolean);
246
+ }
247
+
248
+ /**
249
+ * Join the quota windows into one segment string
250
+ * @returns {string|null} e.g. "5h 14% (2h21m) wk 43% (5d)", or null when there is nothing to show
174
251
  */
175
252
  function buildUsageString(ctx) {
176
- if (!ctx.sessionText || ctx.sessionText === 'N/A') return null;
177
- let str = ctx.sessionText.replace(' until reset', ' left');
178
- if (ctx.usagePercent != null) str += ` (${Math.round(ctx.usagePercent)}%)`;
179
- return str;
253
+ if (!Array.isArray(ctx.usageWindows) || ctx.usageWindows.length === 0) return null;
254
+ return ctx.usageWindows.join(' ');
255
+ }
256
+
257
+ /**
258
+ * Pick the quota segment color: red once any window is near its ceiling.
259
+ * @returns {(s: string) => string} Color function from the colors module
260
+ */
261
+ function getQuotaColor(usageWindows) {
262
+ // Match the percent token specifically — the label carries digits too ("5h 90%").
263
+ const percents = (usageWindows || [])
264
+ .map((windowText) => {
265
+ const match = String(windowText).match(/(\d+)%/);
266
+ return match ? Number(match[1]) : null;
267
+ })
268
+ .filter((percent) => Number.isFinite(percent));
269
+ return percents.some((n) => n >= QUOTA_HIGH_PERCENT) ? red : green;
180
270
  }
181
271
 
182
272
  /**
@@ -223,7 +313,7 @@ function renderSessionLines(ctx) {
223
313
  // Keep usage/reset info close to model/context for quick scanning.
224
314
  const usageStr = buildUsageString(ctx);
225
315
  if (usageStr) {
226
- sessionPart += ` ⌛ ${dim(usageStr.replace(/\)$/, ' used)'))}`;
316
+ sessionPart += ` ⌛ ${getQuotaColor(ctx.usageWindows)(usageStr)}`;
227
317
  }
228
318
 
229
319
  // Build stats part (only lines changed now)
@@ -469,39 +559,13 @@ async function main() {
469
559
  } catch {}
470
560
  }
471
561
 
472
- // Session timer - read actual reset time from usage limits cache
473
- let sessionText = '';
474
562
  const transcriptPath = data.transcript_path;
475
563
 
476
564
  // Parse transcript for tools/agents/todos
477
565
  const transcript = transcriptPath ? await parseTranscript(transcriptPath) : { tools: [], agents: [], todos: [], sessionStart: null };
478
566
 
479
- // Read actual reset time and utilization from usage limits cache (written by usage-quota-cache-refresh hook)
480
- let usagePercent = null;
481
- try {
482
- const usageCachePath = env.CK_USAGE_CACHE_PATH || path.join(os.tmpdir(), 'ck-usage-limits-cache.json');
483
- if (fs.existsSync(usageCachePath)) {
484
- const cache = JSON.parse(fs.readFileSync(usageCachePath, 'utf8'));
485
-
486
- // Check status flag for fallback (non-OAuth scenarios)
487
- if (cache.status === 'unavailable') {
488
- sessionText = 'N/A';
489
- } else {
490
- const fiveHour = cache.data?.five_hour;
491
- usagePercent = fiveHour?.utilization ?? null;
492
- const resetAt = fiveHour?.resets_at;
493
- if (resetAt) {
494
- const resetTime = new Date(resetAt);
495
- const remaining = Math.floor(resetTime.getTime() / 1000) - Math.floor(Date.now() / 1000);
496
- if (remaining > 0 && remaining < 18000) {
497
- const rh = Math.floor(remaining / 3600);
498
- const rm = Math.floor((remaining % 3600) / 60);
499
- sessionText = `${rh}h ${rm}m until reset`;
500
- }
501
- }
502
- }
503
- }
504
- } catch {}
567
+ // Usage quota windows from the cache written by usage-quota-cache-refresh hook
568
+ const usageWindows = buildUsageWindows(readUsageCache());
505
569
 
506
570
  // Lines changed
507
571
  const linesAdded = data.cost?.total_lines_added || 0;
@@ -517,8 +581,7 @@ async function main() {
517
581
  gitAhead,
518
582
  gitBehind,
519
583
  contextPercent,
520
- sessionText,
521
- usagePercent,
584
+ usageWindows,
522
585
  linesAdded,
523
586
  linesRemoved,
524
587
  transcript