create-snipara 1.3.15 → 1.3.16

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.
Files changed (2) hide show
  1. package/dist/index.js +48 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -974,9 +974,10 @@ Agent task lifecycle:
974
974
  11. If \`git status --short\` is dirty, warn that Snipara's indexed code graph may not include local edits; use local reads/tests for exact edits and Snipara for architecture/code graph context.
975
975
  12. Use Snipara Sandbox only when sandboxed execution, repeatable validation, or isolated transformations materially help.
976
976
  13. If a broad query is slow, retry once with a narrow keyword query before falling back to local search.
977
- 14. End each substantial phase with \`snipara_end_of_task_commit\` or \`snipara-companion workflow phase-commit\` when companion manages the plan. End the whole managed workflow with \`snipara-companion final-commit\`.
978
- 15. Use \`snipara_remember_if_novel\` for one reusable memory while avoiding duplicates, and use \`snipara_remember\` for explicit direct memory writes.
979
- 16. Do not store secrets, tokens, passwords, private keys, raw logs, transient command output, or unreviewed guesses in memory.
977
+ 14. When generated hooks are enabled, \`snipara-companion pre-tool\`, \`post-tool\`, and \`stuck-guard status\` provide runtime Rescue Pack checks for repeated failures, empty searches, and risky workflows.
978
+ 15. End each substantial phase with \`snipara_end_of_task_commit\` or \`snipara-companion workflow phase-commit\` when companion manages the plan. End the whole managed workflow with \`snipara-companion final-commit\`.
979
+ 16. Use \`snipara_remember_if_novel\` for one reusable memory while avoiding duplicates, and use \`snipara_remember\` for explicit direct memory writes.
980
+ 17. Do not store secrets, tokens, passwords, private keys, raw logs, transient command output, or unreviewed guesses in memory.
980
981
  `;
981
982
  }
