fapony 0.3.3 → 0.3.5

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 (87) hide show
  1. package/README.md +7 -1
  2. package/fapony.ts +3 -116
  3. package/package.json +5 -6
  4. package/skill/move-to-done/SKILL.md +3 -2
  5. package/src/adapters/cli.ts +128 -0
  6. package/src/adapters/hooks/compute-hint-impact.ts +107 -0
  7. package/src/adapters/hooks/context-data.ts +102 -0
  8. package/src/adapters/hooks/edit-hint.ts +195 -0
  9. package/src/adapters/hooks/git-autonomy.ts +178 -0
  10. package/src/adapters/hooks/index.ts +80 -0
  11. package/src/adapters/hooks/mv-guard.ts +52 -0
  12. package/src/adapters/hooks/read-hint.ts +383 -0
  13. package/src/adapters/hooks/session-start.ts +101 -0
  14. package/src/adapters/hooks/stop.ts +434 -0
  15. package/src/{mcp → adapters/mcp}/evidence.ts +2 -2
  16. package/src/{mcp → adapters/mcp}/primitives.ts +2 -2
  17. package/src/{mcp → adapters/mcp}/tools/check.ts +1 -1
  18. package/src/{mcp → adapters/mcp}/tools/collect.ts +1 -1
  19. package/src/{mcp → adapters/mcp}/tools/mem.ts +3 -3
  20. package/src/{mcp → adapters/mcp}/tools/report.ts +4 -4
  21. package/src/adapters/mcp/types.ts +18 -0
  22. package/src/{mcp → adapters/mcp}/worktree.ts +1 -1
  23. package/src/analyze.ts +1 -1
  24. package/src/commands.ts +180 -0
  25. package/src/conventions-seed.ts +1 -1
  26. package/src/core/config.ts +199 -0
  27. package/src/core/debt-format.ts +107 -0
  28. package/src/core/debt-types.ts +79 -0
  29. package/src/core/defaults.ts +8 -0
  30. package/src/core/enums.ts +34 -0
  31. package/src/core/format.ts +33 -0
  32. package/src/core/hint-log.ts +68 -0
  33. package/src/core/hook-helpers.ts +31 -0
  34. package/src/core/mem-log.ts +357 -0
  35. package/src/core/parse.ts +71 -0
  36. package/src/core/pricing.ts +217 -0
  37. package/src/core/safety.ts +18 -0
  38. package/src/core/types.ts +142 -0
  39. package/src/core/util.ts +105 -0
  40. package/src/db/store.ts +2 -2
  41. package/src/debt/cli.ts +1 -1
  42. package/src/debt/format.ts +2 -107
  43. package/src/debt/load.ts +1 -1
  44. package/src/debt/promotion.ts +1 -1
  45. package/src/debt/types.ts +14 -79
  46. package/src/digest/collect.ts +4 -3
  47. package/src/gate.ts +2 -2
  48. package/src/gates.ts +1 -1
  49. package/src/hook.ts +70 -1424
  50. package/src/init-mem.ts +1 -1
  51. package/src/init.ts +1 -1
  52. package/src/install/claude.ts +17 -0
  53. package/src/install/opencode.ts +114 -0
  54. package/src/install.ts +12 -5
  55. package/src/lint-baseline.ts +1 -2
  56. package/src/map.ts +29 -8
  57. package/src/mem/commands/plan.ts +197 -42
  58. package/src/mem/commands/read.ts +53 -12
  59. package/src/mem/index.ts +60 -1
  60. package/src/mem/store.ts +5 -1
  61. package/src/memory.ts +26 -388
  62. package/src/parse.ts +9 -71
  63. package/src/price/fetch.ts +4 -16
  64. package/src/price/resolve.ts +12 -213
  65. package/src/report/cli.ts +3 -3
  66. package/src/safety.ts +2 -18
  67. package/src/seed/plan-seed.ts +126 -32
  68. package/src/seed/primitives.ts +1 -7
  69. package/src/session/types.ts +14 -128
  70. package/src/setup.ts +1 -1
  71. package/src/stats/data.ts +3 -3
  72. package/src/telemetry.ts +2 -2
  73. package/src/update.ts +1 -1
  74. package/src/usage/cache.ts +1 -2
  75. package/src/usage/cli.ts +1 -1
  76. package/src/usage/scan.ts +2 -1
  77. package/src/util.ts +10 -93
  78. package/src/web/html.ts +2 -33
  79. package/src/db/defaults.ts +0 -34
  80. package/src/db/getters.ts +0 -35
  81. package/src/db/index.ts +0 -7
  82. package/src/db/load.ts +0 -57
  83. package/src/db/types.ts +0 -77
  84. package/src/mcp/types.ts +0 -54
  85. package/src/test.ts +0 -2
  86. /package/src/{mcp → adapters/mcp}/tools/index.ts +0 -0
  87. /package/src/{mcp → adapters/mcp}/transport.ts +0 -0
