claudecode-omc 5.6.8 → 5.11.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/.local/settings/settings.json +8 -0
- package/.local/skills/prompt-optimizer/SKILL.md +262 -19
- package/.omc-curation/ecc-selection.json +80 -0
- package/.omc-curation/governance.json +116 -0
- package/.omc-curation/sources.lock.json +30 -0
- package/README.md +78 -4
- package/bundled/manifest.json +6 -5
- package/bundled/upstream/anthropic-skills/.omc-source/bundle.json +18 -0
- package/bundled/upstream/anthropic-skills/.omc-source/provenance.json +399 -0
- package/bundled/upstream/anthropic-skills/skills/claude-api/SKILL.md +18 -17
- package/bundled/upstream/anthropic-skills/skills/claude-api/curl/examples.md +9 -9
- package/bundled/upstream/anthropic-skills/skills/claude-api/curl/managed-agents.md +4 -4
- package/bundled/upstream/anthropic-skills/skills/claude-api/go/managed-agents/README.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/java/claude-api.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/java/managed-agents/README.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/php/claude-api.md +10 -10
- package/bundled/upstream/anthropic-skills/skills/claude-api/php/managed-agents/README.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/README.md +16 -16
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/batches.md +3 -3
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/files-api.md +3 -3
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/streaming.md +7 -7
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/tool-use.md +19 -19
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/managed-agents/README.md +3 -3
- package/bundled/upstream/anthropic-skills/skills/claude-api/ruby/claude-api.md +4 -4
- package/bundled/upstream/anthropic-skills/skills/claude-api/ruby/managed-agents/README.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/error-codes.md +5 -5
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/live-sources.md +3 -1
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-api-reference.md +10 -4
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-core.md +19 -1
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-environments.md +6 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-multiagent.md +1 -1
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-onboarding.md +3 -3
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-overview.md +3 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-self-hosted-sandboxes.md +173 -0
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-tools.md +10 -4
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/model-migration.md +113 -13
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/models.md +14 -11
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/prompt-caching.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/tool-use-concepts.md +4 -4
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/README.md +15 -15
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/batches.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/files-api.md +1 -1
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/streaming.md +5 -5
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/tool-use.md +15 -15
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/managed-agents/README.md +3 -3
- package/bundled/upstream/ecc/.omc-source/bundle.json +2 -1
- package/bundled/upstream/ecc/.omc-source/last-plan-apply.json +108 -24
- package/bundled/upstream/ecc/.omc-source/manifests/.claude-plugin/marketplace.json +3 -3
- package/bundled/upstream/ecc/.omc-source/provenance.json +563 -0
- package/bundled/upstream/ecc/agents/marketing-agent.md +159 -0
- package/bundled/upstream/ecc/agents/react-build-resolver.md +215 -0
- package/bundled/upstream/ecc/agents/react-reviewer.md +167 -0
- package/bundled/upstream/ecc/agents/typescript-reviewer.md +3 -0
- package/bundled/upstream/ecc/commands/harness-audit.md +17 -10
- package/bundled/upstream/ecc/commands/marketing-campaign.md +129 -0
- package/bundled/upstream/ecc/commands/react-build.md +187 -0
- package/bundled/upstream/ecc/commands/react-review.md +170 -0
- package/bundled/upstream/ecc/commands/react-test.md +265 -0
- package/bundled/upstream/ecc/skills/benchmark-optimization-loop/SKILL.md +69 -0
- package/bundled/upstream/ecc/skills/blender-motion-state-inspection/SKILL.md +164 -0
- package/bundled/upstream/ecc/skills/canary-watch/SKILL.md +9 -1
- package/bundled/upstream/ecc/skills/continuous-learning-v2/hooks/observe.sh +31 -9
- package/bundled/upstream/ecc/skills/continuous-learning-v2/scripts/detect-project.sh +38 -4
- package/bundled/upstream/ecc/skills/continuous-learning-v2/scripts/instinct-cli.py +319 -12
- package/bundled/upstream/ecc/skills/data-throughput-accelerator/SKILL.md +72 -0
- package/bundled/upstream/ecc/skills/dynamic-workflow-mode/SKILL.md +123 -0
- package/bundled/upstream/ecc/skills/frontend-a11y/SKILL.md +446 -0
- package/bundled/upstream/ecc/skills/ito-basket-compare/SKILL.md +63 -0
- package/bundled/upstream/ecc/skills/ito-data-atlas-agent/SKILL.md +63 -0
- package/bundled/upstream/ecc/skills/ito-market-intelligence/SKILL.md +60 -0
- package/bundled/upstream/ecc/skills/ito-trade-planner/SKILL.md +67 -0
- package/bundled/upstream/ecc/skills/latency-critical-systems/SKILL.md +73 -0
- package/bundled/upstream/ecc/skills/marketing-campaign/SKILL.md +113 -0
- package/bundled/upstream/ecc/skills/nextjs-turbopack/SKILL.md +13 -0
- package/bundled/upstream/ecc/skills/parallel-execution-optimizer/SKILL.md +72 -0
- package/bundled/upstream/ecc/skills/prediction-market-oracle-research/SKILL.md +63 -0
- package/bundled/upstream/ecc/skills/prediction-market-risk-review/SKILL.md +60 -0
- package/bundled/upstream/ecc/skills/react-patterns/SKILL.md +341 -0
- package/bundled/upstream/ecc/skills/react-performance/SKILL.md +574 -0
- package/bundled/upstream/ecc/skills/react-testing/SKILL.md +423 -0
- package/bundled/upstream/ecc/skills/recsys-pipeline-architect/SKILL.md +114 -0
- package/bundled/upstream/ecc/skills/recursive-decision-ledger/SKILL.md +79 -0
- package/bundled/upstream/ecc/skills/social-publisher/SKILL.md +115 -0
- package/bundled/upstream/ecc/skills/team-agent-orchestration/SKILL.md +110 -0
- package/bundled/upstream/ecc/skills/uncloud/SKILL.md +343 -0
- package/bundled/upstream/ecc/skills/windows-desktop-e2e/SKILL.md +99 -0
- package/bundled/upstream/impeccable/.omc-source/bundle.json +20 -0
- package/bundled/upstream/impeccable/.omc-source/provenance.json +105 -0
- package/bundled/upstream/impeccable/agents/impeccable-manual-edit-applier.md +97 -0
- package/bundled/upstream/impeccable/skills/impeccable/SKILL.md +168 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/adapt.md +311 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/animate.md +201 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/audit.md +133 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/bolder.md +113 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/brand.md +108 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/clarify.md +288 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/codex.md +105 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/colorize.md +257 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/craft.md +123 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/critique.md +767 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/delight.md +302 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/distill.md +111 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/document.md +429 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/extract.md +69 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/harden.md +347 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/hooks.md +88 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/init.md +172 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/interaction-design.md +189 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/layout.md +161 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/live.md +718 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/onboard.md +234 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/optimize.md +258 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/overdrive.md +130 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/polish.md +241 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/product.md +60 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/quieter.md +99 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/shape.md +165 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/typeset.md +279 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/command-metadata.json +94 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/context-signals.mjs +225 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/context.mjs +280 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/critique-storage.mjs +242 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detect-csp.mjs +198 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detect.mjs +21 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/browser/injected/index.mjs +1735 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/cli/main.mjs +244 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +4907 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/detect-antipatterns.mjs +43 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +252 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +552 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +1013 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +208 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +189 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/findings.mjs +12 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/node/file-system.mjs +198 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/profile/profiler.mjs +166 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/registry/antipatterns.mjs +419 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/rules/checks.mjs +2671 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/shared/color.mjs +124 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/shared/constants.mjs +101 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/shared/page.mjs +7 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/hook-admin.mjs +574 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/hook-before-edit.mjs +473 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/hook-lib.mjs +1286 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/hook.mjs +61 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/lib/design-parser.mjs +835 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/lib/impeccable-paths.mjs +126 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/lib/is-generated.mjs +69 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/browser-script-parts.mjs +49 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/completion.mjs +19 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/event-validation.mjs +137 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/insert-ui.mjs +458 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/manual-apply.mjs +939 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/manual-edit-routes.mjs +357 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/manual-edits-buffer.mjs +152 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/session-store.mjs +289 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/svelte-component.mjs +826 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/sveltekit-adapter.mjs +274 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/ui-core.mjs +180 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/vocabulary.mjs +36 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-accept.mjs +812 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-browser-dom.js +146 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-browser-session.js +123 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-browser.js +11086 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-commit-manual-edits.mjs +1241 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-complete.mjs +75 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-copy-edit-agent.mjs +683 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-discard-manual-edits.mjs +51 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-inject.mjs +583 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-insert.mjs +272 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-manual-edit-evidence.mjs +363 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-poll.mjs +379 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-resume.mjs +94 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-server.mjs +1134 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-status.mjs +61 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-wrap.mjs +894 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live.mjs +246 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/palette.mjs +633 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/pin.mjs +214 -0
- package/bundled/upstream/oh-my-claudecode/.omc-source/bundle.json +2 -1
- package/bundled/upstream/oh-my-claudecode/.omc-source/provenance.json +116 -0
- package/bundled/upstream/oh-my-claudecode/skills/autopilot/SKILL.md +7 -0
- package/bundled/upstream/oh-my-claudecode/skills/cancel/SKILL.md +1 -0
- package/bundled/upstream/oh-my-claudecode/skills/deep-interview/SKILL.md +39 -5
- package/bundled/upstream/oh-my-claudecode/skills/hud/SKILL.md +1 -0
- package/bundled/upstream/oh-my-claudecode/skills/local-build-reminder/SKILL.md +78 -0
- package/bundled/upstream/oh-my-claudecode/skills/omc-doctor/SKILL.md +1 -1
- package/bundled/upstream/oh-my-claudecode/skills/omc-setup/SKILL.md +26 -10
- package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/01-install-claude-md.md +3 -3
- package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/02-configure.md +6 -4
- package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/03-integrations.md +1 -1
- package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/04-welcome.md +2 -2
- package/bundled/upstream/oh-my-claudecode/skills/omc-teams/SKILL.md +6 -6
- package/bundled/upstream/oh-my-claudecode/skills/plan/SKILL.md +44 -32
- package/bundled/upstream/oh-my-claudecode/skills/ralph/SKILL.md +45 -21
- package/bundled/upstream/oh-my-claudecode/skills/ralplan/SKILL.md +1 -1
- package/bundled/upstream/oh-my-claudecode/skills/self-improve/SKILL.md +7 -0
- package/bundled/upstream/oh-my-claudecode/skills/self-improve/scripts/resolve-paths.mjs +39 -15
- package/bundled/upstream/oh-my-claudecode/skills/team/SKILL.md +132 -90
- package/bundled/upstream/oh-my-claudecode/skills/ultragoal/SKILL.md +93 -0
- package/bundled/upstream/oh-my-claudecode/skills/ultraqa/SKILL.md +28 -13
- package/bundled/upstream/oh-my-claudecode/skills/ultrawork/SKILL.md +7 -0
- package/bundled/upstream/superpowers/.omc-source/bundle.json +2 -1
- package/bundled/upstream/superpowers/.omc-source/provenance.json +63 -0
- package/package.json +2 -1
- package/src/catalog/source-catalog.js +10 -4
- package/src/cli/index.js +4 -0
- package/src/cli/plan.js +14 -2
- package/src/cli/setup.js +52 -13
- package/src/cli/skill.js +1 -1
- package/src/cli/source.js +271 -14
- package/src/config/sources.js +82 -1
- package/src/merge/content-patch.js +88 -0
- package/templates/merge-config.json +1 -8
- package/bundled/upstream/ecc/skills/strategic-compact/suggest-compact.sh +0 -54
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { getLegacyLiveSessionsDir, getLiveSessionsDir } from '../lib/impeccable-paths.mjs';
|
|
4
|
+
|
|
5
|
+
const COMPLETED_PHASES = new Set(['completed', 'discarded']);
|
|
6
|
+
|
|
7
|
+
export function createLiveSessionStore({ cwd = process.cwd(), sessionId } = {}) {
|
|
8
|
+
const rootDir = getLiveSessionsDir(cwd);
|
|
9
|
+
const legacyRootDir = getLegacyLiveSessionsDir(cwd);
|
|
10
|
+
fs.mkdirSync(rootDir, { recursive: true });
|
|
11
|
+
const snapshotCache = new Map();
|
|
12
|
+
|
|
13
|
+
function loadCachedOrRebuild(id) {
|
|
14
|
+
const cached = snapshotCache.get(id);
|
|
15
|
+
if (cached) return cached;
|
|
16
|
+
const journalPath = getReadableJournalPath(id);
|
|
17
|
+
const rebuilt = rebuildSnapshotFromJournal(journalPath, id);
|
|
18
|
+
snapshotCache.set(id, rebuilt);
|
|
19
|
+
return rebuilt;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getReadableJournalPath(id) {
|
|
23
|
+
const primary = getJournalPath(rootDir, id);
|
|
24
|
+
if (fs.existsSync(primary)) return primary;
|
|
25
|
+
const legacy = getJournalPath(legacyRootDir, id);
|
|
26
|
+
if (fs.existsSync(legacy)) return legacy;
|
|
27
|
+
return primary;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
rootDir,
|
|
32
|
+
legacyRootDir,
|
|
33
|
+
appendEvent(event) {
|
|
34
|
+
const normalized = normalizeEvent(event, sessionId);
|
|
35
|
+
const journalPath = getJournalPath(rootDir, normalized.id);
|
|
36
|
+
const snapshotPath = getSnapshotPath(rootDir, normalized.id);
|
|
37
|
+
const legacyJournalPath = getJournalPath(legacyRootDir, normalized.id);
|
|
38
|
+
if (!fs.existsSync(journalPath) && fs.existsSync(legacyJournalPath)) {
|
|
39
|
+
fs.copyFileSync(legacyJournalPath, journalPath);
|
|
40
|
+
}
|
|
41
|
+
const prior = loadCachedOrRebuild(normalized.id);
|
|
42
|
+
const seq = prior.nextSeq;
|
|
43
|
+
const entry = {
|
|
44
|
+
seq,
|
|
45
|
+
id: normalized.id,
|
|
46
|
+
type: normalized.type,
|
|
47
|
+
ts: new Date().toISOString(),
|
|
48
|
+
event: normalized,
|
|
49
|
+
};
|
|
50
|
+
fs.appendFileSync(journalPath, JSON.stringify(entry) + '\n');
|
|
51
|
+
const next = applyEvent(prior.snapshot, entry, prior.diagnostics);
|
|
52
|
+
snapshotCache.set(normalized.id, { snapshot: next, diagnostics: next.diagnostics || [], nextSeq: seq + 1 });
|
|
53
|
+
writeSnapshot(snapshotPath, next);
|
|
54
|
+
return next;
|
|
55
|
+
},
|
|
56
|
+
getSnapshot(id = sessionId, opts = {}) {
|
|
57
|
+
if (!id) throw new Error('session id required');
|
|
58
|
+
const journalPath = getReadableJournalPath(id);
|
|
59
|
+
const snapshotPath = getSnapshotPath(rootDir, id);
|
|
60
|
+
const rebuilt = rebuildSnapshotFromJournal(journalPath, id);
|
|
61
|
+
snapshotCache.set(id, rebuilt);
|
|
62
|
+
writeSnapshot(snapshotPath, rebuilt.snapshot);
|
|
63
|
+
if (!opts.includeCompleted && COMPLETED_PHASES.has(rebuilt.snapshot.phase)) return null;
|
|
64
|
+
return rebuilt.snapshot;
|
|
65
|
+
},
|
|
66
|
+
listActiveSessions() {
|
|
67
|
+
const ids = new Set();
|
|
68
|
+
for (const dir of [legacyRootDir, rootDir]) {
|
|
69
|
+
if (!fs.existsSync(dir)) continue;
|
|
70
|
+
for (const name of fs.readdirSync(dir)) {
|
|
71
|
+
if (name.endsWith('.jsonl')) ids.add(name.slice(0, -'.jsonl'.length));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return [...ids]
|
|
75
|
+
.sort()
|
|
76
|
+
.map((id) => this.getSnapshot(id))
|
|
77
|
+
.filter(Boolean);
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function normalizeEvent(event, fallbackId) {
|
|
83
|
+
if (!event || typeof event !== 'object') throw new Error('event object required');
|
|
84
|
+
const id = event.id || fallbackId;
|
|
85
|
+
if (!id || typeof id !== 'string') throw new Error('event id required');
|
|
86
|
+
if (!event.type || typeof event.type !== 'string') throw new Error('event type required');
|
|
87
|
+
return { ...event, id };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function getJournalPath(rootDir, id) {
|
|
91
|
+
return path.join(rootDir, safeSessionId(id) + '.jsonl');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function getSnapshotPath(rootDir, id) {
|
|
95
|
+
return path.join(rootDir, safeSessionId(id) + '.snapshot.json');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function safeSessionId(id) {
|
|
99
|
+
if (!/^[A-Za-z0-9_-]{1,128}$/.test(id)) throw new Error('invalid session id: ' + id);
|
|
100
|
+
return id;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function baseSnapshot(id) {
|
|
104
|
+
return {
|
|
105
|
+
id,
|
|
106
|
+
phase: 'new',
|
|
107
|
+
pageUrl: null,
|
|
108
|
+
sourceFile: null,
|
|
109
|
+
previewFile: null,
|
|
110
|
+
previewMode: null,
|
|
111
|
+
expectedVariants: 0,
|
|
112
|
+
arrivedVariants: 0,
|
|
113
|
+
visibleVariant: null,
|
|
114
|
+
paramValues: {},
|
|
115
|
+
pendingEventSeq: null,
|
|
116
|
+
pendingEvent: null,
|
|
117
|
+
deliveryLease: null,
|
|
118
|
+
checkpointRevision: 0,
|
|
119
|
+
activeOwner: null,
|
|
120
|
+
sourceMarkers: {},
|
|
121
|
+
fallbackMode: null,
|
|
122
|
+
annotationArtifacts: [],
|
|
123
|
+
diagnostics: [],
|
|
124
|
+
updatedAt: null,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function rebuildSnapshotFromJournal(journalPath, id) {
|
|
129
|
+
let snapshot = baseSnapshot(id);
|
|
130
|
+
const diagnostics = [];
|
|
131
|
+
let nextSeq = 1;
|
|
132
|
+
if (!fs.existsSync(journalPath)) return { snapshot, diagnostics, nextSeq };
|
|
133
|
+
|
|
134
|
+
const lines = fs.readFileSync(journalPath, 'utf-8').split('\n');
|
|
135
|
+
for (let i = 0; i < lines.length; i++) {
|
|
136
|
+
const line = lines[i];
|
|
137
|
+
if (!line.trim()) continue;
|
|
138
|
+
try {
|
|
139
|
+
const entry = JSON.parse(line);
|
|
140
|
+
if (!entry || typeof entry !== 'object') throw new Error('entry is not object');
|
|
141
|
+
if (Number.isInteger(entry.seq)) nextSeq = Math.max(nextSeq, entry.seq + 1);
|
|
142
|
+
snapshot = applyEvent(snapshot, entry);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
diagnostics.push({
|
|
145
|
+
error: 'journal_parse_failed',
|
|
146
|
+
line: i + 1,
|
|
147
|
+
message: err.message,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
snapshot.diagnostics = [...snapshot.diagnostics, ...diagnostics];
|
|
152
|
+
return { snapshot, diagnostics, nextSeq };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function applyEvent(snapshot, entry, inheritedDiagnostics = []) {
|
|
156
|
+
const event = entry.event || entry;
|
|
157
|
+
const next = {
|
|
158
|
+
...snapshot,
|
|
159
|
+
paramValues: { ...(snapshot.paramValues || {}) },
|
|
160
|
+
sourceMarkers: { ...(snapshot.sourceMarkers || {}) },
|
|
161
|
+
annotationArtifacts: [...(snapshot.annotationArtifacts || [])],
|
|
162
|
+
diagnostics: [...(snapshot.diagnostics || [])],
|
|
163
|
+
updatedAt: entry.ts || new Date().toISOString(),
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
if (inheritedDiagnostics.length && next.diagnostics.length === 0) {
|
|
167
|
+
next.diagnostics = [...inheritedDiagnostics];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
switch (event.type) {
|
|
171
|
+
case 'generate':
|
|
172
|
+
next.phase = 'generate_requested';
|
|
173
|
+
next.pageUrl = event.pageUrl ?? next.pageUrl;
|
|
174
|
+
next.expectedVariants = event.count ?? next.expectedVariants;
|
|
175
|
+
next.pendingEventSeq = entry.seq ?? next.pendingEventSeq;
|
|
176
|
+
next.pendingEvent = toPendingEvent(event);
|
|
177
|
+
if (event.screenshotPath) upsertArtifact(next.annotationArtifacts, { type: 'screenshot', path: event.screenshotPath });
|
|
178
|
+
break;
|
|
179
|
+
case 'variants_ready':
|
|
180
|
+
case 'agent_done':
|
|
181
|
+
next.phase = event.carbonize === true ? 'carbonize_required' : 'variants_ready';
|
|
182
|
+
next.sourceFile = event.sourceFile ?? event.file ?? next.sourceFile;
|
|
183
|
+
next.previewFile = event.previewFile ?? next.previewFile;
|
|
184
|
+
next.previewMode = event.previewMode ?? next.previewMode;
|
|
185
|
+
next.arrivedVariants = event.arrivedVariants ?? (next.expectedVariants || next.arrivedVariants || 0);
|
|
186
|
+
next.pendingEventSeq = null;
|
|
187
|
+
next.pendingEvent = null;
|
|
188
|
+
if (event.carbonize === true) {
|
|
189
|
+
next.diagnostics.push({
|
|
190
|
+
error: 'carbonize_cleanup_required',
|
|
191
|
+
file: event.file || null,
|
|
192
|
+
message: 'Accepted variant still has carbonize markers that must be folded into source CSS.',
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
break;
|
|
196
|
+
case 'checkpoint':
|
|
197
|
+
if (COMPLETED_PHASES.has(next.phase)) {
|
|
198
|
+
next.diagnostics.push({ error: 'checkpoint_after_terminal_ignored', phase: event.phase ?? null, revision: event.revision ?? null });
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
if ((event.revision ?? 0) >= (next.checkpointRevision ?? 0)) {
|
|
202
|
+
next.phase = event.phase ?? next.phase;
|
|
203
|
+
next.checkpointRevision = event.revision ?? next.checkpointRevision;
|
|
204
|
+
next.activeOwner = event.owner ?? next.activeOwner;
|
|
205
|
+
next.arrivedVariants = event.arrivedVariants ?? next.arrivedVariants;
|
|
206
|
+
next.visibleVariant = event.visibleVariant ?? next.visibleVariant;
|
|
207
|
+
next.sourceFile = event.sourceFile ?? next.sourceFile;
|
|
208
|
+
next.previewFile = event.previewFile ?? next.previewFile;
|
|
209
|
+
next.previewMode = event.previewMode ?? next.previewMode;
|
|
210
|
+
if (event.paramValues) next.paramValues = { ...event.paramValues };
|
|
211
|
+
} else {
|
|
212
|
+
next.diagnostics.push({ error: 'stale_checkpoint_ignored', revision: event.revision });
|
|
213
|
+
}
|
|
214
|
+
break;
|
|
215
|
+
case 'accept':
|
|
216
|
+
case 'accept_intent':
|
|
217
|
+
next.phase = 'accept_requested';
|
|
218
|
+
next.visibleVariant = Number(event.variantId ?? next.visibleVariant);
|
|
219
|
+
if (event.paramValues) next.paramValues = { ...event.paramValues };
|
|
220
|
+
next.pendingEventSeq = entry.seq ?? next.pendingEventSeq;
|
|
221
|
+
next.pendingEvent = toPendingEvent(event);
|
|
222
|
+
break;
|
|
223
|
+
case 'manual_edit_apply':
|
|
224
|
+
next.phase = 'manual_edit_apply_requested';
|
|
225
|
+
next.pageUrl = event.pageUrl ?? next.pageUrl;
|
|
226
|
+
next.pendingEventSeq = entry.seq ?? next.pendingEventSeq;
|
|
227
|
+
next.pendingEvent = toPendingEvent(event);
|
|
228
|
+
break;
|
|
229
|
+
case 'steer':
|
|
230
|
+
next.phase = 'steer_requested';
|
|
231
|
+
next.pageUrl = event.pageUrl ?? next.pageUrl;
|
|
232
|
+
next.pendingEventSeq = entry.seq ?? next.pendingEventSeq;
|
|
233
|
+
next.pendingEvent = toPendingEvent(event);
|
|
234
|
+
break;
|
|
235
|
+
case 'steer_done':
|
|
236
|
+
next.phase = 'steer_done';
|
|
237
|
+
next.sourceFile = event.sourceFile ?? event.file ?? next.sourceFile;
|
|
238
|
+
next.previewFile = event.previewFile ?? next.previewFile;
|
|
239
|
+
next.previewMode = event.previewMode ?? next.previewMode;
|
|
240
|
+
next.message = event.message ?? next.message;
|
|
241
|
+
next.pendingEventSeq = null;
|
|
242
|
+
next.pendingEvent = null;
|
|
243
|
+
break;
|
|
244
|
+
case 'discard':
|
|
245
|
+
next.phase = 'discard_requested';
|
|
246
|
+
next.pendingEventSeq = entry.seq ?? next.pendingEventSeq;
|
|
247
|
+
next.pendingEvent = toPendingEvent(event);
|
|
248
|
+
break;
|
|
249
|
+
case 'discarded':
|
|
250
|
+
next.phase = 'discarded';
|
|
251
|
+
next.pendingEventSeq = null;
|
|
252
|
+
next.pendingEvent = null;
|
|
253
|
+
break;
|
|
254
|
+
case 'complete':
|
|
255
|
+
next.phase = 'completed';
|
|
256
|
+
next.sourceFile = event.sourceFile ?? event.file ?? next.sourceFile;
|
|
257
|
+
next.previewFile = event.previewFile ?? next.previewFile;
|
|
258
|
+
next.previewMode = event.previewMode ?? next.previewMode;
|
|
259
|
+
next.pendingEventSeq = null;
|
|
260
|
+
next.pendingEvent = null;
|
|
261
|
+
break;
|
|
262
|
+
case 'agent_error':
|
|
263
|
+
next.phase = 'agent_error';
|
|
264
|
+
next.pendingEventSeq = null;
|
|
265
|
+
next.pendingEvent = null;
|
|
266
|
+
next.diagnostics.push({ error: 'agent_error', message: event.message || 'unknown agent error' });
|
|
267
|
+
break;
|
|
268
|
+
default:
|
|
269
|
+
next.diagnostics.push({ error: 'unknown_event_type', type: event.type });
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
return next;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function toPendingEvent(event) {
|
|
276
|
+
const pending = { ...event };
|
|
277
|
+
delete pending.token;
|
|
278
|
+
return pending;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function upsertArtifact(artifacts, artifact) {
|
|
282
|
+
if (!artifacts.some((existing) => existing.path === artifact.path && existing.type === artifact.type)) {
|
|
283
|
+
artifacts.push(artifact);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function writeSnapshot(snapshotPath, snapshot) {
|
|
288
|
+
fs.writeFileSync(snapshotPath, JSON.stringify(snapshot, null, 2) + '\n');
|
|
289
|
+
}
|