@venizia/vulcan 0.4.9-0 → 0.4.9-2
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/base/extensions/vulcan-guards.ts +48 -41
- package/base/hooks/antigravity-guards.ts +2 -2
- package/base/hooks/codex-guards.ts +15 -5
- package/base/hooks/guard-git.ts +8 -8
- package/base/hooks/guard-manifest.ts +4 -5
- package/base/hooks/guard-outside.ts +8 -8
- package/base/hooks/guard-package.ts +5 -6
- package/base/hooks/guard-remote-hosts.ts +6 -7
- package/base/hooks/guard-scripting.ts +5 -6
- package/base/hooks/guard-writes.ts +8 -9
- package/base/hooks/post-tool.ts +2 -2
- package/base/hooks/prompt-submit.ts +2 -2
- package/base/hooks/session-start.ts +3 -3
- package/base/hooks/stop.ts +2 -2
- package/base/hooks/subagent-start.ts +2 -2
- package/base/skills/docs-update/SKILL.md +4 -2
- package/base/skills/visualize-work/SKILL.md +9 -0
- package/package.json +3 -3
- package/src/agents/atlas-block.ts +43 -43
- package/src/agents/codex-hooks.ts +45 -43
- package/src/agents/detect.ts +19 -16
- package/src/agents/exclude.ts +96 -97
- package/src/agents/hooks-json.ts +38 -36
- package/src/agents/local.ts +46 -43
- package/src/agents/prompt.ts +45 -42
- package/src/agents/render.ts +201 -195
- package/src/agents/resolve.ts +133 -134
- package/src/agents/table.ts +12 -8
- package/src/commands/add.command.ts +2 -2
- package/src/commands/agents.command.ts +11 -17
- package/src/commands/clean.command.ts +6 -6
- package/src/commands/doctor.command.ts +4 -4
- package/src/commands/init.command.ts +12 -8
- package/src/commands/preset.command.ts +2 -2
- package/src/commands/profile.command.ts +42 -49
- package/src/commands/sync.command.ts +109 -111
- package/src/commands/upgrade.command.ts +80 -75
- package/src/commands/visualize.command.ts +7 -13
- package/src/commands/x.command.ts +55 -50
- package/src/common/format.ts +23 -21
- package/src/common/json.ts +8 -5
- package/src/common/layout-folder.ts +94 -91
- package/src/common/paths.ts +14 -12
- package/src/config/loader.ts +52 -49
- package/src/config/packages.ts +14 -11
- package/src/config/schema.ts +3 -3
- package/src/create/add-app.ts +519 -509
- package/src/create/add-lib.ts +237 -240
- package/src/create/bunfig.ts +26 -23
- package/src/create/checks.ts +36 -34
- package/src/create/diff.ts +21 -23
- package/src/create/dockerignore.ts +26 -24
- package/src/create/files.ts +7 -5
- package/src/create/init-monorepo.ts +75 -80
- package/src/create/lib-preset.ts +59 -63
- package/src/create/manifest-json.ts +10 -4
- package/src/create/names.ts +217 -210
- package/src/create/next.ts +26 -23
- package/src/create/plan.ts +15 -12
- package/src/create/preset-diff.ts +301 -303
- package/src/create/preset-menu.ts +38 -32
- package/src/create/preset.ts +202 -197
- package/src/create/process.ts +79 -72
- package/src/create/scratch.ts +48 -49
- package/src/create/workspace.ts +404 -396
- package/src/doctor/checks.ts +1027 -1014
- package/src/doctor/makefile.ts +17 -13
- package/src/doctor/runner.ts +88 -118
- package/src/doctor/skills.ts +97 -95
- package/src/doctor/tags.ts +42 -37
- package/src/hooks/codex-patch.ts +25 -22
- package/src/hooks/command-view.ts +44 -39
- package/src/hooks/decision.ts +37 -37
- package/src/hooks/guard-git.ts +51 -49
- package/src/hooks/guard-manifest.ts +58 -55
- package/src/hooks/guard-outside.ts +93 -91
- package/src/hooks/guard-package.ts +82 -79
- package/src/hooks/guard-scripting.ts +19 -14
- package/src/hooks/guard-writes.ts +154 -149
- package/src/hooks/owner-reply.ts +127 -127
- package/src/hooks/post-tool.ts +94 -93
- package/src/hooks/project-guards.ts +65 -62
- package/src/hooks/project-tmp.ts +27 -24
- package/src/hooks/remote-hosts.ts +153 -130
- package/src/hooks/session-digest.ts +98 -101
- package/src/hooks/shell.ts +509 -499
- package/src/hooks/subagent-card.ts +11 -7
- package/src/hooks/trusted-scripts.ts +106 -104
- package/src/init/scaffold.ts +135 -132
- package/src/local/clean.ts +38 -36
- package/src/local/format.ts +21 -17
- package/src/local/scan.ts +144 -138
- package/src/manifest/render.ts +110 -104
- package/src/owner/card.ts +51 -46
- package/src/owner/profile.ts +99 -93
- package/src/owner/reply-switch.ts +9 -6
- package/src/owner/shape.ts +71 -69
- package/src/owner/survey.ts +173 -171
- package/src/owner/view.ts +62 -59
- package/src/owner/violations.ts +119 -123
- package/src/rules/base.ts +15 -11
- package/src/rules/parser.ts +39 -32
- package/src/rules/slots.ts +8 -6
- package/src/signals/claims.ts +30 -28
- package/src/signals/classify.ts +38 -33
- package/src/signals/loop.ts +39 -37
- package/src/signals/state.ts +79 -81
- package/src/skills/frontmatter.ts +28 -28
- package/src/sync/agent-files.ts +217 -199
- package/src/sync/agent-removal.ts +56 -59
- package/src/sync/atlas-block.ts +45 -43
- package/src/sync/base-rules.ts +32 -30
- package/src/sync/claude-launch.ts +36 -34
- package/src/sync/exclude.ts +77 -69
- package/src/sync/local-choice.ts +50 -47
- package/src/sync/planner.ts +59 -61
- package/src/sync/prune.ts +52 -48
- package/src/sync/settings.ts +166 -167
- package/src/ui/capability.ts +12 -7
- package/src/ui/keyboard.ts +38 -38
- package/src/ui/prompt.ts +79 -77
- package/src/visualize/assets.ts +33 -24
- package/src/visualize/charts.ts +179 -176
- package/src/visualize/compare-css.ts +3 -2
- package/src/visualize/compare-render.ts +9 -7
- package/src/visualize/diagrams.ts +189 -174
- package/src/visualize/grid-span.ts +34 -0
- package/src/visualize/icons.ts +7 -5
- package/src/visualize/kinds-render.ts +50 -45
- package/src/visualize/kinds-validate.ts +12 -10
- package/src/visualize/labels.ts +21 -17
- package/src/visualize/layout.ts +112 -97
- package/src/visualize/page.ts +92 -104
- package/src/visualize/render.ts +143 -140
- package/src/visualize/sections.ts +395 -384
- package/src/visualize/sources.ts +2 -2
- package/src/visualize/theme.ts +12 -10
- package/src/visualize/validate.ts +13 -9
- package/src/wiki/anchors.ts +38 -36
- package/src/wiki/command.ts +4 -4
- package/src/wiki/source-links.ts +46 -44
package/src/owner/view.ts
CHANGED
|
@@ -25,68 +25,71 @@ export interface IOwnerView {
|
|
|
25
25
|
codeTaste: string | undefined;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
/** Whether a language code is English, whatever its region (`en`, `en-GB`). */
|
|
29
|
-
export const isEnglishLanguage = (opts: { language: string }): boolean =>
|
|
30
|
-
opts.language.split('-')[0]?.toLowerCase() === OwnerConstants.DEFAULT_LANGUAGE;
|
|
31
|
-
|
|
32
28
|
const sameLabelSet = (opts: { first: TOwnerLabelSet; second: TOwnerLabelSet }): boolean =>
|
|
33
29
|
JSON.stringify(opts.first) === JSON.stringify(opts.second);
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
export class OwnerView {
|
|
32
|
+
/** Whether a language code is English, whatever its region (`en`, `en-GB`). */
|
|
33
|
+
static isEnglishLanguage(opts: { language: string }): boolean {
|
|
34
|
+
return opts.language.split('-')[0]?.toLowerCase() === OwnerConstants.DEFAULT_LANGUAGE;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The stricter of two enforcement levels. */
|
|
38
|
+
static stricterEnforcement(opts: { first: string; second: string | undefined }): string {
|
|
39
|
+
const order: readonly string[] = OwnerEnforcement.STRICTNESS;
|
|
40
|
+
const second = opts.second ?? opts.first;
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
}
|
|
42
|
+
return order.indexOf(second) > order.indexOf(opts.first) ? second : opts.first;
|
|
43
|
+
}
|
|
45
44
|
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Language, address, tone, detail and habits come from the person's profile; the shape, status set and
|
|
47
|
+
* label defaults from the project block, which a profile may not change; `enforce` is the stricter of
|
|
48
|
+
* the two. A language with no label set of its own gets the English words and, unless it is English,
|
|
49
|
+
* the `free` label mode: the agent writes the labels in the reader's language and the check looks at the
|
|
50
|
+
* structure, never at another language's words.
|
|
51
|
+
*/
|
|
52
|
+
static resolve(opts: { owner: TOwnerConfig; profile?: TProfile }): IOwnerView {
|
|
53
|
+
const { owner, profile } = opts;
|
|
54
|
+
const language = profile?.language ?? owner.language;
|
|
55
|
+
const projectLabels: TOwnerLabelSet = {
|
|
56
|
+
minimapColumns: owner.report.minimapColumns,
|
|
57
|
+
status: owner.report.status,
|
|
58
|
+
labels: owner.report.labels,
|
|
59
|
+
};
|
|
60
|
+
const own =
|
|
61
|
+
profile !== undefined && Object.hasOwn(profile.labels, language)
|
|
62
|
+
? profile.labels[language]
|
|
63
|
+
: undefined;
|
|
64
|
+
const chosen = own ?? (language === owner.language ? projectLabels : undefined);
|
|
65
|
+
const labels = chosen ?? OwnerConstants.DEFAULT_LABELS;
|
|
66
|
+
const isFree =
|
|
67
|
+
!OwnerView.isEnglishLanguage({ language }) &&
|
|
68
|
+
(chosen === undefined ||
|
|
69
|
+
sameLabelSet({ first: chosen, second: OwnerConstants.DEFAULT_LABELS }));
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
71
|
+
return {
|
|
72
|
+
language,
|
|
73
|
+
labels,
|
|
74
|
+
labelMode: isFree ? OwnerLabelModes.FREE : OwnerLabelModes.EXACT,
|
|
75
|
+
shape: owner.report.shape,
|
|
76
|
+
headlineMaxSentences: owner.report.headlineMaxSentences,
|
|
77
|
+
absolutePaths: owner.report.absolutePaths,
|
|
78
|
+
enforce: OwnerView.stricterEnforcement({
|
|
79
|
+
first: owner.report.enforce,
|
|
80
|
+
second: profile?.enforce,
|
|
81
|
+
}),
|
|
82
|
+
claimWords: owner.report.claimWords,
|
|
83
|
+
shortReplyWords: Math.min(
|
|
84
|
+
owner.report.shortReplyWords,
|
|
85
|
+
profile?.shortReplyWords ?? owner.report.shortReplyWords,
|
|
86
|
+
),
|
|
87
|
+
address: profile?.address,
|
|
88
|
+
tone: profile?.tone,
|
|
89
|
+
reportDetail: profile?.reportDetail,
|
|
90
|
+
habits: profile?.habits,
|
|
91
|
+
about: profile?.about,
|
|
92
|
+
codeTaste: profile?.codeTaste,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
package/src/owner/violations.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
writeFileSync,
|
|
10
10
|
} from 'node:fs';
|
|
11
11
|
import { join } from 'node:path';
|
|
12
|
-
import {
|
|
12
|
+
import { LocalScan } from '../local/scan.ts';
|
|
13
13
|
import { ClaimClasses } from '../signals/constants.ts';
|
|
14
14
|
import { ShapeClasses } from './shape.ts';
|
|
15
15
|
|
|
@@ -37,7 +37,7 @@ export class ViolationConstants {
|
|
|
37
37
|
|
|
38
38
|
/** `.agents/local/<file>` of a trusted project, or `undefined`; a symlinked file is never followed. */
|
|
39
39
|
const fileOf = (opts: { root: string; name: string }): string | undefined => {
|
|
40
|
-
const local = localRootOf({ root: opts.root });
|
|
40
|
+
const local = LocalScan.localRootOf({ root: opts.root });
|
|
41
41
|
|
|
42
42
|
if (local === undefined) {
|
|
43
43
|
return undefined;
|
|
@@ -76,7 +76,7 @@ const noteName = (opts: { session?: string }): string => {
|
|
|
76
76
|
* a directory. Created only when `opts.create` is set.
|
|
77
77
|
*/
|
|
78
78
|
const notesDirectoryOf = (opts: { root: string; create: boolean }): string | undefined => {
|
|
79
|
-
const local = localRootOf({ root: opts.root });
|
|
79
|
+
const local = LocalScan.localRootOf({ root: opts.root });
|
|
80
80
|
|
|
81
81
|
if (local === undefined) {
|
|
82
82
|
return undefined;
|
|
@@ -154,7 +154,7 @@ const readNote = (opts: { root: string; session?: string }): Record<string, unkn
|
|
|
154
154
|
*/
|
|
155
155
|
const pruneNotes = (opts: { root: string; now: number }): void => {
|
|
156
156
|
const directory = notesDirectoryOf({ root: opts.root, create: false });
|
|
157
|
-
const local = localRootOf({ root: opts.root });
|
|
157
|
+
const local = LocalScan.localRootOf({ root: opts.root });
|
|
158
158
|
|
|
159
159
|
if (local !== undefined) {
|
|
160
160
|
const legacy = join(local, ViolationConstants.LEGACY_LAST_FILE);
|
|
@@ -196,155 +196,151 @@ const isOversized = (opts: { path: string }): boolean => {
|
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
198
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
199
|
+
export class ViolationLog {
|
|
200
|
+
/** Records one checked reply: the log when it broke the shape, and always the session's last-reply note. */
|
|
201
|
+
static recordReply(opts: {
|
|
202
|
+
root: string;
|
|
203
|
+
classes: string[];
|
|
204
|
+
session?: string;
|
|
205
|
+
now?: Date;
|
|
206
|
+
}): void {
|
|
207
|
+
const now = opts.now ?? new Date();
|
|
208
|
+
const log = fileOf({ root: opts.root, name: ViolationConstants.LOG_FILE });
|
|
209
|
+
|
|
210
|
+
if (log !== undefined && opts.classes.length > 0 && !isOversized({ path: log })) {
|
|
211
|
+
appendFileSync(
|
|
212
|
+
log,
|
|
213
|
+
`${JSON.stringify({ date: now.toISOString().slice(0, 10), classes: opts.classes })}\n`,
|
|
214
|
+
{ mode: 0o600 },
|
|
215
|
+
);
|
|
216
|
+
}
|
|
216
217
|
|
|
217
|
-
|
|
218
|
+
const last = noteFileOf({ root: opts.root, session: opts.session, create: true });
|
|
218
219
|
|
|
219
|
-
|
|
220
|
-
|
|
220
|
+
if (last !== undefined) {
|
|
221
|
+
const { blockedAt } = readNote({ root: opts.root, session: opts.session });
|
|
221
222
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
223
|
+
writeFileSync(
|
|
224
|
+
last,
|
|
225
|
+
`${JSON.stringify({ at: now.getTime(), classes: opts.classes, ...(typeof blockedAt === 'number' ? { blockedAt } : {}) })}\n`,
|
|
226
|
+
{ mode: 0o600 },
|
|
227
|
+
);
|
|
228
|
+
pruneNotes({ root: opts.root, now: Date.now() });
|
|
229
|
+
}
|
|
228
230
|
}
|
|
229
|
-
};
|
|
230
231
|
|
|
231
|
-
/** Notes that a reply of this session was just sent back, so a second one is never sent back right after it. */
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
/** Notes that a reply of this session was just sent back, so a second one is never sent back right after it. */
|
|
233
|
+
static markBlocked(opts: { root: string; session?: string; now?: Date }): void {
|
|
234
|
+
const last = noteFileOf({ root: opts.root, session: opts.session, create: true });
|
|
234
235
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
236
|
+
if (last !== undefined) {
|
|
237
|
+
writeFileSync(
|
|
238
|
+
last,
|
|
239
|
+
`${JSON.stringify({ ...readNote({ root: opts.root, session: opts.session }), blockedAt: (opts.now ?? new Date()).getTime() })}\n`,
|
|
240
|
+
{ mode: 0o600 },
|
|
241
|
+
);
|
|
242
|
+
}
|
|
241
243
|
}
|
|
242
|
-
};
|
|
243
244
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
session?: string;
|
|
247
|
-
now?: number;
|
|
248
|
-
}): boolean => {
|
|
249
|
-
const { blockedAt } = readNote({ root: opts.root, session: opts.session });
|
|
250
|
-
|
|
251
|
-
return (
|
|
252
|
-
typeof blockedAt === 'number' &&
|
|
253
|
-
(opts.now ?? Date.now()) - blockedAt <= ViolationConstants.BLOCK_COOLDOWN_MS
|
|
254
|
-
);
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
/** The size of the violation log in bytes, 0 when there is none or it is not ours to read. */
|
|
258
|
-
export const violationLogBytes = (opts: { root: string }): number => {
|
|
259
|
-
const log = fileOf({ root: opts.root, name: ViolationConstants.LOG_FILE });
|
|
245
|
+
static wasBlockedRecently(opts: { root: string; session?: string; now?: number }): boolean {
|
|
246
|
+
const { blockedAt } = readNote({ root: opts.root, session: opts.session });
|
|
260
247
|
|
|
261
|
-
|
|
262
|
-
|
|
248
|
+
return (
|
|
249
|
+
typeof blockedAt === 'number' &&
|
|
250
|
+
(opts.now ?? Date.now()) - blockedAt <= ViolationConstants.BLOCK_COOLDOWN_MS
|
|
251
|
+
);
|
|
252
|
+
}
|
|
263
253
|
|
|
264
|
-
/** The
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
session?: string;
|
|
268
|
-
now?: number;
|
|
269
|
-
}): string[] => {
|
|
270
|
-
const last = noteFileOf({ root: opts.root, session: opts.session, create: false });
|
|
254
|
+
/** The size of the violation log in bytes, 0 when there is none or it is not ours to read. */
|
|
255
|
+
static violationBytes(opts: { root: string }): number {
|
|
256
|
+
const log = fileOf({ root: opts.root, name: ViolationConstants.LOG_FILE });
|
|
271
257
|
|
|
272
|
-
|
|
273
|
-
return [];
|
|
258
|
+
return log === undefined ? 0 : (lstatSync(log, { throwIfNoEntry: false })?.size ?? 0);
|
|
274
259
|
}
|
|
275
260
|
|
|
276
|
-
|
|
277
|
-
|
|
261
|
+
/** The classes the previous reply of this session broke, or none when there is no note or it is stale. */
|
|
262
|
+
static readLastClasses(opts: { root: string; session?: string; now?: number }): string[] {
|
|
263
|
+
const last = noteFileOf({ root: opts.root, session: opts.session, create: false });
|
|
278
264
|
|
|
279
|
-
if (
|
|
265
|
+
if (last === undefined) {
|
|
280
266
|
return [];
|
|
281
267
|
}
|
|
282
268
|
|
|
283
|
-
|
|
269
|
+
try {
|
|
270
|
+
const note: unknown = JSON.parse(readFileSync(last, 'utf8'));
|
|
284
271
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
!Array.isArray(classes)
|
|
289
|
-
) {
|
|
290
|
-
return [];
|
|
291
|
-
}
|
|
272
|
+
if (typeof note !== 'object' || note === null || !('at' in note) || !('classes' in note)) {
|
|
273
|
+
return [];
|
|
274
|
+
}
|
|
292
275
|
|
|
293
|
-
|
|
294
|
-
(value): value is string => typeof value === 'string' && isKnownClass(value),
|
|
295
|
-
);
|
|
296
|
-
} catch {
|
|
297
|
-
return [];
|
|
298
|
-
}
|
|
299
|
-
};
|
|
276
|
+
const { at, classes } = note;
|
|
300
277
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
278
|
+
if (
|
|
279
|
+
typeof at !== 'number' ||
|
|
280
|
+
(opts.now ?? Date.now()) - at > ViolationConstants.LAST_MAX_AGE_MS ||
|
|
281
|
+
!Array.isArray(classes)
|
|
282
|
+
) {
|
|
283
|
+
return [];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return classes.filter(
|
|
287
|
+
(value): value is string => typeof value === 'string' && isKnownClass(value),
|
|
288
|
+
);
|
|
289
|
+
} catch {
|
|
290
|
+
return [];
|
|
291
|
+
}
|
|
312
292
|
}
|
|
313
293
|
|
|
314
|
-
|
|
294
|
+
/** Violations by class across the log, and the number of days it covers; empty when there is no log. */
|
|
295
|
+
static readCounts(opts: { root: string }): {
|
|
296
|
+
byClass: Map<string, number>;
|
|
297
|
+
replies: number;
|
|
298
|
+
days: number;
|
|
299
|
+
} {
|
|
300
|
+
const byClass = new Map<string, number>();
|
|
301
|
+
const days = new Set<string>();
|
|
302
|
+
let replies = 0;
|
|
303
|
+
const log = fileOf({ root: opts.root, name: ViolationConstants.LOG_FILE });
|
|
304
|
+
|
|
305
|
+
if (log === undefined) {
|
|
306
|
+
return { byClass, replies, days: 0 };
|
|
307
|
+
}
|
|
315
308
|
|
|
316
|
-
|
|
317
|
-
text = readFileSync(log, 'utf8');
|
|
318
|
-
} catch {
|
|
319
|
-
return { byClass, replies, days: 0 };
|
|
320
|
-
}
|
|
309
|
+
let text = '';
|
|
321
310
|
|
|
322
|
-
for (const line of text.split('\n')) {
|
|
323
311
|
try {
|
|
324
|
-
|
|
312
|
+
text = readFileSync(log, 'utf8');
|
|
313
|
+
} catch {
|
|
314
|
+
return { byClass, replies, days: 0 };
|
|
315
|
+
}
|
|
325
316
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
entry
|
|
329
|
-
'classes' in entry &&
|
|
330
|
-
Array.isArray(entry.classes)
|
|
331
|
-
) {
|
|
332
|
-
replies += 1;
|
|
317
|
+
for (const line of text.split('\n')) {
|
|
318
|
+
try {
|
|
319
|
+
const entry: unknown = JSON.parse(line);
|
|
333
320
|
|
|
334
|
-
if (
|
|
335
|
-
|
|
336
|
-
|
|
321
|
+
if (
|
|
322
|
+
typeof entry === 'object' &&
|
|
323
|
+
entry !== null &&
|
|
324
|
+
'classes' in entry &&
|
|
325
|
+
Array.isArray(entry.classes)
|
|
326
|
+
) {
|
|
327
|
+
replies += 1;
|
|
337
328
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
329
|
+
if ('date' in entry && typeof entry.date === 'string') {
|
|
330
|
+
days.add(entry.date);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
for (const value of entry.classes) {
|
|
334
|
+
if (typeof value === 'string' && isKnownClass(value)) {
|
|
335
|
+
byClass.set(value, (byClass.get(value) ?? 0) + 1);
|
|
336
|
+
}
|
|
341
337
|
}
|
|
342
338
|
}
|
|
339
|
+
} catch {
|
|
340
|
+
// A damaged line is skipped: the log is advisory.
|
|
343
341
|
}
|
|
344
|
-
} catch {
|
|
345
|
-
// A damaged line is skipped: the log is advisory.
|
|
346
342
|
}
|
|
347
|
-
}
|
|
348
343
|
|
|
349
|
-
|
|
350
|
-
}
|
|
344
|
+
return { byClass, replies, days: days.size };
|
|
345
|
+
}
|
|
346
|
+
}
|
package/src/rules/base.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { BASE_DIRECTORY } from '../common/index.ts';
|
|
4
|
-
import {
|
|
4
|
+
import { RuleParser } from './parser.ts';
|
|
5
5
|
|
|
6
6
|
const readBaseMarkdown = (): string => readFileSync(join(BASE_DIRECTORY, 'rules.md'), 'utf8');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
export class BaseRules {
|
|
9
|
+
/** Each base rule's ID with its table row, verbatim. */
|
|
10
|
+
static read(): Record<string, string> {
|
|
11
|
+
return Object.fromEntries(
|
|
12
|
+
RuleParser.extractRows({ markdown: readBaseMarkdown() }).map((row) => {
|
|
13
|
+
const [id] = RuleParser.parseIds({ markdown: row });
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
return [id, row];
|
|
16
|
+
}),
|
|
17
|
+
);
|
|
18
|
+
}
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
static readRetiredIds(): string[] {
|
|
21
|
+
return RuleParser.parseRetiredIds({ markdown: readBaseMarkdown() });
|
|
22
|
+
}
|
|
23
|
+
}
|
package/src/rules/parser.ts
CHANGED
|
@@ -2,48 +2,55 @@ import { RuleConstants } from './common/index.ts';
|
|
|
2
2
|
|
|
3
3
|
const RULE_ROW = new RegExp(`^\\|\\s*(?:\\*\\*)?(${RuleConstants.ID_SOURCE})(?:\\*\\*)?\\s*\\|`);
|
|
4
4
|
|
|
5
|
-
/** Rule IDs in table order, from rows whose first cell is `W-01`, `V-W-01` or either in bold. */
|
|
6
|
-
export const parseRuleIds = (opts: { markdown: string }): string[] =>
|
|
7
|
-
opts.markdown
|
|
8
|
-
.split('\n')
|
|
9
|
-
.map((line) => RULE_ROW.exec(line)?.[1])
|
|
10
|
-
.filter((id): id is string => id !== undefined);
|
|
11
|
-
|
|
12
|
-
/** The table rows of every rule, verbatim, in order. */
|
|
13
|
-
export const extractRuleRows = (opts: { markdown: string }): string[] =>
|
|
14
|
-
opts.markdown.split('\n').filter((line) => RULE_ROW.test(line));
|
|
15
|
-
|
|
16
5
|
const BASE_ID = new RegExp(`(?<![A-Z-])${RuleConstants.BASE_ID_SOURCE}\\b`, 'g');
|
|
6
|
+
|
|
17
7
|
const EXTENDS_LIST = new RegExp(
|
|
18
8
|
`\\bExtends\\s+${RuleConstants.BASE_ID_SOURCE}(?:(?:\\s*,\\s*|\\s+and\\s+)${RuleConstants.BASE_ID_SOURCE})*`,
|
|
19
9
|
'g',
|
|
20
10
|
);
|
|
11
|
+
|
|
21
12
|
const RETIRED_ITEM = new RegExp(`^- \`(${RuleConstants.BASE_ID_SOURCE})\` - `);
|
|
22
13
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
export class RuleParser {
|
|
15
|
+
/** Rule IDs in table order, from rows whose first cell is `W-01`, `V-W-01` or either in bold. */
|
|
16
|
+
static parseIds(opts: { markdown: string }): string[] {
|
|
17
|
+
return opts.markdown
|
|
18
|
+
.split('\n')
|
|
19
|
+
.map((line) => RULE_ROW.exec(line)?.[1])
|
|
20
|
+
.filter((id): id is string => id !== undefined);
|
|
21
|
+
}
|
|
29
22
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
/** The table rows of every rule, verbatim, in order. */
|
|
24
|
+
static extractRows(opts: { markdown: string }): string[] {
|
|
25
|
+
return opts.markdown.split('\n').filter((line) => RULE_ROW.test(line));
|
|
26
|
+
}
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
/**
|
|
29
|
+
* The base IDs a project's rules point at, once each, in order: an `Extends V-X, V-Y and V-Z` list
|
|
30
|
+
* in a table row, and every `V-` ID in a row's first cell. A `V-` ID in prose or a later cell is not one.
|
|
31
|
+
*/
|
|
32
|
+
static parseBaseReferences(opts: { markdown: string }): string[] {
|
|
33
|
+
const references = new Set<string>();
|
|
34
|
+
|
|
35
|
+
for (const line of opts.markdown.split('\n').filter((row) => row.startsWith('|'))) {
|
|
36
|
+
const firstCell = line.split('|')[1] ?? '';
|
|
37
|
+
const lists = [...line.matchAll(EXTENDS_LIST)].map((match) => match[0]);
|
|
38
|
+
|
|
39
|
+
for (const text of [...lists, firstCell]) {
|
|
40
|
+
for (const match of text.matchAll(BASE_ID)) {
|
|
41
|
+
references.add(match[0]);
|
|
42
|
+
}
|
|
37
43
|
}
|
|
38
44
|
}
|
|
39
|
-
}
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
}
|
|
46
|
+
return [...references];
|
|
47
|
+
}
|
|
43
48
|
|
|
44
|
-
/** The IDs the base retired, one `` - `V-X-NN` - why `` bullet each; they are never reused. */
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
/** The IDs the base retired, one `` - `V-X-NN` - why `` bullet each; they are never reused. */
|
|
50
|
+
static parseRetiredIds(opts: { markdown: string }): string[] {
|
|
51
|
+
return opts.markdown
|
|
52
|
+
.split('\n')
|
|
53
|
+
.map((line) => RETIRED_ITEM.exec(line)?.[1])
|
|
54
|
+
.filter((id): id is string => id !== undefined);
|
|
55
|
+
}
|
|
56
|
+
}
|
package/src/rules/slots.ts
CHANGED
|
@@ -3,10 +3,12 @@ import { join } from 'node:path';
|
|
|
3
3
|
import { BASE_DIRECTORY } from '../common/index.ts';
|
|
4
4
|
import type { ISlot } from './common/index.ts';
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export class RuleSlots {
|
|
7
|
+
static read(): Record<string, ISlot> {
|
|
8
|
+
const slots: Record<string, ISlot> = JSON.parse(
|
|
9
|
+
readFileSync(join(BASE_DIRECTORY, 'slots.json'), 'utf8'),
|
|
10
|
+
);
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
}
|
|
12
|
+
return slots;
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/signals/claims.ts
CHANGED
|
@@ -38,34 +38,36 @@ const asserts = (opts: { text: string; words: string[] }): boolean =>
|
|
|
38
38
|
(sentence) => !isDenied({ sentence }) && opts.words.some((word) => hasWord({ sentence, word })),
|
|
39
39
|
);
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
41
|
+
export class ReplyClaims {
|
|
42
|
+
/**
|
|
43
|
+
* What the reply claims against what the turn's calls show. A claim that something is published, released
|
|
44
|
+
* or live needs a public-state probe in the turn; a claim that the checks pass is contradicted while a gate
|
|
45
|
+
* of the turn still failed on its latest run. Phrases match whole words in a sentence that does not deny,
|
|
46
|
+
* ask or quote; English plus any the project adds. Logged, never blocked: a match is a hint, not proof.
|
|
47
|
+
*/
|
|
48
|
+
static check(opts: {
|
|
49
|
+
text: string;
|
|
50
|
+
state: ISignalState;
|
|
51
|
+
publicWords?: string[];
|
|
52
|
+
doneWords?: string[];
|
|
53
|
+
}): string[] {
|
|
54
|
+
const classes: string[] = [];
|
|
55
|
+
const { state } = opts;
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
if (
|
|
58
|
+
asserts({ text: opts.text, words: [...ClaimWords.PUBLIC, ...(opts.publicWords ?? [])] }) &&
|
|
59
|
+
state.probeAt < state.turnAt
|
|
60
|
+
) {
|
|
61
|
+
classes.push(ClaimClasses.PUBLIC_CLAIM_NO_PROBE);
|
|
62
|
+
}
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
if (
|
|
65
|
+
asserts({ text: opts.text, words: [...ClaimWords.DONE, ...(opts.doneWords ?? [])] }) &&
|
|
66
|
+
state.failedGates.length > 0
|
|
67
|
+
) {
|
|
68
|
+
classes.push(ClaimClasses.CONTRADICTED_COMPLETION);
|
|
69
|
+
}
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
}
|
|
71
|
+
return classes;
|
|
72
|
+
}
|
|
73
|
+
}
|