public-ai-sync 0.0.73 → 0.0.74

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 CHANGED
@@ -22,17 +22,17 @@ Empty git repo with a `package.json`:
22
22
 
23
23
  1. `npm install --save-dev public-ai-sync`
24
24
  2. Confirm `.public-ai/` is filled and root links exist (`rules`, `skills`, `scripts/lint`, `.claude/settings.json`)
25
- 3. Copy [github-ai-guardrails-npm.yml](../../skills/repo/setup-repo/assets/ci/github-ai-guardrails-npm.yml) (or the GitLab sibling) into the consumer CI. The job **must** `npm ci` before any linked script; those paths are gitignored
26
- 4. Point git hooks at `skills/repo/setup-repo/assets/scripts/check-clean-code.sh` (pre-commit) and `skills/repo/setup-repo/assets/scripts/pre-push-gate.sh` (pre-push). Husky example:
25
+ 3. Copy [github-ai-guardrails-npm.yml](../../repo/setup-repo/assets/ci/github-ai-guardrails-npm.yml) (or the GitLab sibling) into the consumer CI. The job **must** `npm ci` before any linked script; those paths are gitignored
26
+ 4. Point git hooks at `repo/setup-repo/assets/scripts/check-clean-code.sh` (pre-commit) and `repo/setup-repo/assets/scripts/pre-push-gate.sh` (pre-push). Husky example:
27
27
 
28
28
  ```sh
29
- skills/repo/setup-repo/assets/scripts/check-clean-code.sh || exit $?
30
- skills/repo/setup-repo/assets/scripts/pre-push-gate.sh || exit $?
29
+ repo/setup-repo/assets/scripts/check-clean-code.sh || exit $?
30
+ repo/setup-repo/assets/scripts/pre-push-gate.sh || exit $?
31
31
  ```
32
32
 
33
- 5. Ignore synced trees in the product linter / formatter / test runner: `.public-ai/**`, `skills/**`, `rules/**`, `AI-setup/**`, `scripts/lint/**`, `scripts/guard/**`, `scripts/tests/**`
34
- 6. JS/TS: import `cleanCodeRules` from `skills/repo/setup-repo/assets/lint/eslint.clean-code.js` (exists after `npm ci`). Spread into a flat-config entry; relax for tests
35
- 7. Paste [AGENTS.guardrails-sync.md](../../skills/repo/setup-repo/assets/AGENTS.guardrails-sync.md) into consumer `AGENTS.md` (keep a real `AGENTS.md` if the product index must stay tracked)
33
+ 5. Ignore synced trees in the product linter / formatter / test runner: `.public-ai/**`, `skills/**`, `rules/**`, `AI-setup/**`, `scripts/lint/**`, `repo/guard/**`, `scripts/tests/**`
34
+ 6. JS/TS: import `cleanCodeRules` from `repo/setup-repo/assets/lint/eslint.clean-code.js` (exists after `npm ci`). Spread into a flat-config entry; relax for tests
35
+ 7. Paste [AGENTS.guardrails-sync.md](../../repo/setup-repo/assets/AGENTS.guardrails-sync.md) into consumer `AGENTS.md` (keep a real `AGENTS.md` if the product index must stay tracked)
36
36
 
37
37
  ### Defaults to omit or keep
38
38
 
@@ -42,7 +42,7 @@ skills/repo/setup-repo/assets/scripts/pre-push-gate.sh || exit $?
42
42
  | `.func-size` | `size: b` → function warn 20 / error 40 | Omit; keep profile `a` (40/80) or `c` (50/100) via env / own file |
43
43
  | `AGENTS.md`, vendor entry files | Whole-file link when the name is free | Omit when the consumer already has a real file |
44
44
  | `PRIVACY.md`, `scripts/check-privacy.sh` | Privacy grep for this public pack | Omit or leave unhooked on a private product repo |