982
983
  function buildClaudeMdTemplate(answers) {
@@ -997,6 +998,7 @@ Use Snipara Hosted MCP before answering project-specific questions.
997
998
  - Check every \`snipara_code_*\` response for indexed commit SHA, indexing time, included files, coverage, and freshness warnings. Legacy \`rlm_code_*\` IDs return the same payloads.
998
999
  - Use local file reads, \`rg\`, \`git status --short\`, and tests for exact edits/current working tree; use Snipara for architecture and indexed code graph context.
999
1000
  - When the plan is visible and \`snipara-companion\` is installed, use \`snipara-companion workflow start\`, \`phase-start\`, \`phase-commit\`, \`workflow resume\`, and \`final-commit\` to keep phase state durable across compaction. Legacy \`rlm-hook\` commands remain compatible.
1001
+ - If generated hooks are enabled, \`snipara-companion pre-tool\`, \`post-tool\`, and \`stuck-guard status\` provide runtime Rescue Pack checks when the agent loops on failures or empty searches.
1000
1002
  - Use Snipara Sandbox only when sandboxed execution or repeatable validation materially helps.
1001
1003
  - End substantial work with \`snipara_end_of_task_commit\` when available; for managed workflows, end every phase with \`snipara-companion workflow phase-commit\` and the task with \`snipara-companion final-commit\`.
1002
1004
  - Use \`snipara_remember_if_novel\` or \`snipara_remember\` only for narrow durable memories.
@@ -1026,6 +1028,7 @@ This workspace uses Snipara Hosted MCP for current project context, business/cli
1026
1028
  - Use \`snipara_plan\` or \`snipara_decompose\` only for complex work and only when available.
1027
1029
  - Use local file reads, \`rg\`, \`git status --short\`, and tests for exact code edits and current working-tree state.
1028
1030
  - When \`snipara-companion\` is installed and the LLM has a visible multi-phase plan, use \`snipara-companion workflow start\`, \`phase-start\`, \`phase-commit\`, \`workflow resume\`, and \`final-commit\` so the next phase survives compaction. Legacy \`rlm-hook\` commands remain compatible.
1031
+ - Generated hooks can call \`snipara-companion pre-tool\`, \`post-tool\`, and \`stuck-guard status\` so Rescue Packs are runtime-triggered rather than relying only on instructions.
1029
1032
  - Use Snipara Sandbox only when sandboxed execution or repeatable validation materially helps.
1030
1033
  - End substantial work with \`snipara_end_of_task_commit\` when available; for managed workflows, end every phase with \`snipara-companion workflow phase-commit\` and the task with \`snipara-companion final-commit\`. Use \`snipara_remember_if_novel\` or \`snipara_remember\` only for narrow durable memories. Never store secrets.
1031
1034
  `;
@@ -1121,6 +1124,10 @@ async function installClaudeCodeHooks(answers) {
1121
1124
  fs.mkdirSync(hooksDir, { recursive: true });
1122
1125
  }
1123
1126
  const hooks = [
1127
+ {
1128
+ name: "snipara-stuck-guard.sh",
1129
+ content: createStuckGuardHook(answers)
1130
+ },
1124
1131
  {
1125
1132
  name: "snipara-startup.sh",
1126
1133
  content: createStartupHook(answers)
@@ -1152,6 +1159,11 @@ async function installClaudeCodeHooks(answers) {
1152
1159
  settings.hooks = settings.hooks || {};
1153
1160
  const hooksConfig = settings.hooks;
1154
1161
  const hookEntries = [
1162
+ {
1163
+ event: "PreToolUse",
1164
+ script: path.join(hooksDir, "snipara-stuck-guard.sh"),
1165
+ matcher: { tool_name: "Bash|Read|Grep|Glob|Edit|MultiEdit|Write" }
1166
+ },
1155
1167
  {
1156
1168
  event: "PreToolUse",
1157
1169
  script: path.join(hooksDir, "snipara-startup.sh"),
@@ -1160,7 +1172,7 @@ async function installClaudeCodeHooks(answers) {
1160
1172
  {
1161
1173
  event: "PostToolUse",
1162
1174
  script: path.join(hooksDir, "snipara-session.sh"),
1163
- matcher: { tool_name: "Bash" }
1175
+ matcher: { tool_name: "Bash|Read|Grep|Glob|Edit|MultiEdit|Write" }
1164
1176
  },
1165
1177
  {
1166
1178
  event: "PreCompact",
@@ -1180,6 +1192,26 @@ async function installClaudeCodeHooks(answers) {
1180
1192
  fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
1181
1193
  console.log(chalk.green(" \u2713 Updated ~/.claude/settings.json"));
1182
1194
  }
1195
+ function createStuckGuardHook(answers) {
1196
+ return `#!/usr/bin/env bash
1197
+ set -euo pipefail
1198
+
1199
+ export SNIPARA_PROJECT_SLUG="${answers.projectSlug}"
1200
+ ${answers.projectId ? `export SNIPARA_PROJECT_ID="${answers.projectId}"` : ""}
1201
+
1202
+ SNIPARA_COMPANION_BIN=""
1203
+ if command -v ${COMPANION_COMMAND_NAME} >/dev/null 2>&1; then
1204
+ SNIPARA_COMPANION_BIN="${COMPANION_COMMAND_NAME}"
1205
+ elif command -v ${LEGACY_COMPANION_COMMAND_NAME} >/dev/null 2>&1; then
1206
+ SNIPARA_COMPANION_BIN="${LEGACY_COMPANION_COMMAND_NAME}"
1207
+ fi
1208
+
1209
+ if [ -n "$SNIPARA_COMPANION_BIN" ]; then
1210
+ INPUT=$(cat || true)
1211
+ "$SNIPARA_COMPANION_BIN" pre-tool "$INPUT" || true
1212
+ fi
1213
+ `;
1214
+ }
1183
1215
  function createStartupHook(answers) {
1184
1216
  return `#!/usr/bin/env bash
1185
1217
  set -euo pipefail
@@ -1218,7 +1250,8 @@ elif command -v ${LEGACY_COMPANION_COMMAND_NAME} >/dev/null 2>&1; then
1218
1250
  fi
1219
1251
 
1220
1252
  if [ -n "$SNIPARA_COMPANION_BIN" ]; then
1221
- "$SNIPARA_COMPANION_BIN" emit-event --event-type tool_result --json '{"source":"claude-code-hook"}' || true
1253
+ INPUT=$(cat || true)
1254
+ "$SNIPARA_COMPANION_BIN" post-tool "$INPUT" || true
1222
1255
  fi
1223
1256
  `;
1224
1257
  }
@@ -1431,6 +1464,16 @@ function getCompanionCommands(answers) {
1431
1464
  command: `${COMPANION_COMMAND_NAME} session-bootstrap`,
1432
1465
  purpose: "Load durable decisions, learnings, and optional short-lived carryover at session start."
1433
1466
  },
1467
+ {
1468
+ title: "Check Stuck Guard status",
1469
+ command: `${COMPANION_COMMAND_NAME} stuck-guard status`,
1470
+ purpose: "Inspect whether recent tool failures, empty searches, or risky workflow signals should trigger a Rescue Pack."
1471
+ },
1472
+ {
1473
+ title: "Simulate a Stuck Guard fixture",
1474
+ command: `${COMPANION_COMMAND_NAME} stuck-guard simulate --fixture ./stuck-guard-fixture.json`,
1475
+ purpose: "Replay canonical events against the hosted Stuck Guard decision API before enabling stricter modes."
1476
+ },
1434
1477
  {
1435
1478
  title: "Ask memory about past decisions",
1436
1479
  command: `${COMPANION_COMMAND_NAME} recall --query "What did we decide about auth retries?" --type decision`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-snipara",
3
- "version": "1.3.15",
3
+ "version": "1.3.16",
4
4
  "description": "Onboard Snipara Hosted MCP Context + Memory with auth, companion workflows, and optional Snipara Sandbox",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",