@vitorcen/context-resume 1.0.0 → 1.0.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/adapters/index.js +3 -2
- package/dist/index.js +13 -2
- package/dist/ui/app.js +5 -2
- package/package.json +1 -1
package/dist/adapters/index.js
CHANGED
|
@@ -4,10 +4,11 @@ import { glob } from 'glob';
|
|
|
4
4
|
import os from 'os';
|
|
5
5
|
// --- Claude Adapter ---
|
|
6
6
|
function getClaudeEncodedPath(projectPath) {
|
|
7
|
-
// Claude encodes paths by replacing
|
|
7
|
+
// Claude encodes paths by replacing /, ., and _ with -
|
|
8
8
|
// e.g. /home/user/project -> -home-user-project
|
|
9
9
|
// e.g. /path/v1.0 -> -path-v1-0
|
|
10
|
-
|
|
10
|
+
// e.g. /home/work_ro -> -home-work-ro
|
|
11
|
+
return projectPath.replace(/[\/\._]/g, '-');
|
|
11
12
|
}
|
|
12
13
|
export async function getClaudeSessions(cwd, limit = 10) {
|
|
13
14
|
const homeDir = os.homedir();
|
package/dist/index.js
CHANGED
|
@@ -3,16 +3,27 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import { render } from 'ink';
|
|
5
5
|
import App from './ui/app.js';
|
|
6
|
+
import { createRequire } from 'module';
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const { version } = require('../package.json');
|
|
6
9
|
const program = new Command();
|
|
7
10
|
program
|
|
8
11
|
.name('context')
|
|
9
12
|
.description('Context Resume CLI')
|
|
10
|
-
.version(
|
|
13
|
+
.version(version, '-v, --version');
|
|
11
14
|
program
|
|
12
15
|
.option('-n, --number <count>', 'Number of sessions to show per source (claude/codex)', '10')
|
|
13
16
|
.action(async (options) => {
|
|
14
17
|
const cwd = process.cwd();
|
|
15
18
|
const limit = parseInt(options.number, 10) || 10;
|
|
16
|
-
|
|
19
|
+
let selectionOutput = '';
|
|
20
|
+
const app = render(_jsx(App, { cwd: cwd, limit: limit, onSubmit: (output) => {
|
|
21
|
+
selectionOutput = output;
|
|
22
|
+
} }));
|
|
23
|
+
await app.waitUntilExit();
|
|
24
|
+
if (selectionOutput) {
|
|
25
|
+
app.clear();
|
|
26
|
+
process.stdout.write(selectionOutput);
|
|
27
|
+
}
|
|
17
28
|
});
|
|
18
29
|
program.parse(process.argv);
|
package/dist/ui/app.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useState, useEffect } from 'react';
|
|
|
3
3
|
import { Box, Text, useInput, useApp } from 'ink';
|
|
4
4
|
import SelectInput from 'ink-select-input';
|
|
5
5
|
import { getClaudeSessions, getCodexSessions } from '../adapters/index.js';
|
|
6
|
-
const App = ({ cwd, limit = 10 }) => {
|
|
6
|
+
const App = ({ cwd, limit = 10, onSubmit }) => {
|
|
7
7
|
const [claudeItems, setClaudeItems] = useState([]);
|
|
8
8
|
const [codexItems, setCodexItems] = useState([]);
|
|
9
9
|
const [activePanel, setActivePanel] = useState('claude');
|
|
@@ -21,6 +21,9 @@ const App = ({ cwd, limit = 10 }) => {
|
|
|
21
21
|
if (key.rightArrow && activePanel === 'claude') {
|
|
22
22
|
setActivePanel('codex');
|
|
23
23
|
}
|
|
24
|
+
if (key.escape) {
|
|
25
|
+
exit();
|
|
26
|
+
}
|
|
24
27
|
});
|
|
25
28
|
useEffect(() => {
|
|
26
29
|
const loadSessions = async () => {
|
|
@@ -54,7 +57,7 @@ const App = ({ cwd, limit = 10 }) => {
|
|
|
54
57
|
const englishPrompt = `Here's a context file ${selectedItem.session.path} from the user's previous operations. Analyze what the user was doing. Then use TodoWrite to list what might be incomplete, and what needs to be done next (if mentioned in the context), otherwise wait for user instructions.`;
|
|
55
58
|
const chinesePrompt = `这里有份上下文 ${selectedItem.session.path} ,是用户曾经的操作。你分析下用户在做什么。然后用TodoWrite列出可能没做完的事情,和接下来要的事情(如果上下文中有提到),如果没有就等待用户指令。`;
|
|
56
59
|
const output = `\n\n${englishPrompt}\n\n${chinesePrompt}\n\n`;
|
|
57
|
-
|
|
60
|
+
onSubmit?.(output);
|
|
58
61
|
exit();
|
|
59
62
|
};
|
|
60
63
|
const handleHighlightClaude = (item) => setActiveClaudeItem(item);
|
package/package.json
CHANGED