loopwright 0.1.1 → 0.1.3

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/dist/cli.js CHANGED
@@ -7,6 +7,50 @@ import { execFileSync } from "node:child_process";
7
7
  import { createHash } from "node:crypto";
8
8
  import { fileURLToPath } from "node:url";
9
9
  import { createInterface } from "node:readline";
10
+ // src/core/experimental.ts
11
+ const EXPERIMENTAL_FEATURES = ["junie-hooks"];
12
+ /** Parse a comma-separated `--experimental` value; `all` expands to every feature, in registry order. */
13
+ function parseExperimental(raw) {
14
+ const names = raw.split(",").map((s) => s.trim()).filter(Boolean);
15
+ const out = /* @__PURE__ */ new Set();
16
+ for (const n of names) if (n === "all") for (const f of EXPERIMENTAL_FEATURES) out.add(f);
17
+ else if (EXPERIMENTAL_FEATURES.includes(n)) out.add(n);
18
+ else throw new Error(`Unknown experimental feature "${n}". Valid: ${EXPERIMENTAL_FEATURES.join(", ")}, all`);
19
+ return EXPERIMENTAL_FEATURES.filter((f) => out.has(f));
20
+ }
21
+ // src/core/profiles.ts
22
+ /** Effort per role. Mirrored in content/hooks/lib.mjs (a test pins them equal). Efforts only, never models. */
23
+ const PROFILES = {
24
+ lean: {
25
+ scout: "low",
26
+ tester: "low",
27
+ implementer: "low",
28
+ reviewer: "medium"
29
+ },
30
+ balanced: {
31
+ scout: "medium",
32
+ tester: "medium",
33
+ implementer: "medium",
34
+ reviewer: "high"
35
+ },
36
+ thorough: {
37
+ scout: "high",
38
+ tester: "high",
39
+ implementer: "high",
40
+ reviewer: "xhigh"
41
+ },
42
+ deep: {
43
+ scout: "xhigh",
44
+ tester: "xhigh",
45
+ implementer: "xhigh",
46
+ reviewer: "xhigh"
47
+ }
48
+ };
49
+ const PROFILE_NAMES = Object.keys(PROFILES);
50
+ function resolveProfile(name) {
51
+ if (!Object.hasOwn(PROFILES, name)) throw new Error(`Unknown profile ${JSON.stringify(name)} (allowed: ${PROFILE_NAMES.join(", ")})`);
52
+ return PROFILES[name];
53
+ }
10
54
  // src/core/git.ts
