@codeledger/cli 0.9.1 → 0.9.2
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/dist/commands/activate.d.ts.map +1 -1
- package/dist/commands/activate.js +162 -17
- package/dist/commands/activate.js.map +1 -1
- package/dist/commands/ci.js +9 -119
- package/dist/commands/ci.js.map +1 -1
- package/dist/commands/coordination.js +1 -1
- package/dist/commands/coordination.js.map +1 -1
- package/dist/commands/dashboard.d.ts +9 -3
- package/dist/commands/dashboard.d.ts.map +1 -1
- package/dist/commands/dashboard.js +374 -4
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/features.d.ts.map +1 -1
- package/dist/commands/features.js +3 -0
- package/dist/commands/features.js.map +1 -1
- package/dist/commands/harvest.d.ts.map +1 -1
- package/dist/commands/harvest.js +28 -0
- package/dist/commands/harvest.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +22 -7
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/insight.js +2 -1
- package/dist/commands/insight.js.map +1 -1
- package/dist/commands/mcp.d.ts +14 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +70 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/memory.js +53 -0
- package/dist/commands/memory.js.map +1 -1
- package/dist/commands/outcome.d.ts.map +1 -1
- package/dist/commands/outcome.js +3 -0
- package/dist/commands/outcome.js.map +1 -1
- package/dist/commands/scan.d.ts.map +1 -1
- package/dist/commands/scan.js +9 -2
- package/dist/commands/scan.js.map +1 -1
- package/dist/commands/serve.js.map +1 -1
- package/dist/commands/session-summary.d.ts.map +1 -1
- package/dist/commands/session-summary.js +198 -1
- package/dist/commands/session-summary.js.map +1 -1
- package/dist/commands/setup-ci.js +8 -4
- package/dist/commands/setup-ci.js.map +1 -1
- package/dist/commands/sync.d.ts +9 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +157 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/verify.d.ts +24 -1
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +73 -0
- package/dist/commands/verify.js.map +1 -1
- package/dist/coordination/index.js +26 -9
- package/dist/coordination/index.js.map +1 -1
- package/dist/ecl/git-sync.d.ts +53 -0
- package/dist/ecl/git-sync.d.ts.map +1 -0
- package/dist/ecl/git-sync.js +182 -0
- package/dist/ecl/git-sync.js.map +1 -0
- package/dist/ecl/lifecycle.d.ts +107 -0
- package/dist/ecl/lifecycle.d.ts.map +1 -0
- package/dist/ecl/lifecycle.js +264 -0
- package/dist/ecl/lifecycle.js.map +1 -0
- package/dist/ecl/persistence.d.ts +108 -0
- package/dist/ecl/persistence.d.ts.map +1 -0
- package/dist/ecl/persistence.js +362 -0
- package/dist/ecl/persistence.js.map +1 -0
- package/dist/ecl/sync.d.ts +43 -0
- package/dist/ecl/sync.d.ts.map +1 -0
- package/dist/ecl/sync.js +155 -0
- package/dist/ecl/sync.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.d.ts +20 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +271 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/skill-template.d.ts +10 -0
- package/dist/mcp/skill-template.d.ts.map +1 -0
- package/dist/mcp/skill-template.js +75 -0
- package/dist/mcp/skill-template.js.map +1 -0
- package/dist/memory/golden-patterns.d.ts +68 -0
- package/dist/memory/golden-patterns.d.ts.map +1 -0
- package/dist/memory/golden-patterns.js +260 -0
- package/dist/memory/golden-patterns.js.map +1 -0
- package/dist/memory/storage.d.ts +4 -1
- package/dist/memory/storage.d.ts.map +1 -1
- package/dist/memory/storage.js +22 -0
- package/dist/memory/storage.js.map +1 -1
- package/dist/prompt-coach/admission.d.ts +31 -0
- package/dist/prompt-coach/admission.d.ts.map +1 -0
- package/dist/prompt-coach/admission.js +103 -0
- package/dist/prompt-coach/admission.js.map +1 -0
- package/dist/prompt-coach/feedback.d.ts +49 -0
- package/dist/prompt-coach/feedback.d.ts.map +1 -0
- package/dist/prompt-coach/feedback.js +177 -0
- package/dist/prompt-coach/feedback.js.map +1 -0
- package/dist/prompt-coach/format.d.ts +56 -0
- package/dist/prompt-coach/format.d.ts.map +1 -0
- package/dist/prompt-coach/format.js +162 -0
- package/dist/prompt-coach/format.js.map +1 -0
- package/dist/prompt-coach/index.d.ts +13 -0
- package/dist/prompt-coach/index.d.ts.map +1 -0
- package/dist/prompt-coach/index.js +13 -0
- package/dist/prompt-coach/index.js.map +1 -0
- package/dist/prompt-coach/interactive.d.ts +28 -0
- package/dist/prompt-coach/interactive.d.ts.map +1 -0
- package/dist/prompt-coach/interactive.js +118 -0
- package/dist/prompt-coach/interactive.js.map +1 -0
- package/dist/prompt-coach/policy.d.ts +48 -0
- package/dist/prompt-coach/policy.d.ts.map +1 -0
- package/dist/prompt-coach/policy.js +469 -0
- package/dist/prompt-coach/policy.js.map +1 -0
- package/dist/prompt-coach/summary.d.ts +56 -0
- package/dist/prompt-coach/summary.d.ts.map +1 -0
- package/dist/prompt-coach/summary.js +304 -0
- package/dist/prompt-coach/summary.js.map +1 -0
- package/dist/protected-runtime/core.js +2 -2
- package/dist/protected-runtime/core.js.map +1 -1
- package/dist/protected-runtime/module-loader.d.ts +6 -6
- package/dist/protected-runtime/module-loader.d.ts.map +1 -1
- package/dist/protected-runtime/module-loader.js +40 -54
- package/dist/protected-runtime/module-loader.js.map +1 -1
- package/dist/protected-shell.js +24 -33
- package/dist/protected-shell.js.map +1 -1
- package/dist/utils/two-loop.d.ts +36 -0
- package/dist/utils/two-loop.d.ts.map +1 -0
- package/dist/utils/two-loop.js +75 -0
- package/dist/utils/two-loop.js.map +1 -0
- package/dist/utils/upgrade-nudge.d.ts +18 -0
- package/dist/utils/upgrade-nudge.d.ts.map +1 -0
- package/dist/utils/upgrade-nudge.js +57 -0
- package/dist/utils/upgrade-nudge.js.map +1 -0
- package/package.json +18 -17
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Skill Manifest Template
|
|
3
|
+
*
|
|
4
|
+
* Generated during `codeledger init` and placed at `.codeledger/skill.md`.
|
|
5
|
+
* Teaches Claude (and other agents) to use the CodeLedger MCP server.
|
|
6
|
+
*
|
|
7
|
+
* IP Classification: public (intentionally readable by agents)
|
|
8
|
+
*/
|
|
9
|
+
export function generateSkillManifest(repoName) {
|
|
10
|
+
return `# CodeLedger — AI Engineering Skill
|
|
11
|
+
|
|
12
|
+
You have access to the **Enterprise Context Ledger (ECL)** for this repository.
|
|
13
|
+
Your goal is **First-Pass Sufficiency** — get the code right on the first try.
|
|
14
|
+
|
|
15
|
+
## Your Capabilities
|
|
16
|
+
|
|
17
|
+
You can use these MCP tools:
|
|
18
|
+
|
|
19
|
+
### \`query_ledger\`
|
|
20
|
+
**Before coding**, search for verified engineering patterns:
|
|
21
|
+
\`\`\`
|
|
22
|
+
Use tool: query_ledger
|
|
23
|
+
Input: { "intent": "description of what you're about to do" }
|
|
24
|
+
\`\`\`
|
|
25
|
+
If patterns are found, follow their structure — they represent verified team standards.
|
|
26
|
+
|
|
27
|
+
### \`get_active_context\`
|
|
28
|
+
Retrieve the current task-specific context bundle:
|
|
29
|
+
\`\`\`
|
|
30
|
+
Use tool: get_active_context
|
|
31
|
+
\`\`\`
|
|
32
|
+
Stay within the files listed in the active context. Going outside the bundle increases risk.
|
|
33
|
+
|
|
34
|
+
### \`record_interaction\`
|
|
35
|
+
**After coding**, report your outcome:
|
|
36
|
+
\`\`\`
|
|
37
|
+
Use tool: record_interaction
|
|
38
|
+
Input: {
|
|
39
|
+
"intent": "what you did",
|
|
40
|
+
"status": "success" | "failure" | "partial",
|
|
41
|
+
"filesModified": ["path/to/file.ts"],
|
|
42
|
+
"thoughtTrace": "brief reasoning (no secrets)"
|
|
43
|
+
}
|
|
44
|
+
\`\`\`
|
|
45
|
+
|
|
46
|
+
## The Two-Loop Model
|
|
47
|
+
|
|
48
|
+
**⚡ Now (Loop A):** You are helping with the current task.
|
|
49
|
+
- Query the ledger for relevant patterns before writing code
|
|
50
|
+
- Stay within the active context bundle
|
|
51
|
+
- Report your outcome when done
|
|
52
|
+
|
|
53
|
+
**💎 Next (Loop B):** Your work today becomes tomorrow's intelligence.
|
|
54
|
+
- Successful outcomes strengthen existing patterns
|
|
55
|
+
- New solutions may become reusable patterns for the team
|
|
56
|
+
- Your evidence compounds into institutional memory
|
|
57
|
+
|
|
58
|
+
## Rules
|
|
59
|
+
|
|
60
|
+
1. **Always check for patterns before implementing** — don't reinvent what's been verified
|
|
61
|
+
2. **Stay within the active context** — files outside the bundle are higher risk
|
|
62
|
+
3. **Always report your outcome** — even failures teach the system
|
|
63
|
+
4. **Never include secrets or PII** in thoughtTrace
|
|
64
|
+
5. **Follow verified patterns strictly** — they represent team-tested solutions
|
|
65
|
+
|
|
66
|
+
## About This Repo
|
|
67
|
+
|
|
68
|
+
Repository: ${repoName}
|
|
69
|
+
Ledger: .codeledger/ (local-first, privacy-preserving)
|
|
70
|
+
MCP Server: codeledger mcp start (stdio transport)
|
|
71
|
+
|
|
72
|
+
Your success today becomes the team's wisdom tomorrow.
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=skill-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-template.js","sourceRoot":"","sources":["../../src/mcp/skill-template.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,UAAU,qBAAqB,CAAC,QAAgB;IACpD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA0DK,QAAQ;;;;;CAKrB,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Golden Patterns — Repo-Wide Institutional Memory
|
|
3
|
+
*
|
|
4
|
+
* Solves the cold-start problem for new team members. Instead of requiring
|
|
5
|
+
* 2+ personal task history entries for the history-based downgrade, golden
|
|
6
|
+
* patterns provide high-fidelity task templates from the team's best
|
|
7
|
+
* executions.
|
|
8
|
+
*
|
|
9
|
+
* Sources:
|
|
10
|
+
* - ECL-Lite success entries with high confidence
|
|
11
|
+
* - Lessons ledger entries with category 'golden_path'
|
|
12
|
+
* - Manual entries via codeledger memory golden --add
|
|
13
|
+
*
|
|
14
|
+
* Matching uses the same Jaccard similarity threshold as personal history
|
|
15
|
+
* (> 0.5, slightly lower than personal's 0.6 since these are curated).
|
|
16
|
+
*/
|
|
17
|
+
import type { GoldenPattern, GoldenPatternsLedger, EclLiteEntry, RepoLesson } from '@codeledger/types';
|
|
18
|
+
/** Jaccard similarity threshold for golden pattern matching (slightly lower than personal) */
|
|
19
|
+
export declare const GOLDEN_PATTERN_SIMILARITY_THRESHOLD = 0.5;
|
|
20
|
+
/**
|
|
21
|
+
* Normalize a task string into keywords for Jaccard comparison.
|
|
22
|
+
* Same approach as personal history but exported for testing.
|
|
23
|
+
*/
|
|
24
|
+
export declare function normalizeTaskKeywords(task: string): Set<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Compute Jaccard similarity between two keyword sets.
|
|
27
|
+
*/
|
|
28
|
+
export declare function jaccardSimilarity(a: Set<string>, b: Set<string>): number;
|
|
29
|
+
/**
|
|
30
|
+
* Check if a task matches any golden pattern.
|
|
31
|
+
* Returns the best matching pattern, or null if no match.
|
|
32
|
+
*/
|
|
33
|
+
export declare function matchGoldenPattern(task: string, ledger: GoldenPatternsLedger): GoldenPattern | null;
|
|
34
|
+
/**
|
|
35
|
+
* Seed golden patterns from ECL-Lite success entries.
|
|
36
|
+
* Only includes entries with high confidence and 'success' outcome.
|
|
37
|
+
*/
|
|
38
|
+
export declare function seedFromEclEntries(entries: EclLiteEntry[]): GoldenPattern[];
|
|
39
|
+
/**
|
|
40
|
+
* Seed golden patterns from lessons with category 'golden_path'.
|
|
41
|
+
*/
|
|
42
|
+
export declare function seedFromLessons(lessons: RepoLesson[]): GoldenPattern[];
|
|
43
|
+
/**
|
|
44
|
+
* Merge new patterns into an existing ledger, deduplicating by ID.
|
|
45
|
+
*/
|
|
46
|
+
export declare function mergePatterns(existing: GoldenPatternsLedger, newPatterns: GoldenPattern[]): GoldenPatternsLedger;
|
|
47
|
+
/**
|
|
48
|
+
* Extract "Institutional North Star" patterns from ECL-Lite.
|
|
49
|
+
*
|
|
50
|
+
* Stricter criteria than general seeding:
|
|
51
|
+
* - outcome === 'success' (first-pass success)
|
|
52
|
+
* - confidenceScore > 0.9 (high intent fidelity)
|
|
53
|
+
* - No failure vector (clean execution, no rework)
|
|
54
|
+
* - Multiple entries for the same intent (consistency signal)
|
|
55
|
+
*
|
|
56
|
+
* These become the patterns that shape onboarding. When a new developer
|
|
57
|
+
* writes a vague prompt, the coach says: "Looks like you're doing X;
|
|
58
|
+
* typically we follow [pattern]. Suggesting refinement..."
|
|
59
|
+
*/
|
|
60
|
+
export declare function extractNorthStarPatterns(entries: EclLiteEntry[]): GoldenPattern[];
|
|
61
|
+
/**
|
|
62
|
+
* Full golden pattern seeding pipeline.
|
|
63
|
+
*
|
|
64
|
+
* Priority: North Stars > general ECL seeds > lessons.
|
|
65
|
+
* Merges into existing ledger without losing manual entries.
|
|
66
|
+
*/
|
|
67
|
+
export declare function seedGoldenPatterns(existing: GoldenPatternsLedger, eclEntries: EclLiteEntry[], lessons: RepoLesson[]): GoldenPatternsLedger;
|
|
68
|
+
//# sourceMappingURL=golden-patterns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"golden-patterns.d.ts","sourceRoot":"","sources":["../../src/memory/golden-patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,UAAU,EACX,MAAM,mBAAmB,CAAC;AAY3B,8FAA8F;AAC9F,eAAO,MAAM,mCAAmC,MAAM,CAAC;AAOvD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAQ/D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAQxE;AAID;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,oBAAoB,GAC3B,aAAa,GAAG,IAAI,CAoBtB;AAID;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,aAAa,EAAE,CA+C3E;AAID;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,aAAa,EAAE,CAkBtE;AAID;;GAEG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,oBAAoB,EAC9B,WAAW,EAAE,aAAa,EAAE,GAC3B,oBAAoB,CAQtB;AAID;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,aAAa,EAAE,CAmEjF;AAID;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,oBAAoB,EAC9B,UAAU,EAAE,YAAY,EAAE,EAC1B,OAAO,EAAE,UAAU,EAAE,GACpB,oBAAoB,CAgBtB"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Golden Patterns — Repo-Wide Institutional Memory
|
|
3
|
+
*
|
|
4
|
+
* Solves the cold-start problem for new team members. Instead of requiring
|
|
5
|
+
* 2+ personal task history entries for the history-based downgrade, golden
|
|
6
|
+
* patterns provide high-fidelity task templates from the team's best
|
|
7
|
+
* executions.
|
|
8
|
+
*
|
|
9
|
+
* Sources:
|
|
10
|
+
* - ECL-Lite success entries with high confidence
|
|
11
|
+
* - Lessons ledger entries with category 'golden_path'
|
|
12
|
+
* - Manual entries via codeledger memory golden --add
|
|
13
|
+
*
|
|
14
|
+
* Matching uses the same Jaccard similarity threshold as personal history
|
|
15
|
+
* (> 0.5, slightly lower than personal's 0.6 since these are curated).
|
|
16
|
+
*/
|
|
17
|
+
import { createHash } from 'node:crypto';
|
|
18
|
+
// ─── Constants ──────────────────────────────────────────────────────────────
|
|
19
|
+
/** Minimum confidence score for an ECL entry to become a golden pattern (general) */
|
|
20
|
+
const MIN_ECL_CONFIDENCE = 0.7;
|
|
21
|
+
/** North Star criteria — the "Institutional North Stars" heuristic */
|
|
22
|
+
const NORTH_STAR_CONFIDENCE = 0.9;
|
|
23
|
+
/** North Star: no failure vector means clean execution */
|
|
24
|
+
const NORTH_STAR_NO_FAILURE = true;
|
|
25
|
+
/** Jaccard similarity threshold for golden pattern matching (slightly lower than personal) */
|
|
26
|
+
export const GOLDEN_PATTERN_SIMILARITY_THRESHOLD = 0.5;
|
|
27
|
+
/** Maximum golden patterns to store */
|
|
28
|
+
const MAX_GOLDEN_PATTERNS = 50;
|
|
29
|
+
// ─── Normalization ──────────────────────────────────────────────────────────
|
|
30
|
+
/**
|
|
31
|
+
* Normalize a task string into keywords for Jaccard comparison.
|
|
32
|
+
* Same approach as personal history but exported for testing.
|
|
33
|
+
*/
|
|
34
|
+
export function normalizeTaskKeywords(task) {
|
|
35
|
+
return new Set(task.toLowerCase()
|
|
36
|
+
.replace(/[^a-z0-9 ]/g, ' ')
|
|
37
|
+
.trim()
|
|
38
|
+
.split(/\s+/)
|
|
39
|
+
.filter((w) => w.length > 3));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Compute Jaccard similarity between two keyword sets.
|
|
43
|
+
*/
|
|
44
|
+
export function jaccardSimilarity(a, b) {
|
|
45
|
+
if (a.size === 0 && b.size === 0)
|
|
46
|
+
return 0;
|
|
47
|
+
let intersection = 0;
|
|
48
|
+
for (const w of a) {
|
|
49
|
+
if (b.has(w))
|
|
50
|
+
intersection++;
|
|
51
|
+
}
|
|
52
|
+
const union = new Set([...a, ...b]).size;
|
|
53
|
+
return union === 0 ? 0 : intersection / union;
|
|
54
|
+
}
|
|
55
|
+
// ─── Matching ───────────────────────────────────────────────────────────────
|
|
56
|
+
/**
|
|
57
|
+
* Check if a task matches any golden pattern.
|
|
58
|
+
* Returns the best matching pattern, or null if no match.
|
|
59
|
+
*/
|
|
60
|
+
export function matchGoldenPattern(task, ledger) {
|
|
61
|
+
if (ledger.patterns.length === 0)
|
|
62
|
+
return null;
|
|
63
|
+
const taskKeywords = normalizeTaskKeywords(task);
|
|
64
|
+
if (taskKeywords.size === 0)
|
|
65
|
+
return null;
|
|
66
|
+
let bestMatch = null;
|
|
67
|
+
let bestSimilarity = 0;
|
|
68
|
+
for (const pattern of ledger.patterns) {
|
|
69
|
+
const patternKeywords = new Set(pattern.keywords);
|
|
70
|
+
const similarity = jaccardSimilarity(taskKeywords, patternKeywords);
|
|
71
|
+
if (similarity > GOLDEN_PATTERN_SIMILARITY_THRESHOLD && similarity > bestSimilarity) {
|
|
72
|
+
bestMatch = pattern;
|
|
73
|
+
bestSimilarity = similarity;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return bestMatch;
|
|
77
|
+
}
|
|
78
|
+
// ─── Seeding from ECL-Lite ──────────────────────────────────────────────────
|
|
79
|
+
/**
|
|
80
|
+
* Seed golden patterns from ECL-Lite success entries.
|
|
81
|
+
* Only includes entries with high confidence and 'success' outcome.
|
|
82
|
+
*/
|
|
83
|
+
export function seedFromEclEntries(entries) {
|
|
84
|
+
const patterns = [];
|
|
85
|
+
const seen = new Set();
|
|
86
|
+
for (const entry of entries) {
|
|
87
|
+
if (entry.outcome !== 'success')
|
|
88
|
+
continue;
|
|
89
|
+
if (entry.confidenceScore < MIN_ECL_CONFIDENCE)
|
|
90
|
+
continue;
|
|
91
|
+
// Use intent signature as dedup key
|
|
92
|
+
if (seen.has(entry.intentSignature))
|
|
93
|
+
continue;
|
|
94
|
+
seen.add(entry.intentSignature);
|
|
95
|
+
// Build keywords from intent category + files
|
|
96
|
+
const keywords = [];
|
|
97
|
+
if (entry.intentCategory) {
|
|
98
|
+
keywords.push(...entry.intentCategory.toLowerCase().split(/[_\s]+/).filter((w) => w.length > 3));
|
|
99
|
+
}
|
|
100
|
+
// Extract domain hints from file paths
|
|
101
|
+
for (const file of entry.files.slice(0, 5)) {
|
|
102
|
+
const parts = file.split('/');
|
|
103
|
+
for (const part of parts) {
|
|
104
|
+
const clean = part.replace(/\.[^.]+$/, '').toLowerCase();
|
|
105
|
+
if (clean.length > 3 && !keywords.includes(clean)) {
|
|
106
|
+
keywords.push(clean);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (keywords.length < 2)
|
|
111
|
+
continue;
|
|
112
|
+
const id = createHash('sha256')
|
|
113
|
+
.update(entry.intentSignature)
|
|
114
|
+
.digest('hex')
|
|
115
|
+
.slice(0, 12);
|
|
116
|
+
patterns.push({
|
|
117
|
+
id: `ecl-${id}`,
|
|
118
|
+
keywords: [...new Set(keywords)].sort(),
|
|
119
|
+
source: 'ecl_success',
|
|
120
|
+
label: entry.intentCategory ?? 'successful execution',
|
|
121
|
+
confidence: entry.confidenceScore,
|
|
122
|
+
recordedAt: new Date(entry.timestamp).toISOString(),
|
|
123
|
+
typicalFiles: entry.files.slice(0, 5),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return patterns.slice(0, MAX_GOLDEN_PATTERNS);
|
|
127
|
+
}
|
|
128
|
+
// ─── Seeding from Lessons Ledger ────────────────────────────────────────────
|
|
129
|
+
/**
|
|
130
|
+
* Seed golden patterns from lessons with category 'golden_path'.
|
|
131
|
+
*/
|
|
132
|
+
export function seedFromLessons(lessons) {
|
|
133
|
+
return lessons
|
|
134
|
+
.filter((l) => l.category === 'golden_path' && l.status !== 'deprecated')
|
|
135
|
+
.map((l) => {
|
|
136
|
+
const keywords = normalizeTaskKeywords(`${l.title} ${l.summary} ${(l.concepts ?? []).join(' ')}`);
|
|
137
|
+
return {
|
|
138
|
+
id: `lesson-${l.id}`,
|
|
139
|
+
keywords: [...keywords].sort(),
|
|
140
|
+
source: 'lesson',
|
|
141
|
+
label: l.title,
|
|
142
|
+
confidence: 0.8,
|
|
143
|
+
recordedAt: new Date().toISOString(),
|
|
144
|
+
typicalFiles: l.fileHints,
|
|
145
|
+
};
|
|
146
|
+
})
|
|
147
|
+
.filter((p) => p.keywords.length >= 2);
|
|
148
|
+
}
|
|
149
|
+
// ─── Merge ──────────────────────────────────────────────────────────────────
|
|
150
|
+
/**
|
|
151
|
+
* Merge new patterns into an existing ledger, deduplicating by ID.
|
|
152
|
+
*/
|
|
153
|
+
export function mergePatterns(existing, newPatterns) {
|
|
154
|
+
const byId = new Map(existing.patterns.map((p) => [p.id, p]));
|
|
155
|
+
for (const p of newPatterns) {
|
|
156
|
+
byId.set(p.id, p);
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
patterns: [...byId.values()].slice(0, MAX_GOLDEN_PATTERNS),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
// ─── North Star Extraction ──────────────────────────────────────────────────
|
|
163
|
+
/**
|
|
164
|
+
* Extract "Institutional North Star" patterns from ECL-Lite.
|
|
165
|
+
*
|
|
166
|
+
* Stricter criteria than general seeding:
|
|
167
|
+
* - outcome === 'success' (first-pass success)
|
|
168
|
+
* - confidenceScore > 0.9 (high intent fidelity)
|
|
169
|
+
* - No failure vector (clean execution, no rework)
|
|
170
|
+
* - Multiple entries for the same intent (consistency signal)
|
|
171
|
+
*
|
|
172
|
+
* These become the patterns that shape onboarding. When a new developer
|
|
173
|
+
* writes a vague prompt, the coach says: "Looks like you're doing X;
|
|
174
|
+
* typically we follow [pattern]. Suggesting refinement..."
|
|
175
|
+
*/
|
|
176
|
+
export function extractNorthStarPatterns(entries) {
|
|
177
|
+
// Group entries by intent signature
|
|
178
|
+
const bySignature = new Map();
|
|
179
|
+
for (const entry of entries) {
|
|
180
|
+
const existing = bySignature.get(entry.intentSignature) ?? [];
|
|
181
|
+
existing.push(entry);
|
|
182
|
+
bySignature.set(entry.intentSignature, existing);
|
|
183
|
+
}
|
|
184
|
+
const patterns = [];
|
|
185
|
+
for (const [sig, group] of bySignature) {
|
|
186
|
+
// Require at least 2 executions for consistency signal
|
|
187
|
+
if (group.length < 2)
|
|
188
|
+
continue;
|
|
189
|
+
// All executions must be successful
|
|
190
|
+
const allSuccess = group.every((e) => e.outcome === 'success');
|
|
191
|
+
if (!allSuccess)
|
|
192
|
+
continue;
|
|
193
|
+
// Average confidence must exceed North Star threshold
|
|
194
|
+
const avgConfidence = group.reduce((s, e) => s + e.confidenceScore, 0) / group.length;
|
|
195
|
+
if (avgConfidence < NORTH_STAR_CONFIDENCE)
|
|
196
|
+
continue;
|
|
197
|
+
// No failure vectors in any execution (clean history)
|
|
198
|
+
if (NORTH_STAR_NO_FAILURE && group.some((e) => e.failureVector))
|
|
199
|
+
continue;
|
|
200
|
+
// Extract rich keywords from all executions
|
|
201
|
+
const allKeywords = new Set();
|
|
202
|
+
const allFiles = new Set();
|
|
203
|
+
for (const entry of group) {
|
|
204
|
+
if (entry.intentCategory) {
|
|
205
|
+
for (const w of entry.intentCategory.toLowerCase().split(/[_\s]+/)) {
|
|
206
|
+
if (w.length > 3)
|
|
207
|
+
allKeywords.add(w);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
for (const file of entry.files) {
|
|
211
|
+
allFiles.add(file);
|
|
212
|
+
for (const part of file.split('/')) {
|
|
213
|
+
const clean = part.replace(/\.[^.]+$/, '').toLowerCase();
|
|
214
|
+
if (clean.length > 3)
|
|
215
|
+
allKeywords.add(clean);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (allKeywords.size < 2)
|
|
220
|
+
continue;
|
|
221
|
+
const id = createHash('sha256').update(sig).digest('hex').slice(0, 12);
|
|
222
|
+
const latest = group.sort((a, b) => b.timestamp - a.timestamp)[0];
|
|
223
|
+
patterns.push({
|
|
224
|
+
id: `northstar-${id}`,
|
|
225
|
+
keywords: [...allKeywords].sort(),
|
|
226
|
+
source: 'ecl_success',
|
|
227
|
+
label: latest.intentCategory
|
|
228
|
+
? `${latest.intentCategory} (${group.length}x verified)`
|
|
229
|
+
: `verified pattern (${group.length}x)`,
|
|
230
|
+
confidence: avgConfidence,
|
|
231
|
+
recordedAt: new Date(latest.timestamp).toISOString(),
|
|
232
|
+
typicalFiles: [...allFiles].slice(0, 8),
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
// Sort by confidence (highest first), then cap
|
|
236
|
+
return patterns
|
|
237
|
+
.sort((a, b) => b.confidence - a.confidence)
|
|
238
|
+
.slice(0, MAX_GOLDEN_PATTERNS);
|
|
239
|
+
}
|
|
240
|
+
// ─── Orchestrator ───────────────────────────────────────────────────────────
|
|
241
|
+
/**
|
|
242
|
+
* Full golden pattern seeding pipeline.
|
|
243
|
+
*
|
|
244
|
+
* Priority: North Stars > general ECL seeds > lessons.
|
|
245
|
+
* Merges into existing ledger without losing manual entries.
|
|
246
|
+
*/
|
|
247
|
+
export function seedGoldenPatterns(existing, eclEntries, lessons) {
|
|
248
|
+
// 1. Extract North Stars (highest quality)
|
|
249
|
+
const northStars = extractNorthStarPatterns(eclEntries);
|
|
250
|
+
// 2. General ECL seeds (fill remaining slots)
|
|
251
|
+
const generalSeeds = seedFromEclEntries(eclEntries);
|
|
252
|
+
// 3. Lesson-derived patterns
|
|
253
|
+
const lessonPatterns = seedFromLessons(lessons);
|
|
254
|
+
// Merge: North Stars take priority, then general, then lessons
|
|
255
|
+
let result = mergePatterns(existing, northStars);
|
|
256
|
+
result = mergePatterns(result, generalSeeds);
|
|
257
|
+
result = mergePatterns(result, lessonPatterns);
|
|
258
|
+
return result;
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=golden-patterns.js.map
|
|
@@ -0,0 +1 @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C;AACnC,CAAC;AAED,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAA8B,EAC9B,UAA0B,EAC1B,OAAqB;IAErB,2CAA2C;IAC3C,MAAM,UAAU,GAAG,wBAAwB,CAAC,UAAU,CAAC,CAAC;IAExD,8CAA8C;IAC9C,MAAM,YAAY,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAEpD,6BAA6B;IAC7B,MAAM,cAAc,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAEhD,+DAA+D;IAC/D,IAAI,MAAM,GAAG,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACjD,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC7C,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAE/C,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/memory/storage.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CodeLedgerMemory, RecentTruthLedger, DeltaValidationLedger, ProductOntologyLedger, StructuralTrustLedger, EvidenceGateLedger, LessonsLedger } from '@codeledger/types';
|
|
1
|
+
import type { CodeLedgerMemory, RecentTruthLedger, DeltaValidationLedger, ProductOntologyLedger, StructuralTrustLedger, EvidenceGateLedger, LessonsLedger, GoldenPatternsLedger } from '@codeledger/types';
|
|
2
2
|
export declare function memoryDir(cwd: string): string;
|
|
3
3
|
export declare function recentTruthPath(cwd: string): string;
|
|
4
4
|
export declare function validationLedgerPath(cwd: string): string;
|
|
@@ -6,6 +6,7 @@ export declare function ontologyPath(cwd: string): string;
|
|
|
6
6
|
export declare function structuralTrustPath(cwd: string): string;
|
|
7
7
|
export declare function evidenceGatesPath(cwd: string): string;
|
|
8
8
|
export declare function lessonsLedgerPath(cwd: string): string;
|
|
9
|
+
export declare function goldenPatternsPath(cwd: string): string;
|
|
9
10
|
export declare function ensureMemoryDir(cwd: string): void;
|
|
10
11
|
export declare function loadRecentTruth(cwd: string): RecentTruthLedger;
|
|
11
12
|
export declare function loadValidationLedger(cwd: string): DeltaValidationLedger;
|
|
@@ -13,12 +14,14 @@ export declare function loadOntology(cwd: string): ProductOntologyLedger;
|
|
|
13
14
|
export declare function loadStructuralTrust(cwd: string): StructuralTrustLedger;
|
|
14
15
|
export declare function loadEvidenceGates(cwd: string): EvidenceGateLedger;
|
|
15
16
|
export declare function loadLessonsLedger(cwd: string): LessonsLedger;
|
|
17
|
+
export declare function loadGoldenPatterns(cwd: string): GoldenPatternsLedger;
|
|
16
18
|
export declare function saveRecentTruth(cwd: string, ledger: RecentTruthLedger): void;
|
|
17
19
|
export declare function saveValidationLedger(cwd: string, ledger: DeltaValidationLedger): void;
|
|
18
20
|
export declare function saveOntology(cwd: string, ledger: ProductOntologyLedger): void;
|
|
19
21
|
export declare function saveStructuralTrust(cwd: string, ledger: StructuralTrustLedger): void;
|
|
20
22
|
export declare function saveEvidenceGates(cwd: string, ledger: EvidenceGateLedger): void;
|
|
21
23
|
export declare function saveLessonsLedger(cwd: string, ledger: LessonsLedger): void;
|
|
24
|
+
export declare function saveGoldenPatterns(cwd: string, ledger: GoldenPatternsLedger): void;
|
|
22
25
|
export declare function loadMemory(cwd: string): CodeLedgerMemory;
|
|
23
26
|
export declare function saveMemory(cwd: string, memory: CodeLedgerMemory): void;
|
|
24
27
|
export declare function memoryExists(cwd: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/memory/storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/memory/storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB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AI,CAG5E;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAGrF;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAG7E;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAGpF;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAG/E;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAG1E;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAGlF;AAID,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAaxD;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAatE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEjD"}
|
package/dist/memory/storage.js
CHANGED
|
@@ -22,6 +22,9 @@ export function evidenceGatesPath(cwd) {
|
|
|
22
22
|
export function lessonsLedgerPath(cwd) {
|
|
23
23
|
return join(memoryDir(cwd), 'lessons.json');
|
|
24
24
|
}
|
|
25
|
+
export function goldenPatternsPath(cwd) {
|
|
26
|
+
return join(memoryDir(cwd), 'golden-patterns.json');
|
|
27
|
+
}
|
|
25
28
|
// ─── Defaults ─────────────────────────────────────────────────────────────────
|
|
26
29
|
function defaultRecentTruth() {
|
|
27
30
|
return { acceptedChanges: [], architectureDecisions: [], recentFeatures: [] };
|
|
@@ -41,6 +44,9 @@ function defaultEvidenceGates() {
|
|
|
41
44
|
function defaultLessonsLedger() {
|
|
42
45
|
return { lessons: [], events: [] };
|
|
43
46
|
}
|
|
47
|
+
function defaultGoldenPatterns() {
|
|
48
|
+
return { patterns: [] };
|
|
49
|
+
}
|
|
44
50
|
// ─── Ensure dir ──────────────────────────────────────────────────────────────
|
|
45
51
|
export function ensureMemoryDir(cwd) {
|
|
46
52
|
const dir = memoryDir(cwd);
|
|
@@ -87,6 +93,11 @@ function guardLessonsLedger(v) {
|
|
|
87
93
|
return false;
|
|
88
94
|
return Array.isArray(v['lessons']) && Array.isArray(v['events']);
|
|
89
95
|
}
|
|
96
|
+
function guardGoldenPatterns(v) {
|
|
97
|
+
if (!isObject(v))
|
|
98
|
+
return false;
|
|
99
|
+
return Array.isArray(v['patterns']);
|
|
100
|
+
}
|
|
90
101
|
// ─── Loaders ─────────────────────────────────────────────────────────────────
|
|
91
102
|
function loadJson(path, fallback, guard, label) {
|
|
92
103
|
if (!existsSync(path))
|
|
@@ -123,6 +134,9 @@ export function loadEvidenceGates(cwd) {
|
|
|
123
134
|
export function loadLessonsLedger(cwd) {
|
|
124
135
|
return loadJson(lessonsLedgerPath(cwd), defaultLessonsLedger, guardLessonsLedger, 'lessons-ledger');
|
|
125
136
|
}
|
|
137
|
+
export function loadGoldenPatterns(cwd) {
|
|
138
|
+
return loadJson(goldenPatternsPath(cwd), defaultGoldenPatterns, guardGoldenPatterns, 'golden-patterns');
|
|
139
|
+
}
|
|
126
140
|
// ─── Savers ──────────────────────────────────────────────────────────────────
|
|
127
141
|
function saveJson(path, data) {
|
|
128
142
|
writeFileSync(path, JSON.stringify(data, null, 2), 'utf-8');
|
|
@@ -151,6 +165,10 @@ export function saveLessonsLedger(cwd, ledger) {
|
|
|
151
165
|
ensureMemoryDir(cwd);
|
|
152
166
|
saveJson(lessonsLedgerPath(cwd), ledger);
|
|
153
167
|
}
|
|
168
|
+
export function saveGoldenPatterns(cwd, ledger) {
|
|
169
|
+
ensureMemoryDir(cwd);
|
|
170
|
+
saveJson(goldenPatternsPath(cwd), ledger);
|
|
171
|
+
}
|
|
154
172
|
// ─── Full memory load/save ────────────────────────────────────────────────────
|
|
155
173
|
export function loadMemory(cwd) {
|
|
156
174
|
return {
|
|
@@ -163,6 +181,7 @@ export function loadMemory(cwd) {
|
|
|
163
181
|
structure: loadStructuralTrust(cwd),
|
|
164
182
|
evidence: loadEvidenceGates(cwd),
|
|
165
183
|
lessons: loadLessonsLedger(cwd),
|
|
184
|
+
goldenPatterns: loadGoldenPatterns(cwd),
|
|
166
185
|
};
|
|
167
186
|
}
|
|
168
187
|
export function saveMemory(cwd, memory) {
|
|
@@ -175,6 +194,9 @@ export function saveMemory(cwd, memory) {
|
|
|
175
194
|
if (memory.lessons) {
|
|
176
195
|
saveLessonsLedger(cwd, memory.lessons);
|
|
177
196
|
}
|
|
197
|
+
if (memory.goldenPatterns) {
|
|
198
|
+
saveGoldenPatterns(cwd, memory.goldenPatterns);
|
|
199
|
+
}
|
|
178
200
|
}
|
|
179
201
|
export function memoryExists(cwd) {
|
|
180
202
|
return existsSync(memoryDir(cwd));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/memory/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/memory/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAYjC,iFAAiF;AAEjF,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,OAAO,IAAI,CAAC,GAAG,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC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AAoB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IAC7C,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnC,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IAC3C,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IACD,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;QAC1B,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;IACjD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Coach — Ledger Admission Outcome Detection
|
|
3
|
+
*
|
|
4
|
+
* Bridges the execution/ledger distinction by querying the most recent
|
|
5
|
+
* ECL-Lite write and the team-ledger write-safety infrastructure.
|
|
6
|
+
*
|
|
7
|
+
* The ECL-Lite recording flow:
|
|
8
|
+
* 1. assertNoProhibitedLedgerContent(entry) → throws if rejected
|
|
9
|
+
* 2. sanitizeEclEntry(entry) → abstracts paths/symbols (always applied)
|
|
10
|
+
* 3. appendFileSync → write to ecl-lite.jsonl
|
|
11
|
+
*
|
|
12
|
+
* Therefore:
|
|
13
|
+
* - If the latest entry exists → it was at least "abstracted_and_allowed"
|
|
14
|
+
* - If no entry exists for the current session → it was rejected or never recorded
|
|
15
|
+
* - The sanitize step always applies abstraction → that's always true
|
|
16
|
+
*
|
|
17
|
+
* For richer signal, we also run validateLedgerWriteObject on the session
|
|
18
|
+
* summary data to detect if any fields would be redacted or rejected.
|
|
19
|
+
*/
|
|
20
|
+
import type { LedgerAdmissionOutcome, SessionValueSummary } from '@codeledger/types';
|
|
21
|
+
/**
|
|
22
|
+
* Detect the ledger admission outcome for the current session.
|
|
23
|
+
*
|
|
24
|
+
* Strategy:
|
|
25
|
+
* 1. Check if ECL-Lite has a recent entry (timestamp within last 60s)
|
|
26
|
+
* → If yes: admitted (abstracted by default)
|
|
27
|
+
* 2. Check for write-safety rejection markers
|
|
28
|
+
* 3. Validate the session summary data against write-safety rules
|
|
29
|
+
*/
|
|
30
|
+
export declare function detectLedgerAdmission(cwd: string, sessionSummary: SessionValueSummary): LedgerAdmissionOutcome;
|
|
31
|
+
//# sourceMappingURL=admission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admission.d.ts","sourceRoot":"","sources":["../../src/prompt-coach/admission.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAIrF;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,mBAAmB,GAClC,sBAAsB,CAmFxB"}
|