@forwardimpact/libwiki 0.2.20 → 0.2.21
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/package.json +1 -1
- package/src/audit/rules.js +2 -2
- package/src/commands/rotate.js +7 -1
- package/src/weekly-log.js +7 -0
package/package.json
CHANGED
package/src/audit/rules.js
CHANGED
|
@@ -254,7 +254,7 @@ export const RULES = [
|
|
|
254
254
|
remediation: "rotate",
|
|
255
255
|
check: lineBudget(WEEKLY_LOG_LINE_BUDGET),
|
|
256
256
|
message: (_s, r) => `${r.value} lines (limit ${WEEKLY_LOG_LINE_BUDGET})`,
|
|
257
|
-
hint: "run `bunx fit-wiki rotate
|
|
257
|
+
hint: "run `bunx fit-wiki rotate --agent <agent>` (agent = this filename's prefix) to seal this file as a sealed part and start a fresh weekly log",
|
|
258
258
|
},
|
|
259
259
|
{
|
|
260
260
|
id: "weekly-log.word-budget",
|
|
@@ -263,7 +263,7 @@ export const RULES = [
|
|
|
263
263
|
remediation: "rotate",
|
|
264
264
|
check: wordBudget(WEEKLY_LOG_WORD_BUDGET),
|
|
265
265
|
message: (_s, r) => `${r.value} words (limit ${WEEKLY_LOG_WORD_BUDGET})`,
|
|
266
|
-
hint: "run `bunx fit-wiki rotate
|
|
266
|
+
hint: "run `bunx fit-wiki rotate --agent <agent>` (agent = this filename's prefix) to seal this file as a sealed part and start a fresh weekly log",
|
|
267
267
|
},
|
|
268
268
|
{
|
|
269
269
|
id: "weekly-log.h1-agent-matches-filename",
|
package/src/commands/rotate.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { rotateIfOverBudget } from "../weekly-log.js";
|
|
1
|
+
import { rotateIfOverBudget, weeklyLogPath } from "../weekly-log.js";
|
|
2
2
|
import { currentDayIso } from "../util/clock.js";
|
|
3
3
|
import { resolveWikiRoot } from "../util/wiki-dir.js";
|
|
4
4
|
|
|
@@ -16,6 +16,12 @@ export function runRotateCommand(ctx) {
|
|
|
16
16
|
}
|
|
17
17
|
const wikiRoot = resolveWikiRoot(runtime, options);
|
|
18
18
|
const today = options.today || currentDayIso(runtime);
|
|
19
|
+
// Name the resolved target before any seal: the file follows from agent +
|
|
20
|
+
// current week, not from any audit finding, so an env-default agent can
|
|
21
|
+
// silently select a different file than the one the operator has in mind.
|
|
22
|
+
runtime.proc.stdout.write(
|
|
23
|
+
`target → ${weeklyLogPath(wikiRoot, agent, today)}\n`,
|
|
24
|
+
);
|
|
19
25
|
|
|
20
26
|
let result;
|
|
21
27
|
try {
|
package/src/weekly-log.js
CHANGED
|
@@ -281,6 +281,13 @@ export function rotateIfOverBudget(
|
|
|
281
281
|
const { force = false } = options;
|
|
282
282
|
if (!fs.existsSync(filePath)) return { status: "noop", fromPath: filePath };
|
|
283
283
|
const text = fs.readFileSync(filePath, "utf-8");
|
|
284
|
+
// A header-only (or empty) log has nothing to seal. Without this floor,
|
|
285
|
+
// force-rotating a freshly-reset main would mint an empty `(part 1 of 1)`
|
|
286
|
+
// file and reset the main again — once per invocation, forever.
|
|
287
|
+
const nl = text.indexOf("\n");
|
|
288
|
+
if ((nl === -1 ? "" : text.slice(nl + 1)).trim() === "") {
|
|
289
|
+
return { status: "noop", fromPath: filePath };
|
|
290
|
+
}
|
|
284
291
|
const current = countLines(text);
|
|
285
292
|
if (!force && current + appendLines <= WEEKLY_LOG_LINE_BUDGET) {
|
|
286
293
|
return { status: "noop", fromPath: filePath };
|