@dreamlake/dreamlake-cli 0.92.0 → 0.94.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.
@@ -11,6 +11,15 @@ import { collectionList } from "../collection-list.js";
11
11
  // `<skill>/.dreamlake-skill.json` so `update` and `remove` never have to
12
12
  // guess which files are theirs. Manual install is unpacking the same tarball.
13
13
  //
14
+ // ONE AGENT OR SEVERAL. `--agent` (and what `init` saved) may name both
15
+ // agents — `all` or `claude,codex`. Each agent's copy is a separate install
16
+ // with its own manifest; a multi-agent run plans and applies them one by one
17
+ // from one catalog and one download. With exactly one agent every result is
18
+ // the single-agent shape, unchanged: `remindAfterInstall` reads it across CLI
19
+ // versions. Several agents add `agents` (and drop the top-level `agent`), tag
20
+ // each skill result with its `agent`, and give `remove` and `list` their own
21
+ // per-agent shapes (`removals`, `installs`).
22
+ //
14
23
  // THREE THINGS THIS MUST NEVER DO, each from a real hazard in this tree:
15
24
  //
16
25
  // 0. Every write, unlink, mkdir and rmdir goes through the owned-path
@@ -47,8 +56,8 @@ import path from "node:path";
47
56
  import { emitJson, fail, ok, warn } from "../helpers.js";
48
57
  import { EMBEDDED_SKILL, ReleaseError, SKILLS_ENV, catalogFileCount, catalogUrl, compareVersions, embeddedCatalog, embeddedPayload, embeddedVersion, extractSkills, fetchLatestCatalog, fetchSkillsTarball, fmtVersion, listBundledSkills, manualDownloadUrl, resolveBundleDir, bundledFiles, versionsEqual, } from "./catalog.js";
49
58
  import { hashFile, hasSymlinkAncestor, isDirectChild, kindOf, listDir, pinOwnedDir, pruneEmptyDirs, resolveExisting, sha256, unlinkOwnedFile, writeOwnedFile, } from "./files.js";
50
- import { MANIFEST_FILE, isAgent, readManifest, writeManifest, } from "./manifest.js";
51
- import { readSkillPreferences, writeSkillPreferences } from "./prefs.js";
59
+ import { AGENTS, MANIFEST_FILE, parseAgents, readManifest, writeManifest, } from "./manifest.js";
60
+ import { preferredAgents, readSkillPreferences, skillPreferences, writeSkillPreferences, } from "./prefs.js";
52
61
  export { listBundledSkills, resolveBundleDir } from "./catalog.js";
53
62
  // ─── names ───────────────────────────────────────────────────────────────────
54
63
  //
