@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":"miner.js","sourceRoot":"","sources":["../../src/reflect/miner.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAuCH,sCAkBC;AAtDD,uCAA0C;AAG1C,0EAA0E;AAC1E,MAAM,UAAU,GAAG;IAC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AK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;gBACnE,OAAO,EAAE,EAAE;gBACX,MAAM,EAAE,GAAG,IAAI,gBAAgB,CAAC,CAAC,CAAC,WAAW;aAC9C;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS,EAAE,CAAS;IACpC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACxC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Proposal persistence (REQ-REFLECT-007).
3
+ *
4
+ * Wraps the `reflect_proposals` table. Proposals are keyed by `contentHash`, so
5
+ * re-mining the same pattern UPSERTs the existing row (refreshing the
6
+ * user-facing fields + evidence) while PRESERVING its state — a dismissed
7
+ * proposal stays dismissed, an applied one stays applied. `upsertMined` reports
8
+ * which hashes were freshly inserted, which the sweep uses to decide what's
9
+ * "new" and therefore notify-worthy (REQ-REFLECT-006).
10
+ */
11
+ import { SqliteDatabase } from '../db/sqlite-adapter';
12
+ import { Proposal, ProposalState } from './types';
13
+ export declare class ReflectStore {
14
+ private db;
15
+ private now;
16
+ constructor(db: SqliteDatabase, now?: () => number);
17
+ /**
18
+ * Persist a freshly-mined batch. Returns the proposals as stored (with state
19
+ * resolved) plus the set of hashes that were newly inserted this call.
20
+ */
21
+ upsertMined(mined: Proposal[]): {
22
+ stored: Proposal[];
23
+ insertedHashes: Set<string>;
24
+ };
25
+ get(hash: string): Proposal | null;
26
+ /** List proposals, optionally filtered by state. Newest-updated first. */
27
+ list(state?: ProposalState): Proposal[];
28
+ /** Transition a proposal's state. `applied` stamps `applied_at` on first apply. */
29
+ setState(hash: string, state: ProposalState): void;
30
+ }
31
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/reflect/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAoClD,qBAAa,YAAY;IACX,OAAO,CAAC,EAAE;IAAkB,OAAO,CAAC,GAAG;gBAA/B,EAAE,EAAE,cAAc,EAAU,GAAG,GAAE,MAAM,MAAyB;IAEpF;;;OAGG;IACH,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG;QAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QAAC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KAAE;IAwCnF,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI;IAOlC,0EAA0E;IAC1E,IAAI,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,QAAQ,EAAE;IASvC,mFAAmF;IACnF,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI;CAgBnD"}
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ /**
3
+ * Proposal persistence (REQ-REFLECT-007).
4
+ *
5
+ * Wraps the `reflect_proposals` table. Proposals are keyed by `contentHash`, so
6
+ * re-mining the same pattern UPSERTs the existing row (refreshing the
7
+ * user-facing fields + evidence) while PRESERVING its state — a dismissed
8
+ * proposal stays dismissed, an applied one stays applied. `upsertMined` reports
9
+ * which hashes were freshly inserted, which the sweep uses to decide what's
10
+ * "new" and therefore notify-worthy (REQ-REFLECT-006).
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.ReflectStore = void 0;
14
+ function rowToProposal(r) {
15
+ return {
16
+ contentHash: r.content_hash,
17
+ type: r.type,
18
+ severity: r.severity,
19
+ title: r.title,
20
+ body: r.body,
21
+ targetKind: r.target_kind,
22
+ targetPath: r.target_path,
23
+ payload: JSON.parse(r.payload),
24
+ evidence: JSON.parse(r.evidence),
25
+ state: r.state,
26
+ createdAt: r.created_at,
27
+ updatedAt: r.updated_at,
28
+ appliedAt: r.applied_at,
29
+ };
30
+ }
31
+ class ReflectStore {
32
+ db;
33
+ now;
34
+ constructor(db, now = () => Date.now()) {
35
+ this.db = db;
36
+ this.now = now;
37
+ }
38
+ /**
39
+ * Persist a freshly-mined batch. Returns the proposals as stored (with state
40
+ * resolved) plus the set of hashes that were newly inserted this call.
41
+ */
42
+ upsertMined(mined) {
43
+ const insertedHashes = new Set();
44
+ const ts = this.now();
45
+ const existsStmt = this.db.prepare(`SELECT 1 AS x FROM reflect_proposals WHERE content_hash = ?`);
46
+ const insertStmt = this.db.prepare(`INSERT INTO reflect_proposals
47
+ (content_hash, type, severity, title, body, target_kind, target_path, payload, evidence, state, created_at, updated_at, applied_at)
48
+ VALUES (?,?,?,?,?,?,?,?,?, 'open', ?, ?, NULL)
49
+ ON CONFLICT(content_hash) DO UPDATE SET
50
+ severity = excluded.severity,
51
+ title = excluded.title,
52
+ body = excluded.body,
53
+ payload = excluded.payload,
54
+ evidence = excluded.evidence,
55
+ updated_at = excluded.updated_at`);
56
+ const tx = this.db.transaction((items) => {
57
+ for (const p of items) {
58
+ const already = existsStmt.get(p.contentHash);
59
+ if (!already)
60
+ insertedHashes.add(p.contentHash);
61
+ insertStmt.run(p.contentHash, p.type, p.severity, p.title, p.body, p.targetKind, p.targetPath, JSON.stringify(p.payload), JSON.stringify(p.evidence), ts, ts);
62
+ }
63
+ });
64
+ tx(mined);
65
+ const stored = mined.map((p) => this.get(p.contentHash)).filter((x) => !!x);
66
+ return { stored, insertedHashes };
67
+ }
68
+ get(hash) {
69
+ const r = this.db
70
+ .prepare(`SELECT * FROM reflect_proposals WHERE content_hash = ?`)
71
+ .get(hash);
72
+ return r ? rowToProposal(r) : null;
73
+ }
74
+ /** List proposals, optionally filtered by state. Newest-updated first. */
75
+ list(state) {
76
+ const rows = state
77
+ ? this.db
78
+ .prepare(`SELECT * FROM reflect_proposals WHERE state = ? ORDER BY updated_at DESC`)
79
+ .all(state)
80
+ : this.db.prepare(`SELECT * FROM reflect_proposals ORDER BY updated_at DESC`).all();
81
+ return rows.map(rowToProposal);
82
+ }
83
+ /** Transition a proposal's state. `applied` stamps `applied_at` on first apply. */
84
+ setState(hash, state) {
85
+ const ts = this.now();
86
+ if (state === 'applied') {
87
+ this.db
88
+ .prepare(`UPDATE reflect_proposals
89
+ SET state = ?, updated_at = ?, applied_at = COALESCE(applied_at, ?)
90
+ WHERE content_hash = ?`)
91
+ .run(state, ts, ts, hash);
92
+ }
93
+ else {
94
+ this.db
95
+ .prepare(`UPDATE reflect_proposals SET state = ?, updated_at = ? WHERE content_hash = ?`)
96
+ .run(state, ts, hash);
97
+ }
98
+ }
99
+ }
100
+ exports.ReflectStore = ReflectStore;
101
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/reflect/store.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAqBH,SAAS,aAAa,CAAC,CAAM;IAC3B,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,YAAY;QAC3B,IAAI,EAAE,CAAC,CAAC,IAAwB;QAChC,QAAQ,EAAE,CAAC,CAAC,QAAgC;QAC5C,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,UAAU,EAAE,CAAC,CAAC,WAAqC;QACnD,UAAU,EAAE,CAAC,CAAC,WAAW;QACzB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAwB;QACrD,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAA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E,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;QAC9B,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,EAAE;iBACJ,OAAO,CAAC,+EAA+E,CAAC;iBACxF,GAAG,CAAC,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;CACF;AAjFD,oCAiFC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Reflection orchestration (REQ-REFLECT-001 / 006).
3
+ *
4
+ * `analyze` runs the miner and persists the batch, returning the current open
5
+ * proposals — this is what the on-demand button and `specship reflect` call.
6
+ *
7
+ * `sweep` does the same but additionally returns the proposals that should fire
8
+ * a notification: freshly-inserted (not previously seen, applied, or dismissed)
9
+ * AND high-severity. Already-seen and lower-severity findings are persisted and
10
+ * listed, but never re-notified.
11
+ */
12
+ import { SqliteDatabase } from '../db/sqlite-adapter';
13
+ import { Proposal, ReflectContext } from './types';
14
+ export interface AnalyzeResult {
15
+ /** All currently-open proposals after this run. */
16
+ open: Proposal[];
17
+ /** Whether the transcript corpus yielded any signal at all (REQ-REFLECT-001.A2). */
18
+ empty: boolean;
19
+ }
20
+ export interface SweepResult extends AnalyzeResult {
21
+ /** New high-severity proposals worth a notification (REQ-REFLECT-006.A2/A3). */
22
+ notify: Proposal[];
23
+ }
24
+ export declare function analyze(db: SqliteDatabase, ctx: ReflectContext, now?: () => number): AnalyzeResult;
25
+ export declare function sweep(db: SqliteDatabase, ctx: ReflectContext, now?: () => number): SweepResult;
26
+ //# sourceMappingURL=sweep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sweep.d.ts","sourceRoot":"","sources":["../../src/reflect/sweep.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,oFAAoF;IACpF,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,gFAAgF;IAChF,MAAM,EAAE,QAAQ,EAAE,CAAC;CACpB;AAED,wBAAgB,OAAO,CACrB,EAAE,EAAE,cAAc,EAClB,GAAG,EAAE,cAAc,EACnB,GAAG,GAAE,MAAM,MAAyB,GACnC,aAAa,CAKf;AAED,wBAAgB,KAAK,CACnB,EAAE,EAAE,cAAc,EAClB,GAAG,EAAE,cAAc,EACnB,GAAG,GAAE,MAAM,MAAyB,GACnC,WAAW,CAgBb"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /**
3
+ * Reflection orchestration (REQ-REFLECT-001 / 006).
4
+ *
5
+ * `analyze` runs the miner and persists the batch, returning the current open
6
+ * proposals — this is what the on-demand button and `specship reflect` call.
7
+ *
8
+ * `sweep` does the same but additionally returns the proposals that should fire
9
+ * a notification: freshly-inserted (not previously seen, applied, or dismissed)
10
+ * AND high-severity. Already-seen and lower-severity findings are persisted and
11
+ * listed, but never re-notified.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.analyze = analyze;
15
+ exports.sweep = sweep;
16
+ const miner_1 = require("./miner");
17
+ const store_1 = require("./store");
18
+ function analyze(db, ctx, now = () => Date.now()) {
19
+ const store = new store_1.ReflectStore(db, now);
20
+ const mined = (0, miner_1.mineProposals)(db, ctx);
21
+ if (mined.length > 0)
22
+ store.upsertMined(mined);
23
+ return { open: store.list('open'), empty: mined.length === 0 };
24
+ }
25
+ function sweep(db, ctx, now = () => Date.now()) {
26
+ const store = new store_1.ReflectStore(db, now);
27
+ const mined = (0, miner_1.mineProposals)(db, ctx);
28
+ const notify = [];
29
+ if (mined.length > 0) {
30
+ const { stored, insertedHashes } = store.upsertMined(mined);
31
+ for (const p of stored) {
32
+ // Notify only on a brand-new, still-open, high-severity proposal. A row
33
+ // that already existed (even if re-mined) is not "new"; an applied or
34
+ // dismissed one is filtered by the open check.
35
+ if (insertedHashes.has(p.contentHash) && p.severity === 'high' && p.state === 'open') {
36
+ notify.push(p);
37
+ }
38
+ }
39
+ }
40
+ return { open: store.list('open'), empty: mined.length === 0, notify };
41
+ }
42
+ //# sourceMappingURL=sweep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sweep.js","sourceRoot":"","sources":["../../src/reflect/sweep.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAmBH,0BASC;AAED,sBAoBC;AA/CD,mCAAwC;AACxC,mCAAuC;AAevC,SAAgB,OAAO,CACrB,EAAkB,EAClB,GAAmB,EACnB,MAAoB,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;IAEpC,MAAM,KAAK,GAAG,IAAI,oBAAY,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACxC,MAAM,KAAK,GAAG,IAAA,qBAAa,EAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACrC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC/C,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;AACjE,CAAC;AAED,SAAgB,KAAK,CACnB,EAAkB,EAClB,GAAmB,EACnB,MAAoB,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;IAEpC,MAAM,KAAK,GAAG,IAAI,oBAAY,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACxC,MAAM,KAAK,GAAG,IAAA,qBAAa,EAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACrC,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC5D,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;YACvB,wEAAwE;YACxE,sEAAsE;YACtE,+CAA+C;YAC/C,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,MAAM,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;gBACrF,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;AACzE,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Target resolution (REQ-REFLECT-002).
3
+ *
4
+ * Each proposal type maps to a concrete write target with its own marker
5
+ * convention so the apply can be idempotent (re-apply = no-op) and reversible
6
+ * (undo strips exactly what apply added — REQ-REFLECT-004):
7
+ *
8
+ * - memory_rule, project scope → a `<!-- SPECSHIP_LEARNING:<id> -->` block in
9
+ * the project CLAUDE.md
10
+ * - memory_rule, portable scope → a new `~/.claude/memory/<slug>.md` note
11
+ * (carrying a `specship_proposal:` frontmatter
12
+ * marker) + a one-line `MEMORY.md` pointer
13
+ * - skill → a new `commands/ss-<name>.md` (carrying a
14
+ * leading marker comment)
15
+ * - hook → a hook entry merged into `.claude/settings.json`
16
+ *
17
+ * This module is pure: it builds the payload + path, it does not touch disk.
18
+ */
19
+ import { Proposal, ProposalEvidence, ProposalSeverity, ProposalType, ReflectContext } from './types';
20
+ /** Marker bounding an engine-written block in CLAUDE.md / command files. */
21
+ export declare function learningMarkers(id: string): {
22
+ start: string;
23
+ end: string;
24
+ };
25
+ /** Frontmatter marker line stamped into an engine-created memory note. */
26
+ export declare function memoryNoteMarker(id: string): string;
27
+ /**
28
+ * Assemble a fully-formed Proposal from a rule's raw inputs. Computes the target
29
+ * path, builds the type-specific payload (including its markers), and derives the
30
+ * stable content hash. `createdAt`/`updatedAt` are stamped by the caller (the
31
+ * store) — here they default to 0 so the object is pure/deterministic.
32
+ */
33
+ export declare function buildProposal(ctx: ReflectContext, input: {
34
+ type: ProposalType;
35
+ severity: ProposalSeverity;
36
+ title: string;
37
+ body: string;
38
+ evidence: ProposalEvidence;
39
+ /** memory_rule scope: 'project' → CLAUDE.md, 'portable' → ~/.claude/memory note. */
40
+ scope?: 'project' | 'portable';
41
+ /** The durable rule/skill/hook content, type-dependent. */
42
+ content: string;
43
+ /** Hook-only: the settings.json event + matcher + command. */
44
+ hook?: {
45
+ event: string;
46
+ matcher: string;
47
+ command: string;
48
+ };
49
+ /** A short name seed (for slug / command name). */
50
+ nameSeed: string;
51
+ }): Proposal;
52
+ //# sourceMappingURL=targets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"targets.d.ts","sourceRoot":"","sources":["../../src/reflect/targets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,EACL,QAAQ,EACR,gBAAgB,EAEhB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EAEf,MAAM,SAAS,CAAC;AAEjB,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAK1E;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEnD;AAUD;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,cAAc,EACnB,KAAK,EAAE;IACL,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,oFAAoF;IACpF,KAAK,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IAC/B,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;CAClB,GACA,QAAQ,CAsEV"}
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+ /**
3
+ * Target resolution (REQ-REFLECT-002).
4
+ *
5
+ * Each proposal type maps to a concrete write target with its own marker
6
+ * convention so the apply can be idempotent (re-apply = no-op) and reversible
7
+ * (undo strips exactly what apply added — REQ-REFLECT-004):
8
+ *
9
+ * - memory_rule, project scope → a `<!-- SPECSHIP_LEARNING:<id> -->` block in
10
+ * the project CLAUDE.md
11
+ * - memory_rule, portable scope → a new `~/.claude/memory/<slug>.md` note
12
+ * (carrying a `specship_proposal:` frontmatter
13
+ * marker) + a one-line `MEMORY.md` pointer
14
+ * - skill → a new `commands/ss-<name>.md` (carrying a
15
+ * leading marker comment)
16
+ * - hook → a hook entry merged into `.claude/settings.json`
17
+ *
18
+ * This module is pure: it builds the payload + path, it does not touch disk.
19
+ */
20
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ var desc = Object.getOwnPropertyDescriptor(m, k);
23
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
24
+ desc = { enumerable: true, get: function() { return m[k]; } };
25
+ }
26
+ Object.defineProperty(o, k2, desc);
27
+ }) : (function(o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ o[k2] = m[k];
30
+ }));
31
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
32
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
33
+ }) : function(o, v) {
34
+ o["default"] = v;
35
+ });
36
+ var __importStar = (this && this.__importStar) || (function () {
37
+ var ownKeys = function(o) {
38
+ ownKeys = Object.getOwnPropertyNames || function (o) {
39
+ var ar = [];
40
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
41
+ return ar;
42
+ };
43
+ return ownKeys(o);
44
+ };
45
+ return function (mod) {
46
+ if (mod && mod.__esModule) return mod;
47
+ var result = {};
48
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
49
+ __setModuleDefault(result, mod);
50
+ return result;
51
+ };
52
+ })();
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.learningMarkers = learningMarkers;
55
+ exports.memoryNoteMarker = memoryNoteMarker;
56
+ exports.buildProposal = buildProposal;
57
+ const path = __importStar(require("path"));
58
+ const hash_1 = require("./hash");
59
+ /** Marker bounding an engine-written block in CLAUDE.md / command files. */
60
+ function learningMarkers(id) {
61
+ return {
62
+ start: `<!-- SPECSHIP_LEARNING:${id} -->`,
63
+ end: `<!-- /SPECSHIP_LEARNING:${id} -->`,
64
+ };
65
+ }
66
+ /** Frontmatter marker line stamped into an engine-created memory note. */
67
+ function memoryNoteMarker(id) {
68
+ return `specship_proposal: ${id}`;
69
+ }
70
+ function slugify(s) {
71
+ return s
72
+ .toLowerCase()
73
+ .replace(/[^a-z0-9]+/g, '-')
74
+ .replace(/(^-|-$)/g, '')
75
+ .slice(0, 48) || 'learning';
76
+ }
77
+ /**
78
+ * Assemble a fully-formed Proposal from a rule's raw inputs. Computes the target
79
+ * path, builds the type-specific payload (including its markers), and derives the
80
+ * stable content hash. `createdAt`/`updatedAt` are stamped by the caller (the
81
+ * store) — here they default to 0 so the object is pure/deterministic.
82
+ */
83
+ function buildProposal(ctx, input) {
84
+ let targetKind;
85
+ let targetPath;
86
+ let payload;
87
+ if (input.type === 'memory_rule') {
88
+ if (input.scope === 'portable') {
89
+ const slug = slugify(input.nameSeed);
90
+ targetKind = 'memory_note';
91
+ targetPath = path.join(ctx.homeDir, '.claude', 'memory', `${slug}.md`);
92
+ // Hash needs a deterministic id; derive a provisional one from the slug so
93
+ // the marker is stable, then fold everything into the final hash below.
94
+ const note = renderMemoryNote(slug, input.title, input.content);
95
+ const indexLine = `- [${input.title}](${slug}.md) — ${firstSentence(input.body)}`;
96
+ payload = { kind: 'memory_note', slug, note, indexLine };
97
+ }
98
+ else {
99
+ targetKind = 'claude_md';
100
+ targetPath = path.join(ctx.projectRoot, 'CLAUDE.md');
101
+ // markerId is finalized after we know the hash; use a placeholder then
102
+ // re-render once hashed (below) so the block carries its own id.
103
+ payload = { kind: 'claude_md', markerId: '', block: '' };
104
+ }
105
+ }
106
+ else if (input.type === 'skill') {
107
+ const name = slugify(input.nameSeed).replace(/^ss-/, '');
108
+ targetKind = 'command';
109
+ targetPath = path.join(ctx.projectRoot, 'commands', `ss-${name}.md`);
110
+ payload = { kind: 'command', name: `ss-${name}`, content: '' };
111
+ }
112
+ else {
113
+ // hook
114
+ targetKind = 'settings_hook';
115
+ targetPath = path.join(ctx.projectRoot, '.claude', 'settings.json');
116
+ const h = input.hook;
117
+ payload = {
118
+ kind: 'settings_hook',
119
+ event: h.event,
120
+ matcher: h.matcher,
121
+ entry: { type: 'command', command: h.command },
122
+ };
123
+ }
124
+ // First-pass hash over the (still-placeholder) identity, then bake the id into
125
+ // marker-bearing payloads and re-hash so the persisted hash matches the bytes.
126
+ let contentHash = (0, hash_1.proposalHash)({ type: input.type, targetKind, targetPath, payload });
127
+ if (payload.kind === 'claude_md') {
128
+ const { start, end } = learningMarkers(contentHash);
129
+ const block = `${start}\n${renderClaudeRule(input.title, input.content)}\n${end}`;
130
+ payload = { kind: 'claude_md', markerId: contentHash, block };
131
+ contentHash = (0, hash_1.proposalHash)({ type: input.type, targetKind, targetPath, payload });
132
+ }
133
+ else if (payload.kind === 'command') {
134
+ const content = renderCommand(contentHash, payload.name, input.title, input.content);
135
+ payload = { kind: 'command', name: payload.name, content };
136
+ contentHash = (0, hash_1.proposalHash)({ type: input.type, targetKind, targetPath, payload });
137
+ }
138
+ return {
139
+ contentHash,
140
+ type: input.type,
141
+ severity: input.severity,
142
+ title: input.title,
143
+ body: input.body,
144
+ targetKind,
145
+ targetPath,
146
+ payload,
147
+ evidence: input.evidence,
148
+ state: 'open',
149
+ createdAt: 0,
150
+ updatedAt: 0,
151
+ appliedAt: null,
152
+ };
153
+ }
154
+ function firstSentence(s) {
155
+ const m = s.split(/(?<=[.!?])\s/)[0] ?? s;
156
+ return m.length > 100 ? m.slice(0, 100) + '…' : m;
157
+ }
158
+ /** The rule body written inside a CLAUDE.md marked block. */
159
+ function renderClaudeRule(title, content) {
160
+ return `## ${title}\n\n${content}\n\n_(Added by SpecShip reflection — edit or remove freely.)_`;
161
+ }
162
+ /** A self-contained memory note matching the user's memory-file convention. */
163
+ function renderMemoryNote(slug, title, content) {
164
+ return [
165
+ '---',
166
+ `name: ${slug}`,
167
+ `description: ${firstSentence(title)}`,
168
+ `${memoryNoteMarker(slug)}`,
169
+ 'metadata:',
170
+ ' type: feedback',
171
+ '---',
172
+ '',
173
+ content,
174
+ '',
175
+ ].join('\n');
176
+ }
177
+ /** A minimal slash-command skill file. */
178
+ function renderCommand(id, name, title, content) {
179
+ const { start, end } = learningMarkers(id);
180
+ return [
181
+ start,
182
+ `# ${title}`,
183
+ '',
184
+ `> \`/${name}\` — proposed by SpecShip reflection from a recurring pattern.`,
185
+ '',
186
+ content,
187
+ '',
188
+ end,
189
+ '',
190
+ ].join('\n');
191
+ }
192
+ //# sourceMappingURL=targets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"targets.js","sourceRoot":"","sources":["../../src/reflect/targets.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeH,0CA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ACF,OAAO;QACP,EAAE;QACF,GAAG;QACH,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Reflection engine types (REFLECT-DOC).
3
+ *
4
+ * A Proposal is a durable, human-gated self-improvement suggestion mined from
5
+ * the ingested `claude_*` transcript tables. It is never advisory text alone —
6
+ * it resolves to a concrete, previewable file change (REQ-REFLECT-002), keyed by
7
+ * a stable `contentHash` so re-mining the same pattern converges to one row
8
+ * (REQ-REFLECT-007). The engine PROPOSES; bytes reach disk only on an explicit
9
+ * per-proposal apply (REQ-REFLECT-005).
10
+ */
11
+ /** The kind of durable artifact a proposal produces. */
12
+ export type ProposalType = 'memory_rule' | 'skill' | 'hook';
13
+ /** Severity, reusing the tips engine's scale. `high` drives sweep notifications. */
14
+ export type ProposalSeverity = 'high' | 'warn' | 'info';
15
+ /** Persisted lifecycle state (REQ-REFLECT-007). */
16
+ export type ProposalState = 'open' | 'applied' | 'undone' | 'dismissed';
17
+ /** The concrete file the apply writes. */
18
+ export type TargetKind = 'claude_md' | 'memory_note' | 'command' | 'settings_hook';
19
+ /** What the proposal was derived from, so the user can judge it (REQ-REFLECT-001). */
20
+ export interface ProposalEvidence {
21
+ /** Contributing session ids. */
22
+ sessions: string[];
23
+ /** Contributing prompt ids. */
24
+ prompts: string[];
25
+ /** Human-readable one-line summary of the observed pattern. */
26
+ detail: string;
27
+ }
28
+ /**
29
+ * Artifact-type-specific payload — the exact intended content the preview
30
+ * renders and the apply writes (REQ-REFLECT-002.A4). Discriminated on `kind`,
31
+ * which matches the proposal's `targetKind`.
32
+ */
33
+ export type ProposalPayload = {
34
+ kind: 'claude_md';
35
+ markerId: string;
36
+ block: string;
37
+ } | {
38
+ kind: 'memory_note';
39
+ slug: string;
40
+ note: string;
41
+ indexLine: string;
42
+ } | {
43
+ kind: 'command';
44
+ name: string;
45
+ content: string;
46
+ } | {
47
+ kind: 'settings_hook';
48
+ event: string;
49
+ matcher: string;
50
+ entry: Record<string, unknown>;
51
+ };
52
+ /** A single reflection proposal. */
53
+ export interface Proposal {
54
+ /** Stable id over (type, targetKind, targetPath, payload) — excludes evidence/timestamps. */
55
+ contentHash: string;
56
+ type: ProposalType;
57
+ severity: ProposalSeverity;
58
+ title: string;
59
+ body: string;
60
+ targetKind: TargetKind;
61
+ /** Absolute path the apply will write. */
62
+ targetPath: string;
63
+ payload: ProposalPayload;
64
+ evidence: ProposalEvidence;
65
+ state: ProposalState;
66
+ createdAt: number;
67
+ updatedAt: number;
68
+ appliedAt: number | null;
69
+ }
70
+ /** Result of applying a proposal (REQ-REFLECT-004). */
71
+ export type ApplyOutcome = 'applied' | 'unchanged' | 'conflict';
72
+ /** Result of undoing a proposal (REQ-REFLECT-004.A3). */
73
+ export type UndoOutcome = 'undone' | 'noop';
74
+ /** A non-mutating preview of the change a proposal would make (REQ-REFLECT-003). */
75
+ export interface PreviewResult {
76
+ targetPath: string;
77
+ targetKind: TargetKind;
78
+ /** Whether the target file already exists on disk. */
79
+ exists: boolean;
80
+ /** Current file content (empty string when the file is absent). */
81
+ before: string;
82
+ /** File content after the change would be applied. */
83
+ after: string;
84
+ /** A line-based unified-style diff of before → after. */
85
+ diff: string;
86
+ /** Set when the apply would be refused — a non-marked file already occupies the path. */
87
+ conflict?: boolean;
88
+ }
89
+ /** Options the engine needs to resolve target paths. */
90
+ export interface ReflectContext {
91
+ /** Absolute project root (for project CLAUDE.md / commands / .claude/settings.json). */
92
+ projectRoot: string;
93
+ /** Home directory (for ~/.claude/memory notes). */
94
+ homeDir: string;
95
+ }
96
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/reflect/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,wDAAwD;AACxD,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,OAAO,GAAG,MAAM,CAAC;AAE5D,oFAAoF;AACpF,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IACvB,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,uDAAuD;AACvD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;AAEhE,yDAAyD;AACzD,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE5C,oFAAoF;AACpF,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;IACvB,sDAAsD;IACtD,MAAM,EAAE,OAAO,CAAC;IAChB,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,yFAAyF;IACzF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wDAAwD;AACxD,MAAM,WAAW,cAAc;IAC7B,wFAAwF;IACxF,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ /**
3
+ * Reflection engine types (REFLECT-DOC).
4
+ *
5
+ * A Proposal is a durable, human-gated self-improvement suggestion mined from
6
+ * the ingested `claude_*` transcript tables. It is never advisory text alone —
7
+ * it resolves to a concrete, previewable file change (REQ-REFLECT-002), keyed by
8
+ * a stable `contentHash` so re-mining the same pattern converges to one row
9
+ * (REQ-REFLECT-007). The engine PROPOSES; bytes reach disk only on an explicit
10
+ * per-proposal apply (REQ-REFLECT-005).
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/reflect/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG"}