45
- | `scripts/install-hooks.sh` | Privacy + language (Bash/JS only) + skill-catalog + size | Skip: Husky / `core.hooksPath` already set, or `PUBLIC_AI_SYNC_SKIP_HOOKS=1`. Language check fails on Python and other languages |
45
+ | `repo/install-hooks.sh` | Privacy + language (Bash/JS only) + skill-catalog + size | Skip: Husky / `core.hooksPath` already set, or `PUBLIC_AI_SYNC_SKIP_HOOKS=1`. Language check fails on Python and other languages |
46
46
 
47
47
  `scripts/`, the neutral dir, and each vendor config dir merge as real directories: each child is linked; a real child file stays. Other default paths link as a whole, or stay if a real file or directory already occupies the name.
48
48
 
@@ -51,7 +51,7 @@ skills/repo/setup-repo/assets/scripts/pre-push-gate.sh || exit $?
51
51
  - Real `AGENTS.md`, vendor entry files, `.claude/settings.json`, Husky: left in place
52
52
  - `.ai/rules` is linked next to a real `.ai`
53
53
  - `.claude` links to `.ai` only when the name is free. This pack ships `.claude/settings.json`, so `.claude` stays a real dir and gets no `rules` or `skills` link; the consumer's own `.claude/rules` link (from `setup-repo`) is untouched
54
- - Tracked `scripts/install-hooks.sh` that is not a pack link runs as-is (a no-op stub keeps Husky even on an empty `.husky` miss)
54
+ - Tracked `repo/install-hooks.sh` that is not a pack link runs as-is (a no-op stub keeps Husky even on an empty `.husky` miss)
55
55
  - Product skills stay in `.ai/skills/`; pack skills live at gitignored `skills/`
56
56
 
57
57
  ## What install does
@@ -59,7 +59,7 @@ skills/repo/setup-repo/assets/scripts/pre-push-gate.sh || exit $?
59
59
  1. Copy the default paths into the target folder (atomic replace: staging, then swap)
60
60
  2. Create relative symlinks at the consumer root so agent hooks (project-dir-relative commands) resolve. The neutral dir, vendor config dirs, and `scripts/` stay real directories; each child is linked. `AGENTS.md`, vendor entry files, `PRIVACY.md`, `rules`, `skills`, `AI-setup`, `.func-size`, and `.mr-size` link as a whole when those names are free. An existing non-link file is left in place
61
61
  3. Gitignore the target and every link this package created
62
- 4. Run `scripts/install-hooks.sh` when that script is present **and** the consumer has no `.husky/` directory and no `core.hooksPath`. A consumer that is not a git repo, or that already has a foreign hook plus a `.bak`, does not fail the install
62
+ 4. Run `repo/install-hooks.sh` when that script is present **and** the consumer has no `.husky/` directory and no `core.hooksPath`. A consumer that is not a git repo, or that already has a foreign hook plus a `.bak`, does not fail the install
63
63
  5. Add `public-ai:*` npm scripts when those names are free: `public-ai:sync` (manual re-run), `public-ai:lint-docs`, `public-ai:lint-explainer`, `public-ai:lint`, `public-ai:check-languages`, `public-ai:check-copies`, `public-ai:check-duplicates`, `public-ai:check-skill-catalog`, `public-ai:check-1k-cross`, `public-ai:verdict-parse`, `public-ai:code-quality`, `public-ai:privacy`, and `public-ai:install-hooks`. Consumer `postinstall` and `prepare` scripts are not added
64
64
 
65
65
  ## Vendors
@@ -3,6 +3,7 @@ import { join } from "node:path";
3
3
  import { spawnSync } from "node:child_process";
4
4
  import { SyncError } from "./errors.mjs";
5
5
  import { listFiles, rmIfExists } from "./fs-util.mjs";
6
+ import { projectMissingPath } from "./project.mjs";
6
7
 
7
8
  const CLONE_DEPTH = "1";
8
9
 
