docks-kit 0.1.0 → 0.1.2

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.
Files changed (39) hide show
  1. package/AGENTS.md +14 -15
  2. package/README.md +12 -11
  3. package/SoT/.agents/skills.txt +3 -3
  4. package/SoT/.claude/settings.json +3 -26
  5. package/SoT/models.json +1 -1
  6. package/SoT/toolchain.json +3 -3
  7. package/cli/docs/install.md +39 -12
  8. package/cli/docs/overview.md +3 -4
  9. package/cli/docs/platforms.md +35 -22
  10. package/cli/src/commands/sync.ts +32 -4
  11. package/cli/src/commands/update.ts +116 -0
  12. package/cli/src/engine-native/DESIGN.md +89 -0
  13. package/cli/src/engine-native/claudeModel.ts +48 -0
  14. package/cli/src/engine-native/claudeSync.ts +771 -0
  15. package/cli/src/engine-native/codexSync.ts +439 -0
  16. package/cli/src/engine-native/codexToml.ts +67 -0
  17. package/cli/src/engine-native/exec.ts +54 -0
  18. package/cli/src/engine-native/index.ts +109 -0
  19. package/cli/src/engine-native/jq.ts +63 -0
  20. package/cli/src/engine-native/models.ts +73 -0
  21. package/cli/src/engine-native/modes.ts +133 -0
  22. package/cli/src/engine-native/output.ts +20 -0
  23. package/cli/src/engine-native/parseArgs.ts +223 -0
  24. package/cli/src/engine-native/settings.ts +41 -0
  25. package/cli/src/engine-native/skillsSync.ts +369 -0
  26. package/cli/src/engine-native/toolchain.ts +257 -0
  27. package/cli/src/engine.ts +35 -18
  28. package/cli/src/kitHome.ts +4 -4
  29. package/cli/src/main.ts +14 -1
  30. package/cli/src/manifests.ts +3 -2
  31. package/cli/tsconfig.json +1 -1
  32. package/docks-kit +6 -3
  33. package/package.json +8 -4
  34. package/lib/claude.sh +0 -846
  35. package/lib/codex.sh +0 -518
  36. package/lib/common.sh +0 -229
  37. package/lib/engine.sh +0 -153
  38. package/lib/skills.sh +0 -373
  39. package/lib/toolchain.sh +0 -222
