@selvakumaresra/specship 0.7.0 → 0.9.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.
Files changed (72) hide show
  1. package/dist/bin/specship.js +59 -0
  2. package/dist/bin/specship.js.map +1 -1
  3. package/dist/db/migrations.d.ts +1 -1
  4. package/dist/db/migrations.d.ts.map +1 -1
  5. package/dist/db/migrations.js +28 -1
  6. package/dist/db/migrations.js.map +1 -1
  7. package/dist/db/schema.sql +25 -1
  8. package/dist/index.d.ts +20 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +71 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/reflect/apply.d.ts +31 -0
  13. package/dist/reflect/apply.d.ts.map +1 -0
  14. package/dist/reflect/apply.js +286 -0
  15. package/dist/reflect/apply.js.map +1 -0
  16. package/dist/reflect/hash.d.ts +20 -0
  17. package/dist/reflect/hash.d.ts.map +1 -0
  18. package/dist/reflect/hash.js +36 -0
  19. package/dist/reflect/hash.js.map +1 -0
  20. package/dist/reflect/index.d.ts +16 -0
  21. package/dist/reflect/index.d.ts.map +1 -0
  22. package/dist/reflect/index.js +43 -0
  23. package/dist/reflect/index.js.map +1 -0
  24. package/dist/reflect/miner.d.ts +21 -0
  25. package/dist/reflect/miner.d.ts.map +1 -0
  26. package/dist/reflect/miner.js +463 -0
  27. package/dist/reflect/miner.js.map +1 -0
  28. package/dist/reflect/store.d.ts +31 -0
  29. package/dist/reflect/store.d.ts.map +1 -0
  30. package/dist/reflect/store.js +101 -0
  31. package/dist/reflect/store.js.map +1 -0
  32. package/dist/reflect/sweep.d.ts +26 -0
  33. package/dist/reflect/sweep.d.ts.map +1 -0
  34. package/dist/reflect/sweep.js +42 -0
  35. package/dist/reflect/sweep.js.map +1 -0
  36. package/dist/reflect/targets.d.ts +52 -0
  37. package/dist/reflect/targets.d.ts.map +1 -0
  38. package/dist/reflect/targets.js +192 -0
  39. package/dist/reflect/targets.js.map +1 -0
  40. package/dist/reflect/types.d.ts +96 -0
  41. package/dist/reflect/types.d.ts.map +1 -0
  42. package/dist/reflect/types.js +13 -0
  43. package/dist/reflect/types.js.map +1 -0
  44. package/dist/server/routes/events.js +20 -0
  45. package/dist/server/routes/reflect.js +93 -0
  46. package/dist/server/server.js +2 -0
  47. package/dist/types.d.ts +1 -1
  48. package/dist/types.d.ts.map +1 -1
  49. package/dist/web/chunk-ITHLF4GI.js +1 -0
  50. package/dist/web/chunk-JBO7ZIPO.js +1 -0
  51. package/dist/web/chunk-RJLLYZEQ.js +6 -0
  52. package/dist/web/chunk-TPDB5GJN.js +1 -0
  53. package/dist/web/chunk-Y6WWDS4R.js +1 -0
  54. package/dist/web/chunk-Z5L3T5EO.js +1 -0
  55. package/dist/web/index.html +1 -1
  56. package/dist/web/main-P33TUYUP.js +1 -0
  57. package/dist/workflows/executor.d.ts.map +1 -1
  58. package/dist/workflows/executor.js +3 -0
  59. package/dist/workflows/executor.js.map +1 -1
  60. package/dist/workflows/runners/prompt.d.ts +31 -8
  61. package/dist/workflows/runners/prompt.d.ts.map +1 -1
  62. package/dist/workflows/runners/prompt.js +117 -23
  63. package/dist/workflows/runners/prompt.js.map +1 -1
  64. package/dist/workflows/runners/types.d.ts +7 -1
  65. package/dist/workflows/runners/types.d.ts.map +1 -1
  66. package/package.json +1 -1
  67. package/dist/web/chunk-HGBF7AY5.js +0 -1
  68. package/dist/web/chunk-JQ534IB6.js +0 -6
  69. package/dist/web/chunk-MVOMVPYB.js +0 -1
  70. package/dist/web/chunk-NZEZCT65.js +0 -1
  71. package/dist/web/chunk-WQWYTRFN.js +0 -1
  72. package/dist/web/main-LHCYPOXF.js +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply.js","sourceRoot":"","sources":["../../src/reflect/apply.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBH,4BAmBC;AAyBD,0CA4CC;AAKD,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EAAE,CAAC;QAC7B,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/E,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,IAAI,QAAQ,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/D,OAAO,QAAQ,CAAC,KAAK,CAAC;IACxB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Stable content hashing for proposals (REQ-REFLECT-007.A1).