@@ -52,8 +53,12 @@ function copyListedPaths(spec) {
52
53
 
53
54
  function copyOnePath(spec) {
54
55
  const src = join(spec.from, spec.rel);
55
- if (!existsSync(src)) return;
56
- cpSync(src, join(spec.to, spec.rel), { recursive: true });
56
+ const dest = join(spec.to, spec.rel);
57
+ if (existsSync(src)) {
58
+ cpSync(src, dest, { recursive: true });
59
+ return;
60
+ }
61
+ projectMissingPath(spec.from, spec.to, spec.rel);
57
62
  }
58
63
 
59
64
  function assertNonEmpty(dir) {
@@ -0,0 +1,72 @@
1
+ import { cpSync, existsSync, mkdirSync, readdirSync } from "node:fs";
2
+ import { join } from "node:path";
3
+
4
+ const PACK_ROOT_SKIP = new Set([
5
+ "docs",
6
+ "site",
7
+ "packages",
8
+ "test-consumer",
9
+ "AI-setup",
10
+ "skills",
11
+ "rules",
12
+ "shared",
13
+ "scripts",
14
+ "adapters",
15
+ "node_modules",
16
+ ]);
17
+
18
+ const SKIP_DIRS = new Set(["node_modules", "assets", "references", "scripts", "experimental"]);
19
+ const SKILL_FILE = "SKILL.md";
20
+
21
+ export function projectMissingPath(from, to, rel) {
22
+ if (rel === "skills") projectSkills(from, join(to, "skills"));
23
+ else if (rel === "rules") projectRules(from, join(to, "rules"));
24
+ else if (rel === "AI-setup") copyIfExists(join(from, "repo", "ai-setup"), join(to, "AI-setup"));
25
+ else if (rel === "PRIVACY.md") copyIfExists(join(from, "repo", "PRIVACY.md"), join(to, "PRIVACY.md"));
26
+ }
27
+
28
+ function copyIfExists(src, dest) {
29
+ if (!existsSync(src)) return;
30
+ mkdirSync(join(dest, ".."), { recursive: true });
31
+ cpSync(src, dest, { recursive: true });
32
+ }
33
+
34
+ function projectSkills(from, dest) {
35
+ mkdirSync(dest, { recursive: true });
36
+ const found = new Map();
37
+ const walk = (dir) => {
38
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
39
+ if (!entry.isDirectory() || SKIP_DIRS.has(entry.name) || entry.name.startsWith(".")) continue;
40
+ const child = join(dir, entry.name);
41
+ if (existsSync(join(child, SKILL_FILE))) {
42
+ if (!found.has(entry.name)) found.set(entry.name, child);
43
+ } else walk(child);
44
+ }
45
+ };
46
+ for (const entry of readdirSync(from, { withFileTypes: true })) {
47
+ if (!entry.isDirectory() || entry.name.startsWith(".") || PACK_ROOT_SKIP.has(entry.name)) continue;
48
+ walk(join(from, entry.name));
49
+ }
50
+ for (const [name, skillDir] of found) cpSync(skillDir, join(dest, name), { recursive: true });
51
+ }
52
+
53
+ function projectRules(from, dest) {
54
+ const image = join(from, "repo", "setup-repo", "assets", "rules");
55
+ if (existsSync(image)) {
56
+ cpSync(image, dest, { recursive: true });
57
+ return;
58
+ }
59
+ const legacy = join(from, "skills", "repo", "setup-repo", "assets", "rules");
60
+ if (existsSync(legacy)) {
61
+ cpSync(legacy, dest, { recursive: true });
62
+ return;
63
+ }
64
+ mkdirSync(dest, { recursive: true });
65
+ const shared = join(from, "shared");
66
+ if (!existsSync(shared)) return;
67
+ for (const entry of readdirSync(shared, { withFileTypes: true })) {
68
+ const src = join(shared, entry.name);
69
+ if (entry.isFile() && entry.name.endsWith(".md")) cpSync(src, join(dest, entry.name));
70
+ if (entry.isDirectory()) cpSync(src, join(dest, entry.name), { recursive: true });
71
+ }
72
+ }
package/lib/run.mjs CHANGED
@@ -52,7 +52,7 @@ function fillThenSwap(cfg, work) {
52
52
  }
53
53
 
54
54
  function installGitHooks(cfg) {
55
- const script = join(cfg.root, "scripts", "install-hooks.sh");
55
+ const script = join(cfg.root, "repo", "install-hooks.sh");
56
56
  if (!existsSync(script)) return;
57
57
  const reason = skipHooksReason(cfg);
58
58
  if (reason) {
package/lib/tools.mjs CHANGED
@@ -7,19 +7,19 @@ const NPM_PREFIX = "public-ai:";
7
7
  const SYNC_BIN = "public-ai-sync";
8
8
 
9
9
  export const TOOLS = {
10
- "lint-docs": "scripts/lint/lint-docs.sh",
11
- "lint-explainer": "scripts/lint/lint-explainer.sh",
12
- lint: "scripts/lint/lint-clean-code.sh",
13
- "check-languages": "scripts/lint/check-languages.sh",
14
- "check-db-outcome": "scripts/lint/check-db-outcome.sh",
15
- "check-copies": "scripts/lint/check-copies.sh",
16
- "check-duplicates": "scripts/lint/check-duplicates.sh",
17
- "check-skill-catalog": "scripts/lint/check-skill-catalog.sh",
18
- "check-1k-cross": "scripts/lint/check-1k-cross.sh",
19
- "verdict-parse": "scripts/lint/verdict-parse.sh",
20
- "code-quality": "skills/repo/setup-repo/assets/scripts/code-quality-check.sh",
21
- privacy: "scripts/check-privacy.sh",
22
- "install-hooks": "scripts/install-hooks.sh",
10
+ "lint-docs": "shared/lint-docs.sh",
11
+ "lint-explainer": "understand/explain-code/lint-explainer.sh",
12
+ lint: "shared/lint-clean-code.sh",
13
+ "check-languages": "shared/check-languages.sh",
14
+ "check-db-outcome": "shared/check-db-outcome.sh",
15
+ "check-copies": "repo/setup-repo/scripts/check-copies.sh",
16
+ "check-duplicates": "shared/check-duplicates.sh",
17
+ "check-skill-catalog": "shared/check-skill-catalog.sh",
18
+ "check-1k-cross": "shared/check-1k-cross.sh",
19
+ "verdict-parse": "development/build/check-work/verdict-parse.sh",
20
+ "code-quality": "repo/setup-repo/assets/scripts/code-quality-check.sh",
21
+ privacy: "repo/check-privacy.sh",
22
+ "install-hooks": "repo/install-hooks.sh",
23
23
  };
24
24
 
25
25
  export function npmScripts() {
@@ -46,4 +46,4 @@ function exitStatus(result) {
46
46
  if (result.status === 0) return 0;
47
47
  if (result.status == null) return 1;
48
48
  return result.status;
49
- }
49
+ }
package/lib/vendors.mjs CHANGED
@@ -5,7 +5,7 @@ export const DEFAULT_VENDORS = [
5
5
  { name: "claude", entry: "CLAUDE.md", dir: ".claude", neutralLink: true, what: "Claude Code redirect and hooks" },
6
6
  { name: "gemini", entry: "GEMINI.md", what: "Gemini redirect" },
7
7
  ];
8
- const HEAD_PATHS = ["rules", "skills", "AI-setup", "AGENTS.md"];
8
+ const HEAD_PATHS = ["rules", "skills", "AI-setup", "AGENTS.md", "shared", "repo", "understand"];
9
9
  const TAIL_PATHS = [".func-size", ".mr-size", "scripts"];
10
10
 
11
11
  export function resolveVendors(extra) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "public-ai-sync",
3
- "version": "0.0.73",
3
+ "version": "0.0.74",
4
4
  "description": "Dev dependency that installs the public AI environment into a consuming repo on install",
5
5
  "type": "module",
6
6
  "license": "MIT",