aiwcli 0.15.5 → 0.17.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/README.md +108 -1124
- package/bin/run.js +0 -4
- package/dist/capabilities/branch/adapters.d.ts +2 -0
- package/dist/capabilities/branch/adapters.js +21 -0
- package/dist/capabilities/branch/contracts.d.ts +57 -0
- package/dist/capabilities/branch/contracts.js +1 -0
- package/dist/capabilities/branch/control-plane.d.ts +2 -0
- package/dist/capabilities/branch/control-plane.js +343 -0
- package/dist/capabilities/branch/runtime-core.d.ts +5 -0
- package/dist/capabilities/branch/runtime-core.js +36 -0
- package/dist/capabilities/installation/control-plane/clean-command.d.ts +41 -0
- package/dist/capabilities/installation/control-plane/clean-command.js +196 -0
- package/dist/capabilities/installation/control-plane/clear-command.d.ts +162 -0
- package/dist/capabilities/installation/control-plane/clear-command.js +1249 -0
- package/dist/capabilities/installation/control-plane/init-command.d.ts +81 -0
- package/dist/capabilities/installation/control-plane/init-command.js +449 -0
- package/dist/capabilities/launch/contracts.d.ts +86 -0
- package/dist/capabilities/launch/contracts.js +1 -0
- package/dist/capabilities/launch/control-plane/execute-launch.d.ts +2 -0
- package/dist/capabilities/launch/control-plane/execute-launch.js +261 -0
- package/dist/capabilities/launch/runtime-core/launch-decisions.d.ts +82 -0
- package/dist/capabilities/launch/runtime-core/launch-decisions.js +202 -0
- package/dist/capabilities/launch/runtime-core/launch-options.d.ts +14 -0
- package/dist/capabilities/launch/runtime-core/launch-options.js +69 -0
- package/dist/cli/base-command.d.ts +18 -0
- package/dist/cli/base-command.js +55 -0
- package/dist/commands/branch.d.ts +1 -21
- package/dist/commands/branch.js +25 -417
- package/dist/commands/clean.d.ts +1 -41
- package/dist/commands/clean.js +1 -196
- package/dist/commands/clear.d.ts +1 -161
- package/dist/commands/clear.js +1 -1121
- package/dist/commands/init/index.d.ts +1 -98
- package/dist/commands/init/index.js +4 -478
- package/dist/commands/launch.d.ts +32 -12
- package/dist/commands/launch.js +107 -166
- package/dist/lib/claude-settings-types.d.ts +31 -19
- package/dist/lib/config.js +1 -2
- package/dist/lib/context/context-formatter.d.ts +74 -0
- package/dist/lib/context/context-formatter.js +493 -0
- package/dist/lib/context/context-selector.d.ts +42 -0
- package/dist/lib/context/context-selector.js +451 -0
- package/dist/lib/context/context-store.d.ts +100 -0
- package/dist/lib/context/context-store.js +644 -0
- package/dist/lib/context/plan-manager.d.ts +54 -0
- package/dist/lib/context/plan-manager.js +282 -0
- package/dist/lib/context/task-tracker.d.ts +44 -0
- package/dist/lib/context/task-tracker.js +146 -0
- package/dist/lib/core-ide-base.d.ts +4 -0
- package/dist/lib/core-ide-base.js +77 -0
- package/dist/lib/core-installer.d.ts +5 -0
- package/dist/lib/core-installer.js +33 -0
- package/dist/lib/debug.d.ts +0 -10
- package/dist/lib/debug.js +0 -10
- package/dist/lib/env-sanitizer.d.ts +25 -0
- package/dist/lib/env-sanitizer.js +46 -0
- package/dist/lib/errors.d.ts +0 -13
- package/dist/lib/errors.js +0 -15
- package/dist/lib/git-exclude-manager.d.ts +2 -2
- package/dist/lib/git-exclude-manager.js +3 -3
- package/dist/lib/hooks/context-monitor-logic.d.ts +6 -0
- package/dist/lib/hooks/context-monitor-logic.js +25 -0
- package/dist/lib/hooks/hook-utils.d.ts +143 -0
- package/dist/lib/hooks/hook-utils.js +620 -0
- package/dist/lib/hooks/prompt-binding-logic.d.ts +7 -0
- package/dist/lib/hooks/prompt-binding-logic.js +50 -0
- package/dist/lib/hooks/session-end-logic.d.ts +5 -0
- package/dist/lib/hooks/session-end-logic.js +51 -0
- package/dist/lib/hooks-merger.js +25 -19
- package/dist/lib/ide-path-resolver.d.ts +19 -7
- package/dist/lib/ide-path-resolver.js +25 -9
- package/dist/lib/install-state.d.ts +34 -0
- package/dist/lib/install-state.js +154 -0
- package/dist/lib/json-io.d.ts +12 -0
- package/dist/lib/json-io.js +30 -0
- package/dist/lib/lsp-patch.d.ts +12 -0
- package/dist/lib/lsp-patch.js +156 -0
- package/dist/lib/multiplexer.d.ts +65 -0
- package/dist/lib/multiplexer.js +38 -0
- package/dist/lib/multiplexers/psmux.d.ts +55 -0
- package/dist/lib/multiplexers/psmux.js +324 -0
- package/dist/lib/multiplexers/tmux.d.ts +36 -0
- package/dist/lib/multiplexers/tmux.js +221 -0
- package/dist/lib/multiplexers/wezterm.d.ts +38 -0
- package/dist/lib/multiplexers/wezterm.js +225 -0
- package/dist/lib/mux-utils.d.ts +6 -0
- package/dist/lib/mux-utils.js +36 -0
- package/dist/lib/paths.d.ts +2 -2
- package/dist/lib/paths.js +2 -2
- package/dist/lib/platform-commands.d.ts +27 -0
- package/dist/lib/platform-commands.js +49 -0
- package/dist/lib/prompt-file-manager.d.ts +23 -0
- package/dist/lib/prompt-file-manager.js +41 -0
- package/dist/lib/runtime/agent-launcher.d.ts +67 -0
- package/dist/lib/runtime/agent-launcher.js +262 -0
- package/dist/lib/runtime/aiw-cli.d.ts +39 -0
- package/dist/lib/runtime/aiw-cli.js +76 -0
- package/dist/lib/runtime/atomic-write.d.ts +19 -0
- package/dist/lib/runtime/atomic-write.js +121 -0
- package/dist/lib/runtime/cli-args.d.ts +58 -0
- package/dist/lib/runtime/cli-args.js +200 -0
- package/dist/lib/runtime/constants.d.ts +56 -0
- package/dist/lib/runtime/constants.js +230 -0
- package/dist/lib/runtime/executable-policy.d.ts +16 -0
- package/dist/lib/runtime/executable-policy.js +57 -0
- package/dist/lib/runtime/git-state.d.ts +9 -0
- package/dist/lib/runtime/git-state.js +59 -0
- package/dist/lib/runtime/inference.d.ts +37 -0
- package/dist/lib/runtime/inference.js +251 -0
- package/dist/lib/runtime/lint-dispatch.d.ts +40 -0
- package/dist/lib/runtime/lint-dispatch.js +285 -0
- package/dist/lib/runtime/logger.d.ts +66 -0
- package/dist/lib/runtime/logger.js +201 -0
- package/dist/lib/runtime/models.d.ts +20 -0
- package/dist/lib/runtime/models.js +20 -0
- package/dist/lib/runtime/platform-adapter.d.ts +7 -0
- package/dist/lib/runtime/platform-adapter.js +21 -0
- package/dist/lib/runtime/preflight.d.ts +24 -0
- package/dist/lib/runtime/preflight.js +65 -0
- package/dist/lib/runtime/sentinel-ipc.d.ts +14 -0
- package/dist/lib/runtime/sentinel-ipc.js +67 -0
- package/dist/lib/runtime/state-io.d.ts +31 -0
- package/dist/lib/runtime/state-io.js +179 -0
- package/dist/lib/runtime/stop-words.d.ts +20 -0
- package/dist/lib/runtime/stop-words.js +150 -0
- package/dist/lib/runtime/subprocess-utils.d.ts +29 -0
- package/dist/lib/runtime/subprocess-utils.js +96 -0
- package/dist/lib/runtime/tmux-preflight.d.ts +13 -0
- package/dist/lib/runtime/tmux-preflight.js +78 -0
- package/dist/lib/runtime/utils.d.ts +62 -0
- package/dist/lib/runtime/utils.js +192 -0
- package/dist/lib/schemas.d.ts +250 -0
- package/dist/lib/schemas.js +216 -0
- package/dist/lib/sentinel-manager.d.ts +32 -0
- package/dist/lib/sentinel-manager.js +62 -0
- package/dist/lib/sentinel-wrapper.d.ts +10 -0
- package/dist/lib/sentinel-wrapper.js +29 -0
- package/dist/lib/settings-hierarchy.js +3 -20
- package/dist/lib/shell-adapters/bash-adapter.d.ts +18 -0
- package/dist/lib/shell-adapters/bash-adapter.js +69 -0
- package/dist/lib/shell-adapters/index.d.ts +5 -0
- package/dist/lib/shell-adapters/index.js +7 -0
- package/dist/lib/shell-adapters/powershell-adapter.d.ts +18 -0
- package/dist/lib/shell-adapters/powershell-adapter.js +62 -0
- package/dist/lib/shell-adapters/shell-adapter.d.ts +45 -0
- package/dist/lib/shell-adapters/shell-adapter.js +5 -0
- package/dist/lib/shell-quoting.d.ts +5 -0
- package/dist/lib/shell-quoting.js +17 -0
- package/dist/lib/spawn-errors.d.ts +9 -0
- package/dist/lib/spawn-errors.js +29 -0
- package/dist/lib/spawn.js +5 -11
- package/dist/lib/spinner.d.ts +0 -5
- package/dist/lib/spinner.js +0 -16
- package/dist/lib/template-installer.d.ts +14 -5
- package/dist/lib/template-installer.js +40 -38
- package/dist/lib/template-resolver.d.ts +6 -7
- package/dist/lib/template-resolver.js +26 -21
- package/dist/lib/template-settings-reconstructor.d.ts +7 -2
- package/dist/lib/template-settings-reconstructor.js +76 -45
- package/dist/lib/terminal-strategy.d.ts +12 -0
- package/dist/lib/terminal-strategy.js +55 -0
- package/dist/lib/terminal.d.ts +34 -4
- package/dist/lib/terminal.js +192 -119
- package/dist/lib/tmux-pane-placement.d.ts +17 -0
- package/dist/lib/tmux-pane-placement.js +58 -0
- package/dist/lib/tmux-primitives.d.ts +3 -0
- package/dist/lib/tmux-primitives.js +11 -0
- package/dist/lib/tmux-session.d.ts +32 -0
- package/dist/lib/tmux-session.js +87 -0
- package/dist/lib/tty-detection.js +1 -1
- package/dist/lib/types.d.ts +168 -0
- package/dist/lib/types.js +6 -0
- package/dist/lib/version.d.ts +1 -1
- package/dist/lib/version.js +1 -1
- package/dist/lib/windsurf-hooks-hierarchy.js +6 -23
- package/dist/platform/launch.d.ts +11 -0
- package/dist/platform/launch.js +11 -0
- package/dist/templates/CLAUDE.md +30 -40
- package/dist/templates/cc-native/.claude/settings.json +26 -36
- package/dist/templates/cc-native/CC-NATIVE-README.md +1 -1
- package/dist/templates/cc-native/TEMPLATE-SCHEMA.md +20 -12
- package/dist/templates/cc-native/_cc-native/cc-native.config.json +2 -6
- package/dist/templates/cc-native/_cc-native/hooks/CLAUDE.md +39 -59
- package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.ts +9 -11
- package/dist/templates/cc-native/_cc-native/hooks/enhance_plan_post_subagent.ts +2 -2
- package/dist/templates/cc-native/_cc-native/hooks/enhance_plan_post_write.ts +4 -5
- package/dist/templates/cc-native/_cc-native/hooks/mark_questions_asked.ts +4 -4
- package/dist/templates/cc-native/_cc-native/hooks/plan_questions_early.ts +2 -27
- package/dist/templates/cc-native/_cc-native/hooks/validate_task_prompt.ts +7 -7
- package/dist/templates/cc-native/_cc-native/lib-ts/.mocharc.json +9 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/aggregate-agents.test.ts +118 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/artifacts.test.ts +234 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/cc-native-state.test.ts +170 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/cli-output-parser.test.ts +73 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/config.test.ts +64 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/constants.test.ts +40 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/debug.test.ts +42 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/exports.test.ts +58 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/helpers.ts +107 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/hooks/add-plan-context.hook.test.ts +97 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/hooks/plan-questions.hook.test.ts +81 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/hooks/plan-review.hook.test.ts +71 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/json-parser.test.ts +99 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/orchestrator-agent.test.ts +288 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/orchestrator.test.ts +48 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/reviewers.test.ts +32 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/state.test.ts +124 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/verdict.test.ts +93 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/agent-selection.ts +163 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/aggregate-agents.ts +6 -14
- package/dist/templates/cc-native/_cc-native/{artifacts/lib → lib-ts/artifacts}/format.ts +597 -599
- package/dist/templates/cc-native/_cc-native/{artifacts/lib → lib-ts/artifacts}/index.ts +26 -26
- package/dist/templates/cc-native/_cc-native/{artifacts/lib → lib-ts/artifacts}/tracker.ts +106 -107
- package/dist/templates/cc-native/_cc-native/{artifacts/lib → lib-ts/artifacts}/write.ts +118 -119
- package/dist/templates/cc-native/_cc-native/lib-ts/artifacts.ts +21 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/cc-native-state.ts +17 -16
- package/dist/templates/cc-native/_cc-native/lib-ts/cli-output-parser.ts +132 -10
- package/dist/templates/cc-native/_cc-native/lib-ts/config.ts +1 -1
- package/dist/templates/cc-native/_cc-native/lib-ts/constants.ts +6 -6
- package/dist/templates/cc-native/_cc-native/lib-ts/corroboration.ts +119 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/debug.ts +2 -3
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/graduation.ts +132 -132
- package/dist/templates/cc-native/_cc-native/lib-ts/index.ts +88 -86
- package/dist/templates/cc-native/_cc-native/lib-ts/json-parser.ts +5 -6
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/orchestrator.ts +70 -70
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/output-builder.ts +130 -121
- package/dist/templates/cc-native/_cc-native/lib-ts/package-lock.json +1679 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/package.json +24 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/plan-discovery.ts +5 -5
- package/dist/templates/cc-native/_cc-native/lib-ts/plan-enhancement.ts +1 -6
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/plan-questions.ts +101 -101
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/review-pipeline.ts +511 -543
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/__tests__/agent-providers.test.ts +262 -0
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/agent.ts +71 -85
- package/dist/templates/{_shared/lib-ts/agent-exec → cc-native/_cc-native/lib-ts/reviewers/base}/base-agent.ts +138 -150
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/index.ts +12 -12
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/providers/claude-agent.ts +66 -57
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/providers/codex-agent.ts +185 -200
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/providers/gemini-agent.ts +39 -40
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/providers/orchestrator-claude-agent.ts +196 -225
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/schemas.ts +201 -201
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/types.ts +21 -23
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/__tests__/hyde.test.ts +365 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/__tests__/ollama-client.test.ts +223 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/embedding-indexer.ts +12 -16
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/hyde.ts +3 -2
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/index.ts +31 -31
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/logger.ts +7 -8
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/ollama-client.ts +7 -9
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/retrieval-pipeline.ts +16 -19
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-indexer.ts +37 -41
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-loader.ts +33 -43
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-searcher.ts +20 -20
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/types.ts +9 -10
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/vector-store.ts +3 -4
- package/dist/templates/cc-native/_cc-native/lib-ts/settings.ts +50 -126
- package/dist/templates/cc-native/_cc-native/lib-ts/state.ts +20 -22
- package/dist/templates/cc-native/_cc-native/lib-ts/tsconfig.json +2 -2
- package/dist/templates/cc-native/_cc-native/lib-ts/types.ts +14 -89
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/verdict.ts +72 -72
- package/dist/templates/cc-native/_cc-native/plan-review/CLAUDE.md +38 -1
- package/dist/templates/cc-native/_cc-native/plan-review/lib/__tests__/agent-selection.test.ts +345 -0
- package/dist/templates/cc-native/_cc-native/plan-review/lib/__tests__/preflight.test.ts +344 -0
- package/dist/templates/cc-native/_cc-native/plan-review/lib/agent-selection.ts +38 -16
- package/dist/templates/cc-native/_cc-native/plan-review/lib/preflight.ts +56 -26
- package/dist/templates/cc-native/_cc-native/scripts/council_debate.ts +242 -0
- package/dist/templates/cc-native/_cc-native/scripts/council_debate_simple.ts +294 -0
- package/dist/templates/cc-native/_cc-native/{plan-review/workflows → workflows}/specdev.md +9 -9
- package/dist/templates/core/.claude/skills/codex/SKILL.md +25 -0
- package/dist/templates/core/.claude/skills/devin/SKILL.md +25 -0
- package/dist/templates/core/.claude/skills/handoff/SKILL.md +11 -0
- package/dist/templates/core/.claude/skills/handoff-resume/SKILL.md +11 -0
- package/dist/templates/core/.claude/skills/meta-plan/SKILL.md +13 -0
- package/dist/templates/core/.codex/skills/codex/SKILL.md +13 -0
- package/dist/templates/core/.codex/skills/devin/SKILL.md +19 -0
- package/dist/templates/core/.codex/skills/handoff/SKILL.md +11 -0
- package/dist/templates/core/.codex/skills/handoff-resume/SKILL.md +11 -0
- package/dist/templates/core/.codex/skills/meta-plan/SKILL.md +13 -0
- package/dist/templates/core/.devin/AGENTS.md +5 -0
- package/dist/templates/core/.devin/config.json +12 -0
- package/dist/templates/core/.devin/skills/codex/SKILL.md +19 -0
- package/dist/templates/core/.devin/skills/devin/SKILL.md +13 -0
- package/dist/templates/core/.devin/skills/handoff/SKILL.md +11 -0
- package/dist/templates/core/.devin/skills/handoff-resume/SKILL.md +11 -0
- package/dist/templates/core/.devin/skills/meta-plan/SKILL.md +13 -0
- package/dist/templates/core/.windsurf/workflows/handoff-resume.md +9 -0
- package/dist/templates/{_shared → core}/.windsurf/workflows/handoff.md +1 -1
- package/dist/templates/{_shared → core}/.windsurf/workflows/meta-plan.md +1 -1
- package/dist/templates/core/hooks-ts/_utils/git-state.ts +2 -0
- package/dist/templates/{_shared → core}/hooks-ts/archive_plan.ts +15 -44
- package/dist/templates/core/hooks-ts/codex_explorer.ts +160 -0
- package/dist/templates/{_shared → core}/hooks-ts/context_monitor.ts +23 -55
- package/dist/templates/{_shared → core}/hooks-ts/file-suggestion.ts +5 -22
- package/dist/templates/{_shared → core}/hooks-ts/lint_after_edit.ts +7 -9
- package/dist/templates/core/hooks-ts/pre_compact.ts +36 -0
- package/dist/templates/{_shared → core}/hooks-ts/session_end.ts +38 -78
- package/dist/templates/{_shared → core}/hooks-ts/session_start.ts +5 -5
- package/dist/templates/core/hooks-ts/task_create_capture.ts +32 -0
- package/dist/templates/{_shared → core}/hooks-ts/task_update_capture.ts +9 -24
- package/dist/templates/core/hooks-ts/user_prompt_submit.ts +46 -0
- package/dist/templates/{_shared → core}/lib-ts/CLAUDE.md +27 -16
- package/dist/templates/{_shared → core}/lib-ts/context/CLAUDE.md +9 -6
- package/dist/templates/{_shared → core}/lib-ts/context/context-formatter.ts +16 -21
- package/dist/templates/{_shared → core}/lib-ts/context/context-selector.ts +8 -6
- package/dist/templates/{_shared → core}/lib-ts/context/context-store.ts +59 -20
- package/dist/templates/{_shared → core}/lib-ts/context/plan-manager.ts +19 -15
- package/dist/templates/{_shared → core}/lib-ts/context/task-tracker.ts +3 -3
- package/dist/templates/core/lib-ts/hooks/context-monitor-logic.ts +32 -0
- package/dist/templates/{_shared/lib-ts/base → core/lib-ts/hooks}/hook-utils.ts +179 -41
- package/dist/templates/core/lib-ts/hooks/prompt-binding-logic.ts +80 -0
- package/dist/templates/core/lib-ts/hooks/session-end-logic.ts +82 -0
- package/dist/templates/core/lib-ts/package.json +19 -0
- package/dist/templates/core/lib-ts/runtime/agent-launcher.ts +369 -0
- package/dist/templates/core/lib-ts/runtime/aiw-cli.ts +108 -0
- package/dist/templates/{_shared/lib-ts/base → core/lib-ts/runtime}/atomic-write.ts +12 -7
- package/dist/templates/{_shared/lib-ts/base → core/lib-ts/runtime}/cli-args.ts +24 -8
- package/dist/templates/{_shared/lib-ts/base → core/lib-ts/runtime}/constants.ts +326 -324
- package/dist/templates/core/lib-ts/runtime/executable-policy.ts +89 -0
- package/dist/templates/{_shared/lib-ts/base → core/lib-ts/runtime}/git-state.ts +6 -4
- package/dist/templates/{_shared/lib-ts/base → core/lib-ts/runtime}/inference.ts +60 -23
- package/dist/templates/{_shared/lib-ts/base → core/lib-ts/runtime}/lint-dispatch.ts +25 -23
- package/dist/templates/{_shared/lib-ts/base → core/lib-ts/runtime}/logger.ts +32 -29
- package/dist/templates/{_shared/lib-ts/base → core/lib-ts/runtime}/models.ts +9 -2
- package/dist/templates/core/lib-ts/runtime/platform-adapter.ts +33 -0
- package/dist/templates/{_shared/lib-ts/base → core/lib-ts/runtime}/preflight.ts +4 -3
- package/dist/templates/core/lib-ts/runtime/sentinel-ipc.ts +91 -0
- package/dist/templates/{_shared/lib-ts/base → core/lib-ts/runtime}/state-io.ts +20 -11
- package/dist/templates/core/lib-ts/runtime/stop-words.ts +185 -0
- package/dist/templates/core/lib-ts/runtime/subprocess-utils.ts +147 -0
- package/dist/templates/core/lib-ts/runtime/tmux-preflight.ts +93 -0
- package/dist/templates/{_shared/lib-ts/base → core/lib-ts/runtime}/utils.ts +34 -4
- package/dist/templates/core/lib-ts/schemas.ts +233 -0
- package/dist/templates/{_shared → core}/lib-ts/templates/formatters.ts +7 -5
- package/dist/templates/{_shared → core}/lib-ts/templates/plan-context.ts +2 -1
- package/dist/templates/{_shared → core}/lib-ts/tsconfig.json +3 -1
- package/dist/templates/{_shared → core}/lib-ts/types.ts +78 -77
- package/dist/templates/core/scripts/resolve-run.ts +93 -0
- package/dist/templates/{_shared → core}/scripts/resolve_context.ts +3 -3
- package/dist/templates/{_shared → core}/scripts/status_line.ts +26 -21
- package/dist/templates/core/skills/codex/CLAUDE.md +83 -0
- package/dist/templates/{_shared → core}/skills/codex/SKILL.md +27 -18
- package/dist/templates/{_shared → core}/skills/codex/lib/codex-watcher.ts +79 -113
- package/dist/templates/{_shared → core}/skills/codex/scripts/launch-codex.ts +134 -148
- package/dist/templates/{_shared → core}/skills/codex/scripts/watch-codex.ts +6 -4
- package/dist/templates/core/skills/devin/CLAUDE.md +122 -0
- package/dist/templates/core/skills/devin/SKILL.md +73 -0
- package/dist/templates/core/skills/devin/lib/devin-watcher.ts +300 -0
- package/dist/templates/core/skills/devin/scripts/launch-devin.ts +258 -0
- package/dist/templates/{_shared → core}/skills/handoff-system/CLAUDE.md +436 -433
- package/dist/templates/{_shared → core}/skills/handoff-system/lib/document-generator.ts +9 -7
- package/dist/templates/{_shared → core}/skills/handoff-system/lib/handoff-reader.ts +6 -4
- package/dist/templates/{_shared → core}/skills/handoff-system/scripts/resume_handoff.ts +10 -8
- package/dist/templates/{_shared → core}/skills/handoff-system/scripts/save_handoff.ts +12 -10
- package/dist/templates/{_shared → core}/skills/handoff-system/workflows/handoff-resume.md +2 -2
- package/dist/templates/{_shared → core}/skills/handoff-system/workflows/handoff.md +6 -5
- package/dist/templates/{_shared → core}/skills/meta-plan/CLAUDE.md +2 -1
- package/dist/templates/{_shared → core}/skills/meta-plan/workflows/meta-plan.md +8 -7
- package/oclif.manifest.json +89 -13
- package/package.json +13 -12
- package/dist/lib/base-command.d.ts +0 -114
- package/dist/lib/base-command.js +0 -153
- package/dist/lib/env-compat.d.ts +0 -18
- package/dist/lib/env-compat.js +0 -23
- package/dist/lib/stdin.d.ts +0 -48
- package/dist/lib/stdin.js +0 -60
- package/dist/templates/_shared/.claude/settings.json +0 -120
- package/dist/templates/_shared/.claude/skills/codex/SKILL.md +0 -35
- package/dist/templates/_shared/.claude/skills/handoff/SKILL.md +0 -13
- package/dist/templates/_shared/.claude/skills/handoff-resume/SKILL.md +0 -13
- package/dist/templates/_shared/.claude/skills/meta-plan/SKILL.md +0 -43
- package/dist/templates/_shared/.codex/workflows/codex.md +0 -11
- package/dist/templates/_shared/.codex/workflows/handoff.md +0 -226
- package/dist/templates/_shared/.codex/workflows/meta-plan.md +0 -347
- package/dist/templates/_shared/hooks-ts/_utils/git-state.ts +0 -2
- package/dist/templates/_shared/hooks-ts/pre_compact.ts +0 -49
- package/dist/templates/_shared/hooks-ts/task_create_capture.ts +0 -48
- package/dist/templates/_shared/hooks-ts/user_prompt_submit.ts +0 -93
- package/dist/templates/_shared/lib-ts/agent-exec/backends/headless.ts +0 -33
- package/dist/templates/_shared/lib-ts/agent-exec/backends/index.ts +0 -6
- package/dist/templates/_shared/lib-ts/agent-exec/backends/tmux.ts +0 -119
- package/dist/templates/_shared/lib-ts/agent-exec/execution-backend.ts +0 -50
- package/dist/templates/_shared/lib-ts/agent-exec/index.ts +0 -6
- package/dist/templates/_shared/lib-ts/agent-exec/structured-output.ts +0 -166
- package/dist/templates/_shared/lib-ts/base/launchers/tmux-launcher.ts +0 -173
- package/dist/templates/_shared/lib-ts/base/launchers/window-launcher.ts +0 -93
- package/dist/templates/_shared/lib-ts/base/launchers/wt-launcher.ts +0 -64
- package/dist/templates/_shared/lib-ts/base/pane-launcher.ts +0 -55
- package/dist/templates/_shared/lib-ts/base/sentinel-ipc.ts +0 -87
- package/dist/templates/_shared/lib-ts/base/stop-words.ts +0 -184
- package/dist/templates/_shared/lib-ts/base/subprocess-utils.ts +0 -249
- package/dist/templates/_shared/lib-ts/base/tmux-driver.ts +0 -341
- package/dist/templates/_shared/lib-ts/base/tmux-pane-placement.ts +0 -78
- package/dist/templates/_shared/lib-ts/package.json +0 -20
- package/dist/templates/_shared/scripts/resolve-run.ts +0 -62
- package/dist/templates/_shared/skills/codex/CLAUDE.md +0 -70
- package/dist/templates/cc-native/_cc-native/CLAUDE.md +0 -73
- package/dist/templates/cc-native/_cc-native/artifacts/CLAUDE.md +0 -64
- package/dist/templates/cc-native/_cc-native/lib-ts/CLAUDE.md +0 -70
- package/dist/templates/cc-native/_cc-native/plan-review/CODING-STANDARDS-CHECKLIST.md +0 -75
- package/dist/templates/cc-native/_cc-native/plan-review/agents/CLAUDE.md +0 -143
- package/dist/templates/cc-native/_cc-native/plan-review/agents/PLAN-ORCHESTRATOR.md +0 -213
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-questions/PLAN-QUESTIONER.md +0 -70
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-EVOLUTION.md +0 -62
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-PATTERNS.md +0 -61
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-STRUCTURE.md +0 -62
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ASSUMPTION-TRACER.md +0 -56
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CLARITY-AUDITOR.md +0 -53
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-FEASIBILITY.md +0 -66
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-GAPS.md +0 -70
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-ORDERING.md +0 -62
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CONSTRAINT-VALIDATOR.md +0 -72
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-ADR-VALIDATOR.md +0 -61
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-SCALE-MATCHER.md +0 -64
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DEVILS-ADVOCATE.md +0 -56
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DOCUMENTATION-PHILOSOPHY.md +0 -86
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HANDOFF-READINESS.md +0 -59
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HIDDEN-COMPLEXITY.md +0 -58
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/INCREMENTAL-DELIVERY.md +0 -66
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-DEPENDENCY.md +0 -62
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-FMEA.md +0 -66
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-PREMORTEM.md +0 -71
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-REVERSIBILITY.md +0 -74
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SCOPE-BOUNDARY.md +0 -77
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SIMPLICITY-GUARDIAN.md +0 -62
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SKEPTIC.md +0 -68
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-BEHAVIOR-AUDITOR.md +0 -61
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-CHARACTERIZATION.md +0 -71
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-FIRST-VALIDATOR.md +0 -61
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-PYRAMID-ANALYZER.md +0 -61
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-COSTS.md +0 -67
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-STAKEHOLDERS.md +0 -65
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-COVERAGE.md +0 -74
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-STRENGTH.md +0 -69
- package/dist/templates/cc-native/_cc-native/plan-review/lib/corroboration.ts +0 -172
- package/dist/templates/cc-native/_cc-native/plan-review/lib/reviewers/base/base-agent.ts +0 -7
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
CC-Native uses Claude Code's native tools with minimal workflow overhead. Plan review runs automatically via external CLIs (Codex/Gemini) and parallel Claude Code agents when exiting plan mode.
|
|
6
6
|
|
|
7
|
+
This directory is the canonical source for the packaged CC-Native template. Build/package steps copy it directly; they do not mirror from a repo-root `.aiwcli/_cc-native`.
|
|
8
|
+
|
|
7
9
|
---
|
|
8
10
|
|
|
9
11
|
## Directory Structure
|
|
@@ -14,8 +16,11 @@ packages/cli/src/templates/cc-native/
|
|
|
14
16
|
│ ├── workflows/*.md # Workflow definitions
|
|
15
17
|
│ ├── hooks/ # Hook scripts (TypeScript, run via bun)
|
|
16
18
|
│ │ ├── cc-native-plan-review.ts # Unified plan review (CLI + agents)
|
|
17
|
-
│ │ ├──
|
|
18
|
-
│ │
|
|
19
|
+
│ │ ├── plan_questions_early.ts # Phase A clarification prompt
|
|
20
|
+
│ │ ├── mark_questions_asked.ts # Tracks whether clarification happened
|
|
21
|
+
│ │ ├── enhance_plan_post_write.ts # Post-write plan enhancement
|
|
22
|
+
│ │ ├── enhance_plan_post_subagent.ts # Post-subagent plan enhancement
|
|
23
|
+
│ │ └── validate_task_prompt.ts # Task prompt validation gate
|
|
19
24
|
│ ├── lib-ts/ # CC-Native specific TypeScript libraries
|
|
20
25
|
│ │ ├── cc-native-state.ts # State management
|
|
21
26
|
│ │ ├── config.ts # Configuration loading
|
|
@@ -103,9 +108,9 @@ CC-Native settings are stored in `_cc-native/cc-native.config.json`:
|
|
|
103
108
|
"timeout": 30
|
|
104
109
|
},
|
|
105
110
|
"agentSelection": {
|
|
106
|
-
"simple": { "min":
|
|
107
|
-
"medium": { "min":
|
|
108
|
-
"high": { "min":
|
|
111
|
+
"simple": { "min": 3, "max": 3 },
|
|
112
|
+
"medium": { "min": 5, "max": 5 },
|
|
113
|
+
"high": { "min": 7, "max": 7 },
|
|
109
114
|
"fallbackCount": 2
|
|
110
115
|
}
|
|
111
116
|
}
|
|
@@ -129,12 +134,12 @@ CC-Native settings are stored in `_cc-native/cc-native.config.json`:
|
|
|
129
134
|
|---------|---------|---------|
|
|
130
135
|
| `agentReview.enabled` | Master switch for agent review | `true` |
|
|
131
136
|
| `agentReview.timeout` | Seconds per agent before timeout | `120` |
|
|
132
|
-
| `agentReview.blockOnFail` | Block Claude if
|
|
137
|
+
| `agentReview.blockOnFail` | Block Claude if unknown agent fails | `true` |
|
|
133
138
|
| `agentReview.orchestrator.enabled` | Use orchestrator for complexity analysis | `true` |
|
|
134
139
|
| `agentReview.orchestrator.model` | Model for orchestrator | `haiku` |
|
|
135
|
-
| `agentReview.agentSelection.simple` | Agent count for simple plans | `
|
|
136
|
-
| `agentReview.agentSelection.medium` | Agent count for medium plans | `
|
|
137
|
-
| `agentReview.agentSelection.high` | Agent count for complex plans | `
|
|
140
|
+
| `agentReview.agentSelection.simple` | Agent count for simple plans | `3-3` |
|
|
141
|
+
| `agentReview.agentSelection.medium` | Agent count for medium plans | `5-5` |
|
|
142
|
+
| `agentReview.agentSelection.high` | Agent count for complex plans | `7-7` |
|
|
138
143
|
|
|
139
144
|
### Environment Variables
|
|
140
145
|
|
|
@@ -233,8 +238,11 @@ Hook scripts live in `_cc-native/hooks/`. IDE-specific wiring in `.claude/settin
|
|
|
233
238
|
| Hook | Trigger | Purpose |
|
|
234
239
|
|------|---------|---------|
|
|
235
240
|
| `cc-native-plan-review.ts` | ExitPlanMode | Unified review: CLI + orchestrator + agents |
|
|
236
|
-
| `
|
|
241
|
+
| `mark_questions_asked.ts` | PostToolUse:AskUserQuestion | Mark that clarification questions were asked |
|
|
242
|
+
| `enhance_plan_post_write.ts` | PostToolUse:Write | Nudge plan improvement after write-heavy work |
|
|
243
|
+
| `enhance_plan_post_subagent.ts` | PostToolUse:Task | Nudge plan improvement after subagent work |
|
|
237
244
|
| `plan_questions_early.ts` | UserPromptSubmit | Injects Phase A clarification in plan mode |
|
|
245
|
+
| `validate_task_prompt.ts` | PreToolUse:Task | Blocks vague or non-self-contained Task prompts |
|
|
238
246
|
|
|
239
247
|
### Claude Feedback Mechanism
|
|
240
248
|
|
|
@@ -268,7 +276,7 @@ The orchestrator uses a fast model (Haiku) to:
|
|
|
268
276
|
- Categorize the plan (code/infrastructure/documentation/life/business/design/research)
|
|
269
277
|
- Select appropriate agents based on complexity and category
|
|
270
278
|
|
|
271
|
-
|
|
279
|
+
Plans run a complexity-tiered reviewer set: simple plans use 3 agents, medium plans use 5, and high-complexity plans use 7 (including mandatory reviewers).
|
|
272
280
|
|
|
273
281
|
#### Agent Execution
|
|
274
282
|
|
|
@@ -297,7 +305,7 @@ Each selected agent:
|
|
|
297
305
|
|
|
298
306
|
| Version | Changes |
|
|
299
307
|
|---------|---------|
|
|
300
|
-
| 1.4.0 | **Phase 1 Shared Infrastructure**: Event-sourced context management in `
|
|
308
|
+
| 1.4.0 | **Phase 1 Shared Infrastructure**: Event-sourced context management in `core/`, contexts in `_output/contexts/`, atomic writes. **BREAKING**: Renamed config.json → cc-native.config.json |
|
|
301
309
|
| 1.3.0 | Consolidated CLI + agent review into single unified hook with combined output |
|
|
302
310
|
| 1.2.0 | Added multi-agent plan review via Claude Code agents, reordered hooks (archive last) |
|
|
303
311
|
| 1.1.0 | Added plan review via Codex/Gemini with Claude feedback, config.json |
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
},
|
|
8
8
|
"codex": {
|
|
9
9
|
"enabled": true,
|
|
10
|
-
"models": ["gpt-5.
|
|
11
|
-
"
|
|
10
|
+
"models": ["gpt-5.4"],
|
|
11
|
+
"reasoning_effort": "low"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
},
|
|
@@ -30,10 +30,6 @@
|
|
|
30
30
|
"model": "opus",
|
|
31
31
|
"timeout": 60
|
|
32
32
|
},
|
|
33
|
-
"preflight": {
|
|
34
|
-
"enabled": true,
|
|
35
|
-
"timeoutMs": 15000
|
|
36
|
-
},
|
|
37
33
|
"legacyMode": false,
|
|
38
34
|
"mandatoryAgents": {
|
|
39
35
|
"always": ["handoff-readiness", "clarity-auditor", "skeptic"],
|
|
@@ -9,27 +9,24 @@
|
|
|
9
9
|
| Hook | Trigger | Purpose |
|
|
10
10
|
|------|---------|---------|
|
|
11
11
|
| `cc-native-plan-review.ts` | PreToolUse: ExitPlanMode | Questions gate + plan review before user approval |
|
|
12
|
-
| `
|
|
13
|
-
| `enhance_plan_post_subagent.ts` | PostToolUse: Task | Post-subagent plan enhancement |
|
|
14
|
-
| `enhance_plan_post_write.ts` | PostToolUse: Write | Post-write plan enhancement |
|
|
12
|
+
| `add_plan_context.ts` | PostToolUse: AskUserQuestion, PreToolUse: Task | Mark questions asked; nudge Plan subagent to ask questions first |
|
|
15
13
|
| `plan_questions_early.ts` | UserPromptSubmit | Inject Phase A clarification prompt in plan mode |
|
|
16
|
-
| `validate_task_prompt.ts` | PreToolUse: TaskCreate | Validates task creation prompts |
|
|
17
14
|
|
|
18
15
|
### Plan Review Architecture
|
|
19
16
|
|
|
20
|
-
The hook is a thin coordinator (~70 lines) that delegates to `
|
|
17
|
+
The hook is a thin coordinator (~70 lines) that delegates to `lib-ts/review-pipeline.ts`. The pipeline wires together focused modules:
|
|
21
18
|
|
|
22
|
-
| Module |
|
|
23
|
-
|
|
24
|
-
| `plan-discovery.ts` |
|
|
25
|
-
| `settings.ts` |
|
|
26
|
-
| `agent-selection.ts` |
|
|
27
|
-
| `graduation.ts` |
|
|
28
|
-
| `output-builder.ts` |
|
|
29
|
-
| `review-pipeline.ts` |
|
|
30
|
-
| `artifacts/
|
|
31
|
-
| `artifacts/
|
|
32
|
-
| `artifacts/
|
|
19
|
+
| Module | Responsibility |
|
|
20
|
+
|--------|----------------|
|
|
21
|
+
| `plan-discovery.ts` | Find plan file, read content, compute hash |
|
|
22
|
+
| `settings.ts` | Load + merge config with defaults, load agent library |
|
|
23
|
+
| `agent-selection.ts` | Mandatory agent resolution, orchestrator-based selection, model assignment |
|
|
24
|
+
| `graduation.ts` | Pass eligibility, pass streaks, graduation threshold, iteration advancement |
|
|
25
|
+
| `output-builder.ts` | Issue truncation, verdict override, context/block message construction |
|
|
26
|
+
| `review-pipeline.ts` | Pipeline orchestrator wiring all modules together |
|
|
27
|
+
| `artifacts/format.ts` | Pure formatting (markdown, JSON, inline summaries) |
|
|
28
|
+
| `artifacts/write.ts` | File I/O for review artifacts |
|
|
29
|
+
| `artifacts/tracker.ts` | Review tracker management |
|
|
33
30
|
|
|
34
31
|
### Questions Gate (in review-pipeline.ts)
|
|
35
32
|
|
|
@@ -42,10 +39,10 @@ Before running plan review agents, the pipeline checks `wasQuestionsAsked()`. If
|
|
|
42
39
|
CC-native hooks are TypeScript, run via `bun`. Use relative imports from the hook file location.
|
|
43
40
|
|
|
44
41
|
```typescript
|
|
45
|
-
// Shared library imports (via
|
|
46
|
-
import { loadHookInput, runHook, logInfo, emitContext } from "../../
|
|
47
|
-
import { isInternalCall } from "../../
|
|
48
|
-
import { getProjectRoot } from "../../
|
|
42
|
+
// Shared library imports (via _core/lib-ts/)
|
|
43
|
+
import { loadHookInput, runHook, logInfo, emitContext } from "../../_core/lib-ts/hooks/hook-utils.js";
|
|
44
|
+
import { isInternalCall } from "../../_core/lib-ts/runtime/subprocess-utils.js";
|
|
45
|
+
import { getProjectRoot } from "../../_core/lib-ts/runtime/constants.js";
|
|
49
46
|
|
|
50
47
|
// CC-native library imports (via ../lib-ts/)
|
|
51
48
|
import { wasQuestionsAsked, markQuestionsAsked } from "../lib-ts/cc-native-state.js";
|
|
@@ -55,7 +52,7 @@ import type { AgentConfig } from "../lib-ts/types.js";
|
|
|
55
52
|
|
|
56
53
|
**Important:** Always use `.js` extensions in import paths — Bun resolves `.ts` files from `.js` imports.
|
|
57
54
|
|
|
58
|
-
**Import direction:** Hooks → `_cc-native/lib-ts/` → `
|
|
55
|
+
**Import direction:** Hooks → `_cc-native/lib-ts/` → `_core/lib-ts/`. Never reverse.
|
|
59
56
|
|
|
60
57
|
---
|
|
61
58
|
|
|
@@ -64,7 +61,7 @@ import type { AgentConfig } from "../lib-ts/types.js";
|
|
|
64
61
|
Hooks can be invoked recursively when spawning subprocesses (agents, orchestrator). Always check and skip:
|
|
65
62
|
|
|
66
63
|
```typescript
|
|
67
|
-
import { isInternalCall } from "../../
|
|
64
|
+
import { isInternalCall } from "../../_core/lib-ts/runtime/subprocess-utils.js";
|
|
68
65
|
|
|
69
66
|
function main(): void {
|
|
70
67
|
// FIRST LINE of main - before any other logic
|
|
@@ -87,7 +84,7 @@ Claude Code hooks return JSON to stdout. The format is specific to each hook typ
|
|
|
87
84
|
Use the shared hook utilities — never construct JSON manually:
|
|
88
85
|
|
|
89
86
|
```typescript
|
|
90
|
-
import { emitContext, emitContextAndBlock } from "../../
|
|
87
|
+
import { emitContext, emitContextAndBlock } from "../../_core/lib-ts/hooks/hook-utils.js";
|
|
91
88
|
|
|
92
89
|
// Inject context without blocking:
|
|
93
90
|
emitContext("Information for Claude to see...");
|
|
@@ -105,7 +102,7 @@ emitContextAndBlock(
|
|
|
105
102
|
|
|
106
103
|
## Debugging Output
|
|
107
104
|
|
|
108
|
-
For logging tiers, visibility rules, and stderr behavior, see **`
|
|
105
|
+
For logging tiers, visibility rules, and stderr behavior, see **`_core/lib-ts/CLAUDE.md`** (the shared library guide). The key rules:
|
|
109
106
|
|
|
110
107
|
- **stderr is opt-in.** `log_debug/log_info/log_warn/log_error` write to file only (no UI noise)
|
|
111
108
|
- **`logBlocking()` / `log_hook_error()`** for problems that must be visible
|
|
@@ -115,7 +112,7 @@ For logging tiers, visibility rules, and stderr behavior, see **`_shared/lib-ts/
|
|
|
115
112
|
TypeScript hooks use re-exported logger functions from `hook-utils.ts`:
|
|
116
113
|
|
|
117
114
|
```typescript
|
|
118
|
-
import { logDebug, logInfo, logWarn, logError } from "../../
|
|
115
|
+
import { logDebug, logInfo, logWarn, logError } from "../../_core/lib-ts/hooks/hook-utils.js";
|
|
119
116
|
|
|
120
117
|
logDebug("hook-name", `Found ${items.length} items`); // file only
|
|
121
118
|
logInfo("hook-name", "Starting hook..."); // file only
|
|
@@ -129,15 +126,15 @@ logError("hook-name", `Failed: ${e}`); // file only
|
|
|
129
126
|
Plan review hooks integrate with the shared context system for state management:
|
|
130
127
|
|
|
131
128
|
```typescript
|
|
132
|
-
import { getContextBySessionId, getAllContexts } from "../../
|
|
133
|
-
import { getContextReviewsDir } from "../../
|
|
129
|
+
import { getContextBySessionId, getAllContexts } from "../../_core/lib-ts/context/context-store.js";
|
|
130
|
+
import { getContextReviewsDir } from "../../_core/lib-ts/runtime/constants.js";
|
|
134
131
|
|
|
135
132
|
// Find active context
|
|
136
133
|
const context = getContextBySessionId(sessionId, projectRoot);
|
|
137
134
|
if (!context) {
|
|
138
135
|
// Fallback: find single planning context
|
|
139
136
|
const allActive = getAllContexts("active", projectRoot);
|
|
140
|
-
const planning = allActive.filter((c: any) => c.mode === "active" || c.mode === "
|
|
137
|
+
const planning = allActive.filter((c: any) => c.mode === "active" || c.mode === "has_plan");
|
|
141
138
|
if (planning.length === 1) {
|
|
142
139
|
context = planning[0];
|
|
143
140
|
}
|
|
@@ -160,7 +157,7 @@ import { isPlanAlreadyReviewed, markPlanReviewed, wasQuestionsAsked } from "../l
|
|
|
160
157
|
Hooks should fail gracefully — a broken hook shouldn't break the user's workflow. `runHook()` and `runHookAsync()` handle this automatically: uncaught errors log to file and exit 0 (non-blocking).
|
|
161
158
|
|
|
162
159
|
```typescript
|
|
163
|
-
import { runHook, logInfo } from "../../
|
|
160
|
+
import { runHook, logInfo } from "../../_core/lib-ts/hooks/hook-utils.js";
|
|
164
161
|
|
|
165
162
|
function main(): void {
|
|
166
163
|
// Hook logic — uncaught errors are handled by runHook
|
|
@@ -173,7 +170,7 @@ runHook(main, "hook_name");
|
|
|
173
170
|
For async hooks (plan review with parallel agents):
|
|
174
171
|
|
|
175
172
|
```typescript
|
|
176
|
-
import { runHookAsync } from "../../
|
|
173
|
+
import { runHookAsync } from "../../_core/lib-ts/hooks/hook-utils.js";
|
|
177
174
|
|
|
178
175
|
async function main(): Promise<void> {
|
|
179
176
|
// Async hook logic with Promise.all() etc.
|
|
@@ -188,7 +185,7 @@ Use `emitContextAndBlock()` for intentional blocking (e.g., plan review denial).
|
|
|
188
185
|
|
|
189
186
|
## Error Handling: Non-Critical Operations
|
|
190
187
|
|
|
191
|
-
Wrap non-critical shared library calls in try/catch to prevent false "hook error" UI display. See **`
|
|
188
|
+
Wrap non-critical shared library calls in try/catch to prevent false "hook error" UI display. See **`_core/lib-ts/CLAUDE.md`** > Context Store for the pattern and rationale.
|
|
192
189
|
|
|
193
190
|
**When to catch locally vs let bubble:**
|
|
194
191
|
- **Catch locally:** Side effects like mode transitions, state saves — the hook's primary purpose can still succeed without them
|
|
@@ -220,7 +217,7 @@ Validate TypeScript syntax after editing hooks:
|
|
|
220
217
|
bun --print "import('.aiwcli/_cc-native/hooks/cc-native-plan-review.ts')" 2>&1 | head -5
|
|
221
218
|
|
|
222
219
|
# Or check imports resolve (dry run)
|
|
223
|
-
bun build --no-bundle .aiwcli/_cc-native/hooks/
|
|
220
|
+
bun build --no-bundle .aiwcli/_cc-native/hooks/add_plan_context.ts --outdir /dev/null 2>&1
|
|
224
221
|
```
|
|
225
222
|
|
|
226
223
|
Hooks fail silently on import errors — verify after any import path changes.
|
|
@@ -238,30 +235,13 @@ Hooks fail silently on import errors — verify after any import path changes.
|
|
|
238
235
|
| 2026-02-10 | **Migrated cc-native hooks from Python to TypeScript.** `cc-native-plan-review.ts` (async, parallel agent reviews via `Promise.all()`), `add_plan_context.ts`, `plan_questions_early.ts`. All hooks use `runHook()`/`runHookAsync()` entry points. Library code in `_cc-native/lib-ts/` (18 files). Settings.json updated to use `bun` runner. Python `.py` files kept as fallback until TS hooks verified. |
|
|
239
236
|
| 2026-02-10 | Flipped TS logger stderr default to opt-in (`opts?.stderr === true`). Added `logBlocking()` for intentional stderr visibility. Removed redundant `{stderr: false}` from hook-utils.ts, user_prompt_submit.ts, context_monitor.ts. Added "Hook Error Visibility" section documenting visibility tiers and exit code behavior. |
|
|
240
237
|
| 2026-02-10 | Fixed `debug.py` `context_path` crash. Added local try/catch around `maybeActivate` in `user_prompt_submit.ts` and `context_monitor.ts` to prevent stderr error display on non-critical I/O failures. Removed dead `context_path` from `_emitHookEnd` in `hook-utils.ts`. Added "Error Handling" section to CLAUDE.md. |
|
|
241
|
-
| 2026-02-
|
|
242
|
-
| 2026-02-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
the code, and it belongs at this scope (project-wide rule → root CLAUDE.md; WHY decision
|
|
252
|
-
→ inline comment or ADR; inferable from code → nowhere).
|
|
253
|
-
|
|
254
|
-
**Remove** any entry that fails the falsifiability test: if removing it would not change
|
|
255
|
-
how an agent acts here, remove it. If a convention here conflicts with the codebase,
|
|
256
|
-
the codebase wins — update this file, do not work around it. Prune aggressively.
|
|
257
|
-
|
|
258
|
-
**Staleness anchor:** This file assumes `cc-native-plan-review.ts` exists. If it doesn't, this file
|
|
259
|
-
is stale — update or regenerate before relying on it.
|
|
260
|
-
|
|
261
|
-
**Trigger Audit or Generate:**
|
|
262
|
-
- Rename/move files or dirs → Audit
|
|
263
|
-
- >20% of files changed → Generate
|
|
264
|
-
- 30+ days without touching this file → Audit
|
|
265
|
-
- Agent mistake caused by this file → fix immediately, then Audit
|
|
266
|
-
|
|
267
|
-
<!-- context-layer: generated=2026-02-10 | last-audited=2026-02-21 | version=2 | dir-commits-at-audit=58 -->
|
|
238
|
+
| 2026-02-07 | Handoff staging lifecycle: `has_handoff` mode + `handoff_consumed` flag mirrors plan lifecycle. `save_handoff.py` no longer transitions to idle — stays active for session_end staging. `session_end.py` stages `active→has_handoff` when handoff_path set and not consumed. `session_start.py` restores `has_handoff→active` on /clear. `context_selector.py` has fallback Case 3b for has_handoff. PostToolUse context_monitor matcher simplified from specific tool list to `*`. |
|
|
239
|
+
| 2026-02-07 | Removed PreToolUse:Write matcher from `add_plan_context.py`. Write-time plan nudges were redundant after consolidating enforcement to PreToolUse:Task. Removed `is_plan_file_write()`, `load_plan_context_config()`, `PHASE_B_ENFORCEMENT`, `nudge_write_questions()`, and `project_dir` import. |
|
|
240
|
+
| 2026-02-07 | Question enforcement is now advisory-only (never blocks). `add_plan_context.py` uses `emit_context()` for all question nudges — no `permissionDecision:deny` anywhere. Removed `emit_context_and_block` import and `TASK_ENFORCEMENT_REASON` constant. |
|
|
241
|
+
| 2026-02-07 | Moved question enforcement to PreToolUse:Task (Plan subagent gate). `add_plan_context.py` now handles three events: PostToolUse:AskUserQuestion, PreToolUse:Task (primary gate), PreToolUse:Write (fallback). Added `is_plan_task()`, `is_internal_call()` guard, `TASK_ENFORCEMENT_CONTEXT` constant. Registered `^Task$` command hook in settings.json. |
|
|
242
|
+
| 2026-02-07 | Deleted `plan_accepted.py` (dead code — PostToolUse:ExitPlanMode never fires due to /clear race). Plan field assignment handled by `session_end.py` fallback. Added `plan_consumed` flag to prevent infinite plan re-staging. |
|
|
243
|
+
| 2026-02-07 | Hook lifecycle diagnostics: all hooks now use `run_hook(main, "hook_name")` entry point. Logs HOOK_START/HOOK_END with template origin, event type, duration_ms, and status. Millisecond timestamps in logger. |
|
|
244
|
+
| 2026-02-07 | Unified logger: all diagnostic logging uses `log_debug/log_info/log_warn/log_error` from `_shared/lib/base/logger.py` instead of eprint/print-to-stderr. Updated debugging and error handling docs. |
|
|
245
|
+
| 2026-02-06 | Merged mark_questions_asked.py into add_plan_context.py. Hook now handles both PostToolUse:AskUserQuestion and PreToolUse:Write. Deleted standalone mark_questions_asked.py. |
|
|
246
|
+
| 2026-02-06 | Fixed add_plan_context.py trigger docs (was PostToolUse: EnterPlanMode, is PreToolUse: Write). Added emit_context/emit_context_and_block utility docs. |
|
|
247
|
+
| 2026-02-03 | Initial creation |
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
* Output: _output/cc-native/plans/{YYYY-MM-DD}/{slug}/reviews/
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { getProjectRoot, getAiwcliDir } from "../../_shared/lib-ts/base/constants.js";
|
|
14
13
|
import {
|
|
15
14
|
loadHookInput,
|
|
16
15
|
runHookAsync,
|
|
@@ -19,10 +18,11 @@ import {
|
|
|
19
18
|
logWarn,
|
|
20
19
|
emitContext,
|
|
21
20
|
emitContextAndBlock,
|
|
22
|
-
} from "../../
|
|
23
|
-
import { isInternalCall } from "../../
|
|
21
|
+
} from "../../_core/lib-ts/hooks/hook-utils.js";
|
|
22
|
+
import { isInternalCall } from "../../_core/lib-ts/runtime/subprocess-utils.js";
|
|
23
|
+
import { getProjectRoot, getAiwcliDir } from "../../_core/lib-ts/runtime/constants.js";
|
|
24
|
+
import { runReviewPipeline } from "../lib-ts/review-pipeline.js";
|
|
24
25
|
import type { PipelineResult } from "../lib-ts/types.js";
|
|
25
|
-
import { runReviewPipeline } from "../plan-review/lib/review-pipeline.js";
|
|
26
26
|
|
|
27
27
|
const HOOK = "cc-native-plan-review";
|
|
28
28
|
|
|
@@ -59,15 +59,13 @@ async function main(): Promise<void> {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
switch (result.action) {
|
|
62
|
-
case "
|
|
63
|
-
emitContextAndBlock(result.contextText, result.blockReason);
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
case "skip": {
|
|
62
|
+
case "skip":
|
|
67
63
|
logInfo(HOOK, `Skipping: ${result.reason}`);
|
|
68
64
|
emitContext(`[Plan Review Skipped] ${result.reason}`);
|
|
69
|
-
break;
|
|
70
|
-
|
|
65
|
+
break;
|
|
66
|
+
case "block":
|
|
67
|
+
emitContextAndBlock(result.contextText, result.blockReason);
|
|
68
|
+
break;
|
|
71
69
|
default: {
|
|
72
70
|
const _exhaustive: never = result;
|
|
73
71
|
logWarn(HOOK, `Unhandled pipeline action: ${(_exhaustive as { action: string }).action}`);
|
|
@@ -18,8 +18,8 @@ import {
|
|
|
18
18
|
logDebug,
|
|
19
19
|
emitContext,
|
|
20
20
|
getToolInput,
|
|
21
|
-
} from "../../
|
|
22
|
-
import { isInternalCall } from "../../
|
|
21
|
+
} from "../../_core/lib-ts/hooks/hook-utils.js";
|
|
22
|
+
import { isInternalCall } from "../../_core/lib-ts/runtime/subprocess-utils.js";
|
|
23
23
|
import { getPlanQualityReviewContext } from "../lib-ts/plan-enhancement.js";
|
|
24
24
|
|
|
25
25
|
function main(): void {
|
|
@@ -12,17 +12,16 @@
|
|
|
12
12
|
* - Emits context via emitContext() — no file mutation
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import * as os from "node:os";
|
|
16
|
-
import * as path from "node:path";
|
|
17
|
-
|
|
18
15
|
import {
|
|
19
16
|
loadHookInput,
|
|
20
17
|
runHook,
|
|
21
18
|
logInfo,
|
|
22
19
|
emitContext,
|
|
23
|
-
} from "../../
|
|
24
|
-
import { isInternalCall } from "../../
|
|
20
|
+
} from "../../_core/lib-ts/hooks/hook-utils.js";
|
|
21
|
+
import { isInternalCall } from "../../_core/lib-ts/runtime/subprocess-utils.js";
|
|
25
22
|
import { getPlanQualityReviewContext } from "../lib-ts/plan-enhancement.js";
|
|
23
|
+
import * as path from "path";
|
|
24
|
+
import * as os from "os";
|
|
26
25
|
|
|
27
26
|
function main(): void {
|
|
28
27
|
if (isInternalCall()) return;
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
* Fail-safe: Any error exits 0 (non-blocking).
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { getProjectRoot } from "../../_shared/lib-ts/base/constants.js";
|
|
15
14
|
import {
|
|
16
15
|
loadHookInput,
|
|
17
16
|
runHook,
|
|
18
17
|
logInfo,
|
|
19
18
|
logDiagnostic,
|
|
20
|
-
} from "../../
|
|
21
|
-
import { isInternalCall } from "../../
|
|
19
|
+
} from "../../_core/lib-ts/hooks/hook-utils.js";
|
|
20
|
+
import { isInternalCall } from "../../_core/lib-ts/runtime/subprocess-utils.js";
|
|
21
|
+
import { getProjectRoot } from "../../_core/lib-ts/runtime/constants.js";
|
|
22
22
|
import { markQuestionsAsked } from "../lib-ts/cc-native-state.js";
|
|
23
23
|
|
|
24
24
|
function main(): void {
|
|
@@ -46,7 +46,7 @@ function main(): void {
|
|
|
46
46
|
markQuestionsAsked(sessionId, projectRoot, "early");
|
|
47
47
|
logInfo("add_plan_context", `Marked early questions asked for session ${sessionId.slice(0, 8)}...`);
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
return;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -9,34 +9,10 @@
|
|
|
9
9
|
* Skips if questions were already asked this session.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { loadHookInput, runHook, logDebug, logInfo, emitContext } from "../../_core/lib-ts/hooks/hook-utils.js";
|
|
13
|
+
import { getProjectRoot } from "../../_core/lib-ts/runtime/constants.js";
|
|
14
14
|
import { wasEarlyQuestionsAsked } from "../lib-ts/cc-native-state.js";
|
|
15
15
|
|
|
16
|
-
// Unconditional injection by design — no code-detection gate.
|
|
17
|
-
// "When this plan involves code" is self-selecting; non-code plans ignore it.
|
|
18
|
-
// Soft framing per Anthropic Claude 4.x best practices (avoid MUST/MANDATORY overtriggering).
|
|
19
|
-
// Motivation per standard enables generalization better than threats.
|
|
20
|
-
// Generalizability disclaimer: not all codebases need all standards.
|
|
21
|
-
const CODING_STANDARDS_NUDGE = `## Coding Standards for Code Changes
|
|
22
|
-
|
|
23
|
-
When this plan creates or modifies production code, apply these standards — they address the
|
|
24
|
-
most common plan review failure modes:
|
|
25
|
-
|
|
26
|
-
1. **Test-First Design** — Design interfaces from the test perspective first. Plans that
|
|
27
|
-
describe "implement then test" consistently fail review. Structure tests before implementation.
|
|
28
|
-
2. **File Structure Fit** — Verify where similar things already live in this project before
|
|
29
|
-
proposing new files. Agents commonly pick plausible-but-wrong locations that don't match
|
|
30
|
-
existing conventions.
|
|
31
|
-
3. **Extensibility Analysis** — Identify what features most commonly follow this one. Designs
|
|
32
|
-
that resist extension require expensive rewrites later.
|
|
33
|
-
|
|
34
|
-
These standards apply to production code in established codebases. For prototypes, scripts,
|
|
35
|
-
or exploratory work, use judgment on which apply.
|
|
36
|
-
|
|
37
|
-
**Full checklist:** \`.aiwcli/_cc-native/plan-review/CODING-STANDARDS-CHECKLIST.md\`
|
|
38
|
-
Read this file for detailed guidance on each standard.`;
|
|
39
|
-
|
|
40
16
|
const PHASE_A_PROMPT = `## Plan Mode: Narrow the Approach After Exploration
|
|
41
17
|
|
|
42
18
|
After exploring the codebase, use AskUserQuestion — one call, 3-4 questions — before drafting the plan.
|
|
@@ -80,7 +56,6 @@ function main(): void {
|
|
|
80
56
|
|
|
81
57
|
logInfo("plan_questions_early", "Plan mode detected, injecting Phase A prompt");
|
|
82
58
|
emitContext(PHASE_A_PROMPT);
|
|
83
|
-
emitContext(CODING_STANDARDS_NUDGE);
|
|
84
59
|
}
|
|
85
60
|
|
|
86
61
|
runHook(main, "plan_questions_early");
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* Short-circuits immediately for resume calls (no prompt to validate).
|
|
7
7
|
*
|
|
8
8
|
* Design:
|
|
9
|
-
* - Resume calls (tool_input.resume present)
|
|
10
|
-
* - Missing/empty prompt
|
|
11
|
-
* - Non-empty prompt
|
|
9
|
+
* - Resume calls (tool_input.resume present) -> allow through, no inference
|
|
10
|
+
* - Missing/empty prompt -> allow through (fail open)
|
|
11
|
+
* - Non-empty prompt -> run AI validation via inference(), block if ok:false
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import {
|
|
@@ -19,9 +19,9 @@ import {
|
|
|
19
19
|
logWarn,
|
|
20
20
|
emitContextAndBlock,
|
|
21
21
|
getToolInput,
|
|
22
|
-
} from "../../
|
|
23
|
-
import { inference } from "../../
|
|
24
|
-
import { isInternalCall } from "../../
|
|
22
|
+
} from "../../_core/lib-ts/hooks/hook-utils.js";
|
|
23
|
+
import { inference } from "../../_core/lib-ts/runtime/inference.js";
|
|
24
|
+
import { isInternalCall } from "../../_core/lib-ts/runtime/subprocess-utils.js";
|
|
25
25
|
|
|
26
26
|
const VALIDATION_SYSTEM_PROMPT = `The sub-agent receives ONLY the prompt text — no conversation history, no prior context.
|
|
27
27
|
|
|
@@ -70,7 +70,7 @@ function main(): void {
|
|
|
70
70
|
logInfo("validate_task_prompt", "Blocking Task — prompt failed validation");
|
|
71
71
|
emitContextAndBlock(output, retryMessage);
|
|
72
72
|
}
|
|
73
|
-
// ok:true or anything else
|
|
73
|
+
// ok:true or anything else -> allow through (no output = no block)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
runHook(main, "validate_task_prompt");
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { extractFrontmatter, extractBody, aggregateAgents } from "../aggregate-agents.js";
|
|
5
|
+
import { createTempDir, cleanupTempDir } from "./helpers.js";
|
|
6
|
+
|
|
7
|
+
describe("aggregate-agents", () => {
|
|
8
|
+
describe("extractFrontmatter", () => {
|
|
9
|
+
it("extracts key-value pairs from frontmatter", () => {
|
|
10
|
+
const content = "---\nname: test-agent\nmodel: sonnet\nenabled: true\n---\nBody";
|
|
11
|
+
const result = extractFrontmatter(content);
|
|
12
|
+
expect(result).to.not.be.null;
|
|
13
|
+
expect(result!.name).to.equal("test-agent");
|
|
14
|
+
expect(result!.model).to.equal("sonnet");
|
|
15
|
+
expect(result!.enabled).to.equal(true);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("returns null when no frontmatter", () => {
|
|
19
|
+
expect(extractFrontmatter("No frontmatter here")).to.be.null;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("returns null when frontmatter not closed", () => {
|
|
23
|
+
expect(extractFrontmatter("---\nname: test\nno closing")).to.be.null;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("handles arrays in frontmatter", () => {
|
|
27
|
+
const content = "---\ncategories: [code, security]\n---\nBody";
|
|
28
|
+
const result = extractFrontmatter(content);
|
|
29
|
+
expect(result!.categories).to.deep.equal(["code", "security"]);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("handles boolean false", () => {
|
|
33
|
+
const content = "---\nenabled: false\n---\nBody";
|
|
34
|
+
const result = extractFrontmatter(content);
|
|
35
|
+
expect(result!.enabled).to.equal(false);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("handles quoted strings", () => {
|
|
39
|
+
const content = '---\nname: "quoted agent"\n---\nBody';
|
|
40
|
+
const result = extractFrontmatter(content);
|
|
41
|
+
expect(result!.name).to.equal("quoted agent");
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe("extractBody", () => {
|
|
46
|
+
it("extracts content after frontmatter", () => {
|
|
47
|
+
const content = "---\nname: test\n---\n\nBody content here.";
|
|
48
|
+
const result = extractBody(content);
|
|
49
|
+
expect(result).to.equal("Body content here.");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("returns full content when no frontmatter", () => {
|
|
53
|
+
const content = "Just body content.";
|
|
54
|
+
expect(extractBody(content)).to.equal("Just body content.");
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("returns full content when frontmatter not closed", () => {
|
|
58
|
+
const content = "---\nname: test\nno closing";
|
|
59
|
+
expect(extractBody(content)).to.equal(content);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe("aggregateAgents", () => {
|
|
64
|
+
let tmpDir: string;
|
|
65
|
+
|
|
66
|
+
beforeEach(() => { tmpDir = createTempDir("agents-test-"); });
|
|
67
|
+
afterEach(() => cleanupTempDir(tmpDir));
|
|
68
|
+
|
|
69
|
+
it("returns empty array when directory does not exist", () => {
|
|
70
|
+
const result = aggregateAgents(path.join(tmpDir, "nonexistent"));
|
|
71
|
+
expect(result).to.deep.equal([]);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("loads agents from markdown files", () => {
|
|
75
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
76
|
+
fs.writeFileSync(
|
|
77
|
+
path.join(tmpDir, "test-agent.md"),
|
|
78
|
+
"---\nname: test-agent\nmodel: sonnet\nfocus: testing\ncategories: [code]\n---\nYou are a test agent.",
|
|
79
|
+
);
|
|
80
|
+
const result = aggregateAgents(tmpDir);
|
|
81
|
+
expect(result).to.have.length(1);
|
|
82
|
+
expect(result[0]!.name).to.equal("test-agent");
|
|
83
|
+
expect(result[0]!.system_prompt).to.equal("You are a test agent.");
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("skips plan-orchestrator agent", () => {
|
|
87
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
88
|
+
fs.writeFileSync(
|
|
89
|
+
path.join(tmpDir, "plan-orchestrator.md"),
|
|
90
|
+
"---\nname: plan-orchestrator\n---\nOrchestrator prompt.",
|
|
91
|
+
);
|
|
92
|
+
fs.writeFileSync(
|
|
93
|
+
path.join(tmpDir, "real-agent.md"),
|
|
94
|
+
"---\nname: real-agent\n---\nReal agent prompt.",
|
|
95
|
+
);
|
|
96
|
+
const result = aggregateAgents(tmpDir);
|
|
97
|
+
expect(result).to.have.length(1);
|
|
98
|
+
expect(result[0]!.name).to.equal("real-agent");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("skips files without frontmatter", () => {
|
|
102
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
103
|
+
fs.writeFileSync(path.join(tmpDir, "no-fm.md"), "Just a readme.");
|
|
104
|
+
const result = aggregateAgents(tmpDir);
|
|
105
|
+
expect(result).to.have.length(0);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("defaults categories to [code]", () => {
|
|
109
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
110
|
+
fs.writeFileSync(
|
|
111
|
+
path.join(tmpDir, "simple.md"),
|
|
112
|
+
"---\nname: simple\n---\nPrompt.",
|
|
113
|
+
);
|
|
114
|
+
const result = aggregateAgents(tmpDir);
|
|
115
|
+
expect(result[0]!.categories).to.deep.equal(["code"]);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|