package/src/debt/types.ts CHANGED
@@ -1,79 +1,14 @@
1
- // src/debt/types.ts — shared types + caps for `fapony debt`.
2
- //
3
- // One convention = pattern to use (ok) + pattern meaning not-yet-migrated
4
- // (stale) + scope (where) + file condition (guard). Iron rule: checker not
5
- // null = fapony never reports that debt item — reporting twice with eslint
6
- // is an abstraction with one implementation (rule 1).
7
-
8
- export interface Convention {
9
- id: string;
10
- rule: string;
11
- /** Repo-relative dir scope ("." = whole repo). */
12
- where: string;
13
- /** Regex source: a match means the file still has the debt. null = not derivable (checker rows) or not filled in yet. */
14
- stale: string | null;
15
- /** Regex source: files that already moved (informational count). */
16
- ok?: string;
17
- /** Regex source a file must ALSO match to be in scope (e.g. "extends Base"). */
18
- guard?: string;
19
- /** Non-null = a checker (eslint rule / script) exists → fapony never reports this debt. */
20
- checker?: string | null;
21
- /** Human answered "no checker" on the promotion question — never ask again. */
22
- decided?: "no-checker" | null;
23
- }
24
-
25
- export interface LoadedConventions {
26
- path: string | null;
27
- convs: Convention[];
28
- /** Rows kept for display but not scannable, plus invalid rows — said out loud, never silent. */
29
- warnings: string[];
30
- }
31
-
32
- export interface DebtEntry {
33
- conv: Convention;
34
- /** Files with the debt (stale match), sorted. */
35
- files: string[];
36
- /** Files that already moved (ok match) — null when ok is not set. */
37
- movedCount: number | null;
38
- }
39
-
40
- export interface DebtReport {
41
- worktree: string;
42
- scannedFiles: number;
43
- ms: number;
44
- /** Scannable conventions with their debt list (checker rows never land here). */
45
- entries: DebtEntry[];
46
- /** Declared but not fillable by fapony: checker null + no stale — the human/agent fills `stale`. */
47
- declared: Convention[];
48
- /** Skipped-with-reason: checker rows are silent by design (not dropped), these are real drops. */
49
- dropped: { id: string; reason: string }[];
50
- /** Silent-by-design count: checker non-null — reported as a number, not a list. */
51
- checkedCount: number;
52
- }
53
-
54
- export interface Promotion {
55
- convId: string;
56
- rule: string;
57
- occurrences: number;
58
- dates: string[];
59
- debtCount: number;
60
- }
61
-
62
- // A stale regex matching more than this many files is not a convention — it is
63
- // a broken/wide regex (stale="e" would flag the repo). SPEC §6: drop the entry
64
- // and say so, never report 600 files.
65
- export const DEBT_FILE_CAP = 250;
66
-
67
- export const PROMOTION_THRESHOLD = 3;
68
- export const PROMOTION_MAX = 3;
69
- /** Identifiers shorter than this are too generic to match prose on ("throw", "Error"). */
70
- export const WORD_MIN = 6;
71
-
72
- // Zone grouping: a zone is a file's *directory*, capped at this many leading
73
- // segments — never a fixed-depth prefix of the path (which would cut into the
74
- // filename) and never the filename itself. SPEC §4 shows zones at depth 5
75
- // (`apps/mdl/src/server/services`) and depth 3 (`packages/cache/src`) in the
76
- // same report, so the cap must follow the directory, not a constant.
77
- export const ZONE_DEPTH = 5;
78
- // Default cap on zones shown per convention — more than this is a wall, not an answer.
79
- export const ZONE_CAP = 6;
1
+ // shim — moved to src/core/debt-types.ts
2
+ export {
3
+ type Convention,
4
+ DEBT_FILE_CAP,
5
+ type DebtEntry,
6
+ type DebtReport,
7
+ type LoadedConventions,
8
+ PROMOTION_MAX,
9
+ PROMOTION_THRESHOLD,
10
+ type Promotion,
11
+ WORD_MIN,
12
+ ZONE_CAP,
13
+ ZONE_DEPTH,
14
+ } from "../core/debt-types.js";
@@ -10,11 +10,12 @@ import {
10
10
  doneDir,
11
11
  type Event,
12
12
  loadConfig,
13
- openDb,
14
13
  planDir,
15
14
  type Run,
16
- } from "../db/index.js";
17
- import { computeHintImpact, type HintImpact, hintLogPath } from "../hook.js";
15
+ } from "../core/config.js";
16
+ import { type HintImpact, hintLogPath } from "../core/hint-log.js";
17
+ import { openDb } from "../db/store.js";
18
+ import { computeHintImpact } from "../hook.js";
18
19
  import { type MemRow, readMemLog } from "../memory.js";
19
20
  import { isPassFamily, VERDICT_GRADES } from "../parse.js";
20
21
  import { imputeResult, loadPrices } from "../price/index.js";
package/src/gate.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  // gateOnce is the core review-verdict logic — still live, called by the CLI
2
2
  // wrapper (cmdGate) was removed with the rest of the execute→review→fix loop
3
3
  // (Wave 2). The MCP verdict_submit tool was removed in PLAN-verdict-to-mem.
4
+ import { loadConfig } from "./core/config.js";
4
5
  import {
5
6
  addEvent,
6
7
  getRun,
7
8
  incrementRound,
8
- loadConfig,
9
9
  openDb,
10
10
  setStatus,
11
- } from "./db/index.js";
11
+ } from "./db/store.js";
12
12
  import { closeMemory, kickoffMemory } from "./memory.js";
13
13
  import { isPassFamily, type VerdictGrade } from "./parse.js";
14
14
 
package/src/gates.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  // cumulative. Events arrive sorted (run_id, id), so one bucketing pass plus a
10
10
  // forward spawn pointer over the disjoint windows is O(events) total.
11
11
 
12
- import type { Event } from "./db/index.js";
12
+ import type { Event } from "./core/config.js";
13
13
  import { qualityScore, VERDICT_GRADES, type VerdictGrade } from "./parse.js";
14
14
  import {
15
15
  findSessionAt,