fapony 0.7.0 → 0.7.1

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 (64) hide show
  1. package/README.md +144 -156
  2. package/package.json +5 -6
  3. package/skill/define-convention/SKILL.md +3 -3
  4. package/skill/lookup-before-edit/SKILL.md +2 -1
  5. package/skill/move-to-done/SKILL.md +18 -22
  6. package/skill/plan-with-pony/SKILL.md +4 -4
  7. package/skill/review-pony/SKILL.md +10 -12
  8. package/src/adapters/cli.ts +11 -52
  9. package/src/adapters/hooks/index.ts +0 -67
  10. package/src/adapters/hooks/mv-guard.ts +2 -2
  11. package/src/analyze/discover.ts +1 -1
  12. package/src/analyze/index.ts +0 -1
  13. package/src/commands.ts +8 -39
  14. package/src/core/config.ts +0 -8
  15. package/src/core/fapony-dir.ts +71 -0
  16. package/src/core/hook-helpers.ts +2 -11
  17. package/src/debt/load.ts +3 -5
  18. package/src/debt/promotion.ts +2 -2
  19. package/src/debt/scan.ts +1 -1
  20. package/src/digest/collect.ts +6 -7
  21. package/src/fael.ts +139 -0
  22. package/src/hook.ts +1 -81
  23. package/src/init.ts +30 -90
  24. package/src/install/antigravity.ts +8 -99
  25. package/src/install/claude.ts +66 -200
  26. package/src/install/codex.ts +6 -170
  27. package/src/install/detect.ts +4 -14
  28. package/src/install/opencode.ts +50 -486
  29. package/src/install/types.ts +1 -39
  30. package/src/install/zcode.ts +5 -91
  31. package/src/install.ts +9 -35
  32. package/src/memory.ts +10 -69
  33. package/src/plan/index.ts +34 -0
  34. package/src/plan/next.ts +181 -0
  35. package/src/plan/store.ts +41 -0
  36. package/src/{mem/commands/plan.ts → plan/sweep.ts} +66 -46
  37. package/src/seed/plan-seed.ts +10 -9
  38. package/src/setup.ts +4 -22
  39. package/src/update.ts +1 -1
  40. package/templates/PLAN.md +1 -1
  41. package/src/adapters/hooks/bug-markers.ts +0 -60
  42. package/src/adapters/hooks/context-data.ts +0 -211
  43. package/src/adapters/hooks/edit-hint.ts +0 -215
  44. package/src/adapters/hooks/read-hint.ts +0 -400
  45. package/src/adapters/hooks/session-start.ts +0 -112
  46. package/src/adapters/hooks/stop.ts +0 -768
  47. package/src/adapters/mcp/tools/index.ts +0 -149
  48. package/src/adapters/mcp/tools/mem.ts +0 -258
  49. package/src/adapters/mcp/transport.ts +0 -147
  50. package/src/analyze/cache.ts +0 -162
  51. package/src/core/mem-log.ts +0 -394
  52. package/src/init-mem.ts +0 -143
  53. package/src/install/cursor.ts +0 -167
  54. package/src/install/utils.ts +0 -29
  55. package/src/mem/commands/read.ts +0 -792
  56. package/src/mem/commands/rotate.ts +0 -59
  57. package/src/mem/commands/where.ts +0 -56
  58. package/src/mem/commands/write.ts +0 -284
  59. package/src/mem/engine.ts +0 -329
  60. package/src/mem/index.ts +0 -201
  61. package/src/mem/key-registry.ts +0 -116
  62. package/src/mem/render.ts +0 -66
  63. package/src/mem/selectors.ts +0 -227
  64. package/src/mem/store.ts +0 -356
