@oriro/orirocli 0.1.8 → 0.1.11
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/ATTRIBUTION.md +53 -45
- package/LICENSE +21 -0
- package/README.md +20 -17
- package/dist/cli.js +4425 -2975
- package/package.json +64 -64
- package/skills/1password/SKILL.md +118 -118
- package/skills/1password/references/cli-examples.md +29 -29
- package/skills/1password/references/get-started.md +21 -21
- package/skills/21stdev/SKILL.md +64 -0
- package/skills/algorithmic-art/LICENSE +21 -21
- package/skills/algorithmic-art/SKILL.md +446 -446
- package/skills/algorithmic-art/templates/generator_template.js +223 -223
- package/skills/algorithmic-art/templates/viewer.html +598 -598
- package/skills/apple-notes/SKILL.md +81 -81
- package/skills/apple-reminders/SKILL.md +122 -122
- package/skills/bear-notes/SKILL.md +111 -111
- package/skills/blogwatcher/SKILL.md +73 -73
- package/skills/blucli/SKILL.md +51 -51
- package/skills/brand-guidelines/LICENSE +21 -21
- package/skills/brand-guidelines/SKILL.md +76 -76
- package/skills/business/biz-analysis/LICENSE +21 -21
- package/skills/business/biz-analysis/SKILL.md +103 -103
- package/skills/business/biz-corporate-strategy/LICENSE +21 -21
- package/skills/business/biz-corporate-strategy/SKILL.md +76 -76
- package/skills/business/biz-customer-success/LICENSE +21 -21
- package/skills/business/biz-customer-success/SKILL.md +55 -55
- package/skills/business/biz-entrepreneurship/LICENSE +21 -21
- package/skills/business/biz-entrepreneurship/SKILL.md +72 -72
- package/skills/business/biz-hr/LICENSE +21 -21
- package/skills/business/biz-hr/SKILL.md +67 -67
- package/skills/business/biz-international/LICENSE +21 -21
- package/skills/business/biz-international/SKILL.md +51 -51
- package/skills/business/biz-leadership/LICENSE +21 -21
- package/skills/business/biz-leadership/SKILL.md +106 -106
- package/skills/business/biz-marketing-strategy/LICENSE +21 -21
- package/skills/business/biz-marketing-strategy/SKILL.md +119 -119
- package/skills/business/biz-negotiation/LICENSE +21 -21
- package/skills/business/biz-negotiation/SKILL.md +152 -152
- package/skills/business/biz-operations/LICENSE +21 -21
- package/skills/business/biz-operations/SKILL.md +74 -74
- package/skills/business/biz-project/LICENSE +21 -21
- package/skills/business/biz-project/SKILL.md +203 -203
- package/skills/business/biz-risk/LICENSE +21 -21
- package/skills/business/biz-risk/SKILL.md +85 -85
- package/skills/business/biz-sales/LICENSE +21 -21
- package/skills/business/biz-sales/SKILL.md +92 -92
- package/skills/business/biz-startup-ops/LICENSE +21 -21
- package/skills/business/biz-startup-ops/SKILL.md +70 -70
- package/skills/business/biz-strategy/LICENSE +21 -21
- package/skills/business/biz-strategy/SKILL.md +233 -233
- package/skills/business/biz-supply-chain-advanced/LICENSE +21 -21
- package/skills/business/biz-supply-chain-advanced/SKILL.md +68 -68
- package/skills/business/fin-chartered-exams/LICENSE +21 -21
- package/skills/business/fin-chartered-exams/SKILL.md +69 -69
- package/skills/camsnap/SKILL.md +49 -49
- package/skills/canvas/SKILL.md +82 -82
- package/skills/canvas-design/LICENSE +21 -21
- package/skills/canvas-design/SKILL.md +140 -140
- package/skills/canvas-design/canvas-fonts/ArsenalSC-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/BigShoulders-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/Boldonse-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/BricolageGrotesque-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/CrimsonPro-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/DMMono-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/EricaOne-OFL.txt +94 -94
- package/skills/canvas-design/canvas-fonts/GeistMono-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/Gloock-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/IBMPlexMono-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/InstrumentSans-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/JetBrainsMono-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/Jura-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/LibreBaskerville-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/Lora-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/NationalPark-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/Outfit-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/PixelifySans-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/RedHatMono-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/Silkscreen-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/SmoochSans-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/Tektur-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/WorkSans-OFL.txt +93 -93
- package/skills/canvas-design/canvas-fonts/YoungSerif-OFL.txt +93 -93
- package/skills/coding-agent/SKILL.md +146 -146
- package/skills/communication/comm-business-writing/LICENSE +21 -21
- package/skills/communication/comm-business-writing/SKILL.md +67 -67
- package/skills/communication/comm-cross-cultural/LICENSE +21 -21
- package/skills/communication/comm-cross-cultural/SKILL.md +88 -88
- package/skills/communication/comm-journalism/LICENSE +21 -21
- package/skills/communication/comm-journalism/SKILL.md +81 -81
- package/skills/communication/comm-linguistics/LICENSE +21 -21
- package/skills/communication/comm-linguistics/SKILL.md +82 -82
- package/skills/communication/comm-negotiation/LICENSE +21 -21
- package/skills/communication/comm-negotiation/SKILL.md +120 -120
- package/skills/communication/comm-presentations/LICENSE +21 -21
- package/skills/communication/comm-presentations/SKILL.md +93 -93
- package/skills/communication/comm-public-speaking/LICENSE +21 -21
- package/skills/communication/comm-public-speaking/SKILL.md +68 -68
- package/skills/communication/comm-writing/LICENSE +21 -21
- package/skills/communication/comm-writing/SKILL.md +69 -69
- package/skills/craft/ai-engineering/LICENSE +21 -21
- package/skills/craft/ai-engineering/SKILL.md +828 -828
- package/skills/craft/app-builder-guide/LICENSE +21 -21
- package/skills/craft/app-builder-guide/SKILL.md +332 -332
- package/skills/craft/become-an-ai-engineer-26/CONTRIBUTING.md +46 -46
- package/skills/craft/become-an-ai-engineer-26/LICENSE +21 -21
- package/skills/craft/become-an-ai-engineer-26/README.md +270 -270
- package/skills/craft/become-an-ai-engineer-26/SKILL.md +667 -667
- package/skills/craft/become-an-ai-engineer-26/community/BUILDS.md +13 -13
- package/skills/craft/become-an-ai-engineer-26/community/DISCUSSIONS.md +8 -8
- package/skills/craft/become-an-ai-engineer-26/phases/phase-0-mental-models/README.md +14 -14
- package/skills/craft/become-an-ai-engineer-26/phases/phase-0-mental-models/project/TEMPLATE.md +33 -33
- package/skills/craft/become-an-ai-engineer-26/phases/phase-1-first-agent/README.md +25 -25
- package/skills/craft/become-an-ai-engineer-26/phases/phase-1-first-agent/code/raw_loop.py +126 -126
- package/skills/craft/become-an-ai-engineer-26/phases/phase-2-architecture/README.md +17 -17
- package/skills/craft/become-an-ai-engineer-26/phases/phase-3-harness/README.md +17 -17
- package/skills/craft/become-an-ai-engineer-26/phases/phase-4-evals/README.md +21 -21
- package/skills/craft/become-an-ai-engineer-26/phases/phase-4-evals/code/.github/workflows/eval.yml +40 -40
- package/skills/craft/become-an-ai-engineer-26/phases/phase-5-production/README.md +16 -16
- package/skills/craft/become-an-ai-engineer-26/projects/1-mobile-app-slm/README.md +11 -11
- package/skills/craft/become-an-ai-engineer-26/projects/2-self-improving-coder/README.md +11 -11
- package/skills/craft/become-an-ai-engineer-26/projects/3-video-editor-agent/README.md +11 -11
- package/skills/craft/become-an-ai-engineer-26/projects/4-personal-life-os/README.md +12 -12
- package/skills/craft/become-an-ai-engineer-26/projects/5-enterprise-workflow/README.md +12 -12
- package/skills/craft/become-an-ai-engineer-26/references/benchmark-numbers.md +41 -41
- package/skills/craft/become-an-ai-engineer-26/references/mhc-stable-training.md +73 -73
- package/skills/craft/become-an-ai-engineer-26/references/stack-decisions.md +37 -37
- package/skills/craft/become-an-ai-engineer-26/references/yarn-context-extension.md +123 -123
- package/skills/craft/codex-result-handling/LICENSE +21 -21
- package/skills/craft/codex-result-handling/SKILL.md +26 -26
- package/skills/craft/debug-and-build-methodology/LICENSE +21 -21
- package/skills/craft/debug-and-build-methodology/SKILL.md +432 -432
- package/skills/craft/design/LICENSE +21 -21
- package/skills/craft/design/SKILL.md +274 -274
- package/skills/craft/dev/LICENSE +21 -21
- package/skills/craft/dev/SKILL.md +12 -12
- package/skills/craft/dev/release.md +85 -85
- package/skills/craft/dev/roll.md +50 -50
- package/skills/craft/doc-coauthoring/LICENSE +21 -21
- package/skills/craft/doc-coauthoring/SKILL.md +397 -397
- package/skills/craft/focus/LICENSE +21 -21
- package/skills/craft/focus/SKILL.md +432 -432
- package/skills/craft/focus/UPSTREAM_README.md +233 -233
- package/skills/craft/gh/LICENSE +21 -21
- package/skills/craft/gh/SKILL.md +84 -84
- package/skills/craft/gh-skill/LICENSE +21 -21
- package/skills/craft/gh-skill/SKILL.md +121 -121
- package/skills/craft/godmode/LICENSE +21 -21
- package/skills/craft/godmode/SKILL.md +87 -87
- package/skills/craft/godmode/references/android-launch.md +680 -680
- package/skills/craft/godmode/references/data-gcp.md +1038 -1038
- package/skills/craft/godmode/references/expo-eas.md +816 -816
- package/skills/craft/godmode/references/ios-launch.md +734 -734
- package/skills/craft/google-ai-latest/LICENSE +21 -21
- package/skills/craft/google-ai-latest/SKILL.md +682 -682
- package/skills/craft/gpt-5-4-prompting/LICENSE +21 -21
- package/skills/craft/gpt-5-4-prompting/SKILL.md +63 -63
- package/skills/craft/gpt-5-4-prompting/references/codex-prompt-antipatterns.md +101 -101
- package/skills/craft/gpt-5-4-prompting/references/codex-prompt-recipes.md +150 -150
- package/skills/craft/gpt-5-4-prompting/references/prompt-blocks.md +172 -172
- package/skills/craft/grill-me/LICENSE +21 -21
- package/skills/craft/grill-me/SKILL.md +13 -13
- package/skills/craft/idea-to-deploy/LICENSE +21 -21
- package/skills/craft/idea-to-deploy/SKILL.md +292 -292
- package/skills/craft/idea-to-deploy/references/auth-playbook.md +195 -195
- package/skills/craft/idea-to-deploy/references/gcp-deployment.md +268 -268
- package/skills/craft/idea-to-deploy/references/stack-selection.md +117 -117
- package/skills/craft/image-generation-engineer/LICENSE +21 -21
- package/skills/craft/image-generation-engineer/SKILL.md +183 -183
- package/skills/craft/image-generation-engineer/references/architectures.md +260 -260
- package/skills/craft/image-generation-engineer/references/foundations.md +107 -107
- package/skills/craft/image-generation-engineer/references/inference-and-serving.md +253 -253
- package/skills/craft/image-generation-engineer/references/training.md +149 -149
- package/skills/craft/marketing/LICENSE +21 -21
- package/skills/craft/marketing/SKILL.md +1954 -1954
- package/skills/craft/master-architect/LICENSE +21 -21
- package/skills/craft/master-architect/SKILL.md +361 -361
- package/skills/craft/master-architect/references/ai-ml.md +317 -317
- package/skills/craft/master-architect/references/architecture.md +268 -268
- package/skills/craft/master-architect/references/auth-playbook.md +195 -195
- package/skills/craft/master-architect/references/cloud.md +323 -323
- package/skills/craft/master-architect/references/cyber.md +839 -839
- package/skills/craft/master-architect/references/data-eng.md +366 -366
- package/skills/craft/master-architect/references/devops.md +550 -550
- package/skills/craft/master-architect/references/gcp-deployment.md +268 -268
- package/skills/craft/master-architect/references/languages.md +748 -748
- package/skills/craft/master-architect/references/legacy.md +240 -240
- package/skills/craft/master-architect/references/mobile.md +447 -447
- package/skills/craft/master-architect/references/patterns.md +451 -451
- package/skills/craft/master-architect/references/saas-patterns.md +379 -379
- package/skills/craft/master-architect/references/sdlc.md +349 -349
- package/skills/craft/master-architect/references/stack-selection.md +117 -117
- package/skills/craft/oriro-ui-2026/LICENSE +21 -21
- package/skills/craft/oriro-ui-2026/SKILL.md +329 -329
- package/skills/craft/playwright-cli/LICENSE +21 -21
- package/skills/craft/playwright-cli/SKILL.md +393 -393
- package/skills/craft/playwright-cli/references/element-attributes.md +23 -23
- package/skills/craft/playwright-cli/references/playwright-tests.md +39 -39
- package/skills/craft/playwright-cli/references/request-mocking.md +87 -87
- package/skills/craft/playwright-cli/references/running-code.md +240 -240
- package/skills/craft/playwright-cli/references/session-management.md +226 -226
- package/skills/craft/playwright-cli/references/spec-driven-testing.md +312 -312
- package/skills/craft/playwright-cli/references/storage-state.md +275 -275
- package/skills/craft/playwright-cli/references/test-generation.md +134 -134
- package/skills/craft/playwright-cli/references/tracing.md +142 -142
- package/skills/craft/playwright-cli/references/video-recording.md +150 -150
- package/skills/craft/remotion-best-practices/LICENSE +21 -21
- package/skills/craft/remotion-best-practices/SKILL.md +345 -345
- package/skills/craft/remotion-best-practices/rules/3d.md +86 -86
- package/skills/craft/remotion-best-practices/rules/assets/charts-bar-chart.tsx +165 -165
- package/skills/craft/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +89 -89
- package/skills/craft/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +101 -101
- package/skills/craft/remotion-best-practices/rules/audio-visualization.md +195 -195
- package/skills/craft/remotion-best-practices/rules/audio.md +167 -167
- package/skills/craft/remotion-best-practices/rules/calculate-metadata.md +118 -118
- package/skills/craft/remotion-best-practices/rules/compositions.md +132 -132
- package/skills/craft/remotion-best-practices/rules/display-captions.md +176 -176
- package/skills/craft/remotion-best-practices/rules/ffmpeg.md +34 -34
- package/skills/craft/remotion-best-practices/rules/get-audio-duration.md +58 -58
- package/skills/craft/remotion-best-practices/rules/get-video-dimensions.md +68 -68
- package/skills/craft/remotion-best-practices/rules/get-video-duration.md +60 -60
- package/skills/craft/remotion-best-practices/rules/gifs.md +135 -135
- package/skills/craft/remotion-best-practices/rules/google-fonts.md +72 -72
- package/skills/craft/remotion-best-practices/rules/html-in-canvas.md +122 -122
- package/skills/craft/remotion-best-practices/rules/images.md +67 -67
- package/skills/craft/remotion-best-practices/rules/import-srt-captions.md +69 -69
- package/skills/craft/remotion-best-practices/rules/light-leaks.md +73 -73
- package/skills/craft/remotion-best-practices/rules/local-fonts.md +65 -65
- package/skills/craft/remotion-best-practices/rules/lottie.md +67 -67
- package/skills/craft/remotion-best-practices/rules/maplibre.md +441 -441
- package/skills/craft/remotion-best-practices/rules/measuring-dom-nodes.md +34 -34
- package/skills/craft/remotion-best-practices/rules/measuring-text.md +140 -140
- package/skills/craft/remotion-best-practices/rules/parameters.md +109 -109
- package/skills/craft/remotion-best-practices/rules/sequencing.md +144 -144
- package/skills/craft/remotion-best-practices/rules/sfx.md +30 -30
- package/skills/craft/remotion-best-practices/rules/silence-detection.md +73 -73
- package/skills/craft/remotion-best-practices/rules/subtitles.md +36 -36
- package/skills/craft/remotion-best-practices/rules/tailwind.md +11 -11
- package/skills/craft/remotion-best-practices/rules/text-animations.md +20 -20
- package/skills/craft/remotion-best-practices/rules/timing.md +130 -130
- package/skills/craft/remotion-best-practices/rules/transcribe-captions.md +70 -70
- package/skills/craft/remotion-best-practices/rules/transitions.md +193 -193
- package/skills/craft/remotion-best-practices/rules/transparent-videos.md +102 -102
- package/skills/craft/remotion-best-practices/rules/trimming.md +51 -51
- package/skills/craft/remotion-best-practices/rules/videos.md +169 -169
- package/skills/craft/remotion-best-practices/rules/voiceover.md +94 -94
- package/skills/craft/supabase-postgres-best-practices/CHANGELOG.md +25 -25
- package/skills/craft/supabase-postgres-best-practices/LICENSE +21 -21
- package/skills/craft/supabase-postgres-best-practices/SKILL.md +69 -69
- package/skills/craft/supabase-postgres-best-practices/references/_contributing.md +166 -166
- package/skills/craft/supabase-postgres-best-practices/references/_sections.md +47 -47
- package/skills/craft/supabase-postgres-best-practices/references/_template.md +34 -34
- package/skills/craft/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -55
- package/skills/craft/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -49
- package/skills/craft/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -46
- package/skills/craft/supabase-postgres-best-practices/references/conn-limits.md +44 -44
- package/skills/craft/supabase-postgres-best-practices/references/conn-pooling.md +41 -41
- package/skills/craft/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -46
- package/skills/craft/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -54
- package/skills/craft/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -53
- package/skills/craft/supabase-postgres-best-practices/references/data-pagination.md +50 -50
- package/skills/craft/supabase-postgres-best-practices/references/data-upsert.md +50 -50
- package/skills/craft/supabase-postgres-best-practices/references/lock-advisory.md +56 -56
- package/skills/craft/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -68
- package/skills/craft/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -50
- package/skills/craft/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -54
- package/skills/craft/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -45
- package/skills/craft/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -55
- package/skills/craft/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -55
- package/skills/craft/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -44
- package/skills/craft/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -40
- package/skills/craft/supabase-postgres-best-practices/references/query-index-types.md +48 -48
- package/skills/craft/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -43
- package/skills/craft/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -45
- package/skills/craft/supabase-postgres-best-practices/references/schema-constraints.md +80 -80
- package/skills/craft/supabase-postgres-best-practices/references/schema-data-types.md +46 -46
- package/skills/craft/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -59
- package/skills/craft/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -55
- package/skills/craft/supabase-postgres-best-practices/references/schema-partitioning.md +55 -55
- package/skills/craft/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -61
- package/skills/craft/supabase-postgres-best-practices/references/security-privileges.md +54 -54
- package/skills/craft/supabase-postgres-best-practices/references/security-rls-basics.md +50 -50
- package/skills/craft/supabase-postgres-best-practices/references/security-rls-performance.md +63 -63
- package/skills/craft/uipm-banner-design/LICENSE +21 -21
- package/skills/craft/uipm-banner-design/SKILL.md +201 -201
- package/skills/craft/uipm-banner-design/references/banner-sizes-and-styles.md +129 -129
- package/skills/craft/uipm-brand/LICENSE +21 -21
- package/skills/craft/uipm-brand/SKILL.md +104 -104
- package/skills/craft/uipm-brand/references/approval-checklist.md +184 -184
- package/skills/craft/uipm-brand/references/asset-organization.md +167 -167
- package/skills/craft/uipm-brand/references/brand-guideline-template.md +161 -161
- package/skills/craft/uipm-brand/references/color-palette-management.md +203 -203
- package/skills/craft/uipm-brand/references/consistency-checklist.md +105 -105
- package/skills/craft/uipm-brand/references/logo-usage-rules.md +204 -204
- package/skills/craft/uipm-brand/references/messaging-framework.md +91 -91
- package/skills/craft/uipm-brand/references/typography-specifications.md +265 -265
- package/skills/craft/uipm-brand/references/update.md +128 -128
- package/skills/craft/uipm-brand/references/visual-identity.md +109 -109
- package/skills/craft/uipm-brand/references/voice-framework.md +99 -99
- package/skills/craft/uipm-brand/scripts/extract-colors.cjs +333 -333
- package/skills/craft/uipm-brand/scripts/inject-brand-context.cjs +324 -324
- package/skills/craft/uipm-brand/scripts/sync-brand-to-tokens.cjs +269 -269
- package/skills/craft/uipm-brand/scripts/validate-asset.cjs +361 -361
- package/skills/craft/uipm-brand/templates/brand-guidelines-starter.md +280 -280
- package/skills/craft/uipm-design/LICENSE +21 -21
- package/skills/craft/uipm-design/SKILL.md +305 -305
- package/skills/craft/uipm-design/data/cip/deliverables.csv +50 -50
- package/skills/craft/uipm-design/data/cip/industries.csv +20 -20
- package/skills/craft/uipm-design/data/cip/mockup-contexts.csv +20 -20
- package/skills/craft/uipm-design/data/cip/styles.csv +20 -20
- package/skills/craft/uipm-design/data/icon/styles.csv +16 -16
- package/skills/craft/uipm-design/data/logo/colors.csv +56 -56
- package/skills/craft/uipm-design/data/logo/industries.csv +56 -56
- package/skills/craft/uipm-design/data/logo/styles.csv +56 -56
- package/skills/craft/uipm-design/references/banner-sizes-and-styles.md +129 -129
- package/skills/craft/uipm-design/references/cip-deliverable-guide.md +111 -111
- package/skills/craft/uipm-design/references/cip-design.md +121 -121
- package/skills/craft/uipm-design/references/cip-prompt-engineering.md +94 -94
- package/skills/craft/uipm-design/references/cip-style-guide.md +76 -76
- package/skills/craft/uipm-design/references/design-routing.md +226 -226
- package/skills/craft/uipm-design/references/icon-design.md +122 -122
- package/skills/craft/uipm-design/references/logo-color-psychology.md +113 -113
- package/skills/craft/uipm-design/references/logo-design.md +92 -92
- package/skills/craft/uipm-design/references/logo-prompt-engineering.md +176 -176
- package/skills/craft/uipm-design/references/logo-style-guide.md +129 -129
- package/skills/craft/uipm-design/references/slides-copywriting-formulas.md +92 -92
- package/skills/craft/uipm-design/references/slides-create.md +5 -5
- package/skills/craft/uipm-design/references/slides-html-template.md +374 -374
- package/skills/craft/uipm-design/references/slides-layout-patterns.md +155 -155
- package/skills/craft/uipm-design/references/slides-strategies.md +97 -97
- package/skills/craft/uipm-design/references/slides.md +42 -42
- package/skills/craft/uipm-design/references/social-photos-design.md +353 -353
- package/skills/craft/uipm-design/scripts/cip/core.py +215 -215
- package/skills/craft/uipm-design/scripts/cip/generate.py +484 -484
- package/skills/craft/uipm-design/scripts/cip/render-html.py +424 -424
- package/skills/craft/uipm-design/scripts/cip/search.py +127 -127
- package/skills/craft/uipm-design/scripts/icon/generate.py +487 -487
- package/skills/craft/uipm-design/scripts/logo/core.py +175 -175
- package/skills/craft/uipm-design/scripts/logo/generate.py +362 -362
- package/skills/craft/uipm-design/scripts/logo/search.py +114 -114
- package/skills/craft/uipm-design-system/LICENSE +21 -21
- package/skills/craft/uipm-design-system/SKILL.md +255 -255
- package/skills/craft/uipm-design-system/data/slide-backgrounds.csv +11 -11
- package/skills/craft/uipm-design-system/data/slide-charts.csv +26 -26
- package/skills/craft/uipm-design-system/data/slide-color-logic.csv +14 -14
- package/skills/craft/uipm-design-system/data/slide-copy.csv +26 -26
- package/skills/craft/uipm-design-system/data/slide-layout-logic.csv +16 -16
- package/skills/craft/uipm-design-system/data/slide-layouts.csv +26 -26
- package/skills/craft/uipm-design-system/data/slide-strategies.csv +16 -16
- package/skills/craft/uipm-design-system/data/slide-typography.csv +15 -15
- package/skills/craft/uipm-design-system/references/component-specs.md +236 -236
- package/skills/craft/uipm-design-system/references/component-tokens.md +214 -214
- package/skills/craft/uipm-design-system/references/primitive-tokens.md +199 -199
- package/skills/craft/uipm-design-system/references/semantic-tokens.md +215 -215
- package/skills/craft/uipm-design-system/references/states-and-variants.md +243 -243
- package/skills/craft/uipm-design-system/references/tailwind-integration.md +257 -257
- package/skills/craft/uipm-design-system/references/token-architecture.md +226 -226
- package/skills/craft/uipm-design-system/scripts/embed-tokens.cjs +97 -97
- package/skills/craft/uipm-design-system/scripts/fetch-background.py +317 -317
- package/skills/craft/uipm-design-system/scripts/generate-slide.py +753 -753
- package/skills/craft/uipm-design-system/scripts/generate-tokens.cjs +213 -213
- package/skills/craft/uipm-design-system/scripts/html-token-validator.py +327 -327
- package/skills/craft/uipm-design-system/scripts/search-slides.py +218 -218
- package/skills/craft/uipm-design-system/scripts/slide-token-validator.py +35 -35
- package/skills/craft/uipm-design-system/scripts/slide_search_core.py +453 -453
- package/skills/craft/uipm-design-system/scripts/validate-tokens.cjs +254 -254
- package/skills/craft/uipm-design-system/templates/design-tokens-starter.json +143 -143
- package/skills/craft/uipm-slides/LICENSE +21 -21
- package/skills/craft/uipm-slides/SKILL.md +45 -45
- package/skills/craft/uipm-slides/references/copywriting-formulas.md +92 -92
- package/skills/craft/uipm-slides/references/create.md +5 -5
- package/skills/craft/uipm-slides/references/html-template.md +374 -374
- package/skills/craft/uipm-slides/references/layout-patterns.md +155 -155
- package/skills/craft/uipm-slides/references/slide-strategies.md +97 -97
- package/skills/craft/uipm-ui-ux-pro-max/LICENSE +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/SKILL.md +678 -678
- package/skills/craft/uipm-ui-ux-pro-max/data/_sync_all.py +414 -414
- package/skills/craft/uipm-ui-ux-pro-max/data/app-interface.csv +30 -30
- package/skills/craft/uipm-ui-ux-pro-max/data/charts.csv +26 -26
- package/skills/craft/uipm-ui-ux-pro-max/data/colors.csv +161 -161
- package/skills/craft/uipm-ui-ux-pro-max/data/design.csv +1775 -1775
- package/skills/craft/uipm-ui-ux-pro-max/data/draft.csv +1778 -1778
- package/skills/craft/uipm-ui-ux-pro-max/data/google-fonts.csv +1924 -1924
- package/skills/craft/uipm-ui-ux-pro-max/data/icons.csv +105 -105
- package/skills/craft/uipm-ui-ux-pro-max/data/landing.csv +35 -35
- package/skills/craft/uipm-ui-ux-pro-max/data/products.csv +162 -162
- package/skills/craft/uipm-ui-ux-pro-max/data/react-performance.csv +45 -45
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/angular.csv +51 -51
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/astro.csv +54 -54
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/flutter.csv +53 -53
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -56
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -53
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/laravel.csv +51 -51
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/nextjs.csv +53 -53
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -51
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -59
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/react-native.csv +52 -52
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/react.csv +54 -54
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/shadcn.csv +61 -61
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/svelte.csv +54 -54
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/swiftui.csv +51 -51
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/threejs.csv +54 -54
- package/skills/craft/uipm-ui-ux-pro-max/data/stacks/vue.csv +50 -50
- package/skills/craft/uipm-ui-ux-pro-max/data/styles.csv +85 -85
- package/skills/craft/uipm-ui-ux-pro-max/data/typography.csv +74 -74
- package/skills/craft/uipm-ui-ux-pro-max/data/ui-reasoning.csv +162 -162
- package/skills/craft/uipm-ui-ux-pro-max/data/ux-guidelines.csv +99 -99
- package/skills/craft/uipm-ui-ux-pro-max/scripts/core.py +262 -262
- package/skills/craft/uipm-ui-ux-pro-max/scripts/design_system.py +1148 -1148
- package/skills/craft/uipm-ui-ux-pro-max/scripts/search.py +114 -114
- package/skills/craft/uipm-ui-ux-pro-max/templates/base/quick-reference.md +297 -297
- package/skills/craft/uipm-ui-ux-pro-max/templates/base/skill-content.md +375 -375
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/agent.json +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/augment.json +18 -18
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/claude.json +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/codebuddy.json +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/codex.json +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/continue.json +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/copilot.json +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/cursor.json +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/droid.json +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/gemini.json +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/kilocode.json +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/kiro.json +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/opencode.json +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/qoder.json +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/roocode.json +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/trae.json +21 -21
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/warp.json +18 -18
- package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/windsurf.json +21 -21
- package/skills/craft/vercel-optimize/AGENTS.md +48 -48
- package/skills/craft/vercel-optimize/CONTRIBUTING.md +41 -41
- package/skills/craft/vercel-optimize/LICENSE +21 -21
- package/skills/craft/vercel-optimize/README.md +91 -91
- package/skills/craft/vercel-optimize/SKILL.md +325 -325
- package/skills/craft/vercel-optimize/lib/auth-route.mjs +23 -23
- package/skills/craft/vercel-optimize/lib/budget-summary.mjs +208 -208
- package/skills/craft/vercel-optimize/lib/citations.mjs +147 -147
- package/skills/craft/vercel-optimize/lib/cost-coverage.mjs +162 -162
- package/skills/craft/vercel-optimize/lib/dedup-recs.mjs +340 -340
- package/skills/craft/vercel-optimize/lib/deep-dive.mjs +371 -371
- package/skills/craft/vercel-optimize/lib/display-labels.mjs +219 -219
- package/skills/craft/vercel-optimize/lib/extract-claims.mjs +640 -640
- package/skills/craft/vercel-optimize/lib/framework-support.mjs +69 -69
- package/skills/craft/vercel-optimize/lib/gates/build-minutes-fanout.mjs +73 -73
- package/skills/craft/vercel-optimize/lib/gates/cold-start.mjs +72 -72
- package/skills/craft/vercel-optimize/lib/gates/contract.mjs +82 -82
- package/skills/craft/vercel-optimize/lib/gates/cwv-poor.mjs +95 -95
- package/skills/craft/vercel-optimize/lib/gates/external-api-slow.mjs +60 -60
- package/skills/craft/vercel-optimize/lib/gates/hard-gates.mjs +70 -70
- package/skills/craft/vercel-optimize/lib/gates/index.mjs +45 -45
- package/skills/craft/vercel-optimize/lib/gates/isr-overrevalidation.mjs +62 -62
- package/skills/craft/vercel-optimize/lib/gates/middleware-heavy.mjs +53 -53
- package/skills/craft/vercel-optimize/lib/gates/observability-events-attribution.mjs +58 -58
- package/skills/craft/vercel-optimize/lib/gates/platform-bot-protection.mjs +123 -123
- package/skills/craft/vercel-optimize/lib/gates/platform-fluid-compute.mjs +94 -94
- package/skills/craft/vercel-optimize/lib/gates/region-misconfig.mjs +71 -71
- package/skills/craft/vercel-optimize/lib/gates/route-errors.mjs +95 -95
- package/skills/craft/vercel-optimize/lib/gates/scanner-driven.mjs +150 -150
- package/skills/craft/vercel-optimize/lib/gates/select-candidates.mjs +137 -137
- package/skills/craft/vercel-optimize/lib/gates/slow-route.mjs +97 -97
- package/skills/craft/vercel-optimize/lib/gates/types.d.ts +38 -38
- package/skills/craft/vercel-optimize/lib/gates/uncached-route.mjs +103 -103
- package/skills/craft/vercel-optimize/lib/gates/usage-spike-triage.mjs +122 -122
- package/skills/craft/vercel-optimize/lib/grade-recommendation.mjs +170 -170
- package/skills/craft/vercel-optimize/lib/impact-label.mjs +128 -128
- package/skills/craft/vercel-optimize/lib/impact-magnitude.mjs +66 -66
- package/skills/craft/vercel-optimize/lib/investigation-brief.mjs +751 -751
- package/skills/craft/vercel-optimize/lib/observation-safety.mjs +217 -217
- package/skills/craft/vercel-optimize/lib/project-facts.mjs +101 -101
- package/skills/craft/vercel-optimize/lib/queries.mjs +333 -333
- package/skills/craft/vercel-optimize/lib/reconcile-candidates.mjs +388 -388
- package/skills/craft/vercel-optimize/lib/render-report.mjs +1065 -1065
- package/skills/craft/vercel-optimize/lib/repo-root.mjs +97 -97
- package/skills/craft/vercel-optimize/lib/route-normalize.mjs +224 -224
- package/skills/craft/vercel-optimize/lib/sanitizers/bot-protection-certainty.mjs +56 -56
- package/skills/craft/vercel-optimize/lib/sanitizers/cache-tag-invalidation-certainty.mjs +33 -33
- package/skills/craft/vercel-optimize/lib/sanitizers/count-correct.mjs +53 -53
- package/skills/craft/vercel-optimize/lib/sanitizers/function-duration-invocations.mjs +32 -32
- package/skills/craft/vercel-optimize/lib/sanitizers/index.mjs +87 -87
- package/skills/craft/vercel-optimize/lib/sanitizers/middleware-conflict.mjs +37 -37
- package/skills/craft/vercel-optimize/lib/sanitizers/missing-citation.mjs +16 -16
- package/skills/craft/vercel-optimize/lib/sanitizers/pre-release.mjs +75 -75
- package/skills/craft/vercel-optimize/lib/sanitizers/rate-limit.mjs +73 -73
- package/skills/craft/vercel-optimize/lib/sanitizers/rendering-mode-mislabel.mjs +42 -42
- package/skills/craft/vercel-optimize/lib/sanitizers/undeclared-dep.mjs +110 -110
- package/skills/craft/vercel-optimize/lib/sanitizers/vercel-directive-strip.mjs +37 -37
- package/skills/craft/vercel-optimize/lib/sanitizers/window-units.mjs +26 -26
- package/skills/craft/vercel-optimize/lib/scanners/cache-components-suspense-dedupe.mjs +114 -114
- package/skills/craft/vercel-optimize/lib/scanners/edge-heavy-import.mjs +102 -102
- package/skills/craft/vercel-optimize/lib/scanners/force-dynamic.mjs +39 -39
- package/skills/craft/vercel-optimize/lib/scanners/headers-in-page.mjs +43 -43
- package/skills/craft/vercel-optimize/lib/scanners/index.mjs +35 -35
- package/skills/craft/vercel-optimize/lib/scanners/large-static-asset.mjs +93 -93
- package/skills/craft/vercel-optimize/lib/scanners/max-age-without-s-maxage.mjs +47 -47
- package/skills/craft/vercel-optimize/lib/scanners/middleware-broad-matcher.mjs +53 -53
- package/skills/craft/vercel-optimize/lib/scanners/missing-cache-headers.mjs +97 -97
- package/skills/craft/vercel-optimize/lib/scanners/prisma-include-tree.mjs +39 -39
- package/skills/craft/vercel-optimize/lib/scanners/region-pin-in-config.mjs +89 -89
- package/skills/craft/vercel-optimize/lib/scanners/source-maps-production.mjs +33 -33
- package/skills/craft/vercel-optimize/lib/scanners/sveltekit-prerender-missing.mjs +47 -47
- package/skills/craft/vercel-optimize/lib/scanners/turbo-force-bypass.mjs +136 -136
- package/skills/craft/vercel-optimize/lib/scanners/unoptimized-image.mjs +127 -127
- package/skills/craft/vercel-optimize/lib/scanners/use-cache-date-stamp.mjs +112 -112
- package/skills/craft/vercel-optimize/lib/support-topics.mjs +365 -365
- package/skills/craft/vercel-optimize/lib/throttle.mjs +280 -280
- package/skills/craft/vercel-optimize/lib/util.mjs +17 -17
- package/skills/craft/vercel-optimize/lib/vercel.mjs +855 -855
- package/skills/craft/vercel-optimize/lib/verify-claim.mjs +1843 -1843
- package/skills/craft/vercel-optimize/lib/workspace-resolver.mjs +552 -552
- package/skills/craft/vercel-optimize/metadata.json +14 -14
- package/skills/craft/vercel-optimize/references/candidates.md +176 -176
- package/skills/craft/vercel-optimize/references/data-collection.md +224 -224
- package/skills/craft/vercel-optimize/references/docs-library.json +683 -683
- package/skills/craft/vercel-optimize/references/doctrine.md +108 -108
- package/skills/craft/vercel-optimize/references/observability-plus.md +109 -109
- package/skills/craft/vercel-optimize/references/playbooks/README.md +57 -57
- package/skills/craft/vercel-optimize/references/playbooks/ai-application.md +32 -32
- package/skills/craft/vercel-optimize/references/playbooks/api-service.md +30 -30
- package/skills/craft/vercel-optimize/references/playbooks/content-site.md +30 -30
- package/skills/craft/vercel-optimize/references/playbooks/ecommerce.md +30 -30
- package/skills/craft/vercel-optimize/references/playbooks/marketing.md +30 -30
- package/skills/craft/vercel-optimize/references/playbooks/saas.md +31 -31
- package/skills/craft/vercel-optimize/references/playbooks/sveltekit.md +75 -75
- package/skills/craft/vercel-optimize/references/recommendations.md +214 -214
- package/skills/craft/vercel-optimize/references/scanner-patterns.md +266 -266
- package/skills/craft/vercel-optimize/references/scoring.md +208 -208
- package/skills/craft/vercel-optimize/references/support-topics/README.md +50 -50
- package/skills/craft/vercel-optimize/references/support-topics/astro-edge-middleware-scope.md +30 -30
- package/skills/craft/vercel-optimize/references/support-topics/astro-output-mode-and-isr.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/auth-preserving-parallelization.md +30 -30
- package/skills/craft/vercel-optimize/references/support-topics/bot-protection-product-guardrails.md +32 -32
- package/skills/craft/vercel-optimize/references/support-topics/build-minutes-monorepo-fanout.md +32 -32
- package/skills/craft/vercel-optimize/references/support-topics/cache-components-static-shell-boundaries.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/cache-components-suspense-dedupe-pitfall.md +32 -32
- package/skills/craft/vercel-optimize/references/support-topics/cdn-cache-auth-safety.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/cold-start-initialization-bundle.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/core-web-vitals-client-bottlenecks.md +33 -33
- package/skills/craft/vercel-optimize/references/support-topics/database-egress-pooling-region.md +32 -32
- package/skills/craft/vercel-optimize/references/support-topics/dynamic-rendering-traps.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/external-api-critical-path-platform.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/external-api-critical-path.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/fast-data-transfer-payloads.md +26 -26
- package/skills/craft/vercel-optimize/references/support-topics/fluid-compute-caveats.md +26 -26
- package/skills/craft/vercel-optimize/references/support-topics/function-duration-io-and-after.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/function-invocation-reduction.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/function-region-misconfiguration-ttfb.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/image-optimization-cost-control.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/isr-revalidation-static-generation.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/middleware-proxy-edge-cost.md +30 -30
- package/skills/craft/vercel-optimize/references/support-topics/next-fetch-revalidate-floor.md +30 -30
- package/skills/craft/vercel-optimize/references/support-topics/next-font-cls-self-hosting.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/next-heavy-ui-lazy-load-boundaries.md +28 -28
- package/skills/craft/vercel-optimize/references/support-topics/next-image-lcp-preload-sizes.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/next-route-handler-get-cache-defaults.md +30 -30
- package/skills/craft/vercel-optimize/references/support-topics/next-script-third-party-strategy.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/nextjs-version-cache-semantics.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/not-found-catchall-request-waste.md +33 -33
- package/skills/craft/vercel-optimize/references/support-topics/nuxt-route-rules-cache-isr.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/observability-events-cost-attribution.md +27 -27
- package/skills/craft/vercel-optimize/references/support-topics/post-response-work-waituntil.md +26 -26
- package/skills/craft/vercel-optimize/references/support-topics/route-error-durable-offload.md +33 -33
- package/skills/craft/vercel-optimize/references/support-topics/route-error-runtime-limits.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/runtime-cache-reusable-data.md +30 -30
- package/skills/craft/vercel-optimize/references/support-topics/sveltekit-isr-prerender-safety.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/sveltekit-split-cold-start-tradeoff.md +30 -30
- package/skills/craft/vercel-optimize/references/support-topics/usage-spike-triage.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/use-cache-date-stamp-isr-write-amplifier.md +31 -31
- package/skills/craft/vercel-optimize/references/support-topics/use-cache-remote-shared-origin-data.md +30 -30
- package/skills/craft/vercel-optimize/references/support-topics/workflow-resumable-stream-routes.md +32 -32
- package/skills/craft/vercel-optimize/references/verification.md +102 -102
- package/skills/craft/vercel-optimize/references/voice.md +76 -76
- package/skills/craft/vercel-optimize/scripts/budget-summary.mjs +58 -58
- package/skills/craft/vercel-optimize/scripts/build-docs.mjs +76 -76
- package/skills/craft/vercel-optimize/scripts/check-citations.mjs +91 -91
- package/skills/craft/vercel-optimize/scripts/check-docs-fresh.mjs +100 -100
- package/skills/craft/vercel-optimize/scripts/collect-signals.mjs +638 -638
- package/skills/craft/vercel-optimize/scripts/collect-sub-agent-outputs.mjs +306 -306
- package/skills/craft/vercel-optimize/scripts/deep-dive.mjs +358 -358
- package/skills/craft/vercel-optimize/scripts/gate-investigations.mjs +178 -178
- package/skills/craft/vercel-optimize/scripts/merge-signals.mjs +203 -203
- package/skills/craft/vercel-optimize/scripts/prepare-investigation-brief.mjs +249 -249
- package/skills/craft/vercel-optimize/scripts/reconcile-candidates.mjs +69 -69
- package/skills/craft/vercel-optimize/scripts/render-report.mjs +462 -462
- package/skills/craft/vercel-optimize/scripts/scan-codebase.mjs +361 -361
- package/skills/craft/vercel-optimize/scripts/verify-and-regen.mjs +379 -379
- package/skills/craft/vercel-optimize/scripts/verify-finding.mjs +21 -21
- package/skills/craft/web-design-guidelines/LICENSE +21 -21
- package/skills/craft/web-design-guidelines/SKILL.md +43 -43
- package/skills/craft/zero-to-live/LICENSE +21 -21
- package/skills/craft/zero-to-live/SKILL.md +422 -422
- package/skills/creative/creative-3d-modeling/LICENSE +21 -21
- package/skills/creative/creative-3d-modeling/SKILL.md +70 -70
- package/skills/creative/creative-architecture/LICENSE +21 -21
- package/skills/creative/creative-architecture/SKILL.md +94 -94
- package/skills/creative/creative-design-principles/LICENSE +21 -21
- package/skills/creative/creative-design-principles/SKILL.md +95 -95
- package/skills/creative/creative-fashion-advanced/LICENSE +21 -21
- package/skills/creative/creative-fashion-advanced/SKILL.md +68 -68
- package/skills/creative/creative-fashion-design/LICENSE +21 -21
- package/skills/creative/creative-fashion-design/SKILL.md +66 -66
- package/skills/creative/creative-game-design/LICENSE +21 -21
- package/skills/creative/creative-game-design/SKILL.md +77 -77
- package/skills/creative/creative-industrial-design/LICENSE +21 -21
- package/skills/creative/creative-industrial-design/SKILL.md +57 -57
- package/skills/creative/creative-interior-design/LICENSE +21 -21
- package/skills/creative/creative-interior-design/SKILL.md +59 -59
- package/skills/creative/creative-music-theory/LICENSE +21 -21
- package/skills/creative/creative-music-theory/SKILL.md +98 -98
- package/skills/creative/creative-photography/LICENSE +21 -21
- package/skills/creative/creative-photography/SKILL.md +87 -87
- package/skills/creative/creative-textile-science/LICENSE +21 -21
- package/skills/creative/creative-textile-science/SKILL.md +67 -67
- package/skills/creative/creative-ux/LICENSE +21 -21
- package/skills/creative/creative-ux/SKILL.md +81 -81
- package/skills/creative/creative-video/LICENSE +21 -21
- package/skills/creative/creative-video/SKILL.md +84 -84
- package/skills/creative/creative-writing-craft/LICENSE +21 -21
- package/skills/creative/creative-writing-craft/SKILL.md +91 -91
- package/skills/diagram-maker/SKILL.md +56 -56
- package/skills/diagram-maker/references/excalidraw-patterns.md +85 -85
- package/skills/diagram-maker/references/svg-template.md +112 -112
- package/skills/discord/SKILL.md +140 -140
- package/skills/education/edu-adult-learning/LICENSE +21 -21
- package/skills/education/edu-adult-learning/SKILL.md +81 -81
- package/skills/education/edu-africa-multilingual/LICENSE +21 -21
- package/skills/education/edu-africa-multilingual/SKILL.md +55 -55
- package/skills/education/edu-arabic/LICENSE +21 -21
- package/skills/education/edu-arabic/SKILL.md +60 -60
- package/skills/education/edu-australia-nz/LICENSE +21 -21
- package/skills/education/edu-australia-nz/SKILL.md +48 -48
- package/skills/education/edu-china-mandarin/LICENSE +21 -21
- package/skills/education/edu-china-mandarin/SKILL.md +58 -58
- package/skills/education/edu-critical-thinking/LICENSE +21 -21
- package/skills/education/edu-critical-thinking/SKILL.md +86 -86
- package/skills/education/edu-curriculum/LICENSE +21 -21
- package/skills/education/edu-curriculum/SKILL.md +87 -87
- package/skills/education/edu-ed-tech/LICENSE +21 -21
- package/skills/education/edu-ed-tech/SKILL.md +73 -73
- package/skills/education/edu-france/LICENSE +21 -21
- package/skills/education/edu-france/SKILL.md +42 -42
- package/skills/education/edu-germany/LICENSE +21 -21
- package/skills/education/edu-germany/SKILL.md +46 -46
- package/skills/education/edu-india-competitive/LICENSE +21 -21
- package/skills/education/edu-india-competitive/SKILL.md +159 -159
- package/skills/education/edu-india-east/LICENSE +21 -21
- package/skills/education/edu-india-east/SKILL.md +60 -60
- package/skills/education/edu-india-hindi/LICENSE +21 -21
- package/skills/education/edu-india-hindi/SKILL.md +107 -107
- package/skills/education/edu-india-south/LICENSE +21 -21
- package/skills/education/edu-india-south/SKILL.md +64 -64
- package/skills/education/edu-india-west/LICENSE +21 -21
- package/skills/education/edu-india-west/SKILL.md +68 -68
- package/skills/education/edu-indonesia-malay/LICENSE +21 -21
- package/skills/education/edu-indonesia-malay/SKILL.md +57 -57
- package/skills/education/edu-international-ib/LICENSE +21 -21
- package/skills/education/edu-international-ib/SKILL.md +61 -61
- package/skills/education/edu-japan/LICENSE +21 -21
- package/skills/education/edu-japan/SKILL.md +48 -48
- package/skills/education/edu-korea/LICENSE +21 -21
- package/skills/education/edu-korea/SKILL.md +48 -48
- package/skills/education/edu-learning-science/LICENSE +21 -21
- package/skills/education/edu-learning-science/SKILL.md +76 -76
- package/skills/education/edu-portuguese-brazil/LICENSE +21 -21
- package/skills/education/edu-portuguese-brazil/SKILL.md +51 -51
- package/skills/education/edu-russia/LICENSE +21 -21
- package/skills/education/edu-russia/SKILL.md +50 -50
- package/skills/education/edu-spain-latam/LICENSE +21 -21
- package/skills/education/edu-spain-latam/SKILL.md +55 -55
- package/skills/education/edu-special/LICENSE +21 -21
- package/skills/education/edu-special/SKILL.md +76 -76
- package/skills/education/edu-thailand/LICENSE +21 -21
- package/skills/education/edu-thailand/SKILL.md +55 -55
- package/skills/education/edu-turkey/LICENSE +21 -21
- package/skills/education/edu-turkey/SKILL.md +58 -58
- package/skills/education/edu-uk-gcse-alevel/LICENSE +21 -21
- package/skills/education/edu-uk-gcse-alevel/SKILL.md +51 -51
- package/skills/education/edu-usa-graduate/LICENSE +21 -21
- package/skills/education/edu-usa-graduate/SKILL.md +57 -57
- package/skills/education/edu-usa-sat-act/LICENSE +21 -21
- package/skills/education/edu-usa-sat-act/SKILL.md +55 -55
- package/skills/education/edu-vietnam/LICENSE +21 -21
- package/skills/education/edu-vietnam/SKILL.md +53 -53
- package/skills/eightctl/SKILL.md +54 -54
- package/skills/engineering/eng-aerospace/LICENSE +21 -21
- package/skills/engineering/eng-aerospace/SKILL.md +117 -117
- package/skills/engineering/eng-chemical/LICENSE +21 -21
- package/skills/engineering/eng-chemical/SKILL.md +63 -63
- package/skills/engineering/eng-civil/LICENSE +21 -21
- package/skills/engineering/eng-civil/SKILL.md +223 -223
- package/skills/engineering/eng-control-systems/LICENSE +21 -21
- package/skills/engineering/eng-control-systems/SKILL.md +158 -158
- package/skills/engineering/eng-cryogenics/LICENSE +21 -21
- package/skills/engineering/eng-cryogenics/SKILL.md +151 -151
- package/skills/engineering/eng-electrical/LICENSE +21 -21
- package/skills/engineering/eng-electrical/SKILL.md +70 -70
- package/skills/engineering/eng-electronics-embedded/LICENSE +21 -21
- package/skills/engineering/eng-electronics-embedded/SKILL.md +89 -89
- package/skills/engineering/eng-environmental/LICENSE +21 -21
- package/skills/engineering/eng-environmental/SKILL.md +66 -66
- package/skills/engineering/eng-manufacturing/LICENSE +21 -21
- package/skills/engineering/eng-manufacturing/SKILL.md +78 -78
- package/skills/engineering/eng-mechanical/LICENSE +21 -21
- package/skills/engineering/eng-mechanical/SKILL.md +66 -66
- package/skills/engineering/eng-project/LICENSE +21 -21
- package/skills/engineering/eng-project/SKILL.md +72 -72
- package/skills/engineering/eng-propulsion/LICENSE +21 -21
- package/skills/engineering/eng-propulsion/SKILL.md +133 -133
- package/skills/engineering/eng-robotics/LICENSE +21 -21
- package/skills/engineering/eng-robotics/SKILL.md +92 -92
- package/skills/engineering/eng-systems/LICENSE +21 -21
- package/skills/engineering/eng-systems/SKILL.md +81 -81
- package/skills/environment/env-biodiversity/LICENSE +21 -21
- package/skills/environment/env-biodiversity/SKILL.md +66 -66
- package/skills/environment/env-circular-economy/LICENSE +21 -21
- package/skills/environment/env-circular-economy/SKILL.md +71 -71
- package/skills/environment/env-climate-action/LICENSE +21 -21
- package/skills/environment/env-climate-action/SKILL.md +55 -55
- package/skills/environment/env-energy/LICENSE +21 -21
- package/skills/environment/env-energy/SKILL.md +83 -83
- package/skills/environment/env-sustainability-biz/LICENSE +21 -21
- package/skills/environment/env-sustainability-biz/SKILL.md +65 -65
- package/skills/environment/env-water/LICENSE +21 -21
- package/skills/environment/env-water/SKILL.md +67 -67
- package/skills/finance/finance-accounting/LICENSE +21 -21
- package/skills/finance/finance-accounting/SKILL.md +239 -239
- package/skills/finance/finance-banking/LICENSE +21 -21
- package/skills/finance/finance-banking/SKILL.md +54 -54
- package/skills/finance/finance-corporate/LICENSE +21 -21
- package/skills/finance/finance-corporate/SKILL.md +105 -105
- package/skills/finance/finance-crypto/LICENSE +21 -21
- package/skills/finance/finance-crypto/SKILL.md +94 -94
- package/skills/finance/finance-debt-management/LICENSE +21 -21
- package/skills/finance/finance-debt-management/SKILL.md +87 -87
- package/skills/finance/finance-insurance/LICENSE +21 -21
- package/skills/finance/finance-insurance/SKILL.md +91 -91
- package/skills/finance/finance-investing/LICENSE +21 -21
- package/skills/finance/finance-investing/SKILL.md +269 -269
- package/skills/finance/finance-options-derivatives/LICENSE +21 -21
- package/skills/finance/finance-options-derivatives/SKILL.md +68 -68
- package/skills/finance/finance-personal/LICENSE +21 -21
- package/skills/finance/finance-personal/SKILL.md +268 -268
- package/skills/finance/finance-real-estate/LICENSE +21 -21
- package/skills/finance/finance-real-estate/SKILL.md +110 -110
- package/skills/finance/finance-startup/LICENSE +21 -21
- package/skills/finance/finance-startup/SKILL.md +253 -253
- package/skills/finance/finance-tax-planning/LICENSE +21 -21
- package/skills/finance/finance-tax-planning/SKILL.md +89 -89
- package/skills/finance/finance-trading/LICENSE +21 -21
- package/skills/finance/finance-trading/SKILL.md +112 -112
- package/skills/gemini/SKILL.md +51 -51
- package/skills/gh-issues/SKILL.md +216 -216
- package/skills/gifgrep/SKILL.md +89 -89
- package/skills/github/SKILL.md +87 -87
- package/skills/gog/SKILL.md +120 -120
- package/skills/goplaces/SKILL.md +56 -56
- package/skills/graphify/SKILL.md +619 -0
- package/skills/graphify/__init__.py +28 -0
- package/skills/graphify/__main__.py +4582 -0
- package/skills/graphify/affected.py +154 -0
- package/skills/graphify/always_on/agents-md.md +12 -0
- package/skills/graphify/always_on/antigravity-rules.md +14 -0
- package/skills/graphify/always_on/claude-md.md +9 -0
- package/skills/graphify/always_on/gemini-md.md +9 -0
- package/skills/graphify/always_on/kiro-steering.md +5 -0
- package/skills/graphify/always_on/vscode-instructions.md +17 -0
- package/skills/graphify/analyze.py +724 -0
- package/skills/graphify/benchmark.py +155 -0
- package/skills/graphify/build.py +487 -0
- package/skills/graphify/cache.py +417 -0
- package/skills/graphify/callflow_html.py +2020 -0
- package/skills/graphify/cluster.py +272 -0
- package/skills/graphify/command-kilo.md +15 -0
- package/skills/graphify/dedup.py +429 -0
- package/skills/graphify/detect.py +1379 -0
- package/skills/graphify/diagnostics.py +390 -0
- package/skills/graphify/export.py +1408 -0
- package/skills/graphify/extract.py +11570 -0
- package/skills/graphify/global_graph.py +159 -0
- package/skills/graphify/google_workspace.py +223 -0
- package/skills/graphify/hooks.py +457 -0
- package/skills/graphify/ingest.py +331 -0
- package/skills/graphify/llm.py +1896 -0
- package/skills/graphify/manifest.py +4 -0
- package/skills/graphify/mcp_ingest.py +392 -0
- package/skills/graphify/multigraph_compat.py +212 -0
- package/skills/graphify/pg_introspect.py +142 -0
- package/skills/graphify/prs.py +748 -0
- package/skills/graphify/querylog.py +70 -0
- package/skills/graphify/report.py +218 -0
- package/skills/graphify/scip_ingest.py +363 -0
- package/skills/graphify/security.py +336 -0
- package/skills/graphify/semantic_cleanup.py +319 -0
- package/skills/graphify/serve.py +1309 -0
- package/skills/graphify/skill-aider.md +1246 -0
- package/skills/graphify/skill-amp.md +613 -0
- package/skills/graphify/skill-claw.md +616 -0
- package/skills/graphify/skill-codex.md +613 -0
- package/skills/graphify/skill-copilot.md +616 -0
- package/skills/graphify/skill-devin.md +1372 -0
- package/skills/graphify/skill-droid.md +613 -0
- package/skills/graphify/skill-kilo.md +625 -0
- package/skills/graphify/skill-kiro.md +615 -0
- package/skills/graphify/skill-opencode.md +608 -0
- package/skills/graphify/skill-pi.md +615 -0
- package/skills/graphify/skill-trae.md +614 -0
- package/skills/graphify/skill-vscode.md +612 -0
- package/skills/graphify/skill-windows.md +651 -0
- package/skills/graphify/skills/amp/references/add-watch.md +56 -0
- package/skills/graphify/skills/amp/references/exports.md +71 -0
- package/skills/graphify/skills/amp/references/extraction-spec.md +68 -0
- package/skills/graphify/skills/amp/references/github-and-merge.md +46 -0
- package/skills/graphify/skills/amp/references/hooks.md +33 -0
- package/skills/graphify/skills/amp/references/query.md +249 -0
- package/skills/graphify/skills/amp/references/transcribe.md +48 -0
- package/skills/graphify/skills/amp/references/update.md +179 -0
- package/skills/graphify/skills/claude/references/add-watch.md +56 -0
- package/skills/graphify/skills/claude/references/exports.md +71 -0
- package/skills/graphify/skills/claude/references/extraction-spec.md +68 -0
- package/skills/graphify/skills/claude/references/github-and-merge.md +46 -0
- package/skills/graphify/skills/claude/references/hooks.md +33 -0
- package/skills/graphify/skills/claude/references/query.md +103 -0
- package/skills/graphify/skills/claude/references/transcribe.md +48 -0
- package/skills/graphify/skills/claude/references/update.md +179 -0
- package/skills/graphify/skills/claw/references/add-watch.md +56 -0
- package/skills/graphify/skills/claw/references/exports.md +71 -0
- package/skills/graphify/skills/claw/references/extraction-spec.md +29 -0
- package/skills/graphify/skills/claw/references/github-and-merge.md +46 -0
- package/skills/graphify/skills/claw/references/hooks.md +33 -0
- package/skills/graphify/skills/claw/references/query.md +249 -0
- package/skills/graphify/skills/claw/references/transcribe.md +48 -0
- package/skills/graphify/skills/claw/references/update.md +179 -0
- package/skills/graphify/skills/codex/references/add-watch.md +56 -0
- package/skills/graphify/skills/codex/references/exports.md +71 -0
- package/skills/graphify/skills/codex/references/extraction-spec.md +29 -0
- package/skills/graphify/skills/codex/references/github-and-merge.md +46 -0
- package/skills/graphify/skills/codex/references/hooks.md +33 -0
- package/skills/graphify/skills/codex/references/query.md +249 -0
- package/skills/graphify/skills/codex/references/transcribe.md +48 -0
- package/skills/graphify/skills/codex/references/update.md +179 -0
- package/skills/graphify/skills/copilot/references/add-watch.md +56 -0
- package/skills/graphify/skills/copilot/references/exports.md +71 -0
- package/skills/graphify/skills/copilot/references/extraction-spec.md +68 -0
- package/skills/graphify/skills/copilot/references/github-and-merge.md +46 -0
- package/skills/graphify/skills/copilot/references/hooks.md +33 -0
- package/skills/graphify/skills/copilot/references/query.md +249 -0
- package/skills/graphify/skills/copilot/references/transcribe.md +48 -0
- package/skills/graphify/skills/copilot/references/update.md +179 -0
- package/skills/graphify/skills/droid/references/add-watch.md +56 -0
- package/skills/graphify/skills/droid/references/exports.md +71 -0
- package/skills/graphify/skills/droid/references/extraction-spec.md +68 -0
- package/skills/graphify/skills/droid/references/github-and-merge.md +46 -0
- package/skills/graphify/skills/droid/references/hooks.md +33 -0
- package/skills/graphify/skills/droid/references/query.md +249 -0
- package/skills/graphify/skills/droid/references/transcribe.md +48 -0
- package/skills/graphify/skills/droid/references/update.md +179 -0
- package/skills/graphify/skills/kilo/references/add-watch.md +56 -0
- package/skills/graphify/skills/kilo/references/exports.md +71 -0
- package/skills/graphify/skills/kilo/references/extraction-spec.md +68 -0
- package/skills/graphify/skills/kilo/references/github-and-merge.md +46 -0
- package/skills/graphify/skills/kilo/references/hooks.md +33 -0
- package/skills/graphify/skills/kilo/references/query.md +249 -0
- package/skills/graphify/skills/kilo/references/transcribe.md +48 -0
- package/skills/graphify/skills/kilo/references/update.md +179 -0
- package/skills/graphify/skills/kiro/references/add-watch.md +56 -0
- package/skills/graphify/skills/kiro/references/exports.md +71 -0
- package/skills/graphify/skills/kiro/references/extraction-spec.md +29 -0
- package/skills/graphify/skills/kiro/references/github-and-merge.md +46 -0
- package/skills/graphify/skills/kiro/references/hooks.md +33 -0
- package/skills/graphify/skills/kiro/references/query.md +249 -0
- package/skills/graphify/skills/kiro/references/transcribe.md +48 -0
- package/skills/graphify/skills/kiro/references/update.md +179 -0
- package/skills/graphify/skills/opencode/references/add-watch.md +56 -0
- package/skills/graphify/skills/opencode/references/exports.md +71 -0
- package/skills/graphify/skills/opencode/references/extraction-spec.md +68 -0
- package/skills/graphify/skills/opencode/references/github-and-merge.md +46 -0
- package/skills/graphify/skills/opencode/references/hooks.md +33 -0
- package/skills/graphify/skills/opencode/references/query.md +249 -0
- package/skills/graphify/skills/opencode/references/transcribe.md +48 -0
- package/skills/graphify/skills/opencode/references/update.md +179 -0
- package/skills/graphify/skills/pi/references/add-watch.md +56 -0
- package/skills/graphify/skills/pi/references/exports.md +71 -0
- package/skills/graphify/skills/pi/references/extraction-spec.md +29 -0
- package/skills/graphify/skills/pi/references/github-and-merge.md +46 -0
- package/skills/graphify/skills/pi/references/hooks.md +33 -0
- package/skills/graphify/skills/pi/references/query.md +249 -0
- package/skills/graphify/skills/pi/references/transcribe.md +48 -0
- package/skills/graphify/skills/pi/references/update.md +179 -0
- package/skills/graphify/skills/trae/references/add-watch.md +56 -0
- package/skills/graphify/skills/trae/references/exports.md +71 -0
- package/skills/graphify/skills/trae/references/extraction-spec.md +68 -0
- package/skills/graphify/skills/trae/references/github-and-merge.md +46 -0
- package/skills/graphify/skills/trae/references/hooks.md +35 -0
- package/skills/graphify/skills/trae/references/query.md +249 -0
- package/skills/graphify/skills/trae/references/transcribe.md +48 -0
- package/skills/graphify/skills/trae/references/update.md +179 -0
- package/skills/graphify/skills/vscode/references/add-watch.md +56 -0
- package/skills/graphify/skills/vscode/references/exports.md +71 -0
- package/skills/graphify/skills/vscode/references/extraction-spec.md +68 -0
- package/skills/graphify/skills/vscode/references/github-and-merge.md +46 -0
- package/skills/graphify/skills/vscode/references/hooks.md +33 -0
- package/skills/graphify/skills/vscode/references/query.md +249 -0
- package/skills/graphify/skills/vscode/references/transcribe.md +48 -0
- package/skills/graphify/skills/vscode/references/update.md +179 -0
- package/skills/graphify/skills/windows/references/add-watch.md +56 -0
- package/skills/graphify/skills/windows/references/exports.md +71 -0
- package/skills/graphify/skills/windows/references/extraction-spec.md +68 -0
- package/skills/graphify/skills/windows/references/github-and-merge.md +46 -0
- package/skills/graphify/skills/windows/references/hooks.md +33 -0
- package/skills/graphify/skills/windows/references/query.md +249 -0
- package/skills/graphify/skills/windows/references/transcribe.md +48 -0
- package/skills/graphify/skills/windows/references/update.md +179 -0
- package/skills/graphify/symbol_resolution.py +538 -0
- package/skills/graphify/transcribe.py +184 -0
- package/skills/graphify/tree_html.py +582 -0
- package/skills/graphify/validate.py +72 -0
- package/skills/graphify/watch.py +898 -0
- package/skills/graphify/wiki.py +282 -0
- package/skills/health/health-aging/LICENSE +21 -21
- package/skills/health/health-aging/SKILL.md +82 -82
- package/skills/health/health-chronic/LICENSE +21 -21
- package/skills/health/health-chronic/SKILL.md +202 -202
- package/skills/health/health-dental/LICENSE +21 -21
- package/skills/health/health-dental/SKILL.md +41 -41
- package/skills/health/health-eye-care/LICENSE +21 -21
- package/skills/health/health-eye-care/SKILL.md +56 -56
- package/skills/health/health-first-aid/LICENSE +21 -21
- package/skills/health/health-first-aid/SKILL.md +201 -201
- package/skills/health/health-fitness/LICENSE +21 -21
- package/skills/health/health-fitness/SKILL.md +111 -111
- package/skills/health/health-general/LICENSE +21 -21
- package/skills/health/health-general/SKILL.md +277 -277
- package/skills/health/health-mens/LICENSE +21 -21
- package/skills/health/health-mens/SKILL.md +53 -53
- package/skills/health/health-mental/LICENSE +21 -21
- package/skills/health/health-mental/SKILL.md +221 -221
- package/skills/health/health-naturopathy-ayurveda/LICENSE +21 -21
- package/skills/health/health-naturopathy-ayurveda/SKILL.md +60 -60
- package/skills/health/health-nutrition/LICENSE +21 -21
- package/skills/health/health-nutrition/SKILL.md +262 -262
- package/skills/health/health-pediatric/LICENSE +21 -21
- package/skills/health/health-pediatric/SKILL.md +94 -94
- package/skills/health/health-pharmacology/LICENSE +21 -21
- package/skills/health/health-pharmacology/SKILL.md +87 -87
- package/skills/health/health-pregnancy/LICENSE +21 -21
- package/skills/health/health-pregnancy/SKILL.md +71 -71
- package/skills/health/health-skin/LICENSE +21 -21
- package/skills/health/health-skin/SKILL.md +71 -71
- package/skills/health/health-sleep/LICENSE +21 -21
- package/skills/health/health-sleep/SKILL.md +81 -81
- package/skills/health/health-womens/LICENSE +21 -21
- package/skills/health/health-womens/SKILL.md +72 -72
- package/skills/health/health-yoga-wellness/LICENSE +21 -21
- package/skills/health/health-yoga-wellness/SKILL.md +58 -58
- package/skills/healthcare-systems/health-sys-global/LICENSE +21 -21
- package/skills/healthcare-systems/health-sys-global/SKILL.md +69 -69
- package/skills/healthcare-systems/health-sys-management/LICENSE +21 -21
- package/skills/healthcare-systems/health-sys-management/SKILL.md +71 -71
- package/skills/healthcare-systems/health-sys-navigation/LICENSE +21 -21
- package/skills/healthcare-systems/health-sys-navigation/SKILL.md +60 -60
- package/skills/healthcare-systems/health-sys-public/LICENSE +21 -21
- package/skills/healthcare-systems/health-sys-public/SKILL.md +71 -71
- package/skills/healthcheck/SKILL.md +109 -109
- package/skills/himalaya/SKILL.md +84 -84
- package/skills/himalaya/references/configuration.md +184 -184
- package/skills/himalaya/references/message-composition.md +199 -199
- package/skills/humanities/humanities-history-world/LICENSE +21 -21
- package/skills/humanities/humanities-history-world/SKILL.md +59 -59
- package/skills/humanities/humanities-indian-classical/LICENSE +21 -21
- package/skills/humanities/humanities-indian-classical/SKILL.md +104 -104
- package/skills/humanities/humanities-philosophy/LICENSE +21 -21
- package/skills/humanities/humanities-philosophy/SKILL.md +105 -105
- package/skills/humanities/humanities-world-religions/LICENSE +21 -21
- package/skills/humanities/humanities-world-religions/SKILL.md +67 -67
- package/skills/impeccable/SKILL.md +186 -0
- package/skills/impeccable/agents/impeccable_asset_producer.toml +92 -0
- package/skills/impeccable/agents/impeccable_manual_edit_applier.toml +95 -0
- package/skills/impeccable/agents/openai.yaml +4 -0
- package/skills/impeccable/reference/adapt.md +311 -0
- package/skills/impeccable/reference/animate.md +201 -0
- package/skills/impeccable/reference/audit.md +133 -0
- package/skills/impeccable/reference/bolder.md +113 -0
- package/skills/impeccable/reference/brand.md +108 -0
- package/skills/impeccable/reference/clarify.md +288 -0
- package/skills/impeccable/reference/codex.md +105 -0
- package/skills/impeccable/reference/colorize.md +257 -0
- package/skills/impeccable/reference/craft.md +123 -0
- package/skills/impeccable/reference/critique.md +790 -0
- package/skills/impeccable/reference/delight.md +302 -0
- package/skills/impeccable/reference/distill.md +111 -0
- package/skills/impeccable/reference/document.md +429 -0
- package/skills/impeccable/reference/extract.md +69 -0
- package/skills/impeccable/reference/harden.md +347 -0
- package/skills/impeccable/reference/init.md +172 -0
- package/skills/impeccable/reference/interaction-design.md +189 -0
- package/skills/impeccable/reference/layout.md +161 -0
- package/skills/impeccable/reference/live.md +720 -0
- package/skills/impeccable/reference/onboard.md +234 -0
- package/skills/impeccable/reference/optimize.md +258 -0
- package/skills/impeccable/reference/overdrive.md +130 -0
- package/skills/impeccable/reference/polish.md +241 -0
- package/skills/impeccable/reference/product.md +60 -0
- package/skills/impeccable/reference/quieter.md +99 -0
- package/skills/impeccable/reference/shape.md +165 -0
- package/skills/impeccable/reference/typeset.md +279 -0
- package/skills/impeccable/scripts/cleanup-deprecated.mjs +284 -0
- package/skills/impeccable/scripts/command-metadata.json +94 -0
- package/skills/impeccable/scripts/context-signals.mjs +225 -0
- package/skills/impeccable/scripts/context.mjs +266 -0
- package/skills/impeccable/scripts/critique-storage.mjs +242 -0
- package/skills/impeccable/scripts/design-parser.mjs +835 -0
- package/skills/impeccable/scripts/detect-csp.mjs +198 -0
- package/skills/impeccable/scripts/detect.mjs +21 -0
- package/skills/impeccable/scripts/detector/browser/injected/index.mjs +1733 -0
- package/skills/impeccable/scripts/detector/cli/main.mjs +244 -0
- package/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +4618 -0
- package/skills/impeccable/scripts/detector/detect-antipatterns.mjs +43 -0
- package/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +252 -0
- package/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +535 -0
- package/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +986 -0
- package/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +208 -0
- package/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +189 -0
- package/skills/impeccable/scripts/detector/findings.mjs +12 -0
- package/skills/impeccable/scripts/detector/node/file-system.mjs +198 -0
- package/skills/impeccable/scripts/detector/profile/profiler.mjs +166 -0
- package/skills/impeccable/scripts/detector/registry/antipatterns.mjs +419 -0
- package/skills/impeccable/scripts/detector/rules/checks.mjs +2384 -0
- package/skills/impeccable/scripts/detector/shared/color.mjs +124 -0
- package/skills/impeccable/scripts/detector/shared/constants.mjs +101 -0
- package/skills/impeccable/scripts/detector/shared/page.mjs +7 -0
- package/skills/impeccable/scripts/impeccable-paths.mjs +126 -0
- package/skills/impeccable/scripts/is-generated.mjs +69 -0
- package/skills/impeccable/scripts/live-accept.mjs +812 -0
- package/skills/impeccable/scripts/live-browser-session.js +123 -0
- package/skills/impeccable/scripts/live-browser.js +10295 -0
- package/skills/impeccable/scripts/live-commit-manual-edits.mjs +1241 -0
- package/skills/impeccable/scripts/live-complete.mjs +75 -0
- package/skills/impeccable/scripts/live-completion.mjs +19 -0
- package/skills/impeccable/scripts/live-copy-edit-agent.mjs +683 -0
- package/skills/impeccable/scripts/live-discard-manual-edits.mjs +51 -0
- package/skills/impeccable/scripts/live-event-validation.mjs +137 -0
- package/skills/impeccable/scripts/live-inject.mjs +557 -0
- package/skills/impeccable/scripts/live-insert-ui.mjs +458 -0
- package/skills/impeccable/scripts/live-insert.mjs +272 -0
- package/skills/impeccable/scripts/live-manual-edit-evidence.mjs +363 -0
- package/skills/impeccable/scripts/live-manual-edits-buffer.mjs +152 -0
- package/skills/impeccable/scripts/live-poll.mjs +379 -0
- package/skills/impeccable/scripts/live-resume.mjs +94 -0
- package/skills/impeccable/scripts/live-server.mjs +2326 -0
- package/skills/impeccable/scripts/live-session-store.mjs +289 -0
- package/skills/impeccable/scripts/live-status.mjs +61 -0
- package/skills/impeccable/scripts/live-svelte-component.mjs +826 -0
- package/skills/impeccable/scripts/live-sveltekit-adapter.mjs +274 -0
- package/skills/impeccable/scripts/live-ui-core.mjs +179 -0
- package/skills/impeccable/scripts/live-vocabulary.mjs +36 -0
- package/skills/impeccable/scripts/live-wrap.mjs +894 -0
- package/skills/impeccable/scripts/live.mjs +246 -0
- package/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/skills/impeccable/scripts/palette.mjs +633 -0
- package/skills/impeccable/scripts/pin.mjs +214 -0
- package/skills/imsg/SKILL.md +126 -126
- package/skills/industry/industry-construction/LICENSE +21 -21
- package/skills/industry/industry-construction/SKILL.md +81 -81
- package/skills/industry/industry-education-sector/LICENSE +21 -21
- package/skills/industry/industry-education-sector/SKILL.md +49 -49
- package/skills/industry/industry-fashion/LICENSE +21 -21
- package/skills/industry/industry-fashion/SKILL.md +82 -82
- package/skills/industry/industry-food/LICENSE +21 -21
- package/skills/industry/industry-food/SKILL.md +79 -79
- package/skills/industry/industry-government/LICENSE +21 -21
- package/skills/industry/industry-government/SKILL.md +80 -80
- package/skills/industry/industry-hospitality/LICENSE +21 -21
- package/skills/industry/industry-hospitality/SKILL.md +73 -73
- package/skills/industry/industry-insurance-sector/LICENSE +21 -21
- package/skills/industry/industry-insurance-sector/SKILL.md +57 -57
- package/skills/industry/industry-logistics/LICENSE +21 -21
- package/skills/industry/industry-logistics/SKILL.md +80 -80
- package/skills/industry/industry-media/LICENSE +21 -21
- package/skills/industry/industry-media/SKILL.md +66 -66
- package/skills/industry/industry-nonprofit/LICENSE +21 -21
- package/skills/industry/industry-nonprofit/SKILL.md +77 -77
- package/skills/industry/industry-pharma/LICENSE +21 -21
- package/skills/industry/industry-pharma/SKILL.md +69 -69
- package/skills/industry/industry-real-estate/LICENSE +21 -21
- package/skills/industry/industry-real-estate/SKILL.md +61 -61
- package/skills/industry/industry-sports/LICENSE +21 -21
- package/skills/industry/industry-sports/SKILL.md +71 -71
- package/skills/industry/industry-tech-startup/LICENSE +21 -21
- package/skills/industry/industry-tech-startup/SKILL.md +82 -82
- package/skills/internal-comms/LICENSE +21 -21
- package/skills/internal-comms/SKILL.md +38 -38
- package/skills/internal-comms/examples/3p-updates.md +49 -49
- package/skills/internal-comms/examples/company-newsletter.md +76 -76
- package/skills/internal-comms/examples/faq-answers.md +35 -35
- package/skills/internal-comms/examples/general-comms.md +19 -19
- package/skills/legal/legal-business/LICENSE +21 -21
- package/skills/legal/legal-business/SKILL.md +227 -227
- package/skills/legal/legal-consumer/LICENSE +21 -21
- package/skills/legal/legal-consumer/SKILL.md +155 -155
- package/skills/legal/legal-contracts/LICENSE +21 -21
- package/skills/legal/legal-contracts/SKILL.md +268 -268
- package/skills/legal/legal-corporate-governance/LICENSE +21 -21
- package/skills/legal/legal-corporate-governance/SKILL.md +53 -53
- package/skills/legal/legal-employment/LICENSE +21 -21
- package/skills/legal/legal-employment/SKILL.md +291 -291
- package/skills/legal/legal-immigration/LICENSE +21 -21
- package/skills/legal/legal-immigration/SKILL.md +146 -146
- package/skills/legal/legal-international/LICENSE +21 -21
- package/skills/legal/legal-international/SKILL.md +51 -51
- package/skills/legal/legal-ip/LICENSE +21 -21
- package/skills/legal/legal-ip/SKILL.md +264 -264
- package/skills/legal/legal-privacy/LICENSE +21 -21
- package/skills/legal/legal-privacy/SKILL.md +161 -161
- package/skills/legal/legal-real-estate/LICENSE +21 -21
- package/skills/legal/legal-real-estate/SKILL.md +142 -142
- package/skills/legal/legal-startup/LICENSE +21 -21
- package/skills/legal/legal-startup/SKILL.md +182 -182
- package/skills/legal/legal-tax/LICENSE +21 -21
- package/skills/legal/legal-tax/SKILL.md +156 -156
- package/skills/mcp-builder/LICENSE +21 -21
- package/skills/mcp-builder/SKILL.md +257 -257
- package/skills/mcp-builder/reference/evaluation.md +630 -630
- package/skills/mcp-builder/reference/mcp_best_practices.md +269 -269
- package/skills/mcp-builder/reference/node_mcp_server.md +980 -980
- package/skills/mcp-builder/reference/python_mcp_server.md +737 -737
- package/skills/mcp-builder/scripts/connections.py +151 -151
- package/skills/mcp-builder/scripts/evaluation.py +373 -373
- package/skills/mcp-builder/scripts/example_evaluation.xml +22 -22
- package/skills/mcp-builder/scripts/requirements.txt +2 -2
- package/skills/mcporter/SKILL.md +65 -65
- package/skills/meme-maker/SKILL.md +46 -46
- package/skills/meme-maker/references/templates.json +358 -358
- package/skills/meme-maker/scripts/meme.mjs +398 -398
- package/skills/mental-health/mental-health-cbt/LICENSE +21 -21
- package/skills/mental-health/mental-health-cbt/SKILL.md +254 -254
- package/skills/mental-health/psych-addiction/LICENSE +21 -21
- package/skills/mental-health/psych-addiction/SKILL.md +79 -79
- package/skills/mental-health/psych-behavioral-econ/LICENSE +21 -21
- package/skills/mental-health/psych-behavioral-econ/SKILL.md +84 -84
- package/skills/mental-health/psych-child/LICENSE +21 -21
- package/skills/mental-health/psych-child/SKILL.md +84 -84
- package/skills/mental-health/psych-grief/LICENSE +21 -21
- package/skills/mental-health/psych-grief/SKILL.md +85 -85
- package/skills/mental-health/psych-mindfulness/LICENSE +21 -21
- package/skills/mental-health/psych-mindfulness/SKILL.md +71 -71
- package/skills/mental-health/psych-org/LICENSE +21 -21
- package/skills/mental-health/psych-org/SKILL.md +115 -115
- package/skills/mental-health/psych-positive/LICENSE +21 -21
- package/skills/mental-health/psych-positive/SKILL.md +86 -86
- package/skills/mental-health/psych-relationships/LICENSE +21 -21
- package/skills/mental-health/psych-relationships/SKILL.md +100 -100
- package/skills/mental-health/psych-trauma/LICENSE +21 -21
- package/skills/mental-health/psych-trauma/SKILL.md +109 -109
- package/skills/model-usage/SKILL.md +75 -75
- package/skills/model-usage/references/codexbar-cli.md +33 -33
- package/skills/model-usage/scripts/model_usage.py +319 -319
- package/skills/model-usage/scripts/test_model_usage.py +40 -40
- package/skills/nano-pdf/SKILL.md +42 -42
- package/skills/node-connect/SKILL.md +147 -147
- package/skills/node-inspect-debugger/SKILL.md +88 -88
- package/skills/notion/SKILL.md +154 -154
- package/skills/obsidian/SKILL.md +123 -123
- package/skills/openai-whisper/SKILL.md +42 -42
- package/skills/openai-whisper-api/SKILL.md +75 -75
- package/skills/openai-whisper-api/scripts/transcribe.sh +154 -154
- package/skills/openhue/SKILL.md +116 -116
- package/skills/oracle/SKILL.md +130 -130
- package/skills/ordercli/SKILL.md +82 -82
- package/skills/peekaboo/SKILL.md +217 -217
- package/skills/pyproject.toml +10 -10
- package/skills/python-debugpy/SKILL.md +76 -76
- package/skills/sag/SKILL.md +91 -91
- package/skills/science/sci-astronomy/LICENSE +21 -21
- package/skills/science/sci-astronomy/SKILL.md +80 -80
- package/skills/science/sci-biology/LICENSE +21 -21
- package/skills/science/sci-biology/SKILL.md +74 -74
- package/skills/science/sci-chemistry/LICENSE +21 -21
- package/skills/science/sci-chemistry/SKILL.md +89 -89
- package/skills/science/sci-climate/LICENSE +21 -21
- package/skills/science/sci-climate/SKILL.md +72 -72
- package/skills/science/sci-data-analysis/LICENSE +21 -21
- package/skills/science/sci-data-analysis/SKILL.md +87 -87
- package/skills/science/sci-environmental-science/LICENSE +21 -21
- package/skills/science/sci-environmental-science/SKILL.md +69 -69
- package/skills/science/sci-geology/LICENSE +21 -21
- package/skills/science/sci-geology/SKILL.md +56 -56
- package/skills/science/sci-method/LICENSE +21 -21
- package/skills/science/sci-method/SKILL.md +77 -77
- package/skills/science/sci-neuroscience/LICENSE +21 -21
- package/skills/science/sci-neuroscience/SKILL.md +79 -79
- package/skills/science/sci-physics/LICENSE +21 -21
- package/skills/science/sci-physics/SKILL.md +78 -78
- package/skills/science/sci-research-methods/LICENSE +21 -21
- package/skills/science/sci-research-methods/SKILL.md +83 -83
- package/skills/science/sci-statistics/LICENSE +21 -21
- package/skills/science/sci-statistics/SKILL.md +249 -249
- package/skills/session-logs/SKILL.md +155 -155
- package/skills/sherpa-onnx-tts/SKILL.md +113 -113
- package/skills/skill-creator/SKILL.md +81 -81
- package/skills/skill-creator/license.txt +202 -202
- package/skills/skill-creator/scripts/init_skill.py +378 -378
- package/skills/skill-creator/scripts/package_skill.py +144 -144
- package/skills/skill-creator/scripts/quick_validate.py +169 -169
- package/skills/skill-creator/scripts/test_init_skill.py +51 -51
- package/skills/skill-creator/scripts/test_package_skill.py +199 -199
- package/skills/skill-creator/scripts/test_quick_validate.py +116 -116
- package/skills/slack/SKILL.md +82 -82
- package/skills/slack-gif-creator/LICENSE +21 -21
- package/skills/slack-gif-creator/SKILL.md +293 -293
- package/skills/slack-gif-creator/requirements.txt +3 -3
- package/skills/social-sciences/social-anthropology/LICENSE +21 -21
- package/skills/social-sciences/social-anthropology/SKILL.md +62 -62
- package/skills/social-sciences/social-economics/LICENSE +21 -21
- package/skills/social-sciences/social-economics/SKILL.md +88 -88
- package/skills/social-sciences/social-geography/LICENSE +21 -21
- package/skills/social-sciences/social-geography/SKILL.md +61 -61
- package/skills/social-sciences/social-international-dev/LICENSE +21 -21
- package/skills/social-sciences/social-international-dev/SKILL.md +76 -76
- package/skills/social-sciences/social-political-science/LICENSE +21 -21
- package/skills/social-sciences/social-political-science/SKILL.md +70 -70
- package/skills/social-sciences/social-public-policy/LICENSE +21 -21
- package/skills/social-sciences/social-public-policy/SKILL.md +73 -73
- package/skills/social-sciences/social-sociology/LICENSE +21 -21
- package/skills/social-sciences/social-sociology/SKILL.md +78 -78
- package/skills/songsee/SKILL.md +53 -53
- package/skills/sonoscli/SKILL.md +69 -69
- package/skills/spike/SKILL.md +55 -55
- package/skills/spotify-player/SKILL.md +68 -68
- package/skills/summarize/SKILL.md +90 -90
- package/skills/taskflow/SKILL.md +153 -153
- package/skills/taskflow/examples/inbox-triage.lobster +33 -33
- package/skills/taskflow/examples/pr-intake.lobster +32 -32
- package/skills/taskflow-inbox-triage/SKILL.md +123 -123
- package/skills/technical/ai-ethics/LICENSE +21 -21
- package/skills/technical/ai-ethics/SKILL.md +92 -92
- package/skills/technical/ai-product-builder/LICENSE +21 -21
- package/skills/technical/ai-product-builder/SKILL.md +180 -180
- package/skills/technical/analytics-setup/LICENSE +21 -21
- package/skills/technical/analytics-setup/SKILL.md +125 -125
- package/skills/technical/api-builder/LICENSE +21 -21
- package/skills/technical/api-builder/SKILL.md +202 -202
- package/skills/technical/architecture-decisions/LICENSE +21 -21
- package/skills/technical/architecture-decisions/SKILL.md +120 -120
- package/skills/technical/auth-security/LICENSE +21 -21
- package/skills/technical/auth-security/SKILL.md +209 -209
- package/skills/technical/blockchain-web3/LICENSE +21 -21
- package/skills/technical/blockchain-web3/SKILL.md +84 -84
- package/skills/technical/cloud-architecture/LICENSE +21 -21
- package/skills/technical/cloud-architecture/SKILL.md +85 -85
- package/skills/technical/content-platform/LICENSE +21 -21
- package/skills/technical/content-platform/SKILL.md +134 -134
- package/skills/technical/cybersecurity-advanced/LICENSE +21 -21
- package/skills/technical/cybersecurity-advanced/SKILL.md +99 -99
- package/skills/technical/data-engineering/LICENSE +21 -21
- package/skills/technical/data-engineering/SKILL.md +117 -117
- package/skills/technical/database-design/LICENSE +21 -21
- package/skills/technical/database-design/SKILL.md +185 -185
- package/skills/technical/devops-cicd/LICENSE +21 -21
- package/skills/technical/devops-cicd/SKILL.md +181 -181
- package/skills/technical/ecommerce-builder/LICENSE +21 -21
- package/skills/technical/ecommerce-builder/SKILL.md +123 -123
- package/skills/technical/email-marketing/LICENSE +21 -21
- package/skills/technical/email-marketing/SKILL.md +128 -128
- package/skills/technical/fintech-builder/LICENSE +21 -21
- package/skills/technical/fintech-builder/SKILL.md +141 -141
- package/skills/technical/full-stack-web/LICENSE +21 -21
- package/skills/technical/full-stack-web/SKILL.md +173 -173
- package/skills/technical/gdpr-basics/LICENSE +21 -21
- package/skills/technical/gdpr-basics/SKILL.md +145 -145
- package/skills/technical/launch-playbook/LICENSE +21 -21
- package/skills/technical/launch-playbook/SKILL.md +95 -95
- package/skills/technical/marketing-copy/LICENSE +21 -21
- package/skills/technical/marketing-copy/SKILL.md +126 -126
- package/skills/technical/marketplace-builder/LICENSE +21 -21
- package/skills/technical/marketplace-builder/SKILL.md +105 -105
- package/skills/technical/mobile-pwa/LICENSE +21 -21
- package/skills/technical/mobile-pwa/SKILL.md +191 -191
- package/skills/technical/no-code-tools/LICENSE +21 -21
- package/skills/technical/no-code-tools/SKILL.md +80 -80
- package/skills/technical/open-source/LICENSE +21 -21
- package/skills/technical/open-source/SKILL.md +71 -71
- package/skills/technical/performance-optimization/LICENSE +21 -21
- package/skills/technical/performance-optimization/SKILL.md +155 -155
- package/skills/technical/pricing-design/LICENSE +21 -21
- package/skills/technical/pricing-design/SKILL.md +87 -87
- package/skills/technical/product-management/LICENSE +21 -21
- package/skills/technical/product-management/SKILL.md +94 -94
- package/skills/technical/saas-builder/LICENSE +21 -21
- package/skills/technical/saas-builder/SKILL.md +138 -138
- package/skills/technical/scope-estimation/LICENSE +21 -21
- package/skills/technical/scope-estimation/SKILL.md +99 -99
- package/skills/technical/secrets-management/LICENSE +21 -21
- package/skills/technical/secrets-management/SKILL.md +135 -135
- package/skills/technical/seo-technical/LICENSE +21 -21
- package/skills/technical/seo-technical/SKILL.md +136 -136
- package/skills/technical/technical-writing/LICENSE +21 -21
- package/skills/technical/technical-writing/SKILL.md +149 -149
- package/skills/technical/ux-research-tools/LICENSE +21 -21
- package/skills/technical/ux-research-tools/SKILL.md +54 -54
- package/skills/theme-factory/LICENSE +21 -21
- package/skills/theme-factory/SKILL.md +65 -65
- package/skills/theme-factory/themes/arctic-frost.md +19 -19
- package/skills/theme-factory/themes/botanical-garden.md +19 -19
- package/skills/theme-factory/themes/desert-rose.md +19 -19
- package/skills/theme-factory/themes/forest-canopy.md +19 -19
- package/skills/theme-factory/themes/golden-hour.md +19 -19
- package/skills/theme-factory/themes/midnight-galaxy.md +19 -19
- package/skills/theme-factory/themes/modern-minimalist.md +19 -19
- package/skills/theme-factory/themes/ocean-depths.md +19 -19
- package/skills/theme-factory/themes/sunset-boulevard.md +19 -19
- package/skills/theme-factory/themes/tech-innovation.md +19 -19
- package/skills/things-mac/SKILL.md +90 -90
- package/skills/tmux/SKILL.md +95 -95
- package/skills/tmux/scripts/find-sessions.sh +112 -112
- package/skills/tmux/scripts/wait-for-text.sh +83 -83
- package/skills/trades/trades-agriculture/LICENSE +21 -21
- package/skills/trades/trades-agriculture/SKILL.md +80 -80
- package/skills/trades/trades-automotive/LICENSE +21 -21
- package/skills/trades/trades-automotive/SKILL.md +84 -84
- package/skills/trades/trades-carpentry/LICENSE +21 -21
- package/skills/trades/trades-carpentry/SKILL.md +71 -71
- package/skills/trades/trades-cooking-pro/LICENSE +21 -21
- package/skills/trades/trades-cooking-pro/SKILL.md +90 -90
- package/skills/trades/trades-electrical/LICENSE +21 -21
- package/skills/trades/trades-electrical/SKILL.md +146 -146
- package/skills/trades/trades-hvac/LICENSE +21 -21
- package/skills/trades/trades-hvac/SKILL.md +80 -80
- package/skills/trades/trades-landscaping/LICENSE +21 -21
- package/skills/trades/trades-landscaping/SKILL.md +60 -60
- package/skills/trades/trades-metalworking/LICENSE +21 -21
- package/skills/trades/trades-metalworking/SKILL.md +64 -64
- package/skills/trades/trades-painting/LICENSE +21 -21
- package/skills/trades/trades-painting/SKILL.md +70 -70
- package/skills/trades/trades-plumbing/LICENSE +21 -21
- package/skills/trades/trades-plumbing/SKILL.md +160 -160
- package/skills/trades/trades-welding/LICENSE +21 -21
- package/skills/trades/trades-welding/SKILL.md +82 -82
- package/skills/trello/SKILL.md +112 -112
- package/skills/uipm-ui-styling/LICENSE.txt +202 -0
- package/skills/uipm-ui-styling/SKILL.md +328 -0
- package/skills/uipm-ui-styling/canvas-fonts/ArsenalSC-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/ArsenalSC-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/BigShoulders-Bold.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/BigShoulders-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/BigShoulders-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/Boldonse-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/Boldonse-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/BricolageGrotesque-Bold.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/BricolageGrotesque-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/BricolageGrotesque-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/CrimsonPro-Bold.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/CrimsonPro-Italic.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/CrimsonPro-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/CrimsonPro-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/DMMono-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/DMMono-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/EricaOne-OFL.txt +94 -0
- package/skills/uipm-ui-styling/canvas-fonts/EricaOne-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/GeistMono-Bold.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/GeistMono-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/GeistMono-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/Gloock-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/Gloock-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/IBMPlexMono-Bold.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/IBMPlexMono-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/IBMPlexMono-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/IBMPlexSerif-Bold.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/IBMPlexSerif-BoldItalic.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/IBMPlexSerif-Italic.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/IBMPlexSerif-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/InstrumentSans-Bold.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/InstrumentSans-BoldItalic.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/InstrumentSans-Italic.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/InstrumentSans-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/InstrumentSans-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/InstrumentSerif-Italic.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/InstrumentSerif-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/Italiana-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/Italiana-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/JetBrainsMono-Bold.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/JetBrainsMono-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/JetBrainsMono-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/Jura-Light.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/Jura-Medium.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/Jura-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/LibreBaskerville-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/LibreBaskerville-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/Lora-Bold.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/Lora-BoldItalic.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/Lora-Italic.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/Lora-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/Lora-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/NationalPark-Bold.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/NationalPark-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/NationalPark-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/NothingYouCouldDo-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/NothingYouCouldDo-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/Outfit-Bold.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/Outfit-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/Outfit-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/PixelifySans-Medium.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/PixelifySans-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/PoiretOne-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/PoiretOne-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/RedHatMono-Bold.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/RedHatMono-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/RedHatMono-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/Silkscreen-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/Silkscreen-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/SmoochSans-Medium.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/SmoochSans-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/Tektur-Medium.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/Tektur-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/Tektur-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/WorkSans-Bold.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/WorkSans-BoldItalic.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/WorkSans-Italic.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/WorkSans-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/WorkSans-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/canvas-fonts/YoungSerif-OFL.txt +93 -0
- package/skills/uipm-ui-styling/canvas-fonts/YoungSerif-Regular.ttf +0 -0
- package/skills/uipm-ui-styling/references/canvas-design-system.md +320 -0
- package/skills/uipm-ui-styling/references/shadcn-accessibility.md +471 -0
- package/skills/uipm-ui-styling/references/shadcn-components.md +424 -0
- package/skills/uipm-ui-styling/references/shadcn-theming.md +373 -0
- package/skills/uipm-ui-styling/references/tailwind-customization.md +483 -0
- package/skills/uipm-ui-styling/references/tailwind-responsive.md +382 -0
- package/skills/uipm-ui-styling/references/tailwind-utilities.md +455 -0
- package/skills/uipm-ui-styling/scripts/.coverage +0 -0
- package/skills/uipm-ui-styling/scripts/requirements.txt +17 -0
- package/skills/uipm-ui-styling/scripts/shadcn_add.py +292 -0
- package/skills/uipm-ui-styling/scripts/tailwind_config_gen.py +456 -0
- package/skills/uipm-ui-styling/scripts/tests/coverage-ui.json +1 -0
- package/skills/uipm-ui-styling/scripts/tests/requirements.txt +3 -0
- package/skills/uipm-ui-styling/scripts/tests/test_shadcn_add.py +266 -0
- package/skills/uipm-ui-styling/scripts/tests/test_tailwind_config_gen.py +336 -0
- package/skills/video-frames/SKILL.md +50 -50
- package/skills/video-frames/scripts/frame.sh +81 -81
- package/skills/voice-call/SKILL.md +49 -49
- package/skills/wacli/SKILL.md +76 -76
- package/skills/weather/SKILL.md +91 -91
- package/skills/web-artifacts-builder/LICENSE +21 -21
- package/skills/web-artifacts-builder/SKILL.md +82 -82
- package/skills/web-artifacts-builder/scripts/bundle-artifact.sh +53 -53
- package/skills/web-artifacts-builder/scripts/init-artifact.sh +322 -322
- package/skills/xurl/SKILL.md +124 -124
|
@@ -0,0 +1,2326 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Live variant mode server (self-contained, zero dependencies).
|
|
4
|
+
*
|
|
5
|
+
* Serves the browser script (/live.js), the detection overlay (/detect.js),
|
|
6
|
+
* uses Server-Sent Events (SSE) for server→browser push, and HTTP POST for
|
|
7
|
+
* browser→server events. Agent communicates via HTTP long-poll (/poll).
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* node <scripts_path>/live-server.mjs # start
|
|
11
|
+
* node <scripts_path>/live-server.mjs stop # stop + remove injected live.js tag
|
|
12
|
+
* node <scripts_path>/live-server.mjs stop --keep-inject # stop only
|
|
13
|
+
* node <scripts_path>/live-server.mjs --help
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import http from 'node:http';
|
|
17
|
+
import { randomUUID } from 'node:crypto';
|
|
18
|
+
import { spawn, execFileSync } from 'node:child_process';
|
|
19
|
+
import fs from 'node:fs';
|
|
20
|
+
import path from 'node:path';
|
|
21
|
+
import net from 'node:net';
|
|
22
|
+
import { fileURLToPath } from 'node:url';
|
|
23
|
+
import { parseDesignMd } from './design-parser.mjs';
|
|
24
|
+
import { resolveContextDir } from './context.mjs';
|
|
25
|
+
import { createLiveSessionStore } from './live-session-store.mjs';
|
|
26
|
+
import { validateEvent } from './live-event-validation.mjs';
|
|
27
|
+
import { LIVE_COMMANDS } from './live-vocabulary.mjs';
|
|
28
|
+
import {
|
|
29
|
+
getDesignSidecarPath,
|
|
30
|
+
getLiveDir,
|
|
31
|
+
getLiveAnnotationsDir,
|
|
32
|
+
readLiveServerInfo,
|
|
33
|
+
removeLiveServerInfo,
|
|
34
|
+
resolveDesignSidecarPath,
|
|
35
|
+
writeLiveServerInfo,
|
|
36
|
+
} from './impeccable-paths.mjs';
|
|
37
|
+
import {
|
|
38
|
+
countByPage as countPendingByPage,
|
|
39
|
+
readBuffer as readManualEditsBuffer,
|
|
40
|
+
removeEntries as removeManualEditEntries,
|
|
41
|
+
stageEntry as stageManualEditEntry,
|
|
42
|
+
truncateBuffer as truncateManualEditsBuffer,
|
|
43
|
+
} from './live-manual-edits-buffer.mjs';
|
|
44
|
+
import { buildManualEditEvidence } from './live-manual-edit-evidence.mjs';
|
|
45
|
+
import { commitManualEdits } from './live-commit-manual-edits.mjs';
|
|
46
|
+
import {
|
|
47
|
+
applyDeferredSvelteComponentAccepts,
|
|
48
|
+
removeAllSvelteComponentSessions,
|
|
49
|
+
} from './live-svelte-component.mjs';
|
|
50
|
+
|
|
51
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
52
|
+
// PRODUCT.md / DESIGN.md live wherever context.mjs resolves. The generated
|
|
53
|
+
// DESIGN sidecar is project-local at .impeccable/design.json, with legacy
|
|
54
|
+
// DESIGN.json fallback for existing projects.
|
|
55
|
+
const CONTEXT_DIR = resolveContextDir(process.cwd());
|
|
56
|
+
const DEFAULT_POLL_TIMEOUT = 600_000; // 10 min — agent re-polls on timeout anyway
|
|
57
|
+
const SSE_HEARTBEAT_INTERVAL = 30_000; // keepalive ping every 30s
|
|
58
|
+
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// Port detection
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
async function findOpenPort(start = 8400) {
|
|
64
|
+
return new Promise((resolve) => {
|
|
65
|
+
const srv = net.createServer();
|
|
66
|
+
srv.listen(start, '127.0.0.1', () => {
|
|
67
|
+
const port = srv.address().port;
|
|
68
|
+
srv.close(() => resolve(port));
|
|
69
|
+
});
|
|
70
|
+
srv.on('error', () => resolve(findOpenPort(start + 1)));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
// Session state
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
|
|
78
|
+
const state = {
|
|
79
|
+
token: null,
|
|
80
|
+
port: null,
|
|
81
|
+
sseClients: new Set(), // SSE response objects (server→browser push)
|
|
82
|
+
pendingEvents: [], // browser events waiting for agent ack ({ event, leaseUntil })
|
|
83
|
+
pendingPolls: [], // agent poll callbacks waiting for browser events
|
|
84
|
+
nextEventSeq: 1,
|
|
85
|
+
lastAgentPollingBroadcast: null,
|
|
86
|
+
exitTimer: null,
|
|
87
|
+
sessionDir: null, // per-session tmp dir for annotation screenshots
|
|
88
|
+
sessionStore: null,
|
|
89
|
+
leaseTimer: null,
|
|
90
|
+
manualEditActivity: null,
|
|
91
|
+
nextManualEditSeq: 1,
|
|
92
|
+
// Deferreds for in-flight chat-routed Apply events. Keyed by event id; each
|
|
93
|
+
// entry is resolved when the chat agent POSTs an ack carrying the batch
|
|
94
|
+
// result, or rejected when the hard timeout fires.
|
|
95
|
+
pendingApplyDeferreds: new Map(),
|
|
96
|
+
// Updated whenever a /poll long-poll request arrives or is resolved with an
|
|
97
|
+
// event. Used to detect "a chat agent is likely attached" without requiring
|
|
98
|
+
// a poll to be parked at the exact moment we dispatch.
|
|
99
|
+
lastPollAt: 0,
|
|
100
|
+
timedOutApplyIds: new Map(),
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const CHAT_POLL_FRESHNESS_MS = 60_000;
|
|
104
|
+
const APPLY_EVENT_HARD_TIMEOUT_MS = Number(process.env.IMPECCABLE_LIVE_APPLY_EVENT_HARD_TIMEOUT_MS || 150_000);
|
|
105
|
+
const APPLY_EVENT_SOFT_DEADLINE_MS = Number(process.env.IMPECCABLE_LIVE_APPLY_EVENT_SOFT_DEADLINE_MS || 120_000);
|
|
106
|
+
const DEFAULT_MANUAL_EDIT_APPLY_CHUNK_SIZE = 3;
|
|
107
|
+
const MIN_MANUAL_EDIT_APPLY_CHUNK_SIZE = 1;
|
|
108
|
+
const MAX_MANUAL_EDIT_APPLY_CHUNK_SIZE = 20;
|
|
109
|
+
const MANUAL_APPLY_COMPACT_TEXT_LIMIT = 240;
|
|
110
|
+
const MANUAL_APPLY_COMPACT_NEARBY_LIMIT = 4;
|
|
111
|
+
const POLL_LEASE_EXPIRY_TIMER_GRACE_MS = 2;
|
|
112
|
+
const DEBUG_MANUAL_EDIT_EVENTS = /^(1|true|yes)$/i.test(process.env.IMPECCABLE_LIVE_DEBUG_EVENTS || '');
|
|
113
|
+
|
|
114
|
+
function tombstoneTimedOutApplyId(eventId, details = {}) {
|
|
115
|
+
if (!eventId) return;
|
|
116
|
+
state.timedOutApplyIds.set(eventId, details);
|
|
117
|
+
if (state.timedOutApplyIds.size <= 200) return;
|
|
118
|
+
const oldest = state.timedOutApplyIds.keys().next().value;
|
|
119
|
+
state.timedOutApplyIds.delete(oldest);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function chatAgentLikelyActive() {
|
|
123
|
+
if (state.pendingPolls.length > 0) return true;
|
|
124
|
+
if (!state.lastPollAt) return false;
|
|
125
|
+
return Date.now() - state.lastPollAt < CHAT_POLL_FRESHNESS_MS;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function manualEditApplyChunkSize(env = process.env) {
|
|
129
|
+
const raw = Number(env.IMPECCABLE_LIVE_MANUAL_EDIT_CHUNK_SIZE);
|
|
130
|
+
if (!Number.isFinite(raw)) return DEFAULT_MANUAL_EDIT_APPLY_CHUNK_SIZE;
|
|
131
|
+
const size = Math.trunc(raw);
|
|
132
|
+
return Math.max(MIN_MANUAL_EDIT_APPLY_CHUNK_SIZE, Math.min(MAX_MANUAL_EDIT_APPLY_CHUNK_SIZE, size));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function countManualApplyOps(entriesOrBatch) {
|
|
136
|
+
const entries = Array.isArray(entriesOrBatch)
|
|
137
|
+
? entriesOrBatch
|
|
138
|
+
: Array.isArray(entriesOrBatch?.entries) ? entriesOrBatch.entries : [];
|
|
139
|
+
let count = 0;
|
|
140
|
+
for (const entry of entries) count += Array.isArray(entry.ops) ? entry.ops.length : 0;
|
|
141
|
+
return count;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function pushApplyEventAndWait(batch, pageUrl, chunk = null, repair = null) {
|
|
145
|
+
const eventId = randomUUID().replace(/-/g, '').slice(0, 8);
|
|
146
|
+
const evidencePath = writeManualApplyEvidence(eventId, batch);
|
|
147
|
+
const event = {
|
|
148
|
+
type: 'manual_edit_apply',
|
|
149
|
+
id: eventId,
|
|
150
|
+
pageUrl,
|
|
151
|
+
batch: compactManualApplyBatch(batch),
|
|
152
|
+
evidencePath,
|
|
153
|
+
agentAction: buildManualApplyAgentAction(eventId),
|
|
154
|
+
schemaVersion: 1,
|
|
155
|
+
deadlineMs: APPLY_EVENT_SOFT_DEADLINE_MS,
|
|
156
|
+
};
|
|
157
|
+
if (chunk) event.chunk = chunk;
|
|
158
|
+
if (repair) event.repair = repair;
|
|
159
|
+
const rollbackSnapshot = snapshotApplyEventFiles(batch);
|
|
160
|
+
recordManualEditActivity('manual_edit_apply_dispatched', {
|
|
161
|
+
id: eventId,
|
|
162
|
+
pageUrl,
|
|
163
|
+
chunk,
|
|
164
|
+
repair,
|
|
165
|
+
entryCount: Array.isArray(batch.entries) ? batch.entries.length : 0,
|
|
166
|
+
opCount: countManualApplyOps(batch),
|
|
167
|
+
fileCount: collectManualApplyFiles(batch).length,
|
|
168
|
+
});
|
|
169
|
+
return new Promise((resolve, reject) => {
|
|
170
|
+
const timer = setTimeout(() => {
|
|
171
|
+
state.pendingApplyDeferreds.delete(eventId);
|
|
172
|
+
tombstoneTimedOutApplyId(eventId, { batch, rollbackSnapshot });
|
|
173
|
+
acknowledgePendingEvent(eventId);
|
|
174
|
+
removeManualApplyEvidence(evidencePath);
|
|
175
|
+
recordManualEditActivity('manual_edit_apply_timeout', {
|
|
176
|
+
id: eventId,
|
|
177
|
+
pageUrl,
|
|
178
|
+
chunk,
|
|
179
|
+
entryCount: Array.isArray(batch.entries) ? batch.entries.length : 0,
|
|
180
|
+
opCount: countManualApplyOps(batch),
|
|
181
|
+
});
|
|
182
|
+
reject(new Error('chat_agent_timeout'));
|
|
183
|
+
}, APPLY_EVENT_HARD_TIMEOUT_MS);
|
|
184
|
+
state.pendingApplyDeferreds.set(eventId, { resolve, reject, timer, event, batch, pageUrl, rollbackSnapshot });
|
|
185
|
+
enqueueEvent(event);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function writeManualApplyEvidence(eventId, batch) {
|
|
190
|
+
const dir = manualApplyEvidenceDir(process.cwd());
|
|
191
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
192
|
+
const evidencePath = path.join(dir, `${eventId}.json`);
|
|
193
|
+
fs.writeFileSync(evidencePath, JSON.stringify(batch, null, 2) + '\n', 'utf-8');
|
|
194
|
+
return evidencePath;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function manualApplyEvidenceDir(cwd = process.cwd()) {
|
|
198
|
+
return path.join(getLiveDir(cwd), 'manual-edit-evidence');
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function normalizeManualApplyEvidencePath(evidencePath, cwd = process.cwd()) {
|
|
202
|
+
if (!evidencePath || typeof evidencePath !== 'string') return null;
|
|
203
|
+
const fullPath = path.isAbsolute(evidencePath) ? evidencePath : path.resolve(cwd, evidencePath);
|
|
204
|
+
const evidenceDir = manualApplyEvidenceDir(cwd);
|
|
205
|
+
const relative = path.relative(evidenceDir, fullPath);
|
|
206
|
+
if (!relative || relative.startsWith('..') || path.isAbsolute(relative)) return null;
|
|
207
|
+
if (path.extname(relative) !== '.json') return null;
|
|
208
|
+
return fullPath;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function removeManualApplyEvidence(evidencePath, cwd = process.cwd()) {
|
|
212
|
+
const fullPath = normalizeManualApplyEvidencePath(evidencePath, cwd);
|
|
213
|
+
if (!fullPath) return false;
|
|
214
|
+
try {
|
|
215
|
+
fs.unlinkSync(fullPath);
|
|
216
|
+
return true;
|
|
217
|
+
} catch {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function referencedManualApplyEvidencePaths(cwd = process.cwd()) {
|
|
223
|
+
const referenced = new Set();
|
|
224
|
+
const add = (event) => {
|
|
225
|
+
const fullPath = normalizeManualApplyEvidencePath(event?.evidencePath, cwd);
|
|
226
|
+
if (fullPath) referenced.add(fullPath);
|
|
227
|
+
};
|
|
228
|
+
for (const entry of state.pendingEvents) add(entry.event);
|
|
229
|
+
for (const deferred of state.pendingApplyDeferreds.values()) add(deferred.event);
|
|
230
|
+
return referenced;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function pruneStaleManualApplyEvidence(cwd = process.cwd()) {
|
|
234
|
+
const dir = manualApplyEvidenceDir(cwd);
|
|
235
|
+
if (!fs.existsSync(dir)) return [];
|
|
236
|
+
const referenced = referencedManualApplyEvidencePaths(cwd);
|
|
237
|
+
const removed = [];
|
|
238
|
+
for (const name of fs.readdirSync(dir)) {
|
|
239
|
+
if (!name.endsWith('.json')) continue;
|
|
240
|
+
const fullPath = path.join(dir, name);
|
|
241
|
+
if (referenced.has(fullPath)) continue;
|
|
242
|
+
try {
|
|
243
|
+
fs.unlinkSync(fullPath);
|
|
244
|
+
removed.push(fullPath);
|
|
245
|
+
} catch {
|
|
246
|
+
// Stale evidence cleanup is best-effort; Apply verification never relies
|
|
247
|
+
// on deleting these files.
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return removed;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function compactManualApplyBatch(batch = {}) {
|
|
254
|
+
const entries = (batch.entries || []).map(compactManualApplyEntry);
|
|
255
|
+
const candidates = compactManualApplyCandidates(batch.candidates || []);
|
|
256
|
+
return {
|
|
257
|
+
version: batch.version,
|
|
258
|
+
pageUrl: batch.pageUrl || null,
|
|
259
|
+
count: batch.count,
|
|
260
|
+
entries,
|
|
261
|
+
ops: entries.flatMap((entry) => entry.ops.map((op) => ({ ...op, entryId: entry.id }))),
|
|
262
|
+
candidates: candidates.length > 0 ? candidates : undefined,
|
|
263
|
+
context: batch.context ? {
|
|
264
|
+
bufferPath: batch.context.bufferPath,
|
|
265
|
+
totalEntries: batch.context.totalEntries,
|
|
266
|
+
totalOps: batch.context.totalOps,
|
|
267
|
+
chunkIndex: batch.context.chunkIndex,
|
|
268
|
+
chunkTotal: batch.context.chunkTotal,
|
|
269
|
+
totalApplyOps: batch.context.totalApplyOps,
|
|
270
|
+
} : undefined,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function compactManualApplyCandidates(candidates) {
|
|
275
|
+
return (Array.isArray(candidates) ? candidates : [])
|
|
276
|
+
.slice(0, 24)
|
|
277
|
+
.map((candidate) => ({
|
|
278
|
+
entryId: candidate.entryId,
|
|
279
|
+
ref: candidate.ref,
|
|
280
|
+
sourceHint: compactManualApplySourceMatch(candidate.sourceHint),
|
|
281
|
+
textMatches: compactManualApplySourceMatches(candidate.textMatches, 8),
|
|
282
|
+
objectKeyMatches: compactManualApplySourceMatches(candidate.objectKeyMatches, 8),
|
|
283
|
+
contextTextMatches: compactManualApplySourceMatches(candidate.contextTextMatches, 8),
|
|
284
|
+
locatorMatches: compactManualApplySourceMatches(candidate.locatorMatches, 6),
|
|
285
|
+
}));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function compactManualApplySourceMatches(matches, limit) {
|
|
289
|
+
return (Array.isArray(matches) ? matches : [])
|
|
290
|
+
.slice(0, limit)
|
|
291
|
+
.map(compactManualApplySourceMatch)
|
|
292
|
+
.filter(Boolean);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function compactManualApplySourceMatch(match) {
|
|
296
|
+
if (!match || typeof match !== 'object') return null;
|
|
297
|
+
const file = match.relativeFile || match.file;
|
|
298
|
+
if (!file && !match.line) return null;
|
|
299
|
+
return {
|
|
300
|
+
file: summarizeManualLogFile(file),
|
|
301
|
+
line: match.line || null,
|
|
302
|
+
column: match.column || null,
|
|
303
|
+
reason: match.reason || match.kind || undefined,
|
|
304
|
+
status: match.status || undefined,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function compactManualApplyEntry(entry = {}) {
|
|
309
|
+
return {
|
|
310
|
+
id: entry.id,
|
|
311
|
+
pageUrl: entry.pageUrl,
|
|
312
|
+
stagedAt: entry.stagedAt || null,
|
|
313
|
+
element: compactManualApplyContext(entry.element),
|
|
314
|
+
ops: (entry.ops || []).map(compactManualApplyOp),
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function compactManualApplyOp(op = {}) {
|
|
319
|
+
return {
|
|
320
|
+
entryId: op.entryId,
|
|
321
|
+
ref: op.ref,
|
|
322
|
+
contextRef: op.contextRef,
|
|
323
|
+
tag: op.tag,
|
|
324
|
+
elementId: op.elementId,
|
|
325
|
+
classes: Array.isArray(op.classes) ? op.classes : [],
|
|
326
|
+
originalText: op.originalText,
|
|
327
|
+
newText: op.newText,
|
|
328
|
+
deleted: op.deleted === true || undefined,
|
|
329
|
+
sourceHint: op.sourceHint || null,
|
|
330
|
+
leaf: compactManualApplyContext(op.leaf),
|
|
331
|
+
nearbyEditableTexts: compactNearbyManualEditTexts(op.nearbyEditableTexts),
|
|
332
|
+
container: compactManualApplyContext(op.container),
|
|
333
|
+
contextHints: Array.isArray(op.contextHints) ? op.contextHints.slice(0, 8) : undefined,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function compactManualApplyContext(value) {
|
|
338
|
+
if (!value || typeof value !== 'object') return null;
|
|
339
|
+
return {
|
|
340
|
+
ref: value.ref,
|
|
341
|
+
tagName: value.tagName || value.tag || null,
|
|
342
|
+
id: value.id || null,
|
|
343
|
+
classes: Array.isArray(value.classes) ? value.classes : [],
|
|
344
|
+
textContent: truncateManualApplyText(value.textContent, MANUAL_APPLY_COMPACT_TEXT_LIMIT),
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function compactNearbyManualEditTexts(items) {
|
|
349
|
+
return (Array.isArray(items) ? items : [])
|
|
350
|
+
.slice(0, MANUAL_APPLY_COMPACT_NEARBY_LIMIT)
|
|
351
|
+
.map((item) => typeof item === 'string' ? { text: truncateManualApplyText(item, MANUAL_APPLY_COMPACT_TEXT_LIMIT) } : {
|
|
352
|
+
ref: item?.ref,
|
|
353
|
+
tag: item?.tag,
|
|
354
|
+
classes: Array.isArray(item?.classes) ? item.classes : [],
|
|
355
|
+
text: truncateManualApplyText(item?.text, MANUAL_APPLY_COMPACT_TEXT_LIMIT),
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function truncateManualApplyText(value, max) {
|
|
360
|
+
if (typeof value !== 'string') return value || null;
|
|
361
|
+
return value.length > max ? value.slice(0, max) : value;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
async function pushApplyBatchInChunksAndWait(batch, pageUrl, context = {}) {
|
|
365
|
+
const repair = context?.repair || batch?.repair || null;
|
|
366
|
+
if (repair) return pushApplyEventAndWait(batch, pageUrl, null, repair);
|
|
367
|
+
const chunks = splitManualApplyBatch(batch, manualEditApplyChunkSize());
|
|
368
|
+
if (chunks.length <= 1) return pushApplyEventAndWait(batch, pageUrl);
|
|
369
|
+
|
|
370
|
+
const expectedOpsByEntry = new Map();
|
|
371
|
+
for (const entry of batch?.entries || []) {
|
|
372
|
+
expectedOpsByEntry.set(entry.id, Array.isArray(entry.ops) ? entry.ops.length : 0);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const appliedOpsByEntry = new Map();
|
|
376
|
+
const failedByEntry = new Map();
|
|
377
|
+
const files = new Set();
|
|
378
|
+
const notes = [];
|
|
379
|
+
let aborted = false;
|
|
380
|
+
|
|
381
|
+
for (const chunk of chunks) {
|
|
382
|
+
if (aborted) {
|
|
383
|
+
markChunkEntriesFailed(failedByEntry, chunk, 'manual_edit_chunk_aborted');
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
let result;
|
|
388
|
+
try {
|
|
389
|
+
result = normalizeApplyChunkResult(await pushApplyEventAndWait(chunk.batch, pageUrl, chunk.meta));
|
|
390
|
+
} catch (err) {
|
|
391
|
+
markChunkEntriesFailed(failedByEntry, chunk, err.message || 'chat_agent_error');
|
|
392
|
+
aborted = true;
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
for (const file of result.files) files.add(file);
|
|
397
|
+
notes.push(...result.notes);
|
|
398
|
+
|
|
399
|
+
const chunkFailedIds = new Set();
|
|
400
|
+
for (const item of result.failed) {
|
|
401
|
+
const entryId = item.entryId || item.id;
|
|
402
|
+
if (!entryId) continue;
|
|
403
|
+
chunkFailedIds.add(entryId);
|
|
404
|
+
if (!failedByEntry.has(entryId)) {
|
|
405
|
+
failedByEntry.set(entryId, {
|
|
406
|
+
entryId,
|
|
407
|
+
reason: item.reason || item.message || 'failed',
|
|
408
|
+
candidates: Array.isArray(item.candidates) ? item.candidates : [],
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (result.status === 'error') {
|
|
414
|
+
markChunkEntriesFailed(failedByEntry, chunk, result.message || firstFailureReason(result) || 'chat_agent_error');
|
|
415
|
+
aborted = true;
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
const reportedAppliedIds = new Set(result.appliedEntryIds);
|
|
420
|
+
for (const entryId of reportedAppliedIds) {
|
|
421
|
+
if (!chunk.entryIds.has(entryId) || chunkFailedIds.has(entryId)) continue;
|
|
422
|
+
appliedOpsByEntry.set(entryId, (appliedOpsByEntry.get(entryId) || 0) + (chunk.opCountsByEntry.get(entryId) || 0));
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
for (const entryId of chunk.entryIds) {
|
|
426
|
+
if (reportedAppliedIds.has(entryId) || chunkFailedIds.has(entryId)) continue;
|
|
427
|
+
if (!failedByEntry.has(entryId)) {
|
|
428
|
+
failedByEntry.set(entryId, { entryId, reason: 'not_reported_applied', candidates: [] });
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const appliedEntryIds = [];
|
|
434
|
+
for (const [entryId, expectedOps] of expectedOpsByEntry.entries()) {
|
|
435
|
+
if (failedByEntry.has(entryId)) continue;
|
|
436
|
+
if ((appliedOpsByEntry.get(entryId) || 0) === expectedOps && expectedOps > 0) {
|
|
437
|
+
appliedEntryIds.push(entryId);
|
|
438
|
+
} else if (!failedByEntry.has(entryId)) {
|
|
439
|
+
failedByEntry.set(entryId, { entryId, reason: 'not_reported_applied', candidates: [] });
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const failed = [...failedByEntry.values()];
|
|
444
|
+
return {
|
|
445
|
+
status: failed.length === 0 ? 'done' : appliedEntryIds.length > 0 ? 'partial' : 'error',
|
|
446
|
+
appliedEntryIds,
|
|
447
|
+
failed,
|
|
448
|
+
files: [...files],
|
|
449
|
+
notes,
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function normalizeApplyChunkResult(result) {
|
|
454
|
+
const status = result?.status === 'partial' ? 'partial' : result?.status === 'error' ? 'error' : 'done';
|
|
455
|
+
return {
|
|
456
|
+
status,
|
|
457
|
+
message: typeof result?.message === 'string' ? result.message : null,
|
|
458
|
+
appliedEntryIds: Array.isArray(result?.appliedEntryIds) ? result.appliedEntryIds.filter((id) => typeof id === 'string') : [],
|
|
459
|
+
failed: Array.isArray(result?.failed) ? result.failed.filter(Boolean) : [],
|
|
460
|
+
files: Array.isArray(result?.files) ? result.files.filter((file) => typeof file === 'string') : [],
|
|
461
|
+
notes: Array.isArray(result?.notes) ? result.notes.filter((note) => typeof note === 'string') : [],
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function manualApplyResultShapeHint(eventId = 'EVENT_ID') {
|
|
466
|
+
return `Use live-poll.mjs --reply ${eventId} done --data '{"status":"done","appliedEntryIds":["ENTRY_ID"],"failed":[],"files":["src/page.html"],"notes":[]}'`;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
function invalidManualApplyResult(reason, eventId, extra = {}) {
|
|
470
|
+
return {
|
|
471
|
+
ok: false,
|
|
472
|
+
body: {
|
|
473
|
+
error: 'invalid_manual_apply_result',
|
|
474
|
+
reason,
|
|
475
|
+
hint: manualApplyResultShapeHint(eventId),
|
|
476
|
+
...extra,
|
|
477
|
+
},
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function validateManualApplyResultMessage(msg, deferred) {
|
|
482
|
+
let data = msg?.data;
|
|
483
|
+
const eventId = msg?.id || deferred?.event?.id || 'EVENT_ID';
|
|
484
|
+
if (!data || typeof data !== 'object' || Array.isArray(data)) {
|
|
485
|
+
return invalidManualApplyResult('missing_result_data', eventId);
|
|
486
|
+
}
|
|
487
|
+
if ('entries' in data || 'ops' in data) {
|
|
488
|
+
return invalidManualApplyResult('summary_result_not_allowed', eventId);
|
|
489
|
+
}
|
|
490
|
+
if (!['done', 'partial', 'error'].includes(data.status)) {
|
|
491
|
+
return invalidManualApplyResult('invalid_status', eventId, { status: data.status ?? null });
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
for (const key of ['appliedEntryIds', 'failed', 'files', 'notes']) {
|
|
495
|
+
if (!Array.isArray(data[key])) {
|
|
496
|
+
return invalidManualApplyResult(`${key}_must_be_array`, eventId);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
for (const [index, value] of data.appliedEntryIds.entries()) {
|
|
501
|
+
if (typeof value !== 'string' || !value) {
|
|
502
|
+
return invalidManualApplyResult('appliedEntryIds_must_contain_strings', eventId, { index });
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
for (const [index, value] of data.files.entries()) {
|
|
506
|
+
if (typeof value !== 'string' || !value) {
|
|
507
|
+
return invalidManualApplyResult('files_must_contain_strings', eventId, { index });
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
for (const [index, value] of data.notes.entries()) {
|
|
511
|
+
if (typeof value !== 'string') {
|
|
512
|
+
return invalidManualApplyResult('notes_must_contain_strings', eventId, { index });
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
for (const [index, item] of data.failed.entries()) {
|
|
516
|
+
if (!item || typeof item !== 'object' || Array.isArray(item)) {
|
|
517
|
+
return invalidManualApplyResult('failed_must_contain_objects', eventId, { index });
|
|
518
|
+
}
|
|
519
|
+
if (typeof item.entryId !== 'string' || !item.entryId) {
|
|
520
|
+
return invalidManualApplyResult('failed_entryId_required', eventId, { index });
|
|
521
|
+
}
|
|
522
|
+
if (typeof item.reason !== 'string' || !item.reason) {
|
|
523
|
+
return invalidManualApplyResult('failed_reason_required', eventId, { index });
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
const eventEntryIds = new Set((deferred?.batch?.entries || []).map((entry) => entry.id).filter(Boolean));
|
|
528
|
+
for (const entryId of data.appliedEntryIds) {
|
|
529
|
+
if (eventEntryIds.size > 0 && !eventEntryIds.has(entryId)) {
|
|
530
|
+
return invalidManualApplyResult('applied_entry_id_not_in_event', eventId, { entryId });
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
for (const item of data.failed) {
|
|
534
|
+
if (eventEntryIds.size > 0 && !eventEntryIds.has(item.entryId)) {
|
|
535
|
+
return invalidManualApplyResult('failed_entry_id_not_in_event', eventId, { entryId: item.entryId });
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
if (data.status === 'done') {
|
|
540
|
+
if (data.failed.length > 0) {
|
|
541
|
+
return invalidManualApplyResult('done_result_has_failed_entries', eventId);
|
|
542
|
+
}
|
|
543
|
+
if (countManualApplyOps(deferred?.batch) > 0 && data.appliedEntryIds.length === 0) {
|
|
544
|
+
return invalidManualApplyResult('done_result_missing_applied_entry_ids', eventId);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if (data.status === 'partial' && data.appliedEntryIds.length === 0 && data.failed.length === 0) {
|
|
548
|
+
return invalidManualApplyResult('partial_result_has_no_entries', eventId);
|
|
549
|
+
}
|
|
550
|
+
if (data.status === 'error' && data.appliedEntryIds.length > 0) {
|
|
551
|
+
return invalidManualApplyResult('error_result_has_applied_entries', eventId);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
return {
|
|
555
|
+
ok: true,
|
|
556
|
+
result: {
|
|
557
|
+
status: data.status,
|
|
558
|
+
message: typeof data.message === 'string' ? data.message : undefined,
|
|
559
|
+
appliedEntryIds: data.appliedEntryIds,
|
|
560
|
+
failed: data.failed,
|
|
561
|
+
files: data.files,
|
|
562
|
+
notes: data.notes,
|
|
563
|
+
},
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function firstFailureReason(result) {
|
|
568
|
+
const first = Array.isArray(result?.failed) ? result.failed.find(Boolean) : null;
|
|
569
|
+
return first?.reason || first?.message || null;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
function markChunkEntriesFailed(failedByEntry, chunk, reason) {
|
|
573
|
+
for (const entryId of chunk.entryIds) {
|
|
574
|
+
if (failedByEntry.has(entryId)) continue;
|
|
575
|
+
failedByEntry.set(entryId, { entryId, reason, candidates: [] });
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
function splitManualApplyBatch(batch, maxOps) {
|
|
580
|
+
const totalOpCount = countManualApplyOps(batch);
|
|
581
|
+
if (totalOpCount <= maxOps) {
|
|
582
|
+
return [{
|
|
583
|
+
batch,
|
|
584
|
+
meta: null,
|
|
585
|
+
entryIds: new Set((batch?.entries || []).map((entry) => entry.id).filter(Boolean)),
|
|
586
|
+
opCountsByEntry: new Map((batch?.entries || []).map((entry) => [entry.id, Array.isArray(entry.ops) ? entry.ops.length : 0])),
|
|
587
|
+
}];
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
const rawChunks = [];
|
|
591
|
+
let current = createManualApplyChunkBuilder();
|
|
592
|
+
for (const entry of batch?.entries || []) {
|
|
593
|
+
const ops = entry.ops || [];
|
|
594
|
+
if (ops.length <= maxOps) {
|
|
595
|
+
if (current.opCount > 0 && current.opCount + ops.length > maxOps) {
|
|
596
|
+
rawChunks.push(current);
|
|
597
|
+
current = createManualApplyChunkBuilder();
|
|
598
|
+
}
|
|
599
|
+
for (const op of ops) addOpToManualApplyChunk(current, entry, op);
|
|
600
|
+
continue;
|
|
601
|
+
}
|
|
602
|
+
if (current.opCount > 0) {
|
|
603
|
+
rawChunks.push(current);
|
|
604
|
+
current = createManualApplyChunkBuilder();
|
|
605
|
+
}
|
|
606
|
+
for (const op of ops) {
|
|
607
|
+
if (current.opCount >= maxOps) {
|
|
608
|
+
rawChunks.push(current);
|
|
609
|
+
current = createManualApplyChunkBuilder();
|
|
610
|
+
}
|
|
611
|
+
addOpToManualApplyChunk(current, entry, op);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
if (current.opCount > 0) rawChunks.push(current);
|
|
615
|
+
|
|
616
|
+
return rawChunks.map((chunk, index) => ({
|
|
617
|
+
batch: {
|
|
618
|
+
...batch,
|
|
619
|
+
count: chunk.opCount,
|
|
620
|
+
entries: chunk.entries,
|
|
621
|
+
ops: chunk.ops,
|
|
622
|
+
candidates: filterManualApplyChunkCandidates(batch, chunk.refsByEntry),
|
|
623
|
+
context: {
|
|
624
|
+
...(batch?.context || {}),
|
|
625
|
+
totalEntries: chunk.entries.length,
|
|
626
|
+
totalOps: chunk.opCount,
|
|
627
|
+
chunkIndex: index + 1,
|
|
628
|
+
chunkTotal: rawChunks.length,
|
|
629
|
+
totalApplyOps: totalOpCount,
|
|
630
|
+
},
|
|
631
|
+
},
|
|
632
|
+
meta: {
|
|
633
|
+
index: index + 1,
|
|
634
|
+
total: rawChunks.length,
|
|
635
|
+
opCount: chunk.opCount,
|
|
636
|
+
totalOpCount,
|
|
637
|
+
},
|
|
638
|
+
entryIds: new Set(chunk.entries.map((entry) => entry.id).filter(Boolean)),
|
|
639
|
+
opCountsByEntry: chunk.opCountsByEntry,
|
|
640
|
+
}));
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
function createManualApplyChunkBuilder() {
|
|
644
|
+
return {
|
|
645
|
+
entries: [],
|
|
646
|
+
entryById: new Map(),
|
|
647
|
+
entryIds: new Set(),
|
|
648
|
+
ops: [],
|
|
649
|
+
refsByEntry: new Map(),
|
|
650
|
+
opCountsByEntry: new Map(),
|
|
651
|
+
opCount: 0,
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
function addOpToManualApplyChunk(chunk, entry, op) {
|
|
656
|
+
let chunkEntry = chunk.entryById.get(entry.id);
|
|
657
|
+
if (!chunkEntry) {
|
|
658
|
+
chunkEntry = { ...entry, ops: [] };
|
|
659
|
+
chunk.entryById.set(entry.id, chunkEntry);
|
|
660
|
+
chunk.entryIds.add(entry.id);
|
|
661
|
+
chunk.entries.push(chunkEntry);
|
|
662
|
+
}
|
|
663
|
+
chunkEntry.ops.push(op);
|
|
664
|
+
chunk.ops.push({ ...op, entryId: op.entryId || entry.id });
|
|
665
|
+
if (!chunk.refsByEntry.has(entry.id)) chunk.refsByEntry.set(entry.id, new Set());
|
|
666
|
+
if (op.ref) chunk.refsByEntry.get(entry.id).add(op.ref);
|
|
667
|
+
chunk.opCountsByEntry.set(entry.id, (chunk.opCountsByEntry.get(entry.id) || 0) + 1);
|
|
668
|
+
chunk.opCount += 1;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
function filterManualApplyChunkCandidates(batch, refsByEntry) {
|
|
672
|
+
return (batch?.candidates || []).filter((candidate) => {
|
|
673
|
+
const refs = refsByEntry.get(candidate.entryId);
|
|
674
|
+
if (!refs) return false;
|
|
675
|
+
if (!candidate.ref) return true;
|
|
676
|
+
return refs.has(candidate.ref);
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
function resolveApplyDeferred(eventId, body) {
|
|
681
|
+
const deferred = state.pendingApplyDeferreds.get(eventId);
|
|
682
|
+
if (!deferred) return false;
|
|
683
|
+
state.pendingApplyDeferreds.delete(eventId);
|
|
684
|
+
clearTimeout(deferred.timer);
|
|
685
|
+
removeManualApplyEvidence(deferred.event?.evidencePath);
|
|
686
|
+
deferred.resolve(body);
|
|
687
|
+
return true;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
function rejectApplyDeferred(eventId, reason) {
|
|
691
|
+
const deferred = state.pendingApplyDeferreds.get(eventId);
|
|
692
|
+
if (!deferred) return false;
|
|
693
|
+
state.pendingApplyDeferreds.delete(eventId);
|
|
694
|
+
clearTimeout(deferred.timer);
|
|
695
|
+
removeManualApplyEvidence(deferred.event?.evidencePath);
|
|
696
|
+
deferred.reject(new Error(reason || 'chat_agent_error'));
|
|
697
|
+
return true;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
function snapshotApplyEventFiles(batch) {
|
|
701
|
+
const snapshot = new Map();
|
|
702
|
+
for (const relativeFile of collectManualApplyFiles(batch)) {
|
|
703
|
+
const absolute = path.resolve(process.cwd(), relativeFile);
|
|
704
|
+
try {
|
|
705
|
+
snapshot.set(relativeFile, {
|
|
706
|
+
exists: fs.existsSync(absolute),
|
|
707
|
+
content: fs.existsSync(absolute) ? fs.readFileSync(absolute, 'utf-8') : '',
|
|
708
|
+
});
|
|
709
|
+
} catch {
|
|
710
|
+
// If a file cannot be read before dispatch, do not attempt late rollback.
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return snapshot;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
function manualApplyTransactionPath(cwd = process.cwd()) {
|
|
717
|
+
return path.join(getLiveDir(cwd), 'manual-edit-apply-transaction.json');
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
function readManualApplyTransaction(cwd = process.cwd()) {
|
|
721
|
+
const file = manualApplyTransactionPath(cwd);
|
|
722
|
+
if (!fs.existsSync(file)) return null;
|
|
723
|
+
try {
|
|
724
|
+
return JSON.parse(fs.readFileSync(file, 'utf-8'));
|
|
725
|
+
} catch {
|
|
726
|
+
return null;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
function writeManualApplyTransaction({ cwd = process.cwd(), pageUrl = null, batch }) {
|
|
731
|
+
const file = manualApplyTransactionPath(cwd);
|
|
732
|
+
const files = collectManualApplyFiles(batch);
|
|
733
|
+
const transaction = {
|
|
734
|
+
version: 1,
|
|
735
|
+
id: randomUUID().replace(/-/g, '').slice(0, 8),
|
|
736
|
+
createdAt: new Date().toISOString(),
|
|
737
|
+
pageUrl,
|
|
738
|
+
entryIds: (batch?.entries || []).map((entry) => entry.id).filter(Boolean),
|
|
739
|
+
files: files.map((relativeFile) => {
|
|
740
|
+
const absolute = path.resolve(cwd, relativeFile);
|
|
741
|
+
const exists = fs.existsSync(absolute);
|
|
742
|
+
return {
|
|
743
|
+
file: relativeFile,
|
|
744
|
+
exists,
|
|
745
|
+
content: exists ? fs.readFileSync(absolute, 'utf-8') : '',
|
|
746
|
+
};
|
|
747
|
+
}),
|
|
748
|
+
};
|
|
749
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
750
|
+
fs.writeFileSync(`${file}.tmp`, JSON.stringify(transaction, null, 2) + '\n', 'utf-8');
|
|
751
|
+
fs.renameSync(`${file}.tmp`, file);
|
|
752
|
+
return transaction;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
function clearManualApplyTransaction(cwd = process.cwd(), transactionId = null) {
|
|
756
|
+
const file = manualApplyTransactionPath(cwd);
|
|
757
|
+
if (!fs.existsSync(file)) return false;
|
|
758
|
+
if (transactionId) {
|
|
759
|
+
const existing = readManualApplyTransaction(cwd);
|
|
760
|
+
if (existing?.id && existing.id !== transactionId) return false;
|
|
761
|
+
}
|
|
762
|
+
try {
|
|
763
|
+
fs.unlinkSync(file);
|
|
764
|
+
return true;
|
|
765
|
+
} catch {
|
|
766
|
+
return false;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
function rollbackManualApplyTransaction({ cwd = process.cwd(), pageUrl = null, reason = 'manual_edit_transaction_rollback' } = {}) {
|
|
771
|
+
const transaction = readManualApplyTransaction(cwd);
|
|
772
|
+
if (!transaction) return null;
|
|
773
|
+
if (pageUrl && transaction.pageUrl && transaction.pageUrl !== pageUrl) return null;
|
|
774
|
+
|
|
775
|
+
let pendingIds = new Set();
|
|
776
|
+
try {
|
|
777
|
+
const buffer = readManualEditsBuffer(cwd);
|
|
778
|
+
pendingIds = new Set((buffer.entries || []).map((entry) => entry.id).filter(Boolean));
|
|
779
|
+
} catch {
|
|
780
|
+
pendingIds = new Set(transaction.entryIds || []);
|
|
781
|
+
}
|
|
782
|
+
const shouldRollback = (transaction.entryIds || []).some((id) => pendingIds.has(id));
|
|
783
|
+
if (!shouldRollback) {
|
|
784
|
+
clearManualApplyTransaction(cwd, transaction.id);
|
|
785
|
+
return { id: transaction.id, reason, rolledBackFiles: [], rollbackFailures: [], skipped: 'entries_not_pending' };
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
const rolledBackFiles = [];
|
|
789
|
+
const rollbackFailures = [];
|
|
790
|
+
for (const item of transaction.files || []) {
|
|
791
|
+
const relativeFile = normalizeProjectFile(item.file);
|
|
792
|
+
if (!relativeFile) continue;
|
|
793
|
+
const absolute = path.resolve(cwd, relativeFile);
|
|
794
|
+
try {
|
|
795
|
+
if (item.exists) {
|
|
796
|
+
fs.mkdirSync(path.dirname(absolute), { recursive: true });
|
|
797
|
+
fs.writeFileSync(absolute, item.content || '', 'utf-8');
|
|
798
|
+
} else if (fs.existsSync(absolute)) {
|
|
799
|
+
fs.rmSync(absolute);
|
|
800
|
+
}
|
|
801
|
+
rolledBackFiles.push(relativeFile);
|
|
802
|
+
} catch (err) {
|
|
803
|
+
rollbackFailures.push({ file: relativeFile, reason: 'restore_failed', message: err.message || String(err) });
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
clearManualApplyTransaction(cwd, transaction.id);
|
|
807
|
+
recordManualEditActivity('manual_edit_transaction_rolled_back', {
|
|
808
|
+
id: transaction.id,
|
|
809
|
+
pageUrl: transaction.pageUrl || null,
|
|
810
|
+
reason,
|
|
811
|
+
entryIds: transaction.entryIds || [],
|
|
812
|
+
rolledBackFiles: rolledBackFiles.map(summarizeManualLogFile).filter(Boolean),
|
|
813
|
+
rollbackFailures: summarizeManualDiagnostics(rollbackFailures),
|
|
814
|
+
});
|
|
815
|
+
return { id: transaction.id, reason, rolledBackFiles, rollbackFailures };
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
function collectManualApplyFiles(batch, extraFiles = []) {
|
|
819
|
+
const files = [];
|
|
820
|
+
for (const entry of batch?.entries || []) {
|
|
821
|
+
for (const op of entry.ops || []) files.push(op.sourceHint?.file);
|
|
822
|
+
}
|
|
823
|
+
for (const candidate of batch?.candidates || []) {
|
|
824
|
+
files.push(candidate.sourceHint?.relativeFile, candidate.sourceHint?.file);
|
|
825
|
+
for (const item of candidate.textMatches || []) files.push(item.file);
|
|
826
|
+
for (const item of candidate.objectKeyMatches || []) files.push(item.file);
|
|
827
|
+
for (const item of candidate.locatorMatches || []) files.push(item.file);
|
|
828
|
+
for (const item of candidate.contextTextMatches || []) files.push(item.file);
|
|
829
|
+
}
|
|
830
|
+
files.push(...(extraFiles || []));
|
|
831
|
+
return [...new Set(files)]
|
|
832
|
+
.map((file) => normalizeProjectFile(file))
|
|
833
|
+
.filter(Boolean);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
function normalizeProjectFile(file) {
|
|
837
|
+
if (!file || typeof file !== 'string') return null;
|
|
838
|
+
const absolute = path.isAbsolute(file) ? file : path.resolve(process.cwd(), file);
|
|
839
|
+
const relative = path.relative(process.cwd(), absolute);
|
|
840
|
+
if (!relative || relative.startsWith('..') || path.isAbsolute(relative)) return null;
|
|
841
|
+
return relative;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
function rollbackApplySnapshot(batch, rollbackSnapshot, extraFiles = [], reason = 'manual_edit_apply_snapshot_rollback') {
|
|
845
|
+
const scope = collectManualApplyFiles(batch, extraFiles);
|
|
846
|
+
const rolledBackFiles = [];
|
|
847
|
+
const rollbackFailures = [];
|
|
848
|
+
for (const relativeFile of scope) {
|
|
849
|
+
const before = rollbackSnapshot?.get(relativeFile);
|
|
850
|
+
if (!before) continue;
|
|
851
|
+
const absolute = path.resolve(process.cwd(), relativeFile);
|
|
852
|
+
try {
|
|
853
|
+
if (before.exists) {
|
|
854
|
+
fs.mkdirSync(path.dirname(absolute), { recursive: true });
|
|
855
|
+
fs.writeFileSync(absolute, before.content, 'utf-8');
|
|
856
|
+
} else if (fs.existsSync(absolute)) {
|
|
857
|
+
fs.rmSync(absolute);
|
|
858
|
+
}
|
|
859
|
+
rolledBackFiles.push(relativeFile);
|
|
860
|
+
} catch (err) {
|
|
861
|
+
rollbackFailures.push({ file: relativeFile, reason: 'restore_failed', message: err.message || String(err) });
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
return { rolledBackFiles, rollbackFailures };
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
function rollbackTimedOutApplyReply(msg) {
|
|
868
|
+
const details = state.timedOutApplyIds.get(msg.id);
|
|
869
|
+
if (!details) return { rolledBackFiles: [], rollbackFailures: [] };
|
|
870
|
+
state.timedOutApplyIds.delete(msg.id);
|
|
871
|
+
return rollbackApplySnapshot(details.batch, details.rollbackSnapshot, msg.data?.files || [], 'stale_manual_edit_apply_reply');
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
// Cap per-annotation upload size. A full 1920×1080 PNG is typically <1 MB;
|
|
875
|
+
// cap at 10 MB to guard against runaway writes from a misbehaving client.
|
|
876
|
+
const MAX_ANNOTATION_BYTES = 10 * 1024 * 1024;
|
|
877
|
+
|
|
878
|
+
function enqueueEvent(event) {
|
|
879
|
+
if (!event || (event.id && state.pendingEvents.some((entry) => entry.event?.id === event.id && entry.event?.type === event.type))) return;
|
|
880
|
+
state.pendingEvents.push({ event, leaseUntil: 0, seq: state.nextEventSeq++ });
|
|
881
|
+
flushPendingPolls();
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
function restorePendingEventsFromStore() {
|
|
885
|
+
if (!state.sessionStore) return;
|
|
886
|
+
for (const snapshot of state.sessionStore.listActiveSessions()) {
|
|
887
|
+
if (snapshot.pendingEvent) enqueueEvent(snapshot.pendingEvent);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
function findAvailablePendingEvent(now = Date.now()) {
|
|
892
|
+
for (const entry of state.pendingEvents) {
|
|
893
|
+
if (entry.leaseUntil && entry.leaseUntil > now) continue;
|
|
894
|
+
return entry;
|
|
895
|
+
}
|
|
896
|
+
return null;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
function leaseEvent(entry, leaseMs) {
|
|
900
|
+
if (!entry.event?.id) {
|
|
901
|
+
const idx = state.pendingEvents.indexOf(entry);
|
|
902
|
+
if (idx !== -1) state.pendingEvents.splice(idx, 1);
|
|
903
|
+
return entry.event;
|
|
904
|
+
}
|
|
905
|
+
entry.leaseUntil = Date.now() + leaseMs;
|
|
906
|
+
scheduleLeaseFlush();
|
|
907
|
+
broadcastAgentPollingIfChanged();
|
|
908
|
+
return entry.event;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
function acknowledgePendingEvent(id) {
|
|
912
|
+
if (!id) return false;
|
|
913
|
+
const idx = state.pendingEvents.findIndex((entry) => entry.event?.id === id);
|
|
914
|
+
if (idx === -1) return false;
|
|
915
|
+
const acknowledged = state.pendingEvents[idx].event;
|
|
916
|
+
state.pendingEvents.splice(idx, 1);
|
|
917
|
+
scheduleLeaseFlush();
|
|
918
|
+
broadcastAgentPollingIfChanged();
|
|
919
|
+
return acknowledged;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
function findPendingEventById(id) {
|
|
923
|
+
if (!id) return null;
|
|
924
|
+
const entry = state.pendingEvents.find((item) => item.event?.id === id);
|
|
925
|
+
return entry?.event || null;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
function manualApplyReplyCommand(eventOrId = 'EVENT_ID') {
|
|
929
|
+
const id = typeof eventOrId === 'string' ? eventOrId : eventOrId?.id || 'EVENT_ID';
|
|
930
|
+
return `live-poll.mjs --reply ${id} done --data '<json>'`;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
function buildManualApplyAgentAction(eventOrId = 'EVENT_ID') {
|
|
934
|
+
return {
|
|
935
|
+
kind: 'manual_edit_apply',
|
|
936
|
+
required: 'apply_source_edits_then_reply',
|
|
937
|
+
replyCommand: manualApplyReplyCommand(eventOrId),
|
|
938
|
+
warning: 'Polling only leases this work item; it does not commit source edits.',
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
function summarizeManualApplyEvent(event = {}, batch = event.batch) {
|
|
943
|
+
const entries = Array.isArray(batch?.entries) ? batch.entries : [];
|
|
944
|
+
const opCount = entries.reduce((sum, entry) => sum + (Array.isArray(entry.ops) ? entry.ops.length : 0), 0);
|
|
945
|
+
return {
|
|
946
|
+
pageUrl: event.pageUrl || null,
|
|
947
|
+
chunk: event.chunk || null,
|
|
948
|
+
entryCount: entries.length,
|
|
949
|
+
opCount,
|
|
950
|
+
files: collectManualApplyFiles(batch),
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
function summarizePendingEventForStatus(entry) {
|
|
955
|
+
const event = entry.event || {};
|
|
956
|
+
const summary = {
|
|
957
|
+
id: event.id,
|
|
958
|
+
type: event.type,
|
|
959
|
+
leased: !!(entry.leaseUntil && entry.leaseUntil > Date.now()),
|
|
960
|
+
leaseUntil: entry.leaseUntil || null,
|
|
961
|
+
};
|
|
962
|
+
if (event.type === 'manual_edit_apply') {
|
|
963
|
+
summary.pageUrl = event.pageUrl || null;
|
|
964
|
+
summary.chunk = event.chunk || null;
|
|
965
|
+
summary.repair = event.repair || null;
|
|
966
|
+
summary.evidencePath = event.evidencePath || null;
|
|
967
|
+
summary.agentAction = event.agentAction || buildManualApplyAgentAction(event);
|
|
968
|
+
summary.manualApplySummary = summarizeManualApplyEvent(event, state.pendingApplyDeferreds.get(event.id)?.batch || event.batch);
|
|
969
|
+
}
|
|
970
|
+
return summary;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
function summarizeActiveSessionForClient(snapshot = {}) {
|
|
974
|
+
return {
|
|
975
|
+
id: snapshot.id,
|
|
976
|
+
phase: snapshot.phase,
|
|
977
|
+
pageUrl: snapshot.pageUrl ?? null,
|
|
978
|
+
sourceFile: snapshot.sourceFile ?? null,
|
|
979
|
+
previewFile: snapshot.previewFile ?? null,
|
|
980
|
+
previewMode: snapshot.previewMode ?? null,
|
|
981
|
+
expectedVariants: snapshot.expectedVariants ?? 0,
|
|
982
|
+
arrivedVariants: snapshot.arrivedVariants ?? 0,
|
|
983
|
+
visibleVariant: snapshot.visibleVariant ?? null,
|
|
984
|
+
checkpointRevision: snapshot.checkpointRevision ?? 0,
|
|
985
|
+
paramValues: snapshot.paramValues || {},
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
function activeSessionSummaries() {
|
|
990
|
+
if (!state.sessionStore) return [];
|
|
991
|
+
return state.sessionStore.listActiveSessions().map((snapshot) => summarizeActiveSessionForClient(snapshot));
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
function cancelQueuedAnonymousExitEvents() {
|
|
995
|
+
let removed = 0;
|
|
996
|
+
for (let i = state.pendingEvents.length - 1; i >= 0; i -= 1) {
|
|
997
|
+
const event = state.pendingEvents[i]?.event;
|
|
998
|
+
if (event?.type !== 'exit' || event.id) continue;
|
|
999
|
+
state.pendingEvents.splice(i, 1);
|
|
1000
|
+
removed += 1;
|
|
1001
|
+
}
|
|
1002
|
+
if (removed > 0) {
|
|
1003
|
+
scheduleLeaseFlush();
|
|
1004
|
+
broadcastAgentPollingIfChanged();
|
|
1005
|
+
}
|
|
1006
|
+
return removed;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
function cancelPendingManualApplyEvents(pageUrl, reason = 'manual_edit_discarded') {
|
|
1010
|
+
const canceledById = new Map();
|
|
1011
|
+
const shouldCancel = (event) => event?.type === 'manual_edit_apply' && (!pageUrl || event.pageUrl === pageUrl);
|
|
1012
|
+
|
|
1013
|
+
for (let i = state.pendingEvents.length - 1; i >= 0; i -= 1) {
|
|
1014
|
+
const event = state.pendingEvents[i]?.event;
|
|
1015
|
+
if (!shouldCancel(event)) continue;
|
|
1016
|
+
state.pendingEvents.splice(i, 1);
|
|
1017
|
+
removeManualApplyEvidence(event.evidencePath);
|
|
1018
|
+
canceledById.set(event.id, {
|
|
1019
|
+
id: event.id,
|
|
1020
|
+
pageUrl: event.pageUrl,
|
|
1021
|
+
entryCount: event.batch?.entries?.length || 0,
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
for (const [eventId, deferred] of [...state.pendingApplyDeferreds.entries()]) {
|
|
1026
|
+
if (!shouldCancel(deferred.event)) continue;
|
|
1027
|
+
state.pendingApplyDeferreds.delete(eventId);
|
|
1028
|
+
clearTimeout(deferred.timer);
|
|
1029
|
+
const rollback = rollbackApplySnapshot(deferred.batch, deferred.rollbackSnapshot, [], reason);
|
|
1030
|
+
tombstoneTimedOutApplyId(eventId, {
|
|
1031
|
+
batch: deferred.batch,
|
|
1032
|
+
rollbackSnapshot: deferred.rollbackSnapshot,
|
|
1033
|
+
reason,
|
|
1034
|
+
});
|
|
1035
|
+
removeManualApplyEvidence(deferred.event?.evidencePath);
|
|
1036
|
+
canceledById.set(eventId, {
|
|
1037
|
+
id: eventId,
|
|
1038
|
+
pageUrl: deferred.pageUrl,
|
|
1039
|
+
entryCount: deferred.batch?.entries?.length || 0,
|
|
1040
|
+
rolledBackFiles: rollback.rolledBackFiles,
|
|
1041
|
+
rollbackFailures: rollback.rollbackFailures,
|
|
1042
|
+
});
|
|
1043
|
+
deferred.reject(new Error(reason));
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
if (canceledById.size > 0) flushPendingPolls();
|
|
1047
|
+
return [...canceledById.values()];
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
function scheduleLeaseFlush() {
|
|
1051
|
+
if (state.leaseTimer) {
|
|
1052
|
+
clearTimeout(state.leaseTimer);
|
|
1053
|
+
state.leaseTimer = null;
|
|
1054
|
+
}
|
|
1055
|
+
const now = Date.now();
|
|
1056
|
+
const nextLeaseUntil = state.pendingEvents
|
|
1057
|
+
.map((entry) => entry.leaseUntil || 0)
|
|
1058
|
+
.filter((leaseUntil) => leaseUntil > now)
|
|
1059
|
+
.sort((a, b) => a - b)[0];
|
|
1060
|
+
if (!nextLeaseUntil) return;
|
|
1061
|
+
state.leaseTimer = setTimeout(() => {
|
|
1062
|
+
state.leaseTimer = null;
|
|
1063
|
+
flushPendingPolls();
|
|
1064
|
+
broadcastAgentPollingIfChanged();
|
|
1065
|
+
}, Math.max(0, nextLeaseUntil - now + POLL_LEASE_EXPIRY_TIMER_GRACE_MS));
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
function flushPendingPolls() {
|
|
1069
|
+
let changed = false;
|
|
1070
|
+
while (state.pendingPolls.length > 0) {
|
|
1071
|
+
const entry = findAvailablePendingEvent();
|
|
1072
|
+
if (!entry) {
|
|
1073
|
+
scheduleLeaseFlush();
|
|
1074
|
+
broadcastAgentPollingIfChanged();
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
const poll = state.pendingPolls.shift();
|
|
1078
|
+
poll.resolve(leaseEvent(entry, poll.leaseMs));
|
|
1079
|
+
changed = true;
|
|
1080
|
+
}
|
|
1081
|
+
scheduleLeaseFlush();
|
|
1082
|
+
if (changed) broadcastAgentPollingIfChanged();
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
function agentPollingConnected() {
|
|
1086
|
+
const now = Date.now();
|
|
1087
|
+
return state.pendingPolls.length > 0
|
|
1088
|
+
|| state.pendingEvents.some((entry) => entry.leaseUntil && entry.leaseUntil > now);
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
function broadcastAgentPollingIfChanged() {
|
|
1092
|
+
const connected = agentPollingConnected();
|
|
1093
|
+
if (state.lastAgentPollingBroadcast === connected) return;
|
|
1094
|
+
state.lastAgentPollingBroadcast = connected;
|
|
1095
|
+
broadcast({ type: 'agent_polling', connected });
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
/** Push a message to all connected SSE clients. */
|
|
1099
|
+
function broadcast(msg) {
|
|
1100
|
+
const data = 'data: ' + JSON.stringify(msg) + '\n\n';
|
|
1101
|
+
for (const res of state.sseClients) {
|
|
1102
|
+
try { res.write(data); } catch { /* client gone */ }
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
function recordManualEditActivity(type, details = {}) {
|
|
1107
|
+
const entry = {
|
|
1108
|
+
seq: state.nextManualEditSeq++,
|
|
1109
|
+
type,
|
|
1110
|
+
ts: new Date().toISOString(),
|
|
1111
|
+
...details,
|
|
1112
|
+
};
|
|
1113
|
+
state.manualEditActivity = entry;
|
|
1114
|
+
if (DEBUG_MANUAL_EDIT_EVENTS) {
|
|
1115
|
+
try {
|
|
1116
|
+
const filePath = path.join(getLiveDir(process.cwd()), 'manual-edit-events.jsonl');
|
|
1117
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
1118
|
+
fs.appendFileSync(filePath, JSON.stringify(entry) + '\n');
|
|
1119
|
+
} catch {
|
|
1120
|
+
/* diagnostics are best-effort; never block live mode on observability */
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
broadcast(entry);
|
|
1124
|
+
return entry;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
function getManualEditStatus() {
|
|
1128
|
+
try {
|
|
1129
|
+
const { totalCount, perPage } = countPendingByPage(process.cwd());
|
|
1130
|
+
return { totalCount, perPage, lastActivity: state.manualEditActivity };
|
|
1131
|
+
} catch (err) {
|
|
1132
|
+
return {
|
|
1133
|
+
totalCount: null,
|
|
1134
|
+
perPage: {},
|
|
1135
|
+
lastActivity: state.manualEditActivity,
|
|
1136
|
+
error: err.message,
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
function summarizePendingManualEditBatch(pageUrl = null) {
|
|
1142
|
+
try {
|
|
1143
|
+
const buffer = readManualEditsBuffer(process.cwd());
|
|
1144
|
+
const entries = (buffer.entries || [])
|
|
1145
|
+
.filter((entry) => !pageUrl || entry.pageUrl === pageUrl);
|
|
1146
|
+
return {
|
|
1147
|
+
pendingEntryCount: entries.length,
|
|
1148
|
+
pendingOpCount: entries.reduce((sum, entry) => sum + (entry.ops?.length || 0), 0),
|
|
1149
|
+
};
|
|
1150
|
+
} catch (err) {
|
|
1151
|
+
return { pendingSummaryError: err.message || String(err) };
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
function summarizeManualApplyFailures(failed) {
|
|
1156
|
+
if (!Array.isArray(failed)) return [];
|
|
1157
|
+
return failed.slice(0, 20).map((item) => ({
|
|
1158
|
+
id: item.id || item.entryId || null,
|
|
1159
|
+
reason: item.reason || item.message || 'failed',
|
|
1160
|
+
message: compactManualLogText(item.message, 300),
|
|
1161
|
+
files: Array.isArray(item.files) ? item.files.slice(0, 12).map(summarizeManualLogFile).filter(Boolean) : undefined,
|
|
1162
|
+
checks: summarizeManualDiagnostics(item.checks),
|
|
1163
|
+
failures: summarizeManualDiagnostics(item.failures),
|
|
1164
|
+
candidates: summarizeManualDiagnostics(item.candidates),
|
|
1165
|
+
}));
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
function summarizeManualDiagnostics(items) {
|
|
1169
|
+
if (!Array.isArray(items) || items.length === 0) return undefined;
|
|
1170
|
+
return items.slice(0, 12).map((item) => ({
|
|
1171
|
+
reason: item.reason || item.kind || undefined,
|
|
1172
|
+
detail: compactManualLogText(item.detail, 220),
|
|
1173
|
+
message: compactManualLogText(item.message, 300),
|
|
1174
|
+
file: summarizeManualLogFile(item.file || item.relativeFile),
|
|
1175
|
+
line: item.line || undefined,
|
|
1176
|
+
ref: compactManualLogText(item.ref, 180),
|
|
1177
|
+
marker: compactManualLogText(item.marker, 120),
|
|
1178
|
+
files: Array.isArray(item.files) ? item.files.slice(0, 8).map(summarizeManualLogFile).filter(Boolean) : undefined,
|
|
1179
|
+
}));
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
function summarizeManualLogFile(file) {
|
|
1183
|
+
if (!file || typeof file !== 'string') return undefined;
|
|
1184
|
+
if (!path.isAbsolute(file)) return file;
|
|
1185
|
+
const relative = path.relative(process.cwd(), file);
|
|
1186
|
+
return relative && !relative.startsWith('..') && !path.isAbsolute(relative) ? relative : file;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
function compactManualLogText(value, max = 200) {
|
|
1190
|
+
if (typeof value !== 'string') return undefined;
|
|
1191
|
+
const normalized = value.replace(/\s+/g, ' ').trim();
|
|
1192
|
+
if (normalized.length <= max) return normalized;
|
|
1193
|
+
return normalized.slice(0, max) + `... [truncated ${normalized.length - max} chars]`;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
// ---------------------------------------------------------------------------
|
|
1197
|
+
// Load scripts
|
|
1198
|
+
// ---------------------------------------------------------------------------
|
|
1199
|
+
|
|
1200
|
+
function loadBrowserScripts() {
|
|
1201
|
+
// Detection script: prefer the skill-bundled detector, then fall back to
|
|
1202
|
+
// source/npm package locations for local development and older installs.
|
|
1203
|
+
// This one IS cached — detect.js rarely changes during a session.
|
|
1204
|
+
const detectPaths = [
|
|
1205
|
+
path.join(__dirname, 'detector', 'detect-antipatterns-browser.js'),
|
|
1206
|
+
path.join(__dirname, '..', '..', 'cli', 'engine', 'detect-antipatterns-browser.js'),
|
|
1207
|
+
path.join(__dirname, '..', '..', '..', '..', 'cli', 'engine', 'detect-antipatterns-browser.js'),
|
|
1208
|
+
path.join(process.cwd(), 'node_modules', 'impeccable', 'cli', 'engine', 'detect-antipatterns-browser.js'),
|
|
1209
|
+
];
|
|
1210
|
+
let detectScript = '';
|
|
1211
|
+
for (const p of detectPaths) {
|
|
1212
|
+
try { detectScript = fs.readFileSync(p, 'utf-8'); break; } catch { /* try next */ }
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
// live-browser.js: DO NOT cache. Return the path so the /live.js handler
|
|
1216
|
+
// can re-read on every request. Editing the browser script during iteration
|
|
1217
|
+
// should land on the next tab reload, not require a server restart.
|
|
1218
|
+
const sessionPath = path.join(__dirname, 'live-browser-session.js');
|
|
1219
|
+
const livePath = path.join(__dirname, 'live-browser.js');
|
|
1220
|
+
for (const p of [sessionPath, livePath]) {
|
|
1221
|
+
if (!fs.existsSync(p)) {
|
|
1222
|
+
process.stderr.write('Error: live browser script not found at ' + p + '\n');
|
|
1223
|
+
process.exit(1);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
return { detectScript, sessionPath, livePath };
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
function hasProjectContext() {
|
|
1231
|
+
// PRODUCT.md carries brand voice / anti-references — that's what determines
|
|
1232
|
+
// whether variants are brand-aware. DESIGN.md (visual tokens) is a separate
|
|
1233
|
+
// concern, surfaced by the design panel's own empty state.
|
|
1234
|
+
try {
|
|
1235
|
+
fs.accessSync(path.join(CONTEXT_DIR, 'PRODUCT.md'), fs.constants.R_OK);
|
|
1236
|
+
return true;
|
|
1237
|
+
} catch { return false; }
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
function statOrNull(filePath) {
|
|
1241
|
+
try { return fs.statSync(filePath); } catch { return null; }
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
// HTTP request handler
|
|
1245
|
+
// ---------------------------------------------------------------------------
|
|
1246
|
+
|
|
1247
|
+
function createRequestHandler({ detectScript, sessionPath, livePath }) {
|
|
1248
|
+
return (req, res) => {
|
|
1249
|
+
const url = new URL(req.url, `http://localhost:${state.port}`);
|
|
1250
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
1251
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
|
1252
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
|
1253
|
+
if (req.method === 'OPTIONS') { res.writeHead(204); res.end(); return; }
|
|
1254
|
+
|
|
1255
|
+
const p = url.pathname;
|
|
1256
|
+
|
|
1257
|
+
// --- Scripts ---
|
|
1258
|
+
if (p === '/live.js') {
|
|
1259
|
+
// Re-read from disk each request so edits to live-browser.js land on
|
|
1260
|
+
// the next tab reload. No-store headers prevent browser caching across
|
|
1261
|
+
// sessions — during iteration, a cached old script silently breaks
|
|
1262
|
+
// every subsequent session.
|
|
1263
|
+
let sessionScript;
|
|
1264
|
+
let liveScript;
|
|
1265
|
+
try {
|
|
1266
|
+
sessionScript = fs.readFileSync(sessionPath, 'utf-8');
|
|
1267
|
+
liveScript = fs.readFileSync(livePath, 'utf-8');
|
|
1268
|
+
} catch (err) {
|
|
1269
|
+
res.writeHead(500, { 'Content-Type': 'text/plain' });
|
|
1270
|
+
res.end('Error reading live browser scripts: ' + err.message);
|
|
1271
|
+
return;
|
|
1272
|
+
}
|
|
1273
|
+
const body =
|
|
1274
|
+
`window.__IMPECCABLE_TOKEN__ = '${state.token}';\n` +
|
|
1275
|
+
`window.__IMPECCABLE_PORT__ = ${state.port};\n` +
|
|
1276
|
+
// Canonical command vocabulary (values + labels + icons). live-browser.js
|
|
1277
|
+
// builds its action picker from this instead of an inline copy.
|
|
1278
|
+
`window.__IMPECCABLE_VOCAB__ = ${JSON.stringify(LIVE_COMMANDS)};\n` +
|
|
1279
|
+
sessionScript + '\n' +
|
|
1280
|
+
liveScript;
|
|
1281
|
+
res.writeHead(200, {
|
|
1282
|
+
'Content-Type': 'application/javascript',
|
|
1283
|
+
'Cache-Control': 'no-store, no-cache, must-revalidate, max-age=0',
|
|
1284
|
+
'Pragma': 'no-cache',
|
|
1285
|
+
});
|
|
1286
|
+
res.end(body);
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
if (p === '/detect.js' || p === '/') {
|
|
1290
|
+
if (!detectScript) { res.writeHead(404); res.end('Not available'); return; }
|
|
1291
|
+
res.writeHead(200, { 'Content-Type': 'application/javascript' });
|
|
1292
|
+
res.end(detectScript);
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
// --- Vendored modern-screenshot (UMD build) ---
|
|
1297
|
+
// Lazy-loaded by live.js when the user clicks Go; exposes
|
|
1298
|
+
// window.modernScreenshot.domToBlob(...) for capture.
|
|
1299
|
+
if (p === '/modern-screenshot.js') {
|
|
1300
|
+
const vendorPath = path.join(__dirname, 'modern-screenshot.umd.js');
|
|
1301
|
+
try {
|
|
1302
|
+
res.writeHead(200, {
|
|
1303
|
+
'Content-Type': 'application/javascript',
|
|
1304
|
+
'Cache-Control': 'public, max-age=31536000, immutable',
|
|
1305
|
+
});
|
|
1306
|
+
res.end(fs.readFileSync(vendorPath));
|
|
1307
|
+
} catch {
|
|
1308
|
+
res.writeHead(404); res.end('Vendor script not found');
|
|
1309
|
+
}
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
// --- Annotation upload (browser → server, raw PNG body) ---
|
|
1314
|
+
// Client generates the eventId, POSTs the PNG, then POSTs the generate
|
|
1315
|
+
// event with screenshotPath already set. Keeps bytes out of the SSE/poll
|
|
1316
|
+
// bridge and preserves the "one shot from the user's POV" UX.
|
|
1317
|
+
if (p === '/annotation' && req.method === 'POST') {
|
|
1318
|
+
const token = url.searchParams.get('token');
|
|
1319
|
+
if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
|
|
1320
|
+
const eventId = url.searchParams.get('eventId');
|
|
1321
|
+
if (!eventId || !/^[A-Za-z0-9_-]{1,64}$/.test(eventId)) {
|
|
1322
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
1323
|
+
res.end(JSON.stringify({ error: 'Invalid eventId' }));
|
|
1324
|
+
return;
|
|
1325
|
+
}
|
|
1326
|
+
if ((req.headers['content-type'] || '').toLowerCase() !== 'image/png') {
|
|
1327
|
+
res.writeHead(415, { 'Content-Type': 'application/json' });
|
|
1328
|
+
res.end(JSON.stringify({ error: 'Content-Type must be image/png' }));
|
|
1329
|
+
return;
|
|
1330
|
+
}
|
|
1331
|
+
if (!state.sessionDir) {
|
|
1332
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
1333
|
+
res.end(JSON.stringify({ error: 'Session dir unavailable' }));
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
const chunks = [];
|
|
1337
|
+
let total = 0;
|
|
1338
|
+
let aborted = false;
|
|
1339
|
+
req.on('data', (c) => {
|
|
1340
|
+
if (aborted) return;
|
|
1341
|
+
total += c.length;
|
|
1342
|
+
if (total > MAX_ANNOTATION_BYTES) {
|
|
1343
|
+
aborted = true;
|
|
1344
|
+
res.writeHead(413, { 'Content-Type': 'application/json' });
|
|
1345
|
+
res.end(JSON.stringify({ error: 'Payload too large' }));
|
|
1346
|
+
req.destroy();
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
chunks.push(c);
|
|
1350
|
+
});
|
|
1351
|
+
req.on('end', () => {
|
|
1352
|
+
if (aborted) return;
|
|
1353
|
+
const absPath = path.join(state.sessionDir, eventId + '.png');
|
|
1354
|
+
try {
|
|
1355
|
+
fs.writeFileSync(absPath, Buffer.concat(chunks));
|
|
1356
|
+
} catch (err) {
|
|
1357
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
1358
|
+
res.end(JSON.stringify({ error: 'Write failed: ' + err.message }));
|
|
1359
|
+
return;
|
|
1360
|
+
}
|
|
1361
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1362
|
+
res.end(JSON.stringify({ ok: true, path: absPath }));
|
|
1363
|
+
});
|
|
1364
|
+
req.on('error', () => {
|
|
1365
|
+
if (!aborted) {
|
|
1366
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
1367
|
+
res.end(JSON.stringify({ error: 'Upload failed' }));
|
|
1368
|
+
}
|
|
1369
|
+
});
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
// --- Health ---
|
|
1374
|
+
if (p === '/status') {
|
|
1375
|
+
const token = url.searchParams.get('token');
|
|
1376
|
+
if (token !== state.token) { res.writeHead(401, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ error: 'Unauthorized' })); return; }
|
|
1377
|
+
const sessions = activeSessionSummaries();
|
|
1378
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1379
|
+
res.end(JSON.stringify({
|
|
1380
|
+
status: 'ok',
|
|
1381
|
+
port: state.port,
|
|
1382
|
+
connectedClients: state.sseClients.size,
|
|
1383
|
+
pendingEvents: state.pendingEvents.map((entry) => summarizePendingEventForStatus(entry)),
|
|
1384
|
+
agentPolling: agentPollingConnected(),
|
|
1385
|
+
activeSessions: sessions,
|
|
1386
|
+
manualEdits: getManualEditStatus(),
|
|
1387
|
+
}));
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
if (p === '/health') {
|
|
1392
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1393
|
+
res.end(JSON.stringify({
|
|
1394
|
+
status: 'ok', port: state.port, mode: 'variant',
|
|
1395
|
+
hasProjectContext: hasProjectContext(),
|
|
1396
|
+
connectedClients: state.sseClients.size,
|
|
1397
|
+
}));
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
// --- Design system (unified v2 response) + raw ---
|
|
1402
|
+
// /design-system.json returns both parsed DESIGN.md and .impeccable/design.json
|
|
1403
|
+
// sidecar when present. Panel merges them:
|
|
1404
|
+
// { present, parsed, sidecar, hasMd, hasSidecar,
|
|
1405
|
+
// mdNewerThanJson, parseError?, sidecarError? }
|
|
1406
|
+
// - parsed: output of parseDesignMd (frontmatter
|
|
1407
|
+
// + six canonical sections) when DESIGN.md exists.
|
|
1408
|
+
// - sidecar: .impeccable/design.json contents when present.
|
|
1409
|
+
// Expected shape: schemaVersion 2, carrying
|
|
1410
|
+
// extensions + components + narrative.
|
|
1411
|
+
// /design-system/raw returns DESIGN.md markdown verbatim
|
|
1412
|
+
if (p === '/design-system.json' || p === '/design-system/raw') {
|
|
1413
|
+
const token = url.searchParams.get('token');
|
|
1414
|
+
if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
|
|
1415
|
+
|
|
1416
|
+
const mdPath = path.join(CONTEXT_DIR, 'DESIGN.md');
|
|
1417
|
+
const jsonPath = resolveDesignSidecarPath(process.cwd(), CONTEXT_DIR) || getDesignSidecarPath(process.cwd());
|
|
1418
|
+
const mdStat = statOrNull(mdPath);
|
|
1419
|
+
const jsonStat = statOrNull(jsonPath);
|
|
1420
|
+
|
|
1421
|
+
if (p === '/design-system/raw') {
|
|
1422
|
+
if (!mdStat) { res.writeHead(404); res.end('Not found'); return; }
|
|
1423
|
+
res.writeHead(200, { 'Content-Type': 'text/markdown; charset=utf-8' });
|
|
1424
|
+
res.end(fs.readFileSync(mdPath, 'utf-8'));
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
if (!mdStat && !jsonStat) {
|
|
1429
|
+
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
1430
|
+
res.end(JSON.stringify({ present: false }));
|
|
1431
|
+
return;
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
const response = {
|
|
1435
|
+
present: true,
|
|
1436
|
+
hasMd: !!mdStat,
|
|
1437
|
+
hasSidecar: !!jsonStat,
|
|
1438
|
+
mdNewerThanJson: !!(mdStat && jsonStat && mdStat.mtimeMs > jsonStat.mtimeMs + 1000),
|
|
1439
|
+
};
|
|
1440
|
+
|
|
1441
|
+
if (mdStat) {
|
|
1442
|
+
try {
|
|
1443
|
+
response.parsed = parseDesignMd(fs.readFileSync(mdPath, 'utf-8'));
|
|
1444
|
+
} catch (err) {
|
|
1445
|
+
response.parseError = err.message;
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
if (jsonStat) {
|
|
1450
|
+
try {
|
|
1451
|
+
response.sidecar = JSON.parse(fs.readFileSync(jsonPath, 'utf-8'));
|
|
1452
|
+
} catch (err) {
|
|
1453
|
+
response.sidecarError = 'Failed to parse .impeccable/design.json: ' + err.message;
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1458
|
+
res.end(JSON.stringify(response));
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
// --- Source file (no-HMR fallback) ---
|
|
1463
|
+
if (p === '/source') {
|
|
1464
|
+
const token = url.searchParams.get('token');
|
|
1465
|
+
if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
|
|
1466
|
+
const filePath = url.searchParams.get('path');
|
|
1467
|
+
if (!filePath || filePath.includes('..')) { res.writeHead(400); res.end('Bad path'); return; }
|
|
1468
|
+
const absPath = path.resolve(process.cwd(), filePath);
|
|
1469
|
+
if (!absPath.startsWith(process.cwd())) { res.writeHead(403); res.end('Forbidden'); return; }
|
|
1470
|
+
let content;
|
|
1471
|
+
try { content = fs.readFileSync(absPath, 'utf-8'); }
|
|
1472
|
+
catch { res.writeHead(404); res.end('File not found'); return; }
|
|
1473
|
+
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
1474
|
+
res.end(content);
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
// --- SSE: server→browser push (replaces WebSocket) ---
|
|
1479
|
+
if (p === '/events' && req.method === 'GET') {
|
|
1480
|
+
const token = url.searchParams.get('token');
|
|
1481
|
+
if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
|
|
1482
|
+
clearTimeout(state.exitTimer);
|
|
1483
|
+
state.exitTimer = null;
|
|
1484
|
+
cancelQueuedAnonymousExitEvents();
|
|
1485
|
+
res.writeHead(200, {
|
|
1486
|
+
'Content-Type': 'text/event-stream',
|
|
1487
|
+
'Cache-Control': 'no-cache',
|
|
1488
|
+
'Connection': 'keep-alive',
|
|
1489
|
+
});
|
|
1490
|
+
res.write('data: ' + JSON.stringify({
|
|
1491
|
+
type: 'connected',
|
|
1492
|
+
hasProjectContext: hasProjectContext(),
|
|
1493
|
+
agentPolling: agentPollingConnected(),
|
|
1494
|
+
activeSessions: activeSessionSummaries(),
|
|
1495
|
+
}) + '\n\n');
|
|
1496
|
+
|
|
1497
|
+
state.sseClients.add(res);
|
|
1498
|
+
|
|
1499
|
+
// Keepalive: SSE comment every 30s prevents silent connection drops.
|
|
1500
|
+
const heartbeat = setInterval(() => {
|
|
1501
|
+
try { res.write(': keepalive\n\n'); } catch { clearInterval(heartbeat); }
|
|
1502
|
+
}, SSE_HEARTBEAT_INTERVAL);
|
|
1503
|
+
|
|
1504
|
+
req.on('close', () => {
|
|
1505
|
+
clearInterval(heartbeat);
|
|
1506
|
+
state.sseClients.delete(res);
|
|
1507
|
+
if (state.sseClients.size === 0) {
|
|
1508
|
+
clearTimeout(state.exitTimer);
|
|
1509
|
+
state.exitTimer = setTimeout(() => {
|
|
1510
|
+
if (state.sseClients.size === 0) enqueueEvent({ type: 'exit' });
|
|
1511
|
+
}, 8000);
|
|
1512
|
+
}
|
|
1513
|
+
});
|
|
1514
|
+
return;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
// --- Manual copy edits: Save stages entries, Apply commits the staged
|
|
1518
|
+
// page batch through the local AI copy-edit runner.
|
|
1519
|
+
if (p === '/manual-edit-stash' && req.method === 'POST') {
|
|
1520
|
+
let body = '';
|
|
1521
|
+
req.on('data', (c) => { body += c; });
|
|
1522
|
+
req.on('end', () => {
|
|
1523
|
+
let msg;
|
|
1524
|
+
try { msg = JSON.parse(body); } catch {
|
|
1525
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
1526
|
+
res.end(JSON.stringify({ error: 'Invalid JSON' }));
|
|
1527
|
+
return;
|
|
1528
|
+
}
|
|
1529
|
+
if (msg.token !== state.token) {
|
|
1530
|
+
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
1531
|
+
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
1532
|
+
return;
|
|
1533
|
+
}
|
|
1534
|
+
const error = validateEvent({ ...msg, type: 'manual_edits' });
|
|
1535
|
+
if (error) {
|
|
1536
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
1537
|
+
res.end(JSON.stringify({ error }));
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
try {
|
|
1541
|
+
stageManualEditEntry(process.cwd(), {
|
|
1542
|
+
id: msg.id,
|
|
1543
|
+
pageUrl: msg.pageUrl,
|
|
1544
|
+
element: msg.element,
|
|
1545
|
+
ops: msg.ops,
|
|
1546
|
+
});
|
|
1547
|
+
} catch (err) {
|
|
1548
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
1549
|
+
res.end(JSON.stringify({ error: 'stash_write_failed', message: err.message }));
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
const { totalCount, perPage } = countPendingByPage(process.cwd());
|
|
1553
|
+
const pendingCount = perPage[msg.pageUrl] || 0;
|
|
1554
|
+
recordManualEditActivity('manual_edit_stashed', {
|
|
1555
|
+
id: msg.id,
|
|
1556
|
+
pageUrl: msg.pageUrl,
|
|
1557
|
+
opCount: msg.ops.length,
|
|
1558
|
+
pendingCount,
|
|
1559
|
+
totalCount,
|
|
1560
|
+
hintedFileCount: new Set((msg.ops || []).map((op) => summarizeManualLogFile(op.sourceHint?.file)).filter(Boolean)).size,
|
|
1561
|
+
});
|
|
1562
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1563
|
+
res.end(JSON.stringify({ ok: true, pendingCount, totalCount, perPage }));
|
|
1564
|
+
});
|
|
1565
|
+
return;
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
// GET /manual-edit-stash?pageUrl=<url> → { count, totalCount, perPage, entries }
|
|
1569
|
+
if (p === '/manual-edit-stash' && req.method === 'GET') {
|
|
1570
|
+
const token = url.searchParams.get('token');
|
|
1571
|
+
if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
|
|
1572
|
+
const pageUrl = url.searchParams.get('pageUrl') || '';
|
|
1573
|
+
const { totalCount, perPage } = countPendingByPage(process.cwd());
|
|
1574
|
+
const buffer = readManualEditsBuffer(process.cwd());
|
|
1575
|
+
const entriesForPage = pageUrl ? buffer.entries.filter((e) => e.pageUrl === pageUrl) : buffer.entries;
|
|
1576
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1577
|
+
res.end(JSON.stringify({
|
|
1578
|
+
count: pageUrl ? (perPage[pageUrl] || 0) : totalCount,
|
|
1579
|
+
totalCount,
|
|
1580
|
+
perPage,
|
|
1581
|
+
entries: entriesForPage,
|
|
1582
|
+
}));
|
|
1583
|
+
return;
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
// POST /manual-edit-commit?pageUrl=<url> → ask the AI to apply the staged page batch.
|
|
1587
|
+
if (p === '/manual-edit-commit' && req.method === 'POST') {
|
|
1588
|
+
const token = url.searchParams.get('token');
|
|
1589
|
+
if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
|
|
1590
|
+
const pageUrl = url.searchParams.get('pageUrl');
|
|
1591
|
+
const asyncMode = /^(1|true|yes)$/i.test(url.searchParams.get('async') || '');
|
|
1592
|
+
const repairOnly = /^(1|true|yes)$/i.test(url.searchParams.get('repair') || '');
|
|
1593
|
+
const existingTransaction = readManualApplyTransaction(process.cwd());
|
|
1594
|
+
if (repairOnly && !existingTransaction) {
|
|
1595
|
+
res.writeHead(409, { 'Content-Type': 'application/json' });
|
|
1596
|
+
res.end(JSON.stringify({ error: 'manual_edit_repair_transaction_missing' }));
|
|
1597
|
+
return;
|
|
1598
|
+
}
|
|
1599
|
+
const recoveredTransaction = repairOnly ? null : rollbackManualApplyTransaction({
|
|
1600
|
+
cwd: process.cwd(),
|
|
1601
|
+
pageUrl,
|
|
1602
|
+
reason: 'manual_edit_commit_recovered_abandoned_transaction',
|
|
1603
|
+
});
|
|
1604
|
+
const before = getManualEditStatus();
|
|
1605
|
+
const pendingCount = pageUrl ? (before.perPage[pageUrl] || 0) : before.totalCount;
|
|
1606
|
+
recordManualEditActivity('manual_edit_commit_started', {
|
|
1607
|
+
pageUrl,
|
|
1608
|
+
repairOnly,
|
|
1609
|
+
pendingCount,
|
|
1610
|
+
totalCount: before.totalCount,
|
|
1611
|
+
recoveredTransaction: recoveredTransaction ? {
|
|
1612
|
+
id: recoveredTransaction.id,
|
|
1613
|
+
reason: recoveredTransaction.reason,
|
|
1614
|
+
skipped: recoveredTransaction.skipped,
|
|
1615
|
+
rolledBackFiles: recoveredTransaction.rolledBackFiles,
|
|
1616
|
+
rollbackFailures: summarizeManualDiagnostics(recoveredTransaction.rollbackFailures),
|
|
1617
|
+
} : null,
|
|
1618
|
+
...summarizePendingManualEditBatch(pageUrl),
|
|
1619
|
+
});
|
|
1620
|
+
if (asyncMode) {
|
|
1621
|
+
res.writeHead(202, { 'Content-Type': 'application/json' });
|
|
1622
|
+
res.end(JSON.stringify({
|
|
1623
|
+
status: 'started',
|
|
1624
|
+
pendingCount,
|
|
1625
|
+
totalCount: before.totalCount,
|
|
1626
|
+
perPage: before.perPage,
|
|
1627
|
+
}));
|
|
1628
|
+
}
|
|
1629
|
+
(async () => {
|
|
1630
|
+
let result;
|
|
1631
|
+
let routedProvider = 'subprocess';
|
|
1632
|
+
let transaction = null;
|
|
1633
|
+
let commitBatch = null;
|
|
1634
|
+
try {
|
|
1635
|
+
if (pendingCount > 0) {
|
|
1636
|
+
const transactionBatch = buildManualEditEvidence({ cwd: process.cwd(), pageUrl });
|
|
1637
|
+
commitBatch = transactionBatch;
|
|
1638
|
+
if (!repairOnly && countManualApplyOps(transactionBatch) > 0) {
|
|
1639
|
+
transaction = writeManualApplyTransaction({
|
|
1640
|
+
cwd: process.cwd(),
|
|
1641
|
+
pageUrl,
|
|
1642
|
+
batch: transactionBatch,
|
|
1643
|
+
});
|
|
1644
|
+
} else if (repairOnly && existingTransaction) {
|
|
1645
|
+
transaction = existingTransaction;
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
const requestedMode = (process.env.IMPECCABLE_LIVE_COPY_AGENT || 'auto').trim().toLowerCase();
|
|
1649
|
+
const useChatRoute = requestedMode === 'chat'
|
|
1650
|
+
|| (requestedMode === 'auto' && chatAgentLikelyActive());
|
|
1651
|
+
if (useChatRoute) {
|
|
1652
|
+
routedProvider = 'chat';
|
|
1653
|
+
const timeoutMs = Number(process.env.IMPECCABLE_LIVE_COPY_AGENT_TIMEOUT_MS || 120000);
|
|
1654
|
+
result = await commitManualEdits({
|
|
1655
|
+
cwd: process.cwd(),
|
|
1656
|
+
pageUrl,
|
|
1657
|
+
provider: 'chat',
|
|
1658
|
+
env: process.env,
|
|
1659
|
+
timeoutMs,
|
|
1660
|
+
chatAvailable: chatAgentLikelyActive,
|
|
1661
|
+
applyBatchToSource: (batch, context) => pushApplyBatchInChunksAndWait(batch, pageUrl, context),
|
|
1662
|
+
repairOnly,
|
|
1663
|
+
transactionId: transaction?.id || existingTransaction?.id || null,
|
|
1664
|
+
batch: commitBatch,
|
|
1665
|
+
});
|
|
1666
|
+
} else {
|
|
1667
|
+
const timeoutMs = Number(process.env.IMPECCABLE_LIVE_COPY_AGENT_TIMEOUT_MS || 120000);
|
|
1668
|
+
const provider = ['codex', 'claude', 'mock'].includes(requestedMode) ? requestedMode : undefined;
|
|
1669
|
+
result = await commitManualEdits({
|
|
1670
|
+
cwd: process.cwd(),
|
|
1671
|
+
pageUrl,
|
|
1672
|
+
provider,
|
|
1673
|
+
env: process.env,
|
|
1674
|
+
timeoutMs,
|
|
1675
|
+
chatAvailable: chatAgentLikelyActive,
|
|
1676
|
+
repairOnly,
|
|
1677
|
+
transactionId: transaction?.id || existingTransaction?.id || null,
|
|
1678
|
+
batch: commitBatch,
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
} catch (err) {
|
|
1682
|
+
if (transaction) {
|
|
1683
|
+
rollbackManualApplyTransaction({
|
|
1684
|
+
cwd: process.cwd(),
|
|
1685
|
+
pageUrl,
|
|
1686
|
+
reason: 'manual_edit_commit_exception',
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
const message = err.stderr?.toString?.() || err.message;
|
|
1690
|
+
recordManualEditActivity('manual_edit_commit_failed', {
|
|
1691
|
+
pageUrl,
|
|
1692
|
+
provider: routedProvider,
|
|
1693
|
+
error: 'manual_edit_commit_failed',
|
|
1694
|
+
message,
|
|
1695
|
+
transactionId: transaction?.id || null,
|
|
1696
|
+
});
|
|
1697
|
+
if (!asyncMode) {
|
|
1698
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
1699
|
+
res.end(JSON.stringify({
|
|
1700
|
+
error: 'manual_edit_commit_failed',
|
|
1701
|
+
message,
|
|
1702
|
+
}));
|
|
1703
|
+
}
|
|
1704
|
+
return;
|
|
1705
|
+
} finally {
|
|
1706
|
+
if (transaction) {
|
|
1707
|
+
const shouldKeepTransaction = result?.needsManualDecision === true;
|
|
1708
|
+
if (!shouldKeepTransaction) clearManualApplyTransaction(process.cwd(), transaction.id);
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
const { totalCount, perPage } = countPendingByPage(process.cwd());
|
|
1712
|
+
if (result?.needsManualDecision) {
|
|
1713
|
+
recordManualEditActivity('manual_edit_repair_needs_decision', {
|
|
1714
|
+
pageUrl,
|
|
1715
|
+
provider: routedProvider,
|
|
1716
|
+
transactionId: transaction?.id || existingTransaction?.id || null,
|
|
1717
|
+
repair: result.repair || null,
|
|
1718
|
+
failed: summarizeManualApplyFailures(result.failed),
|
|
1719
|
+
files: Array.isArray(result.files) ? result.files.slice(0, 20).map(summarizeManualLogFile).filter(Boolean) : [],
|
|
1720
|
+
remainingCount: pageUrl ? (perPage[pageUrl] || 0) : totalCount,
|
|
1721
|
+
totalCount,
|
|
1722
|
+
});
|
|
1723
|
+
} else {
|
|
1724
|
+
recordManualEditActivity('manual_edit_commit_done', {
|
|
1725
|
+
pageUrl,
|
|
1726
|
+
provider: routedProvider,
|
|
1727
|
+
reason: result.reason || null,
|
|
1728
|
+
repair: result.repair || null,
|
|
1729
|
+
appliedCount: Array.isArray(result.applied) ? result.applied.length : 0,
|
|
1730
|
+
failedCount: Array.isArray(result.failed) ? result.failed.length : 0,
|
|
1731
|
+
failed: summarizeManualApplyFailures(result.failed),
|
|
1732
|
+
files: Array.isArray(result.files) ? result.files.slice(0, 20).map(summarizeManualLogFile).filter(Boolean) : [],
|
|
1733
|
+
warnings: summarizeManualDiagnostics(result.warnings),
|
|
1734
|
+
rolledBackFiles: Array.isArray(result.rolledBackFiles) ? result.rolledBackFiles.slice(0, 20).map(summarizeManualLogFile).filter(Boolean) : [],
|
|
1735
|
+
rollbackFailures: summarizeManualDiagnostics(result.rollbackFailures),
|
|
1736
|
+
unreportedFiles: Array.isArray(result.unreportedFiles) ? result.unreportedFiles.slice(0, 20).map(summarizeManualLogFile).filter(Boolean) : undefined,
|
|
1737
|
+
noteCount: Array.isArray(result.notes) ? result.notes.length : 0,
|
|
1738
|
+
cleared: result.cleared || 0,
|
|
1739
|
+
remainingCount: pageUrl ? (perPage[pageUrl] || 0) : totalCount,
|
|
1740
|
+
totalCount,
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
if (!asyncMode) {
|
|
1744
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1745
|
+
res.end(JSON.stringify({ ...result, totalCount, perPage }));
|
|
1746
|
+
}
|
|
1747
|
+
})();
|
|
1748
|
+
return;
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
// POST /manual-edit-repair-decision → user resolves an exhausted repair loop.
|
|
1752
|
+
if (p === '/manual-edit-repair-decision' && req.method === 'POST') {
|
|
1753
|
+
let body = '';
|
|
1754
|
+
req.on('data', (chunk) => { body += chunk; });
|
|
1755
|
+
req.on('end', () => {
|
|
1756
|
+
let payload = {};
|
|
1757
|
+
try { payload = body ? JSON.parse(body) : {}; } catch {
|
|
1758
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
1759
|
+
res.end(JSON.stringify({ error: 'Invalid JSON' }));
|
|
1760
|
+
return;
|
|
1761
|
+
}
|
|
1762
|
+
const token = payload.token || url.searchParams.get('token');
|
|
1763
|
+
if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
|
|
1764
|
+
const pageUrl = payload.pageUrl || url.searchParams.get('pageUrl') || null;
|
|
1765
|
+
const action = String(payload.action || url.searchParams.get('action') || '').trim().toLowerCase();
|
|
1766
|
+
if (action !== 'rollback') {
|
|
1767
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
1768
|
+
res.end(JSON.stringify({ error: 'unsupported_manual_edit_repair_decision', action }));
|
|
1769
|
+
return;
|
|
1770
|
+
}
|
|
1771
|
+
const rollback = rollbackManualApplyTransaction({
|
|
1772
|
+
cwd: process.cwd(),
|
|
1773
|
+
pageUrl,
|
|
1774
|
+
reason: 'manual_edit_user_requested_rollback',
|
|
1775
|
+
});
|
|
1776
|
+
const { totalCount, perPage } = countPendingByPage(process.cwd());
|
|
1777
|
+
const response = {
|
|
1778
|
+
action,
|
|
1779
|
+
pageUrl,
|
|
1780
|
+
rollback,
|
|
1781
|
+
remainingCount: pageUrl ? (perPage[pageUrl] || 0) : totalCount,
|
|
1782
|
+
totalCount,
|
|
1783
|
+
perPage,
|
|
1784
|
+
};
|
|
1785
|
+
recordManualEditActivity('manual_edit_repair_rollback_done', response);
|
|
1786
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1787
|
+
res.end(JSON.stringify(response));
|
|
1788
|
+
});
|
|
1789
|
+
return;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
// POST /manual-edit-discard?pageUrl=<url> → drops entries (all if no pageUrl)
|
|
1793
|
+
if (p === '/manual-edit-discard' && req.method === 'POST') {
|
|
1794
|
+
const token = url.searchParams.get('token');
|
|
1795
|
+
if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
|
|
1796
|
+
const pageUrl = url.searchParams.get('pageUrl');
|
|
1797
|
+
let discarded;
|
|
1798
|
+
let discardedEntries = [];
|
|
1799
|
+
let canceledApplyEvents = [];
|
|
1800
|
+
let transactionRollback = null;
|
|
1801
|
+
try {
|
|
1802
|
+
const buffer = readManualEditsBuffer(process.cwd());
|
|
1803
|
+
transactionRollback = rollbackManualApplyTransaction({
|
|
1804
|
+
cwd: process.cwd(),
|
|
1805
|
+
pageUrl,
|
|
1806
|
+
reason: 'manual_edit_discarded',
|
|
1807
|
+
});
|
|
1808
|
+
if (pageUrl) {
|
|
1809
|
+
discardedEntries = buffer.entries.filter((entry) => entry.pageUrl === pageUrl);
|
|
1810
|
+
discarded = removeManualEditEntries(process.cwd(), (entry) => entry.pageUrl === pageUrl);
|
|
1811
|
+
} else {
|
|
1812
|
+
discardedEntries = buffer.entries;
|
|
1813
|
+
discarded = truncateManualEditsBuffer(process.cwd());
|
|
1814
|
+
}
|
|
1815
|
+
canceledApplyEvents = cancelPendingManualApplyEvents(pageUrl);
|
|
1816
|
+
} catch (err) {
|
|
1817
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
1818
|
+
res.end(JSON.stringify({ error: 'discard_failed', message: err.message }));
|
|
1819
|
+
return;
|
|
1820
|
+
}
|
|
1821
|
+
const { totalCount, perPage } = countPendingByPage(process.cwd());
|
|
1822
|
+
recordManualEditActivity('manual_edit_discarded', {
|
|
1823
|
+
pageUrl,
|
|
1824
|
+
discarded,
|
|
1825
|
+
canceledApplyIds: canceledApplyEvents.map((event) => event.id),
|
|
1826
|
+
transactionRollback: transactionRollback ? {
|
|
1827
|
+
id: transactionRollback.id,
|
|
1828
|
+
rolledBackFiles: transactionRollback.rolledBackFiles?.map(summarizeManualLogFile).filter(Boolean) || [],
|
|
1829
|
+
rollbackFailures: summarizeManualDiagnostics(transactionRollback.rollbackFailures),
|
|
1830
|
+
skipped: transactionRollback.skipped,
|
|
1831
|
+
} : undefined,
|
|
1832
|
+
totalCount,
|
|
1833
|
+
});
|
|
1834
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1835
|
+
res.end(JSON.stringify({ discarded, entries: discardedEntries, canceledApplyEvents, totalCount, perPage }));
|
|
1836
|
+
return;
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
// Defense in depth: redirect any stragglers from the old /manual-edit endpoint.
|
|
1840
|
+
if (p === '/manual-edit' && req.method === 'POST') {
|
|
1841
|
+
res.writeHead(410, { 'Content-Type': 'application/json' });
|
|
1842
|
+
res.end(JSON.stringify({ error: '/manual-edit is removed; use /manual-edit-stash and /manual-edit-commit for staged copy edits.' }));
|
|
1843
|
+
return;
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
// --- Browser→server events (replaces WebSocket messages) ---
|
|
1847
|
+
if (p === '/events' && req.method === 'POST') {
|
|
1848
|
+
let body = '';
|
|
1849
|
+
req.on('data', (c) => { body += c; });
|
|
1850
|
+
req.on('end', () => {
|
|
1851
|
+
let msg;
|
|
1852
|
+
try { msg = JSON.parse(body); } catch {
|
|
1853
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
1854
|
+
res.end(JSON.stringify({ error: 'Invalid JSON' }));
|
|
1855
|
+
return;
|
|
1856
|
+
}
|
|
1857
|
+
if (msg.token !== state.token) {
|
|
1858
|
+
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
1859
|
+
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
1860
|
+
return;
|
|
1861
|
+
}
|
|
1862
|
+
// Defense in depth: manual copy edits must use the staged stash/apply
|
|
1863
|
+
// endpoints. The direct Save event path is disabled in the browser.
|
|
1864
|
+
if (msg.type === 'manual_edits') {
|
|
1865
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
1866
|
+
res.end(JSON.stringify({ error: 'manual_edits must POST to /manual-edit-stash, not /events' }));
|
|
1867
|
+
return;
|
|
1868
|
+
}
|
|
1869
|
+
if (msg.type === 'manual_edit_apply') {
|
|
1870
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
1871
|
+
res.end(JSON.stringify({ error: 'manual_edit_apply is disabled; use /manual-edit-stash then /manual-edit-commit' }));
|
|
1872
|
+
return;
|
|
1873
|
+
}
|
|
1874
|
+
const error = validateEvent(msg);
|
|
1875
|
+
if (error) {
|
|
1876
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
1877
|
+
res.end(JSON.stringify({ error }));
|
|
1878
|
+
return;
|
|
1879
|
+
}
|
|
1880
|
+
if (state.sessionStore && msg.id) {
|
|
1881
|
+
try {
|
|
1882
|
+
state.sessionStore.appendEvent(msg);
|
|
1883
|
+
} catch (err) {
|
|
1884
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
1885
|
+
res.end(JSON.stringify({ error: 'session_store_append_failed', message: err.message }));
|
|
1886
|
+
return;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
if (msg.type === 'exit') {
|
|
1890
|
+
cleanupSvelteComponentSessionsBeforeExit();
|
|
1891
|
+
}
|
|
1892
|
+
if (msg.type !== 'checkpoint') {
|
|
1893
|
+
enqueueEvent(msg);
|
|
1894
|
+
}
|
|
1895
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1896
|
+
res.end(JSON.stringify({ ok: true }));
|
|
1897
|
+
});
|
|
1898
|
+
return;
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
// --- Stop ---
|
|
1902
|
+
if (p === '/stop') {
|
|
1903
|
+
const token = url.searchParams.get('token');
|
|
1904
|
+
if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
|
|
1905
|
+
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
1906
|
+
res.end('stopping');
|
|
1907
|
+
shutdown();
|
|
1908
|
+
return;
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
// --- Agent poll ---
|
|
1912
|
+
if (p === '/poll' && req.method === 'GET') {
|
|
1913
|
+
handlePollGet(req, res, url);
|
|
1914
|
+
return;
|
|
1915
|
+
}
|
|
1916
|
+
if (p === '/poll' && req.method === 'POST') {
|
|
1917
|
+
handlePollPost(req, res);
|
|
1918
|
+
return;
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
res.writeHead(404); res.end('Not found');
|
|
1922
|
+
};
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
// ---------------------------------------------------------------------------
|
|
1926
|
+
// Agent poll endpoints (unchanged from WS version)
|
|
1927
|
+
// ---------------------------------------------------------------------------
|
|
1928
|
+
|
|
1929
|
+
function handlePollGet(req, res, url) {
|
|
1930
|
+
const token = url.searchParams.get('token');
|
|
1931
|
+
if (token !== state.token) {
|
|
1932
|
+
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
1933
|
+
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1936
|
+
state.lastPollAt = Date.now();
|
|
1937
|
+
const timeout = parseInt(url.searchParams.get('timeout') || DEFAULT_POLL_TIMEOUT, 10);
|
|
1938
|
+
const leaseMs = parseInt(url.searchParams.get('leaseMs') || '30000', 10);
|
|
1939
|
+
const available = findAvailablePendingEvent();
|
|
1940
|
+
if (available) {
|
|
1941
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1942
|
+
res.end(JSON.stringify(leaseEvent(available, leaseMs)));
|
|
1943
|
+
return;
|
|
1944
|
+
}
|
|
1945
|
+
const poll = { resolve, leaseMs };
|
|
1946
|
+
const timer = setTimeout(() => {
|
|
1947
|
+
const idx = state.pendingPolls.indexOf(poll);
|
|
1948
|
+
if (idx !== -1) state.pendingPolls.splice(idx, 1);
|
|
1949
|
+
broadcastAgentPollingIfChanged();
|
|
1950
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1951
|
+
res.end(JSON.stringify({ type: 'timeout' }));
|
|
1952
|
+
}, timeout);
|
|
1953
|
+
function resolve(event) {
|
|
1954
|
+
clearTimeout(timer);
|
|
1955
|
+
state.lastPollAt = Date.now();
|
|
1956
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1957
|
+
res.end(JSON.stringify(event));
|
|
1958
|
+
}
|
|
1959
|
+
state.pendingPolls.push(poll);
|
|
1960
|
+
broadcastAgentPollingIfChanged();
|
|
1961
|
+
scheduleLeaseFlush();
|
|
1962
|
+
req.on('close', () => {
|
|
1963
|
+
clearTimeout(timer);
|
|
1964
|
+
const idx = state.pendingPolls.indexOf(poll);
|
|
1965
|
+
if (idx !== -1) state.pendingPolls.splice(idx, 1);
|
|
1966
|
+
broadcastAgentPollingIfChanged();
|
|
1967
|
+
});
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
function sessionFileMetadataFromPollReply(file) {
|
|
1971
|
+
if (!file || typeof file !== 'string') return { file };
|
|
1972
|
+
const normalized = file.split(path.sep).join('/');
|
|
1973
|
+
const base = { file: normalized };
|
|
1974
|
+
if (!normalized.endsWith('/manifest.json') && normalized !== 'manifest.json') return base;
|
|
1975
|
+
if (!normalized.includes('node_modules/.impeccable-live/') && !normalized.includes('src/lib/impeccable/')) return base;
|
|
1976
|
+
|
|
1977
|
+
let full;
|
|
1978
|
+
try {
|
|
1979
|
+
full = path.resolve(process.cwd(), normalized);
|
|
1980
|
+
const rel = path.relative(process.cwd(), full);
|
|
1981
|
+
if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) return base;
|
|
1982
|
+
} catch {
|
|
1983
|
+
return base;
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
try {
|
|
1987
|
+
const manifest = JSON.parse(fs.readFileSync(full, 'utf-8'));
|
|
1988
|
+
if (manifest?.previewMode !== 'svelte-component' || !manifest.sourceFile) return base;
|
|
1989
|
+
return {
|
|
1990
|
+
file: String(manifest.sourceFile).split(path.sep).join('/'),
|
|
1991
|
+
sourceFile: String(manifest.sourceFile).split(path.sep).join('/'),
|
|
1992
|
+
previewFile: normalized,
|
|
1993
|
+
previewMode: 'svelte-component',
|
|
1994
|
+
};
|
|
1995
|
+
} catch {
|
|
1996
|
+
return base;
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
function handlePollPost(req, res) {
|
|
2001
|
+
let body = '';
|
|
2002
|
+
req.on('data', (c) => { body += c; });
|
|
2003
|
+
req.on('end', () => {
|
|
2004
|
+
let msg;
|
|
2005
|
+
try { msg = JSON.parse(body); } catch {
|
|
2006
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
2007
|
+
res.end(JSON.stringify({ error: 'Invalid JSON' }));
|
|
2008
|
+
return;
|
|
2009
|
+
}
|
|
2010
|
+
if (msg.token !== state.token) {
|
|
2011
|
+
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
2012
|
+
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
2013
|
+
return;
|
|
2014
|
+
}
|
|
2015
|
+
const pendingApplyDeferred = state.pendingApplyDeferreds.get(msg.id);
|
|
2016
|
+
if (pendingApplyDeferred) {
|
|
2017
|
+
const validation = validateManualApplyResultMessage(msg, pendingApplyDeferred);
|
|
2018
|
+
if (!validation.ok) {
|
|
2019
|
+
recordManualEditActivity('manual_edit_apply_reply_invalid', {
|
|
2020
|
+
id: msg.id,
|
|
2021
|
+
pageUrl: pendingApplyDeferred.pageUrl,
|
|
2022
|
+
chunk: pendingApplyDeferred.event?.chunk || null,
|
|
2023
|
+
repair: pendingApplyDeferred.event?.repair || null,
|
|
2024
|
+
reason: validation.body?.reason || validation.body?.error || 'invalid_manual_apply_result',
|
|
2025
|
+
status: msg.data?.status || null,
|
|
2026
|
+
});
|
|
2027
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
2028
|
+
res.end(JSON.stringify(validation.body));
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
recordManualEditActivity('manual_edit_apply_reply_received', {
|
|
2032
|
+
id: msg.id,
|
|
2033
|
+
pageUrl: pendingApplyDeferred.pageUrl,
|
|
2034
|
+
chunk: pendingApplyDeferred.event?.chunk || null,
|
|
2035
|
+
repair: pendingApplyDeferred.event?.repair || null,
|
|
2036
|
+
status: validation.result.status,
|
|
2037
|
+
appliedCount: validation.result.appliedEntryIds.length,
|
|
2038
|
+
failed: summarizeManualApplyFailures(validation.result.failed),
|
|
2039
|
+
fileCount: validation.result.files.length,
|
|
2040
|
+
noteCount: validation.result.notes.length,
|
|
2041
|
+
});
|
|
2042
|
+
resolveApplyDeferred(msg.id, validation.result);
|
|
2043
|
+
acknowledgePendingEvent(msg.id);
|
|
2044
|
+
flushPendingPolls();
|
|
2045
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
2046
|
+
res.end(JSON.stringify({ ok: true }));
|
|
2047
|
+
return;
|
|
2048
|
+
}
|
|
2049
|
+
if (state.timedOutApplyIds.has(msg.id)) {
|
|
2050
|
+
const rollback = rollbackTimedOutApplyReply(msg);
|
|
2051
|
+
recordManualEditActivity('manual_edit_apply_stale_reply_rejected', {
|
|
2052
|
+
id: msg.id,
|
|
2053
|
+
rolledBackFileCount: rollback.rolledBackFiles?.length || 0,
|
|
2054
|
+
rollbackFailureCount: rollback.rollbackFailures?.length || 0,
|
|
2055
|
+
});
|
|
2056
|
+
res.writeHead(409, { 'Content-Type': 'application/json' });
|
|
2057
|
+
res.end(JSON.stringify({ error: 'stale_manual_edit_apply_reply', ...rollback }));
|
|
2058
|
+
return;
|
|
2059
|
+
}
|
|
2060
|
+
const pendingEventBeforeAck = findPendingEventById(msg.id);
|
|
2061
|
+
if (pendingEventBeforeAck?.type === 'steer' && msg.type === 'steer_done'
|
|
2062
|
+
&& !msg.file && !(typeof msg.message === 'string' && msg.message.trim())) {
|
|
2063
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
2064
|
+
res.end(JSON.stringify({
|
|
2065
|
+
error: 'steer_done_requires_file_or_message',
|
|
2066
|
+
hint: 'Reply with --file after writing source, or include a message explaining an intentional no-op.',
|
|
2067
|
+
}));
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
2070
|
+
const acknowledgedEvent = acknowledgePendingEvent(msg.id);
|
|
2071
|
+
let skipJournalReply = false;
|
|
2072
|
+
let existingSession = null;
|
|
2073
|
+
if (!acknowledgedEvent && state.sessionStore && msg.id) {
|
|
2074
|
+
try {
|
|
2075
|
+
existingSession = state.sessionStore.getSnapshot(msg.id, { includeCompleted: true });
|
|
2076
|
+
if (!existingSession?.updatedAt) existingSession = null;
|
|
2077
|
+
skipJournalReply = existingSession?.phase === 'completed' || existingSession?.phase === 'discarded';
|
|
2078
|
+
} catch { /* fall through and record the reply normally */ }
|
|
2079
|
+
}
|
|
2080
|
+
if (!acknowledgedEvent && !existingSession) {
|
|
2081
|
+
recordManualEditActivity('manual_edit_poll_reply_unknown', {
|
|
2082
|
+
id: msg.id || null,
|
|
2083
|
+
type: msg.type || null,
|
|
2084
|
+
});
|
|
2085
|
+
res.writeHead(msg.id ? 404 : 400, { 'Content-Type': 'application/json' });
|
|
2086
|
+
res.end(JSON.stringify({
|
|
2087
|
+
error: msg.id ? 'unknown_poll_reply_id' : 'missing_poll_reply_id',
|
|
2088
|
+
id: msg.id,
|
|
2089
|
+
}));
|
|
2090
|
+
return;
|
|
2091
|
+
}
|
|
2092
|
+
const replyFileMeta = sessionFileMetadataFromPollReply(msg.file);
|
|
2093
|
+
if (state.sessionStore && msg.id && !skipJournalReply) {
|
|
2094
|
+
try {
|
|
2095
|
+
const eventType = msg.type === 'steer_done'
|
|
2096
|
+
? 'steer_done'
|
|
2097
|
+
: msg.type === 'discard' || msg.type === 'discarded'
|
|
2098
|
+
? 'discarded'
|
|
2099
|
+
: msg.type === 'complete'
|
|
2100
|
+
? 'complete'
|
|
2101
|
+
: msg.type === 'error'
|
|
2102
|
+
? 'agent_error'
|
|
2103
|
+
: 'agent_done';
|
|
2104
|
+
state.sessionStore.appendEvent({
|
|
2105
|
+
type: eventType,
|
|
2106
|
+
id: msg.id,
|
|
2107
|
+
file: replyFileMeta.file,
|
|
2108
|
+
sourceFile: replyFileMeta.sourceFile,
|
|
2109
|
+
previewFile: replyFileMeta.previewFile,
|
|
2110
|
+
previewMode: replyFileMeta.previewMode,
|
|
2111
|
+
message: msg.message,
|
|
2112
|
+
sourceEventType: acknowledgedEvent?.type,
|
|
2113
|
+
carbonize: msg.data?.carbonize === true,
|
|
2114
|
+
});
|
|
2115
|
+
} catch { /* keep reply path best-effort; browser still needs SSE */ }
|
|
2116
|
+
}
|
|
2117
|
+
flushPendingPolls();
|
|
2118
|
+
// Forward the reply to the browser via SSE
|
|
2119
|
+
broadcast({
|
|
2120
|
+
type: msg.type || 'done',
|
|
2121
|
+
id: msg.id,
|
|
2122
|
+
message: msg.message,
|
|
2123
|
+
file: msg.file,
|
|
2124
|
+
sourceFile: replyFileMeta.sourceFile,
|
|
2125
|
+
previewFile: replyFileMeta.previewFile,
|
|
2126
|
+
previewMode: replyFileMeta.previewMode,
|
|
2127
|
+
data: msg.data,
|
|
2128
|
+
});
|
|
2129
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
2130
|
+
res.end(JSON.stringify({ ok: true }));
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
// ---------------------------------------------------------------------------
|
|
2135
|
+
// Lifecycle
|
|
2136
|
+
// ---------------------------------------------------------------------------
|
|
2137
|
+
|
|
2138
|
+
let httpServer = null;
|
|
2139
|
+
|
|
2140
|
+
function shutdown() {
|
|
2141
|
+
cleanupSvelteComponentSessionsBeforeExit();
|
|
2142
|
+
removeLiveServerInfo(process.cwd());
|
|
2143
|
+
if (state.leaseTimer) clearTimeout(state.leaseTimer);
|
|
2144
|
+
state.leaseTimer = null;
|
|
2145
|
+
if (state.sessionDir) {
|
|
2146
|
+
try { fs.rmSync(state.sessionDir, { recursive: true, force: true }); } catch {}
|
|
2147
|
+
}
|
|
2148
|
+
for (const res of state.sseClients) { try { res.end(); } catch {} }
|
|
2149
|
+
state.sseClients.clear();
|
|
2150
|
+
for (const poll of state.pendingPolls) poll.resolve({ type: 'exit' });
|
|
2151
|
+
state.pendingPolls.length = 0;
|
|
2152
|
+
if (httpServer) httpServer.close();
|
|
2153
|
+
process.exit(0);
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2156
|
+
function cleanupSvelteComponentSessionsBeforeExit() {
|
|
2157
|
+
try {
|
|
2158
|
+
removeAllSvelteComponentSessions(process.cwd());
|
|
2159
|
+
} catch (err) {
|
|
2160
|
+
console.warn('[impeccable] Svelte component session cleanup failed:', err.message);
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
function applyLegacyDeferredAcceptsOnStartup() {
|
|
2165
|
+
try {
|
|
2166
|
+
const result = applyDeferredSvelteComponentAccepts(process.cwd());
|
|
2167
|
+
if (result.applied > 0 || result.failed > 0) {
|
|
2168
|
+
console.log('[impeccable] applied legacy deferred Svelte component accepts:', JSON.stringify(result));
|
|
2169
|
+
}
|
|
2170
|
+
} catch (err) {
|
|
2171
|
+
console.warn('[impeccable] legacy deferred Svelte component accept apply failed:', err.message);
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
// ---------------------------------------------------------------------------
|
|
2176
|
+
// Main
|
|
2177
|
+
// ---------------------------------------------------------------------------
|
|
2178
|
+
|
|
2179
|
+
const args = process.argv.slice(2);
|
|
2180
|
+
|
|
2181
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
2182
|
+
console.log(`Usage: node live-server.mjs [options]
|
|
2183
|
+
|
|
2184
|
+
Start the live variant mode server (zero dependencies).
|
|
2185
|
+
|
|
2186
|
+
Commands:
|
|
2187
|
+
(default) Start the server (foreground)
|
|
2188
|
+
stop Stop the server and remove the injected live.js script tag
|
|
2189
|
+
stop --keep-inject Stop the server only (leave the script tag in the HTML entry)
|
|
2190
|
+
|
|
2191
|
+
Options:
|
|
2192
|
+
--background Start detached, print connection JSON to stdout, then exit
|
|
2193
|
+
--port=PORT Use a specific port (default: auto-detect starting at 8400)
|
|
2194
|
+
--keep-inject Only with stop: skip live-inject.mjs --remove
|
|
2195
|
+
--help Show this help
|
|
2196
|
+
|
|
2197
|
+
Endpoints:
|
|
2198
|
+
/live.js Browser script (element picker + variant cycling)
|
|
2199
|
+
/detect.js Detection overlay (backwards compatible)
|
|
2200
|
+
/modern-screenshot.js Vendored modern-screenshot UMD build (lazy-loaded by live.js)
|
|
2201
|
+
/annotation POST raw image/png to stage a variant screenshot
|
|
2202
|
+
/events SSE stream (server→browser) + POST (browser→server)
|
|
2203
|
+
/poll Long-poll for agent CLI
|
|
2204
|
+
/manual-edit-stash Stage browser copy edits
|
|
2205
|
+
/manual-edit-commit Apply staged browser copy edits
|
|
2206
|
+
/manual-edit-discard Discard staged browser copy edits
|
|
2207
|
+
/source Raw source file reader (no-HMR fallback)
|
|
2208
|
+
/status Durable recovery status (token-protected)
|
|
2209
|
+
/health Health check`);
|
|
2210
|
+
process.exit(0);
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
if (args.includes('stop')) {
|
|
2214
|
+
const keepInject = args.includes('--keep-inject');
|
|
2215
|
+
try {
|
|
2216
|
+
const { info } = readLiveServerInfo(process.cwd()) || {};
|
|
2217
|
+
const res = await fetch(`http://localhost:${info.port}/stop?token=${info.token}`);
|
|
2218
|
+
if (res.ok) console.log(`Stopped live server on port ${info.port}.`);
|
|
2219
|
+
} catch {
|
|
2220
|
+
console.log('No running live server found.');
|
|
2221
|
+
}
|
|
2222
|
+
if (!keepInject) {
|
|
2223
|
+
const injectPath = path.join(__dirname, 'live-inject.mjs');
|
|
2224
|
+
try {
|
|
2225
|
+
const out = execFileSync(process.execPath, [injectPath, '--remove'], {
|
|
2226
|
+
encoding: 'utf-8',
|
|
2227
|
+
cwd: process.cwd(),
|
|
2228
|
+
});
|
|
2229
|
+
const line = out.trim().split('\n').filter(Boolean).pop();
|
|
2230
|
+
if (line) {
|
|
2231
|
+
try {
|
|
2232
|
+
const j = JSON.parse(line);
|
|
2233
|
+
if (j.removed === true) {
|
|
2234
|
+
console.log(`Removed live script tag from ${j.file}.`);
|
|
2235
|
+
}
|
|
2236
|
+
} catch {
|
|
2237
|
+
/* ignore non-JSON lines */
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
} catch (err) {
|
|
2241
|
+
const detail = err.stderr?.toString?.().trim?.()
|
|
2242
|
+
|| err.stdout?.toString?.().trim?.()
|
|
2243
|
+
|| err.message
|
|
2244
|
+
|| String(err);
|
|
2245
|
+
console.warn(`Note: could not remove live script tag (${detail.split('\n')[0]})`);
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
process.exit(0);
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
// --background: spawn a detached child server, wait for it to be ready,
|
|
2252
|
+
// print the connection JSON, then exit. This keeps the startup command
|
|
2253
|
+
// simple (no shell backgrounding or chained commands).
|
|
2254
|
+
if (args.includes('--background')) {
|
|
2255
|
+
const childArgs = args.filter(a => a !== '--background');
|
|
2256
|
+
const child = spawn(process.execPath, [fileURLToPath(import.meta.url), ...childArgs], {
|
|
2257
|
+
detached: true,
|
|
2258
|
+
stdio: 'ignore',
|
|
2259
|
+
cwd: process.cwd(),
|
|
2260
|
+
});
|
|
2261
|
+
child.unref();
|
|
2262
|
+
|
|
2263
|
+
// Poll for the PID file (the child writes it once the HTTP server is listening).
|
|
2264
|
+
const deadline = Date.now() + 10_000;
|
|
2265
|
+
while (Date.now() < deadline) {
|
|
2266
|
+
try {
|
|
2267
|
+
const { info } = readLiveServerInfo(process.cwd()) || {};
|
|
2268
|
+
if (info.pid !== process.pid) {
|
|
2269
|
+
// Output JSON so the agent can read port + token from stdout.
|
|
2270
|
+
console.log(JSON.stringify(info));
|
|
2271
|
+
process.exit(0);
|
|
2272
|
+
}
|
|
2273
|
+
} catch { /* not ready yet */ }
|
|
2274
|
+
await new Promise(r => setTimeout(r, 200));
|
|
2275
|
+
}
|
|
2276
|
+
console.error('Timed out waiting for live server to start.');
|
|
2277
|
+
process.exit(1);
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
// Check for existing session
|
|
2281
|
+
const existingRecord = readLiveServerInfo(process.cwd());
|
|
2282
|
+
if (existingRecord?.info) {
|
|
2283
|
+
const existing = existingRecord.info;
|
|
2284
|
+
try {
|
|
2285
|
+
process.kill(existing.pid, 0);
|
|
2286
|
+
console.error(`Live server already running on port ${existing.port} (pid ${existing.pid}).`);
|
|
2287
|
+
console.error('Stop it first with: node ' + path.basename(fileURLToPath(import.meta.url)) + ' stop');
|
|
2288
|
+
process.exit(1);
|
|
2289
|
+
} catch {
|
|
2290
|
+
try { fs.unlinkSync(existingRecord.path); } catch {}
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
state.token = randomUUID();
|
|
2295
|
+
state.sessionStore = createLiveSessionStore({ cwd: process.cwd() });
|
|
2296
|
+
rollbackManualApplyTransaction({
|
|
2297
|
+
cwd: process.cwd(),
|
|
2298
|
+
reason: 'manual_edit_server_start_recovered_abandoned_transaction',
|
|
2299
|
+
});
|
|
2300
|
+
applyLegacyDeferredAcceptsOnStartup();
|
|
2301
|
+
restorePendingEventsFromStore();
|
|
2302
|
+
pruneStaleManualApplyEvidence(process.cwd());
|
|
2303
|
+
const portArg = args.find(a => a.startsWith('--port='));
|
|
2304
|
+
state.port = portArg ? parseInt(portArg.split('=')[1], 10) : await findOpenPort();
|
|
2305
|
+
// Annotation screenshots live in the project root so the agent's Read tool
|
|
2306
|
+
// doesn't trip a per-file permission prompt. Sessioned by token so concurrent
|
|
2307
|
+
// projects (or quick restarts) don't collide.
|
|
2308
|
+
const annotRoot = getLiveAnnotationsDir(process.cwd());
|
|
2309
|
+
fs.mkdirSync(annotRoot, { recursive: true });
|
|
2310
|
+
state.sessionDir = fs.mkdtempSync(path.join(annotRoot, 'session-'));
|
|
2311
|
+
|
|
2312
|
+
const { detectScript, sessionPath, livePath } = loadBrowserScripts();
|
|
2313
|
+
httpServer = http.createServer(createRequestHandler({ detectScript, sessionPath, livePath }));
|
|
2314
|
+
|
|
2315
|
+
httpServer.listen(state.port, '127.0.0.1', () => {
|
|
2316
|
+
writeLiveServerInfo(process.cwd(), { pid: process.pid, port: state.port, token: state.token });
|
|
2317
|
+
const url = `http://localhost:${state.port}`;
|
|
2318
|
+
console.log(`\nImpeccable live server running on ${url}`);
|
|
2319
|
+
console.log(`Token: ${state.token}\n`);
|
|
2320
|
+
console.log(`Script: ${url}/live.js`);
|
|
2321
|
+
console.log('Inject: managed by live-inject.mjs; Astro source tags use is:inline automatically.');
|
|
2322
|
+
console.log(`Stop: node ${path.basename(fileURLToPath(import.meta.url))} stop`);
|
|
2323
|
+
});
|
|
2324
|
+
|
|
2325
|
+
process.on('SIGINT', shutdown);
|
|
2326
|
+
process.on('SIGTERM', shutdown);
|