claude-code-session-manager 0.127.0 → 0.129.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 +1 -1
- package/README.md +2 -0
- package/dist/assets/{AgentLibrary-DKQznr7o.js → AgentLibrary-Cp250YHF.js} +1 -1
- package/dist/assets/{Button-CZXqmIiM.js → Button-DU5UF-6L.js} +1 -1
- package/dist/assets/{DataModel-piyV33To.js → DataModel-CPf6f17e.js} +1 -1
- package/dist/assets/{History-BxwtrKF2.js → History-B2x-LMlT.js} +1 -1
- package/dist/assets/{Hooks-DogeSPII.js → Hooks-BWr33C4Q.js} +1 -1
- package/dist/assets/{Library-BDt6EeQQ.js → Library-DBNLTAa8.js} +1 -1
- package/dist/assets/{ListDetail-CwS-LKar.js → ListDetail-BGBw6egp.js} +1 -1
- package/dist/assets/{McpServers-D2HVljgS.js → McpServers-DywZ50Ec.js} +1 -1
- package/dist/assets/{Memory-hNzuOGn8.js → Memory-CnalwnFf.js} +1 -1
- package/dist/assets/{Panel-BLDrsUeq.js → Panel-BzIklgKf.js} +1 -1
- package/dist/assets/{Permissions-DzZ5vaJW.js → Permissions-mgRifwQc.js} +1 -1
- package/dist/assets/{Plugins-Cz9yaxzG.js → Plugins-CV42zfid.js} +2 -2
- package/dist/assets/{ProvenanceBadge-CCgLO4m9.js → ProvenanceBadge-DYmX4xgB.js} +1 -1
- package/dist/assets/{SaveBar-Shmn699J.js → SaveBar-DxrAfnlC.js} +1 -1
- package/dist/assets/{Scheduler-Bqr0WHNd.js → Scheduler-iyUl1NDl.js} +1 -1
- package/dist/assets/{ScopeSwitcher-CBx1fB5g.js → ScopeSwitcher-CC8BDPgf.js} +1 -1
- package/dist/assets/{Settings-Ci8in-yF.js → Settings-CWBnQghD.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-BWwljba8.js → SkillReferenceGraph-DOhiCxuL.js} +1 -1
- package/dist/assets/{Skills-BON6o-c4.js → Skills-3Er-9YA9.js} +1 -1
- package/dist/assets/{SystemPrompt-D5epIYYs.js → SystemPrompt-BLxdvZ9K.js} +1 -1
- package/dist/assets/{TagLibrary-C2qDZROJ.js → TagLibrary-BZ6QHYMQ.js} +1 -1
- package/dist/assets/{TiptapBody-SZhI3-bW.js → TiptapBody-Du6jRBoW.js} +1 -1
- package/dist/assets/{Toggle-C_qFDG0g.js → Toggle-Qdi2Z7VD.js} +1 -1
- package/dist/assets/{ViewTabs-C9q5WCEd.js → ViewTabs-BKfFsziD.js} +1 -1
- package/dist/assets/{historyTotals-BCl7IOhY.js → historyTotals-8ecP_6wF.js} +1 -1
- package/dist/assets/{index-BnKaYERU.css → index-DtdWBGrI.css} +1 -1
- package/dist/assets/index-GI6F_j41.js +3083 -0
- package/dist/assets/{settingsSchema-BBrRBrBr.js → settingsSchema-lHTHAabD.js} +1 -1
- package/dist/assets/{skillFrontmatter-B01qJk6N.js → skillFrontmatter-8X1Uc282.js} +1 -1
- package/dist/assets/{useAgentsDirWatch-CuR3GSjS.js → useAgentsDirWatch-CcsoD1bp.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +373 -369
- package/package.json +1 -1
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
- package/plugins/session-manager-dev/skills/develop/SKILL.md +4 -2
- package/scripts/hooks/lib/guard-inline-implementation-policy.cjs +10 -0
- package/scripts/scheduler-mcp-server.cjs +170 -6
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +8 -0
- package/src/main/index.cjs +27 -0
- package/src/main/ipcSchemas.cjs +110 -1
- package/src/main/lib/claude/agentModelResolve.cjs +31 -10
- package/src/main/lib/claude/effectiveModelInfo.cjs +14 -4
- package/src/main/lib/claude/modelCatalog.cjs +28 -1
- package/src/main/lib/claude/personaToolScope.cjs +40 -2
- package/src/main/lib/demo-video-kit/capture.cjs +113 -0
- package/src/main/lib/demo-video-kit/character.cjs +97 -0
- package/src/main/lib/demo-video-kit/checks.cjs +150 -0
- package/src/main/lib/demo-video-kit/frames.cjs +200 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +52 -0
- package/src/main/lib/demo-video-kit/sound.cjs +312 -0
- package/src/main/lib/epic/developLoopSpawn.cjs +18 -0
- package/src/main/lib/epic/epicMint.cjs +4 -2
- package/src/main/lib/epic/epicValidationHook.cjs +17 -1
- package/src/main/lib/epic/promptSessionsCreateEpic.cjs +4 -3
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +21 -21
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +185 -34
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +15 -0
- package/src/main/lib/mcpToolCatalog.cjs +71 -11
- package/src/main/lib/opsOwnership.cjs +9 -5
- package/src/main/lib/persona-macro/builtinMacros.cjs +19 -5
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +116 -0
- package/src/main/lib/persona-macro/macroJobIpc.cjs +50 -0
- package/src/main/lib/persona-macro/macroJobStatus.cjs +112 -0
- package/src/main/lib/persona-macro/macroLibrary.cjs +16 -0
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +113 -0
- package/src/main/lib/prd/prdCreate.cjs +27 -1
- package/src/main/lib/prd/prdFrontmatter.cjs +7 -2
- package/src/main/lib/project-pages/pagesLibrary.cjs +171 -0
- package/src/main/lib/project-pages/playerBridge.cjs +129 -0
- package/src/main/lib/promptSessionSchema.cjs +8 -0
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
- package/src/main/lib/smfileHeaders.cjs +11 -3
- package/src/main/projectPages.cjs +107 -30
- package/src/main/promptSessionsIpc.cjs +131 -0
- package/src/main/scheduler/prdParser.cjs +2 -0
- package/src/main/scheduler.cjs +26 -9
- package/src/main/seedSchedulerMcp.cjs +10 -1
- package/src/main/transcripts.cjs +8 -0
- package/src/main/webRemote.cjs +3 -1
- package/src/preload/api.d.ts +107 -6
- package/src/preload/apiSurface.json +77 -0
- package/src/preload/index.cjs +18 -0
- package/src/seed/agents/architect.md +8 -8
- package/src/seed/agents/demo-video-builder.md +86 -36
- package/src/seed/agents/project-home-builder.md +26 -13
- package/dist/assets/index-CMIYLbPb.js +0 -3079
- package/src/main/lib/epic/epicStandingInstructions.cjs +0 -73
|
@@ -28,11 +28,14 @@
|
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
const path = require('node:path');
|
|
31
|
+
const crypto = require('node:crypto');
|
|
31
32
|
const os = require('node:os');
|
|
32
33
|
const { splitFrontmatter } = require('../prd/prdFrontmatter.cjs');
|
|
33
34
|
const { readActiveIndex, resolvePersonaPaths } = require('../epic/epicMint.cjs');
|
|
34
35
|
const { resolveMergedPersona, PERSONA_NAME_RE } = require('../persona-macro/personaMerge.cjs');
|
|
36
|
+
const { readSettingsModel } = require('./modelCatalog.cjs');
|
|
35
37
|
const configMgr = require('../../config.cjs');
|
|
38
|
+
const { SHIPPED_PERSONA_SEEDS } = require('../persona-macro/shippedPersonaSeeds.cjs');
|
|
36
39
|
|
|
37
40
|
/** The hardcoded floor every branch of resolveEpicModel falls back to — --model must never be omitted (CLAUDE.md "Automation model pinning"). */
|
|
38
41
|
const FALLBACK_MODEL = 'sonnet';
|
|
@@ -168,29 +171,44 @@ function resolveEpicModel({ cwd, claudeSessionId, fallbackModel = FALLBACK_MODEL
|
|
|
168
171
|
const override = epicOverrideValue(epic, 'model');
|
|
169
172
|
if (override && override !== 'inherit') return override;
|
|
170
173
|
const agentType = epic?.agentType || null;
|
|
171
|
-
|
|
174
|
+
const settingsOrFallback = () => readSettingsModel(cwd, deps) || fallbackModel || FALLBACK_MODEL;
|
|
175
|
+
if (!agentType) return settingsOrFallback();
|
|
172
176
|
const model = readOverlayAwarePersonaModel(agentType, { ...deps, cwd });
|
|
173
|
-
if (!model || model === 'inherit') return
|
|
177
|
+
if (!model || model === 'inherit') return settingsOrFallback();
|
|
174
178
|
return model;
|
|
175
179
|
} catch {
|
|
176
|
-
return fallbackModel;
|
|
180
|
+
return fallbackModel || FALLBACK_MODEL;
|
|
177
181
|
}
|
|
178
182
|
}
|
|
179
183
|
|
|
180
184
|
/** Mirrors epicIntake.ts's AGENT_BODY_CHAR_CAP — a runaway persona file must
|
|
181
185
|
* not be able to dominate a spawned job's system prompt either. Duplicated
|
|
182
186
|
* rather than imported: epicIntake.ts is a renderer module (no ES modules
|
|
183
|
-
* in main).
|
|
187
|
+
* in main).
|
|
188
|
+
*
|
|
189
|
+
* EXEMPTION: a body whose digest matches a version the app itself shipped
|
|
190
|
+
* (SHIPPED_PERSONA_SEEDS) is passed whole — an unedited app-shipped body
|
|
191
|
+
* cannot be a runaway file, and demo-video-builder's style and palette rules
|
|
192
|
+
* sit past 6000 chars, so capping it silently drops them. Every other body
|
|
193
|
+
* (edited, overlay-changed, no manifest entry) stays capped. */
|
|
184
194
|
const AGENT_BODY_CHAR_CAP = 6000;
|
|
185
195
|
|
|
196
|
+
/** sha256 hex of a body (newlines normalized, trimmed). MUST stay the same
|
|
197
|
+
* digest as seedAgentPersonas.cjs's personaBodyHash (not required here: it
|
|
198
|
+
* pulls the seeding writers); the unit test enforces the equality. */
|
|
199
|
+
function shippedBodyHash(body) {
|
|
200
|
+
const normalized = String(body || '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
201
|
+
return crypto.createHash('sha256').update(normalized.trim()).digest('hex');
|
|
202
|
+
}
|
|
203
|
+
|
|
186
204
|
/** Trims a persona's frontmatter-stripped body and caps it at
|
|
187
|
-
* AGENT_BODY_CHAR_CAP, appending a truncation notice
|
|
188
|
-
* — same shape as epicIntake.ts's buildPersonaBodyText.
|
|
189
|
-
* empty body. */
|
|
190
|
-
function buildPersonaBodyText(rawBody, personaPath) {
|
|
205
|
+
* AGENT_BODY_CHAR_CAP (unless `uncapped`), appending a truncation notice
|
|
206
|
+
* naming `personaPath` — same shape as epicIntake.ts's buildPersonaBodyText.
|
|
207
|
+
* Returns null for an empty body. */
|
|
208
|
+
function buildPersonaBodyText(rawBody, personaPath, { uncapped = false } = {}) {
|
|
191
209
|
const body = (rawBody || '').trim();
|
|
192
210
|
if (!body) return null;
|
|
193
|
-
if (body.length <= AGENT_BODY_CHAR_CAP) return body;
|
|
211
|
+
if (uncapped || body.length <= AGENT_BODY_CHAR_CAP) return body;
|
|
194
212
|
const truncated = body.slice(0, AGENT_BODY_CHAR_CAP);
|
|
195
213
|
const pathLabel = personaPath || 'the persona file';
|
|
196
214
|
return `${truncated}\n\n[Truncated — ${pathLabel} exceeds ${AGENT_BODY_CHAR_CAP} characters; see the file for the full body.]`;
|
|
@@ -229,7 +247,9 @@ async function resolvePrdPersonaForSpawn({ cwd, agentType, fallbackModel = FALLB
|
|
|
229
247
|
// (older injected reader) is parsed here.
|
|
230
248
|
const { fm, body } = persona.fm ? persona : splitFrontmatter(persona.text);
|
|
231
249
|
const model = fm.model && fm.model !== 'inherit' ? fm.model : fallbackModel;
|
|
232
|
-
const
|
|
250
|
+
const digest = shippedBodyHash(body);
|
|
251
|
+
const uncapped = (SHIPPED_PERSONA_SEEDS[agentType] || []).some((e) => e.bodySha256 === digest);
|
|
252
|
+
const systemPrompt = buildPersonaBodyText(body, persona.path, { uncapped });
|
|
233
253
|
const parseTools = deps.parseTools || require('../../agentLibrary.cjs').parseTools;
|
|
234
254
|
const list = parseTools(typeof fm.tools === 'string' ? fm.tools : '');
|
|
235
255
|
return { model, systemPrompt, personaPath: persona.path, tools: list.length ? list : null };
|
|
@@ -241,6 +261,7 @@ async function resolvePrdPersonaForSpawn({ cwd, agentType, fallbackModel = FALLB
|
|
|
241
261
|
module.exports = {
|
|
242
262
|
FALLBACK_MODEL,
|
|
243
263
|
AGENT_BODY_CHAR_CAP,
|
|
264
|
+
shippedBodyHash,
|
|
244
265
|
resolveEpicModel,
|
|
245
266
|
findAgentTypeByClaudeSessionId,
|
|
246
267
|
findEpicByClaudeSessionId,
|
|
@@ -281,17 +281,24 @@ async function resolveEffectiveModelInfo({ cwd, agentType, deps = {} } = {}) {
|
|
|
281
281
|
personaEffort: null,
|
|
282
282
|
personaEffortSource: null,
|
|
283
283
|
};
|
|
284
|
-
if (!cwd
|
|
284
|
+
if (!cwd) return miss;
|
|
285
285
|
|
|
286
286
|
try {
|
|
287
287
|
const { projectRootOf } = deps.activeSessions || require('../activeSessions.cjs');
|
|
288
288
|
const normalizedCwd = projectRootOf(path.resolve(cwd));
|
|
289
289
|
if (!normalizedCwd) return miss;
|
|
290
290
|
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
let { modelAlias, modelSource, provenance: personaProvenance } = agentType
|
|
292
|
+
? await resolvePersonaModelAlias(normalizedCwd, agentType, deps)
|
|
293
|
+
: { modelAlias: null, modelSource: 'fallback', provenance: {} };
|
|
294
|
+
if (!modelAlias) {
|
|
295
|
+
// No persona model (agentless, inherit or dangling): the launch uses the Claude settings model.
|
|
296
|
+
const settingsModel = (deps.readSettingsModel || require('./modelCatalog.cjs').readSettingsModel)(normalizedCwd, deps);
|
|
297
|
+
if (settingsModel) { modelAlias = settingsModel; modelSource = 'settings'; }
|
|
298
|
+
}
|
|
299
|
+
const { effort: personaEffort, source: personaEffortSource } = !agentType ? { effort: null, source: null } : (deps.agentEffortResolve || require('./agentEffortResolve.cjs'))
|
|
293
300
|
.resolveEpicEffort({ cwd: normalizedCwd, agentType, deps });
|
|
294
|
-
const result = { agentType, modelAlias, modelSource, personaProvenance, resolvedModelId: null, resolvedFrom: null, effortEnvReachable, personaEffort, personaEffortSource };
|
|
301
|
+
const result = { agentType: agentType || null, modelAlias, modelSource, personaProvenance, resolvedModelId: null, resolvedFrom: null, effortEnvReachable, personaEffort, personaEffortSource };
|
|
295
302
|
|
|
296
303
|
if (isConcreteModelId(modelAlias)) {
|
|
297
304
|
// Already a concrete pinned id — echo it back, fabricate no evidence.
|
|
@@ -299,6 +306,9 @@ async function resolveEffectiveModelInfo({ cwd, agentType, deps = {} } = {}) {
|
|
|
299
306
|
return result;
|
|
300
307
|
}
|
|
301
308
|
|
|
309
|
+
// Agentless: no per-agent evidence to look up (it would match every agentless job).
|
|
310
|
+
if (!agentType) return result;
|
|
311
|
+
|
|
302
312
|
// Evidence is never derived via historyAggregator.cjs's resolvePricingKey
|
|
303
313
|
// (which buckets any unknown id to 'sonnet' with estimated:true) —
|
|
304
314
|
// deliberately: that is a pricing heuristic, and borrowing it here would
|
|
@@ -132,6 +132,33 @@ function readAvailableModels(cwd, d, fsImpl) {
|
|
|
132
132
|
return merged ? [...new Set(merged)] : null;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* The `model` key of the user's Claude settings: first non-empty string from
|
|
137
|
+
* <projectRoot>/.claude/settings.local.json, <projectRoot>/.claude/settings.json,
|
|
138
|
+
* then ~/.claude/settings.json (local over project over user). Never throws; null when none.
|
|
139
|
+
*/
|
|
140
|
+
function readSettingsModel(cwd, deps = {}) {
|
|
141
|
+
try {
|
|
142
|
+
const d = deps || {};
|
|
143
|
+
const fsImpl = d.fs || fs;
|
|
144
|
+
const home = d.homeDir ? d.homeDir() : os.homedir();
|
|
145
|
+
const files = [];
|
|
146
|
+
if (cwd) {
|
|
147
|
+
let root;
|
|
148
|
+
try { root = (d.projectRootOf || require('../activeSessions.cjs').projectRootOf)(path.resolve(cwd)); } catch { root = path.resolve(cwd); }
|
|
149
|
+
if (root) files.push(path.join(root, '.claude', 'settings.local.json'), path.join(root, '.claude', 'settings.json'));
|
|
150
|
+
}
|
|
151
|
+
files.push(path.join(home, '.claude', 'settings.json'));
|
|
152
|
+
for (const f of files) {
|
|
153
|
+
try {
|
|
154
|
+
const m = JSON.parse(fsImpl.readFileSync(f, 'utf8')).model;
|
|
155
|
+
if (typeof m === 'string' && m.trim()) return m.trim();
|
|
156
|
+
} catch { /* missing/unreadable scope */ }
|
|
157
|
+
}
|
|
158
|
+
} catch { /* never throws */ }
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
135
162
|
function readCache(file, fsImpl) {
|
|
136
163
|
try {
|
|
137
164
|
const c = JSON.parse(fsImpl.readFileSync(file, 'utf8'));
|
|
@@ -240,4 +267,4 @@ function resolveModelCatalog({ cwd, force, deps } = {}) {
|
|
|
240
267
|
return inFlight;
|
|
241
268
|
}
|
|
242
269
|
|
|
243
|
-
module.exports = { resolveModelCatalog, CATALOG_FLOOR, parseAliases, parseEffortLevels, scanModelIds };
|
|
270
|
+
module.exports = { resolveModelCatalog, readSettingsModel, CATALOG_FLOOR, parseAliases, parseEffortLevels, scanModelIds };
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
* prompt, CLAUDE.md, `--append-system-prompt` and `--disallowedTools` keep
|
|
12
12
|
* working.
|
|
13
13
|
*
|
|
14
|
+
* Scoping is focus, not containment: the scope decides which tools a job is
|
|
15
|
+
* offered. Every headless job runs as the owner's OS user with
|
|
16
|
+
* --dangerously-skip-permissions, so a job with Bash can still start an MCP
|
|
17
|
+
* server or call the admin API itself.
|
|
18
|
+
*
|
|
14
19
|
* Pure: no fs, and no require of scheduler.cjs (cycle) — the caller passes its
|
|
15
20
|
* HEADLESS_DISALLOWED_TOOLS list in.
|
|
16
21
|
*/
|
|
@@ -45,9 +50,12 @@ function buildPersonaToolScope(tools, { disallowed = [] } = {}) {
|
|
|
45
50
|
|
|
46
51
|
/**
|
|
47
52
|
* @param {{ tools: string[] }|null} scope result of buildPersonaToolScope
|
|
53
|
+
* @param {{ mcpServers?: Record<string, object> }} [opts] known MCP server
|
|
54
|
+
* definitions by name. When EVERY mcp__ tool in scope names a server here,
|
|
55
|
+
* only those servers are passed (--mcp-config <json> --strict-mcp-config).
|
|
48
56
|
* @returns {string[]} argv fragment ([] when unscoped)
|
|
49
57
|
*/
|
|
50
|
-
function personaToolScopeArgs(scope) {
|
|
58
|
+
function personaToolScopeArgs(scope, { mcpServers } = {}) {
|
|
51
59
|
if (!scope) return [];
|
|
52
60
|
const def = {
|
|
53
61
|
description: 'Headless run with a scheduler-enforced tool scope.',
|
|
@@ -60,13 +68,43 @@ function personaToolScopeArgs(scope) {
|
|
|
60
68
|
];
|
|
61
69
|
// A scope naming no MCP tool never uses a server: with --strict-mcp-config and
|
|
62
70
|
// no --mcp-config (variadic; would swallow later args) the CLI boots none.
|
|
63
|
-
|
|
71
|
+
const mcpTools = scope.tools.map(String).filter((t) => t.startsWith('mcp__'));
|
|
72
|
+
if (mcpTools.length === 0) {
|
|
64
73
|
args.push('--strict-mcp-config');
|
|
74
|
+
return args;
|
|
75
|
+
}
|
|
76
|
+
// Server name = the segment between `mcp__` and the next `__`.
|
|
77
|
+
const named = new Set(mcpTools.map((t) => t.slice(5).split('__')[0]));
|
|
78
|
+
const known = mcpServers || {};
|
|
79
|
+
const allKnown = [...named].every((n) => n && Object.prototype.hasOwnProperty.call(known, n));
|
|
80
|
+
if (allKnown) {
|
|
81
|
+
const picked = {};
|
|
82
|
+
for (const n of named) picked[n] = known[n];
|
|
83
|
+
// --mcp-config is variadic: the caller must keep a `--flag` right after.
|
|
84
|
+
args.push('--mcp-config', JSON.stringify({ mcpServers: picked }), '--strict-mcp-config');
|
|
65
85
|
}
|
|
66
86
|
return args;
|
|
67
87
|
}
|
|
68
88
|
|
|
89
|
+
const JOB_MCP_TOOLS_ENV = 'SM_SCHEDULER_JOB_MCP_TOOLS';
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Env fragment a scoped job carries so an out-of-process MCP server can tell
|
|
93
|
+
* which MCP tools the scope admits. scripts/scheduler-mcp-server.cjs reads it
|
|
94
|
+
* to list and serve only in-scope tools. The value is always a JSON array
|
|
95
|
+
* string; '[]' means no MCP tool.
|
|
96
|
+
* @param {{ tools: string[] }|null|undefined} scope
|
|
97
|
+
* @returns {Record<string, string>} {} when unscoped
|
|
98
|
+
*/
|
|
99
|
+
function personaToolScopeEnv(scope) {
|
|
100
|
+
if (!scope) return {};
|
|
101
|
+
const mcp = scope.tools.map(String).filter((t) => t.startsWith('mcp__'));
|
|
102
|
+
return { [JOB_MCP_TOOLS_ENV]: JSON.stringify(mcp) };
|
|
103
|
+
}
|
|
104
|
+
|
|
69
105
|
module.exports = {
|
|
106
|
+
JOB_MCP_TOOLS_ENV,
|
|
107
|
+
personaToolScopeEnv,
|
|
70
108
|
HEADLESS_TOOL_FLOOR,
|
|
71
109
|
HEADLESS_SCOPE_AGENT_NAME,
|
|
72
110
|
buildPersonaToolScope,
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Demo-video kit capture helper: up to 6 size-budgeted screenshots (and optional short clips)
|
|
3
|
+
// of the live product at one URL. Playwright is resolved at runtime (cwd, then global npm
|
|
4
|
+
// root, or an injected loader) and is never installed here. Node builtins only.
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { spawnSync } = require('child_process');
|
|
8
|
+
|
|
9
|
+
const MAX_SHOTS = 6;
|
|
10
|
+
const IMAGE_BUDGET = 120 * 1024;
|
|
11
|
+
const CLIP_BUDGET = 280 * 1024;
|
|
12
|
+
const QUALITY_STEPS = [80, 65, 52, 40, 30, 20]; // at most 6 tries
|
|
13
|
+
const NAV_TIMEOUT_MS = 30000;
|
|
14
|
+
const VIEWPORT = { width: 1280, height: 720 };
|
|
15
|
+
|
|
16
|
+
function tryRequire(name, paths) {
|
|
17
|
+
try {
|
|
18
|
+
return require(require.resolve(name, { paths }));
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function globalNpmRoot() {
|
|
25
|
+
try {
|
|
26
|
+
const r = spawnSync('npm', ['root', '-g'], { encoding: 'utf8', timeout: 15000 });
|
|
27
|
+
return r.status === 0 ? String(r.stdout).trim() : '';
|
|
28
|
+
} catch {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Default loader: process.cwd() first, then the global npm root. Never installs. */
|
|
34
|
+
function defaultLoader() {
|
|
35
|
+
for (const name of ['playwright', 'playwright-core']) {
|
|
36
|
+
const m = tryRequire(name, [process.cwd()]);
|
|
37
|
+
if (m) return m;
|
|
38
|
+
}
|
|
39
|
+
const root = globalNpmRoot();
|
|
40
|
+
if (root) {
|
|
41
|
+
for (const name of ['playwright', 'playwright-core']) {
|
|
42
|
+
const m = tryRequire(name, [root]);
|
|
43
|
+
if (m) return m;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function defaultEncode(page, { kind, quality }) {
|
|
50
|
+
if (kind !== 'image') return null; // clips need an injected encoder; dropped otherwise
|
|
51
|
+
return page.screenshot({ type: 'jpeg', quality });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Step quality down (<= 6 tries) until the buffer fits the budget; null when it never does. */
|
|
55
|
+
async function fitBudget(encode, page, kind, budget) {
|
|
56
|
+
const steps = kind === 'image' ? QUALITY_STEPS : [QUALITY_STEPS[0], QUALITY_STEPS[2], QUALITY_STEPS[4]];
|
|
57
|
+
for (let i = 0; i < steps.length && i < 6; i++) {
|
|
58
|
+
const buf = await encode(page, { kind, quality: steps[i] });
|
|
59
|
+
if (!buf) return null;
|
|
60
|
+
if (buf.length <= budget) return buf;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function focusFor(page, shot) {
|
|
66
|
+
const sel = shot.focusSelector || shot.selector;
|
|
67
|
+
if (sel) {
|
|
68
|
+
try {
|
|
69
|
+
const b = await page.locator(sel).first().boundingBox();
|
|
70
|
+
if (b) return { x: Math.round(b.x), y: Math.round(b.y), w: Math.round(b.width), h: Math.round(b.height) };
|
|
71
|
+
} catch { /* fall through to default */ }
|
|
72
|
+
}
|
|
73
|
+
return { x: Math.round(VIEWPORT.width * 0.25), y: Math.round(VIEWPORT.height * 0.25), w: Math.round(VIEWPORT.width * 0.5), h: Math.round(VIEWPORT.height * 0.5) };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function capture({ url, outDir, shots, max = MAX_SHOTS, loadPlaywright, encode, navTimeoutMs } = {}) {
|
|
77
|
+
if (!url || typeof url !== 'string') return { skipped: 'no-url' };
|
|
78
|
+
const pw = (loadPlaywright || defaultLoader)();
|
|
79
|
+
const resolved = pw && typeof pw.then === 'function' ? await pw : pw;
|
|
80
|
+
const chromium = resolved && resolved.chromium;
|
|
81
|
+
if (!chromium) return { skipped: 'no-playwright' };
|
|
82
|
+
|
|
83
|
+
const cap = Math.max(0, Math.min(Number(max) || MAX_SHOTS, MAX_SHOTS));
|
|
84
|
+
const list = (Array.isArray(shots) && shots.length ? shots : [{}]).slice(0, cap);
|
|
85
|
+
const enc = encode || defaultEncode;
|
|
86
|
+
const timeout = Math.min(Number(navTimeoutMs) || NAV_TIMEOUT_MS, NAV_TIMEOUT_MS);
|
|
87
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
88
|
+
|
|
89
|
+
const items = [];
|
|
90
|
+
const browser = await chromium.launch({ headless: true });
|
|
91
|
+
try {
|
|
92
|
+
const page = await browser.newPage({ viewport: VIEWPORT });
|
|
93
|
+
page.setDefaultTimeout(timeout);
|
|
94
|
+
await page.goto(url, { timeout, waitUntil: 'load' }); // the only navigation, to the given URL
|
|
95
|
+
for (let i = 0; i < list.length; i++) {
|
|
96
|
+
const shot = list[i] || {};
|
|
97
|
+
const kind = shot.kind === 'clip' ? 'clip' : 'image';
|
|
98
|
+
if (shot.selector) {
|
|
99
|
+
try { await page.locator(shot.selector).first().scrollIntoViewIfNeeded({ timeout }); } catch { /* keep going */ }
|
|
100
|
+
}
|
|
101
|
+
const buf = await fitBudget(enc, page, kind, kind === 'image' ? IMAGE_BUDGET : CLIP_BUDGET);
|
|
102
|
+
if (!buf) continue;
|
|
103
|
+
const file = path.join(outDir, `shot-${String(i + 1).padStart(2, '0')}.${kind === 'image' ? 'jpg' : 'webm'}`);
|
|
104
|
+
fs.writeFileSync(file, buf);
|
|
105
|
+
items.push({ file, kind, bytes: buf.length, focus: await focusFor(page, shot) });
|
|
106
|
+
}
|
|
107
|
+
} finally {
|
|
108
|
+
await browser.close().catch(() => {});
|
|
109
|
+
}
|
|
110
|
+
return { items };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
module.exports = { capture, IMAGE_BUDGET, CLIP_BUDGET, QUALITY_STEPS };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Demo-video kit character: a project's mascot lives in
|
|
3
|
+
// <ops>/project-pages/videos/_character/{character.json,character.js}.
|
|
4
|
+
// Reading is plain file reading; writing goes only through the
|
|
5
|
+
// POST /admin/project-home/character/write route (writer 'project-home').
|
|
6
|
+
// speakWithCommand spawns the user's TTS argv directly — never through a shell.
|
|
7
|
+
const fs = require('node:fs');
|
|
8
|
+
const path = require('node:path');
|
|
9
|
+
const { spawnSync } = require('node:child_process');
|
|
10
|
+
const { opsPath } = require('../opsOwnership.cjs');
|
|
11
|
+
|
|
12
|
+
const MAX_JS_BYTES = 300 * 1024;
|
|
13
|
+
const MAX_JSON_BYTES = 16 * 1024;
|
|
14
|
+
const COMMAND_TIMEOUT_MS = 120000;
|
|
15
|
+
|
|
16
|
+
/** -> null when `c` is a valid character.json object, else a reason string. */
|
|
17
|
+
function validateCharacterJson(c) {
|
|
18
|
+
if (!c || typeof c !== 'object' || Array.isArray(c)) return 'character.json must be an object';
|
|
19
|
+
if (typeof c.name !== 'string' || !c.name.trim()) return 'name must be a non-empty string';
|
|
20
|
+
if (!Array.isArray(c.palette) || c.palette.length === 0 || !c.palette.every((p) => typeof p === 'string' && p)) {
|
|
21
|
+
return 'palette must be a non-empty array of strings';
|
|
22
|
+
}
|
|
23
|
+
const v = c.voice;
|
|
24
|
+
if (!v || typeof v !== 'object') return 'voice is required';
|
|
25
|
+
if (v.engine === 'kokoro') {
|
|
26
|
+
if (typeof v.id !== 'string' || !v.id) return 'voice.id must be a non-empty string for engine kokoro';
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (v.engine === 'command') {
|
|
30
|
+
const cmd = v.command;
|
|
31
|
+
if (!Array.isArray(cmd) || cmd.length === 0 || !cmd.every((a) => typeof a === 'string')) {
|
|
32
|
+
return 'voice.command must be a non-empty string[]';
|
|
33
|
+
}
|
|
34
|
+
if (!cmd[0]) return 'voice.command[0] must be a program name';
|
|
35
|
+
if (!cmd.some((a) => a.includes('{text}'))) return 'voice.command must contain a {text} placeholder';
|
|
36
|
+
if (!cmd.some((a) => a.includes('{out}'))) return 'voice.command must contain an {out} placeholder';
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return "voice.engine must be 'kokoro' or 'command'";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** -> null when `js` is acceptable character.js source, else a reason. Needs the
|
|
43
|
+
* route's network checks, so they are injected (avoids a require cycle). */
|
|
44
|
+
function validateCharacterJs(js, networkChecks = []) {
|
|
45
|
+
if (typeof js !== 'string' || !js.trim()) return 'js must be a non-empty string';
|
|
46
|
+
if (Buffer.byteLength(js, 'utf8') > MAX_JS_BYTES) return `js exceeds the ${MAX_JS_BYTES}-byte limit`;
|
|
47
|
+
for (const { re, message } of networkChecks) {
|
|
48
|
+
if (re.test(js)) return `js must not be network-capable: ${message}`;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function characterDir(projectRoot) {
|
|
54
|
+
return opsPath(projectRoot, 'project-pages', 'videos', '_character');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** -> {json, js} | null (absent or invalid). */
|
|
58
|
+
function readCharacter(projectRoot) {
|
|
59
|
+
try {
|
|
60
|
+
const dir = characterDir(projectRoot);
|
|
61
|
+
const jsonRaw = fs.readFileSync(path.join(dir, 'character.json'), 'utf8');
|
|
62
|
+
if (Buffer.byteLength(jsonRaw, 'utf8') > MAX_JSON_BYTES) return null;
|
|
63
|
+
const json = JSON.parse(jsonRaw);
|
|
64
|
+
if (validateCharacterJson(json)) return null;
|
|
65
|
+
const js = fs.readFileSync(path.join(dir, 'character.js'), 'utf8');
|
|
66
|
+
if (!js.trim()) return null;
|
|
67
|
+
return { json, js };
|
|
68
|
+
} catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Substitute {text}/{out} into each argv element; the argv is never joined. */
|
|
74
|
+
function buildCommandArgv(voice, text, out) {
|
|
75
|
+
return voice.command.map((a) => a.split('{text}').join(text).split('{out}').join(out));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Run the voice command (no shell). -> {ok, status, error?} */
|
|
79
|
+
function speakWithCommand(voice, text, out) {
|
|
80
|
+
if (!voice || voice.engine !== 'command' || validateCharacterJson({ name: 'x', palette: ['x'], voice })) {
|
|
81
|
+
return { ok: false, status: null, error: 'not a valid command voice' };
|
|
82
|
+
}
|
|
83
|
+
const [bin, ...args] = buildCommandArgv(voice, String(text), String(out));
|
|
84
|
+
const r = spawnSync(bin, args, { shell: false, stdio: 'ignore', timeout: COMMAND_TIMEOUT_MS });
|
|
85
|
+
if (r.error) return { ok: false, status: r.status, error: r.error.message };
|
|
86
|
+
return { ok: r.status === 0, status: r.status, ...(r.status === 0 ? {} : { error: `exit ${r.status}` }) };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports = {
|
|
90
|
+
readCharacter,
|
|
91
|
+
speakWithCommand,
|
|
92
|
+
buildCommandArgv,
|
|
93
|
+
validateCharacterJson,
|
|
94
|
+
validateCharacterJs,
|
|
95
|
+
characterDir,
|
|
96
|
+
MAX_JS_BYTES,
|
|
97
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Pure, dependency-free analyzers a demo-video builder must pass before saving.
|
|
3
|
+
// Node builtins only: this folder is copied to ~/.claude/session-manager/demo-video-kit/.
|
|
4
|
+
// Each check returns {id, ok, detail}. CLI: node checks.cjs <input.json> -> JSON, exit 1 on failure.
|
|
5
|
+
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
|
|
8
|
+
const BANNED_WORDS = Object.freeze([
|
|
9
|
+
'MCP', 'API', 'SDK', 'CLI', 'repo', 'cron', 'pipeline', 'automation', 'npm', 'pnpm', 'deploy',
|
|
10
|
+
'backend', 'frontend', 'local-first', 'headless', 'leverage', 'utilize', 'seamless', 'robust',
|
|
11
|
+
'facilitate', 'sign up now', "don't miss", 'game-changer', 'revolutionary', 'unlock', 'level up',
|
|
12
|
+
'supercharge', 'best-in-class', 'world-class', 'cutting-edge', 'limited time', 'act now',
|
|
13
|
+
'buy now', 'skyrocket', 'must-have',
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
const MAX_CAPTION_WORDS = 12;
|
|
17
|
+
const MAX_SENTENCE_WORDS = 14;
|
|
18
|
+
const MAX_GRADE = 8;
|
|
19
|
+
const VOICE_FIT_RATIO = 1.2;
|
|
20
|
+
const MIN_SPEECH_COVERAGE = 0.4;
|
|
21
|
+
const BLANK_AFTER_S = 0.5;
|
|
22
|
+
const DEFAULT_BLANK_STDDEV = 3;
|
|
23
|
+
const HTML_MB_PER_30S = 2 * 1024 * 1024;
|
|
24
|
+
|
|
25
|
+
const result = (id, ok, detail) => ({ id, ok: !!ok, detail });
|
|
26
|
+
const words = (s) => String(s || '').split(/\s+/).filter(Boolean);
|
|
27
|
+
const escRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
28
|
+
|
|
29
|
+
// Syllable heuristic: count vowel groups (aeiouy), drop a trailing silent "e"
|
|
30
|
+
// (but not "-le"), minimum 1 per word. Approximate, good enough for grade lint.
|
|
31
|
+
function countSyllables(word) {
|
|
32
|
+
let w = String(word).toLowerCase().replace(/[^a-z]/g, '');
|
|
33
|
+
if (!w) return 0;
|
|
34
|
+
if (w.length > 2 && /e$/.test(w) && !/[aeiouy]le$/.test(w) && !/[^aeiouy]le$/.test(w)) w = w.slice(0, -1);
|
|
35
|
+
const groups = w.match(/[aeiouy]+/g);
|
|
36
|
+
return Math.max(1, groups ? groups.length : 0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function splitSentences(text) {
|
|
40
|
+
return String(text || '').split(/[.!?]+(?:\s+|$)|\n+/).map((s) => s.trim()).filter((s) => words(s).length);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function checkCaptions(captions) {
|
|
44
|
+
const list = Array.isArray(captions) ? captions : [];
|
|
45
|
+
const bad = list.map((c, i) => ({ i, n: words(c).length })).filter((x) => x.n > MAX_CAPTION_WORDS);
|
|
46
|
+
return result('captions', bad.length === 0,
|
|
47
|
+
bad.length ? `caption(s) over ${MAX_CAPTION_WORDS} words: ${bad.map((b) => `#${b.i + 1} (${b.n})`).join(', ')}`
|
|
48
|
+
: `${list.length} caption(s) within ${MAX_CAPTION_WORDS} words`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function findBanned(text) {
|
|
52
|
+
const t = String(text || '');
|
|
53
|
+
return BANNED_WORDS.filter((b) => new RegExp(`(?<![A-Za-z0-9])${escRe(b)}(?![A-Za-z0-9])`, 'i').test(t));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function lintLanguage(text) {
|
|
57
|
+
const t = Array.isArray(text) ? text.join('. ') : String(text || '');
|
|
58
|
+
const problems = [];
|
|
59
|
+
const sentences = splitSentences(t);
|
|
60
|
+
const ws = words(t);
|
|
61
|
+
const long = sentences.filter((s) => words(s).length > MAX_SENTENCE_WORDS);
|
|
62
|
+
if (long.length) problems.push(`${long.length} sentence(s) over ${MAX_SENTENCE_WORDS} words`);
|
|
63
|
+
let grade = 0;
|
|
64
|
+
if (ws.length && sentences.length) {
|
|
65
|
+
const syl = ws.reduce((n, w) => n + countSyllables(w), 0);
|
|
66
|
+
grade = 0.39 * (ws.length / sentences.length) + 11.8 * (syl / ws.length) - 15.59;
|
|
67
|
+
if (grade > MAX_GRADE) problems.push(`Flesch-Kincaid grade ${grade.toFixed(1)} > ${MAX_GRADE}`);
|
|
68
|
+
}
|
|
69
|
+
const banned = findBanned(t);
|
|
70
|
+
if (banned.length) problems.push(`banned: ${banned.join(', ')}`);
|
|
71
|
+
return result('language', problems.length === 0,
|
|
72
|
+
problems.length ? problems.join('; ') : `grade ${grade.toFixed(1)}, sentences <= ${MAX_SENTENCE_WORDS} words, no banned words`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const SHELL_CMD = /(?<![A-Za-z0-9-])(npm|npx|pnpm|yarn|git|curl|wget|pip|pip3|brew|sudo|apt|docker)\s+[A-Za-z-]/i;
|
|
76
|
+
function checkClosing(closing) {
|
|
77
|
+
const t = String(closing || '');
|
|
78
|
+
const lead = /^\s*\$/.test(t) || /(^|\n)\s*\$\s/.test(t);
|
|
79
|
+
const m = t.match(SHELL_CMD);
|
|
80
|
+
const ok = !lead && !m;
|
|
81
|
+
return result('closing', ok, ok ? 'closing has no shell command' : `closing contains a shell command (${lead ? 'leading $' : m[0].trim()})`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// lines: [{text?, speechS, sceneS}]
|
|
85
|
+
function checkVoiceFit(lines) {
|
|
86
|
+
const list = Array.isArray(lines) ? lines : [];
|
|
87
|
+
const bad = list.map((l, i) => ({ i, r: l.sceneS > 0 ? l.speechS / l.sceneS : Infinity }))
|
|
88
|
+
.filter((x) => x.r > VOICE_FIT_RATIO);
|
|
89
|
+
return result('voiceFit', bad.length === 0,
|
|
90
|
+
bad.length ? `line(s) need more than ${VOICE_FIT_RATIO}x scene time: ${bad.map((b) => `#${b.i + 1} (${b.r.toFixed(2)}x)`).join(', ')}`
|
|
91
|
+
: `${list.length} line(s) fit within ${VOICE_FIT_RATIO}x`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function checkSpeechCoverage(speechS, lengthS) {
|
|
95
|
+
const total = Number(lengthS) || 0;
|
|
96
|
+
const ratio = total > 0 ? (Number(speechS) || 0) / total : 0;
|
|
97
|
+
return result('speechCoverage', ratio >= MIN_SPEECH_COVERAGE,
|
|
98
|
+
`speech covers ${(ratio * 100).toFixed(0)}% of ${total}s (min ${MIN_SPEECH_COVERAGE * 100}%)`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// frames: [{t, lumaStddev}]; frames after 0.5 s whose stddev < threshold are blank.
|
|
102
|
+
function checkBlankFrames(frames, threshold = DEFAULT_BLANK_STDDEV) {
|
|
103
|
+
const list = Array.isArray(frames) ? frames : [];
|
|
104
|
+
const bad = list.filter((f) => f.t > BLANK_AFTER_S && f.lumaStddev < threshold);
|
|
105
|
+
return result('blankFrames', bad.length === 0,
|
|
106
|
+
bad.length ? `blank frame(s) at ${bad.map((f) => `${f.t}s`).join(', ')}` : `${list.length} frame(s) non-blank`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function checkHtmlLimits({ html, bytes, lengthS } = {}) {
|
|
110
|
+
const h = String(html || '');
|
|
111
|
+
const size = Number.isFinite(bytes) ? bytes : Buffer.byteLength(h);
|
|
112
|
+
const cap = Math.ceil((Number(lengthS) || 0) / 30) * HTML_MB_PER_30S;
|
|
113
|
+
const problems = [];
|
|
114
|
+
if (size > cap) problems.push(`${size} bytes exceeds cap ${cap}`);
|
|
115
|
+
const dur = h.match(/<meta[^>]*name=["']sm-demo-duration["'][^>]*content=["']([^"']*)["']/i)
|
|
116
|
+
|| h.match(/<meta[^>]*content=["']([^"']*)["'][^>]*name=["']sm-demo-duration["']/i);
|
|
117
|
+
if (!dur) problems.push('sm-demo-duration meta missing');
|
|
118
|
+
else if (Number(dur[1]) !== Number(lengthS)) problems.push(`sm-demo-duration ${dur[1]} != ${lengthS}`);
|
|
119
|
+
if (!/window\.smDemo\s*=/.test(h) || !/scenes\s*:/.test(h)) problems.push('window.smDemo with scenes missing');
|
|
120
|
+
return result('htmlLimits', problems.length === 0, problems.length ? problems.join('; ') : `${size} bytes within cap ${cap}`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// input: {captions, narration (string|string[]), closing, lines, speechS, lengthS, frames, blankThreshold, html, bytes}
|
|
124
|
+
function runChecks(input = {}) {
|
|
125
|
+
const out = [];
|
|
126
|
+
if (input.captions) out.push(checkCaptions(input.captions));
|
|
127
|
+
if (input.narration != null) out.push(lintLanguage(input.narration));
|
|
128
|
+
if (input.closing != null) out.push(checkClosing(input.closing));
|
|
129
|
+
if (input.lines) out.push(checkVoiceFit(input.lines));
|
|
130
|
+
if (input.speechS != null) out.push(checkSpeechCoverage(input.speechS, input.lengthS));
|
|
131
|
+
if (input.frames) out.push(checkBlankFrames(input.frames, input.blankThreshold));
|
|
132
|
+
if (input.html != null) out.push(checkHtmlLimits({ html: input.html, bytes: input.bytes, lengthS: input.lengthS }));
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
module.exports = {
|
|
137
|
+
BANNED_WORDS, countSyllables, checkCaptions, lintLanguage, checkClosing, checkVoiceFit,
|
|
138
|
+
checkSpeechCoverage, checkBlankFrames, checkHtmlLimits, runChecks,
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
if (require.main === module) {
|
|
142
|
+
try {
|
|
143
|
+
const report = runChecks(JSON.parse(fs.readFileSync(process.argv[2], 'utf8')));
|
|
144
|
+
process.stdout.write(JSON.stringify(report, null, 2) + '\n');
|
|
145
|
+
process.exit(report.some((c) => !c.ok) ? 1 : 0);
|
|
146
|
+
} catch (e) {
|
|
147
|
+
process.stderr.write(`checks: ${e.message}\n`);
|
|
148
|
+
process.exit(2);
|
|
149
|
+
}
|
|
150
|
+
}
|