@walwal-harness/cli 6.1.5 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/HR-Resource/academic-academic-anthropologist/SKILL.md +142 -0
- package/HR-Resource/academic-academic-geographer/SKILL.md +144 -0
- package/HR-Resource/academic-academic-historian/SKILL.md +140 -0
- package/HR-Resource/academic-academic-narratologist/SKILL.md +135 -0
- package/HR-Resource/academic-academic-psychologist/SKILL.md +135 -0
- package/HR-Resource/brick-office/SKILL.md +20 -0
- package/HR-Resource/cdo/SKILL.md +33 -0
- package/HR-Resource/ceo/SKILL.md +36 -0
- package/HR-Resource/coo/SKILL.md +36 -0
- package/HR-Resource/cqo/SKILL.md +33 -0
- package/HR-Resource/cto/SKILL.md +36 -0
- package/HR-Resource/design-design-brand-guardian/SKILL.md +339 -0
- package/HR-Resource/design-design-image-prompt-engineer/SKILL.md +253 -0
- package/HR-Resource/design-design-inclusive-visuals-specialist/SKILL.md +88 -0
- package/HR-Resource/design-design-ui-designer/SKILL.md +400 -0
- package/HR-Resource/design-design-ux-architect/SKILL.md +486 -0
- package/HR-Resource/design-design-ux-researcher/SKILL.md +346 -0
- package/HR-Resource/design-design-visual-storyteller/SKILL.md +166 -0
- package/HR-Resource/design-design-whimsy-injector/SKILL.md +455 -0
- package/HR-Resource/engineering-engineering-ai-data-remediation-engineer/SKILL.md +227 -0
- package/HR-Resource/engineering-engineering-ai-engineer/SKILL.md +163 -0
- package/HR-Resource/engineering-engineering-autonomous-optimization-architect/SKILL.md +124 -0
- package/HR-Resource/engineering-engineering-backend-architect/SKILL.md +252 -0
- package/HR-Resource/engineering-engineering-cms-developer/SKILL.md +553 -0
- package/HR-Resource/engineering-engineering-code-reviewer/SKILL.md +93 -0
- package/HR-Resource/engineering-engineering-codebase-onboarding-engineer/SKILL.md +190 -0
- package/HR-Resource/engineering-engineering-data-engineer/SKILL.md +323 -0
- package/HR-Resource/engineering-engineering-database-optimizer/SKILL.md +193 -0
- package/HR-Resource/engineering-engineering-devops-automator/SKILL.md +393 -0
- package/HR-Resource/engineering-engineering-email-intelligence-engineer/SKILL.md +370 -0
- package/HR-Resource/engineering-engineering-embedded-firmware-engineer/SKILL.md +190 -0
- package/HR-Resource/engineering-engineering-feishu-integration-developer/SKILL.md +615 -0
- package/HR-Resource/engineering-engineering-filament-optimization-specialist/SKILL.md +300 -0
- package/HR-Resource/engineering-engineering-frontend-developer/SKILL.md +242 -0
- package/HR-Resource/engineering-engineering-git-workflow-master/SKILL.md +101 -0
- package/HR-Resource/engineering-engineering-incident-response-commander/SKILL.md +461 -0
- package/HR-Resource/engineering-engineering-minimal-change-engineer/SKILL.md +224 -0
- package/HR-Resource/engineering-engineering-mobile-app-builder/SKILL.md +510 -0
- package/HR-Resource/engineering-engineering-rapid-prototyper/SKILL.md +479 -0
- package/HR-Resource/engineering-engineering-security-engineer/SKILL.md +321 -0
- package/HR-Resource/engineering-engineering-senior-developer/SKILL.md +193 -0
- package/HR-Resource/engineering-engineering-software-architect/SKILL.md +98 -0
- package/HR-Resource/engineering-engineering-solidity-smart-contract-engineer/SKILL.md +539 -0
- package/HR-Resource/engineering-engineering-sre/SKILL.md +107 -0
- package/HR-Resource/engineering-engineering-technical-writer/SKILL.md +410 -0
- package/HR-Resource/engineering-engineering-threat-detection-engineer/SKILL.md +551 -0
- package/HR-Resource/engineering-engineering-voice-ai-integration-engineer/SKILL.md +578 -0
- package/HR-Resource/engineering-engineering-wechat-mini-program-developer/SKILL.md +367 -0
- package/HR-Resource/finance-finance-bookkeeper-controller/SKILL.md +277 -0
- package/HR-Resource/finance-finance-financial-analyst/SKILL.md +251 -0
- package/HR-Resource/finance-finance-fpa-analyst/SKILL.md +280 -0
- package/HR-Resource/finance-finance-investment-researcher/SKILL.md +289 -0
- package/HR-Resource/finance-finance-tax-strategist/SKILL.md +256 -0
- package/HR-Resource/game-development-blender-blender-addon-engineer/SKILL.md +251 -0
- package/HR-Resource/game-development-game-audio-engineer/SKILL.md +281 -0
- package/HR-Resource/game-development-game-designer/SKILL.md +184 -0
- package/HR-Resource/game-development-godot-godot-gameplay-scripter/SKILL.md +351 -0
- package/HR-Resource/game-development-godot-godot-multiplayer-engineer/SKILL.md +314 -0
- package/HR-Resource/game-development-godot-godot-shader-developer/SKILL.md +283 -0
- package/HR-Resource/game-development-level-designer/SKILL.md +225 -0
- package/HR-Resource/game-development-narrative-designer/SKILL.md +260 -0
- package/HR-Resource/game-development-roblox-studio-roblox-avatar-creator/SKILL.md +314 -0
- package/HR-Resource/game-development-roblox-studio-roblox-experience-designer/SKILL.md +322 -0
- package/HR-Resource/game-development-roblox-studio-roblox-systems-scripter/SKILL.md +342 -0
- package/HR-Resource/game-development-technical-artist/SKILL.md +246 -0
- package/HR-Resource/game-development-unity-unity-architect/SKILL.md +288 -0
- package/HR-Resource/game-development-unity-unity-editor-tool-developer/SKILL.md +327 -0
- package/HR-Resource/game-development-unity-unity-multiplayer-engineer/SKILL.md +338 -0
- package/HR-Resource/game-development-unity-unity-shader-graph-artist/SKILL.md +286 -0
- package/HR-Resource/game-development-unreal-engine-unreal-multiplayer-architect/SKILL.md +330 -0
- package/HR-Resource/game-development-unreal-engine-unreal-systems-engineer/SKILL.md +327 -0
- package/HR-Resource/game-development-unreal-engine-unreal-technical-artist/SKILL.md +273 -0
- package/HR-Resource/game-development-unreal-engine-unreal-world-builder/SKILL.md +290 -0
- package/HR-Resource/hiring/SKILL.md +28 -0
- package/HR-Resource/index.json +747 -0
- package/HR-Resource/integrations-mcp-memory-backend-architect-with-memory/SKILL.md +264 -0
- package/HR-Resource/marketing-marketing-agentic-search-optimizer/SKILL.md +328 -0
- package/HR-Resource/marketing-marketing-ai-citation-strategist/SKILL.md +187 -0
- package/HR-Resource/marketing-marketing-app-store-optimizer/SKILL.md +338 -0
- package/HR-Resource/marketing-marketing-baidu-seo-specialist/SKILL.md +243 -0
- package/HR-Resource/marketing-marketing-bilibili-content-strategist/SKILL.md +216 -0
- package/HR-Resource/marketing-marketing-book-co-author/SKILL.md +127 -0
- package/HR-Resource/marketing-marketing-carousel-growth-engine/SKILL.md +216 -0
- package/HR-Resource/marketing-marketing-china-ecommerce-operator/SKILL.md +300 -0
- package/HR-Resource/marketing-marketing-china-market-localization-strategist/SKILL.md +300 -0
- package/HR-Resource/marketing-marketing-content-creator/SKILL.md +71 -0
- package/HR-Resource/marketing-marketing-cross-border-ecommerce/SKILL.md +276 -0
- package/HR-Resource/marketing-marketing-douyin-strategist/SKILL.md +166 -0
- package/HR-Resource/marketing-marketing-growth-hacker/SKILL.md +71 -0
- package/HR-Resource/marketing-marketing-instagram-curator/SKILL.md +130 -0
- package/HR-Resource/marketing-marketing-kuaishou-strategist/SKILL.md +240 -0
- package/HR-Resource/marketing-marketing-linkedin-content-creator/SKILL.md +230 -0
- package/HR-Resource/marketing-marketing-livestream-commerce-coach/SKILL.md +322 -0
- package/HR-Resource/marketing-marketing-podcast-strategist/SKILL.md +294 -0
- package/HR-Resource/marketing-marketing-private-domain-operator/SKILL.md +325 -0
- package/HR-Resource/marketing-marketing-reddit-community-builder/SKILL.md +140 -0
- package/HR-Resource/marketing-marketing-seo-specialist/SKILL.md +338 -0
- package/HR-Resource/marketing-marketing-short-video-editing-coach/SKILL.md +429 -0
- package/HR-Resource/marketing-marketing-social-media-strategist/SKILL.md +142 -0
- package/HR-Resource/marketing-marketing-tiktok-strategist/SKILL.md +142 -0
- package/HR-Resource/marketing-marketing-twitter-engager/SKILL.md +143 -0
- package/HR-Resource/marketing-marketing-video-optimization-specialist/SKILL.md +136 -0
- package/HR-Resource/marketing-marketing-wechat-official-account/SKILL.md +162 -0
- package/HR-Resource/marketing-marketing-weibo-strategist/SKILL.md +257 -0
- package/HR-Resource/marketing-marketing-xiaohongshu-specialist/SKILL.md +155 -0
- package/HR-Resource/marketing-marketing-zhihu-strategist/SKILL.md +179 -0
- package/HR-Resource/ops/SKILL.md +46 -0
- package/HR-Resource/paid-media-paid-media-auditor/SKILL.md +88 -0
- package/HR-Resource/paid-media-paid-media-creative-strategist/SKILL.md +88 -0
- package/HR-Resource/paid-media-paid-media-paid-social-strategist/SKILL.md +88 -0
- package/HR-Resource/paid-media-paid-media-ppc-strategist/SKILL.md +88 -0
- package/HR-Resource/paid-media-paid-media-programmatic-buyer/SKILL.md +88 -0
- package/HR-Resource/paid-media-paid-media-search-query-analyst/SKILL.md +88 -0
- package/HR-Resource/paid-media-paid-media-tracking-specialist/SKILL.md +88 -0
- package/HR-Resource/product-product-behavioral-nudge-engine/SKILL.md +97 -0
- package/HR-Resource/product-product-feedback-synthesizer/SKILL.md +136 -0
- package/HR-Resource/product-product-manager/SKILL.md +486 -0
- package/HR-Resource/product-product-sprint-prioritizer/SKILL.md +171 -0
- package/HR-Resource/product-product-trend-researcher/SKILL.md +176 -0
- package/HR-Resource/project-management-project-management-experiment-tracker/SKILL.md +215 -0
- package/HR-Resource/project-management-project-management-jira-workflow-steward/SKILL.md +247 -0
- package/HR-Resource/project-management-project-management-project-shepherd/SKILL.md +211 -0
- package/HR-Resource/project-management-project-management-studio-operations/SKILL.md +217 -0
- package/HR-Resource/project-management-project-management-studio-producer/SKILL.md +220 -0
- package/HR-Resource/project-management-project-manager-senior/SKILL.md +152 -0
- package/HR-Resource/resource-manager/SKILL.md +23 -0
- package/HR-Resource/sales-sales-account-strategist/SKILL.md +244 -0
- package/HR-Resource/sales-sales-coach/SKILL.md +288 -0
- package/HR-Resource/sales-sales-deal-strategist/SKILL.md +197 -0
- package/HR-Resource/sales-sales-discovery-coach/SKILL.md +242 -0
- package/HR-Resource/sales-sales-engineer/SKILL.md +199 -0
- package/HR-Resource/sales-sales-outbound-strategist/SKILL.md +218 -0
- package/HR-Resource/sales-sales-pipeline-analyst/SKILL.md +284 -0
- package/HR-Resource/sales-sales-proposal-strategist/SKILL.md +234 -0
- package/HR-Resource/spatial-computing-macos-spatial-metal-engineer/SKILL.md +354 -0
- package/HR-Resource/spatial-computing-terminal-integration-specialist/SKILL.md +87 -0
- package/HR-Resource/spatial-computing-visionos-spatial-engineer/SKILL.md +71 -0
- package/HR-Resource/spatial-computing-xr-cockpit-interaction-specialist/SKILL.md +49 -0
- package/HR-Resource/spatial-computing-xr-immersive-developer/SKILL.md +49 -0
- package/HR-Resource/spatial-computing-xr-interface-architect/SKILL.md +49 -0
- package/HR-Resource/specialized-accounts-payable-agent/SKILL.md +202 -0
- package/HR-Resource/specialized-agentic-identity-trust/SKILL.md +404 -0
- package/HR-Resource/specialized-agents-orchestrator/SKILL.md +384 -0
- package/HR-Resource/specialized-automation-governance-architect/SKILL.md +233 -0
- package/HR-Resource/specialized-blockchain-security-auditor/SKILL.md +480 -0
- package/HR-Resource/specialized-compliance-auditor/SKILL.md +175 -0
- package/HR-Resource/specialized-corporate-training-designer/SKILL.md +209 -0
- package/HR-Resource/specialized-customer-service/SKILL.md +415 -0
- package/HR-Resource/specialized-data-consolidation-agent/SKILL.md +77 -0
- package/HR-Resource/specialized-government-digital-presales-consultant/SKILL.md +380 -0
- package/HR-Resource/specialized-healthcare-customer-service/SKILL.md +406 -0
- package/HR-Resource/specialized-healthcare-marketing-compliance/SKILL.md +412 -0
- package/HR-Resource/specialized-hospitality-guest-services/SKILL.md +620 -0
- package/HR-Resource/specialized-hr-onboarding/SKILL.md +468 -0
- package/HR-Resource/specialized-identity-graph-operator/SKILL.md +277 -0
- package/HR-Resource/specialized-language-translator/SKILL.md +281 -0
- package/HR-Resource/specialized-legal-billing-time-tracking/SKILL.md +586 -0
- package/HR-Resource/specialized-legal-client-intake/SKILL.md +509 -0
- package/HR-Resource/specialized-legal-document-review/SKILL.md +471 -0
- package/HR-Resource/specialized-loan-officer-assistant/SKILL.md +572 -0
- package/HR-Resource/specialized-lsp-index-engineer/SKILL.md +331 -0
- package/HR-Resource/specialized-real-estate-buyer-seller/SKILL.md +613 -0
- package/HR-Resource/specialized-recruitment-specialist/SKILL.md +526 -0
- package/HR-Resource/specialized-report-distribution-agent/SKILL.md +82 -0
- package/HR-Resource/specialized-retail-customer-returns/SKILL.md +583 -0
- package/HR-Resource/specialized-sales-data-extraction-agent/SKILL.md +84 -0
- package/HR-Resource/specialized-sales-outreach/SKILL.md +442 -0
- package/HR-Resource/specialized-specialized-chief-of-staff/SKILL.md +296 -0
- package/HR-Resource/specialized-specialized-civil-engineer/SKILL.md +373 -0
- package/HR-Resource/specialized-specialized-cultural-intelligence-strategist/SKILL.md +105 -0
- package/HR-Resource/specialized-specialized-developer-advocate/SKILL.md +334 -0
- package/HR-Resource/specialized-specialized-document-generator/SKILL.md +72 -0
- package/HR-Resource/specialized-specialized-french-consulting-market/SKILL.md +209 -0
- package/HR-Resource/specialized-specialized-korean-business-navigator/SKILL.md +233 -0
- package/HR-Resource/specialized-specialized-mcp-builder/SKILL.md +265 -0
- package/HR-Resource/specialized-specialized-model-qa/SKILL.md +505 -0
- package/HR-Resource/specialized-specialized-salesforce-architect/SKILL.md +197 -0
- package/HR-Resource/specialized-specialized-workflow-architect/SKILL.md +614 -0
- package/HR-Resource/specialized-study-abroad-advisor/SKILL.md +299 -0
- package/HR-Resource/specialized-supply-chain-strategist/SKILL.md +599 -0
- package/HR-Resource/specialized-zk-steward/SKILL.md +228 -0
- package/HR-Resource/support-support-analytics-reporter/SKILL.md +382 -0
- package/HR-Resource/support-support-executive-summary-generator/SKILL.md +229 -0
- package/HR-Resource/support-support-finance-tracker/SKILL.md +459 -0
- package/HR-Resource/support-support-infrastructure-maintainer/SKILL.md +635 -0
- package/HR-Resource/support-support-legal-compliance-checker/SKILL.md +605 -0
- package/HR-Resource/support-support-support-responder/SKILL.md +602 -0
- package/HR-Resource/testing-testing-accessibility-auditor/SKILL.md +333 -0
- package/HR-Resource/testing-testing-api-tester/SKILL.md +323 -0
- package/HR-Resource/testing-testing-evidence-collector/SKILL.md +227 -0
- package/HR-Resource/testing-testing-performance-benchmarker/SKILL.md +285 -0
- package/HR-Resource/testing-testing-reality-checker/SKILL.md +253 -0
- package/HR-Resource/testing-testing-test-results-analyzer/SKILL.md +322 -0
- package/HR-Resource/testing-testing-tool-evaluator/SKILL.md +411 -0
- package/HR-Resource/testing-testing-workflow-optimizer/SKILL.md +467 -0
- package/assets/launchd/com.walwal.harness-wake.plist.template +1 -1
- package/assets/templates/company-pipeline-manifest.json +71 -0
- package/assets/templates/config.json +40 -2
- package/bin/init.js +208 -109
- package/commands/goal.md +25 -0
- package/commands/hot-fix.md +25 -0
- package/commands/play-harness.md +22 -0
- package/commands/release-harness.md +22 -0
- package/commands/stop-harness.md +21 -0
- package/conventions/README.md +14 -88
- package/conventions/brick-office.md +5 -0
- package/conventions/cdo.md +6 -0
- package/conventions/ceo.md +9 -0
- package/conventions/coo.md +6 -0
- package/conventions/cqo.md +6 -23
- package/conventions/cto.md +5 -23
- package/conventions/hiring.md +7 -0
- package/conventions/ops.md +9 -0
- package/conventions/resource-manager.md +6 -0
- package/conventions/shared.md +29 -40
- package/gotchas/README.md +14 -82
- package/gotchas/brick-office.md +9 -0
- package/gotchas/cdo.md +9 -0
- package/gotchas/ceo.md +9 -0
- package/gotchas/coo.md +9 -0
- package/gotchas/cqo.md +6 -19
- package/gotchas/cto.md +6 -19
- package/gotchas/hiring.md +9 -0
- package/gotchas/ops.md +17 -0
- package/gotchas/resource-manager.md +9 -0
- package/gotchas/shared.md +13 -0
- package/package.json +11 -17
- package/scripts/conductor-tick.sh +97 -4
- package/scripts/harness-hourly-review.sh +284 -5
- package/scripts/harness-parity-audit.sh +101 -0
- package/scripts/harness-queue-manager.sh +1 -1
- package/scripts/harness-runtime-stop.sh +58 -0
- package/scripts/harness-service-ops-monitor.sh +207 -18
- package/scripts/harness-stop.sh +18 -0
- package/scripts/harness-wake-install.sh +1 -0
- package/scripts/harness-wake.sh +100 -8
- package/scripts/harness-worker-dispatch.sh +52 -21
- package/scripts/harness-worker-evidence-validate.sh +59 -0
- package/scripts/import-agency-agents.js +102 -0
- package/scripts/lib/harness-agent-resolver.sh +127 -0
- package/scripts/play.sh +104 -0
- package/scripts/release.sh +89 -0
- package/conventions/conductor.md +0 -24
- package/conventions/coo-developer.md +0 -24
- package/conventions/dispatcher.md +0 -24
- package/conventions/documentationer.md +0 -24
- package/conventions/evaluator-architecture.md +0 -24
- package/conventions/evaluator-code-quality.md +0 -24
- package/conventions/evaluator-functional.md +0 -24
- package/conventions/evaluator-security.md +0 -24
- package/conventions/evaluator-visual.md +0 -24
- package/conventions/generator-backend.md +0 -24
- package/conventions/generator-designer.md +0 -24
- package/conventions/generator-devops.md +0 -24
- package/conventions/generator-frontend.md +0 -24
- package/conventions/meeting-manager.md +0 -24
- package/conventions/planner.md +0 -24
- package/conventions/service-ops.md +0 -24
- package/gotchas/conductor.md +0 -38
- package/gotchas/coo-developer.md +0 -22
- package/gotchas/dispatcher.md +0 -38
- package/gotchas/documentationer.md +0 -22
- package/gotchas/evaluator-architecture.md +0 -22
- package/gotchas/evaluator-code-quality.md +0 -22
- package/gotchas/evaluator-functional.md +0 -22
- package/gotchas/evaluator-security.md +0 -22
- package/gotchas/evaluator-visual.md +0 -22
- package/gotchas/generator-backend-laravel.md +0 -19
- package/gotchas/generator-backend.md +0 -22
- package/gotchas/generator-designer.md +0 -22
- package/gotchas/generator-devops.md +0 -22
- package/gotchas/generator-frontend.md +0 -22
- package/gotchas/meeting-manager.md +0 -30
- package/gotchas/planner.md +0 -22
- package/gotchas/service-ops.md +0 -30
- package/skills/_shared/dynamic-registration.md +0 -120
- package/skills/brainstorming/SKILL.md +0 -220
- package/skills/brainstorming/references/attribution.md +0 -109
- package/skills/brainstorming/references/spec-document-reviewer-prompt.md +0 -49
- package/skills/brainstorming/references/visual-companion.md +0 -287
- package/skills/brainstorming/scripts/frame-template.html +0 -214
- package/skills/brainstorming/scripts/helper.js +0 -88
- package/skills/brainstorming/scripts/server.cjs +0 -354
- package/skills/brainstorming/scripts/start-server.sh +0 -148
- package/skills/brainstorming/scripts/stop-server.sh +0 -56
- package/skills/conductor/SKILL.md +0 -336
- package/skills/coo-developer/SKILL.md +0 -72
- package/skills/cqo/SKILL.md +0 -146
- package/skills/cto/SKILL.md +0 -141
- package/skills/dispatcher/SKILL.md +0 -298
- package/skills/dispatcher/persona-ceo.md +0 -169
- package/skills/dispatcher/references/convention-flow.md +0 -111
- package/skills/dispatcher/references/gotcha-flow.md +0 -79
- package/skills/dispatcher/references/initialization.md +0 -53
- package/skills/dispatcher/references/pipeline-definitions.md +0 -151
- package/skills/documentationer/SKILL.md +0 -92
- package/skills/evaluator-architecture/SKILL.md +0 -173
- package/skills/evaluator-code-quality/SKILL.md +0 -218
- package/skills/evaluator-code-quality/references/scoring-rubric.md +0 -104
- package/skills/evaluator-functional/SKILL.md +0 -271
- package/skills/evaluator-functional/references/ia-compliance.md +0 -37
- package/skills/evaluator-functional/references/playwright-tools.md +0 -43
- package/skills/evaluator-functional/references/scoring-rubric.md +0 -52
- package/skills/evaluator-security/SKILL.md +0 -172
- package/skills/evaluator-visual/SKILL.md +0 -165
- package/skills/evaluator-visual/references/responsive-checklist.md +0 -44
- package/skills/evaluator-visual/references/scoring-rubric.md +0 -59
- package/skills/generator-backend/SKILL.md +0 -153
- package/skills/generator-backend/references/nestjs-msa-patterns.md +0 -69
- package/skills/generator-backend/references/sprint-contract-be.md +0 -32
- package/skills/generator-designer/SKILL.md +0 -219
- package/skills/generator-devops/SKILL.md +0 -201
- package/skills/generator-frontend/SKILL.md +0 -155
- package/skills/generator-frontend/references/_web-react-legacy/ai-forbidden-patterns.md +0 -89
- package/skills/generator-frontend/references/_web-react-legacy/component-patterns.md +0 -52
- package/skills/generator-frontend/references/_web-react-legacy/design-system-rules.md +0 -139
- package/skills/generator-frontend/references/_web-react-legacy/vercel-best-practices.md +0 -54
- package/skills/meeting-manager/SKILL.md +0 -419
- package/skills/planner/SKILL.md +0 -243
- package/skills/planner/hr-onboard.md +0 -134
- package/skills/planner/hr-recruit.md +0 -99
- package/skills/planner/persona-coo-hr.md +0 -182
- package/skills/planner/references/api-contract-schema.md +0 -34
- package/skills/planner/references/fe-stack-detection.md +0 -164
- package/skills/planner/references/ia-map-guide.md +0 -31
- package/skills/planner/references/plan-template.md +0 -51
- package/skills/service-ops/SKILL.md +0 -295
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<title>Superpowers Brainstorming</title>
|
|
6
|
-
<style>
|
|
7
|
-
/*
|
|
8
|
-
* BRAINSTORM COMPANION FRAME TEMPLATE
|
|
9
|
-
*
|
|
10
|
-
* This template provides a consistent frame with:
|
|
11
|
-
* - OS-aware light/dark theming
|
|
12
|
-
* - Fixed header and selection indicator bar
|
|
13
|
-
* - Scrollable main content area
|
|
14
|
-
* - CSS helpers for common UI patterns
|
|
15
|
-
*
|
|
16
|
-
* Content is injected via placeholder comment in #claude-content.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
20
|
-
html, body { height: 100%; overflow: hidden; }
|
|
21
|
-
|
|
22
|
-
/* ===== THEME VARIABLES ===== */
|
|
23
|
-
:root {
|
|
24
|
-
--bg-primary: #f5f5f7;
|
|
25
|
-
--bg-secondary: #ffffff;
|
|
26
|
-
--bg-tertiary: #e5e5e7;
|
|
27
|
-
--border: #d1d1d6;
|
|
28
|
-
--text-primary: #1d1d1f;
|
|
29
|
-
--text-secondary: #86868b;
|
|
30
|
-
--text-tertiary: #aeaeb2;
|
|
31
|
-
--accent: #0071e3;
|
|
32
|
-
--accent-hover: #0077ed;
|
|
33
|
-
--success: #34c759;
|
|
34
|
-
--warning: #ff9f0a;
|
|
35
|
-
--error: #ff3b30;
|
|
36
|
-
--selected-bg: #e8f4fd;
|
|
37
|
-
--selected-border: #0071e3;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@media (prefers-color-scheme: dark) {
|
|
41
|
-
:root {
|
|
42
|
-
--bg-primary: #1d1d1f;
|
|
43
|
-
--bg-secondary: #2d2d2f;
|
|
44
|
-
--bg-tertiary: #3d3d3f;
|
|
45
|
-
--border: #424245;
|
|
46
|
-
--text-primary: #f5f5f7;
|
|
47
|
-
--text-secondary: #86868b;
|
|
48
|
-
--text-tertiary: #636366;
|
|
49
|
-
--accent: #0a84ff;
|
|
50
|
-
--accent-hover: #409cff;
|
|
51
|
-
--selected-bg: rgba(10, 132, 255, 0.15);
|
|
52
|
-
--selected-border: #0a84ff;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
body {
|
|
57
|
-
font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
|
|
58
|
-
background: var(--bg-primary);
|
|
59
|
-
color: var(--text-primary);
|
|
60
|
-
display: flex;
|
|
61
|
-
flex-direction: column;
|
|
62
|
-
line-height: 1.5;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/* ===== FRAME STRUCTURE ===== */
|
|
66
|
-
.header {
|
|
67
|
-
background: var(--bg-secondary);
|
|
68
|
-
padding: 0.5rem 1.5rem;
|
|
69
|
-
display: flex;
|
|
70
|
-
justify-content: space-between;
|
|
71
|
-
align-items: center;
|
|
72
|
-
border-bottom: 1px solid var(--border);
|
|
73
|
-
flex-shrink: 0;
|
|
74
|
-
}
|
|
75
|
-
.header h1 { font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); }
|
|
76
|
-
.header .status { font-size: 0.7rem; color: var(--success); display: flex; align-items: center; gap: 0.4rem; }
|
|
77
|
-
.header .status::before { content: ''; width: 6px; height: 6px; background: var(--success); border-radius: 50%; }
|
|
78
|
-
|
|
79
|
-
.main { flex: 1; overflow-y: auto; }
|
|
80
|
-
#claude-content { padding: 2rem; min-height: 100%; }
|
|
81
|
-
|
|
82
|
-
.indicator-bar {
|
|
83
|
-
background: var(--bg-secondary);
|
|
84
|
-
border-top: 1px solid var(--border);
|
|
85
|
-
padding: 0.5rem 1.5rem;
|
|
86
|
-
flex-shrink: 0;
|
|
87
|
-
text-align: center;
|
|
88
|
-
}
|
|
89
|
-
.indicator-bar span {
|
|
90
|
-
font-size: 0.75rem;
|
|
91
|
-
color: var(--text-secondary);
|
|
92
|
-
}
|
|
93
|
-
.indicator-bar .selected-text {
|
|
94
|
-
color: var(--accent);
|
|
95
|
-
font-weight: 500;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/* ===== TYPOGRAPHY ===== */
|
|
99
|
-
h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.5rem; }
|
|
100
|
-
h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.25rem; }
|
|
101
|
-
.subtitle { color: var(--text-secondary); margin-bottom: 1.5rem; }
|
|
102
|
-
.section { margin-bottom: 2rem; }
|
|
103
|
-
.label { font-size: 0.7rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
|
|
104
|
-
|
|
105
|
-
/* ===== OPTIONS (for A/B/C choices) ===== */
|
|
106
|
-
.options { display: flex; flex-direction: column; gap: 0.75rem; }
|
|
107
|
-
.option {
|
|
108
|
-
background: var(--bg-secondary);
|
|
109
|
-
border: 2px solid var(--border);
|
|
110
|
-
border-radius: 12px;
|
|
111
|
-
padding: 1rem 1.25rem;
|
|
112
|
-
cursor: pointer;
|
|
113
|
-
transition: all 0.15s ease;
|
|
114
|
-
display: flex;
|
|
115
|
-
align-items: flex-start;
|
|
116
|
-
gap: 1rem;
|
|
117
|
-
}
|
|
118
|
-
.option:hover { border-color: var(--accent); }
|
|
119
|
-
.option.selected { background: var(--selected-bg); border-color: var(--selected-border); }
|
|
120
|
-
.option .letter {
|
|
121
|
-
background: var(--bg-tertiary);
|
|
122
|
-
color: var(--text-secondary);
|
|
123
|
-
width: 1.75rem; height: 1.75rem;
|
|
124
|
-
border-radius: 6px;
|
|
125
|
-
display: flex; align-items: center; justify-content: center;
|
|
126
|
-
font-weight: 600; font-size: 0.85rem; flex-shrink: 0;
|
|
127
|
-
}
|
|
128
|
-
.option.selected .letter { background: var(--accent); color: white; }
|
|
129
|
-
.option .content { flex: 1; }
|
|
130
|
-
.option .content h3 { font-size: 0.95rem; margin-bottom: 0.15rem; }
|
|
131
|
-
.option .content p { color: var(--text-secondary); font-size: 0.85rem; margin: 0; }
|
|
132
|
-
|
|
133
|
-
/* ===== CARDS (for showing designs/mockups) ===== */
|
|
134
|
-
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
|
|
135
|
-
.card {
|
|
136
|
-
background: var(--bg-secondary);
|
|
137
|
-
border: 1px solid var(--border);
|
|
138
|
-
border-radius: 12px;
|
|
139
|
-
overflow: hidden;
|
|
140
|
-
cursor: pointer;
|
|
141
|
-
transition: all 0.15s ease;
|
|
142
|
-
}
|
|
143
|
-
.card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
|
|
144
|
-
.card.selected { border-color: var(--selected-border); border-width: 2px; }
|
|
145
|
-
.card-image { background: var(--bg-tertiary); aspect-ratio: 16/10; display: flex; align-items: center; justify-content: center; }
|
|
146
|
-
.card-body { padding: 1rem; }
|
|
147
|
-
.card-body h3 { margin-bottom: 0.25rem; }
|
|
148
|
-
.card-body p { color: var(--text-secondary); font-size: 0.85rem; }
|
|
149
|
-
|
|
150
|
-
/* ===== MOCKUP CONTAINER ===== */
|
|
151
|
-
.mockup {
|
|
152
|
-
background: var(--bg-secondary);
|
|
153
|
-
border: 1px solid var(--border);
|
|
154
|
-
border-radius: 12px;
|
|
155
|
-
overflow: hidden;
|
|
156
|
-
margin-bottom: 1.5rem;
|
|
157
|
-
}
|
|
158
|
-
.mockup-header {
|
|
159
|
-
background: var(--bg-tertiary);
|
|
160
|
-
padding: 0.5rem 1rem;
|
|
161
|
-
font-size: 0.75rem;
|
|
162
|
-
color: var(--text-secondary);
|
|
163
|
-
border-bottom: 1px solid var(--border);
|
|
164
|
-
}
|
|
165
|
-
.mockup-body { padding: 1.5rem; }
|
|
166
|
-
|
|
167
|
-
/* ===== SPLIT VIEW (side-by-side comparison) ===== */
|
|
168
|
-
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
|
|
169
|
-
@media (max-width: 700px) { .split { grid-template-columns: 1fr; } }
|
|
170
|
-
|
|
171
|
-
/* ===== PROS/CONS ===== */
|
|
172
|
-
.pros-cons { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1rem 0; }
|
|
173
|
-
.pros, .cons { background: var(--bg-secondary); border-radius: 8px; padding: 1rem; }
|
|
174
|
-
.pros h4 { color: var(--success); font-size: 0.85rem; margin-bottom: 0.5rem; }
|
|
175
|
-
.cons h4 { color: var(--error); font-size: 0.85rem; margin-bottom: 0.5rem; }
|
|
176
|
-
.pros ul, .cons ul { margin-left: 1.25rem; font-size: 0.85rem; color: var(--text-secondary); }
|
|
177
|
-
.pros li, .cons li { margin-bottom: 0.25rem; }
|
|
178
|
-
|
|
179
|
-
/* ===== PLACEHOLDER (for mockup areas) ===== */
|
|
180
|
-
.placeholder {
|
|
181
|
-
background: var(--bg-tertiary);
|
|
182
|
-
border: 2px dashed var(--border);
|
|
183
|
-
border-radius: 8px;
|
|
184
|
-
padding: 2rem;
|
|
185
|
-
text-align: center;
|
|
186
|
-
color: var(--text-tertiary);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/* ===== INLINE MOCKUP ELEMENTS ===== */
|
|
190
|
-
.mock-nav { background: var(--accent); color: white; padding: 0.75rem 1rem; display: flex; gap: 1.5rem; font-size: 0.9rem; }
|
|
191
|
-
.mock-sidebar { background: var(--bg-tertiary); padding: 1rem; min-width: 180px; }
|
|
192
|
-
.mock-content { padding: 1.5rem; flex: 1; }
|
|
193
|
-
.mock-button { background: var(--accent); color: white; border: none; padding: 0.5rem 1rem; border-radius: 6px; font-size: 0.85rem; }
|
|
194
|
-
.mock-input { background: var(--bg-primary); border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem; width: 100%; }
|
|
195
|
-
</style>
|
|
196
|
-
</head>
|
|
197
|
-
<body>
|
|
198
|
-
<div class="header">
|
|
199
|
-
<h1><a href="https://github.com/obra/superpowers" style="color: inherit; text-decoration: none;">Superpowers Brainstorming</a></h1>
|
|
200
|
-
<div class="status">Connected</div>
|
|
201
|
-
</div>
|
|
202
|
-
|
|
203
|
-
<div class="main">
|
|
204
|
-
<div id="claude-content">
|
|
205
|
-
<!-- CONTENT -->
|
|
206
|
-
</div>
|
|
207
|
-
</div>
|
|
208
|
-
|
|
209
|
-
<div class="indicator-bar">
|
|
210
|
-
<span id="indicator-text">Click an option above, then return to the terminal</span>
|
|
211
|
-
</div>
|
|
212
|
-
|
|
213
|
-
</body>
|
|
214
|
-
</html>
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
(function() {
|
|
2
|
-
const WS_URL = 'ws://' + window.location.host;
|
|
3
|
-
let ws = null;
|
|
4
|
-
let eventQueue = [];
|
|
5
|
-
|
|
6
|
-
function connect() {
|
|
7
|
-
ws = new WebSocket(WS_URL);
|
|
8
|
-
|
|
9
|
-
ws.onopen = () => {
|
|
10
|
-
eventQueue.forEach(e => ws.send(JSON.stringify(e)));
|
|
11
|
-
eventQueue = [];
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
ws.onmessage = (msg) => {
|
|
15
|
-
const data = JSON.parse(msg.data);
|
|
16
|
-
if (data.type === 'reload') {
|
|
17
|
-
window.location.reload();
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
ws.onclose = () => {
|
|
22
|
-
setTimeout(connect, 1000);
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function sendEvent(event) {
|
|
27
|
-
event.timestamp = Date.now();
|
|
28
|
-
if (ws && ws.readyState === WebSocket.OPEN) {
|
|
29
|
-
ws.send(JSON.stringify(event));
|
|
30
|
-
} else {
|
|
31
|
-
eventQueue.push(event);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Capture clicks on choice elements
|
|
36
|
-
document.addEventListener('click', (e) => {
|
|
37
|
-
const target = e.target.closest('[data-choice]');
|
|
38
|
-
if (!target) return;
|
|
39
|
-
|
|
40
|
-
sendEvent({
|
|
41
|
-
type: 'click',
|
|
42
|
-
text: target.textContent.trim(),
|
|
43
|
-
choice: target.dataset.choice,
|
|
44
|
-
id: target.id || null
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// Update indicator bar (defer so toggleSelect runs first)
|
|
48
|
-
setTimeout(() => {
|
|
49
|
-
const indicator = document.getElementById('indicator-text');
|
|
50
|
-
if (!indicator) return;
|
|
51
|
-
const container = target.closest('.options') || target.closest('.cards');
|
|
52
|
-
const selected = container ? container.querySelectorAll('.selected') : [];
|
|
53
|
-
if (selected.length === 0) {
|
|
54
|
-
indicator.textContent = 'Click an option above, then return to the terminal';
|
|
55
|
-
} else if (selected.length === 1) {
|
|
56
|
-
const label = selected[0].querySelector('h3, .content h3, .card-body h3')?.textContent?.trim() || selected[0].dataset.choice;
|
|
57
|
-
indicator.innerHTML = '<span class="selected-text">' + label + ' selected</span> — return to terminal to continue';
|
|
58
|
-
} else {
|
|
59
|
-
indicator.innerHTML = '<span class="selected-text">' + selected.length + ' selected</span> — return to terminal to continue';
|
|
60
|
-
}
|
|
61
|
-
}, 0);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// Frame UI: selection tracking
|
|
65
|
-
window.selectedChoice = null;
|
|
66
|
-
|
|
67
|
-
window.toggleSelect = function(el) {
|
|
68
|
-
const container = el.closest('.options') || el.closest('.cards');
|
|
69
|
-
const multi = container && container.dataset.multiselect !== undefined;
|
|
70
|
-
if (container && !multi) {
|
|
71
|
-
container.querySelectorAll('.option, .card').forEach(o => o.classList.remove('selected'));
|
|
72
|
-
}
|
|
73
|
-
if (multi) {
|
|
74
|
-
el.classList.toggle('selected');
|
|
75
|
-
} else {
|
|
76
|
-
el.classList.add('selected');
|
|
77
|
-
}
|
|
78
|
-
window.selectedChoice = el.dataset.choice;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// Expose API for explicit use
|
|
82
|
-
window.brainstorm = {
|
|
83
|
-
send: sendEvent,
|
|
84
|
-
choice: (value, metadata = {}) => sendEvent({ type: 'choice', value, ...metadata })
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
connect();
|
|
88
|
-
})();
|
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
const crypto = require('crypto');
|
|
2
|
-
const http = require('http');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
|
|
6
|
-
// ========== WebSocket Protocol (RFC 6455) ==========
|
|
7
|
-
|
|
8
|
-
const OPCODES = { TEXT: 0x01, CLOSE: 0x08, PING: 0x09, PONG: 0x0A };
|
|
9
|
-
const WS_MAGIC = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';
|
|
10
|
-
|
|
11
|
-
function computeAcceptKey(clientKey) {
|
|
12
|
-
return crypto.createHash('sha1').update(clientKey + WS_MAGIC).digest('base64');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function encodeFrame(opcode, payload) {
|
|
16
|
-
const fin = 0x80;
|
|
17
|
-
const len = payload.length;
|
|
18
|
-
let header;
|
|
19
|
-
|
|
20
|
-
if (len < 126) {
|
|
21
|
-
header = Buffer.alloc(2);
|
|
22
|
-
header[0] = fin | opcode;
|
|
23
|
-
header[1] = len;
|
|
24
|
-
} else if (len < 65536) {
|
|
25
|
-
header = Buffer.alloc(4);
|
|
26
|
-
header[0] = fin | opcode;
|
|
27
|
-
header[1] = 126;
|
|
28
|
-
header.writeUInt16BE(len, 2);
|
|
29
|
-
} else {
|
|
30
|
-
header = Buffer.alloc(10);
|
|
31
|
-
header[0] = fin | opcode;
|
|
32
|
-
header[1] = 127;
|
|
33
|
-
header.writeBigUInt64BE(BigInt(len), 2);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return Buffer.concat([header, payload]);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function decodeFrame(buffer) {
|
|
40
|
-
if (buffer.length < 2) return null;
|
|
41
|
-
|
|
42
|
-
const secondByte = buffer[1];
|
|
43
|
-
const opcode = buffer[0] & 0x0F;
|
|
44
|
-
const masked = (secondByte & 0x80) !== 0;
|
|
45
|
-
let payloadLen = secondByte & 0x7F;
|
|
46
|
-
let offset = 2;
|
|
47
|
-
|
|
48
|
-
if (!masked) throw new Error('Client frames must be masked');
|
|
49
|
-
|
|
50
|
-
if (payloadLen === 126) {
|
|
51
|
-
if (buffer.length < 4) return null;
|
|
52
|
-
payloadLen = buffer.readUInt16BE(2);
|
|
53
|
-
offset = 4;
|
|
54
|
-
} else if (payloadLen === 127) {
|
|
55
|
-
if (buffer.length < 10) return null;
|
|
56
|
-
payloadLen = Number(buffer.readBigUInt64BE(2));
|
|
57
|
-
offset = 10;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const maskOffset = offset;
|
|
61
|
-
const dataOffset = offset + 4;
|
|
62
|
-
const totalLen = dataOffset + payloadLen;
|
|
63
|
-
if (buffer.length < totalLen) return null;
|
|
64
|
-
|
|
65
|
-
const mask = buffer.slice(maskOffset, dataOffset);
|
|
66
|
-
const data = Buffer.alloc(payloadLen);
|
|
67
|
-
for (let i = 0; i < payloadLen; i++) {
|
|
68
|
-
data[i] = buffer[dataOffset + i] ^ mask[i % 4];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return { opcode, payload: data, bytesConsumed: totalLen };
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// ========== Configuration ==========
|
|
75
|
-
|
|
76
|
-
const PORT = process.env.BRAINSTORM_PORT || (49152 + Math.floor(Math.random() * 16383));
|
|
77
|
-
const HOST = process.env.BRAINSTORM_HOST || '127.0.0.1';
|
|
78
|
-
const URL_HOST = process.env.BRAINSTORM_URL_HOST || (HOST === '127.0.0.1' ? 'localhost' : HOST);
|
|
79
|
-
const SESSION_DIR = process.env.BRAINSTORM_DIR || '/tmp/brainstorm';
|
|
80
|
-
const CONTENT_DIR = path.join(SESSION_DIR, 'content');
|
|
81
|
-
const STATE_DIR = path.join(SESSION_DIR, 'state');
|
|
82
|
-
let ownerPid = process.env.BRAINSTORM_OWNER_PID ? Number(process.env.BRAINSTORM_OWNER_PID) : null;
|
|
83
|
-
|
|
84
|
-
const MIME_TYPES = {
|
|
85
|
-
'.html': 'text/html', '.css': 'text/css', '.js': 'application/javascript',
|
|
86
|
-
'.json': 'application/json', '.png': 'image/png', '.jpg': 'image/jpeg',
|
|
87
|
-
'.jpeg': 'image/jpeg', '.gif': 'image/gif', '.svg': 'image/svg+xml'
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// ========== Templates and Constants ==========
|
|
91
|
-
|
|
92
|
-
const WAITING_PAGE = `<!DOCTYPE html>
|
|
93
|
-
<html>
|
|
94
|
-
<head><meta charset="utf-8"><title>Brainstorm Companion</title>
|
|
95
|
-
<style>body { font-family: system-ui, sans-serif; padding: 2rem; max-width: 800px; margin: 0 auto; }
|
|
96
|
-
h1 { color: #333; } p { color: #666; }</style>
|
|
97
|
-
</head>
|
|
98
|
-
<body><h1>Brainstorm Companion</h1>
|
|
99
|
-
<p>Waiting for the agent to push a screen...</p></body></html>`;
|
|
100
|
-
|
|
101
|
-
const frameTemplate = fs.readFileSync(path.join(__dirname, 'frame-template.html'), 'utf-8');
|
|
102
|
-
const helperScript = fs.readFileSync(path.join(__dirname, 'helper.js'), 'utf-8');
|
|
103
|
-
const helperInjection = '<script>\n' + helperScript + '\n</script>';
|
|
104
|
-
|
|
105
|
-
// ========== Helper Functions ==========
|
|
106
|
-
|
|
107
|
-
function isFullDocument(html) {
|
|
108
|
-
const trimmed = html.trimStart().toLowerCase();
|
|
109
|
-
return trimmed.startsWith('<!doctype') || trimmed.startsWith('<html');
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function wrapInFrame(content) {
|
|
113
|
-
return frameTemplate.replace('<!-- CONTENT -->', content);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function getNewestScreen() {
|
|
117
|
-
const files = fs.readdirSync(CONTENT_DIR)
|
|
118
|
-
.filter(f => f.endsWith('.html'))
|
|
119
|
-
.map(f => {
|
|
120
|
-
const fp = path.join(CONTENT_DIR, f);
|
|
121
|
-
return { path: fp, mtime: fs.statSync(fp).mtime.getTime() };
|
|
122
|
-
})
|
|
123
|
-
.sort((a, b) => b.mtime - a.mtime);
|
|
124
|
-
return files.length > 0 ? files[0].path : null;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// ========== HTTP Request Handler ==========
|
|
128
|
-
|
|
129
|
-
function handleRequest(req, res) {
|
|
130
|
-
touchActivity();
|
|
131
|
-
if (req.method === 'GET' && req.url === '/') {
|
|
132
|
-
const screenFile = getNewestScreen();
|
|
133
|
-
let html = screenFile
|
|
134
|
-
? (raw => isFullDocument(raw) ? raw : wrapInFrame(raw))(fs.readFileSync(screenFile, 'utf-8'))
|
|
135
|
-
: WAITING_PAGE;
|
|
136
|
-
|
|
137
|
-
if (html.includes('</body>')) {
|
|
138
|
-
html = html.replace('</body>', helperInjection + '\n</body>');
|
|
139
|
-
} else {
|
|
140
|
-
html += helperInjection;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
144
|
-
res.end(html);
|
|
145
|
-
} else if (req.method === 'GET' && req.url.startsWith('/files/')) {
|
|
146
|
-
const fileName = req.url.slice(7);
|
|
147
|
-
const filePath = path.join(CONTENT_DIR, path.basename(fileName));
|
|
148
|
-
if (!fs.existsSync(filePath)) {
|
|
149
|
-
res.writeHead(404);
|
|
150
|
-
res.end('Not found');
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
const ext = path.extname(filePath).toLowerCase();
|
|
154
|
-
const contentType = MIME_TYPES[ext] || 'application/octet-stream';
|
|
155
|
-
res.writeHead(200, { 'Content-Type': contentType });
|
|
156
|
-
res.end(fs.readFileSync(filePath));
|
|
157
|
-
} else {
|
|
158
|
-
res.writeHead(404);
|
|
159
|
-
res.end('Not found');
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// ========== WebSocket Connection Handling ==========
|
|
164
|
-
|
|
165
|
-
const clients = new Set();
|
|
166
|
-
|
|
167
|
-
function handleUpgrade(req, socket) {
|
|
168
|
-
const key = req.headers['sec-websocket-key'];
|
|
169
|
-
if (!key) { socket.destroy(); return; }
|
|
170
|
-
|
|
171
|
-
const accept = computeAcceptKey(key);
|
|
172
|
-
socket.write(
|
|
173
|
-
'HTTP/1.1 101 Switching Protocols\r\n' +
|
|
174
|
-
'Upgrade: websocket\r\n' +
|
|
175
|
-
'Connection: Upgrade\r\n' +
|
|
176
|
-
'Sec-WebSocket-Accept: ' + accept + '\r\n\r\n'
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
let buffer = Buffer.alloc(0);
|
|
180
|
-
clients.add(socket);
|
|
181
|
-
|
|
182
|
-
socket.on('data', (chunk) => {
|
|
183
|
-
buffer = Buffer.concat([buffer, chunk]);
|
|
184
|
-
while (buffer.length > 0) {
|
|
185
|
-
let result;
|
|
186
|
-
try {
|
|
187
|
-
result = decodeFrame(buffer);
|
|
188
|
-
} catch (e) {
|
|
189
|
-
socket.end(encodeFrame(OPCODES.CLOSE, Buffer.alloc(0)));
|
|
190
|
-
clients.delete(socket);
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
if (!result) break;
|
|
194
|
-
buffer = buffer.slice(result.bytesConsumed);
|
|
195
|
-
|
|
196
|
-
switch (result.opcode) {
|
|
197
|
-
case OPCODES.TEXT:
|
|
198
|
-
handleMessage(result.payload.toString());
|
|
199
|
-
break;
|
|
200
|
-
case OPCODES.CLOSE:
|
|
201
|
-
socket.end(encodeFrame(OPCODES.CLOSE, Buffer.alloc(0)));
|
|
202
|
-
clients.delete(socket);
|
|
203
|
-
return;
|
|
204
|
-
case OPCODES.PING:
|
|
205
|
-
socket.write(encodeFrame(OPCODES.PONG, result.payload));
|
|
206
|
-
break;
|
|
207
|
-
case OPCODES.PONG:
|
|
208
|
-
break;
|
|
209
|
-
default: {
|
|
210
|
-
const closeBuf = Buffer.alloc(2);
|
|
211
|
-
closeBuf.writeUInt16BE(1003);
|
|
212
|
-
socket.end(encodeFrame(OPCODES.CLOSE, closeBuf));
|
|
213
|
-
clients.delete(socket);
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
socket.on('close', () => clients.delete(socket));
|
|
221
|
-
socket.on('error', () => clients.delete(socket));
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function handleMessage(text) {
|
|
225
|
-
let event;
|
|
226
|
-
try {
|
|
227
|
-
event = JSON.parse(text);
|
|
228
|
-
} catch (e) {
|
|
229
|
-
console.error('Failed to parse WebSocket message:', e.message);
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
touchActivity();
|
|
233
|
-
console.log(JSON.stringify({ source: 'user-event', ...event }));
|
|
234
|
-
if (event.choice) {
|
|
235
|
-
const eventsFile = path.join(STATE_DIR, 'events');
|
|
236
|
-
fs.appendFileSync(eventsFile, JSON.stringify(event) + '\n');
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function broadcast(msg) {
|
|
241
|
-
const frame = encodeFrame(OPCODES.TEXT, Buffer.from(JSON.stringify(msg)));
|
|
242
|
-
for (const socket of clients) {
|
|
243
|
-
try { socket.write(frame); } catch (e) { clients.delete(socket); }
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// ========== Activity Tracking ==========
|
|
248
|
-
|
|
249
|
-
const IDLE_TIMEOUT_MS = 30 * 60 * 1000; // 30 minutes
|
|
250
|
-
let lastActivity = Date.now();
|
|
251
|
-
|
|
252
|
-
function touchActivity() {
|
|
253
|
-
lastActivity = Date.now();
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// ========== File Watching ==========
|
|
257
|
-
|
|
258
|
-
const debounceTimers = new Map();
|
|
259
|
-
|
|
260
|
-
// ========== Server Startup ==========
|
|
261
|
-
|
|
262
|
-
function startServer() {
|
|
263
|
-
if (!fs.existsSync(CONTENT_DIR)) fs.mkdirSync(CONTENT_DIR, { recursive: true });
|
|
264
|
-
if (!fs.existsSync(STATE_DIR)) fs.mkdirSync(STATE_DIR, { recursive: true });
|
|
265
|
-
|
|
266
|
-
// Track known files to distinguish new screens from updates.
|
|
267
|
-
// macOS fs.watch reports 'rename' for both new files and overwrites,
|
|
268
|
-
// so we can't rely on eventType alone.
|
|
269
|
-
const knownFiles = new Set(
|
|
270
|
-
fs.readdirSync(CONTENT_DIR).filter(f => f.endsWith('.html'))
|
|
271
|
-
);
|
|
272
|
-
|
|
273
|
-
const server = http.createServer(handleRequest);
|
|
274
|
-
server.on('upgrade', handleUpgrade);
|
|
275
|
-
|
|
276
|
-
const watcher = fs.watch(CONTENT_DIR, (eventType, filename) => {
|
|
277
|
-
if (!filename || !filename.endsWith('.html')) return;
|
|
278
|
-
|
|
279
|
-
if (debounceTimers.has(filename)) clearTimeout(debounceTimers.get(filename));
|
|
280
|
-
debounceTimers.set(filename, setTimeout(() => {
|
|
281
|
-
debounceTimers.delete(filename);
|
|
282
|
-
const filePath = path.join(CONTENT_DIR, filename);
|
|
283
|
-
|
|
284
|
-
if (!fs.existsSync(filePath)) return; // file was deleted
|
|
285
|
-
touchActivity();
|
|
286
|
-
|
|
287
|
-
if (!knownFiles.has(filename)) {
|
|
288
|
-
knownFiles.add(filename);
|
|
289
|
-
const eventsFile = path.join(STATE_DIR, 'events');
|
|
290
|
-
if (fs.existsSync(eventsFile)) fs.unlinkSync(eventsFile);
|
|
291
|
-
console.log(JSON.stringify({ type: 'screen-added', file: filePath }));
|
|
292
|
-
} else {
|
|
293
|
-
console.log(JSON.stringify({ type: 'screen-updated', file: filePath }));
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
broadcast({ type: 'reload' });
|
|
297
|
-
}, 100));
|
|
298
|
-
});
|
|
299
|
-
watcher.on('error', (err) => console.error('fs.watch error:', err.message));
|
|
300
|
-
|
|
301
|
-
function shutdown(reason) {
|
|
302
|
-
console.log(JSON.stringify({ type: 'server-stopped', reason }));
|
|
303
|
-
const infoFile = path.join(STATE_DIR, 'server-info');
|
|
304
|
-
if (fs.existsSync(infoFile)) fs.unlinkSync(infoFile);
|
|
305
|
-
fs.writeFileSync(
|
|
306
|
-
path.join(STATE_DIR, 'server-stopped'),
|
|
307
|
-
JSON.stringify({ reason, timestamp: Date.now() }) + '\n'
|
|
308
|
-
);
|
|
309
|
-
watcher.close();
|
|
310
|
-
clearInterval(lifecycleCheck);
|
|
311
|
-
server.close(() => process.exit(0));
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
function ownerAlive() {
|
|
315
|
-
if (!ownerPid) return true;
|
|
316
|
-
try { process.kill(ownerPid, 0); return true; } catch (e) { return e.code === 'EPERM'; }
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// Check every 60s: exit if owner process died or idle for 30 minutes
|
|
320
|
-
const lifecycleCheck = setInterval(() => {
|
|
321
|
-
if (!ownerAlive()) shutdown('owner process exited');
|
|
322
|
-
else if (Date.now() - lastActivity > IDLE_TIMEOUT_MS) shutdown('idle timeout');
|
|
323
|
-
}, 60 * 1000);
|
|
324
|
-
lifecycleCheck.unref();
|
|
325
|
-
|
|
326
|
-
// Validate owner PID at startup. If it's already dead, the PID resolution
|
|
327
|
-
// was wrong (common on WSL, Tailscale SSH, and cross-user scenarios).
|
|
328
|
-
// Disable monitoring and rely on the idle timeout instead.
|
|
329
|
-
if (ownerPid) {
|
|
330
|
-
try { process.kill(ownerPid, 0); }
|
|
331
|
-
catch (e) {
|
|
332
|
-
if (e.code !== 'EPERM') {
|
|
333
|
-
console.log(JSON.stringify({ type: 'owner-pid-invalid', pid: ownerPid, reason: 'dead at startup' }));
|
|
334
|
-
ownerPid = null;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
server.listen(PORT, HOST, () => {
|
|
340
|
-
const info = JSON.stringify({
|
|
341
|
-
type: 'server-started', port: Number(PORT), host: HOST,
|
|
342
|
-
url_host: URL_HOST, url: 'http://' + URL_HOST + ':' + PORT,
|
|
343
|
-
screen_dir: CONTENT_DIR, state_dir: STATE_DIR
|
|
344
|
-
});
|
|
345
|
-
console.log(info);
|
|
346
|
-
fs.writeFileSync(path.join(STATE_DIR, 'server-info'), info + '\n');
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
if (require.main === module) {
|
|
351
|
-
startServer();
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
module.exports = { computeAcceptKey, encodeFrame, decodeFrame, OPCODES };
|