docks-kit 0.1.0 → 0.1.1

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 +746 -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 +218 -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
@@ -0,0 +1,89 @@
1
+ # EngineNative Design
2
+
3
+ EngineNative is the only supported sync engine. It lives in
4
+ `cli/src/engine-native/` and is invoked through `cli/src/engine.ts`; the rest
5
+ of the CLI passes normalized argv to that seam. The former shell engine was
6
+ removed after the `bash-engine-final` tag. `DOCKS_KIT_ENGINE=bash` is now an
7
+ explicit removed-engine diagnostic and exits 2 with the recovery tag message.
8
+
9
+ ## Selection Contract
10
+
11
+ - Public CLI commands route through `engine(args)` after @effect/cli parses
12
+ pickers, target words, and flag spellings.
13
+ - `engineCapture(args)` re-spawns the raw channel to capture stdout for
14
+ commands such as `status --json`.
15
+ - `DOCKS_KIT_ENGINE=native-raw` is harness-private: it bypasses @effect/cli
16
+ and hands argv directly to EngineNative so tests can exercise the internal
17
+ engine vocabulary.
18
+
19
+ ## Behavior Contract
20
+
21
+ - **Golden regression is the engine contract.** Dry-run output, mutation tree
22
+ shape, child-process argv logs, normalized output, and exit codes are recorded
23
+ under `cli/test/goldens/`.
24
+ - **`--update-goldens` is review-gated.** Regeneration must be byte-identical
25
+ on an unchanged engine; intentional behavior changes update goldens in the
26
+ same reviewed diff.
27
+ - **Prove-red stays red.** The golden suites compare live native output to a
28
+ mismatched golden under `--prove-red` and must exit non-zero after printing
29
+ `prove-red OK`.
30
+ - **Step ordering is load-bearing.** The Claude pipeline runs RTK before the
31
+ settings merge, modifiers after it, removals before plugins, and LSP checks
32
+ after plugin state.
33
+ - **External CLIs stay external.** `claude`, `codex`, `npx`, `npm`, `rtk`,
34
+ `bun`, `curl`, and platform package managers are spawned with argv arrays,
35
+ not shell command strings except where the external installer contract is a
36
+ shell script.
37
+ - **Backups precede mutation.** Deployed settings/config files write `.bak`
38
+ backups before replacement.
39
+
40
+ ## Module Map
41
+
42
+ | Module | Owns |
43
+ |---|---|
44
+ | `parseArgs.ts` | engine usage, target selection, flag parsing, legacy rename hints, preflight, model flag validation |
45
+ | `index.ts` | sync orchestration, target dispatch, run summary and next-step blocks |
46
+ | `claudeSync.ts` | Claude pipeline: RTK, assets, settings merge, deploy-time modifiers, `~/.claude.json`, connector env, removed artifacts, plugins, optional plugins, LSP binaries |
47
+ | `settings.ts` | pure Claude settings merge/reconcile semantics and permission-array union |
48
+ | `claudeModel.ts` | deployed Claude model modifier and direct `model claude` write path |
49
+ | `codexSync.ts` | Codex pipeline: bubblewrap check, config merge, rules, AGENTS.md, personal marketplace, plugin refresh |
50
+ | `codexToml.ts` | line-based top-level TOML replacement and deployed Codex model modifier |
51
+ | `skillsSync.ts` | universal skill install/prune, Claude symlink healing, agent-browser/effect-solutions/Bun helpers, managed-skill snapshot |
52
+ | `toolchain.ts` | tool presence/version probes, verified-version gate, managed install/upgrade orchestration, report table |
53
+ | `modes.ts` | direct `model` and `toolchain` modes |
54
+ | `models.ts` | model catalog listing and validation |
55
+ | `jq.ts` | JSON helpers that preserve jq-style merge/order/stringify behavior where the deployed file contract needs it |
56
+ | `exec.ts` | path helpers, command probes, capture/spawn wrappers, Windows command resolution |
57
+ | `output.ts` | stable stdout/stderr emitters |
58
+
59
+ ## Windows Specifics
60
+
61
+ - Home resolves through Node's platform APIs; CI deliberately unsets `HOME` so
62
+ `%USERPROFILE%` is exercised.
63
+ - Paths are built through `node:path`.
64
+ - Connector env uses `setx` on win32; Unix shell rc files are not touched.
65
+ - Symlink creation falls back to copy where the platform or permissions require
66
+ it.
67
+ - Bubblewrap and shell-rc work are Linux/macOS only.
68
+ - Claude hook/statusline assets remain shell scripts because Claude Code owns
69
+ that runtime.
70
+
71
+ ## Tests
72
+
73
+ - `bun run test:unit` covers pure JSON merge semantics and jq-oracle cases.
74
+ - `bun run golden:dryrun` compares live native dry-run output to
75
+ `cli/test/goldens/dryrun.json`.
76
+ - `bun run golden:mutation` compares live native mutation snapshots, argv logs,
77
+ output, and TOML invariants to `cli/test/goldens/mutation.json`.
78
+ - `.github/workflows/parity.yml` is now the golden-regression workflow: Linux
79
+ runs unit + golden + prove-red; the `native-windows` job runs PowerShell
80
+ smoke checks for native Windows behavior.
81
+ - `.github/workflows/windows-entrypoints.yml` verifies the release binary and
82
+ `bun add -g` entrypoints on Windows.
83
+
84
+ ## Non-Goals
85
+
86
+ - Reintroducing the removed shell engine as a supported fallback. Fix forward in
87
+ EngineNative; recover historical source only from `bash-engine-final`.
88
+ - Porting Claude Code's hook/statusline shell assets.
89
+ - Adding new sync features while changing the engine contract.
@@ -0,0 +1,48 @@
1
+ /**
2
+ * --claude-model deploy-time modifier, shared with the `model claude <value>`
3
+ * direct mode.
4
+ */
5
+ import { p } from "./exec"
6
+ import { readFileSync, renameSync, writeFileSync } from "node:fs"
7
+
8
+ import type { Ctx } from "./index"
9
+ import { isObject, jqStringify, parseJson } from "./jq"
10
+ import { echo, err, log, warn } from "./output"
11
+
12
+ export function syncClaudeModel(ctx: Ctx, model: string): void {
13
+ const userSettings = p(ctx.home, ".claude", "settings.json")
14
+
15
+ if (model === "") return
16
+
17
+ if (ctx.dryRun) {
18
+ if (model === "default") {
19
+ echo(`[dry-run] (--claude-model) delete .model in ${userSettings} (account default applies)`)
20
+ } else {
21
+ echo(`[dry-run] (--claude-model) set .model=${model} in ${userSettings}`)
22
+ }
23
+ return
24
+ }
25
+
26
+ let text: string
27
+ try {
28
+ text = readFileSync(userSettings, "utf8")
29
+ } catch {
30
+ warn(`(--claude-model) ${userSettings} missing — skipped`)
31
+ return
32
+ }
33
+ const doc = parseJson(text)
34
+ if (doc === undefined) {
35
+ err(`(--claude-model) ${userSettings} is not valid JSON — skipped`)
36
+ return
37
+ }
38
+ if (isObject(doc)) {
39
+ if (model === "default") {
40
+ delete doc["model"]
41
+ } else {
42
+ doc["model"] = model
43
+ }
44
+ }
45
+ writeFileSync(`${userSettings}.tmp`, jqStringify(doc))
46
+ renameSync(`${userSettings}.tmp`, userSettings)
47
+ log(`Model: deployed settings model set to ${model} (SoT unchanged; flag-less sync reverts)`)
48
+ }