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.
- package/README.md +144 -156
- package/package.json +5 -6
- package/skill/define-convention/SKILL.md +3 -3
- package/skill/lookup-before-edit/SKILL.md +2 -1
- package/skill/move-to-done/SKILL.md +18 -22
- package/skill/plan-with-pony/SKILL.md +4 -4
- package/skill/review-pony/SKILL.md +10 -12
- package/src/adapters/cli.ts +11 -52
- package/src/adapters/hooks/index.ts +0 -67
- package/src/adapters/hooks/mv-guard.ts +2 -2
- package/src/analyze/discover.ts +1 -1
- package/src/analyze/index.ts +0 -1
- package/src/commands.ts +8 -39
- package/src/core/config.ts +0 -8
- package/src/core/fapony-dir.ts +71 -0
- package/src/core/hook-helpers.ts +2 -11
- package/src/debt/load.ts +3 -5
- package/src/debt/promotion.ts +2 -2
- package/src/debt/scan.ts +1 -1
- package/src/digest/collect.ts +6 -7
- package/src/fael.ts +139 -0
- package/src/hook.ts +1 -81
- package/src/init.ts +30 -90
- package/src/install/antigravity.ts +8 -99
- package/src/install/claude.ts +66 -200
- package/src/install/codex.ts +6 -170
- package/src/install/detect.ts +4 -14
- package/src/install/opencode.ts +50 -486
- package/src/install/types.ts +1 -39
- package/src/install/zcode.ts +5 -91
- package/src/install.ts +9 -35
- package/src/memory.ts +10 -69
- package/src/plan/index.ts +34 -0
- package/src/plan/next.ts +181 -0
- package/src/plan/store.ts +41 -0
- package/src/{mem/commands/plan.ts → plan/sweep.ts} +66 -46
- package/src/seed/plan-seed.ts +10 -9
- package/src/setup.ts +4 -22
- package/src/update.ts +1 -1
- package/templates/PLAN.md +1 -1
- package/src/adapters/hooks/bug-markers.ts +0 -60
- package/src/adapters/hooks/context-data.ts +0 -211
- package/src/adapters/hooks/edit-hint.ts +0 -215
- package/src/adapters/hooks/read-hint.ts +0 -400
- package/src/adapters/hooks/session-start.ts +0 -112
- package/src/adapters/hooks/stop.ts +0 -768
- package/src/adapters/mcp/tools/index.ts +0 -149
- package/src/adapters/mcp/tools/mem.ts +0 -258
- package/src/adapters/mcp/transport.ts +0 -147
- package/src/analyze/cache.ts +0 -162
- package/src/core/mem-log.ts +0 -394
- package/src/init-mem.ts +0 -143
- package/src/install/cursor.ts +0 -167
- package/src/install/utils.ts +0 -29
- package/src/mem/commands/read.ts +0 -792
- package/src/mem/commands/rotate.ts +0 -59
- package/src/mem/commands/where.ts +0 -56
- package/src/mem/commands/write.ts +0 -284
- package/src/mem/engine.ts +0 -329
- package/src/mem/index.ts +0 -201
- package/src/mem/key-registry.ts +0 -116
- package/src/mem/render.ts +0 -66
- package/src/mem/selectors.ts +0 -227
- 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
|
-
}
|