@devrik-tools/claude-gates 0.3.1 → 0.6.0
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/.claude-plugin/marketplace.json +2 -2
- package/README.es.md +25 -4
- package/README.md +75 -43
- package/cli/config.mjs +126 -124
- package/cli/index.mjs +154 -104
- package/cli/init.mjs +303 -276
- package/cli/install.mjs +281 -175
- package/cli/materialize.mjs +103 -102
- package/cli/registry.mjs +139 -136
- package/cli/smoke-fixtures.json +441 -0
- package/cli/smoke.mjs +129 -0
- package/cli/task.mjs +140 -140
- package/package.json +1 -1
- package/plugins/gates/.claude-plugin/plugin.json +1 -1
- package/plugins/gates/hooks/ask-adoption.mjs +147 -147
- package/plugins/gates/hooks/doctor.mjs +207 -207
- package/plugins/gates/hooks/gates/atomic-commit/index.mjs +229 -0
- package/plugins/gates/hooks/gates/audit-before-build/index.mjs +110 -88
- package/plugins/gates/hooks/gates/autonomous-mode/index.mjs +50 -50
- package/plugins/gates/hooks/gates/bash-commands/index.mjs +215 -215
- package/plugins/gates/hooks/gates/brief-before-delegate/index.mjs +269 -265
- package/plugins/gates/hooks/gates/capability-map/index.mjs +377 -0
- package/plugins/gates/hooks/gates/circuit-breaker/index.mjs +527 -501
- package/plugins/gates/hooks/gates/diagnosis-before-patch/index.mjs +48 -43
- package/plugins/gates/hooks/gates/feature-catalog/index.mjs +83 -83
- package/plugins/gates/hooks/gates/force-parallel/index.mjs +134 -119
- package/plugins/gates/hooks/gates/forge-flow/index.mjs +134 -134
- package/plugins/gates/hooks/gates/implementation-pipeline/index.mjs +187 -187
- package/plugins/gates/hooks/gates/intent-flow/index.mjs +260 -260
- package/plugins/gates/hooks/gates/lint-commit/index.mjs +152 -149
- package/plugins/gates/hooks/gates/mandatory-flow/index.mjs +180 -180
- package/plugins/gates/hooks/gates/never-assume/index.mjs +59 -58
- package/plugins/gates/hooks/gates/no-blocking/index.mjs +163 -148
- package/plugins/gates/hooks/gates/no-coauthor/index.mjs +127 -0
- package/plugins/gates/hooks/gates/no-lint-suppression/index.mjs +183 -0
- package/plugins/gates/hooks/gates/protected-paths/index.mjs +149 -144
- package/plugins/gates/hooks/gates/recurrence-lock/index.mjs +91 -89
- package/plugins/gates/hooks/gates/reuse-before-build/index.mjs +263 -159
- package/plugins/gates/hooks/gates/risk-level/index.mjs +265 -263
- package/plugins/gates/hooks/gates/root-cause-first/index.mjs +57 -56
- package/plugins/gates/hooks/gates/root-whitelist/index.mjs +211 -131
- package/plugins/gates/hooks/gates/rule-skill-autodiscovery/index.mjs +181 -184
- package/plugins/gates/hooks/gates/sdd-specs/index.mjs +256 -256
- package/plugins/gates/hooks/gates/staged-lint/index.mjs +187 -0
- package/plugins/gates/hooks/gates/stop-pending/index.mjs +169 -164
- package/plugins/gates/hooks/gates/test-matrix/index.mjs +187 -187
- package/plugins/gates/hooks/gates/tool-map/index.mjs +168 -143
- package/plugins/gates/hooks/hooks.json +51 -0
- package/plugins/gates/hooks/lib/config.mjs +179 -172
- package/plugins/gates/hooks/lib/hook-io.mjs +367 -357
- package/plugins/gates/hooks/lib/signals.mjs +172 -127
- package/plugins/gates/hooks/wiring-check.mjs +227 -227
- package/plugins/tasks/.claude-plugin/plugin.json +1 -1
- package/plugins/tasks/hooks/hooks.json +26 -26
- package/plugins/tasks/hooks/lib/task-store.mjs +217 -197
- package/plugins/tasks/hooks/register-requests.mjs +145 -145
- package/plugins/tasks/hooks/session-tasks.mjs +108 -108
- package/registry.json +171 -1
|
@@ -1,197 +1,217 @@
|
|
|
1
|
-
// The task store: the single source of truth for a project's tasks, on disk under
|
|
2
|
-
// .ai/tasks/. Self-contained (Node built-ins only) so a hook can use it when the plugin is
|
|
3
|
-
// installed on its own.
|
|
4
|
-
//
|
|
5
|
-
// justification: no existing tool covers this. Audited LOCAL deps (find-up, commander,
|
|
6
|
-
// @clack/prompts, zod — none is a task store), CONTEXT7 (generic JSON-store libs), and WEB
|
|
7
|
-
// (victor-software-house/task-tracker-plugin and Claude Code's native task manager both
|
|
8
|
-
// persist tasks and survive compaction, but neither distills tasks from chat, none is a
|
|
9
|
-
// zero-runtime-dependency library, and none fits the active/history + git-root shape here).
|
|
10
|
-
// The generic persistence is a solved pattern; this store is the thin, dependency-free,
|
|
11
|
-
// domain-specific piece the value layer (distil + remind + unlazy) sits on.
|
|
12
|
-
//
|
|
13
|
-
// Two files, mirroring the harness-sdd model:
|
|
14
|
-
// active.json { tasks: [ {id, title, description, status, size, createdAt, messages[]} ] }
|
|
15
|
-
// history.json { tasks: [ ...same shape + closedAt + closeReason ] } — append-only
|
|
16
|
-
// A task is never deleted: done and abandoned tasks MOVE from active to history, so the
|
|
17
|
-
// record of what was decided (and dropped) is never lost.
|
|
18
|
-
|
|
19
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
20
|
-
import { dirname, join } from 'node:path';
|
|
21
|
-
|
|
22
|
-
const TASKS_DIR = join('.ai', 'tasks');
|
|
23
|
-
const ACTIVE_FILE = 'active.json';
|
|
24
|
-
const HISTORY_FILE = 'history.json';
|
|
25
|
-
const COUNTER_FILE = 'counter.json';
|
|
26
|
-
const JSON_INDENT = 2;
|
|
27
|
-
// A project root holds `.git` or `.ai/` — the same set the CLI and the gates config use, so
|
|
28
|
-
// a repo-less project (no git yet) still resolves. Anchoring on `.git` alone drops it.
|
|
29
|
-
const PROJECT_ROOT_MARKERS = ['.git', '.ai'];
|
|
30
|
-
|
|
31
|
-
/** Statuses a task can hold. Active: open/blocked/in_forge. Terminal (history): done/abandoned. */
|
|
32
|
-
export const STATUS = Object.freeze({
|
|
33
|
-
OPEN: 'open',
|
|
34
|
-
BLOCKED: 'blocked',
|
|
35
|
-
IN_FORGE: 'in_forge', // promoted to a forge run for pipeline execution; still active
|
|
36
|
-
DONE: 'done',
|
|
37
|
-
ABANDONED: 'abandoned',
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const TERMINAL_STATUSES = new Set([STATUS.DONE, STATUS.ABANDONED]);
|
|
41
|
-
// A task closed as done must carry evidence it was actually attended and resolved — the
|
|
42
|
-
// project rule "ningún pedido se marca hecho sin evidencia válida" made mechanical. Abandoned
|
|
43
|
-
// needs only a reason (it is a deliberate drop, not a claim of completion), so it is exempt.
|
|
44
|
-
const STATUS_REQUIRING_EVIDENCE = new Set([STATUS.DONE]);
|
|
45
|
-
|
|
46
|
-
/** Climbs to the nearest project root (a dir holding `.git` or `.ai/`); null when none. */
|
|
47
|
-
export function projectRootOf(startDirectory) {
|
|
48
|
-
let current = startDirectory;
|
|
49
|
-
while (true) {
|
|
50
|
-
if (
|
|
51
|
-
PROJECT_ROOT_MARKERS.some((marker) => existsSync(join(current, marker)))
|
|
52
|
-
) {
|
|
53
|
-
return current;
|
|
54
|
-
}
|
|
55
|
-
const parent = dirname(current);
|
|
56
|
-
if (parent === current) return null;
|
|
57
|
-
current = parent;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Node's readFileSync('utf8') does not strip a leading UTF-8 BOM (EF BB BF, decoded as
|
|
62
|
-
// U+FEFF), and JSON.parse rejects a string starting with it. A file written by a BOM-adding
|
|
63
|
-
// editor or `PowerShell Set-Content -Encoding utf8` would otherwise silently read back as
|
|
64
|
-
// "corrupt" (caught below, treated as empty) — the same failure mode that made the gates'
|
|
65
|
-
// own config.mjs treat a valid project config as absent. Stripping it here is the fix.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return { tasks: [] };
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
*
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
);
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
|
|
1
|
+
// The task store: the single source of truth for a project's tasks, on disk under
|
|
2
|
+
// .ai/tasks/. Self-contained (Node built-ins only) so a hook can use it when the plugin is
|
|
3
|
+
// installed on its own.
|
|
4
|
+
//
|
|
5
|
+
// justification: no existing tool covers this. Audited LOCAL deps (find-up, commander,
|
|
6
|
+
// @clack/prompts, zod — none is a task store), CONTEXT7 (generic JSON-store libs), and WEB
|
|
7
|
+
// (victor-software-house/task-tracker-plugin and Claude Code's native task manager both
|
|
8
|
+
// persist tasks and survive compaction, but neither distills tasks from chat, none is a
|
|
9
|
+
// zero-runtime-dependency library, and none fits the active/history + git-root shape here).
|
|
10
|
+
// The generic persistence is a solved pattern; this store is the thin, dependency-free,
|
|
11
|
+
// domain-specific piece the value layer (distil + remind + unlazy) sits on.
|
|
12
|
+
//
|
|
13
|
+
// Two files, mirroring the harness-sdd model:
|
|
14
|
+
// active.json { tasks: [ {id, title, description, status, size, createdAt, messages[]} ] }
|
|
15
|
+
// history.json { tasks: [ ...same shape + closedAt + closeReason ] } — append-only
|
|
16
|
+
// A task is never deleted: done and abandoned tasks MOVE from active to history, so the
|
|
17
|
+
// record of what was decided (and dropped) is never lost.
|
|
18
|
+
|
|
19
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
20
|
+
import { dirname, join } from 'node:path';
|
|
21
|
+
|
|
22
|
+
const TASKS_DIR = join('.ai', 'tasks');
|
|
23
|
+
const ACTIVE_FILE = 'active.json';
|
|
24
|
+
const HISTORY_FILE = 'history.json';
|
|
25
|
+
const COUNTER_FILE = 'counter.json';
|
|
26
|
+
const JSON_INDENT = 2;
|
|
27
|
+
// A project root holds `.git` or `.ai/` — the same set the CLI and the gates config use, so
|
|
28
|
+
// a repo-less project (no git yet) still resolves. Anchoring on `.git` alone drops it.
|
|
29
|
+
const PROJECT_ROOT_MARKERS = ['.git', '.ai'];
|
|
30
|
+
|
|
31
|
+
/** Statuses a task can hold. Active: open/blocked/in_forge. Terminal (history): done/abandoned. */
|
|
32
|
+
export const STATUS = Object.freeze({
|
|
33
|
+
OPEN: 'open',
|
|
34
|
+
BLOCKED: 'blocked',
|
|
35
|
+
IN_FORGE: 'in_forge', // promoted to a forge run for pipeline execution; still active
|
|
36
|
+
DONE: 'done',
|
|
37
|
+
ABANDONED: 'abandoned',
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const TERMINAL_STATUSES = new Set([STATUS.DONE, STATUS.ABANDONED]);
|
|
41
|
+
// A task closed as done must carry evidence it was actually attended and resolved — the
|
|
42
|
+
// project rule "ningún pedido se marca hecho sin evidencia válida" made mechanical. Abandoned
|
|
43
|
+
// needs only a reason (it is a deliberate drop, not a claim of completion), so it is exempt.
|
|
44
|
+
const STATUS_REQUIRING_EVIDENCE = new Set([STATUS.DONE]);
|
|
45
|
+
|
|
46
|
+
/** Climbs to the nearest project root (a dir holding `.git` or `.ai/`); null when none. */
|
|
47
|
+
export function projectRootOf(startDirectory) {
|
|
48
|
+
let current = startDirectory;
|
|
49
|
+
while (true) {
|
|
50
|
+
if (
|
|
51
|
+
PROJECT_ROOT_MARKERS.some((marker) => existsSync(join(current, marker)))
|
|
52
|
+
) {
|
|
53
|
+
return current;
|
|
54
|
+
}
|
|
55
|
+
const parent = dirname(current);
|
|
56
|
+
if (parent === current) return null;
|
|
57
|
+
current = parent;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Node's readFileSync('utf8') does not strip a leading UTF-8 BOM (EF BB BF, decoded as
|
|
62
|
+
// U+FEFF), and JSON.parse rejects a string starting with it. A file written by a BOM-adding
|
|
63
|
+
// editor or `PowerShell Set-Content -Encoding utf8` would otherwise silently read back as
|
|
64
|
+
// "corrupt" (caught below, treated as empty) — the same failure mode that made the gates'
|
|
65
|
+
// own config.mjs treat a valid project config as absent. Stripping it here is the fix.
|
|
66
|
+
const BOM_CODE_POINT = 0xfeff;
|
|
67
|
+
|
|
68
|
+
function stripBom(text) {
|
|
69
|
+
return text.charCodeAt(0) === BOM_CODE_POINT ? text.slice(1) : text;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function readCollection(path) {
|
|
73
|
+
if (!existsSync(path)) return { tasks: [] };
|
|
74
|
+
try {
|
|
75
|
+
const parsed = JSON.parse(stripBom(readFileSync(path, 'utf8')));
|
|
76
|
+
return Array.isArray(parsed.tasks) ? parsed : { tasks: [] };
|
|
77
|
+
} catch {
|
|
78
|
+
return { tasks: [] };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function writeCollection(path, collection) {
|
|
83
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
84
|
+
writeFileSync(
|
|
85
|
+
path,
|
|
86
|
+
`${JSON.stringify(collection, null, JSON_INDENT)}\n`,
|
|
87
|
+
'utf8',
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Closes an active task: sets a terminal status + closedAt + closeReason, then MOVES it
|
|
93
|
+
* from active to history (append-only). Nothing is deleted. Returns { task } on success,
|
|
94
|
+
* or { error } describing why it was refused — so a caller can tell "not found" from
|
|
95
|
+
* "done without evidence" and surface the right message.
|
|
96
|
+
*
|
|
97
|
+
* Closing as `done` REQUIRES non-empty `evidence` (a command output, a test result, a
|
|
98
|
+
* diff, a verification note): a request is never marked resolved on a claim alone.
|
|
99
|
+
* `abandoned` needs only a reason.
|
|
100
|
+
*
|
|
101
|
+
* Extracted from the `openTaskStore` handle purely to keep that function's line count
|
|
102
|
+
* within the project's budget — same behavior, same order, just a named module function
|
|
103
|
+
* taking the two paths it needs instead of closing over them.
|
|
104
|
+
*/
|
|
105
|
+
function closeTask(
|
|
106
|
+
activePath,
|
|
107
|
+
historyPath,
|
|
108
|
+
id,
|
|
109
|
+
status,
|
|
110
|
+
{ reason, evidence } = {},
|
|
111
|
+
) {
|
|
112
|
+
if (!TERMINAL_STATUSES.has(status)) {
|
|
113
|
+
return { error: `invalid terminal status: ${status}` };
|
|
114
|
+
}
|
|
115
|
+
if (STATUS_REQUIRING_EVIDENCE.has(status) && !String(evidence ?? '').trim()) {
|
|
116
|
+
return {
|
|
117
|
+
error:
|
|
118
|
+
'closing a task as done requires evidence that it was attended and resolved ' +
|
|
119
|
+
'(test output, a diff, a verification note). Provide --evidence, or close it as ' +
|
|
120
|
+
'abandoned with a reason if it will not be finished.',
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const activeCollection = readCollection(activePath);
|
|
124
|
+
const index = activeCollection.tasks.findIndex((entry) => entry.id === id);
|
|
125
|
+
if (index === -1) return { error: `no active task with id ${id}` };
|
|
126
|
+
|
|
127
|
+
const [task] = activeCollection.tasks.splice(index, 1);
|
|
128
|
+
task.status = status;
|
|
129
|
+
task.closedAt = new Date().toISOString();
|
|
130
|
+
task.closeReason = reason ?? '';
|
|
131
|
+
if (STATUS_REQUIRING_EVIDENCE.has(status))
|
|
132
|
+
task.evidence = String(evidence).trim();
|
|
133
|
+
|
|
134
|
+
const historyCollection = readCollection(historyPath);
|
|
135
|
+
historyCollection.tasks.push(task);
|
|
136
|
+
|
|
137
|
+
writeCollection(historyPath, historyCollection);
|
|
138
|
+
writeCollection(activePath, activeCollection);
|
|
139
|
+
return { task };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Opens the store rooted at a project. All paths derive from the project root's .ai/tasks/.
|
|
144
|
+
* Returns a handle with read/mutate operations; each mutation persists immediately so a
|
|
145
|
+
* crash between calls never loses a recorded task. Null when there is no project (no .git).
|
|
146
|
+
*/
|
|
147
|
+
export function openTaskStore(startDirectory) {
|
|
148
|
+
const root = projectRootOf(startDirectory);
|
|
149
|
+
if (!root) return null;
|
|
150
|
+
|
|
151
|
+
const directory = join(root, TASKS_DIR);
|
|
152
|
+
const activePath = join(directory, ACTIVE_FILE);
|
|
153
|
+
const historyPath = join(directory, HISTORY_FILE);
|
|
154
|
+
const counterPath = join(directory, COUNTER_FILE);
|
|
155
|
+
|
|
156
|
+
return {
|
|
157
|
+
root,
|
|
158
|
+
/** Open (non-terminal) tasks. */
|
|
159
|
+
active() {
|
|
160
|
+
return readCollection(activePath).tasks;
|
|
161
|
+
},
|
|
162
|
+
/** Terminal (done/abandoned) tasks, newest last. */
|
|
163
|
+
history() {
|
|
164
|
+
return readCollection(historyPath).tasks;
|
|
165
|
+
},
|
|
166
|
+
/** Adds a task to active and returns it. `id` is caller-supplied (stable, human-readable). */
|
|
167
|
+
add(task) {
|
|
168
|
+
const collection = readCollection(activePath);
|
|
169
|
+
collection.tasks.push(task);
|
|
170
|
+
writeCollection(activePath, collection);
|
|
171
|
+
return task;
|
|
172
|
+
},
|
|
173
|
+
/** Merges fields into the active task with matching id. Null if not found. */
|
|
174
|
+
update(id, fields) {
|
|
175
|
+
const collection = readCollection(activePath);
|
|
176
|
+
const task = collection.tasks.find((entry) => entry.id === id);
|
|
177
|
+
if (!task) return null;
|
|
178
|
+
Object.assign(task, fields);
|
|
179
|
+
writeCollection(activePath, collection);
|
|
180
|
+
return task;
|
|
181
|
+
},
|
|
182
|
+
close(id, status, options) {
|
|
183
|
+
return closeTask(activePath, historyPath, id, status, options);
|
|
184
|
+
},
|
|
185
|
+
/**
|
|
186
|
+
* Promotes an active task to a forge run: records the run id and flips status to in_forge
|
|
187
|
+
* (still active — it is being executed, not closed). Whether a task is promoted is the
|
|
188
|
+
* assistant's judgment, not a rule; this only records the link. Null if id not found.
|
|
189
|
+
*/
|
|
190
|
+
promoteToForge(id, forgeRunId) {
|
|
191
|
+
return this.update(id, {
|
|
192
|
+
status: STATUS.IN_FORGE,
|
|
193
|
+
forgeRunId: String(forgeRunId),
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
/** The message counter since the last reminder (0 when unset or unreadable). */
|
|
197
|
+
counter() {
|
|
198
|
+
if (!existsSync(counterPath)) return 0;
|
|
199
|
+
try {
|
|
200
|
+
return (
|
|
201
|
+
JSON.parse(stripBom(readFileSync(counterPath, 'utf8'))).count ?? 0
|
|
202
|
+
);
|
|
203
|
+
} catch {
|
|
204
|
+
return 0;
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
/** Sets the message counter. */
|
|
208
|
+
setCounter(count) {
|
|
209
|
+
mkdirSync(directory, { recursive: true });
|
|
210
|
+
writeFileSync(
|
|
211
|
+
counterPath,
|
|
212
|
+
`${JSON.stringify({ count }, null, JSON_INDENT)}\n`,
|
|
213
|
+
'utf8',
|
|
214
|
+
);
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
}
|