fiko-ai-context-sync
v0.1.0
Published
Syncs the shared fiko-ai-context bundle (CLAUDE.md, .ai/*, githooks) into a consumer repo
Readme
fiko-ai-context-sync
CLI that syncs the fiko-ai-context bundle
(CLAUDE.md, .ai/*, git hooks) into a consumer service repo. Ported from
fiko-shared-types/scripts/distribute-types.js's proven copy/clean/CRLF-safe
approach, adapted from a push model (run from the source repo) to a pull
model (run from inside each consumer, since .ai/* isn't an npm dependency
of each service and CI runners only ever check out one repo at a time).
Status: prototype, not yet published to npm. Consumer repos reference it
via a local file: link during the fiko-core-service rollout prototype;
see fiko-ai-context/README.md's "Deferred"/handoff notes for what's left
before a real npm publish.
Commands
fiko-ai-context-sync pull [--quiet] [--source <path>] [--repo-url <url>] [--ref <tag|branch>]
fiko-ai-context-sync check [--source <path>] [--repo-url <url>] [--ref <tag|branch>]
fiko-ai-context-sync install-hookspull— the main sync operation. Copies.ai/andgithooks/from the resolved source into the current repo, mergesCLAUDE.md(preserving the repo's own "Repo-local preface" below the sync markers), writes.ai-context-version, and callsinstall-hooks. Never exits non-zero and never throws — any failure (network, missing source, git error) is logged to stderr as a warning and the existing context is left in place. This is what makes it safe inpostinstall: a Docker build layer that runspnpm installbeforeCOPY . .has no.gitdirectory present, sopulldetects that and no-ops immediately, rather than breaking the build.check— compares the local.ai-context-versionto the latest sourceVERSIONand exits 1 on mismatch. Used by CI (though CI implements the same comparison directly in shell rather than depending on this package — seefiko-ai-context'scheck_ai_context_versionjob — so a registry outage never blocks a pipeline). Useful locally as a pre-flight check.install-hooks— idempotently pointscore.hooksPathat.githooks. Warns (doesn't override) ifcore.hooksPathis already set to something else. Called automatically at the end ofpull.
Source resolution order
--source <path>— explicit override (local testing).../fiko-ai-contextsibling folder relative to cwd — fast path for local dev in this org's folder-of-repos layout, no network needed.- A cached shallow clone at
~/.cache/fiko-ai-context, fetched to the highest semver tag on the remote (falls back tomainif no tags exist yet).
Wiring into a consumer repo
// package.json
{
"scripts": {
"sync:ai-context": "fiko-ai-context-sync pull",
"postinstall": "fiko-ai-context-sync pull --quiet"
},
"devDependencies": {
"fiko-ai-context-sync": "^0.1.0"
}
}Plus .githooks/post-merge / .githooks/post-checkout (synced in from
fiko-ai-context/githooks/, wired via core.hooksPath once install-hooks
has run at least once).
