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
package/llms.txt
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# continuous-improvement
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> The persistent-memory and runtime-discipline layer for Claude Code. It remembers the corrections you already gave, grounds every edit in real facts before it lands, and — through the Mulahazah engine — turns each fix into a reusable instinct, so a lesson learned once is applied automatically next time with no re-teaching. Built on the 7 Laws of AI Agent Discipline (research, plan, verify, reflect, learn) and shipped as 25 bundled skills, instinct-aware hooks, an MCP toolset for recall and reflection, and a GitHub Action transcript linter that feeds real work history back into sharper instincts.
|
|
4
4
|
|
|
5
5
|
## What This Is
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The persistent-memory and discipline layer for AI coding agents. It carries the corrections Claude has already received from one session into the next, grounds each edit in real facts before it lands, and learns from every session so its competence compounds over time — research, plan, execute one thing at a time, verify, reflect, iterate, learn — building behavioral instincts via the Mulahazah learning system, so the same correction never has to be given twice and each run starts smarter than the last. Orchestration tools run a task; this is the layer that makes the lessons survive the run.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "continuous-improvement",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.15.0",
|
|
4
|
+
"description": "The persistent-memory and runtime-discipline layer for Claude Code. It remembers the corrections you already gave, grounds every edit in real facts before it lands, and — through the Mulahazah engine — turns each fix into a reusable instinct, so a lesson learned once is applied automatically next time with no re-teaching. Built on the 7 Laws of AI Agent Discipline (research, plan, verify, reflect, learn) and shipped as 25 bundled skills, instinct-aware hooks, an MCP toolset for recall and reflection, and a GitHub Action transcript linter that feeds real work history back into sharper instincts. Beginner: one /plugin install command. Expert: adds MCP tools and session hooks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
7
7
|
"claude-code-skill",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"bin": {
|
|
30
30
|
"continuous-improvement": "bin/install.mjs",
|
|
31
31
|
"ci-lint-transcript": "bin/lint-transcript.mjs",
|
|
32
|
-
"ci": "bin/unified-cli.mjs"
|
|
32
|
+
"ci": "bin/unified-cli.mjs",
|
|
33
|
+
"ci-plan-pack": "bin/plan-pack.mjs"
|
|
33
34
|
},
|
|
34
35
|
"scripts": {
|
|
35
36
|
"build": "tsc -p tsconfig.json && node bin/generate-plugin-manifests.mjs && node -e \"const fs=require('node:fs'); for (const f of fs.readdirSync('bin')) { if (f.endsWith('.mjs')) fs.chmodSync('bin/'+f, 0o755); } for (const f of fs.readdirSync('hooks')) { if (f.endsWith('.mjs')) fs.chmodSync('hooks/'+f, 0o755); } for (const f of fs.readdirSync('lib')) { if (f.endsWith('.mjs')) fs.chmodSync('lib/'+f, 0o755); } for (const f of fs.readdirSync('plugins/continuous-improvement/bin')) { if (f.endsWith('.mjs')) fs.chmodSync('plugins/continuous-improvement/bin/'+f, 0o755); } for (const f of fs.readdirSync('plugins/continuous-improvement/lib')) { if (f.endsWith('.mjs')) fs.chmodSync('plugins/continuous-improvement/lib/'+f, 0o755); } for (const f of fs.readdirSync('plugins/continuous-improvement/hooks')) { if (f.endsWith('.mjs')) fs.chmodSync('plugins/continuous-improvement/hooks/'+f, 0o755); } for (const f of fs.readdirSync('scripts')) { if (f.endsWith('.mjs')) fs.chmodSync('scripts/'+f, 0o755); } for (const f of fs.readdirSync('synthetic-checks')) { if (f.endsWith('.mjs')) fs.chmodSync('synthetic-checks/'+f, 0o755); } \"",
|
package/plugins/beginner.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "continuous-improvement",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"mode": "beginner",
|
|
5
|
-
"description": "Beginner mode: see what your agent learned, list its instincts, and request a session reflection. Bundles
|
|
5
|
+
"description": "Beginner mode: see what your agent learned, list its instincts, and request a session reflection. Bundles three grounding skills (gateguard, tdd-workflow, verification-loop) so research, memory, tests, and verification happen by default — every edit starts from facts, not guesses.",
|
|
6
6
|
"tools": [
|
|
7
7
|
{
|
|
8
8
|
"name": "ci_status",
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
"plugins": [
|
|
8
8
|
{
|
|
9
9
|
"name": "continuous-improvement",
|
|
10
|
-
"description": "
|
|
11
|
-
"version": "3.
|
|
10
|
+
"description": "The persistent-memory and runtime-discipline layer for Claude Code. It remembers the corrections you already gave, grounds every edit in real facts before it lands, and — through the Mulahazah engine — turns each fix into a reusable instinct, so a lesson learned once is applied automatically next time with no re-teaching. Built on the 7 Laws of AI Agent Discipline (research, plan, verify, reflect, learn) and shipped as 25 bundled skills, instinct-aware hooks, an MCP toolset for recall and reflection, and a GitHub Action transcript linter that feeds real work history back into sharper instincts.",
|
|
11
|
+
"version": "3.15.0",
|
|
12
12
|
"source": "./",
|
|
13
13
|
"author": {
|
|
14
14
|
"name": "naimkatiman"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "continuous-improvement",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.15.0",
|
|
4
|
+
"description": "The persistent-memory and runtime-discipline layer for Claude Code. It remembers the corrections you already gave, grounds every edit in real facts before it lands, and — through the Mulahazah engine — turns each fix into a reusable instinct, so a lesson learned once is applied automatically next time with no re-teaching. Built on the 7 Laws of AI Agent Discipline (research, plan, verify, reflect, learn) and shipped as 25 bundled skills, instinct-aware hooks, an MCP toolset for recall and reflection, and a GitHub Action transcript linter that feeds real work history back into sharper instincts.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "naimkatiman",
|
|
7
7
|
"url": "https://github.com/naimkatiman"
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Naim Katiman
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Naim Katiman
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -35,7 +35,7 @@ the trade-off is fallback quality vs dedicated-skill quality.
|
|
|
35
35
|
- `tdd-workflow` — RED/GREEN/REFACTOR + 80% coverage gate
|
|
36
36
|
- `workspace-surface-audit` — environment + capability audit
|
|
37
37
|
- Tier-1/Tier-2 enforcement skills (`gateguard`, `verification-loop`,
|
|
38
|
-
`
|
|
38
|
+
`safety-guard`, `token-budget-advisor`,
|
|
39
39
|
`strategic-compact`, `wild-risa-balance`)
|
|
40
40
|
|
|
41
41
|
**Optional companions the orchestrator routes to (install separately if
|
|
@@ -27,25 +27,25 @@ const args = process.argv.slice(2);
|
|
|
27
27
|
const DRY_RUN = args.includes("--dry-run");
|
|
28
28
|
const HELP = args.includes("--help") || args.includes("-h");
|
|
29
29
|
if (HELP) {
|
|
30
|
-
console.log(`
|
|
31
|
-
backfill — Tag legacy thin-schema observation rows.
|
|
32
|
-
|
|
33
|
-
Usage:
|
|
34
|
-
npx continuous-improvement backfill Tag rows in place
|
|
35
|
-
npx continuous-improvement backfill --dry-run Report counts, write nothing
|
|
36
|
-
|
|
37
|
-
What it does:
|
|
38
|
-
Walks ~/.claude/instincts/<hash>/observations.jsonl files and adds a
|
|
39
|
-
schema field ("thin" or "rich") to every row that lacks one. Thin rows
|
|
40
|
-
came from the legacy bash fallback (jq missing) and have no input_summary;
|
|
41
|
-
rich rows came from the Node observer and have full tool_input.command /
|
|
42
|
-
Edit.file_path / etc.
|
|
43
|
-
|
|
44
|
-
Output:
|
|
45
|
-
- observations.jsonl rewritten in place (original kept as .bak)
|
|
46
|
-
- backfill-summary.json with per-project counts
|
|
47
|
-
|
|
48
|
-
Idempotent. Always exits 0 — failures go to stderr only.
|
|
30
|
+
console.log(`
|
|
31
|
+
backfill — Tag legacy thin-schema observation rows.
|
|
32
|
+
|
|
33
|
+
Usage:
|
|
34
|
+
npx continuous-improvement backfill Tag rows in place
|
|
35
|
+
npx continuous-improvement backfill --dry-run Report counts, write nothing
|
|
36
|
+
|
|
37
|
+
What it does:
|
|
38
|
+
Walks ~/.claude/instincts/<hash>/observations.jsonl files and adds a
|
|
39
|
+
schema field ("thin" or "rich") to every row that lacks one. Thin rows
|
|
40
|
+
came from the legacy bash fallback (jq missing) and have no input_summary;
|
|
41
|
+
rich rows came from the Node observer and have full tool_input.command /
|
|
42
|
+
Edit.file_path / etc.
|
|
43
|
+
|
|
44
|
+
Output:
|
|
45
|
+
- observations.jsonl rewritten in place (original kept as .bak)
|
|
46
|
+
- backfill-summary.json with per-project counts
|
|
47
|
+
|
|
48
|
+
Idempotent. Always exits 0 — failures go to stderr only.
|
|
49
49
|
`);
|
|
50
50
|
process.exit(0);
|
|
51
51
|
}
|
|
File without changes
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
import { execSync } from "node:child_process";
|
|
14
14
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
15
15
|
import { homedir } from "node:os";
|
|
16
|
-
import { basename, dirname, join } from "node:path";
|
|
16
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
17
17
|
import { createInterface } from "node:readline";
|
|
18
18
|
import { fileURLToPath } from "node:url";
|
|
19
19
|
import { createHash } from "node:crypto";
|
|
20
20
|
import { PACKAGE_NAME, VERSION, getToolDefinitions, isPluginMode, } from "../lib/plugin-metadata.mjs";
|
|
21
21
|
import { formatDriftReport, parseGoalFromPlan, scoreObservations, } from "../lib/goal-state.mjs";
|
|
22
22
|
import { buildIndex, formatRecallHits, parseSince, query as queryRecall, } from "../lib/recall-index.mjs";
|
|
23
|
-
import { draftFromCandidate, extractTrajectories, findCandidates, formatCandidates, serializeDraft, } from "../lib/skill-distill.mjs";
|
|
24
|
-
import { MAX_CLEARED_FILES, clearFiles, resolveSessionDir, } from "../lib/gateguard-state.mjs";
|
|
23
|
+
import { draftFromCandidate, draftFromWorkflowRun, extractTrajectories, findCandidates, formatCandidates, serializeDraft, workflowRunFromObservations, } from "../lib/skill-distill.mjs";
|
|
24
|
+
import { MAX_CLEARED_FILES, canonicalizeFileKey, clearFiles, resolveInstinctsRoot, resolveSessionDir, } from "../lib/gateguard-state.mjs";
|
|
25
25
|
function getHomeDir() {
|
|
26
26
|
return process.env.HOME || process.env.USERPROFILE || homedir();
|
|
27
27
|
}
|
|
@@ -508,10 +508,11 @@ function handleTool(name, params) {
|
|
|
508
508
|
}
|
|
509
509
|
case "ci_gateguard_clear": {
|
|
510
510
|
// Beginner-available on purpose: the GateGuard hook fires for every
|
|
511
|
-
// install, so the clearance action must too.
|
|
512
|
-
//
|
|
513
|
-
//
|
|
514
|
-
//
|
|
511
|
+
// install, so the clearance action must too. The hook's block reason now
|
|
512
|
+
// prints state_path (the session-scoped state file); honoring it writes
|
|
513
|
+
// the marker exactly where the hook looks. Without it the MCP server can't
|
|
514
|
+
// know the caller's session, so it falls back to the canonical session dir
|
|
515
|
+
// — correct only on the legacy unscoped path.
|
|
515
516
|
const rawList = Array.isArray(params.file_paths) ? params.file_paths : [];
|
|
516
517
|
const listPaths = rawList.filter((value) => typeof value === "string" && value.length > 0);
|
|
517
518
|
const single = getString(params.file_path).trim();
|
|
@@ -519,7 +520,24 @@ function handleTool(name, params) {
|
|
|
519
520
|
if (paths.length === 0) {
|
|
520
521
|
return error("file_paths is required — pass the file path(s) named in the GateGuard block reason, e.g. { file_paths: [\"src/x.ts\"] }.");
|
|
521
522
|
}
|
|
522
|
-
|
|
523
|
+
// state_path is a model-controlled argument, so it could be a traversal
|
|
524
|
+
// string (`../../etc/...`). dirname leaves `..` segments for the OS to
|
|
525
|
+
// resolve at write time, so without a bound this is an arbitrary-write
|
|
526
|
+
// primitive. Resolve + canonicalize, then require containment within the
|
|
527
|
+
// instincts root (the only tree the hook ever prints a state_path inside).
|
|
528
|
+
const rawStatePath = getString(params.state_path).trim();
|
|
529
|
+
let sessionDir;
|
|
530
|
+
if (rawStatePath) {
|
|
531
|
+
const resolvedKey = canonicalizeFileKey(resolve(rawStatePath));
|
|
532
|
+
const rootKey = canonicalizeFileKey(resolveInstinctsRoot());
|
|
533
|
+
if (resolvedKey !== rootKey && !resolvedKey.startsWith(`${rootKey}/`)) {
|
|
534
|
+
return error("state_path must resolve inside ~/.claude/instincts/. Pass it verbatim from the GateGuard block reason.");
|
|
535
|
+
}
|
|
536
|
+
sessionDir = dirname(resolve(rawStatePath));
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
sessionDir = resolveSessionDir();
|
|
540
|
+
}
|
|
523
541
|
const { cleared, skippedForCap } = clearFiles(sessionDir, paths);
|
|
524
542
|
const lines = [
|
|
525
543
|
"## GateGuard clearance",
|
|
@@ -837,6 +855,45 @@ function handleTool(name, params) {
|
|
|
837
855
|
"```",
|
|
838
856
|
].join("\n"));
|
|
839
857
|
}
|
|
858
|
+
case "ci_distill_from_workflow": {
|
|
859
|
+
if (MODE !== "expert") {
|
|
860
|
+
return error("ci_distill_from_workflow requires expert mode");
|
|
861
|
+
}
|
|
862
|
+
const run = workflowRunFromObservations(readDistillObservations(project.hash));
|
|
863
|
+
if (!run) {
|
|
864
|
+
return text("No completed-and-verified Workflow run found in this project's observations. " +
|
|
865
|
+
"A run qualifies when a `Workflow` tool call is followed by a passing verify/test/build in the same feed. " +
|
|
866
|
+
"Run a workflow, verify its output, then try `ci_distill_from_workflow` again.");
|
|
867
|
+
}
|
|
868
|
+
const draftInstinct = draftFromWorkflowRun(run);
|
|
869
|
+
if (!isSafeDraftId(draftInstinct.id)) {
|
|
870
|
+
return error(`Internal error: generated draft id "${draftInstinct.id}" failed the safety check.`);
|
|
871
|
+
}
|
|
872
|
+
const draft = serializeDraft(draftInstinct);
|
|
873
|
+
const draftsDir = join(INSTINCTS_DIR, project.hash, "drafts");
|
|
874
|
+
const draftPath = join(draftsDir, `${draftInstinct.id}.yaml`);
|
|
875
|
+
try {
|
|
876
|
+
mkdirSync(draftsDir, { recursive: true });
|
|
877
|
+
writeFileSync(draftPath, draft);
|
|
878
|
+
}
|
|
879
|
+
catch (err) {
|
|
880
|
+
return error(`Failed to write draft to ${draftPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
881
|
+
}
|
|
882
|
+
return text([
|
|
883
|
+
"## Draft written from a verified workflow run",
|
|
884
|
+
"",
|
|
885
|
+
`**Workflow:** ${run.name}`,
|
|
886
|
+
`**Path:** ${draftPath}`,
|
|
887
|
+
"",
|
|
888
|
+
"Edit the body to capture the real recipe (preconditions, concrete steps, gotchas), then promote with:",
|
|
889
|
+
"",
|
|
890
|
+
` ci_distill_promote id=${draftInstinct.id}`,
|
|
891
|
+
"",
|
|
892
|
+
"```yaml",
|
|
893
|
+
draft.trimEnd(),
|
|
894
|
+
"```",
|
|
895
|
+
].join("\n"));
|
|
896
|
+
}
|
|
840
897
|
case "ci_distill_promote": {
|
|
841
898
|
if (MODE !== "expert") {
|
|
842
899
|
return error("ci_distill_promote requires expert mode");
|
|
File without changes
|
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: continuous-improvement
|
|
3
|
-
description: "Reflect on the current session, analyze observations for patterns, and show instinct status. Runs on-demand to save tokens."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# /continuous-improvement
|
|
7
|
-
|
|
8
|
-
Run this when you want to reflect and learn — not every session. Three steps in order.
|
|
9
|
-
|
|
10
|
-
## Step 1: Reflect
|
|
11
|
-
|
|
12
|
-
Generate a reflection for this session based on what happened:
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
## Reflection — [Date]
|
|
16
|
-
- What worked:
|
|
17
|
-
- What failed:
|
|
18
|
-
- What I'd do differently:
|
|
19
|
-
- Rule to add:
|
|
20
|
-
- Iteration — Next best recommendations (ranked, top 3):
|
|
21
|
-
1. <primary — strongest next move>
|
|
22
|
-
2. <alternative — different angle>
|
|
23
|
-
3. <alternative — smaller/larger scope>
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
If there's a "Rule to add", create an instinct YAML file with 0.6 starting confidence in the project's instinct directory.
|
|
27
|
-
|
|
28
|
-
The "Iteration — Next best recommendations" field is the Law 6 handoff. List the **top 3 ranked** core-development moves — what to build, fix, refactor, or investigate next so the feature/system advances. Item #1 is the strongest; #2 and #3 are alternatives the user can pivot to. NOT git steps (commit, push, PR), NOT verification re-runs, NOT deploy actions — those belong in the end-of-run summary.
|
|
29
|
-
|
|
30
|
-
Format per item: `<verb> <object at path:line> (<why, one clause grounded in current context>)`.
|
|
31
|
-
|
|
32
|
-
Rules: always exactly 3 distinct directions, not padding. If fewer real moves exist, fill remaining slots with `None — goal met from this angle.` If the goal is fully met across all angles, write `1. None — goal met, stop.` and omit #2 and #3.
|
|
33
|
-
|
|
34
|
-
## Step 2: Analyze Observations
|
|
35
|
-
|
|
36
|
-
Check `~/.claude/instincts/` for the current project (detect via git root → SHA-256 first 12 chars).
|
|
37
|
-
|
|
38
|
-
Look at `~/.claude/instincts/<hash>/observations.jsonl`. If 20+ lines exist:
|
|
39
|
-
|
|
40
|
-
1. Read the last 500 lines
|
|
41
|
-
2. Read existing instinct `*.yaml` files (project + global)
|
|
42
|
-
3. Detect patterns:
|
|
43
|
-
- User corrections → "don't do X" instincts
|
|
44
|
-
- Error→fix sequences → "when X fails, try Y"
|
|
45
|
-
- Repeated workflows (3+ times) → "for X, do A→B→C"
|
|
46
|
-
- Tool preferences → "use tool Y for task X"
|
|
47
|
-
4. Create/update instinct YAML files
|
|
48
|
-
5. Be conservative: only create instincts for 3+ observations of the same pattern
|
|
49
|
-
|
|
50
|
-
If fewer than 20 observations, skip analysis and note the count.
|
|
51
|
-
|
|
52
|
-
### Multi-Agent Analysis (500+ observations)
|
|
53
|
-
|
|
54
|
-
When observation backlog is large, parallelize:
|
|
55
|
-
- **Agent 1:** User corrections + error→fix patterns
|
|
56
|
-
- **Agent 2:** Repeated workflows + tool preferences
|
|
57
|
-
- **Agent 3:** Cross-reference existing instincts for updates
|
|
58
|
-
|
|
59
|
-
Merge results and deduplicate before writing YAML files.
|
|
60
|
-
|
|
61
|
-
## Step 3: Show Status
|
|
62
|
-
|
|
63
|
-
Display all instincts for the current project + global:
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
=== continuous-improvement ===
|
|
67
|
-
|
|
68
|
-
## Level: [CAPTURE | ANALYZE | SUGGEST | AUTO-APPLY]
|
|
69
|
-
|
|
70
|
-
## Session Reflection
|
|
71
|
-
- What worked: [from this session]
|
|
72
|
-
- What failed: [from this session]
|
|
73
|
-
- What I'd do differently: [from this session]
|
|
74
|
-
- Rule to add: [captured as instinct]
|
|
75
|
-
- Iteration — Next best recommendations (ranked, top 3):
|
|
76
|
-
1. [primary core-development move]
|
|
77
|
-
2. [alternative angle]
|
|
78
|
-
3. [alternative scope]
|
|
79
|
-
|
|
80
|
-
## Learning
|
|
81
|
-
NEW [instinct-id] [domain] [confidence] (from reflection)
|
|
82
|
-
↑ [instinct-id] [domain] [old]→[new] (+N observations)
|
|
83
|
-
|
|
84
|
-
## Instincts — [project-name] ([hash])
|
|
85
|
-
● [0.85] instinct-id domain auto-apply
|
|
86
|
-
◐ [0.60] instinct-id domain suggest
|
|
87
|
-
○ [0.35] instinct-id domain silent
|
|
88
|
-
|
|
89
|
-
## Instincts — global
|
|
90
|
-
● [0.90] instinct-id domain auto-apply
|
|
91
|
-
|
|
92
|
-
## Next
|
|
93
|
-
- Keep working — hooks capture automatically
|
|
94
|
-
- System auto-levels as instincts gain confidence
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
If no instincts or observations exist yet, explain this is expected — the system is in CAPTURE level and will create instincts after 20+ observations accumulate.
|
|
98
|
-
|
|
99
|
-
## Subcommands
|
|
100
|
-
|
|
101
|
-
### `/continuous-improvement weekly`
|
|
102
|
-
|
|
103
|
-
Set up a weekly analysis schedule:
|
|
104
|
-
1. Create a cron/loop schedule that runs `/continuous-improvement analyze` every 7 days
|
|
105
|
-
2. Confirm the schedule to the user
|
|
106
|
-
3. Show next scheduled run date
|
|
107
|
-
|
|
108
|
-
### `/continuous-improvement always-on`
|
|
109
|
-
|
|
110
|
-
Toggle always-on mode for the current project:
|
|
111
|
-
1. Find project hash
|
|
112
|
-
2. Create/update `~/.claude/instincts/<hash>/config.yaml` with `always_on: true|false`
|
|
113
|
-
3. Confirm the change
|
|
114
|
-
|
|
115
|
-
**Default is off** — observations accumulate silently, analysis only runs when you ask.
|
|
1
|
+
---
|
|
2
|
+
name: continuous-improvement
|
|
3
|
+
description: "Reflect on the current session, analyze observations for patterns, and show instinct status. Runs on-demand to save tokens."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /continuous-improvement
|
|
7
|
+
|
|
8
|
+
Run this when you want to reflect and learn — not every session. Three steps in order.
|
|
9
|
+
|
|
10
|
+
## Step 1: Reflect
|
|
11
|
+
|
|
12
|
+
Generate a reflection for this session based on what happened:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
## Reflection — [Date]
|
|
16
|
+
- What worked:
|
|
17
|
+
- What failed:
|
|
18
|
+
- What I'd do differently:
|
|
19
|
+
- Rule to add:
|
|
20
|
+
- Iteration — Next best recommendations (ranked, top 3):
|
|
21
|
+
1. <primary — strongest next move>
|
|
22
|
+
2. <alternative — different angle>
|
|
23
|
+
3. <alternative — smaller/larger scope>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
If there's a "Rule to add", create an instinct YAML file with 0.6 starting confidence in the project's instinct directory.
|
|
27
|
+
|
|
28
|
+
The "Iteration — Next best recommendations" field is the Law 6 handoff. List the **top 3 ranked** core-development moves — what to build, fix, refactor, or investigate next so the feature/system advances. Item #1 is the strongest; #2 and #3 are alternatives the user can pivot to. NOT git steps (commit, push, PR), NOT verification re-runs, NOT deploy actions — those belong in the end-of-run summary.
|
|
29
|
+
|
|
30
|
+
Format per item: `<verb> <object at path:line> (<why, one clause grounded in current context>)`.
|
|
31
|
+
|
|
32
|
+
Rules: always exactly 3 distinct directions, not padding. If fewer real moves exist, fill remaining slots with `None — goal met from this angle.` If the goal is fully met across all angles, write `1. None — goal met, stop.` and omit #2 and #3.
|
|
33
|
+
|
|
34
|
+
## Step 2: Analyze Observations
|
|
35
|
+
|
|
36
|
+
Check `~/.claude/instincts/` for the current project (detect via git root → SHA-256 first 12 chars).
|
|
37
|
+
|
|
38
|
+
Look at `~/.claude/instincts/<hash>/observations.jsonl`. If 20+ lines exist:
|
|
39
|
+
|
|
40
|
+
1. Read the last 500 lines
|
|
41
|
+
2. Read existing instinct `*.yaml` files (project + global)
|
|
42
|
+
3. Detect patterns:
|
|
43
|
+
- User corrections → "don't do X" instincts
|
|
44
|
+
- Error→fix sequences → "when X fails, try Y"
|
|
45
|
+
- Repeated workflows (3+ times) → "for X, do A→B→C"
|
|
46
|
+
- Tool preferences → "use tool Y for task X"
|
|
47
|
+
4. Create/update instinct YAML files
|
|
48
|
+
5. Be conservative: only create instincts for 3+ observations of the same pattern
|
|
49
|
+
|
|
50
|
+
If fewer than 20 observations, skip analysis and note the count.
|
|
51
|
+
|
|
52
|
+
### Multi-Agent Analysis (500+ observations)
|
|
53
|
+
|
|
54
|
+
When observation backlog is large, parallelize:
|
|
55
|
+
- **Agent 1:** User corrections + error→fix patterns
|
|
56
|
+
- **Agent 2:** Repeated workflows + tool preferences
|
|
57
|
+
- **Agent 3:** Cross-reference existing instincts for updates
|
|
58
|
+
|
|
59
|
+
Merge results and deduplicate before writing YAML files.
|
|
60
|
+
|
|
61
|
+
## Step 3: Show Status
|
|
62
|
+
|
|
63
|
+
Display all instincts for the current project + global:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
=== continuous-improvement ===
|
|
67
|
+
|
|
68
|
+
## Level: [CAPTURE | ANALYZE | SUGGEST | AUTO-APPLY]
|
|
69
|
+
|
|
70
|
+
## Session Reflection
|
|
71
|
+
- What worked: [from this session]
|
|
72
|
+
- What failed: [from this session]
|
|
73
|
+
- What I'd do differently: [from this session]
|
|
74
|
+
- Rule to add: [captured as instinct]
|
|
75
|
+
- Iteration — Next best recommendations (ranked, top 3):
|
|
76
|
+
1. [primary core-development move]
|
|
77
|
+
2. [alternative angle]
|
|
78
|
+
3. [alternative scope]
|
|
79
|
+
|
|
80
|
+
## Learning
|
|
81
|
+
NEW [instinct-id] [domain] [confidence] (from reflection)
|
|
82
|
+
↑ [instinct-id] [domain] [old]→[new] (+N observations)
|
|
83
|
+
|
|
84
|
+
## Instincts — [project-name] ([hash])
|
|
85
|
+
● [0.85] instinct-id domain auto-apply
|
|
86
|
+
◐ [0.60] instinct-id domain suggest
|
|
87
|
+
○ [0.35] instinct-id domain silent
|
|
88
|
+
|
|
89
|
+
## Instincts — global
|
|
90
|
+
● [0.90] instinct-id domain auto-apply
|
|
91
|
+
|
|
92
|
+
## Next
|
|
93
|
+
- Keep working — hooks capture automatically
|
|
94
|
+
- System auto-levels as instincts gain confidence
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
If no instincts or observations exist yet, explain this is expected — the system is in CAPTURE level and will create instincts after 20+ observations accumulate.
|
|
98
|
+
|
|
99
|
+
## Subcommands
|
|
100
|
+
|
|
101
|
+
### `/continuous-improvement weekly`
|
|
102
|
+
|
|
103
|
+
Set up a weekly analysis schedule:
|
|
104
|
+
1. Create a cron/loop schedule that runs `/continuous-improvement analyze` every 7 days
|
|
105
|
+
2. Confirm the schedule to the user
|
|
106
|
+
3. Show next scheduled run date
|
|
107
|
+
|
|
108
|
+
### `/continuous-improvement always-on`
|
|
109
|
+
|
|
110
|
+
Toggle always-on mode for the current project:
|
|
111
|
+
1. Find project hash
|
|
112
|
+
2. Create/update `~/.claude/instincts/<hash>/config.yaml` with `always_on: true|false`
|
|
113
|
+
3. Confirm the change
|
|
114
|
+
|
|
115
|
+
**Default is off** — observations accumulate silently, analysis only runs when you ask.
|