@@ -106,11 +115,31 @@ export function skillTarget(scopeRoot, name, agent = "claude") {
106
115
  export function ownedTarget(dir, name) {
107
116
  return pinOwnedDir(targetIn(dir, name));
108
117
  }
118
+ // ─── selection: agent and scope ──────────────────────────────────────────────
119
+ //
120
+ // Flags win; otherwise what `dreamlake init` saved; otherwise claude/project
121
+ // with a one-line hint. `--dir` beats `--project` beats `--global`.
122
+ export const AGENT_ERROR = "--agent must be claude, codex, all, or a comma-separated list of them";
123
+ function isMulti(sel) {
124
+ return sel.targets.length > 1;
125
+ }
126
+ /** `agent` for one agent, `agents` for several: the only difference at the top of a result. */
127
+ function agentFields(sel) {
128
+ return isMulti(sel) ? { agents: sel.agents } : { agent: sel.agents[0] };
129
+ }
130
+ function agentsLabel(sel) {
131
+ return [isMulti(sel) ? "agents" : "agent", `${sel.agents.join(", ")}${sel.saved ? " (saved)" : ""}`];
132
+ }
133
+ /** The options of a multi-agent run, narrowed to one agent for a command that concerns only its copy. */
134
+ function forAgent(opts, agent) {
135
+ return { ...opts, agent };
136
+ }
109
137
  function selectTarget(opts) {
110
- if (opts.agent !== undefined && !isAgent(opts.agent))
111
- return { error: "--agent must be claude or codex" };
138
+ const flagged = opts.agent !== undefined ? parseAgents(opts.agent) : null;
139
+ if (opts.agent !== undefined && !flagged)
140
+ return { error: AGENT_ERROR };
112
141
  const prefs = readSkillPreferences();
113
- const agent = isAgent(opts.agent) ? opts.agent : prefs?.agent ?? "claude";
142
+ const agents = flagged ?? (prefs ? preferredAgents(prefs) : ["claude"]);
114
143
  const o = opts;
115
144
  let scope;
116
145
  let root;
@@ -131,7 +160,8 @@ function selectTarget(opts) {
131
160
  root = process.cwd();
132
161
  }
133
162
  return {
134
- agent, scope, root, dir: skillsDir(root, agent),
163
+ agents, scope, root,
164
+ targets: agents.map((agent) => ({ agent, dir: skillsDir(root, agent) })),
135
165
  saved: prefs !== null && opts.agent === undefined,
136
166
  hint: prefs === null && opts.agent === undefined,
137
167
  };
@@ -139,7 +169,7 @@ function selectTarget(opts) {
139
169
  function printHint(sel, opts) {
140
170
  if (!sel.hint || opts.json)
141
171
  return;
142
- process.stderr.write(` hint: no saved agent — using ${sel.agent}, ${sel.scope}; run 'dreamlake init' once to remember your choice\n`);
172
+ process.stderr.write(` hint: no saved agent — using ${sel.agents.join(", ")}, ${sel.scope}; run 'dreamlake init' once to remember your choice\n`);
143
173
  }
144
174
  // ─── prose ───────────────────────────────────────────────────────────────────
145
175
  //
@@ -176,6 +206,24 @@ export function skillCommand(verb, names, opts, force, allowDowngrade = false) {
176
206
  export function installCommand(skill, opts, force) {
177
207
  return skillCommand("install", skill, opts, force);
178
208
  }
209
+ /**
210
+ * Plan and apply one payload into one agent's directory. In a multi-agent run
211
+ * the result carries its `agent`, and any command it suggests names only that
212
+ * agent; with one agent it is exactly the single-agent result.
213
+ */
214
+ function applyTo(sel, target, payload, verb, opts, requiredBy) {
215
+ const owned = ownedTarget(target.dir, payload.name);
216
+ const force = Boolean(opts.force);
217
+ const allowDowngrade = Boolean(opts.allowDowngrade);
218
+ const plan = verb === "install"
219
+ ? planInstall(payload, owned.skillDir, force, allowDowngrade)
220
+ : planUpdate(payload, owned.skillDir, force, allowDowngrade);
221
+ const multi = isMulti(sel);
222
+ const result = applyPlan(payload, owned, plan, {
223
+ agent: target.agent, scope: sel.scope, dir: target.dir, verb, opts: multi ? forAgent(opts, target.agent) : opts, requiredBy,
224
+ });
225
+ return multi ? { ...result, agent: target.agent } : result;
226
+ }
179
227
  /** The one error exit: prose to stderr, or folded into --json. */
180
228
  function reject(opts, message, kind, nextAction = null, base) {
181
229
  if (opts.json) {
@@ -684,16 +732,29 @@ function printSkillResult(r, width, verb) {
684
732
  function printRun(verb, requested, sel, ctx, results, opts) {
685
733
  process.stdout.write(`${verb === "init" ? "init" : `skill ${verb}`} ${requested.join(" ")}\n`);
686
734
  header([
687
- ["agent", `${sel.agent}${sel.saved ? " (saved)" : ""}`],
735
+ agentsLabel(sel),
688
736
  ["scope", sel.scope === "dir" ? `dir ${sel.root}` : sel.scope],
689
737
  ["catalog", catalogLine(info(ctx))],
690
738
  ]);
691
739
  const width = Math.max(...results.map((r) => r.skill.length), 1);
692
- for (const r of results)
693
- printSkillResult(r, width, verb === "update" ? "update" : "install");
740
+ const skillVerb = verb === "update" ? "update" : "install";
741
+ if (isMulti(sel)) {
742
+ for (const t of sel.targets) {
743
+ const mine = results.filter((r) => r.agent === t.agent);
744
+ if (mine.length === 0)
745
+ continue;
746
+ process.stdout.write(`\n ${t.agent} ${t.dir}\n`);
747
+ for (const r of mine)
748
+ printSkillResult(r, width, skillVerb);
749
+ }
750
+ }
751
+ else {
752
+ for (const r of results)
753
+ printSkillResult(r, width, skillVerb);
754
+ }
694
755
  const conflicts = results.filter((r) => r.status === "conflict" && r.nextAction?.kind === "run");
695
756
  if (conflicts.length > 0) {
696
- const cmd = skillCommand(verb === "update" ? "update" : "install", conflicts.map((r) => r.skill), opts, true);
757
+ const cmd = forceCommand(skillVerb, conflicts, opts);
697
758
  process.stderr.write(`\n overwrite ${conflicts.length > 1 ? "them" : "it"} with:\n ${cmd}\n`);
698
759
  }
699
760
  for (const r of results) {
@@ -701,10 +762,16 @@ function printRun(verb, requested, sel, ctx, results, opts) {
701
762
  process.stderr.write(`\n next: ${r.nextAction.command}\n`);
702
763
  }
703
764
  }
765
+ /** `--force` for every conflicting skill, narrowed to one agent when only that agent's copies conflict. */
766
+ function forceCommand(verb, conflicts, opts) {
767
+ const names = [...new Set(conflicts.map((r) => r.skill))];
768
+ const agents = [...new Set(conflicts.flatMap((r) => (r.agent ? [r.agent] : [])))];
769
+ return skillCommand(verb, names, agents.length === 1 ? forAgent(opts, agents[0]) : opts, true);
770
+ }
704
771
  function runNextAction(verb, results, opts) {
705
772
  const conflicts = results.filter((r) => r.status === "conflict" && r.nextAction?.kind === "run");
706
773
  if (conflicts.length > 0)
707
- return { kind: "run", command: skillCommand(verb, conflicts.map((r) => r.skill), opts, true) };
774
+ return { kind: "run", command: forceCommand(verb, conflicts, opts) };
708
775
  const errored = results.find((r) => r.status === "error" && r.nextAction);
709
776
  if (errored)
710
777
  return errored.nextAction;
@@ -738,16 +805,11 @@ export async function runSkillInstall(names, opts, internal = {}) {
738
805
  }
739
806
  printHint(sel, opts);
740
807
  const resolved = await resolvePayloads(requested, ctx, bundleDir);
741
- const common = { agent: sel.agent, scope: sel.scope, catalog: info(ctx) };
808
+ const common = { ...agentFields(sel), scope: sel.scope, catalog: info(ctx) };
742
809
  if (isRejection(resolved))
743
810
  return reject(opts, resolved.message, resolved.kind, resolved.nextAction, common);
744
- const results = resolved.payloads.map((payload) => {
745
- const owned = ownedTarget(sel.dir, payload.name);
746
- const plan = planInstall(payload, owned.skillDir, Boolean(opts.force), Boolean(opts.allowDowngrade));
747
- return applyPlan(payload, owned, plan, {
748
- agent: sel.agent, scope: sel.scope, dir: sel.dir, verb: "install", opts, requiredBy: resolved.requiredBy.get(payload.name),
749
- });
750
- });
811
+ // One catalog, one download; each agent's copy is planned and applied on its own.
812
+ const results = sel.targets.flatMap((target) => resolved.payloads.map((payload) => applyTo(sel, target, payload, "install", opts, resolved.requiredBy.get(payload.name))));
751
813
  const status = aggregate(results);
752
814
  const result = {
753
815
  status,
@@ -780,7 +842,7 @@ function catalogOthers(catalog, exclude) {
780
842
  }
781
843
  function printInitFooter(result) {
782
844
  const prefs = result.preferences;
783
- process.stdout.write(` saved ${prefs.agent}, ${prefs.scope} as the default for 'dreamlake skill' → ${prefs.path}\n`);
845
+ process.stdout.write(` saved ${preferredAgents(prefs).join(" and ")}, ${prefs.scope} as the default for 'dreamlake skill' → ${prefs.path}\n`);
784
846
  const others = result.available ?? [];
785
847
  if (others.length === 0)
786
848
  return;
@@ -820,10 +882,21 @@ export async function runSkillUpdate(names, opts) {
820
882
  if (bad !== null)
821
883
  return reject(opts, invalidNameMessage(bad), "invalid-name");
822
884
  printHint(sel, opts);
823
- const requested = names.length > 0 ? names : managedSkills(sel.dir);
885
+ // What each agent updates: the names given, or every skill with a manifest
886
+ // in its directory. With several agents, a named skill that is absent under
887
+ // one of them is skipped there — unless it is absent under all of them,
888
+ // which is reported per agent as `not-installed`.
889
+ const perAgent = new Map(sel.targets.map((t) => {
890
+ if (names.length === 0)
891
+ return [t.agent, managedSkills(t.dir)];
892
+ if (!isMulti(sel))
893
+ return [t.agent, names];
894
+ return [t.agent, names.filter((name) => kindOf(targetIn(t.dir, name)) !== "absent" || sel.targets.every((o) => kindOf(targetIn(o.dir, name)) === "absent"))];
895
+ }));
896
+ const requested = names.length > 0 ? names : [...new Set([...perAgent.values()].flat())].sort();
824
897
  const bundleDir = resolveBundleDir();
825
898
  const ctx = await loadCatalog(bundleDir, false);
826
- const common = { agent: sel.agent, scope: sel.scope, catalog: info(ctx) };
899
+ const common = { ...agentFields(sel), scope: sel.scope, catalog: info(ctx) };
827
900
  if (requested.length === 0) {
828
901
  const result = { status: "exists", ...common, skills: [], nextAction: { kind: "run", command: "dreamlake skill list" } };
829
902
  if (opts.json) {
@@ -831,8 +904,8 @@ export async function runSkillUpdate(names, opts) {
831
904
  return 0;
832
905
  }
833
906
  process.stdout.write(`skill update\n`);
834
- header([["agent", sel.agent], ["scope", sel.scope === "dir" ? `dir ${sel.root}` : sel.scope]]);
835
- warn(`no installed skills with a manifest under ${sel.dir}`);
907
+ header([[isMulti(sel) ? "agents" : "agent", sel.agents.join(", ")], ["scope", sel.scope === "dir" ? `dir ${sel.root}` : sel.scope]]);
908
+ warn(`no installed skills with a manifest under ${sel.targets.map((t) => t.dir).join(" or ")}`);
836
909
  process.stdout.write(`\n next: dreamlake skill list\n`);
837
910
  return 0;
838
911
  }
@@ -841,14 +914,16 @@ export async function runSkillUpdate(names, opts) {
841
914
  // planUpdate's guard). A skill installed from the release is updated from
842
915
  // the release or not at all.
843
916
  if (ctx.origin !== "release") {
844
- const fromRelease = requested.filter((name) => {
917
+ const fromRelease = requested.filter((name) => sel.targets.some((t) => {
918
+ if (!perAgent.get(t.agent).includes(name))
919
+ return false;
845
920
  try {
846
- return readManifest(targetIn(sel.dir, name))?.source === "catalog";
921
+ return readManifest(targetIn(t.dir, name))?.source === "catalog";
847
922
  }
848
923
  catch {
849
924
  return false; // An invalid manifest is reported by planUpdate.
850
925
  }
851
- });
926
+ }));
852
927
  if (fromRelease.length > 0) {
853
928
  const why = ctx.unreachable ? `cannot reach the skills release (${ctx.unreachable})` : "this build has no catalog and the release was not consulted";
854
929
  return reject(opts, `${why} — ${fromRelease.join(", ")} ${fromRelease.length > 1 ? "were" : "was"} installed from the release and can only be updated from it`, "catalog-unreachable", { kind: "download", url: manualDownloadUrl() }, common);
@@ -858,11 +933,11 @@ export async function runSkillUpdate(names, opts) {
858
933
  if (isRejection(resolved))
859
934
  return reject(opts, resolved.message, resolved.kind, resolved.nextAction, common);
860
935
  // `update` touches what was named (or installed); `requires` are not pulled in.
861
- const payloads = resolved.payloads.filter((p) => requested.includes(p.name));
862
- const results = payloads.map((payload) => {
863
- const owned = ownedTarget(sel.dir, payload.name);
864
- const plan = planUpdate(payload, owned.skillDir, Boolean(opts.force), Boolean(opts.allowDowngrade));
865
- return applyPlan(payload, owned, plan, { agent: sel.agent, scope: sel.scope, dir: sel.dir, verb: "update", opts });
936
+ const results = sel.targets.flatMap((target) => {
937
+ const mine = perAgent.get(target.agent);
938
+ return resolved.payloads
939
+ .filter((p) => mine.includes(p.name))
940
+ .map((payload) => applyTo(sel, target, payload, "update", opts));
866
941
  });
867
942
  const status = aggregate(results);
868
943
  const result = {
@@ -888,34 +963,67 @@ export async function runSkillRemove(name, opts) {
888
963
  if (!isSkillName(name))
889
964
  return reject(opts, invalidNameMessage(name), "invalid-name");
890
965
  printHint(sel, opts);
891
- const owned = ownedTarget(sel.dir, name);
892
- const target = owned.skillDir;
893
- const base = { status: "removed", agent: sel.agent, scope: sel.scope, skill: name, target, nextAction: null };
894
- const rejectRemove = (message, kind, nextAction = null) => {
895
- if (opts.json) {
896
- emitJson({ ...base, status: "error", error: message, kind, nextAction });
897
- }
898
- else {
899
- fail(message);
900
- if (nextAction?.kind === "run")
901
- process.stderr.write(`\n next: ${nextAction.command}\n`);
902
- }
903
- return 1;
966
+ if (!isMulti(sel)) {
967
+ const { result, source } = removeFrom(sel, sel.targets[0], name);
968
+ if (opts.json)
969
+ emitJson(result);
970
+ else if (result.status === "error")
971
+ printRemoveError(result);
972
+ else
973
+ printRemoved(sel, result, source);
974
+ return result.status === "removed" ? 0 : 1;
975
+ }
976
+ // Several agents: remove each copy that is there. Absent under some agents
977
+ // is fine; absent under all of them is the single-agent not-installed error, per agent.
978
+ const all = sel.targets.map((t) => removeFrom(sel, t, name));
979
+ const found = all.filter((r) => r.result.kind !== "not-installed");
980
+ const outcomes = found.length > 0 ? found : all;
981
+ const removals = outcomes.map((o) => o.result);
982
+ const failed = removals.find((r) => r.status === "error");
983
+ const result = {
984
+ status: failed ? "error" : "removed",
985
+ agents: sel.agents,
986
+ scope: sel.scope,
987
+ skill: name,
988
+ removals,
989
+ nextAction: failed?.nextAction ?? null,
990
+ ...(failed ? { error: failed.error, kind: failed.kind } : {}),
904
991
  };
992
+ if (opts.json) {
993
+ emitJson(result);
994
+ }
995
+ else {
996
+ for (const [i, { result: r, source }] of outcomes.entries()) {
997
+ if (i > 0)
998
+ process.stdout.write("\n");
999
+ if (r.status === "error")
1000
+ printRemoveError(r);
1001
+ else
1002
+ printRemoved(sel, r, source);
1003
+ }
1004
+ }
1005
+ return failed ? 1 : 0;
1006
+ }
1007
+ /** Remove one agent's copy. Writes nothing to stdout or stderr; the caller reports. */
1008
+ function removeFrom(sel, t, name) {
1009
+ const owned = ownedTarget(t.dir, name);
1010
+ const target = owned.skillDir;
1011
+ const base = { status: "removed", agent: t.agent, scope: sel.scope, skill: name, target, nextAction: null };
1012
+ const rejected = (message, kind, nextAction = null) => ({ result: { ...base, status: "error", error: message, kind, nextAction } });
905
1013
  const kind = kindOf(target);
906
1014
  if (kind === "absent")
907
- return rejectRemove(`${name} is not installed at ${target}`, "not-installed", { kind: "run", command: "dreamlake skill list" });
1015
+ return rejected(`${name} is not installed at ${target}`, "not-installed", { kind: "run", command: "dreamlake skill list" });
908
1016
  if (kind !== "dir")
909
- return rejectRemove(`${target} exists and is not a directory — nothing to remove safely`, "not-a-directory");
1017
+ return rejected(`${target} exists and is not a directory — nothing to remove safely`, "not-a-directory");
910
1018
  let manifest;
911
1019
  try {
912
1020
  manifest = readManifest(target);
913
1021
  }
914
1022
  catch (err) {
915
- return rejectRemove(`${err.file}: ${err.message}`, "invalid-manifest");
1023
+ return rejected(`${err.file}: ${err.message}`, "invalid-manifest");
916
1024
  }
917
1025
  if (!manifest) {
918
- return rejectRemove(`${target} has no ${MANIFEST_FILE} — it was not installed by dreamlake, so delete it yourself if you want it gone`, "unmanaged");
1026
+ return rejected(`${target} has no ${MANIFEST_FILE} — it was not installed by dreamlake, so delete it yourself if you want it gone`, "unmanaged");
919
1027
  }
920
1028
  // Only a manifest-listed regular file whose hash still matches is deleted.
921
1029
  // Everything else — an edited file, a file the manifest never listed, a
@@ -939,35 +1047,33 @@ export async function runSkillRemove(name, opts) {
939
1047
  pruneEmptyDirs(owned, "x", true);
940
1048
  }
941
1049
  catch (err) {
942
- const result = { ...base, status: "error", version: manifest.version, deleted, error: `cannot remove from ${target}: ${err.message}`, kind: "remove-failed", nextAction: null };
943
- if (opts.json)
944
- emitJson(result);
945
- else
946
- fail(result.error);
947
- return 1;
1050
+ return { result: { ...base, status: "error", version: manifest.version, deleted, error: `cannot remove from ${target}: ${err.message}`, kind: "remove-failed", nextAction: null } };
948
1051
  }
949
1052
  const kept = kindOf(target) === "dir" ? localExtras(target, new Set()) : [];
950
- const result = { ...base, status: "removed", version: manifest.version, deleted, kept, nextAction: null };
951
- if (opts.json) {
952
- emitJson(result);
953
- return 0;
954
- }
955
- process.stdout.write(`skill remove ${name}\n`);
1053
+ return { result: { ...base, status: "removed", version: manifest.version, deleted, kept, nextAction: null }, source: manifest.source };
1054
+ }
1055
+ function printRemoveError(r) {
1056
+ fail(r.error);
1057
+ if (r.nextAction?.kind === "run")
1058
+ process.stderr.write(`\n next: ${r.nextAction.command}\n`);
1059
+ }
1060
+ function printRemoved(sel, r, source) {
1061
+ process.stdout.write(`skill remove ${r.skill}\n`);
956
1062
  header([
957
- ["agent", `${sel.agent}${sel.saved ? " (saved)" : ""}`],
1063
+ ["agent", `${r.agent}${sel.saved ? " (saved)" : ""}`],
958
1064
  ["scope", sel.scope === "dir" ? `dir ${sel.root}` : sel.scope],
959
- ["target", target],
1065
+ ["target", r.target],
960
1066
  ]);
961
- ok(`removed ${deleted.length} file(s) of ${manifest.source} ${fmtVersion(manifest.version)}`);
1067
+ ok(`removed ${r.deleted.length} file(s) of ${source} ${fmtVersion(r.version ?? null)}`);
1068
+ const kept = r.kept ?? [];
962
1069
  if (kept.length > 0) {
963
1070
  warn(`${kept.length} file(s) kept — edited, or not part of this skill:`);
964
1071
  for (const rel of kept)
965
1072
  process.stdout.write(` · ${rel}\n`);
966
1073
  if (kept.includes("SKILL.md")) {
967
- warn(`SKILL.md was kept, so the agent still discovers this skill — delete ${target} yourself to remove it fully`);
1074
+ warn(`SKILL.md was kept, so the agent still discovers this skill — delete ${r.target} yourself to remove it fully`);
968
1075
  }
969
1076
  }
970
- return 0;
971
1077
  }
972
1078
  // ─── list ────────────────────────────────────────────────────────────────────
973
1079
  function scopeState(target, verify) {
@@ -1052,10 +1158,73 @@ export async function runSkillList(opts) {
1052
1158
  latest = { error: err.message, url: catalogUrl() };
1053
1159
  }
1054
1160
  }
1055
- const entries = installedSkillEntries(sel.agent, { latest: refreshed });
1161
+ const present = (s) => s.state === "installed" || s.state === "modified";
1162
+ const label = (s) => ({
1163
+ absent: "not installed",
1164
+ installed: `installed ${fmtVersion(s.version)}`,
1165
+ modified: `modified ${fmtVersion(s.version)}`,
1166
+ blocked: "blocked (not a directory)",
1167
+ unmanaged: "unmanaged (no manifest)",
1168
+ })[s.state];
1169
+ const printHeader = () => {
1170
+ process.stdout.write(`skill list\n`);
1171
+ header([
1172
+ agentsLabel(sel),
1173
+ ["source", bundleDir ?? "none"],
1174
+ ["catalog", snapshot ? `${fmtVersion(snapshot.version)} (embedded snapshot)` : "none"],
1175
+ ...(latest ? [["latest", "version" in latest ? `${fmtVersion(latest.version)} (release)` : `unreachable — ${latest.error}`]] : []),
1176
+ ]);
1177
+ if (latest && "error" in latest)
1178
+ warn(`could not refresh the catalog; showing the embedded snapshot`);
1179
+ };
1180
+ const meta = (e) => [e.latest ? fmtVersion(e.latest) : "", e.files !== null ? `${e.files} files` : "", e.embedded ? "embedded" : ""]
1181
+ .filter(Boolean).join(" ");
1182
+ const catalogInfo = { version: snapshot?.version ?? null, origin: snapshot ? "embedded" : "none" };
1183
+ if (isMulti(sel)) {
1184
+ // Rows are the same for every agent; only the installed state differs.
1185
+ const perAgent = sel.agents.map((agent) => ({ agent, entries: installedSkillEntries(agent, { latest: refreshed }) }));
1186
+ const entries = perAgent[0].entries.map(({ project: _p, global: _g, ...row }) => ({
1187
+ ...row,
1188
+ installs: Object.fromEntries(perAgent.map(({ agent, entries: rows }) => {
1189
+ const mine = rows.find((r) => r.name === row.name);
1190
+ return [agent, { project: mine.project, global: mine.global }];
1191
+ })),
1192
+ }));
1193
+ // The first skill some agent has at neither scope; install names every agent, and copies already there are no-ops.
1194
+ const pending = entries.find((e) => Object.values(e.installs).some((i) => !present(i.project) && !present(i.global)));
1195
+ const nextAction = pending ? { kind: "run", command: installCommand(pending.name, opts, false) } : null;
1196
+ const result = {
1197
+ status: "ok", source: bundleDir, agents: sel.agents, catalog: catalogInfo, ...(latest ? { latest } : {}), skills: entries, nextAction,
1198
+ };
1199
+ if (opts.json) {
1200
+ emitJson(result);
1201
+ return 0;
1202
+ }
1203
+ printHeader();
1204
+ if (entries.length === 0) {
1205
+ warn("this build bundles no skills");
1206
+ return 0;
1207
+ }
1208
+ const width = Math.max(...entries.map((e) => e.name.length));
1209
+ const agentWidth = Math.max(...sel.agents.map((a) => a.length));
1210
+ const stateWidth = Math.max(...entries.flatMap((e) => Object.values(e.installs).flatMap((i) => [label(i.project).length, label(i.global).length])));
1211
+ for (const e of entries) {
1212
+ process.stdout.write(`\n ${e.name.padEnd(width)} ${meta(e)}\n`);
1213
+ if (e.description)
1214
+ process.stdout.write(` ${e.description}\n`);
1215
+ for (const agent of sel.agents) {
1216
+ const i = e.installs[agent];
1217
+ process.stdout.write(` ${agent.padEnd(agentWidth)} project ${label(i.project).padEnd(stateWidth)} ${i.project.path}\n`);
1218
+ process.stdout.write(` ${agent.padEnd(agentWidth)} global ${label(i.global).padEnd(stateWidth)} ${i.global.path}\n`);
1219
+ }
1220
+ }
1221
+ if (nextAction)
1222
+ process.stdout.write(`\n next: ${nextAction.command}\n`);
1223
+ return 0;
1224
+ }
1225
+ const entries = installedSkillEntries(sel.agents[0], { latest: refreshed });
1056
1226
  // One next action, and only when there is something to do. A skill with a
1057
1227
  // manifest at either scope is present, even if edited; `update` handles it.
1058
- const present = (s) => s.state === "installed" || s.state === "modified";
1059
1228
  const pending = entries.find((e) => !present(e.project) && !present(e.global));
1060
1229
  const nextAction = pending
1061
1230
  ? { kind: "run", command: installCommand(pending.name, opts, false) }
@@ -1063,8 +1232,8 @@ export async function runSkillList(opts) {
1063
1232
  const result = {
1064
1233
  status: "ok",
1065
1234
  source: bundleDir,
1066
- agent: sel.agent,
1067
- catalog: { version: snapshot?.version ?? null, origin: snapshot ? "embedded" : "none" },
1235
+ agent: sel.agents[0],
1236
+ catalog: catalogInfo,
1068
1237
  ...(latest ? { latest } : {}),
1069
1238
  skills: entries,
1070
1239
  nextAction,
@@ -1073,32 +1242,15 @@ export async function runSkillList(opts) {
1073
1242
  emitJson(result);
1074
1243
  return 0;
1075
1244
  }
1076
- process.stdout.write(`skill list\n`);
1077
- header([
1078
- ["agent", `${sel.agent}${sel.saved ? " (saved)" : ""}`],
1079
- ["source", bundleDir ?? "none"],
1080
- ["catalog", snapshot ? `${fmtVersion(snapshot.version)} (embedded snapshot)` : "none"],
1081
- ...(latest ? [["latest", "version" in latest ? `${fmtVersion(latest.version)} (release)` : `unreachable — ${latest.error}`]] : []),
1082
- ]);
1083
- if (latest && "error" in latest)
1084
- warn(`could not refresh the catalog; showing the embedded snapshot`);
1245
+ printHeader();
1085
1246
  if (entries.length === 0) {
1086
1247
  warn("this build bundles no skills");
1087
1248
  return 0;
1088
1249
  }
1089
- const label = (s) => ({
1090
- absent: "not installed",
1091
- installed: `installed ${fmtVersion(s.version)}`,
1092
- modified: `modified ${fmtVersion(s.version)}`,
1093
- blocked: "blocked (not a directory)",
1094
- unmanaged: "unmanaged (no manifest)",
1095
- })[s.state];
1096
1250
  const width = Math.max(...entries.map((e) => e.name.length));
1097
1251
  const stateWidth = Math.max(...entries.flatMap((e) => [label(e.project).length, label(e.global).length]));
1098
1252
  for (const e of entries) {
1099
- const meta = [e.latest ? fmtVersion(e.latest) : "", e.files !== null ? `${e.files} files` : "", e.embedded ? "embedded" : ""]
1100
- .filter(Boolean).join(" ");
1101
- process.stdout.write(`\n ${e.name.padEnd(width)} ${meta}\n`);
1253
+ process.stdout.write(`\n ${e.name.padEnd(width)} ${meta(e)}\n`);
1102
1254
  if (e.description)
1103
1255
  process.stdout.write(` ${e.description}\n`);
1104
1256
  process.stdout.write(` project ${label(e.project).padEnd(stateWidth)} ${e.project.path}\n`);
@@ -1111,30 +1263,36 @@ export async function runSkillList(opts) {
1111
1263
  export async function runSkillInit(opts, io = {
1112
1264
  interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY),
1113
1265
  agent: () => select({ message: "Which agent?", choices: [
1114
- { name: "Codex", value: "codex" }, { name: "Claude Code", value: "claude" },
1266
+ { name: "Claude Code and Codex", value: ["claude", "codex"] },
1267
+ { name: "Codex", value: ["codex"] },
1268
+ { name: "Claude Code", value: ["claude"] },
1115
1269
  ] }),
1116
1270
  global: () => select({ message: "Where should skills be installed?", choices: [
1117
1271
  { name: "This project", value: false }, { name: "All projects (global)", value: true },
1118
1272
  ] }),
1119
1273
  }) {
1120
1274
  if (opts.agent !== undefined) {
1121
- if (!isAgent(opts.agent))
1122
- return reject(opts, "--agent must be claude or codex", "invalid-agent");
1123
- return initInstall(opts, { agent: opts.agent, scope: opts.global && !opts.dir && !opts.project ? "global" : "project" });
1275
+ const agents = parseAgents(opts.agent);
1276
+ if (!agents)
1277
+ return reject(opts, AGENT_ERROR, "invalid-agent");
1278
+ return initInstall(opts, skillPreferences(agents, opts.global && !opts.dir && !opts.project ? "global" : "project"));
1124
1279
  }
1125
1280
  if (!io.interactive || Object.values(opts).some((v) => v !== undefined && v !== false)) {
1126
- return reject(opts, "specify --agent codex or --agent claude for non-interactive setup", "agent-required", { kind: "run", command: "dreamlake init --agent codex" });
1281
+ return reject(opts, "specify --agent claude, codex or all for non-interactive setup", "agent-required", { kind: "run", command: "dreamlake init --agent all" });
1127
1282
  }
1128
- let agent;
1283
+ let agents;
1129
1284
  let global;
1130
1285
  try {
1131
- agent = await io.agent();
1286
+ const chosen = await io.agent();
1287
+ agents = AGENTS.filter((a) => (Array.isArray(chosen) ? chosen : [chosen]).includes(a));
1132
1288
  global = await io.global();
1133
1289
  }
1134
1290
  catch {
1135
1291
  return reject(opts, "setup canceled; no skill files were written", "canceled");
1136
1292
  }
1137
- return initInstall({ ...opts, agent, global }, { agent, scope: global ? "global" : "project" });
1293
+ if (agents.length === 0)
1294
+ return reject(opts, "setup canceled; no agent was chosen", "canceled");
1295
+ return initInstall({ ...opts, agent: agents.join(","), global }, skillPreferences(agents, global ? "global" : "project"));
1138
1296
  }
1139
1297
  function initInstall(opts, preferences) {
1140
1298
  let saved;
@@ -1155,7 +1313,7 @@ function initInstall(opts, preferences) {
1155
1313
  // --version` drift produced.
1156
1314
  function scopeOptions(command) {
1157
1315
  return command
1158
- .option("--agent <agent>", "target agent: claude or codex (default: what dreamlake init saved, else claude)")
1316
+ .option("--agent <agent>", "target agent: claude, codex, all, or a comma list (default: what dreamlake init saved, else claude)")
1159
1317
  .option("--global", "use your home directory instead of the current project")
1160
1318
  .option("--project", "use the current project even if dreamlake init chose global")
1161
1319
  .option("--dir <path>", "use this project root; overrides --global and --project");
@@ -1169,7 +1327,7 @@ function installationOptions(command) {
1169
1327
  export function registerSkillCommand(program) {
1170
1328
  program.command("init")
1171
1329
  .description("set up agent skills: choose an agent and scope, install the embedded dreamlake-cli skill offline")
1172
- .option("--agent <agent>", "claude or codex; saved as the default for 'dreamlake skill' and skips the prompts")
1330
+ .option("--agent <agent>", "claude, codex, all, or a comma list; saved as the default for 'dreamlake skill' and skips the prompts")
1173
1331
  .option("--global", "install under your home directory and save global scope")
1174
1332
  .option("--dir <path>", "install under this project root; overrides --global")
1175
1333
  .option("--force", "overwrite files that differ; files the skill does not own are kept")
@@ -1180,8 +1338,8 @@ export function registerSkillCommand(program) {
1180
1338
  const skill = program.command("skill")
1181
1339
  .description("install, update, remove and list agent skills from the dreamlake-skills release")
1182
1340
  .addHelpText("after", `
1183
- Claude Code uses .claude/skills/; Codex uses .agents/skills/.
1184
- 'dreamlake init' saves the default agent and scope; --agent, --global, --project and --dir override it.
1341
+ Claude Code uses .claude/skills/; Codex uses .agents/skills/. --agent all installs into both, one copy each.
1342
+ 'dreamlake init' saves the default agent(s) and scope; --agent, --global, --project and --dir override it.
1185
1343
  install and update download from the public release; dreamlake-cli is embedded and installs offline.
1186
1344
  Every install writes <skill>/.dreamlake-skill.json; update and remove touch only files it lists.
1187
1345
  remove never deletes a file you edited: it is kept and reported.
@@ -1207,7 +1365,7 @@ remove never deletes a file you edited: it is kept and reported.
1207
1365
  });
1208
1366
  collectionList(skill, "list")
1209
1367
  .description("show the catalog with project/global installation status")
1210
- .option("--agent <agent>", "target agent: claude or codex (default: what dreamlake init saved, else claude)")
1368
+ .option("--agent <agent>", "target agent: claude, codex, all, or a comma list (default: what dreamlake init saved, else claude)")
1211
1369
  .option("--refresh", "fetch the latest catalog from the release and show it next to the installed versions")
1212
1370
  .option("--json", "emit one result object")
1213
1371
  .action(async (opts) => {
@@ -19,6 +19,12 @@ export declare class ManifestError extends Error {
19
19
  }
20
20
  export declare const AGENTS: readonly SkillAgent[];
21
21
  export declare function isAgent(v: unknown): v is SkillAgent;
22
+ /**
23
+ * An `--agent` value: one agent, a comma-separated list, or `all`. Returns the
24
+ * agents in canonical order without duplicates, or null when any part is not
25
+ * an agent. A manifest still records exactly one agent; this is selection only.
26
+ */
27
+ export declare function parseAgents(v: unknown): SkillAgent[] | null;
22
28
  export declare function manifestPath(target: string): string;
23
29
  /** Validate a parsed manifest. Throws `ManifestError` naming the first problem. */
24
30
  export declare function validateManifest(raw: unknown, file: string): SkillManifest;
@@ -25,6 +25,21 @@ const SHA256 = /^[0-9a-f]{64}$/;
25
25
  export function isAgent(v) {
26
26
  return typeof v === "string" && AGENTS.includes(v);
27
27
  }
28
+ /**
29
+ * An `--agent` value: one agent, a comma-separated list, or `all`. Returns the
30
+ * agents in canonical order without duplicates, or null when any part is not
31
+ * an agent. A manifest still records exactly one agent; this is selection only.
32
+ */
33
+ export function parseAgents(v) {
34
+ if (typeof v !== "string")
35
+ return null;
36
+ const parts = v.split(",").map((p) => p.trim());
37
+ if (parts.length === 0 || parts.some((p) => p !== "all" && !isAgent(p)))
38
+ return null;
39
+ if (parts.includes("all"))
40
+ return [...AGENTS];
41
+ return AGENTS.filter((a) => parts.includes(a));
42
+ }
28
43
  export function manifestPath(target) {
29
44
  return path.join(target, MANIFEST_FILE);
30
45
  }