@cogit/cli 0.18.1 → 0.19.1

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.1",
5
5
  "description": "Git remembers what changed. cogit remembers why.",
6
6
  "author": {
7
7
  "name": "Eren Sertkaya"
@@ -20844,6 +20844,15 @@ var PLUGIN_ID = "cogit@cogit";
20844
20844
  var MARKETPLACE = "cogit";
20845
20845
  var MARKETPLACE_REPO = "erensrtky/cogit";
20846
20846
  var INSTALL_COMMAND = `claude plugin install cogit --marketplace ${MARKETPLACE_REPO}`;
20847
+ async function readPluginInstalled(env) {
20848
+ const base = env.CLAUDE_CONFIG_DIR ?? join5(homedir2(), ".claude");
20849
+ const read = await readJson(join5(base, "plugins", "installed_plugins.json"));
20850
+ if (!read.found || "error" in read) return void 0;
20851
+ const plugins = isObject2(read.value) ? read.value.plugins : void 0;
20852
+ if (!isObject2(plugins)) return void 0;
20853
+ const entries = plugins[PLUGIN_ID];
20854
+ return Array.isArray(entries) && entries.length > 0;
20855
+ }
20847
20856
  function liveDir() {
20848
20857
  return join5(tmpdir(), "cogit-live");
20849
20858
  }
@@ -20875,11 +20884,42 @@ function hasGuard(settings) {
20875
20884
  const hooks = isObject2(settings.hooks) ? settings.hooks.UserPromptSubmit : void 0;
20876
20885
  return JSON.stringify(hooks ?? []).includes(GUARD_TAG);
20877
20886
  }
20887
+ function hasCurrentGuard(settings) {
20888
+ const hooks = isObject2(settings.hooks) ? settings.hooks.UserPromptSubmit : void 0;
20889
+ return JSON.stringify(hooks ?? []).includes(JSON.stringify(GUARD_COMMAND));
20890
+ }
20891
+ function withCurrentGuard(submit) {
20892
+ return [
20893
+ ...submit.filter((entry) => !JSON.stringify(entry).includes(GUARD_TAG)),
20894
+ { hooks: [{ type: "command", command: GUARD_COMMAND, timeout: 5 }] }
20895
+ ];
20896
+ }
20878
20897
  async function readProjectSetup(root) {
20879
20898
  const settings = await readSettings(projectSettingsPath(root));
20880
20899
  if (!settings) return void 0;
20881
20900
  const plugins = isObject2(settings.enabledPlugins) ? settings.enabledPlugins : {};
20882
- return plugins[PLUGIN_ID] === true && hasGuard(settings);
20901
+ return plugins[PLUGIN_ID] === true && hasCurrentGuard(settings);
20902
+ }
20903
+ async function refreshProjectSetup(root) {
20904
+ const file2 = projectSettingsPath(root);
20905
+ const settings = await readSettings(file2);
20906
+ if (!settings || !isObject2(settings.hooks)) return void 0;
20907
+ const submit = settings.hooks.UserPromptSubmit;
20908
+ const marketplaces = isObject2(settings.extraKnownMarketplaces) ? settings.extraKnownMarketplaces : void 0;
20909
+ const ours = marketplaces?.[MARKETPLACE];
20910
+ const staleGuard = Array.isArray(submit) && hasGuard(settings) && !hasCurrentGuard(settings);
20911
+ const staleMarketplace = isObject2(ours) && isObject2(ours.source) && ours.source.source === "github" && ours.source.repo !== MARKETPLACE_REPO;
20912
+ if (!staleGuard && !staleMarketplace) return void 0;
20913
+ const next = { ...settings };
20914
+ if (staleGuard)
20915
+ next.hooks = { ...settings.hooks, UserPromptSubmit: withCurrentGuard(submit) };
20916
+ if (staleMarketplace)
20917
+ next.extraKnownMarketplaces = {
20918
+ ...marketplaces,
20919
+ [MARKETPLACE]: { source: { source: "github", repo: MARKETPLACE_REPO } }
20920
+ };
20921
+ await atomicWriteJson(file2, next);
20922
+ return file2;
20883
20923
  }
20884
20924
  async function writeProjectSetup(root) {
20885
20925
  const file2 = projectSettingsPath(root);
@@ -20899,13 +20939,7 @@ async function writeProjectSetup(root) {
20899
20939
  ...settings.extraKnownMarketplaces,
20900
20940
  [MARKETPLACE]: { source: { source: "github", repo: MARKETPLACE_REPO } }
20901
20941
  },
20902
- hooks: hasGuard(settings) ? hooks : {
20903
- ...hooks,
20904
- UserPromptSubmit: [
20905
- ...submit,
20906
- { hooks: [{ type: "command", command: GUARD_COMMAND, timeout: 5 }] }
20907
- ]
20908
- }
20942
+ hooks: hasCurrentGuard(settings) ? hooks : { ...hooks, UserPromptSubmit: withCurrentGuard(submit) }
20909
20943
  };
20910
20944
  await mkdir3(join5(root, ".claude"), { recursive: true });
20911
20945
  await atomicWriteJson(file2, next);
@@ -21206,6 +21240,7 @@ var claude = {
21206
21240
  name: DEFAULT_AGENT,
21207
21241
  skill: "/cogit:record",
21208
21242
  skillRule: SKILL_RULE,
21243
+ installCommand: INSTALL_COMMAND,
21209
21244
  projectDirEnv: "CLAUDE_PROJECT_DIR",
21210
21245
  pluginRootEnv: "CLAUDE_PLUGIN_ROOT",
21211
21246
  sessionIdEnv: "CLAUDE_SESSION_ID",
@@ -21224,11 +21259,13 @@ var claude = {
21224
21259
  parseHookInput,
21225
21260
  additionalContext,
21226
21261
  readRetention,
21262
+ readPluginInstalled,
21227
21263
  readSkillAllowed,
21228
21264
  setRetention,
21229
21265
  allowSkill,
21230
21266
  readProjectSetup,
21231
21267
  writeProjectSetup,
21268
+ refreshProjectSetup,
21232
21269
  markLive
21233
21270
  };
21234
21271