@houserules/payload 0.1.1 → 0.2.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@houserules/payload",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "houserules: shared payload libraries, copied into .claude/scripts/lib and executed on bare node with zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"command": "tsc -p tsconfig.payload.json && publint",
|
|
22
22
|
"files": [
|
|
23
23
|
"payload/**",
|
|
24
|
-
"!payload/**/
|
|
24
|
+
"!payload/**/__tests__/**",
|
|
25
25
|
"tsconfig.payload.json"
|
|
26
26
|
],
|
|
27
27
|
"output": [
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
],
|
|
36
36
|
"files": [
|
|
37
37
|
"payload/**/*.mts",
|
|
38
|
-
"payload/**/
|
|
38
|
+
"payload/**/__tests__/**/*.ts",
|
|
39
39
|
"tsconfig.json",
|
|
40
40
|
"tsconfig.payload.json"
|
|
41
41
|
],
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"typescript": "^6.0.3",
|
|
78
78
|
"vitest": "^4.1.10",
|
|
79
79
|
"wireit": "^0.14.13",
|
|
80
|
-
"@houserules/test": "0.1.
|
|
80
|
+
"@houserules/test": "0.1.1"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"build": "wireit",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LedgerKind } from './ledger-index.mjs';
|
|
1
2
|
export declare const SEPARATOR = "---";
|
|
2
3
|
export declare const nowIso: () => string;
|
|
3
4
|
export declare const todayDate: () => string;
|
|
@@ -39,10 +40,28 @@ export declare function ledgerPath(repoRoot: string, name: string, configuredDir
|
|
|
39
40
|
* produces and a decision never does, since superseding leaves the entry rendered.
|
|
40
41
|
*/
|
|
41
42
|
export declare function rebuildWouldDropEntries(file: string, nextContent: string, intentionallyDropped?: ReadonlySet<string>): boolean;
|
|
43
|
+
/** The local enable token a projects sync bootstrap writes into the ledger directory. */
|
|
44
|
+
export declare const PROJECTS_ENABLE_TOKEN = ".projects.json";
|
|
45
|
+
/**
|
|
46
|
+
* Whether the pulled index, rather than the queue, is the store this ledger's surfaces render
|
|
47
|
+
* from.
|
|
48
|
+
*
|
|
49
|
+
* Without a projects sync the queue is the only durable copy of an entry, so a surface holding
|
|
50
|
+
* entries the queue cannot account for means the queue was truncated and rewriting would
|
|
51
|
+
* destroy them. With a sync configured the model inverts: the queue jsonl drains to zero after
|
|
52
|
+
* a successful push, and the board is the durable store, pulled into the index. A fully synced
|
|
53
|
+
* repo therefore sits at zero queued entries with a rendered surface, which the queue
|
|
54
|
+
* comparison reads as corruption and refuses forever.
|
|
55
|
+
*
|
|
56
|
+
* The index has to be on disk for this. A repo that enabled the sync but has never pulled
|
|
57
|
+
* knows nothing about the board, so the queue comparison is still the only safe one there.
|
|
58
|
+
*/
|
|
59
|
+
export declare function indexIsAuthoritative(ledgerDirectory: string, kind: LedgerKind): boolean;
|
|
42
60
|
export declare function readSurface(file: string): string;
|
|
43
61
|
/** Reads the body from the argument, or from stdin when it was omitted and stdin is a pipe. */
|
|
44
62
|
export declare function readContentArg(content: string | undefined): string;
|
|
45
63
|
export declare function relativeToRoot(repoRoot: string, p: string): string;
|
|
64
|
+
export declare const DEFAULT_LEDGER_DIR = ".claude/ledgers";
|
|
46
65
|
/**
|
|
47
66
|
* The ledger directory, from `ledgers.dir` or the default.
|
|
48
67
|
*
|
|
@@ -3,6 +3,7 @@ import { appendFileSync, closeSync, existsSync, fstatSync, openSync, readFileSyn
|
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { dirname, relative, resolve } from 'node:path';
|
|
5
5
|
import { ENTRY_HEAD } from './backlog-id.mjs';
|
|
6
|
+
import { loadIndex } from './ledger-index.mjs';
|
|
6
7
|
export const SEPARATOR = '---';
|
|
7
8
|
const TRANSCRIPT_TAIL_BYTES = 16384;
|
|
8
9
|
const METADATA_LINE = /^\*\*([A-Za-z][A-Za-z ]*):\*\*\s+(.+)$/;
|
|
@@ -185,6 +186,27 @@ export function rebuildWouldDropEntries(file, nextContent, intentionallyDropped
|
|
|
185
186
|
const after = new Set(parseEntries(nextContent).map((e) => e.id));
|
|
186
187
|
return before.some((e) => !after.has(e.id) && !intentionallyDropped.has(e.id));
|
|
187
188
|
}
|
|
189
|
+
/** The local enable token a projects sync bootstrap writes into the ledger directory. */
|
|
190
|
+
export const PROJECTS_ENABLE_TOKEN = '.projects.json';
|
|
191
|
+
/**
|
|
192
|
+
* Whether the pulled index, rather than the queue, is the store this ledger's surfaces render
|
|
193
|
+
* from.
|
|
194
|
+
*
|
|
195
|
+
* Without a projects sync the queue is the only durable copy of an entry, so a surface holding
|
|
196
|
+
* entries the queue cannot account for means the queue was truncated and rewriting would
|
|
197
|
+
* destroy them. With a sync configured the model inverts: the queue jsonl drains to zero after
|
|
198
|
+
* a successful push, and the board is the durable store, pulled into the index. A fully synced
|
|
199
|
+
* repo therefore sits at zero queued entries with a rendered surface, which the queue
|
|
200
|
+
* comparison reads as corruption and refuses forever.
|
|
201
|
+
*
|
|
202
|
+
* The index has to be on disk for this. A repo that enabled the sync but has never pulled
|
|
203
|
+
* knows nothing about the board, so the queue comparison is still the only safe one there.
|
|
204
|
+
*/
|
|
205
|
+
export function indexIsAuthoritative(ledgerDirectory, kind) {
|
|
206
|
+
if (!existsSync(resolve(ledgerDirectory, PROJECTS_ENABLE_TOKEN)))
|
|
207
|
+
return false;
|
|
208
|
+
return loadIndex(ledgerDirectory, kind) !== null;
|
|
209
|
+
}
|
|
188
210
|
export function readSurface(file) {
|
|
189
211
|
return existsSync(file) ? readFileSync(file, 'utf8') : '';
|
|
190
212
|
}
|
|
@@ -199,7 +221,7 @@ export function readContentArg(content) {
|
|
|
199
221
|
export function relativeToRoot(repoRoot, p) {
|
|
200
222
|
return relative(repoRoot, resolve(p));
|
|
201
223
|
}
|
|
202
|
-
const DEFAULT_LEDGER_DIR = '.claude/ledgers';
|
|
224
|
+
export const DEFAULT_LEDGER_DIR = '.claude/ledgers';
|
|
203
225
|
/**
|
|
204
226
|
* The ledger directory, from `ledgers.dir` or the default.
|
|
205
227
|
*
|
|
@@ -17,7 +17,7 @@ export declare function readJson<T = PackageJson>(path: string): T | null;
|
|
|
17
17
|
* Extracts the `packages:` list from pnpm-workspace.yaml. Hand-rolled on purpose: the
|
|
18
18
|
* payload ships into user repos and runs on bare node, so it cannot import a YAML
|
|
19
19
|
* library. This is not a YAML parser. It reads one key in the shapes real workspace files
|
|
20
|
-
* use, and never throws. `
|
|
20
|
+
* use, and never throws. `__tests__/workspaces.test.ts` pins that contract case by case.
|
|
21
21
|
*
|
|
22
22
|
* Sibling top-level blocks such as `catalog:` and `catalogMode:` must not confuse it, so
|
|
23
23
|
* only lines inside the packages block are read and the block ends at the next
|
|
@@ -49,7 +49,7 @@ function splitFlow(inner) {
|
|
|
49
49
|
* Extracts the `packages:` list from pnpm-workspace.yaml. Hand-rolled on purpose: the
|
|
50
50
|
* payload ships into user repos and runs on bare node, so it cannot import a YAML
|
|
51
51
|
* library. This is not a YAML parser. It reads one key in the shapes real workspace files
|
|
52
|
-
* use, and never throws. `
|
|
52
|
+
* use, and never throws. `__tests__/workspaces.test.ts` pins that contract case by case.
|
|
53
53
|
*
|
|
54
54
|
* Sibling top-level blocks such as `catalog:` and `catalogMode:` must not confuse it, so
|
|
55
55
|
* only lines inside the packages block are read and the block ends at the next
|