continuous-improvement 3.12.3 → 3.15.0
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/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +31 -1
- package/LICENSE +21 -21
- package/QUICKSTART.md +1 -1
- package/README.md +25 -5
- package/bin/analyze.sh +161 -161
- package/bin/backfill.mjs +19 -19
- package/bin/check-doc-runtime-claims.mjs +0 -0
- package/bin/check-docs-substrings.mjs +0 -0
- package/bin/check-everything-mirror.mjs +0 -0
- package/bin/check-routing-targets.mjs +0 -0
- package/bin/check-scripts-citation-drift.mjs +0 -0
- package/bin/check-skill-count.mjs +32 -1
- package/bin/check-skill-law-tag.mjs +0 -0
- package/bin/check-skill-mirror.mjs +0 -0
- package/bin/check-skill-tiers.mjs +0 -0
- package/bin/check-test-imports-only.mjs +1 -1
- package/bin/check-third-party-shape.mjs +0 -0
- package/bin/check-tool-count.mjs +0 -0
- package/bin/companion-preference-status.mjs +0 -0
- package/bin/gateguard-clear.mjs +0 -0
- package/bin/generate-plugin-manifests.mjs +2 -1
- package/bin/harvest-friction.mjs +0 -0
- package/bin/hook-stats.mjs +21 -21
- package/bin/install.mjs +74 -1
- package/bin/lint-transcript.mjs +0 -0
- package/bin/mcp-server.mjs +65 -8
- package/bin/observe.mjs +0 -0
- package/bin/plan-pack.mjs +77 -0
- package/bin/pre-commit-block-strays.sh +0 -0
- package/bin/refresh-third-party.mjs +0 -0
- package/bin/unified-cli.mjs +55 -410
- package/commands/continuous-improvement.md +115 -115
- package/commands/dashboard.md +56 -56
- package/commands/model-forward.md +13 -0
- package/commands/production-readiness-review.md +53 -0
- package/commands/seven-laws.md +16 -16
- package/commands/ship.md +57 -0
- package/commands/workspace-surface-audit.md +77 -77
- package/hooks/companion-preference.mjs +31 -19
- package/hooks/gateguard.mjs +38 -16
- package/hooks/goal-drift-stop.mjs +0 -0
- package/hooks/hook-pack.mjs +110 -0
- package/hooks/observe.sh +0 -0
- package/hooks/recall-briefing.mjs +0 -0
- package/hooks/route-prompt.mjs +0 -0
- package/hooks/session.sh +106 -106
- package/hooks/three-section-close.mjs +0 -0
- package/instinct-packs/go.json +58 -58
- package/instinct-packs/meta.json +16 -16
- package/instinct-packs/python.json +58 -58
- package/instinct-packs/react.json +58 -58
- package/lib/cli-anything.mjs +0 -0
- package/lib/gateguard-state.mjs +62 -13
- package/lib/goal-drift-gate.mjs +0 -0
- package/lib/goal-state.mjs +8 -4
- package/lib/hook-pack-gate.mjs +65 -0
- package/lib/install-targets.mjs +121 -0
- package/lib/observe-event.mjs +0 -0
- package/lib/plan-review-packet.mjs +96 -0
- package/lib/plugin-metadata.mjs +23 -2
- package/lib/pm-marketplace.mjs +0 -0
- package/lib/recall-briefing.mjs +0 -0
- package/lib/recall-index.mjs +0 -0
- package/lib/resolve-home-dir.mjs +0 -0
- package/lib/skill-distill.mjs +141 -0
- package/lib/skill-tiers.mjs +0 -0
- package/llms.txt +2 -2
- package/package.json +4 -3
- package/plugins/beginner.json +2 -2
- package/plugins/continuous-improvement/.claude-plugin/marketplace.json +2 -2
- package/plugins/continuous-improvement/.claude-plugin/plugin.json +2 -2
- package/plugins/continuous-improvement/LICENSE +21 -21
- package/plugins/continuous-improvement/README.md +1 -1
- package/plugins/continuous-improvement/bin/backfill.mjs +19 -19
- package/plugins/continuous-improvement/bin/gateguard-clear.mjs +0 -0
- package/plugins/continuous-improvement/bin/mcp-server.mjs +65 -8
- package/plugins/continuous-improvement/bin/observe.mjs +0 -0
- package/plugins/continuous-improvement/commands/continuous-improvement.md +115 -115
- package/plugins/continuous-improvement/commands/dashboard.md +56 -56
- package/plugins/continuous-improvement/commands/model-forward.md +13 -0
- package/plugins/continuous-improvement/commands/production-readiness-review.md +53 -0
- package/plugins/continuous-improvement/commands/seven-laws.md +16 -16
- package/plugins/continuous-improvement/commands/ship.md +57 -0
- package/plugins/continuous-improvement/commands/workspace-surface-audit.md +77 -77
- package/plugins/continuous-improvement/hooks/companion-preference.mjs +31 -19
- package/plugins/continuous-improvement/hooks/gateguard.mjs +38 -16
- package/plugins/continuous-improvement/hooks/goal-drift-stop.mjs +0 -0
- package/plugins/continuous-improvement/hooks/hook-pack.mjs +110 -0
- package/plugins/continuous-improvement/hooks/hooks.json +10 -0
- package/plugins/continuous-improvement/hooks/observe.sh +0 -0
- package/plugins/continuous-improvement/hooks/recall-briefing.mjs +0 -0
- package/plugins/continuous-improvement/hooks/route-prompt.mjs +0 -0
- package/plugins/continuous-improvement/hooks/session.sh +106 -106
- package/plugins/continuous-improvement/hooks/three-section-close.mjs +0 -0
- package/plugins/continuous-improvement/instinct-packs/go.json +58 -58
- package/plugins/continuous-improvement/instinct-packs/meta.json +16 -16
- package/plugins/continuous-improvement/instinct-packs/python.json +58 -58
- package/plugins/continuous-improvement/instinct-packs/react.json +58 -58
- package/plugins/continuous-improvement/lib/gateguard-state.mjs +62 -13
- package/plugins/continuous-improvement/lib/goal-drift-gate.mjs +0 -0
- package/plugins/continuous-improvement/lib/goal-state.mjs +8 -4
- package/plugins/continuous-improvement/lib/hook-pack-gate.mjs +65 -0
- package/plugins/continuous-improvement/lib/observe-event.mjs +0 -0
- package/plugins/continuous-improvement/lib/plugin-metadata.mjs +23 -2
- package/plugins/continuous-improvement/lib/recall-briefing.mjs +0 -0
- package/plugins/continuous-improvement/lib/recall-index.mjs +0 -0
- package/plugins/continuous-improvement/lib/resolve-home-dir.mjs +0 -0
- package/plugins/continuous-improvement/lib/skill-distill.mjs +141 -0
- package/plugins/continuous-improvement/skills/README.md +1 -1
- package/plugins/continuous-improvement/skills/gateguard/SKILL.md +4 -4
- package/plugins/continuous-improvement/skills/goal-monitor/SKILL.md +1 -1
- package/plugins/continuous-improvement/skills/handoff/SKILL.md +0 -1
- package/plugins/continuous-improvement/skills/model-forward/SKILL.md +44 -0
- package/plugins/continuous-improvement/skills/tdd-workflow/SKILL.md +411 -411
- package/plugins/expert.json +5 -1
- package/skills/README.md +4 -2
- package/skills/gateguard.md +4 -4
- package/skills/goal-monitor.md +1 -1
- package/skills/handoff.md +0 -1
- package/skills/model-forward.md +44 -0
- package/skills/tdd-workflow.md +411 -411
- package/lib/compound-engineering.mjs +0 -831
- package/lib/pm-skills.mjs +0 -1274
- package/lib/unified-plugin.mjs +0 -924
- package/plugins/continuous-improvement/skills/para-memory-files/SKILL.md +0 -108
- package/skills/para-memory-files.md +0 -108
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Runtime PreToolUse enforcing-hook pack (v1).
|
|
4
|
+
*
|
|
5
|
+
* Stdin : JSON { tool_name, tool_input: { command } }
|
|
6
|
+
* Stdout : empty on allow / warn (warn prints to stderr); on block, the
|
|
7
|
+
* documented PreToolUse shape:
|
|
8
|
+
* { hookSpecificOutput: { hookEventName: "PreToolUse",
|
|
9
|
+
* permissionDecision: "deny", permissionDecisionReason } }
|
|
10
|
+
* A bare { decision: "allow" } is not schema-valid for PreToolUse.
|
|
11
|
+
* Exit : 0 always (decision is in stdout; fail-open on any error).
|
|
12
|
+
*
|
|
13
|
+
* Two gates over Bash git commands (pure logic in ../lib/hook-pack-gate.mjs):
|
|
14
|
+
* - push-to-main : a direct `git push` to main/master/release-*
|
|
15
|
+
* - commit-size : a `git commit` staging more than COMMIT_FILE_LIMIT files
|
|
16
|
+
*
|
|
17
|
+
* Mode via CLAUDE_CI_HOOKPACK_GATE: "warn" (default) | "block" | "off".
|
|
18
|
+
* warn : print a one-line notice to stderr; never blocks.
|
|
19
|
+
* block : emit the PreToolUse deny shape.
|
|
20
|
+
* off : no-op.
|
|
21
|
+
*
|
|
22
|
+
* Only `git push` / `git commit` commands spawn a git subprocess; every other
|
|
23
|
+
* Bash command and non-Bash tool returns immediately. No network. Fail-open.
|
|
24
|
+
*/
|
|
25
|
+
import { execFileSync } from "node:child_process";
|
|
26
|
+
import { readFileSync } from "node:fs";
|
|
27
|
+
import { COMMIT_FILE_LIMIT, classifyCommand, decide, evaluateCommitSize, evaluatePush, parseMode, } from "../lib/hook-pack-gate.mjs";
|
|
28
|
+
function readStdinSync() {
|
|
29
|
+
try {
|
|
30
|
+
return readFileSync(0, "utf8");
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function safeJsonParse(text) {
|
|
37
|
+
try {
|
|
38
|
+
return JSON.parse(text);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function gitCurrentBranch() {
|
|
45
|
+
try {
|
|
46
|
+
const branch = execFileSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
|
|
47
|
+
encoding: "utf8",
|
|
48
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
49
|
+
}).trim();
|
|
50
|
+
return branch || null;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function gitStagedCount() {
|
|
57
|
+
try {
|
|
58
|
+
const out = execFileSync("git", ["diff", "--cached", "--name-only"], {
|
|
59
|
+
encoding: "utf8",
|
|
60
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
61
|
+
});
|
|
62
|
+
return out.split(/\r?\n/).filter(Boolean).length;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const ALLOW = { action: "allow", reason: "" };
|
|
69
|
+
function compute() {
|
|
70
|
+
const mode = parseMode(process.env.CLAUDE_CI_HOOKPACK_GATE);
|
|
71
|
+
if (mode === "off")
|
|
72
|
+
return ALLOW;
|
|
73
|
+
const payload = safeJsonParse(readStdinSync());
|
|
74
|
+
if (!payload || typeof payload !== "object")
|
|
75
|
+
return ALLOW;
|
|
76
|
+
const obj = payload;
|
|
77
|
+
if (obj.tool_name !== "Bash")
|
|
78
|
+
return ALLOW;
|
|
79
|
+
const input = (obj.tool_input && typeof obj.tool_input === "object"
|
|
80
|
+
? obj.tool_input
|
|
81
|
+
: {});
|
|
82
|
+
const command = typeof input.command === "string" ? input.command : "";
|
|
83
|
+
const kind = classifyCommand(command);
|
|
84
|
+
if (kind === "push") {
|
|
85
|
+
const res = evaluatePush(command, gitCurrentBranch());
|
|
86
|
+
return decide(mode, res.gated, `Direct push to protected branch "${res.branch}" — open a feature branch + PR instead.`);
|
|
87
|
+
}
|
|
88
|
+
if (kind === "commit") {
|
|
89
|
+
const res = evaluateCommitSize(command, gitStagedCount());
|
|
90
|
+
return decide(mode, res.gated, `This commit stages more than ${COMMIT_FILE_LIMIT} files — exceeds the one-concern limit. Split by layer, or set CLAUDE_CI_HOOKPACK_GATE=off for genuinely generated bulk.`);
|
|
91
|
+
}
|
|
92
|
+
return ALLOW;
|
|
93
|
+
}
|
|
94
|
+
function main() {
|
|
95
|
+
const decision = compute();
|
|
96
|
+
if (decision.action === "block") {
|
|
97
|
+
process.stdout.write(JSON.stringify({
|
|
98
|
+
hookSpecificOutput: {
|
|
99
|
+
hookEventName: "PreToolUse",
|
|
100
|
+
permissionDecision: "deny",
|
|
101
|
+
permissionDecisionReason: decision.reason,
|
|
102
|
+
},
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
else if (decision.action === "warn") {
|
|
106
|
+
process.stderr.write(`[hook-pack] ${decision.reason}\n`);
|
|
107
|
+
}
|
|
108
|
+
process.exit(0);
|
|
109
|
+
}
|
|
110
|
+
main();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# session.sh — SessionStart/SessionEnd hook for continuous-improvement
|
|
3
|
-
# SessionStart: loads instincts and prints status
|
|
4
|
-
# SessionEnd: prompts reflection
|
|
5
|
-
# Always exits 0 — never blocks the session
|
|
6
|
-
trap 'exit 0' EXIT ERR INT TERM
|
|
7
|
-
|
|
8
|
-
INSTINCTS_DIR="${HOME}/.claude/instincts"
|
|
9
|
-
|
|
10
|
-
# Read stdin
|
|
11
|
-
INPUT="$(cat)"
|
|
12
|
-
[[ -z "$INPUT" ]] && exit 0
|
|
13
|
-
|
|
14
|
-
# ---------------------------------------------------------------------------
|
|
15
|
-
# Detect event type from hook context
|
|
16
|
-
# ---------------------------------------------------------------------------
|
|
17
|
-
# SessionStart hooks receive no tool_name, SessionEnd hooks may vary.
|
|
18
|
-
# We detect based on the hook_type field or the calling context.
|
|
19
|
-
EVENT_TYPE=""
|
|
20
|
-
if command -v jq &>/dev/null; then
|
|
21
|
-
EVENT_TYPE="$(printf '%s' "$INPUT" | jq -r '.hook_type // .event_type // "unknown"' 2>/dev/null)"
|
|
22
|
-
else
|
|
23
|
-
if printf '%s' "$INPUT" | grep -q '"SessionStart"'; then
|
|
24
|
-
EVENT_TYPE="SessionStart"
|
|
25
|
-
elif printf '%s' "$INPUT" | grep -q '"SessionEnd"'; then
|
|
26
|
-
EVENT_TYPE="SessionEnd"
|
|
27
|
-
fi
|
|
28
|
-
fi
|
|
29
|
-
|
|
30
|
-
# ---------------------------------------------------------------------------
|
|
31
|
-
# Project detection (same as observe.sh)
|
|
32
|
-
# ---------------------------------------------------------------------------
|
|
33
|
-
PROJECT_ROOT=""
|
|
34
|
-
if [[ -n "${CLAUDE_PROJECT_DIR:-}" && -d "${CLAUDE_PROJECT_DIR}" ]]; then
|
|
35
|
-
PROJECT_ROOT="${CLAUDE_PROJECT_DIR}"
|
|
36
|
-
fi
|
|
37
|
-
if [[ -z "$PROJECT_ROOT" ]]; then
|
|
38
|
-
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
|
|
39
|
-
fi
|
|
40
|
-
if [[ -z "$PROJECT_ROOT" ]]; then
|
|
41
|
-
PROJECT_ROOT="global"
|
|
42
|
-
fi
|
|
43
|
-
|
|
44
|
-
PROJECT_HASH="$(printf '%s' "$PROJECT_ROOT" | sha256sum | cut -c1-12)"
|
|
45
|
-
PROJECT_DIR="${INSTINCTS_DIR}/${PROJECT_HASH}"
|
|
46
|
-
|
|
47
|
-
# ---------------------------------------------------------------------------
|
|
48
|
-
# SessionStart: count observations and instincts, print brief status
|
|
49
|
-
# ---------------------------------------------------------------------------
|
|
50
|
-
if [[ "$EVENT_TYPE" == "SessionStart" || "$EVENT_TYPE" == "unknown" ]]; then
|
|
51
|
-
OBS_COUNT=0
|
|
52
|
-
INSTINCT_COUNT=0
|
|
53
|
-
|
|
54
|
-
OBS_FILE="${PROJECT_DIR}/observations.jsonl"
|
|
55
|
-
if [[ -f "$OBS_FILE" ]]; then
|
|
56
|
-
OBS_COUNT="$(wc -l < "$OBS_FILE" 2>/dev/null || echo 0)"
|
|
57
|
-
fi
|
|
58
|
-
|
|
59
|
-
# Count yaml files in project + global
|
|
60
|
-
for dir in "$PROJECT_DIR" "${INSTINCTS_DIR}/global"; do
|
|
61
|
-
if [[ -d "$dir" ]]; then
|
|
62
|
-
count="$(find "$dir" -maxdepth 1 -name '*.yaml' 2>/dev/null | wc -l)"
|
|
63
|
-
INSTINCT_COUNT=$((INSTINCT_COUNT + count))
|
|
64
|
-
fi
|
|
65
|
-
done
|
|
66
|
-
|
|
67
|
-
# Determine level
|
|
68
|
-
LEVEL="CAPTURE"
|
|
69
|
-
if (( OBS_COUNT >= 20 )) || (( INSTINCT_COUNT > 0 )); then
|
|
70
|
-
LEVEL="ANALYZE"
|
|
71
|
-
fi
|
|
72
|
-
|
|
73
|
-
# Check for high-confidence instincts
|
|
74
|
-
if (( INSTINCT_COUNT > 0 )); then
|
|
75
|
-
for dir in "$PROJECT_DIR" "${INSTINCTS_DIR}/global"; do
|
|
76
|
-
if [[ -d "$dir" ]]; then
|
|
77
|
-
for f in "$dir"/*.yaml; do
|
|
78
|
-
[[ -f "$f" ]] || continue
|
|
79
|
-
conf="$(grep '^confidence:' "$f" 2>/dev/null | head -1 | sed 's/confidence: *//')"
|
|
80
|
-
if [[ -n "$conf" ]]; then
|
|
81
|
-
# Compare as integer (multiply by 100) using awk for portability
|
|
82
|
-
int_conf="$(printf '%s' "$conf" | awk '{printf "%.0f", $1 * 100}')"
|
|
83
|
-
if [[ -n "$int_conf" ]] && (( int_conf >= 70 )); then
|
|
84
|
-
LEVEL="AUTO-APPLY"
|
|
85
|
-
break 2
|
|
86
|
-
elif (( int_conf >= 50 )); then
|
|
87
|
-
LEVEL="SUGGEST"
|
|
88
|
-
fi
|
|
89
|
-
fi
|
|
90
|
-
done
|
|
91
|
-
fi
|
|
92
|
-
done
|
|
93
|
-
fi
|
|
94
|
-
|
|
95
|
-
# Write status to stderr (visible in hook output, not blocking)
|
|
96
|
-
echo "[continuous-improvement] Level: ${LEVEL} | Observations: ${OBS_COUNT} | Instincts: ${INSTINCT_COUNT}" >&2
|
|
97
|
-
fi
|
|
98
|
-
|
|
99
|
-
# ---------------------------------------------------------------------------
|
|
100
|
-
# SessionEnd: remind to reflect
|
|
101
|
-
# ---------------------------------------------------------------------------
|
|
102
|
-
if [[ "$EVENT_TYPE" == "SessionEnd" ]]; then
|
|
103
|
-
echo "[continuous-improvement] Session ending. Run /continuous-improvement to reflect and capture learnings." >&2
|
|
104
|
-
fi
|
|
105
|
-
|
|
106
|
-
exit 0
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# session.sh — SessionStart/SessionEnd hook for continuous-improvement
|
|
3
|
+
# SessionStart: loads instincts and prints status
|
|
4
|
+
# SessionEnd: prompts reflection
|
|
5
|
+
# Always exits 0 — never blocks the session
|
|
6
|
+
trap 'exit 0' EXIT ERR INT TERM
|
|
7
|
+
|
|
8
|
+
INSTINCTS_DIR="${HOME}/.claude/instincts"
|
|
9
|
+
|
|
10
|
+
# Read stdin
|
|
11
|
+
INPUT="$(cat)"
|
|
12
|
+
[[ -z "$INPUT" ]] && exit 0
|
|
13
|
+
|
|
14
|
+
# ---------------------------------------------------------------------------
|
|
15
|
+
# Detect event type from hook context
|
|
16
|
+
# ---------------------------------------------------------------------------
|
|
17
|
+
# SessionStart hooks receive no tool_name, SessionEnd hooks may vary.
|
|
18
|
+
# We detect based on the hook_type field or the calling context.
|
|
19
|
+
EVENT_TYPE=""
|
|
20
|
+
if command -v jq &>/dev/null; then
|
|
21
|
+
EVENT_TYPE="$(printf '%s' "$INPUT" | jq -r '.hook_type // .event_type // "unknown"' 2>/dev/null)"
|
|
22
|
+
else
|
|
23
|
+
if printf '%s' "$INPUT" | grep -q '"SessionStart"'; then
|
|
24
|
+
EVENT_TYPE="SessionStart"
|
|
25
|
+
elif printf '%s' "$INPUT" | grep -q '"SessionEnd"'; then
|
|
26
|
+
EVENT_TYPE="SessionEnd"
|
|
27
|
+
fi
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
# ---------------------------------------------------------------------------
|
|
31
|
+
# Project detection (same as observe.sh)
|
|
32
|
+
# ---------------------------------------------------------------------------
|
|
33
|
+
PROJECT_ROOT=""
|
|
34
|
+
if [[ -n "${CLAUDE_PROJECT_DIR:-}" && -d "${CLAUDE_PROJECT_DIR}" ]]; then
|
|
35
|
+
PROJECT_ROOT="${CLAUDE_PROJECT_DIR}"
|
|
36
|
+
fi
|
|
37
|
+
if [[ -z "$PROJECT_ROOT" ]]; then
|
|
38
|
+
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
|
|
39
|
+
fi
|
|
40
|
+
if [[ -z "$PROJECT_ROOT" ]]; then
|
|
41
|
+
PROJECT_ROOT="global"
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
PROJECT_HASH="$(printf '%s' "$PROJECT_ROOT" | sha256sum | cut -c1-12)"
|
|
45
|
+
PROJECT_DIR="${INSTINCTS_DIR}/${PROJECT_HASH}"
|
|
46
|
+
|
|
47
|
+
# ---------------------------------------------------------------------------
|
|
48
|
+
# SessionStart: count observations and instincts, print brief status
|
|
49
|
+
# ---------------------------------------------------------------------------
|
|
50
|
+
if [[ "$EVENT_TYPE" == "SessionStart" || "$EVENT_TYPE" == "unknown" ]]; then
|
|
51
|
+
OBS_COUNT=0
|
|
52
|
+
INSTINCT_COUNT=0
|
|
53
|
+
|
|
54
|
+
OBS_FILE="${PROJECT_DIR}/observations.jsonl"
|
|
55
|
+
if [[ -f "$OBS_FILE" ]]; then
|
|
56
|
+
OBS_COUNT="$(wc -l < "$OBS_FILE" 2>/dev/null || echo 0)"
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
# Count yaml files in project + global
|
|
60
|
+
for dir in "$PROJECT_DIR" "${INSTINCTS_DIR}/global"; do
|
|
61
|
+
if [[ -d "$dir" ]]; then
|
|
62
|
+
count="$(find "$dir" -maxdepth 1 -name '*.yaml' 2>/dev/null | wc -l)"
|
|
63
|
+
INSTINCT_COUNT=$((INSTINCT_COUNT + count))
|
|
64
|
+
fi
|
|
65
|
+
done
|
|
66
|
+
|
|
67
|
+
# Determine level
|
|
68
|
+
LEVEL="CAPTURE"
|
|
69
|
+
if (( OBS_COUNT >= 20 )) || (( INSTINCT_COUNT > 0 )); then
|
|
70
|
+
LEVEL="ANALYZE"
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
# Check for high-confidence instincts
|
|
74
|
+
if (( INSTINCT_COUNT > 0 )); then
|
|
75
|
+
for dir in "$PROJECT_DIR" "${INSTINCTS_DIR}/global"; do
|
|
76
|
+
if [[ -d "$dir" ]]; then
|
|
77
|
+
for f in "$dir"/*.yaml; do
|
|
78
|
+
[[ -f "$f" ]] || continue
|
|
79
|
+
conf="$(grep '^confidence:' "$f" 2>/dev/null | head -1 | sed 's/confidence: *//')"
|
|
80
|
+
if [[ -n "$conf" ]]; then
|
|
81
|
+
# Compare as integer (multiply by 100) using awk for portability
|
|
82
|
+
int_conf="$(printf '%s' "$conf" | awk '{printf "%.0f", $1 * 100}')"
|
|
83
|
+
if [[ -n "$int_conf" ]] && (( int_conf >= 70 )); then
|
|
84
|
+
LEVEL="AUTO-APPLY"
|
|
85
|
+
break 2
|
|
86
|
+
elif (( int_conf >= 50 )); then
|
|
87
|
+
LEVEL="SUGGEST"
|
|
88
|
+
fi
|
|
89
|
+
fi
|
|
90
|
+
done
|
|
91
|
+
fi
|
|
92
|
+
done
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
# Write status to stderr (visible in hook output, not blocking)
|
|
96
|
+
echo "[continuous-improvement] Level: ${LEVEL} | Observations: ${OBS_COUNT} | Instincts: ${INSTINCT_COUNT}" >&2
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
# ---------------------------------------------------------------------------
|
|
100
|
+
# SessionEnd: remind to reflect
|
|
101
|
+
# ---------------------------------------------------------------------------
|
|
102
|
+
if [[ "$EVENT_TYPE" == "SessionEnd" ]]; then
|
|
103
|
+
echo "[continuous-improvement] Session ending. Run /continuous-improvement to reflect and capture learnings." >&2
|
|
104
|
+
fi
|
|
105
|
+
|
|
106
|
+
exit 0
|
|
File without changes
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": "go-error-handling",
|
|
4
|
-
"trigger": "when calling functions that return errors",
|
|
5
|
-
"body": "Always check returned errors immediately. Never use _ to discard errors unless you've explicitly decided it's safe and documented why.",
|
|
6
|
-
"confidence": 0.7,
|
|
7
|
-
"domain": "patterns"
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"id": "go-defer-cleanup",
|
|
11
|
-
"trigger": "when opening files, connections, or acquiring locks",
|
|
12
|
-
"body": "Use defer immediately after acquiring a resource for cleanup. Place defer right after the error check for the acquisition.",
|
|
13
|
-
"confidence": 0.7,
|
|
14
|
-
"domain": "patterns"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"id": "go-interface-consumer",
|
|
18
|
-
"trigger": "when defining Go interfaces",
|
|
19
|
-
"body": "Define interfaces at the consumer side, not the producer side. Keep interfaces small (1-3 methods). Accept interfaces, return structs.",
|
|
20
|
-
"confidence": 0.65,
|
|
21
|
-
"domain": "patterns"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"id": "go-table-driven-tests",
|
|
25
|
-
"trigger": "when writing Go tests",
|
|
26
|
-
"body": "Use table-driven tests with subtests (t.Run) for functions with multiple input/output cases. Name test cases descriptively.",
|
|
27
|
-
"confidence": 0.7,
|
|
28
|
-
"domain": "testing"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"id": "go-context-propagation",
|
|
32
|
-
"trigger": "when writing HTTP handlers or long-running operations",
|
|
33
|
-
"body": "Accept context.Context as the first parameter. Propagate it to all downstream calls. Use it for cancellation and timeouts.",
|
|
34
|
-
"confidence": 0.65,
|
|
35
|
-
"domain": "patterns"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"id": "go-goroutine-lifecycle",
|
|
39
|
-
"trigger": "when spawning goroutines",
|
|
40
|
-
"body": "Always ensure goroutines have a way to exit (context cancellation, done channel, or WaitGroup). Never fire-and-forget goroutines without cleanup.",
|
|
41
|
-
"confidence": 0.7,
|
|
42
|
-
"domain": "patterns"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"id": "go-struct-zero-values",
|
|
46
|
-
"trigger": "when designing Go structs",
|
|
47
|
-
"body": "Design structs so their zero value is useful. Use pointer fields only when nil is a meaningful distinct state from zero value.",
|
|
48
|
-
"confidence": 0.6,
|
|
49
|
-
"domain": "patterns"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"id": "go-mod-tidy",
|
|
53
|
-
"trigger": "when adding or removing dependencies",
|
|
54
|
-
"body": "Run 'go mod tidy' after adding or removing imports to keep go.mod and go.sum clean.",
|
|
55
|
-
"confidence": 0.65,
|
|
56
|
-
"domain": "workflow"
|
|
57
|
-
}
|
|
58
|
-
]
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "go-error-handling",
|
|
4
|
+
"trigger": "when calling functions that return errors",
|
|
5
|
+
"body": "Always check returned errors immediately. Never use _ to discard errors unless you've explicitly decided it's safe and documented why.",
|
|
6
|
+
"confidence": 0.7,
|
|
7
|
+
"domain": "patterns"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "go-defer-cleanup",
|
|
11
|
+
"trigger": "when opening files, connections, or acquiring locks",
|
|
12
|
+
"body": "Use defer immediately after acquiring a resource for cleanup. Place defer right after the error check for the acquisition.",
|
|
13
|
+
"confidence": 0.7,
|
|
14
|
+
"domain": "patterns"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "go-interface-consumer",
|
|
18
|
+
"trigger": "when defining Go interfaces",
|
|
19
|
+
"body": "Define interfaces at the consumer side, not the producer side. Keep interfaces small (1-3 methods). Accept interfaces, return structs.",
|
|
20
|
+
"confidence": 0.65,
|
|
21
|
+
"domain": "patterns"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "go-table-driven-tests",
|
|
25
|
+
"trigger": "when writing Go tests",
|
|
26
|
+
"body": "Use table-driven tests with subtests (t.Run) for functions with multiple input/output cases. Name test cases descriptively.",
|
|
27
|
+
"confidence": 0.7,
|
|
28
|
+
"domain": "testing"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": "go-context-propagation",
|
|
32
|
+
"trigger": "when writing HTTP handlers or long-running operations",
|
|
33
|
+
"body": "Accept context.Context as the first parameter. Propagate it to all downstream calls. Use it for cancellation and timeouts.",
|
|
34
|
+
"confidence": 0.65,
|
|
35
|
+
"domain": "patterns"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "go-goroutine-lifecycle",
|
|
39
|
+
"trigger": "when spawning goroutines",
|
|
40
|
+
"body": "Always ensure goroutines have a way to exit (context cancellation, done channel, or WaitGroup). Never fire-and-forget goroutines without cleanup.",
|
|
41
|
+
"confidence": 0.7,
|
|
42
|
+
"domain": "patterns"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": "go-struct-zero-values",
|
|
46
|
+
"trigger": "when designing Go structs",
|
|
47
|
+
"body": "Design structs so their zero value is useful. Use pointer fields only when nil is a meaningful distinct state from zero value.",
|
|
48
|
+
"confidence": 0.6,
|
|
49
|
+
"domain": "patterns"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "go-mod-tidy",
|
|
53
|
+
"trigger": "when adding or removing dependencies",
|
|
54
|
+
"body": "Run 'go mod tidy' after adding or removing imports to keep go.mod and go.sum clean.",
|
|
55
|
+
"confidence": 0.65,
|
|
56
|
+
"domain": "workflow"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": "skip-thin-observation-schema",
|
|
4
|
-
"trigger": "when running /continuous-improvement and observations.jsonl entries contain only tool_start events with no inputs/outputs/errors",
|
|
5
|
-
"body": "Skip instinct fabrication and report the schema gap instead. With only ts/event/session/tool/project_id/project_name fields, the stream cannot distinguish a `git status` Bash call from a `rm -rf` Bash call. Tool-name bigrams (Bash→Bash, Edit→Edit, Read→Edit) reflect parallel-call artifacts and harness-enforced read-before-edit, not learned preferences. Recommend enhancing PostToolUse/PreToolUse hooks to log tool inputs (Bash command head, Skill name) and tool_end with success flag before retrying analysis.",
|
|
6
|
-
"confidence": 0.6,
|
|
7
|
-
"domain": "meta"
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"id": "parallelize-independent-tool-calls",
|
|
11
|
-
"trigger": "when issuing 2+ tool calls with no data dependency between them in the same turn",
|
|
12
|
-
"body": "Batch independent tool calls into a single message instead of issuing them sequentially. Independent reads, independent greps, independent git inspections, independent file edits in unrelated files belong in one message with multiple tool blocks. Dependent calls (output of A determines input of B) stay sequential. Exception: when a single check would short-circuit the whole task (e.g., `git status` returning empty), one call first is fine. Sequential issuing of independent calls wastes wall-clock time and burns context per round-trip.",
|
|
13
|
-
"confidence": 0.6,
|
|
14
|
-
"domain": "workflow"
|
|
15
|
-
}
|
|
16
|
-
]
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "skip-thin-observation-schema",
|
|
4
|
+
"trigger": "when running /continuous-improvement and observations.jsonl entries contain only tool_start events with no inputs/outputs/errors",
|
|
5
|
+
"body": "Skip instinct fabrication and report the schema gap instead. With only ts/event/session/tool/project_id/project_name fields, the stream cannot distinguish a `git status` Bash call from a `rm -rf` Bash call. Tool-name bigrams (Bash→Bash, Edit→Edit, Read→Edit) reflect parallel-call artifacts and harness-enforced read-before-edit, not learned preferences. Recommend enhancing PostToolUse/PreToolUse hooks to log tool inputs (Bash command head, Skill name) and tool_end with success flag before retrying analysis.",
|
|
6
|
+
"confidence": 0.6,
|
|
7
|
+
"domain": "meta"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "parallelize-independent-tool-calls",
|
|
11
|
+
"trigger": "when issuing 2+ tool calls with no data dependency between them in the same turn",
|
|
12
|
+
"body": "Batch independent tool calls into a single message instead of issuing them sequentially. Independent reads, independent greps, independent git inspections, independent file edits in unrelated files belong in one message with multiple tool blocks. Dependent calls (output of A determines input of B) stay sequential. Exception: when a single check would short-circuit the whole task (e.g., `git status` returning empty), one call first is fine. Sequential issuing of independent calls wastes wall-clock time and burns context per round-trip.",
|
|
13
|
+
"confidence": 0.6,
|
|
14
|
+
"domain": "workflow"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": "python-virtual-env",
|
|
4
|
-
"trigger": "when starting work on a Python project",
|
|
5
|
-
"body": "Check for virtual environment (venv, .venv, conda) before installing packages. Never install to system Python.",
|
|
6
|
-
"confidence": 0.7,
|
|
7
|
-
"domain": "workflow"
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"id": "python-type-hints",
|
|
11
|
-
"trigger": "when writing Python functions",
|
|
12
|
-
"body": "Add type hints to function parameters and return values. Use Optional[], list[], dict[] (Python 3.10+) or typing module for older versions.",
|
|
13
|
-
"confidence": 0.6,
|
|
14
|
-
"domain": "code-style"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"id": "python-pathlib",
|
|
18
|
-
"trigger": "when working with file paths in Python",
|
|
19
|
-
"body": "Use pathlib.Path instead of os.path for file operations. It's more readable and cross-platform.",
|
|
20
|
-
"confidence": 0.65,
|
|
21
|
-
"domain": "patterns"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"id": "python-context-managers",
|
|
25
|
-
"trigger": "when opening files or database connections",
|
|
26
|
-
"body": "Always use context managers (with statement) for files, database connections, and locks. Never rely on manual .close() calls.",
|
|
27
|
-
"confidence": 0.7,
|
|
28
|
-
"domain": "patterns"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"id": "python-list-comprehension",
|
|
32
|
-
"trigger": "when writing simple for loops that build lists",
|
|
33
|
-
"body": "Prefer list comprehensions for simple transformations. Use regular for loops when the logic is complex or has side effects.",
|
|
34
|
-
"confidence": 0.6,
|
|
35
|
-
"domain": "code-style"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"id": "python-requirements-check",
|
|
39
|
-
"trigger": "when adding a new import",
|
|
40
|
-
"body": "Check if the package is already in requirements.txt, pyproject.toml, or Pipfile before adding. Search for existing usage in the codebase.",
|
|
41
|
-
"confidence": 0.65,
|
|
42
|
-
"domain": "workflow"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"id": "python-pytest-fixtures",
|
|
46
|
-
"trigger": "when writing Python tests",
|
|
47
|
-
"body": "Use pytest fixtures for test setup/teardown instead of unittest setUp/tearDown. Use conftest.py for shared fixtures.",
|
|
48
|
-
"confidence": 0.6,
|
|
49
|
-
"domain": "testing"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"id": "python-dataclass",
|
|
53
|
-
"trigger": "when creating classes that primarily hold data",
|
|
54
|
-
"body": "Use @dataclass or Pydantic BaseModel instead of plain classes for data containers. They provide __init__, __repr__, and comparison for free.",
|
|
55
|
-
"confidence": 0.65,
|
|
56
|
-
"domain": "patterns"
|
|
57
|
-
}
|
|
58
|
-
]
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "python-virtual-env",
|
|
4
|
+
"trigger": "when starting work on a Python project",
|
|
5
|
+
"body": "Check for virtual environment (venv, .venv, conda) before installing packages. Never install to system Python.",
|
|
6
|
+
"confidence": 0.7,
|
|
7
|
+
"domain": "workflow"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "python-type-hints",
|
|
11
|
+
"trigger": "when writing Python functions",
|
|
12
|
+
"body": "Add type hints to function parameters and return values. Use Optional[], list[], dict[] (Python 3.10+) or typing module for older versions.",
|
|
13
|
+
"confidence": 0.6,
|
|
14
|
+
"domain": "code-style"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "python-pathlib",
|
|
18
|
+
"trigger": "when working with file paths in Python",
|
|
19
|
+
"body": "Use pathlib.Path instead of os.path for file operations. It's more readable and cross-platform.",
|
|
20
|
+
"confidence": 0.65,
|
|
21
|
+
"domain": "patterns"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "python-context-managers",
|
|
25
|
+
"trigger": "when opening files or database connections",
|
|
26
|
+
"body": "Always use context managers (with statement) for files, database connections, and locks. Never rely on manual .close() calls.",
|
|
27
|
+
"confidence": 0.7,
|
|
28
|
+
"domain": "patterns"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": "python-list-comprehension",
|
|
32
|
+
"trigger": "when writing simple for loops that build lists",
|
|
33
|
+
"body": "Prefer list comprehensions for simple transformations. Use regular for loops when the logic is complex or has side effects.",
|
|
34
|
+
"confidence": 0.6,
|
|
35
|
+
"domain": "code-style"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "python-requirements-check",
|
|
39
|
+
"trigger": "when adding a new import",
|
|
40
|
+
"body": "Check if the package is already in requirements.txt, pyproject.toml, or Pipfile before adding. Search for existing usage in the codebase.",
|
|
41
|
+
"confidence": 0.65,
|
|
42
|
+
"domain": "workflow"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": "python-pytest-fixtures",
|
|
46
|
+
"trigger": "when writing Python tests",
|
|
47
|
+
"body": "Use pytest fixtures for test setup/teardown instead of unittest setUp/tearDown. Use conftest.py for shared fixtures.",
|
|
48
|
+
"confidence": 0.6,
|
|
49
|
+
"domain": "testing"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "python-dataclass",
|
|
53
|
+
"trigger": "when creating classes that primarily hold data",
|
|
54
|
+
"body": "Use @dataclass or Pydantic BaseModel instead of plain classes for data containers. They provide __init__, __repr__, and comparison for free.",
|
|
55
|
+
"confidence": 0.65,
|
|
56
|
+
"domain": "patterns"
|
|
57
|
+
}
|
|
58
|
+
]
|