@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.
- package/README.md +47 -63
- package/bin/inject-claude-settings.mjs +4 -0
- package/dist/claude-hashes.json +9 -9
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/runCli/index.d.ts +1 -1
- package/dist/commands/runCli/runCli.d.ts +10 -6
- package/dist/commands/runCli/runCli.mjs +33 -6
- package/dist/commands/runCli/type.d.ts +4 -12
- package/dist/commands/runCli/utils/classifyTarget.d.ts +19 -0
- package/dist/commands/runCli/utils/classifyTarget.mjs +46 -0
- package/dist/commands/runCli/utils/renderOrFallback.d.ts +6 -0
- package/dist/commands/runCli/utils/renderOrFallback.mjs +12 -0
- package/dist/commands/runCli/utils/renderPlain.d.ts +11 -0
- package/dist/commands/runCli/utils/renderPlain.mjs +89 -0
- package/dist/commands/runCli/utils/resolvePackage.d.ts +16 -0
- package/dist/commands/runCli/utils/resolvePackage.mjs +74 -0
- package/dist/commands/runCli/utils/resolveScopeAlias.d.ts +2 -0
- package/dist/commands/runCli/utils/resolveScopeAlias.mjs +67 -0
- package/dist/commands/runCli/utils/resolveScopeFlag.d.ts +9 -1
- package/dist/commands/runCli/utils/resolveScopeFlag.mjs +5 -11
- package/dist/commands/runCli/utils/resolveTargets.d.ts +15 -0
- package/dist/commands/runCli/utils/resolveTargets.mjs +38 -0
- package/dist/commands/runCli/utils/toConsumerPackages.d.ts +9 -0
- package/dist/commands/runCli/utils/toConsumerPackages.mjs +26 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/injectDocs/index.d.ts +3 -2
- package/dist/core/injectDocs/type.d.ts +0 -19
- package/dist/core/injectDocs/utils/applyAction.mjs +1 -1
- package/dist/core/scope/index.d.ts +1 -1
- package/dist/core/scope/scope.d.ts +0 -1
- package/dist/core/scope/scope.mjs +1 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/ui/InjectApp/InjectApp.d.ts +2 -0
- package/dist/ui/InjectApp/InjectApp.mjs +82 -0
- package/dist/ui/InjectApp/index.d.ts +2 -0
- package/dist/ui/InjectApp/utils/eventSelectors.d.ts +5 -0
- package/dist/ui/InjectApp/utils/eventSelectors.mjs +24 -0
- package/dist/ui/InjectApp/utils/phaseReducer.d.ts +2 -0
- package/dist/ui/InjectApp/utils/phaseReducer.mjs +130 -0
- package/dist/ui/InjectApp/utils/renderInjectApp.d.ts +2 -0
- package/dist/ui/InjectApp/utils/renderInjectApp.mjs +19 -0
- package/dist/ui/InjectApp/utils/type.d.ts +5 -0
- package/dist/ui/components/ActionRow.d.ts +7 -0
- package/dist/ui/components/ActionRow.mjs +45 -0
- package/dist/ui/components/Banner.d.ts +7 -0
- package/dist/ui/components/Banner.mjs +9 -0
- package/dist/ui/components/ConfirmForce.d.ts +8 -0
- package/dist/ui/components/ConfirmForce.mjs +35 -0
- package/dist/ui/components/ErrorPanel.d.ts +6 -0
- package/dist/ui/components/ErrorPanel.mjs +14 -0
- package/dist/ui/components/Footer.d.ts +8 -0
- package/dist/ui/components/Footer.mjs +27 -0
- package/dist/ui/components/PlanTable.d.ts +8 -0
- package/dist/ui/components/PlanTable.mjs +15 -0
- package/dist/ui/components/ProgressBar.d.ts +10 -0
- package/dist/ui/components/ProgressBar.mjs +28 -0
- package/dist/ui/components/ScopePicker.d.ts +7 -0
- package/dist/ui/components/ScopePicker.mjs +26 -0
- package/dist/ui/components/Spinner.d.ts +8 -0
- package/dist/ui/components/Spinner.mjs +10 -0
- package/dist/ui/components/StatusBadge.d.ts +8 -0
- package/dist/ui/components/StepTracker.d.ts +9 -0
- package/dist/ui/components/StepTracker.mjs +43 -0
- package/dist/ui/components/Summary.d.ts +9 -0
- package/dist/ui/components/Summary.mjs +30 -0
- package/dist/ui/components/TargetCard.d.ts +11 -0
- package/dist/ui/components/TargetCard.mjs +29 -0
- package/dist/ui/hooks/useApplyStep.d.ts +12 -0
- package/dist/ui/hooks/useApplyStep.mjs +30 -0
- package/dist/ui/hooks/useExitApp.d.ts +8 -0
- package/dist/ui/hooks/useExitApp.mjs +19 -0
- package/dist/ui/hooks/useForceConfirmStep.d.ts +9 -0
- package/dist/ui/hooks/useForceConfirmStep.mjs +24 -0
- package/dist/ui/hooks/useInjectSession.d.ts +10 -0
- package/dist/ui/hooks/useInjectSession.mjs +63 -0
- package/dist/ui/hooks/useInterval.d.ts +1 -0
- package/dist/ui/hooks/usePhase.d.ts +2 -0
- package/dist/ui/hooks/usePhase.mjs +9 -0
- package/dist/ui/hooks/usePlanStep.d.ts +13 -0
- package/dist/ui/hooks/usePlanStep.mjs +94 -0
- package/dist/ui/hooks/useResolveStep.d.ts +18 -0
- package/dist/ui/hooks/useResolveStep.mjs +21 -0
- package/dist/ui/hooks/useTerminalWidth.d.ts +1 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.mjs +16 -0
- package/dist/ui/theme/colors.d.ts +12 -0
- package/dist/ui/theme/colors.mjs +9 -0
- package/dist/ui/theme/icons.d.ts +29 -0
- package/dist/ui/theme/icons.mjs +17 -0
- package/dist/ui/theme/layout.d.ts +20 -0
- package/dist/ui/theme/layout.mjs +9 -0
- package/dist/ui/types/event.d.ts +45 -0
- package/dist/ui/types/index.d.ts +4 -0
- package/dist/ui/types/phase.d.ts +44 -0
- package/dist/ui/types/render.d.ts +6 -0
- package/dist/ui/types/target.d.ts +25 -0
- package/dist/utils/version.d.ts +1 -1
- package/dist/utils/version.mjs +1 -1
- package/docs/claude/skills/claude-docs-asset-wiring/SKILL.md +159 -0
- package/docs/claude/skills/claude-docs-asset-wiring/knowledge/claude-md-template.md +78 -0
- package/docs/claude/skills/claude-docs-asset-wiring/knowledge/dependency-cruiser.md +54 -0
- package/docs/claude/skills/claude-docs-asset-wiring/knowledge/gotchas.md +125 -0
- package/docs/claude/skills/claude-docs-asset-wiring/knowledge/package-json-patches.md +150 -0
- package/docs/claude/skills/claude-docs-asset-wiring/knowledge/reference-files.md +37 -0
- package/docs/claude/skills/claude-docs-asset-wiring/knowledge/smoke-tests.md +111 -0
- package/docs/consumer-integration.md +43 -101
- package/package.json +13 -8
- package/scripts/dev-ui-fixtures.ts +288 -0
- package/scripts/dev-ui.tsx +289 -0
- package/bin/claude-sync.mjs +0 -24
- package/dist/commands/runCli/runCli.cjs +0 -31
- package/dist/commands/runCli/utils/injectOne.cjs +0 -48
- package/dist/commands/runCli/utils/injectOne.d.ts +0 -3
- package/dist/commands/runCli/utils/injectOne.mjs +0 -46
- package/dist/commands/runCli/utils/resolveScopeFlag.cjs +0 -28
- package/dist/commands/runCli/utils/runInject.cjs +0 -36
- package/dist/commands/runCli/utils/runInject.d.ts +0 -2
- package/dist/commands/runCli/utils/runInject.mjs +0 -34
- package/dist/core/buildPlan/buildPlan.cjs +0 -42
- package/dist/core/buildPlan/utils/toPosix.cjs +0 -9
- package/dist/core/buildPlan/utils/walkFiles.cjs +0 -25
- package/dist/core/hash/hash.cjs +0 -30
- package/dist/core/hashManifest/hashManifest.cjs +0 -27
- package/dist/core/injectDocs/injectDocs.cjs +0 -43
- package/dist/core/injectDocs/injectDocs.d.ts +0 -2
- package/dist/core/injectDocs/injectDocs.mjs +0 -41
- package/dist/core/injectDocs/utils/applyAction.cjs +0 -21
- package/dist/core/injectDocs/utils/emitCiForceList.cjs +0 -10
- package/dist/core/injectDocs/utils/emitCiForceList.d.ts +0 -2
- package/dist/core/injectDocs/utils/emitCiForceList.mjs +0 -8
- package/dist/core/injectDocs/utils/printPlan.cjs +0 -20
- package/dist/core/injectDocs/utils/printPlan.d.ts +0 -2
- package/dist/core/injectDocs/utils/printPlan.mjs +0 -18
- package/dist/core/injectDocs/utils/summarize.cjs +0 -27
- package/dist/core/scope/scope.cjs +0 -46
- package/dist/core/scope/utils/isDirectory.cjs +0 -14
- package/dist/index.cjs +0 -20
- package/dist/prompts/confirmForce.cjs +0 -27
- package/dist/prompts/confirmForce.d.ts +0 -1
- package/dist/prompts/confirmForce.mjs +0 -25
- package/dist/prompts/index.d.ts +0 -2
- package/dist/prompts/selectScope.cjs +0 -30
- package/dist/prompts/selectScope.d.ts +0 -2
- package/dist/prompts/selectScope.mjs +0 -28
- package/dist/utils/asyncPool.cjs +0 -26
- package/dist/utils/heartbeat.cjs +0 -25
- package/dist/utils/heartbeat.d.ts +0 -16
- package/dist/utils/heartbeat.mjs +0 -23
- package/dist/utils/logger.cjs +0 -74
- package/dist/utils/version.cjs +0 -5
- package/docs/claude/skills/claude-sync-applier/SKILL.md +0 -195
- package/docs/claude/skills/claude-sync-applier/knowledge/claude-md-template.md +0 -77
- package/docs/claude/skills/claude-sync-applier/knowledge/dependency-cruiser.md +0 -126
- package/docs/claude/skills/claude-sync-applier/knowledge/gotchas.md +0 -139
- package/docs/claude/skills/claude-sync-applier/knowledge/package-json-patches.md +0 -130
- package/docs/claude/skills/claude-sync-applier/knowledge/reference-files.md +0 -120
- 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.
|