@@ -1,112 +0,0 @@
1
- // src/adapters/hooks/session-start.ts — SessionStart hook: emit mem kickoff
2
- // as context.
3
- //
4
- // Split from src/hook.ts (PLAN-lib-layer chunk 3). sessionStartContext is the
5
- // one copy shared by Claude/Codex CLI and the generated OpenCode plugin.
6
-
7
- import { whereMemDir } from "../../memory.js";
8
-
9
- /** Cap on injected context — kickoff is short, a broken repo's output is not. */
10
- export const SESSION_START_MAX_CHARS = 4_000;
11
-
12
- const TRUNCATED = "… truncated — run `fapony mem find <word>` for the rest";
13
-
14
- /** Trim to whole lines, keeping the marker's line boundary intact. */
15
- function headLines(text: string, max: number): string {
16
- const cut = text.slice(0, max);
17
- const lastNl = cut.lastIndexOf("\n");
18
- return (lastNl > 0 ? cut.slice(0, lastNl) : cut).trimEnd();
19
- }
20
-
21
- /**
22
- * Trim to whole lines within the cap, with an honest truncation marker.
23
- *
24
- * Kickoff's ordering is: ranked rows → "## next up" → "## recent". The
25
- * most actionable content is at the top (bugs, diff-matched) and in "## next
26
- * up". A plain head-cut drops the suggestions — so we try to keep "## next up"
27
- * visible. When "## recent" exists, we cut it first; otherwise fall back to
28
- * keeping "## next up" at the tail.
29
- */
30
- export function capContext(
31
- text: string,
32
- max = SESSION_START_MAX_CHARS,
33
- ): string {
34
- if (text.length <= max) return text;
35
- const recentIdx = text.indexOf("\n## recent");
36
- if (recentIdx > 0) {
37
- const head = text.slice(0, recentIdx).trimEnd();
38
- if (head.length <= max) return head;
39
- const nextIdx = head.lastIndexOf("\n## next up");
40
- if (nextIdx > 0) {
41
- const beforeNext = head.slice(0, nextIdx).trimEnd();
42
- const nextTail = head.slice(nextIdx).trimEnd();
43
- if (nextTail.length < max / 2) {
44
- return `${headLines(beforeNext, max - nextTail.length)}\n${TRUNCATED}\n${nextTail}`;
45
- }
46
- }
47
- return `${headLines(head, max)}\n${TRUNCATED}`;
48
- }
49
- const at = text.lastIndexOf("\n## next up");
50
- const tail = at > 0 ? text.slice(at).trimEnd() : "";
51
- if (tail && tail.length < max / 2) {
52
- return `${headLines(text, max - tail.length)}\n${TRUNCATED}\n${tail}`;
53
- }
54
- return `${headLines(text, max)}\n${TRUNCATED}`;
55
- }
56
-
57
- /**
58
- * Kickoff output for `cwd`'s mem log, capped — or null when there is no log in
59
- * scope, the command fails, or it prints nothing. The single implementation
60
- * behind both cmdHookSessionStart (Claude/Codex) and the generated OpenCode
61
- * plugin, so a pull of INSTALL_ROOT updates all three.
62
- *
63
- * `faponyTs` is where the CLI lives. The hook defaults to `Bun.main` (itself,
64
- * when run as `bun <root>/fapony.ts hook-session-start`); the OpenCode plugin
65
- * must pass its baked path because `Bun.main` inside OpenCode is OpenCode's own
66
- * entry, not fapony's.
67
- */
68
- export function sessionStartContext(
69
- cwd: string,
70
- faponyTs: string = Bun.main,
71
- ): string | null {
72
- // Resolution shares one function with every reader. A bare monorepo root has
73
- // no log at/above cwd, so the resolver reports the app-scoped log only as an
74
- // out-of-scope candidate (SPEC §1). For a *read* at session start that is
75
- // still recoverable: if the whole repo holds exactly one log, it is the
76
- // project's memory — point kickoff at it with --mem-dir. Two or more is
77
- // genuinely ambiguous (which app?), so refuse exactly as the resolver does.
78
- const resolved = whereMemDir(cwd);
79
- const memArgs: string[] = [];
80
- if (!resolved.dir) {
81
- const candidates = resolved.candidates ?? [];
82
- if (candidates.length !== 1) return null;
83
- memArgs.push("--mem-dir", candidates[0]);
84
- }
85
- const p = Bun.spawnSync(
86
- [process.execPath, faponyTs, "mem", ...memArgs, "kickoff"],
87
- { cwd, stdout: "pipe", stderr: "pipe" },
88
- );
89
- const out = p.stdout.toString().trim();
90
- if (p.exitCode !== 0 || !out) return null;
91
- return capContext(out);
92
- }
93
-
94
- /** SessionStart hook: emit sessionStartContext as Claude/Codex JSON. */
95
- export async function cmdHookSessionStart(): Promise<void> {
96
- try {
97
- const raw = JSON.parse(await Bun.stdin.text()) as { cwd?: string };
98
- const cwd = raw.cwd ?? process.cwd();
99
- const ctx = sessionStartContext(cwd);
100
- if (!ctx) return;
101
- console.log(
102
- JSON.stringify({
103
- hookSpecificOutput: {
104
- hookEventName: "SessionStart",
105
- additionalContext: ctx,
106
- },
107
- }),
108
- );
109
- } catch {
110
- // any failure = no context, never a broken session start
111
- }
112
- }