@cogit/cli 0.18.1 → 0.19.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cogit",
3
3
  "displayName": "cogit",
4
- "version": "0.18.1",
4
+ "version": "0.19.0",
5
5
  "description": "Git remembers what changed. cogit remembers why.",
6
6
  "author": {
7
7
  "name": "Eren Sertkaya"
@@ -20875,11 +20875,42 @@ function hasGuard(settings) {
20875
20875
  const hooks = isObject2(settings.hooks) ? settings.hooks.UserPromptSubmit : void 0;
20876
20876
  return JSON.stringify(hooks ?? []).includes(GUARD_TAG);
20877
20877
  }
20878
+ function hasCurrentGuard(settings) {
20879
+ const hooks = isObject2(settings.hooks) ? settings.hooks.UserPromptSubmit : void 0;
20880
+ return JSON.stringify(hooks ?? []).includes(JSON.stringify(GUARD_COMMAND));
20881
+ }
20882
+ function withCurrentGuard(submit) {
20883
+ return [
20884
+ ...submit.filter((entry) => !JSON.stringify(entry).includes(GUARD_TAG)),
20885
+ { hooks: [{ type: "command", command: GUARD_COMMAND, timeout: 5 }] }
20886
+ ];
20887
+ }
20878
20888
  async function readProjectSetup(root) {
20879
20889
  const settings = await readSettings(projectSettingsPath(root));
20880
20890
  if (!settings) return void 0;
20881
20891
  const plugins = isObject2(settings.enabledPlugins) ? settings.enabledPlugins : {};
20882
- return plugins[PLUGIN_ID] === true && hasGuard(settings);
20892
+ return plugins[PLUGIN_ID] === true && hasCurrentGuard(settings);
20893
+ }
20894
+ async function refreshProjectSetup(root) {
20895
+ const file2 = projectSettingsPath(root);
20896
+ const settings = await readSettings(file2);
20897
+ if (!settings || !isObject2(settings.hooks)) return void 0;
20898
+ const submit = settings.hooks.UserPromptSubmit;
20899
+ const marketplaces = isObject2(settings.extraKnownMarketplaces) ? settings.extraKnownMarketplaces : void 0;
20900
+ const ours = marketplaces?.[MARKETPLACE];
20901
+ const staleGuard = Array.isArray(submit) && hasGuard(settings) && !hasCurrentGuard(settings);
20902
+ const staleMarketplace = isObject2(ours) && isObject2(ours.source) && ours.source.source === "github" && ours.source.repo !== MARKETPLACE_REPO;
20903
+ if (!staleGuard && !staleMarketplace) return void 0;
20904
+ const next = { ...settings };
20905
+ if (staleGuard)
20906
+ next.hooks = { ...settings.hooks, UserPromptSubmit: withCurrentGuard(submit) };
20907
+ if (staleMarketplace)
20908
+ next.extraKnownMarketplaces = {
20909
+ ...marketplaces,
20910
+ [MARKETPLACE]: { source: { source: "github", repo: MARKETPLACE_REPO } }
20911
+ };
20912
+ await atomicWriteJson(file2, next);
20913
+ return file2;
20883
20914
  }
20884
20915
  async function writeProjectSetup(root) {
20885
20916
  const file2 = projectSettingsPath(root);
@@ -20899,13 +20930,7 @@ async function writeProjectSetup(root) {
20899
20930
  ...settings.extraKnownMarketplaces,
20900
20931
  [MARKETPLACE]: { source: { source: "github", repo: MARKETPLACE_REPO } }
20901
20932
  },
20902
- hooks: hasGuard(settings) ? hooks : {
20903
- ...hooks,
20904
- UserPromptSubmit: [
20905
- ...submit,
20906
- { hooks: [{ type: "command", command: GUARD_COMMAND, timeout: 5 }] }
20907
- ]
20908
- }
20933
+ hooks: hasCurrentGuard(settings) ? hooks : { ...hooks, UserPromptSubmit: withCurrentGuard(submit) }
20909
20934
  };
20910
20935
  await mkdir3(join5(root, ".claude"), { recursive: true });
20911
20936
  await atomicWriteJson(file2, next);
@@ -21229,6 +21254,7 @@ var claude = {
21229
21254
  allowSkill,
21230
21255
  readProjectSetup,
21231
21256
  writeProjectSetup,
21257
+ refreshProjectSetup,
21232
21258
  markLive
21233
21259
  };
21234
21260
 
package/dist/cli.js CHANGED
@@ -79,7 +79,7 @@ import {
79
79
  updateState,
80
80
  upgradeSessionIds,
81
81
  withLock
82
- } from "./chunk-3FDYKXX3.js";
82
+ } from "./chunk-5MM3O5LE.js";
83
83
 
84
84
  // ../../node_modules/cli-width/index.js
85
85
  var require_cli_width = __commonJS({
@@ -3618,7 +3618,7 @@ var program = new Command();
3618
3618
  // package.json
3619
3619
  var package_default = {
3620
3620
  name: "@cogit/cli",
3621
- version: "0.18.1",
3621
+ version: "0.19.0",
3622
3622
  description: "Git remembers what changed. cogit remembers why.",
3623
3623
  license: "MIT",
3624
3624
  keywords: [
@@ -5737,7 +5737,7 @@ async function migrateProject(root) {
5737
5737
  const next = renameGitignoreLines(text);
5738
5738
  if (next !== text) await atomicWrite(gitignore, next).catch(() => void 0);
5739
5739
  }
5740
- const { installGitHooks: installGitHooks2 } = await import("./git-hooks-MBUVWXP3.js");
5740
+ const { installGitHooks: installGitHooks2 } = await import("./git-hooks-NUO4CPYK.js");
5741
5741
  await installGitHooks2(dir).catch(() => void 0);
5742
5742
  return true;
5743
5743
  }
@@ -7962,6 +7962,10 @@ async function init(dir, opts, io) {
7962
7962
  await register(io, root, existing.data.name);
7963
7963
  if (opts.allowSkill !== void 0) await askSkillPermission(io, opts);
7964
7964
  if (opts.projectSettings !== void 0) await askProjectSettings(io, root, opts);
7965
+ await bestEffort(io, "could not refresh the project's Claude Code settings", async () => {
7966
+ const file = await agent2.refreshProjectSetup(root);
7967
+ if (file) io.out(`Updated the cogit guard and marketplace in ${file}.`);
7968
+ });
7965
7969
  await refreshGitIntegration(io, root);
7966
7970
  io.out(`Already initialized: ${existing.data.name} (${root})`);
7967
7971
  return;
@@ -15,7 +15,7 @@ import {
15
15
  uninstallGitHooks,
16
16
  withHookBlock,
17
17
  withoutHookBlock
18
- } from "./chunk-3FDYKXX3.js";
18
+ } from "./chunk-5MM3O5LE.js";
19
19
  export {
20
20
  BLOCK_END,
21
21
  BLOCK_START,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cogit/cli",
3
- "version": "0.18.1",
3
+ "version": "0.19.0",
4
4
  "description": "Git remembers what changed. cogit remembers why.",
5
5
  "license": "MIT",
6
6
  "keywords": [