- Remove deprecated scripts/ directory (6 files) - Add hooks/post-commit-ots (ots CLI version) - Add hooks/pre-commit-ots (ots CLI backfill) - Add hooks/post-commit-node (Node.js version, local proofs only) - Add hooks/pre-commit-node (Node.js backfill, no upgrade) - Update hooks/install.sh to auto-detect and install matching hooks - Update documentation (SKILL.md, README.md, AGENTS.md) - Add node_modules/ to .gitignore for Node.js mode Breaking change: Scripts removed, use new hooks/ directory.
49 lines
1.4 KiB
Bash
Executable file
49 lines
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
# Git OpenTimestamp Post-Commit Hook (Node.js version)
|
|
# Requires: @opentimestamps/ots (npm install)
|
|
|
|
set -e
|
|
|
|
OUTPUT_DIR=".ots"
|
|
OUTPUT_FILE="$OUTPUT_DIR/proof.ots"
|
|
|
|
mkdir -p "$OUTPUT_DIR"
|
|
|
|
COMMIT_HASH=$(git rev-parse HEAD)
|
|
|
|
# Generate proof using Node.js
|
|
node -e "
|
|
const ots = require('@opentimestamps/ots');
|
|
const fs = require('fs');
|
|
const hash = '$COMMIT_HASH';
|
|
const output = '$OUTPUT_FILE';
|
|
const hashBuffer = Buffer.from(hash, 'hex');
|
|
|
|
ots.Timestamp.hash(hashBuffer).then(timestamp => {
|
|
// Note: This creates a local proof only, not submitted to calendars
|
|
// For full Bitcoin attestation, use the ots CLI version
|
|
const proof = {
|
|
hash: hash,
|
|
timestamp: new Date().toISOString(),
|
|
status: 'pending',
|
|
note: 'Local proof only - use ots CLI for calendar submission'
|
|
};
|
|
fs.writeFileSync(output, JSON.stringify(proof, null, 2));
|
|
console.log('[ots-node] Generated local proof: ' + hash.substring(0, 8));
|
|
}).catch(err => {
|
|
console.error('[ots-node] Error:', err.message);
|
|
process.exit(1);
|
|
});
|
|
"
|
|
|
|
# Save previous commit for chaining
|
|
PREV_COMMIT=$(git rev-parse HEAD^1 2>/dev/null || echo "")
|
|
if [ -n "$PREV_COMMIT" ]; then
|
|
echo "$PREV_COMMIT" > "$OUTPUT_DIR/prev-commit.txt"
|
|
fi
|
|
|
|
# Create individual proof file (JSON format for node version)
|
|
INDIVIDUAL_PROOF="$OUTPUT_DIR/${COMMIT_HASH}.ots"
|
|
cp "$OUTPUT_FILE" "$INDIVIDUAL_PROOF"
|
|
|
|
echo "[ots-node] Proof generated successfully"
|