@esneiderbravo/speclaw 2.0.11 → 2.0.13

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 (43) hide show
  1. package/README.md +5 -1
  2. package/dist/cli/commands/cortex.js +3 -2
  3. package/dist/cli/commands/lawbook.js +7 -3
  4. package/dist/cli/commands/laws.js +10 -2
  5. package/dist/cli/commands/query.js +2 -2
  6. package/dist/cli/commands/ship-on-stop.js +46 -0
  7. package/dist/cli/commands/ship.js +44 -0
  8. package/dist/cli/commands/update.js +25 -0
  9. package/dist/cli/index.js +8 -3
  10. package/dist/cli/lib/args.js +35 -5
  11. package/dist/cli/lib/help.js +36 -4
  12. package/dist/modules/compass/db.js +47 -9
  13. package/dist/modules/compass/explore-rich.js +50 -9
  14. package/dist/modules/compass/extract.js +220 -0
  15. package/dist/modules/compass/find-output.js +172 -0
  16. package/dist/modules/compass/hybrid.js +149 -21
  17. package/dist/modules/compass/indexer.js +26 -2
  18. package/dist/modules/compass/query.js +48 -12
  19. package/dist/modules/compass/register.js +13 -7
  20. package/dist/modules/cortex/harness.js +17 -4
  21. package/dist/modules/cortex/status.js +1 -1
  22. package/dist/modules/foundation/assets/AGENTS.template.md +10 -9
  23. package/dist/modules/foundation/assets/CLAUDE.template.md +13 -10
  24. package/dist/modules/foundation/assets/docs/compass.template.md +11 -4
  25. package/dist/modules/foundation/deps.js +5 -3
  26. package/dist/modules/foundation/doctor.js +1 -1
  27. package/dist/modules/foundation/graph.js +5 -5
  28. package/dist/modules/foundation/hooks.js +30 -4
  29. package/dist/modules/foundation/integrity.js +11 -3
  30. package/dist/modules/foundation/laws.js +5 -0
  31. package/dist/modules/lawbook/assets/commands/cortex.md +1 -1
  32. package/dist/modules/lawbook/assets/rules/spec-reports-disciplines.md +6 -0
  33. package/dist/modules/lawbook/assets/rules/spec-tasks-mandatory-steps.md +6 -0
  34. package/dist/modules/lawbook/assets/skills/cortex/SKILL.md +17 -5
  35. package/dist/modules/lawbook/bugfix.js +12 -4
  36. package/dist/modules/lawbook/change-tool.js +7 -0
  37. package/dist/modules/lawbook/engine.js +3 -0
  38. package/dist/modules/lawbook/levels.js +35 -4
  39. package/dist/modules/lawbook/quick.js +17 -6
  40. package/dist/modules/lawbook/ship.js +325 -0
  41. package/dist/shared/mcp.js +6 -4
  42. package/dist/shared/output-budget.js +36 -12
  43. package/package.json +1 -1
@@ -3,26 +3,43 @@ export const OUTPUT_BUDGET = {
3
3
  brief: 1500,
4
4
  full: 4500,
5
5
  };
6
+ /** Brief-mode suffix: the caller can still widen the response with `mode:"full"`. */
6
7
  const TRUNCATION_SUFFIX = `\n… [truncated — use mode:"full" or narrow includes]`;
8
+ /** Suffix under the full ceiling or an explicit cap: widening the mode would not help. */
9
+ const FINAL_TRUNCATION_SUFFIX = `\n… [truncated — narrow includes or the query]`;
7
10
  /** Stable offline token estimate for budgeting (not a real tokenizer). */
8
11
  export function estimateTokens(text) {
9
12
  return Math.ceil(text.length / 4);
10
13
  }
11
14
  /**
12
- * Trim `text` to fit `mode` budget; returns the possibly shortened text and
13
- * whether truncation occurred.
15
+ * Token ceiling of a {@link TextBudget}.
16
+ *
17
+ * @param budget - Output mode or explicit cap.
18
+ */
19
+ export function budgetTokens(budget) {
20
+ return typeof budget === "string" ? OUTPUT_BUDGET[budget] : Math.max(1, budget.maxTokens);
21
+ }
22
+ /**
23
+ * Trim `text` to fit `budget`; returns the possibly shortened text and whether
24
+ * truncation occurred. Under `brief` the suffix suggests `mode:"full"`; under
25
+ * `full` or an explicit cap it never does, since that would not widen anything.
26
+ *
27
+ * @param text - Text to budget.
28
+ * @param budget - Output mode (`brief` default) or `{ maxTokens }`.
14
29
  */
15
- export function applyTextBudget(text, mode = "brief") {
16
- const budget = OUTPUT_BUDGET[mode];
30
+ // Covers: req~find-response-budget~1
31
+ export function applyTextBudget(text, budget = "brief") {
32
+ const cap = budgetTokens(budget);
17
33
  const tokens = estimateTokens(text);
18
- if (tokens <= budget)
34
+ if (tokens <= cap)
19
35
  return { text, truncated: false, omittedChars: 0 };
20
- const suffixTokens = estimateTokens(TRUNCATION_SUFFIX);
21
- const bodyBudget = Math.max(1, budget - suffixTokens);
36
+ const suffix = budget === "brief" ? TRUNCATION_SUFFIX : FINAL_TRUNCATION_SUFFIX;
37
+ const suffixTokens = estimateTokens(suffix);
38
+ const bodyBudget = Math.max(1, cap - suffixTokens);
22
39
  const maxChars = bodyBudget * 4;
23
40
  const trimmed = text.slice(0, maxChars);
24
41
  return {
25
- text: trimmed + TRUNCATION_SUFFIX,
42
+ text: trimmed + suffix,
26
43
  truncated: true,
27
44
  omittedChars: text.length - maxChars,
28
45
  };
@@ -37,8 +54,11 @@ export function applyTextBudget(text, mode = "brief") {
37
54
  * @param truncated - Collector for explicit truncation records.
38
55
  */
39
56
  export function budgetExploreShape(value, mode, truncated) {
40
- const maxCallers = mode === "full" ? 40 : 12;
41
- const maxSourceLines = mode === "full" ? 120 : 40;
57
+ // Full mode sizes source to the full-mode token ceiling (~4500 tokens), so a
58
+ // typical long function arrives whole; its hints cannot point at mode:"full".
59
+ const full = mode === "full";
60
+ const maxCallers = full ? 40 : 12;
61
+ const maxSourceLines = full ? 400 : 40;
42
62
  const symbol = value.symbol;
43
63
  if (symbol && typeof symbol.source === "string") {
44
64
  const lines = symbol.source.split("\n");
@@ -48,7 +68,9 @@ export function budgetExploreShape(value, mode, truncated) {
48
68
  truncated.push({
49
69
  field: "symbol.source",
50
70
  omitted,
51
- hint: 'use mode:"full" or omit source from include',
71
+ hint: full
72
+ ? "read the remaining lines from the file by startLine/endLine"
73
+ : 'use mode:"full" or omit source from include',
52
74
  });
53
75
  }
54
76
  }
@@ -63,7 +85,9 @@ export function budgetExploreShape(value, mode, truncated) {
63
85
  truncated.push({
64
86
  field,
65
87
  omitted,
66
- hint: 'use mode:"full" or narrow with include',
88
+ hint: full
89
+ ? "use compass_impact for the full list"
90
+ : 'use mode:"full" or narrow with include',
67
91
  });
68
92
  }
69
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esneiderbravo/speclaw",
3
- "version": "2.0.11",
3
+ "version": "2.0.13",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },