claudecode-omc 4.8.2 → 4.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +3 -3
- package/README.de.md +60 -0
- package/README.es.md +60 -0
- package/README.fr.md +60 -0
- package/README.it.md +60 -0
- package/README.ja.md +60 -0
- package/README.ko.md +60 -0
- package/README.md +101 -16
- package/README.pt.md +60 -0
- package/README.ru.md +60 -0
- package/README.tr.md +60 -0
- package/README.vi.md +60 -0
- package/README.zh.md +60 -0
- package/agents/code-reviewer.md +107 -6
- package/agents/critic.md +212 -42
- package/agents/debugger.md +52 -4
- package/agents/document-specialist.md +39 -60
- package/agents/executor.md +29 -9
- package/agents/explore.md +3 -1
- package/agents/security-reviewer.md +57 -0
- package/agents/test-engineer.md +21 -0
- package/agents/verifier.md +2 -0
- package/agents/writer.md +2 -0
- package/bridge/cli.cjs +7402 -3580
- package/bridge/mcp-server.cjs +558 -43
- package/bridge/runtime-cli.cjs +3034 -1801
- package/bridge/team-bridge.cjs +25 -1
- package/bridge/team-mcp.cjs +257 -88
- package/bridge/team.js +5226 -413
- package/dist/__tests__/agent-boundary-guidance.test.d.ts +2 -0
- package/dist/__tests__/agent-boundary-guidance.test.d.ts.map +1 -0
- package/dist/__tests__/agent-boundary-guidance.test.js +48 -0
- package/dist/__tests__/agent-boundary-guidance.test.js.map +1 -0
- package/dist/__tests__/agent-registry.test.js +48 -11
- package/dist/__tests__/agent-registry.test.js.map +1 -1
- package/dist/__tests__/auto-slash-aliases.test.js +25 -0
- package/dist/__tests__/auto-slash-aliases.test.js.map +1 -1
- package/dist/__tests__/bedrock-model-routing.test.d.ts +21 -0
- package/dist/__tests__/bedrock-model-routing.test.d.ts.map +1 -0
- package/dist/__tests__/bedrock-model-routing.test.js +397 -0
- package/dist/__tests__/bedrock-model-routing.test.js.map +1 -0
- package/dist/__tests__/cleanup-validation.test.js +7 -3
- package/dist/__tests__/cleanup-validation.test.js.map +1 -1
- package/dist/__tests__/cli-win32-warning.test.js +15 -2
- package/dist/__tests__/cli-win32-warning.test.js.map +1 -1
- package/dist/__tests__/consolidation-contracts.test.js +28 -3
- package/dist/__tests__/consolidation-contracts.test.js.map +1 -1
- package/dist/__tests__/context-guard-stop.test.d.ts +2 -0
- package/dist/__tests__/context-guard-stop.test.d.ts.map +1 -0
- package/dist/__tests__/context-guard-stop.test.js +58 -0
- package/dist/__tests__/context-guard-stop.test.js.map +1 -0
- package/dist/__tests__/delegation-enforcer.test.js +76 -11
- package/dist/__tests__/delegation-enforcer.test.js.map +1 -1
- package/dist/__tests__/doctor-conflicts.test.js +62 -1
- package/dist/__tests__/doctor-conflicts.test.js.map +1 -1
- package/dist/__tests__/hooks.test.js +165 -4
- package/dist/__tests__/hooks.test.js.map +1 -1
- package/dist/__tests__/hud/defaults.test.js +4 -0
- package/dist/__tests__/hud/defaults.test.js.map +1 -1
- package/dist/__tests__/hud/limits-error.test.js +2 -4
- package/dist/__tests__/hud/limits-error.test.js.map +1 -1
- package/dist/__tests__/hud/mission-board-state.test.d.ts +2 -0
- package/dist/__tests__/hud/mission-board-state.test.d.ts.map +1 -0
- package/dist/__tests__/hud/mission-board-state.test.js +170 -0
- package/dist/__tests__/hud/mission-board-state.test.js.map +1 -0
- package/dist/__tests__/hud/mission-board.test.d.ts +2 -0
- package/dist/__tests__/hud/mission-board.test.d.ts.map +1 -0
- package/dist/__tests__/hud/mission-board.test.js +143 -0
- package/dist/__tests__/hud/mission-board.test.js.map +1 -0
- package/dist/__tests__/hud/rate-limits-error.test.js +13 -0
- package/dist/__tests__/hud/rate-limits-error.test.js.map +1 -1
- package/dist/__tests__/hud/render-rate-limits-priority.test.d.ts +8 -0
- package/dist/__tests__/hud/render-rate-limits-priority.test.d.ts.map +1 -0
- package/dist/__tests__/hud/render-rate-limits-priority.test.js +145 -0
- package/dist/__tests__/hud/render-rate-limits-priority.test.js.map +1 -0
- package/dist/__tests__/hud/render.test.js +22 -0
- package/dist/__tests__/hud/render.test.js.map +1 -1
- package/dist/__tests__/hud/stale-indicator.test.d.ts +9 -0
- package/dist/__tests__/hud/stale-indicator.test.d.ts.map +1 -0
- package/dist/__tests__/hud/stale-indicator.test.js +81 -0
- package/dist/__tests__/hud/stale-indicator.test.js.map +1 -0
- package/dist/__tests__/hud/state.test.js +30 -0
- package/dist/__tests__/hud/state.test.js.map +1 -1
- package/dist/__tests__/hud/usage-api-lock.test.d.ts +2 -0
- package/dist/__tests__/hud/usage-api-lock.test.d.ts.map +1 -0
- package/dist/__tests__/hud/usage-api-lock.test.js +245 -0
- package/dist/__tests__/hud/usage-api-lock.test.js.map +1 -0
- package/dist/__tests__/hud/usage-api-stale.test.d.ts +9 -0
- package/dist/__tests__/hud/usage-api-stale.test.d.ts.map +1 -0
- package/dist/__tests__/hud/usage-api-stale.test.js +297 -0
- package/dist/__tests__/hud/usage-api-stale.test.js.map +1 -0
- package/dist/__tests__/hud/usage-api.test.js +223 -0
- package/dist/__tests__/hud/usage-api.test.js.map +1 -1
- package/dist/__tests__/hud/watch-mode-init.test.d.ts +2 -0
- package/dist/__tests__/hud/watch-mode-init.test.d.ts.map +1 -0
- package/dist/__tests__/hud/watch-mode-init.test.js +133 -0
- package/dist/__tests__/hud/watch-mode-init.test.js.map +1 -0
- package/dist/__tests__/hud-agents.test.js +12 -10
- package/dist/__tests__/hud-agents.test.js.map +1 -1
- package/dist/__tests__/hud-build-guidance.test.js +6 -2
- package/dist/__tests__/hud-build-guidance.test.js.map +1 -1
- package/dist/__tests__/hud-marketplace-resolution.test.d.ts +2 -0
- package/dist/__tests__/hud-marketplace-resolution.test.d.ts.map +1 -0
- package/dist/__tests__/hud-marketplace-resolution.test.js +53 -0
- package/dist/__tests__/hud-marketplace-resolution.test.js.map +1 -0
- package/dist/__tests__/installer-hud-skip.test.js +12 -0
- package/dist/__tests__/installer-hud-skip.test.js.map +1 -1
- package/dist/__tests__/installer-plugin-agents.test.d.ts +2 -0
- package/dist/__tests__/installer-plugin-agents.test.d.ts.map +1 -0
- package/dist/__tests__/installer-plugin-agents.test.js +111 -0
- package/dist/__tests__/installer-plugin-agents.test.js.map +1 -0
- package/dist/__tests__/installer-version-guard.test.d.ts +2 -0
- package/dist/__tests__/installer-version-guard.test.d.ts.map +1 -0
- package/dist/__tests__/installer-version-guard.test.js +75 -0
- package/dist/__tests__/installer-version-guard.test.js.map +1 -0
- package/dist/__tests__/installer.test.js +58 -4
- package/dist/__tests__/installer.test.js.map +1 -1
- package/dist/__tests__/omc-tools-server.test.js +8 -5
- package/dist/__tests__/omc-tools-server.test.js.map +1 -1
- package/dist/__tests__/pre-tool-enforcer.test.js +38 -0
- package/dist/__tests__/pre-tool-enforcer.test.js.map +1 -1
- package/dist/__tests__/prompt-injection.test.js +3 -3
- package/dist/__tests__/prompt-injection.test.js.map +1 -1
- package/dist/__tests__/ralph-prd-mandatory.test.js +53 -2
- package/dist/__tests__/ralph-prd-mandatory.test.js.map +1 -1
- package/dist/__tests__/rate-limit-wait/rate-limit-monitor.test.js +42 -0
- package/dist/__tests__/rate-limit-wait/rate-limit-monitor.test.js.map +1 -1
- package/dist/__tests__/rate-limit-wait/tmux-detector.test.js +1 -1
- package/dist/__tests__/session-history-search.test.d.ts +2 -0
- package/dist/__tests__/session-history-search.test.d.ts.map +1 -0
- package/dist/__tests__/session-history-search.test.js +115 -0
- package/dist/__tests__/session-history-search.test.js.map +1 -0
- package/dist/__tests__/session-start-script-context.test.d.ts +2 -0
- package/dist/__tests__/session-start-script-context.test.d.ts.map +1 -0
- package/dist/__tests__/session-start-script-context.test.js +49 -0
- package/dist/__tests__/session-start-script-context.test.js.map +1 -0
- package/dist/__tests__/skills.test.js +71 -24
- package/dist/__tests__/skills.test.js.map +1 -1
- package/dist/__tests__/standalone-server.test.js +8 -4
- package/dist/__tests__/standalone-server.test.js.map +1 -1
- package/dist/__tests__/tier0-docs-consistency.test.js +10 -2
- package/dist/__tests__/tier0-docs-consistency.test.js.map +1 -1
- package/dist/agents/definitions.d.ts +5 -15
- package/dist/agents/definitions.d.ts.map +1 -1
- package/dist/agents/definitions.js +48 -49
- package/dist/agents/definitions.js.map +1 -1
- package/dist/agents/document-specialist.d.ts +1 -1
- package/dist/agents/document-specialist.d.ts.map +1 -1
- package/dist/agents/document-specialist.js +46 -21
- package/dist/agents/document-specialist.js.map +1 -1
- package/dist/agents/explore.d.ts.map +1 -1
- package/dist/agents/explore.js +3 -2
- package/dist/agents/explore.js.map +1 -1
- package/dist/agents/index.d.ts +2 -4
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +3 -6
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/types.d.ts +2 -2
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/cli/__tests__/ask.test.js +255 -8
- package/dist/cli/__tests__/ask.test.js.map +1 -1
- package/dist/cli/__tests__/session-search-help.test.d.ts +2 -0
- package/dist/cli/__tests__/session-search-help.test.d.ts.map +1 -0
- package/dist/cli/__tests__/session-search-help.test.js +13 -0
- package/dist/cli/__tests__/session-search-help.test.js.map +1 -0
- package/dist/cli/__tests__/session-search.test.d.ts +2 -0
- package/dist/cli/__tests__/session-search.test.d.ts.map +1 -0
- package/dist/cli/__tests__/session-search.test.js +72 -0
- package/dist/cli/__tests__/session-search.test.js.map +1 -0
- package/dist/cli/__tests__/team-help.test.js +1 -1
- package/dist/cli/__tests__/team-help.test.js.map +1 -1
- package/dist/cli/__tests__/team.test.js +256 -4
- package/dist/cli/__tests__/team.test.js.map +1 -1
- package/dist/cli/commands/__tests__/team.test.js +52 -2
- package/dist/cli/commands/__tests__/team.test.js.map +1 -1
- package/dist/cli/commands/doctor-conflicts.d.ts.map +1 -1
- package/dist/cli/commands/doctor-conflicts.js +15 -1
- package/dist/cli/commands/doctor-conflicts.js.map +1 -1
- package/dist/cli/commands/session-search.d.ts +18 -0
- package/dist/cli/commands/session-search.d.ts.map +1 -0
- package/dist/cli/commands/session-search.js +47 -0
- package/dist/cli/commands/session-search.js.map +1 -0
- package/dist/cli/commands/team.d.ts +11 -0
- package/dist/cli/commands/team.d.ts.map +1 -1
- package/dist/cli/commands/team.js +94 -24
- package/dist/cli/commands/team.js.map +1 -1
- package/dist/cli/commands/wait.d.ts.map +1 -1
- package/dist/cli/commands/wait.js +12 -1
- package/dist/cli/commands/wait.js.map +1 -1
- package/dist/cli/index.js +70 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/team.d.ts +1 -0
- package/dist/cli/team.d.ts.map +1 -1
- package/dist/cli/team.js +100 -214
- package/dist/cli/team.js.map +1 -1
- package/dist/cli/win32-warning.d.ts +2 -1
- package/dist/cli/win32-warning.d.ts.map +1 -1
- package/dist/cli/win32-warning.js +20 -6
- package/dist/cli/win32-warning.js.map +1 -1
- package/dist/config/__tests__/loader.test.d.ts +2 -0
- package/dist/config/__tests__/loader.test.d.ts.map +1 -0
- package/dist/config/__tests__/loader.test.js +145 -0
- package/dist/config/__tests__/loader.test.js.map +1 -0
- package/dist/config/__tests__/models.test.d.ts +2 -0
- package/dist/config/__tests__/models.test.d.ts.map +1 -0
- package/dist/config/__tests__/models.test.js +147 -0
- package/dist/config/__tests__/models.test.js.map +1 -0
- package/dist/config/__tests__/test-helpers.d.ts +3 -0
- package/dist/config/__tests__/test-helpers.d.ts.map +1 -0
- package/dist/config/__tests__/test-helpers.js +19 -0
- package/dist/config/__tests__/test-helpers.js.map +1 -0
- package/dist/config/loader.d.ts +3 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +140 -126
- package/dist/config/loader.js.map +1 -1
- package/dist/config/models.d.ts +29 -10
- package/dist/config/models.d.ts.map +1 -1
- package/dist/config/models.js +96 -10
- package/dist/config/models.js.map +1 -1
- package/dist/features/builtin-skills/skills.d.ts.map +1 -1
- package/dist/features/builtin-skills/skills.js +8 -1
- package/dist/features/builtin-skills/skills.js.map +1 -1
- package/dist/features/builtin-skills/types.d.ts +3 -0
- package/dist/features/builtin-skills/types.d.ts.map +1 -1
- package/dist/features/delegation-enforcer.d.ts +5 -12
- package/dist/features/delegation-enforcer.d.ts.map +1 -1
- package/dist/features/delegation-enforcer.js +48 -54
- package/dist/features/delegation-enforcer.js.map +1 -1
- package/dist/features/delegation-routing/__tests__/resolver.test.js +4 -3
- package/dist/features/delegation-routing/__tests__/resolver.test.js.map +1 -1
- package/dist/features/delegation-routing/types.d.ts.map +1 -1
- package/dist/features/delegation-routing/types.js +7 -4
- package/dist/features/delegation-routing/types.js.map +1 -1
- package/dist/features/index.d.ts +1 -0
- package/dist/features/index.d.ts.map +1 -1
- package/dist/features/index.js +2 -0
- package/dist/features/index.js.map +1 -1
- package/dist/features/rate-limit-wait/daemon.d.ts.map +1 -1
- package/dist/features/rate-limit-wait/daemon.js +8 -5
- package/dist/features/rate-limit-wait/daemon.js.map +1 -1
- package/dist/features/rate-limit-wait/index.d.ts +1 -1
- package/dist/features/rate-limit-wait/index.d.ts.map +1 -1
- package/dist/features/rate-limit-wait/index.js +1 -1
- package/dist/features/rate-limit-wait/index.js.map +1 -1
- package/dist/features/rate-limit-wait/rate-limit-monitor.d.ts +9 -0
- package/dist/features/rate-limit-wait/rate-limit-monitor.d.ts.map +1 -1
- package/dist/features/rate-limit-wait/rate-limit-monitor.js +38 -0
- package/dist/features/rate-limit-wait/rate-limit-monitor.js.map +1 -1
- package/dist/features/rate-limit-wait/tmux-detector.d.ts +2 -1
- package/dist/features/rate-limit-wait/tmux-detector.d.ts.map +1 -1
- package/dist/features/rate-limit-wait/tmux-detector.js +8 -9
- package/dist/features/rate-limit-wait/tmux-detector.js.map +1 -1
- package/dist/features/rate-limit-wait/types.d.ts +11 -0
- package/dist/features/rate-limit-wait/types.d.ts.map +1 -1
- package/dist/features/session-history-search/index.d.ts +6 -0
- package/dist/features/session-history-search/index.d.ts.map +1 -0
- package/dist/features/session-history-search/index.js +480 -0
- package/dist/features/session-history-search/index.js.map +1 -0
- package/dist/features/session-history-search/types.d.ts +36 -0
- package/dist/features/session-history-search/types.d.ts.map +1 -0
- package/dist/features/session-history-search/types.js +2 -0
- package/dist/features/session-history-search/types.js.map +1 -0
- package/dist/hooks/__tests__/background-process-guard.test.js +101 -5
- package/dist/hooks/__tests__/background-process-guard.test.js.map +1 -1
- package/dist/hooks/__tests__/bridge-openclaw.test.js +16 -5
- package/dist/hooks/__tests__/bridge-openclaw.test.js.map +1 -1
- package/dist/hooks/__tests__/bridge-routing.test.js +48 -1
- package/dist/hooks/__tests__/bridge-routing.test.js.map +1 -1
- package/dist/hooks/auto-slash-command/executor.d.ts.map +1 -1
- package/dist/hooks/auto-slash-command/executor.js +9 -1
- package/dist/hooks/auto-slash-command/executor.js.map +1 -1
- package/dist/hooks/auto-slash-command/types.d.ts +2 -0
- package/dist/hooks/auto-slash-command/types.d.ts.map +1 -1
- package/dist/hooks/auto-slash-command/types.js +0 -7
- package/dist/hooks/auto-slash-command/types.js.map +1 -1
- package/dist/hooks/autopilot/adapters/execution-adapter.js +3 -3
- package/dist/hooks/autopilot/prompts.js +1 -1
- package/dist/hooks/bridge-normalize.d.ts.map +1 -1
- package/dist/hooks/bridge-normalize.js +2 -0
- package/dist/hooks/bridge-normalize.js.map +1 -1
- package/dist/hooks/bridge.d.ts.map +1 -1
- package/dist/hooks/bridge.js +248 -39
- package/dist/hooks/bridge.js.map +1 -1
- package/dist/hooks/keyword-detector/__tests__/index.test.js +41 -0
- package/dist/hooks/keyword-detector/__tests__/index.test.js.map +1 -1
- package/dist/hooks/keyword-detector/index.d.ts +1 -1
- package/dist/hooks/keyword-detector/index.d.ts.map +1 -1
- package/dist/hooks/keyword-detector/index.js +3 -1
- package/dist/hooks/keyword-detector/index.js.map +1 -1
- package/dist/hooks/permission-handler/index.d.ts +8 -0
- package/dist/hooks/permission-handler/index.d.ts.map +1 -1
- package/dist/hooks/permission-handler/index.js +76 -0
- package/dist/hooks/permission-handler/index.js.map +1 -1
- package/dist/hooks/persistent-mode/__tests__/ralph-verification-flow.test.d.ts +2 -0
- package/dist/hooks/persistent-mode/__tests__/ralph-verification-flow.test.d.ts.map +1 -0
- package/dist/hooks/persistent-mode/__tests__/ralph-verification-flow.test.js +90 -0
- package/dist/hooks/persistent-mode/__tests__/ralph-verification-flow.test.js.map +1 -0
- package/dist/hooks/persistent-mode/__tests__/team-ralplan-stop.test.d.ts +2 -0
- package/dist/hooks/persistent-mode/__tests__/team-ralplan-stop.test.d.ts.map +1 -0
- package/dist/hooks/persistent-mode/__tests__/team-ralplan-stop.test.js +535 -0
- package/dist/hooks/persistent-mode/__tests__/team-ralplan-stop.test.js.map +1 -0
- package/dist/hooks/persistent-mode/index.d.ts +1 -1
- package/dist/hooks/persistent-mode/index.d.ts.map +1 -1
- package/dist/hooks/persistent-mode/index.js +296 -21
- package/dist/hooks/persistent-mode/index.js.map +1 -1
- package/dist/hooks/persistent-mode/stop-hook-blocking.test.js +156 -0
- package/dist/hooks/persistent-mode/stop-hook-blocking.test.js.map +1 -1
- package/dist/hooks/project-memory/__tests__/integration.test.js +27 -2
- package/dist/hooks/project-memory/__tests__/integration.test.js.map +1 -1
- package/dist/hooks/project-memory/__tests__/storage.test.js +37 -0
- package/dist/hooks/project-memory/__tests__/storage.test.js.map +1 -1
- package/dist/hooks/project-memory/storage.d.ts +1 -1
- package/dist/hooks/project-memory/storage.d.ts.map +1 -1
- package/dist/hooks/project-memory/storage.js +5 -4
- package/dist/hooks/project-memory/storage.js.map +1 -1
- package/dist/hooks/ralph/index.d.ts +1 -1
- package/dist/hooks/ralph/index.d.ts.map +1 -1
- package/dist/hooks/ralph/index.js +1 -1
- package/dist/hooks/ralph/index.js.map +1 -1
- package/dist/hooks/ralph/loop.d.ts +18 -0
- package/dist/hooks/ralph/loop.d.ts.map +1 -1
- package/dist/hooks/ralph/loop.js +31 -0
- package/dist/hooks/ralph/loop.js.map +1 -1
- package/dist/hooks/ralph/verifier.d.ts +4 -1
- package/dist/hooks/ralph/verifier.d.ts.map +1 -1
- package/dist/hooks/ralph/verifier.js +56 -21
- package/dist/hooks/ralph/verifier.js.map +1 -1
- package/dist/hooks/recovery/__tests__/storage.test.d.ts +2 -0
- package/dist/hooks/recovery/__tests__/storage.test.d.ts.map +1 -0
- package/dist/hooks/recovery/__tests__/storage.test.js +65 -0
- package/dist/hooks/recovery/__tests__/storage.test.js.map +1 -0
- package/dist/hooks/recovery/storage.d.ts +5 -1
- package/dist/hooks/recovery/storage.d.ts.map +1 -1
- package/dist/hooks/recovery/storage.js +7 -29
- package/dist/hooks/recovery/storage.js.map +1 -1
- package/dist/hooks/recovery/types.d.ts +1 -1
- package/dist/hooks/recovery/types.d.ts.map +1 -1
- package/dist/hooks/session-end/__tests__/duplicate-notifications.test.d.ts +2 -0
- package/dist/hooks/session-end/__tests__/duplicate-notifications.test.d.ts.map +1 -0
- package/dist/hooks/session-end/__tests__/duplicate-notifications.test.js +140 -0
- package/dist/hooks/session-end/__tests__/duplicate-notifications.test.js.map +1 -0
- package/dist/hooks/session-end/__tests__/mode-state-cleanup.test.d.ts +2 -0
- package/dist/hooks/session-end/__tests__/mode-state-cleanup.test.d.ts.map +1 -0
- package/dist/hooks/session-end/__tests__/mode-state-cleanup.test.js +122 -0
- package/dist/hooks/session-end/__tests__/mode-state-cleanup.test.js.map +1 -0
- package/dist/hooks/session-end/__tests__/openclaw-session-end.test.js +38 -12
- package/dist/hooks/session-end/__tests__/openclaw-session-end.test.js.map +1 -1
- package/dist/hooks/session-end/callbacks.d.ts +4 -1
- package/dist/hooks/session-end/callbacks.d.ts.map +1 -1
- package/dist/hooks/session-end/callbacks.js +5 -4
- package/dist/hooks/session-end/callbacks.js.map +1 -1
- package/dist/hooks/session-end/index.d.ts.map +1 -1
- package/dist/hooks/session-end/index.js +162 -36
- package/dist/hooks/session-end/index.js.map +1 -1
- package/dist/hooks/skill-state/__tests__/skill-state.test.js +35 -33
- package/dist/hooks/skill-state/__tests__/skill-state.test.js.map +1 -1
- package/dist/hooks/skill-state/index.d.ts +3 -3
- package/dist/hooks/skill-state/index.d.ts.map +1 -1
- package/dist/hooks/skill-state/index.js +7 -11
- package/dist/hooks/skill-state/index.js.map +1 -1
- package/dist/hooks/subagent-tracker/index.d.ts.map +1 -1
- package/dist/hooks/subagent-tracker/index.js +22 -0
- package/dist/hooks/subagent-tracker/index.js.map +1 -1
- package/dist/hooks/think-mode/__tests__/index.test.js +20 -20
- package/dist/hooks/think-mode/__tests__/index.test.js.map +1 -1
- package/dist/hooks/think-mode/switcher.d.ts.map +1 -1
- package/dist/hooks/think-mode/switcher.js +13 -10
- package/dist/hooks/think-mode/switcher.js.map +1 -1
- package/dist/hooks/thinking-block-validator/__tests__/index.test.d.ts +2 -0
- package/dist/hooks/thinking-block-validator/__tests__/index.test.d.ts.map +1 -0
- package/dist/hooks/thinking-block-validator/__tests__/index.test.js +56 -0
- package/dist/hooks/thinking-block-validator/__tests__/index.test.js.map +1 -0
- package/dist/hooks/thinking-block-validator/index.d.ts.map +1 -1
- package/dist/hooks/thinking-block-validator/index.js +7 -6
- package/dist/hooks/thinking-block-validator/index.js.map +1 -1
- package/dist/hooks/todo-continuation/index.d.ts +6 -0
- package/dist/hooks/todo-continuation/index.d.ts.map +1 -1
- package/dist/hooks/todo-continuation/index.js +14 -5
- package/dist/hooks/todo-continuation/index.js.map +1 -1
- package/dist/hud/elements/agents.d.ts.map +1 -1
- package/dist/hud/elements/agents.js +8 -14
- package/dist/hud/elements/agents.js.map +1 -1
- package/dist/hud/elements/index.d.ts +1 -0
- package/dist/hud/elements/index.d.ts.map +1 -1
- package/dist/hud/elements/index.js +1 -0
- package/dist/hud/elements/index.js.map +1 -1
- package/dist/hud/elements/limits.d.ts +3 -3
- package/dist/hud/elements/limits.d.ts.map +1 -1
- package/dist/hud/elements/limits.js +26 -18
- package/dist/hud/elements/limits.js.map +1 -1
- package/dist/hud/elements/mission-board.d.ts +2 -0
- package/dist/hud/elements/mission-board.d.ts.map +1 -0
- package/dist/hud/elements/mission-board.js +2 -0
- package/dist/hud/elements/mission-board.js.map +1 -0
- package/dist/hud/index.d.ts +1 -1
- package/dist/hud/index.d.ts.map +1 -1
- package/dist/hud/index.js +10 -2
- package/dist/hud/index.js.map +1 -1
- package/dist/hud/mission-board.d.ts +75 -0
- package/dist/hud/mission-board.d.ts.map +1 -0
- package/dist/hud/mission-board.js +420 -0
- package/dist/hud/mission-board.js.map +1 -0
- package/dist/hud/render.d.ts.map +1 -1
- package/dist/hud/render.js +16 -8
- package/dist/hud/render.js.map +1 -1
- package/dist/hud/state.d.ts.map +1 -1
- package/dist/hud/state.js +13 -0
- package/dist/hud/state.js.map +1 -1
- package/dist/hud/types.d.ts +11 -0
- package/dist/hud/types.d.ts.map +1 -1
- package/dist/hud/types.js +10 -0
- package/dist/hud/types.js.map +1 -1
- package/dist/hud/usage-api.d.ts +1 -1
- package/dist/hud/usage-api.d.ts.map +1 -1
- package/dist/hud/usage-api.js +207 -106
- package/dist/hud/usage-api.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/installer/__tests__/claude-md-merge.test.js +53 -9
- package/dist/installer/__tests__/claude-md-merge.test.js.map +1 -1
- package/dist/installer/__tests__/hook-templates.test.d.ts +2 -0
- package/dist/installer/__tests__/hook-templates.test.d.ts.map +1 -0
- package/dist/installer/__tests__/hook-templates.test.js +76 -0
- package/dist/installer/__tests__/hook-templates.test.js.map +1 -0
- package/dist/installer/hooks.d.ts +15 -0
- package/dist/installer/hooks.d.ts.map +1 -1
- package/dist/installer/hooks.js +51 -0
- package/dist/installer/hooks.js.map +1 -1
- package/dist/installer/index.d.ts +25 -0
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +273 -64
- package/dist/installer/index.js.map +1 -1
- package/dist/lib/mode-names.d.ts.map +1 -1
- package/dist/lib/mode-names.js +2 -0
- package/dist/lib/mode-names.js.map +1 -1
- package/dist/mcp/__tests__/team-server-artifact-convergence.test.js +30 -3
- package/dist/mcp/__tests__/team-server-artifact-convergence.test.js.map +1 -1
- package/dist/mcp/__tests__/team-server-deprecation.test.js +2 -0
- package/dist/mcp/__tests__/team-server-deprecation.test.js.map +1 -1
- package/dist/mcp/team-job-convergence.d.ts.map +1 -1
- package/dist/mcp/team-job-convergence.js +12 -3
- package/dist/mcp/team-job-convergence.js.map +1 -1
- package/dist/mcp/team-server.d.ts.map +1 -1
- package/dist/mcp/team-server.js +18 -4
- package/dist/mcp/team-server.js.map +1 -1
- package/dist/notifications/__tests__/config-merge.test.js +36 -1
- package/dist/notifications/__tests__/config-merge.test.js.map +1 -1
- package/dist/notifications/__tests__/formatter.test.js +13 -5
- package/dist/notifications/__tests__/formatter.test.js.map +1 -1
- package/dist/notifications/__tests__/notify-registry-integration.test.js +27 -1
- package/dist/notifications/__tests__/notify-registry-integration.test.js.map +1 -1
- package/dist/notifications/__tests__/verbosity.test.js +33 -1
- package/dist/notifications/__tests__/verbosity.test.js.map +1 -1
- package/dist/notifications/config.d.ts +7 -0
- package/dist/notifications/config.d.ts.map +1 -1
- package/dist/notifications/config.js +18 -0
- package/dist/notifications/config.js.map +1 -1
- package/dist/notifications/formatter.d.ts +2 -2
- package/dist/notifications/formatter.d.ts.map +1 -1
- package/dist/notifications/formatter.js +7 -6
- package/dist/notifications/formatter.js.map +1 -1
- package/dist/notifications/index.d.ts +1 -1
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +5 -3
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications/template-engine.js +1 -1
- package/dist/notifications/template-engine.js.map +1 -1
- package/dist/notifications/types.d.ts +4 -0
- package/dist/notifications/types.d.ts.map +1 -1
- package/dist/openclaw/__tests__/dispatcher.test.js +26 -0
- package/dist/openclaw/__tests__/dispatcher.test.js.map +1 -1
- package/dist/openclaw/__tests__/index.test.js +42 -0
- package/dist/openclaw/__tests__/index.test.js.map +1 -1
- package/dist/openclaw/__tests__/signal.test.d.ts +2 -0
- package/dist/openclaw/__tests__/signal.test.d.ts.map +1 -0
- package/dist/openclaw/__tests__/signal.test.js +69 -0
- package/dist/openclaw/__tests__/signal.test.js.map +1 -0
- package/dist/openclaw/dispatcher.d.ts +5 -1
- package/dist/openclaw/dispatcher.d.ts.map +1 -1
- package/dist/openclaw/dispatcher.js +13 -2
- package/dist/openclaw/dispatcher.js.map +1 -1
- package/dist/openclaw/index.d.ts +2 -1
- package/dist/openclaw/index.d.ts.map +1 -1
- package/dist/openclaw/index.js +29 -15
- package/dist/openclaw/index.js.map +1 -1
- package/dist/openclaw/signal.d.ts +3 -0
- package/dist/openclaw/signal.d.ts.map +1 -0
- package/dist/openclaw/signal.js +215 -0
- package/dist/openclaw/signal.js.map +1 -0
- package/dist/openclaw/types.d.ts +35 -0
- package/dist/openclaw/types.d.ts.map +1 -1
- package/dist/shared/types.d.ts +2 -12
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/skills/__tests__/mingw-escape.test.js +41 -11
- package/dist/skills/__tests__/mingw-escape.test.js.map +1 -1
- package/dist/team/__tests__/api-interop.cwd-resolution.test.d.ts +2 -0
- package/dist/team/__tests__/api-interop.cwd-resolution.test.d.ts.map +1 -0
- package/dist/team/__tests__/api-interop.cwd-resolution.test.js +78 -0
- package/dist/team/__tests__/api-interop.cwd-resolution.test.js.map +1 -0
- package/dist/team/__tests__/api-interop.dispatch.test.d.ts +2 -0
- package/dist/team/__tests__/api-interop.dispatch.test.d.ts.map +1 -0
- package/dist/team/__tests__/api-interop.dispatch.test.js +125 -0
- package/dist/team/__tests__/api-interop.dispatch.test.js.map +1 -0
- package/dist/team/__tests__/cli-detection.test.d.ts +2 -0
- package/dist/team/__tests__/cli-detection.test.d.ts.map +1 -0
- package/dist/team/__tests__/cli-detection.test.js +36 -0
- package/dist/team/__tests__/cli-detection.test.js.map +1 -0
- package/dist/team/__tests__/model-contract.test.js +79 -2
- package/dist/team/__tests__/model-contract.test.js.map +1 -1
- package/dist/team/__tests__/runtime-done-recovery.test.js +1 -0
- package/dist/team/__tests__/runtime-done-recovery.test.js.map +1 -1
- package/dist/team/__tests__/runtime-prompt-mode.test.js +84 -8
- package/dist/team/__tests__/runtime-prompt-mode.test.js.map +1 -1
- package/dist/team/__tests__/runtime-v2.dispatch.test.d.ts +2 -0
- package/dist/team/__tests__/runtime-v2.dispatch.test.d.ts.map +1 -0
- package/dist/team/__tests__/runtime-v2.dispatch.test.js +237 -0
- package/dist/team/__tests__/runtime-v2.dispatch.test.js.map +1 -0
- package/dist/team/__tests__/runtime-v2.monitor.test.d.ts +2 -0
- package/dist/team/__tests__/runtime-v2.monitor.test.d.ts.map +1 -0
- package/dist/team/__tests__/runtime-v2.monitor.test.js +103 -0
- package/dist/team/__tests__/runtime-v2.monitor.test.js.map +1 -0
- package/dist/team/__tests__/runtime-v2.shutdown.test.d.ts +2 -0
- package/dist/team/__tests__/runtime-v2.shutdown.test.d.ts.map +1 -0
- package/dist/team/__tests__/runtime-v2.shutdown.test.js +49 -0
- package/dist/team/__tests__/runtime-v2.shutdown.test.js.map +1 -0
- package/dist/team/__tests__/runtime-watchdog-retry.test.js +3 -0
- package/dist/team/__tests__/runtime-watchdog-retry.test.js.map +1 -1
- package/dist/team/__tests__/tmux-session.create-team.test.js +29 -12
- package/dist/team/__tests__/tmux-session.create-team.test.js.map +1 -1
- package/dist/team/__tests__/tmux-session.kill-team-session.test.js +6 -0
- package/dist/team/__tests__/tmux-session.kill-team-session.test.js.map +1 -1
- package/dist/team/__tests__/tmux-session.test.js +9 -0
- package/dist/team/__tests__/tmux-session.test.js.map +1 -1
- package/dist/team/__tests__/worker-bootstrap.test.js +32 -3
- package/dist/team/__tests__/worker-bootstrap.test.js.map +1 -1
- package/dist/team/api-interop.d.ts.map +1 -1
- package/dist/team/api-interop.js +153 -2
- package/dist/team/api-interop.js.map +1 -1
- package/dist/team/cli-detection.d.ts.map +1 -1
- package/dist/team/cli-detection.js +6 -2
- package/dist/team/cli-detection.js.map +1 -1
- package/dist/team/idle-nudge.js +1 -1
- package/dist/team/idle-nudge.js.map +1 -1
- package/dist/team/mcp-team-bridge.d.ts.map +1 -1
- package/dist/team/mcp-team-bridge.js +2 -1
- package/dist/team/mcp-team-bridge.js.map +1 -1
- package/dist/team/model-contract.d.ts +1 -1
- package/dist/team/model-contract.d.ts.map +1 -1
- package/dist/team/model-contract.js +35 -4
- package/dist/team/model-contract.js.map +1 -1
- package/dist/team/runtime-cli.d.ts.map +1 -1
- package/dist/team/runtime-cli.js +10 -7
- package/dist/team/runtime-cli.js.map +1 -1
- package/dist/team/runtime-v2.d.ts +4 -0
- package/dist/team/runtime-v2.d.ts.map +1 -1
- package/dist/team/runtime-v2.js +231 -59
- package/dist/team/runtime-v2.js.map +1 -1
- package/dist/team/runtime.d.ts +6 -1
- package/dist/team/runtime.d.ts.map +1 -1
- package/dist/team/runtime.js +39 -14
- package/dist/team/runtime.js.map +1 -1
- package/dist/team/tmux-session.d.ts +20 -11
- package/dist/team/tmux-session.d.ts.map +1 -1
- package/dist/team/tmux-session.js +108 -51
- package/dist/team/tmux-session.js.map +1 -1
- package/dist/team/types.d.ts +1 -0
- package/dist/team/types.d.ts.map +1 -1
- package/dist/team/types.js.map +1 -1
- package/dist/team/worker-bootstrap.d.ts +2 -0
- package/dist/team/worker-bootstrap.d.ts.map +1 -1
- package/dist/team/worker-bootstrap.js +46 -12
- package/dist/team/worker-bootstrap.js.map +1 -1
- package/dist/tools/__tests__/memory-tools.test.js +29 -1
- package/dist/tools/__tests__/memory-tools.test.js.map +1 -1
- package/dist/tools/lsp/client.d.ts +11 -0
- package/dist/tools/lsp/client.d.ts.map +1 -1
- package/dist/tools/lsp/client.js +46 -0
- package/dist/tools/lsp/client.js.map +1 -1
- package/dist/tools/session-history-tools.d.ts +23 -0
- package/dist/tools/session-history-tools.d.ts.map +1 -0
- package/dist/tools/session-history-tools.js +41 -0
- package/dist/tools/session-history-tools.js.map +1 -0
- package/dist/tools/trace-tools.d.ts +9 -0
- package/dist/tools/trace-tools.d.ts.map +1 -1
- package/dist/tools/trace-tools.js +2 -1
- package/dist/tools/trace-tools.js.map +1 -1
- package/dist/utils/frontmatter.d.ts +5 -0
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +22 -0
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/skill-pipeline.d.ts +9 -0
- package/dist/utils/skill-pipeline.d.ts.map +1 -0
- package/dist/utils/skill-pipeline.js +97 -0
- package/dist/utils/skill-pipeline.js.map +1 -0
- package/docs/AGENTS.md +1 -1
- package/docs/ANALYTICS-SYSTEM.md +23 -132
- package/docs/CLAUDE.md +40 -139
- package/docs/MIGRATION.md +4 -4
- package/docs/OPENCLAW-ROUTING.md +102 -0
- package/docs/PERFORMANCE-MONITORING.md +30 -55
- package/docs/REFERENCE.md +62 -35
- package/docs/TIERED_AGENTS_V2.md +3 -2
- package/docs/design/SKILL_AUDIT_1445.md +75 -0
- package/docs/ko/MIGRATION.md +2 -2
- package/docs/ko/REFERENCE.md +14 -22
- package/docs/partials/agent-tiers.md +11 -15
- package/docs/partials/features.md +2 -2
- package/docs/partials/mode-selection-guide.md +2 -2
- package/docs/shared/agent-tiers.md +11 -15
- package/docs/shared/features.md +2 -2
- package/docs/shared/mode-selection-guide.md +2 -2
- package/package.json +4 -1
- package/scripts/code-simplifier.mjs +1 -1
- package/scripts/context-guard-stop.mjs +26 -10
- package/scripts/keyword-detector.mjs +99 -39
- package/scripts/persistent-mode.cjs +295 -34
- package/scripts/persistent-mode.mjs +79 -21
- package/scripts/plugin-setup.mjs +10 -1
- package/scripts/post-tool-verifier.mjs +57 -3
- package/scripts/pre-tool-enforcer.mjs +207 -2
- package/scripts/run-provider-advisor.js +30 -3
- package/scripts/session-start.mjs +3 -3
- package/scripts/setup-claude-md.sh +159 -0
- package/scripts/setup-progress.sh +123 -0
- package/scripts/sync-metadata.ts +11 -1
- package/skills/AGENTS.md +13 -17
- package/skills/ai-slop-cleaner/SKILL.md +130 -0
- package/skills/ask/SKILL.md +51 -0
- package/skills/ccg/SKILL.md +6 -6
- package/skills/deep-interview/SKILL.md +4 -0
- package/skills/omc-doctor/SKILL.md +2 -2
- package/skills/omc-setup/SKILL.md +75 -1206
- package/skills/omc-setup/phases/01-install-claude-md.md +76 -0
- package/skills/omc-setup/phases/02-configure.md +211 -0
- package/skills/omc-setup/phases/03-integrations.md +192 -0
- package/skills/omc-setup/phases/04-welcome.md +192 -0
- package/skills/omc-teams/SKILL.md +35 -2
- package/skills/plan/SKILL.md +3 -0
- package/skills/ralph/SKILL.md +16 -10
- package/skills/release/SKILL.md +4 -0
- package/skills/setup/SKILL.md +40 -0
- package/skills/team/SKILL.md +6 -6
- package/templates/hooks/code-simplifier.mjs +1 -1
- package/templates/hooks/keyword-detector.mjs +100 -32
- package/templates/hooks/persistent-mode.mjs +43 -4
- package/templates/hooks/pre-tool-use.mjs +115 -1
- package/templates/hooks/session-start.mjs +1 -1
- package/agents/build-fixer.md +0 -90
- package/agents/deep-executor.md +0 -112
- package/agents/harsh-critic.md +0 -254
- package/agents/quality-reviewer.md +0 -151
- package/skills/analyze/SKILL.md +0 -87
- package/skills/ask-codex/SKILL.md +0 -47
- package/skills/ask-gemini/SKILL.md +0 -47
- package/skills/build-fix/SKILL.md +0 -123
- package/skills/code-review/SKILL.md +0 -573
- package/skills/configure-openclaw/SKILL.md +0 -383
- package/skills/learn-about-omc/SKILL.md +0 -37
- package/skills/note/SKILL.md +0 -62
- package/skills/omc-help/SKILL.md +0 -192
- package/skills/ralph-init/SKILL.md +0 -40
- package/skills/security-review/SKILL.md +0 -282
- package/skills/tdd/SKILL.md +0 -104
- package/skills/trace/SKILL.md +0 -33
|
@@ -12,6 +12,9 @@ import { homedir } from 'os';
|
|
|
12
12
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
13
13
|
import { readStdin } from './lib/stdin.mjs';
|
|
14
14
|
|
|
15
|
+
const AGENT_OUTPUT_ANALYSIS_LIMIT = parseInt(process.env.OMC_AGENT_OUTPUT_ANALYSIS_LIMIT || '12000', 10);
|
|
16
|
+
const AGENT_OUTPUT_SUMMARY_LIMIT = parseInt(process.env.OMC_AGENT_OUTPUT_SUMMARY_LIMIT || '360', 10);
|
|
17
|
+
|
|
15
18
|
// Get the directory of this script to resolve the dist module
|
|
16
19
|
const __filename = fileURLToPath(import.meta.url);
|
|
17
20
|
const __dirname = dirname(__filename);
|
|
@@ -208,6 +211,36 @@ function detectBackgroundOperation(output) {
|
|
|
208
211
|
return bgPatterns.some(pattern => pattern.test(output));
|
|
209
212
|
}
|
|
210
213
|
|
|
214
|
+
export function summarizeAgentResult(output, maxChars = AGENT_OUTPUT_SUMMARY_LIMIT) {
|
|
215
|
+
if (!output || typeof output !== 'string') return '';
|
|
216
|
+
|
|
217
|
+
const normalized = output
|
|
218
|
+
.replace(/\r/g, '')
|
|
219
|
+
.split('\n')
|
|
220
|
+
.map(l => l.trim())
|
|
221
|
+
.filter(Boolean)
|
|
222
|
+
.slice(0, 6)
|
|
223
|
+
.join(' | ');
|
|
224
|
+
|
|
225
|
+
if (!normalized) return '';
|
|
226
|
+
if (normalized.length <= maxChars) return normalized;
|
|
227
|
+
return `${normalized.slice(0, Math.max(0, maxChars - 20)).trimEnd()} … [truncated]`;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function clipToolOutputForAnalysis(toolName, output) {
|
|
231
|
+
if (typeof output !== 'string') return { clipped: '', wasTruncated: false };
|
|
232
|
+
|
|
233
|
+
const isAgentResultTool = toolName === 'Task' || toolName === 'TaskCreate' || toolName === 'TaskUpdate' || toolName === 'TaskOutput';
|
|
234
|
+
if (!isAgentResultTool || output.length <= AGENT_OUTPUT_ANALYSIS_LIMIT) {
|
|
235
|
+
return { clipped: output, wasTruncated: false };
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return {
|
|
239
|
+
clipped: `${output.slice(0, AGENT_OUTPUT_ANALYSIS_LIMIT)}\n...[agent output truncated by OMC context guard]`,
|
|
240
|
+
wasTruncated: true,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
211
244
|
/**
|
|
212
245
|
* Process <remember> tags from agent output
|
|
213
246
|
* <remember>content</remember> -> Working Memory
|
|
@@ -292,7 +325,8 @@ function getAgentCompletionSummary(directory) {
|
|
|
292
325
|
}
|
|
293
326
|
|
|
294
327
|
// Generate contextual message
|
|
295
|
-
function generateMessage(toolName, toolOutput, sessionId, toolCount, directory) {
|
|
328
|
+
function generateMessage(toolName, toolOutput, sessionId, toolCount, directory, options = {}) {
|
|
329
|
+
const { wasTruncated = false, rawLength = 0 } = options;
|
|
296
330
|
let message = '';
|
|
297
331
|
|
|
298
332
|
switch (toolName) {
|
|
@@ -320,12 +354,28 @@ function generateMessage(toolName, toolOutput, sessionId, toolCount, directory)
|
|
|
320
354
|
} else if (toolCount > 5) {
|
|
321
355
|
message = `Multiple tasks delegated (${toolCount} total). Track their completion status.`;
|
|
322
356
|
}
|
|
357
|
+
if (wasTruncated) {
|
|
358
|
+
const truncationNote = `Agent result stream clipped for context safety (${rawLength} chars). Synthesize only key outcomes in main session.`;
|
|
359
|
+
message = message ? `${message} | ${truncationNote}` : truncationNote;
|
|
360
|
+
}
|
|
323
361
|
if (agentSummary) {
|
|
324
362
|
message = message ? `${message} | ${agentSummary}` : agentSummary;
|
|
325
363
|
}
|
|
326
364
|
break;
|
|
327
365
|
}
|
|
328
366
|
|
|
367
|
+
case 'TaskOutput': {
|
|
368
|
+
const summary = summarizeAgentResult(toolOutput);
|
|
369
|
+
if (summary) {
|
|
370
|
+
message = `TaskOutput summary: ${summary}`;
|
|
371
|
+
}
|
|
372
|
+
if (wasTruncated) {
|
|
373
|
+
const truncationNote = `TaskOutput clipped (${rawLength} chars). Continue with concise synthesis and defer full logs to files.`;
|
|
374
|
+
message = message ? `${message} | ${truncationNote}` : truncationNote;
|
|
375
|
+
}
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
|
|
329
379
|
case 'Edit':
|
|
330
380
|
if (detectWriteFailure(toolOutput)) {
|
|
331
381
|
message = 'Edit operation failed. Verify file exists and content matches exactly.';
|
|
@@ -389,6 +439,7 @@ async function main() {
|
|
|
389
439
|
const toolName = data.tool_name || data.toolName || '';
|
|
390
440
|
const rawResponse = data.tool_response || data.toolOutput || '';
|
|
391
441
|
const toolOutput = typeof rawResponse === 'string' ? rawResponse : JSON.stringify(rawResponse);
|
|
442
|
+
const { clipped: clippedToolOutput, wasTruncated } = clipToolOutputForAnalysis(toolName, toolOutput);
|
|
392
443
|
const sessionId = data.session_id || data.sessionId || 'unknown';
|
|
393
444
|
const directory = data.cwd || data.directory || process.cwd();
|
|
394
445
|
|
|
@@ -409,11 +460,14 @@ async function main() {
|
|
|
409
460
|
toolName === 'TaskCreate' ||
|
|
410
461
|
toolName === 'TaskUpdate'
|
|
411
462
|
) {
|
|
412
|
-
processRememberTags(
|
|
463
|
+
processRememberTags(clippedToolOutput, directory);
|
|
413
464
|
}
|
|
414
465
|
|
|
415
466
|
// Generate contextual message
|
|
416
|
-
const message = generateMessage(toolName,
|
|
467
|
+
const message = generateMessage(toolName, clippedToolOutput, sessionId, toolCount, directory, {
|
|
468
|
+
wasTruncated,
|
|
469
|
+
rawLength: toolOutput.length,
|
|
470
|
+
});
|
|
417
471
|
|
|
418
472
|
// Build response - use hookSpecificOutput.additionalContext for PostToolUse
|
|
419
473
|
const response = { continue: true };
|
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
* Cross-platform: Windows, macOS, Linux
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { existsSync, readFileSync } from 'fs';
|
|
10
|
-
import { join } from 'path';
|
|
9
|
+
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, renameSync, statSync, writeFileSync } from 'fs';
|
|
10
|
+
import { dirname, join, resolve } from 'path';
|
|
11
|
+
import { execSync } from 'child_process';
|
|
12
|
+
import { homedir } from 'os';
|
|
11
13
|
import { pathToFileURL } from 'url';
|
|
12
14
|
import { readStdin } from './lib/stdin.mjs';
|
|
13
15
|
|
|
@@ -22,6 +24,103 @@ const MODE_STATE_FILES = [
|
|
|
22
24
|
'team-state.json',
|
|
23
25
|
'omc-teams-state.json',
|
|
24
26
|
];
|
|
27
|
+
const AGENT_HEAVY_TOOLS = new Set(['Task', 'TaskCreate', 'TaskUpdate']);
|
|
28
|
+
const PREFLIGHT_CONTEXT_THRESHOLD = parseInt(process.env.OMC_AGENT_PREFLIGHT_CONTEXT_THRESHOLD || '72', 10);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Resolve transcript path in worktree environments.
|
|
32
|
+
* Mirrors logic used by context safety/guard hooks.
|
|
33
|
+
*/
|
|
34
|
+
function resolveTranscriptPath(transcriptPath, cwd) {
|
|
35
|
+
if (!transcriptPath) return transcriptPath;
|
|
36
|
+
try {
|
|
37
|
+
if (existsSync(transcriptPath)) return transcriptPath;
|
|
38
|
+
} catch { /* fallthrough */ }
|
|
39
|
+
|
|
40
|
+
const worktreePattern = /--claude-worktrees-[^/\\]+/;
|
|
41
|
+
if (worktreePattern.test(transcriptPath)) {
|
|
42
|
+
const resolvedPath = transcriptPath.replace(worktreePattern, '');
|
|
43
|
+
try {
|
|
44
|
+
if (existsSync(resolvedPath)) return resolvedPath;
|
|
45
|
+
} catch { /* fallthrough */ }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const effectiveCwd = cwd || process.cwd();
|
|
49
|
+
try {
|
|
50
|
+
const gitCommonDir = execSync('git rev-parse --git-common-dir', {
|
|
51
|
+
cwd: effectiveCwd,
|
|
52
|
+
encoding: 'utf-8',
|
|
53
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
54
|
+
}).trim();
|
|
55
|
+
|
|
56
|
+
const absoluteCommonDir = resolve(effectiveCwd, gitCommonDir);
|
|
57
|
+
const mainRepoRoot = dirname(absoluteCommonDir);
|
|
58
|
+
|
|
59
|
+
const worktreeTop = execSync('git rev-parse --show-toplevel', {
|
|
60
|
+
cwd: effectiveCwd,
|
|
61
|
+
encoding: 'utf-8',
|
|
62
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
63
|
+
}).trim();
|
|
64
|
+
|
|
65
|
+
if (mainRepoRoot !== worktreeTop) {
|
|
66
|
+
const lastSep = transcriptPath.lastIndexOf('/');
|
|
67
|
+
const sessionFile = lastSep !== -1 ? transcriptPath.substring(lastSep + 1) : '';
|
|
68
|
+
if (sessionFile) {
|
|
69
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || join(homedir(), '.claude');
|
|
70
|
+
const projectsDir = join(configDir, 'projects');
|
|
71
|
+
if (existsSync(projectsDir)) {
|
|
72
|
+
const encodedMain = mainRepoRoot.replace(/[/\\]/g, '-');
|
|
73
|
+
const resolvedPath = join(projectsDir, encodedMain, sessionFile);
|
|
74
|
+
try {
|
|
75
|
+
if (existsSync(resolvedPath)) return resolvedPath;
|
|
76
|
+
} catch { /* fallthrough */ }
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
} catch { /* best-effort fallback */ }
|
|
81
|
+
|
|
82
|
+
return transcriptPath;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function estimateContextPercent(transcriptPath) {
|
|
86
|
+
if (!transcriptPath) return 0;
|
|
87
|
+
|
|
88
|
+
let fd = -1;
|
|
89
|
+
try {
|
|
90
|
+
const stat = statSync(transcriptPath);
|
|
91
|
+
if (stat.size === 0) return 0;
|
|
92
|
+
|
|
93
|
+
fd = openSync(transcriptPath, 'r');
|
|
94
|
+
const readSize = Math.min(4096, stat.size);
|
|
95
|
+
const buf = Buffer.alloc(readSize);
|
|
96
|
+
readSync(fd, buf, 0, readSize, stat.size - readSize);
|
|
97
|
+
closeSync(fd);
|
|
98
|
+
fd = -1;
|
|
99
|
+
|
|
100
|
+
const tail = buf.toString('utf-8');
|
|
101
|
+
const windowMatch = tail.match(/"context_window"\s{0,5}:\s{0,5}(\d+)/g);
|
|
102
|
+
const inputMatch = tail.match(/"input_tokens"\s{0,5}:\s{0,5}(\d+)/g);
|
|
103
|
+
|
|
104
|
+
if (!windowMatch || !inputMatch) return 0;
|
|
105
|
+
|
|
106
|
+
const lastWindow = parseInt(windowMatch[windowMatch.length - 1].match(/(\d+)/)[1], 10);
|
|
107
|
+
const lastInput = parseInt(inputMatch[inputMatch.length - 1].match(/(\d+)/)[1], 10);
|
|
108
|
+
|
|
109
|
+
if (lastWindow === 0) return 0;
|
|
110
|
+
return Math.round((lastInput / lastWindow) * 100);
|
|
111
|
+
} catch {
|
|
112
|
+
return 0;
|
|
113
|
+
} finally {
|
|
114
|
+
if (fd !== -1) try { closeSync(fd); } catch { /* ignore */ }
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function buildPreflightRecoveryAdvice(contextPercent) {
|
|
119
|
+
return `[OMC] Preflight context guard: ${contextPercent}% used ` +
|
|
120
|
+
`(threshold: ${PREFLIGHT_CONTEXT_THRESHOLD}%). Avoid spawning additional agent-heavy tasks ` +
|
|
121
|
+
`until context is reduced. Safe recovery: (1) pause new Task fan-out, (2) run /compact now, ` +
|
|
122
|
+
`(3) if compact fails, open a fresh session and continue from .omc/state + .omc/notepad.md.`;
|
|
123
|
+
}
|
|
25
124
|
|
|
26
125
|
// Simple JSON field extraction
|
|
27
126
|
function extractJsonField(input, field, defaultValue = '') {
|
|
@@ -216,6 +315,85 @@ function generateMessage(toolName, todoStatus, modeActive = false) {
|
|
|
216
315
|
return '';
|
|
217
316
|
}
|
|
218
317
|
|
|
318
|
+
// ---------------------------------------------------------------------------
|
|
319
|
+
// Skill Active State (issue #1033)
|
|
320
|
+
// Writes skill-active-state.json so the persistent-mode Stop hook can prevent
|
|
321
|
+
// premature session termination while a skill is executing.
|
|
322
|
+
// ---------------------------------------------------------------------------
|
|
323
|
+
|
|
324
|
+
const SKILL_PROTECTION_CONFIGS = {
|
|
325
|
+
none: { maxReinforcements: 0, staleTtlMs: 0 },
|
|
326
|
+
light: { maxReinforcements: 3, staleTtlMs: 5 * 60 * 1000 },
|
|
327
|
+
medium: { maxReinforcements: 5, staleTtlMs: 15 * 60 * 1000 },
|
|
328
|
+
heavy: { maxReinforcements: 10, staleTtlMs: 30 * 60 * 1000 },
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
const SKILL_PROTECTION_MAP = {
|
|
332
|
+
autopilot: 'none', ralph: 'none', ultrawork: 'none', team: 'none',
|
|
333
|
+
'omc-teams': 'none', ultraqa: 'none', cancel: 'none',
|
|
334
|
+
trace: 'none', hud: 'none', 'omc-doctor': 'none', 'omc-help': 'none',
|
|
335
|
+
'learn-about-omc': 'none', note: 'none',
|
|
336
|
+
tdd: 'light', 'build-fix': 'light', analyze: 'light', skill: 'light',
|
|
337
|
+
'configure-notifications': 'light',
|
|
338
|
+
'code-review': 'medium', 'security-review': 'medium', plan: 'medium',
|
|
339
|
+
ralplan: 'medium', review: 'medium', 'external-context': 'medium',
|
|
340
|
+
sciomc: 'medium', learner: 'medium', 'omc-setup': 'medium',
|
|
341
|
+
'mcp-setup': 'medium', 'project-session-manager': 'medium',
|
|
342
|
+
'writer-memory': 'medium', 'ralph-init': 'medium', ccg: 'medium',
|
|
343
|
+
deepinit: 'heavy',
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
function getSkillProtectionLevel(skillName) {
|
|
347
|
+
const normalized = (skillName || '').toLowerCase().replace(/^oh-my-claudecode:/, '');
|
|
348
|
+
return SKILL_PROTECTION_MAP[normalized] || 'light';
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function extractSkillName(toolInput) {
|
|
352
|
+
if (!toolInput || typeof toolInput !== 'object') return null;
|
|
353
|
+
const rawSkill = toolInput.skill || toolInput.skill_name || toolInput.skillName || toolInput.command || null;
|
|
354
|
+
if (typeof rawSkill !== 'string' || !rawSkill.trim()) return null;
|
|
355
|
+
const normalized = rawSkill.trim();
|
|
356
|
+
return normalized.includes(':') ? normalized.split(':').at(-1).toLowerCase() : normalized.toLowerCase();
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function writeSkillActiveState(directory, skillName, sessionId) {
|
|
360
|
+
const protection = getSkillProtectionLevel(skillName);
|
|
361
|
+
if (protection === 'none') return;
|
|
362
|
+
|
|
363
|
+
const config = SKILL_PROTECTION_CONFIGS[protection];
|
|
364
|
+
const now = new Date().toISOString();
|
|
365
|
+
const normalized = (skillName || '').toLowerCase().replace(/^oh-my-claudecode:/, '');
|
|
366
|
+
|
|
367
|
+
const state = {
|
|
368
|
+
active: true,
|
|
369
|
+
skill_name: normalized,
|
|
370
|
+
session_id: sessionId || undefined,
|
|
371
|
+
started_at: now,
|
|
372
|
+
last_checked_at: now,
|
|
373
|
+
reinforcement_count: 0,
|
|
374
|
+
max_reinforcements: config.maxReinforcements,
|
|
375
|
+
stale_ttl_ms: config.staleTtlMs,
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
const stateDir = join(directory, '.omc', 'state');
|
|
379
|
+
const safeSessionId = sessionId && SESSION_ID_PATTERN.test(sessionId) ? sessionId : '';
|
|
380
|
+
const targetDir = safeSessionId
|
|
381
|
+
? join(stateDir, 'sessions', safeSessionId)
|
|
382
|
+
: stateDir;
|
|
383
|
+
const targetPath = join(targetDir, 'skill-active-state.json');
|
|
384
|
+
|
|
385
|
+
try {
|
|
386
|
+
if (!existsSync(targetDir)) {
|
|
387
|
+
mkdirSync(targetDir, { recursive: true });
|
|
388
|
+
}
|
|
389
|
+
const tmpPath = targetPath + '.tmp';
|
|
390
|
+
writeFileSync(tmpPath, JSON.stringify(state, null, 2), { mode: 0o600 });
|
|
391
|
+
renameSync(tmpPath, targetPath);
|
|
392
|
+
} catch {
|
|
393
|
+
// Best-effort; don't fail the hook
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
219
397
|
// Record Skill/Task invocations to flow trace (best-effort)
|
|
220
398
|
async function recordToolInvocation(data, directory) {
|
|
221
399
|
try {
|
|
@@ -252,6 +430,19 @@ async function main() {
|
|
|
252
430
|
try { data = JSON.parse(input); } catch {}
|
|
253
431
|
recordToolInvocation(data, directory);
|
|
254
432
|
|
|
433
|
+
// Activate skill state when Skill tool is invoked (issue #1033)
|
|
434
|
+
// Writes skill-active-state.json so the persistent-mode Stop hook can
|
|
435
|
+
// prevent premature session termination while a skill is executing.
|
|
436
|
+
if (toolName === 'Skill') {
|
|
437
|
+
const toolInput = data.toolInput || data.tool_input || {};
|
|
438
|
+
const skillName = extractSkillName(toolInput);
|
|
439
|
+
if (skillName) {
|
|
440
|
+
const sid = typeof data.session_id === 'string' ? data.session_id
|
|
441
|
+
: typeof data.sessionId === 'string' ? data.sessionId : '';
|
|
442
|
+
writeSkillActiveState(directory, skillName, sid);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
255
446
|
const sessionId =
|
|
256
447
|
typeof data.session_id === 'string'
|
|
257
448
|
? data.session_id
|
|
@@ -287,6 +478,20 @@ async function main() {
|
|
|
287
478
|
|
|
288
479
|
const todoStatus = getTodoStatus(directory);
|
|
289
480
|
|
|
481
|
+
if (AGENT_HEAVY_TOOLS.has(toolName)) {
|
|
482
|
+
const rawTranscriptPath = data.transcript_path || data.transcriptPath || '';
|
|
483
|
+
const transcriptPath = resolveTranscriptPath(rawTranscriptPath, directory);
|
|
484
|
+
const contextPercent = estimateContextPercent(transcriptPath);
|
|
485
|
+
|
|
486
|
+
if (contextPercent >= PREFLIGHT_CONTEXT_THRESHOLD) {
|
|
487
|
+
console.log(JSON.stringify({
|
|
488
|
+
decision: 'block',
|
|
489
|
+
reason: buildPreflightRecoveryAdvice(contextPercent),
|
|
490
|
+
}));
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
290
495
|
let message;
|
|
291
496
|
if (toolName === 'Task' || toolName === 'TaskCreate' || toolName === 'TaskUpdate') {
|
|
292
497
|
const toolInput = data.toolInput || data.tool_input || null;
|
|
@@ -9,6 +9,7 @@ const PROVIDER_BINARIES = {
|
|
|
9
9
|
codex: 'codex',
|
|
10
10
|
gemini: 'gemini',
|
|
11
11
|
};
|
|
12
|
+
const SHOULD_USE_WINDOWS_SHELL = process.platform === 'win32';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Build CLI args for a given provider.
|
|
@@ -74,13 +75,37 @@ function parseArgs(argv) {
|
|
|
74
75
|
return { provider, prompt: rest.join(' ').trim() };
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
const CODEX_STRIPPED_ENV_VARS = new Set(['RUST_LOG', 'RUST_BACKTRACE', 'RUST_LIB_BACKTRACE']);
|
|
79
|
+
|
|
80
|
+
function buildProviderEnv(provider, env = process.env) {
|
|
81
|
+
if (provider !== 'codex') {
|
|
82
|
+
return env;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return Object.fromEntries(
|
|
86
|
+
Object.entries(env).filter(([key]) => !CODEX_STRIPPED_ENV_VARS.has(key)),
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function ensureBinary(provider, binary) {
|
|
78
91
|
const probe = spawnSync(binary, ['--version'], {
|
|
79
92
|
stdio: 'ignore',
|
|
80
93
|
encoding: 'utf8',
|
|
94
|
+
env: buildProviderEnv(provider),
|
|
95
|
+
shell: SHOULD_USE_WINDOWS_SHELL,
|
|
81
96
|
});
|
|
82
97
|
|
|
83
|
-
|
|
98
|
+
const isMissingOnWindowsShell = SHOULD_USE_WINDOWS_SHELL
|
|
99
|
+
&& probe.status !== 0
|
|
100
|
+
&& (() => {
|
|
101
|
+
const whereResult = spawnSync('where', [binary], {
|
|
102
|
+
encoding: 'utf8',
|
|
103
|
+
env: buildProviderEnv(provider),
|
|
104
|
+
});
|
|
105
|
+
return whereResult.status !== 0 || !whereResult.stdout?.trim();
|
|
106
|
+
})();
|
|
107
|
+
|
|
108
|
+
if ((probe.error && probe.error.code === 'ENOENT') || isMissingOnWindowsShell) {
|
|
84
109
|
const verify = `${binary} --version`;
|
|
85
110
|
console.error(`[ask-${binary}] Missing required local CLI binary: ${binary}`);
|
|
86
111
|
console.error(`[ask-${binary}] Install/configure ${binary} CLI, then verify with: ${verify}`);
|
|
@@ -182,12 +207,14 @@ async function main() {
|
|
|
182
207
|
const { provider, prompt } = parseArgs(process.argv.slice(2));
|
|
183
208
|
const binary = PROVIDER_BINARIES[provider];
|
|
184
209
|
|
|
185
|
-
ensureBinary(binary);
|
|
210
|
+
ensureBinary(provider, binary);
|
|
186
211
|
|
|
187
212
|
const providerArgs = buildProviderArgs(provider, prompt);
|
|
188
213
|
const run = spawnSync(binary, providerArgs, {
|
|
189
214
|
encoding: 'utf8',
|
|
190
215
|
maxBuffer: 10 * 1024 * 1024,
|
|
216
|
+
env: buildProviderEnv(provider),
|
|
217
|
+
shell: SHOULD_USE_WINDOWS_SHELL,
|
|
191
218
|
});
|
|
192
219
|
|
|
193
220
|
const stdout = run.stdout || '';
|
|
@@ -353,7 +353,7 @@ async function main() {
|
|
|
353
353
|
You have an active ultrawork session from ${ultraworkState.started_at}.
|
|
354
354
|
Original task: ${ultraworkState.original_prompt}
|
|
355
355
|
|
|
356
|
-
|
|
356
|
+
Treat this as prior-session context only. Prioritize the user's newest request, and resume ultrawork only if the user explicitly asks to continue it.
|
|
357
357
|
|
|
358
358
|
</session-restore>
|
|
359
359
|
|
|
@@ -387,7 +387,7 @@ You have an active ralph-loop session.
|
|
|
387
387
|
Original task: ${ralphState.prompt || 'Task in progress'}
|
|
388
388
|
Iteration: ${ralphState.iteration || 1}/${ralphState.max_iterations || 10}
|
|
389
389
|
|
|
390
|
-
|
|
390
|
+
Treat this as prior-session context only. Prioritize the user's newest request, and resume the ralph loop only if the user explicitly asks to continue it.
|
|
391
391
|
|
|
392
392
|
</session-restore>
|
|
393
393
|
|
|
@@ -420,7 +420,7 @@ Continue working until the task is verified complete.
|
|
|
420
420
|
[PENDING TASKS DETECTED]
|
|
421
421
|
|
|
422
422
|
You have ${incompleteCount} incomplete tasks from a previous session.
|
|
423
|
-
|
|
423
|
+
Treat this as prior-session context only. Prioritize the user's newest request, and resume these tasks only if the user explicitly asks to continue them.
|
|
424
424
|
|
|
425
425
|
</session-restore>
|
|
426
426
|
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# setup-claude-md.sh - Unified CLAUDE.md download/merge script
|
|
3
|
+
# Usage: setup-claude-md.sh <local|global>
|
|
4
|
+
#
|
|
5
|
+
# Handles: version extraction, backup, download, marker stripping, merge, version reporting.
|
|
6
|
+
# For global mode, also cleans up legacy hooks.
|
|
7
|
+
|
|
8
|
+
set -euo pipefail
|
|
9
|
+
|
|
10
|
+
MODE="${1:?Usage: setup-claude-md.sh <local|global>}"
|
|
11
|
+
DOWNLOAD_URL="https://raw.githubusercontent.com/Yeachan-Heo/oh-my-claudecode/main/docs/CLAUDE.md"
|
|
12
|
+
|
|
13
|
+
# Determine target path
|
|
14
|
+
if [ "$MODE" = "local" ]; then
|
|
15
|
+
mkdir -p .claude
|
|
16
|
+
TARGET_PATH=".claude/CLAUDE.md"
|
|
17
|
+
elif [ "$MODE" = "global" ]; then
|
|
18
|
+
TARGET_PATH="$HOME/.claude/CLAUDE.md"
|
|
19
|
+
else
|
|
20
|
+
echo "ERROR: Invalid mode '$MODE'. Use 'local' or 'global'." >&2
|
|
21
|
+
exit 1
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
# Extract old version before download
|
|
25
|
+
OLD_VERSION=$(grep -m1 'OMC:VERSION:' "$TARGET_PATH" 2>/dev/null | sed -E 's/.*OMC:VERSION:([^ ]+).*/\1/' || true)
|
|
26
|
+
if [ -z "$OLD_VERSION" ]; then
|
|
27
|
+
OLD_VERSION=$(omc --version 2>/dev/null | head -1 || true)
|
|
28
|
+
fi
|
|
29
|
+
if [ -z "$OLD_VERSION" ]; then
|
|
30
|
+
OLD_VERSION="none"
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# Backup existing
|
|
34
|
+
if [ -f "$TARGET_PATH" ]; then
|
|
35
|
+
BACKUP_DATE=$(date +%Y-%m-%d_%H%M%S)
|
|
36
|
+
BACKUP_PATH="${TARGET_PATH}.backup.${BACKUP_DATE}"
|
|
37
|
+
cp "$TARGET_PATH" "$BACKUP_PATH"
|
|
38
|
+
echo "Backed up existing CLAUDE.md to $BACKUP_PATH"
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# Download fresh OMC content to temp file
|
|
42
|
+
TEMP_OMC=$(mktemp /tmp/omc-claude-XXXXXX.md)
|
|
43
|
+
trap 'rm -f "$TEMP_OMC"' EXIT
|
|
44
|
+
curl -fsSL "$DOWNLOAD_URL" -o "$TEMP_OMC"
|
|
45
|
+
|
|
46
|
+
if [ ! -s "$TEMP_OMC" ]; then
|
|
47
|
+
echo "ERROR: Failed to download CLAUDE.md. Aborting."
|
|
48
|
+
echo "FALLBACK: Manually download from: $DOWNLOAD_URL"
|
|
49
|
+
rm -f "$TEMP_OMC"
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
# Strip existing markers from downloaded content (idempotency)
|
|
54
|
+
# Use awk for cross-platform compatibility (GNU/BSD)
|
|
55
|
+
if grep -q '<!-- OMC:START -->' "$TEMP_OMC"; then
|
|
56
|
+
awk '/<!-- OMC:END -->/{p=0} p; /<!-- OMC:START -->/{p=1}' "$TEMP_OMC" > "${TEMP_OMC}.clean"
|
|
57
|
+
mv "${TEMP_OMC}.clean" "$TEMP_OMC"
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
if [ ! -f "$TARGET_PATH" ]; then
|
|
61
|
+
# Fresh install: wrap in markers
|
|
62
|
+
{
|
|
63
|
+
echo '<!-- OMC:START -->'
|
|
64
|
+
cat "$TEMP_OMC"
|
|
65
|
+
echo '<!-- OMC:END -->'
|
|
66
|
+
} > "$TARGET_PATH"
|
|
67
|
+
rm -f "$TEMP_OMC"
|
|
68
|
+
echo "Installed CLAUDE.md (fresh)"
|
|
69
|
+
else
|
|
70
|
+
# Merge: preserve user content outside OMC markers
|
|
71
|
+
if grep -q '<!-- OMC:START -->' "$TARGET_PATH"; then
|
|
72
|
+
# Has markers: remove ALL complete OMC blocks, preserve only real user text
|
|
73
|
+
# Use perl -0 for a global multiline regex replace (portable across GNU/BSD environments)
|
|
74
|
+
perl -0pe 's/^<!-- OMC:START -->\R[\s\S]*?^<!-- OMC:END -->(?:\R)?//msg; s/^<!-- User customizations(?: \([^)]+\))? -->\R?//mg; s/\A(?:[ \t]*\R)+//; s/(?:\R[ \t]*)+\z//;' \
|
|
75
|
+
"$TARGET_PATH" > "${TARGET_PATH}.preserved"
|
|
76
|
+
|
|
77
|
+
if grep -Eq '^<!-- OMC:(START|END) -->$' "${TARGET_PATH}.preserved"; then
|
|
78
|
+
# Corrupted/unmatched markers remain: preserve the whole original file for manual recovery
|
|
79
|
+
OLD_CONTENT=$(cat "$TARGET_PATH")
|
|
80
|
+
{
|
|
81
|
+
echo '<!-- OMC:START -->'
|
|
82
|
+
cat "$TEMP_OMC"
|
|
83
|
+
echo '<!-- OMC:END -->'
|
|
84
|
+
echo ""
|
|
85
|
+
echo "<!-- User customizations (recovered from corrupted markers) -->"
|
|
86
|
+
printf '%s\n' "$OLD_CONTENT"
|
|
87
|
+
} > "${TARGET_PATH}.tmp"
|
|
88
|
+
else
|
|
89
|
+
PRESERVED_CONTENT=$(cat "${TARGET_PATH}.preserved")
|
|
90
|
+
{
|
|
91
|
+
echo '<!-- OMC:START -->'
|
|
92
|
+
cat "$TEMP_OMC"
|
|
93
|
+
echo '<!-- OMC:END -->'
|
|
94
|
+
if printf '%s' "$PRESERVED_CONTENT" | grep -q '[^[:space:]]'; then
|
|
95
|
+
echo ""
|
|
96
|
+
echo "<!-- User customizations -->"
|
|
97
|
+
printf '%s\n' "$PRESERVED_CONTENT"
|
|
98
|
+
fi
|
|
99
|
+
} > "${TARGET_PATH}.tmp"
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
mv "${TARGET_PATH}.tmp" "$TARGET_PATH"
|
|
103
|
+
rm -f "${TARGET_PATH}.preserved"
|
|
104
|
+
echo "Updated OMC section (user customizations preserved)"
|
|
105
|
+
else
|
|
106
|
+
# No markers: wrap new content in markers, append old content as user section
|
|
107
|
+
OLD_CONTENT=$(cat "$TARGET_PATH")
|
|
108
|
+
{
|
|
109
|
+
echo '<!-- OMC:START -->'
|
|
110
|
+
cat "$TEMP_OMC"
|
|
111
|
+
echo '<!-- OMC:END -->'
|
|
112
|
+
echo ""
|
|
113
|
+
echo "<!-- User customizations (migrated from previous CLAUDE.md) -->"
|
|
114
|
+
printf '%s\n' "$OLD_CONTENT"
|
|
115
|
+
} > "${TARGET_PATH}.tmp"
|
|
116
|
+
mv "${TARGET_PATH}.tmp" "$TARGET_PATH"
|
|
117
|
+
echo "Migrated existing CLAUDE.md (added OMC markers, preserved old content)"
|
|
118
|
+
fi
|
|
119
|
+
rm -f "$TEMP_OMC"
|
|
120
|
+
fi
|
|
121
|
+
|
|
122
|
+
# Extract new version and report
|
|
123
|
+
NEW_VERSION=$(grep -m1 'OMC:VERSION:' "$TARGET_PATH" 2>/dev/null | sed -E 's/.*OMC:VERSION:([^ ]+).*/\1/' || true)
|
|
124
|
+
if [ -z "$NEW_VERSION" ]; then
|
|
125
|
+
NEW_VERSION=$(omc --version 2>/dev/null | head -1 || true)
|
|
126
|
+
fi
|
|
127
|
+
if [ -z "$NEW_VERSION" ]; then
|
|
128
|
+
NEW_VERSION="unknown"
|
|
129
|
+
fi
|
|
130
|
+
if [ "$OLD_VERSION" = "none" ]; then
|
|
131
|
+
echo "Installed CLAUDE.md: $NEW_VERSION"
|
|
132
|
+
elif [ "$OLD_VERSION" = "$NEW_VERSION" ]; then
|
|
133
|
+
echo "CLAUDE.md unchanged: $NEW_VERSION"
|
|
134
|
+
else
|
|
135
|
+
echo "Updated CLAUDE.md: $OLD_VERSION -> $NEW_VERSION"
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
# Legacy hooks cleanup (global mode only)
|
|
139
|
+
if [ "$MODE" = "global" ]; then
|
|
140
|
+
rm -f ~/.claude/hooks/keyword-detector.sh
|
|
141
|
+
rm -f ~/.claude/hooks/stop-continuation.sh
|
|
142
|
+
rm -f ~/.claude/hooks/persistent-mode.sh
|
|
143
|
+
rm -f ~/.claude/hooks/session-start.sh
|
|
144
|
+
echo "Legacy hooks cleaned"
|
|
145
|
+
|
|
146
|
+
# Check for manual hook entries in settings.json
|
|
147
|
+
SETTINGS_FILE="$HOME/.claude/settings.json"
|
|
148
|
+
if [ -f "$SETTINGS_FILE" ]; then
|
|
149
|
+
if jq -e '.hooks' "$SETTINGS_FILE" > /dev/null 2>&1; then
|
|
150
|
+
echo ""
|
|
151
|
+
echo "NOTE: Found legacy hooks in settings.json. These should be removed since"
|
|
152
|
+
echo "the plugin now provides hooks automatically. Remove the \"hooks\" section"
|
|
153
|
+
echo "from ~/.claude/settings.json to prevent duplicate hook execution."
|
|
154
|
+
fi
|
|
155
|
+
fi
|
|
156
|
+
fi
|
|
157
|
+
|
|
158
|
+
# Verify plugin installation
|
|
159
|
+
grep -q "oh-my-claudecode" ~/.claude/settings.json && echo "Plugin verified" || echo "Plugin NOT found - run: claude /install-plugin oh-my-claudecode"
|