@slats/claude-assets-sync 0.2.0 → 0.3.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 (158) hide show
  1. package/README.md +47 -63
  2. package/bin/inject-claude-settings.mjs +4 -0
  3. package/dist/claude-hashes.json +9 -9
  4. package/dist/commands/index.d.ts +1 -1
  5. package/dist/commands/runCli/index.d.ts +1 -1
  6. package/dist/commands/runCli/runCli.d.ts +10 -6
  7. package/dist/commands/runCli/runCli.mjs +33 -6
  8. package/dist/commands/runCli/type.d.ts +4 -12
  9. package/dist/commands/runCli/utils/classifyTarget.d.ts +19 -0
  10. package/dist/commands/runCli/utils/classifyTarget.mjs +46 -0
  11. package/dist/commands/runCli/utils/renderOrFallback.d.ts +6 -0
  12. package/dist/commands/runCli/utils/renderOrFallback.mjs +12 -0
  13. package/dist/commands/runCli/utils/renderPlain.d.ts +11 -0
  14. package/dist/commands/runCli/utils/renderPlain.mjs +89 -0
  15. package/dist/commands/runCli/utils/resolvePackage.d.ts +16 -0
  16. package/dist/commands/runCli/utils/resolvePackage.mjs +74 -0
  17. package/dist/commands/runCli/utils/resolveScopeAlias.d.ts +2 -0
  18. package/dist/commands/runCli/utils/resolveScopeAlias.mjs +67 -0
  19. package/dist/commands/runCli/utils/resolveScopeFlag.d.ts +9 -1
  20. package/dist/commands/runCli/utils/resolveScopeFlag.mjs +5 -11
  21. package/dist/commands/runCli/utils/resolveTargets.d.ts +15 -0
  22. package/dist/commands/runCli/utils/resolveTargets.mjs +38 -0
  23. package/dist/commands/runCli/utils/toConsumerPackages.d.ts +9 -0
  24. package/dist/commands/runCli/utils/toConsumerPackages.mjs +26 -0
  25. package/dist/core/index.d.ts +2 -2
  26. package/dist/core/injectDocs/index.d.ts +3 -2
  27. package/dist/core/injectDocs/type.d.ts +0 -19
  28. package/dist/core/injectDocs/utils/applyAction.mjs +1 -1
  29. package/dist/core/scope/index.d.ts +1 -1
  30. package/dist/core/scope/scope.d.ts +0 -1
  31. package/dist/core/scope/scope.mjs +1 -4
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.mjs +2 -2
  34. package/dist/ui/InjectApp/InjectApp.d.ts +2 -0
  35. package/dist/ui/InjectApp/InjectApp.mjs +82 -0
  36. package/dist/ui/InjectApp/index.d.ts +2 -0
  37. package/dist/ui/InjectApp/utils/eventSelectors.d.ts +5 -0
  38. package/dist/ui/InjectApp/utils/eventSelectors.mjs +24 -0
  39. package/dist/ui/InjectApp/utils/phaseReducer.d.ts +2 -0
  40. package/dist/ui/InjectApp/utils/phaseReducer.mjs +130 -0
  41. package/dist/ui/InjectApp/utils/renderInjectApp.d.ts +2 -0
  42. package/dist/ui/InjectApp/utils/renderInjectApp.mjs +19 -0
  43. package/dist/ui/InjectApp/utils/type.d.ts +5 -0
  44. package/dist/ui/components/ActionRow.d.ts +7 -0
  45. package/dist/ui/components/ActionRow.mjs +45 -0
  46. package/dist/ui/components/Banner.d.ts +7 -0
  47. package/dist/ui/components/Banner.mjs +9 -0
  48. package/dist/ui/components/ConfirmForce.d.ts +8 -0
  49. package/dist/ui/components/ConfirmForce.mjs +35 -0
  50. package/dist/ui/components/ErrorPanel.d.ts +6 -0
  51. package/dist/ui/components/ErrorPanel.mjs +14 -0
  52. package/dist/ui/components/Footer.d.ts +8 -0
  53. package/dist/ui/components/Footer.mjs +27 -0
  54. package/dist/ui/components/PlanTable.d.ts +8 -0
  55. package/dist/ui/components/PlanTable.mjs +15 -0
  56. package/dist/ui/components/ProgressBar.d.ts +10 -0
  57. package/dist/ui/components/ProgressBar.mjs +28 -0
  58. package/dist/ui/components/ScopePicker.d.ts +7 -0
  59. package/dist/ui/components/ScopePicker.mjs +26 -0
  60. package/dist/ui/components/Spinner.d.ts +8 -0
  61. package/dist/ui/components/Spinner.mjs +10 -0
  62. package/dist/ui/components/StatusBadge.d.ts +8 -0
  63. package/dist/ui/components/StepTracker.d.ts +9 -0
  64. package/dist/ui/components/StepTracker.mjs +43 -0
  65. package/dist/ui/components/Summary.d.ts +9 -0
  66. package/dist/ui/components/Summary.mjs +30 -0
  67. package/dist/ui/components/TargetCard.d.ts +11 -0
  68. package/dist/ui/components/TargetCard.mjs +29 -0
  69. package/dist/ui/hooks/useApplyStep.d.ts +12 -0
  70. package/dist/ui/hooks/useApplyStep.mjs +30 -0
  71. package/dist/ui/hooks/useExitApp.d.ts +8 -0
  72. package/dist/ui/hooks/useExitApp.mjs +19 -0
  73. package/dist/ui/hooks/useForceConfirmStep.d.ts +9 -0
  74. package/dist/ui/hooks/useForceConfirmStep.mjs +24 -0
  75. package/dist/ui/hooks/useInjectSession.d.ts +10 -0
  76. package/dist/ui/hooks/useInjectSession.mjs +63 -0
  77. package/dist/ui/hooks/useInterval.d.ts +1 -0
  78. package/dist/ui/hooks/usePhase.d.ts +2 -0
  79. package/dist/ui/hooks/usePhase.mjs +9 -0
  80. package/dist/ui/hooks/usePlanStep.d.ts +13 -0
  81. package/dist/ui/hooks/usePlanStep.mjs +94 -0
  82. package/dist/ui/hooks/useResolveStep.d.ts +18 -0
  83. package/dist/ui/hooks/useResolveStep.mjs +21 -0
  84. package/dist/ui/hooks/useTerminalWidth.d.ts +1 -0
  85. package/dist/ui/index.d.ts +2 -0
  86. package/dist/ui/index.mjs +16 -0
  87. package/dist/ui/theme/colors.d.ts +12 -0
  88. package/dist/ui/theme/colors.mjs +9 -0
  89. package/dist/ui/theme/icons.d.ts +29 -0
  90. package/dist/ui/theme/icons.mjs +17 -0
  91. package/dist/ui/theme/layout.d.ts +20 -0
  92. package/dist/ui/theme/layout.mjs +9 -0
  93. package/dist/ui/types/event.d.ts +45 -0
  94. package/dist/ui/types/index.d.ts +4 -0
  95. package/dist/ui/types/phase.d.ts +44 -0
  96. package/dist/ui/types/render.d.ts +6 -0
  97. package/dist/ui/types/target.d.ts +25 -0
  98. package/dist/utils/version.d.ts +1 -1
  99. package/dist/utils/version.mjs +1 -1
  100. package/docs/claude/skills/claude-docs-asset-wiring/SKILL.md +159 -0
  101. package/docs/claude/skills/claude-docs-asset-wiring/knowledge/claude-md-template.md +78 -0
  102. package/docs/claude/skills/claude-docs-asset-wiring/knowledge/dependency-cruiser.md +54 -0
  103. package/docs/claude/skills/claude-docs-asset-wiring/knowledge/gotchas.md +125 -0
  104. package/docs/claude/skills/claude-docs-asset-wiring/knowledge/package-json-patches.md +150 -0
  105. package/docs/claude/skills/claude-docs-asset-wiring/knowledge/reference-files.md +37 -0
  106. package/docs/claude/skills/claude-docs-asset-wiring/knowledge/smoke-tests.md +111 -0
  107. package/docs/consumer-integration.md +43 -101
  108. package/package.json +13 -8
  109. package/scripts/dev-ui-fixtures.ts +288 -0
  110. package/scripts/dev-ui.tsx +289 -0
  111. package/bin/claude-sync.mjs +0 -24
  112. package/dist/commands/runCli/runCli.cjs +0 -31
  113. package/dist/commands/runCli/utils/injectOne.cjs +0 -48
  114. package/dist/commands/runCli/utils/injectOne.d.ts +0 -3
  115. package/dist/commands/runCli/utils/injectOne.mjs +0 -46
  116. package/dist/commands/runCli/utils/resolveScopeFlag.cjs +0 -28
  117. package/dist/commands/runCli/utils/runInject.cjs +0 -36
  118. package/dist/commands/runCli/utils/runInject.d.ts +0 -2
  119. package/dist/commands/runCli/utils/runInject.mjs +0 -34
  120. package/dist/core/buildPlan/buildPlan.cjs +0 -42
  121. package/dist/core/buildPlan/utils/toPosix.cjs +0 -9
  122. package/dist/core/buildPlan/utils/walkFiles.cjs +0 -25
  123. package/dist/core/hash/hash.cjs +0 -30
  124. package/dist/core/hashManifest/hashManifest.cjs +0 -27
  125. package/dist/core/injectDocs/injectDocs.cjs +0 -43
  126. package/dist/core/injectDocs/injectDocs.d.ts +0 -2
  127. package/dist/core/injectDocs/injectDocs.mjs +0 -41
  128. package/dist/core/injectDocs/utils/applyAction.cjs +0 -21
  129. package/dist/core/injectDocs/utils/emitCiForceList.cjs +0 -10
  130. package/dist/core/injectDocs/utils/emitCiForceList.d.ts +0 -2
  131. package/dist/core/injectDocs/utils/emitCiForceList.mjs +0 -8
  132. package/dist/core/injectDocs/utils/printPlan.cjs +0 -20
  133. package/dist/core/injectDocs/utils/printPlan.d.ts +0 -2
  134. package/dist/core/injectDocs/utils/printPlan.mjs +0 -18
  135. package/dist/core/injectDocs/utils/summarize.cjs +0 -27
  136. package/dist/core/scope/scope.cjs +0 -46
  137. package/dist/core/scope/utils/isDirectory.cjs +0 -14
  138. package/dist/index.cjs +0 -20
  139. package/dist/prompts/confirmForce.cjs +0 -27
  140. package/dist/prompts/confirmForce.d.ts +0 -1
  141. package/dist/prompts/confirmForce.mjs +0 -25
  142. package/dist/prompts/index.d.ts +0 -2
  143. package/dist/prompts/selectScope.cjs +0 -30
  144. package/dist/prompts/selectScope.d.ts +0 -2
  145. package/dist/prompts/selectScope.mjs +0 -28
  146. package/dist/utils/asyncPool.cjs +0 -26
  147. package/dist/utils/heartbeat.cjs +0 -25
  148. package/dist/utils/heartbeat.d.ts +0 -16
  149. package/dist/utils/heartbeat.mjs +0 -23
  150. package/dist/utils/logger.cjs +0 -74
  151. package/dist/utils/version.cjs +0 -5
  152. package/docs/claude/skills/claude-sync-applier/SKILL.md +0 -195
  153. package/docs/claude/skills/claude-sync-applier/knowledge/claude-md-template.md +0 -77
  154. package/docs/claude/skills/claude-sync-applier/knowledge/dependency-cruiser.md +0 -126
  155. package/docs/claude/skills/claude-sync-applier/knowledge/gotchas.md +0 -139
  156. package/docs/claude/skills/claude-sync-applier/knowledge/package-json-patches.md +0 -130
  157. package/docs/claude/skills/claude-sync-applier/knowledge/reference-files.md +0 -120
  158. package/docs/claude/skills/claude-sync-applier/knowledge/smoke-tests.md +0 -102
