@mmnto/cli 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/dist/commands/anchor.d.ts.map +1 -1
- package/dist/commands/anchor.js +7 -4
- package/dist/commands/anchor.js.map +1 -1
- package/dist/commands/briefing.d.ts +1 -0
- package/dist/commands/briefing.d.ts.map +1 -1
- package/dist/commands/briefing.js +32 -32
- package/dist/commands/briefing.js.map +1 -1
- package/dist/commands/handoff.d.ts +1 -0
- package/dist/commands/handoff.d.ts.map +1 -1
- package/dist/commands/handoff.js +37 -38
- package/dist/commands/handoff.js.map +1 -1
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +170 -44
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/init.test.d.ts +2 -0
- package/dist/commands/init.test.d.ts.map +1 -0
- package/dist/commands/init.test.js +98 -0
- package/dist/commands/init.test.js.map +1 -0
- package/dist/commands/install-hooks.js +9 -9
- package/dist/commands/learn.d.ts +1 -0
- package/dist/commands/learn.d.ts.map +1 -1
- package/dist/commands/learn.js +32 -34
- package/dist/commands/learn.js.map +1 -1
- package/dist/commands/shield.d.ts +5 -0
- package/dist/commands/shield.d.ts.map +1 -1
- package/dist/commands/shield.js +63 -35
- package/dist/commands/shield.js.map +1 -1
- package/dist/commands/shield.test.d.ts +2 -0
- package/dist/commands/shield.test.d.ts.map +1 -0
- package/dist/commands/shield.test.js +92 -0
- package/dist/commands/shield.test.js.map +1 -0
- package/dist/commands/spec.d.ts +1 -0
- package/dist/commands/spec.d.ts.map +1 -1
- package/dist/commands/spec.js +36 -36
- package/dist/commands/spec.js.map +1 -1
- package/dist/commands/triage.d.ts +1 -0
- package/dist/commands/triage.d.ts.map +1 -1
- package/dist/commands/triage.js +30 -30
- package/dist/commands/triage.js.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +127 -13
- package/dist/utils.js.map +1 -1
- package/dist/utils.test.d.ts +2 -0
- package/dist/utils.test.d.ts.map +1 -0
- package/dist/utils.test.js +27 -0
- package/dist/utils.test.js.map +1 -0
- package/package.json +5 -4
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Matt Sutton
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matt Sutton
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../src/commands/anchor.ts"],"names":[],"mappings":"AAkBA,wBAAsB,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../src/commands/anchor.ts"],"names":[],"mappings":"AAkBA,wBAAsB,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0ErE"}
|
package/dist/commands/anchor.js
CHANGED
|
@@ -34,7 +34,10 @@ export async function anchorCommand(lessonArg) {
|
|
|
34
34
|
const fix = await rl.question('> Fix/Rule (e.g., Use custom localStorage wrappers...): ');
|
|
35
35
|
const tagStr = await rl.question('> Tags (comma separated): ');
|
|
36
36
|
if (tagStr.trim()) {
|
|
37
|
-
tags.push(...tagStr
|
|
37
|
+
tags.push(...tagStr
|
|
38
|
+
.split(',')
|
|
39
|
+
.map((t) => t.trim())
|
|
40
|
+
.filter(Boolean));
|
|
38
41
|
}
|
|
39
42
|
const parts = [];
|
|
40
43
|
if (context.trim())
|
|
@@ -43,7 +46,7 @@ export async function anchorCommand(lessonArg) {
|
|
|
43
46
|
parts.push(`**Symptom:** ${symptom.trim()}`);
|
|
44
47
|
if (fix.trim())
|
|
45
48
|
parts.push(`**Fix/Rule:** ${fix.trim()}`);
|
|
46
|
-
lessonText = parts.join('
|
|
49
|
+
lessonText = parts.join('\n');
|
|
47
50
|
}
|
|
48
51
|
finally {
|
|
49
52
|
rl.close();
|
|
@@ -55,9 +58,9 @@ export async function anchorCommand(lessonArg) {
|
|
|
55
58
|
}
|
|
56
59
|
const timestamp = new Date().toISOString();
|
|
57
60
|
const tagString = tags.length > 0 ? tags.join(', ') : 'manual';
|
|
58
|
-
const entry =
|
|
61
|
+
const entry = `\n## Lesson — ${timestamp}\n\n**Tags:** ${tagString}\n\n${lessonText.trim()}\n`;
|
|
59
62
|
fs.appendFileSync(lessonsPath, entry, 'utf-8');
|
|
60
|
-
console.log(
|
|
63
|
+
console.log(`\n[Totem] Lesson saved to ${config.totemDir}/lessons.md`);
|
|
61
64
|
const logPath = path.join(totemDir, 'mcp-sync.log');
|
|
62
65
|
console.log('[Totem] Triggering background re-index...');
|
|
63
66
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor.js","sourceRoot":"","sources":["../../src/commands/anchor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,KAAK,IAAI,KAAK,EA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QAC7C,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACxC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE;YAC7B,GAAG;YACH,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC;YAC/B,KAAK,EAAE,MAAM;YACb,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;QACH,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,oDAAoD,EAAE,GAAG,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"briefing.d.ts","sourceRoot":"","sources":["../../src/commands/briefing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"briefing.d.ts","sourceRoot":"","sources":["../../src/commands/briefing.ts"],"names":[],"mappings":"AAwJA,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAwC7E"}
|
|
@@ -3,42 +3,42 @@ import * as path from 'node:path';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { createEmbedder, LanceStore } from '@mmnto/totem';
|
|
5
5
|
import { getGitBranch, getGitStatus } from '../git.js';
|
|
6
|
-
import { formatResults, GH_TIMEOUT_MS, IS_WIN, loadConfig, loadEnv, resolveConfigPath, runOrchestrator, writeOutput, } from '../utils.js';
|
|
6
|
+
import { formatResults, GH_TIMEOUT_MS, IS_WIN, loadConfig, loadEnv, resolveConfigPath, runOrchestrator, wrapXml, writeOutput, } from '../utils.js';
|
|
7
7
|
// ─── Constants ──────────────────────────────────────────
|
|
8
8
|
const TAG = 'Briefing';
|
|
9
9
|
const MAX_SPEC_RESULTS = 5;
|
|
10
10
|
const MAX_SESSION_RESULTS = 5;
|
|
11
11
|
// ─── System prompt ──────────────────────────────────────
|
|
12
|
-
const SYSTEM_PROMPT = `# Briefing System Prompt — Session Startup Briefing
|
|
13
|
-
|
|
14
|
-
## Purpose
|
|
15
|
-
Produce a session startup briefing that orients the developer at the start of an AI-assisted work session.
|
|
16
|
-
|
|
17
|
-
## Role
|
|
18
|
-
You are a technical project assistant producing a quick-start briefing. You have access to the current git state, open pull requests, and project knowledge from Totem. Your job is to synthesize this into an actionable summary so the developer knows exactly where they left off and what to do next.
|
|
19
|
-
|
|
20
|
-
## Rules
|
|
21
|
-
- Reference PRs by number (#NNN) and branch name
|
|
22
|
-
- Reference issues by number (#NNN) when they appear in Totem knowledge
|
|
23
|
-
- Be opinionated about what the recommended first action should be
|
|
24
|
-
- Be concise — this is a startup briefing, not a project plan
|
|
25
|
-
- If there are uncommitted changes, flag them prominently
|
|
26
|
-
- If there are no open PRs, say so
|
|
27
|
-
|
|
28
|
-
## Output Format
|
|
29
|
-
Respond with ONLY the sections below. No preamble, no closing remarks.
|
|
30
|
-
|
|
31
|
-
### Session Context
|
|
32
|
-
[Current branch, uncommitted changes summary. If working tree is clean, say so. If on a feature branch, note what it likely relates to.]
|
|
33
|
-
|
|
34
|
-
### Open PRs
|
|
35
|
-
[List of open PRs with number, title, and branch. If none, say "No open PRs." Highlight any that are the developer's current branch.]
|
|
36
|
-
|
|
37
|
-
### Active Priorities
|
|
38
|
-
[Key priorities and recent work context from Totem knowledge — what was recently worked on, what specs are active, what sessions covered. If no relevant knowledge, say "No recent context found in Totem index."]
|
|
39
|
-
|
|
40
|
-
### Recommended First Action
|
|
41
|
-
[Single clear recommendation for what the developer should do first in this session. Consider: uncommitted work to commit/continue, PRs to review/merge, next issue to pick up.]
|
|
12
|
+
const SYSTEM_PROMPT = `# Briefing System Prompt — Session Startup Briefing
|
|
13
|
+
|
|
14
|
+
## Purpose
|
|
15
|
+
Produce a session startup briefing that orients the developer at the start of an AI-assisted work session.
|
|
16
|
+
|
|
17
|
+
## Role
|
|
18
|
+
You are a technical project assistant producing a quick-start briefing. You have access to the current git state, open pull requests, and project knowledge from Totem. Your job is to synthesize this into an actionable summary so the developer knows exactly where they left off and what to do next.
|
|
19
|
+
|
|
20
|
+
## Rules
|
|
21
|
+
- Reference PRs by number (#NNN) and branch name
|
|
22
|
+
- Reference issues by number (#NNN) when they appear in Totem knowledge
|
|
23
|
+
- Be opinionated about what the recommended first action should be
|
|
24
|
+
- Be concise — this is a startup briefing, not a project plan
|
|
25
|
+
- If there are uncommitted changes, flag them prominently
|
|
26
|
+
- If there are no open PRs, say so
|
|
27
|
+
|
|
28
|
+
## Output Format
|
|
29
|
+
Respond with ONLY the sections below. No preamble, no closing remarks.
|
|
30
|
+
|
|
31
|
+
### Session Context
|
|
32
|
+
[Current branch, uncommitted changes summary. If working tree is clean, say so. If on a feature branch, note what it likely relates to.]
|
|
33
|
+
|
|
34
|
+
### Open PRs
|
|
35
|
+
[List of open PRs with number, title, and branch. If none, say "No open PRs." Highlight any that are the developer's current branch.]
|
|
36
|
+
|
|
37
|
+
### Active Priorities
|
|
38
|
+
[Key priorities and recent work context from Totem knowledge — what was recently worked on, what specs are active, what sessions covered. If no relevant knowledge, say "No recent context found in Totem index."]
|
|
39
|
+
|
|
40
|
+
### Recommended First Action
|
|
41
|
+
[Single clear recommendation for what the developer should do first in this session. Consider: uncommitted work to commit/continue, PRs to review/merge, next issue to pick up.]
|
|
42
42
|
`;
|
|
43
43
|
// ─── GitHub helpers ─────────────────────────────────────
|
|
44
44
|
const GhPrListItemSchema = z.object({
|
|
@@ -81,7 +81,7 @@ function assemblePrompt(branch, status, prs, context) {
|
|
|
81
81
|
// Git state
|
|
82
82
|
sections.push('=== GIT STATE ===');
|
|
83
83
|
sections.push(`Branch: ${branch}`);
|
|
84
|
-
sections.push(`Uncommitted changes:\n${status
|
|
84
|
+
sections.push(`Uncommitted changes:\n${status ? wrapXml('git_status', status) : '(clean working tree)'}`);
|
|
85
85
|
// Open PRs
|
|
86
86
|
sections.push('\n=== OPEN PULL REQUESTS ===');
|
|
87
87
|
sections.push(formatPRList(prs));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"briefing.js","sourceRoot":"","sources":["../../src/commands/briefing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EACL,aAAa,EACb,aAAa,EACb,MAAM,EACN,UAAU,EACV,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,2DAA2D;AAE3D,MAAM,GAAG,GAAG,UAAU,CAAC;AACvB,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,2DAA2D;AAE3D,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BrB,CAAC;AAEF,2DAA2D;AAE3D,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;CACxB,CAAC,CAAC;AAGH,SAAS,YAAY,CAAC,GAAW;IAC/B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,YAAY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I,IAAI,EAAE,CAAC;QACpB,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,OAAO,CAAC,GAAG;YAAE,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,gBAAgB,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../../src/commands/handoff.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../../src/commands/handoff.ts"],"names":[],"mappings":"AAoHA,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAsB,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAuC3E"}
|
package/dist/commands/handoff.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { getGitBranch, getGitDiff, getGitDiffStat, getGitStatus } from '../git.js';
|
|
4
|
-
import { loadConfig, loadEnv, resolveConfigPath, runOrchestrator, writeOutput } from '../utils.js';
|
|
4
|
+
import { loadConfig, loadEnv, resolveConfigPath, runOrchestrator, wrapXml, writeOutput, } from '../utils.js';
|
|
5
5
|
// ─── Constants ──────────────────────────────────────────
|
|
6
6
|
const TAG = 'Handoff';
|
|
7
7
|
const MAX_DIFF_CHARS = 50_000;
|
|
8
8
|
const LESSONS_TAIL_LINES = 100;
|
|
9
9
|
// ─── System prompt ──────────────────────────────────────
|
|
10
|
-
const SYSTEM_PROMPT = `# Handoff System Prompt — End-of-Session State Transfer
|
|
11
|
-
|
|
12
|
-
## Purpose
|
|
13
|
-
Produce an end-of-session handoff snapshot that captures everything the next session (or the next developer) needs to resume work immediately.
|
|
14
|
-
|
|
15
|
-
## Role
|
|
16
|
-
You are writing a concise, tactical "End of Shift" handoff. You have access to the current git state, uncommitted changes, and lessons learned during this session. Your job is to synthesize this into a snapshot that lets the next session bootstrap instantly — no detective work required.
|
|
17
|
-
|
|
18
|
-
## Rules
|
|
19
|
-
- Be concrete and specific — file paths, branch names, issue numbers
|
|
20
|
-
- Distinguish between what IS done vs what NEEDS to be done next
|
|
21
|
-
- If there are uncommitted changes, describe what they represent and whether they look ready to commit
|
|
22
|
-
- If the working tree is clean, say so and focus on what was accomplished and what's next
|
|
23
|
-
- Capture any lessons or traps discovered during this session
|
|
24
|
-
- Be concise — this is a tactical handoff, not a retrospective
|
|
25
|
-
|
|
26
|
-
## Output Format
|
|
27
|
-
Respond with ONLY the sections below. No preamble, no closing remarks.
|
|
28
|
-
|
|
29
|
-
### Branch & State
|
|
30
|
-
[Current branch, clean/dirty status, what the branch represents]
|
|
31
|
-
|
|
32
|
-
### What Was Done
|
|
33
|
-
[Summary of work completed this session based on the diff and git state. If no changes, say "No uncommitted changes — session may have been exploratory or changes were already committed."]
|
|
34
|
-
|
|
35
|
-
### Uncommitted Changes
|
|
36
|
-
[Description of what the uncommitted changes contain and their state (staged vs unstaged). If clean, say "Working tree is clean."]
|
|
37
|
-
|
|
38
|
-
### Lessons & Traps
|
|
39
|
-
[Lessons learned during this session from the memory file. If none, say "No new lessons recorded this session."]
|
|
40
|
-
|
|
41
|
-
### Next Steps
|
|
42
|
-
[Clear, ordered list of what the next session should do first. Be specific — not "continue working" but "finish implementing X in file Y, then run tests."]
|
|
10
|
+
const SYSTEM_PROMPT = `# Handoff System Prompt — End-of-Session State Transfer
|
|
11
|
+
|
|
12
|
+
## Purpose
|
|
13
|
+
Produce an end-of-session handoff snapshot that captures everything the next session (or the next developer) needs to resume work immediately.
|
|
14
|
+
|
|
15
|
+
## Role
|
|
16
|
+
You are writing a concise, tactical "End of Shift" handoff. You have access to the current git state, uncommitted changes, and lessons learned during this session. Your job is to synthesize this into a snapshot that lets the next session bootstrap instantly — no detective work required.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Be concrete and specific — file paths, branch names, issue numbers
|
|
20
|
+
- Distinguish between what IS done vs what NEEDS to be done next
|
|
21
|
+
- If there are uncommitted changes, describe what they represent and whether they look ready to commit
|
|
22
|
+
- If the working tree is clean, say so and focus on what was accomplished and what's next
|
|
23
|
+
- Capture any lessons or traps discovered during this session
|
|
24
|
+
- Be concise — this is a tactical handoff, not a retrospective
|
|
25
|
+
|
|
26
|
+
## Output Format
|
|
27
|
+
Respond with ONLY the sections below. No preamble, no closing remarks.
|
|
28
|
+
|
|
29
|
+
### Branch & State
|
|
30
|
+
[Current branch, clean/dirty status, what the branch represents]
|
|
31
|
+
|
|
32
|
+
### What Was Done
|
|
33
|
+
[Summary of work completed this session based on the diff and git state. If no changes, say "No uncommitted changes — session may have been exploratory or changes were already committed."]
|
|
34
|
+
|
|
35
|
+
### Uncommitted Changes
|
|
36
|
+
[Description of what the uncommitted changes contain and their state (staged vs unstaged). If clean, say "Working tree is clean."]
|
|
37
|
+
|
|
38
|
+
### Lessons & Traps
|
|
39
|
+
[Lessons learned during this session from the memory file. If none, say "No new lessons recorded this session."]
|
|
40
|
+
|
|
41
|
+
### Next Steps
|
|
42
|
+
[Clear, ordered list of what the next session should do first. Be specific — not "continue working" but "finish implementing X in file Y, then run tests."]
|
|
43
43
|
`;
|
|
44
44
|
// ─── Lessons file reader ────────────────────────────────
|
|
45
45
|
function readRecentLessons(cwd, totemDir) {
|
|
@@ -58,7 +58,7 @@ function assemblePrompt(branch, status, diff, diffStat, lessons) {
|
|
|
58
58
|
// Git state
|
|
59
59
|
sections.push('=== GIT STATE ===');
|
|
60
60
|
sections.push(`Branch: ${branch}`);
|
|
61
|
-
sections.push(`Status:\n${status
|
|
61
|
+
sections.push(`Status:\n${status ? wrapXml('git_status', status) : '(clean working tree)'}`);
|
|
62
62
|
// Diff
|
|
63
63
|
sections.push('\n=== DIFF ===');
|
|
64
64
|
if (!diff.trim()) {
|
|
@@ -70,11 +70,10 @@ function assemblePrompt(branch, status, diff, diffStat, lessons) {
|
|
|
70
70
|
sections.push('');
|
|
71
71
|
}
|
|
72
72
|
if (diff.length > MAX_DIFF_CHARS) {
|
|
73
|
-
sections.push(diff.slice(0, MAX_DIFF_CHARS));
|
|
74
|
-
sections.push(`\n... [diff truncated at ${MAX_DIFF_CHARS} chars] ...`);
|
|
73
|
+
sections.push(wrapXml('git_diff', diff.slice(0, MAX_DIFF_CHARS) + `\n... [diff truncated at ${MAX_DIFF_CHARS} chars] ...`));
|
|
75
74
|
}
|
|
76
75
|
else {
|
|
77
|
-
sections.push(diff);
|
|
76
|
+
sections.push(wrapXml('git_diff', diff));
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
// Lessons
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/commands/handoff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,
|
|
1
|
+
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/commands/handoff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EACL,UAAU,EACV,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,OAAO,EACP,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,2DAA2D;AAE3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AC,IAAI,CAAC,CAAC;IAEzE,MAAM,OAAO,GAAG,eAAe,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5E,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,OAAO,CAAC,GAAG;YAAE,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,gBAAgB,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC"}
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
export declare function buildNpxCommand(isWin: boolean): {
|
|
2
|
+
command: string;
|
|
3
|
+
args: string[];
|
|
4
|
+
};
|
|
5
|
+
export declare function scaffoldMcpConfig(filePath: string, serverEntry: Record<string, unknown>): {
|
|
6
|
+
action: 'created' | 'merged' | 'skipped';
|
|
7
|
+
err?: string;
|
|
8
|
+
};
|
|
1
9
|
export declare function initCommand(): Promise<void>;
|
|
2
10
|
//# sourceMappingURL=init.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAmDA,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAInF;AAuCD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC;IAAE,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAoD5D;AAkHD,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CA+KjD"}
|
package/dist/commands/init.js
CHANGED
|
@@ -2,30 +2,113 @@ import * as fs from 'node:fs';
|
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { stdin as input, stdout as output } from 'node:process';
|
|
4
4
|
import * as readline from 'node:readline/promises';
|
|
5
|
+
import { IS_WIN } from '../utils.js';
|
|
5
6
|
import { installPostMergeHook } from './install-hooks.js';
|
|
6
|
-
const AI_PROMPT_BLOCK = `
|
|
7
|
-
|
|
8
|
-
## Totem AI Integration (Auto-Generated)
|
|
9
|
-
You have access to the Totem MCP for long-term project memory. You MUST operate with the following reflexes:
|
|
10
|
-
|
|
11
|
-
### Memory Reflexes
|
|
12
|
-
1. **Pull Before Planning:** Before writing specs, architecture, or fixing complex bugs, use \`search_knowledge\` to retrieve domain constraints and past traps.
|
|
13
|
-
2. **Proactive Anchoring (The 3 Triggers):** You must autonomously call \`add_lesson\` when any of the following occur — do NOT wait for the user to ask:
|
|
14
|
-
- **The Trap Trigger:** If you spend >2 turns fixing a bug caused by a framework quirk, unexpected API response, or edge case. (Anchor the symptom + fix).
|
|
15
|
-
- **The Pivot Trigger:** If the user introduces a new architectural pattern or deprecates an old one. (Anchor the rule).
|
|
16
|
-
- **The Handoff Trigger:** At the end of a session or when wrapping up a complex feature, extract the non-obvious lessons learned and anchor them.
|
|
17
|
-
3. **Tool Preference (MCP over CLI):** Always prioritize using dedicated MCP tools (e.g., GitHub, Supabase, Vercel) over executing generic shell commands (like \`gh issue view\` or \`curl\`). MCP tools provide structured, un-truncated data optimized for your context window. Only fall back to bash execution if an MCP tool is unavailable or fails.
|
|
18
|
-
|
|
19
|
-
Lessons are automatically re-indexed in the background after each \`add_lesson\` call — no manual sync needed.
|
|
20
|
-
|
|
21
|
-
### Workflow Orchestrator Rituals
|
|
22
|
-
[FOR LOCAL CLI/TERMINAL AGENTS ONLY] Do not attempt to run these commands if you are a headless bot or operating in a cloud PR environment (e.g., Gemini Code Assist on GitHub).
|
|
23
|
-
Totem provides CLI commands that map to your development lifecycle. Use them at these moments:
|
|
24
|
-
1. **Start of Session:** Run \`totem briefing\` to get oriented with current branch state, open PRs, and recent context. Run \`totem triage\` if you need to pick a new task.
|
|
25
|
-
2. **Before Implementation:** Run \`totem spec <issue-url-or-topic>\` to generate an architectural plan and review related context before writing code.
|
|
26
|
-
3. **Before PR/Push:** Run \`totem shield\` to analyze uncommitted changes against project knowledge — catches architectural drift and pattern violations.
|
|
27
|
-
4. **End of Session:** Run \`totem handoff\` to generate a snapshot for the next agent session with current progress and open threads.
|
|
7
|
+
const AI_PROMPT_BLOCK = `
|
|
8
|
+
|
|
9
|
+
## Totem AI Integration (Auto-Generated)
|
|
10
|
+
You have access to the Totem MCP for long-term project memory. You MUST operate with the following reflexes:
|
|
11
|
+
|
|
12
|
+
### Memory Reflexes
|
|
13
|
+
1. **Pull Before Planning:** Before writing specs, architecture, or fixing complex bugs, use \`search_knowledge\` to retrieve domain constraints and past traps.
|
|
14
|
+
2. **Proactive Anchoring (The 3 Triggers):** You must autonomously call \`add_lesson\` when any of the following occur — do NOT wait for the user to ask:
|
|
15
|
+
- **The Trap Trigger:** If you spend >2 turns fixing a bug caused by a framework quirk, unexpected API response, or edge case. (Anchor the symptom + fix).
|
|
16
|
+
- **The Pivot Trigger:** If the user introduces a new architectural pattern or deprecates an old one. (Anchor the rule).
|
|
17
|
+
- **The Handoff Trigger:** At the end of a session or when wrapping up a complex feature, extract the non-obvious lessons learned and anchor them.
|
|
18
|
+
3. **Tool Preference (MCP over CLI):** Always prioritize using dedicated MCP tools (e.g., GitHub, Supabase, Vercel) over executing generic shell commands (like \`gh issue view\` or \`curl\`). MCP tools provide structured, un-truncated data optimized for your context window. Only fall back to bash execution if an MCP tool is unavailable or fails.
|
|
19
|
+
|
|
20
|
+
Lessons are automatically re-indexed in the background after each \`add_lesson\` call — no manual sync needed.
|
|
21
|
+
|
|
22
|
+
### Workflow Orchestrator Rituals
|
|
23
|
+
[FOR LOCAL CLI/TERMINAL AGENTS ONLY] Do not attempt to run these commands if you are a headless bot or operating in a cloud PR environment (e.g., Gemini Code Assist on GitHub).
|
|
24
|
+
Totem provides CLI commands that map to your development lifecycle. Use them at these moments:
|
|
25
|
+
1. **Start of Session:** Run \`totem briefing\` to get oriented with current branch state, open PRs, and recent context. Run \`totem triage\` if you need to pick a new task.
|
|
26
|
+
2. **Before Implementation:** Run \`totem spec <issue-url-or-topic>\` to generate an architectural plan and review related context before writing code.
|
|
27
|
+
3. **Before PR/Push:** Run \`totem shield\` to analyze uncommitted changes against project knowledge — catches architectural drift and pattern violations.
|
|
28
|
+
4. **End of Session:** Run \`totem handoff\` to generate a snapshot for the next agent session with current progress and open threads.
|
|
28
29
|
`;
|
|
30
|
+
export function buildNpxCommand(isWin) {
|
|
31
|
+
return isWin
|
|
32
|
+
? { command: 'cmd', args: ['/c', 'npx', '-y', '@mmnto/mcp'] }
|
|
33
|
+
: { command: 'npx', args: ['-y', '@mmnto/mcp'] };
|
|
34
|
+
}
|
|
35
|
+
const { command: npxCmd, args: npxArgs } = buildNpxCommand(IS_WIN);
|
|
36
|
+
const AI_TOOLS = [
|
|
37
|
+
{
|
|
38
|
+
name: 'Claude Code',
|
|
39
|
+
mcpPath: '.mcp.json',
|
|
40
|
+
serverEntry: { type: 'stdio', command: npxCmd, args: npxArgs },
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Gemini CLI',
|
|
44
|
+
mcpPath: '.gemini/settings.json',
|
|
45
|
+
serverEntry: { command: npxCmd, args: npxArgs },
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Cursor',
|
|
49
|
+
mcpPath: '.cursor/mcp.json',
|
|
50
|
+
serverEntry: { type: 'stdio', command: npxCmd, args: npxArgs },
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
function detectAiTools(cwd) {
|
|
54
|
+
const exists = (p) => fs.existsSync(path.join(cwd, p));
|
|
55
|
+
const detected = [];
|
|
56
|
+
if (exists('CLAUDE.md') || exists('.claude')) {
|
|
57
|
+
detected.push(AI_TOOLS.find((t) => t.name === 'Claude Code'));
|
|
58
|
+
}
|
|
59
|
+
if (exists('.gemini')) {
|
|
60
|
+
detected.push(AI_TOOLS.find((t) => t.name === 'Gemini CLI'));
|
|
61
|
+
}
|
|
62
|
+
if (exists('.cursorrules')) {
|
|
63
|
+
detected.push(AI_TOOLS.find((t) => t.name === 'Cursor'));
|
|
64
|
+
}
|
|
65
|
+
return detected;
|
|
66
|
+
}
|
|
67
|
+
export function scaffoldMcpConfig(filePath, serverEntry) {
|
|
68
|
+
try {
|
|
69
|
+
if (!fs.existsSync(filePath)) {
|
|
70
|
+
const dir = path.dirname(filePath);
|
|
71
|
+
if (!fs.existsSync(dir)) {
|
|
72
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
fs.writeFileSync(filePath, JSON.stringify({ mcpServers: { totem: serverEntry } }, null, 2) + '\n', 'utf-8');
|
|
75
|
+
return { action: 'created' };
|
|
76
|
+
}
|
|
77
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
78
|
+
let parsed;
|
|
79
|
+
try {
|
|
80
|
+
parsed = JSON.parse(raw);
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
84
|
+
return {
|
|
85
|
+
action: 'skipped',
|
|
86
|
+
err: `Could not parse ${path.basename(filePath)} (invalid JSON): ${message}`,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if (parsed.mcpServers !== undefined &&
|
|
90
|
+
(typeof parsed.mcpServers !== 'object' ||
|
|
91
|
+
parsed.mcpServers === null ||
|
|
92
|
+
Array.isArray(parsed.mcpServers))) {
|
|
93
|
+
return {
|
|
94
|
+
action: 'skipped',
|
|
95
|
+
err: `Could not merge config: "mcpServers" in ${path.basename(filePath)} must be an object.`,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const servers = (parsed.mcpServers ?? {});
|
|
99
|
+
if ('totem' in servers) {
|
|
100
|
+
return { action: 'skipped' };
|
|
101
|
+
}
|
|
102
|
+
servers.totem = serverEntry;
|
|
103
|
+
parsed.mcpServers = servers;
|
|
104
|
+
fs.writeFileSync(filePath, JSON.stringify(parsed, null, 2) + '\n', 'utf-8');
|
|
105
|
+
return { action: 'merged' };
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
109
|
+
return { action: 'skipped', err: message };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
29
112
|
function detectProject(cwd) {
|
|
30
113
|
const exists = (p) => fs.existsSync(path.join(cwd, p));
|
|
31
114
|
return {
|
|
@@ -94,28 +177,28 @@ function generateConfig(targets, provider) {
|
|
|
94
177
|
const embeddingBlock = provider === 'openai'
|
|
95
178
|
? ` embedding: { provider: 'openai', model: 'text-embedding-3-small' },`
|
|
96
179
|
: ` embedding: { provider: 'ollama', model: 'nomic-embed-text', baseUrl: 'http://localhost:11434' },`;
|
|
97
|
-
return `import type { TotemConfig } from '@mmnto/totem';
|
|
98
|
-
|
|
99
|
-
const config: TotemConfig = {
|
|
100
|
-
targets: [
|
|
101
|
-
${formatTargets(targets)}
|
|
102
|
-
],
|
|
103
|
-
|
|
104
|
-
${embeddingBlock}
|
|
105
|
-
|
|
106
|
-
orchestrator: {
|
|
107
|
-
provider: 'shell',
|
|
108
|
-
command: 'gemini --model {model} -o json -e none < {file}',
|
|
109
|
-
defaultModel: 'gemini-3-flash-preview',
|
|
110
|
-
overrides: {
|
|
111
|
-
'spec': 'gemini-3.1-pro-preview',
|
|
112
|
-
'shield': 'gemini-3.1-pro-preview',
|
|
113
|
-
'triage': 'gemini-3.1-pro-preview',
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export default config;
|
|
180
|
+
return `import type { TotemConfig } from '@mmnto/totem';
|
|
181
|
+
|
|
182
|
+
const config: TotemConfig = {
|
|
183
|
+
targets: [
|
|
184
|
+
${formatTargets(targets)}
|
|
185
|
+
],
|
|
186
|
+
|
|
187
|
+
${embeddingBlock}
|
|
188
|
+
|
|
189
|
+
orchestrator: {
|
|
190
|
+
provider: 'shell',
|
|
191
|
+
command: 'gemini --model {model} -o json -e none < {file}',
|
|
192
|
+
defaultModel: 'gemini-3-flash-preview',
|
|
193
|
+
overrides: {
|
|
194
|
+
'spec': 'gemini-3.1-pro-preview',
|
|
195
|
+
'shield': 'gemini-3.1-pro-preview',
|
|
196
|
+
'triage': 'gemini-3.1-pro-preview',
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export default config;
|
|
119
202
|
`;
|
|
120
203
|
}
|
|
121
204
|
export async function initCommand() {
|
|
@@ -213,6 +296,49 @@ export async function initCommand() {
|
|
|
213
296
|
}
|
|
214
297
|
}
|
|
215
298
|
}
|
|
299
|
+
// --- Always run: MCP server registration ---
|
|
300
|
+
const detectedTools = detectAiTools(cwd);
|
|
301
|
+
if (detectedTools.length > 0) {
|
|
302
|
+
const toolNames = detectedTools.map((t) => t.name).join(', ');
|
|
303
|
+
console.log(`\n[Totem] Detected AI tools: ${toolNames}`);
|
|
304
|
+
const mcpAnswer = await rl.question('Which tools should Totem configure MCP for? [all/none/select] (default: all): ');
|
|
305
|
+
let selectedTools;
|
|
306
|
+
const trimmed = mcpAnswer.trim().toLowerCase();
|
|
307
|
+
if (trimmed === 'none') {
|
|
308
|
+
selectedTools = [];
|
|
309
|
+
}
|
|
310
|
+
else if (trimmed === 'select') {
|
|
311
|
+
selectedTools = [];
|
|
312
|
+
for (const tool of detectedTools) {
|
|
313
|
+
const pick = await rl.question(` Configure ${tool.name}? (Y/n): `);
|
|
314
|
+
if (pick.trim().toLowerCase() !== 'n' && pick.trim().toLowerCase() !== 'no') {
|
|
315
|
+
selectedTools.push(tool);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
// 'all' or Enter (default)
|
|
321
|
+
selectedTools = detectedTools;
|
|
322
|
+
}
|
|
323
|
+
for (const tool of selectedTools) {
|
|
324
|
+
const filePath = path.join(cwd, tool.mcpPath);
|
|
325
|
+
const result = scaffoldMcpConfig(filePath, tool.serverEntry);
|
|
326
|
+
if (result.err) {
|
|
327
|
+
console.error(`\n[Totem Error] ${result.err}`);
|
|
328
|
+
console.log(`To fix this, add the following manually to your ${tool.mcpPath} under "mcpServers":\n`);
|
|
329
|
+
console.log(` "totem": ${JSON.stringify(tool.serverEntry, null, 2)}\n`);
|
|
330
|
+
}
|
|
331
|
+
else if (result.action === 'created') {
|
|
332
|
+
console.log(`[Totem] Created ${tool.mcpPath} with Totem MCP server.`);
|
|
333
|
+
}
|
|
334
|
+
else if (result.action === 'merged') {
|
|
335
|
+
console.log(`[Totem] Added Totem MCP server to existing ${tool.mcpPath}.`);
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
console.log(`[Totem] ${tool.mcpPath} already has Totem configured.`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
216
342
|
// --- Always run: post-merge git hook ---
|
|
217
343
|
await installPostMergeHook(cwd, rl);
|
|
218
344
|
// --- Always run: .gitignore ---
|