aact 3.0.0-beta.3 → 3.0.0-beta.5

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.
@@ -209,7 +209,23 @@ const filterElements = (elements) => {
209
209
  const TAGS_MARKER = "__aact_tags__:";
210
210
  const LINK_MARKER = "__aact_link__:";
211
211
  const SPRITE_MARKER = "__aact_sprite__:";
212
- const preTransformNamedArgs = (raw) => raw.replaceAll(/, \$tags="(.+?)"/g, `, "${TAGS_MARKER}$1"`).replaceAll(/, \$link="(.+?)"/g, `, "${LINK_MARKER}$1"`).replaceAll(/, \$sprite="(.+?)"/g, `, "${SPRITE_MARKER}$1"`).replaceAll('""', '" "');
212
+ const INDEX_MARKER = "__aact_index__:";
213
+ const preTransformNamedArgs = (raw) => raw.replaceAll(/, \$tags="(.+?)"/g, `, "${TAGS_MARKER}$1"`).replaceAll(/, \$link="(.+?)"/g, `, "${LINK_MARKER}$1"`).replaceAll(/, \$sprite="(.+?)"/g, `, "${SPRITE_MARKER}$1"`).replaceAll(
214
+ /, \$index=(?:"([^"]+)"|([^,)\s]+))/g,
215
+ (_match, quoted, bare) => `, "${INDEX_MARKER}${quoted ?? bare ?? ""}"`
216
+ ).replaceAll('""', '" "');
217
+ const COMPONENT_BOUNDARY_ALIAS_RE = /\bComponent_Boundary\(\s*([A-Za-z0-9_.]+)/g;
218
+ const preTransform = (raw) => {
219
+ const componentBoundaryAliases = /* @__PURE__ */ new Set();
220
+ for (const match of raw.matchAll(COMPONENT_BOUNDARY_ALIAS_RE)) {
221
+ componentBoundaryAliases.add(match[1]);
222
+ }
223
+ const source = preTransformNamedArgs(raw).replaceAll(
224
+ /\bComponent_Boundary\(/g,
225
+ "Container_Boundary("
226
+ );
227
+ return { source, componentBoundaryAliases };
228
+ };
213
229
  const stripMarker = (value, marker) => value && value.startsWith(marker) ? value.slice(marker.length) : void 0;
214
230
  const extractMarked = (marker, ...slots) => {
215
231
  for (const slot of slots) {
@@ -234,7 +250,7 @@ const normalizeRelBack = (elements) => {
234
250
  }
235
251
  }
236
252
  };
237
- const ALL_MARKERS = [TAGS_MARKER, LINK_MARKER, SPRITE_MARKER];
253
+ const ALL_MARKERS = [TAGS_MARKER, LINK_MARKER, SPRITE_MARKER, INDEX_MARKER];
238
254
  const buildContainer = (el) => {
239
255
  const macroKind = parseC4MacroKind(el.type_.name);
240
256
  const kind = macroKind?.kind ?? "Container";
@@ -278,30 +294,18 @@ const buildContainer = (el) => {
278
294
  };
279
295
  };
280
296
  const buildRelation = (rel) => {
281
- const taggedValue = extractMarked(
282
- TAGS_MARKER,
283
- rel.techn,
284
- rel.descr,
285
- rel.sprite,
286
- rel.tags,
287
- rel.link
288
- );
289
- const linkValue = extractMarked(
290
- LINK_MARKER,
291
- rel.techn,
292
- rel.descr,
293
- rel.sprite,
294
- rel.tags,
295
- rel.link
296
- );
297
- const spriteNamedValue = extractMarked(
298
- SPRITE_MARKER,
297
+ const relSlots = [
299
298
  rel.techn,
300
299
  rel.descr,
301
300
  rel.sprite,
302
301
  rel.tags,
303
302
  rel.link
304
- );
303
+ ];
304
+ const taggedValue = extractMarked(TAGS_MARKER, ...relSlots);
305
+ const linkValue = extractMarked(LINK_MARKER, ...relSlots);
306
+ const spriteNamedValue = extractMarked(SPRITE_MARKER, ...relSlots);
307
+ const indexValue = extractMarked(INDEX_MARKER, ...relSlots);
308
+ const order = indexValue !== void 0 && Number.isFinite(Number(indexValue)) ? Number(indexValue) : void 0;
305
309
  return {
306
310
  to: rel.to,
307
311
  description: cleanSlot(rel.label, ...ALL_MARKERS) || void 0,
@@ -310,16 +314,18 @@ const buildRelation = (rel) => {
310
314
  cleanSlot(rel.descr, ...ALL_MARKERS) || cleanSlot(rel.tags, ...ALL_MARKERS)
311
315
  ) : parseCsvTags(taggedValue),
312
316
  sprite: spriteNamedValue ?? cleanSlot(rel.sprite, ...ALL_MARKERS),
313
- link: linkValue ?? cleanSlot(rel.link, ...ALL_MARKERS)
317
+ link: linkValue ?? cleanSlot(rel.link, ...ALL_MARKERS),
318
+ order
314
319
  };
315
320
  };
316
- const buildBoundary = (el, childContainers, childBoundaries) => {
321
+ const buildBoundary = (el, childContainers, childBoundaries, componentBoundaryAliases) => {
317
322
  const taggedValue = extractMarked(TAGS_MARKER, el.tags, el.link);
318
323
  const linkValue = extractMarked(LINK_MARKER, el.tags, el.link);
324
+ const kind = componentBoundaryAliases.has(el.alias) ? "Component" : parseBoundaryMacro(el.type_.name);
319
325
  return {
320
326
  name: el.alias,
321
327
  label: el.label,
322
- kind: parseBoundaryMacro(el.type_.name),
328
+ kind,
323
329
  tags: taggedValue === void 0 ? parseCsvTags(cleanSlot(el.tags, ...ALL_MARKERS)) : parseCsvTags(taggedValue),
324
330
  containerNames: childContainers,
325
331
  boundaryNames: childBoundaries,
@@ -371,7 +377,7 @@ const collectChildBoundaryNames = (boundaryElements) => {
371
377
  const load = async (filePath) => {
372
378
  const filepath = path.resolve(filePath);
373
379
  const raw = await fs.readFile(filepath, "utf8");
374
- const transformed = preTransformNamedArgs(raw);
380
+ const { source: transformed, componentBoundaryAliases } = preTransform(raw);
375
381
  const [{ elements: rawElements }] = parse(transformed);
376
382
  const elements = filterElements(rawElements);
377
383
  normalizeRelBack(elements);
@@ -388,7 +394,12 @@ const load = async (filePath) => {
388
394
  const childOfBoundary = collectChildBoundaryNames(boundaryElements);
389
395
  const boundaries = boundaryElements.map((b) => {
390
396
  const { containers, boundaries: childBoundaries } = collectBoundaryChildren(b);
391
- return buildBoundary(b, containers, childBoundaries);
397
+ return buildBoundary(
398
+ b,
399
+ containers,
400
+ childBoundaries,
401
+ componentBoundaryAliases
402
+ );
392
403
  });
393
404
  const rootBoundaryNames = boundaries.map((b) => b.name).filter((name) => !childOfBoundary.has(name));
394
405
  return buildModel({
@@ -7,8 +7,10 @@ import path, { basename } from 'pathe';
7
7
  import * as v from 'valibot';
8
8
  import fs, { readFile, writeFile } from 'node:fs/promises';
9
9
  import { colors, box } from 'consola/utils';
10
+ import { execFile } from 'node:child_process';
11
+ import os from 'node:os';
10
12
 
11
- const version = "3.0.0-beta.3";
13
+ const version = "3.0.0-beta.5";
12
14
 
13
15
  const matchesPattern = (filePath, pattern) => {
14
16
  if (pattern.startsWith("*")) {
@@ -708,12 +710,304 @@ const rule = defineCommand({
708
710
  subCommands: { list: listAction }
709
711
  });
710
712
 
713
+ const skillName = "aact-architect";
714
+ const markerFileName = ".aact-skill.json";
715
+ const defaultRepo = "https://github.com/ChS23/aact-architect-skill.git";
716
+ const defaultRef = "main";
717
+ const clientValues = [
718
+ "shared",
719
+ "codex",
720
+ "cursor",
721
+ "copilot",
722
+ "claude",
723
+ "cline",
724
+ "all"
725
+ ];
726
+ const targetLabels = {
727
+ shared: "Agent Skills",
728
+ claude: "Claude Code",
729
+ cline: "Cline"
730
+ };
731
+ const defaultRoots = {
732
+ shared: "~/.agents/skills",
733
+ claude: "~/.claude/skills",
734
+ cline: "~/.cline/skills"
735
+ };
736
+ const sharedClientValues = /* @__PURE__ */ new Set([
737
+ "shared",
738
+ "codex",
739
+ "cursor",
740
+ "copilot"
741
+ ]);
742
+ const defaultRuntime = {
743
+ git: (args, options) => new Promise((resolve, reject) => {
744
+ execFile(
745
+ // eslint-disable-next-line sonarjs/no-os-command-from-path -- This CLI intentionally invokes the user's git binary to clone/update the skill repository.
746
+ "git",
747
+ [...args],
748
+ { cwd: options?.cwd },
749
+ (error, _stdout, stderr) => {
750
+ if (error) {
751
+ const reason = stderr.trim() || error.message;
752
+ reject(new Error(`git ${args.join(" ")} failed: ${reason}`));
753
+ return;
754
+ }
755
+ resolve();
756
+ }
757
+ );
758
+ }),
759
+ now: () => /* @__PURE__ */ new Date()
760
+ };
761
+ const isClientValue = (value) => clientValues.includes(value);
762
+ const expandHome = (input) => {
763
+ if (input === "~") return os.homedir();
764
+ if (input.startsWith("~/")) return path.join(os.homedir(), input.slice(2));
765
+ return input;
766
+ };
767
+ const resolveRootDir = (rootOrSkillDir) => {
768
+ const resolved = path.resolve(expandHome(rootOrSkillDir));
769
+ return path.basename(resolved) === skillName ? path.dirname(resolved) : resolved;
770
+ };
771
+ const toSkillDir = (rootDir) => path.join(rootDir, skillName);
772
+ const normalizeKind = (client) => {
773
+ if (client === "all") return ["shared", "claude", "cline"];
774
+ if (sharedClientValues.has(client)) return ["shared"];
775
+ if (client === "claude" || client === "cline") return [client];
776
+ return ["shared"];
777
+ };
778
+ const selectedKinds = (args) => {
779
+ const out = /* @__PURE__ */ new Set();
780
+ if (args.all) {
781
+ for (const kind of normalizeKind("all")) out.add(kind);
782
+ }
783
+ if (args.client) {
784
+ if (!isClientValue(args.client)) {
785
+ throw new Error(
786
+ `Unknown skill client "${args.client}". Expected one of: ${clientValues.join(", ")}.`
787
+ );
788
+ }
789
+ for (const kind of normalizeKind(args.client)) out.add(kind);
790
+ }
791
+ if (args.codex) out.add("shared");
792
+ if (args.cursor) out.add("shared");
793
+ if (args.copilot) out.add("shared");
794
+ if (args.claude) out.add("claude");
795
+ if (args.cline) out.add("cline");
796
+ if (out.size === 0) out.add("shared");
797
+ return [...out];
798
+ };
799
+ const createInstallPlans = (args) => {
800
+ const kinds = selectedKinds(args);
801
+ if (args.target && kinds.length > 1) {
802
+ throw new Error(
803
+ "--target can be used with a single client target only. Remove --all or install clients one by one."
804
+ );
805
+ }
806
+ return kinds.map((kind) => {
807
+ const rootDir = resolveRootDir(args.target ?? defaultRoots[kind]);
808
+ return {
809
+ kind,
810
+ label: targetLabels[kind],
811
+ rootDir,
812
+ skillDir: toSkillDir(rootDir)
813
+ };
814
+ });
815
+ };
816
+ const pathExists = async (target) => {
817
+ try {
818
+ await fs.access(target);
819
+ return true;
820
+ } catch {
821
+ return false;
822
+ }
823
+ };
824
+ const readMarker = async (skillDir) => {
825
+ try {
826
+ const content = await fs.readFile(
827
+ path.join(skillDir, markerFileName),
828
+ "utf8"
829
+ );
830
+ const parsed = JSON.parse(content);
831
+ if (parsed.managedBy === "aact" && parsed.skill === skillName) {
832
+ return parsed;
833
+ }
834
+ } catch {
835
+ }
836
+ return null;
837
+ };
838
+ const writeMarker = async (plan, repo, ref, runtime) => {
839
+ const marker = {
840
+ managedBy: "aact",
841
+ skill: skillName,
842
+ client: plan.kind,
843
+ repo,
844
+ ref,
845
+ aactVersion: version,
846
+ installedAt: runtime.now().toISOString()
847
+ };
848
+ await fs.writeFile(
849
+ path.join(plan.skillDir, markerFileName),
850
+ JSON.stringify(marker, void 0, 2) + "\n"
851
+ );
852
+ };
853
+ const ensureSkillFile = async (skillDir) => {
854
+ const skillFile = path.join(skillDir, "SKILL.md");
855
+ if (!await pathExists(skillFile)) {
856
+ throw new Error(
857
+ `Installed repository does not contain ${skillName}/SKILL.md at ${skillFile}.`
858
+ );
859
+ }
860
+ };
861
+ const cloneSkill = async (plan, repo, ref, runtime) => {
862
+ await fs.mkdir(plan.rootDir, { recursive: true });
863
+ await runtime.git([
864
+ "clone",
865
+ "--depth",
866
+ "1",
867
+ "--branch",
868
+ ref,
869
+ repo,
870
+ plan.skillDir
871
+ ]);
872
+ await ensureSkillFile(plan.skillDir);
873
+ };
874
+ const updateSkill = async (plan, repo, ref, runtime) => {
875
+ const marker = await readMarker(plan.skillDir);
876
+ if (!marker) {
877
+ throw new Error(
878
+ `${plan.skillDir} already exists and is not managed by aact. Use --force to overwrite it.`
879
+ );
880
+ }
881
+ if (marker.repo !== repo) {
882
+ throw new Error(
883
+ `${plan.skillDir} is managed by aact but was installed from ${marker.repo}. Use --force to reinstall from ${repo}.`
884
+ );
885
+ }
886
+ if (!await pathExists(path.join(plan.skillDir, ".git"))) {
887
+ throw new Error(
888
+ `${plan.skillDir} is managed by aact but is not a git checkout. Use --force to reinstall it.`
889
+ );
890
+ }
891
+ await runtime.git(["fetch", "--depth", "1", "origin", ref], {
892
+ cwd: plan.skillDir
893
+ });
894
+ await runtime.git(["checkout", "--force", "FETCH_HEAD"], {
895
+ cwd: plan.skillDir
896
+ });
897
+ await ensureSkillFile(plan.skillDir);
898
+ };
899
+ const installOne = async (plan, args, runtime) => {
900
+ const repo = args.repo ?? defaultRepo;
901
+ const ref = args.ref ?? defaultRef;
902
+ const dryRun = args["dry-run"] ?? false;
903
+ const force = args.force ?? false;
904
+ const exists = await pathExists(plan.skillDir);
905
+ const action = exists ? "update" : "install";
906
+ if (dryRun) {
907
+ consola.info(
908
+ `[dry run] ${force && exists ? "reinstall" : action} ${skillName} for ${plan.label}: ${plan.skillDir}`
909
+ );
910
+ return;
911
+ }
912
+ if (exists && force) {
913
+ await fs.rm(plan.skillDir, { recursive: true, force: true });
914
+ }
915
+ if (exists && !force) {
916
+ await updateSkill(plan, repo, ref, runtime);
917
+ await writeMarker(plan, repo, ref, runtime);
918
+ consola.success(`Updated ${skillName} for ${plan.label}: ${plan.skillDir}`);
919
+ return;
920
+ }
921
+ await cloneSkill(plan, repo, ref, runtime);
922
+ await writeMarker(plan, repo, ref, runtime);
923
+ consola.success(`Installed ${skillName} for ${plan.label}: ${plan.skillDir}`);
924
+ };
925
+ const installAgentSkill = async (args, runtime = defaultRuntime) => {
926
+ const repo = args.repo ?? defaultRepo;
927
+ const ref = args.ref ?? defaultRef;
928
+ const plans = createInstallPlans(args);
929
+ consola.info(`Installing community ${skillName} skill from ${repo} (${ref})`);
930
+ for (const plan of plans) {
931
+ await installOne(plan, args, runtime);
932
+ }
933
+ };
934
+ const installArgs = {
935
+ client: {
936
+ type: "enum",
937
+ description: "Client target: shared, codex, cursor, copilot, claude, cline, all",
938
+ options: [...clientValues]
939
+ },
940
+ codex: {
941
+ type: "boolean",
942
+ description: "Install into the shared ~/.agents/skills path used by Codex"
943
+ },
944
+ cursor: {
945
+ type: "boolean",
946
+ description: "Install into the shared ~/.agents/skills path used by Cursor"
947
+ },
948
+ copilot: {
949
+ type: "boolean",
950
+ description: "Install into the shared ~/.agents/skills path used by GitHub Copilot"
951
+ },
952
+ claude: {
953
+ type: "boolean",
954
+ description: "Install into ~/.claude/skills for Claude Code"
955
+ },
956
+ cline: {
957
+ type: "boolean",
958
+ description: "Install into ~/.cline/skills for Cline"
959
+ },
960
+ all: {
961
+ type: "boolean",
962
+ description: "Install shared, Claude Code, and Cline targets"
963
+ },
964
+ target: {
965
+ type: "string",
966
+ description: "Custom skills root or full skill directory"
967
+ },
968
+ repo: {
969
+ type: "string",
970
+ description: "Skill repository URL",
971
+ default: defaultRepo
972
+ },
973
+ ref: {
974
+ type: "string",
975
+ description: "Git branch or tag to install",
976
+ default: defaultRef
977
+ },
978
+ force: {
979
+ type: "boolean",
980
+ description: "Overwrite an existing unmanaged skill directory"
981
+ },
982
+ "dry-run": {
983
+ type: "boolean",
984
+ description: "Show target directories without writing files"
985
+ }
986
+ };
987
+ const install = defineCommand({
988
+ meta: {
989
+ description: "Install the community aact-architect skill for AI agents"
990
+ },
991
+ args: installArgs,
992
+ async run({ args }) {
993
+ await installAgentSkill(args);
994
+ }
995
+ });
996
+ const skill = defineCommand({
997
+ meta: {
998
+ description: "Install agent skills for aact workflows"
999
+ },
1000
+ args: installArgs,
1001
+ default: "install",
1002
+ subCommands: { install }
1003
+ });
1004
+
711
1005
  const main = defineCommand({
712
1006
  meta: {
713
1007
  name: "aact",
714
1008
  version,
715
1009
  description: "Architecture analysis and compliance tool"
716
1010
  },
717
- subCommands: { init, check, analyze, generate, rule }
1011
+ subCommands: { init, check, analyze, generate, rule, skill }
718
1012
  });
719
1013
  void runMain(main);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aact",
3
- "version": "3.0.0-beta.3",
3
+ "version": "3.0.0-beta.5",
4
4
  "type": "module",
5
5
  "description": "Architecture analysis and compliance tool",
6
6
  "keywords": [