claude-mem 12.7.0 → 12.7.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.
@@ -0,0 +1,87 @@
1
+ ---
2
+ name: babysit
3
+ description: Watch a pull request or review cycle until it is ready to merge. Use when asked to babysit, monitor, or keep checking PR comments, reviews, and CI until all actionable issues are resolved.
4
+ ---
5
+
6
+ # Babysit PR
7
+
8
+ Stay with the PR until it is actually clean. Do not stop after one check pass if comments or review threads are still unresolved.
9
+
10
+ ## Workflow
11
+
12
+ 1. Identify the PR number, branch, and base branch.
13
+ 2. Confirm the PR is not draft and inspect mergeability, checks, review decision, comments, and review threads.
14
+ 3. Watch pending checks until they finish. Poll at a practical interval, usually 30-60 seconds unless the user asks for a different cadence.
15
+ 4. Read new comments and unresolved review threads. Treat bot summaries as useful, but verify actionable findings against the code.
16
+ 5. Fix real issues in focused commits, run relevant tests/builds, push, and return to step 2.
17
+ 6. Resolve stale review threads only after verifying the code or generated artifact now addresses the comment.
18
+ 7. Stop only when checks are passing or intentionally skipped, review decision is acceptable, no actionable comments remain, and no unresolved review threads remain.
19
+
20
+ ## GitHub CLI Checks
21
+
22
+ Use `gh pr view` for the coarse status:
23
+
24
+ ```bash
25
+ gh pr view <number> --json \
26
+ number,state,isDraft,mergeable,mergeStateStatus,reviewDecision,headRefOid,statusCheckRollup,url
27
+ ```
28
+
29
+ Resolve the repository owner/name before using GraphQL:
30
+
31
+ ```bash
32
+ repo_json=$(gh repo view --json owner,name)
33
+ owner=$(jq -r '.owner.login // .owner.name' <<<"$repo_json")
34
+ repo=$(jq -r '.name' <<<"$repo_json")
35
+ ```
36
+
37
+ Use GraphQL for unresolved review threads. Include `pageInfo`; omit `cursor` on the first page, then pass the previous `endCursor` with `-f cursor="$cursor"` while `hasNextPage` is `true`.
38
+
39
+ ```bash
40
+ gh api graphql \
41
+ -f query='query($owner:String!,$repo:String!,$number:Int!,$cursor:String){repository(owner:$owner,name:$repo){pullRequest(number:$number){reviewThreads(first:100,after:$cursor){pageInfo{hasNextPage endCursor}nodes{id,isResolved,isOutdated,path,line,comments(last:1){nodes{author{login},body,createdAt,url}}}}}}}' \
42
+ -f owner="$owner" -f repo="$repo" -F number=<number>
43
+ ```
44
+
45
+ Use this loop when a PR may have many review threads:
46
+
47
+ ```bash
48
+ thread_query='query($owner:String!,$repo:String!,$number:Int!,$cursor:String){repository(owner:$owner,name:$repo){pullRequest(number:$number){reviewThreads(first:100,after:$cursor){pageInfo{hasNextPage endCursor}nodes{id,isResolved,isOutdated,path,line,comments(last:1){nodes{author{login},body,createdAt,url}}}}}}}'
49
+ cursor_args=()
50
+
51
+ while :; do
52
+ page=$(gh api graphql -f query="$thread_query" -f owner="$owner" -f repo="$repo" -F number=<number> "${cursor_args[@]}")
53
+ printf '%s\n' "$page" | jq -r '.data.repository.pullRequest.reviewThreads.nodes[]
54
+ | select(.isResolved==false)
55
+ | [.id,.path,(.line//""),(.isOutdated|tostring),(.comments.nodes[-1].author.login//""),(.comments.nodes[-1].body|gsub("\n";" ")|.[0:240])]
56
+ | @tsv'
57
+
58
+ jq -e '.data.repository.pullRequest.reviewThreads.pageInfo.hasNextPage' >/dev/null <<<"$page" || break
59
+ cursor=$(jq -r '.data.repository.pullRequest.reviewThreads.pageInfo.endCursor' <<<"$page")
60
+ cursor_args=(-f cursor="$cursor")
61
+ done
62
+ ```
63
+
64
+ Filter unresolved threads with `jq`:
65
+
66
+ ```bash
67
+ jq -r '.data.repository.pullRequest.reviewThreads.nodes[]
68
+ | select(.isResolved==false)
69
+ | [.id,.path,(.line//""),(.isOutdated|tostring),(.comments.nodes[-1].author.login//""),(.comments.nodes[-1].body|gsub("\n";" ")|.[0:240])]
70
+ | @tsv'
71
+ ```
72
+
73
+ Resolve a stale thread only when the fix is verified:
74
+
75
+ ```bash
76
+ gh api graphql \
77
+ -f query='mutation($threadId:ID!){resolveReviewThread(input:{threadId:$threadId}){thread{id,isResolved}}}' \
78
+ -f threadId=<thread-id>
79
+ ```
80
+
81
+ ## Operating Rules
82
+
83
+ - Keep the watcher running while long checks are pending.
84
+ - If a generated file is part of the distribution, verify the source and generated artifact agree before resolving comments.
85
+ - If a bot reports an issue against stale code, confirm whether the thread is outdated or addressed in the latest head.
86
+ - Before final reporting, do one fresh sweep of PR status, unresolved threads, recent comments, and local `git status`.
87
+ - Report concrete evidence: latest commit SHA, check names and results, unresolved thread count, tests run, and any dirty local files left untouched.
package/dist/index.d.ts DELETED
@@ -1,7 +0,0 @@
1
- /**
2
- * Claude-Mem - TypeScript Declarations
3
- *
4
- * Re-exports SDK utilities for convenience.
5
- */
6
-
7
- export * from './sdk/index.js';
package/dist/index.js DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * Claude-Mem - Main Package Entry Point
3
- *
4
- * This re-exports the SDK utilities for convenience.
5
- * For full SDK access, use: import { ... } from 'claude-mem/sdk'
6
- */
7
-
8
- export * from './sdk/index.js';
@@ -1,109 +0,0 @@
1
- /**
2
- * Claude-Mem SDK - TypeScript Declarations
3
- *
4
- * Standalone module for external consumers to parse claude-mem observation XML
5
- * and build prompts for the memory worker.
6
- */
7
-
8
- export interface ParsedObservation {
9
- type: string;
10
- title: string | null;
11
- subtitle: string | null;
12
- facts: string[];
13
- narrative: string | null;
14
- concepts: string[];
15
- files_read: string[];
16
- files_modified: string[];
17
- }
18
-
19
- export interface ParsedSummary {
20
- request: string | null;
21
- investigated: string | null;
22
- learned: string | null;
23
- completed: string | null;
24
- next_steps: string | null;
25
- notes: string | null;
26
- }
27
-
28
- export interface Observation {
29
- id: number;
30
- tool_name: string;
31
- tool_input: string;
32
- tool_output: string;
33
- created_at_epoch: number;
34
- cwd?: string;
35
- }
36
-
37
- export interface ParseObservationsOptions {
38
- /** Array of valid observation types. If provided, validates types against this list. */
39
- validTypes?: string[];
40
- /** Type to use if type is missing or invalid. Defaults to 'observation'. */
41
- fallbackType?: string;
42
- }
43
-
44
- /**
45
- * Parse observation XML blocks from text
46
- * Returns all observations found in the text
47
- *
48
- * @param text - The text containing observation XML blocks
49
- * @param options - Optional configuration for type validation
50
- * @returns Array of parsed observations
51
- *
52
- * @example
53
- * ```typescript
54
- * const text = `<observation>
55
- * <type>code_change</type>
56
- * <title>Added login feature</title>
57
- * <facts><fact>New auth module</fact></facts>
58
- * </observation>`;
59
- *
60
- * const observations = parseObservations(text);
61
- * // => [{ type: 'code_change', title: 'Added login feature', ... }]
62
- * ```
63
- */
64
- export function parseObservations(
65
- text: string,
66
- options?: ParseObservationsOptions
67
- ): ParsedObservation[];
68
-
69
- /**
70
- * Parse summary XML block from text
71
- * Returns null if no valid summary found or if summary was skipped
72
- *
73
- * @param text - The text containing summary XML block
74
- * @returns Parsed summary or null
75
- *
76
- * @example
77
- * ```typescript
78
- * const text = `<summary>
79
- * <request>Implement auth</request>
80
- * <completed>Added JWT tokens</completed>
81
- * </summary>`;
82
- *
83
- * const summary = parseSummary(text);
84
- * // => { request: 'Implement auth', completed: 'Added JWT tokens', ... }
85
- * ```
86
- */
87
- export function parseSummary(text: string): ParsedSummary | null;
88
-
89
- /**
90
- * Build prompt to send tool observation to SDK agent
91
- *
92
- * @param obs - The observation object containing tool data
93
- * @returns Formatted XML prompt string
94
- *
95
- * @example
96
- * ```typescript
97
- * const obs = {
98
- * id: 1,
99
- * tool_name: 'Read',
100
- * tool_input: '{"file_path": "/src/index.ts"}',
101
- * tool_output: '{"content": "..."}',
102
- * created_at_epoch: Date.now()
103
- * };
104
- *
105
- * const prompt = buildObservationPrompt(obs);
106
- * // => '<observed_from_primary_session>...'
107
- * ```
108
- */
109
- export function buildObservationPrompt(obs: Observation): string;
package/dist/sdk/index.js DELETED
@@ -1,183 +0,0 @@
1
- /**
2
- * Claude-Mem SDK - Standalone module for external consumers
3
- *
4
- * This is a self-contained module that exports parsing and prompt utilities
5
- * without internal dependencies on the main claude-mem codebase.
6
- *
7
- * Usage:
8
- * import { parseObservations, buildObservationPrompt } from 'claude-mem/sdk';
9
- */
10
-
11
- // ============================================================================
12
- // Parser Functions
13
- // ============================================================================
14
-
15
- /**
16
- * Parse observation XML blocks from text
17
- * Returns all observations found in the text
18
- *
19
- * @param {string} text - The text containing observation XML blocks
20
- * @param {Object} [options] - Optional configuration
21
- * @param {string[]} [options.validTypes] - Array of valid observation types. If provided, validates types.
22
- * @param {string} [options.fallbackType='observation'] - Type to use if type is missing or invalid
23
- * @returns {ParsedObservation[]} Array of parsed observations
24
- */
25
- export function parseObservations(text, options = {}) {
26
- const observations = [];
27
- const { validTypes, fallbackType = 'observation' } = options;
28
-
29
- // Match <observation>...</observation> blocks (non-greedy)
30
- const observationRegex = /<observation>([\s\S]*?)<\/observation>/g;
31
-
32
- let match;
33
- while ((match = observationRegex.exec(text)) !== null) {
34
- const obsContent = match[1];
35
-
36
- // Extract all fields
37
- const type = extractField(obsContent, 'type');
38
- const title = extractField(obsContent, 'title');
39
- const subtitle = extractField(obsContent, 'subtitle');
40
- const narrative = extractField(obsContent, 'narrative');
41
- const facts = extractArrayElements(obsContent, 'facts', 'fact');
42
- const concepts = extractArrayElements(obsContent, 'concepts', 'concept');
43
- const files_read = extractArrayElements(obsContent, 'files_read', 'file');
44
- const files_modified = extractArrayElements(obsContent, 'files_modified', 'file');
45
-
46
- // Determine final type
47
- let finalType = fallbackType;
48
- if (type) {
49
- const trimmedType = type.trim();
50
- if (validTypes) {
51
- finalType = validTypes.includes(trimmedType) ? trimmedType : fallbackType;
52
- } else {
53
- finalType = trimmedType;
54
- }
55
- }
56
-
57
- // Filter out type from concepts array (types and concepts are separate dimensions)
58
- const cleanedConcepts = concepts.filter(c => c !== finalType);
59
-
60
- observations.push({
61
- type: finalType,
62
- title,
63
- subtitle,
64
- facts,
65
- narrative,
66
- concepts: cleanedConcepts,
67
- files_read,
68
- files_modified
69
- });
70
- }
71
-
72
- return observations;
73
- }
74
-
75
- /**
76
- * Parse summary XML block from text
77
- * Returns null if no valid summary found or if summary was skipped
78
- *
79
- * @param {string} text - The text containing summary XML block
80
- * @returns {ParsedSummary|null} Parsed summary or null
81
- */
82
- export function parseSummary(text) {
83
- // Check for skip_summary first
84
- const skipRegex = /<skip_summary\s+reason="([^"]+)"\s*\/>/;
85
- const skipMatch = skipRegex.exec(text);
86
-
87
- if (skipMatch) {
88
- return null;
89
- }
90
-
91
- // Match <summary>...</summary> block (non-greedy)
92
- const summaryRegex = /<summary>([\s\S]*?)<\/summary>/;
93
- const summaryMatch = summaryRegex.exec(text);
94
-
95
- if (!summaryMatch) {
96
- return null;
97
- }
98
-
99
- const summaryContent = summaryMatch[1];
100
-
101
- return {
102
- request: extractField(summaryContent, 'request'),
103
- investigated: extractField(summaryContent, 'investigated'),
104
- learned: extractField(summaryContent, 'learned'),
105
- completed: extractField(summaryContent, 'completed'),
106
- next_steps: extractField(summaryContent, 'next_steps'),
107
- notes: extractField(summaryContent, 'notes')
108
- };
109
- }
110
-
111
- /**
112
- * Extract a simple field value from XML content
113
- * Returns null for missing or empty/whitespace-only fields
114
- */
115
- function extractField(content, fieldName) {
116
- const regex = new RegExp(`<${fieldName}>([^<]*)</${fieldName}>`);
117
- const match = regex.exec(content);
118
- if (!match) return null;
119
-
120
- const trimmed = match[1].trim();
121
- return trimmed === '' ? null : trimmed;
122
- }
123
-
124
- /**
125
- * Extract array of elements from XML content
126
- */
127
- function extractArrayElements(content, arrayName, elementName) {
128
- const elements = [];
129
-
130
- // Match the array block
131
- const arrayRegex = new RegExp(`<${arrayName}>(.*?)</${arrayName}>`, 's');
132
- const arrayMatch = arrayRegex.exec(content);
133
-
134
- if (!arrayMatch) {
135
- return elements;
136
- }
137
-
138
- const arrayContent = arrayMatch[1];
139
-
140
- // Extract individual elements
141
- const elementRegex = new RegExp(`<${elementName}>([^<]+)</${elementName}>`, 'g');
142
- let elementMatch;
143
- while ((elementMatch = elementRegex.exec(arrayContent)) !== null) {
144
- elements.push(elementMatch[1].trim());
145
- }
146
-
147
- return elements;
148
- }
149
-
150
- // ============================================================================
151
- // Prompt Building Functions
152
- // ============================================================================
153
-
154
- /**
155
- * Build prompt to send tool observation to SDK agent
156
- *
157
- * @param {Observation} obs - The observation object containing tool data
158
- * @returns {string} Formatted XML prompt string
159
- */
160
- export function buildObservationPrompt(obs) {
161
- // Safely parse tool_input and tool_output - they may be JSON strings
162
- let toolInput;
163
- let toolOutput;
164
-
165
- try {
166
- toolInput = typeof obs.tool_input === 'string' ? JSON.parse(obs.tool_input) : obs.tool_input;
167
- } catch {
168
- toolInput = obs.tool_input;
169
- }
170
-
171
- try {
172
- toolOutput = typeof obs.tool_output === 'string' ? JSON.parse(obs.tool_output) : obs.tool_output;
173
- } catch {
174
- toolOutput = obs.tool_output;
175
- }
176
-
177
- return `<observed_from_primary_session>
178
- <what_happened>${obs.tool_name}</what_happened>
179
- <occurred_at>${new Date(obs.created_at_epoch).toISOString()}</occurred_at>${obs.cwd ? `\n <working_directory>${obs.cwd}</working_directory>` : ''}
180
- <parameters>${JSON.stringify(toolInput, null, 2)}</parameters>
181
- <outcome>${JSON.stringify(toolOutput, null, 2)}</outcome>
182
- </observed_from_primary_session>`;
183
- }