fapony 0.1.1 → 0.1.3
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 +22 -36
- package/images/logo.png +0 -0
- package/images/logo.webp +0 -0
- package/images/logo@400.webp +0 -0
- package/images/sample.webp +0 -0
- package/images/summary.webp +0 -0
- package/package.json +10 -8
- package/skill/plan-with-pony/SKILL.md +1 -1
- package/src/analyze.ts +9 -8
- package/src/conventions-seed.ts +10 -10
- package/src/db/index.ts +1 -1
- package/src/db/store.ts +4 -0
- package/src/debt.ts +26 -22
- package/src/digest/collect.ts +7 -7
- package/src/digest/html.ts +2 -2
- package/src/digest/text.ts +1 -1
- package/src/gate.ts +3 -3
- package/src/hook.ts +119 -21
- package/src/init-mem.ts +3 -3
- package/src/install/opencode.ts +95 -8
- package/src/install/types.ts +1 -1
- package/src/install.ts +5 -1
- package/src/lint-baseline.ts +9 -9
- package/src/mcp/tools/mem.ts +1 -1
- package/src/mcp/tools/stats.ts +2 -2
- package/src/mcp/tools/usage.ts +3 -3
- package/src/mcp/tools/verdict.ts +29 -16
- package/src/mcp/transport.ts +1 -1
- package/src/plan-seed.ts +23 -21
- package/src/price/fetch.ts +19 -19
- package/src/price/resolve.ts +24 -24
- package/src/review-seed.ts +1 -1
- package/src/stats/data.ts +8 -7
- package/src/stats/format.ts +6 -5
- package/src/usage/render.ts +6 -5
- package/templates/PLAN.md +1 -1
- package/templates/mem/commands/plan.ts +44 -44
- package/templates/mem/commands/read.ts +5 -5
- package/templates/mem/commands/rotate.ts +6 -6
- package/templates/mem/commands/selftest.ts +14 -14
- package/templates/mem/commands/write.ts +13 -13
- package/templates/mem/mem.ts +5 -5
- package/templates/mem/selectors.ts +18 -18
- package/templates/mem/store.ts +50 -50
package/templates/mem/store.ts
CHANGED
|
@@ -60,43 +60,43 @@ type LogRow = WorkRow | CloseRow | ClaimRow | ReleaseRow | SyncedRow;
|
|
|
60
60
|
const root = Bun.spawnSync(["git", "rev-parse", "--show-toplevel"])
|
|
61
61
|
.stdout.toString()
|
|
62
62
|
.trim();
|
|
63
|
-
// ponytail: worktree
|
|
64
|
-
// fapony template: repo
|
|
65
|
-
//
|
|
63
|
+
// ponytail: worktree named wt-<app> = monorepo scope (apps/<app>/.fapony/.memory).
|
|
64
|
+
// fapony template: single repo (no apps/) → fallback straight to .fapony/.memory at root
|
|
65
|
+
// no config/flag needed for either shape
|
|
66
66
|
const app = process.env.MEM_APP ?? basename(root).replace(/^wt-/, "");
|
|
67
|
-
//
|
|
68
|
-
// apps → packages → services
|
|
69
|
-
//
|
|
67
|
+
// app container folder found from {apps,packages,services}/<app>, first that exists — fixed order
|
|
68
|
+
// apps → packages → services, first hit wins (the order is the contract, not an accident)
|
|
69
|
+
// the `unknown app` guard below is still tied to apps/ as before — not widened this round
|
|
70
70
|
const appBase: string | undefined = ["apps", "packages", "services"]
|
|
71
71
|
.map((d) => `${root}/${d}/${app}`)
|
|
72
72
|
.find((p) => existsSync(p));
|
|
73
73
|
const monorepo = appBase !== undefined;
|
|
74
74
|
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
// app —
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
// .fapony/.memory
|
|
83
|
-
//
|
|
75
|
+
// The copy `fapony init` places lives in <project>/.fapony/.memory/ — its log and plan
|
|
76
|
+
// must key off their own folder, not the git root: the real broken case is apps/<x>/.fapony/.memory/ in a monorepo,
|
|
77
|
+
// where the heuristic below would point at apps/<worktree name>/.fapony/.memory = writing a log mixed into another project.
|
|
78
|
+
// But the central copy that was moved into .fapony/.memory at the monorepo root itself (single code copy, logs split per
|
|
79
|
+
// app — e.g. vela) must "not" count as scaffolded even though the path matches, because it still has to guess the app
|
|
80
|
+
// from the monorepo — the discriminator is "can the app be guessed" (`monorepo`), not "is there an app container folder":
|
|
81
|
+
// just having apps/ at the root does not make this copy the central one — `fapony init <monorepo root>` also places
|
|
82
|
+
// .fapony/.memory at the root, and it must key off its own folder, or it dies at the guard below
|
|
83
|
+
// from the very first command even though its plan sits right next to it.
|
|
84
84
|
const centralAtMonorepoRoot =
|
|
85
85
|
import.meta.dir === `${root}/.fapony/.memory` && monorepo;
|
|
86
86
|
const scaffolded =
|
|
87
87
|
import.meta.dir.includes("/.fapony/.memory") && !centralAtMonorepoRoot;
|
|
88
88
|
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
// (
|
|
89
|
+
// apps/ exists but apps/<app> does not = guessed the app wrong (worktree name mismatch / typo in MEM_APP) — die here
|
|
90
|
+
// rather than fall back silently and write a log at the root that becomes an orphan nobody reads
|
|
91
|
+
// (a copy scaffolded under apps/<x>/.fapony/.memory/ keys off its own folder, needs no guess, so it does not hit this)
|
|
92
92
|
if (!scaffolded && !monorepo && existsSync(`${root}/apps`)) {
|
|
93
93
|
console.error(
|
|
94
94
|
`unknown app (guessed "${app}" from ${basename(root)}) — pass MEM_APP=<app>`,
|
|
95
95
|
);
|
|
96
96
|
process.exit(1);
|
|
97
97
|
}
|
|
98
|
-
// default
|
|
99
|
-
//
|
|
98
|
+
// new default: log lives under .fapony/.memory — fall back to the old .memory/ only when an old log actually exists
|
|
99
|
+
// check for log.jsonl, not the dir: an empty folder someone accidentally mkdir'd must not lock the repo to the old layout
|
|
100
100
|
const newDir = appBase
|
|
101
101
|
? `${appBase}/.fapony/.memory`
|
|
102
102
|
: `${root}/.fapony/.memory`;
|
|
@@ -106,12 +106,12 @@ const dir = scaffolded
|
|
|
106
106
|
: existsSync(`${legacyDir}/log.jsonl`)
|
|
107
107
|
? legacyDir
|
|
108
108
|
: newDir;
|
|
109
|
-
//
|
|
109
|
+
// who wrote this row — the client can override with MEM_AGENT ("claude-code", "opencode")
|
|
110
110
|
const agent = process.env.MEM_AGENT || process.env.USER || "unknown";
|
|
111
111
|
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
// git user.name
|
|
112
|
+
// filename = *person*, not client, deliberately different from agent above: naming files by MEM_AGENT
|
|
113
|
+
// would put two people running Claude Code back into the same log.claude-code.jsonl = same collision as before
|
|
114
|
+
// git user.name exists on every machine that can commit, so no env to set and no config to add
|
|
115
115
|
const person = (
|
|
116
116
|
Bun.spawnSync(["git", "config", "user.name"]).stdout.toString().trim() ||
|
|
117
117
|
process.env.USER ||
|
|
@@ -121,12 +121,12 @@ const person = (
|
|
|
121
121
|
.replace(/[^a-z0-9._-]+/g, "-")
|
|
122
122
|
.replace(/^-+|-+$/g, "");
|
|
123
123
|
|
|
124
|
-
//
|
|
125
|
-
//
|
|
124
|
+
// write your own file, read everyone's — two people never touch the same file = merge conflicts
|
|
125
|
+
// are structurally zero, no need for merge=union or GitHub behaving itself on PR merge
|
|
126
126
|
const LOG = `${dir}/log.${person || "unknown"}.jsonl`;
|
|
127
127
|
|
|
128
|
-
// log.jsonl =
|
|
129
|
-
//
|
|
128
|
+
// log.jsonl = the pre-split original (still read forever, no migration needed)
|
|
129
|
+
// skip the log.YYYY-MM-DD.jsonl that rotate creates, or rotate reduces nothing because they get read back in
|
|
130
130
|
const isLogFile = (f: string): boolean =>
|
|
131
131
|
f === "log.jsonl" ||
|
|
132
132
|
(/^log\.[A-Za-z0-9._-]+\.jsonl$/.test(f) &&
|
|
@@ -140,17 +140,17 @@ const logFiles = (): string[] =>
|
|
|
140
140
|
.map((f) => join(dir, f))
|
|
141
141
|
: [];
|
|
142
142
|
|
|
143
|
-
//
|
|
144
|
-
// (
|
|
143
|
+
// the folder this project's plan/ and done/ live under — the single place these paths are assembled
|
|
144
|
+
// (previously commands/plan.ts hardcoded `apps/<app>/plan` in 10 places = dead on arrival for a single repo)
|
|
145
145
|
const planBase = scaffolded
|
|
146
146
|
? dirname(import.meta.dir) // <project>/.fapony
|
|
147
147
|
: (appBase ?? root);
|
|
148
148
|
|
|
149
|
-
// fapony.config.json
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
//
|
|
153
|
-
// monorepo
|
|
149
|
+
// fapony.config.json is the *agreement* on where plan lives; planBase above is only a guess —
|
|
150
|
+
// whenever the file exists it must beat the guess (vela declares `apps/vela/plan` outright, which happens to match the guess
|
|
151
|
+
// but a repo that puts plan elsewhere breaks silently if this is not read)
|
|
152
|
+
// read only at the project level: a copy scaffolded in apps/<x>/.fapony/ must not pick up the root
|
|
153
|
+
// monorepo's config, because that is another project's path
|
|
154
154
|
const configDir = scaffolded ? dirname(planBase) : root;
|
|
155
155
|
|
|
156
156
|
const configPaths = ((): Record<string, string> => {
|
|
@@ -158,7 +158,7 @@ const configPaths = ((): Record<string, string> => {
|
|
|
158
158
|
const raw = readFileSync(`${configDir}/fapony.config.json`, "utf8");
|
|
159
159
|
return (JSON.parse(raw)?.paths ?? {}) as Record<string, string>;
|
|
160
160
|
} catch {
|
|
161
|
-
//
|
|
161
|
+
// no file / broken JSON → use the guessed values, not an error: memory must work without fapony
|
|
162
162
|
return {};
|
|
163
163
|
}
|
|
164
164
|
})();
|
|
@@ -168,27 +168,27 @@ const fromConfig = (key: string): string | null =>
|
|
|
168
168
|
? join(configDir, configPaths[key])
|
|
169
169
|
: null;
|
|
170
170
|
|
|
171
|
-
// app
|
|
172
|
-
//
|
|
171
|
+
// an app that moved plan into .fapony/ uses the new location; one that has not uses the old — so a monorepo migrates app by app
|
|
172
|
+
// without touching config (config has a single planDir, so declaring it points the other apps wrong too)
|
|
173
173
|
const base = existsSync(`${planBase}/.fapony`)
|
|
174
174
|
? `${planBase}/.fapony`
|
|
175
175
|
: planBase;
|
|
176
176
|
|
|
177
177
|
const planDir = fromConfig("planDir") ?? `${base}/plan`;
|
|
178
178
|
|
|
179
|
-
// done/
|
|
180
|
-
//
|
|
179
|
+
// done/ sits beside plan/ (same depth after the move, relative links in files survive) — a repo still on the old layout
|
|
180
|
+
// with plan/done/ keeps using it, no need to move before sweeping
|
|
181
181
|
const doneDir =
|
|
182
182
|
fromConfig("doneDir") ??
|
|
183
183
|
(!existsSync(`${base}/done`) && existsSync(`${planDir}/done`)
|
|
184
184
|
? `${planDir}/done`
|
|
185
185
|
: `${base}/done`);
|
|
186
186
|
|
|
187
|
-
// path
|
|
187
|
+
// path used for display/logging — always relative to repo root (`apps/vela/plan`, `.fapony/plan`)
|
|
188
188
|
const rel = (p: string) => relative(root, p) || ".";
|
|
189
189
|
|
|
190
|
-
//
|
|
191
|
-
//
|
|
190
|
+
// the command we tell the user to type must be the path of the mem.ts actually running, not a constant —
|
|
191
|
+
// the copy `fapony init` places lives in .fapony/.memory/, not the .memory/ the old help text hardcoded
|
|
192
192
|
const memCmd = `bun ${rel(dir)}/mem.ts`;
|
|
193
193
|
|
|
194
194
|
const KINDS: WorkKind[] = ["next", "bug", "decision", "note", "hold"];
|
|
@@ -205,7 +205,7 @@ const rows = (): LogRow[] =>
|
|
|
205
205
|
try {
|
|
206
206
|
return [JSON.parse(l) as LogRow];
|
|
207
207
|
} catch {
|
|
208
|
-
// ponytail:
|
|
208
|
+
// ponytail: one broken line (bad escape) must not make the whole log unreadable — skip it and warn
|
|
209
209
|
console.error(
|
|
210
210
|
`[mem] skipped ${basename(f)} line ${i + 1} (bad JSON)`,
|
|
211
211
|
);
|
|
@@ -213,7 +213,7 @@ const rows = (): LogRow[] =>
|
|
|
213
213
|
}
|
|
214
214
|
}),
|
|
215
215
|
)
|
|
216
|
-
//
|
|
216
|
+
// concatenating several files scrambles the time order — every selector reads top-down assuming ts order
|
|
217
217
|
.sort((a, b) => a.ts.localeCompare(b.ts));
|
|
218
218
|
|
|
219
219
|
function put(r: Omit<WorkRow, "ts" | "agent">): void;
|
|
@@ -236,9 +236,9 @@ function put(
|
|
|
236
236
|
);
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
// ponytail:
|
|
240
|
-
//
|
|
241
|
-
//
|
|
239
|
+
// ponytail: prevent id collisions — base36 + increment per retry + random suffix
|
|
240
|
+
// shared everywhere a WorkRow.id must be generated (cmdAdd, ship-log in cmdPlanSweep)
|
|
241
|
+
// do not copy this loop elsewhere — change the scheme here only
|
|
242
242
|
function nextId(all: LogRow[]): string {
|
|
243
243
|
const used = new Set(all.map((r) => ("id" in r ? r.id : "")));
|
|
244
244
|
let base = Date.now();
|
|
@@ -250,8 +250,8 @@ function nextId(all: LogRow[]): string {
|
|
|
250
250
|
return id;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
//
|
|
254
|
-
//
|
|
253
|
+
// write a raw row (original ts/agent, no regeneration) — used when rotate moves old rows to a new file
|
|
254
|
+
// normally writing to the log must go through put(); this is the only exception
|
|
255
255
|
const appendRaw = (path: string, r: LogRow): void =>
|
|
256
256
|
appendFileSync(path, `${JSON.stringify(r)}\n`);
|
|
257
257
|
|