3
+ *
4
+ * The hash is computed over the *identity* of a proposal — its type, target,
5
+ * and intended payload — and deliberately EXCLUDES evidence (which session ids
6
+ * contributed) and timestamps, both of which vary run to run. Two reflection
7
+ * passes over the same underlying pattern therefore produce the same hash, so
8
+ * the store converges to a single row rather than duplicating.
9
+ */
10
+ import { ProposalPayload, ProposalType, TargetKind } from './types';
11
+ /**
12
+ * Derive the stable content hash for a proposal's identity.
13
+ */
14
+ export declare function proposalHash(parts: {
15
+ type: ProposalType;
16
+ targetKind: TargetKind;
17
+ targetPath: string;
18
+ payload: ProposalPayload;
19
+ }): string;
20
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/reflect/hash.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAWpE;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,eAAe,CAAC;CAC1B,GAAG,MAAM,CAQT"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /**
3
+ * Stable content hashing for proposals (REQ-REFLECT-007.A1).
4
+ *
5
+ * The hash is computed over the *identity* of a proposal — its type, target,
6
+ * and intended payload — and deliberately EXCLUDES evidence (which session ids
7
+ * contributed) and timestamps, both of which vary run to run. Two reflection
8
+ * passes over the same underlying pattern therefore produce the same hash, so
9
+ * the store converges to a single row rather than duplicating.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.proposalHash = proposalHash;
13
+ const crypto_1 = require("crypto");
14
+ /** Canonical JSON: object keys sorted recursively so key order can't perturb the hash. */
15
+ function canonical(value) {
16
+ if (value === null || typeof value !== 'object')
17
+ return JSON.stringify(value);
18
+ if (Array.isArray(value))
19
+ return '[' + value.map(canonical).join(',') + ']';
20
+ const obj = value;
21
+ const keys = Object.keys(obj).sort();
22
+ return '{' + keys.map((k) => JSON.stringify(k) + ':' + canonical(obj[k])).join(',') + '}';
23
+ }
24
+ /**
25
+ * Derive the stable content hash for a proposal's identity.
26
+ */
27
+ function proposalHash(parts) {
28
+ const sig = canonical({
29
+ type: parts.type,
30
+ targetKind: parts.targetKind,
31
+ targetPath: parts.targetPath,
32
+ payload: parts.payload,
33
+ });
34
+ return (0, crypto_1.createHash)('sha256').update(sig).digest('hex').slice(0, 16);
35
+ }
36
+ //# sourceMappingURL=hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/reflect/hash.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAiBH,oCAaC;AA5BD,mCAAoC;AAGpC,0FAA0F;AAC1F,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9E,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IAC5E,MAAM,GAAG,GAAG,KAAgC,CAAC;IAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACrC,OAAO,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AAC5F,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,KAK5B;IACC,MAAM,GAAG,GAAG,SAAS,CAAC;QACpB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC,CAAC;IACH,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACrE,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Reflection engine (REFLECT-DOC) — barrel.
3
+ *
4
+ * Mines the ingested `claude_*` transcript tables for recurring, actionable
5
+ * patterns and turns them into durable, human-gated proposals (memory/CLAUDE.md
6
+ * rules, skills/commands, hooks). Surfaced via the SpecShip class methods, the
7
+ * `specship reflect` CLI, and the dashboard's Improvements list.
8
+ */
9
+ export * from './types';
10
+ export { mineProposals } from './miner';
11
+ export { buildProposal, learningMarkers, memoryNoteMarker } from './targets';
12
+ export { previewProposal, applyProposal, undoProposal, lineDiff } from './apply';
13
+ export { ReflectStore } from './store';
14
+ export { analyze, sweep } from './sweep';
15
+ export type { AnalyzeResult, SweepResult } from './sweep';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reflect/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACzC,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /**
3
+ * Reflection engine (REFLECT-DOC) — barrel.
4
+ *
5
+ * Mines the ingested `claude_*` transcript tables for recurring, actionable
6
+ * patterns and turns them into durable, human-gated proposals (memory/CLAUDE.md
7
+ * rules, skills/commands, hooks). Surfaced via the SpecShip class methods, the
8
+ * `specship reflect` CLI, and the dashboard's Improvements list.
9
+ */
10
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ var desc = Object.getOwnPropertyDescriptor(m, k);
13
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14
+ desc = { enumerable: true, get: function() { return m[k]; } };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
17
+ }) : (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ o[k2] = m[k];
20
+ }));
21
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.sweep = exports.analyze = exports.ReflectStore = exports.lineDiff = exports.undoProposal = exports.applyProposal = exports.previewProposal = exports.memoryNoteMarker = exports.learningMarkers = exports.buildProposal = exports.mineProposals = void 0;
26
+ __exportStar(require("./types"), exports);
27
+ var miner_1 = require("./miner");
28
+ Object.defineProperty(exports, "mineProposals", { enumerable: true, get: function () { return miner_1.mineProposals; } });
29
+ var targets_1 = require("./targets");
30
+ Object.defineProperty(exports, "buildProposal", { enumerable: true, get: function () { return targets_1.buildProposal; } });
31
+ Object.defineProperty(exports, "learningMarkers", { enumerable: true, get: function () { return targets_1.learningMarkers; } });
32
+ Object.defineProperty(exports, "memoryNoteMarker", { enumerable: true, get: function () { return targets_1.memoryNoteMarker; } });
33
+ var apply_1 = require("./apply");
34
+ Object.defineProperty(exports, "previewProposal", { enumerable: true, get: function () { return apply_1.previewProposal; } });
35
+ Object.defineProperty(exports, "applyProposal", { enumerable: true, get: function () { return apply_1.applyProposal; } });
36
+ Object.defineProperty(exports, "undoProposal", { enumerable: true, get: function () { return apply_1.undoProposal; } });
37
+ Object.defineProperty(exports, "lineDiff", { enumerable: true, get: function () { return apply_1.lineDiff; } });
38
+ var store_1 = require("./store");
39
+ Object.defineProperty(exports, "ReflectStore", { enumerable: true, get: function () { return store_1.ReflectStore; } });
40
+ var sweep_1 = require("./sweep");
41
+ Object.defineProperty(exports, "analyze", { enumerable: true, get: function () { return sweep_1.analyze; } });
42
+ Object.defineProperty(exports, "sweep", { enumerable: true, get: function () { return sweep_1.sweep; } });
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reflect/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;;AAEH,0CAAwB;AACxB,iCAAwC;AAA/B,sGAAA,aAAa,OAAA;AACtB,qCAA6E;AAApE,wGAAA,aAAa,OAAA;AAAE,0GAAA,eAAe,OAAA;AAAE,2GAAA,gBAAgB,OAAA;AACzD,iCAAiF;AAAxE,wGAAA,eAAe,OAAA;AAAE,sGAAA,aAAa,OAAA;AAAE,qGAAA,YAAY,OAAA;AAAE,iGAAA,QAAQ,OAAA;AAC/D,iCAAuC;AAA9B,qGAAA,YAAY,OAAA;AACrB,iCAAyC;AAAhC,gGAAA,OAAO,OAAA;AAAE,8FAAA,KAAK,OAAA"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Proposal miner (REQ-REFLECT-001 / 002).
3
+ *
4
+ * Reads the ingested `claude_*` transcript tables and detects recurring,
5
+ * actionable patterns, emitting one typed Proposal per finding with cited
6
+ * evidence and a severity. Each rule is a bounded SQL query (mirroring the tips
7
+ * engine's shape) feeding `buildProposal`, which resolves the concrete write
8
+ * target and the stable content hash.
9
+ *
10
+ * The *set* of rules is the implementation frontier the spec deliberately left
11
+ * open — new detectors slot in here without touching apply/store/surface.
12
+ *
13
+ * When the transcript tables are absent (a headless `specship reflect` against a
14
+ * project the dashboard has never ingested), the miner returns `[]` so the
15
+ * caller can render the empty state rather than erroring (REQ-REFLECT-001.A2).
16
+ */
17
+ import { SqliteDatabase } from '../db/sqlite-adapter';
18
+ import { Proposal, ReflectContext } from './types';
19
+ /** Mine all rules. Pure read — never writes the DB or disk. */
20
+ export declare function mineProposals(db: SqliteDatabase, ctx: ReflectContext): Proposal[];
21
+ //# sourceMappingURL=miner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"miner.d.ts","sourceRoot":"","sources":["../../src/reflect/miner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAkCnD,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,cAAc,GAAG,QAAQ,EAAE,CAkBjF"}
@@ -0,0 +1,463 @@
1
+ "use strict";
2
+ /**
3
+ * Proposal miner (REQ-REFLECT-001 / 002).
4
+ *
5
+ * Reads the ingested `claude_*` transcript tables and detects recurring,
6
+ * actionable patterns, emitting one typed Proposal per finding with cited
7
+ * evidence and a severity. Each rule is a bounded SQL query (mirroring the tips
8
+ * engine's shape) feeding `buildProposal`, which resolves the concrete write
9
+ * target and the stable content hash.
10
+ *
11
+ * The *set* of rules is the implementation frontier the spec deliberately left
12
+ * open — new detectors slot in here without touching apply/store/surface.
13
+ *
14
+ * When the transcript tables are absent (a headless `specship reflect` against a
15
+ * project the dashboard has never ingested), the miner returns `[]` so the
16
+ * caller can render the empty state rather than erroring (REQ-REFLECT-001.A2).
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.mineProposals = mineProposals;
20
+ const targets_1 = require("./targets");
21
+ /** Tuning knobs — thresholds above which a pattern is worth proposing. */
22
+ const THRESHOLDS = {
23
+ repeatedReadsPerSession: 10, // R1: same file Read ≥N times in one session
24
+ grepHabitTotal: 12, // R2: grep/find used ≥N times overall
25
+ repeatedPromptCount: 3, // R3: identical ask appears ≥N times
26
+ repeatedCmdSessions: 2, // R4: same bash command in ≥N sessions
27
+ repeatedCmdTotal: 5, // R4: …and ≥N times overall
28
+ destructiveMin: 2, // R5: a destructive shell op seen ≥N times
29
+ editHotspotTotal: 8, // R6: same file Edited ≥N times overall
30
+ editHotspotSessions: 2, // R6: …across ≥N sessions
31
+ correctionMin: 2, // R7: same corrective instruction repeated ≥N times
32
+ specshipColdReadMin: 15, // R8: reads/greps in a session to count as read-heavy
33
+ specshipColdSessions: 2, // R8: ≥N read-heavy sessions with zero specship calls
34
+ heavyOutputBytes: 50000, // R9: a Bash call whose result exceeds N "tokens"
35
+ heavyOutputMin: 2, // R9: …seen ≥N times
36
+ refDocSessions: 3, // R10: a doc file Read across ≥N distinct sessions
37
+ };
38
+ /** Per-rule cap so a noisy corpus can't flood the Improvements list. */
39
+ const PER_RULE_LIMIT = 5;
40
+ function tableExists(db, name) {
41
+ try {
42
+ const row = db
43
+ .prepare(`SELECT 1 AS x FROM sqlite_master WHERE type='table' AND name=?`)
44
+ .get(name);
45
+ return !!row;
46
+ }
47
+ catch {
48
+ return false;
49
+ }
50
+ }
51
+ /** Mine all rules. Pure read — never writes the DB or disk. */
52
+ function mineProposals(db, ctx) {
53
+ if (!tableExists(db, 'claude_tool_calls') || !tableExists(db, 'claude_prompts')) {
54
+ return [];
55
+ }
56
+ const out = [];
57
+ out.push(...ruleRepeatedReads(db, ctx));
58
+ out.push(...ruleGrepHabit(db, ctx));
59
+ out.push(...ruleRepeatedPrompts(db, ctx));
60
+ out.push(...ruleRepeatedCommands(db, ctx));
61
+ // Round 2 detectors.
62
+ out.push(...ruleDestructiveCommands(db, ctx));
63
+ out.push(...ruleEditHotspot(db, ctx));
64
+ out.push(...ruleRecurringCorrection(db, ctx));
65
+ // Round 3 detectors.
66
+ out.push(...ruleSpecshipCold(db, ctx));
67
+ out.push(...ruleHeavyOutput(db, ctx));
68
+ out.push(...ruleReferenceDoc(db, ctx));
69
+ return out;
70
+ }
71
+ /**
72
+ * R1 → memory_rule (project CLAUDE.md): the agent Read the same file many times
73
+ * in a single session. A project-specific rule steering it to specship_explore
74
+ * for that area is the durable fix.
75
+ */
76
+ function ruleRepeatedReads(db, ctx) {
77
+ const rows = db
78
+ .prepare(`SELECT session_id, input_summary AS file, COUNT(*) AS n
79
+ FROM claude_tool_calls
80
+ WHERE tool_name = 'Read' AND input_summary != ''
81
+ GROUP BY session_id, input_summary
82
+ HAVING n >= ?
83
+ ORDER BY n DESC
84
+ LIMIT ?`)
85
+ .all(THRESHOLDS.repeatedReadsPerSession, PER_RULE_LIMIT);
86
+ return rows.map((r) => {
87
+ const base = r.file.split('/').pop() || r.file;
88
+ return (0, targets_1.buildProposal)(ctx, {
89
+ type: 'memory_rule',
90
+ scope: 'project',
91
+ severity: 'high',
92
+ nameSeed: base,
93
+ title: `Prefer specship_explore over re-reading ${base}`,
94
+ body: `${base} was Read ${r.n} times in a single session. A structural specship_explore query returns its callers, callees, and linked specs in one call — cheaper and complete.`,
95
+ content: `When you need to understand \`${base}\` (or the area around it), call \`specship_explore\` with the relevant symbol names first and treat the returned source as already Read — do not re-Read the file repeatedly.`,
96
+ evidence: {
97
+ sessions: [r.session_id],
98
+ prompts: [],
99
+ detail: `Read(${r.file}) × ${r.n} in one session`,
100
+ },
101
+ });
102
+ });
103
+ }
104
+ /**
105
+ * R2 → memory_rule (portable ~/.claude/memory): heavy grep/find usage is a
106
+ * cross-project habit, so the learning is portable, not repo-specific.
107
+ */
108
+ function ruleGrepHabit(db, ctx) {
109
+ const row = db
110
+ .prepare(`SELECT COUNT(*) AS n, COUNT(DISTINCT session_id) AS s
111
+ FROM claude_tool_calls
112
+ WHERE tool_name = 'Bash'
113
+ AND (input_summary LIKE 'grep%' OR input_summary LIKE '%grep %'
114
+ OR input_summary LIKE 'find %' OR input_summary LIKE 'rg %')`)
115
+ .get();
116
+ if (!row || row.n < THRESHOLDS.grepHabitTotal)
117
+ return [];
118
+ const sessRows = db
119
+ .prepare(`SELECT DISTINCT session_id FROM claude_tool_calls
120
+ WHERE tool_name = 'Bash' AND (input_summary LIKE '%grep %' OR input_summary LIKE 'grep%'
121
+ OR input_summary LIKE 'find %' OR input_summary LIKE 'rg %')
122
+ LIMIT 8`)
123
+ .all();
124
+ return [
125
+ (0, targets_1.buildProposal)(ctx, {
126
+ type: 'memory_rule',
127
+ scope: 'portable',
128
+ severity: 'warn',
129
+ nameSeed: 'prefer-specship-search-over-grep',
130
+ title: 'Prefer specship_search over grep/find',
131
+ body: `grep/find ran ${row.n} times across ${row.s} sessions. specship_search hits the pre-built FTS index and returns symbol locations directly — usually one call instead of a grep+read loop.`,
132
+ content: 'For "where is X" / "find the symbol named X" questions, reach for `specship_search` (or `specship_explore` for "how does X work") before shelling out to grep/find/rg — SpecShip is the pre-built search index, so a grep+read loop repeats work it already did.',
133
+ evidence: {
134
+ sessions: sessRows.map((s) => s.session_id),
135
+ prompts: [],
136
+ detail: `grep/find/rg × ${row.n} across ${row.s} sessions`,
137
+ },
138
+ }),
139
+ ];
140
+ }
141
+ /** Normalize a prompt for grouping: trim, lowercase, collapse whitespace. */
142
+ function normalizePrompt(t) {
143
+ return t.replace(/\s+/g, ' ').trim().toLowerCase();
144
+ }
145
+ /**
146
+ * R3 → skill (commands/ss-<name>.md): the user typed essentially the same ask
147
+ * many times. A reusable slash command captures the routine.
148
+ */
149
+ function ruleRepeatedPrompts(db, ctx) {
150
+ const rows = db
151
+ .prepare(`SELECT id, text FROM claude_prompts
152
+ WHERE text IS NOT NULL AND length(text) BETWEEN 12 AND 200
153
+ AND text NOT LIKE '<%' AND text NOT LIKE '%<command-name>%'
154
+ AND is_sidechain = 0
155
+ ORDER BY ts DESC
156
+ LIMIT 4000`)
157
+ .all();
158
+ const groups = new Map();
159
+ for (const r of rows) {
160
+ const key = normalizePrompt(r.text);
161
+ if (!key)
162
+ continue;
163
+ const g = groups.get(key) ?? { count: 0, prompts: [], sample: r.text.trim() };
164
+ g.count++;
165
+ if (g.prompts.length < 8)
166
+ g.prompts.push(r.id);
167
+ groups.set(key, g);
168
+ }
169
+ const repeated = [...groups.values()]
170
+ .filter((g) => g.count >= THRESHOLDS.repeatedPromptCount)
171
+ .sort((a, b) => b.count - a.count)
172
+ .slice(0, PER_RULE_LIMIT);
173
+ return repeated.map((g) => (0, targets_1.buildProposal)(ctx, {
174
+ type: 'skill',
175
+ severity: 'warn',
176
+ nameSeed: g.sample,
177
+ title: `Capture "${truncate(g.sample, 48)}" as a command`,
178
+ body: `This ask appeared ${g.count} times. A slash command turns the repeated instruction into one reusable invocation.`,
179
+ content: `Run the following routine:\n\n${g.sample}`,
180
+ evidence: {
181
+ sessions: [],
182
+ prompts: g.prompts,
183
+ detail: `Same ask repeated ${g.count}×`,
184
+ },
185
+ }));
186
+ }
187
+ /**
188
+ * R4 → hook (.claude/settings.json): the agent ran the same shell command after
189
+ * edits across multiple sessions. A PostToolUse hook automates the manual step.
190
+ */
191
+ function ruleRepeatedCommands(db, ctx) {
192
+ const rows = db
193
+ .prepare(`SELECT input_summary AS cmd, COUNT(*) AS n, COUNT(DISTINCT session_id) AS s,
194
+ GROUP_CONCAT(DISTINCT session_id) AS sessions
195
+ FROM claude_tool_calls
196
+ WHERE tool_name = 'Bash' AND input_summary != ''
197
+ AND input_summary NOT LIKE 'grep%' AND input_summary NOT LIKE '%grep %'
198
+ AND input_summary NOT LIKE 'find %' AND input_summary NOT LIKE 'cd %'
199
+ AND input_summary NOT LIKE 'ls%' AND input_summary NOT LIKE 'cat %'
200
+ GROUP BY input_summary
201
+ HAVING s >= ? AND n >= ?
202
+ ORDER BY n DESC
203
+ LIMIT ?`)
204
+ .all(THRESHOLDS.repeatedCmdSessions, THRESHOLDS.repeatedCmdTotal, PER_RULE_LIMIT);
205
+ return rows.map((r) => (0, targets_1.buildProposal)(ctx, {
206
+ type: 'hook',
207
+ severity: 'info',
208
+ nameSeed: r.cmd,
209
+ title: `Automate \`${truncate(r.cmd, 40)}\` with a hook`,
210
+ body: `\`${truncate(r.cmd, 80)}\` was run ${r.n} times across ${r.s} sessions, mostly by hand. A PostToolUse hook can run it automatically after edits.`,
211
+ content: r.cmd,
212
+ hook: { event: 'PostToolUse', matcher: 'Edit|Write', command: r.cmd },
213
+ evidence: {
214
+ sessions: (r.sessions || '').split(',').filter(Boolean).slice(0, 8),
215
+ prompts: [],
216
+ detail: `\`${truncate(r.cmd, 60)}\` × ${r.n} across ${r.s} sessions`,
217
+ },
218
+ }));
219
+ }
220
+ /** Destructive shell-operation categories the agent should treat with care. */
221
+ const DESTRUCTIVE = [
222
+ { key: 'rm-rf', label: 'recursive force-delete (`rm -rf`)', re: /\brm\s+-[a-z]*r[a-z]*f[a-z]*\b|\brm\s+-[a-z]*f[a-z]*r[a-z]*\b/i },
223
+ { key: 'git-force-push', label: 'force push (`git push --force`)', re: /\bgit\s+push\b[^|;&]*(--force\b|--force-with-lease\b|\s-f\b)/i },
224
+ { key: 'git-reset-hard', label: 'hard reset (`git reset --hard`)', re: /\bgit\s+reset\b[^|;&]*--hard\b/i },
225
+ { key: 'git-clean', label: 'force clean (`git clean -fd`)', re: /\bgit\s+clean\b[^|;&]*-[a-z]*f/i },
226
+ { key: 'drop-db', label: 'dropping a table/database (`DROP …`)', re: /\bdrop\s+(table|database|schema)\b/i },
227
+ ];
228
+ /**
229
+ * R5 → memory_rule (project CLAUDE.md): destructive shell operations showed up
230
+ * in the transcripts. A high-severity caution rule is the durable response — we
231
+ * deliberately propose a *rule* rather than auto-generating a fragile guard
232
+ * script (a guard-hook variant is a future detector).
233
+ */
234
+ function ruleDestructiveCommands(db, ctx) {
235
+ const rows = db
236
+ .prepare(`SELECT session_id, input_summary AS cmd FROM claude_tool_calls WHERE tool_name = 'Bash' AND input_summary != ''`)
237
+ .all();
238
+ const buckets = new Map();
239
+ for (const r of rows) {
240
+ for (const d of DESTRUCTIVE) {
241
+ if (d.re.test(r.cmd)) {
242
+ const b = buckets.get(d.key) ?? { count: 0, sessions: new Set(), sample: r.cmd };
243
+ b.count++;
244
+ b.sessions.add(r.session_id);
245
+ buckets.set(d.key, b);
246
+ }
247
+ }
248
+ }
249
+ const out = [];
250
+ for (const d of DESTRUCTIVE) {
251
+ const b = buckets.get(d.key);
252
+ if (!b || b.count < THRESHOLDS.destructiveMin)
253
+ continue;
254
+ out.push((0, targets_1.buildProposal)(ctx, {
255
+ type: 'memory_rule',
256
+ scope: 'project',
257
+ severity: 'high',
258
+ nameSeed: `caution-${d.key}`,
259
+ title: `Treat ${d.label} with care`,
260
+ body: `${d.label} ran ${b.count} times across ${b.sessions.size} session(s). A standing caution keeps an irreversible operation from being run without a beat of confirmation.`,
261
+ content: `Before running ${d.label}, pause and confirm the target is correct — these operations are irreversible. Prefer a dry-run or a narrower, reversible alternative when one exists.`,
262
+ evidence: {
263
+ sessions: [...b.sessions].slice(0, 8),
264
+ prompts: [],
265
+ detail: `${d.label} × ${b.count} across ${b.sessions.size} session(s)`,
266
+ },
267
+ }));
268
+ }
269
+ return out;
270
+ }
271
+ /**
272
+ * R6 → memory_rule (project CLAUDE.md): a file is edited over and over across
273
+ * sessions — a hotspot whose contract is worth documenting so future edits
274
+ * don't relearn it from scratch.
275
+ */
276
+ function ruleEditHotspot(db, ctx) {
277
+ const rows = db
278
+ .prepare(`SELECT input_summary AS file, COUNT(*) AS n, COUNT(DISTINCT session_id) AS s,
279
+ GROUP_CONCAT(DISTINCT session_id) AS sessions
280
+ FROM claude_tool_calls
281
+ WHERE tool_name IN ('Edit', 'Write', 'MultiEdit') AND input_summary != ''
282
+ GROUP BY input_summary
283
+ HAVING n >= ? AND s >= ?
284
+ ORDER BY n DESC
285
+ LIMIT ?`)
286
+ .all(THRESHOLDS.editHotspotTotal, THRESHOLDS.editHotspotSessions, PER_RULE_LIMIT);
287
+ return rows.map((r) => {
288
+ const base = r.file.split('/').pop() || r.file;
289
+ return (0, targets_1.buildProposal)(ctx, {
290
+ type: 'memory_rule',
291
+ scope: 'project',
292
+ severity: 'warn',
293
+ nameSeed: `hotspot-${base}`,
294
+ title: `Document the contract of ${base} — it changes often`,
295
+ body: `${base} was edited ${r.n} times across ${r.s} sessions. Capturing its invariants (and what must stay true after a change) saves rediscovering them on every edit.`,
296
+ content: `\`${base}\` is a frequently-edited hotspot. Before changing it, check \`specship_explore\` for its callers and document the invariants a change must preserve. Consider whether it needs tighter test coverage.`,
297
+ evidence: {
298
+ sessions: (r.sessions || '').split(',').filter(Boolean).slice(0, 8),
299
+ prompts: [],
300
+ detail: `${base} edited × ${r.n} across ${r.s} sessions`,
301
+ },
302
+ });
303
+ });
304
+ }
305
+ /** Leading cues that mark a prompt as a correction of the agent's behavior. */
306
+ const CORRECTION_CUE = /^(no\b|don'?t\b|do not\b|never\b|always\b|stop\b|instead\b|actually\b|you should\b|please don'?t\b)/i;
307
+ /**
308
+ * R7 → memory_rule (portable ~/.claude/memory): the user keeps issuing the same
309
+ * corrective instruction. That's a durable preference worth recording so it
310
+ * doesn't have to be repeated — the core Hermes "learn from corrections" idea.
311
+ */
312
+ function ruleRecurringCorrection(db, ctx) {
313
+ const rows = db
314
+ .prepare(`SELECT id, text FROM claude_prompts
315
+ WHERE text IS NOT NULL AND length(text) BETWEEN 12 AND 200
316
+ AND text NOT LIKE '<%' AND text NOT LIKE '%<command-name>%'
317
+ AND is_sidechain = 0
318
+ ORDER BY ts DESC
319
+ LIMIT 4000`)
320
+ .all();
321
+ const groups = new Map();
322
+ for (const r of rows) {
323
+ const trimmed = r.text.trim();
324
+ if (!CORRECTION_CUE.test(trimmed))
325
+ continue;
326
+ const key = trimmed.replace(/\s+/g, ' ').toLowerCase();
327
+ const g = groups.get(key) ?? { count: 0, prompts: [], sample: trimmed };
328
+ g.count++;
329
+ if (g.prompts.length < 8)
330
+ g.prompts.push(r.id);
331
+ groups.set(key, g);
332
+ }
333
+ const repeated = [...groups.values()]
334
+ .filter((g) => g.count >= THRESHOLDS.correctionMin)
335
+ .sort((a, b) => b.count - a.count)
336
+ .slice(0, PER_RULE_LIMIT);
337
+ return repeated.map((g) => (0, targets_1.buildProposal)(ctx, {
338
+ type: 'memory_rule',
339
+ scope: 'portable',
340
+ severity: 'warn',
341
+ nameSeed: `correction-${g.sample}`,
342
+ title: `Recurring correction: "${truncate(g.sample, 48)}"`,
343
+ body: `You've given this correction ${g.count} times. Recording it as a durable preference means you shouldn't have to repeat it.`,
344
+ content: `Standing user preference (you have repeated this): ${g.sample}`,
345
+ evidence: {
346
+ sessions: [],
347
+ prompts: g.prompts,
348
+ detail: `Correction repeated ${g.count}×`,
349
+ },
350
+ }));
351
+ }
352
+ /**
353
+ * R8 → memory_rule (portable ~/.claude/memory): sessions that lean hard on
354
+ * Read/grep while making zero specship calls. SpecShip is indexed here, so a
355
+ * portable habit-note to query it first is the durable fix. Uses the
356
+ * `is_specship` classification on tool calls.
357
+ */
358
+ function ruleSpecshipCold(db, ctx) {
359
+ const rows = db
360
+ .prepare(`SELECT session_id,
361
+ SUM(CASE WHEN tool_name IN ('Read','Grep')
362
+ OR (tool_name='Bash' AND (input_summary LIKE 'grep%' OR input_summary LIKE '%grep %'
363
+ OR input_summary LIKE 'find %' OR input_summary LIKE 'rg %'))
364
+ THEN 1 ELSE 0 END) AS reads,
365
+ SUM(is_specship) AS ss
366
+ FROM claude_tool_calls
367
+ GROUP BY session_id
368
+ HAVING reads >= ? AND ss = 0`)
369
+ .all(THRESHOLDS.specshipColdReadMin);
370
+ if (rows.length < THRESHOLDS.specshipColdSessions)
371
+ return [];
372
+ const totalReads = rows.reduce((a, r) => a + r.reads, 0);
373
+ return [
374
+ (0, targets_1.buildProposal)(ctx, {
375
+ type: 'memory_rule',
376
+ scope: 'portable',
377
+ severity: 'warn',
378
+ nameSeed: 'query-specship-first',
379
+ title: 'Query SpecShip before reading or grepping',
380
+ body: `${rows.length} read-heavy sessions (${totalReads} Read/grep calls) made no specship calls at all. SpecShip is the pre-built index for this code — a structural query usually answers in one call what a grep+read loop takes many.`,
381
+ content: 'This project is indexed by SpecShip. For "how does X work" / "where is X" / trace / impact questions, call `specship_explore` (or `specship_search`) FIRST and treat the returned source as already Read — only fall back to Read/grep to confirm a detail it did not cover.',
382
+ evidence: {
383
+ sessions: rows.map((r) => r.session_id).slice(0, 8),
384
+ prompts: [],
385
+ detail: `${rows.length} read-heavy sessions with 0 specship calls`,
386
+ },
387
+ }),
388
+ ];
389
+ }
390
+ /**
391
+ * R9 → memory_rule (project CLAUDE.md): a Bash command that dumps a huge result
392
+ * into context, repeatedly. Scoping its output (or using a structural query) is
393
+ * the durable fix. Uses `result_length`.
394
+ */
395
+ function ruleHeavyOutput(db, ctx) {
396
+ const rows = db
397
+ .prepare(`SELECT input_summary AS cmd, COUNT(*) AS n, MAX(result_length) AS maxlen,
398
+ GROUP_CONCAT(DISTINCT session_id) AS sessions
399
+ FROM claude_tool_calls
400
+ WHERE tool_name = 'Bash' AND input_summary != '' AND result_length > ?
401
+ GROUP BY input_summary
402
+ HAVING n >= ?
403
+ ORDER BY maxlen DESC
404
+ LIMIT ?`)
405
+ .all(THRESHOLDS.heavyOutputBytes, THRESHOLDS.heavyOutputMin, PER_RULE_LIMIT);
406
+ return rows.map((r) => (0, targets_1.buildProposal)(ctx, {
407
+ type: 'memory_rule',
408
+ scope: 'project',
409
+ severity: 'warn',
410
+ nameSeed: `heavy-output-${r.cmd}`,
411
+ title: `Scope the output of \`${truncate(r.cmd, 40)}\``,
412
+ body: `\`${truncate(r.cmd, 80)}\` returned up to ~${Math.round(r.maxlen / 1000)}k tokens and ran ${r.n} times. Dumping large output into context is a dominant cost driver.`,
413
+ content: `When you need the result of \`${truncate(r.cmd, 80)}\`, scope it (filter, head, or target a path) — or answer the underlying question with a \`specship_search\`/\`specship_explore\` query instead of reading the full output into context.`,
414
+ evidence: {
415
+ sessions: (r.sessions || '').split(',').filter(Boolean).slice(0, 8),
416
+ prompts: [],
417
+ detail: `~${Math.round(r.maxlen / 1000)}k-token output × ${r.n}`,
418
+ },
419
+ }));
420
+ }
421
+ /**
422
+ * R10 → memory_rule (project CLAUDE.md): a documentation file read across many
423
+ * separate sessions is context the agent keeps rediscovering. Pointing at it
424
+ * from CLAUDE.md keeps it in context. Distinct from R1 (in-session re-reads of
425
+ * any file) — this keys on cross-session breadth of a *doc* file.
426
+ */
427
+ function ruleReferenceDoc(db, ctx) {
428
+ const rows = db
429
+ .prepare(`SELECT input_summary AS file, COUNT(DISTINCT session_id) AS s,
430
+ GROUP_CONCAT(DISTINCT session_id) AS sessions
431
+ FROM claude_tool_calls
432
+ WHERE tool_name = 'Read' AND input_summary != ''
433
+ AND (input_summary LIKE '%.md' OR input_summary LIKE '%.mdx'
434
+ OR input_summary LIKE '%.txt' OR input_summary LIKE '%.rst'
435
+ OR input_summary LIKE '%.adoc')
436
+ GROUP BY input_summary
437
+ HAVING s >= ?
438
+ ORDER BY s DESC
439
+ LIMIT ?`)
440
+ .all(THRESHOLDS.refDocSessions, PER_RULE_LIMIT);
441
+ return rows.map((r) => {
442
+ const base = r.file.split('/').pop() || r.file;
443
+ return (0, targets_1.buildProposal)(ctx, {
444
+ type: 'memory_rule',
445
+ scope: 'project',
446
+ severity: 'warn',
447
+ nameSeed: `reference-${base}`,
448
+ title: `Reference ${base} from CLAUDE.md`,
449
+ body: `${base} was read in ${r.s} separate sessions — context the agent keeps rediscovering. Pointing at it from CLAUDE.md (or importing it with @path) keeps it on hand without a Read each time.`,
450
+ content: `\`${base}\` is frequently-needed context. Add a short pointer to it here (or import it with \`@${r.file}\`) so its guidance is always in context instead of re-Read each session.`,
451
+ evidence: {
452
+ sessions: (r.sessions || '').split(',').filter(Boolean).slice(0, 8),
453
+ prompts: [],
454
+ detail: `${base} read across ${r.s} sessions`,
455
+ },
456
+ });
457
+ });
458
+ }
459
+ function truncate(s, n) {
460
+ const t = s.replace(/\s+/g, ' ').trim();
461
+ return t.length > n ? t.slice(0, n) + '…' : t;
462
+ }
463
+ //# sourceMappingURL=miner.js.map