aiwcli 0.15.7 → 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 +106 -1125
- package/bin/run.js +0 -4
- package/dist/capabilities/installation/control-plane/clear-command.d.ts +2 -0
- package/dist/capabilities/installation/control-plane/clear-command.js +32 -3
- package/dist/capabilities/installation/control-plane/init-command.js +2 -2
- package/dist/capabilities/launch/contracts.d.ts +39 -4
- package/dist/capabilities/launch/control-plane/execute-launch.js +158 -119
- 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/commands/branch.d.ts +1 -1
- package/dist/commands/branch.js +1 -1
- package/dist/commands/launch.d.ts +0 -5
- package/dist/commands/launch.js +2 -37
- package/dist/lib/config.js +1 -2
- package/dist/lib/context/context-store.js +28 -2
- package/dist/lib/core-installer.d.ts +1 -1
- package/dist/lib/core-installer.js +6 -27
- 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.js +1 -1
- 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.js +11 -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.js +2 -14
- package/dist/lib/install-state.js +6 -13
- package/dist/lib/json-io.d.ts +12 -0
- package/dist/lib/json-io.js +30 -0
- package/dist/lib/multiplexer.d.ts +43 -35
- package/dist/lib/multiplexer.js +21 -2
- package/dist/lib/multiplexers/psmux.d.ts +14 -34
- package/dist/lib/multiplexers/psmux.js +70 -130
- package/dist/lib/multiplexers/tmux.d.ts +11 -19
- package/dist/lib/multiplexers/tmux.js +79 -120
- package/dist/lib/multiplexers/wezterm.d.ts +38 -0
- package/dist/lib/multiplexers/wezterm.js +225 -0
- package/dist/lib/mux-utils.d.ts +4 -3
- package/dist/lib/mux-utils.js +7 -13
- 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 +2 -0
- package/dist/lib/runtime/aiw-cli.js +3 -1
- package/dist/lib/runtime/cli-args.d.ts +5 -2
- package/dist/lib/runtime/cli-args.js +18 -3
- package/dist/lib/runtime/inference.js +3 -14
- package/dist/lib/runtime/models.d.ts +6 -0
- package/dist/lib/runtime/models.js +6 -0
- package/dist/lib/runtime/state-io.d.ts +2 -1
- package/dist/lib/runtime/state-io.js +9 -4
- package/dist/lib/runtime/utils.d.ts +8 -0
- package/dist/lib/runtime/utils.js +31 -1
- 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 +1 -0
- package/dist/lib/sentinel-wrapper.js +12 -3
- 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/spawn-errors.d.ts +3 -0
- package/dist/lib/spawn-errors.js +15 -1
- package/dist/lib/spinner.d.ts +0 -5
- package/dist/lib/spinner.js +0 -16
- package/dist/lib/template-installer.d.ts +10 -0
- package/dist/lib/template-installer.js +4 -4
- package/dist/lib/terminal-strategy.d.ts +1 -0
- package/dist/lib/terminal-strategy.js +12 -6
- package/dist/lib/terminal.d.ts +7 -5
- package/dist/lib/terminal.js +42 -19
- package/dist/lib/tmux-primitives.d.ts +0 -2
- package/dist/lib/tmux-primitives.js +0 -4
- package/dist/lib/tmux-session.js +2 -1
- package/dist/lib/windsurf-hooks-hierarchy.js +6 -23
- package/dist/platform/launch.d.ts +2 -1
- package/dist/platform/launch.js +1 -0
- package/dist/templates/CLAUDE.md +0 -1
- package/dist/templates/cc-native/.claude/settings.json +0 -10
- package/dist/templates/cc-native/TEMPLATE-SCHEMA.md +11 -4
- package/dist/templates/cc-native/_cc-native/cc-native.config.json +3 -7
- package/dist/templates/cc-native/_cc-native/hooks/CLAUDE.md +26 -47
- package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.ts +7 -9
- package/dist/templates/cc-native/_cc-native/hooks/enhance_plan_post_write.ts +2 -3
- package/dist/templates/cc-native/_cc-native/hooks/mark_questions_asked.ts +2 -2
- package/dist/templates/cc-native/_cc-native/hooks/plan_questions_early.ts +0 -25
- package/dist/templates/cc-native/_cc-native/hooks/validate_task_prompt.ts +4 -4
- 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 +16 -15
- package/dist/templates/cc-native/_cc-native/lib-ts/cli-output-parser.ts +132 -10
- package/dist/templates/cc-native/_cc-native/lib-ts/constants.ts +6 -6
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/corroboration.ts +119 -119
- package/dist/templates/cc-native/_cc-native/lib-ts/debug.ts +1 -2
- 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 +4 -4
- 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/{core/lib-ts/agent-exec → cc-native/_cc-native/lib-ts/reviewers/base}/base-agent.ts +138 -152
- 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 -224
- 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 +6 -7
- 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 +14 -17
- 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 +8 -9
- 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 +19 -21
- package/dist/templates/cc-native/_cc-native/lib-ts/types.ts +13 -88
- 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 +35 -0
- package/dist/templates/cc-native/_cc-native/plan-review/lib/agent-selection.ts +1 -1
- 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/{workflows/meta-plan.md → skills/meta-plan/SKILL.md} +6 -0
- package/dist/templates/core/{.cognition → .devin}/AGENTS.md +2 -2
- 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/core/hooks-ts/archive_plan.ts +1 -21
- package/dist/templates/core/hooks-ts/file-suggestion.ts +1 -19
- package/dist/templates/core/hooks-ts/pre_compact.ts +5 -18
- package/dist/templates/core/lib-ts/context/context-store.ts +29 -2
- package/dist/templates/core/lib-ts/hooks/hook-utils.ts +11 -0
- package/dist/templates/core/lib-ts/hooks/session-end-logic.ts +2 -13
- package/dist/templates/core/lib-ts/runtime/agent-launcher.ts +74 -0
- package/dist/templates/core/lib-ts/runtime/aiw-cli.ts +4 -2
- package/dist/templates/core/lib-ts/runtime/cli-args.ts +18 -4
- package/dist/templates/core/lib-ts/runtime/inference.ts +3 -15
- package/dist/templates/core/lib-ts/runtime/models.ts +7 -0
- package/dist/templates/core/lib-ts/runtime/state-io.ts +9 -4
- package/dist/templates/core/lib-ts/runtime/utils.ts +30 -1
- package/dist/templates/core/lib-ts/schemas.ts +233 -0
- package/dist/templates/core/scripts/resolve-run.ts +34 -2
- package/dist/templates/core/scripts/status_line.ts +1 -1
- package/dist/templates/core/skills/codex/CLAUDE.md +9 -4
- package/dist/templates/core/skills/codex/SKILL.md +6 -0
- package/dist/templates/core/skills/codex/lib/codex-watcher.ts +3 -10
- package/dist/templates/core/skills/codex/scripts/launch-codex.ts +26 -26
- package/dist/templates/core/skills/devin/CLAUDE.md +63 -6
- package/dist/templates/core/skills/devin/lib/devin-watcher.ts +116 -96
- package/dist/templates/core/skills/devin/scripts/launch-devin.ts +22 -21
- package/dist/templates/core/skills/handoff-system/CLAUDE.md +1 -1
- package/oclif.manifest.json +4 -4
- package/package.json +4 -4
- package/dist/lib/base-command.d.ts +0 -1
- package/dist/lib/base-command.js +0 -1
- package/dist/lib/env-compat.d.ts +0 -18
- package/dist/lib/env-compat.js +0 -23
- package/dist/lib/launch-options.d.ts +0 -1
- package/dist/lib/launch-options.js +0 -1
- package/dist/lib/stdin.d.ts +0 -48
- package/dist/lib/stdin.js +0 -60
- 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/reviewers/base/base-agent.ts +0 -7
- package/dist/templates/core/.codex/workflows/codex.md +0 -17
- package/dist/templates/core/.codex/workflows/handoff.md +0 -5
- package/dist/templates/core/lib-ts/agent-exec/backends/headless.ts +0 -34
- package/dist/templates/core/lib-ts/agent-exec/backends/index.ts +0 -6
- package/dist/templates/core/lib-ts/agent-exec/backends/tmux.ts +0 -148
- package/dist/templates/core/lib-ts/agent-exec/execution-backend.ts +0 -50
- package/dist/templates/core/lib-ts/agent-exec/index.ts +0 -6
- package/dist/templates/core/lib-ts/agent-exec/structured-output.ts +0 -165
- /package/dist/templates/core/{.cognition → .devin}/config.json +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PsmuxMultiplexer — unified psmux (Windows ConPTY) backend.
|
|
3
|
-
*
|
|
3
|
+
* Composes with PowerShellAdapter for command building.
|
|
4
|
+
* Owns: version checking, session readiness polling, bootstrap defaults.
|
|
4
5
|
*/
|
|
5
6
|
import { existsSync, readdirSync, writeFileSync } from 'node:fs';
|
|
6
7
|
import * as os from 'node:os';
|
|
7
8
|
import path from 'node:path';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
9
|
+
import { sanitizedProcessEnv } from '../env-sanitizer.js';
|
|
10
|
+
import { PANE_HOLD_MESSAGE, buildBootstrapPrompt, getLastLine, spawnAttached, splitFlagFromDimensions } from '../mux-utils.js';
|
|
10
11
|
import { execFileAsync, findExecutable } from '../runtime/subprocess-utils.js';
|
|
11
|
-
import {
|
|
12
|
-
import { quoteForPowerShell, toEncodedPowerShell } from '../shell-quoting.js';
|
|
12
|
+
import { PowerShellAdapter } from '../shell-adapters/powershell-adapter.js';
|
|
13
13
|
const MIN_VERSION = { major: 0, minor: 4, patch: 0 };
|
|
14
14
|
const ATTACH_RETRY_DELAY_MS = 200;
|
|
15
15
|
const SESSION_READY_BACKOFF_MS = [50, 100, 150, 250];
|
|
@@ -37,27 +37,9 @@ export function parseVersionString(stdout) {
|
|
|
37
37
|
patch: Number(match[3]),
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
/** @internal */
|
|
41
|
-
export function
|
|
42
|
-
|
|
43
|
-
return args;
|
|
44
|
-
const absolutePromptPath = path.resolve(promptPath);
|
|
45
|
-
const bootstrap = `Read startup instructions from this file path before taking action: ${formatPromptPathForBootstrap(absolutePromptPath)}. Use that file as the initial context.`;
|
|
46
|
-
return [...args, bootstrap];
|
|
47
|
-
}
|
|
48
|
-
/** @internal */
|
|
49
|
-
export function buildPowerShellToolCommand(params) {
|
|
50
|
-
const { toolPath, args, env, mode, promptPath } = params;
|
|
51
|
-
const envPrefix = Object.entries(env)
|
|
52
|
-
.map(([key, value]) => `$env:${key}=${quoteForPowerShell(value)}`)
|
|
53
|
-
.join('; ');
|
|
54
|
-
const commandArgs = buildCommandArgs(args, mode, promptPath);
|
|
55
|
-
const argArray = commandArgs.map((arg) => quoteForPowerShell(arg)).join(', ');
|
|
56
|
-
const invocation = `& ${quoteForPowerShell(toolPath)}${argArray ? ` @(${argArray})` : ''}`;
|
|
57
|
-
const body = mode === 'exec' && promptPath
|
|
58
|
-
? `Get-Content -Raw -Path ${quoteForPowerShell(promptPath)} | ${invocation}`
|
|
59
|
-
: invocation;
|
|
60
|
-
return [envPrefix, body].filter(Boolean).join('; ');
|
|
40
|
+
/** @internal — translate unified SplitDirection to psmux flag. */
|
|
41
|
+
export function toPsmuxSplitFlag(direction) {
|
|
42
|
+
return direction === 'horizontal' ? '-h' : '-v';
|
|
61
43
|
}
|
|
62
44
|
/** @internal */
|
|
63
45
|
export function buildCreateSessionArgs(params) {
|
|
@@ -82,15 +64,11 @@ export function buildAttachArgs(sessionName) {
|
|
|
82
64
|
export class PsmuxMultiplexer {
|
|
83
65
|
backend = 'psmux';
|
|
84
66
|
psmuxPath;
|
|
67
|
+
shell;
|
|
85
68
|
constructor(psmuxPath) {
|
|
86
69
|
this.psmuxPath = psmuxPath;
|
|
70
|
+
this.shell = new PowerShellAdapter();
|
|
87
71
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Check if psmux is installed and meets version requirements.
|
|
90
|
-
* Checks PATH first, then probes the winget install directory
|
|
91
|
-
* (winget install doesn't always add packages to PATH).
|
|
92
|
-
* Returns a PsmuxMultiplexer instance or null.
|
|
93
|
-
*/
|
|
94
72
|
static async create() {
|
|
95
73
|
if (process.platform !== 'win32')
|
|
96
74
|
return null;
|
|
@@ -107,48 +85,40 @@ export class PsmuxMultiplexer {
|
|
|
107
85
|
return null;
|
|
108
86
|
return new PsmuxMultiplexer(psmuxPath);
|
|
109
87
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
88
|
+
resolveStrategy(ctx) {
|
|
89
|
+
if (ctx.disableMux) {
|
|
90
|
+
return { strategy: 'inline', reason: 'Multiplexer disabled via --no-tmux' };
|
|
91
|
+
}
|
|
92
|
+
if (Boolean(process.env.PSMUX_PANE)) {
|
|
93
|
+
return { strategy: 'split', reason: 'Inside psmux session' };
|
|
94
|
+
}
|
|
95
|
+
return { strategy: 'create-session', reason: 'Outside psmux — will create new session' };
|
|
96
|
+
}
|
|
115
97
|
async createSession(options) {
|
|
116
|
-
const { sessionName, reattach, enableMouse = true } = options;
|
|
98
|
+
const { sessionName, reattach, enableMouse = true, cwd } = options;
|
|
117
99
|
let promptFilePath;
|
|
118
100
|
if (options.promptText) {
|
|
119
101
|
promptFilePath = path.join(os.tmpdir(), `aiwcli-prompt-${Date.now()}-${process.pid}.txt`);
|
|
120
102
|
writeFileSync(promptFilePath, options.promptText, { encoding: 'utf8', mode: 0o600 });
|
|
121
103
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const commandWithEnv = `$env:PSMUX_PANE='1'; ${shellCommand}`;
|
|
104
|
+
const shellCommand = buildPsmuxShellCommand(this.shell, options, promptFilePath);
|
|
105
|
+
// Inject PSMUX_PANE=1 for inside-session detection + nesting cleanup
|
|
106
|
+
const nestingCleanup = this.shell.buildNestingCleanup();
|
|
107
|
+
const commandWithEnv = `$env:PSMUX_PANE='1'; ${nestingCleanup} ${shellCommand}`;
|
|
126
108
|
const psmuxArgs = buildCreateSessionArgs({
|
|
127
109
|
sessionName,
|
|
128
|
-
cwd
|
|
129
|
-
encodedCommand:
|
|
110
|
+
cwd,
|
|
111
|
+
encodedCommand: this.shell.encodeForExecution(commandWithEnv),
|
|
130
112
|
});
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (!exists) {
|
|
134
|
-
const detachedCreate = await execFileAsync(this.psmuxPath, psmuxArgs, { timeout: 5000 });
|
|
135
|
-
if (detachedCreate.exitCode !== 0) {
|
|
136
|
-
const stderr = detachedCreate.stderr.trim();
|
|
137
|
-
return {
|
|
138
|
-
exitCode: detachedCreate.exitCode ?? 1,
|
|
139
|
-
usedMux: false,
|
|
140
|
-
reason: stderr ? `psmux new-session failed: ${stderr}` : 'psmux new-session failed',
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
113
|
+
const shouldCreate = !reattach || !(await this.hasSession(sessionName));
|
|
114
|
+
if (shouldCreate) {
|
|
146
115
|
const detachedCreate = await execFileAsync(this.psmuxPath, psmuxArgs, { timeout: 5000 });
|
|
147
116
|
if (detachedCreate.exitCode !== 0) {
|
|
148
117
|
const stderr = detachedCreate.stderr.trim();
|
|
149
118
|
return {
|
|
119
|
+
launched: false,
|
|
150
120
|
exitCode: detachedCreate.exitCode ?? 1,
|
|
151
|
-
|
|
121
|
+
backend: this.backend,
|
|
152
122
|
reason: stderr ? `psmux new-session failed: ${stderr}` : 'psmux new-session failed',
|
|
153
123
|
};
|
|
154
124
|
}
|
|
@@ -156,112 +126,88 @@ export class PsmuxMultiplexer {
|
|
|
156
126
|
const ready = await this.waitForSessionReady(sessionName);
|
|
157
127
|
if (!ready) {
|
|
158
128
|
return {
|
|
129
|
+
launched: false,
|
|
159
130
|
exitCode: 1,
|
|
160
|
-
|
|
131
|
+
backend: this.backend,
|
|
161
132
|
reason: `psmux session '${sessionName}' not ready for attach`,
|
|
162
133
|
};
|
|
163
134
|
}
|
|
164
135
|
await this.applyBootstrapDefaults(enableMouse);
|
|
165
136
|
const attachArgs = buildAttachArgs(sessionName);
|
|
166
|
-
const env =
|
|
137
|
+
const env = sanitizedProcessEnv();
|
|
167
138
|
const firstAttach = await spawnAttached(this.psmuxPath, attachArgs, env, this.backend);
|
|
168
|
-
if (firstAttach.
|
|
139
|
+
if (firstAttach.launched || (firstAttach.exitCode !== undefined && firstAttach.exitCode !== 1))
|
|
169
140
|
return firstAttach;
|
|
170
141
|
await waitMs(ATTACH_RETRY_DELAY_MS);
|
|
171
142
|
const secondAttach = await spawnAttached(this.psmuxPath, attachArgs, env, this.backend);
|
|
172
|
-
if (secondAttach.
|
|
143
|
+
if (secondAttach.launched || (secondAttach.exitCode !== undefined && secondAttach.exitCode !== 1))
|
|
173
144
|
return secondAttach;
|
|
174
145
|
return {
|
|
175
146
|
...secondAttach,
|
|
176
147
|
reason: 'psmux attach failed after retry (auth/session readiness race)',
|
|
177
|
-
|
|
148
|
+
launched: false,
|
|
178
149
|
};
|
|
179
150
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
* Uses PSMUX_PANE env var that we inject in createSession().
|
|
183
|
-
*/
|
|
184
|
-
isInsideSession() {
|
|
185
|
-
return Boolean(process.env.PSMUX_PANE);
|
|
186
|
-
}
|
|
187
|
-
async kill(paneId) {
|
|
188
|
-
if (!paneId)
|
|
151
|
+
async kill(handle) {
|
|
152
|
+
if (!handle)
|
|
189
153
|
return;
|
|
190
|
-
await execFileAsync(this.psmuxPath, ['kill-pane', '-t',
|
|
154
|
+
await execFileAsync(this.psmuxPath, ['kill-pane', '-t', handle], { timeout: 3000 });
|
|
191
155
|
}
|
|
192
|
-
async
|
|
193
|
-
const mode = options
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
// Resolve tool path — psmux uses native Windows paths directly
|
|
198
|
-
const toolPath = findExecutable(options.toolName);
|
|
199
|
-
if (!toolPath) {
|
|
200
|
-
return { launched: false, backend: this.backend, reason: `${options.toolName} not found on PATH` };
|
|
156
|
+
async split(options) {
|
|
157
|
+
const { toolName, args, env, cwd, mode, sentinelPath } = options;
|
|
158
|
+
const nativePath = findExecutable(toolName);
|
|
159
|
+
if (!nativePath) {
|
|
160
|
+
return { launched: false, backend: this.backend, reason: `${toolName} not found on PATH` };
|
|
201
161
|
}
|
|
202
|
-
// Sentinel IPC
|
|
203
|
-
const useSentinel = options.sentinel !== false;
|
|
204
|
-
const sentinel = useSentinel ? createSentinelIpcPaths(`aiwcli-pane-${options.toolName}`) : null;
|
|
205
162
|
try {
|
|
206
|
-
const baseCommand =
|
|
207
|
-
toolPath,
|
|
163
|
+
const baseCommand = this.shell.buildToolCommand({
|
|
164
|
+
toolPath: nativePath,
|
|
208
165
|
args,
|
|
209
|
-
env
|
|
166
|
+
env,
|
|
210
167
|
mode,
|
|
211
168
|
...(options.promptPath ? { promptPath: options.promptPath } : {}),
|
|
212
169
|
});
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
// Wrap in PowerShell using -EncodedCommand to avoid double-quote expansion issues
|
|
225
|
-
const effectivePaneCommand = toEncodedPowerShell(paneCommand);
|
|
170
|
+
const holdMessage = PANE_HOLD_MESSAGE;
|
|
171
|
+
const wrappedCommand = this.shell.wrapSentinel({
|
|
172
|
+
command: baseCommand,
|
|
173
|
+
sentinelPath,
|
|
174
|
+
autoClose: false,
|
|
175
|
+
holdPane: false,
|
|
176
|
+
holdMessage,
|
|
177
|
+
});
|
|
178
|
+
const effectiveCommand = this.shell.encodeForExecution(wrappedCommand);
|
|
226
179
|
// Resolve split direction
|
|
227
|
-
const splitDirection = options.split
|
|
180
|
+
const splitDirection = options.split;
|
|
228
181
|
let splitFlag;
|
|
229
182
|
if (splitDirection === 'auto') {
|
|
230
183
|
splitFlag = await this.resolveAutoSplit();
|
|
231
184
|
}
|
|
232
185
|
else {
|
|
233
|
-
splitFlag = splitDirection
|
|
186
|
+
splitFlag = toPsmuxSplitFlag(splitDirection);
|
|
234
187
|
}
|
|
235
188
|
await this.applyBootstrapDefaults();
|
|
236
|
-
// Build psmux split-window command
|
|
237
189
|
const psmuxArgs = buildSplitWindowArgs({
|
|
238
190
|
splitFlag,
|
|
239
|
-
encodedCommand:
|
|
191
|
+
encodedCommand: effectiveCommand,
|
|
240
192
|
cwd,
|
|
241
|
-
splitTarget: options.splitTarget,
|
|
242
193
|
});
|
|
243
194
|
const split = await execFileAsync(this.psmuxPath, psmuxArgs, { timeout: 5000 });
|
|
244
195
|
if (split.exitCode !== 0) {
|
|
245
|
-
if (sentinel)
|
|
246
|
-
cleanupSentinelIpc(sentinel);
|
|
247
196
|
return {
|
|
248
197
|
launched: false,
|
|
249
198
|
backend: this.backend,
|
|
250
199
|
reason: 'psmux split-window failed',
|
|
251
|
-
stderr: split.stderr.trim() || undefined,
|
|
252
200
|
};
|
|
253
201
|
}
|
|
254
|
-
const
|
|
202
|
+
const handle = getLastLine(split.stdout) || undefined;
|
|
255
203
|
return {
|
|
256
204
|
launched: true,
|
|
257
205
|
backend: this.backend,
|
|
258
|
-
|
|
259
|
-
sentinelPath
|
|
206
|
+
handle,
|
|
207
|
+
sentinelPath,
|
|
260
208
|
};
|
|
261
209
|
}
|
|
262
210
|
catch (error) {
|
|
263
|
-
if (sentinel)
|
|
264
|
-
cleanupSentinelIpc(sentinel);
|
|
265
211
|
return {
|
|
266
212
|
launched: false,
|
|
267
213
|
backend: this.backend,
|
|
@@ -314,9 +260,6 @@ export class PsmuxMultiplexer {
|
|
|
314
260
|
return poll(0);
|
|
315
261
|
}
|
|
316
262
|
}
|
|
317
|
-
// Probe winget package dir for psmux.exe.
|
|
318
|
-
// winget install drops the binary under %LOCALAPPDATA%/Microsoft/WinGet/Packages/
|
|
319
|
-
// but does not always add it to PATH.
|
|
320
263
|
function findPsmuxInWinget() {
|
|
321
264
|
const localAppData = process.env.LOCALAPPDATA;
|
|
322
265
|
if (!localAppData)
|
|
@@ -346,25 +289,22 @@ export function buildPsmuxBootstrapCommands(enableMouse = true) {
|
|
|
346
289
|
return commands;
|
|
347
290
|
}
|
|
348
291
|
/** @internal */
|
|
349
|
-
export function buildPsmuxShellCommand(opts, promptFilePath) {
|
|
292
|
+
export function buildPsmuxShellCommand(shell, opts, promptFilePath) {
|
|
350
293
|
const { toolPath, toolArgs } = opts;
|
|
351
294
|
const cmdParts = [];
|
|
352
|
-
cmdParts.push(`& ${
|
|
295
|
+
cmdParts.push(`& ${shell.quote(toolPath)}`);
|
|
353
296
|
for (const arg of toolArgs) {
|
|
354
|
-
cmdParts.push(
|
|
297
|
+
cmdParts.push(shell.quote(arg));
|
|
355
298
|
}
|
|
356
299
|
if (promptFilePath) {
|
|
357
|
-
const
|
|
358
|
-
|
|
300
|
+
const formatted = process.platform === 'win32'
|
|
301
|
+
? promptFilePath.replaceAll('\\', '/')
|
|
302
|
+
: promptFilePath;
|
|
303
|
+
const bootstrap = buildBootstrapPrompt(formatted);
|
|
304
|
+
cmdParts.push(shell.quote(bootstrap));
|
|
359
305
|
}
|
|
360
306
|
return cmdParts.join(' ');
|
|
361
307
|
}
|
|
362
|
-
/** @internal */
|
|
363
|
-
export function formatPromptPathForBootstrap(promptPath) {
|
|
364
|
-
if (process.platform !== 'win32')
|
|
365
|
-
return promptPath;
|
|
366
|
-
return promptPath.replaceAll('\\', '/');
|
|
367
|
-
}
|
|
368
308
|
async function runBootstrapCommands(psmuxPath, commands, index = 0) {
|
|
369
309
|
const command = commands[index];
|
|
370
310
|
if (!command)
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TmuxMultiplexer — unified tmux backend.
|
|
3
|
-
*
|
|
3
|
+
* Composes with BashAdapter for command building.
|
|
4
|
+
* Owns: split direction resolution, tmux session config, Windows bootstrap.
|
|
4
5
|
*/
|
|
5
|
-
import type { CreateSessionOptions,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export declare function buildShToolCommand(params: {
|
|
10
|
-
args: string[];
|
|
11
|
-
env: Record<string, string>;
|
|
12
|
-
mode: 'exec' | 'repl';
|
|
13
|
-
promptPath?: string;
|
|
14
|
-
promptText?: string | undefined;
|
|
15
|
-
toolPath: string;
|
|
16
|
-
}): string;
|
|
17
|
-
/** @internal */
|
|
18
|
-
export declare function buildCommandArgs(args: string[], mode: 'exec' | 'repl', promptText?: string): string[];
|
|
6
|
+
import type { CreateSessionOptions, LaunchResult, Multiplexer, ResolvedStrategy, SplitOptions, StrategyContext } from '../multiplexer.js';
|
|
7
|
+
import { type TmuxSplitFlag } from '../tmux-pane-placement.js';
|
|
8
|
+
/** @internal — translate unified SplitDirection to tmux flag. */
|
|
9
|
+
export declare function toTmuxSplitFlag(direction: 'horizontal' | 'vertical'): TmuxSplitFlag;
|
|
19
10
|
/** @internal */
|
|
20
11
|
export declare function withWindowsTmuxBootstrap(command: string, platform?: NodeJS.Platform): string;
|
|
21
12
|
/** @internal */
|
|
@@ -35,10 +26,11 @@ export declare function buildTmuxCreateSessionArgs(params: {
|
|
|
35
26
|
export declare class TmuxMultiplexer implements Multiplexer {
|
|
36
27
|
readonly backend: "tmux";
|
|
37
28
|
private readonly tmuxPath;
|
|
29
|
+
private readonly shell;
|
|
38
30
|
private constructor();
|
|
39
31
|
static create(): null | TmuxMultiplexer;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
kill(
|
|
43
|
-
|
|
32
|
+
resolveStrategy(ctx: StrategyContext): ResolvedStrategy;
|
|
33
|
+
createSession(options: CreateSessionOptions): Promise<LaunchResult>;
|
|
34
|
+
kill(handle: string): Promise<void>;
|
|
35
|
+
split(options: SplitOptions): Promise<LaunchResult>;
|
|
44
36
|
}
|