11
55
  function git(cwd, args) {
12
56
  return execFileSync("git", args, {
@@ -20,7 +64,7 @@ function git(cwd, args) {
20
64
  }).trim();
21
65
  }
22
66
  function gitTopLevel(cwd) {
23
- return git(cwd, ["rev-parse", "--show-toplevel"]);
67
+ return resolve(git(cwd, ["rev-parse", "--show-toplevel"]));
24
68
  }
25
69
  function mainWorktreeRoot(cwd) {
26
70
  const common = git(cwd, [
@@ -28,7 +72,7 @@ function mainWorktreeRoot(cwd) {
28
72
  "--path-format=absolute",
29
73
  "--git-common-dir"
30
74
  ]);
31
- if (basename(common) === ".git") return dirname(common);
75
+ if (basename(common) === ".git") return resolve(dirname(common));
32
76
  return gitTopLevel(cwd);
33
77
  }
34
78
  // src/core/targets.ts
@@ -50,9 +94,11 @@ function resolveTargets(opts) {
50
94
  claudeSkillsMode: "copy",
51
95
  claudeAgentsDir: join(h, ".claude/agents"),
52
96
  codexAgentsDir: join(h, ".codex/agents"),
97
+ junieAgentsDir: join(h, ".junie/agents"),
53
98
  lwHome: lw,
54
99
  lwHomeRef: lw,
55
100
  claudeSettingsPath: join(h, ".claude/settings.json"),
101
+ junieConfigPath: join(h, ".junie/config.json"),
56
102
  codexConfigPath: join(h, ".codex/config.toml"),
57
103
  manifestPath: join(lw, "manifest.json"),
58
104
  configPath: join(lw, "config.json"),
@@ -76,9 +122,11 @@ function resolveTargets(opts) {
76
122
  claudeSkillsMode: opts.symlink ? "symlink" : "none",
77
123
  claudeAgentsDir: join(root, ".claude/agents"),
78
124
  codexAgentsDir: join(root, ".codex/agents"),
125
+ junieAgentsDir: join(root, ".junie/agents"),
79
126
  lwHome: join(root, ".agents/loopwright"),
80
127
  lwHomeRef: ".agents/loopwright",
81
128
  claudeSettingsPath: join(root, ".claude/settings.json"),
129
+ junieConfigPath: join(root, ".junie/config.json"),
82
130
  codexConfigPath: join(root, ".codex/config.toml"),
83
131
  manifestPath: join(stateDir, "manifest.json"),
84
132
  configPath: join(stateDir, "config.json"),
@@ -88,7 +136,7 @@ function resolveTargets(opts) {
88
136
  // src/core/config.ts
89
137
  const DEFAULT_CONFIG = {
90
138
  maxFixRounds: 3,
91
- crossModelReview: "off",
139
+ crossAgentReview: "off",
92
140
  docsDir: "docs/agents",
93
141
  models: {
94
142
  claude: {
@@ -103,7 +151,13 @@ const DEFAULT_CONFIG = {
103
151
  implementer: "inherit",
104
152
  reviewer: "inherit"
105
153
  },
106
- crossModelReviewer: {
154
+ junie: {
155
+ scout: "opus",
156
+ tester: "sonnet",
157
+ implementer: "sonnet",
158
+ reviewer: "gpt"
159
+ },
160
+ crossAgentReviewer: {
107
161
  claude: "opus",
108
162
  codex: "inherit"
109
163
  }
@@ -118,15 +172,27 @@ function merge(base, over) {
118
172
  for (const [k, v] of Object.entries(over)) out[k] = merge(base[k], v);
119
173
  return out;
120
174
  }
121
- function readConfig(path) {
122
- if (!existsSync(path)) return structuredClone(DEFAULT_CONFIG);
123
- let parsed;
124
- try {
125
- parsed = JSON.parse(readFileSync(path, "utf8"));
126
- } catch (e) {
127
- throw new Error(`Invalid JSON in ${path}: ${e.message}`);
175
+ /** Efforts come only from `profile` (--profile, default balanced); effort keys in the file are ignored. Models are never touched. */
176
+ function readConfig(path, profile) {
177
+ profile ??= "balanced";
178
+ if (!PROFILE_NAMES.includes(profile)) throw new Error(`Invalid profile in ${path}: ${JSON.stringify(profile)} (allowed: ${PROFILE_NAMES.join(", ")})`);
179
+ let config = structuredClone(DEFAULT_CONFIG);
180
+ if (existsSync(path)) {
181
+ let parsed;
182
+ try {
183
+ parsed = JSON.parse(readFileSync(path, "utf8"));
184
+ } catch (e) {
185
+ throw new Error(`Invalid JSON in ${path}: ${e.message}`, { cause: e });
186
+ }
187
+ config = merge(config, parsed);
128
188
  }
129
- return merge(structuredClone(DEFAULT_CONFIG), parsed);
189
+ const efforts = resolveProfile(profile);
190
+ const m = config.models;
191
+ m.claude.effort = { ...efforts };
192
+ m.junie.effort = { ...efforts };
193
+ m.codex.effort = { ...efforts };
194
+ m.crossAgentReviewer.effort = { claude: efforts.reviewer };
195
+ return config;
130
196
  }
131
197
  // src/core/manifest.ts
132
198
  function sha256(text) {
@@ -194,8 +260,8 @@ var InstallWriter = class {
194
260
  });
195
261
  }
196
262
  /** Hooks skipped this run: existing wiring stays in place, so its manifest record must too. */
197
- carryPriorConfig() {
198
- for (const c of this.opts.manifest?.config ?? []) this.addConfig(c);
263
+ carryPriorConfig(kinds) {
264
+ for (const c of this.opts.manifest?.config ?? []) if (kinds.includes(c.kind)) this.addConfig(c);
199
265
  }
200
266
  addConfig(entry) {
201
267
  if (!this.config.some((c) => c.file === entry.file && c.kind === entry.kind)) this.config.push({
@@ -277,7 +343,7 @@ function parseAgentSource(role, md) {
277
343
  body: m[2].trim()
278
344
  };
279
345
  }
280
- function renderClaudeAgent(src, model) {
346
+ function renderClaudeAgent(src, model, effort) {
281
347
  const lines = [
282
348
  "---",
283
349
  `name: ${src.name}`,
@@ -285,6 +351,7 @@ function renderClaudeAgent(src, model) {
285
351
  ];
286
352
  if (src.tools) lines.push(`tools: ${src.tools}`);
287
353
  if (model !== "inherit") lines.push(`model: ${model}`);
354
+ if (effort) lines.push(`effort: ${effort}`);
288
355
  lines.push("---", "", src.body, "");
289
356
  return lines.join("\n");
290
357
  }
@@ -302,6 +369,22 @@ function renderCodexAgent(src, model, effort) {
302
369
  lines.push(`developer_instructions = ${instructions}`, "");
303
370
  return lines.join("\n");
304
371
  }
372
+ /** Junie takes the same tool labels as the role source, as a YAML list. */
373
+ function renderJunieAgent(src, model, effort, lwHome = ".agents/loopwright") {
374
+ const lines = [
375
+ "---",
376
+ `name: ${src.name}`,
377
+ `description: ${src.description}`
378
+ ];
379
+ if (src.tools) {
380
+ lines.push("tools:");
381
+ for (const t of src.tools.split(",").map((x) => x.trim()).filter(Boolean)) lines.push(` - ${t}`);
382
+ }
383
+ if (model !== "inherit") lines.push(`model: ${model}`);
384
+ if (effort) lines.push(`reasoningLevel: ${effort}`);
385
+ lines.push("---", "", renderTemplate(src.body, { LW_HOME: lwHome }), "");
386
+ return lines.join("\n");
387
+ }
305
388
  // src/install/hook-wiring.ts
306
389
  /** Substring identifying commands managed by loopwright. */
307
390
  const MANAGED_HOOK_HINT = "loopwright/hooks/";
@@ -324,7 +407,7 @@ function hookSpecs(tool) {
324
407
  ];
325
408
  }
326
409
  function hookCommand(tool, targets, script) {
327
- if (targets.mode === "global") return `node "${targets.lwHome}/hooks/${script}" --tool ${tool}`;
410
+ if (targets.mode === "global" || tool === "junie") return `node "${targets.lwHome}/hooks/${script}" --tool ${tool}`;
328
411
  return `node "${tool === "claude" ? "$CLAUDE_PROJECT_DIR" : "$(git rev-parse --show-toplevel)"}/.agents/loopwright/hooks/${script}" --tool ${tool}`;
329
412
  }
330
413
  // src/install/claude-settings.ts
@@ -399,6 +482,13 @@ function removeClaudeHooks(settingsText, hint, filePath) {
399
482
  else next["hooks"] = hooks;
400
483
  return JSON.stringify(next, null, 2) + "\n";
401
484
  }
485
+ // src/install/junie-config.ts
486
+ function upsertJunieHooks(text, specs, commandFor, filePath) {
487
+ return mergeClaudeHooks(text, specs, commandFor, filePath);
488
+ }
489
+ function removeJunieHooks(text, hint = MANAGED_HOOK_HINT, filePath) {
490
+ return removeClaudeHooks(text, hint, filePath);
491
+ }
402
492
  // src/install/codex-config.ts
403
493
  const CODEX_BEGIN = "# BEGIN loopwright";
404
494
  const CODEX_END = "# END loopwright";
@@ -450,6 +540,12 @@ function symlinkTarget(path) {
450
540
  return null;
451
541
  }
452
542
  }
543
+ /** Windows readlink may return backslashes for a link we created with slashes. */
544
+ function sameLinkTarget(actual, expected, platform = process.platform) {
545
+ if (actual === null) return false;
546
+ if (platform === "win32") return actual.replaceAll("\\", "/") === expected.replaceAll("\\", "/");
547
+ return actual === expected;
548
+ }
453
549
  function isEmptyDir(path) {
454
550
  try {
455
551
  return lstatSync(path).isDirectory() && readdirSync$1(path).length === 0;
@@ -526,7 +622,7 @@ function detectConflict(claudeSkillsPath, expectedTarget) {
526
622
  if (!existsSync$1(claudeSkillsPath) && !isSymlink(claudeSkillsPath)) return { kind: "none" };
527
623
  if (isSymlink(claudeSkillsPath)) {
528
624
  const target = symlinkTarget(claudeSkillsPath);
529
- if (target === expectedTarget) return {
625
+ if (sameLinkTarget(target, expectedTarget)) return {
530
626
  kind: "correct-symlink",
531
627
  currentTarget: target ?? void 0
532
628
  };
@@ -581,10 +677,35 @@ async function planLink(opts) {
581
677
  default: return "skip";
582
678
  }
583
679
  }
680
+ var SymlinkUnavailableError = class extends Error {
681
+ constructor(cause) {
682
+ super(`cannot create symlinks here: ${cause instanceof Error ? cause.message : String(cause)}`);
683
+ this.name = "SymlinkUnavailableError";
684
+ }
685
+ };
686
+ /** Create and remove a throwaway link so a failure surfaces before anything is deleted. */
687
+ function probeSymlink(root) {
688
+ const probe = join(root, ".claude", `.lw-link-probe-${process.pid}`);
689
+ try {
690
+ createSymlink("probe-target", probe);
691
+ } catch (e) {
692
+ throw new SymlinkUnavailableError(e);
693
+ }
694
+ try {
695
+ unlinkSync(probe);
696
+ } catch {}
697
+ }
584
698
  /** Carry out a planned action. Returns whether anything changed. */
585
699
  function applyLink(root, action, dryRun) {
586
700
  const claudeSkillsPath = join(root, ".claude", "skills");
587
701
  const agentsSkillsPath = join(root, ".agents", "skills");
702
+ if (!dryRun && [
703
+ "create",
704
+ "repoint",
705
+ "replace-empty",
706
+ "merge",
707
+ "replace"
708
+ ].includes(action)) probeSymlink(root);
588
709
  switch (action) {
589
710
  case "create":
590
711
  if (dryRun) {
@@ -619,7 +740,13 @@ function applyLink(root, action, dryRun) {
619
740
  case "merge":
620
741
  case "replace":
621
742
  if (dryRun) return false;
622
- if (action === "merge") mergeIntoAgents(claudeSkillsPath, agentsSkillsPath);
743
+ if (action === "merge") {
744
+ const { copied, conflicts } = mergeIntoAgents(claudeSkillsPath, agentsSkillsPath);
745
+ if (conflicts.length > 0) {
746
+ log.warn(`Kept .claude/skills/ (differs from .agents/skills/: ${conflicts.join(", ")}); symlink skipped`);
747
+ return copied > 0;
748
+ }
749
+ }
623
750
  removeDir(claudeSkillsPath);
624
751
  createSymlink(RELATIVE_TARGET, claudeSkillsPath);
625
752
  log.success(action === "merge" ? "Merged existing skills and created symlink" : "Replaced .claude/skills/ with symlink");
@@ -631,33 +758,74 @@ function applyLink(root, action, dryRun) {
631
758
  }
632
759
  function mergeIntoAgents(source, dest) {
633
760
  ensureDir(dest);
761
+ let copied = 0;
762
+ const conflicts = [];
634
763
  for (const entry of readdirSync$1(source)) {
635
764
  const srcPath = join(source, entry);
636
765
  const destPath = join(dest, entry);
637
- if (!existsSync$1(destPath)) {
766
+ if (!lstatSync(destPath, { throwIfNoEntry: false })) {
638
767
  cpSync(srcPath, destPath, { recursive: true });
768
+ copied++;
639
769
  log.dim(` Merged ${entry}`);
640
- } else log.dim(` Skipped ${entry} (already exists in .agents/skills/)`);
770
+ } else if (!sameEntry(srcPath, destPath)) conflicts.push(entry);
771
+ }
772
+ return {
773
+ copied,
774
+ conflicts
775
+ };
776
+ }
777
+ /** Structural equality without following symlinks. */
778
+ function sameEntry(a, b) {
779
+ const sa = lstatSync(a, { throwIfNoEntry: false });
780
+ const sb = lstatSync(b, { throwIfNoEntry: false });
781
+ if (!sa || !sb) return false;
782
+ if (sa.isSymbolicLink() || sb.isSymbolicLink()) return sa.isSymbolicLink() && sb.isSymbolicLink() && readlinkSync(a) === readlinkSync(b);
783
+ if (sa.isDirectory() && sb.isDirectory()) {
784
+ const na = readdirSync$1(a).sort();
785
+ const nb = readdirSync$1(b).sort();
786
+ return na.length === nb.length && na.every((n, i) => n === nb[i] && sameEntry(join(a, n), join(b, n)));
641
787
  }
788
+ if (sa.isFile() && sb.isFile()) return readFileSync(a).equals(readFileSync(b));
789
+ return false;
642
790
  }
643
791
  // src/install/install.ts
644
792
  /** Compute hook wiring results without writing. Throws SettingsParseError on malformed files. */
645
793
  function planWiring(targets, opts) {
646
- if (!opts.hook) return [];
647
794
  const read = (f) => existsSync(f) ? readFileSync(f, "utf8") : "";
648
- const cs = read(targets.claudeSettingsPath);
649
- const cc = read(targets.codexConfigPath);
650
- return [{
651
- file: targets.claudeSettingsPath,
652
- kind: "claude-hooks",
653
- cur: cs,
654
- out: mergeClaudeHooks(cs, hookSpecs("claude"), (s) => hookCommand("claude", targets, s.script), targets.claudeSettingsPath)
655
- }, {
656
- file: targets.codexConfigPath,
657
- kind: "codex-block",
658
- cur: cc,
659
- out: upsertCodexBlock(cc, renderCodexHookBlock(hookSpecs("codex"), (s) => hookCommand("codex", targets, s.script)))
660
- }];
795
+ const plans = [];
796
+ if (opts.hook) {
797
+ const cs = read(targets.claudeSettingsPath);
798
+ const cc = read(targets.codexConfigPath);
799
+ plans.push({
800
+ file: targets.claudeSettingsPath,
801
+ kind: "claude-hooks",
802
+ managed: true,
803
+ cur: cs,
804
+ out: mergeClaudeHooks(cs, hookSpecs("claude"), (s) => hookCommand("claude", targets, s.script), targets.claudeSettingsPath)
805
+ }, {
806
+ file: targets.codexConfigPath,
807
+ kind: "codex-block",
808
+ managed: true,
809
+ cur: cc,
810
+ out: upsertCodexBlock(cc, renderCodexHookBlock(hookSpecs("codex"), (s) => hookCommand("codex", targets, s.script)))
811
+ });
812
+ }
813
+ const jc = read(targets.junieConfigPath);
814
+ if (opts.experimental?.includes("junie-hooks")) plans.push({
815
+ file: targets.junieConfigPath,
816
+ kind: "junie-hooks",
817
+ managed: true,
818
+ cur: jc,
819
+ out: upsertJunieHooks(jc, hookSpecs("junie"), (s) => hookCommand("junie", targets, s.script), targets.junieConfigPath)
820
+ });
821
+ else if (jc.includes("loopwright/hooks/")) plans.push({
822
+ file: targets.junieConfigPath,
823
+ kind: "junie-hooks",
824
+ managed: false,
825
+ cur: jc,
826
+ out: removeJunieHooks(jc, MANAGED_HOOK_HINT, targets.junieConfigPath)
827
+ });
828
+ return plans;
661
829
  }
662
830
  /** Install every file under content/ plus agents and hook wiring. Returns whether anything changed. */
663
831
  async function installAll(targets, writer, config, opts, link = "skip") {
@@ -680,8 +848,9 @@ async function installAll(targets, writer, config, opts, link = "skip") {
680
848
  if (!f.endsWith(".md")) continue;
681
849
  const role = basename(f, ".md");
682
850
  const src = parseAgentSource(role, renderTemplate(readContent(`agents/${f}`), vars));
683
- await put(join(targets.claudeAgentsDir, `${src.name}.md`), renderClaudeAgent(src, config.models.claude[role] ?? "inherit"));
851
+ await put(join(targets.claudeAgentsDir, `${src.name}.md`), renderClaudeAgent(src, config.models.claude[role] ?? "inherit", config.models.claude.effort?.[role]));
684
852
  await put(join(targets.codexAgentsDir, `${src.name}.toml`), renderCodexAgent(src, config.models.codex[role] ?? "inherit", config.models.codex.effort?.[role]));
853
+ await put(join(targets.junieAgentsDir, `${src.name}.md`), renderJunieAgent(src, config.models.junie[role] ?? "inherit", config.models.junie.effort?.[role], targets.lwHomeRef));
685
854
  }
686
855
  for (const sub of [
687
856
  "hooks",
@@ -691,12 +860,15 @@ async function installAll(targets, writer, config, opts, link = "skip") {
691
860
  const raw = readContent(`${sub}/${f}`);
692
861
  await put(join(targets.lwHome, sub, f), sub === "hooks" ? raw : renderTemplate(raw, vars));
693
862
  }
694
- if (targets.claudeSkillsMode === "symlink") {
863
+ if (targets.claudeSkillsMode === "symlink") try {
695
864
  if (applyLink(targets.root, link, opts.dryRun)) changed = true;
865
+ } catch (e) {
866
+ if (!(e instanceof SymlinkUnavailableError)) throw e;
867
+ log.warn(`${e.message}; leaving .claude/skills as-is (enable Developer Mode or run elevated on Windows)`);
696
868
  }
697
- if (!opts.hook) writer.carryPriorConfig();
869
+ if (!opts.hook) writer.carryPriorConfig(["claude-hooks", "codex-block"]);
698
870
  for (const w of wiring) {
699
- writer.recordConfig({
871
+ if (w.managed) writer.recordConfig({
700
872
  file: w.file,
701
873
  kind: w.kind
702
874
  });
@@ -740,7 +912,9 @@ function withRecordedOptions(opts, recorded) {
740
912
  return {
741
913
  ...opts,
742
914
  hook: opts.explicit?.hook ? opts.hook : recorded.hook,
743
- symlink: opts.explicit?.symlink ? opts.symlink : recorded.symlink
915
+ symlink: opts.explicit?.symlink ? opts.symlink : recorded.symlink,
916
+ experimental: opts.explicit?.experimental ? opts.experimental : recorded.experimental ?? [],
917
+ profile: opts.explicit?.profile ? opts.profile : recorded.profile
744
918
  };
745
919
  }
746
920
  /** Shared install flow for `init` and `update`. */
@@ -771,7 +945,7 @@ async function runInstall(opts, doneVerb, isInit = false) {
771
945
  return 1;
772
946
  }
773
947
  if (targets.mode === "repo" && targets.stateDir) scaffoldLoopwrightDir(targets.stateDir, opts.dryRun);
774
- const config = readConfig(targets.configPath);
948
+ const config = readConfig(targets.configPath, opts.profile);
775
949
  if (targets.mode === "global" && !opts.dryRun && !opts.force) {
776
950
  log.info("The following changes would be made to your user configuration:");
777
951
  const preview = {
@@ -790,12 +964,20 @@ async function runInstall(opts, doneVerb, isInit = false) {
790
964
  ...writer.result(),
791
965
  options: {
792
966
  hook: opts.hook,
793
- symlink: opts.symlink
967
+ symlink: opts.symlink,
968
+ ...opts.experimental?.length ? { experimental: opts.experimental } : {},
969
+ ...opts.profile ? { profile: opts.profile } : {}
794
970
  }
795
971
  });
796
972
  if (!changed) log.success("loopwright is already up to date.");
797
973
  else if (!opts.dryRun) log.success(`loopwright ${doneVerb}.`);
798
974
  if (targets.mode === "repo" && opts.hook) log.info("Codex: trust this project and approve loopwright hooks via /hooks.");
975
+ log.info("Junie (WIP/EAP): subagents installed to .junie/agents; skills are read from .agents/skills.");
976
+ if (opts.profile) log.info(`Effort profile: ${opts.profile}. Claude Code can also set it per task at Plan; run \`npx loopwright update\` after changing it.`);
977
+ for (const f of opts.experimental ?? []) {
978
+ log.warn(`Experimental feature "${f}" is unstable and may change or break.`);
979
+ if (f === "junie-hooks") log.info(`Junie hooks are written to ${targets.junieConfigPath}. Junie ignores project hooks unless started with --config-location (e.g. junie --config-location .junie).`);
980
+ }
799
981
  return 0;
800
982
  } catch (e) {
801
983
  if (e instanceof SettingsParseError) {
@@ -864,12 +1046,15 @@ async function runUninstall(opts) {
864
1046
  for (const c of manifest.config) configs.set(resolve(abs(c.file)), c.kind);
865
1047
  configs.set(resolve(targets.claudeSettingsPath), "claude-hooks");
866
1048
  configs.set(resolve(targets.codexConfigPath), "codex-block");
1049
+ configs.set(resolve(targets.junieConfigPath), "junie-hooks");
867
1050
  for (const [file, kind] of configs) {
868
1051
  if (!existsSync(file)) continue;
869
1052
  const cur = readFileSync(file, "utf-8");
870
1053
  let out;
871
1054
  try {
872
- out = kind === "claude-hooks" ? removeClaudeHooks(cur, "loopwright/hooks/", file) : removeCodexBlock(cur);
1055
+ if (kind === "claude-hooks") out = removeClaudeHooks(cur, "loopwright/hooks/", file);
1056
+ else if (kind === "junie-hooks") out = removeJunieHooks(cur, "loopwright/hooks/", file);
1057
+ else out = removeCodexBlock(cur);
873
1058
  } catch (e) {
874
1059
  if (e instanceof SettingsParseError) {
875
1060
  log.warn(`left ${file} untouched: ${e.message}`);
@@ -880,10 +1065,10 @@ async function runUninstall(opts) {
880
1065
  if (out === cur) continue;
881
1066
  log.dim(` ${dry ? "Would update" : "Updated"} ${file}`);
882
1067
  if (dry) continue;
883
- writeFileSync(file, kind === "claude-hooks" && out.trim() === "{}" ? "{}\n" : out, "utf-8");
1068
+ writeFileSync(file, kind !== "codex-block" && out.trim() === "{}" ? "{}\n" : out, "utf-8");
884
1069
  }
885
1070
  const link = targets.claudeSkillsDir;
886
- if (lstatSync(link, { throwIfNoEntry: false })?.isSymbolicLink() && readlinkSync(link) === "../.agents/skills") {
1071
+ if (lstatSync(link, { throwIfNoEntry: false })?.isSymbolicLink() && sameLinkTarget(symlinkTarget(link), "../.agents/skills")) {
887
1072
  log.dim(` ${would} ${link}`);
888
1073
  if (!dry) {
889
1074
  unlinkSync(link);
@@ -908,7 +1093,7 @@ async function runUninstall(opts) {
908
1093
  return 0;
909
1094
  }
910
1095
  // src/cli.ts
911
- const HELP = `loopwright - agent workflow installer for Claude Code and Codex
1096
+ const HELP = `loopwright - agent workflow installer for Claude Code, Codex and Junie (WIP)
912
1097
 
913
1098
  Usage:
914
1099
  loopwright init Install the workflow into the current repo (or globally)
@@ -920,6 +1105,14 @@ Options:
920
1105
  --global Install into the user home instead of the current repo
921
1106
  --no-hook Skip hook wiring
922
1107
  --no-symlink Skip the .claude/skills symlink
1108
+ --experimental <names>
1109
+ Enable unstable features (comma-separated, or 'all'): ${EXPERIMENTAL_FEATURES.join(", ")}.
1110
+ junie-hooks: wire Junie CLI hooks (Early Access; needs --config-location).
1111
+ update keeps the recorded list; --experimental '' turns all off
1112
+ --profile <name>
1113
+ Effort profile for the subagents: ${PROFILE_NAMES.join(", ")} (default balanced).
1114
+ Per-task profiles are chosen at Plan on Claude Code; this is the install-time
1115
+ default (and the only setting for Junie). update keeps the recorded profile
923
1116
  --dry-run Show what would change without writing
924
1117
  --force Overwrite conflicting files without prompting
925
1118
  -v, --version Print version
@@ -956,6 +1149,8 @@ async function main(argv) {
956
1149
  type: "boolean",
957
1150
  default: false
958
1151
  },
1152
+ experimental: { type: "string" },
1153
+ profile: { type: "string" },
959
1154
  version: {
960
1155
  type: "boolean",
961
1156
  short: "v",
@@ -982,6 +1177,17 @@ async function main(argv) {
982
1177
  console.log(HELP);
983
1178
  return 0;
984
1179
  }
1180
+ let experimental = [];
1181
+ try {
1182
+ if (values.experimental !== void 0) experimental = parseExperimental(values.experimental);
1183
+ } catch (err) {
1184
+ console.error(err.message);
1185
+ return 1;
1186
+ }
1187
+ if (values.profile !== void 0 && !PROFILE_NAMES.includes(values.profile)) {
1188
+ console.error(`Invalid --profile ${JSON.stringify(values.profile)} (allowed: ${PROFILE_NAMES.join(", ")})`);
1189
+ return 1;
1190
+ }
985
1191
  const opts = {
986
1192
  mode: values.global ? "global" : "repo",
987
1193
  cwd: process.cwd(),
@@ -990,9 +1196,13 @@ async function main(argv) {
990
1196
  force: values.force,
991
1197
  hook: !values["no-hook"],
992
1198
  symlink: !values["no-symlink"],
1199
+ experimental,
1200
+ profile: values.profile,
993
1201
  explicit: {
994
1202
  hook: values["no-hook"],
995
- symlink: values["no-symlink"]
1203
+ symlink: values["no-symlink"],
1204
+ experimental: values.experimental !== void 0,
1205
+ profile: values.profile !== void 0
996
1206
  }
997
1207
  };
998
1208
  switch (command) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "loopwright",
3
3
  "author": "Xuan Son Trinh",
4
- "version": "0.1.1",
5
- "description": "Agent workflow installer for Claude Code and Codex",
4
+ "version": "0.1.3",
5
+ "description": "Agent workflow installer for Claude Code, Codex and Junie",
6
6
  "type": "module",
7
7
  "bin": {
8
8
  "loopwright": "./dist/cli.js"
@@ -17,7 +17,9 @@
17
17
  "pretest": "npm run build",
18
18
  "test": "vitest run",
19
19
  "dev": "npm run build && node dist/cli.js",
20
- "prepublishOnly": "npm run build"
20
+ "prepublishOnly": "npm run build",
21
+ "format": "prettier --write .",
22
+ "format:check": "prettier --check ."
21
23
  },
22
24
  "files": [
23
25
  "dist/",
@@ -34,11 +36,12 @@
34
36
  ],
35
37
  "license": "MIT",
36
38
  "devDependencies": {
37
- "@types/node": "^25.5.0",
39
+ "@types/node": "^22.20.5",
40
+ "prettier": "^3.9.10",
38
41
  "smol-toml": "^1.9.1",
39
42
  "tsdown": "^0.23.7",
40
- "typescript": "^5.7.0",
43
+ "typescript": "^7.0.2",
41
44
  "unrun": "^0.3.1",
42
- "vitest": "^3.0.0"
45
+ "vitest": "^5.1.0"
43
46
  }
44
47
  }