@caupulican/pi-adaptative 0.81.38 → 0.81.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +79 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/README.md +18 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +131 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +196 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +308 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +22 -2
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +585 -24
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +749 -27
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/__init__.py +43 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/fs.py +270 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/search.py +252 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/strings.py +399 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +575 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/context.py +52 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/errors.py +49 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +734 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/expand.py +238 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +132 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/nodes.py +116 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/parser.py +287 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/proc.py +137 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +100 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +579 -0
- package/dist/bundled-resources/skills/tool-call-repair/SKILL.md +19 -9
- package/dist/bundled-resources/skills/tool-call-repair/references/failure-grammar.md +22 -5
- package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +5 -5
- package/dist/bundled-resources/skills/tool-call-repair/references/text-protocol-grammar.md +28 -7
- package/dist/cli/args.d.ts +3 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +15 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-paths.d.ts +49 -0
- package/dist/core/agent-paths.d.ts.map +1 -0
- package/dist/core/agent-paths.js +107 -0
- package/dist/core/agent-paths.js.map +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +3 -3
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +234 -17
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +484 -62
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts +9 -0
- package/dist/core/autonomy/contracts.d.ts.map +1 -1
- package/dist/core/autonomy/contracts.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts +10 -1
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +5 -1
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +122 -6
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +446 -89
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bash-execution-controller.d.ts +4 -0
- package/dist/core/bash-execution-controller.d.ts.map +1 -1
- package/dist/core/bash-execution-controller.js +7 -1
- package/dist/core/bash-execution-controller.js.map +1 -1
- package/dist/core/compaction-support.d.ts +13 -3
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +43 -7
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/context-audit.d.ts +33 -1
- package/dist/core/context/context-audit.d.ts.map +1 -1
- package/dist/core/context/context-audit.js +31 -5
- package/dist/core/context/context-audit.js.map +1 -1
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +16 -1
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +26 -4
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +137 -14
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost-guard.d.ts +19 -3
- package/dist/core/cost-guard.d.ts.map +1 -1
- package/dist/core/cost-guard.js +18 -3
- package/dist/core/cost-guard.js.map +1 -1
- package/dist/core/delegation/session-worker-result.d.ts +34 -4
- package/dist/core/delegation/session-worker-result.d.ts.map +1 -1
- package/dist/core/delegation/session-worker-result.js +64 -4
- package/dist/core/delegation/session-worker-result.js.map +1 -1
- package/dist/core/delegation/worker-result.d.ts +42 -1
- package/dist/core/delegation/worker-result.d.ts.map +1 -1
- package/dist/core/delegation/worker-result.js +68 -0
- package/dist/core/delegation/worker-result.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +20 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +1 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +51 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts +17 -1
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +79 -11
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-controller.d.ts +48 -2
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js +77 -0
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts +39 -0
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.js +42 -0
- package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts +4 -0
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js +51 -10
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.d.ts +101 -2
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js +87 -4
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-state.d.ts +89 -1
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +71 -5
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +56 -2
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +111 -5
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/session-goal-state.d.ts +11 -2
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js +32 -17
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/keybindings.d.ts +10 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +10 -2
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/learning/observation-store.d.ts +12 -3
- package/dist/core/learning/observation-store.d.ts.map +1 -1
- package/dist/core/learning/observation-store.js +30 -15
- package/dist/core/learning/observation-store.js.map +1 -1
- package/dist/core/learning/skill-curator.d.ts +5 -1
- package/dist/core/learning/skill-curator.d.ts.map +1 -1
- package/dist/core/learning/skill-curator.js +21 -19
- package/dist/core/learning/skill-curator.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts +65 -3
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js +186 -26
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/memory/providers/file-store.d.ts +1 -1
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +6 -6
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/model-capability.d.ts +34 -0
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +42 -1
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-router/tool-escalation.d.ts +15 -0
- package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
- package/dist/core/model-router/tool-escalation.js +23 -1
- package/dist/core/model-router/tool-escalation.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +34 -7
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +95 -16
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/models/adaptation-store.d.ts +7 -0
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +47 -11
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
- package/dist/core/models/default-model-suggestions.js +17 -0
- package/dist/core/models/default-model-suggestions.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts +3 -0
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +11 -2
- package/dist/core/models/fitness-store.js.map +1 -1
- package/dist/core/models/llamacpp-runtime.d.ts +180 -0
- package/dist/core/models/llamacpp-runtime.d.ts.map +1 -0
- package/dist/core/models/llamacpp-runtime.js +475 -0
- package/dist/core/models/llamacpp-runtime.js.map +1 -0
- package/dist/core/models/local-registration.d.ts +40 -0
- package/dist/core/models/local-registration.d.ts.map +1 -1
- package/dist/core/models/local-registration.js +94 -5
- package/dist/core/models/local-registration.js.map +1 -1
- package/dist/core/models/local-runtime.d.ts.map +1 -1
- package/dist/core/models/local-runtime.js +6 -5
- package/dist/core/models/local-runtime.js.map +1 -1
- package/dist/core/models/model-ref.d.ts +7 -0
- package/dist/core/models/model-ref.d.ts.map +1 -1
- package/dist/core/models/model-ref.js +26 -0
- package/dist/core/models/model-ref.js.map +1 -1
- package/dist/core/models/needle-runtime.d.ts +257 -0
- package/dist/core/models/needle-runtime.d.ts.map +1 -0
- package/dist/core/models/needle-runtime.js +519 -0
- package/dist/core/models/needle-runtime.js.map +1 -0
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts +89 -0
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -0
- package/dist/core/models/prism-llamacpp-lifecycle.js +121 -0
- package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +11 -10
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/process-matrix/codes.d.ts +72 -0
- package/dist/core/process-matrix/codes.d.ts.map +1 -0
- package/dist/core/process-matrix/codes.js +15 -0
- package/dist/core/process-matrix/codes.js.map +1 -0
- package/dist/core/process-matrix/runtime.d.ts +63 -0
- package/dist/core/process-matrix/runtime.d.ts.map +1 -0
- package/dist/core/process-matrix/runtime.js +310 -0
- package/dist/core/process-matrix/runtime.js.map +1 -0
- package/dist/core/process-matrix/store.d.ts +22 -0
- package/dist/core/process-matrix/store.d.ts.map +1 -0
- package/dist/core/process-matrix/store.js +80 -0
- package/dist/core/process-matrix/store.js.map +1 -0
- package/dist/core/process-matrix/supervisor.d.ts +72 -0
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -0
- package/dist/core/process-matrix/supervisor.js +130 -0
- package/dist/core/process-matrix/supervisor.js.map +1 -0
- package/dist/core/profile-registry.d.ts +7 -0
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +20 -0
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/python-runtime.d.ts.map +1 -1
- package/dist/core/python-runtime.js +3 -3
- package/dist/core/python-runtime.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +29 -5
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +215 -126
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts +36 -0
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +44 -0
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +8 -7
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +58 -5
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +209 -25
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/scout-controller.d.ts +6 -0
- package/dist/core/scout-controller.d.ts.map +1 -1
- package/dist/core/scout-controller.js +66 -52
- package/dist/core/scout-controller.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +3 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-role.d.ts +31 -0
- package/dist/core/session-role.d.ts.map +1 -0
- package/dist/core/session-role.js +52 -0
- package/dist/core/session-role.js.map +1 -0
- package/dist/core/settings-manager.d.ts +42 -3
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +94 -60
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +12 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +6 -0
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.d.ts +14 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +20 -3
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts +11 -2
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js +27 -11
- package/dist/core/tasks/session-task-state.js.map +1 -1
- package/dist/core/tasks/task-contract-monitor.d.ts +45 -0
- package/dist/core/tasks/task-contract-monitor.d.ts.map +1 -0
- package/dist/core/tasks/task-contract-monitor.js +56 -0
- package/dist/core/tasks/task-contract-monitor.js.map +1 -0
- package/dist/core/tasks/task-state.d.ts +8 -0
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js +28 -1
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/tool-gate-controller.d.ts.map +1 -1
- package/dist/core/tool-gate-controller.js +5 -0
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-recovery-log-records.d.ts +7 -0
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js +14 -6
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-selection/promotion.d.ts +54 -0
- package/dist/core/tool-selection/promotion.d.ts.map +1 -0
- package/dist/core/tool-selection/promotion.js +81 -0
- package/dist/core/tool-selection/promotion.js.map +1 -0
- package/dist/core/tool-selection/tool-performance-store.d.ts +37 -0
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +87 -3
- package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.d.ts +45 -0
- package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.js +96 -0
- package/dist/core/tool-selection/tool-selection-controller.js.map +1 -1
- package/dist/core/tools/bash.d.ts +18 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +95 -16
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +14 -0
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +82 -7
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +25 -8
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/goal.d.ts +94 -3
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +165 -15
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts +7 -0
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js +2 -2
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/shell-contract-router.d.ts +6 -1
- package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
- package/dist/core/tools/shell-contract-router.js +23 -2
- package/dist/core/tools/shell-contract-router.js.map +1 -1
- package/dist/core/tools/shell-session.d.ts +89 -0
- package/dist/core/tools/shell-session.d.ts.map +1 -0
- package/dist/core/tools/shell-session.js +432 -0
- package/dist/core/tools/shell-session.js.map +1 -0
- package/dist/core/tools/task-steps.d.ts +4 -0
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +63 -8
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts +86 -0
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -0
- package/dist/core/tools/tmux-dispatch.js +91 -0
- package/dist/core/tools/tmux-dispatch.js.map +1 -0
- package/dist/core/tools/windows-shell-engine.d.ts +42 -0
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -0
- package/dist/core/tools/windows-shell-engine.js +153 -0
- package/dist/core/tools/windows-shell-engine.js.map +1 -0
- package/dist/core/tools/windows-shell-state.d.ts +40 -0
- package/dist/core/tools/windows-shell-state.d.ts.map +1 -0
- package/dist/core/tools/windows-shell-state.js +59 -0
- package/dist/core/tools/windows-shell-state.js.map +1 -0
- package/dist/core/tools/worktree-sync.d.ts +24 -0
- package/dist/core/tools/worktree-sync.d.ts.map +1 -0
- package/dist/core/tools/worktree-sync.js +338 -0
- package/dist/core/tools/worktree-sync.js.map +1 -0
- package/dist/core/trust-manager.d.ts +4 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +20 -2
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +55 -0
- package/dist/core/util/atomic-file.d.ts.map +1 -0
- package/dist/core/util/atomic-file.js +255 -0
- package/dist/core/util/atomic-file.js.map +1 -0
- package/dist/core/util/minimatch-cache.d.ts +33 -0
- package/dist/core/util/minimatch-cache.d.ts.map +1 -0
- package/dist/core/util/minimatch-cache.js +0 -0
- package/dist/core/util/minimatch-cache.js.map +1 -0
- package/dist/core/worktree-sync/codes.d.ts +227 -0
- package/dist/core/worktree-sync/codes.d.ts.map +1 -0
- package/dist/core/worktree-sync/codes.js +14 -0
- package/dist/core/worktree-sync/codes.js.map +1 -0
- package/dist/core/worktree-sync/git-engine.d.ts +156 -0
- package/dist/core/worktree-sync/git-engine.d.ts.map +1 -0
- package/dist/core/worktree-sync/git-engine.js +1191 -0
- package/dist/core/worktree-sync/git-engine.js.map +1 -0
- package/dist/core/worktree-sync/lane-gate.d.ts +75 -0
- package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -0
- package/dist/core/worktree-sync/lane-gate.js +360 -0
- package/dist/core/worktree-sync/lane-gate.js.map +1 -0
- package/dist/core/worktree-sync/runtime.d.ts +47 -0
- package/dist/core/worktree-sync/runtime.d.ts.map +1 -0
- package/dist/core/worktree-sync/runtime.js +96 -0
- package/dist/core/worktree-sync/runtime.js.map +1 -0
- package/dist/core/worktree-sync/store.d.ts +69 -0
- package/dist/core/worktree-sync/store.d.ts.map +1 -0
- package/dist/core/worktree-sync/store.js +247 -0
- package/dist/core/worktree-sync/store.js.map +1 -0
- package/dist/core/worktree-sync/watcher.d.ts +29 -0
- package/dist/core/worktree-sync/watcher.d.ts.map +1 -0
- package/dist/core/worktree-sync/watcher.js +93 -0
- package/dist/core/worktree-sync/watcher.js.map +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +94 -0
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +9 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +38 -0
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts +16 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +50 -8
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.js +23 -1
- package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +4 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/local-model-commands.d.ts +43 -0
- package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
- package/dist/modes/interactive/local-model-commands.js +290 -3
- package/dist/modes/interactive/local-model-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +24 -4
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/utils/fs-watch.d.ts +11 -0
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js +20 -2
- package/dist/utils/fs-watch.js.map +1 -1
- package/dist/utils/highlight-js-languages.d.ts +4 -0
- package/dist/utils/highlight-js-languages.d.ts.map +1 -0
- package/dist/utils/highlight-js-languages.js +573 -0
- package/dist/utils/highlight-js-languages.js.map +1 -0
- package/dist/utils/shell.d.ts +7 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +21 -6
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +53 -5
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +112 -1
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/process-matrix.md +120 -0
- package/docs/settings.md +3 -0
- package/docs/tmux-agent-manager.md +85 -2
- package/docs/windows.md +52 -3
- package/docs/work-directory.md +29 -0
- package/docs/worktree-sync.md +250 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +10 -4
- package/docs/integration-sweep-builder-blueprint-2026-07-09.md +0 -365
- package/docs/integration-sweep-resume-2026-07-09.md +0 -407
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
"""Text/stream builtins: cat, head, tail, wc, sort, uniq, cut, tr.
|
|
2
|
+
|
|
3
|
+
Pure `BuiltinFn`s per context.py §1.5: read `ctx.stdin` when no file operand,
|
|
4
|
+
write to `ctx.stdout`, never touch state. Behavior matches
|
|
5
|
+
windows-shell-workpackages-2026-07-19.md §2.2 exactly, including the
|
|
6
|
+
documented divergences (wc/uniq -c column widths, ordinal sort).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import os
|
|
12
|
+
import re
|
|
13
|
+
from typing import TYPE_CHECKING
|
|
14
|
+
|
|
15
|
+
from errors import UnsupportedConstruct
|
|
16
|
+
|
|
17
|
+
if TYPE_CHECKING:
|
|
18
|
+
from context import BuiltinContext
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _read_stdin(ctx: "BuiltinContext") -> bytes:
|
|
22
|
+
return ctx.stdin.read()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _resolve_path(ctx: "BuiltinContext", path: str) -> str:
|
|
26
|
+
if os.path.isabs(path):
|
|
27
|
+
return path
|
|
28
|
+
return os.path.join(ctx.cwd, path)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _split_flags_and_operands(
|
|
32
|
+
argv: list[str], flag_chars: str, valued_flags: set[str]
|
|
33
|
+
) -> tuple[list[str], list[str]]:
|
|
34
|
+
"""Split argv[1:] into (flags-as-single-chars-or-valued, operands).
|
|
35
|
+
|
|
36
|
+
Stops flag parsing at `--` or the first non-flag token. Unknown flags are
|
|
37
|
+
left for the caller to reject (returned inside `flags` unresolved is not
|
|
38
|
+
possible here; callers pass only the flag set they accept and this raises
|
|
39
|
+
nothing itself — callers validate).
|
|
40
|
+
"""
|
|
41
|
+
flags: list[str] = []
|
|
42
|
+
operands: list[str] = []
|
|
43
|
+
i = 0
|
|
44
|
+
args = argv[1:]
|
|
45
|
+
end_of_flags = False
|
|
46
|
+
while i < len(args):
|
|
47
|
+
a = args[i]
|
|
48
|
+
if end_of_flags:
|
|
49
|
+
operands.append(a)
|
|
50
|
+
i += 1
|
|
51
|
+
continue
|
|
52
|
+
if a == "--":
|
|
53
|
+
end_of_flags = True
|
|
54
|
+
i += 1
|
|
55
|
+
continue
|
|
56
|
+
if a.startswith("-") and a != "-" and len(a) > 1:
|
|
57
|
+
flags.append(a)
|
|
58
|
+
i += 1
|
|
59
|
+
continue
|
|
60
|
+
operands.append(a)
|
|
61
|
+
i += 1
|
|
62
|
+
return flags, operands
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _refuse_flag(name: str, flag: str) -> None:
|
|
66
|
+
raise UnsupportedConstruct(
|
|
67
|
+
"unsupported-flag", f"{name}: unsupported flag or form '{flag}'"
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# --- cat ---------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def cat(ctx: "BuiltinContext") -> int:
|
|
75
|
+
flags, operands = _split_flags_and_operands(ctx.argv, "", set())
|
|
76
|
+
for f in flags:
|
|
77
|
+
_refuse_flag("cat", f)
|
|
78
|
+
if not operands:
|
|
79
|
+
ctx.stdout.write(_read_stdin(ctx))
|
|
80
|
+
return 0
|
|
81
|
+
exit_code = 0
|
|
82
|
+
for operand in operands:
|
|
83
|
+
if operand == "-":
|
|
84
|
+
ctx.stdout.write(_read_stdin(ctx))
|
|
85
|
+
continue
|
|
86
|
+
path = _resolve_path(ctx, operand)
|
|
87
|
+
try:
|
|
88
|
+
with open(path, "rb") as fh:
|
|
89
|
+
ctx.stdout.write(fh.read())
|
|
90
|
+
except OSError as exc:
|
|
91
|
+
ctx.stdout.write(f"cat: {operand}: {exc.strerror or exc}\n".encode())
|
|
92
|
+
exit_code = 1
|
|
93
|
+
return exit_code
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# --- head / tail ---------------------------------------------------------------
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _parse_n_flag(name: str, argv: list[str]) -> tuple[int, list[str]]:
|
|
100
|
+
"""Parse `[-n N] [FILE]` only. Any other flag/form -> unsupported-flag."""
|
|
101
|
+
n = 10
|
|
102
|
+
operands: list[str] = []
|
|
103
|
+
args = argv[1:]
|
|
104
|
+
i = 0
|
|
105
|
+
while i < len(args):
|
|
106
|
+
a = args[i]
|
|
107
|
+
if a == "--":
|
|
108
|
+
operands.extend(args[i + 1 :])
|
|
109
|
+
break
|
|
110
|
+
if a == "-n":
|
|
111
|
+
i += 1
|
|
112
|
+
if i >= len(args):
|
|
113
|
+
_refuse_flag(name, "-n")
|
|
114
|
+
n = _parse_int_operand(name, args[i])
|
|
115
|
+
i += 1
|
|
116
|
+
continue
|
|
117
|
+
if a.startswith("-n") and len(a) > 2:
|
|
118
|
+
n = _parse_int_operand(name, a[2:])
|
|
119
|
+
i += 1
|
|
120
|
+
continue
|
|
121
|
+
if a.startswith("-") and a != "-":
|
|
122
|
+
_refuse_flag(name, a)
|
|
123
|
+
operands.append(a)
|
|
124
|
+
i += 1
|
|
125
|
+
if len(operands) > 1:
|
|
126
|
+
_refuse_flag(name, "multi-file")
|
|
127
|
+
return n, operands
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _parse_int_operand(name: str, raw: str) -> int:
|
|
131
|
+
if raw.startswith("+"):
|
|
132
|
+
_refuse_flag(name, f"-n {raw}")
|
|
133
|
+
try:
|
|
134
|
+
return int(raw)
|
|
135
|
+
except ValueError:
|
|
136
|
+
_refuse_flag(name, f"-n {raw}")
|
|
137
|
+
raise AssertionError("unreachable")
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def head(ctx: "BuiltinContext") -> int:
|
|
141
|
+
n, operands = _parse_n_flag("head", ctx.argv)
|
|
142
|
+
data = _read_operand_or_stdin(ctx, operands)
|
|
143
|
+
lines = data.splitlines(keepends=True)
|
|
144
|
+
ctx.stdout.write(b"".join(lines[:n]))
|
|
145
|
+
return 0
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def tail(ctx: "BuiltinContext") -> int:
|
|
149
|
+
n, operands = _parse_n_flag("tail", ctx.argv)
|
|
150
|
+
data = _read_operand_or_stdin(ctx, operands)
|
|
151
|
+
lines = data.splitlines(keepends=True)
|
|
152
|
+
if n <= 0:
|
|
153
|
+
ctx.stdout.write(b"")
|
|
154
|
+
else:
|
|
155
|
+
ctx.stdout.write(b"".join(lines[-n:]))
|
|
156
|
+
return 0
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _read_operand_or_stdin(ctx: "BuiltinContext", operands: list[str]) -> bytes:
|
|
160
|
+
if not operands or operands[0] == "-":
|
|
161
|
+
return _read_stdin(ctx)
|
|
162
|
+
path = _resolve_path(ctx, operands[0])
|
|
163
|
+
with open(path, "rb") as fh:
|
|
164
|
+
return fh.read()
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
# --- wc --------------------------------------------------------------------
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def _wc_counts(data: bytes) -> tuple[int, int, int, int]:
|
|
171
|
+
lines = data.count(b"\n")
|
|
172
|
+
words = len(data.split())
|
|
173
|
+
byte_count = len(data)
|
|
174
|
+
try:
|
|
175
|
+
char_count = len(data.decode("utf-8"))
|
|
176
|
+
except UnicodeDecodeError:
|
|
177
|
+
char_count = byte_count
|
|
178
|
+
return lines, words, byte_count, char_count
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def wc(ctx: "BuiltinContext") -> int:
|
|
182
|
+
known_single = {"-l", "-w", "-c", "-m"}
|
|
183
|
+
flags: list[str] = []
|
|
184
|
+
operands: list[str] = []
|
|
185
|
+
for a in ctx.argv[1:]:
|
|
186
|
+
if a == "--":
|
|
187
|
+
continue
|
|
188
|
+
if a.startswith("-") and a != "-":
|
|
189
|
+
if a not in known_single:
|
|
190
|
+
_refuse_flag("wc", a)
|
|
191
|
+
flags.append(a)
|
|
192
|
+
else:
|
|
193
|
+
operands.append(a)
|
|
194
|
+
|
|
195
|
+
if len(operands) > 1:
|
|
196
|
+
_refuse_flag("wc", "multi-file")
|
|
197
|
+
|
|
198
|
+
single_flag = len(flags) == 1 and not operands
|
|
199
|
+
if single_flag:
|
|
200
|
+
data = _read_stdin(ctx)
|
|
201
|
+
lines, words, byte_count, char_count = _wc_counts(data)
|
|
202
|
+
value = {"-l": lines, "-w": words, "-c": byte_count, "-m": char_count}[flags[0]]
|
|
203
|
+
ctx.stdout.write(f"{value}\n".encode())
|
|
204
|
+
return 0
|
|
205
|
+
|
|
206
|
+
# Bare wc / multi-count / file-arg form: GNU-style column padding (C-marked).
|
|
207
|
+
if operands:
|
|
208
|
+
path = _resolve_path(ctx, operands[0])
|
|
209
|
+
with open(path, "rb") as fh:
|
|
210
|
+
data = fh.read()
|
|
211
|
+
label = operands[0]
|
|
212
|
+
else:
|
|
213
|
+
data = _read_stdin(ctx)
|
|
214
|
+
label = None
|
|
215
|
+
|
|
216
|
+
lines, words, byte_count, char_count = _wc_counts(data)
|
|
217
|
+
if flags:
|
|
218
|
+
selected = []
|
|
219
|
+
for f in flags:
|
|
220
|
+
selected.append({"-l": lines, "-w": words, "-c": byte_count, "-m": char_count}[f])
|
|
221
|
+
else:
|
|
222
|
+
selected = [lines, words, byte_count]
|
|
223
|
+
|
|
224
|
+
width = max((len(str(v)) for v in selected), default=1)
|
|
225
|
+
width = max(width, 7)
|
|
226
|
+
columns = "".join(str(v).rjust(width) for v in selected)
|
|
227
|
+
out = columns + (f" {label}" if label is not None else "")
|
|
228
|
+
ctx.stdout.write(f"{out}\n".encode())
|
|
229
|
+
return 0
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
# --- sort --------------------------------------------------------------------
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def sort(ctx: "BuiltinContext") -> int:
|
|
236
|
+
flags: list[str] = []
|
|
237
|
+
operands: list[str] = []
|
|
238
|
+
for a in ctx.argv[1:]:
|
|
239
|
+
if a == "--":
|
|
240
|
+
continue
|
|
241
|
+
if a.startswith("-") and a != "-":
|
|
242
|
+
if a not in {"-r", "-n", "-u", "-f"}:
|
|
243
|
+
_refuse_flag("sort", a)
|
|
244
|
+
flags.append(a)
|
|
245
|
+
else:
|
|
246
|
+
operands.append(a)
|
|
247
|
+
if len(operands) > 1:
|
|
248
|
+
_refuse_flag("sort", "multi-file")
|
|
249
|
+
|
|
250
|
+
data = _read_operand_or_stdin(ctx, operands)
|
|
251
|
+
text = data.decode("utf-8", errors="surrogateescape")
|
|
252
|
+
had_trailing_newline = text.endswith("\n")
|
|
253
|
+
lines = text.split("\n")
|
|
254
|
+
if had_trailing_newline:
|
|
255
|
+
lines = lines[:-1]
|
|
256
|
+
|
|
257
|
+
reverse = "-r" in flags
|
|
258
|
+
numeric = "-n" in flags
|
|
259
|
+
fold = "-f" in flags
|
|
260
|
+
unique = "-u" in flags
|
|
261
|
+
|
|
262
|
+
def key_numeric(line: str) -> tuple[float, str]:
|
|
263
|
+
m = re.match(r"\s*[-+]?\d+(\.\d+)?", line)
|
|
264
|
+
value = float(m.group(0)) if m else 0.0
|
|
265
|
+
return (value, line)
|
|
266
|
+
|
|
267
|
+
if numeric:
|
|
268
|
+
lines.sort(key=key_numeric, reverse=reverse)
|
|
269
|
+
else:
|
|
270
|
+
key_fn = (lambda line: line.lower()) if fold else (lambda line: line)
|
|
271
|
+
lines.sort(key=key_fn, reverse=reverse)
|
|
272
|
+
|
|
273
|
+
if unique:
|
|
274
|
+
deduped: list[str] = []
|
|
275
|
+
seen: set[str] = set()
|
|
276
|
+
for line in lines:
|
|
277
|
+
k = line.lower() if fold else line
|
|
278
|
+
if k not in seen:
|
|
279
|
+
seen.add(k)
|
|
280
|
+
deduped.append(line)
|
|
281
|
+
lines = deduped
|
|
282
|
+
|
|
283
|
+
out = "\n".join(lines)
|
|
284
|
+
if lines:
|
|
285
|
+
out += "\n"
|
|
286
|
+
ctx.stdout.write(out.encode("utf-8", errors="surrogateescape"))
|
|
287
|
+
return 0
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
# --- uniq --------------------------------------------------------------------
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def uniq(ctx: "BuiltinContext") -> int:
|
|
294
|
+
flags: list[str] = []
|
|
295
|
+
operands: list[str] = []
|
|
296
|
+
for a in ctx.argv[1:]:
|
|
297
|
+
if a == "--":
|
|
298
|
+
continue
|
|
299
|
+
if a.startswith("-") and a != "-":
|
|
300
|
+
if a not in {"-c", "-d", "-u", "-i"}:
|
|
301
|
+
_refuse_flag("uniq", a)
|
|
302
|
+
flags.append(a)
|
|
303
|
+
else:
|
|
304
|
+
operands.append(a)
|
|
305
|
+
if len(operands) > 1:
|
|
306
|
+
_refuse_flag("uniq", "multi-file")
|
|
307
|
+
|
|
308
|
+
data = _read_operand_or_stdin(ctx, operands)
|
|
309
|
+
text = data.decode("utf-8", errors="surrogateescape")
|
|
310
|
+
had_trailing_newline = text.endswith("\n")
|
|
311
|
+
lines = text.split("\n")
|
|
312
|
+
if had_trailing_newline:
|
|
313
|
+
lines = lines[:-1]
|
|
314
|
+
|
|
315
|
+
ignore_case = "-i" in flags
|
|
316
|
+
count_flag = "-c" in flags
|
|
317
|
+
dup_only = "-d" in flags
|
|
318
|
+
uniq_only = "-u" in flags
|
|
319
|
+
|
|
320
|
+
groups: list[tuple[str, int]] = []
|
|
321
|
+
for line in lines:
|
|
322
|
+
cmp_line = line.lower() if ignore_case else line
|
|
323
|
+
if groups:
|
|
324
|
+
prev_line, prev_count = groups[-1]
|
|
325
|
+
prev_cmp = prev_line.lower() if ignore_case else prev_line
|
|
326
|
+
if cmp_line == prev_cmp:
|
|
327
|
+
groups[-1] = (prev_line, prev_count + 1)
|
|
328
|
+
continue
|
|
329
|
+
groups.append((line, 1))
|
|
330
|
+
|
|
331
|
+
if dup_only:
|
|
332
|
+
groups = [g for g in groups if g[1] > 1]
|
|
333
|
+
elif uniq_only:
|
|
334
|
+
groups = [g for g in groups if g[1] == 1]
|
|
335
|
+
|
|
336
|
+
if count_flag:
|
|
337
|
+
width = max((len(str(c)) for _, c in groups), default=1)
|
|
338
|
+
width = max(width, 7)
|
|
339
|
+
out_lines = [f"{str(c).rjust(width)} {line}" for line, c in groups]
|
|
340
|
+
else:
|
|
341
|
+
out_lines = [line for line, _ in groups]
|
|
342
|
+
|
|
343
|
+
out = "\n".join(out_lines)
|
|
344
|
+
if out_lines:
|
|
345
|
+
out += "\n"
|
|
346
|
+
ctx.stdout.write(out.encode("utf-8", errors="surrogateescape"))
|
|
347
|
+
return 0
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
# --- cut ---------------------------------------------------------------------
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
def _parse_list_spec(name: str, spec: str) -> list[tuple[int, int | None]]:
|
|
354
|
+
"""Parse a cut LIST: comma-separated N | N-M | N- | -M (1-based)."""
|
|
355
|
+
ranges: list[tuple[int, int | None]] = []
|
|
356
|
+
for part in spec.split(","):
|
|
357
|
+
part = part.strip()
|
|
358
|
+
if not part:
|
|
359
|
+
continue
|
|
360
|
+
if part.startswith("-"):
|
|
361
|
+
ranges.append((1, int(part[1:])))
|
|
362
|
+
elif part.endswith("-"):
|
|
363
|
+
ranges.append((int(part[:-1]), None))
|
|
364
|
+
elif "-" in part:
|
|
365
|
+
a, b = part.split("-", 1)
|
|
366
|
+
ranges.append((int(a), int(b)))
|
|
367
|
+
else:
|
|
368
|
+
n = int(part)
|
|
369
|
+
ranges.append((n, n))
|
|
370
|
+
return ranges
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
def _in_ranges(index: int, ranges: list[tuple[int, int | None]]) -> bool:
|
|
374
|
+
for lo, hi in ranges:
|
|
375
|
+
if hi is None:
|
|
376
|
+
if index >= lo:
|
|
377
|
+
return True
|
|
378
|
+
elif lo <= index <= hi:
|
|
379
|
+
return True
|
|
380
|
+
return False
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
def cut(ctx: "BuiltinContext") -> int:
|
|
384
|
+
delim = "\t"
|
|
385
|
+
field_spec: str | None = None
|
|
386
|
+
char_spec: str | None = None
|
|
387
|
+
operands: list[str] = []
|
|
388
|
+
args = ctx.argv[1:]
|
|
389
|
+
i = 0
|
|
390
|
+
while i < len(args):
|
|
391
|
+
a = args[i]
|
|
392
|
+
if a == "-d":
|
|
393
|
+
i += 1
|
|
394
|
+
if i >= len(args):
|
|
395
|
+
_refuse_flag("cut", "-d")
|
|
396
|
+
delim = args[i]
|
|
397
|
+
i += 1
|
|
398
|
+
continue
|
|
399
|
+
if a.startswith("-d") and len(a) > 2:
|
|
400
|
+
delim = a[2:]
|
|
401
|
+
i += 1
|
|
402
|
+
continue
|
|
403
|
+
if a == "-f":
|
|
404
|
+
i += 1
|
|
405
|
+
if i >= len(args):
|
|
406
|
+
_refuse_flag("cut", "-f")
|
|
407
|
+
field_spec = args[i]
|
|
408
|
+
i += 1
|
|
409
|
+
continue
|
|
410
|
+
if a.startswith("-f") and len(a) > 2:
|
|
411
|
+
field_spec = a[2:]
|
|
412
|
+
i += 1
|
|
413
|
+
continue
|
|
414
|
+
if a == "-c":
|
|
415
|
+
i += 1
|
|
416
|
+
if i >= len(args):
|
|
417
|
+
_refuse_flag("cut", "-c")
|
|
418
|
+
char_spec = args[i]
|
|
419
|
+
i += 1
|
|
420
|
+
continue
|
|
421
|
+
if a.startswith("-c") and len(a) > 2:
|
|
422
|
+
char_spec = a[2:]
|
|
423
|
+
i += 1
|
|
424
|
+
continue
|
|
425
|
+
if a == "--":
|
|
426
|
+
operands.extend(args[i + 1 :])
|
|
427
|
+
break
|
|
428
|
+
if a.startswith("-") and a != "-":
|
|
429
|
+
_refuse_flag("cut", a)
|
|
430
|
+
operands.append(a)
|
|
431
|
+
i += 1
|
|
432
|
+
|
|
433
|
+
if (field_spec is None) == (char_spec is None):
|
|
434
|
+
_refuse_flag("cut", "-f/-c required (exactly one)")
|
|
435
|
+
|
|
436
|
+
if len(operands) > 1:
|
|
437
|
+
_refuse_flag("cut", "multi-file")
|
|
438
|
+
|
|
439
|
+
data = _read_operand_or_stdin(ctx, operands)
|
|
440
|
+
text = data.decode("utf-8", errors="surrogateescape")
|
|
441
|
+
had_trailing_newline = text.endswith("\n")
|
|
442
|
+
lines = text.split("\n")
|
|
443
|
+
if had_trailing_newline:
|
|
444
|
+
lines = lines[:-1]
|
|
445
|
+
|
|
446
|
+
out_lines: list[str] = []
|
|
447
|
+
if field_spec is not None:
|
|
448
|
+
ranges = _parse_list_spec("cut", field_spec)
|
|
449
|
+
for line in lines:
|
|
450
|
+
parts = line.split(delim)
|
|
451
|
+
selected = [p for idx, p in enumerate(parts, start=1) if _in_ranges(idx, ranges)]
|
|
452
|
+
out_lines.append(delim.join(selected))
|
|
453
|
+
else:
|
|
454
|
+
ranges = _parse_list_spec("cut", char_spec) # type: ignore[arg-type]
|
|
455
|
+
for line in lines:
|
|
456
|
+
selected_chars = [c for idx, c in enumerate(line, start=1) if _in_ranges(idx, ranges)]
|
|
457
|
+
out_lines.append("".join(selected_chars))
|
|
458
|
+
|
|
459
|
+
out = "\n".join(out_lines)
|
|
460
|
+
if out_lines:
|
|
461
|
+
out += "\n"
|
|
462
|
+
ctx.stdout.write(out.encode("utf-8", errors="surrogateescape"))
|
|
463
|
+
return 0
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
# --- tr --------------------------------------------------------------------
|
|
467
|
+
|
|
468
|
+
_TR_CLASSES = {
|
|
469
|
+
"upper": "".join(chr(c) for c in range(256) if chr(c).isupper()),
|
|
470
|
+
"lower": "".join(chr(c) for c in range(256) if chr(c).islower()),
|
|
471
|
+
"digit": "0123456789",
|
|
472
|
+
"alpha": "".join(chr(c) for c in range(256) if chr(c).isalpha()),
|
|
473
|
+
"space": " \t\n\r\v\f",
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
def _expand_tr_set(spec: str) -> str:
|
|
478
|
+
result: list[str] = []
|
|
479
|
+
i = 0
|
|
480
|
+
while i < len(spec):
|
|
481
|
+
c = spec[i]
|
|
482
|
+
if c == "[" and spec[i : i + 2] == "[:":
|
|
483
|
+
end = spec.find(":]", i + 2)
|
|
484
|
+
if end != -1:
|
|
485
|
+
cls = spec[i + 2 : end]
|
|
486
|
+
if cls in _TR_CLASSES:
|
|
487
|
+
result.append(_TR_CLASSES[cls])
|
|
488
|
+
i = end + 2
|
|
489
|
+
continue
|
|
490
|
+
if i + 2 < len(spec) and spec[i + 1] == "-" and spec[i + 2] != "":
|
|
491
|
+
start_c, end_c = spec[i], spec[i + 2]
|
|
492
|
+
if ord(start_c) <= ord(end_c):
|
|
493
|
+
result.append("".join(chr(x) for x in range(ord(start_c), ord(end_c) + 1)))
|
|
494
|
+
i += 3
|
|
495
|
+
continue
|
|
496
|
+
result.append(c)
|
|
497
|
+
i += 1
|
|
498
|
+
return "".join(result)
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
def tr(ctx: "BuiltinContext") -> int:
|
|
502
|
+
flags: list[str] = []
|
|
503
|
+
operands: list[str] = []
|
|
504
|
+
for a in ctx.argv[1:]:
|
|
505
|
+
if a == "--":
|
|
506
|
+
continue
|
|
507
|
+
if a.startswith("-") and a != "-":
|
|
508
|
+
if a not in {"-d", "-s", "-c"}:
|
|
509
|
+
_refuse_flag("tr", a)
|
|
510
|
+
flags.append(a)
|
|
511
|
+
else:
|
|
512
|
+
operands.append(a)
|
|
513
|
+
|
|
514
|
+
delete = "-d" in flags
|
|
515
|
+
squeeze = "-s" in flags
|
|
516
|
+
complement = "-c" in flags
|
|
517
|
+
|
|
518
|
+
if not operands:
|
|
519
|
+
_refuse_flag("tr", "missing SET1")
|
|
520
|
+
set1_raw = operands[0]
|
|
521
|
+
set2_raw = operands[1] if len(operands) > 1 else None
|
|
522
|
+
|
|
523
|
+
if len(operands) > 2:
|
|
524
|
+
_refuse_flag("tr", "too many operands")
|
|
525
|
+
if delete and set2_raw is not None and not squeeze:
|
|
526
|
+
_refuse_flag("tr", "tr -d takes only SET1 (unless combined with -s)")
|
|
527
|
+
if not delete and not squeeze and set2_raw is None:
|
|
528
|
+
_refuse_flag("tr", "SET2 required unless -d or -s")
|
|
529
|
+
|
|
530
|
+
set1 = _expand_tr_set(set1_raw)
|
|
531
|
+
set2 = _expand_tr_set(set2_raw) if set2_raw is not None else ""
|
|
532
|
+
|
|
533
|
+
if complement:
|
|
534
|
+
all_chars = "".join(chr(c) for c in range(256))
|
|
535
|
+
set1 = "".join(c for c in all_chars if c not in set1)
|
|
536
|
+
|
|
537
|
+
data = _read_stdin(ctx)
|
|
538
|
+
text = data.decode("utf-8", errors="surrogateescape")
|
|
539
|
+
|
|
540
|
+
if delete:
|
|
541
|
+
deleted = "".join(c for c in text if c not in set1)
|
|
542
|
+
if squeeze and set2_raw is not None:
|
|
543
|
+
result_chars: list[str] = []
|
|
544
|
+
prev: str | None = None
|
|
545
|
+
for c in deleted:
|
|
546
|
+
if c in set2 and c == prev:
|
|
547
|
+
continue
|
|
548
|
+
result_chars.append(c)
|
|
549
|
+
prev = c if c in set2 else None
|
|
550
|
+
out_text = "".join(result_chars)
|
|
551
|
+
else:
|
|
552
|
+
out_text = deleted
|
|
553
|
+
else:
|
|
554
|
+
if set2:
|
|
555
|
+
pad_char = set2[-1]
|
|
556
|
+
padded_set2 = set2 + pad_char * max(0, len(set1) - len(set2))
|
|
557
|
+
table = str.maketrans(set1, padded_set2[: len(set1)])
|
|
558
|
+
else:
|
|
559
|
+
table = str.maketrans("", "")
|
|
560
|
+
translated = text.translate(table)
|
|
561
|
+
if squeeze:
|
|
562
|
+
result_chars2: list[str] = []
|
|
563
|
+
prev2: str | None = None
|
|
564
|
+
squeeze_set = set2 if set2 else set1
|
|
565
|
+
for c in translated:
|
|
566
|
+
if c in squeeze_set and c == prev2:
|
|
567
|
+
continue
|
|
568
|
+
result_chars2.append(c)
|
|
569
|
+
prev2 = c if c in squeeze_set else None
|
|
570
|
+
out_text = "".join(result_chars2)
|
|
571
|
+
else:
|
|
572
|
+
out_text = translated
|
|
573
|
+
|
|
574
|
+
ctx.stdout.write(out_text.encode("utf-8", errors="surrogateescape"))
|
|
575
|
+
return 0
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Frozen ExecContext/BuiltinContext/type-alias module.
|
|
2
|
+
|
|
3
|
+
Carries only string annotations (`from __future__ import annotations`), so it imports
|
|
4
|
+
nothing at runtime and lets WP-B/C/D code against one shared type surface without
|
|
5
|
+
same-wave import coupling. Transcribed verbatim from
|
|
6
|
+
windows-shell-workpackages-2026-07-19.md §1.5.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from typing import TYPE_CHECKING, BinaryIO, Callable, Mapping
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from nodes import Word
|
|
16
|
+
from state import ShellState
|
|
17
|
+
|
|
18
|
+
BuiltinFn = Callable[["BuiltinContext"], int]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass
|
|
22
|
+
class BuiltinContext:
|
|
23
|
+
"""What a PURE builtin (WP-D) may touch."""
|
|
24
|
+
|
|
25
|
+
argv: list[str]
|
|
26
|
+
cwd: str
|
|
27
|
+
env: Mapping[str, str]
|
|
28
|
+
stdin: BinaryIO
|
|
29
|
+
stdout: BinaryIO
|
|
30
|
+
# Builtins historically receive only stdin/stdout; stderr is optional so existing direct
|
|
31
|
+
# callers retain the merged-stream behavior while exec.py can pass a redirected sink.
|
|
32
|
+
stderr: BinaryIO | None = None
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass
|
|
36
|
+
class ExecContext:
|
|
37
|
+
"""What exec (WP-C) threads through the run."""
|
|
38
|
+
|
|
39
|
+
state: "ShellState"
|
|
40
|
+
stdin: BinaryIO
|
|
41
|
+
stdout: BinaryIO
|
|
42
|
+
expand_word: Callable[["Word", "ExecContext"], list[str]]
|
|
43
|
+
run_command_substitution: Callable[[str, "ExecContext"], tuple[str, int]]
|
|
44
|
+
builtins: Mapping[str, BuiltinFn]
|
|
45
|
+
deadline: float | None
|
|
46
|
+
stderr: BinaryIO | int | None = None
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# Frozen inline sets: state mutators and the runner builtin are NOT in commands/REGISTRY;
|
|
50
|
+
# exec.py handles them inline because they need ShellState / the executor.
|
|
51
|
+
STATE_BUILTINS = {"cd", "export", "unset"}
|
|
52
|
+
RUNNER_BUILTINS = {"xargs"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Structured refusal exception + the frozen refusal-code catalog for the pi shell engine.
|
|
2
|
+
|
|
3
|
+
Any construct outside the frozen grammar (see nodes.py / parser.py) raises
|
|
4
|
+
`UnsupportedConstruct` with a stable `construct` id from the catalog below. The engine
|
|
5
|
+
never returns a partial or guessed AST/result for an unsupported construct.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
# Frozen construct-id catalog (do not rename/remove existing ids; "tilde-user" added per
|
|
11
|
+
# architect addendum for ~user forms raised by the expander; "malformed-syntax" and
|
|
12
|
+
# "parameter-expansion" added per architect amendment after WP-A review — see
|
|
13
|
+
# windows-shell-workpackages-2026-07-19.md §1.6: "malformed-syntax" covers any
|
|
14
|
+
# syntactically-broken input (unbalanced quote/paren/brace, stray/trailing tokens, missing
|
|
15
|
+
# redirect target, empty pipeline element) so a raw Python exception never escapes;
|
|
16
|
+
# "parameter-expansion" covers a `${...}` form outside the supported op set (`:-`, `:=`,
|
|
17
|
+
# `:+`, `:?`, `#len`), distinct from "unsupported-flag" which stays builtin-flag-specific.
|
|
18
|
+
UNSUPPORTED_CONSTRUCTS = frozenset(
|
|
19
|
+
{
|
|
20
|
+
"job-control",
|
|
21
|
+
"process-substitution",
|
|
22
|
+
"arithmetic-expansion",
|
|
23
|
+
"brace-expansion",
|
|
24
|
+
"nested-shell",
|
|
25
|
+
"exec-builtin",
|
|
26
|
+
"heredoc",
|
|
27
|
+
"here-string",
|
|
28
|
+
"function-definition",
|
|
29
|
+
"control-flow",
|
|
30
|
+
"extended-glob",
|
|
31
|
+
"unsupported-builtin",
|
|
32
|
+
"unsupported-flag",
|
|
33
|
+
"posix-script",
|
|
34
|
+
"cwd-missing",
|
|
35
|
+
"tilde-user",
|
|
36
|
+
"malformed-syntax",
|
|
37
|
+
"parameter-expansion",
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class UnsupportedConstruct(Exception):
|
|
43
|
+
"""Raised for any construct outside the frozen grammar/behavior contract."""
|
|
44
|
+
|
|
45
|
+
def __init__(self, construct: str, message: str) -> None:
|
|
46
|
+
super().__init__(message)
|
|
47
|
+
self.code = "unsupported"
|
|
48
|
+
self.construct = construct
|
|
49
|
+
self.message = message
|