@@ -1,120 +0,0 @@
1
- # Reference Files
2
-
3
- The two stub files are **identical across all consumers**. Copy verbatim, do
4
- no substitution — the stubs discover package metadata at runtime via
5
- `import.meta.url`.
6
-
7
- Reference consumer: `packages/canard/schema-form`.
8
-
9
- ---
10
-
11
- ## `bin/claude-sync.mjs`
12
-
13
- Source of truth: `packages/canard/schema-form/bin/claude-sync.mjs`.
14
-
15
- Expected content (must match exactly):
16
-
17
- ```js
18
- #!/usr/bin/env node
19
- import { runCli } from '@slats/claude-assets-sync';
20
- import { readFile } from 'node:fs/promises';
21
- import { dirname, resolve } from 'node:path';
22
- import { fileURLToPath } from 'node:url';
23
-
24
- const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
25
- const pkg = JSON.parse(
26
- await readFile(resolve(packageRoot, 'package.json'), 'utf-8'),
27
- );
28
-
29
- if (typeof pkg.claude?.assetPath === 'string') {
30
- runCli(process.argv, {
31
- packageRoot,
32
- packageName: pkg.name,
33
- packageVersion: pkg.version,
34
- assetPath: pkg.claude.assetPath,
35
- }).catch((err) => {
36
- process.stderr.write(
37
- `[${pkg.name}] claude-sync failed: ${err instanceof Error ? err.message : String(err)}\n`,
38
- );
39
- process.exit(1);
40
- });
41
- }
42
- ```
43
-
44
- **Notes**
45
-
46
- - `import.meta.url` is resolved at runtime to the installed file path, so
47
- `packageRoot` works both during local development and when consumed as a
48
- dependency.
49
- - `pkg.claude?.assetPath` missing → the stub is a silent no-op. That is the
50
- feature that lets a package opt out without shipping broken bins.
51
- - Emit to stderr on failure and exit 1. Do not `throw` — the CLI is the
52
- process boundary.
53
-
54
- After writing, make it executable:
55
-
56
- ```bash
57
- chmod +x ${TARGET_PATH}/bin/claude-sync.mjs
58
- ```
59
-
60
- ---
61
-
62
- ## `scripts/build-hashes.mjs`
63
-
64
- Source of truth: `packages/canard/schema-form/scripts/build-hashes.mjs`.
65
-
66
- Expected content (must match exactly):
67
-
68
- ```js
69
- #!/usr/bin/env node
70
- // Thin wrapper — parses this package's package.json and delegates to
71
- // @slats/claude-assets-sync/buildHashes. The `claude.assetPath` convention
72
- // lives here, in the consumer; the library is generic.
73
- import { buildHashes } from '@slats/claude-assets-sync/buildHashes';
74
- import { readFile } from 'node:fs/promises';
75
- import { resolve } from 'node:path';
76
-
77
- const packageRoot = process.cwd();
78
- const pkg = JSON.parse(
79
- await readFile(resolve(packageRoot, 'package.json'), 'utf-8'),
80
- );
81
-
82
- if (typeof pkg.claude?.assetPath === 'string') {
83
- try {
84
- const { outPath, fileCount } = await buildHashes({
85
- packageRoot,
86
- packageName: pkg.name,
87
- packageVersion: pkg.version,
88
- assetPath: pkg.claude.assetPath,
89
- });
90
- console.log(
91
- `✓ claude-hashes.json written: ${fileCount} file(s) → ${outPath}`,
92
- );
93
- } catch (err) {
94
- console.error('❌ build-hashes failed:', err?.message ?? err);
95
- process.exit(1);
96
- }
97
- }
98
- ```
99
-
100
- **Notes**
101
-
102
- - `packageRoot = process.cwd()` intentionally — this script runs via
103
- `yarn <shortcut> build:hashes` from the package directory.
104
- - Same no-op behavior when `claude.assetPath` is missing.
105
- - Emits to stdout on success (humans read it during the build).
106
-
107
- No `chmod +x` needed — it's invoked via `node scripts/build-hashes.mjs`.
108
-
109
- ---
110
-
111
- ## Verification
112
-
113
- Before declaring Step 1/Step 2 complete, diff against the reference:
114
-
115
- ```bash
116
- diff packages/canard/schema-form/bin/claude-sync.mjs ${TARGET_PATH}/bin/claude-sync.mjs
117
- diff packages/canard/schema-form/scripts/build-hashes.mjs ${TARGET_PATH}/scripts/build-hashes.mjs
118
- ```
119
-
120
- Both diffs must be empty.
@@ -1,102 +0,0 @@
1
- # E2E Smoke Tests — 6-path matrix
2
-
3
- **Run from `/tmp/...` — never from the monorepo root or `${TARGET_PATH}/`.**
4
-
5
- `--scope=project` walks `cwd` upward looking for an existing `.claude`
6
- directory. Running from the monorepo would reuse or mutate the real repo's
7
- `.claude`, which is a destructive error.
8
-
9
- No fake `node_modules` needed — the bin resolves everything via
10
- `import.meta.url`.
11
-
12
- ---
13
-
14
- ## Setup
15
-
16
- ```bash
17
- BIN=$PWD/${TARGET_PATH}/bin/claude-sync.mjs
18
- DIR=/tmp/claude-sync-smoke-${SHORTCUT:-target}
19
- [ -d "$DIR" ] && find "$DIR" -mindepth 1 -delete
20
- mkdir -p "$DIR" && cd "$DIR"
21
- ```
22
-
23
- `[ -d ... ] && find -delete` keeps the setup idempotent. **Never** use
24
- `rm -rf` or unquoted `*` globs — too easy to nuke the wrong directory.
25
-
26
- ---
27
-
28
- ## Matrix
29
-
30
- Execute sequentially. `EXIT=$?` after each so the value is captured before the
31
- next command overwrites `$?`.
32
-
33
- | # | Command | Expected exit | Purpose |
34
- |---|-----------------------------------------------------------------------------|---------------|----------------------------------------------------------|
35
- | 1 | `node "$BIN" --scope=project --dry-run` | 0 | Dry run on empty dir — previews actions, no writes. |
36
- | 2 | `node "$BIN" --scope=project` | 0 | First real install — writes `.claude/` under `$DIR`. |
37
- | 3 | `node "$BIN" --scope=project` | 0 | Re-run — no-op because everything is already up-to-date. |
38
- | 4 | (after tampering) `CI=true node "$BIN" --scope=project` | **2** | CI + tampered content → refuse to overwrite. |
39
- | 5 | `CI=true node "$BIN" --scope=project --force` | 0 | `--force` overrides the refusal. |
40
- | 6 | `CI=true node "$BIN"` | **2** | Missing `--scope` in non-TTY context → exit 2. |
41
-
42
- ### Tamper step (between path 3 and path 4)
43
-
44
- ```bash
45
- find .claude -name SKILL.md -exec sh -c 'echo tampered >> "$1"' _ {} \;
46
- ```
47
-
48
- Appends `tampered` to every `SKILL.md` under the local `.claude/`. This
49
- simulates a human edit that the CI-mode bin must detect and refuse to clobber.
50
-
51
- ---
52
-
53
- ## Execution Shape
54
-
55
- Split into **two bash calls** because `cwd` resets between Bash tool
56
- invocations.
57
-
58
- **First call** — paths 1–3:
59
-
60
- ```bash
61
- BIN=$PWD/${TARGET_PATH}/bin/claude-sync.mjs
62
- DIR=/tmp/claude-sync-smoke-${SHORTCUT:-target}
63
- [ -d "$DIR" ] && find "$DIR" -mindepth 1 -delete
64
- mkdir -p "$DIR" && cd "$DIR"
65
-
66
- node "$BIN" --scope=project --dry-run; echo "EXIT=$?" # expect 0
67
- node "$BIN" --scope=project; echo "EXIT=$?" # expect 0
68
- node "$BIN" --scope=project; echo "EXIT=$?" # expect 0
69
- ```
70
-
71
- **Second call** — paths 4–6 (re-enter `$DIR`, reuse state from first call):
72
-
73
- ```bash
74
- DIR=/tmp/claude-sync-smoke-${SHORTCUT:-target}
75
- BIN=$PWD/${TARGET_PATH}/bin/claude-sync.mjs
76
- cd "$DIR"
77
-
78
- find .claude -name SKILL.md -exec sh -c 'echo tampered >> "$1"' _ {} \;
79
- CI=true node "$BIN" --scope=project; echo "EXIT=$?" # expect 2
80
- CI=true node "$BIN" --scope=project --force; echo "EXIT=$?" # expect 0
81
- CI=true node "$BIN"; echo "EXIT=$?" # expect 2
82
- ```
83
-
84
- Note: `$PWD` in the second call is the parent shell's cwd (monorepo root), so
85
- `BIN` resolves correctly. `cd "$DIR"` then moves into the smoke directory
86
- before invoking.
87
-
88
- ---
89
-
90
- ## Failure Handling
91
-
92
- | Observed | Meaning | Action |
93
- |----------|-------------------------------------------------------------------------|--------------------------------------------------------------------|
94
- | 1 ≠ 0 | Dry-run crashed. Likely a stub or engine bug. | Stop, capture stderr, report. |
95
- | 2 ≠ 0 | First write failed. Likely permissions, engine bug, or manifest issue. | Stop, inspect `dist/claude-hashes.json`, report. |
96
- | 3 ≠ 0 | Idempotency broken — re-run should be no-op. | Stop, diff `$DIR/.claude` before/after, report. |
97
- | 4 = 0 | CI mode did not refuse tampered files. Safety regression. | Stop — the engine's CI gate is broken. |
98
- | 5 ≠ 0 | `--force` failed to override. Check engine. | Stop, report. |
99
- | 6 = 0 | Engine defaulted a scope in non-TTY context. Should require `--scope`. | Stop, report. |
100
-
101
- Do not attempt to "make the tests pass" by altering expectations. The matrix
102
- encodes invariants of the engine — a mismatch is a real regression upstream.