codiedev 0.9.69 → 0.9.70

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/hook.js CHANGED
@@ -546,6 +546,7 @@ async function main() {
546
546
  // which is what makes a pnpm install safe to upgrade.
547
547
  if (migrated.length === 0)
548
548
  (0, selfUpdate_1.maybeSpawnSelfUpdate)(process.argv[1]);
549
+ (0, selfUpdate_1.maybeRefreshInstructions)();
549
550
  let hookInput = {};
550
551
  try {
551
552
  const raw = await readStdin();
@@ -38,6 +38,13 @@ export declare function readSelfUpdateState(): SelfUpdateState | null;
38
38
  * child, not one each; the child's lock covers whatever still slips through.
39
39
  */
40
40
  export declare function maybeSpawnSelfUpdate(hookEntry: string | undefined): void;
41
+ /**
42
+ * First hook call on a new CLI version (self-updated or installed by hand)
43
+ * re-renders the codiedev block in the harness instruction files, so they
44
+ * stop listing commands this version no longer has. The steady-state cost is
45
+ * one small file read. Honors the same opt-outs as the self-update.
46
+ */
47
+ export declare function maybeRefreshInstructions(refresh?: () => string[]): void;
41
48
  /**
42
49
  * Where the just-installed copy lives. npm/bun reinstall in place. pnpm's
43
50
  * `root -g` is <root>/node_modules up to v10 but the bare global/v11 parent
@@ -48,6 +48,7 @@ exports.planSelfUpdate = planSelfUpdate;
48
48
  exports.isSelfUpdateDue = isSelfUpdateDue;
49
49
  exports.readSelfUpdateState = readSelfUpdateState;
50
50
  exports.maybeSpawnSelfUpdate = maybeSpawnSelfUpdate;
51
+ exports.maybeRefreshInstructions = maybeRefreshInstructions;
51
52
  exports.findInstalledHookScript = findInstalledHookScript;
52
53
  exports.runSelfUpdate = runSelfUpdate;
53
54
  const fs = __importStar(require("fs"));
@@ -58,6 +59,7 @@ const versionCheck_1 = require("./versionCheck");
58
59
  const configDir_1 = require("./configDir");
59
60
  const captureLog_1 = require("./captureLog");
60
61
  const launcher_1 = require("./launcher");
62
+ const utils_1 = require("./utils");
61
63
  const PKG = "codiedev";
62
64
  const DAY_MS = 24 * 60 * 60 * 1000;
63
65
  const LOCK_STALE_MS = 10 * 60 * 1000;
@@ -161,6 +163,43 @@ function maybeSpawnSelfUpdate(hookEntry) {
161
163
  // Best-effort; a failed spawn retries tomorrow.
162
164
  }
163
165
  }
166
+ function instructionsVersionPath() {
167
+ return path.join((0, configDir_1.codiedevStateDir)(), ".instructions-version");
168
+ }
169
+ /**
170
+ * First hook call on a new CLI version (self-updated or installed by hand)
171
+ * re-renders the codiedev block in the harness instruction files, so they
172
+ * stop listing commands this version no longer has. The steady-state cost is
173
+ * one small file read. Honors the same opt-outs as the self-update.
174
+ */
175
+ function maybeRefreshInstructions(refresh = utils_1.refreshInstalledInstructions) {
176
+ if (process.env.CODIEDEV_NO_AUTO_UPDATE || process.env.CODIEDEV_NO_UPDATE_CHECK)
177
+ return;
178
+ try {
179
+ const marker = instructionsVersionPath();
180
+ try {
181
+ if (fs.readFileSync(marker, "utf8").trim() === version_1.CLI_VERSION)
182
+ return;
183
+ }
184
+ catch {
185
+ // No marker yet: first run on a version that ships this check.
186
+ }
187
+ const refreshed = refresh();
188
+ fs.mkdirSync((0, configDir_1.codiedevStateDir)(), { recursive: true });
189
+ fs.writeFileSync(marker, version_1.CLI_VERSION, "utf8");
190
+ if (refreshed.length > 0) {
191
+ (0, captureLog_1.appendCaptureLog)({
192
+ stage: "self-update",
193
+ sessionId: undefined,
194
+ outcome: "ok",
195
+ detail: `result=instructions-refreshed version=${version_1.CLI_VERSION} files=${refreshed.length}`,
196
+ });
197
+ }
198
+ }
199
+ catch {
200
+ // Best-effort; retried on the next hook call.
201
+ }
202
+ }
164
203
  function acquireLock() {
165
204
  const lock = lockPath();
166
205
  try {
package/dist/utils.d.ts CHANGED
@@ -129,6 +129,19 @@ export declare function installCodexInstructions(): void;
129
129
  export declare function copilotInstructionsPath(): string;
130
130
  export declare function installCopilotInstructions(): void;
131
131
  export declare function installCursorInstructions(): void;
132
+ export interface InstructionsTarget {
133
+ path: string;
134
+ body: string;
135
+ }
136
+ export declare function installedInstructionsTargets(): InstructionsTarget[];
137
+ /**
138
+ * Re-render the codiedev block in every instructions file that already has
139
+ * one, so an upgrade (background self-update or a manual `npm i`) stops
140
+ * teaching retired commands without the user re-running `connect`. Never
141
+ * creates a file or adds a block: a user who deleted it, or never connected
142
+ * that harness, is left alone. Returns the paths it rewrote.
143
+ */
144
+ export declare function refreshInstalledInstructions(targets?: InstructionsTarget[]): string[];
132
145
  /**
133
146
  * Install the Codiedev MCP server into Claude Code's user-scope config.
134
147
  * Safe to call multiple times — updates the existing entry if present.
package/dist/utils.js CHANGED
@@ -79,6 +79,8 @@ exports.installCodexInstructions = installCodexInstructions;
79
79
  exports.copilotInstructionsPath = copilotInstructionsPath;
80
80
  exports.installCopilotInstructions = installCopilotInstructions;
81
81
  exports.installCursorInstructions = installCursorInstructions;
82
+ exports.installedInstructionsTargets = installedInstructionsTargets;
83
+ exports.refreshInstalledInstructions = refreshInstalledInstructions;
82
84
  exports.installClaudeCodeMcp = installClaudeCodeMcp;
83
85
  exports.installCursorMcp = installCursorMcp;
84
86
  exports.installVSCodeMcp = installVSCodeMcp;
@@ -1645,6 +1647,45 @@ function installCursorInstructions() {
1645
1647
  }
1646
1648
  fs.writeFileSync(CURSOR_RULES_PATH, next, "utf8");
1647
1649
  }
1650
+ function installedInstructionsTargets() {
1651
+ const withTeamContext = `${teamSkillContext_1.TEAM_SKILL_CONTEXT}\n\n${CODIEDEV_INSTRUCTIONS_BODY}`;
1652
+ return [
1653
+ { path: CLAUDE_USER_INSTRUCTIONS_PATH, body: CODIEDEV_INSTRUCTIONS_BODY },
1654
+ { path: CODEX_USER_INSTRUCTIONS_PATH, body: CODIEDEV_INSTRUCTIONS_BODY },
1655
+ { path: copilotInstructionsPath(), body: withTeamContext },
1656
+ { path: CURSOR_RULES_PATH, body: withTeamContext },
1657
+ ];
1658
+ }
1659
+ /**
1660
+ * Re-render the codiedev block in every instructions file that already has
1661
+ * one, so an upgrade (background self-update or a manual `npm i`) stops
1662
+ * teaching retired commands without the user re-running `connect`. Never
1663
+ * creates a file or adds a block: a user who deleted it, or never connected
1664
+ * that harness, is left alone. Returns the paths it rewrote.
1665
+ */
1666
+ function refreshInstalledInstructions(targets = installedInstructionsTargets()) {
1667
+ const refreshed = [];
1668
+ for (const target of targets) {
1669
+ try {
1670
+ const existing = fs.readFileSync(target.path, "utf8");
1671
+ const beginIdx = existing.indexOf(CODIEDEV_INSTRUCTIONS_BEGIN);
1672
+ const endIdx = existing.indexOf(CODIEDEV_INSTRUCTIONS_END);
1673
+ if (beginIdx === -1 || endIdx === -1 || endIdx <= beginIdx)
1674
+ continue;
1675
+ const next = existing.slice(0, beginIdx) +
1676
+ `${CODIEDEV_INSTRUCTIONS_BEGIN}\n${target.body}\n${CODIEDEV_INSTRUCTIONS_END}` +
1677
+ existing.slice(endIdx + CODIEDEV_INSTRUCTIONS_END.length);
1678
+ if (next === existing)
1679
+ continue;
1680
+ fs.writeFileSync(target.path, next, "utf8");
1681
+ refreshed.push(target.path);
1682
+ }
1683
+ catch {
1684
+ // Missing or unreadable file: nothing of ours to refresh.
1685
+ }
1686
+ }
1687
+ return refreshed;
1688
+ }
1648
1689
  function readMcpConfigSafely(path) {
1649
1690
  if (!fs.existsSync(path))
1650
1691
  return {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codiedev",
3
- "version": "0.9.69",
3
+ "version": "0.9.70",
4
4
  "description": "Connect Claude Code, Codex, Cursor, OpenCode, or VS Code Copilot to Codiedev for team session capture and artifact collaboration — and run the governed Codie harness",
5
5
  "bin": {
6
6
  "codiedev": "dist/cli.js",