package/lib/common.sh DELETED
@@ -1,229 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
-
4
- DRY_RUN=${DRY_RUN:-0}
5
- SKIP_RTK=${SKIP_RTK:-0}
6
- RECONCILE=${RECONCILE:-0}
7
- PRUNE=${PRUNE:-0}
8
- ASSUME_YES=${ASSUME_YES:-0}
9
- CLAUDE_COMPACT_WINDOW=${CLAUDE_COMPACT_WINDOW:-}
10
- CLAUDE_PERMISSIVE=${CLAUDE_PERMISSIVE:-0}
11
- CLAUDE_PLUGINS=${CLAUDE_PLUGINS:-}
12
- CLAUDE_MODEL=${CLAUDE_MODEL:-}
13
- CODEX_MODEL=${CODEX_MODEL:-}
14
- TARGET_FILTER_SET=${TARGET_FILTER_SET:-0}
15
- SYNC_CLAUDE=${SYNC_CLAUDE:-0}
16
- SYNC_CODEX=${SYNC_CODEX:-0}
17
- SYNC_AGENTS=${SYNC_AGENTS:-0}
18
- AGENTS_DIR="${AGENTS_DIR:-$HOME/.agents}"
19
-
20
- # Opt-in plugins installable via --claude-plugin=<name> (space-separated).
21
- KNOWN_CLAUDE_OPTIN_PLUGINS="supabase n8n"
22
-
23
- log() { printf "\033[1;32m[ok]\033[0m %s\n" "$1" >&2; }
24
- warn() { printf "\033[1;33m[warn]\033[0m %s\n" "$1" >&2; }
25
- err() { printf "\033[1;31m[err]\033[0m %s\n" "$1" >&2; }
26
-
27
- common::usage() {
28
- echo "Usage: $0 [claude] [codex] [agents] [flags]"
29
- echo ""
30
- echo "Targets (positional; default: all three)"
31
- echo " claude sync the Claude Code SoT"
32
- echo " codex sync the Codex SoT"
33
- echo " agents sync universal agent skills"
34
- echo ""
35
- echo "Global flags"
36
- echo " --dry-run preview without applying"
37
- echo " --reconcile reconcile kit-owned settings with SoT (SoT keys win; user-only keys preserved; permissions arrays replaced)"
38
- echo " --prune uninstall kit-managed installs not in SoT (plugins, marketplaces, skills in SoT/.agents/skills.txt)"
39
- echo " --skip-rtk skip optional tool bootstrap (RTK, bubblewrap)"
40
- echo " --yes auto-accept toolchain prompts (containers/CI)"
41
- echo ""
42
- echo "Deploy-time modifiers (deployed config only; SoT untouched; a later flag-less sync reverts)"
43
- echo " --claude-model=<m> set deployed ~/.claude/settings.json model (aliases: best|opus|fable|sonnet|haiku, full claude-* IDs, or 'default' to unset)"
44
- echo " --claude-compact-window=<n> set deployed autocompact window in tokens (e.g. 680000 or 680k) for disposable sessions"
45
- echo " --claude-permissive empty permissions.ask/deny in deployed settings (sandboxes/containers; unattended commits + pushes)"
46
- echo " --codex-model=<m> set deployed ~/.codex/config.toml model (e.g. gpt-5.5)"
47
- echo ""
48
- echo "Sticky opt-ins (installed + enabled until --prune)"
49
- echo " --claude-plugin=<name> opt an optional plugin into this machine (known: ${KNOWN_CLAUDE_OPTIN_PLUGINS// /, }; repeatable)"
50
- }
51
-
52
- common::select_target() {
53
- case "$1" in
54
- claude) SYNC_CLAUDE=1 ;;
55
- codex) SYNC_CODEX=1 ;;
56
- agents) SYNC_AGENTS=1 ;;
57
- *) err "Unknown sync target: $1"; exit 2 ;;
58
- esac
59
- TARGET_FILTER_SET=1
60
- }
61
-
62
- # Normalize a --claude-compact-window value to plain tokens: digits, or
63
- # digits + k/K (x1000). Echoes the normalized number; returns 1 on junk.
64
- common::parse_compact_window() {
65
- local v="$1"
66
- case "$v" in
67
- *[kK]) v="${v%[kK]}"; [[ "$v" =~ ^[0-9]+$ ]] || return 1; v=$((v * 1000)) ;;
68
- *) [[ "$v" =~ ^[0-9]+$ ]] || return 1 ;;
69
- esac
70
- printf '%s' "$v"
71
- }
72
-
73
- common::add_claude_plugin() {
74
- local name="$1"
75
- case " $KNOWN_CLAUDE_OPTIN_PLUGINS " in
76
- *" $name "*) CLAUDE_PLUGINS="$CLAUDE_PLUGINS $name" ;;
77
- *) err "Unknown opt-in plugin '$name'. Known: ${KNOWN_CLAUDE_OPTIN_PLUGINS// /, }"; exit 2 ;;
78
- esac
79
- }
80
-
81
- common::claude_plugin_wanted() {
82
- case " $CLAUDE_PLUGINS " in
83
- *" $1 "*) return 0 ;;
84
- *) return 1 ;;
85
- esac
86
- }
87
-
88
- # Emit the kit-verified model IDs for a tool, one per line, from SoT/models.json.
89
- # Silent no-op when the manifest or jq is unavailable (validators then fall back
90
- # to their pattern checks).
91
- common::_models_from_manifest() {
92
- local tool="$1" manifest="$REPO_DIR/SoT/models.json"
93
- [[ -f "$manifest" ]] && command -v jq >/dev/null 2>&1 || return 0
94
- jq -r --arg t "$tool" '.[$t].models[]?.id // empty' "$manifest" 2>/dev/null
95
- }
96
-
97
- # Human-readable catalog listing (stderr) — used by the bare-flag helper and
98
- # validation failures so the user sees valid values without leaving the terminal.
99
- common::print_models() {
100
- local tool="$1" manifest="$REPO_DIR/SoT/models.json" verified
101
- if [[ ! -f "$manifest" ]] || ! command -v jq >/dev/null 2>&1; then
102
- warn "Model catalog unavailable ($manifest)"
103
- return 0
104
- fi
105
- verified=$(jq -r --arg t "$tool" '.[$t].verified // "?"' "$manifest")
106
- {
107
- echo "Available $tool models (kit-verified $verified — SoT/models.json):"
108
- jq -r --arg t "$tool" '.[$t].models[]? | " \(.id)\(if .note then " — \(.note)" else "" end)"' "$manifest"
109
- case "$tool" in
110
- claude) echo " (full claude-* model IDs outside the catalog are accepted with a warning)" ;;
111
- codex) echo " (well-formed IDs outside the catalog are accepted with a warning)" ;;
112
- esac
113
- } >&2
114
- }
115
-
116
- # Catalog match, or any full claude-* ID (warned — new models outrun the catalog).
117
- common::_validate_claude_model() {
118
- local m="$1"
119
- [[ -n "$m" ]] || return 1
120
- if common::_models_from_manifest claude | grep -qx -- "$m"; then
121
- return 0
122
- fi
123
- case "$m" in
124
- claude-*)
125
- warn "Claude model '$m' is not in the kit-verified catalog (SoT/models.json) — applying anyway"
126
- return 0 ;;
127
- *) return 1 ;;
128
- esac
129
- }
130
-
131
- # Charset check is the hard gate (also blocks TOML-quote injection — the value
132
- # is interpolated into a quoted config.toml string); catalog miss only warns.
133
- common::_validate_codex_model() {
134
- local m="$1"
135
- [[ "$m" =~ ^[A-Za-z0-9._-]+$ ]] || return 1
136
- if ! common::_models_from_manifest codex | grep -qx -- "$m"; then
137
- warn "Codex model '$m' is not in the kit-verified catalog (SoT/models.json) — applying anyway (check ~/.codex/config.toml if Codex rejects it)"
138
- fi
139
- return 0
140
- }
141
-
142
- # Fail-fast gate: runs after parse+preflight, BEFORE any sync step mutates
143
- # state, so a bad model value can never abort a half-finished sync.
144
- common::validate_model_flags() {
145
- if [[ -n "$CLAUDE_MODEL" ]]; then
146
- if [[ "$SYNC_CLAUDE" -eq 0 ]]; then
147
- warn "--claude-model ignored: claude target not selected"
148
- CLAUDE_MODEL=""
149
- elif ! common::_validate_claude_model "$CLAUDE_MODEL"; then
150
- common::print_models claude
151
- err "Invalid Claude model '$CLAUDE_MODEL' — use an alias above or a full claude-* ID"
152
- exit 2
153
- fi
154
- fi
155
- if [[ -n "$CODEX_MODEL" ]]; then
156
- if [[ "$SYNC_CODEX" -eq 0 ]]; then
157
- warn "--codex-model ignored: codex target not selected"
158
- CODEX_MODEL=""
159
- elif ! common::_validate_codex_model "$CODEX_MODEL"; then
160
- common::print_models codex
161
- err "Invalid Codex model '$CODEX_MODEL' — must match ^[A-Za-z0-9._-]+\$"
162
- exit 2
163
- fi
164
- fi
165
- }
166
-
167
- common::parse_args() {
168
- local arg
169
- for arg in "$@"; do
170
- case "$arg" in
171
- claude|codex|agents) common::select_target "$arg" ;;
172
- --dry-run) DRY_RUN=1 ;;
173
- --skip-rtk) SKIP_RTK=1 ;;
174
- --reconcile) RECONCILE=1 ;;
175
- --prune) PRUNE=1 ;;
176
- --yes) ASSUME_YES=1 ;;
177
- --claude-model=*) CLAUDE_MODEL="${arg#*=}" ;;
178
- --codex-model=*) CODEX_MODEL="${arg#*=}" ;;
179
- --claude-model)
180
- common::print_models claude
181
- err "--claude-model requires a value: --claude-model=<model>"
182
- exit 2 ;;
183
- --codex-model)
184
- common::print_models codex
185
- err "--codex-model requires a value: --codex-model=<model>"
186
- exit 2 ;;
187
- --claude-compact-window=*)
188
- CLAUDE_COMPACT_WINDOW="$(common::parse_compact_window "${arg#*=}")" \
189
- || { err "--claude-compact-window expects a token count (e.g. 680000 or 680k)"; exit 2; } ;;
190
- --claude-compact-window)
191
- err "--claude-compact-window requires a value: --claude-compact-window=<tokens> (e.g. 680k)"
192
- exit 2 ;;
193
- --claude-permissive) CLAUDE_PERMISSIVE=1 ;;
194
- --claude-plugin=*) common::add_claude_plugin "${arg#*=}" ;;
195
- --claude-plugin)
196
- err "--claude-plugin requires a value: --claude-plugin=<${KNOWN_CLAUDE_OPTIN_PLUGINS// /|}>"
197
- exit 2 ;;
198
- # Renamed legacy flags: hint and refuse (clean break, no compat behavior).
199
- --claude|--codex|--agents)
200
- err "${arg} was renamed: pass the target as a word, e.g. 'sync ${arg#--}'"; exit 2 ;;
201
- --force) err "--force was renamed to --reconcile"; exit 2 ;;
202
- --remove-plugins) err "--remove-plugins was renamed to --prune (it also removes marketplaces + kit-managed skills)"; exit 2 ;;
203
- --680k) err "--680k was renamed to --claude-compact-window=680k"; exit 2 ;;
204
- --permissive) err "--permissive was renamed to --claude-permissive"; exit 2 ;;
205
- --supabase) err "--supabase was renamed to --claude-plugin=supabase"; exit 2 ;;
206
- --n8n) err "--n8n was renamed to --claude-plugin=n8n"; exit 2 ;;
207
- --no-rtk) err "--no-rtk was renamed to --skip-rtk"; exit 2 ;;
208
- -h|--help)
209
- common::usage
210
- exit 0 ;;
211
- *) err "Unknown arg: $arg"; exit 2 ;;
212
- esac
213
- done
214
-
215
- if [[ "$TARGET_FILTER_SET" -eq 0 ]]; then
216
- SYNC_CLAUDE=1
217
- SYNC_CODEX=1
218
- SYNC_AGENTS=1
219
- fi
220
- }
221
-
222
- common::preflight() {
223
- if [[ "$SYNC_CLAUDE" -eq 1 || "$SYNC_CODEX" -eq 1 ]]; then
224
- command -v jq >/dev/null 2>&1 || { err "jq is required. Install: sudo apt install -y jq (or brew install jq)"; exit 1; }
225
- fi
226
- if [[ "$SYNC_CLAUDE" -eq 1 ]]; then
227
- command -v curl >/dev/null 2>&1 || { err "curl is required."; exit 1; }
228
- fi
229
- }
package/lib/engine.sh DELETED
@@ -1,153 +0,0 @@
1
- #!/bin/bash
2
- # engine.sh — the docks-kit bash engine (zero-dependency escape hatch).
3
- # Canonical UX is the ./docks-kit CLI; this is the same engine it drives:
4
- # bash lib/engine.sh sync [claude] [codex] [agents] [flags] # full sync
5
- # bash lib/engine.sh model <claude|codex> [value] [--dry-run] # get/set deployed model
6
- # bash lib/engine.sh toolchain check # doctor table
7
- # bash lib/engine.sh toolchain ensure <tool> [--yes] # install/upgrade one tool
8
- set -euo pipefail
9
-
10
- REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
11
-
12
- # shellcheck source=lib/common.sh
13
- source "$REPO_DIR/lib/common.sh"
14
- # shellcheck source=lib/toolchain.sh
15
- source "$REPO_DIR/lib/toolchain.sh"
16
-
17
- engine::sync() {
18
- common::parse_args "$@"
19
- common::preflight
20
- common::validate_model_flags
21
-
22
- if [[ "$SYNC_CLAUDE" -eq 1 && -d "$REPO_DIR/SoT/.claude" ]]; then
23
- # shellcheck source=lib/claude.sh
24
- source "$REPO_DIR/lib/claude.sh"
25
- claude::sync
26
- fi
27
-
28
- if [[ "$SYNC_CODEX" -eq 1 && -d "$REPO_DIR/SoT/.codex" ]]; then
29
- # shellcheck source=lib/codex.sh
30
- source "$REPO_DIR/lib/codex.sh"
31
- codex::sync
32
- fi
33
-
34
- if [[ "$SYNC_AGENTS" -eq 1 && -d "$REPO_DIR/SoT/.agents" ]]; then
35
- # shellcheck source=lib/skills.sh
36
- source "$REPO_DIR/lib/skills.sh"
37
- skills::sync
38
- fi
39
-
40
- echo ""
41
- echo "--- Sync complete ---"
42
- echo "Repo: $REPO_DIR"
43
- if declare -F claude::summary >/dev/null 2>&1; then
44
- claude::summary
45
- fi
46
- if declare -F codex::summary >/dev/null 2>&1; then
47
- codex::summary
48
- fi
49
- if declare -F skills::summary >/dev/null 2>&1; then
50
- skills::summary
51
- fi
52
-
53
- echo ""
54
- if declare -F claude::next_steps >/dev/null 2>&1; then
55
- claude::next_steps
56
- fi
57
- if declare -F codex::next_steps >/dev/null 2>&1; then
58
- codex::next_steps
59
- fi
60
- if declare -F skills::next_steps >/dev/null 2>&1; then
61
- skills::next_steps
62
- fi
63
- }
64
-
65
- # Direct mode: get/set the DEPLOYED model for one tool without a full sync.
66
- # Set path reuses the deploy-time modifier functions (claude::sync_model /
67
- # codex::sync_model) so `docks-kit model claude opus` and
68
- # `docks-kit sync claude --claude-model=opus` share one implementation.
69
- engine::model() {
70
- local tool="" value="" arg
71
- for arg in "$@"; do
72
- case "$arg" in
73
- --dry-run) DRY_RUN=1 ;;
74
- claude|codex) tool="$arg" ;;
75
- -*) err "Unknown flag for model: $arg"; exit 2 ;;
76
- *) value="$arg" ;;
77
- esac
78
- done
79
- [[ -n "$tool" ]] || { err "Usage: model <claude|codex> [value] [--dry-run]"; exit 2; }
80
-
81
- if [[ -z "$value" ]]; then
82
- case "$tool" in
83
- claude)
84
- [[ -f "$HOME/.claude/settings.json" ]] || { warn "~/.claude/settings.json missing"; return; }
85
- echo "deployed: $(jq -r '.model // "default (unset)"' "$HOME/.claude/settings.json")"
86
- echo "SoT: $(jq -r '.model // "default (unset)"' "$REPO_DIR/SoT/.claude/settings.json")" ;;
87
- codex)
88
- [[ -f "$HOME/.codex/config.toml" ]] || { warn "~/.codex/config.toml missing"; return; }
89
- echo "deployed: $(awk -F'"' '/^model[[:space:]]*=/{print $2; exit}' "$HOME/.codex/config.toml")"
90
- echo "SoT: $(awk -F'"' '/^model[[:space:]]*=/{print $2; exit}' "$REPO_DIR/SoT/.codex/config.toml")" ;;
91
- esac
92
- common::print_models "$tool"
93
- return
94
- fi
95
-
96
- case "$tool" in
97
- claude)
98
- common::_validate_claude_model "$value" \
99
- || { common::print_models claude; err "Invalid Claude model '$value'"; exit 2; }
100
- CLAUDE_MODEL="$value"
101
- # shellcheck source=lib/claude.sh
102
- source "$REPO_DIR/lib/claude.sh"
103
- claude::sync_model ;;
104
- codex)
105
- common::_validate_codex_model "$value" \
106
- || { common::print_models codex; err "Invalid Codex model '$value'"; exit 2; }
107
- CODEX_MODEL="$value"
108
- # shellcheck source=lib/codex.sh
109
- source "$REPO_DIR/lib/codex.sh"
110
- codex::sync_model ;;
111
- esac
112
- }
113
-
114
- # Direct mode: toolchain doctor / single-tool ensure.
115
- engine::toolchain() {
116
- local op="${1:-check}" tool="${2:-}" arg
117
- for arg in "$@"; do
118
- [[ "$arg" == "--yes" ]] && ASSUME_YES=1
119
- done
120
-
121
- case "$op" in
122
- check) toolchain::report ;;
123
- ensure)
124
- [[ -n "$tool" && "$tool" != "--yes" ]] || { err "Usage: toolchain ensure <tool> [--yes]"; exit 2; }
125
- case "$tool" in
126
- rtk)
127
- # shellcheck source=lib/claude.sh
128
- source "$REPO_DIR/lib/claude.sh"
129
- toolchain::ensure rtk claude::_rtk_install ;;
130
- bun)
131
- # shellcheck source=lib/skills.sh
132
- source "$REPO_DIR/lib/skills.sh"
133
- skills::_bun_bootstrap >/dev/null ;;
134
- effect-solutions)
135
- # shellcheck source=lib/skills.sh
136
- source "$REPO_DIR/lib/skills.sh"
137
- toolchain::ensure effect-solutions skills::_effect_solutions_install ;;
138
- agent-browser)
139
- # shellcheck source=lib/skills.sh
140
- source "$REPO_DIR/lib/skills.sh"
141
- toolchain::ensure agent-browser skills::_agent_browser_install ;;
142
- *) err "toolchain ensure supports managed tools only (rtk, bun, effect-solutions, agent-browser)"; exit 2 ;;
143
- esac ;;
144
- *) err "Usage: toolchain [check|ensure <tool>] [--yes]"; exit 2 ;;
145
- esac
146
- }
147
-
148
- case "${1:-}" in
149
- model) shift; engine::model "$@" ;;
150
- toolchain) shift; engine::toolchain "$@" ;;
151
- sync) shift; engine::sync "$@" ;;
152
- *) engine::sync "$@" ;;
153
- esac