refactor: hard-fork GSD -> MSD (Make Software Done)
Mechanical rename produced by scripts/msd-rename.cjs: gsd/Gsd/GSD -> msd/Msd/MSD across contents and paths, upstream package/repo coordinates -> @golem15/msd-core and golem15com/msd-core. Deep links into upstream history, sibling upstream packages, the GSD-2 import feature, CHANGELOG.md and .changeset/ are kept as-is. Hand edits on top: MSD block-letter banner and logos, LICENSE copyright line, package/plugin identity, regenerated lockfile, install-tree fixtures, derived registries and benchmark baseline; migration checksum baseline re-locked (MSD keeps its own install state, so no install had applied the old sums); sort-order and regex-escaped expectations in tests adjusted.
This commit is contained in:
57
hooks/msd-cursor-session-start.js
Normal file
57
hooks/msd-cursor-session-start.js
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env node
|
||||
// msd-hook-version: {{MSD_VERSION}}
|
||||
// msd-cursor-session-start.js — Cursor sessionStart hook (issue #777)
|
||||
//
|
||||
// Cursor invokes this script at the start of each agent session.
|
||||
// Protocol: JSON from Cursor on stdin; JSON response on stdout.
|
||||
//
|
||||
// Input schema (cursor sessionStart):
|
||||
// { session_id, is_background_agent, composer_mode, conversation_id,
|
||||
// generation_id, model, hook_event_name, cursor_version,
|
||||
// workspace_roots, user_email, transcript_path }
|
||||
//
|
||||
// Output schema (cursor sessionStart):
|
||||
// { additional_context?: string } ← injected into the session as context
|
||||
//
|
||||
// Behaviour:
|
||||
// - If .planning/STATE.md is present, injects a brief state reminder.
|
||||
// - If absent, nudges the user toward /msd:new-project.
|
||||
// - Fails open: any error silently exits 0 so a hook bug never wedges Cursor.
|
||||
//
|
||||
// Cursor docs: https://cursor.com/docs/hooks
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const { allow } = require('./lib/hook-exit.js');
|
||||
|
||||
const MSG_PRESENT =
|
||||
'MSD: .planning/STATE.md is present — review the current phase and any blockers before acting.';
|
||||
const MSG_ABSENT =
|
||||
'MSD: no .planning/ workflow found — run /msd:new-project to start a tracked workflow.';
|
||||
|
||||
// Workspace resolution is shared across the Cursor hooks (#2587) — see
|
||||
// hooks/lib/cursor-workspace.js. Staged next to these scripts by
|
||||
// writeCursorHooksJson so the require always resolves post-install.
|
||||
const { resolveStatePath } = require('./lib/cursor-workspace.js');
|
||||
|
||||
let raw = '';
|
||||
const stdinTimeout = setTimeout(() => {
|
||||
// Timeout guard: exit silently rather than hanging.
|
||||
allow(undefined);
|
||||
}, 10000);
|
||||
|
||||
process.stdin.setEncoding('utf8');
|
||||
process.stdin.on('data', (chunk) => { raw += chunk; });
|
||||
process.stdin.on('end', () => {
|
||||
clearTimeout(stdinTimeout);
|
||||
try {
|
||||
const statePath = resolveStatePath(raw);
|
||||
const statePresent = fs.existsSync(statePath);
|
||||
const msg = statePresent ? MSG_PRESENT : MSG_ABSENT;
|
||||
process.stdout.write(JSON.stringify({ additional_context: msg }));
|
||||
} catch {
|
||||
// Fail open — never block a Cursor session because of a MSD hook error.
|
||||
process.stdout.write(JSON.stringify({}));
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user