ai-engineering-kit 0.5.0 → 0.6.0

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
@@ -9,7 +9,7 @@
9
9
  - **Skills** — Markdown playbooks, grouped into categories you pick at install time:
10
10
  - **core-workflow** — brainstorm → foundations → PRD → plan → implement → review → verify.
11
11
  - **engineering**, **productivity**, **misc** — additional day-to-day skills forked from [`mattpocock/skills`](https://github.com/mattpocock/skills) (see attribution below).
12
- - **A structured workspace** — `ai/` for ephemeral artifacts (brainstorms, PRDs, plans, reviews) and `docs/foundations/` for canonical, long-lived project knowledge.
12
+ - **A structured workspace** — `ai/` for ephemeral artifacts (brainstorms, PRDs, plans, reviews) and `docs/` for durable knowledge: `foundations/` (vision, guidelines, decisions) plus `system/`, `references/`, `operations/`, and `debt/`.
13
13
  - **Agent-agnostic wiring** — skills live as portable Markdown in `ai/skills/`; the kit generates the entry file each agent reads (`CLAUDE.md` + a `.claude/skills/` symlink for Claude Code, `AGENTS.md` for Codex). More agents are a template + a manifest entry away.
14
14
 
15
15
  ## Quickstart
package/dist/cli.js CHANGED
@@ -54,10 +54,10 @@ var CATEGORIES = [
54
54
  var TREE_COMPONENTS = [
55
55
  {
56
56
  id: "docs-foundations",
57
- label: "Foundation docs",
58
- hint: "Starter docs for product vision, guidelines, and technical decisions (docs/foundations/)",
59
- from: "docs/foundations",
60
- to: "docs/foundations"
57
+ label: "Project docs",
58
+ hint: "docs/ scaffold: foundations stubs + system, references, operations, debt",
59
+ from: "docs",
60
+ to: "docs"
61
61
  },
62
62
  {
63
63
  id: "ai-workspace",
@@ -211,7 +211,7 @@ function planUntracked(_file, onDisk) {
211
211
  }
212
212
 
213
213
  // src/io/project.ts
214
- import { existsSync, readFileSync as readFileSync2 } from "fs";
214
+ import { existsSync, readFileSync as readFileSync2, writeFileSync } from "fs";
215
215
  import { join as join2 } from "path";
216
216
  var MANIFEST_FILE = ".ai-kit.json";
217
217
  function readManifest(projectDir) {
@@ -219,6 +219,9 @@ function readManifest(projectDir) {
219
219
  if (!existsSync(path)) return null;
220
220
  return parseManifest(readFileSync2(path, "utf8"));
221
221
  }
222
+ function writeManifest(projectDir, manifest) {
223
+ writeFileSync(join2(projectDir, MANIFEST_FILE), serializeManifest(manifest));
224
+ }
222
225
  function readOnDiskHashes(projectDir, files) {
223
226
  const hashes = /* @__PURE__ */ new Map();
224
227
  for (const file of files) {
@@ -229,11 +232,11 @@ function readOnDiskHashes(projectDir, files) {
229
232
  }
230
233
 
231
234
  // src/applier/applier.ts
232
- import { writeFileSync as writeFileSync2 } from "fs";
235
+ import { writeFileSync as writeFileSync3 } from "fs";
233
236
  import { join as join4 } from "path";
234
237
 
235
238
  // src/applier/write.ts
236
- import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
239
+ import { mkdirSync, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
237
240
  import { dirname, join as join3 } from "path";
238
241
  function writeTemplateFile(projectDir, templateDir, file, projectName, suffix = "") {
239
242
  const raw = readFileSync3(join3(templateDir, file.templatePath), "utf8");
@@ -241,7 +244,7 @@ function writeTemplateFile(projectDir, templateDir, file, projectName, suffix =
241
244
  const targetPath = file.targetPath + suffix;
242
245
  const dest = join3(projectDir, targetPath);
243
246
  mkdirSync(dirname(dest), { recursive: true });
244
- writeFileSync(dest, content);
247
+ writeFileSync2(dest, content);
245
248
  return targetPath;
246
249
  }
247
250
 
@@ -280,7 +283,7 @@ function applyPlan(input) {
280
283
  categories: input.selection.categories,
281
284
  files: entries
282
285
  };
283
- writeFileSync2(join4(input.projectDir, MANIFEST_FILE), serializeManifest(manifest));
286
+ writeFileSync3(join4(input.projectDir, MANIFEST_FILE), serializeManifest(manifest));
284
287
  return { written, manifest };
285
288
  }
286
289
 
@@ -426,10 +429,6 @@ async function promptForSelection(projectDir) {
426
429
  return { selection, projectName };
427
430
  }
428
431
 
429
- // src/applier/update.ts
430
- import { writeFileSync as writeFileSync3 } from "fs";
431
- import { join as join7 } from "path";
432
-
433
432
  // src/applier/resolve.ts
434
433
  function conflictOps(choice) {
435
434
  switch (choice) {
@@ -506,6 +505,10 @@ function applyUpdate(input) {
506
505
  entries.push(prior);
507
506
  }
508
507
  }
508
+ const covered = new Set(input.files.map((f) => f.targetPath));
509
+ for (const prior of input.priorManifest.files) {
510
+ if (!covered.has(prior.path)) entries.push(prior);
511
+ }
509
512
  const manifest = {
510
513
  version: input.version,
511
514
  agents: input.selection.agents,
@@ -513,10 +516,45 @@ function applyUpdate(input) {
513
516
  categories: input.selection.categories,
514
517
  files: entries
515
518
  };
516
- writeFileSync3(join7(input.projectDir, MANIFEST_FILE), serializeManifest(manifest));
519
+ writeManifest(input.projectDir, manifest);
517
520
  return { written, manifest };
518
521
  }
519
522
 
523
+ // src/applier/prune.ts
524
+ import { existsSync as existsSync3, readFileSync as readFileSync5, rmSync, readdirSync as readdirSync2, rmdirSync } from "fs";
525
+ import { dirname as dirname3, join as join7 } from "path";
526
+ function findOrphans(manifest, catalog) {
527
+ const inCatalog = new Set(catalog.files.map((f) => f.targetPath));
528
+ return manifest.files.filter((f) => f.status === "managed" && !inCatalog.has(f.path));
529
+ }
530
+ function pruneOrphans(projectDir, orphans) {
531
+ const result = { deleted: [], keptEdited: [] };
532
+ for (const orphan of orphans) {
533
+ const path = join7(projectDir, orphan.path);
534
+ if (!existsSync3(path)) continue;
535
+ if (hashContent(readFileSync5(path, "utf8")) !== orphan.hash) {
536
+ result.keptEdited.push(orphan.path);
537
+ continue;
538
+ }
539
+ rmSync(path);
540
+ removeEmptyDirs(projectDir, dirname3(path));
541
+ result.deleted.push(orphan.path);
542
+ }
543
+ const resolved = new Set(orphans.map((o) => o.path));
544
+ const manifest = readManifest(projectDir);
545
+ if (manifest) {
546
+ writeManifest(projectDir, { ...manifest, files: manifest.files.filter((f) => !resolved.has(f.path)) });
547
+ }
548
+ return result;
549
+ }
550
+ function removeEmptyDirs(root, dir) {
551
+ let current = dir;
552
+ while (current !== root && existsSync3(current) && readdirSync2(current).length === 0) {
553
+ rmdirSync(current);
554
+ current = dirname3(current);
555
+ }
556
+ }
557
+
520
558
  // src/cli.ts
521
559
  var EMPTY_SELECTION = { components: [], categories: [], agents: [] };
522
560
  function fullSelection() {
@@ -657,31 +695,34 @@ async function runReRun(projectDir) {
657
695
  const applicable = {
658
696
  actions: prepared.plan.actions.filter((a) => prepared.applyTypes.has(a.type))
659
697
  };
698
+ const orphans = findOrphans(manifest, prepared.catalog);
660
699
  const pending = applicable.actions.filter((a) => a.type !== "skip").length;
661
- if (pending === 0) {
700
+ if (pending === 0 && orphans.length === 0) {
662
701
  outro("Already up to date \u2014 nothing to do.");
663
702
  return;
664
703
  }
665
- note(formatSummary(summarize(prepared.files, applicable)), mode === "add" ? "This will add" : "This will update");
666
704
  const resolutions = /* @__PURE__ */ new Map();
667
- const conflicts = applicable.actions.filter((a) => a.type === "conflict");
668
- for (const [index, action] of conflicts.entries()) {
669
- const choice = bail(
670
- await select2({
671
- message: `Conflict ${index + 1}/${conflicts.length}: you edited ${action.path}, and a newer version exists.`,
672
- options: [
673
- { value: "keep-mine", label: "Keep mine", hint: "discard the update for this file" },
674
- { value: "overwrite", label: "Use the new version", hint: "replace your file" },
675
- { value: "keep-theirs", label: "Keep mine + save theirs", hint: `writes ${basename3(action.path)}.new` }
676
- ]
677
- })
678
- );
679
- resolutions.set(action.path, choice);
680
- }
681
- const proceed = await confirm({ message: `Apply ${pending} changes in ${projectDir}?` });
682
- if (isCancel2(proceed) || !proceed) {
683
- outro("Nothing written.");
684
- return;
705
+ if (pending > 0) {
706
+ note(formatSummary(summarize(prepared.files, applicable)), mode === "add" ? "This will add" : "This will update");
707
+ const conflicts = applicable.actions.filter((a) => a.type === "conflict");
708
+ for (const [index, action] of conflicts.entries()) {
709
+ const choice = bail(
710
+ await select2({
711
+ message: `Conflict ${index + 1}/${conflicts.length}: you edited ${action.path}, and a newer version exists.`,
712
+ options: [
713
+ { value: "keep-mine", label: "Keep mine", hint: "discard the update for this file" },
714
+ { value: "overwrite", label: "Use the new version", hint: "replace your file" },
715
+ { value: "keep-theirs", label: "Keep mine + save theirs", hint: `writes ${basename3(action.path)}.new` }
716
+ ]
717
+ })
718
+ );
719
+ resolutions.set(action.path, choice);
720
+ }
721
+ const proceed = await confirm({ message: `Apply ${pending} changes in ${projectDir}?` });
722
+ if (isCancel2(proceed) || !proceed) {
723
+ outro("Nothing written.");
724
+ return;
725
+ }
685
726
  }
686
727
  const result = applyUpdate({
687
728
  projectDir,
@@ -695,6 +736,16 @@ async function runReRun(projectDir) {
695
736
  projectName,
696
737
  applyTypes: prepared.applyTypes
697
738
  });
739
+ if (orphans.length > 0) {
740
+ note(orphans.map((o) => ` ${o.path}`).join("\n"), `${orphans.length} file(s) no longer in the kit`);
741
+ const doPrune = await confirm({ message: `Delete ${orphans.length} removed file(s) from disk?` });
742
+ if (!isCancel2(doPrune) && doPrune) {
743
+ const pruned = pruneOrphans(projectDir, orphans);
744
+ if (pruned.keptEdited.length > 0) {
745
+ note(pruned.keptEdited.map((p) => ` ${p}`).join("\n"), "Kept \u2014 you edited these");
746
+ }
747
+ }
748
+ }
698
749
  successOutro(mode === "add" ? "Added" : "Updated", result.written.length, prepared.selection);
699
750
  }
700
751
  async function runInteractive() {
@@ -717,7 +768,7 @@ async function runInteractive() {
717
768
  if (!reportConflict(error)) throw error;
718
769
  }
719
770
  }
720
- function performReRun(projectDir, mode, addParts) {
771
+ function performReRun(projectDir, mode, addParts, prune) {
721
772
  const manifest = readManifest(projectDir);
722
773
  if (!manifest) {
723
774
  console.error("Not an ai-engineering-kit project (no .ai-kit.json). Run `ai-engineering-kit init` first.");
@@ -725,6 +776,7 @@ function performReRun(projectDir, mode, addParts) {
725
776
  return;
726
777
  }
727
778
  const prepared = prepareReRun({ projectDir, manifest, mode, addParts });
779
+ const orphans = findOrphans(manifest, prepared.catalog);
728
780
  const result = applyUpdate({
729
781
  projectDir,
730
782
  templateDir: prepared.templateDir,
@@ -739,9 +791,22 @@ function performReRun(projectDir, mode, addParts) {
739
791
  applyTypes: prepared.applyTypes
740
792
  });
741
793
  console.log(`${result.written.length} files written. Edited files were kept (use the interactive flow to resolve).`);
794
+ if (orphans.length === 0) return;
795
+ if (prune) {
796
+ const pruned = pruneOrphans(projectDir, orphans);
797
+ console.log(`Pruned ${pruned.deleted.length} file(s) no longer in the kit.`);
798
+ if (pruned.keptEdited.length > 0) {
799
+ console.log(`Kept ${pruned.keptEdited.length} you edited: ${pruned.keptEdited.join(", ")}`);
800
+ }
801
+ } else {
802
+ console.log(`
803
+ ${orphans.length} file(s) are no longer in the kit:`);
804
+ for (const o of orphans) console.log(` ${o.path}`);
805
+ console.log("Run again with --prune to remove them.");
806
+ }
742
807
  }
743
- function update() {
744
- performReRun(process.cwd(), "update", EMPTY_SELECTION);
808
+ function update(args) {
809
+ performReRun(process.cwd(), "update", EMPTY_SELECTION, args.includes("--prune"));
745
810
  }
746
811
  function add(args) {
747
812
  const addParts = {
@@ -749,20 +814,20 @@ function add(args) {
749
814
  categories: parseList(args, "--categories") ?? [],
750
815
  agents: parseList(args, "--agents") ?? []
751
816
  };
752
- performReRun(process.cwd(), "add", addParts);
817
+ performReRun(process.cwd(), "add", addParts, false);
753
818
  }
754
819
  async function main(argv) {
755
820
  const args = argv.slice(2);
756
821
  if (args.includes("--dry-run")) return dryRun(args);
757
822
  if (args[0] === "init") return init(args.slice(1));
758
- if (args[0] === "update") return update();
823
+ if (args[0] === "update") return update(args.slice(1));
759
824
  if (args[0] === "add") return add(args.slice(1));
760
825
  if (args.length === 0) return runInteractive();
761
826
  console.log("ai-engineering-kit");
762
827
  console.log("\nUsage:");
763
828
  console.log(" ai-engineering-kit # interactive install or update");
764
829
  console.log(" ai-engineering-kit init [--name <project>] [--all | --components a,b --categories x --agents y]");
765
- console.log(" ai-engineering-kit update # refresh installed parts to latest (keeps your edits)");
830
+ console.log(" ai-engineering-kit update [--prune] # refresh to latest; --prune removes skills dropped from the kit");
766
831
  console.log(" ai-engineering-kit add --components a,b [--categories x] [--agents y]");
767
832
  console.log(" ai-engineering-kit --dry-run [--all | --components a,b --categories x --agents y]");
768
833
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-engineering-kit",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "An opinionated, agent-agnostic AI-development kit — disciplined skills plus a structured workspace — installed and updated through one npx command.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -0,0 +1,5 @@
1
+ # Debt
2
+
3
+ Structured registries of deferred or known work — shortcuts taken, follow-ups owed, known limitations.
4
+
5
+ Starts empty. Record debt here so it's visible and trackable rather than lost in scattered code comments. Note what was deferred, why, and what would need to change to pay it down.
@@ -0,0 +1,5 @@
1
+ # Operations
2
+
3
+ Runbooks — what a human should do when something needs manual action: incidents, migrations, recovery, routine maintenance.
4
+
5
+ Starts empty. Add a runbook per procedure, written as numbered steps someone can follow under pressure without re-deriving the process.
@@ -0,0 +1,5 @@
1
+ # References
2
+
3
+ How external systems we integrate with work — vendor APIs, protocols, third-party quirks and gotchas.
4
+
5
+ Starts empty. Add a document per external system as you integrate it, capturing the parts that aren't obvious from the vendor's own docs (auth flows, rate limits, edge cases you hit).
@@ -0,0 +1,5 @@
1
+ # System
2
+
3
+ How our own code works — per-flow specs, event/contract conventions, sequence notes.
4
+
5
+ Starts empty. Promote knowledge here as it stabilises: one document per flow or subsystem, so the next agent (or person) can understand a piece of the system without re-reading all the code.